Improve the stability of kylin-nm software.

This commit is contained in:
chenlelin 2020-01-09 16:32:16 +08:00
parent 1d02bbc335
commit 2f159df25c
67 changed files with 1809 additions and 1003 deletions

View File

@ -18,10 +18,22 @@
#include "backthread.h" #include "backthread.h"
#include <unistd.h>
#include <QFile> #include <QFile>
#include <QRegExp> #include <QRegExp>
BackThread::BackThread(QObject *parent) : QObject(parent){ 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(){ IFace* BackThread::execGetIface(){
@ -32,7 +44,8 @@ IFace* BackThread::execGetIface(){
QFile file("/tmp/kylin-nm-iface"); QFile file("/tmp/kylin-nm-iface");
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) 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(); QString txt = file.readAll();
QStringList txtList = txt.split("\n"); QStringList txtList = txt.split("\n");
@ -84,60 +97,87 @@ IFace* BackThread::execGetIface(){
} }
void BackThread::execEnNet(){ void BackThread::execEnNet(){
system("nmcli networking on;sleep 5"); system("nmcli networking on");
emit enNetDone(); while(1){
emit btFinish(); if (execGetIface()->lstate != 2){
sleep(3);
emit enNetDone();
emit btFinish();
break;
}
sleep(1);
}
} }
void BackThread::execDisNet(){ void BackThread::execDisNet(){
system("nmcli networking off;sleep 3"); if (execGetIface()->wstate != 2){
emit disNetDone(); system("nmcli radio wifi off");
emit btFinish(); 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(){ void BackThread::execEnWifi(){
if (execGetIface()->lstate == 2){ if (execGetIface()->lstate == 2){
system("nmcli networking on;sleep 3"); system("nmcli networking on");
emit launchLanDone(); 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(){ void BackThread::execDisWifi(){
system("nmcli radio wifi off;sleep 3"); system("nmcli radio wifi off");
emit disWifiDone(); while(1){
emit btFinish(); if (execGetIface()->wstate == 2){
emit disWifiDone();
emit btFinish();
break;
}
sleep(1);
}
} }
void BackThread::execConnLan(QString connName){ void BackThread::execConnLan(QString connName){
QString net_card = "ifconfig>/tmp/kylin-nm-ifconfig"; lanDelete(); //连接前先断开已经连接的有线网
system(net_card.toUtf8().data());
QFile file("/tmp/kylin-nm-ifconfig"); KylinDBus objKyDbus;
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) { if(objKyDbus.isWiredCableOn){
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){
QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up '" + connName + "'"; QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up '" + connName + "'";
system(cmd.toUtf8().data()); system(cmd.toUtf8().data());
emit connDone(0); emit connDone(0);
@ -148,21 +188,48 @@ void BackThread::execConnLan(QString connName){
emit btFinish(); emit btFinish();
} }
void BackThread::execConnWifi(QString connName){ void BackThread::execConnWifiPWD(QString connName, QString password){
QString cmd = "/usr/share/kylin-nm/shell/connup.sh '" + connName + "'"; 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()); system(cmd.toUtf8().data());
QFile file("/tmp/kylin-nm-btoutput_"); QFile file("/tmp/kylin-nm-btoutput");
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) 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(); QString line = file.readLine();
file.close(); file.close();
if(line.indexOf("successfully") != -1){ if(line.indexOf("successfully") != -1){
emit connDone(0); 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); emit connDone(2);
}else{ }else{
emit connDone(1); emit connDone(1);
@ -171,20 +238,15 @@ void BackThread::execConnWifi(QString connName){
emit btFinish(); emit btFinish();
} }
void BackThread::execConnWifiPWD(QString connName, QString password){ void BackThread::on_readerror()
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()); QString str = cmd->readAllStandardError();
cmd->close();
QFile file("/tmp/kylin-nm-btoutput"); qDebug()<<"on_readerror: "<< str;
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) if(str.indexOf("successfully") != -1){
{
qDebug()<<"Can't open the file!"<<endl;
}
QString line = file.readLine();
file.close();
if(line.indexOf("successfully") != -1){
emit connDone(0); emit connDone(0);
}else if(str.indexOf("unknown") != -1){
emit connDone(2);
}else{ }else{
emit connDone(1); emit connDone(1);
} }
@ -199,7 +261,8 @@ QString BackThread::getConnProp(QString connName){
QFile file("/tmp/kylin-nm-connprop"); QFile file("/tmp/kylin-nm-connprop");
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) 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(); QString txt = file.readAll();
@ -251,7 +314,8 @@ bool BackThread::execChkWifiExist(QString connName){
QFile file("/tmp/kylin-nm-chkwifiexist"); QFile file("/tmp/kylin-nm-chkwifiexist");
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) 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(); QString line = file.readLine();
file.close(); file.close();
@ -270,7 +334,8 @@ QString BackThread::execChkLanWidth(QString ethName){
QFile file("/tmp/kylin-nm-bandwidth"); QFile file("/tmp/kylin-nm-bandwidth");
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) 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(); QString line = file.readLine();
file.close(); file.close();
@ -282,5 +347,65 @@ QString BackThread::execChkLanWidth(QString ethName){
QString rtn = params.at(1); QString rtn = params.at(1);
return rtn.trimmed(); 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
} }

View File

@ -19,8 +19,17 @@
#ifndef BACKTHREAD_H #ifndef BACKTHREAD_H
#define BACKTHREAD_H #define BACKTHREAD_H
#include "kylin-dbus-interface.h"
#include "kylin-network-interface.h"
#include <sys/syslog.h>
#include <QObject> #include <QObject>
#include <QDebug> #include <QDebug>
#include <QTimer>
#include <QProcess>
#include <QDBusInterface>
#include <QDBusMessage>
#include <QDBusArgument>
class IFace{ class IFace{
public: public:
@ -35,11 +44,13 @@ class BackThread : public QObject
Q_OBJECT Q_OBJECT
public: public:
explicit BackThread(QObject *parent = nullptr); explicit BackThread(QObject *parent = nullptr);
~BackThread();
IFace* execGetIface(); IFace* execGetIface();
QString getConnProp(QString connName); QString getConnProp(QString connName);
bool execChkWifiExist(QString connName); bool execChkWifiExist(QString connName);
QString execChkLanWidth(QString ethName); QString execChkLanWidth(QString ethName);
QProcess *cmd;
signals: signals:
void enNetDone(); void enNetDone();
@ -51,6 +62,8 @@ signals:
void connDone(int connFlag); void connDone(int connFlag);
void btFinish(); void btFinish();
void disFinish();
void ttFinish();
public slots: public slots:
void execEnNet(); void execEnNet();
@ -60,6 +73,11 @@ public slots:
void execConnLan(QString connName); void execConnLan(QString connName);
void execConnWifi(QString connName); void execConnWifi(QString connName);
void execConnWifiPWD(QString connName, QString password); void execConnWifiPWD(QString connName, QString password);
void redundantNetDeleted();
void lanDelete();
void wifiDelete();
void on_readoutput();
void on_readerror();
}; };
#endif // BACKTHREAD_H #endif // BACKTHREAD_H

View File

@ -1,2 +0,0 @@
#!/bin/bash
export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up "$1" &> /tmp/kylin-nm-btoutput_

View File

@ -0,0 +1 @@
./man/kylin-nm.1

View File

@ -0,0 +1 @@
18c1694c9d87adc92ebb3d79a081909857f60aff

View File

@ -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

View File

@ -0,0 +1 @@
469c8cb42ada0c9dd27938a1626a381a usr/lib/debug/.build-id/18/c1694c9d87adc92ebb3d79a081909857f60aff.debug

View File

@ -0,0 +1 @@
kylin-nm

2
debian/control vendored
View File

@ -5,6 +5,7 @@ Maintainer: Kylin Team <team+kylin@tracker.debian.org>
Uploaders: handsome_feng <jianfengli@ubuntukylin.com> Uploaders: handsome_feng <jianfengli@ubuntukylin.com>
Build-Depends: debhelper-compat (= 12), Build-Depends: debhelper-compat (= 12),
qtbase5-dev, qtbase5-dev,
libnotify-bin,
libqt5x11extras5-dev (>= 5.11.1-2), libqt5x11extras5-dev (>= 5.11.1-2),
Standards-Version: 4.4.1 Standards-Version: 4.4.1
Rules-Requires-Root: no Rules-Requires-Root: no
@ -16,6 +17,7 @@ Package: kylin-nm
Architecture: any Architecture: any
Depends: libqt5x11extras5 (>= 5.11.1-2), Depends: libqt5x11extras5 (>= 5.11.1-2),
network-manager (>=1.12.4), network-manager (>=1.12.4),
libnotify-bin,
${shlibs:Depends}, ${shlibs:Depends},
${misc:Depends} ${misc:Depends}
Description: Gui Applet tool for display and edit network simply Description: Gui Applet tool for display and edit network simply

1
debian/debhelper-build-stamp vendored Normal file
View File

@ -0,0 +1 @@
kylin-nm

3
debian/files vendored Normal file
View File

@ -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

3
debian/kylin-nm.substvars vendored Normal file
View File

@ -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=

View File

@ -18,24 +18,33 @@
#include "ksimplenm.h" #include "ksimplenm.h"
#include <stdio.h> #include <stdio.h>
#include <unistd.h>
#include <QThread>
#define MAX_LEN 2048 #define MAX_LEN 2048
#define MAX_PATH 1024 #define MAX_PATH 1024
KSimpleNM::KSimpleNM(QObject *parent) : QObject(parent) KSimpleNM::KSimpleNM(QObject *parent) : QObject(parent)
{ {
runShellProcess =new QProcess(this); runShellProcess = new QProcess(this);
connect(runShellProcess, &QProcess::readyRead, this, &KSimpleNM::readProcess); connect(runShellProcess, &QProcess::readyRead, this, &KSimpleNM::readProcess);
connect(runShellProcess, SIGNAL(finished(int)), this, SLOT(finishedProcess(int))); connect(runShellProcess, SIGNAL(finished(int)), this, SLOT(finishedProcess(int)));
} }
void KSimpleNM::execGetLanList(){ 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 = ""; shellOutput = "";
type = 0; type = 0;
runShellProcess->start("nmcli -f type,device,name connection show"); runShellProcess->start("nmcli -f type,device,name connection show");
} }
void KSimpleNM::execGetWifiList(){ void KSimpleNM::execGetWifiList(){
isExecutingGetWifiList = true;
shellOutput = ""; shellOutput = "";
type = 1; type = 1;
runShellProcess->start("nmcli -f signal,rate,security,ssid device wifi"); runShellProcess->start("nmcli -f signal,rate,security,ssid device wifi");
@ -50,7 +59,9 @@ void KSimpleNM::finishedProcess(int msg){
QStringList slist = shellOutput.split("\n"); QStringList slist = shellOutput.split("\n");
if(type == 0){ if(type == 0){
emit getLanListFinished(slist); emit getLanListFinished(slist);
isExecutingGetLanList = false;
}else{ }else{
emit getWifiListFinished(slist); emit getWifiListFinished(slist);
isExecutingGetWifiList = false;
} }
} }

View File

@ -19,6 +19,7 @@
#ifndef KSIMPLENM_H #ifndef KSIMPLENM_H
#define KSIMPLENM_H #define KSIMPLENM_H
#include <sys/syslog.h>
#include <QObject> #include <QObject>
#include <QProcess> #include <QProcess>
#include <QDebug> #include <QDebug>
@ -32,6 +33,9 @@ public:
QProcess *runShellProcess; QProcess *runShellProcess;
QString shellOutput; QString shellOutput;
int type; int type;
bool isExecutingGetLanList = false;
bool isExecutingGetWifiList = false;
bool isUseOldLanSlist = false;
void execGetLanList(); void execGetLanList();
void execGetWifiList(); void execGetWifiList();

169
kylin-dbus-interface.cpp Normal file
View File

@ -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/&gt;.
*
*/
#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();
}

51
kylin-dbus-interface.h Normal file
View File

@ -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

View File

@ -310,7 +310,6 @@ activecon *kylin_network_get_activecon_info()
activelist[count].dev=NULL; activelist[count].dev=NULL;
return activelist; return activelist;
} }
//创建新的以太网连接 //创建新的以太网连接

View File

@ -10,15 +10,16 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = kylin-nm TARGET = kylin-nm
#CONFIG += link_pkgconfig
#PKGCONFIG += libnm glib-2.0 gio-2.0 dbus-glib-1
target.path = /usr/bin target.path = /usr/bin
target.source += $$TARGET target.source += $$TARGET
shells.path = /usr/share/kylin-nm/shell/
shells.files = connup.sh
desktop.path = /etc/xdg/autostart/ desktop.path = /etc/xdg/autostart/
desktop.files = kylin-nm.desktop desktop.files = kylin-nm.desktop
INSTALLS += target \ INSTALLS += target \
shells \
desktop desktop
TEMPLATE = app TEMPLATE = app
@ -45,16 +46,17 @@ SOURCES += \
backthread.cpp \ backthread.cpp \
onelancform.cpp \ onelancform.cpp \
loadingdiv.cpp \ loadingdiv.cpp \
dlgconnhidwifi.cpp \ wireless-security/dlgconnhidwifi.cpp \
dlgconnhidwifisecfast.cpp \ wireless-security/dlgconnhidwifisecfast.cpp \
dlgconnhidwifisectunneltls.cpp \ wireless-security/dlgconnhidwifisectunneltls.cpp \
dlgconnhidwifisecpeap.cpp \ wireless-security/dlgconnhidwifisecpeap.cpp \
dlgconnhidwifisectls.cpp \ wireless-security/dlgconnhidwifisectls.cpp \
dlgconnhidwifisecleap.cpp \ wireless-security/dlgconnhidwifisecleap.cpp \
dlgconnhidwifisecpwd.cpp \ wireless-security/dlgconnhidwifisecpwd.cpp \
dlgconnhidwifiwep.cpp \ wireless-security/dlgconnhidwifiwep.cpp \
dlgconnhidwifileap.cpp \ wireless-security/dlgconnhidwifileap.cpp \
dlgconnhidwifiwpa.cpp wireless-security/dlgconnhidwifiwpa.cpp \
kylin-dbus-interface.cpp
HEADERS += \ HEADERS += \
mainwindow.h \ mainwindow.h \
@ -65,33 +67,34 @@ HEADERS += \
backthread.h \ backthread.h \
onelancform.h \ onelancform.h \
loadingdiv.h \ loadingdiv.h \
dlgconnhidwifi.h \ wireless-security/dlgconnhidwifi.h \
dlgconnhidwifisecfast.h \ wireless-security/dlgconnhidwifisecfast.h \
dlgconnhidwifisectunneltls.h \ wireless-security/dlgconnhidwifisectunneltls.h \
dlgconnhidwifisecpeap.h \ wireless-security/dlgconnhidwifisecpeap.h \
dlgconnhidwifisectls.h \ wireless-security/dlgconnhidwifisectls.h \
dlgconnhidwifisecleap.h \ wireless-security/dlgconnhidwifisecleap.h \
dlgconnhidwifisecpwd.h \ wireless-security/dlgconnhidwifisecpwd.h \
dlgconnhidwifiwep.h \ wireless-security/dlgconnhidwifiwep.h \
dlgconnhidwifileap.h \ wireless-security/dlgconnhidwifileap.h \
dlgconnhidwifiwpa.h \ wireless-security/dlgconnhidwifiwpa.h \
kylinheadfile.h wireless-security/kylinheadfile.h \
kylin-dbus-interface.h
FORMS += \ FORMS += \
mainwindow.ui \ mainwindow.ui \
oneconnform.ui \ oneconnform.ui \
confform.ui \ confform.ui \
onelancform.ui \ onelancform.ui \
dlgconnhidwifi.ui \ wireless-security/dlgconnhidwifi.ui \
dlgconnhidwifisecfast.ui \ wireless-security/dlgconnhidwifisecfast.ui \
dlgconnhidwifisectunneltls.ui \ wireless-security/dlgconnhidwifisectunneltls.ui \
dlgconnhidwifisecpeap.ui \ wireless-security/dlgconnhidwifisecpeap.ui \
dlgconnhidwifisectls.ui \ wireless-security/dlgconnhidwifisectls.ui \
dlgconnhidwifisecleap.ui \ wireless-security/dlgconnhidwifisecleap.ui \
dlgconnhidwifisecpwd.ui \ wireless-security/dlgconnhidwifisecpwd.ui \
dlgconnhidwifiwep.ui \ wireless-security/dlgconnhidwifiwep.ui \
dlgconnhidwifileap.ui \ wireless-security/dlgconnhidwifileap.ui \
dlgconnhidwifiwpa.ui wireless-security/dlgconnhidwifiwpa.ui
RESOURCES += \ RESOURCES += \
nmqrc.qrc nmqrc.qrc

View File

@ -17,26 +17,35 @@
*/ */
#include "mainwindow.h" #include "mainwindow.h"
#include "dlgconnhidwifi.h" #include "ksimplenm.h"
#include "kylin-network-interface.h"
#include "wireless-security/dlgconnhidwifi.h"
#include <QTranslator> #include <QTranslator>
#include <QLocale> #include <QLocale>
#include <QApplication> #include <QApplication>
#include <QDebug> #include <QDebug>
#include "ksimplenm.h" #define LOG_IDENT "ukui_kylin_nm"
#include "kylin-network-interface.h"
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QApplication a(argc, 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"); QIcon::setThemeName("ukui-icon-theme-default");
// 国际化 // 国际化
QString locale = QLocale::system().name(); QString locale = QLocale::system().name();
QTranslator trans_global; QTranslator trans_global;
if(locale == "zh_CN"){ 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); a.installTranslator(&trans_global);
} }

File diff suppressed because it is too large Load Diff

View File

@ -38,16 +38,18 @@
#include <QtDBus/QDBusInterface> #include <QtDBus/QDBusInterface>
#include <QtDBus/QDBusObjectPath> #include <QtDBus/QDBusObjectPath>
#include <QDBusObjectPath> #include <QDBusObjectPath>
#include <QVariant>
#include <fcntl.h> #include <fcntl.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/syslog.h>
#include <QVariant> #include <unistd.h>
#include <xcb/xcb.h> #include <xcb/xcb.h>
#include "ksimplenm.h" #include "ksimplenm.h"
#include "loadingdiv.h" #include "loadingdiv.h"
#include "kylin-dbus-interface.h"
#include "kylin-network-interface.h" #include "kylin-network-interface.h"
class OneConnForm; class OneConnForm;
@ -79,28 +81,38 @@ public:
QIcon iconWifiFull, iconWifiHigh, iconWifiMedium, iconWifiLow; QIcon iconWifiFull, iconWifiHigh, iconWifiMedium, iconWifiLow;
QIcon iconConnecting; QIcon iconConnecting;
QList<QIcon> loadIcons; QList<QIcon> loadIcons;
QString mwBandWidth;
KylinDBus *objKyDBus;
//状态设置,0为假1为真 //状态设置,0为假1为真
int is_update_wifi_list = 0; //是否是update wifi列表而不是load wifi列表
int is_by_click_connect = 0; //是否是通过点击连接按钮进行的连接 int is_by_click_connect = 0; //是否是通过点击连接按钮进行的连接
int is_btnNetList_clicked = 1; //是否处于有线网界面 int is_btnNetList_clicked = 1; //是否处于有线网界面
int is_btnWifiList_clicked = 0; //是否处于无线网界面 int is_btnWifiList_clicked = 0; //是否处于无线网界面
int is_wired_line_ready = 1; //主机是否连接网线 int is_wired_line_ready = 1; //主机是否连接网线
int is_wireless_adapter_ready = 1; //主机是否插入无线网卡 int is_wireless_adapter_ready = 1; //主机是否插入无线网卡
int is_keep_wifi_turn_on_state = 1; //是否要执行wifi开关变为打开样式 int is_keep_wifi_turn_on_state = 1; //是否要执行wifi开关变为打开样式
int is_stop_check_net_state = 0; //是否要在进行其他操作时停止检查网络状态
public slots: 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: private:
void checkSingle(); void checkSingle();
void getActiveInfo(); void getActiveInfo();
void getIface(); void initNetwork();
void createTrayIcon(); void createTrayIcon();
void moveBottomRight(); void moveBottomRight();
bool checkLanOn(); bool checkLanOn();
bool checkWlOn(); bool checkWlOn();
void getLanList(); void getLanList();
void getWifiList(); void getWifiList();
void getInitLanSlist();
Ui::MainWindow *ui; Ui::MainWindow *ui;
@ -131,17 +143,21 @@ private:
// 主界面按钮底色 // 主界面按钮底色
QString btnOffQss, btnOnQss; QString btnOffQss, btnOnQss;
//上一次获取Lan列表
QStringList oldLanSlist;
//上一次获取wifi列表 //上一次获取wifi列表
QStringList lastSlist; QStringList oldWifiSlist;
//循环检测网络连接状态 //循环检测网络连接状态
QTimer *iconTimer; QTimer *iconTimer;
QTimer *check_isLanConnect; QTimer *wiredCableUpTimer;
QTimer *check_isWifiConnect; QTimer *wiredCableDownTimer;
QTimer *check_isNetOn; QTimer *checkWifiListChanged;
QTimer *checkIfLanConnect;
QTimer *checkIfWifiConnect;
QTimer *checkIfNetworkOn;
int currentIconIndex; int currentIconIndex;
int updateFlag = 0;
private slots: private slots:
void iconActivated(QSystemTrayIcon::ActivationReason reason); void iconActivated(QSystemTrayIcon::ActivationReason reason);
@ -163,11 +179,13 @@ private slots:
void oneLanFormSelected(QString lanName); void oneLanFormSelected(QString lanName);
void oneWifiFormSelected(QString wifiName); void oneWifiFormSelected(QString wifiName);
void oneHideFormSelected(QString wifiName);
void activeLanDisconn(); void activeLanDisconn();
void activeWifiDisconn(); void activeWifiDisconn();
void activeStartLoading();
void activeGetWifiList();
void on_btnAdvConf_pressed(); void on_btnAdvConf_pressed();
void on_btnAdvConf_released(); void on_btnAdvConf_released();
void on_checkWifiListChanged();
void on_isLanConnect(); void on_isLanConnect();
void on_isWifiConnect(); void on_isWifiConnect();
void on_isNetOn(); void on_isNetOn();
@ -180,9 +198,11 @@ private slots:
void disWifiDone(); void disWifiDone();
void keepDisWifiState(); void keepDisWifiState();
void connLanDone(int connFlag); void connLanDone(int connFlag);
void connDone(int connFlag); void connWifiDone(int connFlag);
void iconStep(); void iconStep();
signals:
void deleteRedundantNet();
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H

View File

@ -61,13 +61,13 @@
<file>res/s/rescan/10.png</file> <file>res/s/rescan/10.png</file>
<file>res/s/rescan/11.png</file> <file>res/s/rescan/11.png</file>
<file>res/s/rescan/12.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.png</file>
<file>res/h/add-hide-wifi.svg</file> <file>res/h/add-hide-wifi.svg</file>
<file>res/h/hide-pwd.png</file> <file>res/h/hide-pwd.png</file>
<file>res/h/right-pwd.png</file> <file>res/h/right-pwd.png</file>
<file>res/h/show-pwd.png</file> <file>res/h/show-pwd.png</file>
<file>res/h/no-pwd-wifi.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> </qresource>
</RCC> </RCC>

View File

@ -19,7 +19,7 @@
#include "oneconnform.h" #include "oneconnform.h"
#include "ui_oneconnform.h" #include "ui_oneconnform.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "dlgconnhidwifi.h" #include "wireless-security/dlgconnhidwifi.h"
extern int currentActWifiSignalLv; extern int currentActWifiSignalLv;
@ -90,7 +90,7 @@ OneConnForm::~OneConnForm()
delete ui; delete ui;
} }
void OneConnForm::mouseReleaseEvent(QMouseEvent *){ void OneConnForm::mousePressEvent(QMouseEvent *){
emit selectedOneWifiForm(wifiName); emit selectedOneWifiForm(wifiName);
} }
@ -128,6 +128,8 @@ void OneConnForm::setSelected(bool isSelected){
}else{ }else{
resize(314, 60); resize(314, 60);
ui->lePassword->setText("");
ui->wbg->hide(); ui->wbg->hide();
if(isActive){ if(isActive){
@ -357,24 +359,24 @@ void OneConnForm::on_btnConf_clicked()
//点击后断开wifi网络 //点击后断开wifi网络
void OneConnForm::on_btnDisConn_clicked() void OneConnForm::on_btnDisConn_clicked()
{ {
mw->is_stop_check_net_state = 1;
kylin_network_set_con_down(ui->lbName->text().toUtf8().data()); kylin_network_set_con_down(ui->lbName->text().toUtf8().data());
disconnect(this, SIGNAL(selectedOneWifiForm(QString)), mw, SLOT(oneWifiFormSelected(QString))); disconnect(this, SIGNAL(selectedOneWifiForm(QString)), mw, SLOT(oneWifiFormSelected(QString)));
emit disconnActiveWifi(); emit disconnActiveWifi();
} }
//无需密码的wifi连接 //无需密码的wifi连接
void OneConnForm::on_btnConn_clicked() void OneConnForm::on_btnConn_clicked()
{ {
mw->is_stop_check_net_state = 1;
QThread *t = new QThread(); QThread *t = new QThread();
BackThread *bt = new BackThread(); BackThread *bt = new BackThread();
bt->moveToThread(t); bt->moveToThread(t);
connect(t, SIGNAL(finished()), t, SLOT(deleteLater())); connect(t, SIGNAL(finished()), t, SLOT(deleteLater()));
connect(t, SIGNAL(started()), this, SLOT(slotConnWifi())); connect(t, SIGNAL(started()), this, SLOT(slotConnWifi()));
connect(this, SIGNAL(sigConnWifi(QString)), bt, SLOT(execConnWifi(QString))); connect(this, SIGNAL(sigConnWifi(QString)), bt, SLOT(execConnWifi(QString)));
connect(bt, SIGNAL(connDone(int)), mw, SLOT(connDone(int))); connect(bt, SIGNAL(connDone(int)), mw, SLOT(connWifiDone(int)));
connect(bt, SIGNAL(connDone(int)), this, SLOT(slotConnDone(int))); connect(bt, SIGNAL(connDone(int)), this, SLOT(slotConnWifiResult(int)));
connect(bt, SIGNAL(btFinish()), t, SLOT(quit())); connect(bt, SIGNAL(btFinish()), t, SLOT(quit()));
t->start(); t->start();
} }
@ -382,14 +384,15 @@ void OneConnForm::on_btnConn_clicked()
//需要密码的wifi连接 //需要密码的wifi连接
void OneConnForm::on_btnConnPWD_clicked() void OneConnForm::on_btnConnPWD_clicked()
{ {
mw->is_stop_check_net_state = 1;
QThread *t = new QThread(); QThread *t = new QThread();
BackThread *bt = new BackThread(); BackThread *bt = new BackThread();
bt->moveToThread(t); bt->moveToThread(t);
connect(t, SIGNAL(finished()), t, SLOT(deleteLater())); connect(t, SIGNAL(finished()), t, SLOT(deleteLater()));
connect(t, SIGNAL(started()), this, SLOT(slotConnWifiPWD())); connect(t, SIGNAL(started()), this, SLOT(slotConnWifiPWD()));
connect(this, SIGNAL(sigConnWifiPWD(QString, QString)), bt, SLOT(execConnWifiPWD(QString, QString))); 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)), mw, SLOT(connWifiDone(int)));
connect(bt, SIGNAL(connDone(int)), this, SLOT(slotConnDone(int))); connect(bt, SIGNAL(connDone(int)), this, SLOT(slotConnWifiResult(int)));
connect(bt, SIGNAL(btFinish()), t, SLOT(quit())); connect(bt, SIGNAL(btFinish()), t, SLOT(quit()));
t->start(); t->start();
} }
@ -404,10 +407,11 @@ void OneConnForm::on_btnHideConn_clicked()
} }
// Wifi连接结果0成功 1失败 2没有配置文件 // Wifi连接结果0成功 1失败 2没有配置文件
void OneConnForm::slotConnDone(int connFlag){ void OneConnForm::slotConnWifiResult(int connFlag){
qDebug()<<"slot conn done: "<<connFlag; qDebug()<<"Function slotConnWifiResult receives a number: "<<connFlag;
// 无此wifi配置需要输入密码创建配置文件尝试连接
if(connFlag == 2){ if(connFlag == 2){
// 无此wifi配置需要输入密码创建配置文件尝试连接
ui->lbPassword->show(); ui->lbPassword->show();
ui->lePassword->show(); ui->lePassword->show();
ui->checkBoxPwd->show(); ui->checkBoxPwd->show();
@ -421,9 +425,11 @@ void OneConnForm::slotConnDone(int connFlag){
ui->btnConn->hide(); ui->btnConn->hide();
ui->btnDisConn->hide(); ui->btnDisConn->hide();
} }
// 使用配置文件连接失败,需要删除该配置文件
QString txt(tr("Conn Wifi Failed"));//"连接 Wifi 失败"
if(connFlag == 1){ 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"; 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()); system(cmd.toUtf8().data());
} }
@ -434,6 +440,7 @@ void OneConnForm::slotConnDone(int connFlag){
mw->stopLoading(); mw->stopLoading();
} }
//设置密码隐藏或可见
void OneConnForm::on_checkBoxPwd_stateChanged(int arg1) void OneConnForm::on_checkBoxPwd_stateChanged(int arg1)
{ {
if (arg1 == 0) { if (arg1 == 0) {

View File

@ -75,18 +75,17 @@ signals:
void sigConnWifiPWD(QString, QString); void sigConnWifiPWD(QString, QString);
protected: protected:
void mouseReleaseEvent(QMouseEvent *event); void mousePressEvent(QMouseEvent *event);
private slots: private slots:
void on_btnConf_clicked(); void on_btnConf_clicked();
void on_btnConn_clicked();
void on_btnConn_clicked();
void on_btnDisConn_clicked(); void on_btnDisConn_clicked();
void slotConnWifi(); void slotConnWifi();
void slotConnWifiPWD(); void slotConnWifiPWD();
void slotConnWifiResult(int connFlag);
void slotConnDone(int connFlag);
void on_btnConnPWD_clicked(); void on_btnConnPWD_clicked();

View File

@ -179,8 +179,8 @@
<widget class="QCheckBox" name="checkBoxPwd"> <widget class="QCheckBox" name="checkBoxPwd">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>264</x> <x>260</x>
<y>30</y> <y>31</y>
<width>18</width> <width>18</width>
<height>9</height> <height>9</height>
</rect> </rect>
@ -195,13 +195,13 @@
<zorder>btnConn</zorder> <zorder>btnConn</zorder>
<zorder>lbSignal</zorder> <zorder>lbSignal</zorder>
<zorder>lbSafe</zorder> <zorder>lbSafe</zorder>
<zorder>lePassword</zorder>
<zorder>lbConned</zorder> <zorder>lbConned</zorder>
<zorder>lbPoint</zorder> <zorder>lbPoint</zorder>
<zorder>btnDisConn</zorder> <zorder>btnDisConn</zorder>
<zorder>lbPassword</zorder> <zorder>lbPassword</zorder>
<zorder>btnConnPWD</zorder> <zorder>btnConnPWD</zorder>
<zorder>btnHideConn</zorder> <zorder>btnHideConn</zorder>
<zorder>lePassword</zorder>
<zorder>checkBoxPwd</zorder> <zorder>checkBoxPwd</zorder>
</widget> </widget>
<resources/> <resources/>

View File

@ -20,6 +20,8 @@
#include "ui_onelancform.h" #include "ui_onelancform.h"
#include "mainwindow.h" #include "mainwindow.h"
#include <time.h>
OneLancForm::OneLancForm(QWidget *parent, MainWindow *mainWindow, ConfForm *confForm, KSimpleNM *ksnm) : OneLancForm::OneLancForm(QWidget *parent, MainWindow *mainWindow, ConfForm *confForm, KSimpleNM *ksnm) :
QWidget(parent), QWidget(parent),
ui(new Ui::OneLancForm) ui(new Ui::OneLancForm)
@ -57,6 +59,8 @@ OneLancForm::OneLancForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf
this->isSelected = false; this->isSelected = false;
this->isActive = false; this->isActive = false;
srand((unsigned)time(NULL));
} }
OneLancForm::~OneLancForm() OneLancForm::~OneLancForm()
@ -64,7 +68,7 @@ OneLancForm::~OneLancForm()
delete ui; delete ui;
} }
void OneLancForm::mouseReleaseEvent(QMouseEvent *){ void OneLancForm::mousePressEvent(QMouseEvent *){
emit selectedOneLanForm(lanName); emit selectedOneLanForm(lanName);
} }
@ -134,6 +138,7 @@ void OneLancForm::setBandWidth(QString bandWidth){
if(bandWidth != ""){ if(bandWidth != ""){
QString rateStr = bandWidth.mid(0, bandWidth.indexOf("Mb")); QString rateStr = bandWidth.mid(0, bandWidth.indexOf("Mb"));
int rateNum = rateStr.toInt(); int rateNum = rateStr.toInt();
if(rateNum >= 1000){ if(rateNum >= 1000){
ui->lbPoint->setStyleSheet("QLabel{background:url(:/res/s/pgood.png);}"); ui->lbPoint->setStyleSheet("QLabel{background:url(:/res/s/pgood.png);}");
} }

View File

@ -64,7 +64,7 @@ signals:
void sigConnLan(QString); void sigConnLan(QString);
protected: protected:
void mouseReleaseEvent(QMouseEvent *event); void mousePressEvent(QMouseEvent *event);
private slots: private slots:
void on_btnConf_clicked(); void on_btnConf_clicked();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

View File

@ -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

6
wifidetector.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef WIFIDETECTOR_H
#define WIFIDETECTOR_H
#include <NetworkManager.h>
#endif // WIFIDETECTOR_H

View File

@ -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/&gt;.
*
*/
#include "dlgconnhidwifi.h" #include "dlgconnhidwifi.h"
#include "kylinheadfile.h" #include "kylinheadfile.h"
#include "ui_dlgconnhidwifi.h" #include "ui_dlgconnhidwifi.h"
@ -114,6 +133,7 @@ void DlgConnHidWifi::mouseMoveEvent(QMouseEvent *event){
} }
} }
//切换到其他Wi-Fi安全类型
void DlgConnHidWifi::changeDialog() void DlgConnHidWifi::changeDialog()
{ {
if(ui->cbxSecurity->currentIndex()==0){ if(ui->cbxSecurity->currentIndex()==0){
@ -152,6 +172,7 @@ void DlgConnHidWifi::changeDialog()
} }
} }
//同一 Wi-Fi安全类型的窗口变换
void DlgConnHidWifi::changeWindow(){ void DlgConnHidWifi::changeWindow(){
if (ui->cbxConn->currentIndex() == 0){ if (ui->cbxConn->currentIndex() == 0){
isUsed = ui->cbxConn->currentIndex(); isUsed = ui->cbxConn->currentIndex();

View File

@ -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/&gt;.
*
*/
#include "ui_dlgconnhidwifileap.h" #include "ui_dlgconnhidwifileap.h"
#include "kylinheadfile.h" #include "kylinheadfile.h"
@ -73,6 +92,7 @@ DlgConnHidWifiLeap::~DlgConnHidWifiLeap()
delete ui; delete ui;
} }
//切换到其他Wi-Fi安全类型
void DlgConnHidWifiLeap::changeDialog() void DlgConnHidWifiLeap::changeDialog()
{ {
if(ui->cbxSecurity->currentIndex()==0){ if(ui->cbxSecurity->currentIndex()==0){

View File

@ -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/&gt;.
*
*/
#include "dlgconnhidwifisecfast.h" #include "dlgconnhidwifisecfast.h"
#include "ui_dlgconnhidwifisecfast.h" #include "ui_dlgconnhidwifisecfast.h"
#include "kylinheadfile.h" #include "kylinheadfile.h"

View File

@ -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/&gt;.
*
*/
#include "dlgconnhidwifisecleap.h" #include "dlgconnhidwifisecleap.h"
#include "ui_dlgconnhidwifisecleap.h" #include "ui_dlgconnhidwifisecleap.h"
#include "kylinheadfile.h" #include "kylinheadfile.h"

View File

@ -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/&gt;.
*
*/
#include "dlgconnhidwifisecpeap.h" #include "dlgconnhidwifisecpeap.h"
#include "ui_dlgconnhidwifisecpeap.h" #include "ui_dlgconnhidwifisecpeap.h"
#include "kylinheadfile.h" #include "kylinheadfile.h"

View File

@ -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/&gt;.
*
*/
#include "dlgconnhidwifisecpwd.h" #include "dlgconnhidwifisecpwd.h"
#include "ui_dlgconnhidwifisecpwd.h" #include "ui_dlgconnhidwifisecpwd.h"
#include "kylinheadfile.h" #include "kylinheadfile.h"

View File

@ -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/&gt;.
*
*/
#include "ui_dlgconnhidwifisectls.h" #include "ui_dlgconnhidwifisectls.h"
#include "kylinheadfile.h" #include "kylinheadfile.h"

View File

@ -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/&gt;.
*
*/
#include "dlgconnhidwifisectunneltls.h" #include "dlgconnhidwifisectunneltls.h"
#include "ui_dlgconnhidwifisectunneltls.h" #include "ui_dlgconnhidwifisectunneltls.h"
#include "kylinheadfile.h" #include "kylinheadfile.h"

View File

@ -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/&gt;.
*
*/
#include "ui_dlgconnhidwifiwep.h" #include "ui_dlgconnhidwifiwep.h"
#include "kylinheadfile.h" #include "kylinheadfile.h"
@ -109,6 +128,7 @@ void DlgConnHidWifiWep::mouseMoveEvent(QMouseEvent *event){
} }
} }
//切换到其他Wi-Fi安全类型
void DlgConnHidWifiWep::changeDialog() void DlgConnHidWifiWep::changeDialog()
{ {
if(ui->cbxSecurity->currentIndex()==0){ if(ui->cbxSecurity->currentIndex()==0){

View File

@ -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/&gt;.
*
*/
#include "dlgconnhidwifiwpa.h" #include "dlgconnhidwifiwpa.h"
#include "ui_dlgconnhidwifiwpa.h" #include "ui_dlgconnhidwifiwpa.h"
#include "kylinheadfile.h" #include "kylinheadfile.h"
@ -114,6 +133,7 @@ void DlgConnHidWifiWpa::mouseMoveEvent(QMouseEvent *event){
} }
} }
//切换到其他Wi-Fi安全类型
void DlgConnHidWifiWpa::changeDialog() void DlgConnHidWifiWpa::changeDialog()
{ {
if(ui->cbxSecurity->currentIndex()==0){ if(ui->cbxSecurity->currentIndex()==0){
@ -152,6 +172,7 @@ void DlgConnHidWifiWpa::changeDialog()
} }
} }
//同一 Wi-Fi安全类型的窗口变换
void DlgConnHidWifiWpa::changeWindow(){ void DlgConnHidWifiWpa::changeWindow(){
if (ui->cbxConn->currentIndex() == 0){ if (ui->cbxConn->currentIndex() == 0){
QApplication::setQuitOnLastWindowClosed(false); QApplication::setQuitOnLastWindowClosed(false);