summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSiraj Razick <siraj.razick@collabora.co.uk>2012-01-06 16:32:47 -0500
committerSiraj Razick <siraj.razick@collabora.co.uk>2012-01-20 15:07:07 -0500
commit9ee76cdc02c550850c8490ddc97dc0c0fa24c38a (patch)
tree720684ea3b631d2c697765a4fcffe4c8adb7de25
parent035a6b0a6e8ce1787abf2583bb918436282026fe (diff)
downloadtelepathy-gabble-9ee76cdc02c550850c8490ddc97dc0c0fa24c38a.tar.gz
Change the plugin API to create_sidecar_async and create_sidecar_finish
All gabble plugins should implement these two methods hereafter. This patch also updates all the internal plugins to use this new API https://bugs.freedesktop.org/show_bug.cgi?id=44331
-rw-r--r--NEWS6
-rw-r--r--gabble/plugin.h16
-rw-r--r--plugins/console.c31
-rw-r--r--plugins/gateways.c31
-rw-r--r--plugins/test.c33
-rw-r--r--src/plugin-loader.c2
-rw-r--r--src/plugin.c24
7 files changed, 113 insertions, 30 deletions
diff --git a/NEWS b/NEWS
index 6810989f4..29cca3e92 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,12 @@ Enhancements:
* fd.o#41790 - Make file transfer support optional (andrunko)
+* fd.o#44331 - Gabble plugin API symbols should be factored out to a separate library :
+ gabble_plugin_create_sidecar function is renamed to gabble_plugin_create_sidecar_async
+ and new virtual function gabble_plugin_create_sidecar_finish is introduced. All gabble
+ plugins should implement these two methods and all internal plugins are updated to use
+ this new API.
+
telepathy-gabble 0.15.3 (2011-12-22)
====================================
diff --git a/gabble/plugin.h b/gabble/plugin.h
index 6da99f136..ffb888c29 100644
--- a/gabble/plugin.h
+++ b/gabble/plugin.h
@@ -60,6 +60,11 @@ typedef GPtrArray * (*GabblePluginCreateChannelManagersImpl) (
GabblePlugin *plugin,
TpBaseConnection *connection);
+typedef GabbleSidecar * (*GabblePluginCreateSidecarFinishImpl) (
+ GabblePlugin *plugin,
+ GAsyncResult *result,
+ GError **error);
+
struct _GabblePluginPrivacyListMap {
const gchar *presence_status_name;
const gchar *privacy_list_name;
@@ -81,9 +86,14 @@ struct _GabblePluginInterface {
const gchar * const *sidecar_interfaces;
/**
- * An implementation of gabble_plugin_create_sidecar().
+ * An implementation of gabble_plugin_create_sidecar_async().
+ */
+ GabblePluginCreateSidecarImpl create_sidecar_async;
+
+ /**
+ * An implementation of gabble_plugin_create_sidecar_finish().
*/
- GabblePluginCreateSidecarImpl create_sidecar;
+ GabblePluginCreateSidecarFinishImpl create_sidecar_finish;
/**
* The plugin's version, conventionally a "."-separated sequence of
@@ -120,7 +130,7 @@ gboolean gabble_plugin_implements_sidecar (
GabblePlugin *plugin,
const gchar *sidecar_interface);
-void gabble_plugin_create_sidecar (
+void gabble_plugin_create_sidecar_async (
GabblePlugin *plugin,
const gchar *sidecar_interface,
GabbleConnection *connection,
diff --git a/plugins/console.c b/plugins/console.c
index 13ca0eccf..b0ba7c592 100644
--- a/plugins/console.c
+++ b/plugins/console.c
@@ -77,7 +77,7 @@ gabble_console_plugin_class_init (GabbleConsolePluginClass *klass)
}
static void
-gabble_console_plugin_create_sidecar (
+gabble_console_plugin_create_sidecar_async (
GabblePlugin *plugin,
const gchar *sidecar_interface,
GabbleConnection *connection,
@@ -87,10 +87,7 @@ gabble_console_plugin_create_sidecar (
{
GSimpleAsyncResult *result = g_simple_async_result_new (G_OBJECT (plugin),
callback, user_data,
- /* sic: all plugins share gabble_plugin_create_sidecar_finish() so we
- * need to use the same source tag.
- */
- gabble_plugin_create_sidecar);
+ gabble_console_plugin_create_sidecar_async);
GabbleSidecar *sidecar = NULL;
if (!tp_strdiff (sidecar_interface, GABBLE_IFACE_GABBLE_PLUGIN_CONSOLE))
@@ -114,6 +111,27 @@ gabble_console_plugin_create_sidecar (
g_object_unref (result);
}
+static GabbleSidecar *
+gabble_console_plugin_create_sidecar_finish (
+ GabblePlugin *plugin,
+ GAsyncResult *result,
+ GError **error)
+{
+ GabbleSidecar *sidecar;
+
+ if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
+ error))
+ return NULL;
+
+ g_return_val_if_fail (g_simple_async_result_is_valid (result,
+ G_OBJECT (plugin), gabble_console_plugin_create_sidecar_async), NULL);
+
+ sidecar = GABBLE_SIDECAR (g_simple_async_result_get_op_res_gpointer (
+ G_SIMPLE_ASYNC_RESULT (result)));
+
+ return g_object_ref (sidecar);
+}
+
static void
plugin_iface_init (
gpointer g_iface,
@@ -124,7 +142,8 @@ plugin_iface_init (
iface->name = "XMPP console";
iface->version = PACKAGE_VERSION;
iface->sidecar_interfaces = sidecar_interfaces;
- iface->create_sidecar = gabble_console_plugin_create_sidecar;
+ iface->create_sidecar_async = gabble_console_plugin_create_sidecar_async;
+ iface->create_sidecar_finish = gabble_console_plugin_create_sidecar_finish;
}
GabblePlugin *
diff --git a/plugins/gateways.c b/plugins/gateways.c
index 88a32223f..1e7b141a2 100644
--- a/plugins/gateways.c
+++ b/plugins/gateways.c
@@ -75,7 +75,7 @@ gabble_gateway_plugin_class_init (GabbleGatewayPluginClass *klass)
}
static void
-gabble_gateway_plugin_create_sidecar (
+gabble_gateway_plugin_create_sidecar_async (
GabblePlugin *plugin,
const gchar *sidecar_interface,
GabbleConnection *connection,
@@ -85,10 +85,7 @@ gabble_gateway_plugin_create_sidecar (
{
GSimpleAsyncResult *result = g_simple_async_result_new (G_OBJECT (plugin),
callback, user_data,
- /* sic: all plugins share gabble_plugin_create_sidecar_finish() so we
- * need to use the same source tag.
- */
- gabble_plugin_create_sidecar);
+ gabble_gateway_plugin_create_sidecar_async);
GabbleSidecar *sidecar = NULL;
if (!tp_strdiff (sidecar_interface, GABBLE_IFACE_GABBLE_PLUGIN_GATEWAYS))
@@ -112,6 +109,27 @@ gabble_gateway_plugin_create_sidecar (
g_object_unref (result);
}
+static GabbleSidecar *
+gabble_gateway_plugin_create_sidecar_finish (
+ GabblePlugin *plugin,
+ GAsyncResult *result,
+ GError **error)
+{
+ GabbleSidecar *sidecar;
+
+ if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
+ error))
+ return NULL;
+
+ g_return_val_if_fail (g_simple_async_result_is_valid (result,
+ G_OBJECT (plugin), gabble_gateway_plugin_create_sidecar_async), NULL);
+
+ sidecar = GABBLE_SIDECAR (g_simple_async_result_get_op_res_gpointer (
+ G_SIMPLE_ASYNC_RESULT (result)));
+
+ return g_object_ref (sidecar);
+}
+
static void
plugin_iface_init (
gpointer g_iface,
@@ -122,7 +140,8 @@ plugin_iface_init (
iface->name = "Gateway registration plugin";
iface->version = PACKAGE_VERSION;
iface->sidecar_interfaces = sidecar_interfaces;
- iface->create_sidecar = gabble_gateway_plugin_create_sidecar;
+ iface->create_sidecar_async = gabble_gateway_plugin_create_sidecar_async;
+ iface->create_sidecar_finish = gabble_gateway_plugin_create_sidecar_finish;
}
GabblePlugin *
diff --git a/plugins/test.c b/plugins/test.c
index 05d784052..43b18ea3b 100644
--- a/plugins/test.c
+++ b/plugins/test.c
@@ -80,7 +80,7 @@ sidecar_iq_created_cb (
}
static void
-test_plugin_create_sidecar (
+test_plugin_create_sidecar_async (
GabblePlugin *plugin,
const gchar *sidecar_interface,
GabbleConnection *connection,
@@ -90,10 +90,8 @@ test_plugin_create_sidecar (
{
GSimpleAsyncResult *result = g_simple_async_result_new (G_OBJECT (plugin),
callback, user_data,
- /* sic: all plugins share gabble_plugin_create_sidecar_finish() so we
- * need to use the same source tag.
- */
- gabble_plugin_create_sidecar);
+ test_plugin_create_sidecar_async);
+
GabbleSidecar *sidecar = NULL;
if (!tp_strdiff (sidecar_interface, IFACE_TEST))
@@ -124,9 +122,31 @@ test_plugin_create_sidecar (
g_simple_async_result_set_op_res_gpointer (result, sidecar, g_object_unref);
g_simple_async_result_complete_in_idle (result);
+
g_object_unref (result);
}
+static GabbleSidecar *
+test_plugin_create_sidecar_finish (
+ GabblePlugin *plugin,
+ GAsyncResult *result,
+ GError **error)
+{
+ GabbleSidecar *sidecar;
+
+ if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
+ error))
+ return NULL;
+
+ g_return_val_if_fail (g_simple_async_result_is_valid (result,
+ G_OBJECT (plugin), test_plugin_create_sidecar_async), NULL);
+
+ sidecar = GABBLE_SIDECAR (g_simple_async_result_get_op_res_gpointer (
+ G_SIMPLE_ASYNC_RESULT (result)));
+
+ return g_object_ref (sidecar);
+}
+
static GPtrArray *
test_plugin_create_channel_managers (GabblePlugin *plugin,
TpBaseConnection *connection)
@@ -164,7 +184,8 @@ plugin_iface_init (
iface->name = "Sidecar test plugin";
iface->version = PACKAGE_VERSION;
iface->sidecar_interfaces = sidecar_interfaces;
- iface->create_sidecar = test_plugin_create_sidecar;
+ iface->create_sidecar_async = test_plugin_create_sidecar_async;
+ iface->create_sidecar_finish = test_plugin_create_sidecar_finish;
iface->create_channel_managers = test_plugin_create_channel_managers;
iface->presence_statuses = test_presences;
diff --git a/src/plugin-loader.c b/src/plugin-loader.c
index 2568ff5db..7e016b899 100644
--- a/src/plugin-loader.c
+++ b/src/plugin-loader.c
@@ -290,7 +290,7 @@ gabble_plugin_loader_create_sidecar (
GSimpleAsyncResult *res = g_simple_async_result_new (G_OBJECT (self),
callback, user_data, gabble_plugin_loader_create_sidecar);
- gabble_plugin_create_sidecar (p, sidecar_interface, connection, session,
+ gabble_plugin_create_sidecar_async (p, sidecar_interface, connection, session,
create_sidecar_cb, res);
return;
}
diff --git a/src/plugin.c b/src/plugin.c
index 4f35de781..783e721a4 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -96,7 +96,7 @@ gabble_plugin_implements_sidecar (
* @user_data: data to pass to @callback
*/
void
-gabble_plugin_create_sidecar (
+gabble_plugin_create_sidecar_async (
GabblePlugin *plugin,
const gchar *sidecar_interface,
GabbleConnection *connection,
@@ -111,13 +111,18 @@ gabble_plugin_create_sidecar (
user_data, TP_ERRORS, TP_ERROR_NOT_IMPLEMENTED,
"Gabble is buggy: '%s' doesn't implement sidecar %s",
iface->name, sidecar_interface);
- else if (iface->create_sidecar == NULL)
+ else if (iface->create_sidecar_async == NULL)
g_simple_async_report_error_in_idle (G_OBJECT (plugin), callback,
user_data, TP_ERRORS, TP_ERROR_NOT_IMPLEMENTED,
"'%s' is buggy: it claims to implement %s, but does not implement "
- "create_sidecar", iface->name, sidecar_interface);
+ "create_sidecar_async", iface->name, sidecar_interface);
+ else if (iface->create_sidecar_finish == NULL)
+ g_simple_async_report_error_in_idle (G_OBJECT (plugin), callback,
+ user_data, TP_ERRORS, TP_ERROR_NOT_IMPLEMENTED,
+ "'%s' is buggy: does not imlement create_sidecar_finish",
+ iface->name);
else
- iface->create_sidecar (plugin, sidecar_interface, connection, session,
+ iface->create_sidecar_async (plugin, sidecar_interface, connection, session,
callback, user_data);
}
@@ -127,17 +132,20 @@ gabble_plugin_create_sidecar_finish (
GAsyncResult *result,
GError **error)
{
+ GabblePluginInterface *iface = GABBLE_PLUGIN_GET_INTERFACE (plugin);
GabbleSidecar *sidecar;
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
error))
return NULL;
- g_return_val_if_fail (g_simple_async_result_is_valid (result,
- G_OBJECT (plugin), gabble_plugin_create_sidecar), NULL);
+ if (iface->create_sidecar_finish == NULL) {
+ WARNING ("'%s' is buggy: does not implement create_sidecar_finish", iface->name);
+ return NULL;
+ }
+
+ sidecar = iface->create_sidecar_finish (plugin, result, error);
- sidecar = GABBLE_SIDECAR (g_simple_async_result_get_op_res_gpointer (
- G_SIMPLE_ASYNC_RESULT (result)));
return g_object_ref (sidecar);
}