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 752941 - Add generic GoaProvider::show_account() implementation
Add generic GoaProvider::show_account() implementation
Status: RESOLVED FIXED
Product: gnome-online-accounts
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: GNOME Online Accounts maintainer(s)
GNOME Online Accounts maintainer(s)
: 696077 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2015-07-27 21:56 UTC by Christophe Fergeau
Modified: 2017-05-29 18:18 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
owncloud: Add uri_to_string_with_path() helper (3.31 KB, patch)
2015-07-27 21:57 UTC, Christophe Fergeau
needs-work Details | Review
owncloud: Introduce get_webdav_uri() helper (2.48 KB, patch)
2015-07-27 21:57 UTC, Christophe Fergeau
needs-work Details | Review
provider: Unify default vfunc name (2.10 KB, patch)
2015-07-27 21:57 UTC, Christophe Fergeau
accepted-commit_now Details | Review
provider: Add default implementation for GoaProvider::show_account() (6.48 KB, patch)
2015-07-27 21:57 UTC, Christophe Fergeau
needs-work Details | Review
provider: Sort show_account() entries depending on locale (2.88 KB, patch)
2015-07-27 21:57 UTC, Christophe Fergeau
reviewed Details | Review
providers: Use default implementation of ::show_account() (25.15 KB, patch)
2015-07-27 21:57 UTC, Christophe Fergeau
needs-work Details | Review
owncloud: Add uri_to_string_with_path() helper (3.40 KB, patch)
2015-07-30 20:42 UTC, Christophe Fergeau
committed Details | Review
owncloud: Introduce get_webdav_uri() helper (2.23 KB, patch)
2015-07-30 20:42 UTC, Christophe Fergeau
committed Details | Review
provider: Unify default vfunc name (2.10 KB, patch)
2015-07-30 20:42 UTC, Christophe Fergeau
committed Details | Review
provider: Add default implementation for GoaProvider::show_account() (7.39 KB, patch)
2015-07-30 20:42 UTC, Christophe Fergeau
needs-work Details | Review
providers: Use default implementation of ::show_account() (25.02 KB, patch)
2015-07-30 20:43 UTC, Christophe Fergeau
committed Details | Review
Reorder GoaProviderClass fields as it's private now (1.77 KB, patch)
2015-07-30 20:43 UTC, Christophe Fergeau
committed Details | Review
Fix typo in comment in goaprovider.c (923 bytes, patch)
2015-07-30 20:43 UTC, Christophe Fergeau
committed Details | Review
provider: Sort show_account() entries depending on locale (3.22 KB, patch)
2015-07-30 20:43 UTC, Christophe Fergeau
none Details | Review
provider: Add default implementation for GoaProvider::show_account() (7.40 KB, patch)
2015-07-31 18:14 UTC, Christophe Fergeau
none Details | Review
provider: Add default implementation for GoaProvider::show_account() (7.35 KB, patch)
2015-07-31 19:19 UTC, Christophe Fergeau
committed Details | Review
provider: Sort show_account() entries depending on locale (3.66 KB, patch)
2015-07-31 19:20 UTC, Christophe Fergeau
reviewed Details | Review

Description Christophe Fergeau 2015-07-27 21:56:59 UTC
This patch series adds a generic implementation of GoaProvider::show_account()
and use it in the various providers rather than having duplicated code in each of them.
Comment 1 Christophe Fergeau 2015-07-27 21:57:04 UTC
Created attachment 308257 [details] [review]
owncloud: Add uri_to_string_with_path() helper

This extracts a bit of repeated code out of
GoaOwncloudProvider::build_object() and makes the high level code flow
somewhat easier to follow.
Comment 2 Christophe Fergeau 2015-07-27 21:57:09 UTC
Created attachment 308258 [details] [review]
owncloud: Introduce get_webdav_uri() helper

Move a bit more code out of GoaOwncloudProvider::build_object().
Comment 3 Christophe Fergeau 2015-07-27 21:57:15 UTC
Created attachment 308259 [details] [review]
provider: Unify default vfunc name

