| 1 | /* |
| 2 | * Copyright (C) 2016 Canonical, Ltd. |
| 3 | * |
| 4 | * This program is free software: you can redistribute it and/or modify it under |
| 5 | * the terms of the GNU Lesser General Public License version 3, as published by |
| 6 | * the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 9 | * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
| 10 | * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 | * Lesser General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU Lesser General Public License |
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ |
| 16 | |
| 17 | #ifndef LOMIRI_MENU_REGISTRY_H |
| 18 | #define LOMIRI_MENU_REGISTRY_H |
| 19 | |
| 20 | #include <QObject> |
| 21 | #include <QScopedPointer> |
| 22 | |
| 23 | class ComLomiriMenuRegistrarInterface; |
| 24 | class QDBusObjectPath; |
| 25 | class QDBusServiceWatcher; |
| 26 | |
| 27 | class LomiriMenuRegistry : public QObject |
| 28 | { |
| 29 | Q_OBJECT |
| 30 | public: |
| 31 | LomiriMenuRegistry(QObject* parent = nullptr); |
| 32 | virtual ~LomiriMenuRegistry(); |
| 33 | |
| 34 | static LomiriMenuRegistry *instance(); |
| 35 | |
| 36 | void registerApplicationMenu(pid_t pid, QDBusObjectPath menuObjectPath, const QString &service); |
| 37 | void unregisterApplicationMenu(pid_t pid, QDBusObjectPath menuObjectPath); |
| 38 | |
| 39 | void registerSurfaceMenu(const QString &surfaceId, QDBusObjectPath menuObjectPath, const QString &service); |
| 40 | void unregisterSurfaceMenu(const QString &surfaceId, QDBusObjectPath menuObjectPath); |
| 41 | |
| 42 | bool isConnected() const { return m_connected; } |
| 43 | |
| 44 | Q_SIGNALS: |
| 45 | void serviceChanged(); |
| 46 | |
| 47 | private Q_SLOTS: |
| 48 | void serviceOwnerChanged(const QString &serviceName, const QString& oldOwner, const QString &newOwner); |
| 49 | |
| 50 | private: |
| 51 | QScopedPointer<QDBusServiceWatcher> m_serviceWatcher; |
| 52 | QScopedPointer<ComLomiriMenuRegistrarInterface> m_interface; |
| 53 | bool m_connected; |
| 54 | }; |
| 55 | |
| 56 | #endif // LOMIRI_MENU_REGISTRY_H |