From b8295ad613323c7a2d637caa06b918019e9dbaf2 Mon Sep 17 00:00:00 2001
From: yuanxing <yuanxing@kylinsec.com.cn>
Date: Thu, 14 Sep 2023 18:51:56 +0800
Subject: [PATCH] fix(plugin):remove active or deactive mate plugin code
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

- 移除 激活/不激活 mate插件代码
---
 plugins/appearance/appearance-plugin.cpp      | 26 +------------------
 plugins/clipboard/clipboard-plugin.cpp        | 26 +------------------
 plugins/display/display-plugin.cpp            | 26 +------------------
 .../inputdevices/keyboard/keyboard-plugin.cpp | 26 +------------------
 plugins/inputdevices/mouse/mouse-plugin.cpp   | 25 +-----------------
 .../inputdevices/touchpad/touchpad-plugin.cpp | 26 +------------------
 plugins/keybinding/keybinding-plugin.cpp      | 26 +------------------
 plugins/xsettings/xsettings-plugin.cpp        | 26 +------------------
 8 files changed, 8 insertions(+), 199 deletions(-)

diff --git a/plugins/appearance/appearance-plugin.cpp b/plugins/appearance/appearance-plugin.cpp
index 8f3e123..f5dcdaa 100644
--- a/plugins/appearance/appearance-plugin.cpp
+++ b/plugins/appearance/appearance-plugin.cpp
@@ -19,9 +19,6 @@
 
 PLUGIN_EXPORT_FUNC_DEF(AppearancePlugin);
 
-#define MATE_BACKGROUND_SCHEMA_ID "org.mate.SettingsDaemon.plugins.background"
-#define MATE_BACKGROUND_SCHEMA_KEY_ACTIVE "active"
-
 namespace Kiran
 {
 AppearancePlugin::AppearancePlugin()
@@ -36,17 +33,6 @@ void AppearancePlugin::activate()
 {
     KLOG_PROFILE("active appearance plugin.");
 
-    // kiran和mate的插件最好不要同时运行，如果开启了kiran的插件，则将mate的插件停用
-    auto schemas = Gio::Settings::list_schemas();
-    if (std::find(schemas.begin(), schemas.end(), MATE_BACKGROUND_SCHEMA_ID) != schemas.end())
-    {
-        auto mate_background = Gio::Settings::create(MATE_BACKGROUND_SCHEMA_ID);
-        if (mate_background->get_boolean(MATE_BACKGROUND_SCHEMA_KEY_ACTIVE))
-        {
-            mate_background->set_boolean(MATE_BACKGROUND_SCHEMA_KEY_ACTIVE, false);
-        }
-    }
-
     AppearanceManager::global_init();
 }
 
@@ -54,16 +40,6 @@ void AppearancePlugin::deactivate()
 {
     KLOG_PROFILE("deactive appearance plugin.");
 
-    auto schemas = Gio::Settings::list_schemas();
-    if (std::find(schemas.begin(), schemas.end(), MATE_BACKGROUND_SCHEMA_ID) != schemas.end())
-    {
-        auto mate_background = Gio::Settings::create(MATE_BACKGROUND_SCHEMA_ID);
-        if (!mate_background->get_boolean(MATE_BACKGROUND_SCHEMA_KEY_ACTIVE))
-        {
-            mate_background->set_boolean(MATE_BACKGROUND_SCHEMA_KEY_ACTIVE, true);
-        }
-    }
-
     AppearanceManager::global_deinit();
 }
-}  // namespace Kiran
\ No newline at end of file
+}  // namespace Kiran
diff --git a/plugins/clipboard/clipboard-plugin.cpp b/plugins/clipboard/clipboard-plugin.cpp
index 7a9cbec..92b6a20 100644
--- a/plugins/clipboard/clipboard-plugin.cpp
+++ b/plugins/clipboard/clipboard-plugin.cpp
@@ -18,9 +18,6 @@
 
 PLUGIN_EXPORT_FUNC_DEF(ClipboardPlugin);
 
