Mercurial > pidgin
comparison src/protocols/oscar/family_buddy.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 | 5796551db930 |
comparison
equal
deleted
inserted
replaced
13591:dcfda39ad547 | 13592:6519aeb66b31 |
---|---|
31 * Subtype 0x0002 - Request rights. | 31 * Subtype 0x0002 - Request rights. |
32 * | 32 * |
33 * Request Buddy List rights. | 33 * Request Buddy List rights. |
34 * | 34 * |
35 */ | 35 */ |
36 faim_export int aim_buddylist_reqrights(OscarSession *sess, OscarConnection *conn) | 36 int |
37 { | 37 aim_buddylist_reqrights(OscarData *od, FlapConnection *conn) |
38 return aim_genericreq_n_snacid(sess, conn, 0x0003, 0x0002); | 38 { |
39 return aim_genericreq_n_snacid(od, conn, 0x0003, 0x0002); | |
39 } | 40 } |
40 | 41 |
41 /* | 42 /* |
42 * Subtype 0x0003 - Rights. | 43 * Subtype 0x0003 - Rights. |
43 * | 44 * |
44 */ | 45 */ |
45 static int rights(OscarSession *sess, aim_module_t *mod, FlapFrame *rx, aim_modsnac_t *snac, ByteStream *bs) | 46 static int |
47 rights(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) | |
46 { | 48 { |
47 aim_rxcallback_t userfunc; | 49 aim_rxcallback_t userfunc; |
48 aim_tlvlist_t *tlvlist; | 50 aim_tlvlist_t *tlvlist; |
49 guint16 maxbuddies = 0, maxwatchers = 0; | 51 guint16 maxbuddies = 0, maxwatchers = 0; |
50 int ret = 0; | 52 int ret = 0; |
75 * TLV type 0x0003: Unknown. | 77 * TLV type 0x0003: Unknown. |
76 * | 78 * |
77 * ICQ only? | 79 * ICQ only? |
78 */ | 80 */ |
79 | 81 |
80 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | 82 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) |
81 ret = userfunc(sess, rx, maxbuddies, maxwatchers); | 83 ret = userfunc(od, conn, frame, maxbuddies, maxwatchers); |
82 | 84 |
83 aim_tlvlist_free(&tlvlist); | 85 aim_tlvlist_free(&tlvlist); |
84 | 86 |
85 return ret; | 87 return ret; |
86 } | 88 } |
90 * | 92 * |
91 * Adds a single buddy to your buddy list after login. | 93 * Adds a single buddy to your buddy list after login. |
92 * XXX This should just be an extension of setbuddylist() | 94 * XXX This should just be an extension of setbuddylist() |
93 * | 95 * |
94 */ | 96 */ |
95 faim_export int aim_buddylist_addbuddy(OscarSession *sess, OscarConnection *conn, const char *sn) | 97 int |
96 { | 98 aim_buddylist_addbuddy(OscarData *od, FlapConnection *conn, const char *sn) |
97 FlapFrame *fr; | 99 { |
100 FlapFrame *frame; | |
98 aim_snacid_t snacid; | 101 aim_snacid_t snacid; |
99 | 102 |
100 if (!sn || !strlen(sn)) | 103 if (!sn || !strlen(sn)) |
101 return -EINVAL; | 104 return -EINVAL; |
102 | 105 |
103 if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+1+strlen(sn)))) | 106 frame = flap_frame_new(od, 0x02, 10+1+strlen(sn)); |
104 return -ENOMEM; | 107 |
105 | 108 snacid = aim_cachesnac(od, 0x0003, 0x0004, 0x0000, sn, strlen(sn)+1); |
106 snacid = aim_cachesnac(sess, 0x0003, 0x0004, 0x0000, sn, strlen(sn)+1); | 109 aim_putsnac(&frame->data, 0x0003, 0x0004, 0x0000, snacid); |
107 aim_putsnac(&fr->data, 0x0003, 0x0004, 0x0000, snacid); | 110 |
108 | 111 byte_stream_put8(&frame->data, strlen(sn)); |
109 aimbs_put8(&fr->data, strlen(sn)); | 112 byte_stream_putstr(&frame->data, sn); |
110 aimbs_putstr(&fr->data, sn); | 113 |
111 | 114 flap_connection_send(conn, frame); |
112 aim_tx_enqueue(sess, fr); | |
113 | 115 |
114 return 0; | 116 return 0; |
115 } | 117 } |
116 | 118 |
117 /* | 119 /* |
122 * buddy_list = "Screen Name One&ScreenNameTwo&"; | 124 * buddy_list = "Screen Name One&ScreenNameTwo&"; |
123 * | 125 * |
124 * XXX Clean this up. | 126 * XXX Clean this up. |
125 * | 127 * |
126 */ | 128 */ |
127 faim_export int aim_buddylist_set(OscarSession *sess, OscarConnection *conn, const char *buddy_list) | 129 int |
128 { | 130 aim_buddylist_set(OscarData *od, FlapConnection *conn, const char *buddy_list) |
129 FlapFrame *fr; | 131 { |
132 FlapFrame *frame; | |
130 aim_snacid_t snacid; | 133 aim_snacid_t snacid; |
131 int len = 0; | 134 int len = 0; |
132 char *localcpy = NULL; | 135 char *localcpy = NULL; |
133 char *tmpptr = NULL; | 136 char *tmpptr = NULL; |
134 | 137 |
139 gaim_debug_misc("oscar", "---adding: %s (%d)\n", tmpptr, strlen(tmpptr)); | 142 gaim_debug_misc("oscar", "---adding: %s (%d)\n", tmpptr, strlen(tmpptr)); |
140 len += 1 + strlen(tmpptr); | 143 len += 1 + strlen(tmpptr); |
141 tmpptr = strtok(NULL, "&"); | 144 tmpptr = strtok(NULL, "&"); |
142 } | 145 } |
143 | 146 |
144 if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+len))) | 147 frame = flap_frame_new(od, 0x02, 10+len); |
145 return -ENOMEM; | 148 |
146 | 149 snacid = aim_cachesnac(od, 0x0003, 0x0004, 0x0000, NULL, 0); |
147 snacid = aim_cachesnac(sess, 0x0003, 0x0004, 0x0000, NULL, 0); | 150 aim_putsnac(&frame->data, 0x0003, 0x0004, 0x0000, snacid); |
148 aim_putsnac(&fr->data, 0x0003, 0x0004, 0x0000, snacid); | |
149 | 151 |
150 strncpy(localcpy, buddy_list, strlen(buddy_list) + 1); | 152 strncpy(localcpy, buddy_list, strlen(buddy_list) + 1); |
151 | 153 |
152 for (tmpptr = strtok(localcpy, "&"); tmpptr; ) { | 154 for (tmpptr = strtok(localcpy, "&"); tmpptr; ) { |
153 | 155 |
154 gaim_debug_misc("oscar", "---adding: %s (%d)\n", tmpptr, strlen(tmpptr)); | 156 gaim_debug_misc("oscar", "---adding: %s (%d)\n", tmpptr, strlen(tmpptr)); |
155 | 157 |
156 aimbs_put8(&fr->data, strlen(tmpptr)); | 158 byte_stream_put8(&frame->data, strlen(tmpptr)); |
157 aimbs_putstr(&fr->data, tmpptr); | 159 byte_stream_putstr(&frame->data, tmpptr); |
158 tmpptr = strtok(NULL, "&"); | 160 tmpptr = strtok(NULL, "&"); |
159 } | 161 } |
160 | 162 |
161 aim_tx_enqueue(sess, fr); | 163 flap_connection_send(conn, frame); |
162 | 164 |
163 free(localcpy); | 165 free(localcpy); |
164 | 166 |
165 return 0; | 167 return 0; |
166 } | 168 } |
170 * | 172 * |
171 * XXX generalise to support removing multiple buddies (basically, its | 173 * XXX generalise to support removing multiple buddies (basically, its |
172 * the same as setbuddylist() but with a different snac subtype). | 174 * the same as setbuddylist() but with a different snac subtype). |
173 * | 175 * |
174 */ | 176 */ |
175 faim_export int aim_buddylist_removebuddy(OscarSession *sess, OscarConnection *conn, const char *sn) | 177 int |
176 { | 178 aim_buddylist_removebuddy(OscarData *od, FlapConnection *conn, const char *sn) |
177 FlapFrame *fr; | 179 { |
180 FlapFrame *frame; | |
178 aim_snacid_t snacid; | 181 aim_snacid_t snacid; |
179 | 182 |
180 if (!sn || !strlen(sn)) | 183 if (!sn || !strlen(sn)) |
181 return -EINVAL; | 184 return -EINVAL; |
182 | 185 |
183 if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+1+strlen(sn)))) | 186 frame = flap_frame_new(od, 0x02, 10+1+strlen(sn)); |
184 return -ENOMEM; | 187 |
185 | 188 snacid = aim_cachesnac(od, 0x0003, 0x0005, 0x0000, sn, strlen(sn)+1); |
186 snacid = aim_cachesnac(sess, 0x0003, 0x0005, 0x0000, sn, strlen(sn)+1); | 189 aim_putsnac(&frame->data, 0x0003, 0x0005, 0x0000, snacid); |
187 aim_putsnac(&fr->data, 0x0003, 0x0005, 0x0000, snacid); | 190 |
188 | 191 byte_stream_put8(&frame->data, strlen(sn)); |
189 aimbs_put8(&fr->data, strlen(sn)); | 192 byte_stream_putstr(&frame->data, sn); |
190 aimbs_putstr(&fr->data, sn); | 193 |
191 | 194 flap_connection_send(conn, frame); |
192 aim_tx_enqueue(sess, fr); | |
193 | |
194 return 0; | |
195 } | |
196 | |
197 /* | |
198 * Subtype 0x000b | |
199 * | |
200 * XXX Why would we send this? | |
201 * | |
202 */ | |
203 faim_export int aim_buddylist_oncoming(OscarSession *sess, OscarConnection *conn, aim_userinfo_t *info) | |
204 { | |
205 FlapFrame *fr; | |
206 aim_snacid_t snacid; | |
207 | |
208 if (!sess || !conn || !info) | |
209 return -EINVAL; | |
210 | |
211 if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1152))) | |
212 return -ENOMEM; | |
213 | |
214 snacid = aim_cachesnac(sess, 0x0003, 0x000b, 0x0000, NULL, 0); | |
215 | |
216 aim_putsnac(&fr->data, 0x0003, 0x000b, 0x0000, snacid); | |
217 aim_putuserinfo(&fr->data, info); | |
218 | |
219 aim_tx_enqueue(sess, fr); | |
220 | |
221 return 0; | |
222 } | |
223 | |
224 /* | |
225 * Subtype 0x000c | |
226 * | |
227 * XXX Why would we send this? | |
228 * | |
229 */ | |
230 faim_export int aim_buddylist_offgoing(OscarSession *sess, OscarConnection *conn, const char *sn) | |
231 { | |
232 FlapFrame *fr; | |
233 aim_snacid_t snacid; | |
234 | |
235 if (!sess || !conn || !sn) | |
236 return -EINVAL; | |
237 | |
238 if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+1+strlen(sn)))) | |
239 return -ENOMEM; | |
240 | |
241 snacid = aim_cachesnac(sess, 0x0003, 0x000c, 0x0000, NULL, 0); | |
242 | |
243 aim_putsnac(&fr->data, 0x0003, 0x000c, 0x0000, snacid); | |
244 aimbs_put8(&fr->data, strlen(sn)); | |
245 aimbs_putstr(&fr->data, sn); | |
246 | |
247 aim_tx_enqueue(sess, fr); | |
248 | 195 |
249 return 0; | 196 return 0; |
250 } | 197 } |
251 | 198 |
252 /* | 199 /* |
258 * | 205 * |
259 * Although the offgoing notification contains no information, | 206 * Although the offgoing notification contains no information, |
260 * it is still in a format parsable by aim_info_extract(). | 207 * it is still in a format parsable by aim_info_extract(). |
261 * | 208 * |
262 */ | 209 */ |
263 static int buddychange(OscarSession *sess, aim_module_t *mod, FlapFrame *rx, aim_modsnac_t *snac, ByteStream *bs) | 210 static int |
211 buddychange(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) | |
264 { | 212 { |
265 int ret = 0; | 213 int ret = 0; |
266 aim_userinfo_t userinfo; | 214 aim_userinfo_t userinfo; |
267 aim_rxcallback_t userfunc; | 215 aim_rxcallback_t userfunc; |
268 | 216 |
269 aim_info_extract(sess, bs, &userinfo); | 217 aim_info_extract(od, bs, &userinfo); |
270 | 218 |
271 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | 219 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) |
272 ret = userfunc(sess, rx, &userinfo); | 220 ret = userfunc(od, conn, frame, &userinfo); |
273 | 221 |
274 if (snac->subtype == 0x000b) | 222 if (snac->subtype == 0x000b) |
275 aim_locate_requestuserinfo(sess, userinfo.sn); | 223 aim_locate_requestuserinfo(od, userinfo.sn); |
276 aim_info_free(&userinfo); | 224 aim_info_free(&userinfo); |
277 | 225 |
278 return ret; | 226 return ret; |
279 } | 227 } |
280 | 228 |
281 static int snachandler(OscarSession *sess, aim_module_t *mod, FlapFrame *rx, aim_modsnac_t *snac, ByteStream *bs) | 229 static int |
282 { | 230 snachandler(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) |
283 | 231 { |
284 if (snac->subtype == 0x0003) | 232 if (snac->subtype == 0x0003) |
285 return rights(sess, mod, rx, snac, bs); | 233 return rights(od, conn, mod, frame, snac, bs); |
286 else if ((snac->subtype == 0x000b) || (snac->subtype == 0x000c)) | 234 else if ((snac->subtype == 0x000b) || (snac->subtype == 0x000c)) |
287 return buddychange(sess, mod, rx, snac, bs); | 235 return buddychange(od, conn, mod, frame, snac, bs); |
288 | 236 |
289 return 0; | 237 return 0; |
290 } | 238 } |
291 | 239 |
292 faim_internal int buddylist_modfirst(OscarSession *sess, aim_module_t *mod) | 240 int |
293 { | 241 buddylist_modfirst(OscarData *od, aim_module_t *mod) |
294 | 242 { |
295 mod->family = 0x0003; | 243 mod->family = 0x0003; |
296 mod->version = 0x0001; | 244 mod->version = 0x0001; |
297 mod->toolid = 0x0110; | 245 mod->toolid = 0x0110; |
298 mod->toolversion = 0x0629; | 246 mod->toolversion = 0x0629; |
299 mod->flags = 0; | 247 mod->flags = 0; |