| 1 | /* |
| 2 | SPDX-FileCopyrightText: 2011 Ilia Kats <ilia-kats@gmx.net> |
| 3 | SPDX-FileCopyrightText: 2013 Jan Grulich <jgrulich@redhat.com> |
| 4 | |
| 5 | SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
| 6 | */ |
| 7 | |
| 8 | #include "generictypes.h" |
| 9 | |
| 10 | QDBusArgument &operator<<(QDBusArgument &argument, const IpV6DBusAddress &address) |
| 11 | { |
| 12 | argument.beginStructure(); |
| 13 | argument << address.address << address.prefix << address.gateway; |
| 14 | argument.endStructure(); |
| 15 | return argument; |
| 16 | } |
| 17 | |
| 18 | const QDBusArgument &operator>>(const QDBusArgument &argument, IpV6DBusAddress &address) |
| 19 | { |
| 20 | argument.beginStructure(); |
| 21 | argument >> address.address >> address.prefix >> address.gateway; |
| 22 | argument.endStructure(); |
| 23 | return argument; |
| 24 | } |
| 25 | |
| 26 | QDBusArgument &operator<<(QDBusArgument &argument, const IpV6DBusRoute &route) |
| 27 | { |
| 28 | argument.beginStructure(); |
| 29 | argument << route.destination << route.prefix << route.nexthop << route.metric; |
| 30 | argument.endStructure(); |
| 31 | return argument; |
| 32 | } |
| 33 | |
| 34 | const QDBusArgument &operator>>(const QDBusArgument &argument, IpV6DBusRoute &route) |
| 35 | { |
| 36 | argument.beginStructure(); |
| 37 | argument >> route.destination >> route.prefix >> route.nexthop >> route.metric; |
| 38 | argument.endStructure(); |
| 39 | return argument; |
| 40 | } |
| 41 | |
| 42 | QDBusArgument &operator<<(QDBusArgument &argument, const NMStringMap &mydict) |
| 43 | { |
| 44 | argument.beginMap(keyMetaTypeId: QMetaType::QString, valueMetaTypeId: QMetaType::QString); |
| 45 | |
| 46 | QMapIterator<QString, QString> i(mydict); |
| 47 | while (i.hasNext()) { |
| 48 | i.next(); |
| 49 | argument.beginMapEntry(); |
| 50 | argument << i.key() << i.value(); |
| 51 | argument.endMapEntry(); |
| 52 | } |
| 53 | argument.endMap(); |
| 54 | return argument; |
| 55 | } |
| 56 | |
| 57 | const QDBusArgument &operator>>(const QDBusArgument &argument, NMStringMap &mydict) |
| 58 | { |
| 59 | argument.beginMap(); |
| 60 | mydict.clear(); |
| 61 | |
| 62 | while (!argument.atEnd()) { |
| 63 | QString key; |
| 64 | QString value; |
| 65 | argument.beginMapEntry(); |
| 66 | argument >> key >> value; |
| 67 | argument.endMapEntry(); |
| 68 | mydict.insert(key, value); |
| 69 | } |
| 70 | |
| 71 | argument.endMap(); |
| 72 | return argument; |
| 73 | } |
| 74 | |
| 75 | QDBusArgument &operator<<(QDBusArgument &argument, const DeviceDBusStateReason &reason) |
| 76 | { |
| 77 | argument.beginStructure(); |
| 78 | argument << reason.state << reason.reason; |
| 79 | argument.endStructure(); |
| 80 | return argument; |
| 81 | } |
| 82 | |
| 83 | const QDBusArgument &operator>>(const QDBusArgument &argument, DeviceDBusStateReason &reason) |
| 84 | { |
| 85 | argument.beginStructure(); |
| 86 | argument >> reason.state >> reason.reason; |
| 87 | argument.endStructure(); |
| 88 | return argument; |
| 89 | } |
| 90 | |