Lomiri
Loading...
Searching...
No Matches
dbusapplicationmenuregistry.cpp
1/*
2 * Copyright (C) 2016 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "dbusapplicationmenuregistry.h"
18#include "menuregistraradaptor.h"
19
20DBusApplicationMenuRegistry::DBusApplicationMenuRegistry(QObject *parent)
21 : ApplicationMenuRegistry(parent)
22{
23 new MenuRegistrarAdaptor(this);
24
25 QDBusConnection connection = QDBusConnection::sessionBus();
26 if (!connection.registerObject("/com/lomiri/MenuRegistrar", this)) {
27 qCWarning(LOMIRI_APPMENU) << "Unable to register DBus object /com/lomiri/MenuRegistrar";
28 }
29 if (!connection.registerService("com.lomiri.MenuRegistrar")) {
30 qCWarning(LOMIRI_APPMENU) << "Unable to register DBus service com.lomiri.MenuRegistrar";
31 }
32}
33
34DBusApplicationMenuRegistry::~DBusApplicationMenuRegistry()
35{
36 QDBusConnection connection = QDBusConnection::sessionBus();
37 connection.unregisterObject("/com/lomiri/MenuRegistrar");
38}
39
40ApplicationMenuRegistry *DBusApplicationMenuRegistry::instance()
41{
42 static ApplicationMenuRegistry* reg(new DBusApplicationMenuRegistry());
43 return reg;
44}