diff --git a/tdenetworkmanager/src/CMakeLists.txt b/tdenetworkmanager/src/CMakeLists.txt index c3961da..9c89dfc 100644 --- a/tdenetworkmanager/src/CMakeLists.txt +++ b/tdenetworkmanager/src/CMakeLists.txt @@ -55,8 +55,7 @@ tde_add_tdeinit_executable( knetworkmanager AUTOMOC knetworkmanager-wired_device_tray.cpp knetworkmanager-wireless_device_tray.cpp knetworkmanager-wireless_menuitem.cpp knetworkmanager-menuitem.cpp knetworkmanager-menu_subhead.cpp - knetworkmanager-nmsettings.cpp - sha1.cpp md5.cpp xmlmarshaller.cpp + sha1.cpp md5.cpp knetworkmanager-wireless_network.cpp knetworkmanager-wireless_manager.cpp knetworkmanager-connection_editor.cpp knetworkmanager-plugin.cpp knetworkmanager-vpnplugin.cpp knetworkmanager-pluginmanager.cpp knetworkmanager-vpnservice.cpp knetworkmanager-vpnmanager.cpp diff --git a/tdenetworkmanager/src/knetworkmanager-nmsettings.cpp b/tdenetworkmanager/src/knetworkmanager-nmsettings.cpp deleted file mode 100644 index e0227c7..0000000 --- a/tdenetworkmanager/src/knetworkmanager-nmsettings.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-nminfo_dbus.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Timo Hoenig , - * Valentine Sinitsyn - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#include -#include - -#include - -#include -#include - -#include "knetworkmanager.h" -#include "knetworkmanager-nmsettings.h" -#include "knetworkmanager-connection_setting.h" -#include "knetworkmanager-connection_store.h" -#include "knetworkmanager-connection.h" - -#if !defined(NM_CHECK_VERSION) -#define NM_CHECK_VERSION(x,y,z) 0 -#endif - -class NMSettingsPrivate -{ - public: - NMSettingsPrivate() - : obj_path_index(0) - { - - } - - ~NMSettingsPrivate() - { - - } - - int obj_path_index; -}; - - -NMSettings* NMSettings::_instance = NULL; - -NMSettings* NMSettings::getInstance() -{ - // return singleton instance - if (_instance) - return _instance; - return (_instance = new NMSettings()); -} - -NMSettings::NMSettings() -{ - d = new NMSettingsPrivate(); - TQT_DBusConnection conn = TQT_DBusConnection::systemBus(); - - kdDebug() << "NMSettings::NMSettings" << endl; - -#if NM_CHECK_VERSION(0,8,992) - if (!conn.requestName("org.freedesktop.NetworkManagerUserSettings")) - kdError() << "req name failed for " << "org.freedesktop.NetworkManagerUserSettings" << endl; -#else - // request the name for the settings interface - if (!conn.requestName(NM_DBUS_SERVICE_USER_SETTINGS)) - kdError() << "req name failed for " << NM_DBUS_SERVICE_USER_SETTINGS << endl; -#endif - - // request the name for the connections here too - if (!conn.requestName(NM_DBUS_IFACE_SETTINGS_CONNECTION)) - kdError() << "req name failed for " << NM_DBUS_IFACE_SETTINGS_CONNECTION << endl; - - // request the name for the connections here too - if (!conn.requestName(NM_DBUS_IFACE_SETTINGS_CONNECTION_SECRETS)) - kdError() << "req name failed for " << NM_DBUS_IFACE_SETTINGS_CONNECTION_SECRETS << endl; - - // register on the DBus - if (!conn.registerObject(objectPath(), this)) - kdError() << "registerobjectpath failed" << endl; - - - ConnectionStore* cstore = ConnectionStore::getInstance(); - - // we need to get informed about new connections... - connect(cstore, TQT_SIGNAL(signalConnectionAdded(ConnectionSettings::Connection*)), this, TQT_SLOT(slotNewConnection(ConnectionSettings::Connection*))); -} - -NMSettings::~NMSettings() -{ - delete d; - TQT_DBusConnection conn = TQT_DBusConnection::systemBus(); - conn.unregisterObject(NM_DBUS_PATH_SETTINGS); -} - - -bool NMSettings::handleSignalSend(const TQT_DBusMessage& reply) -{ - TQT_DBusConnection::systemBus().send(reply); - return true; -} - -TQString NMSettings::objectPath() const -{ - return TQString(NM_DBUS_PATH_SETTINGS); -} - -bool NMSettings::ListConnections(TQValueList& connections, TQT_DBusError& /*error*/) -{ - // return connections - ConnectionStore* cstore = ConnectionStore::getInstance(); - TQValueList conns = cstore->getConnections(); - - for (TQValueList::Iterator it = conns.begin(); it != conns.end(); ++it) - { - ConnectionSettings::Connection* conn = (*it); - connections.append(conn->getObjectPath()); - } - - return true; -} - -void NMSettings::handleMethodReply(const TQT_DBusMessage& reply) -{ - TQT_DBusConnection::systemBus().send(reply); -} - -TQT_DBusObjectPath -NMSettings::getObjPathForConnection() -{ - // just increase the number for this connection - TQT_DBusObjectPath obj_path(NM_DBUS_PATH_SETTINGS_CONNECTION"/"); - obj_path += TQString::number(d->obj_path_index++); - return obj_path; -} - -void -NMSettings::slotNewConnection(ConnectionSettings::Connection* conn) -{ - emitNewConnection(conn->getObjectPath()); -} - - -#include "knetworkmanager-nmsettings.moc" diff --git a/tdenetworkmanager/src/knetworkmanager-nmsettings.h b/tdenetworkmanager/src/knetworkmanager-nmsettings.h deleted file mode 100644 index c9769c1..0000000 --- a/tdenetworkmanager/src/knetworkmanager-nmsettings.h +++ /dev/null @@ -1,77 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-nminfo_dbus.h - A NetworkManager frontend for KDE - * - * Copyright (C) 2005, 2006 Novell, Inc. - * - * Author: Helmut Schaa , - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#ifndef KNETWORKMANAGER_NMSETTINGS_H -#define KNETWORKMANAGER_NMSETTINGS_H - -#include - -#include "knetworkmanager-connection_setting.h" -#include "dbus/networkmanagersettings.h" - -class Network; -class TQT_DBusObjectPath; -class NMSettingsPrivate; - -class NMSettings : public TQObject, DBus::SettingsInterface -{ - Q_OBJECT - - public: - /* get singleton */ - static NMSettings* getInstance(); - - ~NMSettings(); - /* request the required interface from the DBus */ -// void requestName (DBusMessage*); - - /* functions for handling method calls sended _by_ NetworkManager */ -// void getConnections (DBusMessage*); - bool handleSignalSend(const TQT_DBusMessage& reply); - TQString objectPath() const; - bool ListConnections(TQValueList& connections, TQT_DBusError& error); - void handleMethodReply(const TQT_DBusMessage& reply); - - /* get Connection from obj_path */ - TQT_DBusObjectPath getObjPathForConnection(); - - public slots: - /* notification about new connections */ - void slotNewConnection (ConnectionSettings::Connection*); - - private: - NMSettingsPrivate* d; - - /* private constructor -> singleton */ - NMSettings(); - - /* functions for sending signals/methodcalls _to_ NetworkManager */ - void signalNewConnection (const char*); - - /* pointer to the singleton class */ - static NMSettings* _instance; - -}; - -#endif /* KNETWORKMANAGER_NMSETTINGS_H */ diff --git a/tdenetworkmanager/src/knetworkmanager-wireless_manager.cpp b/tdenetworkmanager/src/knetworkmanager-wireless_manager.cpp index 3238c0a..2137939 100644 --- a/tdenetworkmanager/src/knetworkmanager-wireless_manager.cpp +++ b/tdenetworkmanager/src/knetworkmanager-wireless_manager.cpp @@ -41,24 +41,20 @@ #include "knetworkmanager-nm_proxy.h" #include "knetworkmanager-devicestore.h" -#if !defined(NM_CHECK_VERSION) -#define NM_CHECK_VERSION(x,y,z) 0 -#endif - TQValueList WirelessManager::getWirelessNetworks(TDENetworkDevice* dev, TQ_UINT32 match) { TQValueList nets; - TQValueList aps; + TQValueList aps; // fetch all APs aps = WirelessManager::getAccessPoints(dev); // now group the APs together according to their security settings - for (TQValueList::Iterator apit = aps.begin(); apit != aps.end(); ++apit) + for (TQValueList::Iterator apit = aps.begin(); apit != aps.end(); ++apit) { bool found = false; // no hidden APs - AccessPoint * ap = *apit; + TDENetworkWiFiAPInfo * ap = *apit; if ( ap ) { if (!ap->isValid()) continue; @@ -100,22 +96,18 @@ TQValueList WirelessManager::getWirelessNetworks(TDENetworkDevi return nets; } -TQValueList WirelessManager::getAccessPoints(TDENetworkDevice* dev) +TQValueList WirelessManager::getAccessPoints(TDENetworkDevice* dev) { // build up AP list depending on one device or on all devices if (dev) { return dev->accessPoints(); } else { - TQValueList aps; + TQValueList aps; DeviceStore* store = DeviceStore::getInstance(); if (store) { -#if NM_CHECK_VERSION(0,8,992) TQValueList devs = store->getDevices(NM_DEVICE_TYPE_WIFI); -#else - TQValueList devs = store->getDevices(DEVICE_TYPE_802_11_WIRELESS); -#endif for (TQValueList::Iterator it = devs.begin(); it != devs.end(); ++it) { TDENetworkDevice* wdev = dynamic_cast(*it); @@ -147,22 +139,18 @@ TQValueList WirelessManager::getWirelessConnections() return conns; } -TQValueList WirelessManager::getAccessPointsForEssid(TQByteArray essid, TDENetworkDevice* dev) +TQValueList WirelessManager::getAccessPointsForEssid(TQByteArray essid, TDENetworkDevice* dev) { // build up AP list depending on one device or on all devices if (dev) return dev->accessPointsForEssid(essid); else { - TQValueList aps; + TQValueList aps; DeviceStore* store = DeviceStore::getInstance(); if (store) { -#if NM_CHECK_VERSION(0,8,992) TQValueList devs = store->getDevices(NM_DEVICE_TYPE_WIFI); -#else - TQValueList devs = store->getDevices(DEVICE_TYPE_802_11_WIRELESS); -#endif for (TQValueList::Iterator it = devs.begin(); it != devs.end(); ++it) { TDENetworkDevice* wdev = dynamic_cast(*it); diff --git a/tdenetworkmanager/src/knetworkmanager-wireless_manager.h b/tdenetworkmanager/src/knetworkmanager-wireless_manager.h index ac49a37..75d9f4a 100644 --- a/tdenetworkmanager/src/knetworkmanager-wireless_manager.h +++ b/tdenetworkmanager/src/knetworkmanager-wireless_manager.h @@ -47,13 +47,13 @@ class WirelessManager static TQValueList getWirelessNetworks(TDENetworkDevice* dev = 0, TQ_UINT32 match = WirelessNetwork::MATCH_SSID); // get all aps from either one device or from all available devices - static TQValueList getAccessPoints(TDENetworkDevice* dev = 0); + static TQValueList getAccessPoints(TDENetworkDevice* dev = 0); // get a list of all known wireless connections static TQValueList getWirelessConnections(); // get a list of all APs with a specific SSID - static TQValueList getAccessPointsForEssid(TQByteArray, TDENetworkDevice* dev = 0); + static TQValueList getAccessPointsForEssid(TQByteArray, TDENetworkDevice* dev = 0); }; diff --git a/tdenetworkmanager/src/knetworkmanager-wireless_network.cpp b/tdenetworkmanager/src/knetworkmanager-wireless_network.cpp index 66eded2..3b96bb2 100644 --- a/tdenetworkmanager/src/knetworkmanager-wireless_network.cpp +++ b/tdenetworkmanager/src/knetworkmanager-wireless_network.cpp @@ -22,24 +22,17 @@ * **************************************************************************/ -// NM includes -#include - // KNM includes #include "knetworkmanager.h" -#include "knetworkmanager-connection.h" -#include "knetworkmanager-accesspoint.h" #include "knetworkmanager-wireless_network.h" -// KDE includes +// TDE includes #include // TQt includes #include #include -using namespace ConnectionSettings; - class WirelessNetworkPrivate { public: @@ -55,7 +48,7 @@ class WirelessNetworkPrivate bool active; TQ_UINT32 match; - TQValueList aps; + TQValueList aps; }; WirelessNetwork::WirelessNetwork(const WirelessNetwork& other) @@ -84,7 +77,7 @@ WirelessNetwork& WirelessNetwork::operator= (const WirelessNetwork& other) return *this; } -bool WirelessNetwork::contains (const AccessPoint * const ap) +bool WirelessNetwork::contains (const TDENetworkWiFiAPInfo * const ap) { if ( (d->match & MATCH_SSID) && getSsid() != ap->getSsidByteArray()) return false; @@ -93,7 +86,7 @@ bool WirelessNetwork::contains (const AccessPoint * const ap) return true; } -bool WirelessNetwork::addAP(const AccessPoint * const ap) +bool WirelessNetwork::addAP(const TDENetworkWiFiAPInfo * const ap) { if ( this->contains( ap ) || d->aps.isEmpty()) { @@ -124,7 +117,7 @@ TQString WirelessNetwork::getDisplaySsid() const TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags WirelessNetwork::getFlags() const { TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags flags = TDENetworkWiFiAPFlags::None; - for (TQValueList::Iterator it = d->aps.begin(); it != d->aps.end(); ++it) + for (TQValueList::Iterator it = d->aps.begin(); it != d->aps.end(); ++it) { flags |= (*it)->getFlags(); } @@ -134,7 +127,7 @@ TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags WirelessNetwork::getFlags() const TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags WirelessNetwork::getWpaFlags() const { TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags flags = TDENetworkWiFiAPFlags::None; - for (TQValueList::Iterator it = d->aps.begin(); it != d->aps.end(); ++it) + for (TQValueList::Iterator it = d->aps.begin(); it != d->aps.end(); ++it) { flags |= (*it)->getWpaFlags(); } @@ -144,7 +137,7 @@ TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags WirelessNetwork::getWpaFlags() cons TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags WirelessNetwork::getRsnFlags() const { TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags flags = TDENetworkWiFiAPFlags::None; - for (TQValueList::Iterator it = d->aps.begin(); it != d->aps.end(); ++it) + for (TQValueList::Iterator it = d->aps.begin(); it != d->aps.end(); ++it) { flags |= (*it)->getRsnFlags(); } @@ -159,7 +152,7 @@ bool WirelessNetwork::isEncrypted() const TQ_UINT8 WirelessNetwork::getStrength() const { TQ_UINT8 strength = 0; - for (TQValueList::Iterator it = d->aps.begin(); it != d->aps.end(); ++it) + for (TQValueList::Iterator it = d->aps.begin(); it != d->aps.end(); ++it) { if ((*it)->getStrength() > strength) strength = (*it)->getStrength(); diff --git a/tdenetworkmanager/src/knetworkmanager-wireless_network.h b/tdenetworkmanager/src/knetworkmanager-wireless_network.h index ff3c09b..979eddc 100644 --- a/tdenetworkmanager/src/knetworkmanager-wireless_network.h +++ b/tdenetworkmanager/src/knetworkmanager-wireless_network.h @@ -29,8 +29,10 @@ #include +#include +#include + class KNetworkManager; -class AccessPoint; class WirelessNetworkPrivate; /* @@ -55,10 +57,10 @@ class WirelessNetwork WirelessNetwork& operator= (const WirelessNetwork&); // check if the AccessPoint represents the same net - bool contains(const AccessPoint * const); + bool contains(const TDENetworkWiFiAPInfo * const); // add an AP to the Network - bool addAP(const AccessPoint * const); + bool addAP(const TDENetworkWiFiAPInfo * const); // combined flags of all APs TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags getFlags() const; diff --git a/tdenetworkmanager/src/xmlmarshaller.cpp b/tdenetworkmanager/src/xmlmarshaller.cpp deleted file mode 100644 index a826e39..0000000 --- a/tdenetworkmanager/src/xmlmarshaller.cpp +++ /dev/null @@ -1,1109 +0,0 @@ -/*************************************************************************** - * - * Copyright (C) 2008 by Kevin Krammer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#include "xmlmarshaller.h" - -#include -#include -#include -#include -#include - -#include -#include - -#include - -static TQDomElement fromBool(bool value, const TQDomDocument& ownerDoc) -{ - TQDomDocument doc = ownerDoc; - TQDomElement element = doc.createElement("bool"); - TQDomText text = doc.createTextNode((value ? "true" : "false")); - - element.appendChild(text); - - return element; -} - -static TQDomElement fromByte(TQ_UINT8 value, const TQDomDocument& ownerDoc) -{ - TQDomDocument doc = ownerDoc; - TQDomElement element = doc.createElement("byte"); - TQDomText text = doc.createTextNode(TQString::number(value)); - - element.appendChild(text); - - return element; -} - -static TQDomElement fromInt16(TQ_INT16 value, const TQDomDocument& ownerDoc) -{ - TQDomDocument doc = ownerDoc; - TQDomElement element = doc.createElement("int16"); - TQDomText text = doc.createTextNode(TQString::number(value)); - - element.appendChild(text); - - return element; -} - -static TQDomElement fromUInt16(TQ_UINT16 value, const TQDomDocument& ownerDoc) -{ - TQDomDocument doc = ownerDoc; - TQDomElement element = doc.createElement("uin16"); - TQDomText text = doc.createTextNode(TQString::number(value)); - - element.appendChild(text); - - return element; -} - -static TQDomElement fromInt32(TQ_INT32 value, const TQDomDocument& ownerDoc) -{ - TQDomDocument doc = ownerDoc; - TQDomElement element = doc.createElement("int32"); - TQDomText text = doc.createTextNode(TQString::number(value)); - - element.appendChild(text); - - return element; -} - -static TQDomElement fromUInt32(TQ_UINT32 value, const TQDomDocument& ownerDoc) -{ - TQDomDocument doc = ownerDoc; - TQDomElement element = doc.createElement("uint32"); - TQDomText text = doc.createTextNode(TQString::number(value)); - - element.appendChild(text); - - return element; -} - -static TQDomElement fromInt64(TQ_INT64 value, const TQDomDocument& ownerDoc) -{ - TQDomDocument doc = ownerDoc; - TQDomElement element = doc.createElement("int64"); - TQDomText text = doc.createTextNode(TQString::number(value)); - - element.appendChild(text); - - return element; -} - -static TQDomElement fromUInt64(TQ_UINT64 value, const TQDomDocument& ownerDoc) -{ - TQDomDocument doc = ownerDoc; - TQDomElement element = doc.createElement("uint64"); - TQDomText text = doc.createTextNode(TQString::number(value)); - - element.appendChild(text); - - return element; -} - -static TQDomElement fromDouble(double value, const TQDomDocument& ownerDoc) -{ - TQDomDocument doc = ownerDoc; - TQDomElement element = doc.createElement("double"); - TQDomText text = doc.createTextNode(TQString::number(value)); - - element.appendChild(text); - - return element; -} - -static TQDomElement fromString(const TQString& value, const TQDomDocument& ownerDoc) -{ - TQDomDocument doc = ownerDoc; - TQDomElement element = doc.createElement("string"); - TQDomText text = doc.createTextNode(value); // TODO: espace - - element.appendChild(text); - - return element; -} - -static TQDomElement fromObjectPath(const TQT_DBusObjectPath& value, const TQDomDocument& ownerDoc) -{ - TQDomDocument doc = ownerDoc; - TQDomElement element = doc.createElement("objectpath"); - TQDomText text = doc.createTextNode(value); - - element.appendChild(text); - - return element; -} - -static TQDomElement fromByteKeyMap(const TQT_DBusDataMap& map, const TQDomDocument& ownerDoc) -{ - TQDomDocument doc = ownerDoc; - TQDomElement element = doc.createElement("map"); - - if (map.isEmpty()) return element; - - TQT_DBusDataMap::const_iterator it = map.begin(); - TQT_DBusDataMap::const_iterator endIt = map.end(); - for (; it != endIt; ++it) - { - TQDomElement entryElement = doc.createElement("entry"); - - entryElement.appendChild(fromByte(it.key(), ownerDoc)); - entryElement.appendChild(XMLMarshaller::fromTQT_DBusData(it.data(), ownerDoc)); - - element.appendChild(entryElement); - } - - return element; -} - -static TQDomElement fromInt16KeyMap(const TQT_DBusDataMap& map, const TQDomDocument& ownerDoc) -{ - TQDomDocument doc = ownerDoc; - TQDomElement element = doc.createElement("map"); - - if (map.isEmpty()) return element; - - TQT_DBusDataMap::const_iterator it = map.begin(); - TQT_DBusDataMap::const_iterator endIt = map.end(); - for (; it != endIt; ++it) - { - TQDomElement entryElement = doc.createElement("entry"); - - entryElement.appendChild(fromInt16(it.key(), ownerDoc)); - entryElement.appendChild(XMLMarshaller::fromTQT_DBusData(it.data(), ownerDoc)); - - element.appendChild(entryElement); - } - - return element; -} - -static TQDomElement fromUInt16KeyMap(const TQT_DBusDataMap& map, const TQDomDocument& ownerDoc) -{ - TQDomDocument doc = ownerDoc; - TQDomElement element = doc.createElement("map"); - - if (map.isEmpty()) return element; - - TQT_DBusDataMap::const_iterator it = map.begin(); - TQT_DBusDataMap::const_iterator endIt = map.end(); - for (; it != endIt; ++it) - { - TQDomElement entryElement = doc.createElement("entry"); - - entryElement.appendChild(fromUInt16(it.key(), ownerDoc)); - entryElement.appendChild(XMLMarshaller::fromTQT_DBusData(it.data(), ownerDoc)); - - element.appendChild(entryElement); - } - - return element; -} - -static TQDomElement fromInt32KeyMap(const TQT_DBusDataMap& map, const TQDomDocument& ownerDoc) -{ - TQDomDocument doc = ownerDoc; - TQDomElement element = doc.createElement("map"); - - if (map.isEmpty()) return element; - - TQT_DBusDataMap::const_iterator it = map.begin(); - TQT_DBusDataMap::const_iterator endIt = map.end(); - for (; it != endIt; ++it) - { - TQDomElement entryElement = doc.createElement("entry"); - - entryElement.appendChild(fromInt32(it.key(), ownerDoc)); - entryElement.appendChild(XMLMarshaller::fromTQT_DBusData(it.data(), ownerDoc)); - - element.appendChild(entryElement); - } - - return element; -} - -static TQDomElement fromUInt32KeyMap(const TQT_DBusDataMap& map, const TQDomDocument& ownerDoc) -{ - TQDomDocument doc = ownerDoc; - TQDomElement element = doc.createElement("map"); - - if (map.isEmpty()) return element; - - TQT_DBusDataMap::const_iterator it = map.begin(); - TQT_DBusDataMap::const_iterator endIt = map.end(); - for (; it != endIt; ++it) - { - TQDomElement entryElement = doc.createElement("entry"); - - entryElement.appendChild(fromUInt32(it.key(), ownerDoc)); - entryElement.appendChild(XMLMarshaller::fromTQT_DBusData(it.data(), ownerDoc)); - - element.appendChild(entryElement); - } - - return element; -} - -static TQDomElement fromInt64KeyMap(const TQT_DBusDataMap& map, const TQDomDocument& ownerDoc) -{ - TQDomDocument doc = ownerDoc; - TQDomElement element = doc.createElement("map"); - - if (map.isEmpty()) return element; - - TQT_DBusDataMap::const_iterator it = map.begin(); - TQT_DBusDataMap::const_iterator endIt = map.end(); - for (; it != endIt; ++it) - { - TQDomElement entryElement = doc.createElement("entry"); - - entryElement.appendChild(fromInt16(it.key(), ownerDoc)); - entryElement.appendChild(XMLMarshaller::fromTQT_DBusData(it.data(), ownerDoc)); - - element.appendChild(entryElement); - } - - return element; -} - -static TQDomElement fromUInt64KeyMap(const TQT_DBusDataMap& map, const TQDomDocument& ownerDoc) -{ - TQDomDocument doc = ownerDoc; - TQDomElement element = doc.createElement("map"); - - if (map.isEmpty()) return element; - - TQT_DBusDataMap::const_iterator it = map.begin(); - TQT_DBusDataMap::const_iterator endIt = map.end(); - for (; it != endIt; ++it) - { - TQDomElement entryElement = doc.createElement("entry"); - - entryElement.appendChild(fromUInt64(it.key(), ownerDoc)); - entryElement.appendChild(XMLMarshaller::fromTQT_DBusData(it.data(), ownerDoc)); - - element.appendChild(entryElement); - } - - return element; -} - -static TQDomElement fromStringKeyMap(const TQT_DBusDataMap& map, const TQDomDocument& ownerDoc) -{ - TQDomDocument doc = ownerDoc; - TQDomElement element = doc.createElement("map"); - - if (map.isEmpty()) return element; - - TQT_DBusDataMap::const_iterator it = map.begin(); - TQT_DBusDataMap::const_iterator endIt = map.end(); - for (; it != endIt; ++it) - { - TQDomElement entryElement = doc.createElement("entry"); - - entryElement.appendChild(fromString(it.key(), ownerDoc)); - entryElement.appendChild(XMLMarshaller::fromTQT_DBusData(it.data(), ownerDoc)); - - element.appendChild(entryElement); - } - - return element; -} - -static TQDomElement fromObjectPathKeyMap(const TQT_DBusDataMap& map, const TQDomDocument& ownerDoc) -{ - TQDomDocument doc = ownerDoc; - TQDomElement element = doc.createElement("map"); - - if (map.isEmpty()) return element; - - TQT_DBusDataMap::const_iterator it = map.begin(); - TQT_DBusDataMap::const_iterator endIt = map.end(); - for (; it != endIt; ++it) - { - TQDomElement entryElement = doc.createElement("entry"); - - entryElement.appendChild(fromObjectPath(it.key(), ownerDoc)); - entryElement.appendChild(XMLMarshaller::fromTQT_DBusData(it.data(), ownerDoc)); - - element.appendChild(entryElement); - } - - return element; -} - -static bool toBool(const TQDomElement& element) -{ - return element.text() == "true"; -} - -static TQ_UINT8 toByte(const TQDomElement& element) -{ - uint number = element.text().toUInt(); - if (number > 255) return 0; - return number; -} - -static TQ_INT16 toInt16(const TQDomElement& element) -{ - return element.text().toShort(); -} - -static TQ_UINT16 toUInt16(const TQDomElement& element) -{ - return element.text().toUShort(); -} - -static TQ_INT32 toInt32(const TQDomElement& element) -{ - return element.text().toInt(); -} - -static TQ_UINT32 toUInt32(const TQDomElement& element) -{ - return element.text().toUInt(); -} - -static TQ_INT64 toInt64(const TQDomElement& element) -{ - return element.text().toLongLong(); -} - -static TQ_UINT64 toUInt64(const TQDomElement& element) -{ - return element.text().toULongLong(); -} - -static double toDouble(const TQDomElement& element) -{ - return element.text().toDouble(); -} - -static TQString toString(const TQDomElement& element) -{ - return element.text(); -} - -static TQT_DBusObjectPath toObjectPath(const TQDomElement& element) -{ - return TQCString(element.text().ascii()); -} - -static TQT_DBusData::Type typeFromEntry(const TQDomElement& element) -{ - for (TQDomNode child = element.firstChild(); !child.isNull(); child = child.nextSibling()) - { - if (!child.isElement()) continue; - - TQDomElement childElement = child.toElement(); - - if (childElement.tagName() == "byte") return TQT_DBusData::Byte; - if (childElement.tagName() == "int16") return TQT_DBusData::Int16; - if (childElement.tagName() == "uint16") return TQT_DBusData::UInt16; - if (childElement.tagName() == "int32") return TQT_DBusData::Int32; - if (childElement.tagName() == "uint32") return TQT_DBusData::UInt32; - if (childElement.tagName() == "int64") return TQT_DBusData::Int64; - if (childElement.tagName() == "uint64") return TQT_DBusData::UInt64; - if (childElement.tagName() == "string") return TQT_DBusData::String; - if (childElement.tagName() == "objectpath") return TQT_DBusData::ObjectPath; - } - - return TQT_DBusData::Invalid; -} - -static TQT_DBusData toByteKeyMap(const TQDomElement& element) -{ - TQT_DBusDataMap map; - - for (TQDomNode child = element.firstChild(); !child.isNull(); child = child.nextSibling()) - { - if (!child.isElement()) continue; - - TQDomElement entryElement = child.toElement(); - if (entryElement.tagName() != "entry") continue; - - for (TQDomNode entryChild = entryElement.firstChild(); !entryChild.isNull(); - entryChild = entryChild.nextSibling()) - { - if (!entryChild.isElement()) continue; - - TQDomElement childElement = entryChild.toElement(); - if (childElement.tagName() != "byte") continue; - - TQ_UINT8 key = toByte(childElement); - - TQT_DBusData data; - for (entryChild = entryChild.nextSibling(); !entryChild.isNull(); - entryChild = entryChild.nextSibling()) - { - if (!entryChild.isElement()) continue; - - data = XMLMarshaller::toTQT_DBusData(entryChild.toElement()); - if (data.isValid()) break; - } - - if (!data.isValid()) return TQT_DBusData(); - - map.insert(key, data); - break; - } - } - - return TQT_DBusData::fromByteKeyMap(map); -} - -static TQT_DBusData toInt16KeyMap(const TQDomElement& element) -{ - TQT_DBusDataMap map; - - for (TQDomNode child = element.firstChild(); !child.isNull(); child = child.nextSibling()) - { - if (!child.isElement()) continue; - - TQDomElement entryElement = child.toElement(); - if (entryElement.tagName() != "entry") continue; - - for (TQDomNode entryChild = entryElement.firstChild(); !entryChild.isNull(); - entryChild = entryChild.nextSibling()) - { - if (!entryChild.isElement()) continue; - - TQDomElement childElement = entryChild.toElement(); - if (childElement.tagName() != "int16") continue; - - TQ_INT16 key = toInt16(childElement); - - TQT_DBusData data; - for (entryChild = entryChild.nextSibling(); !entryChild.isNull(); - entryChild = entryChild.nextSibling()) - { - if (!entryChild.isElement()) continue; - - data = XMLMarshaller::toTQT_DBusData(entryChild.toElement()); - if (data.isValid()) break; - } - - if (!data.isValid()) return TQT_DBusData(); - - map.insert(key, data); - break; - } - } - - return TQT_DBusData::fromInt16KeyMap(map); -} - -static TQT_DBusData toUInt16KeyMap(const TQDomElement& element) -{ - TQT_DBusDataMap map; - - for (TQDomNode child = element.firstChild(); !child.isNull(); child = child.nextSibling()) - { - if (!child.isElement()) continue; - - TQDomElement entryElement = child.toElement(); - if (entryElement.tagName() != "entry") continue; - - for (TQDomNode entryChild = entryElement.firstChild(); !entryChild.isNull(); - entryChild = entryChild.nextSibling()) - { - if (!entryChild.isElement()) continue; - - TQDomElement childElement = entryChild.toElement(); - if (childElement.tagName() != "uint16") continue; - - TQ_UINT16 key = toUInt16(childElement); - - TQT_DBusData data; - for (entryChild = entryChild.nextSibling(); !entryChild.isNull(); - entryChild = entryChild.nextSibling()) - { - if (!entryChild.isElement()) continue; - - data = XMLMarshaller::toTQT_DBusData(entryChild.toElement()); - if (data.isValid()) break; - } - - if (!data.isValid()) return TQT_DBusData(); - - map.insert(key, data); - break; - } - } - - return TQT_DBusData::fromUInt16KeyMap(map); -} - -static TQT_DBusData toInt32KeyMap(const TQDomElement& element) -{ - TQT_DBusDataMap map; - - for (TQDomNode child = element.firstChild(); !child.isNull(); child = child.nextSibling()) - { - if (!child.isElement()) continue; - - TQDomElement entryElement = child.toElement(); - if (entryElement.tagName() != "entry") continue; - - for (TQDomNode entryChild = entryElement.firstChild(); !entryChild.isNull(); - entryChild = entryChild.nextSibling()) - { - if (!entryChild.isElement()) continue; - - TQDomElement childElement = entryChild.toElement(); - if (childElement.tagName() != "int32") continue; - - TQ_INT32 key = toInt32(childElement); - - TQT_DBusData data; - for (entryChild = entryChild.nextSibling(); !entryChild.isNull(); - entryChild = entryChild.nextSibling()) - { - if (!entryChild.isElement()) continue; - - data = XMLMarshaller::toTQT_DBusData(entryChild.toElement()); - if (data.isValid()) break; - } - - if (!data.isValid()) return TQT_DBusData(); - - map.insert(key, data); - break; - } - } - - return TQT_DBusData::fromInt32KeyMap(map); -} - -static TQT_DBusData toUInt32KeyMap(const TQDomElement& element) -{ - TQT_DBusDataMap map; - - for (TQDomNode child = element.firstChild(); !child.isNull(); child = child.nextSibling()) - { - if (!child.isElement()) continue; - - TQDomElement entryElement = child.toElement(); - if (entryElement.tagName() != "entry") continue; - - for (TQDomNode entryChild = entryElement.firstChild(); !entryChild.isNull(); - entryChild = entryChild.nextSibling()) - { - if (!entryChild.isElement()) continue; - - TQDomElement childElement = entryChild.toElement(); - if (childElement.tagName() != "uint32") continue; - - TQ_UINT32 key = toUInt32(childElement); - - TQT_DBusData data; - for (entryChild = entryChild.nextSibling(); !entryChild.isNull(); - entryChild = entryChild.nextSibling()) - { - if (!entryChild.isElement()) continue; - - data = XMLMarshaller::toTQT_DBusData(entryChild.toElement()); - if (data.isValid()) break; - } - - if (!data.isValid()) return TQT_DBusData(); - - map.insert(key, data); - break; - } - } - - return TQT_DBusData::fromUInt32KeyMap(map); -} - -static TQT_DBusData toInt64KeyMap(const TQDomElement& element) -{ - TQT_DBusDataMap map; - - for (TQDomNode child = element.firstChild(); !child.isNull(); child = child.nextSibling()) - { - if (!child.isElement()) continue; - - TQDomElement entryElement = child.toElement(); - if (entryElement.tagName() != "entry") continue; - - for (TQDomNode entryChild = entryElement.firstChild(); !entryChild.isNull(); - entryChild = entryChild.nextSibling()) - { - if (!entryChild.isElement()) continue; - - TQDomElement childElement = entryChild.toElement(); - if (childElement.tagName() != "int64") continue; - - TQ_INT64 key = toInt64(childElement); - - TQT_DBusData data; - for (entryChild = entryChild.nextSibling(); !entryChild.isNull(); - entryChild = entryChild.nextSibling()) - { - if (!entryChild.isElement()) continue; - - data = XMLMarshaller::toTQT_DBusData(entryChild.toElement()); - if (data.isValid()) break; - } - - if (!data.isValid()) return TQT_DBusData(); - - map.insert(key, data); - break; - } - } - - return TQT_DBusData::fromInt64KeyMap(map); -} - -static TQT_DBusData toUInt64KeyMap(const TQDomElement& element) -{ - TQT_DBusDataMap map; - - for (TQDomNode child = element.firstChild(); !child.isNull(); child = child.nextSibling()) - { - if (!child.isElement()) continue; - - TQDomElement entryElement = child.toElement(); - if (entryElement.tagName() != "entry") continue; - - for (TQDomNode entryChild = entryElement.firstChild(); !entryChild.isNull(); - entryChild = entryChild.nextSibling()) - { - if (!entryChild.isElement()) continue; - - TQDomElement childElement = entryChild.toElement(); - if (childElement.tagName() != "uint64") continue; - - TQ_UINT64 key = toUInt64(childElement); - - TQT_DBusData data; - for (entryChild = entryChild.nextSibling(); !entryChild.isNull(); - entryChild = entryChild.nextSibling()) - { - if (!entryChild.isElement()) continue; - - data = XMLMarshaller::toTQT_DBusData(entryChild.toElement()); - if (data.isValid()) break; - } - - if (!data.isValid()) return TQT_DBusData(); - - map.insert(key, data); - break; - } - } - - return TQT_DBusData::fromUInt64KeyMap(map); -} - -static TQT_DBusData toStringKeyMap(const TQDomElement& element) -{ - TQT_DBusDataMap map; - - for (TQDomNode child = element.firstChild(); !child.isNull(); child = child.nextSibling()) - { - if (!child.isElement()) continue; - - TQDomElement entryElement = child.toElement(); - if (entryElement.tagName() != "entry") continue; - - for (TQDomNode entryChild = entryElement.firstChild(); !entryChild.isNull(); - entryChild = entryChild.nextSibling()) - { - if (!entryChild.isElement()) continue; - - TQDomElement childElement = entryChild.toElement(); - if (childElement.tagName() != "string") continue; - - TQString key = toString(childElement); - - TQT_DBusData data; - for (entryChild = entryChild.nextSibling(); !entryChild.isNull(); - entryChild = entryChild.nextSibling()) - { - if (!entryChild.isElement()) continue; - - data = XMLMarshaller::toTQT_DBusData(entryChild.toElement()); - if (data.isValid()) break; - } - - if (!data.isValid()) return TQT_DBusData(); - - map.insert(key, data); - break; - } - } - - return TQT_DBusData::fromStringKeyMap(map); -} - -static TQT_DBusData toObjectPathKeyMap(const TQDomElement& element) -{ - TQT_DBusDataMap map; - - for (TQDomNode child = element.firstChild(); !child.isNull(); child = child.nextSibling()) - { - if (!child.isElement()) continue; - - TQDomElement entryElement = child.toElement(); - if (entryElement.tagName() != "entry") continue; - - for (TQDomNode entryChild = entryElement.firstChild(); !entryChild.isNull(); - entryChild = entryChild.nextSibling()) - { - if (!entryChild.isElement()) continue; - - TQDomElement childElement = entryChild.toElement(); - if (childElement.tagName() != "objectpath") continue; - - TQT_DBusObjectPath key = toObjectPath(childElement); - - TQT_DBusData data; - for (entryChild = entryChild.nextSibling(); !entryChild.isNull(); - entryChild = entryChild.nextSibling()) - { - if (!entryChild.isElement()) continue; - - data = XMLMarshaller::toTQT_DBusData(entryChild.toElement()); - if (data.isValid()) break; - } - - if (!data.isValid()) return TQT_DBusData(); - - map.insert(key, data); - break; - } - } - - return TQT_DBusData::fromObjectPathKeyMap(map); -} - -TQDomElement XMLMarshaller::fromTQT_DBusData(const TQT_DBusData& data, const TQDomDocument& ownerDoc) -{ - switch (data.type()) - { - case TQT_DBusData::Invalid: - kdWarning() << "XMLMarsaller::fromTQT_DBusData: data is invalid" << endl; - return TQDomElement(); - - case TQT_DBusData::Bool: - return fromBool(data.toBool(), ownerDoc); - - case TQT_DBusData::Byte: - return fromByte(data.toByte(), ownerDoc); - - case TQT_DBusData::Int16: - return fromInt16(data.toInt16(), ownerDoc); - - case TQT_DBusData::UInt16: - return fromUInt16(data.toUInt16(), ownerDoc); - - case TQT_DBusData::Int32: - return fromInt32(data.toInt32(), ownerDoc); - - case TQT_DBusData::UInt32: - return fromUInt32(data.toUInt32(), ownerDoc); - - case TQT_DBusData::Int64: - return fromInt64(data.toInt64(), ownerDoc); - - case TQT_DBusData::UInt64: - return fromUInt64(data.toUInt64(), ownerDoc); - - case TQT_DBusData::Double: - return fromDouble(data.toDouble(), ownerDoc); - - case TQT_DBusData::String: - return fromString(data.toString(), ownerDoc); - - case TQT_DBusData::ObjectPath: - return fromObjectPath(data.toObjectPath(), ownerDoc); - - case TQT_DBusData::List: - { - TQDomDocument doc = ownerDoc; - TQDomElement element = doc.createElement("list"); - TQT_DBusDataList list = data.toList(); - if (list.isEmpty()) - { - element.setAttribute("signature", data.buildDBusSignature().data()); - } - else - { - TQValueList items = list.toTQValueList(); - TQValueList::const_iterator it = items.begin(); - TQValueList::const_iterator endIt = items.end(); - for (; it != endIt; ++it) - { - TQDomElement itemElement = fromTQT_DBusData(*it, ownerDoc); - - if (!itemElement.isNull()) element.appendChild(itemElement); - } - } - - return element; - } - - case TQT_DBusData::Struct: - { - TQDomDocument doc = ownerDoc; - TQDomElement element = doc.createElement("struct"); - - TQValueList members = data.toStruct(); - TQValueList::const_iterator it = members.begin(); - TQValueList::const_iterator endIt = members.end(); - for (; it != endIt; ++it) - { - TQDomElement memberElement = fromTQT_DBusData(*it, ownerDoc); - - if (!memberElement.isNull()) element.appendChild(memberElement); - } - return element; - } - - case TQT_DBusData::Variant: - { - TQDomDocument doc = ownerDoc; - TQDomElement element = doc.createElement("variant"); - - TQT_DBusVariant variant = data.toVariant(); - - element.setAttribute("signature", variant.signature); - - TQDomElement dataElement = fromTQT_DBusData(variant.value, ownerDoc); - if (!dataElement.isNull()) element.appendChild(dataElement); - - return element; - } - - case TQT_DBusData::Map: - { - TQDomElement mapElement; - - switch (data.keyType()) - { - case TQT_DBusData::Byte: - mapElement = fromByteKeyMap(data.toByteKeyMap(), ownerDoc); - break; - - case TQT_DBusData::Int16: - mapElement = fromInt16KeyMap(data.toInt16KeyMap(), ownerDoc); - break; - - case TQT_DBusData::UInt16: - mapElement = fromUInt16KeyMap(data.toUInt16KeyMap(), ownerDoc); - break; - - case TQT_DBusData::Int32: - mapElement = fromInt32KeyMap(data.toInt32KeyMap(), ownerDoc); - break; - - case TQT_DBusData::UInt32: - mapElement = fromUInt32KeyMap(data.toUInt32KeyMap(), ownerDoc); - break; - - case TQT_DBusData::Int64: - mapElement = fromInt64KeyMap(data.toInt64KeyMap(), ownerDoc); - break; - - case TQT_DBusData::UInt64: - mapElement = fromUInt64KeyMap(data.toUInt64KeyMap(), ownerDoc); - break; - - case TQT_DBusData::String: - mapElement = fromStringKeyMap(data.toStringKeyMap(), ownerDoc); - break; - - case TQT_DBusData::ObjectPath: - mapElement = fromObjectPathKeyMap(data.toObjectPathKeyMap(), ownerDoc); - break; - - default: - return TQDomElement(); - } - - if (!mapElement.hasChildNodes()) - { - mapElement.setAttribute("signature", data.buildDBusSignature().data()); - } - - return mapElement; - } - } - - return TQDomElement(); -} - -TQT_DBusData XMLMarshaller::toTQT_DBusData(const TQDomElement& element) -{ - if (element.isNull()) return TQT_DBusData(); - - if (element.tagName() == "bool") return TQT_DBusData::fromBool(toBool(element)); - if (element.tagName() == "byte") return TQT_DBusData::fromByte(toByte(element)); - if (element.tagName() == "int16") return TQT_DBusData::fromInt16(toInt16(element)); - if (element.tagName() == "uint16") return TQT_DBusData::fromUInt16(toUInt16(element)); - if (element.tagName() == "int32") return TQT_DBusData::fromInt32(toInt32(element)); - if (element.tagName() == "uint32") return TQT_DBusData::fromUInt32(toUInt32(element)); - if (element.tagName() == "int64") return TQT_DBusData::fromInt64(toInt64(element)); - if (element.tagName() == "uint64") return TQT_DBusData::fromUInt64(toUInt64(element)); - if (element.tagName() == "double") return TQT_DBusData::fromDouble(toDouble(element)); - if (element.tagName() == "string") return TQT_DBusData::fromString(toString(element)); - if (element.tagName() == "objectpath") return TQT_DBusData::fromObjectPath(toObjectPath(element)); - - if (element.tagName() == "list") - { - if (element.hasChildNodes()) - { - TQValueList list; - - for (TQDomNode child = element.firstChild(); !child.isNull(); child = child.nextSibling()) - { - if (!child.isElement()) continue; - - TQT_DBusData itemData = toTQT_DBusData(child.toElement()); - if (itemData.isValid()) list << itemData; - } - - return TQT_DBusData::fromList(list); - } - - // TODO handle empty list with signatures as hint - } - - if (element.tagName() == "struct") - { - TQValueList members; - - for (TQDomNode child = element.firstChild(); !child.isNull(); child = child.nextSibling()) - { - if (!child.isElement()) continue; - - TQT_DBusData memberData = toTQT_DBusData(child.toElement()); - if (memberData.isValid()) members << memberData; - } - - return TQT_DBusData::fromStruct(members); - } - - if (element.tagName() == "variant") - { - TQT_DBusData data; - for (TQDomNode child = element.firstChild(); !child.isNull(); child = child.nextSibling()) - { - if (!child.isElement()) continue; - - TQT_DBusData childData = toTQT_DBusData(child.toElement()); - if (childData.isValid()) - { - data = childData; - break; - } - } - - if (!data.isValid()) return TQT_DBusData(); - - TQT_DBusVariant variant; - variant.signature = element.attribute("signature"); - variant.value = data; - - return TQT_DBusData::fromVariant(variant); - } - - if (element.tagName() == "map") - { - TQDomElement entryElement; - for (TQDomNode child = element.firstChild(); !child.isNull(); child = child.nextSibling()) - { - if (!child.isElement()) continue; - - TQDomElement childElement = child.toElement(); - if (childElement.tagName() == "entry") - { - entryElement = childElement; - break; - } - } - - if (entryElement.isNull()) - { - // TODO: empty map - return TQT_DBusData(); - } - - switch (typeFromEntry(entryElement)) - { - case TQT_DBusData::Byte: - return toByteKeyMap(element); - - case TQT_DBusData::Int16: - return toInt16KeyMap(element); - - case TQT_DBusData::UInt16: - return toUInt16KeyMap(element); - - case TQT_DBusData::Int32: - return toInt32KeyMap(element); - - case TQT_DBusData::UInt32: - return toUInt32KeyMap(element); - - case TQT_DBusData::Int64: - return toInt64KeyMap(element); - - case TQT_DBusData::UInt64: - return toUInt64KeyMap(element); - - case TQT_DBusData::String: - return toStringKeyMap(element); - - case TQT_DBusData::ObjectPath: - return toObjectPathKeyMap(element); - - default: - return TQT_DBusData(); - } - } - - return TQT_DBusData(); -} - -TQString XMLMarshaller::fromTQT_DBusData(const TQT_DBusData& data) -{ - TQDomDocument doc; - - TQDomElement element = fromTQT_DBusData(data, doc); - if (element.isNull()) return TQString(); - - doc.appendChild(element); - return doc.toString(); -} - -TQT_DBusData XMLMarshaller::toTQT_DBusData(const TQString& xmlString) -{ - TQDomDocument doc; - - if (!doc.setContent(xmlString)) return TQT_DBusData(); - - return toTQT_DBusData(doc.documentElement()); -} - diff --git a/tdenetworkmanager/src/xmlmarshaller.h b/tdenetworkmanager/src/xmlmarshaller.h deleted file mode 100644 index f86ef92..0000000 --- a/tdenetworkmanager/src/xmlmarshaller.h +++ /dev/null @@ -1,42 +0,0 @@ -/*************************************************************************** - * - * Copyright (C) 2008 by Kevin Krammer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#ifndef XMLMARSHALLER_H -#define XMLMARSHALLER_H - -class TQT_DBusData; -class TQDomDocument; -class TQDomElement; -class TQString; - -class XMLMarshaller -{ -public: - static TQDomElement fromTQT_DBusData(const TQT_DBusData& data, const TQDomDocument& ownerDoc); - - static TQT_DBusData toTQT_DBusData(const TQDomElement& element); - - static TQString fromTQT_DBusData(const TQT_DBusData& data); - - static TQT_DBusData toTQT_DBusData(const TQString& xmlString); -}; - -#endif -