GNOME Bugzilla – Bug 658911
google: Always readonly addressbooks with goa
Last modified: 2011-09-13 14:09:03 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.
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