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 659079 - Read all gContact:website
Read all gContact:website
Status: RESOLVED FIXED
Product: evolution-data-server
Classification: Platform
Component: Contacts
3.2.x (obsolete)
Other Linux
: Normal normal
: ---
Assigned To: evolution-addressbook-maintainers
Evolution QA team
Depends on:
Blocks: 659040
 
 
Reported: 2011-09-14 18:18 UTC by Alexander Larsson
Modified: 2013-09-14 16:53 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
proposed eds patch (4.00 KB, patch)
2011-09-15 09:50 UTC, Milan Crha
rejected Details | Review
proposed eds patch ][ (5.21 KB, patch)
2011-09-15 15:27 UTC, Milan Crha
committed Details | Review
Incremental patch (1004 bytes, patch)
2011-09-15 17:39 UTC, Alexander Larsson
none Details | Review
eds patch for no-type defined (3.15 KB, patch)
2011-09-16 06:40 UTC, Milan Crha
none Details | Review
New patch (7.36 KB, patch)
2011-09-16 09:20 UTC, Alexander Larsson
committed Details | Review

Description Alexander Larsson 2011-09-14 18:18:05 UTC
The current backend only saves the gcontact:Website with rel=blog or rel=home-page because these correspond to known evolution fields, the rest are dropped.

This is sad because i'm very interested in the rel="profile" links.

It would be cool if the backend could drop the rest of the links in X-URIS vcard attribute, because that is what folks is using for it.
Comment 1 Milan Crha 2011-09-15 07:04:19 UTC
If Philip will not find time for this till tomorrow, then I'll fix this for 3.2.0 on Friday. The change is more or less trivial anyway.

By the way, how does the folks distinguish between address types? I suppose they have there some parameter in the X-URIS, do they? Maybe if you have an example what is mapped how, then we can mimic it for compatibility. It's fine to see how respective addresses are stored in these attributes of a vCard.
Comment 2 Philip Withnall 2011-09-15 07:29:23 UTC
(In reply to comment #1)
> If Philip will not find time for this till tomorrow, then I'll fix this for
> 3.2.0 on Friday. The change is more or less trivial anyway.

That would be great, thanks. If you need patch review, let me know.

> By the way, how does the folks distinguish between address types? I suppose
> they have there some parameter in the X-URIS, do they? Maybe if you have an
> example what is mapped how, then we can mimic it for compatibility. It's fine
> to see how respective addresses are stored in these attributes of a vCard.

The code to parse X-URIS is here: http://git.gnome.org/browse/folks/tree/backends/eds/lib/edsf-persona.vala#n1169
The code to set X-URIS is here: http://git.gnome.org/browse/folks/tree/backends/eds/lib/edsf-persona-store.vala#n1092

So folks uses the multi-valued attribute parameter “TYPE” of X-URIS to distinguish address types; which iirc is fairly standard.

The values it uses for TYPE are here: http://git.gnome.org/browse/folks/tree/backends/eds/lib/edsf-persona.vala#n60

If any more values need adding, or if those values need changing, or if using TYPE is wrong, or if X-URIS needs renaming, please say so now since it's probably just about still possible to change in folks.
Comment 3 Milan Crha 2011-09-15 08:54:46 UTC
(In reply to comment #2)
> (In reply to comment #1)
> > If Philip will not find time for this till tomorrow, then I'll fix this for
> > 3.2.0 on Friday. The change is more or less trivial anyway.
> 
> That would be great, thanks. If you need patch review, let me know.

OK, I'll do it now, so we have a little more time for testing.

> > By the way, how does the folks distinguish between address types? I suppose
> > they have there some parameter in the X-URIS, do they? Maybe if you have an
> > example what is mapped how, then we can mimic it for compatibility. It's fine
> > to see how respective addresses are stored in these attributes of a vCard.
> 
> The code to parse X-URIS is here:
> http://git.gnome.org/browse/folks/tree/backends/eds/lib/edsf-persona.vala#n1169
> The code to set X-URIS is here:
> http://git.gnome.org/browse/folks/tree/backends/eds/lib/edsf-persona-store.vala#n1092

I do not know vala at all, but do I understand it right that if the url is homepage/blog/fburl/video then the newly allocated 'attr' is leaked? It seems so to me, but I do not know how vala handles memory management and garbage collections.

> So folks uses the multi-valued attribute parameter “TYPE” of X-URIS to
> distinguish address types; which iirc is fairly standard.

Yup, that's really a standard way of doing such thing. Furthermore, as this begins with "X-", then you can do pretty anything with it.

> If any more values need adding, or if those values need changing, or if using
> TYPE is wrong, or if X-URIS needs renaming, please say so now since it's
> probably just about still possible to change in folks.

Everything seems fine on the folks side, except of the memory question I wrote above. From the vCard point of view is everything right, as far as I can tell. And thanks a lot for pointers.
Comment 4 Milan Crha 2011-09-15 09:50:22 UTC
Created attachment 196600 [details] [review]
proposed eds patch

for evolution-data-server;

Could you try this, please? I tested it against Google itself, but I do not know whether it's 100% compatible with folks, thus a little bit of testing with it is much appreciated. Thanks in advance.
Comment 5 Alexander Larsson 2011-09-15 12:35:44 UTC
Review of attachment 196600 [details] [review]:

The whole remove_websites stuff needs to go, we now store all the websites so we should rewrite them all when we save.
Otherwise we will be unable to remove a X-URIS website.

Furthermore, Its definately allowed to save multple links in a contact with the same "rel" value, so this is currently broken for multiple home-page or blog links.
Comment 6 Milan Crha 2011-09-15 15:27:16 UTC
Created attachment 196645 [details] [review]
proposed eds patch ][

for evolution-data-server;

This fixes the above mentioned issue I didn't think of initially. Unfortunately, the local cache is vanished if it is not of the "expected" version. There seem to be issues with updates, which are not propagated to evo when done on the server, but I'm not going to fix everything here, only this X-URIS issue.
Comment 7 Alexander Larsson 2011-09-15 16:32:58 UTC
Patch looks good to me
Comment 8 Alexander Larsson 2011-09-15 17:19:49 UTC
Works in testing here, and mbarnes was ok with it, so i pushed this to master.
Comment 9 Alexander Larsson 2011-09-15 17:24:38 UTC
Actually, there seems to be some issue with adding a link field via folks. Looking into it now.
Comment 10 Philip Withnall 2011-09-15 17:35:11 UTC
Review of attachment 196645 [details] [review]:

No need to change anything now, but just for future reference:

::: addressbook/backends/google/e-book-backend-google.c
@@ +2851,3 @@
+
+				website = gdata_gcontact_website_new (url, param->data, NULL, FALSE);
+				if (website) {

gdata_gcontact_website_new() never returns NULL, so this check's redundant.
Comment 11 Alexander Larsson 2011-09-15 17:39:17 UTC
Created attachment 196659 [details] [review]
Incremental patch

Ah, it failed because folks didn't supply a type and the "rel" property is mandatory. Lets make it "other" in case its not there, Tested it with contacts, and it now works.
Comment 12 Philip Withnall 2011-09-15 18:11:20 UTC
Review of attachment 196659 [details] [review]:

::: addressbook/backends/google/e-book-backend-google.c
@@ +2848,2 @@
 			param = e_vcard_attribute_get_param (attr, EVC_TYPE);
+			type = param ? param->data : "other";

Might be better to map from the types which folks uses to the GDATA_GCONTACT_WEBSITE_* #defines in libgdata (http://git.gnome.org/browse/libgdata/tree/gdata/gcontact/gdata-gcontact-website.h#n40).

If the folks type is unknown, it should either map to GDATA_GCONTACT_WEBSITE_OTHER, or (preferably?) be set as the label for the website instead. Using labels would need some changes to _e_contact_new_from_gdata_entry() to do the conversion in the opposite direction, though.
Comment 13 Alexander Larsson 2011-09-16 06:27:04 UTC
True, google will probably throw an error if we put in some random type in the rel field. However, tha vcard TYPE attribute is not really meant to be a display label, so showing it as such is not ideal.

This is related to bug 653623 where we want to define what types means for urls in folks.
Comment 14 Milan Crha 2011-09-16 06:40:59 UTC
Created attachment 196690 [details] [review]
eds patch for no-type defined

for evolution-data-server;

What about this version then? And thinking of it, there is lost some information for those types in evolution's blog/home url addresses, like the label and primary website. Might not be an issue, though.
Comment 15 Alexander Larsson 2011-09-16 07:01:42 UTC
EVC_LABEL == LABEL == vcard field for physical address, don't use that.
the google backend uses GOOGLE_LABEL_PARAM == "X-GOOGLE-LABEL", see add_label_param().

Also, i'm not sure this is right. Because you save something with X-URIS http://foo type=bar and get back something X-URIS http://foo x-google-label=bar

Let me think on this some more.
Comment 16 Alexander Larsson 2011-09-16 07:13:53 UTC
Actually, in theory you can save any vcard style parameter on the url field and its assumed to be saved, but we lose any but type...
Comment 17 Alexander Larsson 2011-09-16 09:20:38 UTC
Created attachment 196700 [details] [review]
New patch

This patch uses X-GOOGLE-LABEL, and handles primary better.
It also looks more like the rest of the google backend, sharing the same
helper functions.
Comment 18 Milan Crha 2011-09-16 09:42:57 UTC
I would say yes, for both using X-GOOGLE-LABEL, then also for deeply integrated patch, but I would like to see Philip's idea too. If he approves, then please commit before Monday release (hard code freeze). Thanks.
Comment 19 Philip Withnall 2011-09-16 20:48:29 UTC
Review of attachment 196700 [details] [review]:

A few small comments to fix, but it otherwise looks good to me. Please commit.

::: addressbook/backends/google/e-book-backend-google.c
@@ +2851,1 @@
+			website =gdata_gc_contact_website_from_attribute (attr, &have_uri_primary);

Missing space after the equals sign.

@@ +3346,3 @@
+	{ "home", { "HOME", NULL }},
+	{ "other", { "OTHER", NULL }},
+	{ "work", { "WORK", NULL }},

It would be nice to use the #defines which libgdata provides here (e.g. GDATA_GCONTACT_WEBSITE_HOME_PAGE instead of "home-page").

@@ +3735,3 @@
+		return;
+
+	attr = e_vcard_attribute_new (NULL, "X-URIS");

Would be nice to move the "X-URIS" out into a #define at the top of the file to prevent typos of it anywhere.

@@ +3744,3 @@
+
+	if (attr)
+		e_vcard_add_attribute (vcard, attr);

Could attr ever be NULL here?
Comment 20 Philip Withnall 2011-09-16 20:53:24 UTC
(In reply to comment #16)
> Actually, in theory you can save any vcard style parameter on the url field and
> its assumed to be saved, but we lose any but type...

There's not much we can do about it, since (afaik, though I haven't actually tested it) Google don't support arbitrary attributes on XML elements.

(In reply to comment #18)
> I would say yes, for both using X-GOOGLE-LABEL, then also for deeply integrated
> patch, but I would like to see Philip's idea too. If he approves, then please
> commit before Monday release (hard code freeze). Thanks.

Falling back to using X-GOOGLE-LABEL if we don't understand a TYPE is a reasonable change which should be made to the entire backend. Probably a bit late in the cycle to spend time on it now. I've filed bug #659285 about it, and I'll try and look at that next cycle.
Comment 21 Philip Withnall 2011-09-18 16:38:31 UTC
Comment on attachment 196700 [details] [review]
New patch

Committed with the suggested fixes from comment #19.

commit a7312a51508974847ed6c63837eb5e88ac6f6609
Author: Alexander Larsson <alexl@redhat.com>
Date:   Sun Sep 18 17:36:47 2011 +0100

    Bug 659079 — Read all gContact:website
    
    Convert the website code in EDS' Google Contacts backend to support TYPEs
    and generally use the existing framework code.
    
    Closes: bgo#659079

 .../backends/google/e-book-backend-google.c        |  127 ++++++++++++++++----
 1 files changed, 104 insertions(+), 23 deletions(-)
Comment 22 Philip Withnall 2011-09-18 16:39:09 UTC
(I also renamed some of the non-standard types to use an ‘X-’ prefix; e.g. ‘X-HOME-PAGE’.)