summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2014-02-05 13:24:45 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2014-02-06 13:06:29 +0000
commite3748958037ac74bd6b89e6ea2439378e91b3b89 (patch)
tree072977082199bffcf26ab766662bc8e4b1d1e068 /tests
parent5090a5d462bfaa62300fa0526c043f60759306a6 (diff)
McdStorage: watch and proxy plugins' change-notification signals
This lets us get rid of the "ready" vfunc on plugins: we now connect to each plugin's signals only after we have called mcp_account_storage_list(), so we won't get double-notification for accounts that are both present in the initial list and signalled. This means we can remove a queue of delayed signal emissions from the test D-Bus plugin (and when it's ported to this API, from Empathy's libaccounts/UOA plugin). As far as I can see, list() and ready() happen within the same main-loop iteration anyway, so I don't think it was even possible to receive notification of a new account in that window. Empathy's GNOME Online Accounts plugin never really implemented this: in theory, it was incorrect, since any account that happened to be added between list() and ready() would be lost altogether. However, list() and ready() seem to happen in the same main-loop iteration, so this might never have been a practical concern. Rather than "fixing" Empathy's GOA plugin, it seems better to remove the difficult case altogether. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=74581 Reviewed-by: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Diffstat (limited to 'tests')
-rw-r--r--tests/twisted/dbus-account-plugin.c204
1 files changed, 36 insertions, 168 deletions
diff --git a/tests/twisted/dbus-account-plugin.c b/tests/twisted/dbus-account-plugin.c
index 487d35d9..79464ed9 100644
--- a/tests/twisted/dbus-account-plugin.c
+++ b/tests/twisted/dbus-account-plugin.c
@@ -122,29 +122,6 @@ async_data_free (AsyncData *ad)
g_slice_free (AsyncData, ad);
}
-typedef enum {
- EVENT_PARAMS,
- EVENT_ATTRS,
- EVENT_CREATION,
- EVENT_DELETION
-} EventType;
-
-typedef struct {
- EventType type;
- GVariant *args;
-} Event;
-
-static Event *
-event_new (EventType type,
- GVariant *args)
-{
- Event *e = g_slice_new0 (Event);
-
- e->type = type;
- e->args = g_variant_ref_sink (args);
- return e;
-}
-
static Account *
lookup_account (TestDBusAccountPlugin *self,
const gchar *account_name)
@@ -311,9 +288,15 @@ test_dbus_account_plugin_add_account (TestDBusAccountPlugin *self,
}
static void
-test_dbus_account_plugin_process_account_creation (TestDBusAccountPlugin *self,
- GVariant *args)
+account_created_cb (GDBusConnection *bus,
+ const gchar *sender_name,
+ const gchar *object_path,
+ const gchar *iface_name,
+ const gchar *signal_name,
+ GVariant *tuple,
+ gpointer user_data)
{
+ TestDBusAccountPlugin *self = TEST_DBUS_ACCOUNT_PLUGIN (user_data);
const gchar *account_name;
Account *account;
GVariant *attrs;
@@ -323,7 +306,7 @@ test_dbus_account_plugin_process_account_creation (TestDBusAccountPlugin *self,
GVariant *param_flags;
guint32 restrictions;
- g_variant_get (args, "(&s@a{sv}@a{su}@a{sv}@a{ss}@a{su}u)",
+ g_variant_get (tuple, "(&s@a{sv}@a{su}@a{sv}@a{ss}@a{su}u)",
&account_name, &attrs, &attr_flags,
&params, &untyped_params, &param_flags,
&restrictions);
@@ -361,13 +344,19 @@ test_dbus_account_plugin_process_account_creation (TestDBusAccountPlugin *self,
}
static void
-test_dbus_account_plugin_process_account_deletion (TestDBusAccountPlugin *self,
- GVariant *args)
+account_deleted_cb (GDBusConnection *bus,
+ const gchar *sender_name,
+ const gchar *object_path,
+ const gchar *iface_name,
+ const gchar *signal_name,
+ GVariant *tuple,
+ gpointer user_data)
{
+ TestDBusAccountPlugin *self = TEST_DBUS_ACCOUNT_PLUGIN (user_data);
const gchar *account_name;
Account *account;
- g_variant_get (args, "(&s)", &account_name);
+ g_variant_get (tuple, "(&s)", &account_name);
DEBUG ("%s", account_name);
account = lookup_account (self, account_name);
@@ -395,16 +384,22 @@ test_dbus_account_plugin_process_account_deletion (TestDBusAccountPlugin *self,
}
static void
-test_dbus_account_plugin_process_attributes (TestDBusAccountPlugin *self,
- GVariant *args)
+attributes_changed_cb (GDBusConnection *bus,
+ const gchar *sender_name,
+ const gchar *object_path,
+ const gchar *iface_name,
+ const gchar *signal_name,
+ GVariant *tuple,
+ gpointer user_data)
{
+ TestDBusAccountPlugin *self = TEST_DBUS_ACCOUNT_PLUGIN (user_data);
const gchar *account_name;
Account *account;
GVariant *attrs;
GVariant *attr_flags;
GVariant *deleted;
- g_variant_get (args, "(&s@a{sv}@a{su}@as)",
+ g_variant_get (tuple, "(&s@a{sv}@a{su}@as)",
&account_name, &attrs, &attr_flags, &deleted);
DEBUG ("%s", account_name);
account = lookup_account (self, account_name);
@@ -501,9 +496,15 @@ test_dbus_account_plugin_process_attributes (TestDBusAccountPlugin *self,
}
static void
-test_dbus_account_plugin_process_parameters (TestDBusAccountPlugin *self,
- GVariant *args)
+parameters_changed_cb (GDBusConnection *bus,
+ const gchar *sender_name,
+ const gchar *object_path,
+ const gchar *iface_name,
+ const gchar *signal_name,
+ GVariant *tuple,
+ gpointer user_data)
{
+ TestDBusAccountPlugin *self = TEST_DBUS_ACCOUNT_PLUGIN (user_data);
const gchar *account_name;
Account *account;
GVariant *params;
@@ -511,7 +512,7 @@ test_dbus_account_plugin_process_parameters (TestDBusAccountPlugin *self,
GVariant *param_flags;
GVariant *deleted;
- g_variant_get (args, "(&s@a{sv}@a{ss}@a{su}@as)",
+ g_variant_get (tuple, "(&s@a{sv}@a{ss}@a{su}@as)",
&account_name, &params, &untyped_params, &param_flags, &deleted);
DEBUG ("%s", account_name);
account = lookup_account (self, account_name);
@@ -630,123 +631,6 @@ test_dbus_account_plugin_process_parameters (TestDBusAccountPlugin *self,
g_variant_unref (deleted);
}
-static void
-test_dbus_account_plugin_process_events (TestDBusAccountPlugin *self)
-{
- Event *event;
-
- if (self->feedback == NULL)
- return;
-
- while ((event = g_queue_pop_head (&self->events)) != NULL)
- {
- switch (event->type)
- {
- case EVENT_CREATION:
- test_dbus_account_plugin_process_account_creation (self,
- event->args);
- break;
-
- case EVENT_DELETION:
- test_dbus_account_plugin_process_account_deletion (self,
- event->args);
- break;
-
- case EVENT_ATTRS:
- test_dbus_account_plugin_process_attributes (self,
- event->args);
- break;
-
- case EVENT_PARAMS:
- test_dbus_account_plugin_process_parameters (self,
- event->args);
- break;
- }
-
- g_variant_unref (event->args);
- g_slice_free (Event, event);
- }
-}
-
-static void
-account_created_cb (GDBusConnection *bus,
- const gchar *sender_name,
- const gchar *object_path,
- const gchar *iface_name,
- const gchar *signal_name,
- GVariant *tuple,
- gpointer user_data)
-{
- TestDBusAccountPlugin *self = TEST_DBUS_ACCOUNT_PLUGIN (user_data);
- const gchar *account_name;
-
- g_variant_get (tuple, "(&s@a{sv}@a{su}@a{sv}@a{ss}@a{su}u)",
- &account_name, NULL, NULL, NULL, NULL, NULL, NULL);
- DEBUG ("%s", account_name);
-
- g_queue_push_tail (&self->events, event_new (EVENT_CREATION, tuple));
- test_dbus_account_plugin_process_events (self);
-}
-
-static void
-account_deleted_cb (GDBusConnection *bus,
- const gchar *sender_name,
- const gchar *object_path,
- const gchar *iface_name,
- const gchar *signal_name,
- GVariant *tuple,
- gpointer user_data)
-{
- TestDBusAccountPlugin *self = TEST_DBUS_ACCOUNT_PLUGIN (user_data);
- const gchar *account_name;
-
- g_variant_get (tuple, "(&s)", &account_name);
- DEBUG ("%s", account_name);
-
- g_queue_push_tail (&self->events, event_new (EVENT_DELETION, tuple));
- test_dbus_account_plugin_process_events (self);
-}
-
-static void
-attributes_changed_cb (GDBusConnection *bus,
- const gchar *sender_name,
- const gchar *object_path,
- const gchar *iface_name,
- const gchar *signal_name,
- GVariant *tuple,
- gpointer user_data)
-{
- TestDBusAccountPlugin *self = TEST_DBUS_ACCOUNT_PLUGIN (user_data);
- const gchar *account_name;
-
- g_variant_get (tuple, "(&s@a{sv}@a{su}@as)", &account_name,
- NULL, NULL, NULL);
- DEBUG ("%s", account_name);
-
- g_queue_push_tail (&self->events, event_new (EVENT_ATTRS, tuple));
- test_dbus_account_plugin_process_events (self);
-}
-
-static void
-parameters_changed_cb (GDBusConnection *bus,
- const gchar *sender_name,
- const gchar *object_path,
- const gchar *iface_name,
- const gchar *signal_name,
- GVariant *tuple,
- gpointer user_data)
-{
- TestDBusAccountPlugin *self = TEST_DBUS_ACCOUNT_PLUGIN (user_data);
- const gchar *account_name;
-
- g_variant_get (tuple, "(&s@a{sv}@a{ss}@a{su}@as)", &account_name,
- NULL, NULL, NULL, NULL);
- DEBUG ("%s", account_name);
-
- g_queue_push_tail (&self->events, event_new (EVENT_PARAMS, tuple));
- test_dbus_account_plugin_process_events (self);
-}
-
static GList *
test_dbus_account_plugin_list (McpAccountStorage *storage,
McpAccountManager *am)
@@ -857,21 +741,6 @@ test_dbus_account_plugin_list (McpAccountStorage *storage,
return ret;
}
-static void
-test_dbus_account_plugin_ready (McpAccountStorage *storage,
- McpAccountManager *am)
-{
- TestDBusAccountPlugin *self = TEST_DBUS_ACCOUNT_PLUGIN (storage);
-
- DEBUG ("called");
- g_dbus_connection_emit_signal (self->bus, NULL,
- TEST_DBUS_ACCOUNT_PLUGIN_PATH, TEST_DBUS_ACCOUNT_PLUGIN_IFACE,
- "Ready", NULL, NULL);
- self->feedback = MCP_ACCOUNT_MANAGER (am);
-
- test_dbus_account_plugin_process_events (self);
-}
-
static gchar *
test_dbus_account_plugin_create (McpAccountStorage *storage,
McpAccountManager *am,
@@ -1568,7 +1437,6 @@ account_storage_iface_init (McpAccountStorageIface *iface)
iface->set_attribute = test_dbus_account_plugin_set_attribute;
iface->set_parameter = test_dbus_account_plugin_set_parameter;
iface->list = test_dbus_account_plugin_list;
- iface->ready = test_dbus_account_plugin_ready;
iface->delete_async = test_dbus_account_plugin_delete_async;
iface->delete_finish = test_dbus_account_plugin_delete_finish;
iface->commit = test_dbus_account_plugin_commit;