ModemManagerQt

generictypes.cpp
1/*
2 SPDX-FileCopyrightText: 2010 Lamarque Souza <lamarque@kde.org>
3 SPDX-FileCopyrightText: 2013 Lukas Tinkl <ltinkl@redhat.com>
4 SPDX-FileCopyrightText: 2013-2015 Jan Grulich <jgrulich@redhat.com>
5
6 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7*/
8
9#include "generictypes.h"
10#include "generictypes_p.h"
11
12#include <QDBusMetaType>
13
14QDBusArgument &operator<<(QDBusArgument &arg, const ModemManager::Port &port)
15{
16 arg.beginStructure();
17 arg << port.name << port.type;
18 arg.endStructure();
19 return arg;
20}
21
22const QDBusArgument &operator>>(const QDBusArgument &arg, ModemManager::Port &port)
23{
24 QString temp1;
25 uint temp2;
26 arg.beginStructure();
27 arg >> temp1 >> temp2;
28 port.name = temp1;
29 port.type = (MMModemPortType)temp2;
30 arg.endStructure();
31
32 return arg;
33}
34
35// Marshall the CurrentModesType data into a D-BUS argument
36QDBusArgument &operator<<(QDBusArgument &arg, const ModemManager::CurrentModesType &mode)
37{
38 arg.beginStructure();
39 arg << mode.allowed << mode.preferred;
40 arg.endStructure();
41 return arg;
42}
43
44// Retrieve the CurrentModesType data from the D-BUS argument
45const QDBusArgument &operator>>(const QDBusArgument &arg, ModemManager::CurrentModesType &mode)
46{
47 uint temp1;
48 uint temp2;
49 arg.beginStructure();
50 arg >> temp1 >> temp2;
51 mode.allowed = (MMModemMode)temp1;
52 mode.preferred = (MMModemMode)temp2;
53 arg.endStructure();
54
55 return arg;
56}
57
58#if MM_CHECK_VERSION(1, 2, 0)
59// Marshall the OmaSessionType data into a D-BUS argument
60QDBusArgument &operator<<(QDBusArgument &arg, const ModemManager::OmaSessionType &sessionType)
61{
62 arg.beginStructure();
63 arg << sessionType.type << sessionType.id;
64 arg.endStructure();
65 return arg;
66}
67
68// Retrieve the OmaSessionType data from the D-BUS argument
69const QDBusArgument &operator>>(const QDBusArgument &arg, ModemManager::OmaSessionType &sessionType)
70{
71 uint type;
72 uint id;
73 arg.beginStructure();
74 arg >> type >> id;
75 sessionType.type = (MMOmaSessionType)type;
76 sessionType.id = id;
77 arg.endStructure();
78
79 return arg;
80}
81#endif
82
83// Marshall the SignalQualityPair data into a D-BUS argument
84QDBusArgument &operator<<(QDBusArgument &arg, const ModemManager::SignalQualityPair &sqp)
85{
86 arg.beginStructure();
87 arg << sqp.signal << sqp.recent;
88 arg.endStructure();
89 return arg;
90}
91
92// Retrieve the SignalQualityPair data from the D-BUS argument
93const QDBusArgument &operator>>(const QDBusArgument &arg, ModemManager::SignalQualityPair &sqp)
94{
95 arg.beginStructure();
96 arg >> sqp.signal >> sqp.recent;
97 arg.endStructure();
98 return arg;
99}
100
101// Marshall the ValidityPair data into a D-BUS argument
102QDBusArgument &operator<<(QDBusArgument &arg, const ModemManager::ValidityPair &vp)
103{
104 arg.beginStructure();
105 arg << vp.validity << vp.value;
106 arg.endStructure();
107 return arg;
108}
109
110// Retrieve the ValidityPair data from the D-BUS argument
111const QDBusArgument &operator>>(const QDBusArgument &arg, ModemManager::ValidityPair &vp)
112{
113 uint temp1;
114 uint temp2;
115 arg.beginStructure();
116 arg >> temp1 >> temp2;
117 vp.validity = (MMSmsValidityType)temp1;
118 vp.value = temp2;
119 arg.endStructure();
120
121 return arg;
122}
123
124// Marshall the UnlockRetriesMap data into a D-BUS argument
125QDBusArgument &operator<<(QDBusArgument &argument, const ModemManager::UnlockRetriesMap &unlockRetriesMap)
126{
128
129 QMapIterator<MMModemLock, uint> i(unlockRetriesMap);
130 while (i.hasNext()) {
131 i.next();
132 argument.beginMapEntry();
133 argument << i.key() << i.value();
134 argument.endMapEntry();
135 }
136 argument.endMap();
137 return argument;
138}
139
140// Retrieve the UnlockRetriesMap data from the D-BUS argument
141const QDBusArgument &operator>>(const QDBusArgument &argument, ModemManager::UnlockRetriesMap &unlockRetriesMap)
142{
143 argument.beginMap();
144 unlockRetriesMap.clear();
145
146 while (!argument.atEnd()) {
147 int key;
148 uint value;
149 argument.beginMapEntry();
150 argument >> key;
151 argument >> value;
152 argument.endMapEntry();
153 unlockRetriesMap.insert((MMModemLock)key, value);
154 }
155
156 argument.endMap();
157 return argument;
158}
159
160// Marshal QList<QVariantMap> into a D-BUS argument
162{
163 argument.beginArray(qMetaTypeId<QVariantMap>());
164 for (int i = 0; i < variantMapList.length(); ++i) {
165 argument << variantMapList[i];
166 }
167 argument.endArray();
168 return argument;
169}
170
171// Retrieve QList<QVariantMap> from a D-BUS argument
172const QDBusArgument &operator>>(const QDBusArgument &argument, ModemManager::QVariantMapList &variantMapList)
173{
174 argument.beginArray();
175 variantMapList.clear();
176
177 while (!argument.atEnd()) {
178 QVariantMap element;
179 argument >> element;
180 variantMapList.append(element);
181 }
182
183 argument.endArray();
184 return argument;
185}
186
187// Marshal LocationInformationMap into a D-BUS argument
189{
190 argument.beginMap(qMetaTypeId<uint>(), qMetaTypeId<QDBusVariant>());
191
193 while (i.hasNext()) {
194 i.next();
195 argument.beginMapEntry();
196 argument << (uint)i.key() << QDBusVariant(i.value());
197 argument.endMapEntry();
198 }
199 argument.endMap();
200 return argument;
201}
202
203// Retrieve LocationInformationMap from a D-BUS argument
205{
206 argument.beginMap();
207 locationMap.clear();
208
209 while (!argument.atEnd()) {
210 uint key;
211 QDBusVariant value;
212 argument.beginMapEntry();
213 argument >> key;
214 argument >> value;
215 argument.endMapEntry();
216 locationMap.insert((MMModemLocationSource)key, value.variant());
217 }
218
219 argument.endMap();
220 return argument;
221}
222
223void registerModemManagerTypes()
224{
225 qDBusRegisterMetaType<ModemManager::MMVariantMapMap>();
226 qDBusRegisterMetaType<ModemManager::DBUSManagerStruct>();
227 qDBusRegisterMetaType<ModemManager::UIntList>();
228 qDBusRegisterMetaType<ModemManager::UIntListList>();
229 qDBusRegisterMetaType<ModemManager::Port>();
230 qDBusRegisterMetaType<ModemManager::PortList>();
231 qDBusRegisterMetaType<ModemManager::CurrentModesType>();
232 qDBusRegisterMetaType<ModemManager::SignalQualityPair>();
233 qDBusRegisterMetaType<ModemManager::SupportedModesType>();
234 qDBusRegisterMetaType<ModemManager::UnlockRetriesMap>();
235 qDBusRegisterMetaType<ModemManager::QVariantMapList>();
236#if MM_CHECK_VERSION(1, 2, 0)
237 qDBusRegisterMetaType<ModemManager::OmaSessionType>();
238 qDBusRegisterMetaType<ModemManager::OmaSessionTypes>();
239#endif
240 qDBusRegisterMetaType<ModemManager::LocationInformationMap>();
241 qDBusRegisterMetaType<ModemManager::ValidityPair>();
242 qDBusRegisterMetaType<ModemManager::PortList>();
243 qRegisterMetaType<MMModemMode>("MMModemMode");
244 qRegisterMetaType<MMModemLock>("MMModemLock");
245 qRegisterMetaType<MMModem3gppUssdSessionState>("MMModem3gppUssdSessionState");
246 qRegisterMetaType<MMModemLocationSource>("MMModemLocationSource");
247}
Type type(const QSqlDatabase &db)
KCALENDARCORE_EXPORT QDataStream & operator>>(QDataStream &in, const KCalendarCore::Alarm::Ptr &)
QDebug operator<<(QDebug dbg, const PerceptualColor::MultiSpinBoxSection &value)
bool atEnd() const const
void beginArray(QMetaType id)
void beginMap(QMetaType keyMetaType, QMetaType valueMetaType)
void beginMapEntry()
void beginStructure()
void endMapEntry()
void endStructure()
void append(QList< T > &&value)
void clear()
qsizetype length() const const
void clear()
iterator insert(const Key &key, const T &value)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:15:10 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.