]> andersk Git - libfaim.git/blame - src/admin.c
- Sat Sep 8 00:55:46 PDT 2001
[libfaim.git] / src / admin.c
CommitLineData
9f1a4013 1
2#define FAIM_INTERNAL
3#include <aim.h>
4
5/* called for both reply and change-reply */
d410cf58 6static int infochange(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
9f1a4013 7{
d410cf58 8#ifdef MID_FINALLY_REWROTE_ALL_THE_CRAP
9 int i;
10
11 /*
12 * struct {
13 * unsigned short perms;
14 * unsigned short tlvcount;
15 * aim_tlv_t tlvs[tlvcount];
16 * } admin_info[n];
17 */
18 for (i = 0; i < datalen; ) {
19 int perms, tlvcount;
20
21 perms = aimutil_get16(data+i);
22 i += 2;
23
24 tlvcount = aimutil_get16(data+i);
25 i += 2;
26
27 while (tlvcount) {
28 aim_rxcallback_t userfunc;
29 aim_tlv_t *tlv;
30 int str = 0;
31
32 if ((aimutil_get16(data+i) == 0x0011) ||
33 (aimutil_get16(data+i) == 0x0004))
34 str = 1;
35
36 if (str)
37 tlv = aim_grabtlvstr(data+i);
38 else
39 tlv = aim_grabtlv(data+i);
40
41 /* XXX fix so its only called once for the entire packet */
42 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
43 userfunc(sess, rx, perms, tlv->type, tlv->length, tlv->value, str);
44
45 if (tlv)
46 i += 2+2+tlv->length;
47
48 if (tlv && tlv->value)
49 free(tlv->value);
50 if (tlv)
51 free(tlv);
52
53 tlvcount--;
54 }
55 }
56#endif /* MID_FINALLY_REWROTE_ALL_THE_CRAP */
57 return 1;
9f1a4013 58}
59
d410cf58 60static int accountconfirm(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
9f1a4013 61{
d410cf58 62 aim_rxcallback_t userfunc;
63 fu16_t status;
9f1a4013 64
d410cf58 65 status = aimbs_get16(bs);
9f1a4013 66
d410cf58 67 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
68 return userfunc(sess, rx, status);
9f1a4013 69
d410cf58 70 return 0;
9f1a4013 71}
72
d410cf58 73static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
9f1a4013 74{
75
d410cf58 76 if ((snac->subtype == 0x0003) || (snac->subtype == 0x0005))
77 return infochange(sess, mod, rx, snac, bs);
78 else if (snac->subtype == 0x0007)
79 return accountconfirm(sess, mod, rx, snac, bs);
9f1a4013 80
d410cf58 81 return 0;
9f1a4013 82}
83
d410cf58 84faim_internal int admin_modfirst(aim_session_t *sess, aim_module_t *mod)
9f1a4013 85{
86
d410cf58 87 mod->family = 0x0007;
88 mod->version = 0x0000;
89 mod->flags = 0;
90 strncpy(mod->name, "admin", sizeof(mod->name));
91 mod->snachandler = snachandler;
9f1a4013 92
d410cf58 93 return 0;
9f1a4013 94}
95
d410cf58 96faim_export int aim_auth_clientready(aim_session_t *sess, aim_conn_t *conn)
9f1a4013 97{
d410cf58 98 static const struct aim_tool_version tools[] = {
99 {0x0001, 0x0003, AIM_TOOL_NEWWIN, 0x0361},
100 {0x0007, 0x0001, AIM_TOOL_NEWWIN, 0x0361},
101 };
102 int j;
103 aim_frame_t *tx;
104 int toolcount = sizeof(tools) / sizeof(struct aim_tool_version);
105 aim_snacid_t snacid;
106
107 if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x0002, 1152)))
108 return -ENOMEM;
109
110 snacid = aim_cachesnac(sess, 0x0001, 0x0002, 0x0000, NULL, 0);
111 aim_putsnac(&tx->data, 0x0001, 0x0002, 0x0000, snacid);
112
113 for (j = 0; j < toolcount; j++) {
114 aimbs_put16(&tx->data, tools[j].group);
115 aimbs_put16(&tx->data, tools[j].version);
116 aimbs_put16(&tx->data, tools[j].tool);
117 aimbs_put16(&tx->data, tools[j].toolversion);
118 }
119
120 aim_tx_enqueue(sess, tx);
121
122 return 0;
9f1a4013 123}
124
d410cf58 125faim_export int aim_auth_changepasswd(aim_session_t *sess, aim_conn_t *conn, const char *newpw, const char *curpw)
9f1a4013 126{
d410cf58 127 aim_frame_t *tx;
128 aim_tlvlist_t *tl = NULL;
129 aim_snacid_t snacid;
9f1a4013 130
d410cf58 131 if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+4+strlen(curpw)+4+strlen(newpw))))
132 return -ENOMEM;
9f1a4013 133
d410cf58 134 snacid = aim_cachesnac(sess, 0x0007, 0x0004, 0x0000, NULL, 0);
135 aim_putsnac(&tx->data, 0x0007, 0x0004, 0x0000, snacid);
9f1a4013 136
d410cf58 137 /* new password TLV t(0002) */
138 aim_addtlvtochain_raw(&tl, 0x0002, strlen(newpw), newpw);
9f1a4013 139
d410cf58 140 /* current password TLV t(0012) */
141 aim_addtlvtochain_raw(&tl, 0x0012, strlen(curpw), curpw);
9f1a4013 142
d410cf58 143 aim_writetlvchain(&tx->data, &tl);
144 aim_freetlvchain(&tl);
9f1a4013 145
d410cf58 146 aim_tx_enqueue(sess, tx);
9f1a4013 147
d410cf58 148 return 0;
9f1a4013 149}
150
d410cf58 151faim_export int aim_auth_setversions(aim_session_t *sess, aim_conn_t *conn)
9f1a4013 152{
d410cf58 153 aim_frame_t *tx;
154 aim_snacid_t snacid;
9f1a4013 155
d410cf58 156 if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 18)))
157 return -ENOMEM;
9f1a4013 158
d410cf58 159 snacid = aim_cachesnac(sess, 0x0001, 0x0017, 0x0000, NULL, 0);
160 aim_putsnac(&tx->data, 0x0001, 0x0017, 0x0000, snacid);
9f1a4013 161
d410cf58 162 aimbs_put16(&tx->data, 0x0001);
163 aimbs_put16(&tx->data, 0x0003);
9f1a4013 164
d410cf58 165 aimbs_put16(&tx->data, 0x0007);
166 aimbs_put16(&tx->data, 0x0001);
9f1a4013 167
d410cf58 168 aim_tx_enqueue(sess, tx);
9f1a4013 169
d410cf58 170 return 0;
9f1a4013 171}
172
173/*
174 * Request account confirmation.
175 *
176 * This will cause an email to be sent to the address associated with
177 * the account. By following the instructions in the mail, you can
178 * get the TRIAL flag removed from your account.
179 *
180 */
d410cf58 181faim_export int aim_auth_reqconfirm(aim_session_t *sess, aim_conn_t *conn)
9f1a4013 182{
d410cf58 183 return aim_genericreq_n(sess, conn, 0x0007, 0x0006);
9f1a4013 184}
185
186/*
187 * Request a bit of account info.
188 *
189 * The only known valid tag is 0x0011 (email address).
190 *
191 */
d410cf58 192faim_export int aim_auth_getinfo(aim_session_t *sess, aim_conn_t *conn, fu16_t info)
9f1a4013 193{
d410cf58 194 aim_frame_t *tx;
195 aim_snacid_t snacid;
9f1a4013 196
d410cf58 197 if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 14)))
198 return -ENOMEM;
9f1a4013 199
d410cf58 200 snacid = aim_cachesnac(sess, 0x0002, 0x0002, 0x0000, NULL, 0);
201 aim_putsnac(&tx->data, 0x0007, 0x0002, 0x0000, snacid);
9f1a4013 202
d410cf58 203 aimbs_put16(&tx->data, info);
204 aimbs_put16(&tx->data, 0x0000);
9f1a4013 205
d410cf58 206 aim_tx_enqueue(sess, tx);
9f1a4013 207
d410cf58 208 return 0;
9f1a4013 209}
210
d410cf58 211faim_export int aim_auth_setemail(aim_session_t *sess, aim_conn_t *conn, const char *newemail)
9f1a4013 212{
d410cf58 213 aim_frame_t *tx;
214 aim_snacid_t snacid;
215 aim_tlvlist_t *tl = NULL;
9f1a4013 216
d410cf58 217 if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+2+2+strlen(newemail))))
218 return -ENOMEM;
9f1a4013 219
d410cf58 220 snacid = aim_cachesnac(sess, 0x0007, 0x0004, 0x0000, NULL, 0);
221 aim_putsnac(&tx->data, 0x0007, 0x0004, 0x0000, snacid);
9f1a4013 222
d410cf58 223 aim_addtlvtochain_raw(&tl, 0x0011, strlen(newemail), newemail);
224
225 aim_writetlvchain(&tx->data, &tl);
226 aim_freetlvchain(&tl);
227
228 aim_tx_enqueue(sess, tx);
9f1a4013 229
d410cf58 230 return 0;
9f1a4013 231}
This page took 0.153672 seconds and 5 git commands to generate.