Add system dbus
This commit is contained in:
parent
79bb52e33e
commit
d9333c0c7c
15
kylin-nm.pro
15
kylin-nm.pro
|
@ -25,8 +25,15 @@ target.source += $$TARGET
|
|||
desktop.path = /etc/xdg/autostart/
|
||||
desktop.files = kylin-nm.desktop
|
||||
|
||||
inst1.files += src/conf/com.kylin.NetworkManager.qt.systemdbus.service
|
||||
inst1.path = /usr/share/dbus-1/system-services/
|
||||
inst2.files += src/conf/com.kylin.NetworkManager.qt.systemdbus.conf
|
||||
inst2.path = /etc/dbus-1/system.d/
|
||||
|
||||
INSTALLS += target \
|
||||
desktop
|
||||
desktop \
|
||||
inst1 \
|
||||
inst2 \
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
# any feature of Qt which has been marked as deprecated (the exact warnings
|
||||
|
@ -58,6 +65,7 @@ SOURCES += \
|
|||
src/oneconnform.cpp \
|
||||
src/onelancform.cpp \
|
||||
src/switchbutton.cpp \
|
||||
src/sysdbusregister.cpp \
|
||||
src/utils.cpp \
|
||||
src/wpawifidialog.cpp \
|
||||
wireless-security/dlghidewifi.cpp \
|
||||
|
@ -85,6 +93,7 @@ HEADERS += \
|
|||
src/oneconnform.h \
|
||||
src/onelancform.h \
|
||||
src/switchbutton.h \
|
||||
src/sysdbusregister.h \
|
||||
src/utils.h \
|
||||
src/wpawifidialog.h \
|
||||
wireless-security/dlghidewifi.h \
|
||||
|
@ -131,4 +140,6 @@ TRANSLATIONS = translations/kylin-nm_zh_CN.ts \
|
|||
translations/kylin-nm_tr.ts \
|
||||
translations/kylin-nm_bo.ts
|
||||
|
||||
DISTFILES +=
|
||||
DISTFILES += \
|
||||
src/conf/com.kylin.NetworkManager.qt.systemdbus.conf \
|
||||
src/conf/com.kylin.NetworkManager.qt.systemdbus.service
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?> <!-- -*- XML -*- -->
|
||||
|
||||
<!DOCTYPE busconfig PUBLIC
|
||||
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
|
||||
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
|
||||
<busconfig>
|
||||
<!-- Only root can own the service -->
|
||||
<policy user="root">
|
||||
<allow own="com.kylin.NetworkManager.qt.systemdbus"/>
|
||||
<allow send_interface="com.kylin.NetworkManager.interface"/>
|
||||
</policy>
|
||||
|
||||
<!-- Allow anyone to invoke methods on the interfaces -->
|
||||
<policy context="default">
|
||||
<allow send_destination="com.kylin.NetworkManager.qt.systemdbus"
|
||||
send_interface="com.kylin.NetworkManager.interface"/>
|
||||
<allow send_destination="com.kylin.NetworkManager.qt.systemdbus"
|
||||
send_interface="org.freedesktop.DBus.Introspectable"/>
|
||||
<allow send_destination="com.kylin.NetworkManager.qt.systemdbus"
|
||||
send_interface="org.freedesktop.DBus.Properties"/>
|
||||
</policy>
|
||||
</busconfig>
|
|
@ -0,0 +1,4 @@
|
|||
[D-BUS Service]
|
||||
Name=com.kylin.NetworkManager.qt.systemdbus
|
||||
Exec=/usr/bin/kylin-nm
|
||||
User=root
|
|
@ -22,6 +22,7 @@
|
|||
#include "onelancform.h"
|
||||
#include "hot-spot/dlghotspotcreate.h"
|
||||
#include "wireless-security/dlghidewifi.h"
|
||||
#include "sysdbusregister.h"
|
||||
|
||||
#include <KWindowEffects>
|
||||
#include <QFont>
|
||||
|
@ -113,6 +114,15 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
ui->btnWifiList->installEventFilter(this);
|
||||
|
||||
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
|
||||
|
||||
QDBusConnection systemBus = QDBusConnection::systemBus();
|
||||
if (!systemBus.registerService("com.kylin.NetworkManager.qt.systemdbus")){
|
||||
qCritical() << "QDbus register service failed reason:" << systemBus.lastError();
|
||||
}
|
||||
|
||||
if (!systemBus.registerObject("/", new SysdbusRegister(), QDBusConnection::ExportAllSlots | QDBusConnection::ExportAllSignals)){
|
||||
qCritical() << "QDbus register object failed reason:" << systemBus.lastError();
|
||||
}
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#include "sysdbusregister.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QSettings>
|
||||
#include <QSharedPointer>
|
||||
|
||||
SysdbusRegister::SysdbusRegister()
|
||||
{
|
||||
}
|
||||
|
||||
SysdbusRegister::~SysdbusRegister()
|
||||
{
|
||||
}
|
||||
|
||||
void SysdbusRegister::systemRun(QString cmd){
|
||||
QProcess::execute(cmd);
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifndef SYSDBUSREGISTER_H
|
||||
#define SYSDBUSREGISTER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QProcess>
|
||||
#include <QDBusError>
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusReply>
|
||||
#include <QDBusInterface>
|
||||
|
||||
#include <QFile>
|
||||
|
||||
class SysdbusRegister : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_CLASSINFO("D-Bus Interface", "com.kylin.NetworkManager.interface")
|
||||
|
||||
public:
|
||||
explicit SysdbusRegister();
|
||||
~SysdbusRegister();
|
||||
|
||||
private:
|
||||
// QString m_name;
|
||||
|
||||
signals:
|
||||
// Q_SCRIPTABLE void nameChanged(QString);
|
||||
// Q_SCRIPTABLE void computerinfo(QString);
|
||||
|
||||
public slots:
|
||||
|
||||
Q_SCRIPTABLE void systemRun(QString cmd);
|
||||
|
||||
};
|
||||
|
||||
#endif // SYSDBUSREGISTER_H
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#include "wpawifidialog.h"
|
||||
#include "ui_wpawifidialog.h"
|
||||
#include "kylin-network-interface.h"
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Copyright (C) 2020 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifndef WPAWIFIDIALOG_H
|
||||
#define WPAWIFIDIALOG_H
|
||||
|
||||
|
|
Loading…
Reference in New Issue