Feat: Add menu for wifi to connect/disconnect/forget wifi.

Optimize log.
This commit is contained in:
zhangjiaping 2021-05-31 17:16:50 +08:00
parent f38a73cb45
commit 23dc7f35bf
29 changed files with 152 additions and 194 deletions

View File

@ -19,8 +19,6 @@
#ifndef DLGHOTSPOTCREATE_H #ifndef DLGHOTSPOTCREATE_H
#define DLGHOTSPOTCREATE_H #define DLGHOTSPOTCREATE_H
#include <sys/syslog.h>
#include <QDialog> #include <QDialog>
#include <QMouseEvent> #include <QMouseEvent>
#include <QDebug> #include <QDebug>

View File

@ -21,7 +21,6 @@
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/syslog.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
@ -57,8 +56,6 @@ IFace* BackThread::execGetIface()
QFile file(tmpPath); QFile file(tmpPath);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
// print information if can not open file ~/.config/kylin-nm-iface
//syslog(LOG_ERR, "Can't open the file ~/.config/kylin-nm-iface!");
qDebug()<<"Can't open the file ~/.config/kylin-nm-iface!"; qDebug()<<"Can't open the file ~/.config/kylin-nm-iface!";
} }
QString txt = file.readAll(); QString txt = file.readAll();
@ -228,7 +225,6 @@ void BackThread::execConnLan(QString connName, QString ifname, QString connectTy
cmdProcessLan->waitForFinished(); cmdProcessLan->waitForFinished();
} else { } else {
qDebug()<<"connect wired network failed for without wired cable plug in."; qDebug()<<"connect wired network failed for without wired cable plug in.";
//syslog(LOG_DEBUG, "connect wired network failed for without wired cable plug in.");
emit connDone(1); emit connDone(1);
} }
@ -254,7 +250,6 @@ void BackThread::dellConnectLanResult(QString info)
{ {
if (info.indexOf("successfully") != -1) { if (info.indexOf("successfully") != -1) {
qDebug()<<"debug: in function execConnLan, wired net state is: "<<QString::number(execGetIface()->lstate); qDebug()<<"debug: in function execConnLan, wired net state is: "<<QString::number(execGetIface()->lstate);
//syslog(LOG_DEBUG, "In function execConnLan, wired net state is: %d", execGetIface()->lstate);
if (currConnLanType == "bluetooth") { if (currConnLanType == "bluetooth") {
emit connDone(2); emit connDone(2);
@ -307,7 +302,6 @@ void BackThread::execConnWifiPWD(QString connName, QString password, QString con
QFile file(tmpPath); QFile file(tmpPath);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
//syslog(LOG_DEBUG, "Can't open the file /tmp/kylin-nm-btoutput !");
qDebug()<<"Can't open the file /tmp/kylin-nm-btoutput !"<<endl; qDebug()<<"Can't open the file /tmp/kylin-nm-btoutput !"<<endl;
} }
QString line = file.readLine(); QString line = file.readLine();
@ -317,7 +311,6 @@ void BackThread::execConnWifiPWD(QString connName, QString password, QString con
if (line.indexOf("successfully") != -1) { if (line.indexOf("successfully") != -1) {
emit connDone(0); emit connDone(0);
qDebug()<<"debug: in function execConnWifiPWD, wireless net state is: "<<QString::number(execGetIface()->wstate); qDebug()<<"debug: in function execConnWifiPWD, wireless net state is: "<<QString::number(execGetIface()->wstate);
//syslog(LOG_DEBUG, "In function execConnWifiPWD, wireless net state is: %d", execGetIface()->wstate);
} else if(line.indexOf("Secrets were required") != -1){ } else if(line.indexOf("Secrets were required") != -1){
//emit connDone(4);//发出信号4是之前添加每次连接输入密码的功能时需要的 //emit connDone(4);//发出信号4是之前添加每次连接输入密码的功能时需要的
emit connDone(1); emit connDone(1);
@ -334,7 +327,7 @@ void BackThread::execConnHiddenWifiWPA(QString wifiName, QString wifiPassword)
do { do {
n += 1; n += 1;
if (n >= 4) { if (n >= 4) {
//syslog(LOG_ERR, "connection attempt of hidden wifi %s failed for 3 times, no more attempt", wifiName); qDebug()<<"connection attempt of hidden wifi"<<wifiName<<" failed for 3 times, no more attempt";
x = 0; x = 0;
emit connDone(1); emit connDone(1);
emit btFinish(); emit btFinish();
@ -344,11 +337,8 @@ void BackThread::execConnHiddenWifiWPA(QString wifiName, QString wifiPassword)
QString tmpPath = "/tmp/kylin-nm-btoutput-" + QDir::home().dirName(); QString tmpPath = "/tmp/kylin-nm-btoutput-" + QDir::home().dirName();
QString cmd = "nmcli device wifi connect '" + wifiName + "' password '" + wifiPassword + "' hidden yes > " + tmpPath + " 2>&1"; QString cmd = "nmcli device wifi connect '" + wifiName + "' password '" + wifiPassword + "' hidden yes > " + tmpPath + " 2>&1";
qDebug() << Q_FUNC_INFO << cmd << tmpPath;
int status = Utils::m_system(cmd.toUtf8().data()); int status = Utils::m_system(cmd.toUtf8().data());
if (status != 0) { qDebug() << Q_FUNC_INFO << cmd << tmpPath << "res=" << status;
//syslog(LOG_ERR, "execute 'nmcli device wifi connect' in function 'on_btnConnect_clicked' failed");
}
QFile file(tmpPath); QFile file(tmpPath);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
@ -365,7 +355,6 @@ void BackThread::execConnHiddenWifiWPA(QString wifiName, QString wifiPassword)
emit connDone(6); emit connDone(6);
x = 0; x = 0;
} }
// qDebug() << Q_FUNC_INFO << x << text;
} while (x == 1); } while (x == 1);
emit btFinish(); emit btFinish();
@ -396,7 +385,7 @@ void BackThread::execConnRememberedHiddenWifi(QString wifiName)
} }
} else { } else {
//已保存的wifi没有在wifi列表找到隐藏wifi保存后也会出现在wifi列表则当前区域无法连接此wifi //已保存的wifi没有在wifi列表找到隐藏wifi保存后也会出现在wifi列表则当前区域无法连接此wifi
//syslog(LOG_DEBUG, "Choosen wifi can not be sacnned in finishedProcess() in dlghidewifiwpa.cpp 377."); qDebug() << "Choosen wifi can not be sacnned, wifiName=" << wifiName;
emit connDone(5); emit connDone(5);
} }
} }
@ -411,22 +400,19 @@ void BackThread::execConnWifiPsk(QString cmd)
//to connected wireless network driectly do not need a password //to connected wireless network driectly do not need a password
void BackThread::execConnWifi(QString connName, QString connIfName) void BackThread::execConnWifi(QString connName, QString connIfName)
{ {
qDebug() << "Will to connect wifi " << connName << " with wifi card named " <<connIfName; qDebug() << "Will to connect wifi " << connName << " with wifi card named " << connIfName;
//syslog(LOG_DEBUG, "Will to connect wifi %s with wifi card named %s", connName.toUtf8().data(), connIfName.toUtf8().data());
QString cmdStr; QString cmdStr;
KylinDBus objBackThreadDBus; KylinDBus objBackThreadDBus;
QString wifiUuid = objBackThreadDBus.checkHasWifiConfigFile(connName); QString wifiUuid = objBackThreadDBus.checkHasWifiConfigFile(connName);
if (!wifiUuid.isEmpty()) { if (!wifiUuid.isEmpty()) {
//有配置文件 //有配置文件
//qDebug() << "-------------------------> wifiUuid = " << wifiUuid;
cmdStr = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up '" + wifiUuid + "'\n"; cmdStr = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up '" + wifiUuid + "'\n";
} else { } else {
//没有配置文件 //没有配置文件
//qDebug() << "-------------------------> connName = " << connName;
cmdStr = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up '" + connName + "' ifname '" + connIfName + "'\n"; cmdStr = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up '" + connName + "' ifname '" + connIfName + "'\n";
} }
qDebug()<<"Trying to connect wifi. ssid="<<connName; qDebug() << "Trying to connect wifi. cmd=" << cmdStr;
QStringList options; QStringList options;
options << "-c" << cmdStr; options << "-c" << cmdStr;
@ -448,14 +434,12 @@ void BackThread::onReadOutputWifi()
{ {
QString str = cmdProcessWifi->readAllStandardOutput(); QString str = cmdProcessWifi->readAllStandardOutput();
qDebug()<<"on_readoutput_wifi: "<< str; qDebug()<<"on_readoutput_wifi: "<< str;
//syslog(LOG_DEBUG, "on_readoutput_wifi : %s", str.toUtf8().data());
dellConnectWifiResult(str); dellConnectWifiResult(str);
} }
void BackThread::onReadErrorWifi() void BackThread::onReadErrorWifi()
{ {
QString str = cmdProcessWifi->readAllStandardError(); QString str = cmdProcessWifi->readAllStandardError();
qDebug()<<"on_readerror_wifi: "<< str; qDebug()<<"on_readerror_wifi: "<< str;
//syslog(LOG_DEBUG, "on_readerror_wifi : %s", str.toUtf8().data());
dellConnectWifiResult(str); dellConnectWifiResult(str);
} }
@ -491,8 +475,7 @@ QString BackThread::getConnProp(QString connName)
QFile file(tmpPath); QFile file(tmpPath);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
//syslog(LOG_ERR, "Can't open the file /tmp/kylin-nm-connprop!"); qDebug() << "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();
@ -565,12 +548,12 @@ QString BackThread::execChkLanWidth(QString ethName)
{ {
QString tmpPath = "/tmp/kylin-nm-bandwidth-" + QDir::home().dirName(); QString tmpPath = "/tmp/kylin-nm-bandwidth-" + QDir::home().dirName();
QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';ethtool '" + ethName + "' | grep Speed > " + tmpPath; QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';ethtool '" + ethName + "' | grep Speed > " + tmpPath;
Utils::m_system(cmd.toUtf8().data()); int res = Utils::m_system(cmd.toUtf8().data());
qDebug() << "executed cmd=" << cmd << ".res="<<res;
QFile file(tmpPath); QFile file(tmpPath);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
//syslog(LOG_ERR, "Can't open the file /tmp/kylin-nm-bandwidth!"); qDebug() << "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();
@ -606,8 +589,7 @@ void BackThread::disConnLanOrWifi(QString type)
p_file = popen("nmcli connection show -active", "r"); p_file = popen("nmcli connection show -active", "r");
if (!p_file) { if (!p_file) {
//syslog(LOG_ERR, "Error occurred when popen cmd 'nmcli connection show'"); qDebug() << "Error occurred when popen cmd 'nmcli connection show";
qDebug()<<"Error occurred when popen cmd 'nmcli connection show";
} }
while (fgets(buf, BUF_SIZE, p_file) != NULL) { while (fgets(buf, BUF_SIZE, p_file) != NULL) {

View File

@ -360,11 +360,7 @@ void ConfForm::on_btnSave_clicked()
// QString cmd = "nmcli connection delete '" + netUuid + "'"; // QString cmd = "nmcli connection delete '" + netUuid + "'";
QString cmd = "nmcli connection modify '" + lastConnName + "' con-name '"+name+"'"; QString cmd = "nmcli connection modify '" + lastConnName + "' con-name '"+name+"'";
int status = system(cmd.toUtf8().data()); int status = system(cmd.toUtf8().data());
if (status != 0) { qDebug()<<"executed 'nmcli connection modify'. cmd="<<cmd<<". res="<<status;
//syslog(LOG_ERR, "execute 'nmcli connection modify' in function 'on_btnSave_clicked' failed");
} else {
//syslog(LOG_ERR, "execute 'nmcli connection modify' in function 'on_btnSave_clicked' success");
}
// this->isCreateNewNet = true; // this->isCreateNewNet = true;
// newUuid = "--"; // newUuid = "--";

View File

@ -50,7 +50,6 @@ KSimpleNM::~KSimpleNM()
void KSimpleNM::execGetLanList() void KSimpleNM::execGetLanList()
{ {
if (isExecutingGetLanList) { if (isExecutingGetLanList) {
//syslog(LOG_DEBUG, "It is running getting lan list when getting lan list");
qDebug()<<"debug: it is running getting lan list when getting lan list"; qDebug()<<"debug: it is running getting lan list when getting lan list";
isUseOldLanSlist = true; isUseOldLanSlist = true;
QStringList slistmEmpty; QStringList slistmEmpty;
@ -73,7 +72,6 @@ void KSimpleNM::execGetLanList()
void KSimpleNM::execGetWifiList(const QString& wname, const bool &isHuaweiPc) void KSimpleNM::execGetWifiList(const QString& wname, const bool &isHuaweiPc)
{ {
if (isExecutingGetWifiList) { if (isExecutingGetWifiList) {
//syslog(LOG_DEBUG, "It is running getting wifi list when getting wifi list");
qDebug()<<"debug: it is running getting wifi list when getting wifi list"; qDebug()<<"debug: it is running getting wifi list when getting wifi list";
isUseOldWifiSlist = true; isUseOldWifiSlist = true;
QStringList slistmEmpty; QStringList slistmEmpty;

View File

@ -19,8 +19,6 @@
#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>

View File

@ -95,14 +95,12 @@ KylinDBus::KylinDBus(MainWindow *mainWindow, QObject *parent) :QObject(parent)
QString("PropertiesChanged"), this, SLOT(onLanPropertyChanged(QVariantMap) ) ); QString("PropertiesChanged"), this, SLOT(onLanPropertyChanged(QVariantMap) ) );
} }
} else { } else {
//syslog(LOG_DEBUG, "Can not find wired device object path when using dbus.");
qDebug()<<"Can not find wired device object path when using dbus."; qDebug()<<"Can not find wired device object path when using dbus.";
} }
if (!multiWirelessPaths.isEmpty()) { if (!multiWirelessPaths.isEmpty()) {
getWirelessCardName();//获取无线网卡名称 getWirelessCardName();//获取无线网卡名称
} else { } else {
//syslog(LOG_DEBUG, "Can not find wireless device object path when using dbus.");
qDebug()<<"Can not find wireless device object path when using dbus."; qDebug()<<"Can not find wireless device object path when using dbus.";
} }
@ -154,7 +152,6 @@ void KylinDBus::getObjectPath()
//先获取所有的网络设备的设备路径 //先获取所有的网络设备的设备路径
QDBusReply<QList<QDBusObjectPath>> obj_reply = m_interface.call("GetAllDevices"); QDBusReply<QList<QDBusObjectPath>> obj_reply = m_interface.call("GetAllDevices");
if (!obj_reply.isValid()) { if (!obj_reply.isValid()) {
//syslog(LOG_DEBUG, "execute dbus method 'GetAllDevices' is invalid in func getObjectPath()");
qDebug()<<"execute dbus method 'GetAllDevices' is invalid in func getObjectPath()"; qDebug()<<"execute dbus method 'GetAllDevices' is invalid in func getObjectPath()";
} }
@ -169,7 +166,6 @@ void KylinDBus::getObjectPath()
QDBusReply<QString> reply = interface.call("Introspect"); QDBusReply<QString> reply = interface.call("Introspect");
if (!reply.isValid()) { if (!reply.isValid()) {
//syslog(LOG_DEBUG, "execute dbus method 'Introspect' is invalid in func getObjectPath()");
qDebug()<<"execute dbus method 'Introspect' is invalid in func getObjectPath()"; qDebug()<<"execute dbus method 'Introspect' is invalid in func getObjectPath()";
} }
@ -210,7 +206,6 @@ void KylinDBus::getPhysicalCarrierState(int n)
throw -1; //出现异常 throw -1; //出现异常
} }
} catch(...) { } catch(...) {
//syslog(LOG_ERR, "Error occurred when get the property 'Carrier' of Wired");
qDebug()<<"Error occurred when get the property 'Carrier' of Wired"; qDebug()<<"Error occurred when get the property 'Carrier' of Wired";
} }
} }
@ -240,7 +235,6 @@ void KylinDBus::getLanHwAddressState()
QDBusReply<QVariant> lanReply = lanInterface.call("Get", "org.freedesktop.NetworkManager.Device.Wired", "HwAddress"); QDBusReply<QVariant> lanReply = lanInterface.call("Get", "org.freedesktop.NetworkManager.Device.Wired", "HwAddress");
if (!lanReply.isValid()) { if (!lanReply.isValid()) {
//syslog(LOG_DEBUG, "can not get the attribute 'HwAddress' in func getLanHwAddressState()");
qDebug()<<"can not get the attribute 'HwAddress' in func getLanHwAddressState()"; qDebug()<<"can not get the attribute 'HwAddress' in func getLanHwAddressState()";
} else { } else {
QString dbusLanMac = lanReply.value().toString(); QString dbusLanMac = lanReply.value().toString();
@ -270,7 +264,6 @@ void KylinDBus::getWiredCardName()
QDBusReply<QVariant> lanReply = lanInterface.call("Get", "org.freedesktop.NetworkManager.Device", "Interface"); QDBusReply<QVariant> lanReply = lanInterface.call("Get", "org.freedesktop.NetworkManager.Device", "Interface");
if (!lanReply.isValid()) { if (!lanReply.isValid()) {
//syslog(LOG_DEBUG, "can not get the attribute 'Interface' in func getWiredCardName()");
qDebug()<<"can not get the attribute 'Interface' in func getWiredCardName()"; qDebug()<<"can not get the attribute 'Interface' in func getWiredCardName()";
} else { } else {
QString dbusLanCardName = lanReply.value().toString(); QString dbusLanCardName = lanReply.value().toString();
@ -294,7 +287,6 @@ void KylinDBus::getWirelessCardName()
QDBusReply<QVariant> lanReply = lanInterface.call("Get", "org.freedesktop.NetworkManager.Device", "Interface"); QDBusReply<QVariant> lanReply = lanInterface.call("Get", "org.freedesktop.NetworkManager.Device", "Interface");
if (!lanReply.isValid()) { if (!lanReply.isValid()) {
//syslog(LOG_DEBUG, "can not get the attribute 'Interface' in func getWirelessCardName()");
qDebug()<<"can not get the attribute 'Interface' in func getWirelessCardName()"; qDebug()<<"can not get the attribute 'Interface' in func getWirelessCardName()";
} else { } else {
dbusWiFiCardName = lanReply.value().toString(); dbusWiFiCardName = lanReply.value().toString();
@ -1040,11 +1032,9 @@ void KylinDBus::onNewConnection(QDBusObjectPath objPath)
emit this->newConnAdded(0); emit this->newConnAdded(0);
m_lanPathList.append(objPath.path()); m_lanPathList.append(objPath.path());
emit mw->wiredConnectionAdded(); emit mw->wiredConnectionAdded();
//syslog(LOG_DEBUG, "A new wired network was created.");
qDebug()<<"A new wired network was created."; qDebug()<<"A new wired network was created.";
break; break;
} else if (key == "802-11-wireless") { } else if (key == "802-11-wireless") {
//syslog(LOG_DEBUG, "A new wireless network(wifi) was created.");
qDebug()<<"A new wireless network was created."; qDebug()<<"A new wireless network was created.";
sleep(1); sleep(1);
bool has_wpa_psk = false; bool has_wpa_psk = false;
@ -1104,7 +1094,6 @@ void KylinDBus::onNewConnection(QDBusObjectPath objPath)
//减少了一个网络,伴随着减少了一个网络配置文件 //减少了一个网络,伴随着减少了一个网络配置文件
void KylinDBus::onConnectionRemoved(QDBusObjectPath objPath) void KylinDBus::onConnectionRemoved(QDBusObjectPath objPath)
{ {
//syslog(LOG_DEBUG, "An old network was removed from configure directory.");
if (m_lanPathList.contains(objPath.path())) { if (m_lanPathList.contains(objPath.path())) {
m_lanPathList.removeOne(objPath.path()); m_lanPathList.removeOne(objPath.path());
qDebug()<<"An old network was removed from configure directory."; qDebug()<<"An old network was removed from configure directory.";
@ -1718,8 +1707,7 @@ void KylinDBus::onPropertiesChanged(QVariantMap qvm)
//接收到自动连接的信号过后执行自动连接wifi //接收到自动连接的信号过后执行自动连接wifi
void KylinDBus::onAutoConnect() void KylinDBus::onAutoConnect()
{ {
//syslog(LOG_DEBUG, "Receive a auto-connect signal to reconnect wifi"); qDebug() << "Receive a auto-connect signal to reconnect wifi";
qDebug() << Q_FUNC_INFO << "Receive a auto-connect signal to reconnect wifi";
mw->toReconnectWifi(); mw->toReconnectWifi();
} }
@ -1727,7 +1715,6 @@ void KylinDBus::onAutoConnect()
void KylinDBus::onLanPropertyChanged(QVariantMap qvm) void KylinDBus::onLanPropertyChanged(QVariantMap qvm)
{ {
if (!isRunningFunction) { if (!isRunningFunction) {
//syslog(LOG_DEBUG, "kylin-nm receive a signal 'Device.Wired PropertiesChanged' about interface.");
qDebug()<<"kylin-nm receive a signal 'Device.Wired PropertiesChanged' about interface."; qDebug()<<"kylin-nm receive a signal 'Device.Wired PropertiesChanged' about interface.";
isRunningFunction = true; //function onLanPropertyChanged is running isRunningFunction = true; //function onLanPropertyChanged is running
time->start(3000); time->start(3000);
@ -2060,11 +2047,9 @@ void KylinDBus::getWifiSwitchState()
if (judge) { if (judge) {
mw->onBtnWifiClicked(2); //打开wifi开关 mw->onBtnWifiClicked(2); //打开wifi开关
qDebug()<<"receive a signal to turn on wifi switch from control-center"; qDebug()<<"receive a signal to turn on wifi switch from control-center";
//syslog(LOG_DEBUG, "receive a signal to turn on wifi switch from control-center");
} else { } else {
mw->onBtnWifiClicked(3); //关闭wifi开关 mw->onBtnWifiClicked(3); //关闭wifi开关
qDebug()<<"receive a signal to turn off wifi switch from control-center"; qDebug()<<"receive a signal to turn off wifi switch from control-center";
//syslog(LOG_DEBUG, "receive a signal to turn off wifi switch from control-center");
} }
} }
} }

View File

@ -19,8 +19,6 @@
#ifndef KYLINDBUSINTERFACE_H #ifndef KYLINDBUSINTERFACE_H
#define KYLINDBUSINTERFACE_H #define KYLINDBUSINTERFACE_H
#include <sys/syslog.h>
#include <QObject> #include <QObject>
#include <QDebug> #include <QDebug>
#include <QtDBus/QDBusConnection> #include <QtDBus/QDBusConnection>

View File

@ -27,7 +27,6 @@
#include <QDebug> #include <QDebug>
#include <QDesktopWidget> #include <QDesktopWidget>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <syslog.h>
#include <QFile> #include <QFile>
#define LOG_IDENT "ukui_kylin_nm" #define LOG_IDENT "ukui_kylin_nm"
@ -84,15 +83,12 @@ int main(int argc, char *argv[])
QApplication a(argc, argv); QApplication a(argc, argv);
qInstallMessageHandler(messageOutput); qInstallMessageHandler(messageOutput);
openlog(LOG_IDENT, LOG_NDELAY | LOG_NOWAIT | LOG_PID, LOG_USER);
qDebug()<<"Kylin Network Manager Is Already Launched"; qDebug()<<"Kylin Network Manager Is Already Launched";
//syslog(LOG_DEBUG, "Kylin Network Manager Is Already Launched");
int loopNum = 0; int loopNum = 0;
while (!QSystemTrayIcon::isSystemTrayAvailable()) { while (!QSystemTrayIcon::isSystemTrayAvailable()) {
if (loopNum == 15) return 1; if (loopNum == 15) return 1;
qDebug()<<"I couldn't detect any system tray on this system now"; qDebug()<<"I couldn't detect any system tray on this system now";
//syslog(LOG_DEBUG, "I couldn't detect any system tray on this system now");
loopNum += 1; loopNum += 1;
sleep(1); sleep(1);
} }

View File

@ -42,7 +42,6 @@ MainWindow::MainWindow(QWidget *parent) :
{ {
ui->setupUi(this); ui->setupUi(this);
//syslog(LOG_DEBUG, "Using the icon theme named 'ukui-icon-theme-default'");
//QIcon::setThemeName("ukui-icon-theme-default"); //QIcon::setThemeName("ukui-icon-theme-default");
PrimaryManager(); PrimaryManager();
@ -363,7 +362,7 @@ void MainWindow::createLeftAreaUI()
paletteLan.setBrush(QPalette::Button, QBrush(QColor(1,1,1,0))); paletteLan.setBrush(QPalette::Button, QBrush(QColor(1,1,1,0)));
ui->btnNetListImg->setPalette(paletteLan); ui->btnNetListImg->setPalette(paletteLan);
//添加PushButton的svg图片 //添加PushButton的svg图片
ui->btnNetListImg->setIcon(QIcon(":/res/x/net-list-bg.svg")); ui->btnNetListImg->setIcon(QIcon::fromTheme("network-wired-symbolic"));
ui->btnNetListImg->setProperty("useIconHighlightEffect", true); ui->btnNetListImg->setProperty("useIconHighlightEffect", true);
ui->btnNetListImg->setProperty("iconHighlightEffectMode", true); ui->btnNetListImg->setProperty("iconHighlightEffectMode", true);
@ -377,7 +376,7 @@ void MainWindow::createLeftAreaUI()
paletteWifi.setBrush(QPalette::Button, QBrush(QColor(1,1,1,0))); paletteWifi.setBrush(QPalette::Button, QBrush(QColor(1,1,1,0)));
ui->btnWifiListImg->setPalette(paletteWifi); ui->btnWifiListImg->setPalette(paletteWifi);
//添加PushButton的svg图片 //添加PushButton的svg图片
ui->btnWifiListImg->setIcon(QIcon(":/res/x/wifi-list-bg.svg")); ui->btnWifiListImg->setIcon(QIcon::fromTheme("network-wireless-signal-excellent-symbolic"));
ui->btnWifiListImg->setProperty("useIconHighlightEffect", true); ui->btnWifiListImg->setProperty("useIconHighlightEffect", true);
ui->btnWifiListImg->setProperty("iconHighlightEffectMode", true); ui->btnWifiListImg->setProperty("iconHighlightEffectMode", true);
@ -3095,6 +3094,9 @@ void MainWindow::actionTriggerSlots()
//列表中item的扩展与收缩 //列表中item的扩展与收缩
void MainWindow::oneLanFormSelected(QString lanName, QString uniqueName) void MainWindow::oneLanFormSelected(QString lanName, QString uniqueName)
{ {
if (currSelNetName == uniqueName) {
return;
}
QList<OneLancForm *> topLanList = topLanListWidget->findChildren<OneLancForm *>(); QList<OneLancForm *> topLanList = topLanListWidget->findChildren<OneLancForm *>();
QList<OneLancForm *> lanList = lanListWidget->findChildren<OneLancForm *>(); QList<OneLancForm *> lanList = lanListWidget->findChildren<OneLancForm *>();
@ -3114,16 +3116,16 @@ void MainWindow::oneLanFormSelected(QString lanName, QString uniqueName)
//是否与上一次选中同一个网络框 //是否与上一次选中同一个网络框
if (currSelNetName == uniqueName) { if (currSelNetName == uniqueName) {
// 缩小所有选项卡 // 缩小所有选项卡
for (int i = 0;i < lanList.size(); i ++) { // for (int i = 0;i < lanList.size(); i ++) {
OneLancForm *ocf = lanList.at(i); // OneLancForm *ocf = lanList.at(i);
if (ocf->uuidName == uniqueName) { // if (ocf->uuidName == uniqueName) {
ocf->setSelected(false, true); // ocf->setSelected(false, true);
} else { // } else {
ocf->setSelected(false, false); // ocf->setSelected(false, false);
} // }
} // }
currSelNetName = ""; // currSelNetName = "";
} else { } else {
int selectY = 0; int selectY = 0;
for (int i = 0;i < lanList.size(); i ++) { for (int i = 0;i < lanList.size(); i ++) {
@ -3177,6 +3179,8 @@ void MainWindow::oneLanFormSelected(QString lanName, QString uniqueName)
} }
void MainWindow::oneTopLanFormSelected(QString lanName, QString uniqueName) void MainWindow::oneTopLanFormSelected(QString lanName, QString uniqueName)
{ {
//应设计要求,选中同一选项卡不再缩小
if (currSelNetName == uniqueName) return;
QList<OneLancForm *> topLanList = topLanListWidget->findChildren<OneLancForm *>(); QList<OneLancForm *> topLanList = topLanListWidget->findChildren<OneLancForm *>();
QList<OneLancForm *> lanList = lanListWidget->findChildren<OneLancForm *>(); QList<OneLancForm *> lanList = lanListWidget->findChildren<OneLancForm *>();
@ -3188,17 +3192,17 @@ void MainWindow::oneTopLanFormSelected(QString lanName, QString uniqueName)
if (currSelNetName == uniqueName) { if (currSelNetName == uniqueName) {
// 与上一次选中同一个网络框,缩小当前选项卡 // 与上一次选中同一个网络框,缩小当前选项卡
topLanListWidget->resize(W_TOP_LIST_WIDGET, H_NORMAL_ITEM*currTopLanItem + H_GAP_UP + X_ITEM); // topLanListWidget->resize(W_TOP_LIST_WIDGET, H_NORMAL_ITEM*currTopLanItem + H_GAP_UP + X_ITEM);
lbTopLanList->move(X_MIDDLE_WORD, H_NORMAL_ITEM*currTopLanItem + H_GAP_UP); // lbTopLanList->move(X_MIDDLE_WORD, H_NORMAL_ITEM*currTopLanItem + H_GAP_UP);
btnCreateNet->move(X_BTN_FUN, Y_BTN_FUN + H_NORMAL_ITEM*(currTopLanItem-1)); // btnCreateNet->move(X_BTN_FUN, Y_BTN_FUN + H_NORMAL_ITEM*(currTopLanItem-1));
scrollAreal->move(W_LEFT_AREA, Y_SCROLL_AREA + H_NORMAL_ITEM*(currTopLanItem-1)); // scrollAreal->move(W_LEFT_AREA, Y_SCROLL_AREA + H_NORMAL_ITEM*(currTopLanItem-1));
lbNoItemTip->move(this->width()/2 - W_NO_ITEM_TIP/2 + W_LEFT_AREA/2, this->height()/2 + H_NORMAL_ITEM*(currTopLanItem-1)/2); // lbNoItemTip->move(this->width()/2 - W_NO_ITEM_TIP/2 + W_LEFT_AREA/2, this->height()/2 + H_NORMAL_ITEM*(currTopLanItem-1)/2);
foreach (OneLancForm *ocf, topLanList) { // foreach (OneLancForm *ocf, topLanList) {
ocf->setTopItem(false); // ocf->setTopItem(false);
} // }
currSelNetName = ""; // currSelNetName = "";
} else { } else {
// 没有与上一次选中同一个网络框,放大当前选项卡 // 没有与上一次选中同一个网络框,放大当前选项卡
@ -3249,6 +3253,11 @@ void MainWindow::oneTopLanFormSelected(QString lanName, QString uniqueName)
void MainWindow::oneWifiFormSelected(QString wifibssid, int extendLength) void MainWindow::oneWifiFormSelected(QString wifibssid, int extendLength)
{ {
if (currSelNetName == wifibssid) {
//与win逻辑一致点击同一选项不再缩小选项卡
return;
}
QList<OneConnForm *>topWifiList = topWifiListWidget->findChildren<OneConnForm *>(); QList<OneConnForm *>topWifiList = topWifiListWidget->findChildren<OneConnForm *>();
QList<OneConnForm *> wifiList = wifiListWidget->findChildren<OneConnForm *>(); QList<OneConnForm *> wifiList = wifiListWidget->findChildren<OneConnForm *>();
@ -3267,25 +3276,25 @@ void MainWindow::oneWifiFormSelected(QString wifibssid, int extendLength)
//是否与上一次选中同一个网络框 //是否与上一次选中同一个网络框
if (currSelNetName == wifibssid) { if (currSelNetName == wifibssid) {
// 缩小所有选项卡 // // 缩小所有选项卡
for (int i = 0;i < wifiList.size(); i ++) { // for (int i = 0;i < wifiList.size(); i ++) {
OneConnForm *ocf = wifiList.at(i); // OneConnForm *ocf = wifiList.at(i);
if (ocf->wifiBSsid == wifibssid) { // if (ocf->wifiBSsid == wifibssid) {
if (ocf->wifiBSsid == hideWiFiConn) { // if (ocf->wifiBSsid == hideWiFiConn) {
ocf->setHideItem(true, true); // ocf->setHideItem(true, true);
} else { // } else {
ocf->setSelected(false, true); // ocf->setSelected(false, true);
} // }
} else { // } else {
if (ocf->wifiBSsid == hideWiFiConn) { // if (ocf->wifiBSsid == hideWiFiConn) {
ocf->setHideItem(true, true); // ocf->setHideItem(true, true);
} else { // } else {
ocf->setSelected(false, false); // ocf->setSelected(false, false);
} // }
} // }
} // }
currSelNetName = ""; // currSelNetName = "";
} else { } else {
int selectY = 0; int selectY = 0;
for (int i = 0;i < wifiList.size(); i ++) { for (int i = 0;i < wifiList.size(); i ++) {
@ -3345,21 +3354,23 @@ void MainWindow::oneWifiFormSelected(QString wifibssid, int extendLength)
} }
void MainWindow::oneTopWifiFormSelected(QString wifibssid, int extendLength) void MainWindow::oneTopWifiFormSelected(QString wifibssid, int extendLength)
{ {
//应设计师要求,此处展开后点击不再收起
if (currSelNetName == wifibssid) return;
QList<OneConnForm *>topWifiList = topWifiListWidget->findChildren<OneConnForm *>(); QList<OneConnForm *>topWifiList = topWifiListWidget->findChildren<OneConnForm *>();
QList<OneConnForm *> wifiList = wifiListWidget->findChildren<OneConnForm *>(); QList<OneConnForm *> wifiList = wifiListWidget->findChildren<OneConnForm *>();
if (currSelNetName == wifibssid) { if (currSelNetName == wifibssid) {
// 与上一次选中同一个网络框,缩小当前选项卡 // 与上一次选中同一个网络框,缩小当前选项卡
topWifiListWidget->resize(W_TOP_LIST_WIDGET, H_NORMAL_ITEM + H_GAP_UP + X_ITEM); // topWifiListWidget->resize(W_TOP_LIST_WIDGET, H_NORMAL_ITEM + H_GAP_UP + X_ITEM);
lbTopWifiList->move(X_MIDDLE_WORD, H_NORMAL_ITEM + H_GAP_UP); // lbTopWifiList->move(X_MIDDLE_WORD, H_NORMAL_ITEM + H_GAP_UP);
btnAddNet->move(X_BTN_FUN, Y_BTN_FUN); // btnAddNet->move(X_BTN_FUN, Y_BTN_FUN);
scrollAreaw->move(W_LEFT_AREA, Y_SCROLL_AREA); // scrollAreaw->move(W_LEFT_AREA, Y_SCROLL_AREA);
lbNoItemTip->move(this->width()/2 - W_NO_ITEM_TIP/2 + W_LEFT_AREA/2, this->height()/2); // lbNoItemTip->move(this->width()/2 - W_NO_ITEM_TIP/2 + W_LEFT_AREA/2, this->height()/2);
OneConnForm *ocf = topWifiList.at(0); // OneConnForm *ocf = topWifiList.at(0);
ocf->setTopItem(false); // ocf->setTopItem(false);
currSelNetName = ""; // currSelNetName = "";
} else { } else {
// 没有与上一次选中同一个网络框,放大当前选项卡 // 没有与上一次选中同一个网络框,放大当前选项卡
@ -4248,7 +4259,7 @@ int MainWindow::getScreenGeometry(QString methodName)
void MainWindow::requestRefreshWifiList() void MainWindow::requestRefreshWifiList()
{ {
current_wifi_list_state = REFRESH_WIFI; current_wifi_list_state = REFRESH_WIFI;
syslog(LOG_DEBUG, "[%s++%d] state[%d]", __FUNCTION__, __LINE__, current_wifi_list_state); qDebug()<<"current_wifi_list_state="<<current_wifi_list_state;
this->ksnm->execGetWifiList(this->wcardname, this->isHuaWeiPC); this->ksnm->execGetWifiList(this->wcardname, this->isHuaWeiPC);
} }

View File

@ -31,7 +31,6 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/syslog.h>
#include <unistd.h> #include <unistd.h>
#include <xcb/xcb.h> #include <xcb/xcb.h>

View File

@ -209,11 +209,61 @@ OneConnForm::~OneConnForm()
delete ui; delete ui;
} }
void OneConnForm::mousePressEvent(QMouseEvent *) void OneConnForm::mousePressEvent(QMouseEvent *event)
{ {
if (event->button() == Qt::RightButton && this->wifiBSsid != "--") {
QMenu * m_menu = new QMenu();//右键菜单
if (this->isTopItem) {
m_menu->addAction(new QAction(tr("Disconnect"), this));
} else {
m_menu->addAction(new QAction(tr("Connect"), this));
}
if (checkIsSaved())
m_menu->addAction(new QAction(tr("Forget"), this));
m_menu->move(cursor().pos());
m_menu->show();
connect(m_menu, &QMenu::triggered, this, &OneConnForm::onMenuTriggered);
}
emit selectedOneWifiForm(wifiBSsid, H_WIFI_ITEM_BIG_EXTEND); emit selectedOneWifiForm(wifiBSsid, H_WIFI_ITEM_BIG_EXTEND);
} }
bool OneConnForm::checkIsSaved()
{
QString name = this->wifiName;
QString currStr = "nmcli -f connection.type connection show \"" + name.replace("\"","\\\"") + "\"";
int status = system(currStr.toUtf8().data());
if (status != 0){
qDebug()<<"There is no configuration for wifi "<<this->wifiName;
return false;
} else {
return true;
}
}
/**
* @brief OneConnForm::onMenuTriggered
* @param action
*/
bool OneConnForm::onMenuTriggered(QAction *action)
{
if (action->text() == tr("Disconnect")) {
this->on_btnDisConn_clicked();
return true;
} else if (action->text() == tr("Connect")) {
this->on_btnConn_clicked();
return true;
} else if (action->text() == tr("Forget")) {
QString name = this->wifiName;
QString currStr = "nmcli connection delete \"" + name.replace("\"","\\\"") + "\"";
int status = system(currStr.toUtf8().data());
if (status != 0){
qDebug()<<"Delete wifi failed. wifi="<<this->wifiName;
return false;
}
return true;
}
}
void OneConnForm::onBtnPropertyClicked() void OneConnForm::onBtnPropertyClicked()
{ {
//WORKAROUND::ukui-control-center启动会出现rfkill僵尸进程 //WORKAROUND::ukui-control-center启动会出现rfkill僵尸进程
@ -564,7 +614,6 @@ void OneConnForm::on_btnDisConn_clicked()
return; return;
} }
//syslog(LOG_DEBUG, "DisConnect button about wifi net is clicked, current wifi name is %s .", wifiName.toUtf8().data());
qDebug()<<"DisConnect button about wifi net is clicked, current wifi name is "<<wifiName; qDebug()<<"DisConnect button about wifi net is clicked, current wifi name is "<<wifiName;
if (mw->canReconnectWifiList.contains(wifiName)) { if (mw->canReconnectWifiList.contains(wifiName)) {
mw->canReconnectWifiList.removeOne(wifiName); mw->canReconnectWifiList.removeOne(wifiName);
@ -587,7 +636,6 @@ void OneConnForm::on_btnConnSub_clicked()
return; return;
} }
//syslog(LOG_DEBUG, "A button named on_btnConnSub about wifi net is clicked.");
qDebug()<<"A button named on_btnConnSub about wifi net is clicked."; qDebug()<<"A button named on_btnConnSub about wifi net is clicked.";
toConnectWirelessNetwork(); toConnectWirelessNetwork();
} }
@ -599,7 +647,6 @@ void OneConnForm::on_btnConn_clicked()
return; return;
} }
//syslog(LOG_DEBUG, "A button named btnConn about wifi net is clicked.");
qDebug()<<"A button named btnConn about wifi net is clicked."; qDebug()<<"A button named btnConn about wifi net is clicked.";
toConnectWirelessNetwork(); toConnectWirelessNetwork();
} }
@ -771,7 +818,6 @@ void OneConnForm::toConnectWirelessNetwork()
//需要密码的wifi连接 //需要密码的wifi连接
void OneConnForm::on_btnConnPWD_clicked() void OneConnForm::on_btnConnPWD_clicked()
{ {
//syslog(LOG_DEBUG, "A button named btnConnPWD about wifi net is clicked.");
qDebug()<<"A button named btnConnPWD about wifi net is clicked."; qDebug()<<"A button named btnConnPWD about wifi net is clicked.";
if (this->getPskFlag() != 0) { if (this->getPskFlag() != 0) {
@ -1004,7 +1050,6 @@ void OneConnForm::slotConnWifiResult(int connFlag)
QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection delete '" + wifiName + "'"; QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection delete '" + wifiName + "'";
int status = system(cmd.toUtf8().data()); int status = system(cmd.toUtf8().data());
if (status != 0) { if (status != 0) {
//syslog(LOG_ERR, "execute 'nmcli connection delete' in function 'slotConnWifiResult' failed");
qDebug()<<"execute 'nmcli connection delete' in function 'slotConnWifiResult' failed."; qDebug()<<"execute 'nmcli connection delete' in function 'slotConnWifiResult' failed.";
} }
} }
@ -1070,7 +1115,6 @@ void OneConnForm::waitAnimStep()
int status = system(cmd.toUtf8().data()); int status = system(cmd.toUtf8().data());
if (status != 0) { if (status != 0) {
qDebug()<<"execute 'kill -9 $(pidof nmcli)' in function 'waitAnimStep' failed"; qDebug()<<"execute 'kill -9 $(pidof nmcli)' in function 'waitAnimStep' failed";
//syslog(LOG_ERR, "execute 'kill -9 $(pidof nmcli)' in function 'waitAnimStep' failed");
} }
this->stopWifiWaiting(true); //动画超出时间限制,强制停止动画 this->stopWifiWaiting(true); //动画超出时间限制,强制停止动画
@ -1120,7 +1164,6 @@ void OneConnForm::on_btnCancel_clicked()
// int status = system(cmd.toUtf8().data()); // int status = system(cmd.toUtf8().data());
// if (status != 0) { // if (status != 0) {
// qDebug()<<"execute 'kill -9 $(pidof nmcli)' in function 'on_btnCancel_clicked' failed"; // qDebug()<<"execute 'kill -9 $(pidof nmcli)' in function 'on_btnCancel_clicked' failed";
// syslog(LOG_ERR, "execute 'kill -9 $(pidof nmcli)' in function 'on_btnCancel_clicked' failed");
// } // }
KylinDBus myKylinDbus; KylinDBus myKylinDbus;

View File

@ -112,6 +112,7 @@ protected:
private: private:
bool getWifiConfig(WifiConfig &wc, QString netName); bool getWifiConfig(WifiConfig &wc, QString netName);
bool checkIsSaved();
private slots: private slots:
void on_btnConn_clicked(); void on_btnConn_clicked();
@ -137,6 +138,8 @@ private slots:
void on_checkBoxPwd_released(); void on_checkBoxPwd_released();
bool onMenuTriggered(QAction *);
private: private:
QTimer *waitTimer = nullptr; QTimer *waitTimer = nullptr;
int waitPage; int waitPage;

View File

@ -309,7 +309,6 @@ void OneLancForm::slotConnLan()
//点击网络断开按钮,执行该函数 //点击网络断开按钮,执行该函数
void OneLancForm::on_btnDisConn_clicked() void OneLancForm::on_btnDisConn_clicked()
{ {
//syslog(LOG_DEBUG, "DisConnect button about lan net is clicked, current wired net name is %s .", ui->lbName->text().toUtf8().data());
qDebug()<<"DisConnect button about lan net is clicked, current wired net name is "<<ui->lbName->text(); qDebug()<<"DisConnect button about lan net is clicked, current wired net name is "<<ui->lbName->text();
this->startWaiting(false); this->startWaiting(false);
@ -370,7 +369,6 @@ void OneLancForm::toDisConnWiredNetwork(QString netUuid)
//点击了连接网络按钮,执行该函数 //点击了连接网络按钮,执行该函数
void OneLancForm::on_btnConn_clicked() void OneLancForm::on_btnConn_clicked()
{ {
//syslog(LOG_DEBUG, "A button named btnConn about lan net is clicked.");
qDebug()<<"A button named btnConn about lan net is clicked."; qDebug()<<"A button named btnConn about lan net is clicked.";
toConnectWiredNetwork(); toConnectWiredNetwork();
} }
@ -378,7 +376,6 @@ void OneLancForm::on_btnConn_clicked()
//点击了item被扩展中的连接网络按钮执行该函数 //点击了item被扩展中的连接网络按钮执行该函数
void OneLancForm::on_btnConnSub_clicked() void OneLancForm::on_btnConnSub_clicked()
{ {
//syslog(LOG_DEBUG, "A button named btnConnSub about lan net is clicked.");
qDebug()<<"A button named btnConnSub about lan net is clicked."; qDebug()<<"A button named btnConnSub about lan net is clicked.";
toConnectWiredNetwork(); toConnectWiredNetwork();
} }
@ -473,7 +470,6 @@ void OneLancForm::waitAnimStep()
int status = system(cmd.toUtf8().data()); int status = system(cmd.toUtf8().data());
if (status != 0) { if (status != 0) {
qDebug()<<"execute 'kill -9 $(pidof nmcli)' in function 'waitAnimStep' failed"; qDebug()<<"execute 'kill -9 $(pidof nmcli)' in function 'waitAnimStep' failed";
//syslog(LOG_ERR, "execute 'kill -9 $(pidof nmcli)' in function 'waitAnimStep' failed");
} }
this->stopWaiting(); //动画超出时间限制,强制停止动画 this->stopWaiting(); //动画超出时间限制,强制停止动画
@ -530,7 +526,6 @@ void OneLancForm::on_btnCancel_clicked()
int status = system(cmd.toUtf8().data()); int status = system(cmd.toUtf8().data());
if (status != 0) { if (status != 0) {
qDebug()<<"execute 'kill -9 $(pidof nmcli)' in function 'on_btnCancel_clicked' failed"; qDebug()<<"execute 'kill -9 $(pidof nmcli)' in function 'on_btnCancel_clicked' failed";
//syslog(LOG_ERR, "execute 'kill -9 $(pidof nmcli)' in function 'on_btnCancel_clicked' failed");
} }
KylinDBus myKylinDbus; KylinDBus myKylinDbus;

View File

@ -17,8 +17,6 @@
*/ */
#include "utils.h" #include "utils.h"
#include <sys/syslog.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <unistd.h> #include <unistd.h>
@ -42,7 +40,6 @@ int Utils::m_system(char *cmd)
clock_t start,finish; clock_t start,finish;
if ((pid = vfork()) <0) { if ((pid = vfork()) <0) {
qDebug()<<"failed to create a subprocess by using vfork"; qDebug()<<"failed to create a subprocess by using vfork";
//syslog(LOG_ERR, "failed to create a subprocess by using vfork");
status = -1; status = -1;
} else if (pid==0) { } else if (pid==0) {
const char *new_argv[4]; const char *new_argv[4];
@ -64,7 +61,6 @@ int Utils::m_system(char *cmd)
start = clock(); start = clock();
if (execve("/bin/sh",(char *const *) new_argv, NULL) <0) { if (execve("/bin/sh",(char *const *) new_argv, NULL) <0) {
qDebug()<<"failed to execve a shell command in function m_system"; qDebug()<<"failed to execve a shell command in function m_system";
//syslog(LOG_ERR, "failed to execve %s! errno: %d\n",cmd, errno);
exit(1); exit(1);
} else { } else {
exit(0); exit(0);
@ -74,8 +70,7 @@ int Utils::m_system(char *cmd)
finish = clock(); finish = clock();
} }
double duration = (double)(finish-start)/CLOCKS_PER_SEC; double duration = (double)(finish-start)/CLOCKS_PER_SEC;
QString str = "It takes "+QString::number(duration)+" seconds to execute command:"+cmd; qDebug()<<"It takes "<<QString::number(duration)<<" seconds to execute command:"<<cmd;
//syslog(LOG_DEBUG,"%s",str.toStdString().c_str());
return status; return status;
} }
@ -114,14 +109,12 @@ int NetworkSpeed::getCurrentDownloadRates(char *netname, long *save_rate, long *
char tmp_value[128]; char tmp_value[128];
if((NULL == netname)||(NULL == save_rate)||(NULL == tx_rate)) { if((NULL == netname)||(NULL == save_rate)||(NULL == tx_rate)) {
qDebug()<<"parameter pass to function getCurrentDownloadRates() error"; qDebug()<<"parameter pass error";
//syslog(LOG_ERR, "parameter pass to function getCurrentDownloadRates() error");
return -1; return -1;
} }
if ( (net_dev_file=fopen("/proc/net/dev", "r")) == NULL ) { //打开文件/pro/net/dev/,从中读取流量数据 if ( (net_dev_file=fopen("/proc/net/dev", "r")) == NULL ) { //打开文件/pro/net/dev/,从中读取流量数据
qDebug()<<"error occurred when try to open file /proc/net/dev/"; qDebug()<<"error occurred when try to open file /proc/net/dev/";
//syslog(LOG_ERR, "error occurred when try to open file /proc/net/dev/");
return -1; return -1;
} }
memset(buffer,0,sizeof(buffer)); memset(buffer,0,sizeof(buffer));

View File

@ -5,7 +5,6 @@
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <syslog.h>
#include <KWindowEffects> #include <KWindowEffects>
#include <QtConcurrent> #include <QtConcurrent>
@ -129,7 +128,6 @@ void WiFiConfigDialog::toConfigWifi()
QFile file(tmpPath); QFile file(tmpPath);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
//syslog(LOG_DEBUG, "Can't open the file /tmp/kylin-nm-btoutput in function toConfigWifi !");
qDebug()<<"Can't open the file /tmp/kylin-nm-btoutput in function toConfigWifi !"; qDebug()<<"Can't open the file /tmp/kylin-nm-btoutput in function toConfigWifi !";
} }
QString line = file.readLine(); QString line = file.readLine();
@ -142,10 +140,7 @@ void WiFiConfigDialog::toConfigWifi()
} else { } else {
QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection delete '" + ui->leWifiId->text() + "'"; QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection delete '" + ui->leWifiId->text() + "'";
int status = system(cmd.toUtf8().data()); int status = system(cmd.toUtf8().data());
if (status != 0) { qDebug()<<"executed cmd="<<cmd<<". res="<<status;
//syslog(LOG_ERR, "execute 'nmcli connection delete' in function 'toConfigWifi' failed");
qDebug()<<"execute 'nmcli connection delete' in function 'toConfigWifi' failed";
}
} }
} }

View File

@ -23,7 +23,6 @@
#include "wireless-security/kylinheadfile.h" #include "wireless-security/kylinheadfile.h"
#include <KWindowEffects> #include <KWindowEffects>
#include <sys/syslog.h>
#include <QFile> #include <QFile>
#include <QStringListModel> #include <QStringListModel>
#include <QCompleter> #include <QCompleter>
@ -327,7 +326,9 @@ void WpaWifiDialog::initCombox() {
QStringList eapStringList; QStringList eapStringList;
/*eapStringList<< "PEAP" << "FAST" << "MD5" << "PWD" << "SIM" << "TLS" << "TTLS";*/ /*eapStringList<< "PEAP" << "FAST" << "MD5" << "PWD" << "SIM" << "TLS" << "TTLS";*/
/*eapStringList<< "PEAP";*/ /*eapStringList<< "PEAP";*/
eapStringList << "TLS" << "LEAP" << "PWD" << "FAST" << "TTLS" << "PEAP"; // eapStringList << "TLS" << "PEAP" << "PWD" << "FAST" << "TTLS" << "LEAP";
//暂时隐藏尚未完成的功能
eapStringList << "TLS" << "PEAP";
for (int i = 0; i < eapStringList.length(); i++) { for (int i = 0; i < eapStringList.length(); i++) {
eapCombox->addItem(eapStringList.at(i), QString(eapStringList.at(i)).toLower()); eapCombox->addItem(eapStringList.at(i), QString(eapStringList.at(i)).toLower());
} }
@ -659,14 +660,12 @@ void WpaWifiDialog::slot_on_connectBtn_clicked() {
// qDebug() << create_cmd; // qDebug() << create_cmd;
int res = Utils::m_system(create_cmd.toUtf8().data()); int res = Utils::m_system(create_cmd.toUtf8().data());
if (res == 0) { if (res == 0) {
//syslog(LOG_DEBUG, "In function slot_on_connectBtn_clicked, created a wifi config named %s", nameEditor->text());
qDebug() << "qDebug: created a wifi config successfully in function slot_on_connectBtn_clicked"; qDebug() << "qDebug: created a wifi config successfully in function slot_on_connectBtn_clicked";
if (askPwdBtn->isChecked() && eapCombox->currentIndex() == EapType::PEAP) setPwdFlag(2); if (askPwdBtn->isChecked() && eapCombox->currentIndex() == EapType::PEAP) setPwdFlag(2);
else setPwdFlag(0); else setPwdFlag(0);
//创建成功,激活连接 //创建成功,激活连接
activateConnection(); activateConnection();
} else { } else {
//syslog(LOG_ERR, "execute 'nmcli connection add' in function 'slot_on_connectBtn_clicked' failed");
qDebug() << "qDebug: create wpa wifi config file failed in function slot_on_connectBtn_clicked"; qDebug() << "qDebug: create wpa wifi config file failed in function slot_on_connectBtn_clicked";
} }
} }
@ -711,7 +710,6 @@ void WpaWifiDialog::activateConnection() {
Utils::m_system(cmdStr_2.toUtf8().data()); Utils::m_system(cmdStr_2.toUtf8().data());
//this->mw->is_stop_check_net_state = 0; //this->mw->is_stop_check_net_state = 0;
//this->mw->setTrayLoading(false); //this->mw->setTrayLoading(false);
//syslog(LOG_DEBUG, "execute 'nmcli connection up' in function 'activateConnection' time out");
qDebug() << "qDebug: activate time out in function activateConnection"; qDebug() << "qDebug: activate time out in function activateConnection";
qDebug() << "qDebug: 连接超时30秒超时时间"; qDebug() << "qDebug: 连接超时30秒超时时间";
}); });
@ -736,7 +734,6 @@ void WpaWifiDialog::activateConnection() {
emit conn_done(); emit conn_done();
//this->mw->is_stop_check_net_state = 0; //this->mw->is_stop_check_net_state = 0;
//this->mw->setTrayLoading(false); //this->mw->setTrayLoading(false);
//syslog(LOG_DEBUG, "execute 'nmcli connection up' in function 'activateConnection' accepted");
qDebug() << "qDebug: activated wpa security wifi successfully"; qDebug() << "qDebug: activated wpa security wifi successfully";
this->close(); this->close();
} }

View File

@ -214,11 +214,11 @@ private:
**/ **/
enum EapType { enum EapType {
TLS = 0, TLS = 0,
LEAP, PEAP,
PWD, PWD,
FAST, FAST,
TTLS, TTLS,
PEAP LEAP
}; };
WifiConfig *m_wifiConfig = nullptr; WifiConfig *m_wifiConfig = nullptr;

Binary file not shown.

View File

@ -1662,6 +1662,11 @@
<source>Disconnect</source> <source>Disconnect</source>
<translation></translation> <translation></translation>
</message> </message>
<message>
<location filename="../src/oneconnform.cpp" line="222"/>
<source>Forget</source>
<translation></translation>
</message>
<message> <message>
<location filename="../src/oneconnform.cpp" line="131"/> <location filename="../src/oneconnform.cpp" line="131"/>
<source>Property</source> <source>Property</source>

View File

@ -212,10 +212,7 @@ void DlgHideWifi::changeWindow(){
QString currStr = "nmcli connection show '" + ui->cbxConn->currentText() + "' >" + tmpPath; QString currStr = "nmcli connection show '" + ui->cbxConn->currentText() + "' >" + tmpPath;
int status = system(currStr.toUtf8().data()); int status = system(currStr.toUtf8().data());
if (status != 0){ qDebug()<<"executed cmd="<<currStr<<". res="<<status;
qDebug() << "execute 'nmcli connection show' in function 'changeWindow' failed";
//syslog(LOG_ERR, "execute 'nmcli connection show' in function 'changeWindow' failed");
}
QFile file(tmpPath); QFile file(tmpPath);
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){ if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
@ -344,10 +341,7 @@ void DlgHideWifi::on_execSecConn()
{ {
QString str = "nmcli device wifi connect '" + strWifiname + "' password ''"; QString str = "nmcli device wifi connect '" + strWifiname + "' password ''";
int status = system(str.toUtf8().data()); int status = system(str.toUtf8().data());
if (status != 0){ qDebug()<<"executed cmd="<<str<<". res="<<status;
//syslog(LOG_ERR, "execute 'nmcli device wifi connect' in function 'on_execSecConn' failed");
qDebug() << "execute 'nmcli device wifi connect' in function 'on_execSecConn' failed";
}
QTimer::singleShot(3*1000, this, SLOT(emitSignal() )); QTimer::singleShot(3*1000, this, SLOT(emitSignal() ));
} }

View File

@ -22,8 +22,6 @@
#include "kylinheadfile.h" #include "kylinheadfile.h"
#include "src/kylin-dbus-interface.h" #include "src/kylin-dbus-interface.h"
#include <sys/syslog.h>
DlgHideWifiEapFast::DlgHideWifiEapFast(int type, QWidget *parent) : DlgHideWifiEapFast::DlgHideWifiEapFast(int type, QWidget *parent) :
WepOrWpa(type), WepOrWpa(type),
QDialog(parent), QDialog(parent),
@ -101,7 +99,7 @@ DlgHideWifiEapFast::DlgHideWifiEapFast(int type, QWidget *parent) :
ui->cbxConn->addItem(tr("C_reate…")); //新建... ui->cbxConn->addItem(tr("C_reate…")); //新建...
int status = system("nmcli connection show>/tmp/kylin-nm-connshow"); int status = system("nmcli connection show>/tmp/kylin-nm-connshow");
//if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection show' in function 'DlgHideWifiEapFast' failed");} qDebug()<<"executed cmd=nmcli connection show>/tmp/kylin-nm-connshow. res="<<status;
QFile file("/tmp/kylin-nm-connshow"); QFile file("/tmp/kylin-nm-connshow");
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){ if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
qDebug()<<"Can't open the file!"; qDebug()<<"Can't open the file!";

View File

@ -22,8 +22,6 @@
#include "kylinheadfile.h" #include "kylinheadfile.h"
#include "src/kylin-dbus-interface.h" #include "src/kylin-dbus-interface.h"
#include <sys/syslog.h>
DlgHideWifiEapLeap::DlgHideWifiEapLeap(int type, QWidget *parent) : DlgHideWifiEapLeap::DlgHideWifiEapLeap(int type, QWidget *parent) :
WepOrWpa(type), WepOrWpa(type),
QDialog(parent), QDialog(parent),
@ -84,7 +82,7 @@ DlgHideWifiEapLeap::DlgHideWifiEapLeap(int type, QWidget *parent) :
ui->cbxConn->addItem(tr("C_reate…")); //新建... ui->cbxConn->addItem(tr("C_reate…")); //新建...
int status = system("nmcli connection show>/tmp/kylin-nm-connshow"); int status = system("nmcli connection show>/tmp/kylin-nm-connshow");
//if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection show' in function 'DlgHideWifiEapLeap' failed");} qDebug()<<"executed cmd=nmcli connection show>/tmp/kylin-nm-connshow. res="<<status;
QFile file("/tmp/kylin-nm-connshow"); QFile file("/tmp/kylin-nm-connshow");
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){ if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
qDebug()<<"Can't open the file!"; qDebug()<<"Can't open the file!";

View File

@ -22,9 +22,6 @@
#include "kylinheadfile.h" #include "kylinheadfile.h"
#include "src/mainwindow.h" #include "src/mainwindow.h"
#include "src/kylin-dbus-interface.h" #include "src/kylin-dbus-interface.h"
#include <sys/syslog.h>
#include <QStandardItemModel> #include <QStandardItemModel>
#include <QDir> #include <QDir>
@ -80,7 +77,7 @@ DlgHideWifiEapPeap::DlgHideWifiEapPeap(int type, int beUsed, MainWindow *mainWin
ui->cbxConn->addItem("新建..."); ui->cbxConn->addItem("新建...");
int status = system("nmcli connection show>/tmp/kylin-nm-connshow"); int status = system("nmcli connection show>/tmp/kylin-nm-connshow");
//if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection show' in function 'DlgHideWifiEapPeap' failed");} qDebug()<<"executed cmd=nmcli connection show>/tmp/kylin-nm-connshow. res="<<status;
QFile file("/tmp/kylin-nm-connshow"); QFile file("/tmp/kylin-nm-connshow");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
qDebug()<<"Can't open the file!"; qDebug()<<"Can't open the file!";
@ -274,9 +271,7 @@ void DlgHideWifiEapPeap::changeWindow(){
QString currStr = "nmcli connection show '" + ui->cbxConn->currentText() + "' > " + tmpPath; QString currStr = "nmcli connection show '" + ui->cbxConn->currentText() + "' > " + tmpPath;
int status = system(currStr.toUtf8().data()); int status = system(currStr.toUtf8().data());
if(status != 0){ qDebug()<<"executed cmd="<<currStr<<". res="<<status;
//syslog(LOG_ERR, "execute 'nmcli connection show' in function 'changeWindow' failed");
}
QFile file(tmpPath); QFile file(tmpPath);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
qDebug()<<"Can't open the file!"; qDebug()<<"Can't open the file!";

View File

@ -22,8 +22,6 @@
#include "kylinheadfile.h" #include "kylinheadfile.h"
#include "src/kylin-dbus-interface.h" #include "src/kylin-dbus-interface.h"
#include <sys/syslog.h>
DlgHideWifiEapPwd::DlgHideWifiEapPwd(int type, QWidget *parent) : DlgHideWifiEapPwd::DlgHideWifiEapPwd(int type, QWidget *parent) :
WepOrWpa(type), WepOrWpa(type),
QDialog(parent), QDialog(parent),
@ -85,7 +83,7 @@ DlgHideWifiEapPwd::DlgHideWifiEapPwd(int type, QWidget *parent) :
ui->cbxConn->addItem(tr("C_reate…")); //新建... ui->cbxConn->addItem(tr("C_reate…")); //新建...
int status = system("nmcli connection show>/tmp/kylin-nm-connshow"); int status = system("nmcli connection show>/tmp/kylin-nm-connshow");
//if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection show' in function 'DlgHideWifiEapPwd' failed");} qDebug()<<"executed cmd=nmcli connection show>/tmp/kylin-nm-connshow. res="<<status;
QFile file("/tmp/kylin-nm-connshow"); QFile file("/tmp/kylin-nm-connshow");
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){ if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
qDebug()<<"Can't open the file!"; qDebug()<<"Can't open the file!";

View File

@ -21,9 +21,6 @@
#include "kylinheadfile.h" #include "kylinheadfile.h"
#include "src/mainwindow.h" #include "src/mainwindow.h"
#include "src/kylin-dbus-interface.h" #include "src/kylin-dbus-interface.h"
#include <sys/syslog.h>
#include <QStandardItemModel> #include <QStandardItemModel>
#include <QDir> #include <QDir>
@ -79,7 +76,7 @@ DlgHideWifiEapTls::DlgHideWifiEapTls(int type, int beUsed, MainWindow *mainWindo
ui->cbxConn->addItem(tr("C_reate…")); //新建... ui->cbxConn->addItem(tr("C_reate…")); //新建...
int status = system("nmcli connection show>/tmp/kylin-nm-connshow"); int status = system("nmcli connection show>/tmp/kylin-nm-connshow");
//if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection show' in function 'DlgHideWifiEapTls' failed");} qDebug()<<"executed cmd=nmcli connection show>/tmp/kylin-nm-connshow. res="<<status;
QFile file("/tmp/kylin-nm-connshow"); QFile file("/tmp/kylin-nm-connshow");
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){ if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
qDebug()<<"Can't open the file!"; qDebug()<<"Can't open the file!";
@ -263,7 +260,7 @@ void DlgHideWifiEapTls::changeWindow(){
QString currStr = "nmcli connection show '" + ui->cbxConn->currentText() + "' >" + tmpPath; QString currStr = "nmcli connection show '" + ui->cbxConn->currentText() + "' >" + tmpPath;
int status = system(currStr.toUtf8().data()); int status = system(currStr.toUtf8().data());
//if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection show' in function 'changeWindow' failed");} qDebug()<<"executed cmd="<<currStr<<". res="<<status;
QFile file(tmpPath); QFile file(tmpPath);
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){ if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){

View File

@ -22,8 +22,6 @@
#include "kylinheadfile.h" #include "kylinheadfile.h"
#include "src/kylin-dbus-interface.h" #include "src/kylin-dbus-interface.h"
#include <sys/syslog.h>
DlgHideWifiEapTTLS::DlgHideWifiEapTTLS(int type, QWidget *parent) : DlgHideWifiEapTTLS::DlgHideWifiEapTTLS(int type, QWidget *parent) :
WepOrWpa(type), WepOrWpa(type),
QDialog(parent), QDialog(parent),
@ -106,7 +104,7 @@ DlgHideWifiEapTTLS::DlgHideWifiEapTTLS(int type, QWidget *parent) :
ui->cbxConn->addItem(tr("C_reate…")); //新建... ui->cbxConn->addItem(tr("C_reate…")); //新建...
int status = system("nmcli connection show>/tmp/kylin-nm-connshow"); int status = system("nmcli connection show>/tmp/kylin-nm-connshow");
//if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection show' in function 'DlgHideWifiEapTTLS' failed");} qDebug()<<"executed cmd=nmcli connection show>/tmp/kylin-nm-connshow. res="<<status;
QFile file("/tmp/kylin-nm-connshow"); QFile file("/tmp/kylin-nm-connshow");
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){ if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
qDebug()<<"Can't open the file!"; qDebug()<<"Can't open the file!";

View File

@ -21,8 +21,6 @@
#include "kylinheadfile.h" #include "kylinheadfile.h"
#include "src/kylin-dbus-interface.h" #include "src/kylin-dbus-interface.h"
#include <sys/syslog.h>
DlgHideWifiLeap::DlgHideWifiLeap(QWidget *parent) : DlgHideWifiLeap::DlgHideWifiLeap(QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::DlgHideWifiLeap) ui(new Ui::DlgHideWifiLeap)
@ -78,7 +76,7 @@ DlgHideWifiLeap::DlgHideWifiLeap(QWidget *parent) :
ui->cbxConn->addItem(tr("C_reate…")); //新建... ui->cbxConn->addItem(tr("C_reate…")); //新建...
int status = system("nmcli connection show>/tmp/kylin-nm-connshow"); int status = system("nmcli connection show>/tmp/kylin-nm-connshow");
//if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection show' in function 'DlgHideWifiLeap' failed");} qDebug()<<"executed cmd=nmcli connection show>/tmp/kylin-nm-connshow. res="<<status;
QFile file("/tmp/kylin-nm-connshow"); QFile file("/tmp/kylin-nm-connshow");
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){ if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
qDebug()<<"Can't open the file!"; qDebug()<<"Can't open the file!";

View File

@ -21,8 +21,6 @@
#include "kylinheadfile.h" #include "kylinheadfile.h"
#include "src/kylin-dbus-interface.h" #include "src/kylin-dbus-interface.h"
#include <sys/syslog.h>
DlgHideWifiWep::DlgHideWifiWep(int type, QWidget *parent) : DlgHideWifiWep::DlgHideWifiWep(int type, QWidget *parent) :
WepPwdOrCode(type), WepPwdOrCode(type),
QDialog(parent), QDialog(parent),
@ -84,7 +82,7 @@ DlgHideWifiWep::DlgHideWifiWep(int type, QWidget *parent) :
ui->cbxConn->addItem(tr("C_reate…")); //新建... ui->cbxConn->addItem(tr("C_reate…")); //新建...
int status = system("nmcli connection show>/tmp/kylin-nm-connshow"); int status = system("nmcli connection show>/tmp/kylin-nm-connshow");
//if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection show' in function 'DlgHideWifiWep' failed");} qDebug()<<"executed cmd=nmcli connection show>/tmp/kylin-nm-connshow. res="<<status;
QFile file("/tmp/kylin-nm-connshow"); QFile file("/tmp/kylin-nm-connshow");
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){ if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
qDebug()<<"Can't open the file!"; qDebug()<<"Can't open the file!";

View File

@ -219,10 +219,7 @@ void DlgHideWifiWpa::changeWindow()
QString currStr = "nmcli connection show '" + ui->cbxConn->currentText() + "' > " + tmpPath; QString currStr = "nmcli connection show '" + ui->cbxConn->currentText() + "' > " + tmpPath;
int status = system(currStr.toUtf8().data()); int status = system(currStr.toUtf8().data());
if(status != 0){ qDebug()<<"executed cmd="<<currStr<<". res="<<status;
//syslog(LOG_ERR, "execute 'nmcli connection show' in function 'changeWindow' failed");
qDebug() << "execute 'nmcli connection show' in function 'changeWindow' failed";
}
QFile file(tmpPath); QFile file(tmpPath);
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){ if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
qDebug()<<"Can't open the file!"; qDebug()<<"Can't open the file!";
@ -321,7 +318,6 @@ void DlgHideWifiWpa::on_btnConnect_clicked()
} }
//void DlgHideWifiWpa::finishedProcess(int state) { //void DlgHideWifiWpa::finishedProcess(int state) {
// if (! state) syslog(LOG_ERR, "Scan wifi list failed in functin on_btnConnect_clicked() in dlghidewifiwpa.cpp 359.");
// wlist = shellOutput.split("\n"); // wlist = shellOutput.split("\n");
// bool is_hidden = true; // bool is_hidden = true;
// foreach (QString wifi, wlist) { // foreach (QString wifi, wlist) {
@ -335,7 +331,6 @@ void DlgHideWifiWpa::on_btnConnect_clicked()
// QTimer::singleShot(4*1000, this, SLOT(emitSignal() )); // QTimer::singleShot(4*1000, this, SLOT(emitSignal() ));
// } else { // } else {
// //已保存的wifi没有在wifi列表找到隐藏wifi保存后也会出现在wifi列表则当前区域无法连接此wifi // //已保存的wifi没有在wifi列表找到隐藏wifi保存后也会出现在wifi列表则当前区域无法连接此wifi
// syslog(LOG_DEBUG, "Choosen wifi can not be sacnned in finishedProcess() in dlghidewifiwpa.cpp 377.");
// QString txt(tr("Selected Wifi has not been scanned.")); // QString txt(tr("Selected Wifi has not been scanned."));
// mw->objKyDBus->showDesktopNotify(txt); // mw->objKyDBus->showDesktopNotify(txt);
// emit this->stopSignal(); // emit this->stopSignal();
@ -396,10 +391,7 @@ void DlgHideWifiWpa::on_execSecConn()
{ {
QString str = "nmcli device wifi connect '" + strWifiname + "' password '" + strWifiPassword + "'"; QString str = "nmcli device wifi connect '" + strWifiname + "' password '" + strWifiPassword + "'";
int status = system(str.toUtf8().data()); int status = system(str.toUtf8().data());
if (status != 0){ qDebug()<<"executed cmd="<<str<<". res="<<status;
//syslog(LOG_ERR, "execute 'nmcli device wifi connect' in function 'on_execSecConn' failed");
qDebug() << "execute 'nmcli device wifi connect' in function 'on_execSecConn' failed";
}
qDebug() << "debug: 准备等待7秒"; qDebug() << "debug: 准备等待7秒";
QTimer::singleShot(7*1000, this, SLOT(emitSignal() )); QTimer::singleShot(7*1000, this, SLOT(emitSignal() ));
} }