Add libkylin-nm-base and kylin-nm-plugin in kylin-nm
This commit is contained in:
parent
cb621701e4
commit
88b08c8df1
|
@ -1,54 +0,0 @@
|
|||
# C++ objects and libs
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.a
|
||||
*.la
|
||||
*.lai
|
||||
*.so
|
||||
*.so.*
|
||||
*.dll
|
||||
*.dylib
|
||||
|
||||
# Qt-es
|
||||
object_script.*.Release
|
||||
object_script.*.Debug
|
||||
*_plugin_import.cpp
|
||||
/.qmake.cache
|
||||
/.qmake.stash
|
||||
*.pro.user
|
||||
*.pro.user.*
|
||||
*.qbs.user
|
||||
*.qbs.user.*
|
||||
*.moc
|
||||
moc_*.cpp
|
||||
moc_*.h
|
||||
qrc_*.cpp
|
||||
ui_*.h
|
||||
*.qmlc
|
||||
*.jsc
|
||||
Makefile*
|
||||
*build-*
|
||||
*.prl
|
||||
|
||||
# Qt unit tests
|
||||
target_wrapper.*
|
||||
|
||||
# QtCreator
|
||||
*.autosave
|
||||
|
||||
# QtCreator Qml
|
||||
*.qmlproject.user
|
||||
*.qmlproject.user.*
|
||||
|
||||
# QtCreator CMake
|
||||
CMakeLists.txt.user*
|
||||
|
||||
# QtCreator 4.8< compilation database
|
||||
compile_commands.json
|
||||
|
||||
# QtCreator local machine specific files for imported projects
|
||||
*creator.user*
|
||||
|
||||
# OS X extra file
|
||||
.DS_Store
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "libnm-base-kylin_global.h"
|
||||
|
||||
#include <kylin-nm/kylinnetworkmanager.h>
|
||||
#include <kylinnetworkmanager.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QWidget>
|
||||
|
|
|
@ -11,7 +11,14 @@ CONFIG += c++14 qt link_pkgconfig no_keywords
|
|||
# deprecated API in order to know how to port your code away from it.
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
PKGCONFIG += kylin-nm-base
|
||||
PKGCONFIG += gio-2.0 libnm
|
||||
|
||||
INCLUDEPATH += /usr/include/KF5/NetworkManagerQt
|
||||
LIBS += -L/usr/lib/ -lKF5NetworkManagerQt
|
||||
|
||||
#PKGCONFIG += kylin-nm-base
|
||||
INCLUDEPATH += $$PWD/../../libkylin-nm-base/libnm-kylin/libnm-base-kylin
|
||||
LIBS += -L$$PWD/../../libkylin-nm-base/libnm-kylin/libnm-base-kylin/ -lkylin-nm-base
|
||||
|
||||
#INCLUDEPATH += $$PWD/../libnm-base-kylin/
|
||||
#INCLUDEPATH += /usr/include/KF5/NetworkManagerQt
|
||||
|
|
|
@ -44,8 +44,8 @@ using namespace kdk;
|
|||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
#include <kylin-nm/kylin-nm-interface.h>
|
||||
#include <kylin-nm/kylinnetworkmanager.h>
|
||||
#include <kylin-nm-interface.h>
|
||||
#include <kylinnetworkmanager.h>
|
||||
#include "lanitem.h"
|
||||
#include "../component/DeviceFrame/deviceframe.h"
|
||||
#include "itemframe.h"
|
||||
|
|
|
@ -2,12 +2,6 @@ QT += widgets network dbus gui core
|
|||
TEMPLATE = lib
|
||||
CONFIG += plugin
|
||||
|
||||
include(../component/infobutton.pri)
|
||||
include(../component/divider.pri)
|
||||
include(../component/deviceframe.pri)
|
||||
include(../component/RadioItemButton.pri)
|
||||
include(../component/fixlabel.pri)
|
||||
|
||||
TARGET = $$qtLibraryTarget(netconnect)
|
||||
DESTDIR = ../..
|
||||
target.path = /usr/lib/kylin-nm
|
||||
|
@ -16,18 +10,28 @@ INCLUDEPATH += \
|
|||
$$PROJECT_COMPONENTSOURCE \
|
||||
$$PROJECT_ROOTDIR \
|
||||
|
||||
LIBS += -L$$[QT_INSTALL_LIBS] -lkylin-nm-base
|
||||
|
||||
CONFIG += c++11 \
|
||||
link_pkgconfig \
|
||||
no_keywords
|
||||
CONFIG += c++11 link_pkgconfig no_keywords qt warn_on no_install_prl ordered
|
||||
#CONFIG += create_pc create_prl
|
||||
|
||||
PKGCONFIG += gsettings-qt \
|
||||
kysdk-qtwidgets \
|
||||
kylin-nm-base
|
||||
libnm \
|
||||
gtk+-3.0
|
||||
# kylin-nm-base
|
||||
|
||||
INCLUDEPATH += /usr/include/KF5/NetworkManagerQt
|
||||
LIBS += -L/usr/lib/ -lKF5NetworkManagerQt
|
||||
|
||||
INCLUDEPATH += $$PWD/../../../libkylin-nm-base/libnm-kylin/libnm-base-kylin
|
||||
LIBS += -L$$PWD/../../../libkylin-nm-base/libnm-kylin/libnm-base-kylin/ -lkylin-nm-base
|
||||
#DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
include(../component/infobutton.pri)
|
||||
include(../component/divider.pri)
|
||||
include(../component/deviceframe.pri)
|
||||
include(../component/RadioItemButton.pri)
|
||||
include(../component/fixlabel.pri)
|
||||
|
||||
SOURCES += \
|
||||
itemframe.cpp \
|
||||
lanitem.cpp \
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <QDesktopWidget>
|
||||
#include <QApplication>
|
||||
|
||||
#include <kylin-nm/kylinnetworkmanager.h>
|
||||
#include <kylinnetworkmanager.h>
|
||||
#include "entsecuritywidget.h"
|
||||
|
||||
class EnterpriseWlanPage : public QWidget
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "kpasswordedit.h"
|
||||
#include "kdialog.h"
|
||||
#include "kballontip.h"
|
||||
#include "kylin-nm/depend/kyenterpricesettinginfo.h"
|
||||
#include "depend/kyenterpricesettinginfo.h"
|
||||
|
||||
using namespace kdk;
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "kpasswordedit.h"
|
||||
#include "kborderlessbutton.h"
|
||||
#include "entsecuritywidget.h"
|
||||
#include "kylin-nm/depend/kywirelessconnectoperation.h"
|
||||
#include "depend/kywirelessconnectoperation.h"
|
||||
|
||||
using namespace kdk;
|
||||
|
||||
|
|
|
@ -43,9 +43,9 @@ using namespace kdk;
|
|||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
#include <kylin-nm/kylin-nm-interface.h>
|
||||
#include <kylin-nm/kylinnetworkmanager.h>
|
||||
#include <kylin-nm/kylin-agent/kylinagent.h>
|
||||
#include <kylin-nm-interface.h>
|
||||
#include <kylinnetworkmanager.h>
|
||||
#include <kylin-agent/kylinagent.h>
|
||||
#include "../component/DeviceFrame/deviceframe.h"
|
||||
#include "itemframe.h"
|
||||
#include "wlanitem.h"
|
||||
|
|
|
@ -2,13 +2,6 @@ QT += widgets network dbus gui core
|
|||
TEMPLATE = lib
|
||||
CONFIG += plugin
|
||||
|
||||
include(../component/infobutton.pri)
|
||||
include(../component/divider.pri)
|
||||
include(../component/deviceframe.pri)
|
||||
include(../component/RadioItemButton.pri)
|
||||
include(../component/fixlabel.pri)
|
||||
include(hiddenwifi/hiddenwifi.pri)
|
||||
|
||||
TARGET = $$qtLibraryTarget(wlanconnect)
|
||||
DESTDIR = ../..
|
||||
target.path = /usr/lib/kylin-nm
|
||||
|
@ -19,17 +12,35 @@ INCLUDEPATH += \
|
|||
|
||||
LIBS += -L$$[QT_INSTALL_LIBS] -lkylin-nm-base -lkylin-keyring
|
||||
|
||||
CONFIG += c++11 \
|
||||
link_pkgconfig \
|
||||
no_keywords
|
||||
CONFIG += c++11 link_pkgconfig no_keywords qt warn_on no_install_prl ordered
|
||||
#CONFIG += create_pc create_prl
|
||||
|
||||
|
||||
PKGCONFIG += gsettings-qt \
|
||||
kysdk-qtwidgets \
|
||||
kylin-nm-base \
|
||||
# kylin-nm-base \
|
||||
libnm \
|
||||
gtk+-3.0 \
|
||||
libsecret-1
|
||||
|
||||
INCLUDEPATH += /usr/include/KF5/NetworkManagerQt
|
||||
LIBS += -L/usr/lib/ -lKF5NetworkManagerQt
|
||||
|
||||
INCLUDEPATH += $$PWD/../../../libkylin-nm-base/libnm-kylin/libnm-base-kylin
|
||||
LIBS += -L$$PWD/../../../libkylin-nm-base/libnm-kylin/libnm-base-kylin/ -lkylin-nm-base
|
||||
|
||||
INCLUDEPATH += $$PWD/../../../libkylin-nm-base/kylin-keyring
|
||||
LIBS += -L$$PWD/../../../libkylin-nm-base/kylin-keyring/ -lkylin-keyring
|
||||
|
||||
#DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
include(../component/infobutton.pri)
|
||||
include(../component/divider.pri)
|
||||
include(../component/deviceframe.pri)
|
||||
include(../component/RadioItemButton.pri)
|
||||
include(../component/fixlabel.pri)
|
||||
include(hiddenwifi/hiddenwifi.pri)
|
||||
|
||||
SOURCES += \
|
||||
itemframe.cpp \
|
||||
wlanconnect.cpp \
|
||||
|
|
|
@ -5,10 +5,11 @@ CONFIG += \
|
|||
qt \
|
||||
|
||||
SUBDIRS = \
|
||||
libkylin-nm-base/libkylin-nm-base.pro \
|
||||
plugins/plugin.pro \
|
||||
src-vpn/src-vpn.pro \
|
||||
src \
|
||||
sys-dbus-register \
|
||||
kylin-nm-plugin/kylin-nm-plugin.pro \
|
||||
kylin-nm-plugin/kylin-nm-plugin.pro
|
||||
|
||||
QT += widgets
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
<svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g filter="url(#filter0_i_6285_186732)">
|
||||
<path d="M9.59994 14.9488C9.59994 10.1061 13.3194 6.16587 18.1333 6.16587C22.9471 6.16587 26.8639 10.1061 26.8639 14.9488V26.3141H31.9999V14.9488C31.9999 7.25707 25.7791 1 18.1333 1C10.4874 1 4.2666 7.25707 4.2666 14.9488V22.1819H9.59994V14.9488Z" fill="#EAEAEA"/>
|
||||
</g>
|
||||
<path d="M0 19.1333H36.2667V40.7333C36.2667 42.9424 34.4758 44.7333 32.2667 44.7333H4C1.79086 44.7333 0 42.9424 0 40.7333V19.1333Z" fill="url(#paint0_linear_6285_186732)"/>
|
||||
<path d="M36.2667 19.1333H0V19.2997C4.63573 20.472 11.0475 21.1984 18.1333 21.1984C25.2192 21.1984 31.6309 20.472 36.2667 19.2997V19.1333Z" fill="#FCEFD2"/>
|
||||
<path d="M36.2667 19.1333H0V19.2506C4.63573 20.0752 11.0475 20.5861 18.1333 20.5861C25.2192 20.5861 31.6309 20.0752 36.2667 19.2506V19.1333Z" fill="#FFD18F"/>
|
||||
<path d="M22.4173 44.7333L22.5037 44.6469L22.6755 44.7333H23.66L25.1949 43.1984L24.3661 41.5418L25.6088 40.2992L27.2653 41.128L32.8931 35.5002C33.9437 36.0773 35.069 36.4677 36.2211 36.6757V19.1333L28.5667 20.5349C28.1741 20.8336 28.7043 21.113 27.7336 21.2666C26.8653 23.4629 28.1368 24.4496 28.8003 27.6666L11.8701 44.6874L22.4173 44.7333Z" fill="#DE9653"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M29.2526 15.8032C33.5417 11.5142 40.4942 11.5142 44.7833 15.8032C49.0723 20.0912 49.0723 27.0448 44.7854 31.3339C41.2515 34.8678 35.9139 35.4822 31.7433 33.1942L28.1155 36.8219L26.459 35.9931L25.2163 37.2358L26.0451 38.8923L24.1817 40.7558L23.3529 40.3419L22.1102 41.5846L22.5241 42.4134L21.2814 43.656L19.6249 42.8272L18.3822 44.0699L19.211 45.7264L17.2067 47.7307L12.1699 46.5542L12.2361 42.76L26.9838 28.0112C25.2014 23.9824 25.9513 19.1046 29.2526 15.8032ZM37.3294 18.9083C36.1283 20.1094 36.1283 22.056 37.3294 23.2571C38.5294 24.4582 40.4771 24.4582 41.6782 23.2571C42.8793 22.056 42.8793 20.1094 41.6782 18.9083C40.4771 17.7072 38.5305 17.7072 37.3294 18.9083Z" fill="url(#paint1_linear_6285_186732)"/>
|
||||
<path d="M17.2055 47.7297L19.2097 45.7254L18.3809 44.0689L19.6236 42.8262L21.2801 43.655L22.5228 42.4123L22.1089 41.5835L23.3505 40.3419L24.1793 40.7558L26.0428 38.8923L25.2151 37.2358L26.4577 35.9931L28.1143 36.8209L30.1847 34.7505L27.6993 33.5078L14.1836 47.0246L17.2055 47.7297Z" fill="url(#paint2_linear_6285_186732)"/>
|
||||
<path d="M12.1689 46.5539L26.458 32.2648L25.8361 31.644L12.1913 45.2888L12.1689 46.5539Z" fill="url(#paint3_linear_6285_186732)"/>
|
||||
<path d="M26.4579 32.2651L12.4355 46.2865L12.5913 46.6523L26.715 32.5233L26.4579 32.2651Z" fill="url(#paint4_linear_6285_186732)"/>
|
||||
<path d="M27.4009 28.4272L27.3988 28.4219L26.9828 28.0059L26.9849 28.0112L12.2361 42.76L12.1689 46.5541L12.5913 46.6523L12.6521 43.176L27.4009 28.4272Z" fill="url(#paint5_linear_6285_186732)"/>
|
||||
<path d="M44.7831 15.8032C40.494 11.5142 33.5415 11.5142 29.2524 15.8032C25.7783 19.2774 25.1202 24.4998 27.2748 28.6384L27.6119 28.3014C25.6247 24.3526 26.2722 19.4171 29.5692 16.12C33.6823 12.007 40.3522 12.007 44.4652 16.12C48.5783 20.2331 48.5783 26.903 44.4652 31.016C41.0903 34.391 35.998 34.9915 32.0055 32.8294L31.678 33.1568C35.8572 35.4864 41.2311 34.8848 44.782 31.3339C49.0722 27.0448 49.0722 20.0912 44.7831 15.8032Z" fill="url(#paint6_linear_6285_186732)"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M47.9319 22.3921C48.0801 25.382 47.0241 28.4198 44.7415 30.7025C41.2087 34.2353 35.87 34.8508 31.6993 32.5628L28.0716 36.1905L26.4151 35.3617L25.1724 36.6044L25.3964 37.0534L26.4567 35.9932L28.1132 36.822L31.7409 33.1942C35.9116 35.4822 41.2492 34.8678 44.7831 31.334C47.2279 28.8892 48.2732 25.5804 47.9319 22.3921ZM19.582 42.1948L21.2385 43.0236L22.2988 41.9633L22.5228 42.4124L21.2801 43.655L19.6236 42.8262L18.5633 43.8865L18.3393 43.4374L19.582 42.1948ZM19.2097 45.7265L18.9857 45.2774L17.1628 47.1004L14.6999 46.5052L14.1836 47.0246L17.2055 47.7308L19.2097 45.7265ZM23.3089 39.7116L24.1377 40.1254L25.8188 38.4444L26.0428 38.8934L24.1793 40.7569L23.3505 40.343L22.2903 41.4033L22.0663 40.9542L23.3089 39.7116Z" fill="url(#paint7_linear_6285_186732)"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M35.9619 21.1013C35.9619 19.1557 37.5395 17.5781 39.4851 17.5781C41.4307 17.5781 43.0083 19.1557 43.0083 21.1013C43.0083 23.0469 41.4307 24.6245 39.4851 24.6245C37.5395 24.6245 35.9619 23.0469 35.9619 21.1013ZM36.4099 21.1013C36.4099 22.7995 37.787 24.1765 39.4851 24.1765C41.1832 24.1765 42.5603 22.7995 42.5603 21.1013C42.5603 19.4032 41.1832 18.0261 39.4851 18.0261C37.787 18.0261 36.4099 19.4032 36.4099 21.1013Z" fill="url(#paint8_linear_6285_186732)"/>
|
||||
<path d="M37.3288 18.9094C38.5299 17.7083 40.4765 17.7083 41.6776 18.9094C42.0445 19.2763 42.2845 19.7158 42.4275 20.1787L46.8466 18.6822C46.3304 17.6443 45.6488 16.6683 44.7837 15.8032C40.4946 11.5142 33.541 11.5142 29.253 15.8032C26.5736 18.4816 25.5762 22.1979 26.2472 25.6571L36.6248 22.1435C36.2237 21.0523 36.453 19.784 37.3288 18.9094Z" fill="url(#paint9_linear_6285_186732)"/>
|
||||
<path d="M40.6454 24.7346C40.3777 24.485 40.6742 23.7309 41.3089 23.0503C41.9425 22.3698 42.6742 22.0199 42.9419 22.2695C43.2097 22.5191 42.9131 23.2733 42.2785 23.9538C41.6438 24.6343 40.9131 24.9831 40.6454 24.7346Z" fill="url(#paint10_radial_6285_186732)"/>
|
||||
<defs>
|
||||
<filter id="filter0_i_6285_186732" x="4.2666" y="0" width="27.7334" height="26.314" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
|
||||
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
||||
<feOffset dy="-1"/>
|
||||
<feGaussianBlur stdDeviation="1.5"/>
|
||||
<feComposite in2="hardAlpha" operator="arithmetic" k2="-1" k3="1"/>
|
||||
<feColorMatrix type="matrix" values="0 0 0 0 0.665151 0 0 0 0 0.619268 0 0 0 0 0.591884 0 0 0 1 0"/>
|
||||
<feBlend mode="normal" in2="shape" result="effect1_innerShadow_6285_186732"/>
|
||||
</filter>
|
||||
<linearGradient id="paint0_linear_6285_186732" x1="0" y1="44.0485" x2="34.3264" y2="44.0485" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#EEAE53"/>
|
||||
<stop offset="0.143919" stop-color="#FEC675"/>
|
||||
<stop offset="0.862824" stop-color="#EBB567"/>
|
||||
<stop offset="1" stop-color="#DA8A2C"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint1_linear_6285_186732" x1="49.4072" y1="48.5995" x2="49.6138" y2="10.5456" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#C3CFCF"/>
|
||||
<stop offset="1" stop-color="#C8C8C8"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint2_linear_6285_186732" x1="30.8129" y1="48.0813" x2="30.8887" y2="32.6819" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#B8B4B4"/>
|
||||
<stop offset="1" stop-color="#B0BDBD"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint3_linear_6285_186732" x1="27.0191" y1="46.9225" x2="27.1123" y2="30.7783" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#B8B4B4"/>
|
||||
<stop offset="1" stop-color="#B0BDBD"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint4_linear_6285_186732" x1="32.7105" y1="55.1596" x2="33.1696" y2="28.1678" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#6A6A6A"/>
|
||||
<stop offset="1" stop-color="#D4D4D4"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint5_linear_6285_186732" x1="23.4989" y1="37.1977" x2="19.05" y2="34.3633" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#6A6A6A"/>
|
||||
<stop offset="1" stop-color="#E0E0E0"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint6_linear_6285_186732" x1="50.5224" y1="21.6683" x2="35.5627" y2="5.58614" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#7F7F7F"/>
|
||||
<stop offset="1" stop-color="#EEEEEE"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint7_linear_6285_186732" x1="-1.53607" y1="60.8839" x2="15.2429" y2="47.353" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#515151"/>
|
||||
<stop offset="1" stop-color="#838383"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint8_linear_6285_186732" x1="44.8931" y1="20.96" x2="39.3454" y2="15.3493" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#EEEEEE"/>
|
||||
<stop offset="1" stop-color="#6A6A6A"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint9_linear_6285_186732" x1="49.3078" y1="27.0197" x2="47.4617" y2="13.3093" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0.048" stop-color="white" stop-opacity="0.01"/>
|
||||
<stop offset="0.994" stop-color="white" stop-opacity="0.5"/>
|
||||
</linearGradient>
|
||||
<radialGradient id="paint10_radial_6285_186732" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(41.8058 23.453) rotate(132.967) scale(1.51573 1.5122)">
|
||||
<stop stop-color="white"/>
|
||||
<stop offset="0.999" stop-color="white" stop-opacity="0.01"/>
|
||||
</radialGradient>
|
||||
</defs>
|
||||
</svg>
|
After Width: | Height: | Size: 8.4 KiB |
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifndef AGENTUTILS_H
|
||||
#define AGENTUTILS_H
|
||||
|
||||
#define VPN_TYPE "vpn"
|
||||
#define VPN_NAME "vpn"
|
||||
#define VPN_SERVICE "service-type"
|
||||
#define VPN_DATA "data"
|
||||
#define VPN_SECRET "secrets"
|
||||
#define VPN_FLAG "password-flags"
|
||||
|
||||
#define CONNECTION_KEY "connection"
|
||||
#define UUID_KEY "uuid"
|
||||
#define SSID_KEY "ssid"
|
||||
#define ID_KEY "id"
|
||||
#define TYPE_KEY "type"
|
||||
|
||||
|
||||
#define WIRELESS_SECURITY_NAME "802-11-wireless-security"
|
||||
#define KEY_MGMT "key-mgmt"
|
||||
|
||||
#define PSK_MGMT "wpa-psk"
|
||||
#define SAE_MGMT "sae"
|
||||
#define PSK_FLAG "psk-flags"
|
||||
#define PSK_KEY "psk"
|
||||
|
||||
#define WEP_MGMT "none"
|
||||
#define WEP128_MGMT "passphrase"
|
||||
#define WEP_FLAG_KEY "wep-key-flags"
|
||||
#define WEP_ID_KEY "wep-tx-keyidx"
|
||||
#define WEP_KEY0 "wep-key0"
|
||||
#define WEP_KEY1 "wep-key1"
|
||||
#define WEP_KEY2 "wep-key2"
|
||||
#define WEP_KEY3 "wep-key3"
|
||||
|
||||
#define LEAP_MGMT "ieee8021x"
|
||||
#define LEAP_PASSWORD_FLAG "leap-password-flags"
|
||||
#define LEAP_PASSWORD_KEY "leap-password"
|
||||
#define LEAP_USER_KEY "leap-username"
|
||||
|
||||
#define ENTERPRICE_NAME "802-1x"
|
||||
#define EAP_KEY "eap"
|
||||
#define PWD_EAP "pwd"
|
||||
#define LEAP_EAP "leap"
|
||||
#define FAST_EAP "fast"
|
||||
#define PEAP_EAP "peap"
|
||||
#define TTLS_EAP "ttls"
|
||||
#define TLS_EAP "tls"
|
||||
|
||||
#define IDENTITY_KEY "identity"
|
||||
|
||||
#define PASSWORD_FLAG "password-flags"
|
||||
#define PASSWORD_KEY "password"
|
||||
|
||||
#define PIN_FLAG "pin-flags"
|
||||
#define PIN_KEY "pin"
|
||||
|
||||
#define PHASE2_PRIVATE_KEY_FLAG "phase2-private-key-password-flags"
|
||||
#define PHASE2_PRIVATE_KEY "phase2-private-key-password"
|
||||
|
||||
#define PRIVATE_KEY_FLAG "private-key-password-flags"
|
||||
#define PRIVATE_KEY "private-key-password"
|
||||
#define DOMAIN_KEY "domain-suffix-match"
|
||||
|
||||
#define PHASE2_CLIENT_FLAG "phase2-client-cert-password-flags"
|
||||
#define PHASE2_CLIENT "phase2-client-cert-password"
|
||||
|
||||
#define PHASE2_CACERT_FLAG "phase2-ca-cert-password-flags"
|
||||
#define PHASE2_CACERT "phase2-ca-cert-password"
|
||||
|
||||
#define PHASE1_AUTH_FLAG "phase1-auth-flags"
|
||||
#define PHASE1_AUTH "phase1-auth"
|
||||
|
||||
#define CLIENT_CERT_FLAG "client-cert-password-flags"
|
||||
#define CLIENT_CERT "client-cert-password"
|
||||
|
||||
#define CACERT_FLAG "ca-cert-password-flags"
|
||||
#define CACERT "ca-cert-password"
|
||||
|
||||
|
||||
|
||||
enum SecretPolicyFlag{
|
||||
POLICY_NONE = 0,
|
||||
POLICY_AGENT_OWNED = 0x01,
|
||||
POLICY_NOT_SAVED = 0x02,
|
||||
POLICY_NOT_REQUIRED = 0x04
|
||||
};
|
||||
|
||||
enum SecretWepKeyId{
|
||||
KEY_TYPE0 = 0,
|
||||
KEY_TYPE1 = 1,
|
||||
KEY_TYPE2 = 2,
|
||||
KEY_TYPE3 = 3
|
||||
};
|
||||
|
||||
|
||||
#endif // AGENTUTILS_H
|
|
@ -0,0 +1,14 @@
|
|||
INCLUDEPATH += $$PWD
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/agentutils.h \
|
||||
$$PWD/kylinagent.h \
|
||||
$$PWD/kylinagentobject.h \
|
||||
$$PWD/kylinpassworddialog.h \
|
||||
$$PWD/kylinsecretagent.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/kylinagent.cpp \
|
||||
$$PWD/kylinagentobject.cpp \
|
||||
$$PWD/kylinpassworddialog.cpp \
|
||||
$$PWD/kylinsecretagent.cpp
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#include "kylinagent.h"
|
||||
#include <QApplication>
|
||||
#include <QTranslator>
|
||||
|
||||
KylinAgent::KylinAgent(QObject *parent) : QObject(parent)
|
||||
{
|
||||
QLocale local;
|
||||
QString locale = /*QLocale::system().*/local.name();
|
||||
QTranslator* translator = new QTranslator(this);
|
||||
if (translator->load(":/translations/kylin-keyring_"+ locale + ".qm")) {
|
||||
QApplication::installTranslator(translator);
|
||||
} else {
|
||||
// qWarning() << "Translations load fail";
|
||||
}
|
||||
}
|
||||
|
||||
KylinAgent::~KylinAgent()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void KylinAgent::startKylinAgent()
|
||||
{
|
||||
m_secretAgnet = new KylinSecretAgent("kylinagent", pWidget, this);
|
||||
}
|
||||
|
||||
//void KylinAgent::stopKylinAgent()
|
||||
//{
|
||||
// delete m_kylinAgnetObject;
|
||||
// m_kylinAgnetObject = nullptr;
|
||||
// return;
|
||||
//}
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifndef KYLINAGENT_H
|
||||
#define KYLINAGENT_H
|
||||
|
||||
#include "kylinsecretagent.h".h"
|
||||
|
||||
#if defined(LIBKYLIN_KEYRING_LIBRARY)
|
||||
# define LIBKYLIN_KEYRING_LIBRARY Q_DECL_EXPORT
|
||||
#else
|
||||
# define LIBKYLIN_KEYRING_LIBRARY Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
class LIBKYLIN_KEYRING_LIBRARY KylinAgent : public QObject
|
||||
{
|
||||
public:
|
||||
explicit KylinAgent(QObject *parent = nullptr);
|
||||
~KylinAgent();
|
||||
void startKylinAgent();
|
||||
void setParentWidget(QWidget *widget){
|
||||
pWidget = widget;
|
||||
}
|
||||
|
||||
private:
|
||||
KylinSecretAgent *m_secretAgnet;
|
||||
QWidget* pWidget = nullptr;
|
||||
};
|
||||
|
||||
|
||||
#endif // KYLINAGENT_H
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#include "kylinagentobject.h"
|
||||
|
||||
KylinAgentObject::KylinAgentObject(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
KylinAgentObject::~KylinAgentObject()
|
||||
{
|
||||
if (nullptr != m_secretAgnet) {
|
||||
delete m_secretAgnet;
|
||||
m_secretAgnet = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void KylinAgentObject::onInitAgent()
|
||||
{
|
||||
m_secretAgnet = new KylinSecretAgent("kylinagent");
|
||||
|
||||
return;
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifndef KYLINAGENTOBJECT_H
|
||||
#define KYLINAGENTOBJECT_H
|
||||
|
||||
#include "kylinsecretagent.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class KylinAgentObject : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit KylinAgentObject(QObject *parent = nullptr);
|
||||
~KylinAgentObject();
|
||||
|
||||
public Q_SLOTS:
|
||||
void onInitAgent();
|
||||
|
||||
private:
|
||||
KylinSecretAgent *m_secretAgnet;
|
||||
|
||||
};
|
||||
|
||||
#endif // KYLINAGENTOBJECT_H
|
|
@ -0,0 +1,508 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#include "kylinpassworddialog.h"
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QMessageBox>
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
#include <QApplication>
|
||||
|
||||
#define CLOSE_TIME 30*1000
|
||||
|
||||
|
||||
static QPalette lightPalette(QWidget *widget)
|
||||
{
|
||||
auto palette = widget->palette();
|
||||
//ukui-light palette UKUI3.1
|
||||
QColor windowText_at(38, 38, 38),
|
||||
windowText_iat(38, 38, 38),
|
||||
windowText_dis(166, 166, 166),
|
||||
button_at(230, 230, 230),
|
||||
button_iat(230, 230, 230),
|
||||
button_dis(233, 233, 233),
|
||||
light_at(255, 255, 255),
|
||||
light_iat(255, 255, 255),
|
||||
light_dis(242, 242, 242),
|
||||
midlight_at(218, 218, 218),
|
||||
midlight_iat(218, 218, 218),
|
||||
midlight_dis(230, 230, 230),
|
||||
dark_at(77, 77, 77),
|
||||
dark_iat(77, 77, 77),
|
||||
dark_dis(64, 64, 64),
|
||||
mid_at(115, 115, 115),
|
||||
mid_iat(115, 115, 115),
|
||||
mid_dis(102, 102, 102),
|
||||
text_at(38, 38, 38),
|
||||
text_iat(38, 38, 38),
|
||||
text_dis(140, 140, 140),
|
||||
brightText_at(89, 89, 89),
|
||||
brightText_iat(89, 89, 89),
|
||||
brightText_dis(77, 77, 77),
|
||||
buttonText_at(38, 38, 38),
|
||||
buttonText_iat(38, 38, 38),
|
||||
buttonText_dis(179, 179, 179),
|
||||
base_at(255, 255, 255),
|
||||
base_iat(245, 245, 245),
|
||||
base_dis(237, 237, 237),
|
||||
window_at(245, 245, 245),
|
||||
window_iat(237, 237, 237),
|
||||
window_dis(230, 230, 230),
|
||||
shadow_at(0, 0, 0, 16),
|
||||
shadow_iat(0, 0, 0, 16),
|
||||
shadow_dis(0, 0, 0, 21),
|
||||
// shadow_at(214, 214, 214),
|
||||
// shadow_iat(214, 214, 214),
|
||||
// shadow_dis(201, 201, 201),
|
||||
highLight_at(55, 144, 250),
|
||||
highLight_iat(55, 144, 250),
|
||||
highLight_dis(233, 233, 233),
|
||||
highLightText_at(255, 255, 255),
|
||||
highLightText_iat(255, 255, 255),
|
||||
highLightText_dis(179, 179, 179),
|
||||
link_at(55, 144, 250),
|
||||
link_iat(55, 144, 250),
|
||||
link_dis(55, 144, 250),
|
||||
linkVisited_at(114, 46, 209),
|
||||
linkVisited_iat(114, 46, 209),
|
||||
linkVisited_dis(114, 46, 209),
|
||||
alternateBase_at(245, 245, 245),
|
||||
alternateBase_iat(245, 245, 245),
|
||||
alternateBase_dis(245, 245, 245),
|
||||
noRale_at(240, 240, 240),
|
||||
noRole_iat(240, 240, 240),
|
||||
noRole_dis(217, 217, 217),
|
||||
toolTipBase_at(255, 255, 255),
|
||||
toolTipBase_iat(255, 255, 255),
|
||||
toolTipBase_dis(255, 255, 255),
|
||||
toolTipText_at(38, 38, 38),
|
||||
toolTipText_iat(38, 38, 38),
|
||||
toolTipText_dis(38, 38, 38),
|
||||
placeholderText_at(38, 38, 38),
|
||||
placeholderText_iat(38, 38, 38),
|
||||
placeholderText_dis(38, 38, 38);
|
||||
|
||||
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::WindowText, windowText_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::WindowText, windowText_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::WindowText, windowText_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::Button, button_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::Button, button_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::Button, button_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::Light, light_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::Light, light_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::Light, light_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::Midlight, midlight_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::Midlight, midlight_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::Midlight, midlight_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::Dark, dark_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::Dark, dark_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::Dark, dark_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::Mid, mid_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::Mid, mid_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::Mid, mid_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::Text, text_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::Text, text_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::Text, text_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::BrightText, brightText_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::BrightText, brightText_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::BrightText, brightText_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::ButtonText, buttonText_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::ButtonText, buttonText_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::ButtonText, buttonText_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::Base, base_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::Base, base_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::Base, base_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::Window, window_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::Window, window_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::Window, window_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::Shadow, shadow_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::Shadow, shadow_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::Shadow, shadow_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::Highlight, highLight_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::Highlight, highLight_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::Highlight, highLight_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::HighlightedText, highLightText_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::HighlightedText, highLightText_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::HighlightedText, highLightText_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::Link, link_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::Link, link_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::Link, link_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::LinkVisited, linkVisited_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::LinkVisited, linkVisited_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::LinkVisited, linkVisited_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::AlternateBase, alternateBase_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::AlternateBase, alternateBase_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::AlternateBase, alternateBase_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::NoRole, noRale_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::NoRole, noRole_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::NoRole, noRole_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::ToolTipBase, toolTipBase_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::ToolTipBase, toolTipBase_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::ToolTipBase, toolTipBase_dis);
|
||||
|
||||
palette.setColor(QPalette::Active, QPalette::ToolTipText, toolTipText_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::ToolTipText, toolTipText_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::ToolTipText, toolTipText_dis);
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5,12,0))
|
||||
palette.setColor(QPalette::Active, QPalette::PlaceholderText, placeholderText_at);
|
||||
palette.setColor(QPalette::Inactive, QPalette::PlaceholderText, placeholderText_iat);
|
||||
palette.setColor(QPalette::Disabled, QPalette::PlaceholderText, placeholderText_dis);
|
||||
#endif
|
||||
|
||||
return palette;
|
||||
|
||||
}
|
||||
|
||||
RowWidget::RowWidget(QWidget *widget, QWidget *parent) : valueWidget(widget), QWidget(parent)
|
||||
{
|
||||
mainLayout = new QHBoxLayout(this);
|
||||
mainLayout->setContentsMargins(0,0,0,0);
|
||||
this->setLayout(mainLayout);
|
||||
keyLabel = new QLabel(this);
|
||||
keyLabel->setMaximumWidth(87);
|
||||
valueWidget->setMinimumWidth(280);
|
||||
mainLayout->addWidget(keyLabel);
|
||||
mainLayout->addStretch();
|
||||
mainLayout->addWidget(valueWidget);
|
||||
}
|
||||
|
||||
RowWidget::~RowWidget()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RowWidget::setKey(QString text)
|
||||
{
|
||||
this->keyLabel->setText(text);
|
||||
}
|
||||
|
||||
KyPasswordDialog::KyPasswordDialog(QString dialogType, QString connectionID, QWidget *parent)
|
||||
:connectionID(connectionID),dialogType(dialogType),QDialog(parent)
|
||||
{
|
||||
this->setAttribute(Qt::WA_QuitOnClose, false);
|
||||
// this->setWindowFlags(Qt::Dialog);
|
||||
// this->setWindowIcon(QIcon::fromTheme("kylin-network"));
|
||||
// this->setWindowTitle(connectionID);
|
||||
|
||||
initUI(dialogType);
|
||||
m_sdkPasswdEdit->installEventFilter(this);
|
||||
this->setWindowFlags(Qt::MSWindowsFixedSizeDialogHint);
|
||||
|
||||
connect(qApp, &QApplication::paletteChanged, this, &KyPasswordDialog::onPaletteChanged);
|
||||
onPaletteChanged();
|
||||
}
|
||||
|
||||
void KyPasswordDialog::showDesktopNotify(const QString &message)
|
||||
{
|
||||
QDBusInterface iface("org.freedesktop.Notifications",
|
||||
"/org/freedesktop/Notifications",
|
||||
"org.freedesktop.Notifications",
|
||||
QDBusConnection::sessionBus());
|
||||
QList<QVariant> args;
|
||||
args<<(tr("Kylin NM"))
|
||||
<<((unsigned int) 0)
|
||||
<<QString("gnome-dev-ethernet")
|
||||
<<tr("kylin network desktop message") //显示的是什么类型的信息
|
||||
<<message //显示的具体信息
|
||||
<<QStringList()
|
||||
<<QVariantMap()
|
||||
<<(int)-1;
|
||||
iface.callWithArgumentList(QDBus::AutoDetect,"Notify",args);
|
||||
}
|
||||
|
||||
KyPasswordDialog::~KyPasswordDialog(){
|
||||
|
||||
}
|
||||
|
||||
void KyPasswordDialog::InitConnect()
|
||||
{
|
||||
connect(m_connectBtn, &QPushButton::clicked, this, &KyPasswordDialog::login);
|
||||
connect(m_exitBtn, &QPushButton::clicked, this, &KyPasswordDialog::reject);
|
||||
connect(m_sdkPasswdEdit, &KPasswordEdit::textChanged, this, &KyPasswordDialog::onTextChanged);
|
||||
if (m_usrLineEdit != nullptr) {
|
||||
connect(m_usrLineEdit, &QLineEdit::textChanged, this, &KyPasswordDialog::onTextChanged);
|
||||
}
|
||||
QTimer::singleShot(CLOSE_TIME, this, [=](){
|
||||
reject();
|
||||
});
|
||||
}
|
||||
|
||||
void KyPasswordDialog::initUI(QString dialogType)
|
||||
{
|
||||
#define MAIN_LAYOUT_MARGINS 24,24,24,24
|
||||
#define DEFAULT_LAYOUT_MARGINS 0,0,0,0
|
||||
|
||||
#define DEFAULT_LAYOUT_SPACE 24
|
||||
#define LESS_LAYOUT_SPACE 16
|
||||
|
||||
#define DEFAULT_BTN_FIXSIZE 112,56
|
||||
#define DEFAULT_FIXHEIGHT 48
|
||||
#define DEFAULT_PICTURE_FIXSIZE 48,48
|
||||
|
||||
#define DEFAULT_EDIT_SIZE 278,48
|
||||
#define WPA2_EDIT_SIZE 270,48
|
||||
|
||||
#define DEFAULT_PAGE_SIZE 446,283
|
||||
#define WPA2_PAGE_SIZE 446,339
|
||||
|
||||
//设置字体大小
|
||||
QFont fontTitle;
|
||||
fontTitle.setPointSizeF(13.5);
|
||||
fontTitle.setWeight(QFont::Bold);
|
||||
QFont fontNormal;
|
||||
fontNormal.setPointSizeF(11.5);
|
||||
fontNormal.setWeight(QFont::Normal);
|
||||
|
||||
//主布局
|
||||
QVBoxLayout *mainVBoxLayout = new QVBoxLayout(this);
|
||||
mainVBoxLayout->setContentsMargins(MAIN_LAYOUT_MARGINS);
|
||||
mainVBoxLayout->setSpacing(DEFAULT_LAYOUT_SPACE);
|
||||
this->setLayout(mainVBoxLayout);
|
||||
|
||||
//不包含按钮的横向布局
|
||||
QHBoxLayout *hBoxLayout = new QHBoxLayout(this);
|
||||
hBoxLayout->setContentsMargins(DEFAULT_LAYOUT_MARGINS);
|
||||
hBoxLayout->setSpacing(DEFAULT_LAYOUT_SPACE);
|
||||
|
||||
//图标
|
||||
QLabel *picture = new QLabel(this);
|
||||
picture->setContentsMargins(DEFAULT_LAYOUT_MARGINS);
|
||||
picture->setFixedSize(DEFAULT_PICTURE_FIXSIZE);
|
||||
picture->setPixmap(QPixmap(":/authorize.svg"));
|
||||
|
||||
//标题
|
||||
QLabel *titleLabel = new QLabel(this);
|
||||
titleLabel->setText(tr("Wi-Fi authentication required"));
|
||||
titleLabel->setFont(fontTitle);
|
||||
|
||||
//提示信息
|
||||
QLabel *tipLabel = new QLabel(this);
|
||||
tipLabel->setFixedSize(328, DEFAULT_FIXHEIGHT);
|
||||
tipLabel->setAlignment(Qt::AlignTop);
|
||||
tipLabel->setWordWrap(true);
|
||||
QString text = tr("Access wireless networks");
|
||||
text += " " + connectionID + " ";
|
||||
text += tr("needs password or encryption key");
|
||||
tipLabel->setText(text);
|
||||
tipLabel->setFont(fontNormal);
|
||||
|
||||
//密码输入框
|
||||
QLabel *pwdLabel = new QLabel(this);
|
||||
pwdLabel->setText(tr("password"));
|
||||
pwdLabel->setFont(fontNormal);
|
||||
m_sdkPasswdEdit = new KPasswordEdit(this);
|
||||
if (dialogType != "") {
|
||||
this->setFixedSize(WPA2_PAGE_SIZE);
|
||||
m_sdkPasswdEdit->setFixedSize(WPA2_EDIT_SIZE);
|
||||
} else {
|
||||
this->setFixedSize(DEFAULT_PAGE_SIZE);
|
||||
m_sdkPasswdEdit->setFixedSize(DEFAULT_EDIT_SIZE);
|
||||
}
|
||||
m_sdkPasswdEdit->setClearButtonEnabled(false);
|
||||
m_sdkPasswdEdit->setState(LoginFailed);
|
||||
m_sdkPasswdEdit->setAttribute(Qt::WA_InputMethodEnabled, true);
|
||||
QRegExp rx("^[A-Za-z0-9`~!@#$%^&*()_-+=<>,.\\\/]+$");
|
||||
QRegExpValidator *latitude = new QRegExpValidator(rx, this);
|
||||
m_sdkPasswdEdit->setValidator(latitude);
|
||||
|
||||
//密码输入框布局
|
||||
QHBoxLayout *pwdLayout = new QHBoxLayout(this);
|
||||
pwdLayout->setContentsMargins(DEFAULT_LAYOUT_MARGINS);
|
||||
if (dialogType != "") {
|
||||
pwdLayout->setSpacing(DEFAULT_LAYOUT_SPACE);
|
||||
} else {
|
||||
pwdLayout->setSpacing(LESS_LAYOUT_SPACE);
|
||||
}
|
||||
pwdLayout->addWidget(pwdLabel);
|
||||
pwdLayout->addWidget(m_sdkPasswdEdit);
|
||||
|
||||
//不包含图标的纵向布局
|
||||
QVBoxLayout *contentLayout = new QVBoxLayout(this);
|
||||
contentLayout->setContentsMargins(DEFAULT_LAYOUT_MARGINS);
|
||||
contentLayout->setSpacing(LESS_LAYOUT_SPACE);
|
||||
contentLayout->setAlignment(Qt::AlignTop);
|
||||
contentLayout->addWidget(titleLabel);
|
||||
contentLayout->addWidget(tipLabel);
|
||||
if (dialogType != "") {
|
||||
//WPA2企业加密方式用户名输入框
|
||||
QLabel *userNameLabel = new QLabel(this);
|
||||
userNameLabel->setText(tr("user name"));
|
||||
userNameLabel->setFont(fontNormal);
|
||||
m_usrLineEdit = new QLineEdit(this);
|
||||
m_usrLineEdit->setFixedSize(WPA2_EDIT_SIZE);
|
||||
|
||||
//用户名输入框布局
|
||||
QHBoxLayout *userNameLayout = new QHBoxLayout(this);
|
||||
userNameLayout->setContentsMargins(DEFAULT_LAYOUT_MARGINS);
|
||||
userNameLayout->setSpacing(8);
|
||||
userNameLayout->addWidget(userNameLabel);
|
||||
userNameLayout->addWidget(m_usrLineEdit);
|
||||
contentLayout->addLayout(userNameLayout);
|
||||
}
|
||||
contentLayout->addLayout(pwdLayout);
|
||||
|
||||
//连接按钮
|
||||
m_connectBtn = new QPushButton(this);
|
||||
m_connectBtn->setText(tr("Connect"));
|
||||
m_connectBtn->setFont(fontNormal);
|
||||
m_connectBtn->setFixedSize(DEFAULT_BTN_FIXSIZE);
|
||||
|
||||
//取消按钮
|
||||
m_exitBtn = new QPushButton(this);
|
||||
m_exitBtn->setText(tr("Cancel"));
|
||||
m_exitBtn->setFont(fontNormal);
|
||||
m_exitBtn->setFixedSize(DEFAULT_BTN_FIXSIZE);
|
||||
|
||||
//按钮布局
|
||||
QHBoxLayout *btnLayout = new QHBoxLayout(this);
|
||||
btnLayout->setContentsMargins(DEFAULT_LAYOUT_MARGINS);
|
||||
btnLayout->setSpacing(LESS_LAYOUT_SPACE);
|
||||
btnLayout->addStretch();
|
||||
btnLayout->addWidget(m_exitBtn);
|
||||
btnLayout->addWidget(m_connectBtn);
|
||||
|
||||
hBoxLayout->addWidget(picture);
|
||||
hBoxLayout->setAlignment(picture, Qt::AlignTop);
|
||||
hBoxLayout->addLayout(contentLayout);
|
||||
|
||||
mainVBoxLayout->addLayout(hBoxLayout);
|
||||
mainVBoxLayout->addLayout(btnLayout);
|
||||
|
||||
if (m_usrLineEdit == nullptr) {
|
||||
showDesktopNotify(tr("password error!"));
|
||||
} else {
|
||||
showDesktopNotify(tr("username or password error!"));
|
||||
}
|
||||
}
|
||||
|
||||
QString KyPasswordDialog::getPassword()
|
||||
{
|
||||
return m_sdkPasswdEdit->text();
|
||||
}
|
||||
|
||||
void KyPasswordDialog::setPassword(QString password)
|
||||
{
|
||||
m_sdkPasswdEdit->setText(password);
|
||||
m_sdkPasswdEdit->setFocus();
|
||||
}
|
||||
|
||||
QString KyPasswordDialog::getUserName()
|
||||
{
|
||||
return m_usrLineEdit->text();
|
||||
}
|
||||
|
||||
void KyPasswordDialog::setUserName(QString name)
|
||||
{
|
||||
m_usrLineEdit->setText(name);
|
||||
}
|
||||
|
||||
void KyPasswordDialog::login()
|
||||
{
|
||||
qDebug() << "KyPasswordDialog login";
|
||||
if ((!m_sdkPasswdEdit->text().isEmpty()) && (m_usrLineEdit == nullptr? true : (!m_usrLineEdit->text().isEmpty()))) {
|
||||
accept();
|
||||
} else {
|
||||
m_sdkPasswdEdit->clear();
|
||||
if (m_usrLineEdit != nullptr) {
|
||||
m_usrLineEdit->clear();
|
||||
m_usrLineEdit->setFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KyPasswordDialog::onTextChanged(const QString & text)
|
||||
{
|
||||
qDebug() << "KyPasswordDialog onTextChanged";
|
||||
m_sdkPasswdEdit->setState(Ordinary);
|
||||
if (text == "") {
|
||||
//任何输入框为空,则不许按下连接按钮
|
||||
m_connectBtn->setEnabled(false);
|
||||
return ;
|
||||
}
|
||||
|
||||
if (m_usrLineEdit != nullptr) {
|
||||
//企业网修改密码页面
|
||||
if (!m_usrLineEdit->text().isEmpty() && !m_sdkPasswdEdit->text().isEmpty()) {
|
||||
//用户名和密码均不为空,允许按下连接按钮
|
||||
m_connectBtn->setEnabled(true);
|
||||
} else {
|
||||
m_connectBtn->setEnabled(false);
|
||||
}
|
||||
return ;
|
||||
}
|
||||
|
||||
if (m_sdkPasswdEdit->text().isEmpty() || m_sdkPasswdEdit->text().length() < 8) {
|
||||
//普通热点密码修改页面,若密码为空,或长度小于8位,不许按下连接按钮
|
||||
m_connectBtn->setEnabled(false);
|
||||
return ;
|
||||
}
|
||||
|
||||
m_connectBtn->setEnabled(true);
|
||||
}
|
||||
|
||||
|
||||
void KyPasswordDialog::onPaletteChanged()
|
||||
{
|
||||
QPalette pal = lightPalette(this);
|
||||
|
||||
this->setPalette(pal);
|
||||
m_sdkPasswdEdit->setPalette(pal);
|
||||
if (nullptr != m_usrLineEdit)
|
||||
m_usrLineEdit->setPalette(pal);
|
||||
|
||||
// setFramePalette(this, pal);
|
||||
}
|
||||
|
||||
void KyPasswordDialog::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPalette pal = this->palette();
|
||||
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter:: Antialiasing, true); //设置渲染,启动反锯齿
|
||||
painter.setPen(Qt::NoPen);
|
||||
painter.setBrush(pal.color(QPalette::Base));
|
||||
|
||||
QRect rect = this->rect();
|
||||
painter.drawRoundedRect(rect, 12, 12);
|
||||
|
||||
|
||||
QDialog::paintEvent(event);
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifndef KYLINPASSWORDDIALOG_H
|
||||
#define KYLINPASSWORDDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QVBoxLayout>
|
||||
#include <QFormLayout>
|
||||
#include <QCheckBox>
|
||||
#include <QRegExpValidator>
|
||||
#include <QTimer>
|
||||
#include <QDBusInterface>
|
||||
|
||||
#include "kpasswordedit.h"
|
||||
|
||||
using namespace kdk;
|
||||
|
||||
class RowWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
RowWidget(QWidget *widget, QWidget *parent = nullptr);
|
||||
~RowWidget();
|
||||
void setKey(QString text);
|
||||
|
||||
private:
|
||||
QHBoxLayout *mainLayout;
|
||||
QLabel *keyLabel;
|
||||
QWidget *valueWidget;
|
||||
};
|
||||
|
||||
class KyPasswordDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
KyPasswordDialog(QString dialogType, QString connectionID = "", QWidget *parent = 0);
|
||||
~KyPasswordDialog();
|
||||
|
||||
void showDesktopNotify(const QString &message);
|
||||
|
||||
void InitConnect();
|
||||
private:
|
||||
QString dialogType;
|
||||
QString connectionID;
|
||||
|
||||
QLineEdit *m_usrLineEdit = nullptr;
|
||||
QPushButton *m_connectBtn = nullptr;
|
||||
QPushButton *m_exitBtn = nullptr;
|
||||
|
||||
KPasswordEdit *m_sdkPasswdEdit = nullptr;
|
||||
|
||||
void onPaletteChanged();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
|
||||
public:
|
||||
void initUI(QString dialogType);
|
||||
|
||||
QString getPassword();
|
||||
void setPassword(QString password);
|
||||
|
||||
QString getUserName();
|
||||
void setUserName(QString name);
|
||||
|
||||
private Q_SLOTS:
|
||||
void login();
|
||||
void onTextChanged(const QString &);
|
||||
|
||||
Q_SIGNALS:
|
||||
void signal_username(QString);
|
||||
};
|
||||
|
||||
#endif // KYLINPASSWORDDIALOG_H
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,129 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifndef KYLINSECRETAGENT_H
|
||||
#define KYLINSECRETAGENT_H
|
||||
|
||||
#include <libsecret/secret.h>
|
||||
|
||||
#include <QObject>
|
||||
//#include <NetworkManagerQt/SecretAgent>
|
||||
#include "networkmanagerqt/secretagent.h"
|
||||
|
||||
#include "agentutils.h"
|
||||
|
||||
class KylinSecretAgent: public NetworkManager::SecretAgent
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit KylinSecretAgent(const QString &id, QWidget *pWidget = nullptr, QObject *parent = nullptr);
|
||||
~KylinSecretAgent();
|
||||
|
||||
private:
|
||||
QWidget *parentWidget = nullptr;
|
||||
void saveOneSecret(QString &connectUuid, QString settingName,
|
||||
QString secretKey, QString &secretValue, QString &displayNmae);
|
||||
void saveConnectSecret(QVariantMap &securityMap, QString secretSettingName,
|
||||
QString &secretKey, QString &connectId, QString &connectUuid);
|
||||
|
||||
void saveWepSecret(QVariantMap &wirelessSecurityMap,
|
||||
QString &connectId, QString &connectUuid);
|
||||
void saveWirelessSecret(QVariantMap &wirelessSecurityMap,
|
||||
QString &connectId, QString &connectUuid);
|
||||
|
||||
void saveEnterpriceSecret(QVariantMap &enterpriceSecurityMap,
|
||||
QString &connectId, QString &connectUuidd);
|
||||
|
||||
void saveSecretForWireless(const NMVariantMapMap &connection,
|
||||
QString &connectId, QString &connectUuid);
|
||||
|
||||
QStringList getVpnPassword(QVariantMap &vpnSettingMap);
|
||||
QString getVpnDataItemByKey(QVariantMap &vpnSettingMap, QString key);
|
||||
void saveSecretForVpn(QVariantMap &vpnSetingMap,
|
||||
QString &connectId, QString &connectUuid);
|
||||
|
||||
void getSecretFromKeyring(GList *p_secretList, const QString &settingName,
|
||||
QString connectType, NMVariantMapMap &secretMap);
|
||||
bool hintIsFind(GList *p_secretList, const QStringList &hints);
|
||||
bool connectionIsAlwaysAsk(const NMVariantMapMap &connection);
|
||||
QString getWepKeyFromId(uint wepId);
|
||||
|
||||
|
||||
void askSecretForLeap(QVariantMap &wirelessSecurityMap,
|
||||
const QString &settingName, NMVariantMapMap &secretMap, QString connectionID);
|
||||
void askSecretForWep(QVariantMap &wirelessSecurityMap,
|
||||
const QString &settingName, NMVariantMapMap &secretMap, QString connectionID);
|
||||
void askSecretForPassword(QVariantMap &securityMap, QString passwordKey,
|
||||
const QString &settingName, NMVariantMapMap &secretMap, QString connectionID);
|
||||
void askSecretForWireless(const NMVariantMapMap &connection,
|
||||
const QString settingName, NMVariantMapMap &secretMap);
|
||||
|
||||
void askSecretForTls(QVariantMap securityMap,
|
||||
const QString &settingName, NMVariantMapMap &secretMap, QString connectionID);
|
||||
void askSecretWithIdentityAndPassword(QVariantMap securityMap, QString userKey,
|
||||
QString passwordKey, const QString &settingName, NMVariantMapMap &secretMap, QString connectionID);
|
||||
void askSecretForEnterpriceWireless(const NMVariantMapMap &connection,
|
||||
const QString settingName, NMVariantMapMap &secretMap);
|
||||
void askSecretForVpn(const NMVariantMapMap &connection,
|
||||
const QString settingName, NMVariantMapMap &secretMap);
|
||||
void askForSecret(const NMVariantMapMap &connection, const QString &settingName,
|
||||
QString connectType, NMVariantMapMap &secretMap);
|
||||
|
||||
public Q_SLOTS:
|
||||
|
||||
/*
|
||||
* kylin-nm的agent功能主要是实现如下四个函数,这四个函数继承自父类NetworkManager::SecretAgent
|
||||
* 当发生错误的时候,调用父类的sendError函数,给networkmanager返回结果
|
||||
* 调试方式
|
||||
* 根据kylin-nm移植的nm-applet的agent功能代码添加日志,进行流程调试梳理,完成了该代码的开发,
|
||||
* 后续出了问题可以通过这种方式理顺流程调试解决问题。
|
||||
* 注意事项:
|
||||
* 1)所有的函数keyring、的操作都是同步的,需要其单独的agent线程,否则容易阻塞
|
||||
* 2)目前代码只是对能够测试到的情况做了代码实现,有可能会有遗漏的地方,后续出现新情况,在完善。
|
||||
*/
|
||||
|
||||
/*
|
||||
* 该函数从秘钥环上面获取密码,并将获取到的密码组成安全的mapmap返回,失败后通过sendError返回错误,
|
||||
* 函数的返回值将变得无效
|
||||
*/
|
||||
NMVariantMapMap GetSecrets(const NMVariantMapMap &connection, const QDBusObjectPath &connection_path,
|
||||
const QString &setting_name, const QStringList &hints, uint flags);
|
||||
|
||||
/*
|
||||
* 该函数用于取消agent的操作,从测试的情况来看,目前没有发现在什么时候会出现这种情况
|
||||
* 暂时未实现,后期注意观察,出现问题后根据具体情况实现,
|
||||
* 返回值为空,如果出现错误,通过sendError返回错误
|
||||
*/
|
||||
void CancelGetSecrets(const QDBusObjectPath &connection_path, const QString &setting_name);
|
||||
|
||||
/*
|
||||
* 该函数将密码保存到keyring上面,要保存的密码可以在connection参数中查找到,
|
||||
* 返回值为空,如果出现错误,通过sendError返回错误
|
||||
*/
|
||||
void SaveSecrets(const NMVariantMapMap &connection, const QDBusObjectPath &connection_path);
|
||||
/*
|
||||
* 该函数将密码从keyring上面删除,返回值为空,如果出现错误,通过sendError返回错误
|
||||
*/
|
||||
void DeleteSecrets(const NMVariantMapMap &connection, const QDBusObjectPath &connection_path);
|
||||
|
||||
private:
|
||||
QMap<QString, QString> enterpriceInfo;
|
||||
QMap<QString, QString> wirelessInfo;
|
||||
};
|
||||
|
||||
#endif // KYLINSECRETAGENT_H
|
|
@ -0,0 +1,75 @@
|
|||
QT += core gui x11extras dbus KWindowSystem svg concurrent network
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
TARGET = kylin-keyring
|
||||
TEMPLATE = lib
|
||||
DEFINES += LIBKYLIN_KEYRING_LIBRARY
|
||||
|
||||
CONFIG += c++14 qt warn_on link_pkgconfig console
|
||||
CONFIG += no_keywords
|
||||
|
||||
PKGCONFIG +=gio-2.0 glib-2.0 gio-unix-2.0 libnm libnma libsecret-1 gsettings-qt libcap kysdk-qtwidgets
|
||||
#gtk+-3.0
|
||||
INCLUDEPATH += /usr/include/KF5/NetworkManagerQt
|
||||
|
||||
LIBS += -L/usr/lib/ -lKF5NetworkManagerQt
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
# any Qt feature that has been marked 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 it uses 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)
|
||||
|
||||
#include(kylin-agent/kylin-agent.pri)
|
||||
INCLUDEPATH += $$PWD
|
||||
INCLUDEPATH += ./kylin-agent
|
||||
|
||||
HEADERS += \
|
||||
./kylin-agent/agentutils.h \
|
||||
./kylin-agent/kylinagent.h \
|
||||
# ./kylin-agent/kylinagentobject.h \
|
||||
./kylin-agent/kylinpassworddialog.h \
|
||||
./kylin-agent/kylinsecretagent.h
|
||||
|
||||
SOURCES += \
|
||||
./kylin-agent/kylinagent.cpp \
|
||||
# ./kylin-agent/kylinagentobject.cpp \
|
||||
./kylin-agent/kylinpassworddialog.cpp \
|
||||
./kylin-agent/kylinsecretagent.cpp \
|
||||
|
||||
TRANSLATIONS += \
|
||||
./translations/kylin-keyring_zh_CN.ts \
|
||||
./translations/kylin-keyring_tr.ts \
|
||||
./translations/kylin-keyring_bo.ts \
|
||||
./translations/kylin-keyring_bo_CN.ts
|
||||
|
||||
unix {
|
||||
target.path = /usr/lib/
|
||||
|
||||
manager.path = /usr/include/kylin-nm/kylin-agent
|
||||
manager.files = kylin-agent/agentutils.h \
|
||||
kylin-agent/kylinagent.h \
|
||||
kylin-agent/kylinagentobject.h \
|
||||
kylin-agent/kylinpassworddialog.h \
|
||||
kylin-agent/kylinsecretagent.h
|
||||
|
||||
INSTALLS += manager \
|
||||
trans
|
||||
}
|
||||
!isEmpty(target.path): INSTALLS += target
|
||||
|
||||
|
||||
RESOURCES += \
|
||||
svg.qrc
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QWidget>
|
||||
#include "kylinagent.h"
|
||||
#include <QTranslator>
|
||||
|
||||
bool isAppRuning();
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
QApplication a(argc, argv);
|
||||
|
||||
KylinAgent* agent = new KylinAgent();
|
||||
agent->startKylinAgent();
|
||||
|
||||
QTranslator trans_global;
|
||||
qDebug() << "QLocale " << QLocale();
|
||||
if (trans_global.load(QLocale(), "kylin-keyring", "_", "/usr/share/kylin-keyring/"))
|
||||
{
|
||||
a.installTranslator(&trans_global);
|
||||
qDebug()<<"Translations load success";
|
||||
} else {
|
||||
qWarning() << "Translations load fail";
|
||||
}
|
||||
|
||||
return a.exec();
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>authorize.svg</file>
|
||||
<file>translations/kylin-keyring_zh_CN.qm</file>
|
||||
<file>translations/kylin-keyring_bo_CN.qm</file>
|
||||
</qresource>
|
||||
</RCC>
|
|
@ -0,0 +1,75 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="bo_CN">
|
||||
<context>
|
||||
<name>KyPasswordDialog</name>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="57"/>
|
||||
<source>Kylin NM</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="60"/>
|
||||
<source>kylin network desktop message</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="130"/>
|
||||
<source>Wi-Fi authentication required</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="138"/>
|
||||
<source>Access wireless networks</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="140"/>
|
||||
<source>needs password or encryption key</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="185"/>
|
||||
<source>user name</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="202"/>
|
||||
<source>Connect</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="208"/>
|
||||
<source>Cancel</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="228"/>
|
||||
<source>password error!</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="230"/>
|
||||
<source>username or password error!</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="146"/>
|
||||
<source>password</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>KylinSecretAgent</name>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinsecretagent.cpp" line="454"/>
|
||||
<source>userAndPwd</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinsecretagent.cpp" line="513"/>
|
||||
<source>tls</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
Binary file not shown.
|
@ -0,0 +1,75 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="bo_CN">
|
||||
<context>
|
||||
<name>KyPasswordDialog</name>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="223"/>
|
||||
<source>Kylin NM</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="226"/>
|
||||
<source>kylin network desktop message</source>
|
||||
<translation>དྲ་རྒྱའི་གསལ་འདེབས་ཆ་འཕྲིན།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="296"/>
|
||||
<source>Wi-Fi authentication required</source>
|
||||
<translation>སྐུད་མེད་དྲ་རྒྱ་འདི་ལ་གསང་བའི་བདེན་དཔང་ར་སྤྲོད་བྱེད་དགོས།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="304"/>
|
||||
<source>Access wireless networks</source>
|
||||
<translation>སྐུད་མེད་དྲ་རྒྱར་བཅར་འདྲི་བྱེད་པ།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="306"/>
|
||||
<source>needs password or encryption key</source>
|
||||
<translation>གསང་བ་དང་གསང་བའི་ལྡེ་མིག་དགོས།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="312"/>
|
||||
<source>password</source>
|
||||
<translation>གསང་བའི་ཨང་གྲངས།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="350"/>
|
||||
<source>user name</source>
|
||||
<translation>སྤྱོད་མཁན་གྱི་མིང་།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="367"/>
|
||||
<source>Connect</source>
|
||||
<translation>འབྲེལ་མཐུད་བཅས་བྱ་དགོས།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="373"/>
|
||||
<source>Cancel</source>
|
||||
<translation>མེད་པར་བཟོ་དགོས།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="393"/>
|
||||
<source>password error!</source>
|
||||
<translation>གསང་བའི་ཨང་གྲངས་ནོར་བ།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="395"/>
|
||||
<source>username or password error!</source>
|
||||
<translation>སྤྱོད་མཁན་གྱི་མིང་ངམ་གསང་གྲངས་ནོར་འཁྲུལ་རེད།</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>KylinSecretAgent</name>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinsecretagent.cpp" line="465"/>
|
||||
<source>userAndPwd</source>
|
||||
<translation>སྤྱོད་མཁན་གྱི་མིང་དང་གསང་གྲངས།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinsecretagent.cpp" line="527"/>
|
||||
<source>tls</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
|
@ -0,0 +1,75 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="tr_TR">
|
||||
<context>
|
||||
<name>KyPasswordDialog</name>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="57"/>
|
||||
<source>Kylin NM</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="60"/>
|
||||
<source>kylin network desktop message</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="130"/>
|
||||
<source>Wi-Fi authentication required</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="138"/>
|
||||
<source>Access wireless networks</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="140"/>
|
||||
<source>needs password or encryption key</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="185"/>
|
||||
<source>user name</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="202"/>
|
||||
<source>Connect</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="208"/>
|
||||
<source>Cancel</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="228"/>
|
||||
<source>password error!</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="230"/>
|
||||
<source>username or password error!</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="146"/>
|
||||
<source>password</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>KylinSecretAgent</name>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinsecretagent.cpp" line="454"/>
|
||||
<source>userAndPwd</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinsecretagent.cpp" line="513"/>
|
||||
<source>tls</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
Binary file not shown.
|
@ -0,0 +1,83 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="zh_CN">
|
||||
<context>
|
||||
<name>KyPasswordDialog</name>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="57"/>
|
||||
<source>Kylin NM</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="60"/>
|
||||
<source>kylin network desktop message</source>
|
||||
<translation>网络提示信息</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="130"/>
|
||||
<source>Wi-Fi authentication required</source>
|
||||
<translation>此无线网络需要密码认证</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="138"/>
|
||||
<source>Access wireless networks</source>
|
||||
<translation>访问无线网络</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="140"/>
|
||||
<source>needs password or encryption key</source>
|
||||
<translation>需要密码或加密秘钥</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="185"/>
|
||||
<source>user name</source>
|
||||
<translation>用户名</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="202"/>
|
||||
<source>Connect</source>
|
||||
<translation>连接</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="208"/>
|
||||
<source>Cancel</source>
|
||||
<translation>取消</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="228"/>
|
||||
<source>password error!</source>
|
||||
<translation>密码错误!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="230"/>
|
||||
<source>username or password error!</source>
|
||||
<translation>用户名或密码错误!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>WiFi </source>
|
||||
<translation type="vanished">访问无线网络</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source> needs password</source>
|
||||
<translation type="vanished">需要密码或加密秘钥</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinpassworddialog.cpp" line="146"/>
|
||||
<source>password</source>
|
||||
<translation>密码</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>KylinSecretAgent</name>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinsecretagent.cpp" line="454"/>
|
||||
<source>userAndPwd</source>
|
||||
<translation>用户名和密码</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../kylin-agent/kylinsecretagent.cpp" line="513"/>
|
||||
<source>tls</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
|
@ -0,0 +1,8 @@
|
|||
TEMPLATE = subdirs
|
||||
|
||||
CONFIG += ordered \
|
||||
qt
|
||||
|
||||
SUBDIRS = \
|
||||
libnm-kylin \
|
||||
kylin-keyring/kylin-keyring.pro
|
|
@ -0,0 +1,134 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#include "kyapnetresource.h"
|
||||
#include "kylinnetworkdeviceresource.h"
|
||||
#include "kywirelessconnectoperation.h"
|
||||
#include "kylinnetworkmanagerutil.h"
|
||||
|
||||
const QString str2GBand = "2.4Ghz";
|
||||
const QString str5GBand = "5Ghz";
|
||||
|
||||
KyApNetResource::KyApNetResource(QObject *parent) : QObject(parent)
|
||||
{
|
||||
m_networkResourceInstance = KyNetworkResourceManager::getInstance();
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::wirelessApConnectStateChange,
|
||||
this, &KyApNetResource::wirelessApConnectStateChange);
|
||||
}
|
||||
|
||||
KyApNetResource::~KyApNetResource()
|
||||
{
|
||||
m_networkResourceInstance = nullptr;
|
||||
}
|
||||
|
||||
KyApConnectItem KyApNetResource::getApConnectItem(NetworkManager::Connection::Ptr connectPtr)
|
||||
{
|
||||
if (nullptr == connectPtr) {
|
||||
qWarning()<<"[KyConnectResourse]"<<"get bluetooth connection item failed, the connect is empty";
|
||||
return KyApConnectItem();
|
||||
}
|
||||
|
||||
NetworkManager::ConnectionSettings::Ptr settingPtr = connectPtr->settings();
|
||||
NetworkManager::WirelessSetting::Ptr wirelessSetting
|
||||
= settingPtr->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
|
||||
if (NetworkManager::WirelessSetting::NetworkMode::Ap
|
||||
!= wirelessSetting->mode()) {
|
||||
qWarning() << "[KyConnectResourse]" <<"get ap item failed, the active connect mode is not ap.";
|
||||
return KyApConnectItem();
|
||||
}
|
||||
|
||||
KyNetworkDeviceResourse deviceResource;
|
||||
if (!deviceResource.wirelessDeviceIsExist(settingPtr->interfaceName())) {
|
||||
qWarning() << "[KyConnectResourse]" <<"get ap item failed, the ap device is not exist yet";
|
||||
return KyApConnectItem();
|
||||
}
|
||||
|
||||
QByteArray rawSsid = wirelessSetting->ssid();
|
||||
|
||||
KyApConnectItem apConnectItem;
|
||||
apConnectItem.m_connectName = connectPtr->name();
|
||||
apConnectItem.m_connectSsid = getSsidFromByteArray(rawSsid);
|
||||
apConnectItem.m_connectUuid = connectPtr->uuid();
|
||||
if (wirelessSetting->band() == NetworkManager::WirelessSetting::FrequencyBand::A) {
|
||||
apConnectItem.m_band = str2GBand;
|
||||
} else if (wirelessSetting->band() == NetworkManager::WirelessSetting::FrequencyBand::Bg) {
|
||||
apConnectItem.m_band = str5GBand;
|
||||
}
|
||||
apConnectItem.m_ifaceName = settingPtr->interfaceName();
|
||||
apConnectItem.m_isActivated = KyNetworkResourceManager::getInstance()->isActiveConnection(connectPtr->uuid());
|
||||
|
||||
//NetworkManager::WirelessSecuritySetting::Ptr wirelessSecuritySetting
|
||||
// = settingPtr->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
KyWirelessConnectOperation wirelessOperation;
|
||||
apConnectItem.m_password = wirelessOperation.getPsk(apConnectItem.m_connectUuid);// wirelessSecuritySetting->psk();
|
||||
|
||||
return apConnectItem;
|
||||
}
|
||||
|
||||
KyApConnectItem KyApNetResource::getApConnectionByUuid(QString connectUuid)
|
||||
{
|
||||
NetworkManager::Connection::Ptr connectPtr = nullptr;
|
||||
|
||||
connectPtr = KyNetworkResourceManager::getInstance()->findConnectByUuid(connectUuid);
|
||||
if (nullptr == connectPtr) {
|
||||
return KyApConnectItem();
|
||||
}
|
||||
|
||||
if (NetworkManager::ConnectionSettings::ConnectionType::Wireless
|
||||
!= connectPtr->settings()->connectionType()) {
|
||||
return KyApConnectItem();
|
||||
}
|
||||
|
||||
KyApConnectItem connectItem = getApConnectItem(connectPtr);
|
||||
|
||||
return connectItem;
|
||||
}
|
||||
|
||||
void KyApNetResource::getApConnections(QList<KyApConnectItem> &apConnectItemList)
|
||||
{
|
||||
QList<KyApConnectItem> apActiveConnectItemList;
|
||||
QList<KyApConnectItem> apDeactiveConnectItemList;
|
||||
NetworkManager::Connection::List connectList;
|
||||
|
||||
connectList.clear();
|
||||
connectList = KyNetworkResourceManager::getInstance()->getConnectList();
|
||||
|
||||
if (connectList.empty()) {
|
||||
qWarning()<<"[KyConnectResourse]"<<"get ap connections failed, the connect list is empty";
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkManager::Connection::Ptr connectPtr = nullptr;
|
||||
for (int index = 0; index < connectList.size(); index++) {
|
||||
connectPtr = connectList.at(index);
|
||||
if (NetworkManager::ConnectionSettings::ConnectionType::Wireless
|
||||
!= connectPtr->settings()->connectionType()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
KyApConnectItem connectItem = getApConnectItem(connectPtr);
|
||||
if (connectItem.m_isActivated) {
|
||||
apActiveConnectItemList << connectItem;
|
||||
} else {
|
||||
apDeactiveConnectItemList << connectItem;
|
||||
}
|
||||
}
|
||||
|
||||
apConnectItemList << apActiveConnectItemList << apDeactiveConnectItemList;
|
||||
|
||||
return;
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifndef KYAPNETRESOURCE_H
|
||||
#define KYAPNETRESOURCE_H
|
||||
|
||||
#include <QObject>
|
||||
#include "kylinapconnectitem.h"
|
||||
#include "kylinnetworkresourcemanager.h"
|
||||
|
||||
class KyApNetResource : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit KyApNetResource(QObject *parent = nullptr);
|
||||
~KyApNetResource();
|
||||
|
||||
void getApConnections(QList<KyApConnectItem> &apConnectItemList);
|
||||
Q_SIGNALS:
|
||||
void wirelessApConnectStateChange();
|
||||
private:
|
||||
KyApConnectItem getApConnectItem(NetworkManager::Connection::Ptr connectPtr);
|
||||
KyApConnectItem getApConnectionByUuid(QString connectUuid);
|
||||
|
||||
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
|
||||
};
|
||||
|
||||
#endif // KYAPNETRESOURCE_H
|
|
@ -0,0 +1,188 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#include "kyenterpricesettinginfo.h"
|
||||
|
||||
void assembleEapMethodTlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTlsInfo &info)
|
||||
{
|
||||
NetworkManager::Security8021xSetting::Ptr wifi_8021x_sett
|
||||
= connSettingPtr->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>();
|
||||
|
||||
QList<NetworkManager::Security8021xSetting::EapMethod> list;
|
||||
list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodTls);
|
||||
wifi_8021x_sett->setInitialized(true);
|
||||
wifi_8021x_sett->setEapMethods(list);
|
||||
wifi_8021x_sett->setIdentity(info.identity);
|
||||
if (!info.domain.isEmpty()){
|
||||
wifi_8021x_sett->setDomainSuffixMatch(info.domain);
|
||||
}
|
||||
if (info.bNeedCa) {
|
||||
QByteArray caCerEndWithNull("file://" + info.caCertPath.toUtf8() + '\0');
|
||||
wifi_8021x_sett->setCaCertificate(caCerEndWithNull);
|
||||
} else {
|
||||
QByteArray caCerEndWithNull("");
|
||||
wifi_8021x_sett->setCaCertificate(caCerEndWithNull);
|
||||
}
|
||||
QByteArray cliCertEndWithNull("file://" + info.clientCertPath.toUtf8() + '\0');
|
||||
wifi_8021x_sett->setClientCertificate(cliCertEndWithNull);
|
||||
QByteArray cliPriKeyEndWithNull("file://" + info.clientPrivateKey.toUtf8() + '\0');
|
||||
wifi_8021x_sett->setPrivateKey(cliPriKeyEndWithNull);
|
||||
wifi_8021x_sett->setPrivateKeyPassword(info.clientPrivateKeyPWD);
|
||||
wifi_8021x_sett->setPrivateKeyPasswordFlags(info.m_privateKeyPWDFlag);
|
||||
|
||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
||||
= connSettingPtr->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
security_sett->setInitialized(true);
|
||||
security_sett->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaEap);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void assembleEapMethodPeapSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodPeapInfo &info)
|
||||
{
|
||||
NetworkManager::Security8021xSetting::Ptr wifi_8021x_sett
|
||||
= connSettingPtr->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>();
|
||||
|
||||
QList<NetworkManager::Security8021xSetting::EapMethod> list;
|
||||
list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodPeap);
|
||||
wifi_8021x_sett->setInitialized(true);
|
||||
wifi_8021x_sett->setEapMethods(list);
|
||||
wifi_8021x_sett->setPhase2AuthMethod((NetworkManager::Security8021xSetting::AuthMethod)info.phase2AuthMethod);
|
||||
wifi_8021x_sett->setIdentity(info.userName);
|
||||
wifi_8021x_sett->setPassword(info.userPWD);
|
||||
wifi_8021x_sett->setPasswordFlags(info.m_passwdFlag);
|
||||
|
||||
|
||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
||||
= connSettingPtr->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
security_sett->setInitialized(true);
|
||||
security_sett->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaEap);
|
||||
return;
|
||||
}
|
||||
|
||||
void assembleEapMethodTtlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTtlsInfo &info)
|
||||
{
|
||||
|
||||
NetworkManager::Security8021xSetting::Ptr wifi_8021x_sett
|
||||
= connSettingPtr->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>();
|
||||
|
||||
QList<NetworkManager::Security8021xSetting::EapMethod> list;
|
||||
list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodTtls);
|
||||
wifi_8021x_sett->setInitialized(true);
|
||||
wifi_8021x_sett->setEapMethods(list);
|
||||
if (info.authType == KyTtlsAuthMethod::AUTH_EAP)
|
||||
{
|
||||
wifi_8021x_sett->setPhase2AuthEapMethod((NetworkManager::Security8021xSetting::AuthEapMethod)info.authEapMethod);//gtc md5 mschapv2 otp tls
|
||||
} else if (info.authType == KyTtlsAuthMethod::AUTH_NO_EAP)
|
||||
{
|
||||
wifi_8021x_sett->setPhase2AuthMethod((NetworkManager::Security8021xSetting::AuthMethod)info.authNoEapMethod);//chap md5 mschapv2 pap gtc mschap otp tls
|
||||
}
|
||||
wifi_8021x_sett->setIdentity(info.userName);
|
||||
wifi_8021x_sett->setPassword(info.userPWD);
|
||||
wifi_8021x_sett->setPasswordFlags(info.m_passwdFlag);
|
||||
|
||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
||||
= connSettingPtr->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
security_sett->setInitialized(true);
|
||||
security_sett->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaEap);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void modifyEapMethodTlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTlsInfo &tlsInfo)
|
||||
{
|
||||
NetworkManager::Security8021xSetting::Ptr setting = connSettingPtr->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>();
|
||||
setting->setInitialized(true);
|
||||
|
||||
QList<NetworkManager::Security8021xSetting::EapMethod> list;
|
||||
list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodTls);
|
||||
setting->setEapMethods(list);
|
||||
setting->setIdentity(tlsInfo.identity);
|
||||
if(!tlsInfo.domain.isEmpty())
|
||||
{
|
||||
setting->setDomainSuffixMatch(tlsInfo.domain);
|
||||
}
|
||||
if (tlsInfo.bNeedCa)
|
||||
{
|
||||
QByteArray caCerEndWithNull("file://" + tlsInfo.caCertPath.toUtf8() + '\0');
|
||||
setting->setCaCertificate(caCerEndWithNull);
|
||||
} else {
|
||||
QByteArray caCerEndWithNull("");
|
||||
setting->setCaCertificate(caCerEndWithNull);
|
||||
}
|
||||
|
||||
QByteArray cliCertEndWithNull("file://" + tlsInfo.clientCertPath.toUtf8() + '\0');
|
||||
setting->setClientCertificate(cliCertEndWithNull);
|
||||
QByteArray cliPriKeyEndWithNull("file://" + tlsInfo.clientPrivateKey.toUtf8() + '\0');
|
||||
setting->setPrivateKey(cliPriKeyEndWithNull);
|
||||
setting->setPrivateKeyPasswordFlags(tlsInfo.m_privateKeyPWDFlag);
|
||||
if(tlsInfo.bChanged)
|
||||
{
|
||||
setting->setPrivateKeyPassword(tlsInfo.clientPrivateKeyPWD);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void modifyEapMethodPeapSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodPeapInfo &peapInfo)
|
||||
{
|
||||
NetworkManager::Security8021xSetting::Ptr wifi_8021x_sett
|
||||
= connSettingPtr->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>();
|
||||
wifi_8021x_sett->setInitialized(true);
|
||||
|
||||
QList<NetworkManager::Security8021xSetting::EapMethod> list;
|
||||
list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodPeap);
|
||||
wifi_8021x_sett->setEapMethods(list);
|
||||
wifi_8021x_sett->setPhase2AuthMethod((NetworkManager::Security8021xSetting::AuthMethod)peapInfo.phase2AuthMethod);
|
||||
wifi_8021x_sett->setIdentity(peapInfo.userName);
|
||||
if(peapInfo.bChanged) {
|
||||
wifi_8021x_sett->setPassword(peapInfo.userPWD);
|
||||
}
|
||||
wifi_8021x_sett->setPasswordFlags(peapInfo.m_passwdFlag);
|
||||
|
||||
QByteArray caCerEndWithNull("");
|
||||
wifi_8021x_sett->setCaCertificate(caCerEndWithNull);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void modifyEapMethodTtlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTtlsInfo &ttlsInfo)
|
||||
{
|
||||
NetworkManager::Security8021xSetting::Ptr wifi_8021x_sett
|
||||
= connSettingPtr->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>();
|
||||
|
||||
QList<NetworkManager::Security8021xSetting::EapMethod> list;
|
||||
list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodTtls);
|
||||
wifi_8021x_sett->setInitialized(true);
|
||||
wifi_8021x_sett->setEapMethods(list);
|
||||
if (ttlsInfo.authType == KyTtlsAuthMethod::AUTH_EAP)
|
||||
{
|
||||
wifi_8021x_sett->setPhase2AuthEapMethod((NetworkManager::Security8021xSetting::AuthEapMethod)ttlsInfo.authEapMethod);//gtc md5 mschapv2 otp tls
|
||||
} else if (ttlsInfo.authType == KyTtlsAuthMethod::AUTH_NO_EAP)
|
||||
{
|
||||
wifi_8021x_sett->setPhase2AuthMethod((NetworkManager::Security8021xSetting::AuthMethod)ttlsInfo.authNoEapMethod);//chap md5 mschapv2 pap gtc mschap otp tls
|
||||
}
|
||||
wifi_8021x_sett->setIdentity(ttlsInfo.userName);
|
||||
if(ttlsInfo.bChanged)
|
||||
{
|
||||
wifi_8021x_sett->setPassword(ttlsInfo.userPWD);
|
||||
}
|
||||
wifi_8021x_sett->setPasswordFlags(ttlsInfo.m_passwdFlag);
|
||||
|
||||
QByteArray caCerEndWithNull("");
|
||||
wifi_8021x_sett->setCaCertificate(caCerEndWithNull);
|
||||
return;
|
||||
}
|
|
@ -0,0 +1,163 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifndef KYENTERPRICESETTINGINFO_H
|
||||
#define KYENTERPRICESETTINGINFO_H
|
||||
|
||||
#include <NetworkManagerQt/Ipv4Setting>
|
||||
#include <NetworkManagerQt/Ipv6Setting>
|
||||
|
||||
#include "kylinnetworkresourcemanager.h"
|
||||
#include <QObject>
|
||||
|
||||
enum KyEapMethodType {
|
||||
TLS = 0,
|
||||
PEAP,
|
||||
TTLS,
|
||||
};
|
||||
|
||||
class KyEapMethodTlsInfo
|
||||
{
|
||||
public:
|
||||
QString identity;
|
||||
QString domain;
|
||||
QString devIfaceName;
|
||||
QString caCertPath;
|
||||
bool bNeedCa;
|
||||
QString clientCertPath;
|
||||
QString clientPrivateKey;
|
||||
QString clientPrivateKeyPWD;
|
||||
NetworkManager::Setting::SecretFlags m_privateKeyPWDFlag;
|
||||
// only valid when update
|
||||
bool bChanged;
|
||||
|
||||
inline bool operator == (const KyEapMethodTlsInfo& info) const
|
||||
{
|
||||
if (this->identity == info.identity
|
||||
&& this->domain == info.domain
|
||||
// && this->devIfaceName == info.devIfaceName
|
||||
&& this->caCertPath == info.caCertPath
|
||||
&& this->bNeedCa == info.bNeedCa
|
||||
&& this->clientCertPath == info.clientCertPath
|
||||
&& this->clientPrivateKey == info.clientPrivateKey
|
||||
&& this->clientPrivateKeyPWD == info.clientPrivateKeyPWD
|
||||
&& this->m_privateKeyPWDFlag == info.m_privateKeyPWDFlag) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
KyAuthEapMethodUnknown = 0,
|
||||
KyAuthEapMethodMd5,
|
||||
KyAuthEapMethodMschapv2,
|
||||
KyAuthEapMethodOtp,
|
||||
KyAuthEapMethodGtc,
|
||||
KyAuthEapMethodTls
|
||||
} KyEapMethodAuth;
|
||||
|
||||
typedef enum{
|
||||
KyAuthMethodUnknown = 0,
|
||||
KyAuthMethodPap,
|
||||
KyAuthMethodChap,
|
||||
KyAuthMethodMschap,
|
||||
KyAuthMethodMschapv2,
|
||||
KyAuthMethodGtc,
|
||||
KyAuthMethodOtp,
|
||||
KyAuthMethodMd5,
|
||||
KyAuthMethodTls
|
||||
} KyNoEapMethodAuth;
|
||||
|
||||
|
||||
class KyEapMethodPeapInfo
|
||||
{
|
||||
public:
|
||||
KyNoEapMethodAuth phase2AuthMethod;
|
||||
QString userName;
|
||||
QString userPWD;
|
||||
NetworkManager::Setting::SecretFlags m_passwdFlag;
|
||||
// only valid when update
|
||||
bool bChanged;
|
||||
|
||||
inline bool operator == (const KyEapMethodPeapInfo& info) const
|
||||
{
|
||||
if (this->phase2AuthMethod == info.phase2AuthMethod
|
||||
&& this->userName == info.userName
|
||||
&& this->userPWD == info.userPWD
|
||||
&& this->m_passwdFlag == info.m_passwdFlag) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
enum KyTtlsAuthMethod
|
||||
{
|
||||
AUTH_EAP,
|
||||
AUTH_NO_EAP
|
||||
};
|
||||
|
||||
class KyEapMethodTtlsInfo
|
||||
{
|
||||
public:
|
||||
KyTtlsAuthMethod authType;
|
||||
KyEapMethodAuth authEapMethod;
|
||||
KyNoEapMethodAuth authNoEapMethod;
|
||||
QString userName;
|
||||
QString userPWD;
|
||||
NetworkManager::Setting::SecretFlags m_passwdFlag;
|
||||
// only valid when update
|
||||
bool bChanged;
|
||||
|
||||
inline bool operator == (const KyEapMethodTtlsInfo& info) const
|
||||
{
|
||||
if (this->authType == info.authType) {
|
||||
if (authType == AUTH_EAP) {
|
||||
if (this->authEapMethod == info.authEapMethod
|
||||
&& this ->userName == info.userName
|
||||
&& this->userPWD == info.userPWD
|
||||
&& this->m_passwdFlag == info.m_passwdFlag) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (authType == AUTH_EAP) {
|
||||
if (this->authNoEapMethod == info.authNoEapMethod
|
||||
&& this ->userName == info.userName
|
||||
&& this->userPWD == info.userPWD
|
||||
&& this->m_passwdFlag == info.m_passwdFlag) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
void assembleEapMethodTlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTlsInfo &tlsInfo);
|
||||
void assembleEapMethodPeapSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodPeapInfo &peapInfo);
|
||||
void assembleEapMethodTtlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTtlsInfo &ttlsInfo);
|
||||
|
||||
void modifyEapMethodTlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTlsInfo &tlsInfo);
|
||||
void modifyEapMethodPeapSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodPeapInfo &peapInfo);
|
||||
void modifyEapMethodTtlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTtlsInfo &ttlsInfo);
|
||||
|
||||
#endif // KYENTERPRICESETTINGINFO_H
|
|
@ -0,0 +1,300 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#include "kylinactiveconnectresource.h"
|
||||
#include "kywirelessconnectoperation.h"
|
||||
#include "kylinnetworkmanagerutil.h"
|
||||
#include "kylinnetworkdeviceresource.h"
|
||||
|
||||
#include <NetworkManagerQt/IpConfig>
|
||||
#include <NetworkManagerQt/Dhcp4Config>
|
||||
#include <NetworkManagerQt/Dhcp6Config>
|
||||
|
||||
#define LOG_FLAG "[KyActiveConnectResourse]"
|
||||
|
||||
KyActiveConnectResourse::KyActiveConnectResourse(QObject *parent) : QObject(parent)
|
||||
{
|
||||
m_networkResourceInstance = KyNetworkResourceManager::getInstance();
|
||||
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::wiredConnectStateChange,
|
||||
this, &KyActiveConnectResourse::wiredStateChange);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::wirelessConnectStateChange,
|
||||
this, &KyActiveConnectResourse::wirelessStateChange);
|
||||
}
|
||||
|
||||
KyActiveConnectResourse::~KyActiveConnectResourse()
|
||||
{
|
||||
m_networkResourceInstance = nullptr;
|
||||
}
|
||||
|
||||
KyActivateItem KyActiveConnectResourse::getActiveConnectionItem(NetworkManager::ActiveConnection::Ptr activeConnectPtr)
|
||||
{
|
||||
if (nullptr == activeConnectPtr) {
|
||||
qWarning() << LOG_FLAG <<"the active connect is empty";
|
||||
return KyActivateItem();
|
||||
}
|
||||
|
||||
if (NetworkManager::ActiveConnection::State::Activated != activeConnectPtr->state()) {
|
||||
return KyActivateItem();
|
||||
}
|
||||
|
||||
KyActivateItem activeConnectItem;
|
||||
activeConnectItem.m_uuid = activeConnectPtr->uuid();
|
||||
|
||||
NetworkManager::Connection::Ptr connectPtr = activeConnectPtr->connection();
|
||||
activeConnectItem.m_connName = connectPtr->name();
|
||||
activeConnectItem.m_dbusPath = connectPtr->path();
|
||||
if (activeConnectPtr->type() == CONNECT_TYPE_WIRELESS) {
|
||||
NetworkManager::WirelessSetting::Ptr wireless_sett =
|
||||
connectPtr->settings()->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
|
||||
QByteArray rawSsid = wireless_sett->ssid();
|
||||
activeConnectItem.m_ssid = getSsidFromByteArray(rawSsid);
|
||||
}
|
||||
|
||||
activeConnectItem.m_connStatus = CONNECT_STATE_ACTIVATED;
|
||||
|
||||
return activeConnectItem;
|
||||
}
|
||||
|
||||
void KyActiveConnectResourse::getActiveConnectionList(QString deviceName,
|
||||
KyConnectionType connectionType,
|
||||
QList<KyActivateItem> &activeConnectItemList)
|
||||
{
|
||||
NetworkManager::ActiveConnection::List activeConnectList = m_networkResourceInstance->getActiveConnectList();
|
||||
|
||||
if (activeConnectList.isEmpty()) {
|
||||
qWarning() << LOG_FLAG <<"the active connect list is empty";
|
||||
return;
|
||||
}
|
||||
NetworkManager::ActiveConnection::Ptr activeConnectPtr = nullptr;
|
||||
for (int index = 0; index < activeConnectList.size(); index++) {
|
||||
activeConnectPtr = nullptr;
|
||||
activeConnectPtr = activeConnectList.at(index);
|
||||
if (activeConnectPtr.isNull()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (connectionType != activeConnectPtr->type()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
QStringList interfaces = activeConnectPtr->devices();
|
||||
for (int index = 0; index < interfaces.size(); ++index) {
|
||||
QString ifaceUni = interfaces.at(index);
|
||||
NetworkManager::Device:: Ptr devicePtr =
|
||||
m_networkResourceInstance->findDeviceByUni(ifaceUni);
|
||||
if (devicePtr->interfaceName() == deviceName) {
|
||||
KyActivateItem activeConnectItem =
|
||||
getActiveConnectionItem(activeConnectPtr);
|
||||
activeConnectItem.m_interface = deviceName;
|
||||
activeConnectItemList << activeConnectItem;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//动态ip地址
|
||||
void KyActiveConnectResourse::getActiveConnectIpInfo(
|
||||
const QString &connectUuid,
|
||||
QString &ipv4Address,
|
||||
QString &ipv6Address)
|
||||
{
|
||||
ipv4Address.clear();
|
||||
ipv6Address.clear();
|
||||
NetworkManager::ActiveConnection::Ptr activeConnectPtr =
|
||||
m_networkResourceInstance->findActiveConnectByUuid(connectUuid);
|
||||
|
||||
if (activeConnectPtr.isNull()) {
|
||||
qWarning() << LOG_FLAG <<"it can not find connect "<< connectUuid;
|
||||
return;
|
||||
}
|
||||
|
||||
getActiveConnectIp(activeConnectPtr, ipv4Address, ipv6Address);
|
||||
}
|
||||
|
||||
void KyActiveConnectResourse::getActiveConnectIp(
|
||||
NetworkManager::ActiveConnection::Ptr activeConnectPtr,
|
||||
QString &ipv4Address,
|
||||
QString &ipv6Address)
|
||||
{
|
||||
NetworkManager::IpConfig ipv4Config =activeConnectPtr->ipV4Config();
|
||||
if (ipv4Config.isValid()) {
|
||||
if (!ipv4Config.addresses().isEmpty()) {
|
||||
NetworkManager::IpAddress address = ipv4Config.addresses().at(0);
|
||||
ipv4Address = address.ip().toString();
|
||||
} else {
|
||||
qWarning()<<"[KyActiveConnectResourse]"<<"the ipv4 address is empty.";
|
||||
}
|
||||
} else {
|
||||
qWarning()<<"[KyActiveConnectResourse]"<<"ipv4 config is not valid";
|
||||
}
|
||||
|
||||
NetworkManager::IpConfig ipv6Config =activeConnectPtr->ipV6Config();
|
||||
if (ipv6Config.isValid()) {
|
||||
if (!ipv6Config.addresses().isEmpty()) {
|
||||
NetworkManager::IpAddress address = ipv6Config.addresses().at(0);
|
||||
ipv6Address = address.ip().toString();
|
||||
} else {
|
||||
qWarning()<<"[KyActiveConnectResourse]"<<"ipv6 address is empty";
|
||||
}
|
||||
} else {
|
||||
qWarning()<<"[KyActiveConnectResourse]"<<"ipv6 config is not valid";
|
||||
}
|
||||
}
|
||||
|
||||
void KyActiveConnectResourse::getActiveConnectDnsInfo(
|
||||
const QString &connectUuid,
|
||||
QList<QHostAddress> &ipv4Dns,
|
||||
QList<QHostAddress> &ipv6Dns)
|
||||
{
|
||||
NetworkManager::ActiveConnection::Ptr activeConnectPtr =
|
||||
m_networkResourceInstance->findActiveConnectByUuid(connectUuid);
|
||||
if (activeConnectPtr.isNull()) {
|
||||
qWarning()<< "[KyActiveConnectResourse]" <<"it can not find connect "<< connectUuid;
|
||||
return;
|
||||
}
|
||||
|
||||
getActiveConnectDns(activeConnectPtr, ipv4Dns, ipv6Dns);
|
||||
}
|
||||
|
||||
void KyActiveConnectResourse::getActiveConnectDns(
|
||||
NetworkManager::ActiveConnection::Ptr activeConnectPtr,
|
||||
QList<QHostAddress> &ipv4Dns,
|
||||
QList<QHostAddress> &ipv6Dns)
|
||||
{
|
||||
NetworkManager::IpConfig ipv4Config = activeConnectPtr->ipV4Config();
|
||||
if (ipv4Config.isValid()) {
|
||||
ipv4Dns = ipv4Config.nameservers();
|
||||
} else {
|
||||
qWarning()<<"[KyActiveConnectResourse]"<<"ipv4 config is not valid";
|
||||
}
|
||||
|
||||
NetworkManager::IpConfig ipv6Config =activeConnectPtr->ipV6Config();
|
||||
if (ipv6Config.isValid()) {
|
||||
ipv6Dns = ipv6Config.nameservers();
|
||||
} else {
|
||||
qWarning()<<"[KyActiveConnectResourse]"<<"ipv6 config is not valid";
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool KyActiveConnectResourse::wiredConnectIsActived()
|
||||
{
|
||||
int index = 0;
|
||||
NetworkManager::ActiveConnection::List activeConnectList;
|
||||
|
||||
activeConnectList.clear();
|
||||
activeConnectList = m_networkResourceInstance->getActiveConnectList();
|
||||
|
||||
if (activeConnectList.empty()) {
|
||||
qWarning()<<"[KyActiveConnectResourse]"
|
||||
<<"get active connect failed, the active connect list is empty";
|
||||
return false;
|
||||
}
|
||||
|
||||
NetworkManager::ActiveConnection::Ptr activeConnectPtr = nullptr;
|
||||
for (index = 0; index < activeConnectList.size(); index++) {
|
||||
activeConnectPtr = activeConnectList.at(index);
|
||||
if (activeConnectPtr.isNull()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (NetworkManager::ConnectionSettings::ConnectionType::Wired
|
||||
!= activeConnectPtr->type()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
QString path = activeConnectPtr->connection()->path();
|
||||
if (!m_networkResourceInstance->isWiredConnect(path)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (activeConnectPtr->state() == NetworkManager::ActiveConnection::State::Activated) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KyActiveConnectResourse::wirelessConnectIsActived()
|
||||
{
|
||||
int index = 0;
|
||||
NetworkManager::ActiveConnection::List activeConnectList;
|
||||
|
||||
activeConnectList.clear();
|
||||
activeConnectList = m_networkResourceInstance->getActiveConnectList();
|
||||
|
||||
if (activeConnectList.empty()) {
|
||||
qWarning()<<"[KyActiveConnectResourse]"
|
||||
<<"get active connect failed, the active connect list is empty";
|
||||
return false;
|
||||
}
|
||||
|
||||
NetworkManager::ActiveConnection::Ptr activeConnectPtr = nullptr;
|
||||
for (index = 0; index < activeConnectList.size(); index++) {
|
||||
activeConnectPtr = activeConnectList.at(index);
|
||||
if (activeConnectPtr.isNull()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (NetworkManager::ConnectionSettings::ConnectionType::Wireless
|
||||
!= activeConnectPtr->type()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (activeConnectPtr->state() == NetworkManager::ActiveConnection::State::Activated) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int KyActiveConnectResourse::getAcivateWifiSignal()
|
||||
{
|
||||
int signalStrength = 0;
|
||||
KyNetworkDeviceResourse devResource;
|
||||
QStringList devList;
|
||||
devResource.getNetworkDeviceList(DEVICE_TYPE_WIFI, devList);
|
||||
|
||||
for (int i = 0; i < devList.size(); ++i) {
|
||||
|
||||
NetworkManager::Device::Ptr connectDevice =
|
||||
m_networkResourceInstance->findDeviceByName(devList.at(i));
|
||||
|
||||
if (nullptr == connectDevice || !connectDevice->isValid()) {
|
||||
qWarning()<< LOG_FLAG <<"getDeviceActiveAPInfo failed, the device" << devList.at(i) << "is not existed";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (connectDevice->type() == NetworkManager::Device::Wifi) {
|
||||
NetworkManager::WirelessDevice *wirelessDevicePtr =
|
||||
qobject_cast<NetworkManager::WirelessDevice *>(connectDevice.data());
|
||||
NetworkManager::AccessPoint::Ptr apPtr = wirelessDevicePtr->activeAccessPoint();
|
||||
if (apPtr.isNull()) {
|
||||
continue;
|
||||
}
|
||||
signalStrength = apPtr->signalStrength();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return signalStrength;
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifndef KYLINACTIVECONNECTRESOURCE_H
|
||||
#define KYLINACTIVECONNECTRESOURCE_H
|
||||
|
||||
#include <QString>
|
||||
#include "kylinnetworkresourcemanager.h"
|
||||
#include "kylinconnectitem.h"
|
||||
#include "kylinnetworkdeviceresource.h"
|
||||
#include "kylinapconnectitem.h"
|
||||
#include "kylinnetworkresourcetype.h"
|
||||
|
||||
class KyActivateItem
|
||||
{
|
||||
public:
|
||||
QString m_interface;
|
||||
QString m_uuid;
|
||||
QString m_ssid;
|
||||
QString m_connName;
|
||||
QString m_dbusPath;
|
||||
KyConnectState m_connStatus;
|
||||
};
|
||||
|
||||
class KyActiveConnectResourse : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit KyActiveConnectResourse(QObject *parent = nullptr);
|
||||
~KyActiveConnectResourse();
|
||||
|
||||
public:
|
||||
void getActiveConnectionList(QString deviceName,
|
||||
KyConnectionType connectionType, QList<KyActivateItem> &connectItemList);
|
||||
|
||||
void getActiveConnectIpInfo(const QString &uuid,
|
||||
QString &ipv4Address, QString &ipv6Address);
|
||||
void getActiveConnectDnsInfo(const QString &uuid,
|
||||
QList<QHostAddress> &ipv4Dns, QList<QHostAddress> &ipv6Dns);
|
||||
|
||||
bool wiredConnectIsActived();
|
||||
bool wirelessConnectIsActived();
|
||||
|
||||
int getAcivateWifiSignal();
|
||||
|
||||
private:
|
||||
void getActiveConnectIp(NetworkManager::ActiveConnection::Ptr activeConnectPtr,
|
||||
QString &ipv4Address, QString &ipv6Address);
|
||||
void getActiveConnectDns(NetworkManager::ActiveConnection::Ptr activeConnectPtr,
|
||||
QList<QHostAddress> &ipv4Dns, QList<QHostAddress> &ipv6Dns);
|
||||
|
||||
KyActivateItem getActiveConnectionItem(NetworkManager::ActiveConnection::Ptr activeConnectPtr);
|
||||
|
||||
Q_SIGNALS:
|
||||
void wiredStateChange(QString deviceName, QString uuid, KyConnectState state);
|
||||
void wirelessStateChange(QString deviceName, QString ssid, QString uuid, KyConnectState state);
|
||||
|
||||
private:
|
||||
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
|
||||
};
|
||||
#endif // KYLINACTIVECONNECTRESOURCE_H
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#include "kylinapconnectitem.h"
|
||||
|
||||
KyApConnectItem::KyApConnectItem(QObject *parent) : QObject(parent)
|
||||
{
|
||||
m_connectName = "";
|
||||
m_connectUuid = "";
|
||||
m_connectSsid = "";
|
||||
m_ifaceName = "";
|
||||
m_password = "";
|
||||
m_band = "";
|
||||
m_isActivated = false;
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifndef KYLINAPCONNECTITEM_H
|
||||
#define KYLINAPCONNECTITEM_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
class KyApConnectItem
|
||||
{
|
||||
public:
|
||||
QString m_connectName = "";
|
||||
QString m_connectSsid = "";
|
||||
QString m_connectUuid = "";
|
||||
QString m_ifaceName = "";
|
||||
QString m_password = "";
|
||||
QString m_band = "";
|
||||
bool m_isActivated = false;
|
||||
|
||||
};
|
||||
|
||||
#endif // KYLINAPCONNECTITEM_H
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifndef KYLINCONNECTITEM_H
|
||||
#define KYLINCONNECTITEM_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
class KyWiredItem
|
||||
{
|
||||
public:
|
||||
QString m_connectName;
|
||||
QString m_connectUuid;
|
||||
QString m_connectPath;
|
||||
|
||||
};
|
||||
|
||||
#endif // KYLINWIREDCONNECTITEM_H
|
|
@ -0,0 +1,289 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "kylinconnectoperation.h"
|
||||
#include "kylinnetworkdeviceresource.h"
|
||||
|
||||
#include <NetworkManagerQt/AdslDevice>
|
||||
#include <NetworkManagerQt/WiredDevice>
|
||||
#include <NetworkManagerQt/Ipv4Setting>
|
||||
#include <NetworkManagerQt/Ipv6Setting>
|
||||
#include <NetworkManagerQt/WiredSetting>
|
||||
|
||||
KyConnectOperation::KyConnectOperation(QObject *parent) : QObject(parent)
|
||||
{
|
||||
m_networkResourceInstance = KyNetworkResourceManager::getInstance();
|
||||
}
|
||||
|
||||
KyConnectOperation::~KyConnectOperation()
|
||||
{
|
||||
m_networkResourceInstance = nullptr;
|
||||
}
|
||||
|
||||
void KyConnectOperation::ipv4SettingSet(
|
||||
NetworkManager::Ipv4Setting::Ptr &ipv4Setting,
|
||||
const KyConnectSetting &connectSettingsInfo)
|
||||
{
|
||||
ipv4Setting->setInitialized(true);
|
||||
ipv4Setting->setDns(connectSettingsInfo.m_ipv4Dns);
|
||||
|
||||
if (CONFIG_IP_DHCP == connectSettingsInfo.m_ipv4ConfigIpType) {
|
||||
ipv4Setting->setMethod(NetworkManager::Ipv4Setting::Automatic);
|
||||
return;
|
||||
} else {
|
||||
ipv4Setting->setMethod(NetworkManager::Ipv4Setting::Manual);
|
||||
}
|
||||
ipv4Setting->setAddresses(connectSettingsInfo.m_ipv4Address);
|
||||
|
||||
return;
|
||||
}
|
||||
void KyConnectOperation::ipv6SettingSet(
|
||||
NetworkManager::Ipv6Setting::Ptr &ipv6Setting,
|
||||
const KyConnectSetting &connectSettingsInfo)
|
||||
{
|
||||
ipv6Setting->setInitialized(true);
|
||||
ipv6Setting->setDns(connectSettingsInfo.m_ipv6Dns);
|
||||
|
||||
if (CONFIG_IP_DHCP == connectSettingsInfo.m_ipv6ConfigIpType) {
|
||||
ipv6Setting->setMethod(NetworkManager::Ipv6Setting::Automatic);
|
||||
ipv6Setting->setPrivacy(NetworkManager::Ipv6Setting::Disabled);
|
||||
return;
|
||||
}
|
||||
|
||||
ipv6Setting->setMethod(NetworkManager::Ipv6Setting::Manual);
|
||||
ipv6Setting->setAddresses(connectSettingsInfo.m_ipv6Address);
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
void KyConnectOperation::connectSettingSet(
|
||||
NetworkManager::ConnectionSettings::Ptr connectionSettings,
|
||||
const KyConnectSetting &connectSettingsInfo)
|
||||
{
|
||||
connectionSettings->setId(connectSettingsInfo.m_connectName);
|
||||
connectionSettings->setUuid(NetworkManager::ConnectionSettings::createNewUuid());
|
||||
connectionSettings->setAutoconnect(true);
|
||||
connectionSettings->setAutoconnectPriority(0);
|
||||
if (!connectSettingsInfo.m_ifaceName.isEmpty()) {
|
||||
connectionSettings->setInterfaceName(connectSettingsInfo.m_ifaceName);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void KyConnectOperation::setAutoConnect(NetworkManager::ConnectionSettings::Ptr &connectSetting,
|
||||
bool bAutoConnect)
|
||||
{
|
||||
if (connectSetting.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
connectSetting->setAutoconnect(bAutoConnect);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//ipv4 ipv6更新
|
||||
void KyConnectOperation::updateConnect(QString connectUuid, const KyConnectSetting &connectSettingsInfo)
|
||||
{
|
||||
NetworkManager::Connection::Ptr connectPtr =
|
||||
NetworkManager::findConnectionByUuid(connectUuid);
|
||||
if (nullptr == connectPtr) {
|
||||
QString errorMessage = tr("it can not find connection") + connectUuid;
|
||||
qWarning() << errorMessage;
|
||||
Q_EMIT updateConnectionError(errorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkManager::ConnectionSettings::Ptr connectSettingPtr = connectPtr->settings();
|
||||
|
||||
NetworkManager::Ipv4Setting::Ptr ipv4Setting = connectSettingPtr->setting(NetworkManager::Setting::Ipv4).dynamicCast<NetworkManager::Ipv4Setting>();
|
||||
ipv4SettingSet(ipv4Setting, connectSettingsInfo);
|
||||
|
||||
NetworkManager::Ipv6Setting::Ptr ipv6Setting = connectSettingPtr->setting(NetworkManager::Setting::Ipv6).dynamicCast<NetworkManager::Ipv6Setting>();
|
||||
ipv6SettingSet(ipv6Setting, connectSettingsInfo);
|
||||
|
||||
|
||||
NMVariantMapMap connectMapMap = connectSettingPtr->toMap();
|
||||
|
||||
if (connectMapMap.contains("ipv4")) {
|
||||
QVariantMap ipv4SettingMap = connectMapMap.value(QLatin1String("ipv4"));
|
||||
if (ipv4SettingMap.contains("method") && ipv4SettingMap["method"] == "auto") {
|
||||
if (ipv4SettingMap.contains("address-data")) {
|
||||
ipv4SettingMap.remove("address-data");
|
||||
}
|
||||
if (ipv4SettingMap.contains("addresses")) {
|
||||
ipv4SettingMap.remove("addresses");
|
||||
}
|
||||
if (ipv4SettingMap.contains("gateway")) {
|
||||
ipv4SettingMap.remove("gateway");
|
||||
}
|
||||
}
|
||||
connectMapMap["ipv4"] = ipv4SettingMap;
|
||||
}
|
||||
|
||||
if (connectMapMap.contains("ipv6")) {
|
||||
QVariantMap ipv4SettingMap = connectMapMap.value(QLatin1String("ipv6"));
|
||||
if (ipv4SettingMap.contains("method") && ipv4SettingMap["method"] == "auto") {
|
||||
if (ipv4SettingMap.contains("address-data")) {
|
||||
ipv4SettingMap.remove("address-data");
|
||||
}
|
||||
if (ipv4SettingMap.contains("addresses")) {
|
||||
ipv4SettingMap.remove("addresses");
|
||||
}
|
||||
if (ipv4SettingMap.contains("gateway")) {
|
||||
ipv4SettingMap.remove("gateway");
|
||||
}
|
||||
}
|
||||
|
||||
connectMapMap["ipv6"] = ipv4SettingMap;
|
||||
}
|
||||
|
||||
connectPtr->update(connectMapMap);
|
||||
}
|
||||
|
||||
void KyConnectOperation::deleteConnect(const QString &connectUuid)
|
||||
{
|
||||
qDebug()<<"delete connect uuid " << connectUuid;
|
||||
|
||||
NetworkManager::Connection::Ptr connectPtr =
|
||||
NetworkManager::findConnectionByUuid(connectUuid);
|
||||
if (nullptr == connectPtr) {
|
||||
QString errorMessage = tr("it can not find connection") + connectUuid;
|
||||
qWarning()<<errorMessage;
|
||||
Q_EMIT deleteConnectionError(errorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
connectPtr->remove();
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
void KyConnectOperation::activateConnection(const QString connectUuid, const QString deviceName)
|
||||
{
|
||||
QString connectPath = "";
|
||||
QString deviceIdentifier = "";
|
||||
QString connectName = "";
|
||||
QString specificObject = "";
|
||||
NetworkManager::Connection::Ptr connectPtr = nullptr;
|
||||
|
||||
qDebug()<<"it will activate connect"<<connectUuid;
|
||||
connectPtr = NetworkManager::findConnectionByUuid(connectUuid);
|
||||
if (nullptr == connectPtr) {
|
||||
QString errorMessage = "the connect uuid " + connectUuid + "is not exsit";
|
||||
qWarning()<<errorMessage;
|
||||
Q_EMIT activateConnectionError(errorMessage);
|
||||
return;
|
||||
}
|
||||
#if 0
|
||||
if (NetworkManager::ConnectionSettings::Wired != connectPtr->settings()->connectionType()) {
|
||||
QString errorMessage = tr("the connect type is")
|
||||
+ connectPtr->settings()->connectionType()
|
||||
+ tr(", but it is not wired");
|
||||
qWarning()<<errorMessage;
|
||||
Q_EMIT activateConnectionError(errorMessage);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
connectPath = connectPtr->path();
|
||||
connectName = connectPtr->name();
|
||||
// deviceName = connectPtr->settings()->interfaceName();
|
||||
|
||||
// for (auto const & dev : m_networkResourceInstance->m_devices) {
|
||||
// for (auto const & dev_conn : dev->availableConnections()) {
|
||||
// if (dev_conn == connectPtr) {
|
||||
// deviceIdentifier = dev->uni();
|
||||
// deviceName = dev->interfaceName();
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
auto dev = m_networkResourceInstance->findDeviceByName(deviceName);
|
||||
if (!dev.isNull()) {
|
||||
deviceIdentifier = dev->uni();
|
||||
}
|
||||
|
||||
|
||||
if (deviceIdentifier.isEmpty()) {
|
||||
QString errorMessage = tr("device Identifier is empty, its name") + deviceName;
|
||||
qWarning() << errorMessage;
|
||||
Q_EMIT activateConnectionError(errorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
if (NetworkManager::ConnectionSettings::Wired == connectPtr->settings()->connectionType()) {
|
||||
KyNetworkDeviceResourse deviceResource;
|
||||
if (!deviceResource.wiredDeviceIsCarriered(deviceName)) {
|
||||
qWarning() << deviceName << "is not carried, so can not activate connection";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
qDebug() <<"active wired connect: path "<< connectPath
|
||||
<< "device identify " << deviceIdentifier
|
||||
<< "connect name " << connectName
|
||||
<< "device name" << deviceName
|
||||
<< "specific parameter"<< specificObject;
|
||||
|
||||
QDBusPendingCallWatcher * watcher;
|
||||
watcher = new QDBusPendingCallWatcher{NetworkManager::activateConnection(connectPath, deviceIdentifier, specificObject), this};
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished, [this, connectName, deviceName] (QDBusPendingCallWatcher * watcher) {
|
||||
if (watcher->isError() || !watcher->isValid()) {
|
||||
QString errorMessage = tr("activate connection failed: ") + watcher->error().message();
|
||||
qWarning()<<errorMessage;
|
||||
Q_EMIT this->activateConnectionError(errorMessage);
|
||||
} else {
|
||||
qWarning()<<"active wired connect complete.";
|
||||
}
|
||||
|
||||
watcher->deleteLater();
|
||||
});
|
||||
}
|
||||
|
||||
void KyConnectOperation::deactivateConnection(const QString &activeConnectUuid)
|
||||
{
|
||||
NetworkManager::ActiveConnection::Ptr activateConnectPtr = nullptr;
|
||||
|
||||
|
||||
activateConnectPtr = m_networkResourceInstance->findActiveConnectByUuid(activeConnectUuid);
|
||||
if (nullptr == activateConnectPtr) {
|
||||
QString errorMessage = tr("it can not find the activate connect")
|
||||
+ tr("uuid") + activeConnectUuid;
|
||||
qWarning()<<errorMessage;
|
||||
Q_EMIT deactivateConnectionError(errorMessage);
|
||||
return ;
|
||||
}
|
||||
|
||||
qDebug() <<"deactive connection path:"<< activateConnectPtr->path();
|
||||
QDBusPendingReply<> reply = NetworkManager::deactivateConnection(activateConnectPtr->path());
|
||||
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished, [this, activateConnectPtr] (QDBusPendingCallWatcher * watcher) {
|
||||
if (watcher->isError() || !watcher->isValid()) {
|
||||
QString errorMessage = tr("deactivation of connection")
|
||||
+ activateConnectPtr->connection()->name() + tr("failed:")
|
||||
+ watcher->error().message();
|
||||
|
||||
qWarning()<<errorMessage;
|
||||
Q_EMIT this->deactivateConnectionError(errorMessage);
|
||||
} else {
|
||||
qWarning() << "deactive connect operation finished" << activateConnectPtr->connection()->name();
|
||||
}
|
||||
watcher->deleteLater();
|
||||
});
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifndef KYLINCONNECTOPERATION_H
|
||||
#define KYLINCONNECTOPERATION_H
|
||||
|
||||
#include "kylinnetworkresourcemanager.h"
|
||||
#include "kylinconnectsetting.h"
|
||||
|
||||
class KyConnectOperation : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit KyConnectOperation(QObject *parent = nullptr);
|
||||
~KyConnectOperation();
|
||||
|
||||
void updateConnect(QString connectUuid, const KyConnectSetting &connectSettingsInfo);
|
||||
void deleteConnect(const QString &connectUuid);
|
||||
void activateConnection(const QString connectUuid, const QString deviceName);
|
||||
void deactivateConnection(const QString &activeConnectUuid);
|
||||
|
||||
protected:
|
||||
void connectSettingSet(NetworkManager::ConnectionSettings::Ptr connectionSettings,
|
||||
const KyConnectSetting &connectSettingsInfo);
|
||||
void ipv4SettingSet(NetworkManager::Ipv4Setting::Ptr &ipv4Setting,
|
||||
const KyConnectSetting &connectSettingsInfo);
|
||||
void ipv6SettingSet(NetworkManager::Ipv6Setting::Ptr &ipv6Setting,
|
||||
const KyConnectSetting &connectSettingsInfo);
|
||||
void setAutoConnect(NetworkManager::ConnectionSettings::Ptr &connectSetting, bool bAutoConnect);
|
||||
inline void errorProcess(QString errorMessage);
|
||||
|
||||
Q_SIGNALS:
|
||||
void createConnectionError(QString errorMessage);
|
||||
void updateConnectionError(QString errorMessage);
|
||||
void deleteConnectionError(QString errorMessage);
|
||||
void activateConnectionError(QString errorMessage);
|
||||
void deactivateConnectionError(QString errorMessage);
|
||||
|
||||
protected:
|
||||
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
|
||||
};
|
||||
|
||||
#endif // KYLINCONNECTOPERATION_H
|
|
@ -0,0 +1,133 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#include "kylinconnectsetting.h"
|
||||
#include <QDebug>
|
||||
|
||||
KyConnectSetting::KyConnectSetting(/*QObject *parent) : QObject(parent*/)
|
||||
{
|
||||
m_connectName = "";
|
||||
m_ifaceName = "";
|
||||
|
||||
m_ipv4ConfigIpType = CONFIG_IP_DHCP;
|
||||
m_ipv4Address.clear();
|
||||
m_ipv4Dns.clear();
|
||||
|
||||
m_ipv6ConfigIpType = CONFIG_IP_DHCP;
|
||||
m_ipv6Address.clear();
|
||||
m_ipv6Dns.clear();
|
||||
|
||||
m_isAutoConnect = true;
|
||||
}
|
||||
|
||||
KyConnectSetting::~KyConnectSetting()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void KyConnectSetting::setIfaceName(QString &ifaceName)
|
||||
{
|
||||
m_ifaceName = ifaceName;
|
||||
}
|
||||
|
||||
void KyConnectSetting::setConnectName(QString &connectName)
|
||||
{
|
||||
m_connectName = connectName;
|
||||
}
|
||||
|
||||
int KyConnectSetting::setIpConfigType(KyIpAddressType ipType, KyIpConfigType ipConfigType)
|
||||
{
|
||||
if (ipType != IPADDRESS_V4 && ipType != IPADDRESS_V6) {
|
||||
qWarning()<<"set config ip type failed, the ip address type undefined"<<ipType;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (CONFIG_IP_DHCP != ipConfigType && CONFIG_IP_MANUAL != ipConfigType) {
|
||||
qWarning()<<"set config ip type failed, the config ip type undefined"<<ipConfigType;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (IPADDRESS_V4 == ipType) {
|
||||
m_ipv4ConfigIpType = ipConfigType;
|
||||
} else {
|
||||
m_ipv6ConfigIpType = ipConfigType;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
void KyConnectSetting::ipv4AddressConstruct(QString &ipv4Address, QString &ipv4NetMask, QString &ipv4GateWay, QStringList &ipv4Dns)
|
||||
{
|
||||
qDebug()<<"ipv4 address"<<ipv4Address << ipv4NetMask << ipv4GateWay;
|
||||
NetworkManager::IpAddress nmIpv4Address;
|
||||
nmIpv4Address.setIp(QHostAddress(ipv4Address));
|
||||
nmIpv4Address.setGateway(QHostAddress(ipv4GateWay));
|
||||
nmIpv4Address.setNetmask(QHostAddress(ipv4NetMask));
|
||||
m_ipv4Address.clear();
|
||||
m_ipv4Address << nmIpv4Address;
|
||||
|
||||
m_ipv4Dns.clear();
|
||||
for (int index = 0; index < ipv4Dns.size(); ++index) {
|
||||
qDebug()<<"dns"<<ipv4Dns[index];
|
||||
m_ipv4Dns << QHostAddress(ipv4Dns[index]);
|
||||
}
|
||||
|
||||
return ;
|
||||
}
|
||||
void KyConnectSetting::ipv6AddressConstruct(QString &ipv6Address, QString &ipv6NetMask, QString &ipv6GateWay, QStringList &ipv6Dns)
|
||||
{
|
||||
NetworkManager::IpAddress nmIpv6Address;
|
||||
nmIpv6Address.setIp(QHostAddress(ipv6Address));
|
||||
nmIpv6Address.setGateway(QHostAddress(ipv6GateWay));
|
||||
nmIpv6Address.setPrefixLength(ipv6NetMask.toInt());
|
||||
m_ipv6Address.clear();
|
||||
m_ipv6Address << nmIpv6Address;
|
||||
|
||||
m_ipv6Dns.clear();
|
||||
for (int index = 0; index < ipv6Dns.size(); index++) {
|
||||
m_ipv6Dns << QHostAddress(ipv6Dns[index]);
|
||||
}
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
void KyConnectSetting::dumpInfo()
|
||||
{
|
||||
qDebug()<<"connect setting info:";
|
||||
qDebug()<<"connect name"<< m_connectName;
|
||||
qDebug()<<"iface name" << m_ifaceName;
|
||||
qDebug()<<"ipv4 method" <<m_ipv4ConfigIpType;
|
||||
|
||||
for (int index = 0 ; index < m_ipv4Address.size(); index++) {
|
||||
qDebug()<<"ipv4 address" << m_ipv4Address.at(index).ip().toString();
|
||||
qDebug()<<"ipv4 gate way" << m_ipv4Address.at(index).gateway().toString();
|
||||
qDebug()<<"ipv4 net mask" << m_ipv4Address.at(index).netmask().toString();
|
||||
}
|
||||
|
||||
for (int index = 0; index < m_ipv4Dns.size(); ++index) {
|
||||
qDebug()<<"ipv4 dns" << m_ipv4Dns.at(index).toString();
|
||||
}
|
||||
|
||||
for (int index = 0 ; index < m_ipv6Address.size(); index++) {
|
||||
qDebug()<<"ipv6 address" << m_ipv6Address.at(index).ip().toString();
|
||||
qDebug()<<"ipv6 gate way" << m_ipv6Address.at(index).gateway().toString();
|
||||
qDebug()<<"ipv6 net mask" << m_ipv6Address.at(index).netmask().toString();
|
||||
}
|
||||
|
||||
for (int index = 0; index < m_ipv6Dns.size(); ++index) {
|
||||
qDebug()<<"ipv6 dns" << m_ipv6Dns.at(index).toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef KYLINCONNECTSETTING_H
|
||||
#define KYLINCONNECTSETTING_H
|
||||
|
||||
#include <QStringList>
|
||||
#include <QString>
|
||||
//#include <QObject>
|
||||
|
||||
#include <NetworkManagerQt/AdslDevice>
|
||||
#include <NetworkManagerQt/WiredDevice>
|
||||
#include <NetworkManagerQt/Ipv4Setting>
|
||||
#include <NetworkManagerQt/Ipv6Setting>
|
||||
#include <NetworkManagerQt/WiredSetting>
|
||||
|
||||
typedef enum {
|
||||
CONFIG_IP_MANUAL,
|
||||
CONFIG_IP_DHCP,
|
||||
}KyIpConfigType;
|
||||
|
||||
typedef enum {
|
||||
IPADDRESS_V4,
|
||||
IPADDRESS_V6,
|
||||
}KyIpAddressType;
|
||||
|
||||
class KyConnectSetting/* : public QObject*/
|
||||
{
|
||||
// Q_OBJECT
|
||||
public:
|
||||
/* explicit*/ KyConnectSetting(/*QObject *parent = nullptr*/);
|
||||
~KyConnectSetting();
|
||||
|
||||
public:
|
||||
void setIfaceName(QString &ifaceName);
|
||||
void setConnectName(QString &connectName);
|
||||
int setIpConfigType(KyIpAddressType ipType, KyIpConfigType configType);
|
||||
void ipv4AddressConstruct(QString &ipv4Address, QString &ipv4NetMask, QString &ipv4GateWay, QStringList &ipv4Dns);
|
||||
void ipv6AddressConstruct(QString &ipv6Address, QString &ipv6NetMask, QString &ipv6GateWay, QStringList &ipv6Dns);
|
||||
void dumpInfo();
|
||||
|
||||
public:
|
||||
QString m_connectName;
|
||||
QString m_ifaceName;
|
||||
|
||||
KyIpConfigType m_ipv4ConfigIpType;
|
||||
QList<NetworkManager::IpAddress> m_ipv4Address;
|
||||
QList<QHostAddress> m_ipv4Dns;
|
||||
|
||||
KyIpConfigType m_ipv6ConfigIpType;
|
||||
QList<NetworkManager::IpAddress> m_ipv6Address;
|
||||
QList<QHostAddress> m_ipv6Dns;
|
||||
|
||||
bool m_isAutoConnect = true;
|
||||
};
|
||||
|
||||
#endif // KYLINCONNECTSETTING_H
|
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#include "kylingeneral.h"
|
||||
#include "kylinnetworkdeviceresource.h"
|
||||
#include "kylinactiveconnectresource.h"
|
||||
#include "kylinnetworkmanagerutil.h"
|
||||
|
||||
KylinGeneralOpration::KylinGeneralOpration(QObject *parent) : QObject(parent)
|
||||
{
|
||||
m_networkResourceInstance = KyNetworkResourceManager::getInstance();
|
||||
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::wifiEnabledChanged,
|
||||
this, &KylinGeneralOpration::wifiEnabledChanged);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::networkingEnabledChanged,
|
||||
this, &KylinGeneralOpration::networkingEnabledChanged);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::primaryConnectionTypeChanged,
|
||||
this, &KylinGeneralOpration::updateConnectStatus);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::connectivityChanged,
|
||||
this, &KylinGeneralOpration::updateConnectStatus);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::wiredEnabledChanged,
|
||||
this, &KylinGeneralOpration::wiredEnabledChanged);
|
||||
}
|
||||
|
||||
KylinGeneralOpration::~KylinGeneralOpration()
|
||||
{
|
||||
m_networkResourceInstance = nullptr;
|
||||
}
|
||||
|
||||
void KylinGeneralOpration::getConnectStatus(KyConnectStatus &status)
|
||||
{
|
||||
updateConnectStatus();
|
||||
status = m_status;
|
||||
}
|
||||
|
||||
void KylinGeneralOpration::updateConnectStatus()
|
||||
{
|
||||
KyConnectStatus status;
|
||||
|
||||
KyConnectionType connectType;
|
||||
KyActiveConnectResourse activeResource;
|
||||
getPrimaryConnectionType(connectType);
|
||||
if (activeResource.wiredConnectIsActived()) {
|
||||
status = LAN_CONNECTED;
|
||||
} else if (activeResource.wirelessConnectIsActived()) {
|
||||
status = WLAN_CONNECTED;
|
||||
} else {
|
||||
status = NOT_CONNECTED;
|
||||
}
|
||||
|
||||
KyConnectivity connecttivity;
|
||||
getConnectivity(connecttivity);
|
||||
if (connecttivity != CONNECTIVITY_FULL) {
|
||||
if (status == LAN_CONNECTED) {
|
||||
status = LAN_CONNECTED_LIMITED;
|
||||
} else if (status == WLAN_CONNECTED) {
|
||||
status = WLAN_CONNECTED_LIMITED;
|
||||
}
|
||||
}
|
||||
|
||||
if (status != m_status) {
|
||||
m_status = status;
|
||||
Q_EMIT connectStatusChanged(m_status);
|
||||
}
|
||||
}
|
||||
|
||||
void KylinGeneralOpration::getConnectivity(KyConnectivity &connectivity)
|
||||
{
|
||||
connectivity = (KyConnectivity)NetworkManager::connectivity();
|
||||
}
|
||||
|
||||
void KylinGeneralOpration::getPrimaryConnectionType(KyConnectionType &connectType)
|
||||
{
|
||||
connectType = (KyConnectionType)NetworkManager::primaryConnectionType();
|
||||
}
|
||||
|
||||
bool KylinGeneralOpration::getWirelessEnabled()
|
||||
{
|
||||
return NetworkManager::isWirelessEnabled();
|
||||
}
|
||||
|
||||
void KylinGeneralOpration::setWirelessNetworkEnabled(bool enabled)
|
||||
{
|
||||
NetworkManager::setWirelessEnabled(enabled);
|
||||
}
|
||||
|
||||
bool KylinGeneralOpration::getNetworkingEnabled()
|
||||
{
|
||||
return NetworkManager::isNetworkingEnabled();
|
||||
}
|
||||
|
||||
void KylinGeneralOpration::setNetworkingEnabled(bool enabled)
|
||||
{
|
||||
NetworkManager::setNetworkingEnabled(enabled);
|
||||
}
|
||||
|
||||
void KylinGeneralOpration::setWiredEnabled(bool enabled)
|
||||
{
|
||||
setWiredEnabledByGDbus(enabled);
|
||||
}
|
||||
|
||||
bool KylinGeneralOpration::getWiredEnabled()
|
||||
{
|
||||
return getWiredEnabledByGDbus();
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifndef KYLINGENERAL_H
|
||||
#define KYLINGENERAL_H
|
||||
|
||||
#include <QObject>
|
||||
#include "kylinnetworkresourcemanager.h"
|
||||
|
||||
enum KyConnectStatus {
|
||||
NOT_CONNECTED = 0,
|
||||
LAN_CONNECTED,
|
||||
WLAN_CONNECTED,
|
||||
LAN_CONNECTED_LIMITED,
|
||||
WLAN_CONNECTED_LIMITED,
|
||||
};
|
||||
|
||||
class KylinGeneralOpration : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit KylinGeneralOpration(QObject *parent = nullptr);
|
||||
~KylinGeneralOpration();
|
||||
void getConnectStatus(KyConnectStatus &status);
|
||||
bool getWirelessEnabled();
|
||||
void setWirelessNetworkEnabled(bool enabled);
|
||||
bool getNetworkingEnabled();
|
||||
void setNetworkingEnabled(bool enabled);
|
||||
void setWiredEnabled(bool enabled);
|
||||
bool getWiredEnabled();
|
||||
|
||||
Q_SIGNALS:
|
||||
void connectStatusChanged(KyConnectStatus);
|
||||
void wifiEnabledChanged(bool);
|
||||
void wiredEnabledChanged(bool);
|
||||
void networkingEnabledChanged(bool);
|
||||
|
||||
private Q_SLOTS:
|
||||
void updateConnectStatus();
|
||||
|
||||
private:
|
||||
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
|
||||
KyConnectStatus m_status = NOT_CONNECTED;
|
||||
|
||||
void updateGsetting(bool);
|
||||
void getConnectivity(KyConnectivity &connectivity);
|
||||
void getPrimaryConnectionType(KyConnectionType &connectType);
|
||||
};
|
||||
|
||||
#endif // KYLINGENERAL_H
|
|
@ -0,0 +1,160 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#include "kylinnetresource.h"
|
||||
#include "kylinnetworkdeviceresource.h"
|
||||
#include "kylinactiveconnectresource.h"
|
||||
#include "kywirelessnetresource.h"
|
||||
#include "kylinnetworkmanagerutil.h"
|
||||
|
||||
KyNetResource::KyNetResource(QObject *parent) : QObject(parent)
|
||||
{
|
||||
m_networkResourceInstance = KyNetworkResourceManager::getInstance();
|
||||
}
|
||||
|
||||
KyNetResource::~KyNetResource() {
|
||||
m_networkResourceInstance = nullptr;
|
||||
}
|
||||
|
||||
void KyNetResource::getIpv4ConnectSetting(
|
||||
NetworkManager::Ipv4Setting::Ptr &ipv4Setting,
|
||||
KyConnectSetting &connectSetting)
|
||||
{
|
||||
if (NetworkManager::Ipv4Setting::Automatic == ipv4Setting->method()) {
|
||||
connectSetting.m_ipv4ConfigIpType = CONFIG_IP_DHCP;
|
||||
return;
|
||||
}
|
||||
|
||||
connectSetting.m_ipv4ConfigIpType = CONFIG_IP_MANUAL;
|
||||
|
||||
connectSetting.m_ipv4Address = ipv4Setting->addresses();
|
||||
connectSetting.m_ipv4Dns = ipv4Setting->dns();
|
||||
}
|
||||
|
||||
void KyNetResource::getIpv6ConnectSetting(
|
||||
NetworkManager::Ipv6Setting::Ptr &ipv6Setting,
|
||||
KyConnectSetting &connectSetting)
|
||||
{
|
||||
|
||||
if (NetworkManager::Ipv6Setting::Automatic == ipv6Setting->method()) {
|
||||
connectSetting.m_ipv6ConfigIpType = CONFIG_IP_DHCP;
|
||||
return;
|
||||
}
|
||||
|
||||
connectSetting.m_ipv6ConfigIpType = CONFIG_IP_MANUAL;
|
||||
connectSetting.m_ipv6Address = ipv6Setting->addresses();
|
||||
connectSetting.m_ipv6Dns = ipv6Setting->dns();
|
||||
}
|
||||
|
||||
void KyNetResource::getConnectionSetting(QString connectUuid, KyConnectSetting &connectSetting)
|
||||
{
|
||||
NetworkManager::Connection::Ptr connectPtr =
|
||||
m_networkResourceInstance->findConnectByUuid(connectUuid);
|
||||
|
||||
if (nullptr == connectPtr
|
||||
|| !connectPtr->isValid()) {
|
||||
qWarning() <<"[KyConnectResourse]" << "it can not find valid connection" << connectUuid;
|
||||
return;
|
||||
}
|
||||
|
||||
connectSetting.m_connectName = connectPtr->name();
|
||||
|
||||
NetworkManager::ConnectionSettings::Ptr connectionSettings = connectPtr->settings();
|
||||
connectSetting.m_ifaceName = connectionSettings->interfaceName();
|
||||
connectSetting.m_isAutoConnect = connectionSettings->autoconnect();
|
||||
|
||||
NetworkManager::Ipv4Setting::Ptr ipv4Setting = connectionSettings->setting(NetworkManager::Setting::Ipv4).dynamicCast<NetworkManager::Ipv4Setting>();
|
||||
getIpv4ConnectSetting(ipv4Setting, connectSetting);
|
||||
|
||||
NetworkManager::Ipv6Setting::Ptr ipv6Setting = connectionSettings->setting(NetworkManager::Setting::Ipv6).dynamicCast<NetworkManager::Ipv6Setting>();
|
||||
getIpv6ConnectSetting(ipv6Setting, connectSetting);
|
||||
}
|
||||
|
||||
void KyNetResource::getBaseInfo(QString devName,QString ssid, bool isWlan, bool isActive, KyDetailInfo &conInfo)
|
||||
{
|
||||
//有线无线公有
|
||||
KyNetworkDeviceResourse devResource;
|
||||
|
||||
QString hardAddress;
|
||||
int bandWith;
|
||||
devResource.getHardwareInfo(devName, hardAddress, bandWith);
|
||||
|
||||
if (!hardAddress.isEmpty()) {
|
||||
conInfo.strBandWidth = QString("%1").arg(bandWith/1000) + "Mbps";
|
||||
conInfo.strMac = hardAddress;
|
||||
}
|
||||
|
||||
if (isWlan) {
|
||||
if (!isActive) {
|
||||
NetworkManager::Device::Ptr devPtr =
|
||||
KyNetworkResourceManager::getInstance()->findDeviceByName(devName);
|
||||
if (devPtr.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkManager::WirelessNetwork::Ptr netPtr =
|
||||
KyNetworkResourceManager::getInstance()->findWifiNetwork(ssid, devPtr->uni());
|
||||
if (netPtr.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkManager::AccessPoint::Ptr bestApPtr = netPtr->referenceAccessPoint();
|
||||
conInfo.strHz = QString::number(bestApPtr->frequency()) + "MHz";
|
||||
conInfo.strChan = QString::number(NetworkManager::findChannel(bestApPtr->frequency()));
|
||||
NetworkManager::AccessPoint::Capabilities cap = bestApPtr->capabilities();
|
||||
NetworkManager::AccessPoint::WpaFlags wpaFlag = bestApPtr->wpaFlags();
|
||||
NetworkManager::AccessPoint::WpaFlags rsnFlag = bestApPtr->rsnFlags();
|
||||
conInfo.strSecType = enumToQstring(cap, wpaFlag, rsnFlag);
|
||||
} else {
|
||||
uint iHz,iChan;
|
||||
QString strMac;
|
||||
devResource.getDeviceActiveAPInfo(devName, strMac, iHz, iChan, conInfo.strSecType);
|
||||
|
||||
conInfo.strHz = QString::number(iHz);
|
||||
conInfo.strChan = QString::number(iChan);
|
||||
}
|
||||
|
||||
if (conInfo.strSecType.isEmpty()) {
|
||||
conInfo.strSecType = tr("None");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//详情ipv4 ipv6 ipv4Dns
|
||||
void KyNetResource::getDynamicIpInfo(QString uuid, KyDetailInfo &conInfo)
|
||||
{
|
||||
//已激活的网络 详情页显示动态ipv4 ipv6 dns
|
||||
QString ipv4,ipv6;
|
||||
QList<QHostAddress> ipv4Dns,ipv6Dns;
|
||||
KyActiveConnectResourse activeResourse;
|
||||
activeResourse.getActiveConnectIpInfo(uuid,ipv4,ipv6);
|
||||
activeResourse.getActiveConnectDnsInfo(uuid,ipv4Dns,ipv6Dns);
|
||||
|
||||
//Ipv6
|
||||
if (!ipv6.isEmpty()) {
|
||||
conInfo.strDynamicIpv6 = ipv6;
|
||||
}
|
||||
|
||||
//IPv4
|
||||
if (!ipv4.isEmpty()) {
|
||||
conInfo.strDynamicIpv4 = ipv4;
|
||||
}
|
||||
|
||||
if (!ipv4Dns.isEmpty()) {
|
||||
conInfo.strDynamicIpv4Dns = ipv4Dns.at(0).toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifndef KYNETRESOURCE_H
|
||||
#define KYNETRESOURCE_H
|
||||
|
||||
#include "kylinnetworkresourcemanager.h"
|
||||
#include "kylinconnectsetting.h"
|
||||
#include <NetworkManagerQt/Ipv4Setting>
|
||||
#include <NetworkManagerQt/Ipv6Setting>
|
||||
|
||||
class KyDetailInfo
|
||||
{
|
||||
public:
|
||||
QString strSecType;
|
||||
QString strChan;
|
||||
QString strMac;
|
||||
QString strHz;
|
||||
QString strBandWidth;
|
||||
QString strDynamicIpv4;
|
||||
QString strDynamicIpv6;
|
||||
QString strDynamicIpv4Dns;
|
||||
bool isAutoConnect = false;
|
||||
};
|
||||
|
||||
class KyNetResource : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit KyNetResource(QObject *parent = nullptr);
|
||||
~KyNetResource();
|
||||
|
||||
void getConnectionSetting(QString connectUuid, KyConnectSetting &connectSetting);
|
||||
|
||||
protected:
|
||||
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
|
||||
|
||||
void getBaseInfo(QString devName,QString ssid, bool isWlan, bool isActive, KyDetailInfo &conInfo);
|
||||
void getDynamicIpInfo(QString uuid, KyDetailInfo &conInfo);
|
||||
|
||||
private:
|
||||
void getIpv4ConnectSetting(NetworkManager::Ipv4Setting::Ptr &ipv4Setting,
|
||||
KyConnectSetting &connectSetting);
|
||||
void getIpv6ConnectSetting(NetworkManager::Ipv6Setting::Ptr &ipv6Setting,
|
||||
KyConnectSetting &connectSetting);
|
||||
};
|
||||
|
||||
#endif // KYNETRESOURCE_H
|
|
@ -0,0 +1,256 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#include "kylinnetworkdeviceresource.h"
|
||||
#include "kylinnetworkmanagerutil.h"
|
||||
#include "kylinconnectoperation.h"
|
||||
|
||||
#define VIRTURAL_DEVICE_PATH "/sys/devices/virtual/net"
|
||||
#define LOG_FLAG "KyNetworkDeviceResourse"
|
||||
|
||||
KyNetworkDeviceResourse::KyNetworkDeviceResourse(QObject *parent) : QObject(parent)
|
||||
{
|
||||
m_networkResourceInstance = KyNetworkResourceManager::getInstance();
|
||||
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceCarrierChange,
|
||||
this, &KyNetworkDeviceResourse::carrierChange);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceStateChange,
|
||||
this, &KyNetworkDeviceResourse::deviceStateChange);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceManagedChange,
|
||||
this, &KyNetworkDeviceResourse::deviceManagedChange);
|
||||
// connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceBitRateChange,
|
||||
// this, &KyNetworkDeviceResourse::deviceBitRateChange);
|
||||
// connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceMacAddressChange,
|
||||
// this, &KyNetworkDeviceResourse::deviceMacAddressChange);
|
||||
// connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceActiveChange,
|
||||
// this, &KyNetworkDeviceResourse::deviceActiveChange);
|
||||
|
||||
}
|
||||
|
||||
KyNetworkDeviceResourse::~KyNetworkDeviceResourse()
|
||||
{
|
||||
m_networkResourceInstance = nullptr;
|
||||
}
|
||||
|
||||
void KyNetworkDeviceResourse::getNetworkDeviceList(
|
||||
KyDeviceType deviceType,
|
||||
QStringList &networkDeviceList)
|
||||
{
|
||||
NetworkManager::Device::List deviceList
|
||||
= m_networkResourceInstance->getNetworkDeviceList();
|
||||
|
||||
if (deviceList.isEmpty()) {
|
||||
qDebug() << LOG_FLAG <<"network device is not exist. device type" << deviceType;
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkManager::Device::Ptr devicePtr = nullptr;
|
||||
for (int index = 0; index < deviceList.size(); ++index) {
|
||||
devicePtr = deviceList.at(index);
|
||||
if (devicePtr.isNull()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (devicePtr->type() == deviceType) {
|
||||
if (DEVICE_TYPE_ETHERNET == deviceType) {
|
||||
//为了区分有线网卡和虚拟网卡
|
||||
qDebug()<< LOG_FLAG << "device uni" << devicePtr->udi();
|
||||
if (devicePtr->udi().startsWith(VIRTURAL_DEVICE_PATH)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
networkDeviceList<<devicePtr->interfaceName();
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void KyNetworkDeviceResourse::getHardwareInfo(QString ifaceName, QString &hardAddress, int &bandWith)
|
||||
{
|
||||
NetworkManager::Device::Ptr connectDevice =
|
||||
m_networkResourceInstance->findDeviceByName(ifaceName);
|
||||
|
||||
if (nullptr == connectDevice || !connectDevice->isValid()) {
|
||||
qWarning()<< LOG_FLAG <<"get hardware info failed, the device" << ifaceName << "is not existed";
|
||||
hardAddress.clear();
|
||||
bandWith = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (connectDevice->type()) {
|
||||
case NetworkManager::Device::Ethernet:
|
||||
{
|
||||
NetworkManager::WiredDevice *wiredDevicePtr =
|
||||
qobject_cast<NetworkManager::WiredDevice *>(connectDevice.data());
|
||||
hardAddress = wiredDevicePtr->hardwareAddress();
|
||||
bandWith = wiredDevicePtr->bitRate();
|
||||
break;
|
||||
}
|
||||
case NetworkManager::Device::Wifi:
|
||||
{
|
||||
NetworkManager::WirelessDevice *wirelessDevicePtr =
|
||||
qobject_cast<NetworkManager::WirelessDevice *>(connectDevice.data());
|
||||
hardAddress = wirelessDevicePtr->hardwareAddress();
|
||||
bandWith = wirelessDevicePtr->bitRate();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
hardAddress = "";
|
||||
bandWith = 0;
|
||||
qWarning()<< LOG_FLAG << "the network device type is undefined" << connectDevice->type();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
KyDeviceState KyNetworkDeviceResourse::getDeviceState(QString deviceName)
|
||||
{
|
||||
NetworkManager::Device::Ptr connectDevice =
|
||||
m_networkResourceInstance->findDeviceByName(deviceName);
|
||||
if (!connectDevice.isNull() && connectDevice->isValid()) {
|
||||
return (KyDeviceState)connectDevice->state();
|
||||
}
|
||||
|
||||
qWarning()<< LOG_FLAG <<"get device state failed, the device is " << deviceName;
|
||||
|
||||
return DEVICE_STATE_UNKNOWN;
|
||||
}
|
||||
|
||||
bool KyNetworkDeviceResourse::wiredDeviceIsCarriered(QString deviceName)
|
||||
{
|
||||
NetworkManager::Device::Ptr connectDevice =
|
||||
m_networkResourceInstance->findDeviceByName(deviceName);
|
||||
if (connectDevice.isNull()) {
|
||||
qWarning()<< LOG_FLAG << "check device carriered failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (connectDevice->isValid()
|
||||
&& NetworkManager::Device::Type::Ethernet == connectDevice->type()) {
|
||||
NetworkManager::WiredDevice *wiredDevicePtr =
|
||||
qobject_cast<NetworkManager::WiredDevice *>(connectDevice.data());
|
||||
return wiredDevicePtr->carrier();
|
||||
}
|
||||
|
||||
qWarning()<< LOG_FLAG << deviceName <<" can not get carrier state.";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void KyNetworkDeviceResourse::getDeviceActiveAPInfo(const QString devName, QString &strMac, uint &iHz, uint &iChan, QString &secuType)
|
||||
{
|
||||
strMac.clear();
|
||||
iHz = 0;
|
||||
iChan = 0;
|
||||
secuType.clear();
|
||||
|
||||
NetworkManager::Device::Ptr connectDevice =
|
||||
m_networkResourceInstance->findDeviceByName(devName);
|
||||
|
||||
if (nullptr == connectDevice || !connectDevice->isValid()) {
|
||||
qWarning()<< LOG_FLAG <<"getDeviceActiveAPInfo failed, the device" << devName << "is not existed";
|
||||
return;
|
||||
}
|
||||
|
||||
switch (connectDevice->type()) {
|
||||
case NetworkManager::Device::Wifi:
|
||||
{
|
||||
NetworkManager::WirelessDevice *wirelessDevicePtr =
|
||||
qobject_cast<NetworkManager::WirelessDevice *>(connectDevice.data());
|
||||
NetworkManager::AccessPoint::Ptr apPtr = wirelessDevicePtr->activeAccessPoint();
|
||||
if (apPtr.isNull()) {
|
||||
break;
|
||||
}
|
||||
strMac = apPtr->hardwareAddress();
|
||||
iHz = apPtr->frequency();
|
||||
iChan = NetworkManager::findChannel(iHz);
|
||||
NetworkManager::AccessPoint::Capabilities capability = apPtr->capabilities();
|
||||
NetworkManager::AccessPoint::WpaFlags wpaFlag = apPtr->wpaFlags();
|
||||
NetworkManager::AccessPoint::WpaFlags rsnFlag = apPtr->rsnFlags();
|
||||
secuType = enumToQstring(capability, wpaFlag, rsnFlag);
|
||||
break;
|
||||
}
|
||||
case NetworkManager::Device::Ethernet:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int KyNetworkDeviceResourse::getWirelessDeviceCapability(const QString deviceName)
|
||||
{
|
||||
NetworkManager::Device::Ptr connectDevice =
|
||||
m_networkResourceInstance->findDeviceByName(deviceName);
|
||||
if (!connectDevice.isNull() && connectDevice->isValid()
|
||||
&& NetworkManager::Device::Type::Wifi == connectDevice->type()) {
|
||||
NetworkManager::WirelessDevice *wirelessDevicePtr =
|
||||
qobject_cast<NetworkManager::WirelessDevice *>(connectDevice.data());
|
||||
|
||||
int cap = 0;
|
||||
if (wirelessDevicePtr->wirelessCapabilities() & NetworkManager::WirelessDevice::ApCap) {
|
||||
cap = cap | 0x01;
|
||||
}
|
||||
if (wirelessDevicePtr->wirelessCapabilities() & NetworkManager::WirelessDevice::Freq2Ghz) {
|
||||
cap = cap | 0x02;
|
||||
}
|
||||
if (wirelessDevicePtr->wirelessCapabilities() & NetworkManager::WirelessDevice::Freq5Ghz) {
|
||||
cap = cap | 0x04;
|
||||
}
|
||||
return cap;
|
||||
} else {
|
||||
qWarning()<<"[KyNetworkDeviceResourse]"<<deviceName<<" is not valid or not wireless.";
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool KyNetworkDeviceResourse::wirelessDeviceIsExist(const QString devName)
|
||||
{
|
||||
QStringList list;
|
||||
getNetworkDeviceList(DEVICE_TYPE_WIFI, list);
|
||||
return list.contains(devName);
|
||||
}
|
||||
|
||||
void KyNetworkDeviceResourse::setDeviceManaged(QString devName, bool managed)
|
||||
{
|
||||
QString dbusPath;
|
||||
NetworkManager::Device::Ptr connectDevice =
|
||||
m_networkResourceInstance->findDeviceByName(devName);
|
||||
if (!connectDevice.isNull() && connectDevice->isValid()) {
|
||||
dbusPath = connectDevice->uni();
|
||||
} else {
|
||||
qWarning()<<"[KyNetworkDeviceResourse] can not find device " << devName;
|
||||
return;
|
||||
}
|
||||
setDeviceManagedByGDbus(dbusPath, managed);
|
||||
}
|
||||
|
||||
bool KyNetworkDeviceResourse::getDeviceManaged(QString deviceName)
|
||||
{
|
||||
NetworkManager::Device::Ptr connectDevice =
|
||||
m_networkResourceInstance->findDeviceByName(deviceName);
|
||||
if (connectDevice != nullptr && connectDevice->isValid()) {
|
||||
return connectDevice->managed();
|
||||
} else {
|
||||
qWarning()<<"[KyNetworkDeviceResourse] can not find device " << deviceName;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifndef KYLINNETORKDEVICERESOURCE_H
|
||||
#define KYLINNETORKDEVICERESOURCE_H
|
||||
|
||||
#include <QString>
|
||||
#include "kylinnetworkresourcemanager.h"
|
||||
#include "kylinconnectitem.h"
|
||||
#include "kylinwiredconnectoperation.h"
|
||||
|
||||
//设备操作和信息获取
|
||||
class KyNetworkDeviceResourse : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit KyNetworkDeviceResourse(QObject *parent = nullptr);
|
||||
~KyNetworkDeviceResourse();
|
||||
|
||||
public:
|
||||
void getNetworkDeviceList(KyDeviceType deviceType, QStringList &networkDeviceList);
|
||||
void getHardwareInfo(QString ifaceName, QString &hardAddress, int &bandWith);
|
||||
|
||||
//移动热点有关
|
||||
void getDeviceActiveAPInfo(const QString devName, QString &strMac, uint &iHz, uint &iChan, QString &secuType);
|
||||
int getWirelessDeviceCapability(const QString deviceName);
|
||||
|
||||
KyDeviceState getDeviceState(QString deviceName);
|
||||
|
||||
bool wiredDeviceIsCarriered(QString deviceName);
|
||||
bool wirelessDeviceIsExist(const QString devName);
|
||||
|
||||
void setDeviceManaged(QString devName, bool managed);
|
||||
bool getDeviceManaged(QString devName);
|
||||
|
||||
private:
|
||||
void getActiveConnection(QString &deviceName, QString &connectUuid);
|
||||
void saveActiveConnection(QString &deviceName, QString &connectUuid);
|
||||
|
||||
Q_SIGNALS:
|
||||
void deviceStateChange(QString deviceName, KyDeviceState newstate, KyDeviceState oldstate,
|
||||
NetworkManager::Device::StateChangeReason reason);
|
||||
void carrierChange(QString deviceName, bool pluged);
|
||||
|
||||
void wiredDeviceEnableChange(QString, bool);
|
||||
void deviceManagedChange(QString deviceName, bool managed);
|
||||
|
||||
// void deviceBitRateChanage(QString deviceName, int bitRate);
|
||||
// void deviceMacAddressChanage(QString deviceName, const QString &hwAddress);
|
||||
// void deviceActiveChanage(QString deviceName, bool deivceActive);
|
||||
|
||||
private:
|
||||
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
|
||||
};
|
||||
#endif // KYLINNETORKDEVICERESOURCE_H
|
|
@ -0,0 +1,240 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#include <QSettings>
|
||||
#include <QTextCodec>
|
||||
#include <QDir>
|
||||
#include <dbus-1.0/dbus/dbus.h>
|
||||
#include <glib-2.0/glib.h>
|
||||
#include <dbus-1.0/dbus/dbus-glib.h>
|
||||
#include <gio/gio.h>
|
||||
#include "kylinnetworkmanagerutil.h"
|
||||
#include "kylinnetworkdeviceresource.h"
|
||||
#define LOG_FLAG "[kylin-util]"
|
||||
const QString CONFIG_FILE_PATH = QDir::homePath() + "/.config/ukui/kylin-nm.conf";
|
||||
|
||||
QString getConnectTypeByDbus(QString connectPath)
|
||||
{
|
||||
QString connectType = "";
|
||||
if (connectPath.isEmpty()) {
|
||||
qWarning() << LOG_FLAG << "connect path is empty, so can not get connect type";
|
||||
return connectType;
|
||||
}
|
||||
|
||||
QDBusInterface dbusInterface("org.freedesktop.NetworkManager",
|
||||
connectPath,
|
||||
"org.freedesktop.NetworkManager.Settings.Connection",
|
||||
QDBusConnection::systemBus());
|
||||
|
||||
QDBusMessage result = dbusInterface.call("GetSettings");
|
||||
const QDBusArgument &dbusArg1st = result.arguments().at( 0 ).value<QDBusArgument>();
|
||||
QMap<QString, QMap<QString, QVariant>> map;
|
||||
dbusArg1st >> map;
|
||||
|
||||
if (map.isEmpty()) {
|
||||
qWarning() << LOG_FLAG <<"get connection settings failed.";
|
||||
return connectType;
|
||||
}
|
||||
|
||||
QMap<QString,QVariant> connectMap = map.value(KEY_CONNECTION);
|
||||
if (connectMap.isEmpty()) {
|
||||
qWarning() << LOG_FLAG <<"threre is not connection settings";
|
||||
return connectType;
|
||||
}
|
||||
|
||||
connectType = connectMap.value(KEY_CONNECT_TYPE).toString();
|
||||
return connectType;
|
||||
}
|
||||
|
||||
QString getSsidFromByteArray(QByteArray &rawSsid)
|
||||
{
|
||||
QString wifiSsid = "";
|
||||
|
||||
if (rawSsid.isEmpty()) {
|
||||
qWarning() << LOG_FLAG << "wifi raw ssid is empty";
|
||||
return wifiSsid;
|
||||
}
|
||||
|
||||
QTextCodec::ConverterState state;
|
||||
QTextCodec *codec = QTextCodec::codecForName("UTF-8");
|
||||
codec->toUnicode( rawSsid.constData(), rawSsid.size(), &state);
|
||||
if (state.invalidChars > 0) {
|
||||
wifiSsid = QTextCodec::codecForName("GBK")->toUnicode(rawSsid);
|
||||
} else {
|
||||
wifiSsid = rawSsid;
|
||||
}
|
||||
|
||||
return wifiSsid;
|
||||
}
|
||||
|
||||
QString enumToQstring(NetworkManager::AccessPoint::Capabilities apCapability,
|
||||
NetworkManager::AccessPoint::WpaFlags wpaFlags,
|
||||
NetworkManager::AccessPoint::WpaFlags rsnFlags)
|
||||
{
|
||||
QString out;
|
||||
|
||||
if ((apCapability & AP_CAPABILITY_PRIVACY)
|
||||
&& (wpaFlags == AP_SECURITY_NONE)
|
||||
&& (rsnFlags == AP_SECURITY_NONE)) {
|
||||
out += "WEP ";
|
||||
}
|
||||
|
||||
if (wpaFlags != AP_SECURITY_NONE) {
|
||||
out += "WPA1 ";
|
||||
}
|
||||
|
||||
if ((rsnFlags & AP_SECURITY_KEY_MGMT_PSK)
|
||||
|| (rsnFlags & AP_SECURITY_KEY_MGMT_802_1X)) {
|
||||
out += "WPA2 ";
|
||||
}
|
||||
|
||||
if (rsnFlags & AP_SECURITY_KEY_MGMT_SAE) {
|
||||
out += "WPA3 ";
|
||||
}
|
||||
|
||||
if ((wpaFlags & AP_SECURITY_KEY_MGMT_802_1X)
|
||||
|| (rsnFlags & AP_SECURITY_KEY_MGMT_802_1X)) {
|
||||
out += "802.1X ";
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
void setWiredEnabledByGDbus(bool enabled)
|
||||
{
|
||||
GDBusProxy *props_proxy;
|
||||
GVariant *ret = NULL;
|
||||
GError *error = NULL;
|
||||
|
||||
/* Create a D-Bus object proxy for the active connection object's properties */
|
||||
props_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
|
||||
G_DBUS_PROXY_FLAGS_NONE,
|
||||
NULL,
|
||||
"org.freedesktop.NetworkManager",
|
||||
"/org/freedesktop/NetworkManager",
|
||||
"org.freedesktop.DBus.Properties",
|
||||
NULL, NULL);
|
||||
g_assert (props_proxy);
|
||||
|
||||
/* Get the object path of the Connection details */
|
||||
ret = g_dbus_proxy_call_sync (props_proxy,
|
||||
"Set",
|
||||
g_variant_new ("(ssv)",
|
||||
"org.freedesktop.NetworkManager",
|
||||
"WiredEnabled",
|
||||
g_variant_new_boolean(enabled)),
|
||||
G_DBUS_CALL_FLAGS_NONE, -1,
|
||||
NULL, &error);
|
||||
if (!ret) {
|
||||
g_dbus_error_strip_remote_error (error);
|
||||
qDebug() << "failed to setWiredEnabledByGDbus";
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
out:
|
||||
if (ret)
|
||||
g_variant_unref (ret);
|
||||
g_object_unref (props_proxy);
|
||||
}
|
||||
|
||||
bool getWiredEnabledByGDbus()
|
||||
{
|
||||
GDBusProxy *props_proxy;
|
||||
GVariant *ret = NULL, *path_value = NULL;
|
||||
GError *error = NULL;
|
||||
gboolean bRet = false;
|
||||
|
||||
/* Create a D-Bus object proxy for the active connection object's properties */
|
||||
props_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
|
||||
G_DBUS_PROXY_FLAGS_NONE,
|
||||
NULL,
|
||||
"org.freedesktop.NetworkManager",
|
||||
"/org/freedesktop/NetworkManager",
|
||||
"org.freedesktop.DBus.Properties",
|
||||
NULL, NULL);
|
||||
g_assert (props_proxy);
|
||||
|
||||
/* Get the object path of the Connection details */
|
||||
ret = g_dbus_proxy_call_sync (props_proxy,
|
||||
"Get",
|
||||
g_variant_new ("(ss)",
|
||||
"org.freedesktop.NetworkManager",
|
||||
"WiredEnabled"),
|
||||
G_DBUS_CALL_FLAGS_NONE, -1,
|
||||
NULL, &error);
|
||||
if (!ret) {
|
||||
g_dbus_error_strip_remote_error (error);
|
||||
qDebug() << "failed to setWiredEnabledByGDbus";
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
g_variant_get (ret, "(v)", &path_value);
|
||||
if (!g_variant_is_of_type (path_value, G_VARIANT_TYPE_BOOLEAN)) {
|
||||
g_warning ("Unexpected type returned getting Connection property: %s",
|
||||
g_variant_get_type_string (path_value));
|
||||
goto out;
|
||||
}
|
||||
|
||||
bRet = g_variant_get_boolean (path_value);
|
||||
|
||||
out:
|
||||
if (path_value)
|
||||
g_variant_unref (path_value);
|
||||
if (ret)
|
||||
g_variant_unref (ret);
|
||||
g_object_unref (props_proxy);
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
|
||||
void setDeviceManagedByGDbus(QString dbusPath, bool managed)
|
||||
{
|
||||
GDBusProxy *props_proxy;
|
||||
GVariant *ret = NULL;
|
||||
GError *error = NULL;
|
||||
|
||||
/* Create a D-Bus object proxy for the active connection object's properties */
|
||||
props_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
|
||||
G_DBUS_PROXY_FLAGS_NONE,
|
||||
NULL,
|
||||
"org.freedesktop.NetworkManager",
|
||||
dbusPath.toStdString().c_str(),
|
||||
"org.freedesktop.DBus.Properties",
|
||||
NULL, NULL);
|
||||
g_assert (props_proxy);
|
||||
|
||||
/* Get the object path of the Connection details */
|
||||
ret = g_dbus_proxy_call_sync (props_proxy,
|
||||
"Set",
|
||||
g_variant_new ("(ssv)",
|
||||
"org.freedesktop.NetworkManager.Device",
|
||||
"Managed",
|
||||
g_variant_new_boolean(managed)),
|
||||
G_DBUS_CALL_FLAGS_NONE, -1,
|
||||
NULL, &error);
|
||||
if (!ret) {
|
||||
g_dbus_error_strip_remote_error (error);
|
||||
qDebug() << "failed to setWiredEnabledByGDbus";
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
out:
|
||||
if (ret)
|
||||
g_variant_unref (ret);
|
||||
g_object_unref (props_proxy);
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifndef KYLINUTIL_H
|
||||
#define KYLINUTIL_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
#include <QtDBus/QDBusConnection>
|
||||
#include <QtDBus/QDBusMessage>
|
||||
#include <QtDBus/QDBusInterface>
|
||||
#include <QtDBus/QDBusObjectPath>
|
||||
#include <QDBusReply>
|
||||
#include <QDBusObjectPath>
|
||||
|
||||
#include <NetworkManagerQt/AccessPoint>
|
||||
#include "kylinnetworkresourcetype.h"
|
||||
#include "kywirelessconnectoperation.h"
|
||||
|
||||
#define KEY_CONNECTION "connection"
|
||||
#define KEY_CONNECT_TYPE "type"
|
||||
#define ETHERNET_TYPE "802-3-ethernet"
|
||||
|
||||
QString getConnectTypeByDbus(QString connectPath);
|
||||
QString getSsidFromByteArray(QByteArray &rawSsid);
|
||||
QString enumToQstring(NetworkManager::AccessPoint::Capabilities cap, NetworkManager::AccessPoint::WpaFlags wpa_flags,NetworkManager::AccessPoint::WpaFlags rsn_flags);
|
||||
|
||||
void setWiredEnabledByGDbus(bool enabled);
|
||||
void setDeviceManagedByGDbus(QString dbusPath, bool managed);
|
||||
bool getWiredEnabledByGDbus();
|
||||
|
||||
|
||||
#endif // KYLINUTIL_H
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,245 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef KYLINNETWORKRESOURCEMANAGER_H
|
||||
#define KYLINNETWORKRESOURCEMANAGER_H
|
||||
|
||||
#include "NetworkManagerQt/Manager"
|
||||
#include "NetworkManagerQt/Settings"
|
||||
#include "NetworkManagerQt/WirelessDevice"
|
||||
#include "NetworkManagerQt/GenericTypes"
|
||||
#include "NetworkManagerQt/VpnConnection"
|
||||
#include "NetworkManagerQt/WirelessDevice"
|
||||
#include "NetworkManagerQt/AdslDevice"
|
||||
#include "NetworkManagerQt/WiredDevice"
|
||||
#include "NetworkManagerQt/WimaxDevice"
|
||||
#include "NetworkManagerQt/VlanDevice"
|
||||
#include "NetworkManagerQt/BondDevice"
|
||||
#include "NetworkManagerQt/BridgeDevice"
|
||||
#include "NetworkManagerQt/GenericDevice"
|
||||
#include "NetworkManagerQt/InfinibandDevice"
|
||||
#include "NetworkManagerQt/BluetoothDevice"
|
||||
#include "NetworkManagerQt/OlpcMeshDevice"
|
||||
#include "NetworkManagerQt/TeamDevice"
|
||||
#include "NetworkManagerQt/WirelessSetting"
|
||||
#include "NetworkManagerQt/WirelessSecuritySetting"
|
||||
#include "NetworkManagerQt/Utils"
|
||||
#include "NetworkManagerQt/ConnectionSettings"
|
||||
#include "NetworkManagerQt/Security8021xSetting"
|
||||
#include <QDBusPendingCallWatcher>
|
||||
#include <QMetaEnum>
|
||||
|
||||
#include "kylinnetworkresourcetype.h"
|
||||
|
||||
#define VIRTURAL_DEVICE_PATH "/sys/devices/virtual/net"
|
||||
|
||||
class KyNetworkResourceManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static KyNetworkResourceManager* getInstance();
|
||||
static void Release();
|
||||
|
||||
public:
|
||||
explicit KyNetworkResourceManager(QObject *parent = nullptr);
|
||||
~KyNetworkResourceManager();
|
||||
|
||||
public:
|
||||
NetworkManager::ActiveConnection::Ptr findActiveConnectionByPath(QString const & path);
|
||||
NetworkManager::ActiveConnection::Ptr findActiveConnectByUuid(const QString activeConnectUuid);
|
||||
|
||||
NetworkManager::Connection::Ptr findConnectByUuid(const QString uuid);
|
||||
|
||||
NetworkManager::Device::Ptr findDeviceByUni(QString const &deviceUni);
|
||||
NetworkManager::Device::Ptr findDeviceByName(QString interfaceName);
|
||||
|
||||
NetworkManager::WirelessNetwork::Ptr findWifiNetwork(QString const &ssid, QString const &deviceUni);
|
||||
|
||||
NetworkManager::ActiveConnection::List getActiveConnectList();
|
||||
NetworkManager::Connection::List getConnectList();
|
||||
NetworkManager::Device::List getNetworkDeviceList();
|
||||
NetworkManager::WirelessNetwork::List getWifiNetworkList();
|
||||
|
||||
bool isActiveConnection(QString uuid);
|
||||
bool isActivatingConnection(QString uuid);
|
||||
|
||||
void getConnectivity(KyConnectivity &connectivity);
|
||||
|
||||
bool NetworkManagerIsInited();
|
||||
|
||||
void requestScan(NetworkManager::WirelessDevice *p_wirelessDevice);
|
||||
|
||||
bool isWiredConnect(QString connectPath);
|
||||
bool isApConnection(NetworkManager::Connection::Ptr connectPtr);
|
||||
|
||||
private:
|
||||
void removeActiveConnection(int pos);
|
||||
void clearActiveConnections();
|
||||
void insertActiveConnections();
|
||||
void addActiveConnection(NetworkManager::ActiveConnection::Ptr conn);
|
||||
|
||||
void removeConnection(int pos);
|
||||
void clearConnections();
|
||||
void insertConnections();
|
||||
void addConnection(NetworkManager::Connection::Ptr conn);
|
||||
|
||||
void removeDevice(int pos);
|
||||
void clearDevices();
|
||||
void insertDevices();
|
||||
void addDevice(NetworkManager::Device::Ptr conn);
|
||||
void updateDeviceName(NetworkManager::Device *p_device);
|
||||
|
||||
void removeWifiNetwork(int pos);
|
||||
void clearWifiNetworks();
|
||||
void insertWifiNetworks();
|
||||
void addWifiNetwork(NetworkManager::WirelessNetwork::Ptr net);
|
||||
|
||||
void connectionDump();
|
||||
|
||||
void wifiNetworkAdd(NetworkManager::Device * dev, QString const & ssid);
|
||||
void wifiNetworkUpdate(NetworkManager::WirelessNetwork * net);
|
||||
void wifiNetworkRemove(NetworkManager::Device * dev, QString const & ssid);
|
||||
|
||||
|
||||
void wirelessActiveStateChange(NetworkManager::ConnectionSettings::Ptr connectSettingsPtr,
|
||||
QString deviceName, QString uuid, KyConnectState state);
|
||||
void wiredActiveStateChange(QString connectPath, QString deviceName,
|
||||
QString uuid, KyConnectState state);
|
||||
void connectActiveStateChange(NetworkManager::Connection::Ptr connectPtr,
|
||||
QString deviceName, KyConnectState state);
|
||||
|
||||
private Q_SLOTS:
|
||||
void onServiceAppear(QString, QString, QString);
|
||||
void onPropertiesChanged(QVariantMap qvm);
|
||||
|
||||
Q_SIGNALS:
|
||||
|
||||
// wired connect
|
||||
void wiredConnectionAdd(QString devName, QString connectUuid, QString connectName, QString connectPath);
|
||||
void wiredConnectionUpdate(QString devName, QString connectUuid, QString connectName, QString connectPath);
|
||||
// void wiredConnectionRemove(QString path);
|
||||
|
||||
void connectionAdd(QString connectUuid, QString connectName, QString connectPath);
|
||||
void connectionUpdate(QString connectUuid, QString connectName, QString connectPath);
|
||||
void connectionRemove(QString path);
|
||||
|
||||
//device
|
||||
void wiredDeviceAdd(QString deviceName);
|
||||
void wiredDeviceUpdate(QString oldDeviceName, QString newDeviceName);
|
||||
|
||||
void wirelessDeviceAdd(QString deviceName);
|
||||
void wirelessDeviceUpdate(QString oldDeviceName, QString newDeviceName);
|
||||
|
||||
void deviceAdd(QString deviceName, KyDeviceType deviceType);
|
||||
void deviceUpdate(QString oldDeviceName, QString newDeviceName);
|
||||
void deviceRemove(QString deviceName);
|
||||
void deviceManagedChange(QString deviceName, bool managed);
|
||||
|
||||
void deviceActiveChange(QString deviceName, bool deviceActive);
|
||||
void deviceCarrierChange(QString deviceName, bool pluged);
|
||||
void deviceBitRateChange(QString deviceName, int bitRate);
|
||||
void deviceMacAddressChange(QString deviceName, const QString &hwAddress);
|
||||
void deviceStateChange(QString deviceName, KyDeviceState newstate, KyDeviceState oldstate,
|
||||
NetworkManager::Device::StateChangeReason reason);
|
||||
|
||||
//wireless
|
||||
void wifiNetworkRemoved(QString, QString);
|
||||
void wifiNetworkAdded(QString, QString);
|
||||
void wifiNetworkPropertyChange(NetworkManager::WirelessNetwork::Ptr net);
|
||||
void wifiNetworkDeviceDisappear();
|
||||
|
||||
void wirelessConnectionAdd(QString connectUuid, QString connectName, QString connectPath);
|
||||
void wirelessConnectionUpdate(QString devName,QString connectUuid, QString connectName, QString connectPath);
|
||||
// void wirelessConnectionRemove(QString path);
|
||||
|
||||
// void wiredConnectionUpdate(QString connectUuid, QString connectName, QString connectPath);
|
||||
|
||||
|
||||
//activate connection
|
||||
void activeConnectionAdd(QString uuid);
|
||||
void activeConnectionRemove(QString uuid);
|
||||
|
||||
void wiredConnectStateChange(QString deviceName, QString uuid, KyConnectState state);
|
||||
void wirelessConnectStateChange(QString deviceName, QString ssid, QString uuid, KyConnectState state);
|
||||
void wirelessApConnectStateChange();
|
||||
|
||||
|
||||
//general
|
||||
void connectivityChanged(KyConnectivity connectivity);
|
||||
void wifiEnabledChanged(bool);
|
||||
void wiredEnabledChanged(bool);
|
||||
void networkingEnabledChanged(bool);
|
||||
void primaryConnectionTypeChanged(KyConnectionType type);
|
||||
|
||||
public Q_SLOTS:
|
||||
void onInitNetwork();
|
||||
|
||||
//connection
|
||||
void onConnectionUpdated();
|
||||
//void onConnectionRemoved();
|
||||
|
||||
//active connection
|
||||
void onActiveConnectionChanged(NetworkManager::ActiveConnection::State state);
|
||||
void onVpnActiveConnectChangedReason(NetworkManager::VpnConnection::State state,
|
||||
NetworkManager::VpnConnection::StateChangeReason reason);
|
||||
|
||||
void onDeviceActiveChange();
|
||||
void onDeviceCarrierChange(bool pluged);
|
||||
void onDeviceBitRateChange(int bitRate);
|
||||
void onDeviceMacAddressChange(const QString &hwAddress);
|
||||
void onDeviceStateChanged(NetworkManager::Device::State newstate,
|
||||
NetworkManager::Device::State oldstate, NetworkManager::Device::StateChangeReason reason);
|
||||
|
||||
void onWifiNetworkAppeared(QString const & ssid);
|
||||
void onWifiNetworkDisappeared(QString const & ssid);
|
||||
|
||||
//wifi network
|
||||
void onUpdateWirelessNet();
|
||||
void onConnectivityChanged(NetworkManager::Connectivity connectivity);
|
||||
|
||||
//notifier
|
||||
void onDeviceAdded(QString const & uni);
|
||||
void onDeviceRemoved(QString const & uni);
|
||||
void onDeviceUpdated();
|
||||
void onDeviceManagedChange();
|
||||
|
||||
//active connection notifier
|
||||
void onActiveConnectionAdded(QString const & path);
|
||||
void onActiveConnectionRemoved(QString const & path);
|
||||
|
||||
//settings notifier
|
||||
void onConnectionAdded(QString const & path);
|
||||
void onConnectionRemoved(QString const & path);
|
||||
|
||||
void onPrimaryConnectionTypeChanged(NetworkManager::ConnectionSettings::ConnectionType);
|
||||
|
||||
public:
|
||||
static KyNetworkResourceManager* m_pInstance;
|
||||
|
||||
private:
|
||||
bool m_initFinished = false;
|
||||
NetworkManager::ActiveConnection::List m_activeConnectList;
|
||||
NetworkManager::Connection::List m_connectList;
|
||||
NetworkManager::Device::List m_deviceList;
|
||||
NetworkManager::WirelessNetwork::List m_wifiNetList;
|
||||
|
||||
QMap<QString, QString> m_deviceMap;
|
||||
};
|
||||
|
||||
|
||||
#endif // KYLINNETWORKRESOURCEMANAGER_H
|
|
@ -0,0 +1,224 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifndef KYLINNETWORKRESOURCETYPE_H
|
||||
#define KYLINNETWORKRESOURCETYPE_H
|
||||
|
||||
|
||||
typedef enum{
|
||||
CONNECT_STATE_UNKONW = 0, /**< The active connection is in an unknown state */
|
||||
CONNECT_STATE_ACTIVATING, /**< The connection is activating */
|
||||
CONNECT_STATE_ACTIVATED, /**< The connection is activated */
|
||||
CONNECT_STATE_DEACTIVATING, /**< The connection is being torn down and cleaned up */
|
||||
CONNECT_STATE_DEACTIVATED, /**< The connection is no longer active */
|
||||
|
||||
CONNECT_STATE_COUNT
|
||||
}KyConnectState;
|
||||
|
||||
typedef enum{
|
||||
CHANGE_REASON_UNKNOWN = 0, /**< The reason for the active connection state change is unknown */
|
||||
CHANGE_REASON_NONE, /**< No reason was given for the active connection state change */
|
||||
CHANGE_REASON_USER_DISCONNECTED, /**< The active connection changed state because the user disconnected it */
|
||||
CHANGE_REASON_DEVICE_DISCONNECTIED, /**< The active connection changed state because the device it was using was disconnected */
|
||||
CHANGE_REASON_SERVICE_STOP, /**< The service providing the VPN connection was stopped */
|
||||
|
||||
CHANGE_REASON_IPCONFIG_INVALID = 5, /**< The IP config of the active connection was invalid */
|
||||
CHANGE_REASON_CONNECT_TIMEOUT, /**< The connection attempt to the VPN service timed out */
|
||||
CHANGE_REASON_SERVICE_START_TIMEOUT,/**< A timeout occurred while starting the service providing the VPN connection */
|
||||
CHANGE_REASON_SERVICE_START_FAILED, /**< Starting the service providing the VPN connection failed */
|
||||
CHANGE_REASON_NO_SECRET, /**< Necessary secrets for the connection were not provided */
|
||||
|
||||
CHANGE_REASON_LOGIN_FAILED = 10, /**< Authentication to the server failed */
|
||||
CHANGE_REASON_CONNECT_REMOVED, /**< The connection was deleted from settings */
|
||||
CHANGE_REASON_DEPENDENCY_FAILED, /**< Master connection of this connection failed to activate */
|
||||
CHANGE_REASON_DEVICE_REALIZE_FAILED,/**< Could not create the software device link */
|
||||
CHANGE_REASON_DEVICE_REMOVED, /**< The device this connection depended on disappeared */
|
||||
|
||||
CHANGE_REASON_COUNT
|
||||
}KyConnectChangeReason;
|
||||
|
||||
typedef enum {
|
||||
CONNECT_TYPE_UNKNOWN = 0,
|
||||
CONNECT_TYPE_ADSL,
|
||||
CONNECT_TYPE_BLUETOOTH,
|
||||
CONNECT_TYPE_BOND,
|
||||
CONNECT_TYPE_BRIDGE,
|
||||
|
||||
CONNECT_TYPE_CDMA = 5,
|
||||
CONNECT_TYPE_GSM,
|
||||
CONNECT_TYPE_INFINIBAND,
|
||||
CONNECT_TYPE_OLPCMESH,
|
||||
CONNECT_TYPE_PPPOE,
|
||||
|
||||
CONNECT_TYPE_VLAN = 10,
|
||||
CONNECT_TYPE_VPN,
|
||||
CONNECT_TYPE_WIMAX,
|
||||
CONNECT_TYPE_WIRED,
|
||||
CONNECT_TYPE_WIRELESS,
|
||||
|
||||
CONNECT_TYPE_TEAM = 15,
|
||||
CONNECT_TYPE_GENERIC,
|
||||
CONNECT_TYPE_TUN,
|
||||
CONNECT_TYPE_IPTUNNEL,
|
||||
CONNECT_TYPE_WIREDGUARD,
|
||||
|
||||
CONNECT_TYPE_COUNT
|
||||
}KyConnectionType;
|
||||
|
||||
typedef enum {
|
||||
CONNECTIVITY_UNKNOWN = 0, /**< Network connectivity is unknown. */
|
||||
CONNECTIVITY_NO, /**< The host is not connected to any network. */
|
||||
CONNECTIVITY_PORTAL, /**< The host is behind a captive portal and cannot reach the full Internet. */
|
||||
CONNECTIVITY_LIMITED, /**< The host is connected to a network, but does not appear to be able to reach the full Internet. */
|
||||
CONNECTIVITY_FULL, /**< The host is connected to a network, and appears to be able to reach the full Internet. */
|
||||
|
||||
CONNECTIVITY_COUNT
|
||||
}KyConnectivity;
|
||||
|
||||
typedef enum {
|
||||
DEVICE_TYPE_UNKNOWN = 0, /**< Unknown device type */
|
||||
DEVICE_TYPE_ETHERNET, /**< Ieee8023 wired ethernet */
|
||||
DEVICE_TYPE_WIFI, /**< the Ieee80211 family of wireless networks */
|
||||
DEVICE_TYPE_UNUSED1, /**< Currently unused */
|
||||
DEVICE_TYPE_UNUSED2, /**< Currently unused */
|
||||
|
||||
DEVICE_TYPE_BLUETOOTH = 5, /**< network bluetooth device (usually a cell phone) */
|
||||
DEVICE_TYPE_OLPCMESH, /**< OLPC Mesh networking device */
|
||||
DEVICE_TYPE_WIMAX, /**< WiMax WWAN technology */
|
||||
DEVICE_TYPE_MODEM, /**< POTS, GSM, CDMA or LTE modems */
|
||||
DEVICE_TYPE_INFINIBAND, /**< Infiniband network device */
|
||||
|
||||
DEVICE_TYPE_BOND = 10, /**< Bond virtual device */
|
||||
DEVICE_TYPE_VLAN, /**< Vlan virtual device */
|
||||
DEVICE_TYPE_ADSL, /**< ADSL modem device */
|
||||
DEVICE_TYPE_BRIDGE, /**< Bridge virtual device */
|
||||
DEVICE_TYPE_GENERIC, /**< Generic device @since 1.0.0 */
|
||||
|
||||
DEVICE_TYPE_TEAM = 15, /**< Team master device @since 1.0.0 */
|
||||
DEVICE_TYPE_GRE, /**< Gre virtual device @since 1.2.0, @deprecated use IpTunnel instead*/
|
||||
DEVICE_TYPE_MACVLAN, /**< MacVlan virtual device @since 1.2.0 */
|
||||
DEVICE_TYPE_TUN, /**< Tun virtual device @since 1.2.0 */
|
||||
DEVICE_TYPE_VETH, /**< Veth virtual device @since 1.2.0 */
|
||||
|
||||
DEVICE_TYPE_IPTUNNEL = 20, /**< IP Tunneling Device @since 1.2.0 */
|
||||
DEVICE_TYPE_VXLAN, /**< Vxlan Device @since 1.2.0 */
|
||||
DEVICE_TYPE_MACSEC, /**< MacSec Device @since 1.6.0 */
|
||||
DEVICE_TYPE_DUMMY, /**< Dummy Device @since 1.8.0 */
|
||||
DEVICE_TYPE_PPP, /**< Ppp Device @since 1.10 */
|
||||
|
||||
DEVICE_TYPE_OVSINTERFACE = 25, /**< OvsInterface Device @since 1.10 */
|
||||
DEVICE_TYPE_OVSPORT, /**< OvsPort Device @since 1.10 */
|
||||
DEVICE_TYPE_OVSBRIDGE, /**< OvsBridge Device @since 1.10 */
|
||||
DEVICE_TYPE_WPAN, /**< Wpan Device @since 1.14 */
|
||||
DEVICE_TYPE_LOWPAN, /**< Lowpan Device @since 1.14 */
|
||||
|
||||
DEVICE_TYPE_WIREGUARD = 30, /**< WireGuard Device @since 1.14 */
|
||||
DEVICE_TYPE_WIFIP2P, /**< WifiP2P Device @since 1.16 */
|
||||
DEVICE_TYPE_COUNT
|
||||
}KyDeviceType;
|
||||
|
||||
typedef enum {
|
||||
DEVICE_STATE_UNKNOWN = 0, /**< The device is in an unknown state */
|
||||
DEVICE_STATE_UNMANAGED = 10, /**< The device is recognized but not managed by NetworkManager */
|
||||
DEVICE_STATE_UNAVAILABLE = 20, /**< The device cannot be used (carrier off, rfkill, etc) */
|
||||
DEVICE_STATE_DISCONNECTED = 30, /**< The device is not connected */
|
||||
DEVICE_STATE_PREPARING = 40, /**< The device is preparing to connect */
|
||||
DEVICE_STATE_CONFIGURINGHARDWARE = 50, /**< The device is being configured */
|
||||
DEVICE_STATE_NEEDAUTH = 60, /**< The device is awaiting secrets necessary to continue connection */
|
||||
DEVICE_STATE_CONFIGURINGIP = 70, /**< The IP settings of the device are being requested and configured */
|
||||
DEVICE_STATE_CHECKINGIP = 80, /**< The device's IP connectivity ability is being determined */
|
||||
DEVICE_STATE_WAITINGFORSECONDARIES = 90, /**< The device is waiting for secondary connections to be activated */
|
||||
DEVICE_STATE_ACTIVATED = 100, /**< The device is active */
|
||||
DEVICE_STATE_DEACTIVATING = 110, /**< The device's network connection is being torn down */
|
||||
DEVICE_STATE_FAILED = 120 /**< The device is in a failure state following an attempt to activate it */
|
||||
}KyDeviceState;
|
||||
|
||||
|
||||
/**
|
||||
* KyApSecurityFlags:
|
||||
* @AP_SEC_NONE: the access point has no special security requirements
|
||||
* @AP_SEC_PAIR_WEP40: 40/64-bit WEP is supported for
|
||||
* pairwise/unicast encryption
|
||||
* @AP_SEC_PAIR_WEP104: 104/128-bit WEP is supported for
|
||||
* pairwise/unicast encryption
|
||||
* @AP_SEC_PAIR_TKIP: TKIP is supported for pairwise/unicast encryption
|
||||
* @AP_SEC_PAIR_CCMP: AES/CCMP is supported for pairwise/unicast encryption
|
||||
* @AP_SEC_GROUP_WEP40: 40/64-bit WEP is supported for group/broadcast
|
||||
* encryption
|
||||
* @AP_SEC_GROUP_WEP104: 104/128-bit WEP is supported for
|
||||
* group/broadcast encryption
|
||||
* @AP_SEC_GROUP_TKIP: TKIP is supported for group/broadcast encryption
|
||||
* @AP_SEC_GROUP_CCMP: AES/CCMP is supported for group/broadcast
|
||||
* encryption
|
||||
* @AP_SEC_KEY_MGMT_PSK: WPA/RSN Pre-Shared Key encryption is
|
||||
* supported
|
||||
* @AP_SEC_KEY_MGMT_802_1X: 802.1x authentication and key management
|
||||
* is supported
|
||||
* @AP_SEC_KEY_MGMT_SAE: WPA/RSN Simultaneous Authentication of Equals is
|
||||
* supported
|
||||
*
|
||||
* 802.11 access point security and authentication flags. These flags describe
|
||||
* the current security requirements of an access point as determined from the
|
||||
* access point's beacon.
|
||||
**/
|
||||
typedef enum { /*< underscore_name=nm_802_11_ap_security_flags, flags >*/
|
||||
AP_SECURITY_NONE = 0x00000000,
|
||||
AP_SECURITY_PAIR_WEP40 = 0x00000001,
|
||||
AP_SECURITY_PAIR_WEP104 = 0x00000002,
|
||||
AP_SECURITY_PAIR_TKIP = 0x00000004,
|
||||
AP_SECURITY_PAIR_CCMP = 0x00000008,
|
||||
AP_SECURITY_GROUP_WEP40 = 0x00000010,
|
||||
AP_SECURITY_GROUP_WEP104 = 0x00000020,
|
||||
AP_SECURITY_GROUP_TKIP = 0x00000040,
|
||||
AP_SECURITY_GROUP_CCMP = 0x00000080,
|
||||
AP_SECURITY_KEY_MGMT_PSK = 0x00000100,
|
||||
AP_SECURITY_KEY_MGMT_802_1X = 0x00000200,
|
||||
AP_SECURITY_KEY_MGMT_SAE = 0x00000400,
|
||||
}KyApSecurityFlags;
|
||||
|
||||
/**
|
||||
* KyApCapabilities:
|
||||
* @AP_FLAGS_NONE: access point has no special capabilities
|
||||
* @AP_FLAGS_PRIVACY: access point requires authentication and
|
||||
* encryption (usually means WEP)
|
||||
* @AP_FLAGS_WPS: access point supports some WPS method
|
||||
* @AP_FLAGS_WPS_PBC: access point supports push-button WPS
|
||||
* @AP_FLAGS_WPS_PIN: access point supports PIN-based WPS
|
||||
*
|
||||
* 802.11 access point fCapabilities.
|
||||
**/
|
||||
typedef enum {
|
||||
AP_CAPABILITY_NONE = 0x00000000,
|
||||
AP_CAPABILITY_PRIVACY = 0x00000001,
|
||||
AP_CAPABILITY_WPS = 0x00000002,
|
||||
AP_CAPABILITY_WPS_PBC = 0x00000004,
|
||||
AP_CAPABILITY_WPS_PIN = 0x00000008,
|
||||
}KyApCapabilities;
|
||||
|
||||
//class KySecretFlagType {
|
||||
//public:
|
||||
// enum KySecretFlag{
|
||||
// SECRET_FLAG_NONE = 0,
|
||||
// SECRET_FLAG_AgentOWNED = 0x01,
|
||||
// SECRET_FLAG_NOTSAVED = 0x02,
|
||||
// SECRET_FLAG_NOTREQUIRED = 0x04
|
||||
// };
|
||||
// Q_DECLARE_FLAGS(kySecretFlags, KySecretFlag)
|
||||
//};
|
||||
//Q_DECLARE_OPERATORS_FOR_FLAGS(KySecretFlagType::KySecretFlags)
|
||||
|
||||
#endif // KYLINNETWORKRESOURCETYPE_H
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "kylinnetworkdeviceresource.h"
|
||||
#include "kylinnetworkmanagerutil.h"
|
||||
|
||||
#include <NetworkManagerQt/AdslDevice>
|
||||
#include <NetworkManagerQt/WiredDevice>
|
||||
#include <NetworkManagerQt/Ipv4Setting>
|
||||
#include <NetworkManagerQt/Ipv6Setting>
|
||||
#include <NetworkManagerQt/WiredSetting>
|
||||
|
||||
KyWiredConnectOperation::KyWiredConnectOperation(QObject *parent) : KyConnectOperation(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void KyWiredConnectOperation::createWiredConnect(KyConnectSetting &connectSettingsInfo)
|
||||
{
|
||||
connectSettingsInfo.dumpInfo();
|
||||
|
||||
NetworkManager::ConnectionSettings::Ptr wiredConnectionSettings = NetworkManager::ConnectionSettings::Ptr(new NetworkManager::ConnectionSettings(NetworkManager::ConnectionSettings::Wired));
|
||||
connectSettingSet(wiredConnectionSettings, connectSettingsInfo);
|
||||
|
||||
NetworkManager::Ipv4Setting::Ptr ipv4Setting = wiredConnectionSettings->setting(NetworkManager::Setting::Ipv4).dynamicCast<NetworkManager::Ipv4Setting>();
|
||||
ipv4SettingSet(ipv4Setting, connectSettingsInfo);
|
||||
|
||||
NetworkManager::Ipv6Setting::Ptr ipv6Setting = wiredConnectionSettings->setting(NetworkManager::Setting::Ipv6).dynamicCast<NetworkManager::Ipv6Setting>();
|
||||
ipv6SettingSet(ipv6Setting, connectSettingsInfo);
|
||||
|
||||
NetworkManager::WiredSetting::Ptr wiredSetting = wiredConnectionSettings->setting(NetworkManager::Setting::Wired).dynamicCast<NetworkManager::WiredSetting>();
|
||||
wiredSetting->setInitialized(true);
|
||||
|
||||
QDBusPendingCallWatcher * watcher;
|
||||
watcher = new QDBusPendingCallWatcher{NetworkManager::addConnection(wiredConnectionSettings->toMap()), this};
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished, [this](QDBusPendingCallWatcher * watcher) {
|
||||
if (watcher->isError() || !watcher->isValid()) {
|
||||
QString errorMessage = tr("create wired connection failed: ") + watcher->error().message();
|
||||
qWarning() << errorMessage;
|
||||
Q_EMIT this->createConnectionError(errorMessage);
|
||||
}
|
||||
watcher->deleteLater();
|
||||
});
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifndef KYLINWIREDCONNECTOPERATION_H
|
||||
#define KYLINWIREDCONNECTOPERATION_H
|
||||
|
||||
#include <QSettings>
|
||||
#include <QDir>
|
||||
|
||||
#include "kylinnetworkresourcemanager.h"
|
||||
#include "kylinconnectsetting.h"
|
||||
#include "kylinconnectoperation.h"
|
||||
|
||||
const QString WIRED_NETWORK_STATE_CONF_FILE = QDir::homePath() + "/.config/ukui/kylin-nm-wired.ini";
|
||||
|
||||
class KyWiredConnectOperation : public KyConnectOperation
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit KyWiredConnectOperation(QObject *parent = nullptr);
|
||||
|
||||
void createWiredConnect(KyConnectSetting &connectSettingsInfo);
|
||||
};
|
||||
|
||||
#endif // KYLINWIREDCONNECTOPERATION_H
|
|
@ -0,0 +1,143 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#include "kylinwirednetresource.h"
|
||||
#include "kywirelessconnectoperation.h"
|
||||
#include "kylinnetworkmanagerutil.h"
|
||||
|
||||
#include <NetworkManagerQt/Ipv4Setting>
|
||||
#include <NetworkManagerQt/Ipv6Setting>
|
||||
#include <NetworkManagerQt/VpnConnection>
|
||||
#include <NetworkManagerQt/VpnPlugin>
|
||||
#include <NetworkManagerQt/VpnSetting>
|
||||
|
||||
static bool subLanListSort(const KyWiredItem info1, const KyWiredItem info2)
|
||||
{
|
||||
QString name1 = info1.m_connectName;
|
||||
QString name2 = info2.m_connectName;
|
||||
bool result = true;
|
||||
if (QString::compare(name1, name2, Qt::CaseInsensitive) > 0) {
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static void lanListSort(QList<KyWiredItem> &list)
|
||||
{
|
||||
qSort(list.begin(), list.end(), subLanListSort);
|
||||
}
|
||||
|
||||
KyWiredConnectResourse::KyWiredConnectResourse(QObject *parent) : KyNetResource(parent)
|
||||
{
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::wiredConnectionAdd, this, &KyWiredConnectResourse::wiredConnectionAdd);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::wiredConnectionUpdate, this, &KyWiredConnectResourse::wiredConnectionUpdate);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::connectionRemove, this, &KyWiredConnectResourse::connectionRemove);
|
||||
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::wiredDeviceAdd, this, &KyWiredConnectResourse::wiredDeviceAdd);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::wiredDeviceUpdate, this, &KyWiredConnectResourse::wiredDeviceUpdate);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceRemove, this, &KyWiredConnectResourse::deviceRemove);
|
||||
}
|
||||
|
||||
//配合activeconnection 此处未单独区分已连接的wifi
|
||||
void KyWiredConnectResourse::getWiredList(QMap<QString,QList<KyWiredItem>> &map)
|
||||
{
|
||||
map.clear();
|
||||
kyWirdNetItemListInit();
|
||||
if (m_wiredNetworkMap.isEmpty()) {
|
||||
return;
|
||||
} else {
|
||||
QMap<QString, QList<KyWiredItem> >::iterator iter = m_wiredNetworkMap.begin();
|
||||
while (iter != m_wiredNetworkMap.end()) {
|
||||
lanListSort(m_wiredNetworkMap[iter.key()]);
|
||||
iter++;
|
||||
}
|
||||
map = m_wiredNetworkMap;
|
||||
}
|
||||
}
|
||||
|
||||
void KyWiredConnectResourse::getWiredConnectDetail(QString interface, QString uuid, KyDetailInfo &connectSetting)
|
||||
{
|
||||
getBaseInfo(interface, "", false, false, connectSetting);
|
||||
getDynamicIpInfo(uuid, connectSetting);
|
||||
}
|
||||
|
||||
KyWiredItem KyWiredConnectResourse::getConnectionItem(NetworkManager::Connection::Ptr connectPtr)
|
||||
{
|
||||
if (nullptr == connectPtr) {
|
||||
qWarning()<<"[KyConnectResourse]"<<"the connect is empty";
|
||||
return KyWiredItem();
|
||||
}
|
||||
|
||||
KyWiredItem connectionItem;
|
||||
connectionItem.m_connectName = connectPtr->name();
|
||||
connectionItem.m_connectUuid = connectPtr->uuid();
|
||||
connectionItem.m_connectPath = connectPtr->path();
|
||||
|
||||
return connectionItem;
|
||||
}
|
||||
|
||||
|
||||
void KyWiredConnectResourse::kyWirdNetItemListInit()
|
||||
{
|
||||
m_wiredNetworkMap.clear();
|
||||
NetworkManager::Connection::List connectList = m_networkResourceInstance->getConnectList();
|
||||
|
||||
if (connectList.empty()) {
|
||||
qWarning()<<"[KyConnectResourse]"<<"kyWirdNetItemListInit failed, the connect list is empty";
|
||||
return;
|
||||
}
|
||||
|
||||
KyNetworkDeviceResourse deviceResource;
|
||||
QStringList devList;
|
||||
deviceResource.getNetworkDeviceList(DEVICE_TYPE_ETHERNET, devList);
|
||||
if (devList.isEmpty()) {
|
||||
qWarning()<<"[KyConnectResourse]"<<"kyWirdNetItemListInit failed, the device list is empty";
|
||||
return;
|
||||
} else {
|
||||
for (int i = 0; i < devList.size(); ++i) {
|
||||
m_wiredNetworkMap.insert(devList.at(i), QList<KyWiredItem>());
|
||||
}
|
||||
}
|
||||
|
||||
NetworkManager::Connection::Ptr connectPtr = nullptr;
|
||||
for (int index = 0; index < connectList.size(); index++) {
|
||||
connectPtr = connectList.at(index);
|
||||
if (connectPtr.isNull()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!m_networkResourceInstance->isWiredConnect(connectPtr->path())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
KyWiredItem connectItem = getConnectionItem(connectPtr);
|
||||
if (connectItem.m_connectUuid.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
QString connectInterface = connectPtr->settings()->interfaceName();
|
||||
if (connectInterface.isEmpty()) {
|
||||
for (int i = 0; i < m_wiredNetworkMap.keys().size(); ++i) {
|
||||
m_wiredNetworkMap[m_wiredNetworkMap.keys().at(i)] << connectItem;
|
||||
}
|
||||
} else {
|
||||
if (m_wiredNetworkMap.contains(connectInterface)) {
|
||||
m_wiredNetworkMap[connectInterface] << connectItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifndef KYLINCONNECTRESOURCE_H
|
||||
#define KYLINCONNECTRESOURCE_H
|
||||
|
||||
#include <QString>
|
||||
#include "kylinnetworkresourcemanager.h"
|
||||
#include "kylinnetresource.h"
|
||||
#include "kylinconnectitem.h"
|
||||
#include "kylinnetworkdeviceresource.h"
|
||||
#include "kylinconnectsetting.h"
|
||||
#include "kylinapconnectitem.h"
|
||||
|
||||
class KyWiredConnectResourse : public KyNetResource
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit KyWiredConnectResourse(QObject *parent = nullptr);
|
||||
|
||||
public:
|
||||
void getWiredList(QMap<QString,QList<KyWiredItem>> &map);
|
||||
|
||||
void getWiredConnectDetail(QString interface, QString uuid, KyDetailInfo &connectSetting);
|
||||
private:
|
||||
void kyWirdNetItemListInit();
|
||||
KyWiredItem getConnectionItem(NetworkManager::Connection::Ptr connectPtr);
|
||||
|
||||
Q_SIGNALS:
|
||||
void wiredConnectionAdd(QString devName, QString connectUuid, QString connectName, QString connectPath);
|
||||
void wiredConnectionUpdate(QString devName, QString connectUuid, QString connectName, QString connectPath);
|
||||
void connectionRemove(QString path);
|
||||
|
||||
void wiredDeviceAdd(QString deviceName);
|
||||
void wiredDeviceUpdate(QString oldDeviceName, QString newDeviceName);
|
||||
void deviceRemove(QString deviceName);
|
||||
|
||||
private:
|
||||
QMap<QString, QList<KyWiredItem>> m_wiredNetworkMap;
|
||||
};
|
||||
#endif // KYLINCONNECTRESOURCE_H
|
|
@ -0,0 +1,989 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#include "kywirelessconnectoperation.h"
|
||||
#include "kylinnetworkmanagerutil.h"
|
||||
|
||||
#include <networkmanagerqt/wirelesssecuritysetting.h>
|
||||
|
||||
#define PSK_SETTING_NAME "802-11-wireless-security"
|
||||
#define PRIVATE_PSK_SETTING_NAME "802-1x"
|
||||
|
||||
NetworkManager::ConnectionSettings::Ptr assembleWpaXPskSettings(NetworkManager::AccessPoint::Ptr accessPoint, QString &psk, bool isAutoConnect)
|
||||
{
|
||||
QByteArray rawSsid = accessPoint->rawSsid();
|
||||
QString wifiSsid = getSsidFromByteArray(rawSsid);
|
||||
|
||||
NetworkManager::ConnectionSettings::Ptr settings{new NetworkManager::ConnectionSettings{NetworkManager::ConnectionSettings::Wireless}};
|
||||
settings->setId(wifiSsid);
|
||||
settings->setUuid(NetworkManager::ConnectionSettings::createNewUuid());
|
||||
settings->setAutoconnect(isAutoConnect);
|
||||
//Note: workaround for wrongly (randomly) initialized gateway-ping-timeout
|
||||
settings->setGatewayPingTimeout(0);
|
||||
|
||||
NetworkManager::WirelessSetting::Ptr wifi_sett
|
||||
= settings->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
|
||||
wifi_sett->setInitialized(true);
|
||||
wifi_sett->setSsid(rawSsid);
|
||||
wifi_sett->setSecurity("802-11-wireless-security");
|
||||
|
||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
||||
= settings->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
security_sett->setInitialized(true);
|
||||
if (NetworkManager::AccessPoint::Adhoc == accessPoint->mode()) {
|
||||
wifi_sett->setMode(NetworkManager::WirelessSetting::Adhoc);
|
||||
security_sett->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaNone);
|
||||
} else {
|
||||
security_sett->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaPsk);
|
||||
}
|
||||
if (!psk.isEmpty()) {
|
||||
security_sett->setPsk(psk);
|
||||
}
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
NetworkManager::ConnectionSettings::Ptr assembleSaeSettings(NetworkManager::AccessPoint::Ptr accessPoint, QString &psk, bool isAutoConnect)
|
||||
{
|
||||
QByteArray rawSsid = accessPoint->rawSsid();
|
||||
QString wifiSsid = getSsidFromByteArray(rawSsid);
|
||||
|
||||
NetworkManager::ConnectionSettings::Ptr settings{new NetworkManager::ConnectionSettings{NetworkManager::ConnectionSettings::Wireless}};
|
||||
settings->setId(wifiSsid);
|
||||
settings->setUuid(NetworkManager::ConnectionSettings::createNewUuid());
|
||||
settings->setAutoconnect(isAutoConnect);
|
||||
//Note: workaround for wrongly (randomly) initialized gateway-ping-timeout
|
||||
settings->setGatewayPingTimeout(0);
|
||||
|
||||
NetworkManager::WirelessSetting::Ptr wifi_sett
|
||||
= settings->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
|
||||
wifi_sett->setInitialized(true);
|
||||
wifi_sett->setSsid(rawSsid);
|
||||
wifi_sett->setSecurity("802-11-wireless-security");
|
||||
|
||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
||||
= settings->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
security_sett->setInitialized(true);
|
||||
if (NetworkManager::AccessPoint::Adhoc == accessPoint->mode()) {
|
||||
wifi_sett->setMode(NetworkManager::WirelessSetting::Adhoc);
|
||||
security_sett->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaNone);
|
||||
} else {
|
||||
security_sett->setKeyMgmt(NetworkManager::WirelessSecuritySetting::SAE);
|
||||
}
|
||||
if (!psk.isEmpty()) {
|
||||
security_sett->setPsk(psk);
|
||||
}
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
NetworkManager::ConnectionSettings::Ptr assembleWirelessSettings(const NetworkManager::AccessPoint::Ptr accessPointPtr,
|
||||
const KyWirelessConnectSetting &connSettingInfo,
|
||||
KyKeyMgmt type,
|
||||
bool isHidden)
|
||||
{
|
||||
QByteArray rawSsid;
|
||||
if (nullptr == accessPointPtr || accessPointPtr.isNull()) {
|
||||
rawSsid = connSettingInfo.m_ssid.toUtf8();
|
||||
} else {
|
||||
rawSsid = accessPointPtr->rawSsid();
|
||||
}
|
||||
|
||||
NetworkManager::ConnectionSettings::Ptr settings{new NetworkManager::ConnectionSettings{NetworkManager::ConnectionSettings::Wireless}};
|
||||
settings->setId(connSettingInfo.m_connectName);
|
||||
settings->setUuid(NetworkManager::ConnectionSettings::createNewUuid());
|
||||
settings->setAutoconnect(connSettingInfo.m_isAutoConnect);
|
||||
//Note: workaround for wrongly (randomly) initialized gateway-ping-timeout
|
||||
settings->setGatewayPingTimeout(0);
|
||||
settings->setInterfaceName(connSettingInfo.m_ifaceName);
|
||||
|
||||
NetworkManager::WirelessSetting::Ptr wifi_sett
|
||||
= settings->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
|
||||
wifi_sett->setInitialized(true);
|
||||
wifi_sett->setSsid(rawSsid);
|
||||
wifi_sett->setSecurity("802-11-wireless-security");
|
||||
wifi_sett->setHidden(isHidden);
|
||||
|
||||
|
||||
if (type != KyKeyMgmt::WpaNone && type != KyKeyMgmt::Unknown)
|
||||
{
|
||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
||||
= settings->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
security_sett->setInitialized(true);
|
||||
security_sett->setKeyMgmt((NetworkManager::WirelessSecuritySetting::KeyMgmt)type);
|
||||
if (KyKeyMgmt::SAE == type || KyKeyMgmt::WpaPsk == type)
|
||||
{
|
||||
security_sett->setPsk(connSettingInfo.m_psk);
|
||||
}
|
||||
}
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
KyWirelessConnectOperation::KyWirelessConnectOperation(QObject *parent) : KyConnectOperation(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void KyWirelessConnectOperation::requestWirelessScan()
|
||||
{
|
||||
NetworkManager::Device::List deviceList = m_networkResourceInstance->getNetworkDeviceList();
|
||||
|
||||
for (auto const & dev : deviceList) {
|
||||
auto spec_dev = dev->as<NetworkManager::WirelessDevice>();
|
||||
if (nullptr != spec_dev) {
|
||||
m_networkResourceInstance->requestScan(spec_dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//普通wifi
|
||||
void KyWirelessConnectOperation::addConnect(const KyWirelessConnectSetting &connSettingInfo, KySecuType &type)
|
||||
{
|
||||
KyKeyMgmt mgmt;
|
||||
if (type == NONE) {
|
||||
mgmt = WpaNone;
|
||||
} else if (type == WPA_AND_WPA2_PERSONAL) {
|
||||
mgmt = WpaPsk;
|
||||
} else if (type == WPA3_PERSONAL) {
|
||||
mgmt = WpaEap;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkManager::WirelessNetwork::Ptr wifiNet =
|
||||
checkWifiNetExist(connSettingInfo.m_ssid, connSettingInfo.m_ifaceName);
|
||||
if (wifiNet.isNull()) {
|
||||
QString errorMessage = "the ssid " + connSettingInfo.m_ssid
|
||||
+ " is not exsit in " + connSettingInfo.m_ifaceName;
|
||||
qWarning()<<errorMessage;
|
||||
Q_EMIT createConnectionError(errorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkManager::AccessPoint::Ptr accessPointPtr = wifiNet->referenceAccessPoint();
|
||||
NetworkManager::ConnectionSettings::Ptr connSetting =
|
||||
assembleWirelessSettings(accessPointPtr, connSettingInfo, mgmt, false);
|
||||
setIpv4AndIpv6Setting(connSetting, connSettingInfo);
|
||||
|
||||
QDBusPendingCallWatcher * watcher;
|
||||
watcher = new QDBusPendingCallWatcher{NetworkManager::addConnection(connSetting->toMap()), this};
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished, [this](QDBusPendingCallWatcher * watcher) {
|
||||
if (watcher->isError() || !watcher->isValid()) {
|
||||
QString errorMessage = tr("create wireless connection failed: ") + watcher->error().message();
|
||||
qWarning()<<errorMessage;
|
||||
Q_EMIT this->createConnectionError(errorMessage);
|
||||
}
|
||||
watcher->deleteLater();
|
||||
});
|
||||
}
|
||||
//tls
|
||||
void KyWirelessConnectOperation::addTlsConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodTlsInfo &tlsInfo)
|
||||
{
|
||||
|
||||
NetworkManager::WirelessNetwork::Ptr wifiNet =
|
||||
checkWifiNetExist(connSettingInfo.m_ssid, connSettingInfo.m_ifaceName);
|
||||
if (wifiNet.isNull()) {
|
||||
QString errorMessage = "the ssid " + connSettingInfo.m_ssid
|
||||
+ " is not exsit in " + connSettingInfo.m_ifaceName;
|
||||
qWarning() << errorMessage;
|
||||
Q_EMIT createConnectionError(errorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkManager::AccessPoint::Ptr accessPointPtr = wifiNet->referenceAccessPoint();
|
||||
NetworkManager::ConnectionSettings::Ptr connSetting =
|
||||
assembleWirelessSettings(accessPointPtr, connSettingInfo, WpaEap, false);
|
||||
setIpv4AndIpv6Setting(connSetting, connSettingInfo);
|
||||
assembleEapMethodTlsSettings(connSetting, tlsInfo);
|
||||
|
||||
QDBusPendingCallWatcher * watcher;
|
||||
watcher = new QDBusPendingCallWatcher{NetworkManager::addConnection(connSetting->toMap()), this};
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished, [this](QDBusPendingCallWatcher * watcher) {
|
||||
if (watcher->isError() || !watcher->isValid()) {
|
||||
QString errorMessage = tr("create wireless tls connection failed: ") + watcher->error().message();
|
||||
qWarning()<<errorMessage;
|
||||
Q_EMIT this->createConnectionError(errorMessage);
|
||||
}
|
||||
watcher->deleteLater();
|
||||
});
|
||||
|
||||
}
|
||||
//peap
|
||||
void KyWirelessConnectOperation::addPeapConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodPeapInfo &peapInfo)
|
||||
{
|
||||
NetworkManager::WirelessNetwork::Ptr wifiNet =
|
||||
checkWifiNetExist(connSettingInfo.m_ssid, connSettingInfo.m_ifaceName);
|
||||
if (wifiNet.isNull()) {
|
||||
QString errorMessage = "the ssid " + connSettingInfo.m_ssid
|
||||
+ " is not exsit in " + connSettingInfo.m_ifaceName;
|
||||
qWarning()<<errorMessage;
|
||||
Q_EMIT createConnectionError(errorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkManager::AccessPoint::Ptr accessPointPtr = wifiNet->referenceAccessPoint();
|
||||
NetworkManager::ConnectionSettings::Ptr connSetting =
|
||||
assembleWirelessSettings(accessPointPtr, connSettingInfo, WpaEap, false);
|
||||
setIpv4AndIpv6Setting(connSetting, connSettingInfo);
|
||||
assembleEapMethodPeapSettings(connSetting, peapInfo);
|
||||
|
||||
QDBusPendingCallWatcher * watcher;
|
||||
watcher = new QDBusPendingCallWatcher{NetworkManager::addConnection(connSetting->toMap()), this};
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished, [this](QDBusPendingCallWatcher * watcher) {
|
||||
if (watcher->isError() || !watcher->isValid()) {
|
||||
QString errorMessage = tr("create wireless peap connection failed: ") + watcher->error().message();
|
||||
qWarning()<<errorMessage;
|
||||
Q_EMIT this->createConnectionError(errorMessage);
|
||||
}
|
||||
watcher->deleteLater();
|
||||
});
|
||||
}
|
||||
|
||||
void KyWirelessConnectOperation::addTtlsConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodTtlsInfo &ttlsInfo)
|
||||
{
|
||||
NetworkManager::WirelessNetwork::Ptr wifiNet =
|
||||
checkWifiNetExist(connSettingInfo.m_ssid, connSettingInfo.m_ifaceName);
|
||||
if (wifiNet.isNull()) {
|
||||
QString errorMessage = "the ssid " + connSettingInfo.m_ssid
|
||||
+ " is not exsit in " + connSettingInfo.m_ifaceName;
|
||||
qWarning()<<errorMessage;
|
||||
Q_EMIT createConnectionError(errorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkManager::AccessPoint::Ptr accessPointPtr = wifiNet->referenceAccessPoint();
|
||||
NetworkManager::ConnectionSettings::Ptr connSetting =
|
||||
assembleWirelessSettings(accessPointPtr, connSettingInfo, WpaEap, false);
|
||||
setIpv4AndIpv6Setting(connSetting, connSettingInfo);
|
||||
assembleEapMethodTtlsSettings(connSetting, ttlsInfo);
|
||||
|
||||
QDBusPendingCallWatcher * watcher;
|
||||
watcher = new QDBusPendingCallWatcher{NetworkManager::addConnection(connSetting->toMap()), this};
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished, [this](QDBusPendingCallWatcher * watcher) {
|
||||
if (watcher->isError() || !watcher->isValid()) {
|
||||
QString errorMessage = tr("create wireless ttls connection failed: ") + watcher->error().message();
|
||||
qWarning()<<errorMessage;
|
||||
Q_EMIT this->createConnectionError(errorMessage);
|
||||
}
|
||||
watcher->deleteLater();
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void KyWirelessConnectOperation::setWirelessAutoConnect(const QString &uuid, bool bAutoConnect)
|
||||
{
|
||||
NetworkManager::Connection::Ptr connectPtr =
|
||||
NetworkManager::findConnectionByUuid(uuid);
|
||||
if (nullptr == connectPtr) {
|
||||
QString errorMessage = tr("it can not find connection") + uuid;
|
||||
qWarning()<<errorMessage;
|
||||
Q_EMIT updateConnectionError(errorMessage);
|
||||
return;
|
||||
}
|
||||
NetworkManager::ConnectionSettings::Ptr connectionSettings = connectPtr->settings();
|
||||
setAutoConnect(connectionSettings, bAutoConnect);
|
||||
connectPtr->update(connectionSettings->toMap());
|
||||
}
|
||||
|
||||
QString KyWirelessConnectOperation::getPsk(const QString &connectUuid)
|
||||
{
|
||||
NetworkManager::Connection::Ptr connectPtr =
|
||||
NetworkManager::findConnectionByUuid(connectUuid);
|
||||
if (connectPtr.isNull()) {
|
||||
QString errorMessage = tr("it can not find connection") + connectUuid;
|
||||
qWarning()<<errorMessage;
|
||||
return "";
|
||||
}
|
||||
QDBusPendingReply<NMVariantMapMap> reply = connectPtr->secrets(PSK_SETTING_NAME);
|
||||
QMap<QString,QVariantMap> map(reply.value());
|
||||
if (map.contains("802-11-wireless-security")
|
||||
&& map.value("802-11-wireless-security").contains("psk")) {
|
||||
QString psk = map.value("802-11-wireless-security").value("psk").toString();
|
||||
return psk;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
QString KyWirelessConnectOperation::getPrivateKeyPassword(const QString &connectUuid)
|
||||
{
|
||||
NetworkManager::Connection::Ptr connectPtr =
|
||||
NetworkManager::findConnectionByUuid(connectUuid);
|
||||
if (connectPtr.isNull()) {
|
||||
QString errorMessage = tr("it can not find connection") + connectUuid;
|
||||
qWarning()<<errorMessage;
|
||||
return "";
|
||||
}
|
||||
QDBusPendingReply<NMVariantMapMap> reply = connectPtr->secrets(PRIVATE_PSK_SETTING_NAME);
|
||||
QMap<QString,QVariantMap> map(reply.value());
|
||||
if (map.contains("802-1x")
|
||||
&& map.value("802-1x").contains("private-key-password")) {
|
||||
QString psk = map.value("802-1x").value("private-key-password").toString();
|
||||
return psk;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
QString KyWirelessConnectOperation::get8021xPassword(const QString &connectUuid)
|
||||
{
|
||||
NetworkManager::Connection::Ptr connectPtr =
|
||||
NetworkManager::findConnectionByUuid(connectUuid);
|
||||
if (connectPtr.isNull()) {
|
||||
QString errorMessage = tr("it can not find connection") + connectUuid;
|
||||
qWarning()<<errorMessage;
|
||||
return "";
|
||||
}
|
||||
QDBusPendingReply<NMVariantMapMap> reply = connectPtr->secrets(PRIVATE_PSK_SETTING_NAME);
|
||||
QMap<QString,QVariantMap> map(reply.value());
|
||||
if (map.contains("802-1x") && map.value("802-1x").contains("password"))
|
||||
{
|
||||
QString psk = map.value("802-1x").value("password").toString();
|
||||
return psk;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
void KyWirelessConnectOperation::updateIpv4AndIpv6SettingInfo(const QString &uuid, const KyConnectSetting &connectSettingsInfo)
|
||||
{
|
||||
NetworkManager::Connection::Ptr connectPtr =
|
||||
NetworkManager::findConnectionByUuid(uuid);
|
||||
if (nullptr == connectPtr) {
|
||||
QString errorMessage = tr("it can not find connection") + uuid;
|
||||
qWarning()<<errorMessage;
|
||||
Q_EMIT updateConnectionError(errorMessage);
|
||||
return;
|
||||
}
|
||||
NetworkManager::ConnectionSettings::Ptr connectionSettings = connectPtr->settings();
|
||||
|
||||
setIpv4AndIpv6Setting(connectionSettings,connectSettingsInfo);
|
||||
connectPtr->update(connectionSettings->toMap());
|
||||
return;
|
||||
}
|
||||
|
||||
void KyWirelessConnectOperation::updateWirelessPersonalConnect(const QString &uuid, const KyWirelessConnectSetting &connSettingInfo, bool bPwdChange)
|
||||
{
|
||||
NetworkManager::Connection::Ptr connectPtr =
|
||||
NetworkManager::findConnectionByUuid(uuid);
|
||||
if (nullptr == connectPtr) {
|
||||
QString errorMessage = tr("it can not find connection") + uuid;
|
||||
qWarning()<<errorMessage;
|
||||
Q_EMIT updateConnectionError(errorMessage);
|
||||
return;
|
||||
}
|
||||
NetworkManager::ConnectionSettings::Ptr connectionSettings = connectPtr->settings();
|
||||
|
||||
NetworkManager::Security8021xSetting::Ptr wifi_8021x_sett
|
||||
= connectionSettings->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>();
|
||||
wifi_8021x_sett->setInitialized(false);
|
||||
|
||||
updateWirelessSecu(connectionSettings, connSettingInfo, bPwdChange);
|
||||
connectPtr->update(connectionSettings->toMap());
|
||||
return;
|
||||
}
|
||||
|
||||
void KyWirelessConnectOperation::updateWirelessEnterPriseTlsConnect(const QString &uuid, const KyEapMethodTlsInfo &tlsInfo)
|
||||
{
|
||||
NetworkManager::Connection::Ptr connectPtr =
|
||||
NetworkManager::findConnectionByUuid(uuid);
|
||||
if (connectPtr.isNull()) {
|
||||
QString errorMessage = tr("it can not find connection") + uuid;
|
||||
qWarning()<<errorMessage;
|
||||
Q_EMIT updateConnectionError(errorMessage);
|
||||
return;
|
||||
}
|
||||
NetworkManager::ConnectionSettings::Ptr connectionSettings = connectPtr->settings();
|
||||
|
||||
setWirelessSecuWpaXEap(connectionSettings);
|
||||
modifyEapMethodTlsSettings(connectionSettings, tlsInfo);
|
||||
connectPtr->update(connectionSettings->toMap());
|
||||
return;
|
||||
}
|
||||
|
||||
void KyWirelessConnectOperation::updateWirelessEnterPrisePeapConnect(const QString &uuid, const KyEapMethodPeapInfo &peapInfo)
|
||||
{
|
||||
NetworkManager::Connection::Ptr connectPtr =
|
||||
NetworkManager::findConnectionByUuid(uuid);
|
||||
if (nullptr == connectPtr) {
|
||||
QString errorMessage = tr("it can not find connection") + uuid;
|
||||
qWarning()<<errorMessage;
|
||||
Q_EMIT updateConnectionError(errorMessage);
|
||||
return;
|
||||
}
|
||||
NetworkManager::ConnectionSettings::Ptr connectionSettings = connectPtr->settings();
|
||||
|
||||
setWirelessSecuWpaXEap(connectionSettings);
|
||||
modifyEapMethodPeapSettings(connectionSettings, peapInfo);
|
||||
connectPtr->update(connectionSettings->toMap());
|
||||
return;
|
||||
}
|
||||
|
||||
void KyWirelessConnectOperation::updateWirelessEnterPriseTtlsConnect(const QString &uuid, const KyEapMethodTtlsInfo &ttlsInfo)
|
||||
{
|
||||
NetworkManager::Connection::Ptr connectPtr =
|
||||
NetworkManager::findConnectionByUuid(uuid);
|
||||
if (nullptr == connectPtr) {
|
||||
QString errorMessage = tr("it can not find connection") + uuid;
|
||||
qWarning()<<errorMessage;
|
||||
Q_EMIT updateConnectionError(errorMessage);
|
||||
return;
|
||||
}
|
||||
NetworkManager::ConnectionSettings::Ptr connectionSettings = connectPtr->settings();
|
||||
|
||||
setWirelessSecuWpaXEap(connectionSettings);
|
||||
modifyEapMethodTtlsSettings(connectionSettings, ttlsInfo);
|
||||
connectPtr->update(connectionSettings->toMap());
|
||||
return;
|
||||
}
|
||||
|
||||
void KyWirelessConnectOperation::addAndActiveWirelessConnect(KyWirelessConnectSetting &connSettingInfo, KySecuType &type)
|
||||
{
|
||||
KyKeyMgmt mgmt;
|
||||
if (type == NONE) {
|
||||
mgmt = WpaNone;
|
||||
} else if (type == WPA_AND_WPA2_PERSONAL) {
|
||||
mgmt = WpaPsk;
|
||||
} else if (type == WPA3_PERSONAL) {
|
||||
mgmt = SAE;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
QString devIface = connSettingInfo.m_ifaceName;
|
||||
QString conn_uni, dev_uni, conn_name, spec_object;
|
||||
NMVariantMapMap map_settings;
|
||||
|
||||
//检测wifi是否存在
|
||||
NetworkManager::WirelessNetwork::Ptr wifiNet = checkWifiNetExist(connSettingInfo.m_ssid, devIface);
|
||||
if (!connSettingInfo.isHidden && wifiNet.isNull()) {
|
||||
QString errorMessage = "the ssid " + connSettingInfo.m_ssid + " is not exsit in " + devIface;
|
||||
qWarning() << errorMessage;
|
||||
Q_EMIT activateConnectionError(errorMessage);
|
||||
return;
|
||||
}
|
||||
//配置生成
|
||||
auto dev = m_networkResourceInstance->findDeviceByName(devIface);
|
||||
if (dev.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
dev_uni = dev->uni();
|
||||
auto spec_dev = dev->as<NetworkManager::WirelessDevice>();
|
||||
if (!connSettingInfo.isHidden) {
|
||||
//非隐藏wifi
|
||||
auto access_point = wifiNet->referenceAccessPoint();
|
||||
conn_uni = access_point->uni();
|
||||
conn_name = access_point->ssid();
|
||||
spec_object = conn_uni;
|
||||
|
||||
NetworkManager::WirelessSecurityType sec_type = NetworkManager::findBestWirelessSecurity(spec_dev->wirelessCapabilities()
|
||||
, true, (spec_dev->mode() == NetworkManager::WirelessDevice::Adhoc)
|
||||
, access_point->capabilities(), access_point->wpaFlags(), access_point->rsnFlags());
|
||||
NetworkManager::ConnectionSettings::Ptr settings = nullptr;
|
||||
switch (sec_type)
|
||||
{
|
||||
case NetworkManager::UnknownSecurity:
|
||||
qWarning() << QStringLiteral("unknown security to use for '%1'").arg(conn_name);
|
||||
case NetworkManager::NoneSecurity:
|
||||
//nothing to do
|
||||
break;
|
||||
case NetworkManager::WpaPsk:
|
||||
case NetworkManager::Wpa2Psk:
|
||||
settings = assembleWpaXPskSettings(access_point, connSettingInfo.m_psk, connSettingInfo.m_isAutoConnect);
|
||||
if (nullptr != settings) {
|
||||
map_settings = settings->toMap();
|
||||
} else {
|
||||
qWarning() << QStringLiteral("connection settings assembly for '%1' failed, abandoning activation...").arg(conn_name);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case NetworkManager::SAE:
|
||||
settings = assembleSaeSettings(access_point, connSettingInfo.m_psk, connSettingInfo.m_isAutoConnect);
|
||||
if (nullptr != settings) {
|
||||
map_settings = settings->toMap();
|
||||
} else {
|
||||
qWarning() << QStringLiteral("connection settings assembly for '%1' failed, abandoning activation...").arg(conn_name);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
//TODO:其他加密类型
|
||||
default:
|
||||
qWarning() << "addAndActiveWirelessConnect not support";
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
//隐藏wifi
|
||||
map_settings = assembleWirelessSettings(nullptr, connSettingInfo, mgmt, connSettingInfo.isHidden)->toMap();
|
||||
}
|
||||
//激活
|
||||
QDBusPendingCallWatcher * watcher;
|
||||
watcher = new QDBusPendingCallWatcher{NetworkManager::addAndActivateConnection(map_settings, dev_uni, spec_object), this};
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) {
|
||||
if (watcher->isError() || !watcher->isValid()) {
|
||||
QString errorMessage = watcher->error().message();
|
||||
qWarning() << "activation of connection failed " << errorMessage;
|
||||
}
|
||||
watcher->deleteLater();
|
||||
});
|
||||
}
|
||||
|
||||
void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTlsConnect(KyEapMethodTlsInfo &info, KyWirelessConnectSetting &connSettingInfo)
|
||||
{
|
||||
QString devIface = connSettingInfo.m_ifaceName;
|
||||
QString conn_uni, dev_uni, spec_object;
|
||||
NMVariantMapMap map_settings;
|
||||
NetworkManager::AccessPoint::Ptr accessPointPtr = nullptr;
|
||||
|
||||
if (!connSettingInfo.isHidden) {
|
||||
NetworkManager::WirelessNetwork::Ptr wifiNet = checkWifiNetExist(connSettingInfo.m_ssid, devIface);
|
||||
if (wifiNet.isNull()) {
|
||||
QString errorMessage = "the ssid " + connSettingInfo.m_ssid + " is not exsit in " + devIface;
|
||||
qWarning()<<errorMessage;
|
||||
Q_EMIT activateConnectionError(errorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
accessPointPtr = wifiNet->referenceAccessPoint();
|
||||
conn_uni = accessPointPtr->uni();
|
||||
spec_object = conn_uni;
|
||||
}
|
||||
|
||||
auto dev = m_networkResourceInstance->findDeviceByName(devIface);
|
||||
if (dev.isNull()) {
|
||||
return;
|
||||
}
|
||||
dev_uni = dev->uni();
|
||||
|
||||
NetworkManager::ConnectionSettings::Ptr settings = assembleWirelessSettings(accessPointPtr, connSettingInfo, WpaEap, connSettingInfo.isHidden);
|
||||
assembleEapMethodTlsSettings(settings, info);
|
||||
|
||||
if(settings.isNull()) {
|
||||
qWarning() << "assembleEapMethodTlsSettings failed";
|
||||
return;
|
||||
}
|
||||
|
||||
map_settings = settings->toMap();
|
||||
|
||||
QDBusPendingCallWatcher * watcher;
|
||||
watcher = new QDBusPendingCallWatcher{NetworkManager::addAndActivateConnection(map_settings, dev_uni, spec_object), this};
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) {
|
||||
if (watcher->isError() || !watcher->isValid()) {
|
||||
QString errorMessage = watcher->error().message();
|
||||
qWarning() << "addAndActiveWirelessEnterPriseTlsConnect failed " << errorMessage;
|
||||
}
|
||||
watcher->deleteLater();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
void KyWirelessConnectOperation::addAndActiveWirelessEnterPrisePeapConnect(KyEapMethodPeapInfo &info, KyWirelessConnectSetting &connSettingInfo)
|
||||
{
|
||||
qDebug() << "addAndActiveWirelessEnterPrisePeapConnect";
|
||||
QString devIface = connSettingInfo.m_ifaceName;
|
||||
QString conn_uni, dev_uni, spec_object;
|
||||
NMVariantMapMap map_settings;
|
||||
NetworkManager::AccessPoint::Ptr accessPointPtr = nullptr;
|
||||
|
||||
if (!connSettingInfo.isHidden) {
|
||||
NetworkManager::WirelessNetwork::Ptr wifiNet = checkWifiNetExist(connSettingInfo.m_ssid, devIface);
|
||||
if (wifiNet.isNull()) {
|
||||
QString errorMessage = "the ssid " + connSettingInfo.m_ssid + " is not exsit in " + devIface;
|
||||
qWarning() << errorMessage;
|
||||
Q_EMIT activateConnectionError(errorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
accessPointPtr = wifiNet->referenceAccessPoint();
|
||||
conn_uni = accessPointPtr->uni();
|
||||
spec_object = conn_uni;
|
||||
}
|
||||
|
||||
auto dev = m_networkResourceInstance->findDeviceByName(devIface);
|
||||
if (dev.isNull()) {
|
||||
return;
|
||||
}
|
||||
dev_uni = dev->uni();
|
||||
|
||||
NetworkManager::ConnectionSettings::Ptr settings =
|
||||
assembleWirelessSettings(accessPointPtr, connSettingInfo, WpaEap, connSettingInfo.isHidden);
|
||||
assembleEapMethodPeapSettings(settings, info);
|
||||
|
||||
if(settings.isNull()) {
|
||||
qWarning() << "assembleEapMethodPeapSettings failed";
|
||||
return;
|
||||
}
|
||||
map_settings = settings->toMap();
|
||||
|
||||
QDBusPendingCallWatcher * watcher;
|
||||
watcher = new QDBusPendingCallWatcher{NetworkManager::addAndActivateConnection(map_settings, dev_uni, spec_object), this};
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) {
|
||||
if (watcher->isError() || !watcher->isValid()) {
|
||||
QString errorMessage = watcher->error().message();
|
||||
qWarning() << "addAndActiveWirelessEnterPrisePeapConnect failed " << errorMessage;
|
||||
}
|
||||
watcher->deleteLater();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTtlsConnect(KyEapMethodTtlsInfo &info, KyWirelessConnectSetting &connSettingInfo)
|
||||
{
|
||||
QString devIface = connSettingInfo.m_ifaceName;
|
||||
QString conn_uni, dev_uni, spec_object;
|
||||
NMVariantMapMap map_settings;
|
||||
NetworkManager::AccessPoint::Ptr accessPointPtr = nullptr;
|
||||
|
||||
if (!connSettingInfo.isHidden) {
|
||||
NetworkManager::WirelessNetwork::Ptr wifiNet = checkWifiNetExist(connSettingInfo.m_ssid, devIface);
|
||||
if (wifiNet.isNull()) {
|
||||
QString errorMessage = "the ssid " + connSettingInfo.m_ssid + " is not exsit in " + devIface;
|
||||
qWarning()<<errorMessage;
|
||||
Q_EMIT activateConnectionError(errorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
accessPointPtr = wifiNet->referenceAccessPoint();
|
||||
conn_uni = accessPointPtr->uni();
|
||||
spec_object = conn_uni;
|
||||
}
|
||||
|
||||
auto dev = m_networkResourceInstance->findDeviceByName(devIface);
|
||||
if (dev.isNull()) {
|
||||
return;
|
||||
}
|
||||
dev_uni = dev->uni();
|
||||
|
||||
NetworkManager::ConnectionSettings::Ptr settings =
|
||||
assembleWirelessSettings(accessPointPtr, connSettingInfo, WpaEap, connSettingInfo.isHidden);
|
||||
assembleEapMethodTtlsSettings(settings, info);
|
||||
|
||||
if(settings.isNull()) {
|
||||
qWarning() << "assembleEapMethodTtlsSettings failed";
|
||||
return;
|
||||
}
|
||||
|
||||
map_settings = settings->toMap();
|
||||
|
||||
QDBusPendingCallWatcher * watcher;
|
||||
watcher = new QDBusPendingCallWatcher{NetworkManager::addAndActivateConnection(map_settings, dev_uni, spec_object), this};
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) {
|
||||
if (watcher->isError() || !watcher->isValid()) {
|
||||
QString errorMessage = watcher->error().message();
|
||||
qWarning() << "addAndActiveWirelessEnterPriseTtlsConnect failed " << errorMessage;
|
||||
}
|
||||
watcher->deleteLater();
|
||||
});
|
||||
}
|
||||
|
||||
bool KyWirelessConnectOperation::getConnSecretFlags(QString &connUuid, NetworkManager::Setting::SecretFlags &flag)
|
||||
{
|
||||
NetworkManager::Connection::Ptr conn;
|
||||
conn = m_networkResourceInstance->findConnectByUuid(connUuid);
|
||||
if (conn.isNull()) {
|
||||
qWarning() <<"get failed";
|
||||
return false;
|
||||
}
|
||||
|
||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
||||
= conn->settings()->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
flag = security_sett->pskFlags();
|
||||
return true;
|
||||
}
|
||||
|
||||
NetworkManager::ConnectionSettings::Ptr
|
||||
KyWirelessConnectOperation::createWirelessApSetting(const QString apSsid,
|
||||
const QString apPassword,
|
||||
const QString apDevice,
|
||||
const QString wirelessBand)
|
||||
{
|
||||
NetworkManager::ConnectionSettings::Ptr connectionSettings =
|
||||
NetworkManager::ConnectionSettings::Ptr(new NetworkManager::ConnectionSettings(NetworkManager::ConnectionSettings::Wireless));
|
||||
connectionSettings->setId(apSsid);
|
||||
connectionSettings->setUuid(NetworkManager::ConnectionSettings::createNewUuid());
|
||||
connectionSettings->setAutoconnect(false);
|
||||
connectionSettings->setAutoconnectPriority(0);
|
||||
connectionSettings->setInterfaceName(apDevice);
|
||||
//Note: workaround for wrongly (randomly) initialized gateway-ping-timeout
|
||||
connectionSettings->setGatewayPingTimeout(0);
|
||||
|
||||
NetworkManager::Ipv4Setting::Ptr ipv4Setting = connectionSettings->setting(NetworkManager::Setting::Ipv4).dynamicCast<NetworkManager::Ipv4Setting>();
|
||||
ipv4Setting->setInitialized(true);
|
||||
ipv4Setting->setMethod(NetworkManager::Ipv4Setting::Shared);
|
||||
|
||||
NetworkManager::Ipv6Setting::Ptr ipv6Setting = connectionSettings->setting(NetworkManager::Setting::Ipv6).dynamicCast<NetworkManager::Ipv6Setting>();
|
||||
ipv6Setting->setInitialized(true);
|
||||
ipv6Setting->setMethod(NetworkManager::Ipv6Setting::Ignored);
|
||||
|
||||
NetworkManager::WirelessSetting::Ptr wirelessSetting
|
||||
= connectionSettings->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
|
||||
wirelessSetting->setInitialized(true);
|
||||
wirelessSetting->setSsid(apSsid.toUtf8());
|
||||
wirelessSetting->setMode(NetworkManager::WirelessSetting::NetworkMode::Ap);
|
||||
wirelessSetting->setSecurity("802-11-wireless-security");
|
||||
if (wirelessBand == WIFI_BAND_2_4GHZ) {
|
||||
wirelessSetting->setBand(NetworkManager::WirelessSetting::FrequencyBand::Bg);
|
||||
} else if (wirelessBand == WIFI_BAND_5GHZ) {
|
||||
wirelessSetting->setBand(NetworkManager::WirelessSetting::FrequencyBand::A);
|
||||
} else {
|
||||
qWarning()<<"[KyWirelessConnectOperation] the band type undefined"<<wirelessBand;
|
||||
wirelessSetting->setBand(NetworkManager::WirelessSetting::FrequencyBand::Automatic);
|
||||
}
|
||||
|
||||
|
||||
NetworkManager::WirelessSecuritySetting::Ptr wirelessSecuritySetting
|
||||
= connectionSettings->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
if (apPassword.isEmpty()) {
|
||||
wirelessSecuritySetting->setInitialized(false);
|
||||
} else {
|
||||
wirelessSecuritySetting->setInitialized(true);
|
||||
wirelessSecuritySetting->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaPsk);
|
||||
wirelessSecuritySetting->setPsk(apPassword);
|
||||
}
|
||||
|
||||
return connectionSettings;
|
||||
}
|
||||
|
||||
void KyWirelessConnectOperation::updateWirelessApSetting(
|
||||
NetworkManager::Connection::Ptr apConnectPtr,
|
||||
const QString apName, const QString apPassword,
|
||||
const QString apDevice, const QString wirelessBand)
|
||||
|
||||
{
|
||||
NetworkManager::ConnectionSettings::Ptr apConnectSettingPtr = apConnectPtr->settings();
|
||||
apConnectSettingPtr->setId(apName);
|
||||
apConnectSettingPtr->setInterfaceName(apDevice);
|
||||
apConnectSettingPtr->setAutoconnect(false);
|
||||
|
||||
NetworkManager::WirelessSetting::Ptr wirelessSetting
|
||||
= apConnectSettingPtr->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
|
||||
wirelessSetting->setInitialized(true);
|
||||
wirelessSetting->setSsid(apName.toUtf8());
|
||||
if (wirelessBand == WIFI_BAND_2_4GHZ) {
|
||||
wirelessSetting->setBand(NetworkManager::WirelessSetting::FrequencyBand::Bg);
|
||||
} else if (wirelessBand == WIFI_BAND_5GHZ) {
|
||||
wirelessSetting->setBand(NetworkManager::WirelessSetting::FrequencyBand::A);
|
||||
} else {
|
||||
qWarning()<<"[KyWirelessConnectOperation] the band type undefined"<<wirelessBand;
|
||||
wirelessSetting->setBand(NetworkManager::WirelessSetting::FrequencyBand::Automatic);
|
||||
}
|
||||
|
||||
|
||||
NetworkManager::WirelessSecuritySetting::Ptr wirelessSecuritySetting
|
||||
= apConnectSettingPtr->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
if (apPassword.isEmpty()) {
|
||||
wirelessSecuritySetting->setInitialized(false);
|
||||
} else {
|
||||
wirelessSecuritySetting->setInitialized(true);
|
||||
wirelessSecuritySetting->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaPsk);
|
||||
wirelessSecuritySetting->setPsk(apPassword);
|
||||
}
|
||||
|
||||
apConnectPtr->update(apConnectSettingPtr->toMap());
|
||||
}
|
||||
|
||||
void KyWirelessConnectOperation::activeWirelessAp(const QString apUuid, const QString apName,
|
||||
const QString apPassword, const QString apDevice,
|
||||
const QString wirelessBand)
|
||||
|
||||
{
|
||||
//1、检查连接是否存在
|
||||
NetworkManager::Connection::Ptr connectPtr = m_networkResourceInstance->findConnectByUuid(apUuid);
|
||||
if (nullptr == connectPtr) {
|
||||
NetworkManager::Device::Ptr devicePtr = m_networkResourceInstance->findDeviceByName(apDevice);
|
||||
if (devicePtr.isNull()) {
|
||||
QString errorMsg ="Create hotspot faild. " + apDevice + " is not existed";
|
||||
qWarning()<< errorMsg;
|
||||
return;
|
||||
}
|
||||
|
||||
QString deviceIdentifier = devicePtr->uni();
|
||||
|
||||
NetworkManager::ConnectionSettings::Ptr apConnectSettingPtr =
|
||||
createWirelessApSetting(apName, apPassword, apDevice, wirelessBand);
|
||||
QString specificObject = "";
|
||||
QDBusPendingCallWatcher * watcher;
|
||||
watcher = new QDBusPendingCallWatcher{NetworkManager::addAndActivateConnection(apConnectSettingPtr->toMap(), deviceIdentifier, specificObject), this};
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) {
|
||||
if (watcher->isError() || !watcher->isValid()) {
|
||||
QString errorMsg = "Create hotspot faild. " + watcher->error().message();
|
||||
qWarning() << errorMsg;
|
||||
}
|
||||
watcher->deleteLater();
|
||||
});
|
||||
} else {
|
||||
updateWirelessApSetting(connectPtr, apName, apPassword, apDevice, wirelessBand);
|
||||
QTimer::singleShot(500, this, [=](){
|
||||
activateApConnectionByUuid(apUuid, apDevice);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void KyWirelessConnectOperation::deactiveWirelessAp(const QString apName, const QString apUuid)
|
||||
{
|
||||
deactivateConnection(apUuid);
|
||||
}
|
||||
|
||||
//private
|
||||
NetworkManager::WirelessNetwork::Ptr KyWirelessConnectOperation::checkWifiNetExist(QString ssid, QString devName)
|
||||
{
|
||||
NetworkManager::WirelessNetwork::List wifiNetList = m_networkResourceInstance->getWifiNetworkList();
|
||||
|
||||
for (auto const & net : wifiNetList) {
|
||||
auto dev = m_networkResourceInstance->findDeviceByUni(net->device());
|
||||
if (dev == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (dev->type() != NetworkManager::Device::Wifi || dev->interfaceName() != devName) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NetworkManager::AccessPoint::Ptr accessPointPtr = net->referenceAccessPoint();
|
||||
QByteArray rawSsid = accessPointPtr->rawSsid();
|
||||
QString wifiSsid = getSsidFromByteArray(rawSsid);
|
||||
|
||||
if (ssid == wifiSsid) {
|
||||
return net;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
KyKeyMgmt KyWirelessConnectOperation::getConnectKeyMgmt(const QString &uuid)
|
||||
{
|
||||
NetworkManager::Connection::Ptr connectPtr =
|
||||
NetworkManager::findConnectionByUuid(uuid);
|
||||
if (connectPtr.isNull()) {
|
||||
return KyKeyMgmt::Unknown;
|
||||
}
|
||||
|
||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
||||
= connectPtr->settings()->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
|
||||
if(security_sett.isNull()) {
|
||||
return KyKeyMgmt::Unknown;
|
||||
}
|
||||
return (KyKeyMgmt)security_sett->keyMgmt();
|
||||
}
|
||||
|
||||
KySecuType KyWirelessConnectOperation::getConnectSecuType(const QString &uuid)
|
||||
{
|
||||
KyKeyMgmt type = getConnectKeyMgmt(uuid);
|
||||
if (type == WpaNone) {
|
||||
return KySecuType::NONE;
|
||||
} else if (type == WpaPsk) {
|
||||
return KySecuType::WPA_AND_WPA2_PERSONAL;
|
||||
} else if (type == SAE) {
|
||||
return KySecuType::WPA3_PERSONAL;
|
||||
} else if (type == WpaEap) {
|
||||
return KySecuType::WPA_AND_WPA2_ENTERPRISE;
|
||||
} else {
|
||||
qWarning() << "KeyMgmt not support now " << type;
|
||||
return KySecuType::UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
void KyWirelessConnectOperation::updateWirelessSecu(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyWirelessConnectSetting &connSettingInfo, bool bPwdChange)
|
||||
{
|
||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
||||
= connSettingPtr->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
|
||||
KyKeyMgmt type = getConnectKeyMgmt(connSettingPtr->uuid());
|
||||
if (type == WpaNone) {
|
||||
security_sett->setInitialized(false);
|
||||
return;
|
||||
} else {
|
||||
security_sett->setInitialized(true);
|
||||
}
|
||||
security_sett->setKeyMgmt((NetworkManager::WirelessSecuritySetting::KeyMgmt)type);
|
||||
if (bPwdChange) {
|
||||
security_sett->setPsk(connSettingInfo.m_psk);
|
||||
NetworkManager::Setting::SecretFlags flag = NetworkManager::Setting::None;
|
||||
security_sett->setPskFlags(flag);
|
||||
}
|
||||
}
|
||||
|
||||
void KyWirelessConnectOperation::setWirelessSecuWpaXEap(NetworkManager::ConnectionSettings::Ptr connSettingPtr)
|
||||
{
|
||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
||||
= connSettingPtr->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
|
||||
security_sett->setInitialized(true);
|
||||
security_sett->setKeyMgmt(NetworkManager::WirelessSecuritySetting::KeyMgmt::WpaEap);
|
||||
}
|
||||
|
||||
void KyWirelessConnectOperation::setIpv4AndIpv6Setting(NetworkManager::ConnectionSettings::Ptr connSetting, const KyConnectSetting &connSettingInfo)
|
||||
{
|
||||
NetworkManager::Ipv4Setting::Ptr ipv4Setting = connSetting->setting(NetworkManager::Setting::Ipv4).dynamicCast<NetworkManager::Ipv4Setting>();
|
||||
ipv4SettingSet(ipv4Setting, connSettingInfo);
|
||||
|
||||
NetworkManager::Ipv6Setting::Ptr ipv6Setting = connSetting->setting(NetworkManager::Setting::Ipv6).dynamicCast<NetworkManager::Ipv6Setting>();
|
||||
ipv6SettingSet(ipv6Setting, connSettingInfo);
|
||||
}
|
||||
|
||||
void KyWirelessConnectOperation::activateApConnectionByUuid(const QString apUuid, const QString apDevice)
|
||||
{
|
||||
QString connectPath = "";
|
||||
QString deviceIdentifier = "";
|
||||
QString connectName = "";
|
||||
QString specificObject = "";
|
||||
|
||||
NetworkManager::Connection::Ptr connectPtr = m_networkResourceInstance->findConnectByUuid(apUuid);
|
||||
if (connectPtr.isNull())
|
||||
{
|
||||
QString errorMessage = tr("Create hotspot faild.UUID is empty, its name") + apUuid;
|
||||
qWarning() << errorMessage;
|
||||
Q_EMIT activateConnectionError(errorMessage);
|
||||
return;
|
||||
}
|
||||
connectPath = connectPtr->path();
|
||||
connectName = connectPtr->name();
|
||||
|
||||
auto dev = m_networkResourceInstance->findDeviceByName(apDevice);
|
||||
if (!dev.isNull()) {
|
||||
deviceIdentifier = dev->uni();
|
||||
}
|
||||
|
||||
if (deviceIdentifier.isEmpty()) {
|
||||
QString errorMessage = tr("Create hotspot faild.Device Identifier is empty, its name") + apDevice;
|
||||
qWarning() << errorMessage;
|
||||
Q_EMIT activateConnectionError(errorMessage);
|
||||
return ;
|
||||
}
|
||||
|
||||
QDBusPendingCallWatcher * watcher;
|
||||
watcher = new QDBusPendingCallWatcher{NetworkManager::activateConnection(connectPath, deviceIdentifier, specificObject), this};
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished, [this, connectName, apDevice] (QDBusPendingCallWatcher * watcher) {
|
||||
if (watcher->isError() || !watcher->isValid()) {
|
||||
QString errorMessage = tr("Create hotspot faild. ") + watcher->error().message();
|
||||
qWarning()<<errorMessage;
|
||||
Q_EMIT this->activateConnectionError(errorMessage);
|
||||
} else {
|
||||
qWarning()<<"active wired connect complete.";
|
||||
}
|
||||
|
||||
watcher->deleteLater();
|
||||
});
|
||||
}
|
||||
|
||||
bool KyWirelessConnectOperation::isApConnection(QString uuid)
|
||||
{
|
||||
NetworkManager::Connection::Ptr connectPtr = nullptr;
|
||||
|
||||
connectPtr = m_networkResourceInstance->findConnectByUuid(uuid);
|
||||
return m_networkResourceInstance->isApConnection(connectPtr);
|
||||
}
|
|
@ -0,0 +1,133 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifndef KYWIRELESSCONNECTOPERATION_H
|
||||
#define KYWIRELESSCONNECTOPERATION_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QTimer>
|
||||
#include "kyenterpricesettinginfo.h"
|
||||
#include "kylinconnectoperation.h"
|
||||
#include "kyenterpricesettinginfo.h"
|
||||
|
||||
const QByteArray GSETTINGS_SCHEMA = "org.ukui.kylin-nm.switch";
|
||||
const QString WIRELESS_SWITCH = "wirelessswitch";
|
||||
|
||||
const QString WIFI_BAND_2_4GHZ = "2.4Ghz";
|
||||
const QString WIFI_BAND_5GHZ = "5Ghz";
|
||||
|
||||
enum KySecuType {
|
||||
UNKNOWN,
|
||||
NONE,
|
||||
WPA_AND_WPA2_PERSONAL,
|
||||
WPA_AND_WPA2_ENTERPRISE,
|
||||
WPA3_PERSONAL,
|
||||
};
|
||||
|
||||
enum KyKeyMgmt {
|
||||
Unknown = -1,
|
||||
Wep, Ieee8021x,
|
||||
WpaNone,
|
||||
WpaPsk,
|
||||
WpaEap,
|
||||
SAE
|
||||
};
|
||||
|
||||
class KyWirelessConnectSetting : public KyConnectSetting
|
||||
{
|
||||
public:
|
||||
QString m_ssid;
|
||||
QString m_psk;
|
||||
NetworkManager::Setting::SecretFlags m_secretFlag = NetworkManager::Setting::SecretFlagType::None;
|
||||
bool isHidden = false;
|
||||
};
|
||||
|
||||
|
||||
class KyWirelessConnectOperation : public KyConnectOperation
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit KyWirelessConnectOperation(QObject *parent = nullptr);
|
||||
|
||||
public:
|
||||
|
||||
void requestWirelessScan();
|
||||
//获取密码保存策略
|
||||
bool getConnSecretFlags(QString &connUuid, NetworkManager::Setting::SecretFlags &);
|
||||
|
||||
//获取KeyMgmt
|
||||
KyKeyMgmt getConnectKeyMgmt(const QString &uuid);
|
||||
KySecuType getConnectSecuType(const QString &uuid);
|
||||
|
||||
//激活连接
|
||||
void activeWirelessConnect(QString , QString);
|
||||
//断开连接
|
||||
void deActivateWirelessConnection(const QString activeConnectName, const QString &activeConnectUuid);
|
||||
//新增普通连接
|
||||
void addConnect(const KyWirelessConnectSetting &connSettingInfo, KySecuType &type);
|
||||
//新增TLS连接
|
||||
void addTlsConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodTlsInfo &tlsinfo);
|
||||
//新增PEAP连接
|
||||
void addPeapConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodPeapInfo &peapInfo);
|
||||
//新增TTLS连接
|
||||
void addTtlsConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodTtlsInfo &ttlsInfo);
|
||||
//新增连接并激活(普通wifi)
|
||||
void addAndActiveWirelessConnect(KyWirelessConnectSetting &connSettingInfo, KySecuType &type);
|
||||
|
||||
//新增连接并激活(企业wifi)
|
||||
void addAndActiveWirelessEnterPriseTlsConnect(KyEapMethodTlsInfo &info, KyWirelessConnectSetting &connSettingInfo);
|
||||
void addAndActiveWirelessEnterPrisePeapConnect(KyEapMethodPeapInfo &info, KyWirelessConnectSetting &connSettingInfo);
|
||||
void addAndActiveWirelessEnterPriseTtlsConnect(KyEapMethodTtlsInfo &info, KyWirelessConnectSetting &connSettingInfo);
|
||||
//属性页 page1 AutoConnect
|
||||
void setWirelessAutoConnect(const QString &uuid, bool bAutoConnect);
|
||||
//属性页 page2 page3 ipv6
|
||||
void updateIpv4AndIpv6SettingInfo(const QString &uuid, const KyConnectSetting &connectSettingsInfo);
|
||||
//属性页 page4 wifi Security
|
||||
//连接修改(安全改为个人/None)
|
||||
void updateWirelessPersonalConnect(const QString &uuid, const KyWirelessConnectSetting &connSettingInfo, bool bPwdChange);
|
||||
//连接修改(安全改为改为企业)
|
||||
void updateWirelessEnterPriseTlsConnect(const QString &uuid, const KyEapMethodTlsInfo &tlsinfo);
|
||||
void updateWirelessEnterPrisePeapConnect(const QString &uuid, const KyEapMethodPeapInfo &peapInfo);
|
||||
void updateWirelessEnterPriseTtlsConnect(const QString &uuid, const KyEapMethodTtlsInfo &ttlsInfo);
|
||||
//忘记
|
||||
void deleteWirelessConnect(const QString &connectUuid);
|
||||
//获取密码
|
||||
QString getPsk(const QString &connectUuid);
|
||||
QString getPrivateKeyPassword(const QString &connectUuid);
|
||||
QString get8021xPassword(const QString &connectUuid);
|
||||
|
||||
void activeWirelessAp(const QString apUuid, const QString apName,
|
||||
const QString apPassword, const QString apDevice,
|
||||
const QString wirelessBand);
|
||||
void deactiveWirelessAp(const QString apName, const QString apUuid);
|
||||
|
||||
bool isApConnection(QString uuid);
|
||||
|
||||
private:
|
||||
NetworkManager::ConnectionSettings::Ptr createWirelessApSetting(const QString apSsid,
|
||||
const QString apPassword, const QString apDevice, const QString wirelessBand);
|
||||
void updateWirelessApSetting(NetworkManager::Connection::Ptr apConnectPtr, const QString apName,
|
||||
const QString apPassword, const QString apDevice, const QString wirelessBand);
|
||||
|
||||
NetworkManager::WirelessNetwork::Ptr checkWifiNetExist(QString ssid, QString devName);
|
||||
void updateWirelessSecu(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyWirelessConnectSetting &connSettingInfo, bool bPwdChange = false);
|
||||
void setIpv4AndIpv6Setting(NetworkManager::ConnectionSettings::Ptr connSetting, const KyConnectSetting &connSettingInfo);
|
||||
void setWirelessSecuWpaXEap(NetworkManager::ConnectionSettings::Ptr connSettingPtr);
|
||||
void activateApConnectionByUuid(const QString apUuid, const QString apDevice);
|
||||
};
|
||||
|
||||
#endif // KYWIRELESSCONNECTOPERATION_H
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#include "kywirelessnetitem.h"
|
||||
|
||||
KyWirelessNetItem::KyWirelessNetItem()
|
||||
{
|
||||
m_NetSsid = "";
|
||||
m_connectUuid = "";
|
||||
m_connectSecuType = KySecuType::NONE;
|
||||
m_secuType = "";
|
||||
m_signalStrength = 0;
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifndef KYWIRELESSNETITEM_H
|
||||
#define KYWIRELESSNETITEM_H
|
||||
|
||||
#include <QString>
|
||||
#include "kywirelessconnectoperation.h"
|
||||
|
||||
class KyWirelessNetItem
|
||||
{
|
||||
public:
|
||||
QString m_NetSsid = "";
|
||||
QString m_connectUuid = "";
|
||||
QString m_dbusPath = "";
|
||||
KySecuType m_connectSecuType = KySecuType::NONE;
|
||||
bool m_isApConnection = false;
|
||||
QString m_secuType = "";
|
||||
int m_signalStrength = 0;
|
||||
};
|
||||
|
||||
#endif // KYWIRELESSNETITEM_H
|
|
@ -0,0 +1,601 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#include "kywirelessnetresource.h"
|
||||
#include "kylinnetworkmanagerutil.h"
|
||||
|
||||
#define LOG_FLAG "[KyWirelessNetResource]"
|
||||
|
||||
#define PSK_SETTING_NAME "802-11-wireless-security"
|
||||
#define PRIVATE_PSK_SETTING_NAME "802-1x"
|
||||
|
||||
static bool subWifiListSort(const KyWirelessNetItem info1, const KyWirelessNetItem info2)
|
||||
{
|
||||
if (info1.m_connectUuid.isEmpty() == info2.m_connectUuid.isEmpty()) {
|
||||
if (info1.m_signalStrength != info2.m_signalStrength) {
|
||||
return info1.m_signalStrength > info2.m_signalStrength;
|
||||
} else {
|
||||
if (QString::compare(info1.m_NetSsid, info2.m_NetSsid, Qt::CaseInsensitive) > 0) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return !info1.m_connectUuid.isEmpty();
|
||||
}
|
||||
|
||||
static void wifiListSort(QList<KyWirelessNetItem> &list)
|
||||
{
|
||||
qSort(list.begin(), list.end(), subWifiListSort);
|
||||
}
|
||||
|
||||
KyWirelessNetResource::KyWirelessNetResource(QObject *parent) : KyNetResource(parent)
|
||||
{
|
||||
qRegisterMetaType<KyWirelessNetItem>("KyWirelessNetItem&");
|
||||
qRegisterMetaType<NetworkManager::WirelessNetwork::Ptr>("NetworkManager::WirelessNetwork::Ptr");
|
||||
|
||||
kyWirelessNetItemListInit();
|
||||
|
||||
//无线出现/消失-->item 增删
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::wifiNetworkAdded,
|
||||
this, &KyWirelessNetResource::onWifiNetworkAdded);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::wifiNetworkRemoved,
|
||||
this, &KyWirelessNetResource::onWifiNetworkRemoved);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::wifiNetworkPropertyChange,
|
||||
this, &KyWirelessNetResource::onWifiNetworkPropertyChange);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::wifiNetworkDeviceDisappear,
|
||||
this, &KyWirelessNetResource::onWifiNetworkDeviceDisappear);
|
||||
|
||||
//无线配置变化-->item uuid变化
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::wirelessConnectionAdd,
|
||||
this, &KyWirelessNetResource::onConnectionAdd);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::connectionRemove,
|
||||
this, &KyWirelessNetResource::onConnectionRemove);
|
||||
|
||||
//设备变化-->map key变化
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::wirelessDeviceAdd,
|
||||
this, &KyWirelessNetResource::onDeviceAdd);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceRemove,
|
||||
this, &KyWirelessNetResource::onDeviceRemove);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::wirelessDeviceUpdate,
|
||||
this, &KyWirelessNetResource::onDeviceNameUpdate);
|
||||
|
||||
m_updateTimer = new QTimer(this);
|
||||
m_updateTimer->start(10*1000);
|
||||
connect(m_updateTimer, &QTimer::timeout, this, &KyWirelessNetResource::updateList);
|
||||
|
||||
}
|
||||
|
||||
//配合activeconnection 此处未单独区分已连接的wifi
|
||||
void KyWirelessNetResource::getWifiNetworkList(QString devName, QList<KyWirelessNetItem> &list)
|
||||
{
|
||||
list.clear();
|
||||
if (m_WifiNetworkList.isEmpty() || !m_WifiNetworkList.contains(devName)) {
|
||||
return;
|
||||
} else {
|
||||
QMap<QString, QList<KyWirelessNetItem> >::iterator iter = m_WifiNetworkList.begin();
|
||||
while (iter != m_WifiNetworkList.end()) {
|
||||
if (iter.key() == devName) {
|
||||
list = m_WifiNetworkList[iter.key()];
|
||||
wifiListSort(list);
|
||||
return;
|
||||
}
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KyWirelessNetResource::kyWirelessNetItemListInit()
|
||||
{
|
||||
m_WifiNetworkList.clear();
|
||||
|
||||
NetworkManager::WirelessNetwork::List m_wifiNetList = m_networkResourceInstance->getWifiNetworkList();
|
||||
for (auto const & net : m_wifiNetList) {
|
||||
QString devIface = getDeviceIFace(net);
|
||||
if (devIface.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
KyWirelessNetItem item;
|
||||
wirelessNetItemInit(item, net);
|
||||
if (!m_WifiNetworkList.contains(devIface)){
|
||||
QList<KyWirelessNetItem> list;
|
||||
list.append(item);
|
||||
m_WifiNetworkList.insert(devIface,list);
|
||||
} else {
|
||||
m_WifiNetworkList[devIface].append(item);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void KyWirelessNetResource::wirelessNetItemInit(KyWirelessNetItem &wirelessItem,
|
||||
NetworkManager::WirelessNetwork::Ptr wirelessNetPtr)
|
||||
{
|
||||
if(wirelessNetPtr.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkManager::AccessPoint::Ptr accessPointPtr = wirelessNetPtr->referenceAccessPoint();
|
||||
QByteArray rawSsid = accessPointPtr->rawSsid();
|
||||
wirelessItem.m_NetSsid = getSsidFromByteArray(rawSsid);
|
||||
|
||||
wirelessItem.m_signalStrength = accessPointPtr->signalStrength();
|
||||
NetworkManager::AccessPoint::Capabilities cap = accessPointPtr->capabilities();
|
||||
NetworkManager::AccessPoint::WpaFlags wpaFlag = accessPointPtr->wpaFlags();
|
||||
NetworkManager::AccessPoint::WpaFlags rsnFlag = accessPointPtr->rsnFlags();
|
||||
wirelessItem.m_secuType = enumToQstring(cap, wpaFlag, rsnFlag);
|
||||
QString interface = getDeviceIFace(wirelessNetPtr);
|
||||
getUuidBySsid(wirelessItem.m_NetSsid, interface, wirelessItem.m_connectUuid, wirelessItem.m_dbusPath);
|
||||
KyWirelessConnectOperation operation;
|
||||
wirelessItem.m_connectSecuType = operation.getConnectSecuType(wirelessItem.m_connectUuid);
|
||||
wirelessItem.m_isApConnection = operation.isApConnection(wirelessItem.m_connectUuid);
|
||||
}
|
||||
|
||||
void KyWirelessNetResource::getUuidBySsid(const QString &ssid, QString &deviceName, QString &uuid, QString &dbusPath)
|
||||
{
|
||||
uuid.clear();
|
||||
dbusPath.clear();
|
||||
NetworkManager::Connection::List connectList;
|
||||
|
||||
connectList.clear();
|
||||
connectList = m_networkResourceInstance->getConnectList();
|
||||
|
||||
if (connectList.empty()) {
|
||||
qWarning()<<"[KyConnectResourse]"<<"get connection failed, the connect list is empty";
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkManager::Connection::Ptr connectPtr = nullptr;
|
||||
for (int index = 0; index < connectList.size(); index++) {
|
||||
connectPtr = connectList.at(index);
|
||||
if (connectPtr.isNull()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (NetworkManager::ConnectionSettings::Wireless != connectPtr->settings()->connectionType()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
QString connectInterface = connectPtr->settings()->interfaceName();
|
||||
if (!connectInterface.isEmpty()
|
||||
&& deviceName != connectInterface) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NetworkManager::WirelessSetting::Ptr wifi_sett
|
||||
= connectPtr->settings()->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
|
||||
if (wifi_sett->ssid() == ssid) {
|
||||
uuid = connectPtr->settings()->uuid();
|
||||
dbusPath = connectPtr->path();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KyWirelessNetResource::onWifiNetworkAdded(QString devIfaceName, QString ssid)
|
||||
{
|
||||
NetworkManager::WirelessNetwork::Ptr wifi = nullptr;
|
||||
NetworkManager::WirelessNetwork::List m_wifiNetList = m_networkResourceInstance->getWifiNetworkList();
|
||||
for (auto const & net : m_wifiNetList) {
|
||||
if (net.isNull()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NetworkManager::AccessPoint::Ptr accessPointPtr = net->referenceAccessPoint();
|
||||
QByteArray rawSsid = accessPointPtr->rawSsid();
|
||||
QString wifiSsid = getSsidFromByteArray(rawSsid);
|
||||
|
||||
if (wifiSsid == ssid
|
||||
&& m_networkResourceInstance->findDeviceByUni(net->device())->interfaceName() == devIfaceName) {
|
||||
wifi = net;
|
||||
}
|
||||
}
|
||||
|
||||
if (wifi.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
KyWirelessNetItem item;
|
||||
wirelessNetItemInit(item, wifi);
|
||||
|
||||
if (m_WifiNetworkList.contains(devIfaceName)) {
|
||||
m_WifiNetworkList[devIfaceName].append(item);
|
||||
} else {
|
||||
QList<KyWirelessNetItem> list;
|
||||
list.append(item);
|
||||
m_WifiNetworkList.insert(devIfaceName,list);
|
||||
}
|
||||
|
||||
Q_EMIT wifiNetworkAdd(devIfaceName, item);
|
||||
}
|
||||
|
||||
void KyWirelessNetResource::onWifiNetworkRemoved(QString devIfaceName, QString ssid)
|
||||
{
|
||||
if (m_WifiNetworkList.contains(devIfaceName)) {
|
||||
int index = 0;
|
||||
for ( ; index < m_WifiNetworkList.value(devIfaceName).size(); index++) {
|
||||
if ( m_WifiNetworkList[devIfaceName].at(index).m_NetSsid == ssid) {
|
||||
m_WifiNetworkList[devIfaceName].removeAt(index);
|
||||
}
|
||||
}
|
||||
//remove后为空则删除
|
||||
if (m_WifiNetworkList.value(devIfaceName).isEmpty()) {
|
||||
m_WifiNetworkList.remove(devIfaceName);
|
||||
}
|
||||
Q_EMIT wifiNetworkRemove(devIfaceName, ssid);
|
||||
}
|
||||
}
|
||||
|
||||
void KyWirelessNetResource::onWifiNetworkPropertyChange(NetworkManager::WirelessNetwork::Ptr net)
|
||||
{
|
||||
if (nullptr == net) {
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkManager::AccessPoint::Ptr accessPointPtr = net->referenceAccessPoint();
|
||||
QByteArray rawSsid = accessPointPtr->rawSsid();
|
||||
QString wifiSsid = getSsidFromByteArray(rawSsid);
|
||||
|
||||
QString devIface = m_networkResourceInstance->findDeviceByUni(net->device())->interfaceName();
|
||||
if (m_WifiNetworkList.contains(devIface)) {
|
||||
QList<KyWirelessNetItem>::iterator iter = m_WifiNetworkList[devIface].begin();
|
||||
while (iter != m_WifiNetworkList[devIface].end()) {
|
||||
if (iter->m_NetSsid == wifiSsid) {
|
||||
if (iter->m_signalStrength != net->signalStrength()) {
|
||||
iter->m_signalStrength = net->signalStrength();
|
||||
}
|
||||
|
||||
QString secuType = enumToQstring(accessPointPtr->capabilities(),
|
||||
accessPointPtr->wpaFlags(),
|
||||
accessPointPtr->rsnFlags());
|
||||
if (iter->m_secuType != secuType) {
|
||||
iter->m_secuType = secuType;
|
||||
KyWirelessNetItem item = *iter;
|
||||
Q_EMIT wifiNetworkUpdate(devIface, wifiSsid, item);
|
||||
}
|
||||
break;
|
||||
}
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KyWirelessNetResource::onWifiNetworkDeviceDisappear()
|
||||
{
|
||||
qWarning() << "wifiNetworkDeviceDisappear!!!!!!!!!";
|
||||
for (int i = 0; i < m_WifiNetworkList.keys().size(); ++i) {
|
||||
Q_EMIT deviceRemove(m_WifiNetworkList.keys().at(i));
|
||||
}
|
||||
kyWirelessNetItemListInit();
|
||||
}
|
||||
|
||||
//对应属性页-->安全
|
||||
bool KyWirelessNetResource::getNormalWifiConnectSecuInfo(QString &uuid, KyWpaPasswordInfo &info)
|
||||
{
|
||||
KyWirelessConnectOperation operation;
|
||||
info.pwd = operation.getPsk(uuid);
|
||||
return operation.getConnSecretFlags(uuid, info.flag);
|
||||
}
|
||||
|
||||
bool KyWirelessNetResource::getEnterpiseEapMethod(const QString &uuid, KyEapMethodType &type)
|
||||
{
|
||||
NetworkManager::Connection::Ptr connectPtr =
|
||||
NetworkManager::findConnectionByUuid(uuid);
|
||||
if (connectPtr.isNull()) {
|
||||
qWarning() << "getEnterpiseEapMethod faild.Can't find uuid = " << uuid;
|
||||
return false;
|
||||
}
|
||||
|
||||
KyWirelessConnectOperation operation;
|
||||
KyKeyMgmt keyMgmt = operation.getConnectKeyMgmt(uuid);
|
||||
if (keyMgmt != WpaEap) {
|
||||
qWarning() << "getEnterpiseEapMethod but not WpaEap.it's " << keyMgmt;
|
||||
return false;
|
||||
}
|
||||
|
||||
NetworkManager::ConnectionSettings::Ptr connectionSettings = connectPtr->settings();
|
||||
|
||||
NetworkManager::Security8021xSetting::Ptr wifi_8021x_sett
|
||||
= connectionSettings->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>();
|
||||
|
||||
QList<NetworkManager::Security8021xSetting::EapMethod> list = wifi_8021x_sett->eapMethods();
|
||||
|
||||
if (list.contains(NetworkManager::Security8021xSetting::EapMethod::EapMethodTls)) {
|
||||
type = TLS;
|
||||
} else if (list.contains(NetworkManager::Security8021xSetting::EapMethod::EapMethodPeap)) {
|
||||
type = PEAP;
|
||||
} else if (list.contains(NetworkManager::Security8021xSetting::EapMethod::EapMethodTtls)) {
|
||||
type = TTLS;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool KyWirelessNetResource::getEnterPriseInfoTls(QString &uuid, KyEapMethodTlsInfo &info)
|
||||
{
|
||||
NetworkManager::Connection::Ptr conn = m_networkResourceInstance->findConnectByUuid(uuid);
|
||||
if (conn.isNull()) {
|
||||
qWarning() << LOG_FLAG << "modifyEnterPriseInfoTls connection missing";
|
||||
return false;
|
||||
}
|
||||
|
||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett =
|
||||
conn->settings()->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
if (security_sett.isNull()) {
|
||||
qWarning()<< LOG_FLAG << "don't have WirelessSecurity connection";
|
||||
return false;
|
||||
}
|
||||
if (security_sett->keyMgmt() != NetworkManager::WirelessSecuritySetting::WpaEap) {
|
||||
return false;
|
||||
}
|
||||
NetworkManager::Security8021xSetting::Ptr setting =
|
||||
conn->settings()->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>();
|
||||
if (setting.isNull()) {
|
||||
qWarning()<< LOG_FLAG << "don't have Security8021x connection";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
info.identity = setting->identity();
|
||||
info.domain = setting->domainSuffixMatch();
|
||||
info.caCertPath = setting->caPath();
|
||||
if (info.caCertPath.left(7) == "file://") {
|
||||
info.caCertPath = info.caCertPath.mid(7);
|
||||
}
|
||||
|
||||
info.clientCertPath = setting->clientCertificate();
|
||||
if (info.clientCertPath.left(7) == "file://") {
|
||||
info.clientCertPath = info.clientCertPath.mid(7);
|
||||
}
|
||||
|
||||
info.clientPrivateKey = QString(setting->privateKey());
|
||||
if (info.clientPrivateKey.left(7) == "file://") {
|
||||
info.clientPrivateKey = info.clientPrivateKey.mid(7);
|
||||
}
|
||||
|
||||
info.m_privateKeyPWDFlag = setting->privateKeyPasswordFlags();
|
||||
if (!info.m_privateKeyPWDFlag) {
|
||||
KyWirelessConnectOperation operation;
|
||||
info.clientPrivateKeyPWD = operation.getPrivateKeyPassword(conn->uuid());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool KyWirelessNetResource::getEnterPriseInfoPeap(QString &uuid, KyEapMethodPeapInfo &info)
|
||||
{
|
||||
NetworkManager::Connection::Ptr conn = m_networkResourceInstance->findConnectByUuid(uuid);
|
||||
if (conn.isNull()) {
|
||||
qWarning() << LOG_FLAG << "getEnterPriseInfoPeap connection missing";
|
||||
return false;
|
||||
}
|
||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
||||
= conn->settings()->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
if (security_sett.isNull()) {
|
||||
qWarning() << LOG_FLAG << "don't have WirelessSecurity connection";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (security_sett->keyMgmt() != NetworkManager::WirelessSecuritySetting::WpaEap) {
|
||||
qWarning() << LOG_FLAG << "keyMgmt not WpaEap " << security_sett->keyMgmt();
|
||||
return false;
|
||||
}
|
||||
|
||||
NetworkManager::Security8021xSetting::Ptr setting =
|
||||
conn->settings()->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>();
|
||||
if (setting.isNull() || !setting->eapMethods().contains(NetworkManager::Security8021xSetting::EapMethod::EapMethodPeap)) {
|
||||
qWarning()<< LOG_FLAG << "don't have Security8021x connection";
|
||||
return false;
|
||||
}
|
||||
|
||||
info.phase2AuthMethod = (KyNoEapMethodAuth)setting->phase2AuthMethod();
|
||||
info.userName = setting->identity();
|
||||
info.m_passwdFlag = setting->passwordFlags();
|
||||
if (!info.m_passwdFlag) {
|
||||
KyWirelessConnectOperation operation;
|
||||
info.userPWD = operation.get8021xPassword(conn->uuid());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool KyWirelessNetResource::getEnterPriseInfoTtls(QString &uuid, KyEapMethodTtlsInfo &info)
|
||||
{
|
||||
NetworkManager::Connection::Ptr conn = m_networkResourceInstance->findConnectByUuid(uuid);
|
||||
if (conn.isNull()) {
|
||||
qWarning() << LOG_FLAG << "modifyEnterPriseInfoTtls connection missing";
|
||||
return false;
|
||||
}
|
||||
|
||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
||||
= conn->settings()->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
if (security_sett.isNull()) {
|
||||
qWarning() << LOG_FLAG << "don't have WirelessSecurity connection";
|
||||
return false;
|
||||
}
|
||||
if (security_sett->keyMgmt() != NetworkManager::WirelessSecuritySetting::WpaEap) {
|
||||
qWarning() << LOG_FLAG << "not wpaeap"<<security_sett->keyMgmt();
|
||||
return false;
|
||||
}
|
||||
|
||||
NetworkManager::Security8021xSetting::Ptr setting = conn->settings()->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>();
|
||||
if (setting.isNull() || !setting->eapMethods().contains(NetworkManager::Security8021xSetting::EapMethod::EapMethodTtls)) {
|
||||
qWarning() << LOG_FLAG << "don't have Security8021x connection";
|
||||
return false;
|
||||
}
|
||||
|
||||
info.authEapMethod = (KyEapMethodAuth)setting->phase2AuthEapMethod();
|
||||
info.authNoEapMethod = (KyNoEapMethodAuth)setting->phase2AuthMethod();
|
||||
|
||||
info.authType = KyTtlsAuthMethod::AUTH_EAP;
|
||||
if (info.authEapMethod != KyAuthEapMethodUnknown) {
|
||||
info.authType = KyTtlsAuthMethod::AUTH_EAP;
|
||||
} else {
|
||||
info.authType = KyTtlsAuthMethod::AUTH_NO_EAP;
|
||||
}
|
||||
|
||||
info.userName = setting->identity();
|
||||
info.m_passwdFlag = setting->passwordFlags();
|
||||
if (!info.m_passwdFlag) {
|
||||
KyWirelessConnectOperation operation;
|
||||
info.userPWD = operation.get8021xPassword(conn->uuid());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void KyWirelessNetResource::getWirelessConnectDetail(QString interface, QString ssid, QString uuid, KyDetailInfo &connectSetting)
|
||||
{
|
||||
getBaseInfo(interface, ssid, true, !uuid.isEmpty(), connectSetting);
|
||||
if (!uuid.isEmpty()) {
|
||||
getDynamicIpInfo(uuid, connectSetting);
|
||||
}
|
||||
}
|
||||
|
||||
void KyWirelessNetResource::onConnectionAdd(QString connectUuid, QString connectName, QString connectPath)
|
||||
{
|
||||
Q_UNUSED(connectName);
|
||||
NetworkManager::Connection::Ptr conn = m_networkResourceInstance->findConnectByUuid(connectUuid);
|
||||
if (conn.isNull()) {
|
||||
qWarning() << LOG_FLAG << "onConnectionAdd can not find connection" << connectUuid;
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkManager::ConnectionSettings::Ptr sett = conn->settings();
|
||||
NetworkManager::WirelessSetting::Ptr wireless_sett =
|
||||
sett->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
|
||||
|
||||
QByteArray rawSsid = wireless_sett->ssid();
|
||||
QString wifiSsid = getSsidFromByteArray(rawSsid);
|
||||
|
||||
QMap<QString, QString> map;
|
||||
map.clear();
|
||||
QMap<QString, QList<KyWirelessNetItem> >::iterator iter = m_WifiNetworkList.begin();
|
||||
while (iter != m_WifiNetworkList.end()) {
|
||||
for(int i = 0; i < iter.value().size(); i++) {
|
||||
if (iter.value().at(i).m_NetSsid == wifiSsid
|
||||
&& (sett->interfaceName() == iter.key() || sett->interfaceName().isEmpty())) {
|
||||
QString devIfaceName;
|
||||
QString ssid;
|
||||
KyWirelessConnectOperation operation;
|
||||
m_WifiNetworkList[iter.key()][i].m_connectUuid = conn->uuid();
|
||||
m_WifiNetworkList[iter.key()][i].m_dbusPath = conn->path();
|
||||
m_WifiNetworkList[iter.key()][i].m_connectSecuType = operation.getConnectSecuType(conn->uuid());
|
||||
|
||||
devIfaceName = iter.key();
|
||||
ssid = iter.value().at(i).m_NetSsid;
|
||||
|
||||
Q_EMIT wirelessConnectionAdd(devIfaceName, ssid, connectUuid, connectPath);
|
||||
map.insert(devIfaceName, ssid);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
|
||||
void KyWirelessNetResource::onConnectionRemove(QString path)
|
||||
{
|
||||
QMap<QString, QString> map;
|
||||
map.clear();
|
||||
|
||||
QMap<QString, QList<KyWirelessNetItem> >::iterator iter = m_WifiNetworkList.begin();
|
||||
while (iter != m_WifiNetworkList.end()) {
|
||||
for(int i = 0; i < iter.value().size(); i++) {
|
||||
if (iter.value().at(i).m_dbusPath == path) {
|
||||
KyWirelessConnectOperation operation;
|
||||
QString devIfaceName = iter.key();
|
||||
QString ssid = iter.value().at(i).m_NetSsid;
|
||||
|
||||
getUuidBySsid(ssid, devIfaceName, m_WifiNetworkList[iter.key()][i].m_connectUuid, m_WifiNetworkList[iter.key()][i].m_dbusPath);
|
||||
if (m_WifiNetworkList[iter.key()][i].m_connectUuid.isEmpty()) {
|
||||
Q_EMIT wirelessConnectionRemove(devIfaceName, ssid);
|
||||
} else {
|
||||
Q_EMIT wirelessConnectionUpdate(devIfaceName, ssid,
|
||||
m_WifiNetworkList[iter.key()][i].m_connectUuid,
|
||||
m_WifiNetworkList[iter.key()][i].m_dbusPath,
|
||||
operation.getConnectSecuType(m_WifiNetworkList[iter.key()][i].m_connectUuid));
|
||||
}
|
||||
|
||||
map.insert(devIfaceName, ssid);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
|
||||
void KyWirelessNetResource::onDeviceAdd(QString deviceName)
|
||||
{
|
||||
if (!m_WifiNetworkList.contains(deviceName)) {
|
||||
m_WifiNetworkList.insert(deviceName,QList<KyWirelessNetItem>());
|
||||
Q_EMIT wirelessDeviceAdd(deviceName);
|
||||
}
|
||||
}
|
||||
|
||||
void KyWirelessNetResource::onDeviceRemove(QString deviceName)
|
||||
{
|
||||
if (m_WifiNetworkList.contains(deviceName)) {
|
||||
m_WifiNetworkList.remove(deviceName);
|
||||
Q_EMIT deviceRemove(deviceName);
|
||||
}
|
||||
}
|
||||
|
||||
void KyWirelessNetResource::onDeviceNameUpdate(QString oldName, QString newName)
|
||||
{
|
||||
if (m_WifiNetworkList.contains(oldName)) {
|
||||
QMap<QString, QList<KyWirelessNetItem>> newWifiNetworkList(m_WifiNetworkList);
|
||||
QList<KyWirelessNetItem> list = m_WifiNetworkList[oldName];
|
||||
newWifiNetworkList.remove(oldName);
|
||||
newWifiNetworkList.insert(newName,list);
|
||||
m_WifiNetworkList = newWifiNetworkList;
|
||||
Q_EMIT wirelessDeviceNameUpdate(oldName, newName);
|
||||
}
|
||||
}
|
||||
|
||||
void KyWirelessNetResource::updateList()
|
||||
{
|
||||
for (int i = 0; i< m_WifiNetworkList.keys().size(); ++i) {
|
||||
QString devName = m_WifiNetworkList.keys().at(i);
|
||||
QList<KyActivateItem> connectItemList;
|
||||
KyActiveConnectResourse actResource;
|
||||
actResource.getActiveConnectionList(devName, CONNECT_TYPE_WIRELESS, connectItemList);
|
||||
QList<KyWirelessNetItem> list = m_WifiNetworkList[devName];
|
||||
wifiListSort(list);
|
||||
Q_EMIT updateWifiList(devName, connectItemList, list);
|
||||
}
|
||||
}
|
||||
|
||||
QString KyWirelessNetResource::getDeviceIFace(NetworkManager::WirelessNetwork::Ptr net)
|
||||
{
|
||||
if (net.isNull()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
QString devUni = net->device();
|
||||
NetworkManager::Device::Ptr dev = m_networkResourceInstance->findDeviceByUni(devUni);
|
||||
if (dev.isNull()) {
|
||||
qDebug()<< LOG_FLAG << "KyWirelessNetResource: can't find " << net->ssid() << " find in device list";
|
||||
return "";
|
||||
}
|
||||
|
||||
return dev->interfaceName();
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifndef KYWIRELESSNETRESOURCE_H
|
||||
#define KYWIRELESSNETRESOURCE_H
|
||||
|
||||
#include <QObject>
|
||||
#include "kylinnetresource.h"
|
||||
#include "kywirelessnetitem.h"
|
||||
#include "kylinnetworkresourcemanager.h"
|
||||
#include "kyenterpricesettinginfo.h"
|
||||
#include "kywirelessconnectoperation.h"
|
||||
#include "kylinactiveconnectresource.h"
|
||||
|
||||
class KyWpaPasswordInfo{
|
||||
public:
|
||||
QString pwd;
|
||||
NetworkManager::Setting::SecretFlags flag;
|
||||
};
|
||||
|
||||
class KyWirelessNetResource : public KyNetResource
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit KyWirelessNetResource(QObject *parent = nullptr);
|
||||
|
||||
public:
|
||||
//初始化列表用到的接口
|
||||
void getWifiNetworkList(QString devName, QList<KyWirelessNetItem> &list);
|
||||
|
||||
//属性页---->安全
|
||||
bool getNormalWifiConnectSecuInfo(QString &uuid, KyWpaPasswordInfo &info);
|
||||
bool getEnterPriseInfoTls(QString &uuid, KyEapMethodTlsInfo &info);
|
||||
bool getEnterPriseInfoPeap(QString &uuid, KyEapMethodPeapInfo &info);
|
||||
bool getEnterPriseInfoTtls(QString &uuid, KyEapMethodTtlsInfo &info);
|
||||
|
||||
//获取企业网类型
|
||||
bool getEnterpiseEapMethod(const QString &uuid, KyEapMethodType &type);
|
||||
|
||||
void getWirelessConnectDetail(QString interface, QString ssid, QString uuid, KyDetailInfo &connectSetting);
|
||||
|
||||
private:
|
||||
void kyWirelessNetItemListInit();
|
||||
void wirelessNetItemInit(KyWirelessNetItem &wirelessItem,
|
||||
NetworkManager::WirelessNetwork::Ptr wirelessNetPtr);
|
||||
void getUuidBySsid(const QString &ssid, QString &deviceName, QString &uuid, QString &dbusPath);
|
||||
|
||||
public Q_SLOTS:
|
||||
void onWifiNetworkAdded(QString devIfaceName, QString ssid);
|
||||
void onWifiNetworkRemoved(QString devIfaceName, QString ssid);
|
||||
void onWifiNetworkPropertyChange(NetworkManager::WirelessNetwork::Ptr net);
|
||||
void onWifiNetworkDeviceDisappear();
|
||||
|
||||
void onConnectionAdd(QString connectUuid, QString connectName, QString connectPath);
|
||||
void onConnectionRemove(QString);
|
||||
|
||||
void onDeviceAdd(QString deviceName);
|
||||
void onDeviceRemove(QString deviceName);
|
||||
void onDeviceNameUpdate(QString oldName, QString newName);
|
||||
private Q_SLOTS:
|
||||
void updateList();
|
||||
|
||||
Q_SIGNALS:
|
||||
void signalStrengthChange(QString deviceName, QString ssid, int strength);
|
||||
void secuTypeChange(QString deviceName, QString ssid, QString securityType);
|
||||
|
||||
void wirelessConnectionRemove(QString deviceName, QString ssid);
|
||||
void wirelessConnectionAdd(QString deviceName, QString ssid, QString uuid, QString dbusPath);
|
||||
void wirelessConnectionUpdate(QString deviceName, QString ssid, QString uuid, QString dbusPath, KySecuType connectSecuType);
|
||||
|
||||
void wifiNetworkUpdate(QString, QString, KyWirelessNetItem);
|
||||
void wifiNetworkAdd(QString deviceName, KyWirelessNetItem &item);
|
||||
void wifiNetworkRemove(QString deviceName, QString ssid);
|
||||
|
||||
void wirelessDeviceAdd(QString deviceName);
|
||||
void deviceRemove(QString deviceName);
|
||||
void wirelessDeviceNameUpdate(QString oldName, QString newName);
|
||||
|
||||
void updateWifiList(QString, QList<KyActivateItem>, QList<KyWirelessNetItem>);
|
||||
|
||||
private:
|
||||
QMap<QString, QList<KyWirelessNetItem>> m_WifiNetworkList;
|
||||
QTimer * m_updateTimer = nullptr;
|
||||
|
||||
QString getDeviceIFace(NetworkManager::WirelessNetwork::Ptr net);
|
||||
};
|
||||
|
||||
#endif // KYWIRELESSNETRESOURCE_H
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifndef KYLINNMINTERFACE_H
|
||||
#define KYLINNMINTERFACE_H
|
||||
|
||||
#include "libnm-base-kylin_global.h"
|
||||
#include <QObject>
|
||||
|
||||
class QWidget;
|
||||
enum PluginType {
|
||||
SIMPLE = 0, //锁屏 && 登录
|
||||
COMPLEX, //托盘
|
||||
};
|
||||
|
||||
class LIBNMBASEKYLIN_EXPORT Interface : public QObject{
|
||||
Q_OBJECT
|
||||
public:
|
||||
virtual ~Interface(){}
|
||||
virtual QWidget * pluginUi() = 0; // 插件主界面---setPluginType后调用
|
||||
virtual void setPluginType(PluginType type, bool useSwitch = true) = 0; // 设置插件类型
|
||||
virtual void setParentWidget(QWidget* widget) = 0;
|
||||
virtual void setWidgetVisable(bool) = 0;
|
||||
|
||||
Q_SIGNALS:
|
||||
void needShowVirtualKeyboard();
|
||||
};
|
||||
|
||||
#define Interface_iid "org.kylin.network"
|
||||
|
||||
Q_DECLARE_INTERFACE(Interface, Interface_iid)
|
||||
|
||||
#endif // KYLINNMINTERFACE_H
|
|
@ -0,0 +1,198 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifndef KYLINNETWORKMANAGER_H
|
||||
#define KYLINNETWORKMANAGER_H
|
||||
|
||||
#include <QObject>
|
||||
#include "libnm-base-kylin_global.h"
|
||||
|
||||
#include "depend/kylinnetworkresourcemanager.h"
|
||||
#include "depend/kylinactiveconnectresource.h"
|
||||
#include "depend/kylinnetworkdeviceresource.h"
|
||||
#include "depend/kylinconnectoperation.h"
|
||||
#include "depend/kylinwiredconnectoperation.h"
|
||||
#include "depend/kylinwirednetresource.h"
|
||||
#include "depend/kywirelessconnectoperation.h"
|
||||
#include "depend/kywirelessnetresource.h"
|
||||
#include "depend/kylinnetresource.h"
|
||||
#include "depend/kyapnetresource.h"
|
||||
#include "depend/kylingeneral.h"
|
||||
|
||||
class LIBNMBASEKYLIN_EXPORT KyNetworkManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit KyNetworkManager(QObject *parent = nullptr);
|
||||
~KyNetworkManager();
|
||||
|
||||
private:
|
||||
bool m_init = false;
|
||||
KyNetworkResourceManager *m_networkResource;
|
||||
KyActiveConnectResourse *m_activeConnectResource;
|
||||
KyNetworkDeviceResourse *m_deviceResource;
|
||||
KylinGeneralOpration *m_general;
|
||||
KyWiredConnectResourse *m_wiredConnectResourse;
|
||||
KyWirelessNetResource *m_wirelessNetResource;
|
||||
KyApNetResource *m_apNetResource;
|
||||
|
||||
void initConnect();
|
||||
|
||||
Q_SIGNALS:
|
||||
//activeConnection
|
||||
void wiredStateChange(QString deviceName, QString uuid, KyConnectState state);
|
||||
void wirelessStateChange(QString deviceName, QString ssid, QString uuid, KyConnectState state);
|
||||
|
||||
//device
|
||||
void deviceStateChange(QString deviceName, KyDeviceState newstate, KyDeviceState oldstate,
|
||||
NetworkManager::Device::StateChangeReason reason);
|
||||
void carrierChange(QString deviceName, bool pluged);
|
||||
void deviceRemove(QString deviceName);
|
||||
void deviceManagedChange(QString deviceName, bool managed);
|
||||
|
||||
//general
|
||||
void wifiEnabledChanged(bool);
|
||||
void wiredEnabledChanged(bool);
|
||||
void networkingEnabledChanged(bool);
|
||||
void connectStatusChanged(KyConnectStatus);
|
||||
|
||||
//wired
|
||||
void wiredConnectionAdd(QString devName, QString connectUuid, QString connectName, QString connectPath);
|
||||
void wiredConnectionUpdate(QString devName, QString connectUuid, QString connectName, QString connectPath);
|
||||
void connectionRemove(QString path);
|
||||
|
||||
void wiredDeviceAdd(QString deviceName);
|
||||
void wiredDeviceUpdate(QString oldDeviceName, QString newDeviceName);
|
||||
|
||||
//wireless
|
||||
void signalStrengthChange(QString deviceName, QString ssid, int strength);
|
||||
void secuTypeChange(QString deviceName, QString ssid, QString securityType);
|
||||
|
||||
void wirelessConnectionRemove(QString deviceName, QString ssid);
|
||||
void wirelessConnectionAdd(QString deviceName, QString ssid, QString uuid, QString dbusPath);
|
||||
void wirelessConnectionUpdate(QString deviceName, QString ssid, QString uuid, QString dbusPath, KySecuType connectSecuType);
|
||||
|
||||
void wifiNetworkUpdate(QString, QString, KyWirelessNetItem);
|
||||
void wifiNetworkAdd(QString deviceName, KyWirelessNetItem &item);
|
||||
void wifiNetworkRemove(QString deviceName, QString ssid);
|
||||
|
||||
void wirelessDeviceAdd(QString deviceName);
|
||||
void wirelessDeviceNameUpdate(QString oldName, QString newName);
|
||||
|
||||
void updateWifiList(QString, QList<KyActivateItem>, QList<KyWirelessNetItem>);
|
||||
|
||||
//移动热点
|
||||
void wirelessApConnectStateChange();
|
||||
|
||||
|
||||
|
||||
public:
|
||||
bool isInitFinished(){return m_init;}
|
||||
//activeConnection
|
||||
void getActiveConnectionList(QString deviceName,
|
||||
KyConnectionType connectionType, QList<KyActivateItem> &connectItemList);
|
||||
int getAcivateWifiSignal();
|
||||
|
||||
//device
|
||||
void getNetworkDeviceList(KyDeviceType deviceType, QStringList &networkDeviceList);
|
||||
bool getDeviceManaged(QString devName);
|
||||
|
||||
//general
|
||||
bool getWirelessEnabled();
|
||||
bool getWiredEnabled();
|
||||
bool getNetworkingEnabled();
|
||||
void getConnectStatus(KyConnectStatus &status);
|
||||
|
||||
//wired
|
||||
void getWiredList(QMap<QString,QList<KyWiredItem>> &map);
|
||||
//wireless
|
||||
void getWifiNetworkList(QString devName, QList<KyWirelessNetItem> &list);
|
||||
//移动热点
|
||||
void getApConnections(QList<KyApConnectItem> &apConnectItemList);
|
||||
|
||||
//详情页-->ipv4 + ipv6 + autoconnect
|
||||
void getConnectIpInfo(QString uuid, KyConnectSetting &connectSetting);
|
||||
|
||||
//详情页-->有线连接detail
|
||||
void getWiredConnectDetail(QString interface, QString uuid, KyDetailInfo &connectSetting);
|
||||
|
||||
//详情页-->无线连接detail
|
||||
void getWirelessConnectDetail(QString interface, QString ssid, QString uuid, KyDetailInfo &connectSetting);
|
||||
|
||||
//无线连接-->安全
|
||||
bool getNormalWifiConnectSecuInfo(QString &uuid, KyWpaPasswordInfo &info);
|
||||
bool getEnterPriseInfoTls(QString &uuid, KyEapMethodTlsInfo &info);
|
||||
bool getEnterPriseInfoPeap(QString &uuid, KyEapMethodPeapInfo &info);
|
||||
bool getEnterPriseInfoTtls(QString &uuid, KyEapMethodTtlsInfo &info);
|
||||
|
||||
//获取企业网类型
|
||||
bool getEnterpiseEapMethod(const QString &uuid, KyEapMethodType &type);
|
||||
|
||||
bool wiredConnectIsActived();
|
||||
bool wirelessConnectIsActived();
|
||||
|
||||
public Q_SLOTS:
|
||||
void kylinNetworkManagerInit();
|
||||
//general
|
||||
void onSetWirelessNetworkEnabled(bool enabled);
|
||||
void onSetNetworkingEnabled(bool enabled);
|
||||
void onSetWiredEnabled(bool enabled);
|
||||
void onSetDeviceManaged(QString devName, bool managed);
|
||||
void onSetWiredDeviceEnable(QString interface, bool enable);
|
||||
//有线无线公用
|
||||
void onDeleteConnect(const QString &connectUuid);
|
||||
void onActivateConnection(const QString connectUuid, const QString deviceName);
|
||||
void onDeactivateConnection(const QString &activeConnectUuid);
|
||||
//wireless
|
||||
//申请扫描
|
||||
void onRequestWirelessScan();
|
||||
|
||||
void onCreateWiredConnect(KyConnectSetting connectSettingsInfo);
|
||||
|
||||
//详情页
|
||||
//=======================连接操作====================
|
||||
//连接无本地配置的非企业网热点
|
||||
void onAddAndActivateNormalWifi(KyWirelessConnectSetting connSettingInfo, KySecuType type);
|
||||
//连接无本地配置的企业网热点
|
||||
void onAddAndActiveWirelessEnterPriseTlsConnect(KyEapMethodTlsInfo info,
|
||||
KyWirelessConnectSetting connSettingInfo);
|
||||
void onAddAndActiveWirelessEnterPrisePeapConnect(KyEapMethodPeapInfo info,
|
||||
KyWirelessConnectSetting connSettingInfo);
|
||||
void onAddAndActiveWirelessEnterPriseTtlsConnect(KyEapMethodTtlsInfo info,
|
||||
KyWirelessConnectSetting connSettingInfo);
|
||||
|
||||
//=====================新增配置操作====================
|
||||
//新增普通连接
|
||||
void onAddNormalConnect(const KyWirelessConnectSetting &connSettingInfo, KySecuType &type);
|
||||
//新增TLS连接
|
||||
void onAddTlsConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodTlsInfo &tlsinfo);
|
||||
//新增PEAP连接
|
||||
void onAddPeapConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodPeapInfo &peapInfo);
|
||||
//新增TTLS连接
|
||||
void onAddTtlsConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodTtlsInfo &ttlsInfo);
|
||||
|
||||
//=====================更新配置操作====================
|
||||
void onUpdateIpv4AndIpv6SettingInfo(const QString &uuid, const KyConnectSetting &connectSettingsInfo);
|
||||
//连接修改(安全改为个人/None)
|
||||
void onUpdateWirelessPersonalConnect(const QString &uuid, const KyWirelessConnectSetting &connSettingInfo, bool bPwdChange);
|
||||
//连接修改(安全改为改为企业)
|
||||
void onUpdateWirelessEnterPriseTlsConnect(const QString &uuid, const KyEapMethodTlsInfo &tlsinfo);
|
||||
void onUpdateWirelessEnterPrisePeapConnect(const QString &uuid, const KyEapMethodPeapInfo &peapInfo);
|
||||
void onUpdateWirelessEnterPriseTtlsConnect(const QString &uuid, const KyEapMethodTtlsInfo &ttlsInfo);
|
||||
};
|
||||
|
||||
#endif // KYLINNETWORKMANAGER_H
|
|
@ -0,0 +1,375 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#include "kylinnetworkmanager.h"
|
||||
|
||||
#define WAIT_US 1000
|
||||
|
||||
KyNetworkManager::KyNetworkManager(QObject *parent) : QObject(parent)
|
||||
{
|
||||
// kylinNetworkManagerInit();
|
||||
m_init = false;
|
||||
}
|
||||
|
||||
KyNetworkManager::~KyNetworkManager()
|
||||
{
|
||||
m_networkResource = nullptr;
|
||||
}
|
||||
|
||||
void KyNetworkManager::kylinNetworkManagerInit()
|
||||
{
|
||||
if (!m_init) {
|
||||
qDebug() << "kylinNetworkManagerInit";
|
||||
m_networkResource = KyNetworkResourceManager::getInstance();
|
||||
if (!m_networkResource->NetworkManagerIsInited()) {
|
||||
m_networkResource->onInitNetwork();
|
||||
}
|
||||
m_activeConnectResource = new KyActiveConnectResourse(this);
|
||||
m_deviceResource = new KyNetworkDeviceResourse(this);
|
||||
m_general = new KylinGeneralOpration(this);
|
||||
m_wiredConnectResourse = new KyWiredConnectResourse(this);
|
||||
m_wirelessNetResource = new KyWirelessNetResource(this);
|
||||
m_apNetResource = new KyApNetResource(this);
|
||||
|
||||
initConnect();
|
||||
}
|
||||
m_init = true;
|
||||
}
|
||||
|
||||
void KyNetworkManager::initConnect()
|
||||
{
|
||||
connect(m_activeConnectResource, &KyActiveConnectResourse::wiredStateChange,
|
||||
this, &KyNetworkManager::wiredStateChange);
|
||||
connect(m_activeConnectResource, &KyActiveConnectResourse::wirelessStateChange,
|
||||
this, &KyNetworkManager::wirelessStateChange);
|
||||
|
||||
connect(m_deviceResource, &KyNetworkDeviceResourse::carrierChange,
|
||||
this, &KyNetworkManager::carrierChange);
|
||||
connect(m_deviceResource, &KyNetworkDeviceResourse::deviceStateChange,
|
||||
this, &KyNetworkManager::deviceStateChange);
|
||||
connect(m_deviceResource, &KyNetworkDeviceResourse::deviceManagedChange,
|
||||
this, &KyNetworkManager::deviceManagedChange);
|
||||
|
||||
connect(m_general, &KylinGeneralOpration::connectStatusChanged,
|
||||
this, &KyNetworkManager::connectStatusChanged);
|
||||
connect(m_general, &KylinGeneralOpration::networkingEnabledChanged,
|
||||
this, &KyNetworkManager::networkingEnabledChanged);
|
||||
connect(m_general, &KylinGeneralOpration::wifiEnabledChanged,
|
||||
this, &KyNetworkManager::wifiEnabledChanged);
|
||||
connect(m_general, &KylinGeneralOpration::wiredEnabledChanged,
|
||||
this, &KyNetworkManager::wiredEnabledChanged);
|
||||
|
||||
connect(m_apNetResource, &KyApNetResource::wirelessApConnectStateChange,
|
||||
this, &KyNetworkManager::wirelessApConnectStateChange);
|
||||
|
||||
connect(m_wiredConnectResourse, &KyWiredConnectResourse::wiredConnectionAdd,
|
||||
this, &KyNetworkManager::wiredConnectionAdd);
|
||||
connect(m_wiredConnectResourse, &KyWiredConnectResourse::wiredConnectionUpdate,
|
||||
this, &KyNetworkManager::wiredConnectionUpdate);
|
||||
connect(m_wiredConnectResourse, &KyWiredConnectResourse::connectionRemove,
|
||||
this, &KyNetworkManager::connectionRemove);
|
||||
connect(m_wiredConnectResourse, &KyWiredConnectResourse::wiredDeviceAdd,
|
||||
this, &KyNetworkManager::wiredDeviceAdd);
|
||||
connect(m_wiredConnectResourse, &KyWiredConnectResourse::wiredDeviceUpdate,
|
||||
this, &KyNetworkManager::wiredDeviceUpdate);
|
||||
connect(m_wiredConnectResourse, &KyWiredConnectResourse::deviceRemove,
|
||||
this, &KyNetworkManager::deviceRemove);
|
||||
|
||||
|
||||
connect(m_wirelessNetResource, &KyWirelessNetResource::signalStrengthChange,
|
||||
this, &KyNetworkManager::signalStrengthChange);
|
||||
connect(m_wirelessNetResource, &KyWirelessNetResource::secuTypeChange,
|
||||
this, &KyNetworkManager::secuTypeChange);
|
||||
connect(m_wirelessNetResource, &KyWirelessNetResource::wirelessConnectionRemove,
|
||||
this, &KyNetworkManager::wirelessConnectionRemove);
|
||||
connect(m_wirelessNetResource, &KyWirelessNetResource::wirelessConnectionAdd,
|
||||
this, &KyNetworkManager::wirelessConnectionAdd);
|
||||
connect(m_wirelessNetResource, &KyWirelessNetResource::wirelessConnectionUpdate,
|
||||
this, &KyNetworkManager::wirelessConnectionUpdate);
|
||||
connect(m_wirelessNetResource, &KyWirelessNetResource::wifiNetworkUpdate,
|
||||
this, &KyNetworkManager::wifiNetworkUpdate);
|
||||
connect(m_wirelessNetResource, &KyWirelessNetResource::wifiNetworkAdd,
|
||||
this, &KyNetworkManager::wifiNetworkAdd);
|
||||
connect(m_wirelessNetResource, &KyWirelessNetResource::wifiNetworkRemove,
|
||||
this, &KyNetworkManager::wifiNetworkRemove);
|
||||
connect(m_wirelessNetResource, &KyWirelessNetResource::wirelessDeviceAdd,
|
||||
this, &KyNetworkManager::wirelessDeviceAdd);
|
||||
connect(m_wirelessNetResource, &KyWirelessNetResource::wirelessDeviceNameUpdate,
|
||||
this, &KyNetworkManager::wirelessDeviceNameUpdate);
|
||||
connect(m_wirelessNetResource, &KyWirelessNetResource::updateWifiList,
|
||||
this, &KyNetworkManager::updateWifiList);
|
||||
}
|
||||
|
||||
//同步方法
|
||||
//有线 无线 移动热点界面
|
||||
void KyNetworkManager::getActiveConnectionList(QString deviceName,
|
||||
KyConnectionType connectionType, QList<KyActivateItem> &connectItemList)
|
||||
{
|
||||
m_activeConnectResource->getActiveConnectionList(deviceName, connectionType, connectItemList);
|
||||
}
|
||||
|
||||
int KyNetworkManager::getAcivateWifiSignal()
|
||||
{
|
||||
return m_activeConnectResource->getAcivateWifiSignal();
|
||||
}
|
||||
|
||||
void KyNetworkManager::getNetworkDeviceList(KyDeviceType deviceType, QStringList &networkDeviceList)
|
||||
{
|
||||
m_deviceResource->getNetworkDeviceList(deviceType, networkDeviceList);
|
||||
}
|
||||
|
||||
bool KyNetworkManager::getDeviceManaged(QString devName)
|
||||
{
|
||||
return m_deviceResource->getDeviceManaged(devName);
|
||||
}
|
||||
|
||||
void KyNetworkManager::getConnectStatus(KyConnectStatus &connectType)
|
||||
{
|
||||
m_general->getConnectStatus(connectType);
|
||||
}
|
||||
|
||||
bool KyNetworkManager::getWirelessEnabled()
|
||||
{
|
||||
return m_general->getWirelessEnabled();
|
||||
}
|
||||
|
||||
bool KyNetworkManager::getWiredEnabled()
|
||||
{
|
||||
return m_general->getWiredEnabled();
|
||||
}
|
||||
|
||||
bool KyNetworkManager::getNetworkingEnabled()
|
||||
{
|
||||
return m_general->getNetworkingEnabled();
|
||||
}
|
||||
|
||||
void KyNetworkManager::getWiredList(QMap<QString,QList<KyWiredItem>> &map)
|
||||
{
|
||||
m_wiredConnectResourse->getWiredList(map);
|
||||
}
|
||||
|
||||
void KyNetworkManager::getWifiNetworkList(QString devName, QList<KyWirelessNetItem> &list)
|
||||
{
|
||||
m_wirelessNetResource->getWifiNetworkList(devName, list);
|
||||
}
|
||||
|
||||
void KyNetworkManager::getApConnections(QList<KyApConnectItem> &apConnectItemList)
|
||||
{
|
||||
m_apNetResource->getApConnections(apConnectItemList);
|
||||
}
|
||||
//详情页
|
||||
//共有ipv4 ipv6 包括autoconnect
|
||||
void KyNetworkManager::getConnectIpInfo(QString uuid, KyConnectSetting &connectSetting)
|
||||
{
|
||||
KyNetResource resource;
|
||||
resource.getConnectionSetting(uuid, connectSetting);
|
||||
}
|
||||
//详情页-->有线连接detail
|
||||
void KyNetworkManager::getWiredConnectDetail(QString interface, QString uuid, KyDetailInfo &connectSetting)
|
||||
{
|
||||
KyWiredConnectResourse resource;
|
||||
resource.getWiredConnectDetail(interface, uuid, connectSetting);
|
||||
}
|
||||
|
||||
//详情页-->无线连接detail
|
||||
void KyNetworkManager::getWirelessConnectDetail(QString interface, QString ssid, QString uuid, KyDetailInfo &connectSetting)
|
||||
{
|
||||
KyWirelessNetResource resource;
|
||||
resource.getWirelessConnectDetail(interface, ssid, uuid, connectSetting);
|
||||
}
|
||||
|
||||
//无线连接-->安全
|
||||
bool KyNetworkManager::getNormalWifiConnectSecuInfo(QString &uuid, KyWpaPasswordInfo &info)
|
||||
{
|
||||
KyWirelessNetResource resource;
|
||||
return resource.getNormalWifiConnectSecuInfo(uuid, info);
|
||||
}
|
||||
|
||||
bool KyNetworkManager::getEnterPriseInfoTls(QString &uuid, KyEapMethodTlsInfo &info)
|
||||
{
|
||||
KyWirelessNetResource resource;
|
||||
return resource.getEnterPriseInfoTls(uuid, info);
|
||||
}
|
||||
|
||||
bool KyNetworkManager::getEnterPriseInfoPeap(QString &uuid, KyEapMethodPeapInfo &info)
|
||||
{
|
||||
KyWirelessNetResource resource;
|
||||
return resource.getEnterPriseInfoPeap(uuid, info);
|
||||
}
|
||||
|
||||
bool KyNetworkManager::getEnterPriseInfoTtls(QString &uuid, KyEapMethodTtlsInfo &info)
|
||||
{
|
||||
KyWirelessNetResource resource;
|
||||
return resource.getEnterPriseInfoTtls(uuid, info);
|
||||
}
|
||||
|
||||
//获取企业网类型
|
||||
bool KyNetworkManager::getEnterpiseEapMethod(const QString &uuid, KyEapMethodType &type)
|
||||
{
|
||||
KyWirelessNetResource resource;
|
||||
return resource.getEnterpiseEapMethod(uuid, type);
|
||||
}
|
||||
|
||||
bool KyNetworkManager::wiredConnectIsActived()
|
||||
{
|
||||
return m_activeConnectResource->wiredConnectIsActived();
|
||||
}
|
||||
|
||||
bool KyNetworkManager::wirelessConnectIsActived()
|
||||
{
|
||||
return m_activeConnectResource->wirelessConnectIsActived();
|
||||
}
|
||||
|
||||
//异步槽
|
||||
void KyNetworkManager::onSetWirelessNetworkEnabled(bool enabled)
|
||||
{
|
||||
m_general->setWirelessNetworkEnabled(enabled);
|
||||
}
|
||||
|
||||
void KyNetworkManager::onSetNetworkingEnabled(bool enabled)
|
||||
{
|
||||
m_general->setNetworkingEnabled(enabled);
|
||||
}
|
||||
|
||||
void KyNetworkManager::onSetWiredEnabled(bool enabled)
|
||||
{
|
||||
m_general->setWiredEnabled(enabled);
|
||||
}
|
||||
|
||||
void KyNetworkManager::onSetDeviceManaged(QString devName, bool managed)
|
||||
{
|
||||
m_deviceResource->setDeviceManaged(devName, managed);
|
||||
}
|
||||
|
||||
void KyNetworkManager::onSetWiredDeviceEnable(QString devName, bool enable)
|
||||
{
|
||||
m_deviceResource->setDeviceManaged(devName, enable);
|
||||
}
|
||||
|
||||
void KyNetworkManager::onDeleteConnect(const QString &connectUuid)
|
||||
{
|
||||
KyConnectOperation operate;
|
||||
operate.deleteConnect(connectUuid);
|
||||
}
|
||||
|
||||
void KyNetworkManager::onActivateConnection(const QString connectUuid, const QString deviceName)
|
||||
{
|
||||
KyConnectOperation operate;
|
||||
operate.activateConnection(connectUuid, deviceName);
|
||||
}
|
||||
|
||||
void KyNetworkManager::onDeactivateConnection(const QString &activeConnectUuid)
|
||||
{
|
||||
KyConnectOperation operate;
|
||||
operate.deactivateConnection(activeConnectUuid);
|
||||
}
|
||||
|
||||
void KyNetworkManager::onCreateWiredConnect(KyConnectSetting connectSettingsInfo)
|
||||
{
|
||||
KyWiredConnectOperation operate;
|
||||
operate.createWiredConnect(connectSettingsInfo);
|
||||
}
|
||||
|
||||
//=====================申请无线扫描===================
|
||||
void KyNetworkManager::onRequestWirelessScan()
|
||||
{
|
||||
KyWirelessConnectOperation operate;
|
||||
operate.requestWirelessScan();
|
||||
}
|
||||
|
||||
//=======================连接操作====================
|
||||
//连接无本地配置的非企业网热点
|
||||
void KyNetworkManager::onAddAndActivateNormalWifi(KyWirelessConnectSetting connSettingInfo, KySecuType type)
|
||||
{
|
||||
KyWirelessConnectOperation operate;
|
||||
operate.addAndActiveWirelessConnect(connSettingInfo, type);
|
||||
}
|
||||
//连接无本地配置的企业网热点
|
||||
void KyNetworkManager::onAddAndActiveWirelessEnterPriseTlsConnect(KyEapMethodTlsInfo info,
|
||||
KyWirelessConnectSetting connSettingInfo)
|
||||
{
|
||||
KyWirelessConnectOperation operate;
|
||||
operate.addAndActiveWirelessEnterPriseTlsConnect(info, connSettingInfo);
|
||||
}
|
||||
void KyNetworkManager::onAddAndActiveWirelessEnterPrisePeapConnect(KyEapMethodPeapInfo info,
|
||||
KyWirelessConnectSetting connSettingInfo)
|
||||
{
|
||||
KyWirelessConnectOperation operate;
|
||||
operate.addAndActiveWirelessEnterPrisePeapConnect(info, connSettingInfo);
|
||||
}
|
||||
void KyNetworkManager::onAddAndActiveWirelessEnterPriseTtlsConnect(KyEapMethodTtlsInfo info,
|
||||
KyWirelessConnectSetting connSettingInfo)
|
||||
{
|
||||
KyWirelessConnectOperation operate;
|
||||
operate.addAndActiveWirelessEnterPriseTtlsConnect(info, connSettingInfo);
|
||||
}
|
||||
|
||||
//=====================新增配置操作====================
|
||||
//新增普通连接
|
||||
void KyNetworkManager::onAddNormalConnect(const KyWirelessConnectSetting &connSettingInfo, KySecuType &type)
|
||||
{
|
||||
KyWirelessConnectOperation operate;
|
||||
operate.addConnect(connSettingInfo, type);
|
||||
}
|
||||
//新增TLS连接
|
||||
void KyNetworkManager::onAddTlsConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodTlsInfo &tlsinfo)
|
||||
{
|
||||
KyWirelessConnectOperation operate;
|
||||
operate.addTlsConnect(connSettingInfo, tlsinfo);
|
||||
}
|
||||
//新增PEAP连接
|
||||
void KyNetworkManager::onAddPeapConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodPeapInfo &peapInfo)
|
||||
{
|
||||
KyWirelessConnectOperation operate;
|
||||
operate.addPeapConnect(connSettingInfo, peapInfo);
|
||||
}
|
||||
//新增TTLS连接
|
||||
void KyNetworkManager::onAddTtlsConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodTtlsInfo &ttlsInfo)
|
||||
{
|
||||
KyWirelessConnectOperation operate;
|
||||
operate.addTtlsConnect(connSettingInfo, ttlsInfo);
|
||||
}
|
||||
|
||||
//=====================更新配置操作====================
|
||||
void KyNetworkManager::onUpdateIpv4AndIpv6SettingInfo(const QString &uuid, const KyConnectSetting &connectSettingsInfo)
|
||||
{
|
||||
KyWirelessConnectOperation operate;
|
||||
operate.updateIpv4AndIpv6SettingInfo(uuid, connectSettingsInfo);
|
||||
}
|
||||
//连接修改(安全改为个人/None)
|
||||
void KyNetworkManager::onUpdateWirelessPersonalConnect(const QString &uuid,
|
||||
const KyWirelessConnectSetting &connSettingInfo, bool bPwdChange)
|
||||
{
|
||||
KyWirelessConnectOperation operate;
|
||||
operate.updateWirelessPersonalConnect(uuid, connSettingInfo, bPwdChange);
|
||||
}
|
||||
//连接修改(安全改为改为企业)
|
||||
void KyNetworkManager::onUpdateWirelessEnterPriseTlsConnect(const QString &uuid, const KyEapMethodTlsInfo &tlsinfo)
|
||||
{
|
||||
KyWirelessConnectOperation operate;
|
||||
operate.updateWirelessEnterPriseTlsConnect(uuid, tlsinfo);
|
||||
}
|
||||
void KyNetworkManager::onUpdateWirelessEnterPrisePeapConnect(const QString &uuid, const KyEapMethodPeapInfo &peapInfo)
|
||||
{
|
||||
KyWirelessConnectOperation operate;
|
||||
operate.updateWirelessEnterPrisePeapConnect(uuid, peapInfo);
|
||||
}
|
||||
void KyNetworkManager::onUpdateWirelessEnterPriseTtlsConnect(const QString &uuid, const KyEapMethodTtlsInfo &ttlsInfo)
|
||||
{
|
||||
KyWirelessConnectOperation operate;
|
||||
operate.updateWirelessEnterPriseTtlsConnect(uuid, ttlsInfo);
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
#QT -= gui
|
||||
#QT += core gui x11extras dbus KWindowSystem svg concurrent network
|
||||
QT += core dbus network
|
||||
|
||||
TARGET = kylin-nm-base
|
||||
TEMPLATE = lib
|
||||
DEFINES += LIBNMBASEKYLIN_LIBRARY
|
||||
|
||||
CONFIG += c++11 qt warn_on link_pkgconfig no_keywords
|
||||
#CONFIG += create_pc create_prl no_install_prl
|
||||
|
||||
|
||||
PKGCONFIG +=libnm gsettings-qt gtk+-3.0
|
||||
#PKGCONFIG += gio-2.0 glib-2.0 gio-unix-2.0 libnm libnma libsecret-1 gsettings-qt
|
||||
#INCLUDEPATH += /usr/include/dbus-1.0/dbu
|
||||
|
||||
INCLUDEPATH += /usr/include/KF5/NetworkManagerQt
|
||||
LIBS += -L/usr/lib/ -lKF5NetworkManagerQt
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
# any Qt feature that has been marked 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 it uses 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 += \
|
||||
depend/kyapnetresource.cpp \
|
||||
depend/kyenterpricesettinginfo.cpp \
|
||||
depend/kylinactiveconnectresource.cpp \
|
||||
depend/kylinconnectoperation.cpp \
|
||||
depend/kylinconnectsetting.cpp \
|
||||
depend/kylingeneral.cpp \
|
||||
depend/kylinnetresource.cpp \
|
||||
depend/kylinnetworkdeviceresource.cpp \
|
||||
depend/kylinnetworkmanagerutil.cpp \
|
||||
kylinnetworkmanger.cpp \
|
||||
depend/kylinnetworkresourcemanager.cpp \
|
||||
depend/kylinwiredconnectoperation.cpp \
|
||||
depend/kylinwirednetresource.cpp \
|
||||
depend/kywirelessconnectoperation.cpp \
|
||||
depend/kywirelessnetresource.cpp
|
||||
kylinnetworkmanger.cpp \
|
||||
|
||||
HEADERS += \
|
||||
libnm-base-kylin_global.h \
|
||||
kylin-nm-interface.h \
|
||||
kylinnetworkmanager.h \
|
||||
depend/kyapnetresource.h \
|
||||
depend/kyenterpricesettinginfo.h \
|
||||
depend/kylinactiveconnectresource.h \
|
||||
depend/kylinapconnectitem.h \
|
||||
depend/kylinconnectitem.h \
|
||||
depend/kylinconnectoperation.h \
|
||||
depend/kylinconnectsetting.h \
|
||||
depend/kylingeneral.h \
|
||||
depend/kylinnetresource.h \
|
||||
depend/kylinnetworkdeviceresource.h \
|
||||
depend/kylinnetworkmanagerutil.h \
|
||||
depend/kylinnetworkresourcemanager.h \
|
||||
depend/kylinnetworkresourcetype.h \
|
||||
depend/kylinwiredconnectoperation.h \
|
||||
depend/kylinwirednetresource.h \
|
||||
depend/kywirelessconnectoperation.h \
|
||||
depend/kywirelessnetitem.h \
|
||||
depend/kywirelessnetresource.h
|
||||
|
||||
DESTDIR += $$PWD
|
||||
# Default rules for deployment.
|
||||
unix {
|
||||
target.path = /usr/lib/
|
||||
|
||||
manager.path = /usr/include/kylin-nm
|
||||
manager.files = kylinnetworkmanager.h \
|
||||
libnm-base-kylin_global.h \
|
||||
kylin-nm-interface.h
|
||||
|
||||
depend.path = /usr/include/kylin-nm/depend
|
||||
depend.files = depend/*.h
|
||||
|
||||
# gschema.files = org.ukui.kylin-nm.switch.gschema.xml
|
||||
# gschema.path = /usr/share/glib-2.0/schemas/
|
||||
|
||||
|
||||
INSTALLS += manager \
|
||||
depend \
|
||||
gschema
|
||||
|
||||
# QMAKE_PKGCONFIG_NAME = kylin-nm-base
|
||||
# QMAKE_PKGCONFIG_DESCRIPTION = kylin-nm Header files
|
||||
# QMAKE_PKGCONFIG_VERSION = $$VERSION
|
||||
# QMAKE_PKGCONFIG_LIBDIR = $$target.path
|
||||
# QMAKE_PKGCONFIG_DESTDIR = pkgconfig
|
||||
# QMAKE_PKGCONFIG_INCDIR = $$INCLUDEPATH
|
||||
##/usr/include/kylin-nm /usr/include/KF5/NetworkManagerQt
|
||||
## QMAKE_PKGCONFIG_INCDIR += /usr/include/KF5/NetworkManagerQt
|
||||
# QMAKE_PKGCONFIG_CFLAGS += -I/usr/include/kylin-nm
|
||||
# QMAKE_PKGCONFIG_REQUIRES = gio-2.0 glib-2.0 libnm
|
||||
# QMAKE_INSTALL_DIR = /usr/share/pkgconfig/
|
||||
}
|
||||
!isEmpty(target.path): INSTALLS += target
|
||||
|
||||
DISTFILES += \
|
||||
org.ukui.kylin-nm.switch.gschema.xml
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (C) 2023, KylinSoft 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifndef LIBNMBASEKYLIN_GLOBAL_H
|
||||
#define LIBNMBASEKYLIN_GLOBAL_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#if defined(LIBNMBASEKYLIN_LIBRARY)
|
||||
# define LIBNMBASEKYLIN_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
# define LIBNMBASEKYLIN_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#endif // LIBNMBASEKYLIN_GLOBAL_H
|
|
@ -0,0 +1,13 @@
|
|||
prefix=/usr
|
||||
exec_prefix=${prefix}
|
||||
libdir=${prefix}/lib/
|
||||
includedir=${prefix}/include/KF5/NetworkManagerQt
|
||||
|
||||
|
||||
Name: kylin-nm-base
|
||||
Description: kylin-nm Header files
|
||||
Version: 1.0.0
|
||||
Libs: -L${libdir} -lkylin-nm-base
|
||||
Cflags: -I/usr/include/kylin-nm -I${includedir}
|
||||
Requires: gio-2.0 glib-2.0 libnm
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
TEMPLATE = subdirs
|
||||
|
||||
SUBDIRS += \
|
||||
libnm-base-kylin
|
|
@ -0,0 +1,20 @@
|
|||
.\" Man page for Kylin-nm
|
||||
.TH KYLIN-NM 1 "20 September 2019" "UKUI Desktop Environment"
|
||||
.\" Please adjust this date when revising the manpage.
|
||||
.\"
|
||||
.SH "NAME"
|
||||
kylin-nm \- The tool for the UKUI Desktop Environment
|
||||
.SH "SYNOPSIS"
|
||||
.B kylin-nm
|
||||
.SH "DESCRIPTION"
|
||||
The \fBkylin-nm\fR program is a part of the ukui-indicators, It provides network manager for the the UKUI Desktop Environment. Detect the system disk automatically, Can pop up and open the device.
|
||||
.PP
|
||||
This manual page documents the \fBkylin-nm\fR command.
|
||||
.P
|
||||
.SH "BUGS"
|
||||
.SS Should you encounter any bugs, they may be reported at:
|
||||
https://github.com/ukui/kylin-nm/issues
|
||||
.SH "AUTHORS"
|
||||
.SS This Man Page has been written for the UKUI Desktop Environment by:
|
||||
shine <shenghuang@ubuntukylin.com> (2019)
|
||||
.SH "SEE ALSO"
|
|
@ -0,0 +1,20 @@
|
|||
.\" Man page for kylin-nm-sysdbus
|
||||
.TH KYLIN-NM 1 "20 September 2019" "UKUI Desktop Environment"
|
||||
.\" Please adjust this date when revising the manpage.
|
||||
.\"
|
||||
.SH "NAME"
|
||||
kylin-nm \- The tool for the UKUI Desktop Environment
|
||||
.SH "SYNOPSIS"
|
||||
.B kylin-nm
|
||||
.SH "DESCRIPTION"
|
||||
The \fBkylin-nm\fR program is a part of the ukui-indicators, It provides network manager for the the UKUI Desktop Environment. Detect the system disk automatically, Can pop up and open the device.
|
||||
.PP
|
||||
This manual page documents the \fBkylin-nm\fR command.
|
||||
.P
|
||||
.SH "BUGS"
|
||||
.SS Should you encounter any bugs, they may be reported at:
|
||||
https://github.com/ukui/kylin-nm/issues
|
||||
.SH "AUTHORS"
|
||||
.SS This Man Page has been written for the UKUI Desktop Environment by:
|
||||
shine <shenghuang@ubuntukylin.com> (2019)
|
||||
.SH "SEE ALSO"
|
|
@ -0,0 +1,20 @@
|
|||
.\" Man page for kylin-vpn
|
||||
.TH KYLIN-NM 1 "20 September 2019" "UKUI Desktop Environment"
|
||||
.\" Please adjust this date when revising the manpage.
|
||||
.\"
|
||||
.SH "NAME"
|
||||
kylin-nm \- The tool for the UKUI Desktop Environment
|
||||
.SH "SYNOPSIS"
|
||||
.B kylin-nm
|
||||
.SH "DESCRIPTION"
|
||||
The \fBkylin-nm\fR program is a part of the ukui-indicators, It provides network manager for the the UKUI Desktop Environment. Detect the system disk automatically, Can pop up and open the device.
|
||||
.PP
|
||||
This manual page documents the \fBkylin-nm\fR command.
|
||||
.P
|
||||
.SH "BUGS"
|
||||
.SS Should you encounter any bugs, they may be reported at:
|
||||
https://github.com/ukui/kylin-nm/issues
|
||||
.SH "AUTHORS"
|
||||
.SS This Man Page has been written for the UKUI Desktop Environment by:
|
||||
shine <shenghuang@ubuntukylin.com> (2019)
|
||||
.SH "SEE ALSO"
|
|
@ -15,7 +15,12 @@ CONFIG += c++14 qt warn_on link_pkgconfig no_keywords
|
|||
#CONFIG += release
|
||||
|
||||
PKGCONFIG +=gio-2.0 glib-2.0 gio-unix-2.0 libnm libnma libsecret-1 gtk+-3.0 gsettings-qt libcap kysdk-qtwidgets kysdk-waylandhelper
|
||||
PKGCONFIG +=kysdk-sysinfo
|
||||
|
||||
exists(/usr/include/kysdk/kysdk-system/libkysysinfo.h) {
|
||||
# message("kysysinfo find")
|
||||
DEFINES += KY_SDK_SYSINFO
|
||||
PKGCONFIG += kysdk-sysinfo
|
||||
}
|
||||
|
||||
INCLUDEPATH += /usr/include/KF5/NetworkManagerQt
|
||||
|
||||
|
|
|
@ -32,7 +32,10 @@
|
|||
|
||||
#include "ukuistylehelper/ukuistylehelper.h"
|
||||
#include "windowmanager/windowmanager.h"
|
||||
|
||||
#ifdef KY_SDK_SYSINFO
|
||||
#include "kysdk/kysdk-system/libkysysinfo.h"
|
||||
#endif
|
||||
|
||||
#define MAINWINDOW_WIDTH 420
|
||||
#define MAINWINDOW_HEIGHT 476
|
||||
|
@ -193,6 +196,8 @@ void MainWindow::secondaryStart()
|
|||
*/
|
||||
void MainWindow::initPlatform()
|
||||
{
|
||||
#ifdef KY_SDK_SYSINFO
|
||||
|
||||
char* projectName = kdk_system_get_projectName();
|
||||
QString strProjectName(projectName);
|
||||
free(projectName);
|
||||
|
@ -206,6 +211,7 @@ void MainWindow::initPlatform()
|
|||
m_isShowInCenter = true;
|
||||
}
|
||||
qDebug() << "projectName" << projectName << m_isShowInCenter;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -165,7 +165,7 @@ int main(int argc, char *argv[])
|
|||
QString locale = QLocale::system().name();
|
||||
QTranslator trans_global;
|
||||
qDebug() << "QLocale " << QLocale();
|
||||
if (trans_global.load(QLocale(), "kylin-nm", "_", "/usr/share/kylin-nm/kylin-nm/"))
|
||||
if (trans_global.load(QLocale(), "kylin-nm", "_", "/usr/share/kylin-nm/"))
|
||||
{
|
||||
a.installTranslator(&trans_global);
|
||||
qDebug()<<"Translations load success";
|
||||
|
|
|
@ -15,7 +15,12 @@ CONFIG += c++14 qt warn_on link_pkgconfig no_keywords
|
|||
#CONFIG += release
|
||||
|
||||
PKGCONFIG +=gio-2.0 glib-2.0 gio-unix-2.0 libnm libnma libsecret-1 gtk+-3.0 gsettings-qt libcap kysdk-qtwidgets kysdk-waylandhelper
|
||||
PKGCONFIG +=kysdk-sysinfo
|
||||
|
||||
exists(/usr/include/kysdk/kysdk-system/libkysysinfo.h) {
|
||||
# message("kysysinfo find")
|
||||
DEFINES += KY_SDK_SYSINFO
|
||||
PKGCONFIG += kysdk-sysinfo
|
||||
}
|
||||
|
||||
INCLUDEPATH += /usr/include/KF5/NetworkManagerQt
|
||||
|
||||
|
@ -32,7 +37,7 @@ desktop.path = /etc/xdg/autostart/
|
|||
desktop.files = kylin-nm.desktop
|
||||
gschema.files = org.ukui.kylin-nm.switch.gschema.xml
|
||||
gschema.path = /usr/share/glib-2.0/schemas/
|
||||
qm_files.path = $${PREFIX}/share/kylin-nm/kylin-nm/
|
||||
qm_files.path = $${PREFIX}/share/kylin-nm/
|
||||
qm_files.files = translations/*.qm
|
||||
|
||||
INSTALLS += target \
|
||||
|
|
|
@ -12,7 +12,7 @@ PKGCONFIG +=gio-2.0 glib-2.0 gio-unix-2.0 libcap
|
|||
inst1.files += conf/com.kylin.network.qt.systemdbus.service
|
||||
inst1.path = /usr/share/dbus-1/system-services/
|
||||
inst2.files += conf/com.kylin.network.qt.systemdbus.conf
|
||||
inst2.path = /etc/dbus-1/system.d/
|
||||
inst2.path = /usr/share/dbus-1/system.d/
|
||||
target.source += $$TARGET
|
||||
target.path = /usr/bin
|
||||
|
||||
|
|
Loading…
Reference in New Issue