Mercurial > pidgin
annotate libfaim/admin.c @ 2042:d5033540df18
[gaim-migrate @ 2052]
i finally made up my mind about this. if you're specifying --login then it shouldn't reorder them, because you might not want them to be in a different order.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sat, 16 Jun 2001 19:53:23 +0000 |
parents | 109cacf1ff97 |
children |
rev | line source |
---|---|
1649 | 1 |
2 #define FAIM_INTERNAL | |
3 #include <aim.h> | |
4 | |
5 /* called for both reply and change-reply */ | |
6 static int infochange(struct aim_session_t *sess, aim_module_t *mod, struct command_rx_struct *rx, aim_modsnac_t *snac, unsigned char *data, int datalen) | |
7 { | |
8 int i; | |
9 | |
10 /* | |
11 * struct { | |
12 * unsigned short perms; | |
13 * unsigned short tlvcount; | |
14 * aim_tlv_t tlvs[tlvcount]; | |
15 * } admin_info[n]; | |
16 */ | |
17 for (i = 0; i < datalen; ) { | |
18 int perms, tlvcount; | |
19 | |
20 perms = aimutil_get16(data+i); | |
21 i += 2; | |
22 | |
23 tlvcount = aimutil_get16(data+i); | |
24 i += 2; | |
25 | |
26 while (tlvcount) { | |
1839
109cacf1ff97
[gaim-migrate @ 1849]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1649
diff
changeset
|
27 aim_rxcallback_t userfunc; |
1649 | 28 struct aim_tlv_t *tlv; |
29 int str = 0; | |
30 | |
31 if ((aimutil_get16(data+i) == 0x0011) || | |
32 (aimutil_get16(data+i) == 0x0004)) | |
33 str = 1; | |
34 | |
35 if (str) | |
36 tlv = aim_grabtlvstr(data+i); | |
37 else | |
38 tlv = aim_grabtlv(data+i); | |
39 | |
40 /* XXX fix so its only called once for the entire packet */ | |
41 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | |
42 userfunc(sess, rx, perms, tlv->type, tlv->length, tlv->value, str); | |
43 | |
44 if (tlv) | |
45 i += 2+2+tlv->length; | |
46 | |
47 if (tlv && tlv->value) | |
48 free(tlv->value); | |
49 if (tlv) | |
50 free(tlv); | |
51 | |
52 tlvcount--; | |
53 } | |
54 } | |
55 | |
56 return 1; | |
57 } | |
58 | |
59 static int accountconfirm(struct aim_session_t *sess, aim_module_t *mod, struct command_rx_struct *rx, aim_modsnac_t *snac, unsigned char *data, int datalen) | |
60 { | |
1839
109cacf1ff97
[gaim-migrate @ 1849]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1649
diff
changeset
|
61 aim_rxcallback_t userfunc; |
1649 | 62 int status; |
63 | |
64 status = aimutil_get16(data); | |
65 | |
66 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | |
67 return userfunc(sess, rx, status); | |
68 | |
69 return 0; | |
70 } | |
71 | |
72 static int snachandler(struct aim_session_t *sess, aim_module_t *mod, struct command_rx_struct *rx, aim_modsnac_t *snac, unsigned char *data, int datalen) | |
73 { | |
74 | |
75 if ((snac->subtype == 0x0003) || (snac->subtype == 0x0005)) | |
76 return infochange(sess, mod, rx, snac, data, datalen); | |
77 else if (snac->subtype == 0x0007) | |
78 return accountconfirm(sess, mod, rx, snac, data, datalen); | |
79 | |
80 return 0; | |
81 } | |
82 | |
83 faim_internal int admin_modfirst(struct aim_session_t *sess, aim_module_t *mod) | |
84 { | |
85 | |
86 mod->family = 0x0007; | |
87 mod->version = 0x0000; | |
88 mod->flags = 0; | |
89 strncpy(mod->name, "admin", sizeof(mod->name)); | |
90 mod->snachandler = snachandler; | |
91 | |
92 return 0; | |
93 } | |
94 | |
95 faim_export unsigned long aim_auth_clientready(struct aim_session_t *sess, | |
96 struct aim_conn_t *conn) | |
97 { | |
98 struct aim_tool_version tools[] = { | |
99 {0x0001, 0x0003, AIM_TOOL_NEWWIN, 0x0361}, | |
100 {0x0007, 0x0001, AIM_TOOL_NEWWIN, 0x0361}, | |
101 }; | |
102 int i,j; | |
103 struct command_tx_struct *newpacket; | |
104 int toolcount = sizeof(tools)/sizeof(struct aim_tool_version); | |
105 | |
106 if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 1152))) | |
107 return -1; | |
108 | |
109 newpacket->lock = 1; | |
110 | |
111 i = aim_putsnac(newpacket->data, 0x0001, 0x0002, 0x0000, sess->snac_nextid); | |
112 aim_cachesnac(sess, 0x0001, 0x0002, 0x0000, NULL, 0); | |
113 | |
114 for (j = 0; j < toolcount; j++) { | |
115 i += aimutil_put16(newpacket->data+i, tools[j].group); | |
116 i += aimutil_put16(newpacket->data+i, tools[j].version); | |
117 i += aimutil_put16(newpacket->data+i, tools[j].tool); | |
118 i += aimutil_put16(newpacket->data+i, tools[j].toolversion); | |
119 } | |
120 | |
121 newpacket->commandlen = i; | |
122 newpacket->lock = 0; | |
123 | |
124 aim_tx_enqueue(sess, newpacket); | |
125 | |
126 return sess->snac_nextid; | |
127 } | |
128 | |
129 faim_export unsigned long aim_auth_changepasswd(struct aim_session_t *sess, | |
130 struct aim_conn_t *conn, | |
131 char *new, char *current) | |
132 { | |
133 struct command_tx_struct *newpacket; | |
134 int i; | |
135 | |
136 if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10+4+strlen(current)+4+strlen(new)))) | |
137 return -1; | |
138 | |
139 newpacket->lock = 1; | |
140 | |
141 i = aim_putsnac(newpacket->data, 0x0007, 0x0004, 0x0000, sess->snac_nextid); | |
142 aim_cachesnac(sess, 0x0007, 0x0004, 0x0000, NULL, 0); | |
143 | |
144 /* new password TLV t(0002) */ | |
145 i += aim_puttlv_str(newpacket->data+i, 0x0002, strlen(new), new); | |
146 | |
147 /* current password TLV t(0012) */ | |
148 i += aim_puttlv_str(newpacket->data+i, 0x0012, strlen(current), current); | |
149 | |
150 aim_tx_enqueue(sess, newpacket); | |
151 | |
152 return sess->snac_nextid; | |
153 } | |
154 | |
155 faim_export unsigned long aim_auth_setversions(struct aim_session_t *sess, | |
156 struct aim_conn_t *conn) | |
157 { | |
158 struct command_tx_struct *newpacket; | |
159 int i; | |
160 | |
161 if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10 + (4*2)))) | |
162 return -1; | |
163 | |
164 newpacket->lock = 1; | |
165 | |
166 i = aim_putsnac(newpacket->data, 0x0001, 0x0017, 0x0000, sess->snac_nextid); | |
167 aim_cachesnac(sess, 0x0001, 0x0017, 0x0000, NULL, 0); | |
168 | |
169 i += aimutil_put16(newpacket->data+i, 0x0001); | |
170 i += aimutil_put16(newpacket->data+i, 0x0003); | |
171 | |
172 i += aimutil_put16(newpacket->data+i, 0x0007); | |
173 i += aimutil_put16(newpacket->data+i, 0x0001); | |
174 | |
175 newpacket->commandlen = i; | |
176 newpacket->lock = 0; | |
177 aim_tx_enqueue(sess, newpacket); | |
178 | |
179 return sess->snac_nextid; | |
180 } | |
181 | |
182 /* | |
183 * Request account confirmation. | |
184 * | |
185 * This will cause an email to be sent to the address associated with | |
186 * the account. By following the instructions in the mail, you can | |
187 * get the TRIAL flag removed from your account. | |
188 * | |
189 */ | |
190 faim_export unsigned long aim_auth_reqconfirm(struct aim_session_t *sess, | |
191 struct aim_conn_t *conn) | |
192 { | |
193 return aim_genericreq_n(sess, conn, 0x0007, 0x0006); | |
194 } | |
195 | |
196 /* | |
197 * Request a bit of account info. | |
198 * | |
199 * The only known valid tag is 0x0011 (email address). | |
200 * | |
201 */ | |
202 faim_export unsigned long aim_auth_getinfo(struct aim_session_t *sess, | |
203 struct aim_conn_t *conn, | |
204 unsigned short info) | |
205 { | |
206 struct command_tx_struct *newpacket; | |
207 int i; | |
208 | |
209 if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10 + 4))) | |
210 return -1; | |
211 | |
212 newpacket->lock = 1; | |
213 | |
214 i = aim_putsnac(newpacket->data, 0x0007, 0x0002, 0x0000, sess->snac_nextid); | |
215 aim_cachesnac(sess, 0x0002, 0x0002, 0x0000, NULL, 0); | |
216 | |
217 i += aimutil_put16(newpacket->data+i, info); | |
218 i += aimutil_put16(newpacket->data+i, 0x0000); | |
219 | |
220 newpacket->commandlen = i; | |
221 newpacket->lock = 0; | |
222 aim_tx_enqueue(sess, newpacket); | |
223 | |
224 return sess->snac_nextid; | |
225 } | |
226 | |
227 faim_export unsigned long aim_auth_setemail(struct aim_session_t *sess, | |
228 struct aim_conn_t *conn, | |
229 char *newemail) | |
230 { | |
231 struct command_tx_struct *newpacket; | |
232 int i; | |
233 | |
234 if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10+2+2+strlen(newemail)))) | |
235 return -1; | |
236 | |
237 newpacket->lock = 1; | |
238 | |
239 i = aim_putsnac(newpacket->data, 0x0007, 0x0004, 0x0000, sess->snac_nextid); | |
240 aim_cachesnac(sess, 0x0007, 0x0004, 0x0000, NULL, 0); | |
241 | |
242 i += aim_puttlv_str(newpacket->data+i, 0x0011, strlen(newemail), newemail); | |
243 | |
244 aim_tx_enqueue(sess, newpacket); | |
245 | |
246 return sess->snac_nextid; | |
247 } |