From a2ce688cad3579e6fd4078f7033d2086e9df64e0 Mon Sep 17 00:00:00 2001 From: Eion Robb Date: Thu, 20 Apr 2017 18:49:46 +1200 Subject: Fix for crash when receiving a typing notification from a chat room user who we don't know is in the chat room See issue #543 --- skypeweb/skypeweb_messages.c | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/skypeweb/skypeweb_messages.c b/skypeweb/skypeweb_messages.c index 4d47948..37286c4 100644 --- a/skypeweb/skypeweb_messages.c +++ b/skypeweb/skypeweb_messages.c @@ -191,19 +191,21 @@ process_message_resource(SkypeWebAccount *sa, JsonObject *resource) } cb = purple_chat_conversation_find_user(chatconv, from); - cbflags = purple_chat_user_get_flags(cb); - - cbflags |= PURPLE_CHAT_USER_TYPING; - - // typing notification icon - if (purple_account_get_bool(sa->account, "show-typing-as-icon", FALSE)) { - cbflags |= PURPLE_CHAT_USER_VOICE; + if (cb != NULL) { + cbflags = purple_chat_user_get_flags(cb); + + cbflags |= PURPLE_CHAT_USER_TYPING; + + // typing notification icon + if (purple_account_get_bool(sa->account, "show-typing-as-icon", FALSE)) { + cbflags |= PURPLE_CHAT_USER_VOICE; + } + + purple_chat_user_set_flags(cb, cbflags); + + //purple_timeout_add_seconds(7, skypeweb_clear_typing_hack, cb); } - purple_chat_user_set_flags(cb, cbflags); - - //purple_timeout_add_seconds(7, skypeweb_clear_typing_hack, cb); - } else if ((g_str_equal(messagetype, "RichText") || g_str_equal(messagetype, "Text"))) { gchar *html; gint64 skypeemoteoffset = 0; @@ -219,21 +221,15 @@ process_message_resource(SkypeWebAccount *sa, JsonObject *resource) // Remove typing notification icon w/o "show-typing-as-icon" option check. // Hard reset cbflags even if user changed settings while someone typing message. - #if !PURPLE_VERSION_CHECK(3, 0, 0) - cbflags = purple_conv_chat_user_get_flags(chatconv, from); - (void) cb; - #else - cb = purple_chat_conversation_find_user(chatconv, from); - cbflags = purple_chat_user_get_flags(cb); - #endif - cbflags &= ~PURPLE_CHAT_USER_TYPING & ~PURPLE_CHAT_USER_VOICE; - - #if !PURPLE_VERSION_CHECK(3, 0, 0) - purple_conv_chat_user_set_flags(chatconv, from, cbflags); - #else + cb = purple_chat_conversation_find_user(chatconv, from); + if (cb != NULL) { + cbflags = purple_chat_user_get_flags(cb); + + cbflags &= ~PURPLE_CHAT_USER_TYPING & ~PURPLE_CHAT_USER_VOICE; + purple_chat_user_set_flags(cb, cbflags); - #endif + } if (content && *content) { if (g_str_equal(messagetype, "Text")) { -- cgit v1.2.3