[gnote] Make SyncUtils non-singleton
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Make SyncUtils non-singleton
- Date: Sun, 17 Nov 2019 16:44:31 +0000 (UTC)
commit 64cbcda0465e382d30e68e18d7a7604c3db0bddb
Author: Aurimas Černius <aurisc4 gmail com>
Date: Sun Nov 17 18:15:31 2019 +0200
Make SyncUtils non-singleton
src/synchronization/fusesyncserviceaddin.cpp | 10 +++++-----
src/synchronization/isyncmanager.hpp | 1 +
src/synchronization/syncmanager.hpp | 5 +++++
src/synchronization/syncserviceaddin.hpp | 4 ++++
src/synchronization/syncutils.cpp | 3 ---
src/synchronization/syncutils.hpp | 5 +----
6 files changed, 16 insertions(+), 12 deletions(-)
---
diff --git a/src/synchronization/fusesyncserviceaddin.cpp b/src/synchronization/fusesyncserviceaddin.cpp
index 3769aad6..5c0358e6 100644
--- a/src/synchronization/fusesyncserviceaddin.cpp
+++ b/src/synchronization/fusesyncserviceaddin.cpp
@@ -99,9 +99,9 @@ void FuseSyncServiceAddin::post_sync_cleanup()
bool FuseSyncServiceAddin::is_supported()
{
// Check for fusermount and child-specific executable
- m_fuse_mount_exe_path = SyncUtils::obj().find_first_executable_in_path(fuse_mount_exe_name());
- m_fuse_unmount_exe_path = SyncUtils::obj().find_first_executable_in_path("fusermount");
- m_mount_exe_path = SyncUtils::obj().find_first_executable_in_path("mount");
+ m_fuse_mount_exe_path = sync_manager().utils().find_first_executable_in_path(fuse_mount_exe_name());
+ m_fuse_unmount_exe_path = sync_manager().utils().find_first_executable_in_path("fusermount");
+ m_mount_exe_path = sync_manager().utils().find_first_executable_in_path("mount");
return m_fuse_mount_exe_path != "" && m_fuse_unmount_exe_path != "" && m_mount_exe_path != "";
}
@@ -199,8 +199,8 @@ bool FuseSyncServiceAddin::mount_fuse(bool useStoredValues)
return false;
}
- if(SyncUtils::obj().is_fuse_enabled() == false) {
- if(SyncUtils::obj().enable_fuse() == false) {
+ if(sync_manager().utils().is_fuse_enabled() == false) {
+ if(sync_manager().utils().enable_fuse() == false) {
DBG_OUT("User canceled or something went wrong enabling FUSE");
throw GnoteSyncException(_("FUSE could not be enabled."));
}
diff --git a/src/synchronization/isyncmanager.hpp b/src/synchronization/isyncmanager.hpp
index 1a6eee70..db9dd0b7 100644
--- a/src/synchronization/isyncmanager.hpp
+++ b/src/synchronization/isyncmanager.hpp
@@ -71,6 +71,7 @@ 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 c196d5e4..db00e9fe 100644
--- a/src/synchronization/syncmanager.hpp
+++ b/src/synchronization/syncmanager.hpp
@@ -53,6 +53,10 @@ 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();
@@ -82,6 +86,7 @@ namespace sync {
NoteManagerBase & note_mgr();
void get_synchronized_xml_bits(const Glib::ustring & noteXml, Glib::ustring & title, Glib::ustring &
tags, Glib::ustring & content);
+ SyncUtils m_utils;
IGnote & m_gnote;
NoteManagerBase & m_note_manager;
SyncState m_state;
diff --git a/src/synchronization/syncserviceaddin.hpp b/src/synchronization/syncserviceaddin.hpp
index 06da00ee..3b950c4c 100644
--- a/src/synchronization/syncserviceaddin.hpp
+++ b/src/synchronization/syncserviceaddin.hpp
@@ -49,6 +49,10 @@ namespace sync {
m_sync_manager = &sync_manager;
}
+ virtual ISyncManager & sync_manager()
+ {
+ return *m_sync_manager;
+ }
virtual SyncServer::Ptr create_sync_server() = 0;
virtual void post_sync_cleanup() = 0;
virtual Gtk::Widget *create_preferences_control(EventHandler requiredPrefChanged) = 0;
diff --git a/src/synchronization/syncutils.cpp b/src/synchronization/syncutils.cpp
index b1737b5d..e98b8c88 100644
--- a/src/synchronization/syncutils.cpp
+++ b/src/synchronization/syncutils.cpp
@@ -110,9 +110,6 @@ namespace sync {
const char *SyncUtils::common_paths[] = {"/sbin", "/bin", "/usr/bin"};
- //instance
- SyncUtils SyncUtils::s_obj;
-
bool SyncUtils::is_fuse_enabled()
{
diff --git a/src/synchronization/syncutils.hpp b/src/synchronization/syncutils.hpp
index 05594a19..125daf4c 100644
--- a/src/synchronization/syncutils.hpp
+++ b/src/synchronization/syncutils.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
@@ -25,7 +25,6 @@
#include <vector>
#include "note.hpp"
-#include "base/singleton.hpp"
namespace gnote {
@@ -82,7 +81,6 @@ namespace sync {
class SyncUtils
- : public base::Singleton<SyncUtils>
{
public:
bool is_fuse_enabled();
@@ -91,7 +89,6 @@ namespace sync {
Glib::ustring find_first_executable_in_path(const Glib::ustring & executableName);
private:
static const char *common_paths[];
- static SyncUtils s_obj;
Glib::ustring m_guisu_tool;
Glib::ustring m_modprobe_tool;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]