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
|
2023-04-21 10:03:57 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2021-10-27 12:28:16 +08:00
|
|
|
* (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 NETCONNECT_H
|
|
|
|
#define NETCONNECT_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QtPlugin>
|
|
|
|
#include <QTranslator>
|
|
|
|
#include <QApplication>
|
|
|
|
|
|
|
|
#include <QNetworkInterface>
|
|
|
|
#include <QtNetwork/QNetworkConfigurationManager>
|
|
|
|
#include <QtNetwork/QtNetwork>
|
|
|
|
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QStringList>
|
|
|
|
#include <QString>
|
|
|
|
#include <QGSettings>
|
|
|
|
#include <QListWidget>
|
|
|
|
#include <QListWidgetItem>
|
|
|
|
#include <QMap>
|
|
|
|
#include <QPropertyAnimation>
|
|
|
|
#include <QPoint>
|
|
|
|
|
|
|
|
#include <QDBusMessage>
|
|
|
|
#include <QDBusObjectPath>
|
|
|
|
#include <QDBusInterface>
|
|
|
|
#include <QDBusReply>
|
|
|
|
|
|
|
|
#include "interface.h"
|
|
|
|
#include "addbtn.h"
|
|
|
|
#include "fixlabel.h"
|
|
|
|
#include "hoverbtn.h"
|
|
|
|
#include "lanitem.h"
|
|
|
|
#include "deviceframe.h"
|
|
|
|
#include "itemframe.h"
|
2022-05-27 09:46:05 +08:00
|
|
|
#include "kwidget.h"
|
|
|
|
#include "kswitchbutton.h"
|
|
|
|
|
|
|
|
using namespace kdk;
|
2021-10-27 12:28:16 +08:00
|
|
|
|
|
|
|
enum {
|
|
|
|
DISCONNECTED,
|
|
|
|
NOINTERNET,
|
|
|
|
CONNECTED
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class NetConnect;
|
|
|
|
}
|
|
|
|
|
|
|
|
class NetConnect : public QObject, CommonInterface
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_PLUGIN_METADATA(IID "org.ukcc.CommonInterface")
|
|
|
|
Q_INTERFACES(CommonInterface)
|
|
|
|
|
|
|
|
public:
|
|
|
|
NetConnect();
|
|
|
|
~NetConnect();
|
|
|
|
|
|
|
|
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 initSearchText();
|
|
|
|
void initComponent();
|
|
|
|
void runExternalApp();
|
|
|
|
|
2021-11-03 11:48:45 +08:00
|
|
|
void showDesktopNotify(const QString &message);
|
|
|
|
|
2021-10-27 12:28:16 +08:00
|
|
|
|
|
|
|
//开关相关
|
|
|
|
void setSwitchStatus();
|
|
|
|
void hideLayout(QVBoxLayout * layout);
|
|
|
|
void showLayout(QVBoxLayout * layout);
|
|
|
|
|
|
|
|
int getInsertPos(QString connName, QString deviceName);
|
|
|
|
|
|
|
|
|
2023-04-07 14:20:19 +08:00
|
|
|
void deleteOneLan(QString ssid, int type);
|
2021-10-27 12:28:16 +08:00
|
|
|
void activeConnect(QString ssid, QString deviceName, int type);
|
|
|
|
void deActiveConnect(QString ssid, QString deviceName, int type);
|
|
|
|
|
|
|
|
//获取设备列表
|
|
|
|
void getDeviceStatusMap(QMap<QString, bool> &map);
|
|
|
|
void initNet();
|
|
|
|
void initNetListFromDevice(QString deviceName);
|
|
|
|
//处理列表增加
|
|
|
|
void addLanItem(ItemFrame *frame, QString devName, QStringList infoList, bool isActived);
|
|
|
|
//增加设备
|
|
|
|
void addDeviceFrame(QString devName);
|
|
|
|
//减少设备
|
|
|
|
void removeDeviceFrame(QString devName);
|
|
|
|
//增加一项
|
|
|
|
void addOneLanFrame(ItemFrame *frame, QString devName, QStringList infoList);
|
|
|
|
//减少一项
|
|
|
|
void removeOneLanFrame(ItemFrame *frame, QString deviceName, QString uuid);
|
|
|
|
|
|
|
|
//单个lan连接状态变化
|
|
|
|
void itemActiveConnectionStatusChanged(LanItem *item, int status);
|
|
|
|
|
2023-04-07 14:20:19 +08:00
|
|
|
bool LaunchApp(QString desktopFile);
|
2023-04-12 16:46:45 +08:00
|
|
|
|
|
|
|
bool isExitWiredDevice();
|
|
|
|
|
2021-10-27 12:28:16 +08:00
|
|
|
protected:
|
|
|
|
bool eventFilter(QObject *w,QEvent *e);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Ui::NetConnect *ui;
|
|
|
|
|
|
|
|
QString pluginName;
|
|
|
|
int pluginType;
|
|
|
|
QWidget *pluginWidget;
|
|
|
|
|
|
|
|
QDBusInterface *m_interface = nullptr;
|
2022-05-27 09:46:05 +08:00
|
|
|
KSwitchButton *wiredSwitch;
|
2021-10-27 12:28:16 +08:00
|
|
|
|
|
|
|
bool mFirstLoad;
|
|
|
|
QGSettings *m_switchGsettings;
|
|
|
|
|
|
|
|
QMap<QString, bool> deviceStatusMap;
|
|
|
|
QMap<QString, ItemFrame *> deviceFrameMap;
|
|
|
|
|
2023-04-12 16:46:45 +08:00
|
|
|
bool needLoad;
|
|
|
|
|
2021-10-27 12:28:16 +08:00
|
|
|
private slots:
|
|
|
|
void updateLanInfo(QString deviceName, QStringList lanInfo);
|
|
|
|
|
|
|
|
void onLanAdd(QString deviceName, QStringList lanInfo);
|
|
|
|
void onLanRemove(QString dbusPath);
|
|
|
|
|
|
|
|
void onActiveConnectionChanged(QString deviceName, QString uuid, int status);
|
|
|
|
|
|
|
|
void onDeviceStatusChanged();
|
|
|
|
void onDeviceNameChanged(QString, QString, int);
|
|
|
|
};
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(QList<QDBusObjectPath>);
|
|
|
|
|
|
|
|
#endif // NETCONNECT_H
|