From 7020b63e5005b7d0f540d99ebf32bbcb65f4988d Mon Sep 17 00:00:00 2001 From: zhangjiaping Date: Sat, 22 May 2021 09:40:48 +0800 Subject: [PATCH] feat(log): Add log file. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Description: 添加日志文件,可通过tail -f .config/ukui/kylin-nm.log查看 Log: 添加日志文件,可通过tail -f .config/ukui/kylin-nm.log查看 --- src/backthread.cpp | 4 ++++ src/main.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++ src/mainwindow.cpp | 25 ++++++++++++++--------- src/oneconnform.cpp | 6 +++++- src/wpawifidialog.cpp | 1 + 5 files changed, 72 insertions(+), 11 deletions(-) diff --git a/src/backthread.cpp b/src/backthread.cpp index 80e48958..fc9accca 100644 --- a/src/backthread.cpp +++ b/src/backthread.cpp @@ -218,6 +218,7 @@ void BackThread::execConnLan(QString connName, QString ifname, QString connectTy } else { mycmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up '" + connName + "' ifname '" + ifname + "'"; } + qDebug()<<"Trying to connect wifi. ssid="< connName = " << connName; cmdStr = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up '" + connName + "' ifname '" + connIfName + "'\n"; } + qDebug()<<"Trying to connect wifi. ssid="<= 0) { - wDbusPath = line.mid(Path,indexCate-Path).trimmed(); + wDbusPath = line.mid(indexPath,indexCate-indexPath).trimmed(); } else { - wDbusPath = line.mid(Path,indexName-Path).trimmed(); + wDbusPath = line.mid(indexPath,indexName-indexPath).trimmed(); } QDBusInterface interface("org.freedesktop.NetworkManager", wDbusPath, @@ -2525,13 +2525,11 @@ void MainWindow::loadWifiListDone(QStringList slist) int max_freq = wfreq.toInt(); int min_freq = wfreq.toInt(); for (int k = i; k < slist.size(); k ++) { - QString tmpLine = slist.at(k); - int Path = tmpLine.indexOf("/org/"); QString m_DbusPath; if (indexCate >= 0) { - m_DbusPath = line.mid(Path,indexCate-Path).trimmed(); + m_DbusPath = slist.at(k).mid(indexPath,indexCate-indexPath).trimmed(); } else { - m_DbusPath = line.mid(Path,indexName-Path).trimmed(); + m_DbusPath = slist.at(k).mid(indexPath,indexName-indexPath).trimmed(); } QDBusInterface m_interface("org.freedesktop.NetworkManager", m_DbusPath, @@ -2548,7 +2546,7 @@ void MainWindow::loadWifiListDone(QStringList slist) } } } - + qDebug()<<"Wifi ssid="<ksnm->execGetWifiList(this->wcardname, this->isHuaWeiPC); @@ -4005,6 +4005,7 @@ void MainWindow::connWifiDone(int connFlag) objKyDBus->showDesktopNotify(txt); } else if (connFlag == 1) { syslog(LOG_DEBUG, "Confirm your Wi-Fi password or usable of wireless card"); + qWarning()<<"Wi-Fi connected failed. res=1"; //is_stop_check_net_state = 0; is_connect_net_failed = 1; is_connect_hide_wifi = 0; @@ -4012,20 +4013,24 @@ void MainWindow::connWifiDone(int connFlag) objKyDBus->showDesktopNotify(txt); } else if (connFlag == 3) { syslog(LOG_DEBUG, "Launch kylin-nm, Wi-Fi already connected"); + qWarning()<<"Wi-Fi connected failed. res=3"; } else if (connFlag == 4) { syslog(LOG_DEBUG, "Confirm your Wi-Fi password"); is_connect_net_failed = 1; QString txt(tr("Confirm your Wi-Fi password")); + qWarning()<<"Wi-Fi connected failed. res=4"; objKyDBus->showDesktopNotify(txt); } else if (connFlag == 5) { syslog(LOG_DEBUG, "Selected Wifi has not been scanned."); is_connect_net_failed = 1; QString txt(tr("Selected Wifi has not been scanned.")); + qWarning()<<"Wi-Fi connected failed. res=5"; objKyDBus->showDesktopNotify(txt); } else if (connFlag == 6) { syslog(LOG_DEBUG, "Connect Hidden Wifi Success."); this->ksnm->execGetWifiList(this->wcardname, this->isHuaWeiPC); QString txt(tr("Connect Hidden Wifi Success")); + qWarning()<<"Wi-Fi connected failed. res=6"; objKyDBus->showDesktopNotify(txt); } diff --git a/src/oneconnform.cpp b/src/oneconnform.cpp index 06e93f1a..4ee82bf1 100644 --- a/src/oneconnform.cpp +++ b/src/oneconnform.cpp @@ -732,6 +732,7 @@ void OneConnForm::toConnectWirelessNetwork() connect(t, &QThread::started, this, [ = ]() { this->startWifiWaiting(true); QString cmdStr = "nmcli connection up '" + wifiName + "' passwd-file " + homePath +"/.config/" + wifiName + ".psk"; + qDebug()<<"Trying to connect wifi. ssid="<sigConnWifiPsk(cmdStr); }); connect(this, SIGNAL(sigConnWifiPsk(QString)), bt, SLOT(execConnWifiPsk(QString))); @@ -790,6 +791,7 @@ void OneConnForm::on_btnConnPWD_clicked() connect(t, &QThread::started, this, [ = ]() { this->startWifiWaiting(true); QString cmdStr = "nmcli connection up '" + wifiName + "' passwd-file " + homePath +"/.config/" + wifiName + ".psk"; + qDebug()<<"Trying to connect wifi. ssid="<sigConnWifiPsk(cmdStr); }); connect(this, SIGNAL(sigConnWifiPsk(QString)), bt, SLOT(execConnWifiPsk(QString))); @@ -983,8 +985,10 @@ void OneConnForm::slotConnWifiResult(int connFlag) qDebug() << "实际连接的wifi的bssid是 " << wifiBSsid; if (currConnWifiBssid != wifiBSsid && !currConnWifiBssid.isEmpty()) { QString modityCmd = "nmcli connection modify \""+ wifiName + "\" " + "802-11-wireless.bssid " + wifiBSsid; - system(modityCmd.toUtf8().data()); + int res = system(modityCmd.toUtf8().data()); + qDebug()<<"Modified bssid for wifi. ssid="<conn_name + "'"; } + qDebug()<<"Trying to connect wifi. ssid="<conn_name; qDebug()<<"qDebug: 激活连接: \n"<< "qDebug: " + cmdStr; int res = Utils::m_system(cmdStr.toUtf8().data());