Convert Oscar to libsoup.
[pidgin-git.git] / libpurple / protocols / oscar / oscar.h
blob5e439f176b73bb16f06f37c259ddda1db7eeb6b9
1 /*
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"
25 * -- Josh Myer
29 #ifndef PURPLE_OSCAR_OSCAR_H
30 #define PURPLE_OSCAR_OSCAR_H
32 #include "internal.h"
33 #include "circularbuffer.h"
34 #include "debug.h"
35 #include "eventloop.h"
36 #include "http.h"
37 #include "proxy.h"
38 #include "sslconn.h"
40 #include <stdio.h>
41 #include <string.h>
42 #include <fcntl.h>
43 #include <sys/types.h>
44 #include <stdlib.h>
45 #include <stdarg.h>
46 #include <errno.h>
47 #include <time.h>
49 #include <gmodule.h>
50 #include <libsoup/soup.h>
52 #ifndef _WIN32
53 #include <sys/time.h>
54 #include <unistd.h>
55 #include <netdb.h>
56 #include <netinet/in.h>
57 #include <sys/socket.h>
58 #endif
60 #define OSCAR_TYPE_PROTOCOL (oscar_protocol_get_type())
61 #define OSCAR_PROTOCOL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), OSCAR_TYPE_PROTOCOL, OscarProtocol))
62 #define OSCAR_PROTOCOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), OSCAR_TYPE_PROTOCOL, OscarProtocolClass))
63 #define OSCAR_IS_PROTOCOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), OSCAR_TYPE_PROTOCOL))
64 #define OSCAR_IS_PROTOCOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), OSCAR_TYPE_PROTOCOL))
65 #define OSCAR_PROTOCOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), OSCAR_TYPE_PROTOCOL, OscarProtocolClass))
67 typedef struct _ByteStream ByteStream;
68 typedef struct _ClientInfo ClientInfo;
69 typedef struct _FlapConnection FlapConnection;
70 typedef struct _FlapFrame FlapFrame;
71 typedef struct _IcbmArgsCh2 IcbmArgsCh2;
72 typedef struct _IcbmCookie IcbmCookie;
73 typedef struct _OscarData OscarData;
74 typedef struct _QueuedSnac QueuedSnac;
76 typedef guint32 aim_snacid_t;
78 #include "snactypes.h"
80 G_BEGIN_DECLS
82 #define FAIM_SNAC_HASH_SIZE 16
85 * Current Maximum Length for usernames (not including NULL)
87 * Currently only names up to 16 characters can be registered
88 * however it is apparently legal for them to be larger.
90 #define MAXSNLEN 97
93 * Current Maximum Length for Instant Messages
95 * This was found basically by experiment, but not wholly
96 * accurate experiment. It should not be regarded
97 * as completely correct. But its a decent approximation.
99 * Note that although we can send this much, its impossible
100 * for WinAIM clients (up through the latest (4.0.1957)) to
101 * send any more than 1kb. Amaze all your windows friends
102 * with utterly oversized instant messages!
104 #define MAXMSGLEN 2544
107 * Maximum size of a Buddy Icon.
109 #define MAXICONLEN 7168
110 #define AIM_ICONIDENT "AVT1picture.id"
113 * Found by trial and error.
115 #define MAXAVAILMSGLEN 251
118 * Maximum length for the password of an ICQ account
120 #define MAXICQPASSLEN 16
122 #define AIM_MD5_STRING "AOL Instant Messenger (SM)"
124 #define OSCAR_CONNECT_STEPS 6
127 * Client info. Filled in by the client and passed in to
128 * aim_send_login(). The information ends up getting passed to OSCAR
129 * through the initial login command.
132 struct _ClientInfo
134 const char *clientstring;
135 guint16 clientid;
136 guint16 major;
137 guint16 minor;
138 guint16 point;
139 guint16 build;
140 guint32 distrib;
141 const char *country; /* two-letter abbrev */
142 const char *lang; /* two-letter abbrev */
146 * We need to use the major-minor-micro versions from the official
147 * AIM and ICQ programs here or AOL won't let us use certain features.
149 * 0x00000611 is the distid given to us by AOL for use as the default
150 * libpurple distid.
152 #define CLIENTINFO_PURPLE_AIM { \
153 NULL, \
154 0x0109, \
155 0x0005, 0x0001, \
156 0x0000, 0x0bdc, \
157 0x00000611, \
158 "us", "en", \
161 #define CLIENTINFO_PURPLE_ICQ { \
162 NULL, \
163 0x010a, \
164 0x0014, 0x0034, \
165 0x0000, 0x0c18, \
166 0x00000611, \
167 "us", "en", \
170 typedef enum
172 OSCAR_DISCONNECT_DONE, /* not considered an error */
173 OSCAR_DISCONNECT_LOCAL_CLOSED, /* peer connections only, not considered an error */
174 OSCAR_DISCONNECT_REMOTE_CLOSED,
175 OSCAR_DISCONNECT_REMOTE_REFUSED, /* peer connections only */
176 OSCAR_DISCONNECT_LOST_CONNECTION,
177 OSCAR_DISCONNECT_INVALID_DATA,
178 OSCAR_DISCONNECT_COULD_NOT_CONNECT,
179 OSCAR_DISCONNECT_RETRYING /* peer connections only */
180 } OscarDisconnectReason;
182 #define OSCAR_CAPABILITY_BUDDYICON 0x0000000000000001LL
183 #define OSCAR_CAPABILITY_TALK 0x0000000000000002LL
184 #define OSCAR_CAPABILITY_DIRECTIM 0x0000000000000004LL
185 #define OSCAR_CAPABILITY_CHAT 0x0000000000000008LL
186 #define OSCAR_CAPABILITY_GETFILE 0x0000000000000010LL
187 #define OSCAR_CAPABILITY_SENDFILE 0x0000000000000020LL
188 #define OSCAR_CAPABILITY_GAMES 0x0000000000000040LL
189 #define OSCAR_CAPABILITY_ADDINS 0x0000000000000080LL
190 #define OSCAR_CAPABILITY_SENDBUDDYLIST 0x0000000000000100LL
191 #define OSCAR_CAPABILITY_GAMES2 0x0000000000000200LL
192 #define OSCAR_CAPABILITY_ICQ_DIRECT 0x0000000000000400LL
193 #define OSCAR_CAPABILITY_APINFO 0x0000000000000800LL
194 #define OSCAR_CAPABILITY_ICQRTF 0x0000000000001000LL
195 #define OSCAR_CAPABILITY_EMPTY 0x0000000000002000LL
196 #define OSCAR_CAPABILITY_ICQSERVERRELAY 0x0000000000004000LL
197 #define OSCAR_CAPABILITY_UNICODEOLD 0x0000000000008000LL
198 #define OSCAR_CAPABILITY_TRILLIANCRYPT 0x0000000000010000LL
199 #define OSCAR_CAPABILITY_UNICODE 0x0000000000020000LL
200 #define OSCAR_CAPABILITY_INTEROPERATE 0x0000000000040000LL
201 #define OSCAR_CAPABILITY_SHORTCAPS 0x0000000000080000LL
202 #define OSCAR_CAPABILITY_HIPTOP 0x0000000000100000LL
203 #define OSCAR_CAPABILITY_SECUREIM 0x0000000000200000LL
204 #define OSCAR_CAPABILITY_SMS 0x0000000000400000LL
205 #define OSCAR_CAPABILITY_VIDEO 0x0000000000800000LL
206 #define OSCAR_CAPABILITY_ICHATAV 0x0000000001000000LL
207 #define OSCAR_CAPABILITY_LIVEVIDEO 0x0000000002000000LL
208 #define OSCAR_CAPABILITY_CAMERA 0x0000000004000000LL
209 #define OSCAR_CAPABILITY_ICHAT_SCREENSHARE 0x0000000008000000LL
210 #define OSCAR_CAPABILITY_TYPING 0x0000000010000000LL
211 #define OSCAR_CAPABILITY_NEWCAPS 0x0000000020000000LL
212 #define OSCAR_CAPABILITY_XTRAZ 0x0000000040000000LL
213 #define OSCAR_CAPABILITY_GENERICUNKNOWN 0x0000000080000000LL
214 #define OSCAR_CAPABILITY_HTML_MSGS 0x0000000100000000LL
215 #define OSCAR_CAPABILITY_LAST 0x0000000200000000LL
217 #define OSCAR_STATUS_ID_INVISIBLE "invisible"
218 #define OSCAR_STATUS_ID_OFFLINE "offline"
219 #define OSCAR_STATUS_ID_AVAILABLE "available"
220 #define OSCAR_STATUS_ID_AWAY "away"
221 #define OSCAR_STATUS_ID_DND "dnd"
222 #define OSCAR_STATUS_ID_NA "na"
223 #define OSCAR_STATUS_ID_OCCUPIED "occupied"
224 #define OSCAR_STATUS_ID_FREE4CHAT "free4chat"
225 #define OSCAR_STATUS_ID_CUSTOM "custom"
226 #define OSCAR_STATUS_ID_MOBILE "mobile"
227 #define OSCAR_STATUS_ID_EVIL "evil"
228 #define OSCAR_STATUS_ID_DEPRESSION "depression"
229 #define OSCAR_STATUS_ID_ATHOME "athome"
230 #define OSCAR_STATUS_ID_ATWORK "atwork"
231 #define OSCAR_STATUS_ID_LUNCH "lunch"
233 typedef struct
235 PurpleProtocol parent;
236 } OscarProtocol;
238 typedef struct
240 PurpleProtocolClass parent_class;
241 } OscarProtocolClass;
244 * Returns the GType for the OscarProtocol object.
246 G_MODULE_EXPORT GType oscar_protocol_get_type(void);
249 * Byte Stream type. Sort of.
251 * Use of this type serves a couple purposes:
252 * - Buffer/buflen pairs are passed all around everywhere. This turns
253 * that into one value, as well as abstracting it slightly.
254 * - Through the abstraction, it is possible to enable bounds checking
255 * for robustness at the cost of performance. But a clean failure on
256 * weird packets is much better than a segfault.
257 * - I like having variables named "bs".
259 * Don't touch the insides of this struct. Or I'll have to kill you.
262 struct _ByteStream
264 guint8 *data;
265 size_t len;
266 size_t offset;
269 struct _QueuedSnac
271 guint16 family;
272 guint16 subtype;
273 FlapFrame *frame;
276 struct _FlapFrame
278 guint8 channel;
279 guint16 seqnum;
280 ByteStream data; /* payload stream */
283 struct _FlapConnection
285 OscarData *od; /**< Pointer to parent session. */
286 gboolean connected;
287 time_t lastactivity; /**< Time of last transmit. */
288 guint destroy_timeout;
289 OscarDisconnectReason disconnect_reason;
290 gchar *error_message;
291 guint16 disconnect_code;
293 /* A few variables that are only used when connecting */
294 PurpleProxyConnectData *connect_data;
295 guint16 cookielen;
296 guint8 *cookie;
297 gpointer new_conn_data;
299 int fd;
300 PurpleSslConnection *gsc;
301 guint8 header[6];
302 gssize header_received;
303 FlapFrame buffer_incoming;
304 PurpleCircularBuffer *buffer_outgoing;
305 guint watcher_incoming;
306 guint watcher_outgoing;
308 guint16 type;
309 guint16 subtype;
310 guint16 seqnum_out; /**< The sequence number of most recently sent packet. */
311 guint16 seqnum_in; /**< The sequence number of most recently received packet. */
312 GSList *groups;
313 GSList *rateclasses; /* Contains nodes of struct rateclass. */
314 struct rateclass *default_rateclass;
315 GHashTable *rateclass_members; /* Key is family and subtype, value is pointer to the rateclass struct to use. */
317 GQueue *queued_snacs; /**< Contains QueuedSnacs. */
318 GQueue *queued_lowpriority_snacs; /**< Contains QueuedSnacs to send only once queued_snacs is empty */
319 guint queued_timeout;
321 void *internal; /* internal conn-specific libfaim data */
324 struct _IcbmCookie
326 guchar cookie[8];
327 int type;
328 void *data;
329 time_t addtime;
330 struct _IcbmCookie *next;
333 #include "peer.h"
335 struct aim_ssi_itemlist {
336 struct aim_ssi_item *data;
337 GHashTable *idx_gid_bid;
338 GHashTable *idx_all_named_items;
342 * The main client-data interface.
344 struct _OscarData
346 /* Only used when connecting with clientLogin or Kerberos. */
347 SoupSession *http_conns;
349 gboolean iconconnecting;
350 gboolean set_icon;
352 GSList *create_rooms;
354 gboolean conf;
355 gboolean reqemail;
356 gboolean setemail;
357 char *email;
358 gboolean setnick;
359 char *newformatting;
360 gboolean chpass;
361 char *oldp;
362 char *newp;
364 GSList *oscar_chats;
365 GHashTable *buddyinfo;
366 GSList *requesticon;
368 gboolean use_ssl;
369 gboolean icq;
370 guint getblisttimer;
372 struct {
373 guint maxwatchers; /* max users who can watch you */
374 guint maxbuddies; /* max users you can watch */
375 guint maxgroups; /* max groups in server list */
376 guint maxpermits; /* max users on permit list */
377 guint maxdenies; /* max users on deny list */
378 guint maxsiglen; /* max size (bytes) of profile */
379 guint maxawaymsglen; /* max size (bytes) of posted away message */
380 } rights;
382 PurpleConnection *gc;
384 void *modlistv;
387 * Outstanding snac handling
389 * TODO: Should these be per-connection? -mid
391 void *snac_hash[FAIM_SNAC_HASH_SIZE];
392 aim_snacid_t snacid_next;
395 * TODO: Data specific to a certain family should go into a
396 * hashtable and the core parts of libfaim shouldn't
397 * need to know about them.
400 IcbmCookie *msgcookies;
401 GSList *icq_info;
403 /** Only used when connecting with the old-style BUCP login. */
404 struct aim_authresp_info *authinfo;
405 struct aim_emailinfo *emailinfo;
407 struct {
408 struct aim_userinfo_s *userinfo;
409 } locate;
411 struct {
412 gboolean have_rights;
413 } bos;
415 /* Server-stored information (ssi) */
416 struct {
417 gboolean received_data;
418 guint16 numitems;
419 struct aim_ssi_itemlist official;
420 struct aim_ssi_itemlist local;
421 struct aim_ssi_tmp *pending;
422 time_t timestamp;
423 gboolean waiting_for_ack;
424 gboolean in_transaction;
425 } ssi;
427 /** Contains pointers to handler functions for each family/subtype. */
428 GHashTable *handlerlist;
430 /** A linked list containing FlapConnections. */
431 GSList *oscar_connections;
432 guint16 default_port;
434 /** A linked list containing PeerConnections. */
435 GSList *peer_connections;
438 /* Valid for calling aim_icq_setstatus() and for aim_userinfo_t->icqinfo.status */
439 #define AIM_ICQ_STATE_NORMAL 0x00000000
440 #define AIM_ICQ_STATE_AWAY 0x00000001
441 #define AIM_ICQ_STATE_DND 0x00000002
442 #define AIM_ICQ_STATE_OUT 0x00000004
443 #define AIM_ICQ_STATE_BUSY 0x00000010
444 #define AIM_ICQ_STATE_CHAT 0x00000020
445 #define AIM_ICQ_STATE_INVISIBLE 0x00000100
446 #define AIM_ICQ_STATE_EVIL 0x00003000
447 #define AIM_ICQ_STATE_DEPRESSION 0x00004000
448 #define AIM_ICQ_STATE_ATHOME 0x00005000
449 #define AIM_ICQ_STATE_ATWORK 0x00006000
450 #define AIM_ICQ_STATE_LUNCH 0x00002001
451 #define AIM_ICQ_STATE_EVIL 0x00003000
452 #define AIM_ICQ_STATE_WEBAWARE 0x00010000
453 #define AIM_ICQ_STATE_HIDEIP 0x00020000
454 #define AIM_ICQ_STATE_BIRTHDAY 0x00080000
455 #define AIM_ICQ_STATE_ICQHOMEPAGE 0x00200000
456 #define AIM_ICQ_STATE_DIRECTREQUIREAUTH 0x10000000
459 * Only used when connecting with the old-style BUCP login.
461 struct aim_clientrelease
463 char *name;
464 guint32 build;
465 char *url;
466 char *info;
470 * Only used when connecting with the old-style BUCP login.
472 struct aim_authresp_info
474 char *bn;
475 guint16 errorcode;
476 char *errorurl;
477 guint16 regstatus;
478 char *email;
479 char *bosip;
480 guint16 cookielen;
481 guint8 *cookie;
482 char *chpassurl;
483 struct aim_clientrelease latestrelease;
484 struct aim_clientrelease latestbeta;
487 /* Callback data for redirect. */
488 struct aim_redirect_data
490 guint16 group;
491 const char *ip;
492 guint16 cookielen;
493 const guint8 *cookie;
494 const char *ssl_cert_cn;
495 guint8 use_ssl;
496 struct { /* group == SNAC_FAMILY_CHAT */
497 guint16 exchange;
498 const char *room;
499 guint16 instance;
500 } chat;
503 int oscar_connect_to_bos(PurpleConnection *gc, OscarData *od, const char *host, guint16 port, guint8 *cookie, guint16 cookielen, const char *tls_certname);
505 /* family_auth.c */
508 * Only used when connecting with the old-style BUCP login.
510 int aim_request_login(OscarData *od, FlapConnection *conn, const char *bn);
513 * Only used when connecting with the old-style BUCP login.
515 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);
518 * Only used when connecting with the old-style BUCP login.
520 /* 0x000b */ int aim_auth_securid_send(OscarData *od, const char *securid);
523 * Only used when connecting with clientLogin.
525 void send_client_login(OscarData *od, const char *username);
528 * Only used when connecting with kerberos login.
530 void send_kerberos_login(OscarData *od, const char *username);
533 /* flap_connection.c */
534 FlapConnection *flap_connection_new(OscarData *, int type);
535 void flap_connection_close(OscarData *od, FlapConnection *conn);
536 void flap_connection_destroy(FlapConnection *conn, OscarDisconnectReason reason, const gchar *error_message);
537 void flap_connection_schedule_destroy(FlapConnection *conn, OscarDisconnectReason reason, const gchar *error_message);
538 FlapConnection *flap_connection_findbygroup(OscarData *od, guint16 group);
539 FlapConnection *flap_connection_getbytype(OscarData *, int type);
540 FlapConnection *flap_connection_getbytype_all(OscarData *, int type);
541 void flap_connection_recv_cb(gpointer data, gint source, PurpleInputCondition cond);
542 void flap_connection_recv_cb_ssl(gpointer data, PurpleSslConnection *gsc, PurpleInputCondition cond);
544 void flap_connection_send(FlapConnection *conn, FlapFrame *frame);
545 void flap_connection_send_version(OscarData *od, FlapConnection *conn);
546 void flap_connection_send_version_with_cookie(OscarData *od, FlapConnection *conn, guint16 length, const guint8 *chipsahoy);
547 void flap_connection_send_version_with_cookie_and_clientinfo(OscarData *od, FlapConnection *conn, guint16 length, const guint8 *chipsahoy, ClientInfo *ci, gboolean allow_multiple_login);
548 void flap_connection_send_snac(OscarData *od, FlapConnection *conn, guint16 family, const guint16 subtype, aim_snacid_t snacid, ByteStream *data);
549 void flap_connection_send_snac_with_priority(OscarData *od, FlapConnection *conn, guint16 family, const guint16 subtype, aim_snacid_t snacid, ByteStream *data, gboolean high_priority);
550 void flap_connection_send_keepalive(OscarData *od, FlapConnection *conn);
551 FlapFrame *flap_frame_new(OscarData *od, guint16 channel, int datalen);
553 /* oscar_data.c */
554 typedef int (*aim_rxcallback_t)(OscarData *od, FlapConnection *conn, FlapFrame *frame, ...);
556 OscarData *oscar_data_new(void);
557 void oscar_data_destroy(OscarData *);
558 void oscar_data_addhandler(OscarData *od, guint16 family, guint16 subtype, aim_rxcallback_t newhandler, guint16 flags);
559 aim_rxcallback_t aim_callhandler(OscarData *od, guint16 family, guint16 subtype);
561 /* 0x0001 - family_oservice.c */
562 /* 0x0002 */ void aim_srv_clientready(OscarData *od, FlapConnection *conn);
563 /* 0x0004 */ void aim_srv_requestnew(OscarData *od, guint16 serviceid);
564 /* 0x0006 */ void aim_srv_reqrates(OscarData *od, FlapConnection *conn);
565 /* 0x0008 */ void aim_srv_rates_addparam(OscarData *od, FlapConnection *conn);
566 /* 0x000e */ void aim_srv_reqpersonalinfo(OscarData *od, FlapConnection *conn);
567 /* 0x0011 */ void aim_srv_setidle(OscarData *od, guint32 idletime);
568 /* 0x0017 */ void aim_srv_setversions(OscarData *od, FlapConnection *conn);
569 /* 0x001e */ int aim_srv_setextrainfo(OscarData *od, gboolean seticqstatus, guint32 icqstatus, gboolean setstatusmsg, const char *statusmsg, const char *itmsurl);
570 void aim_srv_set_dc_info(OscarData *od);
573 void aim_bos_reqrights(OscarData *od, FlapConnection *conn);
575 #define AIM_RATE_CODE_LIMIT 0x0003
577 /* family_icbm.c */
578 #define AIM_OFT_SUBTYPE_SEND_DIR 0x0002
580 #define AIM_TRANSFER_DENY_DECLINE 0x0001
582 #define AIM_IMPARAM_FLAG_CHANNEL_MSGS_ALLOWED 0x00000001
583 #define AIM_IMPARAM_FLAG_MISSED_CALLS_ENABLED 0x00000002
584 #define AIM_IMPARAM_FLAG_EVENTS_ALLOWED 0x00000008
585 #define AIM_IMPARAM_FLAG_SMS_SUPPORTED 0x00000010
586 #define AIM_IMPARAM_FLAG_OFFLINE_MSGS_ALLOWED 0x00000100
589 * This flag tells the server that we always send HTML in messages
590 * sent from an ICQ account to an ICQ account. (If this flag is
591 * not sent then plaintext is sent ICQ<-->ICQ (HTML is sent in all
592 * other cases)).
594 * If we send an HTML message to an old client that doesn't support
595 * HTML messages, then the oscar servers will merrily strip the HTML
596 * for us.
598 * All incoming IMs are treated as HTML.
600 #define AIM_IMPARAM_FLAG_USE_HTML_FOR_ICQ 0x00000400
602 struct aim_icbmparameters
604 guint16 maxchan;
605 guint32 flags; /* AIM_IMPARAM_FLAG_ */
606 guint16 maxmsglen; /* message size that you will accept */
607 guint16 maxsenderwarn; /* this and below are *10 (999=99.9%) */
608 guint16 maxrecverwarn;
609 guint32 minmsginterval; /* in milliseconds? */
613 * TODO: Should probably combine this with struct chat_connection.
615 struct aim_chat_roominfo
617 guint16 exchange;
618 char *name;
619 guint8 namelen;
620 guint16 instance;
623 struct chat_connection
625 char *name;
626 char *show; /* AOL did something funny to us */
627 guint16 exchange;
628 guint16 instance;
629 FlapConnection *conn;
630 int id;
631 PurpleConnection *gc;
632 PurpleChatConversation *conv;
633 guint16 maxlen;
634 guint16 maxvis;
638 * All this chat struct stuff should be in family_chat.c
640 void oscar_chat_destroy(struct chat_connection *cc);
642 #define AIM_IMFLAGS_AWAY 0x0001 /* mark as an autoreply */
643 #define AIM_IMFLAGS_ACK 0x0002 /* request a receipt notice */
644 #define AIM_IMFLAGS_BUDDYREQ 0x0010 /* buddy icon requested */
645 #define AIM_IMFLAGS_HASICON 0x0020 /* already has icon */
646 #define AIM_IMFLAGS_SUBENC_MACINTOSH 0x0040 /* damn that Steve Jobs! */
647 #define AIM_IMFLAGS_CUSTOMFEATURES 0x0080 /* features field present */
648 #define AIM_IMFLAGS_OFFLINE 0x0800 /* send to offline user */
649 #define AIM_IMFLAGS_TYPINGNOT 0x1000 /* typing notification */
651 #define AIM_CHARSET_ASCII 0x0000 /* ISO 646 */
652 #define AIM_CHARSET_UNICODE 0x0002 /* ISO 10646 (UTF-16/UCS-2BE) */
653 #define AIM_CHARSET_LATIN_1 0x0003 /* ISO 8859-1 */
656 * Arguments to aim_send_im_ext().
658 * This is really complicated. But immensely versatile.
661 struct aim_sendimext_args
663 /* These are _required_ */
664 const char *destbn;
665 guint32 flags; /* often 0 */
667 const char *msg;
668 gsize msglen;
670 /* Only used if AIM_IMFLAGS_HASICON is set */
671 guint32 iconlen;
672 time_t iconstamp;
673 guint32 iconsum;
675 guint16 featureslen;
676 guint8 *features;
678 guint16 charset;
682 * This information is provided in the Incoming ICBM callback for
683 * Channel 1 ICBM's.
685 struct aim_incomingim_ch1_args
687 guint32 icbmflags; /* some flags apply only to ->msg, not all mpmsg */
688 time_t timestamp; /* Only set for offline messages */
690 gchar *msg;
692 /* Only provided if AIM_IMFLAGS_HASICON is set */
693 time_t iconstamp;
694 guint32 iconlen;
695 guint16 iconsum;
698 /* Valid values for channel 2 args->status */
699 #define AIM_RENDEZVOUS_PROPOSE 0x0000
700 #define AIM_RENDEZVOUS_CANCEL 0x0001
701 #define AIM_RENDEZVOUS_CONNECTED 0x0002
703 struct _IcbmArgsCh2
705 guint16 status;
706 guchar cookie[8];
707 guint64 type; /* One of the OSCAR_CAPABILITY_ constants */
708 const char *proxyip;
709 const char *clientip;
710 const char *verifiedip;
711 guint16 port;
712 gboolean use_proxy;
713 guint16 errorcode;
714 const char *msg; /* invite message or file description */
715 guint16 msglen;
716 const char *encoding;
717 const char *language;
718 guint16 requestnumber;
719 union {
720 struct {
721 guint32 checksum;
722 guint32 length;
723 time_t timestamp;
724 guint8 *icon;
725 } icon;
726 struct {
727 struct aim_chat_roominfo roominfo;
728 } chat;
729 struct {
730 guint8 msgtype;
731 const char *msg;
732 } rtfmsg;
733 struct {
734 guint16 subtype;
735 guint16 totfiles;
736 guint32 totsize;
737 char *filename;
738 } sendfile;
739 } info;
740 void *destructor; /* used internally only */
743 struct aim_incomingim_ch4_args
745 guint32 uin; /* Of the sender of the ICBM */
746 guint8 type;
747 guint8 flags;
748 gchar *msg; /* Reason for auth request, deny, or accept */
749 int msglen;
752 /* SNAC sending functions */
753 /* 0x0002 */ int aim_im_setparams(OscarData *od, struct aim_icbmparameters *params);
754 /* 0x0004 */ int aim_im_reqparams(OscarData *od);
755 /* 0x0006 */ int aim_im_sendch1_ext(OscarData *od, struct aim_sendimext_args *args);
756 /* 0x0006 */ int aim_im_sendch1(OscarData *, const char *destbn, guint16 flags, const char *msg);
757 /* 0x0006 */ int aim_im_sendch2_chatinvite(OscarData *od, const char *bn, const char *msg, guint16 exchange, const char *roomname, guint16 instance);
758 /* 0x0006 */ int aim_im_sendch2_icon(OscarData *od, const char *bn, const guint8 *icon, int iconlen, time_t stamp, guint16 iconsum);
760 /* 0x0006 */ void aim_im_sendch2_cancel(PeerConnection *peer_conn);
761 /* 0x0006 */ void aim_im_sendch2_connected(PeerConnection *peer_conn);
762 /* 0x0006 */ void aim_im_sendch2_odc_requestdirect(OscarData *od, guchar *cookie, const char *bn, const guint8 *ip, guint16 port, guint16 requestnumber);
763 /* 0x0006 */ void aim_im_sendch2_odc_requestproxy(OscarData *od, guchar *cookie, const char *bn, const guint8 *ip, guint16 pin, guint16 requestnumber);
764 /* 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);
765 /* 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);
767 /* 0x000b */ int aim_im_denytransfer(OscarData *od, const char *bn, const guchar *cookie, guint16 code);
768 /* 0x0010 */ int aim_im_reqofflinemsgs(OscarData *od);
769 /* 0x0014 */ int aim_im_sendmtn(OscarData *od, guint16 type1, const char *bn, guint16 type2);
770 /* 0x000b */ int icq_relay_xstatus (OscarData *od, const char *sn, const guchar* cookie);
771 void aim_icbm_makecookie(guchar* cookie);
772 void aim_im_send_icq_confirmation(OscarData *od, const char *bn, const guchar *cookie);
774 /* 0x0002 - family_locate.c */
776 * AIM User Info, Standard Form.
778 #define AIM_FLAG_ADMINISTRATOR 0x0002
779 #define AIM_FLAG_AOL 0x0004
780 #define AIM_FLAG_AWAY 0x0020
781 #define AIM_FLAG_WIRELESS 0x0080
782 #define AIM_FLAG_ICQ 0x0040
783 #define AIM_FLAG_ACTIVEBUDDY 0x0400
785 #define AIM_USERINFO_PRESENT_FLAGS 0x00000001
786 #define AIM_USERINFO_PRESENT_MEMBERSINCE 0x00000002
787 #define AIM_USERINFO_PRESENT_ONLINESINCE 0x00000004
788 #define AIM_USERINFO_PRESENT_IDLE 0x00000008
789 #define AIM_USERINFO_PRESENT_ICQEXTSTATUS 0x00000010
790 #define AIM_USERINFO_PRESENT_ICQIPADDR 0x00000020
791 #define AIM_USERINFO_PRESENT_ICQDATA 0x00000040
792 #define AIM_USERINFO_PRESENT_CAPABILITIES 0x00000080
793 #define AIM_USERINFO_PRESENT_SESSIONLEN 0x00000100
794 #define AIM_USERINFO_PRESENT_CREATETIME 0x00000200
796 struct userinfo_node
798 char *bn;
799 struct userinfo_node *next;
802 typedef struct aim_userinfo_s
804 char *bn;
805 guint16 warnlevel; /* evil percent * 10 (999 = 99.9%) */
806 guint16 idletime; /* in seconds */
807 guint16 flags;
808 guint32 createtime; /* time_t */
809 guint32 membersince; /* time_t */
810 guint32 onlinesince; /* time_t */
811 guint32 sessionlen; /* in seconds */
812 guint64 capabilities;
813 struct {
814 guint32 status;
815 guint32 ipaddr;
816 guint8 crap[0x25]; /* until we figure it out... */
817 } icqinfo;
818 guint32 present;
820 guint8 iconcsumtype;
821 guint16 iconcsumlen;
822 guint8 *iconcsum;
824 char *info;
825 char *info_encoding;
826 guint16 info_len;
828 char *status;
829 char *status_encoding;
830 guint16 status_len;
832 char *itmsurl;
833 char *itmsurl_encoding;
834 guint16 itmsurl_len;
836 char *away;
837 char *away_encoding;
838 guint16 away_len;
840 struct aim_userinfo_s *next;
841 } aim_userinfo_t;
843 struct aim_invite_priv
845 char *bn;
846 char *roomname;
847 guint16 exchange;
848 guint16 instance;
851 #define AIM_COOKIETYPE_CHAT 0x01
852 #define AIM_COOKIETYPE_INVITE 0x02
854 aim_userinfo_t *aim_locate_finduserinfo(OscarData *od, const char *bn);
855 void aim_locate_dorequest(OscarData *od);
857 /* 0x0002 */ int aim_locate_reqrights(OscarData *od);
858 /* 0x0004 */ int aim_locate_setcaps(OscarData *od, guint64 caps);
859 /* 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);
860 /* 0x0015 */ int aim_locate_getinfoshort(OscarData *od, const char *bn, guint32 flags);
862 guint64 aim_locate_getcaps(OscarData *od, ByteStream *bs, int len);
863 guint64 aim_locate_getcaps_short(OscarData *od, ByteStream *bs, int len);
864 void aim_info_free(aim_userinfo_t *);
865 int aim_info_extract(OscarData *od, ByteStream *bs, aim_userinfo_t *);
866 int aim_putuserinfo(ByteStream *bs, aim_userinfo_t *info);
867 PurpleMood* icq_get_purple_moods(PurpleAccount *account);
868 const char* icq_get_custom_icon_description(const char *mood);
869 guint8* icq_get_custom_icon_data(const char *mood);
870 int icq_im_xstatus_request(OscarData *od, const char *sn);
872 /* 0x0003 - family_buddy.c */
873 /* 0x0002 */ void aim_buddylist_reqrights(OscarData *, FlapConnection *);
876 /* 0x000a - family_userlookup.c */
877 int aim_search_address(OscarData *, const char *);
879 struct aim_chat_exchangeinfo
881 guint16 number;
882 guint16 flags;
883 char *name;
884 char *charset1;
885 char *lang1;
886 char *charset2;
887 char *lang2;
890 #define AIM_CHATFLAGS_NOREFLECT 0x0001
891 #define AIM_CHATFLAGS_AWAY 0x0002
892 int aim_chat_send_im(OscarData *od, FlapConnection *conn, guint16 flags, const gchar *msg, int msglen, const char *encoding, const char *language);
893 int aim_chat_join(OscarData *od, guint16 exchange, const char *roomname, guint16 instance);
895 void aim_chatnav_reqrights(OscarData *od, FlapConnection *conn);
897 int aim_chatnav_createroom(OscarData *od, FlapConnection *conn, const char *name, guint16 exchange);
900 /* 0x0010 - family_bart.c */
901 int aim_bart_upload(OscarData *od, const guint8 *icon, guint16 iconlen);
902 int aim_bart_request(OscarData *od, const char *bn, guint8 iconcsumtype, const guint8 *iconstr, guint16 iconstrlen);
906 /* 0x0013 - family_feedbag.c */
907 #define AIM_SSI_TYPE_BUDDY 0x0000
908 #define AIM_SSI_TYPE_GROUP 0x0001
909 #define AIM_SSI_TYPE_PERMIT 0x0002
910 #define AIM_SSI_TYPE_DENY 0x0003
911 #define AIM_SSI_TYPE_PDINFO 0x0004
912 #define AIM_SSI_TYPE_PRESENCEPREFS 0x0005
913 #define AIM_SSI_TYPE_ICQDENY 0x000e
914 #define AIM_SSI_TYPE_ICONINFO 0x0014
916 /* These flags are set in the 0x00c9 TLV of SSI type 0x0005 */
917 #define AIM_SSI_PRESENCE_FLAG_SHOWIDLE 0x00000400
918 #define AIM_SSI_PRESENCE_FLAG_NORECENTBUDDIES 0x00020000
920 struct aim_ssi_item
922 char *name;
923 guint16 gid;
924 guint16 bid;
925 guint16 type;
926 GSList *data;
927 struct aim_ssi_item *next;
930 struct aim_ssi_tmp
932 guint16 action;
933 guint16 ack;
934 char *name;
935 struct aim_ssi_item *item;
936 struct aim_ssi_tmp *next;
939 /* These build the actual SNACs and queue them to be sent */
940 /* 0x0002 */ int aim_ssi_reqrights(OscarData *od);
941 /* 0x0004 */ int aim_ssi_reqdata(OscarData *od);
942 /* 0x0007 */ int aim_ssi_enable(OscarData *od);
943 /* 0x0011 */ int aim_ssi_modbegin(OscarData *od);
944 /* 0x0012 */ int aim_ssi_modend(OscarData *od);
945 /* 0x0018 */ int aim_ssi_sendauthrequest(OscarData *od, const char *bn, const char *msg);
946 /* 0x001a */ int aim_ssi_sendauthreply(OscarData *od, const char *bn, guint8 reply, const char *msg);
948 /* Client functions for retrieving SSI data */
949 struct aim_ssi_item *aim_ssi_itemlist_find(struct aim_ssi_itemlist *list, guint16 gid, guint16 bid);
950 struct aim_ssi_item *aim_ssi_itemlist_finditem(struct aim_ssi_itemlist *list, const char *gn, const char *bn, guint16 type);
951 struct aim_ssi_item *aim_ssi_itemlist_exists(struct aim_ssi_itemlist *list, const char *bn);
952 char *aim_ssi_itemlist_findparentname(struct aim_ssi_itemlist *list, const char *bn);
953 int aim_ssi_getpermdeny(struct aim_ssi_itemlist *list);
954 guint32 aim_ssi_getpresence(struct aim_ssi_itemlist *list);
955 char *aim_ssi_getalias(struct aim_ssi_itemlist *list, const char *gn, const char *bn);
956 char *aim_ssi_getalias_from_item(struct aim_ssi_item *item);
957 char *aim_ssi_getcomment(struct aim_ssi_itemlist *list, const char *gn, const char *bn);
958 gboolean aim_ssi_waitingforauth(struct aim_ssi_itemlist *list, const char *gn, const char *bn);
960 /* Client functions for changing SSI data */
961 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);
962 int aim_ssi_delbuddy(OscarData *od, const char *name, const char *group);
963 int aim_ssi_delgroup(OscarData *od, const char *group);
964 int aim_ssi_movebuddy(OscarData *od, const char *oldgn, const char *newgn, const char *bn);
965 int aim_ssi_aliasbuddy(OscarData *od, const char *gn, const char *bn, const char *alias);
966 int aim_ssi_editcomment(OscarData *od, const char *gn, const char *bn, const char *alias);
967 int aim_ssi_rename_group(OscarData *od, const char *oldgn, const char *newgn);
968 int aim_ssi_deletelist(OscarData *od);
969 int aim_ssi_setpermdeny(OscarData *od, guint8 permdeny);
970 int aim_ssi_setpresence(OscarData *od, guint32 presence);
971 int aim_ssi_seticon(OscarData *od, const guint8 *iconsum, guint8 iconsumlen);
972 int aim_ssi_delicon(OscarData *od);
973 int aim_ssi_add_to_private_list(OscarData *od, const char* name, guint16 list_type);
974 int aim_ssi_del_from_private_list(OscarData* od, const char* name, guint16 list_type);
976 guint16 aim_ssi_getdenyentrytype(OscarData* od);
978 struct aim_icq_info
980 guint16 reqid;
982 /* simple */
983 guint32 uin;
985 /* general and "home" information (0x00c8) */
986 char *nick;
987 char *first;
988 char *last;
989 char *email;
990 char *homecity;
991 char *homestate;
992 char *homephone;
993 char *homefax;
994 char *homeaddr;
995 char *mobile;
996 char *homezip;
997 guint16 homecountry;
998 /* guint8 timezone;
999 guint8 hideemail; */
1001 /* personal (0x00dc) */
1002 guint8 age;
1003 guint8 unknown;
1004 guint8 gender;
1005 char *personalwebpage;
1006 guint16 birthyear;
1007 guint8 birthmonth;
1008 guint8 birthday;
1009 guint8 language1;
1010 guint8 language2;
1011 guint8 language3;
1013 /* work (0x00d2) */
1014 char *workcity;
1015 char *workstate;
1016 char *workphone;
1017 char *workfax;
1018 char *workaddr;
1019 char *workzip;
1020 guint16 workcountry;
1021 char *workcompany;
1022 char *workdivision;
1023 char *workposition;
1024 char *workwebpage;
1026 /* additional personal information (0x00e6) */
1027 char *info;
1029 /* email (0x00eb) */
1030 guint16 numaddresses;
1031 char **email2;
1033 /* status note info */
1034 guint8 icbm_cookie[8];
1035 char *status_note_title;
1037 gboolean for_auth_request;
1038 char *auth_request_reason;
1041 int aim_icq_setsecurity(OscarData *od, gboolean auth_required, gboolean webaware);
1042 int aim_icq_changepasswd(OscarData *od, const char *passwd);
1043 int aim_icq_getalias(OscarData *od, const char *uin, gboolean for_auth_request, char *auth_request_reason);
1044 int aim_icq_getallinfo(OscarData *od, const char *uin);
1045 int aim_icq_sendsms(OscarData *od, const char *name, const char *msg, const char *alias);
1048 /* 0x0017 - family_auth.c */
1049 void aim_sendcookie(OscarData *, FlapConnection *, const guint16 length, const guint8 *);
1050 void aim_admin_changepasswd(OscarData *, FlapConnection *, const char *newpw, const char *curpw);
1051 void aim_admin_reqconfirm(OscarData *od, FlapConnection *conn);
1052 void aim_admin_getinfo(OscarData *od, FlapConnection *conn, guint16 info);
1053 void aim_admin_setemail(OscarData *od, FlapConnection *conn, const char *newemail);
1054 void aim_admin_setnick(OscarData *od, FlapConnection *conn, const char *newnick);
1058 /* 0x0018 - family_alert.c */
1059 struct aim_emailinfo
1061 guint8 *cookie16;
1062 guint8 *cookie8;
1063 char *url;
1064 guint16 nummsgs;
1065 guint8 unread;
1066 char *domain;
1067 guint16 flag;
1068 struct aim_emailinfo *next;
1071 int aim_email_sendcookies(OscarData *od);
1072 int aim_email_activate(OscarData *od);
1076 /* tlv.c - TLV handling */
1078 /* TLV structure */
1079 typedef struct aim_tlv_s
1081 guint16 type;
1082 guint16 length;
1083 guint8 *value;
1084 } aim_tlv_t;
1086 /* TLV handling functions */
1087 char *aim_tlv_getvalue_as_string(aim_tlv_t *tlv);
1089 aim_tlv_t *aim_tlv_gettlv(GSList *list, const guint16 type, const int nth);
1090 int aim_tlv_getlength(GSList *list, const guint16 type, const int nth);
1091 char *aim_tlv_getstr(GSList *list, const guint16 type, const int nth);
1092 guint8 aim_tlv_get8(GSList *list, const guint16 type, const int nth);
1093 guint16 aim_tlv_get16(GSList *list, const guint16 type, const int nth);
1094 guint32 aim_tlv_get32(GSList *list, const guint16 type, const int nth);
1096 /* TLV list handling functions */
1097 GSList *aim_tlvlist_read(ByteStream *bs);
1098 GSList *aim_tlvlist_readnum(ByteStream *bs, guint16 num);
1099 GSList *aim_tlvlist_readlen(ByteStream *bs, guint16 len);
1100 GSList *aim_tlvlist_copy(GSList *orig);
1102 int aim_tlvlist_count(GSList *list);
1103 size_t aim_tlvlist_size(GSList *list);
1104 int aim_tlvlist_cmp(GSList *one, GSList *two);
1105 int aim_tlvlist_write(ByteStream *bs, GSList **list);
1106 void aim_tlvlist_free(GSList *list);
1108 int aim_tlvlist_add_raw(GSList **list, const guint16 type, const guint16 length, const guint8 *value);
1109 int aim_tlvlist_add_noval(GSList **list, const guint16 type);
1110 int aim_tlvlist_add_8(GSList **list, const guint16 type, const guint8 value);
1111 int aim_tlvlist_add_16(GSList **list, const guint16 type, const guint16 value);
1112 int aim_tlvlist_add_32(GSList **list, const guint16 type, const guint32 value);
1113 int aim_tlvlist_add_str(GSList **list, const guint16 type, const char *value);
1114 int aim_tlvlist_add_caps(GSList **list, const guint16 type, const guint64 caps, const char *mood);
1115 int aim_tlvlist_add_userinfo(GSList **list, guint16 type, aim_userinfo_t *userinfo);
1116 int aim_tlvlist_add_chatroom(GSList **list, guint16 type, guint16 exchange, const char *roomname, guint16 instance);
1117 int aim_tlvlist_add_frozentlvlist(GSList **list, guint16 type, GSList **tl);
1119 int aim_tlvlist_replace_raw(GSList **list, const guint16 type, const guint16 lenth, const guint8 *value);
1120 int aim_tlvlist_replace_str(GSList **list, const guint16 type, const char *str);
1121 int aim_tlvlist_replace_noval(GSList **list, const guint16 type);
1122 int aim_tlvlist_replace_8(GSList **list, const guint16 type, const guint8 value);
1123 int aim_tlvlist_replace_16(GSList **list, const guint16 type, const guint16 value);
1124 int aim_tlvlist_replace_32(GSList **list, const guint16 type, const guint32 value);
1126 void aim_tlvlist_remove(GSList **list, const guint16 type);
1130 /* util.c */
1131 /* These are really ugly. You'd think this was LISP. I wish it was. */
1132 #define aimutil_put8(buf, data) ((*(buf) = (guint8)(data)&0xff),1)
1133 #define aimutil_get8(buf) ((*(buf))&0xff)
1134 #define aimutil_put16(buf, data) ( \
1135 (*(buf) = (guint8)((data)>>8)&0xff), \
1136 (*((buf)+1) = (guint8)(data)&0xff), \
1138 #define aimutil_get16(buf) ((((*(buf))<<8)&0xff00) + ((*((buf)+1)) & 0xff))
1139 #define aimutil_put32(buf, data) ( \
1140 (*((buf)) = (guint8)((data)>>24)&0xff), \
1141 (*((buf)+1) = (guint8)((data)>>16)&0xff), \
1142 (*((buf)+2) = (guint8)((data)>>8)&0xff), \
1143 (*((buf)+3) = (guint8)(data)&0xff), \
1145 #define aimutil_get32(buf) ((((*(buf))<<24)&0xff000000) + \
1146 (((*((buf)+1))<<16)&0x00ff0000) + \
1147 (((*((buf)+2))<< 8)&0x0000ff00) + \
1148 (((*((buf)+3) )&0x000000ff)))
1150 /* Little-endian versions (damn ICQ) */
1151 #define aimutil_putle8(buf, data) ( \
1152 (*(buf) = (guint8)(data) & 0xff), \
1154 #define aimutil_getle8(buf) ( \
1155 (*(buf)) & 0xff \
1157 #define aimutil_putle16(buf, data) ( \
1158 (*((buf)+0) = (guint8)((data) >> 0) & 0xff), \
1159 (*((buf)+1) = (guint8)((data) >> 8) & 0xff), \
1161 #define aimutil_getle16(buf) ( \
1162 (((*((buf)+0)) << 0) & 0x00ff) + \
1163 (((*((buf)+1)) << 8) & 0xff00) \
1165 #define aimutil_putle32(buf, data) ( \
1166 (*((buf)+0) = (guint8)((data) >> 0) & 0xff), \
1167 (*((buf)+1) = (guint8)((data) >> 8) & 0xff), \
1168 (*((buf)+2) = (guint8)((data) >> 16) & 0xff), \
1169 (*((buf)+3) = (guint8)((data) >> 24) & 0xff), \
1171 #define aimutil_getle32(buf) ( \
1172 (((*((buf)+0)) << 0) & 0x000000ff) + \
1173 (((*((buf)+1)) << 8) & 0x0000ff00) + \
1174 (((*((buf)+2)) << 16) & 0x00ff0000) + \
1175 (((*((buf)+3)) << 24) & 0xff000000))
1177 const char *oscar_get_msgerr_reason(size_t reason);
1178 int oscar_get_ui_info_int(const char *str, int default_value);
1179 const char *oscar_get_ui_info_string(const char *str, const char *default_value);
1180 gchar *oscar_get_clientstring(void);
1182 guint16 aimutil_iconsum(const guint8 *buf, int buflen);
1184 gboolean oscar_util_valid_name(const char *bn);
1185 gboolean oscar_util_valid_name_icq(const char *bn);
1186 gboolean oscar_util_valid_name_sms(const char *bn);
1187 int oscar_util_name_compare(const char *bn1, const char *bn2);
1188 gchar *oscar_util_format_string(const char *str, const char *name);
1189 gchar *oscar_format_buddies(GSList *buddies, const gchar *no_buddies_message);
1191 typedef struct {
1192 guint16 family;
1193 guint16 subtype;
1194 guint16 flags;
1195 guint32 id;
1196 } aim_modsnac_t;
1198 #define AIM_MODULENAME_MAXLEN 16
1199 #define AIM_MODFLAG_MULTIFAMILY 0x0001
1200 typedef struct aim_module_s
1202 guint16 family;
1203 guint16 version;
1204 guint16 toolid;
1205 guint16 toolversion;
1206 guint16 flags;
1207 char name[AIM_MODULENAME_MAXLEN+1];
1208 int (*snachandler)(OscarData *od, FlapConnection *conn, struct aim_module_s *mod, FlapFrame *rx, aim_modsnac_t *snac, ByteStream *bs);
1209 void (*shutdown)(OscarData *od, struct aim_module_s *mod);
1210 void *priv;
1211 struct aim_module_s *next;
1212 } aim_module_t;
1214 int aim__registermodule(OscarData *od, int (*modfirst)(OscarData *, aim_module_t *));
1215 void aim__shutdownmodules(OscarData *od);
1216 aim_module_t *aim__findmodulebygroup(OscarData *od, guint16 group);
1217 aim_module_t *aim__findmodule(OscarData *od, const char *name);
1219 int admin_modfirst(OscarData *od, aim_module_t *mod);
1220 int buddylist_modfirst(OscarData *od, aim_module_t *mod);
1221 int bos_modfirst(OscarData *od, aim_module_t *mod);
1222 int search_modfirst(OscarData *od, aim_module_t *mod);
1223 int stats_modfirst(OscarData *od, aim_module_t *mod);
1224 int auth_modfirst(OscarData *od, aim_module_t *mod);
1225 int msg_modfirst(OscarData *od, aim_module_t *mod);
1226 int misc_modfirst(OscarData *od, aim_module_t *mod);
1227 int chatnav_modfirst(OscarData *od, aim_module_t *mod);
1228 int chat_modfirst(OscarData *od, aim_module_t *mod);
1229 int locate_modfirst(OscarData *od, aim_module_t *mod);
1230 int service_modfirst(OscarData *od, aim_module_t *mod);
1231 int popups_modfirst(OscarData *od, aim_module_t *mod);
1232 int bart_modfirst(OscarData *od, aim_module_t *mod);
1233 int ssi_modfirst(OscarData *od, aim_module_t *mod);
1234 int icq_modfirst(OscarData *od, aim_module_t *mod);
1235 int email_modfirst(OscarData *od, aim_module_t *mod);
1237 void aim_genericreq_n(OscarData *od, FlapConnection *conn, guint16 family, guint16 subtype);
1238 void aim_genericreq_n_snacid(OscarData *od, FlapConnection *conn, guint16 family, guint16 subtype);
1239 void aim_genericreq_l(OscarData *od, FlapConnection *conn, guint16 family, guint16 subtype, guint32 *);
1241 /* bstream.c */
1242 int byte_stream_new(ByteStream *bs, size_t len);
1243 int byte_stream_init(ByteStream *bs, guint8 *data, size_t len);
1244 void byte_stream_destroy(ByteStream *bs);
1245 size_t byte_stream_bytes_left(ByteStream *bs);
1246 int byte_stream_curpos(ByteStream *bs);
1247 int byte_stream_setpos(ByteStream *bs, size_t off);
1248 void byte_stream_rewind(ByteStream *bs);
1249 int byte_stream_advance(ByteStream *bs, int n);
1250 guint8 byte_stream_get8(ByteStream *bs);
1251 guint16 byte_stream_get16(ByteStream *bs);
1252 guint32 byte_stream_get32(ByteStream *bs);
1253 guint8 byte_stream_getle8(ByteStream *bs);
1254 guint16 byte_stream_getle16(ByteStream *bs);
1255 guint32 byte_stream_getle32(ByteStream *bs);
1256 int byte_stream_getrawbuf(ByteStream *bs, guint8 *buf, size_t len);
1257 guint8 *byte_stream_getraw(ByteStream *bs, size_t len);
1258 char *byte_stream_getstr(ByteStream *bs, size_t len);
1259 int byte_stream_put8(ByteStream *bs, guint8 v);
1260 int byte_stream_put16(ByteStream *bs, guint16 v);
1261 int byte_stream_put32(ByteStream *bs, guint32 v);
1262 int byte_stream_putle8(ByteStream *bs, guint8 v);
1263 int byte_stream_putle16(ByteStream *bs, guint16 v);
1264 int byte_stream_putle32(ByteStream *bs, guint32 v);
1265 int byte_stream_putraw(ByteStream *bs, const guint8 *v, size_t len);
1266 int byte_stream_putstr(ByteStream *bs, const char *str);
1267 int byte_stream_putbs(ByteStream *bs, ByteStream *srcbs, size_t len);
1268 int byte_stream_putuid(ByteStream *bs, OscarData *od);
1269 int byte_stream_putcaps(ByteStream *bs, guint64 caps);
1272 * Inserts a BART asset block into the given byte stream. The flags
1273 * and length are set appropriately based on the value of data.
1275 void byte_stream_put_bart_asset(ByteStream *bs, guint16 type, ByteStream *data);
1278 * A helper function that calls byte_stream_put_bart_asset with the
1279 * appropriate data ByteStream given the datastr.
1281 void byte_stream_put_bart_asset_str(ByteStream *bs, guint16 type, const char *datastr);
1284 * Generic SNAC structure. Rarely if ever used.
1286 typedef struct aim_snac_s {
1287 aim_snacid_t id;
1288 guint16 family;
1289 guint16 type;
1290 guint16 flags;
1291 void *data;
1292 time_t issuetime;
1293 struct aim_snac_s *next;
1294 } aim_snac_t;
1296 /* snac.c */
1297 void aim_initsnachash(OscarData *od);
1298 aim_snacid_t aim_newsnac(OscarData *, aim_snac_t *newsnac);
1299 aim_snacid_t aim_cachesnac(OscarData *od, const guint16 family, const guint16 type, const guint16 flags, const void *data, const int datalen);
1300 aim_snac_t *aim_remsnac(OscarData *, aim_snacid_t id);
1301 void aim_cleansnacs(OscarData *, int maxage);
1302 int aim_putsnac(ByteStream *, guint16 family, guint16 type, aim_snacid_t id);
1304 struct chatsnacinfo {
1305 guint16 exchange;
1306 char name[128];
1307 guint16 instance;
1310 struct rateclass {
1311 guint16 classid;
1312 guint32 windowsize;
1313 guint32 clear;
1314 guint32 alert;
1315 guint32 limit;
1316 guint32 disconnect;
1317 guint32 current;
1318 guint32 max;
1319 guint8 dropping_snacs;
1321 struct timeval last; /**< The time when we last sent a SNAC of this rate class. */
1324 int aim_cachecookie(OscarData *od, IcbmCookie *cookie);
1325 IcbmCookie *aim_uncachecookie(OscarData *od, guint8 *cookie, int type);
1326 IcbmCookie *aim_mkcookie(guint8 *, int, void *);
1327 IcbmCookie *aim_checkcookie(OscarData *, const unsigned char *, const int);
1328 int aim_freecookie(OscarData *od, IcbmCookie *cookie);
1329 int aim_cookie_free(OscarData *od, IcbmCookie *cookie);
1331 int aim_chat_readroominfo(ByteStream *bs, struct aim_chat_roominfo *outinfo);
1333 void flap_connection_destroy_chat(OscarData *od, FlapConnection *conn);
1335 /* userinfo.c - displaying user information */
1337 void oscar_user_info_append_status(PurpleConnection *gc, PurpleNotifyUserInfo *user_info, PurpleBuddy *b, aim_userinfo_t *userinfo, gboolean use_html_status);
1338 void oscar_user_info_append_extra_info(PurpleConnection *gc, PurpleNotifyUserInfo *user_info, PurpleBuddy *b, aim_userinfo_t *userinfo);
1339 void oscar_user_info_display_error(OscarData *od, guint16 error_reason, char *buddy);
1340 void oscar_user_info_display_icq(OscarData *od, struct aim_icq_info *info);
1341 void oscar_user_info_display_aim(OscarData *od, aim_userinfo_t *userinfo);
1343 /* authorization.c - OSCAR authorization requests */
1344 void oscar_auth_sendrequest(PurpleConnection *gc, const char *name, const char *msg);
1345 void oscar_auth_sendrequest_menu(PurpleBlistNode *node, gpointer ignored);
1346 void oscar_auth_recvrequest(PurpleConnection *gc, gchar *name, gchar *nick, gchar *reason);
1348 void oscar_set_aim_permdeny(PurpleConnection *gc);
1350 struct buddyinfo
1352 gboolean typingnot;
1353 guint32 ipaddr;
1355 unsigned long ico_me_len;
1356 unsigned long ico_me_csum;
1357 time_t ico_me_time;
1358 gboolean ico_informed;
1360 unsigned long ico_len;
1361 unsigned long ico_csum;
1362 time_t ico_time;
1363 gboolean ico_need;
1364 gboolean ico_sent;
1367 struct name_data
1369 PurpleConnection *gc;
1370 gchar *name;
1371 gchar *nick;
1374 void oscar_free_name_data(struct name_data *data);
1376 void oscar_init_account_options(PurpleProtocol *protocol, gboolean is_icq);
1378 G_END_DECLS
1380 #endif /* PURPLE_OSCAR_OSCAR_H */