From 71bf63b44f9ec183b1af7d2051c1967ee4571bcf Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Thu, 17 Jan 2013 17:38:32 -0600 Subject: [PATCH] Report backend connection modification failures to user Refresh network list on connection modification --- .../tdenetman-connection_settings_dialog.cpp | 35 +++++++++++-------- .../src/tdenetman-connection_editor.cpp | 16 ++++++--- tdenetworkmanager/src/tdenetman-tray.cpp | 2 +- 3 files changed, 33 insertions(+), 20 deletions(-) diff --git a/tdenetworkmanager/src/configwidgets/tdenetman-connection_settings_dialog.cpp b/tdenetworkmanager/src/configwidgets/tdenetman-connection_settings_dialog.cpp index 50ac293..d6c673f 100644 --- a/tdenetworkmanager/src/configwidgets/tdenetman-connection_settings_dialog.cpp +++ b/tdenetworkmanager/src/configwidgets/tdenetman-connection_settings_dialog.cpp @@ -286,20 +286,23 @@ ConnectionSettingsDialogImpl::slotConnect() TDEGlobalNetworkManager* nm = KGlobal::networkManager(); // add/save the connection - nm->saveConnection(_conn); - - // activate device - if (_conn && nm) { -// // VPN connection needs a special specific object -// if (_conn->getType() == NM_SETTING_VPN_SETTING_NAME) { -// TQT_DBusObjectPath act_conn = nm->getDefaultActiveConnection(); -// TQT_DBusObjectPath device = nm->getDeviceForActiveConnection(act_conn); -// nm->ActivateConnectionAsync(id, "org.freedesktop.NetworkManagerUserSettings", _conn->getObjectPath(), device, act_conn, err); -// } -// else { - // we need to call ActivateDevice async - nm->initiateConnection(_conn->UUID); -// } + if (nm->saveConnection(_conn)) { + // activate device + if (_conn && nm) { + // // VPN connection needs a special specific object + // if (_conn->getType() == NM_SETTING_VPN_SETTING_NAME) { + // TQT_DBusObjectPath act_conn = nm->getDefaultActiveConnection(); + // TQT_DBusObjectPath device = nm->getDeviceForActiveConnection(act_conn); + // nm->ActivateConnectionAsync(id, "org.freedesktop.NetworkManagerUserSettings", _conn->getObjectPath(), device, act_conn, err); + // } + // else { + // we need to call ActivateDevice async + nm->initiateConnection(_conn->UUID); + // } + } + } + else { + KMessageBox::error(this, i18n("Unable to save network connection!

Potential causes:
* Insufficient permissions
* NetworkManager not running
* DBUS failure"), i18n("Unable to perform requested operation")); } emit connectionSaved(); @@ -325,7 +328,9 @@ ConnectionSettingsDialogImpl::slotSave() TDEGlobalNetworkManager* nm = KGlobal::networkManager(); // save the connection - nm->saveConnection(_conn); + if (!nm->saveConnection(_conn)) { + KMessageBox::error(this, i18n("Unable to save network connection!

Potential causes:
* Insufficient permissions
* NetworkManager not running
* DBUS failure"), i18n("Unable to perform requested operation")); + } emit connectionSaved(); this->close(true); diff --git a/tdenetworkmanager/src/tdenetman-connection_editor.cpp b/tdenetworkmanager/src/tdenetman-connection_editor.cpp index 994105a..a0a4e83 100644 --- a/tdenetworkmanager/src/tdenetman-connection_editor.cpp +++ b/tdenetworkmanager/src/tdenetman-connection_editor.cpp @@ -33,13 +33,14 @@ #include #include -// kde headers +// tde headers #include #include #include #include #include #include +#include // tdenm headers #include "tdenetman-connection_editor.h" @@ -110,7 +111,7 @@ ConnectionEditorImpl::ConnectionEditorImpl(TQWidget* parent, const char* name, b popup->insertItem(KGlobal::iconLoader()->loadIcon("wired", KIcon::Small), i18n("Wired"), this, TQT_SLOT(slotNewWiredConnection())); // if (!VPNManager::getVPNServices().isEmpty()) { -// popup->insertItem(KGlobal::iconLoader()->loadIcon("encrypted", KIcon::Small), i18n("VPN"), this, TQT_SLOT(slotNewVPNConnection())); + popup->insertItem(KGlobal::iconLoader()->loadIcon("encrypted", KIcon::Small), i18n("VPN"), this, TQT_SLOT(slotNewVPNConnection())); // } pbNew->setPopup(popup); @@ -158,7 +159,7 @@ void ConnectionEditorImpl::slotNewWiredConnection() */ void ConnectionEditorImpl::slotNewVPNConnection() { -// slotEditNewConnection(new TDEVPNConnection()); + slotEditNewConnection(new TDEVPNConnection()); } /* @@ -174,6 +175,11 @@ void ConnectionEditorImpl::slotEditNewConnection(TDENetworkConnection* conn) void ConnectionEditorImpl::slotRefreshConnectionList() { + TDEGlobalNetworkManager* nm = KGlobal::networkManager(); + if (!nm) { + return; + } + nm->loadConnectionInformation(); fillConnectionList(); } @@ -224,7 +230,9 @@ void ConnectionEditorImpl::slotRemoveCurrentConnection() lvConnections->takeItem(item); delete item; - nm->deleteConnection(conn->UUID); + if (!nm->deleteConnection(conn->UUID)) { + KMessageBox::error(this, i18n("Unable to delete network connection!

Potential causes:
* Insufficient permissions
* NetworkManager not running
* DBUS failure"), i18n("Unable to perform requested operation")); + } } /* diff --git a/tdenetworkmanager/src/tdenetman-tray.cpp b/tdenetworkmanager/src/tdenetman-tray.cpp index 06c7e4d..fd955f3 100644 --- a/tdenetworkmanager/src/tdenetman-tray.cpp +++ b/tdenetworkmanager/src/tdenetman-tray.cpp @@ -165,7 +165,7 @@ void Tray::slotEditConnections() if (!nm) return; if (tdenetworkmanager_editor_dialog_count == 0) nm->loadConnectionInformation(); - ConnectionEditorImpl* dlg = new ConnectionEditorImpl(this); + ConnectionEditorImpl* dlg = new ConnectionEditorImpl(this, NULL, TRUE, (WFlags)TQt::WDestructiveClose); dlg->show(); }