feat(lan): Emit dbus signal when lan connected/disconnected/added/removed
Description: 当有线网增删连断时,发出dbus信号通知控制面板更新 Log: 当有线网增删连断时,发出dbus信号通知控制面板更新
This commit is contained in:
parent
afc47aee93
commit
49eccd8ac2
|
@ -44,6 +44,9 @@ class DbusAdaptor: public QDBusAbstractAdaptor
|
|||
" </method>\n"
|
||||
" <signal name=\"getWifiListFinished\"/>\n"
|
||||
" <signal name=\"configurationChanged\"/>\n"
|
||||
" <signal name=\"wiredConnectionAdded\"/>\n"
|
||||
" <signal name=\"wiredConnectionRemoved\"/>\n"
|
||||
" <signal name=\"actWiredConnectionChanged\"/>\n"
|
||||
" </interface>\n"
|
||||
"")
|
||||
public:
|
||||
|
@ -61,6 +64,9 @@ public Q_SLOTS: // METHODS
|
|||
Q_SIGNALS: // SIGNALS
|
||||
void getWifiListFinished();
|
||||
void configurationChanged();
|
||||
void wiredConnectionAdded();
|
||||
void wiredConnectionRemoved();
|
||||
void actWiredConnectionChanged();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -717,6 +717,7 @@ void KylinDBus::getConnectNetIp(QString netUuid)
|
|||
//监听有线网络ip变化
|
||||
void KylinDBus::getLanIpChanged()
|
||||
{
|
||||
m_lanPathList.clear();
|
||||
QDBusInterface m_interface("org.freedesktop.NetworkManager",
|
||||
"/org/freedesktop/NetworkManager/Settings",
|
||||
"org.freedesktop.NetworkManager.Settings",
|
||||
|
@ -742,6 +743,7 @@ void KylinDBus::getLanIpChanged()
|
|||
objNet.path(),
|
||||
QString("org.freedesktop.NetworkManager.Settings.Connection"),
|
||||
QString("Updated"), this, SLOT(onLanIpPropertiesChanged() ) );
|
||||
m_lanPathList.append(objNet.path());
|
||||
} else if (key == "802-11-wireless") {
|
||||
QDBusConnection::systemBus().connect(QString("org.freedesktop.NetworkManager"),
|
||||
objNet.path(),
|
||||
|
@ -1036,6 +1038,8 @@ void KylinDBus::onNewConnection(QDBusObjectPath objPath)
|
|||
if (key == "802-3-ethernet") {
|
||||
emit this->updateWiredList(0); //send this signal to update wired network list
|
||||
emit this->newConnAdded(0);
|
||||
m_lanPathList.append(objPath.path());
|
||||
emit mw->wiredConnectionAdded();
|
||||
//syslog(LOG_DEBUG, "A new wired network was created.");
|
||||
qDebug()<<"A new wired network was created.";
|
||||
break;
|
||||
|
@ -1101,10 +1105,13 @@ void KylinDBus::onNewConnection(QDBusObjectPath objPath)
|
|||
void KylinDBus::onConnectionRemoved(QDBusObjectPath objPath)
|
||||
{
|
||||
//syslog(LOG_DEBUG, "An old network was removed from configure directory.");
|
||||
qDebug()<<"An old network was removed from configure directory.";
|
||||
|
||||
if (mw->is_btnLanList_clicked == 1) {
|
||||
emit this->updateWiredList(0); //send this signal to update wired network list
|
||||
if (m_lanPathList.contains(objPath.path())) {
|
||||
m_lanPathList.removeOne(objPath.path());
|
||||
qDebug()<<"An old network was removed from configure directory.";
|
||||
if (mw->is_btnLanList_clicked == 1) {
|
||||
emit this->updateWiredList(0); //send this signal to update wired network list
|
||||
}
|
||||
emit mw->wiredConnectionRemoved();
|
||||
}
|
||||
|
||||
onWiredSettingNumChanged();
|
||||
|
@ -1724,7 +1731,6 @@ void KylinDBus::onLanPropertyChanged(QVariantMap qvm)
|
|||
qDebug()<<"kylin-nm receive a signal 'Device.Wired PropertiesChanged' about interface.";
|
||||
isRunningFunction = true; //function onLanPropertyChanged is running
|
||||
time->start(3000);
|
||||
|
||||
QString str = qvm.value("Carrier").toString();
|
||||
if (str == "false" || str == "true") {
|
||||
getPhysicalCarrierState(1);
|
||||
|
|
|
@ -147,6 +147,7 @@ private:
|
|||
QGSettings *m_tastbar_gsettings = nullptr;
|
||||
QGSettings *m_gsettings = nullptr;
|
||||
QGSettings *m_transparency_gsettings = nullptr;
|
||||
QStringList m_lanPathList;//有线网dbuspath列表
|
||||
|
||||
signals:
|
||||
void updateWiredList(int n);
|
||||
|
|
|
@ -3387,6 +3387,7 @@ void MainWindow::handleLanDisconn()
|
|||
qDebug()<<"Wired net is disconnected!";
|
||||
|
||||
QString txt(tr("Wired net is disconnected"));
|
||||
emit this->actWiredConnectionChanged();
|
||||
objKyDBus->showDesktopNotify(txt);
|
||||
currSelNetName = "";
|
||||
oldActLanName = "";
|
||||
|
@ -3669,6 +3670,7 @@ void MainWindow::onExternalConnectionChange(QString type, bool isConnUp)
|
|||
|
||||
void MainWindow::onExternalLanChange()
|
||||
{
|
||||
emit this->actWiredConnectionChanged();
|
||||
if (is_btnLanList_clicked) {
|
||||
onBtnNetListClicked(0);
|
||||
} else {
|
||||
|
@ -3924,6 +3926,7 @@ void MainWindow::connLanDone(int connFlag)
|
|||
//this->ksnm->execGetLanList();
|
||||
|
||||
QString txt(tr("Conn Ethernet Success"));
|
||||
emit this->actWiredConnectionChanged();
|
||||
objKyDBus->showDesktopNotify(txt);
|
||||
}
|
||||
|
||||
|
|
|
@ -421,6 +421,9 @@ signals:
|
|||
void getWifiListFinished();
|
||||
void startReconnectWifi(const QString& ssid);
|
||||
void stopReconnectWifi(const QString& ssid);
|
||||
void wiredConnectionAdded();
|
||||
void wiredConnectionRemoved();
|
||||
void actWiredConnectionChanged();
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
|
Loading…
Reference in New Issue