source: libfaim/aim.h @ 1286893

release-1.10release-1.6release-1.7release-1.8release-1.9
Last change on this file since 1286893 was f8074e9, checked in by Anders Kaseorg <andersk@mit.edu>, 14 years ago
Use bool from <stdbool.h> instead of an ad-hoc definition in libfaim/aim.h. Signed-off-by: Anders Kaseorg <andersk@mit.edu> Reviewed-by: Nelson Elhage <nelhage@mit.edu>
  • Property mode set to 100644
File size: 46.0 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 Myer
6 *
7 */
8
9#ifndef __AIM_H__
10#define __AIM_H__
11
12#define FAIM_VERSION_MAJOR 0
13#define FAIM_VERSION_MINOR 99
14#define FAIM_VERSION_MINORMINOR 1
15
16#include <faimconfig.h>
17#include <aim_cbtypes.h>
18
19#include <stdbool.h>
20#include <stdio.h>
21#include <string.h>
22#include <fcntl.h>
23#include <sys/types.h>
24#include <stdlib.h>
25#include <stdarg.h>
26#include <errno.h>
27#include <time.h>
28
29#ifndef _WIN32
30#include <sys/time.h>
31#include <unistd.h>
32#include <netdb.h>
33#include <netinet/in.h>
34#include <sys/socket.h>
35#else
36#include <winsock.h>
37#endif
38
39#ifdef __cplusplus
40extern "C" {
41#endif
42
43/* XXX adjust these based on autoconf-detected platform */
44typedef unsigned char fu8_t;
45typedef unsigned short fu16_t;
46typedef unsigned int fu32_t;
47typedef fu32_t aim_snacid_t;
48typedef fu16_t flap_seqnum_t;
49
50#if defined(mach) && defined(__APPLE__)
51#define gethostbyname(x) gethostbyname2(x, AF_INET)
52#endif
53
54#if defined(_WIN32) && !defined(WIN32_STATIC)
55/*
56 * For a win32 DLL, we define WIN32_INDLL if this file
57 * is included while compiling the DLL. If its not
58 * defined (its included in a client app), the symbols
59 * will be imported instead of exported.
60 */
61#ifdef WIN32_INDLL
62#define faim_export __declspec(dllexport)
63#else
64#define faim_export __declspec(dllimport)
65#endif /* WIN32_INDLL */
66#define faim_internal
67#else
68/*
69 * Nothing normally needed for unix...
70 */
71#define faim_export
72#define faim_internal
73#endif
74
75#ifndef FALSE
76#define FALSE false
77#endif
78
79#ifndef TRUE
80#define TRUE true
81#endif
82
83/*
84 * Current Maximum Length for Screen Names (not including NULL)
85 *
86 * Currently only names up to 16 characters can be registered
87 * however it is aparently legal for them to be larger.
88 */
89#define MAXSNLEN 97
90
91/*
92 * Current Maximum Length for Instant Messages
93 *
94 * This was found basically by experiment, but not wholly
95 * accurate experiment.  It should not be regarded
96 * as completely correct.  But its a decent approximation.
97 *
98 * Note that although we can send this much, its impossible
99 * for WinAIM clients (up through the latest (4.0.1957)) to
100 * send any more than 1kb.  Amaze all your windows friends
101 * with utterly oversized instant messages!
102 *
103 * XXX: the real limit is the total SNAC size at 8192. Fix this.
104 *
105 */
106#define MAXMSGLEN 7987
107
108/*
109 * Maximum size of a Buddy Icon.
110 */
111#define MAXICONLEN 7168
112#define AIM_ICONIDENT "AVT1picture.id"
113
114/*
115 * Current Maximum Length for Chat Room Messages
116 *
117 * This is actually defined by the protocol to be
118 * dynamic, but I have yet to see due cause to
119 * define it dynamically here.  Maybe later.
120 *
121 */
122#define MAXCHATMSGLEN 512
123
124/**
125 * Maximum length for the password of an ICQ account
126 */
127#define MAXICQPASSLEN 8
128
129#define AIM_MD5_STRING "AOL Instant Messenger (SM)"
130
131/*
132 * Client info.  Filled in by the client and passed in to
133 * aim_send_login().  The information ends up getting passed to OSCAR
134 * through the initial login command.
135 *
136 */
137struct client_info_s {
138        const char *clientstring;
139        fu16_t clientid;
140        fu16_t major;
141        fu16_t minor;
142        fu16_t point;
143        fu16_t build;
144        fu32_t distrib;
145        const char *country; /* two-letter abbrev */
146        const char *lang; /* two-letter abbrev */
147};
148
149/* Needs to be checked */
150#define CLIENTINFO_AIM_3_5_1670 { \
151        "AOL Instant Messenger (SM), version 3.5.1670/WIN32", \
152        0x0004, \
153        0x0003, 0x0005, \
154        0x0000, 0x0686, \
155        0x0000002a, \
156        "us", "en", \
157}
158
159/* Needs to be checked */
160/* Latest winaim without ssi */
161#define CLIENTINFO_AIM_4_1_2010 { \
162        "AOL Instant Messenger (SM), version 4.1.2010/WIN32", \
163        0x0004, \
164        0x0004, 0x0001, \
165        0x0000, 0x07da, \
166        0x0000004b, \
167        "us", "en", \
168}
169
170/* Needs to be checked */
171#define CLIENTINFO_AIM_4_3_2188 { \
172        "AOL Instant Messenger (SM), version 4.3.2188/WIN32", \
173        0x0109, \
174        0x0400, 0x0003, \
175        0x0000, 0x088c, \
176        0x00000086, \
177        "us", "en", \
178}
179
180/* Needs to be checked */
181#define CLIENTINFO_AIM_4_8_2540 { \
182        "AOL Instant Messenger (SM), version 4.8.2540/WIN32", \
183        0x0109, \
184        0x0004, 0x0008, \
185        0x0000, 0x09ec, \
186        0x000000af, \
187        "us", "en", \
188}
189
190/* Needs to be checked */
191#define CLIENTINFO_AIM_5_0_2938 { \
192        "AOL Instant Messenger, version 5.0.2938/WIN32", \
193        0x0109, \
194        0x0005, 0x0000, \
195        0x0000, 0x0b7a, \
196        0x00000000, \
197        "us", "en", \
198}
199
200#define CLIENTINFO_AIM_5_1_3036 { \
201        "AOL Instant Messenger, version 5.1.3036/WIN32", \
202        0x0109, \
203        0x0005, 0x0001, \
204        0x0000, 0x0bdc, \
205        0x000000d2, \
206        "us", "en", \
207}
208
209#define CLIENTINFO_AIM_5_5_3415 { \
210        "AOL Instant Messenger, version 5.5.3415/WIN32", \
211        0x0109, \
212        0x0005, 0x0005, \
213        0x0000, 0x0057, \
214        0x000000ef, \
215        "us", "en", \
216}
217
218#define CLIENTINFO_ICHAT_1_0 { \
219        "Apple iChat", \
220        0x311a, \
221        0x0001, 0x0000, \
222        0x0000, 0x003c, \
223        0x000000c6, \
224        "us", "en", \
225}
226
227/* Needs to be checked */
228#define CLIENTINFO_ICQ_4_65_3281 { \
229        "ICQ Inc. - Product of ICQ (TM) 2000b.4.65.1.3281.85", \
230        0x010a, \
231        0x0004, 0x0041, \
232        0x0001, 0x0cd1, \
233        0x00000055, \
234        "us", "en", \
235}
236
237/* Needs to be checked */
238#define CLIENTINFO_ICQ_5_34_3728 { \
239        "ICQ Inc. - Product of ICQ (TM).2002a.5.34.1.3728.85", \
240        0x010a, \
241        0x0005, 0x0022, \
242        0x0001, 0x0e8f, \
243        0x00000055, \
244        "us", "en", \
245}
246
247#define CLIENTINFO_ICQ_5_45_3777 { \
248        "ICQ Inc. - Product of ICQ (TM).2003a.5.45.1.3777.85", \
249        0x010a, \
250        0x0005, 0x002d, \
251        0x0001, 0x0ec1, \
252        0x00000055, \
253        "us", "en", \
254}
255
256#define CLIENTINFO_ICQBASIC_14_3_1068 { \
257        "ICQBasic", \
258        0x010a, \
259        0x0014, 0x0003, \
260        0x0000, 0x042c, \
261        0x0000043d, \
262        "us", "en", \
263}
264
265#define CLIENTINFO_NETSCAPE_7_0_1 { \
266        "Netscape 2000 an approved user of AOL Instant Messenger (SM)", \
267        0x1d0d, \
268        0x0007, 0x0000, \
269        0x0001, 0x0000, \
270        0x00000058, \
271        "us", "en", \
272}
273
274#define CLIENTINFO_AIM_KNOWNGOOD CLIENTINFO_AIM_5_1_3036
275#define CLIENTINFO_ICQ_KNOWNGOOD CLIENTINFO_ICQ_5_45_3777
276
277/*
278 * These could be arbitrary, but its easier to use the actual AIM values
279 */
280#define AIM_CONN_TYPE_BOS               0x0002
281#define AIM_CONN_TYPE_ADS               0x0005
282#define AIM_CONN_TYPE_AUTH              0x0007
283#define AIM_CONN_TYPE_CHATNAV           0x000d
284#define AIM_CONN_TYPE_CHAT              0x000e
285#define AIM_CONN_TYPE_SEARCH            0x000f
286#define AIM_CONN_TYPE_ICON              0x0010
287#define AIM_CONN_TYPE_EMAIL             0x0018
288
289/* they start getting arbitrary for rendezvous stuff =) */
290#define AIM_CONN_TYPE_RENDEZVOUS        0xfffe /* these do not speak FLAP! */
291#define AIM_CONN_TYPE_LISTENER          0xffff /* socket waiting for accept() */
292
293/*
294 * Subtypes, we need these for OFT stuff.
295 */
296#define AIM_CONN_SUBTYPE_OFT_DIRECTIM   0x0001
297#define AIM_CONN_SUBTYPE_OFT_GETFILE    0x0002
298#define AIM_CONN_SUBTYPE_OFT_SENDFILE   0x0003
299#define AIM_CONN_SUBTYPE_OFT_BUDDYICON  0x0004
300#define AIM_CONN_SUBTYPE_OFT_VOICE      0x0005
301
302/*
303 * Status values returned from aim_conn_new().  ORed together.
304 */
305#define AIM_CONN_STATUS_READY           0x0001
306#define AIM_CONN_STATUS_INTERNALERR     0x0002
307#define AIM_CONN_STATUS_RESOLVERR       0x0040
308#define AIM_CONN_STATUS_CONNERR         0x0080
309#define AIM_CONN_STATUS_INPROGRESS      0x0100
310
311#define AIM_FRAMETYPE_FLAP              0x0000
312#define AIM_FRAMETYPE_OFT               0x0001
313
314typedef struct aim_conn_s {
315        int fd;
316        fu16_t type;
317        fu16_t subtype;
318        flap_seqnum_t seqnum;
319        fu32_t status;
320        void *priv; /* misc data the client may want to store */
321        void *internal; /* internal conn-specific libfaim data */
322        time_t lastactivity; /* time of last transmit */
323        int forcedlatency; 
324        void *handlerlist;
325        void *sessv; /* pointer to parent session */
326        void *inside; /* only accessible from inside libfaim */
327        struct aim_conn_s *next;
328} aim_conn_t;
329
330/*
331 * Byte Stream type. Sort of.
332 *
333 * Use of this type serves a couple purposes:
334 *   - Buffer/buflen pairs are passed all around everywhere. This turns
335 *     that into one value, as well as abstracting it slightly.
336 *   - Through the abstraction, it is possible to enable bounds checking
337 *     for robustness at the cost of performance.  But a clean failure on
338 *     weird packets is much better than a segfault.
339 *   - I like having variables named "bs".
340 *
341 * Don't touch the insides of this struct.  Or I'll have to kill you.
342 *
343 */
344typedef struct aim_bstream_s {
345        fu8_t *data;
346        fu32_t len;
347        fu32_t offset;
348} aim_bstream_t;
349
350typedef struct aim_frame_s {
351        fu8_t hdrtype; /* defines which piece of the union to use */
352        union {
353                struct { 
354                        fu8_t type;
355                        flap_seqnum_t seqnum;     
356                } flap;
357                struct {
358                        fu8_t magic[4]; /* ODC2 or OFT2 */
359                        fu16_t hdrlen;
360                        fu16_t type;
361                } rend;
362        } hdr;
363        aim_bstream_t data;     /* payload stream */
364        fu8_t handled;          /* 0 = new, !0 = been handled */
365        fu8_t nofree;           /* 0 = free data on purge, 1 = only unlink */
366        aim_conn_t *conn;       /* the connection it came in on... */
367        struct aim_frame_s *next;
368} aim_frame_t;
369
370typedef struct aim_msgcookie_s {
371        fu8_t cookie[8];
372        int type;
373        void *data;
374        time_t addtime;
375        struct aim_msgcookie_s *next;
376} aim_msgcookie_t;
377
378/*
379 * AIM Session: The main client-data interface. 
380 *
381 */
382typedef struct aim_session_s {
383
384        /* ---- Client Accessible ------------------------ */
385
386        /* Our screen name. */
387        char sn[MAXSNLEN+1];
388
389        /*
390         * Pointer to anything the client wants to
391         * explicitly associate with this session.
392         *
393         * This is for use in the callbacks mainly. In any
394         * callback, you can access this with sess->aux_data.
395         *
396         */
397        void *aux_data;
398
399        /* ---- Internal Use Only ------------------------ */
400
401        /* Connection information */
402        aim_conn_t *connlist;
403
404        /*
405         * Transmit/receive queues.
406         *
407         * These are only used when you don't use your own lowlevel
408         * I/O.  I don't suggest that you use libfaim's internal I/O.
409         * Its really bad and the API/event model is quirky at best.
410         * 
411         */
412        aim_frame_t *queue_outgoing;   
413        aim_frame_t *queue_incoming; 
414
415        /*
416         * Tx Enqueuing function.
417         *
418         * This is how you override the transmit direction of libfaim's
419         * internal I/O.  This function will be called whenever it needs
420         * to send something.
421         *
422         */
423        int (*tx_enqueue)(struct aim_session_s *, aim_frame_t *);
424
425        void *modlistv;
426
427        struct {
428                char server[128];
429                char username[128];
430                char password[128];
431        } socksproxy;
432
433        bool nonblocking;
434
435        int debug;
436        void (*debugcb)(struct aim_session_s *sess, int level, const char *format, va_list va); /* same as faim_debugging_callback_t */
437
438        /*
439         * Outstanding snac handling
440         *
441         * XXX: Should these be per-connection? -mid
442         */
443        void *snac_hash[FAIM_SNAC_HASH_SIZE];
444        aim_snacid_t snacid_next;
445
446        aim_msgcookie_t *msgcookies;
447        struct aim_icq_info *icq_info;
448        struct aim_oft_info *oft_info;
449        struct aim_authresp_info *authinfo;
450        struct aim_emailinfo *emailinfo;
451
452        struct {
453                struct aim_userinfo_s *userinfo;
454                struct userinfo_node *torequest;
455                struct userinfo_node *requested;
456                int waiting_for_response;
457        } locate;
458
459        /* Server-stored information (ssi) */
460        struct {
461                int received_data;
462                fu16_t numitems;
463                struct aim_ssi_item *official;
464                struct aim_ssi_item *local;
465                struct aim_ssi_tmp *pending;
466                time_t timestamp;
467                int waiting_for_ack;
468        } ssi;
469} aim_session_t;
470
471/* Valid for calling aim_icq_setstatus() and for aim_userinfo_t->icqinfo.status */
472#define AIM_ICQ_STATE_NORMAL            0x00000000
473#define AIM_ICQ_STATE_AWAY              0x00000001
474#define AIM_ICQ_STATE_DND               0x00000002
475#define AIM_ICQ_STATE_OUT               0x00000004
476#define AIM_ICQ_STATE_BUSY              0x00000010
477#define AIM_ICQ_STATE_CHAT              0x00000020
478#define AIM_ICQ_STATE_INVISIBLE         0x00000100
479#define AIM_ICQ_STATE_WEBAWARE          0x00010000
480#define AIM_ICQ_STATE_HIDEIP            0x00020000
481#define AIM_ICQ_STATE_BIRTHDAY          0x00080000
482#define AIM_ICQ_STATE_DIRECTDISABLED    0x00100000
483#define AIM_ICQ_STATE_ICQHOMEPAGE       0x00200000
484#define AIM_ICQ_STATE_DIRECTREQUIREAUTH 0x10000000
485#define AIM_ICQ_STATE_DIRECTCONTACTLIST 0x20000000
486
487
488
489/*
490 * Get command from connections
491 *
492 * aim_get_commmand() is the libfaim lowlevel I/O in the receive direction.
493 * XXX Make this easily overridable.
494 *
495 */
496faim_export int aim_get_command(aim_session_t *, aim_conn_t *);
497
498/*
499 * Dispatch commands that are in the rx queue.
500 */
501faim_export void aim_rxdispatch(aim_session_t *);
502
503faim_export int aim_debugconn_sendconnect(aim_session_t *sess, aim_conn_t *conn);
504
505faim_export int aim_logoff(aim_session_t *);
506
507#if !defined(FAIM_INTERNAL) || defined(FAIM_INTERNAL_INSANE)
508/* the library should never call aim_conn_kill */
509faim_export void aim_conn_kill(aim_session_t *sess, aim_conn_t **deadconn);
510#endif
511
512typedef int (*aim_rxcallback_t)(aim_session_t *, aim_frame_t *, ...);
513
514
515/* auth.c */
516struct aim_clientrelease {
517        char *name;
518        fu32_t build;
519        char *url;
520        char *info;
521};
522
523struct aim_authresp_info {
524        char *sn;
525        fu16_t errorcode;
526        char *errorurl;
527        fu16_t regstatus;
528        char *email;
529        char *bosip;
530        fu16_t cookielen;
531        fu8_t *cookie;
532        char *chpassurl;
533        struct aim_clientrelease latestrelease;
534        struct aim_clientrelease latestbeta;
535};
536
537/* Callback data for redirect. */
538struct aim_redirect_data {
539        fu16_t group;
540        const char *ip;
541        fu16_t cookielen;
542        const fu8_t *cookie;
543        struct { /* group == AIM_CONN_TYPE_CHAT */
544                fu16_t exchange;
545                const char *room;
546                fu16_t instance;
547        } chat;
548};
549
550faim_export int aim_clientready(aim_session_t *sess, aim_conn_t *conn);
551faim_export int aim_sendflapver(aim_session_t *sess, aim_conn_t *conn);
552faim_export int aim_request_login(aim_session_t *sess, aim_conn_t *conn, const char *sn);
553faim_export int aim_send_login(aim_session_t *, aim_conn_t *, const char *, const char *, struct client_info_s *, const char *key);
554faim_export void aim_purge_rxqueue(aim_session_t *);
555faim_export void aim_cleansnacs(aim_session_t *, int maxage);
556
557#define AIM_TX_QUEUED    0 /* default */
558#define AIM_TX_IMMEDIATE 1
559#define AIM_TX_USER      2
560faim_export int aim_tx_setenqueue(aim_session_t *sess, int what, int (*func)(aim_session_t *, aim_frame_t *));
561
562faim_export int aim_tx_flushqueue(aim_session_t *);
563faim_export void aim_tx_purgequeue(aim_session_t *);
564
565faim_export int aim_conn_setlatency(aim_conn_t *conn, int newval);
566
567faim_export int aim_conn_addhandler(aim_session_t *, aim_conn_t *conn, fu16_t family, fu16_t type, aim_rxcallback_t newhandler, fu16_t flags);
568faim_export int aim_clearhandlers(aim_conn_t *conn);
569
570faim_export aim_conn_t *aim_conn_findbygroup(aim_session_t *sess, fu16_t group);
571faim_export aim_session_t *aim_conn_getsess(aim_conn_t *conn);
572faim_export void aim_conn_close(aim_conn_t *deadconn);
573faim_export aim_conn_t *aim_newconn(aim_session_t *, int type, const char *dest);
574faim_export int aim_conngetmaxfd(aim_session_t *);
575faim_export aim_conn_t *aim_select(aim_session_t *, struct timeval *, int *);
576faim_export int aim_conn_in_sess(aim_session_t *sess, aim_conn_t *conn);
577faim_export int aim_conn_isready(aim_conn_t *);
578faim_export int aim_conn_setstatus(aim_conn_t *, int);
579faim_export int aim_conn_completeconnect(aim_session_t *sess, aim_conn_t *conn);
580faim_export int aim_conn_isconnecting(aim_conn_t *conn);
581
582typedef void (*faim_debugging_callback_t)(aim_session_t *sess, int level, const char *format, va_list va);
583faim_export int aim_setdebuggingcb(aim_session_t *sess, faim_debugging_callback_t);
584faim_export void aim_session_init(aim_session_t *, bool nonblocking, int debuglevel);
585faim_export void aim_session_kill(aim_session_t *);
586faim_export void aim_setupproxy(aim_session_t *sess, const char *server, const char *username, const char *password);
587faim_export aim_conn_t *aim_getconn_type(aim_session_t *, int type);
588faim_export aim_conn_t *aim_getconn_type_all(aim_session_t *, int type);
589faim_export aim_conn_t *aim_getconn_fd(aim_session_t *, int fd);
590
591
592
593/* 0x0001 - service.c */
594faim_export int aim_srv_setavailmsg(aim_session_t *sess, char *msg);
595faim_export int aim_srv_setidle(aim_session_t *sess, fu32_t idletime);
596
597
598
599/* misc.c */
600
601#define AIM_VISIBILITYCHANGE_PERMITADD    0x05
602#define AIM_VISIBILITYCHANGE_PERMITREMOVE 0x06
603#define AIM_VISIBILITYCHANGE_DENYADD      0x07
604#define AIM_VISIBILITYCHANGE_DENYREMOVE   0x08
605
606#define AIM_PRIVFLAGS_ALLOWIDLE           0x01
607#define AIM_PRIVFLAGS_ALLOWMEMBERSINCE    0x02
608
609#define AIM_WARN_ANON                     0x01
610
611faim_export int aim_sendpauseack(aim_session_t *sess, aim_conn_t *conn);
612faim_export int aim_nop(aim_session_t *, aim_conn_t *);
613faim_export int aim_flap_nop(aim_session_t *sess, aim_conn_t *conn);
614faim_export int aim_bos_changevisibility(aim_session_t *, aim_conn_t *, int, const char *);
615faim_export int aim_bos_setgroupperm(aim_session_t *, aim_conn_t *, fu32_t mask);
616faim_export int aim_bos_setprivacyflags(aim_session_t *, aim_conn_t *, fu32_t);
617faim_export int aim_reqpersonalinfo(aim_session_t *, aim_conn_t *);
618faim_export int aim_reqservice(aim_session_t *, aim_conn_t *, fu16_t);
619faim_export int aim_bos_reqrights(aim_session_t *, aim_conn_t *);
620faim_export int aim_setextstatus(aim_session_t *sess, fu32_t status);
621
622#define AIM_CLIENTTYPE_UNKNOWN  0x0000
623#define AIM_CLIENTTYPE_MC       0x0001
624#define AIM_CLIENTTYPE_WINAIM   0x0002
625#define AIM_CLIENTTYPE_WINAIM41 0x0003
626#define AIM_CLIENTTYPE_AOL_TOC  0x0004
627faim_export fu16_t aim_im_fingerprint(const fu8_t *msghdr, int len);
628
629#define AIM_RATE_CODE_CHANGE     0x0001
630#define AIM_RATE_CODE_WARNING    0x0002
631#define AIM_RATE_CODE_LIMIT      0x0003
632#define AIM_RATE_CODE_CLEARLIMIT 0x0004
633faim_export int aim_ads_requestads(aim_session_t *sess, aim_conn_t *conn);
634
635
636
637/* im.c */
638#define AIM_OFT_SUBTYPE_SEND_FILE       0x0001
639#define AIM_OFT_SUBTYPE_SEND_DIR        0x0002
640#define AIM_OFT_SUBTYPE_GET_FILE        0x0011
641#define AIM_OPT_SUBTYPE_GET_LIST        0x0012
642
643#define AIM_TRANSFER_DENY_NOTSUPPORTED  0x0000
644#define AIM_TRANSFER_DENY_DECLINE       0x0001
645#define AIM_TRANSFER_DENY_NOTACCEPTING  0x0002
646
647#define AIM_IMPARAM_FLAG_CHANMSGS_ALLOWED       0x00000001
648#define AIM_IMPARAM_FLAG_MISSEDCALLS_ENABLED    0x00000002
649
650/* This is what the server will give you if you don't set them yourself. */
651#define AIM_IMPARAM_DEFAULTS { \
652        0, \
653        AIM_IMPARAM_FLAG_CHANMSGS_ALLOWED | AIM_IMPARAM_FLAG_MISSEDCALLS_ENABLED, \
654        512, /* !! Note how small this is. */ \
655        (99.9)*10, (99.9)*10, \
656        1000 /* !! And how large this is. */ \
657}
658
659/* This is what most AIM versions use. */
660#define AIM_IMPARAM_REASONABLE { \
661        0, \
662        AIM_IMPARAM_FLAG_CHANMSGS_ALLOWED | AIM_IMPARAM_FLAG_MISSEDCALLS_ENABLED, \
663        8000, \
664        (99.9)*10, (99.9)*10, \
665        0 \
666}
667
668struct aim_icbmparameters {
669        fu16_t maxchan;
670        fu32_t flags; /* AIM_IMPARAM_FLAG_ */
671        fu16_t maxmsglen; /* message size that you will accept */
672        fu16_t maxsenderwarn; /* this and below are *10 (999=99.9%) */
673        fu16_t maxrecverwarn;
674        fu32_t minmsginterval; /* in milliseconds? */
675};
676
677struct aim_chat_roominfo {
678        fu16_t exchange;
679        char *name;
680        fu16_t instance;
681};
682
683#define AIM_IMFLAGS_AWAY                0x0001 /* mark as an autoreply */
684#define AIM_IMFLAGS_ACK                 0x0002 /* request a receipt notice */
685#define AIM_IMFLAGS_UNICODE             0x0004
686#define AIM_IMFLAGS_ISO_8859_1          0x0008
687#define AIM_IMFLAGS_BUDDYREQ            0x0010 /* buddy icon requested */
688#define AIM_IMFLAGS_HASICON             0x0020 /* already has icon */
689#define AIM_IMFLAGS_SUBENC_MACINTOSH    0x0040 /* damn that Steve Jobs! */
690#define AIM_IMFLAGS_CUSTOMFEATURES      0x0080 /* features field present */
691#define AIM_IMFLAGS_EXTDATA             0x0100
692#define AIM_IMFLAGS_X                   0x0200
693#define AIM_IMFLAGS_MULTIPART           0x0400 /* ->mpmsg section valid */
694#define AIM_IMFLAGS_OFFLINE             0x0800 /* send to offline user */
695#define AIM_IMFLAGS_TYPINGNOT           0x1000 /* typing notification */
696
697/*
698 * Multipart message structures.
699 */
700typedef struct aim_mpmsg_section_s {
701        fu16_t charset;
702        fu16_t charsubset;
703        fu8_t *data;
704        fu16_t datalen;
705        struct aim_mpmsg_section_s *next;
706} aim_mpmsg_section_t;
707
708typedef struct aim_mpmsg_s {
709        int numparts;
710        aim_mpmsg_section_t *parts;
711} aim_mpmsg_t;
712
713faim_export int aim_mpmsg_init(aim_session_t *sess, aim_mpmsg_t *mpm);
714faim_export int aim_mpmsg_addraw(aim_session_t *sess, aim_mpmsg_t *mpm, fu16_t charset, fu16_t charsubset, const fu8_t *data, fu16_t datalen);
715faim_export int aim_mpmsg_addascii(aim_session_t *sess, aim_mpmsg_t *mpm, const char *ascii);
716faim_export int aim_mpmsg_addunicode(aim_session_t *sess, aim_mpmsg_t *mpm, const fu16_t *unicode, fu16_t unicodelen);
717faim_export void aim_mpmsg_free(aim_session_t *sess, aim_mpmsg_t *mpm);
718
719/*
720 * Arguments to aim_send_im_ext().
721 *
722 * This is really complicated.  But immensely versatile.
723 *
724 */
725struct aim_sendimext_args {
726
727        /* These are _required_ */
728        const char *destsn;
729        fu32_t flags; /* often 0 */
730
731        /* Only required if not using multipart messages */
732        const char *msg;
733        int msglen;
734
735        /* Required if ->msg is not provided */
736        aim_mpmsg_t *mpmsg;
737
738        /* Only used if AIM_IMFLAGS_HASICON is set */
739        fu32_t iconlen;
740        time_t iconstamp;
741        fu32_t iconsum;
742
743        /* Only used if AIM_IMFLAGS_CUSTOMFEATURES is set */
744        fu8_t *features;
745        fu8_t featureslen;
746
747        /* Only used if AIM_IMFLAGS_CUSTOMCHARSET is set and mpmsg not used */
748        fu16_t charset;
749        fu16_t charsubset;
750};
751
752/*
753 * Arguments to aim_send_rtfmsg().
754 */
755struct aim_sendrtfmsg_args {
756        const char *destsn;
757        fu32_t fgcolor;
758        fu32_t bgcolor;
759        const char *rtfmsg; /* must be in RTF */
760};
761
762/*
763 * This information is provided in the Incoming ICBM callback for
764 * Channel 1 ICBM's. 
765 *
766 * Note that although CUSTOMFEATURES and CUSTOMCHARSET say they
767 * are optional, both are always set by the current libfaim code.
768 * That may or may not change in the future.  It is mainly for
769 * consistency with aim_sendimext_args.
770 *
771 * Multipart messages require some explanation. If you want to use them,
772 * I suggest you read all the comments in im.c.
773 *
774 */
775struct aim_incomingim_ch1_args {
776
777        /* Always provided */
778        aim_mpmsg_t mpmsg;
779        fu32_t icbmflags; /* some flags apply only to ->msg, not all mpmsg */
780       
781        /* Only provided if message has a human-readable section */
782        char *msg;
783        int msglen;
784
785        /* Only provided if AIM_IMFLAGS_HASICON is set */
786        time_t iconstamp;
787        fu32_t iconlen;
788        fu16_t iconsum;
789
790        /* Only provided if AIM_IMFLAGS_CUSTOMFEATURES is set */
791        fu8_t *features;
792        fu8_t featureslen;
793
794        /* Only provided if AIM_IMFLAGS_EXTDATA is set */
795        fu8_t extdatalen;
796        fu8_t *extdata;
797
798        /* Only used if AIM_IMFLAGS_CUSTOMCHARSET is set */
799        fu16_t charset;
800        fu16_t charsubset;
801};
802
803/* Valid values for channel 2 args->status */
804#define AIM_RENDEZVOUS_PROPOSE  0x0000
805#define AIM_RENDEZVOUS_CANCEL   0x0001
806#define AIM_RENDEZVOUS_ACCEPT   0x0002
807
808struct aim_incomingim_ch2_args {
809        fu16_t status;
810        fu8_t cookie[8];
811        int reqclass;
812        const char *proxyip;
813        const char *clientip;
814        const char *verifiedip;
815        fu16_t port;
816        fu16_t errorcode;
817        const char *msg; /* invite message or file description */
818        const char *encoding;
819        const char *language;
820        union {
821                struct {
822                        fu32_t checksum;
823                        fu32_t length;
824                        time_t timestamp;
825                        fu8_t *icon;
826                } icon;
827                struct {
828                        struct aim_chat_roominfo roominfo;
829                } chat;
830                struct {
831                        fu32_t fgcolor;
832                        fu32_t bgcolor;
833                        const char *rtfmsg;
834                } rtfmsg;
835                struct {
836                        fu16_t subtype;
837                        fu16_t totfiles;
838                        fu32_t totsize;
839                        char *filename;
840                } sendfile;
841        } info;
842        void *destructor; /* used internally only */
843};
844
845/* Valid values for channel 4 args->type */
846#define AIM_ICQMSG_AUTHREQUEST  0x0006
847#define AIM_ICQMSG_AUTHDENIED   0x0007
848#define AIM_ICQMSG_AUTHGRANTED  0x0008
849
850struct aim_incomingim_ch4_args {
851        fu32_t uin; /* Of the sender of the ICBM */
852        fu8_t type;
853        fu8_t flags;
854        char *msg; /* Reason for auth request, deny, or accept */
855        int msglen;
856};
857
858/* SNAC sending functions */
859/* 0x0002 */ faim_export int aim_im_setparams(aim_session_t *sess, struct aim_icbmparameters *params);
860/* 0x0004 */ faim_export int aim_im_reqparams(aim_session_t *sess);
861/* 0x0006 */ faim_export int aim_im_sendch1_ext(aim_session_t *sess, struct aim_sendimext_args *args);
862/* 0x0006 */ faim_export int aim_im_sendch1(aim_session_t *, const char *destsn, fu16_t flags, const char *msg);
863/* 0x0006 */ faim_export int aim_im_sendch2_icon(aim_session_t *sess, const char *sn, const fu8_t *icon, int iconlen, time_t stamp, fu16_t iconsum);
864/* 0x0006 */ faim_export int aim_im_sendch2_rtfmsg(aim_session_t *sess, struct aim_sendrtfmsg_args *args);
865/* 0x0006 */ faim_export int aim_im_sendch2_odcrequest(aim_session_t *sess, fu8_t *cookie, const char *sn, const fu8_t *ip, fu16_t port);
866/* 0x0006 */ faim_export int aim_im_sendch2_sendfile_ask(aim_session_t *sess, struct aim_oft_info *oft_info);
867/* 0x0006 */ faim_export int aim_im_sendch2_sendfile_accept(aim_session_t *sess, struct aim_oft_info *info);
868/* 0x0006 */ faim_export int aim_im_sendch2_sendfile_cancel(aim_session_t *sess, struct aim_oft_info *oft_info);
869/* 0x0006 */ faim_export int aim_im_sendch2_geticqaway(aim_session_t *sess, const char *sn, int type);
870/* 0x0006 */ faim_export int aim_im_sendch4(aim_session_t *sess, char *sn, fu16_t type, fu8_t *message);
871/* 0x0008 */ faim_export int aim_im_warn(aim_session_t *sess, aim_conn_t *conn, const char *destsn, fu32_t flags);
872/* 0x000b */ faim_export int aim_im_denytransfer(aim_session_t *sess, const char *sender, const char *cookie, fu16_t code);
873/* 0x0014 */ faim_export int aim_im_sendmtn(aim_session_t *sess, fu16_t type1, const char *sn, fu16_t type2);
874
875
876
877/* ft.c */
878struct aim_fileheader_t {
879#if 0
880        char magic[4];          /* 0 */
881        fu16_t hdrlen;          /* 4 */
882        fu16_t hdrtype;         /* 6 */
883#endif
884        char bcookie[8];        /* 8 */
885        fu16_t encrypt;         /* 16 */
886        fu16_t compress;        /* 18 */
887        fu16_t totfiles;        /* 20 */
888        fu16_t filesleft;       /* 22 */
889        fu16_t totparts;        /* 24 */
890        fu16_t partsleft;       /* 26 */
891        fu32_t totsize;         /* 28 */
892        fu32_t size;            /* 32 */
893        fu32_t modtime;         /* 36 */
894        fu32_t checksum;        /* 40 */
895        fu32_t rfrcsum;         /* 44 */
896        fu32_t rfsize;          /* 48 */
897        fu32_t cretime;         /* 52 */
898        fu32_t rfcsum;          /* 56 */
899        fu32_t nrecvd;          /* 60 */
900        fu32_t recvcsum;        /* 64 */
901        fu8_t idstring[32];     /* 68 */
902        fu8_t flags;            /* 100 */
903        fu8_t lnameoffset;      /* 101 */
904        fu8_t lsizeoffset;      /* 102 */
905        char dummy[69];         /* 103 */
906        char macfileinfo[16];   /* 172 */
907        fu16_t nencode;         /* 188 */
908        fu16_t nlanguage;       /* 190 */
909        char name[64];          /* 192 */
910                                /* 256 */
911};
912
913struct aim_oft_info {
914        char cookie[8];
915        char *sn;
916        char *proxyip;
917        char *clientip;
918        char *verifiedip;
919        fu16_t port;
920        aim_conn_t *conn;
921        aim_session_t *sess;
922        struct aim_fileheader_t fh;
923        struct aim_oft_info *next;
924};
925
926faim_export fu32_t aim_oft_checksum_chunk(const fu8_t *buffer, int bufferlen, fu32_t prevcheck);
927faim_export fu32_t aim_oft_checksum_file(char *filename);
928faim_export int aim_handlerendconnect(aim_session_t *sess, aim_conn_t *cur);
929faim_export int aim_odc_send_typing(aim_session_t *sess, aim_conn_t *conn, int typing);
930faim_export int aim_odc_send_im(aim_session_t *sess, aim_conn_t *conn, const char *msg, int len, int encoding, int isawaymsg);
931faim_export const char *aim_odc_getsn(aim_conn_t *conn);
932faim_export aim_conn_t *aim_odc_getconn(aim_session_t *sess, const char *sn);
933faim_export aim_conn_t *aim_odc_initiate(aim_session_t *sess, const char *sn);
934faim_export aim_conn_t *aim_odc_connect(aim_session_t *sess, const char *sn, const char *addr, const fu8_t *cookie);
935
936faim_export struct aim_oft_info *aim_oft_createinfo(aim_session_t *sess, const fu8_t *cookie, const char *sn, const char *ip, fu16_t port, fu32_t size, fu32_t modtime, char *filename);
937faim_export int aim_oft_destroyinfo(struct aim_oft_info *oft_info);
938faim_export int aim_sendfile_listen(aim_session_t *sess, struct aim_oft_info *oft_info);
939faim_export int aim_oft_sendheader(aim_session_t *sess, fu16_t type, struct aim_oft_info *oft_info);
940
941
942
943/* 0x0002 - locate.c */
944/*
945 * AIM User Info, Standard Form.
946 */
947#define AIM_FLAG_UNCONFIRMED    0x0001 /* "damned transients" */
948#define AIM_FLAG_ADMINISTRATOR  0x0002
949#define AIM_FLAG_AOL                    0x0004
950#define AIM_FLAG_OSCAR_PAY              0x0008
951#define AIM_FLAG_FREE                   0x0010
952#define AIM_FLAG_AWAY                   0x0020
953#define AIM_FLAG_ICQ                    0x0040
954#define AIM_FLAG_WIRELESS               0x0080
955#define AIM_FLAG_UNKNOWN100             0x0100
956#define AIM_FLAG_UNKNOWN200             0x0200
957#define AIM_FLAG_ACTIVEBUDDY    0x0400
958#define AIM_FLAG_UNKNOWN800             0x0800
959#define AIM_FLAG_ABINTERNAL             0x1000
960#define AIM_FLAG_ALLUSERS               0x001f
961
962#define AIM_USERINFO_PRESENT_FLAGS        0x00000001
963#define AIM_USERINFO_PRESENT_MEMBERSINCE  0x00000002
964#define AIM_USERINFO_PRESENT_ONLINESINCE  0x00000004
965#define AIM_USERINFO_PRESENT_IDLE         0x00000008
966#define AIM_USERINFO_PRESENT_ICQEXTSTATUS 0x00000010
967#define AIM_USERINFO_PRESENT_ICQIPADDR    0x00000020
968#define AIM_USERINFO_PRESENT_ICQDATA      0x00000040
969#define AIM_USERINFO_PRESENT_CAPABILITIES 0x00000080
970#define AIM_USERINFO_PRESENT_SESSIONLEN   0x00000100
971#define AIM_USERINFO_PRESENT_CREATETIME   0x00000200
972
973struct userinfo_node {
974        char *sn;
975        struct userinfo_node *next;
976};
977
978typedef struct aim_userinfo_s {
979        char *sn;
980        fu16_t warnlevel; /* evil percent * 10 (999 = 99.9%) */
981        fu16_t idletime; /* in seconds */
982        fu16_t flags;
983        fu32_t createtime; /* time_t */
984        fu32_t membersince; /* time_t */
985        fu32_t onlinesince; /* time_t */
986        fu32_t sessionlen;  /* in seconds */
987        fu32_t capabilities;
988        struct {
989                fu32_t status;
990                fu32_t ipaddr;
991                fu8_t crap[0x25]; /* until we figure it out... */
992        } icqinfo;
993        fu32_t present;
994
995        fu16_t iconcsumlen;
996        fu8_t *iconcsum;
997
998        char *info;
999        char *info_encoding;
1000        fu16_t info_len;
1001
1002        char *avail;
1003        char *avail_encoding;
1004        fu16_t avail_len;
1005
1006        char *away;
1007        char *away_encoding;
1008        fu16_t away_len;
1009
1010        struct aim_userinfo_s *next;
1011} aim_userinfo_t;
1012
1013#define AIM_CAPS_BUDDYICON              0x00000001
1014#define AIM_CAPS_VOICE                  0x00000002
1015#define AIM_CAPS_DIRECTIM               0x00000004
1016#define AIM_CAPS_CHAT                   0x00000008
1017#define AIM_CAPS_GETFILE                0x00000010
1018#define AIM_CAPS_SENDFILE               0x00000020
1019#define AIM_CAPS_GAMES                  0x00000040
1020#define AIM_CAPS_SAVESTOCKS             0x00000080
1021#define AIM_CAPS_SENDBUDDYLIST  0x00000100
1022#define AIM_CAPS_GAMES2                 0x00000200
1023#define AIM_CAPS_ICQ_DIRECT             0x00000400
1024#define AIM_CAPS_APINFO                 0x00000800
1025#define AIM_CAPS_ICQRTF                 0x00001000
1026#define AIM_CAPS_EMPTY                  0x00002000
1027#define AIM_CAPS_ICQSERVERRELAY 0x00004000
1028#define AIM_CAPS_ICQUTF8OLD             0x00008000
1029#define AIM_CAPS_TRILLIANCRYPT  0x00010000
1030#define AIM_CAPS_ICQUTF8                0x00020000
1031#define AIM_CAPS_INTEROPERATE   0x00040000
1032#define AIM_CAPS_ICHAT                  0x00080000
1033#define AIM_CAPS_HIPTOP                 0x00100000
1034#define AIM_CAPS_SECUREIM               0x00200000
1035#define AIM_CAPS_SMS                    0x00400000
1036#define AIM_CAPS_GENERICUNKNOWN 0x00800000
1037#define AIM_CAPS_VIDEO                  0x01000000
1038#define AIM_CAPS_LAST                   0x02000000
1039
1040#define AIM_SENDMEMBLOCK_FLAG_ISREQUEST  0
1041#define AIM_SENDMEMBLOCK_FLAG_ISHASH     1
1042
1043faim_export int aim_sendmemblock(aim_session_t *sess, aim_conn_t *conn, fu32_t offset, fu32_t len, const fu8_t *buf, fu8_t flag);
1044
1045struct aim_invite_priv {
1046        char *sn;
1047        char *roomname;
1048        fu16_t exchange;
1049        fu16_t instance;
1050};
1051
1052#define AIM_COOKIETYPE_UNKNOWN  0x00
1053#define AIM_COOKIETYPE_ICBM     0x01
1054#define AIM_COOKIETYPE_ADS      0x02
1055#define AIM_COOKIETYPE_BOS      0x03
1056#define AIM_COOKIETYPE_IM       0x04
1057#define AIM_COOKIETYPE_CHAT     0x05
1058#define AIM_COOKIETYPE_CHATNAV  0x06
1059#define AIM_COOKIETYPE_INVITE   0x07
1060/* we'll move OFT up a bit to give breathing room.  not like it really
1061 * matters. */
1062#define AIM_COOKIETYPE_OFTIM    0x10
1063#define AIM_COOKIETYPE_OFTGET   0x11
1064#define AIM_COOKIETYPE_OFTSEND  0x12
1065#define AIM_COOKIETYPE_OFTVOICE 0x13
1066#define AIM_COOKIETYPE_OFTIMAGE 0x14
1067#define AIM_COOKIETYPE_OFTICON  0x15
1068
1069faim_export aim_userinfo_t *aim_locate_finduserinfo(aim_session_t *sess, const char *sn);
1070
1071/* 0x0002 */ faim_export int aim_locate_reqrights(aim_session_t *sess);
1072/* 0x0004 */ faim_export int aim_locate_setprofile(aim_session_t *sess, const char *profile_encoding, const char *profile, const int profile_len, const char *awaymsg_encoding, const char *awaymsg, const int awaymsg_len);
1073/* 0x0004 */ faim_export int aim_locate_setcaps(aim_session_t *sess, fu32_t caps);
1074/* 0x0005 */ faim_export int aim_locate_getinfo(aim_session_t *sess, const char *, fu16_t);
1075/* 0x0009 */ faim_export int aim_locate_setdirinfo(aim_session_t *sess, 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, fu16_t privacy);
1076/* 0x000b */ faim_export int aim_locate_000b(aim_session_t *sess, const char *sn);
1077/* 0x000f */ faim_export int aim_locate_setinterests(aim_session_t *sess, const char *interest1, const char *interest2, const char *interest3, const char *interest4, const char *interest5, fu16_t privacy);
1078/* 0x0015 */ faim_export int aim_locate_getinfoshort(aim_session_t *sess, const char *sn, fu32_t flags);
1079
1080
1081
1082/* 0x0003 - buddylist.c */
1083/* 0x0002 */ faim_export int aim_buddylist_reqrights(aim_session_t *, aim_conn_t *);
1084/* 0x0004 */ faim_export int aim_buddylist_set(aim_session_t *, aim_conn_t *, const char *);
1085/* 0x0004 */ faim_export int aim_buddylist_addbuddy(aim_session_t *, aim_conn_t *, const char *);
1086/* 0x0005 */ faim_export int aim_buddylist_removebuddy(aim_session_t *, aim_conn_t *, const char *);
1087/* 0x000b */ faim_export int aim_buddylist_oncoming(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *info);
1088/* 0x000c */ faim_export int aim_buddylist_offgoing(aim_session_t *sess, aim_conn_t *conn, const char *sn);
1089
1090
1091
1092/* 0x000a - search.c */
1093faim_export int aim_search_address(aim_session_t *, aim_conn_t *, const char *);
1094
1095
1096
1097/* 0x000d - chatnav.c */
1098/* 0x000e - chat.c */
1099/* These apply to exchanges as well. */
1100#define AIM_CHATROOM_FLAG_EVILABLE 0x0001
1101#define AIM_CHATROOM_FLAG_NAV_ONLY 0x0002
1102#define AIM_CHATROOM_FLAG_INSTANCING_ALLOWED 0x0004
1103#define AIM_CHATROOM_FLAG_OCCUPANT_PEEK_ALLOWED 0x0008
1104
1105struct aim_chat_exchangeinfo {
1106        fu16_t number;
1107        fu16_t flags;
1108        char *name;
1109        char *charset1;
1110        char *lang1;
1111        char *charset2;
1112        char *lang2;
1113};
1114
1115#define AIM_CHATFLAGS_NOREFLECT 0x0001
1116#define AIM_CHATFLAGS_AWAY      0x0002
1117faim_export int aim_chat_send_im(aim_session_t *sess, aim_conn_t *conn, fu16_t flags, const char *msg, int msglen);
1118faim_export int aim_chat_join(aim_session_t *sess, aim_conn_t *conn, fu16_t exchange, const char *roomname, fu16_t instance);
1119faim_export int aim_chat_attachname(aim_conn_t *conn, fu16_t exchange, const char *roomname, fu16_t instance);
1120faim_export char *aim_chat_getname(aim_conn_t *conn);
1121faim_export aim_conn_t *aim_chat_getconn(aim_session_t *, const char *name);
1122
1123faim_export int aim_chatnav_reqrights(aim_session_t *sess, aim_conn_t *conn);
1124
1125faim_export int aim_chat_invite(aim_session_t *sess, aim_conn_t *conn, const char *sn, const char *msg, fu16_t exchange, const char *roomname, fu16_t instance);
1126
1127faim_export int aim_chatnav_createroom(aim_session_t *sess, aim_conn_t *conn, const char *name, fu16_t exchange);
1128faim_export int aim_chat_leaveroom(aim_session_t *sess, const char *name);
1129
1130
1131
1132/* 0x000f - odir.c */
1133struct aim_odir {
1134        char *first;
1135        char *last;
1136        char *middle;
1137        char *maiden;
1138        char *email;
1139        char *country;
1140        char *state;
1141        char *city;
1142        char *sn;
1143        char *interest;
1144        char *nick;
1145        char *zip;
1146        char *region;
1147        char *address;
1148        struct aim_odir *next;
1149};
1150
1151faim_export int aim_odir_email(aim_session_t *, const char *, const char *);
1152faim_export int aim_odir_name(aim_session_t *, const char *, const char *, const char *, const char *, const char *, const char *, const char *, const char *, const char *, const char *, const char *);
1153faim_export int aim_odir_interest(aim_session_t *, const char *, const char *);
1154
1155
1156
1157/* 0x0010 - icon.c */
1158faim_export int aim_bart_upload(aim_session_t *sess, const fu8_t *icon, fu16_t iconlen);
1159faim_export int aim_bart_request(aim_session_t *sess, const char *sn, const fu8_t *iconstr, fu16_t iconstrlen);
1160
1161
1162
1163/* 0x0013 - ssi.c */
1164#define AIM_SSI_TYPE_BUDDY              0x0000
1165#define AIM_SSI_TYPE_GROUP              0x0001
1166#define AIM_SSI_TYPE_PERMIT             0x0002
1167#define AIM_SSI_TYPE_DENY               0x0003
1168#define AIM_SSI_TYPE_PDINFO             0x0004
1169#define AIM_SSI_TYPE_PRESENCEPREFS      0x0005
1170#define AIM_SSI_TYPE_ICONINFO           0x0014
1171
1172#define AIM_SSI_ACK_SUCCESS             0x0000
1173#define AIM_SSI_ACK_ITEMNOTFOUND        0x0002
1174#define AIM_SSI_ACK_IDNUMINUSE          0x000a
1175#define AIM_SSI_ACK_ATMAX               0x000c
1176#define AIM_SSI_ACK_INVALIDNAME         0x000d
1177#define AIM_SSI_ACK_AUTHREQUIRED        0x000e
1178
1179struct aim_ssi_item {
1180        char *name;
1181        fu16_t gid;
1182        fu16_t bid;
1183        fu16_t type;
1184        struct aim_tlvlist_s *data;
1185        struct aim_ssi_item *next;
1186};
1187
1188struct aim_ssi_tmp {
1189        fu16_t action;
1190        fu16_t ack;
1191        char *name;
1192        struct aim_ssi_item *item;
1193        struct aim_ssi_tmp *next;
1194};
1195
1196/* These build the actual SNACs and queue them to be sent */
1197/* 0x0002 */ faim_export int aim_ssi_reqrights(aim_session_t *sess);
1198/* 0x0004 */ faim_export int aim_ssi_reqdata(aim_session_t *sess);
1199/* 0x0005 */ faim_export int aim_ssi_reqifchanged(aim_session_t *sess, time_t localstamp, fu16_t localrev);
1200/* 0x0007 */ faim_export int aim_ssi_enable(aim_session_t *sess);
1201/* 0x0008 */ faim_export int aim_ssi_addmoddel(aim_session_t *sess);
1202/* 0x0011 */ faim_export int aim_ssi_modbegin(aim_session_t *sess);
1203/* 0x0012 */ faim_export int aim_ssi_modend(aim_session_t *sess);
1204/* 0x0014 */ faim_export int aim_ssi_sendauth(aim_session_t *sess, char *sn, char *msg);
1205/* 0x0018 */ faim_export int aim_ssi_sendauthrequest(aim_session_t *sess, char *sn, char *msg);
1206/* 0x001a */ faim_export int aim_ssi_sendauthreply(aim_session_t *sess, char *sn, fu8_t reply, char *msg);
1207
1208/* Client functions for retrieving SSI data */
1209faim_export struct aim_ssi_item *aim_ssi_itemlist_find(struct aim_ssi_item *list, fu16_t gid, fu16_t bid);
1210faim_export struct aim_ssi_item *aim_ssi_itemlist_finditem(struct aim_ssi_item *list, const char *gn, const char *sn, fu16_t type);
1211faim_export struct aim_ssi_item *aim_ssi_itemlist_exists(struct aim_ssi_item *list, const char *sn);
1212faim_export char *aim_ssi_itemlist_findparentname(struct aim_ssi_item *list, const char *sn);
1213faim_export int aim_ssi_getpermdeny(struct aim_ssi_item *list);
1214faim_export fu32_t aim_ssi_getpresence(struct aim_ssi_item *list);
1215faim_export char *aim_ssi_getalias(struct aim_ssi_item *list, const char *gn, const char *sn);
1216faim_export char *aim_ssi_getcomment(struct aim_ssi_item *list, const char *gn, const char *sn);
1217faim_export int aim_ssi_waitingforauth(struct aim_ssi_item *list, const char *gn, const char *sn);
1218
1219/* Client functions for changing SSI data */
1220faim_export int aim_ssi_addbuddy(aim_session_t *sess, const char *name, const char *group, const char *alias, const char *comment, const char *smsnum, int needauth);
1221faim_export int aim_ssi_addpermit(aim_session_t *sess, const char *name);
1222faim_export int aim_ssi_adddeny(aim_session_t *sess, const char *name);
1223faim_export int aim_ssi_delbuddy(aim_session_t *sess, const char *name, const char *group);
1224faim_export int aim_ssi_delpermit(aim_session_t *sess, const char *name);
1225faim_export int aim_ssi_deldeny(aim_session_t *sess, const char *name);
1226faim_export int aim_ssi_movebuddy(aim_session_t *sess, const char *oldgn, const char *newgn, const char *sn);
1227faim_export int aim_ssi_aliasbuddy(aim_session_t *sess, const char *gn, const char *sn, const char *alias);
1228faim_export int aim_ssi_editcomment(aim_session_t *sess, const char *gn, const char *sn, const char *alias);
1229faim_export int aim_ssi_rename_group(aim_session_t *sess, const char *oldgn, const char *newgn);
1230faim_export int aim_ssi_cleanlist(aim_session_t *sess);
1231faim_export int aim_ssi_deletelist(aim_session_t *sess);
1232faim_export int aim_ssi_setpermdeny(aim_session_t *sess, fu8_t permdeny, fu32_t vismask);
1233faim_export int aim_ssi_setpresence(aim_session_t *sess, fu32_t presence);
1234faim_export int aim_ssi_seticon(aim_session_t *sess, fu8_t *iconsum, fu16_t iconsumlen);
1235faim_export int aim_ssi_delicon(aim_session_t *sess);
1236
1237
1238
1239/* 0x0015 - icq.c */
1240#define AIM_ICQ_INFO_SIMPLE     0x001
1241#define AIM_ICQ_INFO_SUMMARY    0x002
1242#define AIM_ICQ_INFO_EMAIL      0x004
1243#define AIM_ICQ_INFO_PERSONAL   0x008
1244#define AIM_ICQ_INFO_ADDITIONAL 0x010
1245#define AIM_ICQ_INFO_WORK       0x020
1246#define AIM_ICQ_INFO_INTERESTS  0x040
1247#define AIM_ICQ_INFO_ORGS       0x080
1248#define AIM_ICQ_INFO_UNKNOWN    0x100
1249#define AIM_ICQ_INFO_HAVEALL    0x1ff
1250
1251struct aim_icq_offlinemsg {
1252        fu32_t sender;
1253        fu16_t year;
1254        fu8_t month, day, hour, minute;
1255        fu8_t type;
1256        fu8_t flags;
1257        char *msg;
1258        int msglen;
1259};
1260
1261struct aim_icq_info {
1262        fu16_t reqid;
1263
1264        /* simple */
1265        fu32_t uin;
1266
1267        /* general and "home" information (0x00c8) */
1268        char *nick;
1269        char *first;
1270        char *last;
1271        char *email;
1272        char *homecity;
1273        char *homestate;
1274        char *homephone;
1275        char *homefax;
1276        char *homeaddr;
1277        char *mobile;
1278        char *homezip;
1279        fu16_t homecountry;
1280/*      fu8_t timezone;
1281        fu8_t hideemail; */
1282
1283        /* personal (0x00dc) */
1284        fu8_t age;
1285        fu8_t unknown;
1286        fu8_t gender;
1287        char *personalwebpage;
1288        fu16_t birthyear;
1289        fu8_t birthmonth;
1290        fu8_t birthday;
1291        fu8_t language1;
1292        fu8_t language2;
1293        fu8_t language3;
1294
1295        /* work (0x00d2) */
1296        char *workcity;
1297        char *workstate;
1298        char *workphone;
1299        char *workfax;
1300        char *workaddr;
1301        char *workzip;
1302        fu16_t workcountry;
1303        char *workcompany;
1304        char *workdivision;
1305        char *workposition;
1306        char *workwebpage;
1307
1308        /* additional personal information (0x00e6) */
1309        char *info;
1310
1311        /* email (0x00eb) */
1312        fu16_t numaddresses;
1313        char **email2;
1314
1315        /* we keep track of these in a linked list because we're 1337 */
1316        struct aim_icq_info *next;
1317};
1318
1319faim_export int aim_icq_reqofflinemsgs(aim_session_t *sess);
1320faim_export int aim_icq_ackofflinemsgs(aim_session_t *sess);
1321faim_export int aim_icq_hideip(aim_session_t *sess);
1322faim_export int aim_icq_changepasswd(aim_session_t *sess, const char *passwd);
1323faim_export int aim_icq_getsimpleinfo(aim_session_t *sess, const char *uin);
1324faim_export int aim_icq_getalias(aim_session_t *sess, const char *uin);
1325faim_export int aim_icq_getallinfo(aim_session_t *sess, const char *uin);
1326
1327
1328
1329/* 0x0017 - auth.c */
1330faim_export int aim_sendcookie(aim_session_t *, aim_conn_t *, const fu16_t length, const fu8_t *);
1331faim_export int aim_admin_changepasswd(aim_session_t *, aim_conn_t *, const char *newpw, const char *curpw);
1332faim_export int aim_admin_reqconfirm(aim_session_t *sess, aim_conn_t *conn);
1333faim_export int aim_admin_getinfo(aim_session_t *sess, aim_conn_t *conn, fu16_t info);
1334faim_export int aim_admin_setemail(aim_session_t *sess, aim_conn_t *conn, const char *newemail);
1335faim_export int aim_admin_setnick(aim_session_t *sess, aim_conn_t *conn, const char *newnick);
1336
1337
1338
1339/* 0x0018 - email.c */
1340struct aim_emailinfo {
1341        fu8_t *cookie16;
1342        fu8_t *cookie8;
1343        char *url;
1344        fu16_t nummsgs;
1345        fu8_t unread;
1346        char *domain;
1347        fu16_t flag;
1348        struct aim_emailinfo *next;
1349};
1350
1351faim_export int aim_email_sendcookies(aim_session_t *sess);
1352faim_export int aim_email_activate(aim_session_t *sess);
1353
1354
1355
1356#if defined(FAIM_INTERNAL) || defined(FAIM_NEED_TLV)
1357/* tlv.c - TLV handling */
1358
1359/* TLV structure */
1360typedef struct aim_tlv_s {
1361        fu16_t type;
1362        fu16_t length;
1363        fu8_t *value;
1364} aim_tlv_t;
1365
1366/* TLV List structure */
1367typedef struct aim_tlvlist_s {
1368        aim_tlv_t *tlv;
1369        struct aim_tlvlist_s *next;
1370} aim_tlvlist_t;
1371
1372/* TLV handling functions */
1373faim_internal aim_tlv_t *aim_tlv_gettlv(aim_tlvlist_t *list, fu16_t type, const int nth);
1374faim_internal char *aim_tlv_getstr(aim_tlvlist_t *list, const fu16_t type, const int nth);
1375faim_internal fu8_t aim_tlv_get8(aim_tlvlist_t *list, const fu16_t type, const int nth);
1376faim_internal fu16_t aim_tlv_get16(aim_tlvlist_t *list, const fu16_t type, const int nth);
1377faim_internal fu32_t aim_tlv_get32(aim_tlvlist_t *list, const fu16_t type, const int nth);
1378
1379/* TLV list handling functions */
1380faim_internal aim_tlvlist_t *aim_tlvlist_read(aim_bstream_t *bs);
1381faim_internal aim_tlvlist_t *aim_tlvlist_readnum(aim_bstream_t *bs, fu16_t num);
1382faim_internal aim_tlvlist_t *aim_tlvlist_readlen(aim_bstream_t *bs, fu16_t len);
1383faim_internal aim_tlvlist_t *aim_tlvlist_copy(aim_tlvlist_t *orig);
1384
1385faim_internal int aim_tlvlist_count(aim_tlvlist_t **list);
1386faim_internal int aim_tlvlist_size(aim_tlvlist_t **list);
1387faim_internal int aim_tlvlist_cmp(aim_tlvlist_t *one, aim_tlvlist_t *two);
1388faim_internal int aim_tlvlist_write(aim_bstream_t *bs, aim_tlvlist_t **list);
1389faim_internal void aim_tlvlist_free(aim_tlvlist_t **list);
1390
1391faim_internal int aim_tlvlist_add_raw(aim_tlvlist_t **list, const fu16_t type, const fu16_t length, const fu8_t *value);
1392faim_internal int aim_tlvlist_add_noval(aim_tlvlist_t **list, const fu16_t type);
1393faim_internal int aim_tlvlist_add_8(aim_tlvlist_t **list, const fu16_t type, const fu8_t value);
1394faim_internal int aim_tlvlist_add_16(aim_tlvlist_t **list, const fu16_t type, const fu16_t value);
1395faim_internal int aim_tlvlist_add_32(aim_tlvlist_t **list, const fu16_t type, const fu32_t value);
1396faim_internal int aim_tlvlist_add_caps(aim_tlvlist_t **list, const fu16_t type, const fu32_t caps);
1397faim_internal int aim_tlvlist_add_userinfo(aim_tlvlist_t **list, fu16_t type, aim_userinfo_t *userinfo);
1398faim_internal int aim_tlvlist_add_frozentlvlist(aim_tlvlist_t **list, fu16_t type, aim_tlvlist_t **tl);
1399
1400faim_internal int aim_tlvlist_replace_raw(aim_tlvlist_t **list, const fu16_t type, const fu16_t lenth, const fu8_t *value);
1401faim_internal int aim_tlvlist_replace_noval(aim_tlvlist_t **list, const fu16_t type);
1402faim_internal int aim_tlvlist_replace_8(aim_tlvlist_t **list, const fu16_t type, const fu8_t value);
1403faim_internal int aim_tlvlist_replace_16(aim_tlvlist_t **list, const fu16_t type, const fu16_t value);
1404faim_internal int aim_tlvlist_replace_32(aim_tlvlist_t **list, const fu16_t type, const fu32_t value);
1405
1406faim_internal void aim_tlvlist_remove(aim_tlvlist_t **list, const fu16_t type);
1407#endif /* FAIM_INTERNAL */
1408
1409
1410
1411/* util.c */
1412/*
1413 * These are really ugly.  You'd think this was LISP.  I wish it was.
1414 *
1415 * XXX With the advent of bstream's, these should be removed to enforce
1416 * their use.
1417 *
1418 */
1419#define aimutil_put8(buf, data) ((*(buf) = (fu8_t)(data)&0xff),1)
1420#define aimutil_get8(buf) ((*(buf))&0xff)
1421#define aimutil_put16(buf, data) ( \
1422                (*(buf) = (fu8_t)((data)>>8)&0xff), \
1423                (*((buf)+1) = (fu8_t)(data)&0xff),  \
1424                2)
1425#define aimutil_get16(buf) ((((*(buf))<<8)&0xff00) + ((*((buf)+1)) & 0xff))
1426#define aimutil_put32(buf, data) ( \
1427                (*((buf)) = (fu8_t)((data)>>24)&0xff), \
1428                (*((buf)+1) = (fu8_t)((data)>>16)&0xff), \
1429                (*((buf)+2) = (fu8_t)((data)>>8)&0xff), \
1430                (*((buf)+3) = (fu8_t)(data)&0xff), \
1431                4)
1432#define aimutil_get32(buf) ((((*(buf))<<24)&0xff000000) + \
1433                (((*((buf)+1))<<16)&0x00ff0000) + \
1434                (((*((buf)+2))<< 8)&0x0000ff00) + \
1435                (((*((buf)+3)    )&0x000000ff)))
1436
1437/* Little-endian versions (damn ICQ) */
1438#define aimutil_putle8(buf, data) ( \
1439                (*(buf) = (fu8_t)(data) & 0xff), \
1440                1)
1441#define aimutil_getle8(buf) ( \
1442                (*(buf)) & 0xff \
1443                )
1444#define aimutil_putle16(buf, data) ( \
1445                (*((buf)+0) = (fu8_t)((data) >> 0) & 0xff),  \
1446                (*((buf)+1) = (fu8_t)((data) >> 8) & 0xff), \
1447                2)
1448#define aimutil_getle16(buf) ( \
1449                (((*((buf)+0)) << 0) & 0x00ff) + \
1450                (((*((buf)+1)) << 8) & 0xff00) \
1451                )
1452#define aimutil_putle32(buf, data) ( \
1453                (*((buf)+0) = (fu8_t)((data) >>  0) & 0xff), \
1454                (*((buf)+1) = (fu8_t)((data) >>  8) & 0xff), \
1455                (*((buf)+2) = (fu8_t)((data) >> 16) & 0xff), \
1456                (*((buf)+3) = (fu8_t)((data) >> 24) & 0xff), \
1457                4)
1458#define aimutil_getle32(buf) ( \
1459                (((*((buf)+0)) <<  0) & 0x000000ff) + \
1460                (((*((buf)+1)) <<  8) & 0x0000ff00) + \
1461                (((*((buf)+2)) << 16) & 0x00ff0000) + \
1462                (((*((buf)+3)) << 24) & 0xff000000))
1463
1464
1465faim_export int aimutil_putstr(char *, const char *, int);
1466faim_export fu16_t aimutil_iconsum(const fu8_t *buf, int buflen);
1467faim_export int aim_util_getlocalip(fu8_t *ip);
1468faim_export int aimutil_tokslen(char *toSearch, int theindex, char dl);
1469faim_export int aimutil_itemcnt(char *toSearch, char dl);
1470faim_export char *aimutil_itemindex(char *toSearch, int theindex, char dl);
1471
1472faim_export int aim_snlen(const char *sn);
1473faim_export int aim_sncmp(const char *sn1, const char *sn2);
1474
1475#include <aim_internal.h>
1476
1477#ifdef __cplusplus
1478}
1479#endif
1480
1481#endif /* __AIM_H__ */
Note: See TracBrowser for help on using the repository browser.