Merge branch '2209bug-new' into 'yhkylin/v101'

增加dbus判空 控制面板插件#代理 #有线网络 #无线网络前端  #网络模式配置

See merge request kylinos-src/kylin-nm!89
This commit is contained in:
赵世旭 2023-02-03 03:43:13 +00:00
commit 2548807fe2
6 changed files with 75 additions and 38 deletions

View File

@ -168,7 +168,9 @@ bool NetConnect::eventFilter(QObject *w, QEvent *e) {
if (!wiredSwitch->isCheckable()) {
showDesktopNotify(tr("No ethernet device avaliable"));
} else {
if (m_interface != nullptr && m_interface->isValid()) {
m_interface->call(QStringLiteral("setWiredSwitchEnable"), !wiredSwitch->isChecked());
}
return true;
}
}
@ -242,7 +244,7 @@ void NetConnect::initComponent() {
//获取网卡列表
void NetConnect::getDeviceStatusMap(QMap<QString, bool> &map)
{
if (!m_interface->isValid()) {
if (m_interface == nullptr || !m_interface->isValid()) {
return;
}
qDebug() << "[NetConnect]call getDeviceListAndEnabled" << __LINE__;
@ -357,6 +359,9 @@ void NetConnect::runExternalApp() {
//激活
void NetConnect::activeConnect(QString ssid, QString deviceName, int type) {
if (m_interface == nullptr || !m_interface->isValid()) {
return;
}
qDebug() << "[NetConnect]call activateConnect" << __LINE__;
m_interface->call(QStringLiteral("activateConnect"),type, deviceName, ssid);
qDebug() << "[NetConnect]call activateConnect respond" << __LINE__;
@ -364,6 +369,9 @@ void NetConnect::activeConnect(QString ssid, QString deviceName, int type) {
//断开
void NetConnect::deActiveConnect(QString ssid, QString deviceName, int type) {
if (m_interface == nullptr || !m_interface->isValid()) {
return;
}
qDebug() << "[NetConnect]call deActivateConnect" << __LINE__;
m_interface->call(QStringLiteral("deActivateConnect"),type, deviceName, ssid);
qDebug() << "[NetConnect]call deActivateConnect respond" << __LINE__;
@ -377,7 +385,7 @@ void NetConnect::initNetListFromDevice(QString deviceName)
qDebug() << "[NetConnect]initNetListFromDevice " << deviceName << " not exist";
return;
}
if (!m_interface->isValid()) {
if (m_interface == nullptr || !m_interface->isValid()) {
return;
}
qDebug() << "[NetConnect]call getWiredList" << __LINE__;
@ -442,7 +450,7 @@ void NetConnect::addLanItem(ItemFrame *frame, QString devName, QStringList infoL
connect(lanItem->infoLabel, &GrayInfoButton::clicked, this, [=]{
// open landetail page
if (!m_interface->isValid()) {
if (m_interface == nullptr || !m_interface->isValid()) {
return;
}
qDebug() << "[NetConnect]call showPropertyWidget" << __LINE__;
@ -469,6 +477,9 @@ void NetConnect::addLanItem(ItemFrame *frame, QString devName, QStringList infoL
//增加设备
void NetConnect::addDeviceFrame(QString devName)
{
if (m_interface == nullptr || !m_interface->isValid()) {
return;
}
qDebug() << "[NetConnect]addDeviceFrame " << devName;
qDebug() << "[NetConnect]call getDeviceListAndEnabled" << __LINE__;
@ -528,7 +539,7 @@ void NetConnect::addDeviceFrame(QString devName)
});
connect(itemFrame->addLanWidget, &AddNetBtn::clicked, this, [=](){
if (m_interface->isValid()) {
if (m_interface != nullptr && m_interface->isValid()) {
qDebug() << "[NetConnect]call showCreateWiredConnectWidget" << devName << __LINE__;
m_interface->call(QStringLiteral("showCreateWiredConnectWidget"), devName);
qDebug() << "[NetConnect]call setDeviceEnable Respond" << __LINE__;
@ -725,7 +736,7 @@ void NetConnect::addOneLanFrame(ItemFrame *frame, QString deviceName, QStringLis
connect(lanItem->infoLabel, &GrayInfoButton::clicked, this, [=]{
// open landetail page
if (!m_interface->isValid()) {
if (m_interface == nullptr || !m_interface->isValid()) {
return;
}
qDebug() << "[NetConnect]call showPropertyWidget" << deviceName << connUuid << __LINE__;
@ -867,7 +878,7 @@ int NetConnect::getInsertPos(QString connName, QString deviceName)
{
qDebug() << "[NetConnect]getInsertPos" << connName << deviceName;
int index = 0;
if(!m_interface->isValid()) {
if(m_interface == nullptr || !m_interface->isValid()) {
index = 0;
} else {
qDebug() << "[NetConnect]call getWiredList" << __LINE__;

View File

@ -29,7 +29,7 @@ AppListWidget::AppListWidget(QString path, QWidget *parent)
AppListWidget::~AppListWidget()
{
delete m_dbusInterface;
}
/**
@ -79,8 +79,9 @@ void AppListWidget::onAppCheckStateChanged()
*/
void AppListWidget::AddAppProxyConfig()
{
if(!m_dbusInterface->isValid()) {
if(m_dbusInterface == nullptr || !m_dbusInterface->isValid()) {
qWarning ()<< "init AppProxy dbus error";
return;
}
qDebug() << "call QDBusInterface addAppIntoProxy";
@ -93,8 +94,9 @@ void AppListWidget::AddAppProxyConfig()
*/
void AppListWidget::RemoveAppProxyConfig()
{
if(!m_dbusInterface->isValid()) {
if(m_dbusInterface == nullptr || !m_dbusInterface->isValid()) {
qWarning ()<< "init AppProxy dbus error";
return;
}
qDebug() << "call QDBusInterface delAppIntoProxy";
@ -135,4 +137,7 @@ void AppListWidget::initDbus()
"/org/ukui/SettingsDaemon/AppProxy",
"org.ukui.SettingsDaemon.AppProxy",
QDBusConnection::sessionBus());
if(!m_dbusInterface->isValid()) {
qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
}
}

View File

@ -68,6 +68,7 @@ Proxy::~Proxy()
{
if (!mFirstLoad) {
plugin_leave();
delete m_appProxyDbus;
}
}
@ -702,6 +703,9 @@ void Proxy::initDbus()
"/org/ukui/SettingsDaemon/AppProxy",
"org.ukui.SettingsDaemon.AppProxy",
QDBusConnection::sessionBus());
if(!m_appProxyDbus->isValid()) {
qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
}
}
void Proxy::initAppProxyStatus()
@ -752,8 +756,11 @@ void Proxy::setAptProxy(QString host, QString port, bool status)
"/",
"com.control.center.interface",
QDBusConnection::systemBus());
if (mAptproxyDbus->isValid())
if (mAptproxyDbus->isValid()) {
QDBusReply<bool> reply = mAptproxyDbus->call("setaptproxy", host, port , status);
}
delete mAptproxyDbus;
mAptproxyDbus = nullptr;
}
QHash<QString, QVariant> Proxy::getAptProxy()
@ -786,6 +793,8 @@ QHash<QString, QVariant> Proxy::getAptProxy()
mAptInfo.insert(it.arg, it.out.variant());
}
}
delete mAptproxyDbus;
mAptproxyDbus = nullptr;
return mAptInfo;
}
@ -814,8 +823,9 @@ void Proxy::reboot()
"/org/gnome/SessionManager",
"org.gnome.SessionManager",
QDBusConnection::sessionBus());
if (rebootDbus->isValid()) {
rebootDbus->call("reboot");
}
delete rebootDbus;
rebootDbus = nullptr;
}
@ -841,8 +851,9 @@ QFrame *Proxy::setLine(QFrame *frame)
bool Proxy::getAppProxyState()
{
bool state = true;
if(!m_appProxyDbus->isValid()) {
if(m_appProxyDbus == nullptr || !m_appProxyDbus->isValid()) {
qWarning ()<< "init AppProxy dbus error";
return false;
}
//获取应用代理开启状态
@ -859,7 +870,7 @@ bool Proxy::getAppProxyState()
void Proxy::setAppProxyState(bool state)
{
if(!m_appProxyDbus->isValid()) {
if(m_appProxyDbus == nullptr || !m_appProxyDbus->isValid()) {
qWarning ()<< "init AppProxy dbus error";
return;
}
@ -881,6 +892,7 @@ QStringList Proxy::getAppProxyConf()
if(!dbusInterface.isValid()) {
qWarning ()<< "init AppProxy dbus error";
return info;
}
//获取应用代理配置信息
@ -903,11 +915,12 @@ QStringList Proxy::getAppProxyConf()
void Proxy::setAppProxyConf(QStringList list)
{
//AppProxyConf 必填项数量为3
if (list.count() < 3) {
return;
}
if(!m_appProxyDbus->isValid()) {
if(m_appProxyDbus == nullptr || !m_appProxyDbus->isValid()) {
qWarning ()<< "init AppProxy dbus error";
return;
}
@ -1244,7 +1257,6 @@ void Proxy::onAppProxyConfChanged()
{
if (!getipEditState(m_ipAddressLineEdit->text()) || m_portLineEdit->text().isEmpty()) {
return;
qDebug() << "onAppProxyConfChanged return";
}
if (m_ipAddressLineEdit->text().isEmpty()) {
@ -1261,8 +1273,6 @@ void Proxy::onAppProxyConfChanged()
m_appProxyInfo.append("");
m_appProxyInfo.append("");
}
qDebug() << m_appProxyInfo << Q_FUNC_INFO << __LINE__;
}
}

View File

@ -262,8 +262,8 @@ private:
QFileSystemWatcher *mfileWatch_1;
QFileSystemWatcher *mfileWatch_2;
QDBusInterface *mAptproxyDbus;
QDBusInterface *m_appProxyDbus;
// QDBusInterface *mAptproxyDbus;
QDBusInterface *m_appProxyDbus = nullptr;
bool isExistSettings = false;
bool settingsCreate;

View File

@ -227,7 +227,9 @@ bool WlanConnect::eventFilter(QObject *w, QEvent *e) {
if (!getSwitchBtnEnable()) {
showDesktopNotify(tr("No wireless network card detected"));
} else {
if (m_interface != nullptr && m_interface->isValid()) {
m_interface->call(QStringLiteral("setWirelessSwitchEnable"), !getSwitchBtnState());
}
return true;
}
}
@ -298,7 +300,7 @@ void WlanConnect::initComponent() {
void WlanConnect::reScan()
{
qDebug() << "time to rescan wifi";
if (m_interface->isValid()) {
if (m_interface != nullptr && m_interface->isValid()) {
qDebug() << "[WlanConnect]call reScan" << __LINE__;
m_interface->call("reScan");
qDebug() << "[WlanConnect]call reScan respond" << __LINE__;
@ -312,7 +314,7 @@ void WlanConnect::updateList()
return;
}
qDebug() << "update list";
if(m_interface->isValid()) {
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__;
@ -684,7 +686,7 @@ void WlanConnect::onNetworkRemove(QString deviceName, QString wlannName)
//获取设备列表=======================================================
void WlanConnect::getDeviceList(QStringList &list)
{
if (!m_interface->isValid()) {
if (m_interface == nullptr || !m_interface->isValid()) {
return;
}
qDebug() << "[WlanConnect]call getDeviceListAndEnabled" << __LINE__;
@ -703,7 +705,7 @@ void WlanConnect::getDeviceList(QStringList &list)
void WlanConnect::initSwtichState()
{
if (!m_interface->isValid()) {
if (m_interface == nullptr || !m_interface->isValid()) {
return;
}
@ -745,7 +747,7 @@ void WlanConnect::initNetListFromDevice(QString deviceName)
qDebug() << "[WlanConnect]initNetListFromDevice " << deviceName << " not exist";
return;
}
if (!m_interface->isValid()) {
if (m_interface == nullptr || !m_interface->isValid()) {
return;
}
qDebug() << "[WlanConnect]call getWirelessList" << __LINE__;
@ -878,6 +880,9 @@ void WlanConnect::showLayout(QVBoxLayout * layout) {
//获取应该插入哪个位置
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__;
@ -904,7 +909,7 @@ int WlanConnect::sortWlanNet(QString deviceName, QString name, QString signal)
}
void WlanConnect::activeConnect(QString netName, QString deviceName, int type) {
if (!m_interface->isValid()) {
if (m_interface == nullptr || !m_interface->isValid()) {
return;
}
qDebug() << "[WlanConnect]call activateConnect" << __LINE__;
@ -913,7 +918,7 @@ void WlanConnect::activeConnect(QString netName, QString deviceName, int type) {
}
void WlanConnect::deActiveConnect(QString netName, QString deviceName, int type) {
if (!m_interface->isValid()) {
if (m_interface == nullptr || !m_interface->isValid()) {
return;
}
qDebug() << "[WlanConnect]call deActivateConnect" << __LINE__;
@ -966,7 +971,7 @@ void WlanConnect::addDeviceFrame(QString devName)
deviceFrameMap.insert(devName, itemFrame);
connect(itemFrame->addWlanWidget, &AddNetBtn::clicked, this, [=](){
if (m_interface->isValid()) {
if (m_interface != nullptr && m_interface->isValid()) {
qDebug() << "[NetConnect]call showAddOtherWlanWidget" << devName << __LINE__;
m_interface->call(QStringLiteral("showAddOtherWlanWidget"), devName);
qDebug() << "[NetConnect]call setDeviceEnable Respond" << __LINE__;
@ -1034,7 +1039,7 @@ void WlanConnect::addOneWlanFrame(ItemFrame *frame, QString deviceName, QString
connect(wlanItem->infoLabel, &GrayInfoButton::clicked, this, [=]{
// open detail page
if (!m_interface->isValid()) {
if (m_interface == nullptr || !m_interface->isValid()) {
return;
}
qDebug() << "[WlanConnect]call showPropertyWidget" << __LINE__;

View File

@ -37,6 +37,9 @@ NetworkModeConfig::NetworkModeConfig(QObject *parent) : QObject(parent)
"/firewall",
"com.ksc.defender.firewall",
QDBusConnection::systemBus());
if(!m_dbusInterface->isValid()) {
qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
}
}
int NetworkModeConfig::getNetworkModeConfig(QString uuid)
@ -46,8 +49,9 @@ int NetworkModeConfig::getNetworkModeConfig(QString uuid)
return -1;
}
if(!m_dbusInterface->isValid()) {
qWarning ()<< "init com.ksc.defender dbus error";
if(m_dbusInterface == nullptr || !m_dbusInterface->isValid()) {
qWarning () << "com.ksc.defender dbus is invalid";
return -1;
}
QDBusReply<int> reply = m_dbusInterface->call("get_networkModeConfig", uuid);
@ -61,8 +65,9 @@ int NetworkModeConfig::getNetworkModeConfig(QString uuid)
void NetworkModeConfig::setNetworkModeConfig(QString uuid, QString cardName, QString ssid, int mode)
{
if(!m_dbusInterface->isValid()) {
qWarning ()<< "init com.ksc.defender dbus error";
if(m_dbusInterface == nullptr || !m_dbusInterface->isValid()) {
qWarning () << "com.ksc.defender dbus is invalid";
return;
}
QDBusReply<int> reply = m_dbusInterface->call("set_networkModeConfig", uuid, cardName, ssid, mode);
@ -75,8 +80,9 @@ void NetworkModeConfig::setNetworkModeConfig(QString uuid, QString cardName, QSt
int NetworkModeConfig::breakNetworkConnect(QString uuid, QString cardName, QString ssid)
{
if(!m_dbusInterface->isValid()) {
qWarning ()<< "init com.ksc.defender dbus error";
if(m_dbusInterface == nullptr || !m_dbusInterface->isValid()) {
qWarning () << "com.ksc.defender dbus is invalid";
return -1;
}
QDBusReply<int> reply = m_dbusInterface->call("break_networkConnect", uuid, cardName, ssid);