Commit 7a1f9a1d authored by Jan Grulich's avatar Jan Grulich
Browse files

Notify about missing VPN plugin when trying to active VPN connection

parent 4d242bd8
......@@ -37,8 +37,12 @@
#include <QInputDialog>
#include <KNotification>
#include <KUser>
#include <KIcon>
#include <KProcess>
#include <KService>
#include <KServiceTypeTrader>
#include <KWindowSystem>
Handler::Handler(QObject* parent)
......@@ -58,7 +62,27 @@ void Handler::activateConnection(const QString& connection, const QString& devic
NMHandlerDebug() << "Not possible to activate this connection";
return;
}
NMHandlerDebug() << "Activating " << con->name() << " connection";
NMHandlerDebug() << "Activating " << con->name() << " connection";
if (con->settings()->connectionType() == NetworkManager::ConnectionSettings::Vpn) {
NetworkManager::VpnSetting::Ptr vpnSetting = con->settings()->setting(NetworkManager::Setting::Vpn).staticCast<NetworkManager::VpnSetting>();
if (vpnSetting) {
NMHandlerDebug() << "Checking VPN" << con->name() << "type:" << vpnSetting->serviceType();
// get the list of supported VPN service types
const KService::List services = KServiceTypeTrader::self()->query("PlasmaNetworkManagement/VpnUiPlugin",
QString::fromLatin1("[X-NetworkManager-Services]=='%1'").arg(vpnSetting->serviceType()));
if (services.isEmpty()) {
NMHandlerDebug() << "VPN" << vpnSetting->serviceType() << "not found, skipping";
KNotification *notification = new KNotification("MissingVpnPlugin", KNotification::Persistent, this);
notification->setComponentData(KComponentData("networkmanagement"));
notification->setTitle(con->name());
notification->setText(i18n("Missing VPN plugin"));
notification->setPixmap(KIcon("dialog-warning").pixmap(64, 64));
notification->sendEvent();
return;
}
}
}
NetworkManager::activateConnection(connection, device, specificObject);
}
......
......@@ -102,3 +102,8 @@ Name[x-test]=xxVPN connection state changedxx
Name[zh_CN]=VPN 连接状态改变
IconName=applications-internet
Action=Popup
[Event/MissingVpnPlugin]
Name=Missing VPN plugin
IconName=applications-internet
Action=Popup
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment