source: libfaim/aim.h @ 8c46404

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