Add function to scan wifi per 10 seconds
This commit is contained in:
parent
e4580344de
commit
5ebdc6c3cb
|
@ -25,7 +25,8 @@
|
|||
|
||||
#include <QTextCodec>
|
||||
#include <QByteArray>
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QDBusMetaType>
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -177,6 +178,7 @@ void KylinDBus::getObjectPath()
|
|||
multiWiredPaths.append(obj_path);
|
||||
} else if (reply.value().indexOf("org.freedesktop.NetworkManager.Device.Wireless") != -1) {
|
||||
//表明有wifi设备
|
||||
multiWirelessPaths.append(obj_path);
|
||||
wirelessPath = obj_path;
|
||||
isWirelessCardOn = true;
|
||||
}
|
||||
|
@ -1851,6 +1853,23 @@ bool KylinDBus::toConnectWiredNet(QString netUuid, QString netIfName)
|
|||
return isConnectUp;
|
||||
}
|
||||
|
||||
//要求底层的驱动进行扫描AP
|
||||
void KylinDBus::requestScanWifi()
|
||||
{
|
||||
if (multiWirelessPaths.size() == 0) return;
|
||||
qDebug() << "----------------------> requestScanWifi " << multiWirelessPaths.at(0).path();
|
||||
|
||||
qRegisterMetaType<QMap<QString, QVariant>>("QMap<QString, QVariant>");
|
||||
qDBusRegisterMetaType<QMap<QString, QVariant>>();
|
||||
QDBusInterface interface( "org.freedesktop.NetworkManager",
|
||||
multiWirelessPaths.at(0).path(),
|
||||
"org.freedesktop.NetworkManager.Device.Wireless",
|
||||
QDBusConnection::systemBus() );
|
||||
QMap<QString, QVariant> my_map;
|
||||
my_map = {};
|
||||
interface.call("RequestScan", my_map); //get accesspoint for each wifi
|
||||
}
|
||||
|
||||
//显示桌面通知
|
||||
void KylinDBus::showDesktopNotify(QString message)
|
||||
{
|
||||
|
|
|
@ -81,6 +81,7 @@ public:
|
|||
void toGetWifiList();
|
||||
|
||||
QDBusObjectPath wirelessPath; //无线设备的路径
|
||||
QList<QDBusObjectPath> multiWirelessPaths; //Wireless Device的对象路径列表
|
||||
QList<QDBusObjectPath> multiWiredPaths; //Wired Device的对象路径列表
|
||||
QList<QString> multiWiredCableState;//多有线网卡的情况,判断有线网卡对应网线是否插入
|
||||
QList<QString> multiWiredMac; //对应有线网卡的Mac地址
|
||||
|
@ -127,6 +128,7 @@ public slots:
|
|||
QString getLanMAC(QString ifname);
|
||||
void getWifiMac(QString netName);
|
||||
void slot_timeout();
|
||||
void requestScanWifi();
|
||||
|
||||
private:
|
||||
MainWindow *mw;
|
||||
|
|
|
@ -558,8 +558,8 @@ void MainWindow::initTimer()
|
|||
//循环检测wifi列表的变化,可用于更新wifi列表
|
||||
checkWifiListChanged = new QTimer(this);
|
||||
checkWifiListChanged->setTimerType(Qt::PreciseTimer);
|
||||
QObject::connect(checkWifiListChanged, SIGNAL(timeout()), this, SLOT(on_checkWifiListChanged()));
|
||||
checkWifiListChanged->start(10*1000);
|
||||
QObject::connect(checkWifiListChanged, SIGNAL(timeout()), this, SLOT(onRequestScanAccesspoint()));
|
||||
checkWifiListChanged->start(11*1000);
|
||||
|
||||
//网线插入时定时执行
|
||||
wiredCableUpTimer = new QTimer(this);
|
||||
|
@ -2955,6 +2955,8 @@ void MainWindow::activeWifiDisconn()
|
|||
}
|
||||
void MainWindow::activeStartLoading()
|
||||
{
|
||||
QTimer::singleShot(13*1000, objKyDBus, SLOT(requestScanWifi() ));
|
||||
|
||||
syslog(LOG_DEBUG, "Wi-Fi is disconnected");
|
||||
QString txt(tr("Wi-Fi is disconnected"));
|
||||
objKyDBus->showDesktopNotify(txt);
|
||||
|
@ -3289,7 +3291,7 @@ void MainWindow::onExternalWifiSwitchChange(bool wifiEnabled)
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//循环处理部分,目前仅on_checkWifiListChanged 与on_setNetSpeed两个函数在运行
|
||||
|
||||
void MainWindow::on_checkWifiListChanged()
|
||||
void MainWindow::onRequestScanAccesspoint()
|
||||
{
|
||||
if (is_init_wifi_list || is_connect_hide_wifi) {
|
||||
return; //遇到启动软件第一次加载wifi列表的时候,或正在连接隐藏wifi,停止更新
|
||||
|
@ -3300,6 +3302,9 @@ void MainWindow::on_checkWifiListChanged()
|
|||
IFace *loop_iface = loop_bt->execGetIface();
|
||||
|
||||
if (loop_iface->wstate != 2) {
|
||||
if (loop_iface->wstate == 0) {
|
||||
objKyDBus->requestScanWifi();
|
||||
}
|
||||
current_wifi_list_state = UPDATE_WIFI_LIST;
|
||||
this->ksnm->execGetWifiList(this->wcardname); //更新wifi列表
|
||||
}
|
||||
|
|
|
@ -361,7 +361,7 @@ private slots:
|
|||
void activeWifiDisconn();
|
||||
void activeStartLoading();
|
||||
void activeGetWifiList();
|
||||
void on_checkWifiListChanged();
|
||||
void onRequestScanAccesspoint();
|
||||
void on_setNetSpeed();
|
||||
void on_checkOverTime();
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ OneConnForm::OneConnForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf
|
|||
btnProperty->setText(tr("Property"));//"属性"
|
||||
btnProperty->setStyleSheet(funcBtnQss);
|
||||
btnProperty->setFocusPolicy(Qt::NoFocus);
|
||||
btnProperty->show();
|
||||
btnProperty->hide();
|
||||
connect(btnProperty,SIGNAL(clicked()),this,SLOT(onBtnPropertyClicked()));
|
||||
|
||||
this->mw = mainWindow;
|
||||
|
|
Loading…
Reference in New Issue