diff pidgin-twitter.c @ 219:739ed7a4426c

revised receiving_im_cb(). conv may be NULL so that filter might not work for messages which arrived at before conversation has been established.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Fri, 29 Aug 2008 01:11:16 +0900
parents 27651b73a638
children 1ebef23bbccb
line wrap: on
line diff
--- a/pidgin-twitter.c	Thu Aug 28 22:02:45 2008 +0900
+++ b/pidgin-twitter.c	Fri Aug 29 01:11:16 2008 +0900
@@ -1445,6 +1445,24 @@
 }
 
 static gint
+get_service_type_by_account(PurpleAccount *account, const char *sender)
+{
+    gint service = unknown_service;
+
+    g_return_val_if_fail(account != NULL, unknown_service);
+    g_return_val_if_fail(sender != NULL, unknown_service);
+
+    if(is_twitter_account(account, sender))
+        service = twitter_service;
+    else if(is_wassr_account(account, sender))
+        service = wassr_service;
+    else if(is_identica_account(account, sender))
+        service = identica_service;
+
+    return service;
+}
+
+static gint
 get_service_type(PurpleConversation *conv)
 {
     gint service = unknown_service;
@@ -1543,6 +1561,7 @@
 
     switch(service) {
     case twitter_service:
+    default:
         list = purple_prefs_get_string(OPT_FILTER_TWITTER);
         screen_name = g_strdup_printf("@%s", purple_prefs_get_string(OPT_SCREEN_NAME_TWITTER));
         break;
@@ -1585,7 +1604,7 @@
             if(!strcmp(user, *candidate)) {
                 twitter_debug("match. filter %s\n", user);
                 /* pidgin should handle this flag properly --yaz */
-//                *flags |= PURPLE_MESSAGE_INVISIBLE; 
+//                *flags |= PURPLE_MESSAGE_INVISIBLE;
 
                 /* temporal workaround */
                 g_free(*sender); *sender = NULL;
@@ -1611,7 +1630,10 @@
     twitter_debug("called\n");
     twitter_debug("buffer = %s suppress_oops = %d\n", *buffer, suppress_oops);
 
-    gint service = get_service_type(conv);
+    gint service;
+
+    service = get_service_type_by_account(account, *sender);
+    twitter_debug("service = %d\n", service);
 
 #ifdef _WIN32
     /* suppress notification of incoming messages. */