| 11 #include <aim.h> |
11 #include <aim.h> |
| 12 |
12 |
| 13 /* |
13 /* |
| 14 * conn must be a chatnav connection! |
14 * conn must be a chatnav connection! |
| 15 */ |
15 */ |
| 16 faim_export unsigned long aim_chatnav_reqrights(struct aim_session_t *sess, |
16 faim_export int aim_chatnav_reqrights(aim_session_t *sess, aim_conn_t *conn) |
| 17 struct aim_conn_t *conn) |
17 { |
| 18 { |
18 return aim_genericreq_n_snacid(sess, conn, 0x000d, 0x0002); |
| 19 |
19 } |
| 20 return aim_genericreq_n_snacid(sess, conn, 0x000d, 0x0002); |
20 |
| 21 } |
21 faim_export int aim_chatnav_clientready(aim_session_t *sess, aim_conn_t *conn) |
| 22 |
22 { |
| 23 faim_export unsigned long aim_chatnav_clientready(struct aim_session_t *sess, |
23 aim_frame_t *fr; |
| 24 struct aim_conn_t *conn) |
24 aim_snacid_t snacid; |
| 25 { |
25 |
| 26 struct command_tx_struct *newpacket; |
26 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 0x20))) |
| 27 int i; |
27 return -ENOMEM; |
| 28 |
28 |
| 29 if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 0x20))) |
29 snacid = aim_cachesnac(sess, 0x0001, 0x0002, 0x0000, NULL, 0); |
| 30 return -1; |
30 aim_putsnac(&fr->data, 0x0001, 0x0002, 0x0000, snacid); |
| 31 |
31 |
| 32 newpacket->lock = 1; |
32 aimbs_put16(&fr->data, 0x000d); |
| 33 |
33 aimbs_put16(&fr->data, 0x0001); |
| 34 i = aim_putsnac(newpacket->data, 0x0001, 0x0002, 0x0000, sess->snac_nextid); |
34 |
| 35 |
35 aimbs_put16(&fr->data, 0x0004); |
| 36 i+= aimutil_put16(newpacket->data+i, 0x000d); |
36 aimbs_put16(&fr->data, 0x0001); |
| 37 i+= aimutil_put16(newpacket->data+i, 0x0001); |
37 |
| 38 |
38 aimbs_put16(&fr->data, 0x0001); |
| 39 i+= aimutil_put16(newpacket->data+i, 0x0004); |
39 aimbs_put16(&fr->data, 0x0003); |
| 40 i+= aimutil_put16(newpacket->data+i, 0x0001); |
40 |
| 41 |
41 aimbs_put16(&fr->data, 0x0004); |
| 42 i+= aimutil_put16(newpacket->data+i, 0x0001); |
42 aimbs_put16(&fr->data, 0x0686); |
| 43 i+= aimutil_put16(newpacket->data+i, 0x0003); |
43 |
| 44 |
44 aim_tx_enqueue(sess, fr); |
| 45 i+= aimutil_put16(newpacket->data+i, 0x0004); |
45 |
| 46 i+= aimutil_put16(newpacket->data+i, 0x0686); |
46 return 0; |
| 47 |
47 } |
| 48 aim_tx_enqueue(sess, newpacket); |
48 |
| 49 |
49 faim_export int aim_chatnav_createroom(aim_session_t *sess, aim_conn_t *conn, const char *name, fu16_t exchange) |
| 50 return (sess->snac_nextid++); |
50 { |
| 51 } |
51 aim_frame_t *fr; |
| 52 |
52 aim_snacid_t snacid; |
| 53 faim_export unsigned long aim_chatnav_createroom(struct aim_session_t *sess, |
53 aim_tlvlist_t *tl = NULL; |
| 54 struct aim_conn_t *conn, |
54 |
| 55 char *name, |
55 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+12+strlen("invite")+strlen(name)))) |
| 56 u_short exchange) |
56 return -ENOMEM; |
| 57 { |
57 |
| 58 struct command_tx_struct *newpacket; |
58 snacid = aim_cachesnac(sess, 0x000d, 0x0008, 0x0000, NULL, 0); |
| 59 int i; |
59 aim_putsnac(&fr->data, 0x000d, 0x0008, 0x0000, snacid); |
| 60 |
60 |
| 61 if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10+12+strlen("invite")+strlen(name)))) |
61 /* exchange */ |
| 62 return -1; |
62 aimbs_put16(&fr->data, exchange); |
| 63 |
63 |
| 64 newpacket->lock = 1; |
64 /* room cookie */ |
| 65 |
65 aimbs_put8(&fr->data, strlen("invite")); |
| 66 i = aim_putsnac(newpacket->data, 0x000d, 0x0008, 0x0000, sess->snac_nextid); |
66 aimbs_putraw(&fr->data, "invite", strlen("invite")); |
| 67 |
67 |
| 68 /* exchange */ |
68 /* |
| 69 i+= aimutil_put16(newpacket->data+i, exchange); |
69 * instance |
| 70 |
70 * |
| 71 /* room cookie */ |
71 * Setting this to 0xffff apparently assigns the last instance. |
| 72 i+= aimutil_put8(newpacket->data+i, strlen("invite")); |
72 * |
| 73 i+= aimutil_putstr(newpacket->data+i, "invite", strlen("invite")); |
73 */ |
| 74 |
74 aimbs_put16(&fr->data, 0xffff); |
| 75 /* instance */ |
75 |
| 76 i+= aimutil_put16(newpacket->data+i, 0xffff); |
76 /* detail level */ |
| 77 |
77 aimbs_put8(&fr->data, 0x01); |
| 78 /* detail level */ |
78 |
| 79 i+= aimutil_put8(newpacket->data+i, 0x01); |
79 /* room name */ |
| 80 |
80 aim_addtlvtochain_raw(&tl, 0x00d3, strlen(name), name); |
| 81 /* tlvcount */ |
81 |
| 82 i+= aimutil_put16(newpacket->data+i, 0x0001); |
82 /* tlvcount */ |
| 83 |
83 aimbs_put16(&fr->data, aim_counttlvchain(&tl)); |
| 84 /* room name */ |
84 aim_writetlvchain(&fr->data, &tl); |
| 85 i+= aim_puttlv_str(newpacket->data+i, 0x00d3, strlen(name), name); |
85 |
| 86 |
86 aim_freetlvchain(&tl); |
| 87 aim_cachesnac(sess, 0x000d, 0x0008, 0x0000, NULL, 0); |
87 |
| 88 |
88 aim_tx_enqueue(sess, fr); |
| 89 aim_tx_enqueue(sess, newpacket); |
89 |
| 90 |
90 return 0; |
| 91 return sess->snac_nextid; |
91 } |
| 92 } |
92 |
| 93 |
93 static int parseinfo_perms(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs, aim_snac_t *snac2) |
| 94 static int parseinfo_perms(struct aim_session_t *sess, aim_module_t *mod, struct command_rx_struct *rx, aim_modsnac_t *snac, unsigned char *data, int datalen, struct aim_snac_t *snac2) |
94 { |
| 95 { |
95 aim_rxcallback_t userfunc; |
| 96 aim_rxcallback_t userfunc; |
96 int ret = 0; |
| 97 int ret = 0; |
97 struct aim_chat_exchangeinfo *exchanges = NULL; |
| 98 struct aim_tlvlist_t *tlvlist; |
98 int curexchange; |
| 99 struct aim_chat_exchangeinfo *exchanges = NULL; |
99 aim_tlv_t *exchangetlv; |
| 100 int curexchange = 0; |
100 fu8_t maxrooms = 0; |
| 101 struct aim_tlv_t *exchangetlv; |
101 aim_tlvlist_t *tlvlist, *innerlist; |
| 102 unsigned char maxrooms = 0; |
102 |
| 103 struct aim_tlvlist_t *innerlist; |
103 tlvlist = aim_readtlvchain(bs); |
| 104 |
104 |
| 105 tlvlist = aim_readtlvchain(data, datalen); |
105 /* |
| 106 |
106 * Type 0x0002: Maximum concurrent rooms. |
| 107 /* |
107 */ |
| 108 * Type 0x0002: Maximum concurrent rooms. |
108 if (aim_gettlv(tlvlist, 0x0002, 1)) |
| 109 */ |
109 maxrooms = aim_gettlv8(tlvlist, 0x0002, 1); |
| 110 if (aim_gettlv(tlvlist, 0x0002, 1)) |
110 |
| 111 maxrooms = aim_gettlv8(tlvlist, 0x0002, 1); |
111 /* |
| 112 |
112 * Type 0x0003: Exchange information |
| 113 /* |
113 * |
| 114 * Type 0x0003: Exchange information |
114 * There can be any number of these, each one |
| 115 * |
115 * representing another exchange. |
| 116 * There can be any number of these, each one |
116 * |
| 117 * representing another exchange. |
117 */ |
| 118 * |
118 for (curexchange = 0; ((exchangetlv = aim_gettlv(tlvlist, 0x0003, curexchange+1))); ) { |
| 119 */ |
119 aim_bstream_t tbs; |
| 120 curexchange = 0; |
120 |
| 121 while ((exchangetlv = aim_gettlv(tlvlist, 0x0003, curexchange+1))) { |
121 aim_bstream_init(&tbs, exchangetlv->value, exchangetlv->length); |
| 122 curexchange++; |
122 |
| 123 exchanges = realloc(exchanges, curexchange * sizeof(struct aim_chat_exchangeinfo)); |
123 curexchange++; |
| 124 /* exchange number */ |
124 |
| 125 exchanges[curexchange-1].number = aimutil_get16(exchangetlv->value); |
125 exchanges = realloc(exchanges, curexchange * sizeof(struct aim_chat_exchangeinfo)); |
| 126 innerlist = aim_readtlvchain(exchangetlv->value+2, exchangetlv->length-2); |
126 |
| 127 |
127 /* exchange number */ |
| 128 /* |
128 exchanges[curexchange-1].number = aimbs_get16(&tbs); |
| 129 * Type 0x000d: Unknown. |
129 innerlist = aim_readtlvchain(&tbs); |
| 130 */ |
130 |
| 131 if (aim_gettlv(innerlist, 0x000d, 1)) |
131 /* |
| 132 ; |
132 * Type 0x000d: Unknown. |
| 133 |
133 */ |
| 134 /* |
134 if (aim_gettlv(innerlist, 0x000d, 1)) |
| 135 * Type 0x0004: Unknown |
135 ; |
| 136 */ |
136 |
| 137 if (aim_gettlv(innerlist, 0x0004, 1)) |
137 /* |
| 138 ; |
138 * Type 0x0004: Unknown |
| 139 |
139 */ |
| 140 /* |
140 if (aim_gettlv(innerlist, 0x0004, 1)) |
| 141 * Type 0x0002: Unknown |
141 ; |
| 142 */ |
142 |
| 143 if (aim_gettlv(innerlist, 0x0002, 1)) { |
143 /* |
| 144 unsigned short classperms; |
144 * Type 0x0002: Unknown |
| 145 |
145 */ |
| 146 classperms = aim_gettlv16(innerlist, 0x0002, 1); |
146 if (aim_gettlv(innerlist, 0x0002, 1)) { |
| 147 |
147 fu16_t classperms; |
| 148 faimdprintf(sess, 1, "faim: class permissions %x\n", classperms); |
148 |
| 149 } |
149 classperms = aim_gettlv16(innerlist, 0x0002, 1); |
| 150 |
150 |
| 151 /* |
151 faimdprintf(sess, 1, "faim: class permissions %x\n", classperms); |
| 152 * Type 0x00c9: Unknown |
152 } |
| 153 */ |
153 |
| 154 if (aim_gettlv(innerlist, 0x00c9, 1)) |
154 /* |
| 155 ; |
155 * Type 0x00c9: Unknown |
| 156 |
156 */ |
| 157 /* |
157 if (aim_gettlv(innerlist, 0x00c9, 1)) |
| 158 * Type 0x00ca: Creation Date |
158 ; |
| 159 */ |
159 |
| 160 if (aim_gettlv(innerlist, 0x00ca, 1)) |
160 /* |
| 161 ; |
161 * Type 0x00ca: Creation Date |
| 162 |
162 */ |
| 163 /* |
163 if (aim_gettlv(innerlist, 0x00ca, 1)) |
| 164 * Type 0x00d0: Mandatory Channels? |
164 ; |
| 165 */ |
165 |
| 166 if (aim_gettlv(innerlist, 0x00d0, 1)) |
166 /* |
| 167 ; |
167 * Type 0x00d0: Mandatory Channels? |
| 168 |
168 */ |
| 169 /* |
169 if (aim_gettlv(innerlist, 0x00d0, 1)) |
| 170 * Type 0x00d1: Maximum Message length |
170 ; |
| 171 */ |
171 |
| 172 if (aim_gettlv(innerlist, 0x00d1, 1)) |
172 /* |
| 173 ; |
173 * Type 0x00d1: Maximum Message length |
| 174 |
174 */ |
| 175 /* |
175 if (aim_gettlv(innerlist, 0x00d1, 1)) |
| 176 * Type 0x00d2: Maximum Occupancy? |
176 ; |
| 177 */ |
177 |
| 178 if (aim_gettlv(innerlist, 0x00d2, 1)) |
178 /* |
| 179 ; |
179 * Type 0x00d2: Maximum Occupancy? |
| 180 |
180 */ |
| 181 /* |
181 if (aim_gettlv(innerlist, 0x00d2, 1)) |
| 182 * Type 0x00d3: Exchange Name |
182 ; |
| 183 */ |
183 |
| 184 if (aim_gettlv(innerlist, 0x00d3, 1)) |
184 /* |
| 185 exchanges[curexchange-1].name = aim_gettlv_str(innerlist, 0x00d3, 1); |
185 * Type 0x00d3: Exchange Name |
| 186 else |
186 */ |
| 187 exchanges[curexchange-1].name = NULL; |
187 if (aim_gettlv(innerlist, 0x00d3, 1)) |
| 188 |
188 exchanges[curexchange-1].name = aim_gettlv_str(innerlist, 0x00d3, 1); |
| 189 /* |
189 else |
| 190 * Type 0x00d5: Creation Permissions |
190 exchanges[curexchange-1].name = NULL; |
| 191 * |
191 |
| 192 * 0 Creation not allowed |
192 /* |
| 193 * 1 Room creation allowed |
193 * Type 0x00d5: Creation Permissions |
| 194 * 2 Exchange creation allowed |
194 * |
| 195 * |
195 * 0 Creation not allowed |
| 196 */ |
196 * 1 Room creation allowed |
| 197 if (aim_gettlv(innerlist, 0x00d5, 1)) { |
197 * 2 Exchange creation allowed |
| 198 unsigned char createperms; |
198 * |
| 199 |
199 */ |
| 200 createperms = aim_gettlv8(innerlist, 0x00d5, 1); |
200 if (aim_gettlv(innerlist, 0x00d5, 1)) { |
| 201 } |
201 fu8_t createperms; |
| 202 |
202 |
| 203 /* |
203 createperms = aim_gettlv8(innerlist, 0x00d5, 1); |
| 204 * Type 0x00d6: Character Set (First Time) |
204 } |
| 205 */ |
205 |
| 206 if (aim_gettlv(innerlist, 0x00d6, 1)) |
206 /* |
| 207 exchanges[curexchange-1].charset1 = aim_gettlv_str(innerlist, 0x00d6, 1); |
207 * Type 0x00d6: Character Set (First Time) |
| 208 else |
208 */ |
| 209 exchanges[curexchange-1].charset1 = NULL; |
209 if (aim_gettlv(innerlist, 0x00d6, 1)) |
| 210 |
210 exchanges[curexchange-1].charset1 = aim_gettlv_str(innerlist, 0x00d6, 1); |
| 211 /* |
211 else |
| 212 * Type 0x00d7: Language (First Time) |
212 exchanges[curexchange-1].charset1 = NULL; |
| 213 */ |
213 |
| 214 if (aim_gettlv(innerlist, 0x00d7, 1)) |
214 /* |
| 215 exchanges[curexchange-1].lang1 = aim_gettlv_str(innerlist, 0x00d7, 1); |
215 * Type 0x00d7: Language (First Time) |
| 216 else |
216 */ |
| 217 exchanges[curexchange-1].lang1 = NULL; |
217 if (aim_gettlv(innerlist, 0x00d7, 1)) |
| 218 |
218 exchanges[curexchange-1].lang1 = aim_gettlv_str(innerlist, 0x00d7, 1); |
| 219 /* |
219 else |
| 220 * Type 0x00d8: Character Set (Second Time) |
220 exchanges[curexchange-1].lang1 = NULL; |
| 221 */ |
221 |
| 222 if (aim_gettlv(innerlist, 0x00d8, 1)) |
222 /* |
| 223 exchanges[curexchange-1].charset2 = aim_gettlv_str(innerlist, 0x00d8, 1); |
223 * Type 0x00d8: Character Set (Second Time) |
| 224 else |
224 */ |
| 225 exchanges[curexchange-1].charset2 = NULL; |
225 if (aim_gettlv(innerlist, 0x00d8, 1)) |
| 226 |
226 exchanges[curexchange-1].charset2 = aim_gettlv_str(innerlist, 0x00d8, 1); |
| 227 /* |
227 else |
| 228 * Type 0x00d9: Language (Second Time) |
228 exchanges[curexchange-1].charset2 = NULL; |
| 229 */ |
229 |
| 230 if (aim_gettlv(innerlist, 0x00d9, 1)) |
230 /* |
| 231 exchanges[curexchange-1].lang2 = aim_gettlv_str(innerlist, 0x00d9, 1); |
231 * Type 0x00d9: Language (Second Time) |
| 232 else |
232 */ |
| 233 exchanges[curexchange-1].lang2 = NULL; |
233 if (aim_gettlv(innerlist, 0x00d9, 1)) |
| 234 |
234 exchanges[curexchange-1].lang2 = aim_gettlv_str(innerlist, 0x00d9, 1); |
| 235 aim_freetlvchain(&innerlist); |
235 else |
| 236 } |
236 exchanges[curexchange-1].lang2 = NULL; |
| 237 |
237 |
| 238 /* |
238 aim_freetlvchain(&innerlist); |
| 239 * Call client. |
239 } |
| 240 */ |
240 |
| 241 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) |
241 /* |
| 242 ret = userfunc(sess, rx, snac2->type, maxrooms, curexchange, exchanges); |
242 * Call client. |
| 243 curexchange--; |
243 */ |
| 244 while(curexchange >= 0) { |
244 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) |
| 245 free(exchanges[curexchange].name); |
245 ret = userfunc(sess, rx, snac2->type, maxrooms, curexchange, exchanges); |
| 246 free(exchanges[curexchange].charset1); |
246 |
| 247 free(exchanges[curexchange].lang1); |
247 for (curexchange--; curexchange >= 0; curexchange--) { |
| 248 free(exchanges[curexchange].charset2); |
248 free(exchanges[curexchange].name); |
| 249 free(exchanges[curexchange].lang2); |
249 free(exchanges[curexchange].charset1); |
| 250 curexchange--; |
250 free(exchanges[curexchange].lang1); |
| 251 } |
251 free(exchanges[curexchange].charset2); |
| 252 free(exchanges); |
252 free(exchanges[curexchange].lang2); |
| 253 aim_freetlvchain(&tlvlist); |
253 } |
| 254 |
254 free(exchanges); |
| 255 return ret; |
255 aim_freetlvchain(&tlvlist); |
| 256 } |
256 |
| 257 |
257 return ret; |
| 258 static int parseinfo_create(struct aim_session_t *sess, aim_module_t *mod, struct command_rx_struct *rx, aim_modsnac_t *snac, unsigned char *data, int datalen, struct aim_snac_t *snac2) |
258 } |
| 259 { |
259 |
| 260 aim_rxcallback_t userfunc; |
260 static int parseinfo_create(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs, aim_snac_t *snac2) |
| 261 struct aim_tlvlist_t *tlvlist, *innerlist; |
261 { |
| 262 char *ck = NULL, *fqcn = NULL, *name = NULL; |
262 aim_rxcallback_t userfunc; |
| 263 unsigned short exchange = 0, instance = 0, unknown = 0, flags = 0, maxmsglen = 0, maxoccupancy = 0; |
263 aim_tlvlist_t *tlvlist, *innerlist; |
| 264 unsigned long createtime = 0; |
264 char *ck = NULL, *fqcn = NULL, *name = NULL; |
| 265 unsigned char createperms = 0; |
265 fu16_t exchange = 0, instance = 0, unknown = 0, flags = 0, maxmsglen = 0, maxoccupancy = 0; |
| 266 int i = 0, cklen; |
266 fu32_t createtime = 0; |
| 267 struct aim_tlv_t *bigblock; |
267 fu8_t createperms = 0, detaillevel; |
| 268 int ret = 0; |
268 int cklen; |
| 269 |
269 aim_tlv_t *bigblock; |
| 270 if (!(tlvlist = aim_readtlvchain(data, datalen))) { |
270 int ret = 0; |
| 271 faimdprintf(sess, 0, "unable to read top tlv in create room response\n"); |
271 aim_bstream_t bbbs; |
| 272 return 0; |
272 |
| 273 } |
273 tlvlist = aim_readtlvchain(bs); |
| 274 |
274 |
| 275 if (!(bigblock = aim_gettlv(tlvlist, 0x0004, 1))) { |
275 if (!(bigblock = aim_gettlv(tlvlist, 0x0004, 1))) { |
| 276 faimdprintf(sess, 0, "no bigblock in top tlv in create room response\n"); |
276 faimdprintf(sess, 0, "no bigblock in top tlv in create room response\n"); |
| 277 aim_freetlvchain(&tlvlist); |
277 aim_freetlvchain(&tlvlist); |
| 278 return 0; |
278 return 0; |
| 279 } |
279 } |
| 280 |
280 |
| 281 exchange = aimutil_get16(bigblock->value+i); |
281 aim_bstream_init(&bbbs, bigblock->value, bigblock->length); |
| 282 i += 2; |
282 |
| 283 |
283 exchange = aimbs_get16(&bbbs); |
| 284 cklen = aimutil_get8(bigblock->value+i); |
284 cklen = aimbs_get8(&bbbs); |
| 285 i++; |
285 ck = aimbs_getstr(&bbbs, cklen); |
| 286 |
286 instance = aimbs_get16(&bbbs); |
| 287 ck = malloc(cklen+1); |
287 detaillevel = aimbs_get8(&bbbs); |
| 288 memcpy(ck, bigblock->value+i, cklen); |
288 |
| 289 ck[cklen] = '\0'; |
289 if (detaillevel != 0x02) { |
| 290 i += cklen; |
290 faimdprintf(sess, 0, "unknown detaillevel in create room response (0x%02x)\n", detaillevel); |
| 291 |
291 aim_freetlvchain(&tlvlist); |
| 292 instance = aimutil_get16(bigblock->value+i); |
292 free(ck); |
| 293 i += 2; |
293 return 0; |
| 294 |
294 } |
| 295 if (aimutil_get8(bigblock->value+i) != 0x02) { |
295 |
| 296 faimdprintf(sess, 0, "unknown detaillevel in create room response (0x%02x)\n", aimutil_get8(bigblock->value+i)); |
296 unknown = aimbs_get16(&bbbs); |
| 297 aim_freetlvchain(&tlvlist); |
297 |
| 298 free(ck); |
298 innerlist = aim_readtlvchain(&bbbs); |
| 299 return 0; |
299 |
| 300 } |
300 if (aim_gettlv(innerlist, 0x006a, 1)) |
| 301 i += 1; |
301 fqcn = aim_gettlv_str(innerlist, 0x006a, 1); |
| 302 |
302 |
| 303 unknown = aimutil_get16(bigblock->value+i); |
303 if (aim_gettlv(innerlist, 0x00c9, 1)) |
| 304 i += 2; |
304 flags = aim_gettlv16(innerlist, 0x00c9, 1); |
| 305 |
305 |
| 306 if (!(innerlist = aim_readtlvchain(bigblock->value+i, bigblock->length-i))) { |
306 if (aim_gettlv(innerlist, 0x00ca, 1)) |
| 307 faimdprintf(sess, 0, "unable to read inner tlv chain in create room response\n"); |
307 createtime = aim_gettlv32(innerlist, 0x00ca, 1); |
| 308 aim_freetlvchain(&tlvlist); |
308 |
| 309 free(ck); |
309 if (aim_gettlv(innerlist, 0x00d1, 1)) |
| 310 return 0; |
310 maxmsglen = aim_gettlv16(innerlist, 0x00d1, 1); |
| 311 } |
311 |
| 312 |
312 if (aim_gettlv(innerlist, 0x00d2, 1)) |
| 313 if (aim_gettlv(innerlist, 0x006a, 1)) |
313 maxoccupancy = aim_gettlv16(innerlist, 0x00d2, 1); |
| 314 fqcn = aim_gettlv_str(innerlist, 0x006a, 1); |
314 |
| 315 |
315 if (aim_gettlv(innerlist, 0x00d3, 1)) |
| 316 if (aim_gettlv(innerlist, 0x00c9, 1)) |
316 name = aim_gettlv_str(innerlist, 0x00d3, 1); |
| 317 flags = aim_gettlv16(innerlist, 0x00c9, 1); |
317 |
| 318 |
318 if (aim_gettlv(innerlist, 0x00d5, 1)) |
| 319 if (aim_gettlv(innerlist, 0x00ca, 1)) |
319 createperms = aim_gettlv8(innerlist, 0x00d5, 1); |
| 320 createtime = aim_gettlv32(innerlist, 0x00ca, 1); |
320 |
| 321 |
321 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) { |
| 322 if (aim_gettlv(innerlist, 0x00d1, 1)) |
322 ret = userfunc(sess, rx, snac2->type, fqcn, instance, exchange, flags, createtime, maxmsglen, maxoccupancy, createperms, unknown, name, ck); |
| 323 maxmsglen = aim_gettlv16(innerlist, 0x00d1, 1); |
323 } |
| 324 |
324 |
| 325 if (aim_gettlv(innerlist, 0x00d2, 1)) |
325 free(ck); |
| 326 maxoccupancy = aim_gettlv16(innerlist, 0x00d2, 1); |
326 free(name); |
| 327 |
327 free(fqcn); |
| 328 if (aim_gettlv(innerlist, 0x00d3, 1)) |
328 aim_freetlvchain(&innerlist); |
| 329 name = aim_gettlv_str(innerlist, 0x00d3, 1); |
329 aim_freetlvchain(&tlvlist); |
| 330 |
330 |
| 331 if (aim_gettlv(innerlist, 0x00d5, 1)) |
331 return ret; |
| 332 createperms = aim_gettlv8(innerlist, 0x00d5, 1); |
|
| 333 |
|
| 334 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) |
|
| 335 ret = userfunc(sess, rx, snac2->type, fqcn, instance, exchange, flags, createtime, maxmsglen, maxoccupancy, createperms, unknown, name, ck); |
|
| 336 |
|
| 337 free(ck); |
|
| 338 free(name); |
|
| 339 free(fqcn); |
|
| 340 aim_freetlvchain(&innerlist); |
|
| 341 aim_freetlvchain(&tlvlist); |
|
| 342 |
|
| 343 return ret; |
|
| 344 } |
332 } |
| 345 |
333 |
| 346 /* |
334 /* |
| 347 * Since multiple things can trigger this callback, |
335 * Since multiple things can trigger this callback, we must lookup the |
| 348 * we must lookup the snacid to determine the original |
336 * snacid to determine the original snac subtype that was called. |
| 349 * snac subtype that was called. |
|
| 350 */ |
337 */ |
| 351 static int parseinfo(struct aim_session_t *sess, aim_module_t *mod, struct command_rx_struct *rx, aim_modsnac_t *snac, unsigned char *data, int datalen) |
338 static int parseinfo(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
| 352 { |
339 { |
| 353 struct aim_snac_t *snac2; |
340 aim_snac_t *snac2; |
| 354 int ret = 0; |
341 int ret = 0; |
| 355 |
342 |
| 356 if (!(snac2 = aim_remsnac(sess, snac->id))) { |
343 if (!(snac2 = aim_remsnac(sess, snac->id))) { |
| 357 faimdprintf(sess, 0, "faim: chatnav_parse_info: received response to unknown request! (%08lx)\n", snac->id); |
344 faimdprintf(sess, 0, "faim: chatnav_parse_info: received response to unknown request! (%08lx)\n", snac->id); |
| 358 return 0; |
345 return 0; |
| 359 } |
346 } |
| 360 |
347 |
| 361 if (snac2->family != 0x000d) { |
348 if (snac2->family != 0x000d) { |
| 362 faimdprintf(sess, 0, "faim: chatnav_parse_info: recieved response that maps to corrupt request! (fam=%04x)\n", snac2->family); |
349 faimdprintf(sess, 0, "faim: chatnav_parse_info: recieved response that maps to corrupt request! (fam=%04x)\n", snac2->family); |
| 363 return 0; |
350 return 0; |
| 364 } |
351 } |
| 365 |
352 |
| 366 /* |
353 /* |
| 367 * We now know what the original SNAC subtype was. |
354 * We now know what the original SNAC subtype was. |
| 368 */ |
355 */ |
| 369 if (snac2->type == 0x0002) /* request chat rights */ |
356 if (snac2->type == 0x0002) /* request chat rights */ |
| 370 ret = parseinfo_perms(sess, mod, rx, snac, data, datalen, snac2); |
357 ret = parseinfo_perms(sess, mod, rx, snac, bs, snac2); |
| 371 else if (snac2->type == 0x0003) /* request exchange info */ |
358 else if (snac2->type == 0x0003) /* request exchange info */ |
| 372 faimdprintf(sess, 0, "chatnav_parse_info: resposne to exchange info\n"); |
359 faimdprintf(sess, 0, "chatnav_parse_info: resposne to exchange info\n"); |
| 373 else if (snac2->type == 0x0004) /* request room info */ |
360 else if (snac2->type == 0x0004) /* request room info */ |
| 374 faimdprintf(sess, 0, "chatnav_parse_info: response to room info\n"); |
361 faimdprintf(sess, 0, "chatnav_parse_info: response to room info\n"); |
| 375 else if (snac2->type == 0x0005) /* request more room info */ |
362 else if (snac2->type == 0x0005) /* request more room info */ |
| 376 faimdprintf(sess, 0, "chatnav_parse_info: response to more room info\n"); |
363 faimdprintf(sess, 0, "chatnav_parse_info: response to more room info\n"); |
| 377 else if (snac2->type == 0x0006) /* request occupant list */ |
364 else if (snac2->type == 0x0006) /* request occupant list */ |
| 378 faimdprintf(sess, 0, "chatnav_parse_info: response to occupant info\n"); |
365 faimdprintf(sess, 0, "chatnav_parse_info: response to occupant info\n"); |
| 379 else if (snac2->type == 0x0007) /* search for a room */ |
366 else if (snac2->type == 0x0007) /* search for a room */ |
| 380 faimdprintf(sess, 0, "chatnav_parse_info: search results\n"); |
367 faimdprintf(sess, 0, "chatnav_parse_info: search results\n"); |
| 381 else if (snac2->type == 0x0008) /* create room */ |
368 else if (snac2->type == 0x0008) /* create room */ |
| 382 ret = parseinfo_create(sess, mod, rx, snac, data, datalen, snac2); |
369 ret = parseinfo_create(sess, mod, rx, snac, bs, snac2); |
| 383 else |
370 else |
| 384 faimdprintf(sess, 0, "chatnav_parse_info: unknown request subtype (%04x)\n", snac2->type); |
371 faimdprintf(sess, 0, "chatnav_parse_info: unknown request subtype (%04x)\n", snac2->type); |
| 385 |
372 |
| 386 if (snac2) |
373 if (snac2) |
| 387 free(snac2->data); |
374 free(snac2->data); |
| 388 free(snac2); |
375 free(snac2); |
| 389 |
376 |
| 390 return ret; |
377 return ret; |
| 391 } |
378 } |
| 392 |
379 |
| 393 static int snachandler(struct aim_session_t *sess, aim_module_t *mod, struct command_rx_struct *rx, aim_modsnac_t *snac, unsigned char *data, int datalen) |
380 static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
| 394 { |
381 { |
| 395 |
382 |
| 396 if (snac->subtype == 0x0009) |
383 if (snac->subtype == 0x0009) |
| 397 return parseinfo(sess, mod, rx, snac, data, datalen); |
384 return parseinfo(sess, mod, rx, snac, bs); |
| 398 |
385 |
| 399 return 0; |
386 return 0; |
| 400 } |
387 } |
| 401 |
388 |
| 402 faim_internal int chatnav_modfirst(struct aim_session_t *sess, aim_module_t *mod) |
389 faim_internal int chatnav_modfirst(aim_session_t *sess, aim_module_t *mod) |
| 403 { |
390 { |
| 404 |
391 |
| 405 mod->family = 0x000d; |
392 mod->family = 0x000d; |
| 406 mod->version = 0x0000; |
393 mod->version = 0x0000; |
| 407 mod->flags = 0; |
394 mod->flags = 0; |
| 408 strncpy(mod->name, "chatnav", sizeof(mod->name)); |
395 strncpy(mod->name, "chatnav", sizeof(mod->name)); |
| 409 mod->snachandler = snachandler; |
396 mod->snachandler = snachandler; |
| 410 |
397 |
| 411 return 0; |
398 return 0; |
| 412 } |
399 } |