diff --git a/BiometricAuth/BiometricAuth.pri b/BiometricAuth/BiometricAuth.pri
deleted file mode 100644
index cbb2ea1..0000000
--- a/BiometricAuth/BiometricAuth.pri
+++ /dev/null
@@ -1,9 +0,0 @@
-SOURCES += \
- $$PWD/biometricproxy.cpp \
- $$PWD/biometricauthwidget.cpp \
- $$PWD/biometricdeviceswidget.cpp
-
-HEADERS += \
- $$PWD/biometricproxy.h \
- $$PWD/biometricauthwidget.h \
- $$PWD/biometricdeviceswidget.h
diff --git a/BiometricAuth/BiometricAuth.pro b/BiometricAuth/BiometricAuth.pro
deleted file mode 100644
index 00bc543..0000000
--- a/BiometricAuth/BiometricAuth.pro
+++ /dev/null
@@ -1,37 +0,0 @@
-#-------------------------------------------------
-#
-# Project created by QtCreator 2018-12-06T09:17:41
-#
-#-------------------------------------------------
-
-QT += core gui dbus
-
-greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
-
-TARGET = BiometricAuth
-TEMPLATE = app
-
-# The following define makes your compiler emit warnings if you use
-# any feature of Qt which has been marked as deprecated (the exact warnings
-# depend on your compiler). Please consult the documentation of the
-# deprecated API in order to know how to port your code away from it.
-DEFINES += QT_DEPRECATED_WARNINGS
-
-# You can also make your code fail to compile if you use deprecated APIs.
-# In order to do so, uncomment the following line.
-# You can also select to disable deprecated APIs only up to a certain version of Qt.
-#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
-
-
-SOURCES += \
- main.cpp \
- biometricauthwidget.cpp \
- biometricproxy.cpp \
- biometricdeviceswidget.cpp
-
-HEADERS += \
- biometricauthwidget.h \
- biometricproxy.h \
- biometricdeviceswidget.h
-
-FORMS +=
diff --git a/BiometricAuth/CMakeLists.txt b/BiometricAuth/CMakeLists.txt
deleted file mode 100644
index e1b52a5..0000000
--- a/BiometricAuth/CMakeLists.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-qt5_wrap_cpp(BiometricAuth_SRC
- biometricdeviceinfo.h
- biometricproxy.h
- giodbus.h
- uniauthservice.h
- )
-
-set(BiometricAuth_SRC
- ${BiometricAuth_SRC}
- biometricdeviceinfo.cpp
- biometricproxy.cpp
- giodbus.cpp
- uniauthservice.cpp
- )
-
-include_directories(
- ${Qt5Core_INCLUDE_DIRS}
- ${Qt5Widgets_INCLUDE_DIRS}
- ${Qt5DBus_INCLUDE_DIRS}
- ${GLIB2_INCLUDE_DIRS}
- ${GIOUNIX2_INCLUDE_DIRS}
- )
-
-
-add_library(BiometricAuth STATIC ${BiometricAuth_SRC})
-target_link_libraries(BiometricAuth Qt5::Core Qt5::DBus Qt5::Widgets
- ${GIOUNIX2_LIBRARIES})
diff --git a/BiometricAuth/biometricauthwidget.cpp b/BiometricAuth/biometricauthwidget.cpp
deleted file mode 100644
index 4a03938..0000000
--- a/BiometricAuth/biometricauthwidget.cpp
+++ /dev/null
@@ -1,343 +0,0 @@
-/*
- * Copyright (C) 2018 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 .
- *
-**/
-#include "biometricauthwidget.h"
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-
-#include "giodbus.h"
-
-BiometricAuthWidget::BiometricAuthWidget(BiometricProxy *proxy, QWidget *parent) :
- QWidget(parent),
- proxy(proxy),
- isInAuth(false),
- movieTimer(nullptr),
- failedCount(0),
- timeoutCount(0),
- beStopped(false),
- retrytimer(nullptr),
- usebind(false)
-{
- usebind = getAuthDouble();
- initUI();
- resize(400, 260);
-
- if(this->proxy)
- {
- connect(this->proxy, &BiometricProxy::StatusChanged,
- this, &BiometricAuthWidget::onStatusChanged);
-
- connect(this->proxy, &BiometricProxy::FrameWritten,
- this, &BiometricAuthWidget::onFrameWritten);
- }
-
-}
-
-void BiometricAuthWidget::initUI()
-{
- //显示提示信息
- lblNotify = new QLabel(this);
- lblNotify->setWordWrap(true);
- lblNotify->setAlignment(Qt::AlignHCenter | Qt::AlignBottom);
-
- //显示当前设备
- lblDevice = new QLabel(this);
- lblDevice->setWordWrap(true);
- lblDevice->setAlignment(Qt::AlignCenter);
-
- //显示图片
- lblImage = new QLabel(this);
- lblImage->setFixedSize(100, 100);
-
-}
-
-
-void BiometricAuthWidget::resizeEvent(QResizeEvent */*event*/)
-{
- lblNotify->setGeometry(0, 0, width(), 45);
- lblDevice->setGeometry(0, lblNotify->geometry().bottom()+5, width(), 30);
- lblImage->setGeometry((width() - lblImage->width()) / 2,
- lblDevice->geometry().bottom() + 10,
- lblImage->width(), lblImage->height());
- //qDebug()
-}
-
-void BiometricAuthWidget::startAuth(DeviceInfoPtr device, int uid)
-{
- if(!proxy)
- {
- qWarning() << "BiometricProxy doesn't exist.";
- return;
- }
-
- if(isInAuth)
- {
- qDebug() << "Identification is currently under way, stop it";
- stopAuth();
- }
-
- this->device = device;
- this->uid = uid;
- this->userName = getpwuid(uid)->pw_name;
- this->failedCount = 0;
- this->timeoutCount = 0;
- this->beStopped = false;
- proxy->StopOps(device->id);
- startAuth_();
-
- if(device->deviceType != DeviceType::Type::Face){
- updateImage(1);
- }
-
-}
-
-void BiometricAuthWidget::startAuth_()
-{
- lblDevice->setText(tr("Current device: ") + device->shortName);
-
- //qDebug().noquote() << QString("Identify:[drvid: %1, uid: %2]").arg(1).arg(2);
-
- isInAuth = true;
- dup_fd = -1;
-
- QDBusPendingCall call = proxy->Identify(device->id, uid);
- QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
- connect(watcher, &QDBusPendingCallWatcher::finished,
- this, &BiometricAuthWidget::onIdentifyComplete);
-
-}
-
-void BiometricAuthWidget::stopAuth()
-{
- beStopped = true;
- if(!isInAuth)
- {
- return;
- }
-
- proxy->StopOps(device->id);
- if(retrytimer&&retrytimer->isActive()){
- retrytimer->stop();
- delete retrytimer;
- retrytimer = nullptr;
- }
- isInAuth = false;
- updateImage(0);
-}
-
-void BiometricAuthWidget::onIdentifyComplete(QDBusPendingCallWatcher *watcher)
-{
- QDBusPendingReply reply = *watcher;
- if(reply.isError())
- {
- qWarning() << "Identify error: " << reply.error().message();
- Q_EMIT authComplete(false);
- updateImage(0);
- return;
- }
- int result = reply.argumentAt(0).toInt();
- int authUid = reply.argumentAt(1).toInt();
-
- // 特征识别成功,而且用户id匹配
- if(result == DBUS_RESULT_SUCCESS && authUid == uid)
- {
- qDebug() << "Identify success";
- Q_EMIT authComplete(true);
- }
- // 特征识别不匹配
- else if(result == DBUS_RESULT_NOTMATCH)
- {
- if(usebind){
- Q_EMIT authComplete(false);
- return;
- }
- qDebug() << "Identify failed";
- failedCount++;
- if(failedCount >= GetMaxFailedAutoRetry(userName))
- {
- Q_EMIT authComplete(false);
- }
- else
- {
- lblNotify->setText(tr("Identify failed, Please retry."));
- if(!beStopped){
- // QTimer::singleShot(1000, this, &BiometricAuthWidget::startAuth_);
- if(!retrytimer){
- retrytimer = new QTimer(this);
- retrytimer->setSingleShot(true);
- connect(retrytimer, &QTimer::timeout, this, &BiometricAuthWidget::startAuth_);
- }
- retrytimer->start(1000);
- }
- }
- }
- //识别发生错误
- else if(result == DBUS_RESULT_ERROR)
- {
- if(usebind){
- Q_EMIT authComplete(false);
- return;
- }
- StatusReslut ret = proxy->UpdateStatus(device->id);
- //识别操作超时
- if(ret.result == 0 && ret.opsStatus == OPS_IDENTIFY_TIMEOUT)
- {
- timeoutCount++;
- if(timeoutCount >= GetMaxTimeoutAutoRetry(userName))
- {
- Q_EMIT authComplete(false);
- }
- else
- {
- QTimer::singleShot(1000, [&]{
- if(!beStopped)
- {
- startAuth_();
- }
- });
- }
- }else{
- Q_EMIT authComplete(false);
- }
- }else{
- Q_EMIT authComplete(false);
- }
- updateImage(0);
-}
-
-void BiometricAuthWidget::onFrameWritten(int drvid)
-{
-
- if(dup_fd == -1){
- dup_fd = get_server_gvariant_stdout(drvid);
- }
-
- if(dup_fd <= 0)
- return ;
-
- cv::Mat img;
- lseek(dup_fd, 0, SEEK_SET);
- char base64_bufferData[1024*1024];
- int rc = read(dup_fd, base64_bufferData, 1024*1024);
- printf("rc = %d\n", rc);
-
- cv::Mat mat2(1, sizeof(base64_bufferData), CV_8U, base64_bufferData);
- img = cv::imdecode(mat2, cv::IMREAD_COLOR);
- cv::cvtColor(img,img,cv::COLOR_BGR2RGB);
-
- QImage srcQImage = QImage((uchar*)(img.data), img.cols, img.rows, QImage::Format_RGB888);
- lblImage->setFixedSize(160,160);
- lblImage->setGeometry((width() - lblImage->width()) / 2,
- lblDevice->geometry().bottom() + 10,
- lblImage->width(), lblImage->height());
- lblImage->setPixmap(QPixmap::fromImage(srcQImage).scaled(lblImage->size()));
-
-}
-
-void BiometricAuthWidget::onStatusChanged(int drvid, int status)
-{
- if(!isInAuth)
- {
- return;
- }
- if(drvid != device->id)
- {
- return;
- }
-
- // 显示来自服务的提示信息
- if(status == STATUS_NOTIFY)
- {
- QString notifyMsg = proxy->GetNotifyMesg(drvid);
- lblNotify->setText(notifyMsg);
- }
-}
-
-static int count = 0;
-void BiometricAuthWidget::updateImage(int type)
-{
- if(device->deviceType == DeviceType::Type::Face)
- return ;
-
- if(type == 0)
- {
- if(movieTimer && movieTimer->isActive())
- {
- movieTimer->stop();
- }
-
- QString imagePath = QString(UKUI_BIOMETRIC_IMAGES_PATH "%1/01.png")
- .arg(DeviceType::getDeviceType(device->deviceType));
- setImage(imagePath);
- }
- else
- {
- if(!movieTimer)
- {
- movieTimer = new QTimer(this);
- movieTimer->setInterval(100);
- connect(movieTimer, &QTimer::timeout,
- this, &BiometricAuthWidget::onMoviePixmapUpdate);
- }
- count = 0;
- movieTimer->start();
- }
-}
-
-void BiometricAuthWidget::onMoviePixmapUpdate()
-{
- if(count >= 18)
- {
- count = 0;
- }
- count++;
- QString fileName = (count < 10 ? "0" : "") + QString::number(count);
- QString imagePath = QString(UKUI_BIOMETRIC_IMAGES_PATH "%1/%2.png")
- .arg(DeviceType::getDeviceType(device->deviceType))
- .arg(fileName);
- setImage(imagePath);
-}
-
-void BiometricAuthWidget::setImage(const QString &path)
-{
- QPixmap image(path);
- image = image.scaled(lblImage->width(), lblImage->height(),
- Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
-
- lblImage->setPixmap(image);
-}
-
-bool BiometricAuthWidget::getAuthDouble()
-{
- QSettings settings("/etc/biometric-auth/ukui-biometric.conf", QSettings::IniFormat);
- bool distribId = settings.value("DoubleAuth").toBool();
- return distribId;
-}
-
-void BiometricAuthWidget::setMinImage(float val)
-{
- resize(400,100+100*val);
- lblImage->setFixedSize(100*val, 100*val);
-}
diff --git a/BiometricAuth/biometricauthwidget.h b/BiometricAuth/biometricauthwidget.h
deleted file mode 100644
index 8390a02..0000000
--- a/BiometricAuth/biometricauthwidget.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2018 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 .
- *
-**/
-#ifndef BIOMETRICAUTHWIDGET_H
-#define BIOMETRICAUTHWIDGET_H
-
-#include
-#include "biometricproxy.h"
-
-class QLabel;
-//class QDBusPendingCallWatcher;
-//class BiometricProxy;
-//class DeviceIdentityPtr;
-class BiometricAuthWidget : public QWidget
-{
- Q_OBJECT
-public:
- explicit BiometricAuthWidget(BiometricProxy *proxy, QWidget *parent = 0);
-
- /**
- * @brief 进行生物识别认证
- * @param deviceInfo 使用的设备
- * @param uid 待认证的用户id
- */
- void startAuth(DeviceInfoPtr device, int uid);
-
- /**
- * @brief 终止生物识别认证
- */
- void stopAuth();
-
- bool isAuthenticating() { return isInAuth; }
-
- void setMinImage(float val);
-
-protected:
- void resizeEvent(QResizeEvent *event);
-
-Q_SIGNALS:
- /**
- * @brief 认证完成
- * @param result 认证结果
- */
- void authComplete(bool result);
-
-private Q_SLOTS:
- void onIdentifyComplete(QDBusPendingCallWatcher *watcher);
- void onStatusChanged(int drvid, int status);
- void onFrameWritten(int drvid);
- void onMoviePixmapUpdate();
- void startAuth_();
-
-private:
- void initUI();
- void updateImage(int type = 0);
- void setImage(const QString &path);
- bool getAuthDouble();
-
-private:
- QLabel *lblNotify;
- QLabel *lblDevice;
- QLabel *lblImage;
-
- BiometricProxy *proxy;
- int uid;
- QString userName;
- DeviceInfoPtr device;
- bool isInAuth;
- QTimer *movieTimer;
- int failedCount;
- int timeoutCount;
- bool beStopped;
- QTimer *retrytimer;
- bool usebind;
- int fd = -1;
- int dup_fd = -1;
-};
-
-#endif // BIOMETRICAUTHWIDGET_H
diff --git a/BiometricAuth/biometricdeviceinfo.cpp b/BiometricAuth/biometricdeviceinfo.cpp
deleted file mode 100644
index 881c79a..0000000
--- a/BiometricAuth/biometricdeviceinfo.cpp
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- * Copyright (C) 2018 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 .
- *
-**/
-#include "biometricdeviceinfo.h"
-
-#include
-#include
-#include
-//#include
-
-QString DeviceType::getDeviceType(int deviceType)
-{
- if(deviceType >= __MAX_NR_TYPES)
- {
- return "";
- }
- QMetaEnum meta = QMetaEnum::fromType();
- const char *typeString = meta.valueToKey(deviceType);
- return QString(typeString);
-}
-
-int DeviceType::getBioType(int bioType)
-{
- switch(bioType)
- {
- case Face:
- return 0;
- case FingerPrint:
- return 1;
- case FingerVein:
- return 2;
- case Iris:
- return 3;
- case VoicePrint:
- return 4;
- default:
- return -1;
- }
-}
-
-QString DeviceType::getDeviceType_tr(int deviceType)
-{
- switch(deviceType)
- {
- case FingerPrint:
- return tr("FingerPrint");
- case FingerVein:
- return tr("FingerVein");
- case Iris:
- return tr("Iris");
- case Face:
- return tr("Face");
- case VoicePrint:
- return tr("VoicePrint");
- case LOGINOPT_TYPE_GENERAL_UKEY:
- return tr("Ukey");
- case REMOTE_QRCODE_TYPE:
- return tr("QRCode");
- default:
- return "";
- }
-}
-
-QDebug operator <<(QDebug stream, const DeviceInfo &deviceInfo)
-{
- stream << "["
- << deviceInfo.id
- << deviceInfo.shortName
- << deviceInfo.fullName
- << deviceInfo.deviceType
- << deviceInfo.driverEnable
- << deviceInfo.deviceNum
- << "]";
- return stream;
-}
-
-QDBusArgument &operator <<(QDBusArgument &arg, const DeviceInfo &deviceInfo)
-{
- arg.beginStructure();
- arg << deviceInfo.id
- << deviceInfo.shortName
- << deviceInfo.fullName
- << deviceInfo.driverEnable
- << deviceInfo.deviceNum
- << deviceInfo.deviceType
- << deviceInfo.storageType
- << deviceInfo.eigType
- << deviceInfo.verifyType
- << deviceInfo.identifyType
- << deviceInfo.busType
- << deviceInfo.deviceStatus
- << deviceInfo.OpsStatus;
- arg.endStructure();
- return arg;
-}
-const QDBusArgument &operator >>(const QDBusArgument &arg, DeviceInfo &deviceInfo)
-{
- arg.beginStructure();
- arg >> deviceInfo.id
- >> deviceInfo.shortName
- >> deviceInfo.fullName
- >> deviceInfo.driverEnable
- >> deviceInfo.deviceNum
- >> deviceInfo.deviceType
- >> deviceInfo.storageType
- >> deviceInfo.eigType
- >> deviceInfo.verifyType
- >> deviceInfo.identifyType
- >> deviceInfo.busType
- >> deviceInfo.deviceStatus
- >> deviceInfo.OpsStatus;
- arg.endStructure();
- return arg;
-}
-
-/* For the type FeatureInfo */
-QDBusArgument &operator<<(QDBusArgument &argument, const FeatureInfo &featureInfo)
-{
- argument.beginStructure();
- argument << featureInfo.uid << featureInfo.biotype
- << featureInfo.device_shortname << featureInfo.index
- << featureInfo.index_name;
- argument.endStructure();
- return argument;
-}
-
-const QDBusArgument &operator>>(const QDBusArgument &argument, FeatureInfo &featureInfo)
-{
- argument.beginStructure();
- argument >> featureInfo.uid >> featureInfo.biotype
- >> featureInfo.device_shortname >> featureInfo.index
- >> featureInfo.index_name;
- argument.endStructure();
- return argument;
-}
-
-void registerMetaType()
-{
- qRegisterMetaType("DeviceInfo");
- qDBusRegisterMetaType();
- qRegisterMetaType("FeatureInfo");
- qDBusRegisterMetaType();
-}
-
-
-QString GetDefaultDevice(const QString &userName)
-{
- //QString configPath = QString("/home/%1/" UKUI_BIOMETRIC_CONFIG_PATH).arg(userName);
- QString configPath = QDir::homePath() + "/" + UKUI_BIOMETRIC_CONFIG_PATH;
- QSettings settings(configPath, QSettings::IniFormat);
- qDebug() << "configure path: " << settings.fileName();
-
- QString defaultDevice = settings.value("DefaultDevice").toString();
- if(defaultDevice.isEmpty())
- {
- QSettings sysSettings(UKUI_BIOMETRIC_SYS_CONFIG_PATH, QSettings::IniFormat);
- defaultDevice = sysSettings.value("DefaultDevice").toString();
- }
-
- return defaultDevice;
-}
-
-int GetLastDevice(const QString &userName)
-{
- int nLastDevId = -1;
- QSettings sysSettings(QString(SHARE_BIOMETRIC_CONFIG_PATH).arg(userName), QSettings::IniFormat);
- sysSettings.beginGroup("Common");
- if (sysSettings.allKeys().contains("LastDeviceId")) {
- nLastDevId = sysSettings.value("LastDeviceId").toInt();
- }
- sysSettings.endGroup();
- return nLastDevId;
-}
-
-void SetLastDevice(const QString &userName, int drvid)
-{
- if (drvid < 0) {
- return;
- }
- QString desConfPath = QString(SHARE_BIOMETRIC_CONFIG_PATH).arg(userName);
- QFile fileConf(desConfPath);
- if (fileConf.exists()) {
- QSettings sysSettings(desConfPath, QSettings::IniFormat);
- sysSettings.beginGroup("Common");
- sysSettings.setValue("LastDeviceId", drvid);
- sysSettings.endGroup();
- } else {
- QSettings sysSettings(desConfPath, QSettings::IniFormat);
- sysSettings.beginGroup("Common");
- sysSettings.setValue("LastDeviceId", drvid);
- sysSettings.endGroup();
- sysSettings.sync();
- QFile file(desConfPath);
- file.setPermissions(QFile::WriteUser | QFile::ReadUser | QFile::WriteOther | QFile::ReadOther);
- }
-}
-
-static int getValueFromSettings(const QString &userName, const QString &key, int defaultValue = 3)
-{
- //从家目录下的配置文件中获取
- //QString configPath = QString("/home/%1/" UKUI_BIOMETRIC_CONFIG_PATH).arg(userName);
- QString configPath = QDir::homePath() + "/" + UKUI_BIOMETRIC_CONFIG_PATH;
- QSettings settings(configPath, QSettings::IniFormat);
- QString valueStr = settings.value(key).toString();
-
- //如果没有获取到,则从系统配置文件中获取
- if(valueStr.isEmpty())
- {
- QSettings sysSettings(UKUI_BIOMETRIC_SYS_CONFIG_PATH, QSettings::IniFormat);
- valueStr = sysSettings.value(key).toString();
- }
-
- bool ok;
- int value = valueStr.toInt(&ok);
- if( (value == 0 && !ok) || valueStr.isEmpty() )
- {
- value = defaultValue;
- }
- return value;
-}
-
-bool GetHiddenSwitchButton()
-{
- QSettings sysSettings(UKUI_BIOMETRIC_SYS_CONFIG_PATH, QSettings::IniFormat);
- if(sysSettings.contains("HiddenSwitchButton"))
- return sysSettings.value("HiddenSwitchButton").toBool();
- else
- return false;
-}
-
-int GetFailedTimes()
-{
- QSettings sysSettings(UKUI_BIOMETRIC_SYS_CONFIG_PATH, QSettings::IniFormat);
- if(sysSettings.contains("MaxFailedTimes"))
- return sysSettings.value("MaxFailedTimes").toInt();
- else
- return 3;
-}
-
-bool GetAuthEnable()
-{
- bool isEnable = false;
- QSettings sysSettings(UKUI_BIOMETRIC_SYS_CONFIG_PATH, QSettings::IniFormat);
- if(sysSettings.contains("EnableAuth"))
- isEnable = sysSettings.value("EnableAuth").toBool();
- else
- isEnable = false;
-
- if(isEnable && sysSettings.allKeys().contains("EnableAuthApp")){
- int isEnableApp = sysSettings.value("EnableAuthApp").toInt();
- isEnable = isEnableApp & (1<<1);
- }
-
- return isEnable;
-}
-
-bool GetQRCodeEnable()
-{
- bool isEnable = false;
- QSettings sysSettings(UKUI_BIOMETRIC_SYS_CONFIG_PATH, QSettings::IniFormat);
- sysSettings.beginGroup("Functions");
- if (sysSettings.allKeys().contains("EnableQRCode")) {
- isEnable = sysSettings.value("EnableQRCode").toBool();
- }
- sysSettings.endGroup();
- return isEnable;
-}
-
-int GetMaxFailedAutoRetry(const QString &userName)
-{
- return getValueFromSettings(userName, "MaxFailedAutoRetry");
-}
-
-int GetMaxTimeoutAutoRetry(const QString &userName)
-{
- return getValueFromSettings(userName, "MaxTimeoutAutoRetry");
-}
diff --git a/BiometricAuth/biometricdeviceswidget.cpp b/BiometricAuth/biometricdeviceswidget.cpp
deleted file mode 100644
index 0766ae3..0000000
--- a/BiometricAuth/biometricdeviceswidget.cpp
+++ /dev/null
@@ -1,279 +0,0 @@
-/*
- * Copyright (C) 2018 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 .
- *
-**/
-#include "biometricdeviceswidget.h"
-#include
-#include
-#include
-#include
-#include
-#include
-
-
-BiometricDevicesWidget::BiometricDevicesWidget(BiometricProxy *proxy, int uid,QWidget *parent)
- : QWidget(parent),
- proxy(proxy),
- m_uid(uid)
-{
- initUI();
- if(proxy && proxy->isValid())
- {
- connect(proxy, &BiometricProxy::USBDeviceHotPlug,
- this, &BiometricDevicesWidget::onUSBDeviceHotPlug);
- updateDevice();
- }
-
- resize(500, 500);
-}
-
-void BiometricDevicesWidget::initUI()
-{
- lblPrompt = new QLabel(this);
- lblPrompt->setObjectName(QStringLiteral("lblBioetricDevicesPrompt"));
- lblPrompt->setText(tr("Please select the biometric device"));
- lblPrompt->setAlignment(Qt::AlignHCenter);
-
- lblDeviceType = new QLabel(this);
- lblDeviceType->setObjectName(QStringLiteral("lblDeviceType"));
- lblDeviceType->setText(tr("Device type:"));
- lblDeviceType->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
-
- QStyledItemDelegate* itemDelegate = new QStyledItemDelegate();
-
- cmbDeviceType = new QComboBox(this);
- cmbDeviceType->view()->parentWidget()->setWindowFlags(Qt::Popup|Qt::FramelessWindowHint);
- cmbDeviceType->view()->parentWidget()->setAttribute(Qt::WA_TranslucentBackground);
- cmbDeviceType->setObjectName(QStringLiteral("cmbDeviceType"));
- cmbDeviceType->setMaxVisibleItems(5);
- cmbDeviceType->setItemDelegate(itemDelegate);
- connect(cmbDeviceType, SIGNAL(currentIndexChanged(int)),
- this, SLOT(onCmbDeviceTypeCurrentIndexChanged(int)));
-
- lblDeviceName = new QLabel(this);
- lblDeviceName->setObjectName(QStringLiteral("lblDeviceName"));
- lblDeviceName->setText(tr("Device name:"));
- lblDeviceName->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
-
- cmbDeviceName = new QComboBox(this);
- cmbDeviceName->view()->parentWidget()->setWindowFlags(Qt::Popup|Qt::FramelessWindowHint);
- cmbDeviceName->view()->parentWidget()->setAttribute(Qt::WA_TranslucentBackground);
- cmbDeviceName->setObjectName(QStringLiteral("cmbDeviceName"));
- cmbDeviceName->setMaxVisibleItems(5);
- cmbDeviceName->setItemDelegate(itemDelegate);
-
- btnOK = new QPushButton(tr("OK"), this);
- btnOK->setObjectName(QStringLiteral("OKButton"));
- btnOK->setCursor(Qt::PointingHandCursor);
- connect(btnOK, &QPushButton::clicked,
- this, &BiometricDevicesWidget::onOKButtonClicked);
-}
-
-void BiometricDevicesWidget::setUser(int user)
-{
- m_uid = user;
-}
-
-void BiometricDevicesWidget::resizeEvent(QResizeEvent */*event*/)
-{
- lblPrompt->setGeometry(0, 0, width(), 40);
- lblDeviceType->setGeometry(100, lblPrompt->geometry().bottom() + 40,
- 120, 20);
- cmbDeviceType->setGeometry(100, lblDeviceType->geometry().bottom() + 15,
- 300, 40);
- lblDeviceName->setGeometry(100, cmbDeviceType->geometry().bottom() + 80,
- 120, 20);
- cmbDeviceName->setGeometry(100, lblDeviceName->geometry().bottom() + 15,
- 300, 40);
- btnOK->setGeometry(100, cmbDeviceName->geometry().bottom() + 80, 140, 38);
-
-}
-
-void BiometricDevicesWidget::updateDevice()
-{
- deviceMap.clear();
- DeviceList deviceList = proxy->GetDevList();
- for(auto pDeviceInfo : deviceList)
- {
- qDebug() << *pDeviceInfo;
- if(proxy->GetUserDevFeatureCount(m_uid,pDeviceInfo->id) > 0)
- deviceMap[pDeviceInfo->deviceType].push_back(pDeviceInfo);
- }
- cmbDeviceType->clear();
- for(int type : deviceMap.keys())
- {
- QString iconPath = QString(UKUI_BIOMETRIC_IMAGES_PATH"icon/%1.png")
- .arg(DeviceType::getDeviceType(type));
- qDebug() << iconPath;
- cmbDeviceType->addItem(QIcon(iconPath), DeviceType::getDeviceType_tr(type), type);
- }
- if(deviceMap.size() > 0)
- {
- int index = deviceMap.keys().at(0);
- setCurrentDevice(deviceMap[index].at(0));
- }
-
-}
-
-
-void BiometricDevicesWidget::setCurrentDevice(int drvid)
-{
- DeviceInfoPtr pDeviceInfo = findDeviceById(drvid);
- if(pDeviceInfo)
- {
- setCurrentDevice(pDeviceInfo);
- }
-}
-
-void BiometricDevicesWidget::setCurrentDevice(const QString &deviceName)
-{
- DeviceInfoPtr pDeviceInfo = findDeviceByName(deviceName);
- if(pDeviceInfo)
- {
- setCurrentDevice(pDeviceInfo);
- }
-}
-
-void BiometricDevicesWidget::setCurrentDevice(const DeviceInfoPtr &pDeviceInfo)
-{
- this->currentDevice = pDeviceInfo;
- cmbDeviceType->setCurrentText(DeviceType::getDeviceType_tr(pDeviceInfo->deviceType));
- cmbDeviceName->setCurrentText(pDeviceInfo->shortName);
-}
-
-bool BiometricDevicesWidget::deviceExists(int drvid)
-{
- return (findDeviceById(drvid) != nullptr);
-}
-
-bool BiometricDevicesWidget::deviceExists(const QString &deviceName)
-{
- return (findDeviceByName(deviceName) != nullptr);
-}
-
-DeviceInfoPtr BiometricDevicesWidget::findDeviceById(int drvid)
-{
- for(int type : deviceMap.keys())
- {
- DeviceList &deviceList = deviceMap[type];
- auto iter = std::find_if(deviceList.begin(), deviceList.end(),
- [&](DeviceInfoPtr ptr){
- return ptr->id == drvid;
- });
- if(iter != deviceList.end())
- {
- return *iter;
- }
- }
- return DeviceInfoPtr();
-}
-
-DeviceInfoPtr BiometricDevicesWidget::findDeviceByName(const QString &name)
-{
- for(int type : deviceMap.keys())
- {
- DeviceList &deviceList = deviceMap[type];
- auto iter = std::find_if(deviceList.begin(), deviceList.end(),
- [&](DeviceInfoPtr ptr){
- return ptr->shortName == name;
- });
- if(iter != deviceList.end())
- {
- return *iter;
- }
- }
- return DeviceInfoPtr();
-}
-
-void BiometricDevicesWidget::onCmbDeviceTypeCurrentIndexChanged(int index)
-{
- if(index < 0 || index >= deviceMap.keys().size())
- {
- return;
- }
- int type = cmbDeviceType->itemData(index).toInt();
- cmbDeviceName->clear();
- for(auto &deviceInfo : deviceMap.value(type))
- {
- cmbDeviceName->addItem(deviceInfo->shortName);
- }
-}
-
-void BiometricDevicesWidget::onOKButtonClicked()
-{
- int type = cmbDeviceType->currentData().toInt();
- int index = cmbDeviceName->currentIndex();
- qDebug() << type << index;
- DeviceInfoPtr deviceInfo = deviceMap.value(type).at(index);
- Q_EMIT deviceChanged(deviceInfo);
- hide();
-}
-
-void BiometricDevicesWidget::onUSBDeviceHotPlug(int drvid, int action, int /*devNum*/)
-{
- int savedDeviceId = currentDevice->id;
- int savedCount = 0;
- for(int type : deviceMap.keys())
- savedCount += deviceMap.value(type).count();
-
- switch(action)
- {
- case ACTION_ATTACHED:
- {
- //插入设备后,需要更新设备列表
- deviceMap.clear();
- updateDevice();
- setCurrentDevice(savedDeviceId);
- break;
- }
- case ACTION_DETACHED:
- {
- DeviceInfoPtr pDeviceInfo = findDeviceById(drvid);
- if(pDeviceInfo)
- {
- int type = pDeviceInfo->deviceType;
- deviceMap[type].removeOne(pDeviceInfo);
- int index = cmbDeviceName->findText(pDeviceInfo->shortName);
- cmbDeviceName->removeItem(index);
-
- //如果该类型的设备全被移除,删除该类型相关的列表
- if(deviceMap[type].isEmpty())
- {
- deviceMap.remove(type);
- index = cmbDeviceType->findData(type);
- cmbDeviceType->removeItem(index);
- }
- }
- if(savedDeviceId != drvid)
- {
- setCurrentDevice(savedDeviceId);
- }
- break;
- }
- }
-
- int count = 0;
- for(int type : deviceMap.keys())
- count += deviceMap.value(type).count();
-
- //设备数量发生了变化
- if(count != savedCount)
- {
- Q_EMIT deviceCountChanged(count);
- }
-}
-
-
diff --git a/BiometricAuth/biometricdeviceswidget.h b/BiometricAuth/biometricdeviceswidget.h
deleted file mode 100644
index bdef3da..0000000
--- a/BiometricAuth/biometricdeviceswidget.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2018 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 .
- *
-**/
-#ifndef BIOMETRICDEVICESWIDGET_H
-#define BIOMETRICDEVICESWIDGET_H
-
-#include
-#include "biometricproxy.h"
-
-class QLabel;
-class QPushButton;
-class QComboBox;
-
-
-class BiometricDevicesWidget : public QWidget
-{
- Q_OBJECT
-public:
- explicit BiometricDevicesWidget(BiometricProxy *proxy, int uid,QWidget *parent = nullptr);
- void setCurrentDevice(int drvid);
- void setCurrentDevice(const QString &deviceName);
- void setCurrentDevice(const DeviceInfoPtr &pDeviceInfo);
- DeviceInfoPtr findDeviceById(int drvid);
- DeviceInfoPtr findDeviceByName(const QString &name);
- bool deviceExists(int drvid);
- bool deviceExists(const QString &deviceName);
- void setUser(int user);
-
-protected:
- void resizeEvent(QResizeEvent *event);
-
-Q_SIGNALS:
- void deviceChanged(const DeviceInfoPtr &pDeviceInfo);
- void deviceCountChanged(int newCount);
-
-public Q_SLOTS:
- void onOKButtonClicked();
-
-private Q_SLOTS:
- void onCmbDeviceTypeCurrentIndexChanged(int index);
- void onUSBDeviceHotPlug(int drvid, int action, int devNum);
-
-private:
- void initUI();
- void updateDevice();
-
-private:
- typedef QMap QButtonMap;
-
- QLabel *lblPrompt;
- QLabel *lblDeviceType;
- QLabel *lblDeviceName;
- QComboBox *cmbDeviceType;
- QComboBox *cmbDeviceName;
- QPushButton *btnOK;
- QPushButton *btnCancel;
-
- BiometricProxy *proxy;
- DeviceMap deviceMap;
- DeviceInfoPtr currentDevice;
- int m_uid;
-};
-
-#endif // BIOMETRICDEVICESWIDGET_H
diff --git a/BiometricAuth/main.cpp b/BiometricAuth/main.cpp
deleted file mode 100644
index cd780b5..0000000
--- a/BiometricAuth/main.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2018 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 .
- *
-**/
-#include
-#include
-#include "biometricproxy.h"
-#include "biometricauthwidget.h"
-#include "biometricdeviceswidget.h"
-
-int main(int argc, char *argv[])
-{
- QApplication a(argc, argv);
-
- BiometricProxy proxy;
- BiometricAuthWidget biometricAuthWidget(&proxy);
- biometricAuthWidget.hide();
- BiometricDevicesWidget biometricDeviceWidget(&proxy);
- QObject::connect(&biometricDeviceWidget, &BiometricDevicesWidget::deviceChanged,
- &a, [&](const DeviceInfoPtr &pDeviceInfo){
- biometricAuthWidget.startAuth(pDeviceInfo, 1000);
- biometricAuthWidget.show();
- });
- QObject::connect(&biometricDeviceWidget, &BiometricDevicesWidget::deviceCountChanged,
- &a, [&](int count){
- qDebug() << "device count changed: " << count;
- });
- biometricDeviceWidget.show();
-
- return a.exec();
-}
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6113071..37e601e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,55 +1,24 @@
cmake_minimum_required(VERSION 2.6)
project(ukui-screensaver)
-find_package(Qt5 COMPONENTS Core Widgets DBus X11Extras Xml Network Svg Multimedia MultimediaWidgets)
-find_package(PkgConfig REQUIRED)
-find_package(OpenCV REQUIRED)
-find_package(PkgConfig)
-find_package(KF5Screen REQUIRED)
-find_package(KF5Wayland REQUIRED)
-find_package(LayerShellQt REQUIRED)
-
-pkg_check_modules(GIOUNIX2 REQUIRED gio-unix-2.0)
-pkg_check_modules(GLIB2 REQUIRED glib-2.0 gio-2.0)
-pkg_check_modules(kylin-nm-base REQUIRED kylin-nm-base)
-pkg_check_modules(KScreen REQUIRED kscreen2)
-
-# 是否是intel项目
-option (USE_INTEL "intel项目" OFF)
-# 用于测试替换用的变量
-set(TEST_ON 1)
-set(TEST_OF 0)
-set(VAR "VAR_NEW")
-
-# 加入一个配置头文件,用于处理 CMake 对源码的设置
-configure_file (
- "${CMAKE_CURRENT_SOURCE_DIR}/config.h.in"
- "${CMAKE_CURRENT_BINARY_DIR}/config.h"
-)
-
-set(TS_FILES
- ${CMAKE_CURRENT_SOURCE_DIR}/i18n_ts/zh_CN.ts
- ${CMAKE_CURRENT_SOURCE_DIR}/i18n_ts/es.ts
- ${CMAKE_CURRENT_SOURCE_DIR}/i18n_ts/fr.ts
- ${CMAKE_CURRENT_SOURCE_DIR}/i18n_ts/bo_CN.ts
- ${CMAKE_CURRENT_SOURCE_DIR}/i18n_ts/pt.ts
- ${CMAKE_CURRENT_SOURCE_DIR}/i18n_ts/ru.ts
- ${CMAKE_CURRENT_SOURCE_DIR}/i18n_ts/tr.ts
- ${CMAKE_CURRENT_SOURCE_DIR}/i18n_ts/nm.ts
- )
+## 更新翻译字段
+file(GLOB TS_FILES ./i18n_ts/*.ts)
add_custom_command(
- OUTPUT ${TS_FILES}
- COMMAND lupdate src/ screensaver/ -ts ${TS_FILES}
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- )
+ OUTPUT ${TS_FILES}
+ COMMAND lupdate src/ screensaver/ -ts ${TS_FILES}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ )
add_custom_target(
- i18n_ts
- DEPENDS ${TS_FILES}
- )
+ i18n_ts
+ DEPENDS ${TS_FILES}
+ )
+
add_compile_options(-fPIC)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_INSTALL_PREFIX /usr)
@@ -58,17 +27,9 @@ if(Debug)
set(CMAKE_BUILD_TYPE "Debug")
endif()
-#add_subdirectory(BioAuth)
-add_subdirectory(BiometricAuth)
-add_subdirectory(VirtualKeyboard)
add_subdirectory(src)
add_subdirectory(i18n_ts)
-add_subdirectory(set4kScale)
add_subdirectory(data)
-add_subdirectory(screensaver)
-add_subdirectory(screensaver-focus-helper)
-add_subdirectory(Common)
-add_subdirectory(KylinNM)
-add_dependencies(ukui-screensaver-dialog BiometricAuth VirtualKeyboard Common Screensaver)
-add_dependencies(ukui-screensaver-default Common)
+# 让主目标依赖翻译文件,这样才会执行i18n
+add_dependencies(ukui-screensaver-dialog i18n)
diff --git a/Common/CMakeLists.txt b/Common/CMakeLists.txt
deleted file mode 100644
index 1f4d3b7..0000000
--- a/Common/CMakeLists.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-pkg_check_modules(GLIB REQUIRED glib-2.0)
-find_package(X11 REQUIRED)
-find_package(KF5WindowSystem)
-
-include_directories(
- ${Qt5Core_INCLUDE_DIRS}
- ${Qt5Widgets_INCLUDE_DIRS}
- ${Qt5DBus_INCLUDE_DIRS}
- ${GLIB2_INCLUDE_DIRS}
- ${KF5Wayland_LIBRARIES}
- )
-
-qt5_wrap_cpp(Common_SRC
- autoresize.h
- checkbutton.h
- commonfunc.h
- glibinterface.h
- plasma-shell-manager.h
- )
-
-set(Common_SRC
- ${Common_SRC}
- autoresize.cpp
- checkbutton.cpp
- commonfunc.cpp
- glibinterface.cpp
- plasma-shell-manager.cpp
- )
-
-add_library(Common STATIC ${Common_SRC})
-target_link_libraries(Common Qt5::Core Qt5::DBus Qt5::Widgets Qt5::X11Extras ${GIOUNIX2_LIBRARIES} ${KF5Wayland_LIBRARIES} -lKF5WaylandClient -lKF5WaylandServer KF5::WindowSystem)
diff --git a/Common/autoresize.cpp b/Common/autoresize.cpp
deleted file mode 100644
index c5301e9..0000000
--- a/Common/autoresize.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2018 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 .
- *
-**/
-
-#include "autoresize.h"
-
-AutoResize::AutoResize(QWidget* obj,int baseWidth,int baseHeight):
- obj(obj),
- baseWidth(baseWidth),
- baseHeight(baseHeight)
-{
-
-}
-
-AutoResize::~AutoResize(void)
-{
-}
-
diff --git a/Common/autoresize.h b/Common/autoresize.h
deleted file mode 100644
index 610a2f9..0000000
--- a/Common/autoresize.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2018 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 .
- *
-**/
-
-#ifndef AUTORESIZE_H
-#define AUTORESIZE_H
-
-#include
-
-struct AutoResizeOriginalData
-{
- QRect data_rect;
- QFont data_font;
-};
-class AutoResize
-{
-public:
- AutoResize(QWidget* obj,int baseWidth,int baseHeight);
- ~AutoResize(void);
-private:
- QWidget *obj;
- int baseWidth;
- int baseHeight;
-
-};
-
-#endif
diff --git a/Common/commonfunc.cpp b/Common/commonfunc.cpp
deleted file mode 100644
index 844791d..0000000
--- a/Common/commonfunc.cpp
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * 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 .
- *
-**/
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include "commonfunc.h"
-
-#define DRM_DIR "/sys/class/leds/"
-
-/**
- * @brief 判断大写键状态
- * @return true: 大写锁定
- */
-bool checkCapsLockState()
-{
- QDir ledDir(DRM_DIR);
- QStringList leds = ledDir.entryList(QDir::Dirs);
- QString capsFile;
-
- for(int i = 0;i width)
- {
- strInfo= QFontMetrics(font).elidedText(strInfo, Qt::ElideRight, width);
- }
- return strInfo;
-}
-
-/*修改图片缩放机制,图片长宽不一致时,先取图片中央的部分*/
-QPixmap scaledPixmap(QPixmap src)
-{
- QPixmap rectPixmap;
- if (src.width() > src.height()) {
- QPixmap iconPixmap = src.copy((src.width() - src.height())/2, 0, src.height(), src.height());
- // 根据label高度等比例缩放图片
- rectPixmap = iconPixmap.scaledToHeight(src.height());
- } else {
- QPixmap iconPixmap = src.copy(0, (src.height() - src.width())/2, src.width(), src.width());
- // 根据label宽度等比例缩放图片
- rectPixmap = iconPixmap.scaledToWidth(src.width());
- }
- return rectPixmap;
-}
-
-QPixmap PixmapToRound(const QPixmap &src, int radius)
-{
- if (src.isNull()) {
- return QPixmap();
- }
-
- QPixmap pixmapa(src);
- QPixmap pixmap(radius*2,radius*2);
- pixmap.fill(Qt::transparent);
- QPainter painter(&pixmap);
- painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
- QPainterPath path;
- path.addEllipse(0, 0, radius*2, radius*2);
- painter.setClipPath(path);
- painter.drawPixmap(0, 0, radius*2, radius*2, pixmapa);
- return pixmap;
-}
diff --git a/Common/commonfunc.h b/Common/commonfunc.h
deleted file mode 100644
index c42f31b..0000000
--- a/Common/commonfunc.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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 .
- *
-**/
-
-#ifndef COMMONFUNC_H
-#define COMMONFUNC_H
-
-#include
-#include
-#include
-
-#define G_FONT_SIZE (11.0)
-
-bool checkCapsLockState();
-bool ispicture(QString filepath);
-QString getSystemVersion();
-QString getSystemDistrib();
-bool getUseFirstDevice();
-QString ElideText(QFont font,int width,QString strInfo);
-QPixmap scaledPixmap(QPixmap src);
-QPixmap PixmapToRound(const QPixmap &src, int radius);
-
-class commonFunc
-{
-public:
- commonFunc();
-};
-
-#endif // COMMONFUNC_H
diff --git a/Common/glibinterface.cpp b/Common/glibinterface.cpp
deleted file mode 100644
index 25cdcff..0000000
--- a/Common/glibinterface.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2023 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 .
- *
-**/
-#include "glibinterface.h"
-#include
-#include
-
-#define STYLE_TYPE_SCHEMA "org.ukui.style"
-#define KEY_SYSTEM_FONT_SIZE "system-font-size"
-#define DEFAULT_FONT_SIZE (10.0)
-
-double getDefaultFontSize()
-{
- GSettingsSchemaSource *schema_source = NULL;
- GSettingsSchema *schema = NULL;
- double defaultFontSize = DEFAULT_FONT_SIZE;
-
- schema_source = g_settings_schema_source_get_default();
- if (schema_source) {
- schema = g_settings_schema_source_lookup(schema_source,STYLE_TYPE_SCHEMA,TRUE);
- if (schema) {
- GSettings *gs = g_settings_new(STYLE_TYPE_SCHEMA);
- if (gs) {
- GVariant *size = g_settings_get_default_value(gs, KEY_SYSTEM_FONT_SIZE);
- QString fontsize(g_variant_get_string(size, NULL));
- g_variant_unref(size);
- g_object_unref(gs);
- defaultFontSize = fontsize.toDouble();
- }
- g_settings_schema_unref(schema);
- }
- }
- return defaultFontSize;
-}
diff --git a/KylinNM/CMakeLists.txt b/KylinNM/CMakeLists.txt
deleted file mode 100644
index f9577ea..0000000
--- a/KylinNM/CMakeLists.txt
+++ /dev/null
@@ -1,95 +0,0 @@
-find_package(Qt5 COMPONENTS Core Widgets REQUIRED)
-find_package(X11 REQUIRED)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTOUIC ON)
-set(CMAKE_AUTORCC ON)
-#pkg_check_modules(X11 REQUIRED x11)
-
-qt5_wrap_ui(Kylin_NM_SRC
- src/confform.ui
- src/kylinnm.ui
- src/oneconnform.ui
- src/onelancform.ui
- wireless-security/dlgconnhidwifi.ui
- wireless-security/dlgconnhidwifisecfast.ui
- wireless-security/dlgconnhidwifisectunneltls.ui
- wireless-security/dlgconnhidwifisecpeap.ui
- wireless-security/dlgconnhidwifisectls.ui
- wireless-security/dlgconnhidwifisecleap.ui
- wireless-security/dlgconnhidwifisecpwd.ui
- wireless-security/dlgconnhidwifiwep.ui
- wireless-security/dlgconnhidwifileap.ui
- wireless-security/dlgconnhidwifiwpa.ui
- hot-spot/dlghotspotcreate.ui
- )
-
-#qt5_wrap_cpp(Kylin_NM_SRC
-# src/backthread.h
-# src/confform.h
-# src/ksimplenm.h
-# src/kylin-dbus-interface.h
-# src/kylin-network-interface.h
-# src/loadingdiv.h
-# src/kylinnm.h
-# src/oneconnform.h
-# src/onelancform.h
-# src/switchbutton.h
-# src/utils.h
-# wireless-security/dlgconnhidwifi.h
-# wireless-security/dlgconnhidwifisecfast.h
-# wireless-security/dlgconnhidwifisectunneltls.h
-# wireless-security/dlgconnhidwifisecpeap.h
-# wireless-security/dlgconnhidwifisectls.h
-# wireless-security/dlgconnhidwifisecleap.h
-# wireless-security/dlgconnhidwifisecpwd.h
-# wireless-security/dlgconnhidwifiwep.h
-# wireless-security/dlgconnhidwifileap.h
-# wireless-security/dlgconnhidwifiwpa.h
-# wireless-security/kylinheadfile.h
-# hot-spot/dlghotspotcreate.h
-# )
-
-qt5_add_resources(Kylin_NM_SRC
- nmqrc.qrc
- res.qrc)
-
-set(Kylin_NM_SRC
- ${Kylin_NM_SRC}
- src/backthread.cpp
- src/confform.cpp
- src/ksimplenm.cpp
- src/kylin-dbus-interface.cpp
- src/kylin-network-interface.c
- src/loadingdiv.cpp
- src/kylinnm.cpp
- src/oneconnform.cpp
- src/onelancform.cpp
- src/switchbutton.cpp
- src/utils.cpp
- src/swipegesturerecognizer.cpp
- wireless-security/dlgconnhidwifi.cpp
- wireless-security/dlgconnhidwifisecfast.cpp
- wireless-security/dlgconnhidwifisectunneltls.cpp
- wireless-security/dlgconnhidwifisecpeap.cpp
- wireless-security/dlgconnhidwifisectls.cpp
- wireless-security/dlgconnhidwifisecleap.cpp
- wireless-security/dlgconnhidwifisecpwd.cpp
- wireless-security/dlgconnhidwifiwep.cpp
- wireless-security/dlgconnhidwifileap.cpp
- wireless-security/dlgconnhidwifiwpa.cpp
- wireless-security/kylinheadfile.cpp
- hot-spot/dlghotspotcreate.cpp
- nmqrc.qrc
- )
-
-include_directories(
- ${Qt5Core_INCLUDE_DIRS}
- ${Qt5Widgets_INCLUDE_DIRS}
- ${Qt5DBus_INCLUDE_DIRS}
- )
-
-find_package(KF5WindowSystem)
-
-add_library(Kylin-nm STATIC ${Kylin_NM_SRC})
-target_link_libraries(Kylin-nm Qt5::Core Qt5::Widgets KF5::WindowSystem Qt5::DBus Qt5::X11Extras)
diff --git a/KylinNM/README.md b/KylinNM/README.md
deleted file mode 100644
index a59ec5e..0000000
--- a/KylinNM/README.md
+++ /dev/null
@@ -1,15 +0,0 @@
-# NAME
- kylin-nm - kylin network monitor used in ubuntu-kylin operation system
-
-# DESCRIPTION
- kylin-nm is a Qt based applet and uses some interface provided by NetworkManager.
- It provides a GUI for users to connect or disconnect wired or wireless network which managed by NetworkManager.
- Users can also create new wired network and configure a old network.
- By click button at left bottom in the main window, a network configure window of NetworkManager will show in the screen.
- Users can get some information about network directly by clicking one item in the network list, these information shown in extension area.
-
-# BUILD KYLIN-NM
- down the source sode
- install dependency packages(see cntrol files in the debian directory)
- execute debuild command in the root directory of project
- execute sudo dpkg -i packagename.deb to install
diff --git a/KylinNM/hot-spot/dlghotspotcreate.cpp b/KylinNM/hot-spot/dlghotspotcreate.cpp
deleted file mode 100644
index a64e249..0000000
--- a/KylinNM/hot-spot/dlghotspotcreate.cpp
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright (C) 2020 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 setupUi(this);
-
- this->setWindowFlags(Qt::FramelessWindowHint);
- this->setStyleSheet("background-color:white;");
-
- ui->lbLeftup->setStyleSheet("QLabel{background-color:#266ab5;}");
- ui->lbLeftupIcon->setStyleSheet("QLabel{background-image:url(:/res/h/no-pwd-wifi.png);background-color:transparent;}");
- ui->lbLeftupTitle->setStyleSheet("QLabel{font-size:12px;color:#ffffff;background-color:transparent;}");
- ui->btnCancel->setStyleSheet("QPushButton{border:1px solid #aaaaaa;background-color:#f5f5f5;}"
- "QPushButton:Hover{border:2px solid #629ee8;background-color:#eeeeee;}"
- "QPushButton:Pressed{border:1px solid #aaaaaa;background-color:#d8d8d8;}");
- ui->btnOk->setStyleSheet("QPushButton{border:1px solid #aaaaaa;background-color:#f5f5f5;}"
- "QPushButton:Hover{border:2px solid #629ee8;background-color:#eeeeee;}"
- "QPushButton:Pressed{border:1px solid #aaaaaa;background-color:#d8d8d8;}");
- ui->checkBoxPwd->setStyleSheet("QCheckBox::indicator {width: 18px; height: 9px;}"
- "QCheckBox::indicator:checked {image: url(:/res/h/show-pwd.png);}"
- "QCheckBox::indicator:unchecked {image: url(:/res/h/hide-pwd.png);}");
-
- ui->lbLeftupTitle->setText(tr("Create Hotspot")); //创建个人热点
- ui->lbNetName->setText(tr("Network name")); //网络名称:
- ui->lbSecurity->setText(tr("Wi-Fi security")); //Wi-Fi 安全性:
- ui->lbPassword->setText(tr("Password")); //密码:
- ui->btnCancel->setText(tr("Cancel")); //取消
- ui->btnOk->setText(tr("Ok")); //确定
- ui->btnOk->setEnabled(false);
-
- ui->cbxSecurity->addItem(tr("None")); //无
- ui->cbxSecurity->addItem(tr("WPA & WPA2 Personal")); //WPA 及 WPA2 个人
- ui->cbxSecurity->setCurrentIndex(1);
- connect(ui->cbxSecurity,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialog()));
-}
-
-DlgHotspotCreate::~DlgHotspotCreate()
-{
- delete ui;
-}
-
-void DlgHotspotCreate::mousePressEvent(QMouseEvent *event){
- if(event->button() == Qt::LeftButton){
- this->isPress = true;
- this->winPos = this->pos();
- this->dragPos = event->globalPos();
- event->accept();
- }
-}
-void DlgHotspotCreate::mouseReleaseEvent(QMouseEvent *event){
- this->isPress = false;
- this->setWindowOpacity(1);
-}
-void DlgHotspotCreate::mouseMoveEvent(QMouseEvent *event){
- if(this->isPress){
- this->move(this->winPos - (this->dragPos - event->globalPos()));
- this->setWindowOpacity(0.9);
- event->accept();
- }
-}
-
-void DlgHotspotCreate::on_btnCancel_clicked()
-{
- this->close();
- emit btnHotspotState();
-}
-
-void DlgHotspotCreate::on_btnOk_clicked()
-{
- //nmcli device wifi hotspot [ifname ifname] [con-name name] [ssid SSID] [band {a | bg}] [channel channel] [password password]
- //example: nmcli device wifi hotspot ifname wlan0 con-name MyHostspot ssid MyHostspotSSID password 12345678
- QString str;
- if(ui->cbxSecurity->currentIndex() == 0 ){
- str = "nmcli device wifi hotspot ifname " + wirelessCardName + " con-name " + ui->leNetName->text() + " ssid " + ui->leNetName->text() + "SSID";
- }else{
- str = "nmcli device wifi hotspot ifname " + wirelessCardName + " con-name " + ui->leNetName->text() + " ssid " + ui->leNetName->text() + " password " + ui->lePassword->text();
- }
- Utils::m_system(str.toUtf8().data());
-// int status = system(str.toUtf8().data());
-// if (status != 0){ syslog(LOG_ERR, "execute 'nmcli device wifi hotspot' in function 'on_btnOk_clicked' failed");}
-
- this->close();
- emit updateHotspotList();
-}
-
-void DlgHotspotCreate::on_checkBoxPwd_stateChanged(int arg1)
-{
- if (arg1 == 0) {
- ui->lePassword ->setEchoMode(QLineEdit::Password);
- } else {
- ui->lePassword->setEchoMode(QLineEdit::Normal);
- }
-}
-
-void DlgHotspotCreate::on_leNetName_textEdited(const QString &arg1)
-{
- if(ui->cbxSecurity->currentIndex() == 0 ){
- if (ui->leNetName->text() == ""){
- ui->btnOk->setEnabled(false);
- } else {
- ui->btnOk->setEnabled(true);
- }
- }else{
- if (ui->leNetName->text() == "" || ui->lePassword->text().size() < 5){
- ui->btnOk->setEnabled(false);
- } else {
- ui->btnOk->setEnabled(true);
- }
- }
-}
-
-void DlgHotspotCreate::on_lePassword_textEdited(const QString &arg1)
-{
- if (ui->leNetName->text() == "" || ui->lePassword->text().size() < 5){
- ui->btnOk->setEnabled(false);
- } else {
- ui->btnOk->setEnabled(true);
- }
-}
-
-void DlgHotspotCreate::changeDialog()
-{
- if(ui->cbxSecurity->currentIndex()==0){
- ui->lbPassword->setEnabled(false);
- ui->lePassword->setEnabled(false);
- ui->checkBoxPwd->setEnabled(false);
- } else {
- ui->lbPassword->setEnabled(true);
- ui->lePassword->setEnabled(true);
- ui->checkBoxPwd->setEnabled(true);
- }
-}
diff --git a/KylinNM/hot-spot/dlghotspotcreate.h b/KylinNM/hot-spot/dlghotspotcreate.h
deleted file mode 100644
index 11a884d..0000000
--- a/KylinNM/hot-spot/dlghotspotcreate.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2020 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
-
-#include
-#include
-#include
-
-namespace Ui {
-class DlgHotspotCreate;
-}
-
-class DlgHotspotCreate : public QDialog
-{
- Q_OBJECT
-
-public:
- explicit DlgHotspotCreate(QString wiFiCardName, QWidget *parent = nullptr);
- ~DlgHotspotCreate();
-
-public Q_SLOTS:
- void changeDialog();
-
-private Q_SLOTS:
- void on_btnCancel_clicked();
-
- void on_btnOk_clicked();
-
- void on_checkBoxPwd_stateChanged(int arg1);
-
- void on_leNetName_textEdited(const QString &arg1);
-
- void on_lePassword_textEdited(const QString &arg1);
-
-private:
- Ui::DlgHotspotCreate *ui;
-
- QString wirelessCardName;
-
- void mousePressEvent(QMouseEvent *event);
- void mouseReleaseEvent(QMouseEvent *event);
- void mouseMoveEvent(QMouseEvent *event);
- bool isPress;
- QPoint winPos;
- QPoint dragPos;
-
-Q_SIGNALS:
- void updateHotspotList();
- void btnHotspotState();
-};
-
-#endif // DLGHOTSPOTCREATE_H
diff --git a/KylinNM/hot-spot/dlghotspotcreate.ui b/KylinNM/hot-spot/dlghotspotcreate.ui
deleted file mode 100644
index 989108f..0000000
--- a/KylinNM/hot-spot/dlghotspotcreate.ui
+++ /dev/null
@@ -1,169 +0,0 @@
-
-
- DlgHotspotCreate
-
-
-
- 0
- 0
- 432
- 250
-
-
-
- Dialog
-
-
-
-
- 0
- 0
- 120
- 32
-
-
-
-
-
-
-
-
-
- 9
- 9
- 16
- 16
-
-
-
-
-
-
-
-
-
- 34
- 6
- 80
- 20
-
-
-
-
-
-
-
-
-
- 215
- 210
- 90
- 30
-
-
-
-
-
-
-
-
-
- 315
- 210
- 90
- 30
-
-
-
-
-
-
-
-
-
- 76
- 60
- 90
- 20
-
-
-
-
-
-
-
-
-
- 175
- 55
- 200
- 32
-
-
-
-
-
-
- 76
- 105
- 90
- 20
-
-
-
-
-
-
-
-
-
- 175
- 100
- 200
- 32
-
-
-
-
-
-
- 76
- 150
- 90
- 20
-
-
-
-
-
-
-
-
-
- 175
- 145
- 200
- 32
-
-
-
- QLineEdit::Password
-
-
-
-
-
- 350
- 157
- 18
- 9
-
-
-
-
-
-
-
-
-
-
diff --git a/KylinNM/kylin-nm.pri b/KylinNM/kylin-nm.pri
deleted file mode 100644
index e124796..0000000
--- a/KylinNM/kylin-nm.pri
+++ /dev/null
@@ -1,70 +0,0 @@
-SOURCES += \
- $$PWD/src/backthread.cpp \
- $$PWD/src/confform.cpp \
- $$PWD/src/ksimplenm.cpp \
- $$PWD/src/kylin-dbus-interface.cpp \
- $$PWD/src/kylin-network-interface.c \
- $$PWD/src/loadingdiv.cpp \
- $$PWD/src/kylinnm.cpp \
- $$PWD/src/oneconnform.cpp \
- $$PWD/src/onelancform.cpp \
- $$PWD/src/switchbutton.cpp \
- $$PWD/src/utils.cpp \
- $$PWD/wireless-security/dlgconnhidwifi.cpp \
- $$PWD/wireless-security/dlgconnhidwifisecfast.cpp \
- $$PWD/wireless-security/dlgconnhidwifisectunneltls.cpp \
- $$PWD/wireless-security/dlgconnhidwifisecpeap.cpp \
- $$PWD/wireless-security/dlgconnhidwifisectls.cpp \
- $$PWD/wireless-security/dlgconnhidwifisecleap.cpp \
- $$PWD/wireless-security/dlgconnhidwifisecpwd.cpp \
- $$PWD/wireless-security/dlgconnhidwifiwep.cpp \
- $$PWD/wireless-security/dlgconnhidwifileap.cpp \
- $$PWD/wireless-security/dlgconnhidwifiwpa.cpp \
- $$PWD/wireless-security/kylinheadfile.cpp \
- $$PWD/hot-spot/dlghotspotcreate.cpp
-
-HEADERS += \
- $$PWD/src/backthread.h \
- $$PWD/src/confform.h \
- $$PWD/src/ksimplenm.h \
- $$PWD/src/kylin-dbus-interface.h \
- $$PWD/src/kylin-network-interface.h \
- $$PWD/src/loadingdiv.h \
- $$PWD/src/kylinnm.h \
- $$PWD/src/oneconnform.h \
- $$PWD/src/onelancform.h \
- $$PWD/src/switchbutton.h \
- $$PWD/src/utils.h \
- $$PWD/wireless-security/dlgconnhidwifi.h \
- $$PWD/wireless-security/dlgconnhidwifisecfast.h \
- $$PWD/wireless-security/dlgconnhidwifisectunneltls.h \
- $$PWD/wireless-security/dlgconnhidwifisecpeap.h \
- $$PWD/wireless-security/dlgconnhidwifisectls.h \
- $$PWD/wireless-security/dlgconnhidwifisecleap.h \
- $$PWD/wireless-security/dlgconnhidwifisecpwd.h \
- $$PWD/wireless-security/dlgconnhidwifiwep.h \
- $$PWD/wireless-security/dlgconnhidwifileap.h \
- $$PWD/wireless-security/dlgconnhidwifiwpa.h \
- $$PWD/wireless-security/kylinheadfile.h \
- $$PWD/hot-spot/dlghotspotcreate.h
-
-FORMS += \
- $$PWD/src/confform.ui \
- $$PWD/src/kylinnm.ui \
- $$PWD/src/oneconnform.ui \
- $$PWD/src/onelancform.ui \
- $$PWD/wireless-security/dlgconnhidwifi.ui \
- $$PWD/wireless-security/dlgconnhidwifisecfast.ui \
- $$PWD/wireless-security/dlgconnhidwifisectunneltls.ui \
- $$PWD/wireless-security/dlgconnhidwifisecpeap.ui \
- $$PWD/wireless-security/dlgconnhidwifisectls.ui \
- $$PWD/wireless-security/dlgconnhidwifisecleap.ui \
- $$PWD/wireless-security/dlgconnhidwifisecpwd.ui \
- $$PWD/wireless-security/dlgconnhidwifiwep.ui \
- $$PWD/wireless-security/dlgconnhidwifileap.ui \
- $$PWD/wireless-security/dlgconnhidwifiwpa.ui \
- $$PWD/hot-spot/dlghotspotcreate.ui
-
-RESOURCES += \
- $$PWD/nmqrc.qrc
-
diff --git a/KylinNM/kylin-nm.pro b/KylinNM/kylin-nm.pro
deleted file mode 100644
index b8af2ba..0000000
--- a/KylinNM/kylin-nm.pro
+++ /dev/null
@@ -1,129 +0,0 @@
-#-------------------------------------------------
-#
-# Project created by QtCreator 2018-10-19T15:29:47
-#
-#-------------------------------------------------
-
-QT += core gui x11extras dbus
-
-greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
-
-TARGET = kylin-nm
-TEMPLATE = app
-LANGUAGE = C++
-
-CONFIG += c++11
-
-# CONFIG += link_pkgconfig
-# PKGCONFIG += gsettings-qt
-LIBS += -L/usr/lib/ -lgsettings-qt -lX11
-
-target.path = /usr/bin
-target.source += $$TARGET
-desktop.path = /etc/xdg/autostart/
-desktop.files = kylin-nm.desktop
-
-INSTALLS += target \
- desktop
-
-# The following define makes your compiler emit warnings if you use
-# any feature of Qt which has been marked as deprecated (the exact warnings
-# depend on your compiler). Please consult the documentation of the
-# deprecated API in order to know how to port your code away from it.
-DEFINES += QT_DEPRECATED_WARNINGS
-
-# You can also make your code fail to compile if you use deprecated APIs.
-# In order to do so, uncomment the following line.
-# You can also select to disable deprecated APIs only up to a certain version of Qt.
-#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
-
-# QMAKE_CXXFLAGS += -Wno-unused-parameter
-QMAKE_CPPFLAGS *= $(shell dpkg-buildflags --get CPPFLAGS)
-QMAKE_CFLAGS *= $(shell dpkg-buildflags --get CFLAGS)
-QMAKE_CXXFLAGS *= $(shell dpkg-buildflags --get CXXFLAGS)
-QMAKE_LFLAGS *= $(shell dpkg-buildflags --get LDFLAGS)
-
-
-SOURCES += \
- src/backthread.cpp \
- src/confform.cpp \
- src/ksimplenm.cpp \
- src/kylin-dbus-interface.cpp \
- src/kylin-network-interface.c \
- src/loadingdiv.cpp \
- src/main.cpp \
- src/kylinnm.cpp \
- src/oneconnform.cpp \
- src/onelancform.cpp \
- src/switchbutton.cpp \
- src/utils.cpp \
- wireless-security/dlgconnhidwifi.cpp \
- wireless-security/dlgconnhidwifisecfast.cpp \
- wireless-security/dlgconnhidwifisectunneltls.cpp \
- wireless-security/dlgconnhidwifisecpeap.cpp \
- wireless-security/dlgconnhidwifisectls.cpp \
- wireless-security/dlgconnhidwifisecleap.cpp \
- wireless-security/dlgconnhidwifisecpwd.cpp \
- wireless-security/dlgconnhidwifiwep.cpp \
- wireless-security/dlgconnhidwifileap.cpp \
- wireless-security/dlgconnhidwifiwpa.cpp \
- wireless-security/kylinheadfile.cpp \
- hot-spot/dlghotspotcreate.cpp
-
-
-HEADERS += \
- src/backthread.h \
- src/confform.h \
- src/ksimplenm.h \
- src/kylin-dbus-interface.h \
- src/kylin-network-interface.h \
- src/loadingdiv.h \
- src/kylinnm.h \
- src/oneconnform.h \
- src/onelancform.h \
- src/switchbutton.h \
- src/utils.h \
- wireless-security/dlgconnhidwifi.h \
- wireless-security/dlgconnhidwifisecfast.h \
- wireless-security/dlgconnhidwifisectunneltls.h \
- wireless-security/dlgconnhidwifisecpeap.h \
- wireless-security/dlgconnhidwifisectls.h \
- wireless-security/dlgconnhidwifisecleap.h \
- wireless-security/dlgconnhidwifisecpwd.h \
- wireless-security/dlgconnhidwifiwep.h \
- wireless-security/dlgconnhidwifileap.h \
- wireless-security/dlgconnhidwifiwpa.h \
- wireless-security/kylinheadfile.h \
- hot-spot/dlghotspotcreate.h
-
-FORMS += \
- src/confform.ui \
- src/kylinnm.ui \
- src/oneconnform.ui \
- src/onelancform.ui \
- wireless-security/dlgconnhidwifi.ui \
- wireless-security/dlgconnhidwifisecfast.ui \
- wireless-security/dlgconnhidwifisectunneltls.ui \
- wireless-security/dlgconnhidwifisecpeap.ui \
- wireless-security/dlgconnhidwifisectls.ui \
- wireless-security/dlgconnhidwifisecleap.ui \
- wireless-security/dlgconnhidwifisecpwd.ui \
- wireless-security/dlgconnhidwifiwep.ui \
- wireless-security/dlgconnhidwifileap.ui \
- wireless-security/dlgconnhidwifiwpa.ui \
- hot-spot/dlghotspotcreate.ui
-
-RESOURCES += \
- nmqrc.qrc
-
-unix {
- UI_DIR = .ui
- MOC_DIR = .moc
- OBJECTS_DIR = .obj
-}
-
-TRANSLATIONS = translations/kylin-nm_zh_CN.ts \
- translations/kylin-nm_tr.ts \
- translations/kylin-nm_bo.ts
-
-DISTFILES +=
diff --git a/KylinNM/nmqrc.qrc b/KylinNM/nmqrc.qrc
deleted file mode 100644
index f2349b6..0000000
--- a/KylinNM/nmqrc.qrc
+++ /dev/null
@@ -1,102 +0,0 @@
-
-
- res/s/conning-b/1.png
- res/s/conning-b/2.png
- res/s/conning-b/3.png
- res/s/conning-b/4.png
- res/s/conning-b/5.png
- res/s/conning-b/6.png
- res/s/conning-b/7.png
- res/s/conning-b/8.png
- res/s/conning-b/9.png
- res/s/conning-b/10.png
- res/s/conning-b/11.png
- res/s/conning-b/12.png
- res/g/down_arrow.png
- res/g/checkbox-checked.svg
- res/g/checkbox-unchecked.svg
- res/s/rescan/1.png
- res/s/rescan/2.png
- res/s/rescan/3.png
- res/s/rescan/4.png
- res/s/rescan/5.png
- res/s/rescan/6.png
- res/s/rescan/7.png
- res/s/rescan/8.png
- res/s/rescan/9.png
- res/s/rescan/10.png
- res/s/rescan/11.png
- res/s/rescan/12.png
- res/h/hide-pwd.png
- res/h/right-pwd.png
- res/h/show-pwd.png
- res/h/no-pwd-wifi.png
- res/x/fly-mode-off.svg
- res/x/fly-mode-on.svg
- res/x/hot-spot-off.svg
- res/x/hot-spot-on.svg
- res/x/net-list-bg.svg
- res/x/wifi-list-bg.svg
- res/x/load-down.png
- res/x/load-up.png
- res/l/network-offline.png
- res/l/network-offline.svg
- res/l/network-online.png
- res/l/network-online.svg
- res/w/wifi-full.png
- res/w/wifi-full-pwd.png
- res/w/wifi-high.png
- res/w/wifi-high-pwd.png
- res/w/wifi-low.png
- res/w/wifi-low-pwd.png
- res/w/wifi-medium.png
- res/w/wifi-medium-pwd.png
- res/w/wifi-none.png
- res/w/wifi-none-pwd.png
- res/s/conning-a/1.png
- res/s/conning-a/2.png
- res/s/conning-a/3.png
- res/s/conning-a/4.png
- res/s/conning-a/5.png
- res/s/conning-a/6.png
- res/s/conning-a/7.png
- res/s/conning-a/8.png
- qss/style.qss
- res/g/close_black.png
- res/g/close_white.png
- res/s/conning-s/1.png
- res/s/conning-s/2.png
- res/s/conning-s/3.png
- res/s/conning-s/4.png
- res/s/conning-s/5.png
- res/s/conning-s/6.png
- res/s/conning-s/7.png
- res/s/conning-s/8.png
- res/s/conning-s/9.png
- res/s/conning-s/10.png
- res/s/conning-s/11.png
- res/s/conning-s/12.png
- res/x/setup.png
- res/x/pb-wifi-n.png
- res/x/pb-wifi-y.png
- res/x/pb-conn-dis.png
- res/l/pb-network-online.png
- res/l/pb-network-info.png
- res/l/pb-network-offline.png
- res/x/pb-newConn.png
- res/x/pb-close.png
- res/l/pb-top-network-offline.png
- res/w/pb-all-wifi-offline.png
- res/w/pb-top-wifi-offline.png
- res/w/wifi-full-off.png
- res/w/wifi-high-off.png
- res/w/wifi-low-off.png
- res/w/wifi-medium-off.png
- res/w/wifi-low-pwd-off.png
- res/w/wifi-full-pwd-off.png
- res/w/wifi-high-pwd-off.png
- res/w/wifi-medium-pwd-off.png
- res/w/wifi-none-off.png
- res/w/wifi-none-pwd-off.png
-
-
diff --git a/KylinNM/qss/style.qss b/KylinNM/qss/style.qss
deleted file mode 100644
index 741e632..0000000
--- a/KylinNM/qss/style.qss
+++ /dev/null
@@ -1,10 +0,0 @@
-QScrollBar:vertical{margin:0px 2px 0px 2px;width:10px;background:rgba(48,48,51,0);border-radius:6px;}
-QScrollBar::up-arrow:vertical{height:0px;}
-QScrollBar::sub-line:vertical{border:0px solid;height:0px}
-QScrollBar::sub-page:vertical{background:transparent;}
-QScrollBar::handle:vertical{width:6px;background:rgba(72,72,76,1);border-radius:3px;}
-QScrollBar::handle:vertical:hover{width:6px;background:rgba(97,97,102,1);border-radius:3px;}
-QScrollBar::handle:vertical:pressed{width:6px;background:rgba(133,133,140,1);border-radius:3px;}
-QScrollBar::add-page:vertical{background:transparent;}
-QScrollBar::add-line:vertical{border:0px solid;height:0px}
-QScrollBar::down-arrow:vertical{height:0px;}
diff --git a/KylinNM/res.qrc b/KylinNM/res.qrc
deleted file mode 100644
index 7646d2b..0000000
--- a/KylinNM/res.qrc
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/KylinNM/res/g/checkbox-checked.svg b/KylinNM/res/g/checkbox-checked.svg
deleted file mode 100644
index b9ee316..0000000
--- a/KylinNM/res/g/checkbox-checked.svg
+++ /dev/null
@@ -1,6 +0,0 @@
-
diff --git a/KylinNM/res/g/checkbox-unchecked.svg b/KylinNM/res/g/checkbox-unchecked.svg
deleted file mode 100644
index 0df442d..0000000
--- a/KylinNM/res/g/checkbox-unchecked.svg
+++ /dev/null
@@ -1,3 +0,0 @@
-
diff --git a/KylinNM/res/g/close_black.png b/KylinNM/res/g/close_black.png
deleted file mode 100644
index 237e555..0000000
Binary files a/KylinNM/res/g/close_black.png and /dev/null differ
diff --git a/KylinNM/res/g/close_white.png b/KylinNM/res/g/close_white.png
deleted file mode 100644
index 0943a4b..0000000
Binary files a/KylinNM/res/g/close_white.png and /dev/null differ
diff --git a/KylinNM/res/g/down_arrow.png b/KylinNM/res/g/down_arrow.png
deleted file mode 100644
index c7a343b..0000000
Binary files a/KylinNM/res/g/down_arrow.png and /dev/null differ
diff --git a/KylinNM/res/h/hide-pwd.png b/KylinNM/res/h/hide-pwd.png
deleted file mode 100644
index c1d3044..0000000
Binary files a/KylinNM/res/h/hide-pwd.png and /dev/null differ
diff --git a/KylinNM/res/h/no-pwd-wifi.png b/KylinNM/res/h/no-pwd-wifi.png
deleted file mode 100644
index dbec54a..0000000
Binary files a/KylinNM/res/h/no-pwd-wifi.png and /dev/null differ
diff --git a/KylinNM/res/h/right-pwd.png b/KylinNM/res/h/right-pwd.png
deleted file mode 100644
index 1bbc00d..0000000
Binary files a/KylinNM/res/h/right-pwd.png and /dev/null differ
diff --git a/KylinNM/res/h/show-pwd.png b/KylinNM/res/h/show-pwd.png
deleted file mode 100644
index 08c4de5..0000000
Binary files a/KylinNM/res/h/show-pwd.png and /dev/null differ
diff --git a/KylinNM/res/l/network-offline.png b/KylinNM/res/l/network-offline.png
deleted file mode 100644
index a288fc3..0000000
Binary files a/KylinNM/res/l/network-offline.png and /dev/null differ
diff --git a/KylinNM/res/l/network-offline.svg b/KylinNM/res/l/network-offline.svg
deleted file mode 100644
index ca9dcea..0000000
--- a/KylinNM/res/l/network-offline.svg
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
diff --git a/KylinNM/res/l/network-online.png b/KylinNM/res/l/network-online.png
deleted file mode 100644
index b8c5fe4..0000000
Binary files a/KylinNM/res/l/network-online.png and /dev/null differ
diff --git a/KylinNM/res/l/network-online.svg b/KylinNM/res/l/network-online.svg
deleted file mode 100644
index 7f10bfd..0000000
--- a/KylinNM/res/l/network-online.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/KylinNM/res/l/pb-network-info.png b/KylinNM/res/l/pb-network-info.png
deleted file mode 100644
index 23fa16c..0000000
Binary files a/KylinNM/res/l/pb-network-info.png and /dev/null differ
diff --git a/KylinNM/res/l/pb-network-offline.png b/KylinNM/res/l/pb-network-offline.png
deleted file mode 100644
index 77be9f0..0000000
Binary files a/KylinNM/res/l/pb-network-offline.png and /dev/null differ
diff --git a/KylinNM/res/l/pb-network-online.png b/KylinNM/res/l/pb-network-online.png
deleted file mode 100644
index d65dcd5..0000000
Binary files a/KylinNM/res/l/pb-network-online.png and /dev/null differ
diff --git a/KylinNM/res/l/pb-top-network-offline.png b/KylinNM/res/l/pb-top-network-offline.png
deleted file mode 100644
index b5822b9..0000000
Binary files a/KylinNM/res/l/pb-top-network-offline.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-a/1.png b/KylinNM/res/s/conning-a/1.png
deleted file mode 100644
index cd0fafa..0000000
Binary files a/KylinNM/res/s/conning-a/1.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-a/2.png b/KylinNM/res/s/conning-a/2.png
deleted file mode 100644
index 38b549a..0000000
Binary files a/KylinNM/res/s/conning-a/2.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-a/3.png b/KylinNM/res/s/conning-a/3.png
deleted file mode 100644
index c002abd..0000000
Binary files a/KylinNM/res/s/conning-a/3.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-a/4.png b/KylinNM/res/s/conning-a/4.png
deleted file mode 100644
index ec398d0..0000000
Binary files a/KylinNM/res/s/conning-a/4.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-a/5.png b/KylinNM/res/s/conning-a/5.png
deleted file mode 100644
index df58230..0000000
Binary files a/KylinNM/res/s/conning-a/5.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-a/6.png b/KylinNM/res/s/conning-a/6.png
deleted file mode 100644
index 44fbf5d..0000000
Binary files a/KylinNM/res/s/conning-a/6.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-a/7.png b/KylinNM/res/s/conning-a/7.png
deleted file mode 100644
index 1dcfb6d..0000000
Binary files a/KylinNM/res/s/conning-a/7.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-a/8.png b/KylinNM/res/s/conning-a/8.png
deleted file mode 100644
index 0178595..0000000
Binary files a/KylinNM/res/s/conning-a/8.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-b/1.png b/KylinNM/res/s/conning-b/1.png
deleted file mode 100644
index 6255abf..0000000
Binary files a/KylinNM/res/s/conning-b/1.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-b/10.png b/KylinNM/res/s/conning-b/10.png
deleted file mode 100644
index 37e465b..0000000
Binary files a/KylinNM/res/s/conning-b/10.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-b/11.png b/KylinNM/res/s/conning-b/11.png
deleted file mode 100644
index d4f8d0e..0000000
Binary files a/KylinNM/res/s/conning-b/11.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-b/12.png b/KylinNM/res/s/conning-b/12.png
deleted file mode 100644
index 1fa952b..0000000
Binary files a/KylinNM/res/s/conning-b/12.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-b/2.png b/KylinNM/res/s/conning-b/2.png
deleted file mode 100644
index a226b69..0000000
Binary files a/KylinNM/res/s/conning-b/2.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-b/3.png b/KylinNM/res/s/conning-b/3.png
deleted file mode 100644
index 31b1b89..0000000
Binary files a/KylinNM/res/s/conning-b/3.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-b/4.png b/KylinNM/res/s/conning-b/4.png
deleted file mode 100644
index eddd9a8..0000000
Binary files a/KylinNM/res/s/conning-b/4.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-b/5.png b/KylinNM/res/s/conning-b/5.png
deleted file mode 100644
index b0a7062..0000000
Binary files a/KylinNM/res/s/conning-b/5.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-b/6.png b/KylinNM/res/s/conning-b/6.png
deleted file mode 100644
index a970490..0000000
Binary files a/KylinNM/res/s/conning-b/6.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-b/7.png b/KylinNM/res/s/conning-b/7.png
deleted file mode 100644
index c58bde1..0000000
Binary files a/KylinNM/res/s/conning-b/7.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-b/8.png b/KylinNM/res/s/conning-b/8.png
deleted file mode 100644
index f3980b3..0000000
Binary files a/KylinNM/res/s/conning-b/8.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-b/9.png b/KylinNM/res/s/conning-b/9.png
deleted file mode 100644
index 80a8f7e..0000000
Binary files a/KylinNM/res/s/conning-b/9.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-s/1.png b/KylinNM/res/s/conning-s/1.png
deleted file mode 100644
index 6974725..0000000
Binary files a/KylinNM/res/s/conning-s/1.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-s/10.png b/KylinNM/res/s/conning-s/10.png
deleted file mode 100644
index 964a300..0000000
Binary files a/KylinNM/res/s/conning-s/10.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-s/11.png b/KylinNM/res/s/conning-s/11.png
deleted file mode 100644
index d4659b5..0000000
Binary files a/KylinNM/res/s/conning-s/11.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-s/12.png b/KylinNM/res/s/conning-s/12.png
deleted file mode 100644
index cb0272e..0000000
Binary files a/KylinNM/res/s/conning-s/12.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-s/1x/1.png b/KylinNM/res/s/conning-s/1x/1.png
deleted file mode 100644
index 258bd70..0000000
Binary files a/KylinNM/res/s/conning-s/1x/1.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-s/1x/10.png b/KylinNM/res/s/conning-s/1x/10.png
deleted file mode 100644
index 88398b8..0000000
Binary files a/KylinNM/res/s/conning-s/1x/10.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-s/1x/11.png b/KylinNM/res/s/conning-s/1x/11.png
deleted file mode 100644
index 7157960..0000000
Binary files a/KylinNM/res/s/conning-s/1x/11.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-s/1x/12.png b/KylinNM/res/s/conning-s/1x/12.png
deleted file mode 100644
index 60b88e9..0000000
Binary files a/KylinNM/res/s/conning-s/1x/12.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-s/1x/2.png b/KylinNM/res/s/conning-s/1x/2.png
deleted file mode 100644
index 45eedb2..0000000
Binary files a/KylinNM/res/s/conning-s/1x/2.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-s/1x/3.png b/KylinNM/res/s/conning-s/1x/3.png
deleted file mode 100644
index 96cfdad..0000000
Binary files a/KylinNM/res/s/conning-s/1x/3.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-s/1x/4.png b/KylinNM/res/s/conning-s/1x/4.png
deleted file mode 100644
index c8a9a98..0000000
Binary files a/KylinNM/res/s/conning-s/1x/4.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-s/1x/5.png b/KylinNM/res/s/conning-s/1x/5.png
deleted file mode 100644
index 0595e6b..0000000
Binary files a/KylinNM/res/s/conning-s/1x/5.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-s/1x/6.png b/KylinNM/res/s/conning-s/1x/6.png
deleted file mode 100644
index 274f5a8..0000000
Binary files a/KylinNM/res/s/conning-s/1x/6.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-s/1x/7.png b/KylinNM/res/s/conning-s/1x/7.png
deleted file mode 100644
index c49a271..0000000
Binary files a/KylinNM/res/s/conning-s/1x/7.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-s/1x/8.png b/KylinNM/res/s/conning-s/1x/8.png
deleted file mode 100644
index 94946d6..0000000
Binary files a/KylinNM/res/s/conning-s/1x/8.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-s/1x/9.png b/KylinNM/res/s/conning-s/1x/9.png
deleted file mode 100644
index 87f7419..0000000
Binary files a/KylinNM/res/s/conning-s/1x/9.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-s/2.png b/KylinNM/res/s/conning-s/2.png
deleted file mode 100644
index eb6a4a4..0000000
Binary files a/KylinNM/res/s/conning-s/2.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-s/3.png b/KylinNM/res/s/conning-s/3.png
deleted file mode 100644
index f985e8c..0000000
Binary files a/KylinNM/res/s/conning-s/3.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-s/4.png b/KylinNM/res/s/conning-s/4.png
deleted file mode 100644
index e8645dc..0000000
Binary files a/KylinNM/res/s/conning-s/4.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-s/5.png b/KylinNM/res/s/conning-s/5.png
deleted file mode 100644
index 089e671..0000000
Binary files a/KylinNM/res/s/conning-s/5.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-s/6.png b/KylinNM/res/s/conning-s/6.png
deleted file mode 100644
index aee7edf..0000000
Binary files a/KylinNM/res/s/conning-s/6.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-s/7.png b/KylinNM/res/s/conning-s/7.png
deleted file mode 100644
index 914deea..0000000
Binary files a/KylinNM/res/s/conning-s/7.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-s/8.png b/KylinNM/res/s/conning-s/8.png
deleted file mode 100644
index b3de287..0000000
Binary files a/KylinNM/res/s/conning-s/8.png and /dev/null differ
diff --git a/KylinNM/res/s/conning-s/9.png b/KylinNM/res/s/conning-s/9.png
deleted file mode 100644
index ffbdb73..0000000
Binary files a/KylinNM/res/s/conning-s/9.png and /dev/null differ
diff --git a/KylinNM/res/s/rescan/1.png b/KylinNM/res/s/rescan/1.png
deleted file mode 100644
index 19c4f77..0000000
Binary files a/KylinNM/res/s/rescan/1.png and /dev/null differ
diff --git a/KylinNM/res/s/rescan/10.png b/KylinNM/res/s/rescan/10.png
deleted file mode 100644
index 2b4c501..0000000
Binary files a/KylinNM/res/s/rescan/10.png and /dev/null differ
diff --git a/KylinNM/res/s/rescan/11.png b/KylinNM/res/s/rescan/11.png
deleted file mode 100644
index c43ee8c..0000000
Binary files a/KylinNM/res/s/rescan/11.png and /dev/null differ
diff --git a/KylinNM/res/s/rescan/12.png b/KylinNM/res/s/rescan/12.png
deleted file mode 100644
index b3c08be..0000000
Binary files a/KylinNM/res/s/rescan/12.png and /dev/null differ
diff --git a/KylinNM/res/s/rescan/2.png b/KylinNM/res/s/rescan/2.png
deleted file mode 100644
index 4062892..0000000
Binary files a/KylinNM/res/s/rescan/2.png and /dev/null differ
diff --git a/KylinNM/res/s/rescan/3.png b/KylinNM/res/s/rescan/3.png
deleted file mode 100644
index d6a64bc..0000000
Binary files a/KylinNM/res/s/rescan/3.png and /dev/null differ
diff --git a/KylinNM/res/s/rescan/4.png b/KylinNM/res/s/rescan/4.png
deleted file mode 100644
index f92092f..0000000
Binary files a/KylinNM/res/s/rescan/4.png and /dev/null differ
diff --git a/KylinNM/res/s/rescan/5.png b/KylinNM/res/s/rescan/5.png
deleted file mode 100644
index 279fd34..0000000
Binary files a/KylinNM/res/s/rescan/5.png and /dev/null differ
diff --git a/KylinNM/res/s/rescan/6.png b/KylinNM/res/s/rescan/6.png
deleted file mode 100644
index cea2f89..0000000
Binary files a/KylinNM/res/s/rescan/6.png and /dev/null differ
diff --git a/KylinNM/res/s/rescan/7.png b/KylinNM/res/s/rescan/7.png
deleted file mode 100644
index f9b384a..0000000
Binary files a/KylinNM/res/s/rescan/7.png and /dev/null differ
diff --git a/KylinNM/res/s/rescan/8.png b/KylinNM/res/s/rescan/8.png
deleted file mode 100644
index 3930bef..0000000
Binary files a/KylinNM/res/s/rescan/8.png and /dev/null differ
diff --git a/KylinNM/res/s/rescan/9.png b/KylinNM/res/s/rescan/9.png
deleted file mode 100644
index bd22fa1..0000000
Binary files a/KylinNM/res/s/rescan/9.png and /dev/null differ
diff --git a/KylinNM/res/w/pb-all-wifi-offline.png b/KylinNM/res/w/pb-all-wifi-offline.png
deleted file mode 100644
index fb2cb35..0000000
Binary files a/KylinNM/res/w/pb-all-wifi-offline.png and /dev/null differ
diff --git a/KylinNM/res/w/pb-top-wifi-offline.png b/KylinNM/res/w/pb-top-wifi-offline.png
deleted file mode 100644
index 89310de..0000000
Binary files a/KylinNM/res/w/pb-top-wifi-offline.png and /dev/null differ
diff --git a/KylinNM/res/w/wifi-full-off.png b/KylinNM/res/w/wifi-full-off.png
deleted file mode 100644
index 54e83d6..0000000
Binary files a/KylinNM/res/w/wifi-full-off.png and /dev/null differ
diff --git a/KylinNM/res/w/wifi-full-pwd-off.png b/KylinNM/res/w/wifi-full-pwd-off.png
deleted file mode 100644
index 7949090..0000000
Binary files a/KylinNM/res/w/wifi-full-pwd-off.png and /dev/null differ
diff --git a/KylinNM/res/w/wifi-full-pwd.png b/KylinNM/res/w/wifi-full-pwd.png
deleted file mode 100644
index 292c031..0000000
Binary files a/KylinNM/res/w/wifi-full-pwd.png and /dev/null differ
diff --git a/KylinNM/res/w/wifi-full.png b/KylinNM/res/w/wifi-full.png
deleted file mode 100644
index a858240..0000000
Binary files a/KylinNM/res/w/wifi-full.png and /dev/null differ
diff --git a/KylinNM/res/w/wifi-high-off.png b/KylinNM/res/w/wifi-high-off.png
deleted file mode 100644
index cc5fa77..0000000
Binary files a/KylinNM/res/w/wifi-high-off.png and /dev/null differ
diff --git a/KylinNM/res/w/wifi-high-pwd-off.png b/KylinNM/res/w/wifi-high-pwd-off.png
deleted file mode 100644
index 2ca3038..0000000
Binary files a/KylinNM/res/w/wifi-high-pwd-off.png and /dev/null differ
diff --git a/KylinNM/res/w/wifi-high-pwd.png b/KylinNM/res/w/wifi-high-pwd.png
deleted file mode 100644
index 3b1f477..0000000
Binary files a/KylinNM/res/w/wifi-high-pwd.png and /dev/null differ
diff --git a/KylinNM/res/w/wifi-high.png b/KylinNM/res/w/wifi-high.png
deleted file mode 100644
index f6ab167..0000000
Binary files a/KylinNM/res/w/wifi-high.png and /dev/null differ
diff --git a/KylinNM/res/w/wifi-low-off.png b/KylinNM/res/w/wifi-low-off.png
deleted file mode 100644
index 60e238a..0000000
Binary files a/KylinNM/res/w/wifi-low-off.png and /dev/null differ
diff --git a/KylinNM/res/w/wifi-low-pwd-off.png b/KylinNM/res/w/wifi-low-pwd-off.png
deleted file mode 100644
index 1c6860d..0000000
Binary files a/KylinNM/res/w/wifi-low-pwd-off.png and /dev/null differ
diff --git a/KylinNM/res/w/wifi-low-pwd.png b/KylinNM/res/w/wifi-low-pwd.png
deleted file mode 100644
index 9cc769e..0000000
Binary files a/KylinNM/res/w/wifi-low-pwd.png and /dev/null differ
diff --git a/KylinNM/res/w/wifi-low.png b/KylinNM/res/w/wifi-low.png
deleted file mode 100644
index 3631505..0000000
Binary files a/KylinNM/res/w/wifi-low.png and /dev/null differ
diff --git a/KylinNM/res/w/wifi-medium-off.png b/KylinNM/res/w/wifi-medium-off.png
deleted file mode 100644
index c823649..0000000
Binary files a/KylinNM/res/w/wifi-medium-off.png and /dev/null differ
diff --git a/KylinNM/res/w/wifi-medium-pwd-off.png b/KylinNM/res/w/wifi-medium-pwd-off.png
deleted file mode 100644
index a9e96d8..0000000
Binary files a/KylinNM/res/w/wifi-medium-pwd-off.png and /dev/null differ
diff --git a/KylinNM/res/w/wifi-medium-pwd.png b/KylinNM/res/w/wifi-medium-pwd.png
deleted file mode 100644
index cc2d363..0000000
Binary files a/KylinNM/res/w/wifi-medium-pwd.png and /dev/null differ
diff --git a/KylinNM/res/w/wifi-medium.png b/KylinNM/res/w/wifi-medium.png
deleted file mode 100644
index 82cdf40..0000000
Binary files a/KylinNM/res/w/wifi-medium.png and /dev/null differ
diff --git a/KylinNM/res/w/wifi-none-off.png b/KylinNM/res/w/wifi-none-off.png
deleted file mode 100644
index 65dceb2..0000000
Binary files a/KylinNM/res/w/wifi-none-off.png and /dev/null differ
diff --git a/KylinNM/res/w/wifi-none-pwd-off.png b/KylinNM/res/w/wifi-none-pwd-off.png
deleted file mode 100644
index 0cdd769..0000000
Binary files a/KylinNM/res/w/wifi-none-pwd-off.png and /dev/null differ
diff --git a/KylinNM/res/w/wifi-none-pwd.png b/KylinNM/res/w/wifi-none-pwd.png
deleted file mode 100644
index c3fd701..0000000
Binary files a/KylinNM/res/w/wifi-none-pwd.png and /dev/null differ
diff --git a/KylinNM/res/w/wifi-none.png b/KylinNM/res/w/wifi-none.png
deleted file mode 100644
index b4927dc..0000000
Binary files a/KylinNM/res/w/wifi-none.png and /dev/null differ
diff --git a/KylinNM/res/x/fly-mode-off.svg b/KylinNM/res/x/fly-mode-off.svg
deleted file mode 100644
index 408b7b0..0000000
--- a/KylinNM/res/x/fly-mode-off.svg
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
diff --git a/KylinNM/res/x/fly-mode-on.svg b/KylinNM/res/x/fly-mode-on.svg
deleted file mode 100644
index 9f5e543..0000000
--- a/KylinNM/res/x/fly-mode-on.svg
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
diff --git a/KylinNM/res/x/hot-spot-off.svg b/KylinNM/res/x/hot-spot-off.svg
deleted file mode 100644
index cf39cad..0000000
--- a/KylinNM/res/x/hot-spot-off.svg
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
diff --git a/KylinNM/res/x/hot-spot-on.svg b/KylinNM/res/x/hot-spot-on.svg
deleted file mode 100644
index 2041db9..0000000
--- a/KylinNM/res/x/hot-spot-on.svg
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
diff --git a/KylinNM/res/x/load-down.png b/KylinNM/res/x/load-down.png
deleted file mode 100644
index a96298a..0000000
Binary files a/KylinNM/res/x/load-down.png and /dev/null differ
diff --git a/KylinNM/res/x/load-up.png b/KylinNM/res/x/load-up.png
deleted file mode 100644
index e5ec581..0000000
Binary files a/KylinNM/res/x/load-up.png and /dev/null differ
diff --git a/KylinNM/res/x/net-list-bg.svg b/KylinNM/res/x/net-list-bg.svg
deleted file mode 100644
index c17c1fd..0000000
--- a/KylinNM/res/x/net-list-bg.svg
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
diff --git a/KylinNM/res/x/pb-close.png b/KylinNM/res/x/pb-close.png
deleted file mode 100644
index c5cc8ad..0000000
Binary files a/KylinNM/res/x/pb-close.png and /dev/null differ
diff --git a/KylinNM/res/x/pb-conn-dis.png b/KylinNM/res/x/pb-conn-dis.png
deleted file mode 100644
index 3726203..0000000
Binary files a/KylinNM/res/x/pb-conn-dis.png and /dev/null differ
diff --git a/KylinNM/res/x/pb-newConn.png b/KylinNM/res/x/pb-newConn.png
deleted file mode 100644
index 86a18e0..0000000
Binary files a/KylinNM/res/x/pb-newConn.png and /dev/null differ
diff --git a/KylinNM/res/x/pb-wifi-n.png b/KylinNM/res/x/pb-wifi-n.png
deleted file mode 100644
index 54e83d6..0000000
Binary files a/KylinNM/res/x/pb-wifi-n.png and /dev/null differ
diff --git a/KylinNM/res/x/pb-wifi-y.png b/KylinNM/res/x/pb-wifi-y.png
deleted file mode 100644
index a858240..0000000
Binary files a/KylinNM/res/x/pb-wifi-y.png and /dev/null differ
diff --git a/KylinNM/res/x/setup.png b/KylinNM/res/x/setup.png
deleted file mode 100644
index fe242f8..0000000
Binary files a/KylinNM/res/x/setup.png and /dev/null differ
diff --git a/KylinNM/res/x/wifi-list-bg.svg b/KylinNM/res/x/wifi-list-bg.svg
deleted file mode 100644
index 43f1866..0000000
--- a/KylinNM/res/x/wifi-list-bg.svg
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
diff --git a/KylinNM/src/backthread.cpp b/KylinNM/src/backthread.cpp
deleted file mode 100644
index 5af20e0..0000000
--- a/KylinNM/src/backthread.cpp
+++ /dev/null
@@ -1,464 +0,0 @@
-/*
- * Copyright (C) 2020 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
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-
-#include "kylinnm.h" //逼不得已,引入kylinnm头文件
-
-BackThread::BackThread(QObject *parent) : QObject(parent)
-{
-}
-
-BackThread::~BackThread()
-{
- if (cmdConnWifi) {
- cmdConnWifi->close();
- }
-}
-
-//get the connection state of wired and wireles network
-IFace BackThread::execGetIface()
-{
- IFace 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;
- Utils::m_system(cmd.toUtf8().data());
-
- // int status = system(cmd.toUtf8().data());
- // if (status != 0){ syslog(LOG_ERR, "execute 'nmcli device' in function 'execGetIface' failed");}
-
- QFile file(tmpPath);
- if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
- // print information if can not open file ~/.config/kylin-nm-iface
- syslog(LOG_ERR, "Can't open the file ~/.config/kylin-nm-iface!");
- qDebug()<<"Can't open the file ~/.config/kylin-nm-iface!";
- }
- QString txt = file.readAll();
- QStringList txtList = txt.split("\n");
- file.close();
-
- iface.lstate = 2;
- iface.wstate = 2;
-
- for (int i = 1; i < txtList.size(); i ++) {
- QString line = txtList.at(i);
- if (line != "") {
- int index1 = line.indexOf(" ");
- QString type = line.left(index1);
- QString lastStr = line.mid(index1).trimmed();
- int index2 = lastStr.indexOf(" ");
- QString iname = lastStr.left(index2);
- QString istateStr = lastStr.mid(index2).trimmed();
-
- if (type == "ethernet" && iface.lstate != 0) {
- // if type is wired network
- iface.lname = iname;
-
- if (istateStr == "unmanaged") {
- iface.lstate = 2; //switch of wired device is off
- }
- if (istateStr == "disconnected" || istateStr == "unavailable") {
- iface.lstate = 1; //wired network is disconnected
- }
- if (istateStr == "connected") {
- iface.lstate = 0; //wired network is connected
- }
- }
- if (type == "wifi" && iface.wstate != 0) {
- // if type is wireless network
- iface.wname = iname;
-
- if (istateStr == "unmanaged" || istateStr == "unavailable") {
- iface.wstate = 2; //switch of wireless device is off
- }
- if (istateStr == "disconnected") {
- iface.wstate = 1; //wireless network is disconnected
- }
- if (istateStr == "connected") {
- iface.wstate = 0; //wireless network is connected
- }
- }
- }
- }
-
- return iface;
-}
-
-//turn on the switch of network
-void BackThread::execEnNet()
-{
- char *chr = "nmcli networking on";
- Utils::m_system(chr);
-
- // 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) {
- sleep(3);
- emit enNetDone();
- emit btFinish();
- break;
- }
- sleep(1);
- }
-}
-
-//turn off the switch of wireless network first, then turn off the switch of network
-void BackThread::execDisNet()
-{
- 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) {
- emit disWifiDone();
- emit btFinish();
- break;
- }
- sleep(1);
- }
- }
-
- char *chr1 = "nmcli networking off";
- Utils::m_system(chr1);
- // 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) {
- emit disNetDone();
- emit btFinish();
- break;
- }
- sleep(1);
- }
-}
-
-//turn on the switch of wireless network
-void BackThread::execEnWifi()
-{
- //if (execGetIface()->lstate == 2){
- // char *chr = "nmcli networking on";
- // Utils::m_system(chr);
- // //int status = system("nmcli networking on");
- // //if (status != 0){ syslog(LOG_ERR, "execute 'nmcli networking on' in function 'execEnWifi' failed");}
- // while(1){
- // if (execGetIface()->lstate != 2){
- // emit launchLanDone();
- // break;
- // }
- // sleep(1);
- // }
- //}
-
- char *chr1 = "nmcli radio wifi on";
- Utils::m_system(chr1);
- //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) {
- KylinDBus objKyDbus;
- while (1) {
- if (objKyDbus.getAccessPointsNumber() > 0) {
- // objKyDbus.getAccessPointsNumber()>0 standard can get wireless accesspoints now
- KylinNM::reflashWifiUi();
- emit enWifiDone();
- emit btFinish();
- break;
- }
- sleep(2);
- }
- break;
- }
- sleep(1);
- }
-}
-
-//turn off the switch of wireless network
-void BackThread::execDisWifi()
-{
- 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 'execDisWifi' failed");}
- while (1) {
- if (execGetIface().wstate == 2) {
- KylinNM::reflashWifiUi();
- emit disWifiDone();
- emit btFinish();
- break;
- }
- sleep(1);
- }
-}
-
-//to connect wired network
-void BackThread::execConnLan(QString connName)
-{
- disConnLanOrWifi("ethernet");
-
- KylinDBus objKyDbus;
- if (objKyDbus.isWiredCableOn) {
- // only if wired cable is plug in, can connect wired network
- QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up \"" + connName.replace("\"","\\\"") + "\"";
- 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: "< " + tmpPath;
- Utils::m_system(cmdStr.toUtf8().data());
- // int status = system(cmdStr.toUtf8().data());
- // if (status != 0){ syslog(LOG_ERR, "execute 'nmcli device wifi connect' in function 'execConnWifiPWD' failed");}
- QFile file(tmpPath);
- if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
- syslog(LOG_DEBUG, "Can't open the file /tmp/kylin-nm-btoutput !");
- qDebug()<<"Can't open the file /tmp/kylin-nm-btoutput !"<start("bash");
- cmdConnWifi->waitForStarted();
- }
- QString cmdStr = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up \"" + connName.replace("\"","\\\"") + "\"\n";
- cmdConnWifi->write(cmdStr.toUtf8().data());
-}
-
-void BackThread::on_readoutput()
-{
- QString str = cmdConnWifi->readAllStandardOutput();
- cmdConnWifi->close();
- 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: "<readAllStandardError();
- cmdConnWifi->close();
- qDebug()<<"on_readerror: "<< str;
- if (str.indexOf("successfully") != -1) {
- emit connDone(0);
- } else if(str.indexOf("unknown") != -1 || str.indexOf("not exist") != -1) {
- emit connDone(2); //send this signal if the network we want to connect has not a configuration file
- } else {
- emit connDone(1); //send this signal if connect net failed
- }
-
- emit btFinish();
-}
-
-//get property of connected network
-QString BackThread::getConnProp(QString connName)
-{
- QString tmpPath = "/tmp/kylin-nm-connprop-" + QDir::home().dirName();
- QString cmd = "export LANG='zh_CN.UTF-8';export LANGUAGE='zh_CN';nmcli connection show \"" + connName.replace("\"","\\\"") + "\" > " + tmpPath;
- Utils::m_system(cmd.toUtf8().data());
- // int status = system(cmd.toUtf8().data());
- // if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection show' in function 'getConnProp' failed");}
-
- QFile file(tmpPath);
- if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
- syslog(LOG_ERR, "Can't open the file /tmp/kylin-nm-connprop!");
- qDebug()<<"Can't open the file /tmp/kylin-nm-connprop!"< " + tmpPath;
- Utils::m_system(cmd.toUtf8().data());
- // int status = system(cmd.toUtf8().data());
- // if (status != 0){ syslog(LOG_ERR, "execute 'ethtool' in function 'execChkLanWidth' failed");}
-
- QFile file(tmpPath);
- if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
- syslog(LOG_ERR, "Can't open the file /tmp/kylin-nm-bandwidth!");
- qDebug()<<"Can't open the file /tmp/kylin-nm-bandwidth!"<
-#include
-#include
-#include
-#include
-#include
-#include
-
-class IFace{
-public:
- QString lname = "";
- QString wname = "";
- int lstate = 2; // 0已连接 1未连接 2已关闭
- int wstate = 2; // 0已连接 1未连接 2已关闭
-};
-
-class BackThread : public QObject
-{
- Q_OBJECT
-public:
- explicit BackThread(QObject *parent = nullptr);
- ~BackThread();
-
- IFace execGetIface();
- QString getConnProp(QString connName);
- QString execChkLanWidth(QString ethName);
- QProcess *cmdConnWifi = nullptr;
-
-public Q_SLOTS:
- void execEnNet();
- void execDisNet();
- void execEnWifi();
- void execDisWifi();
- void execConnLan(QString connName);
- void execConnWifi(QString connName);
- void execConnWifiPWD(QString connName, QString password);
-
- void disConnSparedNetSlot(QString type);
- void disConnLanOrWifi(QString type);
-
- void on_readoutput();
- void on_readerror();
-
-Q_SIGNALS:
- void enNetDone();
- void disNetDone();
- void enWifiDone();
- void launchLanDone();
- void disWifiDone();
-
- void connDone(int connFlag);
-
- void btFinish();
- void disFinish();
- void ttFinish();
-};
-
-#endif // BACKTHREAD_H
diff --git a/KylinNM/src/confform.cpp b/KylinNM/src/confform.cpp
deleted file mode 100644
index 493c50a..0000000
--- a/KylinNM/src/confform.cpp
+++ /dev/null
@@ -1,552 +0,0 @@
-/*
- * Copyright (C) 2020 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
-#include
-#include
-
-extern QString llname, lwname;
-
-ConfForm::ConfForm(QWidget *parent) :
- QWidget(parent),
- ui(new Ui::ConfForm)
-{
- ui->setupUi(this);
- this->setWindowFlags(Qt::FramelessWindowHint); //Qt::WindowStaysOnTopHint
- this->setWindowTitle(tr("edit network"));//"网络设置"
- this->setAttribute(Qt::WA_TranslucentBackground);
- //需要添加 void paintEvent(QPaintEvent *event) 函数
-
- QPainterPath path;
- auto rect = this->rect();
- rect.adjust(1, 1, -1, -1);
- path.addRoundedRect(rect, 6, 6);
- setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
-
- this->setStyleSheet("QWidget{border-radius:16px;border:none;}");
-// KylinDBus mkylindbus;
-
- QString strTrans;
- strTrans = QString::number(1, 10, 2);
- QString sty = "#centralWidget{border:1px solid rgba(255,255,255,0.05);border-radius:16px;background:rgba(255,255,255," + strTrans + ");}";
- ui->centralWidget->setStyleSheet(sty);
-
- labelQss = "QLabel{border:0px;color:rgba(38,38,38,1);background-color:transparent;}";
- cbxQss = "QComboBox{padding-left:20px;font-size:13px;color:rgba(38,38,38,1);"
- "border:1px solid rgba(255, 255, 255, 0.05);border-radius:4px;background:rgba(255,255,255,0.08);}"
- "QComboBox::drop-down{border:0px;width:30px;}"
- "QComboBox::down-arrow{image:url(:/res/g/down_arrow.png);}"
- "QComboBox QAbstractItemView {margin:0px 0px 0px 0px;padding: 0px 0px;border-radius:0px;background-color:#48484C;outline:0px;}"
- "QComboBox QAbstractItemView::item{padding-left:17px;border-radius:0px;font-size:13px;color:rgba(255,255,255,0.91);height: 32px;background-color:#48484C;outline:0px;}"
- "QComboBox QAbstractItemView::item:hover{padding-left:17px;border-radius:0px;font-size:13px;color:rgba(255,255,255,0.91);background-color:#3D6BE5;outline:0px;}";
- leQss = "QLineEdit{padding-left:20px;color:rgba(38,38,38,1);background:rgba(245,245,245,1);}";
- btnOffQss = "QPushButton{border:1px solid rgba(44,44,44,1);border-radius:4px;background-color:rgba(255,255,255,0.12);color:rgba(44,44,44,1);font-size:14px;}";
- // "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(255,255,255,0.2);}"
- // "QPushButton:Pressed{border-radius:4px;background-color:rgba(255,255,255,0.08);}";
- btnOnQss = "QPushButton{border:0px;border-radius:4px;background-color:rgba(61,107,229,1);color:white;font-size:14px;}"
- "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(107,142,235,1);}"
- "QPushButton:Pressed{border-radius:4px;background-color:rgba(50,87,202,1);}";
- lineQss = "background:rgba(255,255,255,0.08);";
-
- // ui->centralWidget->setStyleSheet("#centralWidget{border:1px solid #297a97;background-color:#ffffff;}");
- ui->wdHead->setStyleSheet("#wdHead{border:none}");
- ui->wgManual->setStyleSheet("#wgManual{border:none}");
- ui->wdBottom->setStyleSheet("#wdBottom{border:none}");
- ui->lbLeftupTitle->setStyleSheet("QLabel{border:0px;font-size:14px;color:rgba(38,38,38,1);background-color:transparent;}");
- ui->lbName->setStyleSheet(labelQss);
- ui->lbTxt1->setStyleSheet(labelQss);
- ui->lbTxt2->setStyleSheet(labelQss);
- ui->lbTxt3->setStyleSheet(labelQss);
- ui->lbTxt4->setStyleSheet(labelQss);
- ui->lbTxt5->setStyleSheet(labelQss);
- ui->lbTxt6->setStyleSheet(labelQss);
-
- //YYF
- ui->btnClose->setStyleSheet("border-image:url(:/res/x/pb-close.png);");
- connect(ui->btnClose,&QPushButton::clicked,ui->btnCancel,&QPushButton::clicked);
- ui->isDHCP->setStyleSheet("QCheckBox::indicator {width: 16px; height: 16px;}"
- "QCheckBox::indicator:checked {image: url(:/res/g/checkbox-checked.svg);}"
- "QCheckBox::indicator:unchecked {image: url(:/res/g/checkbox-unchecked.svg);}");
- ui->notDHCP->setStyleSheet("QCheckBox::indicator {width: 16px; height: 16px;}"
- "QCheckBox::indicator:checked {image: url(:/res/g/checkbox-checked.svg);}"
- "QCheckBox::indicator:unchecked {image: url(:/res/g/checkbox-unchecked.svg);}");
-
- ui->cbType->setStyleSheet(cbxQss);
- ui->cbType->setView(new QListView());
- ui->cbType->hide();
- ui->cbMask->setStyleSheet(cbxQss);
- ui->cbMask->setView(new QListView());
-
- ui->leName->setStyleSheet(leQss);
- ui->leAddr->setStyleSheet(leQss);
- ui->leGateway->setStyleSheet(leQss);
- ui->leDns->setStyleSheet(leQss);
- ui->leDns2->setStyleSheet(leQss);
-
- ui->btnCancel->setStyleSheet(btnOffQss);
- ui->btnOk->setStyleSheet(btnOnQss);
- ui->btnCreate->setStyleSheet(btnOnQss);
- ui->lineUp->setStyleSheet(lineQss);
- ui->lineDown->setStyleSheet(lineQss);
- ui->lineUp->hide();
- ui->lineDown->hide();
-
- ui->lbName->setText(tr("LAN name: "));//"网络名称:"
- ui->lbTxt1->setText(tr("Method: "));//"编辑IP设置:"
- ui->lbTxt2->setText(tr("Address: "));//"IP地址:"
- ui->lbTxt3->setText(tr("Netmask: "));//"子网掩码:"
- ui->lbTxt4->setText(tr("Gateway: "));//"默认网关:"
- ui->lbTxt5->setText(tr("DNS 1: "));//"首选DNS:"
- ui->lbTxt6->setText(tr("DNS 2: "));//"备选DNS:"
-
- ui->lbLeftupTitle->setText(tr("Edit Conn"));//"网络设置"
- ui->cbType->addItem(tr("Auto(DHCP)"));//"自动(DHCP)"
- ui->cbType->addItem(tr("Manual"));//"手动"
- ui->isDHCP->setText(tr("Auto(DHCP)"));
- ui->notDHCP->setText(tr("Manual"));
-
- connect(ui->cbType, SIGNAL(currentIndexChanged(int)), this, SLOT(cbTypeChanged(int)));
-
- ui->cbMask->addItem("255.255.255.0"); //24
- ui->cbMask->addItem("255.255.254.0"); //23
- ui->cbMask->addItem("255.255.252.0"); //22
- ui->cbMask->addItem("255.255.0.0"); //16
- ui->cbMask->addItem("255.0.0.0"); //8
-// ui->cbMask->setWindowFlags(Qt::X11BypassWindowManagerHint);
- ui->cbMask->view()->setWindowFlags(Qt::Popup | Qt::X11BypassWindowManagerHint);
- ui->cbMask->view()->setParent(this);
- ui->cbMask->view()->hide();
-
- ui->cbMask->installEventFilter(this);
- ui->cbMask->view()->installEventFilter(this);
-
- connect(ui->cbMask->view(), &QAbstractItemView::pressed, this, [=](QModelIndex index){
-// qDebug() << "-----------------------pressed:" << index.row();
-// qDebug() << "-----------------------itemText:" << ui->cbMask->itemText(index.row());
- Q_EMIT ui->cbMask->setCurrentIndex(index.row());
- ui->cbMask->view()->hide();
- });
-
-// connect(ui->cbMask->view(), &QAbstractItemView::entered, this, [=](QModelIndex index){
-// qDebug() << "-----------------------entered:" << index.row();
-// });
-
- ui->cbMask->view()->setGeometry(QRect(ui->cbMask->geometry().left(), ui->wgManual->geometry().top() + ui->cbMask->geometry().bottom(), ui->cbMask->view()->width(), ui->cbMask->view()->height()));
-
- ui->btnCancel->setText(tr("Cancel"));//"取消"
- ui->btnOk->setText(tr("Save"));//"保存"
- ui->btnCreate->setText(tr("Ok"));//"确定"
-
- ui->btnCancel->setFocusPolicy(Qt::NoFocus);
- ui->btnOk->setFocusPolicy(Qt::NoFocus);
- ui->btnCreate->setFocusPolicy(Qt::NoFocus);
-
- // IP的正则格式限制
- QRegExp rx("\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b");
- ui->leAddr->setValidator(new QRegExpValidator(rx, this));
- ui->leGateway->setValidator(new QRegExpValidator(rx, this));
- ui->leDns->setValidator(new QRegExpValidator(rx, this));
- ui->leDns2->setValidator(new QRegExpValidator(rx, this));
-
-}
-
-void ConfForm::setMainWindow(KylinNM *mainwindow)
-{
- this->mw = mainwindow;
-}
-
-ConfForm::~ConfForm()
-{
- delete ui;
-}
-
-bool ConfForm::eventFilter(QObject *obj, QEvent *ev)
-{
- if(obj == ui->cbMask)
- {
- if(ev->type() == QEvent::MouseButtonPress)
- {
- ui->cbMask->view()->setVisible(!ui->cbMask->view()->isVisible());
- if(ui->cbMask->view()->isVisible())
- ui->cbMask->view()->setFocus();
- }
- } else if (obj != ui->cbMask->view())
- {
- ui->cbMask->view()->hide();
- }
- return false;
-}
-
-void ConfForm::mousePressEvent(QMouseEvent *event)
-{
- if (event->button() == Qt::LeftButton) {
- this->isPress = true;
- this->winPos = this->pos();
- this->dragPos = event->globalPos();
- event->accept();
- }
-}
-void ConfForm::mouseReleaseEvent(QMouseEvent *event)
-{
- this->isPress = false;
-}
-void ConfForm::mouseMoveEvent(QMouseEvent *event)
-{
- if (this->isPress) {
- this->move(this->winPos - (this->dragPos - event->globalPos()));
- event->accept();
- }
-}
-
-void ConfForm::tabletStyle(bool isTablet)
-{
- isTabletStyle = isTablet;
-
- ui->leName->resize(290+194*isTabletStyle,48);
- ui->leName->resize(290+194*isTabletStyle,48);
- ui->btnOk->move(312+194*isTabletStyle,25);
- ui->btnCreate->move(312+194*isTabletStyle,25);
- ui->btnCancel->move(180+194*isTabletStyle,25);
- ui->btnClose->move(408+194*isTabletStyle,8);
- ui->isDHCP->move(180+194*isTabletStyle,130);
- ui->notDHCP->move(356+194*isTabletStyle,130);
-
- ui->wdBottom->setFixedWidth(446+194*isTabletStyle);
- ui->wdHead->setFixedWidth(446+194*isTabletStyle);
- ui->wgManual->setFixedWidth(446+194*isTabletStyle);
- ui->upTitle->setFixedWidth(446+194*isTabletStyle);
-}
-
-//网络配置参数设置界面的显示内容
-void ConfForm::setProp(QString connName, QString v4method, QString addr, QString mask, QString gateway, QString dns, bool isActConf)
-{
- this->isActConf = isActConf;
- ui->leName->setText(connName);
-
- if (v4method == "auto" || v4method == "") {
- ui->isDHCP->setChecked(true);
- ui->notDHCP->setChecked(false);
- ui->cbType->setCurrentIndex(0);
- cbTypeChanged(0);
- } else {
- ui->isDHCP->setChecked(false);
- ui->notDHCP->setChecked(true);
- ui->cbType->setCurrentIndex(1);
- cbTypeChanged(1);
- }
-
- ui->leAddr->setText(addr);
- ui->leGateway->setText(gateway);
-
- // 配置中有多个DNS,只处理前两个
- if (dns.indexOf(",") != -1) {
- QStringList dnss = dns.split(",");
- ui->leDns->setText(dnss.at(0));
- ui->leDns2->setText(dnss.at(1));
- } else {
- ui->leDns->setText(dns);
- ui->leDns2->setText("");
- }
-
- if (mask == "24") {
- ui->cbMask->setCurrentIndex(0);
- } else if(mask == "23") {
- ui->cbMask->setCurrentIndex(1);
- } else if(mask == "22") {
- ui->cbMask->setCurrentIndex(2);
- } else if(mask == "16") {
- ui->cbMask->setCurrentIndex(3);
- } else if(mask == "8") {
- ui->cbMask->setCurrentIndex(4);
- } else {
- ui->cbMask->setCurrentIndex(0);
- }
-}
-
-//点击了创建新的网络的按钮
-void ConfForm::on_btnCreate_clicked()
-{
- if (mw->lanNameList.contains(ui->leName->text())) {
- qWarning() << "Warn : 已有同名LAN存在:" << ui->leName->text();
- // ui->tipLabel->show();
- return;
- }
- KylinDBus kylindbus;
- kylindbus.getWiredCardName();
- QString mIfname = kylindbus.dbusLanCardName;
-
- if (mIfname == "") {
- QString tip(tr("Can not create new wired network for without wired card"));
-// kylindbus.showDesktopNotify(tip);
- this->hide();
- return;
- }
-
- QString name = ui->leName->text();
- QString cmdStr = "nmcli connection add con-name \"" + name.replace("\"","\\\"") + "\" type ethernet"; //由于样机存在veth虚拟网卡,故不指定有线设备,将自动选择
- Utils::m_system(cmdStr.toUtf8().data());
- //int status = system(cmdStr.toUtf8().data());
- //if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection add con-name' in function 'on_btnCreate_clicked' failed");}
-
- if (ui->cbType->currentIndex() == 1) {
- //config the ipv4 and netmask and gateway if select Manual
- this->isCreateNewNet = true;
- this->on_btnOk_clicked();
- } else {
- QString txt(tr("New network already created"));
-// kylindbus.showDesktopNotify(txt);
- }
-
- this->hide();
-}
-
-//点击了保存更改网络设置的按钮
-void ConfForm::on_btnOk_clicked()
-{
- QString mask = "";
- if (ui->cbMask->currentIndex() == 0) {
- mask = "24";
- } else if(ui->cbMask->currentIndex() == 1) {
- mask = "23";
- } else if(ui->cbMask->currentIndex() == 2) {
- mask = "22";
- } else if(ui->cbMask->currentIndex() == 3) {
- mask = "16";
- } else if(ui->cbMask->currentIndex() == 4) {
- mask = "8";
- } else {
- mask = "24";
- }
-
- if (ui->cbType->currentIndex() == 0) {
- QString name = ui->leName->text();
- name.replace("\"","\\\"");
- kylin_network_set_automethod(name.toUtf8().data());
- } else {
- QString dnss = ui->leDns->text();
- if (ui->leDns2->text() != "") {
- dnss.append(",");
- dnss.append(ui->leDns2->text());
- }
- QString name = ui->leName->text();
- name.replace("\"","\\\"");
- kylin_network_set_manualall(name.toUtf8().data(), ui->leAddr->text().toUtf8().data(), mask.toUtf8().data(), ui->leGateway->text().toUtf8().data(), dnss.toUtf8().data());
- }
-
- KylinDBus kylindbus;
-
- this->hide();
-
- QString txt(tr("New network settings already finished"));
- kylindbus.showDesktopNotify(txt);
-
- if (!this->isCreateNewNet) {
- if (this->isActConf == true) {
- // 如果是修改当前连接的网络,则修改设置后简略重连网络
- //QString cmd = "/usr/share/kylin-nm/shell/connup.sh '" + ui->leName->text() + "'";
- kylindbus.connectWiredNet(ui->leName->text()); //reconnect this wired network
-
- QString m_txt(tr("New settings already effective"));
- kylindbus.showDesktopNotify(m_txt); //show desktop notify
- }
-
- //需要更新一下有线网界面
- qDebug()<<"debug: request refresh Lan list";
- emit requestRefreshLanList(0);
- }
- this->isCreateNewNet = false;
-}
-
-//点击取消按钮
-void ConfForm::on_btnCancel_clicked()
-{
- this->hide();
-}
-
-//根据需要设置的种类(自动或手动等)显示界面内容
-void ConfForm::cbTypeChanged(int index)
-{
- if (isShowSaveBtn) {
- ui->leName->setEnabled(false);
- ui->btnOk->show(); //显示保存按钮
- ui->btnCreate->hide(); //隐藏创建按钮
- ui->lbLeftupTitle->setText(tr("Edit Network"));
- }
-
- if (index == 0) {
- ui->lineUp->hide();
- ui->lineDown->hide();
- ui->wgManual->hide();
- ui->centralWidget->resize(446+194*isTabletStyle, 443);
- ui->wdBottom->move(0, 347);
-
- this->setEnableOfBtn();
-
- this->resize(446+194*isTabletStyle,443);
- }
- if (index == 1) {
- ui->lineUp->show();
- ui->lineDown->show();
- ui->wgManual->show();
- ui->centralWidget->resize(446+194*isTabletStyle, 576);
- ui->wdBottom->move(0, 480);
-
- this->setEnableOfBtn();
-
- this->resize(446+194*isTabletStyle, 576);
- }
- if (index == 3) {
- ui->isDHCP->setChecked(true);
- ui->notDHCP->setChecked(false);
- ui->btnOk->setStyleSheet(btnOffQss);
- ui->btnOk->setEnabled(false);
- ui->btnCreate->setStyleSheet(btnOffQss);
- ui->btnCreate->setEnabled(false);
-
- ui->leName->setEnabled(true);
- ui->btnOk->hide();
- ui->btnCreate->show();
- ui->lbLeftupTitle->setText(tr("Add Wired Network"));
- isShowSaveBtn = false;
-
- ui->lineUp->hide();
- ui->lineDown->hide();
- ui->wgManual->hide();
- ui->centralWidget->resize(446+194*isTabletStyle, 443);
- ui->wdBottom->move(0, 347);
- this->resize(446+194*isTabletStyle, 443);
- }
-}
-
-//编辑网络名称
-void ConfForm::on_leName_textEdited(const QString &arg1)
-{
- this->setEnableOfBtn();
-}
-
-//编辑网络ip
-void ConfForm::on_leAddr_textEdited(const QString &arg1)
-{
- this->setEnableOfBtn();
-}
-
-//编辑网络网关
-void ConfForm::on_leGateway_textEdited(const QString &arg1)
-{
- this->setEnableOfBtn();
-}
-
-//编辑网络DNS
-void ConfForm::on_leDns_textEdited(const QString &arg1)
-{
- this->setEnableOfBtn();
-}
-
-//编辑网络备用DNS
-void ConfForm::on_leDns2_textEdited(const QString &arg1)
-{
- // this->setEnableOfBtn();
-}
-
-//设置界面按钮是否可点击
-void ConfForm::setEnableOfBtn()
-{
- if (ui->leName->text().size() == 0 ) {
- this->setBtnEnableFalse();
- return;
- }
-
- if (ui->cbType->currentIndex() == 1) {
- if (!this->getTextEditState(ui->leAddr->text()) ) {
- this->setBtnEnableFalse();
- return;
- }
-
- if (!this->getTextEditState(ui->leGateway->text()) ) {
- this->setBtnEnableFalse();
- return;
- }
-
- if (!this->getTextEditState(ui->leDns->text()) ) {
- this->setBtnEnableFalse();
- return;
- }
- }
-
- ui->btnOk->setStyleSheet(btnOnQss);
- ui->btnOk->setEnabled(true);
-
- ui->btnCreate->setStyleSheet(btnOnQss);
- ui->btnCreate->setEnabled(true);
-}
-
-//文本的输入要符合ip的格式要求
-bool ConfForm::getTextEditState(QString text)
-{
- QRegExp rx("\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b");
-
- bool match = false;
- match = rx.exactMatch(text);
- // qDebug()<<"the match result is: " << match;
-
- return match;
-}
-
-//设置创建或保存按钮不可点击
-void ConfForm::setBtnEnableFalse()
-{
- ui->btnOk->setStyleSheet(btnOffQss);
- ui->btnOk->setEnabled(false);
-
- ui->btnCreate->setStyleSheet(btnOffQss);
- ui->btnCreate->setEnabled(false);
-}
-
-void ConfForm::paintEvent(QPaintEvent *event)
-{
- QStyleOption opt;
- opt.init(this);
- QPainter p(this);
- style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
- QWidget::paintEvent(event);
-}
-
-void ConfForm::on_isDHCP_clicked()
-{
- ui->isDHCP->setEnabled(false);
- ui->notDHCP->setEnabled(true);
- ui->notDHCP->setChecked(false);
- ui->cbType->setCurrentIndex(0);
- cbTypeChanged(0);
-}
-
-void ConfForm::on_notDHCP_clicked()
-{
- ui->notDHCP->setEnabled(false);
- ui->isDHCP->setEnabled(true);
- ui->isDHCP->setChecked(false);
- ui->cbType->setCurrentIndex(1);
- cbTypeChanged(1);
-}
diff --git a/KylinNM/src/confform.h b/KylinNM/src/confform.h
deleted file mode 100644
index 73999d4..0000000
--- a/KylinNM/src/confform.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2020 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
-#include
-#include
-#include
-#include
-#include
-#include
-
-namespace Ui {
-class ConfForm;
-}
-class KylinNM;
-
-class ConfForm : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit ConfForm(QWidget *parent = 0);
- ~ConfForm();
-
- void setProp(QString connName, QString v4method, QString addr, QString mask, QString gateway, QString dns, bool isActConf );
- void setMainWindow(KylinNM *mainwindow);
-
-public Q_SLOTS:
- void tabletStyle(bool isTablet);//YYF 平板桌面模式特有设置
- void cbTypeChanged(int index);
-
-protected:
- void paintEvent(QPaintEvent *event);
- bool eventFilter(QObject *obj, QEvent *ev) override;
-
-private Q_SLOTS:
- void on_btnOk_clicked();
- void on_btnCancel_clicked();
-
- void on_btnCreate_clicked();
-
- void on_leName_textEdited(const QString &arg1);
-
- void on_leAddr_textEdited(const QString &arg1);
-
- void on_leGateway_textEdited(const QString &arg1);
-
- void on_leDns_textEdited(const QString &arg1);
-
- void on_leDns2_textEdited(const QString &arg1);
-
- void setEnableOfBtn();
- bool getTextEditState(QString text);
- void setBtnEnableFalse();
-
- void on_isDHCP_clicked();
-
- void on_notDHCP_clicked();
-
-private:
- Ui::ConfForm *ui;
-
- void mousePressEvent(QMouseEvent *event);
- void mouseReleaseEvent(QMouseEvent *event);
- void mouseMoveEvent(QMouseEvent *event);
-
- bool isPress;
- QPoint winPos;
- QPoint dragPos;
- bool isActConf; //是否对已经连接的网络进行的更改
- bool isCreateNewNet = false; //是否是创建的新网络
- bool isShowSaveBtn = true; //是否显示保存按钮,即是否是编辑网络界面
-
- bool isTabletStyle=false;//YYF 平板桌面模式特有设置
-
- QString labelQss, cbxQss, leQss, lineQss, btnOnQss, btnOffQss;
-
- KylinNM *mw = nullptr;
-
-Q_SIGNALS:
- void requestRefreshLanList(int updateType);
-};
-
-#endif // CONFFORM_H
diff --git a/KylinNM/src/confform.ui b/KylinNM/src/confform.ui
deleted file mode 100644
index 08ff5b4..0000000
--- a/KylinNM/src/confform.ui
+++ /dev/null
@@ -1,434 +0,0 @@
-
-
- ConfForm
-
-
-
- 0
- 0
- 446
- 576
-
-
-
-
-
-
-
-
- 0
- 0
- 446
- 581
-
-
-
-
-
- 0
- 200
- 446
- 280
-
-
-
-
-
- 175
- 15
- 250
- 32
-
-
-
-
- 10
-
-
-
-
-
-
- 175
- 60
- 250
- 32
-
-
-
-
- 10
-
-
-
-
-
-
- 175
- 105
- 250
- 32
-
-
-
-
- 10
-
-
-
-
-
-
- 175
- 150
- 250
- 32
-
-
-
-
- 10
-
-
-
-
-
-
- 20
- 20
- 80
- 20
-
-
-
-
- Noto Sans CJK SC
- 11
-
-
-
-
-
-
-
-
-
- 20
- 65
- 80
- 20
-
-
-
-
- Noto Sans CJK SC
- 11
-
-
-
-
-
-
-
-
-
- 20
- 110
- 80
- 20
-
-
-
-
- Noto Sans CJK SC
- 11
-
-
-
-
-
-
-
-
-
- 20
- 155
- 80
- 20
-
-
-
-
- Noto Sans CJK SC
- 11
-
-
-
-
-
-
-
-
-
- 175
- 195
- 250
- 32
-
-
-
-
- 10
-
-
-
-
-
-
- 20
- 200
- 80
- 20
-
-
-
-
- Noto Sans CJK SC
- 11
-
-
-
-
-
-
-
-
-
-
- 0
- 0
- 446
- 200
-
-
-
-
-
- 170
- 60
- 182
- 32
-
-
-
-
- 10
-
-
-
-
-
-
- 20
- 135
- 80
- 20
-
-
-
-
- Noto Sans CJK SC
- 11
-
-
-
-
-
-
-
-
-
- 20
- 90
- 80
- 20
-
-
-
-
- Noto Sans CJK SC
- 11
-
-
-
-
-
-
-
-
-
- 135
- 75
- 290
- 48
-
-
-
-
- 10
-
-
-
-
-
-
- 0
- 0
- 446
- 48
-
-
-
-
-
- 408
- 8
- 24
- 24
-
-
-
-
-
-
-
-
-
- 24
- 10
- 240
- 22
-
-
-
-
-
-
-
-
-
-
- 180
- 130
- 111
- 28
-
-
-
-
-
-
-
-
-
- 356
- 130
- 50
- 28
-
-
-
-
-
-
-
-
-
-
- 0
- 480
- 446
- 96
-
-
-
-
-
- 312
- 25
- 112
- 48
-
-
-
-
- 10
-
-
-
-
-
-
-
-
-
- 180
- 25
- 112
- 48
-
-
-
-
- 10
-
-
-
-
-
-
-
-
-
- 312
- 25
- 112
- 48
-
-
-
-
-
-
-
-
-
-
- 10
- 200
- 426
- 1
-
-
-
- Qt::Horizontal
-
-
-
-
-
- 10
- 480
- 426
- 1
-
-
-
- Qt::Horizontal
-
-
-
-
-
-
-
diff --git a/KylinNM/src/ksimplenm.cpp b/KylinNM/src/ksimplenm.cpp
deleted file mode 100644
index d5be6e3..0000000
--- a/KylinNM/src/ksimplenm.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2020 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
-#include
-#include
-
-#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()
-{
- if (isExecutingGetWifiList) {
- syslog(LOG_DEBUG, "It is running getting wifi list when getting lan list");
- qDebug()<<"debug: it is running getting wifi list when getting lan list";
- isUseOldLanSlist = true;
- }
- isExecutingGetLanList = true;
- shellOutput = "";
- type = 0;
- qDebug() << "runShellProcess->start ---1";
- runShellProcess->start("nmcli -f type,device,name connection show");
- qDebug() << "runShellProcess->start ---2";
-}
-
-//获取无线网络列表数据
-void KSimpleNM::execGetWifiList()
-{
- isExecutingGetWifiList = true;
- shellOutput = "";
- type = 1;
- runShellProcess->start("nmcli -f in-use,signal,security,freq,bssid,ssid,dbus-path device wifi");
-}
-
-//读取获取到的结果
-void KSimpleNM::readProcess()
-{
- QString output = runShellProcess->readAll();
- shellOutput += output;
-}
-
-//读取完所有列表数据后发信号,将数据发往mainwindow用于显示网络列表
-void KSimpleNM::finishedProcess(int msg)
-{
- QStringList slist = shellOutput.split("\n");
- if (type == 0) {
- emit getLanListFinished(slist);
- isExecutingGetLanList = false;
- } else {
- emit getWifiListFinished(slist);
- isExecutingGetWifiList = false;
- }
-}
diff --git a/KylinNM/src/ksimplenm.h b/KylinNM/src/ksimplenm.h
deleted file mode 100644
index fd1a427..0000000
--- a/KylinNM/src/ksimplenm.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2020 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
-
-#include
-#include
-#include
-
-class KSimpleNM : public QObject
-{
- Q_OBJECT
-public:
- explicit KSimpleNM(QObject *parent = nullptr);
-
- QProcess *runShellProcess = nullptr;
- QString shellOutput;
- int type;
- bool isExecutingGetLanList = false; //是否正在执行获取有线网列表
- bool isExecutingGetWifiList = false; //是否正在执行获取无线网列表
- bool isUseOldLanSlist = false; //是否应该要用上一次获取的有线列表
-
- void execGetLanList();
- void execGetWifiList();
-
-Q_SIGNALS:
- void getLanListFinished(QStringList slist);
- void getWifiListFinished(QStringList slist);
-
-public Q_SLOTS:
- void readProcess();
- void finishedProcess(int msg);
-};
-
-#endif // KSIMPLENM_H
diff --git a/KylinNM/src/kylin-dbus-interface.cpp b/KylinNM/src/kylin-dbus-interface.cpp
deleted file mode 100644
index ddaba02..0000000
--- a/KylinNM/src/kylin-dbus-interface.cpp
+++ /dev/null
@@ -1,1105 +0,0 @@
-/*
- * Copyright (C) 2020 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
-
-#include
-#include
-
-
-namespace {
-
-void quitThread(QThread *thread)
-{
- Q_ASSERT(thread);
- if (thread) {
- thread->quit();
- if (!thread->wait(2000)) {
- thread->terminate();
- thread->wait();
- }
- }
-}
-
-} // namespace
-
-KylinDBus::KylinDBus(KylinNM *mainWindow, QObject *parent) :QObject(parent)
-{
- this->mw = mainWindow;
-
- getObjectPath(); //获取dbus中 lan 与 WiFi 的device路径
- getPhysicalCarrierState(0); //初始化获取网线插入状态
- getLanHwAddressState(); //获取有线网Mac地址
- getWiredCardName(); //获取有线网卡名称
- //initTaskbarGsetting(); //初始化taskbar的GSetting方法
- getWifiSwitchState(); //初始化wifi开关GSetting通信方法
- initTransparentState(); //初始化窗口透明度的GSetting方法
-
- QDBusConnection::systemBus().connect(QString("org.freedesktop.NetworkManager"),
- QString("/org/freedesktop/NetworkManager"),
- QString("org.freedesktop.NetworkManager"),
- QString("PropertiesChanged"), this, SLOT(onPropertiesChanged(QVariantMap) ) );
-
- QDBusConnection::systemBus().connect(QString("org.freedesktop.NetworkManager"),
- QString("/org/freedesktop/NetworkManager"),
- QString("org.freedesktop.NetworkManager"),
- QString("DeviceAdded"), mw, SLOT(onNetworkDeviceAdded(QDBusObjectPath) ) );
-
- QDBusConnection::systemBus().connect(QString("org.freedesktop.NetworkManager"),
- QString("/org/freedesktop/NetworkManager"),
- QString("org.freedesktop.NetworkManager"),
- QString("DeviceRemoved"), mw, SLOT(onNetworkDeviceRemoved(QDBusObjectPath) ) );
-
- QDBusConnection::systemBus().connect(QString("org.freedesktop.NetworkManager"),
- QString("/org/freedesktop/NetworkManager/Settings"),
- QString("org.freedesktop.NetworkManager.Settings"),
- QString("NewConnection"), this, SLOT(onNewConnection(QDBusObjectPath) ) );
-
- QDBusConnection::systemBus().connect(QString("org.freedesktop.NetworkManager"),
- QString("/org/freedesktop/NetworkManager/Settings"),
- QString("org.freedesktop.NetworkManager.Settings"),
- QString("ConnectionRemoved"), this, SLOT(onConnectionRemoved(QDBusObjectPath) ) );
-
- if (wiredPath.path() != "") {
- QDBusConnection::systemBus().connect(QString("org.freedesktop.NetworkManager"),
- QString(wiredPath.path()),
- QString("org.freedesktop.NetworkManager.Device.Wired"),
- QString("PropertiesChanged"), this, SLOT(onLanPropertyChanged(QVariantMap) ) );
- } else {
- qDebug()<<"Can not find wired device object path when using dbus.";
- }
-
- if (wirelessPath.path() != "") {
- QDBusConnection::systemBus().connect(QString("org.freedesktop.NetworkManager"),
- QString(wirelessPath.path()),
- QString("org.freedesktop.NetworkManager.Device.Wireless"),
- QString("PropertiesChanged"), this, SLOT(onWifiPropertyChanged(QVariantMap) ) );
-
- QDBusConnection::systemBus().connect(QString("org.freedesktop.NetworkManager"),
- QString(wirelessPath.path()),
- QString("org.freedesktop.NetworkManager.Device.Wireless"),
- QString("AccessPointAdded"), this, SLOT(onAccessPointAdded(QDBusObjectPath) ) );
- getWirelessCardName();//获取无线网卡名称
- } else {
- qDebug()<<"Can not find wireless device object path when using dbus.";
- }
-
- time = new QTimer(this);
- time->setTimerType(Qt::PreciseTimer);
- QObject::connect(time, SIGNAL(timeout()), this, SLOT(slot_timeout()));
-
- QObject::connect(this, SIGNAL(updateWiredList(int)), mw, SLOT(onBtnNetListClicked(int)));
-
- mUtils = new Utils();
- mUtilsThread = new QThread(this);
- mUtils->moveToThread(mUtilsThread);
- connect(mUtilsThread, &QThread::finished, mUtils, &Utils::deleteLater);
- connect(this, SIGNAL(requestSendDesktopNotify(QString)), mUtils, SLOT(onRequestSendDesktopNotify(QString)), Qt::QueuedConnection);
- QTimer::singleShot(1, this, [=] {
- mUtilsThread->start();
- });
-}
-
-KylinDBus::~KylinDBus()
-{
- quitThread(mUtilsThread);
-}
-
-
-///////////////////////////////////////////////////////////////////////////////
-//下方使用Dbus 进程通信方法
-
-//获取dbus中 lan 与 WiFi 的device路径
-void KylinDBus::getObjectPath()
-{
- foreach (QDBusObjectPath mPath, multiWiredPaths) {
- multiWiredPaths.removeOne(mPath);
- }
-
- QDBusInterface m_interface( "org.freedesktop.NetworkManager",
- "/org/freedesktop/NetworkManager",
- "org.freedesktop.NetworkManager",
- QDBusConnection::systemBus() );
-
- //先获取所有的网络设备的设备路径
- QDBusReply> obj_reply = m_interface.call("GetAllDevices");
- if (!obj_reply.isValid()) {
- qDebug()<<"execute dbus method 'GetAllDevices' is invalid in func getObjectPath()";
- }
-
- QList obj_paths = obj_reply.value();
-
- //再判断有无有线设备和无线设备的路径
- foreach (QDBusObjectPath obj_path, obj_paths) {
- QDBusInterface interface( "org.freedesktop.NetworkManager",
- obj_path.path(),
- "org.freedesktop.DBus.Introspectable",
- QDBusConnection::systemBus() );
-
- QDBusReply reply = interface.call("Introspect");
- if (!reply.isValid()) {
- qDebug()<<"execute dbus method 'Introspect' is invalid in func getObjectPath()";
- }
-
- if(reply.value().indexOf("org.freedesktop.NetworkManager.Device.Wired") != -1) {
- //表明有有线网设备
- wiredPath = obj_path;
- multiWiredPaths.append(obj_path);
- } else if (reply.value().indexOf("org.freedesktop.NetworkManager.Device.Wireless") != -1) {
- //表明有wifi设备
- wirelessPath = obj_path;
- isWirelessCardOn = true;
- }
- }
-}
-
-//获取是否连接有线网网线
-void KylinDBus::getPhysicalCarrierState(int n)
-{
- multiWiredCableState.clear();
-
- foreach (QDBusObjectPath localPath, multiWiredPaths) {
- QDBusInterface interface( "org.freedesktop.NetworkManager",
- localPath.path(),
- "org.freedesktop.DBus.Properties",
- QDBusConnection::systemBus() );
-
- //Carrier值为true,插了网线;为false,未插网线
- QDBusReply reply = interface.call("Get", "org.freedesktop.NetworkManager.Device.Wired", "Carrier");
-
- try {
- if (reply.value().toString() == "true") {
- //isWiredCableOn = true;
- QDBusReply managed = interface.call("Get", "org.freedesktop.NetworkManager.Device", "Managed");
- //针对intel特殊环境的二次判断,当设备未托管时,即时carrier为true,仍认为有线设备未连接
- if (managed.value().toString() == "true") {
- //isWiredCableOn = true;
- multiWiredCableState.append("true");
- } else {
- multiWiredCableState.append("false");
- }
- } else if (reply.value().toString() == "false") {
- //isWiredCableOn = false;
- multiWiredCableState.append("false");
- //if (n == 1){ this->mw->onPhysicalCarrierChanged(isWiredCableOn);}
- } else {
- throw -1; //出现异常
- }
- } catch(...) {
- syslog(LOG_ERR, "Error occurred when get the property 'Carrier' of Wired");
- qDebug()<<"Error occurred when get the property 'Carrier' of Wired";
- }
- }
-
- isWiredCableOn = false;
- foreach (QString state, multiWiredCableState) {
- if (state == "true") {
- isWiredCableOn = true;
- }
- }
-
- if (n == 1) { this->mw->onPhysicalCarrierChanged(isWiredCableOn);}
-}
-
-//获取有线网Mac地址
-void KylinDBus::getLanHwAddressState()
-{
- QDBusInterface lanInterface( "org.freedesktop.NetworkManager",
- wiredPath.path(),
- "org.freedesktop.DBus.Properties",
- QDBusConnection::systemBus() );
-
- QDBusReply lanReply = lanInterface.call("Get", "org.freedesktop.NetworkManager.Device.Wired", "HwAddress");
- if (!lanReply.isValid()) {
- qDebug()<<"can not get the attribute 'HwAddress' in func getLanHwAddressState()";
- } else {
- dbusLanMac = lanReply.value().toString();
- }
-}
-
-//获取有线网卡名称
-void KylinDBus::getWiredCardName()
-{
- if (wiredPath.path() == "") {
- dbusLanCardName = "";
- } else {
- QDBusInterface lanInterface( "org.freedesktop.NetworkManager",
- wiredPath.path(),
- "org.freedesktop.DBus.Properties",
- QDBusConnection::systemBus() );
-
- QDBusReply lanReply = lanInterface.call("Get", "org.freedesktop.NetworkManager.Device", "Interface");
- if (!lanReply.isValid()) {
- qDebug()<<"can not get the attribute 'Interface' in func getWiredCardName()";
- dbusLanCardName = "";
- } else {
- dbusLanCardName = lanReply.value().toString();
- }
- }
-}
-
-//获取无线网卡名称
-void KylinDBus::getWirelessCardName()
-{
- QDBusInterface lanInterface( "org.freedesktop.NetworkManager",
- wirelessPath.path(),
- "org.freedesktop.DBus.Properties",
- QDBusConnection::systemBus() );
-
- QDBusReply lanReply = lanInterface.call("Get", "org.freedesktop.NetworkManager.Device", "Interface");
- if (!lanReply.isValid()) {
- qDebug()<<"can not get the attribute 'Interface' in func getWirelessCardName()";
- } else {
- dbusWiFiCardName = lanReply.value().toString();
- }
-}
-
-//获取没有连接的有线网ip
-void KylinDBus::getLanIp(QString netName)
-{
- QDBusInterface m_interface("org.freedesktop.NetworkManager",
- "/org/freedesktop/NetworkManager/Settings",
- "org.freedesktop.NetworkManager.Settings",
- QDBusConnection::systemBus() );
- QDBusReply> m_reply = m_interface.call("ListConnections");
-
- QList m_objNets = m_reply.value();
- foreach (QDBusObjectPath objNet, m_objNets) {
- QDBusInterface m_interface("org.freedesktop.NetworkManager",
- objNet.path(),
- "org.freedesktop.NetworkManager.Settings.Connection",
- QDBusConnection::systemBus());
- QDBusMessage result = m_interface.call("GetSettings"); //get information of this network
-
- const QDBusArgument &dbusArg1st = result.arguments().at( 0 ).value();
- //DBus type : a{sa{sv}}, a map with a key of QString, which maps to another map of QString,QVariant
- QMap> map;
- dbusArg1st >> map;
-
- for (QString outside_key : map.keys() ) {
- QMap outsideMap = map.value(outside_key);
- if (outside_key == "connection") {
- for (QString search_key : outsideMap.keys()) {
- if (search_key == "id") {
- //const QDBusArgument &dbusArg2nd = innerMap.value(inner_key).value();
- if (netName == outsideMap.value(search_key).toString()) {
- // qDebug()<<"aaaaaa"< innerMap = map.value(key);
- //qDebug() << "Key: " << key;
- if (key == "ipv4") {
- for (QString inner_key : innerMap.keys()) {
- if (inner_key == "address-data") {
- const QDBusArgument &dbusArg2nd = innerMap.value(inner_key).value();
- QMap m_map;
-
- dbusArg2nd.beginArray();
- while (!dbusArg2nd.atEnd()) {
- dbusArg2nd >> m_map;// append map to a vector here if you want to keep it
- }
- dbusArg2nd.endArray();
-
- //qDebug()<<" " << m_map.value("address").toString();
- dbusLanIpv4 = m_map.value("address").toString();
- }
- }
- }
-
- if (key == "ipv6") {
- for (QString inner_key : innerMap.keys()) {
- if (inner_key == "address-data"){
- const QDBusArgument &dbusArg2nd = innerMap.value(inner_key).value();
- QMap m_map;
-
- dbusArg2nd.beginArray();
- while (!dbusArg2nd.atEnd()) {
- dbusArg2nd >> m_map;// append map to a vector here if you want to keep it
- }
- dbusArg2nd.endArray();
-
- //qDebug()<<" " << m_map.value("address").toString();
- dbusLanIpv6 = m_map.value("address").toString();
- }
- }
- }
- } //end for(QString key : map.keys() )
-
- }
- }
- } //end for (QString search_key : outsideMap.keys())
- }
- } // end for(QString outside_key : map.keys() )
-
- } //end foreach (QDBusObjectPath objNet, m_objNets)
-}
-
-//获取已经连接的有线网ip
-void KylinDBus::getConnectNetIp()
-{
- QDBusInterface interface( "org.freedesktop.NetworkManager",
- "/org/freedesktop/NetworkManager",
- "org.freedesktop.DBus.Properties",
- QDBusConnection::systemBus() );
-
- //获取已经连接了那些网络,及这些网络对应的网络类型(ethernet or wifi)
- QDBusMessage result = interface.call("Get", "org.freedesktop.NetworkManager", "ActiveConnections");
- QList outArgs = result.arguments();
- QVariant first = outArgs.at(0);
- QDBusVariant dbvFirst = first.value();
- QVariant vFirst = dbvFirst.variant();
- QDBusArgument dbusArgs = vFirst.value();
-
- QDBusObjectPath objPath;
- dbusArgs.beginArray();
- while (!dbusArgs.atEnd()) {
- dbusArgs >> objPath;
-
- QDBusInterface interfacePro( "org.freedesktop.NetworkManager",
- objPath.path(),
- "org.freedesktop.DBus.Properties",
- QDBusConnection::systemBus() );
-
- QDBusReply reply = interfacePro.call("Get", "org.freedesktop.NetworkManager.Connection.Active", "Type");
- if (reply.value().toString() == "ethernet" || reply.value().toString() == "802-3-ethernet") {
- //ipv4的路径信息和ip信息
- QDBusInterface interfaceIp4( "org.freedesktop.NetworkManager",
- objPath.path(),
- "org.freedesktop.DBus.Properties",
- QDBusConnection::systemBus() );
- QDBusMessage replyIp4 = interfaceIp4.call("Get", "org.freedesktop.NetworkManager.Connection.Active", "Ip4Config");
- QList outArgsIp4 = replyIp4.arguments();
- QVariant firstIp4 = outArgsIp4.at(0);
- QDBusVariant dbvFirstIp4 = firstIp4.value();
- QVariant vFirstIp4 = dbvFirstIp4.variant();
- QDBusObjectPath dbusPathIp4 = vFirstIp4.value();
-
- QDBusInterface interfaceIpv4( "org.freedesktop.NetworkManager",
- dbusPathIp4.path(),
- "org.freedesktop.DBus.Properties",
- QDBusConnection::systemBus() );
- QDBusMessage replyIpv4 = interfaceIpv4.call("Get", "org.freedesktop.NetworkManager.IP4Config", "AddressData");
-
- QList outArgsIpv4 = replyIpv4.arguments();
- if(outArgsIp4.count() >= 0){
- QVariant firstIpv4 = outArgsIpv4.at(0);
- QDBusVariant dbvFirstIpv4 = firstIpv4.value();
- QVariant vFirstIpv4 = dbvFirstIpv4.variant();
-
- const QDBusArgument &dbusArgIpv4 = vFirstIpv4.value();
- QList mDatasIpv4;
- dbusArgIpv4 >> mDatasIpv4;
-
- foreach (QVariantMap mDataIpv4, mDatasIpv4) {
- dbusActiveLanIpv4 = mDataIpv4.value("address").toString();
- }
- }
- //ipv6的路径信息和ip信息
- QDBusInterface interfaceIp6( "org.freedesktop.NetworkManager",
- objPath.path(),
- "org.freedesktop.DBus.Properties",
- QDBusConnection::systemBus() );
- QDBusMessage replyIp6 = interfaceIp6.call("Get", "org.freedesktop.NetworkManager.Connection.Active", "Ip6Config");
- QList outArgsIp6 = replyIp6.arguments();
- QVariant firstIp6 = outArgsIp6.at(0);
- QDBusVariant dbvFirstIp6 = firstIp6.value();
- QVariant vFirstIp6 = dbvFirstIp6.variant();
- QDBusObjectPath dbusPathIp6 = vFirstIp6.value();
-
- QDBusInterface interfaceIpv6( "org.freedesktop.NetworkManager",
- dbusPathIp6.path(),
- "org.freedesktop.DBus.Properties",
- QDBusConnection::systemBus() );
- QDBusMessage replyIpv6 = interfaceIpv6.call("Get", "org.freedesktop.NetworkManager.IP6Config", "AddressData");
-
- QList outArgsIpv6 = replyIpv6.arguments();
- if(outArgsIp6.count() >= 0){
- QVariant firstIpv6 = outArgsIpv6.at(0);
- QDBusVariant dbvFirstIpv6 = firstIpv6.value();
- QVariant vFirstIpv6 = dbvFirstIpv6.variant();
-
- const QDBusArgument &dbusArgIpv6 = vFirstIpv6.value();
- QList mDatasIpv6;
- dbusArgIpv6 >> mDatasIpv6;
-
- foreach (QVariantMap mDataIpv6, mDatasIpv6) {
- dbusActiveLanIpv6 = mDataIpv6.value("address").toString();
- }
- }
- }
- }
- dbusArgs.endArray();
-}
-
-//获取wifi的mac地址
-void KylinDBus::getWifiMac(QString netName)
-{
- dbusWifiMac = "";
-
- QDBusInterface interface( "org.freedesktop.NetworkManager",
- wirelessPath.path(),
- "org.freedesktop.NetworkManager.Device.Wireless",
- QDBusConnection::systemBus() );
-
- QDBusReply> reply = interface.call("GetAllAccessPoints"); //get accesspoint for each wifi
- QList objPaths = reply.value();
-
- foreach (QDBusObjectPath objPath, objPaths) {
- QDBusInterface ssid_interface( "org.freedesktop.NetworkManager",
- objPath.path(),
- "org.freedesktop.DBus.Properties",
- QDBusConnection::systemBus() );
-
- QDBusReply ssid_replys = ssid_interface.call("Get", "org.freedesktop.NetworkManager.AccessPoint", "Ssid");
- QString str_name = ssid_replys.value().toString();
-
- if (str_name == netName) {
- //if the ssid of the accesspoint is just the netName, we can get this hardware address
- QDBusInterface path_interface( "org.freedesktop.NetworkManager",
- objPath.path(),
- "org.freedesktop.DBus.Properties",
- QDBusConnection::systemBus() );
-
- QDBusReply path_reply = path_interface.call("Get", "org.freedesktop.NetworkManager.AccessPoint", "HwAddress");
- dbusWifiMac = path_reply.value().toString();
- }
- }
-}
-
-//获取当前能获取到的wifi的数量, 每个accesspoint 代表一个wifi
-int KylinDBus::getAccessPointsNumber()
-{
- QDBusInterface interface( "org.freedesktop.NetworkManager",
- wirelessPath.path(),
- "org.freedesktop.NetworkManager.Device.Wireless",
- QDBusConnection::systemBus() );
-
- QDBusReply> reply = interface.call("GetAllAccessPoints");
- QList objPaths = reply.value();
-
- return objPaths.size();
-}
-
-//新增了一个网络,伴随着多了一个网络配置文件
-void KylinDBus::onNewConnection(QDBusObjectPath objPath)
-{
- QDBusInterface m_interface("org.freedesktop.NetworkManager",
- objPath.path(),
- "org.freedesktop.NetworkManager.Settings.Connection",
- QDBusConnection::systemBus());
- QDBusMessage result = m_interface.call("GetSettings");
-
- const QDBusArgument &dbusArg1st = result.arguments().at( 0 ).value();
- QMap> map;
- dbusArg1st >> map;
-
- for(QString key : map.keys() ) {
- if (key == "802-3-ethernet") {
- emit this->updateWiredList(0); //send this signal to update wired network list
- syslog(LOG_DEBUG, "A new wired network was created.");
- qDebug()<<"A new wired network was created.";
- }
- }
-}
-
-//减少了一个网络,伴随着减少了一个网络配置文件
-void KylinDBus::onConnectionRemoved(QDBusObjectPath objPath)
-{
- syslog(LOG_DEBUG, "An old network was removed from configure directory.");
- qDebug()<<"An old network was removed from configure directory.";
-
- if (mw->is_btnNetList_clicked == 1) {
- emit this->updateWiredList(0); //send this signal to update wired network list
- }
-}
-
-//应用启动时,获取已经连接的网络信息,包括该网络的路径和类型
-void KylinDBus::initConnectionInfo()
-{
- QDBusInterface interface( "org.freedesktop.NetworkManager",
- "/org/freedesktop/NetworkManager",
- "org.freedesktop.DBus.Properties",
- QDBusConnection::systemBus() );
-
- //获取已经连接了那些网络,及这些网络对应的网络类型(ethernet or wifi)
- QDBusMessage result = interface.call("Get", "org.freedesktop.NetworkManager", "ActiveConnections");
- QList outArgs = result.arguments();
- QVariant first = outArgs.at(0);
- QDBusVariant dbvFirst = first.value();
- QVariant vFirst = dbvFirst.variant();
- QDBusArgument dbusArgs = vFirst.value();
-
- QDBusObjectPath objPath;
- // qDebug()<<" ";
- dbusArgs.beginArray();
- while (!dbusArgs.atEnd()) {
- dbusArgs >> objPath;
- oldPaths.append(objPath);
- // qDebug() <<"debug: *****path is: "<< objPath.path();
-
- QDBusInterface interface( "org.freedesktop.NetworkManager",
- objPath.path(),
- "org.freedesktop.DBus.Properties",
- QDBusConnection::systemBus() );
-
- QDBusReply reply = interface.call("Get", "org.freedesktop.NetworkManager.Connection.Active", "Type");
- // qDebug()<<"debug: *****connection type is: "< m_result = interface.call("Get", "org.freedesktop.NetworkManager", "WirelessEnabled");
- qDebug()<<"debug: *****初始的无线网络开关状态是: "<();
- QList newPaths;
- dbusArg >> newPaths;
- QStringList newPathInfo;
- qDebug()<<" ";
- foreach (QDBusObjectPath objPath, newPaths) {
- qDebug()<<"dbug: bbbbb "< reply = interface.call("Get", "org.freedesktop.NetworkManager.Connection.Active", "Type");
- qDebug()<<"dbug: ccccc "<onExternalConnectionChange(oldPathInfo.at(i));
- } else {
- for (int j=0; jonExternalConnectionChange(oldPathInfo.at(i));
- }
- }
- }
- }
- }
-
- // 第三步 同上一次获取的已连接网络相比较,处理相比于上次增加的网络连接
- for (int i=0; ionExternalConnectionChange(newPathInfo.at(i));
- } else {
- for (int j=0; jonExternalConnectionChange(newPathInfo.at(i));
- }
- }
- }
- }
-
- bool isChangeOldPathInfo = true;
- for (int k=0; konExternalWifiSwitchChange(true);
- setBtnWifiGsetting(true);
- }
- if (oldWifiSwitchState == true && newWifiSwitchState == false) {
- qDebug()<<"debug: wifi开关已经关闭";
- is_wificonnected = false;
- mw->onExternalWifiSwitchChange(false);
- setBtnWifiGsetting(false);
- }
-
- oldWifiSwitchState = newWifiSwitchState; //更新状态用于下一次
- }
- }
-}
-
-//有线网属性变化时,执行该函数。由于可能在短时间收到几条相同属性变化信息,所以在短时间内,执行一次
-void KylinDBus::onLanPropertyChanged(QVariantMap qvm)
-{
- if (!isRunningFunction) {
- syslog(LOG_DEBUG, "kylin-nm receive a signal 'Device.Wired PropertiesChanged' about interface.");
- qDebug()<<"kylin-nm receive a signal 'Device.Wired PropertiesChanged' about interface.";
- isRunningFunction = true; //function onLanPropertyChanged is running
- time->start(3000);
-
- QString str = qvm.value("Carrier").toString();
- if (str == "false" || str == "true") {
- getPhysicalCarrierState(1);
- }
- } else { a = 0; }
-}
-void KylinDBus::slot_timeout()
-{
- isRunningFunction = false;
- time->stop();
-}
-
-//无线网属性变化时,执行该函数
-void KylinDBus::onWifiPropertyChanged(QVariantMap qvm)
-{
- //qDebug()<<"debug: *************"<> m_reply = m_interface.call("ListConnections");
-
- QDBusObjectPath active_connection;
- active_connection.setPath("/");
-
- QList m_objNets = m_reply.value();
- foreach (QDBusObjectPath objNet, m_objNets) {
- QDBusInterface m_interface("org.freedesktop.NetworkManager",
- objNet.path(),
- "org.freedesktop.NetworkManager.Settings.Connection",
- QDBusConnection::systemBus());
- QDBusMessage result = m_interface.call("GetSettings");
-
- const QDBusArgument &dbusArg1st = result.arguments().at( 0 ).value();
- QMap> map;
- dbusArg1st >> map;
-
- for (QString outside_key : map.keys() ) {
- QMap outsideMap = map.value(outside_key);
- if (outside_key == "connection") {
- for (QString search_key : outsideMap.keys()) {
- if (search_key == "id") {
- if (netName == outsideMap.value(search_key).toString()) {
-
- QDBusInterface m_interface("org.freedesktop.NetworkManager",
- "/org/freedesktop/NetworkManager",
- "org.freedesktop.NetworkManager",
- QDBusConnection::systemBus() );
- QDBusReply connectionReply = m_interface.call("ActivateConnection",
- QVariant::fromValue(objNet),
- QVariant::fromValue(wiredPath),
- QVariant::fromValue(active_connection));
- }
- }
- }
- }
- } // end for(QString outside_key : map.keys() )
-
- } //end foreach (QDBusObjectPath objNet, m_objNets)
-}
-
-//显示桌面通知
-void KylinDBus::showDesktopNotify(QString message)
-{
- //锁屏不发送该通知
-// emit requestSendDesktopNotify(message);
-}
-
-//获取任务栏位置,上下左右
-int KylinDBus::getTaskBarPos(QString str)
-{
- QDBusInterface interface( "com.ukui.panel.desktop",
- "/",
- "com.ukui.panel.desktop",
- QDBusConnection::sessionBus() );
-
- QDBusReply reply = interface.call("GetPanelPosition", str);
- if (reply.isValid()) {
- return reply;
- } else {
- return 0; //如果没有成功获取,返回一个默认值
- }
-}
-
-//获取任务栏高度
-int KylinDBus::getTaskBarHeight(QString str)
-{
- QDBusInterface interface( "com.ukui.panel.desktop",
- "/",
- "com.ukui.panel.desktop",
- QDBusConnection::sessionBus() );
-
- QDBusReply reply = interface.call("GetPanelSize", str);
- if (reply.isValid()) {
- return reply;
- } else {
- return 46; //如果没有成功获取,返回一个默认值
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-//下方使用Gsetting 进程通信方法
-
-//创建获取任务栏信息的GSetting对象
-void KylinDBus::initTaskbarGsetting()
-{
- if (QGSettings::isSchemaInstalled("org.ukui.panel.settings")) {
- m_tastbar_gsettings = new QGSettings("org.ukui.panel.settings");
- }
- if (QGSettings::isSchemaInstalled("org.kylinnm.settings")) {
- m_nm_gsettings = new QGSettings("org.kylinnm.settings");
- if (m_nm_gsettings->keys().contains("wifiswitch")) {
- m_nm_gsettings->set("wifiswitch",oldWifiSwitchState);
- }
- }
-}
-
-//使用GSetting方法获取任务栏高度
-int KylinDBus::getTaskbarHeight()
-{
- if (!m_tastbar_gsettings) {
- return 46;
- }
-
- QStringList keys = m_tastbar_gsettings->keys();
- if (keys.contains("panelsize")) {
- int hh = m_tastbar_gsettings->get("panelsize").toInt();
- return hh;
- } else {
- return 46;
- }
-}
-
-//使用GSetting方法写入WIFW信号强度
-void KylinDBus::setWifiSignal(int wifiSignal, QString wifiname)
-{ if(!m_tastbar_gsettings || !m_nm_gsettings)
- return;
-
- if (m_tastbar_gsettings->keys().contains("wifisignal")) {
- m_tastbar_gsettings->set("wifisignal",wifiSignal);
- }
- if (m_nm_gsettings->keys().contains("wifisignal")) {
- m_nm_gsettings->set("wifisignal",wifiSignal);
- }
- if (m_nm_gsettings->keys().contains("wifiname")) {
- m_nm_gsettings->set("wifiname",wifiname);
- }
-}
-//使用GSetting方法获取任务栏位置,上下左右
-int KylinDBus::getTaskbarPos()
-{
- if (!m_tastbar_gsettings) {
- return 0;
- }
-
- QStringList keys = m_tastbar_gsettings->keys();
- if (keys.contains("panelposition")) {
- int pp = m_tastbar_gsettings->get("panelposition").toInt();
- return pp;
- } else {
- return 0;
- }
-}
-
-//创建监听wifi打开或关闭信息的GSetting对象
-void KylinDBus::getWifiSwitchState()
-{
- if (QGSettings::isSchemaInstalled("org.ukui.control-center.wifi.switch")) {
-
- m_gsettings = new QGSettings("org.ukui.control-center.wifi.switch");
-
- // 监听key的value是否发生了变化
- connect(m_gsettings, &QGSettings::changed, this, [=] (const QString &key) {
-
- if (key == "switch") {
- if (isWirelessCardOn) {
- bool judge = getSwitchStatus(key);
- if (judge) {
- mw->onBtnWifiClicked(2); //打开wifi开关
- qDebug()<<"receive a signal to turn on wifi switch from control-center";
- syslog(LOG_DEBUG, "receive a signal to turn on wifi switch from control-center");
- } else {
- if (!is_wificonnected) {
- return;
- }
- mw->onBtnWifiClicked(3); //关闭wifi开关
- qDebug()<<"receive a signal to turn off wifi switch from control-center";
- syslog(LOG_DEBUG, "receive a signal to turn off wifi switch from control-center");
- }
- }
- }
- });
- }
-}
-
-//收到控制面板发来的消息后,获取wifi开关信息
-bool KylinDBus::getSwitchStatus(QString key) {
- if (!m_gsettings) {
- return true;
- }
- const QStringList list = m_gsettings->keys();
- if (!list.contains(key)) {
- return true;
- }
- bool res = m_gsettings->get(key).toBool();
- return res;
-}
-
-//通知控制面板wifi开关的信息
-void KylinDBus::setWifiSwitchState(bool signal)
-{
- if (!m_gsettings) {
- return ;
- }
-
- const QStringList list = m_gsettings->keys();
-
- if (!list.contains("switchor")) {
- return ;
- }
- m_gsettings->set("switchor",signal);
-
- if (!m_nm_gsettings) {
- return ;
- }
- if (m_nm_gsettings->keys().contains("wifiswitch")) {
- m_nm_gsettings->set("wifiswitch",signal);
- }
-}
-
-void KylinDBus::setWifiConnStatus(bool is_wifi_connected)
-{
-// qDebug()<<"WIFI连接状态:"<keys().contains("wificonn")) {
- m_nm_gsettings->set("wificonn",is_wifi_connected);
- }
-}
-
-void KylinDBus::setLanConnStatus(bool is_lan_connected)
-{
-// qDebug()<<"LAN连接状态:"<keys().contains("lanconn")) {
- m_nm_gsettings->set("lanconn",is_lan_connected);
- }
-}
-
-//通知控制面板无线网卡的状态信息
-void KylinDBus::setWifiCardState(bool signal)
-{
- if (!m_gsettings) {
- return ;
- }
-
- const QStringList list = m_gsettings->keys();
-
- if (!list.contains("wificard")) {
- return ;
- }
- m_gsettings->set("wificard",signal);
-}
-
-//创建获取窗口透明度信息的GSetting的对象
-void KylinDBus::initTransparentState()
-{
- if (QGSettings::isSchemaInstalled("org.ukui.control-center.personalise")) {
- m_transparency_gsettings = new QGSettings("org.ukui.control-center.personalise");
- }
-}
-
-//创建WIFI开关状态的GSetting的对象
-void KylinDBus::initBtnWifiGsetting()
-{
- if (QGSettings::isSchemaInstalled("org.ukui.control-center.wifi.switch")) {
- m_btnWifi_gsettings = new QGSettings("org.ukui.control-center.wifi.switch");
- }
-}
-void KylinDBus::setBtnWifiGsetting(bool bl)
-{
- if(m_btnWifi_gsettings->get("switch").toBool()!=bl)
- {
- m_btnWifi_gsettings->set("switch",bl);
- }
-}
-
-//根据Dbus路径获取wifi的ssid(排除空格干扰)
-QString KylinDBus::getWifiSsid(QString accessPointPath)
-{
- QDBusInterface interface( "org.freedesktop.NetworkManager",
- accessPointPath,
- "org.freedesktop.DBus.Properties",
- QDBusConnection::systemBus() );
- QDBusMessage result = interface.call("Get", "org.freedesktop.NetworkManager.AccessPoint", "Ssid");
- if (result.arguments().isEmpty()) return "";
- return result.arguments().at(0).value().variant().toString();
-}
-
-//获取已经连接无线网络的ssid和uuid
-QList KylinDBus::getAtiveWifiBSsidUuid(QStringList wifilist)
-{
- QList strBSsidUuid;
-
- QDBusInterface interface( "org.freedesktop.NetworkManager",
- "/org/freedesktop/NetworkManager",
- "org.freedesktop.DBus.Properties",
- QDBusConnection::systemBus() );
- //获取已经连接了那些网络,及这些网络对应的网络类型(ethernet or wifi)
- QDBusMessage result = interface.call("Get", "org.freedesktop.NetworkManager", "ActiveConnections");
- QList outArgs = result.arguments();
- QVariant first = outArgs.at(0);
- QDBusVariant dbvFirst = first.value();
- QVariant vFirst = dbvFirst.variant();
- QDBusArgument dbusArgs = vFirst.value();
-
- QDBusObjectPath objPath;
- dbusArgs.beginArray();
- while (!dbusArgs.atEnd()) {
- dbusArgs >> objPath;
-
- QDBusInterface interfaceType( "org.freedesktop.NetworkManager",
- objPath.path(),
- "org.freedesktop.DBus.Properties",
- QDBusConnection::systemBus() );
- QDBusReply reply = interfaceType.call("Get", "org.freedesktop.NetworkManager.Connection.Active", "Type");
-
- if (reply.value().toString() == "wifi" || reply.value().toString() == "802-11-wireless") {
- QDBusInterface interfaceInfo( "org.freedesktop.NetworkManager",
- objPath.path(),
- "org.freedesktop.DBus.Properties",
- QDBusConnection::systemBus() );
-
- //获取已经连接wifi的uuid
- QDBusReply replyUuid = interfaceInfo.call("Get", "org.freedesktop.NetworkManager.Connection.Active", "Uuid");
- //qDebug() << "wifi uuid : "<< replyUuid.value().toString();
- strBSsidUuid.append(replyUuid.value().toString());
-
-
- //再获取bssid
- QDBusMessage resultConnection = interfaceInfo.call("Get", "org.freedesktop.NetworkManager.Connection.Active", "Connection");
-
- QList outArgsConnection = resultConnection.arguments();
- QVariant firstConnection = outArgsConnection.at(0);
- QDBusVariant dbvFirstConnection = firstConnection.value();
- QVariant vFirstConnection = dbvFirstConnection.variant();
- QDBusObjectPath dbusArgsConnection = vFirstConnection.value();
-
- QDBusInterface interfaceSet("org.freedesktop.NetworkManager",
- dbusArgsConnection.path(),
- "org.freedesktop.NetworkManager.Settings.Connection",
- QDBusConnection::systemBus());
- QDBusMessage resultSet = interfaceSet.call("GetSettings");
-
- const QDBusArgument &dbusArg1stSet = resultSet.arguments().at( 0 ).value();
- QMap> mapSet;
- dbusArg1stSet >> mapSet;
-
- for (QString setKey : mapSet.keys() ) {
- QMap subSetMap = mapSet.value(setKey);
- if (setKey == "802-11-wireless") {
- for (QString searchKey : subSetMap.keys()) {
- if (searchKey == "seen-bssids") {
- //qDebug() << "wifi bssid : "<keys();
- if (keys.contains("transparency")) {
- double tp = m_transparency_gsettings->get("transparency").toDouble();
- return tp;
- } else {
- return 0.7;
- }
-}
diff --git a/KylinNM/src/kylin-dbus-interface.h b/KylinNM/src/kylin-dbus-interface.h
deleted file mode 100644
index b62c4c5..0000000
--- a/KylinNM/src/kylin-dbus-interface.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (C) 2020 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
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-class KylinNM;
-class Utils;
-
-class KylinDBus : public QObject
-{
- Q_OBJECT
-public:
- explicit KylinDBus(KylinNM *mw = 0, QObject *parent = nullptr);
- ~KylinDBus();
-
- void getObjectPath();
- int getAccessPointsNumber();
- void showDesktopNotify(QString message);
- void initConnectionInfo();
- void connectWiredNet(QString netName);
- void getConnectNetIp();
-
- int getTaskBarPos(QString str);
- int getTaskBarHeight(QString str);
- void initTaskbarGsetting();
- int getTaskbarHeight();
- int getTaskbarPos();
-
- void getWifiSwitchState();
- bool getSwitchStatus(QString key);
- void setWifiSwitchState(bool signal);
- void setWifiCardState(bool signal);
-
- void initTransparentState();
- double getTransparentData();
-
- void initBtnWifiGsetting();
- void setBtnWifiGsetting(bool bl);
- QString getWifiSsid(QString accessPointPath);
- QList getAtiveWifiBSsidUuid(QStringList wifilist);
-
- QDBusObjectPath wiredPath; //有线设备的路径
- QDBusObjectPath wirelessPath; //无线设备的路径
- QList multiWiredPaths; //已连接网络的对象路径列表
-
- QList multiWiredCableState;
- bool isWiredCableOn = false; //是否插入了网线
- bool isWirelessCardOn = false; //是否插入了无线网卡
-
- QString dbusLanCardName = "";
- QString dbusLanIpv4 = "";
- QString dbusLanIpv6 = "";
- QString dbusActiveLanIpv4 = "";
- QString dbusActiveLanIpv6 = "";
- QString dbusLanGateway = "";
- QString dbusLanMac = "";
- QString dbusWiFiCardName = "";
- QString dbusWifiMac = "";
-
-public Q_SLOTS:
- void onNewConnection(QDBusObjectPath objPath);
- void onConnectionRemoved(QDBusObjectPath objPath);
- void onPropertiesChanged(QVariantMap qvm);
- void onLanPropertyChanged(QVariantMap qvm);
- void onWifiPropertyChanged(QVariantMap qvm);
- void onAccessPointAdded(QDBusObjectPath objPath);
- void getPhysicalCarrierState(int n);
- void getLanHwAddressState();
- void getWiredCardName();
- void getWirelessCardName();
- void getLanIp(QString netName);
- void getWifiMac(QString netName);
- void slot_timeout();
- void setWifiSignal(int wifiSignal, QString wifiname);
- void setWifiConnStatus(bool is_wifi_connected);
- void setLanConnStatus(bool is_lan_connected);
-
-private:
- KylinNM *mw;
- Utils *mUtils;
- QThread *mUtilsThread;
-
- int a = 0;
- bool isRunningFunction = false;
- QTimer *time = nullptr;
- QList oldPaths; //已连接网络的对象路径列表
- QStringList oldPathInfo; //某个已连接网络对象路径对应的网络类型(ethernet or wifi)
- bool oldWifiSwitchState; //上一次获取到的wifi开关状态
-
- QGSettings *m_tastbar_gsettings = nullptr;
- QGSettings *m_nm_gsettings = nullptr;
- QGSettings *m_gsettings = nullptr;
- QGSettings *m_transparency_gsettings = nullptr;
- QGSettings *m_btnWifi_gsettings = nullptr;
-
- bool is_wificonnected = false;
-
-Q_SIGNALS:
- void updateWiredList(int n);
- void requestSendDesktopNotify(QString message);
-};
-
-#endif // KYLINDBUSINTERFACE_H
diff --git a/KylinNM/src/kylin-network-interface.c b/KylinNM/src/kylin-network-interface.c
deleted file mode 100644
index 5f69bd0..0000000
--- a/KylinNM/src/kylin-network-interface.c
+++ /dev/null
@@ -1,998 +0,0 @@
-/*
- * Copyright (C) 2020 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
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-
-//获取网络接口名
-ifname *kylin_network_get_ifacename()
-{
- int i = 0;
- int sockfd;
- struct ifconf ifconf;
- struct ifreq *ifreq;
- unsigned char buf[1024];
-
- //初始化ifconf
- ifconf.ifc_len = 1024;
- //字符串指针ifconf.ifc_buf指向buf
- ifconf.ifc_buf = buf;
-
- if((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
- {
- perror("socket error");
- return 0;
- }
-
- //获取所有接口信息
- ioctl(sockfd, SIOCGIFCONF, &ifconf);
- // printf("%s\n",ifconf.ifc_buf);
-
- //逐个获取Ip地址
- //结构体指针ifreq指向buf,即ifconf.ifc_buf
- ifreq = (struct ifreq*)buf;
- int number=ifconf.ifc_len/sizeof(struct ifreq);
- // printf("%d\n",number);
-
- ifname *ifn=(ifname *)malloc(sizeof(ifname)*(number+1));
-
- for(i = number; i>0; i--)
- {
- // printf("name = [%s] \n",ifreq->ifr_name);
-
- int j=number-i;
- ifn[j].if_name=(char *)malloc(sizeof(char)*10);
- strcpy(ifn[j].if_name,ifreq->ifr_name);
- // ifn[j].if_name=ifreq->ifr_name;
- // printf("if_name[%d]:%s\n",j,if_name[j]);
-
- ifreq++;
- }
- ifn[number].if_name=NULL;
-
-
- return ifn;
-}
-
-//获取所有网络连接
-conlist *kylin_network_get_conlist_info()
-{
- int status = system("nmcli connection show > /tmp/conlist.txt");
- if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection show' in function 'kylin_network_get_conlist_info' failed");}
- char *filename="/tmp/conlist.txt";
-
- FILE *confp;
- int connum=0;
- char ConStrLine[1024];
- if((confp=fopen(filename,"r"))==NULL)
- {
- printf("error!");
-
- }
- fgets(ConStrLine,1024,confp);
- while(!feof(confp))
- {
- fgets(ConStrLine,1024,confp);
- connum++;
- }
- // printf("%d\n",connum);
- fclose(confp);
- conlist *clist=(conlist *)malloc(sizeof(conlist)*connum);
-
- int count=0;
- FILE *fp;
- char StrLine[1024];
- if((fp=fopen(filename,"r"))==NULL)
- {
- printf("error!");
-
- }
- fgets(StrLine,1024,fp);
- while(!feof(fp))
- {
- if(count==connum-1)break;
-
- fgets(StrLine,1024,fp);
-
- char *index=StrLine;
- char conname[100];
-
- //截取连接名称
- int num=0;
- for(index;*index!='\n';index++)
- {
- if(*index==' ')
- {
- if(*(index+1)==' ')
- break;
- }
- num++;
- }
-
- // printf("连接名称长度:%d\n",num);
- clist[count].con_name=(char *)malloc(sizeof(char)*(num+1));
- strncpy(conname,StrLine,num+1);
- conname[num]='\0';
- strncpy(clist[count].con_name,conname,num+1);
- // printf("%s\n",clist[count].con_name);
-
- //截取连接类型
- char type[100];
- for(index;*index!='\n';index++)
- {
- if(*index==' ')
- {
- if(*(index+1)=' ')
- if(*(index+2)!=' ')
- break;
-
- }
- }
- char *index1=index+2;
- for(index1;*index1!='\n';index1++)
- {
- if(*index1==' ')
- {
- if(*(index1+1)==' ')
- break;
- }
- }
- int num1=0;
- char *index2=index1+2;
- for(index2;*index2!='\n';index2++)
- {
- if(*index2==' ')break;
- num1++;
- }
- clist[count].type=(char *)malloc(sizeof(char)*(num1+1));
- strncpy(type,index1+2,num1+1);
- type[num1]='\0';
- strncpy(clist[count].type,type,num1+1);
- // printf("%s\n",clist[count].type);
- count++;
- }
- fclose(fp);
-
- clist[count].con_name=NULL;
- clist[count].type=NULL;
-
- return clist;
-}
-
-//获取当前活动网络连接
-int kylin_network_get_activecon_info(activecon** activelist, int* count)
-{
- if (*activelist != NULL || !count) {
- return -1;
- }
- struct passwd *pwd;
- pwd = getpwuid(getuid());
- char *name = pwd->pw_name;
- char *tmpPrefix = "/tmp/kylin-nm-activecon-";
- char *chr = "nmcli connection show -active > ";
-
- char *cmd;
- asprintf(&cmd, "%s%s%s", chr, tmpPrefix, name);
- char *path;
- asprintf(&path, "%s%s", tmpPrefix, name);
- int status = system(cmd);
- //int status = system("nmcli connection show -active > /tmp/activecon.txt");
- if (status != 0)
- syslog(LOG_ERR, "execute 'nmcli connection show -active' in function 'kylin_network_get_activecon_info' failed");
- free(cmd);
-
- char *filename = path;
-
- FILE *activefp;
- int activenum=0;
- char activeStrLine[1024];
- if((activefp=fopen(filename,"r"))==NULL)
- {
- printf("error!");
- return -1;
- }
- fgets(activeStrLine,1024,activefp);
- while(!feof(activefp))
- {
- fgets(activeStrLine,1024,activefp);
- activenum++;
- }
- // printf("%d\n",activenum);
- fclose(activefp);
- *activelist=(activecon *)malloc(sizeof(activecon)*activenum);
-
- *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;
-
- fgets(StrLine,1024,fp);
-
- char *index=StrLine;
- char conname[100];
-
- //截取连接名称
- int num=0;
- for(index;*index!='\n';index++)
- {
- if(*index==' ')
- {
- if(*(index+1)==' ')
- break;
- }
- num++;
- }
-
- // printf("连接名称长度:%d\n",num);
- strncpy(conname,StrLine,num+1);
- conname[num]='\0';
- strncpy((*activelist)[*count].con_name,conname,num+1);
- // printf("%s\n",activelist[count].con_name);
-
- //截取连接类型
- char type[100];
- for(index;*index!='\n';index++)
- {
- if(*index==' ')
- {
- if(*(index+1)=' ')
- if(*(index+2)!=' ')
- break;
-
- }
- }
- char *index1=index+2;
- for(index1;*index1!='\n';index1++)
- {
- if(*index1==' ')
- {
- if(*(index1+1)==' ')
- break;
- }
- }
- int num1=0;
- char *index2=index1+2;
- for(index2;*index2!='\n';index2++)
- {
- if(*index2==' ')break;
- num1++;
- }
- strncpy(type,index1+2,num1+1);
- type[num1]='\0';
- strncpy((*activelist)[*count].type,type,num1+1);
- // printf("%s\n",activelist[count].type);
-
- //截取连接所属设备
- char *index3=index2;
- char dev[100];
- for(index3;*index3!='\n';index3++)
- {
- if(*index3==' ')
- {
- if(*(index3+1)!=' ')
- break;
- }
- }
- int num2=0;
- char *index4=index3+1;
- for(index4;*index4!='\n';index4++)
- {
- if(*index4==' ')break;
- num2++;
- }
- strncpy(dev,index3+1,num2+1);
- dev[num2]='\0';
- strncpy((*activelist)[*count].dev,dev,num2+1);
- // printf("%s\n",activelist[count].dev);
- (*count)++;
- }
- fclose(fp);
- return 0;
-}
-
-//创建新的以太网连接
-void kylin_network_create_new_ethernet(char *con_name,char *if_name)
-{
- char str[100];
- char *net_type="ethernet";
- sprintf(str,"nmcli connection add con-name \"%s\" ifname %s type %s",con_name,if_name,net_type);
- int status = system(str);
- if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection add con-name' in function 'kylin_network_create_new_ethernet' failed");}
-}
-
-// 创建新的wifi连接配置
-void kylin_network_create_new_wifi(char *con_name, char *if_name)
-{
- char str[200];
- sprintf(str, "nmcli connection add con-name \"%s\" ifname \"%s\" type wifi ssid \"%s\"",
- con_name, if_name, con_name);
- int status = system(str);
- if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection add con-name' in function 'kylin_network_create_new_wifi' failed");}
-}
-
-//删除以太网连接
-void kylin_network_del_ethernet_con(char *con_name)
-{
- char str[100];
- sprintf(str,"nmcli connection delete \"%s\"",con_name);
- int status = system(str);
- if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection delete' in function 'kylin_network_del_ethernet_con' failed");}
-}
-
-//设置动态分配ip
-void kylin_network_set_automethod(char *con_name)
-{
- char str[100];
- char *automethod="auto";
- sprintf(str,"nmcli connection modify \"%s\" ipv4.method %s ipv4.address '' ipv4.gateway ''",con_name,automethod);
- int status = system(str);
- if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection modify' in function 'kylin_network_set_automethod' failed");}
-}
-
-//设置手动分配ip
-void kylin_network_set_manualmethod(char *con_name,char *ip)
-{
- char str[100];
- char *method="manual";
- sprintf(str,"nmcli connection modify \"%s\" ipv4.method %s ipv4.address %s",con_name,method,ip);
- int status = system(str);
- if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection modify' in function 'kylin_network_set_manualmethod' failed");}
-}
-
-// 设置手动分配all
-void kylin_network_set_manualall(char *con_name, char *addr, char *mask, char *gateway, char *dns){
- char str[200];
- sprintf(str, "nmcli connection modify \"%s\" ipv4.method manual ipv4.address %s/%s ipv4.gateway %s ipv4.dns %s",
- con_name, addr, mask, gateway, dns);
- int status = system(str);
- if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection modify' in function 'kylin_network_set_manualall' failed");}
-}
-
-//设置是否自动连接
-void kylin_network_set_autoconnect(char *con_name,bool autocon)
-{
- char str[200];
- if(autocon==false)
- {
- char *ac="no";
- sprintf(str,"export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection modify \"%s\" connection.autoconnect %s",con_name,ac);
- }
- else{
- char *ac="yes";
- sprintf(str,"export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection modify \"%s\" connection.autoconnect %s",con_name,ac);
- }
- int status = system(str);
- if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection modify' in function 'kylin_network_set_autoconnect' failed");}
-}
-
-//修改ip
-void kylin_network_mod_ip(char *con_name,char *ip)
-{
- char str[100];
- sprintf(str,"nmcli connection modify \"%s\" ipv4.address %s",con_name,ip);
- int status = system(str);
- if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection modify' in function 'kylin_network_mod_ip' failed");}
-}
-
-//修改网关
-void kylin_network_mod_gateway(char *con_name,char *gw)
-{
- char str[100];
- sprintf(str,"nmcli connection modify \"%s\" ipv4.gateway %s",con_name,gw);
- int status = system(str);
- if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection modify' in function 'kylin_network_mod_gateway' failed");}
-}
-
-//修改dns
-void kylin_network_mod_dns(char *con_name,char *dns)
-{
- char str[100];
- sprintf(str,"nmcli connection modify \"%s\" ipv4.dns %s",con_name,dns);
- int status = system(str);
- if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection modify' in function 'kylin_network_mod_dns' failed");}
-}
-
-//连接以太网
-void kylin_network_set_con_up(char *con_name)
-{
- char str[100];
- sprintf(str,"nmcli connection up \"%s\"",con_name);
- int status = system(str);
- if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection up' in function 'kylin_network_set_con_up' failed");}
-}
-
-//断开以太网
-void kylin_network_set_con_down(char *con_name)
-{
- char str[100];
- sprintf(str,"nmcli connection down \"%s\"",con_name);
- int status = system(str);
- if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection down' in function 'kylin_network_set_con_down' failed");}
-}
-
-//连接wifi
-void kylin_network_set_wifi_up(char *con_name,char *passwd)
-{
- char str[100];
- sprintf(str,"export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli device wifi connect \"%s\" password \"%s\"", con_name,passwd);
- int status = system(str);
- if (status != 0){ syslog(LOG_ERR, "execute 'nmcli device wifi connect' in function 'kylin_network_set_wifi_up' failed");}
-}
-
-//断开wifi连接
-void kylin_network_set_wifi_down(char *if_name)
-{
- char str[100];
- sprintf(str,"nmcli device disconnect \"%s\"",if_name);
- int status = system(str);
- if (status != 0){ syslog(LOG_ERR, "execute 'nmcli device disconnect' in function 'kylin_network_set_wifi_down' failed");}
-}
-
-//获取wifi列表信息
-wifilist *kylin_network_get_wifilist_info()
-{
- int status = system("nmcli device wifi > /tmp/wflist.txt");
- if (status != 0){ syslog(LOG_ERR, "execute 'nmcli device wifi' in function 'kylin_network_get_wifilist_info' failed");}
- char *filename="/tmp/wflist.txt";
-
- FILE *wffp;
- int wfnum=0;
- char WfStrLine[1024];
- if((wffp=fopen(filename,"r"))==NULL)
- {
- printf("error!");
-
- }
- fgets(WfStrLine,1024,wffp);
- while(!feof(wffp))
- {
- fgets(WfStrLine,1024,wffp);
- wfnum++;
- }
- // printf("wifi数量:%d\n",wfnum);
- fclose(wffp);
- //wifi实际数量是wfnum-1
- wifilist *wflist=(wifilist *)malloc(sizeof(wifilist)*wfnum);
-
- int count=0;
- FILE *fp;
- char StrLine[1024];
- if((fp=fopen(filename,"r"))==NULL)
- {
- printf("error!");
-
- }
- fgets(StrLine,1024,fp);
- while(!feof(fp))
- {
- if(count==wfnum-1)break;
-
- fgets(StrLine,1024,fp);
-
- // printf("%s\n",StrLine+3);
- char *index=StrLine+3;
-
- //截取ssid
- char *str1="Infra";
- int num=0;
- for(index;strcmp(index+5,"\n")!=0;index++)
- {
- int result=strncmp(index,str1,5);
- if(result==0)
- {
- // printf("%s\n",index);
- break;
-
- }
- num++;
-
- }
- char ssid[100];
- char *ssidindex=index-1;
- int ssidnum=0;
- for(ssidindex;*ssidindex==' ';ssidindex--)ssidnum++;
- // printf("空格数量:%d\n",ssidnum);
- // if(ssidnum==1)
- strncpy(ssid,StrLine+3,num-1);
- ssid[num-ssidnum]='\0';
- // printf("-6666--%s---\n",ssid);
-
- wflist[count].ssid=(char *)malloc(sizeof(char)*(num-ssidnum));
- strncpy(wflist[count].ssid,ssid,num-ssidnum+1);
- // printf("第%d个:%s ",count,wflist[count].ssid);
-
-
- //截取信号强度
- char *str2="Mbit/s";
- for(index;strcmp(index+6,"\n")!=0;index++)
- {
- int result=strncmp(index,str2,6);
- if(result==0)
- {
- // printf("%s\n",index);
- break;
- }
- }
-
- char signal[10];
- char *signalindex=index+8;
- int signalnum=0;
- for(signalindex;*signalindex!=' ';signalindex++)signalnum++;
- strncpy(signal,index+8,signalnum);
- signal[signalnum]='\0';
- // printf("-7777--%s---\n",signal);
-
- wflist[count].signal=atoi(signal);
- // printf("%d ",wflist[count].signal);
-
- //截取安全性
- char *str3="WPA";
- for(index;strcmp(index+3,"\n")!=0;index++)
- {
- int result=strncmp(index,str3,3);
- if(result==0)
- {
- // printf("%s\n",index);
- break;
- }
- }
-
- char safety[20];
- char *safetyindex=index;
- int safetynum=0;
- for(safetyindex;strcmp(safetyindex+2,"\n")!=0;safetyindex++)
- {
- int result=strncmp(safetyindex," ",2);
- if(result==0)break;
- safetynum++;
- }
- strncpy(safety,index,safetynum+1);
- safety[safetynum+1]='\0';
- // printf("-8888--%s---\n",safety);
-
- wflist[count].safety=(char *)malloc(sizeof(char)*(safetynum+1));
- strncpy(wflist[count].safety,safety,safetynum+2);
- // printf("%s\n",wflist[count].safety);
-
- count++;
-
- }
-
- fclose(fp);
-
- wflist[count].ssid=NULL;
- wflist[count].signal=0;
- wflist[count].safety=NULL;
-
- return wflist;
-}
-
-//启用联网
-void kylin_network_enable_networking()
-{
- int status = system("nmcli networking on");
- if (status != 0){ syslog(LOG_ERR, "execute 'nmcli networking on' in function 'kylin_network_enable_networking' failed");}
-}
-
-//禁用联网
-void kylin_network_disable_networking()
-{
- int status = system("nmcli networking off");
- if (status != 0){ syslog(LOG_ERR, "execute 'nmcli networking off' in function 'kylin_network_disable_networking' failed");}
-}
-
-//启用wifi
-void kylin_network_enable_wifi()
-{
- int status = system("nmcli radio wifi on;sleep 3");
- if (status != 0){ syslog(LOG_ERR, "execute 'nmcli radio wifi on' in function 'kylin_network_enable_wifi' failed");}
-}
-
-//禁用wifi
-void kylin_network_disable_wifi()
-{
- int status = system("nmcli radio wifi off;sleep 2");
- if (status != 0){ syslog(LOG_ERR, "execute 'nmcli radio wifi off' in function 'kylin_network_disable_wifi' failed");}
-}
-
-//获取ip地址
-int kylin_network_get_ipaddr(char *if_name,char *ipaddr)
-{
- int sock_ip;
- struct sockaddr_in sin_ip;
- struct ifreq ifr_ip;
- if((sock_ip=socket(AF_INET,SOCK_STREAM,0))<0)
- {
- perror("sockket error");
- return -1;
- }
-
- strcpy(ifr_ip.ifr_name,if_name);
-
- if(ioctl(sock_ip,SIOCGIFADDR,&ifr_ip)<0)//直接获取ip地址
- {
- perror("Not setup interface\n");
- return -1;
- }
-
- memcpy(&sin_ip,&ifr_ip.ifr_addr,sizeof(sin_ip));
- strcpy(ipaddr,inet_ntoa(sin_ip.sin_addr));//#include
- close(sock_ip);
- return 0;
-
-}
-
-//获取广播地址
-int kylin_network_get_brdaddr(char *if_name,char *brdaddr)
-{
- int sock_brdaddr;
- struct sockaddr_in sin_brd;
- struct ifreq ifr_brd;
- if((sock_brdaddr=socket(AF_INET,SOCK_STREAM,0))<0)
- {
- perror("sockket error");
- return -1;
- }
-
- strcpy(ifr_brd.ifr_name,if_name);
-
- if(ioctl(sock_brdaddr,SIOCGIFBRDADDR,&ifr_brd)<0)//直接获取广播地址
- {
- perror("Not setup interface\n");
- return -1;
- }
-
- memcpy(&sin_brd,&ifr_brd.ifr_broadaddr,sizeof(sin_brd));
- strcpy(brdaddr,inet_ntoa(sin_brd.sin_addr));
- close(sock_brdaddr);
- return 0;
-
-}
-
-//获取子网掩码
-int kylin_network_get_netmask(char *if_name,char *netmask)
-{
- int sock_mask;
- struct sockaddr_in sin_netmask;
- struct ifreq ifr_mask;
- if((sock_mask=socket(AF_INET,SOCK_STREAM,0))<0)
- {
- perror("sockket error");
- return -1;
- }
-
- strcpy(ifr_mask.ifr_name,if_name);
-
- if(ioctl(sock_mask,SIOCGIFNETMASK,&ifr_mask)<0)//直接获取子网掩码
- {
- perror("Not setup interface\n");
- return -1;
- }
-
- memcpy(&sin_netmask,&ifr_mask.ifr_netmask,sizeof(sin_netmask));
- strcpy(netmask,inet_ntoa(sin_netmask.sin_addr));
- close(sock_mask);
- return 0;
-
-}
-
-//获取MAC
-int kylin_network_get_mac(char *if_name,char *macaddr)
-{
- int sock_mac;
- struct ifreq ifr_mac;
- struct sockaddr_in sin_mac;
- struct ether_addr ethaddr;//#include
-
- sock_mac=socket(AF_INET,SOCK_STREAM,0);
-
- strcpy(ifr_mac.ifr_name,if_name);
-
- if(-1==ioctl(sock_mac,SIOCGIFHWADDR,&ifr_mac))
- {
- perror("Not setup interface\n");
- return -1;
- }
- memcpy(ðaddr,&ifr_mac.ifr_hwaddr.sa_data,sizeof(ethaddr));
- strcpy(macaddr,ether_ntoa(ðaddr));//#include
-
- // strcpy(macaddr,ether_ntoa((struct ether_addr*)ifr_mac.ifr_hwaddr.sa_data));
-
- close(sock_mac);
- return 0;
-
-}
-
-//获取MTU
-int kylin_network_get_mtu(char *if_name)
-{
- int sock_mtu;
-// struct sockaddr_in sin_ip;
- struct ifreq ifr_MTU;
- if((sock_mtu=socket(AF_INET,SOCK_STREAM,0))<0)
- {
- perror("sockket error");
- return -1;
- }
-
- strcpy(ifr_MTU.ifr_name,if_name);
-
- if(ioctl(sock_mtu,SIOCGIFMTU,&ifr_MTU))
- {
- perror("Not setup interface\n");
- return -1;
- }
-
- int mtu=ifr_MTU.ifr_mtu;
- // printf("%d\n",ifr_MTU.ifr_mtu);
- // printf("%d\n",mtu);
-
- close(sock_mtu);
- return mtu;
-
-}
-
-static void getBuf(char *bufstr)
-{
- //O_RDONLY以只读方式打开文件
- int fd=open("/proc/net/dev", O_RDONLY);
- if(-1==fd)
- {
- printf("/proc/net/dev not exists!\n");
- }
-
- char buf[1024*2];
- //将读写位置移到文件开头
- lseek(fd,0,SEEK_SET);
- int nBytes=read(fd,buf,sizeof(buf)-1);
- if(-1==nBytes)
- {
- perror("read error");
- close(fd);
- }
-
- buf[nBytes]='\0';
- strcpy(bufstr,buf);
-}
-
-//总计上传下载数据量
-long *kylin_network_get_bytes(char *if_name)
-{
- char buf[1024*2];
- getBuf(buf);
-
- //返回第一次指向if_name位置的指针
- char *pDev=strstr(buf,if_name);
- if(NULL==pDev)
- {
- printf("don't find dev %s\n",if_name);
- return NULL;
- }
-
- char *p;
- char *value;
- int i=0;
- static long rtbyt[2];
- /*去除空格,制表符,换行符等不需要的字段*/
- for (p = strtok(pDev, " \t\r\n"); p; p = strtok(NULL, " \t\r\n"))
- {
- i++;
- value = (char*)malloc(20);
- strcpy(value, p);
- /*得到的字符串中的第二个字段是接收流量*/
- if(i == 2)
- {
- rtbyt[0] = atol(value);
- }
- /*得到的字符串中的第十个字段是发送流量*/
- if(i == 10)
- {
- rtbyt[1] = atol(value);
- free(value);
- break;
- }
- free(value);
- }
- return rtbyt;
-}
-
-//总计上传下载数据包
-long *kylin_network_get_packets(char *if_name)
-{
- char buf[1024*2];
- getBuf(buf);
-
- //返回第一次指向if_name位置的指针
- char *pDev=strstr(buf,if_name);
- if(NULL==pDev)
- {
- printf("don't find dev %s\n",if_name);
- return NULL;
- }
-
- char *p;
- char *value;
- int i=0;
- static long rtpkt[2];
- /*去除空格,制表符,换行符等不需要的字段*/
- for (p = strtok(pDev, " \t\r\n"); p; p = strtok(NULL, " \t\r\n"))
- {
- i++;
- value = (char*)malloc(20);
- strcpy(value, p);
- /*得到的字符串中的第三个字段是接收流量*/
- if(i == 3)
- {
- rtpkt[0] = atol(value);
- }
- /*得到的字符串中的第十一个字段是发送流量*/
- if(i == 11)
- {
- rtpkt[1] = atol(value);
- free(value);
- break;
- }
- free(value);
- }
- return rtpkt;
-}
-
-//总计上传下载错误数据包数量
-long *kylin_network_get_errs(char *if_name)
-{
- char buf[1024*2];
- getBuf(buf);
-
- //返回第一次指向if_name位置的指针
- char *pDev=strstr(buf,if_name);
- if(NULL==pDev)
- {
- printf("don't find dev %s\n",if_name);
- return NULL;
- }
-
- char *p;
- char *value;
- int i=0;
- static long rterrs[2];
- /*去除空格,制表符,换行符等不需要的字段*/
- for (p = strtok(pDev, " \t\r\n"); p; p = strtok(NULL, " \t\r\n"))
- {
- i++;
- value = (char*)malloc(20);
- strcpy(value, p);
- /*得到的字符串中的第四个字段是接收流量*/
- if(i == 4)
- {
- rterrs[0] = atol(value);
- }
- /*得到的字符串中的第十二个字段是发送流量*/
- if(i == 12)
- {
- rterrs[1] = atol(value);
- free(value);
- break;
- }
- free(value);
- }
- return rterrs;
-}
-
-//总计上传下载丢弃数据包数量
-long *kylin_network_get_drop(char *if_name)
-{
- char buf[1024*2];
- getBuf(buf);
-
- //返回第一次指向if_name位置的指针
- char *pDev=strstr(buf,if_name);
- if(NULL==pDev)
- {
- printf("don't find dev %s\n",if_name);
- return NULL;
- }
-
- char *p;
- char *value;
- int i=0;
- static long rtdrop[2];
- /*去除空格,制表符,换行符等不需要的字段*/
- for (p = strtok(pDev, " \t\r\n"); p; p = strtok(NULL, " \t\r\n"))
- {
- i++;
- value = (char*)malloc(20);
- strcpy(value, p);
- /*得到的字符串中的第五个字段是接收流量*/
- if(i == 5)
- {
- rtdrop[0] = atol(value);
- }
- /*得到的字符串中的第十三个字段是发送流量*/
- if(i == 13)
- {
- rtdrop[1] = atol(value);
- free(value);
- break;
- }
- free(value);
- }
- return rtdrop;
-}
-
-//总计上传下载过载数据包数量
-long *kylin_network_get_fifo(char *if_name)
-{
- char buf[1024*2];
- getBuf(buf);
-
- //返回第一次指向if_name位置的指针
- char *pDev=strstr(buf,if_name);
- if(NULL==pDev)
- {
- printf("don't find dev %s\n",if_name);
- return NULL;
- }
-
- char *p;
- char *value;
- int i=0;
- static long rtfifo[2];
- /*去除空格,制表符,换行符等不需要的字段*/
- for (p = strtok(pDev, " \t\r\n"); p; p = strtok(NULL, " \t\r\n"))
- {
- i++;
- value = (char*)malloc(20);
- strcpy(value, p);
- /*得到的字符串中的第六个字段是接收流量*/
- if(i == 6)
- {
- rtfifo[0] = atol(value);
- }
- /*得到的字符串中的第十四个字段是发送流量*/
- if(i == 14)
- {
- rtfifo[1] = atol(value);
- free(value);
- break;
- }
- free(value);
- }
- return rtfifo;
-}
diff --git a/KylinNM/src/kylin-network-interface.h b/KylinNM/src/kylin-network-interface.h
deleted file mode 100644
index db18a52..0000000
--- a/KylinNM/src/kylin-network-interface.h
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Copyright (C) 2020 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
-#include
-#include
-#include
-#include
-#include
-#include
-
-#ifdef __cplusplus
-extern "C"{
-#endif
-
-typedef struct
-{
- char *if_name;
-}ifname;
-
-typedef struct
-{
- char *ssid;//wifi名称
- int signal;//信号强度
- char *safety;//安全性
-
-}wifilist;//存放wifi信息的结构体
-
-typedef struct
-{
- char *con_name;//网络连接名称
- char *type;//网络连接类型
-}conlist;//存放所有网络连接
-
-typedef struct
-{
- char con_name[128];//活动网络连接名称
- char type[128];//活动网络连接类型
- char dev[128];//活动网络所属设备
-}activecon;//存放当前活动网络连接
-
-/*
- * Get the network interface name.
- * return the struct pointer.
- */
-ifname *kylin_network_get_ifacename();
-
-/*
- * Get the all network connection.
- * return the struct pointer.
- */
-conlist *kylin_network_get_conlist_info();
-
-/*
- * Get the active network connection.
- * return the struct pointer and list count.
- */
-int kylin_network_get_activecon_info(activecon** activelist, int* count);
-
-/*
- * Create a new Ethernet connection.
- * @con_name is the connection name.
- * @if_name is the interface name.
- */
-void kylin_network_create_new_ethernet(char *con_name,char *if_name);
-
-/*
- * Create a new Wifi connection.
- * @con_name is the connection name.
- * @if_name is the interface name.
- */
-void kylin_network_create_new_wifi(char *con_name, char *if_name);
-
-/*
- * Delete ethernet connection.
- * @con_name is the connection name.
- */
-void kylin_network_del_ethernet_con(char *con_name);
-
-/*
- * Set up dynamic IP allocation.
- * @con_name is the connection name.
- */
-void kylin_network_set_automethod(char *con_name);
-
-/*
- * Set up manual IP assignment.
- * @con_name is the connection name.
- * @ip is the ip address(for example,"192.168.68.160/16")
- */
-void kylin_network_set_manualmethod(char *con_name,char *ip);
-
-/*
- * Set up manual all prop.
- */
-void kylin_network_set_manualall(char *con_name, char *addr, char *mask, char *gateway, char *dns);
-
-/*
- * Sets whether the connection is automatic.
- * @con_name is the connection name.
- * @autocon is the automatic connection option.
- */
-void kylin_network_set_autoconnect(char *con_name,bool autocon);
-
-/*
- * Modify the ip address.
- * @con_name is the connection name.
- * @ip is the ip address(for example,"192.168.68.160/16")
- */
-void kylin_network_mod_ip(char *con_name,char *ip);
-
-/*
- * Modify the gateway.
- * @con_name is the connection name.
- * @gw is the gateway address.
- */
-void kylin_network_mod_gateway(char *con_name,char *gw);
-
-/*
- * Modify the dns address.
- * @con_name is the connection name.
- * @dns is the dns address.
- */
-void kylin_network_mod_dns(char *con_name,char *dns);
-
-/*
- * Connect the ethernet.
- * @con_name is the connection name.
- */
-void kylin_network_set_con_up(char *con_name);
-
-/*
- * Disconnect the ethernet.
- * @con_name is the connection name.
- */
-void kylin_network_set_con_down(char *con_name);
-
-/*
- * Connect the wifi.
- * @con_name is the wifi name.
- * @passwd is the wifi password.
- */
-void kylin_network_set_wifi_up(char *con_name,char *passwd);
-
-/*
- * Disconnect the wifi.
- * @if_name is the network interface name.
- */
-void kylin_network_set_wifi_down(char *if_name);
-
-/*
- * Get wifi list information.
- * Return the struct pointer.
- */
-wifilist *kylin_network_get_wifilist_info();
-
-/*
- * Enable networking.
- */
-void kylin_network_enable_networking();
-
-/*
- * Disable networking.
- */
-void kylin_network_disable_networking();
-
-/*
- * Enable wifi.
- */
-void kylin_network_enable_wifi();
-
-/*
- * Disable wifi.
- */
-void kylin_network_disable_wifi();
-
-/* Get the ip address.
- * @if_name is the interface name.
- * @ipaddr is used to save the ip address.
- */
-int kylin_network_get_ipaddr(char *if_name,char *ipaddr);
-
-/*
- * Get the broadcast address.
- * @if_name is the interface name.
- * @brdaddr is used to save the broadcast address.
- */
-int kylin_network_get_brdaddr(char *if_name,char *brdaddr);
-
-/*
- * Get the subnet mask.
- * @if_name is the interface name.
- * @netmask is used to save the subnet mask.
- */
-int kylin_network_get_netmask(char *if_name,char *netmask);
-
-/*
- * Get MAC address.
- * @if_name is the interface name.
- * @macaddr is used to save the MAC address.
- */
-int kylin_network_get_mac(char *if_name,char *macaddr);
-
-/* Get the MTU.
- * @if_name is the interface name.
- * return the MTU value.
- */
-int kylin_network_get_mtu(char *if_name);
-
-/*
- * Total upload and download data volume.
- * @if_name is the network interface name.
- * return the address of the first element of a one-dimensional long integer array.
- */
-long *kylin_network_get_bytes(char *if_name);
-
-/*
- * Total upload and download data packets.
- * @if_name is the network interface name.
- * return the address of the first element of a one-dimensional long integer array.
- */
-long *kylin_network_get_packets(char *if_name);
-
-/*
- * Total wrong data packets number of uploading and downloading.
- * @if_name is the network interface name.
- * return the address of the first element of a one-dimensional long integer array.
- */
-long *kylin_network_get_errs(char *if_name);
-
-/*
- * Total discarded data packets number of uploading and downloading.
- * @if_name is the network interface name.
- * return the address of the first element of a one-dimensional long integer array.
- */
-long *kylin_network_get_drop(char *if_name);
-
-/*
- * Total overloaded data packets number of uploading and downloading.
- * @if_name is the network interface name.
- * return the address of the first element of a one-dimensional long integer array.
- */
-long *kylin_network_get_fifo(char *if_name);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/KylinNM/src/kylinnm.cpp b/KylinNM/src/kylinnm.cpp
deleted file mode 100644
index aa6ca7e..0000000
--- a/KylinNM/src/kylinnm.cpp
+++ /dev/null
@@ -1,2799 +0,0 @@
-/*
- * Copyright (C) 2020 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
-#include
-#include
-#include
-
-#include "kylinnm.h"
-#include "ui_kylinnm.h"
-#include "swipegesturerecognizer.h"
-
-QString llname, lwname, hideWiFiConn;
-int currentActWifiSignalLv, count_loop;
-
-bool KylinNM::m_is_reflashWifiUi = false;
-QMutex mutexIsReflashWifi;
-
-KylinNM::KylinNM(QWidget *parent) :
- QWidget(parent),
- ui(new Ui::KylinNM)
-{
- ui->setupUi(this);
- qDebug() << "99999999999999999999999999--------------9";
- //checkSingle();
-
- syslog(LOG_DEBUG, "Using the icon theme named 'ukui-icon-theme-default'");
- //QIcon::setThemeName("ukui-icon-theme-default");
-
- // 如果使用Qt::Popup 任务栏不显示且保留X事件如XCB_FOCUS_OUT, 但如果indicator点击鼠标右键触发,XCB_FOCUS_OUT事件依然会失效
- // 如果使用Qt::ToolTip, Qt::Tool + Qt::WindowStaysOnTopHint, Qt::X11BypassWindowManagerHint等flag则会导致X事件失效
- // this->setWindowFlags(Qt::FramelessWindowHint | Qt::Tool | Qt::WindowStaysOnTopHint);
- this->setWindowFlags(Qt::FramelessWindowHint);//QTool
- this->setAttribute(Qt::WA_TranslucentBackground);//设置窗口背景透明
-
- //UseQssFile::setStyle("style.qss");
-
- QPainterPath path;
- auto rect = this->rect();
- rect.adjust(1, 1, -1, -1);
- path.addRoundedRect(rect, 6, 6);
- setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
-
- this->setStyleSheet("#centralWidget{border:none;border-radius:16px;}");
-
- ui->centralWidget->setStyleSheet("#centralWidget{border:none;border-radius:16px;background:rgba(255,255,255,1);}");
-
- editQssString(); //编辑部分控件QSS
- createTopLanUI(); //创建顶部有线网item
- createTopWifiUI(); //创建顶部无线网item
- createOtherUI(); //创建上传下载控件,列表区无item时的说明控件
- createListAreaUI(); //创建列表区域的控件
- createLeftAreaUI(); //创建左侧区域控件
-
- lname = "-1";
- wname = "-1";
- llname = "-1";
- lwname = "-1";
- hideWiFiConn = "Connect to Hidden Wi-Fi Network";
- currentActWifiSignalLv = -1;
- count_loop = 0;
-
- createTrayIcon();
- connect(trayIcon, &QSystemTrayIcon::activated, this, &KylinNM::iconActivated);
- connect(mShowWindow,SIGNAL(triggered()),this,SLOT(on_showWindowAction()));
- connect(mAdvConf,SIGNAL(triggered()),this,SLOT(on_btnAdvConf_clicked()));
- trayIcon->show();
-
- objKyDBus = new KylinDBus(this);
- objKyDBus->initBtnWifiGsetting();
- objKyDBus->initConnectionInfo();
-
- objKyDBus->initTaskbarGsetting();
-// objKyDBus->setWifiSignal(-1, "");
-
- objNetSpeed = new NetworkSpeed();
-
- this->confForm = new ConfForm(this->parentWidget());
- this->confForm->setMainWindow(this);
- this->confForm->hide();
-
- this->ksnm = new KSimpleNM();
- connect(ksnm, SIGNAL(getLanListFinished(QStringList)), this, SLOT(getLanListDone(QStringList)));
- connect(ksnm, SIGNAL(getWifiListFinished(QStringList)), this, SLOT(getWifiListDone(QStringList)));
-
- loading = new LoadingDiv(this);
- connect(loading, SIGNAL(toStopLoading() ), this, SLOT(on_checkOverTime() ));
-
- checkIsWirelessDeviceOn(); //检测无线网卡是否插入
- getInitLanSlist(); //初始化有线网列表
- initNetwork(); //初始化网络
- initTimer(); //初始化定时器
-
- connect(ui->btnNetList, &QPushButton::clicked, this, &KylinNM::onBtnNetListClicked);
- connect(btnWireless, &SwitchButton::clicked,this, &KylinNM::onBtnWifiClicked);
-
- //auto app = static_cast(QCoreApplication::instance());
- //app->setStyle(new CustomStyle()); //设置自定义主题
-
- ui->btnNetList->setAttribute(Qt::WA_Hover,true);
- ui->btnNetList->installEventFilter(this);
- ui->btnWifiList->setAttribute(Qt::WA_Hover,true);
- ui->btnWifiList->installEventFilter(this);
-
- SwipeGestureRecognizer *fftRecognizer = new SwipeGestureRecognizer(this);
- Qt::GestureType fftType = QGestureRecognizer::registerRecognizer(fftRecognizer);
-// grabGesture(fftType);
- connect(fftRecognizer, &SwipeGestureRecognizer::onSwipeGesture, this, &KylinNM::onSwipeGesture);
-}
-
-KylinNM::~KylinNM()
-{
- trayIcon->deleteLater();
- trayIconMenu->deleteLater();
- delete ui;
-}
-
-void KylinNM::onSwipeGesture(int dx, int dy)
-{
- // qDebug() << "info: [KylinNM] onSwipeGesture dy=" << dy;
- if(scrollAreal->isVisible()) {
- // qDebug() << "info: [KylinNM] onSwipeGesture before moved " << scrollAreal->verticalScrollBar()->value();
- scrollAreal->verticalScrollBar()->setValue(scrollAreal->verticalScrollBar()->value() - dy/5);
- // qDebug() << "info: [KylinNM] onSwipeGesture after moved " << scrollAreal->verticalScrollBar()->value();
- } else if (scrollAreaw->isVisible()) {
- // qDebug() << "info: [KylinNM] onSwipeGesture before moved " << scrollAreaw->verticalScrollBar()->value();
- scrollAreaw->verticalScrollBar()->setValue(scrollAreaw->verticalScrollBar()->value() - dy/5);
- // qDebug() << "info: [KylinNM] onSwipeGesture after moved " << scrollAreaw->verticalScrollBar()->value();
- }
-}
-
-void KylinNM::checkSingle()
-{
- int fd = 0;
- try {
- QStringList homePath = QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
- QString lockPath = homePath.at(0) + "/.config/kylin-nm-lock";
- fd = open(lockPath.toUtf8().data(), O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
-
- if (fd < 0) {
- throw -1;
- }
- } catch(...) {
- fd = open("/tmp/kylin-nm-lock", O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
- if (fd < 0) {
- exit(0);
- }
- }
-
-
- if (lockf(fd, F_TLOCK, 0)) {
- syslog(LOG_ERR, "Can't lock single file, kylin-network-manager is already running!");
- qDebug()<<"Can't lock single file, kylin-network-manager is already running!";
- exit(0);
- }
-}
-
-bool KylinNM::nativeEvent(const QByteArray &eventType, void *message, long *result)
-{
- Q_UNUSED(result);
- if (eventType != "xcb_generic_event_t") {
- return false;
- }
-
- xcb_generic_event_t *event = (xcb_generic_event_t*)message;
-
- switch (event->response_type & ~0x80) {
- case XCB_FOCUS_OUT:
- //this->hide();
- break;
- }
-
- return false;
-}
-
-bool KylinNM::eventFilter(QObject *obj, QEvent *event)
-{
- if (obj == ui->btnNetList) {
- if (event->type() == QEvent::HoverEnter) {
- if (!is_btnNetList_clicked) {
- ui->lbNetListBG->setStyleSheet(btnBgHoverQss);
- }
- return true;
- } else if(event->type() == QEvent::HoverLeave) {
- if (!is_btnNetList_clicked) {
- ui->lbNetListBG->setStyleSheet(btnBgLeaveQss);
- }
- return true;
- }
- }
-
- if (obj == ui->btnWifiList) {
- if (event->type() == QEvent::HoverEnter) {
- if (!is_btnWifiList_clicked) {
- ui->lbWifiListBG->setStyleSheet(btnBgHoverQss);
- }
- return true;
- } else if(event->type() == QEvent::HoverLeave) {
- if (!is_btnWifiList_clicked) {
- ui->lbWifiListBG->setStyleSheet(btnBgLeaveQss);
- }
- return true;
- }
- }
-
- return QWidget::eventFilter(obj,event);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-void KylinNM::tabletStyle()//平板桌面模式特有设置
-{
- this->setFixedWidth(446+194*isTabletStyle);
- ui->centralWidget->setFixedWidth(446+194*isTabletStyle);
- ui->btnNetList->setFixedWidth(223+97*isTabletStyle);
- ui->btnWifiList->setFixedWidth(223+97*isTabletStyle);
- ui->btnWifiList->move(223+97*isTabletStyle,0);
- ui->lbWifiListBG->move(223+97*isTabletStyle,0);
- ui->lbNetListImg->move(16+95*isTabletStyle,17);
- ui->lbWifiListImg->move(288+144*isTabletStyle,17);
- scrollAreal->resize(W_SCROLL_AREA+194*isTabletStyle, H_SCROLL_AREA);
- scrollAreaw->resize(W_SCROLL_AREA+194*isTabletStyle, H_SCROLL_AREA);
- lbNetListText->move(98+48*isTabletStyle,2);
- lbWifiListText->move(98+48*isTabletStyle,2);
- confForm->tabletStyle(isTabletStyle);
- btnWireless->move(385+194*isTabletStyle,73);
- lbNoItemTip->move(this->width()/2 - lbNoItemTip->width()/2, this->height()/2+30);
- if(isTabletStyle)
- {
- btnOffQss = "QLabel{min-width: 320px; min-height: 56px;max-width:320px; max-height: 56px;border-radius: 16px; background-color:rgba(255,255,255,0);}";
- btnOnQss = "QLabel{min-width: 320px; min-height: 56px;max-width:320px; max-height: 56px;border-radius: 16px; background-color:rgba(61,107,229,1);}";
- }
- else
- {
- btnOffQss = "QLabel{min-width: 221px; min-height: 56px;max-width:221px; max-height: 56px;border-radius: 16px; background-color:rgba(255,255,255,0)}";
- btnOnQss = "QLabel{min-width: 221px; min-height: 56px;max-width:221px; max-height: 56px;border-radius: 16px; background-color:rgba(61,107,229,1);}";
- }
- if(scrollAreal->isHidden())//首次运行初始化大按钮状态
- {
- ui->btnNetList->setStyleSheet(btnOffQss);
- ui->btnWifiList->setStyleSheet(btnOnQss);
- ui->lbNetListBG->setStyleSheet(btnOffQss);
- ui->lbWifiListBG->setStyleSheet(btnOnQss);
- ui->lbNetListImg->setStyleSheet("QLabel{border-image:url(:/res/l/pb-network-offline.png);background-position:center;background-repeat:no-repeat;}");
- ui->lbWifiListImg->setStyleSheet("QLabel{border-image:url(:/res/x/pb-wifi-y.png);background-position:center;background-repeat:no-repeat;}");
- lbNetListText->setStyleSheet("QLabel{color:rgba(38, 38, 38, 0.75);background-color:transparent;}");
- lbWifiListText->setStyleSheet("QLabel{color:rgba(47, 179, 232, 1);background-color:transparent;}");
- }
-}
-
-// 初始化控件、网络、定时器
-
-// 初始化界面各控件
-void KylinNM::editQssString()
-{
- btnOffQss = "QLabel{min-width: 221px; min-height: 56px;max-width:221px; max-height: 56px;border-radius: 16px; background-color:rgba(38,38,38,0.15)}";
- btnOnQss = "QLabel{min-width: 221px; min-height: 56px;max-width:221px; max-height: 56px;border-radius: 16px; background-color:rgba(255,255,255,0.2)}";
- btnBgOffQss = "QLabel{min-width: 48px; min-height: 22px;max-width:48px; max-height: 22px;border-radius: 16px; background-color:rgba(38,38,38,0.15)}";
- btnBgOnQss = "QLabel{min-width: 48px; min-height: 22px;max-width:48px; max-height: 22px;border-radius: 16px; background-color:rgba(255,255,255,0.2);}";
- btnBgHoverQss = "QLabel{border-radius: 16px; background-color:rgba(38,38,38,0.2)}";
- btnBgLeaveQss = "QLabel{border-radius: 16px; background-color:rgba(38,38,38,0.15)}";
- leftBtnQss = "QPushButton{border:0px;border-radius:4px;background-color:rgba(255,255,255,0);}"
- "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(255,255,255,0.12);}"
- "QPushButton:Pressed{border-radius:4px;background-color:rgba(255,255,255,0.12);}";
-// funcBtnQss = "QPushButton{border:0px;border-radius:4px;background-color:rgba(255,255,255,0);color:rgba(107,142,235,0.97);font-size:14px;}"
-// "QPushButton:Hover{border:0px;border-radius:4px;background-color:rgba(255,255,255,0);color:rgba(151,175,241,0.97);font-size:14px;}"
-// "QPushButton:Pressed{border-radius:4px;background-color:rgba(255,255,255,0);color:rgba(61,107,229,0.97);font-size:14px;}";
- funcBtnQss="QPushButton{border:0px;border-radius:4px;background-color:rgba(255,255,255,0);color:rgba(38,38,38,1);font-size:14px;text-align:left;}";
-}
-
-void KylinNM::createTopLanUI()
-{
- topLanListWidget = new QWidget(ui->centralWidget);
- topLanListWidget->move(W_LEFT_AREA, Y_TOP_ITEM);
- topLanListWidget->resize(W_TOP_LIST_WIDGET, H_NORMAL_ITEM + H_GAP_UP + X_ITEM);
- /*顶部的一个item*/
- lbTopLanList = new QLabel(topLanListWidget);
- lbTopLanList->setText(tr("Inactivated LAN"));//"可用网络列表"
- lbTopLanList->resize(W_MIDDLE_WORD, H_MIDDLE_WORD);
- lbTopLanList->move(X_MIDDLE_WORD, H_NORMAL_ITEM + H_GAP_UP);
- lbTopLanList->setStyleSheet("QLabel{font-size:14px;color:rgba(38, 38, 38, 0.45);}");
- lbTopLanList->show();
- /*新建有线网按钮*/
-// btnCreateNet = new QPushButton(ui->centralWidget);
-// btnCreateNet->resize(W_BTN_FUN, H_BTN_FUN);
-// btnCreateNet->move(X_BTN_FUN, Y_BTN_FUN);
-// btnCreateNet->setText(" "+tr("New LAN"));//"新建网络"
-// btnCreateNet->setIcon(QIcon(":/res/x/pb-newConn.png"));
-// btnCreateNet->setStyleSheet(funcBtnQss);
-// btnCreateNet->setFocusPolicy(Qt::NoFocus);
-// btnCreateNet->show();
-// connect(btnCreateNet,SIGNAL(clicked()),this,SLOT(onBtnCreateNetClicked()));
-}
-
-void KylinNM::createTopWifiUI()
-{
- topWifiListWidget = new QWidget(ui->centralWidget);
- topWifiListWidget->move(W_LEFT_AREA, Y_TOP_ITEM);
- topWifiListWidget->resize(W_TOP_LIST_WIDGET+194*isTabletStyle, H_NORMAL_ITEM + H_GAP_UP + X_ITEM);
- /*顶部的一个item*/
- lbTopWifiList = new QLabel(topWifiListWidget);
- lbTopWifiList->setText(tr("Other WLAN"));//"可用网络列表"
- lbTopWifiList->resize(W_MIDDLE_WORD, H_MIDDLE_WORD);
- lbTopWifiList->move(X_MIDDLE_WORD, H_NORMAL_ITEM + H_GAP_UP);
- lbTopWifiList->setStyleSheet("QLabel{font-size:14px;color:rgba(38, 38, 38, 0.45);}");
- lbTopWifiList->show();
-
-// /*新建无线网按钮*/
-// if(!btnAddNet){
-// btnAddNet = new QPushButton(ui->centralWidget);
-// connect(btnAddNet,SIGNAL(clicked()),this,SLOT(onBtnAddNetClicked()));
-// }
-// btnAddNet->resize(W_BTN_FUN, H_BTN_FUN);
-// btnAddNet->move(X_BTN_FUN, Y_BTN_FUN);
-// btnAddNet->setText(" "+tr("Hide WiFi"));//"加入网络"
-// btnAddNet->setIcon(QIcon(":/res/x/pb-newConn.png"));
-// btnAddNet->setStyleSheet(funcBtnQss);
-// btnAddNet->setFocusPolicy(Qt::NoFocus);
-}
-
-void KylinNM::createOtherUI()
-{
- lbLoadDown = new QLabel(ui->centralWidget);
- lbLoadDown->move(X_ITEM + 129, Y_TOP_ITEM + 32);
- lbLoadDown->resize(65, 20);
- lbLoadDownImg = new QLabel(ui->centralWidget);
- lbLoadDownImg->move(X_ITEM + 112, Y_TOP_ITEM + 35);
- lbLoadDownImg->resize(16, 16);
-
- lbLoadUp = new QLabel(ui->centralWidget);
- lbLoadUp->move(X_ITEM + 187, Y_TOP_ITEM + 32);
- lbLoadUp->resize(65, 20);
- lbLoadUpImg = new QLabel(ui->centralWidget);
- lbLoadUpImg->move(X_ITEM + 170, Y_TOP_ITEM + 35);
- lbLoadUpImg->resize(16, 16);
-
-//YYF lbLoadDownImg->setStyleSheet("QLabel{background-image:url(:/res/x/load-down.png);}");
-//YYF lbLoadUpImg->setStyleSheet("QLabel{background-image:url(:/res/x/load-up.png);}");
-
- lbNoItemTip = new QLabel(ui->centralWidget);
- lbNoItemTip->resize(W_NO_ITEM_TIP, H_NO_ITEM_TIP);
- lbNoItemTip->move(this->width()/2 - W_NO_ITEM_TIP/2 + W_LEFT_AREA/2, this->height()/2);
- lbNoItemTip->setStyleSheet("QLabel{border:none;background:transparent;font-size:14px;color:rgba(38, 38, 38, 0.45);}");
- lbNoItemTip->setText(tr("No usable network in the list"));//列表暂无可连接网络
- lbNoItemTip->setAlignment(Qt::AlignCenter);
- lbNoItemTip->hide();
-}
-
-void KylinNM::createListAreaUI()
-{
- scrollAreal = new QScrollArea(ui->centralWidget);
- scrollAreal->move(W_LEFT_AREA, Y_TOP_ITEM + H_NORMAL_ITEM + H_GAP_UP + X_ITEM + H_GAP_DOWN);
- scrollAreal->resize(W_SCROLL_AREA, H_SCROLL_AREA);
- scrollAreal->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- scrollAreal->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
-
- scrollAreaw = new QScrollArea(ui->centralWidget);
- scrollAreaw->move(W_LEFT_AREA, Y_TOP_ITEM + H_NORMAL_ITEM + H_GAP_UP + X_ITEM + H_GAP_DOWN);
- scrollAreaw->resize(W_SCROLL_AREA, H_SCROLL_AREA);
- scrollAreaw->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- scrollAreaw->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
-
- lanListWidget = new QWidget(scrollAreal);
- wifiListWidget = new QWidget(scrollAreaw);
- lbLanList = new QLabel(lanListWidget);
- lbWifiList = new QLabel(wifiListWidget);
-
- ui->lbNetwork->setStyleSheet("QLabel{font-size:14px;color:rgba(38, 38, 38, 0.45);}");
- ui->lbNetwork->show();
-
- topLanListWidget->setStyleSheet("QWidget{border:none;}");
- topLanListWidget->setStyleSheet("background-color:transparent;");
-
- topWifiListWidget->setStyleSheet("QWidget{border:none;}");
- topWifiListWidget->setStyleSheet("background-color:transparent;");
-
- lbLoadUp->setStyleSheet("QLabel{font-size:14px;color:rgba(38, 38, 38, 0.45);}");
- lbLoadDown->setStyleSheet("QLabel{font-size:14px;color:rgba(38, 38, 38, 0.45);}");
-//YYF lbLoadUp->setText("0KB/s");
-//YYF lbLoadDown->setText("0KB/s ");
-//YYF this->on_setNetSpeed();
- scrollAreal->setStyleSheet("QScrollArea{border:none;}");
- scrollAreal->viewport()->setStyleSheet("background-color:transparent;");
- //scrollAreal->verticalScrollBar()->setStyleSheet(scrollBarQss);
- scrollAreal->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu);
-
- scrollAreaw->setStyleSheet("QScrollArea{border:none;}");
- scrollAreaw->viewport()->setStyleSheet("background-color:transparent;");
- //scrollAreaw->verticalScrollBar()->setStyleSheet(scrollBarQss);
- scrollAreaw->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu);
-}
-
-void KylinNM::createLeftAreaUI()
-{
- btnWireless = new SwitchButton(this);
- // btnWireless->setStyleSheet("SwitchButton{border:none;background-color:rgba(255,255,255,0.12);}");
- ui->btnNetList->setFocusPolicy(Qt::NoFocus);
- QString txtEthernet(tr("LAN"));
- ui->lbNetListBG->setStyleSheet(btnOffQss);
- lbNetListText =new QLabel(ui->lbNetListBG);
- lbNetListText->setFocusPolicy(Qt::NoFocus);
- lbNetListText->setText(tr("LAN"));
- lbNetListText->move(98,2);
- lbNetListText->setStyleSheet("QLabel{color:rgba(47, 179, 232, 1);background-color:transparent;}");
- ui->lbNetListImg->setStyleSheet("QLabel{border-image:url(:/res/l/pb-network-online.png);background-position:center;background-repeat:no-repeat;}");
-
- ui->btnWifiList->setFocusPolicy(Qt::NoFocus);
- QString txtWifi(tr("WLAN"));
- ui->lbWifiListBG->setStyleSheet(btnOffQss);
- lbWifiListText =new QLabel(ui->lbWifiListBG);
- lbWifiListText->setFocusPolicy(Qt::NoFocus);
- lbWifiListText->setText(tr("WLAN"));
- lbWifiListText->move(98,2);
- lbWifiListText->setStyleSheet("QLabel{color:rgba(38, 38, 38, 0.75);background-color:transparent;}");
- ui->lbWifiListImg->setStyleSheet("QLabel{border-image:url(:/res/x/pb-wifi-n.png);background-position:center;background-repeat:no-repeat;}");
-
- ui->btnNet->hide();
-
- btnWireless->move(385,73);
-
- ui->btnHotspot->setStyleSheet(leftBtnQss);
- ui->btnHotspot->setFocusPolicy(Qt::NoFocus);
- QString txtHotSpot(tr("HotSpot"));
- ui->btnHotspot->hide();
- ui->lbHotImg->hide();
- ui->lbHotImg->setStyleSheet("QLabel{background-image:url(:/res/x/hot-spot-off.svg);}");
- ui->lbHotBG->hide();
- ui->lbHotBG->setStyleSheet(btnOffQss);
-
- ui->btnFlyMode->setStyleSheet(leftBtnQss);
- ui->btnFlyMode->setFocusPolicy(Qt::NoFocus);
- QString txtFlyMode(tr("FlyMode"));
- ui->btnFlyMode->hide();
- ui->lbFlyImg->hide();
- ui->lbFlyImg->setStyleSheet("QLabel{background-image:url(:/res/x/fly-mode-off.svg);}");
- ui->lbFlyBG->hide();
- ui->lbFlyBG->setStyleSheet(btnOffQss);
-
- ui->btnAdvConf->setStyleSheet(leftBtnQss);
- ui->btnAdvConf->setFocusPolicy(Qt::NoFocus);
- QString txtAdvanced(tr("Advanced"));
- //ui->lbBtnConfImg->setStyleSheet("QLabel{background-image:url(:/res/x/setup.png);}");
- ui->btnConfImg->setStyleSheet("QPushButton{background-image:url(:/res/x/setup.png);}");
- //ui->btnConfImg->setIcon(QIcon::fromTheme("settings-app-symbolic.svg", QIcon(":/res/x/setup.png")) );
-}
-
-// 初始化有线网列表
-void KylinNM::getInitLanSlist()
-{
- const int BUF_SIZE = 1024;
- char buf[BUF_SIZE];
-
- FILE * p_file = NULL;
-
- p_file = popen("export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli -f type,device,name connection show", "r");
- if (!p_file) {
- syslog(LOG_ERR, "Error occurred when popen cmd 'nmcli connection show'");
- qDebug()<<"Error occurred when popen cmd 'nmcli connection show";
- }
- while (fgets(buf, BUF_SIZE, p_file) != NULL) {
- QString strSlist = "";
- QString line(buf);
- strSlist = line.trimmed();
- if (strSlist.indexOf("UUID") != -1 || strSlist.indexOf("NAME") != -1) {
- oldLanSlist.append(strSlist);
- }
- if (strSlist.indexOf("802-3-ethernet") != -1 || strSlist.indexOf("ethernet") != -1) {
- oldLanSlist.append(strSlist);
- }
- }
- pclose(p_file);
-}
-
-// 初始化网络
-void KylinNM::initNetwork()
-{
- BackThread bt;
- IFace iface = bt.execGetIface();
-
- wname = iface.wname;
- lwname = iface.wname;
- lname = iface.lname;
- llname = iface.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 ="<lbBtnNetBG->setStyleSheet(btnOnQss);
- 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);
- } else {
- btnWireless->setSwitchStatus(false);
- //ui->lbBtnWifiBG->setStyleSheet(btnBgOffQss);
- //ui->lbBtnWifiBall->move(X_LEFT_WIFI_BALL, Y_WIFI_BALL);
- }
-
- // 初始化网络列表
- if (iface.wstate != 2) {
- if (iface.wstate == 0) {
- connWifiDone(3);
- } else {
- if (iface.lstate == 0) {
- connLanDone(3);
- }
- }
- on_btnWifiList_clicked();
-
- ui->btnNetList->setStyleSheet("QPushButton{border:0px solid rgba(255,255,255,0);background-color:rgba(255,255,255,0);}");
- ui->btnWifiList->setStyleSheet("QPushButton{border:none;}");
- } else {
- objKyDBus->setWifiSwitchState(false); //通知控制面板wifi未开启
- if (iface.lstate != 2) {
- if (iface.lstate == 0) {
- connLanDone(3);
- }
- onBtnNetListClicked();
-
- ui->btnNetList->setStyleSheet("QPushButton{border:0px solid rgba(255,255,255,0);background-color:rgba(255,255,255,0);}");
- ui->btnWifiList->setStyleSheet("QPushButton{border:none;}");
- } else {
- /*没看懂这段断开连接是什么意思,暂时关闭这段操作,会导致页面卡顿、某些情景还会自动断开网络
-// BackThread *m_bt = new BackThread();
-// m_bt->execGetIface();
-
-// m_bt->disConnLanOrWifi("ethernet");
-// sleep(1);
-// m_bt->disConnLanOrWifi("ethernet");
-// sleep(1);
-// m_bt->disConnLanOrWifi("ethernet");
-
-// m_bt->deleteLater();
- */
-
- char *chr = "nmcli networking on";
- Utils::m_system(chr);
- }
- }
- //第一次加载时,加载完lan列表会继续加载WIFI列表,先加载lan后加载WIFI是为了保证在加载WIFI时打开的计时器不会被直接关闭
- onBtnNetListClicked();
- //平板上默认展示wifi界面
-// on_btnWifiList_clicked();
-}
-
-// 初始化定时器
-void KylinNM::initTimer()
-{
- //循环检测wifi列表的变化,可用于更新wifi列表
- checkWifiListChanged = new QTimer(this);
- checkWifiListChanged->setTimerType(Qt::PreciseTimer);
- QObject::connect(checkWifiListChanged, SIGNAL(timeout()), this, SLOT(on_checkWifiListChanged()));
- checkWifiListChanged->start(7000);
-
- //网线插入时定时执行
- wiredCableUpTimer = new QTimer(this);
- wiredCableUpTimer->setTimerType(Qt::PreciseTimer);
- QObject::connect(wiredCableUpTimer, SIGNAL(timeout()), this, SLOT(onCarrierUpHandle()));
-
- //网线拔出时定时执行
- wiredCableDownTimer = new QTimer(this);
- wiredCableDownTimer->setTimerType(Qt::PreciseTimer);
- QObject::connect(wiredCableDownTimer, SIGNAL(timeout()), this, SLOT(onCarrierDownHandle()));
-
- //定时处理异常网络,即当点击Lan列表按钮时,若lstate=2,但任然有有线网连接的情况
- deleteLanTimer = new QTimer(this);
- deleteLanTimer->setTimerType(Qt::PreciseTimer);
- QObject::connect(deleteLanTimer, SIGNAL(timeout()), this, SLOT(onDeleteLan()));
-
- //定时获取网速
- setNetSpeed = new QTimer(this);
- setNetSpeed->setTimerType(Qt::PreciseTimer);
-//YYF QObject::connect(setNetSpeed, SIGNAL(timeout()), this, SLOT(on_setNetSpeed()));
- setNetSpeed->start(3000);
-}
-
-
-///////////////////////////////////////////////////////////////////////////////
-// 任务栏托盘管理、托盘图标处理
-
-void KylinNM::createTrayIcon()
-{
- trayIcon = new QSystemTrayIcon();
-
- trayIconMenu = new QMenu();
-
- mShowWindow = new QAction(tr("Show KylinNM"),this);
- mAdvConf = new QAction(tr("Advanced"),this);
- mAdvConf->setIcon(QIcon::fromTheme("document-page-setup", QIcon(":/res/x/setup.png")) );
-
- trayIconMenu->addAction(mShowWindow);
- //trayIconMenu->addSeparator();
- trayIconMenu->addAction(mAdvConf);
- //trayIconMenu->setAttribute(Qt::WA_TranslucentBackground);//设置窗口背景透明
- //trayIconMenu->setWindowOpacity(0.8);
- trayIcon->setContextMenu(trayIconMenu);
-
- // 初始化托盘所有Icon
- iconLanOnline = QIcon::fromTheme("network-wired-symbolic");
- iconLanOffline = QIcon::fromTheme("network-wired-offline-symbolic");
- iconWifiFull = QIcon::fromTheme("network-wireless-signal-excellent-symbolic");
- iconWifiHigh = QIcon::fromTheme("network-wireless-signal-good-symbolic");
- iconWifiMedium = QIcon::fromTheme("network-wireless-signal-ok");
- iconWifiLow = QIcon::fromTheme("network-wireless-signal-low");
-
- loadIcons.append(QIcon::fromTheme("kylin-network-1"));
- loadIcons.append(QIcon::fromTheme("kylin-network-2"));
- loadIcons.append(QIcon::fromTheme("kylin-network-3"));
- loadIcons.append(QIcon::fromTheme("kylin-network-4"));
- loadIcons.append(QIcon::fromTheme("kylin-network-5"));
- loadIcons.append(QIcon::fromTheme("kylin-network-6"));
- loadIcons.append(QIcon::fromTheme("kylin-network-7"));
- loadIcons.append(QIcon::fromTheme("kylin-network-8"));
- loadIcons.append(QIcon::fromTheme("kylin-network-9"));
- loadIcons.append(QIcon::fromTheme("kylin-network-10"));
- loadIcons.append(QIcon::fromTheme("kylin-network-11"));
- loadIcons.append(QIcon::fromTheme("kylin-network-12"));
-
- iconTimer = new QTimer(this);
- connect(iconTimer, SIGNAL(timeout()), this, SLOT(iconStep()));
-
- setTrayIcon(iconLanOnline);
-}
-
-void KylinNM::iconStep()
-{
- if (currentIconIndex < 0) {
- currentIconIndex = 11;
- }
- setTrayIcon(loadIcons.at(currentIconIndex));
- currentIconIndex --;
-}
-
-void KylinNM::setTrayIcon(QIcon icon)
-{
- trayIcon->setIcon(icon);
-}
-
-void KylinNM::setTrayLoading(bool isLoading)
-{
- if (isLoading) {
- currentIconIndex = 11;
- iconTimer->start(60);
- } else {
- iconTimer->stop();
- }
-}
-
-void KylinNM::updateNetList()
-{
- QString strTrans;
- strTrans = QString::number(1, 10, 2);
- //QString sty = "#centralWidget{background:rgba(19,19,20," + strTrans + ");}"; //YYF
- QString sty = "#centralWidget{background:rgba(255,255,255," + strTrans + ");}";
- ui->centralWidget->setStyleSheet(sty);
-
- this->showNormal();
- if (is_btnNetList_clicked == 1) {
- onBtnNetListClicked(0);
- }
- is_stop_check_net_state = 1;
- if (is_btnWifiList_clicked == 1) {
- BackThread loop_bt;
- IFace loop_iface = loop_bt.execGetIface();
-
- if (loop_iface.wstate != 2) {
- is_update_wifi_list = 1;
- this->ksnm->execGetWifiList(); //更新wifi列表
- }
- }
- is_stop_check_net_state = 0;
-}
-
-void KylinNM::updateWifiList()
-{
- //每次展示都要显示无线
- on_btnWifiList_clicked();
-}
-
-void KylinNM::iconActivated(QSystemTrayIcon::ActivationReason reason)
-{
- switch (reason) {
- case QSystemTrayIcon::Trigger:
- case QSystemTrayIcon::MiddleClick:
-
- handleIconClicked();
-
- if (this->isHidden()) {
- QString strTrans;
- strTrans = QString::number(1, 10, 2);
- //QString sty = "#centralWidget{background:rgba(19,19,20," + strTrans + ");}"; //YYF
- QString sty = "#centralWidget{background:rgba(255,255,255," + strTrans + ");}";
- ui->centralWidget->setStyleSheet(sty);
-
- this->showNormal();
- if (is_btnNetList_clicked == 1) {
- onBtnNetListClicked(0);
- }
- is_stop_check_net_state = 1;
- if (is_btnWifiList_clicked == 1) {
- BackThread loop_bt;
- IFace loop_iface = loop_bt.execGetIface();
-
- if (loop_iface.wstate != 2) {
- is_update_wifi_list = 1;
- this->ksnm->execGetWifiList(); //更新wifi列表
- }
- }
- is_stop_check_net_state = 0;
- } else {
- //this->hide();
- }
- break;
- case QSystemTrayIcon::DoubleClick:
- //this->hide();
- break;
- case QSystemTrayIcon::Context:
- //右键点击托盘图标弹出菜单
- showTrayIconMenu();
- break;
- default:
- break;
- }
-}
-
-void KylinNM::handleIconClicked()
-{
- tabletStyle();
- if(isTabletStyle)//平板桌面模式
- {
- //在屏幕中央显示
- QRect availableGeometry = qApp->primaryScreen()->availableGeometry();
- this->move((availableGeometry.width() - this->width())/2, (availableGeometry.height() - this->height())/2);
- return;
- }
-
- QRect availableGeometry = qApp->primaryScreen()->availableGeometry();
- QRect screenGeometry = qApp->primaryScreen()->geometry();
-
- QDesktopWidget* desktopWidget = QApplication::desktop();
- QRect deskMainRect = desktopWidget->availableGeometry(0);//获取可用桌面大小
- QRect screenMainRect = desktopWidget->screenGeometry(0);//获取设备屏幕大小
- QRect deskDupRect = desktopWidget->availableGeometry(1);//获取可用桌面大小
- QRect screenDupRect = desktopWidget->screenGeometry(1);//获取设备屏幕大小
-
- int n = objKyDBus->getTaskBarPos("position");
- int m = objKyDBus->getTaskBarHeight("height");
- int d = 2; //窗口边沿到任务栏距离
-
- if (screenGeometry.width() == availableGeometry.width() && screenGeometry.height() == availableGeometry.height()) {
- if (n == 0) {
- //任务栏在下侧
- this->move(availableGeometry.x() + availableGeometry.width() - this->width(), screenMainRect.y() + availableGeometry.height() - this->height() - m - d);
- } else if(n == 1) {
- //任务栏在上侧
- this->move(availableGeometry.x() + availableGeometry.width() - this->width(), screenMainRect.y() + screenGeometry.height() - availableGeometry.height() + m + d);
- } else if (n == 2) {
- //任务栏在左侧
- if (screenGeometry.x() == 0) {//主屏在左侧
- this->move(m + d, screenMainRect.y() + screenMainRect.height() - this->height());
- } else {//主屏在右侧
- this->move(screenMainRect.x() + m + d, screenMainRect.y() + screenMainRect.height() - this->height());
- }
- } else if (n == 3) {
- //任务栏在右侧
- if (screenGeometry.x() == 0) {//主屏在左侧
- this->move(screenMainRect.width() - this->width() - m - d, screenMainRect.y() + screenMainRect.height() - this->height());
- } else {//主屏在右侧
- this->move(screenMainRect.x() + screenMainRect.width() - this->width() - m - d, screenMainRect.y() + screenMainRect.height() - this->height());
- }
- }
- } else if(screenGeometry.width() == availableGeometry.width() ) {
- if (trayIcon->geometry().y() > availableGeometry.height()/2) {
- //任务栏在下侧
- this->move(availableGeometry.x() + availableGeometry.width() - this->width(), screenMainRect.y() + availableGeometry.height() - this->height() - d);
- } else {
- //任务栏在上侧
- this->move(availableGeometry.x() + availableGeometry.width() - this->width(), screenMainRect.y() + screenGeometry.height() - availableGeometry.height() + d);
- }
- } else if (screenGeometry.height() == availableGeometry.height()) {
- if (trayIcon->geometry().x() > availableGeometry.width()/2) {
- //任务栏在右侧
- this->move(availableGeometry.x() + availableGeometry.width() - this->width() - d, screenMainRect.y() + screenGeometry.height() - this->height());
- } else {
- //任务栏在左侧
- this->move(screenGeometry.width() - availableGeometry.width() + d, screenMainRect.y() + screenGeometry.height() - this->height());
- }
- }
-}
-
-void KylinNM::showTrayIconMenu()
-{
- QRect availableGeometry = qApp->primaryScreen()->availableGeometry();
- QRect screenGeometry = qApp->primaryScreen()->geometry();
-
- QDesktopWidget* desktopWidget = QApplication::desktop();
- // QRect deskMainRect = desktopWidget->availableGeometry(0);//获取可用桌面大小
- QRect screenMainRect = desktopWidget->screenGeometry(0);//获取设备屏幕大小
- // QRect deskDupRect = desktopWidget->availableGeometry(1);//获取可用桌面大小
- QRect screenDupRect = desktopWidget->screenGeometry(1);//获取设备屏幕大小
-
- QPoint cursorPoint = QCursor::pos();//返回相对显示器的全局坐标
- int cursor_x = cursorPoint.x();
- int cursor_y = cursorPoint.y();
-
- int n = objKyDBus->getTaskBarPos("position");
- int m = objKyDBus->getTaskBarHeight("height");
- int d = 0; //窗口边沿到任务栏距离
- int s = 80; //窗口边沿到屏幕边沿距离
-
- if (screenGeometry.width() == availableGeometry.width() && screenGeometry.height() == availableGeometry.height()) {
- if (n == 0) { //任务栏在下侧
- trayIconMenu->move(availableGeometry.x() + cursor_x - trayIconMenu->width()/2, screenMainRect.y() + availableGeometry.height() - trayIconMenu->height() - m - d);
- } else if(n == 1) { //任务栏在上侧
- trayIconMenu->move(availableGeometry.x() + cursor_x - trayIconMenu->width()/2, screenMainRect.y() + screenGeometry.height() - availableGeometry.height() + m + d);
- } else if (n == 2) { //任务栏在左侧
- trayIconMenu->move(m + d, cursor_y - trayIconMenu->height()/2);
- //if (screenGeometry.x() == 0){//主屏在左侧
- // trayIconMenu->move(screenGeometry.width() - availableGeometry.width() + m + d, screenMainRect.y() + screenMainRect.height() - trayIconMenu->height() - s);
- //}else{//主屏在右侧
- // trayIconMenu->move(screenGeometry.width() - availableGeometry.width() + m + d,screenDupRect.y() + screenDupRect.height() - trayIconMenu->height() - s);
- //}
- } else if (n == 3) { //任务栏在右侧
- trayIconMenu->move(screenMainRect.width() - trayIconMenu->width() - m - d, cursor_y - trayIconMenu->height()/2);
- //if (screenGeometry.x() == 0){//主屏在左侧
- // trayIconMenu->move(screenMainRect.width() + screenDupRect.width() - trayIconMenu->width() - m - d, screenDupRect.y() + screenDupRect.height() - trayIconMenu->height() - s);
- //}else{//主屏在右侧
- // trayIconMenu->move(availableGeometry.x() + availableGeometry.width() - trayIconMenu->width() - m - d, screenMainRect.y() + screenMainRect.height() - trayIconMenu->height() - s);
- //}
- }
- } else if(screenGeometry.width() == availableGeometry.width() ) {
- if (trayIcon->geometry().y() > availableGeometry.height()/2) { //任务栏在下侧
- trayIconMenu->move(availableGeometry.x() + cursor_x - trayIconMenu->width()/2, screenMainRect.y() + availableGeometry.height() - trayIconMenu->height() - d);
- } else { //任务栏在上侧
- trayIconMenu->move(availableGeometry.x() + cursor_x - trayIconMenu->width()/2, screenMainRect.y() + screenGeometry.height() - availableGeometry.height() + d);
- }
- } else if (screenGeometry.height() == availableGeometry.height()) {
- if (trayIcon->geometry().x() > availableGeometry.width()/2) { //任务栏在右侧
- trayIconMenu->move(availableGeometry.x() + availableGeometry.width() - trayIconMenu->width() - d, cursor_y - trayIconMenu->height()/2);
- } else { //任务栏在左侧
- trayIconMenu->move(screenGeometry.width() - availableGeometry.width() + d, cursor_y - trayIconMenu->height()/2);
- }
- }
-}
-
-void KylinNM::on_showWindowAction()
-{
- handleIconClicked();
- this->showNormal();
-}
-
-
-///////////////////////////////////////////////////////////////////////////////
-//加载动画,获取当前连接的网络和状态并设置图标
-
-void KylinNM::startLoading()
-{
-// loading->startLoading();
- setTrayLoading(true);
-}
-
-void KylinNM::stopLoading()
-{
- loading->stopLoading();
- setTrayLoading(false);
- getActiveInfo();
-}
-
-void KylinNM::on_checkOverTime()
-{
- QString cmd = "kill -9 $(pidof nmcli)"; //杀掉当前正在进行的有关nmcli命令的进程
- int status = system(cmd.toUtf8().data());
- if (status != 0) {
- qDebug()<<"execute 'kill -9 $(pidof nmcli)' in function 'on_checkOverTime' failed";
- syslog(LOG_ERR, "execute 'kill -9 $(pidof nmcli)' in function 'on_checkOverTime' failed");
- }
- this->stopLoading(); //超时停止等待动画
- is_stop_check_net_state = 0;
-}
-
-void KylinNM::getActiveInfo()
-{
- QString actLanName = "--";
- QString actWifiName = "--";
-
- activecon *act = NULL;
- int count = 0;
- kylin_network_get_activecon_info(&act, &count);
- if(!act)
- return ;
- int index = 0;
- while (act && index < count) {
- if (QString(act[index].type) == "ethernet" || QString(act[index].type) == "802-3-ethernet") {
- actLanName = QString(act[index].con_name);
- }
- if (QString(act[index].type) == "wifi" || QString(act[index].type) == "802-11-wireless") {
- actWifiName = QString(act[index].con_name);
- }
- index ++;
- }
- if (act) {
- free(act);
- }
-
- //ukui3.0中获取currentActWifiSignalLv的值
- if (activeWifiSignalLv > 75) {
- currentActWifiSignalLv = 1;
- } else if(activeWifiSignalLv > 55 && activeWifiSignalLv <= 75) {
- currentActWifiSignalLv = 2;
- } else if(activeWifiSignalLv > 35 && activeWifiSignalLv <= 55) {
- currentActWifiSignalLv = 3;
- } else if( activeWifiSignalLv <= 35) {
- currentActWifiSignalLv = 4;
- }
-
- // 设置图标
- if (actLanName != "--") {
- setTrayIcon(iconLanOnline);
- } else if (actWifiName != "--") {
- switch (currentActWifiSignalLv) {
- case 1:
- setTrayIcon(iconWifiFull);
- break;
- case 2:
- setTrayIcon(iconWifiHigh);
- break;
- case 3:
- setTrayIcon(iconWifiMedium);
- break;
- case 4:
- setTrayIcon(iconWifiLow);
- break;
- default:
- setTrayIcon(iconWifiFull);
- break;
- }
- } else {
- setTrayIcon(iconLanOffline);
- }
-}
-
-
-///////////////////////////////////////////////////////////////////////////////
-//网络设备管理
-
-//网线插拔处理,由kylin-dbus-interface.cpp调用
-void KylinNM::onPhysicalCarrierChanged(bool flag)
-{
- this->startLoading();
- if (flag) {
- is_stop_check_net_state = 1;
- qDebug()<<"插入了有线网的网线";
- syslog(LOG_DEBUG,"wired physical cable is already plug in");
- wiredCableUpTimer->start(2000);
- } else {
- qDebug()<<"拔出了有线网的网线";
- syslog(LOG_DEBUG,"wired physical cable is already plug out");
-
- BackThread bt;
- IFace iface = bt.execGetIface();
- if (iface.lstate != 0) {
- is_stop_check_net_state = 1;
- wiredCableDownTimer->start(2000);
- }
- }
-}
-
-void KylinNM::onCarrierUpHandle()
-{
- wiredCableUpTimer->stop();
- //BackThread *up_bt = new BackThread();
- //up_bt->disConnLanOrWifi("ethernet");
- //sleep(1);
- //up_bt->disConnLanOrWifi("ethernet");
- //sleep(1);
- //up_bt->disConnLanOrWifi("ethernet");
- //up_bt->deleteLater();
-
- this->stopLoading();
- onBtnNetListClicked(1);
- is_stop_check_net_state = 0;
-}
-
-void KylinNM::onCarrierDownHandle()
-{
- wiredCableDownTimer->stop();
- this->stopLoading();
- onBtnNetListClicked(0);
- is_stop_check_net_state = 0;
-}
-
-void KylinNM::onDeleteLan()
-{
- deleteLanTimer->stop();
- BackThread btn_bt;
- btn_bt.disConnLanOrWifi("ethernet");
- sleep(1);
- btn_bt.disConnLanOrWifi("ethernet");
- sleep(1);
- btn_bt.disConnLanOrWifi("ethernet");
-
- this->stopLoading();
- onBtnNetListClicked(0);
- is_stop_check_net_state = 0;
-}
-
-//无线网卡插拔处理
-void KylinNM::onNetworkDeviceAdded(QDBusObjectPath objPath)
-{
- //仅处理无线网卡插入情况
- objKyDBus->isWirelessCardOn = false;
- objKyDBus->getObjectPath();
-
- if (objKyDBus->wirelessPath.path() == objPath.path()) { //证明添加的是无线网卡
- is_wireless_adapter_ready = 0;
- if (objKyDBus->isWirelessCardOn) {
- syslog(LOG_DEBUG,"wireless device is already plug in");
- qDebug()<<"wireless device is already plug in";
- is_wireless_adapter_ready = 1;
- onBtnWifiClicked(4);
- }
- }
-}
-
-void KylinNM::onNetworkDeviceRemoved(QDBusObjectPath objPath)
-{
- //仅处理无线网卡拔出情况
- if (objKyDBus->wirelessPath.path() == objPath.path()) {
- objKyDBus->isWirelessCardOn = false;
- objKyDBus->getObjectPath(); //检查是不是还有无线网卡
- if (!objKyDBus->isWirelessCardOn) {
- syslog(LOG_DEBUG,"wireless device is already plug out");
- qDebug()<<"wireless device is already plug out";
- is_wireless_adapter_ready = 0;
- onBtnWifiClicked(5);
- } else {
- syslog(LOG_DEBUG,"wireless device is already plug out, but one more wireless exist");
- qDebug()<<"wireless device is already plug out, but one more wireless exist";
- }
- }
-}
-
-void KylinNM::checkIsWirelessDeviceOn()
-{
- //启动时判断是否有无线网卡
- //KylinDBus kDBus3;
- if (objKyDBus->isWirelessCardOn) {
- is_wireless_adapter_ready = 1;
- } else {
- is_wireless_adapter_ready = 0;
- }
-}
-
-void KylinNM::getLanBandWidth()
-{
- BackThread bt;
- IFace iface = bt.execGetIface();
-
- lname = iface.lname;
-
- mwBandWidth = bt.execChkLanWidth(lname);
-}
-
-//检测网络设备状态
-bool KylinNM::checkLanOn()
-{
- BackThread bt;
- IFace iface = bt.execGetIface();
-
- if (iface.lstate == 2) {
- return false;
- } else {
- return true;
- }
-}
-
-bool KylinNM::checkWlOn()
-{
- BackThread bt;
- IFace iface = bt.execGetIface();
-
- bool ret = true;
- if (iface.wstate == 2) {
- ret = false;
- }
- return ret;
-}
-
-
-///////////////////////////////////////////////////////////////////////////////
-//有线网与无线网按钮响应
-
-void KylinNM::on_btnNet_clicked()
-{
- if (checkLanOn()) {
- QThread *t = new QThread();
- BackThread *bt = new BackThread();
- bt->moveToThread(t);
- connect(t, SIGNAL(finished()), t, SLOT(deleteLater()));
- connect(t, SIGNAL(started()), bt, SLOT(execDisNet()));
- connect(bt, SIGNAL(disNetDone()), this, SLOT(disNetDone()));
- connect(bt, SIGNAL(btFinish()), t, SLOT(quit()));
- t->start();
-
- } else {
- is_stop_check_net_state = 1;
- QThread *t = new QThread();
- BackThread *bt = new BackThread();
- bt->moveToThread(t);
- connect(t, SIGNAL(finished()), t, SLOT(deleteLater()));
- connect(t, SIGNAL(started()), bt, SLOT(execEnNet()));
- connect(bt, SIGNAL(enNetDone()), this, SLOT(enNetDone()));
- connect(bt, SIGNAL(btFinish()), t, SLOT(quit()));
- t->start();
- }
-
- this->startLoading();
-}
-
-void KylinNM::onBtnWifiClicked(int flag)
-{
- qDebug()<<"Value of flag passed into function 'onBtnWifiClicked' is: "<setWifiSwitchState(false);
- lbTopWifiList->hide();
-// btnAddNet->hide();
-
- QThread *t = new QThread();
- BackThread *bt = new BackThread();
- bt->moveToThread(t);
- btnWireless->setSwitchStatus(true);
- connect(t, SIGNAL(finished()), t, SLOT(deleteLater()));
- connect(t, SIGNAL(started()), bt, SLOT(execDisWifi()));
- connect(bt, SIGNAL(disWifiDone()), this, SLOT(disWifiDone()));
- connect(bt, SIGNAL(btFinish()), t, SLOT(quit()));
-
- /**锁屏多线程信号槽消息传递异常,暂时以定时器方式检测,需调整pam验证的fork方式
- */
- QTimer *timer = new QTimer(this);
- connect(timer, &QTimer::timeout, this, [=]{
- if(m_is_reflashWifiUi) {
- disWifiDone();
- mutexIsReflashWifi.lock();
- m_is_reflashWifiUi = false;
- mutexIsReflashWifi.unlock();
- timer->stop();
- }
- });
- timer->start(200);
- QTimer::singleShot(8*1000, this, [=]{
- if(timer->isActive())
- timer->stop();
- });
- /**锁屏多线程信号槽消息传递异常,暂时以定时器方式检测,需调整pam验证的fork方式
- */
- t->start();
- this->startLoading();
- }
- } else {
- if (is_fly_mode_on == 0) {
- //on_btnWifiList_clicked();
- is_stop_check_net_state = 1;
- qDebug() << "aaa222";
- objKyDBus->setWifiCardState(true);
- objKyDBus->setWifiSwitchState(true);
- //lbTopWifiList->show();
- //btnAddNet->show();
-
- QThread *t = new QThread();
- BackThread *bt = new BackThread();
- bt->moveToThread(t);
- btnWireless->setSwitchStatus(true);
- connect(t, SIGNAL(finished()), t, SLOT(deleteLater()));
- connect(t, SIGNAL(started()), bt, SLOT(execEnWifi()));
- connect(bt, SIGNAL(enWifiDone()), this, SLOT(enWifiDone()));
- connect(bt, SIGNAL(launchLanDone()), this, SLOT(launchLanDone()));
- connect(bt, SIGNAL(btFinish()), t, SLOT(quit()));
-
- /**锁屏多线程信号槽消息传递异常,暂时以定时器方式检测,需调整pam验证的fork方式
- */
- QTimer *timer = new QTimer(this);
- connect(timer, &QTimer::timeout, this, [=]{
- if(m_is_reflashWifiUi) {
- enWifiDone();
- mutexIsReflashWifi.lock();
- m_is_reflashWifiUi = false;
- mutexIsReflashWifi.unlock();
- timer->stop();
- }
- });
- timer->start(200);
- QTimer::singleShot(8*1000, this, [=]{
- if(timer->isActive())
- timer->stop();
- });
- t->start();
- this->startLoading();
- }
- }
- } else if(flag == 2) {
- if (is_fly_mode_on == 0) {
- //on_btnWifiList_clicked();
- is_stop_check_net_state = 1;
- lbTopWifiList->show();
-// btnAddNet->show();
-
- QThread *t = new QThread();
- BackThread *bt = new BackThread();
- btnWireless->setSwitchStatus(true);
- bt->moveToThread(t);
- connect(t, SIGNAL(finished()), t, SLOT(deleteLater()));
- connect(t, SIGNAL(started()), bt, SLOT(execEnWifi()));
- connect(bt, SIGNAL(enWifiDone()), this, SLOT(enWifiDone()));
- connect(bt, SIGNAL(launchLanDone()), this, SLOT(launchLanDone()));
- connect(bt, SIGNAL(btFinish()), t, SLOT(quit()));
- t->start();
- this->startLoading();
- }
- } else if(flag == 3) {
- is_stop_check_net_state = 1;
- lbTopWifiList->hide();
-// btnAddNet->hide();
-
- QThread *t = new QThread();
- BackThread *bt = new BackThread();
- btnWireless->setSwitchStatus(true);
- bt->moveToThread(t);
- connect(t, SIGNAL(finished()), t, SLOT(deleteLater()));
- connect(t, SIGNAL(started()), bt, SLOT(execDisWifi()));
- connect(bt, SIGNAL(disWifiDone()), this, SLOT(disWifiDone()));
- connect(bt, SIGNAL(btFinish()), t, SLOT(quit()));
- t->start();
- this->startLoading();
- } else {
- qDebug()<<"receive an invalid value in function onBtnWifiClicked";
- syslog(LOG_DEBUG, "receive an invalid value in function onBtnWifiClicked");
- }
-
- } else {
- lbTopWifiList->hide();
-// btnAddNet->hide();
-
- if (flag == 0) {
- objKyDBus->setWifiSwitchState(false);
- objKyDBus->setWifiCardState(false);
- }
-
- QString txt(tr("No wireless card detected")); //未检测到无线网卡
- objKyDBus->showDesktopNotify(txt);
- qDebug()<<"No wireless card detected";
- syslog(LOG_DEBUG, "No wireless card detected");
- //QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "' -t 3800";
- //int status = system(cmd.toUtf8().data());
- //if (status != 0){ syslog(LOG_ERR, "execute 'notify-send' in function 'onBtnWifiClicked' failed");}
-
- disWifiStateKeep();
- }
-
-}
-
-void KylinNM::onBtnNetListClicked(int flag)
-{
- this->is_btnNetList_clicked = 1;
- this->is_btnWifiList_clicked = 0;
-
- ui->lbNetListBG->setStyleSheet(btnOnQss);
- ui->lbWifiListBG->setStyleSheet(btnOffQss);
-
- BackThread bt;
- IFace iface = bt.execGetIface();
-
- lbLoadDown->show();
- lbLoadUp->show();
- lbLoadDownImg->show();
- lbLoadUpImg->show();
- if (iface.lstate != 0) {
- lbLoadDown->hide();
- lbLoadUp->hide();
- lbLoadDownImg->hide();
- lbLoadUpImg->hide();
- }
-
- lbNoItemTip->hide();
-
- ui->lbNetwork->setText(tr("Activated LAN"));
- btnWireless->hide();
- //ui->lbBtnWifiBG->hide();
- //ui->lbBtnWifiBall->hide();
-
- // 强行设置为打开
- if (flag == 1) {
- this->startLoading();
- this->ksnm->execGetLanList();
- this->scrollAreal->show();
- this->topLanListWidget->show();
- this->scrollAreaw->hide();
- this->topWifiListWidget->hide();
- on_btnNetList_pressed();
- return;
- }
-
- if (iface.lstate != 2) {
- this->startLoading();
- this->ksnm->execGetLanList();
- } else {
- this->startLoading();
- this->ksnm->execGetLanList();
- }
-
-// btnCreateNet->show();
-// btnAddNet->hide();
- this->scrollAreal->show();
- this->topLanListWidget->show();
- this->scrollAreaw->hide();
- this->topWifiListWidget->hide();
- on_btnNetList_pressed();
- //YYF
- ui->lbNetListImg->setStyleSheet("QLabel{border-image:url(:/res/l/pb-network-online.png);background-position:center;background-repeat:no-repeat;}");
- 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;}");
-}
-
-// 当点击wifi标题的时候执行
-void KylinNM::on_btnWifiList_clicked()
-{
- this->is_btnWifiList_clicked = 1;
- this->is_btnNetList_clicked = 0;
-
- BackThread bt;
- IFace iface = bt.execGetIface();
-
- lbLoadDown->show();
- lbLoadUp->show();
- lbLoadDownImg->show();
- lbLoadUpImg->show();
- if (iface.wstate != 0) {
- lbLoadDown->hide();
- lbLoadUp->hide();
- lbLoadDownImg->hide();
- lbLoadUpImg->hide();
- }
-
- ui->lbNetListBG->setStyleSheet(btnOffQss);
- ui->lbWifiListBG->setStyleSheet(btnOnQss);
-
- lbNoItemTip->hide();
- ui->lbNetwork->setText(tr("Activated WLAN"));
- btnWireless->show();
- //ui->lbBtnWifiBG->show();
- //ui->lbBtnWifiBall->show();
- 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);
- } else {
- //ui->lbBtnWifiBG->setStyleSheet(btnBgOffQss);
- //ui->lbBtnWifiBall->move(X_LEFT_WIFI_BALL, Y_WIFI_BALL);
- btnWireless->setSwitchStatus(false);
- }
-
- if (iface.wstate != 2) {
- //ui->lbBtnWifiBG->setStyleSheet(btnBgOnQss);
- //ui->lbBtnWifiBall->move(X_RIGHT_WIFI_BALL, Y_WIFI_BALL);
- btnWireless->setSwitchStatus(true);
- lbTopWifiList->show();
-// btnAddNet->show();
-
- this->startLoading();
- this->ksnm->execGetWifiList();
- } else {
- //ui->lbBtnWifiBG->setStyleSheet(btnBgOffQss);
- //ui->lbBtnWifiBall->move(X_LEFT_WIFI_BALL, Y_WIFI_BALL);
- btnWireless->setSwitchStatus(false);
- delete topWifiListWidget; //清空top列表
- createTopWifiUI(); //创建顶部无线网item
- lbTopWifiList->hide();
- ui->lbNetListImg->setStyleSheet("QLabel{border-image:url(:/res/l/pb-network-offline.png);background-position:center;background-repeat:no-repeat;}");
- ui->lbWifiListImg->setStyleSheet("QLabel{border-image:url(:/res/x/pb-wifi-y.png);background-position:center;background-repeat:no-repeat;}");
- lbNetListText->setStyleSheet("QLabel{color:rgba(38, 38, 38, 0.75);background-color:transparent;}");
- lbWifiListText->setStyleSheet("QLabel{color:rgba(47, 179, 232, 1);background-color:transparent;}");
-
- // 清空wifi列表
- wifiListWidget = new QWidget(scrollAreaw);
- wifiListWidget->resize(W_LIST_WIDGET+173*isTabletStyle, H_WIFI_ITEM_BIG_EXTEND);
- scrollAreaw->setWidget(wifiListWidget);
- scrollAreaw->move(W_LEFT_AREA, Y_SCROLL_AREA);
-
-
- // 当前连接的wifi
- OneConnForm *ccf = new OneConnForm(topWifiListWidget, this, confForm, ksnm);
- ccf->setName(tr("Not connected"));//"当前未连接任何 Wifi"
- ccf->setSignal("0", "--");
- ccf->setRate("0");
- ccf->setConnedString(1, tr("Disconnected"), "");//"未连接"
- ccf->isConnected = false;
- ccf->setTopItem(false);
- ccf->setAct(true);
- ccf->move(L_VERTICAL_LINE_TO_ITEM, 0);
- ccf->show();
-
- this->lanListWidget->hide();
- this->wifiListWidget->show();
-
- getActiveInfo();
- is_stop_check_net_state = 0;
- }
-
-// btnCreateNet->hide();
-// if(is_wireless_adapter_ready == 1)
-// {
-// btnAddNet->show();
-// }
-
- this->scrollAreal->hide();
- this->topLanListWidget->hide();
- this->scrollAreaw->show();
- this->topWifiListWidget->show();
- on_btnWifiList_pressed();
-}
-
-void KylinNM::on_btnNetList_pressed()
-{
- //ui->btnNetList->setStyleSheet("#btnNetList{font-size:12px;color:white;border:1px solid rgba(255,255,255,0.1);border:1px solid rgba(255,255,255,0.5);background:transparent;background-color:rgba(255,255,255,0.1);}");
- //ui->btnWifiList->setStyleSheet("#btnWifiList{font-size:12px;color:white;border:1px solid rgba(255,255,255,0.1);background:transparent;background-color:rgba(0,0,0,0.2);}"
- // "#btnWifiList:Pressed{border:1px solid rgba(255,255,255,0.5);background:transparent;background-color:rgba(255,255,255,0.1);}");
-}
-
-void KylinNM::on_btnWifiList_pressed()
-{
- //YYF 复制自tabletStyle方法,后期考虑合并
- ui->btnNetList->setStyleSheet(btnOffQss);
- ui->btnWifiList->setStyleSheet(btnOnQss);
- ui->lbNetListBG->setStyleSheet(btnOffQss);
- ui->lbWifiListBG->setStyleSheet(btnOnQss);
- ui->lbNetListImg->setStyleSheet("QLabel{border-image:url(:/res/l/pb-network-offline.png);background-position:center;background-repeat:no-repeat;}");
- ui->lbWifiListImg->setStyleSheet("QLabel{border-image:url(:/res/x/pb-wifi-y.png);background-position:center;background-repeat:no-repeat;}");
- lbNetListText->setStyleSheet("QLabel{color:rgba(38, 38, 38, 0.75);background-color:transparent;}");
- lbWifiListText->setStyleSheet("QLabel{color:rgba(47, 179, 232, 1);background-color:transparent;}");
-
- //ui->btnWifiList->setStyleSheet("#btnWifiList{font-size:12px;color:white;border:1px solid rgba(255,255,255,0.1);border:1px solid rgba(255,255,255,0.5);background:transparent;background-color:rgba(255,255,255,0.1);}");
- //ui->btnNetList->setStyleSheet("#btnNetList{font-size:12px;color:white;border:1px solid rgba(255,255,255,0.1);background:transparent;background-color:rgba(0,0,0,0.2);}"
- // "#btnNetList:Pressed{border:1px solid rgba(255,255,255,0.5);background:transparent;background-color:rgba(255,255,255,0.1);}");
-}
-
-
-///////////////////////////////////////////////////////////////////////////////
-//网络列表加载与更新
-
-// 获取lan列表回调
-void KylinNM::getLanListDone(QStringList slist)
-{
- if (this->ksnm->isUseOldLanSlist) {
- slist = oldLanSlist;
- this->ksnm->isUseOldLanSlist = false;
- }
-
- delete topLanListWidget; // 清空top列表
-
- createTopLanUI(); //创建顶部有线网item
-
- // 清空lan列表
- lanListWidget = new QWidget(scrollAreal);
- lanListWidget->resize(W_LIST_WIDGET, H_NORMAL_ITEM + H_LAN_ITEM_EXTEND);
- scrollAreal->setWidget(lanListWidget);
- scrollAreal->move(W_LEFT_AREA, Y_SCROLL_AREA);
- lanNameList.clear();
-
- // 获取当前连接的lan name
- QString actLanName = "--";
- activecon *act = NULL;
- int count = 0;
- kylin_network_get_activecon_info(&act, &count);
- int index = 0;
- while (act && index < count) {
- 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);
- topLanListWidget->resize(W_TOP_LIST_WIDGET+173*isTabletStyle, H_NORMAL_ITEM + H_GAP_UP + X_ITEM);
- ccf->setFixedWidth(414+194*isTabletStyle);
- if (actLanName == "--") {
- ccf->setName(tr("Not connected"), "");//"当前未连接任何 以太网"
- ccf->setIcon(false);
- ccf->setConnedString(1, tr("Disconnected"));//"未连接"
- ccf->isConnected = false;
- ifLanConnected = false;
- lbLoadDown->hide();
- lbLoadUp->hide();
- lbLoadDownImg->hide();
- lbLoadUpImg->hide();
- ccf->setTopItem(false);
- ccf->setAct(false);
- }
- else
- ccf->setAct(true);
- ccf->move(L_VERTICAL_LINE_TO_ITEM, 0);
- ccf->show();
- // 填充可用网络列表
- QString headLine;
- if(slist.count() > 0)
- headLine = slist.at(0);
- else
- headLine = "";
- int indexDevice, indexName;
- headLine = headLine.trimmed();
-
- bool isChineseExist = headLine.contains(QRegExp("[\\x4e00-\\x9fa5]+"));
- if (isChineseExist) {
- indexDevice = headLine.indexOf("设备") + 2;
- indexName = headLine.indexOf("名称") + 4;
- } else {
- indexDevice = headLine.indexOf("DEVICE");
- indexName = headLine.indexOf("NAME");
- }
-
- QString order = "a"; //为避免同名情况,这里给每一个有线网设定一个唯一标志
- for(int i = 1, j = 0; i < slist.size(); i ++) {
- QString line = slist.at(i);
- QString ltype = line.mid(0, indexDevice).trimmed();
- QString nname = line.mid(indexName).trimmed();
-
- if (ltype != "802-11-wireless" && ltype != "wifi" && ltype != "" && ltype != "--") {
- lanNameList.append(nname);
- // 当前连接的lan
- if (nname == actLanName) {
- //objKyDBus->getConnectNetIp();
- actLanName = "--";
- if (mwBandWidth == "Unknown!") { getLanBandWidth(); }
-
- connect(ccf, SIGNAL(selectedOneLanForm(QString, QString)), this, SLOT(oneTopLanFormSelected(QString, QString)));
- connect(ccf, SIGNAL(disconnActiveLan()), this, SLOT(activeLanDisconn()));
- ccf->setName(nname, nname + order);
- ccf->setIcon(true);
- ccf->setLanInfo(objKyDBus->dbusActiveLanIpv4, objKyDBus->dbusActiveLanIpv6, mwBandWidth, objKyDBus->dbusLanMac);
- ccf->setConnedString(1, tr("NetOn,"));//"已连接"
- ccf->isConnected = true;
- ifLanConnected = true;
- lbLoadDown->show();
- lbLoadUp->show();
- lbLoadDownImg->show();
- lbLoadUpImg->show();
- ccf->setTopItem(false);
- currSelNetName = "";
- objKyDBus->dbusActiveLanIpv4 = "";
- objKyDBus->dbusActiveLanIpv6 = "";
- syslog(LOG_DEBUG, "already insert an active lannet in the top of lan list");
- } else {
- objKyDBus->getLanIp(nname);
- OneLancForm *ocf = new OneLancForm(lanListWidget, this, confForm, ksnm);
-// connect(ocf, SIGNAL(selectedOneLanForm(QString, QString)), this, SLOT(oneLanFormSelected(QString, QString)));
- ocf->setName(nname, nname + order);
- ocf->setIcon(false); //YYF
- ocf->setLine(true);
- ocf->setLanInfo(objKyDBus->dbusLanIpv4, objKyDBus->dbusLanIpv6, tr("Disconnected"), objKyDBus->dbusLanMac);
- ocf->setConnedString(0, tr("Disconnected"));//"未连接"
- ocf->move(L_VERTICAL_LINE_TO_ITEM, j * H_NORMAL_ITEM);
- lanListWidget->resize(W_LIST_WIDGET+194*isTabletStyle, lanListWidget->height() + H_NORMAL_ITEM);
- ocf->setFixedWidth(W_LIST_WIDGET+194*isTabletStyle); //YYF
- ocf->setSelected(false, false);
- ocf->show();
- j ++;
- }
- order += "a";
- }
- }
-
- QList itemList = lanListWidget->findChildren();
- int n = itemList.size();
- if (n >= 1) {
- OneLancForm *lastItem = itemList.at(n-1);
- lastItem->setLine(false);
- lbNoItemTip->hide();
- } else {
- if (!ifLanConnected) {
- lbNoItemTip->hide();
-// lbTopLanList->hide();
-// btnCreateNet->hide();
- } else {
- lbNoItemTip->show();
- lbNoItemTip->setText(tr("No Other Wired Network Scheme"));
- }
- }
-
- this->lanListWidget->show();
- this->topLanListWidget->show();
- this->wifiListWidget->hide();
- this->topWifiListWidget->hide();
-
- this->stopLoading();
- oldLanSlist = slist;
- is_stop_check_net_state = 0;
-}
-
-// 获取wifi列表回调
-void KylinNM::getWifiListDone(QStringList slist)
-{
- qDebug()<<"debug: oldWifiSlist.size()="<resize(W_LIST_WIDGET+173*isTabletStyle, H_WIFI_ITEM_BIG_EXTEND);
- scrollAreaw->setWidget(wifiListWidget);
- scrollAreaw->move(W_LEFT_AREA, Y_SCROLL_AREA);
-
- QList currConnWifiBSsidUuid;
- currConnWifiBSsidUuid = objKyDBus->getAtiveWifiBSsidUuid(slist);
- // 获取当前连接的wifi name
- QString actWifiName = "--";
- QString actWifiId = "--";
- actWifissid = "--";
- actWifiuuid = "--";
- if (currConnWifiBSsidUuid.size() > 1) {
- actWifiuuid = currConnWifiBSsidUuid.at(0);
- for (int i=1; isetName(tr("Not connected"));//"当前未连接任何 Wifi"
- ccf->setSignal("0", "--");
- activeWifiSignalLv = 0;
- ccf->setConnedString(1, tr("Disconnected"), "");//"未连接"
- ccf->isConnected = false;
- ifWLanConnected = false;
- lbLoadDown->hide();
- lbLoadUp->hide();
- lbLoadDownImg->hide();
- lbLoadUpImg->hide();
- ccf->setTopItem(false);
- }
- ccf->setAct(true);
- ccf->move(L_VERTICAL_LINE_TO_ITEM, 0);
- ccf->show();
- // 填充可用网络列表
- QString headLine = slist.at(0);
- int indexSignal,indexSecu, indexFreq, indexBSsid, indexName, indexPath;
- headLine = headLine.trimmed();
-
- bool isChineseExist = headLine.contains(QRegExp("[\\x4e00-\\x9fa5]+"));
- if (isChineseExist) {
- indexSignal = headLine.indexOf("SIGNAL");
- indexSecu = headLine.indexOf("安全性");
- indexFreq = headLine.indexOf("频率") + 4;
- indexBSsid = headLine.indexOf("BSSID") + 6;
- indexName = indexBSsid + 19;
- indexPath = headLine.indexOf("DBUS-PATH");
- } else {
- indexSignal = headLine.indexOf("SIGNAL");
- indexSecu = headLine.indexOf("SECURITY");
- indexFreq = headLine.indexOf("FREQ");
- indexBSsid = headLine.indexOf("BSSID");
- indexName = indexBSsid + 19;
- indexPath = headLine.indexOf("DBUS-PATH");
- }
- QStringList wnames;
- int count = 0;
- QString actWifiBssid = " ";
- for (int i = 1; i < slist.size(); i ++) {
- QString line = slist.at(i);
- QString wbssid = line.mid(indexBSsid, 17).trimmed();
- QString wname = line.mid(indexName, indexPath - indexName).trimmed();
-
- if (actWifiBssidList.contains(wbssid)) {
- actWifiName = wname;
- }
- if ("*" == line.mid(0,indexSignal).trimmed()){
- actWifiBssid = wbssid;
- }
- }
-
- if (actWifiBssidList.size()==1 && actWifiBssidList.at(0)=="--") {
- actWifiId = actWifiName;
- actWifiName = "--";
- }
- for (int i = 1, j = 0; i < slist.size(); i ++) {
- QString line = slist.at(i);
- //QString wsignal = line.mid(0, indexRate).trimmed();
- //QString wrate = line.mid(indexRate, indexSecu - indexRate).trimmed();
- QString wsignal = line.mid(indexSignal, 3).trimmed();
- QString wsecu = line.mid(indexSecu, indexFreq - indexSecu).trimmed();
- QString wbssid = line.mid(indexBSsid, 17).trimmed();
- QString wname = line.mid(indexName, indexPath - indexName).trimmed();
-
- bool isContinue = false;
- foreach (QString addName, wnames) {
- // 重复的网络名称,跳过不处理
- if(addName == wname){ isContinue = true; }
- }
- if(isContinue){ continue; }
-
- if (actWifiName != "--" && actWifiName == wname) {
- if (!actWifiBssidList.contains(wbssid)) {
- continue; //若当前热点ssid名称和已经连接的wifi的ssid名称相同,但bssid不同,则跳过
- }
- }
-
- if (wname != "" && wname != "--") {
- // 当前连接的wifi
- if (wname == actWifiName) {
- connect(ccf, SIGNAL(selectedOneWifiForm(QString,int)), this, SLOT(oneTopWifiFormSelected(QString,int)));
- connect(ccf, SIGNAL(disconnActiveWifi()), this, SLOT(activeWifiDisconn()));
- QString path = line.mid(indexPath).trimmed();
- QString m_name = this->objKyDBus->getWifiSsid(QString("/org/freedesktop/NetworkManager/AccessPoint/%1").arg(path.mid(path.lastIndexOf("/") + 1)));
-// ccf->setName(m_name);
- if (m_name.isEmpty() || m_name == "") {
- ccf->setName(wname);
- } else {
- ccf->setName(m_name);
- }
- //ccf->setRate(wrate);
- int signal = wsignal.toInt() + 11;
- ccf->setSignal(QString::number(signal), wsecu);
- activeWifiSignalLv = wsignal.toInt();
- objKyDBus->getWifiMac(wname);
- ccf->setWifiInfo(wsecu, wsignal, objKyDBus->dbusWifiMac);
- ccf->setConnedString(1, tr("NetOn,"), wsecu);//"已连接"
- ccf->isConnected = true;
- ifWLanConnected = true;
- lbLoadDown->show();
- lbLoadUp->show();
- lbLoadDownImg->show();
- lbLoadUpImg->show();
- ccf->setTopItem(false);
- currSelNetName = "";
-
- syslog(LOG_DEBUG, "already insert an active wifi in the top of wifi list");
- } else {
- wifiListWidget->resize(W_LIST_WIDGET+173*isTabletStyle, wifiListWidget->height() + H_NORMAL_ITEM);
-
- OneConnForm *ocf = new OneConnForm(wifiListWidget, this, confForm, ksnm);
- connect(ocf, SIGNAL(selectedOneWifiForm(QString,int)), this, SLOT(oneWifiFormSelected(QString,int)));
- connect(ocf,&OneConnForm::onLineEditClicked, this, &KylinNM::onLineEditClicked);
- QString path = line.mid(indexPath).trimmed();
- QString m_name = this->objKyDBus->getWifiSsid(QString("/org/freedesktop/NetworkManager/AccessPoint/%1").arg(path.mid(path.lastIndexOf("/") + 1)));
-// ocf->setName(m_name);
- if (m_name.isEmpty() || m_name == "") {
- ocf->setName(wname);
- } else {
- ocf->setName(m_name);
- }
- //ocf->setRate(wrate);
- ocf->setLine(true);
- ocf->setSignal(wsignal, wsecu);
- objKyDBus->getWifiMac(wname);
- ocf->setWifiInfo(wsecu, wsignal, objKyDBus->dbusWifiMac);
- ocf->setConnedString(0, tr("Disconnected"), wsecu);
- ocf->move(L_VERTICAL_LINE_TO_ITEM, j * H_NORMAL_ITEM);
- ocf->setSelected(false, false);
- ocf->show();
-
- j ++;
- count ++;
- }
-
- wnames.append(wname);
- }
- }
- QList itemList = wifiListWidget->findChildren();
- int n = itemList.size();
- if (n >= 1) {
- OneConnForm *lastItem = itemList.at(n-1);
- lastItem->setLine(false);
- lbNoItemTip->hide();
- } else {
- if (ifWLanConnected) {
- lbNoItemTip->show();
- lbNoItemTip->setText(tr("No Other Wireless Network Scheme"));
- } else {
- lbNoItemTip->hide();
- lbTopWifiList->hide();
-// btnAddNet->hide();
- }
- }
-
- this->lanListWidget->hide();
- this->topLanListWidget->hide();
- this->wifiListWidget->show();
- this->topWifiListWidget->show();
-
- this->stopLoading();
- is_stop_check_net_state = 0;
-
- actWifiBssidList.clear();
- wnames.clear();
-}
-
-// 更新wifi列表
-void KylinNM::updateWifiListDone(QStringList slist)
-{
- if (this->ksnm->isExecutingGetLanList){ return;}
-
- //获取表头信息
- QString lastHeadLine = oldWifiSlist.at(0);
- //int lastIndexName = lastHeadLine.indexOf("SSID");
- int lastIndexName, lastIndexPath;
- lastHeadLine = lastHeadLine.trimmed();
- bool isChineseInIt = lastHeadLine.contains(QRegExp("[\\x4e00-\\x9fa5]+"));
- if (isChineseInIt) {
- lastIndexName = lastHeadLine.indexOf("BSSID") + 6 + 19;
- } else {
- lastIndexName = lastHeadLine.indexOf("BSSID") + 19;
- }
- lastIndexPath = lastHeadLine.indexOf("DBUS-PATH");
-
- QString headLine = slist.at(0);
- int indexSecu, indexFreq, indexBSsid, indexName, indexPath;
- headLine = headLine.trimmed();
- bool isChineseExist = headLine.contains(QRegExp("[\\x4e00-\\x9fa5]+"));
- if (isChineseExist) {
- indexSecu = headLine.indexOf("安全性");
- indexFreq = headLine.indexOf("频率") + 4;
- indexBSsid = headLine.indexOf("BSSID") + 6;
- //indexName = headLine.indexOf("SSID") + 6;
- indexName = indexBSsid + 19;
- indexPath = headLine.indexOf("DBUS-PATH");
- } else {
- indexSecu = headLine.indexOf("SECURITY");
- indexFreq = headLine.indexOf("FREQ");
- indexBSsid = headLine.indexOf("BSSID");
- indexName = indexBSsid + 19;
- indexPath = headLine.indexOf("DBUS-PATH");
- }
-
- //列表中去除已经减少的wifi
- for (int i=1; i wifiList = wifiListWidget->findChildren();
- for (int pos = 0; pos < wifiList.size(); pos ++) {
- OneConnForm *ocf = wifiList.at(pos);
- if (ocf->getName() == lastWname) {
- if (ocf->isActive == true){break;
- } else {
- delete ocf;
- //删除元素下面的的所有元素上移
- for (int after_pos = pos+1; after_pos < wifiList.size(); after_pos ++) {
- OneConnForm *after_ocf = wifiList.at(after_pos);
- if (lastWname == currSelNetName) {after_ocf->move(L_VERTICAL_LINE_TO_ITEM, after_ocf->y() - H_NORMAL_ITEM - H_WIFI_ITEM_BIG_EXTEND);}
- else {after_ocf->move(L_VERTICAL_LINE_TO_ITEM, after_ocf->y() - H_NORMAL_ITEM);}
- }
- wifiListWidget->resize(W_LIST_WIDGET+173*isTabletStyle, wifiListWidget->height() - H_NORMAL_ITEM);
- break;
- }
- }
- }
-
- } //end if (j == slist.size()-1)
- } //end (int j=1; j wifiList = wifiListWidget->findChildren();
- int n = wifiList.size();
- int posY = 0;
- if (n >= 1) {
- OneConnForm *lastOcf = wifiList.at(n-1);
- lastOcf->setLine(true);
- if (lastOcf->wifiName == currSelNetName) {
- posY = lastOcf->y()+H_NORMAL_ITEM + H_WIFI_ITEM_BIG_EXTEND;
- } else {
- posY = lastOcf->y()+H_NORMAL_ITEM;
- }
- }
-
- wifiListWidget->resize(W_LIST_WIDGET+173*isTabletStyle, wifiListWidget->height() + H_NORMAL_ITEM);
- OneConnForm *addItem = new OneConnForm(wifiListWidget, this, confForm, ksnm);
- connect(addItem, SIGNAL(selectedOneWifiForm(QString,int)), this, SLOT(oneWifiFormSelected(QString,int)));
- connect(addItem,&OneConnForm::onLineEditClicked, this, &KylinNM::onLineEditClicked);
- QString path = slist.at(i).mid(indexPath).trimmed();
- QString m_name = this->objKyDBus->getWifiSsid(QString("/org/freedesktop/NetworkManager/AccessPoint/%1").arg(path.mid(path.lastIndexOf("/") + 1)));
- if (m_name.isEmpty() || m_name == "") {
- addItem->setName(wname);
- } else {
- addItem->setName(m_name);
- }
- addItem->setLine(false);
- addItem->setSignal(wsignal, wsecu);
- objKyDBus->getWifiMac(wname);
- addItem->setWifiInfo(wsecu, wsignal, objKyDBus->dbusWifiMac);
- addItem->setConnedString(0, tr("Disconnected"), wsecu);//"未连接"
- addItem->move(L_VERTICAL_LINE_TO_ITEM, posY);
- addItem->setSelected(false, false);
- addItem->show();
-
- count += 1;
- }
- }
- }
-
- this->lanListWidget->hide();
- this->topLanListWidget->hide();
- this->wifiListWidget->show();
- this->topWifiListWidget->show();
- this->stopLoading();
-}
-
-
-///////////////////////////////////////////////////////////////////////////////
-//主窗口其他按钮点击响应
-
-void KylinNM::on_btnAdvConf_clicked()
-{
- QProcess *qprocess = new QProcess(this);
- qprocess->start("nm-connection-editor &");
- // int status = system("nm-connection-editor &");
- // if (status != 0){ syslog(LOG_ERR, "execute 'nm-connection-editor &' in function 'on_btnAdvConf_clicked' failed");}
-}
-
-void KylinNM::on_btnAdvConf_pressed()
-{
- //ui->lbBtnConfBG->setStyleSheet(btnOnQss);
-}
-
-void KylinNM::on_btnAdvConf_released()
-{
- //ui->lbBtnConfBG->setStyleSheet(btnOffQss);
-}
-
-void KylinNM::on_btnFlyMode_clicked()
-{
- if (is_fly_mode_on == 0) {
- ui->lbFlyImg->setStyleSheet("QLabel{background-image:url(:/res/x/fly-mode-on.svg);}");
- ui->lbFlyBG->setStyleSheet(btnOnQss);
- is_fly_mode_on = 1;
-
- onBtnWifiClicked(0);
- on_btnWifiList_clicked();
- } else {
- ui->lbFlyImg->setStyleSheet("QLabel{background-image:url(:/res/x/fly-mode-off.svg);}");
- ui->lbFlyBG->setStyleSheet(btnOffQss);
- is_fly_mode_on = 0;
- }
-}
-
-void KylinNM::on_btnHotspot_clicked()
-{
- if (is_wireless_adapter_ready == 1) {
- if (is_hot_sopt_on == 0) {
- ui->lbHotImg->setStyleSheet("QLabel{background-image:url(:/res/x/hot-spot-on.svg);}");
- ui->lbHotBG->setStyleSheet(btnOnQss);
- is_hot_sopt_on = 1;
-
- QApplication::setQuitOnLastWindowClosed(false);
- DlgHotspotCreate *hotCreate = new DlgHotspotCreate(objKyDBus->dbusWiFiCardName);
- connect(hotCreate,SIGNAL(updateHotspotList()),this,SLOT(on_btnWifiList_clicked() ));
- connect(hotCreate,SIGNAL(btnHotspotState()),this,SLOT(on_btnHotspotState() ));
- hotCreate->show();
- } else {
- on_btnHotspotState();
-
- BackThread objBT;
- objBT.disConnLanOrWifi("wifi");
-
- sleep(2);
- on_btnWifiList_clicked();
- }
- }
-}
-
-void KylinNM::onBtnAddNetClicked()
-{
-// QApplication::setQuitOnLastWindowClosed(false);
- DlgConnHidWifi *connHidWifi = new DlgConnHidWifi(0, this, this->parentWidget());
- connect(connHidWifi, SIGNAL(reSetWifiList() ), this, SLOT(on_btnWifiList_clicked()) );
- connHidWifi->show();
-}
-
-void KylinNM::onBtnCreateNetClicked()
-{
- QPoint pos = QCursor::pos();
- QRect primaryGeometry;
- for (QScreen *screen : qApp->screens()) {
- if (screen->geometry().contains(pos)) {
- primaryGeometry = screen->geometry();
- }
- }
-
- if (primaryGeometry.isEmpty()) {
- primaryGeometry = qApp->primaryScreen()->geometry();
- }
-
- ConfForm *m_cf = new ConfForm(this->parentWidget());
- m_cf->setMainWindow(this);
- m_cf->cbTypeChanged(3);
- m_cf->move(primaryGeometry.width() / 2 - m_cf->width() / 2, primaryGeometry.height() / 2 - m_cf->height() / 2);
- m_cf->show();
-}
-
-
-///////////////////////////////////////////////////////////////////////////////
-//处理窗口变化、网络状态变化
-
-//列表中item的扩展与收缩
-void KylinNM::oneLanFormSelected(QString lanName, QString uniqueName)
-{
- QList topLanList = topLanListWidget->findChildren();
- QList lanList = lanListWidget->findChildren();
-
- //**********************先处理下方列表********************//
- // 下方所有元素回到原位
- for (int i = 0, j = 0;i < lanList.size(); i ++) {
- OneLancForm *ocf = lanList.at(i);
- if (ocf->isActive == true) {
- ocf->move(L_VERTICAL_LINE_TO_ITEM, 0);
- }
- if (ocf->isActive == false) {
- ocf->move(L_VERTICAL_LINE_TO_ITEM, j * H_NORMAL_ITEM);
- j ++;
- }
- }
-
- //是否与上一次选中同一个网络框
- if (currSelNetName == uniqueName) {
- // 缩小所有选项卡
- for (int i = 0;i < lanList.size(); i ++) {
- OneLancForm *ocf = lanList.at(i);
- if (ocf->uniqueName == uniqueName) {
- ocf->setSelected(false, true);
- } else {
- ocf->setSelected(false, false);
- }
- }
-
- currSelNetName = "";
- } else {
- int selectY = 0;
- for (int i = 0;i < lanList.size(); i ++) {
- OneLancForm *ocf = lanList.at(i);
- if (ocf->uniqueName == uniqueName) {
- selectY = ocf->y(); //获取选中item的y坐标
- break;
- }
- }
-
- // 选中元素下面的所有元素下移 H_LAN_ITEM_EXTEND
- for (int i = 0;i < lanList.size(); i ++) {
- OneLancForm *ocf = lanList.at(i);
- if (ocf->y() > selectY) {
- ocf->move(L_VERTICAL_LINE_TO_ITEM, ocf->y() + H_LAN_ITEM_EXTEND);
- }
- }
-
- for (int i = 0;i < lanList.size(); i ++) {
- OneLancForm *ocf = lanList.at(i);
- if (ocf->uniqueName == uniqueName) {
- ocf->setSelected(true, false);
- selectY = ocf->y();
- } else {
- ocf->setSelected(false, false);
- }
- }
-
- currSelNetName = uniqueName;
- }
-
- QList itemList = lanListWidget->findChildren();
- int n = itemList.size();
- if (n >= 1) {
- OneLancForm *lastItem = itemList.at(n-1);
- lastItem->setLine(false);
- }
-
- //**********************处理上方列表-界面所有控件回原位********************//
- topLanListWidget->resize(W_TOP_LIST_WIDGET, H_NORMAL_ITEM + H_GAP_UP + X_ITEM); // 顶部的item缩小
- lbTopLanList->move(X_MIDDLE_WORD, H_NORMAL_ITEM + H_GAP_UP);
-// btnCreateNet->move(X_BTN_FUN, Y_BTN_FUN);
- scrollAreal->move(W_LEFT_AREA, Y_SCROLL_AREA);
- lbNoItemTip->move(this->width()/2 - W_NO_ITEM_TIP/2 + W_LEFT_AREA/2, this->height()/2);
-
- OneLancForm *ocf = topLanList.at(0);
- ocf->setTopItem(false);
-}
-void KylinNM::oneTopLanFormSelected(QString lanName, QString uniqueName)
-{
- currSelNetName = uniqueName;
-}
-
-void KylinNM::oneWifiFormSelected(QString wifiName, int extendLength)
-{
- QListtopWifiList = topWifiListWidget->findChildren();
- QList wifiList = wifiListWidget->findChildren();
-
- //******************先处理下方列表****************//
- // 下方所有元素回到原位
- for (int i = 0, j = 0;i < wifiList.size(); i ++) {
- OneConnForm *ocf = wifiList.at(i);
- if (ocf->isActive == true) {
- ocf->move(L_VERTICAL_LINE_TO_ITEM, 0);
- }
- if (ocf->isActive == false) {
- ocf->move(L_VERTICAL_LINE_TO_ITEM, j * H_NORMAL_ITEM);
- j ++;
- }
- }
-
- //是否与上一次选中同一个网络框
- if (currSelNetName == wifiName) {
- // 缩小所有选项卡
- for (int i = 0;i < wifiList.size(); i ++) {
- OneConnForm *ocf = wifiList.at(i);
- if (ocf->wifiName == wifiName) {
- if (ocf->wifiName == hideWiFiConn) {
- ocf->setHideItem(true, true);
- } else {
- ocf->setSelected(false, true);
- }
- } else {
- if (ocf->wifiName == hideWiFiConn) {
- ocf->setHideItem(true, true);
- } else {
- ocf->setSelected(false, false);
- }
- }
-
- }
- currSelNetName = "";
- } else {
- int selectY = 0;
- for (int i = 0;i < wifiList.size(); i ++) {
- OneConnForm *ocf = wifiList.at(i);
- if (ocf->wifiName == wifiName) {
- selectY = ocf->y(); //获取选中item的y坐标
- this->scrollAreaw->verticalScrollBar()->setValue(selectY);
- break;
- }
- }
-
- // 选中元素下面的所有元素下移 H_WIFI_ITEM_BIG_EXTEND
- for (int i = 0;i < wifiList.size(); i ++) {
- OneConnForm *ocf = wifiList.at(i);
- if (ocf->y() > selectY) {
- ocf->move(L_VERTICAL_LINE_TO_ITEM, ocf->y() + extendLength);
- }
- }
-
- for (int i = 0;i < wifiList.size(); i ++) {
- OneConnForm *ocf = wifiList.at(i);
- if (ocf->wifiName == wifiName) {
- if (ocf->wifiName == hideWiFiConn) {
- ocf->setHideItem(true, true);
- } else {
- ocf->setSelected(true, false);
- }
- } else {
- if (ocf->wifiName == hideWiFiConn) {
- ocf->setHideItem(true, true);
- } else {
- ocf->setSelected(false, false);
- }
- }
- }
-
- currSelNetName = wifiName;
- }
-
- //最后一个item没有下划线
- QList itemList = wifiListWidget->findChildren();
- int n = itemList.size();
- if (n >= 1) {
- OneConnForm *lastItem = itemList.at(n-1);
- lastItem->setLine(false);
- }
-
- //********************处理上方列表-界面所有控件回原位******************//
- // 顶部的item缩小
- topWifiListWidget->resize(W_TOP_LIST_WIDGET+194*isTabletStyle, H_NORMAL_ITEM + H_GAP_UP + X_ITEM);
- lbTopWifiList->move(X_MIDDLE_WORD, H_NORMAL_ITEM + H_GAP_UP);
-// btnAddNet->move(X_BTN_FUN, Y_BTN_FUN);
- scrollAreaw->move(W_LEFT_AREA, Y_SCROLL_AREA);
- lbNoItemTip->move(this->width()/2 - W_NO_ITEM_TIP/2 + W_LEFT_AREA/2, this->height()/2);
-
- OneConnForm *ocf = topWifiList.at(0);
- ocf->setTopItem(false);
-}
-void KylinNM::oneTopWifiFormSelected(QString wifiName, int extendLength)
-{
- QListtopWifiList = topWifiListWidget->findChildren();
- QList wifiList = wifiListWidget->findChildren();
-
- if (currSelNetName == wifiName) {
- // 与上一次选中同一个网络框,缩小当前选项卡
- topWifiListWidget->resize(W_TOP_LIST_WIDGET+194*isTabletStyle, H_NORMAL_ITEM + H_GAP_UP + X_ITEM);
- lbTopWifiList->move(X_MIDDLE_WORD, H_NORMAL_ITEM + H_GAP_UP);
-// btnAddNet->move(X_BTN_FUN, Y_BTN_FUN);
- scrollAreaw->move(W_LEFT_AREA, Y_SCROLL_AREA);
- lbNoItemTip->move(this->width()/2 - W_NO_ITEM_TIP/2 + W_LEFT_AREA/2, this->height()/2);
-
- OneConnForm *ocf = topWifiList.at(0);
- ocf->setTopItem(false);
-
- currSelNetName = "";
- } else {
- // 没有与上一次选中同一个网络框,放大当前选项卡
-
- for(int i = 0;i < wifiList.size(); i ++) {
- // 所有元素回到原位
- OneConnForm *ocf = wifiList.at(i);
- ocf->setSelected(false, false);
- ocf->move(L_VERTICAL_LINE_TO_ITEM, i * H_NORMAL_ITEM);
- }
-
- topWifiListWidget->resize(W_TOP_LIST_WIDGET+194*isTabletStyle, H_NORMAL_ITEM + H_WIFI_ITEM_BIG_EXTEND + H_GAP_UP + X_ITEM);
- lbTopWifiList->move(X_MIDDLE_WORD, H_NORMAL_ITEM + H_WIFI_ITEM_BIG_EXTEND + H_GAP_UP);
-// btnAddNet->move(X_BTN_FUN, Y_BTN_FUN + H_WIFI_ITEM_BIG_EXTEND);
- scrollAreaw->move(W_LEFT_AREA, Y_SCROLL_AREA + H_WIFI_ITEM_BIG_EXTEND);
- lbNoItemTip->move(this->width()/2 - W_NO_ITEM_TIP/2 + W_LEFT_AREA/2, this->height()/2 + 65);
-
- OneConnForm *ocf = topWifiList.at(0);
- ocf->setTopItem(true);
-
- currSelNetName = wifiName;
- }
-}
-
-//断开网络处理
-void KylinNM::activeLanDisconn()
-{
- syslog(LOG_DEBUG, "Wired net is disconnected");
-
- QString txt(tr("Wired net is disconnected"));
- objKyDBus->showDesktopNotify(txt);
- //QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "...' -t 3800";
- //int status1 = system(cmd.toUtf8().data());
- //if (status1 != 0){ syslog(LOG_ERR, "execute 'notify-send' in function 'execConnWifiPWD' failed");}
-
- currSelNetName = "";
- //this->startLoading();
- emit this->waitLanStop();
- this->ksnm->execGetLanList();
- QTimer::singleShot(200, this, &KylinNM::onConnectChanged);
-}
-
-void KylinNM::activeWifiDisconn()
-{
- QThread *tt = new QThread();
- BackThread *btt = new BackThread();
- btt->moveToThread(tt);
- connect(tt, SIGNAL(finished()), tt, SLOT(deleteLater()));
- connect(this, SIGNAL(disConnSparedNet(QString)), btt, SLOT(disConnSparedNetSlot(QString)),Qt::DirectConnection);
- connect(btt, SIGNAL(disFinish()), this, SLOT(activeGetWifiList()), Qt::DirectConnection);
- connect(btt, SIGNAL(ttFinish()), tt, SLOT(quit()),Qt::DirectConnection);
-
- tt->start();
- activeStartLoading();
- QTimer::singleShot(200, this, &KylinNM::onConnectChanged);
-}
-
-void KylinNM::reflashWifiUi()
-{
- mutexIsReflashWifi.lock();
- m_is_reflashWifiUi = true;
- mutexIsReflashWifi.unlock();
-}
-
-void KylinNM::activeStartLoading()
-{
- syslog(LOG_DEBUG, "Wi-Fi is disconnected");
- emit this->disConnSparedNet("wifi");
-}
-void KylinNM::activeGetWifiList()
-{
- emit this->waitWifiStop();
- this->ksnm->execGetWifiList();
-}
-
-//网络开关处理,打开与关闭网络
-void KylinNM::enNetDone()
-{
- BackThread bt;
- mwBandWidth = bt.execChkLanWidth(lname);
-
- ui->lbBtnNetBG->setStyleSheet(btnOnQss);
-
- // 打开网络开关时如果Wifi开关是打开的,设置其样式
- if (checkWlOn()) {
- btnWireless->setSwitchStatus(true);
- //ui->lbBtnWifiBG->setStyleSheet(btnBgOnQss);
- //ui->lbBtnWifiBall->move(X_RIGHT_WIFI_BALL, Y_WIFI_BALL);
- }
-
- onBtnNetListClicked(1);
- is_stop_check_net_state = 0;
-
- qDebug()<<"debug: already turn on the switch of lan network";
- syslog(LOG_DEBUG, "Already turn on the switch of lan network");
-}
-void KylinNM::disNetDone()
-{
- this->is_btnNetList_clicked = 1;
- this->is_btnWifiList_clicked = 0;
-
- ui->lbNetListBG->setStyleSheet(btnOnQss);
- ui->lbWifiListBG->setStyleSheet(btnOffQss);
-
- ui->lbNetwork->setText("Activated LAN");
- btnWireless->hide();
- //ui->lbBtnWifiBG->hide();
- //ui->lbBtnWifiBall->hide();
-
- delete topLanListWidget; // 清空top列表
- createTopLanUI(); //创建顶部有线网item
-
- // 清空lan列表
- lanListWidget = new QWidget(scrollAreal);
- lanListWidget->resize(W_LIST_WIDGET, H_NORMAL_ITEM + H_LAN_ITEM_EXTEND);
- scrollAreal->setWidget(lanListWidget);
- scrollAreal->move(W_LEFT_AREA, Y_SCROLL_AREA);
-
- // 当前连接的lan
- OneLancForm *ccf = new OneLancForm(topLanListWidget, this, confForm, ksnm);
- ccf->setName(tr("Not connected"), "");//"当前未连接任何 以太网"
- ccf->setIcon(false);
- ccf->setConnedString(1, tr("Disconnected"));//"未连接"
- ccf->isConnected = false;
- ccf->setTopItem(false);
- ccf->setAct(true);
- ccf->move(L_VERTICAL_LINE_TO_ITEM, 0);
- ccf->show();
-
- ui->lbBtnNetBG->setStyleSheet(btnOffQss);
-
- btnWireless->setSwitchStatus(false);
-
- this->lanListWidget->show();
- this->wifiListWidget->hide();
- this->scrollAreal->show();
- this->topLanListWidget->show();
- this->scrollAreaw->hide();
- this->topWifiListWidget->hide();
-
- on_btnNetList_pressed();
-
- qDebug()<<"debug: already turn off the switch of lan network";
- syslog(LOG_DEBUG, "Already turn off the switch of lan network");
-
- this->stopLoading();
- QTimer::singleShot(200, this, &KylinNM::onConnectChanged);
-}
-void KylinNM::launchLanDone()
-{
- ui->lbBtnNetBG->setStyleSheet(btnOnQss);
-}
-
-void KylinNM::enWifiDone()
-{
- //ui->lbBtnWifiBG->setStyleSheet(btnBgOnQss);
- //ui->lbBtnWifiBall->move(X_RIGHT_WIFI_BALL, Y_WIFI_BALL);
-
- is_update_wifi_list = 0;
- if (is_btnWifiList_clicked) {
- this->ksnm->execGetWifiList();
- } else {
- on_btnWifiList_clicked();
- }
-
- qDebug()<<"debug: already turn on the switch of wifi network";
- syslog(LOG_DEBUG, "Already turn on the switch of wifi network");
-}
-void KylinNM::disWifiDone()
-{
- disWifiDoneChangeUI();
-
- on_btnWifiList_pressed();
-
- qDebug()<<"debug: already turn off the switch of wifi network";
- syslog(LOG_DEBUG, "Already turn off the switch of wifi network");
-
- this->stopLoading();
- is_stop_check_net_state = 0;
- QTimer::singleShot(200, this, &KylinNM::onConnectChanged);
-}
-void KylinNM::disWifiStateKeep()
-{
- if (this->is_btnNetList_clicked == 1) {
- btnWireless->setSwitchStatus(false);
- //ui->lbBtnWifiBG->setStyleSheet(btnBgOffQss);
- //ui->lbBtnWifiBall->move(X_LEFT_WIFI_BALL, Y_WIFI_BALL);
- }
- if (this->is_btnWifiList_clicked== 1) {
- disWifiDoneChangeUI();
-
- // this->stopLoading();
- getActiveInfo();
- }
-}
-void KylinNM::disWifiDoneChangeUI()
-{
- wifiListWidget = new QWidget(scrollAreaw);
- wifiListWidget->resize(W_LIST_WIDGET+173*isTabletStyle, H_WIFI_ITEM_BIG_EXTEND);
- scrollAreaw->setWidget(wifiListWidget);
- scrollAreaw->move(W_LEFT_AREA, Y_SCROLL_AREA);
-
- lbTopWifiList->move(X_MIDDLE_WORD, H_NORMAL_ITEM + H_GAP_UP);
-// btnAddNet->move(X_BTN_FUN, Y_BTN_FUN);
- topWifiListWidget->resize(W_TOP_LIST_WIDGET+194*isTabletStyle, H_NORMAL_ITEM + H_GAP_UP + X_ITEM);
-
- QList wifiList = topWifiListWidget->findChildren();
- for (int i = 0; i < wifiList.size(); i ++) {
- OneConnForm *ocf = wifiList.at(i);
- if (ocf->isActive == true) {
- ocf->setSelected(false, false);
- ocf->setName(tr("Not connected"));//"当前未连接任何 Wifi"
- ocf->setSignal("0", "--");
- ocf->setConnedString(1, tr("Disconnected"), "");//"未连接"
- lbLoadDown->hide();
- lbLoadUp->hide();
- lbLoadDownImg->hide();
- lbLoadUpImg->hide();
- ocf->isConnected = false;
- ocf->setTopItem(false);
- disconnect(ocf, SIGNAL(selectedOneWifiForm(QString,int)), this, SLOT(oneTopWifiFormSelected(QString,int)));
- } else {
- ocf->deleteLater();
- }
- }
-
- btnWireless->setSwitchStatus(false);
- //ui->lbBtnWifiBG->setStyleSheet(btnBgOffQss);
- //ui->lbBtnWifiBall->move(X_LEFT_WIFI_BALL, Y_WIFI_BALL);
-
- this->lanListWidget->hide();
- this->topLanListWidget->hide();
- this->wifiListWidget->show();
- this->topWifiListWidget->show();
- this->scrollAreal->hide();
- this->scrollAreaw->show();
-}
-
-void KylinNM::on_btnHotspotState()
-{
- ui->lbHotImg->setStyleSheet("QLabel{background-image:url(:/res/x/hot-spot-off.svg);}");
- ui->lbHotBG->setStyleSheet(btnOffQss);
- is_hot_sopt_on = 0;
-}
-
-//处理外界对网络的连接与断开
-void KylinNM::onExternalConnectionChange(QString type)
-{
- qDebug() <is_btnWifiList_clicked==1 && this->isVisible()) {
- BackThread loop_bt;
- IFace loop_iface = loop_bt.execGetIface();
-
- if (loop_iface.wstate != 2) {
- is_update_wifi_list = 1;
- this->ksnm->execGetWifiList(); //更新wifi列表
- }
- }
-}
-
-void KylinNM::on_setNetSpeed()
-{
- if (this->isVisible() && is_stop_check_net_state==0) {
- if (is_btnWifiList_clicked == 1) {
- if ( objNetSpeed->getCurrentDownloadRates(objKyDBus->dbusWiFiCardName.toUtf8().data(), &start_rcv_rates, &start_tx_rates) == -1) {
- start_rcv_rates = end_rcv_rates;
- }
- } else if(is_btnNetList_clicked == 1) {
- if ( objNetSpeed->getCurrentDownloadRates(objKyDBus->dbusLanCardName.toUtf8().data(), &start_rcv_rates, &start_tx_rates) == -1) {
- start_tx_rates = end_tx_rates;
- }
- }
-
- long int delta_rcv = (start_rcv_rates - end_rcv_rates)/800;
- long int delta_tx = (start_tx_rates - end_tx_rates)/8;
- if (delta_rcv>=10000 || delta_rcv<0){delta_rcv = 0;}
- if (delta_tx>=10000 || delta_tx<0){delta_tx = 0;}
-
- int rcv_num = delta_rcv/3;
- int tx_num = delta_tx/3;
-
- QString str_rcv;
- QString str_tx;
-
- if (rcv_num < 1000) {
- str_rcv = QString::number(rcv_num) + "KB/s.";
- } else {
- int remainder;
- if (rcv_num%1000 < 100) {
- remainder = 0;
- } else {
- remainder = (rcv_num%1000)/100;
- }
- str_rcv = QString::number(rcv_num/1000) + "." + QString::number(remainder) + "MB/s.";
- }
-
- if (tx_num < 1000) {
- str_tx = QString::number(tx_num) + "KB/s";
- } else {
- int remainder;
- if (tx_num%1000 < 100) {
- remainder = 0;
- } else {
- remainder = (tx_num%1000)/100;
- }
- str_tx = QString::number(tx_num/1000) + "." + QString::number(remainder) + "MB/s";
- }
-
- lbLoadDown->setText(str_rcv);
- lbLoadUp->setText(str_tx);
-
- switch (str_rcv.size()) {
- case 6:
- lbLoadUp->move(X_ITEM + 187, Y_TOP_ITEM + 32);
- lbLoadUpImg->move(X_ITEM + 170, Y_TOP_ITEM + 35);
- break;
- case 7:
- lbLoadUp->move(X_ITEM + 194, Y_TOP_ITEM + 32);
- lbLoadUpImg->move(X_ITEM + 176, Y_TOP_ITEM + 35);
- break;
- case 8:
- lbLoadUp->move(X_ITEM + 199, Y_TOP_ITEM + 32);
- lbLoadUpImg->move(X_ITEM + 186, Y_TOP_ITEM + 35);
- break;
- default:
- break;
- }
-
- end_rcv_rates = start_rcv_rates;
- end_tx_rates = start_tx_rates;
- }
-}
-
-void KylinNM::connLanDone(int connFlag)
-{
- emit this->waitLanStop(); //停止加载动画
-
- // Lan连接结果,0点击连接成功 1失败 3开机启动网络工具时已经连接
- if (connFlag == 0) {
- syslog(LOG_DEBUG, "Wired net already connected by clicking button");
- this->is_wired_line_ready = 1;
- this->is_by_click_connect = 1;
- this->ksnm->execGetLanList();
-
- QString txt(tr("Conn Ethernet Success"));
- objKyDBus->showDesktopNotify(txt);
- //QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "' -t 3800";
- //int status = system(cmd.toUtf8().data());
- //if (status != 0){ syslog(LOG_ERR, "execute 'notify-send' in function 'connLanDone' failed");}
- }
-
- if (connFlag == 1) {
- qDebug()<<"without net line connect to computer";
- this->is_wired_line_ready = 0; //without net line connect to computer
- is_stop_check_net_state = 0;
-
- QString txt(tr("Conn Ethernet Fail"));
- objKyDBus->showDesktopNotify(txt);
- //QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "' -t 3800";
- //int status = system(cmd.toUtf8().data());
- //if (status != 0){ syslog(LOG_ERR, "execute 'notify-send' in function 'connLanDone' failed");}
- }
-
- if (connFlag == 3) {
- syslog(LOG_DEBUG, "Launch kylin-nm, Lan already connected");
- this->is_wired_line_ready = 1;
- }
-
- this->stopLoading();
- QTimer::singleShot(200, this, &KylinNM::onConnectChanged);
-}
-
-void KylinNM::connWifiDone(int connFlag)
-{
- emit this->waitWifiStop(); //停止加载动画
- // Wifi连接结果,0点击连接成功 1失败 2没有配置文件 3开机启动网络工具时已经连接
- if (connFlag == 0) {
- syslog(LOG_DEBUG, "Wi-Fi already connected by clicking button");
- this->is_by_click_connect = 1;
- this->ksnm->execGetWifiList();
-
- QString txt(tr("Conn Wifi Success"));
- objKyDBus->showDesktopNotify(txt);
- //QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "' -t 3800";
- //int status = system(cmd.toUtf8().data());
- //if (status != 0){ syslog(LOG_ERR, "execute 'notify-send' in function 'connWifiDone' failed");}
- } else if (connFlag == 1) {
- is_stop_check_net_state = 0;
- is_connect_wifi_failed = 1;
-
- QString txt(tr("Confirm your Wi-Fi password or usable of wireless card"));
- objKyDBus->showDesktopNotify(txt);
- //QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "...' -t 3800";
- //int status1 = system(cmd.toUtf8().data());
- //if (status1 != 0){ syslog(LOG_ERR, "execute 'notify-send' in function 'execConnWifiPWD' failed");}
- } else if (connFlag == 3) {
- syslog(LOG_DEBUG, "Launch kylin-nm, Wi-Fi already connected");
- }
- QTimer::singleShot(200, this, &KylinNM::onConnectChanged);
-}
-
-int KylinNM::getConnectStatus()
-{
- int ret = -1;
- QString actLanName = "--";
- QString actWifiName = "--";
-
- activecon *act = NULL;
- int count = 0;
- kylin_network_get_activecon_info(&act, &count);
- int index = 0;
- if(!act){
- return -1;
- }
- while (act && index < count) {
- if (QString(act[index].type) == "ethernet" || QString(act[index].type) == "802-3-ethernet") {
- actLanName = QString(act[index].con_name);
- }
- if (QString(act[index].type) == "wifi" || QString(act[index].type) == "802-11-wireless") {
- actWifiName = QString(act[index].con_name);
- }
- index ++;
- }
- if (act) {
- free(act);
- }
-
- //ukui3.0中获取currentActWifiSignalLv的值
- if (activeWifiSignalLv > 75) {
- currentActWifiSignalLv = 1;
- } else if(activeWifiSignalLv > 55 && activeWifiSignalLv <= 75) {
- currentActWifiSignalLv = 2;
- } else if(activeWifiSignalLv > 35 && activeWifiSignalLv <= 55) {
- currentActWifiSignalLv = 3;
- } else if( activeWifiSignalLv <= 35) {
- currentActWifiSignalLv = 4;
- }
-
- // 设置图标
- if (actLanName != "--") {
- ret = 0;
- } else if (actWifiName != "--") {
- ret = 1;
- } else {
- ret = -1;
- }
-
- return ret;
-}
diff --git a/KylinNM/src/kylinnm.h b/KylinNM/src/kylinnm.h
deleted file mode 100644
index 3ed9ce6..0000000
--- a/KylinNM/src/kylinnm.h
+++ /dev/null
@@ -1,353 +0,0 @@
-/*
- * Copyright (C) 2020 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
-#include
-#include
-#include