changeset 29:c1e5ff55f1b4 default tip

now /song command can be followed by plain text message.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Fri, 23 Oct 2009 01:37:07 +0900
parents 72c95262fd1b
children
files pidgin-audacious.c
diffstat 1 files changed, 17 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin-audacious.c	Thu Sep 10 17:07:53 2009 +0900
+++ b/pidgin-audacious.c	Fri Oct 23 01:37:07 2009 +0900
@@ -506,6 +506,7 @@
     PurpleConversationType type = purple_conversation_get_type(conv);
     size_t dummy;
     const gchar *template = NULL;
+    gchar *msg;
 
     /* audacious isn't playing */
     if(!is_app_playing()) {
@@ -540,18 +541,26 @@
             song = tmp2;
     }
 
+    if(*args) {
+        msg = g_strdup_printf("%s %s", song, *args);
+        g_free(song);
+    }
+    else {
+        msg = song;
+    }
+
     if(type == PURPLE_CONV_TYPE_CHAT) {
         PurpleConvChat *chat = purple_conversation_get_chat_data(conv);
-        if (chat && song)
-            purple_conv_chat_send(chat, song);
+        if (chat && msg)
+            purple_conv_chat_send(chat, msg);
     }
     else if(type == PURPLE_CONV_TYPE_IM) {
         PurpleConvIm *im = purple_conversation_get_im_data(conv);
-        if(im && song)
-            purple_conv_im_send(im, song);
+        if(im && msg)
+            purple_conv_im_send(im, msg);
     }
 
-    g_free(song);
+    g_free(msg);
     return PURPLE_CMD_RET_OK;
 }
 
@@ -720,8 +729,9 @@
 
     /* register /song command */
     cmdid_paste_current_song =
-        purple_cmd_register("song", "", PURPLE_CMD_P_DEFAULT,
-                            PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT,
+        purple_cmd_register("song", "s", PURPLE_CMD_P_DEFAULT,
+                            PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT |
+                            PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS,
                             NULL, paste_current_song,
                             "song: Paste currently plaing song", NULL);