changeset 302:e17b74fdf86a

more ffeed support: - automatically prepend @me to sending message - discard parrot message
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Tue, 26 May 2009 00:37:48 +0900
parents 3b2b68c8babd
children 1d3209e7e197
files main.c
diffstat 1 files changed, 37 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/main.c	Mon May 25 22:52:23 2009 +0900
+++ b/main.c	Tue May 26 00:37:48 2009 +0900
@@ -30,6 +30,7 @@
 static GHashTable *conv_hash = NULL;
 static GList *wassr_parrot_list = NULL;
 static GList *identica_parrot_list = NULL;
+static GList *ffeed_parrot_list = NULL;
 #ifdef _WIN32
 gboolean blink_state = FALSE;
 gboolean blink_modified = FALSE;
@@ -74,6 +75,7 @@
     int utflen, bytes;
     int service = get_service_type_by_account(account, recipient);
     gchar *tmp, *plain;
+    gchar *ffeed_tmp;
     gsize dummy;
 
     twitter_debug("called\n");
@@ -106,6 +108,17 @@
             g_list_prepend(identica_parrot_list, g_strdup(plain));
         twitter_debug("identica parrot pushed:%s\n", plain);
         break;
+    case ffeed_service:
+        /* store sending message to address parrot problem */
+        ffeed_parrot_list =
+            g_list_prepend(ffeed_parrot_list, g_strdup(plain));
+        twitter_debug("ffeed parrot pushed:%s\n", plain);
+
+        /* prepend @me */
+        ffeed_tmp = g_strdup_printf("@me %s", plain);
+        g_free(plain);
+        plain = ffeed_tmp;
+        break;
     default:
         break;
     }
@@ -942,8 +955,7 @@
         }
         g_free(stripped);
     }
-
-    if(service == identica_service) {
+    else if(service == identica_service) {
         /* discard parrot message */
         gchar *stripped = strip_html_markup(*buffer);
         GList *current = g_list_first(identica_parrot_list);
@@ -966,6 +978,29 @@
         }
         g_free(stripped);
     }
+    else if(service == ffeed_service) {
+        /* discard parrot message */
+        gchar *stripped = strip_html_markup(*buffer);
+        GList *current = g_list_first(ffeed_parrot_list);
+        while(current) {
+            GList *next = g_list_next(current);
+
+            if(strstr(stripped, current->data)) {
+                twitter_debug("ffeed parrot clearing: buf = %s post = %s\n",
+                              *buffer, (char *)current->data);
+                g_free(*sender); *sender = NULL;
+                g_free(*buffer); *buffer = NULL;
+                g_free(current->data);
+                current->data = NULL;
+                ffeed_parrot_list =
+                    g_list_delete_link(ffeed_parrot_list, current);
+                break;
+            }
+
+            current = next;
+        }
+        g_free(stripped);
+    }
 
     /* filtering */
     if(purple_prefs_get_bool(OPT_FILTER)) {