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