Mercurial > pidgin.yaz
comparison src/protocols/oscar/family_admin.c @ 13592:6519aeb66b31
[gaim-migrate @ 15978]
Holy cow this is crazy.
34 files changed, 5760 insertions(+), 8517 deletions(-)
* Non-blocking I/O for all of oscar. That includes normal FLAP
connections as well as file transfers and direct IM.
* Kick-ass file transfer and direct IM. Either party can request
the connection. Gaim will try both the "public" IP and the
"client" IP. It'll fall back to transferring through a proxy
if that fails. Should be relatively few memleaks (I didn't
have a lot of confidence in the non-memleakiness of the old
code). And the code is reasonably generic, so it shouldn't
be too much work to add voice chat. This might still be a
LITTLE buggy, but it shouldn't be too bad. If anything, file
transfer will be more buggy than direct IM. And sending a
file will be more buggy than receiving a file. Bug reports
with a series of steps to reproduce are welcome.
* I merged OscarData and aim_session_t
* Somewhere between 50 and 100 hours of work.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Fri, 07 Apr 2006 05:10:56 +0000 |
parents | 87a7c3077c19 |
children | e9289db48a5d |
comparison
equal
deleted
inserted
replaced
13591:dcfda39ad547 | 13592:6519aeb66b31 |
---|---|
35 * 0x0001 - Screen name formatting | 35 * 0x0001 - Screen name formatting |
36 * 0x0011 - Email address | 36 * 0x0011 - Email address |
37 * 0x0013 - Unknown | 37 * 0x0013 - Unknown |
38 * | 38 * |
39 */ | 39 */ |
40 faim_export int aim_admin_getinfo(OscarSession *sess, OscarConnection *conn, guint16 info) | 40 int |
41 { | 41 aim_admin_getinfo(OscarData *od, FlapConnection *conn, guint16 info) |
42 FlapFrame *fr; | 42 { |
43 aim_snacid_t snacid; | 43 FlapFrame *fr; |
44 | 44 aim_snacid_t snacid; |
45 if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 14))) | 45 |
46 return -ENOMEM; | 46 fr = flap_frame_new(od, 0x02, 14); |
47 | 47 |
48 snacid = aim_cachesnac(sess, 0x0007, 0x0002, 0x0000, NULL, 0); | 48 snacid = aim_cachesnac(od, 0x0007, 0x0002, 0x0000, NULL, 0); |
49 aim_putsnac(&fr->data, 0x0007, 0x0002, 0x0000, snacid); | 49 aim_putsnac(&fr->data, 0x0007, 0x0002, 0x0000, snacid); |
50 | 50 |
51 aimbs_put16(&fr->data, info); | 51 byte_stream_put16(&fr->data, info); |
52 aimbs_put16(&fr->data, 0x0000); | 52 byte_stream_put16(&fr->data, 0x0000); |
53 | 53 |
54 aim_tx_enqueue(sess, fr); | 54 flap_connection_send(conn, fr); |
55 | 55 |
56 return 0; | 56 return 0; |
57 } | 57 } |
58 | 58 |
59 /* | 59 /* |
61 * | 61 * |
62 * Called in reply to both an information request (subtype 0x0002) and | 62 * Called in reply to both an information request (subtype 0x0002) and |
63 * an information change (subtype 0x0004). | 63 * an information change (subtype 0x0004). |
64 * | 64 * |
65 */ | 65 */ |
66 static int infochange(OscarSession *sess, aim_module_t *mod, FlapFrame *rx, aim_modsnac_t *snac, ByteStream *bs) | 66 static int |
67 infochange(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) | |
67 { | 68 { |
68 aim_rxcallback_t userfunc; | 69 aim_rxcallback_t userfunc; |
69 char *url=NULL, *sn=NULL, *email=NULL; | 70 char *url=NULL, *sn=NULL, *email=NULL; |
70 guint16 perms, tlvcount, err=0; | 71 guint16 perms, tlvcount, err=0; |
71 | 72 |
72 perms = aimbs_get16(bs); | 73 perms = byte_stream_get16(bs); |
73 tlvcount = aimbs_get16(bs); | 74 tlvcount = byte_stream_get16(bs); |
74 | 75 |
75 while (tlvcount && aim_bstream_empty(bs)) { | 76 while (tlvcount && byte_stream_empty(bs)) { |
76 guint16 type, length; | 77 guint16 type, length; |
77 | 78 |
78 type = aimbs_get16(bs); | 79 type = byte_stream_get16(bs); |
79 length = aimbs_get16(bs); | 80 length = byte_stream_get16(bs); |
80 | 81 |
81 switch (type) { | 82 switch (type) { |
82 case 0x0001: { | 83 case 0x0001: { |
83 sn = aimbs_getstr(bs, length); | 84 sn = byte_stream_getstr(bs, length); |
84 } break; | 85 } break; |
85 | 86 |
86 case 0x0004: { | 87 case 0x0004: { |
87 url = aimbs_getstr(bs, length); | 88 url = byte_stream_getstr(bs, length); |
88 } break; | 89 } break; |
89 | 90 |
90 case 0x0008: { | 91 case 0x0008: { |
91 err = aimbs_get16(bs); | 92 err = byte_stream_get16(bs); |
92 } break; | 93 } break; |
93 | 94 |
94 case 0x0011: { | 95 case 0x0011: { |
95 if (length == 0) { | 96 if (length == 0) |
96 email = (char*)malloc(13*sizeof(char)); | 97 email = g_strdup("*suppressed"); |
97 strcpy(email, "*suppressed*"); | 98 else |
98 } else | 99 email = byte_stream_getstr(bs, length); |
99 email = aimbs_getstr(bs, length); | |
100 } break; | 100 } break; |
101 } | 101 } |
102 | 102 |
103 tlvcount--; | 103 tlvcount--; |
104 } | 104 } |
105 | 105 |
106 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | 106 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) |
107 userfunc(sess, rx, (snac->subtype == 0x0005) ? 1 : 0, perms, err, url, sn, email); | 107 userfunc(od, conn, frame, (snac->subtype == 0x0005) ? 1 : 0, perms, err, url, sn, email); |
108 | 108 |
109 free(sn); | 109 free(sn); |
110 free(url); | 110 free(url); |
111 free(email); | 111 free(email); |
112 | 112 |
115 | 115 |
116 /* | 116 /* |
117 * Subtype 0x0004 - Set screenname formatting. | 117 * Subtype 0x0004 - Set screenname formatting. |
118 * | 118 * |
119 */ | 119 */ |
120 faim_export int aim_admin_setnick(OscarSession *sess, OscarConnection *conn, const char *newnick) | 120 int |
121 aim_admin_setnick(OscarData *od, FlapConnection *conn, const char *newnick) | |
121 { | 122 { |
122 FlapFrame *fr; | 123 FlapFrame *fr; |
123 aim_snacid_t snacid; | 124 aim_snacid_t snacid; |
124 aim_tlvlist_t *tl = NULL; | 125 aim_tlvlist_t *tl = NULL; |
125 | 126 |
126 if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+2+2+strlen(newnick)))) | 127 fr = flap_frame_new(od, 0x02, 10+2+2+strlen(newnick)); |
127 return -ENOMEM; | 128 return -ENOMEM; |
128 | 129 |
129 snacid = aim_cachesnac(sess, 0x0007, 0x0004, 0x0000, NULL, 0); | 130 snacid = aim_cachesnac(od, 0x0007, 0x0004, 0x0000, NULL, 0); |
130 aim_putsnac(&fr->data, 0x0007, 0x0004, 0x0000, snacid); | 131 aim_putsnac(&fr->data, 0x0007, 0x0004, 0x0000, snacid); |
131 | 132 |
132 aim_tlvlist_add_str(&tl, 0x0001, newnick); | 133 aim_tlvlist_add_str(&tl, 0x0001, newnick); |
133 | 134 |
134 aim_tlvlist_write(&fr->data, &tl); | 135 aim_tlvlist_write(&fr->data, &tl); |
135 aim_tlvlist_free(&tl); | 136 aim_tlvlist_free(&tl); |
136 | 137 |
137 aim_tx_enqueue(sess, fr); | 138 flap_connection_send(conn, fr); |
138 | 139 |
139 | 140 |
140 return 0; | 141 return 0; |
141 } | 142 } |
142 | 143 |
143 /* | 144 /* |
144 * Subtype 0x0004 - Change password. | 145 * Subtype 0x0004 - Change password. |
145 * | 146 * |
146 */ | 147 */ |
147 faim_export int aim_admin_changepasswd(OscarSession *sess, OscarConnection *conn, const char *newpw, const char *curpw) | 148 int |
149 aim_admin_changepasswd(OscarData *od, FlapConnection *conn, const char *newpw, const char *curpw) | |
148 { | 150 { |
149 FlapFrame *fr; | 151 FlapFrame *fr; |
150 aim_tlvlist_t *tl = NULL; | 152 aim_tlvlist_t *tl = NULL; |
151 aim_snacid_t snacid; | 153 aim_snacid_t snacid; |
152 | 154 |
153 if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+4+strlen(curpw)+4+strlen(newpw)))) | 155 fr = flap_frame_new(od, 0x02, 10+4+strlen(curpw)+4+strlen(newpw)); |
154 return -ENOMEM; | 156 |
155 | 157 snacid = aim_cachesnac(od, 0x0007, 0x0004, 0x0000, NULL, 0); |
156 snacid = aim_cachesnac(sess, 0x0007, 0x0004, 0x0000, NULL, 0); | |
157 aim_putsnac(&fr->data, 0x0007, 0x0004, 0x0000, snacid); | 158 aim_putsnac(&fr->data, 0x0007, 0x0004, 0x0000, snacid); |
158 | 159 |
159 /* new password TLV t(0002) */ | 160 /* new password TLV t(0002) */ |
160 aim_tlvlist_add_str(&tl, 0x0002, newpw); | 161 aim_tlvlist_add_str(&tl, 0x0002, newpw); |
161 | 162 |
163 aim_tlvlist_add_str(&tl, 0x0012, curpw); | 164 aim_tlvlist_add_str(&tl, 0x0012, curpw); |
164 | 165 |
165 aim_tlvlist_write(&fr->data, &tl); | 166 aim_tlvlist_write(&fr->data, &tl); |
166 aim_tlvlist_free(&tl); | 167 aim_tlvlist_free(&tl); |
167 | 168 |
168 aim_tx_enqueue(sess, fr); | 169 flap_connection_send(conn, fr); |
169 | 170 |
170 return 0; | 171 return 0; |
171 } | 172 } |
172 | 173 |
173 /* | 174 /* |
174 * Subtype 0x0004 - Change email address. | 175 * Subtype 0x0004 - Change email address. |
175 * | 176 * |
176 */ | 177 */ |
177 faim_export int aim_admin_setemail(OscarSession *sess, OscarConnection *conn, const char *newemail) | 178 int |
179 aim_admin_setemail(OscarData *od, FlapConnection *conn, const char *newemail) | |
178 { | 180 { |
179 FlapFrame *fr; | 181 FlapFrame *fr; |
180 aim_snacid_t snacid; | 182 aim_snacid_t snacid; |
181 aim_tlvlist_t *tl = NULL; | 183 aim_tlvlist_t *tl = NULL; |
182 | 184 |
183 if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+2+2+strlen(newemail)))) | 185 flap_frame_new(od, 0x02, 10+2+2+strlen(newemail)); |
184 return -ENOMEM; | 186 |
185 | 187 snacid = aim_cachesnac(od, 0x0007, 0x0004, 0x0000, NULL, 0); |
186 snacid = aim_cachesnac(sess, 0x0007, 0x0004, 0x0000, NULL, 0); | |
187 aim_putsnac(&fr->data, 0x0007, 0x0004, 0x0000, snacid); | 188 aim_putsnac(&fr->data, 0x0007, 0x0004, 0x0000, snacid); |
188 | 189 |
189 aim_tlvlist_add_str(&tl, 0x0011, newemail); | 190 aim_tlvlist_add_str(&tl, 0x0011, newemail); |
190 | 191 |
191 aim_tlvlist_write(&fr->data, &tl); | 192 aim_tlvlist_write(&fr->data, &tl); |
192 aim_tlvlist_free(&tl); | 193 aim_tlvlist_free(&tl); |
193 | 194 |
194 aim_tx_enqueue(sess, fr); | 195 flap_connection_send(conn, fr); |
195 | 196 |
196 return 0; | 197 return 0; |
197 } | 198 } |
198 | 199 |
199 /* | 200 /* |
202 * This will cause an email to be sent to the address associated with | 203 * This will cause an email to be sent to the address associated with |
203 * the account. By following the instructions in the mail, you can | 204 * the account. By following the instructions in the mail, you can |
204 * get the TRIAL flag removed from your account. | 205 * get the TRIAL flag removed from your account. |
205 * | 206 * |
206 */ | 207 */ |
207 faim_export int aim_admin_reqconfirm(OscarSession *sess, OscarConnection *conn) | 208 int |
208 { | 209 aim_admin_reqconfirm(OscarData *od, FlapConnection *conn) |
209 return aim_genericreq_n(sess, conn, 0x0007, 0x0006); | 210 { |
211 return aim_genericreq_n(od, conn, 0x0007, 0x0006); | |
210 } | 212 } |
211 | 213 |
212 /* | 214 /* |
213 * Subtype 0x0007 - Account confirmation request acknowledgement. | 215 * Subtype 0x0007 - Account confirmation request acknowledgement. |
214 * | 216 * |
215 */ | 217 */ |
216 static int accountconfirm(OscarSession *sess, aim_module_t *mod, FlapFrame *rx, aim_modsnac_t *snac, ByteStream *bs) | 218 static int |
219 accountconfirm(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) | |
217 { | 220 { |
218 int ret = 0; | 221 int ret = 0; |
219 aim_rxcallback_t userfunc; | 222 aim_rxcallback_t userfunc; |
220 guint16 status; | 223 guint16 status; |
221 aim_tlvlist_t *tl; | 224 aim_tlvlist_t *tl; |
222 | 225 |
223 status = aimbs_get16(bs); | 226 status = byte_stream_get16(bs); |
224 /* This is 0x0013 if unable to confirm at this time */ | 227 /* This is 0x0013 if unable to confirm at this time */ |
225 | 228 |
226 tl = aim_tlvlist_read(bs); | 229 tl = aim_tlvlist_read(bs); |
227 | 230 |
228 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | 231 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) |
229 ret = userfunc(sess, rx, status); | 232 ret = userfunc(od, conn, frame, status); |
230 | 233 |
231 return ret; | 234 return ret; |
232 } | 235 } |
233 | 236 |
234 static int snachandler(OscarSession *sess, aim_module_t *mod, FlapFrame *rx, aim_modsnac_t *snac, ByteStream *bs) | 237 static int |
235 { | 238 snachandler(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) |
236 | 239 { |
237 if ((snac->subtype == 0x0003) || (snac->subtype == 0x0005)) | 240 if ((snac->subtype == 0x0003) || (snac->subtype == 0x0005)) |
238 return infochange(sess, mod, rx, snac, bs); | 241 return infochange(od, conn, mod, frame, snac, bs); |
239 else if (snac->subtype == 0x0007) | 242 else if (snac->subtype == 0x0007) |
240 return accountconfirm(sess, mod, rx, snac, bs); | 243 return accountconfirm(od, conn, mod, frame, snac, bs); |
241 | 244 |
242 return 0; | 245 return 0; |
243 } | 246 } |
244 | 247 |
245 faim_internal int admin_modfirst(OscarSession *sess, aim_module_t *mod) | 248 int admin_modfirst(OscarData *od, aim_module_t *mod) |
246 { | 249 { |
247 | |
248 mod->family = 0x0007; | 250 mod->family = 0x0007; |
249 mod->version = 0x0001; | 251 mod->version = 0x0001; |
250 mod->toolid = 0x0010; | 252 mod->toolid = 0x0010; |
251 mod->toolversion = 0x0629; | 253 mod->toolversion = 0x0629; |
252 mod->flags = 0; | 254 mod->flags = 0; |