[gnote] Add support for async testing of sync settings



commit 98818d05765206b259a4cfde30460de9402b0143
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Wed Sep 4 23:26:55 2019 +0300

    Add support for async testing of sync settings

 src/preferencesdialog.cpp                    | 13 ++++++++++++-
 src/preferencesdialog.hpp                    |  3 ++-
 src/synchronization/fusesyncserviceaddin.cpp |  3 ++-
 src/synchronization/fusesyncserviceaddin.hpp |  2 +-
 src/synchronization/syncserviceaddin.hpp     |  4 ++--
 5 files changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/src/preferencesdialog.cpp b/src/preferencesdialog.cpp
index 925d3305..da249a27 100644
--- a/src/preferencesdialog.cpp
+++ b/src/preferencesdialog.cpp
@@ -1192,7 +1192,8 @@ namespace gnote {
     try {
       get_window()->set_cursor(Gdk::Cursor::create(Gdk::WATCH));
       get_window()->get_display()->flush();
-      saved = m_selected_sync_addin->save_configuration();
+      set_sensitive(false);
+      saved = m_selected_sync_addin->save_configuration(sigc::mem_fun(*this, 
&PreferencesDialog::on_sync_settings_saved));
     }
     catch(sync::GnoteSyncException & e) {
       errorMsg = e.what();
@@ -1200,6 +1201,16 @@ namespace gnote {
     catch(std::exception & e) {
       DBG_OUT("Unexpected error calling %s.save_configuration: %s", m_selected_sync_addin->id().c_str(), 
e.what());
     }
+
+    if(!saved) {
+      on_sync_settings_saved(saved, errorMsg);
+    }
+  }
+
+
+  void PreferencesDialog::on_sync_settings_saved(bool saved, Glib::ustring errorMsg)
+  {
+    set_sensitive(true);
     get_window()->set_cursor(Glib::RefPtr<Gdk::Cursor>());
     get_window()->get_display()->flush();
 
diff --git a/src/preferencesdialog.hpp b/src/preferencesdialog.hpp
index ac83af79..a0855ee0 100644
--- a/src/preferencesdialog.hpp
+++ b/src/preferencesdialog.hpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2011-2013,2015-2017 Aurimas Cernius
+ * Copyright (C) 2011-2013,2015-2017,2019 Aurimas Cernius
  * Copyright (C) 2009 Hubert Figuiere
  *
  * This program is free software: you can redistribute it and/or modify
@@ -70,6 +70,7 @@ private:
   void on_advanced_sync_config_button();
   void on_reset_sync_addin_button(bool signal);
   void on_save_sync_addin_button();
+  void on_sync_settings_saved(bool saved, Glib::ustring errorMsg);
 
   void on_preferences_setting_changed(const Glib::ustring & key);
   void on_rename_behavior_changed();
diff --git a/src/synchronization/fusesyncserviceaddin.cpp b/src/synchronization/fusesyncserviceaddin.cpp
index dc705e36..812882cf 100644
--- a/src/synchronization/fusesyncserviceaddin.cpp
+++ b/src/synchronization/fusesyncserviceaddin.cpp
@@ -105,7 +105,7 @@ bool FuseSyncServiceAddin::is_supported()
   return m_fuse_mount_exe_path != "" && m_fuse_unmount_exe_path != "" && m_mount_exe_path != "";
 }
 
-bool FuseSyncServiceAddin::save_configuration()
+bool FuseSyncServiceAddin::save_configuration(const sigc::slot<void, bool, Glib::ustring> & on_saved)
 {
   // TODO: When/how best to handle this?
   if(!is_supported()) {
@@ -167,6 +167,7 @@ bool FuseSyncServiceAddin::save_configuration()
 
     // Finish save process
     save_configuration_values();
+    on_saved(true, "");
   }
 
   return mounted;
diff --git a/src/synchronization/fusesyncserviceaddin.hpp b/src/synchronization/fusesyncserviceaddin.hpp
index 82610b11..47589cdf 100644
--- a/src/synchronization/fusesyncserviceaddin.hpp
+++ b/src/synchronization/fusesyncserviceaddin.hpp
@@ -43,7 +43,7 @@ public:
   virtual SyncServer::Ptr create_sync_server() override;
   virtual void post_sync_cleanup() override;
   virtual bool is_supported() override;
-  virtual bool save_configuration() override;
+  virtual bool save_configuration(const sigc::slot<void, bool, Glib::ustring> & on_saved) override;
   virtual void reset_configuration() override;
 
   virtual Glib::ustring fuse_mount_timeout_error();
diff --git a/src/synchronization/syncserviceaddin.hpp b/src/synchronization/syncserviceaddin.hpp
index 306039b6..3bbf7fe1 100644
--- a/src/synchronization/syncserviceaddin.hpp
+++ b/src/synchronization/syncserviceaddin.hpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2012-2013,2017 Aurimas Cernius
+ * Copyright (C) 2012-2013,2017,2019 Aurimas Cernius
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -42,7 +42,7 @@ namespace sync {
     virtual SyncServer::Ptr create_sync_server() = 0;
     virtual void post_sync_cleanup() = 0;
     virtual Gtk::Widget *create_preferences_control(EventHandler requiredPrefChanged) = 0;
-    virtual bool save_configuration() = 0;
+    virtual bool save_configuration(const sigc::slot<void, bool, Glib::ustring> & on_saved) = 0;
     virtual void reset_configuration() = 0;
     virtual bool is_configured() = 0;
     virtual bool are_settings_valid()


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