[5e53c4a] | 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" |
---|
[e374dee] | 5 | * -- Josh Myer |
---|
[5e53c4a] | 6 | * |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | #ifndef __AIM_H__ |
---|
| 10 | #define __AIM_H__ |
---|
| 11 | |
---|
| 12 | #define FAIM_VERSION_MAJOR 0 |
---|
| 13 | #define FAIM_VERSION_MINOR 99 |
---|
[862371b] | 14 | #define FAIM_VERSION_MINORMINOR 1 |
---|
[5e53c4a] | 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 | |
---|
[862371b] | 28 | #ifndef _WIN32 |
---|
[5e53c4a] | 29 | #include <sys/time.h> |
---|
| 30 | #include <unistd.h> |
---|
[e374dee] | 31 | #include <netdb.h> |
---|
[5e53c4a] | 32 | #include <netinet/in.h> |
---|
| 33 | #include <sys/socket.h> |
---|
[862371b] | 34 | #else |
---|
| 35 | #include <winsock.h> |
---|
[5e53c4a] | 36 | #endif |
---|
| 37 | |
---|
[e374dee] | 38 | #ifdef __cplusplus |
---|
| 39 | extern "C" { |
---|
| 40 | #endif |
---|
| 41 | |
---|
[5e53c4a] | 42 | /* XXX adjust these based on autoconf-detected platform */ |
---|
| 43 | typedef unsigned char fu8_t; |
---|
| 44 | typedef unsigned short fu16_t; |
---|
[e374dee] | 45 | typedef unsigned int fu32_t; |
---|
[5e53c4a] | 46 | typedef fu32_t aim_snacid_t; |
---|
| 47 | typedef 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 | |
---|
[e374dee] | 74 | #ifndef FALSE |
---|
| 75 | #define FALSE (0) |
---|
| 76 | #endif |
---|
| 77 | |
---|
| 78 | #ifndef TRUE |
---|
| 79 | #define TRUE (!FALSE) |
---|
| 80 | #endif |
---|
| 81 | |
---|
[5e53c4a] | 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 | */ |
---|
[e374dee] | 88 | #define MAXSNLEN 97 |
---|
[5e53c4a] | 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 | |
---|
[e374dee] | 123 | /** |
---|
| 124 | * Maximum length for the password of an ICQ account |
---|
[5e53c4a] | 125 | */ |
---|
[e374dee] | 126 | #define MAXICQPASSLEN 8 |
---|
[5e53c4a] | 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 | */ |
---|
| 136 | struct client_info_s { |
---|
| 137 | const char *clientstring; |
---|
| 138 | fu16_t clientid; |
---|
[e374dee] | 139 | fu16_t major; |
---|
| 140 | fu16_t minor; |
---|
| 141 | fu16_t point; |
---|
| 142 | fu16_t build; |
---|
| 143 | fu32_t distrib; |
---|
[5e53c4a] | 144 | const char *country; /* two-letter abbrev */ |
---|
| 145 | const char *lang; /* two-letter abbrev */ |
---|
| 146 | }; |
---|
| 147 | |
---|
[e374dee] | 148 | /* Needs to be checked */ |
---|
[862371b] | 149 | #define CLIENTINFO_AIM_3_5_1670 { \ |
---|
[5e53c4a] | 150 | "AOL Instant Messenger (SM), version 3.5.1670/WIN32", \ |
---|
| 151 | 0x0004, \ |
---|
[e374dee] | 152 | 0x0003, 0x0005, \ |
---|
| 153 | 0x0000, 0x0686, \ |
---|
| 154 | 0x0000002a, \ |
---|
| 155 | "us", "en", \ |
---|
[5e53c4a] | 156 | } |
---|
| 157 | |
---|
[e374dee] | 158 | /* Needs to be checked */ |
---|
| 159 | /* Latest winaim without ssi */ |
---|
[862371b] | 160 | #define CLIENTINFO_AIM_4_1_2010 { \ |
---|
[e374dee] | 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", \ |
---|
[5e53c4a] | 187 | } |
---|
| 188 | |
---|
[e374dee] | 189 | /* Needs to be checked */ |
---|
[862371b] | 190 | #define CLIENTINFO_AIM_5_0_2938 { \ |
---|
[e374dee] | 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", \ |
---|
[862371b] | 215 | } |
---|
| 216 | |
---|
[e374dee] | 217 | /* Needs to be checked */ |
---|
[862371b] | 218 | #define CLIENTINFO_ICQ_4_65_3281 { \ |
---|
| 219 | "ICQ Inc. - Product of ICQ (TM) 2000b.4.65.1.3281.85", \ |
---|
| 220 | 0x010a, \ |
---|
[e374dee] | 221 | 0x0004, 0x0041, \ |
---|
| 222 | 0x0001, 0x0cd1, \ |
---|
| 223 | 0x00000055, \ |
---|
| 224 | "us", "en", \ |
---|
[862371b] | 225 | } |
---|
| 226 | |
---|
[e374dee] | 227 | /* Needs to be checked */ |
---|
[862371b] | 228 | #define CLIENTINFO_ICQ_5_34_3728 { \ |
---|
| 229 | "ICQ Inc. - Product of ICQ (TM).2002a.5.34.1.3728.85", \ |
---|
| 230 | 0x010a, \ |
---|
[e374dee] | 231 | 0x0005, 0x0022, \ |
---|
| 232 | 0x0001, 0x0e8f, \ |
---|
| 233 | 0x00000055, \ |
---|
| 234 | "us", "en", \ |
---|
[862371b] | 235 | } |
---|
| 236 | |
---|
[e374dee] | 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 | } |
---|
[5e53c4a] | 245 | |
---|
[e374dee] | 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 |
---|
[5e53c4a] | 266 | |
---|
| 267 | /* |
---|
| 268 | * These could be arbitrary, but its easier to use the actual AIM values |
---|
| 269 | */ |
---|
[e374dee] | 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() */ |
---|
[5e53c4a] | 282 | |
---|
| 283 | /* |
---|
| 284 | * Subtypes, we need these for OFT stuff. |
---|
| 285 | */ |
---|
[e374dee] | 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 |
---|
[5e53c4a] | 291 | |
---|
| 292 | /* |
---|
| 293 | * Status values returned from aim_conn_new(). ORed together. |
---|
| 294 | */ |
---|
[e374dee] | 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 |
---|
[5e53c4a] | 300 | |
---|
[e374dee] | 301 | #define AIM_FRAMETYPE_FLAP 0x0000 |
---|
| 302 | #define AIM_FRAMETYPE_OFT 0x0001 |
---|
[5e53c4a] | 303 | |
---|
| 304 | typedef 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 | */ |
---|
| 334 | typedef struct aim_bstream_s { |
---|
| 335 | fu8_t *data; |
---|
[862371b] | 336 | fu32_t len; |
---|
| 337 | fu32_t offset; |
---|
[5e53c4a] | 338 | } aim_bstream_t; |
---|
| 339 | |
---|
| 340 | typedef 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 { |
---|
[e374dee] | 348 | fu8_t magic[4]; /* ODC2 or OFT2 */ |
---|
[862371b] | 349 | fu16_t hdrlen; |
---|
| 350 | fu16_t type; |
---|
| 351 | } rend; |
---|
[5e53c4a] | 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 */ |
---|
[e374dee] | 356 | aim_conn_t *conn; /* the connection it came in on... */ |
---|
[5e53c4a] | 357 | struct aim_frame_s *next; |
---|
| 358 | } aim_frame_t; |
---|
| 359 | |
---|
| 360 | typedef struct aim_msgcookie_s { |
---|
[e374dee] | 361 | fu8_t cookie[8]; |
---|
[5e53c4a] | 362 | int type; |
---|
| 363 | void *data; |
---|
| 364 | time_t addtime; |
---|
| 365 | struct aim_msgcookie_s *next; |
---|
| 366 | } aim_msgcookie_t; |
---|
| 367 | |
---|
[e374dee] | 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 | |
---|
[5e53c4a] | 374 | /* |
---|
| 375 | * AIM Session: The main client-data interface. |
---|
| 376 | * |
---|
| 377 | */ |
---|
| 378 | typedef 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 | |
---|
[e374dee] | 421 | void *modlistv; |
---|
[5e53c4a] | 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 | |
---|
[e374dee] | 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 | |
---|
[5e53c4a] | 442 | aim_msgcookie_t *msgcookies; |
---|
[e374dee] | 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; |
---|
[5e53c4a] | 447 | |
---|
[e374dee] | 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; |
---|
[5e53c4a] | 458 | } aim_session_t; |
---|
| 459 | |
---|
| 460 | /* Valid for calling aim_icq_setstatus() and for aim_userinfo_t->icqinfo.status */ |
---|
[e374dee] | 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 |
---|
[5e53c4a] | 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 | */ |
---|
| 484 | faim_export int aim_get_command(aim_session_t *, aim_conn_t *); |
---|
| 485 | |
---|
| 486 | /* |
---|
| 487 | * Dispatch commands that are in the rx queue. |
---|
| 488 | */ |
---|
| 489 | faim_export void aim_rxdispatch(aim_session_t *); |
---|
| 490 | |
---|
| 491 | faim_export int aim_debugconn_sendconnect(aim_session_t *sess, aim_conn_t *conn); |
---|
| 492 | |
---|
| 493 | faim_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 */ |
---|
| 497 | faim_export void aim_conn_kill(aim_session_t *sess, aim_conn_t **deadconn); |
---|
| 498 | #endif |
---|
| 499 | |
---|
| 500 | typedef int (*aim_rxcallback_t)(aim_session_t *, aim_frame_t *, ...); |
---|
| 501 | |
---|
[e374dee] | 502 | |
---|
| 503 | /* auth.c */ |
---|
[5e53c4a] | 504 | struct aim_clientrelease { |
---|
| 505 | char *name; |
---|
| 506 | fu32_t build; |
---|
| 507 | char *url; |
---|
| 508 | char *info; |
---|
| 509 | }; |
---|
| 510 | |
---|
| 511 | struct aim_authresp_info { |
---|
| 512 | char *sn; |
---|
| 513 | fu16_t errorcode; |
---|
| 514 | char *errorurl; |
---|
| 515 | fu16_t regstatus; |
---|
| 516 | char *email; |
---|
| 517 | char *bosip; |
---|
[e374dee] | 518 | fu16_t cookielen; |
---|
[5e53c4a] | 519 | fu8_t *cookie; |
---|
[862371b] | 520 | char *chpassurl; |
---|
[5e53c4a] | 521 | struct aim_clientrelease latestrelease; |
---|
| 522 | struct aim_clientrelease latestbeta; |
---|
| 523 | }; |
---|
| 524 | |
---|
| 525 | /* Callback data for redirect. */ |
---|
| 526 | struct aim_redirect_data { |
---|
| 527 | fu16_t group; |
---|
| 528 | const char *ip; |
---|
[e374dee] | 529 | fu16_t cookielen; |
---|
[5e53c4a] | 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 | |
---|
| 538 | faim_export int aim_clientready(aim_session_t *sess, aim_conn_t *conn); |
---|
| 539 | faim_export int aim_sendflapver(aim_session_t *sess, aim_conn_t *conn); |
---|
| 540 | faim_export int aim_request_login(aim_session_t *sess, aim_conn_t *conn, const char *sn); |
---|
| 541 | faim_export int aim_send_login(aim_session_t *, aim_conn_t *, const char *, const char *, struct client_info_s *, const char *key); |
---|
[e374dee] | 542 | faim_export int aim_encode_password_md5(const char *password, const char *key, fu8_t *digest); |
---|
[5e53c4a] | 543 | faim_export void aim_purge_rxqueue(aim_session_t *); |
---|
[e374dee] | 544 | faim_export void aim_cleansnacs(aim_session_t *, int maxage); |
---|
[5e53c4a] | 545 | |
---|
| 546 | #define AIM_TX_QUEUED 0 /* default */ |
---|
| 547 | #define AIM_TX_IMMEDIATE 1 |
---|
| 548 | #define AIM_TX_USER 2 |
---|
| 549 | faim_export int aim_tx_setenqueue(aim_session_t *sess, int what, int (*func)(aim_session_t *, aim_frame_t *)); |
---|
| 550 | |
---|
| 551 | faim_export int aim_tx_flushqueue(aim_session_t *); |
---|
| 552 | faim_export void aim_tx_purgequeue(aim_session_t *); |
---|
| 553 | |
---|
| 554 | faim_export int aim_conn_setlatency(aim_conn_t *conn, int newval); |
---|
| 555 | |
---|
[e374dee] | 556 | faim_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); |
---|
[5e53c4a] | 557 | faim_export int aim_clearhandlers(aim_conn_t *conn); |
---|
| 558 | |
---|
| 559 | faim_export aim_conn_t *aim_conn_findbygroup(aim_session_t *sess, fu16_t group); |
---|
| 560 | faim_export aim_session_t *aim_conn_getsess(aim_conn_t *conn); |
---|
| 561 | faim_export void aim_conn_close(aim_conn_t *deadconn); |
---|
| 562 | faim_export aim_conn_t *aim_newconn(aim_session_t *, int type, const char *dest); |
---|
| 563 | faim_export int aim_conngetmaxfd(aim_session_t *); |
---|
| 564 | faim_export aim_conn_t *aim_select(aim_session_t *, struct timeval *, int *); |
---|
[e374dee] | 565 | faim_export int aim_conn_in_sess(aim_session_t *sess, aim_conn_t *conn); |
---|
[5e53c4a] | 566 | faim_export int aim_conn_isready(aim_conn_t *); |
---|
| 567 | faim_export int aim_conn_setstatus(aim_conn_t *, int); |
---|
| 568 | faim_export int aim_conn_completeconnect(aim_session_t *sess, aim_conn_t *conn); |
---|
| 569 | faim_export int aim_conn_isconnecting(aim_conn_t *conn); |
---|
| 570 | |
---|
| 571 | typedef void (*faim_debugging_callback_t)(aim_session_t *sess, int level, const char *format, va_list va); |
---|
| 572 | faim_export int aim_setdebuggingcb(aim_session_t *sess, faim_debugging_callback_t); |
---|
[e374dee] | 573 | faim_export void aim_session_init(aim_session_t *, fu32_t flags, int debuglevel); |
---|
[5e53c4a] | 574 | faim_export void aim_session_kill(aim_session_t *); |
---|
| 575 | faim_export void aim_setupproxy(aim_session_t *sess, const char *server, const char *username, const char *password); |
---|
| 576 | faim_export aim_conn_t *aim_getconn_type(aim_session_t *, int type); |
---|
| 577 | faim_export aim_conn_t *aim_getconn_type_all(aim_session_t *, int type); |
---|
| 578 | faim_export aim_conn_t *aim_getconn_fd(aim_session_t *, int fd); |
---|
| 579 | |
---|
[e374dee] | 580 | |
---|
| 581 | |
---|
| 582 | /* service.c */ |
---|
| 583 | faim_export int aim_srv_setavailmsg(aim_session_t *sess, char *msg); |
---|
| 584 | |
---|
| 585 | |
---|
| 586 | |
---|
[862371b] | 587 | /* misc.c */ |
---|
[5e53c4a] | 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 | |
---|
| 599 | faim_export int aim_sendpauseack(aim_session_t *sess, aim_conn_t *conn); |
---|
| 600 | faim_export int aim_nop(aim_session_t *, aim_conn_t *); |
---|
| 601 | faim_export int aim_flap_nop(aim_session_t *sess, aim_conn_t *conn); |
---|
| 602 | faim_export int aim_bos_setidle(aim_session_t *, aim_conn_t *, fu32_t); |
---|
| 603 | faim_export int aim_bos_changevisibility(aim_session_t *, aim_conn_t *, int, const char *); |
---|
| 604 | faim_export int aim_bos_setbuddylist(aim_session_t *, aim_conn_t *, const char *); |
---|
[e374dee] | 605 | faim_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); |
---|
[5e53c4a] | 606 | faim_export int aim_bos_setgroupperm(aim_session_t *, aim_conn_t *, fu32_t mask); |
---|
| 607 | faim_export int aim_bos_setprivacyflags(aim_session_t *, aim_conn_t *, fu32_t); |
---|
| 608 | faim_export int aim_reqpersonalinfo(aim_session_t *, aim_conn_t *); |
---|
| 609 | faim_export int aim_reqservice(aim_session_t *, aim_conn_t *, fu16_t); |
---|
| 610 | faim_export int aim_bos_reqrights(aim_session_t *, aim_conn_t *); |
---|
| 611 | faim_export int aim_bos_reqbuddyrights(aim_session_t *, aim_conn_t *); |
---|
| 612 | faim_export int aim_bos_reqlocaterights(aim_session_t *, aim_conn_t *); |
---|
| 613 | 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); |
---|
| 614 | 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); |
---|
[e374dee] | 615 | faim_export int aim_setextstatus(aim_session_t *sess, fu32_t status); |
---|
[5e53c4a] | 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 |
---|
[e374dee] | 622 | faim_export fu16_t aim_im_fingerprint(const fu8_t *msghdr, int len); |
---|
[5e53c4a] | 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 |
---|
| 628 | faim_export int aim_ads_requestads(aim_session_t *sess, aim_conn_t *conn); |
---|
| 629 | |
---|
[e374dee] | 630 | |
---|
| 631 | |
---|
[862371b] | 632 | /* im.c */ |
---|
[e374dee] | 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 |
---|
[5e53c4a] | 637 | |
---|
[e374dee] | 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 |
---|
[5e53c4a] | 644 | |
---|
[e374dee] | 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 | |
---|
| 663 | struct 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 | }; |
---|
[5e53c4a] | 671 | |
---|
| 672 | struct aim_chat_roominfo { |
---|
[e374dee] | 673 | fu16_t exchange; |
---|
[5e53c4a] | 674 | char *name; |
---|
[e374dee] | 675 | fu16_t instance; |
---|
[5e53c4a] | 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 |
---|
[e374dee] | 687 | #define AIM_IMFLAGS_X 0x0200 |
---|
[5e53c4a] | 688 | #define AIM_IMFLAGS_MULTIPART 0x0400 /* ->mpmsg section valid */ |
---|
| 689 | #define AIM_IMFLAGS_OFFLINE 0x0800 /* send to offline user */ |
---|
[862371b] | 690 | #define AIM_IMFLAGS_TYPINGNOT 0x1000 /* typing notification */ |
---|
[5e53c4a] | 691 | |
---|
| 692 | /* |
---|
| 693 | * Multipart message structures. |
---|
| 694 | */ |
---|
| 695 | typedef 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 | |
---|
| 703 | typedef struct aim_mpmsg_s { |
---|
| 704 | int numparts; |
---|
| 705 | aim_mpmsg_section_t *parts; |
---|
| 706 | } aim_mpmsg_t; |
---|
| 707 | |
---|
| 708 | faim_export int aim_mpmsg_init(aim_session_t *sess, aim_mpmsg_t *mpm); |
---|
| 709 | 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); |
---|
| 710 | faim_export int aim_mpmsg_addascii(aim_session_t *sess, aim_mpmsg_t *mpm, const char *ascii); |
---|
| 711 | faim_export int aim_mpmsg_addunicode(aim_session_t *sess, aim_mpmsg_t *mpm, const fu16_t *unicode, fu16_t unicodelen); |
---|
| 712 | faim_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 | */ |
---|
| 720 | struct 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 | */ |
---|
| 750 | struct 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 | */ |
---|
| 770 | struct 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 */ |
---|
[e374dee] | 799 | #define AIM_RENDEZVOUS_PROPOSE 0x0000 |
---|
| 800 | #define AIM_RENDEZVOUS_CANCEL 0x0001 |
---|
| 801 | #define AIM_RENDEZVOUS_ACCEPT 0x0002 |
---|
[5e53c4a] | 802 | |
---|
| 803 | struct aim_incomingim_ch2_args { |
---|
| 804 | fu16_t status; |
---|
[e374dee] | 805 | fu8_t cookie[8]; |
---|
| 806 | int reqclass; |
---|
| 807 | const char *proxyip; |
---|
[5e53c4a] | 808 | const char *clientip; |
---|
| 809 | const char *verifiedip; |
---|
| 810 | fu16_t port; |
---|
[e374dee] | 811 | fu16_t errorcode; |
---|
[5e53c4a] | 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; |
---|
[862371b] | 830 | struct { |
---|
| 831 | fu16_t subtype; |
---|
| 832 | fu16_t totfiles; |
---|
| 833 | fu32_t totsize; |
---|
| 834 | char *filename; |
---|
| 835 | } sendfile; |
---|
[5e53c4a] | 836 | } info; |
---|
| 837 | void *destructor; /* used internally only */ |
---|
| 838 | }; |
---|
| 839 | |
---|
[862371b] | 840 | /* Valid values for channel 4 args->type */ |
---|
[e374dee] | 841 | #define AIM_ICQMSG_AUTHREQUEST 0x0006 |
---|
| 842 | #define AIM_ICQMSG_AUTHDENIED 0x0007 |
---|
| 843 | #define AIM_ICQMSG_AUTHGRANTED 0x0008 |
---|
[862371b] | 844 | |
---|
| 845 | struct aim_incomingim_ch4_args { |
---|
| 846 | fu32_t uin; /* Of the sender of the ICBM */ |
---|
[e374dee] | 847 | fu8_t type; |
---|
| 848 | fu8_t flags; |
---|
[862371b] | 849 | char *msg; /* Reason for auth request, deny, or accept */ |
---|
[e374dee] | 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 */ |
---|
| 873 | struct 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 | |
---|
| 908 | struct 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; |
---|
[862371b] | 919 | }; |
---|
| 920 | |
---|
[e374dee] | 921 | faim_export fu32_t aim_oft_checksum_chunk(const fu8_t *buffer, int bufferlen, fu32_t prevcheck); |
---|
| 922 | faim_export fu32_t aim_oft_checksum_file(char *filename); |
---|
| 923 | faim_export int aim_handlerendconnect(aim_session_t *sess, aim_conn_t *cur); |
---|
| 924 | faim_export int aim_odc_send_typing(aim_session_t *sess, aim_conn_t *conn, int typing); |
---|
| 925 | faim_export int aim_odc_send_im(aim_session_t *sess, aim_conn_t *conn, const char *msg, int len, int encoding, int isawaymsg); |
---|
| 926 | faim_export const char *aim_odc_getsn(aim_conn_t *conn); |
---|
| 927 | faim_export aim_conn_t *aim_odc_getconn(aim_session_t *sess, const char *sn); |
---|
| 928 | faim_export aim_conn_t *aim_odc_initiate(aim_session_t *sess, const char *sn); |
---|
| 929 | faim_export aim_conn_t *aim_odc_connect(aim_session_t *sess, const char *sn, const char *addr, const fu8_t *cookie); |
---|
| 930 | |
---|
| 931 | faim_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); |
---|
| 932 | faim_export int aim_oft_destroyinfo(struct aim_oft_info *oft_info); |
---|
| 933 | faim_export int aim_sendfile_listen(aim_session_t *sess, struct aim_oft_info *oft_info); |
---|
| 934 | faim_export int aim_oft_sendheader(aim_session_t *sess, fu16_t type, struct aim_oft_info *oft_info); |
---|
| 935 | |
---|
| 936 | |
---|
[5e53c4a] | 937 | |
---|
[862371b] | 938 | /* info.c */ |
---|
[e374dee] | 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 | |
---|
| 968 | typedef 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 | |
---|
| 991 | faim_export const char *aim_userinfo_sn(aim_userinfo_t *ui); |
---|
| 992 | faim_export fu16_t aim_userinfo_flags(aim_userinfo_t *ui); |
---|
| 993 | faim_export fu16_t aim_userinfo_idle(aim_userinfo_t *ui); |
---|
| 994 | faim_export float aim_userinfo_warnlevel(aim_userinfo_t *ui); |
---|
| 995 | faim_export time_t aim_userinfo_createtime(aim_userinfo_t *ui); |
---|
| 996 | faim_export time_t aim_userinfo_membersince(aim_userinfo_t *ui); |
---|
| 997 | faim_export time_t aim_userinfo_onlinesince(aim_userinfo_t *ui); |
---|
| 998 | faim_export fu32_t aim_userinfo_sessionlen(aim_userinfo_t *ui); |
---|
| 999 | faim_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 |
---|
[5e53c4a] | 1013 | #define AIM_CAPS_ICQRTF 0x00001000 |
---|
| 1014 | #define AIM_CAPS_EMPTY 0x00002000 |
---|
[e374dee] | 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 |
---|
[5e53c4a] | 1024 | |
---|
| 1025 | faim_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 | |
---|
[e374dee] | 1030 | faim_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); |
---|
[5e53c4a] | 1031 | |
---|
| 1032 | #define AIM_GETINFO_GENERALINFO 0x00001 |
---|
| 1033 | #define AIM_GETINFO_AWAYMESSAGE 0x00003 |
---|
| 1034 | #define AIM_GETINFO_CAPABILITIES 0x0004 |
---|
| 1035 | |
---|
| 1036 | struct 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 | |
---|
[e374dee] | 1060 | /* 0x0005 */ faim_export int aim_getinfo(aim_session_t *, aim_conn_t *, const char *, fu16_t); |
---|
[5e53c4a] | 1061 | |
---|
| 1062 | |
---|
| 1063 | |
---|
[e374dee] | 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); |
---|
[5e53c4a] | 1069 | |
---|
| 1070 | |
---|
| 1071 | |
---|
[e374dee] | 1072 | /* 0x000a - search.c */ |
---|
| 1073 | faim_export int aim_search_address(aim_session_t *, aim_conn_t *, const char *); |
---|
[5e53c4a] | 1074 | |
---|
[862371b] | 1075 | |
---|
| 1076 | |
---|
[e374dee] | 1077 | /* 0x000d - chatnav.c */ |
---|
| 1078 | /* 0x000e - chat.c */ |
---|
[5e53c4a] | 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 | |
---|
| 1085 | struct 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 |
---|
| 1097 | faim_export int aim_chat_send_im(aim_session_t *sess, aim_conn_t *conn, fu16_t flags, const char *msg, int msglen); |
---|
| 1098 | faim_export int aim_chat_join(aim_session_t *sess, aim_conn_t *conn, fu16_t exchange, const char *roomname, fu16_t instance); |
---|
| 1099 | faim_export int aim_chat_attachname(aim_conn_t *conn, fu16_t exchange, const char *roomname, fu16_t instance); |
---|
| 1100 | faim_export char *aim_chat_getname(aim_conn_t *conn); |
---|
| 1101 | faim_export aim_conn_t *aim_chat_getconn(aim_session_t *, const char *name); |
---|
| 1102 | |
---|
| 1103 | faim_export int aim_chatnav_reqrights(aim_session_t *sess, aim_conn_t *conn); |
---|
| 1104 | |
---|
| 1105 | 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); |
---|
| 1106 | |
---|
| 1107 | faim_export int aim_chatnav_createroom(aim_session_t *sess, aim_conn_t *conn, const char *name, fu16_t exchange); |
---|
| 1108 | faim_export int aim_chat_leaveroom(aim_session_t *sess, const char *name); |
---|
| 1109 | |
---|
| 1110 | |
---|
[e374dee] | 1111 | |
---|
| 1112 | /* 0x000f - odir.c */ |
---|
| 1113 | struct 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 | |
---|
| 1131 | faim_export int aim_odir_email(aim_session_t *, const char *, const char *); |
---|
| 1132 | faim_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 *); |
---|
| 1133 | faim_export int aim_odir_interest(aim_session_t *, const char *, const char *); |
---|
| 1134 | |
---|
| 1135 | |
---|
| 1136 | |
---|
| 1137 | /* 0x0010 - icon.c */ |
---|
| 1138 | faim_export int aim_bart_upload(aim_session_t *sess, const fu8_t *icon, fu16_t iconlen); |
---|
| 1139 | faim_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 |
---|
[5e53c4a] | 1158 | |
---|
| 1159 | struct aim_ssi_item { |
---|
| 1160 | char *name; |
---|
| 1161 | fu16_t gid; |
---|
| 1162 | fu16_t bid; |
---|
| 1163 | fu16_t type; |
---|
[e374dee] | 1164 | struct aim_tlvlist_s *data; |
---|
[5e53c4a] | 1165 | struct aim_ssi_item *next; |
---|
| 1166 | }; |
---|
| 1167 | |
---|
[e374dee] | 1168 | struct 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 | |
---|
[862371b] | 1176 | /* These build the actual SNACs and queue them to be sent */ |
---|
[e374dee] | 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 */ |
---|
[862371b] | 1189 | faim_export struct aim_ssi_item *aim_ssi_itemlist_find(struct aim_ssi_item *list, fu16_t gid, fu16_t bid); |
---|
| 1190 | faim_export struct aim_ssi_item *aim_ssi_itemlist_finditem(struct aim_ssi_item *list, const char *gn, const char *sn, fu16_t type); |
---|
[e374dee] | 1191 | faim_export struct aim_ssi_item *aim_ssi_itemlist_exists(struct aim_ssi_item *list, const char *sn); |
---|
| 1192 | faim_export char *aim_ssi_itemlist_findparentname(struct aim_ssi_item *list, const char *sn); |
---|
[862371b] | 1193 | faim_export int aim_ssi_getpermdeny(struct aim_ssi_item *list); |
---|
| 1194 | faim_export fu32_t aim_ssi_getpresence(struct aim_ssi_item *list); |
---|
[e374dee] | 1195 | faim_export char *aim_ssi_getalias(struct aim_ssi_item *list, const char *gn, const char *sn); |
---|
| 1196 | faim_export int aim_ssi_waitingforauth(struct aim_ssi_item *list, const char *gn, const char *sn); |
---|
| 1197 | |
---|
| 1198 | /* Client functions for changing SSI data */ |
---|
| 1199 | faim_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); |
---|
| 1200 | faim_export int aim_ssi_addpermit(aim_session_t *sess, const char *name); |
---|
| 1201 | faim_export int aim_ssi_adddeny(aim_session_t *sess, const char *name); |
---|
| 1202 | faim_export int aim_ssi_delbuddy(aim_session_t *sess, const char *name, const char *group); |
---|
| 1203 | faim_export int aim_ssi_delpermit(aim_session_t *sess, const char *name); |
---|
| 1204 | faim_export int aim_ssi_deldeny(aim_session_t *sess, const char *name); |
---|
| 1205 | faim_export int aim_ssi_movebuddy(aim_session_t *sess, const char *oldgn, const char *newgn, const char *sn); |
---|
| 1206 | faim_export int aim_ssi_aliasbuddy(aim_session_t *sess, const char *gn, const char *sn, const char *alias); |
---|
| 1207 | faim_export int aim_ssi_rename_group(aim_session_t *sess, const char *oldgn, const char *newgn); |
---|
| 1208 | faim_export int aim_ssi_cleanlist(aim_session_t *sess); |
---|
| 1209 | faim_export int aim_ssi_deletelist(aim_session_t *sess); |
---|
| 1210 | faim_export int aim_ssi_setpermdeny(aim_session_t *sess, fu8_t permdeny, fu32_t vismask); |
---|
| 1211 | faim_export int aim_ssi_setpresence(aim_session_t *sess, fu32_t presence); |
---|
| 1212 | faim_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 |
---|
[862371b] | 1227 | |
---|
[5e53c4a] | 1228 | struct aim_icq_offlinemsg { |
---|
| 1229 | fu32_t sender; |
---|
| 1230 | fu16_t year; |
---|
| 1231 | fu8_t month, day, hour, minute; |
---|
[e374dee] | 1232 | fu8_t type; |
---|
| 1233 | fu8_t flags; |
---|
[5e53c4a] | 1234 | char *msg; |
---|
[e374dee] | 1235 | int msglen; |
---|
[5e53c4a] | 1236 | }; |
---|
| 1237 | |
---|
[e374dee] | 1238 | struct aim_icq_info { |
---|
| 1239 | fu16_t reqid; |
---|
| 1240 | |
---|
| 1241 | /* simple */ |
---|
[5e53c4a] | 1242 | fu32_t uin; |
---|
[e374dee] | 1243 | |
---|
| 1244 | /* general and "home" information (0x00c8) */ |
---|
[5e53c4a] | 1245 | char *nick; |
---|
| 1246 | char *first; |
---|
| 1247 | char *last; |
---|
| 1248 | char *email; |
---|
[e374dee] | 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; |
---|
[5e53c4a] | 1294 | }; |
---|
| 1295 | |
---|
| 1296 | faim_export int aim_icq_reqofflinemsgs(aim_session_t *sess); |
---|
| 1297 | faim_export int aim_icq_ackofflinemsgs(aim_session_t *sess); |
---|
[e374dee] | 1298 | faim_export int aim_icq_hideip(aim_session_t *sess); |
---|
| 1299 | faim_export int aim_icq_changepasswd(aim_session_t *sess, const char *passwd); |
---|
[5e53c4a] | 1300 | faim_export int aim_icq_getsimpleinfo(aim_session_t *sess, const char *uin); |
---|
[e374dee] | 1301 | faim_export int aim_icq_getalias(aim_session_t *sess, const char *uin); |
---|
| 1302 | faim_export int aim_icq_getallinfo(aim_session_t *sess, const char *uin); |
---|
| 1303 | |
---|
| 1304 | |
---|
| 1305 | |
---|
| 1306 | /* 0x0017 - auth.c */ |
---|
| 1307 | faim_export int aim_sendcookie(aim_session_t *, aim_conn_t *, const fu16_t length, const fu8_t *); |
---|
| 1308 | faim_export int aim_admin_changepasswd(aim_session_t *, aim_conn_t *, const char *newpw, const char *curpw); |
---|
| 1309 | faim_export int aim_admin_reqconfirm(aim_session_t *sess, aim_conn_t *conn); |
---|
| 1310 | faim_export int aim_admin_getinfo(aim_session_t *sess, aim_conn_t *conn, fu16_t info); |
---|
| 1311 | faim_export int aim_admin_setemail(aim_session_t *sess, aim_conn_t *conn, const char *newemail); |
---|
| 1312 | faim_export int aim_admin_setnick(aim_session_t *sess, aim_conn_t *conn, const char *newnick); |
---|
[5e53c4a] | 1313 | |
---|
[e374dee] | 1314 | |
---|
| 1315 | |
---|
| 1316 | /* 0x0018 - email.c */ |
---|
[862371b] | 1317 | struct 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 | |
---|
| 1328 | faim_export int aim_email_sendcookies(aim_session_t *sess, aim_conn_t *conn); |
---|
| 1329 | faim_export int aim_email_activate(aim_session_t *sess, aim_conn_t *conn); |
---|
| 1330 | |
---|
[e374dee] | 1331 | |
---|
| 1332 | |
---|
| 1333 | /* tlv.c - TLV handling */ |
---|
| 1334 | #if defined(FAIM_INTERNAL) || defined(FAIM_NEED_TLV) |
---|
| 1335 | /* Generic TLV structure. */ |
---|
| 1336 | typedef 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. */ |
---|
| 1343 | typedef 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. */ |
---|
| 1352 | faim_internal int aim_puttlv_8(fu8_t *buf, const fu16_t t, const fu8_t v); |
---|
| 1353 | faim_internal int aim_puttlv_16(fu8_t *buf, const fu16_t t, const fu16_t v); |
---|
| 1354 | faim_internal int aim_puttlv_32(fu8_t *buf, const fu16_t t, const fu32_t v); |
---|
| 1355 | faim_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. */ |
---|
| 1359 | faim_internal aim_tlvlist_t *aim_readtlvchain(aim_bstream_t *bs); |
---|
| 1360 | faim_internal aim_tlvlist_t *aim_readtlvchain_num(aim_bstream_t *bs, fu16_t num); |
---|
| 1361 | faim_internal aim_tlvlist_t *aim_readtlvchain_len(aim_bstream_t *bs, fu16_t len); |
---|
| 1362 | faim_internal aim_tlvlist_t *aim_tlvlist_copy(aim_tlvlist_t *orig); |
---|
| 1363 | faim_internal int aim_tlvlist_cmp(aim_tlvlist_t *one, aim_tlvlist_t *two); |
---|
| 1364 | faim_internal void aim_freetlvchain(aim_tlvlist_t **list); |
---|
| 1365 | faim_internal aim_tlv_t *aim_gettlv(aim_tlvlist_t *, fu16_t t, const int n); |
---|
| 1366 | faim_internal char *aim_gettlv_str(aim_tlvlist_t *, const fu16_t t, const int n); |
---|
| 1367 | faim_internal fu8_t aim_gettlv8(aim_tlvlist_t *list, const fu16_t type, const int num); |
---|
| 1368 | faim_internal fu16_t aim_gettlv16(aim_tlvlist_t *list, const fu16_t t, const int n); |
---|
| 1369 | faim_internal fu32_t aim_gettlv32(aim_tlvlist_t *list, const fu16_t t, const int n); |
---|
| 1370 | faim_internal int aim_writetlvchain(aim_bstream_t *bs, aim_tlvlist_t **list); |
---|
| 1371 | faim_internal int aim_addtlvtochain8(aim_tlvlist_t **list, const fu16_t t, const fu8_t v); |
---|
| 1372 | faim_internal int aim_addtlvtochain16(aim_tlvlist_t **list, const fu16_t t, const fu16_t v); |
---|
| 1373 | faim_internal int aim_addtlvtochain32(aim_tlvlist_t **list, const fu16_t type, const fu32_t v); |
---|
| 1374 | faim_internal int aim_addtlvtochain_raw(aim_tlvlist_t **list, const fu16_t t, const fu16_t l, const fu8_t *v); |
---|
| 1375 | faim_internal int aim_addtlvtochain_caps(aim_tlvlist_t **list, const fu16_t t, const fu32_t caps); |
---|
| 1376 | faim_internal int aim_addtlvtochain_noval(aim_tlvlist_t **list, const fu16_t type); |
---|
| 1377 | faim_internal int aim_addtlvtochain_userinfo(aim_tlvlist_t **list, fu16_t type, aim_userinfo_t *ui); |
---|
| 1378 | faim_internal int aim_addtlvtochain_frozentlvlist(aim_tlvlist_t **list, fu16_t type, aim_tlvlist_t **tl); |
---|
| 1379 | faim_internal int aim_counttlvchain(aim_tlvlist_t **list); |
---|
| 1380 | faim_internal int aim_sizetlvchain(aim_tlvlist_t **list); |
---|
| 1381 | #endif /* FAIM_INTERNAL */ |
---|
| 1382 | |
---|
| 1383 | |
---|
| 1384 | |
---|
[862371b] | 1385 | /* util.c */ |
---|
[5e53c4a] | 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 | */ |
---|
[e374dee] | 1393 | #define aimutil_put8(buf, data) ((*(buf) = (fu8_t)(data)&0xff),1) |
---|
[5e53c4a] | 1394 | #define aimutil_get8(buf) ((*(buf))&0xff) |
---|
| 1395 | #define aimutil_put16(buf, data) ( \ |
---|
[e374dee] | 1396 | (*(buf) = (fu8_t)((data)>>8)&0xff), \ |
---|
| 1397 | (*((buf)+1) = (fu8_t)(data)&0xff), \ |
---|
[5e53c4a] | 1398 | 2) |
---|
| 1399 | #define aimutil_get16(buf) ((((*(buf))<<8)&0xff00) + ((*((buf)+1)) & 0xff)) |
---|
| 1400 | #define aimutil_put32(buf, data) ( \ |
---|
[e374dee] | 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), \ |
---|
[5e53c4a] | 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) ( \ |
---|
[e374dee] | 1413 | (*(buf) = (fu8_t)(data) & 0xff), \ |
---|
[5e53c4a] | 1414 | 1) |
---|
| 1415 | #define aimutil_getle8(buf) ( \ |
---|
| 1416 | (*(buf)) & 0xff \ |
---|
| 1417 | ) |
---|
| 1418 | #define aimutil_putle16(buf, data) ( \ |
---|
[e374dee] | 1419 | (*((buf)+0) = (fu8_t)((data) >> 0) & 0xff), \ |
---|
| 1420 | (*((buf)+1) = (fu8_t)((data) >> 8) & 0xff), \ |
---|
[5e53c4a] | 1421 | 2) |
---|
| 1422 | #define aimutil_getle16(buf) ( \ |
---|
| 1423 | (((*((buf)+0)) << 0) & 0x00ff) + \ |
---|
| 1424 | (((*((buf)+1)) << 8) & 0xff00) \ |
---|
| 1425 | ) |
---|
| 1426 | #define aimutil_putle32(buf, data) ( \ |
---|
[e374dee] | 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), \ |
---|
[5e53c4a] | 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 | |
---|
[e374dee] | 1439 | faim_export int aimutil_putstr(char *, const char *, int); |
---|
| 1440 | faim_export fu16_t aimutil_iconsum(const fu8_t *buf, int buflen); |
---|
| 1441 | faim_export int aim_util_getlocalip(fu8_t *ip); |
---|
| 1442 | faim_export int aimutil_tokslen(char *toSearch, int theindex, char dl); |
---|
[5e53c4a] | 1443 | faim_export int aimutil_itemcnt(char *toSearch, char dl); |
---|
[e374dee] | 1444 | faim_export char *aimutil_itemindex(char *toSearch, int theindex, char dl); |
---|
[5e53c4a] | 1445 | |
---|
| 1446 | faim_export int aim_snlen(const char *sn); |
---|
| 1447 | faim_export int aim_sncmp(const char *sn1, const char *sn2); |
---|
| 1448 | |
---|
| 1449 | #include <aim_internal.h> |
---|
| 1450 | |
---|
[e374dee] | 1451 | #ifdef __cplusplus |
---|
| 1452 | } |
---|
| 1453 | #endif |
---|
[5e53c4a] | 1454 | |
---|
[e374dee] | 1455 | #endif /* __AIM_H__ */ |
---|