diff pidgin-twitter.c @ 74:6b9593d1ffed

quick hack to suppress annoying completion message from wassr.
author Yoshiki Yazawa <yaz@cc.rim.or.jp>
date Sat, 28 Jun 2008 02:20:05 +0900
parents 08bd4abdfd3d
children 63bd9ca28be0
line wrap: on
line diff
--- a/pidgin-twitter.c	Sat Jun 28 00:08:57 2008 +0900
+++ b/pidgin-twitter.c	Sat Jun 28 02:20:05 2008 +0900
@@ -462,7 +462,7 @@
         }
         return FALSE;
     }
-    
+
     /* try to suppress oops message */
     utflen = g_utf8_strlen(*buffer, -1);
     bytes = strlen(*buffer);
@@ -820,6 +820,30 @@
     return is_twitter_account(account, name);
 }
 
+static gboolean
+is_wassr_account(PurpleAccount *account, const char *name)
+{
+    const gchar *proto = purple_account_get_protocol_id(account);
+
+    twitter_debug("name  = %s proto = %s\n", name, proto);
+
+    if(!strcmp(name, "wassr-bot@wassr.jp/bot") &&
+       !strcmp(proto, "prpl-jabber")) {
+        return TRUE;
+    }
+
+    return FALSE;
+}
+
+static gboolean
+is_wassr_conv(PurpleConversation *conv)
+{
+    const char *name = purple_conversation_get_name(conv);
+    PurpleAccount *account = purple_conversation_get_account(conv);
+
+    return is_wassr_account(account, name);
+}
+
 static void
 conv_created_cb(PurpleConversation *conv, gpointer null)
 {
@@ -852,6 +876,16 @@
     /* Check if the conv is not NULL to avoid a clash.
      * conv is null when the conversation window has not opened yet.
      * And if check is a twitter conv. */
+
+    /* quick hack to suppress annoying completion message from wassr */
+    if(conv && is_wassr_conv(conv)) {
+        if(strstr(*buffer, "<body>投稿完了:")) {
+            twitter_debug("clearing sender and buffer\n");
+            g_free(*sender); *sender = NULL;
+            g_free(*buffer); *buffer = NULL;
+        }
+    }
+
     if(!(conv && is_twitter_conv(conv))) {
         return FALSE;
     }