Merge pull request #129 from mammonsama666/0507-dev
feat(wifi): Add dbus interface to provide wifi list to ukui-control-center.
This commit is contained in:
commit
1c791e182c
|
@ -25,7 +25,13 @@ DbusAdaptor::DbusAdaptor(MainWindow *parent)
|
||||||
: QDBusAbstractAdaptor(parent)
|
: QDBusAbstractAdaptor(parent)
|
||||||
{
|
{
|
||||||
// constructor
|
// constructor
|
||||||
|
qDBusRegisterMetaType<QVector<QStringList>>();
|
||||||
setAutoRelaySignals(true);
|
setAutoRelaySignals(true);
|
||||||
|
//setAutoRelaySignals(true)后会自动转发同名信号,因此不必再额外像如下代码一样写一个转发
|
||||||
|
// connect(parent, &MainWindow::getWifiListFinished, this, [ = ]() {
|
||||||
|
// QDBusMessage msg = QDBusMessage::createSignal("/com/kylin/network", "com.kylin.network", "getWifiListFinished");
|
||||||
|
// QDBusConnection::sessionBus().send(msg);
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
DbusAdaptor::~DbusAdaptor()
|
DbusAdaptor::~DbusAdaptor()
|
||||||
|
@ -41,3 +47,13 @@ void DbusAdaptor::showMainWindow()
|
||||||
parent()->on_showWindowAction();
|
parent()->on_showWindowAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DbusAdaptor::requestRefreshWifiList()
|
||||||
|
{
|
||||||
|
parent()->requestRefreshWifiList();
|
||||||
|
}
|
||||||
|
|
||||||
|
QVector<QStringList> DbusAdaptor::getWifiList()
|
||||||
|
{
|
||||||
|
return parent()->dbus_wifiList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,13 +14,15 @@
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtDBus/QtDBus>
|
#include <QtDBus/QtDBus>
|
||||||
|
#include <QtDBus/QDBusMetaType>
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QByteArray;
|
class QByteArray;
|
||||||
template<class T> class QList;
|
//template<class T> class QList;
|
||||||
template<class Key, class Value> class QMap;
|
template<class Key, class Value> class QMap;
|
||||||
class QString;
|
class QString;
|
||||||
class QStringList;
|
class QStringList;
|
||||||
class QVariant;
|
class QVariant;
|
||||||
|
template<class T> class QVector;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -36,6 +38,11 @@ class DbusAdaptor: public QDBusAbstractAdaptor
|
||||||
Q_CLASSINFO("D-Bus Introspection", ""
|
Q_CLASSINFO("D-Bus Introspection", ""
|
||||||
" <interface name=\"com.kylin.network\">\n"
|
" <interface name=\"com.kylin.network\">\n"
|
||||||
" <method name=\"showMainWindow\"/>\n"
|
" <method name=\"showMainWindow\"/>\n"
|
||||||
|
" <method name=\"requestRefreshWifiList\"/>\n"
|
||||||
|
" <method name=\"getWifiList\">\n"
|
||||||
|
" <arg type=\"av\" direction=\"out\"/>\n"
|
||||||
|
" </method>\n"
|
||||||
|
" <signal name=\"getWifiListFinished\"/>\n"
|
||||||
" </interface>\n"
|
" </interface>\n"
|
||||||
"")
|
"")
|
||||||
public:
|
public:
|
||||||
|
@ -48,7 +55,10 @@ public:
|
||||||
public: // PROPERTIES
|
public: // PROPERTIES
|
||||||
public Q_SLOTS: // METHODS
|
public Q_SLOTS: // METHODS
|
||||||
void showMainWindow();
|
void showMainWindow();
|
||||||
|
void requestRefreshWifiList();
|
||||||
|
QVector<QStringList> getWifiList();
|
||||||
Q_SIGNALS: // SIGNALS
|
Q_SIGNALS: // SIGNALS
|
||||||
|
void getWifiListFinished();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2098,6 +2098,7 @@ void MainWindow::loadWifiListDone(QStringList slist)
|
||||||
wifiListWidget->resize(W_LIST_WIDGET, H_WIFI_ITEM_BIG_EXTEND);
|
wifiListWidget->resize(W_LIST_WIDGET, H_WIFI_ITEM_BIG_EXTEND);
|
||||||
scrollAreaw->setWidget(wifiListWidget);
|
scrollAreaw->setWidget(wifiListWidget);
|
||||||
scrollAreaw->move(W_LEFT_AREA, Y_SCROLL_AREA);
|
scrollAreaw->move(W_LEFT_AREA, Y_SCROLL_AREA);
|
||||||
|
dbus_wifiList.clear();
|
||||||
|
|
||||||
// 获取当前有线网的连接状态,正在连接wifiActState==1,已经连接wifiActState==2, 未连接wifiActState==3
|
// 获取当前有线网的连接状态,正在连接wifiActState==1,已经连接wifiActState==2, 未连接wifiActState==3
|
||||||
int wifiActState = objKyDBus->checkWifiConnectivity(); //检查wifi的连接状态
|
int wifiActState = objKyDBus->checkWifiConnectivity(); //检查wifi的连接状态
|
||||||
|
@ -2158,6 +2159,7 @@ void MainWindow::loadWifiListDone(QStringList slist)
|
||||||
lbLoadDownImg->hide();
|
lbLoadDownImg->hide();
|
||||||
lbLoadUpImg->hide();
|
lbLoadUpImg->hide();
|
||||||
ccf->setTopItem(false);
|
ccf->setTopItem(false);
|
||||||
|
dbus_wifiList.append(QStringList("--")); //没有已连接wifi时,第一个元素为--
|
||||||
} else {
|
} else {
|
||||||
QProcess * process = new QProcess;
|
QProcess * process = new QProcess;
|
||||||
QString name = actWifiName;
|
QString name = actWifiName;
|
||||||
|
@ -2325,8 +2327,12 @@ void MainWindow::loadWifiListDone(QStringList slist)
|
||||||
}
|
}
|
||||||
|
|
||||||
//ccf->setRate(wrate);
|
//ccf->setRate(wrate);
|
||||||
int signal = wsignal.toInt() + 11;
|
int signal;
|
||||||
ccf->setSignal(QString::number(signal), wsecu, wcate);
|
if (wsignal.toInt() != 0)
|
||||||
|
signal = ccf->getSignal();
|
||||||
|
else
|
||||||
|
signal = wsignal.toInt() + 11;
|
||||||
|
ccf->setSignal(QString::number(signal), wsecu);
|
||||||
setTrayIconOfWifi(wsignal.toInt());
|
setTrayIconOfWifi(wsignal.toInt());
|
||||||
activeWifiSignalLv = wsignal.toInt();
|
activeWifiSignalLv = wsignal.toInt();
|
||||||
//objKyDBus->getWifiMac(wname);
|
//objKyDBus->getWifiMac(wname);
|
||||||
|
@ -2341,6 +2347,11 @@ void MainWindow::loadWifiListDone(QStringList slist)
|
||||||
ccf->setTopItem(false);
|
ccf->setTopItem(false);
|
||||||
currSelNetName = "";
|
currSelNetName = "";
|
||||||
syslog(LOG_DEBUG, "already insert an active wifi in the top of wifi list");
|
syslog(LOG_DEBUG, "already insert an active wifi in the top of wifi list");
|
||||||
|
if (m_name.isEmpty() || m_name == "") {
|
||||||
|
dbus_wifiList.insert(0, QStringList()<<wname<<wsignal<<wsecu<<QString::number(max_freq)<<QString::number(min_freq)<<wcate);
|
||||||
|
} else {
|
||||||
|
dbus_wifiList.insert(0, QStringList()<<m_name<<wsignal<<wsecu<<QString::number(max_freq)<<QString::number(min_freq)<<wcate);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
//对于未连接的wifi
|
//对于未连接的wifi
|
||||||
wifiListWidget->resize(W_LIST_WIDGET, wifiListWidget->height() + H_NORMAL_ITEM);
|
wifiListWidget->resize(W_LIST_WIDGET, wifiListWidget->height() + H_NORMAL_ITEM);
|
||||||
|
@ -2373,6 +2384,12 @@ void MainWindow::loadWifiListDone(QStringList slist)
|
||||||
|
|
||||||
j ++;
|
j ++;
|
||||||
count ++;
|
count ++;
|
||||||
|
|
||||||
|
if (m_name.isEmpty() || m_name == "") {
|
||||||
|
dbus_wifiList.append(QStringList()<<wname<<wsignal<<wsecu<<QString::number(max_freq)<<QString::number(min_freq)<<wcate);
|
||||||
|
} else {
|
||||||
|
dbus_wifiList.append(QStringList()<<m_name<<wsignal<<wsecu<<QString::number(max_freq)<<QString::number(min_freq)<<wcate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wnames.append(wname);
|
wnames.append(wname);
|
||||||
|
@ -2409,6 +2426,7 @@ void MainWindow::loadWifiListDone(QStringList slist)
|
||||||
|
|
||||||
actWifiBssidList.clear();
|
actWifiBssidList.clear();
|
||||||
wnames.clear();
|
wnames.clear();
|
||||||
|
emit this->getWifiListFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新wifi列表
|
// 更新wifi列表
|
||||||
|
@ -2482,6 +2500,17 @@ void MainWindow::updateWifiListDone(QStringList slist)
|
||||||
}
|
}
|
||||||
wifiListWidget->resize(W_LIST_WIDGET, wifiListWidget->height() - H_NORMAL_ITEM);
|
wifiListWidget->resize(W_LIST_WIDGET, wifiListWidget->height() - H_NORMAL_ITEM);
|
||||||
break;
|
break;
|
||||||
|
//从向外提供的wifi列表中找到并删除这一行
|
||||||
|
QStringList list_to_remove;
|
||||||
|
foreach (QStringList list, dbus_wifiList) {
|
||||||
|
if (list.at(0).trimmed() == lastWname) {
|
||||||
|
list_to_remove = list;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!list_to_remove.isEmpty()) {
|
||||||
|
dbus_wifiList.removeOne(list_to_remove);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2574,6 +2603,11 @@ void MainWindow::updateWifiListDone(QStringList slist)
|
||||||
addItem->move(L_VERTICAL_LINE_TO_ITEM, posY);
|
addItem->move(L_VERTICAL_LINE_TO_ITEM, posY);
|
||||||
addItem->setSelected(false, false);
|
addItem->setSelected(false, false);
|
||||||
addItem->show();
|
addItem->show();
|
||||||
|
if (m_name.isEmpty() || m_name == "") {
|
||||||
|
dbus_wifiList.append(QStringList()<<wname<<wsignal<<wsecu<<QString::number(max_freq)<<QString::number(min_freq)<<wcate);
|
||||||
|
} else {
|
||||||
|
dbus_wifiList.append(QStringList()<<m_name<<wsignal<<wsecu<<QString::number(max_freq)<<QString::number(min_freq)<<wcate);
|
||||||
|
}
|
||||||
|
|
||||||
count += 1;
|
count += 1;
|
||||||
}
|
}
|
||||||
|
@ -2585,6 +2619,7 @@ void MainWindow::updateWifiListDone(QStringList slist)
|
||||||
this->wifiListWidget->show();
|
this->wifiListWidget->show();
|
||||||
this->topWifiListWidget->show();
|
this->topWifiListWidget->show();
|
||||||
this->stopLoading();
|
this->stopLoading();
|
||||||
|
emit this->getWifiListFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
//用于中英文系统有线网络名称国际话
|
//用于中英文系统有线网络名称国际话
|
||||||
|
@ -3884,6 +3919,11 @@ int MainWindow::getScreenGeometry(QString methodName)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::requestRefreshWifiList()
|
||||||
|
{
|
||||||
|
this->ksnm->execGetWifiList(this->wcardname);
|
||||||
|
}
|
||||||
|
|
||||||
/* get primary screen changed */
|
/* get primary screen changed */
|
||||||
void MainWindow::priScreenChanged(int x, int y, int width, int height)
|
void MainWindow::priScreenChanged(int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
|
|
|
@ -185,6 +185,8 @@ public:
|
||||||
int addNumberForWifi = 0; //短时间内收到关于wifi连接信号的次数
|
int addNumberForWifi = 0; //短时间内收到关于wifi连接信号的次数
|
||||||
bool isHuaWeiPC;
|
bool isHuaWeiPC;
|
||||||
bool canReconnectWifiTimeInterval = true;
|
bool canReconnectWifiTimeInterval = true;
|
||||||
|
QVector<QStringList> dbus_wifiList; //其他组件通过dbus接口获取到的wifi列表,第一个元素一定为已连接wifi,若没有已连接wifi则显示为--
|
||||||
|
void requestRefreshWifiList(); //申请刷新wifi列表
|
||||||
|
|
||||||
QString currSelNetName = ""; //当前ScrollArea中选中的网络名称
|
QString currSelNetName = ""; //当前ScrollArea中选中的网络名称
|
||||||
QStringList canReconnectWifiList; //当前可以回连的wifi列表
|
QStringList canReconnectWifiList; //当前可以回连的wifi列表
|
||||||
|
@ -403,6 +405,7 @@ signals:
|
||||||
void waitLanStop();
|
void waitLanStop();
|
||||||
void reConnectWifi(const QString& uuid);
|
void reConnectWifi(const QString& uuid);
|
||||||
void actWifiSignalLvChanaged(const int& currentLevel);
|
void actWifiSignalLvChanaged(const int& currentLevel);
|
||||||
|
void getWifiListFinished();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|
|
@ -52,6 +52,7 @@ OneConnForm::OneConnForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf
|
||||||
ui->lbConned->setAlignment(Qt::AlignLeft);
|
ui->lbConned->setAlignment(Qt::AlignLeft);
|
||||||
ui->lePassword->setEchoMode(QLineEdit::Normal);
|
ui->lePassword->setEchoMode(QLineEdit::Normal);
|
||||||
ui->lePassword->setContextMenuPolicy(Qt::NoContextMenu);
|
ui->lePassword->setContextMenuPolicy(Qt::NoContextMenu);
|
||||||
|
ui->lePassword->setTextMargins(0,0,24,0);
|
||||||
ui->btnConnPWD->setEnabled(false);
|
ui->btnConnPWD->setEnabled(false);
|
||||||
|
|
||||||
leQssLow = "QLineEdit{border:none;background:transparent;font-size:14px;}";
|
leQssLow = "QLineEdit{border:none;background:transparent;font-size:14px;}";
|
||||||
|
@ -436,6 +437,7 @@ void OneConnForm::setLine(bool isShow)
|
||||||
|
|
||||||
void OneConnForm::setSignal(QString lv, QString secu, QString category)
|
void OneConnForm::setSignal(QString lv, QString secu, QString category)
|
||||||
{
|
{
|
||||||
|
this->m_signal = lv.toInt();
|
||||||
int signal = lv.toInt();
|
int signal = lv.toInt();
|
||||||
if (secu == "--" || secu == "") {
|
if (secu == "--" || secu == "") {
|
||||||
hasPwd = false;
|
hasPwd = false;
|
||||||
|
@ -499,6 +501,11 @@ void OneConnForm::setSignal(QString lv, QString secu, QString category)
|
||||||
ui->lbSignal->setStyleSheet(signalStyle);
|
ui->lbSignal->setStyleSheet(signalStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int OneConnForm::getSignal()
|
||||||
|
{
|
||||||
|
return this->m_signal;
|
||||||
|
}
|
||||||
|
|
||||||
void OneConnForm::setWifiInfo(QString str1, QString str2, QString str3, int freq)
|
void OneConnForm::setWifiInfo(QString str1, QString str2, QString str3, int freq)
|
||||||
{
|
{
|
||||||
//freq 0:含2.4G和5G, 1:只有2.4G, 2:只有5G
|
//freq 0:含2.4G和5G, 1:只有2.4G, 2:只有5G
|
||||||
|
|
|
@ -67,6 +67,7 @@ public:
|
||||||
|
|
||||||
// category:1->normal protocol 1->wifi 6 2->wifi 6+
|
// category:1->normal protocol 1->wifi 6 2->wifi 6+
|
||||||
void setSignal(QString lv, QString secu,QString category = "0");
|
void setSignal(QString lv, QString secu,QString category = "0");
|
||||||
|
int getSignal();
|
||||||
void setWifiName(QString name, QString bssid, QString uuid, QString isname, bool isHW);
|
void setWifiName(QString name, QString bssid, QString uuid, QString isname, bool isHW);
|
||||||
QString getName();
|
QString getName();
|
||||||
void setRate(QString rate);
|
void setRate(QString rate);
|
||||||
|
@ -97,6 +98,7 @@ public:
|
||||||
bool isConnected;
|
bool isConnected;
|
||||||
bool isTopItem;
|
bool isTopItem;
|
||||||
int signalLv;
|
int signalLv;
|
||||||
|
int m_signal;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void waitAnimStep();
|
void waitAnimStep();
|
||||||
|
|
Loading…
Reference in New Issue