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