/soc/2013/ankitkv/gobjectification: 207c2716f0a8: Added struct P...

Ankit Vani a at nevitus.org
Wed Jul 31 11:35:52 EDT 2013


Changeset: 207c2716f0a88ca711a65bd994548c36b18f24eb
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-07-31 21:05 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/207c2716f0a8

Description:

Added struct PurpleProtocolAction, and purple_protocol_actions_add().
This API needs a sanity check. Will get to it when I start with protocols.

diffstat:

 libpurple/prpl.c |  21 +++++++++++++++++++++
 libpurple/prpl.h |  33 +++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+), 0 deletions(-)

diffs (95 lines):

diff --git a/libpurple/prpl.c b/libpurple/prpl.c
--- a/libpurple/prpl.c
+++ b/libpurple/prpl.c
@@ -620,6 +620,27 @@ purple_prpl_got_media_caps(PurpleAccount
 }
 
 /**************************************************************************
+ * Protocol actions API
+ **************************************************************************/
+
+void
+purple_protocol_actions_add(PurplePluginProtocolInfo *prpl_info,
+		const char* label, PurpleProtocolActionCallback callback)
+{
+	PurpleProtocolAction *action;
+
+	g_return_if_fail(prpl_info != NULL);
+	g_return_if_fail(label != NULL && callback != NULL);
+
+	action = g_new0(PurpleProtocolAction, 1);
+
+	action->label    = g_strdup(label);
+	action->callback = callback;
+
+	prpl_info->actions = g_list_append(prpl_info->actions, action);
+}
+
+/**************************************************************************
  * Protocols API
  **************************************************************************/
 
diff --git a/libpurple/prpl.h b/libpurple/prpl.h
--- a/libpurple/prpl.h
+++ b/libpurple/prpl.h
@@ -32,6 +32,10 @@
 
 typedef struct _PurplePluginProtocolInfo PurplePluginProtocolInfo;
 
+typedef struct _PurpleProtocolAction PurpleProtocolAction;
+
+typedef void (*PurpleProtocolActionCallback)(PurplePluginProtocolInfo *);
+
 /** Represents "nudges" and "buzzes" that you may send to a buddy to attract
  *  their attention (or vice-versa).
  */
@@ -210,6 +214,15 @@ typedef enum
 } PurpleProtocolOptions;
 
 /**
+ * Represents an action that the protocol can perform. This shows up in the
+ * Accounts menu, under a submenu with the name of the account.
+ */
+struct _PurpleProtocolAction {
+	char *label;
+	PurpleProtocolActionCallback callback;
+};
+
+/**
  * A protocol plugin information structure.
  *
  * Every protocol plugin initializes this structure. It is the gateway
@@ -222,6 +235,11 @@ struct _PurplePluginProtocolInfo
 	const char *name;
 
 	/**
+	 * Actions that the protocol can perform
+	 */
+	GList *actions;
+
+	/**
 	 * The size of the PurplePluginProtocolInfo. This should always be sizeof(PurplePluginProtocolInfo).
 	 * This allows adding more functions to this struct without requiring a major version bump.
 	 */
@@ -952,6 +970,21 @@ void purple_prpl_got_media_caps(PurpleAc
 /*@}*/
 
 /**************************************************************************/
+/** @name Protocol actions API                                            */
+/**************************************************************************/
+/*@{*/
+
+/** TODO A sanity check is needed
+ * Adds a new action to a protocol.
+ *
+ * @param prpl_info The protocol to add the action to.
+ * @param label     The description of the action to show to the user.
+ * @param callback  The callback to call when the user selects this action.
+ */
+void purple_protocol_actions_add(PurplePluginProtocolInfo *prpl_info,
+		const char* label, PurpleProtocolActionCallback callback);
+
+/**************************************************************************/
 /** @name Protocols API                                                   */
 /**************************************************************************/
 /*@{*/



More information about the Commits mailing list