Merge lp:~mardy/libaccounts-glib/packaging into lp:libaccounts-glib

Proposed by Alberto Mardegan on 2015-01-12
Status: Merged
Approved by: David Barth on 2015-01-19
Approved revision: 190
Merged at revision: 190
Proposed branch: lp:~mardy/libaccounts-glib/packaging
Merge into: lp:libaccounts-glib
Diff against target: 351 lines (+85/-36)
5 files modified
libaccounts-glib/ag-auth-data.c (+1/-1)
libaccounts-glib/ag-manager.c (+42/-15)
libaccounts-glib/com.google.code.AccountsSSO.Accounts.Manager.xml (+1/-0)
libaccounts-glib/libaccounts-glib.vapi (+27/-18)
tests/check_ag.c (+14/-2)
To merge this branch: bzr merge lp:~mardy/libaccounts-glib/packaging
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve on 2015-01-12
Online Accounts 2015-01-12 Pending
Review via email: mp+246142@code.launchpad.net

Commit message

Merge from upstream
- Update account ID after a remotely-executed store

Description of the change

Merge from upstream
- Update account ID after a remotely-executed store

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libaccounts-glib/ag-auth-data.c'
2--- libaccounts-glib/ag-auth-data.c 2014-01-03 13:25:25 +0000
3+++ libaccounts-glib/ag-auth-data.c 2015-01-12 13:45:18 +0000
4@@ -320,7 +320,7 @@
5 /**
6 * ag_auth_data_get_login_parameters:
7 * @self: the #AgAuthData.
8- * @extra_parameters: (transfer floating): a #GVariant containing
9+ * @extra_parameters: (transfer floating) (allow-none): a #GVariant containing
10 * client-specific authentication parameters to be added to the returned
11 * dictionary.
12 *
13
14=== modified file 'libaccounts-glib/ag-manager.c'
15--- libaccounts-glib/ag-manager.c 2014-06-23 10:41:35 +0000
16+++ libaccounts-glib/ag-manager.c 2015-01-12 13:45:18 +0000
17@@ -161,6 +161,8 @@
18 struct timespec ts;
19 } ProcessedSignalData;
20
21+static const gchar *key_remote_changes = "ag_remote_changes";
22+
23 static void ag_manager_initable_iface_init(gpointer g_iface,
24 gpointer iface_data);
25
26@@ -199,6 +201,21 @@
27 }
28 else
29 {
30+ GObject *source =
31+ g_async_result_get_source_object ((GAsyncResult *)async_result);
32+ AgAccount *account = AG_ACCOUNT (source);
33+ /* If this was a new account, we must update the local data
34+ * structure */
35+ if (account->id == 0 &&
36+ g_variant_n_children (result) >= 1)
37+ {
38+ AgAccountChanges *changes;
39+
40+ g_variant_get_child (result, 0, "u", &account->id);
41+ changes = g_object_get_data ((GObject *)async_result,
42+ key_remote_changes);
43+ _ag_account_done_changes (account, changes);
44+ }
45 g_variant_unref (result);
46 }
47
48@@ -227,6 +244,9 @@
49
50 changes = _ag_account_steal_changes (account);
51 dbus_changes = _ag_account_build_dbus_changes (account, changes, NULL);
52+ g_object_set_data_full ((GObject *)async_result,
53+ key_remote_changes, changes,
54+ (GDestroyNotify) _ag_account_changes_free);
55
56 g_dbus_connection_call (priv->dbus_conn,
57 AG_MANAGER_SERVICE_NAME,
58@@ -240,8 +260,6 @@
59 cancellable,
60 (GAsyncReadyCallback)on_dbus_store_done,
61 async_result);
62-
63- _ag_account_changes_free (changes);
64 }
65
66 static gboolean
67@@ -251,6 +269,7 @@
68 AgManagerPrivate *priv = manager->priv;
69 AgAccountChanges *changes;
70 GVariant *dbus_changes;
71+ GVariant *result;
72 GError *error_int = NULL;
73
74 if (G_UNLIKELY (!priv->use_dbus)) {
75@@ -264,19 +283,18 @@
76 changes = _ag_account_steal_changes (account);
77 dbus_changes = _ag_account_build_dbus_changes (account, changes, NULL);
78
79- g_dbus_connection_call_sync (priv->dbus_conn,
80- AG_MANAGER_SERVICE_NAME,
81- AG_MANAGER_OBJECT_PATH,
82- AG_MANAGER_INTERFACE,
83- "store",
84- dbus_changes,
85- NULL,
86- G_DBUS_CALL_FLAGS_NONE,
87- -1,
88- NULL,
89- &error_int);
90-
91- _ag_account_changes_free (changes);
92+ result =
93+ g_dbus_connection_call_sync (priv->dbus_conn,
94+ AG_MANAGER_SERVICE_NAME,
95+ AG_MANAGER_OBJECT_PATH,
96+ AG_MANAGER_INTERFACE,
97+ "store",
98+ dbus_changes,
99+ NULL,
100+ G_DBUS_CALL_FLAGS_NONE,
101+ -1,
102+ NULL,
103+ &error_int);
104
105 if (G_UNLIKELY (error_int))
106 {
107@@ -286,9 +304,18 @@
108 AG_ACCOUNTS_ERROR_READONLY,
109 error_int->message);
110 g_error_free (error_int);
111+ _ag_account_changes_free (changes);
112 return FALSE;
113 }
114
115+ if (account->id == 0 &&
116+ g_variant_n_children (result) >= 1)
117+ {
118+ g_variant_get_child (result, 0, "u", &account->id);
119+ _ag_account_done_changes (account, changes);
120+ }
121+
122+ _ag_account_changes_free (changes);
123 return TRUE;
124 }
125
126
127=== modified file 'libaccounts-glib/com.google.code.AccountsSSO.Accounts.Manager.xml'
128--- libaccounts-glib/com.google.code.AccountsSSO.Accounts.Manager.xml 2013-12-23 15:22:56 +0000
129+++ libaccounts-glib/com.google.code.AccountsSSO.Accounts.Manager.xml 2015-01-12 13:45:18 +0000
130@@ -42,6 +42,7 @@
131 <arg name="deleted" type="b" direction="in"/>
132 <arg name="provider" type="s" direction="in"/>
133 <arg name="settings" type="a(ssua{sv}as)" direction="in"/>
134+ <arg name="accountId" type="u" direction="out"/>
135 </method>
136 </interface>
137 </node>
138
139=== modified file 'libaccounts-glib/libaccounts-glib.vapi'
140--- libaccounts-glib/libaccounts-glib.vapi 2013-06-05 08:01:59 +0000
141+++ libaccounts-glib/libaccounts-glib.vapi 2015-01-12 13:45:18 +0000
142@@ -1,9 +1,9 @@
143-/* accounts.vapi generated by vapigen, do not modify. */
144+/* libaccounts-glib.vapi generated by vapigen, do not modify. */
145
146 [CCode (cprefix = "Ag", gir_namespace = "Accounts", gir_version = "1.0", lower_case_cprefix = "ag_")]
147 namespace Ag {
148 [CCode (cheader_filename = "libaccounts-glib/accounts-glib.h", type_id = "ag_account_get_type ()")]
149- public class Account : GLib.Object {
150+ public class Account : GLib.Object, GLib.Initable {
151 [CCode (has_construct_function = false)]
152 protected Account ();
153 public void @delete ();
154@@ -15,7 +15,7 @@
155 public Ag.AccountSettingIter get_settings_iter (string? key_prefix);
156 [Deprecated (replacement = "get_variant", since = "1.4")]
157 public Ag.SettingSource get_value (string key, ref GLib.Value value);
158- public GLib.Variant get_variant (string key, out Ag.SettingSource? source);
159+ public unowned GLib.Variant get_variant (string key, out Ag.SettingSource? source);
160 public GLib.List<Ag.Service> list_enabled_services ();
161 public GLib.List<Ag.Service> list_services ();
162 public GLib.List<Ag.Service> list_services_by_type (string service_type);
163@@ -63,18 +63,18 @@
164 public Ag.AccountSettingIter get_settings_iter (string? key_prefix);
165 [Deprecated (replacement = "get_variant", since = "1.4")]
166 public Ag.SettingSource get_value (string key, ref GLib.Value value);
167- public GLib.Variant get_variant (string key, out Ag.SettingSource? source);
168+ public unowned GLib.Variant get_variant (string key, out Ag.SettingSource? source);
169 [Deprecated (replacement = "set_variant", since = "1.4")]
170 public void set_value (string key, GLib.Value? value);
171 public void set_variant (string key, GLib.Variant? value);
172 public void settings_iter_init (Ag.AccountSettingIter iter, string? key_prefix);
173 [Deprecated (since = "1.4")]
174 public static bool settings_iter_next (Ag.AccountSettingIter iter, out unowned string key, out GLib.Value value);
175- public Ag.Account account { construct; }
176+ public Ag.Account account { get; construct; }
177 /* FIXME: Same name as a signal, so ignore for the moment.
178 public bool enabled { get; }
179 */
180- public Ag.Service service { construct; }
181+ public Ag.Service service { get; construct; }
182 public signal void changed ();
183 public signal void enabled (bool enabled);
184 }
185@@ -83,6 +83,8 @@
186 public class AccountSettingIter {
187 public weak Ag.Account account;
188 public void free ();
189+ public bool get_next (out unowned string key, out unowned GLib.Variant value);
190+ [Deprecated (replacement = "get_next", since = "1.4")]
191 public bool next (out unowned string key, out GLib.Value value);
192 }
193 [CCode (cheader_filename = "libaccounts-glib/accounts-glib.h")]
194@@ -104,9 +106,9 @@
195 [Compact]
196 public class AuthData {
197 public uint get_credentials_id ();
198+ public unowned GLib.Variant get_login_parameters (GLib.Variant? extra_parameters);
199 public unowned string get_mechanism ();
200 public unowned string get_method ();
201- public unowned GLib.Variant get_login_parameters (GLib.Variant variant);
202 [Deprecated (replacement = "get_login_parameters", since = "1.4")]
203 public unowned GLib.HashTable<string,GLib.Value?> get_parameters ();
204 [Deprecated (replacement = "get_login_parameters", since = "1.4")]
205@@ -115,7 +117,7 @@
206 public void unref ();
207 }
208 [CCode (cheader_filename = "libaccounts-glib/accounts-glib.h", type_id = "ag_manager_get_type ()")]
209- public class Manager : GLib.Object {
210+ public class Manager : GLib.Object, GLib.Initable {
211 [CCode (has_construct_function = false)]
212 public Manager ();
213 public Ag.Account create_account (string provider_name);
214@@ -144,7 +146,11 @@
215 public Ag.ServiceType load_service_type (string service_type);
216 public void set_abort_on_db_timeout (bool abort);
217 public void set_db_timeout (uint timeout_ms);
218+ public bool abort_on_db_timeout { get; set; }
219+ public uint db_timeout { get; set; }
220 public string service_type { get; construct; }
221+ [NoAccessorMethod]
222+ public bool use_dbus { get; construct; }
223 public signal void account_created (uint account_id);
224 public virtual signal void account_deleted (uint id);
225 public signal void account_updated (uint account_id);
226@@ -153,14 +159,15 @@
227 [CCode (cheader_filename = "libaccounts-glib/accounts-glib.h", copy_function = "g_boxed_copy", free_function = "g_boxed_free", type_id = "ag_provider_get_type ()")]
228 [Compact]
229 public class Provider {
230+ public unowned string get_description ();
231 public unowned string get_display_name ();
232- public unowned string get_description ();
233 public unowned string get_domains_regex ();
234 public void get_file_contents (string contents);
235 public unowned string get_i18n_domain ();
236 public unowned string get_icon_name ();
237 public unowned string get_name ();
238 public unowned string get_plugin_name ();
239+ public bool get_single_account ();
240 public static void list_free (GLib.List<Ag.Provider> list);
241 public bool match_domain (string domain);
242 public Ag.Provider @ref ();
243@@ -169,8 +176,8 @@
244 [CCode (cheader_filename = "libaccounts-glib/accounts-glib.h", copy_function = "g_boxed_copy", free_function = "g_boxed_free", type_id = "ag_service_get_type ()")]
245 [Compact]
246 public class Service {
247+ public unowned string get_description ();
248 public unowned string get_display_name ();
249- public unowned string get_description ();
250 public void get_file_contents (string contents, size_t data_offset);
251 public unowned string get_i18n_domain ();
252 public unowned string get_icon_name ();
253@@ -186,8 +193,8 @@
254 [CCode (cheader_filename = "libaccounts-glib/accounts-glib.h", copy_function = "g_boxed_copy", free_function = "g_boxed_free", type_id = "ag_service_type_get_type ()")]
255 [Compact]
256 public class ServiceType {
257+ public unowned string get_description ();
258 public unowned string get_display_name ();
259- public unowned string get_description ();
260 public void get_file_contents (string contents, size_t len);
261 public unowned string get_i18n_domain ();
262 public unowned string get_icon_name ();
263@@ -202,6 +209,12 @@
264 [SimpleType]
265 public struct AccountId : uint {
266 }
267+ [CCode (cheader_filename = "libaccounts-glib/accounts-glib.h", cprefix = "AG_SETTING_SOURCE_", has_type_id = false)]
268+ public enum SettingSource {
269+ NONE,
270+ ACCOUNT,
271+ PROFILE
272+ }
273 [CCode (cheader_filename = "libaccounts-glib/accounts-glib.h", cprefix = "AG_ACCOUNTS_ERROR_")]
274 public errordomain AccountsError {
275 DB,
276@@ -209,13 +222,9 @@
277 DELETED,
278 DB_LOCKED,
279 ACCOUNT_NOT_FOUND,
280- STORE_IN_PROGRESS
281- }
282- [CCode (cheader_filename = "libaccounts-glib/accounts-glib.h", cprefix = "AG_SETTING_SOURCE_")]
283- public enum SettingSource {
284- NONE,
285- ACCOUNT,
286- PROFILE
287+ STORE_IN_PROGRESS,
288+ READONLY;
289+ public static GLib.Quark quark ();
290 }
291 [CCode (cheader_filename = "libaccounts-glib/accounts-glib.h", instance_pos = 2.9)]
292 public delegate void AccountNotifyCb (Ag.Account account, string key);
293
294=== modified file 'tests/check_ag.c'
295--- tests/check_ag.c 2014-08-14 12:47:14 +0000
296+++ tests/check_ag.c 2015-01-12 13:45:18 +0000
297@@ -571,6 +571,7 @@
298 StoreCbData *store_data)
299 {
300 g_debug ("%s called", G_STRFUNC);
301+ guint result_id = store_data->account_id;
302
303 store_data->called = TRUE;
304 store_data->account_id = account_id;
305@@ -578,7 +579,7 @@
306 store_data->deleted = deleted;
307 store_data->provider = g_strdup (provider);
308 store_data->settings = g_variant_ref (settings);
309- test_manager_complete_store (test_manager, invocation);
310+ test_manager_complete_store (test_manager, invocation, result_id);
311 return TRUE;
312 }
313
314@@ -603,6 +604,8 @@
315 StoreCbData store_data = { 0 };
316 GDBusObjectManagerServer *object_manager;
317 GDBusConnection *conn;
318+ const gchar *display_name = "My readonly account";
319+ const AgAccountId expected_id = 4;
320 GError *error = NULL;
321 guint reg_id;
322
323@@ -637,11 +640,15 @@
324 manager = ag_manager_new ();
325 ck_assert (manager != NULL);
326
327- /* create an account, and expect a failure */
328+ /* create an account, write its display name */
329 account = ag_manager_create_account (manager, "fakebook");
330 fail_unless (AG_IS_ACCOUNT (account),
331 "Failed to create the AgAccount.");
332+ ag_account_set_display_name (account, display_name);
333
334+ /* We want to verify that the local account will be updated with this
335+ * ID */
336+ store_data.account_id = expected_id;
337 ag_account_store_async (account, NULL,
338 test_store_read_only_store_cb,
339 main_loop);
340@@ -654,6 +661,11 @@
341 ck_assert_str_eq (store_data.provider, "fakebook");
342 store_cb_data_unset (&store_data);
343
344+ ck_assert_uint_eq (account->id, expected_id);
345+ const char *name = ag_account_get_display_name (account);
346+ ck_assert (name != NULL);
347+ ck_assert_str_eq (name, display_name);
348+
349 /* cleaning up */
350 g_object_unref (object_manager);
351 g_object_unref (test_object);

Subscribers

People subscribed via source and target branches

to all changes: