57 lines
1.7 KiB
C++
57 lines
1.7 KiB
C++
/*
|
|
* Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 3, or (at your option)
|
|
* any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
*/
|
|
|
|
#include "ksimplenm.h"
|
|
#include <stdio.h>
|
|
#define MAX_LEN 2048
|
|
#define MAX_PATH 1024
|
|
|
|
KSimpleNM::KSimpleNM(QObject *parent) : QObject(parent)
|
|
{
|
|
runShellProcess =new QProcess(this);
|
|
|
|
connect(runShellProcess, &QProcess::readyRead, this, &KSimpleNM::readProcess);
|
|
connect(runShellProcess, SIGNAL(finished(int)), this, SLOT(finishedProcess(int)));
|
|
}
|
|
|
|
void KSimpleNM::execGetLanList(){
|
|
shellOutput = "";
|
|
type = 0;
|
|
runShellProcess->start("nmcli -f type,device,name connection show");
|
|
}
|
|
|
|
void KSimpleNM::execGetWifiList(){
|
|
shellOutput = "";
|
|
type = 1;
|
|
runShellProcess->start("nmcli -f signal,rate,security,ssid device wifi");
|
|
}
|
|
|
|
void KSimpleNM::readProcess(){
|
|
QString output = runShellProcess->readAll();
|
|
shellOutput += output;
|
|
}
|
|
|
|
void KSimpleNM::finishedProcess(int msg){
|
|
QStringList slist = shellOutput.split("\n");
|
|
if(type == 0){
|
|
emit getLanListFinished(slist);
|
|
}else{
|
|
emit getWifiListFinished(slist);
|
|
}
|
|
}
|