Changeset View
Changeset View
Standalone View
Standalone View
gmenu-dbusmenu-proxy/gdbusmenutypes_p.cpp
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright (C) 2018 Kai Uwe Broulik <kde@privat.broulik.de> | ||||
3 | * | ||||
4 | * This library is free software; you can redistribute it and/or | ||||
5 | * modify it under the terms of the GNU Lesser General Public | ||||
6 | * License as published by the Free Software Foundation; either | ||||
7 | * version 2.1 of the License, or (at your option) any later version. | ||||
8 | * | ||||
9 | * This library is distributed in the hope that it will be useful, | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
12 | * Lesser General Public License for more details. | ||||
13 | * | ||||
14 | * You should have received a copy of the GNU Lesser General Public | ||||
15 | * License along with this library; if not, write to the Free Software | ||||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||||
17 | * | ||||
18 | */ | ||||
19 | | ||||
20 | #include "gdbusmenutypes_p.h" | ||||
21 | | ||||
22 | #include <QDBusArgument> | ||||
23 | #include <QDBusMetaType> | ||||
24 | | ||||
25 | // GMenuItem | ||||
26 | QDBusArgument &operator<<(QDBusArgument &argument, const GMenuItem &item) | ||||
27 | { | ||||
28 | argument.beginStructure(); | ||||
29 | argument << item.id << item.section << item.items; | ||||
30 | argument.endStructure(); | ||||
31 | return argument; | ||||
32 | } | ||||
33 | | ||||
34 | const QDBusArgument &operator>>(const QDBusArgument &argument, GMenuItem &item) | ||||
35 | { | ||||
36 | argument.beginStructure(); | ||||
37 | argument >> item.id >> item.section >> item.items; | ||||
38 | argument.endStructure(); | ||||
39 | return argument; | ||||
40 | } | ||||
41 | | ||||
42 | // GMenuSection | ||||
43 | QDBusArgument &operator<<(QDBusArgument &argument, const GMenuSection &item) | ||||
44 | { | ||||
45 | argument.beginStructure(); | ||||
46 | argument << item.subscription << item.menu; | ||||
47 | argument.endStructure(); | ||||
48 | return argument; | ||||
49 | } | ||||
50 | | ||||
51 | const QDBusArgument &operator>>(const QDBusArgument &argument, GMenuSection &item) | ||||
52 | { | ||||
53 | argument.beginStructure(); | ||||
54 | argument >> item.subscription >> item.menu; | ||||
55 | argument.endStructure(); | ||||
56 | return argument; | ||||
57 | } | ||||
58 | | ||||
59 | // GMenuChange | ||||
60 | QDBusArgument &operator<<(QDBusArgument &argument, const GMenuChange &item) | ||||
61 | { | ||||
62 | argument.beginStructure(); | ||||
63 | argument << item.subscription << item.menu << item.changePosition << item.itemsToRemoveCount << item.itemsToInsert; | ||||
64 | argument.endStructure(); | ||||
65 | return argument; | ||||
66 | } | ||||
67 | | ||||
68 | const QDBusArgument &operator>>(const QDBusArgument &argument, GMenuChange &item) | ||||
69 | { | ||||
70 | argument.beginStructure(); | ||||
71 | argument >> item.subscription >> item.menu >> item.changePosition >> item.itemsToRemoveCount >> item.itemsToInsert; | ||||
72 | argument.endStructure(); | ||||
73 | return argument; | ||||
74 | } | ||||
75 | | ||||
76 | // GMenuActionProperty | ||||
77 | QDBusArgument &operator<<(QDBusArgument &argument, const GMenuAction &item) | ||||
78 | { | ||||
79 | argument.beginStructure(); | ||||
80 | argument << item.enabled << item.signature << item.state; | ||||
81 | argument.endStructure(); | ||||
82 | return argument; | ||||
83 | } | ||||
84 | | ||||
85 | const QDBusArgument &operator>>(const QDBusArgument &argument, GMenuAction &item) | ||||
86 | { | ||||
87 | argument.beginStructure(); | ||||
88 | argument >> item.enabled >> item.signature >> item.state; | ||||
89 | argument.endStructure(); | ||||
90 | return argument; | ||||
91 | } | ||||
92 | | ||||
93 | // GMenuActionsChange | ||||
94 | QDBusArgument &operator<<(QDBusArgument &argument, const GMenuActionsChange &item) | ||||
95 | { | ||||
96 | argument.beginStructure(); | ||||
97 | argument << item.removed << item.enabledChanged << item.stateChanged << item.added; | ||||
98 | argument.endStructure(); | ||||
99 | return argument; | ||||
100 | } | ||||
101 | | ||||
102 | const QDBusArgument &operator>>(const QDBusArgument &argument, GMenuActionsChange &item) | ||||
103 | { | ||||
104 | argument.beginStructure(); | ||||
105 | argument >> item.removed >> item.enabledChanged >> item.stateChanged >> item.added; | ||||
106 | argument.endStructure(); | ||||
107 | return argument; | ||||
108 | } | ||||
109 | | ||||
110 | void GDBusMenuTypes_register() | ||||
111 | { | ||||
112 | static bool registered = false; | ||||
113 | if (registered) { | ||||
114 | return; | ||||
115 | } | ||||
116 | | ||||
117 | qDBusRegisterMetaType<GMenuItem>(); | ||||
118 | qDBusRegisterMetaType<GMenuItemList>(); | ||||
119 | | ||||
120 | qDBusRegisterMetaType<GMenuSection>(); | ||||
121 | | ||||
122 | qDBusRegisterMetaType<GMenuChange>(); | ||||
123 | qDBusRegisterMetaType<GMenuChangeList>(); | ||||
124 | | ||||
125 | qDBusRegisterMetaType<GMenuAction>(); | ||||
126 | qDBusRegisterMetaType<GMenuActionMap>(); | ||||
127 | | ||||
128 | qDBusRegisterMetaType<GMenuActionsChange>(); | ||||
129 | qDBusRegisterMetaType<StringBoolMap>(); | ||||
130 | | ||||
131 | registered = true; | ||||
132 | } |