1 /* This file is part of the dbusmenu-qt library
2 Copyright 2009 Canonical
3 Author: Aurelien Gateau <aurelien.gateau@canonical.com>
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License (LGPL) as published by the Free Software Foundation;
8 either version 2 of the License, or (at your option) any later
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
21 #include "dbusmenutypes_p.h"
24 #include <dbusmenushortcut_p.h>
28 #include <QDBusArgument>
29 #include <QDBusMetaType>
32 QDBusArgument &operator<<(QDBusArgument &argument, const DBusMenuItem &obj)
34 argument.beginStructure();
35 argument << obj.id << obj.properties;
36 argument.endStructure();
40 const QDBusArgument &operator>>(const QDBusArgument &argument, DBusMenuItem &obj)
42 argument.beginStructure();
43 argument >> obj.id >> obj.properties;
44 argument.endStructure();
49 QDBusArgument &operator<<(QDBusArgument &argument, const DBusMenuItemKeys &obj)
51 argument.beginStructure();
52 argument << obj.id << obj.properties;
53 argument.endStructure();
57 const QDBusArgument &operator>>(const QDBusArgument &argument, DBusMenuItemKeys &obj)
59 argument.beginStructure();
60 argument >> obj.id >> obj.properties;
61 argument.endStructure();
65 //// DBusMenuLayoutItem
66 QDBusArgument &operator<<(QDBusArgument &argument, const DBusMenuLayoutItem &obj)
68 argument.beginStructure();
69 argument << obj.id << obj.properties;
70 argument.beginArray(qMetaTypeId<QDBusVariant>());
71 Q_FOREACH(const DBusMenuLayoutItem& child, obj.children) {
72 argument << QDBusVariant(QVariant::fromValue<DBusMenuLayoutItem>(child));
75 argument.endStructure();
79 const QDBusArgument &operator>>(const QDBusArgument &argument, DBusMenuLayoutItem &obj)
81 argument.beginStructure();
82 argument >> obj.id >> obj.properties;
83 argument.beginArray();
84 while (!argument.atEnd()) {
85 QDBusVariant dbusVariant;
86 argument >> dbusVariant;
87 QDBusArgument childArgument = dbusVariant.variant().value<QDBusArgument>();
89 DBusMenuLayoutItem child;
90 childArgument >> child;
91 obj.children.append(child);
94 argument.endStructure();
98 int DBusMenuTypes_register()
100 qDBusRegisterMetaType<DBusMenuItem>();
101 qDBusRegisterMetaType<DBusMenuItemList>();
102 qDBusRegisterMetaType<DBusMenuItemKeys>();
103 qDBusRegisterMetaType<DBusMenuItemKeysList>();
104 qDBusRegisterMetaType<DBusMenuLayoutItem>();
105 qDBusRegisterMetaType<DBusMenuLayoutItemList>();
106 qDBusRegisterMetaType<DBusMenuShortcut>();
110 Q_CONSTRUCTOR_FUNCTION(DBusMenuTypes_register)