After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 776906 - Miscellaneous fixes and improvements to add_temporary_account
Miscellaneous fixes and improvements to add_temporary_account
Status: RESOLVED FIXED
Product: gnome-online-accounts
Classification: Core
Component: Kerberos
3.23.x
Other All
: Normal normal
: ---
Assigned To: GNOME Online Accounts maintainer(s)
GNOME Online Accounts maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2017-01-05 16:59 UTC by Debarshi Ray
Modified: 2017-01-10 14:35 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
identity: Consolidate the exit path (1.06 KB, patch)
2017-01-05 17:01 UTC, Debarshi Ray
committed Details | Review
identity: Fix typo in add_temporary_account (1.37 KB, patch)
2017-01-05 17:02 UTC, Debarshi Ray
committed Details | Review
identity: Simplify the add_temporary_account code (4.22 KB, patch)
2017-01-05 17:02 UTC, Debarshi Ray
committed Details | Review
identity: Hold a ref on the identity while adding a temporary account (1.14 KB, patch)
2017-01-05 17:02 UTC, Debarshi Ray
committed Details | Review
identity: Rename on_account_added to on_temporary_account_added (1.48 KB, patch)
2017-01-06 12:31 UTC, Debarshi Ray
committed Details | Review

Description Debarshi Ray 2017-01-05 16:59:20 UTC
I don't like how we use a callback with the GTask (earlier GSimpleAsyncResult) in add_temporary_account. add_temporary_account is a fire-and-forget function, and the caller doesn't pass any callback. It contains a chain of asynchronous calls and we need a way to carry the context (ie. the GoaIdentityService and the GoaIdentity) across those calls. There are so many ways to do it: (a) a struct (b) g_object_set_data on a GObject (c) abusing GSimpleAsyncResult:source_tag, or (d) GTask:task_data

Attaching a separate callback to the GTask to simply to pass some context seems needlessly convoluted.

I also came across a few minor issues.
Comment 1 Debarshi Ray 2017-01-05 17:01:50 UTC
Created attachment 342970 [details] [review]
identity: Consolidate the exit path
Comment 2 Debarshi Ray 2017-01-05 17:02:02 UTC
Created attachment 342971 [details] [review]
identity: Fix typo in add_temporary_account
Comment 3 Debarshi Ray 2017-01-05 17:02:18 UTC
Created attachment 342972 [details] [review]
identity: Simplify the add_temporary_account code
Comment 4 Debarshi Ray 2017-01-05 17:02:37 UTC
Created attachment 342973 [details] [review]
identity: Hold a ref on the identity while adding a temporary account
Comment 5 Ray Strode [halfline] 2017-01-05 19:03:00 UTC
Review of attachment 342970 [details] [review]:

ok
Comment 6 Ray Strode [halfline] 2017-01-05 19:04:21 UTC
Review of attachment 342971 [details] [review]:

good clean up/fix.
Comment 7 Ray Strode [halfline] 2017-01-05 19:11:32 UTC
Review of attachment 342972 [details] [review]:

i actually think the old way is clearer, but it's subjective, so whatever.  if you like this better I don't care if you push it.

::: src/goaidentity/goaidentityservice.c
@@ +780,1 @@
 on_account_added (GoaManager   *manager,

if you're going to make this function specific to temporary accounts (which is fine, since that's all it's currently used for), then I'd rename it to have temporary somewhere in its name.
Comment 8 Ray Strode [halfline] 2017-01-05 19:13:16 UTC
Review of attachment 342973 [details] [review]:

looks right
Comment 9 Debarshi Ray 2017-01-06 12:19:30 UTC
Comment on attachment 342970 [details] [review]
identity: Consolidate the exit path

Pushed to master.
Comment 10 Debarshi Ray 2017-01-06 12:20:51 UTC
Comment on attachment 342971 [details] [review]
identity: Fix typo in add_temporary_account

Pushed to master.
Comment 11 Debarshi Ray 2017-01-06 12:26:05 UTC
(In reply to Ray Strode [halfline] from comment #7)
> Review of attachment 342972 [details] [review] [review]:
> 
> i actually think the old way is clearer, but it's subjective, so whatever. 
> if you like this better I don't care if you push it.

Ok. :)

> ::: src/goaidentity/goaidentityservice.c
> @@ +780,1 @@
>  on_account_added (GoaManager   *manager,
> 
> if you're going to make this function specific to temporary accounts (which
> is fine, since that's all it's currently used for), then I'd rename it to
> have temporary somewhere in its name.

Ok, I will do that.
Comment 12 Debarshi Ray 2017-01-06 12:31:59 UTC
Created attachment 343015 [details] [review]
identity: Rename on_account_added to on_temporary_account_added