[gnote] Remove FUSE and related code



commit 202b1dc2f19d7acc34b5cc31b45dcc7c36276313
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sat Feb 6 14:14:46 2021 +0200

    Remove FUSE and related code

 src/Makefile.am                              |   2 -
 src/sharp/process.cpp                        | 273 ---------------------
 src/sharp/process.hpp                        | 102 --------
 src/synchronization/fusesyncserviceaddin.cpp | 344 ---------------------------
 src/synchronization/fusesyncserviceaddin.hpp |  83 -------
 src/synchronization/isyncmanager.hpp         |   3 +-
 src/synchronization/syncmanager.hpp          |   7 +-
 src/synchronization/syncutils.cpp            | 138 +----------
 src/synchronization/syncutils.hpp            |  19 +-
 9 files changed, 4 insertions(+), 967 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 1706d277..4b70ec5b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -83,7 +83,6 @@ libgnote_la_SOURCES = \
        sharp/map.hpp \
        sharp/modulefactory.hpp \
        sharp/modulemanager.hpp sharp/modulemanager.cpp \
-       sharp/process.hpp sharp/process.cpp \
        sharp/propertyeditor.hpp sharp/propertyeditor.cpp \
        sharp/streamreader.hpp sharp/streamreader.cpp \
        sharp/streamwriter.hpp sharp/streamwriter.cpp \
@@ -145,7 +144,6 @@ libgnote_la_SOURCES = \
        notebooks/notebooknoteaddin.hpp notebooks/notebooknoteaddin.cpp \
        notebooks/specialnotebooks.hpp notebooks/specialnotebooks.cpp \
        synchronization/filesystemsyncserver.hpp synchronization/filesystemsyncserver.cpp \
-       synchronization/fusesyncserviceaddin.hpp synchronization/fusesyncserviceaddin.cpp \
        synchronization/gvfssyncservice.hpp synchronization/gvfssyncservice.cpp \
        synchronization/isyncmanager.hpp synchronization/isyncmanager.cpp \
        synchronization/syncui.hpp synchronization/syncui.cpp \
diff --git a/src/synchronization/isyncmanager.hpp b/src/synchronization/isyncmanager.hpp
index 6c5e172c..cb9fa463 100644
--- a/src/synchronization/isyncmanager.hpp
+++ b/src/synchronization/isyncmanager.hpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2012-2014,2017,2019-2020 Aurimas Cernius
+ * Copyright (C) 2012-2014,2017,2019-2021 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
@@ -71,7 +71,6 @@ public:
   virtual void resolve_conflict(SyncTitleConflictResolution resolution) = 0;
   virtual bool synchronized_note_xml_matches(const Glib::ustring & noteXml1, const Glib::ustring & noteXml2) 
= 0;
   virtual SyncState state() const = 0;
-  virtual SyncUtils & utils() = 0;
 };
 
 class SyncServer
