grim/pidgin

5e089a52b01b
Parents 4da996236e9b
Children 4db28449567d
Move the ProtocolActionInterface to action.[ch]
--- a/libpurple/action.c Thu Feb 01 22:33:16 2018 -0600
+++ b/libpurple/action.c Thu Feb 01 23:21:30 2018 -0600
@@ -124,3 +124,42 @@
return act->stock_icon;
}
+/******************************************************************************
+ * Protocol Action API
+ *****************************************************************************/
+PurpleProtocolAction *
+purple_protocol_action_new(const gchar* label, PurpleProtocolActionCallback callback) {
+ PurpleProtocolAction *action;
+
+ g_return_val_if_fail(label != NULL, NULL);
+ g_return_val_if_fail(callback != NULL, NULL);
+
+ action = g_new0(PurpleProtocolAction, 1);
+
+ action->label = g_strdup(label);
+ action->callback = callback;
+
+ return action;
+}
+
+void
+purple_protocol_action_free(PurpleProtocolAction *action) {
+ g_return_if_fail(action != NULL);
+
+ g_free(action->label);
+ g_free(action);
+}
+
+static PurpleProtocolAction *
+purple_protocol_action_copy(PurpleProtocolAction *action) {
+ g_return_val_if_fail(action != NULL, NULL);
+
+ return purple_protocol_action_new(action->label, action->callback);
+}
+
+G_DEFINE_BOXED_TYPE(
+ PurpleProtocolAction,
+ purple_protocol_action,
+ purple_protocol_action_copy,
+ purple_protocol_action_free
+);
--- a/libpurple/action.h Thu Feb 01 22:33:16 2018 -0600
+++ b/libpurple/action.h Thu Feb 01 23:21:30 2018 -0600
@@ -25,6 +25,13 @@
#include <glib.h>
#include <glib-object.h>
+
+#define PURPLE_TYPE_PROTOCOL_ACTION (purple_protocol_action_get_type())
+
+typedef struct _PurpleProtocolAction PurpleProtocolAction;
+
+typedef void (*PurpleProtocolActionCallback)(PurpleProtocolAction *action);
+
/**
* PurpleMenuAction:
*
@@ -34,8 +41,27 @@
*/
typedef struct _PurpleMenuAction PurpleMenuAction;
+#include "connection.h"
+
+/**
+ * PurpleProtocolAction:
+ *
+ * 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;
+ PurpleConnection *connection;
+ gpointer user_data;
+};
+
G_BEGIN_DECLS
+/******************************************************************************
+ * Menu Action API
+ *****************************************************************************/
+
/**
* purple_menu_action_new:
* @label: The text label to display for this action.
@@ -154,6 +180,37 @@
*/
const gchar *purple_menu_action_get_stock_icon(PurpleMenuAction *act);
+/******************************************************************************
+ * Protocol Action API
+ *****************************************************************************/
+
+/**
+ * purple_protocol_action_get_type:
+ *
+ * Returns: The #GType for the #PurpleProtocolAction boxed structure.
+ */
+GType purple_protocol_action_get_type(void);
+
+/**
+ * purple_protocol_action_new:
+ * @label: The description of the action to show to the user.
+ * @callback: (scope call): The callback to call when the user selects this
+ * action.
+ *
+ * Allocates and returns a new PurpleProtocolAction. Use this to add actions in
+ * a list in the get_actions function of the protocol.
+ */
+PurpleProtocolAction *purple_protocol_action_new(const gchar *label, PurpleProtocolActionCallback callback);
+
+/**
+ * purple_protocol_action_free:
+ * @action: The PurpleProtocolAction to free.
+ *
+ * Frees a PurpleProtocolAction
+ */
+void purple_protocol_action_free(PurpleProtocolAction *action);
+
+
G_END_DECLS
-#endif /* PURPLE_ACTION */
\ No newline at end of file
+#endif /* PURPLE_ACTION */
--- a/libpurple/protocols.c Thu Feb 01 22:33:16 2018 -0600
+++ b/libpurple/protocols.c Thu Feb 01 23:21:30 2018 -0600
@@ -538,61 +538,6 @@
return purple_protocol_client_iface_get_max_message_size(protocol, NULL);
}
-/**************************************************************************/
-/* Protocol Action API */
-/**************************************************************************/
-
-PurpleProtocolAction *
-purple_protocol_action_new(const char* label,
- PurpleProtocolActionCallback callback)
-{
- PurpleProtocolAction *action;
-
- g_return_val_if_fail(label != NULL && callback != NULL, NULL);
-
- action = g_new0(PurpleProtocolAction, 1);
-
- action->label = g_strdup(label);
- action->callback = callback;
-
- return action;
-}
-
-void
-purple_protocol_action_free(PurpleProtocolAction *action)
-{
- g_return_if_fail(action != NULL);
-
- g_free(action->label);
- g_free(action);
-}
-
-/**************************************************************************
- * GBoxed code for PurpleProtocolAction
- **************************************************************************/
-
-static PurpleProtocolAction *
-purple_protocol_action_copy(PurpleProtocolAction *action)
-{
- g_return_val_if_fail(action != NULL, NULL);
-
- return purple_protocol_action_new(action->label, action->callback);
-}
-
-GType
-purple_protocol_action_get_type(void)
-{
- static GType type = 0;
-
- if (type == 0) {
- type = g_boxed_type_register_static("PurpleProtocolAction",
- (GBoxedCopyFunc)purple_protocol_action_copy,
- (GBoxedFreeFunc)purple_protocol_action_free);
- }
-
- return type;
-}
-
/**************************************************************************
* Protocols API
**************************************************************************/
--- a/libpurple/protocols.h Thu Feb 01 22:33:16 2018 -0600
+++ b/libpurple/protocols.h Thu Feb 01 23:21:30 2018 -0600
@@ -31,11 +31,6 @@
#define PURPLE_PROTOCOLS_DOMAIN (g_quark_from_static_string("protocols"))
-#define PURPLE_TYPE_PROTOCOL_ACTION (purple_protocol_action_get_type())
-
-typedef struct _PurpleProtocolAction PurpleProtocolAction;
-typedef void (*PurpleProtocolActionCallback)(PurpleProtocolAction *action);
-
/**************************************************************************/
/* Basic Protocol Information */
/**************************************************************************/
@@ -128,19 +123,6 @@
gboolean secret;
};
-/**
- * PurpleProtocolAction:
- *
- * 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;
- PurpleConnection *connection;
- gpointer user_data;
-};
-
G_BEGIN_DECLS
/**************************************************************************/
@@ -148,37 +130,6 @@
/**************************************************************************/
/**************************************************************************/
-/* Protocol Action API */
-/**************************************************************************/
-
-/**
- * purple_protocol_action_get_type:
- *
- * Returns: The #GType for the #PurpleProtocolAction boxed structure.
- */
-GType purple_protocol_action_get_type(void);
-
-/**
- * purple_protocol_action_new:
- * @label: The description of the action to show to the user.
- * @callback: (scope call): The callback to call when the user selects this
- * action.
- *
- * Allocates and returns a new PurpleProtocolAction. Use this to add actions in
- * a list in the get_actions function of the protocol.
- */
-PurpleProtocolAction *purple_protocol_action_new(const char* label,
- PurpleProtocolActionCallback callback);
-
-/**
- * purple_protocol_action_free:
- * @action: The PurpleProtocolAction to free.
- *
- * Frees a PurpleProtocolAction
- */
-void purple_protocol_action_free(PurpleProtocolAction *action);
-
-/**************************************************************************/
/* Protocol Chat Entry API */
/**************************************************************************/
--- a/libpurple/protocols/gg/gg.c Thu Feb 01 22:33:16 2018 -0600
+++ b/libpurple/protocols/gg/gg.c Thu Feb 01 23:21:30 2018 -0600
@@ -28,6 +28,7 @@
#include <internal.h>
+#include "action.h"
#include "plugins.h"
#include "version.h"
#include "notify.h"
--- a/libpurple/protocols/irc/irc.c Thu Feb 01 22:33:16 2018 -0600
+++ b/libpurple/protocols/irc/irc.c Thu Feb 01 23:21:30 2018 -0600
@@ -26,6 +26,7 @@
#include "internal.h"
#include "accountopt.h"
+#include "action.h"
#include "buddylist.h"
#include "conversation.h"
#include "core.h"
--- a/libpurple/protocols/jabber/buddy.h Thu Feb 01 22:33:16 2018 -0600
+++ b/libpurple/protocols/jabber/buddy.h Thu Feb 01 23:21:30 2018 -0600
@@ -26,6 +26,8 @@
typedef struct _JabberBuddy JabberBuddy;
+#include "action.h"
+
#include "jabber.h"
#include "caps.h"
#include "jutil.h"
--- a/libpurple/protocols/zephyr/zephyr.c Thu Feb 01 22:33:16 2018 -0600
+++ b/libpurple/protocols/zephyr/zephyr.c Thu Feb 01 23:21:30 2018 -0600
@@ -29,6 +29,7 @@
#include "libpurple/internal.h"
#include "accountopt.h"
+#include "action.h"
#include "debug.h"
#include "notify.h"
#include "plugins.h"