diff options
Diffstat (limited to 'knetworkmanager-0.8/src/knetworkmanager-connection_setting_info.cpp')
-rw-r--r-- | knetworkmanager-0.8/src/knetworkmanager-connection_setting_info.cpp | 163 |
1 files changed, 163 insertions, 0 deletions
diff --git a/knetworkmanager-0.8/src/knetworkmanager-connection_setting_info.cpp b/knetworkmanager-0.8/src/knetworkmanager-connection_setting_info.cpp new file mode 100644 index 0000000..225d002 --- /dev/null +++ b/knetworkmanager-0.8/src/knetworkmanager-connection_setting_info.cpp @@ -0,0 +1,163 @@ +/*************************************************************************** + * + * knetworkmanager-devicestore_dbus.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2005, 2006 Novell, Inc. + * + * Author: Helmut Schaa <[email protected]>, <[email protected]> + * + * 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 + * + **************************************************************************/ + +/* qt headers */ +#include <tqhostaddress.h> +#include <tqvariant.h> + +/* kde headers */ +#include <kdebug.h> +#include <klocale.h> + +/* TQT_DBus headers*/ +#include <tqdbusdata.h> +#include <tqdbusdatamap.h> + +/* knetworkmanager headers */ +#include "knetworkmanager.h" +#include "knetworkmanager-connection_setting_info.h" +#include "knetworkmanager-accesspoint.h" + + +using namespace ConnectionSettings; + +/* + class Info +*/ +Info::Info(Connection* conn, TQString devtype, const TQString& name, bool autoconnect) + : ConnectionSetting(conn, NM_SETTING_CONNECTION_SETTING_NAME) +{ + _name = name; + _devtype = devtype; + _autoconnect = autoconnect; +} + +TQString +Info::getDevType() const +{ + return _devtype; +} + +void +Info::setDevType(const TQString& devtype) +{ + _devtype = devtype; + emitValidityChanged(); +} + +TQString +Info::getName() const +{ + return _name; +} + +void +Info::setName(const TQString& name) +{ + _name = name; + emitValidityChanged(); +} + +bool +Info::getAutoconnect() const +{ + return _autoconnect; +} + +void +Info::setAutoconnect(bool autoconnect) +{ + _autoconnect = autoconnect; + emitValidityChanged(); +} + +TQDateTime +Info::getTimestamp() const +{ + return _timestamp; +} + +void +Info::setTimestamp(const TQDateTime& dt) +{ + _timestamp = dt; +} + +TQString +Info::getUUID() const +{ + return _uuid; +} + +void +Info::setUUID(const TQString& uuid) +{ + _uuid = uuid; +} + +SettingsMap +Info::toMap() const +{ + SettingsMap map; + map.insert(NM_SETTING_CONNECTION_ID, TQT_DBusData::fromString(_name)); + map.insert(NM_SETTING_CONNECTION_TYPE, TQT_DBusData::fromString(_devtype)); + map.insert(NM_SETTING_CONNECTION_AUTOCONNECT, TQT_DBusData::fromBool(_autoconnect)); + map.insert(NM_SETTING_CONNECTION_UUID, TQT_DBusData::fromString(_uuid)); + + if (!_timestamp.isNull()) + map.insert(NM_SETTING_CONNECTION_TIMESTAMP, TQT_DBusData::fromUInt32(_timestamp.toTime_t())); + + return map; +} + +void +Info::fromMap(const SettingsMap& map) +{ + SettingsMap::ConstIterator it; + + if ((it = map.find(NM_SETTING_CONNECTION_ID)) != map.end()) + _name = it.data().toString(); + + if ((it = map.find(NM_SETTING_CONNECTION_TYPE)) != map.end()) + _devtype = it.data().toString(); + + if ((it = map.find(NM_SETTING_CONNECTION_AUTOCONNECT)) != map.end()) + _autoconnect = it.data().toBool(); + + if ((it = map.find(NM_SETTING_CONNECTION_TIMESTAMP)) != map.end()) + _timestamp.setTime_t(it.data().toUInt32()); + + if ((it = map.find(NM_SETTING_CONNECTION_UUID)) != map.end()) + _uuid = it.data().toString(); +} + +bool +Info::isValid() const +{ + // name is essential + if (_name.isEmpty()) + return false; + + return true; +} |