Skip to content

Commit

Permalink
feat: [dconf] add org.deepin.dde.file-manager.plugins.json
Browse files Browse the repository at this point in the history
Managing plugins via dconf

Log: Plugins management

Conflicts:
	src/apps/dde-file-manager-daemon/main.cpp
	src/apps/dde-file-manager-server/main.cpp
	src/apps/dde-file-manager/main.cpp
	src/dfm-framework/lifecycle/private/pluginmanager_p.cpp
  • Loading branch information
Johnson-zs committed Aug 23, 2023
1 parent a6f57f5 commit 53ffefb
Show file tree
Hide file tree
Showing 13 changed files with 148 additions and 100 deletions.
69 changes: 69 additions & 0 deletions assets/configs/org.deepin.dde.file-manager.plugins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"magic": "dsg.config.meta",
"version": "1.0",
"contents": {
"filemanager.blackList": {
"value": [],
"serial": 0,
"flags": [],
"name": "dde-file-manager plugin blacklist",
"name[zh_CN]": "文件管理器插件黑名单列表",
"description[zh_CN]": "文件管理器插件黑名单列表,黑名单中的插件将无法被启用",
"description": "List of plugins disabled by the dde-file-manager, blacklisted plugins will not be enabled",
"permissions": "readwrite",
"visibility": "public"
},
"desktop.blackList": {
"value": [],
"serial": 0,
"flags": [],
"name": "dde-desktop plugins blacklist",
"name[zh_CN]": "桌面插件黑名单列表",
"description[zh_CN]": "桌面插件黑名单列表,黑名单中的插件将无法被启用",
"description": "List of plugins disabled by the dde-desktop, plugins in the blacklist will not be able to be enabled",
"permissions": "readwrite",
"visibility": "public"
},
"server.blackList": {
"value": [],
"serial": 0,
"flags": [],
"name": "dde-file-manager-server plugins blacklist",
"name[zh_CN]": "文件管理器用户服务插件黑名单列表",
"description[zh_CN]": "文件管理器用户服务插件黑名单列表,黑名单中的插件将无法被启用",
"description": "List of plugins disabled by the dde-file-manager-server, plugins in the blacklist will not be able to be enabled",
"permissions": "readwrite",
"visibility": "public"
},
"daemon.blackList": {
"value": [],
"serial": 0,
"flags": [],
"name": "dde-file-manager-daemon plugins blacklist",
"name[zh_CN]": "文件管理器守护进程插件黑名单列表",
"description[zh_CN]": "文件管理器守护进程插件黑名单列表,黑名单中的插件将无法被启用",
"description": "List of plugins disabled by the dde-file-manager-daemon, plugins in the blacklist will not be able to be enabled",
"permissions": "readwrite",
"visibility": "public"
},
"filedialog.blackList": {
"value": ["dfmplugin-burn",
"dfmplugin-dirshare",
"dfmplugin-myshares",
"dfmplugin-propertydialog",
"dfmplugin-trashcore",
"dfmplugin-trash",
"dfmplugin-filepreview",
"dfmplugin-vault",
"dfmplugin-phone" ],
"serial": 0,
"flags": [],
"name": "dde-file-dialog plugins blacklist",
"name[zh_CN]": "文件管理器文件选择对话框插件黑名单列表",
"description[zh_CN]": "文件管理器文件选择对话框插件黑名单列表,黑名单中的插件将无法被启用",
"description": "List of plugins disabled by the dde-file-dialog, plugins in the blacklist will not be able to be enabled",
"permissions": "readwrite",
"visibility": "public"
}
}
}
10 changes: 9 additions & 1 deletion src/apps/dde-desktop/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <dfm-base/base/configs/dconfig/dconfigmanager.h>
#include <dfm-base/utils/sysinfoutils.h>
#include <dfm-base/base/configs/dconfig/dconfigmanager.h>

#include <dfm-framework/dpf.h>

Expand Down Expand Up @@ -52,8 +53,14 @@ static const char *const kLibCore = "libddplugin-core.so";
static constexpr int kMemoryThreshold { 80 * 1024 }; // 80MB
static constexpr int kTimerInterval { 60 * 1000 }; // 1 min

