Fix bug can not show connected tray icon after connect a bluetooth network

This commit is contained in:
liushanwen1997 2021-01-21 14:57:48 +08:00
parent 356ac49cc7
commit dfc28ee667
2 changed files with 30 additions and 9 deletions

View File

@ -209,6 +209,7 @@ void BackThread::execConnLan(QString connName, QString ifname, QString connectTy
{
currConnLanUuid = connName;
currConnLanType = connectType;
QString mycmd; //连接命令
KylinDBus objKyDbus;
//先断开当前网卡对应的已连接有线网
@ -218,18 +219,20 @@ void BackThread::execConnLan(QString connName, QString ifname, QString connectTy
}
bool wiredCableState = objKyDbus.getWiredCableStateByIfname(ifname);
if (connectType == "bluetooth") {
wiredCableState = true; //对于蓝牙类型的网络不需要接入网线就可以连接
mycmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up '" + connName + "'";
} else {
mycmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up '" + connName + "' ifname '" + ifname + "'";
}
if (wiredCableState) {
//if(objKyDbus.toConnectWiredNet(connName, ifname)) { //此处connName是有线网Uuid
// emit connDone(2);
//} else {
// emit connDone(7);
// emit connDone(8);
//}
QString mycmd;
if (connectType == "bluetooth") {
mycmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up '" + connName + "'";
} else {
mycmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up '" + connName + "' ifname '" + ifname + "'";
}
QStringList options;
options << "-c" << mycmd;
process->start("/bin/bash",options);
@ -279,8 +282,12 @@ void BackThread::dellConnectLanResult(QString info)
emit connDone(5);
} else if(info.indexOf("Killed") != -1 || info.indexOf("killed") != -1) {
emit connDone(6);
} else {
} else if(info.indexOf("The Bluetooth connection failed") != -1) {
emit connDone(7);
} else if(info.indexOf("Carrier/link changed") != -1) {
emit connDone(8);
} else {
emit connDone(9);
}
}
}

View File

@ -841,7 +841,7 @@ void MainWindow::getActiveInfo()
activecon *act = kylin_network_get_activecon_info();
int index = 0;
while (act[index].con_name != NULL) {
if (QString(act[index].type) == "ethernet" || QString(act[index].type) == "802-3-ethernet") {
if (QString(act[index].type) == "ethernet" || QString(act[index].type) == "802-3-ethernet" || QString(act[index].type) == "bluetooth") {
actLanName = QString(act[index].con_name);
}
if (QString(act[index].type) == "wifi" || QString(act[index].type) == "802-11-wireless") {
@ -2819,6 +2819,20 @@ void MainWindow::connLanDone(int connFlag)
}
if (connFlag == 7) {
syslog(LOG_DEBUG, "Connect Bluetooth Network Failed");
is_connect_net_failed = 1;
QString txt(tr("Connect Bluetooth Network Failed"));
objKyDBus->showDesktopNotify(txt);
}
if (connFlag == 8) {
syslog(LOG_DEBUG, "Carrier/link changed");
is_connect_net_failed = 1;
QString txt(tr("Carrier/link changed"));
objKyDBus->showDesktopNotify(txt);
}
if (connFlag == 9) {
syslog(LOG_DEBUG, "Connect Wired Network Failed");
is_connect_net_failed = 1;
QString txt(tr("Connect Wired Network Failed"));