[Evolution-hackers] libebook master: obsolete vCard used despite updated properties


I tested SyncEvolution against current EDS master and found a problem:
setting a UID before committing an updated contact has no effect.

The sequence of events is this:
     1. e_contact_new_from_vcard() where the vCard contains no UID.
     2. e_contact_set(E_CONTACT_UID, <uid>) -> g_object_set()
     3. e_book_commit_contact() -> e_vcard_to_string() -> D-Bus

In step 3, e_vcard_to_string() returns the cached evc->priv->vcard
without the UID although it has a UID in its attributes

I think the culprit is this commit here:

commit cca25e98a71d8c06f9ce1b53658ec4675f2dd5c2
Author: Bartosz Szatkowski <bulislaw linux com>
Date:   Tue Oct 18 12:29:07 2011 +0200

    Bug #656603 - Add support for generating vCard 2.1 in libebook


@@ -1016,17 +1246,16 @@ e_vcard_to_string (EVCard *evc,
        g_return_val_if_fail (E_IS_VCARD (evc), NULL);
-       /* If the vcard is not parsed yet, and if we don't have a UID in priv->attributes
-       return priv->vcard directly */
-       /* XXX: The format is ignored but it does not really matter
-        * since only 3.0 is supported at the moment */
-       if (evc->priv->vcard != NULL && evc->priv->attributes == NULL)
-               return g_strdup (evc->priv->vcard);
        switch (format) {
        case EVC_FORMAT_VCARD_21:
+               if (evc->priv->vcard && strstr_nocase (evc->priv->vcard, CRLF "VERSION:2.1" CRLF))
+                       return g_strdup (evc->priv->vcard);
                return e_vcard_to_string_vcard_21 (evc);
        case EVC_FORMAT_VCARD_30:
+               if (evc->priv->vcard && strstr_nocase (evc->priv->vcard, CRLF "VERSION:3.0" CRLF))
+                       return g_strdup (evc->priv->vcard);
                return e_vcard_to_string_vcard_30 (evc);
                g_warning ("invalid format specifier passed to e_vcard_to_string");

It removes the check for evc->priv->attributes. Adding that check back
fixes the problem.

Question: why does the removed comment only mention UID? Isn't any
contact modification detected by checking evc->priv->attributes?

Bye, Patrick Ohly
Patrick Ohly gmx de

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]