DFMBASE_USE_NAMESPACE

static bool pluginsLoad()
{
QString msg;
if (!DConfigManager::instance()->addConfig(kPluginsDConfName, &msg))
qWarning() << "Load plugins but dconfig failed: " << msg;

QStringList pluginsDirs;
#ifdef QT_DEBUG
const QString &pluginsDir { DFM_BUILD_PLUGIN_DIR };
Expand All @@ -77,7 +84,8 @@ static bool pluginsLoad()
"dfmplugin-tag", "dfmplugin-burn", "dfmplugin-dirshare", "dfmplugin-emblem",
"dfmplugin-filepreview" };

DPF_NAMESPACE::LifeCycle::initialize({ kDesktopPluginInterface, kCommonPluginInterface }, pluginsDirs, {}, kLazyLoadPluginNames);
QStringList blackNames { DConfigManager::instance()->value(kPluginsDConfName, "desktop.blackList").toStringList() };
DPF_NAMESPACE::LifeCycle::initialize({ kDesktopPluginInterface, kCommonPluginInterface }, pluginsDirs, blackNames, kLazyLoadPluginNames);

qInfo() << "Depend library paths:" << DApplication::libraryPaths();
qInfo() << "Load plugin paths: " << dpf::LifeCycle::pluginPaths();
Expand Down
20 changes: 8 additions & 12 deletions src/apps/dde-file-dialog-wayland/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
#include <QTextCodec>
#include <QIcon>

#include <dfm-base/base/configs/dconfig/dconfigmanager.h>

#include <dfm-framework/dpf.h>

#include <signal.h>

DGUI_USE_NAMESPACE
DWIDGET_USE_NAMESPACE
DFMBASE_USE_NAMESPACE

#ifdef DFM_ORGANIZATION_NAME
# define ORGANIZATION_NAME DFM_ORGANIZATION_NAME
Expand Down Expand Up @@ -67,17 +70,10 @@ static bool singlePluginLoad(const QString &pluginName, const QString &libName)

