| 185 strstr(type, "image/gif") || |
185 strstr(type, "image/gif") || |
| 186 strstr(type, "image/tiff")) { |
186 strstr(type, "image/tiff")) { |
| 187 char tmp[32]; |
187 char tmp[32]; |
| 188 int imgid; |
188 int imgid; |
| 189 |
189 |
| 190 /* Get channel convo (if message is for channel) */ |
190 /* Get channel chat (if message is for channel) */ |
| 191 if (key && channel) { |
191 if (key && channel) { |
| 192 GList *l; |
192 GList *l; |
| 193 SilcPurplePrvgrp prv; |
193 SilcPurplePrvgrp prv; |
| 194 |
194 |
| 195 for (l = sg->grps; l; l = l->next) |
195 for (l = sg->grps; l; l = l->next) |
| 196 if (((SilcPurplePrvgrp)l->data)->key == key) { |
196 if (((SilcPurplePrvgrp)l->data)->key == key) { |
| 197 prv = l->data; |
197 prv = l->data; |
| 198 convo = purple_conversations_find_with_account(PURPLE_CONV_TYPE_CHAT, |
198 chat = purple_conversations_find_chat_with_account( |
| 199 prv->channel, sg->account); |
199 prv->channel, sg->account); |
| 200 break; |
200 break; |
| 201 } |
201 } |
| 202 } |
202 } |
| 203 if (channel && !convo) |
203 if (channel && !chat) |
| 204 convo = purple_conversations_find_with_account(PURPLE_CONV_TYPE_CHAT, |
204 chat = purple_conversations_find_chat_with_account( |
| 205 channel->channel_name, sg->account); |
205 channel->channel_name, sg->account); |
| 206 if (channel && !convo) |
206 if (channel && !chat) |
| 207 goto out; |
207 goto out; |
| 208 |
208 |
| 209 imgid = purple_imgstore_new_with_id(g_memdup(data, data_len), data_len, ""); |
209 imgid = purple_imgstore_new_with_id(g_memdup(data, data_len), data_len, ""); |
| 210 if (imgid) { |
210 if (imgid) { |
| 211 cflags |= PURPLE_MESSAGE_IMAGES | PURPLE_MESSAGE_RECV; |
211 cflags |= PURPLE_MESSAGE_IMAGES | PURPLE_MESSAGE_RECV; |
| 212 g_snprintf(tmp, sizeof(tmp), |
212 g_snprintf(tmp, sizeof(tmp), |
| 213 "<IMG SRC=\"" PURPLE_STORED_IMAGE_PROTOCOL "%d\">", |
213 "<IMG SRC=\"" PURPLE_STORED_IMAGE_PROTOCOL "%d\">", |
| 214 imgid); |
214 imgid); |
| 215 |
215 |
| 216 if (channel) |
216 if (channel) |
| 217 serv_got_chat_in(gc, purple_chat_conversation_get_id(PURPLE_CONV_CHAT(convo)), |
217 serv_got_chat_in(gc, purple_chat_conversation_get_id(chat), |
| 218 sender->nickname, cflags, |
218 sender->nickname, cflags, |
| 219 tmp, time(NULL)); |
219 tmp, time(NULL)); |
| 220 else |
220 else |
| 221 serv_got_im(gc, sender->nickname, |
221 serv_got_im(gc, sender->nickname, |
| 222 tmp, cflags, time(NULL)); |
222 tmp, cflags, time(NULL)); |
| 273 SilcPurplePrvgrp prv; |
273 SilcPurplePrvgrp prv; |
| 274 |
274 |
| 275 for (l = sg->grps; l; l = l->next) |
275 for (l = sg->grps; l; l = l->next) |
| 276 if (((SilcPurplePrvgrp)l->data)->key == key) { |
276 if (((SilcPurplePrvgrp)l->data)->key == key) { |
| 277 prv = l->data; |
277 prv = l->data; |
| 278 convo = purple_conversations_find_with_account(PURPLE_CONV_TYPE_CHAT, |
278 chat = purple_conversations_find_chat_with_account( |
| 279 prv->channel, sg->account); |
279 prv->channel, sg->account); |
| 280 break; |
280 break; |
| 281 } |
281 } |
| 282 } |
282 } |
| 283 if (!convo) |
283 if (!chat) |
| 284 convo = purple_conversations_find_with_account(PURPLE_CONV_TYPE_CHAT, |
284 chat = purple_conversations_find_chat_with_account( |
| 285 channel->channel_name, sg->account); |
285 channel->channel_name, sg->account); |
| 286 if (!convo) |
286 if (!chat) |
| 287 return; |
287 return; |
| 288 |
288 |
| 289 if (flags & SILC_MESSAGE_FLAG_SIGNED && |
289 if (flags & SILC_MESSAGE_FLAG_SIGNED && |
| 290 purple_account_get_bool(sg->account, "sign-verify", FALSE)) { |
290 purple_account_get_bool(sg->account, "sign-verify", FALSE)) { |
| 291 /* XXX */ |
291 /* XXX */ |
| 484 |
484 |
| 485 /* If we joined channel, do nothing */ |
485 /* If we joined channel, do nothing */ |
| 486 if (client_entry == conn->local_entry) |
486 if (client_entry == conn->local_entry) |
| 487 break; |
487 break; |
| 488 |
488 |
| 489 convo = purple_conversations_find_with_account(PURPLE_CONV_TYPE_CHAT, |
489 chat = purple_conversations_find_chat_with_account( |
| 490 channel->channel_name, sg->account); |
490 channel->channel_name, sg->account); |
| 491 if (!convo) |
491 if (!chat) |
| 492 break; |
492 break; |
| 493 |
493 |
| 494 /* Join user to channel */ |
494 /* Join user to channel */ |
| 495 g_snprintf(buf, sizeof(buf), "%s@%s", |
495 g_snprintf(buf, sizeof(buf), "%s@%s", |
| 496 client_entry->username, client_entry->hostname); |
496 client_entry->username, client_entry->hostname); |
| 497 purple_chat_conversation_add_user(PURPLE_CONV_CHAT(convo), |
497 purple_chat_conversation_add_user(chat, |
| 498 client_entry->nickname, buf, PURPLE_CHAT_USER_NONE, TRUE); |
498 client_entry->nickname, buf, PURPLE_CHAT_USER_NONE, TRUE); |
| 499 |
499 |
| 500 break; |
500 break; |
| 501 |
501 |
| 502 case SILC_NOTIFY_TYPE_LEAVE: |
502 case SILC_NOTIFY_TYPE_LEAVE: |
| 503 client_entry = va_arg(va, SilcClientEntry); |
503 client_entry = va_arg(va, SilcClientEntry); |
| 504 channel = va_arg(va, SilcChannelEntry); |
504 channel = va_arg(va, SilcChannelEntry); |
| 505 |
505 |
| 506 convo = purple_conversations_find_with_account(PURPLE_CONV_TYPE_CHAT, |
506 chat = purple_conversations_find_chat_with_account( |
| 507 channel->channel_name, sg->account); |
507 channel->channel_name, sg->account); |
| 508 if (!convo) |
508 if (!chat) |
| 509 break; |
509 break; |
| 510 |
510 |
| 511 /* Remove user from channel */ |
511 /* Remove user from channel */ |
| 512 purple_chat_conversation_remove_user(PURPLE_CONV_CHAT(convo), |
512 purple_chat_conversation_remove_user(chat, |
| 513 client_entry->nickname, NULL); |
513 client_entry->nickname, NULL); |
| 514 |
514 |
| 515 break; |
515 break; |
| 516 |
516 |
| 517 case SILC_NOTIFY_TYPE_SIGNOFF: |
517 case SILC_NOTIFY_TYPE_SIGNOFF: |
| 519 tmp = va_arg(va, char *); |
519 tmp = va_arg(va, char *); |
| 520 |
520 |
| 521 /* Remove from all channels */ |
521 /* Remove from all channels */ |
| 522 silc_hash_table_list(client_entry->channels, &htl); |
522 silc_hash_table_list(client_entry->channels, &htl); |
| 523 while (silc_hash_table_get(&htl, NULL, (void *)&chu)) { |
523 while (silc_hash_table_get(&htl, NULL, (void *)&chu)) { |
| 524 convo = purple_conversations_find_with_account(PURPLE_CONV_TYPE_CHAT, |
524 chat = purple_conversations_find_chat_with_account( |
| 525 chu->channel->channel_name, sg->account); |
525 chu->channel->channel_name, sg->account); |
| 526 if (!convo) |
526 if (!chat) |
| 527 continue; |
527 continue; |
| 528 purple_chat_conversation_remove_user(PURPLE_CONV_CHAT(convo), |
528 purple_chat_conversation_remove_user(chat, |
| 529 client_entry->nickname, |
529 client_entry->nickname, |
| 530 tmp); |
530 tmp); |
| 531 } |
531 } |
| 532 silc_hash_table_list_reset(&htl); |
532 silc_hash_table_list_reset(&htl); |
| 533 |
533 |
| 556 if (idtype == SILC_ID_CLIENT) { |
556 if (idtype == SILC_ID_CLIENT) { |
| 557 client_entry = (SilcClientEntry)entry; |
557 client_entry = (SilcClientEntry)entry; |
| 558 g_snprintf(buf, sizeof(buf), |
558 g_snprintf(buf, sizeof(buf), |
| 559 _("%s has changed the topic of <I>%s</I> to: %s"), |
559 _("%s has changed the topic of <I>%s</I> to: %s"), |
| 560 client_entry->nickname, channel->channel_name, tmp2); |
560 client_entry->nickname, channel->channel_name, tmp2); |
| 561 purple_chat_conversation_write_message(PURPLE_CONV_CHAT(convo), client_entry->nickname, |
561 purple_conversation_write_message(PURPLE_CONVERSATION(chat), client_entry->nickname, |
| 562 buf, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
562 buf, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
| 563 purple_chat_conversation_set_topic(PURPLE_CONV_CHAT(convo), |
563 purple_chat_conversation_set_topic(chat, |
| 564 client_entry->nickname, tmp); |
564 client_entry->nickname, tmp); |
| 565 } else if (idtype == SILC_ID_SERVER) { |
565 } else if (idtype == SILC_ID_SERVER) { |
| 566 server_entry = (SilcServerEntry)entry; |
566 server_entry = (SilcServerEntry)entry; |
| 567 g_snprintf(buf, sizeof(buf), |
567 g_snprintf(buf, sizeof(buf), |
| 568 _("%s has changed the topic of <I>%s</I> to: %s"), |
568 _("%s has changed the topic of <I>%s</I> to: %s"), |
| 569 server_entry->server_name, channel->channel_name, tmp2); |
569 server_entry->server_name, channel->channel_name, tmp2); |
| 570 purple_chat_conversation_write_message(PURPLE_CONV_CHAT(convo), server_entry->server_name, |
570 purple_conversation_write_message(PURPLE_CONVERSATION(chat), server_entry->server_name, |
| 571 buf, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
571 buf, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
| 572 purple_chat_conversation_set_topic(PURPLE_CONV_CHAT(convo), |
572 purple_chat_conversation_set_topic(chat, |
| 573 server_entry->server_name, tmp); |
573 server_entry->server_name, tmp); |
| 574 } else if (idtype == SILC_ID_CHANNEL) { |
574 } else if (idtype == SILC_ID_CHANNEL) { |
| 575 channel = (SilcChannelEntry)entry; |
575 channel = (SilcChannelEntry)entry; |
| 576 g_snprintf(buf, sizeof(buf), |
576 g_snprintf(buf, sizeof(buf), |
| 577 _("%s has changed the topic of <I>%s</I> to: %s"), |
577 _("%s has changed the topic of <I>%s</I> to: %s"), |
| 578 channel->channel_name, channel->channel_name, tmp2); |
578 channel->channel_name, channel->channel_name, tmp2); |
| 579 purple_chat_conversation_write_message(PURPLE_CONV_CHAT(convo), channel->channel_name, |
579 purple_conversation_write_message(PURPLE_CONVERSATION(chat), channel->channel_name, |
| 580 buf, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
580 buf, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
| 581 purple_chat_conversation_set_topic(PURPLE_CONV_CHAT(convo), |
581 purple_chat_conversation_set_topic(chat, |
| 582 channel->channel_name, tmp); |
582 channel->channel_name, tmp); |
| 583 } else { |
583 } else { |
| 584 purple_chat_conversation_set_topic(PURPLE_CONV_CHAT(convo), NULL, tmp); |
584 purple_chat_conversation_set_topic(chat, NULL, tmp); |
| 585 } |
585 } |
| 586 |
586 |
| 587 g_free(tmp2); |
587 g_free(tmp2); |
| 588 |
588 |
| 589 break; |
589 break; |
| 598 break; |
598 break; |
| 599 |
599 |
| 600 /* Change nick on all channels */ |
600 /* Change nick on all channels */ |
| 601 silc_hash_table_list(client_entry->channels, &htl); |
601 silc_hash_table_list(client_entry->channels, &htl); |
| 602 while (silc_hash_table_get(&htl, NULL, (void *)&chu)) { |
602 while (silc_hash_table_get(&htl, NULL, (void *)&chu)) { |
| 603 convo = purple_conversations_find_with_account(PURPLE_CONV_TYPE_CHAT, |
603 chat = purple_conversations_find_chat_with_account( |
| 604 chu->channel->channel_name, sg->account); |
604 chu->channel->channel_name, sg->account); |
| 605 if (!convo) |
605 if (!chat) |
| 606 continue; |
606 continue; |
| 607 if (purple_chat_conversation_has_user(PURPLE_CONV_CHAT(convo), client_entry->nickname)) |
607 if (purple_chat_conversation_has_user(chat, client_entry->nickname)) |
| 608 purple_chat_conversation_rename_user(PURPLE_CONV_CHAT(convo), |
608 purple_chat_conversation_rename_user(chat, |
| 609 tmp, name); |
609 tmp, name); |
| 610 } |
610 } |
| 611 silc_hash_table_list_reset(&htl); |
611 silc_hash_table_list_reset(&htl); |
| 612 |
612 |
| 613 break; |
613 break; |
| 621 (void)va_arg(va, char *); |
621 (void)va_arg(va, char *); |
| 622 (void)va_arg(va, SilcPublicKey); |
622 (void)va_arg(va, SilcPublicKey); |
| 623 (void)va_arg(va, SilcDList); |
623 (void)va_arg(va, SilcDList); |
| 624 channel = va_arg(va, SilcChannelEntry); |
624 channel = va_arg(va, SilcChannelEntry); |
| 625 |
625 |
| 626 convo = purple_conversations_find_with_account(PURPLE_CONV_TYPE_CHAT, |
626 chat = purple_conversations_find_chat_with_account( |
| 627 channel->channel_name, sg->account); |
627 channel->channel_name, sg->account); |
| 628 if (!convo) |
628 if (!chat) |
| 629 break; |
629 break; |
| 630 |
630 |
| 631 if (idtype == SILC_ID_CLIENT) |
631 if (idtype == SILC_ID_CLIENT) |
| 632 name = ((SilcClientEntry)entry)->nickname; |
632 name = ((SilcClientEntry)entry)->nickname; |
| 633 else if (idtype == SILC_ID_SERVER) |
633 else if (idtype == SILC_ID_SERVER) |
| 645 } else { |
645 } else { |
| 646 g_snprintf(buf, sizeof(buf), |
646 g_snprintf(buf, sizeof(buf), |
| 647 _("<I>%s</I> removed all channel <I>%s</I> modes"), name, |
647 _("<I>%s</I> removed all channel <I>%s</I> modes"), name, |
| 648 channel->channel_name); |
648 channel->channel_name); |
| 649 } |
649 } |
| 650 purple_chat_conversation_write_message(PURPLE_CONV_CHAT(convo), channel->channel_name, |
650 purple_conversation_write_message(PURPLE_CONVERSATION(chat), channel->channel_name, |
| 651 buf, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
651 buf, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
| 652 break; |
652 break; |
| 653 |
653 |
| 654 case SILC_NOTIFY_TYPE_CUMODE_CHANGE: |
654 case SILC_NOTIFY_TYPE_CUMODE_CHANGE: |
| 655 { |
655 { |
| 658 entry = va_arg(va, void *); |
658 entry = va_arg(va, void *); |
| 659 mode = va_arg(va, SilcUInt32); |
659 mode = va_arg(va, SilcUInt32); |
| 660 client_entry2 = va_arg(va, SilcClientEntry); |
660 client_entry2 = va_arg(va, SilcClientEntry); |
| 661 channel = va_arg(va, SilcChannelEntry); |
661 channel = va_arg(va, SilcChannelEntry); |
| 662 |
662 |
| 663 convo = purple_conversations_find_with_account(PURPLE_CONV_TYPE_CHAT, |
663 chat = purple_conversations_find_chat_with_account( |
| 664 channel->channel_name, sg->account); |
664 channel->channel_name, sg->account); |
| 665 if (!convo) |
665 if (!chat) |
| 666 break; |
666 break; |
| 667 |
667 |
| 668 if (idtype == SILC_ID_CLIENT) |
668 if (idtype == SILC_ID_CLIENT) |
| 669 name = ((SilcClientEntry)entry)->nickname; |
669 name = ((SilcClientEntry)entry)->nickname; |
| 670 else if (idtype == SILC_ID_SERVER) |
670 else if (idtype == SILC_ID_SERVER) |
| 686 } else { |
686 } else { |
| 687 g_snprintf(buf, sizeof(buf), |
687 g_snprintf(buf, sizeof(buf), |
| 688 _("<I>%s</I> removed all <I>%s's</I> modes"), name, |
688 _("<I>%s</I> removed all <I>%s's</I> modes"), name, |
| 689 client_entry2->nickname); |
689 client_entry2->nickname); |
| 690 } |
690 } |
| 691 purple_chat_conversation_write_message(PURPLE_CONV_CHAT(convo), channel->channel_name, |
691 purple_conversation_write_message(PURPLE_CONVERSATION(chat), channel->channel_name, |
| 692 buf, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
692 buf, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
| 693 purple_chat_conversation_user_set_flags(PURPLE_CONV_CHAT(convo), client_entry2->nickname, flags); |
693 purple_chat_user_set_flags(purple_chat_conversation_find_user( |
| |
694 chat, client_entry2->nickname), flags); |
| 694 break; |
695 break; |
| 695 } |
696 } |
| 696 |
697 |
| 697 case SILC_NOTIFY_TYPE_MOTD: |
698 case SILC_NOTIFY_TYPE_MOTD: |
| 698 tmp = va_arg(va, char *); |
699 tmp = va_arg(va, char *); |
| 704 client_entry = va_arg(va, SilcClientEntry); |
705 client_entry = va_arg(va, SilcClientEntry); |
| 705 tmp = va_arg(va, char *); |
706 tmp = va_arg(va, char *); |
| 706 client_entry2 = va_arg(va, SilcClientEntry); |
707 client_entry2 = va_arg(va, SilcClientEntry); |
| 707 channel = va_arg(va, SilcChannelEntry); |
708 channel = va_arg(va, SilcChannelEntry); |
| 708 |
709 |
| 709 convo = purple_conversations_find_with_account(PURPLE_CONV_TYPE_CHAT, |
710 chat = purple_conversations_find_chat_with_account( |
| 710 channel->channel_name, sg->account); |
711 channel->channel_name, sg->account); |
| 711 if (!convo) |
712 if (!chat) |
| 712 break; |
713 break; |
| 713 |
714 |
| 714 if (client_entry == conn->local_entry) { |
715 if (client_entry == conn->local_entry) { |
| 715 /* Remove us from channel */ |
716 /* Remove us from channel */ |
| 716 g_snprintf(buf, sizeof(buf), |
717 g_snprintf(buf, sizeof(buf), |
| 717 _("You have been kicked off <I>%s</I> by <I>%s</I> (%s)"), |
718 _("You have been kicked off <I>%s</I> by <I>%s</I> (%s)"), |
| 718 channel->channel_name, client_entry2->nickname, |
719 channel->channel_name, client_entry2->nickname, |
| 719 tmp ? tmp : ""); |
720 tmp ? tmp : ""); |
| 720 purple_chat_conversation_write_message(PURPLE_CONV_CHAT(convo), client_entry->nickname, |
721 purple_conversation_write_message(PURPLE_CONVERSATION(chat), client_entry->nickname, |
| 721 buf, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
722 buf, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
| 722 serv_got_chat_left(gc, purple_chat_conversation_get_id(PURPLE_CONV_CHAT(convo))); |
723 serv_got_chat_left(gc, purple_chat_conversation_get_id(chat)); |
| 723 } else { |
724 } else { |
| 724 /* Remove user from channel */ |
725 /* Remove user from channel */ |
| 725 g_snprintf(buf, sizeof(buf), _("Kicked by %s (%s)"), |
726 g_snprintf(buf, sizeof(buf), _("Kicked by %s (%s)"), |
| 726 client_entry2->nickname, tmp ? tmp : ""); |
727 client_entry2->nickname, tmp ? tmp : ""); |
| 727 purple_chat_conversation_remove_user(PURPLE_CONV_CHAT(convo), |
728 purple_chat_conversation_remove_user(chat, |
| 728 client_entry->nickname, |
729 client_entry->nickname, |
| 729 buf); |
730 buf); |
| 730 } |
731 } |
| 731 |
732 |
| 732 break; |
733 break; |
| 756 } |
757 } |
| 757 |
758 |
| 758 /* Remove us from all channels */ |
759 /* Remove us from all channels */ |
| 759 silc_hash_table_list(client_entry->channels, &htl); |
760 silc_hash_table_list(client_entry->channels, &htl); |
| 760 while (silc_hash_table_get(&htl, NULL, (void *)&chu)) { |
761 while (silc_hash_table_get(&htl, NULL, (void *)&chu)) { |
| 761 convo = purple_conversations_find_with_account(PURPLE_CONV_TYPE_CHAT, |
762 chat = purple_conversations_find_chat_with_account( |
| 762 chu->channel->channel_name, sg->account); |
763 chu->channel->channel_name, sg->account); |
| 763 if (!convo) |
764 if (!chat) |
| 764 continue; |
765 continue; |
| 765 purple_chat_conversation_write_message(PURPLE_CONV_CHAT(convo), client_entry->nickname, |
766 purple_conversation_write_message(PURPLE_CONVERSATION(chat), client_entry->nickname, |
| 766 buf, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
767 buf, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
| 767 serv_got_chat_left(gc, purple_chat_conversation_get_id(PURPLE_CONV_CHAT(convo))); |
768 serv_got_chat_left(gc, purple_chat_conversation_get_id(chat)); |
| 768 } |
769 } |
| 769 silc_hash_table_list_reset(&htl); |
770 silc_hash_table_list_reset(&htl); |
| 770 |
771 |
| 771 } else { |
772 } else { |
| 772 if (idtype == SILC_ID_CLIENT) { |
773 if (idtype == SILC_ID_CLIENT) { |
| 787 } |
788 } |
| 788 |
789 |
| 789 /* Remove user from all channels */ |
790 /* Remove user from all channels */ |
| 790 silc_hash_table_list(client_entry->channels, &htl); |
791 silc_hash_table_list(client_entry->channels, &htl); |
| 791 while (silc_hash_table_get(&htl, NULL, (void *)&chu)) { |
792 while (silc_hash_table_get(&htl, NULL, (void *)&chu)) { |
| 792 convo = purple_conversations_find_with_account(PURPLE_CONV_TYPE_CHAT, |
793 chat = purple_conversations_find_chat_with_account( |
| 793 chu->channel->channel_name, sg->account); |
794 chu->channel->channel_name, sg->account); |
| 794 if (!convo) |
795 if (!chat) |
| 795 continue; |
796 continue; |
| 796 purple_chat_conversation_remove_user(PURPLE_CONV_CHAT(convo), |
797 purple_chat_conversation_remove_user(chat, |
| 797 client_entry->nickname, tmp); |
798 client_entry->nickname, tmp); |
| 798 } |
799 } |
| 799 silc_hash_table_list_reset(&htl); |
800 silc_hash_table_list_reset(&htl); |
| 800 } |
801 } |
| 801 |
802 |
| 811 silc_dlist_start(list); |
812 silc_dlist_start(list); |
| 812 while ((client_entry = silc_dlist_get(list))) { |
813 while ((client_entry = silc_dlist_get(list))) { |
| 813 /* Remove from all channels */ |
814 /* Remove from all channels */ |
| 814 silc_hash_table_list(client_entry->channels, &htl); |
815 silc_hash_table_list(client_entry->channels, &htl); |
| 815 while (silc_hash_table_get(&htl, NULL, (void *)&chu)) { |
816 while (silc_hash_table_get(&htl, NULL, (void *)&chu)) { |
| 816 convo = purple_conversations_find_with_account(PURPLE_CONV_TYPE_CHAT, |
817 chat = purple_conversations_find_chat_with_account( |
| 817 chu->channel->channel_name, sg->account); |
818 chu->channel->channel_name, sg->account); |
| 818 if (!convo) |
819 if (!chat) |
| 819 continue; |
820 continue; |
| 820 purple_chat_conversation_remove_user(PURPLE_CONV_CHAT(convo), |
821 purple_chat_conversation_remove_user(chat, |
| 821 client_entry->nickname, |
822 client_entry->nickname, |
| 822 _("Server signoff")); |
823 _("Server signoff")); |
| 823 } |
824 } |
| 824 silc_hash_table_list_reset(&htl); |
825 silc_hash_table_list_reset(&htl); |
| 825 } |
826 } |
| 1087 SilcCommand command, SilcStatus status, |
1088 SilcCommand command, SilcStatus status, |
| 1088 SilcStatus error, va_list ap) |
1089 SilcStatus error, va_list ap) |
| 1089 { |
1090 { |
| 1090 PurpleConnection *gc = client->application; |
1091 PurpleConnection *gc = client->application; |
| 1091 SilcPurple sg = purple_connection_get_protocol_data(gc); |
1092 SilcPurple sg = purple_connection_get_protocol_data(gc); |
| 1092 PurpleConversation *convo; |
1093 PurpleChatConversation *chat; |
| 1093 |
1094 |
| 1094 switch (command) { |
1095 switch (command) { |
| 1095 case SILC_COMMAND_JOIN: |
1096 case SILC_COMMAND_JOIN: |
| 1096 { |
1097 { |
| 1097 SilcChannelEntry channel; |
1098 SilcChannelEntry channel; |
| 1098 PurpleConversation *convo; |
1099 PurpleChatConversation *chat; |
| 1099 SilcHashTableList *user_list; |
1100 SilcHashTableList *user_list; |
| 1100 SilcChannelUser chu; |
1101 SilcChannelUser chu; |
| 1101 GList *users = NULL, *flags = NULL; |
1102 GList *users = NULL, *flags = NULL; |
| 1102 char tmp[256], *topic; |
1103 char tmp[256], *topic; |
| 1103 |
1104 |
| 1114 topic = va_arg(ap, char *); |
1115 topic = va_arg(ap, char *); |
| 1115 |
1116 |
| 1116 /* Add channel to Purple */ |
1117 /* Add channel to Purple */ |
| 1117 channel->context = SILC_32_TO_PTR(++sg->channel_ids); |
1118 channel->context = SILC_32_TO_PTR(++sg->channel_ids); |
| 1118 serv_got_joined_chat(gc, sg->channel_ids, channel->channel_name); |
1119 serv_got_joined_chat(gc, sg->channel_ids, channel->channel_name); |
| 1119 convo = purple_conversations_find_with_account(PURPLE_CONV_TYPE_CHAT, |
1120 chat = purple_conversations_find_chat_with_account( |
| 1120 channel->channel_name, sg->account); |
1121 channel->channel_name, sg->account); |
| 1121 if (!convo) |
1122 if (!chat) |
| 1122 return; |
1123 return; |
| 1123 |
1124 |
| 1124 /* Add all users to channel */ |
1125 /* Add all users to channel */ |
| 1125 while (silc_hash_table_get(user_list, NULL, (void *)&chu)) { |
1126 while (silc_hash_table_get(user_list, NULL, (void *)&chu)) { |
| 1126 PurpleChatUserFlags f = PURPLE_CHAT_USER_NONE; |
1127 PurpleChatUserFlags f = PURPLE_CHAT_USER_NONE; |
| 1141 else |
1142 else |
| 1142 g_snprintf(tmp, sizeof(tmp), |
1143 g_snprintf(tmp, sizeof(tmp), |
| 1143 _("Channel founder on <I>%s</I> is <I>%s</I>"), |
1144 _("Channel founder on <I>%s</I> is <I>%s</I>"), |
| 1144 channel->channel_name, chu->client->nickname); |
1145 channel->channel_name, chu->client->nickname); |
| 1145 |
1146 |
| 1146 purple_conversation_write(convo, NULL, tmp, |
1147 purple_conversation_write(PURPLE_CONVERSATION(chat), NULL, tmp, |
| 1147 PURPLE_MESSAGE_SYSTEM, time(NULL)); |
1148 PURPLE_MESSAGE_SYSTEM, time(NULL)); |
| 1148 } |
1149 } |
| 1149 } |
1150 } |
| 1150 |
1151 |
| 1151 purple_chat_conversation_add_users(PURPLE_CONV_CHAT(convo), users, NULL, flags, FALSE); |
1152 purple_chat_conversation_add_users(chat, users, NULL, flags, FALSE); |
| 1152 g_list_free(users); |
1153 g_list_free(users); |
| 1153 g_list_free(flags); |
1154 g_list_free(flags); |
| 1154 |
1155 |
| 1155 /* Set topic */ |
1156 /* Set topic */ |
| 1156 if (topic) |
1157 if (topic) |
| 1157 purple_chat_conversation_set_topic(PURPLE_CONV_CHAT(convo), NULL, topic); |
1158 purple_chat_conversation_set_topic(chat, NULL, topic); |
| 1158 |
1159 |
| 1159 /* Set nick */ |
1160 /* Set nick */ |
| 1160 purple_chat_conversation_set_nick(PURPLE_CONV_CHAT(convo), conn->local_entry->nickname); |
1161 purple_chat_conversation_set_nick(chat, conn->local_entry->nickname); |
| 1161 } |
1162 } |
| 1162 break; |
1163 break; |
| 1163 |
1164 |
| 1164 case SILC_COMMAND_LEAVE: |
1165 case SILC_COMMAND_LEAVE: |
| 1165 break; |
1166 break; |
| 1410 return; |
1411 return; |
| 1411 } |
1412 } |
| 1412 |
1413 |
| 1413 channel = va_arg(ap, SilcChannelEntry); |
1414 channel = va_arg(ap, SilcChannelEntry); |
| 1414 |
1415 |
| 1415 convo = purple_conversations_find_with_account(PURPLE_CONV_TYPE_CHAT, |
1416 chat = purple_conversations_find_chat_with_account( |
| 1416 channel->channel_name, sg->account); |
1417 channel->channel_name, sg->account); |
| 1417 if (!convo) { |
1418 if (!chat) { |
| 1418 purple_debug_error("silc", "Got a topic for %s, which doesn't exist\n", |
1419 purple_debug_error("silc", "Got a topic for %s, which doesn't exist\n", |
| 1419 channel->channel_name); |
1420 channel->channel_name); |
| 1420 break; |
1421 break; |
| 1421 } |
1422 } |
| 1422 |
1423 |
| 1423 /* Set topic */ |
1424 /* Set topic */ |
| 1424 if (channel->topic) |
1425 if (channel->topic) |
| 1425 purple_chat_conversation_set_topic(PURPLE_CONV_CHAT(convo), NULL, channel->topic); |
1426 purple_chat_conversation_set_topic(chat, NULL, channel->topic); |
| 1426 } |
1427 } |
| 1427 break; |
1428 break; |
| 1428 |
1429 |
| 1429 case SILC_COMMAND_NICK: |
1430 case SILC_COMMAND_NICK: |
| 1430 { |
1431 { |
| 1443 newnick = va_arg(ap, char *); |
1444 newnick = va_arg(ap, char *); |
| 1444 |
1445 |
| 1445 /* Change nick on all channels */ |
1446 /* Change nick on all channels */ |
| 1446 silc_hash_table_list(local_entry->channels, &htl); |
1447 silc_hash_table_list(local_entry->channels, &htl); |
| 1447 while (silc_hash_table_get(&htl, NULL, (void *)&chu)) { |
1448 while (silc_hash_table_get(&htl, NULL, (void *)&chu)) { |
| 1448 convo = purple_conversations_find_with_account(PURPLE_CONV_TYPE_CHAT, |
1449 chat = purple_conversations_find_chat_with_account( |
| 1449 chu->channel->channel_name, sg->account); |
1450 chu->channel->channel_name, sg->account); |
| 1450 if (!convo) |
1451 if (!chat) |
| 1451 continue; |
1452 continue; |
| 1452 oldnick = purple_chat_conversation_get_nick(PURPLE_CONV_CHAT(convo)); |
1453 oldnick = purple_chat_conversation_get_nick(chat); |
| 1453 if (strcmp(oldnick, purple_normalize(purple_conversation_get_account(convo), newnick))) { |
1454 if (strcmp(oldnick, |
| 1454 purple_chat_conversation_rename_user(PURPLE_CONV_CHAT(convo), |
1455 purple_normalize(purple_conversation_get_account |
| |
1456 (PURPLE_CONVERSATION(chat)), newnick))) { |
| |
1457 |
| |
1458 purple_chat_conversation_rename_user(chat, |
| 1455 oldnick, newnick); |
1459 oldnick, newnick); |
| 1456 purple_chat_conversation_set_nick(PURPLE_CONV_CHAT(convo), newnick); |
1460 purple_chat_conversation_set_nick(chat, newnick); |
| 1457 } |
1461 } |
| 1458 } |
1462 } |
| 1459 silc_hash_table_list_reset(&htl); |
1463 silc_hash_table_list_reset(&htl); |
| 1460 |
1464 |
| 1461 purple_connection_set_display_name(gc, newnick); |
1465 purple_connection_set_display_name(gc, newnick); |