changeset 17221:c9a046a7f326

New function purple_conversation_do_command. This is almost like purple_cmd_do_command, except it allows NULL for markup and error, and it's properly namespaced.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Tue, 22 May 2007 06:03:42 +0000
parents da2bab3b9fab
children 192be492ce25
files ChangeLog.API libpurple/conversation.c libpurple/conversation.h
diffstat 3 files changed, 24 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog.API	Tue May 22 03:28:12 2007 +0000
+++ b/ChangeLog.API	Tue May 22 06:03:42 2007 +0000
@@ -3,6 +3,7 @@
 version 2.1.0 (?/?/?):
 	Added:
 	* purple_conversation_get_extended_menu
+	* purple_conversation_do_command
 
 	Signals - Added: (See the Doxygen docs for details on all signals.)
 	* "conversation-extended-menu"
--- a/libpurple/conversation.c	Tue May 22 03:28:12 2007 +0000
+++ b/libpurple/conversation.c	Tue May 22 06:03:42 2007 +0000
@@ -21,6 +21,7 @@
  */
 #include "internal.h"
 #include "blist.h"
+#include "cmds.h"
 #include "conversation.h"
 #include "dbus-maybe.h"
 #include "debug.h"
@@ -2001,6 +2002,15 @@
 	return menu;
 }
 
+gboolean
+purple_conversation_do_command(PurpleConversation *conv, const gchar *cmdline,
+				const gchar *markup, gchar **error)
+{
+	char *mark = (markup && *markup) ? NULL : g_markup_escape_text(cmdline, -1), *err = NULL;
+	PurpleCmdStatus status = purple_cmd_do_command(conv, cmdline, mark ? mark : markup, error ? error : &err);
+	g_free(mark);
+	return (status == PURPLE_CMD_STATUS_OK);
+}
 
 void *
 purple_conversations_get_handle(void)
--- a/libpurple/conversation.h	Tue May 22 03:28:12 2007 +0000
+++ b/libpurple/conversation.h	Tue May 22 06:03:42 2007 +0000
@@ -1201,6 +1201,19 @@
  */
 GList * purple_conversation_get_extended_menu(PurpleConversation *conv);
 
+/**
+ * Perform a command in a conversation. Similar to @see purple_cmd_do_command
+ *
+ * @param conv    The conversation.
+ * @param cmdline The entire command including the arguments.
+ * @param markup  @c NULL, or the formatted command line.
+ * @param error   If the command failed errormsg is filled in with the appropriate error
+ *                message, if not @c NULL. It must be freed by the caller with g_free().
+ *
+ * @return  @c TRUE if the command was executed successfully, @c FALSE otherwise.
+ */
+gboolean purple_conversation_do_command(PurpleConversation *conv, const gchar *cmdline, const gchar *markup, gchar **error);
+
 /*@}*/
 
 /**************************************************************************/