Mercurial > pidgin.yaz
annotate libfaim/aim_chatnav.c @ 828:4c71c0e7f04e
[gaim-migrate @ 838]
small changes for oscar. look for big, good ones later today.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Fri, 01 Sep 2000 23:45:43 +0000 |
parents | 72e556f6b99d |
children | 595ac7759563 |
rev | line source |
---|---|
2 | 1 /* |
2 * | |
3 * | |
4 * | |
5 * | |
6 */ | |
7 | |
283
0f14e6d8a51b
[gaim-migrate @ 293]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
8 #include <faim/aim.h> |
237 | 9 |
10 | |
11 /* | |
12 * conn must be a chatnav connection! | |
13 */ | |
14 u_long aim_chatnav_reqrights(struct aim_session_t *sess, | |
15 struct aim_conn_t *conn) | |
16 { | |
17 struct aim_snac_t snac; | |
18 | |
19 snac.id = aim_genericreq_n(sess, conn, 0x000d, 0x0002); | |
20 | |
21 snac.family = 0x000d; | |
22 snac.type = 0x0002; | |
23 snac.flags = 0x0000; | |
24 snac.data = NULL; | |
25 | |
26 aim_newsnac(sess, &snac); | |
27 | |
28 return (sess->snac_nextid); /* already incremented */ | |
29 } | |
30 | |
31 u_long aim_chatnav_clientready(struct aim_session_t *sess, | |
32 struct aim_conn_t *conn) | |
33 { | |
34 struct command_tx_struct *newpacket; | |
35 int i; | |
36 | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
37 if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 0x20))) |
237 | 38 return -1; |
39 | |
40 newpacket->lock = 1; | |
41 | |
42 i = aim_putsnac(newpacket->data, 0x0001, 0x0002, 0x0000, sess->snac_nextid); | |
43 | |
44 i+= aimutil_put16(newpacket->data+i, 0x000d); | |
45 i+= aimutil_put16(newpacket->data+i, 0x0001); | |
46 | |
47 i+= aimutil_put16(newpacket->data+i, 0x0004); | |
48 i+= aimutil_put16(newpacket->data+i, 0x0001); | |
49 | |
50 i+= aimutil_put16(newpacket->data+i, 0x0001); | |
51 i+= aimutil_put16(newpacket->data+i, 0x0003); | |
52 | |
53 i+= aimutil_put16(newpacket->data+i, 0x0004); | |
54 i+= aimutil_put16(newpacket->data+i, 0x0686); | |
55 | |
56 aim_tx_enqueue(sess, newpacket); | |
57 | |
58 return (sess->snac_nextid++); | |
59 } | |
60 | |
61 /* | |
62 * Since multiple things can trigger this callback, | |
63 * we must lookup the snacid to determine the original | |
64 * snac subtype that was called. | |
65 */ | |
66 int aim_chatnav_parse_info(struct aim_session_t *sess, struct command_rx_struct *command) | |
67 { | |
68 struct aim_snac_t *snac; | |
69 u_long snacid; | |
70 rxcallback_t userfunc; | |
715
58106806ac2b
[gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
71 int ret=1; |
237 | 72 |
73 snacid = aimutil_get32(command->data+6); | |
74 snac = aim_remsnac(sess, snacid); | |
75 | |
76 if (!snac) | |
77 { | |
78 printf("faim: chatnav_parse_info: received response to unknown request! (%08lx)\n", snacid); | |
79 return 1; | |
80 } | |
81 | |
82 if (snac->family != 0x000d) | |
83 { | |
84 printf("faim: chatnav_parse_info: recieved response that maps to corrupt request! (fam=%04x)\n", snac->family); | |
85 return 1; | |
86 } | |
87 | |
88 /* | |
89 * We now know what the original SNAC subtype was. | |
90 */ | |
91 switch(snac->type) | |
92 { | |
93 case 0x0002: /* request chat rights */ | |
94 { | |
95 struct aim_tlvlist_t *tlvlist; | |
96 struct aim_chat_exchangeinfo *exchanges = NULL; | |
97 int curexchange = 0; | |
98 struct aim_tlv_t *exchangetlv; | |
99 u_char maxrooms = 0; | |
100 struct aim_tlvlist_t *innerlist; | |
101 | |
102 tlvlist = aim_readtlvchain(command->data+10, command->commandlen-10); | |
103 | |
104 /* | |
105 * Type 0x0002: Maximum concurrent rooms. | |
106 */ | |
107 if (aim_gettlv(tlvlist, 0x0002, 1)) | |
108 { | |
109 struct aim_tlv_t *maxroomstlv; | |
110 maxroomstlv = aim_gettlv(tlvlist, 0x0002, 1); | |
111 maxrooms = aimutil_get8(maxroomstlv->value); | |
112 } | |
113 | |
114 /* | |
115 * Type 0x0003: Exchange information | |
116 * | |
117 * There can be any number of these, each one | |
118 * representing another exchange. | |
119 * | |
120 */ | |
121 curexchange = 0; | |
122 while ((exchangetlv = aim_gettlv(tlvlist, 0x0003, curexchange+1))) | |
123 { | |
124 curexchange++; | |
125 exchanges = realloc(exchanges, curexchange * sizeof(struct aim_chat_exchangeinfo)); | |
126 | |
722
26e96119d5a5
[gaim-migrate @ 732]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
127 |
237 | 128 /* exchange number */ |
129 exchanges[curexchange-1].number = aimutil_get16(exchangetlv->value); | |
130 innerlist = aim_readtlvchain(exchangetlv->value+2, exchangetlv->length-2); | |
131 | |
132 /* | |
133 * Type 0x000d: Unknown. | |
134 */ | |
135 if (aim_gettlv(innerlist, 0x000d, 1)) | |
136 ; | |
137 | |
138 /* | |
139 * Type 0x0004: Unknown | |
140 */ | |
141 if (aim_gettlv(innerlist, 0x0004, 1)) | |
142 ; | |
143 | |
771
72e556f6b99d
[gaim-migrate @ 781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
722
diff
changeset
|
144 /* |
72e556f6b99d
[gaim-migrate @ 781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
722
diff
changeset
|
145 * Type 0x0002: Unknown |
72e556f6b99d
[gaim-migrate @ 781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
722
diff
changeset
|
146 */ |
72e556f6b99d
[gaim-migrate @ 781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
722
diff
changeset
|
147 if (aim_gettlv(innerlist, 0x0002, 1)) { |
72e556f6b99d
[gaim-migrate @ 781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
722
diff
changeset
|
148 struct aim_tlv_t *tmptlv; |
72e556f6b99d
[gaim-migrate @ 781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
722
diff
changeset
|
149 unsigned short classperms = 0; |
72e556f6b99d
[gaim-migrate @ 781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
722
diff
changeset
|
150 |
72e556f6b99d
[gaim-migrate @ 781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
722
diff
changeset
|
151 tmptlv = aim_gettlv(innerlist, 0x0002, 1); |
72e556f6b99d
[gaim-migrate @ 781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
722
diff
changeset
|
152 classperms = aimutil_get16(tmptlv->value); |
72e556f6b99d
[gaim-migrate @ 781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
722
diff
changeset
|
153 |
72e556f6b99d
[gaim-migrate @ 781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
722
diff
changeset
|
154 printf("faim: class permissions %x\n", classperms); |
72e556f6b99d
[gaim-migrate @ 781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
722
diff
changeset
|
155 } |
72e556f6b99d
[gaim-migrate @ 781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
722
diff
changeset
|
156 |
237 | 157 /* |
158 * Type 0x00c9: Unknown | |
159 */ | |
160 if (aim_gettlv(innerlist, 0x00c9, 1)) | |
161 ; | |
162 | |
163 /* | |
164 * Type 0x00ca: Creation Date | |
165 */ | |
166 if (aim_gettlv(innerlist, 0x00ca, 1)) | |
167 ; | |
168 | |
169 /* | |
771
72e556f6b99d
[gaim-migrate @ 781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
722
diff
changeset
|
170 * Type 0x00d0: Mandatory Channels? |
237 | 171 */ |
172 if (aim_gettlv(innerlist, 0x00d0, 1)) | |
173 ; | |
2 | 174 |
237 | 175 /* |
176 * Type 0x00d1: Maximum Message length | |
177 */ | |
178 if (aim_gettlv(innerlist, 0x00d1, 1)) | |
179 ; | |
180 | |
181 /* | |
771
72e556f6b99d
[gaim-migrate @ 781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
722
diff
changeset
|
182 * Type 0x00d2: Maximum Occupancy? |
237 | 183 */ |
184 if (aim_gettlv(innerlist, 0x00d2, 1)) | |
185 ; | |
186 | |
187 /* | |
188 * Type 0x00d3: Exchange Name | |
189 */ | |
190 if (aim_gettlv(innerlist, 0x00d3, 1)) | |
191 exchanges[curexchange-1].name = aim_gettlv_str(innerlist, 0x00d3, 1); | |
192 else | |
193 exchanges[curexchange-1].name = NULL; | |
194 | |
195 /* | |
771
72e556f6b99d
[gaim-migrate @ 781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
722
diff
changeset
|
196 * Type 0x00d5: Creation Permissions |
72e556f6b99d
[gaim-migrate @ 781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
722
diff
changeset
|
197 * |
72e556f6b99d
[gaim-migrate @ 781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
722
diff
changeset
|
198 * 0 Creation not allowed |
72e556f6b99d
[gaim-migrate @ 781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
722
diff
changeset
|
199 * 1 Room creation allowed |
72e556f6b99d
[gaim-migrate @ 781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
722
diff
changeset
|
200 * 2 Exchange creation allowed |
72e556f6b99d
[gaim-migrate @ 781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
722
diff
changeset
|
201 * |
237 | 202 */ |
771
72e556f6b99d
[gaim-migrate @ 781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
722
diff
changeset
|
203 if (aim_gettlv(innerlist, 0x00d5, 1)) { |
72e556f6b99d
[gaim-migrate @ 781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
722
diff
changeset
|
204 struct aim_tlv_t *tmptlv; |
72e556f6b99d
[gaim-migrate @ 781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
722
diff
changeset
|
205 unsigned char createperms = 0; |
72e556f6b99d
[gaim-migrate @ 781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
722
diff
changeset
|
206 |
72e556f6b99d
[gaim-migrate @ 781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
722
diff
changeset
|
207 tmptlv = aim_gettlv(innerlist, 0x00d5, 1); |
72e556f6b99d
[gaim-migrate @ 781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
722
diff
changeset
|
208 createperms = aimutil_get8(tmptlv->value); |
72e556f6b99d
[gaim-migrate @ 781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
722
diff
changeset
|
209 |
72e556f6b99d
[gaim-migrate @ 781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
722
diff
changeset
|
210 printf("faim: creation permissions %x\n", createperms); |
72e556f6b99d
[gaim-migrate @ 781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
722
diff
changeset
|
211 } |
237 | 212 |
213 /* | |
214 * Type 0x00d6: Character Set (First Time) | |
215 */ | |
216 if (aim_gettlv(innerlist, 0x00d6, 1)) | |
217 exchanges[curexchange-1].charset1 = aim_gettlv_str(innerlist, 0x00d6, 1); | |
218 else | |
219 exchanges[curexchange-1].charset1 = NULL; | |
220 | |
221 /* | |
222 * Type 0x00d7: Language (First Time) | |
223 */ | |
224 if (aim_gettlv(innerlist, 0x00d7, 1)) | |
225 exchanges[curexchange-1].lang1 = aim_gettlv_str(innerlist, 0x00d7, 1); | |
226 else | |
227 exchanges[curexchange-1].lang1 = NULL; | |
228 | |
229 /* | |
230 * Type 0x00d8: Character Set (Second Time) | |
231 */ | |
232 if (aim_gettlv(innerlist, 0x00d8, 1)) | |
233 exchanges[curexchange-1].charset2 = aim_gettlv_str(innerlist, 0x00d8, 1); | |
234 else | |
235 exchanges[curexchange-1].charset2 = NULL; | |
236 | |
237 /* | |
238 * Type 0x00d9: Language (Second Time) | |
239 */ | |
240 if (aim_gettlv(innerlist, 0x00d9, 1)) | |
241 exchanges[curexchange-1].lang2 = aim_gettlv_str(innerlist, 0x00d9, 1); | |
242 else | |
243 exchanges[curexchange-1].lang2 = NULL; | |
715
58106806ac2b
[gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
244 |
58106806ac2b
[gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
245 aim_freetlvchain(&innerlist); |
237 | 246 } |
247 | |
248 /* | |
249 * Call client. | |
250 */ | |
251 userfunc = aim_callhandler(command->conn, 0x000d, 0x0009); | |
252 if (userfunc) | |
253 ret = userfunc(sess, | |
254 command, | |
255 snac->type, | |
256 maxrooms, | |
257 curexchange, | |
258 exchanges); | |
259 curexchange--; | |
722
26e96119d5a5
[gaim-migrate @ 732]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
260 while(curexchange >= 0) |
237 | 261 { |
262 if (exchanges[curexchange].name) | |
263 free(exchanges[curexchange].name); | |
264 if (exchanges[curexchange].charset1) | |
265 free(exchanges[curexchange].charset1); | |
266 if (exchanges[curexchange].lang1) | |
267 free(exchanges[curexchange].lang1); | |
268 if (exchanges[curexchange].charset2) | |
269 free(exchanges[curexchange].charset2); | |
270 if (exchanges[curexchange].lang2) | |
271 free(exchanges[curexchange].lang2); | |
272 curexchange--; | |
273 } | |
274 free(exchanges); | |
275 aim_freetlvchain(&tlvlist); | |
715
58106806ac2b
[gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
276 |
58106806ac2b
[gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
277 break; |
237 | 278 } |
279 case 0x0003: /* request exchange info */ | |
280 printf("faim: chatnav_parse_info: resposne to exchange info\n"); | |
715
58106806ac2b
[gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
281 break; |
237 | 282 case 0x0004: /* request room info */ |
283 printf("faim: chatnav_parse_info: response to room info\n"); | |
715
58106806ac2b
[gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
284 break; |
237 | 285 case 0x0005: /* request more room info */ |
286 printf("faim: chatnav_parse_info: response to more room info\n"); | |
715
58106806ac2b
[gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
287 break; |
237 | 288 case 0x0006: /* request occupant list */ |
289 printf("faim: chatnav_parse_info: response to occupant info\n"); | |
715
58106806ac2b
[gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
290 break; |
237 | 291 case 0x0007: /* search for a room */ |
292 printf("faim: chatnav_parse_info: search results\n"); | |
715
58106806ac2b
[gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
293 break; |
237 | 294 case 0x0008: /* create room */ |
295 printf("faim: chatnav_parse_info: response to create room\n"); | |
715
58106806ac2b
[gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
296 break; |
237 | 297 default: /* unknown */ |
298 printf("faim: chatnav_parse_info: unknown request subtype (%04x)\n", snac->type); | |
299 } | |
300 | |
715
58106806ac2b
[gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
301 if (snac && snac->data) |
58106806ac2b
[gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
302 free(snac->data); |
58106806ac2b
[gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
303 if (snac) |
58106806ac2b
[gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
304 free(snac); |
58106806ac2b
[gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
305 |
58106806ac2b
[gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
306 return ret; |
237 | 307 } |
308 | |
309 u_long aim_chatnav_createroom(struct aim_session_t *sess, | |
310 struct aim_conn_t *conn, | |
311 char *name, | |
312 u_short exchange) | |
313 { | |
314 struct command_tx_struct *newpacket; | |
315 int i; | |
316 struct aim_snac_t snac; | |
317 | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
318 if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+12+strlen("invite")+strlen(name)))) |
237 | 319 return -1; |
320 | |
321 newpacket->lock = 1; | |
322 | |
323 i = aim_putsnac(newpacket->data, 0x000d, 0x0008, 0x0000, sess->snac_nextid); | |
324 | |
325 /* exchange */ | |
326 i+= aimutil_put16(newpacket->data+i, exchange); | |
327 | |
328 /* room cookie */ | |
329 i+= aimutil_put8(newpacket->data+i, strlen("invite")); | |
330 i+= aimutil_putstr(newpacket->data+i, "invite", strlen("invite")); | |
331 | |
332 /* instance */ | |
333 i+= aimutil_put16(newpacket->data+i, 0xffff); | |
334 | |
335 /* detail level */ | |
336 i+= aimutil_put8(newpacket->data+i, 0x01); | |
337 | |
338 /* tlvcount */ | |
339 i+= aimutil_put16(newpacket->data+i, 0x0001); | |
340 | |
341 /* room name */ | |
342 i+= aim_puttlv_str(newpacket->data+i, 0x00d3, strlen(name), name); | |
343 | |
344 snac.id = sess->snac_nextid; | |
345 snac.family = 0x000d; | |
346 snac.type = 0x0008; | |
347 snac.flags = 0x0000; | |
348 snac.data = NULL; | |
349 | |
350 aim_newsnac(sess, &snac); | |
351 | |
352 aim_tx_enqueue(sess, newpacket); | |
353 | |
354 return (sess->snac_nextid++); | |
355 } |