Mercurial > pidgin
annotate src/protocols/oscar/chat.c @ 12486:5b9ae793e2fb
[gaim-migrate @ 14798]
Stu is one smart young whipper snapper.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 14 Dec 2005 22:53:54 +0000 |
parents | 59207955adc2 |
children |
rev | line source |
---|---|
2086 | 1 /* |
3952 | 2 * Family 0x000e - Routines for the Chat service. |
2086 | 3 * |
4 */ | |
5 | |
6 #define FAIM_INTERNAL | |
10271 | 7 #include <aim.h> |
2086 | 8 |
5927 | 9 #include <string.h> |
10 | |
11074 | 11 /* Stored in the ->internal of chat connections */ |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
12 struct chatconnpriv { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
13 fu16_t exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
14 char *name; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
15 fu16_t instance; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
16 }; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
17 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
18 faim_internal void aim_conn_kill_chat(aim_session_t *sess, aim_conn_t *conn) |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
19 { |
11074 | 20 struct chatconnpriv *ccp = (struct chatconnpriv *)conn->internal; |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
21 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
22 if (ccp) |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
23 free(ccp->name); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
24 free(ccp); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
25 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
26 return; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
27 } |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
28 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
29 faim_export char *aim_chat_getname(aim_conn_t *conn) |
2086 | 30 { |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
31 struct chatconnpriv *ccp; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
32 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
33 if (!conn) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
34 return NULL; |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
35 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
36 if (conn->type != AIM_CONN_TYPE_CHAT) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
37 return NULL; |
2086 | 38 |
11074 | 39 ccp = (struct chatconnpriv *)conn->internal; |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
40 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
41 return ccp->name; |
2086 | 42 } |
43 | |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
44 /* XXX get this into conn.c -- evil!! */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
45 faim_export aim_conn_t *aim_chat_getconn(aim_session_t *sess, const char *name) |
2086 | 46 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
47 aim_conn_t *cur; |
2086 | 48 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
49 for (cur = sess->connlist; cur; cur = cur->next) { |
11074 | 50 struct chatconnpriv *ccp = (struct chatconnpriv *)cur->internal; |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
51 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
52 if (cur->type != AIM_CONN_TYPE_CHAT) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
53 continue; |
11074 | 54 if (!cur->internal) { |
11253 | 55 gaim_debug_misc("oscar", "faim: chat: chat connection with no name! (fd = %d)\n", cur->fd); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
56 continue; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
57 } |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
58 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
59 if (strcmp(ccp->name, name) == 0) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
60 break; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
61 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
62 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
63 return cur; |
2086 | 64 } |
65 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
66 faim_export int aim_chat_attachname(aim_conn_t *conn, fu16_t exchange, const char *roomname, fu16_t instance) |
2086 | 67 { |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
68 struct chatconnpriv *ccp; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
69 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
70 if (!conn || !roomname) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
71 return -EINVAL; |
2086 | 72 |
11074 | 73 if (conn->internal) |
74 free(conn->internal); | |
2086 | 75 |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
76 if (!(ccp = malloc(sizeof(struct chatconnpriv)))) |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
77 return -ENOMEM; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
78 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
79 ccp->exchange = exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
80 ccp->name = strdup(roomname); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
81 ccp->instance = instance; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
82 |
11074 | 83 conn->internal = (void *)ccp; |
2086 | 84 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
85 return 0; |
2086 | 86 } |
87 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
88 faim_internal int aim_chat_readroominfo(aim_bstream_t *bs, struct aim_chat_roominfo *outinfo) |
2086 | 89 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
90 int namelen; |
2086 | 91 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
92 if (!bs || !outinfo) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
93 return 0; |
2086 | 94 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
95 outinfo->exchange = aimbs_get16(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
96 namelen = aimbs_get8(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
97 outinfo->name = aimbs_getstr(bs, namelen); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
98 outinfo->instance = aimbs_get16(bs); |
2086 | 99 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
100 return 0; |
2086 | 101 } |
102 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
103 faim_export int aim_chat_leaveroom(aim_session_t *sess, const char *name) |
2086 | 104 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
105 aim_conn_t *conn; |
2086 | 106 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
107 if (!(conn = aim_chat_getconn(sess, name))) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
108 return -ENOENT; |
2086 | 109 |
10271 | 110 aim_conn_close(conn); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
111 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
112 return 0; |
2086 | 113 } |
114 | |
115 /* | |
3952 | 116 * Subtype 0x0002 - General room information. Lots of stuff. |
2086 | 117 * |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8283
diff
changeset
|
118 * Values I know are in here but I haven't attached |
2086 | 119 * them to any of the 'Unknown's: |
120 * - Language (English) | |
121 * | |
122 */ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
123 static int infoupdate(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
2086 | 124 { |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2270
diff
changeset
|
125 aim_userinfo_t *userinfo = NULL; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
126 aim_rxcallback_t userfunc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
127 int ret = 0; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
128 int usercount = 0; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
129 fu8_t detaillevel = 0; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
130 char *roomname = NULL; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
131 struct aim_chat_roominfo roominfo; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
132 fu16_t tlvcount = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
133 aim_tlvlist_t *tlvlist; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
134 char *roomdesc = NULL; |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
135 fu16_t flags = 0; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
136 fu32_t creationtime = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
137 fu16_t maxmsglen = 0, maxvisiblemsglen = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
138 fu16_t unknown_d2 = 0, unknown_d5 = 0; |
2086 | 139 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
140 aim_chat_readroominfo(bs, &roominfo); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
141 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
142 detaillevel = aimbs_get8(bs); |
2086 | 143 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
144 if (detaillevel != 0x02) { |
11253 | 145 gaim_debug_misc("oscar", "faim: chat_roomupdateinfo: detail level %d not supported\n", detaillevel); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
146 return 1; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
147 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
148 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
149 tlvcount = aimbs_get16(bs); |
2086 | 150 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
151 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
152 * Everything else are TLVs. |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
153 */ |
7167 | 154 tlvlist = aim_tlvlist_read(bs); |
2086 | 155 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
156 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
157 * TLV type 0x006a is the room name in Human Readable Form. |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
158 */ |
7167 | 159 if (aim_tlv_gettlv(tlvlist, 0x006a, 1)) |
160 roomname = aim_tlv_getstr(tlvlist, 0x006a, 1); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
161 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
162 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
163 * Type 0x006f: Number of occupants. |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
164 */ |
7167 | 165 if (aim_tlv_gettlv(tlvlist, 0x006f, 1)) |
166 usercount = aim_tlv_get16(tlvlist, 0x006f, 1); | |
2086 | 167 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
168 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
169 * Type 0x0073: Occupant list. |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
170 */ |
7167 | 171 if (aim_tlv_gettlv(tlvlist, 0x0073, 1)) { |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
172 int curoccupant = 0; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
173 aim_tlv_t *tmptlv; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
174 aim_bstream_t occbs; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
175 |
7167 | 176 tmptlv = aim_tlv_gettlv(tlvlist, 0x0073, 1); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
177 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
178 /* Allocate enough userinfo structs for all occupants */ |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2270
diff
changeset
|
179 userinfo = calloc(usercount, sizeof(aim_userinfo_t)); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
180 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
181 aim_bstream_init(&occbs, tmptlv->value, tmptlv->length); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
182 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
183 while (curoccupant < usercount) |
5836 | 184 aim_info_extract(sess, &occbs, &userinfo[curoccupant++]); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
185 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
186 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
187 /* |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
188 * Type 0x00c9: Flags. (AIM_CHATROOM_FLAG) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
189 */ |
7167 | 190 if (aim_tlv_gettlv(tlvlist, 0x00c9, 1)) |
191 flags = aim_tlv_get16(tlvlist, 0x00c9, 1); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
192 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
193 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
194 * Type 0x00ca: Creation time (4 bytes) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
195 */ |
7167 | 196 if (aim_tlv_gettlv(tlvlist, 0x00ca, 1)) |
197 creationtime = aim_tlv_get32(tlvlist, 0x00ca, 1); | |
2086 | 198 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
199 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
200 * Type 0x00d1: Maximum Message Length |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
201 */ |
7167 | 202 if (aim_tlv_gettlv(tlvlist, 0x00d1, 1)) |
203 maxmsglen = aim_tlv_get16(tlvlist, 0x00d1, 1); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
204 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
205 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
206 * Type 0x00d2: Unknown. (2 bytes) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
207 */ |
7167 | 208 if (aim_tlv_gettlv(tlvlist, 0x00d2, 1)) |
209 unknown_d2 = aim_tlv_get16(tlvlist, 0x00d2, 1); | |
2086 | 210 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
211 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
212 * Type 0x00d3: Room Description |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
213 */ |
7167 | 214 if (aim_tlv_gettlv(tlvlist, 0x00d3, 1)) |
215 roomdesc = aim_tlv_getstr(tlvlist, 0x00d3, 1); | |
2086 | 216 |
12429
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
11253
diff
changeset
|
217 #if 0 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
218 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
219 * Type 0x000d4: Unknown (flag only) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
220 */ |
12429
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
11253
diff
changeset
|
221 if (aim_tlv_gettlv(tlvlist, 0x000d4, 1)) { |
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
11253
diff
changeset
|
222 /* Unhandled */ |
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
11253
diff
changeset
|
223 } |
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
11253
diff
changeset
|
224 #endif |
2086 | 225 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
226 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
227 * Type 0x00d5: Unknown. (1 byte) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
228 */ |
7167 | 229 if (aim_tlv_gettlv(tlvlist, 0x00d5, 1)) |
230 unknown_d5 = aim_tlv_get8(tlvlist, 0x00d5, 1); | |
2086 | 231 |
12429
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
11253
diff
changeset
|
232 #if 0 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
233 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
234 * Type 0x00d6: Encoding 1 ("us-ascii") |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
235 */ |
12429
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
11253
diff
changeset
|
236 if (aim_tlv_gettlv(tlvlist, 0x000d6, 1)) { |
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
11253
diff
changeset
|
237 /* Unhandled */ |
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
11253
diff
changeset
|
238 } |
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
11253
diff
changeset
|
239 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
240 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
241 * Type 0x00d7: Language 1 ("en") |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
242 */ |
12429
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
11253
diff
changeset
|
243 if (aim_tlv_gettlv(tlvlist, 0x000d7, 1)) { |
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
11253
diff
changeset
|
244 /* Unhandled */ |
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
11253
diff
changeset
|
245 } |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
246 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
247 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
248 * Type 0x00d8: Encoding 2 ("us-ascii") |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
249 */ |
12429
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
11253
diff
changeset
|
250 if (aim_tlv_gettlv(tlvlist, 0x000d8, 1)) { |
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
11253
diff
changeset
|
251 /* Unhandled */ |
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
11253
diff
changeset
|
252 } |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
253 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
254 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
255 * Type 0x00d9: Language 2 ("en") |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
256 */ |
12429
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
11253
diff
changeset
|
257 if (aim_tlv_gettlv(tlvlist, 0x000d9, 1)) { |
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
11253
diff
changeset
|
258 /* Unhandled */ |
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
11253
diff
changeset
|
259 } |
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
11253
diff
changeset
|
260 #endif |
2086 | 261 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
262 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
263 * Type 0x00da: Maximum visible message length |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
264 */ |
7167 | 265 if (aim_tlv_gettlv(tlvlist, 0x000da, 1)) |
266 maxvisiblemsglen = aim_tlv_get16(tlvlist, 0x00da, 1); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
267 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
268 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) { |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
269 ret = userfunc(sess, |
5836 | 270 rx, |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
271 &roominfo, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
272 roomname, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
273 usercount, |
5836 | 274 userinfo, |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
275 roomdesc, |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
276 flags, |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
277 creationtime, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
278 maxmsglen, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
279 unknown_d2, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
280 unknown_d5, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
281 maxvisiblemsglen); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
282 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
283 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
284 free(roominfo.name); |
5836 | 285 |
286 while (usercount > 0) | |
287 aim_info_free(&userinfo[--usercount]); | |
288 | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
289 free(userinfo); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
290 free(roomname); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
291 free(roomdesc); |
7167 | 292 aim_tlvlist_free(&tlvlist); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
293 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
294 return ret; |
2086 | 295 } |
296 | |
3952 | 297 /* Subtypes 0x0003 and 0x0004 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
298 static int userlistchange(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
2086 | 299 { |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2270
diff
changeset
|
300 aim_userinfo_t *userinfo = NULL; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
301 aim_rxcallback_t userfunc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
302 int curcount = 0, ret = 0; |
2086 | 303 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
304 while (aim_bstream_empty(bs)) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
305 curcount++; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2270
diff
changeset
|
306 userinfo = realloc(userinfo, curcount * sizeof(aim_userinfo_t)); |
5836 | 307 aim_info_extract(sess, bs, &userinfo[curcount-1]); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
308 } |
2086 | 309 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
310 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
311 ret = userfunc(sess, rx, curcount, userinfo); |
2086 | 312 |
5836 | 313 aim_info_free(userinfo); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
314 free(userinfo); |
2086 | 315 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
316 return ret; |
2086 | 317 } |
318 | |
319 /* | |
3952 | 320 * Subtype 0x0005 - Send a Chat Message. |
321 * | |
322 * Possible flags: | |
323 * AIM_CHATFLAGS_NOREFLECT -- Unset the flag that requests messages | |
324 * should be sent to their sender. | |
325 * AIM_CHATFLAGS_AWAY -- Mark the message as an autoresponse | |
326 * (Note that WinAIM does not honor this, | |
327 * and displays the message as normal.) | |
328 * | |
329 * XXX convert this to use tlvchains | |
330 */ | |
11159 | 331 faim_export int aim_chat_send_im(aim_session_t *sess, aim_conn_t *conn, fu16_t flags, const gchar *msg, int msglen, const char *encoding, const char *language) |
8233 | 332 { |
3952 | 333 int i; |
334 aim_frame_t *fr; | |
335 aim_msgcookie_t *cookie; | |
336 aim_snacid_t snacid; | |
337 fu8_t ckstr[8]; | |
338 aim_tlvlist_t *otl = NULL, *itl = NULL; | |
339 | |
340 if (!sess || !conn || !msg || (msglen <= 0)) | |
341 return 0; | |
342 | |
343 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1152))) | |
344 return -ENOMEM; | |
345 | |
346 snacid = aim_cachesnac(sess, 0x000e, 0x0005, 0x0000, NULL, 0); | |
347 aim_putsnac(&fr->data, 0x000e, 0x0005, 0x0000, snacid); | |
348 | |
4901 | 349 /* |
350 * Cookie | |
3952 | 351 * |
352 * XXX mkcookie should generate the cookie and cache it in one | |
353 * operation to preserve uniqueness. | |
354 */ | |
4901 | 355 for (i = 0; i < 8; i++) |
356 ckstr[i] = (fu8_t)rand(); | |
3952 | 357 |
358 cookie = aim_mkcookie(ckstr, AIM_COOKIETYPE_CHAT, NULL); | |
359 cookie->data = NULL; /* XXX store something useful here */ | |
360 | |
361 aim_cachecookie(sess, cookie); | |
362 | |
4901 | 363 /* ICBM Header */ |
364 aimbs_putraw(&fr->data, ckstr, 8); /* Cookie */ | |
365 aimbs_put16(&fr->data, 0x0003); /* Channel */ | |
3952 | 366 |
367 /* | |
368 * Type 1: Flag meaning this message is destined to the room. | |
369 */ | |
7167 | 370 aim_tlvlist_add_noval(&otl, 0x0001); |
3952 | 371 |
372 /* | |
373 * Type 6: Reflect | |
374 */ | |
375 if (!(flags & AIM_CHATFLAGS_NOREFLECT)) | |
7167 | 376 aim_tlvlist_add_noval(&otl, 0x0006); |
3952 | 377 |
378 /* | |
379 * Type 7: Autoresponse | |
380 */ | |
381 if (flags & AIM_CHATFLAGS_AWAY) | |
7167 | 382 aim_tlvlist_add_noval(&otl, 0x0007); |
3952 | 383 |
384 /* | |
385 * SubTLV: Type 1: Message | |
386 */ | |
11159 | 387 aim_tlvlist_add_raw(&itl, 0x0001, msglen, (guchar *)msg); |
3952 | 388 |
8233 | 389 /* |
390 * SubTLV: Type 2: Encoding | |
391 */ | |
392 if (encoding != NULL) | |
10991 | 393 aim_tlvlist_add_str(&itl, 0x0002, encoding); |
8233 | 394 |
395 /* | |
396 * SubTLV: Type 3: Language | |
397 */ | |
398 if (language != NULL) | |
10991 | 399 aim_tlvlist_add_str(&itl, 0x0003, language); |
8219 | 400 |
3952 | 401 /* |
402 * Type 5: Message block. Contains more TLVs. | |
403 * | |
404 * This could include other information... We just | |
405 * put in a message TLV however. | |
406 * | |
407 */ | |
7167 | 408 aim_tlvlist_add_frozentlvlist(&otl, 0x0005, &itl); |
3952 | 409 |
7167 | 410 aim_tlvlist_write(&fr->data, &otl); |
3952 | 411 |
7167 | 412 aim_tlvlist_free(&itl); |
413 aim_tlvlist_free(&otl); | |
3952 | 414 |
415 aim_tx_enqueue(sess, fr); | |
416 | |
417 return 0; | |
418 } | |
419 | |
420 /* | |
421 * Subtype 0x0006 | |
422 * | |
2086 | 423 * We could probably include this in the normal ICBM parsing |
424 * code as channel 0x0003, however, since only the start | |
425 * would be the same, we might as well do it here. | |
426 * | |
427 * General outline of this SNAC: | |
428 * snac | |
429 * cookie | |
430 * channel id | |
431 * tlvlist | |
432 * unknown | |
433 * source user info | |
434 * name | |
435 * evility | |
436 * userinfo tlvs | |
437 * online time | |
438 * etc | |
439 * message metatlv | |
440 * message tlv | |
441 * message string | |
442 * possibly others | |
443 * | |
444 */ | |
8225 | 445 static int incomingim_ch3(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
2086 | 446 { |
8225 | 447 int ret = 0, i; |
448 aim_rxcallback_t userfunc; | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2270
diff
changeset
|
449 aim_userinfo_t userinfo; |
8225 | 450 fu8_t cookie[8]; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
451 fu16_t channel; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
452 aim_tlvlist_t *otl; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
453 char *msg = NULL; |
8283 | 454 int len = 0; |
8233 | 455 char *encoding = NULL, *language = NULL; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
456 aim_msgcookie_t *ck; |
2086 | 457 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2270
diff
changeset
|
458 memset(&userinfo, 0, sizeof(aim_userinfo_t)); |
2086 | 459 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
460 /* |
8225 | 461 * Read ICBM Cookie. |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
462 */ |
8225 | 463 for (i = 0; i < 8; i++) |
464 cookie[i] = aimbs_get8(bs); | |
2086 | 465 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
466 if ((ck = aim_uncachecookie(sess, cookie, AIM_COOKIETYPE_CHAT))) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
467 free(ck->data); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
468 free(ck); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
469 } |
2086 | 470 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
471 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
472 * Channel ID |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
473 * |
8225 | 474 * Channel 0x0003 is used for chat messages. |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
475 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
476 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
477 channel = aimbs_get16(bs); |
2086 | 478 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
479 if (channel != 0x0003) { |
11253 | 480 gaim_debug_misc("oscar", "faim: chat_incoming: unknown channel! (0x%04x)\n", channel); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
481 return 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
482 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
483 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
484 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
485 * Start parsing TLVs right away. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
486 */ |
7167 | 487 otl = aim_tlvlist_read(bs); |
2086 | 488 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
489 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
490 * Type 0x0003: Source User Information |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
491 */ |
7167 | 492 if (aim_tlv_gettlv(otl, 0x0003, 1)) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
493 aim_tlv_t *userinfotlv; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
494 aim_bstream_t tbs; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
495 |
7167 | 496 userinfotlv = aim_tlv_gettlv(otl, 0x0003, 1); |
2086 | 497 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
498 aim_bstream_init(&tbs, userinfotlv->value, userinfotlv->length); |
5836 | 499 aim_info_extract(sess, &tbs, &userinfo); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
500 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
501 |
12429
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
11253
diff
changeset
|
502 #if 0 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
503 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
504 * Type 0x0001: If present, it means it was a message to the |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
505 * room (as opposed to a whisper). |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
506 */ |
12429
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
11253
diff
changeset
|
507 if (aim_tlv_gettlv(otl, 0x0001, 1)) { |
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
11253
diff
changeset
|
508 /* Unhandled */ |
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
11253
diff
changeset
|
509 } |
59207955adc2
[gaim-migrate @ 14736]
Richard Laager <rlaager@wiktel.com>
parents:
11253
diff
changeset
|
510 #endif |
2086 | 511 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
512 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
513 * Type 0x0005: Message Block. Conains more TLVs. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
514 */ |
7167 | 515 if (aim_tlv_gettlv(otl, 0x0005, 1)) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
516 aim_tlvlist_t *itl; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
517 aim_tlv_t *msgblock; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
518 aim_bstream_t tbs; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
519 |
7167 | 520 msgblock = aim_tlv_gettlv(otl, 0x0005, 1); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
521 aim_bstream_init(&tbs, msgblock->value, msgblock->length); |
7167 | 522 itl = aim_tlvlist_read(&tbs); |
2086 | 523 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
524 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
525 * Type 0x0001: Message. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
526 */ |
8219 | 527 if (aim_tlv_gettlv(itl, 0x0001, 1)) { |
7167 | 528 msg = aim_tlv_getstr(itl, 0x0001, 1); |
8219 | 529 len = aim_tlv_gettlv(itl, 0x0001, 1)->length; |
530 } | |
531 | |
8233 | 532 /* |
533 * Type 0x0002: Encoding. | |
8219 | 534 */ |
535 if (aim_tlv_gettlv(itl, 0x0002, 1)) | |
8233 | 536 encoding = aim_tlv_getstr(itl, 0x0002, 1); |
537 | |
538 /* | |
539 * Type 0x0003: Language. | |
540 */ | |
541 if (aim_tlv_gettlv(itl, 0x0003, 1)) | |
542 language = aim_tlv_getstr(itl, 0x0003, 1); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
543 |
7167 | 544 aim_tlvlist_free(&itl); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
545 } |
2086 | 546 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
547 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) |
8233 | 548 ret = userfunc(sess, rx, &userinfo, len, msg, encoding, language); |
2086 | 549 |
5836 | 550 aim_info_free(&userinfo); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
551 free(msg); |
7167 | 552 aim_tlvlist_free(&otl); |
2086 | 553 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
554 return ret; |
2086 | 555 } |
556 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
557 static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
2086 | 558 { |
559 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
560 if (snac->subtype == 0x0002) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
561 return infoupdate(sess, mod, rx, snac, bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
562 else if ((snac->subtype == 0x0003) || (snac->subtype == 0x0004)) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
563 return userlistchange(sess, mod, rx, snac, bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
564 else if (snac->subtype == 0x0006) |
8225 | 565 return incomingim_ch3(sess, mod, rx, snac, bs); |
2086 | 566 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
567 return 0; |
2086 | 568 } |
569 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
570 faim_internal int chat_modfirst(aim_session_t *sess, aim_module_t *mod) |
2086 | 571 { |
572 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
573 mod->family = 0x000e; |
2672 | 574 mod->version = 0x0001; |
4071 | 575 mod->toolid = 0x0010; |
576 mod->toolversion = 0x0629; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
577 mod->flags = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
578 strncpy(mod->name, "chat", sizeof(mod->name)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
579 mod->snachandler = snachandler; |
2086 | 580 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
581 return 0; |
2086 | 582 } |