2 * Purple's oscar protocol plugin
3 * This file is the legal property of its developers.
4 * Please see the AUTHORS file distributed alongside this file.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
22 * Family 0x0015 - Encapsulated ICQ.
26 #include "glibcompat.h"
31 #define AIM_ICQ_INFO_REQUEST 0x04b2
32 #define AIM_ICQ_ALIAS_REQUEST 0x04ba
35 int compare_icq_infos(gconstpointer a
, gconstpointer b
)
37 const struct aim_icq_info
* aa
= a
;
38 const guint16
* bb
= b
;
39 return aa
->reqid
- *bb
;
42 static void aim_icq_freeinfo(struct aim_icq_info
*info
) {
51 g_free(info
->homecity
);
52 g_free(info
->homestate
);
53 g_free(info
->homephone
);
54 g_free(info
->homefax
);
55 g_free(info
->homeaddr
);
57 g_free(info
->homezip
);
58 g_free(info
->personalwebpage
);
60 for (i
= 0; i
< info
->numaddresses
; i
++)
61 g_free(info
->email2
[i
]);
63 g_free(info
->workcity
);
64 g_free(info
->workstate
);
65 g_free(info
->workphone
);
66 g_free(info
->workfax
);
67 g_free(info
->workaddr
);
68 g_free(info
->workzip
);
69 g_free(info
->workcompany
);
70 g_free(info
->workdivision
);
71 g_free(info
->workposition
);
72 g_free(info
->workwebpage
);
74 g_free(info
->status_note_title
);
75 g_free(info
->auth_request_reason
);
79 int error(OscarData
*od
, aim_modsnac_t
*error_snac
, ByteStream
*bs
)
81 aim_snac_t
*original_snac
= aim_remsnac(od
, error_snac
->id
);
82 guint16
*request_type
;
83 GSList
*original_info_ptr
;
84 struct aim_icq_info
*original_info
;
88 if (!original_snac
|| (original_snac
->family
!= SNAC_FAMILY_ICQ
) || !original_snac
->data
) {
89 purple_debug_misc("oscar", "icq: the original snac for the error packet was not found");
90 g_free(original_snac
);
94 request_type
= original_snac
->data
;
95 original_info_ptr
= g_slist_find_custom(od
->icq_info
, &original_snac
->id
, compare_icq_infos
);
97 if (!original_info_ptr
) {
98 purple_debug_misc("oscar", "icq: the request info for the error packet was not found");
99 g_free(original_snac
);
103 original_info
= original_info_ptr
->data
;
105 reason
= byte_stream_get16(bs
);
106 uin
= g_strdup_printf("%u", original_info
->uin
);
107 switch (*request_type
) {
108 case AIM_ICQ_INFO_REQUEST
:
109 oscar_user_info_display_error(od
, reason
, uin
);
111 case AIM_ICQ_ALIAS_REQUEST
:
112 /* Couldn't retrieve an alias for the buddy requesting authorization; have to make do with UIN only. */
113 if (original_info
->for_auth_request
)
114 oscar_auth_recvrequest(od
->gc
, uin
, NULL
, original_info
->auth_request_reason
);
117 purple_debug_misc("oscar", "icq: got an error packet with unknown request type %u", *request_type
);
121 aim_icq_freeinfo(original_info
);
122 od
->icq_info
= g_slist_remove(od
->icq_info
, original_info_ptr
);
123 g_free(original_snac
->data
);
124 g_free(original_snac
);
129 aim_icq_setsecurity(OscarData
*od
, gboolean auth_required
, gboolean webaware
)
131 FlapConnection
*conn
;
136 if (!od
|| !(conn
= flap_connection_findbygroup(od
, SNAC_FAMILY_ICQ
)))
139 bslen
= 2+4+2+2+2+2+2+1+1+1+1+1+1;
141 byte_stream_new(&bs
, 4 + bslen
);
143 snacid
= aim_cachesnac(od
, SNAC_FAMILY_ICQ
, 0x0002, 0x0000, NULL
, 0);
145 /* For simplicity, don't bother using a tlvlist */
146 byte_stream_put16(&bs
, 0x0001);
147 byte_stream_put16(&bs
, bslen
);
149 byte_stream_putle16(&bs
, bslen
- 2);
150 byte_stream_putuid(&bs
, od
);
151 byte_stream_putle16(&bs
, 0x07d0); /* I command thee. */
152 byte_stream_putle16(&bs
, snacid
); /* eh. */
153 byte_stream_putle16(&bs
, 0x0c3a); /* shrug. */
154 byte_stream_putle16(&bs
, 0x030c);
155 byte_stream_putle16(&bs
, 0x0001);
156 byte_stream_putle8(&bs
, webaware
);
157 byte_stream_putle8(&bs
, 0xf8);
158 byte_stream_putle8(&bs
, 0x02);
159 byte_stream_putle8(&bs
, 0x01);
160 byte_stream_putle8(&bs
, 0x00);
161 byte_stream_putle8(&bs
, !auth_required
);
163 flap_connection_send_snac(od
, conn
, SNAC_FAMILY_ICQ
, 0x0002, snacid
, &bs
);
165 byte_stream_destroy(&bs
);
171 * Change your ICQ password.
173 * @param od The oscar session
174 * @param passwd The new password. If this is longer than 8 characters it
176 * @return Return 0 if no errors, otherwise return the error number.
178 int aim_icq_changepasswd(OscarData
*od
, const char *passwd
)
180 FlapConnection
*conn
;
183 int bslen
, passwdlen
;
188 if (!od
|| !(conn
= flap_connection_findbygroup(od
, SNAC_FAMILY_ICQ
)))
191 passwdlen
= strlen(passwd
);
192 if (passwdlen
> MAXICQPASSLEN
)
193 passwdlen
= MAXICQPASSLEN
;
194 bslen
= 2+4+2+2+2+2+passwdlen
+1;
196 byte_stream_new(&bs
, 4 + bslen
);
198 snacid
= aim_cachesnac(od
, SNAC_FAMILY_ICQ
, 0x0002, 0x0000, NULL
, 0);
200 /* For simplicity, don't bother using a tlvlist */
201 byte_stream_put16(&bs
, 0x0001);
202 byte_stream_put16(&bs
, bslen
);
204 byte_stream_putle16(&bs
, bslen
- 2);
205 byte_stream_putuid(&bs
, od
);
206 byte_stream_putle16(&bs
, 0x07d0); /* I command thee. */
207 byte_stream_putle16(&bs
, snacid
); /* eh. */
208 byte_stream_putle16(&bs
, 0x042e); /* shrug. */
209 byte_stream_putle16(&bs
, passwdlen
+1);
210 byte_stream_putraw(&bs
, (const guint8
*)passwd
, passwdlen
);
211 byte_stream_putle8(&bs
, '\0');
213 flap_connection_send_snac(od
, conn
, SNAC_FAMILY_ICQ
, 0x0002, snacid
, &bs
);
215 byte_stream_destroy(&bs
);
220 int aim_icq_getallinfo(OscarData
*od
, const char *uin
)
222 FlapConnection
*conn
;
226 struct aim_icq_info
*info
;
227 guint16 request_type
= AIM_ICQ_INFO_REQUEST
;
229 if (!uin
|| uin
[0] < '0' || uin
[0] > '9')
232 if (!od
|| !(conn
= flap_connection_findbygroup(od
, SNAC_FAMILY_ICQ
)))
235 bslen
= 2 + 4 + 2 + 2 + 2 + 4;
237 byte_stream_new(&bs
, 4 + bslen
);
239 snacid
= aim_cachesnac(od
, SNAC_FAMILY_ICQ
, 0x0002, 0x0000, &request_type
, sizeof(request_type
));
241 /* For simplicity, don't bother using a tlvlist */
242 byte_stream_put16(&bs
, 0x0001);
243 byte_stream_put16(&bs
, bslen
);
245 byte_stream_putle16(&bs
, bslen
- 2);
246 byte_stream_putuid(&bs
, od
);
247 byte_stream_putle16(&bs
, 0x07d0); /* I command thee. */
248 byte_stream_putle16(&bs
, snacid
); /* eh. */
249 byte_stream_putle16(&bs
, request_type
); /* shrug. */
250 byte_stream_putle32(&bs
, atoi(uin
));
252 flap_connection_send_snac_with_priority(od
, conn
, SNAC_FAMILY_ICQ
, 0x0002, snacid
, &bs
, FALSE
);
254 byte_stream_destroy(&bs
);
256 /* Keep track of this request and the ICQ number and request ID */
257 info
= g_new0(struct aim_icq_info
, 1);
258 info
->reqid
= snacid
;
259 info
->uin
= atoi(uin
);
260 od
->icq_info
= g_slist_prepend(od
->icq_info
, info
);
265 int aim_icq_getalias(OscarData
*od
, const char *uin
, gboolean for_auth_request
, char *auth_request_reason
)
267 FlapConnection
*conn
;
271 struct aim_icq_info
*info
;
272 guint16 request_type
= AIM_ICQ_ALIAS_REQUEST
;
274 if (!uin
|| uin
[0] < '0' || uin
[0] > '9')
277 if (!od
|| !(conn
= flap_connection_findbygroup(od
, SNAC_FAMILY_ICQ
)))
280 purple_debug_info("oscar", "Requesting ICQ alias for %s\n", uin
);
282 bslen
= 2 + 4 + 2 + 2 + 2 + 4;
284 byte_stream_new(&bs
, 4 + bslen
);
286 snacid
= aim_cachesnac(od
, SNAC_FAMILY_ICQ
, 0x0002, 0x0000, &request_type
, sizeof(request_type
));
288 /* For simplicity, don't bother using a tlvlist */
289 byte_stream_put16(&bs
, 0x0001);
290 byte_stream_put16(&bs
, bslen
);
292 byte_stream_putle16(&bs
, bslen
- 2);
293 byte_stream_putuid(&bs
, od
);
294 byte_stream_putle16(&bs
, 0x07d0); /* I command thee. */
295 byte_stream_putle16(&bs
, snacid
); /* eh. */
296 byte_stream_putle16(&bs
, request_type
); /* shrug. */
297 byte_stream_putle32(&bs
, atoi(uin
));
299 flap_connection_send_snac_with_priority(od
, conn
, SNAC_FAMILY_ICQ
, 0x0002, snacid
, &bs
, FALSE
);
301 byte_stream_destroy(&bs
);
303 /* Keep track of this request and the ICQ number and request ID */
304 info
= g_new0(struct aim_icq_info
, 1);
305 info
->reqid
= snacid
;
306 info
->uin
= atoi(uin
);
307 info
->for_auth_request
= for_auth_request
;
308 info
->auth_request_reason
= g_strdup(auth_request_reason
);
309 od
->icq_info
= g_slist_prepend(od
->icq_info
, info
);
315 * Send an SMS message. This is the non-US way. The US-way is to IM
316 * their cell phone number (+19195551234).
318 * We basically construct and send an XML message. The format is:
320 * <destination>full_phone_without_leading_+</destination>
321 * <text>message</text>
322 * <codepage>1252</codepage>
323 * <senders_UIN>self_uin</senders_UIN>
324 * <senders_name>self_name</senders_name>
325 * <delivery_receipt>Yes|No</delivery_receipt>
326 * <time>Wkd, DD Mmm YYYY HH:MM:SS TMZ</time>
329 * Yeah hi Peter, whaaaat's happening. If there's any way to use
330 * a codepage other than 1252 that would be great. Thaaaanks.
332 int aim_icq_sendsms(OscarData
*od
, const char *name
, const char *msg
, const char *alias
)
334 FlapConnection
*conn
;
335 PurpleAccount
*account
;
340 const char *timestr
, *username
;
345 if (!od
|| !(conn
= flap_connection_findbygroup(od
, SNAC_FAMILY_ICQ
)))
348 if (!name
|| !msg
|| !alias
)
351 account
= purple_connection_get_account(od
->gc
);
352 username
= purple_account_get_username(account
);
356 timestr
= purple_utf8_strftime("%a, %d %b %Y %T %Z", tm
);
358 stripped
= purple_markup_strip_html(msg
);
360 /* The length of xml included the null terminating character */
361 xmllen
= 209 + strlen(name
) + strlen(stripped
) + strlen(username
) + strlen(alias
) + strlen(timestr
) + 1;
363 xml
= g_new(char, xmllen
);
364 snprintf(xml
, xmllen
, "<icq_sms_message>"
365 "<destination>%s</destination>"
367 "<codepage>1252</codepage>"
368 "<senders_UIN>%s</senders_UIN>"
369 "<senders_name>%s</senders_name>"
370 "<delivery_receipt>Yes</delivery_receipt>"
372 "</icq_sms_message>",
373 name
, stripped
, username
, alias
, timestr
);
377 byte_stream_new(&bs
, 4 + bslen
);
379 snacid
= aim_cachesnac(od
, SNAC_FAMILY_ICQ
, 0x0002, 0x0000, NULL
, 0);
381 /* For simplicity, don't bother using a tlvlist */
382 byte_stream_put16(&bs
, 0x0001);
383 byte_stream_put16(&bs
, bslen
);
385 byte_stream_putle16(&bs
, bslen
- 2);
386 byte_stream_putuid(&bs
, od
);
387 byte_stream_putle16(&bs
, 0x07d0); /* I command thee. */
388 byte_stream_putle16(&bs
, snacid
); /* eh. */
390 /* From libicq200-0.3.2/src/SNAC-SRV.cpp */
391 byte_stream_putle16(&bs
, 0x1482);
392 byte_stream_put16(&bs
, 0x0001);
393 byte_stream_put16(&bs
, 0x0016);
394 byte_stream_put32(&bs
, 0x00000000);
395 byte_stream_put32(&bs
, 0x00000000);
396 byte_stream_put32(&bs
, 0x00000000);
397 byte_stream_put32(&bs
, 0x00000000);
399 byte_stream_put16(&bs
, 0x0000);
400 byte_stream_put16(&bs
, xmllen
);
401 byte_stream_putstr(&bs
, xml
);
402 byte_stream_put8(&bs
, 0x00);
404 flap_connection_send_snac(od
, conn
, SNAC_FAMILY_ICQ
, 0x0002, snacid
, &bs
);
406 byte_stream_destroy(&bs
);
415 gotalias(OscarData
*od
, struct aim_icq_info
*info
)
417 PurpleConnection
*gc
= od
->gc
;
418 PurpleAccount
*account
= purple_connection_get_account(gc
);
420 gchar
*utf8
= oscar_utf8_try_convert(account
, od
, info
->nick
);
422 if (info
->for_auth_request
) {
423 oscar_auth_recvrequest(gc
, g_strdup_printf("%u", info
->uin
), utf8
, info
->auth_request_reason
);
427 g_snprintf(who
, sizeof(who
), "%u", info
->uin
);
428 purple_serv_got_alias(gc
, who
, utf8
);
429 if ((b
= purple_blist_find_buddy(account
, who
))) {
430 purple_blist_node_set_string((PurpleBlistNode
*)b
, "servernick", utf8
);
438 * Subtype 0x0003 - Response to SNAC_FAMILY_ICQ/0x002, contains an ICQesque packet.
441 icqresponse(OscarData
*od
, aim_modsnac_t
*snac
, ByteStream
*bs
)
447 guint16 cmdlen
, cmd
, reqid
;
449 if (!(tlvlist
= aim_tlvlist_read(bs
)) || !(datatlv
= aim_tlv_gettlv(tlvlist
, 0x0001, 1))) {
450 aim_tlvlist_free(tlvlist
);
451 purple_debug_misc("oscar", "corrupt ICQ response\n");
455 byte_stream_init(&qbs
, datatlv
->value
, datatlv
->length
);
457 cmdlen
= byte_stream_getle16(&qbs
);
458 ouruin
= byte_stream_getle32(&qbs
);
459 cmd
= byte_stream_getle16(&qbs
);
460 reqid
= byte_stream_getle16(&qbs
);
462 purple_debug_misc("oscar", "icq response: %d bytes, %u, 0x%04x, 0x%04x\n", cmdlen
, ouruin
, cmd
, reqid
);
464 if (cmd
== 0x07da) { /* information */
467 struct aim_icq_info
*info
;
469 subtype
= byte_stream_getle16(&qbs
);
470 byte_stream_advance(&qbs
, 1); /* 0x0a */
472 /* find other data from the same request */
473 info_ptr
= g_slist_find_custom(od
->icq_info
, &reqid
, compare_icq_infos
);
475 struct aim_icq_info
*new_info
= g_new0(struct aim_icq_info
, 1);
476 new_info
->reqid
= reqid
;
477 info_ptr
= od
->icq_info
= g_slist_prepend(od
->icq_info
, new_info
);
480 info
= info_ptr
->data
;
482 case 0x00a0: { /* hide ip status */
486 case 0x00aa: { /* password change status */
490 case 0x00c8: { /* general and "home" information */
491 info
->nick
= byte_stream_getstr(&qbs
, byte_stream_getle16(&qbs
));
492 info
->first
= byte_stream_getstr(&qbs
, byte_stream_getle16(&qbs
));
493 info
->last
= byte_stream_getstr(&qbs
, byte_stream_getle16(&qbs
));
494 info
->email
= byte_stream_getstr(&qbs
, byte_stream_getle16(&qbs
));
495 info
->homecity
= byte_stream_getstr(&qbs
, byte_stream_getle16(&qbs
));
496 info
->homestate
= byte_stream_getstr(&qbs
, byte_stream_getle16(&qbs
));
497 info
->homephone
= byte_stream_getstr(&qbs
, byte_stream_getle16(&qbs
));
498 info
->homefax
= byte_stream_getstr(&qbs
, byte_stream_getle16(&qbs
));
499 info
->homeaddr
= byte_stream_getstr(&qbs
, byte_stream_getle16(&qbs
));
500 info
->mobile
= byte_stream_getstr(&qbs
, byte_stream_getle16(&qbs
));
501 info
->homezip
= byte_stream_getstr(&qbs
, byte_stream_getle16(&qbs
));
502 info
->homecountry
= byte_stream_getle16(&qbs
);
504 /* 1 byte timezone? */
505 /* 1 byte hide email flag? */
508 case 0x00dc: { /* personal information */
509 info
->age
= byte_stream_getle8(&qbs
);
510 info
->unknown
= byte_stream_getle8(&qbs
);
511 info
->gender
= byte_stream_getle8(&qbs
); /* Not specified=0x00, Female=0x01, Male=0x02 */
512 info
->personalwebpage
= byte_stream_getstr(&qbs
, byte_stream_getle16(&qbs
));
513 info
->birthyear
= byte_stream_getle16(&qbs
);
514 info
->birthmonth
= byte_stream_getle8(&qbs
);
515 info
->birthday
= byte_stream_getle8(&qbs
);
516 info
->language1
= byte_stream_getle8(&qbs
);
517 info
->language2
= byte_stream_getle8(&qbs
);
518 info
->language3
= byte_stream_getle8(&qbs
);
519 /* 0x00 00 01 00 00 01 00 00 00 00 00 */
522 case 0x00d2: { /* work information */
523 info
->workcity
= byte_stream_getstr(&qbs
, byte_stream_getle16(&qbs
));
524 info
->workstate
= byte_stream_getstr(&qbs
, byte_stream_getle16(&qbs
));
525 info
->workphone
= byte_stream_getstr(&qbs
, byte_stream_getle16(&qbs
));
526 info
->workfax
= byte_stream_getstr(&qbs
, byte_stream_getle16(&qbs
));
527 info
->workaddr
= byte_stream_getstr(&qbs
, byte_stream_getle16(&qbs
));
528 info
->workzip
= byte_stream_getstr(&qbs
, byte_stream_getle16(&qbs
));
529 info
->workcountry
= byte_stream_getle16(&qbs
);
530 info
->workcompany
= byte_stream_getstr(&qbs
, byte_stream_getle16(&qbs
));
531 info
->workdivision
= byte_stream_getstr(&qbs
, byte_stream_getle16(&qbs
));
532 info
->workposition
= byte_stream_getstr(&qbs
, byte_stream_getle16(&qbs
));
533 byte_stream_advance(&qbs
, 2); /* 0x01 00 */
534 info
->workwebpage
= byte_stream_getstr(&qbs
, byte_stream_getle16(&qbs
));
537 case 0x00e6: { /* additional personal information */
538 info
->info
= byte_stream_getstr(&qbs
, byte_stream_getle16(&qbs
)-1);
541 case 0x00eb: { /* email address(es) */
543 info
->numaddresses
= byte_stream_getle16(&qbs
);
544 info
->email2
= g_new0(char *, info
->numaddresses
);
545 for (i
= 0; i
< info
->numaddresses
; i
++) {
546 info
->email2
[i
] = byte_stream_getstr(&qbs
, byte_stream_getle16(&qbs
));
547 if (i
+1 != info
->numaddresses
)
548 byte_stream_advance(&qbs
, 1); /* 0x00 */
552 case 0x00f0: { /* personal interests */
555 case 0x00fa: { /* past background and current organizations */
558 case 0x0104: { /* alias info */
559 info
->nick
= byte_stream_getstr(&qbs
, byte_stream_getle16(&qbs
));
560 info
->first
= byte_stream_getstr(&qbs
, byte_stream_getle16(&qbs
));
561 info
->last
= byte_stream_getstr(&qbs
, byte_stream_getle16(&qbs
));
562 byte_stream_advance(&qbs
, byte_stream_getle16(&qbs
)); /* email address? */
563 /* Then 0x00 02 00 */
566 case 0x010e: { /* unknown */
570 case 0x019a: { /* simple info */
571 byte_stream_advance(&qbs
, 2);
572 info
->uin
= byte_stream_getle32(&qbs
);
573 info
->nick
= byte_stream_getstr(&qbs
, byte_stream_getle16(&qbs
));
574 info
->first
= byte_stream_getstr(&qbs
, byte_stream_getle16(&qbs
));
575 info
->last
= byte_stream_getstr(&qbs
, byte_stream_getle16(&qbs
));
576 info
->email
= byte_stream_getstr(&qbs
, byte_stream_getle16(&qbs
));
577 /* Then 0x00 02 00 00 00 00 00 */
580 /* status note title and send request for status note text */
584 FlapConnection
*conn
;
586 char *status_note_title
= NULL
;
588 conn
= flap_connection_findbygroup(od
, 0x0004);
591 purple_debug_misc("oscar", "icq/0x0fb4: flap connection was not found.\n");
595 byte_stream_advance(&qbs
, 0x02); /* length */
596 byte_stream_advance(&qbs
, 0x2f); /* unknown stuff */
598 tlvlist
= aim_tlvlist_read(&qbs
);
600 tlv
= aim_tlv_gettlv(tlvlist
, 0x0032, 1);
602 /* Get user number */
603 uin
= aim_tlv_getvalue_as_string(tlv
);
605 tlv
= aim_tlv_gettlv(tlvlist
, 0x0226, 1);
607 /* Get status note title */
608 status_note_title
= aim_tlv_getvalue_as_string(tlv
);
610 aim_tlvlist_free(tlvlist
);
612 if (uin
== NULL
|| status_note_title
== NULL
)
614 purple_debug_misc("oscar", "icq/0x0fb4: uin or "
615 "status_note_title was not found\n");
617 g_free(status_note_title
);
621 if (status_note_title
[0] == '\0')
623 PurpleAccount
*account
;
625 PurplePresence
*presence
;
626 PurpleStatus
*status
;
628 account
= purple_connection_get_account(od
->gc
);
629 buddy
= purple_blist_find_buddy(account
, uin
);
630 presence
= purple_buddy_get_presence(buddy
);
631 status
= purple_presence_get_active_status(presence
);
633 purple_protocol_got_user_status(account
, uin
,
634 purple_status_get_id(status
),
635 "message", NULL
, NULL
);
637 g_free(status_note_title
);
641 struct aim_icq_info
*info
;
647 info
= g_new0(struct aim_icq_info
, 1);
649 bslen
= 13 + strlen(uin
) + 30 + 6 + 4 + 55 + 85 + 4;
650 byte_stream_new(&bs
, 4 + bslen
);
652 snacid
= aim_cachesnac(od
, 0x0004, 0x0006, 0x0000, NULL
, 0);
654 aim_icbm_makecookie(cookie
);
656 byte_stream_putraw(&bs
, cookie
, 8); /* ICBM cookie */
657 byte_stream_put16(&bs
, 0x0002); /* message channel */
658 byte_stream_put8(&bs
, strlen(uin
)); /* uin */
659 byte_stream_putstr(&bs
, uin
);
661 byte_stream_put16(&bs
, 0x0005); /* rendez vous data */
662 byte_stream_put16(&bs
, 0x00b2);
663 byte_stream_put16(&bs
, 0x0000); /* request */
664 byte_stream_putraw(&bs
, cookie
, 8); /* ICBM cookie */
665 byte_stream_put32(&bs
, 0x09461349); /* ICQ server relaying */
666 byte_stream_put16(&bs
, 0x4c7f);
667 byte_stream_put16(&bs
, 0x11d1);
668 byte_stream_put32(&bs
, 0x82224445);
669 byte_stream_put32(&bs
, 0x53540000);
671 byte_stream_put16(&bs
, 0x000a); /* unknown TLV */
672 byte_stream_put16(&bs
, 0x0002);
673 byte_stream_put16(&bs
, 0x0001);
675 byte_stream_put16(&bs
, 0x000f); /* unknown TLV */
676 byte_stream_put16(&bs
, 0x0000);
678 byte_stream_put16(&bs
, 0x2711); /* extended data */
679 byte_stream_put16(&bs
, 0x008a);
680 byte_stream_putle16(&bs
, 0x001b); /* length */
681 byte_stream_putle16(&bs
, 0x0009); /* version */
682 byte_stream_putle32(&bs
, 0x00000000); /* plugin: none */
683 byte_stream_putle32(&bs
, 0x00000000);
684 byte_stream_putle32(&bs
, 0x00000000);
685 byte_stream_putle32(&bs
, 0x00000000);
686 byte_stream_putle16(&bs
, 0x0000); /* unknown */
687 byte_stream_putle32(&bs
, 0x00000000); /* client capabilities flags */
688 byte_stream_put8(&bs
, 0x00); /* unknown */
689 byte_stream_putle16(&bs
, 0x0064); /* downcounter? */
690 byte_stream_putle16(&bs
, 0x000e); /* length */
691 byte_stream_putle16(&bs
, 0x0064); /* downcounter? */
692 byte_stream_putle32(&bs
, 0x00000000); /* unknown */
693 byte_stream_putle32(&bs
, 0x00000000);
694 byte_stream_putle32(&bs
, 0x00000000);
695 byte_stream_put8(&bs
, 0x1a); /* message type: plugin message descibed by text string */
696 byte_stream_put8(&bs
, 0x00); /* message flags */
697 byte_stream_putle16(&bs
, 0x0000); /* status code */
698 byte_stream_putle16(&bs
, 0x0001); /* priority code */
699 byte_stream_putle16(&bs
, 0x0000); /* text length */
701 byte_stream_put8(&bs
, 0x3a); /* message dump */
702 byte_stream_put32(&bs
, 0x00811a18);
703 byte_stream_put32(&bs
, 0xbc0e6c18);
704 byte_stream_put32(&bs
, 0x47a5916f);
705 byte_stream_put32(&bs
, 0x18dcc76f);
706 byte_stream_put32(&bs
, 0x1a010013);
707 byte_stream_put32(&bs
, 0x00000041);
708 byte_stream_put32(&bs
, 0x77617920);
709 byte_stream_put32(&bs
, 0x53746174);
710 byte_stream_put32(&bs
, 0x7573204d);
711 byte_stream_put32(&bs
, 0x65737361);
712 byte_stream_put32(&bs
, 0x67650100);
713 byte_stream_put32(&bs
, 0x00000000);
714 byte_stream_put32(&bs
, 0x00000000);
715 byte_stream_put32(&bs
, 0x00000000);
716 byte_stream_put32(&bs
, 0x00000015);
717 byte_stream_put32(&bs
, 0x00000000);
718 byte_stream_put32(&bs
, 0x0000000d);
719 byte_stream_put32(&bs
, 0x00000074);
720 byte_stream_put32(&bs
, 0x6578742f);
721 byte_stream_put32(&bs
, 0x782d616f);
722 byte_stream_put32(&bs
, 0x6c727466);
724 byte_stream_put16(&bs
, 0x0003); /* server ACK requested */
725 byte_stream_put16(&bs
, 0x0000);
727 info
->uin
= atoi(uin
);
728 info
->status_note_title
= status_note_title
;
730 memcpy(&info
->icbm_cookie
, cookie
, 8);
732 od
->icq_info
= g_slist_prepend(od
->icq_info
, info
);
734 flap_connection_send_snac_with_priority(od
, conn
, 0x0004, 0x0006, snacid
, &bs
, FALSE
);
736 byte_stream_destroy(&bs
);
743 } /* End switch statement */
745 if (!(snac
->flags
& 0x0001)) {
746 if (subtype
!= 0x0104)
747 oscar_user_info_display_icq(od
, info
);
749 if (info
->uin
&& info
->nick
)
752 aim_icq_freeinfo(info
);
753 od
->icq_info
= g_slist_remove(od
->icq_info
, info
);
757 aim_tlvlist_free(tlvlist
);
763 snachandler(OscarData
*od
, FlapConnection
*conn
, aim_module_t
*mod
, FlapFrame
*frame
, aim_modsnac_t
*snac
, ByteStream
*bs
)
765 if (snac
->subtype
== 0x0001)
766 return error(od
, snac
, bs
);
767 else if (snac
->subtype
== 0x0003)
768 return icqresponse(od
, snac
, bs
);
774 icq_shutdown(OscarData
*od
, aim_module_t
*mod
)
776 g_slist_free_full(od
->icq_info
, (GDestroyNotify
)aim_icq_freeinfo
);
780 icq_modfirst(OscarData
*od
, aim_module_t
*mod
)
782 mod
->family
= SNAC_FAMILY_ICQ
;
783 mod
->version
= 0x0001;
784 mod
->toolid
= 0x0110;
785 mod
->toolversion
= 0x047c;
787 strncpy(mod
->name
, "icq", sizeof(mod
->name
));
788 mod
->snachandler
= snachandler
;
789 mod
->shutdown
= icq_shutdown
;