comparison libpurple/server.c @ 32827:4a34689eeb33 default tip

merged from im.pidgin.pidgin
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Sat, 19 Nov 2011 14:42:54 +0900
parents 0f94ec89f0bc 2ec94166be43
children
comparison
equal deleted inserted replaced
32692:0f94ec89f0bc 32827:4a34689eeb33
147 /* 147 /*
148 * XXX - If "only auto-reply when away & idle" is set, then shouldn't 148 * XXX - If "only auto-reply when away & idle" is set, then shouldn't
149 * this only reset lar->sent if we're away AND idle? 149 * this only reset lar->sent if we're away AND idle?
150 */ 150 */
151 auto_reply_pref = purple_prefs_get_string("/purple/away/auto_reply"); 151 auto_reply_pref = purple_prefs_get_string("/purple/away/auto_reply");
152 if((gc->flags & PURPLE_CONNECTION_AUTO_RESP) && 152 if((purple_connection_get_flags(gc) & PURPLE_CONNECTION_AUTO_RESP) &&
153 !purple_presence_is_available(presence) && 153 !purple_presence_is_available(presence) &&
154 !purple_strequal(auto_reply_pref, "never")) { 154 !purple_strequal(auto_reply_pref, "never")) {
155 155
156 struct last_auto_response *lar; 156 struct last_auto_response *lar;
157 lar = get_last_auto_response(gc, name); 157 lar = get_last_auto_response(gc, name);
579 579
580 /* 580 /*
581 * We should update the conversation window buttons and menu, 581 * We should update the conversation window buttons and menu,
582 * if it exists. 582 * if it exists.
583 */ 583 */
584 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, who, gc->account); 584 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, who, purple_connection_get_account(gc));
585 585
586 /* 586 /*
587 * Make copies of the message and the sender in case plugins want 587 * Make copies of the message and the sender in case plugins want
588 * to free these strings and replace them with a modifed version. 588 * to free these strings and replace them with a modifed version.
589 */ 589 */
590 buffy = g_strdup(msg); 590 buffy = g_strdup(msg);
591 angel = g_strdup(who); 591 angel = g_strdup(who);
592 592
593 plugin_return = GPOINTER_TO_INT( 593 plugin_return = GPOINTER_TO_INT(
594 purple_signal_emit_return_1(purple_conversations_get_handle(), 594 purple_signal_emit_return_1(purple_conversations_get_handle(),
595 "receiving-im-msg", gc->account, 595 "receiving-im-msg", purple_connection_get_account(gc),
596 &angel, &buffy, conv, &flags)); 596 &angel, &buffy, conv, &flags));
597 597
598 if (!buffy || !angel || plugin_return) { 598 if (!buffy || !angel || plugin_return) {
599 g_free(buffy); 599 g_free(buffy);
600 g_free(angel); 600 g_free(angel);
602 } 602 }
603 603
604 name = angel; 604 name = angel;
605 message = buffy; 605 message = buffy;
606 606
607 purple_signal_emit(purple_conversations_get_handle(), "received-im-msg", gc->account, 607 purple_signal_emit(purple_conversations_get_handle(), "received-im-msg", purple_connection_get_account(gc),
608 name, message, conv, flags); 608 name, message, conv, flags);
609 609
610 /* search for conversation again in case it was created by received-im-msg handler */ 610 /* search for conversation again in case it was created by received-im-msg handler */
611 if (conv == NULL) 611 if (conv == NULL)
612 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, name, gc->account); 612 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, name, purple_connection_get_account(gc));
613 613
614 if (conv == NULL) 614 if (conv == NULL)
615 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, name); 615 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, name);
616 616
617 purple_conv_im_write(PURPLE_CONV_IM(conv), name, message, flags, mtime); 617 purple_conv_im_write(PURPLE_CONV_IM(conv), name, message, flags, mtime);
624 * - we are available 624 * - we are available
625 * - or it's disabled 625 * - or it's disabled
626 * - or we're not idle and the 'only auto respond if idle' pref 626 * - or we're not idle and the 'only auto respond if idle' pref
627 * is set 627 * is set
628 */ 628 */
629 if (gc->flags & PURPLE_CONNECTION_AUTO_RESP) 629 if (purple_connection_get_flags(gc) & PURPLE_CONNECTION_AUTO_RESP)
630 { 630 {
631 PurplePresence *presence; 631 PurplePresence *presence;
632 PurpleStatus *status; 632 PurpleStatus *status;
633 PurpleStatusType *status_type; 633 PurpleStatusType *status_type;
634 PurpleStatusPrimitive primitive; 634 PurpleStatusPrimitive primitive;
697 void serv_got_typing(PurpleConnection *gc, const char *name, int timeout, 697 void serv_got_typing(PurpleConnection *gc, const char *name, int timeout,
698 PurpleTypingState state) { 698 PurpleTypingState state) {
699 PurpleConversation *conv; 699 PurpleConversation *conv;
700 PurpleConvIm *im = NULL; 700 PurpleConvIm *im = NULL;
701 701
702 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, name, gc->account); 702 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, name, purple_connection_get_account(gc));
703 if (conv != NULL) { 703 if (conv != NULL) {
704 im = PURPLE_CONV_IM(conv); 704 im = PURPLE_CONV_IM(conv);
705 705
706 purple_conv_im_set_typing_state(im, state); 706 purple_conv_im_set_typing_state(im, state);
707 } else { 707 } else {
708 switch (state) 708 switch (state)
709 { 709 {
710 case PURPLE_TYPING: 710 case PURPLE_TYPING:
711 purple_signal_emit(purple_conversations_get_handle(), 711 purple_signal_emit(purple_conversations_get_handle(),
712 "buddy-typing", gc->account, name); 712 "buddy-typing", purple_connection_get_account(gc), name);
713 break; 713 break;
714 case PURPLE_TYPED: 714 case PURPLE_TYPED:
715 purple_signal_emit(purple_conversations_get_handle(), 715 purple_signal_emit(purple_conversations_get_handle(),
716 "buddy-typed", gc->account, name); 716 "buddy-typed", purple_connection_get_account(gc), name);
717 break; 717 break;
718 case PURPLE_NOT_TYPING: 718 case PURPLE_NOT_TYPING:
719 purple_signal_emit(purple_conversations_get_handle(), 719 purple_signal_emit(purple_conversations_get_handle(),
720 "buddy-typing-stopped", gc->account, name); 720 "buddy-typing-stopped", purple_connection_get_account(gc), name);
721 break; 721 break;
722 } 722 }
723 } 723 }
724 724
725 if (conv != NULL && timeout > 0) 725 if (conv != NULL && timeout > 0)
729 void serv_got_typing_stopped(PurpleConnection *gc, const char *name) { 729 void serv_got_typing_stopped(PurpleConnection *gc, const char *name) {
730 730
731 PurpleConversation *conv; 731 PurpleConversation *conv;
732 PurpleConvIm *im; 732 PurpleConvIm *im;
733 733
734 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, name, gc->account); 734 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, name, purple_connection_get_account(gc));
735 if (conv != NULL) 735 if (conv != NULL)
736 { 736 {
737 im = PURPLE_CONV_IM(conv); 737 im = PURPLE_CONV_IM(conv);
738 738
739 if (im->typing_state == PURPLE_NOT_TYPING) 739 if (purple_conv_im_get_typing_state(im) == PURPLE_NOT_TYPING)
740 return; 740 return;
741 741
742 purple_conv_im_stop_typing_timeout(im); 742 purple_conv_im_stop_typing_timeout(im);
743 purple_conv_im_set_typing_state(im, PURPLE_NOT_TYPING); 743 purple_conv_im_set_typing_state(im, PURPLE_NOT_TYPING);
744 } 744 }
745 else 745 else
746 { 746 {
747 purple_signal_emit(purple_conversations_get_handle(), 747 purple_signal_emit(purple_conversations_get_handle(),
748 "buddy-typing-stopped", gc->account, name); 748 "buddy-typing-stopped", purple_connection_get_account(gc), name);
749 } 749 }
750 } 750 }
751 751
752 struct chat_invite_data { 752 struct chat_invite_data {
753 PurpleConnection *gc; 753 PurpleConnection *gc;
934 buffy = g_strdup(message); 934 buffy = g_strdup(message);
935 angel = g_strdup(who); 935 angel = g_strdup(who);
936 936
937 plugin_return = GPOINTER_TO_INT( 937 plugin_return = GPOINTER_TO_INT(
938 purple_signal_emit_return_1(purple_conversations_get_handle(), 938 purple_signal_emit_return_1(purple_conversations_get_handle(),
939 "receiving-chat-msg", g->account, 939 "receiving-chat-msg", purple_connection_get_account(g),
940 &angel, &buffy, conv, &flags)); 940 &angel, &buffy, conv, &flags));
941 941
942 if (!buffy || !angel || plugin_return) { 942 if (!buffy || !angel || plugin_return) {
943 g_free(buffy); 943 g_free(buffy);
944 g_free(angel); 944 g_free(angel);
946 } 946 }
947 947
948 who = angel; 948 who = angel;
949 message = buffy; 949 message = buffy;
950 950
951 purple_signal_emit(purple_conversations_get_handle(), "received-chat-msg", g->account, 951 purple_signal_emit(purple_conversations_get_handle(), "received-chat-msg", purple_connection_get_account(g),
952 who, message, conv, flags); 952 who, message, conv, flags);
953 953
954 purple_conv_chat_write(chat, who, message, flags, mtime); 954 purple_conv_chat_write(chat, who, message, flags, mtime);
955 955
956 g_free(angel); 956 g_free(angel);