GNOME Bugzilla – Bug 777492
Notify when an online account needs attention
Last modified: 2017-02-16 16:33:33 UTC
We should show a notification when an online account's credentials don't work anymore. It could be due to the expiry of an OAuth2 token having expired, or due to the password having changed. Currently, you can only check if an account needs attention by going to Settings -> Online Accounts. The notification should say something like: "Your google credentials have expired. [open settings]" Look at the existing code in gnome-photos to launch the Online Accounts panel. Also the following gnome-online-accounts API will be useful: (a) GoaClient::account-changed signal: https://developer.gnome.org/goa/stable/GoaClient.html#GoaClient-account-changed (b) GoaAccount:attention-needed property: https://developer.gnome.org/goa/stable/GoaAccount.html#GoaAccount--attention-needed To force an account to expire for testing, you can use seahorse to delete the credential. Search for 'goa' and look for the account. Then invoke the EnsureCredentials D-Bus method. See: https://wiki.gnome.org/Projects/GnomeOnlineAccounts/Debugging
Created attachment 343947 [details] [review] Add PhotosSourceNotification
Created attachment 343948 [details] [review] Notify when an online account needs attention
Review of attachment 343948 [details] [review]: Thanks for working on this Umang. The patches look quite good as a first attempt. Some comments below: ::: src/photos-source-manager.c @@ +104,3 @@ + if (goa_account_get_attention_needed (account)) + { The problem with doing it this way is that if two different online accounts have their credentials expired, then the notifications will get duplicated. eg., you are already showing a notification for Google, when the credentials for Facebook expires - you will end up with two for Google. We need a way to track which notifications are being shown, etc.. One option is to use a GHashTable that maps the ID of the PhotosSource to the PhotosSourceNotification.
Review of attachment 343948 [details] [review]: ::: src/photos-source-manager.c @@ +104,3 @@ + if (goa_account_get_attention_needed (account)) + { Once the user takes care of the problem, we should withdraw the notification if it hasn't already timed out or been closed. That's another reason why we need the tracking.
Review of attachment 343947 [details] [review]: ::: src/photos-source-notification.c @@ +101,3 @@ + + error = NULL; + app = g_app_info_create_from_commandline ("gnome-control-center online-accounts", It would be even better if we selected the affected account: gnome-control-center online-accounts account_1483638297_0 The third argument is the ID of the GoaAccount. @@ +181,3 @@ + g_signal_connect_swapped (close, "clicked", G_CALLBACK (photos_source_notification_close), self); + + photos_notification_manager_add_notification (PHOTOS_NOTIFICATION_MANAGER (self->ntfctn_mngr), GTK_WIDGET (self)); I think it will be easier if we implement this notification slightly differently from the others. All our existing notifications (except IndexingNotification) are self-managing. ie., they add themselves to NotificationManager, and at some point call gtk_widget_destroy on themselves. However, given that we need to track these notifications in SourceManager, it will be much easier if we let SourceManager manage the addition, timeout, etc.. See below. @@ +256,3 @@ + + +void Let's return 'GtkWidget *' instead.
Created attachment 345956 [details] [review] Add PhotosSourceNotification
Created attachment 345957 [details] [review] source-manager: Keep track of sources that need attention
Created attachment 345958 [details] [review] embed: Notify when a source needs attention
There is an added complication when using GTK+ from inside PhotosSourceManager. It is created before gtk_init, and it is used by the gnome-shell search provider which doesn't have a GtkWindow.
Created attachment 345960 [details] [review] embed: Notify when a source needs attention
Created attachment 345963 [details] Screenshot