[geary/gnumdk/gmail_goa_only] client: accounts: No fallback for GMail if GOA is missing




commit 5e63be98f560701b448b346f5497b55f8f8a8070
Author: Cédric Bellegarde <cedric bellegarde adishatz org>
Date:   Sat Jul 9 13:26:46 2022 +0200

    client: accounts: No fallback for GMail if GOA is missing
    
    GMail does not support "Less secure apps" anymore, so do not fallback to
    local account manager if GNOME Online Accounts is missing.
    
    https://support.google.com/accounts/answer/6010255

 src/client/accounts/accounts-editor-list-pane.vala | 33 ++++++++++++++++++----
 1 file changed, 28 insertions(+), 5 deletions(-)
---
diff --git a/src/client/accounts/accounts-editor-list-pane.vala 
b/src/client/accounts/accounts-editor-list-pane.vala
index c156eeaff..2e3be0536 100644
--- a/src/client/accounts/accounts-editor-list-pane.vala
+++ b/src/client/accounts/accounts-editor-list-pane.vala
@@ -11,6 +11,12 @@
 [GtkTemplate (ui = "/org/gnome/Geary/accounts_editor_list_pane.ui")]
 internal class Accounts.EditorListPane : Gtk.Grid, EditorPane, CommandPane {
 
+    private static Geary.ServiceProvider[] SERVICE_PROVIDERS = {
+        Geary.ServiceProvider.GMAIL,
+        Geary.ServiceProvider.OUTLOOK,
+        Geary.ServiceProvider.YAHOO,
+        Geary.ServiceProvider.OTHER
+    };
 
     private static int ordinal_sort(Gtk.ListBoxRow a, Gtk.ListBoxRow b) {
         AccountListRow? account_a = a as AccountListRow;
@@ -98,10 +104,19 @@ internal class Accounts.EditorListPane : Gtk.Grid, EditorPane, CommandPane {
         }
 
         this.service_list.set_header_func(Editor.seperator_headers);
-        this.service_list.add(new AddServiceProviderRow(Geary.ServiceProvider.GMAIL));
-        this.service_list.add(new AddServiceProviderRow(Geary.ServiceProvider.OUTLOOK));
-        this.service_list.add(new AddServiceProviderRow(Geary.ServiceProvider.YAHOO));
-        this.service_list.add(new AddServiceProviderRow(Geary.ServiceProvider.OTHER));
+        foreach (var service_provider in SERVICE_PROVIDERS) {
+            var service_provider_row = new AddServiceProviderRow(service_provider);
+            this.service_list.add(service_provider_row);
+            service_provider_row.goa_missing.connect (() => {
+                this.editor.add_notification(
+                        new Components.InAppNotification(
+                            // Translators: In-app notification label, when
+                            // GNOME Online Accounts are missing
+                            _("Online accounts are missing")
+                        )
+                    );
+            });
+        }
 
         this.accounts.account_added.connect(on_account_added);
         this.accounts.account_status_changed.connect(on_account_status_changed);
@@ -434,6 +449,7 @@ private class Accounts.AddServiceProviderRow : EditorRow<EditorListPane> {
         "go-next-symbolic", Gtk.IconSize.SMALL_TOOLBAR
     );
 
+    public signal void goa_missing();
 
     public AddServiceProviderRow(Geary.ServiceProvider provider) {
         this.provider = provider;
@@ -481,7 +497,14 @@ private class Accounts.AddServiceProviderRow : EditorRow<EditorListPane> {
                 } catch (GLib.Error err) {
                     debug("Failed to add %s via GOA: %s",
                           this.provider.to_string(), err.message);
-                    add_local = true;
+                    switch (this.provider) {
+                    case Geary.ServiceProvider.GMAIL:
+                        this.goa_missing();
+                        break;
+                    default:
+                        add_local = true;
+                        break;
+                    }
                 }
 
                 if (add_local) {


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