source: libfaim/aim.h @ 35b6eb9

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