KylinNM同步yangtze分支代码
This commit is contained in:
parent
699e58a2c2
commit
dca307b9b2
|
@ -43,9 +43,9 @@ BackThread::~BackThread()
|
|||
}
|
||||
|
||||
//get the connection state of wired and wireles network
|
||||
IFace BackThread::execGetIface()
|
||||
IFace* BackThread::execGetIface()
|
||||
{
|
||||
IFace iface;
|
||||
IFace *iface = new IFace();
|
||||
|
||||
QString tmpPath = "/tmp/kylin-nm-iface-" + QDir::home().dirName();
|
||||
QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli -f TYPE,DEVICE,STATE device > " + tmpPath;
|
||||
|
@ -64,8 +64,8 @@ IFace BackThread::execGetIface()
|
|||
QStringList txtList = txt.split("\n");
|
||||
file.close();
|
||||
|
||||
iface.lstate = 2;
|
||||
iface.wstate = 2;
|
||||
iface->lstate = 2;
|
||||
iface->wstate = 2;
|
||||
|
||||
for (int i = 1; i < txtList.size(); i ++) {
|
||||
QString line = txtList.at(i);
|
||||
|
@ -77,32 +77,32 @@ IFace BackThread::execGetIface()
|
|||
QString iname = lastStr.left(index2);
|
||||
QString istateStr = lastStr.mid(index2).trimmed();
|
||||
|
||||
if (type == "ethernet" && iface.lstate != 0) {
|
||||
if (type == "ethernet" && iface->lstate != 0) {
|
||||
// if type is wired network
|
||||
iface.lname = iname;
|
||||
iface->lname = iname;
|
||||
|
||||
if (istateStr == "unmanaged") {
|
||||
iface.lstate = 2; //switch of wired device is off
|
||||
iface->lstate = 2; //switch of wired device is off
|
||||
}
|
||||
if (istateStr == "disconnected" || istateStr == "unavailable") {
|
||||
iface.lstate = 1; //wired network is disconnected
|
||||
iface->lstate = 1; //wired network is disconnected
|
||||
}
|
||||
if (istateStr == "connected") {
|
||||
iface.lstate = 0; //wired network is connected
|
||||
iface->lstate = 0; //wired network is connected
|
||||
}
|
||||
}
|
||||
if (type == "wifi" && iface.wstate != 0) {
|
||||
if (type == "wifi" && iface->wstate != 0) {
|
||||
// if type is wireless network
|
||||
iface.wname = iname;
|
||||
iface->wname = iname;
|
||||
|
||||
if (istateStr == "unmanaged" || istateStr == "unavailable") {
|
||||
iface.wstate = 2; //switch of wireless device is off
|
||||
iface->wstate = 2; //switch of wireless device is off
|
||||
}
|
||||
if (istateStr == "disconnected") {
|
||||
iface.wstate = 1; //wireless network is disconnected
|
||||
iface->wstate = 1; //wireless network is disconnected
|
||||
}
|
||||
if (istateStr == "connected") {
|
||||
iface.wstate = 0; //wireless network is connected
|
||||
iface->wstate = 0; //wireless network is connected
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ void BackThread::execEnNet()
|
|||
// int status = system("nmcli networking on");
|
||||
// if (status != 0){ syslog(LOG_ERR, "execute 'nmcli networking on' in function 'execEnNet' failed");}
|
||||
while (1) {
|
||||
if (execGetIface().lstate != 2) {
|
||||
if (execGetIface()->lstate != 2) {
|
||||
sleep(3);
|
||||
emit enNetDone();
|
||||
emit btFinish();
|
||||
|
@ -133,14 +133,14 @@ void BackThread::execEnNet()
|
|||
//turn off the switch of wireless network first, then turn off the switch of network
|
||||
void BackThread::execDisNet()
|
||||
{
|
||||
if (execGetIface().wstate != 2) {
|
||||
if (execGetIface()->wstate != 2) {
|
||||
char *chr = "nmcli radio wifi off";
|
||||
Utils::m_system(chr);
|
||||
|
||||
// int status = system("nmcli radio wifi off");
|
||||
// if (status != 0){ syslog(LOG_ERR, "execute 'nmcli radio wifi off' in function 'execDisNet' failed");}
|
||||
while (1) {
|
||||
if (execGetIface().wstate == 2) {
|
||||
if (execGetIface()->wstate == 2) {
|
||||
emit disWifiDone();
|
||||
emit btFinish();
|
||||
break;
|
||||
|
@ -154,7 +154,7 @@ void BackThread::execDisNet()
|
|||
// int status1 = system("nmcli networking off");
|
||||
// if (status1 != 0){ syslog(LOG_ERR, "execute 'nmcli networking off' in function 'execDisNet' failed");}
|
||||
while (1) {
|
||||
if (execGetIface().lstate == 2) {
|
||||
if (execGetIface()->lstate == 2) {
|
||||
emit disNetDone();
|
||||
emit btFinish();
|
||||
break;
|
||||
|
@ -185,7 +185,7 @@ void BackThread::execEnWifi()
|
|||
//int status1 = system("nmcli radio wifi on");
|
||||
//if (status1 != 0){ syslog(LOG_ERR, "execute 'nmcli radio wifi on' in function 'execEnWifi' failed");}
|
||||
while (1) {
|
||||
if (execGetIface().wstate != 2) {
|
||||
if (execGetIface()->wstate != 2) {
|
||||
KylinDBus objKyDbus;
|
||||
while (1) {
|
||||
if (objKyDbus.getAccessPointsNumber() > 0) {
|
||||
|
@ -211,7 +211,7 @@ void BackThread::execDisWifi()
|
|||
// int status = system("nmcli radio wifi off");
|
||||
// if (status != 0){ syslog(LOG_ERR, "execute 'nmcli radio wifi off' in function 'execDisWifi' failed");}
|
||||
while (1) {
|
||||
if (execGetIface().wstate == 2) {
|
||||
if (execGetIface()->wstate == 2) {
|
||||
KylinNM::reflashWifiUi();
|
||||
emit disWifiDone();
|
||||
emit btFinish();
|
||||
|
@ -233,8 +233,8 @@ void BackThread::execConnLan(QString connName)
|
|||
Utils::m_system(cmd.toUtf8().data());
|
||||
// int status = system(cmd.toUtf8().data());
|
||||
// if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection up' in function 'execConnLan' failed");}
|
||||
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);
|
||||
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);
|
||||
emit connDone(0);
|
||||
} else {
|
||||
qDebug()<<"connect wired network failed for without wired cable plug in.";
|
||||
|
@ -263,8 +263,8 @@ void BackThread::execConnWifiPWD(QString connName, QString password)
|
|||
file.close();
|
||||
if (line.indexOf("successfully") != -1) {
|
||||
emit connDone(0);
|
||||
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);
|
||||
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 {
|
||||
emit connDone(1);
|
||||
}
|
||||
|
@ -293,8 +293,8 @@ void BackThread::on_readoutput()
|
|||
qDebug()<<"on_readoutput: "<< str;
|
||||
if (str.indexOf("successfully") != -1) {
|
||||
emit connDone(0); //send this signal if connect net successfully
|
||||
qDebug()<<"debug: in function on_readoutput, wireless net state is: "<<QString::number(execGetIface().wstate);
|
||||
syslog(LOG_DEBUG, "In function on_readoutput, wireless net state is: %d", execGetIface().wstate);
|
||||
qDebug()<<"debug: in function on_readoutput, wireless net state is: "<<QString::number(execGetIface()->wstate);
|
||||
syslog(LOG_DEBUG, "In function on_readoutput, wireless net state is: %d", execGetIface()->wstate);
|
||||
} else if(str.indexOf("unknown") != -1) {
|
||||
emit connDone(2);
|
||||
} else {
|
||||
|
|
|
@ -32,10 +32,10 @@
|
|||
|
||||
class IFace{
|
||||
public:
|
||||
QString lname = "";
|
||||
QString wname = "";
|
||||
int lstate = 2; // 0已连接 1未连接 2已关闭
|
||||
int wstate = 2; // 0已连接 1未连接 2已关闭
|
||||
QString lname;
|
||||
QString wname;
|
||||
int lstate; // 0已连接 1未连接 2已关闭
|
||||
int wstate; // 0已连接 1未连接 2已关闭
|
||||
};
|
||||
|
||||
class BackThread : public QObject
|
||||
|
@ -45,7 +45,7 @@ public:
|
|||
explicit BackThread(QObject *parent = nullptr);
|
||||
~BackThread();
|
||||
|
||||
IFace execGetIface();
|
||||
IFace* execGetIface();
|
||||
QString getConnProp(QString connName);
|
||||
QString execChkLanWidth(QString ethName);
|
||||
QProcess *cmdConnWifi = nullptr;
|
||||
|
|
|
@ -187,11 +187,8 @@ conlist *kylin_network_get_conlist_info()
|
|||
}
|
||||
|
||||
//获取当前活动网络连接
|
||||
int kylin_network_get_activecon_info(activecon** activelist, int* count)
|
||||
activecon *kylin_network_get_activecon_info()
|
||||
{
|
||||
if (*activelist != NULL || !count) {
|
||||
return -1;
|
||||
}
|
||||
struct passwd *pwd;
|
||||
pwd = getpwuid(getuid());
|
||||
char *name = pwd->pw_name;
|
||||
|
@ -216,7 +213,6 @@ int kylin_network_get_activecon_info(activecon** activelist, int* count)
|
|||
if((activefp=fopen(filename,"r"))==NULL)
|
||||
{
|
||||
printf("error!");
|
||||
return -1;
|
||||
}
|
||||
fgets(activeStrLine,1024,activefp);
|
||||
while(!feof(activefp))
|
||||
|
@ -226,22 +222,22 @@ int kylin_network_get_activecon_info(activecon** activelist, int* count)
|
|||
}
|
||||
// printf("%d\n",activenum);
|
||||
fclose(activefp);
|
||||
*activelist=(activecon *)malloc(sizeof(activecon)*activenum);
|
||||
activecon *activelist=(activecon *)malloc(sizeof(activecon)*activenum);
|
||||
|
||||
*count=0;
|
||||
int count=0;
|
||||
FILE *fp;
|
||||
char StrLine[1024];
|
||||
if((fp=fopen(filename,"r"))==NULL)
|
||||
{
|
||||
printf("error!");
|
||||
return -1;
|
||||
|
||||
}
|
||||
free(path);
|
||||
|
||||
fgets(StrLine,1024,fp);
|
||||
while(!feof(fp))
|
||||
{
|
||||
if(*count==activenum-1)break;
|
||||
if(count==activenum-1)break;
|
||||
|
||||
fgets(StrLine,1024,fp);
|
||||
|
||||
|
@ -261,9 +257,10 @@ int kylin_network_get_activecon_info(activecon** activelist, int* count)
|
|||
}
|
||||
|
||||
// printf("连接名称长度:%d\n",num);
|
||||
activelist[count].con_name=(char *)malloc(sizeof(char)*(num+1));
|
||||
strncpy(conname,StrLine,num+1);
|
||||
conname[num]='\0';
|
||||
strncpy((*activelist)[*count].con_name,conname,num+1);
|
||||
strncpy(activelist[count].con_name,conname,num+1);
|
||||
// printf("%s\n",activelist[count].con_name);
|
||||
|
||||
//截取连接类型
|
||||
|
@ -294,9 +291,10 @@ int kylin_network_get_activecon_info(activecon** activelist, int* count)
|
|||
if(*index2==' ')break;
|
||||
num1++;
|
||||
}
|
||||
activelist[count].type=(char *)malloc(sizeof(char)*(num1+1));
|
||||
strncpy(type,index1+2,num1+1);
|
||||
type[num1]='\0';
|
||||
strncpy((*activelist)[*count].type,type,num1+1);
|
||||
strncpy(activelist[count].type,type,num1+1);
|
||||
// printf("%s\n",activelist[count].type);
|
||||
|
||||
//截取连接所属设备
|
||||
|
@ -317,14 +315,20 @@ int kylin_network_get_activecon_info(activecon** activelist, int* count)
|
|||
if(*index4==' ')break;
|
||||
num2++;
|
||||
}
|
||||
activelist[count].dev=(char *)malloc(sizeof(char)*(num2+1));
|
||||
strncpy(dev,index3+1,num2+1);
|
||||
dev[num2]='\0';
|
||||
strncpy((*activelist)[*count].dev,dev,num2+1);
|
||||
strncpy(activelist[count].dev,dev,num2+1);
|
||||
// printf("%s\n",activelist[count].dev);
|
||||
(*count)++;
|
||||
count++;
|
||||
}
|
||||
fclose(fp);
|
||||
return 0;
|
||||
|
||||
activelist[count].con_name=NULL;
|
||||
activelist[count].type=NULL;
|
||||
activelist[count].dev=NULL;
|
||||
|
||||
return activelist;
|
||||
}
|
||||
|
||||
//创建新的以太网连接
|
||||
|
@ -825,7 +829,6 @@ long *kylin_network_get_bytes(char *if_name)
|
|||
if(i == 10)
|
||||
{
|
||||
rtbyt[1] = atol(value);
|
||||
free(value);
|
||||
break;
|
||||
}
|
||||
free(value);
|
||||
|
@ -866,7 +869,6 @@ long *kylin_network_get_packets(char *if_name)
|
|||
if(i == 11)
|
||||
{
|
||||
rtpkt[1] = atol(value);
|
||||
free(value);
|
||||
break;
|
||||
}
|
||||
free(value);
|
||||
|
@ -907,7 +909,6 @@ long *kylin_network_get_errs(char *if_name)
|
|||
if(i == 12)
|
||||
{
|
||||
rterrs[1] = atol(value);
|
||||
free(value);
|
||||
break;
|
||||
}
|
||||
free(value);
|
||||
|
@ -948,7 +949,6 @@ long *kylin_network_get_drop(char *if_name)
|
|||
if(i == 13)
|
||||
{
|
||||
rtdrop[1] = atol(value);
|
||||
free(value);
|
||||
break;
|
||||
}
|
||||
free(value);
|
||||
|
@ -989,7 +989,6 @@ long *kylin_network_get_fifo(char *if_name)
|
|||
if(i == 14)
|
||||
{
|
||||
rtfifo[1] = atol(value);
|
||||
free(value);
|
||||
break;
|
||||
}
|
||||
free(value);
|
||||
|
|
|
@ -52,9 +52,9 @@ typedef struct
|
|||
|
||||
typedef struct
|
||||
{
|
||||
char con_name[128];//活动网络连接名称
|
||||
char type[128];//活动网络连接类型
|
||||
char dev[128];//活动网络所属设备
|
||||
char *con_name;//活动网络连接名称
|
||||
char *type;//活动网络连接类型
|
||||
char *dev;//活动网络所属设备
|
||||
}activecon;//存放当前活动网络连接
|
||||
|
||||
/*
|
||||
|
@ -71,9 +71,9 @@ conlist *kylin_network_get_conlist_info();
|
|||
|
||||
/*
|
||||
* Get the active network connection.
|
||||
* return the struct pointer and list count.
|
||||
* return the struct pointer.
|
||||
*/
|
||||
int kylin_network_get_activecon_info(activecon** activelist, int* count);
|
||||
activecon *kylin_network_get_activecon_info();
|
||||
|
||||
/*
|
||||
* Create a new Ethernet connection.
|
||||
|
|
|
@ -489,26 +489,26 @@ void KylinNM::getInitLanSlist()
|
|||
// 初始化网络
|
||||
void KylinNM::initNetwork()
|
||||
{
|
||||
BackThread bt;
|
||||
IFace iface = bt.execGetIface();
|
||||
BackThread *bt = new BackThread();
|
||||
IFace *iface = bt->execGetIface();
|
||||
|
||||
wname = iface.wname;
|
||||
lwname = iface.wname;
|
||||
lname = iface.lname;
|
||||
llname = iface.lname;
|
||||
wname = iface->wname;
|
||||
lwname = iface->wname;
|
||||
lname = iface->lname;
|
||||
llname = iface->lname;
|
||||
|
||||
mwBandWidth = bt.execChkLanWidth(lname);
|
||||
mwBandWidth = bt->execChkLanWidth(lname);
|
||||
|
||||
// 开关状态
|
||||
qDebug()<<"===";
|
||||
qDebug()<<"state of network: '0' is connected, '1' is disconnected, '2' is net device switch off";
|
||||
syslog(LOG_DEBUG, "state of network: '0' is connected, '1' is disconnected, '2' is net device switch off");
|
||||
qDebug()<<"current network state: lan state ="<<iface.lstate<<", wifi state ="<<iface.wstate ;
|
||||
syslog(LOG_DEBUG, "current network state: wired state =%d, wifi state =%d", iface.lstate, iface.wstate);
|
||||
qDebug()<<"current network state: lan state ="<<iface->lstate<<", wifi state ="<<iface->wstate ;
|
||||
syslog(LOG_DEBUG, "current network state: wired state =%d, wifi state =%d", iface->lstate, iface->wstate);
|
||||
qDebug()<<"===";
|
||||
|
||||
//ui->lbBtnNetBG->setStyleSheet(btnOnQss);
|
||||
if (iface.wstate == 0 || iface.wstate == 1 || iface.wstate == 3) {
|
||||
if (iface->wstate == 0 || iface->wstate == 1 || iface->wstate == 3) {
|
||||
// ui->lbBtnWifiBG->setStyleSheet(btnBgOnQss);
|
||||
//ui->lbBtnWifiBall->move(X_RIGHT_WIFI_BALL, Y_WIFI_BALL);
|
||||
btnWireless->setSwitchStatus(true);
|
||||
|
@ -519,11 +519,11 @@ void KylinNM::initNetwork()
|
|||
}
|
||||
|
||||
// 初始化网络列表
|
||||
if (iface.wstate != 2) {
|
||||
if (iface.wstate == 0) {
|
||||
if (iface->wstate != 2) {
|
||||
if (iface->wstate == 0) {
|
||||
connWifiDone(3);
|
||||
} else {
|
||||
if (iface.lstate == 0) {
|
||||
if (iface->lstate == 0) {
|
||||
connLanDone(3);
|
||||
}
|
||||
}
|
||||
|
@ -533,8 +533,8 @@ void KylinNM::initNetwork()
|
|||
ui->btnWifiList->setStyleSheet("QPushButton{border:none;}");
|
||||
} else {
|
||||
objKyDBus->setWifiSwitchState(false); //通知控制面板wifi未开启
|
||||
if (iface.lstate != 2) {
|
||||
if (iface.lstate == 0) {
|
||||
if (iface->lstate != 2) {
|
||||
if (iface->lstate == 0) {
|
||||
connLanDone(3);
|
||||
}
|
||||
onBtnNetListClicked();
|
||||
|
@ -544,7 +544,7 @@ void KylinNM::initNetwork()
|
|||
} else {
|
||||
/*没看懂这段断开连接是什么意思,暂时关闭这段操作,会导致页面卡顿、某些情景还会自动断开网络
|
||||
// BackThread *m_bt = new BackThread();
|
||||
// m_bt->execGetIface();
|
||||
// IFace *m_iface = m_bt->execGetIface();
|
||||
|
||||
// m_bt->disConnLanOrWifi("ethernet");
|
||||
// sleep(1);
|
||||
|
@ -552,6 +552,7 @@ void KylinNM::initNetwork()
|
|||
// sleep(1);
|
||||
// m_bt->disConnLanOrWifi("ethernet");
|
||||
|
||||
// delete m_iface;
|
||||
// m_bt->deleteLater();
|
||||
*/
|
||||
|
||||
|
@ -682,13 +683,16 @@ void KylinNM::updateNetList()
|
|||
}
|
||||
is_stop_check_net_state = 1;
|
||||
if (is_btnWifiList_clicked == 1) {
|
||||
BackThread loop_bt;
|
||||
IFace loop_iface = loop_bt.execGetIface();
|
||||
BackThread *loop_bt = new BackThread();
|
||||
IFace *loop_iface = loop_bt->execGetIface();
|
||||
|
||||
if (loop_iface.wstate != 2) {
|
||||
if (loop_iface->wstate != 2) {
|
||||
is_update_wifi_list = 1;
|
||||
this->ksnm->execGetWifiList(); //更新wifi列表
|
||||
}
|
||||
|
||||
delete loop_iface;
|
||||
loop_bt->deleteLater();
|
||||
}
|
||||
is_stop_check_net_state = 0;
|
||||
}
|
||||
|
@ -720,13 +724,16 @@ void KylinNM::iconActivated(QSystemTrayIcon::ActivationReason reason)
|
|||
}
|
||||
is_stop_check_net_state = 1;
|
||||
if (is_btnWifiList_clicked == 1) {
|
||||
BackThread loop_bt;
|
||||
IFace loop_iface = loop_bt.execGetIface();
|
||||
BackThread *loop_bt = new BackThread();
|
||||
IFace *loop_iface = loop_bt->execGetIface();
|
||||
|
||||
if (loop_iface.wstate != 2) {
|
||||
if (loop_iface->wstate != 2) {
|
||||
is_update_wifi_list = 1;
|
||||
this->ksnm->execGetWifiList(); //更新wifi列表
|
||||
}
|
||||
|
||||
delete loop_iface;
|
||||
loop_bt->deleteLater();
|
||||
}
|
||||
is_stop_check_net_state = 0;
|
||||
} else {
|
||||
|
@ -905,13 +912,9 @@ void KylinNM::getActiveInfo()
|
|||
QString actLanName = "--";
|
||||
QString actWifiName = "--";
|
||||
|
||||
activecon *act = NULL;
|
||||
int count = 0;
|
||||
kylin_network_get_activecon_info(&act, &count);
|
||||
if(!act)
|
||||
return ;
|
||||
activecon *act = kylin_network_get_activecon_info();
|
||||
int index = 0;
|
||||
while (act && index < count) {
|
||||
while (act[index].con_name != NULL) {
|
||||
if (QString(act[index].type) == "ethernet" || QString(act[index].type) == "802-3-ethernet") {
|
||||
actLanName = QString(act[index].con_name);
|
||||
}
|
||||
|
@ -920,9 +923,7 @@ void KylinNM::getActiveInfo()
|
|||
}
|
||||
index ++;
|
||||
}
|
||||
if (act) {
|
||||
free(act);
|
||||
}
|
||||
|
||||
|
||||
//ukui3.0中获取currentActWifiSignalLv的值
|
||||
if (activeWifiSignalLv > 75) {
|
||||
|
@ -978,12 +979,14 @@ void KylinNM::onPhysicalCarrierChanged(bool flag)
|
|||
qDebug()<<"拔出了有线网的网线";
|
||||
syslog(LOG_DEBUG,"wired physical cable is already plug out");
|
||||
|
||||
BackThread bt;
|
||||
IFace iface = bt.execGetIface();
|
||||
if (iface.lstate != 0) {
|
||||
BackThread *bt = new BackThread();
|
||||
IFace *iface = bt->execGetIface();
|
||||
if (iface->lstate != 0) {
|
||||
is_stop_check_net_state = 1;
|
||||
wiredCableDownTimer->start(2000);
|
||||
}
|
||||
delete iface;
|
||||
bt->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1014,12 +1017,13 @@ void KylinNM::onCarrierDownHandle()
|
|||
void KylinNM::onDeleteLan()
|
||||
{
|
||||
deleteLanTimer->stop();
|
||||
BackThread btn_bt;
|
||||
btn_bt.disConnLanOrWifi("ethernet");
|
||||
BackThread *btn_bt = new BackThread();
|
||||
btn_bt->disConnLanOrWifi("ethernet");
|
||||
sleep(1);
|
||||
btn_bt.disConnLanOrWifi("ethernet");
|
||||
btn_bt->disConnLanOrWifi("ethernet");
|
||||
sleep(1);
|
||||
btn_bt.disConnLanOrWifi("ethernet");
|
||||
btn_bt->disConnLanOrWifi("ethernet");
|
||||
btn_bt->deleteLater();
|
||||
|
||||
this->stopLoading();
|
||||
onBtnNetListClicked(0);
|
||||
|
@ -1075,36 +1079,42 @@ void KylinNM::checkIsWirelessDeviceOn()
|
|||
|
||||
void KylinNM::getLanBandWidth()
|
||||
{
|
||||
BackThread bt;
|
||||
IFace iface = bt.execGetIface();
|
||||
BackThread *bt = new BackThread();
|
||||
IFace *iface = bt->execGetIface();
|
||||
|
||||
lname = iface.lname;
|
||||
lname = iface->lname;
|
||||
|
||||
mwBandWidth = bt.execChkLanWidth(lname);
|
||||
mwBandWidth = bt->execChkLanWidth(lname);
|
||||
}
|
||||
|
||||
//检测网络设备状态
|
||||
bool KylinNM::checkLanOn()
|
||||
{
|
||||
BackThread bt;
|
||||
IFace iface = bt.execGetIface();
|
||||
BackThread *bt = new BackThread();
|
||||
IFace *iface = bt->execGetIface();
|
||||
|
||||
if (iface.lstate == 2) {
|
||||
if (iface->lstate == 2) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
delete iface;
|
||||
bt->deleteLater();
|
||||
}
|
||||
|
||||
bool KylinNM::checkWlOn()
|
||||
{
|
||||
BackThread bt;
|
||||
IFace iface = bt.execGetIface();
|
||||
BackThread *bt = new BackThread();
|
||||
IFace *iface = bt->execGetIface();
|
||||
|
||||
bool ret = true;
|
||||
if (iface.wstate == 2) {
|
||||
if (iface->wstate == 2) {
|
||||
ret = false;
|
||||
}
|
||||
|
||||
delete iface;
|
||||
bt->deleteLater();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1297,14 +1307,14 @@ void KylinNM::onBtnNetListClicked(int flag)
|
|||
ui->lbNetListBG->setStyleSheet(btnOnQss);
|
||||
ui->lbWifiListBG->setStyleSheet(btnOffQss);
|
||||
|
||||
BackThread bt;
|
||||
IFace iface = bt.execGetIface();
|
||||
BackThread *bt = new BackThread();
|
||||
IFace *iface = bt->execGetIface();
|
||||
|
||||
lbLoadDown->show();
|
||||
lbLoadUp->show();
|
||||
lbLoadDownImg->show();
|
||||
lbLoadUpImg->show();
|
||||
if (iface.lstate != 0) {
|
||||
if (iface->lstate != 0) {
|
||||
lbLoadDown->hide();
|
||||
lbLoadUp->hide();
|
||||
lbLoadDownImg->hide();
|
||||
|
@ -1330,7 +1340,7 @@ void KylinNM::onBtnNetListClicked(int flag)
|
|||
return;
|
||||
}
|
||||
|
||||
if (iface.lstate != 2) {
|
||||
if (iface->lstate != 2) {
|
||||
this->startLoading();
|
||||
this->ksnm->execGetLanList();
|
||||
} else {
|
||||
|
@ -1350,6 +1360,10 @@ void KylinNM::onBtnNetListClicked(int flag)
|
|||
ui->lbWifiListImg->setStyleSheet("QLabel{border-image:url(:/res/x/pb-wifi-n.png);background-position:center;background-repeat:no-repeat;}");
|
||||
lbNetListText->setStyleSheet("QLabel{color:rgba(47, 179, 232, 1);background-color:transparent;}");
|
||||
lbWifiListText->setStyleSheet("QLabel{color:rgba(38, 38, 38, 0.75);background-color:transparent;}");
|
||||
|
||||
|
||||
delete iface;
|
||||
bt->deleteLater();
|
||||
}
|
||||
|
||||
// 当点击wifi标题的时候执行
|
||||
|
@ -1358,14 +1372,14 @@ void KylinNM::on_btnWifiList_clicked()
|
|||
this->is_btnWifiList_clicked = 1;
|
||||
this->is_btnNetList_clicked = 0;
|
||||
|
||||
BackThread bt;
|
||||
IFace iface = bt.execGetIface();
|
||||
BackThread *bt = new BackThread();
|
||||
IFace *iface = bt->execGetIface();
|
||||
|
||||
lbLoadDown->show();
|
||||
lbLoadUp->show();
|
||||
lbLoadDownImg->show();
|
||||
lbLoadUpImg->show();
|
||||
if (iface.wstate != 0) {
|
||||
if (iface->wstate != 0) {
|
||||
lbLoadDown->hide();
|
||||
lbLoadUp->hide();
|
||||
lbLoadDownImg->hide();
|
||||
|
@ -1380,7 +1394,7 @@ void KylinNM::on_btnWifiList_clicked()
|
|||
btnWireless->show();
|
||||
//ui->lbBtnWifiBG->show();
|
||||
//ui->lbBtnWifiBall->show();
|
||||
if (iface.wstate == 0 || iface.wstate == 1 || iface.wstate == 3) {
|
||||
if (iface->wstate == 0 || iface->wstate == 1 || iface->wstate == 3) {
|
||||
//ui->lbBtnWifiBG->setStyleSheet(btnBgOnQss);
|
||||
//ui->lbBtnWifiBall->move(X_RIGHT_WIFI_BALL, Y_WIFI_BALL);
|
||||
btnWireless->setSwitchStatus(true);
|
||||
|
@ -1390,7 +1404,7 @@ void KylinNM::on_btnWifiList_clicked()
|
|||
btnWireless->setSwitchStatus(false);
|
||||
}
|
||||
|
||||
if (iface.wstate != 2) {
|
||||
if (iface->wstate != 2) {
|
||||
//ui->lbBtnWifiBG->setStyleSheet(btnBgOnQss);
|
||||
//ui->lbBtnWifiBall->move(X_RIGHT_WIFI_BALL, Y_WIFI_BALL);
|
||||
btnWireless->setSwitchStatus(true);
|
||||
|
@ -1448,6 +1462,9 @@ void KylinNM::on_btnWifiList_clicked()
|
|||
this->scrollAreaw->show();
|
||||
this->topWifiListWidget->show();
|
||||
on_btnWifiList_pressed();
|
||||
|
||||
delete iface;
|
||||
bt->deleteLater();
|
||||
}
|
||||
|
||||
void KylinNM::on_btnNetList_pressed()
|
||||
|
@ -1499,20 +1516,16 @@ void KylinNM::getLanListDone(QStringList slist)
|
|||
|
||||
// 获取当前连接的lan name
|
||||
QString actLanName = "--";
|
||||
activecon *act = NULL;
|
||||
int count = 0;
|
||||
kylin_network_get_activecon_info(&act, &count);
|
||||
activecon *act = kylin_network_get_activecon_info();
|
||||
|
||||
int index = 0;
|
||||
while (act && index < count) {
|
||||
while (act[index].con_name != NULL) {
|
||||
if (QString(act[index].type) == "ethernet" || QString(act[index].type) == "802-3-ethernet") {
|
||||
actLanName = QString(act[index].con_name);
|
||||
break;
|
||||
}
|
||||
index ++;
|
||||
}
|
||||
if (act) {
|
||||
free(act);
|
||||
}
|
||||
|
||||
// 若当前lan name为"--",设置OneConnForm
|
||||
OneLancForm *ccf = new OneLancForm(topLanListWidget, this, confForm, ksnm);
|
||||
|
@ -1673,21 +1686,15 @@ void KylinNM::loadWifiListDone(QStringList slist)
|
|||
actWifiBssidList.append("--");
|
||||
}
|
||||
|
||||
activecon *act = NULL;
|
||||
int wifiCount = 0;
|
||||
kylin_network_get_activecon_info(&act, &wifiCount);
|
||||
activecon *act = kylin_network_get_activecon_info();
|
||||
int index = 0;
|
||||
while (act && index < wifiCount) {
|
||||
while (act[index].con_name != NULL) {
|
||||
if (QString(act[index].type) == "wifi" || QString(act[index].type) == "802-11-wireless") {
|
||||
actWifiName = QString(act[index].con_name);
|
||||
break;
|
||||
}
|
||||
index ++;
|
||||
}
|
||||
if (act) {
|
||||
free(act);
|
||||
}
|
||||
|
||||
// 根据当前连接的wifi 设置OneConnForm
|
||||
OneConnForm *ccf = new OneConnForm(topWifiListWidget, this, confForm, ksnm);
|
||||
if (actWifiName == "--" && actWifiBssidList.at(0) == "--") {
|
||||
|
@ -2374,8 +2381,8 @@ void KylinNM::activeGetWifiList()
|
|||
//网络开关处理,打开与关闭网络
|
||||
void KylinNM::enNetDone()
|
||||
{
|
||||
BackThread bt;
|
||||
mwBandWidth = bt.execChkLanWidth(lname);
|
||||
BackThread *bt = new BackThread();
|
||||
mwBandWidth = bt->execChkLanWidth(lname);
|
||||
|
||||
ui->lbBtnNetBG->setStyleSheet(btnOnQss);
|
||||
|
||||
|
@ -2463,6 +2470,7 @@ void KylinNM::enWifiDone()
|
|||
|
||||
qDebug()<<"debug: already turn on the switch of wifi network";
|
||||
syslog(LOG_DEBUG, "Already turn on the switch of wifi network");
|
||||
QTimer::singleShot(200, this, &KylinNM::onConnectChanged);
|
||||
}
|
||||
void KylinNM::disWifiDone()
|
||||
{
|
||||
|
@ -2598,13 +2606,16 @@ void KylinNM::onExternalWifiSwitchChange(bool wifiEnabled)
|
|||
void KylinNM::on_checkWifiListChanged()
|
||||
{
|
||||
if (is_stop_check_net_state==0 && this->is_btnWifiList_clicked==1 && this->isVisible()) {
|
||||
BackThread loop_bt;
|
||||
IFace loop_iface = loop_bt.execGetIface();
|
||||
BackThread *loop_bt = new BackThread();
|
||||
IFace *loop_iface = loop_bt->execGetIface();
|
||||
|
||||
if (loop_iface.wstate != 2) {
|
||||
if (loop_iface->wstate != 2) {
|
||||
is_update_wifi_list = 1;
|
||||
this->ksnm->execGetWifiList(); //更新wifi列表
|
||||
}
|
||||
|
||||
delete loop_iface;
|
||||
loop_bt->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2755,14 +2766,9 @@ int KylinNM::getConnectStatus()
|
|||
QString actLanName = "--";
|
||||
QString actWifiName = "--";
|
||||
|
||||
activecon *act = NULL;
|
||||
int count = 0;
|
||||
kylin_network_get_activecon_info(&act, &count);
|
||||
activecon *act = kylin_network_get_activecon_info();
|
||||
int index = 0;
|
||||
if(!act){
|
||||
return -1;
|
||||
}
|
||||
while (act && index < count) {
|
||||
while (act[index].con_name != NULL) {
|
||||
if (QString(act[index].type) == "ethernet" || QString(act[index].type) == "802-3-ethernet") {
|
||||
actLanName = QString(act[index].con_name);
|
||||
}
|
||||
|
@ -2771,9 +2777,6 @@ int KylinNM::getConnectStatus()
|
|||
}
|
||||
index ++;
|
||||
}
|
||||
if (act) {
|
||||
free(act);
|
||||
}
|
||||
|
||||
//ukui3.0中获取currentActWifiSignalLv的值
|
||||
if (activeWifiSignalLv > 75) {
|
||||
|
|
Loading…
Reference in New Issue