diff options
author | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2011-03-15 14:39:22 +0000 |
---|---|---|
committer | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2011-03-15 14:39:22 +0000 |
commit | 459624a34cb65c30ede5887166d038d900b2216e (patch) | |
tree | 76075adb0960f8cc53d6db846077e3a6a2ef2200 /plugins | |
parent | 04c5ef4799db15e400bb407396c161e930ab2389 (diff) |
test plugin: add simple sidecar support
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/test.c | 79 | ||||
-rw-r--r-- | plugins/test.h | 33 |
2 files changed, 112 insertions, 0 deletions
diff --git a/plugins/test.c b/plugins/test.c index 7271d9ba..9d47d949 100644 --- a/plugins/test.c +++ b/plugins/test.c @@ -4,6 +4,8 @@ #include <salut/plugin.h> +#include "extensions/extensions.h" + #define DEBUG(msg, ...) \ g_debug ("%s: " msg, G_STRFUNC, ##__VA_ARGS__) @@ -11,6 +13,13 @@ static void plugin_iface_init ( gpointer g_iface, gpointer data); +#define IFACE_TEST "org.freedesktop.Telepathy.Salut.Plugin.Test" + +static const gchar * const sidecar_interfaces[] = { + IFACE_TEST, + NULL +}; + G_DEFINE_TYPE_WITH_CODE (TestPlugin, test_plugin, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (SALUT_TYPE_PLUGIN, plugin_iface_init); ) @@ -47,6 +56,40 @@ create_channel_managers (SalutPlugin *plugin, } static void +test_plugin_create_sidecar ( + SalutPlugin *plugin, + const gchar *sidecar_interface, + SalutConnection *connection, + WockySession *session, + GAsyncReadyCallback callback, + gpointer user_data) +{ + GSimpleAsyncResult *result = g_simple_async_result_new (G_OBJECT (plugin), + callback, user_data, + /* sic: all plugins share salut_plugin_create_sidecar_finish() so we + * need to use the same source tag. + */ + salut_plugin_create_sidecar_async); + SalutSidecar *sidecar = NULL; + + if (!tp_strdiff (sidecar_interface, IFACE_TEST)) + { + sidecar = g_object_new (TEST_TYPE_SIDECAR, NULL); + } + else + { + g_simple_async_result_set_error (result, TP_ERRORS, + TP_ERROR_NOT_IMPLEMENTED, "'%s' not implemented", sidecar_interface); + } + + if (sidecar != NULL) + 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 void plugin_iface_init ( gpointer g_iface, gpointer data G_GNUC_UNUSED) @@ -57,6 +100,8 @@ plugin_iface_init ( iface->name = "Salut test plugin"; iface->version = PACKAGE_VERSION; + iface->sidecar_interfaces = sidecar_interfaces; + iface->create_sidecar = test_plugin_create_sidecar; iface->initialize = initialize; iface->create_channel_managers = create_channel_managers; } @@ -66,3 +111,37 @@ salut_plugin_create () { return g_object_new (test_plugin_get_type (), NULL); } + +/****************************** + * TestSidecar implementation * + ******************************/ + +static void sidecar_iface_init ( + gpointer g_iface, + gpointer data); + +G_DEFINE_TYPE_WITH_CODE (TestSidecar, test_sidecar, G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (SALUT_TYPE_SIDECAR, sidecar_iface_init); + G_IMPLEMENT_INTERFACE (SALUT_TYPE_SVC_SALUT_PLUGIN_TEST, NULL); + ) + +static void +test_sidecar_init (TestSidecar *object) +{ + DEBUG ("%p", object); +} + +static void +test_sidecar_class_init (TestSidecarClass *klass) +{ +} + +static void sidecar_iface_init ( + gpointer g_iface, + gpointer data) +{ + SalutSidecarInterface *iface = g_iface; + + iface->interface = IFACE_TEST; + iface->get_immutable_properties = NULL; +} diff --git a/plugins/test.h b/plugins/test.h index 13e11e4c..a37d19a4 100644 --- a/plugins/test.h +++ b/plugins/test.h @@ -1,5 +1,6 @@ #include <glib-object.h> +/* plugin */ typedef struct _TestPluginClass TestPluginClass; typedef struct _TestPlugin TestPlugin; @@ -30,3 +31,35 @@ GType test_plugin_get_type (void); (G_TYPE_INSTANCE_GET_CLASS ((obj), TEST_TYPE_PLUGIN, \ TestPluginClass)) + +/* Sidecar */ +typedef struct _TestSidecarClass TestSidecarClass; +typedef struct _TestSidecar TestSidecar; + +struct _TestSidecarClass +{ + GObjectClass parent; +}; + +struct _TestSidecar +{ + GObject parent; +}; + +GType test_sidecar_get_type (void); + +#define TEST_TYPE_SIDECAR \ + (test_sidecar_get_type ()) +#define TEST_SIDECAR(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), TEST_TYPE_SIDECAR, TestSidecar)) +#define TEST_SIDECAR_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), TEST_TYPE_SIDECAR, \ + TestSidecarClass)) +#define TEST_IS_SIDECAR(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj), TEST_TYPE_SIDECAR)) +#define TEST_IS_SIDECAR_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass), TEST_TYPE_SIDECAR)) +#define TEST_SIDECAR_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), TEST_TYPE_SIDECAR, \ + TestSidecarClass)) + |