Mercurial > pidgin.yaz
comparison src/protocols/yahoo/yahoochat.c @ 7827:ee32e030c9be
[gaim-migrate @ 8479]
marv asserts that these character set conversions are more correct
than the previous yahoo conversions, which assumed that pretty much
everything was UTF-8. I believe him.
committer: Tailor Script <tailor@pidgin.im>
author | Ethan Blanton <elb@pidgin.im> |
---|---|
date | Wed, 10 Dec 2003 16:48:23 +0000 |
parents | 0da869011d8a |
children | 0555e59dfba9 |
comparison
equal
deleted
inserted
replaced
7826:5ba07997ade3 | 7827:ee32e030c9be |
---|---|
128 | 128 |
129 switch (pair->key) { | 129 switch (pair->key) { |
130 case 1: /* us, but we already know who we are */ | 130 case 1: /* us, but we already know who we are */ |
131 break; | 131 break; |
132 case 57: | 132 case 57: |
133 room = pair->value; | 133 room = yahoo_string_decode(gc, pair->value, FALSE); |
134 break; | 134 break; |
135 case 50: /* inviter */ | 135 case 50: /* inviter */ |
136 who = pair->value; | 136 who = pair->value; |
137 g_string_append_printf(members, "%s\n", who); | 137 g_string_append_printf(members, "%s\n", who); |
138 break; | 138 break; |
139 case 52: /* members */ | 139 case 52: /* members */ |
140 g_string_append_printf(members, "%s\n", pair->value); | 140 g_string_append_printf(members, "%s\n", pair->value); |
141 break; | 141 break; |
142 case 58: | 142 case 58: |
143 msg = pair->value; | 143 msg = yahoo_string_decode(gc, pair->value, FALSE); |
144 break; | 144 break; |
145 case 13: /* ? */ | 145 case 13: /* ? */ |
146 break; | 146 break; |
147 } | 147 } |
148 } | 148 } |
151 g_string_free(members, TRUE); | 151 g_string_free(members, TRUE); |
152 return; | 152 return; |
153 } | 153 } |
154 | 154 |
155 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | 155 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); |
156 g_hash_table_replace(components, g_strdup("room"), g_strdup(room)); | 156 g_hash_table_replace(components, g_strdup("room"), room); |
157 if (msg) | 157 if (msg) |
158 g_hash_table_replace(components, g_strdup("topic"), g_strdup(msg)); | 158 g_hash_table_replace(components, g_strdup("topic"), msg); |
159 g_hash_table_replace(components, g_strdup("type"), g_strdup("Conference")); | 159 g_hash_table_replace(components, g_strdup("type"), g_strdup("Conference")); |
160 if (members) { | 160 if (members) { |
161 g_hash_table_replace(components, g_strdup("members"), g_strdup(members->str)); | 161 g_hash_table_replace(components, g_strdup("members"), g_strdup(members->str)); |
162 } | 162 } |
163 serv_got_chat_invite(gc, room, who, msg, components); | 163 serv_got_chat_invite(gc, room, who, msg, components); |
175 for (l = pkt->hash; l; l = l->next) { | 175 for (l = pkt->hash; l; l = l->next) { |
176 struct yahoo_pair *pair = l->data; | 176 struct yahoo_pair *pair = l->data; |
177 | 177 |
178 switch (pair->key) { | 178 switch (pair->key) { |
179 case 57: | 179 case 57: |
180 room = pair->value; | 180 room = yahoo_string_decode(gc, pair->value, FALSE); |
181 break; | 181 break; |
182 case 54: | 182 case 54: |
183 who = pair->value; | 183 who = pair->value; |
184 break; | 184 break; |
185 case 14: | 185 case 14: |
186 msg = pair->value; | 186 msg = yahoo_string_decode(gc, pair->value, FALSE); |
187 break; | 187 break; |
188 } | 188 } |
189 } | 189 } |
190 | 190 |
191 if (who && room) { | 191 if (who && room) { |
193 | 193 |
194 tmp = g_strdup_printf(_("%s declined your conference invitation to room \"%s\" because \"%s\"."), | 194 tmp = g_strdup_printf(_("%s declined your conference invitation to room \"%s\" because \"%s\"."), |
195 who, room, msg?msg:""); | 195 who, room, msg?msg:""); |
196 gaim_notify_info(gc, NULL, _("Invitation Rejected"), tmp); | 196 gaim_notify_info(gc, NULL, _("Invitation Rejected"), tmp); |
197 g_free(tmp); | 197 g_free(tmp); |
198 g_free(room); | |
199 if (msg) | |
200 g_free(msg); | |
198 } | 201 } |
199 } | 202 } |
200 | 203 |
201 void yahoo_process_conference_logon(GaimConnection *gc, struct yahoo_packet *pkt) | 204 void yahoo_process_conference_logon(GaimConnection *gc, struct yahoo_packet *pkt) |
202 { | 205 { |
208 for (l = pkt->hash; l; l = l->next) { | 211 for (l = pkt->hash; l; l = l->next) { |
209 struct yahoo_pair *pair = l->data; | 212 struct yahoo_pair *pair = l->data; |
210 | 213 |
211 switch (pair->key) { | 214 switch (pair->key) { |
212 case 57: | 215 case 57: |
213 room = pair->value; | 216 room = yahoo_string_decode(gc, pair->value, FALSE); |
214 break; | 217 break; |
215 case 53: | 218 case 53: |
216 who = pair->value; | 219 who = pair->value; |
217 break; | 220 break; |
218 } | 221 } |
220 | 223 |
221 if (who && room) { | 224 if (who && room) { |
222 c = yahoo_find_conference(gc, room); | 225 c = yahoo_find_conference(gc, room); |
223 if (c) | 226 if (c) |
224 yahoo_chat_add_user(GAIM_CONV_CHAT(c), who, NULL); | 227 yahoo_chat_add_user(GAIM_CONV_CHAT(c), who, NULL); |
228 g_free(room); | |
225 } | 229 } |
226 } | 230 } |
227 | 231 |
228 void yahoo_process_conference_logoff(GaimConnection *gc, struct yahoo_packet *pkt) | 232 void yahoo_process_conference_logoff(GaimConnection *gc, struct yahoo_packet *pkt) |
229 { | 233 { |
235 for (l = pkt->hash; l; l = l->next) { | 239 for (l = pkt->hash; l; l = l->next) { |
236 struct yahoo_pair *pair = l->data; | 240 struct yahoo_pair *pair = l->data; |
237 | 241 |
238 switch (pair->key) { | 242 switch (pair->key) { |
239 case 57: | 243 case 57: |
240 room = pair->value; | 244 room = yahoo_string_decode(gc, pair->value, FALSE); |
241 break; | 245 break; |
242 case 56: | 246 case 56: |
243 who = pair->value; | 247 who = pair->value; |
244 break; | 248 break; |
245 } | 249 } |
247 | 251 |
248 if (who && room) { | 252 if (who && room) { |
249 c = yahoo_find_conference(gc, room); | 253 c = yahoo_find_conference(gc, room); |
250 if (c) | 254 if (c) |
251 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c), who, NULL); | 255 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c), who, NULL); |
256 g_free(room); | |
252 } | 257 } |
253 } | 258 } |
254 | 259 |
255 void yahoo_process_conference_message(GaimConnection *gc, struct yahoo_packet *pkt) | 260 void yahoo_process_conference_message(GaimConnection *gc, struct yahoo_packet *pkt) |
256 { | 261 { |
257 GSList *l; | 262 GSList *l; |
258 char *room = NULL; | 263 char *room = NULL; |
259 char *who = NULL; | 264 char *who = NULL; |
260 char *msg = NULL; | 265 char *msg = NULL; |
266 char *msg2; | |
267 int utf8 = 0; | |
261 GaimConversation *c; | 268 GaimConversation *c; |
262 | 269 |
263 for (l = pkt->hash; l; l = l->next) { | 270 for (l = pkt->hash; l; l = l->next) { |
264 struct yahoo_pair *pair = l->data; | 271 struct yahoo_pair *pair = l->data; |
265 | 272 |
266 switch (pair->key) { | 273 switch (pair->key) { |
267 case 57: | 274 case 57: |
268 room = pair->value; | 275 room = yahoo_string_decode(gc, pair->value, FALSE); |
269 break; | 276 break; |
270 case 3: | 277 case 3: |
271 who = pair->value; | 278 who = pair->value; |
272 break; | 279 break; |
273 case 14: | 280 case 14: |
274 msg = pair->value; | 281 msg = pair->value; |
275 break; | 282 break; |
283 case 97: | |
284 utf8 = strtol(pair->value, NULL, 10); | |
285 break; | |
276 } | 286 } |
277 } | 287 } |
278 | 288 |
279 if (room && who && msg) { | 289 if (room && who && msg) { |
290 msg2 = yahoo_string_decode(gc, msg, utf8); | |
280 c = yahoo_find_conference(gc, room); | 291 c = yahoo_find_conference(gc, room); |
281 if (!c) | 292 if (!c) |
282 return; | 293 return; |
283 msg = yahoo_codes_to_html(msg); | 294 msg = yahoo_codes_to_html(msg2); |
284 serv_got_chat_in(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(c)), who, 0, msg, time(NULL)); | 295 serv_got_chat_in(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(c)), who, 0, msg, time(NULL)); |
285 g_free(msg); | 296 g_free(msg); |
286 } | 297 g_free(msg2); |
287 | 298 } |
299 if (room) | |
300 g_free(room); | |
288 } | 301 } |
289 | 302 |
290 | 303 |
291 /* this is a comfirmation of yahoo_chat_online(); */ | 304 /* this is a comfirmation of yahoo_chat_online(); */ |
292 void yahoo_process_chat_online(GaimConnection *gc, struct yahoo_packet *pkt) | 305 void yahoo_process_chat_online(GaimConnection *gc, struct yahoo_packet *pkt) |
300 /* this is basicly the opposite of chat_online */ | 313 /* this is basicly the opposite of chat_online */ |
301 void yahoo_process_chat_logout(GaimConnection *gc, struct yahoo_packet *pkt) | 314 void yahoo_process_chat_logout(GaimConnection *gc, struct yahoo_packet *pkt) |
302 { | 315 { |
303 struct yahoo_data *yd = (struct yahoo_data *) gc->proto_data; | 316 struct yahoo_data *yd = (struct yahoo_data *) gc->proto_data; |
304 GSList *l; | 317 GSList *l; |
305 | 318 |
306 for (l = pkt->hash; l; l = l->next) { | 319 for (l = pkt->hash; l; l = l->next) { |
307 struct yahoo_pair *pair = l->data; | 320 struct yahoo_pair *pair = l->data; |
308 | 321 |
309 if (pair->key == 1) | 322 if (pair->key == 1) |
310 if (g_ascii_strcasecmp(pair->value, | 323 if (g_ascii_strcasecmp(pair->value, |
311 gaim_connection_get_display_name(gc))) | 324 gaim_connection_get_display_name(gc))) |
312 return; | 325 return; |
313 } | 326 } |
314 | 327 |
315 if (pkt->status == 1) { | 328 if (pkt->status == 1) { |
316 yd->chat_online = 0; | 329 yd->chat_online = 0; |
317 if (yd->in_chat) | 330 if (yd->in_chat) |
318 yahoo_c_leave(gc, YAHOO_CHAT_ID); | 331 yahoo_c_leave(gc, YAHOO_CHAT_ID); |
319 } | 332 } |
338 struct yahoo_pair *pair = l->data; | 351 struct yahoo_pair *pair = l->data; |
339 | 352 |
340 switch (pair->key) { | 353 switch (pair->key) { |
341 | 354 |
342 case 104: | 355 case 104: |
343 room = pair->value; | 356 room = yahoo_string_decode(gc, pair->value, FALSE); |
344 break; | 357 break; |
345 case 105: | 358 case 105: |
346 topic = pair->value; | 359 topic = yahoo_string_decode(gc, pair->value, FALSE); |
347 break; | 360 break; |
348 case 128: | 361 case 128: |
349 someid = pair->value; | 362 someid = pair->value; |
350 break; | 363 break; |
351 case 108: /* number of joiners */ | 364 case 108: /* number of joiners */ |
402 } else if (c) { | 415 } else if (c) { |
403 yahoo_chat_add_users(GAIM_CONV_CHAT(c), members); | 416 yahoo_chat_add_users(GAIM_CONV_CHAT(c), members); |
404 } | 417 } |
405 | 418 |
406 g_list_free(members); | 419 g_list_free(members); |
420 g_free(room); | |
421 if (topic) | |
422 g_free(topic); | |
407 } | 423 } |
408 | 424 |
409 void yahoo_process_chat_exit(GaimConnection *gc, struct yahoo_packet *pkt) | 425 void yahoo_process_chat_exit(GaimConnection *gc, struct yahoo_packet *pkt) |
410 { | 426 { |
411 char *who = NULL; | 427 char *who = NULL; |
417 | 433 |
418 for (l = pkt->hash; l; l = l->next) { | 434 for (l = pkt->hash; l; l = l->next) { |
419 struct yahoo_pair *pair = l->data; | 435 struct yahoo_pair *pair = l->data; |
420 | 436 |
421 if (pair->key == 104) | 437 if (pair->key == 104) |
422 room = pair->value; | 438 room = yahoo_string_decode(gc, pair->value, FALSE); |
423 if (pair->key == 109) | 439 if (pair->key == 109) |
424 who = pair->value; | 440 who = pair->value; |
425 } | 441 } |
426 | 442 |
427 | 443 |
429 GaimConversation *c = gaim_find_chat(gc, YAHOO_CHAT_ID); | 445 GaimConversation *c = gaim_find_chat(gc, YAHOO_CHAT_ID); |
430 if (c && !gaim_utf8_strcasecmp(gaim_conversation_get_name(c), room)) | 446 if (c && !gaim_utf8_strcasecmp(gaim_conversation_get_name(c), room)) |
431 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c), who, NULL); | 447 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c), who, NULL); |
432 | 448 |
433 } | 449 } |
450 if (room) | |
451 g_free(room); | |
434 } | 452 } |
435 | 453 |
436 void yahoo_process_chat_message(GaimConnection *gc, struct yahoo_packet *pkt) | 454 void yahoo_process_chat_message(GaimConnection *gc, struct yahoo_packet *pkt) |
437 { | 455 { |
438 char *room = NULL, *who = NULL, *msg = NULL; | 456 char *room = NULL, *who = NULL, *msg = NULL, *msg2; |
439 int msgtype = 1; | 457 int msgtype = 1, utf8 = 0; |
440 GaimConversation *c = NULL; | 458 GaimConversation *c = NULL; |
441 GSList *l; | 459 GSList *l; |
442 | 460 |
443 for (l = pkt->hash; l; l = l->next) { | 461 for (l = pkt->hash; l; l = l->next) { |
444 struct yahoo_pair *pair = l->data; | 462 struct yahoo_pair *pair = l->data; |
445 | 463 |
446 switch (pair->key) { | 464 switch (pair->key) { |
447 | 465 |
466 case 97: | |
467 utf8 = strtol(pair->value, NULL, 10); | |
468 break; | |
448 case 104: | 469 case 104: |
449 room = pair->value; | 470 room = yahoo_string_decode(gc, pair->value, FALSE); |
450 break; | 471 break; |
451 case 109: | 472 case 109: |
452 who = pair->value; | 473 who = pair->value; |
453 break; | 474 break; |
454 case 117: | 475 case 117: |
458 msgtype = strtol(pair->value, NULL, 10); | 479 msgtype = strtol(pair->value, NULL, 10); |
459 break; | 480 break; |
460 } | 481 } |
461 } | 482 } |
462 | 483 |
463 if (!who) | |
464 return; | |
465 | 484 |
466 c = gaim_find_chat(gc, YAHOO_CHAT_ID); | 485 c = gaim_find_chat(gc, YAHOO_CHAT_ID); |
467 if (!c) { | 486 if (!who || !c) { |
487 if (room) | |
488 g_free(room); | |
468 /* we still get messages after we part, funny that */ | 489 /* we still get messages after we part, funny that */ |
469 return; | 490 return; |
470 } | 491 } |
471 | 492 |
472 if (!msg) { | 493 if (!msg) { |
473 gaim_debug(GAIM_DEBUG_MISC, "yahoo", "Got a message packet with no message.\nThis probably means something important, but we're ignoring it.\n"); | 494 gaim_debug(GAIM_DEBUG_MISC, "yahoo", "Got a message packet with no message.\nThis probably means something important, but we're ignoring it.\n"); |
474 return; | 495 return; |
475 } | 496 } |
476 msg = yahoo_codes_to_html(msg); | 497 msg2 = yahoo_string_decode(gc, msg, utf8); |
498 msg = yahoo_codes_to_html(msg2); | |
499 g_free(msg2); | |
477 | 500 |
478 if (msgtype == 2 || msgtype == 3) { | 501 if (msgtype == 2 || msgtype == 3) { |
479 char *tmp; | 502 char *tmp; |
480 tmp = g_strdup_printf("/me %s", msg); | 503 tmp = g_strdup_printf("/me %s", msg); |
481 g_free(msg); | 504 g_free(msg); |
497 for (l = pkt->hash; l; l = l->next) { | 520 for (l = pkt->hash; l; l = l->next) { |
498 struct yahoo_pair *pair = l->data; | 521 struct yahoo_pair *pair = l->data; |
499 | 522 |
500 switch (pair->key) { | 523 switch (pair->key) { |
501 case 104: | 524 case 104: |
502 room = pair->value; | 525 room = yahoo_string_decode(gc, pair->value, FALSE); |
503 break; | 526 break; |
504 case 129: /* room id? */ | 527 case 129: /* room id? */ |
505 break; | 528 break; |
506 case 126: /* ??? */ | 529 case 126: /* ??? */ |
507 break; | 530 break; |
508 case 117: | 531 case 117: |
509 msg = pair->value; | 532 msg = yahoo_string_decode(gc, pair->value, FALSE); |
510 break; | 533 break; |
511 case 119: | 534 case 119: |
512 who = pair->value; | 535 who = pair->value; |
513 break; | 536 break; |
514 case 118: /* us */ | 537 case 118: /* us */ |
521 | 544 |
522 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | 545 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); |
523 g_hash_table_replace(components, g_strdup("room"), g_strdup(room)); | 546 g_hash_table_replace(components, g_strdup("room"), g_strdup(room)); |
524 serv_got_chat_invite(gc, room, who, msg, components); | 547 serv_got_chat_invite(gc, room, who, msg, components); |
525 } | 548 } |
549 if (room) | |
550 g_free(room); | |
551 if (msg) | |
552 g_free(msg); | |
526 } | 553 } |
527 | 554 |
528 void yahoo_process_chat_goto(GaimConnection *gc, struct yahoo_packet *pkt) | 555 void yahoo_process_chat_goto(GaimConnection *gc, struct yahoo_packet *pkt) |
529 { | 556 { |
530 if (pkt->status == -1) | 557 if (pkt->status == -1) |
533 } | 560 } |
534 | 561 |
535 | 562 |
536 /* | 563 /* |
537 * Functions dealing with conferences | 564 * Functions dealing with conferences |
565 * I think conference names are always ascii. | |
538 */ | 566 */ |
539 | 567 |
540 static void yahoo_conf_leave(struct yahoo_data *yd, const char *room, const char *dn, GList *who) | 568 static void yahoo_conf_leave(struct yahoo_data *yd, const char *room, const char *dn, GList *who) |
541 { | 569 { |
542 struct yahoo_packet *pkt; | 570 struct yahoo_packet *pkt; |
555 yahoo_send_packet(yd, pkt); | 583 yahoo_send_packet(yd, pkt); |
556 | 584 |
557 yahoo_packet_free(pkt); | 585 yahoo_packet_free(pkt); |
558 } | 586 } |
559 | 587 |
560 static int yahoo_conf_send(struct yahoo_data *yd, const char *dn, const char *room, | 588 static int yahoo_conf_send(GaimConnection *gc, const char *dn, const char *room, |
561 GList *members, const char *what) | 589 GList *members, const char *what) |
562 { | 590 { |
591 struct yahoo_data *yd = gc->proto_data; | |
563 struct yahoo_packet *pkt; | 592 struct yahoo_packet *pkt; |
564 GList *who; | 593 GList *who; |
565 char *msg; | 594 char *msg, *msg2; |
595 int utf8 = 1; | |
566 | 596 |
567 msg = yahoo_html_to_codes(what); | 597 msg = yahoo_html_to_codes(what); |
598 msg2 = yahoo_string_encode(gc, msg, &utf8); | |
599 | |
568 | 600 |
569 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFMSG, YAHOO_STATUS_AVAILABLE, 0); | 601 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFMSG, YAHOO_STATUS_AVAILABLE, 0); |
570 | 602 |
571 yahoo_packet_hash(pkt, 1, dn); | 603 yahoo_packet_hash(pkt, 1, dn); |
572 for (who = members; who; who = who->next) | 604 for (who = members; who; who = who->next) |
573 yahoo_packet_hash(pkt, 53, (char *)who->data); | 605 yahoo_packet_hash(pkt, 53, (char *)who->data); |
574 yahoo_packet_hash(pkt, 57, room); | 606 yahoo_packet_hash(pkt, 57, room); |
575 yahoo_packet_hash(pkt, 14, msg); | 607 yahoo_packet_hash(pkt, 14, msg2); |
576 yahoo_packet_hash(pkt, 97, "1"); /* utf-8 */ | 608 if (utf8) |
609 yahoo_packet_hash(pkt, 97, "1"); /* utf-8 */ | |
577 | 610 |
578 yahoo_send_packet(yd, pkt); | 611 yahoo_send_packet(yd, pkt); |
579 | 612 |
580 yahoo_packet_free(pkt); | 613 yahoo_packet_free(pkt); |
581 g_free(msg); | 614 g_free(msg); |
615 g_free(msg2); | |
582 | 616 |
583 return 0; | 617 return 0; |
584 } | 618 } |
585 | 619 |
586 static void yahoo_conf_join(struct yahoo_data *yd, GaimConversation *c, const char *dn, const char *room, | 620 static void yahoo_conf_join(struct yahoo_data *yd, GaimConversation *c, const char *dn, const char *room, |
613 | 647 |
614 if (memarr) | 648 if (memarr) |
615 g_strfreev(memarr); | 649 g_strfreev(memarr); |
616 } | 650 } |
617 | 651 |
618 static void yahoo_conf_invite(struct yahoo_data *yd, GaimConversation *c, | 652 static void yahoo_conf_invite(GaimConnection *gc, GaimConversation *c, |
619 const char *dn, const char *buddy, const char *room, const char *msg) | 653 const char *dn, const char *buddy, const char *room, const char *msg) |
620 { | 654 { |
655 struct yahoo_data *yd = gc->proto_data; | |
621 struct yahoo_packet *pkt; | 656 struct yahoo_packet *pkt; |
622 GList *members; | 657 GList *members; |
658 char *msg2 = NULL; | |
659 | |
660 if (msg) | |
661 msg2 = yahoo_string_encode(gc, msg, NULL); | |
623 | 662 |
624 members = gaim_conv_chat_get_users(GAIM_CONV_CHAT(c)); | 663 members = gaim_conv_chat_get_users(GAIM_CONV_CHAT(c)); |
625 | 664 |
626 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFADDINVITE, YAHOO_STATUS_AVAILABLE, 0); | 665 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFADDINVITE, YAHOO_STATUS_AVAILABLE, 0); |
627 | 666 |
628 yahoo_packet_hash(pkt, 1, dn); | 667 yahoo_packet_hash(pkt, 1, dn); |
629 yahoo_packet_hash(pkt, 51, buddy); | 668 yahoo_packet_hash(pkt, 51, buddy); |
630 yahoo_packet_hash(pkt, 57, room); | 669 yahoo_packet_hash(pkt, 57, room); |
631 yahoo_packet_hash(pkt, 58, msg?msg:""); | 670 yahoo_packet_hash(pkt, 58, msg?msg2:""); |
632 yahoo_packet_hash(pkt, 13, "0"); | 671 yahoo_packet_hash(pkt, 13, "0"); |
633 for(; members; members = members->next) { | 672 for(; members; members = members->next) { |
634 if (!strcmp(members->data, dn)) | 673 if (!strcmp(members->data, dn)) |
635 continue; | 674 continue; |
636 yahoo_packet_hash(pkt, 52, (char *)members->data); | 675 yahoo_packet_hash(pkt, 52, (char *)members->data); |
637 yahoo_packet_hash(pkt, 53, (char *)members->data); | 676 yahoo_packet_hash(pkt, 53, (char *)members->data); |
638 } | 677 } |
639 yahoo_send_packet(yd, pkt); | 678 yahoo_send_packet(yd, pkt); |
640 | 679 |
641 yahoo_packet_free(pkt); | 680 yahoo_packet_free(pkt); |
681 if (msg) | |
682 g_free(msg2); | |
642 } | 683 } |
643 | 684 |
644 /* | 685 /* |
645 * Functions dealing with chats | 686 * Functions dealing with chats |
646 */ | 687 */ |
648 static void yahoo_chat_leave(GaimConnection *gc, const char *room, const char *dn, gboolean logout) | 689 static void yahoo_chat_leave(GaimConnection *gc, const char *room, const char *dn, gboolean logout) |
649 { | 690 { |
650 struct yahoo_data *yd = gc->proto_data; | 691 struct yahoo_data *yd = gc->proto_data; |
651 struct yahoo_packet *pkt; | 692 struct yahoo_packet *pkt; |
652 GaimConversation *c; | 693 GaimConversation *c; |
694 char *eroom; | |
695 | |
696 eroom = yahoo_string_encode(gc, room, NULL); | |
653 | 697 |
654 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATEXIT, YAHOO_STATUS_AVAILABLE, 0); | 698 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATEXIT, YAHOO_STATUS_AVAILABLE, 0); |
655 | 699 |
656 yahoo_packet_hash(pkt, 104, room); | 700 yahoo_packet_hash(pkt, 104, eroom); |
657 yahoo_packet_hash(pkt, 109, dn); | 701 yahoo_packet_hash(pkt, 109, dn); |
658 yahoo_packet_hash(pkt, 108, "1"); | 702 yahoo_packet_hash(pkt, 108, "1"); |
659 yahoo_packet_hash(pkt, 112, "0"); /* what does this one mean? */ | 703 yahoo_packet_hash(pkt, 112, "0"); /* what does this one mean? */ |
660 | 704 |
661 yahoo_send_packet(yd, pkt); | 705 yahoo_send_packet(yd, pkt); |
679 yahoo_packet_hash(pkt, 1, dn); | 723 yahoo_packet_hash(pkt, 1, dn); |
680 yahoo_send_packet(yd, pkt); | 724 yahoo_send_packet(yd, pkt); |
681 yahoo_packet_free(pkt); | 725 yahoo_packet_free(pkt); |
682 | 726 |
683 yd->chat_online = 0; | 727 yd->chat_online = 0; |
728 g_free(eroom); | |
684 } | 729 } |
685 | 730 |
686 /* borrowed from gtkconv.c */ | 731 /* borrowed from gtkconv.c */ |
687 static gboolean | 732 static gboolean |
688 meify(char *message, size_t len) | 733 meify(char *message, size_t len) |
720 } | 765 } |
721 | 766 |
722 return FALSE; | 767 return FALSE; |
723 } | 768 } |
724 | 769 |
725 static int yahoo_chat_send(struct yahoo_data *yd, const char *dn, const char *room, const char *what) | 770 static int yahoo_chat_send(GaimConnection *gc, const char *dn, const char *room, const char *what) |
726 { | 771 { |
772 struct yahoo_data *yd = gc->proto_data; | |
727 struct yahoo_packet *pkt; | 773 struct yahoo_packet *pkt; |
728 int me = 0; | 774 int me = 0; |
729 char *msg1, *msg2; | 775 char *msg1, *msg2, *room2; |
776 gboolean utf8 = TRUE; | |
730 | 777 |
731 msg1 = g_strdup(what); | 778 msg1 = g_strdup(what); |
732 | 779 |
733 if (meify(msg1, -1)) | 780 if (meify(msg1, -1)) |
734 me = 1; | 781 me = 1; |
735 | 782 |
736 msg2 = yahoo_html_to_codes(msg1); | 783 msg2 = yahoo_html_to_codes(msg1); |
737 g_free(msg1); | 784 g_free(msg1); |
785 msg1 = yahoo_string_encode(gc, msg2, &utf8); | |
786 g_free(msg2); | |
787 room2 = yahoo_string_encode(gc, room, NULL); | |
738 | 788 |
739 pkt = yahoo_packet_new(YAHOO_SERVICE_COMMENT, YAHOO_STATUS_AVAILABLE, 0); | 789 pkt = yahoo_packet_new(YAHOO_SERVICE_COMMENT, YAHOO_STATUS_AVAILABLE, 0); |
740 | 790 |
741 yahoo_packet_hash(pkt, 1, dn); | 791 yahoo_packet_hash(pkt, 1, dn); |
742 yahoo_packet_hash(pkt, 104, room); | 792 yahoo_packet_hash(pkt, 104, room2); |
743 yahoo_packet_hash(pkt, 117, msg2); | 793 yahoo_packet_hash(pkt, 117, msg1); |
744 if (me) | 794 if (me) |
745 yahoo_packet_hash(pkt, 124, "2"); | 795 yahoo_packet_hash(pkt, 124, "2"); |
746 else | 796 else |
747 yahoo_packet_hash(pkt, 124, "1"); | 797 yahoo_packet_hash(pkt, 124, "1"); |
748 /* fixme: what about /think? (124=3) */ | 798 /* fixme: what about /think? (124=3) */ |
799 if (utf8) | |
800 yahoo_packet_hash(pkt, 97, "1"); | |
749 | 801 |
750 yahoo_send_packet(yd, pkt); | 802 yahoo_send_packet(yd, pkt); |
751 yahoo_packet_free(pkt); | 803 yahoo_packet_free(pkt); |
752 g_free(msg2); | 804 g_free(msg1); |
805 g_free(room2); | |
753 | 806 |
754 return 0; | 807 return 0; |
755 } | 808 } |
756 | 809 |
757 static void yahoo_chat_join(struct yahoo_data *yd, const char *dn, const char *room, const char *topic) | 810 static void yahoo_chat_join(GaimConnection *gc, const char *dn, const char *room, const char *topic) |
758 { | 811 { |
812 struct yahoo_data *yd = gc->proto_data; | |
759 struct yahoo_packet *pkt; | 813 struct yahoo_packet *pkt; |
814 char *room2; | |
815 | |
816 room2 = yahoo_string_encode(gc, room, NULL); | |
760 | 817 |
761 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATJOIN, YAHOO_STATUS_AVAILABLE, 0); | 818 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATJOIN, YAHOO_STATUS_AVAILABLE, 0); |
762 | 819 |
763 yahoo_packet_hash(pkt, 62, "2"); | 820 yahoo_packet_hash(pkt, 62, "2"); |
764 yahoo_packet_hash(pkt, 104, room); | 821 yahoo_packet_hash(pkt, 104, room2); |
765 yahoo_packet_hash(pkt, 129, "0"); | 822 yahoo_packet_hash(pkt, 129, "0"); |
766 | 823 |
767 yahoo_send_packet(yd, pkt); | 824 yahoo_send_packet(yd, pkt); |
768 | 825 |
769 yahoo_packet_free(pkt); | 826 yahoo_packet_free(pkt); |
770 } | 827 g_free(room2); |
771 | 828 } |
772 static void yahoo_chat_invite(struct yahoo_data *yd, const char *dn, const char *buddy, | 829 |
830 static void yahoo_chat_invite(GaimConnection *gc, const char *dn, const char *buddy, | |
773 const char *room, const char *msg) | 831 const char *room, const char *msg) |
774 { | 832 { |
833 struct yahoo_data *yd = gc->proto_data; | |
775 struct yahoo_packet *pkt; | 834 struct yahoo_packet *pkt; |
776 | 835 char *room2, *msg2 = NULL; |
836 | |
837 room2 = yahoo_string_encode(gc, room, NULL); | |
838 if (msg) | |
839 msg2 = yahoo_string_encode(gc, msg, NULL); | |
777 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATADDINVITE, YAHOO_STATUS_AVAILABLE, 0); | 840 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATADDINVITE, YAHOO_STATUS_AVAILABLE, 0); |
778 | 841 |
779 yahoo_packet_hash(pkt, 1, dn); | 842 yahoo_packet_hash(pkt, 1, dn); |
780 yahoo_packet_hash(pkt, 118, buddy); | 843 yahoo_packet_hash(pkt, 118, buddy); |
781 yahoo_packet_hash(pkt, 104, room); | 844 yahoo_packet_hash(pkt, 104, room2); |
782 yahoo_packet_hash(pkt, 117, (msg?msg:"")); | 845 yahoo_packet_hash(pkt, 117, (msg2?msg2:"")); |
783 yahoo_packet_hash(pkt, 129, "0"); | 846 yahoo_packet_hash(pkt, 129, "0"); |
784 | 847 |
785 yahoo_send_packet(yd, pkt); | 848 yahoo_send_packet(yd, pkt); |
786 yahoo_packet_free(pkt); | 849 yahoo_packet_free(pkt); |
850 | |
851 g_free(room2); | |
852 if (msg2) | |
853 g_free(msg2); | |
787 } | 854 } |
788 | 855 |
789 void yahoo_chat_goto(GaimConnection *gc, const char *name) | 856 void yahoo_chat_goto(GaimConnection *gc, const char *name) |
790 { | 857 { |
791 struct yahoo_data *yd; | 858 struct yahoo_data *yd; |
847 c = gaim_find_chat(gc, id); | 914 c = gaim_find_chat(gc, id); |
848 if (!c) | 915 if (!c) |
849 return -1; | 916 return -1; |
850 | 917 |
851 if (id != YAHOO_CHAT_ID) { | 918 if (id != YAHOO_CHAT_ID) { |
852 ret = yahoo_conf_send(yd, gaim_connection_get_display_name(gc), | 919 ret = yahoo_conf_send(gc, gaim_connection_get_display_name(gc), |
853 gaim_conversation_get_name(c), gaim_conv_chat_get_users(GAIM_CONV_CHAT(c)), what); | 920 gaim_conversation_get_name(c), gaim_conv_chat_get_users(GAIM_CONV_CHAT(c)), what); |
854 } else { | 921 } else { |
855 ret = yahoo_chat_send(yd, gaim_connection_get_display_name(gc), | 922 ret = yahoo_chat_send(gc, gaim_connection_get_display_name(gc), |
856 gaim_conversation_get_name(c), what); | 923 gaim_conversation_get_name(c), what); |
857 if (!ret) | 924 if (!ret) |
858 serv_got_chat_in(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(c)), | 925 serv_got_chat_in(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(c)), |
859 gaim_connection_get_display_name(gc), 0, what, time(NULL)); | 926 gaim_connection_get_display_name(gc), 0, what, time(NULL)); |
860 } | 927 } |
908 yahoo_chat_leave(gc, room, | 975 yahoo_chat_leave(gc, room, |
909 gaim_connection_get_display_name(gc), | 976 gaim_connection_get_display_name(gc), |
910 FALSE); | 977 FALSE); |
911 if (!yd->chat_online) | 978 if (!yd->chat_online) |
912 yahoo_chat_online(gc); | 979 yahoo_chat_online(gc); |
913 yahoo_chat_join(yd, gaim_connection_get_display_name(gc), room, topic); | 980 yahoo_chat_join(gc, gaim_connection_get_display_name(gc), room, topic); |
914 return; | 981 return; |
915 } | 982 } |
916 } | 983 } |
917 | 984 |
918 void yahoo_c_invite(GaimConnection *gc, int id, const char *msg, const char *name) | 985 void yahoo_c_invite(GaimConnection *gc, int id, const char *msg, const char *name) |
919 { | 986 { |
920 struct yahoo_data *yd = (struct yahoo_data *) gc->proto_data; | |
921 GaimConversation *c; | 987 GaimConversation *c; |
922 | 988 |
923 c = gaim_find_chat(gc, id); | 989 c = gaim_find_chat(gc, id); |
924 if (!c || !c->name) | 990 if (!c || !c->name) |
925 return; | 991 return; |
926 | 992 |
927 if (id != YAHOO_CHAT_ID) { | 993 if (id != YAHOO_CHAT_ID) { |
928 yahoo_conf_invite(yd, c, gaim_connection_get_display_name(gc), name, | 994 yahoo_conf_invite(gc, c, gaim_connection_get_display_name(gc), name, |
929 gaim_conversation_get_name(c), msg); | 995 gaim_conversation_get_name(c), msg); |
930 } else { | 996 } else { |
931 yahoo_chat_invite(yd, gaim_connection_get_display_name(gc), name, | 997 yahoo_chat_invite(gc, gaim_connection_get_display_name(gc), name, |
932 gaim_conversation_get_name(c), msg); | 998 gaim_conversation_get_name(c), msg); |
933 } | 999 } |
934 } | 1000 } |
935 | 1001 |