有线开关

This commit is contained in:
jzxc95 2022-10-09 09:30:12 +08:00
parent 9210e6c5c7
commit 3f7848a09a
15 changed files with 272 additions and 231 deletions

27
debian/changelog vendored
View File

@ -1,3 +1,30 @@
libkylin-nm-base (3.20.0.8) v101; urgency=medium
* BUG号:#100325 在系统内关闭有线网络的开关后,注销到登录界面,有线网络仍然可以连接
* 需求号:无
* 其他改动:无
* 影响域:登录界面有线开关
-- 赵世旭 <zhaoshixu@kylinos.cn> Thu, 22 Sep 2022 09:49:25 +0800
libkylin-nm-base (3.20.0.7) v101; urgency=medium
* BUG号: #113194 【登录选项】登录界面上网络界面,中英文界面切换异常
* 需求号:无
* 其他改动:无
* 影响域:翻译
-- zhaoshixu <zhaoshixu@kylinos.cn> Thu, 08 Sep 2022 10:01:36 +0800
libkylin-nm-base (3.20.0.6) v101; urgency=medium
* BUG号: #137313 【藏文】【登录】【锁屏】登录锁屏中网络连接部分未完全藏化
* 需求号:无
* 其他改动:无
* 影响域:密码错误弹窗藏文适配
-- zhaoshixu <zhaoshixu@kylinos.cn> Fri, 26 Aug 2022 11:02:23 +0800
libkylin-nm-base (3.20.0.5) v101; urgency=medium
* BUG号: #135530 【OOBE/登录/锁屏】【无线网络】无法加入wpa3类型的无线网络

3
debian/control vendored
View File

@ -20,7 +20,8 @@ Build-Depends: debhelper (>=9),
libcap-dev,
libnma-dev,
libsecret-1-dev,
libkysdk-qtwidgets-dev
libkysdk-qtwidgets-dev,
libgtk-3-dev
Standards-Version: 4.5.0
Rules-Requires-Root: no
Homepage: https://github.com/ukui/kylin-nm

View File

