source: protocols/oscar/aim.h @ 6f903c3

Last change on this file since 6f903c3 was 5ebff60, checked in by dequis <dx@…>, at 2015-02-20T22:50:54Z

Reindent everything to K&R style with tabs

Used uncrustify, with the configuration file in ./doc/uncrustify.cfg

Commit author set to "Indent <please@…>" so that it's easier to
skip while doing git blame.

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