Fix bug program exit when select and click hotpot wifi in add hidden wifi window
This commit is contained in:
parent
041616e259
commit
f0fc60682a
|
@ -640,6 +640,39 @@ int KylinDBus::getWiredNetworkNumber()
|
|||
return wiredNetworkNumber;
|
||||
}
|
||||
|
||||
QStringList KylinDBus::getWifiSsidList()
|
||||
{
|
||||
QStringList wifiSsidList;
|
||||
|
||||
QDBusInterface m_interface("org.freedesktop.NetworkManager",
|
||||
"/org/freedesktop/NetworkManager/Settings",
|
||||
"org.freedesktop.NetworkManager.Settings",
|
||||
QDBusConnection::systemBus() );
|
||||
QDBusReply<QList<QDBusObjectPath>> m_reply = m_interface.call("ListConnections");
|
||||
|
||||
QDBusObjectPath specific_connection;
|
||||
specific_connection.setPath("/");
|
||||
|
||||
QList<QDBusObjectPath> m_objSettingPaths = m_reply.value();
|
||||
foreach (QDBusObjectPath objSettingPath, m_objSettingPaths) {
|
||||
QDBusInterface m_interface("org.freedesktop.NetworkManager",
|
||||
objSettingPath.path(),
|
||||
"org.freedesktop.NetworkManager.Settings.Connection",
|
||||
QDBusConnection::systemBus());
|
||||
QDBusMessage result = m_interface.call("GetSettings");
|
||||
|
||||
const QDBusArgument &dbusArg1st = result.arguments().at( 0 ).value<QDBusArgument>();
|
||||
QMap<QString,QMap<QString,QVariant>> map;
|
||||
dbusArg1st >> map;
|
||||
|
||||
if (map.value("802-11-wireless").value("mode").toString() == "infrastructure") {
|
||||
wifiSsidList.append(map.value("connection").value("id").toString());
|
||||
}
|
||||
}
|
||||
|
||||
return wifiSsidList;
|
||||
}
|
||||
|
||||
void KylinDBus::toCreateNewLan()
|
||||
{
|
||||
int i = 1;
|
||||
|
|
|
@ -48,6 +48,7 @@ public:
|
|||
void getObjectPath();
|
||||
int getAccessPointsNumber();
|
||||
int getWiredNetworkNumber();
|
||||
QStringList getWifiSsidList();
|
||||
void showDesktopNotify(QString message);
|
||||
void initConnectionInfo();
|
||||
QList<QString> getAtiveLanSsidUuid();
|
||||
|
|
|
@ -66,22 +66,10 @@ DlgHideWifi::DlgHideWifi(int type, MainWindow *mainWindow, QWidget *parent) :
|
|||
ui->btnConnect->setText(tr("Connect")); //连接
|
||||
|
||||
ui->cbxConn->addItem(tr("C_reate…")); //新建...
|
||||
QString tmpPath = "/tmp/kylin-nm-connshow-" + QDir::home().dirName();
|
||||
QString cmd = "nmcli connection show>" + tmpPath;
|
||||
int status = system(cmd.toUtf8().data());
|
||||
if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection show' in function 'DlgHideWifi' failed");}
|
||||
QFile file(tmpPath);
|
||||
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
|
||||
qDebug()<<"Can't open the file!";
|
||||
}
|
||||
QString txt = file.readAll();
|
||||
QStringList txtLine = txt.split("\n");
|
||||
file.close();
|
||||
foreach (QString line, txtLine) {
|
||||
if (line.indexOf("wifi") != -1 || line.indexOf("802-11-wireless") != -1) {
|
||||
QStringList subLine = line.split(" ");
|
||||
ui->cbxConn->addItem(subLine[0]);
|
||||
}
|
||||
KylinDBus mkylindbus;
|
||||
QStringList wifiList = mkylindbus.getWifiSsidList();
|
||||
foreach (QString strWifiSsid, wifiList) {
|
||||
ui->cbxConn->addItem(strWifiSsid);
|
||||
}
|
||||
ui->cbxConn->setCurrentIndex(0);
|
||||
connect(ui->cbxConn,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeWindow()));
|
||||
|
|
|
@ -72,24 +72,10 @@ DlgHideWifiWpa::DlgHideWifiWpa(int type, MainWindow *mainWindow, QWidget *parent
|
|||
ui->btnConnect->setText(tr("Connect")); //连接
|
||||
|
||||
ui->cbxConn->addItem(tr("C_reate…")); //新建...
|
||||
QString tmpPath = "/tmp/kylin-nm-connshow-" + QDir::home().dirName();
|
||||
QString cmd = "nmcli connection show > " + tmpPath;
|
||||
int status = system(cmd.toUtf8().data());
|
||||
if (status != 0) {
|
||||
syslog(LOG_ERR, "execute 'nmcli connection show' in function 'DlgHideWifiWpa' failed");
|
||||
}
|
||||
QFile file(tmpPath);
|
||||
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
|
||||
qDebug()<<"Can't open the file!";
|
||||
}
|
||||
QString txt = file.readAll();
|
||||
QStringList txtLine = txt.split("\n");
|
||||
file.close();
|
||||
foreach (QString line, txtLine) {
|
||||
if (line.indexOf("wifi") != -1 || line.indexOf("802-11-wireless") != -1) {
|
||||
QStringList subLine = line.split(" ");
|
||||
ui->cbxConn->addItem(subLine[0]);
|
||||
}
|
||||
KylinDBus mkylindbus;
|
||||
QStringList wifiList = mkylindbus.getWifiSsidList();
|
||||
foreach (QString strWifiSsid, wifiList) {
|
||||
ui->cbxConn->addItem(strWifiSsid);
|
||||
}
|
||||
ui->cbxConn->setCurrentIndex(0);
|
||||
connect(ui->cbxConn,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeWindow()));
|
||||
|
|
Loading…
Reference in New Issue