@ -7,7 +7,7 @@
*****************************************************************************/
static const unsigned char qt_resource_data[] = {
// /home/crush/project/kylin-nm-dev/kylin-keyring/authorize.svg
// /home/zhaoshixu/project/kylin-nm-dev/kylin-keyring/authorize.svg
0x0,0x0,0x21,0x86,
0x3c,
0x73,0x76,0x67,0x20,0x77,0x69,0x64,0x74,0x68,0x3d,0x22,0x34,0x38,0x22,0x20,0x68,
@ -547,7 +547,7 @@ static const unsigned char qt_resource_data[] = {
0x22,0x2f,0x3e,0xa,0x3c,0x2f,0x72,0x61,0x64,0x69,0x61,0x6c,0x47,0x72,0x61,0x64,
0x69,0x65,0x6e,0x74,0x3e,0xa,0x3c,0x2f,0x64,0x65,0x66,0x73,0x3e,0xa,0x3c,0x2f,
0x73,0x76,0x67,0x3e,0xa,
// /home/crush/project/kylin-nm-dev/kylin-keyring/translations/kylin-keyring_zh_CN.qm
// /home/zhaoshixu/project/kylin-nm-dev/kylin-keyring/translations/kylin-keyring_zh_CN.qm
0x0,0x0,0x3,0x47,
0x3c,
0xb8,0x64,0x18,0xca,0xef,0x9c,0x95,0xcd,0x21,0x1c,0xbf,0x60,0xa1,0xbd,0xdd,0x42,
@ -603,7 +603,7 @@ static const unsigned char qt_resource_data[] = {
0x0,0x6,0x0,0x0,0x0,0xa,0x75,0x73,0x65,0x72,0x41,0x6e,0x64,0x50,0x77,0x64,
0x7,0x0,0x0,0x0,0x10,0x4b,0x79,0x6c,0x69,0x6e,0x53,0x65,0x63,0x72,0x65,0x74,
0x41,0x67,0x65,0x6e,0x74,0x1,
// /home/crush/project/kylin-nm-dev/kylin-keyring/translations/kylin-keyring_bo_CN.qm
// /home/zhaoshixu/project/kylin-nm-dev/kylin-keyring/translations/kylin-keyring_bo_CN.qm
0x0,0x0,0x5,0x47,
0x3c,
0xb8,0x64,0x18,0xca,0xef,0x9c,0x95,0xcd,0x21,0x1c,0xbf,0x60,0xa1,0xbd,0xdd,0x42,

View File

@ -204,7 +204,8 @@ bool KyActiveConnectResourse::wiredConnectIsActived()
continue;
}
if (m_networkResourceInstance->isWiredConnect(activeConnectPtr->path())) {
QString path = activeConnectPtr->connection()->path();
if (m_networkResourceInstance->isWiredConnect(path)) {
continue;
}

View File

@ -1,9 +1,7 @@
#include "kylingeneral.h"
#include "kylinnetworkdeviceresource.h"
#include "kylinactiveconnectresource.h"
const QByteArray GSETTINGS_SCHEMA = "org.ukui.kylin-nm.switch";
const QString KEY_WIRED_SWITCH = "wiredswitch";
#include "kylinnetworkmanagerutil.h"
KylinGeneralOpration::KylinGeneralOpration(QObject *parent) : QObject(parent)
{
@ -17,24 +15,13 @@ KylinGeneralOpration::KylinGeneralOpration(QObject *parent) : QObject(parent)
this, &KylinGeneralOpration::updateConnectStatus);
connect(m_networkResourceInstance, &KyNetworkResourceManager::connectivityChanged,
this, &KylinGeneralOpration::updateConnectStatus);
if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA)) {
gsettings = new QGSettings(GSETTINGS_SCHEMA);
if (gsettings->keys().contains(KEY_WIRED_SWITCH)) {
connect(gsettings, &QGSettings::changed, [&](QString key){
if (key == KEY_WIRED_SWITCH) {
setWiredEnabled(gsettings->get(key).toBool());
}
});
}
}
connect(m_networkResourceInstance, &KyNetworkResourceManager::wiredEnabledChanged,
this, &KylinGeneralOpration::wiredEnabledChanged);
}
KylinGeneralOpration::~KylinGeneralOpration()
{
m_networkResourceInstance = nullptr;
delete gsettings;
gsettings = nullptr;
}
void KylinGeneralOpration::getConnectStatus(KyConnectStatus &status)
@ -106,39 +93,10 @@ void KylinGeneralOpration::setNetworkingEnabled(bool enabled)
void KylinGeneralOpration::setWiredEnabled(bool enabled)
{
KyNetworkDeviceResourse devResource;
QStringList devList;
devResource.getNetworkDeviceList(DEVICE_TYPE_ETHERNET, devList);
if (!enabled) {
for (int i = 0; i < devList.size(); ++i) {
devResource.closeWiredNetworkWithDevice(devList.at(i));
}
} else {
QMap<QString, bool> stateMap;
devResource.getWiredDeviceEnableState(stateMap);
for (int i = 0; i < devList.size(); ++i) {
if (stateMap.contains(devList.at(i))
&& !stateMap[devList.at(i)]) {
//do nothing
} else {
qDebug() << "openWiredNetworkWithDevice" << devList.at(i);
devResource.openWiredNetworkWithDevice(devList.at(i));
}
}
}
updateGsetting(enabled);
setWiredEnabledByGDbus(enabled);
}
void KylinGeneralOpration::updateGsetting(bool enable)
bool KylinGeneralOpration::getWiredEnabled()
{
if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA)) {
QGSettings *gsettings = new QGSettings(GSETTINGS_SCHEMA);
if (gsettings->keys().contains(KEY_WIRED_SWITCH)) {
if (enable != gsettings->get(KEY_WIRED_SWITCH).toBool()) {
qDebug() << "updateGsetting set " << enable;
gsettings->set(KEY_WIRED_SWITCH, enable);
}
}
}
return getWiredEnabledByGDbus();
}

