5 /* called for both reply and change-reply */
6 static int infochange(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
11 * unsigned short perms;
12 * unsigned short tlvcount;
13 * aim_tlv_t tlvs[tlvcount];
16 while (aim_bstream_empty(bs)) {
17 fu16_t perms, tlvcount;
19 perms = aimbs_get16(bs);
20 tlvcount = aimbs_get16(bs);
22 while (tlvcount && aim_bstream_empty(bs)) {
23 aim_rxcallback_t userfunc;
28 type = aimbs_get16(bs);
29 len = aimbs_get16(bs);
31 if ((type == 0x0011) || (type == 0x0004))
35 val = aimbs_getstr(bs, len);
37 val = aimbs_getraw(bs, len);
39 /* XXX fix so its only called once for the entire packet */
40 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
41 userfunc(sess, rx, (snac->subtype == 0x0005) ? 1 : 0, perms, type, len, val, str);
52 static int accountconfirm(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
54 aim_rxcallback_t userfunc;
57 status = aimbs_get16(bs);
59 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
60 return userfunc(sess, rx, status);
65 static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
68 if ((snac->subtype == 0x0003) || (snac->subtype == 0x0005))
69 return infochange(sess, mod, rx, snac, bs);
70 else if (snac->subtype == 0x0007)
71 return accountconfirm(sess, mod, rx, snac, bs);
76 faim_internal int admin_modfirst(aim_session_t *sess, aim_module_t *mod)
80 mod->version = 0x0000;
82 strncpy(mod->name, "admin", sizeof(mod->name));
83 mod->snachandler = snachandler;
88 faim_export int aim_auth_clientready(aim_session_t *sess, aim_conn_t *conn)
90 static const struct aim_tool_version tools[] = {
91 {0x0001, 0x0003, AIM_TOOL_NEWWIN, 0x0361},
92 {0x0007, 0x0001, AIM_TOOL_NEWWIN, 0x0361},
96 int toolcount = sizeof(tools) / sizeof(struct aim_tool_version);
99 if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x0002, 1152)))
102 snacid = aim_cachesnac(sess, 0x0001, 0x0002, 0x0000, NULL, 0);
103 aim_putsnac(&tx->data, 0x0001, 0x0002, 0x0000, snacid);
105 for (j = 0; j < toolcount; j++) {
106 aimbs_put16(&tx->data, tools[j].group);
107 aimbs_put16(&tx->data, tools[j].version);
108 aimbs_put16(&tx->data, tools[j].tool);
109 aimbs_put16(&tx->data, tools[j].toolversion);
112 aim_tx_enqueue(sess, tx);
117 faim_export int aim_auth_changepasswd(aim_session_t *sess, aim_conn_t *conn, const char *newpw, const char *curpw)
120 aim_tlvlist_t *tl = NULL;
123 if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+4+strlen(curpw)+4+strlen(newpw))))
126 snacid = aim_cachesnac(sess, 0x0007, 0x0004, 0x0000, NULL, 0);
127 aim_putsnac(&tx->data, 0x0007, 0x0004, 0x0000, snacid);
129 /* new password TLV t(0002) */
130 aim_addtlvtochain_raw(&tl, 0x0002, strlen(newpw), newpw);
132 /* current password TLV t(0012) */
133 aim_addtlvtochain_raw(&tl, 0x0012, strlen(curpw), curpw);
135 aim_writetlvchain(&tx->data, &tl);
136 aim_freetlvchain(&tl);
138 aim_tx_enqueue(sess, tx);
143 faim_export int aim_auth_setversions(aim_session_t *sess, aim_conn_t *conn)
148 if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 18)))
151 snacid = aim_cachesnac(sess, 0x0001, 0x0017, 0x0000, NULL, 0);
152 aim_putsnac(&tx->data, 0x0001, 0x0017, 0x0000, snacid);
154 aimbs_put16(&tx->data, 0x0001);
155 aimbs_put16(&tx->data, 0x0003);
157 aimbs_put16(&tx->data, 0x0007);
158 aimbs_put16(&tx->data, 0x0001);
160 aim_tx_enqueue(sess, tx);
166 * Request account confirmation.
168 * This will cause an email to be sent to the address associated with
169 * the account. By following the instructions in the mail, you can
170 * get the TRIAL flag removed from your account.
173 faim_export int aim_auth_reqconfirm(aim_session_t *sess, aim_conn_t *conn)
175 return aim_genericreq_n(sess, conn, 0x0007, 0x0006);
179 * Request a bit of account info.
181 * The only known valid tag is 0x0011 (email address).
184 faim_export int aim_auth_getinfo(aim_session_t *sess, aim_conn_t *conn, fu16_t info)
189 if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 14)))
192 snacid = aim_cachesnac(sess, 0x0002, 0x0002, 0x0000, NULL, 0);
193 aim_putsnac(&tx->data, 0x0007, 0x0002, 0x0000, snacid);
195 aimbs_put16(&tx->data, info);
196 aimbs_put16(&tx->data, 0x0000);
198 aim_tx_enqueue(sess, tx);
203 faim_export int aim_auth_setemail(aim_session_t *sess, aim_conn_t *conn, const char *newemail)
207 aim_tlvlist_t *tl = NULL;
209 if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+2+2+strlen(newemail))))
212 snacid = aim_cachesnac(sess, 0x0007, 0x0004, 0x0000, NULL, 0);
213 aim_putsnac(&tx->data, 0x0007, 0x0004, 0x0000, snacid);
215 aim_addtlvtochain_raw(&tl, 0x0011, strlen(newemail), newemail);
217 aim_writetlvchain(&tx->data, &tl);
218 aim_freetlvchain(&tl);
220 aim_tx_enqueue(sess, tx);