changeset 91:2b7ef3538cd3

- Fix type of 'flag' of writing_im_cb - Support a function which displays icons of sent messages via IM.
author Konosuke Watanabe <sasugaanija@gmail.com>
date Sun, 06 Jul 2008 17:43:44 +0900
parents fb9831fae969
children 7f20a61e98ad
files pidgin-twitter.c pidgin-twitter.h
diffstat 2 files changed, 14 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin-twitter.c	Sun Jul 06 01:51:07 2008 +0900
+++ b/pidgin-twitter.c	Sun Jul 06 17:43:44 2008 +0900
@@ -374,18 +374,9 @@
     }
 
     if (!error) {
-        gchar *m = NULL;
-        const char *screen_name = purple_prefs_get_string(OPT_SCREEN_NAME);
-        if (screen_name)
-            m = g_strdup_printf("%s: %s", screen_name, tm->status);
-        else
-            m = "";
-
         purple_conv_im_write(conv->u.im,
                              purple_account_get_username(tm->account),
-                             m, PURPLE_MESSAGE_SEND, tm->time);
-
-        g_free(m);
+                             tm->status, PURPLE_MESSAGE_SEND, tm->time);
     } else {
         gchar *m;
         m = g_strdup_printf("%s<BR>%s",
@@ -631,7 +622,7 @@
 
 static gboolean
 writing_im_cb(PurpleAccount *account, char *sender, char **buffer,
-              PurpleConversation *conv, int *flags, void *data)
+              PurpleConversation *conv, int flags, void *data)
 {
     twitter_debug("called\n");
 
@@ -641,6 +632,17 @@
     if(service == unknown_service)
         return FALSE;
 
+    /* Add screen_name if the current message is posted by owner */
+    if (flags & PURPLE_MESSAGE_SEND) {
+        gchar *m = NULL;
+        const char *screen_name = purple_prefs_get_string(OPT_SCREEN_NAME);
+        if (screen_name) {
+            m = g_strdup_printf("%s: %s", screen_name, *buffer);
+            g_free(*buffer);
+            *buffer = m;
+        }
+    }
+
     /* strip all markups */
     strip_markup(buffer);
 
--- a/pidgin-twitter.h	Sun Jul 06 01:51:07 2008 +0900
+++ b/pidgin-twitter.h	Sun Jul 06 17:43:44 2008 +0900
@@ -75,7 +75,7 @@
 static gboolean eval(const GMatchInfo *match_info, GString *result, gpointer user_data);
 static void translate(gchar **str, int which, int service);
 static void playsound(gchar **str, int which);
-static gboolean writing_im_cb(PurpleAccount *account, char *sender, char **buffer, PurpleConversation *conv, int *flags, void *data);
+static gboolean writing_im_cb(PurpleAccount *account, char *sender, char **buffer, PurpleConversation *conv, int flags, void *data);
 static void insert_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *position, gchar *new_text, gint new_text_length, gpointer user_data);
 static void delete_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *start_pos, GtkTextIter *end_pos, gpointer user_data);
 static void detach_from_window(void);