Sat, 11 Jul 2015 14:45:46 -0400
facebook: fixed all errors being marked as fatal
| 13235 | 1 | /* |
| 15884 | 2 | * Purple's oscar protocol plugin |
| 13235 | 3 | * This file is the legal property of its developers. |
| 4 | * Please see the AUTHORS file distributed alongside this file. | |
| 5 | * | |
| 6 | * This library is free software; you can redistribute it and/or | |
| 7 | * modify it under the terms of the GNU Lesser General Public | |
| 8 | * License as published by the Free Software Foundation; either | |
| 9 | * version 2 of the License, or (at your option) any later version. | |
| 10 | * | |
| 11 | * This library is distributed in the hope that it will be useful, | |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 14 | * Lesser General Public License for more details. | |
| 15 | * | |
| 16 | * You should have received a copy of the GNU Lesser General Public | |
| 17 | * License along with this library; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18953
diff
changeset
|
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 13235 | 19 | */ |
| 20 | ||
| 21 | /* | |
| 22 | * Family 0x000d - Handle ChatNav. | |
| 23 | * | |
| 24 | * The ChatNav(igation) service does various things to keep chat | |
| 25 | * alive. It provides room information, room searching and creating, | |
| 26 | * as well as giving users the right ("permission") to use chat. | |
| 27 | * | |
| 28 | */ | |
| 29 | ||
| 30 | #include "oscar.h" | |
| 31 | ||
|
21846
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
32 | static int |
|
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
33 | error(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) |
|
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
34 | { |
|
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
35 | int ret = 0; |
|
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
36 | aim_snac_t *snac2; |
|
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
37 | guint16 error, chatnav_error; |
|
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
38 | GSList *tlvlist; |
|
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
39 | |
|
30296
d97ee3720d8d
Cleanup, basically. Move the icbm snac error handling from oscar.c to
Mark Doliner <markdoliner@pidgin.im>
parents:
26898
diff
changeset
|
40 | snac2 = aim_remsnac(od, snac->id); |
|
d97ee3720d8d
Cleanup, basically. Move the icbm snac error handling from oscar.c to
Mark Doliner <markdoliner@pidgin.im>
parents:
26898
diff
changeset
|
41 | if (!snac2) { |
|
22622
1ecb840b5101
Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <markdoliner@pidgin.im>
parents:
21846
diff
changeset
|
42 | purple_debug_warning("oscar", "chatnav error: received response to unknown request (%08x)\n", snac->id); |
|
21846
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
43 | return 0; |
|
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
44 | } |
|
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
45 | |
|
23456
66ab07770438
Replaced family_*'s magic numbers of FLAP families with the constants
Evan Schoenberg <evands@pidgin.im>
parents:
22860
diff
changeset
|
46 | if (snac2->family != SNAC_FAMILY_CHATNAV) { |
|
21846
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
47 | purple_debug_warning("oscar", "chatnav error: received response that maps to corrupt request (fam=%04x)\n", snac2->family); |
|
26898
11269f6382c1
fixes a potential leak on error case
Ka-Hing Cheung <khc@pidgin.im>
parents:
23456
diff
changeset
|
48 | g_free(snac2->data); |
|
11269f6382c1
fixes a potential leak on error case
Ka-Hing Cheung <khc@pidgin.im>
parents:
23456
diff
changeset
|
49 | g_free(snac2); |
|
21846
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
50 | return 0; |
|
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
51 | } |
|
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
52 | |
|
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
53 | /* |
|
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
54 | * We now know what the original SNAC subtype was. |
|
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
55 | */ |
|
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
56 | if (snac2->type == 0x0008) /* create room */ |
|
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
57 | { |
|
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
58 | error = byte_stream_get16(bs); |
|
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
59 | tlvlist = aim_tlvlist_read(bs); |
|
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
60 | chatnav_error = aim_tlv_get16(tlvlist, 0x0008, 1); |
|
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
61 | |
|
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
62 | purple_debug_warning("oscar", |
|
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
63 | "Could not join room, error=0x%04hx, chatnav_error=0x%04hx\n", |
|
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
64 | error, chatnav_error); |
|
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
65 | purple_notify_error(od->gc, NULL, _("Could not join chat room"), |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33892
diff
changeset
|
66 | chatnav_error == 0x0033 ? _("Invalid chat room name") : |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33892
diff
changeset
|
67 | _("Unknown error"), |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33892
diff
changeset
|
68 | purple_request_cpar_from_connection(od->gc)); |
|
21846
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
69 | |
|
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
70 | ret = 1; |
|
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
71 | } |
|
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
72 | |
|
30296
d97ee3720d8d
Cleanup, basically. Move the icbm snac error handling from oscar.c to
Mark Doliner <markdoliner@pidgin.im>
parents:
26898
diff
changeset
|
73 | g_free(snac2->data); |
|
21846
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
74 | g_free(snac2); |
|
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
75 | |
|
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
76 | return ret; |
|
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
77 | } |
|
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
78 | |
| 13235 | 79 | /* |
| 80 | * Subtype 0x0002 | |
| 81 | * | |
| 82 | * conn must be a chatnav connection! | |
| 83 | * | |
| 84 | */ | |
|
13610
b2c15a312144
[gaim-migrate @ 15995]
Mark Doliner <markdoliner@pidgin.im>
parents:
13593
diff
changeset
|
85 | void aim_chatnav_reqrights(OscarData *od, FlapConnection *conn) |
| 13235 | 86 | { |
|
23456
66ab07770438
Replaced family_*'s magic numbers of FLAP families with the constants
Evan Schoenberg <evands@pidgin.im>
parents:
22860
diff
changeset
|
87 | aim_genericreq_n_snacid(od, conn, SNAC_FAMILY_CHATNAV, 0x0002); |
| 13235 | 88 | } |
| 89 | ||
| 90 | /* | |
| 91 | * Subtype 0x0008 | |
| 92 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
93 | int aim_chatnav_createroom(OscarData *od, FlapConnection *conn, const char *name, guint16 exchange) |
| 13235 | 94 | { |
| 95 | static const char ck[] = {"create"}; | |
| 96 | static const char lang[] = {"en"}; | |
| 97 | static const char charset[] = {"us-ascii"}; | |
|
22860
2b0e247173b2
All SNACs on FLAP channel 2 except in the auth family are now sent through
Evan Schoenberg <evands@pidgin.im>
parents:
22622
diff
changeset
|
98 | ByteStream bs; |
| 13235 | 99 | aim_snacid_t snacid; |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17280
diff
changeset
|
100 | GSList *tlvlist = NULL; |
| 13235 | 101 | |
|
22860
2b0e247173b2
All SNACs on FLAP channel 2 except in the auth family are now sent through
Evan Schoenberg <evands@pidgin.im>
parents:
22622
diff
changeset
|
102 | byte_stream_new(&bs, 1142); |
| 13235 | 103 | |
|
23456
66ab07770438
Replaced family_*'s magic numbers of FLAP families with the constants
Evan Schoenberg <evands@pidgin.im>
parents:
22860
diff
changeset
|
104 | snacid = aim_cachesnac(od, SNAC_FAMILY_CHATNAV, 0x0008, 0x0000, NULL, 0); |
| 13235 | 105 | |
| 106 | /* exchange */ | |
|
22860
2b0e247173b2
All SNACs on FLAP channel 2 except in the auth family are now sent through
Evan Schoenberg <evands@pidgin.im>
parents:
22622
diff
changeset
|
107 | byte_stream_put16(&bs, exchange); |
| 13235 | 108 | |
| 109 | /* | |
| 110 | * This looks to be a big hack. You'll note that this entire | |
| 111 | * SNAC is just a room info structure, but the hard room name, | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
112 | * here, is set to "create". |
| 13235 | 113 | * |
| 114 | * Either this goes on the "list of questions concerning | |
| 115 | * why-the-hell-did-you-do-that", or this value is completely | |
| 116 | * ignored. Without experimental evidence, but a good knowledge of | |
| 117 | * AOL style, I'm going to guess that it is the latter, and that | |
| 118 | * the value of the room name in create requests is ignored. | |
| 119 | */ | |
|
22860
2b0e247173b2
All SNACs on FLAP channel 2 except in the auth family are now sent through
Evan Schoenberg <evands@pidgin.im>
parents:
22622
diff
changeset
|
120 | byte_stream_put8(&bs, strlen(ck)); |
|
2b0e247173b2
All SNACs on FLAP channel 2 except in the auth family are now sent through
Evan Schoenberg <evands@pidgin.im>
parents:
22622
diff
changeset
|
121 | byte_stream_putstr(&bs, ck); |
| 13235 | 122 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
123 | /* |
| 13235 | 124 | * instance |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
125 | * |
| 13235 | 126 | * Setting this to 0xffff apparently assigns the last instance. |
| 127 | * | |
| 128 | */ | |
|
22860
2b0e247173b2
All SNACs on FLAP channel 2 except in the auth family are now sent through
Evan Schoenberg <evands@pidgin.im>
parents:
22622
diff
changeset
|
129 | byte_stream_put16(&bs, 0xffff); |
| 13235 | 130 | |
| 131 | /* detail level */ | |
|
22860
2b0e247173b2
All SNACs on FLAP channel 2 except in the auth family are now sent through
Evan Schoenberg <evands@pidgin.im>
parents:
22622
diff
changeset
|
132 | byte_stream_put8(&bs, 0x01); |
| 13235 | 133 | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17280
diff
changeset
|
134 | aim_tlvlist_add_str(&tlvlist, 0x00d3, name); |
|
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17280
diff
changeset
|
135 | aim_tlvlist_add_str(&tlvlist, 0x00d6, charset); |
|
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17280
diff
changeset
|
136 | aim_tlvlist_add_str(&tlvlist, 0x00d7, lang); |
| 13235 | 137 | |
| 138 | /* tlvcount */ | |
|
22860
2b0e247173b2
All SNACs on FLAP channel 2 except in the auth family are now sent through
Evan Schoenberg <evands@pidgin.im>
parents:
22622
diff
changeset
|
139 | byte_stream_put16(&bs, aim_tlvlist_count(tlvlist)); |
|
2b0e247173b2
All SNACs on FLAP channel 2 except in the auth family are now sent through
Evan Schoenberg <evands@pidgin.im>
parents:
22622
diff
changeset
|
140 | aim_tlvlist_write(&bs, &tlvlist); |
| 13235 | 141 | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17280
diff
changeset
|
142 | aim_tlvlist_free(tlvlist); |
| 13235 | 143 | |
|
30678
78aacd015725
Removed unused "flags" parameter.
Ivan Komarov <ivan.komarov@pidgin.im>
parents:
30665
diff
changeset
|
144 | flap_connection_send_snac(od, conn, SNAC_FAMILY_CHATNAV, 0x0008, snacid, &bs); |
|
22860
2b0e247173b2
All SNACs on FLAP channel 2 except in the auth family are now sent through
Evan Schoenberg <evands@pidgin.im>
parents:
22622
diff
changeset
|
145 | |
|
2b0e247173b2
All SNACs on FLAP channel 2 except in the auth family are now sent through
Evan Schoenberg <evands@pidgin.im>
parents:
22622
diff
changeset
|
146 | byte_stream_destroy(&bs); |
| 13235 | 147 | |
| 148 | return 0; | |
| 149 | } | |
| 150 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
151 | static int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
152 | parseinfo_perms(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs, aim_snac_t *snac2) |
| 13235 | 153 | { |
| 154 | aim_rxcallback_t userfunc; | |
| 155 | int ret = 0; | |
| 156 | struct aim_chat_exchangeinfo *exchanges = NULL; | |
| 157 | int curexchange; | |
| 158 | aim_tlv_t *exchangetlv; | |
| 159 | guint8 maxrooms = 0; | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17280
diff
changeset
|
160 | GSList *tlvlist, *innerlist; |
| 13235 | 161 | |
| 162 | tlvlist = aim_tlvlist_read(bs); | |
| 163 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
164 | /* |
| 13235 | 165 | * Type 0x0002: Maximum concurrent rooms. |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
166 | */ |
| 13235 | 167 | if (aim_tlv_gettlv(tlvlist, 0x0002, 1)) |
| 168 | maxrooms = aim_tlv_get8(tlvlist, 0x0002, 1); | |
| 169 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
170 | /* |
| 13235 | 171 | * Type 0x0003: Exchange information |
| 172 | * | |
| 173 | * There can be any number of these, each one | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
174 | * representing another exchange. |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
175 | * |
| 13235 | 176 | */ |
| 177 | for (curexchange = 0; ((exchangetlv = aim_tlv_gettlv(tlvlist, 0x0003, curexchange+1))); ) { | |
|
13240
db5187cc40d1
[gaim-migrate @ 15605]
Mark Doliner <markdoliner@pidgin.im>
parents:
13235
diff
changeset
|
178 | ByteStream tbs; |
| 13235 | 179 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
180 | byte_stream_init(&tbs, exchangetlv->value, exchangetlv->length); |
| 13235 | 181 | |
| 182 | curexchange++; | |
| 183 | ||
|
17280
7c0472208173
Make all the oscar memory allocations and frees use the glib functions to avoid problems when mixing C runtimes.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
184 | exchanges = g_realloc(exchanges, curexchange * sizeof(struct aim_chat_exchangeinfo)); |
| 13235 | 185 | |
| 186 | /* exchange number */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
187 | exchanges[curexchange-1].number = byte_stream_get16(&tbs); |
| 13235 | 188 | innerlist = aim_tlvlist_read(&tbs); |
| 189 | ||
| 190 | /* | |
| 191 | * Type 0x0002: Unknown | |
| 192 | */ | |
| 193 | if (aim_tlv_gettlv(innerlist, 0x0002, 1)) { | |
| 194 | guint16 classperms; | |
| 195 | ||
| 196 | classperms = aim_tlv_get16(innerlist, 0x0002, 1); | |
| 197 | ||
| 15884 | 198 | purple_debug_misc("oscar", "faim: class permissions %x\n", classperms); |
| 13235 | 199 | } |
| 200 | ||
| 201 | /* | |
| 202 | * Type 0x00c9: Flags | |
| 203 | * | |
| 204 | * 1 Evilable | |
| 205 | * 2 Nav Only | |
| 206 | * 4 Instancing Allowed | |
| 207 | * 8 Occupant Peek Allowed | |
| 208 | * | |
| 209 | */ | |
| 210 | if (aim_tlv_gettlv(innerlist, 0x00c9, 1)) | |
| 211 | exchanges[curexchange-1].flags = aim_tlv_get16(innerlist, 0x00c9, 1); | |
| 212 | ||
| 213 | /* | |
| 214 | * Type 0x00d3: Exchange Description | |
| 215 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
216 | if (aim_tlv_gettlv(innerlist, 0x00d3, 1)) |
| 13235 | 217 | exchanges[curexchange-1].name = aim_tlv_getstr(innerlist, 0x00d3, 1); |
| 218 | else | |
| 219 | exchanges[curexchange-1].name = NULL; | |
| 220 | ||
| 221 | /* | |
| 222 | * Type 0x00d5: Creation Permissions | |
| 223 | * | |
| 224 | * 0 Creation not allowed | |
| 225 | * 1 Room creation allowed | |
| 226 | * 2 Exchange creation allowed | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
227 | * |
| 13235 | 228 | */ |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
30678
diff
changeset
|
229 | if (aim_tlv_gettlv(innerlist, 0x00d5, 1)) |
|
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
30678
diff
changeset
|
230 | aim_tlv_get8(innerlist, 0x00d5, 1); /* createperms */ |
| 13235 | 231 | |
| 232 | /* | |
| 233 | * Type 0x00d6: Character Set (First Time) | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
234 | */ |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
235 | if (aim_tlv_gettlv(innerlist, 0x00d6, 1)) |
| 13235 | 236 | exchanges[curexchange-1].charset1 = aim_tlv_getstr(innerlist, 0x00d6, 1); |
| 237 | else | |
| 238 | exchanges[curexchange-1].charset1 = NULL; | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
239 | |
| 13235 | 240 | /* |
| 241 | * Type 0x00d7: Language (First Time) | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
242 | */ |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
243 | if (aim_tlv_gettlv(innerlist, 0x00d7, 1)) |
| 13235 | 244 | exchanges[curexchange-1].lang1 = aim_tlv_getstr(innerlist, 0x00d7, 1); |
| 245 | else | |
| 246 | exchanges[curexchange-1].lang1 = NULL; | |
| 247 | ||
| 248 | /* | |
| 249 | * Type 0x00d8: Character Set (Second Time) | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
250 | */ |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
251 | if (aim_tlv_gettlv(innerlist, 0x00d8, 1)) |
| 13235 | 252 | exchanges[curexchange-1].charset2 = aim_tlv_getstr(innerlist, 0x00d8, 1); |
| 253 | else | |
| 254 | exchanges[curexchange-1].charset2 = NULL; | |
| 255 | ||
| 256 | /* | |
| 257 | * Type 0x00d9: Language (Second Time) | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
258 | */ |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
259 | if (aim_tlv_gettlv(innerlist, 0x00d9, 1)) |
| 13235 | 260 | exchanges[curexchange-1].lang2 = aim_tlv_getstr(innerlist, 0x00d9, 1); |
| 261 | else | |
| 262 | exchanges[curexchange-1].lang2 = NULL; | |
| 263 | ||
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17280
diff
changeset
|
264 | aim_tlvlist_free(innerlist); |
| 13235 | 265 | } |
| 266 | ||
| 267 | /* | |
| 268 | * Call client. | |
| 269 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
270 | if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
271 | ret = userfunc(od, conn, frame, snac2->type, maxrooms, curexchange, exchanges); |
| 13235 | 272 | |
| 273 | for (curexchange--; curexchange >= 0; curexchange--) { | |
|
17280
7c0472208173
Make all the oscar memory allocations and frees use the glib functions to avoid problems when mixing C runtimes.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
274 | g_free(exchanges[curexchange].name); |
|
7c0472208173
Make all the oscar memory allocations and frees use the glib functions to avoid problems when mixing C runtimes.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
275 | g_free(exchanges[curexchange].charset1); |
|
7c0472208173
Make all the oscar memory allocations and frees use the glib functions to avoid problems when mixing C runtimes.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
276 | g_free(exchanges[curexchange].lang1); |
|
7c0472208173
Make all the oscar memory allocations and frees use the glib functions to avoid problems when mixing C runtimes.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
277 | g_free(exchanges[curexchange].charset2); |
|
7c0472208173
Make all the oscar memory allocations and frees use the glib functions to avoid problems when mixing C runtimes.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
278 | g_free(exchanges[curexchange].lang2); |
| 13235 | 279 | } |
|
17280
7c0472208173
Make all the oscar memory allocations and frees use the glib functions to avoid problems when mixing C runtimes.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
280 | g_free(exchanges); |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17280
diff
changeset
|
281 | aim_tlvlist_free(tlvlist); |
| 13235 | 282 | |
| 283 | return ret; | |
| 284 | } | |
| 285 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
286 | static int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
287 | parseinfo_create(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs, aim_snac_t *snac2) |
| 13235 | 288 | { |
| 289 | aim_rxcallback_t userfunc; | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17280
diff
changeset
|
290 | GSList *tlvlist, *innerlist; |
| 13235 | 291 | char *ck = NULL, *fqcn = NULL, *name = NULL; |
| 292 | guint16 exchange = 0, instance = 0, unknown = 0, flags = 0, maxmsglen = 0, maxoccupancy = 0; | |
| 293 | guint32 createtime = 0; | |
| 294 | guint8 createperms = 0, detaillevel; | |
| 295 | int cklen; | |
| 296 | aim_tlv_t *bigblock; | |
| 297 | int ret = 0; | |
|
13240
db5187cc40d1
[gaim-migrate @ 15605]
Mark Doliner <markdoliner@pidgin.im>
parents:
13235
diff
changeset
|
298 | ByteStream bbbs; |
| 13235 | 299 | |
| 300 | tlvlist = aim_tlvlist_read(bs); | |
| 301 | ||
| 302 | if (!(bigblock = aim_tlv_gettlv(tlvlist, 0x0004, 1))) { | |
| 15884 | 303 | purple_debug_misc("oscar", "no bigblock in top tlv in create room response\n"); |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17280
diff
changeset
|
304 | aim_tlvlist_free(tlvlist); |
| 13235 | 305 | return 0; |
| 306 | } | |
| 307 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
308 | byte_stream_init(&bbbs, bigblock->value, bigblock->length); |
| 13235 | 309 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
310 | exchange = byte_stream_get16(&bbbs); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
311 | cklen = byte_stream_get8(&bbbs); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
312 | ck = byte_stream_getstr(&bbbs, cklen); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
313 | instance = byte_stream_get16(&bbbs); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
314 | detaillevel = byte_stream_get8(&bbbs); |
| 13235 | 315 | |
| 316 | if (detaillevel != 0x02) { | |
| 15884 | 317 | purple_debug_misc("oscar", "unknown detaillevel in create room response (0x%02x)\n", detaillevel); |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17280
diff
changeset
|
318 | aim_tlvlist_free(tlvlist); |
|
17280
7c0472208173
Make all the oscar memory allocations and frees use the glib functions to avoid problems when mixing C runtimes.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
319 | g_free(ck); |
| 13235 | 320 | return 0; |
| 321 | } | |
| 322 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
323 | unknown = byte_stream_get16(&bbbs); |
| 13235 | 324 | |
| 325 | innerlist = aim_tlvlist_read(&bbbs); | |
| 326 | ||
| 327 | if (aim_tlv_gettlv(innerlist, 0x006a, 1)) | |
| 328 | fqcn = aim_tlv_getstr(innerlist, 0x006a, 1); | |
| 329 | ||
| 330 | if (aim_tlv_gettlv(innerlist, 0x00c9, 1)) | |
| 331 | flags = aim_tlv_get16(innerlist, 0x00c9, 1); | |
| 332 | ||
| 333 | if (aim_tlv_gettlv(innerlist, 0x00ca, 1)) | |
| 334 | createtime = aim_tlv_get32(innerlist, 0x00ca, 1); | |
| 335 | ||
| 336 | if (aim_tlv_gettlv(innerlist, 0x00d1, 1)) | |
| 337 | maxmsglen = aim_tlv_get16(innerlist, 0x00d1, 1); | |
| 338 | ||
| 339 | if (aim_tlv_gettlv(innerlist, 0x00d2, 1)) | |
| 340 | maxoccupancy = aim_tlv_get16(innerlist, 0x00d2, 1); | |
| 341 | ||
| 342 | if (aim_tlv_gettlv(innerlist, 0x00d3, 1)) | |
| 343 | name = aim_tlv_getstr(innerlist, 0x00d3, 1); | |
| 344 | ||
| 345 | if (aim_tlv_gettlv(innerlist, 0x00d5, 1)) | |
| 346 | createperms = aim_tlv_get8(innerlist, 0x00d5, 1); | |
| 347 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
348 | if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) { |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
349 | ret = userfunc(od, conn, frame, snac2->type, fqcn, instance, exchange, flags, createtime, maxmsglen, maxoccupancy, createperms, unknown, name, ck); |
| 13235 | 350 | } |
| 351 | ||
|
17280
7c0472208173
Make all the oscar memory allocations and frees use the glib functions to avoid problems when mixing C runtimes.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
352 | g_free(ck); |
|
7c0472208173
Make all the oscar memory allocations and frees use the glib functions to avoid problems when mixing C runtimes.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
353 | g_free(name); |
|
7c0472208173
Make all the oscar memory allocations and frees use the glib functions to avoid problems when mixing C runtimes.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
354 | g_free(fqcn); |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17280
diff
changeset
|
355 | aim_tlvlist_free(innerlist); |
|
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17280
diff
changeset
|
356 | aim_tlvlist_free(tlvlist); |
| 13235 | 357 | |
| 358 | return ret; | |
| 359 | } | |
| 360 | ||
| 361 | /* | |
| 362 | * Subtype 0x0009 | |
| 363 | * | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
364 | * Since multiple things can trigger this callback, we must lookup the |
| 13235 | 365 | * snacid to determine the original snac subtype that was called. |
| 366 | * | |
| 367 | * XXX This isn't really how this works. But this is: Every d/9 response | |
| 368 | * has a 16bit value at the beginning. That matches to: | |
| 369 | * Short Desc = 1 | |
| 370 | * Full Desc = 2 | |
| 371 | * Instance Info = 4 | |
| 372 | * Nav Short Desc = 8 | |
| 373 | * Nav Instance Info = 16 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
374 | * And then everything is really asynchronous. There is no specific |
| 13235 | 375 | * attachment of a response to a create room request, for example. Creating |
| 376 | * the room yields no different a response than requesting the room's info. | |
| 377 | * | |
| 378 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
379 | static int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
380 | parseinfo(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) |
| 13235 | 381 | { |
| 382 | aim_snac_t *snac2; | |
| 383 | int ret = 0; | |
| 384 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
385 | if (!(snac2 = aim_remsnac(od, snac->id))) { |
|
22622
1ecb840b5101
Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <markdoliner@pidgin.im>
parents:
21846
diff
changeset
|
386 | purple_debug_misc("oscar", "faim: chatnav_parse_info: received response to unknown request! (%08x)\n", snac->id); |
| 13235 | 387 | return 0; |
| 388 | } | |
| 389 | ||
|
23456
66ab07770438
Replaced family_*'s magic numbers of FLAP families with the constants
Evan Schoenberg <evands@pidgin.im>
parents:
22860
diff
changeset
|
390 | if (snac2->family != SNAC_FAMILY_CHATNAV) { |
| 15884 | 391 | purple_debug_misc("oscar", "faim: chatnav_parse_info: received response that maps to corrupt request! (fam=%04x)\n", snac2->family); |
|
26898
11269f6382c1
fixes a potential leak on error case
Ka-Hing Cheung <khc@pidgin.im>
parents:
23456
diff
changeset
|
392 | g_free(snac2->data); |
|
11269f6382c1
fixes a potential leak on error case
Ka-Hing Cheung <khc@pidgin.im>
parents:
23456
diff
changeset
|
393 | g_free(snac2); |
| 13235 | 394 | return 0; |
| 395 | } | |
| 396 | ||
| 397 | /* | |
| 398 | * We now know what the original SNAC subtype was. | |
| 399 | */ | |
| 400 | if (snac2->type == 0x0002) /* request chat rights */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
401 | ret = parseinfo_perms(od, conn, mod, frame, snac, bs, snac2); |
| 13235 | 402 | else if (snac2->type == 0x0003) /* request exchange info */ |
| 18953 | 403 | purple_debug_misc("oscar", "chatnav_parse_info: response to exchange info\n"); |
| 13235 | 404 | else if (snac2->type == 0x0004) /* request room info */ |
| 15884 | 405 | purple_debug_misc("oscar", "chatnav_parse_info: response to room info\n"); |
| 13235 | 406 | else if (snac2->type == 0x0005) /* request more room info */ |
| 15884 | 407 | purple_debug_misc("oscar", "chatnav_parse_info: response to more room info\n"); |
| 13235 | 408 | else if (snac2->type == 0x0006) /* request occupant list */ |
| 15884 | 409 | purple_debug_misc("oscar", "chatnav_parse_info: response to occupant info\n"); |
| 13235 | 410 | else if (snac2->type == 0x0007) /* search for a room */ |
| 15884 | 411 | purple_debug_misc("oscar", "chatnav_parse_info: search results\n"); |
| 13235 | 412 | else if (snac2->type == 0x0008) /* create room */ |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
413 | ret = parseinfo_create(od, conn, mod, frame, snac, bs, snac2); |
| 13235 | 414 | else |
| 15884 | 415 | purple_debug_misc("oscar", "chatnav_parse_info: unknown request subtype (%04x)\n", snac2->type); |
| 13235 | 416 | |
| 417 | if (snac2) | |
|
17280
7c0472208173
Make all the oscar memory allocations and frees use the glib functions to avoid problems when mixing C runtimes.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
418 | g_free(snac2->data); |
|
7c0472208173
Make all the oscar memory allocations and frees use the glib functions to avoid problems when mixing C runtimes.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
419 | g_free(snac2); |
| 13235 | 420 | |
| 421 | return ret; | |
| 422 | } | |
| 423 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
424 | static int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
425 | snachandler(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) |
| 13235 | 426 | { |
|
21846
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
427 | if (snac->subtype == 0x0001) |
|
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
428 | return error(od, conn, mod, frame, snac, bs); |
|
ec28f735f3ad
Handle invalid room names and invalid exchanges better, by showing a
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
429 | else if (snac->subtype == 0x0009) |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
430 | return parseinfo(od, conn, mod, frame, snac, bs); |
| 13235 | 431 | |
| 432 | return 0; | |
| 433 | } | |
| 434 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
435 | int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
436 | chatnav_modfirst(OscarData *od, aim_module_t *mod) |
| 13235 | 437 | { |
|
23456
66ab07770438
Replaced family_*'s magic numbers of FLAP families with the constants
Evan Schoenberg <evands@pidgin.im>
parents:
22860
diff
changeset
|
438 | mod->family = SNAC_FAMILY_CHATNAV; |
| 13235 | 439 | mod->version = 0x0001; |
| 440 | mod->toolid = 0x0010; | |
| 441 | mod->toolversion = 0x0629; | |
| 442 | mod->flags = 0; | |
| 443 | strncpy(mod->name, "chatnav", sizeof(mod->name)); | |
| 444 | mod->snachandler = snachandler; | |
| 445 | ||
| 446 | return 0; | |
| 447 | } |