changeset 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 f83b14fbca23
files pidgin-twitter.c pidgin-twitter.h
diffstat 2 files changed, 37 insertions(+), 1 deletions(-) [+]
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;
     }
--- a/pidgin-twitter.h	Sat Jun 28 00:08:57 2008 +0900
+++ b/pidgin-twitter.h	Sat Jun 28 02:20:05 2008 +0900
@@ -83,6 +83,8 @@
 static void attach_to_gtkconv(PidginConversation *gtkconv, gpointer null);
 static gboolean is_twitter_account(PurpleAccount *account, const char *name);
 static gboolean is_twitter_conv(PurpleConversation *conv);
+static gboolean is_wassr_account(PurpleAccount *account, const char *name);
+static gboolean is_wassr_conv(PurpleConversation *conv);
 static void conv_created_cb(PurpleConversation *conv, gpointer null);
 static void deleting_conv_cb(PurpleConversation *conv);
 static gboolean receiving_im_cb(PurpleAccount *account, char **sender, char **buffer, PurpleConversation *conv, PurpleMessageFlags *flags, void *data);