annotate src/protocols/oscar/im.c @ 4965:6e7082cf0892

[gaim-migrate @ 5299] April fools. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Thu, 03 Apr 2003 02:32:17 +0000
parents ad589b887af9
children ac9ca88d4b25
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /*
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
2 * Family 0x0004 - Routines for sending/receiving Instant Messages.
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 *
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
4 * Note the term ICBM (Inter-Client Basic Message) which blankets
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
5 * all types of genericly routed through-server messages. Within
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
6 * the ICBM types (family 4), a channel is defined. Each channel
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
7 * represents a different type of message. Channel 1 is used for
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
8 * what would commonly be called an "instant message". Channel 2
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
9 * is used for negotiating "rendezvous". These transactions end in
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
10 * something more complex happening, such as a chat invitation, or
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
11 * a file transfer. Channel 3 is used for chat messages (not in
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
12 * the same family as these channels). Channel 4 is used for
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
13 * various ICQ messages. Examples are normal messages, URLs, and
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
14 * old-style authorization.
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
15 *
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
16 * In addition to the channel, every ICBM contains a cookie. For
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
17 * standard IMs, these are only used for error messages. However,
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
18 * the more complex rendezvous messages make suitably more complex
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
19 * use of this field.
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
20 *
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
21 * TODO: Split this up into an im.c file an an icbm.c file. It
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
22 * will be beautiful, you'll see.
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
23 *
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
24 * Need to rename all the mpmsg messages to aim_im_bleh.
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
25 *
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
26 * Make sure aim_conn_findbygroup is used by all functions.
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 #define FAIM_INTERNAL
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 #include <aim.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3595
diff changeset
32 #ifdef _WIN32
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3595
diff changeset
33 #include "win32dep.h"
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3595
diff changeset
34 #endif
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3595
diff changeset
35
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
36 /**
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
37 * Add a standard ICBM header to the given bstream with the given
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
38 * information.
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
39 *
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
40 * @param bs The bstream to write the ICBM header to.
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
41 * @param c c is for cookie, and cookie is for me.
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
42 * @param ch The ICBM channel (1 through 4).
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
43 * @param sn Null-terminated scrizeen nizame.
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
44 * @return The number of bytes written. It's really not useful.
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
45 */
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
46 static int aim_im_puticbm(aim_bstream_t *bs, const fu8_t *c, fu16_t ch, const char *sn)
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
47 {
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
48 aimbs_putraw(bs, c, 8);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
49 aimbs_put16(bs, ch);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
50 aimbs_put8(bs, strlen(sn));
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
51 aimbs_putraw(bs, sn, strlen(sn));
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
52 return 8+2+1+strlen(sn);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
53 }
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
54
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55 /*
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56 * Takes a msghdr (and a length) and returns a client type
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 * code. Note that this is *only a guess* and has a low likelihood
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58 * of actually being accurate.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60 * Its based on experimental data, with the help of Eric Warmenhoven
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61 * who seems to have collected a wide variety of different AIM clients.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64 * Heres the current collection:
4102
c5ce82228a2f [gaim-migrate @ 4317]
Mark Doliner <mark@kingant.net>
parents: 4076
diff changeset
65 * 0501 0003 0101 0101 01 AOL Mobile Communicator, WinAIM 1.0.414
c5ce82228a2f [gaim-migrate @ 4317]
Mark Doliner <mark@kingant.net>
parents: 4076
diff changeset
66 * 0501 0003 0101 0201 01 WinAIM 2.0.847, 2.1.1187, 3.0.1464,
c5ce82228a2f [gaim-migrate @ 4317]
Mark Doliner <mark@kingant.net>
parents: 4076
diff changeset
67 * 4.3.2229, 4.4.2286
c5ce82228a2f [gaim-migrate @ 4317]
Mark Doliner <mark@kingant.net>
parents: 4076
diff changeset
68 * 0501 0004 0101 0102 0101 WinAIM 4.1.2010, libfaim (right here)
c5ce82228a2f [gaim-migrate @ 4317]
Mark Doliner <mark@kingant.net>
parents: 4076
diff changeset
69 * 0501 0003 0101 02 WinAIM 5
c5ce82228a2f [gaim-migrate @ 4317]
Mark Doliner <mark@kingant.net>
parents: 4076
diff changeset
70 * 0501 0001 01 iChat x.x
c5ce82228a2f [gaim-migrate @ 4317]
Mark Doliner <mark@kingant.net>
parents: 4076
diff changeset
71 * 0501 0001 0101 01 AOL v6.0, CompuServe 2000 v6.0, any
c5ce82228a2f [gaim-migrate @ 4317]
Mark Doliner <mark@kingant.net>
parents: 4076
diff changeset
72 * TOC client
c5ce82228a2f [gaim-migrate @ 4317]
Mark Doliner <mark@kingant.net>
parents: 4076
diff changeset
73 * 0501 0002 0106 WinICQ 5.45.1.3777.85
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
74 *
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
75 * Note that in this function, only the feature bytes are tested, since
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
76 * the rest will always be the same.
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
77 *
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
78 */
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
79 faim_export fu16_t aim_im_fingerprint(fu8_t *msghdr, int len)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
80 {
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
81 static const struct {
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
82 fu16_t clientid;
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
83 int len;
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
84 fu8_t data[10];
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
85 } fingerprints[] = {
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
86 /* AOL Mobile Communicator, WinAIM 1.0.414 */
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
87 { AIM_CLIENTTYPE_MC,
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
88 3, {0x01, 0x01, 0x01}},
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
89
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
90 /* WinAIM 2.0.847, 2.1.1187, 3.0.1464, 4.3.2229, 4.4.2286 */
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
91 { AIM_CLIENTTYPE_WINAIM,
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
92 3, {0x01, 0x01, 0x02}},
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
93
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
94 /* WinAIM 4.1.2010, libfaim */
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
95 { AIM_CLIENTTYPE_WINAIM41,
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
96 4, {0x01, 0x01, 0x01, 0x02}},
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
97
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
98 /* AOL v6.0, CompuServe 2000 v6.0, any TOC client */
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
99 { AIM_CLIENTTYPE_AOL_TOC,
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
100 1, {0x01}},
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
101
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
102 { 0, 0}
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
103 };
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
104 int i;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
105
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
106 if (!msghdr || (len <= 0))
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
107 return AIM_CLIENTTYPE_UNKNOWN;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
108
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
109 for (i = 0; fingerprints[i].len; i++) {
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
110 if (fingerprints[i].len != len)
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
111 continue;
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
112 if (memcmp(fingerprints[i].data, msghdr, fingerprints[i].len) == 0)
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
113 return fingerprints[i].clientid;
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
114 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
115
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
116 return AIM_CLIENTTYPE_UNKNOWN;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
117 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
118
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
119 /**
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
120 * Subtype 0x0002 - Set ICBM parameters.
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
121 *
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
122 * I definitly recommend sending this. If you don't, you'll be stuck
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
123 * with the rather unreasonable defaults.
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
124 *
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
125 */
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
126 faim_export int aim_im_setparams(aim_session_t *sess, struct aim_icbmparameters *params)
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
127 {
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
128 aim_conn_t *conn;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
129 aim_frame_t *fr;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
130 aim_snacid_t snacid;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
131
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
132 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004)))
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
133 return -EINVAL;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
134
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
135 if (!params)
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
136 return -EINVAL;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
137
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
138 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+16)))
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
139 return -ENOMEM;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
140
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
141 snacid = aim_cachesnac(sess, 0x0004, 0x0002, 0x0000, NULL, 0);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
142 aim_putsnac(&fr->data, 0x0004, 0x0002, 0x0000, snacid);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
143
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
144 /* This is read-only (see Parameter Reply). Must be set to zero here. */
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
145 aimbs_put16(&fr->data, 0x0000);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
146
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
147 /* These are all read-write */
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
148 aimbs_put32(&fr->data, params->flags);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
149 aimbs_put16(&fr->data, params->maxmsglen);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
150 aimbs_put16(&fr->data, params->maxsenderwarn);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
151 aimbs_put16(&fr->data, params->maxrecverwarn);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
152 aimbs_put32(&fr->data, params->minmsginterval);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
153
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
154 aim_tx_enqueue(sess, fr);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
155
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
156 return 0;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
157 }
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
158
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
159 /**
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
160 * Subtype 0x0004 - Request ICBM parameter information.
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
161 *
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
162 */
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
163 faim_export int aim_im_reqparams(aim_session_t *sess)
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
164 {
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
165 aim_conn_t *conn;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
166
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
167 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004)))
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
168 return -EINVAL;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
169
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
170 return aim_genericreq_n(sess, conn, 0x0004, 0x0004);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
171 }
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
172
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
173 /**
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
174 * Subtype 0x0005 - Receive parameter information.
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
175 *
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
176 */
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
177 static int aim_im_paraminfo(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
178 {
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
179 aim_rxcallback_t userfunc;
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
180 struct aim_icbmparameters params;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
181
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
182 params.maxchan = aimbs_get16(bs);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
183 params.flags = aimbs_get32(bs);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
184 params.maxmsglen = aimbs_get16(bs);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
185 params.maxsenderwarn = aimbs_get16(bs);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
186 params.maxrecverwarn = aimbs_get16(bs);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
187 params.minmsginterval = aimbs_get32(bs);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
188
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
189 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
190 return userfunc(sess, rx, &params);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
191
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
192 return 0;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
193 }
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
194
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
195 /**
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
196 * Subtype 0x0006 - Send an ICBM (instant message).
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
197 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
198 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
199 * Possible flags:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
200 * AIM_IMFLAGS_AWAY -- Marks the message as an autoresponse
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
201 * AIM_IMFLAGS_ACK -- Requests that the server send an ack
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
202 * when the message is received (of type 0x0004/0x000c)
2703
441b84ab7f4e [gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2673
diff changeset
203 * AIM_IMFLAGS_OFFLINE--If destination is offline, store it until they are
441b84ab7f4e [gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2673
diff changeset
204 * online (probably ICQ only).
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
205 * AIM_IMFLAGS_UNICODE--Instead of ASCII7, the passed message is
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
206 * made up of UNICODE duples. If you set
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
207 * this, you'd better be damn sure you know
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
208 * what you're doing.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
209 * AIM_IMFLAGS_ISO_8859_1 -- The message contains the ASCII8 subset
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
210 * known as ISO-8859-1.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
211 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
212 * Generally, you should use the lowest encoding possible to send
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
213 * your message. If you only use basic punctuation and the generic
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
214 * Latin alphabet, use ASCII7 (no flags). If you happen to use non-ASCII7
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
215 * characters, but they are all clearly defined in ISO-8859-1, then
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
216 * use that. Keep in mind that not all characters in the PC ASCII8
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
217 * character set are defined in the ISO standard. For those cases (most
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
218 * notably when the (r) symbol is used), you must use the full UNICODE
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
219 * encoding for your message. In UNICODE mode, _all_ characters must
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
220 * occupy 16bits, including ones that are not special. (Remember that
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
221 * the first 128 UNICODE symbols are equivelent to ASCII7, however they
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
222 * must be prefixed with a zero high order byte.)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
223 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
224 * I strongly discourage the use of UNICODE mode, mainly because none
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
225 * of the clients I use can parse those messages (and besides that,
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
226 * wchars are difficult and non-portable to handle in most UNIX environments).
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
227 * If you really need to include special characters, use the HTML UNICODE
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
228 * entities. These are of the form &#2026; where 2026 is the hex
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
229 * representation of the UNICODE index (in this case, UNICODE
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
230 * "Horizontal Ellipsis", or 133 in in ASCII8).
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
231 *
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
232 * Implementation note: Since this is one of the most-used functions
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
233 * in all of libfaim, it is written with performance in mind. As such,
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
234 * it is not as clear as it could be in respect to how this message is
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
235 * supposed to be layed out. Most obviously, tlvlists should be used
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
236 * instead of writing out the bytes manually.
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
237 *
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
238 * XXX - more precise verification that we never send SNACs larger than 8192
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
239 * XXX - check SNAC size for multipart
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
240 *
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
241 */
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
242 faim_export int aim_im_sendch1_ext(aim_session_t *sess, struct aim_sendimext_args *args)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
243 {
2673
81d658e6ac1e [gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2672
diff changeset
244 aim_conn_t *conn;
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
245 aim_frame_t *fr;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
246 aim_snacid_t snacid;
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
247 fu8_t ck[8];
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
248 int i, msgtlvlen;
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
249 static const fu8_t deffeatures[] = { 0x01, 0x01, 0x01, 0x02 };
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
250
2673
81d658e6ac1e [gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2672
diff changeset
251 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004)))
81d658e6ac1e [gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2672
diff changeset
252 return -EINVAL;
81d658e6ac1e [gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2672
diff changeset
253
81d658e6ac1e [gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2672
diff changeset
254 if (!args)
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
255 return -EINVAL;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
256
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
257 if (args->flags & AIM_IMFLAGS_MULTIPART) {
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
258 if (args->mpmsg->numparts <= 0)
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
259 return -EINVAL;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
260 } else {
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
261 if (!args->msg || (args->msglen <= 0))
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
262 return -EINVAL;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
263
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
264 if (args->msglen >= MAXMSGLEN)
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
265 return -E2BIG;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
266 }
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
267
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
268 /* Painfully calculate the size of the message TLV */
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
269 msgtlvlen = 1 + 1; /* 0501 */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
270
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
271 if (args->flags & AIM_IMFLAGS_CUSTOMFEATURES)
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
272 msgtlvlen += 2 + args->featureslen;
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
273 else
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
274 msgtlvlen += 2 + sizeof(deffeatures);
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
275
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
276 if (args->flags & AIM_IMFLAGS_MULTIPART) {
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
277 aim_mpmsg_section_t *sec;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
278
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
279 for (sec = args->mpmsg->parts; sec; sec = sec->next) {
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
280 msgtlvlen += 2 /* 0101 */ + 2 /* block len */;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
281 msgtlvlen += 4 /* charset */ + sec->datalen;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
282 }
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
283
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
284 } else {
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
285 msgtlvlen += 2 /* 0101 */ + 2 /* block len */;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
286 msgtlvlen += 4 /* charset */ + args->msglen;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
287 }
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
288
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
289 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, msgtlvlen+128)))
2122
c99c781e5931 [gaim-migrate @ 2132]
Adam Fritzler <mid@auk.cx>
parents: 2086
diff changeset
290 return -ENOMEM;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
291
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
292 /* XXX - should be optional */
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
293 snacid = aim_cachesnac(sess, 0x0004, 0x0006, 0x0000, args->destsn, strlen(args->destsn)+1);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
294 aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
295
2122
c99c781e5931 [gaim-migrate @ 2132]
Adam Fritzler <mid@auk.cx>
parents: 2086
diff changeset
296 /*
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
297 * Generate a random message cookie
2122
c99c781e5931 [gaim-migrate @ 2132]
Adam Fritzler <mid@auk.cx>
parents: 2086
diff changeset
298 *
c99c781e5931 [gaim-migrate @ 2132]
Adam Fritzler <mid@auk.cx>
parents: 2086
diff changeset
299 * We could cache these like we do SNAC IDs. (In fact, it
c99c781e5931 [gaim-migrate @ 2132]
Adam Fritzler <mid@auk.cx>
parents: 2086
diff changeset
300 * might be a good idea.) In the message error functions,
c99c781e5931 [gaim-migrate @ 2132]
Adam Fritzler <mid@auk.cx>
parents: 2086
diff changeset
301 * the 8byte message cookie is returned as well as the
c99c781e5931 [gaim-migrate @ 2132]
Adam Fritzler <mid@auk.cx>
parents: 2086
diff changeset
302 * SNAC ID.
c99c781e5931 [gaim-migrate @ 2132]
Adam Fritzler <mid@auk.cx>
parents: 2086
diff changeset
303 *
c99c781e5931 [gaim-migrate @ 2132]
Adam Fritzler <mid@auk.cx>
parents: 2086
diff changeset
304 */
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
305 for (i = 0; i < 8; i++)
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
306 ck[i] = (fu8_t)rand();
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
307
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
308 /* ICBM header */
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
309 aim_im_puticbm(&fr->data, ck, 0x0001, args->destsn);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
310
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
311 /* Message TLV (type 0x0002) */
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
312 aimbs_put16(&fr->data, 0x0002);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
313 aimbs_put16(&fr->data, msgtlvlen);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
314
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
315 /* Features TLV (type 0x0501) */
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
316 aimbs_put16(&fr->data, 0x0501);
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
317 if (args->flags & AIM_IMFLAGS_CUSTOMFEATURES) {
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
318 aimbs_put16(&fr->data, args->featureslen);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
319 aimbs_putraw(&fr->data, args->features, args->featureslen);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
320 } else {
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
321 aimbs_put16(&fr->data, sizeof(deffeatures));
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
322 aimbs_putraw(&fr->data, deffeatures, sizeof(deffeatures));
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
323 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
324
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
325 if (args->flags & AIM_IMFLAGS_MULTIPART) {
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
326 aim_mpmsg_section_t *sec;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
327
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
328 /* Insert each message part in a TLV (type 0x0101) */
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
329 for (sec = args->mpmsg->parts; sec; sec = sec->next) {
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
330 aimbs_put16(&fr->data, 0x0101);
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
331 aimbs_put16(&fr->data, sec->datalen + 4);
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
332 aimbs_put16(&fr->data, sec->charset);
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
333 aimbs_put16(&fr->data, sec->charsubset);
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
334 aimbs_putraw(&fr->data, sec->data, sec->datalen);
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
335 }
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
336
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
337 } else {
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
338
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
339 /* Insert message text in a TLV (type 0x0101) */
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
340 aimbs_put16(&fr->data, 0x0101);
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
341
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
342 /* Message block length */
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
343 aimbs_put16(&fr->data, args->msglen + 0x04);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
344
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
345 /* Character set */
4662
6d8a3e81db48 [gaim-migrate @ 4973]
Mark Doliner <mark@kingant.net>
parents: 4650
diff changeset
346 aimbs_put16(&fr->data, args->charset);
6d8a3e81db48 [gaim-migrate @ 4973]
Mark Doliner <mark@kingant.net>
parents: 4650
diff changeset
347 aimbs_put16(&fr->data, args->charsubset);
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
348
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
349 /* Message. Not terminated */
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
350 aimbs_putraw(&fr->data, args->msg, args->msglen);
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
351 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
352
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
353 /* Set the Autoresponse flag */
2122
c99c781e5931 [gaim-migrate @ 2132]
Adam Fritzler <mid@auk.cx>
parents: 2086
diff changeset
354 if (args->flags & AIM_IMFLAGS_AWAY) {
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
355 aimbs_put16(&fr->data, 0x0004);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
356 aimbs_put16(&fr->data, 0x0000);
4838
60d8c5ad77f9 [gaim-migrate @ 5163]
Mark Doliner <mark@kingant.net>
parents: 4662
diff changeset
357 } else if (args->flags & AIM_IMFLAGS_ACK) {
60d8c5ad77f9 [gaim-migrate @ 5163]
Mark Doliner <mark@kingant.net>
parents: 4662
diff changeset
358 /* Set the Request Acknowledge flag */
60d8c5ad77f9 [gaim-migrate @ 5163]
Mark Doliner <mark@kingant.net>
parents: 4662
diff changeset
359 aimbs_put16(&fr->data, 0x0003);
60d8c5ad77f9 [gaim-migrate @ 5163]
Mark Doliner <mark@kingant.net>
parents: 4662
diff changeset
360 aimbs_put16(&fr->data, 0x0000);
2122
c99c781e5931 [gaim-migrate @ 2132]
Adam Fritzler <mid@auk.cx>
parents: 2086
diff changeset
361 }
c99c781e5931 [gaim-migrate @ 2132]
Adam Fritzler <mid@auk.cx>
parents: 2086
diff changeset
362
2703
441b84ab7f4e [gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2673
diff changeset
363 if (args->flags & AIM_IMFLAGS_OFFLINE) {
441b84ab7f4e [gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2673
diff changeset
364 aimbs_put16(&fr->data, 0x0006);
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
365 aimbs_put16(&fr->data, 0x0000);
2122
c99c781e5931 [gaim-migrate @ 2132]
Adam Fritzler <mid@auk.cx>
parents: 2086
diff changeset
366 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
367
2122
c99c781e5931 [gaim-migrate @ 2132]
Adam Fritzler <mid@auk.cx>
parents: 2086
diff changeset
368 /*
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
369 * Set the I HAVE A REALLY PURTY ICON flag.
3595
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
370 * XXX - This should really only be sent on initial
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
371 * IMs and when you change your icon.
2122
c99c781e5931 [gaim-migrate @ 2132]
Adam Fritzler <mid@auk.cx>
parents: 2086
diff changeset
372 */
c99c781e5931 [gaim-migrate @ 2132]
Adam Fritzler <mid@auk.cx>
parents: 2086
diff changeset
373 if (args->flags & AIM_IMFLAGS_HASICON) {
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
374 aimbs_put16(&fr->data, 0x0008);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
375 aimbs_put16(&fr->data, 0x000c);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
376 aimbs_put32(&fr->data, args->iconlen);
2626
93f9bbd62630 [gaim-migrate @ 2639]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2507
diff changeset
377 aimbs_put16(&fr->data, 0x0001);
93f9bbd62630 [gaim-migrate @ 2639]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2507
diff changeset
378 aimbs_put16(&fr->data, args->iconsum);
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
379 aimbs_put32(&fr->data, args->iconstamp);
2122
c99c781e5931 [gaim-migrate @ 2132]
Adam Fritzler <mid@auk.cx>
parents: 2086
diff changeset
380 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
381
2703
441b84ab7f4e [gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2673
diff changeset
382 /*
441b84ab7f4e [gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2673
diff changeset
383 * Set the Buddy Icon Requested flag.
3595
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
384 * XXX - Everytime? Surely not...
2703
441b84ab7f4e [gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2673
diff changeset
385 */
441b84ab7f4e [gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2673
diff changeset
386 if (args->flags & AIM_IMFLAGS_BUDDYREQ) {
441b84ab7f4e [gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2673
diff changeset
387 aimbs_put16(&fr->data, 0x0009);
441b84ab7f4e [gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2673
diff changeset
388 aimbs_put16(&fr->data, 0x0000);
441b84ab7f4e [gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2673
diff changeset
389 }
441b84ab7f4e [gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2673
diff changeset
390
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
391 aim_tx_enqueue(sess, fr);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
392
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
393 /* Move this to receive aim_flap_nop and send aim_flap_nop */
2751
b715593f0d21 [gaim-migrate @ 2764]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2717
diff changeset
394 if (!(sess->flags & AIM_SESS_FLAGS_DONTTIMEOUTONICBM))
b715593f0d21 [gaim-migrate @ 2764]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2717
diff changeset
395 aim_cleansnacs(sess, 60); /* clean out SNACs over 60sec old */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
396
2122
c99c781e5931 [gaim-migrate @ 2132]
Adam Fritzler <mid@auk.cx>
parents: 2086
diff changeset
397 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
398 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
399
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
400 /*
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
401 * Simple wrapper for aim_im_sendch1_ext()
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
402 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
403 * You cannot use aim_send_im if you need the HASICON flag. You must
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
404 * use aim_im_sendch1_ext directly for that.
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
405 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
406 * aim_send_im also cannot be used if you require UNICODE messages, because
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
407 * that requires an explicit message length. Use aim_im_sendch1_ext().
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
408 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
409 */
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
410 faim_export int aim_im_sendch1(aim_session_t *sess, const char *sn, fu16_t flags, const char *msg)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
411 {
2122
c99c781e5931 [gaim-migrate @ 2132]
Adam Fritzler <mid@auk.cx>
parents: 2086
diff changeset
412 struct aim_sendimext_args args;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
413
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
414 args.destsn = sn;
2122
c99c781e5931 [gaim-migrate @ 2132]
Adam Fritzler <mid@auk.cx>
parents: 2086
diff changeset
415 args.flags = flags;
c99c781e5931 [gaim-migrate @ 2132]
Adam Fritzler <mid@auk.cx>
parents: 2086
diff changeset
416 args.msg = msg;
c99c781e5931 [gaim-migrate @ 2132]
Adam Fritzler <mid@auk.cx>
parents: 2086
diff changeset
417 args.msglen = strlen(msg);
4662
6d8a3e81db48 [gaim-migrate @ 4973]
Mark Doliner <mark@kingant.net>
parents: 4650
diff changeset
418 args.charset = 0x0000;
6d8a3e81db48 [gaim-migrate @ 4973]
Mark Doliner <mark@kingant.net>
parents: 4650
diff changeset
419 args.charsubset = 0x0000;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
420
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
421 /* Make these don't get set by accident -- they need aim_im_sendch1_ext */
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
422 args.flags &= ~(AIM_IMFLAGS_CUSTOMFEATURES | AIM_IMFLAGS_HASICON | AIM_IMFLAGS_MULTIPART);
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
423
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
424 return aim_im_sendch1_ext(sess, &args);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
425 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
426
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
427 /**
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
428 * Subtype 0x0006 - Send your icon to a given user.
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
429 *
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
430 * This is also performance sensitive. (If you can believe it...)
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
431 *
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
432 */
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
433 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)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
434 {
2673
81d658e6ac1e [gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2672
diff changeset
435 aim_conn_t *conn;
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
436 aim_frame_t *fr;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
437 aim_snacid_t snacid;
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
438 fu8_t ck[8];
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
439 int i;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
440
2673
81d658e6ac1e [gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2672
diff changeset
441 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004)))
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
442 return -EINVAL;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
443
2673
81d658e6ac1e [gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2672
diff changeset
444 if (!sn || !icon || (iconlen <= 0) || (iconlen >= MAXICONLEN))
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
445 return -EINVAL;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
446
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
447 for (i = 0; i < 8; i++)
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
448 ck[i] = (fu8_t)rand();
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
449
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
450 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+8+2+1+strlen(sn)+2+2+2+8+16+2+2+2+2+2+2+2+4+4+4+iconlen+strlen(AIM_ICONIDENT)+2+2)))
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
451 return -ENOMEM;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
452
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
453 snacid = aim_cachesnac(sess, 0x0004, 0x0006, 0x0000, NULL, 0);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
454 aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
455
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
456 /* ICBM header */
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
457 aim_im_puticbm(&fr->data, ck, 0x0002, sn);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
458
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
459 /*
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
460 * TLV t(0005)
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
461 *
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
462 * Encompasses everything below.
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
463 */
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
464 aimbs_put16(&fr->data, 0x0005);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
465 aimbs_put16(&fr->data, 2+8+16+6+4+4+iconlen+4+4+4+strlen(AIM_ICONIDENT));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
466
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
467 aimbs_put16(&fr->data, 0x0000);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
468 aimbs_putraw(&fr->data, ck, 8);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
469 aim_putcap(&fr->data, AIM_CAPS_BUDDYICON);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
470
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
471 /* TLV t(000a) */
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
472 aimbs_put16(&fr->data, 0x000a);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
473 aimbs_put16(&fr->data, 0x0002);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
474 aimbs_put16(&fr->data, 0x0001);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
475
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
476 /* TLV t(000f) */
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
477 aimbs_put16(&fr->data, 0x000f);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
478 aimbs_put16(&fr->data, 0x0000);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
479
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
480 /* TLV t(2711) */
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
481 aimbs_put16(&fr->data, 0x2711);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
482 aimbs_put16(&fr->data, 4+4+4+iconlen+strlen(AIM_ICONIDENT));
2626
93f9bbd62630 [gaim-migrate @ 2639]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2507
diff changeset
483 aimbs_put16(&fr->data, 0x0000);
93f9bbd62630 [gaim-migrate @ 2639]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2507
diff changeset
484 aimbs_put16(&fr->data, iconsum);
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
485 aimbs_put32(&fr->data, iconlen);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
486 aimbs_put32(&fr->data, stamp);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
487 aimbs_putraw(&fr->data, icon, iconlen);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
488 aimbs_putraw(&fr->data, AIM_ICONIDENT, strlen(AIM_ICONIDENT));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
489
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
490 /* TLV t(0003) */
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
491 aimbs_put16(&fr->data, 0x0003);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
492 aimbs_put16(&fr->data, 0x0000);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
493
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
494 aim_tx_enqueue(sess, fr);
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
495
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
496 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
497 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
498
2866
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
499 /*
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
500 * Subtype 0x0006 - Send a rich text message.
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
501 *
2866
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
502 * This only works for ICQ 2001b (thats 2001 not 2000). Better, only
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
503 * send it to clients advertising the RTF capability. In fact, if you send
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
504 * it to a client that doesn't support that capability, the server will gladly
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
505 * bounce it back to you.
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
506 *
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
507 * You'd think this would be in icq.c, but, well, I'm trying to stick with
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
508 * the one-group-per-file scheme as much as possible. This could easily
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
509 * be an exception, since Rendezvous IMs are external of the Oscar core,
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
510 * and therefore are undefined. Really I just need to think of a good way to
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
511 * make an interface similar to what AOL actually uses. But I'm not using COM.
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
512 *
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
513 */
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
514 faim_export int aim_im_sendch2_rtfmsg(aim_session_t *sess, struct aim_sendrtfmsg_args *args)
2866
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
515 {
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
516 aim_conn_t *conn;
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
517 aim_frame_t *fr;
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
518 aim_snacid_t snacid;
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
519 fu8_t ck[8];
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
520 const char rtfcap[] = {"{97B12751-243C-4334-AD22-D6ABF73F1492}"}; /* AIM_CAPS_ICQRTF capability in string form */
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
521 int i, servdatalen;
2866
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
522
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
523 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004)))
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
524 return -EINVAL;
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
525
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
526 if (!args || !args->destsn || !args->rtfmsg)
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
527 return -EINVAL;
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
528
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
529 servdatalen = 2+2+16+2+4+1+2 + 2+2+4+4+4 + 2+4+2+strlen(args->rtfmsg)+1 + 4+4+4+strlen(rtfcap)+1;
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
530
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
531 for (i = 0; i < 8; i++)
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
532 ck[i] = (fu8_t)rand();
2866
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
533
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
534 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+128+servdatalen)))
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
535 return -ENOMEM;
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
536
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
537 snacid = aim_cachesnac(sess, 0x0004, 0x0006, 0x0000, NULL, 0);
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
538 aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid);
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
539
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
540 /* ICBM header */
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
541 aim_im_puticbm(&fr->data, ck, 0x0002, args->destsn);
2866
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
542
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
543 /* TLV t(0005) - Encompasses everything below. */
2866
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
544 aimbs_put16(&fr->data, 0x0005);
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
545 aimbs_put16(&fr->data, 2+8+16 + 2+2+2 + 2+2 + 2+2+servdatalen);
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
546
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
547 aimbs_put16(&fr->data, 0x0000);
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
548 aimbs_putraw(&fr->data, ck, 8);
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
549 aim_putcap(&fr->data, AIM_CAPS_ICQSERVERRELAY);
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
550
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
551 /* t(000a) l(0002) v(0001) */
2866
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
552 aimbs_put16(&fr->data, 0x000a);
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
553 aimbs_put16(&fr->data, 0x0002);
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
554 aimbs_put16(&fr->data, 0x0001);
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
555
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
556 /* t(000f) l(0000) v() */
2866
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
557 aimbs_put16(&fr->data, 0x000f);
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
558 aimbs_put16(&fr->data, 0x0000);
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
559
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
560 /* Service Data TLV */
2866
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
561 aimbs_put16(&fr->data, 0x2711);
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
562 aimbs_put16(&fr->data, servdatalen);
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
563
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
564 aimbs_putle16(&fr->data, 11 + 16 /* 11 + (sizeof CLSID) */);
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
565 aimbs_putle16(&fr->data, 9);
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
566 aim_putcap(&fr->data, AIM_CAPS_EMPTY);
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
567 aimbs_putle16(&fr->data, 0);
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
568 aimbs_putle32(&fr->data, 0);
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
569 aimbs_putle8(&fr->data, 0);
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
570 aimbs_putle16(&fr->data, 0x03ea); /* trid1 */
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
571
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
572 aimbs_putle16(&fr->data, 14);
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
573 aimbs_putle16(&fr->data, 0x03eb); /* trid2 */
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
574 aimbs_putle32(&fr->data, 0);
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
575 aimbs_putle32(&fr->data, 0);
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
576 aimbs_putle32(&fr->data, 0);
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
577
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
578 aimbs_putle16(&fr->data, 0x0001);
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
579 aimbs_putle32(&fr->data, 0);
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
580 aimbs_putle16(&fr->data, strlen(args->rtfmsg)+1);
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
581 aimbs_putraw(&fr->data, args->rtfmsg, strlen(args->rtfmsg)+1);
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
582
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
583 aimbs_putle32(&fr->data, args->fgcolor);
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
584 aimbs_putle32(&fr->data, args->bgcolor);
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
585 aimbs_putle32(&fr->data, strlen(rtfcap)+1);
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
586 aimbs_putraw(&fr->data, rtfcap, strlen(rtfcap)+1);
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
587
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
588 aim_tx_enqueue(sess, fr);
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
589
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
590 return 0;
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
591 }
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
592
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
593 /**
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
594 * Subtype 0x0006 - Send an "I want to directly connect to you" message
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
595 *
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
596 */
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
597 faim_export int aim_im_sendch2_odcrequest(aim_session_t *sess, fu8_t *cookie, const char *sn, const fu8_t *ip, fu16_t port)
2717
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
598 {
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
599 aim_conn_t *conn;
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
600 aim_frame_t *fr;
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
601 aim_snacid_t snacid;
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
602 fu8_t ck[8];
2717
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
603 aim_tlvlist_t *tl = NULL, *itl = NULL;
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
604 int hdrlen, i;
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
605 fu8_t *hdr;
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
606 aim_bstream_t hdrbs;
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
607
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
608 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004)))
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
609 return -EINVAL;
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
610
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
611 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 256+strlen(sn))))
2717
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
612 return -ENOMEM;
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
613
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
614 snacid = aim_cachesnac(sess, 0x0004, 0x0006, 0x0000, NULL, 0);
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
615 aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid);
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
616
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
617 /*
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
618 * Generate a random message cookie
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
619 *
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
620 * This cookie needs to be alphanumeric and NULL-terminated to be
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
621 * TOC-compatible.
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
622 *
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
623 * XXX - have I mentioned these should be generated in msgcookie.c?
2717
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
624 *
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
625 */
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
626 for (i = 0; i < 7; i++)
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
627 ck[i] = 0x30 + ((fu8_t) rand() % 10);
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
628 ck[7] = '\0';
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
629
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
630 if (cookie)
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
631 memcpy(cookie, ck, 8);
2717
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
632
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
633 /* ICBM header */
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
634 aim_im_puticbm(&fr->data, ck, 0x0002, sn);
2717
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
635
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
636 aim_addtlvtochain_noval(&tl, 0x0003);
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
637
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
638 hdrlen = 2+8+16+6+8+6+4;
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
639 hdr = malloc(hdrlen);
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
640 aim_bstream_init(&hdrbs, hdr, hdrlen);
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
641
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
642 aimbs_put16(&hdrbs, 0x0000);
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
643 aimbs_putraw(&hdrbs, ck, 8);
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
644 aim_putcap(&hdrbs, AIM_CAPS_IMIMAGE);
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
645
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
646 aim_addtlvtochain16(&itl, 0x000a, 0x0001);
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
647 aim_addtlvtochain_raw(&itl, 0x0003, 4, ip);
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
648 aim_addtlvtochain16(&itl, 0x0005, port);
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
649 aim_addtlvtochain_noval(&itl, 0x000f);
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
650
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
651 aim_writetlvchain(&hdrbs, &itl);
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
652
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
653 aim_addtlvtochain_raw(&tl, 0x0005, aim_bstream_curpos(&hdrbs), hdr);
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
654
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
655 aim_writetlvchain(&fr->data, &tl);
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
656
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
657 free(hdr);
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
658 aim_freetlvchain(&itl);
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
659 aim_freetlvchain(&tl);
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
660
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
661 aim_tx_enqueue(sess, fr);
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
662
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
663 return 0;
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
664 }
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
665
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
666 /**
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
667 * Subtype 0x0006 - Send an "I want to send you this file" message
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
668 *
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
669 */
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
670 faim_export int aim_im_sendch2_sendfile_ask(aim_session_t *sess, fu8_t *cookie, const char *sn, const fu8_t *ip, fu16_t port, const char *filename, fu16_t numfiles, fu32_t totsize)
2717
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
671 {
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
672 aim_conn_t *conn;
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
673 aim_frame_t *fr;
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
674 aim_snacid_t snacid;
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
675 aim_tlvlist_t *tl=NULL, *subtl=NULL;
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
676 fu8_t *ck;
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
677 int i;
2717
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
678
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
679 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004)))
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
680 return -EINVAL;
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
681
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
682 if (!sn || !filename)
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
683 return -EINVAL;
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
684
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
685 /* XXX - Should be like "21CBF95" and null terminated */
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
686 ck = (fu8_t *)malloc(8*sizeof(fu8_t));
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
687 for (i = 0; i < 7; i++)
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
688 ck[i] = 0x30 + ((fu8_t)rand() % 10);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
689 ck[7] = '\0';
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
690 if (cookie)
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
691 memcpy(cookie, ck, 8);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
692
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
693 { /* Create the subTLV chain */
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
694 fu8_t *buf;
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
695 int buflen;
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
696 aim_bstream_t bs;
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
697
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
698 aim_addtlvtochain16(&subtl, 0x000a, 0x0001);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
699 aim_addtlvtochain_noval(&subtl, 0x000f);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
700 /* aim_addtlvtochain_raw(&subtl, 0x000e, 2, "en");
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
701 aim_addtlvtochain_raw(&subtl, 0x000d, 8, "us-ascii");
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
702 aim_addtlvtochain_raw(&subtl, 0x000c, 24, "Please accept this file."); */
4650
4938d12f6d48 [gaim-migrate @ 4961]
Mark Doliner <mark@kingant.net>
parents: 4617
diff changeset
703 if (ip[0])
4938d12f6d48 [gaim-migrate @ 4961]
Mark Doliner <mark@kingant.net>
parents: 4617
diff changeset
704 aim_addtlvtochain_raw(&subtl, 0x0003, 4, ip);
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
705 aim_addtlvtochain16(&subtl, 0x0005, port);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
706
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
707 /* TLV t(2711) */
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
708 buflen = 2+2+4+63;
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
709 buf = malloc(buflen);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
710 aim_bstream_init(&bs, buf, buflen);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
711 aimbs_put16(&bs, (numfiles > 1) ? 0x0002 : 0x0001);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
712 aimbs_put16(&bs, numfiles);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
713 aimbs_put32(&bs, totsize);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
714
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
715 /* Filename is a fixed size of 63 bytes, so pad with 0's */
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
716 aimbs_putraw(&bs, filename, strlen(filename));
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
717 for (i=0; i<(63-strlen(filename)); i++)
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
718 aimbs_put8(&bs, 0x00);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
719
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
720 aim_addtlvtochain_raw(&subtl, 0x2711, bs.len, bs.data);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
721 free(buf);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
722 }
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
723
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
724 { /* Create the main TLV chain */
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
725 fu8_t *buf;
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
726 int buflen;
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
727 aim_bstream_t bs;
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
728
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
729 /* TLV t(0005) - Encompasses everything from above. Gee. */
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
730 buflen = 2+8+16+aim_sizetlvchain(&subtl);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
731 buf = malloc(buflen);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
732 aim_bstream_init(&bs, buf, buflen);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
733 aimbs_put16(&bs, AIM_RENDEZVOUS_PROPOSE);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
734 aimbs_putraw(&bs, ck, 8);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
735 aim_putcap(&bs, AIM_CAPS_SENDFILE);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
736 aim_writetlvchain(&bs, &subtl);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
737 aim_freetlvchain(&subtl);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
738 aim_addtlvtochain_raw(&tl, 0x0005, bs.len, bs.data);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
739 free(buf);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
740
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
741 /* TLV t(0003) - Request an ack */
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
742 aim_addtlvtochain_noval(&tl, 0x0003);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
743 }
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
744
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
745 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 11+strlen(sn) + aim_sizetlvchain(&tl))))
2717
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
746 return -ENOMEM;
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
747
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
748 snacid = aim_cachesnac(sess, 0x0004, 0x0006, AIM_SNACFLAGS_DESTRUCTOR, ck, sizeof(ck));
3752
b32474e522fa [gaim-migrate @ 3890]
Luke Schierer <lschiere@pidgin.im>
parents: 3630
diff changeset
749 aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid);
b32474e522fa [gaim-migrate @ 3890]
Luke Schierer <lschiere@pidgin.im>
parents: 3630
diff changeset
750
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
751 /* ICBM header */
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
752 aim_im_puticbm(&fr->data, ck, 0x0002, sn);
2717
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
753
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
754 /* All that crap from above (the 0x0005 TLV and the 0x0003 TLV) */
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
755 aim_writetlvchain(&fr->data, &tl);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
756 aim_freetlvchain(&tl);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
757
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
758 aim_tx_enqueue(sess, fr);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
759
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
760 return 0;
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
761 }
2717
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
762
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
763 /**
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
764 * Subtype 0x0006 - Send an "I will accept this file" message?
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
765 *
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
766 * @param rendid Capability type (AIM_CAPS_GETFILE or AIM_CAPS_SENDFILE)
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
767 */
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
768 faim_export int aim_im_sendch2_sendfile_accept(aim_session_t *sess, const fu8_t *cookie, const char *sn, fu16_t rendid)
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
769 {
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
770 aim_conn_t *conn;
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
771 aim_frame_t *fr;
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
772 aim_snacid_t snacid;
2717
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
773
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
774 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004)) || !cookie || !sn)
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
775 return -EINVAL;
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
776
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
777 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 11+strlen(sn) + 4+2+8+16)))
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
778 return -ENOMEM;
2717
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
779
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
780 snacid = aim_cachesnac(sess, 0x0004, 0x0006, 0x0000, NULL, 0);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
781 aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
782
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
783 /* ICBM header */
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
784 aim_im_puticbm(&fr->data, cookie, 0x0002, sn);
2717
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
785
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
786 aimbs_put16(&fr->data, 0x0005);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
787 aimbs_put16(&fr->data, 0x001a);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
788 aimbs_put16(&fr->data, AIM_RENDEZVOUS_ACCEPT);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
789 aimbs_putraw(&fr->data, cookie, 8);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
790 aim_putcap(&fr->data, rendid);
2717
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
791
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
792 aim_tx_enqueue(sess, fr);
2717
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
793
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
794 return 0;
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
795 }
2717
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
796
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
797 /**
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
798 * Subtype 0x0006 - Send a "cancel this file transfer" message?
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
799 *
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
800 */
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
801 faim_export int aim_im_sendch2_sendfile_cancel(aim_session_t *sess, const fu8_t *cookie, const char *sn, fu16_t rendid)
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
802 {
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
803 aim_conn_t *conn;
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
804 aim_frame_t *fr;
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
805 aim_snacid_t snacid;
2717
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
806
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
807 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004)) || !cookie || !sn)
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
808 return -EINVAL;
2717
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
809
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
810 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 11+strlen(sn) + 4+2+8+16)))
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
811 return -ENOMEM;
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
812
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
813 snacid = aim_cachesnac(sess, 0x0004, 0x0006, 0x0000, NULL, 0);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
814 aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid);
2717
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
815
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
816 /* ICBM header */
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
817 aim_im_puticbm(&fr->data, cookie, 0x0002, sn);
2717
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
818
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
819 aimbs_put16(&fr->data, 0x0005);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
820 aimbs_put16(&fr->data, 0x001a);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
821 aimbs_put16(&fr->data, AIM_RENDEZVOUS_CANCEL);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
822 aimbs_putraw(&fr->data, cookie, 8);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
823 aim_putcap(&fr->data, rendid);
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3595
diff changeset
824
2717
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
825 aim_tx_enqueue(sess, fr);
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
826
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
827 return 0;
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
828 }
03bf072c6238 [gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
829
3212
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
830 /**
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
831 * Subtype 0x0006 - Request the status message of the given ICQ user.
3212
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
832 *
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
833 * @param sess The oscar session.
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
834 * @param sn The UIN of the user of whom you wish to request info.
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
835 * @param type The type of info you wish to request. This should be the current
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
836 * state of the user, as one of the AIM_ICQ_STATE_* defines.
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
837 * @return Return 0 if no errors, otherwise return the error number.
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
838 */
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
839 faim_export int aim_im_sendch2_geticqaway(aim_session_t *sess, const char *sn, int type)
3212
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
840 {
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
841 aim_conn_t *conn;
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
842 aim_frame_t *fr;
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
843 aim_snacid_t snacid;
3212
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
844 int i;
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
845 fu8_t ck[8];
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
846
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
847 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004)) || !sn)
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
848 return -EINVAL;
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
849
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
850 for (i = 0; i < 8; i++)
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
851 ck[i] = (fu8_t)rand();
3212
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
852
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
853 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+8+2+1+strlen(sn) + 4+0x5e + 4)))
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
854 return -ENOMEM;
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
855
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
856 snacid = aim_cachesnac(sess, 0x0004, 0x0006, 0x0000, NULL, 0);
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
857 aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid);
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
858
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
859 /* ICBM header */
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
860 aim_im_puticbm(&fr->data, ck, 0x0002, sn);
3212
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
861
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
862 /* TLV t(0005) - Encompasses almost everything below. */
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
863 aimbs_put16(&fr->data, 0x0005); /* T */
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
864 aimbs_put16(&fr->data, 0x005e); /* L */
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
865 { /* V */
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
866 aimbs_put16(&fr->data, 0x0000);
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
867
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
868 /* Cookie */
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
869 aimbs_putraw(&fr->data, ck, 8);
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
870
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
871 /* Put the 16 byte server relay capability */
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
872 aim_putcap(&fr->data, AIM_CAPS_ICQSERVERRELAY);
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
873
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
874 /* TLV t(000a) */
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
875 aimbs_put16(&fr->data, 0x000a);
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
876 aimbs_put16(&fr->data, 0x0002);
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
877 aimbs_put16(&fr->data, 0x0001);
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
878
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
879 /* TLV t(000f) */
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
880 aimbs_put16(&fr->data, 0x000f);
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
881 aimbs_put16(&fr->data, 0x0000);
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
882
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
883 /* TLV t(2711) */
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
884 aimbs_put16(&fr->data, 0x2711);
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
885 aimbs_put16(&fr->data, 0x0036);
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
886 { /* V */
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
887 aimbs_putle16(&fr->data, 0x001b); /* L */
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
888 aimbs_putle16(&fr->data, 0x0008); /* XXX - Protocol version */
4154
3468d666d3cc [gaim-migrate @ 4382]
Mark Doliner <mark@kingant.net>
parents: 4102
diff changeset
889 aim_putcap(&fr->data, AIM_CAPS_EMPTY);
3212
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
890 aimbs_putle16(&fr->data, 0x0000); /* Unknown */
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
891 aimbs_putle16(&fr->data, 0x0003); /* Client features? */
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
892 aimbs_putle16(&fr->data, 0x0000); /* Unknown */
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
893 aimbs_putle8(&fr->data, 0x00); /* Unkizown */
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
894 aimbs_putle16(&fr->data, 0xffff); /* Sequence number? XXX - This should decrement by 1 with each request */
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
895
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
896 aimbs_putle16(&fr->data, 0x000e); /* L */
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
897 aimbs_putle16(&fr->data, 0xffff); /* Sequence number? XXX - This should decrement by 1 with each request */
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
898 aimbs_putle32(&fr->data, 0x00000000); /* Unknown */
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
899 aimbs_putle32(&fr->data, 0x00000000); /* Unknown */
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
900 aimbs_putle32(&fr->data, 0x00000000); /* Unknown */
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
901
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
902 /* The type of status message being requested */
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
903 if (type & AIM_ICQ_STATE_CHAT)
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
904 aimbs_putle16(&fr->data, 0x03ec);
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
905 else if(type & AIM_ICQ_STATE_DND)
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
906 aimbs_putle16(&fr->data, 0x03eb);
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
907 else if(type & AIM_ICQ_STATE_OUT)
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
908 aimbs_putle16(&fr->data, 0x03ea);
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
909 else if(type & AIM_ICQ_STATE_BUSY)
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
910 aimbs_putle16(&fr->data, 0x03e9);
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
911 else if(type & AIM_ICQ_STATE_AWAY)
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
912 aimbs_putle16(&fr->data, 0x03e8);
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
913
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
914 aimbs_putle16(&fr->data, 0x0000); /* Status? */
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
915 aimbs_putle16(&fr->data, 0x0001); /* Priority of this message? */
4154
3468d666d3cc [gaim-migrate @ 4382]
Mark Doliner <mark@kingant.net>
parents: 4102
diff changeset
916 aimbs_putle16(&fr->data, 0x0001); /* L */
3468d666d3cc [gaim-migrate @ 4382]
Mark Doliner <mark@kingant.net>
parents: 4102
diff changeset
917 aimbs_putle8(&fr->data, 0x00); /* String of length L */
3212
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
918 } /* End TLV t(2711) */
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
919 } /* End TLV t(0005) */
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
920
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
921 /* TLV t(0003) */
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
922 aimbs_put16(&fr->data, 0x0003);
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
923 aimbs_put16(&fr->data, 0x0000);
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
924
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
925 aim_tx_enqueue(sess, fr);
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
926
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
927 return 0;
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
928 }
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
929
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
930 /**
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
931 * Subtype 0x0006 - Send an ICQ-esque ICBM.
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
932 *
3141
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
933 * This can be used to send an ICQ authorization reply (deny or grant). It is the "old way."
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
934 * The new way is to use SSI. I like the new way a lot better. This seems like such a hack,
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
935 * mostly because it's in network byte order. Figuring this stuff out sometimes takes a while,
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
936 * but thats ok, because it gives me time to try to figure out what kind of drugs the AOL people
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
937 * were taking when they merged the two protocols.
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
938 *
3212
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
939 * @param sn The destination screen name.
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
940 * @param type The type of message. 0x0007 for authorization denied. 0x0008 for authorization granted.
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
941 * @param message The message you want to send, it should be null terminated.
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
942 * @return Return 0 if no errors, otherwise return the error number.
3141
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
943 */
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
944 faim_export int aim_im_sendch4(aim_session_t *sess, char *sn, fu16_t type, fu8_t *message)
3141
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
945 {
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
946 aim_conn_t *conn;
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
947 aim_frame_t *fr;
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
948 aim_snacid_t snacid;
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
949 int i;
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
950 char ck[8];
3141
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
951
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
952 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0002)))
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
953 return -EINVAL;
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
954
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
955 if (!sn || !type || !message)
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
956 return -EINVAL;
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
957
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
958 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+8+3+strlen(sn)+12+strlen(message)+1+4)))
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
959 return -ENOMEM;
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
960
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
961 snacid = aim_cachesnac(sess, 0x0004, 0x0006, 0x0000, NULL, 0);
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
962 aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid);
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
963
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
964 /* Cookie */
3141
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
965 for (i=0; i<8; i++)
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
966 ck[i] = (fu8_t)rand();
3141
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
967
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
968 /* ICBM header */
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
969 aim_im_puticbm(&fr->data, ck, 0x0004, sn);
3141
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
970
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
971 /*
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
972 * TLV t(0005)
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
973 *
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
974 * ICQ data (the UIN and the message).
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
975 */
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
976 aimbs_put16(&fr->data, 0x0005);
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
977 aimbs_put16(&fr->data, 4 + 2+2+strlen(message)+1);
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
978
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
979 /*
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
980 * Your UIN
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
981 */
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
982 aimbs_putle32(&fr->data, atoi(sess->sn));
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
983
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
984 /*
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
985 * TLV t(type) l(strlen(message)+1) v(message+NULL)
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
986 */
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
987 aimbs_putle16(&fr->data, type);
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
988 aimbs_putle16(&fr->data, strlen(message)+1);
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
989 aimbs_putraw(&fr->data, message, strlen(message)+1);
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
990
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
991 /*
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
992 * TLV t(0006) l(0000) v()
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
993 */
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
994 aimbs_put16(&fr->data, 0x0006);
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
995 aimbs_put16(&fr->data, 0x0000);
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
996
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
997 aim_tx_enqueue(sess, fr);
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
998
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
999 return 0;
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1000 }
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1001
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1002 /*
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1003 * XXX - I don't see when this would ever get called...
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1004 */
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1005 static int outgoingim(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1006 {
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1007 int i, ret = 0;
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1008 aim_rxcallback_t userfunc;
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1009 fu8_t cookie[8];
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1010 fu16_t channel;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1011 aim_tlvlist_t *tlvlist;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1012 char *sn;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1013 int snlen;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1014 fu16_t icbmflags = 0;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1015 fu8_t flag1 = 0, flag2 = 0;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1016 fu8_t *msg = NULL;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1017 aim_tlv_t *msgblock;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1018
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1019 /* ICBM Cookie. */
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1020 for (i = 0; i < 8; i++)
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1021 cookie[i] = aimbs_get8(bs);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1022
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1023 /* Channel ID */
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1024 channel = aimbs_get16(bs);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1025
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1026 if (channel != 0x01) {
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1027 faimdprintf(sess, 0, "icbm: ICBM recieved on unsupported channel. Ignoring. (chan = %04x)\n", channel);
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1028 return 0;
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1029 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1030
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1031 snlen = aimbs_get8(bs);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1032 sn = aimbs_getstr(bs, snlen);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1033
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1034 tlvlist = aim_readtlvchain(bs);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1035
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1036 if (aim_gettlv(tlvlist, 0x0003, 1))
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1037 icbmflags |= AIM_IMFLAGS_ACK;
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1038 if (aim_gettlv(tlvlist, 0x0004, 1))
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1039 icbmflags |= AIM_IMFLAGS_AWAY;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1040
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1041 if ((msgblock = aim_gettlv(tlvlist, 0x0002, 1))) {
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1042 aim_bstream_t mbs;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1043 int featurelen, msglen;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1044
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1045 aim_bstream_init(&mbs, msgblock->value, msgblock->length);
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1046
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1047 aimbs_get8(&mbs);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1048 aimbs_get8(&mbs);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1049 for (featurelen = aimbs_get16(&mbs); featurelen; featurelen--)
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1050 aimbs_get8(&mbs);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1051 aimbs_get8(&mbs);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1052 aimbs_get8(&mbs);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1053
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1054 msglen = aimbs_get16(&mbs) - 4; /* final block length */
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1055
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1056 flag1 = aimbs_get16(&mbs);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1057 flag2 = aimbs_get16(&mbs);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1058
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1059 msg = aimbs_getstr(&mbs, msglen);
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1060 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1061
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1062 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1063 ret = userfunc(sess, rx, channel, sn, msg, icbmflags, flag1, flag2);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1064
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1065 free(sn);
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1066 aim_freetlvchain(&tlvlist);
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1067
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1068 return ret;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1069 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1070
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1071 /*
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1072 * Ahh, the joys of nearly ridiculous over-engineering.
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1073 *
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1074 * Not only do AIM ICBM's support multiple channels. Not only do they
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1075 * support multiple character sets. But they support multiple character
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1076 * sets / encodings within the same ICBM.
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1077 *
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1078 * These multipart messages allow for complex space savings techniques, which
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1079 * seem utterly unnecessary by today's standards. In fact, there is only
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1080 * one client still in popular use that still uses this method: AOL for the
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1081 * Macintosh, Version 5.0. Obscure, yes, I know.
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1082 *
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1083 * In modern (non-"legacy") clients, if the user tries to send a character
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1084 * that is not ISO-8859-1 or ASCII, the client will send the entire message
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1085 * as UNICODE, meaning that every character in the message will occupy the
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1086 * full 16 bit UNICODE field, even if the high order byte would be zero.
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1087 * Multipart messages prevent this wasted space by allowing the client to
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1088 * only send the characters in UNICODE that need to be sent that way, and
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1089 * the rest of the message can be sent in whatever the native character
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1090 * set is (probably ASCII).
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1091 *
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1092 * An important note is that sections will be displayed in the order that
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1093 * they appear in the ICBM. There is no facility for merging or rearranging
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1094 * sections at run time. So if you have, say, ASCII then UNICODE then ASCII,
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1095 * you must supply two ASCII sections with a UNICODE in the middle, and incur
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1096 * the associated overhead.
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1097 *
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1098 * Normally I would have laughed and given a firm 'no' to supporting this
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1099 * seldom-used feature, but something is attracting me to it. In the future,
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1100 * it may be possible to abuse this to send mixed-media messages to other
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1101 * open source clients (like encryption or something) -- see faimtest for
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1102 * examples of how to do this.
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1103 *
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1104 * I would definitly recommend avoiding this feature unless you really
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1105 * know what you are doing, and/or you have something neat to do with it.
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1106 *
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1107 */
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1108 faim_export int aim_mpmsg_init(aim_session_t *sess, aim_mpmsg_t *mpm)
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1109 {
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1110
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1111 memset(mpm, 0, sizeof(aim_mpmsg_t));
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1112
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1113 return 0;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1114 }
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1115
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1116 static int mpmsg_addsection(aim_session_t *sess, aim_mpmsg_t *mpm, fu16_t charset, fu16_t charsubset, fu8_t *data, fu16_t datalen)
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1117 {
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1118 aim_mpmsg_section_t *sec;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1119
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1120 if (!(sec = malloc(sizeof(aim_mpmsg_section_t))))
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1121 return -1;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1122
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1123 sec->charset = charset;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1124 sec->charsubset = charsubset;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1125 sec->data = data;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1126 sec->datalen = datalen;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1127 sec->next = NULL;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1128
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1129 if (!mpm->parts)
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1130 mpm->parts = sec;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1131 else {
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1132 aim_mpmsg_section_t *cur;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1133
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1134 for (cur = mpm->parts; cur->next; cur = cur->next)
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1135 ;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1136 cur->next = sec;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1137 }
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1138
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1139 mpm->numparts++;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1140
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1141 return 0;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1142 }
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1143
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1144 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)
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1145 {
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1146 fu8_t *dup;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1147
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1148 if (!(dup = malloc(datalen)))
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1149 return -1;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1150 memcpy(dup, data, datalen);
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1151
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1152 if (mpmsg_addsection(sess, mpm, charset, charsubset, dup, datalen) == -1) {
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1153 free(dup);
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1154 return -1;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1155 }
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1156
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1157 return 0;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1158 }
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1159
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1160 /* XXX - should provide a way of saying ISO-8859-1 specifically */
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1161 faim_export int aim_mpmsg_addascii(aim_session_t *sess, aim_mpmsg_t *mpm, const char *ascii)
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1162 {
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1163 fu8_t *dup;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1164
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1165 if (!(dup = strdup(ascii)))
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1166 return -1;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1167
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1168 if (mpmsg_addsection(sess, mpm, 0x0000, 0x0000, dup, strlen(ascii)) == -1) {
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1169 free(dup);
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1170 return -1;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1171 }
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1172
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1173 return 0;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1174 }
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1175
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1176 faim_export int aim_mpmsg_addunicode(aim_session_t *sess, aim_mpmsg_t *mpm, const fu16_t *unicode, fu16_t unicodelen)
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1177 {
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1178 fu8_t *buf;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1179 aim_bstream_t bs;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1180 int i;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1181
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1182 if (!(buf = malloc(unicodelen * 2)))
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1183 return -1;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1184
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1185 aim_bstream_init(&bs, buf, unicodelen * 2);
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1186
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1187 /* We assume unicode is in /host/ byte order -- convert to network */
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1188 for (i = 0; i < unicodelen; i++)
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1189 aimbs_put16(&bs, unicode[i]);
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1190
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1191 if (mpmsg_addsection(sess, mpm, 0x0002, 0x0000, buf, aim_bstream_curpos(&bs)) == -1) {
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1192 free(buf);
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1193 return -1;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1194 }
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1195
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1196 return 0;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1197 }
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1198
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1199 faim_export void aim_mpmsg_free(aim_session_t *sess, aim_mpmsg_t *mpm)
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1200 {
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1201 aim_mpmsg_section_t *cur;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1202
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1203 for (cur = mpm->parts; cur; ) {
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1204 aim_mpmsg_section_t *tmp;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1205
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1206 tmp = cur->next;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1207 free(cur->data);
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1208 free(cur);
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1209 cur = tmp;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1210 }
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1211
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1212 mpm->numparts = 0;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1213 mpm->parts = NULL;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1214
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1215 return;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1216 }
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1217
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1218 /*
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1219 * Start by building the multipart structures, then pick the first
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1220 * human-readable section and stuff it into args->msg so no one gets
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1221 * suspicious.
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1222 *
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1223 */
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1224 static int incomingim_ch1_parsemsgs(aim_session_t *sess, fu8_t *data, int len, struct aim_incomingim_ch1_args *args)
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1225 {
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1226 static const fu16_t charsetpri[] = {
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1227 0x0000, /* ASCII first */
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1228 0x0003, /* then ISO-8859-1 */
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1229 0x0002, /* UNICODE as last resort */
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1230 };
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1231 static const int charsetpricount = 3;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1232 int i;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1233 aim_bstream_t mbs;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1234 aim_mpmsg_section_t *sec;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1235
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1236 aim_bstream_init(&mbs, data, len);
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1237
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1238 while (aim_bstream_empty(&mbs)) {
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1239 fu16_t msglen, flag1, flag2;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1240 fu8_t *msgbuf;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1241
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1242 aimbs_get8(&mbs); /* 01 */
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1243 aimbs_get8(&mbs); /* 01 */
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1244
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1245 /* Message string length, including character set info. */
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1246 msglen = aimbs_get16(&mbs);
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1247
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1248 /* Character set info */
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1249 flag1 = aimbs_get16(&mbs);
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1250 flag2 = aimbs_get16(&mbs);
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1251
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1252 /* Message. */
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1253 msglen -= 4;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1254
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1255 /*
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1256 * For now, we don't care what the encoding is. Just copy
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1257 * it into a multipart struct and deal with it later. However,
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1258 * always pad the ending with a NULL. This makes it easier
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1259 * to treat ASCII sections as strings. It won't matter for
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1260 * UNICODE or binary data, as you should never read past
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1261 * the specified data length, which will not include the pad.
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1262 *
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1263 * XXX - There's an API bug here. For sending, the UNICODE is
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1264 * given in host byte order (aim_mpmsg_addunicode), but here
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1265 * the received messages are given in network byte order.
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1266 *
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1267 */
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1268 msgbuf = aimbs_getstr(&mbs, msglen);
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1269 mpmsg_addsection(sess, &args->mpmsg, flag1, flag2, msgbuf, msglen);
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1271 } /* while */
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1272
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1273 args->icbmflags |= AIM_IMFLAGS_MULTIPART; /* always set */
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1274
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1275 /*
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1276 * Clients that support multiparts should never use args->msg, as it
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1277 * will point to an arbitrary section.
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1278 *
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1279 * Here, we attempt to provide clients that do not support multipart
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1280 * messages with something to look at -- hopefully a human-readable
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1281 * string. But, failing that, a UNICODE message, or nothing at all.
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1282 *
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1283 * Which means that even if args->msg is NULL, it does not mean the
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1284 * message was blank.
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1285 *
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1286 */
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1287 for (i = 0; i < charsetpricount; i++) {
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1288 for (sec = args->mpmsg.parts; sec; sec = sec->next) {
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1289
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1290 if (sec->charset != charsetpri[i])
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1291 continue;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1292
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1293 /* Great. We found one. Fill it in. */
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1294 args->charset = sec->charset;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1295 args->charsubset = sec->charsubset;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1296
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1297 /* Set up the simple flags */
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1298 if (args->charset == 0x0000)
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1299 ; /* ASCII */
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1300 else if (args->charset == 0x0002)
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1301 args->icbmflags |= AIM_IMFLAGS_UNICODE;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1302 else if (args->charset == 0x0003)
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1303 args->icbmflags |= AIM_IMFLAGS_ISO_8859_1;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1304 else if (args->charset == 0xffff)
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1305 ; /* no encoding (yeep!) */
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1306
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1307 if (args->charsubset == 0x0000)
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1308 ; /* standard subencoding? */
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1309 else if (args->charsubset == 0x000b)
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1310 args->icbmflags |= AIM_IMFLAGS_SUBENC_MACINTOSH;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1311 else if (args->charsubset == 0xffff)
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1312 ; /* no subencoding */
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1313
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1314 args->msg = sec->data;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1315 args->msglen = sec->datalen;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1316
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1317 return 0;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1318 }
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1319 }
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1320
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1321 /* No human-readable sections found. Oh well. */
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1322 args->charset = args->charsubset = 0xffff;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1323 args->msg = NULL;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1324 args->msglen = 0;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1325
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1326 return 0;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1327 }
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1328
2421
95b4ec08abec [gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2341
diff changeset
1329 static int incomingim_ch1(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, fu16_t channel, aim_userinfo_t *userinfo, aim_bstream_t *bs, fu8_t *cookie)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1330 {
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1331 fu16_t type, length;
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1332 aim_rxcallback_t userfunc;
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1333 int ret = 0;
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1334 struct aim_incomingim_ch1_args args;
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1335 int endpos;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1336
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1337 memset(&args, 0, sizeof(args));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1338
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1339 aim_mpmsg_init(sess, &args.mpmsg);
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1340
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1341 /*
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1342 * This used to be done using tlvchains. For performance reasons,
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1343 * I've changed it to process the TLVs in-place. This avoids lots
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1344 * of per-IM memory allocations.
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1345 */
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1346 while (aim_bstream_empty(bs)) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1347
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1348 type = aimbs_get16(bs);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1349 length = aimbs_get16(bs);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1350
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1351 endpos = aim_bstream_curpos(bs) + length;
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1352
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1353 if (type == 0x0002) { /* Message Block */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1354
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1355 /*
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1356 * This TLV consists of the following:
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1357 * - 0501 -- Unknown
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1358 * - Features: Don't know how to interpret these
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1359 * - 0101 -- Unknown
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1360 * - Message
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1361 *
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1362 */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1363
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1364 aimbs_get8(bs); /* 05 */
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1365 aimbs_get8(bs); /* 01 */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1366
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1367 args.featureslen = aimbs_get16(bs);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1368 /* XXX XXX this is all evil! */
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1369 args.features = bs->data + bs->offset;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1370 aim_bstream_advance(bs, args.featureslen);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1371 args.icbmflags |= AIM_IMFLAGS_CUSTOMFEATURES;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1372
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1373 /*
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1374 * The rest of the TLV contains one or more message
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1375 * blocks...
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1376 */
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1377 incomingim_ch1_parsemsgs(sess, bs->data + bs->offset /* XXX evil!!! */, length - 2 - 2 - args.featureslen, &args);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1378
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1379 } else if (type == 0x0003) { /* Server Ack Requested */
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1380
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1381 args.icbmflags |= AIM_IMFLAGS_ACK;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1382
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1383 } else if (type == 0x0004) { /* Message is Auto Response */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1384
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1385 args.icbmflags |= AIM_IMFLAGS_AWAY;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1386
2703
441b84ab7f4e [gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2673
diff changeset
1387 } else if (type == 0x0006) { /* Message was received offline. */
441b84ab7f4e [gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2673
diff changeset
1388
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1389 /* XXX - not sure if this actually gets sent. */
2703
441b84ab7f4e [gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2673
diff changeset
1390 args.icbmflags |= AIM_IMFLAGS_OFFLINE;
441b84ab7f4e [gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2673
diff changeset
1391
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1392 } else if (type == 0x0008) { /* I-HAVE-A-REALLY-PURTY-ICON Flag */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1393
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1394 args.iconlen = aimbs_get32(bs);
2626
93f9bbd62630 [gaim-migrate @ 2639]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2507
diff changeset
1395 aimbs_get16(bs); /* 0x0001 */
93f9bbd62630 [gaim-migrate @ 2639]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2507
diff changeset
1396 args.iconsum = aimbs_get16(bs);
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1397 args.iconstamp = aimbs_get32(bs);
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1398
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1399 /*
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1400 * This looks to be a client bug. MacAIM 4.3 will
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1401 * send this tag, but with all zero values, in the
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1402 * first message of a conversation. This makes no
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1403 * sense whatsoever, so I'm going to say its a bug.
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1404 *
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1405 * You really shouldn't advertise a zero-length icon
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1406 * anyway.
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1407 *
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1408 */
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1409 if (args.iconlen)
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1410 args.icbmflags |= AIM_IMFLAGS_HASICON;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1411
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1412 } else if (type == 0x0009) {
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1413
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1414 args.icbmflags |= AIM_IMFLAGS_BUDDYREQ;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1415
3595
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
1416 } else if (type == 0x000b) { /* Non-direct connect typing notification */
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
1417
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
1418 args.icbmflags |= AIM_IMFLAGS_TYPINGNOT;
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
1419
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1420 } else if (type == 0x0017) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1421
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1422 args.extdatalen = length;
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1423 args.extdata = aimbs_getraw(bs, args.extdatalen);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1424
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1425 } else {
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1426 faimdprintf(sess, 0, "incomingim_ch1: unknown TLV 0x%04x (len %d)\n", type, length);
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1427 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1428
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1429 /*
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1430 * This is here to protect ourselves from ourselves. That
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1431 * is, if something above doesn't completly parse its value
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1432 * section, or, worse, overparses it, this will set the
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1433 * stream where it needs to be in order to land on the next
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1434 * TLV when the loop continues.
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1435 *
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1436 */
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1437 aim_bstream_setpos(bs, endpos);
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1438 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1439
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1440
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1441 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1442 ret = userfunc(sess, rx, channel, userinfo, &args);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1443
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
1444 aim_mpmsg_free(sess, &args.mpmsg);
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1445 free(args.extdata);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1446
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1447 return ret;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1448 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1449
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1450 static void incomingim_ch2_buddylist(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args, aim_bstream_t *servdata)
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1451 {
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1452
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1453 /*
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1454 * This goes like this...
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1455 *
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1456 * group name length
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1457 * group name
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1458 * num of buddies in group
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1459 * buddy name length
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1460 * buddy name
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1461 * buddy name length
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1462 * buddy name
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1463 * ...
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1464 * group name length
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1465 * group name
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1466 * num of buddies in group
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1467 * buddy name length
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1468 * buddy name
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1469 * ...
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1470 * ...
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1471 */
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1472 while (servdata && aim_bstream_empty(servdata)) {
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1473 fu16_t gnlen, numb;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1474 int i;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1475 char *gn;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1476
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1477 gnlen = aimbs_get16(servdata);
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1478 gn = aimbs_getstr(servdata, gnlen);
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1479 numb = aimbs_get16(servdata);
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1480
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1481 for (i = 0; i < numb; i++) {
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1482 fu16_t bnlen;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1483 char *bn;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1484
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1485 bnlen = aimbs_get16(servdata);
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1486 bn = aimbs_getstr(servdata, bnlen);
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1487
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1488 faimdprintf(sess, 0, "got a buddy list from %s: group %s, buddy %s\n", userinfo->sn, gn, bn);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1489
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1490 free(bn);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1491 }
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1492
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1493 free(gn);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1494 }
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1495
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1496 return;
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1497 }
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1498
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1499 static void incomingim_ch2_buddyicon_free(aim_session_t *sess, struct aim_incomingim_ch2_args *args)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1500 {
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1501
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1502 free(args->info.icon.icon);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1503
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1504 return;
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1505 }
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1506
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1507 static void incomingim_ch2_buddyicon(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args, aim_bstream_t *servdata)
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1508 {
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1509
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1510 if (servdata) {
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1511 args->info.icon.checksum = aimbs_get32(servdata);
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1512 args->info.icon.length = aimbs_get32(servdata);
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1513 args->info.icon.timestamp = aimbs_get32(servdata);
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1514 args->info.icon.icon = aimbs_getraw(servdata, args->info.icon.length);
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1515 }
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1516
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1517 args->destructor = (void *)incomingim_ch2_buddyicon_free;
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1518
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1519 return;
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1520 }
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1521
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1522 static void incomingim_ch2_chat_free(aim_session_t *sess, struct aim_incomingim_ch2_args *args)
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1523 {
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1524
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1525 /* XXX - aim_chat_roominfo_free() */
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1526 free(args->info.chat.roominfo.name);
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1527
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1528 return;
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1529 }
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1530
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1531 static void incomingim_ch2_chat(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args, aim_bstream_t *servdata)
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1532 {
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1533
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1534 /*
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1535 * Chat room info.
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1536 */
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1537 if (servdata)
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1538 aim_chat_readroominfo(servdata, &args->info.chat.roominfo);
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1539
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1540 args->destructor = (void *)incomingim_ch2_chat_free;
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1541
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1542 return;
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1543 }
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1544
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1545 static void incomingim_ch2_icqserverrelay_free(aim_session_t *sess, struct aim_incomingim_ch2_args *args)
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1546 {
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1547
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1548 free((char *)args->info.rtfmsg.rtfmsg);
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1549
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1550 return;
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1551 }
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1552
2866
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
1553 /*
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
1554 * The relationship between AIM_CAPS_ICQSERVERRELAY and AIM_CAPS_ICQRTF is
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
1555 * kind of odd. This sends the client ICQRTF since that is all that I've seen
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
1556 * SERVERRELAY used for.
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1557 *
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1558 * Note that this is all little-endian. Cringe.
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1559 *
2866
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
1560 */
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1561 static void incomingim_ch2_icqserverrelay(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args, aim_bstream_t *servdata)
2866
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
1562 {
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
1563 fu16_t hdrlen, anslen, msglen;
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
1564 fu16_t msgtype;
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
1565
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1566 hdrlen = aimbs_getle16(servdata);
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1567 aim_bstream_advance(servdata, hdrlen);
2866
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
1568
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1569 hdrlen = aimbs_getle16(servdata);
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1570 aim_bstream_advance(servdata, hdrlen);
2866
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
1571
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1572 msgtype = aimbs_getle16(servdata);
2866
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
1573
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1574 anslen = aimbs_getle32(servdata);
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1575 aim_bstream_advance(servdata, anslen);
2866
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
1576
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1577 msglen = aimbs_getle16(servdata);
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1578 args->info.rtfmsg.rtfmsg = aimbs_getstr(servdata, msglen);
2866
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
1579
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1580 args->info.rtfmsg.fgcolor = aimbs_getle32(servdata);
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1581 args->info.rtfmsg.bgcolor = aimbs_getle32(servdata);
2866
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
1582
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1583 hdrlen = aimbs_getle32(servdata);
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1584 aim_bstream_advance(servdata, hdrlen);
2866
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
1585
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1586 /* XXX - This is such a hack. */
2866
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
1587 args->reqclass = AIM_CAPS_ICQRTF;
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
1588
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1589 args->destructor = (void *)incomingim_ch2_icqserverrelay_free;
2866
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
1590
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1591 return;
2866
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
1592 }
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
1593
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3595
diff changeset
1594 static void incomingim_ch2_sendfile_free(aim_session_t *sess, struct aim_incomingim_ch2_args *args)
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3595
diff changeset
1595 {
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3595
diff changeset
1596 free(args->info.sendfile.filename);
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3595
diff changeset
1597 }
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3595
diff changeset
1598
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3595
diff changeset
1599 static void incomingim_ch2_sendfile(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args, aim_bstream_t *servdata)
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3595
diff changeset
1600 {
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3595
diff changeset
1601
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3595
diff changeset
1602 args->destructor = (void *)incomingim_ch2_sendfile_free;
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3595
diff changeset
1603
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1604 /* Maybe there is a better way to tell what kind of sendfile
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1605 * this is? Maybe TLV t(000a)? */
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1606 if (servdata) { /* Someone is sending us a file */
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
1607 int flen;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
1608
3771
765769211688 [gaim-migrate @ 3910]
Rob Flynn <gaim@robflynn.com>
parents: 3752
diff changeset
1609 /* subtype is one of AIM_OFT_SUBTYPE_* */
765769211688 [gaim-migrate @ 3910]
Rob Flynn <gaim@robflynn.com>
parents: 3752
diff changeset
1610 args->info.sendfile.subtype = aimbs_get16(servdata);
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3595
diff changeset
1611 args->info.sendfile.totfiles = aimbs_get16(servdata);
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3595
diff changeset
1612 args->info.sendfile.totsize = aimbs_get32(servdata);
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
1613
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1614 /*
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1615 * I hope to God I'm right when I guess that there is a
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1616 * 32 char max filename length for single files. I think
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1617 * OFT tends to do that. Gotta love inconsistency. I saw
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1618 * a 26 byte filename?
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1619 */
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1620 /* AAA - create an aimbs_getnullstr function (don't anymore)(maybe) */
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
1621 /* Use an inelegant way of getting the null-terminated filename,
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
1622 * since there's no easy bstream routine. */
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
1623 for (flen = 0; aimbs_get8(servdata); flen++);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
1624 aim_bstream_advance(servdata, -flen -1);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
1625 args->info.sendfile.filename = aimbs_getstr(servdata, flen);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
1626
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
1627 /* There is sometimes more after the null-terminated filename,
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
1628 * but I'm unsure of its format. */
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1629 /* I don't believe him. */
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3595
diff changeset
1630 }
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3595
diff changeset
1631
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3595
diff changeset
1632 return;
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3595
diff changeset
1633 }
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3595
diff changeset
1634
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1635 typedef void (*ch2_args_destructor_t)(aim_session_t *sess, struct aim_incomingim_ch2_args *args);
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1636
2421
95b4ec08abec [gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2341
diff changeset
1637 static int incomingim_ch2(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, fu16_t channel, aim_userinfo_t *userinfo, aim_tlvlist_t *tlvlist, fu8_t *cookie)
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1638 {
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1639 aim_rxcallback_t userfunc;
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1640 aim_tlv_t *block1, *servdatatlv;
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1641 aim_tlvlist_t *list2;
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1642 struct aim_incomingim_ch2_args args;
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1643 aim_bstream_t bbs, sdbs, *sdbsptr = NULL;
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1644 fu8_t *cookie2;
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1645 int ret = 0;
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1646
4898
bd37db7531e4 [gaim-migrate @ 5230]
Mark Doliner <mark@kingant.net>
parents: 4838
diff changeset
1647 char proxyip[30] = {""};
bd37db7531e4 [gaim-migrate @ 5230]
Mark Doliner <mark@kingant.net>
parents: 4838
diff changeset
1648 char clientip[30] = {""};
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1649 char verifiedip[30] = {""};
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1650
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1651 memset(&args, 0, sizeof(args));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1652
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1653 /*
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1654 * There's another block of TLVs embedded in the type 5 here.
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1655 */
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1656 block1 = aim_gettlv(tlvlist, 0x0005, 1);
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1657 aim_bstream_init(&bbs, block1->value, block1->length);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1658
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1659 /*
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1660 * First two bytes represent the status of the connection.
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1661 *
3771
765769211688 [gaim-migrate @ 3910]
Rob Flynn <gaim@robflynn.com>
parents: 3752
diff changeset
1662 * 0 is a request, 1 is a cancel, 2 is an accept
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1663 */
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1664 args.status = aimbs_get16(&bbs);
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1665
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1666 /*
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1667 * Next comes the cookie. Should match the ICBM cookie.
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1668 */
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1669 cookie2 = aimbs_getraw(&bbs, 8);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1670 if (memcmp(cookie, cookie2, 8) != 0)
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1671 faimdprintf(sess, 0, "rend: warning cookies don't match!\n");
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1672 memcpy(args.cookie, cookie2, 8);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1673 free(cookie2);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1674
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1675 /*
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1676 * The next 16bytes are a capability block so we can
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1677 * identify what type of rendezvous this is.
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1678 */
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1679 args.reqclass = aim_getcap(sess, &bbs, 0x10);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1680
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1681 /*
2196
016c5307f26b [gaim-migrate @ 2206]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
1682 * What follows may be TLVs or nothing, depending on the
016c5307f26b [gaim-migrate @ 2206]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
1683 * purpose of the message.
016c5307f26b [gaim-migrate @ 2206]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
1684 *
016c5307f26b [gaim-migrate @ 2206]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
1685 * Ack packets for instance have nothing more to them.
016c5307f26b [gaim-migrate @ 2206]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
1686 */
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1687 list2 = aim_readtlvchain(&bbs);
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1688
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1689 /*
4898
bd37db7531e4 [gaim-migrate @ 5230]
Mark Doliner <mark@kingant.net>
parents: 4838
diff changeset
1690 * IP address to proxy the file transfer through.
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1691 *
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1692 * XXX - I don't like this. Maybe just read in an int? Or inet_ntoa...
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1693 */
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1694 if (aim_gettlv(list2, 0x0002, 1)) {
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1695 aim_tlv_t *iptlv;
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1696
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1697 iptlv = aim_gettlv(list2, 0x0002, 1);
4901
ad589b887af9 [gaim-migrate @ 5235]
Mark Doliner <mark@kingant.net>
parents: 4898
diff changeset
1698 if (iptlv->length == 4)
ad589b887af9 [gaim-migrate @ 5235]
Mark Doliner <mark@kingant.net>
parents: 4898
diff changeset
1699 snprintf(proxyip, sizeof(proxyip), "%hhd.%hhd.%hhd.%hhd",
ad589b887af9 [gaim-migrate @ 5235]
Mark Doliner <mark@kingant.net>
parents: 4898
diff changeset
1700 iptlv->value[0], iptlv->value[1],
ad589b887af9 [gaim-migrate @ 5235]
Mark Doliner <mark@kingant.net>
parents: 4898
diff changeset
1701 iptlv->value[2], iptlv->value[3]);
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1702 }
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1703
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1704 /*
4898
bd37db7531e4 [gaim-migrate @ 5230]
Mark Doliner <mark@kingant.net>
parents: 4838
diff changeset
1705 * IP address from the perspective of the client.
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1706 */
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1707 if (aim_gettlv(list2, 0x0003, 1)) {
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1708 aim_tlv_t *iptlv;
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1709
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1710 iptlv = aim_gettlv(list2, 0x0003, 1);
4901
ad589b887af9 [gaim-migrate @ 5235]
Mark Doliner <mark@kingant.net>
parents: 4898
diff changeset
1711 if (iptlv->length == 4)
ad589b887af9 [gaim-migrate @ 5235]
Mark Doliner <mark@kingant.net>
parents: 4898
diff changeset
1712 snprintf(clientip, sizeof(clientip), "%hhd.%hhd.%hhd.%hhd",
ad589b887af9 [gaim-migrate @ 5235]
Mark Doliner <mark@kingant.net>
parents: 4898
diff changeset
1713 iptlv->value[0], iptlv->value[1],
ad589b887af9 [gaim-migrate @ 5235]
Mark Doliner <mark@kingant.net>
parents: 4898
diff changeset
1714 iptlv->value[2], iptlv->value[3]);
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1715 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1716
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1717 /*
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1718 * Verified IP address (from the perspective of Oscar).
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1719 *
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1720 * This is added by the server.
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1721 */
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1722 if (aim_gettlv(list2, 0x0004, 1)) {
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1723 aim_tlv_t *iptlv;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1724
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1725 iptlv = aim_gettlv(list2, 0x0004, 1);
4901
ad589b887af9 [gaim-migrate @ 5235]
Mark Doliner <mark@kingant.net>
parents: 4898
diff changeset
1726 if (iptlv->length == 4)
ad589b887af9 [gaim-migrate @ 5235]
Mark Doliner <mark@kingant.net>
parents: 4898
diff changeset
1727 snprintf(verifiedip, sizeof(verifiedip), "%hhd.%hhd.%hhd.%hhd",
ad589b887af9 [gaim-migrate @ 5235]
Mark Doliner <mark@kingant.net>
parents: 4898
diff changeset
1728 iptlv->value[0], iptlv->value[1],
ad589b887af9 [gaim-migrate @ 5235]
Mark Doliner <mark@kingant.net>
parents: 4898
diff changeset
1729 iptlv->value[2], iptlv->value[3]);
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1730 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1731
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1732 /*
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1733 * Port number for something.
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1734 */
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1735 if (aim_gettlv(list2, 0x0005, 1))
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1736 args.port = aim_gettlv16(list2, 0x0005, 1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1737
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1738 /*
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1739 * Something to do with ft -- two bytes
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1740 * 0x0001 - "I want to send you this file"
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1741 * 0x0002 - "I will accept this file from you"
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1742 */
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1743 if (aim_gettlv(list2, 0x000a, 1))
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1744 ;
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1745
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1746 /*
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1747 * Error code.
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1748 */
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1749 if (aim_gettlv(list2, 0x000b, 1))
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1750 args.errorcode = aim_gettlv16(list2, 0x000b, 1);
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1751
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1752 /*
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1753 * Invitation message / chat description.
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1754 */
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1755 if (aim_gettlv(list2, 0x000c, 1))
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1756 args.msg = aim_gettlv_str(list2, 0x000c, 1);
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1757
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1758 /*
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1759 * Character set.
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1760 */
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1761 if (aim_gettlv(list2, 0x000d, 1))
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1762 args.encoding = aim_gettlv_str(list2, 0x000d, 1);
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1763
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1764 /*
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1765 * Language.
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1766 */
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1767 if (aim_gettlv(list2, 0x000e, 1))
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1768 args.language = aim_gettlv_str(list2, 0x000e, 1);
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1769
4898
bd37db7531e4 [gaim-migrate @ 5230]
Mark Doliner <mark@kingant.net>
parents: 4838
diff changeset
1770 /*
bd37db7531e4 [gaim-migrate @ 5230]
Mark Doliner <mark@kingant.net>
parents: 4838
diff changeset
1771 * Unknown -- no value
bd37db7531e4 [gaim-migrate @ 5230]
Mark Doliner <mark@kingant.net>
parents: 4838
diff changeset
1772 */
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1773 if (aim_gettlv(list2, 0x000f, 1))
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1774 ;
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1775
4898
bd37db7531e4 [gaim-migrate @ 5230]
Mark Doliner <mark@kingant.net>
parents: 4838
diff changeset
1776 /*
bd37db7531e4 [gaim-migrate @ 5230]
Mark Doliner <mark@kingant.net>
parents: 4838
diff changeset
1777 * Unknown -- no value
bd37db7531e4 [gaim-migrate @ 5230]
Mark Doliner <mark@kingant.net>
parents: 4838
diff changeset
1778 *
bd37db7531e4 [gaim-migrate @ 5230]
Mark Doliner <mark@kingant.net>
parents: 4838
diff changeset
1779 * Maybe means we should proxy the file transfer through an AIM server?
bd37db7531e4 [gaim-migrate @ 5230]
Mark Doliner <mark@kingant.net>
parents: 4838
diff changeset
1780 */
bd37db7531e4 [gaim-migrate @ 5230]
Mark Doliner <mark@kingant.net>
parents: 4838
diff changeset
1781 if (aim_gettlv(list2, 0x0010, 1))
bd37db7531e4 [gaim-migrate @ 5230]
Mark Doliner <mark@kingant.net>
parents: 4838
diff changeset
1782 ;
bd37db7531e4 [gaim-migrate @ 5230]
Mark Doliner <mark@kingant.net>
parents: 4838
diff changeset
1783
bd37db7531e4 [gaim-migrate @ 5230]
Mark Doliner <mark@kingant.net>
parents: 4838
diff changeset
1784 if (strlen(proxyip))
bd37db7531e4 [gaim-migrate @ 5230]
Mark Doliner <mark@kingant.net>
parents: 4838
diff changeset
1785 args.proxyip = (char *)proxyip;
bd37db7531e4 [gaim-migrate @ 5230]
Mark Doliner <mark@kingant.net>
parents: 4838
diff changeset
1786 if (strlen(clientip))
bd37db7531e4 [gaim-migrate @ 5230]
Mark Doliner <mark@kingant.net>
parents: 4838
diff changeset
1787 args.clientip = (char *)clientip;
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1788 if (strlen(verifiedip))
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1789 args.verifiedip = (char *)verifiedip;
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1790
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1791 /*
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1792 * This must be present in PROPOSALs, but will probably not
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1793 * exist in CANCELs and ACCEPTs.
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1794 *
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1795 * Service Data blocks are module-specific in format.
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1796 */
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1797 if ((servdatatlv = aim_gettlv(list2, 0x2711 /* 10001 */, 1))) {
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1798
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1799 aim_bstream_init(&sdbs, servdatatlv->value, servdatatlv->length);
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1800 sdbsptr = &sdbs;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1801 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1802
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1803 /*
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1804 * The rest of the handling depends on what type it is.
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1805 *
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1806 * Not all of them have special handling (yet).
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1807 */
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1808 if (args.reqclass & AIM_CAPS_BUDDYICON)
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1809 incomingim_ch2_buddyicon(sess, mod, rx, snac, userinfo, &args, sdbsptr);
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1810 else if (args.reqclass & AIM_CAPS_SENDBUDDYLIST)
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1811 incomingim_ch2_buddylist(sess, mod, rx, snac, userinfo, &args, sdbsptr);
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1812 else if (args.reqclass & AIM_CAPS_CHAT)
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1813 incomingim_ch2_chat(sess, mod, rx, snac, userinfo, &args, sdbsptr);
2866
6d62d4520460 [gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2808
diff changeset
1814 else if (args.reqclass & AIM_CAPS_ICQSERVERRELAY)
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1815 incomingim_ch2_icqserverrelay(sess, mod, rx, snac, userinfo, &args, sdbsptr);
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3595
diff changeset
1816 else if (args.reqclass & AIM_CAPS_SENDFILE)
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3595
diff changeset
1817 incomingim_ch2_sendfile(sess, mod, rx, snac, userinfo, &args, sdbsptr);
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1818
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1819
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1820 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1821 ret = userfunc(sess, rx, channel, userinfo, &args);
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1822
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1823
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1824 if (args.destructor)
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1825 ((ch2_args_destructor_t)args.destructor)(sess, &args);
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1826
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1827 free((char *)args.msg);
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1828 free((char *)args.encoding);
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1829 free((char *)args.language);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1830
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1831 aim_freetlvchain(&list2);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1832
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1833 return ret;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1834 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1835
3141
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1836 static int incomingim_ch4(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, fu16_t channel, aim_userinfo_t *userinfo, aim_tlvlist_t *tlvlist, fu8_t *cookie)
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1837 {
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1838 aim_bstream_t meat;
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1839 aim_rxcallback_t userfunc;
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1840 aim_tlv_t *block;
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1841 struct aim_incomingim_ch4_args args;
3159
fce1883cc608 [gaim-migrate @ 3175]
Sean Egan <seanegan@gmail.com>
parents: 3141
diff changeset
1842 int ret = 0;
3141
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1843
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1844 /*
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1845 * Make a bstream for the meaty part. Yum. Meat.
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1846 */
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1847 if (!(block = aim_gettlv(tlvlist, 0x0005, 1)))
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1848 return -1;
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1849 aim_bstream_init(&meat, block->value, block->length);
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1850
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1851 args.uin = aimbs_getle32(&meat);
4173
b66f960bfe60 [gaim-migrate @ 4403]
Mark Doliner <mark@kingant.net>
parents: 4154
diff changeset
1852 args.type = aimbs_getle8(&meat);
b66f960bfe60 [gaim-migrate @ 4403]
Mark Doliner <mark@kingant.net>
parents: 4154
diff changeset
1853 args.flags = aimbs_getle8(&meat);
4076
91c4bd698d39 [gaim-migrate @ 4291]
Mark Doliner <mark@kingant.net>
parents: 4071
diff changeset
1854 args.msglen = aimbs_getle16(&meat);
91c4bd698d39 [gaim-migrate @ 4291]
Mark Doliner <mark@kingant.net>
parents: 4071
diff changeset
1855 args.msg = aimbs_getraw(&meat, args.msglen);
3141
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1856
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1857 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1858 ret = userfunc(sess, rx, channel, userinfo, &args);
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1859
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1860 free(args.msg);
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1861
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1862 return ret;
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1863 }
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1864
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1865 /*
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
1866 * Subtype 0x0007
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
1867 *
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1868 * It can easily be said that parsing ICBMs is THE single
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1869 * most difficult thing to do in the in AIM protocol. In
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1870 * fact, I think I just did say that.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1871 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1872 * Below is the best damned solution I've come up with
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1873 * over the past sixteen months of battling with it. This
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1874 * can parse both away and normal messages from every client
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1875 * I have access to. Its not fast, its not clean. But it works.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1876 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1877 */
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1878 static int incomingim(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1879 {
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1880 int i, ret = 0;
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1881 fu8_t cookie[8];
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1882 fu16_t channel;
2421
95b4ec08abec [gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2341
diff changeset
1883 aim_userinfo_t userinfo;
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1884
2421
95b4ec08abec [gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2341
diff changeset
1885 memset(&userinfo, 0x00, sizeof(aim_userinfo_t));
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1886
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1887 /*
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1888 * Read ICBM Cookie. And throw away.
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1889 */
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1890 for (i = 0; i < 8; i++)
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1891 cookie[i] = aimbs_get8(bs);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1892
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1893 /*
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1894 * Channel ID.
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1895 *
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1896 * Channel 0x0001 is the message channel. It is
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1897 * used to send basic ICBMs.
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1898 *
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1899 * Channel 0x0002 is the Rendevous channel, which
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1900 * is where Chat Invitiations and various client-client
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1901 * connection negotiations come from.
3141
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1902 *
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1903 * Channel 0x0003 is used for chat messages.
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1904 *
3141
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1905 * Channel 0x0004 is used for ICQ authorization, or
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1906 * possibly any system notice.
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1907 *
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1908 */
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1909 channel = aimbs_get16(bs);
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1910
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1911 /*
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1912 * Extract the standard user info block.
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1913 *
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1914 * Note that although this contains TLVs that appear contiguous
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1915 * with the TLVs read below, they are two different pieces. The
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1916 * userinfo block contains the number of TLVs that contain user
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1917 * information, the rest are not even though there is no seperation.
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1918 * aim_extractuserinfo() returns the number of bytes used by the
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1919 * userinfo tlvs, so you can start reading the rest of them right
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1920 * afterward.
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1921 *
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1922 * That also means that TLV types can be duplicated between the
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1923 * userinfo block and the rest of the message, however there should
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1924 * never be two TLVs of the same type in one block.
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1925 *
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1926 */
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1927 aim_extractuserinfo(sess, bs, &userinfo);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1928
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1929 /*
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1930 * From here on, its depends on what channel we're on.
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1931 *
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1932 * Technically all channels have a TLV list have this, however,
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1933 * for the common channel 1 case, in-place parsing is used for
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1934 * performance reasons (less memory allocation).
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1935 */
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1936 if (channel == 1) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1937
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1938 ret = incomingim_ch1(sess, mod, rx, snac, channel, &userinfo, bs, cookie);
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1939
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1940 } else if (channel == 2) {
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1941 aim_tlvlist_t *tlvlist;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1942
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1943 /*
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1944 * Read block of TLVs (not including the userinfo data). All
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1945 * further data is derived from what is parsed here.
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1946 */
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
1947 tlvlist = aim_readtlvchain(bs);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1948
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1949 ret = incomingim_ch2(sess, mod, rx, snac, channel, &userinfo, tlvlist, cookie);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1950
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1951 aim_freetlvchain(&tlvlist);
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1952
3141
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1953 } else if (channel == 4) {
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1954 aim_tlvlist_t *tlvlist;
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1955
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1956 tlvlist = aim_readtlvchain(bs);
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1957 ret = incomingim_ch4(sess, mod, rx, snac, channel, &userinfo, tlvlist, cookie);
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1958 aim_freetlvchain(&tlvlist);
bcdbffc2c3e6 [gaim-migrate @ 3156]
Rob Flynn <gaim@robflynn.com>
parents: 2869
diff changeset
1959
2507
1069b0940237 [gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2421
diff changeset
1960 } else {
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1961
2507
1069b0940237 [gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2421
diff changeset
1962 faimdprintf(sess, 0, "icbm: ICBM received on an unsupported channel. Ignoring.\n (chan = %04x)", channel);
2869
9b029055cfba [gaim-migrate @ 2882]
Adam Fritzler <mid@auk.cx>
parents: 2866
diff changeset
1963
2507
1069b0940237 [gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2421
diff changeset
1964 return 0;
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1965 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1966
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
1967 return ret;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1968 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1969
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1970 /*
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1971 * Subtype 0x0008 - Send a warning to sn.
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
1972 *
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
1973 * Flags:
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
1974 * AIM_WARN_ANON Send as an anonymous (doesn't count as much)
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
1975 *
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
1976 * returns -1 on error (couldn't alloc packet), 0 on success.
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
1977 *
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
1978 */
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1979 faim_export int aim_im_warn(aim_session_t *sess, aim_conn_t *conn, const char *sn, fu32_t flags)
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
1980 {
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
1981 aim_frame_t *fr;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
1982 aim_snacid_t snacid;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
1983
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1984 if (!sess || !conn || !sn)
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1985 return -EINVAL;
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1986
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1987 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, strlen(sn)+13)))
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
1988 return -ENOMEM;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
1989
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1990 snacid = aim_cachesnac(sess, 0x0004, 0x0008, 0x0000, sn, strlen(sn)+1);
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
1991 aim_putsnac(&fr->data, 0x0004, 0x0008, 0x0000, snacid);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
1992
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1993 aimbs_put16(&fr->data, (flags & AIM_WARN_ANON) ? 0x0001 : 0x0000);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1994 aimbs_put8(&fr->data, strlen(sn));
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
1995 aimbs_putraw(&fr->data, sn, strlen(sn));
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
1996
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
1997 aim_tx_enqueue(sess, fr);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
1998
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
1999 return 0;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2000 }
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2001
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2002 /* Subtype 0x000a */
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2003 static int missedcall(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2004 {
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2005 int ret = 0;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2006 aim_rxcallback_t userfunc;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2007 fu16_t channel, nummissed, reason;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2008 aim_userinfo_t userinfo;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2009
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2010 while (aim_bstream_empty(bs)) {
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2011
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2012 channel = aimbs_get16(bs);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2013 aim_extractuserinfo(sess, bs, &userinfo);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2014 nummissed = aimbs_get16(bs);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2015 reason = aimbs_get16(bs);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2016
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2017 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2018 ret = userfunc(sess, rx, channel, &userinfo, nummissed, reason);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2019 }
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2020
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2021 return ret;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2022 }
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2023
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2024 /*
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2025 * Subtype 0x000b
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2026 *
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2027 * Possible codes:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2028 * AIM_TRANSFER_DENY_NOTSUPPORTED -- "client does not support"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2029 * AIM_TRANSFER_DENY_DECLINE -- "client has declined transfer"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2030 * AIM_TRANSFER_DENY_NOTACCEPTING -- "client is not accepting transfers"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2031 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2032 */
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
2033 faim_export int aim_im_denytransfer(aim_session_t *sess, const char *sender, const char *cookie, fu16_t code)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2034 {
2673
81d658e6ac1e [gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2672
diff changeset
2035 aim_conn_t *conn;
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2036 aim_frame_t *fr;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2037 aim_snacid_t snacid;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2038 aim_tlvlist_t *tl = NULL;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2039
2673
81d658e6ac1e [gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2672
diff changeset
2040 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004)))
81d658e6ac1e [gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2672
diff changeset
2041 return -EINVAL;
81d658e6ac1e [gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2672
diff changeset
2042
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2043 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+8+2+1+strlen(sender)+6)))
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
2044 return -ENOMEM;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2045
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2046 snacid = aim_cachesnac(sess, 0x0004, 0x000b, 0x0000, NULL, 0);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2047 aim_putsnac(&fr->data, 0x0004, 0x000b, 0x0000, snacid);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2048
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2049 aimbs_putraw(&fr->data, cookie, 8);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2050
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2051 aimbs_put16(&fr->data, 0x0002); /* channel */
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2052 aimbs_put8(&fr->data, strlen(sender));
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2053 aimbs_putraw(&fr->data, sender, strlen(sender));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2054
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2055 aim_addtlvtochain16(&tl, 0x0003, code);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2056 aim_writetlvchain(&fr->data, &tl);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2057 aim_freetlvchain(&tl);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2058
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2059 aim_tx_enqueue(sess, fr);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2060
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
2061 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2062 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2063
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2064 /*
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2065 * Subtype 0x000b - Receive the response from an ICQ status message request.
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2066 *
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2067 * This contains the ICQ status message. Go figure.
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2068 *
3212
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
2069 */
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
2070 static int clientautoresp(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2071 {
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2072 int ret = 0;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2073 aim_rxcallback_t userfunc;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2074 fu16_t channel, reason;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2075 char *sn;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2076 fu8_t *ck, snlen;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2077
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2078 ck = aimbs_getraw(bs, 8);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2079 channel = aimbs_get16(bs);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2080 snlen = aimbs_get8(bs);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2081 sn = aimbs_getstr(bs, snlen);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2082 reason = aimbs_get16(bs);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2083
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2084 if (channel == 0x0002) { /* File transfer declined */
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
2085 aimbs_get16(bs); /* Unknown */
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
2086 aimbs_get16(bs); /* Unknown */
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3595
diff changeset
2087 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3595
diff changeset
2088 ret = userfunc(sess, rx, channel, sn, reason, ck);
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2089 } else if (channel == 0x0004) { /* ICQ message */
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2090 switch (reason) {
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2091 case 0x0003: { /* ICQ status message. Maybe other stuff too, you never know with these people. */
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2092 fu8_t statusmsgtype, *msg;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2093 fu16_t len;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2094 fu32_t state;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2095
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2096 len = aimbs_getle16(bs); /* Should be 0x001b */
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2097 aim_bstream_advance(bs, len); /* Unknown */
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2098
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2099 len = aimbs_getle16(bs); /* Should be 0x000e */
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2100 aim_bstream_advance(bs, len); /* Unknown */
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2101
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2102 statusmsgtype = aimbs_getle8(bs);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2103 switch (statusmsgtype) {
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2104 case 0xe8:
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2105 state = AIM_ICQ_STATE_AWAY;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2106 break;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2107 case 0xe9:
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2108 state = AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2109 break;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2110 case 0xea:
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2111 state = AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_OUT;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2112 break;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2113 case 0xeb:
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2114 state = AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2115 break;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2116 case 0xec:
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2117 state = AIM_ICQ_STATE_CHAT;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2118 break;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2119 default:
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2120 state = 0;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2121 break;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2122 }
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2123
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2124 aimbs_getle8(bs); /* Unknown - 0x03 Maybe this means this is an auto-reply */
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2125 aimbs_getle16(bs); /* Unknown - 0x0000 */
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2126 aimbs_getle16(bs); /* Unknown - 0x0000 */
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2127
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2128 len = aimbs_getle16(bs);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2129 msg = aimbs_getraw(bs, len);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2130
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2131 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2132 ret = userfunc(sess, rx, channel, sn, reason, state, msg);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2133
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2134 free(msg);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2135 } break;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2136
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2137 default: {
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2138 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2139 ret = userfunc(sess, rx, channel, sn, reason);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2140 } break;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2141 } /* end switch */
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3595
diff changeset
2142 }
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3595
diff changeset
2143
2341
5486d558ecee [gaim-migrate @ 2354]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2315
diff changeset
2144 free(ck);
5486d558ecee [gaim-migrate @ 2354]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2315
diff changeset
2145 free(sn);
5486d558ecee [gaim-migrate @ 2354]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2315
diff changeset
2146
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2147 return ret;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2148 }
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2149
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
2150 /*
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
2151 * Subtype 0x000c - Receive an ack after sending an ICBM.
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
2152 *
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
2153 * You have to have send the message with the AIM_IMFLAGS_ACK flag set
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
2154 * (TLV t(0003)). The ack contains the ICBM header of the message you
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
2155 * sent.
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
2156 *
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
2157 */
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2158 static int msgack(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2159 {
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
2160 aim_rxcallback_t userfunc;
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
2161 fu16_t ch;
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
2162 fu8_t *ck;
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2163 char *sn;
2341
5486d558ecee [gaim-migrate @ 2354]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2315
diff changeset
2164 int ret = 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2165
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2166 ck = aimbs_getraw(bs, 8);
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
2167 ch = aimbs_get16(bs);
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
2168 sn = aimbs_getstr(bs, aimbs_get8(bs));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2169
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
2170 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
2171 ret = userfunc(sess, rx, ch, sn);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2172
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2173 free(sn);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2174 free(ck);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2175
2341
5486d558ecee [gaim-migrate @ 2354]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2315
diff changeset
2176 return ret;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2177 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2178
3595
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2179 /*
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2180 * Subtype 0x0014 - Send a mini typing notification (mtn) packet.
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2181 *
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2182 * This is supported by winaim5 and newer, MacAIM bleh and newer, iChat bleh and newer,
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2183 * and Gaim 0.60 and newer.
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2184 *
3595
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2185 */
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
2186 faim_export int aim_im_sendmtn(aim_session_t *sess, fu16_t type1, char *sn, fu16_t type2)
3595
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2187 {
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2188 aim_conn_t *conn;
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2189 aim_frame_t *fr;
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2190 aim_snacid_t snacid;
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2191
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2192 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0002)))
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2193 return -EINVAL;
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2194
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2195 if (!sn)
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2196 return -EINVAL;
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2197
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2198 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+11+strlen(sn)+2)))
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2199 return -ENOMEM;
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2200
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2201 snacid = aim_cachesnac(sess, 0x0004, 0x0014, 0x0000, NULL, 0);
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2202 aim_putsnac(&fr->data, 0x0004, 0x0014, 0x0000, snacid);
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2203
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2204 /*
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2205 * 8 days of light
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2206 * Er, that is to say, 8 bytes of 0's
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2207 */
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2208 aimbs_put16(&fr->data, 0x0000);
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2209 aimbs_put16(&fr->data, 0x0000);
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2210 aimbs_put16(&fr->data, 0x0000);
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2211 aimbs_put16(&fr->data, 0x0000);
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2212
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2213 /*
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2214 * Type 1 (should be 0x0001 for mtn)
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2215 */
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2216 aimbs_put16(&fr->data, type1);
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2217
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2218 /*
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2219 * Dest sn
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2220 */
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2221 aimbs_put8(&fr->data, strlen(sn));
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2222 aimbs_putraw(&fr->data, sn, strlen(sn));
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2223
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2224 /*
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2225 * Type 2 (should be 0x0000, 0x0001, or 0x0002 for mtn)
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2226 */
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2227 aimbs_put16(&fr->data, type2);
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2228
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2229 aim_tx_enqueue(sess, fr);
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2230
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2231 return 0;
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2232 }
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2233
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2234 /*
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2235 * Subtype 0x0014 - Receive a mini typing notification (mtn) packet.
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2236 *
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2237 * This is supported by winaim5 and newer, MacAIM bleh and newer, iChat bleh and newer,
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2238 * and Gaim 0.60 and newer.
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 3771
diff changeset
2239 *
3595
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2240 */
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2241 static int mtn_receive(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2242 {
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2243 int ret = 0;
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2244 aim_rxcallback_t userfunc;
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2245 char *sn;
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2246 fu8_t snlen;
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2247 fu16_t type1, type2;
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2248
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2249 aim_bstream_advance(bs, 8); /* Unknown - All 0's */
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2250 type1 = aimbs_get16(bs);
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2251 snlen = aimbs_get8(bs);
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2252 sn = aimbs_getstr(bs, snlen);
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2253 type2 = aimbs_get16(bs);
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2254
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2255 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2256 ret = userfunc(sess, rx, type1, sn, type2);
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2257
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2258 free(sn);
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2259
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2260 return ret;
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2261 }
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2262
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2263 static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2264 {
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2265
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2266 if (snac->subtype == 0x0005)
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4173
diff changeset
2267 return aim_im_paraminfo(sess, mod, rx, snac, bs);
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2268 else if (snac->subtype == 0x0006)
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2269 return outgoingim(sess, mod, rx, snac, bs);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2270 else if (snac->subtype == 0x0007)
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2271 return incomingim(sess, mod, rx, snac, bs);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2272 else if (snac->subtype == 0x000a)
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2273 return missedcall(sess, mod, rx, snac, bs);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2274 else if (snac->subtype == 0x000b)
3212
56746b0868db [gaim-migrate @ 3229]
Sean Egan <seanegan@gmail.com>
parents: 3159
diff changeset
2275 return clientautoresp(sess, mod, rx, snac, bs);
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2276 else if (snac->subtype == 0x000c)
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2277 return msgack(sess, mod, rx, snac, bs);
3595
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2278 else if (snac->subtype == 0x0014)
1e60a05c7482 [gaim-migrate @ 3697]
Mark Doliner <mark@kingant.net>
parents: 3255
diff changeset
2279 return mtn_receive(sess, mod, rx, snac, bs);
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2280
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2281 return 0;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2282 }
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2283
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2196
diff changeset
2284 faim_internal int msg_modfirst(aim_session_t *sess, aim_module_t *mod)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2285 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2286
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
2287 mod->family = 0x0004;
2672
c41030cfed76 [gaim-migrate @ 2685]
Adam Fritzler <mid@auk.cx>
parents: 2639
diff changeset
2288 mod->version = 0x0001;
c41030cfed76 [gaim-migrate @ 2685]
Adam Fritzler <mid@auk.cx>
parents: 2639
diff changeset
2289 mod->toolid = 0x0110;
4071
2532f1192da3 [gaim-migrate @ 4283]
Mark Doliner <mark@kingant.net>
parents: 3952
diff changeset
2290 mod->toolversion = 0x0629;
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
2291 mod->flags = 0;
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
2292 strncpy(mod->name, "messaging", sizeof(mod->name));
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
2293 mod->snachandler = snachandler;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2294
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2122
diff changeset
2295 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2296 }