-#define MATE_CLIPBOARD_SCHEMA_ID "org.mate.SettingsDaemon.plugins.clipboard"
-#define MATE_CLIPBOARD_SCHEMA_KEY_ACTIVE "active"
-
 namespace Kiran
 {
 ClipboardPlugin::ClipboardPlugin()
@@ -35,17 +32,6 @@ void ClipboardPlugin::activate()
 {
     KLOG_PROFILE("active clipboard plugin.");
 
-    // kiran和mate的插件最好不要同时运行，如果开启了kiran的插件，则将mate的插件停用
-    auto schemas = Gio::Settings::list_schemas();
-    if (std::find(schemas.begin(), schemas.end(), MATE_CLIPBOARD_SCHEMA_ID) != schemas.end())
-    {
-        auto mate_clipboard = Gio::Settings::create(MATE_CLIPBOARD_SCHEMA_ID);
-        if (mate_clipboard->get_boolean(MATE_CLIPBOARD_SCHEMA_KEY_ACTIVE))
-        {
-            mate_clipboard->set_boolean(MATE_CLIPBOARD_SCHEMA_KEY_ACTIVE, false);
-        }
-    }
-
     ClipboardManager::global_init();
 }
 
@@ -53,16 +39,6 @@ void ClipboardPlugin::deactivate()
 {
     KLOG_PROFILE("deactive clipboard plugin.");
 
-    auto schemas = Gio::Settings::list_schemas();
-    if (std::find(schemas.begin(), schemas.end(), MATE_CLIPBOARD_SCHEMA_ID) != schemas.end())
-    {
-        auto mate_clipboard = Gio::Settings::create(MATE_CLIPBOARD_SCHEMA_ID);
-        if (!mate_clipboard->get_boolean(MATE_CLIPBOARD_SCHEMA_KEY_ACTIVE))
-        {
-            mate_clipboard->set_boolean(MATE_CLIPBOARD_SCHEMA_KEY_ACTIVE, true);
-        }
-    }
-
     ClipboardManager::global_deinit();
 }
-}  // namespace Kiran
\ No newline at end of file
+}  // namespace Kiran
diff --git a/plugins/display/display-plugin.cpp b/plugins/display/display-plugin.cpp
index 0385f33..32ae5be 100644
--- a/plugins/display/display-plugin.cpp
+++ b/plugins/display/display-plugin.cpp
@@ -22,9 +22,6 @@
 
 PLUGIN_EXPORT_FUNC_DEF(DisplayPlugin);
 
-#define MATE_XRANDR_SCHEMA_ID "org.mate.SettingsDaemon.plugins.xrandr"
-#define MATE_XRANDR_SCHEMA_KEY_ACTIVE "active"
-
 namespace Kiran
 {
 DisplayPlugin::DisplayPlugin()
@@ -38,16 +35,6 @@ DisplayPlugin::~DisplayPlugin()
 void DisplayPlugin::activate()
 {
     KLOG_PROFILE("active display plugin.");
-    // kiran和mate的插件最好不要同时运行，如果开启了kiran的插件，则将mate的插件停用
-    auto schemas = Gio::Settings::list_schemas();
-    if (std::find(schemas.begin(), schemas.end(), MATE_XRANDR_SCHEMA_ID) != schemas.end())
-    {
-        auto mate_display = Gio::Settings::create(MATE_XRANDR_SCHEMA_ID);
-        if (mate_display->get_boolean(MATE_XRANDR_SCHEMA_KEY_ACTIVE))
-        {
-            mate_display->set_boolean(MATE_XRANDR_SCHEMA_KEY_ACTIVE, false);
-        }
-    }
 
     XrandrManager::global_init();
     DisplayManager::global_init(XrandrManager::get_instance());
@@ -57,18 +44,7 @@ void DisplayPlugin::deactivate()
 {
     KLOG_PROFILE("deactive display plugin.");
 
-    // 恢复MATE的插件
-    auto schemas = Gio::Settings::list_schemas();
-    if (std::find(schemas.begin(), schemas.end(), MATE_XRANDR_SCHEMA_ID) != schemas.end())
-    {
-        auto mate_display = Gio::Settings::create(MATE_XRANDR_SCHEMA_ID);
-        if (!mate_display->get_boolean(MATE_XRANDR_SCHEMA_KEY_ACTIVE))
-        {
-            mate_display->set_boolean(MATE_XRANDR_SCHEMA_KEY_ACTIVE, true);
-        }
-    }
-
     DisplayManager::global_deinit();
     XrandrManager::global_deinit();
 }
-}  // namespace Kiran
\ No newline at end of file
+}  // namespace Kiran
diff --git a/plugins/inputdevices/keyboard/keyboard-plugin.cpp b/plugins/inputdevices/keyboard/keyboard-plugin.cpp
index a8d26bb..6c7b727 100644
--- a/plugins/inputdevices/keyboard/keyboard-plugin.cpp
+++ b/plugins/inputdevices/keyboard/keyboard-plugin.cpp
@@ -23,9 +23,6 @@
 
 PLUGIN_EXPORT_FUNC_DEF(KeyboardPlugin);
 
