cpw.darkrain42.xmpp.disco: a608b289: Use per-PurpleDiscoList ops for cancelin...
paul at darkrain42.org
paul at darkrain42.org
Sat Apr 25 16:17:19 EDT 2009
-----------------------------------------------------------------
Revision: a608b28986dd3a82d6119e4f91bb2b9f2e89a239
Ancestor: 8a1d6af7146c2965c92cdb026c6f0e1e61eb9156
Author: paul at darkrain42.org
Date: 2009-04-11T21:46:12
Branch: im.pidgin.cpw.darkrain42.xmpp.disco
URL: http://d.pidgin.im/viewmtn/revision/info/a608b28986dd3a82d6119e4f91bb2b9f2e89a239
Modified files:
libpurple/dbus-analyze-functions.py libpurple/disco.c
libpurple/disco.h libpurple/protocols/jabber/disco.c
libpurple/protocols/jabber/disco.h
libpurple/protocols/jabber/libxmpp.c libpurple/prpl.h
ChangeLog:
Use per-PurpleDiscoList ops for canceling a disco and registering.
-------------- next part --------------
============================================================
--- libpurple/dbus-analyze-functions.py 02b0f76555acbe1f7b7729bbc17bd78698d2ffa7
+++ libpurple/dbus-analyze-functions.py b876a425ce36b6c945aba7b1f87ad3d751beb9f2
@@ -31,6 +31,11 @@ excluded = [\
"purple_account_unregister",
"purple_connection_new_unregister",
+ # Similar to all the above:
+ "purple_disco_list_set_cancel_func",
+ "purple_disco_list_set_protocol_data",
+ "purple_disco_list_set_register_func",
+
# This is excluded because this script treats PurpleLogReadFlags*
# as pointer to a struct, instead of a pointer to an enum. This
# causes a compilation error. Someone should fix this script.
============================================================
--- libpurple/disco.c d2370d0a3a4c958aee998f0231bdb227c72acfe6
+++ libpurple/disco.c b78fc9bc58fe00b8dd9ce7899902091782a49253
@@ -44,8 +44,13 @@ struct _PurpleDiscoList {
gpointer ui_data; /**< UI private data. */
gpointer proto_data; /**< Prpl private data. */
- PurpleDiscoCloseCallback close_cb; /**< Callback to free the prpl data */
guint ref; /**< The reference count. */
+
+ struct {
+ PurpleDiscoCancelFunc cancel_cb;
+ PurpleDiscoCloseFunc close_cb; /**< Callback to free the prpl data */
+ PurpleDiscoRegisterFunc register_cb;
+ } ops;
};
/**
@@ -106,8 +111,8 @@ static void purple_disco_list_destroy(Pu
if (ops && ops->destroy)
ops->destroy(list);
- if (list->close_cb)
- list->close_cb(list);
+ if (list->ops.close_cb)
+ list->ops.close_cb(list);
for (l = list->services; l; l = l->next) {
PurpleDiscoService *s = l->data;
@@ -178,47 +183,28 @@ void purple_disco_cancel_get_list(Purple
void purple_disco_cancel_get_list(PurpleDiscoList *list)
{
- PurplePlugin *prpl = NULL;
- PurplePluginProtocolInfo *prpl_info = NULL;
- PurpleConnection *gc;
-
g_return_if_fail(list != NULL);
- gc = purple_account_get_connection(list->account);
+ if (list->ops.cancel_cb)
+ list->ops.cancel_cb(list);
- g_return_if_fail(gc != NULL);
-
- if (gc)
- prpl = purple_connection_get_prpl(gc);
-
- if (prpl)
- prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
-
- if (prpl_info && PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, disco_cancel))
- prpl_info->disco_cancel(list);
-
purple_disco_list_set_in_progress(list, FALSE);
}
void purple_disco_service_register(PurpleDiscoService *service)
{
+ PurpleDiscoList *list;
PurpleConnection *pc;
- PurplePlugin *prpl = NULL;
- PurplePluginProtocolInfo *prpl_info = NULL;
g_return_if_fail(service != NULL);
-
- pc = purple_account_get_connection(service->list->account);
- g_return_if_fail(pc != NULL);
+ list = service->list;
+ pc = purple_account_get_connection(list->account);
- prpl = purple_connection_get_prpl(pc);
+ g_return_if_fail(pc != NULL);
- if (prpl != NULL)
- prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
-
- if (prpl_info && PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, disco_service_register))
- prpl_info->disco_service_register(pc, service);
+ if (list->ops.register_cb)
+ list->ops.register_cb(pc, service);
}
const gchar *purple_disco_service_get_name(PurpleDiscoService *service)
@@ -314,12 +300,12 @@ void purple_disco_list_set_protocol_data
void purple_disco_list_set_protocol_data(PurpleDiscoList *list,
gpointer proto_data,
- PurpleDiscoCloseCallback cb)
+ PurpleDiscoCloseFunc cb)
{
g_return_if_fail(list != NULL);
- list->proto_data = proto_data;
- list->close_cb = cb;
+ list->proto_data = proto_data;
+ list->ops.close_cb = cb;
}
gpointer purple_disco_list_get_protocol_data(PurpleDiscoList *list)
============================================================
--- libpurple/disco.h 903ebee25357ea8b6a5c5f3c62996953471a143a
+++ libpurple/disco.h 13f58bd606abb6765b67bb53dea4fabc7ebcb289
@@ -33,13 +33,38 @@ typedef struct _PurpleDiscoUiOps PurpleD
typedef struct _PurpleDiscoUiOps PurpleDiscoUiOps;
#include "account.h"
+#include "connection.h"
/**
+ * A prpl callback called to tell the prpl to cancel creating the list.
+ * The prpl must implement this and must not add services to the
+ * PurpleDiscoList after this is called.
*
+ * @param list The disco list.
*/
-typedef void (*PurpleDiscoCloseCallback) (PurpleDiscoList *list);
+typedef void (*PurpleDiscoCancelFunc)(PurpleDiscoList *list);
/**
+ * A prpl callback called to tell the prpl to tell it to destroy
+ * prpl-specific data relating to this PurpleDiscoList (which will be
+ * destroyed imminently).
+ *
+ * @param list The disco list.
+ */
+typedef void (*PurpleDiscoCloseFunc)(PurpleDiscoList *list);
+
+/**
+ * A prpl callback called to initiate registration with the specificed
+ * service.
+ *
+ * @param pc The connection.
+ * @param service The service to which to register.
+ *
+ */
+typedef void (*PurpleDiscoRegisterFunc)(PurpleConnection *pc,
+ PurpleDiscoService *service);
+
+/**
* The types of services.
*/
typedef enum
@@ -310,7 +335,7 @@ void purple_disco_list_set_protocol_data
* @since TODO
*/
void purple_disco_list_set_protocol_data(PurpleDiscoList *list, gpointer data,
- PurpleDiscoCloseCallback cb);
+ PurpleDiscoCloseFunc cb);
/**
* Returns the disco list's protocol-specific data.
@@ -325,6 +350,9 @@ gpointer purple_disco_list_get_protocol_
*/
gpointer purple_disco_list_get_protocol_data(PurpleDiscoList *list);
+void purple_disco_list_set_cancel_func(PurpleDiscoList *list, PurpleDiscoCancelFunc cb);
+void purple_disco_list_set_register_func(PurpleDiscoList *list, PurpleDiscoRegisterFunc cb);
+
/**
* Sets the UI operations structure to be used in all purple service discovery.
*
============================================================
--- libpurple/protocols/jabber/disco.c a9cd8c4d49dc9f2b1bccd336ac02d0eeb016dfeb
+++ libpurple/protocols/jabber/disco.c 80a0c8afbec055a1793e0e092b63b6ac11fccee8
@@ -957,6 +957,36 @@ static void discolist_ok_cb(struct jabbe
jabber_disco_info_do(js, list_data->server, jabber_disco_server_info_cb, list_data);
}
+static void
+jabber_disco_cancel(PurpleDiscoList *list)
+{
+ struct jabber_disco_list_data *list_data = purple_disco_list_get_protocol_data(list);
+ purple_disco_list_set_protocol_data(list, NULL, NULL);
+
+ if (list_data->fetch_count == 0) {
+ /* Nothing outstanding, just free it now... */
+ jabber_disco_list_data_destroy(list_data);
+ } else {
+ int i;
+ /* Lose all our references to the PurpleDiscoList */
+ for (i = 0; i < list_data->fetch_count; ++i) {
+ purple_disco_list_unref(list);
+ }
+
+ /* We'll free list_data when fetch_count is down to 0 */
+ list_data->list = NULL;
+ }
+}
+
+static void
+jabber_disco_service_register(PurpleConnection *gc, PurpleDiscoService *service)
+{
+ JabberStream *js = purple_connection_get_protocol_data(gc);
+
+ jabber_register_gateway(js, purple_disco_service_get_name(service));
+}
+
+
PurpleDiscoList *
jabber_disco_get_list(PurpleConnection *gc)
{
@@ -975,6 +1005,8 @@ jabber_disco_get_list(PurpleConnection *
disco_list_data->list = list;
disco_list_data->js = js;
purple_disco_list_set_protocol_data(list, disco_list_data, disco_proto_data_destroy_cb);
+ purple_disco_list_set_cancel_func(list, jabber_disco_cancel);
+ purple_disco_list_set_register_func(list, jabber_disco_service_register);
purple_request_input(gc, _("Server name request"), _("Enter an XMPP Server"),
_("Select an XMPP server to query"),
@@ -987,37 +1019,6 @@ jabber_disco_get_list(PurpleConnection *
return list;
}
-void
-jabber_disco_cancel(PurpleDiscoList *list)
-{
- struct jabber_disco_list_data *list_data = purple_disco_list_get_protocol_data(list);
- purple_disco_list_set_protocol_data(list, NULL, NULL);
-
- if (list_data->fetch_count == 0) {
- /* Nothing outstanding, just free it now... */
- jabber_disco_list_data_destroy(list_data);
- } else {
- int i;
- /* Lose all our references to the PurpleDiscoList */
- for (i = 0; i < list_data->fetch_count; ++i) {
- purple_disco_list_unref(list);
- }
-
- /* We'll free list_data when fetch_count is down to 0 */
- list_data->list = NULL;
- }
-}
-
-int
-jabber_disco_service_register(PurpleConnection *gc, PurpleDiscoService *service)
-{
- JabberStream *js = purple_connection_get_protocol_data(gc);
-
- jabber_register_gateway(js, purple_disco_service_get_name(service));
-
- return 0;
-}
-
static void
jabber_disco_items_cb(JabberStream *js, const char *from, JabberIqType type,
const char *id, xmlnode *packet, gpointer data)
============================================================
--- libpurple/protocols/jabber/disco.h 32d67b3d08f356fc019a0f0b2be24a0c4df0f91c
+++ libpurple/protocols/jabber/disco.h 44429b3468bdcd156a0323a05c4cccf21ea851ad
@@ -47,11 +47,7 @@ PurpleDiscoList *jabber_disco_get_list(P
JabberDiscoInfoCallback *callback, gpointer data);
PurpleDiscoList *jabber_disco_get_list(PurpleConnection *gc);
-void jabber_disco_cancel(PurpleDiscoList *list);
-int jabber_disco_service_register(PurpleConnection *gc, PurpleDiscoService *service);
-
-
void jabber_disco_items_do(JabberStream *js, const char *jid, const char *node,
JabberDiscoItemsCallback *callback, gpointer data);
void jabber_disco_item_free(JabberDiscoItem *);
============================================================
--- libpurple/protocols/jabber/libxmpp.c 7feefc5cf0dc1f79b02a4e3243b86540dd43f1e8
+++ libpurple/protocols/jabber/libxmpp.c c07ecb186ccfdecf5263e3b64859aba57517fae3
@@ -124,8 +124,6 @@ static PurplePluginProtocolInfo prpl_inf
jabber_initiate_media, /* initiate_media */
jabber_get_media_caps, /* get_media_caps */
jabber_disco_get_list, /* disco_get_list */
- jabber_disco_cancel, /* disco_cancel */
- jabber_disco_service_register /* disco_service_register */
};
static gboolean load_plugin(PurplePlugin *plugin)
============================================================
--- libpurple/prpl.h 8074cecf021e92c38422b59e1da03dbc37174b24
+++ libpurple/prpl.h 9fdfe639f6a2c5ca733e7fb342e339583cfd5a78
@@ -487,16 +487,6 @@ struct _PurplePluginProtocolInfo
* Service discovery prpl callbacks
*/
PurpleDiscoList *(*disco_get_list)(PurpleConnection *gc);
-
- /**
- * Cancel fetching service list
- */
- void (*disco_cancel)(PurpleDiscoList *list);
-
- /**
- * Register service
- */
- int (*disco_service_register)(PurpleConnection *gc, PurpleDiscoService *service);
};
#define PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl, member) \
More information about the Commits
mailing list