static bool pluginsLoad()
{
static const QStringList kBlackNameList {
"dfmplugin-burn",
"dfmplugin-dirshare",
"dfmplugin-myshares",
"dfmplugin-propertydialog",
"dfmplugin-trashcore",
"dfmplugin-trash",
"dfmplugin-filepreview",
"dfmplugin-vault",
"dfmplugin-phone" // TODO(zhangs): use white list
};
QString msg;
if (!DConfigManager::instance()->addConfig(kPluginsDConfName, &msg))
qWarning() << "Load plugins but dconfig failed: " << msg;
QStringList blackNames { DConfigManager::instance()->value(kPluginsDConfName, "filedialog.blackList").toStringList() };

static const QStringList kLazyLoadPluginNames {
"dfmplugin-emblem",
Expand Down Expand Up @@ -105,7 +101,7 @@ static bool pluginsLoad()
DPF_NAMESPACE::LifeCycle::initialize({ kDialogPluginInterface,
kFmPluginInterface,
kCommonPluginInterface },
pluginsDirs, kBlackNameList, kLazyLoadPluginNames);
pluginsDirs, blackNames, kLazyLoadPluginNames);

qInfo() << "Depend library paths:" << DApplication::libraryPaths();
qInfo() << "Load plugin paths: " << dpf::LifeCycle::pluginPaths();
Expand Down
20 changes: 8 additions & 12 deletions src/apps/dde-file-dialog-x11/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
#include <QTextCodec>
#include <QIcon>

#include <dfm-base/base/configs/dconfig/dconfigmanager.h>

#include <dfm-framework/dpf.h>

#include <signal.h>

DGUI_USE_NAMESPACE
DWIDGET_USE_NAMESPACE
DFMBASE_USE_NAMESPACE

#ifdef DFM_ORGANIZATION_NAME
# define ORGANIZATION_NAME DFM_ORGANIZATION_NAME
Expand Down Expand Up @@ -67,17 +70,10 @@ static bool singlePluginLoad(const QString &pluginName, const QString &libName)

static bool pluginsLoad()
{
static const QStringList kBlackNameList {
"dfmplugin-burn",
"dfmplugin-dirshare",
"dfmplugin-myshares",
"dfmplugin-propertydialog",
"dfmplugin-trashcore",
"dfmplugin-trash",
"dfmplugin-filepreview",
"dfmplugin-vault",
"dfmplugin-phone" // TODO(zhangs): use white list
};
QString msg;
if (!DConfigManager::instance()->addConfig(kPluginsDConfName, &msg))
qWarning() << "Load plugins but dconfig failed: " << msg;
QStringList blackNames { DConfigManager::instance()->value(kPluginsDConfName, "filedialog.blackList").toStringList() };

static const QStringList kLazyLoadPluginNames {
"dfmplugin-emblem",
Expand Down Expand Up @@ -105,7 +101,7 @@ static bool pluginsLoad()
DPF_NAMESPACE::LifeCycle::initialize({ kDialogPluginInterface,
kFmPluginInterface,
kCommonPluginInterface },
pluginsDirs, kBlackNameList, kLazyLoadPluginNames);
pluginsDirs, blackNames, kLazyLoadPluginNames);

qInfo() << "Depend library paths:" << DApplication::libraryPaths();
qInfo() << "Load plugin paths: " << dpf::LifeCycle::pluginPaths();
Expand Down
21 changes: 8 additions & 13 deletions src/apps/dde-file-dialog/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
#include <QTextCodec>
#include <QIcon>

#include <dfm-base/base/configs/dconfig/dconfigmanager.h>

#include <dfm-framework/dpf.h>

#include <signal.h>

DGUI_USE_NAMESPACE
DWIDGET_USE_NAMESPACE
DFMBASE_USE_NAMESPACE

#ifdef DFM_ORGANIZATION_NAME
# define ORGANIZATION_NAME DFM_ORGANIZATION_NAME
Expand Down Expand Up @@ -64,18 +67,10 @@ static bool singlePluginLoad(const QString &pluginName, const QString &libName)

static bool pluginsLoad()
{
// TODO(zhangs): Configurable, maybe config file ?
static const QStringList kBlackNameList {
"dfmplugin-burn",
"dfmplugin-dirshare",
"dfmplugin-myshares",
"dfmplugin-propertydialog",
"dfmplugin-trashcore",
"dfmplugin-trash",
"dfmplugin-filepreview",
"dfmplugin-vault",
"dfmplugin-phone" // TODO(zhangs): use white list
};
QString msg;
if (!DConfigManager::instance()->addConfig(kPluginsDConfName, &msg))
qWarning() << "Load plugins but dconfig failed: " << msg;
QStringList blackNames { DConfigManager::instance()->value(kPluginsDConfName, "filedialog.blackList").toStringList() };

static const QStringList kLazyLoadPluginNames {
"dfmplugin-emblem",
Expand Down Expand Up @@ -103,7 +98,7 @@ static bool pluginsLoad()
DPF_NAMESPACE::LifeCycle::initialize({ kDialogPluginInterface,
kFmPluginInterface,
kCommonPluginInterface },
pluginsDirs, kBlackNameList, kLazyLoadPluginNames);
pluginsDirs, blackNames, kLazyLoadPluginNames);

qInfo() << "Depend library paths:" << DApplication::libraryPaths();
qInfo() << "Load plugin paths: " << dpf::LifeCycle::pluginPaths();
Expand Down
15 changes: 12 additions & 3 deletions src/apps/dde-file-manager-daemon/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <QDebug>
#include <QDir>

#include <dfm-base/base/configs/dconfig/dconfigmanager.h>

#include <dfm-framework/dpf.h>

#include <unistd.h>
Expand All @@ -21,6 +23,8 @@ static constexpr char kDaemonInterface[] { "org.deepin.plugin.daemon" };
static constexpr char kPluginCore[] { "daemonplugin-core" };
static constexpr char kLibCore[] { "libdaemonplugin-core.so" };

DFMBASE_USE_NAMESPACE

static void handleSIGTERM(int sig)
{
qCritical() << "daemon break with !SIGTERM! " << sig;
Expand Down Expand Up @@ -63,6 +67,10 @@ static void initLog()

static bool pluginsLoad()
{
QString msg;
if (!DConfigManager::instance()->addConfig(kPluginsDConfName, &msg))
qWarning() << "Load plugins but dconfig failed: " << msg;

QStringList pluginsDirs;
#ifdef QT_DEBUG
const QString &pluginsDir { DFM_BUILD_PLUGIN_DIR };
Expand All @@ -73,13 +81,14 @@ static bool pluginsLoad()
pluginsDirs << QString(DFM_PLUGIN_FILEMANAGER_CORE_DIR)
<< QString(DFM_PLUGIN_DAEMON_EDGE_DIR);
#endif
QStringList kBlackNameList;
QStringList blackNames { DConfigManager::instance()->value(kPluginsDConfName, "daemon.blackList").toStringList() };
#ifdef DISABLE_ANYTHING
kBlackNameList << "daemonplugin-anything";
if (!blackNames.contains("daemonplugin-anything"))
blackNames << "daemonplugin-anything";
#endif

qInfo() << "Using plugins dir:" << pluginsDirs;
DPF_NAMESPACE::LifeCycle::initialize({ kDaemonInterface }, pluginsDirs, kBlackNameList);
DPF_NAMESPACE::LifeCycle::initialize({ kDaemonInterface }, pluginsDirs, blackNames);

qInfo() << "Depend library paths:" << QCoreApplication::libraryPaths();
qInfo() << "Load plugin paths: " << dpf::LifeCycle::pluginPaths();
Expand Down
38 changes: 11 additions & 27 deletions src/apps/dde-file-manager-server/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,24 @@

#include "config.h"

#include <dfm-base/base/configs/dconfig/dconfigmanager.h>

#include <dfm-framework/dpf.h>

#include <DApplication>
#include <DSysInfo>

#include <QDebug>
#include <QDir>

#include <dfm-framework/dpf.h>

#include <signal.h>

static constexpr char kServerInterface[] { "org.deepin.plugin.server" };
static constexpr char kPluginCore[] { "serverplugin-core" };
static constexpr char kLibCore[] { "libserverplugin-core.so" };

DFMBASE_USE_NAMESPACE

#ifdef DFM_ORGANIZATION_NAME
# define ORGANIZATION_NAME DFM_ORGANIZATION_NAME
#else
Expand All @@ -33,28 +37,12 @@ static void initLog()
dpfLogManager->registerFileAppender();
}

static bool isLoadVaultPlugin()
{
DSysInfo::UosType uosType = DSysInfo::uosType();
DSysInfo::UosEdition uosEdition = DSysInfo::uosEditionType();
if (DSysInfo::UosServer == uosType) {
if (DSysInfo::UosEnterprise == uosEdition
|| DSysInfo::UosEnterpriseC == uosEdition
|| DSysInfo::UosEuler == uosEdition) {
return true;
}
} else if (DSysInfo::UosDesktop == uosType) {
if (DSysInfo::UosProfessional == uosEdition
|| static_cast<int>(DSysInfo::UosEnterprise) == static_cast<int>(uosEdition + 1)
|| DSysInfo::UosEducation == uosEdition) {
return true;
}
}
return false;
}

static bool pluginsLoad()
{
QString msg;
if (!DConfigManager::instance()->addConfig(kPluginsDConfName, &msg))
qWarning() << "Load plugins but dconfig failed: " << msg;

QStringList pluginsDirs;
#ifdef QT_DEBUG
const QString &pluginsDir { DFM_BUILD_PLUGIN_DIR };
Expand All @@ -66,11 +54,7 @@ static bool pluginsLoad()
<< QString(DFM_PLUGIN_SERVER_EDGE_DIR);
#endif
qInfo() << "Using plugins dir:" << pluginsDirs;

QStringList blackNames;
if (!isLoadVaultPlugin())
blackNames << "serverplugin-vaultdaemon";

QStringList blackNames { DConfigManager::instance()->value(kPluginsDConfName, "server.blackList").toStringList() };
DPF_NAMESPACE::LifeCycle::initialize({ kServerInterface }, pluginsDirs, blackNames);

qInfo() << "Depend library paths:" << QCoreApplication::libraryPaths();
Expand Down
Loading

0 comments on commit 53ffefb

Please sign in to comment.