diff options
author | Jonny Lamb <jonny@debian.org> | 2011-04-04 16:06:47 +0100 |
---|---|---|
committer | Jonny Lamb <jonny@debian.org> | 2011-04-04 16:06:47 +0100 |
commit | 28dd033e3f7f26e75822cc7150694b573a481c36 (patch) | |
tree | 5777d26583325a2df08b0c0ab56a02dac1a46e71 /plugins | |
parent | d59e6168556b8e302a70656e5585234e58759877 (diff) | |
parent | c224b4695d0ab6d182295a173be6a9c0532ecb50 (diff) |
Merge branch 'plugin-channel-managers'
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/test.c | 151 | ||||
-rw-r--r-- | plugins/test.h | 31 |
2 files changed, 182 insertions, 0 deletions
diff --git a/plugins/test.c b/plugins/test.c index be7a42cd..95a29178 100644 --- a/plugins/test.c +++ b/plugins/test.c @@ -122,6 +122,22 @@ test_plugin_create_sidecar ( g_object_unref (result); } +static GPtrArray * +test_plugin_create_channel_managers (GabblePlugin *plugin, + TpBaseConnection *connection) +{ + GPtrArray *ret = g_ptr_array_new (); + + DEBUG ("plugin %p on connection %p", plugin, connection); + + g_ptr_array_add (ret, + g_object_new (TEST_TYPE_CHANNEL_MANAGER, + "connection", connection, + NULL)); + + return ret; +} + static TpPresenceStatusSpec test_presences[] = { { "testbusy", TP_CONNECTION_PRESENCE_TYPE_BUSY, TRUE, NULL, NULL, NULL }, { "testaway", TP_CONNECTION_PRESENCE_TYPE_AWAY, FALSE, NULL, NULL, NULL }, @@ -143,6 +159,7 @@ plugin_iface_init ( iface->name = "Sidecar test plugin"; iface->sidecar_interfaces = sidecar_interfaces; iface->create_sidecar = test_plugin_create_sidecar; + iface->create_channel_managers = test_plugin_create_channel_managers; iface->presence_statuses = test_presences; iface->privacy_list_map = privacy_list_map; @@ -460,3 +477,137 @@ async_initable_iface_init ( iface->init_async = sidecar_iq_init_async; iface->init_finish = sidecar_iq_init_finish; } + +/*********************************** + * TestChannelManager implementation * + ***********************************/ +static void channel_manager_iface_init (gpointer, gpointer); + +G_DEFINE_TYPE_WITH_CODE (TestChannelManager, test_channel_manager, + G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (TP_TYPE_CHANNEL_MANAGER, + channel_manager_iface_init)); + +static void +test_channel_manager_init (TestChannelManager *self) +{ +} + +static void +test_channel_manager_set_property ( + GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + TestChannelManager *self = TEST_CHANNEL_MANAGER (object); + + switch (property_id) + { + case PROP_CONNECTION: + self->connection = g_value_dup_object (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +test_channel_manager_get_property ( + GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + TestChannelManager *self = TEST_CHANNEL_MANAGER (object); + + switch (property_id) + { + case PROP_CONNECTION: + g_value_set_object (value, self->connection); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +test_channel_manager_porter_available_cb (GabbleConnection *connection, + WockyPorter *porter, + gpointer user_data) +{ + DEBUG ("now we have a porter: %p", porter); + /* so now we can call things like wocky_porter_register_handler_* + * and get some stanzas. */ +} + +static void +test_channel_manager_constructed (GObject *object) +{ + TestChannelManager *self = TEST_CHANNEL_MANAGER (object); + + if (G_OBJECT_CLASS (test_channel_manager_parent_class)->constructed != NULL) + G_OBJECT_CLASS (test_channel_manager_parent_class)->constructed (object); + + tp_g_signal_connect_object (self->connection, "porter-available", + G_CALLBACK (test_channel_manager_porter_available_cb), + self, 0); +} + +static void +test_channel_manager_dispose (GObject *object) +{ + TestChannelManager *self = TEST_CHANNEL_MANAGER (object); + + if (G_OBJECT_CLASS (test_channel_manager_parent_class)->dispose != NULL) + G_OBJECT_CLASS (test_channel_manager_parent_class)->dispose (object); + + tp_clear_object (&self->connection); +} + +static void +test_channel_manager_class_init (TestChannelManagerClass *klass) +{ + GObjectClass *oclass = G_OBJECT_CLASS (klass); + + oclass->set_property = test_channel_manager_set_property; + oclass->get_property = test_channel_manager_get_property; + oclass->constructed = test_channel_manager_constructed; + oclass->dispose = test_channel_manager_dispose; + + g_object_class_install_property (oclass, PROP_CONNECTION, + g_param_spec_object ("connection", "Gabble Connection", + "Gabble connection", + GABBLE_TYPE_CONNECTION, + G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); +} + +static void +test_channel_manager_type_foreach_channel_class (GType type, + TpChannelManagerTypeChannelClassFunc func, + gpointer user_data) +{ + GHashTable *table = tp_asv_new ( + "cookies", G_TYPE_STRING, "lolbags", + NULL); + const gchar * const chock_a_block_full_of_strings[] = {"omg", "hi mum!", NULL }; + + func (type, table, chock_a_block_full_of_strings, user_data); + + g_hash_table_destroy (table); +} + +static void +channel_manager_iface_init (gpointer g_iface, + gpointer iface_data) +{ + TpChannelManagerIface *iface = g_iface; + + iface->type_foreach_channel_class = test_channel_manager_type_foreach_channel_class; + + /* not requestable. */ + iface->ensure_channel = NULL; + iface->create_channel = NULL; + iface->request_channel = NULL; + iface->foreach_channel_class = NULL; +} diff --git a/plugins/test.h b/plugins/test.h index 46fc562e..6fe0d143 100644 --- a/plugins/test.h +++ b/plugins/test.h @@ -123,3 +123,34 @@ GType test_sidecar_iq_get_type (void); #define TEST_SIDECAR_IQ_GET_CLASS(obj) \ (G_TYPE_INSTANCE_GET_CLASS ((obj), TEST_TYPE_SIDECAR_IQ, \ TestSidecarIQClass)) + +/* Test channel manager */ +typedef struct _TestChannelManager TestChannelManager; +typedef struct _TestChannelManagerClass TestChannelManagerClass; + +struct _TestChannelManagerClass { + GObjectClass parent_class; +}; + +struct _TestChannelManager { + GObject parent; + GabbleConnection *connection; +}; + +GType test_channel_manager_get_type (void); + +/* TYPE MACROS */ +#define TEST_TYPE_CHANNEL_MANAGER \ + (test_channel_manager_get_type ()) +#define TEST_CHANNEL_MANAGER(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), TEST_TYPE_CHANNEL_MANAGER, TestChannelManager)) +#define TEST_CHANNEL_MANAGER_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), TEST_TYPE_CHANNEL_MANAGER,\ + TestChannelManagerClass)) +#define TEST_IS_CHANNEL_MANAGER(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj), TEST_TYPE_CHANNEL_MANAGER)) +#define TEST_IS_CHANNEL_MANAGER_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass), TEST_TYPE_CHANNEL_MANAGER)) +#define TEST_CHANNEL_MANAGER_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), TEST_TYPE_CHANNEL_MANAGER,\ + TestChannelManagerClass)) |