View File

@ -2,7 +2,6 @@
#define KYLINGENERAL_H
#include <QObject>
#include <QGSettings/QGSettings>
#include "kylinnetworkresourcemanager.h"
enum KyConnectStatus {
@ -25,10 +24,12 @@ public:
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:
@ -36,7 +37,6 @@ private Q_SLOTS:
private:
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
QGSettings *gsettings;
KyConnectStatus m_status = NOT_CONNECTED;
void updateGsetting(bool);

View File

@ -14,6 +14,8 @@ KyNetworkDeviceResourse::KyNetworkDeviceResourse(QObject *parent) : QObject(pare
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,
@ -102,121 +104,6 @@ void KyNetworkDeviceResourse::getHardwareInfo(QString ifaceName, QString &hardAd
}
}
void KyNetworkDeviceResourse::setWiredDeviceEnable(const QString& devName, bool enable)
{
saveDeviceEnableState(devName, enable);
KyNetworkDeviceResourse deviceResource;
if (enable) {
deviceResource.openWiredNetworkWithDevice(devName);
} else {
deviceResource.closeWiredNetworkWithDevice(devName);
}
Q_EMIT wiredDeviceEnableChange(devName, enable);
}
void KyNetworkDeviceResourse::getWiredDeviceEnableState(QMap<QString, bool> &map)
{
getDeviceEnableState(map);
}
//用于有线开关回连处理 关闭调用
void KyNetworkDeviceResourse::saveActiveConnection(QString &deviceName, QString &connectUuid)
{
QSettings *p_settings = new QSettings(WIRED_NETWORK_STATE_CONF_FILE, QSettings::IniFormat);
QString settingValue = p_settings->value(deviceName).toString();
if (settingValue.isEmpty()) {
p_settings->setValue(deviceName, connectUuid);
p_settings->sync();
}
delete p_settings;
p_settings = nullptr;
return;
}
//用于有线开关回连处理 开启调用
void KyNetworkDeviceResourse::getActiveConnection(QString &deviceName, QString &connectUuid)
{
QSettings *p_settings = new QSettings(WIRED_NETWORK_STATE_CONF_FILE, QSettings::IniFormat);
connectUuid = p_settings->value(deviceName).toString();
p_settings->remove(deviceName);
delete p_settings;
p_settings = nullptr;
return;
}
//用于有线开关回连处理 关闭调用
int KyNetworkDeviceResourse::closeWiredNetworkWithDevice(QString deviceName)
{
NetworkManager::Device::Ptr wiredDevicePtr =
m_networkResourceInstance->findDeviceByName(deviceName);
if (wiredDevicePtr.isNull()) {
qWarning()<<"[KyWiredConnectOperation]"<<"the network device" << deviceName <<"is not exist.";
return -ENXIO;
}
if (NetworkManager::Device::Type::Ethernet != wiredDevicePtr->type()) {
qWarning()<<"[KyWiredConnectOperation]"<<"the device type"
<< wiredDevicePtr->type() <<"is not Ethernet.";
return -EINVAL;
}
NetworkManager::ActiveConnection::Ptr activeConnectPtr = wiredDevicePtr->activeConnection();
if (nullptr != activeConnectPtr) {
QString activeConnectUuid = activeConnectPtr->uuid();
if (!activeConnectUuid.isEmpty()) {
qDebug()<<"[KyWiredConnectOperation]" <<"close wired network save connection uuid"
<< activeConnectUuid <<"device name " << deviceName;
saveActiveConnection(deviceName, activeConnectUuid);
}
}
wiredDevicePtr->disconnectInterface();
return 0;
}
//用于有线开关回连处理 开启调用
int KyNetworkDeviceResourse::openWiredNetworkWithDevice(QString deviceName)
{
NetworkManager::Device::Ptr wiredDevicePtr =
m_networkResourceInstance->findDeviceByName(deviceName);
if (wiredDevicePtr.isNull() || !wiredDevicePtr->isValid()) {
qWarning()<<"[KyWiredConnectOperation]"<<"the network device" << deviceName <<"is not exist.";
return -ENXIO;
}
if (NetworkManager::Device::Type::Ethernet != wiredDevicePtr->type()) {
qWarning()<<"[KyWiredConnectOperation]"<<"the device type"
<< wiredDevicePtr->type() <<"is not Ethernet.";
return -EINVAL;
}
NetworkManager::WiredDevice *p_wiredDevice =
qobject_cast<NetworkManager::WiredDevice *>(wiredDevicePtr.data());
if (p_wiredDevice->carrier()) {
QString connectUuid;
getActiveConnection(deviceName, connectUuid);
if (!connectUuid.isEmpty()) {
KyConnectOperation operate;
operate.activateConnection(connectUuid, deviceName);
}
}
return 0;
}
KyDeviceState KyNetworkDeviceResourse::getDeviceState(QString deviceName)
{
NetworkManager::Device::Ptr connectDevice =
@ -325,3 +212,29 @@ bool KyNetworkDeviceResourse::wirelessDeviceIsExist(const QString devName)
return list.contains(devName);
}
void KyNetworkDeviceResourse::setDeviceManaged(QString devName, bool managed)
{
QString dbusPath;
NetworkManager::Device::Ptr connectDevice =
m_networkResourceInstance->findDeviceByName(devName);
if (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->isValid()) {
return connectDevice->managed();
} else {
qWarning()<<"[KyNetworkDeviceResourse] can not find device " << deviceName;
return false;
}
}

View File

@ -27,12 +27,8 @@ public:
bool wiredDeviceIsCarriered(QString deviceName);
bool wirelessDeviceIsExist(const QString devName);
//设置单个有线设备开关
void setWiredDeviceEnable(const QString& devName, bool enable);
void getWiredDeviceEnableState(QMap<QString, bool> &map);
int closeWiredNetworkWithDevice(QString deviceName);
int openWiredNetworkWithDevice(QString deviceName);
void setDeviceManaged(QString devName, bool managed);
bool getDeviceManaged(QString devName);
private:
void getActiveConnection(QString &deviceName, QString &connectUuid);
@ -44,6 +40,7 @@ Q_SIGNALS:
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);

