Changeset View
Changeset View
Standalone View
Standalone View
src/core/kssld_dbusmetatypes.h
Show All 16 Lines | 1 | /* | |||
---|---|---|---|---|---|
17 | along with this library; see the file COPYING.LIB. If not, write to | 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, | 18 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
19 | Boston, MA 02110-1301, USA. | 19 | Boston, MA 02110-1301, USA. | ||
20 | */ | 20 | */ | ||
21 | 21 | | |||
22 | #ifndef KSSLD_DBUSMETATYPES_H | 22 | #ifndef KSSLD_DBUSMETATYPES_H | ||
23 | #define KSSLD_DBUSMETATYPES_H | 23 | #define KSSLD_DBUSMETATYPES_H | ||
24 | 24 | | |||
25 | #include "ksslcertificatemanager_p.h" | ||||
26 | | ||||
25 | #include <qglobal.h> | 27 | #include <qglobal.h> | ||
26 | #include <QDBusArgument> | 28 | #include <QDBusArgument> | ||
27 | #include <QDBusMetaType> | 29 | #include <QDBusMetaType> | ||
28 | 30 | | |||
29 | Q_DECLARE_METATYPE(KSslCertificateRule) | 31 | Q_DECLARE_METATYPE(KSslCertificateRule) | ||
30 | Q_DECLARE_METATYPE(KSslError::Error) | 32 | Q_DECLARE_METATYPE(QSslError::SslError) | ||
31 | 33 | | |||
32 | QDBusArgument &operator<<(QDBusArgument &argument, const QSslCertificate &cert) | 34 | QDBusArgument &operator<<(QDBusArgument &argument, const QSslCertificate &cert) | ||
33 | { | 35 | { | ||
34 | argument.beginStructure(); | 36 | argument.beginStructure(); | ||
35 | argument << cert.toDer(); | 37 | argument << cert.toDer(); | ||
36 | argument.endStructure(); | 38 | argument.endStructure(); | ||
37 | return argument; | 39 | return argument; | ||
38 | } | 40 | } | ||
39 | 41 | | |||
40 | const QDBusArgument &operator>>(const QDBusArgument &argument, QSslCertificate &cert) | 42 | const QDBusArgument &operator>>(const QDBusArgument &argument, QSslCertificate &cert) | ||
41 | { | 43 | { | ||
42 | QByteArray data; | 44 | QByteArray data; | ||
43 | argument.beginStructure(); | 45 | argument.beginStructure(); | ||
44 | argument >> data; | 46 | argument >> data; | ||
45 | argument.endStructure(); | 47 | argument.endStructure(); | ||
46 | cert = QSslCertificate(data, QSsl::Der); | 48 | cert = QSslCertificate(data, QSsl::Der); | ||
47 | return argument; | 49 | return argument; | ||
48 | } | 50 | } | ||
49 | 51 | | |||
50 | QDBusArgument &operator<<(QDBusArgument &argument, const KSslCertificateRule &rule) | 52 | QDBusArgument &operator<<(QDBusArgument &argument, const KSslCertificateRule &rule) | ||
51 | { | 53 | { | ||
52 | argument.beginStructure(); | 54 | argument.beginStructure(); | ||
53 | argument << rule.certificate() << rule.hostName() | 55 | argument << rule.certificate() << rule.hostName() | ||
54 | << rule.isRejected() << rule.expiryDateTime().toString(Qt::ISODate) | 56 | << rule.isRejected() << rule.expiryDateTime().toString(Qt::ISODate) | ||
55 | << rule.ignoredErrors(); | 57 | << rule.d->ignoredErrors; // TODO KF6: replace by a call to rule.ignoredErrors | ||
56 | argument.endStructure(); | 58 | argument.endStructure(); | ||
57 | return argument; | 59 | return argument; | ||
58 | } | 60 | } | ||
59 | 61 | | |||
60 | const QDBusArgument &operator>>(const QDBusArgument &argument, KSslCertificateRule &rule) | 62 | const QDBusArgument &operator>>(const QDBusArgument &argument, KSslCertificateRule &rule) | ||
61 | { | 63 | { | ||
62 | QSslCertificate cert; | 64 | QSslCertificate cert; | ||
63 | QString hostName; | 65 | QString hostName; | ||
64 | bool isRejected; | 66 | bool isRejected; | ||
65 | QString expiryStr; | 67 | QString expiryStr; | ||
66 | QList<KSslError::Error> ignoredErrors; | 68 | QList<QSslError::SslError> ignoredErrors; | ||
67 | argument.beginStructure(); | 69 | argument.beginStructure(); | ||
68 | argument >> cert >> hostName >> isRejected >> expiryStr >> ignoredErrors; | 70 | argument >> cert >> hostName >> isRejected >> expiryStr >> ignoredErrors; | ||
69 | argument.endStructure(); | 71 | argument.endStructure(); | ||
70 | 72 | | |||
71 | KSslCertificateRule ret(cert, hostName); | 73 | KSslCertificateRule ret(cert, hostName); | ||
72 | ret.setRejected(isRejected); | 74 | ret.setRejected(isRejected); | ||
73 | ret.setExpiryDateTime(QDateTime::fromString(expiryStr, Qt::ISODate)); | 75 | ret.setExpiryDateTime(QDateTime::fromString(expiryStr, Qt::ISODate)); | ||
74 | ret.setIgnoredErrors(ignoredErrors); | 76 | ret.setIgnoredErrors(ignoredErrors); | ||
75 | rule = ret; | 77 | rule = ret; | ||
76 | return argument; | 78 | return argument; | ||
77 | } | 79 | } | ||
78 | 80 | | |||
79 | QDBusArgument &operator<<(QDBusArgument &argument, const KSslError::Error &error) | 81 | QDBusArgument &operator<<(QDBusArgument &argument, const QSslError::SslError &error) | ||
80 | { | 82 | { | ||
81 | argument.beginStructure(); //overhead ho! | 83 | argument.beginStructure(); //overhead ho! | ||
82 | argument << static_cast<int>(error); | 84 | argument << static_cast<int>(error); | ||
83 | argument.endStructure(); | 85 | argument.endStructure(); | ||
84 | return argument; | 86 | return argument; | ||
85 | } | 87 | } | ||
86 | 88 | | |||
87 | const QDBusArgument &operator>>(const QDBusArgument &argument, KSslError::Error &error) | 89 | const QDBusArgument &operator>>(const QDBusArgument &argument, QSslError::SslError &error) | ||
88 | { | 90 | { | ||
89 | int data; | 91 | int data; | ||
90 | argument.beginStructure(); | 92 | argument.beginStructure(); | ||
91 | argument >> data; | 93 | argument >> data; | ||
92 | argument.endStructure(); | 94 | argument.endStructure(); | ||
93 | error = static_cast<KSslError::Error>(data); | 95 | error = static_cast<QSslError::SslError>(data); | ||
94 | return argument; | 96 | return argument; | ||
95 | } | 97 | } | ||
96 | 98 | | |||
97 | static void registerMetaTypesForKSSLD() | 99 | static void registerMetaTypesForKSSLD() | ||
98 | { | 100 | { | ||
99 | qDBusRegisterMetaType<QSslCertificate>(); | 101 | qDBusRegisterMetaType<QSslCertificate>(); | ||
100 | qDBusRegisterMetaType<KSslCertificateRule>(); | 102 | qDBusRegisterMetaType<KSslCertificateRule>(); | ||
101 | qDBusRegisterMetaType<QList<QSslCertificate> >(); | 103 | qDBusRegisterMetaType<QList<QSslCertificate> >(); | ||
102 | qDBusRegisterMetaType<KSslError::Error>(); | 104 | qDBusRegisterMetaType<QSslError::SslError>(); | ||
103 | qDBusRegisterMetaType<QList<KSslError::Error> >(); | 105 | qDBusRegisterMetaType<QList<QSslError::SslError>>(); | ||
104 | } | 106 | } | ||
105 | 107 | | |||
106 | #endif //KSSLD_DBUSMETATYPES_H | 108 | #endif //KSSLD_DBUSMETATYPES_H |