KDECore
kssld_dbusmetatypes.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef KSSLD_DBUSMETATYPES_H
00023 #define KSSLD_DBUSMETATYPES_H
00024
00025 Q_DECLARE_METATYPE(QSslCertificate)
00026 Q_DECLARE_METATYPE(KSslCertificateRule)
00027 Q_DECLARE_METATYPE(QList<QSslCertificate>)
00028 Q_DECLARE_METATYPE(KSslError::Error)
00029 Q_DECLARE_METATYPE(QList<KSslError::Error>)
00030
00031
00032 QDBusArgument &operator<<(QDBusArgument &argument, const QSslCertificate &cert)
00033 {
00034 argument.beginStructure();
00035 argument << cert.toDer();
00036 argument.endStructure();
00037 return argument;
00038 }
00039
00040
00041 const QDBusArgument &operator>>(const QDBusArgument &argument, QSslCertificate &cert)
00042 {
00043 QByteArray data;
00044 argument.beginStructure();
00045 argument >> data;
00046 argument.endStructure();
00047 cert = QSslCertificate(data, QSsl::Der);
00048 return argument;
00049 }
00050
00051
00052 QDBusArgument &operator<<(QDBusArgument &argument, const KSslCertificateRule &rule)
00053 {
00054 argument.beginStructure();
00055 argument << rule.certificate() << rule.hostName()
00056 << rule.isRejected() << rule.expiryDateTime().toString(Qt::ISODate)
00057 << rule.ignoredErrors();
00058 argument.endStructure();
00059 return argument;
00060 }
00061
00062
00063 const QDBusArgument &operator>>(const QDBusArgument &argument, KSslCertificateRule &rule)
00064 {
00065 QSslCertificate cert;
00066 QString hostName;
00067 bool isRejected;
00068 QString expiryStr;
00069 QList<KSslError::Error> ignoredErrors;
00070 argument.beginStructure();
00071 argument >> cert >> hostName >> isRejected >> expiryStr >> ignoredErrors;
00072 argument.endStructure();
00073
00074 KSslCertificateRule ret(cert, hostName);
00075 ret.setRejected(isRejected);
00076 ret.setExpiryDateTime(QDateTime::fromString(expiryStr, Qt::ISODate));
00077 ret.setIgnoredErrors(ignoredErrors);
00078 rule = ret;
00079 return argument;
00080 }
00081
00082
00083 QDBusArgument &operator<<(QDBusArgument &argument, const KSslError::Error &error)
00084 {
00085 argument.beginStructure();
00086 argument << static_cast<int>(error);
00087 argument.endStructure();
00088 return argument;
00089 }
00090
00091
00092 const QDBusArgument &operator>>(const QDBusArgument &argument, KSslError::Error &error)
00093 {
00094 int data;
00095 argument.beginStructure();
00096 argument >> data;
00097 argument.endStructure();
00098 error = static_cast<KSslError::Error>(data);
00099 return argument;
00100 }
00101
00102
00103 static void registerMetaTypesForKSSLD()
00104 {
00105 qDBusRegisterMetaType<QSslCertificate>();
00106 qDBusRegisterMetaType<KSslCertificateRule>();
00107 qDBusRegisterMetaType<QList<QSslCertificate> >();
00108 qDBusRegisterMetaType<KSslError::Error>();
00109 qDBusRegisterMetaType<QList<KSslError::Error> >();
00110 }
00111
00112 #endif //KSSLD_DBUSMETATYPES_H