|
|
|
@ -41,25 +41,8 @@
|
|
|
|
|
#include <tqdbuserror.h>
|
|
|
|
|
#include <tqdbusobjectpath.h>
|
|
|
|
|
|
|
|
|
|
// NM headers
|
|
|
|
|
#include <NetworkManager.h>
|
|
|
|
|
|
|
|
|
|
// knm headers
|
|
|
|
|
#include "knetworkmanager-connection_setting_widget_interface.h"
|
|
|
|
|
#include "knetworkmanager-connection_setting.h"
|
|
|
|
|
#include "knetworkmanager-connection_setting_info.h"
|
|
|
|
|
#include "knetworkmanager-connection_setting_ipv4.h"
|
|
|
|
|
#include "knetworkmanager-connection_setting_wired.h"
|
|
|
|
|
#include "knetworkmanager-connection_setting_cdma.h"
|
|
|
|
|
#include "knetworkmanager-connection_setting_gsm.h"
|
|
|
|
|
#include "knetworkmanager-connection_setting_wireless.h"
|
|
|
|
|
#include "knetworkmanager-connection_setting_wireless_security.h"
|
|
|
|
|
#include "knetworkmanager-devicestore.h"
|
|
|
|
|
#include "knetworkmanager-connection.h"
|
|
|
|
|
#include "knetworkmanager-wired_connection.h"
|
|
|
|
|
#include "knetworkmanager-wireless_connection.h"
|
|
|
|
|
#include "knetworkmanager-vpn_connection.h"
|
|
|
|
|
#include "knetworkmanager-connection_store.h"
|
|
|
|
|
#include "knetworkmanager-connection_settings_dialog.h"
|
|
|
|
|
#include "knetworkmanager-connection_setting_cdma_widget.h"
|
|
|
|
|
#include "knetworkmanager-connection_setting_gsm_widget.h"
|
|
|
|
@ -69,16 +52,14 @@
|
|
|
|
|
#include "knetworkmanager-connection_setting_wireless_security_widget.h"
|
|
|
|
|
#include "knetworkmanager-connection_setting_ipv4_widget.h"
|
|
|
|
|
#include "knetworkmanager-connection_setting_info_widget.h"
|
|
|
|
|
#include "knetworkmanager-connection_setting_vpn_widget.h"
|
|
|
|
|
#include "knetworkmanager-device.h"
|
|
|
|
|
#include "knetworkmanager-nm_proxy.h"
|
|
|
|
|
#include "knetworkmanager-storage.h"
|
|
|
|
|
#include "knetworkmanager-wireless_network.h"
|
|
|
|
|
#include "knetworkmanager-wireless_manager.h"
|
|
|
|
|
|
|
|
|
|
char use_new_wireless_essid = 0;
|
|
|
|
|
TQByteArray new_wireless_essid;
|
|
|
|
|
|
|
|
|
|
using namespace ConnectionSettings;
|
|
|
|
|
|
|
|
|
|
ConnectionSettingsDialogImpl::ConnectionSettingsDialogImpl(TDENetworkConnection* conn, bool new_conn, TQWidget* parent, const char* name, bool modal, WFlags fl)
|
|
|
|
|
: ConnectionSettingsDialog(parent, name, modal, fl)
|
|
|
|
|
, _conn(conn)
|
|
|
|
@ -176,7 +157,7 @@ ConnectionSettingsDialogImpl::createWidgetsForVPN(TDENetworkConnection* conn, bo
|
|
|
|
|
TQValueList<WidgetInterface*> ret;
|
|
|
|
|
|
|
|
|
|
// widgetlist for wired connection
|
|
|
|
|
ret.append(new ConnectionSettings::VPNWidgetImpl(conn, new_conn));
|
|
|
|
|
// ret.append(new ConnectionSettings::VPNWidgetImpl(conn, new_conn));
|
|
|
|
|
ret.append(new ConnectionSettings::InfoWidgetImpl(conn));
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
@ -221,46 +202,55 @@ ConnectionSettingsDialogImpl::createWidgetsForConnection(TDENetworkConnection* c
|
|
|
|
|
* dev != NULL -> A connection should be edited for connection on this device
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if (!conn)
|
|
|
|
|
{
|
|
|
|
|
if (!conn) {
|
|
|
|
|
// TODO: create an empty widget and show an error
|
|
|
|
|
kdWarning() << k_funcinfo << "Not handled yet" << endl;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
else {
|
|
|
|
|
TQValueList<WidgetInterface*> widgets;
|
|
|
|
|
// TODO: move to a factory class
|
|
|
|
|
if (conn->getType() == NM_SETTING_WIRELESS_SETTING_NAME) {
|
|
|
|
|
if (conn->type() == TDENetworkConnectionType::WiFi) {
|
|
|
|
|
if (use_new_wireless_essid == 0) {
|
|
|
|
|
widgets = createWidgetsForWireless(conn, new_conn, setting);
|
|
|
|
|
widgets = createWidgetsForWireless(conn, new_conn);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
createWidgetsForWirelessKnownESSID(conn, new_conn, setting, new_wireless_essid);
|
|
|
|
|
new_wireless_essid = NULL;
|
|
|
|
|
createWidgetsForWirelessKnownESSID(conn, new_conn, new_wireless_essid);
|
|
|
|
|
new_wireless_essid = TQByteArray();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (conn->type() == TDENetworkConnectionType::WiredEthernet) {
|
|
|
|
|
widgets = createWidgetsForWired(conn, new_conn);
|
|
|
|
|
}
|
|
|
|
|
else if (conn->type() == TDENetworkConnectionType::Modem) {
|
|
|
|
|
TDEModemConnection* modemconn = dynamic_cast<TDEModemConnection*>(conn);
|
|
|
|
|
if (modemconn) {
|
|
|
|
|
if (modemconn->type == TDEModemConnectionType::CDMA) {
|
|
|
|
|
widgets = createWidgetsForCDMA(conn, new_conn);
|
|
|
|
|
}
|
|
|
|
|
else if (modemconn->type == TDEModemConnectionType::GSM) {
|
|
|
|
|
widgets = createWidgetsForGSM(conn, new_conn);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
kdWarning() << k_funcinfo << "Specific modem type not handled yet" << endl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (conn->getType() == NM_SETTING_WIRED_SETTING_NAME)
|
|
|
|
|
widgets = createWidgetsForWired(conn, new_conn, setting);
|
|
|
|
|
else if (conn->getType() == NM_SETTING_CDMA_SETTING_NAME)
|
|
|
|
|
widgets = createWidgetsForCDMA(conn, new_conn, setting);
|
|
|
|
|
else if (conn->getType() == NM_SETTING_GSM_SETTING_NAME)
|
|
|
|
|
widgets = createWidgetsForGSM(conn, new_conn, setting);
|
|
|
|
|
else if (conn->getType() == NM_SETTING_VPN_SETTING_NAME)
|
|
|
|
|
widgets = createWidgetsForVPN(conn, new_conn, setting);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// else if (conn->getType() == NM_SETTING_VPN_SETTING_NAME) {
|
|
|
|
|
// widgets = createWidgetsForVPN(conn, new_conn);
|
|
|
|
|
// }
|
|
|
|
|
else {
|
|
|
|
|
kdWarning() << k_funcinfo << "Not handled yet" << endl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int id;
|
|
|
|
|
for (TQValueList<WidgetInterface*>::Iterator it = widgets.begin(); it != widgets.end(); ++it)
|
|
|
|
|
{
|
|
|
|
|
for (TQValueList<WidgetInterface*>::Iterator it = widgets.begin(); it != widgets.end(); ++it) {
|
|
|
|
|
id = wstackSettings->addWidget(*it);
|
|
|
|
|
_widgetIds.append(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (widgets.begin() != widgets.end())
|
|
|
|
|
if (widgets.begin() != widgets.end()) {
|
|
|
|
|
activateWidget(*widgets.begin());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -275,13 +265,10 @@ ConnectionSettingsDialogImpl::updateDialogForDeviceType()
|
|
|
|
|
delete page;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_conn)
|
|
|
|
|
{
|
|
|
|
|
connect(_conn, TQT_SIGNAL(validityChanged()), this, TQT_SLOT(slotEnableButtons()));
|
|
|
|
|
if (_conn) {
|
|
|
|
|
createWidgetsForConnection(_conn, _new_conn);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
else {
|
|
|
|
|
// this should never happen
|
|
|
|
|
TQLabel* lbl = new TQLabel(wstackSettings, "Unknown Device Type");
|
|
|
|
|
wstackSettings->addWidget(lbl);
|
|
|
|
@ -291,56 +278,41 @@ ConnectionSettingsDialogImpl::updateDialogForDeviceType()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
ConnectionSettingsDialogImpl::getDeviceTypeFromConnection(Connection* conn)
|
|
|
|
|
ConnectionSettingsDialogImpl::getDeviceTypeFromConnection(TDENetworkConnection* conn)
|
|
|
|
|
{
|
|
|
|
|
if (conn->getType() == NM_SETTING_WIRELESS_SETTING_NAME)
|
|
|
|
|
return NM_DEVICE_TYPE_WIFI;
|
|
|
|
|
else if (conn->getType() == NM_SETTING_WIRED_SETTING_NAME)
|
|
|
|
|
return NM_DEVICE_TYPE_ETHERNET;
|
|
|
|
|
else if (conn->getType() == NM_SETTING_GSM_SETTING_NAME)
|
|
|
|
|
return NM_DEVICE_TYPE_MODEM;
|
|
|
|
|
else if (conn->getType() == NM_SETTING_CDMA_SETTING_NAME)
|
|
|
|
|
return NM_DEVICE_TYPE_MODEM;
|
|
|
|
|
|
|
|
|
|
return NM_DEVICE_TYPE_UNKNOWN;
|
|
|
|
|
if (conn->type() == TDENetworkConnectionType::WiFi) {
|
|
|
|
|
return TDENetworkDeviceType::WiFi;
|
|
|
|
|
}
|
|
|
|
|
else if (conn->type() == TDENetworkConnectionType::WiredEthernet) {
|
|
|
|
|
return TDENetworkDeviceType::WiredEthernet;
|
|
|
|
|
}
|
|
|
|
|
else if (conn->type() == TDENetworkConnectionType::Modem) {
|
|
|
|
|
return TDENetworkDeviceType::Modem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TDENetworkDeviceType::Other;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ConnectionSettingsDialogImpl::slotConnect()
|
|
|
|
|
{
|
|
|
|
|
DeviceStore* dstore = DeviceStore::getInstance();
|
|
|
|
|
Device* dev = dstore->getDevices(getDeviceTypeFromConnection(_conn)).first();
|
|
|
|
|
ConnectionStore* cstore = ConnectionStore::getInstance();
|
|
|
|
|
NMProxy* nm = NMProxy::getInstance();
|
|
|
|
|
TQT_DBusError err;
|
|
|
|
|
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
|
|
|
|
|
|
|
|
|
|
// add the connection to the store
|
|
|
|
|
cstore->addConnection(_conn);
|
|
|
|
|
// add/save the connection
|
|
|
|
|
nm->saveConnection(_conn);
|
|
|
|
|
|
|
|
|
|
// activate device
|
|
|
|
|
if (dev && _conn && nm)
|
|
|
|
|
{
|
|
|
|
|
int id;
|
|
|
|
|
if (_conn->awaitingSecrets())
|
|
|
|
|
{
|
|
|
|
|
_conn->Connection::slotSecretsProvided(NULL);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// 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->ActivateConnectionAsync(id, "org.freedesktop.NetworkManagerUserSettings", _conn->getObjectPath(), TQT_DBusObjectPath(QCString(dev->getObjectPath())), _conn->getObjectPath(), err);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
emit connectionSaved();
|
|
|
|
@ -358,23 +330,15 @@ ConnectionSettingsDialogImpl::slotSave()
|
|
|
|
|
|
|
|
|
|
// let the widget know about it being the active one
|
|
|
|
|
widget = dynamic_cast<WidgetInterface*>(wstackSettings->widget(*current));
|
|
|
|
|
if (widget)
|
|
|
|
|
if (widget) {
|
|
|
|
|
deactivateWidget(widget);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Now save
|
|
|
|
|
ConnectionStore* cstore = ConnectionStore::getInstance();
|
|
|
|
|
NMProxy* nm = NMProxy::getInstance();
|
|
|
|
|
TQT_DBusError err;
|
|
|
|
|
|
|
|
|
|
// add the connection to the store
|
|
|
|
|
cstore->addConnection(_conn);
|
|
|
|
|
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
|
|
|
|
|
|
|
|
|
|
// if the connection waits for new secrets
|
|
|
|
|
// signal an error to NM, the user only wants to save
|
|
|
|
|
// the connection
|
|
|
|
|
if (_conn->awaitingSecrets())
|
|
|
|
|
_conn->slotSecretsError();
|
|
|
|
|
// save the connection
|
|
|
|
|
nm->saveConnection(_conn);
|
|
|
|
|
|
|
|
|
|
emit connectionSaved();
|
|
|
|
|
this->close(true);
|
|
|
|
@ -383,7 +347,6 @@ ConnectionSettingsDialogImpl::slotSave()
|
|
|
|
|
void
|
|
|
|
|
ConnectionSettingsDialogImpl::slotCancel()
|
|
|
|
|
{
|
|
|
|
|
_conn->slotSecretsError();
|
|
|
|
|
close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -471,26 +434,27 @@ ConnectionSettingsDialogImpl::slotEnableButtons()
|
|
|
|
|
Next: enabled if another widget is available
|
|
|
|
|
*/
|
|
|
|
|
enabled = true;
|
|
|
|
|
if (current == _widgetIds.fromLast())
|
|
|
|
|
if (current == _widgetIds.fromLast()) {
|
|
|
|
|
enabled = false;
|
|
|
|
|
}
|
|
|
|
|
pbNext->setEnabled(enabled);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Back: enabled if the current widget has a predecessor
|
|
|
|
|
*/
|
|
|
|
|
enabled = true;
|
|
|
|
|
if (current == _widgetIds.begin())
|
|
|
|
|
if (current == _widgetIds.begin()) {
|
|
|
|
|
enabled = false;
|
|
|
|
|
}
|
|
|
|
|
pbBack->setEnabled(enabled);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Connect: only show connect if the connection is valid
|
|
|
|
|
*/
|
|
|
|
|
if (_conn)
|
|
|
|
|
{
|
|
|
|
|
btnConnect->setEnabled(_conn->isValid());
|
|
|
|
|
pbSave->setEnabled(_conn->isValid());
|
|
|
|
|
|
|
|
|
|
if (_conn) {
|
|
|
|
|
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
|
|
|
|
|
btnConnect->setEnabled(nm->verifyConnectionSettings(_conn));
|
|
|
|
|
pbSave->setEnabled(nm->verifyConnectionSettings(_conn));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|