1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
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 <tdelocale.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;
}
|