Changeset 5ebff60 for protocols/oscar/chatnav.c
- Timestamp:
- 2015-02-20T22:50:54Z (9 years ago)
- Branches:
- master
- Children:
- 0b9daac, 3d45471, 7733b8c
- Parents:
- af359b4
- git-author:
- Indent <please@…> (19-02-15 05:47:20)
- git-committer:
- dequis <dx@…> (20-02-15 22:50:54)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/oscar/chatnav.c
raf359b4 r5ebff60 3 3 * 4 4 * [The ChatNav(igation) service does various things to keep chat 5 * alive. It provides room information, room searching and creating, 5 * alive. It provides room information, room searching and creating, 6 6 * as well as giving users the right ("permission") to use chat.] 7 7 * … … 21 21 int aim_chatnav_createroom(aim_session_t *sess, aim_conn_t *conn, const char *name, guint16 exchange) 22 22 { 23 static const char ck[] = { "create"};24 static const char lang[] = { "en"};25 static const char charset[] = { "us-ascii"};23 static const char ck[] = { "create" }; 24 static const char lang[] = { "en" }; 25 static const char charset[] = { "us-ascii" }; 26 26 aim_frame_t *fr; 27 27 aim_snacid_t snacid; 28 28 aim_tlvlist_t *tl = NULL; 29 29 30 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1152))) 30 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1152))) { 31 31 return -ENOMEM; 32 } 32 33 33 34 snacid = aim_cachesnac(sess, 0x000d, 0x0008, 0x0000, NULL, 0); … … 40 41 * This looks to be a big hack. You'll note that this entire 41 42 * SNAC is just a room info structure, but the hard room name, 42 * here, is set to "create". 43 * here, is set to "create". 43 44 * 44 45 * Either this goes on the "list of questions concerning … … 49 50 */ 50 51 aimbs_put8(&fr->data, strlen(ck)); 51 aimbs_putraw(&fr->data, (guint8 *) ck, strlen(ck));52 53 /* 52 aimbs_putraw(&fr->data, (guint8 *) ck, strlen(ck)); 53 54 /* 54 55 * instance 55 * 56 * 56 57 * Setting this to 0xffff apparently assigns the last instance. 57 58 * … … 62 63 aimbs_put8(&fr->data, 0x01); 63 64 64 aim_addtlvtochain_raw(&tl, 0x00d3, strlen(name), (guint8 *) name);65 aim_addtlvtochain_raw(&tl, 0x00d6, strlen(charset), (guint8 *) charset);66 aim_addtlvtochain_raw(&tl, 0x00d7, strlen(lang), (guint8 *) lang);65 aim_addtlvtochain_raw(&tl, 0x00d3, strlen(name), (guint8 *) name); 66 aim_addtlvtochain_raw(&tl, 0x00d6, strlen(charset), (guint8 *) charset); 67 aim_addtlvtochain_raw(&tl, 0x00d7, strlen(lang), (guint8 *) lang); 67 68 68 69 /* tlvcount */ … … 77 78 } 78 79 79 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) 80 static int parseinfo_perms(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, 81 aim_bstream_t *bs, aim_snac_t *snac2) 80 82 { 81 83 aim_rxcallback_t userfunc; … … 89 91 tlvlist = aim_readtlvchain(bs); 90 92 91 /* 93 /* 92 94 * Type 0x0002: Maximum concurrent rooms. 93 */ 94 if (aim_gettlv(tlvlist, 0x0002, 1)) 95 */ 96 if (aim_gettlv(tlvlist, 0x0002, 1)) { 95 97 maxrooms = aim_gettlv8(tlvlist, 0x0002, 1); 96 97 /* 98 } 99 100 /* 98 101 * Type 0x0003: Exchange information 99 102 * 100 103 * There can be any number of these, each one 101 * representing another exchange. 102 * 103 */ 104 for (curexchange = 0; ((exchangetlv = aim_gettlv(tlvlist, 0x0003, curexchange +1))); ) {104 * representing another exchange. 105 * 106 */ 107 for (curexchange = 0; ((exchangetlv = aim_gettlv(tlvlist, 0x0003, curexchange + 1))); ) { 105 108 aim_bstream_t tbs; 106 109 … … 112 115 113 116 /* exchange number */ 114 exchanges[curexchange -1].number = aimbs_get16(&tbs);117 exchanges[curexchange - 1].number = aimbs_get16(&tbs); 115 118 innerlist = aim_readtlvchain(&tbs); 116 119 117 /* 120 /* 118 121 * Type 0x000a: Unknown. 119 122 * … … 121 124 * 122 125 */ 123 if (aim_gettlv(innerlist, 0x000a, 1)) 124 ; 125 126 /* 126 if (aim_gettlv(innerlist, 0x000a, 1)) { 127 ; 128 } 129 130 /* 127 131 * Type 0x000d: Unknown. 128 132 */ 129 if (aim_gettlv(innerlist, 0x000d, 1)) 130 ; 131 132 /* 133 if (aim_gettlv(innerlist, 0x000d, 1)) { 134 ; 135 } 136 137 /* 133 138 * Type 0x0004: Unknown 134 139 */ 135 if (aim_gettlv(innerlist, 0x0004, 1)) 136 ; 137 138 /* 140 if (aim_gettlv(innerlist, 0x0004, 1)) { 141 ; 142 } 143 144 /* 139 145 * Type 0x0002: Unknown 140 146 */ 141 if (aim_gettlv(innerlist, 0x0002, 1)) 142 ; 147 if (aim_gettlv(innerlist, 0x0002, 1)) { 148 ; 149 } 143 150 144 151 /* … … 150 157 * 8 Occupant Peek Allowed 151 158 * 152 */ 153 if (aim_gettlv(innerlist, 0x00c9, 1)) 154 exchanges[curexchange-1].flags = aim_gettlv16(innerlist, 0x00c9, 1); 155 156 /* 157 * Type 0x00ca: Creation Date 158 */ 159 if (aim_gettlv(innerlist, 0x00ca, 1)) 160 ; 161 159 */ 160 if (aim_gettlv(innerlist, 0x00c9, 1)) { 161 exchanges[curexchange - 1].flags = aim_gettlv16(innerlist, 0x00c9, 1); 162 } 163 164 /* 165 * Type 0x00ca: Creation Date 166 */ 167 if (aim_gettlv(innerlist, 0x00ca, 1)) { 168 ; 169 } 170 162 171 /* 163 172 * Type 0x00d0: Mandatory Channels? 164 173 */ 165 if (aim_gettlv(innerlist, 0x00d0, 1)) 166 ; 174 if (aim_gettlv(innerlist, 0x00d0, 1)) { 175 ; 176 } 167 177 168 178 /* 169 179 * Type 0x00d1: Maximum Message length 170 180 */ 171 if (aim_gettlv(innerlist, 0x00d1, 1)) 172 ; 181 if (aim_gettlv(innerlist, 0x00d1, 1)) { 182 ; 183 } 173 184 174 185 /* 175 186 * Type 0x00d2: Maximum Occupancy? 176 187 */ 177 if (aim_gettlv(innerlist, 0x00d2, 1)) 178 ; 188 if (aim_gettlv(innerlist, 0x00d2, 1)) { 189 ; 190 } 179 191 180 192 /* 181 193 * Type 0x00d3: Exchange Description 182 194 */ 183 if (aim_gettlv(innerlist, 0x00d3, 1)) 184 exchanges[curexchange-1].name = aim_gettlv_str(innerlist, 0x00d3, 1); 185 else 186 exchanges[curexchange-1].name = NULL; 195 if (aim_gettlv(innerlist, 0x00d3, 1)) { 196 exchanges[curexchange - 1].name = aim_gettlv_str(innerlist, 0x00d3, 1); 197 } else { 198 exchanges[curexchange - 1].name = NULL; 199 } 187 200 188 201 /* 189 202 * Type 0x00d4: Exchange Description URL 190 203 */ 191 if (aim_gettlv(innerlist, 0x00d4, 1)) 192 ; 204 if (aim_gettlv(innerlist, 0x00d4, 1)) { 205 ; 206 } 193 207 194 208 /* … … 198 212 * 1 Room creation allowed 199 213 * 2 Exchange creation allowed 200 * 214 * 201 215 */ 202 216 if (aim_gettlv(innerlist, 0x00d5, 1)) { … … 206 220 /* 207 221 * Type 0x00d6: Character Set (First Time) 208 */ 209 if (aim_gettlv(innerlist, 0x00d6, 1)) 210 exchanges[curexchange-1].charset1 = aim_gettlv_str(innerlist, 0x00d6, 1); 211 else 212 exchanges[curexchange-1].charset1 = NULL; 213 222 */ 223 if (aim_gettlv(innerlist, 0x00d6, 1)) { 224 exchanges[curexchange - 1].charset1 = aim_gettlv_str(innerlist, 0x00d6, 1); 225 } else { 226 exchanges[curexchange - 1].charset1 = NULL; 227 } 228 214 229 /* 215 230 * Type 0x00d7: Language (First Time) 216 */ 217 if (aim_gettlv(innerlist, 0x00d7, 1)) 218 exchanges[curexchange-1].lang1 = aim_gettlv_str(innerlist, 0x00d7, 1); 219 else 220 exchanges[curexchange-1].lang1 = NULL; 231 */ 232 if (aim_gettlv(innerlist, 0x00d7, 1)) { 233 exchanges[curexchange - 1].lang1 = aim_gettlv_str(innerlist, 0x00d7, 1); 234 } else { 235 exchanges[curexchange - 1].lang1 = NULL; 236 } 221 237 222 238 /* 223 239 * Type 0x00d8: Character Set (Second Time) 224 */ 225 if (aim_gettlv(innerlist, 0x00d8, 1)) 226 exchanges[curexchange-1].charset2 = aim_gettlv_str(innerlist, 0x00d8, 1); 227 else 228 exchanges[curexchange-1].charset2 = NULL; 240 */ 241 if (aim_gettlv(innerlist, 0x00d8, 1)) { 242 exchanges[curexchange - 1].charset2 = aim_gettlv_str(innerlist, 0x00d8, 1); 243 } else { 244 exchanges[curexchange - 1].charset2 = NULL; 245 } 229 246 230 247 /* 231 248 * Type 0x00d9: Language (Second Time) 232 */ 233 if (aim_gettlv(innerlist, 0x00d9, 1)) 234 exchanges[curexchange-1].lang2 = aim_gettlv_str(innerlist, 0x00d9, 1); 235 else 236 exchanges[curexchange-1].lang2 = NULL; 237 249 */ 250 if (aim_gettlv(innerlist, 0x00d9, 1)) { 251 exchanges[curexchange - 1].lang2 = aim_gettlv_str(innerlist, 0x00d9, 1); 252 } else { 253 exchanges[curexchange - 1].lang2 = NULL; 254 } 255 238 256 /* 239 257 * Type 0x00da: Unknown 240 258 */ 241 if (aim_gettlv(innerlist, 0x00da, 1)) 242 ; 259 if (aim_gettlv(innerlist, 0x00da, 1)) { 260 ; 261 } 243 262 244 263 aim_freetlvchain(&innerlist); … … 248 267 * Call client. 249 268 */ 250 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) 269 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) { 251 270 ret = userfunc(sess, rx, snac2->type, maxrooms, curexchange, exchanges); 271 } 252 272 253 273 for (curexchange--; curexchange >= 0; curexchange--) { … … 264 284 } 265 285 266 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) 286 static int parseinfo_create(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, 287 aim_bstream_t *bs, aim_snac_t *snac2) 267 288 { 268 289 aim_rxcallback_t userfunc; … … 281 302 if (!(bigblock = aim_gettlv(tlvlist, 0x0004, 1))) { 282 303 imcb_error(sess->aux_data, "no bigblock in top tlv in create room response"); 283 304 284 305 aim_freetlvchain(&tlvlist); 285 306 return 0; … … 305 326 innerlist = aim_readtlvchain(&bbbs); 306 327 307 if (aim_gettlv(innerlist, 0x006a, 1)) 328 if (aim_gettlv(innerlist, 0x006a, 1)) { 308 329 fqcn = aim_gettlv_str(innerlist, 0x006a, 1); 309 310 if (aim_gettlv(innerlist, 0x00c9, 1)) 330 } 331 332 if (aim_gettlv(innerlist, 0x00c9, 1)) { 311 333 flags = aim_gettlv16(innerlist, 0x00c9, 1); 312 313 if (aim_gettlv(innerlist, 0x00ca, 1)) 334 } 335 336 if (aim_gettlv(innerlist, 0x00ca, 1)) { 314 337 createtime = aim_gettlv32(innerlist, 0x00ca, 1); 315 316 if (aim_gettlv(innerlist, 0x00d1, 1)) 338 } 339 340 if (aim_gettlv(innerlist, 0x00d1, 1)) { 317 341 maxmsglen = aim_gettlv16(innerlist, 0x00d1, 1); 318 319 if (aim_gettlv(innerlist, 0x00d2, 1)) 342 } 343 344 if (aim_gettlv(innerlist, 0x00d2, 1)) { 320 345 maxoccupancy = aim_gettlv16(innerlist, 0x00d2, 1); 321 322 if (aim_gettlv(innerlist, 0x00d3, 1)) 346 } 347 348 if (aim_gettlv(innerlist, 0x00d3, 1)) { 323 349 name = aim_gettlv_str(innerlist, 0x00d3, 1); 324 325 if (aim_gettlv(innerlist, 0x00d5, 1)) 350 } 351 352 if (aim_gettlv(innerlist, 0x00d5, 1)) { 326 353 createperms = aim_gettlv8(innerlist, 0x00d5, 1); 354 } 327 355 328 356 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) { 329 ret = userfunc(sess, rx, snac2->type, fqcn, instance, exchange, flags, createtime, maxmsglen, maxoccupancy, createperms, unknown, name, ck); 357 ret = userfunc(sess, rx, snac2->type, fqcn, instance, exchange, flags, createtime, maxmsglen, 358 maxoccupancy, createperms, unknown, name, ck); 330 359 } 331 360 … … 340 369 341 370 /* 342 * Since multiple things can trigger this callback, we must lookup the 371 * Since multiple things can trigger this callback, we must lookup the 343 372 * snacid to determine the original snac subtype that was called. 344 373 * … … 350 379 * Nav Short Desc = 8 351 380 * Nav Instance Info = 16 352 * And then everything is really asynchronous. There is no specific 381 * And then everything is really asynchronous. There is no specific 353 382 * attachment of a response to a create room request, for example. Creating 354 383 * the room yields no different a response than requesting the room's info. … … 373 402 * We now know what the original SNAC subtype was. 374 403 */ 375 if (snac2->type == 0x0002) /* request chat rights */404 if (snac2->type == 0x0002) { /* request chat rights */ 376 405 ret = parseinfo_perms(sess, mod, rx, snac, bs, snac2); 377 else if (snac2->type == 0x0003) {} /* request exchange info */ 378 else if (snac2->type == 0x0004) {} /* request room info */ 379 else if (snac2->type == 0x0005) {} /* request more room info */ 380 else if (snac2->type == 0x0006) {} /* request occupant list */ 381 else if (snac2->type == 0x0007) {} /* search for a room */ 382 else if (snac2->type == 0x0008) /* create room */ 406 } else if (snac2->type == 0x0003) { 407 } /* request exchange info */ 408 else if (snac2->type == 0x0004) { 409 } /* request room info */ 410 else if (snac2->type == 0x0005) { 411 } /* request more room info */ 412 else if (snac2->type == 0x0006) { 413 } /* request occupant list */ 414 else if (snac2->type == 0x0007) { 415 } /* search for a room */ 416 else if (snac2->type == 0x0008) { /* create room */ 383 417 ret = parseinfo_create(sess, mod, rx, snac, bs, snac2); 384 else418 } else { 385 419 imcb_error(sess->aux_data, "unknown request subtype"); 386 387 if (snac2) 420 } 421 422 if (snac2) { 388 423 g_free(snac2->data); 424 } 389 425 g_free(snac2); 390 426 … … 395 431 { 396 432 397 if (snac->subtype == 0x0009) 433 if (snac->subtype == 0x0009) { 398 434 return parseinfo(sess, mod, rx, snac, bs); 435 } 399 436 400 437 return 0;
Note: See TracChangeset
for help on using the changeset viewer.