diff --git a/backthread.cpp b/backthread.cpp index 9f99d992..b3b4c74b 100644 --- a/backthread.cpp +++ b/backthread.cpp @@ -18,10 +18,22 @@ #include "backthread.h" +#include + #include #include 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!"<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!"< /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!"<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!"<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!"</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 } diff --git a/backthread.h b/backthread.h index a730da96..d37fb91d 100644 --- a/backthread.h +++ b/backthread.h @@ -19,8 +19,17 @@ #ifndef BACKTHREAD_H #define BACKTHREAD_H +#include "kylin-dbus-interface.h" +#include "kylin-network-interface.h" + +#include #include #include +#include +#include +#include +#include +#include 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 diff --git a/connup.sh b/connup.sh deleted file mode 100755 index 2e3a0e3e..00000000 --- a/connup.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up "$1" &> /tmp/kylin-nm-btoutput_ diff --git a/debian/.debhelper/generated/kylin-nm/installed-by-dh_installdocs b/debian/.debhelper/generated/kylin-nm/installed-by-dh_installdocs new file mode 100644 index 00000000..e69de29b diff --git a/debian/.debhelper/generated/kylin-nm/installed-by-dh_installman b/debian/.debhelper/generated/kylin-nm/installed-by-dh_installman new file mode 100644 index 00000000..8c02e760 --- /dev/null +++ b/debian/.debhelper/generated/kylin-nm/installed-by-dh_installman @@ -0,0 +1 @@ +./man/kylin-nm.1 diff --git a/debian/.debhelper/kylin-nm/dbgsym-build-ids b/debian/.debhelper/kylin-nm/dbgsym-build-ids new file mode 100644 index 00000000..8a069737 --- /dev/null +++ b/debian/.debhelper/kylin-nm/dbgsym-build-ids @@ -0,0 +1 @@ +18c1694c9d87adc92ebb3d79a081909857f60aff \ No newline at end of file diff --git a/debian/.debhelper/kylin-nm/dbgsym-root/DEBIAN/control b/debian/.debhelper/kylin-nm/dbgsym-root/DEBIAN/control new file mode 100644 index 00000000..4bcf1df6 --- /dev/null +++ b/debian/.debhelper/kylin-nm/dbgsym-root/DEBIAN/control @@ -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 +Installed-Size: 2144 +Depends: kylin-nm (= 1.0.4-1) +Section: debug +Priority: optional +Description: debug symbols for kylin-nm +Build-Ids: 18c1694c9d87adc92ebb3d79a081909857f60aff diff --git a/debian/.debhelper/kylin-nm/dbgsym-root/DEBIAN/md5sums b/debian/.debhelper/kylin-nm/dbgsym-root/DEBIAN/md5sums new file mode 100644 index 00000000..b6456f76 --- /dev/null +++ b/debian/.debhelper/kylin-nm/dbgsym-root/DEBIAN/md5sums @@ -0,0 +1 @@ +469c8cb42ada0c9dd27938a1626a381a usr/lib/debug/.build-id/18/c1694c9d87adc92ebb3d79a081909857f60aff.debug diff --git a/debian/.debhelper/kylin-nm/dbgsym-root/usr/lib/debug/.build-id/18/c1694c9d87adc92ebb3d79a081909857f60aff.debug b/debian/.debhelper/kylin-nm/dbgsym-root/usr/lib/debug/.build-id/18/c1694c9d87adc92ebb3d79a081909857f60aff.debug new file mode 100644 index 00000000..d3d3f69c Binary files /dev/null and b/debian/.debhelper/kylin-nm/dbgsym-root/usr/lib/debug/.build-id/18/c1694c9d87adc92ebb3d79a081909857f60aff.debug differ diff --git a/debian/.debhelper/kylin-nm/dbgsym-root/usr/share/doc/kylin-nm-dbgsym b/debian/.debhelper/kylin-nm/dbgsym-root/usr/share/doc/kylin-nm-dbgsym new file mode 120000 index 00000000..c065ce9e --- /dev/null +++ b/debian/.debhelper/kylin-nm/dbgsym-root/usr/share/doc/kylin-nm-dbgsym @@ -0,0 +1 @@ +kylin-nm \ No newline at end of file diff --git a/debian/control b/debian/control index 6095fff5..ebc3bf23 100644 --- a/debian/control +++ b/debian/control @@ -5,6 +5,7 @@ Maintainer: Kylin Team Uploaders: handsome_feng 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 diff --git a/debian/debhelper-build-stamp b/debian/debhelper-build-stamp new file mode 100644 index 00000000..236ab1eb --- /dev/null +++ b/debian/debhelper-build-stamp @@ -0,0 +1 @@ +kylin-nm diff --git a/debian/files b/debian/files new file mode 100644 index 00000000..ed6e6535 --- /dev/null +++ b/debian/files @@ -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 diff --git a/debian/kylin-nm.substvars b/debian/kylin-nm.substvars new file mode 100644 index 00000000..971eca0b --- /dev/null +++ b/debian/kylin-nm.substvars @@ -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= diff --git a/ksimplenm.cpp b/ksimplenm.cpp index 4aff60cd..2a8f85a3 100644 --- a/ksimplenm.cpp +++ b/ksimplenm.cpp @@ -18,24 +18,33 @@ #include "ksimplenm.h" #include +#include +#include #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; } } diff --git a/ksimplenm.h b/ksimplenm.h index d524cfc5..ccd2875f 100644 --- a/ksimplenm.h +++ b/ksimplenm.h @@ -19,6 +19,7 @@ #ifndef KSIMPLENM_H #define KSIMPLENM_H +#include #include #include #include @@ -32,6 +33,9 @@ public: QProcess *runShellProcess; QString shellOutput; int type; + bool isExecutingGetLanList = false; + bool isExecutingGetWifiList = false; + bool isUseOldLanSlist = false; void execGetLanList(); void execGetWifiList(); diff --git a/kylin-dbus-interface.cpp b/kylin-dbus-interface.cpp new file mode 100644 index 00000000..bf2e9ab3 --- /dev/null +++ b/kylin-dbus-interface.cpp @@ -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 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> obj_reply = m_interface.call("GetAllDevices"); + QList 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 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 reply = interface.call("Get", "org.freedesktop.NetworkManager.Device.Wired", "Carrier"); + + if (reply.value().toString() == "true"){ + qDebug()<<"physical carrier is found: "<mw->onPhysicalCarrierChanged(isWiredCableOn);} +} + +int KylinDBus::getAccessPointsNumber() +{ + QDBusInterface interface( "org.freedesktop.NetworkManager", + wirelessPath.path(), + "org.freedesktop.NetworkManager.Device.Wireless", + QDBusConnection::systemBus() ); + + QDBusReply> reply = interface.call("GetAllAccessPoints"); + QList objPaths = reply.value(); + +// foreach (QDBusObjectPath objPath, objPaths){ +// qDebug()<<"*****path is: "< 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: *************"< +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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 diff --git a/kylin-network-interface.c b/kylin-network-interface.c index f7a43296..961bd1c6 100644 --- a/kylin-network-interface.c +++ b/kylin-network-interface.c @@ -310,7 +310,6 @@ activecon *kylin_network_get_activecon_info() activelist[count].dev=NULL; return activelist; - } //创建新的以太网连接 diff --git a/kylin-nm.pro b/kylin-nm.pro index e72ab44e..5090348b 100644 --- a/kylin-nm.pro +++ b/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 diff --git a/main.cpp b/main.cpp index 4c4f45b0..b186a391 100644 --- a/main.cpp +++ b/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 #include #include #include -#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); } diff --git a/mainwindow.cpp b/mainwindow.cpp index 11ac53c0..3380cdb8 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -21,7 +21,7 @@ #include "oneconnform.h" #include "onelancform.h" -QString llname, lwname, bandWidth, hideWiFiConn; +QString llname, lwname, hideWiFiConn; int currentActWifiSignalLv, count_loop; MainWindow::MainWindow(QWidget *parent) : @@ -50,6 +50,7 @@ MainWindow::MainWindow(QWidget *parent) : this->confForm = new ConfForm(); this->ksnm = new KSimpleNM(); + loading = new LoadingDiv(this); scrollAreal = new QScrollArea(ui->centralWidget); @@ -132,19 +133,14 @@ MainWindow::MainWindow(QWidget *parent) : connect(trayIcon, &QSystemTrayIcon::activated, this, &MainWindow::iconActivated); connect(ksnm, SIGNAL(getLanListFinished(QStringList)), this, SLOT(getLanListDone(QStringList))); connect(ksnm, SIGNAL(getWifiListFinished(QStringList)), this, SLOT(getWifiListDone(QStringList))); - QDBusConnection::systemBus().connect(QString("org.freedesktop.NetworkManager"), - QString("/org/freedesktop/NetworkManager"), - QString("org.freedesktop.NetworkManager"), - QString("DeviceAdded"), this, SLOT(checkWirelessDeviceState(/*QDBusObjectPath*/)) ); - QDBusConnection::systemBus().connect(QString("org.freedesktop.NetworkManager"), - QString("/org/freedesktop/NetworkManager"), - QString("org.freedesktop.NetworkManager"), - QString("DeviceRemoved"), this, SLOT(checkWirelessDeviceState(/*QDBusObjectPath*/)) ); - initTimer(); //初始化定时器 - changeTimerState();//初始化定时器 + objKyDBus = new KylinDBus(this); + checkIsWirelessDeviceOn(); //检测无线网卡是否插入 - getIface(); //初始化网络 + getInitLanSlist(); //初始化有线网列表 + //initTimer(); //初始化定时器 + //changeTimerState();//停止所有定时器 + initNetwork(); //初始化网络 trayIcon->show(); } @@ -157,12 +153,11 @@ MainWindow::~MainWindow() void MainWindow::checkSingle() { int fd = open("/tmp/kylin-nm-lock", O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); - if (fd < 0) { - exit(1); - } + if (fd < 0) { exit(1); } if (lockf(fd, F_TLOCK, 0)) { - qDebug()<<"can't lock single file, exit."; + syslog(LOG_ERR, "Can't lock single file, kylin-network-manager is already running!"); + qDebug()<<"Can't lock single file, kylin-network-manager is already running!"; exit(0); } } @@ -255,7 +250,7 @@ void MainWindow::stopLoading() getActiveInfo(); } -// 获取当前连接的网络和状态并设置图标 +//获取当前连接的网络和状态并设置图标 void MainWindow::getActiveInfo() { QString actLanName = "--"; @@ -311,78 +306,175 @@ void MainWindow::getActiveInfo() } } -// 初始化定时器 +//初始化有线网列表 +void MainWindow::getInitLanSlist() +{ + oldLanSlist.append("TYPE DEVICE NAME "); + QString strSlist; + + system("nmcli connection show>/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("ethernet") != -1){ + QStringList subLine = line.split(" "); + if (subLine[1].size() == 1){ + strSlist = "ethernet -- " + subLine[0]+ " " + subLine[1] + " "; + }else{strSlist = "ethernet -- " + subLine[0] + " "; } + oldLanSlist.append(strSlist); + } + } +} + +//初始化定时器 void MainWindow::initTimer() { - check_isLanConnect = new QTimer(this); - check_isLanConnect->setTimerType(Qt::PreciseTimer); - QObject::connect(check_isLanConnect, SIGNAL(timeout()), this, SLOT(on_isLanConnect())); - check_isLanConnect->start(2000); + checkIfLanConnect = new QTimer(this); + checkIfLanConnect->setTimerType(Qt::PreciseTimer); + QObject::connect(checkIfLanConnect, SIGNAL(timeout()), this, SLOT(on_isLanConnect())); + checkIfLanConnect->start(2000); - check_isWifiConnect = new QTimer(this); - check_isWifiConnect->setTimerType(Qt::PreciseTimer); - QObject::connect(check_isWifiConnect, SIGNAL(timeout()), this, SLOT(on_isWifiConnect())); - check_isWifiConnect->start(2000); + checkIfWifiConnect = new QTimer(this); + checkIfWifiConnect->setTimerType(Qt::PreciseTimer); + QObject::connect(checkIfWifiConnect, SIGNAL(timeout()), this, SLOT(on_isWifiConnect())); + checkIfWifiConnect->start(2000); - check_isNetOn = new QTimer(this); - check_isNetOn->setTimerType(Qt::PreciseTimer); - QObject::connect(check_isNetOn, SIGNAL(timeout()), this, SLOT(on_isNetOn())); - check_isNetOn->start(2000); + checkIfNetworkOn = new QTimer(this); + checkIfNetworkOn->setTimerType(Qt::PreciseTimer); + QObject::connect(checkIfNetworkOn, SIGNAL(timeout()), this, SLOT(on_isNetOn())); + checkIfNetworkOn->start(2000); } void MainWindow::changeTimerState() { - if (check_isLanConnect->isActive()){ - check_isLanConnect->stop(); + if (checkIfLanConnect->isActive()){ + checkIfLanConnect->stop(); } - if (check_isNetOn->isActive()){ - check_isNetOn->stop(); + if (checkIfNetworkOn->isActive()){ + checkIfNetworkOn->stop(); } - if (check_isWifiConnect->isActive()){ - check_isWifiConnect->stop(); + if (checkIfWifiConnect->isActive()){ + checkIfWifiConnect->stop(); } } -//检测无线网卡与网线是否准备好,以及相应的处理 -void MainWindow::checkWirelessDeviceState(/*QDBusObjectPath path*/) +//由kylin-dbus-interface.cpp调用 +void MainWindow::onPhysicalCarrierChanged(bool flag) { - checkIsWirelessDeviceOn(); + is_stop_check_net_state = 1; + this->startLoading(); + if (flag){ + syslog(LOG_DEBUG,"wired physical cable is already plug in"); + wiredCableUpTimer->start(4000); + } else{ + syslog(LOG_DEBUG,"wired physical cable is already plug out"); + wiredCableDownTimer->start(6000); + } +} +void MainWindow::onCarrierUpHandle() +{ + wiredCableUpTimer->stop(); + BackThread *up_bt = new BackThread(); + up_bt->lanDelete(); + sleep(1); + up_bt->lanDelete(); + sleep(1); + up_bt->lanDelete(); + up_bt->deleteLater(); + + this->stopLoading(); + on_btnNetList_clicked(1); + is_stop_check_net_state = 0; +} +void MainWindow::onCarrierDownHandle() +{ + wiredCableDownTimer->stop(); + this->stopLoading(); + on_btnNetList_clicked(0); + is_stop_check_net_state = 0; +} + +//无线网卡插拔处理 +void MainWindow::onWirelessDeviceAdded(QDBusObjectPath objPath) +{ + //仅处理无线网卡插入情况 + syslog(LOG_DEBUG,"wireless device is already plug in"); +// KylinDBus kDBus1; + objKyDBus->isWirelessCardOn = false; + objKyDBus->getObjectPath(); + if (objKyDBus->isWirelessCardOn) { + is_wireless_adapter_ready = 1; + } else { + is_wireless_adapter_ready = 0; + } + on_btnWifi_clicked(); +} +void MainWindow::onWirelessDeviceRemoved(QDBusObjectPath objPath) +{ + //仅处理无线网卡拔出情况 + syslog(LOG_DEBUG,"wireless device is already plug out"); +// KylinDBus kDBus2; + if (objKyDBus->wirelessPath.path() == objPath.path()){ + is_wireless_adapter_ready = 0; + } on_btnWifi_clicked(); } void MainWindow::checkIsWirelessDeviceOn() { - QString wlan_card = "iwconfig>/tmp/kylin-nm-iwconfig"; - system(wlan_card.toUtf8().data()); - - QFile file("/tmp/kylin-nm-iwconfig"); - if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - qDebug()<<"Can't open the file kylin-nm-iwconfig!"<isWirelessCardOn) { is_wireless_adapter_ready = 1; - }else{ + } else { is_wireless_adapter_ready = 0; } } -// 初始化网络 -void MainWindow::getIface() +void MainWindow::getLanBandWidth() { BackThread *bt = new BackThread(); IFace *iface = bt->execGetIface(); + lname = iface->lname; + + mwBandWidth = bt->execChkLanWidth(lname); +} + +// 初始化网络 +void MainWindow::initNetwork() +{ + BackThread *m_bt = new BackThread(); + IFace *m_iface = m_bt->execGetIface(); + qDebug()<<"lstate ="<lstate<<" wstate ="<wstate ; + syslog(LOG_DEBUG, "state of switch: lstate =%d wstate =%d", m_iface->lstate, m_iface->wstate); + m_bt->lanDelete(); + sleep(1); + m_bt->lanDelete(); + sleep(1); + m_bt->lanDelete(); + delete m_iface; + m_bt->deleteLater(); + + BackThread *bt = new BackThread(); + IFace *iface = bt->execGetIface(); + wname = iface->wname; lwname = iface->wname; lname = iface->lname; llname = iface->lname; - bandWidth = bt->execChkLanWidth(lname); + mwBandWidth = bt->execChkLanWidth(lname); // 开关状态 + qDebug()<<"lstate ="<lstate<<" wstate ="<wstate ; + syslog(LOG_DEBUG, "state of switch: lstate =%d wstate =%d", iface->lstate, iface->wstate); if(iface->lstate == 0 || iface->lstate == 1){ ui->lbLanImg->setStyleSheet("QLabel{background-image:url(:/res/x/network-line.png);}"); ui->lbBtnNetBG->setStyleSheet(btnOnQss); @@ -410,14 +502,17 @@ void MainWindow::getIface() // 初始化网络列表 if(iface->wstate != 2){ - if (iface->wstate == 0) { - connDone(3); - } else if(iface->lstate == 0) { - connLanDone(3); - } else if(iface->wstate == 1 && (iface->lstate == 1)) { - qDebug()<<"启动软件,即将循环检测 Lan或Wifi 是否开启"; - changeTimerState(); - check_isNetOn->start(4000); + if (iface->wstate == 0){ + connWifiDone(3); + }else{ + if (iface->lstate == 0){ + connLanDone(3); + }else{ + //syslog(LOG_DEBUG, "Launch kylin-nm, will check if Lan or Wifi connected circularly"); + //qDebug()<<"连接状态:启动kylin-nm, 即将循环检测 Lan或Wifi 是否连接"; + //changeTimerState(); + //checkIfNetworkOn->start(8000); + } } on_btnWifiList_clicked(); ui->btnWifiList->setStyleSheet("#btnWifiList{font-size:12px;color:white;border:1px solid rgba(255,255,255,0.1);border:1px solid rgba(255,255,255,0.5);background:transparent;background-color:rgba(255,255,255,0.1);}"); @@ -427,15 +522,35 @@ void MainWindow::getIface() if(iface->lstate != 2){ if (iface->lstate == 0) { connLanDone(3); + } else{ + //syslog(LOG_DEBUG, "Launch kylin-nm, will check if Lan or Wifi connected circularly"); + //qDebug()<<"连接状态:启动kylin-nm, 即将循环检测 Lan或Wifi 是否连接"; + //changeTimerState(); + //checkIfNetworkOn->start(8000); } on_btnNetList_clicked(); ui->btnNetList->setStyleSheet("#btnNetList{font-size:12px;color:white;border:1px solid rgba(255,255,255,0.1);border:1px solid rgba(255,255,255,0.5);background:transparent;background-color:rgba(255,255,255,0.1);}"); ui->btnWifiList->setStyleSheet("#btnWifiList{font-size:12px;color:white;border:1px solid rgba(255,255,255,0.1);background:transparent;background-color:rgba(0,0,0,0.2);}" "#btnWifiList:Pressed{border:1px solid rgba(255,255,255,0.5);background:transparent;background-color:rgba(255,255,255,0.1);}"); - }else{ + }else { disNetDone(); } } + + //循环检测wifi列表的变化 + checkWifiListChanged = new QTimer(this); + checkWifiListChanged->setTimerType(Qt::PreciseTimer); + QObject::connect(checkWifiListChanged, SIGNAL(timeout()), this, SLOT(on_checkWifiListChanged())); + checkWifiListChanged->start(7000); + + //网线插入时定时执行 + wiredCableUpTimer = new QTimer(this); + wiredCableUpTimer->setTimerType(Qt::PreciseTimer); + QObject::connect(wiredCableUpTimer, SIGNAL(timeout()), this, SLOT(onCarrierUpHandle())); + //网线拔出时定时执行 + wiredCableDownTimer = new QTimer(this); + wiredCableDownTimer->setTimerType(Qt::PreciseTimer); + QObject::connect(wiredCableDownTimer, SIGNAL(timeout()), this, SLOT(onCarrierDownHandle())); } void MainWindow::iconActivated(QSystemTrayIcon::ActivationReason reason) @@ -505,6 +620,9 @@ bool MainWindow::checkLanOn() }else{ return true; } + + delete iface; + bt->deleteLater(); } bool MainWindow::checkWlOn() @@ -522,6 +640,11 @@ bool MainWindow::checkWlOn() // 获取lan列表回调 void MainWindow::getLanListDone(QStringList slist) { + if (this->ksnm->isUseOldLanSlist){ + slist = oldLanSlist; + this->ksnm->isUseOldLanSlist = false; + } + // 清空lan列表 lanListWidget = new QWidget(scrollAreal); lanListWidget->resize(314, 8 + 60 + 46 + 51); @@ -570,14 +693,17 @@ void MainWindow::getLanListDone(QStringList slist) if(ltype != "wifi" && ltype != "" && ltype != "--"){ // 当前连接的lan if(nname == actLanName){ + if (mwBandWidth == "Unknown!") { getLanBandWidth(); } + connect(ccf, SIGNAL(selectedOneLanForm(QString)), this, SLOT(oneLanFormSelected(QString))); connect(ccf, SIGNAL(disconnActiveLan()), this, SLOT(activeLanDisconn())); ccf->setName(nname); ccf->setIcon(true); - ccf->setBandWidth(bandWidth); + ccf->setBandWidth(mwBandWidth); ccf->setShowPoint(true); ccf->setConnedString(tr("Connected"));//"已连接" currSelNetName = ""; + syslog(LOG_DEBUG, "already insert an active lannet in the top of lan list"); }else{ lanListWidget->resize(314, lanListWidget->height() + 60); @@ -599,21 +725,22 @@ void MainWindow::getLanListDone(QStringList slist) this->wifiListWidget->hide(); this->stopLoading(); + oldLanSlist = slist; } // 获取wifi列表回调 void MainWindow::getWifiListDone(QStringList slist) { - if (updateFlag == 0){ + qDebug()<<"debug: oldWifiSlist.size()="<setSignal(wsignal); ccf->setConnedString(tr("Connected"));//"已连接" currSelNetName = ""; + + syslog(LOG_DEBUG, "already insert an active wifi in the top of wifi list"); }else{ wifiListWidget->resize(314, wifiListWidget->height() + 60); @@ -713,7 +838,6 @@ void MainWindow::loadWifiListDone(QStringList slist) //添加 连接到隐藏的Wi-Fi网络 小窗口 wifiListWidget->resize(314, wifiListWidget->height() + 60); OneConnForm *hideNetButton = new OneConnForm(wifiListWidget, this, confForm, ksnm); -// connect(hideNetButton, SIGNAL(selectedOneWifiForm(QString)), this, SLOT(oneHideFormSelected(QString))); connect(hideNetButton, SIGNAL(selectedOneWifiForm(QString)), this, SLOT(oneWifiFormSelected(QString))); hideNetButton->setSpecialName(hideWiFiConn); hideNetButton->setSignal(0); @@ -723,32 +847,16 @@ void MainWindow::loadWifiListDone(QStringList slist) this->lanListWidget->hide(); this->wifiListWidget->show(); -// this->stopLoading(); + is_stop_check_net_state = 0; + this->stopLoading(); } - // 更新wifi列表 void MainWindow::updateWifiListDone(QStringList slist) { - // 获取当前连接的wifi name - QString actWifiName = "--"; - activecon *act = kylin_network_get_activecon_info(); - int index = 0; - while(act[index].con_name != NULL){ - if(QString(act[index].type) == "wifi"){ - actWifiName = QString(act[index].con_name); - break; - } - index ++; - } - - QList wifiList = wifiListWidget->findChildren(); - if (wifiList.size() <= 1){ - loadWifiListDone(slist); //通常为关闭wifi开关再打开 或是 拔出无线网卡后再插入的情况 - return; - } + if (this->ksnm->isExecutingGetLanList){ return;} //获取表头信息 - QString lastHeadLine = lastSlist.at(0); + QString lastHeadLine = oldWifiSlist.at(0); lastHeadLine = lastHeadLine.trimmed(); int lastIndexName = lastHeadLine.indexOf("SSID"); @@ -759,8 +867,8 @@ void MainWindow::updateWifiListDone(QStringList slist) int indexName = headLine.indexOf("SSID"); //列表中去除已经减少的wifi - for (int i=1; i wifiList = wifiListWidget->findChildren(); for(int pos = 0; pos < wifiList.size(); pos ++){ OneConnForm *ocf = wifiList.at(pos); @@ -811,13 +920,14 @@ void MainWindow::updateWifiListDone(QStringList slist) if(isContinue){continue;} wnames.append(wname); - for (int j=1; j < lastSlist.size(); j++){ - QString line = lastSlist.at(j); + for (int j=1; j < oldWifiSlist.size(); j++){ + QString line = oldWifiSlist.at(j); QString lastWname = line.mid(lastIndexName).trimmed(); if (lastWname == wname){break;} //上一次的wifi列表已经有名为wname的wifi,则停止 - if (j == lastSlist.size()-1){ //到lastSlist最后一个都没找到,执行下面流程 - qDebug()<<"will insert a wifi named "< wifiList = wifiListWidget->findChildren(); int n = wifiList.size(); OneConnForm *lastOcf = wifiList.at(n-1); @@ -831,16 +941,13 @@ void MainWindow::updateWifiListDone(QStringList slist) //添加 连接到隐藏的Wi-Fi网络 小窗口 wifiListWidget->resize(314, wifiListWidget->height() + 60); OneConnForm *hideNetButton = new OneConnForm(wifiListWidget, this, confForm, ksnm); - //connect(hideNetButton, SIGNAL(selectedOneWifiForm(QString)), this, SLOT(oneHideFormSelected(QString))); connect(hideNetButton, SIGNAL(selectedOneWifiForm(QString)), this, SLOT(oneWifiFormSelected(QString))); hideNetButton->setSpecialName(hideWiFiConn); hideNetButton->setSignal(0); hideNetButton->setSafe("Safe"); hideNetButton->move(0, lastOcf->y()+60); hideNetButton->setHideSelected(false); - if (currSelNetName == hideWiFiConn){ - hideNetButton->setHideSelected(true); - } + if (currSelNetName == hideWiFiConn){ hideNetButton->setHideSelected(true); } hideNetButton->show(); count += 1; @@ -866,6 +973,7 @@ void MainWindow::on_btnNet_clicked() t->start(); }else{ + is_stop_check_net_state = 1; QThread *t = new QThread(); BackThread *bt = new BackThread(); bt->moveToThread(t); @@ -895,6 +1003,8 @@ void MainWindow::on_btnWifi_clicked() connect(bt, SIGNAL(btFinish()), t, SLOT(quit())); t->start(); }else{ + on_btnWifiList_clicked(); + is_stop_check_net_state = 1; QThread *t = new QThread(); BackThread *bt = new BackThread(); bt->moveToThread(t); @@ -911,6 +1021,8 @@ void MainWindow::on_btnWifi_clicked() QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "' -t 3800"; system(cmd.toUtf8().data()); + on_btnWifiList_clicked(); + is_stop_check_net_state = 1; QThread *t = new QThread(); BackThread *bt = new BackThread(); bt->moveToThread(t); @@ -933,6 +1045,15 @@ void MainWindow::on_btnWifi_clicked() void MainWindow::on_btnNetList_clicked(int flag) { +// if (this->ksnm->isExecutingGetWifiList ){ +// qDebug()<<"executing update Wifi list now, try again"; +// on_btnWifiList_pressed(); //当正在更新wifi列表时,点击无效 +// QString text(tr("update Wi-Fi list now, click again")); //"正在更新 Wi-Fi列表 请再次点击" +// QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + text + "...' -t 3800"; +// system(cmd.toUtf8().data()); +// return; +// } + this->is_btnNetList_clicked = 1; this->is_btnWifiList_clicked = 0; @@ -950,6 +1071,20 @@ void MainWindow::on_btnNetList_clicked(int flag) this->startLoading(); this->ksnm->execGetLanList(); } else { + syslog(LOG_DEBUG, "btnNetList is clicked, but the return value of checkLanOn() is false"); + qDebug()<<"debug: btnNetList is clicked, but the return value of checkLanOn() is false"; + + //if (objKyDBus->getLanConnState() == 0){ + if (true){ + BackThread *btn_bt = new BackThread(); + btn_bt->lanDelete(); + sleep(1); + btn_bt->lanDelete(); + sleep(1); + btn_bt->lanDelete(); + btn_bt->deleteLater(); + } + // 清空lan列表 lanListWidget = new QWidget(scrollAreal); lanListWidget->resize(314, 8 + 60 + 46 + 51); @@ -977,10 +1112,10 @@ void MainWindow::on_btnNetList_clicked(int flag) this->lanListWidget->show(); this->wifiListWidget->hide(); } + this->scrollAreal->show(); this->scrollAreaw->hide(); on_btnNetList_pressed(); - } void MainWindow::on_btnWifiList_clicked() @@ -1020,14 +1155,34 @@ void MainWindow::on_btnWifiList_clicked() this->lanListWidget->hide(); this->wifiListWidget->show(); } + this->scrollAreal->hide(); this->scrollAreaw->show(); on_btnWifiList_pressed(); } -// Lan连接结果,0点击连接成功 1失败 3开机启动网络工具时已经连接 +//**************下为循环部分************************// +void MainWindow::on_checkWifiListChanged(){ + if (is_stop_check_net_state==0 && this->is_btnWifiList_clicked==1 && this->isVisible()){ + BackThread *loop_bt = new BackThread(); + IFace *loop_iface = loop_bt->execGetIface(); + + if (loop_iface->wstate != 2){ + is_update_wifi_list = 1; + this->ksnm->execGetWifiList(); //更新wifi列表 + } + + delete loop_iface; + loop_bt->deleteLater(); + } +} + void MainWindow::connLanDone(int connFlag){ + // Lan连接结果,0点击连接成功 1失败 3开机启动网络工具时已经连接 if(connFlag == 0){ + syslog(LOG_DEBUG, "Wired net already connected by clicking button"); + //syslog(LOG_DEBUG, "Wired net already connected by clicking button, will check if Lan disconnected again circularly"); + //qDebug()<<"连接状态:有线网络已经点击连接,即将重新检测 Lan 是否断开"; this->is_wired_line_ready = 1; this->is_by_click_connect = 1; this->ksnm->execGetLanList(); @@ -1035,11 +1190,12 @@ void MainWindow::connLanDone(int connFlag){ QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "' -t 3800"; system(cmd.toUtf8().data()); - changeTimerState(); - check_isLanConnect->start(4000); + //changeTimerState(); + //checkIfLanConnect->start(8000); } if(connFlag == 1){ + qDebug()<<"without net line connect to computer"; this->is_wired_line_ready = 0; //without net line connect to computer QString txt(tr("Conn Ethernet Fail")); QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "' -t 3800"; @@ -1047,10 +1203,12 @@ void MainWindow::connLanDone(int connFlag){ } if(connFlag == 3){ - qDebug()<<"启动软件,Lan已经开启,即将循环检测是否断开"; + syslog(LOG_DEBUG, "Launch kylin-nm, Lan already connected"); + //syslog(LOG_DEBUG, "Launch kylin-nm, Lan already connected, will check if Lan disconnected circularly"); + //qDebug()<<"连接状态:启动kylin-nm,Lan已经开启,即将循环检测是否断开"; this->is_wired_line_ready = 1; - changeTimerState(); - check_isLanConnect->start(4000); + //changeTimerState(); + //checkIfLanConnect->start(8000); } this->stopLoading(); @@ -1058,136 +1216,164 @@ void MainWindow::connLanDone(int connFlag){ void MainWindow::on_isLanConnect() { - BackThread *bt = new BackThread(); - IFace *iface = bt->execGetIface(); + BackThread *loop_bt = new BackThread(); + IFace *loop_iface = loop_bt->execGetIface(); - if (iface->lstate == 1){ - qDebug()<<"注意:有线网络连接已经断开"; - if(this->is_btnNetList_clicked == 1) { - this->ksnm->execGetLanList(); - } - if(this->is_btnWifiList_clicked== 1) { - this->ksnm->execGetWifiList(); - } - this->is_by_click_connect = 0; - check_isLanConnect->stop(); + if (is_stop_check_net_state == 0){ + if (loop_iface->lstate == 1){ + syslog(LOG_DEBUG, "Wired net is disconnected"); + qDebug()<<"连接状态:有线网络连接已经断开"; + if(this->is_btnNetList_clicked == 1) { + this->ksnm->execGetLanList(); + } + if(this->is_btnWifiList_clicked== 1) { + this->ksnm->execGetWifiList(); + } + this->is_by_click_connect = 0; + checkIfLanConnect->stop(); - if (iface->wstate != 0){ - qDebug()<<"即将检测是否重新开启 Lan或Wifi"; - changeTimerState(); - check_isNetOn->start(4000); - } - } else if (iface->wstate != 2) { - count_loop += 1; - if (count_loop >= 2 && this->is_btnWifiList_clicked == 1){ - //period update wifilist - updateFlag = 1; - this->ksnm->execGetWifiList(); - count_loop = 0; + if (loop_iface->wstate != 0){ + syslog(LOG_DEBUG, "Will check if LAN or Wi-Fi connected again circularly"); + qDebug()<<"连接状态:即将循环检测是否重新连接 Lan或Wifi"; + //changeTimerState(); + //checkIfNetworkOn->start(8000); + } + } else if (loop_iface->wstate != 2) { + count_loop = 1; + if (count_loop==1 && this->is_btnWifiList_clicked == 1){ + if (this->isVisible() ){ + is_update_wifi_list = 1; + this->ksnm->execGetWifiList(); //更新wifi列表 + } + } + if (count_loop >= 2){ count_loop = 1;} } } + + delete loop_iface; + delete loop_bt; } void MainWindow::on_isNetOn() { - BackThread *bt = new BackThread(); - IFace *iface = bt->execGetIface(); + BackThread *loop_bt = new BackThread(); + IFace *loop_iface = loop_bt->execGetIface(); - if (iface->lstate == 0 && this->is_by_click_connect == 0 && this->is_wired_line_ready == 1){ - qDebug()<<"注意:有线网络已经重新连接"; - if(this->is_btnNetList_clicked == 1) { - this->ksnm->execGetLanList(); - } - if(this->is_btnWifiList_clicked== 1) { - this->ksnm->execGetWifiList(); - } - check_isNetOn->stop(); + if (is_stop_check_net_state == 0){ + if (loop_iface->lstate == 0 && this->is_by_click_connect == 0 && this->is_wired_line_ready == 1){ + syslog(LOG_DEBUG, "Lan already connected again, will check if Wi-Fi disconnected circularly"); + qDebug()<<"连接状态:有线网络已经重新连接,即将循环检测 Lan 是否断开"; + if(this->is_btnNetList_clicked == 1) { + this->ksnm->execGetLanList(); + } + if(this->is_btnWifiList_clicked== 1) { + this->ksnm->execGetWifiList(); + } + checkIfNetworkOn->stop(); - qDebug()<<"即将重新检测 Lan 是否断开"; - changeTimerState(); - check_isLanConnect->start(4000); - } else if (iface->lstate == 0 && this->is_by_click_connect == 1){ - qDebug()<<"注意:有线网络已经点击连接"; - check_isNetOn->stop(); - qDebug()<<"即将重新检测 Lan 是否断开"; - } else if (iface->wstate == 0 && this->is_by_click_connect == 0){ - qDebug()<<"注意:Wifi网络已经重新连接"; - if(this->is_btnNetList_clicked == 1) { - this->ksnm->execGetLanList(); - } - if(this->is_btnWifiList_clicked== 1) { - this->ksnm->execGetWifiList(); - } - check_isNetOn->stop(); + //changeTimerState(); + //checkIfLanConnect->start(8000); + } else if (loop_iface->lstate == 0 && this->is_by_click_connect == 1){ + qDebug()<<"连接状态:有线网络已经点击连接,即将重新循环检测 Lan 是否断开"; + checkIfNetworkOn->stop(); + } else if (loop_iface->wstate == 0 && this->is_by_click_connect == 0){ + syslog(LOG_DEBUG, "Wi-Fi already connected again, will check if Wi-Fi disconnected circularly"); + qDebug()<<"连接状态:Wifi网络已经重新连接,即将循环检测 Wifi 是否断开"; + if(this->is_btnNetList_clicked == 1) { + this->ksnm->execGetLanList(); + } + if(this->is_btnWifiList_clicked== 1) { + this->ksnm->execGetWifiList(); + } + checkIfNetworkOn->stop(); - qDebug()<<"即将重新检测 Wifi 是否断开"; - changeTimerState(); - check_isWifiConnect->start(4000); - } else if (iface->wstate == 0 && this->is_by_click_connect == 1){ - qDebug()<<"注意:Wifi网络已经点击连接"; - check_isNetOn->stop(); - qDebug()<<"即将重新检测 Wifi 是否断开"; - } else if (iface->wstate != 2) { - count_loop += 1; - if (count_loop >= 2 && this->is_btnWifiList_clicked == 1){ - //period update wifilist - updateFlag = 1; - this->ksnm->execGetWifiList(); - count_loop = 0; + //changeTimerState(); + //checkIfWifiConnect->start(8000); + } else if (loop_iface->wstate == 0 && this->is_by_click_connect == 1){ + qDebug()<<"连接状态:Wifi网络已经点击连接,即将重新循环检测 Wifi 是否断开"; + checkIfNetworkOn->stop(); + } else if (loop_iface->wstate != 2) { + count_loop = 1; + if (count_loop==1 && this->is_btnWifiList_clicked == 1){ + if (this->isVisible() ){ + is_update_wifi_list = 1; + this->ksnm->execGetWifiList(); //更新wifi列表 + } + } + if (count_loop >= 2){ count_loop = 1;} } } + + delete loop_iface; + delete loop_bt; } -// Wifi连接结果,0点击连接成功 1失败 2没有配置文件 3开机启动网络工具时已经连接 -void MainWindow::connDone(int connFlag) +void MainWindow::connWifiDone(int connFlag) { + // Wifi连接结果,0点击连接成功 1失败 2没有配置文件 3开机启动网络工具时已经连接 if(connFlag == 0){ + syslog(LOG_DEBUG, "Wi-Fi already connected by clicking button"); + //syslog(LOG_DEBUG, "Wi-Fi already connected by clicking button, will check if Wi-Fi disconnected again circularly"); + //qDebug()<<"连接状态:Wifi网络已经点击连接,即将重新循环检测 Wifi 是否断开"; this->is_by_click_connect = 1; this->ksnm->execGetWifiList(); QString txt(tr("Conn Wifi Success")); QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "' -t 3800"; system(cmd.toUtf8().data()); - changeTimerState(); - check_isWifiConnect->start(4000); + //changeTimerState(); + //checkIfWifiConnect->start(8000); + } else if (connFlag == 1) { + is_stop_check_net_state = 0; } else if (connFlag == 3) { - qDebug()<<"启动软件,Wifi已经开启,即将循环检测是否断开"; - changeTimerState(); - check_isWifiConnect->start(4000); + syslog(LOG_DEBUG, "Launch kylin-nm, Wi-Fi already connected"); + //syslog(LOG_DEBUG, "Launch kylin-nm, Wi-Fi already connected, will check if Wi-Fi disconnected circularly"); + //qDebug()<<"连接状态:启动kylin-nm, Wifi已经连接,即将循环检测是否断开"; + //changeTimerState(); + //checkIfWifiConnect->start(8000); } } void MainWindow::on_isWifiConnect() { - BackThread *bt = new BackThread(); - IFace *iface = bt->execGetIface(); + BackThread *loop_bt = new BackThread(); + IFace *loop_iface = loop_bt->execGetIface(); - if (iface->wstate == 1){ - qDebug()<<"注意:Wifi 网络连接已经断开"; - if(this->is_btnNetList_clicked == 1) { - this->ksnm->execGetLanList(); - } - if(this->is_btnWifiList_clicked== 1) { - this->ksnm->execGetWifiList(); - } - this->is_by_click_connect = 0; - check_isWifiConnect->stop(); + if (is_stop_check_net_state == 0){ + if (loop_iface->wstate == 1){ + syslog(LOG_DEBUG, "Wi-Fi is disconnected"); + qDebug()<<"连接状态:Wifi 网络连接已经断开"; + if(this->is_btnNetList_clicked == 1) { + this->ksnm->execGetLanList(); + } + if(this->is_btnWifiList_clicked== 1) { + this->ksnm->execGetWifiList(); + } + this->is_by_click_connect = 0; + checkIfWifiConnect->stop(); - if (iface->lstate != 0){ - qDebug()<<"即将检测是否重新开启 Lan或Wifi"; - changeTimerState(); - check_isNetOn->start(4000); - } - } else if (iface->wstate != 2){ - count_loop += 1; - if (count_loop >= 2 && this->is_btnWifiList_clicked == 1){ - //period update wifilist - updateFlag = 1; - this->ksnm->execGetWifiList(); - count_loop = 0; + if (loop_iface->lstate != 0){ + syslog(LOG_DEBUG, "Will check if LAN or Wi-Fi connected again circularly"); + qDebug()<<"连接状态:即将循环检测是否重新开启 Lan或Wifi"; + //changeTimerState(); + //checkIfNetworkOn->start(8000); + } + } else if (loop_iface->wstate != 2){ + count_loop = 1; + if (count_loop==1 && this->is_btnWifiList_clicked == 1){ + if (this->isVisible() ){ + is_update_wifi_list = 1; + this->ksnm->execGetWifiList(); //更新wifi列表 + } + } + if (count_loop >= 2){ count_loop = 1;} } } + \ + delete loop_iface; + delete loop_bt; } +//**************上为循环部分************************// void MainWindow::on_btnAdvConf_clicked() { @@ -1345,63 +1531,37 @@ void MainWindow::oneWifiFormSelected(QString wifiName) } -void MainWindow::oneHideFormSelected(QString wifiName) -{ - QList wifiList = wifiListWidget->findChildren(); - - // 所有元素回到原位 - for(int i = 0, j = 0;i < wifiList.size(); i ++){ - OneConnForm *ocf = wifiList.at(i); - if(ocf->isActive == true){ - ocf->move(0, 8); - } - if(ocf->isActive == false){ - ocf->move(0, 114 + j * 60); - j ++; - } - } - lbWifiList->move(12, 68); - - //是否与上一次选中同一个网络框 0否 1是 - int isReSelect = 0; - if (currSelNetName == wifiName){ - isReSelect = 1; - currSelNetName = ""; - } else { - isReSelect = 0; - currSelNetName = wifiName; - } - - - // 设置选中,放大缩小所有选项卡 - int selectY = 0; - for(int i = 0;i < wifiList.size(); i ++){ - OneConnForm *ocf = wifiList.at(i); - if (ocf->wifiName == hideWiFiConn){ - if (isReSelect == 0){ - ocf->setHideSelected(true); - selectY = ocf->y(); - } else if (isReSelect == 1){ - ocf->setHideSelected(false); - } - } else { - ocf->setSelected(false); - } - } -} - void MainWindow::activeLanDisconn() { + syslog(LOG_DEBUG, "Wired net is disconnected"); + currSelNetName = ""; this->startLoading(); this->ksnm->execGetLanList(); - currSelNetName = ""; } void MainWindow::activeWifiDisconn() { - this->startLoading(); - this->ksnm->execGetWifiList(); + QThread *tt = new QThread(); + BackThread *btt = new BackThread(); + btt->moveToThread(tt); + connect(tt, SIGNAL(finished()), tt, SLOT(deleteLater())); + connect(tt, SIGNAL(started()), this, SLOT(activeStartLoading())); + connect(this, SIGNAL(deleteRedundantNet()), btt, SLOT(redundantNetDeleted())); + connect(btt, SIGNAL(disFinish()), this, SLOT(activeGetWifiList())); + connect(btt, SIGNAL(ttFinish()), tt, SLOT(quit())); + tt->start(); +} +void MainWindow::activeStartLoading() +{ + syslog(LOG_DEBUG, "Wi-Fi is disconnected"); currSelNetName = ""; + this->startLoading(); + emit this->deleteRedundantNet(); +} + +void MainWindow::activeGetWifiList() +{ + this->ksnm->execGetWifiList(); } void MainWindow::on_btnAdvConf_pressed() @@ -1417,7 +1577,7 @@ void MainWindow::on_btnAdvConf_released() void MainWindow::enNetDone() { BackThread *bt = new BackThread(); - bandWidth = bt->execChkLanWidth(lname); + mwBandWidth = bt->execChkLanWidth(lname); ui->lbLanImg->setStyleSheet("QLabel{background-image:url(:/res/x/network-line.png);}"); ui->lbBtnNetBG->setStyleSheet(btnOnQss); @@ -1430,9 +1590,11 @@ void MainWindow::enNetDone() ui->lbBtnWifiT1->setText(tr("Enabled"));//"已开启" } - this->stopLoading(); - on_btnNetList_clicked(1); + is_stop_check_net_state = 0; + + qDebug()<<"debug: already turn on the switch of lan network"; + syslog(LOG_DEBUG, "Already turn on the switch of lan network"); } void MainWindow::disNetDone() @@ -1453,7 +1615,7 @@ void MainWindow::disNetDone() ccf->move(0, 8); ccf->show(); - // 名为可用网络列表一栏 + // 名为'可用网络列表'一栏 lbLanList = new QLabel(lanListWidget); lbLanList->setText(tr("Ethernet Networks"));//"可用网络列表" lbLanList->resize(260, 46); @@ -1476,6 +1638,9 @@ void MainWindow::disNetDone() on_btnNetList_pressed(); + qDebug()<<"debug: already turn off the switch of lan network"; + syslog(LOG_DEBUG, "Already turn off the switch of lan network"); + this->stopLoading(); } @@ -1492,9 +1657,12 @@ void MainWindow::enWifiDone() ui->lbBtnWifiBG->setStyleSheet(btnOnQss); ui->lbBtnWifiT1->setText(tr("Enabled"));//"已开启" - this->stopLoading(); + is_update_wifi_list = 0; +// on_btnWifiList_clicked(); + this->ksnm->execGetWifiList(); - on_btnWifiList_clicked(); + qDebug()<<"debug: already turn on the switch of wifi network"; + syslog(LOG_DEBUG, "Already turn on the switch of wifi network"); } void MainWindow::disWifiDone() @@ -1529,6 +1697,9 @@ void MainWindow::disWifiDone() on_btnWifiList_pressed(); + qDebug()<<"debug: already turn off the switch of wifi network"; + syslog(LOG_DEBUG, "Already turn off the switch of wifi network"); + this->stopLoading(); } diff --git a/mainwindow.h b/mainwindow.h index 47227ba8..c0bcc66f 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -38,16 +38,18 @@ #include #include #include +#include #include #include #include - -#include +#include +#include #include #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 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 diff --git a/nmqrc.qrc b/nmqrc.qrc index ab961adb..72e4a216 100644 --- a/nmqrc.qrc +++ b/nmqrc.qrc @@ -61,13 +61,13 @@ res/s/rescan/10.png res/s/rescan/11.png res/s/rescan/12.png - res/kylin-nm_zh_CN.qm - res/wifi.png res/h/add-hide-wifi.png res/h/add-hide-wifi.svg res/h/hide-pwd.png res/h/right-pwd.png res/h/show-pwd.png res/h/no-pwd-wifi.png + translations/kylin-nm_bo.qm + translations/kylin-nm_zh_CN.qm diff --git a/oneconnform.cpp b/oneconnform.cpp index 5ec7f447..a4391599 100644 --- a/oneconnform.cpp +++ b/oneconnform.cpp @@ -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: "<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) { diff --git a/oneconnform.h b/oneconnform.h index 386095cb..1890bea7 100644 --- a/oneconnform.h +++ b/oneconnform.h @@ -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(); diff --git a/oneconnform.ui b/oneconnform.ui index 2e9bdf11..c26b7cf1 100644 --- a/oneconnform.ui +++ b/oneconnform.ui @@ -179,8 +179,8 @@ - 264 - 30 + 260 + 31 18 9 @@ -195,13 +195,13 @@ btnConn lbSignal lbSafe - lePassword lbConned lbPoint btnDisConn lbPassword btnConnPWD btnHideConn + lePassword checkBoxPwd diff --git a/onelancform.cpp b/onelancform.cpp index 409602b3..bb3bc02d 100644 --- a/onelancform.cpp +++ b/onelancform.cpp @@ -20,6 +20,8 @@ #include "ui_onelancform.h" #include "mainwindow.h" +#include + 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);}"); } diff --git a/onelancform.h b/onelancform.h index 63a1402c..fae26e99 100644 --- a/onelancform.h +++ b/onelancform.h @@ -64,7 +64,7 @@ signals: void sigConnLan(QString); protected: - void mouseReleaseEvent(QMouseEvent *event); + void mousePressEvent(QMouseEvent *event); private slots: void on_btnConf_clicked(); diff --git a/res/button-closed.png b/res/button-closed.png deleted file mode 100644 index f3a3e4ed..00000000 Binary files a/res/button-closed.png and /dev/null differ diff --git a/res/wifi.png b/res/wifi.png deleted file mode 100644 index f11308f6..00000000 Binary files a/res/wifi.png and /dev/null differ diff --git a/translations/kylin-nm_bo.qm b/translations/kylin-nm_bo.qm new file mode 100644 index 00000000..be651eed --- /dev/null +++ b/translations/kylin-nm_bo.qm @@ -0,0 +1 @@ + - + + + BackThread + + + Confirm your Wi-Fi password + + + ConfForm @@ -72,72 +80,72 @@ DlgConnHidWifi - + Connect to Hidden Wi-Fi Network - + Add hidden Wi-Fi - + Connection - + Network name - + Wi-Fi security - + Cancel - + Connect - - C_reate… + + C_reate… - + None - + WPA & WPA2 Personal - + WEP 40/128-bit Key (Hex or ASCII) - + WEP 128-bit Passphrase - + Dynamic WEP (802.1X) - + WPA & WPA2 Enterprise @@ -145,82 +153,82 @@ DlgConnHidWifiLeap - + Connect to Hidden Wi-Fi Network - + Add hidden Wi-Fi - + Connection - + Network name - + Wi-Fi security - + Username - + Password - + Cancel - + Connect - - C_reate… + + C_reate… - + None - + WPA & WPA2 Personal - + WEP 40/128-bit Key (Hex or ASCII) - + WEP 128-bit Passphrase - + Dynamic WEP (802.1X) - + WPA & WPA2 Enterprise @@ -228,133 +236,133 @@ DlgConnHidWifiSecFast - + Connect to Hidden Wi-Fi Network - + Add hidden Wi-Fi - + Connection - + Network name - + Wi-Fi security - + Authentication - + Anonymous identity - + Allow automatic PAC pro_visioning - + PAC file - + Inner authentication - + Username - + Password - + Cancel - + Connect - - C_reate… + + C_reate… - - + + None - + WPA & WPA2 Personal - + WEP 40/128-bit Key (Hex or ASCII) - + WEP 128-bit Passphrase - + Dynamic WEP (802.1X) - + WPA & WPA2 Enterprise - + Tunneled TLS - + Protected EAP (PEAP) - + Anonymous - + Authenticated - + Both @@ -362,97 +370,97 @@ DlgConnHidWifiSecLeap - + Connect to Hidden Wi-Fi Network - + Add hidden Wi-Fi - + Connection - + Network name - + Wi-Fi security - + Authentication - + Username - + Password - + Cancel - + Connect - - C_reate… + + C_reate… - + None - + WPA & WPA2 Personal - + WEP 40/128-bit Key (Hex or ASCII) - + WEP 128-bit Passphrase - + Dynamic WEP (802.1X) - + WPA & WPA2 Enterprise - + Tunneled TLS - + Protected EAP (PEAP) @@ -460,148 +468,148 @@ DlgConnHidWifiSecPeap - + Connect to Hidden Wi-Fi Network - + Add hidden Wi-Fi - + Connection - + Network name - + Wi-Fi security - + Authentication - + Anonymous identity - + Domain - + CA certificate - + CA certificate password - + No CA certificate is required - + PEAP version - + Inner authentication - + Username - + Password - + Cancel - + Connect - - + + None - + WPA & WPA2 Personal - + WEP 40/128-bit Key (Hex or ASCII) - + WEP 128-bit Passphrase - + Dynamic WEP (802.1X) - + WPA & WPA2 Enterprise - + Tunneled TLS - + Protected EAP (PEAP) - + Choose from file - + Automatic - + Version 0 - + Version 1 @@ -609,97 +617,97 @@ DlgConnHidWifiSecPwd - + Connect to Hidden Wi-Fi Network - + Add hidden Wi-Fi - + Connection - + Network name - + Wi-Fi security - + Authentication - + Username - + Password - + Cancel - + Connect - - C_reate… + + C_reate… - + None - + WPA & WPA2 Personal - + WEP 40/128-bit Key (Hex or ASCII) - + WEP 128-bit Passphrase - + Dynamic WEP (802.1X) - + WPA & WPA2 Enterprise - + Tunneled TLS - + Protected EAP (PEAP) @@ -707,142 +715,142 @@ DlgConnHidWifiSecTls - + Connect to Hidden Wi-Fi Network - + Add hidden Wi-Fi - + Connection - + Network name - + Wi-Fi security - + Authentication - + Identity - + Domain - + CA certificate - + CA certificate password - + No CA certificate is required - + User certificate - + User certificate password - + User private key - + User key password - + Cancel - + Connect - - C_reate… + + C_reate… - - - - + + + + None - + WPA & WPA2 Personal - + WEP 40/128-bit Key (Hex or ASCII) - + WEP 128-bit Passphrase - + Dynamic WEP (802.1X) - + WPA & WPA2 Enterprise - + Tunneled TLS - + Protected EAP (PEAP) - - - + + + Choose from file @@ -850,133 +858,133 @@ DlgConnHidWifiSecTunnelTLS - + Connect to Hidden Wi-Fi Network - + Add hidden Wi-Fi - + Connection - + Network name - + Wi-Fi security - + Authentication - + Anonymous identity - + Domain - + CA certificate - + CA certificate password - + No CA certificate is required - + Inner authentication - + Username - + Password - + Cancel - + Connect - - C_reate… + + C_reate… - - + + None - + WPA & WPA2 Personal - + WEP 40/128-bit Key (Hex or ASCII) - + WEP 128-bit Passphrase - + Dynamic WEP (802.1X) - + WPA & WPA2 Enterprise - + Tunneled TLS - + Protected EAP (PEAP) - + Choose from file @@ -984,102 +992,102 @@ DlgConnHidWifiWep - + Connect to Hidden Wi-Fi Network - + Add hidden Wi-Fi - + Connection - + Network name - + Wi-Fi security - + Key - + WEP index - + Authentication - + Cancel - + Connect - - C_reate… + + C_reate… - + None - + WPA & WPA2 Personal - + WEP 40/128-bit Key (Hex or ASCII) - + WEP 128-bit Passphrase - + Dynamic WEP (802.1X) - + WPA & WPA2 Enterprise - + 1(default) - + Open System - + Shared Key @@ -1087,77 +1095,77 @@ DlgConnHidWifiWpa - + Connect to Hidden Wi-Fi Network - + Add hidden Wi-Fi - + Connection - + Network name - + Wi-Fi security - + Password - + Cancel - + Connect - - C_reate… + + C_reate… - + None - + WPA & WPA2 Personal - + WEP 40/128-bit Key (Hex or ASCII) - + WEP 128-bit Passphrase - + Dynamic WEP (802.1X) - + WPA & WPA2 Enterprise @@ -1166,115 +1174,115 @@ MainWindow - + kylin-nm - + Network - + Advanced - + Ethernet - + Wifi - - - - - - + + + + + + Enabled - - - - - - - - + + + + + + + + Disabled - - - - - - - + + + + + + + Not connected - - - - - - - + + + + + + + Disconnected - - - + + + Ethernet Networks - - + + Connected - - + + Wifi Networks - + keep wired network switch is on before turning on wireless switch - + please insert the wireless network adapter - + Conn Ethernet Success - + Conn Ethernet Fail - + Conn Wifi Success @@ -1309,27 +1317,27 @@ - + Connect to Hidden Wi-Fi Network - + Public - + Safe - + Rate - + Conn Wifi Failed @@ -1342,17 +1350,17 @@ - + Config - + Connect - + Disconnect diff --git a/translations/kylin-nm_zh_CN.qm b/translations/kylin-nm_zh_CN.qm new file mode 100644 index 00000000..6df74843 Binary files /dev/null and b/translations/kylin-nm_zh_CN.qm differ diff --git a/translations/kylin-nm_zh_CN.ts b/translations/kylin-nm_zh_CN.ts index 0d1845db..f0a054e6 100644 --- a/translations/kylin-nm_zh_CN.ts +++ b/translations/kylin-nm_zh_CN.ts @@ -1,6 +1,14 @@ - + + + BackThread + + + Confirm your Wi-Fi password + 请再次确认Wi-Fi密码 + + ConfForm @@ -72,76 +80,72 @@ DlgConnHidWifi - + Add hidden Wi-Fi 加入隐藏Wi-Fi - + Connection 连接设置: - + Network name 网络名称: - + Wi-Fi security Wi-Fi 安全性: - + Cancel 取消 - + Connect 连接 - - C_reate… - - - + C_reate… - 新建... + 新建... - + None - + WPA & WPA2 Personal WPA 及 WPA2 个人 - + WEP 40/128-bit Key (Hex or ASCII) WEP 40/128 位密钥(十六进制或ASCII) - + WEP 128-bit Passphrase WEP 128 位密码句 - + Dynamic WEP (802.1X) 动态 WEP (802.1x) - + WPA & WPA2 Enterprise WPA 及 WPA2 企业 - + Connect to Hidden Wi-Fi Network 连接到隐藏 Wi-Fi 网络 @@ -149,86 +153,82 @@ DlgConnHidWifiLeap - + Connect to Hidden Wi-Fi Network 连接到隐藏 Wi-Fi 网络 - + Add hidden Wi-Fi 加入隐藏Wi-Fi - + Connection 连接设置: - + Network name 网络名称: - + Wi-Fi security Wi-Fi 安全性: - + Username 用户名: - + Password 密码: - + Cancel 取消 - + Connect 连接 - - C_reate… - - - + C_reate… - 新建... + 新建... - + None - + WPA & WPA2 Personal WPA 及 WPA2 个人 - + WEP 40/128-bit Key (Hex or ASCII) WEP 40/128 位密钥(十六进制或ASCII) - + WEP 128-bit Passphrase WEP 128 位密码句 - + Dynamic WEP (802.1X) 动态 WEP (802.1x) - + WPA & WPA2 Enterprise WPA 及 WPA2 企业 @@ -236,137 +236,133 @@ DlgConnHidWifiSecFast - + Connect to Hidden Wi-Fi Network 连接到隐藏 Wi-Fi 网络 - + Add hidden Wi-Fi 加入隐藏Wi-Fi - + Connection 连接设置: - + Network name 网络名称: - + Wi-Fi security Wi-Fi 安全性: - + Authentication 认证: - + Anonymous identity 匿名身份: - + Allow automatic PAC pro_visioning 自动PAC配置: - + PAC file PAC文件: - + Inner authentication 内部认证: - + Username 用户名: - + Password 密码: - + Cancel 取消 - + Connect 连接 - - C_reate… - - - + C_reate… - 新建... + 新建... - - + + None - + WPA & WPA2 Personal WPA 及 WPA2 个人 - + WEP 40/128-bit Key (Hex or ASCII) WEP 40/128 位密钥(十六进制或ASCII) - + WEP 128-bit Passphrase WEP 128 位密码句 - + Dynamic WEP (802.1X) 动态 WEP (802.1x) - + WPA & WPA2 Enterprise WPA 及 WPA2 企业 - + Tunneled TLS 隧道 TLS - + Protected EAP (PEAP) 受保护的 EAP - + Anonymous 匿名 - + Authenticated 已认证 - + Both 两者兼用 @@ -374,101 +370,97 @@ DlgConnHidWifiSecLeap - + Connect to Hidden Wi-Fi Network 连接到隐藏 Wi-Fi 网络 - + Add hidden Wi-Fi 加入隐藏Wi-Fi - + Connection 连接设置: - + Network name 网络名称: - + Wi-Fi security Wi-Fi 安全性: - + Authentication 认证: - + Username 用户名: - + Password 密码: - + Cancel 取消 - + Connect 连接 - - C_reate… - - - + C_reate… - 新建... + 新建... - + None - + WPA & WPA2 Personal WPA 及 WPA2 个人 - + WEP 40/128-bit Key (Hex or ASCII) WEP 40/128 位密钥(十六进制或ASCII) - + WEP 128-bit Passphrase WEP 128 位密码句 - + Dynamic WEP (802.1X) 动态 WEP (802.1x) - + WPA & WPA2 Enterprise WPA 及 WPA2 企业 - + Tunneled TLS 隧道 TLS - + Protected EAP (PEAP) 受保护的 EAP @@ -476,148 +468,148 @@ DlgConnHidWifiSecPeap - + Connect to Hidden Wi-Fi Network 连接到隐藏 Wi-Fi 网络 - + Add hidden Wi-Fi 加入隐藏Wi-Fi - + Connection 连接设置: - + Network name 网络名称: - + Wi-Fi security Wi-Fi 安全性: - + Authentication 认证: - + Anonymous identity 匿名身份: - + Domain 域名: - + CA certificate CA 证书: - + CA certificate password CA 证书密码: - + No CA certificate is required 不需要CA证书 - + PEAP version PEAP版本: - + Inner authentication 内部认证: - + Username 用户名: - + Password 密码: - + Cancel 取消 - + Connect 连接 - - + + None - + WPA & WPA2 Personal WPA 及 WPA2 个人 - + WEP 40/128-bit Key (Hex or ASCII) WEP 40/128 位密钥(十六进制或ASCII) - + WEP 128-bit Passphrase WEP 128 位密码句 - + Dynamic WEP (802.1X) 动态 WEP (802.1x) - + WPA & WPA2 Enterprise WPA 及 WPA2 企业 - + Tunneled TLS 隧道 TLS - + Protected EAP (PEAP) 受保护的 EAP - + Choose from file 从文件选择... - + Automatic 自动 - + Version 0 版本 0 - + Version 1 版本 1 @@ -625,101 +617,97 @@ DlgConnHidWifiSecPwd - + Connect to Hidden Wi-Fi Network 连接到隐藏 Wi-Fi 网络 - + Add hidden Wi-Fi 加入隐藏Wi-Fi - + Connection 连接设置: - + Network name 网络名称: - + Wi-Fi security Wi-Fi 安全性: - + Authentication 认证: - + Username 用户名: - + Password 密码: - + Cancel 取消 - + Connect 连接 - - C_reate… - - - + C_reate… - 新建... + 新建... - + None - + WPA & WPA2 Personal WPA 及 WPA2 个人 - + WEP 40/128-bit Key (Hex or ASCII) WEP 40/128 位密钥(十六进制或ASCII) - + WEP 128-bit Passphrase WEP 128 位密码句 - + Dynamic WEP (802.1X) 动态 WEP (802.1x) - + WPA & WPA2 Enterprise WPA 及 WPA2 企业 - + Tunneled TLS 隧道 TLS - + Protected EAP (PEAP) 受保护的 EAP @@ -727,146 +715,142 @@ DlgConnHidWifiSecTls - + Connect to Hidden Wi-Fi Network 连接到隐藏 Wi-Fi 网络 - + Add hidden Wi-Fi 加入隐藏Wi-Fi - + Connection 连接设置: - + Network name 网络名称: - + Wi-Fi security Wi-Fi 安全性: - + Authentication 认证: - + Identity 身份: - + Domain 域名: - + CA certificate CA 证书: - + CA certificate password CA 证书密码: - + No CA certificate is required 不需要CA证书 - + User certificate 用户证书: - + User certificate password 用户证书密码: - + User private key 用户私钥: - + User key password 用户密钥密码: - + Cancel 取消 - + Connect 连接 - - C_reate… - - - + C_reate… - 新建... + 新建... - - - - + + + + None - + WPA & WPA2 Personal WPA 及 WPA2 个人 - + WEP 40/128-bit Key (Hex or ASCII) WEP 40/128 位密钥(十六进制或ASCII) - + WEP 128-bit Passphrase WEP 128 位密码句 - + Dynamic WEP (802.1X) 动态 WEP (802.1x) - + WPA & WPA2 Enterprise WPA 及 WPA2 企业 - + Tunneled TLS 隧道 TLS - + Protected EAP (PEAP) 受保护的 EAP - - - + + + Choose from file 从文件选择... @@ -874,137 +858,133 @@ DlgConnHidWifiSecTunnelTLS - + Connect to Hidden Wi-Fi Network 连接到隐藏 Wi-Fi 网络 - + Add hidden Wi-Fi 加入隐藏Wi-Fi - + Connection 连接设置: - + Network name 网络名称: - + Wi-Fi security Wi-Fi 安全性: - + Authentication 认证: - + Anonymous identity 匿名身份: - + Domain 域名: - + CA certificate CA 证书: - + CA certificate password CA 证书密码: - + No CA certificate is required 不需要CA证书 - + Inner authentication 内部认证: - + Username 用户名: - + Password 密码: - + Cancel 取消 - + Connect 连接 - - C_reate… - - - + C_reate… - 新建... + 新建... - - + + None - + WPA & WPA2 Personal WPA 及 WPA2 个人 - + WEP 40/128-bit Key (Hex or ASCII) WEP 40/128 位密钥(十六进制或ASCII) - + WEP 128-bit Passphrase WEP 128 位密码句 - + Dynamic WEP (802.1X) 动态 WEP (802.1x) - + WPA & WPA2 Enterprise WPA 及 WPA2 企业 - + Tunneled TLS 隧道 TLS - + Protected EAP (PEAP) 受保护的 EAP - + Choose from file 从文件选择... @@ -1012,106 +992,102 @@ DlgConnHidWifiWep - + Connect to Hidden Wi-Fi Network 连接到隐藏 Wi-Fi 网络 - + Add hidden Wi-Fi 加入隐藏Wi-Fi - + Connection 连接设置: - + Network name 网络名称: - + Wi-Fi security Wi-Fi 安全性: - + Key 密钥 - + WEP index WEP 检索 - + Authentication 认证: - + Cancel 取消 - + Connect 连接 - - C_reate… - - - + C_reate… - 新建... + 新建... - + None - + WPA & WPA2 Personal WPA 及 WPA2 个人 - + WEP 40/128-bit Key (Hex or ASCII) WEP 40/128 位密钥(十六进制或ASCII) - + WEP 128-bit Passphrase WEP 128 位密码句 - + Dynamic WEP (802.1X) 动态 WEP (802.1x) - + WPA & WPA2 Enterprise WPA 及 WPA2 企业 - + 1(default) 1(默认) - + Open System 开放式系统 - + Shared Key 共享密钥 @@ -1119,81 +1095,77 @@ DlgConnHidWifiWpa - + Connect to Hidden Wi-Fi Network 连接到隐藏 Wi-Fi 网络 - + Add hidden Wi-Fi 加入隐藏Wi-Fi - + Connection 连接设置: - + Network name 网络名称: - + Wi-Fi security Wi-Fi 安全性: - + Password 密码: - + Cancel 取消 - + Connect 连接 - - C_reate… - - - + C_reate… - 新建... + 新建... - + None - + WPA & WPA2 Personal WPA 及 WPA2 个人 - + WEP 40/128-bit Key (Hex or ASCII) WEP 40/128 位密钥(十六进制或ASCII) - + WEP 128-bit Passphrase WEP 128 位密码句 - + Dynamic WEP (802.1X) 动态 WEP (802.1x) - + WPA & WPA2 Enterprise WPA 及 WPA2 企业 @@ -1202,115 +1174,123 @@ MainWindow - + kylin-nm 网络工具 - + Network 网络 - + Advanced 高级设置 - + Ethernet 有线网络 - + Wifi 无线网络 - - - - - - + + + + + + Enabled 已开启 - - - - - - - - + + + + + + + + Disabled 已关闭 - - - - - - - + + + + + + + Not connected 当前未连接任何网络 - - - - - - - + + + + + + + Disconnected 未连接 - - - + + + Ethernet Networks 可用网络列表 - - + + Connected 已连接 - - + + Wifi Networks 可用网络列表 - + keep wired network switch is on before turning on wireless switch 打开无线网开关前保持有线网开关打开 - + please insert the wireless network adapter 请先插入无线网卡 - + update Wi-Fi list now, click again + 正在更新 Wi-Fi列表 请再次点击 + + + update Wi-Fi list now + 正在更新 Wi-Fi列表 + + + Conn Ethernet Success 连接有线网络成功 - + Conn Ethernet Fail 连接有线网络失败 - + Conn Wifi Success 连接无线网络成功 @@ -1345,27 +1325,27 @@ 断开连接 - + Connect to Hidden Wi-Fi Network 连接到隐藏 Wi-Fi 网络 - + Public 开放 - + Safe 安全 - + Rate 速率 - + Conn Wifi Failed 连接无线网络失败 @@ -1378,17 +1358,17 @@ -- - + Config 设置 - + Connect 连接 - + Disconnect 断开连接 diff --git a/wifidetector.h b/wifidetector.h new file mode 100644 index 00000000..c7a79d60 --- /dev/null +++ b/wifidetector.h @@ -0,0 +1,6 @@ +#ifndef WIFIDETECTOR_H +#define WIFIDETECTOR_H + +#include + +#endif // WIFIDETECTOR_H diff --git a/dlgconnhidwifi.cpp b/wireless-security/dlgconnhidwifi.cpp similarity index 92% rename from dlgconnhidwifi.cpp rename to wireless-security/dlgconnhidwifi.cpp index ab3e7d45..13863735 100644 --- a/dlgconnhidwifi.cpp +++ b/wireless-security/dlgconnhidwifi.cpp @@ -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 cbxSecurity->currentIndex()==0){ @@ -152,6 +172,7 @@ void DlgConnHidWifi::changeDialog() } } +//同一 Wi-Fi安全类型的窗口变换 void DlgConnHidWifi::changeWindow(){ if (ui->cbxConn->currentIndex() == 0){ isUsed = ui->cbxConn->currentIndex(); diff --git a/dlgconnhidwifi.h b/wireless-security/dlgconnhidwifi.h similarity index 100% rename from dlgconnhidwifi.h rename to wireless-security/dlgconnhidwifi.h diff --git a/dlgconnhidwifi.ui b/wireless-security/dlgconnhidwifi.ui similarity index 100% rename from dlgconnhidwifi.ui rename to wireless-security/dlgconnhidwifi.ui diff --git a/dlgconnhidwifileap.cpp b/wireless-security/dlgconnhidwifileap.cpp similarity index 90% rename from dlgconnhidwifileap.cpp rename to wireless-security/dlgconnhidwifileap.cpp index 82fead06..294eb6b2 100644 --- a/dlgconnhidwifileap.cpp +++ b/wireless-security/dlgconnhidwifileap.cpp @@ -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 cbxSecurity->currentIndex()==0){ diff --git a/dlgconnhidwifileap.h b/wireless-security/dlgconnhidwifileap.h similarity index 100% rename from dlgconnhidwifileap.h rename to wireless-security/dlgconnhidwifileap.h diff --git a/dlgconnhidwifileap.ui b/wireless-security/dlgconnhidwifileap.ui similarity index 100% rename from dlgconnhidwifileap.ui rename to wireless-security/dlgconnhidwifileap.ui diff --git a/dlgconnhidwifisecfast.cpp b/wireless-security/dlgconnhidwifisecfast.cpp similarity index 94% rename from dlgconnhidwifisecfast.cpp rename to wireless-security/dlgconnhidwifisecfast.cpp index 21ec1208..dc0a178b 100644 --- a/dlgconnhidwifisecfast.cpp +++ b/wireless-security/dlgconnhidwifisecfast.cpp @@ -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 cbxSecurity->currentIndex()==0){ diff --git a/dlgconnhidwifiwep.h b/wireless-security/dlgconnhidwifiwep.h similarity index 100% rename from dlgconnhidwifiwep.h rename to wireless-security/dlgconnhidwifiwep.h diff --git a/dlgconnhidwifiwep.ui b/wireless-security/dlgconnhidwifiwep.ui similarity index 100% rename from dlgconnhidwifiwep.ui rename to wireless-security/dlgconnhidwifiwep.ui diff --git a/dlgconnhidwifiwpa.cpp b/wireless-security/dlgconnhidwifiwpa.cpp similarity index 93% rename from dlgconnhidwifiwpa.cpp rename to wireless-security/dlgconnhidwifiwpa.cpp index a9541081..e988e2ae 100644 --- a/dlgconnhidwifiwpa.cpp +++ b/wireless-security/dlgconnhidwifiwpa.cpp @@ -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 cbxSecurity->currentIndex()==0){ @@ -152,6 +172,7 @@ void DlgConnHidWifiWpa::changeDialog() } } +//同一 Wi-Fi安全类型的窗口变换 void DlgConnHidWifiWpa::changeWindow(){ if (ui->cbxConn->currentIndex() == 0){ QApplication::setQuitOnLastWindowClosed(false); diff --git a/dlgconnhidwifiwpa.h b/wireless-security/dlgconnhidwifiwpa.h similarity index 100% rename from dlgconnhidwifiwpa.h rename to wireless-security/dlgconnhidwifiwpa.h diff --git a/dlgconnhidwifiwpa.ui b/wireless-security/dlgconnhidwifiwpa.ui similarity index 100% rename from dlgconnhidwifiwpa.ui rename to wireless-security/dlgconnhidwifiwpa.ui diff --git a/kylinheadfile.h b/wireless-security/kylinheadfile.h similarity index 100% rename from kylinheadfile.h rename to wireless-security/kylinheadfile.h