summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 3ec5a16fb..f865f32c7 100644
--- a/NEWS
+++ b/NEWS
@@ -35,6 +35,12 @@ API changes to Wocky snapshot:
(This is similar to how GLib's headers are structured.) Out-of-tree
plugins will need to be updated. (Will)
+* 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 7c3b4743f..d608a5511 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 87a450bd1..d6ecb5018 100644
--- a/plugins/console.c
+++ b/plugins/console.c
@@ -73,7 +73,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,
@@ -83,10 +83,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))
@@ -110,6 +107,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,
@@ -120,7 +138,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 be08e6228..02e2f5844 100644
--- a/plugins/gateways.c
+++ b/plugins/gateways.c
@@ -73,7 +73,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,
@@ -83,10 +83,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))
@@ -110,6 +107,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,
@@ -120,7 +138,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 29c45a9e1..eca607940 100644
--- a/plugins/test.c
+++ b/plugins/test.c
@@ -79,7 +79,7 @@ sidecar_iq_created_cb (
}
static void
-test_plugin_create_sidecar (
+test_plugin_create_sidecar_async (
GabblePlugin *plugin,
const gchar *sidecar_interface,
GabbleConnection *connection,
@@ -89,10 +89,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))
@@ -123,9 +121,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)
@@ -163,7 +183,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);
}