feat: 实现Apps服务、Launcher服务、Dock服务
*重写Apps服务,新服务分为org.deepin.daemon.DFWatcher1和org.deepin.daemon.ALRecorder1两个服务 *重写Launcher服务, 新服务名为org.deepin.dde.daemon.Launcher1 *重写Dock服务, 新服务名为org.deepin.dde.daemon.Dock1 *重写部分go-lib接口,保存在src/lib目录, 后续从项目中提出统一存放至开发库 *使用XCB库实现与XServer交互,存放在src/lib目录 *放弃依赖dde-qt-dbus-factory包, 将xml文件生成的静态编译代码存放在frameworkdbus目录 Log: 实现Apps服务、Launcher服务、Dock服务 Task: https://pms.uniontech.com/task-view-109315.html Influence: 无 Change-Id: Ia9676060bfe81ce8d02c48972cc3d3cbaf665a31
This commit is contained in:
76
src/utils/settings.cpp
Normal file
76
src/utils/settings.cpp
Normal file
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
* Maintainer: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "settings.h"
|
||||
|
||||
#include <QSharedPointer>
|
||||
#include <QDebug>
|
||||
|
||||
Settings::Settings()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Settings::~Settings()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DConfig *Settings::ConfigPtr(const QString &name, const QString &subpath, QObject *parent)
|
||||
{
|
||||
DConfig *config = DConfig::create("dde-application-manager", name, subpath, parent);
|
||||
if (!config)
|
||||
return nullptr;
|
||||
|
||||
if (config->isValid())
|
||||
return config;
|
||||
|
||||
delete config;
|
||||
qDebug() << "Cannot find dconfigs, name:" << name;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const QVariant Settings::ConfigValue(const QString &name, const QString &subPath, const QString &key, const QVariant &fallback)
|
||||
{
|
||||
QSharedPointer<DConfig> config(ConfigPtr(name, subPath));
|
||||
if (config && config->isValid() && config->keyList().contains(key)) {
|
||||
QVariant v = config->value(key);
|
||||
return v;
|
||||
}
|
||||
|
||||
qDebug() << "Cannot find dconfigs, name:" << name
|
||||
<< " subPath:" << subPath << " key:" << key
|
||||
<< "Use fallback value:" << fallback;
|
||||
return fallback;
|
||||
}
|
||||
|
||||
bool Settings::ConfigSaveValue(const QString &name, const QString &subPath, const QString &key, const QVariant &value)
|
||||
{
|
||||
QSharedPointer<DConfig> config(ConfigPtr(name, subPath));
|
||||
if (config && config->isValid() && config->keyList().contains(key)) {
|
||||
config->setValue(key, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
qDebug() << "Cannot find dconfigs, name:" << name
|
||||
<< " subPath:" << subPath << " key:" << key;
|
||||
return false;
|
||||
}
|
44
src/utils/settings.h
Normal file
44
src/utils/settings.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
* Maintainer: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef SETTINGS_H
|
||||
#define SETTINGS_H
|
||||
|
||||
#include <DConfig>
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
DCORE_USE_NAMESPACE
|
||||
|
||||
// Dconfig 配置类
|
||||
class Settings
|
||||
{
|
||||
public:
|
||||
Settings();
|
||||
~Settings();
|
||||
|
||||
static DConfig *ConfigPtr(const QString &name, const QString &subpath = QString(), QObject *parent = nullptr);
|
||||
static const QVariant ConfigValue(const QString &name, const QString &subPath = QString(), const QString &key = QString(), const QVariant &fallback = QVariant());
|
||||
static bool ConfigSaveValue(const QString &name, const QString &subPath, const QString &key, const QVariant &value);
|
||||
};
|
||||
|
||||
#endif // SETTINGS_H
|
118
src/utils/synconfig.cpp
Normal file
118
src/utils/synconfig.cpp
Normal file
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
* Maintainer: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "synconfig.h"
|
||||
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusError>
|
||||
#include <QtDebug>
|
||||
#include <QDBusInterface>
|
||||
#include <QDBusConnectionInterface>
|
||||
|
||||
const QString syncDBusService = "org.deepin.sync.Config1";
|
||||
const QString syncDBusObject = "/org/deepin/sync/Config1";
|
||||
const QString syncDBusDaemonService = "com.deepin.sync.Daemon";
|
||||
const QString syncDBusDaemonObject = "/com/deepin/sync/Daemon";
|
||||
const QString syncDBusDaemonInterface = syncDBusDaemonService;
|
||||
|
||||
QMap<QString, SynModuleBase*> SynConfig::synModulesMap;
|
||||
|
||||
SynConfig *SynConfig::instance(QObject *parent)
|
||||
{
|
||||
static SynConfig synConfig(parent);
|
||||
|
||||
return &synConfig;
|
||||
}
|
||||
|
||||
bool SynConfig::registe(QString moduleName, SynModuleBase *module)
|
||||
{
|
||||
bool registed = false;
|
||||
if (moduleName.size() > 0 && module) {
|
||||
synModulesMap[moduleName] = module;
|
||||
registed = true;
|
||||
}
|
||||
|
||||
return registed;
|
||||
}
|
||||
|
||||
QByteArray SynConfig::GetSyncConfig(QString moduleName)
|
||||
{
|
||||
if (synModulesMap.find(moduleName) == synModulesMap.end())
|
||||
return {};
|
||||
|
||||
SynModuleBase *module = synModulesMap[moduleName];
|
||||
if (module)
|
||||
return module->getSyncConfig();
|
||||
else
|
||||
return {};
|
||||
}
|
||||
|
||||
void SynConfig::SetSynConfig(QString moduleName, QByteArray ba)
|
||||
{
|
||||
if (synModulesMap.find(moduleName) == synModulesMap.end())
|
||||
return;
|
||||
|
||||
SynModuleBase *module = synModulesMap[moduleName];
|
||||
if (module) {
|
||||
module->setSynConfig(ba);
|
||||
}
|
||||
}
|
||||
|
||||
SynConfig::SynConfig(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
QDBusConnection con = QDBusConnection::sessionBus();
|
||||
if (!con.registerService(syncDBusService))
|
||||
{
|
||||
qCritical() << "register service org.deepin.sync.Config1 error:" << con.lastError().message();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!con.registerObject(syncDBusObject, this, QDBusConnection::ExportAllSlots | QDBusConnection::ExportAllSignals))
|
||||
{
|
||||
qCritical() << "register object /org/deepin/sync/Config1 error:" << con.lastError().message();
|
||||
return;
|
||||
}
|
||||
|
||||
// 只注册一次
|
||||
registerOnSyncDaemon();
|
||||
// 关联com.deepin.sync.Daemon所有者变化
|
||||
QDBusConnectionInterface *ifc = QDBusConnection::sessionBus().interface();
|
||||
connect(ifc, &QDBusConnectionInterface::serviceOwnerChanged, this, [ & ](const QString & name, const QString & oldOwner, const QString & newOwner) {
|
||||
Q_UNUSED(oldOwner)
|
||||
if (name == syncDBusDaemonService && !newOwner.isEmpty()) {
|
||||
this->registerOnSyncDaemon();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
SynConfig::~SynConfig()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SynConfig::registerOnSyncDaemon()
|
||||
{
|
||||
QDBusInterface interface = QDBusInterface(syncDBusDaemonService, syncDBusDaemonObject, syncDBusDaemonInterface);
|
||||
// 修改V20注册方式,需同步到deepin-deepinid-daemon
|
||||
interface.call("Register", syncDBusService, syncDBusObject);
|
||||
}
|
||||
|
56
src/utils/synconfig.h
Normal file
56
src/utils/synconfig.h
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
* Maintainer: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef SYNCONFIG_H
|
||||
#define SYNCONFIG_H
|
||||
|
||||
#include "synmodulebase.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QMap>
|
||||
|
||||
class SynConfig final : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", "org.deepin.sync.Config1")
|
||||
public:
|
||||
// 实例
|
||||
static SynConfig *instance(QObject *parent = nullptr);
|
||||
// 记录模块对应类信息
|
||||
static bool registe(QString moduleName, SynModuleBase *module);
|
||||
|
||||
public slots:
|
||||
// 获取配置信息
|
||||
QByteArray GetSyncConfig(QString moduleName);
|
||||
// 设置配置信息
|
||||
void SetSynConfig(QString moduleName, QByteArray ba);
|
||||
|
||||
private:
|
||||
explicit SynConfig(QObject *parent = nullptr);
|
||||
~SynConfig();
|
||||
|
||||
// 将本服务注册到com.deepin.sync.Daemon
|
||||
void registerOnSyncDaemon();
|
||||
|
||||
static QMap<QString, SynModuleBase*> synModulesMap; // 记录模块对应类
|
||||
};
|
||||
|
||||
#endif // SYNCONFIG_H
|
42
src/utils/synmodule.h
Normal file
42
src/utils/synmodule.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
* Maintainer: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef SYNMODULE_H
|
||||
#define SYNMODULE_H
|
||||
|
||||
#include "synconfig.h"
|
||||
#include <QString>
|
||||
|
||||
class SynModule : public SynModuleBase, public QObject
|
||||
{
|
||||
public:
|
||||
explicit SynModule(QObject *parent = nullptr) : QObject(parent) {}
|
||||
virtual ~SynModule() {}
|
||||
|
||||
// 获取配置信息
|
||||
virtual QByteArray getSyncConfig() = 0;
|
||||
// 设置配置信息
|
||||
virtual void setSynConfig(QByteArray ba) = 0;
|
||||
// 注册配置模块
|
||||
virtual bool registeModule(QString moduleName) final {return SynConfig::instance(this)->registe(moduleName, this);}
|
||||
};
|
||||
|
||||
#endif // SYNMODULE_H
|
44
src/utils/synmodulebase.h
Normal file
44
src/utils/synmodulebase.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ~ 2023 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
* Maintainer: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef SYNMODULEBASE_H
|
||||
#define SYNMODULEBASE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QByteArray>
|
||||
|
||||
// 同步配置基类
|
||||
class SynModuleBase
|
||||
{
|
||||
public:
|
||||
SynModuleBase() {}
|
||||
virtual ~SynModuleBase() {}
|
||||
|
||||
// 获取配置信息
|
||||
virtual QByteArray getSyncConfig() = 0;
|
||||
// 设置配置信息
|
||||
virtual void setSynConfig(QByteArray ba) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // SYNCONFIGBASE_H
|
Reference in New Issue
Block a user