]> andersk Git - libfaim.git/blame_incremental - src/admin.c
- Sat Sep 8 00:55:46 PDT 2001
[libfaim.git] / src / admin.c
... / ...
CommitLineData
1
2#define FAIM_INTERNAL
3#include <aim.h>
4
5/* called for both reply and change-reply */
6static int infochange(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
7{
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;
58}
59
60static int accountconfirm(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
61{
62 aim_rxcallback_t userfunc;
63 fu16_t status;
64
65 status = aimbs_get16(bs);
66
67 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
68 return userfunc(sess, rx, status);
69
70 return 0;
71}
72
73static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
74{
75
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);
80
81 return 0;
82}
83
84faim_internal int admin_modfirst(aim_session_t *sess, aim_module_t *mod)
85{
86
87 mod->family = 0x0007;
88 mod->version = 0x0000;
89 mod->flags = 0;
90 strncpy(mod->name, "admin", sizeof(mod->name));
91 mod->snachandler = snachandler;
92
93 return 0;
94}
95
96faim_export int aim_auth_clientready(aim_session_t *sess, aim_conn_t *conn)
97{
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;
123}
124
125faim_export int aim_auth_changepasswd(aim_session_t *sess, aim_conn_t *conn, const char *newpw, const char *curpw)
126{
127 aim_frame_t *tx;
128 aim_tlvlist_t *tl = NULL;
129 aim_snacid_t snacid;
130
131 if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+4+strlen(curpw)+4+strlen(newpw))))
132 return -ENOMEM;
133
134 snacid = aim_cachesnac(sess, 0x0007, 0x0004, 0x0000, NULL, 0);
135 aim_putsnac(&tx->data, 0x0007, 0x0004, 0x0000, snacid);
136
137 /* new password TLV t(0002) */
138 aim_addtlvtochain_raw(&tl, 0x0002, strlen(newpw), newpw);
139
140 /* current password TLV t(0012) */
141 aim_addtlvtochain_raw(&tl, 0x0012, strlen(curpw), curpw);
142
143 aim_writetlvchain(&tx->data, &tl);
144 aim_freetlvchain(&tl);
145
146 aim_tx_enqueue(sess, tx);
147
148 return 0;
149}
150
151faim_export int aim_auth_setversions(aim_session_t *sess, aim_conn_t *conn)
152{
153 aim_frame_t *tx;
154 aim_snacid_t snacid;
155
156 if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 18)))
157 return -ENOMEM;
158
159 snacid = aim_cachesnac(sess, 0x0001, 0x0017, 0x0000, NULL, 0);
160 aim_putsnac(&tx->data, 0x0001, 0x0017, 0x0000, snacid);
161
162 aimbs_put16(&tx->data, 0x0001);
163 aimbs_put16(&tx->data, 0x0003);
164
165 aimbs_put16(&tx->data, 0x0007);
166 aimbs_put16(&tx->data, 0x0001);
167
168 aim_tx_enqueue(sess, tx);
169
170 return 0;
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 */
181faim_export int aim_auth_reqconfirm(aim_session_t *sess, aim_conn_t *conn)
182{
183 return aim_genericreq_n(sess, conn, 0x0007, 0x0006);
184}
185
186/*
187 * Request a bit of account info.
188 *
189 * The only known valid tag is 0x0011 (email address).
190 *
191 */
192faim_export int aim_auth_getinfo(aim_session_t *sess, aim_conn_t *conn, fu16_t info)
193{
194 aim_frame_t *tx;
195 aim_snacid_t snacid;
196
197 if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 14)))
198 return -ENOMEM;
199
200 snacid = aim_cachesnac(sess, 0x0002, 0x0002, 0x0000, NULL, 0);
201 aim_putsnac(&tx->data, 0x0007, 0x0002, 0x0000, snacid);
202
203 aimbs_put16(&tx->data, info);
204 aimbs_put16(&tx->data, 0x0000);
205
206 aim_tx_enqueue(sess, tx);
207
208 return 0;
209}
210
211faim_export int aim_auth_setemail(aim_session_t *sess, aim_conn_t *conn, const char *newemail)
212{
213 aim_frame_t *tx;
214 aim_snacid_t snacid;
215 aim_tlvlist_t *tl = NULL;
216
217 if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+2+2+strlen(newemail))))
218 return -ENOMEM;
219
220 snacid = aim_cachesnac(sess, 0x0007, 0x0004, 0x0000, NULL, 0);
221 aim_putsnac(&tx->data, 0x0007, 0x0004, 0x0000, snacid);
222
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);
229
230 return 0;
231}
This page took 0.047445 seconds and 5 git commands to generate.