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 658911 - google: Always readonly addressbooks with goa
google: Always readonly addressbooks with goa
Status: RESOLVED FIXED
Product: evolution-data-server
Classification: Platform
Component: Contacts
unspecified
Other Linux
: Normal normal
: ---
Assigned To: evolution-addressbook-maintainers
Evolution QA team
Depends on:
Blocks:
 
 
Reported: 2011-09-13 12:27 UTC by Alexander Larsson
Modified: 2011-09-13 14:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix for readonly goa addressbooks (687 bytes, patch)
2011-09-13 12:27 UTC, Alexander Larsson
none Details | Review

Description Alexander Larsson 2011-09-13 12:27:21 UTC
Created attachment 196361 [details] [review]
Fix for readonly goa addressbooks

I have a problem with my goa based google contacts addressbook. It always ends
up as readonly. I think I have tracked this down, as follows:

Early on when creating the backend the code calls 
e_book_backend_google_set_online () with is_online == TRUE.

Which does:

if (is_online && e_book_backend_is_opened (backend)) {
  request_authorization (backend);
} else {
  /* Going offline, so cancel all running operations */
  google_cancel_all_operations (backend);

  /* Mark the book as unwriteable if we're going offline, but don't do the inverse when we go online;
   * e_book_backend_google_authenticate_user() will mark us as writeable again once the user's authenticated again. */
  e_book_backend_notify_readonly (backend, TRUE);

Since this is the first call to the backend is_opened() returns false and
we set readonly = TRUE and continue. Eventually the backend becomes opened and 
e_book_backend_google_open gets called. This ends up doing:

  if (priv->is_online) {
    request_authorization (backend);

Which we hit (since we're online). However, request_authorization ends with:

#ifdef HAVE_GOA
  /* If we're using OAuth tokens, then as far as the backend
   * is concerned it's always authorized.  The GDataAuthorizer
   * will take care of everything in the background without
   * bothering clients with "auth-required" signals. */
  if (E_IS_GDATA_GOA_AUTHORIZER (priv->authorizer))
    return;
#endif

Which causes e_book_backend_google_authenticate_user to never get called, and thus not authenticate_client_login_cb, and thus we never set !readonly as the above comment said we would.

We also don't call e_book_backend_notify_opened in this way, as that also happens after authentication. However this is handled a bit down in e_book_backend_google_open where the following was added with the GOA changes:

  if (!priv->is_online || backend_is_authorized (backend))
    e_book_backend_notify_opened (backend, NULL /* Success */);

I think this should also set readonly to true. Doing this make things work for me. Patch attached.
Comment 1 Matthew Barnes 2011-09-13 14:09:03 UTC
That makes sense to me.  Thanks for the thorough analysis... I guess I didn't test this much beyond "did it authenticate with OAuth?".

Patch committed for 3.1.92:
http://git.gnome.org/browse/evolution-data-server/commit/?id=499e1290d64ae3e9bb4c2753c08933f54db0bc86