1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 2020 Henri Chain <henri.chain@enioka.com>
4
5 SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6*/
7
8#ifndef DBUSTYPES_H
9#define DBUSTYPES_H
10
11#include <QDBusArgument>
12
13struct QVariantMultiItem {
14 QString key;
15 QVariant value;
16};
17Q_DECLARE_METATYPE(QVariantMultiItem)
18using QVariantMultiMap = QList<QVariantMultiItem>;
19Q_DECLARE_METATYPE(QVariantMultiMap)
20
21inline QDBusArgument &operator<<(QDBusArgument &argument, const QVariantMultiItem &item)
22{
23 argument.beginStructure();
24 argument << item.key << QDBusVariant(item.value);
25 argument.endStructure();
26 return argument;
27}
28
29inline const QDBusArgument &operator>>(const QDBusArgument &argument, QVariantMultiItem &item)
30{
31 argument.beginStructure();
32 argument >> item.key >> item.value;
33 argument.endStructure();
34 return argument;
35}
36
37struct ExecCommand {
38 QString path;
39 QStringList argv;
40 bool ignoreFailure;
41};
42Q_DECLARE_METATYPE(ExecCommand)
43using ExecCommandList = QList<ExecCommand>;
44Q_DECLARE_METATYPE(ExecCommandList)
45
46inline QDBusArgument &operator<<(QDBusArgument &argument, const ExecCommand &execCommand)
47{
48 argument.beginStructure();
49 argument << execCommand.path << execCommand.argv << execCommand.ignoreFailure;
50 argument.endStructure();
51 return argument;
52}
53
54inline const QDBusArgument &operator>>(const QDBusArgument &argument, ExecCommand &execCommand)
55{
56 argument.beginStructure();
57 argument >> execCommand.path >> execCommand.argv >> execCommand.ignoreFailure;
58 argument.endStructure();
59 return argument;
60}
61
62struct TransientAux {
63 QString name;
64 QVariantMultiMap properties;
65};
66Q_DECLARE_METATYPE(TransientAux)
67using TransientAuxList = QList<TransientAux>;
68Q_DECLARE_METATYPE(TransientAuxList)
69
70inline QDBusArgument &operator<<(QDBusArgument &argument, const TransientAux &aux)
71{
72 argument.beginStructure();
73 argument << aux.name << aux.properties;
74 argument.endStructure();
75 return argument;
76}
77
78inline const QDBusArgument &operator>>(const QDBusArgument &argument, TransientAux &aux)
79{
80 argument.beginStructure();
81 argument >> aux.name >> aux.properties;
82 argument.endStructure();
83 return argument;
84}
85
86#endif // DBUSTYPES_H
87

source code of kio/src/gui/systemd/dbustypes.h