View File

@ -1,15 +1,18 @@
#include "kylinnetworkmanagerutil.h"
#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 getConnectTypeByDbus(QString connectPath)
{
QString connectType = "";
if (connectPath.isEmpty()) {
qWarning() << LOG_FLAG << "connect path is empty, so can not get connect type";
return connectType;
@ -94,45 +97,127 @@ QString enumToQstring(NetworkManager::AccessPoint::Capabilities apCapability,
return out;
}
void saveDeviceEnableState(QString deviceName, bool enable)
void setWiredEnabledByGDbus(bool enabled)
{
QSettings * m_settings = new QSettings(CONFIG_FILE_PATH, QSettings::IniFormat);
m_settings->beginGroup("CARDEABLE");
m_settings->setValue(deviceName, enable);
m_settings->endGroup();
m_settings->sync();
delete m_settings;
m_settings = nullptr;
}
GDBusProxy *props_proxy;
GVariant *ret = NULL;
GError *error = NULL;
void getDeviceEnableState(QMap<QString, bool> &map)
{
map.clear();
if (!QFile::exists(CONFIG_FILE_PATH)) {
qDebug() << "CONFIG_FILE_PATH not exist";
return;
/* 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);
}
KyNetworkDeviceResourse kdr;
QStringList wiredDevList;
wiredDevList.clear();
QSettings * m_settings = new QSettings(CONFIG_FILE_PATH, QSettings::IniFormat);
m_settings->beginGroup("CARDEABLE");
kdr.getNetworkDeviceList(DEVICE_TYPE_ETHERNET, wiredDevList);
if (!wiredDevList.isEmpty()) {
for (int i = 0; i < wiredDevList.size(); ++i) {
if (!m_settings->contains(wiredDevList.at(i))) {
saveDeviceEnableState(wiredDevList.at(i),true);
}
bool enable = m_settings->value(wiredDevList.at(i), true).toBool();
map.insert(wiredDevList.at(i), enable);
}
}
m_settings->endGroup();
delete m_settings;
m_settings = nullptr;
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);
}

View File

@ -18,12 +18,13 @@
#define KEY_CONNECT_TYPE "type"
#define ETHERNET_TYPE "802-3-ethernet"
QString getConnectTypeByDbus(QString &connectPath);
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();
void saveDeviceEnableState(QString deviceName, bool enable);
void getDeviceEnableState(QMap<QString, bool> &map);
#endif // KYLINUTIL_H

View File

@ -104,6 +104,11 @@ void KyNetworkResourceManager::onInitNetwork()
QString("org.freedesktop.DBus"),
QString("NameOwnerChanged"), this, SLOT(onServiceAppear(QString,QString,QString)));
QDBusConnection::systemBus().connect(QString("org.freedesktop.NetworkManager"),
QString("/org/freedesktop/NetworkManager"),
QString("org.freedesktop.NetworkManager"),
QString("PropertiesChanged"), this, SLOT(onPropertiesChanged(QVariantMap)));
m_initFinished = true;
}
@ -234,6 +239,7 @@ void KyNetworkResourceManager::addDevice(NetworkManager::Device::Ptr device)
connect(device.data(), &NetworkManager::Device::activeConnectionChanged, this, &KyNetworkResourceManager::onDeviceActiveChange);
connect(device.data(), &NetworkManager::Device::interfaceNameChanged, this, &KyNetworkResourceManager::onDeviceUpdated);
connect(device.data(), &NetworkManager::Device::managedChanged, this, &KyNetworkResourceManager::onDeviceManagedChange);
switch (device->type())
{
@ -385,10 +391,9 @@ NetworkManager::Device::Ptr KyNetworkResourceManager::findDeviceByUni(QString co
return nullptr;
}
NetworkManager::Device::Ptr KyNetworkResourceManager::findDeviceByName(QString const &interfaceName)
NetworkManager::Device::Ptr KyNetworkResourceManager::findDeviceByName(QString interfaceName)
{
NetworkManager::Device::Ptr devicePtr = nullptr;
if (interfaceName.isEmpty()) {
return nullptr;
}
@ -593,6 +598,19 @@ void KyNetworkResourceManager::requestScan(NetworkManager::WirelessDevice *p_wir
return;
}
void KyNetworkResourceManager::onPropertiesChanged(QVariantMap qvm)
{
for(QString keyStr : qvm.keys()) {
//收到wifi开关打开或关闭的信号后进行处理
if (keyStr == "WiredEnabled") {
bool wiredEnable = qvm.value("WiredEnabled").toBool();
qDebug() << "wiredEnabledChanged" << wiredEnable;
Q_EMIT wiredEnabledChanged(wiredEnable);
}
}
}
void KyNetworkResourceManager::onConnectionUpdated()
{
NetworkManager::Connection *connectPtr =
@ -750,6 +768,19 @@ void KyNetworkResourceManager::onDeviceUpdated()
updateDeviceName(p_device);
}
void KyNetworkResourceManager::onDeviceManagedChange()
{
NetworkManager::Device *p_device = qobject_cast<NetworkManager::Device *>(sender());
if (nullptr == p_device) {
return;
}
QString deviceName = p_device->interfaceName();
bool managed = p_device->managed();
Q_EMIT deviceManagedChange(deviceName, managed);
}
void KyNetworkResourceManager::onDeviceCarrierChange(bool pluged)
{
NetworkManager::WiredDevice * networkDevice
@ -941,7 +972,6 @@ void KyNetworkResourceManager::onDeviceAdded(QString const & uni)
} else if (DEVICE_TYPE_ETHERNET == (KyDeviceType)networkDevicePtr->type()
&& !networkDevicePtr->udi().startsWith(VIRTURAL_DEVICE_PATH)) {
Q_EMIT wiredDeviceAdd(networkDevicePtr->interfaceName());
saveDeviceEnableState(networkDevicePtr->interfaceName(), true);
} else {
Q_EMIT deviceAdd(networkDevicePtr->interfaceName(), (KyDeviceType)networkDevicePtr->type());
}

View File

@ -66,7 +66,7 @@ public:
NetworkManager::Connection::Ptr findConnectByUuid(const QString uuid);
NetworkManager::Device::Ptr findDeviceByUni(QString const &deviceUni);
NetworkManager::Device::Ptr findDeviceByName(QString const &interfaceName);
NetworkManager::Device::Ptr findDeviceByName(QString interfaceName);
NetworkManager::WirelessNetwork::Ptr findWifiNetwork(QString const &ssid, QString const &deviceUni);
@ -125,6 +125,7 @@ private:
private Q_SLOTS:
void onServiceAppear(QString, QString, QString);
void onPropertiesChanged(QVariantMap qvm);
Q_SIGNALS:
@ -147,6 +148,7 @@ Q_SIGNALS:
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);
@ -180,6 +182,7 @@ Q_SIGNALS:
//general
void connectivityChanged(KyConnectivity connectivity);
void wifiEnabledChanged(bool);
void wiredEnabledChanged(bool);
void networkingEnabledChanged(bool);
void primaryConnectionTypeChanged(KyConnectionType type);
@ -213,6 +216,7 @@ public Q_SLOTS:
void onDeviceAdded(QString const & uni);
void onDeviceRemoved(QString const & uni);
void onDeviceUpdated();
void onDeviceManagedChange();
//active connection notifier
void onActiveConnectionAdded(QString const & path);

View File

@ -45,9 +45,11 @@ Q_SIGNALS:
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);
@ -90,9 +92,11 @@ public:
//device
void getNetworkDeviceList(KyDeviceType deviceType, QStringList &networkDeviceList);
bool getDeviceManaged(QString devName);
//general
bool getWirelessEnabled();
bool getWiredEnabled();
bool getNetworkingEnabled();
void getConnectStatus(KyConnectStatus &status);
@ -130,13 +134,12 @@ public Q_SLOTS:
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);
//wired 单设备启用禁用
void onSetWiredDeviceEnable(const QString &interface, bool enable);
//wireless
//申请扫描
void onRequestWirelessScan();

View File

@ -44,6 +44,8 @@ void KyNetworkManager::initConnect()
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);
@ -51,6 +53,8 @@ void KyNetworkManager::initConnect()
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);
@ -111,6 +115,11 @@ void KyNetworkManager::getNetworkDeviceList(KyDeviceType deviceType, QStringList
m_deviceResource->getNetworkDeviceList(deviceType, networkDeviceList);
}
bool KyNetworkManager::getDeviceManaged(QString devName)
{
return m_deviceResource->getDeviceManaged(devName);
}
void KyNetworkManager::getConnectStatus(KyConnectStatus &connectType)
{
m_general->getConnectStatus(connectType);
@ -121,6 +130,11 @@ bool KyNetworkManager::getWirelessEnabled()
return m_general->getWirelessEnabled();
}
bool KyNetworkManager::getWiredEnabled()
{
return m_general->getWiredEnabled();
}
bool KyNetworkManager::getNetworkingEnabled()
{
return m_general->getNetworkingEnabled();
@ -219,6 +233,16 @@ 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;
@ -237,11 +261,6 @@ void KyNetworkManager::onDeactivateConnection(const QString &activeConnectUuid)
operate.deactivateConnection(activeConnectUuid);
}
void KyNetworkManager::onSetWiredDeviceEnable(const QString &interface, bool enable)
{
m_deviceResource->setWiredDeviceEnable(interface, enable);
}
void KyNetworkManager::onCreateWiredConnect(KyConnectSetting connectSettingsInfo)
{
KyWiredConnectOperation operate;

View File

@ -9,8 +9,10 @@ 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
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/KF5/NetworkManagerQt
INCLUDEPATH += /usr/include/dbus-1.0/dbus
LIBS += -L/usr/lib/ -lKF5NetworkManagerQt
# The following define makes your compiler emit warnings if you use