The default vfunc implementations in GoaProvider are named _real except
for goa_provider_get_provider_icon_default().
This commit changes the "_default" suffix to "_real" for better
consistency.
Comment 4 Christophe Fergeau 2015-07-27 21:57:20 UTC
Created attachment 308260 [details] [review]
provider: Add default implementation for GoaProvider::show_account()
Comment 5 Christophe Fergeau 2015-07-27 21:57:25 UTC
Created attachment 308261 [details] [review]
provider: Sort show_account() entries depending on locale
Comment 6 Christophe Fergeau 2015-07-27 21:57:31 UTC
Created attachment 308262 [details] [review]
providers: Use default implementation of ::show_account()

This commit removes quite a bit of duplicated code from the various
providers now that we have a generic default GoaProvider::show_account()
implementation.
Comment 7 Debarshi Ray 2015-07-30 13:47:19 UTC
*** Bug 696077 has been marked as a duplicate of this bug. ***
Comment 8 Debarshi Ray 2015-07-30 13:58:24 UTC
Review of attachment 308257 [details] [review]:

Thanks for the nice clean-up.

::: src/goabackend/goaowncloudprovider.c
@@ +88,3 @@
+uri_to_string_with_path (SoupURI *soup_uri, const gchar *path)
+{
+  gchar *uri;

Nitpick: how about calling it uri_string? It is used elsewhere in the file for an URI expressed as a gchar *, while uri is also used for a SoupURI.

@@ +95,3 @@
+
+  uri_tmp = soup_uri_to_string (soup_uri, FALSE);
+  uri= g_strconcat (uri_tmp, path, NULL);

Missing a space before the '='.
Comment 9 Debarshi Ray 2015-07-30 14:10:23 UTC
Review of attachment 308258 [details] [review]:

Looks good apart from one small detail:

::: src/goabackend/goaowncloudprovider.c
@@ +86,2 @@
 /* ---------------------------------------------------------------------------------------------------- */
+

This new line should have been in the previous patch. I won't complain if you decide to squash them together due to this. ;)
Comment 10 Debarshi Ray 2015-07-30 14:13:27 UTC
Review of attachment 308259 [details] [review]:

++
Comment 11 Debarshi Ray 2015-07-30 16:36:56 UTC
Review of attachment 308260 [details] [review]:

This exposes some mnemonic conflicts, but I am not too fussed about those because they are not used in conjunction at the moment.

::: src/goabackend/goaprovider-priv.h
@@ +79,1 @@
   void         (*show_account)      (GoaProvider         *self,

There is no need to preserve the order of the pointers because this header is decisively not part of the public API since commit 583b9d0f63b1a We should have also dropped the padding, and consolidated all the pure virtual and virtual with default paragraphs as part of that commit.

::: src/goabackend/goaprovider.c
@@ +471,3 @@
+
+static ShowAccountItem show_account_items[] = {
+  {

How about using the same structure / style as 'ordered_builtins_map' further down in the file?

@@ +495,3 @@
+    .property = "documents-disabled",
+    .blurb = N_("_Documents"),
+  },

Thanks for keeping the ordering unchanged!

@@ +556,3 @@
+  item = show_account_items;
+
+  while (item->feature != GOA_PROVIDER_FEATURE_INVALID)

In that case, this would be a for loop using indices.
Comment 12 Debarshi Ray 2015-07-30 16:55:32 UTC
Review of attachment 308261 [details] [review]:

I am not sure about this. Do we sort things like this elsewhere? For example, the entries in GtkPlacesSidebar are not sorted. Maybe there are some counter-examples too? Does the documentation team have an opinion about sorting UI controls like this? I can imagine a support call across multiple locales where the ability to say "click the second switch" can be useful.
Comment 13 Debarshi Ray 2015-07-30 17:26:27 UTC
Review of attachment 308262 [details] [review]:

Looks mostly good, apart from two nitpicks:

a) the telepathy-account-widgets hunk shouldn't be a part of this change, and ...

::: src/goabackend/goatelepathyprovider.c
@@ +875,3 @@
               G_GNUC_UNUSED GtkGrid *dummy)
 {
+  GoaProviderClass *parent_class = GOA_PROVIDER_CLASS (goa_telepathy_provider_parent_class);

We use goa_telepathy_provider_parent_class directly with the cast elsewhere in the file.
Comment 14 Debarshi Ray 2015-07-30 17:26:56 UTC
Thanks for doing this, Christophe!
Comment 15 Christophe Fergeau 2015-07-30 19:46:42 UTC
Review of attachment 308258 [details] [review]:

::: src/goabackend/goaowncloudprovider.c
@@ +86,2 @@
 /* ---------------------------------------------------------------------------------------------------- */
+

Oh it's easy enough to move this to the right commit, thanks for spotting this :) Tweaking these 2 patches made me realize they probably were unrelated to this bug. Well, I had to attach them somewhere :)
Comment 16 Christophe Fergeau 2015-07-30 19:54:31 UTC
Review of attachment 308261 [details] [review]:

No strong feeling about that one, on the one hand, the unsorted list feels a bit weird to me, on the other hand, sorting things from probably most important to less important rather than alphabetically is probably more sensible. 

It's independant of the 5th patch, so I've moved this one last in the series, it can be pushed later if it needs more discussion.
Comment 17 Christophe Fergeau 2015-07-30 20:03:02 UTC
Review of attachment 308262 [details] [review]:

Ah, the telepathy-account-widgets is already gone, noticed it during a rebase.
Comment 18 Christophe Fergeau 2015-07-30 20:25:14 UTC
Review of attachment 308260 [details] [review]:

::: src/goabackend/goaprovider.c
@@ +471,3 @@
+
+static ShowAccountItem show_account_items[] = {
+  {

Do you mean an anonymous structure (see below) or something different?

static struct
{
  ...
} show_account_items[] = {
  ...
}

I'd prefer to keep the .label = xxx; style for initialization though, as this makes things a bit more readable imo.
Comment 19 Christophe Fergeau 2015-07-30 20:27:04 UTC
Review of attachment 308260 [details] [review]:

::: src/goabackend/goaprovider.c
@@ +471,3 @@
+
+static ShowAccountItem show_account_items[] = {
+  {

Actually, not having a typedef would break the sorting patch as it puts some of these items in a list, sorts the list and then iterates over the list and casts the list elements to the right type. I'll keep the typedef for now, if we drop the sorting patch, I don't mind changing that one to what you suggested.
Comment 20 Christophe Fergeau 2015-07-30 20:40:39 UTC
Review of attachment 308260 [details] [review]:

::: src/goabackend/goaprovider-priv.h
@@ +79,1 @@
   void         (*show_account)      (GoaProvider         *self,

Arguably, one could have some code compiled pre-583b9d (aka 3.11.4~2) which directly dereferences the function pointers rather than using the corresponding function wrapper, so moving these fields around is technically an ABI break. This is probably not a usecase we care about though?
Comment 21 Christophe Fergeau 2015-07-30 20:42:41 UTC
Created attachment 308488 [details] [review]
owncloud: Add uri_to_string_with_path() helper

This extracts a bit of repeated code out of
GoaOwncloudProvider::build_object() and makes the high level code flow
somewhat easier to follow.
Comment 22 Christophe Fergeau 2015-07-30 20:42:47 UTC
Created attachment 308489 [details] [review]
owncloud: Introduce get_webdav_uri() helper

Move a bit more code out of GoaOwncloudProvider::build_object().
Comment 23 Christophe Fergeau 2015-07-30 20:42:53 UTC
Created attachment 308490 [details] [review]
provider: Unify default vfunc name

The default vfunc implementations in GoaProvider are named _real except
for goa_provider_get_provider_icon_default().
This commit changes the "_default" suffix to "_real" for better
consistency.
Comment 24 Christophe Fergeau 2015-07-30 20:42:59 UTC
Created attachment 308491 [details] [review]
provider: Add default implementation for GoaProvider::show_account()
Comment 25 Christophe Fergeau 2015-07-30 20:43:05 UTC
Created attachment 308492 [details] [review]
providers: Use default implementation of ::show_account()

This commit removes quite a bit of duplicated code from the various
providers now that we have a generic default GoaProvider::show_account()
implementation.
Comment 26 Christophe Fergeau 2015-07-30 20:43:10 UTC
Created attachment 308493 [details] [review]
Reorder GoaProviderClass fields as it's private now

We can group all pure virtual functions together, and drop the structure
padding as GoaProvider is not publicly exposed anymore.
Comment 27 Christophe Fergeau 2015-07-30 20:43:16 UTC
Created attachment 308494 [details] [review]
Fix typo in comment in goaprovider.c

There is an extra 'is' in the sentence.
Comment 28 Christophe Fergeau 2015-07-30 20:43:22 UTC
Created attachment 308495 [details] [review]
provider: Sort show_account() entries depending on locale
Comment 29 Christophe Fergeau 2015-07-31 07:15:27 UTC
Review of attachment 308260 [details] [review]:

::: src/goabackend/goaprovider.c
@@ +471,3 @@
+
+static ShowAccountItem show_account_items[] = {
+  {

On second thought, I can remove the typedef from this commit, and move it to the 'sorting' patch. If you prefer that approach, just let me know.
Comment 30 Debarshi Ray 2015-07-31 10:57:53 UTC
Review of attachment 308488 [details] [review]:

++
Comment 31 Debarshi Ray 2015-07-31 11:05:12 UTC
Review of attachment 308489 [details] [review]:

++
Comment 32 Debarshi Ray 2015-07-31 11:06:15 UTC
Review of attachment 308490 [details] [review]:

++
Comment 33 Debarshi Ray 2015-07-31 11:16:37 UTC
(In reply to Christophe Fergeau from comment #20)
> Review of attachment 308260 [details] [review] [review]:
> 
> ::: src/goabackend/goaprovider-priv.h
> @@ +79,1 @@
>    void         (*show_account)      (GoaProvider         *self,
> 
> Arguably, one could have some code compiled pre-583b9d (aka 3.11.4~2) which
> directly dereferences the function pointers rather than using the
> corresponding function wrapper, so moving these fields around is technically
> an ABI break. This is probably not a usecase we care about though?

Right, we don't care about that use case.

The libgoabackend subset of the API has always been a semi-private / semi-privileged one that is only meant to be used from gnome-initial-setup or gnome-control-center because it lets you add / remove / modify an account. Other applications or libraries are meant to use the libgoa subset of the API that is a thin convenience wrapper around goa-daemon's D-Bus API. In a sandboxed / app bundle world we will only expose this later subset to the world.
Comment 34 Debarshi Ray 2015-07-31 11:27:23 UTC
(In reply to Christophe Fergeau from comment #18)
> Review of attachment 308260 [details] [review] [review]:
> 
> ::: src/goabackend/goaprovider.c
> @@ +471,3 @@
> +
> +static ShowAccountItem show_account_items[] = {
> +  {
> 
> Do you mean an anonymous structure (see below) or something different?
> 
> static struct
> {
>   ...
> } show_account_items[] = {
>   ...
> }

Yes, the anonymous structure. In the other instance where it is used in the file, I found it convenient to avoid inventing a decent name for an ad-hoc type. :)

But I see the limitations that it imposes if we want to sort the list. So, let's leave it the way it is currently in your patch. We can either make it anonymous later, or invent a name for the other structure.

> I'd prefer to keep the .label = xxx; style for initialization though, as
> this makes things a bit more readable imo.

I don't mind having those. Although, since designated initializers [1] are a C99 invention, I wonder what the general consensus is. A quick scan indicates that it might be an issue with g++, but we are not using it here.

[1] https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html
Comment 35 Debarshi Ray 2015-07-31 11:28:57 UTC
Review of attachment 308494 [details] [review]:

Oops. Thanks for catching it.
Comment 36 Debarshi Ray 2015-07-31 11:35:28 UTC
Review of attachment 308491 [details] [review]:

::: src/goabackend/goaprovider.c
@@ +465,3 @@
 
+typedef struct {
+  guint feature;

Sorry for not asking this earlier. Shouldn't this be a GoaProviderFeatures instead of a guint?

@@ +467,3 @@
+  guint feature;
+  const gchar  *property;
+  const gchar  *blurb;

Looks we have an extra space between 'gchar' and '*'.

@@ +474,3 @@
+   * important because it affects the order in which they are
+   * displayed in the show_account() UI
+   */

Thanks for adding the comment.
Comment 37 Debarshi Ray 2015-07-31 11:47:59 UTC
Review of attachment 308492 [details] [review]:

++
Comment 38 Debarshi Ray 2015-07-31 11:49:22 UTC
Review of attachment 308493 [details] [review]:

++
Comment 39 Christophe Fergeau 2015-07-31 18:14:03 UTC
Review of attachment 308491 [details] [review]:

::: src/goabackend/goaprovider.c
@@ +465,3 @@
 
+typedef struct {
+  guint feature;

No idea :) I'll change it.

@@ +467,3 @@
+  guint feature;
+  const gchar  *property;
+  const gchar  *blurb;

Ah, good catch, changed too
Comment 40 Christophe Fergeau 2015-07-31 18:14:42 UTC
Created attachment 308575 [details] [review]
provider: Add default implementation for GoaProvider::show_account()
Comment 41 Christophe Fergeau 2015-07-31 19:19:54 UTC
Created attachment 308578 [details] [review]
provider: Add default implementation for GoaProvider::show_account()
Comment 42 Christophe Fergeau 2015-07-31 19:20:26 UTC
Created attachment 308579 [details] [review]
provider: Sort show_account() entries depending on locale
Comment 43 Christophe Fergeau 2015-07-31 19:24:29 UTC
Ok, here are 2 variations of the "Add default implementation for GoaProvider::show_account()" patch, first one is the same as the previous version with your comments addressed. The second variations implements the 'anonymous struct' suggestion that you made. I've attached an updated 'sorted patch' to go with the 'anonymous struct' variation.
Comment 44 Debarshi Ray 2015-08-04 10:13:11 UTC
Comment on attachment 308488 [details] [review]
owncloud: Add uri_to_string_with_path() helper

Pushed to master.
Comment 45 Debarshi Ray 2015-08-04 10:13:28 UTC
Comment on attachment 308489 [details] [review]
owncloud: Introduce get_webdav_uri() helper

Pushed to master.
Comment 46 Debarshi Ray 2015-08-04 10:15:36 UTC
Comment on attachment 308494 [details] [review]
Fix typo in comment in goaprovider.c

Pushed to master.
Comment 47 Debarshi Ray 2015-08-04 10:26:21 UTC
Review of attachment 308578 [details] [review]:

Looks good to me.
Comment 48 Debarshi Ray 2015-08-04 10:26:45 UTC
Comment on attachment 308493 [details] [review]
Reorder GoaProviderClass fields as it's private now

Pushed to master.
Comment 49 Debarshi Ray 2015-08-04 10:27:32 UTC
Comment on attachment 308492 [details] [review]
providers: Use default implementation of ::show_account()

Pushed to master.
Comment 50 Debarshi Ray 2017-05-29 18:18:17 UTC
Review of attachment 308579 [details] [review]:

I am still hesitant about this one. Sometimes people attach screenshots from different locales and a static ordering of the buttons makes it easier to identify them. Also comment 12.

On the other hand, I am not strongly against it either. Leaving it as "reviewed" for the time being.