25#include <QtCore/QByteArray>
26#include <QtCore/QEventLoop>
30#include "kpasswdserver_interface.h"
36 : m_interface(new OrgKdeKPasswdServerInterface(
"org.kde.kded",
37 "/modules/kpasswdserver",
38 QDBusConnection::sessionBus()))
50 kDebug(7019) <<
"window-id=" << windowId <<
"url=" << info.
url;
53 if (!QCoreApplication::instance()) {
54 kWarning(7019) <<
"kioslave is not a QCoreApplication!";
55 return legacyCheckAuthInfo(info, windowId, usertime);
60 QObject::connect(m_interface, SIGNAL(checkAuthInfoAsyncResult(qlonglong,qlonglong,
KIO::AuthInfo)),
61 &loop, SLOT(slotQueryResult(qlonglong,qlonglong,
KIO::AuthInfo)));
63 QDBusReply<qlonglong> reply = m_interface->checkAuthInfoAsync(info, windowId,
65 if (!reply.isValid()) {
66 if (reply.error().type() == QDBusError::UnknownMethod) {
67 if (legacyCheckAuthInfo(info, windowId, usertime)) {
72 kWarning(7019) <<
"Can't communicate with kded_kpasswdserver (for checkAuthInfo)!";
73 kDebug(7019) << reply.error().name() << reply.error().message();
78 kWarning(7019) <<
"kded_kpasswdserver died while waiting for reply!";
83 kDebug(7019) <<
"username=" << info.
username <<
"password=[hidden]";
91bool KPasswdServer::legacyCheckAuthInfo(
KIO::AuthInfo &info, qlonglong windowId,
94 kWarning(7019) <<
"Querying old kded_kpasswdserver.";
97 QDataStream stream(¶ms, QIODevice::WriteOnly);
99 QDBusReply<QByteArray> reply = m_interface->checkAuthInfo(params, windowId,
101 if (reply.isValid()) {
103 QDataStream stream2(reply.value());
104 stream2 >> authResult;
114 qlonglong windowId, qlonglong seqNr,
117 kDebug(7019) <<
"window-id=" << windowId;
120 if (!QCoreApplication::instance()) {
121 kWarning(7019) <<
"kioslave is not a QCoreApplication!";
122 return legacyQueryAuthInfo(info, errorMsg, windowId, seqNr, usertime);
127 QObject::connect(m_interface, SIGNAL(queryAuthInfoAsyncResult(qlonglong,qlonglong,
KIO::AuthInfo)),
128 &loop, SLOT(slotQueryResult(qlonglong,qlonglong,
KIO::AuthInfo)));
130 QDBusReply<qlonglong> reply = m_interface->queryAuthInfoAsync(info, errorMsg,
133 if (!reply.isValid()) {
135 if (reply.error().type() == QDBusError::UnknownMethod) {
136 qlonglong res = legacyQueryAuthInfo(info, errorMsg, windowId, seqNr,
143 kWarning(7019) <<
"Can't communicate with kded_kpasswdserver (for queryAuthInfo)!";
144 kDebug(7019) << reply.error().name() << reply.error().message();
149 kWarning(7019) <<
"kded_kpasswdserver died while waiting for reply!";
155 kDebug(7019) <<
"username=" << info.
username <<
"password=[hidden]";
160qlonglong KPasswdServer::legacyQueryAuthInfo(
KIO::AuthInfo &info,
const QString &errorMsg,
161 qlonglong windowId, qlonglong seqNr,
164 kWarning(7019) <<
"Querying old kded_kpasswdserver.";
167 QDataStream stream(¶ms, QIODevice::WriteOnly);
169 QDBusPendingReply<QByteArray, qlonglong> reply = m_interface->queryAuthInfo(params, errorMsg,
172 reply.waitForFinished();
173 if (reply.isValid()) {
175 QDataStream stream2(reply.argumentAt<0>());
176 stream2 >> authResult;
180 return reply.argumentAt<1>();
187 QDBusReply<void> reply = m_interface->addAuthInfo(info, windowId);
188 if (!reply.isValid() && reply.error().type() == QDBusError::UnknownMethod) {
189 legacyAddAuthInfo(info, windowId);
193void KPasswdServer::legacyAddAuthInfo(
const KIO::AuthInfo &info, qlonglong windowId)
195 kWarning(7019) <<
"Querying old kded_kpasswdserver.";
198 QDataStream stream(¶ms, QIODevice::WriteOnly);
200 m_interface->addAuthInfo(params, windowId);
206 m_interface->removeAuthInfo(host, protocol, user);
This class is intended to make it easier to prompt for, cache and retrieve authorization information.
bool isModified() const
Use this method to check if the object was modified.
KUrl url
The URL for which authentication is to be stored.
QString username
This is required for caching.
bool waitForResult(qlonglong requestId)
const AuthInfo & authInfo() const
bool checkAuthInfo(KIO::AuthInfo &info, qlonglong windowId, qlonglong usertime)
Check if kpasswdserver has cached authentication information regarding an AuthInfo object.
void removeAuthInfo(const QString &host, const QString &protocol, const QString &user)
Manually remove authentication information from kpasswdserver's cache.
void addAuthInfo(const KIO::AuthInfo &info, qlonglong windowId)
Manually add authentication information to kpasswdserver's cache.
qlonglong queryAuthInfo(KIO::AuthInfo &info, const QString &errorMsg, qlonglong windowId, qlonglong seqNr, qlonglong usertime)
Let kpasswdserver ask the user for authentication information.
A namespace for KIO globals.