2023-07-10 10:18:33 +08:00
|
|
|
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
|
|
|
#ifndef APPLICATIONMANAGER1SERVICE_H
|
|
|
|
#define APPLICATIONMANAGER1SERVICE_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QDBusObjectPath>
|
|
|
|
#include <QDBusUnixFileDescriptor>
|
2023-07-17 14:49:35 +08:00
|
|
|
#include <QSharedPointer>
|
2023-07-24 14:12:59 +08:00
|
|
|
#include <QScopedPointer>
|
|
|
|
#include <memory>
|
2023-07-17 14:49:35 +08:00
|
|
|
#include <QMap>
|
2023-08-07 14:25:22 +08:00
|
|
|
#include "dbus/jobmanager1service.h"
|
2023-08-21 16:02:26 +08:00
|
|
|
#include "desktopentry.h"
|
2023-07-24 14:12:59 +08:00
|
|
|
#include "identifier.h"
|
2023-07-10 10:18:33 +08:00
|
|
|
|
2023-08-21 16:02:26 +08:00
|
|
|
class ApplicationService;
|
|
|
|
|
2023-07-17 14:49:35 +08:00
|
|
|
class ApplicationManager1Service final : public QObject
|
2023-07-10 10:18:33 +08:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2023-08-21 16:02:26 +08:00
|
|
|
explicit ApplicationManager1Service(std::unique_ptr<Identifier> ptr, QDBusConnection &connection) noexcept;
|
2023-07-17 14:49:35 +08:00
|
|
|
~ApplicationManager1Service() override;
|
|
|
|
ApplicationManager1Service(const ApplicationManager1Service &) = delete;
|
|
|
|
ApplicationManager1Service(ApplicationManager1Service &&) = delete;
|
|
|
|
ApplicationManager1Service &operator=(const ApplicationManager1Service &) = delete;
|
2023-07-21 14:47:40 +08:00
|
|
|
ApplicationManager1Service &operator=(ApplicationManager1Service &&) = delete;
|
2023-07-10 10:18:33 +08:00
|
|
|
|
|
|
|
Q_PROPERTY(QList<QDBusObjectPath> List READ list)
|
2023-08-10 14:32:09 +08:00
|
|
|
[[nodiscard]] QList<QDBusObjectPath> list() const;
|
2023-08-16 17:44:56 +08:00
|
|
|
|
2023-08-20 18:25:59 +08:00
|
|
|
bool addApplication(DesktopFile desktopFileSource) noexcept;
|
|
|
|
void removeOneApplication(const QDBusObjectPath &application) noexcept;
|
|
|
|
void removeAllApplication() noexcept;
|
2023-08-16 17:44:56 +08:00
|
|
|
|
2023-08-20 18:25:59 +08:00
|
|
|
void updateApplication(const QSharedPointer<ApplicationService> &destApp, const DesktopFile &desktopFile) noexcept;
|
2023-08-11 17:46:46 +08:00
|
|
|
|
2023-07-24 14:12:59 +08:00
|
|
|
JobManager1Service &jobManager() noexcept { return *m_jobManager; }
|
|
|
|
|
2023-07-10 10:18:33 +08:00
|
|
|
public Q_SLOTS:
|
|
|
|
QString Identify(const QDBusUnixFileDescriptor &pidfd, QDBusObjectPath &application, QDBusObjectPath &application_instance);
|
2023-08-11 17:46:46 +08:00
|
|
|
void UpdateApplicationInfo(const QStringList &appIdList);
|
2023-08-18 10:01:52 +08:00
|
|
|
[[nodiscard]] ObjectMap GetManagedObjects() const;
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void InterfacesAdded(const QDBusObjectPath &object_path, const QStringList &interfaces);
|
|
|
|
void InterfacesRemoved(const QDBusObjectPath &object_path, const QStringList &interfaces);
|
2023-07-17 14:49:35 +08:00
|
|
|
|
|
|
|
private:
|
2023-07-24 14:12:59 +08:00
|
|
|
std::unique_ptr<Identifier> m_identifier;
|
|
|
|
QScopedPointer<JobManager1Service> m_jobManager{nullptr};
|
2023-07-21 14:47:40 +08:00
|
|
|
QMap<QDBusObjectPath, QSharedPointer<ApplicationService>> m_applicationList;
|
2023-07-10 10:18:33 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|