Commit 1b61dfbe authored by Lamarque Souza's avatar Lamarque Souza
Browse files

Report error message on VPN activation failure.

CCBUG: 287076
parent af9df710
......@@ -66,6 +66,7 @@ set(knm_nm_LIB_SRCS
nm-manager-interface.cpp
nm-device-interface.cpp
nm-ip4-config-interface.cpp
../../libs/service/events.cpp
)
kde4_add_library(knm_nm SHARED ${knm_nm_LIB_SRCS})
......
......@@ -40,6 +40,8 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
// knmservice includes
#include "activatablelist.h"
#include "notificationmanager.h"
#include "events.h"
#include "settings/ipv4.h"
......@@ -288,8 +290,42 @@ void NMDBusSettingsConnectionProvider::interfaceConnectionActivated()
// Now activate the connection
OrgFreedesktopNetworkManagerInterface nmIface(QLatin1String(NM_DBUS_SERVICE), QLatin1String(NM_DBUS_PATH), QDBusConnection::systemBus());
nmIface.ActivateConnection(QDBusObjectPath(ic->property("NMDBusObjectPath").toString()), QDBusObjectPath(deviceToActivateOn), QDBusObjectPath("/"));
if (vpn) {
// to report error messages in notification manager
QDBusPendingCall reply = nmIface.ActivateConnection(QDBusObjectPath(ic->property("NMDBusObjectPath").toString()), QDBusObjectPath(deviceToActivateOn), QDBusObjectPath("/"));
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, 0);
watcher->setProperty("interfaceConnection", qVariantFromValue((void *)ic));
connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(onVpnConnectionActivated(QDBusPendingCallWatcher*)));
} else {
// regular connections already report error messages.
nmIface.ActivateConnection(QDBusObjectPath(ic->property("NMDBusObjectPath").toString()), QDBusObjectPath(deviceToActivateOn), QDBusObjectPath("/"));
}
}
}
void NMDBusSettingsConnectionProvider::onVpnConnectionActivated(QDBusPendingCallWatcher *watcher)
{
if (!watcher) {
return;
}
QDBusPendingReply<QVariantMapMap> reply = *watcher;
// Report errors only.
if (reply.isValid()) {
watcher->deleteLater();
return;
}
Knm::VpnInterfaceConnection *ic = (Knm::VpnInterfaceConnection *)watcher->property("interfaceConnection").value<void *>();
QString errorMsg = reply.error().message();
if (errorMsg.isEmpty()) {
NotificationManager::performNotification(Event::ConnectFailed, QString(), i18nc("@info:status Notification text when connection has failed","Connection %1 failed", ic->connectionName()), Knm::Connection::iconName(ic->connectionType()));
} else {
NotificationManager::performNotification(Event::ConnectFailed, QString(), i18nc("@info:status Notification text when connection has failed","<p>Connection %1 failed:</p><p>%2</p>", ic->connectionName(), errorMsg), Knm::Connection::iconName(ic->connectionType()));
}
watcher->deleteLater();
}
void NMDBusSettingsConnectionProvider::interfaceConnectionDeactivated()
......
......@@ -85,6 +85,7 @@ private Q_SLOTS:
void onConnectionAddArrived(QDBusPendingCallWatcher *watcher);
void interfaceConnectionActivated();
void interfaceConnectionDeactivated();
void onVpnConnectionActivated(QDBusPendingCallWatcher *watcher);
private:
enum Operation {Add, Remove, Update};
......
......@@ -658,4 +658,8 @@ void NotificationManager::statusChanged(NetworkManager::Status status)
}
}
void NotificationManager::performNotification(const QString &eventId, const QString &title, const QString &text, const QString &icon)
{
KNotification::event(eventId, title, text, KIcon(icon).pixmap(QSize(iconSize,iconSize)), 0, KNotification::CloseOnTimeout, *s_networkManagementComponentData);
}
// vim: sw=4 sts=4 et tw=100
......@@ -47,6 +47,7 @@ public:
void handleAdd(Knm::Activatable *);
void handleUpdate(Knm::Activatable *);
void handleRemove(Knm::Activatable *);
static void performNotification(const QString &eventId, const QString &title, const QString &text, const QString &icon);
KComponentData componentData() const;
protected Q_SLOTS:
......
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