diff --git a/debian/changelog b/debian/changelog index dd50a78a..cd1a61f2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +kylin-nm (4.0.0.0-ok8.2) yangtze; urgency=medium + + * issue #I7GT8M #I7GST6 #I7YPFI #I73HNK #I72PU4 + + -- zhaoshixu Tue, 26 Sep 2023 14:58:15 +0800 + kylin-nm (4.0.0.0-ok8.1) yangtze; urgency=medium * rebuild with no changes. diff --git a/plugins/mobilehotspot/mobilehotspot.cpp b/plugins/mobilehotspot/mobilehotspot.cpp index 0a3d594c..406f79e7 100644 --- a/plugins/mobilehotspot/mobilehotspot.cpp +++ b/plugins/mobilehotspot/mobilehotspot.cpp @@ -21,7 +21,7 @@ #include - +#include MobileHotspot::MobileHotspot() : mFirstLoad(true) { @@ -113,23 +113,31 @@ bool MobileHotspot::isExitWirelessDevice() return false; } - QDBusMessage result = interface->call(QStringLiteral("getDeviceListAndEnabled"),1); - if(result.type() == QDBusMessage::ErrorMessage) { - qWarning() << "getWirelessDeviceList error:" << result.errorMessage(); + QDBusReply reply = interface->call(QStringLiteral("getDeviceListAndEnabled"),1); + if(!reply.isValid()) { + qWarning() << "getWirelessDeviceList error:" << reply.error().message(); return false; } - auto dbusArg = result.arguments().at(0).value(); QMap deviceListMap; - dbusArg >> deviceListMap; + QVariantMap::const_iterator itemIter = reply.value().cbegin(); + while (itemIter != reply.value().cend()) { + deviceListMap.insert(itemIter.key(), itemIter.value().toBool()); + itemIter ++; + } - QDBusReply > capReply = interface->call("getWirelessDeviceCap"); + QDBusReply capReply = interface->call("getWirelessDeviceCap"); if (!capReply.isValid()) { qDebug()<<"execute dbus method 'getWirelessDeviceCap' is invalid in func initInterfaceInfo()" < devCapMap = capReply.value(); + QMap devCapMap; + QVariantMap::const_iterator item = reply.value().cbegin(); + while (item != reply.value().cend()) { + devCapMap.insert(item.key(), item.value().toInt()); + item ++; + } if (deviceListMap.isEmpty()) { qDebug() << "no wireless device"; diff --git a/plugins/mobilehotspot/mobilehotspotwidget.cpp b/plugins/mobilehotspot/mobilehotspotwidget.cpp index 8d483673..9b389998 100644 --- a/plugins/mobilehotspot/mobilehotspotwidget.cpp +++ b/plugins/mobilehotspot/mobilehotspotwidget.cpp @@ -316,31 +316,26 @@ void MobileHotspotWidget::onInterfaceChanged() { m_interfaceName = m_interfaceComboBox->currentText(); if(m_interface->isValid()) { - QDBusMessage result = m_interface->call(QStringLiteral("getWirelessList")); - if(result.type() == QDBusMessage::ErrorMessage) + QDBusReply reply = m_interface->call(QStringLiteral("getWirelessList"), m_interfaceName); + if(!reply.isValid()) { - qWarning() << "getWirelessList error:" << result.errorMessage(); + qWarning() << "getWirelessList error:" << reply.error().message(); return; } bool flag = false; - auto dbusArg = result.arguments().at(0).value(); - QMap> variantList; - dbusArg >> variantList; - if (variantList.size() != 0) { - QMap>::iterator iter; - for (iter = variantList.begin(); iter != variantList.end(); iter++) { - if (m_interfaceName == iter.key()) { - QVector wlanListInfo = iter.value(); - if (!wlanListInfo.isEmpty() && wlanListInfo.at(0).size() > 1) { - flag = true; - } - break; - } - } + + QList variantList; + for (int j = 0; j < reply.value().size(); ++j) { + variantList << reply.value().at(j).toStringList(); } + + if (!variantList.isEmpty() && variantList.at(0).size() > 1) { + flag = true; + } + if (flag) { m_interfaceWarnLabel->setText(tr("use ") + m_interfaceName + - tr(" share network, will interrupt local wireless connection")); + tr(" share network, will interrupt local wireless connection")); m_interfaceFrame->setFixedHeight(PASSWORD_FRAME_FIX_HIGHT); m_warnWidget->show(); } else { @@ -392,22 +387,32 @@ void MobileHotspotWidget::initInterfaceInfo() m_interfaceComboBox->hidePopup(); } m_interfaceComboBox->clear(); - QDBusReply > reply = m_interface->call("getDeviceListAndEnabled",WIRELESS); - - if (!reply.isValid()) { - qDebug() << LOG_HEAD <<"execute dbus method 'getDeviceListAndEnabled' is invalid in func initInterfaceInfo()"; - setWidgetHidden(true); + QDBusReply reply = m_interface->call(QStringLiteral("getDeviceListAndEnabled"),WIRELESS); + if(!reply.isValid()) { + qWarning() << "[WlanConnect]getWirelessDeviceList error:" << reply.error().message(); return; } - QMap devMap = reply.value(); - QDBusReply > capReply = m_interface->call("getWirelessDeviceCap"); + QMap devMap; + QVariantMap::const_iterator item = reply.value().cbegin(); + while (item != reply.value().cend()) { + devMap.insert(item.key(), item.value().toBool()); + item ++; + } + + + QDBusReply capReply = m_interface->call("getWirelessDeviceCap"); if (!capReply.isValid()) { qDebug() << LOG_HEAD <<"execute dbus method 'getWirelessDeviceCap' is invalid in func initInterfaceInfo()" < devCapMap = capReply.value(); + QMap devCapMap; + QVariantMap::const_iterator itemIter = capReply.value().cbegin(); + while (itemIter != capReply.value().cend()) { + devCapMap.insert(itemIter.key(), itemIter.value().toInt()); + itemIter ++; + } if (devMap.isEmpty()) { qDebug() << LOG_HEAD << "no wireless device"; @@ -827,7 +832,7 @@ void MobileHotspotWidget::updateBandCombox() { QString tmp = m_freqBandComboBox->currentText(); m_freqBandComboBox->clear(); - QDBusReply > capReply = m_interface->call("getWirelessDeviceCap"); + QDBusReply capReply = m_interface->call("getWirelessDeviceCap"); if (!capReply.isValid()) { qDebug()<<"execute dbus method 'getWirelessDeviceCap' is invalid in func initInterfaceInfo()" << capReply.error().message(); setWidgetHidden(true); @@ -835,7 +840,14 @@ void MobileHotspotWidget::updateBandCombox() } m_isUserSelect = false; - QMap devCapMap = capReply.value(); + + QMap devCapMap; + QVariantMap::const_iterator itemIter = capReply.value().cbegin(); + while (itemIter != capReply.value().cend()) { + devCapMap.insert(itemIter.key(), itemIter.value().toInt()); + itemIter ++; + } + if (devCapMap[m_interfaceName] & 0x02) { m_freqBandComboBox->addItem("2.4GHz"); } diff --git a/plugins/netconnect/netconnect.cpp b/plugins/netconnect/netconnect.cpp index fd70ad59..16180f86 100644 --- a/plugins/netconnect/netconnect.cpp +++ b/plugins/netconnect/netconnect.cpp @@ -76,6 +76,9 @@ void NetConnect::showDesktopNotify(const QString &message) NetConnect::NetConnect() : mFirstLoad(true) { + qDBusRegisterMetaType(); + qDBusRegisterMetaType>(); + QTranslator* translator = new QTranslator(this); translator->load("/usr/share/kylin-nm/netconnect/" + QLocale::system().name()); QApplication::installTranslator(translator); @@ -83,7 +86,15 @@ NetConnect::NetConnect() : mFirstLoad(true) { pluginName = tr("LAN"); pluginType = NETWORK; - needLoad = isExitWiredDevice(); + m_interface = new QDBusInterface("com.kylin.network", + "/com/kylin/network", + "com.kylin.network", + QDBusConnection::sessionBus()); + if(!m_interface->isValid()) { + qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message()); + } + updatePluginShowSettings(); + connect(m_interface, SIGNAL(deviceStatusChanged()), this, SLOT(updatePluginShowSettings()),Qt::QueuedConnection); } NetConnect::~NetConnect() { @@ -111,7 +122,7 @@ QWidget *NetConnect::pluginUi() { pluginWidget = new QWidget; pluginWidget->setAttribute(Qt::WA_DeleteOnClose); ui->setupUi(pluginWidget); - qDBusRegisterMetaType>(); + m_interface = new QDBusInterface("com.kylin.network", "/com/kylin/network", "com.kylin.network", @@ -119,6 +130,9 @@ QWidget *NetConnect::pluginUi() { if(!m_interface->isValid()) { qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message()); } + + qDBusRegisterMetaType>(); + initSearchText(); initComponent(); } @@ -132,7 +146,54 @@ const QString NetConnect::name() const { bool NetConnect::isEnable() const { - return needLoad; + //get isEnable + QDBusInterface dbus("com.kylin.network", "/com/kylin/network", + "com.kylin.network", + QDBusConnection::sessionBus()); + if (!dbus.isValid()) { + return false; + } + + QMap map; + QDBusReply reply = dbus.call(QStringLiteral("getDeviceListAndEnabled"),0); + if(!reply.isValid()) + { + qWarning() << "[NetConnect]getWiredDeviceList error:" << reply.error().message(); + return false; + } + + QVariantMap::const_iterator item = reply.value().cbegin(); + while (item != reply.value().cend()) { + map.insert(item.key(), item.value().toBool()); + item ++; + } + + bool isEnabled = !map.isEmpty(); + + const QByteArray schema("org.ukui.control-center.plugins"); + if (QGSettings::isSchemaInstalled(schema)) { + return isEnabled; + } + + //get gsettings + QGSettings *showSettings; + QString path("/org/ukui/control-center/plugins/netconnect/"); + showSettings = new QGSettings(schema, path.toUtf8()); + + QVariant enabledState = showSettings->get("show"); + + //set gsettings + if (!enabledState.isValid() || enabledState.isNull()) { + qWarning() << "QGSettins get plugin show status error"; + } else { + if (enabledState.toBool() != isEnabled) { + showSettings->set("show", isEnabled); + } + } + delete showSettings; + showSettings = nullptr; + + return isEnabled; } @@ -156,7 +217,8 @@ void NetConnect::initSearchText() { ui->detailBtn->setText(tr("Advanced settings")); ui->titleLabel->setText(tr("LAN")); //~ contents_path /netconnect/open - ui->openLabel->setText(tr("open")); + tr("open"); + ui->openLabel->setText(tr("LAN")); } bool NetConnect::eventFilter(QObject *w, QEvent *e) { @@ -255,16 +317,21 @@ void NetConnect::getDeviceStatusMap(QMap &map) if (m_interface == nullptr || !m_interface->isValid()) { return; } + map.clear(); qDebug() << "[NetConnect]call getDeviceListAndEnabled" << __LINE__; - QDBusMessage result = m_interface->call(QStringLiteral("getDeviceListAndEnabled"),0); + QDBusReply reply = m_interface->call(QStringLiteral("getDeviceListAndEnabled"),0); qDebug() << "[NetConnect]call getDeviceListAndEnabled Respond" << __LINE__; - if(result.type() == QDBusMessage::ErrorMessage) + if(!reply.isValid()) { - qWarning() << "[NetConnect]getWiredDeviceList error:" << result.errorMessage(); + qWarning() << "[NetConnect]getWiredDeviceList error:" << reply.error().message(); return; } - auto dbusArg = result.arguments().at(0).value(); - dbusArg >> map; + + QVariantMap::const_iterator item = reply.value().cbegin(); + while (item != reply.value().cend()) { + map.insert(item.key(), item.value().toBool()); + item ++; + } } //lanUpdate @@ -406,26 +473,17 @@ void NetConnect::initNetListFromDevice(QString deviceName) if (m_interface == nullptr || !m_interface->isValid()) { return; } - qDebug() << "[NetConnect]call getWiredList" << __LINE__; - QDBusMessage result = m_interface->call(QStringLiteral("getWiredList")); - qDebug() << "[NetConnect]call getWiredList respond" << __LINE__; - if(result.type() == QDBusMessage::ErrorMessage) - { - qWarning() << "getWiredList error:" << result.errorMessage(); - return; - } - auto dbusArg = result.arguments().at(0).value(); - QMap> variantList; - dbusArg >> variantList; + + QMap> variantList = getWiredList(); if (variantList.size() == 0) { qDebug() << "[NetConnect]initNetListFromDevice " << deviceName << " list empty"; return; } - QMap>::iterator iter; + QMap>::iterator iter; for (iter = variantList.begin(); iter != variantList.end(); iter++) { if (deviceName == iter.key()) { - QVector wlanListInfo = iter.value(); + QList wlanListInfo = iter.value(); //处理列表 已连接 qDebug() << "[NetConnect]initNetListFromDevice " << deviceName << " acitved lan " << wlanListInfo.at(0); addLanItem(deviceFrameMap[deviceName], deviceName, wlanListInfo.at(0), true); @@ -513,22 +571,25 @@ void NetConnect::addDeviceFrame(QString devName) qDebug() << "[NetConnect]addDeviceFrame " << devName; qDebug() << "[NetConnect]call getDeviceListAndEnabled" << __LINE__; - QDBusMessage result = m_interface->call(QStringLiteral("getDeviceListAndEnabled"),0); + QDBusReply reply = m_interface->call(QStringLiteral("getDeviceListAndEnabled"),0); qDebug() << "[NetConnect]call getDeviceListAndEnabled Respond" << __LINE__; - if(result.type() == QDBusMessage::ErrorMessage) - { - qWarning() << "[NetConnect]getWiredDeviceList error:" << result.errorMessage(); + if(!reply.isValid()) { + qWarning() << "[NetConnect]getWiredDeviceList error:" << reply.error().message(); return; } - auto dbusArg = result.arguments().at(0).value(); QMap map; - dbusArg >> map; + QVariantMap::const_iterator item = reply.value().cbegin(); + while (item != reply.value().cend()) { + map.insert(item.key(), item.value().toBool()); + item ++; + } bool enable = true; if (map.contains(devName)) { enable = map[devName]; } + ItemFrame *itemFrame = new ItemFrame(devName, pluginWidget); ui->availableLayout->addWidget(itemFrame); itemFrame->deviceFrame->deviceLabel->setText(tr("card")+/*QString("%1").arg(count)+*/":"+devName); @@ -926,17 +987,9 @@ int NetConnect::getInsertPos(QString connName, QString deviceName) if(m_interface == nullptr || !m_interface->isValid()) { index = 0; } else { - qDebug() << "[NetConnect]call getWiredList" << __LINE__; - QDBusMessage result = m_interface->call(QStringLiteral("getWiredList")); - qDebug() << "[NetConnect]call getWiredList respond" << __LINE__; - if(result.type() == QDBusMessage::ErrorMessage) - { - qWarning() << "getWiredList error:" << result.errorMessage(); - return 0; - } - auto dbusArg = result.arguments().at(0).value(); - QMap> variantList; - dbusArg >> variantList; + + QMap> variantList = getWiredList(); + if (!variantList.contains(deviceName)) { qDebug() << "[NetConnect] getInsertPos but " << deviceName << "not exist"; return 0; @@ -971,30 +1024,33 @@ bool NetConnect::LaunchApp(QString desktopFile) } } -bool NetConnect::isExitWiredDevice() +QMap> NetConnect::getWiredList() { - QDBusInterface *interface = new QDBusInterface("com.kylin.network", "/com/kylin/network", - "com.kylin.network", - QDBusConnection::sessionBus()); - if (!interface->isValid()) { - qDebug() << "/com/kylin/network is invalid"; - return false; + QMap> map; + + QMap statusMap; + getDeviceStatusMap(statusMap); + + for (int i = 0; i < statusMap.keys().size(); ++i) { + qDebug() << "[NetConnect]call getWiredList" << __LINE__; + QDBusReply reply = m_interface->call(QStringLiteral("getWiredList"), statusMap.keys().at(i)); + qDebug() << "[NetConnect]call getWiredList respond" << __LINE__; + if(!reply.isValid()) + { + qWarning() << "getWiredList error:" << reply.error().message(); + break; + } + + QList list; + for (int j = 0; j < reply.value().size(); ++j) { + list << reply.value().at(j).toStringList(); + } + map.insert(statusMap.keys().at(i), list); } - - QDBusMessage result = interface->call(QStringLiteral("getDeviceListAndEnabled"),0); - if(result.type() == QDBusMessage::ErrorMessage) { - qWarning() << "getWiredDeviceList error:" << result.errorMessage(); - return false; - } - - auto dbusArg = result.arguments().at(0).value(); - QMap deviceListMap; - dbusArg >> deviceListMap; - - - if (deviceListMap.isEmpty()) { - qDebug() << "no wired device"; - return false; - } - return true; + return map; +} + +void NetConnect::updatePluginShowSettings() +{ + isEnable(); } diff --git a/plugins/netconnect/netconnect.h b/plugins/netconnect/netconnect.h index 0f4a0a7e..7b9ff6a6 100644 --- a/plugins/netconnect/netconnect.h +++ b/plugins/netconnect/netconnect.h @@ -147,7 +147,7 @@ private: QMap deviceStatusMap; QMap deviceFrameMap; - bool needLoad; + QMap> getWiredList(); private slots: void updateLanInfo(QString deviceName, QStringList lanInfo); @@ -159,6 +159,9 @@ private slots: void onDeviceStatusChanged(); void onDeviceNameChanged(QString, QString, int); + + //更新控制面板插件Gsetting show + void updatePluginShowSettings(); }; Q_DECLARE_METATYPE(QList); diff --git a/plugins/proxy/proxy.cpp b/plugins/proxy/proxy.cpp index e217764f..8641546d 100644 --- a/plugins/proxy/proxy.cpp +++ b/plugins/proxy/proxy.cpp @@ -348,7 +348,7 @@ void Proxy::initUi(QWidget *widget) mIgnoreLayout->setSpacing(10); mIgnoreLayout->setContentsMargins(16, 0, 16, 24); mIgnoreLabel = new QLabel(mIgnoreFrame); - mIgnoreLabel->setFixedHeight(36); + mIgnoreLabel->setWordWrap(true); mIgnoreLineEdit = new QTextEdit(mIgnoreFrame); mIgnoreLineEdit->setFixedHeight(120); mIgnoreLineEdit->setStyleSheet("border-radius:6px;background-color: palette(button)"); diff --git a/plugins/wlanconnect/wlanconnect.cpp b/plugins/wlanconnect/wlanconnect.cpp index 5d51bdca..09f2bee2 100644 --- a/plugins/wlanconnect/wlanconnect.cpp +++ b/plugins/wlanconnect/wlanconnect.cpp @@ -143,6 +143,15 @@ WlanConnect::WlanConnect() : m_firstLoad(true) { pluginName = tr("WLAN"); pluginType = NETWORK; + + m_interface = new QDBusInterface("com.kylin.network", "/com/kylin/network", + "com.kylin.network", + QDBusConnection::sessionBus()); + if(!m_interface->isValid()) { + qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message()); + } + updatePluginShowSettings(); + connect(m_interface, SIGNAL(wirelessDeviceStatusChanged()), this, SLOT(updatePluginShowSettings()), Qt::QueuedConnection); } WlanConnect::~WlanConnect() @@ -171,12 +180,14 @@ QWidget *WlanConnect::pluginUi() { pluginWidget->setAttribute(Qt::WA_DeleteOnClose); ui->setupUi(pluginWidget); qDBusRegisterMetaType>(); + qDBusRegisterMetaType(); m_interface = new QDBusInterface("com.kylin.network", "/com/kylin/network", "com.kylin.network", QDBusConnection::sessionBus()); if(!m_interface->isValid()) { qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message()); } + initSearchText(); initComponent(); } @@ -190,7 +201,61 @@ const QString WlanConnect::name() const { bool WlanConnect::isEnable() const { - return true; + //get isEnable + QDBusInterface dbus("com.kylin.network", "/com/kylin/network", + "com.kylin.network", + QDBusConnection::sessionBus()); + if (!dbus.isValid()) { + return false; + } + QMap map; + QDBusReply reply = dbus.call(QStringLiteral("getDeviceListAndEnabled"), 1); + if(!reply.isValid()) + { + qWarning() << "[NetConnect]getWiredDeviceList error:" << reply.error().message(); + return false; + } + + QVariantMap::const_iterator item = reply.value().cbegin(); + while (item != reply.value().cend()) { + map.insert(item.key(), item.value().toBool()); + item ++; + } + //筛选已托管(managed)网卡 + QStringList list; + QMap::iterator iters; + for (iters = map.begin(); iters != map.end(); ++iters) { + if (iters.value() == true) { + list << iters.key(); + } + } + + bool isEnabled = !list.isEmpty(); + + const QByteArray schema("org.ukui.control-center.plugins"); + if (QGSettings::isSchemaInstalled(schema)) { + return isEnabled; + } + + //get gsettings + QGSettings *showSettings; + QString path("/org/ukui/control-center/plugins/wlanconnect/"); + showSettings = new QGSettings(schema, path.toUtf8()); + + QVariant enabledState = showSettings->get("show"); + + //set gsettings + if (!enabledState.isValid() || enabledState.isNull()) { + qWarning() << "QGSettins get plugin show status error"; + } else { + if (enabledState.toBool() != isEnabled) { + showSettings->set("show", isEnabled); + } + } + delete showSettings; + showSettings = nullptr; + + return isEnabled; } @@ -214,7 +279,8 @@ void WlanConnect::initSearchText() { ui->detailBtn->setText(tr("Advanced settings")); ui->titleLabel->setText(tr("WLAN")); //~ contents_path /wlanconnect/open - ui->openLabel->setText(tr("open")); + tr("open"); + ui->openLabel->setText(tr("WLAN")); } bool WlanConnect::eventFilter(QObject *w, QEvent *e) { @@ -320,28 +386,18 @@ void WlanConnect::updateList() } qDebug() << "update list"; if(m_interface != nullptr && m_interface->isValid()) { - qDebug() << "[WlanConnect]call getWirelessList" << __LINE__; - QDBusMessage result = m_interface->call(QStringLiteral("getWirelessList")); - qDebug() << "[WlanConnect]call getWirelessList respond" << __LINE__; - if(result.type() == QDBusMessage::ErrorMessage) - { - qWarning() << "getWirelessList error:" << result.errorMessage(); - return; - } - auto dbusArg = result.arguments().at(0).value(); - QMap> variantList; - dbusArg >> variantList; + QMap> variantList = getWirelessList(); if (variantList.size() == 0) { qDebug() << "[WlanConnect]updateList " << " list empty"; return; } - QMap>::iterator iter; + QMap>::iterator iter; for (iter = variantList.begin(); iter != variantList.end(); iter++) { if (deviceFrameMap.contains(iter.key())) { - QVector wifiList = iter.value(); + QList wifiList = iter.value(); resortWifiList(deviceFrameMap[iter.key()], wifiList); deviceFrameMap[iter.key()]->filletStyleChange(); } @@ -349,7 +405,7 @@ void WlanConnect::updateList() } } -void WlanConnect::resortWifiList(ItemFrame *frame, QVector list) +void WlanConnect::resortWifiList(ItemFrame *frame, QList list) { if(nullptr == frame || frame->lanItemLayout->count() <= 0 || list.isEmpty()) { return; @@ -705,16 +761,20 @@ void WlanConnect::getDeviceList(QStringList &list) return; } qDebug() << "[WlanConnect]call getDeviceListAndEnabled" << __LINE__; - QDBusMessage result = m_interface->call(QStringLiteral("getDeviceListAndEnabled"),1); + QDBusReply reply = m_interface->call(QStringLiteral("getDeviceListAndEnabled"),1); qDebug() << "[WlanConnect]call getDeviceListAndEnabled respond" << __LINE__; - if(result.type() == QDBusMessage::ErrorMessage) + if(!reply.isValid()) { - qWarning() << "[WlanConnect]getWirelessDeviceList error:" << result.errorMessage(); + qWarning() << "[WlanConnect]getWirelessDeviceList error:" << reply.error().message(); return; } - auto dbusArg = result.arguments().at(0).value(); + QMap map; - dbusArg >> map; + QVariantMap::const_iterator item = reply.value().cbegin(); + while (item != reply.value().cend()) { + map.insert(item.key(), item.value().toBool()); + item ++; + } //筛选已托管(managed)网卡 QMap::iterator iters; @@ -772,26 +832,20 @@ void WlanConnect::initNetListFromDevice(QString deviceName) if (m_interface == nullptr || !m_interface->isValid()) { return; } - qDebug() << "[WlanConnect]call getWirelessList" << __LINE__; - QDBusMessage result = m_interface->call(QStringLiteral("getWirelessList")); - qDebug() << "[WlanConnect]call getWirelessList respond" << __LINE__; - if(result.type() == QDBusMessage::ErrorMessage) - { - qWarning() << "getWirelessList error:" << result.errorMessage(); - return; - } - auto dbusArg = result.arguments().at(0).value(); - QMap> variantList; - dbusArg >> variantList; + + QMap> variantList = getWirelessList(); if (variantList.size() == 0) { qDebug() << "[WlanConnect]initNetListFromDevice " << deviceName << " list empty"; return; } - QMap>::iterator iter; + QMap>::iterator iter; for (iter = variantList.begin(); iter != variantList.end(); iter++) { if (deviceName == iter.key()) { - QVector wlanListInfo = iter.value(); + QList wlanListInfo = iter.value(); + if (wlanListInfo.size() <= 0) { + break; + } //处理列表 已连接 qDebug() << "[WlanConnect]initNetListFromDevice " << deviceName << " acitved wifi " << wlanListInfo.at(0); addActiveItem(deviceFrameMap[deviceName], deviceName, wlanListInfo.at(0)); @@ -907,21 +961,13 @@ int WlanConnect::sortWlanNet(QString deviceName, QString name, QString signal) if (m_interface == nullptr || !m_interface->isValid()) { return 0; } - qDebug() << "[WlanConnect]call getWirelessList" << __LINE__; - QDBusMessage result = m_interface->call(QStringLiteral("getWirelessList")); - qDebug() << "[WlanConnect]call getWirelessList respond" << __LINE__; - if(result.type() == QDBusMessage::ErrorMessage) - { - qWarning() << "getWirelessList error:" << result.errorMessage(); - return 0; - } - auto dbusArg = result.arguments().at(0).value(); - QMap> variantList; - dbusArg >> variantList; - QMap>::iterator iter; + + QMap> variantList = getWirelessList(); + + QMap>::iterator iter; for (iter = variantList.begin(); iter != variantList.end(); iter++) { if (deviceName == iter.key()) { - QVector wlanListInfo = iter.value(); + QList wlanListInfo = iter.value(); for (int i = 0; i < wlanListInfo.size(); i++) { if (name == wlanListInfo.at(i).at(0)) { return i; @@ -1146,3 +1192,33 @@ bool WlanConnect::LaunchApp(QString desktopFile) return reply; } } + +QMap> WlanConnect::getWirelessList() +{ + QMap> map; + QStringList list; + getDeviceList(list); + + for (int i = 0; i < list.size(); ++i) { + qDebug() << "[NetConnect]call getWirelessList" << __LINE__; + QDBusReply reply = m_interface->call(QStringLiteral("getWirelessList"), list.at(i)); + qDebug() << "[NetConnect]call getWirelessList respond" << __LINE__; + if(!reply.isValid()) + { + qWarning() << "getWirelessList error:" << reply.error().message(); + break; + } + + QList llist; + for (int j = 0; j < reply.value().size(); ++j) { + llist << reply.value().at(j).toStringList(); + } + map.insert(list.at(i), llist); + } + return map; +} + +void WlanConnect::updatePluginShowSettings() +{ + isEnable(); +} diff --git a/plugins/wlanconnect/wlanconnect.h b/plugins/wlanconnect/wlanconnect.h index 10088b38..5c316aee 100644 --- a/plugins/wlanconnect/wlanconnect.h +++ b/plugins/wlanconnect/wlanconnect.h @@ -91,7 +91,7 @@ private: int sortWlanNet(QString deviceName, QString name, QString signal); void updateIcon(WlanItem *item, QString signalStrength, QString security, QString isApConnection, int category); - void resortWifiList(ItemFrame *frame, QVector list); + void resortWifiList(ItemFrame *frame, QList list); //单wifi图标 @@ -174,6 +174,8 @@ private: QTimer * m_scanTimer = nullptr; // QTimer * m_updateTimer = nullptr; + + QMap> getWirelessList(); private: KSwitchButton *m_wifiSwitch; bool m_firstLoad; @@ -192,6 +194,7 @@ private slots: void reScan(); - + //更新控制面板插件Gsetting show + void updatePluginShowSettings(); }; #endif // WLANCONNECT_H diff --git a/src/backend/backend.pri b/src/backend/backend.pri index fdab03bd..5d5b9cca 100644 --- a/src/backend/backend.pri +++ b/src/backend/backend.pri @@ -3,13 +3,17 @@ include(hotspot/hotspot.pri) include(dbus-interface/dbus-interface.pri) HEADERS += \ - $$PWD/dbusadaptor.h \ + $$PWD/dbus.h \ + $$PWD/dbus_adaptor.h \ + $$PWD/dbus_interface.h \ $$PWD/sysdbusregister.h \ $$PWD/utils.h \ $$PWD/wifi-auth-thread.h SOURCES += \ - $$PWD/dbusadaptor.cpp \ + $$PWD/dbus.cpp \ + $$PWD/dbus_adaptor.cpp \ + $$PWD/dbus_interface.cpp \ $$PWD/sysdbusregister.cpp \ $$PWD/utils.cpp \ $$PWD/wifi-auth-thread.cpp diff --git a/src/backend/dbus-interface/kylinconnectresource.cpp b/src/backend/dbus-interface/kylinconnectresource.cpp index 739738a1..a4e8b78f 100644 --- a/src/backend/dbus-interface/kylinconnectresource.cpp +++ b/src/backend/dbus-interface/kylinconnectresource.cpp @@ -80,6 +80,8 @@ KyConnectResourse::KyConnectResourse(QObject *parent) : QObject(parent) connect(m_networkResourceInstance, &KyNetworkResourceManager::connectionRemove, this, &KyConnectResourse::connectionRemove); connect(m_networkResourceInstance, &KyNetworkResourceManager::connectionUpdate, this, &KyConnectResourse::connectionUpdate); connect(m_networkResourceInstance, &KyNetworkResourceManager::connectivityChanged, this, &KyConnectResourse::connectivityChanged); + + connect(m_networkResourceInstance, &KyNetworkResourceManager::connectivityCheckSpareUriChanged, this, &KyConnectResourse::connectivityCheckSpareUriChanged); connect(m_networkResourceInstance, &KyNetworkResourceManager::needShowDesktop, this, &KyConnectResourse::needShowDesktop); } diff --git a/src/backend/dbus-interface/kylinconnectresource.h b/src/backend/dbus-interface/kylinconnectresource.h index 91bffcec..0302e8c1 100644 --- a/src/backend/dbus-interface/kylinconnectresource.h +++ b/src/backend/dbus-interface/kylinconnectresource.h @@ -86,6 +86,7 @@ Q_SIGNALS: void connectionUpdate(QString uuid); void connectionRemove(QString path); void connectivityChanged(NetworkManager::Connectivity connectivity); + void connectivityCheckSpareUriChanged(); void needShowDesktop(QString); diff --git a/src/backend/dbus-interface/kylinnetworkresourcemanager.cpp b/src/backend/dbus-interface/kylinnetworkresourcemanager.cpp index e0a0323e..5bed0749 100644 --- a/src/backend/dbus-interface/kylinnetworkresourcemanager.cpp +++ b/src/backend/dbus-interface/kylinnetworkresourcemanager.cpp @@ -597,6 +597,12 @@ void KyNetworkResourceManager::onPropertiesChanged(QVariantMap qvm) Q_EMIT wiredEnabledChanged(wiredEnable); } } + for(QString keyStr : qvm.keys()) { + //内网检测地址变化 + if (keyStr == "ConnectivityCheckSpareUri") { + Q_EMIT connectivityCheckSpareUriChanged(); + } + } } void KyNetworkResourceManager::onConnectionUpdated() diff --git a/src/backend/dbus-interface/kylinnetworkresourcemanager.h b/src/backend/dbus-interface/kylinnetworkresourcemanager.h index 9cf59896..ad8c4bf0 100644 --- a/src/backend/dbus-interface/kylinnetworkresourcemanager.h +++ b/src/backend/dbus-interface/kylinnetworkresourcemanager.h @@ -129,6 +129,7 @@ Q_SIGNALS: void wifiNetworkDeviceDisappear(); void wifiEnabledChanged(bool); void wiredEnabledChanged(bool); + void connectivityCheckSpareUriChanged(); void activeConnectionsReset(); void activeConnectionAdd(QString uuid); diff --git a/src/backend/dbus-interface/kylinutil.cpp b/src/backend/dbus-interface/kylinutil.cpp index 095c75fc..6521d3ff 100644 --- a/src/backend/dbus-interface/kylinutil.cpp +++ b/src/backend/dbus-interface/kylinutil.cpp @@ -218,3 +218,89 @@ out: g_object_unref (props_proxy); } +QString getConnectivityCheckSpareUriByGDbus() +{ + GDBusProxy *props_proxy; + GVariant *ret = NULL, *path_value = NULL; + GError *error = NULL; + QString str; + + /* 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", + "ConnectivityCheckSpareUri"), + G_DBUS_CALL_FLAGS_NONE, -1, + NULL, &error); + if (!ret) { + g_dbus_error_strip_remote_error (error); + qDebug() << "failed to getConnectivityCheckSpareUri"; + g_error_free (error); + } + + g_variant_get (ret, "(v)", &path_value); +// if (!g_variant_is_of_type (path_value, G_VARIANT_TYPE_VARIANT)) { +// g_warning ("Unexpected type returned getting Connection property: %s", +// g_variant_get_type_string (path_value)); +// goto out; +// } + + str = QString(g_variant_get_string(path_value, NULL)); + +out: + if (path_value) + g_variant_unref (path_value); + if (ret) + g_variant_unref (ret); + g_object_unref (props_proxy); + + return str; +} + +void setConnectivityCheckSpareUriByGDbus(QString uri) +{ + 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", + "ConnectivityCheckSpareUri", + g_variant_new_string(uri.toStdString().c_str())), + G_DBUS_CALL_FLAGS_NONE, -1, + NULL, &error); + if (!ret) { + g_dbus_error_strip_remote_error (error); + qDebug() << "failed to setConnectivityCheckSpareUri"; + g_error_free (error); + } + +out: + if (ret) + g_variant_unref (ret); + g_object_unref (props_proxy); +} diff --git a/src/backend/dbus-interface/kylinutil.h b/src/backend/dbus-interface/kylinutil.h index df700699..cf2c2494 100644 --- a/src/backend/dbus-interface/kylinutil.h +++ b/src/backend/dbus-interface/kylinutil.h @@ -37,6 +37,8 @@ QString getConnectTypeByDbus(QString &connectPath); QString getSsidFromByteArray(QByteArray &rawSsid); void setWiredEnabledByGDbus(bool enabled); void setDeviceManagedByGDbus(QString dbusPath, bool managed); +QString getConnectivityCheckSpareUriByGDbus(); +void setConnectivityCheckSpareUriByGDbus(QString str); bool getWiredEnabledByGDbus(); #endif // KYLINUTIL_H diff --git a/src/backend/dbus-interface/kywirelessnetresource.cpp b/src/backend/dbus-interface/kywirelessnetresource.cpp index db880c5e..ad161dc8 100644 --- a/src/backend/dbus-interface/kywirelessnetresource.cpp +++ b/src/backend/dbus-interface/kywirelessnetresource.cpp @@ -295,6 +295,10 @@ QString KyWirelessNetResource::getDeviceIFace(NetworkManager::ActiveConnection:: NetworkManager::Device:: Ptr devicePtr = m_networkResourceInstance->findDeviceUni(ifaceUni); + if (devicePtr.isNull()) { + return QString(); + } + return devicePtr->interfaceName(); } diff --git a/src/backend/dbus.cpp b/src/backend/dbus.cpp new file mode 100644 index 00000000..be2012a0 --- /dev/null +++ b/src/backend/dbus.cpp @@ -0,0 +1,431 @@ +/* + * This file was generated by qdbusxml2cpp version 0.8 + * Command line was: qdbusxml2cpp com.kylin.weather.xml -a dbusadaptor -c DbusAdaptor -l MainWindow + * + * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd. + * + * This is an auto-generated file. + * Do not edit! All changes made to it will be lost. + */ + +#include "dbus.h" +#include +#include +#include +#include +#include +#include +#include + +const QByteArray GSETTINGS_SCHEMA_KYLIN_NM = "org.ukui.kylin-nm.switch"; +const QString KEY_WIRELESS_SWITCH = "wirelessswitch"; +const QString KEY_WIRED_SWITCH = "wiredswitch"; + +/* + * Implementation of adaptor class DbusAdaptor + */ + +DbusAdaptor::DbusAdaptor(QString display, MainWindow *m, QObject *parent) + : QObject(parent), + m_display(display), + m_mainWindow(m) +{ + // constructor + qDBusRegisterMetaType >(); + qDBusRegisterMetaType >(); + qDBusRegisterMetaType >(); + qDBusRegisterMetaType >>(); + + bool isServiceRegistered = QDBusConnection::sessionBus().interface()->isServiceRegistered(QStringLiteral("com.kylin.network")); + if(!isServiceRegistered) { + registerService(); + } + + m_watcher = new QDBusServiceWatcher(QStringLiteral("com.kylin.network"),QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForOwnerChange, this); + connect(m_watcher, &QDBusServiceWatcher::serviceOwnerChanged, this, &DbusAdaptor::onServiceOwnerChanged); + + connectToMainwindow(); +} + +void DbusAdaptor::onServiceOwnerChanged(const QString &service, const QString &oldOwner, const QString &newOwner) +{ + if (newOwner.isEmpty()) { + bool success = registerService(); + if (success) { + m_watcher->deleteLater(); + } + qDebug() << "try to register service:" << success; + return; + } + + uint newOwnerPid = QDBusConnection::sessionBus().interface()->servicePid(newOwner); + qDebug() << "newOwnerPid:" << newOwnerPid << ", myPid:" << QCoreApplication::applicationPid() << ", display:" << m_display; +} + +bool DbusAdaptor::registerService() +{ + new NetworkAdaptor(this); + + QDBusConnection conn = QDBusConnection::sessionBus(); + auto reply = conn.interface()->registerService(QStringLiteral("com.kylin.network"), + QDBusConnectionInterface::ReplaceExistingService, + QDBusConnectionInterface::DontAllowReplacement); + if (reply.value() == QDBusConnectionInterface::ServiceNotRegistered) { + return false; + } + + bool res = QDBusConnection::sessionBus().registerObject("/com/kylin/network", this); + if (!res) { + QDBusConnection::sessionBus().interface()->unregisterService(QStringLiteral("com.kylin.network")); + } + return res; +} + + +//无线列表 +QVariantList DbusAdaptor::getWirelessList(QString devName) +{ + QList list; + m_mainWindow->getWirelessList(devName, list); + QVariantList vList; + for (int i = 0; i < list.size(); ++i) { + vList.append(QVariant::fromValue(list.at(i))); + } + return vList; +} + +bool DbusAdaptor::getWirelessSwitchBtnState() +{ + return m_mainWindow->getWirelessSwitchBtnState(); +} + +//有线列表 +QVariantList DbusAdaptor::getWiredList(QString devName) +{ + QList list; + m_mainWindow->getWiredList(devName, list); + QVariantList vList; + for (int i = 0; i < list.size(); ++i) { + vList.append(QVariant::fromValue(list.at(i))); + } + return vList; + +} + +//有线开关 +void DbusAdaptor::setWiredSwitchEnable(bool enable) +{ + //todo mainwindow调用backend 对开关 打开/关闭 + if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA_KYLIN_NM)) { + QGSettings *gsetting = new QGSettings(GSETTINGS_SCHEMA_KYLIN_NM); + if (gsetting->get(KEY_WIRED_SWITCH).toBool() != enable) { + gsetting->set(KEY_WIRED_SWITCH, enable); + } + delete gsetting; + gsetting = nullptr; + } else { + qDebug()<<"isSchemaInstalled false"; + } +} + +//无线开关 +void DbusAdaptor::setWirelessSwitchEnable(bool enable) +{ + //todo mainwindow调用backend 对开关 打开/关闭 +// if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA_KYLIN_NM)) { +// QGSettings *gsetting = new QGSettings(GSETTINGS_SCHEMA_KYLIN_NM); +// if (gsetting->get(KEY_WIRELESS_SWITCH).toBool() != enable) { +// gsetting->set(KEY_WIRELESS_SWITCH, enable); +// } +// delete gsetting; +// gsetting = nullptr; +// } else { +// qDebug()<<"isSchemaInstalled false"; +// } + m_mainWindow->setWirelessSwitchEnable(enable); +} + +//启用/禁用网卡 +void DbusAdaptor::setDeviceEnable(QString devName, bool enable) +{ + m_mainWindow->setWiredDeviceEnable(devName, enable); +} + +//设置默认网卡 +//void DbusAdaptor::setDefaultWiredDevice(QString deviceName) +//{ +// if (!checkDeviceExist(WIRED, deviceName)) { +// return; +// } +// setDefaultDevice(WIRED, deviceName); +// parent()->setWiredDefaultDevice(deviceName); +// return; +//} + +//QString DbusAdaptor::getDefaultWiredDevice() +//{ +// QSettings * m_settings = new QSettings(CONFIG_FILE_PATH, QSettings::IniFormat); +// m_settings->beginGroup("DEFAULTCARD"); +// QString key("wired"); +// QString deviceName = m_settings->value(key, "").toString(); +// m_settings->endGroup(); +// delete m_settings; +// m_settings = nullptr; +// return deviceName; +//} + +//void DbusAdaptor::setDefaultWirelessDevice(QString deviceName) +//{ +// if (!checkDeviceExist(WIRED, deviceName)) { +// return; +// } +// setDefaultDevice(WIRELESS, deviceName); +// parent()->setWirelessDefaultDevice(deviceName); +// return; +//} + +//QString DbusAdaptor::getDefaultWirelessDevice() +//{ +// QSettings * m_settings = new QSettings(CONFIG_FILE_PATH, QSettings::IniFormat); +// m_settings->beginGroup("DEFAULTCARD"); +// QString key("wireless"); +// QString deviceName = m_settings->value(key, "").toString(); +// m_settings->endGroup(); +// delete m_settings; +// m_settings = nullptr; +// return deviceName; +//} + +//删除 +void DbusAdaptor::deleteConnect(int type, QString ssid) +{ + if (type == WIRED) { + m_mainWindow->deleteWired(ssid); + } else if (type == WIRELESS) { + //待实现 + } else { + qDebug() << "[DbusAdaptor] deleteConnect type is invalid"; + } +} + +//连接 根据网卡类型 参数1 0:lan 1:wlan 参数3 为ssid/uuid +void DbusAdaptor::activateConnect(int type, QString devName, QString ssid) +{ + if (type == WIRED) { + m_mainWindow->activateWired(devName,ssid); + } else if (type == WIRELESS) { + m_mainWindow->activateWireless(devName,ssid); + } else { + qDebug() << "[DbusAdaptor] activateConnect type is invalid"; + } +} + +//断开连接 根据网卡类型 参数1 0:lan 1:wlan 参数3 为ssid/uuid +void DbusAdaptor::deActivateConnect(int type, QString devName, QString ssid) +{ + if (type == WIRED) { + qDebug() << "deactivateWired"; + m_mainWindow->deactivateWired(devName,ssid); + } else if (type == WIRELESS) { + m_mainWindow->deactivateWireless(devName,ssid); + } else { + qDebug() << "[DbusAdaptor] deactivateConnect type is invalid"; + } +} + +//获取设备列表和启用/禁用状态 +QVariantMap DbusAdaptor::getDeviceListAndEnabled(int devType) +{ + QMap map; + map.clear(); + getDeviceEnableState(devType, map); + QVariantMap vMap; + QMap::const_iterator item = map.cbegin(); + while (item != map.cend()) { + vMap.insert(item.key(), QVariant::fromValue(item.value())); + item ++; + } + return vMap; +} + +//获取无线设备能力 +QVariantMap DbusAdaptor::getWirelessDeviceCap() +{ + QMap map; + m_mainWindow->getWirelessDeviceCap(map); + QVariantMap vMap; + QMap::const_iterator item = map.cbegin(); + while (item != map.cend()) { + vMap.insert(item.key(), QVariant::fromValue(item.value())); + item ++; + } + return vMap; +} + +//唤起属性页 根据网卡类型 参数2 为ssid/uuid +void DbusAdaptor::showPropertyWidget(QString devName, QString ssid) +{ + QString display = checkDisplay(); + if (m_display == display) { + m_mainWindow->showPropertyWidget(devName,ssid); + } else { + Q_EMIT showPropertyWidgetSignal(display, devName, ssid); + } +} + +//唤起新建有线连接界面 +void DbusAdaptor::showCreateWiredConnectWidget(QString devName) +{ + QString display = checkDisplay(); + if (m_display == display) { + m_mainWindow->showCreateWiredConnectWidget(devName); + } else { + Q_EMIT showCreateWiredConnectWidgetSignal(display, devName); + } +} + +//唤起加入其他无线网络界面 +void DbusAdaptor::showAddOtherWlanWidget(QString devName) +{ + QString display = checkDisplay(); + if (m_display == display) { + qDebug() << "showAddOtherWlanWidget"; + m_mainWindow->showAddOtherWlanWidget(devName); + } else { + qDebug() << display; + Q_EMIT showAddOtherWlanWidgetSignal(display, devName); + } +} + +//开启热点 +void DbusAdaptor::activeWirelessAp(const QString apName, const QString apPassword, const QString band, const QString apDevice) +{ + m_mainWindow->activeWirelessAp(apName, apPassword, band, apDevice); +} + +//断开热点 +void DbusAdaptor::deactiveWirelessAp(const QString apName, const QString uuid) +{ + m_mainWindow->deactiveWirelessAp(apName, uuid); +} + +//获取热点 +QStringList DbusAdaptor::getStoredApInfo() +{ + QStringList list; + list.clear(); + m_mainWindow->getStoredApInfo(list); + return list; +} + +//获取热点path +QString DbusAdaptor::getApConnectionPath(QString uuid) +{ + QString path; + path.clear(); + m_mainWindow->getApConnectionPath(path, uuid); + return path; +} + +//获取热点path +QString DbusAdaptor::getActiveConnectionPath(QString uuid) +{ + QString path; + path.clear(); + m_mainWindow->getActiveConnectionPath(path, uuid); + return path; +} + +QStringList DbusAdaptor::getApInfoBySsid(QString devName, QString ssid) +{ + QStringList list; + list.clear(); + m_mainWindow->getApInfoBySsid(devName, ssid, list); + return list; +} + +void DbusAdaptor::showKylinNM(int type) +{ + qDebug() << "display" << checkDisplay(); + QString display = checkDisplay(); + if (m_display == display) { + m_mainWindow->onShowMainWindow(type); + } else { + + Q_EMIT showKylinNMSignal(display, type); + } +} + +//扫描 +void DbusAdaptor::reScan() +{ + m_mainWindow->rescan(); +} + +void DbusAdaptor::keyRingInit() +{ + m_mainWindow->keyRingInit(); +} + +void DbusAdaptor::keyRingClear() +{ + m_mainWindow->keyRingClear(); +} + +void DbusAdaptor::connectToMainwindow() +{ + connect(m_mainWindow, &MainWindow::lanAdd, this, &DbusAdaptor::lanAdd); + connect(m_mainWindow, &MainWindow::lanRemove, this, &DbusAdaptor::lanRemove); + connect(m_mainWindow, &MainWindow::lanUpdate, this, &DbusAdaptor::lanUpdate); + connect(m_mainWindow, &MainWindow::wlanAdd, this, &DbusAdaptor::wlanAdd); + connect(m_mainWindow, &MainWindow::wlanRemove, this, &DbusAdaptor::wlanRemove); + connect(m_mainWindow, &MainWindow::wlanactiveConnectionStateChanged, this, &DbusAdaptor::wlanactiveConnectionStateChanged); + connect(m_mainWindow, &MainWindow::lanActiveConnectionStateChanged, this, &DbusAdaptor::lanActiveConnectionStateChanged); + connect(m_mainWindow, &MainWindow::activateFailed, this, &DbusAdaptor::activateFailed); + connect(m_mainWindow, &MainWindow::deactivateFailed, this, &DbusAdaptor::deactivateFailed); + connect(m_mainWindow, &MainWindow::deviceStatusChanged, this, &DbusAdaptor::deviceStatusChanged); + connect(m_mainWindow, &MainWindow::wirelessDeviceStatusChanged, this, &DbusAdaptor::wirelessDeviceStatusChanged); + connect(m_mainWindow, &MainWindow::deviceNameChanged, this, &DbusAdaptor::deviceNameChanged); + connect(m_mainWindow, &MainWindow::wirelessSwitchBtnChanged, this, &DbusAdaptor::wirelessSwitchBtnChanged); + connect(m_mainWindow, &MainWindow::hotspotDeactivated, this, &DbusAdaptor::hotspotDeactivated); + connect(m_mainWindow, &MainWindow::hotspotActivated, this, &DbusAdaptor::hotspotActivated); + connect(m_mainWindow, &MainWindow::signalStrengthChange, this, &DbusAdaptor::signalStrengthChange); + connect(m_mainWindow, &MainWindow::secuTypeChange, this, &DbusAdaptor::secuTypeChange); + connect(m_mainWindow, &MainWindow::timeToUpdate, this, &DbusAdaptor::timeToUpdate); +} + +QString DbusAdaptor::checkDisplay() +{ + uint pid = 0; + QDBusReply pidReply = connection().interface()->servicePid(message().service()); + qDebug() << "caller pid: " << pidReply.value(); + if(pidReply.isValid()) { + pid = pidReply.value(); + } else { + return {}; + } + return displayFromPid(pid);; +} + +QString DbusAdaptor::displayFromPid(uint pid) +{ + QFile environFile(QStringLiteral("/proc/%1/environ").arg(QString::number(pid))); + if (environFile.open(QIODevice::ReadOnly | QIODevice::Text)) { + const QByteArray DISPLAY = qApp->property("sessionType").toString() == "wayland" ? QByteArrayLiteral("WAYLAND_DISPLAY") + : QByteArrayLiteral("DISPLAY"); + const auto lines = environFile.readAll().split('\0'); + for (const QByteArray &line : lines) { + const int equalsIdx = line.indexOf('='); + if (equalsIdx <= 0) { + continue; + } + const QByteArray key = line.left(equalsIdx); + if (key == DISPLAY) { + const QByteArray value = line.mid(equalsIdx + 1); + return value; + } + } + } + return {}; +} + diff --git a/src/backend/dbusadaptor.h b/src/backend/dbus.h similarity index 78% rename from src/backend/dbusadaptor.h rename to src/backend/dbus.h index 7315f0d3..87add6d5 100644 --- a/src/backend/dbusadaptor.h +++ b/src/backend/dbus.h @@ -15,6 +15,8 @@ #include #include #include +#include "dbus_adaptor.h" +#include "dbus_interface.h" #include "tabpage.h" #include "../dbus-interface/kylinnetworkdeviceresource.h" @@ -34,23 +36,19 @@ QT_END_NAMESPACE #include "mainwindow.h" -class DbusAdaptor: public QDBusAbstractAdaptor +class DbusAdaptor: public QObject, protected QDBusContext { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "com.kylin.network") public: - DbusAdaptor(MainWindow *parent); - virtual ~DbusAdaptor(); - - inline MainWindow *parent() const - { return static_cast(QObject::parent()); } + explicit DbusAdaptor(QString display, MainWindow *m, QObject *parent = nullptr); public: // PROPERTIES public Q_SLOTS: // METHODS //无线列表 - QMap > getWirelessList(); + QVariantList getWirelessList(QString devName); //有线列表 - QMap> getWiredList(); + QVariantList getWiredList(QString devName); //有线总开关 Q_NOREPLY void setWiredSwitchEnable(bool enable); //无线总开关 @@ -69,9 +67,9 @@ public Q_SLOTS: // METHODS //断开连接 根据网卡类型 参数1 0:lan 1:wlan 参数3 为ssid/uuid Q_NOREPLY void deActivateConnect(int type, QString devName, QString ssid); //获取设备列表和启用/禁用状态 - QMap getDeviceListAndEnabled(int devType); + QVariantMap getDeviceListAndEnabled(int devType); //获取无线设备能力 - QMap getWirelessDeviceCap(); + QVariantMap getWirelessDeviceCap(); //唤起属性页 根据网卡类型 参数2 为ssid/uuid Q_NOREPLY void showPropertyWidget(QString devName, QString ssid); //唤起新建有线连接界面 @@ -125,6 +123,29 @@ Q_SIGNALS: // SIGNALS void secuTypeChange(QString devName, QString ssid, QString secuType); //列表排序 void timeToUpdate(); + + + + void showKylinNMSignal(QString display, int type); + + //唤起属性页 根据网卡类型 参数2 为ssid/uuid + void showPropertyWidgetSignal(QString display, QString devName, QString ssid); + //唤起新建有线连接界面 + void showCreateWiredConnectWidgetSignal(QString display, QString devName); + //唤起加入其他无线网络界面 + void showAddOtherWlanWidgetSignal(QString display, QString devName); + +private: + MainWindow *m_mainWindow; + QString m_display; + QDBusServiceWatcher *m_watcher = nullptr; + + QString checkDisplay(); + QString displayFromPid(uint pid); + void connectToMainwindow(); + bool registerService(); +private Q_SLOT: + void onServiceOwnerChanged(const QString &service, const QString &oldOwner, const QString &newOwner); }; #endif diff --git a/src/backend/dbus.xml b/src/backend/dbus.xml new file mode 100644 index 00000000..59d36c32 --- /dev/null +++ b/src/backend/dbus.xml @@ -0,0 +1,186 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/backend/dbus_adaptor.cpp b/src/backend/dbus_adaptor.cpp new file mode 100644 index 00000000..56e99012 --- /dev/null +++ b/src/backend/dbus_adaptor.cpp @@ -0,0 +1,191 @@ +/* + * This file was generated by qdbusxml2cpp version 0.8 + * Command line was: qdbusxml2cpp dbus.xml -a dbus_adaptor + * + * qdbusxml2cpp is Copyright (C) 2020 The Qt Company Ltd. + * + * This is an auto-generated file. + * Do not edit! All changes made to it will be lost. + */ + +#include "dbus_adaptor.h" +#include +#include +#include +#include +#include +#include +#include + +/* + * Implementation of adaptor class NetworkAdaptor + */ + +NetworkAdaptor::NetworkAdaptor(QObject *parent) + : QDBusAbstractAdaptor(parent) +{ + // constructor + setAutoRelaySignals(true); +} + +NetworkAdaptor::~NetworkAdaptor() +{ + // destructor +} + +void NetworkAdaptor::activateConnect(int type, const QString &devName, const QString &ssid) +{ + // handle method call com.kylin.network.activateConnect + QMetaObject::invokeMethod(parent(), "activateConnect", Q_ARG(int, type), Q_ARG(QString, devName), Q_ARG(QString, ssid)); +} + +void NetworkAdaptor::activeWirelessAp(const QString &apName, const QString &apPassword, const QString &band, const QString &apDevice) +{ + // handle method call com.kylin.network.activeWirelessAp + QMetaObject::invokeMethod(parent(), "activeWirelessAp", Q_ARG(QString, apName), Q_ARG(QString, apPassword), Q_ARG(QString, band), Q_ARG(QString, apDevice)); +} + +void NetworkAdaptor::deActivateConnect(int type, const QString &devName, const QString &ssid) +{ + // handle method call com.kylin.network.deActivateConnect + QMetaObject::invokeMethod(parent(), "deActivateConnect", Q_ARG(int, type), Q_ARG(QString, devName), Q_ARG(QString, ssid)); +} + +void NetworkAdaptor::deactiveWirelessAp(const QString &apName, const QString &uuid) +{ + // handle method call com.kylin.network.deactiveWirelessAp + QMetaObject::invokeMethod(parent(), "deactiveWirelessAp", Q_ARG(QString, apName), Q_ARG(QString, uuid)); +} + +QString NetworkAdaptor::getActiveConnectionPath(const QString &uuid) +{ + // handle method call com.kylin.network.getActiveConnectionPath + QString out0; + QMetaObject::invokeMethod(parent(), "getActiveConnectionPath", Q_RETURN_ARG(QString, out0), Q_ARG(QString, uuid)); + return out0; +} + +QString NetworkAdaptor::getApConnectionPath(const QString &uuid) +{ + // handle method call com.kylin.network.getApConnectionPath + QString out0; + QMetaObject::invokeMethod(parent(), "getApConnectionPath", Q_RETURN_ARG(QString, out0), Q_ARG(QString, uuid)); + return out0; +} + +QStringList NetworkAdaptor::getApInfoBySsid(const QString &devName, const QString &ssid) +{ + // handle method call com.kylin.network.getApInfoBySsid + QStringList out0; + QMetaObject::invokeMethod(parent(), "getApInfoBySsid", Q_RETURN_ARG(QStringList, out0), Q_ARG(QString, devName), Q_ARG(QString, ssid)); + return out0; +} + +QVariantMap NetworkAdaptor::getDeviceListAndEnabled(int devType) +{ + // handle method call com.kylin.network.getDeviceListAndEnabled + QVariantMap out0; + QMetaObject::invokeMethod(parent(), "getDeviceListAndEnabled", Q_RETURN_ARG(QVariantMap, out0), Q_ARG(int, devType)); + return out0; +} + +QStringList NetworkAdaptor::getStoredApInfo() +{ + // handle method call com.kylin.network.getStoredApInfo + QStringList out0; + QMetaObject::invokeMethod(parent(), "getStoredApInfo", Q_RETURN_ARG(QStringList, out0)); + return out0; +} + +QVariantList NetworkAdaptor::getWiredList(const QString &devName) +{ + // handle method call com.kylin.network.getWiredList + QVariantList out0; + QMetaObject::invokeMethod(parent(), "getWiredList", Q_RETURN_ARG(QVariantList, out0), Q_ARG(QString, devName)); + return out0; +} + +QVariantMap NetworkAdaptor::getWirelessDeviceCap() +{ + // handle method call com.kylin.network.getWirelessDeviceCap + QVariantMap out0; + QMetaObject::invokeMethod(parent(), "getWirelessDeviceCap", Q_RETURN_ARG(QVariantMap, out0)); + return out0; +} + +QVariantList NetworkAdaptor::getWirelessList(const QString &devName) +{ + // handle method call com.kylin.network.getWirelessList + QVariantList out0; + QMetaObject::invokeMethod(parent(), "getWirelessList", Q_RETURN_ARG(QVariantList, out0), Q_ARG(QString, devName)); + return out0; +} + +bool NetworkAdaptor::getWirelessSwitchBtnState() +{ + // handle method call com.kylin.network.getWirelessSwitchBtnState + bool out0; + QMetaObject::invokeMethod(parent(), "getWirelessSwitchBtnState", Q_RETURN_ARG(bool, out0)); + return out0; +} + +void NetworkAdaptor::keyRingClear() +{ + // handle method call com.kylin.network.keyRingClear + QMetaObject::invokeMethod(parent(), "keyRingClear"); +} + +void NetworkAdaptor::keyRingInit() +{ + // handle method call com.kylin.network.keyRingInit + QMetaObject::invokeMethod(parent(), "keyRingInit"); +} + +void NetworkAdaptor::reScan() +{ + // handle method call com.kylin.network.reScan + QMetaObject::invokeMethod(parent(), "reScan"); +} + +void NetworkAdaptor::setDeviceEnable(const QString &devName, bool enable) +{ + // handle method call com.kylin.network.setDeviceEnable + QMetaObject::invokeMethod(parent(), "setDeviceEnable", Q_ARG(QString, devName), Q_ARG(bool, enable)); +} + +void NetworkAdaptor::setWiredSwitchEnable(bool enable) +{ + // handle method call com.kylin.network.setWiredSwitchEnable + QMetaObject::invokeMethod(parent(), "setWiredSwitchEnable", Q_ARG(bool, enable)); +} + +void NetworkAdaptor::setWirelessSwitchEnable(bool enable) +{ + // handle method call com.kylin.network.setWirelessSwitchEnable + QMetaObject::invokeMethod(parent(), "setWirelessSwitchEnable", Q_ARG(bool, enable)); +} + +void NetworkAdaptor::showAddOtherWlanWidget(const QString &devName) +{ + // handle method call com.kylin.network.showAddOtherWlanWidget + QMetaObject::invokeMethod(parent(), "showAddOtherWlanWidget", Q_ARG(QString, devName)); +} + +void NetworkAdaptor::showCreateWiredConnectWidget(const QString &devName) +{ + // handle method call com.kylin.network.showCreateWiredConnectWidget + QMetaObject::invokeMethod(parent(), "showCreateWiredConnectWidget", Q_ARG(QString, devName)); +} + +void NetworkAdaptor::showKylinNM(int type) +{ + // handle method call com.kylin.network.showKylinNM + QMetaObject::invokeMethod(parent(), "showKylinNM", Q_ARG(int, type)); +} + +void NetworkAdaptor::showPropertyWidget(const QString &devName, const QString &ssid) +{ + // handle method call com.kylin.network.showPropertyWidget + QMetaObject::invokeMethod(parent(), "showPropertyWidget", Q_ARG(QString, devName), Q_ARG(QString, ssid)); +} + diff --git a/src/backend/dbus_adaptor.h b/src/backend/dbus_adaptor.h new file mode 100644 index 00000000..e562a2d3 --- /dev/null +++ b/src/backend/dbus_adaptor.h @@ -0,0 +1,266 @@ +/* + * This file was generated by qdbusxml2cpp version 0.8 + * Command line was: qdbusxml2cpp dbus.xml -a dbus_adaptor + * + * qdbusxml2cpp is Copyright (C) 2020 The Qt Company Ltd. + * + * This is an auto-generated file. + * This file may have been hand-edited. Look for HAND-EDIT comments + * before re-generating it. + */ + +#ifndef DBUS_ADAPTOR_H +#define DBUS_ADAPTOR_H + +#include +#include +QT_BEGIN_NAMESPACE +class QByteArray; +template class QList; +template class QMap; +class QString; +class QStringList; +class QVariant; +QT_END_NAMESPACE + +/* + * Adaptor class for interface com.kylin.network + */ +class NetworkAdaptor: public QDBusAbstractAdaptor +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "com.kylin.network") + Q_CLASSINFO("D-Bus Introspection", "" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" + "") +public: + NetworkAdaptor(QObject *parent); + virtual ~NetworkAdaptor(); + +public: // PROPERTIES +public Q_SLOTS: // METHODS + Q_NOREPLY void activateConnect(int type, const QString &devName, const QString &ssid); + void activeWirelessAp(const QString &apName, const QString &apPassword, const QString &band, const QString &apDevice); + Q_NOREPLY void deActivateConnect(int type, const QString &devName, const QString &ssid); + void deactiveWirelessAp(const QString &apName, const QString &uuid); + QString getActiveConnectionPath(const QString &uuid); + QString getApConnectionPath(const QString &uuid); + QStringList getApInfoBySsid(const QString &devName, const QString &ssid); + QVariantMap getDeviceListAndEnabled(int devType); + QStringList getStoredApInfo(); + QVariantList getWiredList(const QString &devName); + QVariantMap getWirelessDeviceCap(); + QVariantList getWirelessList(const QString &devName); + bool getWirelessSwitchBtnState(); + void keyRingClear(); + void keyRingInit(); + void reScan(); + Q_NOREPLY void setDeviceEnable(const QString &devName, bool enable); + Q_NOREPLY void setWiredSwitchEnable(bool enable); + Q_NOREPLY void setWirelessSwitchEnable(bool enable); + Q_NOREPLY void showAddOtherWlanWidget(const QString &devName); + Q_NOREPLY void showCreateWiredConnectWidget(const QString &devName); + void showKylinNM(int type); + Q_NOREPLY void showPropertyWidget(const QString &devName, const QString &ssid); +Q_SIGNALS: // SIGNALS + void activateFailed(const QString &errorMessage); + void deactivateFailed(const QString &errorMessage); + void deviceNameChanged(const QString &oldName, const QString &newName, int type); + void deviceStatusChanged(); + void hotspotActivated(const QString &devName, const QString &ssid, const QString &uuid, const QString &activePath, const QString &settingPath); + void hotspotDeactivated(const QString &devName, const QString &ssid); + void lanActiveConnectionStateChanged(const QString &devName, const QString &uuid, int status); + void lanAdd(const QString &devName, const QStringList &info); + void lanRemove(const QString &dbusPath); + void lanUpdate(const QString &devName, const QStringList &info); + void secuTypeChange(const QString &devName, const QString &ssid, const QString &secuType); + void showAddOtherWlanWidgetSignal(const QString &display, const QString &devName); + void showCreateWiredConnectWidgetSignal(const QString &display, const QString &devName); + void showKylinNMSignal(const QString &display, int type); + void showPropertyWidgetSignal(const QString &display, const QString &devName, const QString &ssid); + void signalStrengthChange(const QString &devName, const QString &ssid, int strength); + void timeToUpdate(); + void wirelessDeviceStatusChanged(); + void wirelessSwitchBtnChanged(bool state); + void wlanAdd(const QString &devName, const QStringList &info); + void wlanRemove(const QString &devName, const QString &ssid); + void wlanactiveConnectionStateChanged(const QString &devName, const QString &ssid, const QString &uuid, int status); +}; + +#endif diff --git a/src/backend/dbus_interface.cpp b/src/backend/dbus_interface.cpp new file mode 100644 index 00000000..1f04e21e --- /dev/null +++ b/src/backend/dbus_interface.cpp @@ -0,0 +1,26 @@ +/* + * This file was generated by qdbusxml2cpp version 0.8 + * Command line was: qdbusxml2cpp dbus.xml -p dbus_interface + * + * qdbusxml2cpp is Copyright (C) 2020 The Qt Company Ltd. + * + * This is an auto-generated file. + * This file may have been hand-edited. Look for HAND-EDIT comments + * before re-generating it. + */ + +#include "dbus_interface.h" + +/* + * Implementation of interface class ComKylinNetworkInterface + */ + +ComKylinNetworkInterface::ComKylinNetworkInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) + : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) +{ +} + +ComKylinNetworkInterface::~ComKylinNetworkInterface() +{ +} + diff --git a/src/backend/dbus_interface.h b/src/backend/dbus_interface.h new file mode 100644 index 00000000..f8a73c64 --- /dev/null +++ b/src/backend/dbus_interface.h @@ -0,0 +1,224 @@ +/* + * This file was generated by qdbusxml2cpp version 0.8 + * Command line was: qdbusxml2cpp dbus.xml -p dbus_interface + * + * qdbusxml2cpp is Copyright (C) 2020 The Qt Company Ltd. + * + * This is an auto-generated file. + * Do not edit! All changes made to it will be lost. + */ + +#ifndef DBUS_INTERFACE_H +#define DBUS_INTERFACE_H + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Proxy class for interface com.kylin.network + */ +class ComKylinNetworkInterface: public QDBusAbstractInterface +{ + Q_OBJECT +public: + static inline const char *staticInterfaceName() + { return "com.kylin.network"; } + +public: + ComKylinNetworkInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = nullptr); + + ~ComKylinNetworkInterface(); + +public Q_SLOTS: // METHODS + inline Q_NOREPLY void activateConnect(int type, const QString &devName, const QString &ssid) + { + QList argumentList; + argumentList << QVariant::fromValue(type) << QVariant::fromValue(devName) << QVariant::fromValue(ssid); + callWithArgumentList(QDBus::NoBlock, QStringLiteral("activateConnect"), argumentList); + } + + inline QDBusPendingReply<> activeWirelessAp(const QString &apName, const QString &apPassword, const QString &band, const QString &apDevice) + { + QList argumentList; + argumentList << QVariant::fromValue(apName) << QVariant::fromValue(apPassword) << QVariant::fromValue(band) << QVariant::fromValue(apDevice); + return asyncCallWithArgumentList(QStringLiteral("activeWirelessAp"), argumentList); + } + + inline Q_NOREPLY void deActivateConnect(int type, const QString &devName, const QString &ssid) + { + QList argumentList; + argumentList << QVariant::fromValue(type) << QVariant::fromValue(devName) << QVariant::fromValue(ssid); + callWithArgumentList(QDBus::NoBlock, QStringLiteral("deActivateConnect"), argumentList); + } + + inline QDBusPendingReply<> deactiveWirelessAp(const QString &apName, const QString &uuid) + { + QList argumentList; + argumentList << QVariant::fromValue(apName) << QVariant::fromValue(uuid); + return asyncCallWithArgumentList(QStringLiteral("deactiveWirelessAp"), argumentList); + } + + inline QDBusPendingReply getActiveConnectionPath(const QString &uuid) + { + QList argumentList; + argumentList << QVariant::fromValue(uuid); + return asyncCallWithArgumentList(QStringLiteral("getActiveConnectionPath"), argumentList); + } + + inline QDBusPendingReply getApConnectionPath(const QString &uuid) + { + QList argumentList; + argumentList << QVariant::fromValue(uuid); + return asyncCallWithArgumentList(QStringLiteral("getApConnectionPath"), argumentList); + } + + inline QDBusPendingReply getApInfoBySsid(const QString &devName, const QString &ssid) + { + QList argumentList; + argumentList << QVariant::fromValue(devName) << QVariant::fromValue(ssid); + return asyncCallWithArgumentList(QStringLiteral("getApInfoBySsid"), argumentList); + } + + inline QDBusPendingReply getDeviceListAndEnabled(int devType) + { + QList argumentList; + argumentList << QVariant::fromValue(devType); + return asyncCallWithArgumentList(QStringLiteral("getDeviceListAndEnabled"), argumentList); + } + + inline QDBusPendingReply getStoredApInfo() + { + QList argumentList; + return asyncCallWithArgumentList(QStringLiteral("getStoredApInfo"), argumentList); + } + + inline QDBusPendingReply getWiredList(const QString &devName) + { + QList argumentList; + argumentList << QVariant::fromValue(devName); + return asyncCallWithArgumentList(QStringLiteral("getWiredList"), argumentList); + } + + inline QDBusPendingReply getWirelessDeviceCap() + { + QList argumentList; + return asyncCallWithArgumentList(QStringLiteral("getWirelessDeviceCap"), argumentList); + } + + inline QDBusPendingReply getWirelessList(const QString &devName) + { + QList argumentList; + argumentList << QVariant::fromValue(devName); + return asyncCallWithArgumentList(QStringLiteral("getWirelessList"), argumentList); + } + + inline QDBusPendingReply getWirelessSwitchBtnState() + { + QList argumentList; + return asyncCallWithArgumentList(QStringLiteral("getWirelessSwitchBtnState"), argumentList); + } + + inline QDBusPendingReply<> keyRingClear() + { + QList argumentList; + return asyncCallWithArgumentList(QStringLiteral("keyRingClear"), argumentList); + } + + inline QDBusPendingReply<> keyRingInit() + { + QList argumentList; + return asyncCallWithArgumentList(QStringLiteral("keyRingInit"), argumentList); + } + + inline QDBusPendingReply<> reScan() + { + QList argumentList; + return asyncCallWithArgumentList(QStringLiteral("reScan"), argumentList); + } + + inline Q_NOREPLY void setDeviceEnable(const QString &devName, bool enable) + { + QList argumentList; + argumentList << QVariant::fromValue(devName) << QVariant::fromValue(enable); + callWithArgumentList(QDBus::NoBlock, QStringLiteral("setDeviceEnable"), argumentList); + } + + inline Q_NOREPLY void setWiredSwitchEnable(bool enable) + { + QList argumentList; + argumentList << QVariant::fromValue(enable); + callWithArgumentList(QDBus::NoBlock, QStringLiteral("setWiredSwitchEnable"), argumentList); + } + + inline Q_NOREPLY void setWirelessSwitchEnable(bool enable) + { + QList argumentList; + argumentList << QVariant::fromValue(enable); + callWithArgumentList(QDBus::NoBlock, QStringLiteral("setWirelessSwitchEnable"), argumentList); + } + + inline Q_NOREPLY void showAddOtherWlanWidget(const QString &devName) + { + QList argumentList; + argumentList << QVariant::fromValue(devName); + callWithArgumentList(QDBus::NoBlock, QStringLiteral("showAddOtherWlanWidget"), argumentList); + } + + inline Q_NOREPLY void showCreateWiredConnectWidget(const QString &devName) + { + QList argumentList; + argumentList << QVariant::fromValue(devName); + callWithArgumentList(QDBus::NoBlock, QStringLiteral("showCreateWiredConnectWidget"), argumentList); + } + + inline QDBusPendingReply<> showKylinNM(int type) + { + QList argumentList; + argumentList << QVariant::fromValue(type); + return asyncCallWithArgumentList(QStringLiteral("showKylinNM"), argumentList); + } + + inline Q_NOREPLY void showPropertyWidget(const QString &devName, const QString &ssid) + { + QList argumentList; + argumentList << QVariant::fromValue(devName) << QVariant::fromValue(ssid); + callWithArgumentList(QDBus::NoBlock, QStringLiteral("showPropertyWidget"), argumentList); + } + +Q_SIGNALS: // SIGNALS + void activateFailed(const QString &errorMessage); + void deactivateFailed(const QString &errorMessage); + void deviceNameChanged(const QString &oldName, const QString &newName, int type); + void deviceStatusChanged(); + void hotspotActivated(const QString &devName, const QString &ssid, const QString &uuid, const QString &activePath, const QString &settingPath); + void hotspotDeactivated(const QString &devName, const QString &ssid); + void lanActiveConnectionStateChanged(const QString &devName, const QString &uuid, int status); + void lanAdd(const QString &devName, const QStringList &info); + void lanRemove(const QString &dbusPath); + void lanUpdate(const QString &devName, const QStringList &info); + void secuTypeChange(const QString &devName, const QString &ssid, const QString &secuType); + void showAddOtherWlanWidgetSignal(const QString &display, const QString &devName); + void showCreateWiredConnectWidgetSignal(const QString &display, const QString &devName); + void showKylinNMSignal(const QString &display, int type); + void showPropertyWidgetSignal(const QString &display, const QString &devName, const QString &ssid); + void signalStrengthChange(const QString &devName, const QString &ssid, int strength); + void timeToUpdate(); + void wirelessDeviceStatusChanged(); + void wirelessSwitchBtnChanged(bool state); + void wlanAdd(const QString &devName, const QStringList &info); + void wlanRemove(const QString &devName, const QString &ssid); + void wlanactiveConnectionStateChanged(const QString &devName, const QString &ssid, const QString &uuid, int status); +}; + +namespace com { + namespace kylin { + typedef ::ComKylinNetworkInterface network; + } +} +#endif diff --git a/src/frontend/connectivity/connectivity.pri b/src/frontend/connectivity/connectivity.pri new file mode 100644 index 00000000..cfbdbcb6 --- /dev/null +++ b/src/frontend/connectivity/connectivity.pri @@ -0,0 +1,9 @@ +INCLUDEPATH += $$PWD + +FORMS += \ + +HEADERS += \ + $$PWD/connectivitypage.h \ + +SOURCES += \ + $$PWD/connectivitypage.cpp \ diff --git a/src/frontend/connectivity/connectivitypage.cpp b/src/frontend/connectivity/connectivitypage.cpp new file mode 100644 index 00000000..f6aa9687 --- /dev/null +++ b/src/frontend/connectivity/connectivitypage.cpp @@ -0,0 +1,205 @@ +#include "connectivitypage.h" +#include +#include +#include +#include +#include +#include + +#include "windowmanager/windowmanager.h" +#include "kwindowsystem.h" +#include "kwindowsystem_export.h" +#include "kylinutil.h" + +#define THEME_SCHAME "org.ukui.style" +#define COLOR_THEME "styleName" + +#define BOTTOM_LAYOUT_MARGINS 24, 16, 24, 24 +#define LAYOUT_SPACING 16 + +ConnectivityPage::ConnectivityPage(QString uri, QWidget *parent) + :m_uri(uri), QDialog(parent) +{ + this->setAttribute(Qt::WA_DeleteOnClose, true); + this->setFixedSize(380, 369); + this->setWindowTitle(tr("Network connectivity detection")); + setAttribute(Qt::WA_DeleteOnClose, false); + KWindowSystem::setState(this->winId(), NET::SkipTaskbar | NET::SkipPager); + m_connectResource = new KyConnectResourse(this); + initUi(); + initConnect(); + NetworkManager::Connectivity connectivity; + m_connectResource->getConnectivity(connectivity); + setWarning(connectivity); + m_publicNetworkButton->setChecked(m_uri.isEmpty()); + m_intranetButton->setChecked(!m_uri.isEmpty()); + if (!m_uri.isEmpty()) { + checkUri(); + } +} + +void ConnectivityPage::initUi() +{ + m_scrollArea = new QScrollArea(this); + m_scrollArea->setFixedWidth(380); + m_scrollArea->setFrameShape(QFrame::NoFrame); + m_scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + m_scrollArea->setContentsMargins(0,0,0,0); + + m_icon = new QLabel(this); + m_statusText = new QLabel(this); + m_statusText->setWordWrap(true); + + //如访问 Internet 受限,请切换网络 IP 连通性检测方式后再试。 + m_text = new QLabel(this); + m_text->setText(tr("If access to the Internet is restricted, please switch the network IP connectivity detection method and try again.")); + m_text->setWordWrap(true); + m_text->adjustSize(); +// m_text->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + + m_publicNetworkButton = new QRadioButton(this); + m_publicNetworkButton->setText(tr("Public network (default)")); + m_intranetButton = new QRadioButton(this); + m_intranetButton->setText(tr("Local area network (intranet)")); + + m_uriEdit = new QLineEdit(this); + m_uriEdit->setText(m_uri); + m_warningLabel = new QLabel(this); + QPalette hintTextColor; + hintTextColor.setColor(QPalette::WindowText, Qt::red); + m_warningLabel->setPalette(hintTextColor); + m_warningLabel->setWordWrap(true); + + m_confirmBtn = new QPushButton(this); + m_confirmBtn->setText(tr("Confirm")); + + m_warningWidget = new QWidget(this); + m_warningWidget->adjustSize(); + m_editWidget = new QWidget(this); + m_centerWidget = new QWidget(this); + m_centerWidget->setFixedWidth(380); + m_bottomWidget = new QWidget(this); + + QHBoxLayout* warningLayout = new QHBoxLayout(m_warningWidget); + warningLayout->setContentsMargins(0, 0, 0, 24); + warningLayout->setSpacing(8); + warningLayout->addWidget(m_icon); + warningLayout->addWidget(m_statusText); + warningLayout->addStretch(); + + QVBoxLayout* editLayout = new QVBoxLayout(m_editWidget); + editLayout->setContentsMargins(22,0,0,0); + editLayout->setSpacing(0); + editLayout->addWidget(m_uriEdit); + editLayout->addWidget(m_warningLabel); + + QVBoxLayout* mainLayout = new QVBoxLayout(this); + mainLayout->setContentsMargins(0,0,0,0); + mainLayout->setSpacing(0); + mainLayout->addWidget(m_scrollArea); + mainLayout->addWidget(m_bottomWidget); + this->setLayout(mainLayout); + + //中间页面 + QVBoxLayout *vLayout = new QVBoxLayout(m_centerWidget); + vLayout->setContentsMargins(25, 17, 23, 0); + vLayout->setSpacing(0); + vLayout->addWidget(m_warningWidget); + vLayout->addWidget(m_text); + vLayout->addSpacing(10); + vLayout->addWidget(m_publicNetworkButton); + vLayout->addSpacing(12); + vLayout->addWidget(m_intranetButton); + vLayout->addWidget(m_editWidget); + + //底部按钮 + QHBoxLayout* bottomLayout = new QHBoxLayout(m_bottomWidget); + bottomLayout->setContentsMargins(BOTTOM_LAYOUT_MARGINS); + bottomLayout->setSpacing(LAYOUT_SPACING); + bottomLayout->addStretch(); + bottomLayout->addWidget(m_confirmBtn); + + m_scrollArea->setWidget(m_centerWidget); + m_scrollArea->setWidgetResizable(true); + + this->setWindowFlags(Qt::Dialog); +} + +void ConnectivityPage::initConnect() +{ + connect(m_confirmBtn, &QPushButton::released, this, [=](){ + if (m_publicNetworkButton->isChecked()) { + setConnectivityCheckSpareUriByGDbus(""); + } else { + setConnectivityCheckSpareUriByGDbus(m_uriEdit->text()); + } + close(); + }); + connect(m_publicNetworkButton, &QRadioButton::toggled, [&](bool checked){ + if (checked) { + m_uriEdit->clear(); + m_uriEdit->setDisabled(true); + m_confirmBtn->setEnabled(true); + } + }); + connect(m_intranetButton, &QRadioButton::toggled, [&](bool checked){ + if (checked) { + checkUri(); + m_uriEdit->setDisabled(false); + m_uriEdit->setFocus(); + } + }); + connect(m_uriEdit, &QLineEdit::textChanged, this ,&ConnectivityPage::checkUri); + connect(m_connectResource, &KyConnectResourse::connectivityChanged, this, &ConnectivityPage::setWarning); +} + +void ConnectivityPage::setWarning(NetworkManager::Connectivity connectivity) +{ + if (NetworkManager::Connectivity::Full == connectivity) { + //网络已连接,可正常访问 Internet 。 + m_icon->setPixmap(QIcon::fromTheme("ukui-dialog-success").pixmap(16,16)); + m_statusText->setText(tr("The network is connected and can access the Internet normally.")); + } else if (NetworkManager::Connectivity::Limited == connectivity + || NetworkManager::Connectivity::Portal == connectivity) { + //网络已连接,访问 Internet 受限。 + m_icon->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(16,16)); + m_statusText->setText(tr("The network is connected and access to the Internet is restricted.")); + } else { + qWarning() << "network status is " << connectivity << "should not show this page"; + } +} + +void ConnectivityPage::checkUri() +{ + QString text = m_uriEdit->text(); //locationbar input data + if (text.isEmpty()) { + m_confirmBtn->setEnabled(false); + m_warningLabel->setText(tr("Please enter the local area network (intranet) detection address")); + m_warningLabel->show(); + return; + } + int pos = 0; + + QRegExp rx; + //url regular expression + rx.setPattern("(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]"); + QRegExpValidator rv; + rv.setRegExp(rx); + //Test for a match between the url and the regular expression + QValidator::State rvState = rv.validate(text, pos); + if (rvState == QValidator::Acceptable) { + m_confirmBtn->setEnabled(true); + m_warningLabel->clear(); + m_warningLabel->hide(); + } else { + m_confirmBtn->setEnabled(false); + m_warningLabel->setText(tr("Format error")); + m_warningLabel->show(); + } +} + +void ConnectivityPage::closeEvent(QCloseEvent *event) +{ + Q_EMIT pageClose(); + return QWidget::closeEvent(event); +} diff --git a/src/frontend/connectivity/connectivitypage.h b/src/frontend/connectivity/connectivitypage.h new file mode 100644 index 00000000..df2b3294 --- /dev/null +++ b/src/frontend/connectivity/connectivitypage.h @@ -0,0 +1,55 @@ +#ifndef CONNECTIVITYPAGE_H +#define CONNECTIVITYPAGE_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "divider.h" +#include "kylinconnectresource.h" + +class ConnectivityPage : public QDialog +{ + Q_OBJECT +public: + explicit ConnectivityPage(QString uri = "", QWidget *parent = nullptr); + +protected: + void closeEvent(QCloseEvent *event); + +private: + QScrollArea *m_scrollArea; + QWidget* m_warningWidget; + QWidget* m_centerWidget; + QWidget* m_editWidget; + QWidget* m_bottomWidget; + + QString m_uri; + QPushButton *m_confirmBtn; + QLabel *m_icon; + QLabel *m_statusText; + QLabel *m_text; + QRadioButton *m_publicNetworkButton; + QRadioButton *m_intranetButton; + QLineEdit *m_uriEdit; + QLabel* m_warningLabel; + + KyConnectResourse* m_connectResource; + + void initUi(); + void initConnect(); + +private Q_SLOTS: + void setWarning(NetworkManager::Connectivity connectivity); + void checkUri(); + +Q_SIGNALS: + void pageClose(); +}; + +#endif // CONNECTIVITYPAGE_H diff --git a/src/frontend/frontend.pri b/src/frontend/frontend.pri index 324799cc..f9ae6e00 100644 --- a/src/frontend/frontend.pri +++ b/src/frontend/frontend.pri @@ -5,6 +5,7 @@ include(tab-pages/tab-pages.pri) include(list-items/list-items.pri) include(netdetails/netdetails.pri) include(enterprise-wlan/enterprise-wlan.pri) +include(connectivity/connectivity.pri) include(networkmode/networkmode.pri) FORMS += diff --git a/src/frontend/list-items/wlanlistitem.cpp b/src/frontend/list-items/wlanlistitem.cpp index bcd5aca7..f4eaac96 100644 --- a/src/frontend/list-items/wlanlistitem.cpp +++ b/src/frontend/list-items/wlanlistitem.cpp @@ -253,6 +253,18 @@ void WlanListItem::keyPressEvent(QKeyEvent *event) return QFrame::keyPressEvent(event); } +void WlanListItem::paintEvent(QPaintEvent *event) +{ + QPalette pal = this->palette(); + if (m_pwdLineEdit != nullptr) { + pal.setColor(QPalette::Base, pal.color(QPalette::Base)); + pal.setColor(QPalette::Text, pal.color(QPalette::Text)); + m_pwdLineEdit->setPalette(pal); + } + + return QWidget::paintEvent(event); +} + void WlanListItem::initWlanUI() { m_hasPwd = (m_wirelessNetItem.m_secuType.isEmpty() || m_wirelessNetItem.m_secuType == "") ? false : true; diff --git a/src/frontend/list-items/wlanlistitem.h b/src/frontend/list-items/wlanlistitem.h index 21b65ce0..12113488 100644 --- a/src/frontend/list-items/wlanlistitem.h +++ b/src/frontend/list-items/wlanlistitem.h @@ -91,6 +91,7 @@ protected: void leaveEvent(QEvent *event); bool eventFilter(QObject *watched, QEvent *event); void keyPressEvent(QKeyEvent *event); + void paintEvent(QPaintEvent *event); Q_SIGNALS: void itemHeightChanged(const bool isExpanded, const QString &ssid); diff --git a/src/frontend/mainwindow.cpp b/src/frontend/mainwindow.cpp index 78fdd72e..f5ce72e0 100644 --- a/src/frontend/mainwindow.cpp +++ b/src/frontend/mainwindow.cpp @@ -33,11 +33,13 @@ #include "ukuistylehelper/ukuistylehelper.h" #include "windowmanager/windowmanager.h" #include "kysdk/kysdk-system/libkysysinfo.h" +#include "kylinutil.h" #define MAINWINDOW_WIDTH 420 #define MAINWINDOW_HEIGHT 476 #define LAYOUT_MARGINS 0,0,0,0 #define LOADING_TRAYICON_TIMER_MS 60 +#define TABBAR_HEIGHT 30 #define THEME_SCHAME "org.ukui.style" #define COLOR_THEME "styleName" @@ -68,10 +70,16 @@ const QString intel = "V10SP1-edu"; #define LOW_SIGNAL_LIMIT_ICON "ukui-network-wireless-signal-weak-error-symbolic" #define NONE_SIGNAL_LIMIT_ICON "ukui-network-wireless-signal-none-error-symbolic" +#define EXCELLENT_SIGNAL_INTRANET_ICON "ukui-network-wireless-signal-excellent-intranet-symbolic" +#define GOOD_SIGNAL_INTRANET_ICON "ukui-network-wireless-signal-good-intranet-symbolic" +#define OK_SIGNAL_INTRANET_ICON "ukui-network-wireless-signal-ok-intranet-symbolic" +#define LOW_SIGNAL_INTRANET_ICON "ukui-network-wireless-signal-weak-intranet-symbolic" +#define NONE_SIGNAL_INTRANET_ICON "ukui-network-wireless-signal-none-intranet-symbolic" + #include #include -MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) +MainWindow::MainWindow(QString display, QWidget *parent) : QMainWindow(parent), m_display(display) { firstlyStart(); } @@ -176,6 +184,11 @@ void MainWindow::firstlyStart() //加载key ring agent_init(); + + //单网卡显示 + setCentralWidgetPages(); + connect(m_lanWidget, &LanPage::deviceStatusChanged, this, &MainWindow::setCentralWidgetPages); + connect(m_wlanWidget, &LanPage::wirelessDeviceStatusChanged, this, &MainWindow::setCentralWidgetPages); } /** @@ -367,10 +380,12 @@ void MainWindow::initTrayIcon() connect(iconTimer, &QTimer::timeout, this, &MainWindow::onSetTrayIconLoading); m_trayIconMenu = new QMenu(); - m_showMainwindowAction = new QAction(tr("Show MainWindow"),this); +// m_showMainwindowAction = new QAction(tr("Show MainWindow"),this); m_showSettingsAction = new QAction(tr("Settings"),this); + m_showConnectivityPageAction = new QAction(tr("Network Connectivity Detection"), this); m_showSettingsAction->setIcon(QIcon::fromTheme("document-page-setup-symbolic", QIcon(":/res/x/setup.png")) ); + m_showConnectivityPageAction->setIcon(QIcon::fromTheme("gnome-netstatus-txrx")); // m_trayIconMenu->addAction(m_showMainwindowAction); m_trayIconMenu->addAction(m_showSettingsAction); m_trayIcon->setContextMenu(m_trayIconMenu); @@ -380,6 +395,20 @@ void MainWindow::initTrayIcon() connect(m_trayIcon, &QSystemTrayIcon::activated, this, &MainWindow::onTrayIconActivated); // connect(m_showMainwindowAction, &QAction::triggered, this, &MainWindow::onShowMainwindowActionTriggled); connect(m_showSettingsAction, &QAction::triggered, this, &MainWindow::onShowSettingsActionTriggled); + connect(m_showConnectivityPageAction, &QAction::triggered, [=]() { + if (m_connectivityPage != nullptr) { + KWindowSystem::activateWindow(m_connectivityPage->winId()); + KWindowSystem::raiseWindow(m_connectivityPage->winId()); + return; + } + QString uri = getConnectivityCheckSpareUriByGDbus(); + m_connectivityPage = new ConnectivityPage(uri, this); + connect(m_connectivityPage, &ConnectivityPage::pageClose, [&](){ + m_connectivityPage = nullptr; + }); + m_connectivityPage->show(); + }); + m_trayIcon->show(); } @@ -417,6 +446,7 @@ void MainWindow::initDbusConnnect() connect(m_wlanWidget, &WlanPage::timeToUpdate , this, &MainWindow::onTimeUpdateTrayIcon); connect(m_wlanWidget, &WlanPage::showMainWindow, this, &MainWindow::onShowMainWindow); connect(m_wlanWidget, &WlanPage::connectivityChanged, this, &MainWindow::onConnectivityChanged); + connect(m_wlanWidget, &WlanPage::connectivityCheckSpareUriChanged, this, &MainWindow::onConnectivityCheckSpareUriChanged); connect(m_lanWidget, &LanPage::lanConnectChanged, this, &MainWindow::onRefreshTrayIconTooltip); connect(m_lanWidget, &LanPage::deviceStatusChanged, this, &MainWindow::onRefreshTrayIconTooltip); @@ -435,6 +465,27 @@ void MainWindow::initDbusConnnect() hideMainwindow(); } }); + + QDBusConnection::sessionBus().connect(QString("com.kylin.network"), + QString("/com/kylin/network"), + QString("com.kylin.network"), + QString("showKylinNMSignal"), this, SLOT(onShowKylinNMSlot(QString,int))); + + QDBusConnection::sessionBus().connect(QString("com.kylin.network"), + QString("/com/kylin/network"), + QString("com.kylin.network"), + QString("showPropertyWidgetSignal"), this, SLOT(onShowPropertyWidgetSlot(QString,QString,QString))); + + QDBusConnection::sessionBus().connect(QString("com.kylin.network"), + QString("/com/kylin/network"), + QString("com.kylin.network"), + QString("showCreateWiredConnectWidgetSignal"), this, SLOT(onShowCreateWiredConnectWidgetSlot(QString,QString))); + + QDBusConnection::sessionBus().connect(QString("com.kylin.network"), + QString("/com/kylin/network"), + QString("com.kylin.network"), + QString("showAddOtherWlanWidgetSignal"), this, SLOT(onShowAddOtherWlanWidgetSlot(QString,QString))); + } /** @@ -751,10 +802,34 @@ void MainWindow::onRefreshTrayIcon() } } + if(!getConnectivityCheckSpareUriByGDbus().isEmpty()) { + if (iconStatus == IconActiveType::LAN_CONNECTED) { + m_trayIcon->setIcon(QIcon::fromTheme("network-intranet-symbolic")); + } else if (iconStatus == IconActiveType::WLAN_CONNECTED) { + if (signalStrength > MW_EXCELLENT_SIGNAL){ + m_trayIcon->setIcon(QIcon::fromTheme(EXCELLENT_SIGNAL_INTRANET_ICON)); + } else if (signalStrength > MW_GOOD_SIGNAL) { + m_trayIcon->setIcon(QIcon::fromTheme(GOOD_SIGNAL_INTRANET_ICON)); + } else if (signalStrength > MW_OK_SIGNAL) { + m_trayIcon->setIcon(QIcon::fromTheme(OK_SIGNAL_INTRANET_ICON)); + } else if (signalStrength > MW_LOW_SIGNAL) { + m_trayIcon->setIcon(QIcon::fromTheme(LOW_SIGNAL_INTRANET_ICON)); + } else { + m_trayIcon->setIcon(QIcon::fromTheme(NONE_SIGNAL_INTRANET_ICON)); + } + } + } + if (signalStrength == -1) { m_trayIcon->setIcon(QIcon::fromTheme("network-wired-disconnected-symbolic")); } onRefreshTrayIconTooltip(); + +// if (iconStatus > IconActiveType::NOT_CONNECTED) { +// m_trayIconMenu->addAction(m_showConnectivityPageAction); +// } else { +// m_trayIconMenu->removeAction(m_showConnectivityPageAction); +// } } void MainWindow::onSetTrayIconLoading() @@ -844,8 +919,56 @@ void MainWindow::onRefreshTrayIconTooltip() m_trayIcon->setToolTip(trayIconToolTip); } +void MainWindow::setCentralWidgetPages() +{ + bool isChanged = false; + if (m_isWiredUsable != m_lanWidget->isWiredDeviceUsable()) { + if (m_lanWidget->isWiredDeviceUsable()) { + m_centralWidget->insertTab(LANPAGE, m_lanWidget, ""); + m_isWiredUsable = true; + } else { + m_centralWidget->removeTab(LANPAGE); + m_isWiredUsable = false; + } + isChanged = true; + } + + if (m_isWirelessUsable != m_wlanWidget->isWirelessDeviceUsable()) { + if (m_wlanWidget->isWirelessDeviceUsable()) { + m_centralWidget->insertTab(WLANPAGE, m_wlanWidget, ""); + m_isWirelessUsable = true; + } else { + m_centralWidget->removeTab(WLANPAGE); + m_isWirelessUsable = false; + } + isChanged = true; + } + + if (!isChanged) { + return; + } + + if (m_isWiredUsable && m_isWirelessUsable) { + m_centralWidget->tabBar()->show(); + this->setFixedHeight(MAINWINDOW_HEIGHT); + resetWindowPosition(); + } else { + m_centralWidget->tabBar()->hide(); + this->setFixedHeight(MAINWINDOW_HEIGHT - TABBAR_HEIGHT); + resetWindowPosition(); + } + + if (m_trayIcon) { + m_trayIcon->setVisible(m_isWiredUsable || m_isWirelessUsable); + } +} + void MainWindow::onShowMainWindow(int type) { + if (!m_trayIcon->isVisible()) { + qWarning() << "no valid network card, do not show kylin-nm mainwindow"; + return; + } if (type == LANPAGE || type == WLANPAGE) { m_centralWidget->setCurrentIndex(type); @@ -872,6 +995,19 @@ void MainWindow::onConnectivityChanged(NetworkManager::Connectivity connectivity onRefreshTrayIcon(); } +void MainWindow::onConnectivityCheckSpareUriChanged() +{ + if (!m_trayIcon) { + return; + } + + if (iconStatus == ACTIVATING) { + return; + } + + onRefreshTrayIcon(); +} + void MainWindow::onTimeUpdateTrayIcon() { if (!m_trayIcon) { @@ -899,13 +1035,14 @@ void MainWindow::keyPressEvent(QKeyEvent *event) /** * @brief MainWindow::getWirelessList 获取wifi列表,供dbus调用 - * @param map + * @param devName + * @param list */ -void MainWindow::getWirelessList(QMap > &map) +void MainWindow::getWirelessList(QString devName, QList &list) { - map.clear(); + list.clear(); if (nullptr != m_wlanWidget) { - m_wlanWidget->getWirelessList(map); + m_wlanWidget->getWirelessList(devName, list); } } @@ -920,11 +1057,11 @@ bool MainWindow::getWirelessSwitchBtnState() * @brief MainWindow::getWiredList 获取lan列表,供dbus调用 * @param map */ -void MainWindow::getWiredList(QMap> &map) +void MainWindow::getWiredList(QString devName, QList &list) { - map.clear(); + list.clear(); if (nullptr != m_lanWidget) { - m_lanWidget->getWiredList(map); + m_lanWidget->getWiredList(devName, list); } } @@ -1088,3 +1225,32 @@ void MainWindow::keyRingClear() { agent_clear(); } + +void MainWindow::onShowKylinNMSlot(QString display, int type) +{ + if (display == m_display) { + onShowMainWindow(type); + } +} + +//唤起属性页 根据网卡类型 参数2 为ssid/uuid +void MainWindow::onShowPropertyWidgetSlot(QString display, QString devName, QString ssid) +{ + if (display == m_display) { + showPropertyWidget(devName, ssid); + } +} +//唤起新建有线连接界面 +void MainWindow::onShowCreateWiredConnectWidgetSlot(QString display, QString devName) +{ + if (display == m_display) { + showCreateWiredConnectWidget(devName); + } +} +//唤起加入其他无线网络界面 +void MainWindow::onShowAddOtherWlanWidgetSlot(QString display, QString devName) +{ + if (display == m_display) { + showAddOtherWlanWidget(devName); + } +} diff --git a/src/frontend/mainwindow.h b/src/frontend/mainwindow.h index 1c28ba9c..832688e4 100644 --- a/src/frontend/mainwindow.h +++ b/src/frontend/mainwindow.h @@ -34,6 +34,7 @@ #include "wlanpage.h" #include "netdetails/netdetail.h" #include "netdetails/joinhiddenwifipage.h" +#include "connectivity/connectivitypage.h" //安全中心-网络防火墙模式配置 #include "networkmodeconfig.h" //删除此头文件,别在添加 @@ -47,7 +48,9 @@ enum IconActiveType { NOT_CONNECTED = 0, LAN_CONNECTED, + LAN_CONNECTED_INTRANET, WLAN_CONNECTED, + WLAN_CONNECTED_INTRANET, LAN_CONNECTED_LIMITED, WLAN_CONNECTED_LIMITED, ACTIVATING, @@ -61,7 +64,7 @@ class MainWindow : public QMainWindow { Q_OBJECT public: - explicit MainWindow(QWidget *parent = nullptr); + explicit MainWindow(QString display, QWidget *parent = nullptr); void showMainwindow(); void hideMainwindow(); @@ -69,8 +72,8 @@ public: void setWirelessDefaultDevice(QString deviceName); //for dbus - void getWirelessList(QMap > &map); - void getWiredList(QMap> &map); + void getWirelessList(QString devName, QList &list); + void getWiredList(QString devName, QList &list); //开启热点 void activeWirelessAp(const QString apName, const QString apPassword, const QString wirelessBand, const QString apDevice); //断开热点 @@ -186,6 +189,8 @@ private: LanPage * m_lanWidget = nullptr; WlanPage * m_wlanWidget = nullptr; + ConnectivityPage* m_connectivityPage = nullptr; + //监听主题的Gsettings QGSettings * m_styleGsettings = nullptr; @@ -198,6 +203,7 @@ private: QMenu * m_trayIconMenu = nullptr; QAction * m_showMainwindowAction = nullptr; QAction * m_showSettingsAction = nullptr; + QAction * m_showConnectivityPageAction = nullptr; bool m_lanIsLoading = false; bool m_wlanIsLoading = false; @@ -213,6 +219,11 @@ private: uint m_intervalTime = 100; uint m_registerCount = 0; + QString m_display; + + bool m_isWiredUsable = true; + bool m_isWirelessUsable = true; + public Q_SLOTS: void onShowMainWindow(int type); @@ -227,9 +238,20 @@ private Q_SLOTS: void onLanConnectStatusToChangeTrayIcon(int state); void onWlanConnectStatusToChangeTrayIcon(int state); void onConnectivityChanged(NetworkManager::Connectivity connectivity); + void onConnectivityCheckSpareUriChanged(); void onTimeUpdateTrayIcon(); void onTabletModeChanged(bool mode); void onRefreshTrayIconTooltip(); + + void onShowKylinNMSlot(QString display, int type); + //唤起属性页 根据网卡类型 参数2 为ssid/uuid + void onShowPropertyWidgetSlot(QString display, QString devName, QString ssid); + //唤起新建有线连接界面 + void onShowCreateWiredConnectWidgetSlot(QString display, QString devName); + //唤起加入其他无线网络界面 + void onShowAddOtherWlanWidgetSlot(QString display, QString devName); + //设置界面显示 单网卡/多网卡 + void setCentralWidgetPages(); }; #endif // MAINWINDOW_H diff --git a/src/frontend/netdetails/ipv4page.cpp b/src/frontend/netdetails/ipv4page.cpp index 14e032e3..91a57108 100644 --- a/src/frontend/netdetails/ipv4page.cpp +++ b/src/frontend/netdetails/ipv4page.cpp @@ -151,7 +151,7 @@ void Ipv4Page::initComponent() { void Ipv4Page::setIpv4Config(KyIpConfigType ipv4Config) { - if (ipv4Config == CONFIG_IP_MANUAL) { + if (ipv4Config == CONFIG_IP_MANUAL) { ipv4ConfigCombox->setCurrentIndex(MANUAL_CONFIG); } else { ipv4ConfigCombox->setCurrentIndex(AUTO_CONFIG); diff --git a/src/frontend/networkmode/firewalldialog.cpp b/src/frontend/networkmode/firewalldialog.cpp index 4c70c5ce..4e0094ed 100644 --- a/src/frontend/networkmode/firewalldialog.cpp +++ b/src/frontend/networkmode/firewalldialog.cpp @@ -20,6 +20,9 @@ #include "firewalldialog.h" #include +#include "windowmanager/windowmanager.h" +#include "kwindowsystem.h" +#include "kwindowsystem_export.h" #define THEME_SCHAME "org.ukui.style" #define COLOR_THEME "styleName" @@ -30,6 +33,7 @@ FirewallDialog::FirewallDialog(QWidget *parent): KDialog(parent) initUI(); this->setWindowIcon(QIcon::fromTheme("kylin-network")); this->setFixedSize(480, 204); + KWindowSystem::setState(this->winId(), NET::SkipTaskbar | NET::SkipPager); setAttribute(Qt::WA_DeleteOnClose); // centerToScreen(); connect(qApp, &QApplication::paletteChanged, this, &FirewallDialog::onPaletteChanged); diff --git a/src/frontend/tab-pages/lanpage.cpp b/src/frontend/tab-pages/lanpage.cpp index c8bea0c3..38919fab 100644 --- a/src/frontend/tab-pages/lanpage.cpp +++ b/src/frontend/tab-pages/lanpage.cpp @@ -996,34 +996,29 @@ void LanPage::onConnectionStateChange(QString uuid, } -void LanPage::getWiredList(QMap > &map) +void LanPage::getWiredList(QString devName, QList &list) { QStringList devlist; m_deviceResource->getNetworkDeviceList(NetworkManager::Device::Type::Ethernet, devlist); - if (devlist.isEmpty()) { + if (!devlist.contains(devName)) { return; } - Q_FOREACH (auto deviceName, devlist) { - QList activedList; - QList deactivedList; - QVector vector; - m_activeResourse->getActiveConnectionList(deviceName,NetworkManager::ConnectionSettings::Wired,activedList); - if (!activedList.isEmpty()) { - vector.append(QStringList() << activedList.at(0)->m_connectName << activedList.at(0)->m_connectUuid << activedList.at(0)->m_connectPath); - } else { - vector.append(QStringList()<<("--")); - } - - m_connectResourse->getConnectionList(deviceName, NetworkManager::ConnectionSettings::Wired, deactivedList); //未激活列表的显示 - if (!deactivedList.isEmpty()) { - for (int i = 0; i < deactivedList.size(); i++) { - vector.append(QStringList()<m_connectName<m_connectUuid << deactivedList.at(i)->m_connectPath); - } - } - map.insert(deviceName, vector); + QList activedList; + QList deactivedList; + m_activeResourse->getActiveConnectionList(devName,NetworkManager::ConnectionSettings::Wired,activedList); + if (!activedList.isEmpty()) { + list.append(QStringList() << activedList.at(0)->m_connectName << activedList.at(0)->m_connectUuid << activedList.at(0)->m_connectPath); + } else { + list.append(QStringList()<<("--")); + } + + m_connectResourse->getConnectionList(devName, NetworkManager::ConnectionSettings::Wired, deactivedList); //未激活列表的显示 + if (!deactivedList.isEmpty()) { + for (int i = 0; i < deactivedList.size(); i++) { + list.append(QStringList()<m_connectName<m_connectUuid << deactivedList.at(i)->m_connectPath); + } } - return; } void LanPage::sendLanUpdateSignal(KyConnectItem *p_connectItem) diff --git a/src/frontend/tab-pages/lanpage.h b/src/frontend/tab-pages/lanpage.h index ab401e8f..c0e12606 100644 --- a/src/frontend/tab-pages/lanpage.h +++ b/src/frontend/tab-pages/lanpage.h @@ -43,7 +43,7 @@ public: ~LanPage(); //for dbus - void getWiredList(QMap > &map); + void getWiredList(QString devName, QList &list); void activateWired(const QString& devName, const QString& connUuid); void deactivateWired(const QString& devName, const QString& connUuid); void showDetailPage(QString devName, QString uuid); @@ -53,6 +53,10 @@ public: bool lanIsConnected(); void getWiredDeviceConnectState(QMap &map); + bool isWiredDeviceUsable() { + return !m_devList.isEmpty(); + } + protected: bool eventFilter(QObject *watched, QEvent *event); diff --git a/src/frontend/tab-pages/wlanpage.cpp b/src/frontend/tab-pages/wlanpage.cpp index 5d1f506c..cc07d3eb 100644 --- a/src/frontend/tab-pages/wlanpage.cpp +++ b/src/frontend/tab-pages/wlanpage.cpp @@ -82,6 +82,7 @@ WlanPage::WlanPage(QWidget *parent) : TabPage(parent) connect(m_wirelessConnectOpreation, &KyWirelessConnectOperation::wifiEnabledChanged, this, &WlanPage::onWifiEnabledChanged); connect(m_connectResource, &KyConnectResourse::connectivityChanged, this, &WlanPage::connectivityChanged); + connect(m_connectResource, &KyConnectResourse::connectivityCheckSpareUriChanged, this, &WlanPage::connectivityCheckSpareUriChanged); connect(m_netSwitch, &KSwitchButton::clicked, this, [=](bool checked) { //解决 switchBtn不支持点击的情况下,点击按钮,有无线网卡后不自动开启的问题 if (getSwitchBtnEnable()) { @@ -295,9 +296,8 @@ void WlanPage::initDeviceCombox() } } else { m_deviceFrame->hide(); - //解决因m_currentDevice被置空,安全中心网络显示BUG -// m_currentDevice = ""; -// setDefaultDevice(WIRELESS, m_currentDevice); + m_currentDevice = ""; + setDefaultDevice(WIRELESS, m_currentDevice); } connect(m_deviceComboBox, QOverload::of(&QComboBox::currentIndexChanged), @@ -781,25 +781,23 @@ void WlanPage::deleteDeviceFromCombox(QString deviceName) disconnect(m_deviceComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, &WlanPage::onDeviceComboxIndexChanged); - if (getSwitchBtnState()) { - if (0 == m_devList.count()) { - m_deviceFrame->hide(); - //m_tipsLabel->show(); - //m_deviceComboBox->hide(); - m_currentDevice = ""; + if (0 == m_devList.count()) { + m_deviceFrame->hide(); + //m_tipsLabel->show(); + //m_deviceComboBox->hide(); + m_currentDevice = ""; + setDefaultDevice(WIRELESS, m_currentDevice); + } else if (1 == m_devList.count()) { + m_deviceFrame->hide(); + m_deviceComboBox->clear(); + m_currentDevice = m_devList.at(0); + setDefaultDevice(WIRELESS, m_currentDevice); + } else { + int index = m_deviceComboBox->findText(deviceName); + if (-1 != index) { + m_deviceComboBox->removeItem(index); + m_currentDevice = m_deviceComboBox->currentText(); setDefaultDevice(WIRELESS, m_currentDevice); - } else if (1 == m_devList.count()) { - m_deviceFrame->hide(); - m_deviceComboBox->clear(); - m_currentDevice = m_devList.at(0); - setDefaultDevice(WIRELESS, m_currentDevice); - } else { - int index = m_deviceComboBox->findText(deviceName); - if (-1 != index) { - m_deviceComboBox->removeItem(index); - m_currentDevice = m_deviceComboBox->currentText(); - setDefaultDevice(WIRELESS, m_currentDevice); - } } } @@ -1359,72 +1357,61 @@ void WlanPage::onRefreshIconTimer() } //for dbus -void WlanPage::getWirelessList(QMap > &map) +void WlanPage::getWirelessList(QString devName, QList &list) { - QMap actMap; - m_wirelessNetResource->getWirelessActiveConnection(NetworkManager::ActiveConnection::State::Activated, actMap); + KyWirelessNetItem data; - QMap > wlanMap; - if (!m_wirelessNetResource->getAllDeviceWifiNetwork(wlanMap)) { + QList wlanList; + if (!m_wirelessNetResource->getDeviceWifiNetwork(devName, wlanList)) { return; } - QMap >::iterator iter = wlanMap.begin(); - while (iter != wlanMap.end()) { - QVector vector; - QString activeSsid ; - //先是已连接 - if (actMap.contains(iter.key())) { - qDebug() << "find " <getSsidByUuid(actMap[iter.key()].at(0), ssid); - if (m_wirelessNetResource->getWifiNetwork(iter.key(), ssid, data)) { - int category = 0; - int signalStrength; - QString uni,secuType; - - if (m_netDeviceResource->getActiveConnectionInfo(iter.key(), signalStrength, uni, secuType)) { - category = data.getCategory(uni); - } - if (!m_showWifi6Plus && category == 2) { - category = 1; - } - vector.append(QStringList() << data.m_NetSsid - << QString::number(signalStrength) - << secuType - << data.m_connectUuid - << (m_connectResource->isApConnection(data.m_connectUuid) ? IsApConnection : NotApConnection) - << QString::number(category)); - activeSsid = data.m_NetSsid; - } else { - vector.append(QStringList("--")); - } - } else { - vector.append(QStringList("--")); - } - //未连接 - Q_FOREACH (auto itemData, iter.value()) { - if (itemData.m_NetSsid == activeSsid) { - continue; - } + QString activeSsid ; + //先是已连接 + if (m_wirelessNetResource->getActiveWirelessNetItem(devName, data)) { + qDebug() << "find " << devName; + QString ssid =""; + m_wirelessNetResource->getSsidByUuid(data.m_connectUuid, ssid); + if (m_wirelessNetResource->getWifiNetwork(devName, ssid, data)) { int category = 0; - category = itemData.getCategory(itemData.m_uni); + int signalStrength; + QString uni,secuType; + + if (m_netDeviceResource->getActiveConnectionInfo(devName, signalStrength, uni, secuType)) { + category = data.getCategory(uni); + } if (!m_showWifi6Plus && category == 2) { category = 1; } - vector.append(QStringList()<isApConnection(itemData.m_connectUuid) ? IsApConnection : NotApConnection) + list.append(QStringList() << data.m_NetSsid + << QString::number(signalStrength) + << secuType + << data.m_connectUuid + << (m_connectResource->isApConnection(data.m_connectUuid) ? IsApConnection : NotApConnection) << QString::number(category)); + activeSsid = data.m_NetSsid; + } else { + list.append(QStringList("--")); } - - map.insert(iter.key(), vector); - iter++; + } else { + list.append(QStringList("--")); + } + //未连接 + Q_FOREACH (auto itemData, wlanList) { + if (itemData.m_NetSsid == activeSsid) { + continue; + } + int category = 0; + category = itemData.getCategory(itemData.m_uni); + if (!m_showWifi6Plus && category == 2) { + category = 1; + } + list.append(QStringList()<isApConnection(itemData.m_connectUuid) ? IsApConnection : NotApConnection) + << QString::number(category)); } - - return; } //for dbus @@ -1526,7 +1513,7 @@ void WlanPage::activateWirelessConnection(const QString& devName, const QString& m_inactivatedNetListWidget->scrollToItem(p_listWidgetItem, QAbstractItemView::EnsureVisible); - QMouseEvent *event = new QMouseEvent(QEvent::MouseButtonPress, QPoint(0,0), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); + QMouseEvent *event = new QMouseEvent(QEvent::MouseButtonRelease, QPoint(0,0), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); QApplication::postEvent(p_wlanItem, event); } else { qDebug() << "[WlanPage]activateWirelessConnection no such " << ssid << "in" << devName; diff --git a/src/frontend/tab-pages/wlanpage.h b/src/frontend/tab-pages/wlanpage.h index dd26c361..bdc43ea5 100644 --- a/src/frontend/tab-pages/wlanpage.h +++ b/src/frontend/tab-pages/wlanpage.h @@ -52,7 +52,7 @@ public: ~WlanPage() = default; //for dbus - void getWirelessList(QMap > &map); + void getWirelessList(QString devName, QList &list); //开启热点 void activeWirelessAp(const QString apName, const QString apPassword, const QString wirelessBand, const QString apDevice); //断开热点 @@ -88,6 +88,10 @@ public: return m_currentDevice; } + bool isWirelessDeviceUsable() { + return !m_devList.isEmpty(); + } + Q_SIGNALS: void oneItemExpanded(const QString &ssid); void wlanAdd(QString devName, QStringList info); @@ -104,6 +108,7 @@ Q_SIGNALS: void showMainWindow(int type); void connectivityChanged(NetworkManager::Connectivity connectivity); + void connectivityCheckSpareUriChanged(); void wirelessSwitchBtnChanged(bool state); diff --git a/src/main.cpp b/src/main.cpp index 05b5235f..a7019f9b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,7 +18,7 @@ //#include "mainwindow.h" #include "mainwindow.h" -#include "dbusadaptor.h" +#include "dbus.h" #include #include #include "qt-single-application.h" @@ -130,23 +130,30 @@ int main(int argc, char *argv[]) parser.addOptions({swOption,snOption}); parser.process(a); + QString display; + QString sessionType; + if(QString(getenv("XDG_SESSION_TYPE")) == "wayland") { + sessionType = "wayland"; + display = getenv("WAYLAND_DISPLAY"); + } else { + sessionType = "x11"; + display = getenv("DISPLAY"); + } + qDebug() << sessionType << display; + qApp->setProperty("sessionType", sessionType); + QDBusInterface interface("com.kylin.network", "/com/kylin/network", "com.kylin.network", QDBusConnection::sessionBus()); - if(interface.isValid()) { - if (parser.isSet(swOption)) - { - interface.call(QStringLiteral("showKylinNM"), 1); - } else if (parser.isSet(snOption)){ - interface.call(QStringLiteral("showKylinNM"), 0); - } else { - const QString serviceName = "com.kylin.network"; - QDBusConnectionInterface *interface1 = QDBusConnection::sessionBus().interface(); - QDBusReply pid = interface1->servicePid(serviceName); - qDebug() << "current display " << getenv("DISPLAY") << QApplication::applicationPid() - << "exist kylin-nm display" << displayFromPid(pid.value()); - if (getenv("DISPLAY") == displayFromPid(pid.value())) { + + if (a.isRunning()) { + if(interface.isValid()) { + if (parser.isSet(swOption)) { + interface.call(QStringLiteral("showKylinNM"), 1); + } else if (parser.isSet(snOption)) { + interface.call(QStringLiteral("showKylinNM"), 0); + } else { interface.call(QStringLiteral("showKylinNM"), 2); } } @@ -195,7 +202,7 @@ int main(int argc, char *argv[]) ::usleep(1000); } - MainWindow w; + MainWindow w(display, nullptr); a.setActivationWindow(&w); w.setProperty("useStyleWindowManager", false); //禁用拖动 a.setWindowIcon(QIcon::fromTheme("kylin-network")); @@ -207,13 +214,11 @@ int main(int argc, char *argv[]) // window_hints.decorations = MWM_DECOR_BORDER; // XAtomHelper::getInstance()->setWindowMotifHint(w.winId(), window_hints); - DbusAdaptor adaptor(&w); - Q_UNUSED(adaptor); +// w.setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint /*| Qt::X11BypassWindowManagerHint*/); - auto connection = QDBusConnection::sessionBus(); - if (!connection.registerService("com.kylin.network") || !connection.registerObject("/com/kylin/network", &w)) { - qCritical() << "QDbus register service failed reason:" << connection.lastError(); - } + + DbusAdaptor adaptor(display, &w); + Q_UNUSED(adaptor); return a.exec(); } diff --git a/src/translations/kylin-nm_bo.ts b/src/translations/kylin-nm_bo.ts index 1f8dd342..6684d718 100644 --- a/src/translations/kylin-nm_bo.ts +++ b/src/translations/kylin-nm_bo.ts @@ -24,6 +24,54 @@ + + ConnectivityPage + + + Network connectivity detection + + + + + If access to the Internet is restricted, please switch the network IP connectivity detection method and try again. + + + + + Public network (default) + + + + + Local area network (intranet) + + + + + Confirm + + + + + The network is connected and can access the Internet normally. + + + + + The network is connected and access to the Internet is restricted. + + + + + Please enter the local area network (intranet) detection address + + + + + Format error + + + CreatNetPage @@ -260,22 +308,22 @@ FirewallDialog - + Allow other devices on this network to discover this computer? - + It is not recommended to enable this feature on public networks - + Not allowed (recommended) - + Allowed @@ -313,23 +361,23 @@ - + Invalid address - + Invalid subnet mask + - Required - + Address conflict @@ -488,23 +536,23 @@ - + Wired Device not carried - - + + Connected: - + (Limited) - + Not Connected @@ -525,47 +573,47 @@ MainWindow - - + + kylin-nm - + LAN - + WLAN - + Settings - - + + Network Connectivity Detection + + + + + Network tool - + Network Card - + Not connected to the network - - - Show MainWindow - - MultipleDnsWidget @@ -967,35 +1015,35 @@ - - - + + + Disconnect - - - + + + Connect - + Property - + Forget - + Auto Connect @@ -1011,42 +1059,42 @@ WlanPage - + WLAN - + Activated WLAN - + Other WLAN - + Connected: - + Not Connected - + No wireless network card detected - + WLAN Connected Successfully - + WLAN Disconnected Successfully diff --git a/src/translations/kylin-nm_bo_CN.ts b/src/translations/kylin-nm_bo_CN.ts index 8067c616..8ddadbc6 100644 --- a/src/translations/kylin-nm_bo_CN.ts +++ b/src/translations/kylin-nm_bo_CN.ts @@ -55,6 +55,54 @@ མེ་འགོག་གྱང་རྩིག་དང་བདེ་འཇགས་བཀོད་སྒྲིག་བྱ་དགོས། + + ConnectivityPage + + + Network connectivity detection + དྲ་རྒྱའི་སྦྲེལ་མཐུད་རང་བཞིན་གྱི་ཞིབ་དཔྱད་ཚད་ལེན། + + + + If access to the Internet is restricted, please switch the network IP connectivity detection method and try again. + གལ་ཏེ་དྲ་སྦྲེལ་ལ་འཚམས་འདྲི་བྱེད་པར་ཚོད་འཛིན་ཐེབས་པ་དང་། དྲ་རྒྱའི་IPལ་ཞིབ་དཔྱད་ཚད་ལེན་བྱེད་ཐབས་བརྗེས་ནས་ཚོད་ལྟ་བྱེད་དགོས།. + + + + Public network (default) + སྤྱི་པའི་དྲ་རྒྱ། (ཁས་མ་བླངས་པ། ) + + + + Local area network (intranet) + ཅུས་ཁོངས་དྲ་བ། (ནང་དྲ། ) + + + + Confirm + གཏན་འཁེལ་བྱ། + + + + The network is connected and can access the Internet normally. + དྲ་རྒྱ་སྦྲེལ་མཐུད་བྱས་ཟིན་པས་རྒྱུན་ལྡན་གྱི་དྲ་སྦྲེལ་ལ་འཚམས་འདྲི་བྱས་ཆོག. + + + + The network is connected and access to the Internet is restricted. + དྲ་རྒྱ་སྦྲེལ་མཐུད་བྱས་ཟིན་པས་དྲ་སྦྲེལ་ལ་འཚམས་འདྲི་བྱས་པ་རེད།. + + + + Please enter the local area network (intranet) detection address + ཅུས་ཁོངས་ཀྱི་དྲ་རྒྱའི་(ནང་དྲ་)ཞིབ་དཔྱད་ཚད་ལེན་ས་གནས་ནང་འཇུག་བྱེད་རོགས། + + + + Format error + རྣམ་གཞག་གི་ནོར་འཁྲུལ། + + CopyButton @@ -500,7 +548,7 @@ Close - སྒོ་རྒྱག་པ། + སྒོ་རྒྱག་པ། @@ -568,22 +616,22 @@ དེ་ལྟར་མ་བྱས་ - + Allow other devices on this network to discover this computer? དྲ་རྒྱའི་སྟེང་གི་སྒྲིག་ཆས་གཞན་པས་གློག་ཀླད་འདི་རྙེད་དུ་འཇུག་གམ།? - + It is not recommended to enable this feature on public networks བསམ་འཆར་མེད་།སྤྱི་པའི་དྲ་རྒྱའི་སྟེང་ནས་ནུས་པ་འདི་མགོ་བརྩམས་། - + Not allowed (recommended) མི་ཆོག་པ་(འོས་སྦྱོར།) - + Allowed ཆོག་པ་ @@ -629,23 +677,23 @@ ལག་དེབ། - + Invalid address རྩིས་འགྲོ་མེད་པའི་ས་གནས། - + Invalid subnet mask རྩིས་འགྲོ་མེད་པའི་དྲ་བ་འགེབས་སྲུང་བྱེད་པ། + - Required ངེས་པར་དུ་སྐོང་དགོས། - + Address conflict ཤག་གནས་གདོང་གཏུག་ @@ -824,7 +872,7 @@ སྐུད་ཡོད་དྲ་བ་ཆད་སོང་། - + Wired Device not carried སྐུད་ཡོད་སྒྲིག་ཆས་འཁྱེར་མེད་པ། @@ -833,18 +881,18 @@ སྐུད་ཡོད་དྲ་བ་སྦྲེལ་ཡོད། - - + + Connected: འབྲེལ་མཐུད་བྱུང་ཡོད།: - + Not Connected འབྲེལ་མཐུད་མ་བྱས་པ། - + (Limited) (དྲ་བར་ཚོད་འཛིན་ཐེབས་པ་རེད།) @@ -865,47 +913,51 @@ MainWindow - - + + kylin-nm དྲ་རྒྱའི་ཡོ་བྱད། - + LAN 有线网络 སྐུད་ཡོད་དྲ་བ། - + WLAN 无线局域网 སྐུད་མེད་ཅུས་ཁོངས་ཀྱི་དྲ་བ། - Show MainWindow - རླུང་གཙོ་བོ་མངོན་པར་བྱས་ཡོད། + རླུང་གཙོ་བོ་མངོན་པར་བྱས་ཡོད། - + Settings 设置网络项 སྒྲིག་བཀོད། - - + + Network Connectivity Detection + དྲ་རྒྱའི་སྦྲེལ་མཐུད་རང་བཞིན་གྱི་ཞིབ་དཔྱད་ཚད་ལེན། + + + + Network tool དྲ་རྒྱའི་ལག་ཆ་ - + Network Card དྲ་བྱང་། - + Not connected to the network དྲ་རྒྱ་དང་སྦྲེལ་མཐུད་མ་བྱས་པ། @@ -1459,35 +1511,35 @@ - - - + + + Disconnect འབྲེལ་ཐག་ཆད་པ། - - - + + + Connect སྦྲེལ་མཐུད་བྱེད་པ - + Forget བརྗེད་པ། - + Property ངོ་བོ། - + Auto Connect རང་འགུལ་གྱིས་སྦྲེལ་མཐུད་ @@ -1507,22 +1559,22 @@ WlanPage - + WLAN སྐུད་མེད་ཅུས་ཁོངས་ཀྱི་དྲ་བ། - + No wireless network card detected སྐུད་མེད་དྲ་རྒྱའི་བྱང་བུ་མ་རྙེད་པ། - + Activated WLAN ངའི་དྲ་རྒྱ། - + Other WLAN དྲ་བ་གཞན་དག @@ -1531,22 +1583,22 @@ 更多... - + WLAN Connected Successfully སྐུད་མེད་དྲ་བ་སྦྲེལ་ཡོད། - + WLAN Disconnected Successfully སྐུད་མེད་དྲ་རྒྱ་ཆད་སོང་། - + Connected: འབྲེལ་མཐུད་བྱུང་ཡོད།: - + Not Connected འབྲེལ་མཐུད་མ་བྱས་པ། diff --git a/src/translations/kylin-nm_mn.ts b/src/translations/kylin-nm_mn.ts index 1a536303..004537e0 100644 --- a/src/translations/kylin-nm_mn.ts +++ b/src/translations/kylin-nm_mn.ts @@ -55,6 +55,54 @@ ᠭᠠᠯ ᠰᠡᠷᠬᠡᠢᠯᠡᠬᠦ ᠬᠡᠷᠡᠮ ᠪᠤᠯᠤᠨ ᠠᠮᠤᠷ ᠳᠦᠪᠰᠢᠨ ᠤ᠋ ᠳᠤᠬᠢᠷᠠᠭᠤᠯᠭ᠎ᠠ + + ConnectivityPage + + + Network connectivity detection + ᠰᠦᠯᠵᠢᠶ᠎ᠡ ᠶᠢ ᠵᠠᠯᠭᠠᠵᠤ ᠪᠠᠶᠢᠴᠠᠭᠠᠨ ᠬᠡᠮᠵᠢᠨ᠎ᠡ + + + + If access to the Internet is restricted, please switch the network IP connectivity detection method and try again. + ᠬᠡᠷᠪᠡ ᠢᠨᠲ᠋ᠸᠷ ᠰᠦᠯᠵᠢᠶ᠎ᠠ ᠳᠤ ᠰᠤᠷᠪᠤᠯᠵᠢᠯᠠᠬᠤ ᠳᠤ ᠬᠦᠷᠪᠡᠯ ᠂ ᠰᠦᠯᠵᠢᠶ᠎ᠠ ᠶᠢᠨ IP ᠶᠢ ᠬᠤᠯᠪᠤᠵᠤ ᠪᠠᠶᠢᠴᠠᠭᠠᠨ ᠬᠡᠮᠵᠢᠭᠦ ᠠᠷᠭ᠎ᠠ ᠶᠢ ᠰᠤᠯᠢᠵᠤ ᠂ ᠲᠠᠷᠠᠭ᠎ᠠ ᠨᠢ ᠲᠠᠭᠢᠨ ᠰᠢᠯᠭᠠᠯᠲᠠ ᠬᠢᠨ᠎ᠡ. + + + + Public network (default) + ᠨᠡᠶᠢᠲᠡ ᠶᠢᠨ ᠬᠡᠷᠡᠭᠯᠡᠭᠡᠨ ᠦ ᠰᠦᠯᠵᠢᠶ᠎ᠡ ( ᠳᠤᠪ ᠳᠤᠭᠤᠢ ᠲᠠᠨᠢᠯᠴᠠᠨ᠎ᠠ ) + + + + Local area network (intranet) + ᠬᠡᠰᠡᠭ ᠬᠡᠪᠴᠢᠶᠡᠨ ᠦ ᠲᠣᠤᠷ ( ᠳᠣᠲᠣᠭᠠᠳᠤ ᠰᠦᠯᠵᠢᠶ᠎ᠡ ) + + + + Confirm + ᠪᠠᠳᠤᠯᠠᠬᠤ + + + + The network is connected and can access the Internet normally. + ᠰᠦᠯᠵᠢᠶ᠎ᠡ ᠨᠢᠭᠡᠨᠲᠡ ᠬᠣᠯᠪᠣᠭᠳᠠᠵᠤ ᠂ ᠢᠨᠲ᠋ᠧᠷ ᠰᠦᠯᠵᠢᠶ᠎ᠡ ᠶᠢ ᠬᠡᠪ ᠦᠨ ᠶᠣᠰᠣᠭᠠᠷ ᠰᠤᠷᠪᠤᠯᠵᠢᠯᠠᠵᠤ ᠪᠣᠯᠣᠨ᠎ᠠ. + + + + The network is connected and access to the Internet is restricted. + ᠰᠦᠯᠵᠢᠶ᠎ᠡ ᠨᠢᠭᠡᠨᠲᠡ ᠬᠣᠯᠪᠣᠭᠳᠠᠵᠤ ᠂ ᠢᠨᠲ᠋ᠧᠷ ᠰᠦᠯᠵᠢᠶᠡᠨ ᠦ ᠠᠶᠢᠯᠴᠢᠯᠠᠯᠲᠠ ᠳᠤ ᠬᠢᠵᠠᠭᠠᠷᠯᠠᠭᠳᠠᠵᠠᠶ. + + + + Please enter the local area network (intranet) detection address + ᠬᠡᠰᠡᠭ ᠬᠡᠪᠴᠢᠶᠡᠨ ᠦ ᠲᠣᠤᠷ (ᠳᠣᠲᠣᠭᠠᠳᠤ ᠲᠣᠤᠷ) ᠢ ᠪᠠᠶᠢᠴᠠᠭᠠᠨ ᠬᠡᠮᠵᠢᠬᠦ ᠬᠠᠶᠢᠭ ᠢ ᠣᠷᠣᠭᠤᠯᠵᠤ ᠢᠷᠡᠭᠡᠷᠡᠢ + + + + Format error + ᠬᠡᠯᠪᠡᠷᠢ ᠨᠢ ᠪᠤᠷᠤᠭᠤ + + CopyButton @@ -552,22 +600,22 @@ FirewallDialog - + Allow other devices on this network to discover this computer? ᠲᠤᠰ ᠳᠦᠯᠵᠢᠶᠡᠨ ᠳᠡᠭᠡᠷᠡᠬᠢ ᠪᠤᠰᠤᠳ ᠳᠦᠬᠦᠬᠡᠷᠦᠮᠵᠢ ᠡᠨᠡ ᠺᠣᠮᠫᠢᠦ᠋ᠲ᠋ᠧᠷ ᠢ᠋ ᠣᠯᠵᠤ ᠮᠡᠳᠡᠬᠦ ᠵᠢ ᠵᠥᠪᠰᠢᠶᠡᠷᠡᠬᠦ ᠤᠤ? - + It is not recommended to enable this feature on public networks ᠨᠡᠢᠳᠡ ᠵᠢᠨ ᠰᠦᠯᠵᠢᠶᠡᠨ ᠳᠡᠭᠡᠷ᠎ᠡ ᠲᠤᠰ ᠴᠢᠳᠠᠪᠬᠢ ᠵᠢ ᠨᠡᠬᠡᠬᠡᠬᠦ ᠥᠬᠡᠢ ᠪᠠᠢᠬᠤ ᠵᠢ ᠰᠠᠨᠠᠭᠤᠯᠵᠤ ᠪᠠᠢᠨ᠎ᠠ - + Not allowed (recommended) ᠵᠥᠪᠰᠢᠶᠡᠷᠡᠬᠦ ᠥᠬᠡᠢ ( ᠳᠠᠨᠢᠯᠴᠠᠭᠤᠯᠬᠤ) - + Allowed ᠵᠥᠪᠰᠢᠶᠡᠷᠡᠬᠦ @@ -613,23 +661,23 @@ ᠭᠠᠷ᠎ᠢᠶᠠᠷ ᠬᠦᠳᠡᠯᠭᠡᠬᠦ᠌ - + Invalid address ᠬᠦᠴᠦᠨ ᠦᠬᠡᠢ ᠬᠠᠶᠢᠭ - + Invalid subnet mask ᠬᠦᠴᠦᠨ ᠦᠬᠡᠢ ᠬᠤᠪᠢᠶᠠᠷᠢ ᠰᠦᠯᠵᠢᠶᠡᠨ ᠤ᠋ ᠬᠠᠯᠬᠠᠪᠴᠢ + - Required ᠡᠷᠬᠡᠪᠰᠢ ᠳᠠᠭᠯᠠᠬᠤ - + Address conflict ᠬᠠᠶᠢᠭ ᠤ᠋ᠨ ᠮᠦᠷᠬᠦᠯᠳᠦᠬᠡᠨ @@ -804,7 +852,7 @@ ᠤᠳᠠᠰᠤᠳᠤ ᠲᠤᠤᠷ ᠰᠦᠯᠵᠢᠶ᠎ᠡ ᠵᠢ ᠨᠢᠭᠡᠨᠳᠡ ᠳᠠᠰᠤᠯᠪᠠ - + Wired Device not carried ᠰᠦᠯᠵᠢᠶᠡᠨ ᠤ᠋ ᠤᠳᠠᠰᠤ ᠵᠠᠯᠭᠠᠭ᠎ᠠ ᠦᠬᠡᠢ @@ -813,18 +861,18 @@ ᠤᠳᠠᠰᠤᠳᠤ ᠲᠤᠤᠷ ᠰᠦᠯᠵᠢᠶ᠎ᠡ ᠵᠢ ᠨᠢᠭᠡᠨᠳᠡ ᠴᠦᠷᠬᠡᠯᠡᠪᠡ - - + + Connected: ᠴᠥᠷᠬᠡᠯᠡᠪᠡ: - + Not Connected ᠴᠥᠷᠬᠡᠯᠡᠭᠡ ᠥᠬᠡᠢ - + (Limited) ( ᠰᠦᠯᠵᠢᠶ᠎ᠡ ᠬᠢᠵᠠᠭᠠᠷᠯᠠᠭᠳᠠᠪᠠ) @@ -845,47 +893,51 @@ MainWindow - - + + kylin-nm ᠲᠤᠤᠷ ᠰᠦᠯᠵᠢᠶᠡᠨ ᠤ᠋ ᠪᠠᠭᠠᠵᠢ - + LAN 有线网络 ᠤᠳᠠᠰᠤᠳᠤ ᠰᠦᠯᠵᠢᠶ᠎ᠡ - + WLAN 无线局域网 ᠤᠳᠠᠰᠤ ᠦᠬᠡᠢ ᠬᠡᠰᠡᠭ ᠰᠦᠯᠵᠢᠶ᠎ᠡ - Show MainWindow - ᠲᠤᠤᠷ ᠰᠦᠯᠵᠢᠶᠡᠨ ᠤ᠋ ᠪᠠᠭᠠᠵᠢ ᠵᠢ ᠨᠡᠬᠡᠬᠡᠬᠦ + ᠲᠤᠤᠷ ᠰᠦᠯᠵᠢᠶᠡᠨ ᠤ᠋ ᠪᠠᠭᠠᠵᠢ ᠵᠢ ᠨᠡᠬᠡᠬᠡᠬᠦ - + Settings ᠲᠤᠤᠷ ᠰᠦᠯᠵᠢᠶᠡᠨ ᠤ᠋ ᠲᠦᠷᠦᠯ ᠢ᠋ ᠳᠤᠬᠢᠷᠠᠭᠤᠯᠬᠤ ᠲᠤᠤᠷ ᠰᠦᠯᠵᠢᠶᠡᠨ ᠤ᠋ ᠲᠦᠷᠦᠯ ᠢ᠋ ᠳᠤᠬᠢᠷᠠᠭᠤᠯᠬᠤ - - + + Network Connectivity Detection + ᠰᠦᠯᠵᠢᠶ᠎ᠡ ᠶᠢ ᠵᠠᠯᠭᠠᠵᠤ ᠪᠠᠶᠢᠴᠠᠭᠠᠨ ᠬᠡᠮᠵᠢᠨ᠎ᠡ + + + + Network tool ᠰᠦᠯᠵᠢᠶᠡᠨ ᠤ᠋ ᠪᠠᠭᠠᠵᠢ - + Network Card ᠰᠦᠯᠵᠢᠶᠡᠨ ᠤ᠋ ᠺᠠᠷᠲ - + Not connected to the network ᠰᠦᠯᠵᠢᠶᠡᠨ ᠳ᠋ᠤ᠌ ᠴᠥᠷᠬᠡᠯᠡᠭᠡ ᠥᠬᠡᠢ @@ -1420,35 +1472,35 @@ - - - + + + Disconnect ᠳᠠᠰᠤᠯᠬᠤ - - - + + + Connect ᠴᠦᠷᠬᠡᠯᠡᠬᠡ - + Forget ᠲᠤᠰ ᠲᠤᠤᠷ ᠰᠦᠯᠵᠢᠶ᠎ᠡ ᠵᠢ ᠮᠠᠷᠳᠠᠬᠤ - + Property ᠬᠠᠷᠢᠶᠠᠯᠠᠯ - + Auto Connect ᠲᠤᠰ ᠲᠤᠤᠷ ᠰᠦᠯᠵᠢᠶᠡᠨ ᠳ᠋ᠤ᠌ ᠠᠦ᠋ᠲ᠋ᠤ᠋ ᠪᠡᠷ ᠵᠠᠯᠭᠠᠬᠤ @@ -1468,22 +1520,22 @@ WlanPage - + WLAN ᠤᠳᠠᠰᠤ ᠦᠬᠡᠢ ᠬᠡᠰᠡᠭ ᠰᠦᠯᠵᠢᠶ᠎ᠡ - + No wireless network card detected ᠤᠳᠠᠰᠤ ᠦᠬᠡᠢ ᠰᠦᠯᠵᠢᠶᠡᠨ ᠺᠠᠷᠲ᠎ᠢ ᠬᠢᠨᠠᠨ ᠬᠡᠮᠵᠢᠵᠤ ᠤᠯᠤᠭᠰᠠᠨ ᠦᠬᠡᠢ - + Activated WLAN ᠮᠢᠨᠤ ᠲᠤᠤᠷ ᠰᠦᠯᠵᠢᠶ᠎ᠡ - + Other WLAN ᠪᠤᠰᠤᠳ ᠰᠦᠯᠵᠢᠶ᠎ᠡ @@ -1492,22 +1544,22 @@ 更多... - + WLAN Connected Successfully ᠤᠳᠠᠰᠤ ᠦᠬᠡᠢ ᠲᠤᠤᠷ ᠰᠦᠯᠵᠢᠶ᠎ᠡ ᠵᠢ ᠴᠦᠷᠬᠡᠯᠡᠪᠡ - + WLAN Disconnected Successfully ᠤᠳᠠᠰᠤ ᠦᠬᠡᠢ ᠲᠤᠤᠷ ᠰᠦᠯᠵᠢᠶ᠎ᠡ ᠵᠢ ᠳᠠᠰᠤᠯᠪᠠ - + Connected: ᠴᠥᠷᠬᠡᠯᠡᠪᠡ: - + Not Connected ᠴᠥᠷᠬᠡᠯᠡᠭᠡ ᠥᠬᠡᠢ diff --git a/src/translations/kylin-nm_tr.ts b/src/translations/kylin-nm_tr.ts index e79ac137..21104c3c 100644 --- a/src/translations/kylin-nm_tr.ts +++ b/src/translations/kylin-nm_tr.ts @@ -122,6 +122,54 @@ + + ConnectivityPage + + + Network connectivity detection + + + + + If access to the Internet is restricted, please switch the network IP connectivity detection method and try again. + + + + + Public network (default) + + + + + Local area network (intranet) + + + + + Confirm + + + + + The network is connected and can access the Internet normally. + + + + + The network is connected and access to the Internet is restricted. + + + + + Please enter the local area network (intranet) detection address + + + + + Format error + + + CreatNetPage @@ -1279,22 +1327,22 @@ FirewallDialog - + Allow other devices on this network to discover this computer? - + It is not recommended to enable this feature on public networks - + Not allowed (recommended) - + Allowed @@ -1332,23 +1380,23 @@ Elle - + Invalid address - + Invalid subnet mask + - Required - + Address conflict @@ -1514,23 +1562,23 @@ - + Wired Device not carried - - + + Connected: - + (Limited) - + Not Connected @@ -1551,8 +1599,8 @@ MainWindow - - + + kylin-nm @@ -1573,33 +1621,38 @@ Gizli Ağı Bağlan - + LAN - + WLAN WLAN - + Settings - - + + Network Connectivity Detection + + + + + Network tool - + Network Card - + Not connected to the network @@ -1616,9 +1669,8 @@ HotSpot - Show MainWindow - Ana Pencereyi Göster + Ana Pencereyi Göster Not connected @@ -2321,35 +2373,35 @@ - - - + + + Disconnect Bağlantıyı Kes - - - + + + Connect - + Property - + Forget - + Auto Connect @@ -2365,42 +2417,42 @@ WlanPage - + WLAN WLAN - + Activated WLAN - + Other WLAN - + Connected: - + Not Connected - + No wireless network card detected - + WLAN Connected Successfully - + WLAN Disconnected Successfully diff --git a/src/translations/kylin-nm_zh_CN.ts b/src/translations/kylin-nm_zh_CN.ts index eb2b23a9..93e985af 100644 --- a/src/translations/kylin-nm_zh_CN.ts +++ b/src/translations/kylin-nm_zh_CN.ts @@ -55,6 +55,54 @@ 配置防火墙和安全设置 + + ConnectivityPage + + + Network connectivity detection + 网络连通性检测 + + + + If access to the Internet is restricted, please switch the network IP connectivity detection method and try again. + 如访问 Internet 受限,请切换网络 IP 连通性检测方式后再试。 + + + + Public network (default) + 公网(默认) + + + + Local area network (intranet) + 局域网(内网) + + + + Confirm + 确定 + + + + The network is connected and can access the Internet normally. + 网络已连接,可正常访问 Internet 。 + + + + The network is connected and access to the Internet is restricted. + 网络已连接,访问 Internet 受限。 + + + + Please enter the local area network (intranet) detection address + 请输入局域网(内网)检测地址 + + + + Format error + 格式错误 + + CopyButton @@ -568,22 +616,22 @@ - + Allow other devices on this network to discover this computer? 是否允许此网络上的其他设备发现这台电脑? - + It is not recommended to enable this feature on public networks 不建议在公共网络上开启此功能 - + Not allowed (recommended) 不允许(推荐) - + Allowed 允许 @@ -629,23 +677,23 @@ 手动 - + Invalid address 无效的IP地址 - + Invalid subnet mask 无效的子网掩码 + - Required 必填 - + Address conflict 地址冲突 @@ -824,7 +872,7 @@ 有线网络已断开 - + Wired Device not carried 未插入网线 @@ -833,18 +881,18 @@ 有线网络已连接 - - + + Connected: 已连接: - + Not Connected 未连接 - + (Limited) (网络受限) @@ -865,47 +913,51 @@ MainWindow - - + + kylin-nm 网络工具 - + LAN 有线网络 有线网络 - + WLAN 无线局域网 无线局域网 - Show MainWindow - 打开网络工具 + 打开网络工具 - + Settings 设置网络项 设置网络项 - - + + Network Connectivity Detection + 网络连通性检测 + + + + Network tool 网络工具 - + Network Card 网卡 - + Not connected to the network 未连接网络 @@ -1416,35 +1468,35 @@ - - - + + + Disconnect 断开 - - - + + + Connect 连接 - + Forget 忘记此网络 - + Property 属性 - + Auto Connect 自动加入该网络 @@ -1464,22 +1516,22 @@ WlanPage - + WLAN 无线局域网 - + No wireless network card detected 未检测到无线网卡 - + Activated WLAN 我的网络 - + Other WLAN 其他网络 @@ -1488,22 +1540,22 @@ 更多... - + WLAN Connected Successfully 无线网络已连接 - + WLAN Disconnected Successfully 无线网络已断开 - + Connected: 已连接: - + Not Connected 未连接