-#define MATE_KEYBOARD_SCHEMA_ID "org.mate.SettingsDaemon.plugins.keyboard"
-#define MATE_KEYBOARD_SCHEMA_KEY_ACTIVE "active"
-
 namespace Kiran
 {
 KeyboardPlugin::KeyboardPlugin()
@@ -40,17 +37,6 @@ void KeyboardPlugin::activate()
 {
     KLOG_PROFILE("active keyboard plugin.");
 
-    // kiran和mate的插件最好不要同时运行，如果开启了kiran的插件，则将mate的插件停用
-    auto schemas = Gio::Settings::list_schemas();
-    if (std::find(schemas.begin(), schemas.end(), MATE_KEYBOARD_SCHEMA_ID) != schemas.end())
-    {
-        auto mate_keyboard = Gio::Settings::create(MATE_KEYBOARD_SCHEMA_ID);
-        if (mate_keyboard->get_boolean(MATE_KEYBOARD_SCHEMA_KEY_ACTIVE))
-        {
-            mate_keyboard->set_boolean(MATE_KEYBOARD_SCHEMA_KEY_ACTIVE, false);
-        }
-    }
-
     KeyboardManager::global_init();
     ModifierLockManager::global_init(KeyboardManager::get_instance());
 }
@@ -59,17 +45,7 @@ void KeyboardPlugin::deactivate()
 {
     KLOG_PROFILE("deactive keyboard plugin.");
 
-    auto schemas = Gio::Settings::list_schemas();
-    if (std::find(schemas.begin(), schemas.end(), MATE_KEYBOARD_SCHEMA_ID) != schemas.end())
-    {
-        auto mate_keyboard = Gio::Settings::create(MATE_KEYBOARD_SCHEMA_ID);
-        if (!mate_keyboard->get_boolean(MATE_KEYBOARD_SCHEMA_KEY_ACTIVE))
-        {
-            mate_keyboard->set_boolean(MATE_KEYBOARD_SCHEMA_KEY_ACTIVE, true);
-        }
-    }
-
     ModifierLockManager::global_deinit();
     KeyboardManager::global_deinit();
 }
-}  // namespace Kiran
\ No newline at end of file
+}  // namespace Kiran
diff --git a/plugins/inputdevices/mouse/mouse-plugin.cpp b/plugins/inputdevices/mouse/mouse-plugin.cpp
index 8109a03..bb1d47d 100644
--- a/plugins/inputdevices/mouse/mouse-plugin.cpp
+++ b/plugins/inputdevices/mouse/mouse-plugin.cpp
@@ -21,9 +21,6 @@
 
 PLUGIN_EXPORT_FUNC_DEF(MousePlugin);
 
