changeset 48:42869098eda3

adapted for msn style option (or new line plugin).
author Yoshiki Yazawa <yaz@cc.rim.or.jp>
date Tue, 13 May 2008 21:25:47 +0900
parents 6774859df10b
children 82b2b3767311
files pidgin-twitter.c
diffstat 1 files changed, 19 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin-twitter.c	Tue May 13 18:30:19 2008 +0900
+++ b/pidgin-twitter.c	Tue May 13 21:25:47 2008 +0900
@@ -55,13 +55,13 @@
 
 /* formats and templates */
 #define RECIPIENT_FORMAT        "@<a href='http://twitter.com/%s'>%s</a>"
-#define SENDER_FORMAT           "<a href='http://twitter.com/%s'>%s</a>: "
+#define SENDER_FORMAT           "%s<a href='http://twitter.com/%s'>%s</a>: "
 #define DEFAULT_LIST            "(list of users: separated with ' ,:;')"
 #define OOPS_MESSAGE            "<body>Oops! Your update was over 140 characters. We sent the short version to your friends (they can view the entire update on the web).<BR></body>"
 
 /* patterns */
 #define P_RECIPIENT     "@([A-Za-z0-9_]+)"
-#define P_SENDER        "^([A-Za-z0-9_]+): "
+#define P_SENDER        "^(\\r?\\n?)([A-Za-z0-9_]+): "
 #define P_COMMAND       "^(?:\\s*)([dDfFgGlLmMnNtTwW]{1}\\s+[A-Za-z0-9_]+)(?:\\s*\\Z)"
 #define P_PSEUDO        "^\\s*(?:[\"#$%&'()*+,\\-./:;<=>?\\[\\\\\\]_`{|}~]|[^\\s\\x21-\\x7E])*([dDfFgGlLmMnNtTwW]{1})(?:\\Z|\\s+|[^\\x21-\\x7E]+\\Z)"
 
@@ -345,16 +345,27 @@
 static gboolean
 eval(const GMatchInfo *match_info, GString *result, gpointer user_data)
 {
+    int which = *(int *)user_data;
     gchar sub[128];
-    gchar *match = g_match_info_fetch(match_info, 1);
 
-    int which = *(int *)user_data;
+    if(which == RECIPIENT) {
+        gchar *match = g_match_info_fetch(match_info, 1);
 
-    snprintf(sub, 128, which ? SENDER_FORMAT : RECIPIENT_FORMAT,
-             match, match);
+        snprintf(sub, 128, RECIPIENT_FORMAT, match, match);
+        g_free(match);
+    }
+    else if(which == SENDER) {
+        gchar *match1 = g_match_info_fetch(match_info, 1); //preceding CR|LF
+        gchar *match2 = g_match_info_fetch(match_info, 2); //sender
+
+        snprintf(sub, 128, SENDER_FORMAT, match1 ? match1: "",
+                 match2, match2);
+        g_free(match1);
+        g_free(match2);
+    }
+
+    g_string_append(result, sub);
     twitter_debug("sub = %s\n", sub);
-    g_string_append(result, sub);
-    g_free(match);
 
     return FALSE;
 }