source: protocols/oscar/aim.h @ 9066974

Last change on this file since 9066974 was b9369b5, checked in by Wilmer van der Gaast <wilmer@…>, at 2009-06-17T23:17:15Z

Fixed compatibility with AIM mobile messages. Should work according to
reports in bug #88 (where this patch comes from) and #bitlbee. Not sure
about side effects, one way to find out...

  • Property mode set to 100644
File size: 28.7 KB
RevLine 
[b7d3cc34]1/*
2 * Main libfaim header.  Must be included in client for prototypes/macros.
3 *
4 * "come on, i turned a chick lesbian; i think this is the hackish equivalent"
5 *                                                -- Josh Meyer
6 *
7 */
8
9#ifndef __AIM_H__
10#define __AIM_H__
11
12#include <stdio.h>
13#include <string.h>
14#include <fcntl.h>
15#include <sys/types.h>
16#include <stdlib.h>
17#include <stdarg.h>
18#include <errno.h>
19#include <time.h>
20#include <gmodule.h>
21
22#include "bitlbee.h"
23
24/* XXX adjust these based on autoconf-detected platform */
25typedef guint32 aim_snacid_t;
26typedef guint16 flap_seqnum_t;
27
28/* Portability stuff (DMP) */
29
30#if defined(mach) && defined(__APPLE__)
31#define gethostbyname(x) gethostbyname2(x, AF_INET)
32#endif
33
34/*
35 * Current Maximum Length for Screen Names (not including NULL)
36 *
37 * Currently only names up to 16 characters can be registered
38 * however it is aparently legal for them to be larger.
39 */
40#define MAXSNLEN 32
41
42/*
43 * Current Maximum Length for Instant Messages
44 *
45 * This was found basically by experiment, but not wholly
46 * accurate experiment.  It should not be regarded
47 * as completely correct.  But its a decent approximation.
48 *
49 * Note that although we can send this much, its impossible
50 * for WinAIM clients (up through the latest (4.0.1957)) to
51 * send any more than 1kb.  Amaze all your windows friends
52 * with utterly oversized instant messages!
53 *
54 * XXX: the real limit is the total SNAC size at 8192. Fix this.
55 *
56 */
57#define MAXMSGLEN 7987
58
59/*
60 * Maximum size of a Buddy Icon.
61 */
62#define MAXICONLEN 7168
63#define AIM_ICONIDENT "AVT1picture.id"
64
65/*
66 * Current Maximum Length for Chat Room Messages
67 *
68 * This is actually defined by the protocol to be
69 * dynamic, but I have yet to see due cause to
70 * define it dynamically here.  Maybe later.
71 *
72 */
73#define MAXCHATMSGLEN 512
74
75/*
76 * Standard size of an AIM authorization cookie
77 */
78#define AIM_COOKIELEN            0x100
79
80#define AIM_MD5_STRING "AOL Instant Messenger (SM)"
81
82/*
83 * Default Authorizer server name and TCP port for the OSCAR farm. 
84 *
85 * You shouldn't need to change this unless you're writing
86 * your own server.
87 *
88 * Note that only one server is needed to start the whole
89 * AIM process.  The later server addresses come from
90 * the authorizer service.
91 *
92 * This is only here for convenience.  Its still up to
93 * the client to connect to it.
94 *
95 */
[30ce1ce]96#define AIM_DEFAULT_LOGIN_SERVER "login.messaging.aol.com"
[b7d3cc34]97#define AIM_LOGIN_PORT 5190
98
99/*
100 * Size of the SNAC caching hash.
101 *
102 * Default: 16
103 *
104 */
105#define AIM_SNAC_HASH_SIZE 16
106
107/*
108 * Client info.  Filled in by the client and passed in to
109 * aim_send_login().  The information ends up getting passed to OSCAR
110 * through the initial login command.
111 *
112 */
113struct client_info_s {
114        const char *clientstring;
115        guint16 clientid;
116        int major;
117        int minor;
118        int point;
119        int build;
120        const char *country; /* two-letter abbrev */
121        const char *lang; /* two-letter abbrev */
122};
123
124#define AIM_CLIENTINFO_KNOWNGOOD_3_5_1670 { \
125        "AOL Instant Messenger (SM), version 3.5.1670/WIN32", \
126        0x0004, \
127        0x0003, \
128        0x0005, \
129        0x0000, \
130        0x0686, \
131        "us", \
132        "en", \
133}
134
135#define AIM_CLIENTINFO_KNOWNGOOD_4_1_2010 { \
136          "AOL Instant Messenger (SM), version 4.1.2010/WIN32", \
137          0x0004, \
138          0x0004, \
139          0x0001, \
140          0x0000, \
141          0x07da, \
142          "us", \
143          "en", \
144}
145
[b9369b5]146#define AIM_CLIENTINFO_KNOWNGOOD_5_1_3036 { \
147        "AOL Instant Messenger, version 5.1.3036/WIN32", \
148        0x0109, \
149        0x0005, \
150        0x0001, \
151        0x0000, \
152        0x0bdc, \
153        "us", \
154        "en", \
155}
156
[b7d3cc34]157/*
158 * I would make 4.1.2010 the default, but they seem to have found
159 * an alternate way of breaking that one.
160 *
161 * 3.5.1670 should work fine, however, you will be subjected to the
162 * memory test, which may require you to have a WinAIM binary laying
163 * around. (see login.c::memrequest())
164 */
[b9369b5]165#define AIM_CLIENTINFO_KNOWNGOOD AIM_CLIENTINFO_KNOWNGOOD_5_1_3036
[b7d3cc34]166
167#ifndef TRUE
168#define TRUE 1
169#define FALSE 0
170#endif
171
172/*
173 * These could be arbitrary, but its easier to use the actual AIM values
174 */
175#define AIM_CONN_TYPE_AUTH          0x0007
176#define AIM_CONN_TYPE_ADS           0x0005
177#define AIM_CONN_TYPE_BOS           0x0002
178#define AIM_CONN_TYPE_CHAT          0x000e
179#define AIM_CONN_TYPE_CHATNAV       0x000d
180
181/*
182 * Status values returned from aim_conn_new().  ORed together.
183 */
184#define AIM_CONN_STATUS_READY       0x0001
185#define AIM_CONN_STATUS_INTERNALERR 0x0002
186#define AIM_CONN_STATUS_RESOLVERR   0x0040
187#define AIM_CONN_STATUS_CONNERR     0x0080
188#define AIM_CONN_STATUS_INPROGRESS  0x0100
189
190#define AIM_FRAMETYPE_FLAP 0x0000
191
192/*
193 * message type flags
194 */
195#define AIM_MTYPE_PLAIN     0x01
196#define AIM_MTYPE_CHAT      0x02
197#define AIM_MTYPE_FILEREQ   0x03
198#define AIM_MTYPE_URL       0x04
199#define AIM_MTYPE_AUTHREQ   0x06
200#define AIM_MTYPE_AUTHDENY  0x07
201#define AIM_MTYPE_AUTHOK    0x08
202#define AIM_MTYPE_SERVER    0x09
203#define AIM_MTYPE_ADDED     0x0C
204#define AIM_MTYPE_WWP       0x0D
205#define AIM_MTYPE_EEXPRESS  0x0E
206#define AIM_MTYPE_CONTACTS  0x13
207#define AIM_MTYPE_PLUGIN    0x1A
208#define AIM_MTYPE_AUTOAWAY      0xE8
209#define AIM_MTYPE_AUTOBUSY      0xE9
210#define AIM_MTYPE_AUTONA        0xEA
211#define AIM_MTYPE_AUTODND       0xEB
212#define AIM_MTYPE_AUTOFFC       0xEC
213
214typedef struct aim_conn_s {
215        int fd;
216        guint16 type;
217        guint16 subtype;
218        flap_seqnum_t seqnum;
219        guint32 status;
220        void *priv; /* misc data the client may want to store */
221        void *internal; /* internal conn-specific libfaim data */
222        time_t lastactivity; /* time of last transmit */
223        int forcedlatency; 
224        void *handlerlist;
225        void *sessv; /* pointer to parent session */
226        void *inside; /* only accessible from inside libfaim */
227        struct aim_conn_s *next;
228} aim_conn_t;
229
230/*
231 * Byte Stream type. Sort of.
232 *
233 * Use of this type serves a couple purposes:
234 *   - Buffer/buflen pairs are passed all around everywhere. This turns
235 *     that into one value, as well as abstracting it slightly.
236 *   - Through the abstraction, it is possible to enable bounds checking
237 *     for robustness at the cost of performance.  But a clean failure on
238 *     weird packets is much better than a segfault.
239 *   - I like having variables named "bs".
240 *
241 * Don't touch the insides of this struct.  Or I'll have to kill you.
242 *
243 */
244typedef struct aim_bstream_s {
245        guint8 *data;
246        guint32 len;
247        guint32 offset;
248} aim_bstream_t;
249
250typedef struct aim_frame_s {
251        guint8 hdrtype; /* defines which piece of the union to use */
252        union {
253                struct { 
254                        guint8 type;
255                        flap_seqnum_t seqnum;     
256                } flap;
257        } hdr;
258        aim_bstream_t data;     /* payload stream */
259        guint8 handled;         /* 0 = new, !0 = been handled */
260        guint8 nofree;          /* 0 = free data on purge, 1 = only unlink */
261        aim_conn_t *conn;  /* the connection it came in on... */
262        struct aim_frame_s *next;
263} aim_frame_t;
264
265typedef struct aim_msgcookie_s {
266        unsigned char cookie[8];
267        int type;
268        void *data;
269        time_t addtime;
270        struct aim_msgcookie_s *next;
271} aim_msgcookie_t;
272
273/*
274 * AIM Session: The main client-data interface. 
275 *
276 */
277typedef struct aim_session_s {
278
279        /* ---- Client Accessible ------------------------ */
280
281        /* Our screen name. */
282        char sn[MAXSNLEN+1];
283
284        /*
285         * Pointer to anything the client wants to
286         * explicitly associate with this session.
287         *
288         * This is for use in the callbacks mainly. In any
289         * callback, you can access this with sess->aux_data.
290         *
291         */
292        void *aux_data;
293
294        /* ---- Internal Use Only ------------------------ */
295
296        /* Server-stored information (ssi) */
297        struct {
298                int received_data;
299                guint16 revision;
300                struct aim_ssi_item *items;
301                time_t timestamp;
302                int waiting_for_ack;
303                aim_frame_t *holding_queue;
304        } ssi;
305
306        /* Connection information */
307        aim_conn_t *connlist;
308
309        /*
310         * Transmit/receive queues.
311         *
312         * These are only used when you don't use your own lowlevel
313         * I/O.  I don't suggest that you use libfaim's internal I/O.
314         * Its really bad and the API/event model is quirky at best.
315         * 
316         */
317        aim_frame_t *queue_outgoing;   
318        aim_frame_t *queue_incoming; 
319
320        /*
321         * Tx Enqueuing function.
322         *
323         * This is how you override the transmit direction of libfaim's
324         * internal I/O.  This function will be called whenever it needs
325         * to send something.
326         *
327         */
328        int (*tx_enqueue)(struct aim_session_s *, aim_frame_t *);
329
330        /*
331         * Outstanding snac handling
332         *
333         * XXX: Should these be per-connection? -mid
334         */
335        void *snac_hash[AIM_SNAC_HASH_SIZE];
336        aim_snacid_t snacid_next;
337
338        struct aim_icq_info *icq_info;
339        struct aim_oft_info *oft_info;
340        struct aim_authresp_info *authinfo;
341        struct aim_emailinfo *emailinfo;
342
343        struct {
344                struct aim_userinfo_s *userinfo;
345                struct userinfo_node *torequest;
346                struct userinfo_node *requested;
347                int waiting_for_response;
348        } locate;
349
350        guint32 flags; /* AIM_SESS_FLAGS_ */
351
352        aim_msgcookie_t *msgcookies;
353
354        void *modlistv;
355
356        guint8 aim_icq_state;  /* ICQ representation of away state */
357} aim_session_t;
358
359/* Values for sess->flags */
360#define AIM_SESS_FLAGS_SNACLOGIN         0x00000001
361#define AIM_SESS_FLAGS_XORLOGIN          0x00000002
362#define AIM_SESS_FLAGS_NONBLOCKCONNECT   0x00000004
363#define AIM_SESS_FLAGS_DONTTIMEOUTONICBM 0x00000008
364
365/* Valid for calling aim_icq_setstatus() and for aim_userinfo_t->icqinfo.status */
366#define AIM_ICQ_STATE_NORMAL    0x00000000
367#define AIM_ICQ_STATE_AWAY      0x00000001
368#define AIM_ICQ_STATE_DND       0x00000002
369#define AIM_ICQ_STATE_OUT       0x00000004
370#define AIM_ICQ_STATE_BUSY      0x00000010
371#define AIM_ICQ_STATE_CHAT      0x00000020
372#define AIM_ICQ_STATE_INVISIBLE 0x00000100
373#define AIM_ICQ_STATE_WEBAWARE  0x00010000
374#define AIM_ICQ_STATE_HIDEIP            0x00020000
375#define AIM_ICQ_STATE_BIRTHDAY          0x00080000
376#define AIM_ICQ_STATE_DIRECTDISABLED    0x00100000
377#define AIM_ICQ_STATE_ICQHOMEPAGE       0x00200000
378#define AIM_ICQ_STATE_DIRECTREQUIREAUTH 0x10000000
379#define AIM_ICQ_STATE_DIRECTCONTACTLIST 0x20000000
380
381/*
382 * AIM User Info, Standard Form.
383 */
384typedef struct {
385        char sn[MAXSNLEN+1];
386        guint16 warnlevel;
387        guint16 idletime;
388        guint16 flags;
389        guint32 membersince;
390        guint32 onlinesince;
391        guint32 sessionlen; 
392        guint32 capabilities;
393        struct {
394                guint32 status;
395                guint32 ipaddr;
396                guint8 crap[0x25]; /* until we figure it out... */
397        } icqinfo;
398        guint32 present;
399} aim_userinfo_t;
400
401#define AIM_USERINFO_PRESENT_FLAGS        0x00000001
402#define AIM_USERINFO_PRESENT_MEMBERSINCE  0x00000002
403#define AIM_USERINFO_PRESENT_ONLINESINCE  0x00000004
404#define AIM_USERINFO_PRESENT_IDLE         0x00000008
405#define AIM_USERINFO_PRESENT_ICQEXTSTATUS 0x00000010
406#define AIM_USERINFO_PRESENT_ICQIPADDR    0x00000020
407#define AIM_USERINFO_PRESENT_ICQDATA      0x00000040
408#define AIM_USERINFO_PRESENT_CAPABILITIES 0x00000080
409#define AIM_USERINFO_PRESENT_SESSIONLEN   0x00000100
410
411const char *aim_userinfo_sn(aim_userinfo_t *ui);
412guint16 aim_userinfo_flags(aim_userinfo_t *ui);
413guint16 aim_userinfo_idle(aim_userinfo_t *ui);
414float aim_userinfo_warnlevel(aim_userinfo_t *ui);
415time_t aim_userinfo_membersince(aim_userinfo_t *ui);
416time_t aim_userinfo_onlinesince(aim_userinfo_t *ui);
417guint32 aim_userinfo_sessionlen(aim_userinfo_t *ui);
418int aim_userinfo_hascap(aim_userinfo_t *ui, guint32 cap);
419
420#define AIM_FLAG_UNCONFIRMED    0x0001 /* "damned transients" */
421#define AIM_FLAG_ADMINISTRATOR  0x0002
422#define AIM_FLAG_AOL            0x0004
423#define AIM_FLAG_OSCAR_PAY      0x0008
424#define AIM_FLAG_FREE           0x0010
425#define AIM_FLAG_AWAY           0x0020
426#define AIM_FLAG_ICQ            0x0040
427#define AIM_FLAG_WIRELESS       0x0080
428#define AIM_FLAG_UNKNOWN100     0x0100
429#define AIM_FLAG_UNKNOWN200     0x0200
430#define AIM_FLAG_ACTIVEBUDDY    0x0400
431#define AIM_FLAG_UNKNOWN800     0x0800
432#define AIM_FLAG_ABINTERNAL     0x1000
433
434#define AIM_FLAG_ALLUSERS       0x001f
435
436/*
437 * TLV handling
438 */
439
440/* Generic TLV structure. */
441typedef struct aim_tlv_s {
442        guint16 type;
443        guint16 length;
444        guint8 *value;
445} aim_tlv_t;
446
447/* List of above. */
448typedef struct aim_tlvlist_s {
449        aim_tlv_t *tlv;
450        struct aim_tlvlist_s *next;
451} aim_tlvlist_t;
452
453/* TLV-handling functions */
454
455#if 0
456/* Very, very raw TLV handling. */
457int aim_puttlv_8(guint8 *buf, const guint16 t, const guint8 v);
458int aim_puttlv_16(guint8 *buf, const guint16 t, const guint16 v);
459int aim_puttlv_32(guint8 *buf, const guint16 t, const guint32 v);
460int aim_puttlv_raw(guint8 *buf, const guint16 t, const guint16 l, const guint8 *v);
461#endif
462
463/* TLV list handling. */
464aim_tlvlist_t *aim_readtlvchain(aim_bstream_t *bs);
465void aim_freetlvchain(aim_tlvlist_t **list);
466aim_tlv_t *aim_gettlv(aim_tlvlist_t *list, guint16 t, const int n);
467char *aim_gettlv_str(aim_tlvlist_t *list, const guint16 t, const int n);
468guint8 aim_gettlv8(aim_tlvlist_t *list, const guint16 type, const int num);
469guint16 aim_gettlv16(aim_tlvlist_t *list, const guint16 t, const int n);
470guint32 aim_gettlv32(aim_tlvlist_t *list, const guint16 t, const int n);
471int aim_writetlvchain(aim_bstream_t *bs, aim_tlvlist_t **list);
472int aim_addtlvtochain8(aim_tlvlist_t **list, const guint16 t, const guint8 v);
473int aim_addtlvtochain16(aim_tlvlist_t **list, const guint16 t, const guint16 v);
474int aim_addtlvtochain32(aim_tlvlist_t **list, const guint16 type, const guint32 v);
475int aim_addtlvtochain_availmsg(aim_tlvlist_t **list, const guint16 type, const char *msg);
476int aim_addtlvtochain_raw(aim_tlvlist_t **list, const guint16 t, const guint16 l, const guint8 *v);
477int aim_addtlvtochain_caps(aim_tlvlist_t **list, const guint16 t, const guint32 caps);
478int aim_addtlvtochain_noval(aim_tlvlist_t **list, const guint16 type);
[b8ef1b1]479int aim_addtlvtochain_chatroom(aim_tlvlist_t **list, guint16 type, guint16 exchange, const char *roomname, guint16 instance);
[b7d3cc34]480int aim_addtlvtochain_userinfo(aim_tlvlist_t **list, guint16 type, aim_userinfo_t *ui);
481int aim_addtlvtochain_frozentlvlist(aim_tlvlist_t **list, guint16 type, aim_tlvlist_t **tl);
482int aim_counttlvchain(aim_tlvlist_t **list);
483int aim_sizetlvchain(aim_tlvlist_t **list);
484
485
486/*
487 * Get command from connections
488 *
489 * aim_get_commmand() is the libfaim lowlevel I/O in the receive direction.
490 * XXX Make this easily overridable.
491 *
492 */
493int aim_get_command(aim_session_t *, aim_conn_t *);
494
495/*
496 * Dispatch commands that are in the rx queue.
497 */
498void aim_rxdispatch(aim_session_t *);
499
500int aim_debugconn_sendconnect(aim_session_t *sess, aim_conn_t *conn);
501
502typedef int (*aim_rxcallback_t)(aim_session_t *, aim_frame_t *, ...);
503
504struct aim_clientrelease {
505        char *name;
506        guint32 build;
507        char *url;
508        char *info;
509};
510
511struct aim_authresp_info {
512        char *sn;
513        guint16 errorcode;
514        char *errorurl;
515        guint16 regstatus;
516        char *email;
517        char *bosip;
518        guint8 *cookie;
519        struct aim_clientrelease latestrelease;
520        struct aim_clientrelease latestbeta;
521};
522
523/* Callback data for redirect. */
524struct aim_redirect_data {
525        guint16 group;
526        const char *ip;
527        const guint8 *cookie;
528        struct { /* group == AIM_CONN_TYPE_CHAT */
529                guint16 exchange;
530                const char *room;
531                guint16 instance;
532        } chat;
533};
534
535int aim_clientready(aim_session_t *sess, aim_conn_t *conn);
536int aim_sendflapver(aim_session_t *sess, aim_conn_t *conn);
537int aim_request_login(aim_session_t *sess, aim_conn_t *conn, const char *sn);
538int aim_send_login(aim_session_t *, aim_conn_t *, const char *, const char *, struct client_info_s *, const char *key);
539int aim_encode_password_md5(const char *password, const char *key, unsigned char *digest);
540void aim_purge_rxqueue(aim_session_t *);
541
542#define AIM_TX_QUEUED    0 /* default */
543#define AIM_TX_IMMEDIATE 1
544#define AIM_TX_USER      2
545int aim_tx_setenqueue(aim_session_t *sess, int what, int (*func)(aim_session_t *, aim_frame_t *));
546
547int aim_tx_flushqueue(aim_session_t *);
548void aim_tx_purgequeue(aim_session_t *);
549
550int aim_conn_setlatency(aim_conn_t *conn, int newval);
551
552void aim_conn_kill(aim_session_t *sess, aim_conn_t **deadconn);
553
554int aim_conn_addhandler(aim_session_t *, aim_conn_t *conn, u_short family, u_short type, aim_rxcallback_t newhandler, u_short flags);
555int aim_clearhandlers(aim_conn_t *conn);
556
557aim_conn_t *aim_conn_findbygroup(aim_session_t *sess, guint16 group);
558aim_session_t *aim_conn_getsess(aim_conn_t *conn);
559void aim_conn_close(aim_conn_t *deadconn);
560aim_conn_t *aim_newconn(aim_session_t *, int type, const char *dest);
561int aim_conngetmaxfd(aim_session_t *);
562aim_conn_t *aim_select(aim_session_t *, struct timeval *, int *);
563int aim_conn_isready(aim_conn_t *);
564int aim_conn_setstatus(aim_conn_t *, int);
565int aim_conn_completeconnect(aim_session_t *sess, aim_conn_t *conn);
566int aim_conn_isconnecting(aim_conn_t *conn);
567
568typedef void (*faim_debugging_callback_t)(aim_session_t *sess, int level, const char *format, va_list va);
569int aim_setdebuggingcb(aim_session_t *sess, faim_debugging_callback_t);
570void aim_session_init(aim_session_t *, guint32 flags, int debuglevel);
571void aim_session_kill(aim_session_t *);
572void aim_setupproxy(aim_session_t *sess, const char *server, const char *username, const char *password);
573aim_conn_t *aim_getconn_type(aim_session_t *, int type);
574aim_conn_t *aim_getconn_type_all(aim_session_t *, int type);
575aim_conn_t *aim_getconn_fd(aim_session_t *, int fd);
576
577/* aim_misc.c */
578
579
580struct aim_chat_roominfo {
581        unsigned short exchange;
582        char *name;
583        unsigned short instance;
584};
585
[b8ef1b1]586struct aim_chat_invitation {
[0da65d5]587        struct im_connection * ic;
[b8ef1b1]588        char * name;
589        guint8 exchange;
590};
[b7d3cc34]591
592#define AIM_VISIBILITYCHANGE_PERMITADD    0x05
593#define AIM_VISIBILITYCHANGE_PERMITREMOVE 0x06
594#define AIM_VISIBILITYCHANGE_DENYADD      0x07
595#define AIM_VISIBILITYCHANGE_DENYREMOVE   0x08
596
597#define AIM_PRIVFLAGS_ALLOWIDLE           0x01
598#define AIM_PRIVFLAGS_ALLOWMEMBERSINCE    0x02
599
600#define AIM_WARN_ANON                     0x01
601
602int aim_sendpauseack(aim_session_t *sess, aim_conn_t *conn);
603int aim_send_warning(aim_session_t *sess, aim_conn_t *conn, const char *destsn, guint32 flags);
604int aim_nop(aim_session_t *, aim_conn_t *);
605int aim_flap_nop(aim_session_t *sess, aim_conn_t *conn);
606int aim_bos_setidle(aim_session_t *, aim_conn_t *, guint32);
607int aim_bos_changevisibility(aim_session_t *, aim_conn_t *, int, const char *);
608int aim_bos_setbuddylist(aim_session_t *, aim_conn_t *, const char *);
609int aim_bos_setprofile(aim_session_t *sess, aim_conn_t *conn, const char *profile, const char *awaymsg, guint32 caps);
610int aim_bos_setgroupperm(aim_session_t *, aim_conn_t *, guint32 mask);
611int aim_bos_setprivacyflags(aim_session_t *, aim_conn_t *, guint32);
612int aim_reqpersonalinfo(aim_session_t *, aim_conn_t *);
613int aim_reqservice(aim_session_t *, aim_conn_t *, guint16);
614int aim_bos_reqrights(aim_session_t *, aim_conn_t *);
615int aim_bos_reqbuddyrights(aim_session_t *, aim_conn_t *);
616int aim_bos_reqlocaterights(aim_session_t *, aim_conn_t *);
617int aim_setdirectoryinfo(aim_session_t *sess, aim_conn_t *conn, 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);
618int aim_setuserinterests(aim_session_t *sess, aim_conn_t *conn, const char *interest1, const char *interest2, const char *interest3, const char *interest4, const char *interest5, guint16 privacy);
619int aim_setextstatus(aim_session_t *sess, aim_conn_t *conn, guint32 status);
620
621struct aim_fileheader_t *aim_getlisting(aim_session_t *sess, FILE *);
622
623#define AIM_CLIENTTYPE_UNKNOWN  0x0000
624#define AIM_CLIENTTYPE_MC       0x0001
625#define AIM_CLIENTTYPE_WINAIM   0x0002
626#define AIM_CLIENTTYPE_WINAIM41 0x0003
627#define AIM_CLIENTTYPE_AOL_TOC  0x0004
628unsigned short aim_fingerprintclient(unsigned char *msghdr, int len);
629
630#define AIM_RATE_CODE_CHANGE     0x0001
631#define AIM_RATE_CODE_WARNING    0x0002
632#define AIM_RATE_CODE_LIMIT      0x0003
633#define AIM_RATE_CODE_CLEARLIMIT 0x0004
634int aim_ads_requestads(aim_session_t *sess, aim_conn_t *conn);
635
636/* aim_im.c */
637
638aim_conn_t *aim_sendfile_initiate(aim_session_t *, const char *destsn, const char *filename, guint16 numfiles, guint32 totsize);
639
640aim_conn_t *aim_getfile_initiate(aim_session_t *sess, aim_conn_t *conn, const char *destsn);
641int aim_oft_getfile_request(aim_session_t *sess, aim_conn_t *conn, const char *name, int size);
642int aim_oft_getfile_ack(aim_session_t *sess, aim_conn_t *conn);
643int aim_oft_getfile_end(aim_session_t *sess, aim_conn_t *conn);
644
645#define AIM_SENDMEMBLOCK_FLAG_ISREQUEST  0
646#define AIM_SENDMEMBLOCK_FLAG_ISHASH     1
647
648int aim_sendmemblock(aim_session_t *sess, aim_conn_t *conn, guint32 offset, guint32 len, const guint8 *buf, guint8 flag);
649
650#define AIM_GETINFO_GENERALINFO 0x00001
651#define AIM_GETINFO_AWAYMESSAGE 0x00003
652#define AIM_GETINFO_CAPABILITIES 0x0004
653
654struct aim_invite_priv {
655        char *sn;
656        char *roomname;
657        guint16 exchange;
658        guint16 instance;
659};
660
661#define AIM_COOKIETYPE_UNKNOWN  0x00
662#define AIM_COOKIETYPE_ICBM     0x01
663#define AIM_COOKIETYPE_ADS      0x02
664#define AIM_COOKIETYPE_BOS      0x03
665#define AIM_COOKIETYPE_IM       0x04
666#define AIM_COOKIETYPE_CHAT     0x05
667#define AIM_COOKIETYPE_CHATNAV  0x06
668#define AIM_COOKIETYPE_INVITE   0x07
669
670int aim_handlerendconnect(aim_session_t *sess, aim_conn_t *cur);
671
672#define AIM_TRANSFER_DENY_NOTSUPPORTED 0x0000
673#define AIM_TRANSFER_DENY_DECLINE 0x0001
674#define AIM_TRANSFER_DENY_NOTACCEPTING 0x0002
675int aim_denytransfer(aim_session_t *sess, const char *sender, const guint8 *cookie, unsigned short code);
676aim_conn_t *aim_accepttransfer(aim_session_t *sess, aim_conn_t *conn, const char *sn, const guint8 *cookie, const guint8 *ip, guint16 listingfiles, guint16 listingtotsize, guint16 listingsize, guint32 listingchecksum, guint16 rendid);
677
678int aim_getinfo(aim_session_t *, aim_conn_t *, const char *, unsigned short);
679int aim_sendbuddyoncoming(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *info);
680int aim_sendbuddyoffgoing(aim_session_t *sess, aim_conn_t *conn, const char *sn);
681
682#define AIM_IMPARAM_FLAG_CHANMSGS_ALLOWED       0x00000001
683#define AIM_IMPARAM_FLAG_MISSEDCALLS_ENABLED    0x00000002
684
685/* This is what the server will give you if you don't set them yourself. */
686#define AIM_IMPARAM_DEFAULTS { \
687        0, \
688        AIM_IMPARAM_FLAG_CHANMSGS_ALLOWED | AIM_IMPARAM_FLAG_MISSEDCALLS_ENABLED, \
689        512, /* !! Note how small this is. */ \
690        (99.9)*10, (99.9)*10, \
691        1000 /* !! And how large this is. */ \
692}
693
694/* This is what most AIM versions use. */
695#define AIM_IMPARAM_REASONABLE { \
696        0, \
697        AIM_IMPARAM_FLAG_CHANMSGS_ALLOWED | AIM_IMPARAM_FLAG_MISSEDCALLS_ENABLED, \
698        8000, \
699        (99.9)*10, (99.9)*10, \
700        0 \
701}
702
703
704struct aim_icbmparameters {
705        guint16 maxchan;
706        guint32 flags; /* AIM_IMPARAM_FLAG_ */
707        guint16 maxmsglen; /* message size that you will accept */
708        guint16 maxsenderwarn; /* this and below are *10 (999=99.9%) */
709        guint16 maxrecverwarn;
710        guint32 minmsginterval; /* in milliseconds? */
711};
712
713int aim_reqicbmparams(aim_session_t *sess);
714int aim_seticbmparam(aim_session_t *sess, struct aim_icbmparameters *params);
715
716/* auth.c */
717int aim_sendcookie(aim_session_t *, aim_conn_t *, const guint8 *);
718
719int aim_admin_changepasswd(aim_session_t *, aim_conn_t *, const char *newpw, const char *curpw);
720int aim_admin_reqconfirm(aim_session_t *sess, aim_conn_t *conn);
721int aim_admin_getinfo(aim_session_t *sess, aim_conn_t *conn, guint16 info);
722int aim_admin_setemail(aim_session_t *sess, aim_conn_t *conn, const char *newemail);
723int aim_admin_setnick(aim_session_t *sess, aim_conn_t *conn, const char *newnick);
724
725/* These apply to exchanges as well. */
726#define AIM_CHATROOM_FLAG_EVILABLE 0x0001
727#define AIM_CHATROOM_FLAG_NAV_ONLY 0x0002
728#define AIM_CHATROOM_FLAG_INSTANCING_ALLOWED 0x0004
729#define AIM_CHATROOM_FLAG_OCCUPANT_PEEK_ALLOWED 0x0008
730
731struct aim_chat_exchangeinfo {
732        guint16 number;
733        guint16 flags;
734        char *name;
735        char *charset1;
736        char *lang1;
737        char *charset2;
738        char *lang2;
739};
740
[73cf7fd]741#define AIM_CHATFLAGS_NOREFLECT         0x0001
742#define AIM_CHATFLAGS_AWAY              0x0002
743#define AIM_CHATFLAGS_UNICODE           0x0004
744#define AIM_CHATFLAGS_ISO_8859_1        0x0008
745
[b7d3cc34]746int aim_chat_send_im(aim_session_t *sess, aim_conn_t *conn, guint16 flags, const char *msg, int msglen);
747int aim_chat_join(aim_session_t *sess, aim_conn_t *conn, guint16 exchange, const char *roomname, guint16 instance);
748int aim_chat_attachname(aim_conn_t *conn, guint16 exchange, const char *roomname, guint16 instance);
749char *aim_chat_getname(aim_conn_t *conn);
750aim_conn_t *aim_chat_getconn(aim_session_t *, const char *name);
751
752int aim_chatnav_reqrights(aim_session_t *sess, aim_conn_t *conn);
753
754int aim_chat_invite(aim_session_t *sess, aim_conn_t *conn, const char *sn, const char *msg, guint16 exchange, const char *roomname, guint16 instance);
755
756int aim_chatnav_createroom(aim_session_t *sess, aim_conn_t *conn, const char *name, guint16 exchange);
757int aim_chat_leaveroom(aim_session_t *sess, const char *name);
758
759/* aim_util.c */
760/*
761 * These are really ugly.  You'd think this was LISP.  I wish it was.
762 *
763 * XXX With the advent of bstream's, these should be removed to enforce
764 * their use.
765 *
766 */
767#define aimutil_put8(buf, data) ((*(buf) = (u_char)(data)&0xff),1)
768#define aimutil_get8(buf) ((*(buf))&0xff)
769#define aimutil_put16(buf, data) ( \
770                (*(buf) = (u_char)((data)>>8)&0xff), \
771                (*((buf)+1) = (u_char)(data)&0xff),  \
772                2)
773#define aimutil_get16(buf) ((((*(buf))<<8)&0xff00) + ((*((buf)+1)) & 0xff))
774#define aimutil_put32(buf, data) ( \
775                (*((buf)) = (u_char)((data)>>24)&0xff), \
776                (*((buf)+1) = (u_char)((data)>>16)&0xff), \
777                (*((buf)+2) = (u_char)((data)>>8)&0xff), \
778                (*((buf)+3) = (u_char)(data)&0xff), \
779                4)
780#define aimutil_get32(buf) ((((*(buf))<<24)&0xff000000) + \
781                (((*((buf)+1))<<16)&0x00ff0000) + \
782                (((*((buf)+2))<< 8)&0x0000ff00) + \
783                (((*((buf)+3)    )&0x000000ff)))
784
785/* Little-endian versions (damn ICQ) */
786#define aimutil_putle8(buf, data) ( \
787                (*(buf) = (unsigned char)(data) & 0xff), \
788                1)
789#define aimutil_getle8(buf) ( \
790                (*(buf)) & 0xff \
791                )
792#define aimutil_putle16(buf, data) ( \
793                (*((buf)+0) = (unsigned char)((data) >> 0) & 0xff),  \
794                (*((buf)+1) = (unsigned char)((data) >> 8) & 0xff), \
795                2)
796#define aimutil_getle16(buf) ( \
797                (((*((buf)+0)) << 0) & 0x00ff) + \
798                (((*((buf)+1)) << 8) & 0xff00) \
799                )
800#define aimutil_putle32(buf, data) ( \
801                (*((buf)+0) = (unsigned char)((data) >>  0) & 0xff), \
802                (*((buf)+1) = (unsigned char)((data) >>  8) & 0xff), \
803                (*((buf)+2) = (unsigned char)((data) >> 16) & 0xff), \
804                (*((buf)+3) = (unsigned char)((data) >> 24) & 0xff), \
805                4)
806#define aimutil_getle32(buf) ( \
807                (((*((buf)+0)) <<  0) & 0x000000ff) + \
808                (((*((buf)+1)) <<  8) & 0x0000ff00) + \
809                (((*((buf)+2)) << 16) & 0x00ff0000) + \
810                (((*((buf)+3)) << 24) & 0xff000000))
811
812
813int aimutil_putstr(u_char *, const char *, int);
814int aimutil_tokslen(char *toSearch, int index, char dl);
815int aimutil_itemcnt(char *toSearch, char dl);
816char *aimutil_itemidx(char *toSearch, int index, char dl);
817int aim_sncmp(const char *a, const char *b);
818
819#include <aim_internal.h>
820
821/*
822 * SNAC Families.
823 */
824#define AIM_CB_FAM_ACK 0x0000
825#define AIM_CB_FAM_GEN 0x0001
826#define AIM_CB_FAM_SPECIAL 0xffff /* Internal libfaim use */
827
828/*
829 * SNAC Family: Ack.
830 *
831 * Not really a family, but treating it as one really
832 * helps it fit into the libfaim callback structure better.
833 *
834 */
835#define AIM_CB_ACK_ACK 0x0001
836
837/*
838 * SNAC Family: General.
839 */ 
840#define AIM_CB_GEN_ERROR 0x0001
841#define AIM_CB_GEN_CLIENTREADY 0x0002
842#define AIM_CB_GEN_SERVERREADY 0x0003
843#define AIM_CB_GEN_SERVICEREQ 0x0004
844#define AIM_CB_GEN_REDIRECT 0x0005
845#define AIM_CB_GEN_RATEINFOREQ 0x0006
846#define AIM_CB_GEN_RATEINFO 0x0007
847#define AIM_CB_GEN_RATEINFOACK 0x0008
848#define AIM_CB_GEN_RATECHANGE 0x000a
849#define AIM_CB_GEN_SERVERPAUSE 0x000b
850#define AIM_CB_GEN_SERVERRESUME 0x000d
851#define AIM_CB_GEN_REQSELFINFO 0x000e
852#define AIM_CB_GEN_SELFINFO 0x000f
853#define AIM_CB_GEN_EVIL 0x0010
854#define AIM_CB_GEN_SETIDLE 0x0011
855#define AIM_CB_GEN_MIGRATIONREQ 0x0012
856#define AIM_CB_GEN_MOTD 0x0013
857#define AIM_CB_GEN_SETPRIVFLAGS 0x0014
858#define AIM_CB_GEN_WELLKNOWNURL 0x0015
859#define AIM_CB_GEN_NOP 0x0016
860#define AIM_CB_GEN_DEFAULT 0xffff
861
862/*
863 * SNAC Family: Advertisement Services
864 */ 
865#define AIM_CB_ADS_ERROR 0x0001
866#define AIM_CB_ADS_DEFAULT 0xffff
867
868/*
869 * OFT Services
870 *
871 * See non-SNAC note below.
872 */
873#define AIM_CB_OFT_DIRECTIMCONNECTREQ 0x0001/* connect request -- actually an OSCAR CAP*/
874#define AIM_CB_OFT_DIRECTIMINCOMING 0x0002
875#define AIM_CB_OFT_DIRECTIMDISCONNECT 0x0003
876#define AIM_CB_OFT_DIRECTIMTYPING 0x0004
877#define AIM_CB_OFT_DIRECTIMINITIATE 0x0005
878
879#define AIM_CB_OFT_GETFILECONNECTREQ 0x0006 /* connect request -- actually an OSCAR CAP*/
880#define AIM_CB_OFT_GETFILELISTINGREQ 0x0007 /* OFT listing.txt request */
881#define AIM_CB_OFT_GETFILEFILEREQ 0x0008    /* received file request */
882#define AIM_CB_OFT_GETFILEFILESEND 0x0009   /* received file request confirm -- send data */
883#define AIM_CB_OFT_GETFILECOMPLETE 0x000a   /* received file send complete*/
884#define AIM_CB_OFT_GETFILEINITIATE 0x000b   /* request for file get acknowledge */
885#define AIM_CB_OFT_GETFILEDISCONNECT 0x000c   /* OFT connection disconnected.*/
886#define AIM_CB_OFT_GETFILELISTING 0x000d   /* OFT listing.txt received.*/
887#define AIM_CB_OFT_GETFILERECEIVE 0x000e   /* OFT file incoming.*/
888#define AIM_CB_OFT_GETFILELISTINGRXCONFIRM 0x000f
889#define AIM_CB_OFT_GETFILESTATE4 0x0010
890
891#define AIM_CB_OFT_SENDFILEDISCONNECT 0x0020   /* OFT connection disconnected.*/
892
893
894
895/*
896 * SNAC Family: Internal Messages
897 *
898 * This isn't truely a SNAC family either, but using
899 * these, we can integrated non-SNAC services into
900 * the SNAC-centered libfaim callback structure.
901 *
902 */ 
903#define AIM_CB_SPECIAL_AUTHSUCCESS 0x0001
904#define AIM_CB_SPECIAL_AUTHOTHER 0x0002
905#define AIM_CB_SPECIAL_CONNERR 0x0003
906#define AIM_CB_SPECIAL_CONNCOMPLETE 0x0004
907#define AIM_CB_SPECIAL_FLAPVER 0x0005
908#define AIM_CB_SPECIAL_CONNINITDONE 0x0006
909#define AIM_CB_SPECIAL_IMAGETRANSFER 0x007
910#define AIM_CB_SPECIAL_UNKNOWN 0xffff
911#define AIM_CB_SPECIAL_DEFAULT AIM_CB_SPECIAL_UNKNOWN
912
913#endif /* __AIM_H__ */
Note: See TracBrowser for help on using the repository browser.