source: protocols/oscar/aim.h @ 6020e18

Last change on this file since 6020e18 was f66425d, checked in by dequis <dx@…>, at 2015-12-18T17:54:40Z

oscar: Add prefixes to all functions that may conflict with purple

When people build with ./configure --purple=1 --oscar=1, the native
oscar is compiled statically, which should take priority, but sometimes
purple's oscar is used instead and bad things happen, most of it being
due to calling bitlbee's native aim_callhandler instead of the function
with the same name of libpurple's liboscar.so.

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