fix: AM 暴露出调起应用的接口
org.desktopspec.ApplicationManager启动应用服务接口导出 Log: Influence: dbus接口暴露给启动器/任务栏等应用调用 Task: https://pms.uniontech.com/task-view-211667.html Change-Id: I2ccbaf31513db18438cbd18daf96c8bc552e46c5
This commit is contained in:
parent
ecc94f01c8
commit
f260303803
@ -1,50 +1,34 @@
|
|||||||
<interface name='org.desktopspec.ApplicationManager'>
|
<interface name='org.desktopspec.ApplicationManager'>
|
||||||
<method name='Launch'>
|
|
||||||
<arg type='s' name='id' direction='in'/>
|
|
||||||
<arg type='as' name='files' direction='in' />
|
|
||||||
<arg type='o' name='instance' direction='out'/>
|
|
||||||
</method>
|
|
||||||
<method name='AddAutostart'>
|
<method name='AddAutostart'>
|
||||||
<arg type='s' name='fileNamae' direction='in' />
|
<arg type='s' name='fileNamae' direction='in' />
|
||||||
<arg type='b' name='outArg0' direction='out' />
|
<arg type='b' name='outArg0' direction='out' />
|
||||||
</method>
|
</method>
|
||||||
<method name='RemoveAutostart'>
|
|
||||||
<arg type='s' name='fileNamae' direction='in' />
|
|
||||||
<arg type='b' name='outArg0' direction='out' />
|
|
||||||
</method>
|
|
||||||
<method name='AutostartList'>
|
<method name='AutostartList'>
|
||||||
<arg type='as' name='outArg0' direction='out' />
|
<arg type='as' name='outArg0' direction='out' />
|
||||||
</method>
|
</method>
|
||||||
<method name='DumpMemRecord'>
|
|
||||||
<arg type='s' name='outArg0' direction='out' />
|
|
||||||
</method>
|
|
||||||
<method name='IsAutostart'>
|
<method name='IsAutostart'>
|
||||||
<arg type='s' name='fileName' direction='in' />
|
<arg type='s' name='fileName' direction='in' />
|
||||||
<arg type='b' name='outArg0' direction='out' />
|
<arg type='b' name='outArg0' direction='out' />
|
||||||
</method>
|
</method>
|
||||||
<method name='IsMemSufficient'>
|
<method name='RemoveAutostart'>
|
||||||
|
<arg type='s' name='fileNamae' direction='in' />
|
||||||
<arg type='b' name='outArg0' direction='out' />
|
<arg type='b' name='outArg0' direction='out' />
|
||||||
</method>
|
</method>
|
||||||
|
<method name="Launch">
|
||||||
|
<arg type='s' name='desktopFile' direction='in'/>
|
||||||
|
</method>
|
||||||
|
<method name="LaunchApp">
|
||||||
|
<arg type='s' name='desktopFile' direction='in'/>
|
||||||
|
<arg type='u' name='timestamp' direction='in'/>
|
||||||
|
<arg type='as' name='files' direction='in'/>
|
||||||
|
</method>
|
||||||
<method name='LaunchAppAction'>
|
<method name='LaunchAppAction'>
|
||||||
<arg type='s' name='desktopFile' direction='in' />
|
<arg type='s' name='desktopFile' direction='in' />
|
||||||
<arg type='s' name='action' direction='in' />
|
<arg type='s' name='action' direction='in' />
|
||||||
<arg type='u' name='timestamp' direction='in' />
|
<arg type='u' name='timestamp' direction='in' />
|
||||||
</method>
|
</method>
|
||||||
<method name='RunCommand'>
|
|
||||||
<arg type='s' name='exe' direction='in' />
|
|
||||||
<arg type='as' name='args' direction='in' />
|
|
||||||
</method>
|
|
||||||
<method name='TryAgain'>
|
|
||||||
<arg type='b' name='launch' direction='in' />
|
|
||||||
</method>
|
|
||||||
<method name='IsPidVirtualMachine'>
|
|
||||||
<arg type='i' name='pid' direction='in' />
|
|
||||||
<arg type='b' name='isVM' direction='out' />
|
|
||||||
</method>
|
|
||||||
<signal name='AutostartChanged'>
|
<signal name='AutostartChanged'>
|
||||||
<arg type='s' name='status' />
|
<arg type='s' name='status' />
|
||||||
<arg type='s' name='filePath' />
|
<arg type='s' name='filePath' />
|
||||||
</signal>
|
</signal>
|
||||||
<property access='read' type='ao' name='list' />
|
|
||||||
<property access='read' type='ao' name='instances' />
|
|
||||||
</interface>
|
</interface>
|
||||||
|
@ -95,16 +95,6 @@ QStringList StartManager::autostartList()
|
|||||||
return autostartFiles;
|
return autostartFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString StartManager::dumpMemRecord()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
QString StartManager::getApps()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief StartManager::isAutostart
|
* @brief StartManager::isAutostart
|
||||||
* @param fileName desktopFile
|
* @param fileName desktopFile
|
||||||
@ -133,6 +123,11 @@ bool StartManager::isMemSufficient()
|
|||||||
return SETTING->getMemCheckerEnabled() ? MemInfo::isSufficient(minMemAvail, maxSwapUsed) : true;
|
return SETTING->getMemCheckerEnabled() ? MemInfo::isSufficient(minMemAvail, maxSwapUsed) : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StartManager::launchApp(const QString &desktopFile)
|
||||||
|
{
|
||||||
|
doLaunchAppWithOptions(desktopFile);
|
||||||
|
}
|
||||||
|
|
||||||
void StartManager::launchApp(QString desktopFile, uint32_t timestamp, QStringList files)
|
void StartManager::launchApp(QString desktopFile, uint32_t timestamp, QStringList files)
|
||||||
{
|
{
|
||||||
doLaunchAppWithOptions(desktopFile, timestamp, files, QMap<QString, QString>());
|
doLaunchAppWithOptions(desktopFile, timestamp, files, QMap<QString, QString>());
|
||||||
@ -183,11 +178,6 @@ void StartManager::runCommandWithOptions(QString exe, QStringList args, QMap<QSt
|
|||||||
doRunCommandWithOptions(exe, args, options);
|
doRunCommandWithOptions(exe, args, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartManager::tryAgain(bool launch)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void StartManager::onAutoStartupPathChange(const QString &dirPath)
|
void StartManager::onAutoStartupPathChange(const QString &dirPath)
|
||||||
{
|
{
|
||||||
QStringList autostartFilesList = getAutostartList();
|
QStringList autostartFilesList = getAutostartList();
|
||||||
@ -282,6 +272,19 @@ bool StartManager::setAutostart(QString fileName, bool value)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool StartManager::doLaunchAppWithOptions(const QString &desktopFile)
|
||||||
|
{
|
||||||
|
DesktopInfo info(desktopFile.toStdString());
|
||||||
|
if (!info.isValidDesktop())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
launch(&info, info.getCommandLine().c_str(), 0, QStringList());
|
||||||
|
|
||||||
|
dbusHandler->markLaunched(desktopFile);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool StartManager::doLaunchAppWithOptions(QString desktopFile, uint32_t timestamp, QStringList files, QMap<QString, QString> options)
|
bool StartManager::doLaunchAppWithOptions(QString desktopFile, uint32_t timestamp, QStringList files, QMap<QString, QString> options)
|
||||||
{
|
{
|
||||||
// launchApp
|
// launchApp
|
||||||
@ -359,9 +362,23 @@ bool StartManager::launch(DesktopInfo *info, QString cmdLine, uint32_t timestamp
|
|||||||
QString exec = exeArgs[0];
|
QString exec = exeArgs[0];
|
||||||
exeArgs.removeAt(0);
|
exeArgs.removeAt(0);
|
||||||
|
|
||||||
|
#ifdef QT_DEBUG
|
||||||
qDebug() << "launchApp: " << desktopFile << " exec: " << exec << " args: " << exeArgs;
|
qDebug() << "launchApp: " << desktopFile << " exec: " << exec << " args: " << exeArgs;
|
||||||
|
#endif
|
||||||
|
|
||||||
process.setWorkingDirectory(workingDir.c_str());
|
process.setWorkingDirectory(workingDir.c_str());
|
||||||
process.setEnvironment(envs);
|
process.setEnvironment(envs);
|
||||||
|
|
||||||
|
if (desktopFile.contains("/persistent/linglong")) {
|
||||||
|
exeArgs.clear();
|
||||||
|
|
||||||
|
#ifdef QT_DEBUG
|
||||||
|
qDebug() << "exeArgs:" << cmdLine.section(" ", 1, 2);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
exeArgs.append(cmdLine.section(" ", 1, 2).split(" "));
|
||||||
|
}
|
||||||
|
|
||||||
return process.startDetached(exec, exeArgs);
|
return process.startDetached(exec, exeArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,16 +41,14 @@ public:
|
|||||||
bool addAutostart(QString fileName);
|
bool addAutostart(QString fileName);
|
||||||
bool removeAutostart(QString fileName);
|
bool removeAutostart(QString fileName);
|
||||||
QStringList autostartList();
|
QStringList autostartList();
|
||||||
QString dumpMemRecord();
|
|
||||||
QString getApps();
|
|
||||||
bool isAutostart(QString fileName);
|
bool isAutostart(QString fileName);
|
||||||
bool isMemSufficient();
|
bool isMemSufficient();
|
||||||
|
void launchApp(const QString &desktopFile);
|
||||||
void launchApp(QString desktopFile, uint32_t timestamp, QStringList files);
|
void launchApp(QString desktopFile, uint32_t timestamp, QStringList files);
|
||||||
void launchAppAction(QString desktopFile, QString actionSection, uint32_t timestamp);
|
void launchAppAction(QString desktopFile, QString actionSection, uint32_t timestamp);
|
||||||
void launchAppWithOptions(QString desktopFile, uint32_t timestamp, QStringList files, QMap<QString, QString> options);
|
void launchAppWithOptions(QString desktopFile, uint32_t timestamp, QStringList files, QMap<QString, QString> options);
|
||||||
void runCommand(QString exe, QStringList args);
|
void runCommand(QString exe, QStringList args);
|
||||||
void runCommandWithOptions(QString exe, QStringList args, QMap<QString, QString> options);
|
void runCommandWithOptions(QString exe, QStringList args, QMap<QString, QString> options);
|
||||||
void tryAgain(bool launch);
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void autostartChanged(QString status, QString fileName);
|
void autostartChanged(QString status, QString fileName);
|
||||||
@ -60,6 +58,7 @@ public Q_SLOTS:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool setAutostart(QString fileName, bool value);
|
bool setAutostart(QString fileName, bool value);
|
||||||
|
bool doLaunchAppWithOptions(const QString &desktopFile);
|
||||||
bool doLaunchAppWithOptions(QString desktopFile, uint32_t timestamp, QStringList files, QMap<QString, QString> options);
|
bool doLaunchAppWithOptions(QString desktopFile, uint32_t timestamp, QStringList files, QMap<QString, QString> options);
|
||||||
bool launch(DesktopInfo *info, QString cmdLine, uint32_t timestamp, QStringList files);
|
bool launch(DesktopInfo *info, QString cmdLine, uint32_t timestamp, QStringList files);
|
||||||
bool doRunCommandWithOptions(QString exe, QStringList args, QMap<QString, QString> options);
|
bool doRunCommandWithOptions(QString exe, QStringList args, QMap<QString, QString> options);
|
||||||
|
@ -246,41 +246,6 @@ QList<QDBusObjectPath> ApplicationManager::GetInstances(const QString& id)
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief ApplicationManager::Launch 启动应用
|
|
||||||
* @param id QString("/%1/%2/%3").arg(Apptype).arg(d->m_type == Application::Type::System ? "system" : "user").arg(appId)
|
|
||||||
* @param files 应用打开的文件
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
QDBusObjectPath ApplicationManager::Launch(const QString& id, QStringList files)
|
|
||||||
{
|
|
||||||
qInfo() << "Launch " << id;
|
|
||||||
Q_D(ApplicationManager);
|
|
||||||
if (!d->checkDMsgUid())
|
|
||||||
return {};
|
|
||||||
|
|
||||||
// 创建一个实例
|
|
||||||
for (const QSharedPointer<Application>& app : d->applications) {
|
|
||||||
QString appId = app->id();
|
|
||||||
if (app->id() == id) {
|
|
||||||
// 创建任务所需的数据,并记录到任务队列,等待 loader 消耗
|
|
||||||
QSharedPointer<ApplicationInstance> instance{app->createInstance(files)};
|
|
||||||
const std::string hash{instance->hash().toStdString()};
|
|
||||||
connect(instance.get(), &ApplicationInstance::taskFinished, this, [ = ] {
|
|
||||||
for (auto it = d->tasks.begin(); it != d->tasks.end(); ++it){
|
|
||||||
if (it->first == hash) {
|
|
||||||
d->tasks.erase(it);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
d->tasks.insert(std::make_pair(hash, instance));
|
|
||||||
return instance->path();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ApplicationManager::AddAutostart(QString fileName)
|
bool ApplicationManager::AddAutostart(QString fileName)
|
||||||
{
|
{
|
||||||
Q_D(ApplicationManager);
|
Q_D(ApplicationManager);
|
||||||
@ -308,15 +273,6 @@ QStringList ApplicationManager::AutostartList()
|
|||||||
return d->startManager->autostartList();
|
return d->startManager->autostartList();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ApplicationManager::DumpMemRecord()
|
|
||||||
{
|
|
||||||
Q_D(ApplicationManager);
|
|
||||||
if (!d->checkDMsgUid())
|
|
||||||
return "";
|
|
||||||
|
|
||||||
return d->startManager->dumpMemRecord();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ApplicationManager::IsAutostart(QString fileName)
|
bool ApplicationManager::IsAutostart(QString fileName)
|
||||||
{
|
{
|
||||||
Q_D(ApplicationManager);
|
Q_D(ApplicationManager);
|
||||||
@ -326,16 +282,17 @@ bool ApplicationManager::IsAutostart(QString fileName)
|
|||||||
return d->startManager->isAutostart(fileName);
|
return d->startManager->isAutostart(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ApplicationManager::IsMemSufficient()
|
void ApplicationManager::Launch(const QString &desktopFile)
|
||||||
{
|
{
|
||||||
Q_D(ApplicationManager);
|
Q_D(ApplicationManager);
|
||||||
if (!d->checkDMsgUid())
|
if (!d->checkDMsgUid())
|
||||||
return false;
|
return;
|
||||||
|
|
||||||
return d->startManager->isMemSufficient();
|
d->startManager->launchApp(desktopFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplicationManager::LaunchApp(QString desktopFile, uint32_t timestamp, QStringList files)
|
|
||||||
|
void ApplicationManager::LaunchApp(const QString &desktopFile, uint32_t timestamp, const QStringList &files)
|
||||||
{
|
{
|
||||||
Q_D(ApplicationManager);
|
Q_D(ApplicationManager);
|
||||||
if (!d->checkDMsgUid())
|
if (!d->checkDMsgUid())
|
||||||
@ -362,15 +319,6 @@ void ApplicationManager::LaunchAppWithOptions(QString desktopFile, uint32_t time
|
|||||||
d->startManager->launchAppWithOptions(desktopFile, timestamp, files, options);
|
d->startManager->launchAppWithOptions(desktopFile, timestamp, files, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplicationManager::RunCommand(QString exe, QStringList args)
|
|
||||||
{
|
|
||||||
Q_D(ApplicationManager);
|
|
||||||
if (!d->checkDMsgUid())
|
|
||||||
return;
|
|
||||||
|
|
||||||
d->startManager->runCommand(exe, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ApplicationManager::RunCommandWithOptions(QString exe, QStringList args, QMap<QString, QString> options)
|
void ApplicationManager::RunCommandWithOptions(QString exe, QStringList args, QMap<QString, QString> options)
|
||||||
{
|
{
|
||||||
Q_D(ApplicationManager);
|
Q_D(ApplicationManager);
|
||||||
@ -380,15 +328,6 @@ void ApplicationManager::RunCommandWithOptions(QString exe, QStringList args, QM
|
|||||||
d->startManager->runCommandWithOptions(exe, args, options);
|
d->startManager->runCommandWithOptions(exe, args, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplicationManager::TryAgain(bool launch)
|
|
||||||
{
|
|
||||||
Q_D(ApplicationManager);
|
|
||||||
if (!d->checkDMsgUid())
|
|
||||||
return;
|
|
||||||
|
|
||||||
d->startManager->tryAgain(launch);
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<QDBusObjectPath> ApplicationManager::instances() const
|
QList<QDBusObjectPath> ApplicationManager::instances() const
|
||||||
{
|
{
|
||||||
Q_D(const ApplicationManager);
|
Q_D(const ApplicationManager);
|
||||||
@ -414,28 +353,6 @@ QList<QDBusObjectPath> ApplicationManager::list() const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果app manager拥有全部进程信息,可以在app manger里面获取
|
|
||||||
bool ApplicationManager::IsPidVirtualMachine(uint32_t pid)
|
|
||||||
{
|
|
||||||
Q_D(const ApplicationManager);
|
|
||||||
char buff[256];
|
|
||||||
ssize_t nbytes = readlink(QString("/proc/%1/exe").arg(pid).toStdString().c_str(), buff, 256);
|
|
||||||
if (nbytes == -1) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
std::string execPath(buff);
|
|
||||||
|
|
||||||
for (auto iter : d->virtualMachines) {
|
|
||||||
std::string::size_type idx = iter.find(execPath);
|
|
||||||
|
|
||||||
if (idx != std::string::npos) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ApplicationManager::IsProcessExist(uint32_t pid)
|
bool ApplicationManager::IsProcessExist(uint32_t pid)
|
||||||
{
|
{
|
||||||
Q_D(const ApplicationManager);
|
Q_D(const ApplicationManager);
|
||||||
|
@ -66,19 +66,14 @@ public:
|
|||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void AutostartChanged(QString status, QString filePath);
|
void AutostartChanged(QString status, QString filePath);
|
||||||
|
|
||||||
public Q_SLOTS: // METHODS
|
public Q_SLOTS:
|
||||||
//bool Launch(QString desktopFile); deprecated
|
|
||||||
bool AddAutostart(QString fileName);
|
bool AddAutostart(QString fileName);
|
||||||
QStringList AutostartList();
|
QStringList AutostartList();
|
||||||
QString DumpMemRecord();
|
|
||||||
bool IsAutostart(QString fileName);
|
bool IsAutostart(QString fileName);
|
||||||
bool IsMemSufficient();
|
|
||||||
QDBusObjectPath Launch(const QString &id, QStringList files);
|
|
||||||
bool RemoveAutostart(QString fileName);
|
bool RemoveAutostart(QString fileName);
|
||||||
bool IsPidVirtualMachine(uint32_t pid);
|
void Launch(const QString &desktopFile);
|
||||||
|
void LaunchApp(const QString &desktopFile, uint32_t timestamp, const QStringList &files);
|
||||||
void LaunchAppAction(QString desktopFile, QString action, uint32_t timestamp);
|
void LaunchAppAction(QString desktopFile, QString action, uint32_t timestamp);
|
||||||
void RunCommand(QString exe, QStringList args);
|
|
||||||
void TryAgain(bool launch);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ApplicationManager(QObject *parent = nullptr);
|
ApplicationManager(QObject *parent = nullptr);
|
||||||
@ -88,11 +83,7 @@ protected:
|
|||||||
QList<QDBusObjectPath> list() const;
|
QList<QDBusObjectPath> list() const;
|
||||||
QDBusObjectPath GetInformation(const QString &id);
|
QDBusObjectPath GetInformation(const QString &id);
|
||||||
QList<QDBusObjectPath> GetInstances(const QString &id);
|
QList<QDBusObjectPath> GetInstances(const QString &id);
|
||||||
// com.deepin.StartManager
|
|
||||||
//QString GetApps();
|
|
||||||
void LaunchApp(QString desktopFile, uint32_t timestamp, QStringList files);
|
|
||||||
void LaunchAppWithOptions(QString desktopFile, uint32_t timestamp, QStringList files, QMap<QString, QString> options);
|
void LaunchAppWithOptions(QString desktopFile, uint32_t timestamp, QStringList files, QMap<QString, QString> options);
|
||||||
//bool LaunchWithTimestamp(QString desktopFile, uint32_t timestamp); deprecated
|
|
||||||
void RunCommandWithOptions(QString exe, QStringList args, QMap<QString, QString> options);
|
void RunCommandWithOptions(QString exe, QStringList args, QMap<QString, QString> options);
|
||||||
bool IsProcessExist(uint32_t pid);
|
bool IsProcessExist(uint32_t pid);
|
||||||
};
|
};
|
||||||
|
@ -18,6 +18,10 @@
|
|||||||
|
|
||||||
DCORE_USE_NAMESPACE
|
DCORE_USE_NAMESPACE
|
||||||
|
|
||||||
|
#define ApplicationManagerServiceName "org.desktopspec.ApplicationManager"
|
||||||
|
#define ApplicationManagerServicePath "/org/desktopspec/ApplicationManager"
|
||||||
|
#define ApplicationManagerInterface "org.desktopspec.ApplicationManager"
|
||||||
|
|
||||||
QFileInfoList scan(const QString &path)
|
QFileInfoList scan(const QString &path)
|
||||||
{
|
{
|
||||||
QDir dir(path);
|
QDir dir(path);
|
||||||
@ -83,16 +87,31 @@ int main(int argc, char *argv[])
|
|||||||
new DockManager(ApplicationManager::instance());
|
new DockManager(ApplicationManager::instance());
|
||||||
new ApplicationManagerAdaptor(ApplicationManager::instance());
|
new ApplicationManagerAdaptor(ApplicationManager::instance());
|
||||||
|
|
||||||
QDBusConnection::sessionBus().registerService("org.desktopspec.Application");
|
QDBusConnection connection = QDBusConnection::sessionBus();
|
||||||
QDBusConnection::sessionBus().registerService("org.desktopspec.ApplicationManager");
|
if (!connection.registerService("org.desktopspec.Application")) {
|
||||||
QDBusConnection::sessionBus().registerObject("/org/desktopspec/ApplicationManager", "org.desktopspec.ApplicationManager", ApplicationManager::instance());
|
qWarning() << "error: " << connection.lastError().message();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!connection.registerService(ApplicationManagerServiceName)) {
|
||||||
|
qWarning() << "error: " << connection.lastError().message();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!connection.registerObject(ApplicationManagerServicePath, ApplicationManagerInterface, ApplicationManager::instance())) {
|
||||||
|
qWarning() << "error: " << connection.lastError().message();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
QList<QSharedPointer<Application>> apps{ scanFiles() };
|
QList<QSharedPointer<Application>> apps{ scanFiles() };
|
||||||
QList<QSharedPointer<ApplicationAdaptor>> appAdapters;
|
QList<QSharedPointer<ApplicationAdaptor>> appAdapters;
|
||||||
for (const QSharedPointer<Application> app : apps) {
|
for (const QSharedPointer<Application> app : apps) {
|
||||||
QSharedPointer<ApplicationAdaptor> adapter = QSharedPointer<ApplicationAdaptor>(new ApplicationAdaptor(app.get()));
|
QSharedPointer<ApplicationAdaptor> adapter = QSharedPointer<ApplicationAdaptor>(new ApplicationAdaptor(app.get()));
|
||||||
appAdapters << adapter;
|
appAdapters << adapter;
|
||||||
QDBusConnection::sessionBus().registerObject(app->path().path(), "org.desktopspec.Application", app.get());
|
if (!connection.registerObject(app->path().path(), "org.desktopspec.Application", app.get())) {
|
||||||
|
qWarning() << "error: " << connection.lastError().message();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplicationManager::instance()->addApplication(apps);
|
ApplicationManager::instance()->addApplication(apps);
|
||||||
@ -102,8 +121,15 @@ int main(int argc, char *argv[])
|
|||||||
MimeApp* mimeApp = new MimeApp;
|
MimeApp* mimeApp = new MimeApp;
|
||||||
|
|
||||||
new MimeAdaptor(mimeApp);
|
new MimeAdaptor(mimeApp);
|
||||||
QDBusConnection::sessionBus().registerService("org.deepin.daemon.Mime1");
|
if (!connection.registerService("org.deepin.daemon.Mime1")) {
|
||||||
QDBusConnection::sessionBus().registerObject("/org/deepin/daemon/Mime1", "org.deepin.daemon.Mime1", mimeApp);
|
qWarning() << "error: " << connection.lastError().message();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!connection.registerObject("/org/deepin/daemon/Mime1", "org.deepin.daemon.Mime1", mimeApp)) {
|
||||||
|
qWarning() << "error: " << connection.lastError().message();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user