1 | /* |
---|
2 | * Main libfaim header. Must be included in client for prototypes/macros. |
---|
3 | * |
---|
4 | * "come on, i turned a chick lesbian; i think this is the hackish equivalent" |
---|
5 | * -- Josh Meyer |
---|
6 | * |
---|
7 | */ |
---|
8 | |
---|
9 | #ifndef __AIM_H__ |
---|
10 | #define __AIM_H__ |
---|
11 | |
---|
12 | #define FAIM_VERSION_MAJOR 0 |
---|
13 | #define FAIM_VERSION_MINOR 99 |
---|
14 | #define FAIM_VERSION_MINORMINOR 4 |
---|
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 | #ifdef _WIN32 |
---|
29 | #include <windows.h> |
---|
30 | #include <io.h> |
---|
31 | #else |
---|
32 | #include <sys/time.h> |
---|
33 | #include <unistd.h> |
---|
34 | #include <netinet/in.h> |
---|
35 | #include <sys/socket.h> |
---|
36 | #endif |
---|
37 | |
---|
38 | /* XXX adjust these based on autoconf-detected platform */ |
---|
39 | typedef unsigned char fu8_t; |
---|
40 | typedef unsigned short fu16_t; |
---|
41 | typedef unsigned long fu32_t; |
---|
42 | typedef fu32_t aim_snacid_t; |
---|
43 | typedef fu16_t flap_seqnum_t; |
---|
44 | |
---|
45 | /* Portability stuff (DMP) */ |
---|
46 | |
---|
47 | #ifdef _WIN32 |
---|
48 | #define sleep(x) Sleep((x)*1000) |
---|
49 | #define snprintf _snprintf /* I'm not sure whats wrong with Microsoft here */ |
---|
50 | #define close(x) closesocket(x) /* no comment */ |
---|
51 | #endif |
---|
52 | |
---|
53 | #if defined(mach) && defined(__APPLE__) |
---|
54 | #define gethostbyname(x) gethostbyname2(x, AF_INET) |
---|
55 | #endif |
---|
56 | |
---|
57 | #if defined(_WIN32) || defined(STRICT_ANSI) |
---|
58 | #define faim_shortfunc |
---|
59 | #else |
---|
60 | #define faim_shortfunc inline |
---|
61 | #endif |
---|
62 | |
---|
63 | #if defined(_WIN32) && !defined(WIN32_STATIC) |
---|
64 | /* |
---|
65 | * For a win32 DLL, we define WIN32_INDLL if this file |
---|
66 | * is included while compiling the DLL. If its not |
---|
67 | * defined (its included in a client app), the symbols |
---|
68 | * will be imported instead of exported. |
---|
69 | */ |
---|
70 | #ifdef WIN32_INDLL |
---|
71 | #define faim_export __declspec(dllexport) |
---|
72 | #else |
---|
73 | #define faim_export __declspec(dllimport) |
---|
74 | #endif /* WIN32_INDLL */ |
---|
75 | #define faim_internal |
---|
76 | #else |
---|
77 | /* |
---|
78 | * Nothing normally needed for unix... |
---|
79 | */ |
---|
80 | #define faim_export |
---|
81 | #define faim_internal |
---|
82 | #endif |
---|
83 | |
---|
84 | /* |
---|
85 | * Current Maximum Length for Screen Names (not including NULL) |
---|
86 | * |
---|
87 | * Currently only names up to 16 characters can be registered |
---|
88 | * however it is aparently legal for them to be larger. |
---|
89 | */ |
---|
90 | #define MAXSNLEN 32 |
---|
91 | |
---|
92 | /* |
---|
93 | * Current Maximum Length for Instant Messages |
---|
94 | * |
---|
95 | * This was found basically by experiment, but not wholly |
---|
96 | * accurate experiment. It should not be regarded |
---|
97 | * as completely correct. But its a decent approximation. |
---|
98 | * |
---|
99 | * Note that although we can send this much, its impossible |
---|
100 | * for WinAIM clients (up through the latest (4.0.1957)) to |
---|
101 | * send any more than 1kb. Amaze all your windows friends |
---|
102 | * with utterly oversized instant messages! |
---|
103 | * |
---|
104 | * XXX: the real limit is the total SNAC size at 8192. Fix this. |
---|
105 | * |
---|
106 | */ |
---|
107 | #define MAXMSGLEN 7987 |
---|
108 | |
---|
109 | /* |
---|
110 | * Maximum size of a Buddy Icon. |
---|
111 | */ |
---|
112 | #define MAXICONLEN 7168 |
---|
113 | #define AIM_ICONIDENT "AVT1picture.id" |
---|
114 | |
---|
115 | /* |
---|
116 | * Current Maximum Length for Chat Room Messages |
---|
117 | * |
---|
118 | * This is actually defined by the protocol to be |
---|
119 | * dynamic, but I have yet to see due cause to |
---|
120 | * define it dynamically here. Maybe later. |
---|
121 | * |
---|
122 | */ |
---|
123 | #define MAXCHATMSGLEN 512 |
---|
124 | |
---|
125 | /* |
---|
126 | * Standard size of an AIM authorization cookie |
---|
127 | */ |
---|
128 | #define AIM_COOKIELEN 0x100 |
---|
129 | |
---|
130 | #define AIM_MD5_STRING "AOL Instant Messenger (SM)" |
---|
131 | |
---|
132 | /* |
---|
133 | * Client info. Filled in by the client and passed in to |
---|
134 | * aim_send_login(). The information ends up getting passed to OSCAR |
---|
135 | * through the initial login command. |
---|
136 | * |
---|
137 | */ |
---|
138 | struct client_info_s { |
---|
139 | const char *clientstring; |
---|
140 | fu16_t clientid; |
---|
141 | int major; |
---|
142 | int minor; |
---|
143 | int point; |
---|
144 | int build; |
---|
145 | const char *country; /* two-letter abbrev */ |
---|
146 | const char *lang; /* two-letter abbrev */ |
---|
147 | }; |
---|
148 | |
---|
149 | #define AIM_CLIENTINFO_KNOWNGOOD_3_5_1670 { \ |
---|
150 | "AOL Instant Messenger (SM), version 3.5.1670/WIN32", \ |
---|
151 | 0x0004, \ |
---|
152 | 0x0003, \ |
---|
153 | 0x0005, \ |
---|
154 | 0x0000, \ |
---|
155 | 0x0686, \ |
---|
156 | "us", \ |
---|
157 | "en", \ |
---|
158 | } |
---|
159 | |
---|
160 | #define AIM_CLIENTINFO_KNOWNGOOD_4_1_2010 { \ |
---|
161 | "AOL Instant Messenger (SM), version 4.1.2010/WIN32", \ |
---|
162 | 0x0004, \ |
---|
163 | 0x0004, \ |
---|
164 | 0x0001, \ |
---|
165 | 0x0000, \ |
---|
166 | 0x07da, \ |
---|
167 | "us", \ |
---|
168 | "en", \ |
---|
169 | } |
---|
170 | |
---|
171 | /* |
---|
172 | * I would make 4.1.2010 the default, but they seem to have found |
---|
173 | * an alternate way of breaking that one. |
---|
174 | * |
---|
175 | * 3.5.1670 should work fine, however, you will be subjected to the |
---|
176 | * memory test, which may require you to have a WinAIM binary laying |
---|
177 | * around. (see login.c::memrequest()) |
---|
178 | */ |
---|
179 | #define AIM_CLIENTINFO_KNOWNGOOD AIM_CLIENTINFO_KNOWNGOOD_3_5_1670 |
---|
180 | |
---|
181 | #ifndef TRUE |
---|
182 | #define TRUE 1 |
---|
183 | #define FALSE 0 |
---|
184 | #endif |
---|
185 | |
---|
186 | /* |
---|
187 | * These could be arbitrary, but its easier to use the actual AIM values |
---|
188 | */ |
---|
189 | #define AIM_CONN_TYPE_AUTH 0x0007 |
---|
190 | #define AIM_CONN_TYPE_ADS 0x0005 |
---|
191 | #define AIM_CONN_TYPE_BOS 0x0002 |
---|
192 | #define AIM_CONN_TYPE_CHAT 0x000e |
---|
193 | #define AIM_CONN_TYPE_CHATNAV 0x000d |
---|
194 | |
---|
195 | /* they start getting arbitrary in rendezvous stuff =) */ |
---|
196 | #define AIM_CONN_TYPE_RENDEZVOUS 0x0101 /* these do not speak FLAP! */ |
---|
197 | #define AIM_CONN_TYPE_RENDEZVOUS_OUT 0x0102 /* socket waiting for accept() */ |
---|
198 | |
---|
199 | /* |
---|
200 | * Subtypes, we need these for OFT stuff. |
---|
201 | */ |
---|
202 | #define AIM_CONN_SUBTYPE_OFT_DIRECTIM 0x0001 |
---|
203 | #define AIM_CONN_SUBTYPE_OFT_GETFILE 0x0002 |
---|
204 | #define AIM_CONN_SUBTYPE_OFT_SENDFILE 0x0003 |
---|
205 | #define AIM_CONN_SUBTYPE_OFT_BUDDYICON 0x0004 |
---|
206 | #define AIM_CONN_SUBTYPE_OFT_VOICE 0x0005 |
---|
207 | |
---|
208 | /* |
---|
209 | * Status values returned from aim_conn_new(). ORed together. |
---|
210 | */ |
---|
211 | #define AIM_CONN_STATUS_READY 0x0001 |
---|
212 | #define AIM_CONN_STATUS_INTERNALERR 0x0002 |
---|
213 | #define AIM_CONN_STATUS_RESOLVERR 0x0040 |
---|
214 | #define AIM_CONN_STATUS_CONNERR 0x0080 |
---|
215 | #define AIM_CONN_STATUS_INPROGRESS 0x0100 |
---|
216 | |
---|
217 | #define AIM_FRAMETYPE_FLAP 0x0000 |
---|
218 | #define AIM_FRAMETYPE_OFT 0x0001 |
---|
219 | |
---|
220 | typedef struct aim_conn_s { |
---|
221 | int fd; |
---|
222 | fu16_t type; |
---|
223 | fu16_t subtype; |
---|
224 | flap_seqnum_t seqnum; |
---|
225 | fu32_t status; |
---|
226 | void *priv; /* misc data the client may want to store */ |
---|
227 | void *internal; /* internal conn-specific libfaim data */ |
---|
228 | time_t lastactivity; /* time of last transmit */ |
---|
229 | int forcedlatency; |
---|
230 | void *handlerlist; |
---|
231 | void *sessv; /* pointer to parent session */ |
---|
232 | void *inside; /* only accessible from inside libfaim */ |
---|
233 | struct aim_conn_s *next; |
---|
234 | } aim_conn_t; |
---|
235 | |
---|
236 | /* |
---|
237 | * Byte Stream type. Sort of. |
---|
238 | * |
---|
239 | * Use of this type serves a couple purposes: |
---|
240 | * - Buffer/buflen pairs are passed all around everywhere. This turns |
---|
241 | * that into one value, as well as abstracting it slightly. |
---|
242 | * - Through the abstraction, it is possible to enable bounds checking |
---|
243 | * for robustness at the cost of performance. But a clean failure on |
---|
244 | * weird packets is much better than a segfault. |
---|
245 | * - I like having variables named "bs". |
---|
246 | * |
---|
247 | * Don't touch the insides of this struct. Or I'll have to kill you. |
---|
248 | * |
---|
249 | */ |
---|
250 | typedef struct aim_bstream_s { |
---|
251 | fu8_t *data; |
---|
252 | fu16_t len; |
---|
253 | fu16_t offset; |
---|
254 | } aim_bstream_t; |
---|
255 | |
---|
256 | typedef struct aim_frame_s { |
---|
257 | fu8_t hdrtype; /* defines which piece of the union to use */ |
---|
258 | union { |
---|
259 | struct { |
---|
260 | fu8_t type; |
---|
261 | flap_seqnum_t seqnum; |
---|
262 | } flap; |
---|
263 | struct { |
---|
264 | fu16_t type; |
---|
265 | fu8_t magic[4]; /* ODC2 OFT2 */ |
---|
266 | fu16_t hdr2len; |
---|
267 | fu8_t *hdr2; /* rest of bloated header */ |
---|
268 | } oft; |
---|
269 | } hdr; |
---|
270 | aim_bstream_t data; /* payload stream */ |
---|
271 | fu8_t handled; /* 0 = new, !0 = been handled */ |
---|
272 | fu8_t nofree; /* 0 = free data on purge, 1 = only unlink */ |
---|
273 | aim_conn_t *conn; /* the connection it came in on... */ |
---|
274 | struct aim_frame_s *next; |
---|
275 | } aim_frame_t; |
---|
276 | |
---|
277 | typedef struct aim_msgcookie_s { |
---|
278 | unsigned char cookie[8]; |
---|
279 | int type; |
---|
280 | void *data; |
---|
281 | time_t addtime; |
---|
282 | struct aim_msgcookie_s *next; |
---|
283 | } aim_msgcookie_t; |
---|
284 | |
---|
285 | /* |
---|
286 | * AIM Session: The main client-data interface. |
---|
287 | * |
---|
288 | */ |
---|
289 | typedef struct aim_session_s { |
---|
290 | |
---|
291 | /* ---- Client Accessible ------------------------ */ |
---|
292 | |
---|
293 | /* Our screen name. */ |
---|
294 | char sn[MAXSNLEN+1]; |
---|
295 | |
---|
296 | /* |
---|
297 | * Pointer to anything the client wants to |
---|
298 | * explicitly associate with this session. |
---|
299 | * |
---|
300 | * This is for use in the callbacks mainly. In any |
---|
301 | * callback, you can access this with sess->aux_data. |
---|
302 | * |
---|
303 | */ |
---|
304 | void *aux_data; |
---|
305 | |
---|
306 | /* ---- Internal Use Only ------------------------ */ |
---|
307 | |
---|
308 | /* Connection information */ |
---|
309 | aim_conn_t *connlist; |
---|
310 | |
---|
311 | /* |
---|
312 | * Transmit/receive queues. |
---|
313 | * |
---|
314 | * These are only used when you don't use your own lowlevel |
---|
315 | * I/O. I don't suggest that you use libfaim's internal I/O. |
---|
316 | * Its really bad and the API/event model is quirky at best. |
---|
317 | * |
---|
318 | */ |
---|
319 | aim_frame_t *queue_outgoing; |
---|
320 | aim_frame_t *queue_incoming; |
---|
321 | |
---|
322 | /* |
---|
323 | * Tx Enqueuing function. |
---|
324 | * |
---|
325 | * This is how you override the transmit direction of libfaim's |
---|
326 | * internal I/O. This function will be called whenever it needs |
---|
327 | * to send something. |
---|
328 | * |
---|
329 | */ |
---|
330 | int (*tx_enqueue)(struct aim_session_s *, aim_frame_t *); |
---|
331 | |
---|
332 | /* |
---|
333 | * Outstanding snac handling |
---|
334 | * |
---|
335 | * XXX: Should these be per-connection? -mid |
---|
336 | */ |
---|
337 | void *snac_hash[FAIM_SNAC_HASH_SIZE]; |
---|
338 | aim_snacid_t snacid_next; |
---|
339 | |
---|
340 | struct { |
---|
341 | char server[128]; |
---|
342 | char username[128]; |
---|
343 | char password[128]; |
---|
344 | } socksproxy; |
---|
345 | |
---|
346 | fu32_t flags; /* AIM_SESS_FLAGS_ */ |
---|
347 | |
---|
348 | int debug; |
---|
349 | void (*debugcb)(struct aim_session_s *sess, int level, const char *format, va_list va); /* same as faim_debugging_callback_t */ |
---|
350 | |
---|
351 | aim_msgcookie_t *msgcookies; |
---|
352 | |
---|
353 | void *modlistv; |
---|
354 | } aim_session_t; |
---|
355 | |
---|
356 | /* Values for sess->flags */ |
---|
357 | #define AIM_SESS_FLAGS_SNACLOGIN 0x00000001 |
---|
358 | #define AIM_SESS_FLAGS_XORLOGIN 0x00000002 |
---|
359 | #define AIM_SESS_FLAGS_NONBLOCKCONNECT 0x00000004 |
---|
360 | #define AIM_SESS_FLAGS_DONTTIMEOUTONICBM 0x00000008 |
---|
361 | |
---|
362 | /* Valid for calling aim_icq_setstatus() and for aim_userinfo_t->icqinfo.status */ |
---|
363 | #define AIM_ICQ_STATE_NORMAL 0x00000000 |
---|
364 | #define AIM_ICQ_STATE_AWAY 0x00000001 |
---|
365 | #define AIM_ICQ_STATE_DND 0x00000002 |
---|
366 | #define AIM_ICQ_STATE_OUT 0x00000004 |
---|
367 | #define AIM_ICQ_STATE_BUSY 0x00000010 |
---|
368 | #define AIM_ICQ_STATE_CHAT 0x00000020 |
---|
369 | #define AIM_ICQ_STATE_INVISIBLE 0x00000100 |
---|
370 | #define AIM_ICQ_STATE_WEBAWARE 0x00010000 |
---|
371 | |
---|
372 | /* |
---|
373 | * AIM User Info, Standard Form. |
---|
374 | */ |
---|
375 | typedef struct { |
---|
376 | char sn[MAXSNLEN+1]; |
---|
377 | fu16_t warnlevel; /* evil percent * 10 (999 = 99.9%) */ |
---|
378 | fu16_t idletime; /* in seconds */ |
---|
379 | fu16_t flags; |
---|
380 | fu32_t createtime; /* time_t */ |
---|
381 | fu32_t membersince; /* time_t */ |
---|
382 | fu32_t onlinesince; /* time_t */ |
---|
383 | fu32_t sessionlen; /* in seconds */ |
---|
384 | fu32_t capabilities; |
---|
385 | struct { |
---|
386 | fu32_t status; |
---|
387 | fu32_t ipaddr; |
---|
388 | fu8_t crap[0x25]; /* until we figure it out... */ |
---|
389 | } icqinfo; |
---|
390 | fu32_t present; |
---|
391 | } aim_userinfo_t; |
---|
392 | |
---|
393 | #define AIM_USERINFO_PRESENT_FLAGS 0x00000001 |
---|
394 | #define AIM_USERINFO_PRESENT_MEMBERSINCE 0x00000002 |
---|
395 | #define AIM_USERINFO_PRESENT_ONLINESINCE 0x00000004 |
---|
396 | #define AIM_USERINFO_PRESENT_IDLE 0x00000008 |
---|
397 | #define AIM_USERINFO_PRESENT_ICQEXTSTATUS 0x00000010 |
---|
398 | #define AIM_USERINFO_PRESENT_ICQIPADDR 0x00000020 |
---|
399 | #define AIM_USERINFO_PRESENT_ICQDATA 0x00000040 |
---|
400 | #define AIM_USERINFO_PRESENT_CAPABILITIES 0x00000080 |
---|
401 | #define AIM_USERINFO_PRESENT_SESSIONLEN 0x00000100 |
---|
402 | #define AIM_USERINFO_PRESENT_CREATETIME 0x00000200 |
---|
403 | |
---|
404 | faim_export const char *aim_userinfo_sn(aim_userinfo_t *ui); |
---|
405 | faim_export fu16_t aim_userinfo_flags(aim_userinfo_t *ui); |
---|
406 | faim_export fu16_t aim_userinfo_idle(aim_userinfo_t *ui); |
---|
407 | faim_export float aim_userinfo_warnlevel(aim_userinfo_t *ui); |
---|
408 | faim_export time_t aim_userinfo_createtime(aim_userinfo_t *ui); |
---|
409 | faim_export time_t aim_userinfo_membersince(aim_userinfo_t *ui); |
---|
410 | faim_export time_t aim_userinfo_onlinesince(aim_userinfo_t *ui); |
---|
411 | faim_export fu32_t aim_userinfo_sessionlen(aim_userinfo_t *ui); |
---|
412 | faim_export int aim_userinfo_hascap(aim_userinfo_t *ui, fu32_t cap); |
---|
413 | |
---|
414 | #define AIM_FLAG_UNCONFIRMED 0x0001 /* "damned transients" */ |
---|
415 | #define AIM_FLAG_ADMINISTRATOR 0x0002 |
---|
416 | #define AIM_FLAG_AOL 0x0004 |
---|
417 | #define AIM_FLAG_OSCAR_PAY 0x0008 |
---|
418 | #define AIM_FLAG_FREE 0x0010 |
---|
419 | #define AIM_FLAG_AWAY 0x0020 |
---|
420 | #define AIM_FLAG_ICQ 0x0040 |
---|
421 | #define AIM_FLAG_WIRELESS 0x0080 |
---|
422 | #define AIM_FLAG_UNKNOWN100 0x0100 |
---|
423 | #define AIM_FLAG_UNKNOWN200 0x0200 |
---|
424 | #define AIM_FLAG_ACTIVEBUDDY 0x0400 |
---|
425 | #define AIM_FLAG_UNKNOWN800 0x0800 |
---|
426 | #define AIM_FLAG_ABINTERNAL 0x1000 |
---|
427 | |
---|
428 | #define AIM_FLAG_ALLUSERS 0x001f |
---|
429 | |
---|
430 | |
---|
431 | #if defined(FAIM_INTERNAL) || defined(FAIM_NEED_TLV) |
---|
432 | /* |
---|
433 | * TLV handling |
---|
434 | */ |
---|
435 | |
---|
436 | /* Generic TLV structure. */ |
---|
437 | typedef struct aim_tlv_s { |
---|
438 | fu16_t type; |
---|
439 | fu16_t length; |
---|
440 | fu8_t *value; |
---|
441 | } aim_tlv_t; |
---|
442 | |
---|
443 | /* List of above. */ |
---|
444 | typedef struct aim_tlvlist_s { |
---|
445 | aim_tlv_t *tlv; |
---|
446 | struct aim_tlvlist_s *next; |
---|
447 | } aim_tlvlist_t; |
---|
448 | |
---|
449 | /* TLV-handling functions */ |
---|
450 | |
---|
451 | #if 0 |
---|
452 | /* Very, very raw TLV handling. */ |
---|
453 | faim_internal int aim_puttlv_8(fu8_t *buf, const fu16_t t, const fu8_t v); |
---|
454 | faim_internal int aim_puttlv_16(fu8_t *buf, const fu16_t t, const fu16_t v); |
---|
455 | faim_internal int aim_puttlv_32(fu8_t *buf, const fu16_t t, const fu32_t v); |
---|
456 | faim_internal int aim_puttlv_raw(fu8_t *buf, const fu16_t t, const fu16_t l, const fu8_t *v); |
---|
457 | #endif |
---|
458 | |
---|
459 | /* TLV list handling. */ |
---|
460 | faim_internal aim_tlvlist_t *aim_readtlvchain(aim_bstream_t *bs); |
---|
461 | faim_internal void aim_freetlvchain(aim_tlvlist_t **list); |
---|
462 | faim_internal aim_tlv_t *aim_gettlv(aim_tlvlist_t *, fu16_t t, const int n); |
---|
463 | faim_internal char *aim_gettlv_str(aim_tlvlist_t *, const fu16_t t, const int n); |
---|
464 | faim_internal fu8_t aim_gettlv8(aim_tlvlist_t *list, const fu16_t type, const int num); |
---|
465 | faim_internal fu16_t aim_gettlv16(aim_tlvlist_t *list, const fu16_t t, const int n); |
---|
466 | faim_internal fu32_t aim_gettlv32(aim_tlvlist_t *list, const fu16_t t, const int n); |
---|
467 | faim_internal int aim_writetlvchain(aim_bstream_t *bs, aim_tlvlist_t **list); |
---|
468 | faim_internal int aim_addtlvtochain8(aim_tlvlist_t **list, const fu16_t t, const fu8_t v); |
---|
469 | faim_internal int aim_addtlvtochain16(aim_tlvlist_t **list, const fu16_t t, const fu16_t v); |
---|
470 | faim_internal int aim_addtlvtochain32(aim_tlvlist_t **list, const fu16_t type, const fu32_t v); |
---|
471 | faim_internal int aim_addtlvtochain_raw(aim_tlvlist_t **list, const fu16_t t, const fu16_t l, const fu8_t *v); |
---|
472 | faim_internal int aim_addtlvtochain_caps(aim_tlvlist_t **list, const fu16_t t, const fu32_t caps); |
---|
473 | faim_internal int aim_addtlvtochain_noval(aim_tlvlist_t **list, const fu16_t type); |
---|
474 | faim_internal int aim_addtlvtochain_userinfo(aim_tlvlist_t **list, fu16_t type, aim_userinfo_t *ui); |
---|
475 | faim_internal int aim_addtlvtochain_frozentlvlist(aim_tlvlist_t **list, fu16_t type, aim_tlvlist_t **tl); |
---|
476 | faim_internal int aim_counttlvchain(aim_tlvlist_t **list); |
---|
477 | faim_internal int aim_sizetlvchain(aim_tlvlist_t **list); |
---|
478 | #endif /* FAIM_INTERNAL */ |
---|
479 | |
---|
480 | /* |
---|
481 | * Get command from connections |
---|
482 | * |
---|
483 | * aim_get_commmand() is the libfaim lowlevel I/O in the receive direction. |
---|
484 | * XXX Make this easily overridable. |
---|
485 | * |
---|
486 | */ |
---|
487 | faim_export int aim_get_command(aim_session_t *, aim_conn_t *); |
---|
488 | |
---|
489 | /* |
---|
490 | * Dispatch commands that are in the rx queue. |
---|
491 | */ |
---|
492 | faim_export void aim_rxdispatch(aim_session_t *); |
---|
493 | |
---|
494 | faim_export int aim_debugconn_sendconnect(aim_session_t *sess, aim_conn_t *conn); |
---|
495 | |
---|
496 | faim_export int aim_logoff(aim_session_t *); |
---|
497 | |
---|
498 | #if !defined(FAIM_INTERNAL) || defined(FAIM_INTERNAL_INSANE) |
---|
499 | /* the library should never call aim_conn_kill */ |
---|
500 | faim_export void aim_conn_kill(aim_session_t *sess, aim_conn_t **deadconn); |
---|
501 | #endif |
---|
502 | |
---|
503 | typedef int (*aim_rxcallback_t)(aim_session_t *, aim_frame_t *, ...); |
---|
504 | |
---|
505 | struct aim_clientrelease { |
---|
506 | char *name; |
---|
507 | fu32_t build; |
---|
508 | char *url; |
---|
509 | char *info; |
---|
510 | }; |
---|
511 | |
---|
512 | struct aim_authresp_info { |
---|
513 | char *sn; |
---|
514 | fu16_t errorcode; |
---|
515 | char *errorurl; |
---|
516 | fu16_t regstatus; |
---|
517 | char *email; |
---|
518 | char *bosip; |
---|
519 | fu8_t *cookie; |
---|
520 | struct aim_clientrelease latestrelease; |
---|
521 | struct aim_clientrelease latestbeta; |
---|
522 | }; |
---|
523 | |
---|
524 | /* Callback data for redirect. */ |
---|
525 | struct aim_redirect_data { |
---|
526 | fu16_t group; |
---|
527 | const char *ip; |
---|
528 | const fu8_t *cookie; |
---|
529 | struct { /* group == AIM_CONN_TYPE_CHAT */ |
---|
530 | fu16_t exchange; |
---|
531 | const char *room; |
---|
532 | fu16_t instance; |
---|
533 | } chat; |
---|
534 | }; |
---|
535 | |
---|
536 | faim_export int aim_clientready(aim_session_t *sess, aim_conn_t *conn); |
---|
537 | faim_export int aim_sendflapver(aim_session_t *sess, aim_conn_t *conn); |
---|
538 | faim_export int aim_request_login(aim_session_t *sess, aim_conn_t *conn, const char *sn); |
---|
539 | faim_export int aim_send_login(aim_session_t *, aim_conn_t *, const char *, const char *, struct client_info_s *, const char *key); |
---|
540 | faim_export int aim_encode_password_md5(const char *password, const char *key, unsigned char *digest); |
---|
541 | faim_export void aim_purge_rxqueue(aim_session_t *); |
---|
542 | |
---|
543 | #define AIM_TX_QUEUED 0 /* default */ |
---|
544 | #define AIM_TX_IMMEDIATE 1 |
---|
545 | #define AIM_TX_USER 2 |
---|
546 | faim_export int aim_tx_setenqueue(aim_session_t *sess, int what, int (*func)(aim_session_t *, aim_frame_t *)); |
---|
547 | |
---|
548 | faim_export int aim_tx_flushqueue(aim_session_t *); |
---|
549 | faim_export void aim_tx_purgequeue(aim_session_t *); |
---|
550 | |
---|
551 | faim_export int aim_conn_setlatency(aim_conn_t *conn, int newval); |
---|
552 | |
---|
553 | faim_export int aim_conn_addhandler(aim_session_t *, aim_conn_t *conn, u_short family, u_short type, aim_rxcallback_t newhandler, u_short flags); |
---|
554 | faim_export int aim_clearhandlers(aim_conn_t *conn); |
---|
555 | |
---|
556 | faim_export aim_conn_t *aim_conn_findbygroup(aim_session_t *sess, fu16_t group); |
---|
557 | faim_export aim_session_t *aim_conn_getsess(aim_conn_t *conn); |
---|
558 | faim_export void aim_conn_close(aim_conn_t *deadconn); |
---|
559 | faim_export aim_conn_t *aim_newconn(aim_session_t *, int type, const char *dest); |
---|
560 | faim_export int aim_conngetmaxfd(aim_session_t *); |
---|
561 | faim_export aim_conn_t *aim_select(aim_session_t *, struct timeval *, int *); |
---|
562 | faim_export int aim_conn_isready(aim_conn_t *); |
---|
563 | faim_export int aim_conn_setstatus(aim_conn_t *, int); |
---|
564 | faim_export int aim_conn_completeconnect(aim_session_t *sess, aim_conn_t *conn); |
---|
565 | faim_export int aim_conn_isconnecting(aim_conn_t *conn); |
---|
566 | |
---|
567 | typedef void (*faim_debugging_callback_t)(aim_session_t *sess, int level, const char *format, va_list va); |
---|
568 | faim_export int aim_setdebuggingcb(aim_session_t *sess, faim_debugging_callback_t); |
---|
569 | faim_export void aim_session_init(aim_session_t *, unsigned long flags, int debuglevel); |
---|
570 | faim_export void aim_session_kill(aim_session_t *); |
---|
571 | faim_export void aim_setupproxy(aim_session_t *sess, const char *server, const char *username, const char *password); |
---|
572 | faim_export aim_conn_t *aim_getconn_type(aim_session_t *, int type); |
---|
573 | faim_export aim_conn_t *aim_getconn_type_all(aim_session_t *, int type); |
---|
574 | faim_export aim_conn_t *aim_getconn_fd(aim_session_t *, int fd); |
---|
575 | |
---|
576 | /* aim_misc.c */ |
---|
577 | |
---|
578 | #define AIM_VISIBILITYCHANGE_PERMITADD 0x05 |
---|
579 | #define AIM_VISIBILITYCHANGE_PERMITREMOVE 0x06 |
---|
580 | #define AIM_VISIBILITYCHANGE_DENYADD 0x07 |
---|
581 | #define AIM_VISIBILITYCHANGE_DENYREMOVE 0x08 |
---|
582 | |
---|
583 | #define AIM_PRIVFLAGS_ALLOWIDLE 0x01 |
---|
584 | #define AIM_PRIVFLAGS_ALLOWMEMBERSINCE 0x02 |
---|
585 | |
---|
586 | #define AIM_WARN_ANON 0x01 |
---|
587 | |
---|
588 | faim_export int aim_sendpauseack(aim_session_t *sess, aim_conn_t *conn); |
---|
589 | faim_export int aim_send_warning(aim_session_t *sess, aim_conn_t *conn, const char *destsn, fu32_t flags); |
---|
590 | faim_export int aim_nop(aim_session_t *, aim_conn_t *); |
---|
591 | faim_export int aim_flap_nop(aim_session_t *sess, aim_conn_t *conn); |
---|
592 | faim_export int aim_bos_setidle(aim_session_t *, aim_conn_t *, fu32_t); |
---|
593 | faim_export int aim_bos_changevisibility(aim_session_t *, aim_conn_t *, int, const char *); |
---|
594 | faim_export int aim_bos_setbuddylist(aim_session_t *, aim_conn_t *, const char *); |
---|
595 | faim_export int aim_bos_setprofile(aim_session_t *sess, aim_conn_t *conn, const char *profile, const char *awaymsg, fu32_t caps); |
---|
596 | faim_export int aim_bos_setgroupperm(aim_session_t *, aim_conn_t *, fu32_t mask); |
---|
597 | faim_export int aim_bos_setprivacyflags(aim_session_t *, aim_conn_t *, fu32_t); |
---|
598 | faim_export int aim_reqpersonalinfo(aim_session_t *, aim_conn_t *); |
---|
599 | faim_export int aim_reqservice(aim_session_t *, aim_conn_t *, fu16_t); |
---|
600 | faim_export int aim_bos_reqrights(aim_session_t *, aim_conn_t *); |
---|
601 | faim_export int aim_bos_reqbuddyrights(aim_session_t *, aim_conn_t *); |
---|
602 | faim_export int aim_bos_reqlocaterights(aim_session_t *, aim_conn_t *); |
---|
603 | faim_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); |
---|
604 | faim_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); |
---|
605 | faim_export int aim_setextstatus(aim_session_t *sess, aim_conn_t *conn, fu32_t status); |
---|
606 | |
---|
607 | faim_export struct aim_fileheader_t *aim_getlisting(aim_session_t *sess, FILE *); |
---|
608 | |
---|
609 | #define AIM_CLIENTTYPE_UNKNOWN 0x0000 |
---|
610 | #define AIM_CLIENTTYPE_MC 0x0001 |
---|
611 | #define AIM_CLIENTTYPE_WINAIM 0x0002 |
---|
612 | #define AIM_CLIENTTYPE_WINAIM41 0x0003 |
---|
613 | #define AIM_CLIENTTYPE_AOL_TOC 0x0004 |
---|
614 | faim_export unsigned short aim_fingerprintclient(unsigned char *msghdr, int len); |
---|
615 | |
---|
616 | #define AIM_RATE_CODE_CHANGE 0x0001 |
---|
617 | #define AIM_RATE_CODE_WARNING 0x0002 |
---|
618 | #define AIM_RATE_CODE_LIMIT 0x0003 |
---|
619 | #define AIM_RATE_CODE_CLEARLIMIT 0x0004 |
---|
620 | faim_export int aim_ads_requestads(aim_session_t *sess, aim_conn_t *conn); |
---|
621 | |
---|
622 | /* aim_im.c */ |
---|
623 | |
---|
624 | struct aim_fileheader_t { |
---|
625 | #if 0 |
---|
626 | char magic[4]; /* 0 */ |
---|
627 | short hdrlen; /* 4 */ |
---|
628 | short hdrtype; /* 6 */ |
---|
629 | #endif |
---|
630 | char bcookie[8]; /* 8 */ |
---|
631 | short encrypt; /* 16 */ |
---|
632 | short compress; /* 18 */ |
---|
633 | short totfiles; /* 20 */ |
---|
634 | short filesleft; /* 22 */ |
---|
635 | short totparts; /* 24 */ |
---|
636 | short partsleft; /* 26 */ |
---|
637 | long totsize; /* 28 */ |
---|
638 | long size; /* 32 */ |
---|
639 | long modtime; /* 36 */ |
---|
640 | long checksum; /* 40 */ |
---|
641 | long rfrcsum; /* 44 */ |
---|
642 | long rfsize; /* 48 */ |
---|
643 | long cretime; /* 52 */ |
---|
644 | long rfcsum; /* 56 */ |
---|
645 | long nrecvd; /* 60 */ |
---|
646 | long recvcsum; /* 64 */ |
---|
647 | char idstring[32]; /* 68 */ |
---|
648 | char flags; /* 100 */ |
---|
649 | char lnameoffset; /* 101 */ |
---|
650 | char lsizeoffset; /* 102 */ |
---|
651 | char dummy[69]; /* 103 */ |
---|
652 | char macfileinfo[16]; /* 172 */ |
---|
653 | short nencode; /* 188 */ |
---|
654 | short nlanguage; /* 190 */ |
---|
655 | char name[64]; /* 192 */ |
---|
656 | /* 256 */ |
---|
657 | }; |
---|
658 | |
---|
659 | struct aim_filetransfer_priv { |
---|
660 | char sn[MAXSNLEN]; |
---|
661 | char cookie[8]; |
---|
662 | char ip[30]; |
---|
663 | int state; |
---|
664 | struct aim_fileheader_t fh; |
---|
665 | }; |
---|
666 | |
---|
667 | struct aim_chat_roominfo { |
---|
668 | unsigned short exchange; |
---|
669 | char *name; |
---|
670 | unsigned short instance; |
---|
671 | }; |
---|
672 | |
---|
673 | #define AIM_IMFLAGS_AWAY 0x0001 /* mark as an autoreply */ |
---|
674 | #define AIM_IMFLAGS_ACK 0x0002 /* request a receipt notice */ |
---|
675 | #define AIM_IMFLAGS_UNICODE 0x0004 |
---|
676 | #define AIM_IMFLAGS_ISO_8859_1 0x0008 |
---|
677 | #define AIM_IMFLAGS_BUDDYREQ 0x0010 /* buddy icon requested */ |
---|
678 | #define AIM_IMFLAGS_HASICON 0x0020 /* already has icon */ |
---|
679 | #define AIM_IMFLAGS_SUBENC_MACINTOSH 0x0040 /* damn that Steve Jobs! */ |
---|
680 | #define AIM_IMFLAGS_CUSTOMFEATURES 0x0080 /* features field present */ |
---|
681 | #define AIM_IMFLAGS_EXTDATA 0x0100 |
---|
682 | #define AIM_IMFLAGS_CUSTOMCHARSET 0x0200 /* charset fields set */ |
---|
683 | #define AIM_IMFLAGS_MULTIPART 0x0400 /* ->mpmsg section valid */ |
---|
684 | #define AIM_IMFLAGS_OFFLINE 0x0800 /* send to offline user */ |
---|
685 | |
---|
686 | /* |
---|
687 | * Multipart message structures. |
---|
688 | */ |
---|
689 | typedef struct aim_mpmsg_section_s { |
---|
690 | fu16_t charset; |
---|
691 | fu16_t charsubset; |
---|
692 | fu8_t *data; |
---|
693 | fu16_t datalen; |
---|
694 | struct aim_mpmsg_section_s *next; |
---|
695 | } aim_mpmsg_section_t; |
---|
696 | |
---|
697 | typedef struct aim_mpmsg_s { |
---|
698 | int numparts; |
---|
699 | aim_mpmsg_section_t *parts; |
---|
700 | } aim_mpmsg_t; |
---|
701 | |
---|
702 | faim_export int aim_mpmsg_init(aim_session_t *sess, aim_mpmsg_t *mpm); |
---|
703 | faim_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); |
---|
704 | faim_export int aim_mpmsg_addascii(aim_session_t *sess, aim_mpmsg_t *mpm, const char *ascii); |
---|
705 | faim_export int aim_mpmsg_addunicode(aim_session_t *sess, aim_mpmsg_t *mpm, const fu16_t *unicode, fu16_t unicodelen); |
---|
706 | faim_export void aim_mpmsg_free(aim_session_t *sess, aim_mpmsg_t *mpm); |
---|
707 | |
---|
708 | /* |
---|
709 | * Arguments to aim_send_im_ext(). |
---|
710 | * |
---|
711 | * This is really complicated. But immensely versatile. |
---|
712 | * |
---|
713 | */ |
---|
714 | struct aim_sendimext_args { |
---|
715 | |
---|
716 | /* These are _required_ */ |
---|
717 | const char *destsn; |
---|
718 | fu32_t flags; /* often 0 */ |
---|
719 | |
---|
720 | /* Only required if not using multipart messages */ |
---|
721 | const char *msg; |
---|
722 | int msglen; |
---|
723 | |
---|
724 | /* Required if ->msg is not provided */ |
---|
725 | aim_mpmsg_t *mpmsg; |
---|
726 | |
---|
727 | /* Only used if AIM_IMFLAGS_HASICON is set */ |
---|
728 | fu32_t iconlen; |
---|
729 | time_t iconstamp; |
---|
730 | fu32_t iconsum; |
---|
731 | |
---|
732 | /* Only used if AIM_IMFLAGS_CUSTOMFEATURES is set */ |
---|
733 | fu8_t *features; |
---|
734 | fu8_t featureslen; |
---|
735 | |
---|
736 | /* Only used if AIM_IMFLAGS_CUSTOMCHARSET is set and mpmsg not used */ |
---|
737 | fu16_t charset; |
---|
738 | fu16_t charsubset; |
---|
739 | }; |
---|
740 | |
---|
741 | /* |
---|
742 | * Arguments to aim_send_rtfmsg(). |
---|
743 | */ |
---|
744 | struct aim_sendrtfmsg_args { |
---|
745 | const char *destsn; |
---|
746 | fu32_t fgcolor; |
---|
747 | fu32_t bgcolor; |
---|
748 | const char *rtfmsg; /* must be in RTF */ |
---|
749 | }; |
---|
750 | |
---|
751 | /* |
---|
752 | * This information is provided in the Incoming ICBM callback for |
---|
753 | * Channel 1 ICBM's. |
---|
754 | * |
---|
755 | * Note that although CUSTOMFEATURES and CUSTOMCHARSET say they |
---|
756 | * are optional, both are always set by the current libfaim code. |
---|
757 | * That may or may not change in the future. It is mainly for |
---|
758 | * consistency with aim_sendimext_args. |
---|
759 | * |
---|
760 | * Multipart messages require some explanation. If you want to use them, |
---|
761 | * I suggest you read all the comments in im.c. |
---|
762 | * |
---|
763 | */ |
---|
764 | struct aim_incomingim_ch1_args { |
---|
765 | |
---|
766 | /* Always provided */ |
---|
767 | aim_mpmsg_t mpmsg; |
---|
768 | fu32_t icbmflags; /* some flags apply only to ->msg, not all mpmsg */ |
---|
769 | |
---|
770 | /* Only provided if message has a human-readable section */ |
---|
771 | char *msg; |
---|
772 | int msglen; |
---|
773 | |
---|
774 | /* Only provided if AIM_IMFLAGS_HASICON is set */ |
---|
775 | time_t iconstamp; |
---|
776 | fu32_t iconlen; |
---|
777 | fu16_t iconsum; |
---|
778 | |
---|
779 | /* Only provided if AIM_IMFLAGS_CUSTOMFEATURES is set */ |
---|
780 | fu8_t *features; |
---|
781 | fu8_t featureslen; |
---|
782 | |
---|
783 | /* Only provided if AIM_IMFLAGS_EXTDATA is set */ |
---|
784 | fu8_t extdatalen; |
---|
785 | fu8_t *extdata; |
---|
786 | |
---|
787 | /* Only used if AIM_IMFLAGS_CUSTOMCHARSET is set */ |
---|
788 | fu16_t charset; |
---|
789 | fu16_t charsubset; |
---|
790 | }; |
---|
791 | |
---|
792 | /* Valid values for channel 2 args->status */ |
---|
793 | #define AIM_RENDEZVOUS_PROPOSE 0x0000 |
---|
794 | #define AIM_RENDEZVOUS_CANCEL 0x0001 |
---|
795 | #define AIM_RENDEZVOUS_ACCEPT 0x0002 |
---|
796 | |
---|
797 | struct aim_incomingim_ch2_args { |
---|
798 | fu8_t cookie[8]; |
---|
799 | fu16_t reqclass; |
---|
800 | fu16_t status; |
---|
801 | fu16_t errorcode; |
---|
802 | const char *clientip; |
---|
803 | const char *clientip2; |
---|
804 | const char *verifiedip; |
---|
805 | fu16_t port; |
---|
806 | const char *msg; /* invite message or file description */ |
---|
807 | const char *encoding; |
---|
808 | const char *language; |
---|
809 | union { |
---|
810 | struct { |
---|
811 | fu32_t checksum; |
---|
812 | fu32_t length; |
---|
813 | time_t timestamp; |
---|
814 | fu8_t *icon; |
---|
815 | } icon; |
---|
816 | struct { |
---|
817 | struct aim_chat_roominfo roominfo; |
---|
818 | } chat; |
---|
819 | struct { |
---|
820 | fu32_t fgcolor; |
---|
821 | fu32_t bgcolor; |
---|
822 | const char *rtfmsg; |
---|
823 | } rtfmsg; |
---|
824 | } info; |
---|
825 | void *destructor; /* used internally only */ |
---|
826 | }; |
---|
827 | |
---|
828 | faim_export int aim_send_rtfmsg(aim_session_t *sess, struct aim_sendrtfmsg_args *args); |
---|
829 | faim_export int aim_send_im_ext(aim_session_t *sess, struct aim_sendimext_args *args); |
---|
830 | faim_export int aim_send_im(aim_session_t *, const char *destsn, unsigned short flags, const char *msg); |
---|
831 | faim_export int aim_send_icon(aim_session_t *sess, const char *sn, const fu8_t *icon, int iconlen, time_t stamp, fu16_t iconsum); |
---|
832 | faim_export fu16_t aim_iconsum(const fu8_t *buf, int buflen); |
---|
833 | faim_export int aim_send_im_direct(aim_session_t *, aim_conn_t *, const char *msg); |
---|
834 | faim_export const char *aim_directim_getsn(aim_conn_t *conn); |
---|
835 | faim_export aim_conn_t *aim_directim_initiate(aim_session_t *, const char *destsn); |
---|
836 | faim_export aim_conn_t *aim_directim_connect(aim_session_t *, const char *sn, const char *addr, const fu8_t *cookie); |
---|
837 | |
---|
838 | faim_export aim_conn_t *aim_sendfile_initiate(aim_session_t *, const char *destsn, const char *filename, fu16_t numfiles, fu32_t totsize); |
---|
839 | |
---|
840 | faim_export aim_conn_t *aim_getfile_initiate(aim_session_t *sess, aim_conn_t *conn, const char *destsn); |
---|
841 | faim_export int aim_oft_getfile_request(aim_session_t *sess, aim_conn_t *conn, const char *name, int size); |
---|
842 | faim_export int aim_oft_getfile_ack(aim_session_t *sess, aim_conn_t *conn); |
---|
843 | faim_export int aim_oft_getfile_end(aim_session_t *sess, aim_conn_t *conn); |
---|
844 | |
---|
845 | /* aim_info.c */ |
---|
846 | #define AIM_CAPS_BUDDYICON 0x00000001 |
---|
847 | #define AIM_CAPS_VOICE 0x00000002 |
---|
848 | #define AIM_CAPS_IMIMAGE 0x00000004 |
---|
849 | #define AIM_CAPS_CHAT 0x00000008 |
---|
850 | #define AIM_CAPS_GETFILE 0x00000010 |
---|
851 | #define AIM_CAPS_SENDFILE 0x00000020 |
---|
852 | #define AIM_CAPS_GAMES 0x00000040 |
---|
853 | #define AIM_CAPS_SAVESTOCKS 0x00000080 |
---|
854 | #define AIM_CAPS_SENDBUDDYLIST 0x00000100 |
---|
855 | #define AIM_CAPS_GAMES2 0x00000200 |
---|
856 | #define AIM_CAPS_ICQ 0x00000400 |
---|
857 | #define AIM_CAPS_APINFO 0x00000800 |
---|
858 | #define AIM_CAPS_ICQRTF 0x00001000 |
---|
859 | #define AIM_CAPS_EMPTY 0x00002000 |
---|
860 | #define AIM_CAPS_ICQSERVERRELAY 0x00004000 |
---|
861 | #define AIM_CAPS_ICQUNKNOWN 0x00008000 |
---|
862 | #define AIM_CAPS_TRILLIANCRYPT 0x00010000 |
---|
863 | #define AIM_CAPS_LAST 0x00020000 |
---|
864 | |
---|
865 | faim_export int aim_0002_000b(aim_session_t *sess, aim_conn_t *conn, const char *sn); |
---|
866 | |
---|
867 | #define AIM_SENDMEMBLOCK_FLAG_ISREQUEST 0 |
---|
868 | #define AIM_SENDMEMBLOCK_FLAG_ISHASH 1 |
---|
869 | |
---|
870 | faim_export int aim_sendmemblock(aim_session_t *sess, aim_conn_t *conn, unsigned long offset, unsigned long len, const unsigned char *buf, unsigned char flag); |
---|
871 | |
---|
872 | #define AIM_GETINFO_GENERALINFO 0x00001 |
---|
873 | #define AIM_GETINFO_AWAYMESSAGE 0x00003 |
---|
874 | #define AIM_GETINFO_CAPABILITIES 0x0004 |
---|
875 | |
---|
876 | struct aim_invite_priv { |
---|
877 | char *sn; |
---|
878 | char *roomname; |
---|
879 | fu16_t exchange; |
---|
880 | fu16_t instance; |
---|
881 | }; |
---|
882 | |
---|
883 | #define AIM_COOKIETYPE_UNKNOWN 0x00 |
---|
884 | #define AIM_COOKIETYPE_ICBM 0x01 |
---|
885 | #define AIM_COOKIETYPE_ADS 0x02 |
---|
886 | #define AIM_COOKIETYPE_BOS 0x03 |
---|
887 | #define AIM_COOKIETYPE_IM 0x04 |
---|
888 | #define AIM_COOKIETYPE_CHAT 0x05 |
---|
889 | #define AIM_COOKIETYPE_CHATNAV 0x06 |
---|
890 | #define AIM_COOKIETYPE_INVITE 0x07 |
---|
891 | /* we'll move OFT up a bit to give breathing room. not like it really |
---|
892 | * matters. */ |
---|
893 | #define AIM_COOKIETYPE_OFTIM 0x10 |
---|
894 | #define AIM_COOKIETYPE_OFTGET 0x11 |
---|
895 | #define AIM_COOKIETYPE_OFTSEND 0x12 |
---|
896 | #define AIM_COOKIETYPE_OFTVOICE 0x13 |
---|
897 | #define AIM_COOKIETYPE_OFTIMAGE 0x14 |
---|
898 | #define AIM_COOKIETYPE_OFTICON 0x15 |
---|
899 | |
---|
900 | faim_export int aim_handlerendconnect(aim_session_t *sess, aim_conn_t *cur); |
---|
901 | |
---|
902 | #define AIM_TRANSFER_DENY_NOTSUPPORTED 0x0000 |
---|
903 | #define AIM_TRANSFER_DENY_DECLINE 0x0001 |
---|
904 | #define AIM_TRANSFER_DENY_NOTACCEPTING 0x0002 |
---|
905 | faim_export int aim_denytransfer(aim_session_t *sess, const char *sender, const char *cookie, unsigned short code); |
---|
906 | faim_export aim_conn_t *aim_accepttransfer(aim_session_t *sess, aim_conn_t *conn, const char *sn, const fu8_t *cookie, const fu8_t *ip, fu16_t listingfiles, fu16_t listingtotsize, fu16_t listingsize, fu32_t listingchecksum, fu16_t rendid); |
---|
907 | |
---|
908 | faim_export int aim_getinfo(aim_session_t *, aim_conn_t *, const char *, unsigned short); |
---|
909 | faim_export int aim_sendbuddyoncoming(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *info); |
---|
910 | faim_export int aim_sendbuddyoffgoing(aim_session_t *sess, aim_conn_t *conn, const char *sn); |
---|
911 | |
---|
912 | #define AIM_IMPARAM_FLAG_CHANMSGS_ALLOWED 0x00000001 |
---|
913 | #define AIM_IMPARAM_FLAG_MISSEDCALLS_ENABLED 0x00000002 |
---|
914 | |
---|
915 | /* This is what the server will give you if you don't set them yourself. */ |
---|
916 | #define AIM_IMPARAM_DEFAULTS { \ |
---|
917 | 0, \ |
---|
918 | AIM_IMPARAM_FLAG_CHANMSGS_ALLOWED | AIM_IMPARAM_FLAG_MISSEDCALLS_ENABLED, \ |
---|
919 | 512, /* !! Note how small this is. */ \ |
---|
920 | (99.9)*10, (99.9)*10, \ |
---|
921 | 1000 /* !! And how large this is. */ \ |
---|
922 | } |
---|
923 | |
---|
924 | /* This is what most AIM versions use. */ |
---|
925 | #define AIM_IMPARAM_REASONABLE { \ |
---|
926 | 0, \ |
---|
927 | AIM_IMPARAM_FLAG_CHANMSGS_ALLOWED | AIM_IMPARAM_FLAG_MISSEDCALLS_ENABLED, \ |
---|
928 | 8000, \ |
---|
929 | (99.9)*10, (99.9)*10, \ |
---|
930 | 0 \ |
---|
931 | } |
---|
932 | |
---|
933 | |
---|
934 | struct aim_icbmparameters { |
---|
935 | unsigned short maxchan; |
---|
936 | unsigned long flags; /* AIM_IMPARAM_FLAG_ */ |
---|
937 | unsigned short maxmsglen; /* message size that you will accept */ |
---|
938 | unsigned short maxsenderwarn; /* this and below are *10 (999=99.9%) */ |
---|
939 | unsigned short maxrecverwarn; |
---|
940 | unsigned long minmsginterval; /* in milliseconds? */ |
---|
941 | }; |
---|
942 | |
---|
943 | faim_export int aim_reqicbmparams(aim_session_t *sess); |
---|
944 | faim_export int aim_seticbmparam(aim_session_t *sess, struct aim_icbmparameters *params); |
---|
945 | |
---|
946 | |
---|
947 | /* auth.c */ |
---|
948 | faim_export int aim_sendcookie(aim_session_t *, aim_conn_t *, const fu8_t *); |
---|
949 | |
---|
950 | faim_export int aim_admin_changepasswd(aim_session_t *, aim_conn_t *, const char *newpw, const char *curpw); |
---|
951 | faim_export int aim_admin_reqconfirm(aim_session_t *sess, aim_conn_t *conn); |
---|
952 | faim_export int aim_admin_getinfo(aim_session_t *sess, aim_conn_t *conn, fu16_t info); |
---|
953 | faim_export int aim_admin_setemail(aim_session_t *sess, aim_conn_t *conn, const char *newemail); |
---|
954 | faim_export int aim_admin_setnick(aim_session_t *sess, aim_conn_t *conn, const char *newnick); |
---|
955 | |
---|
956 | /* aim_buddylist.c */ |
---|
957 | faim_export int aim_add_buddy(aim_session_t *, aim_conn_t *, const char *); |
---|
958 | faim_export int aim_remove_buddy(aim_session_t *, aim_conn_t *, const char *); |
---|
959 | |
---|
960 | /* aim_search.c */ |
---|
961 | faim_export int aim_usersearch_address(aim_session_t *, aim_conn_t *, const char *); |
---|
962 | |
---|
963 | /* These apply to exchanges as well. */ |
---|
964 | #define AIM_CHATROOM_FLAG_EVILABLE 0x0001 |
---|
965 | #define AIM_CHATROOM_FLAG_NAV_ONLY 0x0002 |
---|
966 | #define AIM_CHATROOM_FLAG_INSTANCING_ALLOWED 0x0004 |
---|
967 | #define AIM_CHATROOM_FLAG_OCCUPANT_PEEK_ALLOWED 0x0008 |
---|
968 | |
---|
969 | struct aim_chat_exchangeinfo { |
---|
970 | fu16_t number; |
---|
971 | fu16_t flags; |
---|
972 | char *name; |
---|
973 | char *charset1; |
---|
974 | char *lang1; |
---|
975 | char *charset2; |
---|
976 | char *lang2; |
---|
977 | }; |
---|
978 | |
---|
979 | #define AIM_CHATFLAGS_NOREFLECT 0x0001 |
---|
980 | #define AIM_CHATFLAGS_AWAY 0x0002 |
---|
981 | faim_export int aim_chat_send_im(aim_session_t *sess, aim_conn_t *conn, fu16_t flags, const char *msg, int msglen); |
---|
982 | faim_export int aim_chat_join(aim_session_t *sess, aim_conn_t *conn, fu16_t exchange, const char *roomname, fu16_t instance); |
---|
983 | faim_export int aim_chat_attachname(aim_conn_t *conn, fu16_t exchange, const char *roomname, fu16_t instance); |
---|
984 | faim_export char *aim_chat_getname(aim_conn_t *conn); |
---|
985 | faim_export aim_conn_t *aim_chat_getconn(aim_session_t *, const char *name); |
---|
986 | |
---|
987 | faim_export int aim_chatnav_reqrights(aim_session_t *sess, aim_conn_t *conn); |
---|
988 | |
---|
989 | faim_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); |
---|
990 | |
---|
991 | faim_export int aim_chatnav_createroom(aim_session_t *sess, aim_conn_t *conn, const char *name, fu16_t exchange); |
---|
992 | faim_export int aim_chat_leaveroom(aim_session_t *sess, const char *name); |
---|
993 | |
---|
994 | |
---|
995 | #define AIM_SSI_TYPE_BUDDY 0x0000 |
---|
996 | #define AIM_SSI_TYPE_GROUP 0x0001 |
---|
997 | #define AIM_SSI_TYPE_PERMITLIST 0x0002 |
---|
998 | #define AIM_SSI_TYPE_DENYLIST 0x0003 |
---|
999 | #define AIM_SSI_TYPE_PDINFO 0x0004 |
---|
1000 | #define AIM_SSI_TYPE_PRESENCEPREFS 0x0005 |
---|
1001 | |
---|
1002 | struct aim_ssi_item { |
---|
1003 | char *name; |
---|
1004 | fu16_t gid; |
---|
1005 | fu16_t bid; |
---|
1006 | fu16_t type; |
---|
1007 | void *data; |
---|
1008 | struct aim_ssi_item *next; |
---|
1009 | }; |
---|
1010 | |
---|
1011 | faim_export int aim_ssi_reqrights(aim_session_t *sess, aim_conn_t *conn); |
---|
1012 | faim_export int aim_ssi_reqdata(aim_session_t *sess, aim_conn_t *conn, time_t localstamp, fu16_t localrev); |
---|
1013 | faim_export int aim_ssi_enable(aim_session_t *sess, aim_conn_t *conn); |
---|
1014 | faim_export int aim_ssi_modbegin(aim_session_t *sess, aim_conn_t *conn); |
---|
1015 | faim_export int aim_ssi_modend(aim_session_t *sess, aim_conn_t *conn); |
---|
1016 | |
---|
1017 | struct aim_icq_offlinemsg { |
---|
1018 | fu32_t sender; |
---|
1019 | fu16_t year; |
---|
1020 | fu8_t month, day, hour, minute; |
---|
1021 | fu16_t type; |
---|
1022 | char *msg; |
---|
1023 | }; |
---|
1024 | |
---|
1025 | struct aim_icq_simpleinfo { |
---|
1026 | fu32_t uin; |
---|
1027 | char *nick; |
---|
1028 | char *first; |
---|
1029 | char *last; |
---|
1030 | char *email; |
---|
1031 | }; |
---|
1032 | |
---|
1033 | faim_export int aim_icq_reqofflinemsgs(aim_session_t *sess); |
---|
1034 | faim_export int aim_icq_ackofflinemsgs(aim_session_t *sess); |
---|
1035 | faim_export int aim_icq_getsimpleinfo(aim_session_t *sess, const char *uin); |
---|
1036 | |
---|
1037 | /* aim_util.c */ |
---|
1038 | /* |
---|
1039 | * These are really ugly. You'd think this was LISP. I wish it was. |
---|
1040 | * |
---|
1041 | * XXX With the advent of bstream's, these should be removed to enforce |
---|
1042 | * their use. |
---|
1043 | * |
---|
1044 | */ |
---|
1045 | #define aimutil_put8(buf, data) ((*(buf) = (u_char)(data)&0xff),1) |
---|
1046 | #define aimutil_get8(buf) ((*(buf))&0xff) |
---|
1047 | #define aimutil_put16(buf, data) ( \ |
---|
1048 | (*(buf) = (u_char)((data)>>8)&0xff), \ |
---|
1049 | (*((buf)+1) = (u_char)(data)&0xff), \ |
---|
1050 | 2) |
---|
1051 | #define aimutil_get16(buf) ((((*(buf))<<8)&0xff00) + ((*((buf)+1)) & 0xff)) |
---|
1052 | #define aimutil_put32(buf, data) ( \ |
---|
1053 | (*((buf)) = (u_char)((data)>>24)&0xff), \ |
---|
1054 | (*((buf)+1) = (u_char)((data)>>16)&0xff), \ |
---|
1055 | (*((buf)+2) = (u_char)((data)>>8)&0xff), \ |
---|
1056 | (*((buf)+3) = (u_char)(data)&0xff), \ |
---|
1057 | 4) |
---|
1058 | #define aimutil_get32(buf) ((((*(buf))<<24)&0xff000000) + \ |
---|
1059 | (((*((buf)+1))<<16)&0x00ff0000) + \ |
---|
1060 | (((*((buf)+2))<< 8)&0x0000ff00) + \ |
---|
1061 | (((*((buf)+3) )&0x000000ff))) |
---|
1062 | |
---|
1063 | /* Little-endian versions (damn ICQ) */ |
---|
1064 | #define aimutil_putle8(buf, data) ( \ |
---|
1065 | (*(buf) = (unsigned char)(data) & 0xff), \ |
---|
1066 | 1) |
---|
1067 | #define aimutil_getle8(buf) ( \ |
---|
1068 | (*(buf)) & 0xff \ |
---|
1069 | ) |
---|
1070 | #define aimutil_putle16(buf, data) ( \ |
---|
1071 | (*((buf)+0) = (unsigned char)((data) >> 0) & 0xff), \ |
---|
1072 | (*((buf)+1) = (unsigned char)((data) >> 8) & 0xff), \ |
---|
1073 | 2) |
---|
1074 | #define aimutil_getle16(buf) ( \ |
---|
1075 | (((*((buf)+0)) << 0) & 0x00ff) + \ |
---|
1076 | (((*((buf)+1)) << 8) & 0xff00) \ |
---|
1077 | ) |
---|
1078 | #define aimutil_putle32(buf, data) ( \ |
---|
1079 | (*((buf)+0) = (unsigned char)((data) >> 0) & 0xff), \ |
---|
1080 | (*((buf)+1) = (unsigned char)((data) >> 8) & 0xff), \ |
---|
1081 | (*((buf)+2) = (unsigned char)((data) >> 16) & 0xff), \ |
---|
1082 | (*((buf)+3) = (unsigned char)((data) >> 24) & 0xff), \ |
---|
1083 | 4) |
---|
1084 | #define aimutil_getle32(buf) ( \ |
---|
1085 | (((*((buf)+0)) << 0) & 0x000000ff) + \ |
---|
1086 | (((*((buf)+1)) << 8) & 0x0000ff00) + \ |
---|
1087 | (((*((buf)+2)) << 16) & 0x00ff0000) + \ |
---|
1088 | (((*((buf)+3)) << 24) & 0xff000000)) |
---|
1089 | |
---|
1090 | |
---|
1091 | faim_export int aimutil_putstr(u_char *, const char *, int); |
---|
1092 | faim_export int aimutil_tokslen(char *toSearch, int index, char dl); |
---|
1093 | faim_export int aimutil_itemcnt(char *toSearch, char dl); |
---|
1094 | faim_export char *aimutil_itemidx(char *toSearch, int index, char dl); |
---|
1095 | |
---|
1096 | faim_export int aim_snlen(const char *sn); |
---|
1097 | faim_export int aim_sncmp(const char *sn1, const char *sn2); |
---|
1098 | |
---|
1099 | /* for libc's that dont have it */ |
---|
1100 | faim_export char *aim_strsep(char **pp, const char *delim); |
---|
1101 | |
---|
1102 | /* aim_meta.c */ |
---|
1103 | faim_export char *aim_getbuilddate(void); |
---|
1104 | faim_export char *aim_getbuildtime(void); |
---|
1105 | faim_export int aim_getbuildstring(char *buf, int buflen); |
---|
1106 | |
---|
1107 | #include <aim_internal.h> |
---|
1108 | |
---|
1109 | #endif /* __AIM_H__ */ |
---|
1110 | |
---|