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 * Main libfaim header. Must be included in client for prototypes/macros.
24 * "come on, i turned a chick lesbian; i think this is the hackish equivalent"
32 #include "circbuffer.h"
34 #include "eventloop.h"
42 #include <sys/types.h>
52 #include <netinet/in.h>
53 #include <sys/socket.h>
55 #include "libc_interface.h"
58 typedef struct _ByteStream ByteStream;
59 typedef struct _ClientInfo ClientInfo;
60 typedef struct _FlapConnection FlapConnection;
61 typedef struct _FlapFrame FlapFrame;
62 typedef struct _IcbmArgsCh2 IcbmArgsCh2;
63 typedef struct _IcbmCookie IcbmCookie;
64 typedef struct _OscarData OscarData;
65 typedef struct _QueuedSnac QueuedSnac;
67 typedef guint32 aim_snacid_t;
69 #include "snactypes.h"
75 #define FAIM_SNAC_HASH_SIZE 16
78 * Current Maximum Length for usernames (not including NULL)
80 * Currently only names up to 16 characters can be registered
81 * however it is apparently legal for them to be larger.
86 * Current Maximum Length for Instant Messages
88 * This was found basically by experiment, but not wholly
89 * accurate experiment. It should not be regarded
90 * as completely correct. But its a decent approximation.
92 * Note that although we can send this much, its impossible
93 * for WinAIM clients (up through the latest (4.0.1957)) to
94 * send any more than 1kb. Amaze all your windows friends
95 * with utterly oversized instant messages!
97 #define MAXMSGLEN 2544
100 * Maximum size of a Buddy Icon.
102 #define MAXICONLEN 7168
103 #define AIM_ICONIDENT "AVT1picture.id"
106 * Current Maximum Length for Chat Room Messages
108 * This is actually defined by the protocol to be
109 * dynamic, but I have yet to see due cause to
110 * define it dynamically here. Maybe later.
113 #define MAXCHATMSGLEN 512
116 * Found by trial and error.
118 #define MAXAVAILMSGLEN 251
121 * Maximum length for the password of an ICQ account
123 #define MAXICQPASSLEN 8
125 #define AIM_MD5_STRING "AOL Instant Messenger (SM)"
128 * Client info. Filled in by the client and passed in to
129 * aim_send_login(). The information ends up getting passed to OSCAR
130 * through the initial login command.
135 const char *clientstring;
142 const char *country; /* two-letter abbrev */
143 const char *lang; /* two-letter abbrev */
146 /* Needs to be checked */
147 #define CLIENTINFO_AIM_3_5_1670 { \
148 "AOL Instant Messenger (SM), version 3.5.1670/WIN32", \
156 /* Needs to be checked */
157 /* Latest winaim without ssi */
158 #define CLIENTINFO_AIM_4_1_2010 { \
159 "AOL Instant Messenger (SM), version 4.1.2010/WIN32", \
167 /* Needs to be checked */
168 #define CLIENTINFO_AIM_4_3_2188 { \
169 "AOL Instant Messenger (SM), version 4.3.2188/WIN32", \
177 /* Needs to be checked */
178 #define CLIENTINFO_AIM_4_8_2540 { \
179 "AOL Instant Messenger (SM), version 4.8.2540/WIN32", \
187 /* Needs to be checked */
188 #define CLIENTINFO_AIM_5_0_2938 { \
189 "AOL Instant Messenger, version 5.0.2938/WIN32", \
197 #define CLIENTINFO_AIM_5_1_3036 { \
198 "AOL Instant Messenger, version 5.1.3036/WIN32", \
206 #define CLIENTINFO_AIM_5_5_3415 { \
207 "AOL Instant Messenger, version 5.5.3415/WIN32", \
215 #define CLIENTINFO_AIM_5_9_3702 { \
216 "AOL Instant Messenger, version 5.9.3702/WIN32", \
224 #define CLIENTINFO_ICHAT_1_0 { \
233 /* Needs to be checked */
234 #define CLIENTINFO_ICQ_4_65_3281 { \
235 "ICQ Inc. - Product of ICQ (TM) 2000b.4.65.1.3281.85", \
243 /* Needs to be checked */
244 #define CLIENTINFO_ICQ_5_34_3728 { \
245 "ICQ Inc. - Product of ICQ (TM).2002a.5.34.1.3728.85", \
253 #define CLIENTINFO_ICQ_5_45_3777 { \
254 "ICQ Inc. - Product of ICQ (TM).2003a.5.45.1.3777.85", \
262 #define CLIENTINFO_ICQ6_6_0_6059 { \
271 #define CLIENTINFO_ICQBASIC_14_3_1068 { \
280 #define CLIENTINFO_ICQBASIC_14_34_3000 { \
289 #define CLIENTINFO_ICQBASIC_14_34_3096 { \
298 #define CLIENTINFO_NETSCAPE_7_0_1 { \
299 "Netscape 2000 an approved user of AOL Instant Messenger (SM)", \
308 * We need to use the major-minor-micro versions from the official
309 * AIM and ICQ programs here or AOL won't let us use certain features.
311 * 0x00000611 is the distid given to us by AOL for use as the default
314 #define CLIENTINFO_PURPLE_AIM { \
323 #define CLIENTINFO_PURPLE_ICQ { \
332 #define CLIENTINFO_AIM_KNOWNGOOD CLIENTINFO_AIM_5_1_3036
333 #define CLIENTINFO_ICQ_KNOWNGOOD CLIENTINFO_ICQBASIC_14_34_3096
337 OSCAR_DISCONNECT_DONE, /* not considered an error */
338 OSCAR_DISCONNECT_LOCAL_CLOSED, /* peer connections only, not considered an error */
339 OSCAR_DISCONNECT_REMOTE_CLOSED,
340 OSCAR_DISCONNECT_REMOTE_REFUSED, /* peer connections only */
341 OSCAR_DISCONNECT_LOST_CONNECTION,
342 OSCAR_DISCONNECT_INVALID_DATA,
343 OSCAR_DISCONNECT_COULD_NOT_CONNECT,
344 OSCAR_DISCONNECT_RETRYING /* peer connections only */
345 } OscarDisconnectReason;
349 OSCAR_CAPABILITY_BUDDYICON = 0x00000001,
350 OSCAR_CAPABILITY_TALK = 0x00000002,
351 OSCAR_CAPABILITY_DIRECTIM = 0x00000004,
352 OSCAR_CAPABILITY_CHAT = 0x00000008,
353 OSCAR_CAPABILITY_GETFILE = 0x00000010,
354 OSCAR_CAPABILITY_SENDFILE = 0x00000020,
355 OSCAR_CAPABILITY_GAMES = 0x00000040,
356 OSCAR_CAPABILITY_ADDINS = 0x00000080,
357 OSCAR_CAPABILITY_SENDBUDDYLIST = 0x00000100,
358 OSCAR_CAPABILITY_GAMES2 = 0x00000200,
359 OSCAR_CAPABILITY_ICQ_DIRECT = 0x00000400,
360 OSCAR_CAPABILITY_APINFO = 0x00000800,
361 OSCAR_CAPABILITY_ICQRTF = 0x00001000,
362 OSCAR_CAPABILITY_EMPTY = 0x00002000,
363 OSCAR_CAPABILITY_ICQSERVERRELAY = 0x00004000,
364 OSCAR_CAPABILITY_UNICODEOLD = 0x00008000,
365 OSCAR_CAPABILITY_TRILLIANCRYPT = 0x00010000,
366 OSCAR_CAPABILITY_UNICODE = 0x00020000,
367 OSCAR_CAPABILITY_INTEROPERATE = 0x00040000,
368 OSCAR_CAPABILITY_SHORTCAPS = 0x00080000,
369 OSCAR_CAPABILITY_HIPTOP = 0x00100000,
370 OSCAR_CAPABILITY_SECUREIM = 0x00200000,
371 OSCAR_CAPABILITY_SMS = 0x00400000,
372 OSCAR_CAPABILITY_VIDEO = 0x00800000,
373 OSCAR_CAPABILITY_ICHATAV = 0x01000000,
374 OSCAR_CAPABILITY_LIVEVIDEO = 0x02000000,
375 OSCAR_CAPABILITY_CAMERA = 0x04000000,
376 OSCAR_CAPABILITY_ICHAT_SCREENSHARE = 0x08000000,
377 OSCAR_CAPABILITY_TYPING = 0x10000000,
378 OSCAR_CAPABILITY_GENERICUNKNOWN = 0x20000000,
379 OSCAR_CAPABILITY_LAST = 0x40000000
383 * Byte Stream type. Sort of.
385 * Use of this type serves a couple purposes:
386 * - Buffer/buflen pairs are passed all around everywhere. This turns
387 * that into one value, as well as abstracting it slightly.
388 * - Through the abstraction, it is possible to enable bounds checking
389 * for robustness at the cost of performance. But a clean failure on
390 * weird packets is much better than a segfault.
391 * - I like having variables named "bs".
393 * Don't touch the insides of this struct. Or I'll have to kill you.
414 ByteStream data; /* payload stream */
417 struct _FlapConnection
419 OscarData *od; /**< Pointer to parent session. */
421 time_t lastactivity; /**< Time of last transmit. */
422 guint destroy_timeout;
423 OscarDisconnectReason disconnect_reason;
424 gchar *error_message;
425 guint16 disconnect_code;
427 /* A few variables that are only used when connecting */
428 PurpleProxyConnectData *connect_data;
431 gpointer new_conn_data;
434 PurpleSslConnection *gsc;
436 gssize header_received;
437 FlapFrame buffer_incoming;
438 PurpleCircBuffer *buffer_outgoing;
439 guint watcher_incoming;
440 guint watcher_outgoing;
444 guint16 seqnum_out; /**< The sequence number of most recently sent packet. */
445 guint16 seqnum_in; /**< The sequence number of most recently received packet. */
447 GSList *rateclasses; /* Contains nodes of struct rateclass. */
449 GQueue *queued_snacs; /**< Contains QueuedSnacs. */
450 GQueue *queued_lowpriority_snacs; /**< Contains QueuedSnacs to send only once queued_snacs is empty */
451 guint queued_timeout;
453 void *internal; /* internal conn-specific libfaim data */
462 struct _IcbmCookie *next;
468 * AIM Session: The main client-data interface.
473 /** Only used when connecting with clientLogin */
474 PurpleUtilFetchUrlData *url_data;
476 gboolean iconconnecting;
479 GSList *create_rooms;
492 GHashTable *buddyinfo;
500 guint maxwatchers; /* max users who can watch you */
501 guint maxbuddies; /* max users you can watch */
502 guint maxgroups; /* max groups in server list */
503 guint maxpermits; /* max users on permit list */
504 guint maxdenies; /* max users on deny list */
505 guint maxsiglen; /* max size (bytes) of profile */
506 guint maxawaymsglen; /* max size (bytes) of posted away message */
509 PurpleConnection *gc;
514 * Outstanding snac handling
516 * TODO: Should these be per-connection? -mid
518 void *snac_hash[FAIM_SNAC_HASH_SIZE];
519 aim_snacid_t snacid_next;
522 * TODO: Data specific to a certain family should go into a
523 * hashtable and the core parts of libfaim shouldn't
524 * need to know about them.
527 IcbmCookie *msgcookies;
528 struct aim_icq_info *icq_info;
530 /** Only used when connecting with the old-style BUCP login. */
531 struct aim_authresp_info *authinfo;
532 struct aim_emailinfo *emailinfo;
535 struct aim_userinfo_s *userinfo;
538 /* Server-stored information (ssi) */
540 gboolean received_data;
542 struct aim_ssi_item *official;
543 struct aim_ssi_item *local;
544 struct aim_ssi_tmp *pending;
546 gboolean waiting_for_ack;
547 gboolean in_transaction;
550 /** Contains pointers to handler functions for each family/subtype. */
551 GHashTable *handlerlist;
553 /** A linked list containing FlapConnections. */
554 GSList *oscar_connections;
555 guint16 default_port;
557 /** A linked list containing PeerConnections. */
558 GSList *peer_connections;
561 /* Valid for calling aim_icq_setstatus() and for aim_userinfo_t->icqinfo.status */
562 #define AIM_ICQ_STATE_NORMAL 0x00000000
563 #define AIM_ICQ_STATE_AWAY 0x00000001
564 #define AIM_ICQ_STATE_DND 0x00000002
565 #define AIM_ICQ_STATE_OUT 0x00000004
566 #define AIM_ICQ_STATE_BUSY 0x00000010
567 #define AIM_ICQ_STATE_CHAT 0x00000020
568 #define AIM_ICQ_STATE_INVISIBLE 0x00000100
569 #define AIM_ICQ_STATE_WEBAWARE 0x00010000
570 #define AIM_ICQ_STATE_HIDEIP 0x00020000
571 #define AIM_ICQ_STATE_BIRTHDAY 0x00080000
572 #define AIM_ICQ_STATE_DIRECTDISABLED 0x00100000
573 #define AIM_ICQ_STATE_ICQHOMEPAGE 0x00200000
574 #define AIM_ICQ_STATE_DIRECTREQUIREAUTH 0x10000000
575 #define AIM_ICQ_STATE_DIRECTCONTACTLIST 0x20000000
578 * Only used when connecting with the old-style BUCP login.
580 struct aim_clientrelease
589 * Only used when connecting with the old-style BUCP login.
591 struct aim_authresp_info
602 struct aim_clientrelease latestrelease;
603 struct aim_clientrelease latestbeta;
606 /* Callback data for redirect. */
607 struct aim_redirect_data
612 const guint8 *cookie;
613 const char *ssl_cert_cn;
615 struct { /* group == SNAC_FAMILY_CHAT */
622 int oscar_connect_to_bos(PurpleConnection *gc, OscarData *od, const char *host, guint16 port, guint8 *cookie, guint16 cookielen);
627 * Only used when connecting with the old-style BUCP login.
629 int aim_request_login(OscarData *od, FlapConnection *conn, const char *bn);
632 * Only used when connecting with the old-style BUCP login.
634 int aim_send_login(OscarData *od, FlapConnection *conn, const char *bn, const char *password, gboolean truncate_pass, ClientInfo *ci, const char *key, gboolean allow_multiple_logins);
637 * Only used when connecting with the old-style BUCP login.
639 /* 0x000b */ int aim_auth_securid_send(OscarData *od, const char *securid);
642 * Only used when connecting with clientLogin.
644 void send_client_login(OscarData *od, const char *username);
646 /* flap_connection.c */
647 FlapConnection *flap_connection_new(OscarData *, int type);
648 void flap_connection_close(OscarData *od, FlapConnection *conn);
649 void flap_connection_destroy(FlapConnection *conn, OscarDisconnectReason reason, const gchar *error_message);
650 void flap_connection_schedule_destroy(FlapConnection *conn, OscarDisconnectReason reason, const gchar *error_message);
651 FlapConnection *flap_connection_findbygroup(OscarData *od, guint16 group);
652 FlapConnection *flap_connection_getbytype(OscarData *, int type);
653 FlapConnection *flap_connection_getbytype_all(OscarData *, int type);
654 void flap_connection_recv_cb(gpointer data, gint source, PurpleInputCondition cond);
655 void flap_connection_recv_cb_ssl(gpointer data, PurpleSslConnection *gsc, PurpleInputCondition cond);
657 void flap_connection_send(FlapConnection *conn, FlapFrame *frame);
658 void flap_connection_send_version(OscarData *od, FlapConnection *conn);
659 void flap_connection_send_version_with_cookie(OscarData *od, FlapConnection *conn, guint16 length, const guint8 *chipsahoy);
660 void flap_connection_send_version_with_cookie_and_clientinfo(OscarData *od, FlapConnection *conn, guint16 length, const guint8 *chipsahoy, ClientInfo *ci);
661 void flap_connection_send_snac(OscarData *od, FlapConnection *conn, guint16 family, const guint16 subtype, guint16 flags, aim_snacid_t snacid, ByteStream *data);
662 void flap_connection_send_snac_with_priority(OscarData *od, FlapConnection *conn, guint16 family, const guint16 subtype, guint16 flags, aim_snacid_t snacid, ByteStream *data, gboolean high_priority);
663 void flap_connection_send_keepalive(OscarData *od, FlapConnection *conn);
664 FlapFrame *flap_frame_new(OscarData *od, guint16 channel, int datalen);
667 typedef int (*aim_rxcallback_t)(OscarData *od, FlapConnection *conn, FlapFrame *frame, ...);
669 OscarData *oscar_data_new(void);
670 void oscar_data_destroy(OscarData *);
671 void oscar_data_addhandler(OscarData *od, guint16 family, guint16 subtype, aim_rxcallback_t newhandler, guint16 flags);
672 aim_rxcallback_t aim_callhandler(OscarData *od, guint16 family, guint16 subtype);
675 #define AIM_VISIBILITYCHANGE_PERMITADD 0x05
676 #define AIM_VISIBILITYCHANGE_PERMITREMOVE 0x06
677 #define AIM_VISIBILITYCHANGE_DENYADD 0x07
678 #define AIM_VISIBILITYCHANGE_DENYREMOVE 0x08
680 #define AIM_PRIVFLAGS_ALLOWIDLE 0x01
681 #define AIM_PRIVFLAGS_ALLOWMEMBERSINCE 0x02
683 #define AIM_WARN_ANON 0x01
687 /* 0x0001 - family_oservice.c */
688 /* 0x0002 */ void aim_srv_clientready(OscarData *od, FlapConnection *conn);
689 /* 0x0004 */ void aim_srv_requestnew(OscarData *od, guint16 serviceid);
690 /* 0x0006 */ void aim_srv_reqrates(OscarData *od, FlapConnection *conn);
691 /* 0x0008 */ void aim_srv_rates_addparam(OscarData *od, FlapConnection *conn);
692 /* 0x0009 */ void aim_srv_rates_delparam(OscarData *od, FlapConnection *conn);
693 /* 0x000c */ void aim_srv_sendpauseack(OscarData *od, FlapConnection *conn);
694 /* 0x000e */ void aim_srv_reqpersonalinfo(OscarData *od, FlapConnection *conn);
695 /* 0x0011 */ void aim_srv_setidle(OscarData *od, guint32 idletime);
696 /* 0x0014 */ void aim_srv_setprivacyflags(OscarData *od, FlapConnection *conn, guint32);
697 /* 0x0016 */ void aim_srv_nop(OscarData *od, FlapConnection *conn);
698 /* 0x0017 */ void aim_srv_setversions(OscarData *od, FlapConnection *conn);
699 /* 0x001e */ int aim_srv_setextrainfo(OscarData *od, gboolean seticqstatus, guint32 icqstatus, gboolean setstatusmsg, const char *statusmsg, const char *itmsurl);
702 void aim_bos_reqrights(OscarData *od, FlapConnection *conn);
703 int aim_bos_changevisibility(OscarData *od, FlapConnection *conn, int, const char *);
704 void aim_bos_setgroupperm(OscarData *od, FlapConnection *conn, guint32 mask);
708 #define AIM_CLIENTTYPE_UNKNOWN 0x0000
709 #define AIM_CLIENTTYPE_MC 0x0001
710 #define AIM_CLIENTTYPE_WINAIM 0x0002
711 #define AIM_CLIENTTYPE_WINAIM41 0x0003
712 #define AIM_CLIENTTYPE_AOL_TOC 0x0004
713 guint16 aim_im_fingerprint(const guint8 *msghdr, int len);
715 #define AIM_RATE_CODE_CHANGE 0x0001
716 #define AIM_RATE_CODE_WARNING 0x0002
717 #define AIM_RATE_CODE_LIMIT 0x0003
718 #define AIM_RATE_CODE_CLEARLIMIT 0x0004
719 void aim_ads_requestads(OscarData *od, FlapConnection *conn);
724 #define AIM_OFT_SUBTYPE_SEND_FILE 0x0001
725 #define AIM_OFT_SUBTYPE_SEND_DIR 0x0002
726 #define AIM_OFT_SUBTYPE_GET_FILE 0x0011
727 #define AIM_OFT_SUBTYPE_GET_LIST 0x0012
729 #define AIM_TRANSFER_DENY_NOTSUPPORTED 0x0000
730 #define AIM_TRANSFER_DENY_DECLINE 0x0001
731 #define AIM_TRANSFER_DENY_NOTACCEPTING 0x0002
733 #define AIM_IMPARAM_FLAG_CHANNEL_MSGS_ALLOWED 0x00000001
734 #define AIM_IMPARAM_FLAG_MISSED_CALLS_ENABLED 0x00000002
735 #define AIM_IMPARAM_FLAG_EVENTS_ALLOWED 0x00000008
736 #define AIM_IMPARAM_FLAG_SMS_SUPPORTED 0x00000010
737 #define AIM_IMPARAM_FLAG_OFFLINE_MSGS_ALLOWED 0x00000100
739 /* This is what the server will give you if you don't set them yourself. */
740 /* This is probably out of date. */
741 #define AIM_IMPARAM_DEFAULTS { \
743 AIM_IMPARAM_FLAG_CHANNEL_MSGS_ALLOWED | AIM_IMPARAM_FLAG_MISSED_CALLS_ENABLED, \
744 512, /* !! Note how small this is. */ \
745 (99.9)*10, (99.9)*10, \
746 1000 /* !! And how large this is. */ \
749 /* This is what most AIM versions use. */
750 /* This is probably out of date. */
751 #define AIM_IMPARAM_REASONABLE { \
753 AIM_IMPARAM_FLAG_CHANNEL_MSGS_ALLOWED | AIM_IMPARAM_FLAG_MISSED_CALLS_ENABLED, \
755 (99.9)*10, (99.9)*10, \
759 struct aim_icbmparameters
762 guint32 flags; /* AIM_IMPARAM_FLAG_ */
763 guint16 maxmsglen; /* message size that you will accept */
764 guint16 maxsenderwarn; /* this and below are *10 (999=99.9%) */
765 guint16 maxrecverwarn;
766 guint32 minmsginterval; /* in milliseconds? */
770 * TODO: Should probably combine this with struct chat_connection.
772 struct aim_chat_roominfo
780 struct chat_connection
783 char *show; /* AOL did something funny to us */
786 FlapConnection *conn;
788 PurpleConnection *gc;
789 PurpleConversation *conv;
795 * All this chat struct stuff should be in family_chat.c
797 void oscar_chat_destroy(struct chat_connection *cc);
799 #define AIM_IMFLAGS_AWAY 0x0001 /* mark as an autoreply */
800 #define AIM_IMFLAGS_ACK 0x0002 /* request a receipt notice */
801 #define AIM_IMFLAGS_BUDDYREQ 0x0010 /* buddy icon requested */
802 #define AIM_IMFLAGS_HASICON 0x0020 /* already has icon */
803 #define AIM_IMFLAGS_SUBENC_MACINTOSH 0x0040 /* damn that Steve Jobs! */
804 #define AIM_IMFLAGS_CUSTOMFEATURES 0x0080 /* features field present */
805 #define AIM_IMFLAGS_EXTDATA 0x0100
806 #define AIM_IMFLAGS_X 0x0200
807 #define AIM_IMFLAGS_MULTIPART 0x0400 /* ->mpmsg section valid */
808 #define AIM_IMFLAGS_OFFLINE 0x0800 /* send to offline user */
809 #define AIM_IMFLAGS_TYPINGNOT 0x1000 /* typing notification */
811 #define AIM_CHARSET_ASCII 0x0000
812 #define AIM_CHARSET_UNICODE 0x0002 /* UTF-16BE */
813 #define AIM_CHARSET_CUSTOM 0x0003
816 * Multipart message structures.
818 typedef struct aim_mpmsg_section_s
824 struct aim_mpmsg_section_s *next;
825 } aim_mpmsg_section_t;
827 typedef struct aim_mpmsg_s
829 unsigned int numparts;
830 aim_mpmsg_section_t *parts;
833 int aim_mpmsg_init(OscarData *od, aim_mpmsg_t *mpm);
834 int aim_mpmsg_addraw(OscarData *od, aim_mpmsg_t *mpm, guint16 charset, guint16 charsubset, const gchar *data, guint16 datalen);
835 int aim_mpmsg_addascii(OscarData *od, aim_mpmsg_t *mpm, const char *ascii);
836 int aim_mpmsg_addunicode(OscarData *od, aim_mpmsg_t *mpm, const guint16 *unicode, guint16 unicodelen);
837 void aim_mpmsg_free(OscarData *od, aim_mpmsg_t *mpm);
840 * Arguments to aim_send_im_ext().
842 * This is really complicated. But immensely versatile.
845 struct aim_sendimext_args
848 /* These are _required_ */
850 guint32 flags; /* often 0 */
852 /* Only required if not using multipart messages */
856 /* Required if ->msg is not provided */
859 /* Only used if AIM_IMFLAGS_HASICON is set */
864 /* Only used if AIM_IMFLAGS_CUSTOMFEATURES is set */
868 /* Only used if AIM_IMFLAGS_CUSTOMCHARSET is set and mpmsg not used */
874 * Arguments to aim_send_rtfmsg().
876 struct aim_sendrtfmsg_args
881 const char *rtfmsg; /* must be in RTF */
885 * This information is provided in the Incoming ICBM callback for
888 * Note that although CUSTOMFEATURES and CUSTOMCHARSET say they
889 * are optional, both are always set by the current libfaim code.
890 * That may or may not change in the future. It is mainly for
891 * consistency with aim_sendimext_args.
893 * Multipart messages require some explanation. If you want to use them,
894 * I suggest you read all the comments in family_icbm.c.
897 struct aim_incomingim_ch1_args
900 /* Always provided */
902 guint32 icbmflags; /* some flags apply only to ->msg, not all mpmsg */
903 time_t timestamp; /* Only set for offline messages */
905 /* Only provided if message has a human-readable section */
909 /* Only provided if AIM_IMFLAGS_HASICON is set */
914 /* Only provided if AIM_IMFLAGS_CUSTOMFEATURES is set */
918 /* Only provided if AIM_IMFLAGS_EXTDATA is set */
922 /* Only used if AIM_IMFLAGS_CUSTOMCHARSET is set */
927 /* Valid values for channel 2 args->status */
928 #define AIM_RENDEZVOUS_PROPOSE 0x0000
929 #define AIM_RENDEZVOUS_CANCEL 0x0001
930 #define AIM_RENDEZVOUS_CONNECTED 0x0002
936 int type; /* One of the OSCAR_CAPABILITY_ constants */
938 const char *clientip;
939 const char *verifiedip;
943 const char *msg; /* invite message or file description */
945 const char *encoding;
946 const char *language;
947 guint16 requestnumber;
956 struct aim_chat_roominfo roominfo;
971 void *destructor; /* used internally only */
974 /* Valid values for channel 4 args->type */
975 #define AIM_ICQMSG_AUTHREQUEST 0x0006
976 #define AIM_ICQMSG_AUTHDENIED 0x0007
977 #define AIM_ICQMSG_AUTHGRANTED 0x0008
979 struct aim_incomingim_ch4_args
981 guint32 uin; /* Of the sender of the ICBM */
984 gchar *msg; /* Reason for auth request, deny, or accept */
988 /* SNAC sending functions */
989 /* 0x0002 */ int aim_im_setparams(OscarData *od, struct aim_icbmparameters *params);
990 /* 0x0004 */ int aim_im_reqparams(OscarData *od);
991 /* 0x0006 */ int aim_im_sendch1_ext(OscarData *od, struct aim_sendimext_args *args);
992 /* 0x0006 */ int aim_im_sendch1(OscarData *, const char *destbn, guint16 flags, const char *msg);
993 /* 0x0006 */ int aim_im_sendch2_chatinvite(OscarData *od, const char *bn, const char *msg, guint16 exchange, const char *roomname, guint16 instance);
994 /* 0x0006 */ int aim_im_sendch2_icon(OscarData *od, const char *bn, const guint8 *icon, int iconlen, time_t stamp, guint16 iconsum);
995 /* 0x0006 */ int aim_im_sendch2_rtfmsg(OscarData *od, struct aim_sendrtfmsg_args *args);
997 /* 0x0006 */ void aim_im_sendch2_cancel(PeerConnection *peer_conn);
998 /* 0x0006 */ void aim_im_sendch2_connected(PeerConnection *peer_conn);
999 /* 0x0006 */ void aim_im_sendch2_odc_requestdirect(OscarData *od, guchar *cookie, const char *bn, const guint8 *ip, guint16 port, guint16 requestnumber);
1000 /* 0x0006 */ void aim_im_sendch2_odc_requestproxy(OscarData *od, guchar *cookie, const char *bn, const guint8 *ip, guint16 pin, guint16 requestnumber);
1001 /* 0x0006 */ void aim_im_sendch2_sendfile_requestdirect(OscarData *od, guchar *cookie, const char *bn, const guint8 *ip, guint16 port, guint16 requestnumber, const gchar *filename, guint32 size, guint16 numfiles);
1002 /* 0x0006 */ void aim_im_sendch2_sendfile_requestproxy(OscarData *od, guchar *cookie, const char *bn, const guint8 *ip, guint16 pin, guint16 requestnumber, const gchar *filename, guint32 size, guint16 numfiles);
1004 /* 0x0006 */ int aim_im_sendch2_geticqaway(OscarData *od, const char *bn, int type);
1005 /* 0x0006 */ int aim_im_sendch4(OscarData *od, const char *bn, guint16 type, const char *message);
1006 /* 0x0008 */ int aim_im_warn(OscarData *od, FlapConnection *conn, const char *destbn, guint32 flags);
1007 /* 0x000b */ int aim_im_denytransfer(OscarData *od, const char *bn, const guchar *cookie, guint16 code);
1008 /* 0x0010 */ int aim_im_reqofflinemsgs(OscarData *od);
1009 /* 0x0014 */ int aim_im_sendmtn(OscarData *od, guint16 type1, const char *bn, guint16 type2);
1010 void aim_icbm_makecookie(guchar* cookie);
1011 gchar *oscar_encoding_extract(const char *encoding);
1012 gchar *oscar_encoding_to_utf8(PurpleAccount *account, const char *encoding, const char *text, int textlen);
1013 gchar *purple_plugin_oscar_decode_im_part(PurpleAccount *account, const char *sourcebn, guint16 charset, guint16 charsubset, const gchar *data, gsize datalen);
1016 /* 0x0002 - family_locate.c */
1018 * AIM User Info, Standard Form.
1020 #define AIM_FLAG_UNCONFIRMED 0x0001 /* "damned transients" */
1021 #define AIM_FLAG_ADMINISTRATOR 0x0002
1022 #define AIM_FLAG_AOL 0x0004
1023 #define AIM_FLAG_OSCAR_PAY 0x0008
1024 #define AIM_FLAG_FREE 0x0010
1025 #define AIM_FLAG_AWAY 0x0020
1026 #define AIM_FLAG_ICQ 0x0040
1027 #define AIM_FLAG_WIRELESS 0x0080
1028 #define AIM_FLAG_UNKNOWN100 0x0100
1029 #define AIM_FLAG_UNKNOWN200 0x0200
1030 #define AIM_FLAG_ACTIVEBUDDY 0x0400
1031 #define AIM_FLAG_UNKNOWN800 0x0800
1032 #define AIM_FLAG_ABINTERNAL 0x1000
1033 #define AIM_FLAG_ALLUSERS 0x001f
1035 #define AIM_USERINFO_PRESENT_FLAGS 0x00000001
1036 #define AIM_USERINFO_PRESENT_MEMBERSINCE 0x00000002
1037 #define AIM_USERINFO_PRESENT_ONLINESINCE 0x00000004
1038 #define AIM_USERINFO_PRESENT_IDLE 0x00000008
1039 #define AIM_USERINFO_PRESENT_ICQEXTSTATUS 0x00000010
1040 #define AIM_USERINFO_PRESENT_ICQIPADDR 0x00000020
1041 #define AIM_USERINFO_PRESENT_ICQDATA 0x00000040
1042 #define AIM_USERINFO_PRESENT_CAPABILITIES 0x00000080
1043 #define AIM_USERINFO_PRESENT_SESSIONLEN 0x00000100
1044 #define AIM_USERINFO_PRESENT_CREATETIME 0x00000200
1046 struct userinfo_node
1049 struct userinfo_node *next;
1052 typedef struct aim_userinfo_s
1055 guint16 warnlevel; /* evil percent * 10 (999 = 99.9%) */
1056 guint16 idletime; /* in seconds */
1058 guint32 createtime; /* time_t */
1059 guint32 membersince; /* time_t */
1060 guint32 onlinesince; /* time_t */
1061 guint32 sessionlen; /* in seconds */
1062 guint32 capabilities;
1066 guint8 crap[0x25]; /* until we figure it out... */
1070 guint8 iconcsumtype;
1071 guint16 iconcsumlen;
1075 char *info_encoding;
1079 char *status_encoding;
1083 char *itmsurl_encoding;
1084 guint16 itmsurl_len;
1087 char *away_encoding;
1090 struct aim_userinfo_s *next;
1093 #define AIM_SENDMEMBLOCK_FLAG_ISREQUEST 0
1094 #define AIM_SENDMEMBLOCK_FLAG_ISHASH 1
1096 int aim_sendmemblock(OscarData *od, FlapConnection *conn, guint32 offset, guint32 len, const guint8 *buf, guint8 flag);
1098 struct aim_invite_priv
1106 #define AIM_COOKIETYPE_UNKNOWN 0x00
1107 #define AIM_COOKIETYPE_ICBM 0x01
1108 #define AIM_COOKIETYPE_ADS 0x02
1109 #define AIM_COOKIETYPE_BOS 0x03
1110 #define AIM_COOKIETYPE_IM 0x04
1111 #define AIM_COOKIETYPE_CHAT 0x05
1112 #define AIM_COOKIETYPE_CHATNAV 0x06
1113 #define AIM_COOKIETYPE_INVITE 0x07
1114 /* we'll move OFT up a bit to give breathing room. not like it really
1116 #define AIM_COOKIETYPE_OFTIM 0x10
1117 #define AIM_COOKIETYPE_OFTGET 0x11
1118 #define AIM_COOKIETYPE_OFTSEND 0x12
1119 #define AIM_COOKIETYPE_OFTVOICE 0x13
1120 #define AIM_COOKIETYPE_OFTIMAGE 0x14
1121 #define AIM_COOKIETYPE_OFTICON 0x15
1123 aim_userinfo_t *aim_locate_finduserinfo(OscarData *od, const char *bn);
1124 void aim_locate_dorequest(OscarData *od);
1126 /* 0x0002 */ int aim_locate_reqrights(OscarData *od);
1127 /* 0x0004 */ int aim_locate_setcaps(OscarData *od, guint32 caps);
1128 /* 0x0004 */ int aim_locate_setprofile(OscarData *od, const char *profile_encoding, const gchar *profile, const int profile_len, const char *awaymsg_encoding, const gchar *awaymsg, const int awaymsg_len);
1129 /* 0x0005 */ int aim_locate_getinfo(OscarData *od, const char *, guint16);
1130 /* 0x0009 */ int aim_locate_setdirinfo(OscarData *od, const char *first, const char *middle, const char *last, const char *maiden, const char *nickname, const char *street, const char *city, const char *state, const char *zip, int country, guint16 privacy);
1131 /* 0x000b */ int aim_locate_000b(OscarData *od, const char *bn);
1132 /* 0x000f */ int aim_locate_setinterests(OscarData *od, const char *interest1, const char *interest2, const char *interest3, const char *interest4, const char *interest5, guint16 privacy);
1133 /* 0x0015 */ int aim_locate_getinfoshort(OscarData *od, const char *bn, guint32 flags);
1135 guint32 aim_locate_getcaps(OscarData *od, ByteStream *bs, int len);
1136 guint32 aim_locate_getcaps_short(OscarData *od, ByteStream *bs, int len);
1137 void aim_info_free(aim_userinfo_t *);
1138 int aim_info_extract(OscarData *od, ByteStream *bs, aim_userinfo_t *);
1139 int aim_putuserinfo(ByteStream *bs, aim_userinfo_t *info);
1143 /* 0x0003 - family_buddy.c */
1144 /* 0x0002 */ void aim_buddylist_reqrights(OscarData *, FlapConnection *);
1145 /* 0x0004 */ int aim_buddylist_set(OscarData *, FlapConnection *, const char *);
1146 /* 0x0004 */ int aim_buddylist_addbuddy(OscarData *, FlapConnection *, const char *);
1147 /* 0x0005 */ int aim_buddylist_removebuddy(OscarData *, FlapConnection *, const char *);
1151 /* 0x000a - family_userlookup.c */
1152 int aim_search_address(OscarData *, const char *);
1156 /* 0x000d - family_chatnav.c */
1157 /* 0x000e - family_chat.c */
1158 /* These apply to exchanges as well. */
1159 #define AIM_CHATROOM_FLAG_EVILABLE 0x0001
1160 #define AIM_CHATROOM_FLAG_NAV_ONLY 0x0002
1161 #define AIM_CHATROOM_FLAG_INSTANCING_ALLOWED 0x0004
1162 #define AIM_CHATROOM_FLAG_OCCUPANT_PEEK_ALLOWED 0x0008
1164 struct aim_chat_exchangeinfo
1175 #define AIM_CHATFLAGS_NOREFLECT 0x0001
1176 #define AIM_CHATFLAGS_AWAY 0x0002
1177 int aim_chat_send_im(OscarData *od, FlapConnection *conn, guint16 flags, const gchar *msg, int msglen, const char *encoding, const char *language);
1178 int aim_chat_join(OscarData *od, guint16 exchange, const char *roomname, guint16 instance);
1179 int aim_chat_attachname(FlapConnection *conn, guint16 exchange, const char *roomname, guint16 instance);
1180 char *aim_chat_getname(FlapConnection *conn);
1181 FlapConnection *aim_chat_getconn(OscarData *, const char *name);
1183 void aim_chatnav_reqrights(OscarData *od, FlapConnection *conn);
1185 int aim_chatnav_createroom(OscarData *od, FlapConnection *conn, const char *name, guint16 exchange);
1186 int aim_chat_leaveroom(OscarData *od, const char *name);
1190 /* 0x000f - family_odir.c */
1207 struct aim_odir *next;
1210 int aim_odir_email(OscarData *, const char *, const char *);
1211 int aim_odir_name(OscarData *, const char *, const char *, const char *, const char *, const char *, const char *, const char *, const char *, const char *, const char *, const char *);
1212 int aim_odir_interest(OscarData *, const char *, const char *);
1216 /* 0x0010 - family_bart.c */
1217 int aim_bart_upload(OscarData *od, const guint8 *icon, guint16 iconlen);
1218 int aim_bart_request(OscarData *od, const char *bn, guint8 iconcsumtype, const guint8 *iconstr, guint16 iconstrlen);
1222 /* 0x0013 - family_feedbag.c */
1223 #define AIM_SSI_TYPE_BUDDY 0x0000
1224 #define AIM_SSI_TYPE_GROUP 0x0001
1225 #define AIM_SSI_TYPE_PERMIT 0x0002
1226 #define AIM_SSI_TYPE_DENY 0x0003
1227 #define AIM_SSI_TYPE_PDINFO 0x0004
1228 #define AIM_SSI_TYPE_PRESENCEPREFS 0x0005
1229 #define AIM_SSI_TYPE_ICONINFO 0x0014
1231 #define AIM_SSI_ACK_SUCCESS 0x0000
1232 #define AIM_SSI_ACK_ITEMNOTFOUND 0x0002
1233 #define AIM_SSI_ACK_IDNUMINUSE 0x000a
1234 #define AIM_SSI_ACK_ATMAX 0x000c
1235 #define AIM_SSI_ACK_INVALIDNAME 0x000d
1236 #define AIM_SSI_ACK_AUTHREQUIRED 0x000e
1238 /* These flags are set in the 0x00c9 TLV of SSI teyp 0x0005 */
1239 #define AIM_SSI_PRESENCE_FLAG_SHOWIDLE 0x00000400
1240 #define AIM_SSI_PRESENCE_FLAG_NORECENTBUDDIES 0x00020000
1249 struct aim_ssi_item *next;
1257 struct aim_ssi_item *item;
1258 struct aim_ssi_tmp *next;
1261 /* These build the actual SNACs and queue them to be sent */
1262 /* 0x0002 */ int aim_ssi_reqrights(OscarData *od);
1263 /* 0x0004 */ int aim_ssi_reqdata(OscarData *od);
1264 /* 0x0005 */ int aim_ssi_reqifchanged(OscarData *od, time_t localstamp, guint16 localrev);
1265 /* 0x0007 */ int aim_ssi_enable(OscarData *od);
1266 /* 0x0011 */ int aim_ssi_modbegin(OscarData *od);
1267 /* 0x0012 */ int aim_ssi_modend(OscarData *od);
1268 /* 0x0014 */ int aim_ssi_sendauth(OscarData *od, char *bn, char *msg);
1269 /* 0x0018 */ int aim_ssi_sendauthrequest(OscarData *od, char *bn, const char *msg);
1270 /* 0x001a */ int aim_ssi_sendauthreply(OscarData *od, char *bn, guint8 reply, const char *msg);
1272 /* Client functions for retrieving SSI data */
1273 struct aim_ssi_item *aim_ssi_itemlist_find(struct aim_ssi_item *list, guint16 gid, guint16 bid);
1274 struct aim_ssi_item *aim_ssi_itemlist_finditem(struct aim_ssi_item *list, const char *gn, const char *bn, guint16 type);
1275 struct aim_ssi_item *aim_ssi_itemlist_exists(struct aim_ssi_item *list, const char *bn);
1276 char *aim_ssi_itemlist_findparentname(struct aim_ssi_item *list, const char *bn);
1277 int aim_ssi_getpermdeny(struct aim_ssi_item *list);
1278 guint32 aim_ssi_getpresence(struct aim_ssi_item *list);
1279 char *aim_ssi_getalias(struct aim_ssi_item *list, const char *gn, const char *bn);
1280 char *aim_ssi_getcomment(struct aim_ssi_item *list, const char *gn, const char *bn);
1281 gboolean aim_ssi_waitingforauth(struct aim_ssi_item *list, const char *gn, const char *bn);
1283 /* Client functions for changing SSI data */
1284 int aim_ssi_addbuddy(OscarData *od, const char *name, const char *group, GSList *tlvlist, const char *alias, const char *comment, const char *smsnum, gboolean needauth);
1285 int aim_ssi_addpermit(OscarData *od, const char *name);
1286 int aim_ssi_adddeny(OscarData *od, const char *name);
1287 int aim_ssi_delbuddy(OscarData *od, const char *name, const char *group);
1288 int aim_ssi_delgroup(OscarData *od, const char *group);
1289 int aim_ssi_delpermit(OscarData *od, const char *name);
1290 int aim_ssi_deldeny(OscarData *od, const char *name);
1291 int aim_ssi_movebuddy(OscarData *od, const char *oldgn, const char *newgn, const char *bn);
1292 int aim_ssi_aliasbuddy(OscarData *od, const char *gn, const char *bn, const char *alias);
1293 int aim_ssi_editcomment(OscarData *od, const char *gn, const char *bn, const char *alias);
1294 int aim_ssi_rename_group(OscarData *od, const char *oldgn, const char *newgn);
1295 int aim_ssi_cleanlist(OscarData *od);
1296 int aim_ssi_deletelist(OscarData *od);
1297 int aim_ssi_setpermdeny(OscarData *od, guint8 permdeny, guint32 vismask);
1298 int aim_ssi_setpresence(OscarData *od, guint32 presence);
1299 int aim_ssi_seticon(OscarData *od, const guint8 *iconsum, guint8 iconsumlen);
1300 int aim_ssi_delicon(OscarData *od);
1304 /* 0x0015 - family_icq.c */
1305 #define AIM_ICQ_INFO_SIMPLE 0x001
1306 #define AIM_ICQ_INFO_SUMMARY 0x002
1307 #define AIM_ICQ_INFO_EMAIL 0x004
1308 #define AIM_ICQ_INFO_PERSONAL 0x008
1309 #define AIM_ICQ_INFO_ADDITIONAL 0x010
1310 #define AIM_ICQ_INFO_WORK 0x020
1311 #define AIM_ICQ_INFO_INTERESTS 0x040
1312 #define AIM_ICQ_INFO_ORGS 0x080
1313 #define AIM_ICQ_INFO_UNKNOWN 0x100
1314 #define AIM_ICQ_INFO_HAVEALL 0x1ff
1316 #ifdef OLDSTYLE_ICQ_OFFLINEMSGS
1317 struct aim_icq_offlinemsg
1321 guint8 month, day, hour, minute;
1327 #endif /* OLDSTYLE_ICQ_OFFLINEMSGS */
1336 /* general and "home" information (0x00c8) */
1348 guint16 homecountry;
1350 guint8 hideemail; */
1352 /* personal (0x00dc) */
1356 char *personalwebpage;
1371 guint16 workcountry;
1377 /* additional personal information (0x00e6) */
1380 /* email (0x00eb) */
1381 guint16 numaddresses;
1384 /* we keep track of these in a linked list because we're 1337 */
1385 struct aim_icq_info *next;
1387 /* status note info */
1388 guint8 icbm_cookie[8];
1389 char *status_note_title;
1392 #ifdef OLDSTYLE_ICQ_OFFLINEMSGS
1393 int aim_icq_reqofflinemsgs(OscarData *od);
1394 int aim_icq_ackofflinemsgs(OscarData *od);
1396 int aim_icq_setsecurity(OscarData *od, gboolean auth_required, gboolean webaware);
1397 int aim_icq_changepasswd(OscarData *od, const char *passwd);
1398 int aim_icq_getsimpleinfo(OscarData *od, const char *uin);
1399 int aim_icq_getalias(OscarData *od, const char *uin);
1400 int aim_icq_getallinfo(OscarData *od, const char *uin);
1401 int aim_icq_sendsms(OscarData *od, const char *name, const char *msg, const char *alias);
1404 /* 0x0017 - family_auth.c */
1405 void aim_sendcookie(OscarData *, FlapConnection *, const guint16 length, const guint8 *);
1406 void aim_admin_changepasswd(OscarData *, FlapConnection *, const char *newpw, const char *curpw);
1407 void aim_admin_reqconfirm(OscarData *od, FlapConnection *conn);
1408 void aim_admin_getinfo(OscarData *od, FlapConnection *conn, guint16 info);
1409 void aim_admin_setemail(OscarData *od, FlapConnection *conn, const char *newemail);
1410 void aim_admin_setnick(OscarData *od, FlapConnection *conn, const char *newnick);
1414 /* 0x0018 - family_alert.c */
1415 struct aim_emailinfo
1424 struct aim_emailinfo *next;
1427 int aim_email_sendcookies(OscarData *od);
1428 int aim_email_activate(OscarData *od);
1432 /* tlv.c - TLV handling */
1435 typedef struct aim_tlv_s
1442 /* TLV handling functions */
1443 char *aim_tlv_getvalue_as_string(aim_tlv_t *tlv);
1445 aim_tlv_t *aim_tlv_gettlv(GSList *list, const guint16 type, const int nth);
1446 int aim_tlv_getlength(GSList *list, const guint16 type, const int nth);
1447 char *aim_tlv_getstr(GSList *list, const guint16 type, const int nth);
1448 guint8 aim_tlv_get8(GSList *list, const guint16 type, const int nth);
1449 guint16 aim_tlv_get16(GSList *list, const guint16 type, const int nth);
1450 guint32 aim_tlv_get32(GSList *list, const guint16 type, const int nth);
1452 /* TLV list handling functions */
1453 GSList *aim_tlvlist_read(ByteStream *bs);
1454 GSList *aim_tlvlist_readnum(ByteStream *bs, guint16 num);
1455 GSList *aim_tlvlist_readlen(ByteStream *bs, guint16 len);
1456 GSList *aim_tlvlist_copy(GSList *orig);
1458 int aim_tlvlist_count(GSList *list);
1459 int aim_tlvlist_size(GSList *list);
1460 int aim_tlvlist_cmp(GSList *one, GSList *two);
1461 int aim_tlvlist_write(ByteStream *bs, GSList **list);
1462 void aim_tlvlist_free(GSList *list);
1464 int aim_tlvlist_add_raw(GSList **list, const guint16 type, const guint16 length, const guint8 *value);
1465 int aim_tlvlist_add_noval(GSList **list, const guint16 type);
1466 int aim_tlvlist_add_8(GSList **list, const guint16 type, const guint8 value);
1467 int aim_tlvlist_add_16(GSList **list, const guint16 type, const guint16 value);
1468 int aim_tlvlist_add_32(GSList **list, const guint16 type, const guint32 value);
1469 int aim_tlvlist_add_str(GSList **list, const guint16 type, const char *value);
1470 int aim_tlvlist_add_caps(GSList **list, const guint16 type, const guint32 caps);
1471 int aim_tlvlist_add_userinfo(GSList **list, guint16 type, aim_userinfo_t *userinfo);
1472 int aim_tlvlist_add_chatroom(GSList **list, guint16 type, guint16 exchange, const char *roomname, guint16 instance);
1473 int aim_tlvlist_add_frozentlvlist(GSList **list, guint16 type, GSList **tl);
1475 int aim_tlvlist_replace_raw(GSList **list, const guint16 type, const guint16 lenth, const guint8 *value);
1476 int aim_tlvlist_replace_str(GSList **list, const guint16 type, const char *str);
1477 int aim_tlvlist_replace_noval(GSList **list, const guint16 type);
1478 int aim_tlvlist_replace_8(GSList **list, const guint16 type, const guint8 value);
1479 int aim_tlvlist_replace_16(GSList **list, const guint16 type, const guint16 value);
1480 int aim_tlvlist_replace_32(GSList **list, const guint16 type, const guint32 value);
1482 void aim_tlvlist_remove(GSList **list, const guint16 type);
1487 /* These are really ugly. You'd think this was LISP. I wish it was. */
1488 #define aimutil_put8(buf, data) ((*(buf) = (guint8)(data)&0xff),1)
1489 #define aimutil_get8(buf) ((*(buf))&0xff)
1490 #define aimutil_put16(buf, data) ( \
1491 (*(buf) = (guint8)((data)>>8)&0xff), \
1492 (*((buf)+1) = (guint8)(data)&0xff), \
1494 #define aimutil_get16(buf) ((((*(buf))<<8)&0xff00) + ((*((buf)+1)) & 0xff))
1495 #define aimutil_put32(buf, data) ( \
1496 (*((buf)) = (guint8)((data)>>24)&0xff), \
1497 (*((buf)+1) = (guint8)((data)>>16)&0xff), \
1498 (*((buf)+2) = (guint8)((data)>>8)&0xff), \
1499 (*((buf)+3) = (guint8)(data)&0xff), \
1501 #define aimutil_get32(buf) ((((*(buf))<<24)&0xff000000) + \
1502 (((*((buf)+1))<<16)&0x00ff0000) + \
1503 (((*((buf)+2))<< 8)&0x0000ff00) + \
1504 (((*((buf)+3) )&0x000000ff)))
1506 /* Little-endian versions (damn ICQ) */
1507 #define aimutil_putle8(buf, data) ( \
1508 (*(buf) = (guint8)(data) & 0xff), \
1510 #define aimutil_getle8(buf) ( \
1513 #define aimutil_putle16(buf, data) ( \
1514 (*((buf)+0) = (guint8)((data) >> 0) & 0xff), \
1515 (*((buf)+1) = (guint8)((data) >> 8) & 0xff), \
1517 #define aimutil_getle16(buf) ( \
1518 (((*((buf)+0)) << 0) & 0x00ff) + \
1519 (((*((buf)+1)) << 8) & 0xff00) \
1521 #define aimutil_putle32(buf, data) ( \
1522 (*((buf)+0) = (guint8)((data) >> 0) & 0xff), \
1523 (*((buf)+1) = (guint8)((data) >> 8) & 0xff), \
1524 (*((buf)+2) = (guint8)((data) >> 16) & 0xff), \
1525 (*((buf)+3) = (guint8)((data) >> 24) & 0xff), \
1527 #define aimutil_getle32(buf) ( \
1528 (((*((buf)+0)) << 0) & 0x000000ff) + \
1529 (((*((buf)+1)) << 8) & 0x0000ff00) + \
1530 (((*((buf)+2)) << 16) & 0x00ff0000) + \
1531 (((*((buf)+3)) << 24) & 0xff000000))
1533 int oscar_get_ui_info_int(const char *str, int default_value);
1534 const char *oscar_get_ui_info_string(const char *str, const char *default_value);
1535 gchar *oscar_get_clientstring(void);
1537 guint16 aimutil_iconsum(const guint8 *buf, int buflen);
1538 int aimutil_tokslen(char *toSearch, int theindex, char dl);
1539 int aimutil_itemcnt(char *toSearch, char dl);
1540 char *aimutil_itemindex(char *toSearch, int theindex, char dl);
1542 gboolean oscar_util_valid_name(const char *bn);
1543 gboolean oscar_util_valid_name_icq(const char *bn);
1544 gboolean oscar_util_valid_name_sms(const char *bn);
1545 int oscar_util_name_compare(const char *bn1, const char *bn2);
1557 #define AIM_MODULENAME_MAXLEN 16
1558 #define AIM_MODFLAG_MULTIFAMILY 0x0001
1559 typedef struct aim_module_s
1564 guint16 toolversion;
1566 char name[AIM_MODULENAME_MAXLEN+1];
1567 int (*snachandler)(OscarData *od, FlapConnection *conn, struct aim_module_s *mod, FlapFrame *rx, aim_modsnac_t *snac, ByteStream *bs);
1568 void (*shutdown)(OscarData *od, struct aim_module_s *mod);
1570 struct aim_module_s *next;
1573 int aim__registermodule(OscarData *od, int (*modfirst)(OscarData *, aim_module_t *));
1574 void aim__shutdownmodules(OscarData *od);
1575 aim_module_t *aim__findmodulebygroup(OscarData *od, guint16 group);
1576 aim_module_t *aim__findmodule(OscarData *od, const char *name);
1578 int admin_modfirst(OscarData *od, aim_module_t *mod);
1579 int buddylist_modfirst(OscarData *od, aim_module_t *mod);
1580 int bos_modfirst(OscarData *od, aim_module_t *mod);
1581 int search_modfirst(OscarData *od, aim_module_t *mod);
1582 int stats_modfirst(OscarData *od, aim_module_t *mod);
1583 int auth_modfirst(OscarData *od, aim_module_t *mod);
1584 int msg_modfirst(OscarData *od, aim_module_t *mod);
1585 int misc_modfirst(OscarData *od, aim_module_t *mod);
1586 int chatnav_modfirst(OscarData *od, aim_module_t *mod);
1587 int chat_modfirst(OscarData *od, aim_module_t *mod);
1588 int locate_modfirst(OscarData *od, aim_module_t *mod);
1589 int service_modfirst(OscarData *od, aim_module_t *mod);
1590 int invite_modfirst(OscarData *od, aim_module_t *mod);
1591 int translate_modfirst(OscarData *od, aim_module_t *mod);
1592 int popups_modfirst(OscarData *od, aim_module_t *mod);
1593 int adverts_modfirst(OscarData *od, aim_module_t *mod);
1594 int odir_modfirst(OscarData *od, aim_module_t *mod);
1595 int bart_modfirst(OscarData *od, aim_module_t *mod);
1596 int ssi_modfirst(OscarData *od, aim_module_t *mod);
1597 int icq_modfirst(OscarData *od, aim_module_t *mod);
1598 int email_modfirst(OscarData *od, aim_module_t *mod);
1600 void aim_genericreq_n(OscarData *od, FlapConnection *conn, guint16 family, guint16 subtype);
1601 void aim_genericreq_n_snacid(OscarData *od, FlapConnection *conn, guint16 family, guint16 subtype);
1602 void aim_genericreq_l(OscarData *od, FlapConnection *conn, guint16 family, guint16 subtype, guint32 *);
1603 void aim_genericreq_s(OscarData *od, FlapConnection *conn, guint16 family, guint16 subtype, guint16 *);
1606 int byte_stream_new(ByteStream *bs, guint32 len);
1607 int byte_stream_init(ByteStream *bs, guint8 *data, int len);
1608 void byte_stream_destroy(ByteStream *bs);
1609 int byte_stream_empty(ByteStream *bs);
1610 int byte_stream_curpos(ByteStream *bs);
1611 int byte_stream_setpos(ByteStream *bs, unsigned int off);
1612 void byte_stream_rewind(ByteStream *bs);
1613 int byte_stream_advance(ByteStream *bs, int n);
1614 guint8 byte_stream_get8(ByteStream *bs);
1615 guint16 byte_stream_get16(ByteStream *bs);
1616 guint32 byte_stream_get32(ByteStream *bs);
1617 guint8 byte_stream_getle8(ByteStream *bs);
1618 guint16 byte_stream_getle16(ByteStream *bs);
1619 guint32 byte_stream_getle32(ByteStream *bs);
1620 int byte_stream_getrawbuf(ByteStream *bs, guint8 *buf, int len);
1621 guint8 *byte_stream_getraw(ByteStream *bs, int len);
1622 char *byte_stream_getstr(ByteStream *bs, int len);
1623 int byte_stream_put8(ByteStream *bs, guint8 v);
1624 int byte_stream_put16(ByteStream *bs, guint16 v);
1625 int byte_stream_put32(ByteStream *bs, guint32 v);
1626 int byte_stream_putle8(ByteStream *bs, guint8 v);
1627 int byte_stream_putle16(ByteStream *bs, guint16 v);
1628 int byte_stream_putle32(ByteStream *bs, guint32 v);
1629 int byte_stream_putraw(ByteStream *bs, const guint8 *v, int len);
1630 int byte_stream_putstr(ByteStream *bs, const char *str);
1631 int byte_stream_putbs(ByteStream *bs, ByteStream *srcbs, int len);
1632 int byte_stream_putuid(ByteStream *bs, OscarData *od);
1633 int byte_stream_putcaps(ByteStream *bs, guint32 caps);
1636 * Inserts a BART asset block into the given byte stream. The flags
1637 * and length are set appropriately based on the value of data.
1639 void byte_stream_put_bart_asset(ByteStream *bs, guint16 type, ByteStream *data);
1642 * A helper function that calls byte_stream_put_bart_asset with the
1643 * appropriate data ByteStream given the datastr.
1645 void byte_stream_put_bart_asset_str(ByteStream *bs, guint16 type, const char *datastr);
1648 * Generic SNAC structure. Rarely if ever used.
1650 typedef struct aim_snac_s {
1657 struct aim_snac_s *next;
1661 void aim_initsnachash(OscarData *od);
1662 aim_snacid_t aim_newsnac(OscarData *, aim_snac_t *newsnac);
1663 aim_snacid_t aim_cachesnac(OscarData *od, const guint16 family, const guint16 type, const guint16 flags, const void *data, const int datalen);
1664 aim_snac_t *aim_remsnac(OscarData *, aim_snacid_t id);
1665 void aim_cleansnacs(OscarData *, int maxage);
1666 int aim_putsnac(ByteStream *, guint16 family, guint16 type, guint16 flags, aim_snacid_t id);
1668 struct chatsnacinfo {
1683 guint8 unknown[5]; /* only present in versions >= 3 */
1684 GHashTable *members; /* Key is family and subtype, value is TRUE. */
1686 struct timeval last; /**< The time when we last sent a SNAC of this rate class. */
1689 int aim_cachecookie(OscarData *od, IcbmCookie *cookie);
1690 IcbmCookie *aim_uncachecookie(OscarData *od, guint8 *cookie, int type);
1691 IcbmCookie *aim_mkcookie(guint8 *, int, void *);
1692 IcbmCookie *aim_checkcookie(OscarData *, const unsigned char *, const int);
1693 int aim_freecookie(OscarData *od, IcbmCookie *cookie);
1694 int aim_msgcookie_gettype(int type);
1695 int aim_cookie_free(OscarData *od, IcbmCookie *cookie);
1697 int aim_chat_readroominfo(ByteStream *bs, struct aim_chat_roominfo *outinfo);
1699 void flap_connection_destroy_chat(OscarData *od, FlapConnection *conn);
1705 #endif /* _OSCAR_H_ */