-#define MATE_MOUSE_SCHEMA_ID "org.mate.SettingsDaemon.plugins.mouse"
-#define MATE_MOUSE_SCHEMA_KEY_ACTIVE "active"
-
 namespace Kiran
 {
 MousePlugin::MousePlugin()
@@ -38,16 +35,6 @@ void MousePlugin::activate()
 {
     KLOG_PROFILE("active mouse plugin.");
 
-    // kiran和mate的相同插件不要同时运行，如果开启了kiran的插件，则将mate的插件停用
-    auto schemas = Gio::Settings::list_schemas();
-    if (std::find(schemas.begin(), schemas.end(), MATE_MOUSE_SCHEMA_ID) != schemas.end())
-    {
-        auto mate_mouse = Gio::Settings::create(MATE_MOUSE_SCHEMA_ID);
-        if (mate_mouse->get_boolean(MATE_MOUSE_SCHEMA_KEY_ACTIVE))
-        {
-            mate_mouse->set_boolean(MATE_MOUSE_SCHEMA_KEY_ACTIVE, false);
-        }
-    }
     MouseManager::global_init();
 }
 
@@ -55,16 +42,6 @@ void MousePlugin::deactivate()
 {
     KLOG_PROFILE("deactive mouse plugin.");
 
-    auto schemas = Gio::Settings::list_schemas();
-    if (std::find(schemas.begin(), schemas.end(), MATE_MOUSE_SCHEMA_ID) != schemas.end())
-    {
-        auto mate_mouse = Gio::Settings::create(MATE_MOUSE_SCHEMA_ID);
-        if (!mate_mouse->get_boolean(MATE_MOUSE_SCHEMA_KEY_ACTIVE))
-        {
-            mate_mouse->set_boolean(MATE_MOUSE_SCHEMA_KEY_ACTIVE, true);
-        }
-    }
-
     MouseManager::global_deinit();
 }
-}  // namespace Kiran
\ No newline at end of file
+}  // namespace Kiran
diff --git a/plugins/inputdevices/touchpad/touchpad-plugin.cpp b/plugins/inputdevices/touchpad/touchpad-plugin.cpp
index 00ac7a9..910038c 100644
--- a/plugins/inputdevices/touchpad/touchpad-plugin.cpp
+++ b/plugins/inputdevices/touchpad/touchpad-plugin.cpp
@@ -21,9 +21,6 @@
 
 PLUGIN_EXPORT_FUNC_DEF(TouchPadPlugin);
 
-#define MATE_MOUSE_SCHEMA_ID "org.mate.SettingsDaemon.plugins.mouse"
-#define MATE_MOUSE_SCHEMA_KEY_ACTIVE "active"
-
 namespace Kiran
 {
 TouchPadPlugin::TouchPadPlugin()
@@ -38,17 +35,6 @@ void TouchPadPlugin::activate()
 {
     KLOG_PROFILE("active touchpad plugin.");
 
-    // kiran和mate的相同插件不要同时运行，如果开启了kiran的插件，则将mate的插件停用
-    auto schemas = Gio::Settings::list_schemas();
-    if (std::find(schemas.begin(), schemas.end(), MATE_MOUSE_SCHEMA_ID) != schemas.end())
-    {
-        auto mate_touchpad = Gio::Settings::create(MATE_MOUSE_SCHEMA_ID);
-        if (mate_touchpad->get_boolean(MATE_MOUSE_SCHEMA_KEY_ACTIVE))
-        {
-            mate_touchpad->set_boolean(MATE_MOUSE_SCHEMA_KEY_ACTIVE, false);
-        }
-    }
-
     TouchPadManager::global_init();
 }
 
@@ -56,16 +42,6 @@ void TouchPadPlugin::deactivate()
 {
     KLOG_PROFILE("deactive touchpad plugin.");
 
-    auto schemas = Gio::Settings::list_schemas();
-    if (std::find(schemas.begin(), schemas.end(), MATE_MOUSE_SCHEMA_ID) != schemas.end())
-    {
-        auto mate_touchpad = Gio::Settings::create(MATE_MOUSE_SCHEMA_ID);
-        if (!mate_touchpad->get_boolean(MATE_MOUSE_SCHEMA_KEY_ACTIVE))
-        {
-            mate_touchpad->set_boolean(MATE_MOUSE_SCHEMA_KEY_ACTIVE, true);
-        }
-    }
-
     TouchPadManager::global_deinit();
 }
-}  // namespace Kiran
\ No newline at end of file
+}  // namespace Kiran
diff --git a/plugins/keybinding/keybinding-plugin.cpp b/plugins/keybinding/keybinding-plugin.cpp
index e2ea9c3..90cc06c 100644
--- a/plugins/keybinding/keybinding-plugin.cpp
+++ b/plugins/keybinding/keybinding-plugin.cpp
@@ -21,9 +21,6 @@
 
 PLUGIN_EXPORT_FUNC_DEF(KeybindingPlugin);
 
