Merge branch 'dbus-interface' of http://gitlab2.kylin.com/kylin-desktop/kylin-nm into 0922

0922 pull
This commit is contained in:
ksn 2021-09-22 15:45:07 +08:00
commit 3a276a7dee
11 changed files with 57 additions and 38 deletions

View File

@ -39,6 +39,7 @@ void KyConnectOperation::ipv4SettingSet(
const KyConnectSetting &connectSettingsInfo)
{
ipv4Setting->setInitialized(true);
ipv4Setting->setDns(connectSettingsInfo.m_ipv4Dns);
if (CONFIG_IP_DHCP == connectSettingsInfo.m_ipv4ConfigIpType) {
ipv4Setting->setMethod(NetworkManager::Ipv4Setting::Automatic);
@ -46,14 +47,7 @@ void KyConnectOperation::ipv4SettingSet(
} else {
ipv4Setting->setMethod(NetworkManager::Ipv4Setting::Manual);
}
if (!connectSettingsInfo.m_ipv4Dns.empty()) {
ipv4Setting->setDns(connectSettingsInfo.m_ipv4Dns);
}
if (!connectSettingsInfo.m_ipv4Address.empty()) {
ipv4Setting->setAddresses(connectSettingsInfo.m_ipv4Address);
}
ipv4Setting->setAddresses(connectSettingsInfo.m_ipv4Address);
return;
}
@ -62,6 +56,7 @@ void KyConnectOperation::ipv6SettingSet(
const KyConnectSetting &connectSettingsInfo)
{
ipv6Setting->setInitialized(true);
ipv6Setting->setDns(connectSettingsInfo.m_ipv6Dns);
if (CONFIG_IP_DHCP == connectSettingsInfo.m_ipv6ConfigIpType) {
ipv6Setting->setMethod(NetworkManager::Ipv6Setting::Automatic);
@ -70,15 +65,7 @@ void KyConnectOperation::ipv6SettingSet(
}
ipv6Setting->setMethod(NetworkManager::Ipv6Setting::Manual);
if (!connectSettingsInfo.m_ipv6Dns.empty()) {
ipv6Setting->setDns(connectSettingsInfo.m_ipv6Dns);
}
if (!connectSettingsInfo.m_ipv6Address.empty()) {
ipv6Setting->setAddresses(connectSettingsInfo.m_ipv6Address);
}
ipv6Setting->setAddresses(connectSettingsInfo.m_ipv6Address);
return ;
}

View File

@ -109,6 +109,7 @@ 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();

View File

@ -82,6 +82,9 @@ void KyNetworkDeviceResourse::getHardwareInfo(QString ifaceName, QString &hardAd
if (nullptr == connectDevice || !connectDevice->isValid()) {
qWarning()<<"[KyNetworkDeviceResourse]"<<"get hardware info failed, the device" << ifaceName << "is not existed";
hardAddress.clear();
bandWith = 0;
return;
}
switch (connectDevice->type()) {

View File

@ -63,7 +63,11 @@ void DbusAdaptor::setWiredSwitchEnable(bool enable)
//todo mainwindow调用backend 对开关 打开/关闭
if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA_KYLIN_NM)) {
QGSettings *gsetting = new QGSettings(GSETTINGS_SCHEMA_KYLIN_NM);
gsetting->set(KEY_WIRED_SWITCH, enable);
if (gsetting->get(KEY_WIRED_SWITCH).toBool() != enable) {
gsetting->set(KEY_WIRED_SWITCH, enable);
}
delete gsetting;
gsetting = nullptr;
} else {
qDebug()<<"isSchemaInstalled false";
}
@ -75,7 +79,9 @@ void DbusAdaptor::setWirelessSwitchEnable(bool enable)
//todo mainwindow调用backend 对开关 打开/关闭
if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA_KYLIN_NM)) {
QGSettings *gsetting = new QGSettings(GSETTINGS_SCHEMA_KYLIN_NM);
gsetting->set(KEY_WIRELESS_SWITCH, enable);
if (gsetting->get(KEY_WIRELESS_SWITCH).toBool() != enable) {
gsetting->set(KEY_WIRELESS_SWITCH, enable);
}
delete gsetting;
gsetting = nullptr;
} else {
@ -151,6 +157,7 @@ void DbusAdaptor::activateConnect(int type, QString devName, QString ssid)
void DbusAdaptor::deActivateConnect(int type, QString devName, QString ssid)
{
if (type == WIRED) {
qDebug() << "deactivateWired";
parent()->deactivateWired(devName,ssid);
} else if (type == WIRELESS) {
parent()->deactivateWireless(devName,ssid);

View File

@ -43,8 +43,8 @@ void CreatNetPage::initUI()
m_detailLayout->addRow(m_dnsLabel,firstDnsEdit);
m_detailLayout->addRow(m_secDnsLabel,secondDnsEdit);
ipv4ConfigCombox->addItem(tr("Auto(DHCP)")); //"自动(DHCP)"
ipv4ConfigCombox->addItem(tr("Manual")); //"手动"
ipv4ConfigCombox->addItem(tr("Auto(DHCP)"), AUTO_CONFIG); //"自动(DHCP)"
ipv4ConfigCombox->addItem(tr("Manual"), MANUAL_CONFIG); //"手动"
// IP的正则格式限制

View File

@ -114,6 +114,13 @@ bool Ipv4Page::checkIsChanged(const ConInfo info, KyConnectSetting &setting)
if (info.ipv4ConfigType != CONFIG_IP_DHCP) {
qDebug() << "ipv4ConfigType change to Auto";
setting.setIpConfigType(IPADDRESS_V4, CONFIG_IP_DHCP);
QString ipv4address("");
QString netMask("");
QString gateWay("");
QStringList dnsList;
dnsList.empty();
qDebug() << ipv4address << netMask << gateWay;
setting.ipv4AddressConstruct(ipv4address, netMask, gateWay, dnsList);
isChanged = true;
}
} else {

View File

@ -43,6 +43,12 @@ bool Ipv6Page::checkIsChanged(const ConInfo info, KyConnectSetting &setting)
if (info.ipv6ConfigType != CONFIG_IP_DHCP) {
qDebug() << "ipv6ConfigType change to Auto";
setting.setIpConfigType(IPADDRESS_V6, CONFIG_IP_DHCP);
QString ipv6address("");
QString prefix("");
QString gateWay("");
QStringList dnsList;
dnsList.empty();
setting.ipv6AddressConstruct(ipv6address, prefix, gateWay, dnsList);
isChanged = true;
}
} else {

View File

@ -656,10 +656,12 @@ bool NetDetail::createWiredConnect()
KyWirelessConnectSetting connetSetting;
connetSetting.setIfaceName(m_deviceName);
createNetPage->constructIpv4Info(connetSetting);
if (checkIpv4Conflict(connetSetting.m_ipv4Address.at(0).ip().toString())) {
qDebug() << "ipv4 conflict";
//todo desktop notify
return false;
if (connetSetting.m_ipv4ConfigIpType != CONFIG_IP_DHCP) {
if (checkIpv4Conflict(connetSetting.m_ipv4Address.at(0).ip().toString())) {
qDebug() << "ipv4 conflict";
//todo desktop notify
return false;
}
}
m_wiredConnOperation->createWiredConnect(connetSetting);
return true;

View File

@ -163,6 +163,8 @@ void MainWindow::initDbusConnnect()
connect(m_wlanWidget, &WlanPage::activateFailed, this, &MainWindow::activateFailed);
connect(m_wlanWidget, &WlanPage::deactivateFailed, this, &MainWindow::deactivateFailed);
connect(m_lanWidget, &LanPage::activateFailed, this, &MainWindow::activateFailed);
connect(m_lanWidget, &LanPage::deactivateFailed, this, &MainWindow::deactivateFailed);
connect(m_lanWidget, &LanPage::lanAdd, this, &MainWindow::lanAdd);
connect(m_lanWidget, &LanPage::lanRemove, this, &MainWindow::lanRemove);

View File

@ -511,7 +511,7 @@ void LanPage::getWiredList(QMap<QString, QVector<QStringList> > &map)
m_connectResourse->getConnectionList(deviceName, NetworkManager::ConnectionSettings::Wired, deactivedList); //未激活列表的显示
if (!deactivedList.isEmpty()) {
for (int i = 0; i < deactivedList.size(); i++) {
vector.append(QStringList()<<deactivedList.at(i)->m_connectName<<deactivedList.at(i)->m_connectUuid);
vector.append(QStringList()<<deactivedList.at(i)->m_connectName<<deactivedList.at(i)->m_connectUuid << deactivedList.at(i)->m_connectPath);
}
}
map.insert(deviceName, vector);
@ -635,23 +635,26 @@ void LanPage::setWiredDeviceEnable(const QString& devName, bool enable)
void LanPage::activateWired(const QString& devName, const QString& connUuid)
{
qDebug() << "activateWired" << devName << connUuid;
KyWiredConnectOperation a;
a.activateConnection(connUuid, devName);
m_wiredConnectOperation->activateConnection(connUuid, devName);
}
void LanPage::deactivateWired(const QString& devName, const QString& connUuid)
{
qDebug() << "deactivateWired" << devName << connUuid;
KyConnectItem *item = nullptr;
item = m_activeResourse->getActiveConnectionByUuid(connUuid, devName);
if (nullptr == item) {
//todo: 通知桌面
qDebug() << "not ActiveConnection";
return;
}
KyWiredConnectOperation a;
a.deactivateWiredConnection(item->m_connectName, connUuid);
// KyConnectItem *item = nullptr;
// item = m_activeResourse->getActiveConnectionByUuid(connUuid, devName);
// if (nullptr == item) {
// qDebug() << "not ActiveConnection";
// item = m_connectResourse->getConnectionItemByUuid(connUuid, devName);
// if (nullptr == item) {
// QString errorMessage = tr("it can not find the activate connect" + tr("uuid") + connUuid;
// qWarning()<<errorMessage;
// emit deactivateFailed(errorMessage);
// return;
// }
// }
QString name("");
m_wiredConnectOperation->deactivateWiredConnection(name, connUuid);
}
void LanPage::showDetailPage(QString devName, QString uuid)

View File

@ -50,6 +50,7 @@ private:
QListWidgetItem *m_listWidgetItem = nullptr;
KyNetworkDeviceResourse *m_device = nullptr;
KyWiredConnectOperation *m_wiredConnectOperation = nullptr;
KyActiveConnectResourse *m_activeResourse = nullptr; //激活的连接
KyConnectResourse *m_connectResourse = nullptr; //未激活的连接