src/protocols/msn/slp.c

changeset 11518
c1c6ea0117d8
parent 11338
1a3663ac9b05
child 11573
e4a695b3053a
equal deleted inserted replaced
11517:a3d6d136b7dd 11518:c1c6ea0117d8
787 MsnSlpLink *slplink; 787 MsnSlpLink *slplink;
788 MsnObject *obj; 788 MsnObject *obj;
789 char **tokens; 789 char **tokens;
790 char *smile, *body_str; 790 char *smile, *body_str;
791 const char *body, *who, *sha1c; 791 const char *body, *who, *sha1c;
792 guint tok;
792 size_t body_len; 793 size_t body_len;
793 794
794 GaimConversation *conversation; 795 GaimConversation *conv;
795 GaimConnection *gc;
796 796
797 session = cmdproc->servconn->session; 797 session = cmdproc->servconn->session;
798 798
799 body = msn_message_get_bin_data(msg, &body_len); 799 body = msn_message_get_bin_data(msg, &body_len);
800 body_str = g_strndup(body, body_len); 800 body_str = g_strndup(body, body_len);
801 801
802 tokens = g_strsplit(body_str, "\t", 2); 802 /* MSN Messenger 7 may send more than one MSNObject in a single message...
803 * Maybe 10 tokens is a reasonable max value. */
804 tokens = g_strsplit(body_str, "\t", 10);
803 805
804 g_free(body_str); 806 g_free(body_str);
805 807
806 smile = tokens[0]; 808 for (tok = 0; tok < 9; tok += 2) {
807 obj = msn_object_new_from_string(gaim_url_decode(tokens[1])); 809 if (tokens[tok] == NULL || tokens[tok + 1] == NULL) {
808 810 break;
809 who = msn_object_get_creator(obj); 811 }
810 sha1c = msn_object_get_sha1c(obj); 812
811 813 smile = tokens[tok];
812 slplink = msn_session_get_slplink(session, who); 814 obj = msn_object_new_from_string(gaim_url_decode(tokens[tok + 1]));
813 815
814 gc = slplink->session->account->gc; 816 who = msn_object_get_creator(obj);
815 817 sha1c = msn_object_get_sha1c(obj);
816 conversation = gaim_find_conversation_with_account(GAIM_CONV_TYPE_ANY, who, gc->account); 818
817 819 slplink = msn_session_get_slplink(session, who);
818 if (gaim_conv_custom_smiley_add(conversation, smile, "sha1", sha1c)) { 820
819 msn_slplink_request_object(slplink, smile, got_emoticon, NULL, obj); 821 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_ANY, who,
820 } 822 session->account);
821 823
824 /* If the conversation doesn't exist then this is a custom smiley
825 * used in the first message in a MSN conversation: we need to create
826 * the conversation now, otherwise the custom smiley won't be shown.
827 * This happens because every GtkIMHtml has its own smiley tree: if
828 * the conversation doesn't exist then we cannot associate the new
829 * smiley with its GtkIMHtml widget. */
830 if (!conv) {
831 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, session->account, who);
832 }
833
834 if (gaim_conv_custom_smiley_add(conv, smile, "sha1", sha1c)) {
835 msn_slplink_request_object(slplink, smile, got_emoticon, NULL, obj);
836 }
837
838 msn_object_destroy(obj);
839 obj = NULL;
840 who = NULL;
841 sha1c = NULL;
842 }
822 g_strfreev(tokens); 843 g_strfreev(tokens);
823 } 844 }
824 845
825 static gboolean 846 static gboolean
826 buddy_icon_cached(GaimConnection *gc, MsnObject *obj) 847 buddy_icon_cached(GaimConnection *gc, MsnObject *obj)

mercurial