-#define MATE_KEYBINDINGS_SCHEMA_ID "org.mate.SettingsDaemon.plugins.keybindings"
-#define MATE_KEYBINDINGS_SCHEMA_KEY_ACTIVE "active"
-
 namespace Kiran
 {
 KeybindingPlugin::KeybindingPlugin()
@@ -38,17 +35,6 @@ void KeybindingPlugin::activate()
 {
     KLOG_PROFILE("active keybinding plugin.");
 
-    // kiran和mate的相同插件不要同时运行，如果开启了kiran的插件，则将mate的插件停用
-    auto schemas = Gio::Settings::list_schemas();
-    if (std::find(schemas.begin(), schemas.end(), MATE_KEYBINDINGS_SCHEMA_ID) != schemas.end())
-    {
-        auto mate_keybinding = Gio::Settings::create(MATE_KEYBINDINGS_SCHEMA_ID);
-        if (mate_keybinding->get_boolean(MATE_KEYBINDINGS_SCHEMA_KEY_ACTIVE))
-        {
-            mate_keybinding->set_boolean(MATE_KEYBINDINGS_SCHEMA_KEY_ACTIVE, false);
-        }
-    }
-
     KeybindingManager::global_init();
 }
 
@@ -56,16 +42,6 @@ void KeybindingPlugin::deactivate()
 {
     KLOG_PROFILE("deactive keybinding plugin.");
 
-    auto schemas = Gio::Settings::list_schemas();
-    if (std::find(schemas.begin(), schemas.end(), MATE_KEYBINDINGS_SCHEMA_ID) != schemas.end())
-    {
-        auto mate_keybinding = Gio::Settings::create(MATE_KEYBINDINGS_SCHEMA_ID);
-        if (!mate_keybinding->get_boolean(MATE_KEYBINDINGS_SCHEMA_KEY_ACTIVE))
-        {
-            mate_keybinding->set_boolean(MATE_KEYBINDINGS_SCHEMA_KEY_ACTIVE, true);
-        }
-    }
-
     KeybindingManager::global_deinit();
 }
-}  // namespace Kiran
\ No newline at end of file
+}  // namespace Kiran
diff --git a/plugins/xsettings/xsettings-plugin.cpp b/plugins/xsettings/xsettings-plugin.cpp
index f4d705f..0755a02 100644
--- a/plugins/xsettings/xsettings-plugin.cpp
+++ b/plugins/xsettings/xsettings-plugin.cpp
@@ -21,9 +21,6 @@
 
 PLUGIN_EXPORT_FUNC_DEF(XSettingsPlugin);
 
-#define MATE_XSETTINGS_SCHEMA_ID "org.mate.SettingsDaemon.plugins.xsettings"
-#define MATE_XSETTINGS_SCHEMA_KEY_ACTIVE "active"
-
 namespace Kiran
 {
 XSettingsPlugin::XSettingsPlugin()
@@ -38,17 +35,6 @@ void XSettingsPlugin::activate()
 {
     KLOG_PROFILE("active xsettings plugin.");
 
-    // kiran和mate的xrandr插件只能运行一个，如果开启了kiran的插件，则将mate的插件停用
-    auto schemas = Gio::Settings::list_schemas();
-    if (std::find(schemas.begin(), schemas.end(), MATE_XSETTINGS_SCHEMA_ID) != schemas.end())
-    {
-        auto mate_xsettings = Gio::Settings::create(MATE_XSETTINGS_SCHEMA_ID);
-        if (mate_xsettings->get_boolean(MATE_XSETTINGS_SCHEMA_KEY_ACTIVE))
-        {
-            mate_xsettings->set_boolean(MATE_XSETTINGS_SCHEMA_KEY_ACTIVE, false);
-        }
-    }
-
     XSettingsManager::global_init();
 }
 
@@ -56,16 +42,6 @@ void XSettingsPlugin::deactivate()
 {
     KLOG_PROFILE("deactive xsettings plugin.");
 
-    auto schemas = Gio::Settings::list_schemas();
-    if (std::find(schemas.begin(), schemas.end(), MATE_XSETTINGS_SCHEMA_ID) != schemas.end())
-    {
-        auto mate_xsettings = Gio::Settings::create(MATE_XSETTINGS_SCHEMA_ID);
-        if (!mate_xsettings->get_boolean(MATE_XSETTINGS_SCHEMA_KEY_ACTIVE))
-        {
-            mate_xsettings->set_boolean(MATE_XSETTINGS_SCHEMA_KEY_ACTIVE, true);
-        }
-    }
-
     XSettingsManager::global_deinit();
 }
-}  // namespace Kiran
\ No newline at end of file
+}  // namespace Kiran
-- 
2.33.0

