2023-07-10 10:18:33 +08:00
|
|
|
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
2023-08-07 14:25:22 +08:00
|
|
|
#include "dbus/jobmanager1service.h"
|
|
|
|
#include "dbus/jobmanager1adaptor.h"
|
2023-07-10 10:18:33 +08:00
|
|
|
|
2023-07-24 14:12:59 +08:00
|
|
|
JobManager1Service::JobManager1Service(ApplicationManager1Service *parent)
|
|
|
|
: m_parent(parent)
|
|
|
|
{
|
2023-08-11 10:12:46 +08:00
|
|
|
new JobManager1Adaptor{this};
|
2023-09-20 18:29:42 +08:00
|
|
|
if (!registerObjectToDBus(this, DDEApplicationManager1JobManager1ObjectPath, JobManager1Interface)) {
|
2023-07-24 14:12:59 +08:00
|
|
|
std::terminate();
|
|
|
|
}
|
2023-08-11 10:12:46 +08:00
|
|
|
qRegisterMetaType<LaunchTask>();
|
2023-07-24 14:12:59 +08:00
|
|
|
}
|
2023-07-17 14:49:35 +08:00
|
|
|
|
|
|
|
JobManager1Service::~JobManager1Service() = default;
|
2023-07-24 14:12:59 +08:00
|
|
|
|
|
|
|
bool JobManager1Service::removeOneJob(const QDBusObjectPath &path)
|
|
|
|
{
|
|
|
|
decltype(m_jobs)::size_type removeCount{0};
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&m_mutex};
|
|
|
|
removeCount = m_jobs.remove(path);
|
|
|
|
}
|
|
|
|
// removeCount means m_jobs can't find value which corresponding with path
|
|
|
|
// and we shouldn't emit jobRemoved signal because this signal may already has been emit
|
|
|
|
if (removeCount == 0) {
|
|
|
|
qWarning() << "Job already has been removed: " << path.path();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
unregisterObjectFromDBus(path.path());
|
|
|
|
return true;
|
|
|
|
}
|