changeset 138:eaf5d2c4ada0

temporal fix for identi.ca problems: - identi.ca sends us massive html. - the XMPP daemon starts to parrot user's post.
author Yoshiki Yazawa <yaz@honeyplnaet.jp>
date Wed, 23 Jul 2008 07:32:21 +0900
parents 97f11d057071
children 9871186ebf8f
files pidgin-twitter.c pidgin-twitter.h
diffstat 2 files changed, 50 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin-twitter.c	Wed Jul 23 04:53:17 2008 +0900
+++ b/pidgin-twitter.c	Wed Jul 23 07:32:21 2008 +0900
@@ -33,6 +33,7 @@
 static GList *statuseslist = NULL;
 static GList *postedlist = NULL;
 static gchar *wassr_post = NULL;
+static gchar *identica_post = NULL;
 
 
 /*************/
@@ -68,6 +69,7 @@
     "<span ",
     "</span>",
     "<body>",
+    "<body ",
     "</body>",
     "<i>",
     "</i>",
@@ -76,6 +78,9 @@
     "<br>",
     "<br/>",
     "<img ",
+    "<html>",
+    "<html ",
+    "</html>",
     NULL
 };
 
@@ -85,7 +90,7 @@
     gchar *head, *tail;     /* head and tail of html */
     gchar *begin, *end;     /* begin:<  end:> */
     gchar *html, *str;      /* copied src and str to be returned */
-    gchar *vis1, *vis2;     /* begin and end of address part */
+//    gchar *vis1, *vis2;     /* begin and end of address part */
     gchar *startp;          /* starting point marker */
     gchar **tagp;           /* tag iterator */
     gchar *tmp, *tmp2;      /* scratches */
@@ -153,6 +158,7 @@
         if(!g_ascii_strncasecmp(begin, *tagp, strlen(*tagp))) {
             /* we found a valid tag */
             /* if tag is <a href=, extract address. */
+#if 0
             if(!strcmp(*tagp, "<a href=")) {
                 vis1 = NULL; vis2 = NULL;
 
@@ -174,6 +180,10 @@
                 startp = end + 1;
                 goto loop;
             } /* <a href= */
+#else
+            if(0) {
+            }
+#endif
             else {
                 /* anything else: discard whole <>. */
                 startp = end + 1;
@@ -721,20 +731,27 @@
               void *data)
 {
     int utflen, bytes;
-    gboolean twitter_ac = FALSE, wassr_ac = FALSE;
+    gboolean twitter_ac = FALSE, wassr_ac = FALSE, identica_ac = FALSE;
     twitter_debug("called\n");
 
     twitter_ac = is_twitter_account(account, recipient);
     wassr_ac   = is_wassr_account(account, recipient);
+    identica_ac = is_identica_account(account, recipient);
 
     /* strip all markups */
-    if(twitter_ac || wassr_ac)
+    if(twitter_ac || wassr_ac || identica_ac)
         strip_markup(buffer, TRUE);
 
     if(wassr_ac) {
         /* store sending message to address parrot problem */
         g_strlcpy(wassr_post, *buffer, WASSR_POST_LEN);
-        twitter_debug("parrot pushed:%s\n", *buffer);
+        twitter_debug("wassr parrot pushed:%s\n", *buffer);
+    }
+
+    if(identica_ac) {
+        /* store sending message to address parrot problem */
+        g_strlcpy(identica_post, *buffer, IDENTICA_POST_LEN);
+        twitter_debug("identica parrot pushed:%s\n", *buffer);
     }
 
     /* return here if the message is not to twitter */
@@ -1459,14 +1476,16 @@
     twitter_debug("called\n");
     twitter_debug("buffer = %s suppress_oops = %d\n", *buffer, suppress_oops);
 
-    if(is_twitter_conv(conv) || is_wassr_conv(conv) || is_identica_conv(conv)) {
+    gint service = get_service_type(conv);
+
+    if(service != unknown_service) {
         /* suppress notification of incoming messages. */
         if(purple_prefs_get_bool(OPT_PREVENT_NOTIFICATION))
             *flags |= PURPLE_MESSAGE_SYSTEM;
     }
 
     /* quick hack to suppress annoying completion message from wassr */
-    if(is_wassr_conv(conv)) {
+    if(service == wassr_service) {
         if(strstr(*buffer, "<body>投稿完了:") ||
            strstr(*buffer, "<body>チャンネル投稿完了:")) {
             twitter_debug("clearing sender and buffer\n");
@@ -1474,14 +1493,27 @@
             g_free(*buffer); *buffer = NULL;
         }
         /* fix for parrot problem during post to a channel */
-        else if(strlen(wassr_post) && strstr(*buffer, wassr_post)) {
+        else if(wassr_post &&
+                strlen(wassr_post) &&
+                strstr(*buffer, wassr_post)) {
             twitter_debug("parrot clearing: buf = %s post = %s\n", *buffer, wassr_post);
             g_free(*sender); *sender = NULL;
             g_free(*buffer); *buffer = NULL;
         }
     }
 
-    if(!is_twitter_conv(conv)) {
+    if(service == identica_service) {
+        if(identica_post &&
+           strlen(identica_post) &&
+           strstr(*buffer, identica_post)) {
+            twitter_debug("identica parrot clearing: buf = %s post = %s\n",
+                          *buffer, identica_post);
+            g_free(*sender); *sender = NULL;
+            g_free(*buffer); *buffer = NULL;
+        }
+    }
+
+    if(service != twitter_service) {
         return FALSE;
     }
 
@@ -2261,6 +2293,9 @@
     /* allocate wassr_post */
     wassr_post = g_new0(gchar, WASSR_POST_LEN + 1);
 
+    /* allocate identica_post */
+    identica_post = g_new0(gchar, IDENTICA_POST_LEN + 1);
+
     return TRUE;
 }
 
@@ -2344,6 +2379,10 @@
     g_free(wassr_post);
     wassr_post = NULL;
 
+    /* free identica_post */
+    g_free(identica_post);
+    identica_post = NULL;
+
     return TRUE;
 }
 
--- a/pidgin-twitter.h	Wed Jul 23 04:53:17 2008 +0900
+++ b/pidgin-twitter.h	Wed Jul 23 07:32:21 2008 +0900
@@ -148,13 +148,14 @@
     "Content-Length: %d\r\n\r\n"
 #define TWITTER_STATUS_FORMAT "status=%s"
 #define TWITTER_STATUS_TERMINATOR "\r\n\r\n"
-#define TWITTER_DEFAULT_INTERVAL 60
+#define TWITTER_DEFAULT_INTERVAL (60)
 
 /* wassr specific macros */
 #define WASSR_POST_LEN (255 * 4)
+#define IDENTICA_POST_LEN (140)
 
 /* misc macros */
-#define DEFAULT_ICON_SIZE 48
+#define DEFAULT_ICON_SIZE (48)
 
 /* debug macros */
 #define twitter_debug(fmt, ...)	purple_debug(PURPLE_DEBUG_INFO, PLUGIN_NAME, "%s():%4d:  " fmt, __FUNCTION__, (int)__LINE__, ## __VA_ARGS__);