KIO

kssld_dbusmetatypes.h
1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 2007 Andreas Hartmetz <ahartmetz@gmail.com>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#ifndef KSSLD_DBUSMETATYPES_H
9#define KSSLD_DBUSMETATYPES_H
10
11#include "ksslcertificatemanager_p.h"
12
13#include <QDBusArgument>
14#include <QDBusMetaType>
15#include <qglobal.h>
16
17Q_DECLARE_METATYPE(KSslCertificateRule)
18Q_DECLARE_METATYPE(QSslError::SslError)
19
20inline QDBusArgument &operator<<(QDBusArgument &argument, const QSslCertificate &cert)
21{
22 argument.beginStructure();
23 argument << cert.toDer();
24 argument.endStructure();
25 return argument;
26}
27
28inline const QDBusArgument &operator>>(const QDBusArgument &argument, QSslCertificate &cert)
29{
30 QByteArray data;
31 argument.beginStructure();
32 argument >> data;
33 argument.endStructure();
34 cert = QSslCertificate(data, QSsl::Der);
35 return argument;
36}
37
38inline QDBusArgument &operator<<(QDBusArgument &argument, const KSslCertificateRule &rule)
39{
40 argument.beginStructure();
41 argument << rule.certificate() << rule.hostName() << rule.isRejected() << rule.expiryDateTime().toString(Qt::ISODate) << rule.ignoredErrors();
42 argument.endStructure();
43 return argument;
44}
45
46inline const QDBusArgument &operator>>(const QDBusArgument &argument, KSslCertificateRule &rule)
47{
48 QSslCertificate cert;
49 QString hostName;
50 bool isRejected;
51 QString expiryStr;
52 QList<QSslError::SslError> ignoredErrors;
53 argument.beginStructure();
54 argument >> cert >> hostName >> isRejected >> expiryStr >> ignoredErrors;
55 argument.endStructure();
56
57 KSslCertificateRule ret(cert, hostName);
58 ret.setRejected(isRejected);
59 ret.setExpiryDateTime(QDateTime::fromString(expiryStr, Qt::ISODate));
60 ret.setIgnoredErrors(ignoredErrors);
61 rule = ret;
62 return argument;
63}
64
65inline QDBusArgument &operator<<(QDBusArgument &argument, const QSslError::SslError &error)
66{
67 argument.beginStructure(); // overhead ho!
68 argument << static_cast<int>(error);
69 argument.endStructure();
70 return argument;
71}
72
73inline const QDBusArgument &operator>>(const QDBusArgument &argument, QSslError::SslError &error)
74{
75 int data;
76 argument.beginStructure();
77 argument >> data;
78 argument.endStructure();
79 error = static_cast<QSslError::SslError>(data);
80 return argument;
81}
82
83static void registerMetaTypesForKSSLD()
84{
85 qDBusRegisterMetaType<QSslCertificate>();
86 qDBusRegisterMetaType<KSslCertificateRule>();
87 qDBusRegisterMetaType<QList<QSslCertificate>>();
88 qDBusRegisterMetaType<QSslError::SslError>();
89 qDBusRegisterMetaType<QList<QSslError::SslError>>();
90}
91
92#endif // KSSLD_DBUSMETATYPES_H
KCALENDARCORE_EXPORT QDataStream & operator>>(QDataStream &in, const KCalendarCore::Alarm::Ptr &)
void error(QWidget *parent, const QString &text, const QString &title, const KGuiItem &buttonOk, Options options=Notify)
QDebug operator<<(QDebug dbg, const PerceptualColor::MultiSpinBoxSection &value)
QDateTime fromString(QStringView string, QStringView format, QCalendar cal)
QString toString(QStringView format, QCalendar cal) const const
void beginStructure()
void endStructure()
QByteArray toDer() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:27 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.