diff --git a/src/synchronization/syncmanager.hpp b/src/synchronization/syncmanager.hpp
index 142adcf9..ce584c43 100644
--- a/src/synchronization/syncmanager.hpp
+++ b/src/synchronization/syncmanager.hpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2012-2014,2017-2020 Aurimas Cernius
+ * Copyright (C) 2012-2014,2017-2021 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
@@ -53,10 +53,6 @@ namespace sync {
       {
         return m_state;
       }
-    virtual SyncUtils & utils() override
-      {
-        return m_utils;
-      }
   protected:
     virtual void initialize_sync_service_addins(NoteManagerBase &);
     virtual void connect_system_signals();
@@ -86,7 +82,6 @@ namespace sync {
     void get_synchronized_xml_bits(const Glib::ustring & noteXml, Glib::ustring & title, Glib::ustring & 
tags, Glib::ustring & content);
     void abort_sync(SyncServer *server);
 
-    SyncUtils m_utils;
     IGnote & m_gnote;
     NoteManagerBase & m_note_manager;
     SyncState m_state;
diff --git a/src/synchronization/syncutils.cpp b/src/synchronization/syncutils.cpp
index e98b8c88..91966830 100644
--- a/src/synchronization/syncutils.cpp
+++ b/src/synchronization/syncutils.cpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2012-2014,2016-2017,2019 Aurimas Cernius
+ * Copyright (C) 2012-2014,2016-2017,2019,2021 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
@@ -18,20 +18,8 @@
  */
 
 
-#include <algorithm>
-#include <vector>
-
-#include <glibmm/i18n.h>
-#include <glibmm/miscutils.h>
-#include <glibmm/regex.h>
-
-#include "debug.hpp"
 #include "notemanagerbase.hpp"
 #include "syncutils.hpp"
-#include "utils.hpp"
-#include "sharp/files.hpp"
-#include "sharp/process.hpp"
-#include "sharp/string.hpp"
 #include "sharp/xmlreader.hpp"
 
 namespace gnote {
@@ -107,129 +95,5 @@ namespace sync {
     return true;
   }
 
-
-  const char *SyncUtils::common_paths[] = {"/sbin", "/bin", "/usr/bin"};
-
-
-  bool SyncUtils::is_fuse_enabled()
-  {
-    try {
-      Glib::ustring fsFileName = "/proc/filesystems";
-      if(sharp::file_exists(fsFileName)) {
-        Glib::ustring fsOutput = sharp::file_read_all_text(fsFileName);
-        Glib::RefPtr<Glib::Regex> re = Glib::Regex::create("\\s+fuse\\s+", Glib::REGEX_MULTILINE);
-        return re->match(fsOutput);
-      }
-    }
-    catch(...) {}
-    return false;
-  }
-
-  bool SyncUtils::enable_fuse()
-  {
-    if(is_fuse_enabled()) {
-      return true; // nothing to do
-    }
-
-    if(m_guisu_tool == "" || m_modprobe_tool == "") {
-      DBG_OUT("Couldn't enable fuse; missing either GUI 'su' tool or modprobe");
-
-      // Let the user know that FUSE could not be enabled
-      utils::HIGMessageDialog cannotEnableDlg(NULL, GTK_DIALOG_MODAL, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK,
-        _("Could not enable FUSE"),
-        _("The FUSE module could not be loaded. Please check that it is installed properly and try again."));
-
-      cannotEnableDlg.run();
-      return false;
-    }
-
-    // Prompt the user first about enabling fuse
-    utils::HIGMessageDialog dialog(NULL, GTK_DIALOG_MODAL, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO,
-      _("Enable FUSE?"),
-      // TODO: This message isn't entirely accurate.
-      //       We should fix it.
-      _("The synchronization you've chosen requires the FUSE module to be loaded.\n\n"
-        "To avoid getting this prompt in the future, you should load FUSE at startup.  "
-        "Add \"modprobe fuse\" to /etc/init.d/boot.local or \"fuse\" to /etc/modules."));
-    int response = dialog.run();
-    if(response == Gtk::RESPONSE_YES) {
-      // "modprobe fuse"
-      sharp::Process p;
-      p.file_name(m_guisu_tool);
-      std::vector<Glib::ustring> args;
-      args.push_back(m_modprobe_tool);
-      args.push_back("fuse");
-      p.arguments(args);
-      p.start();
-      p.wait_for_exit();
-
-      if(p.exit_code() != 0) {
-        DBG_OUT("Couldn't enable fuse");
-
-        // Let the user know that they don't have FUSE installed on their machine
-        utils::HIGMessageDialog failedDlg(NULL, GTK_DIALOG_MODAL, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK,
-          _("Could not enable FUSE"),
-          _("The FUSE module could not be loaded. Please check that it is installed properly and try 
again."));
-        failedDlg.run();
-        return false;
-      }
-
-      // "echo fuse >> /etc/modules"
-      /*
-      // Punting for now.  Can't seem to get this to work.
-      // When using /etc/init.d/boot.local, you should add "modprobe fuse",
-      // and not what has been coded below.
-      p = new Process ();
-      p.StartInfo.UseShellExecute = false;
-      p.StartInfo.FileName = guisuTool;
-      p.StartInfo.Arguments = string.Format ("\"{0} fuse >> {1}\"",
-        echoTool, bootLocalFile);
-      p.StartInfo.CreateNoWindow = true;
-      p.Start ();
-      p.WaitForExit ();
-      if (p.ExitCode != 0) {
-       Logger.Warn ("Could not enable FUSE persistently.  User will have to be prompted again during their 
next login session.");
-      }
-      */
-      return true;
-    }
-
-    return false;
-  }
-
-  Glib::ustring SyncUtils::find_first_executable_in_path(const std::vector<Glib::ustring> & executableNames)
-  {
-    for(auto executable : executableNames) {
-      Glib::ustring pathVar = Glib::getenv("PATH");
-      std::vector<Glib::ustring> paths;
-      const char separator[] = {G_SEARCHPATH_SEPARATOR, 0};
-      sharp::string_split(paths, pathVar, separator);
-
-      for(unsigned i = 0; i < sizeof(common_paths) / sizeof(char*); ++i) {
-        Glib::ustring commonPath = common_paths[i];
-        if(std::find(paths.begin(), paths.end(), commonPath) == paths.end()) {
-          paths.push_back(commonPath);
-        }
-      }
-
-      for(auto path : paths) {
-        Glib::ustring testExecutablePath = Glib::build_filename(path, executable);
-        if(sharp::file_exists(testExecutablePath)) {
-          return testExecutablePath;
-        }
-      }
-      DBG_OUT("Unable to locate '%s' in your PATH", executable.c_str());
-    }
-
-    return "";
-  }
-
-  Glib::ustring SyncUtils::find_first_executable_in_path(const Glib::ustring & executableName)
-  {
-    std::vector<Glib::ustring> executable_names;
-    executable_names.push_back(executableName);
-    return find_first_executable_in_path(executable_names);
-  }
-
 }
 }
diff --git a/src/synchronization/syncutils.hpp b/src/synchronization/syncutils.hpp
index 125daf4c..1888b1d9 100644
--- a/src/synchronization/syncutils.hpp
+++ b/src/synchronization/syncutils.hpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2012-2013,2017,2019 Aurimas Cernius
+ * Copyright (C) 2012-2013,2017,2019,2021 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
@@ -22,8 +22,6 @@
 #define _SYNCHRONIZATION_SYNCUTILS_HPP_
 
 
-#include <vector>
-
 #include "note.hpp"
 
 
@@ -79,21 +77,6 @@ namespace sync {
     bool compare_tags(const std::map<Glib::ustring, Tag::Ptr> set1, const std::map<Glib::ustring, Tag::Ptr> 
set2) const;
   };
 
-
-  class SyncUtils
-  {
-  public:
-    bool is_fuse_enabled();
-    bool enable_fuse();
-    Glib::ustring find_first_executable_in_path(const std::vector<Glib::ustring> & executableNames);
-    Glib::ustring find_first_executable_in_path(const Glib::ustring & executableName);
-  private:
-    static const char *common_paths[];
-
-    Glib::ustring m_guisu_tool;
-    Glib::ustring m_modprobe_tool;
-  };
-
 }
 }
 


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