summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Kramlich <grim@reaperworld.com>2018-02-01 23:21:30 -0600
committerGary Kramlich <grim@reaperworld.com>2018-02-01 23:21:30 -0600
commitef05f992cedbe39a6d55576962be92b82019f5ae (patch)
tree036d439bbb9d7c11ac3b3590c68e8c24278eec21
parent16a065ff9ed5078e46d564a962a84a4224650095 (diff)
downloadpidgin-ef05f992cedbe39a6d55576962be92b82019f5ae.tar.gz
Move the ProtocolActionInterface to action.[ch]
-rw-r--r--libpurple/action.c39
-rw-r--r--libpurple/action.h59
-rw-r--r--libpurple/protocols.c55
-rw-r--r--libpurple/protocols.h49
-rw-r--r--libpurple/protocols/gg/gg.c1
-rw-r--r--libpurple/protocols/irc/irc.c1
-rw-r--r--libpurple/protocols/jabber/buddy.h2
-rw-r--r--libpurple/protocols/zephyr/zephyr.c1
8 files changed, 102 insertions, 105 deletions
diff --git a/libpurple/action.c b/libpurple/action.c
index 2dcf084f05..0dfcf3cd81 100644
--- a/libpurple/action.c
+++ b/libpurple/action.c
@@ -124,3 +124,42 @@ purple_menu_action_get_stock_icon(PurpleMenuAction *act) {
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
+);
diff --git a/libpurple/action.h b/libpurple/action.h
index 58a2a8444f..9f51912d69 100644
--- a/libpurple/action.h
+++ b/libpurple/action.h
@@ -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 @@ void purple_menu_action_set_stock_icon(PurpleMenuAction *act, const gchar *stock
*/
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 */
diff --git a/libpurple/protocols.c b/libpurple/protocols.c
index 7a14721707..2b99da64ac 100644
--- a/libpurple/protocols.c
+++ b/libpurple/protocols.c
@@ -538,61 +538,6 @@ purple_protocol_get_max_message_size(PurpleProtocol *protocol)
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
**************************************************************************/
diff --git a/libpurple/protocols.h b/libpurple/protocols.h
index 81c314e1a8..eb01f627ae 100644
--- a/libpurple/protocols.h
+++ b/libpurple/protocols.h
@@ -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 @@ struct _PurpleProtocolChatEntry {
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 @@ G_BEGIN_DECLS
/**************************************************************************/
/**************************************************************************/
-/* 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 */
/**************************************************************************/
diff --git a/libpurple/protocols/gg/gg.c b/libpurple/protocols/gg/gg.c
index b06b10c2b1..f1635f8760 100644
--- a/libpurple/protocols/gg/gg.c
+++ b/libpurple/protocols/gg/gg.c
@@ -28,6 +28,7 @@
#include <internal.h>
+#include "action.h"
#include "plugins.h"
#include "version.h"
#include "notify.h"
diff --git a/libpurple/protocols/irc/irc.c b/libpurple/protocols/irc/irc.c
index 7c13dc2432..b81109e5cc 100644
--- a/libpurple/protocols/irc/irc.c
+++ b/libpurple/protocols/irc/irc.c
@@ -26,6 +26,7 @@
#include "internal.h"
#include "accountopt.h"
+#include "action.h"
#include "buddylist.h"
#include "conversation.h"
#include "core.h"
diff --git a/libpurple/protocols/jabber/buddy.h b/libpurple/protocols/jabber/buddy.h
index 268275f204..e60e7dd38f 100644
--- a/libpurple/protocols/jabber/buddy.h
+++ b/libpurple/protocols/jabber/buddy.h
@@ -26,6 +26,8 @@
typedef struct _JabberBuddy JabberBuddy;
+#include "action.h"
+
#include "jabber.h"
#include "caps.h"
#include "jutil.h"
diff --git a/libpurple/protocols/zephyr/zephyr.c b/libpurple/protocols/zephyr/zephyr.c
index c5df24de54..f9f42f94e3 100644
--- a/libpurple/protocols/zephyr/zephyr.c
+++ b/libpurple/protocols/zephyr/zephyr.c
@@ -29,6 +29,7 @@
#include "libpurple/internal.h"
#include "accountopt.h"
+#include "action.h"
#include "debug.h"
#include "notify.h"
#include "plugins.h"