Improve the stability of kylin-nm software.
This commit is contained in:
parent
1d02bbc335
commit
2f159df25c
249
backthread.cpp
249
backthread.cpp
|
@ -18,10 +18,22 @@
|
|||
|
||||
#include "backthread.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <QFile>
|
||||
#include <QRegExp>
|
||||
|
||||
BackThread::BackThread(QObject *parent) : QObject(parent){
|
||||
cmd = new QProcess(this);
|
||||
connect(cmd , SIGNAL(readyReadStandardOutput()) , this , SLOT(on_readoutput()));
|
||||
connect(cmd , SIGNAL(readyReadStandardError()) , this , SLOT(on_readerror()));
|
||||
cmd->start("bash");
|
||||
cmd->waitForStarted();
|
||||
}
|
||||
|
||||
BackThread::~BackThread()
|
||||
{
|
||||
cmd->close();
|
||||
}
|
||||
|
||||
IFace* BackThread::execGetIface(){
|
||||
|
@ -32,7 +44,8 @@ IFace* BackThread::execGetIface(){
|
|||
QFile file("/tmp/kylin-nm-iface");
|
||||
if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
{
|
||||
qDebug()<<"Can't open the file!"<<endl;
|
||||
syslog(LOG_ERR, "Can't open the file /tmp/kylin-nm-iface!");
|
||||
qDebug()<<"Can't open the file /tmp/kylin-nm-iface!"<<endl;
|
||||
}
|
||||
QString txt = file.readAll();
|
||||
QStringList txtList = txt.split("\n");
|
||||
|
@ -84,60 +97,87 @@ IFace* BackThread::execGetIface(){
|
|||
}
|
||||
|
||||
void BackThread::execEnNet(){
|
||||
system("nmcli networking on;sleep 5");
|
||||
emit enNetDone();
|
||||
emit btFinish();
|
||||
system("nmcli networking on");
|
||||
while(1){
|
||||
if (execGetIface()->lstate != 2){
|
||||
sleep(3);
|
||||
emit enNetDone();
|
||||
emit btFinish();
|
||||
break;
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
void BackThread::execDisNet(){
|
||||
system("nmcli networking off;sleep 3");
|
||||
emit disNetDone();
|
||||
emit btFinish();
|
||||
if (execGetIface()->wstate != 2){
|
||||
system("nmcli radio wifi off");
|
||||
while(1){
|
||||
if (execGetIface()->wstate == 2){
|
||||
emit disWifiDone();
|
||||
emit btFinish();
|
||||
break;
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
system("nmcli networking off");
|
||||
while(1){
|
||||
if (execGetIface()->lstate == 2){
|
||||
emit disNetDone();
|
||||
emit btFinish();
|
||||
break;
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
void BackThread::execEnWifi(){
|
||||
if (execGetIface()->lstate == 2){
|
||||
system("nmcli networking on;sleep 3");
|
||||
emit launchLanDone();
|
||||
system("nmcli networking on");
|
||||
while(1){
|
||||
if (execGetIface()->lstate != 2){
|
||||
emit launchLanDone();
|
||||
break;
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
system("nmcli radio wifi on");
|
||||
while(1){
|
||||
if (execGetIface()->wstate != 2){
|
||||
KylinDBus objKyDbus;
|
||||
while(1){
|
||||
if (objKyDbus.getAccessPointsNumber() > 0){
|
||||
emit enWifiDone();
|
||||
emit btFinish();
|
||||
break;
|
||||
}
|
||||
sleep(2);
|
||||
}
|
||||
break;
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
system("nmcli radio wifi on;sleep 6");
|
||||
emit enWifiDone();
|
||||
emit btFinish();
|
||||
}
|
||||
|
||||
void BackThread::execDisWifi(){
|
||||
system("nmcli radio wifi off;sleep 3");
|
||||
emit disWifiDone();
|
||||
emit btFinish();
|
||||
system("nmcli radio wifi off");
|
||||
while(1){
|
||||
if (execGetIface()->wstate == 2){
|
||||
emit disWifiDone();
|
||||
emit btFinish();
|
||||
break;
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
void BackThread::execConnLan(QString connName){
|
||||
QString net_card = "ifconfig>/tmp/kylin-nm-ifconfig";
|
||||
system(net_card.toUtf8().data());
|
||||
lanDelete(); //连接前先断开已经连接的有线网
|
||||
|
||||
QFile file("/tmp/kylin-nm-ifconfig");
|
||||
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
qDebug()<<"Can't open the file kylin-nm-ifconfig!"<<endl;
|
||||
}
|
||||
|
||||
QString txt = file.readLine();
|
||||
QString strType;
|
||||
int i = 0;
|
||||
while(1){
|
||||
if (txt[i] == ":"){ break; }
|
||||
strType += txt[i];
|
||||
i += 1;
|
||||
}
|
||||
|
||||
QString carrierPath ="/sys/class/net/" + strType + "/carrier";
|
||||
QFile sys_carrier(carrierPath);
|
||||
if(!sys_carrier.open(QIODevice::ReadOnly | QIODevice::Text)){
|
||||
qDebug()<<"Can't open the file carrier in documentary"<<strType <<endl;
|
||||
}
|
||||
|
||||
QString sys_line = sys_carrier.readLine();
|
||||
sys_carrier.close();
|
||||
if(sys_line.indexOf("1") != -1){
|
||||
KylinDBus objKyDbus;
|
||||
if(objKyDbus.isWiredCableOn){
|
||||
QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up '" + connName + "'";
|
||||
system(cmd.toUtf8().data());
|
||||
emit connDone(0);
|
||||
|
@ -148,21 +188,48 @@ void BackThread::execConnLan(QString connName){
|
|||
emit btFinish();
|
||||
}
|
||||
|
||||
void BackThread::execConnWifi(QString connName){
|
||||
QString cmd = "/usr/share/kylin-nm/shell/connup.sh '" + connName + "'";
|
||||
void BackThread::execConnWifiPWD(QString connName, QString password){
|
||||
wifiDelete(); //连接前先断开已经连接的wifi
|
||||
|
||||
QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli device wifi connect '" + connName + "' password '" + password + "' > /tmp/kylin-nm-btoutput";
|
||||
system(cmd.toUtf8().data());
|
||||
|
||||
QFile file("/tmp/kylin-nm-btoutput_");
|
||||
QFile file("/tmp/kylin-nm-btoutput");
|
||||
if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
{
|
||||
qDebug()<<"Can't open the file!"<<endl;
|
||||
syslog(LOG_DEBUG, "Can't open the file /tmp/kylin-nm-btoutput !");
|
||||
qDebug()<<"Can't open the file /tmp/kylin-nm-btoutput !"<<endl;
|
||||
}
|
||||
QString line = file.readLine();
|
||||
file.close();
|
||||
|
||||
if(line.indexOf("successfully") != -1){
|
||||
emit connDone(0);
|
||||
}else if(line.indexOf("unknown") != -1){
|
||||
}else{
|
||||
QString txt(tr("Confirm your Wi-Fi password"));
|
||||
QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "...' -t 3800";
|
||||
system(cmd.toUtf8().data());
|
||||
emit connDone(1);
|
||||
}
|
||||
|
||||
emit btFinish();
|
||||
}
|
||||
|
||||
void BackThread::execConnWifi(QString connName){
|
||||
wifiDelete(); //连接前先断开已经连接的wifi
|
||||
|
||||
QString cmdStr = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up '" + connName + "'\n";
|
||||
cmd->write(cmdStr.toUtf8().data());
|
||||
}
|
||||
|
||||
void BackThread::on_readoutput()
|
||||
{
|
||||
QString str = cmd->readAllStandardOutput();
|
||||
cmd->close();
|
||||
qDebug()<<"on_readoutput: "<< str;
|
||||
if(str.indexOf("successfully") != -1){
|
||||
emit connDone(0);
|
||||
}else if(str.indexOf("unknown") != -1){
|
||||
emit connDone(2);
|
||||
}else{
|
||||
emit connDone(1);
|
||||
|
@ -171,20 +238,15 @@ void BackThread::execConnWifi(QString connName){
|
|||
emit btFinish();
|
||||
}
|
||||
|
||||
void BackThread::execConnWifiPWD(QString connName, QString password){
|
||||
QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli device wifi connect '" + connName + "' password '" + password + "' > /tmp/kylin-nm-btoutput";
|
||||
system(cmd.toUtf8().data());
|
||||
|
||||
QFile file("/tmp/kylin-nm-btoutput");
|
||||
if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
{
|
||||
qDebug()<<"Can't open the file!"<<endl;
|
||||
}
|
||||
QString line = file.readLine();
|
||||
file.close();
|
||||
|
||||
if(line.indexOf("successfully") != -1){
|
||||
void BackThread::on_readerror()
|
||||
{
|
||||
QString str = cmd->readAllStandardError();
|
||||
cmd->close();
|
||||
qDebug()<<"on_readerror: "<< str;
|
||||
if(str.indexOf("successfully") != -1){
|
||||
emit connDone(0);
|
||||
}else if(str.indexOf("unknown") != -1){
|
||||
emit connDone(2);
|
||||
}else{
|
||||
emit connDone(1);
|
||||
}
|
||||
|
@ -199,7 +261,8 @@ QString BackThread::getConnProp(QString connName){
|
|||
QFile file("/tmp/kylin-nm-connprop");
|
||||
if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
{
|
||||
qDebug()<<"Can't open the file!"<<endl;
|
||||
syslog(LOG_ERR, "Can't open the file /tmp/kylin-nm-connprop!");
|
||||
qDebug()<<"Can't open the file /tmp/kylin-nm-connprop!"<<endl;
|
||||
}
|
||||
|
||||
QString txt = file.readAll();
|
||||
|
@ -251,7 +314,8 @@ bool BackThread::execChkWifiExist(QString connName){
|
|||
QFile file("/tmp/kylin-nm-chkwifiexist");
|
||||
if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
{
|
||||
qDebug()<<"Can't open the file!"<<endl;
|
||||
syslog(LOG_ERR, "Can't open the file /tmp/kylin-nm-chkwifiexist!");
|
||||
qDebug()<<"Can't open the file /tmp/kylin-nm-chkwifiexist!"<<endl;
|
||||
}
|
||||
QString line = file.readLine();
|
||||
file.close();
|
||||
|
@ -270,7 +334,8 @@ QString BackThread::execChkLanWidth(QString ethName){
|
|||
QFile file("/tmp/kylin-nm-bandwidth");
|
||||
if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
{
|
||||
qDebug()<<"Can't open the file!"<<endl;
|
||||
syslog(LOG_ERR, "Can't open the file /tmp/kylin-nm-bandwidth!");
|
||||
qDebug()<<"Can't open the file /tmp/kylin-nm-bandwidth!"<<endl;
|
||||
}
|
||||
QString line = file.readLine();
|
||||
file.close();
|
||||
|
@ -282,5 +347,65 @@ QString BackThread::execChkLanWidth(QString ethName){
|
|||
|
||||
QString rtn = params.at(1);
|
||||
return rtn.trimmed();
|
||||
|
||||
}
|
||||
|
||||
void BackThread::redundantNetDeleted()
|
||||
{
|
||||
sleep(1);
|
||||
wifiDelete();
|
||||
|
||||
emit disFinish();
|
||||
emit ttFinish();
|
||||
}
|
||||
|
||||
void BackThread::wifiDelete()
|
||||
{
|
||||
QString strSlist;
|
||||
system("nmcli connection show -active>/tmp/kylin-nm-connshow");
|
||||
QFile file("/tmp/kylin-nm-connshow");
|
||||
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
|
||||
syslog(LOG_ERR, "Can't open the file /tmp/kylin-nm-connshow!");
|
||||
qDebug()<<"Can't open the file /tmp/kylin-nm-connshow!";
|
||||
}
|
||||
|
||||
QString txt = file.readAll();
|
||||
QStringList txtLine = txt.split("\n");
|
||||
file.close();
|
||||
foreach (QString line, txtLine) {
|
||||
if(line.indexOf("wifi") != -1){
|
||||
QStringList subLine = line.split(" ");
|
||||
if (subLine[1].size() == 1){
|
||||
strSlist = subLine[0]+ " " + subLine[1];
|
||||
}else {
|
||||
strSlist = subLine[0];
|
||||
}
|
||||
kylin_network_set_con_down(strSlist.toUtf8().data());
|
||||
}
|
||||
} //end foreach
|
||||
}
|
||||
|
||||
void BackThread::lanDelete()
|
||||
{
|
||||
QString strSlist;
|
||||
system("nmcli connection show -active>/tmp/kylin-nm-connshow");
|
||||
QFile file("/tmp/kylin-nm-connshow");
|
||||
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
|
||||
syslog(LOG_DEBUG, "Can't open the file /tmp/kylin-nm-connshow!");
|
||||
qDebug()<<"Can't open the file /tmp/kylin-nm-connshow!";
|
||||
}
|
||||
|
||||
QString txt = file.readAll();
|
||||
QStringList txtLine = txt.split("\n");
|
||||
file.close();
|
||||
foreach (QString line, txtLine) {
|
||||
if(line.indexOf("ethernet") != -1){
|
||||
QStringList subLine = line.split(" ");
|
||||
if (subLine[1].size() == 1){
|
||||
strSlist = subLine[0]+ " " + subLine[1];
|
||||
}else {
|
||||
strSlist = subLine[0];
|
||||
}
|
||||
kylin_network_set_con_down(strSlist.toUtf8().data());
|
||||
}
|
||||
} //end foreach
|
||||
}
|
||||
|
|
18
backthread.h
18
backthread.h
|
@ -19,8 +19,17 @@
|
|||
#ifndef BACKTHREAD_H
|
||||
#define BACKTHREAD_H
|
||||
|
||||
#include "kylin-dbus-interface.h"
|
||||
#include "kylin-network-interface.h"
|
||||
|
||||
#include <sys/syslog.h>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
#include <QTimer>
|
||||
#include <QProcess>
|
||||
#include <QDBusInterface>
|
||||
#include <QDBusMessage>
|
||||
#include <QDBusArgument>
|
||||
|
||||
class IFace{
|
||||
public:
|
||||
|
@ -35,11 +44,13 @@ class BackThread : public QObject
|
|||
Q_OBJECT
|
||||
public:
|
||||
explicit BackThread(QObject *parent = nullptr);
|
||||
~BackThread();
|
||||
|
||||
IFace* execGetIface();
|
||||
QString getConnProp(QString connName);
|
||||
bool execChkWifiExist(QString connName);
|
||||
QString execChkLanWidth(QString ethName);
|
||||
QProcess *cmd;
|
||||
|
||||
signals:
|
||||
void enNetDone();
|
||||
|
@ -51,6 +62,8 @@ signals:
|
|||
void connDone(int connFlag);
|
||||
|
||||
void btFinish();
|
||||
void disFinish();
|
||||
void ttFinish();
|
||||
|
||||
public slots:
|
||||
void execEnNet();
|
||||
|
@ -60,6 +73,11 @@ public slots:
|
|||
void execConnLan(QString connName);
|
||||
void execConnWifi(QString connName);
|
||||
void execConnWifiPWD(QString connName, QString password);
|
||||
void redundantNetDeleted();
|
||||
void lanDelete();
|
||||
void wifiDelete();
|
||||
void on_readoutput();
|
||||
void on_readerror();
|
||||
};
|
||||
|
||||
#endif // BACKTHREAD_H
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
#!/bin/bash
|
||||
export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up "$1" &> /tmp/kylin-nm-btoutput_
|
|
@ -0,0 +1 @@
|
|||
./man/kylin-nm.1
|
|
@ -0,0 +1 @@
|
|||
18c1694c9d87adc92ebb3d79a081909857f60aff
|
|
@ -0,0 +1,13 @@
|
|||
Package: kylin-nm-dbgsym
|
||||
Package-Type: ddeb
|
||||
Source: kylin-nm
|
||||
Version: 1.0.4-1
|
||||
Auto-Built-Package: debug-symbols
|
||||
Architecture: amd64
|
||||
Maintainer: Kylin Team <team+kylin@tracker.debian.org>
|
||||
Installed-Size: 2144
|
||||
Depends: kylin-nm (= 1.0.4-1)
|
||||
Section: debug
|
||||
Priority: optional
|
||||
Description: debug symbols for kylin-nm
|
||||
Build-Ids: 18c1694c9d87adc92ebb3d79a081909857f60aff
|
|
@ -0,0 +1 @@
|
|||
469c8cb42ada0c9dd27938a1626a381a usr/lib/debug/.build-id/18/c1694c9d87adc92ebb3d79a081909857f60aff.debug
|
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
kylin-nm
|
|
@ -5,6 +5,7 @@ Maintainer: Kylin Team <team+kylin@tracker.debian.org>
|
|||
Uploaders: handsome_feng <jianfengli@ubuntukylin.com>
|
||||
Build-Depends: debhelper-compat (= 12),
|
||||
qtbase5-dev,
|
||||
libnotify-bin,
|
||||
libqt5x11extras5-dev (>= 5.11.1-2),
|
||||
Standards-Version: 4.4.1
|
||||
Rules-Requires-Root: no
|
||||
|
@ -16,6 +17,7 @@ Package: kylin-nm
|
|||
Architecture: any
|
||||
Depends: libqt5x11extras5 (>= 5.11.1-2),
|
||||
network-manager (>=1.12.4),
|
||||
libnotify-bin,
|
||||
${shlibs:Depends},
|
||||
${misc:Depends}
|
||||
Description: Gui Applet tool for display and edit network simply
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
kylin-nm
|
|
@ -0,0 +1,3 @@
|
|||
kylin-nm-dbgsym_1.0.4-1_amd64.ddeb debug optional automatic=yes
|
||||
kylin-nm_1.0.4-1_amd64.buildinfo utils optional
|
||||
kylin-nm_1.0.4-1_amd64.deb utils optional
|
|
@ -0,0 +1,3 @@
|
|||
shlibs:Depends=libc6 (>= 2.14), libgcc1 (>= 1:3.0), libqt5core5a (>= 5.12.2), libqt5dbus5 (>= 5.0.2), libqt5gui5 (>= 5.7.0) | libqt5gui5-gles (>= 5.7.0), libqt5widgets5 (>= 5.2.0), libstdc++6 (>= 5)
|
||||
misc:Depends=
|
||||
misc:Pre-Depends=
|
|
@ -18,24 +18,33 @@
|
|||
|
||||
#include "ksimplenm.h"
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <QThread>
|
||||
#define MAX_LEN 2048
|
||||
#define MAX_PATH 1024
|
||||
|
||||
KSimpleNM::KSimpleNM(QObject *parent) : QObject(parent)
|
||||
{
|
||||
runShellProcess =new QProcess(this);
|
||||
runShellProcess = new QProcess(this);
|
||||
|
||||
connect(runShellProcess, &QProcess::readyRead, this, &KSimpleNM::readProcess);
|
||||
connect(runShellProcess, SIGNAL(finished(int)), this, SLOT(finishedProcess(int)));
|
||||
}
|
||||
|
||||
void KSimpleNM::execGetLanList(){
|
||||
if (isExecutingGetWifiList){
|
||||
syslog(LOG_DEBUG, "It is running getting wifi list when getting lan list");
|
||||
qDebug()<<"debug: it is running getting wifi list when getting lan list";
|
||||
isUseOldLanSlist = true;
|
||||
}
|
||||
isExecutingGetLanList = true;
|
||||
shellOutput = "";
|
||||
type = 0;
|
||||
runShellProcess->start("nmcli -f type,device,name connection show");
|
||||
}
|
||||
|
||||
void KSimpleNM::execGetWifiList(){
|
||||
isExecutingGetWifiList = true;
|
||||
shellOutput = "";
|
||||
type = 1;
|
||||
runShellProcess->start("nmcli -f signal,rate,security,ssid device wifi");
|
||||
|
@ -50,7 +59,9 @@ void KSimpleNM::finishedProcess(int msg){
|
|||
QStringList slist = shellOutput.split("\n");
|
||||
if(type == 0){
|
||||
emit getLanListFinished(slist);
|
||||
isExecutingGetLanList = false;
|
||||
}else{
|
||||
emit getWifiListFinished(slist);
|
||||
isExecutingGetWifiList = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#ifndef KSIMPLENM_H
|
||||
#define KSIMPLENM_H
|
||||
|
||||
#include <sys/syslog.h>
|
||||
#include <QObject>
|
||||
#include <QProcess>
|
||||
#include <QDebug>
|
||||
|
@ -32,6 +33,9 @@ public:
|
|||
QProcess *runShellProcess;
|
||||
QString shellOutput;
|
||||
int type;
|
||||
bool isExecutingGetLanList = false;
|
||||
bool isExecutingGetWifiList = false;
|
||||
bool isUseOldLanSlist = false;
|
||||
|
||||
void execGetLanList();
|
||||
void execGetWifiList();
|
||||
|
|
|
@ -0,0 +1,169 @@
|
|||
/*
|
||||
* 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 "kylin-dbus-interface.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
|
||||
KylinDBus::KylinDBus(MainWindow *mainWindow, QObject *parent) :QObject(parent)
|
||||
{
|
||||
this->mw = mainWindow;
|
||||
|
||||
getObjectPath(); //获取dbus中 lan 与 WiFi 的device路径
|
||||
getPhysicalCarrierState(0); //初始化获取网线插入状态
|
||||
|
||||
QDBusConnection::systemBus().connect(QString("org.freedesktop.NetworkManager"),
|
||||
QString("/org/freedesktop/NetworkManager"),
|
||||
QString("org.freedesktop.NetworkManager"),
|
||||
QString("DeviceAdded"), mw, SLOT(onWirelessDeviceAdded(QDBusObjectPath) ) );
|
||||
|
||||
QDBusConnection::systemBus().connect(QString("org.freedesktop.NetworkManager"),
|
||||
QString("/org/freedesktop/NetworkManager"),
|
||||
QString("org.freedesktop.NetworkManager"),
|
||||
QString("DeviceRemoved"), mw, SLOT(onWirelessDeviceRemoved(QDBusObjectPath) ) );
|
||||
|
||||
QDBusConnection::systemBus().connect(QString("org.freedesktop.NetworkManager"),
|
||||
QString(wiredPath.path()),
|
||||
QString("org.freedesktop.NetworkManager.Device.Wired"),
|
||||
QString("PropertiesChanged"), this, SLOT(onLanPropertyChanged(QVariantMap) ) );
|
||||
|
||||
if (wiredPath.path() != ""){
|
||||
QDBusConnection::systemBus().connect(QString("org.freedesktop.NetworkManager"),
|
||||
QString(wirelessPath.path()),
|
||||
QString("org.freedesktop.NetworkManager.Device.Wireless"),
|
||||
QString("PropertiesChanged"), this, SLOT(onWifiPropertyChanged(QVariantMap) ) );
|
||||
|
||||
QDBusConnection::systemBus().connect(QString("org.freedesktop.NetworkManager"),
|
||||
QString(wirelessPath.path()),
|
||||
QString("org.freedesktop.NetworkManager.Device.Wireless"),
|
||||
QString("AccessPointAdded"), this, SLOT(onAccessPointAdded(QDBusObjectPath) ) );
|
||||
}
|
||||
|
||||
time = new QTimer(this);
|
||||
time->setTimerType(Qt::PreciseTimer);
|
||||
QObject::connect(time, SIGNAL(timeout()), this, SLOT(slot_timeout()));
|
||||
}
|
||||
|
||||
void KylinDBus::getObjectPath()
|
||||
{
|
||||
QDBusInterface m_interface( "org.freedesktop.NetworkManager",
|
||||
"/org/freedesktop/NetworkManager",
|
||||
"org.freedesktop.NetworkManager",
|
||||
QDBusConnection::systemBus() );
|
||||
|
||||
QDBusReply<QList<QDBusObjectPath>> obj_reply = m_interface.call("GetAllDevices");
|
||||
QList<QDBusObjectPath> obj_paths = obj_reply.value();
|
||||
|
||||
foreach (QDBusObjectPath obj_path, obj_paths){
|
||||
QDBusInterface interface( "org.freedesktop.NetworkManager",
|
||||
obj_path.path(),
|
||||
"org.freedesktop.DBus.Introspectable",
|
||||
QDBusConnection::systemBus() );
|
||||
|
||||
QDBusReply<QString> reply = interface.call("Introspect");
|
||||
if(reply.value().indexOf("org.freedesktop.NetworkManager.Device.Wired") != -1){
|
||||
wiredPath = obj_path;
|
||||
} else if (reply.value().indexOf("org.freedesktop.NetworkManager.Device.Wireless") != -1){
|
||||
wirelessPath = obj_path;
|
||||
isWirelessCardOn = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KylinDBus::getPhysicalCarrierState(int n)
|
||||
{
|
||||
QDBusInterface interface( "org.freedesktop.NetworkManager",
|
||||
wiredPath.path(),
|
||||
"org.freedesktop.DBus.Properties",
|
||||
QDBusConnection::systemBus() );
|
||||
|
||||
QDBusReply<QVariant> reply = interface.call("Get", "org.freedesktop.NetworkManager.Device.Wired", "Carrier");
|
||||
|
||||
if (reply.value().toString() == "true"){
|
||||
qDebug()<<"physical carrier is found: "<<reply.value().toString();
|
||||
isWiredCableOn = true;
|
||||
} else if (reply.value().toString() == "false"){
|
||||
qDebug()<<"physical carrier is not found: "<<reply.value().toString();
|
||||
isWiredCableOn = false;
|
||||
} else {
|
||||
syslog(LOG_ERR, "Error occured when get the property 'Carrier' of Wired");
|
||||
qDebug()<<"Error occured when get the property 'Carrier' of Wired";
|
||||
}
|
||||
|
||||
if (n == 1){ this->mw->onPhysicalCarrierChanged(isWiredCableOn);}
|
||||
}
|
||||
|
||||
int KylinDBus::getAccessPointsNumber()
|
||||
{
|
||||
QDBusInterface interface( "org.freedesktop.NetworkManager",
|
||||
wirelessPath.path(),
|
||||
"org.freedesktop.NetworkManager.Device.Wireless",
|
||||
QDBusConnection::systemBus() );
|
||||
|
||||
QDBusReply<QList<QDBusObjectPath>> reply = interface.call("GetAllAccessPoints");
|
||||
QList<QDBusObjectPath> objPaths = reply.value();
|
||||
|
||||
// foreach (QDBusObjectPath objPath, objPaths){
|
||||
// qDebug()<<"*****path is: "<<objPath.path(); //列出每一个objectPath
|
||||
// }
|
||||
|
||||
return objPaths.size();
|
||||
}
|
||||
|
||||
int KylinDBus::getLanConnState()
|
||||
{
|
||||
QDBusInterface interface( "org.freedesktop.NetworkManager",
|
||||
"/org/freedesktop/NetworkManager/Devices/2",
|
||||
"org.freedesktop.DBus.Properties",
|
||||
QDBusConnection::systemBus() );
|
||||
|
||||
QDBusReply<QVariant> reply = interface.call("Get", "org.freedesktop.NetworkManager.Device", "ActiveConnection");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void KylinDBus::onLanPropertyChanged(QVariantMap qvm)
|
||||
{
|
||||
if (!isRunningFunction) {
|
||||
isRunningFunction = true;
|
||||
time->start(3000);
|
||||
|
||||
QString str = qvm.value("Carrier").toString();
|
||||
if (str == "false" || str == "true"){
|
||||
getPhysicalCarrierState(1);
|
||||
}
|
||||
} else { a = 0; }
|
||||
}
|
||||
void KylinDBus::slot_timeout()
|
||||
{
|
||||
isRunningFunction = false;
|
||||
time->stop();
|
||||
}
|
||||
|
||||
void KylinDBus::onWifiPropertyChanged(QVariantMap qvm)
|
||||
{
|
||||
//qDebug()<<"debug: *************"<<qvm.values();
|
||||
//uint ii = qvm.value("Bitrate").toUInt();
|
||||
//QString ss = QString::number(ii);
|
||||
//qDebug()<<"debug: ============="<<ss;
|
||||
}
|
||||
|
||||
void KylinDBus::onAccessPointAdded(QDBusObjectPath objPath)
|
||||
{
|
||||
//qDebug()<<"debug: &&&&&&&&&&&&&"<<objPath.path();
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
#ifndef KYLINDBUSINTERFACE_H
|
||||
#define KYLINDBUSINTERFACE_H
|
||||
|
||||
#include <sys/syslog.h>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
#include <QtDBus/QDBusConnection>
|
||||
#include <QtDBus/QDBusMessage>
|
||||
#include <QtDBus/QDBusInterface>
|
||||
#include <QtDBus/QDBusObjectPath>
|
||||
#include <QDBusObjectPath>
|
||||
#include <QDBusReply>
|
||||
#include <QVariant>
|
||||
#include <QVariantMap>
|
||||
#include <QTimer>
|
||||
|
||||
class MainWindow;
|
||||
|
||||
class KylinDBus : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit KylinDBus(MainWindow *mw = 0, QObject *parent = nullptr);
|
||||
|
||||
void getObjectPath();
|
||||
int getAccessPointsNumber();
|
||||
int getLanConnState();
|
||||
|
||||
QDBusObjectPath wiredPath;
|
||||
QDBusObjectPath wirelessPath;
|
||||
|
||||
bool isWiredCableOn = false;
|
||||
bool isWirelessCardOn = false;
|
||||
|
||||
|
||||
public slots:
|
||||
void onLanPropertyChanged(QVariantMap qvm);
|
||||
void onWifiPropertyChanged(QVariantMap qvm);
|
||||
void onAccessPointAdded(QDBusObjectPath objPath);
|
||||
void getPhysicalCarrierState(int n);
|
||||
void slot_timeout();
|
||||
|
||||
private:
|
||||
MainWindow *mw;
|
||||
|
||||
int a = 0;
|
||||
bool isRunningFunction = false;
|
||||
QTimer *time;
|
||||
};
|
||||
|
||||
#endif // KYLINDBUSINTERFACE_H
|
|
@ -310,7 +310,6 @@ activecon *kylin_network_get_activecon_info()
|
|||
activelist[count].dev=NULL;
|
||||
|
||||
return activelist;
|
||||
|
||||
}
|
||||
|
||||
//创建新的以太网连接
|
||||
|
|
71
kylin-nm.pro
71
kylin-nm.pro
|
@ -10,15 +10,16 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
|||
|
||||
TARGET = kylin-nm
|
||||
|
||||
#CONFIG += link_pkgconfig
|
||||
#PKGCONFIG += libnm glib-2.0 gio-2.0 dbus-glib-1
|
||||
|
||||
|
||||
target.path = /usr/bin
|
||||
target.source += $$TARGET
|
||||
shells.path = /usr/share/kylin-nm/shell/
|
||||
shells.files = connup.sh
|
||||
desktop.path = /etc/xdg/autostart/
|
||||
desktop.files = kylin-nm.desktop
|
||||
|
||||
INSTALLS += target \
|
||||
shells \
|
||||
desktop
|
||||
|
||||
TEMPLATE = app
|
||||
|
@ -45,16 +46,17 @@ SOURCES += \
|
|||
backthread.cpp \
|
||||
onelancform.cpp \
|
||||
loadingdiv.cpp \
|
||||
dlgconnhidwifi.cpp \
|
||||
dlgconnhidwifisecfast.cpp \
|
||||
dlgconnhidwifisectunneltls.cpp \
|
||||
dlgconnhidwifisecpeap.cpp \
|
||||
dlgconnhidwifisectls.cpp \
|
||||
dlgconnhidwifisecleap.cpp \
|
||||
dlgconnhidwifisecpwd.cpp \
|
||||
dlgconnhidwifiwep.cpp \
|
||||
dlgconnhidwifileap.cpp \
|
||||
dlgconnhidwifiwpa.cpp
|
||||
wireless-security/dlgconnhidwifi.cpp \
|
||||
wireless-security/dlgconnhidwifisecfast.cpp \
|
||||
wireless-security/dlgconnhidwifisectunneltls.cpp \
|
||||
wireless-security/dlgconnhidwifisecpeap.cpp \
|
||||
wireless-security/dlgconnhidwifisectls.cpp \
|
||||
wireless-security/dlgconnhidwifisecleap.cpp \
|
||||
wireless-security/dlgconnhidwifisecpwd.cpp \
|
||||
wireless-security/dlgconnhidwifiwep.cpp \
|
||||
wireless-security/dlgconnhidwifileap.cpp \
|
||||
wireless-security/dlgconnhidwifiwpa.cpp \
|
||||
kylin-dbus-interface.cpp
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h \
|
||||
|
@ -65,33 +67,34 @@ HEADERS += \
|
|||
backthread.h \
|
||||
onelancform.h \
|
||||
loadingdiv.h \
|
||||
dlgconnhidwifi.h \
|
||||
dlgconnhidwifisecfast.h \
|
||||
dlgconnhidwifisectunneltls.h \
|
||||
dlgconnhidwifisecpeap.h \
|
||||
dlgconnhidwifisectls.h \
|
||||
dlgconnhidwifisecleap.h \
|
||||
dlgconnhidwifisecpwd.h \
|
||||
dlgconnhidwifiwep.h \
|
||||
dlgconnhidwifileap.h \
|
||||
dlgconnhidwifiwpa.h \
|
||||
kylinheadfile.h
|
||||
wireless-security/dlgconnhidwifi.h \
|
||||
wireless-security/dlgconnhidwifisecfast.h \
|
||||
wireless-security/dlgconnhidwifisectunneltls.h \
|
||||
wireless-security/dlgconnhidwifisecpeap.h \
|
||||
wireless-security/dlgconnhidwifisectls.h \
|
||||
wireless-security/dlgconnhidwifisecleap.h \
|
||||
wireless-security/dlgconnhidwifisecpwd.h \
|
||||
wireless-security/dlgconnhidwifiwep.h \
|
||||
wireless-security/dlgconnhidwifileap.h \
|
||||
wireless-security/dlgconnhidwifiwpa.h \
|
||||
wireless-security/kylinheadfile.h \
|
||||
kylin-dbus-interface.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui \
|
||||
oneconnform.ui \
|
||||
confform.ui \
|
||||
onelancform.ui \
|
||||
dlgconnhidwifi.ui \
|
||||
dlgconnhidwifisecfast.ui \
|
||||
dlgconnhidwifisectunneltls.ui \
|
||||
dlgconnhidwifisecpeap.ui \
|
||||
dlgconnhidwifisectls.ui \
|
||||
dlgconnhidwifisecleap.ui \
|
||||
dlgconnhidwifisecpwd.ui \
|
||||
dlgconnhidwifiwep.ui \
|
||||
dlgconnhidwifileap.ui \
|
||||
dlgconnhidwifiwpa.ui
|
||||
wireless-security/dlgconnhidwifi.ui \
|
||||
wireless-security/dlgconnhidwifisecfast.ui \
|
||||
wireless-security/dlgconnhidwifisectunneltls.ui \
|
||||
wireless-security/dlgconnhidwifisecpeap.ui \
|
||||
wireless-security/dlgconnhidwifisectls.ui \
|
||||
wireless-security/dlgconnhidwifisecleap.ui \
|
||||
wireless-security/dlgconnhidwifisecpwd.ui \
|
||||
wireless-security/dlgconnhidwifiwep.ui \
|
||||
wireless-security/dlgconnhidwifileap.ui \
|
||||
wireless-security/dlgconnhidwifiwpa.ui
|
||||
|
||||
RESOURCES += \
|
||||
nmqrc.qrc
|
||||
|
|
17
main.cpp
17
main.cpp
|
@ -17,26 +17,35 @@
|
|||
*/
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "dlgconnhidwifi.h"
|
||||
#include "ksimplenm.h"
|
||||
#include "kylin-network-interface.h"
|
||||
#include "wireless-security/dlgconnhidwifi.h"
|
||||
|
||||
#include <QTranslator>
|
||||
#include <QLocale>
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
|
||||
#include "ksimplenm.h"
|
||||
#include "kylin-network-interface.h"
|
||||
#define LOG_IDENT "ukui_kylin_nm"
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
|
||||
openlog(LOG_IDENT, LOG_NDELAY | LOG_NOWAIT | LOG_PID, LOG_USER);
|
||||
|
||||
syslog(LOG_DEBUG, "Kylin Network Manager Is Already Launched");
|
||||
|
||||
syslog(LOG_DEBUG, "Using the icon theme named 'ukui-icon-theme-default'");
|
||||
QIcon::setThemeName("ukui-icon-theme-default");
|
||||
|
||||
// 国际化
|
||||
QString locale = QLocale::system().name();
|
||||
QTranslator trans_global;
|
||||
if(locale == "zh_CN"){
|
||||
trans_global.load(":/res/kylin-nm_zh_CN.qm");
|
||||
trans_global.load(":/translations/kylin-nm_zh_CN.qm");
|
||||
//trans_global.load(":/translations/kylin-nm_bo.qm");
|
||||
a.installTranslator(&trans_global);
|
||||
}
|
||||
|
||||
|
|
699
mainwindow.cpp
699
mainwindow.cpp
File diff suppressed because it is too large
Load Diff
42
mainwindow.h
42
mainwindow.h
|
@ -38,16 +38,18 @@
|
|||
#include <QtDBus/QDBusInterface>
|
||||
#include <QtDBus/QDBusObjectPath>
|
||||
#include <QDBusObjectPath>
|
||||
#include <QVariant>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <QVariant>
|
||||
#include <sys/syslog.h>
|
||||
#include <unistd.h>
|
||||
#include <xcb/xcb.h>
|
||||
|
||||
#include "ksimplenm.h"
|
||||
#include "loadingdiv.h"
|
||||
#include "kylin-dbus-interface.h"
|
||||
#include "kylin-network-interface.h"
|
||||
|
||||
class OneConnForm;
|
||||
|
@ -79,28 +81,38 @@ public:
|
|||
QIcon iconWifiFull, iconWifiHigh, iconWifiMedium, iconWifiLow;
|
||||
QIcon iconConnecting;
|
||||
QList<QIcon> loadIcons;
|
||||
QString mwBandWidth;
|
||||
KylinDBus *objKyDBus;
|
||||
|
||||
//状态设置,0为假,1为真
|
||||
int is_update_wifi_list = 0; //是否是update wifi列表,而不是load wifi列表
|
||||
int is_by_click_connect = 0; //是否是通过点击连接按钮进行的连接
|
||||
int is_btnNetList_clicked = 1; //是否处于有线网界面
|
||||
int is_btnWifiList_clicked = 0; //是否处于无线网界面
|
||||
int is_wired_line_ready = 1; //主机是否连接网线
|
||||
int is_wireless_adapter_ready = 1; //主机是否插入无线网卡
|
||||
int is_keep_wifi_turn_on_state = 1; //是否要执行wifi开关变为打开样式
|
||||
int is_stop_check_net_state = 0; //是否要在进行其他操作时停止检查网络状态
|
||||
|
||||
public slots:
|
||||
void checkWirelessDeviceState(/*QDBusObjectPath path*/);
|
||||
void onPhysicalCarrierChanged(bool flag);
|
||||
void onCarrierUpHandle();
|
||||
void onCarrierDownHandle();
|
||||
void onWirelessDeviceAdded(QDBusObjectPath objPath);
|
||||
void onWirelessDeviceRemoved(QDBusObjectPath objPath);
|
||||
void getLanBandWidth();
|
||||
|
||||
private:
|
||||
void checkSingle();
|
||||
void getActiveInfo();
|
||||
void getIface();
|
||||
void initNetwork();
|
||||
void createTrayIcon();
|
||||
void moveBottomRight();
|
||||
bool checkLanOn();
|
||||
bool checkWlOn();
|
||||
void getLanList();
|
||||
void getWifiList();
|
||||
void getInitLanSlist();
|
||||
|
||||
Ui::MainWindow *ui;
|
||||
|
||||
|
@ -131,17 +143,21 @@ private:
|
|||
// 主界面按钮底色
|
||||
QString btnOffQss, btnOnQss;
|
||||
|
||||
//上一次获取Lan列表
|
||||
QStringList oldLanSlist;
|
||||
//上一次获取wifi列表
|
||||
QStringList lastSlist;
|
||||
QStringList oldWifiSlist;
|
||||
|
||||
//循环检测网络连接状态
|
||||
QTimer *iconTimer;
|
||||
QTimer *check_isLanConnect;
|
||||
QTimer *check_isWifiConnect;
|
||||
QTimer *check_isNetOn;
|
||||
QTimer *wiredCableUpTimer;
|
||||
QTimer *wiredCableDownTimer;
|
||||
QTimer *checkWifiListChanged;
|
||||
QTimer *checkIfLanConnect;
|
||||
QTimer *checkIfWifiConnect;
|
||||
QTimer *checkIfNetworkOn;
|
||||
|
||||
int currentIconIndex;
|
||||
int updateFlag = 0;
|
||||
|
||||
private slots:
|
||||
void iconActivated(QSystemTrayIcon::ActivationReason reason);
|
||||
|
@ -163,11 +179,13 @@ private slots:
|
|||
|
||||
void oneLanFormSelected(QString lanName);
|
||||
void oneWifiFormSelected(QString wifiName);
|
||||
void oneHideFormSelected(QString wifiName);
|
||||
void activeLanDisconn();
|
||||
void activeWifiDisconn();
|
||||
void activeStartLoading();
|
||||
void activeGetWifiList();
|
||||
void on_btnAdvConf_pressed();
|
||||
void on_btnAdvConf_released();
|
||||
void on_checkWifiListChanged();
|
||||
void on_isLanConnect();
|
||||
void on_isWifiConnect();
|
||||
void on_isNetOn();
|
||||
|
@ -180,9 +198,11 @@ private slots:
|
|||
void disWifiDone();
|
||||
void keepDisWifiState();
|
||||
void connLanDone(int connFlag);
|
||||
void connDone(int connFlag);
|
||||
void connWifiDone(int connFlag);
|
||||
|
||||
void iconStep();
|
||||
signals:
|
||||
void deleteRedundantNet();
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
|
|
@ -61,13 +61,13 @@
|
|||
<file>res/s/rescan/10.png</file>
|
||||
<file>res/s/rescan/11.png</file>
|
||||
<file>res/s/rescan/12.png</file>
|
||||
<file>res/kylin-nm_zh_CN.qm</file>
|
||||
<file>res/wifi.png</file>
|
||||
<file>res/h/add-hide-wifi.png</file>
|
||||
<file>res/h/add-hide-wifi.svg</file>
|
||||
<file>res/h/hide-pwd.png</file>
|
||||
<file>res/h/right-pwd.png</file>
|
||||
<file>res/h/show-pwd.png</file>
|
||||
<file>res/h/no-pwd-wifi.png</file>
|
||||
<file>translations/kylin-nm_bo.qm</file>
|
||||
<file>translations/kylin-nm_zh_CN.qm</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "oneconnform.h"
|
||||
#include "ui_oneconnform.h"
|
||||
#include "mainwindow.h"
|
||||
#include "dlgconnhidwifi.h"
|
||||
#include "wireless-security/dlgconnhidwifi.h"
|
||||
|
||||
extern int currentActWifiSignalLv;
|
||||
|
||||
|
@ -90,7 +90,7 @@ OneConnForm::~OneConnForm()
|
|||
delete ui;
|
||||
}
|
||||
|
||||
void OneConnForm::mouseReleaseEvent(QMouseEvent *){
|
||||
void OneConnForm::mousePressEvent(QMouseEvent *){
|
||||
emit selectedOneWifiForm(wifiName);
|
||||
}
|
||||
|
||||
|
@ -128,6 +128,8 @@ void OneConnForm::setSelected(bool isSelected){
|
|||
|
||||
}else{
|
||||
resize(314, 60);
|
||||
ui->lePassword->setText("");
|
||||
|
||||
ui->wbg->hide();
|
||||
|
||||
if(isActive){
|
||||
|
@ -357,24 +359,24 @@ void OneConnForm::on_btnConf_clicked()
|
|||
//点击后断开wifi网络
|
||||
void OneConnForm::on_btnDisConn_clicked()
|
||||
{
|
||||
mw->is_stop_check_net_state = 1;
|
||||
kylin_network_set_con_down(ui->lbName->text().toUtf8().data());
|
||||
|
||||
disconnect(this, SIGNAL(selectedOneWifiForm(QString)), mw, SLOT(oneWifiFormSelected(QString)));
|
||||
|
||||
emit disconnActiveWifi();
|
||||
}
|
||||
|
||||
//无需密码的wifi连接
|
||||
void OneConnForm::on_btnConn_clicked()
|
||||
{
|
||||
mw->is_stop_check_net_state = 1;
|
||||
QThread *t = new QThread();
|
||||
BackThread *bt = new BackThread();
|
||||
bt->moveToThread(t);
|
||||
connect(t, SIGNAL(finished()), t, SLOT(deleteLater()));
|
||||
connect(t, SIGNAL(started()), this, SLOT(slotConnWifi()));
|
||||
connect(this, SIGNAL(sigConnWifi(QString)), bt, SLOT(execConnWifi(QString)));
|
||||
connect(bt, SIGNAL(connDone(int)), mw, SLOT(connDone(int)));
|
||||
connect(bt, SIGNAL(connDone(int)), this, SLOT(slotConnDone(int)));
|
||||
connect(bt, SIGNAL(connDone(int)), mw, SLOT(connWifiDone(int)));
|
||||
connect(bt, SIGNAL(connDone(int)), this, SLOT(slotConnWifiResult(int)));
|
||||
connect(bt, SIGNAL(btFinish()), t, SLOT(quit()));
|
||||
t->start();
|
||||
}
|
||||
|
@ -382,14 +384,15 @@ void OneConnForm::on_btnConn_clicked()
|
|||
//需要密码的wifi连接
|
||||
void OneConnForm::on_btnConnPWD_clicked()
|
||||
{
|
||||
mw->is_stop_check_net_state = 1;
|
||||
QThread *t = new QThread();
|
||||
BackThread *bt = new BackThread();
|
||||
bt->moveToThread(t);
|
||||
connect(t, SIGNAL(finished()), t, SLOT(deleteLater()));
|
||||
connect(t, SIGNAL(started()), this, SLOT(slotConnWifiPWD()));
|
||||
connect(this, SIGNAL(sigConnWifiPWD(QString, QString)), bt, SLOT(execConnWifiPWD(QString, QString)));
|
||||
connect(bt, SIGNAL(connDone(int)), mw, SLOT(connDone(int)));
|
||||
connect(bt, SIGNAL(connDone(int)), this, SLOT(slotConnDone(int)));
|
||||
connect(bt, SIGNAL(connDone(int)), mw, SLOT(connWifiDone(int)));
|
||||
connect(bt, SIGNAL(connDone(int)), this, SLOT(slotConnWifiResult(int)));
|
||||
connect(bt, SIGNAL(btFinish()), t, SLOT(quit()));
|
||||
t->start();
|
||||
}
|
||||
|
@ -404,10 +407,11 @@ void OneConnForm::on_btnHideConn_clicked()
|
|||
}
|
||||
|
||||
// Wifi连接结果,0成功 1失败 2没有配置文件
|
||||
void OneConnForm::slotConnDone(int connFlag){
|
||||
qDebug()<<"slot conn done: "<<connFlag;
|
||||
// 无此wifi配置,需要输入密码创建配置文件尝试连接
|
||||
void OneConnForm::slotConnWifiResult(int connFlag){
|
||||
qDebug()<<"Function slotConnWifiResult receives a number: "<<connFlag;
|
||||
|
||||
if(connFlag == 2){
|
||||
// 无此wifi配置,需要输入密码创建配置文件尝试连接
|
||||
ui->lbPassword->show();
|
||||
ui->lePassword->show();
|
||||
ui->checkBoxPwd->show();
|
||||
|
@ -421,9 +425,11 @@ void OneConnForm::slotConnDone(int connFlag){
|
|||
ui->btnConn->hide();
|
||||
ui->btnDisConn->hide();
|
||||
}
|
||||
// 使用配置文件连接失败,需要删除该配置文件
|
||||
QString txt(tr("Conn Wifi Failed"));//"连接 Wifi 失败"
|
||||
|
||||
if(connFlag == 1){
|
||||
// 使用配置文件连接失败,需要删除该配置文件
|
||||
QString txt(tr("Conn Wifi Failed"));//"连接 Wifi 失败"
|
||||
syslog(LOG_DEBUG, "Try to connect wifi named %s, but failed, will delete it's configuration file", ui->lbName->text().toUtf8().data());
|
||||
QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection delete '" + ui->lbName->text() + "';notify-send '" + txt + "...' -t 3800";
|
||||
system(cmd.toUtf8().data());
|
||||
}
|
||||
|
@ -434,6 +440,7 @@ void OneConnForm::slotConnDone(int connFlag){
|
|||
mw->stopLoading();
|
||||
}
|
||||
|
||||
//设置密码隐藏或可见
|
||||
void OneConnForm::on_checkBoxPwd_stateChanged(int arg1)
|
||||
{
|
||||
if (arg1 == 0) {
|
||||
|
|
|
@ -75,18 +75,17 @@ signals:
|
|||
void sigConnWifiPWD(QString, QString);
|
||||
|
||||
protected:
|
||||
void mouseReleaseEvent(QMouseEvent *event);
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
|
||||
private slots:
|
||||
void on_btnConf_clicked();
|
||||
void on_btnConn_clicked();
|
||||
|
||||
void on_btnConn_clicked();
|
||||
void on_btnDisConn_clicked();
|
||||
|
||||
void slotConnWifi();
|
||||
void slotConnWifiPWD();
|
||||
|
||||
void slotConnDone(int connFlag);
|
||||
void slotConnWifiResult(int connFlag);
|
||||
|
||||
void on_btnConnPWD_clicked();
|
||||
|
||||
|
|
|
@ -179,8 +179,8 @@
|
|||
<widget class="QCheckBox" name="checkBoxPwd">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>264</x>
|
||||
<y>30</y>
|
||||
<x>260</x>
|
||||
<y>31</y>
|
||||
<width>18</width>
|
||||
<height>9</height>
|
||||
</rect>
|
||||
|
@ -195,13 +195,13 @@
|
|||
<zorder>btnConn</zorder>
|
||||
<zorder>lbSignal</zorder>
|
||||
<zorder>lbSafe</zorder>
|
||||
<zorder>lePassword</zorder>
|
||||
<zorder>lbConned</zorder>
|
||||
<zorder>lbPoint</zorder>
|
||||
<zorder>btnDisConn</zorder>
|
||||
<zorder>lbPassword</zorder>
|
||||
<zorder>btnConnPWD</zorder>
|
||||
<zorder>btnHideConn</zorder>
|
||||
<zorder>lePassword</zorder>
|
||||
<zorder>checkBoxPwd</zorder>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
#include "ui_onelancform.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <time.h>
|
||||
|
||||
OneLancForm::OneLancForm(QWidget *parent, MainWindow *mainWindow, ConfForm *confForm, KSimpleNM *ksnm) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::OneLancForm)
|
||||
|
@ -57,6 +59,8 @@ OneLancForm::OneLancForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf
|
|||
|
||||
this->isSelected = false;
|
||||
this->isActive = false;
|
||||
|
||||
srand((unsigned)time(NULL));
|
||||
}
|
||||
|
||||
OneLancForm::~OneLancForm()
|
||||
|
@ -64,7 +68,7 @@ OneLancForm::~OneLancForm()
|
|||
delete ui;
|
||||
}
|
||||
|
||||
void OneLancForm::mouseReleaseEvent(QMouseEvent *){
|
||||
void OneLancForm::mousePressEvent(QMouseEvent *){
|
||||
emit selectedOneLanForm(lanName);
|
||||
}
|
||||
|
||||
|
@ -134,6 +138,7 @@ void OneLancForm::setBandWidth(QString bandWidth){
|
|||
if(bandWidth != ""){
|
||||
QString rateStr = bandWidth.mid(0, bandWidth.indexOf("Mb"));
|
||||
int rateNum = rateStr.toInt();
|
||||
|
||||
if(rateNum >= 1000){
|
||||
ui->lbPoint->setStyleSheet("QLabel{background:url(:/res/s/pgood.png);}");
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ signals:
|
|||
void sigConnLan(QString);
|
||||
|
||||
protected:
|
||||
void mouseReleaseEvent(QMouseEvent *event);
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
|
||||
private slots:
|
||||
void on_btnConf_clicked();
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 2.2 KiB |
BIN
res/wifi.png
BIN
res/wifi.png
Binary file not shown.
Before Width: | Height: | Size: 14 KiB |
|
@ -0,0 +1 @@
|
|||
<クdハ<>箆!ソ`。スン
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,6 @@
|
|||
#ifndef WIFIDETECTOR_H
|
||||
#define WIFIDETECTOR_H
|
||||
|
||||
#include <NetworkManager.h>
|
||||
|
||||
#endif // WIFIDETECTOR_H
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* 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 "dlgconnhidwifi.h"
|
||||
#include "kylinheadfile.h"
|
||||
#include "ui_dlgconnhidwifi.h"
|
||||
|
@ -114,6 +133,7 @@ void DlgConnHidWifi::mouseMoveEvent(QMouseEvent *event){
|
|||
}
|
||||
}
|
||||
|
||||
//切换到其他Wi-Fi安全类型
|
||||
void DlgConnHidWifi::changeDialog()
|
||||
{
|
||||
if(ui->cbxSecurity->currentIndex()==0){
|
||||
|
@ -152,6 +172,7 @@ void DlgConnHidWifi::changeDialog()
|
|||
}
|
||||
}
|
||||
|
||||
//同一 Wi-Fi安全类型的窗口变换
|
||||
void DlgConnHidWifi::changeWindow(){
|
||||
if (ui->cbxConn->currentIndex() == 0){
|
||||
isUsed = ui->cbxConn->currentIndex();
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* 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 "ui_dlgconnhidwifileap.h"
|
||||
#include "kylinheadfile.h"
|
||||
|
||||
|
@ -73,6 +92,7 @@ DlgConnHidWifiLeap::~DlgConnHidWifiLeap()
|
|||
delete ui;
|
||||
}
|
||||
|
||||
//切换到其他Wi-Fi安全类型
|
||||
void DlgConnHidWifiLeap::changeDialog()
|
||||
{
|
||||
if(ui->cbxSecurity->currentIndex()==0){
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* 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 "dlgconnhidwifisecfast.h"
|
||||
#include "ui_dlgconnhidwifisecfast.h"
|
||||
#include "kylinheadfile.h"
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* 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 "dlgconnhidwifisecleap.h"
|
||||
#include "ui_dlgconnhidwifisecleap.h"
|
||||
#include "kylinheadfile.h"
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* 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 "dlgconnhidwifisecpeap.h"
|
||||
#include "ui_dlgconnhidwifisecpeap.h"
|
||||
#include "kylinheadfile.h"
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* 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 "dlgconnhidwifisecpwd.h"
|
||||
#include "ui_dlgconnhidwifisecpwd.h"
|
||||
#include "kylinheadfile.h"
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* 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 "ui_dlgconnhidwifisectls.h"
|
||||
#include "kylinheadfile.h"
|
||||
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* 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 "dlgconnhidwifisectunneltls.h"
|
||||
#include "ui_dlgconnhidwifisectunneltls.h"
|
||||
#include "kylinheadfile.h"
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* 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 "ui_dlgconnhidwifiwep.h"
|
||||
#include "kylinheadfile.h"
|
||||
|
||||
|
@ -109,6 +128,7 @@ void DlgConnHidWifiWep::mouseMoveEvent(QMouseEvent *event){
|
|||
}
|
||||
}
|
||||
|
||||
//切换到其他Wi-Fi安全类型
|
||||
void DlgConnHidWifiWep::changeDialog()
|
||||
{
|
||||
if(ui->cbxSecurity->currentIndex()==0){
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* 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 "dlgconnhidwifiwpa.h"
|
||||
#include "ui_dlgconnhidwifiwpa.h"
|
||||
#include "kylinheadfile.h"
|
||||
|
@ -114,6 +133,7 @@ void DlgConnHidWifiWpa::mouseMoveEvent(QMouseEvent *event){
|
|||
}
|
||||
}
|
||||
|
||||
//切换到其他Wi-Fi安全类型
|
||||
void DlgConnHidWifiWpa::changeDialog()
|
||||
{
|
||||
if(ui->cbxSecurity->currentIndex()==0){
|
||||
|
@ -152,6 +172,7 @@ void DlgConnHidWifiWpa::changeDialog()
|
|||
}
|
||||
}
|
||||
|
||||
//同一 Wi-Fi安全类型的窗口变换
|
||||
void DlgConnHidWifiWpa::changeWindow(){
|
||||
if (ui->cbxConn->currentIndex() == 0){
|
||||
QApplication::setQuitOnLastWindowClosed(false);
|
Loading…
Reference in New Issue