update the wired network list after create new network by dbus method
This commit is contained in:
parent
99db999388
commit
2ea3d456e4
|
@ -189,8 +189,6 @@ void ConfForm::on_btnCreate_clicked()
|
|||
this->on_btnOk_clicked();
|
||||
}
|
||||
|
||||
sleep(2);
|
||||
emit this->updateNetList();
|
||||
this->hide();
|
||||
}
|
||||
|
||||
|
|
|
@ -64,9 +64,6 @@ private:
|
|||
QPoint dragPos;
|
||||
bool isActConf;
|
||||
bool isShowSaveBtn = true;
|
||||
|
||||
signals:
|
||||
void updateNetList();
|
||||
};
|
||||
|
||||
#endif // CONFFORM_H
|
||||
|
|
|
@ -1,3 +1,21 @@
|
|||
/*
|
||||
* Copyright (C) 2019 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 "dlghotspotcreate.h"
|
||||
#include "ui_dlghotspotcreate.h"
|
||||
|
||||
|
|
|
@ -42,6 +42,11 @@ KylinDBus::KylinDBus(MainWindow *mainWindow, QObject *parent) :QObject(parent)
|
|||
QString("org.freedesktop.NetworkManager"),
|
||||
QString("DeviceRemoved"), mw, SLOT(onWirelessDeviceRemoved(QDBusObjectPath) ) );
|
||||
|
||||
QDBusConnection::systemBus().connect(QString("org.freedesktop.NetworkManager"),
|
||||
QString("/org/freedesktop/NetworkManager/Settings"),
|
||||
QString("org.freedesktop.NetworkManager.Settings"),
|
||||
QString("NewConnection"), this, SLOT(onNewConnection(QDBusObjectPath) ) );
|
||||
|
||||
QDBusConnection::systemBus().connect(QString("org.freedesktop.NetworkManager"),
|
||||
QString(wiredPath.path()),
|
||||
QString("org.freedesktop.NetworkManager.Device.Wired"),
|
||||
|
@ -63,6 +68,8 @@ KylinDBus::KylinDBus(MainWindow *mainWindow, QObject *parent) :QObject(parent)
|
|||
time = new QTimer(this);
|
||||
time->setTimerType(Qt::PreciseTimer);
|
||||
QObject::connect(time, SIGNAL(timeout()), this, SLOT(slot_timeout()));
|
||||
|
||||
QObject::connect(this, SIGNAL(updateWiredList(int)), mw, SLOT(onBtnNetListClicked(int)));
|
||||
}
|
||||
|
||||
void KylinDBus::getObjectPath()
|
||||
|
@ -336,6 +343,27 @@ int KylinDBus::getLanConnState()
|
|||
return 0;
|
||||
}
|
||||
|
||||
void KylinDBus::onNewConnection(QDBusObjectPath objPath)
|
||||
{
|
||||
QDBusInterface m_interface("org.freedesktop.NetworkManager",
|
||||
objPath.path(),
|
||||
"org.freedesktop.NetworkManager.Settings.Connection",
|
||||
QDBusConnection::systemBus());
|
||||
QDBusMessage result = m_interface.call("GetSettings");
|
||||
|
||||
const QDBusArgument &dbusArg1st = result.arguments().at( 0 ).value<QDBusArgument>();
|
||||
QMap<QString,QMap<QString,QVariant>> map;
|
||||
dbusArg1st >> map;
|
||||
|
||||
for(QString key : map.keys() ){
|
||||
if (key == "802-3-ethernet") {
|
||||
emit this->updateWiredList(0);
|
||||
syslog(LOG_DEBUG, "A new wired network was created.");
|
||||
qDebug()<<"A new wired network was created.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KylinDBus::onLanPropertyChanged(QVariantMap qvm)
|
||||
{
|
||||
if (!isRunningFunction) {
|
||||
|
|
|
@ -40,6 +40,7 @@ public:
|
|||
QString dbusWifiMac = "";
|
||||
|
||||
public slots:
|
||||
void onNewConnection(QDBusObjectPath objPath);
|
||||
void onLanPropertyChanged(QVariantMap qvm);
|
||||
void onWifiPropertyChanged(QVariantMap qvm);
|
||||
void onAccessPointAdded(QDBusObjectPath objPath);
|
||||
|
@ -58,6 +59,10 @@ private:
|
|||
int a = 0;
|
||||
bool isRunningFunction = false;
|
||||
QTimer *time;
|
||||
|
||||
signals:
|
||||
void updateWiredList(int n);
|
||||
|
||||
};
|
||||
|
||||
#endif // KYLINDBUSINTERFACE_H
|
||||
|
|
|
@ -125,7 +125,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
lbNoItemTip = new QLabel(ui->centralWidget);
|
||||
lbNoItemTip->resize(200, 20);
|
||||
lbNoItemTip->move(this->width()/2 - 200/2 + 41/2, this->height()/2 + 96);
|
||||
lbNoItemTip->setStyleSheet("QLabel{boder:none;background:transparent;font-size:14px;color:rgba(255,255,255,0.91);}");
|
||||
lbNoItemTip->setStyleSheet("QLabel{border:none;background:transparent;font-size:14px;color:rgba(255,255,255,0.91);}");
|
||||
lbNoItemTip->setText(tr("No usable network in the list"));//列表暂无可连接网络
|
||||
lbNoItemTip->setAlignment(Qt::AlignCenter);
|
||||
lbNoItemTip->hide();
|
||||
|
@ -277,7 +277,12 @@ MainWindow::~MainWindow()
|
|||
|
||||
void MainWindow::checkSingle()
|
||||
{
|
||||
int fd = open("/tmp/kylin-nm-lock", O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
|
||||
//int fd = open("/tmp/kylin-nm-lock", O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
|
||||
|
||||
QStringList homePath = QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
|
||||
QString lockPath = homePath.at(0) + "/.config/kylin-nm-lock";
|
||||
int fd = open(lockPath.toUtf8().data(), O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
|
||||
|
||||
if (fd < 0) { exit(1); }
|
||||
|
||||
if (lockf(fd, F_TLOCK, 0)) {
|
||||
|
@ -2368,7 +2373,6 @@ void MainWindow::onBtnAddNetClicked()
|
|||
void MainWindow::onBtnCreateNetClicked()
|
||||
{
|
||||
ConfForm *m_cf = new ConfForm();
|
||||
connect(m_cf, SIGNAL(updateNetList()), this, SLOT(onBtnNetListClicked()));
|
||||
m_cf->cbTypeChanged(3);
|
||||
m_cf->show();
|
||||
}
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
#include <QtDBus/QDBusObjectPath>
|
||||
#include <QDBusObjectPath>
|
||||
#include <QVariant>
|
||||
#include <QStandardPaths>
|
||||
#include <QStringList>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
|
|
|
@ -1,10 +1,25 @@
|
|||
/*
|
||||
* Copyright (C) 2019 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 "networkspeed.h"
|
||||
#include <stdio.h>
|
||||
|
||||
NetworkSpeed::NetworkSpeed(QObject *parent) :QObject(parent)
|
||||
{
|
||||
qDebug()<<"debug: this is creator function of class NetworkSpeed";
|
||||
}
|
||||
NetworkSpeed::NetworkSpeed(QObject *parent) :QObject(parent){}
|
||||
|
||||
int NetworkSpeed::getCurrentDownloadRates(char *netname, long *save_rate, long *tx_rate)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue