add method and dbus signal

This commit is contained in:
jzxc95 2021-09-15 11:42:06 +08:00
parent 6d7e721972
commit 84429a703b
19 changed files with 295 additions and 176 deletions

View File

@ -511,3 +511,24 @@ void KyActiveConnectResourse::getApActivateConnect(QList<KyApConnectItem *> &apC
return;
}
bool KyActiveConnectResourse::isActiveConnection(QString uuid, QStringList &devName)
{
if (!m_networkResourceInstance->isActiveConnection(uuid)) {
return false;
} else {
NetworkManager::ActiveConnection::Ptr actPtr = m_networkResourceInstance->getActiveConnect(uuid);
if (actPtr.isNull()) {
return false;
} else {
QStringList interfaces = actPtr->devices();
for (int index = 0; index < interfaces.size(); ++index) {
QString ifaceUni = interfaces.at(index);
NetworkManager::Device:: Ptr devicePtr =
m_networkResourceInstance->findDeviceUni(ifaceUni);
devName <<devicePtr->interfaceName();
}
return true;
}
}
}

View File

@ -34,6 +34,8 @@ public:
void getApActivateConnect(QList<KyApConnectItem *> &apConnectItemList);
bool isActiveConnection(QString uuid, QStringList &devName);
private:
void getActiveConnectIp(NetworkManager::ActiveConnection::Ptr activeConnectPtr,
QString &ipv4Address,

View File

@ -16,6 +16,7 @@ KyConnectResourse::KyConnectResourse(QObject *parent) : QObject(parent)
connect(m_networkResourceInstance, &KyNetworkResourceManager::connectionAdd, this, &KyConnectResourse::connectionAdd);
connect(m_networkResourceInstance, &KyNetworkResourceManager::connectionRemove, this, &KyConnectResourse::connectionRemove);
connect(m_networkResourceInstance, &KyNetworkResourceManager::connectionUpdate, this, &KyConnectResourse::connectionUpdate);
connect(m_networkResourceInstance, &KyNetworkResourceManager::connectivityChanged, this, &KyConnectResourse::connectivityChanged);
}
KyConnectResourse::~KyConnectResourse()
@ -278,6 +279,11 @@ void KyConnectResourse::getIpv6ConnectSetting(
return;
}
void KyConnectResourse::getConnectivity(NetworkManager::Connectivity &connectivity)
{
m_networkResourceInstance->getConnectivity(connectivity);
}
void KyConnectResourse::getConnectionSetting(QString connectUuid, KyConnectSetting &connectSetting)
{
qDebug() <<"[KyConnectResourse]" << connectUuid <<"get connect setting info, connect uuid";

View File

@ -28,6 +28,7 @@ public:
void getApConnections(QList<KyApConnectItem *> &apConnectItemList);
void getConnectionSetting(QString connectUuid, KyConnectSetting &connectSetting);
bool getInterfaceByUuid(QString &deviceName, NetworkManager::ConnectionSettings::ConnectionType &type, const QString connUuid);
void getConnectivity(NetworkManager::Connectivity &connectivity);
private:
KyConnectItem *getConnectionItem(NetworkManager::Connection::Ptr connectPtr);
@ -51,6 +52,7 @@ signals:
void connectionAdd(QString uuid);
void connectionUpdate(QString uuid);
void connectionRemove(QString path);
void connectivityChanged(NetworkManager::Connectivity connectivity);
private:
KyNetworkResourceManager *m_networkResourceInstance = nullptr;

View File

@ -51,6 +51,7 @@ KyNetworkResourceManager::KyNetworkResourceManager(QObject *parent) : QObject(pa
connect(NetworkManager::settingsNotifier(), &NetworkManager::SettingsNotifier::connectionAdded, this, &KyNetworkResourceManager::onConnectionAdded);
connect(NetworkManager::settingsNotifier(), &NetworkManager::SettingsNotifier::connectionRemoved, this, static_cast<void (KyNetworkResourceManager::*)(QString const &)>(&KyNetworkResourceManager::onConnectionRemoved));
connect(NetworkManager::notifier(), &NetworkManager::Notifier::connectivityChanged, this, &KyNetworkResourceManager::connectivityChanged);
//todo wifi开关信号
connect(NetworkManager::notifier(), &NetworkManager::Notifier::wirelessEnabledChanged, this, &KyNetworkResourceManager::wifinEnabledChanged);
connect(NetworkManager::notifier(), &NetworkManager::Notifier::wirelessHardwareEnabledChanged, [=](){
@ -483,6 +484,11 @@ bool KyNetworkResourceManager::isActivatingConnection(QString uuid)
return false;
}
void KyNetworkResourceManager::getConnectivity(NetworkManager::Connectivity &connectivity)
{
connectivity = NetworkManager::connectivity();
}
void KyNetworkResourceManager::requestScan(NetworkManager::WirelessDevice * dev)
{
qDebug() <<"[KyNetworkResourceManager]"<< dev->interfaceName()<<"start scan wifi ap";

View File

@ -101,6 +101,8 @@ public:
bool isActiveConnection(QString uuid);
bool isActivatingConnection(QString uuid);
void getConnectivity(NetworkManager::Connectivity &connectivity);
signals:
void connectionAdd(QString uuid);
void connectionUpdate(QString uuid);
@ -136,6 +138,8 @@ signals:
NetworkManager::VpnConnection::State state,
NetworkManager::VpnConnection::StateChangeReason reason);
void connectivityChanged(NetworkManager::Connectivity connectivity);
private slots:
//connection
void onConnectionUpdated();

View File

@ -247,8 +247,8 @@ QString KyWirelessConnectOperation::getPsk(const QString &connectUuid)
}
QDBusPendingReply<NMVariantMapMap> reply = connectPtr->secrets(PSK_SETTING_NAME);
QMap<QString,QVariantMap> map(reply.value());
if (map.contains("802-11-wireless-security") && map.value("802-11-wireless-security").contains("psk"))
{
if (map.contains("802-11-wireless-security")
&& map.value("802-11-wireless-security").contains("psk")) {
QString psk = map.value("802-11-wireless-security").value("psk").toString();
return psk;
}
@ -267,8 +267,8 @@ QString KyWirelessConnectOperation::getPrivateKeyPassword(const QString &connect
}
QDBusPendingReply<NMVariantMapMap> reply = connectPtr->secrets(PSK_SETTING_NAME);
QMap<QString,QVariantMap> map(reply.value());
if (map.contains("802-1x") && map.value("802-1x").contains("private-key-password"))
{
if (map.contains("802-1x")
&& map.value("802-1x").contains("private-key-password")) {
QString psk = map.value("802-1x").value("private-key-password").toString();
return psk;
}
@ -825,8 +825,7 @@ KyKeyMgmt KyWirelessConnectOperation::getConnectKeyMgmt(const QString &uuid)
NetworkManager::WirelessSecuritySetting::Ptr security_sett
= connectPtr->settings()->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
if(security_sett.isNull())
{
if(security_sett.isNull()) {
return KyKeyMgmt::Unknown;
}
return (KyKeyMgmt)security_sett->keyMgmt();
@ -848,7 +847,6 @@ void KyWirelessConnectOperation::updateWirelessSecu(NetworkManager::ConnectionSe
}
security_sett->setKeyMgmt((NetworkManager::WirelessSecuritySetting::KeyMgmt)type);
if (bPwdChange) {
qDebug() << "set psk " << connSettingInfo.m_psk;
security_sett->setPsk(connSettingInfo.m_psk);
}
return;
@ -927,13 +925,13 @@ bool KyWirelessConnectOperation::getEnterpiseEapMethod(const QString &uuid, KyEa
NetworkManager::Connection::Ptr connectPtr =
NetworkManager::findConnectionByUuid(uuid);
if (connectPtr.isNull()) {
qDebug() << "getEnterpiseEapMethod faild.Can't find uuid = " << uuid;
qWarning() << "getEnterpiseEapMethod faild.Can't find uuid = " << uuid;
return false;
}
KyKeyMgmt keyMgmt = getConnectKeyMgmt(uuid);
if (keyMgmt != WpaEap) {
qDebug() << "getEnterpiseEapMethod but not WpaEap.it's " << keyMgmt;
qWarning() << "getEnterpiseEapMethod but not WpaEap.it's " << keyMgmt;
return false;
}

View File

@ -79,9 +79,15 @@ public Q_SLOTS: // METHODS
//获取热点
QStringList getStoredApInfo();
Q_SIGNALS: // SIGNALS
void wirelessActivating(QString devName, QString ssid);
void wiredActivating(QString devName, QString ssid);
void listUpdate(QString devName);
// void wirelessActivating(QString devName, QString ssid);
// void wiredActivating(QString devName, QString ssid);
void lanAdd(QString devName, QStringList info);
void lanRemove(QString dbusPath);
void lanUpdate(QString devName, QStringList info);
void wlanAdd(QString devName, QStringList info);
void wlanRemove(QString devName,QString ssid);
void wlanactiveConnectionStateChanged(QString devName, QString ssid, int status);
void lanActiveConnectionStateChanged(QString devName, QString uuid, int status);
//仅失败若成功直接发listUpdate
void activateFailed(QString errorMessage);
void deactivateFailed(QString errorMessage);

View File

@ -165,7 +165,9 @@ void CreatNetPage::constructIpv4Info(KyConnectSetting &setting)
QString ipv4address =ipv4addressEdit->text();
QString netMask = netMaskEdit->text();
QString gateWay = gateWayEdit->text();
qDebug() << ipv4address << netMask << gateWay;
qDebug() << "constructIpv4Info: " << "ipv4address " << ipv4address
<< " netMask " << netMask
<< " gateWay " << gateWay;
QStringList dnsList;
dnsList.empty();

View File

@ -524,11 +524,9 @@ void NetDetail::on_btnForget_clicked()
void NetDetail::setConfirmEnable()
{
qDebug() << isCreateNet << isWlan;
if (isCreateNet && !isWlan) {
isConfirmBtnEnable = isCreateOk;
} else {
qDebug() << isDetailOk << isIpv4Ok << isIpv6Ok << isSecuOk;
if (isDetailOk && isIpv4Ok && isIpv6Ok) {
if (isWlan && !isSecuOk) {
isConfirmBtnEnable = false;
@ -551,7 +549,7 @@ bool NetDetail::checkIpv4Conflict(QString ipv4Address)
if (ipv4Arping->ipv4ConflictCheck() >= 0) {
isConflict = ipv4Arping->ipv4IsConflict();
} else {
qDebug() << "checkIpv4Conflict internal error";
qWarning() << "checkIpv4Conflict internal error";
}
delete ipv4Arping;
@ -567,7 +565,7 @@ bool NetDetail::checkIpv6Conflict(QString ipv6address)
if (ipv46rping->ipv6ConflictCheck() >= 0) {
isConflict = ipv46rping->ipv6IsConflict();
} else {
qDebug() << "checkIpv6Conflict internal error";
qWarning() << "checkIpv6Conflict internal error";
}
delete ipv46rping;
@ -580,7 +578,6 @@ void NetDetail::updateWirelessPersonalConnect()
KyWirelessConnectSetting setting;
securityPage->updateSecurityChange(setting);
bool isPwdChanged = !(m_info.strPassword == setting.m_psk);
qDebug() << setting.m_psk << isPwdChanged;
m_wirelessConnOpration->updateWirelessPersonalConnect(m_uuid, setting, isPwdChanged);
}

View File

@ -165,112 +165,20 @@ void SecurityPage::initConnect()
//EAP方式变化
connect(eapTypeCombox, &QComboBox::currentTextChanged, this, &SecurityPage::onEapTypeComboxIndexChanged);
connect(caNeedBox, &QCheckBox::clicked, this, [&](){
if (caNeedBox->isChecked()) {
caCertPathCombox->setEnabled(false);
} else {
caCertPathCombox->setEnabled(true);
}
});
connect(caNeedBox, &QCheckBox::clicked, this, &SecurityPage::onCaNeedBoxClicked);
connect(pwdBox, &QCheckBox::clicked, this, [&]() {
if (pwdEdit->echoMode() == QLineEdit::Password) {
pwdBox->setChecked(true);
pwdEdit->setEchoMode(QLineEdit::Normal);
} else {
pwdBox->setChecked(false);
pwdEdit->setEchoMode(QLineEdit::Password);
}
connect(pwdBox, &QCheckBox::clicked, this, &SecurityPage::onPwdBoxClicked);
connect(userPwdBox, &QCheckBox::clicked, this, &SecurityPage::onUserPwdBox);
connect(privateKeyBox, &QCheckBox::clicked, this, &SecurityPage::onPrivateKeyBoxClicked);
});
connect(caCertPathCombox, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &SecurityPage::onCaCertPathComboxIndexChanged);
connect(userPwdBox, &QCheckBox::clicked, this, [&]() {
if (userPwdEdit->echoMode() == QLineEdit::Password) {
userPwdBox->setChecked(true);
userPwdEdit->setEchoMode(QLineEdit::Normal);
} else {
userPwdBox->setChecked(false);
userPwdEdit->setEchoMode(QLineEdit::Password);
}
connect(clientCertPathCombox, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &SecurityPage::onClientCertPathComboxIndexChanged);
});
connect(privateKeyBox, &QCheckBox::clicked, this, [&]() {
if (clientPrivateKeyPwdEdit->echoMode() == QLineEdit::Password) {
privateKeyBox->setChecked(true);
clientPrivateKeyPwdEdit->setEchoMode(QLineEdit::Normal);
} else {
privateKeyBox->setChecked(false);
clientPrivateKeyPwdEdit->setEchoMode(QLineEdit::Password);
}
});
connect(caCertPathCombox, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged), this, [=] (const QString &str) {
if (str.contains("Choose from file...") || str.contains("从文件选择..."))
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Choose a CA certificate"), "recent:///",
tr("CA Files (*.pem *.der *.p12 *.crt *.cer *.pfx)"));
if (!fileName.isNull()) {
QStringList nameList = fileName.split("/");
caCertPathCombox->blockSignals(true);
caCertPathCombox->setItemText(0, fileName);
caCertPathCombox->setCurrentIndex(0);
caCertPathCombox->blockSignals(false);
} else {
caCertPathCombox->blockSignals(true);
caCertPathCombox->setItemText(0, tr("None"));
caCertPathCombox->setCurrentIndex(0);
caCertPathCombox->blockSignals(false);
}
} else {
qWarning() << "Choose file is null or unvalible";
}
});
connect(clientCertPathCombox, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged), this, [=] (const QString &str) {
if (str.contains("Choose from file...") || str.contains("从文件选择..."))
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Choose a CA certificate"), "recent:///",
tr("CA Files (*.pem *.der *.p12 *.crt *.cer *.pfx)"));
if (!fileName.isNull()) {
// QStringList nameList = fileName.split("/");
clientCertPathCombox->blockSignals(true);
clientCertPathCombox->setItemText(0, fileName);
clientCertPathCombox->setCurrentIndex(0);
clientCertPathCombox->blockSignals(false);
} else {
clientCertPathCombox->blockSignals(true);
clientCertPathCombox->setItemText(0, tr("None"));
clientCertPathCombox->setCurrentIndex(0);
clientCertPathCombox->blockSignals(false);
}
} else {
qWarning() << "Choose file is null or unvalible";
}
});
connect(clientPrivateKeyCombox, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged), this, [=] (const QString &str) {
if (str.contains("Choose from file...") || str.contains("从文件选择..."))
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Choose a CA certificate"), "recent:///",
tr("CA Files (*.pem *.der *.p12 *.crt *.cer *.pfx)"));
if (!fileName.isNull()) {
QStringList nameList = fileName.split("/");
clientPrivateKeyCombox->blockSignals(true);
clientPrivateKeyCombox->setItemText(0, fileName);
clientPrivateKeyCombox->setCurrentIndex(0);
clientPrivateKeyCombox->blockSignals(false);
} else {
clientPrivateKeyCombox->blockSignals(true);
clientPrivateKeyCombox->setItemText(0, tr("None"));
clientPrivateKeyCombox->setCurrentIndex(0);
clientPrivateKeyCombox->blockSignals(false);
}
} else {
qWarning() << "Choose file is null or unvalible";
}
});
connect(clientPrivateKeyCombox, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &SecurityPage::onClientPrivateKeyComboxIndexChanged);
connect(secuTypeCombox, SIGNAL(currentIndexChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(pwdEdit, &QLineEdit::textChanged, this, &SecurityPage::setEnableOfSaveBtn);
@ -740,3 +648,114 @@ void SecurityPage::onEapTypeComboxIndexChanged()
eapMethodCombox->addItem("gtc(eap)", GTC_EAP);
}
}
void SecurityPage::onCaNeedBoxClicked()
{
if (caNeedBox->isChecked()) {
caCertPathCombox->setEnabled(false);
} else {
caCertPathCombox->setEnabled(true);
}
}
void SecurityPage::onPwdBoxClicked()
{
if (pwdEdit->echoMode() == QLineEdit::Password) {
pwdBox->setChecked(true);
pwdEdit->setEchoMode(QLineEdit::Normal);
} else {
pwdBox->setChecked(false);
pwdEdit->setEchoMode(QLineEdit::Password);
}
}
void SecurityPage::onUserPwdBox()
{
if (userPwdEdit->echoMode() == QLineEdit::Password) {
userPwdBox->setChecked(true);
userPwdEdit->setEchoMode(QLineEdit::Normal);
} else {
userPwdBox->setChecked(false);
userPwdEdit->setEchoMode(QLineEdit::Password);
}
}
void SecurityPage::onPrivateKeyBoxClicked()
{
if (clientPrivateKeyPwdEdit->echoMode() == QLineEdit::Password) {
privateKeyBox->setChecked(true);
clientPrivateKeyPwdEdit->setEchoMode(QLineEdit::Normal);
} else {
privateKeyBox->setChecked(false);
clientPrivateKeyPwdEdit->setEchoMode(QLineEdit::Password);
}
}
void SecurityPage::onCaCertPathComboxIndexChanged(QString str)
{
if (str.contains("Choose from file...") || str.contains("从文件选择..."))
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Choose a CA certificate"), "recent:///",
tr("CA Files (*.pem *.der *.p12 *.crt *.cer *.pfx)"));
if (!fileName.isNull()) {
QStringList nameList = fileName.split("/");
caCertPathCombox->blockSignals(true);
caCertPathCombox->setItemText(0, fileName);
caCertPathCombox->setCurrentIndex(0);
caCertPathCombox->blockSignals(false);
} else {
caCertPathCombox->blockSignals(true);
caCertPathCombox->setItemText(0, tr("None"));
caCertPathCombox->setCurrentIndex(0);
caCertPathCombox->blockSignals(false);
}
} else {
qWarning() << "Choose file is null or unvalible";
}
}
void SecurityPage::onClientCertPathComboxIndexChanged(QString str)
{
if (str.contains("Choose from file...") || str.contains("从文件选择..."))
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Choose a CA certificate"), "recent:///",
tr("CA Files (*.pem *.der *.p12 *.crt *.cer *.pfx)"));
if (!fileName.isNull()) {
clientCertPathCombox->blockSignals(true);
clientCertPathCombox->setItemText(0, fileName);
clientCertPathCombox->setCurrentIndex(0);
clientCertPathCombox->blockSignals(false);
} else {
clientCertPathCombox->blockSignals(true);
clientCertPathCombox->setItemText(0, tr("None"));
clientCertPathCombox->setCurrentIndex(0);
clientCertPathCombox->blockSignals(false);
}
} else {
qWarning() << "Choose file is null or unvalible";
}
}
void SecurityPage::onClientPrivateKeyComboxIndexChanged(QString str)
{
if (str.contains("Choose from file...") || str.contains("从文件选择..."))
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Choose a CA certificate"), "recent:///",
tr("CA Files (*.pem *.der *.p12 *.crt *.cer *.pfx)"));
if (!fileName.isNull()) {
QStringList nameList = fileName.split("/");
clientPrivateKeyCombox->blockSignals(true);
clientPrivateKeyCombox->setItemText(0, fileName);
clientPrivateKeyCombox->setCurrentIndex(0);
clientPrivateKeyCombox->blockSignals(false);
} else {
clientPrivateKeyCombox->blockSignals(true);
clientPrivateKeyCombox->setItemText(0, tr("None"));
clientPrivateKeyCombox->setCurrentIndex(0);
clientPrivateKeyCombox->blockSignals(false);
}
} else {
qWarning() << "Choose file is null or unvalible";
}
}

View File

@ -96,6 +96,15 @@ private slots:
void onEapTypeComboxIndexChanged();
void setEnableOfSaveBtn();
void onCaNeedBoxClicked();
void onPwdBoxClicked();
void onUserPwdBox();
void onPrivateKeyBoxClicked();
void onCaCertPathComboxIndexChanged(QString str);
void onClientCertPathComboxIndexChanged(QString str);
void onClientPrivateKeyComboxIndexChanged(QString str);
signals:
void setSecuPageState(bool);
};

View File

@ -153,12 +153,15 @@ void MainWindow::initDbusConnnect()
connect(m_wlanWidget, &WlanPage::activateFailed, this, &MainWindow::activateFailed);
connect(m_wlanWidget, &WlanPage::deactivateFailed, this, &MainWindow::deactivateFailed);
connect(m_lanWidget, &LanPage::listUpdate, this, &MainWindow::listUpdate);
connect(m_wlanWidget, &WlanPage::listUpdate, this, &MainWindow::listUpdate);
connect(m_lanWidget, &LanPage::lanAdd, this, &MainWindow::lanAdd);
connect(m_lanWidget, &LanPage::lanRemove, this, &MainWindow::lanRemove);
connect(m_lanWidget, &LanPage::lanUpdate, this, &MainWindow::lanUpdate);
connect(m_lanWidget, &LanPage::lanActiveConnectionStateChanged, this, &MainWindow::lanActiveConnectionStateChanged);
connect(m_lanWidget, &LanPage::wiredActivating, this, &MainWindow::wiredActivating);
connect(m_wlanWidget, &WlanPage::wirelessActivating, this, &MainWindow::wirelessActivating);
connect(m_wlanWidget, &WlanPage::wlanAdd, this, &MainWindow::wlanAdd);
connect(m_wlanWidget, &WlanPage::wlanRemove, this, &MainWindow::wlanRemove);
connect(m_wlanWidget, &WlanPage::wlanActiveConnectionStateChanged, this, &MainWindow::wlanactiveConnectionStateChanged);
connect(m_wlanWidget, &WlanPage::hotspotDeactivated, this, &MainWindow::hotspotDeactivated);
connect(m_wlanWidget, &WlanPage::hotspotActivated, this, &MainWindow::hotspotActivated);
connect(m_wlanWidget, &WlanPage::secuTypeChange, this, &MainWindow::secuTypeChange);
@ -431,7 +434,9 @@ void MainWindow::showPropertyWidget(QString devName, QString ssid)
return;
}
qDebug() << "showPropertyWidget no such device " << devName;
qWarning() << "showPropertyWidget no such device " << devName;
delete devResourse;
devResourse = nullptr;
}
void MainWindow::showCreateWiredConnectWidget(const QString devName)

View File

@ -52,11 +52,14 @@ signals:
void deviceStatusChanged();
//设备名称变化
void deviceNameChanged(QString oldName, QString newName);
//设备有线无线列表更新(有线增删、无线增加减少)
void listUpdate(QString devName);
//控制面板连接中
void wiredActivating(QString devName, QString ssid);
void wirelessActivating(QString devName, QString ssid);
//有线无线列表更新(有线增删、无线增加减少)
void lanAdd(QString devName, QStringList info);
void lanRemove(QString dbusPath);
void lanUpdate(QString devName, QStringList info);
void wlanAdd(QString devName, QStringList info);
void wlanRemove(QString devName,QString ssid);
void wlanactiveConnectionStateChanged(QString devName, QString ssid, int status);
void lanActiveConnectionStateChanged(QString devName, QString uuid, int status);
void activateFailed(QString errorMessage);
void deactivateFailed(QString errorMessage);
//热点断开

View File

@ -38,6 +38,7 @@ LanPage::LanPage(QWidget *parent) : TabPage(parent)
connect(m_activeResourse, &KyActiveConnectResourse::stateChangeReason, this, &LanPage::updateLanlist);
connect(m_connectResourse, &KyConnectResourse::connectionAdd, this, &LanPage::addConnectionSlot);
connect(m_connectResourse, &KyConnectResourse::connectionRemove, this, &LanPage::removeConnectionSlot);
connect(m_connectResourse, &KyConnectResourse::connectionUpdate, this, &LanPage::connectionUpdateSlot);
connect(m_device, &KyNetworkDeviceResourse::deviceAdd, this, &LanPage::onDeviceAdd);
connect(m_device, &KyNetworkDeviceResourse::deviceRemove, this, &LanPage::onDeviceRemove);
connect(m_device, &KyNetworkDeviceResourse::deviceNameUpdate, this, &LanPage::onDeviceNameUpdate);
@ -121,6 +122,10 @@ void LanPage::onLanSwitchClicked()
void LanPage::removeConnectionSlot(QString path) //删除时后端会自动断开激活,将其从未激活列表中删除
{
//for dbus
qDebug() << "[LanPage] emit lanRemove because removeConnectionSlot " << path;
emit lanRemove(path);
qDebug()<<"[LanPage] Removing a connection, path:"<<path;
bool isLan = false;
QEventLoop loop;
@ -135,22 +140,10 @@ void LanPage::removeConnectionSlot(QString path) //删除时后端会
delete(iters.value());
m_deactiveMap.erase(iters);
isLan = true;
//for dbus
qDebug() << "[LanPage] because removeConnectionSlot " << item->m_ifaceName;
emit listUpdate(item->m_ifaceName);
break;
}
}
if (!isLan) {
//removeConnection不是当前设备的可能是其他有线设备或无线设备保险起见发送信号更新
for (int index = 0; index < devList.size(); ++index) {
if (devList.at(index) == m_deviceName) {
continue;
}
emit listUpdate(devList.at(index));
}
}
}
void LanPage::addConnectionSlot(QString uuid) //新增一个有线连接,将其加入到激活列表
@ -167,8 +160,14 @@ void LanPage::addConnectionSlot(QString uuid) //新增一个有线
}
//for dbus
qDebug() << "[LanPage] emit listUpdate because addConnection " << devName;
emit listUpdate(devName);
KyConnectItem *item = nullptr;
item = m_connectResourse->getConnectionItemByUuid(uuid, devName);
if (nullptr != item) {
QStringList info;
info << item->m_connectName << uuid << item->m_connectPath;
qDebug() << "[LanPage] emit lanAdd because addConnection " << devName;
emit lanAdd(devName, info);
}
KyConnectItem * newItem = m_connectResourse->getConnectionItemByUuid(uuid, m_deviceName);
if (newItem != nullptr) {
@ -182,6 +181,41 @@ void LanPage::addConnectionSlot(QString uuid) //新增一个有线
qDebug()<<"[LanPage] GetConnectionItemByUuid is empty when add a new!";
}
}
void LanPage::connectionUpdateSlot(QString uuid)
{
//for dbus
QStringList devNameList;
if (m_activeResourse->isActiveConnection(uuid, devNameList)) {
for (int i = 0; i < devNameList.size(); ++i) {
KyConnectItem *item = nullptr;
item = m_activeResourse->getActiveConnectionByUuid(uuid, devNameList.at(i));
if (nullptr != item) {
if (item->m_itemType != NetworkManager::ConnectionSettings::ConnectionType::Wired) {
return;
}
QStringList info;
info << item->m_connectName << uuid << item->m_connectPath;
emit lanUpdate(devNameList.at(i), info);
}
}
} else {
QString devName;
NetworkManager::ConnectionSettings::ConnectionType type;
if (!m_connectResourse->getInterfaceByUuid(devName, type, uuid)) {
return;
}
if (type != NetworkManager::ConnectionSettings::ConnectionType::Wired) {
return;
}
KyConnectItem *item = nullptr;
item = m_connectResourse->getConnectionItemByUuid(uuid, devName);
if (nullptr != item) {
QStringList info;
info << item->m_connectName << uuid << item->m_connectPath;
emit lanUpdate(devName, info);
}
}
}
void LanPage::initDevice()
{
@ -413,16 +447,23 @@ void LanPage::updateLanlist(QString uuid, NetworkManager::ActiveConnection::Stat
qDebug() << "[LanPage] updateLanlist but uuid is invalid";
}
if (state == NetworkManager::ActiveConnection::State::Activating) {
qDebug() << "[LanPage] wiredActivating " << devName;
emit wiredActivating(devName,uuid);
QStringList devNameList;
if (m_activeResourse->isActiveConnection(uuid, devNameList)) {
for (int i = 0; i < devNameList.size(); ++i) {
KyConnectItem *item = nullptr;
item = m_activeResourse->getActiveConnectionByUuid(uuid, devNameList.at(i));
if (nullptr != item) {
QStringList info;
info << item->m_connectName << uuid << item->m_connectPath;
emit lanActiveConnectionStateChanged(devNameList.at(i), uuid, state);
}
}
} else {
qDebug() << "emit lanActiveConnectionStateChanged" << devName << uuid << state;
emit lanActiveConnectionStateChanged(devName, uuid, state);
}
if (state == NetworkManager::ActiveConnection::State::Activated || state == NetworkManager::ActiveConnection::State::Deactivated)
{
qDebug() << "[LanPage] because updateLanlist " <<devName;
emit listUpdate(devName);
}
if (state == NetworkManager::ActiveConnection::State::Deactivated) {
qDebug()<<"Get a deactivate, begin to remove it from activeList";
@ -509,7 +550,7 @@ void LanPage::getWiredList(QMap<QString, QVector<QStringList> > &map)
QVector<QStringList> 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);
vector.append(QStringList() << activedList.at(0)->m_connectName << activedList.at(0)->m_connectUuid << activedList.at(0)->m_connectPath);
} else {
vector.append(QStringList()<<("--"));
}
@ -560,14 +601,13 @@ void LanPage::showDetailPage(QString devName, QString uuid)
item = m_activeResourse->getActiveConnectionByUuid(uuid, devName);
if (nullptr == item) {
item = m_connectResourse->getConnectionItemByUuid(uuid, devName);
if (nullptr == item) {
qWarning()<<"[LanPage] GetConnectionItemByUuid is empty when showDetailPage";
return;
}
isActive= false;
}
if (nullptr == item) {
qDebug()<<"[LanPage] GetConnectionItemByUuid is empty when showDetailPage";
return;
}
NetDetail *netDetail = new NetDetail(devName, item->m_connectName, uuid, isActive, false, false, this);
netDetail->show();
delete item;

View File

@ -29,8 +29,10 @@ public:
void showDetailPage(QString devName, QString uuid);
void setWiredDeviceEnable(const QString& devName, bool enable);
signals:
void wiredActivating(QString devName, QString ssid);
void lanAdd(QString devName, QStringList info);
void lanRemove(QString dbusPath);
void lanUpdate(QString devName, QStringList info);
void lanActiveConnectionStateChanged(QString interface, QString uuid, int status);
private:
void initDevice();//初始化默认设备
void initDeviceCombox();
@ -72,6 +74,7 @@ private slots:
void updateLanlist(QString uuid, NetworkManager::ActiveConnection::State state, NetworkManager::ActiveConnection::Reason reason);
void addConnectionSlot(QString uuid);
void removeConnectionSlot(QString path);
void connectionUpdateSlot(QString uuid);
void onSwithGsettingsChanged(const QString &key);
void onLanSwitchClicked();
void onDeviceAdd(QString deviceName, NetworkManager::Device::Type deviceType);

View File

@ -56,7 +56,6 @@ signals:
void deviceNameChanged(QString oldName, QString newName);
void activateFailed(QString errorMessage);
void deactivateFailed(QString errorMessage);
void listUpdate(QString devName);
protected:
void initUI();

View File

@ -106,8 +106,6 @@ void WlanPage::initConnections()
{
connect(m_resource, &KyWirelessNetResource::wifiNetworkAdd, this, &WlanPage::onWlanAdded);
connect(m_resource, &KyWirelessNetResource::wifiNetworkRemove, this, &WlanPage::onWlanRemoved);
connect(m_resource, &KyWirelessNetResource::wifiNetworkAdd, this, &WlanPage::listUpdate);
connect(m_resource, &KyWirelessNetResource::wifiNetworkRemove, this, &WlanPage::listUpdate);
connect(m_resource, &KyWirelessNetResource::signalStrengthChange, this, &WlanPage::signalStrengthChange);
connect(m_resource, &KyWirelessNetResource::secuTypeChange, this, &WlanPage::secuTypeChange);
@ -290,7 +288,12 @@ void WlanPage::getAllWlan()
void WlanPage::onWlanAdded(QString interface, KyWirelessNetItem &item)
{
emit listUpdate(interface);
//for dbus
QStringList info;
info <<item.m_NetSsid<<QString::number(item.m_signalStrength)<<item.m_secuType;
emit wlanAdd(interface, info);
qDebug() << "A Wlan Added! interface = " << interface << "; ssid = " << item.m_NetSsid << Q_FUNC_INFO <<__LINE__;
if (interface != defaultDevice) {
qDebug() << "wlan add interface not equal defaultdevice,ignore";
@ -311,7 +314,7 @@ void WlanPage::onWlanAdded(QString interface, KyWirelessNetItem &item)
void WlanPage::onWlanRemoved(QString interface, QString ssid)
{
emit listUpdate(interface);
emit wlanRemove(interface, ssid);
if (!m_itemsMap.contains(ssid)) { return; }
if (m_expandedItem == m_itemsMap.value(ssid)) { m_expandedItem = nullptr; }
qDebug() << "A Wlan Removed! interface = " << interface << "; ssid = " << ssid << Q_FUNC_INFO <<__LINE__;
@ -428,16 +431,8 @@ void WlanPage::onActivatedWlanChanged(QString uuid, NetworkManager::ActiveConnec
m_resource->getSsidByUuid(uuid, ssid);
if (state == NetworkManager::ActiveConnection::State::Activating) {
qDebug() << "[WlanPage] wirelessActivating" << devName << ssid;
emit wirelessActivating(devName, ssid);
}
if (state == NetworkManager::ActiveConnection::State::Activated || state == NetworkManager::ActiveConnection::State::Deactivated)
{
qDebug() << "[WlanPage] because ActivatedWlanChanged " << devName;
emit listUpdate(devName);
}
qDebug() << "emit wlanActiveConnectionStateChanged" << devName << ssid << state;
emit wlanActiveConnectionStateChanged(devName, ssid, state);
if (state == NetworkManager::ActiveConnection::State::Deactivated) {
QList<KyApConnectItem *> apConnectItemList;

View File

@ -36,7 +36,9 @@ public:
void showDetailPage(QString devName, QString uuid);
signals:
void oneItemExpanded(const QString &ssid);
void wirelessActivating(QString devName, QString ssid);
void wlanAdd(QString devName, QStringList info);
void wlanRemove(QString devName,QString ssid);
void wlanActiveConnectionStateChanged(QString interface, QString ssid, int status);
void hotspotDeactivated(QString devName, QString ssid);
void hotspotActivated(QString devName, QString ssid);
void signalStrengthChange(QString devName, QString ssid, int strength);