2021-10-27 12:28:16 +08:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
*
|
|
|
|
* 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 2 of the License, 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, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef WLANCONNECT_H
|
|
|
|
#define WLANCONNECT_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QtPlugin>
|
|
|
|
|
|
|
|
#include <QNetworkInterface>
|
|
|
|
#include <QtNetwork/QNetworkConfigurationManager>
|
|
|
|
#include <QtNetwork/QtNetwork>
|
|
|
|
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QStringList>
|
|
|
|
#include <QString>
|
|
|
|
#include <QGSettings>
|
|
|
|
#include <QListWidget>
|
|
|
|
#include <QListWidgetItem>
|
|
|
|
#include <QMap>
|
|
|
|
|
|
|
|
#include <QDBusMessage>
|
|
|
|
#include <QDBusObjectPath>
|
|
|
|
#include <QDBusInterface>
|
|
|
|
#include <QDBusReply>
|
|
|
|
|
|
|
|
#include <interface.h>
|
|
|
|
#include "hoverbtn.h"
|
|
|
|
#include "itemframe.h"
|
|
|
|
#include "wlanitem.h"
|
2022-05-27 09:01:18 +08:00
|
|
|
#include "kwidget.h"
|
|
|
|
#include "kswitchbutton.h"
|
|
|
|
|
|
|
|
using namespace kdk;
|
|
|
|
|
2021-10-27 12:28:16 +08:00
|
|
|
namespace Ui {
|
|
|
|
class WlanConnect;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class WlanConnect : public QObject, CommonInterface
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_PLUGIN_METADATA(IID "org.kycc.CommonInterface")
|
|
|
|
Q_INTERFACES(CommonInterface)
|
|
|
|
|
|
|
|
public:
|
|
|
|
WlanConnect();
|
|
|
|
~WlanConnect();
|
|
|
|
|
|
|
|
QString plugini18nName() Q_DECL_OVERRIDE;
|
|
|
|
int pluginTypes() Q_DECL_OVERRIDE;
|
|
|
|
QWidget * pluginUi() Q_DECL_OVERRIDE;
|
|
|
|
const QString name() const Q_DECL_OVERRIDE;
|
|
|
|
bool isShowOnHomePage() const Q_DECL_OVERRIDE;
|
|
|
|
QIcon icon() const Q_DECL_OVERRIDE;
|
|
|
|
bool isEnable() const Q_DECL_OVERRIDE;
|
|
|
|
QString translationPath() const Q_DECL_OVERRIDE;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void initComponent();
|
|
|
|
void runExternalApp();
|
|
|
|
void initSearchText();
|
|
|
|
|
2021-11-03 11:48:45 +08:00
|
|
|
void showDesktopNotify(const QString &message);
|
|
|
|
|
2021-10-27 12:28:16 +08:00
|
|
|
//点击item 连接/断开
|
|
|
|
void activeConnect(QString netName, QString deviceName, int type);
|
|
|
|
void deActiveConnect(QString netName, QString deviceName, int type);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int sortWlanNet(QString deviceName, QString name, QString signal);
|
2022-05-24 14:51:22 +08:00
|
|
|
void updateIcon(WlanItem *item, QString signalStrength, QString security, QString isApConnection, int category);
|
2021-10-27 12:28:16 +08:00
|
|
|
void resortWifiList(ItemFrame *frame, QVector<QStringList> list);
|
|
|
|
|
|
|
|
|
|
|
|
//单wifi图标
|
|
|
|
int setSignal(QString lv);
|
2022-05-24 14:51:22 +08:00
|
|
|
QString wifiIcon(bool isLock, int strength, int category);
|
2021-10-27 12:28:16 +08:00
|
|
|
|
|
|
|
|
|
|
|
//开关相关
|
|
|
|
void hideLayout(QVBoxLayout * layout);
|
|
|
|
void showLayout(QVBoxLayout * layout);
|
|
|
|
|
|
|
|
|
|
|
|
//获取设备列表
|
|
|
|
void getDeviceList(QStringList &list);
|
|
|
|
//初始化设备wifi列表
|
|
|
|
void initNet();
|
|
|
|
void initNetListFromDevice(QString deviceName);
|
|
|
|
//处理列表 已连接
|
|
|
|
void addActiveItem(ItemFrame *frame, QString devName, QStringList infoList);
|
|
|
|
//处理列表 未连接
|
|
|
|
void addCustomItem(ItemFrame *frame, QString devName, QStringList infoList);
|
|
|
|
//增加设备
|
|
|
|
void addDeviceFrame(QString devName);
|
|
|
|
//减少设备
|
|
|
|
void removeDeviceFrame(QString devName);
|
|
|
|
//增加ap
|
2022-05-24 14:51:22 +08:00
|
|
|
void addOneWlanFrame(ItemFrame *frame, QString deviceName, QString name, QString signal, QString uuid, bool isLock, bool status, int type, QString isApConnection, int category);
|
2021-10-27 12:28:16 +08:00
|
|
|
//减少ap
|
|
|
|
void removeOneWlanFrame(ItemFrame *frame, QString deviceName, QString ssid);
|
|
|
|
|
|
|
|
|
|
|
|
//单个wifi连接状态变化
|
|
|
|
void itemActiveConnectionStatusChanged(WlanItem *item, int status);
|
2022-08-18 15:35:40 +08:00
|
|
|
|
|
|
|
void initSwtichState();
|
|
|
|
inline void setSwitchBtnEnable(bool state) {
|
|
|
|
if (m_wifiSwitch != nullptr) {
|
2023-04-06 14:09:59 +08:00
|
|
|
m_wifiSwitch->setEnabled(state);
|
2022-08-18 15:35:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
inline bool getSwitchBtnEnable() {
|
|
|
|
if (m_wifiSwitch != nullptr) {
|
2023-04-06 14:09:59 +08:00
|
|
|
return m_wifiSwitch->isEnabled();
|
2022-08-18 15:35:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void setSwitchBtnState(bool state) {
|
|
|
|
if (m_wifiSwitch != nullptr) {
|
|
|
|
m_wifiSwitch->blockSignals(true);
|
|
|
|
m_wifiSwitch->setChecked(state);
|
|
|
|
m_wifiSwitch->blockSignals(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
inline bool getSwitchBtnState() {
|
|
|
|
if (m_wifiSwitch != nullptr) {
|
|
|
|
return m_wifiSwitch->isChecked();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-10-27 12:28:16 +08:00
|
|
|
protected:
|
|
|
|
bool eventFilter(QObject *w,QEvent *e);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Ui::WlanConnect *ui;
|
|
|
|
|
|
|
|
QString pluginName;
|
|
|
|
int pluginType;
|
|
|
|
QWidget *pluginWidget;
|
|
|
|
|
|
|
|
QDBusInterface *m_interface = nullptr;
|
|
|
|
|
|
|
|
//设备列表
|
|
|
|
QStringList deviceList;
|
|
|
|
//设备名 + 单设备frame
|
|
|
|
QMap<QString, ItemFrame *> deviceFrameMap;
|
|
|
|
|
|
|
|
//QVector<QStringList> wlanSignalList;
|
|
|
|
// DeviceWlanlistInfo deviceWlanlistInfo;
|
|
|
|
|
|
|
|
QTimer * m_scanTimer = nullptr;
|
2021-10-28 12:50:05 +08:00
|
|
|
// QTimer * m_updateTimer = nullptr;
|
2021-10-27 12:28:16 +08:00
|
|
|
private:
|
2022-05-27 09:01:18 +08:00
|
|
|
KSwitchButton *m_wifiSwitch;
|
2021-11-04 09:44:25 +08:00
|
|
|
bool m_firstLoad;
|
2021-10-27 12:28:16 +08:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
|
|
|
void onNetworkAdd(QString deviceName, QStringList wlanInfo);
|
|
|
|
void onNetworkRemove(QString deviceName, QString wlannName);
|
|
|
|
void onActiveConnectionChanged(QString deviceName, QString ssid, QString uuid, int status);
|
|
|
|
|
|
|
|
void updateList();
|
|
|
|
void onDeviceStatusChanged();
|
|
|
|
void onDeviceNameChanged(QString, QString, int);
|
|
|
|
|
2022-08-18 15:35:40 +08:00
|
|
|
void onSwitchBtnChanged(bool);
|
|
|
|
|
2021-10-27 12:28:16 +08:00
|
|
|
void reScan();
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
#endif // WLANCONNECT_H
|