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)
8 #ifdef MID_FINALLY_REWROTE_ALL_THE_CRAP
13 * unsigned short perms;
14 * unsigned short tlvcount;
15 * aim_tlv_t tlvs[tlvcount];
18 for (i = 0; i < datalen; ) {
21 perms = aimutil_get16(data+i);
24 tlvcount = aimutil_get16(data+i);
28 aim_rxcallback_t userfunc;
32 if ((aimutil_get16(data+i) == 0x0011) ||
33 (aimutil_get16(data+i) == 0x0004))
37 tlv = aim_grabtlvstr(data+i);
39 tlv = aim_grabtlv(data+i);
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);
48 if (tlv && tlv->value)
56 #endif /* MID_FINALLY_REWROTE_ALL_THE_CRAP */
60 static int accountconfirm(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
62 aim_rxcallback_t userfunc;
65 status = aimbs_get16(bs);
67 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
68 return userfunc(sess, rx, status);
73 static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
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);
84 faim_internal int admin_modfirst(aim_session_t *sess, aim_module_t *mod)
88 mod->version = 0x0000;
90 strncpy(mod->name, "admin", sizeof(mod->name));
91 mod->snachandler = snachandler;
96 faim_export int aim_auth_clientready(aim_session_t *sess, aim_conn_t *conn)
98 static const struct aim_tool_version tools[] = {
99 {0x0001, 0x0003, AIM_TOOL_NEWWIN, 0x0361},
100 {0x0007, 0x0001, AIM_TOOL_NEWWIN, 0x0361},
104 int toolcount = sizeof(tools) / sizeof(struct aim_tool_version);
107 if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x0002, 1152)))
110 snacid = aim_cachesnac(sess, 0x0001, 0x0002, 0x0000, NULL, 0);
111 aim_putsnac(&tx->data, 0x0001, 0x0002, 0x0000, snacid);
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);
120 aim_tx_enqueue(sess, tx);
125 faim_export int aim_auth_changepasswd(aim_session_t *sess, aim_conn_t *conn, const char *newpw, const char *curpw)
128 aim_tlvlist_t *tl = NULL;
131 if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+4+strlen(curpw)+4+strlen(newpw))))
134 snacid = aim_cachesnac(sess, 0x0007, 0x0004, 0x0000, NULL, 0);
135 aim_putsnac(&tx->data, 0x0007, 0x0004, 0x0000, snacid);
137 /* new password TLV t(0002) */
138 aim_addtlvtochain_raw(&tl, 0x0002, strlen(newpw), newpw);
140 /* current password TLV t(0012) */
141 aim_addtlvtochain_raw(&tl, 0x0012, strlen(curpw), curpw);
143 aim_writetlvchain(&tx->data, &tl);
144 aim_freetlvchain(&tl);
146 aim_tx_enqueue(sess, tx);
151 faim_export int aim_auth_setversions(aim_session_t *sess, aim_conn_t *conn)
156 if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 18)))
159 snacid = aim_cachesnac(sess, 0x0001, 0x0017, 0x0000, NULL, 0);
160 aim_putsnac(&tx->data, 0x0001, 0x0017, 0x0000, snacid);
162 aimbs_put16(&tx->data, 0x0001);
163 aimbs_put16(&tx->data, 0x0003);
165 aimbs_put16(&tx->data, 0x0007);
166 aimbs_put16(&tx->data, 0x0001);
168 aim_tx_enqueue(sess, tx);
174 * Request account confirmation.
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.
181 faim_export int aim_auth_reqconfirm(aim_session_t *sess, aim_conn_t *conn)
183 return aim_genericreq_n(sess, conn, 0x0007, 0x0006);
187 * Request a bit of account info.
189 * The only known valid tag is 0x0011 (email address).
192 faim_export int aim_auth_getinfo(aim_session_t *sess, aim_conn_t *conn, fu16_t info)
197 if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 14)))
200 snacid = aim_cachesnac(sess, 0x0002, 0x0002, 0x0000, NULL, 0);
201 aim_putsnac(&tx->data, 0x0007, 0x0002, 0x0000, snacid);
203 aimbs_put16(&tx->data, info);
204 aimbs_put16(&tx->data, 0x0000);
206 aim_tx_enqueue(sess, tx);
211 faim_export int aim_auth_setemail(aim_session_t *sess, aim_conn_t *conn, const char *newemail)
215 aim_tlvlist_t *tl = NULL;
217 if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+2+2+strlen(newemail))))
220 snacid = aim_cachesnac(sess, 0x0007, 0x0004, 0x0000, NULL, 0);
221 aim_putsnac(&tx->data, 0x0007, 0x0004, 0x0000, snacid);
223 aim_addtlvtochain_raw(&tl, 0x0011, strlen(newemail), newemail);
225 aim_writetlvchain(&tx->data, &tl);
226 aim_freetlvchain(&tl);
228 aim_tx_enqueue(sess, tx);