Commit ac6296aa authored by Christian Mollekopf's avatar Christian Mollekopf Committed by Sandro Knauß

Report the client id using the ID command.

parent b4b12c4e
......@@ -41,6 +41,7 @@ ImapResource::ImapResource(const QString &id)
{
m_pool->setPasswordRequester(new SettingsPasswordRequester(this, m_pool));
m_pool->setSessionUiProxy(SessionUiProxy::Ptr(new SessionUiProxy));
m_pool->setClientId(clientId());
}
ImapResource::~ImapResource()
......@@ -52,6 +53,11 @@ QString ImapResource::defaultName() const
return i18n("IMAP Account");
}
QByteArray ImapResource::clientId() const
{
return "Kontact IMAP Resource";
}
QDialog *ImapResource::createConfigureDialog(WId windowId)
{
SetupServer *dlg = new SetupServer(this, windowId);
......
......@@ -42,6 +42,7 @@ public:
protected:
QString defaultName() const Q_DECL_OVERRIDE;
QByteArray clientId() const Q_DECL_OVERRIDE;
private Q_SLOTS:
void onConfigurationDone(int result);
......
......@@ -116,6 +116,7 @@ protected:
virtual ResourceStateInterface::Ptr createResourceState(const TaskArguments &);
virtual QString defaultName() const = 0;
virtual QByteArray clientId() const = 0;
protected Q_SLOTS:
void delayedInit();
......
......@@ -30,6 +30,7 @@
#include <kimap/capabilitiesjob.h>
#include <kimap/logoutjob.h>
#include <kimap/namespacejob.h>
#include <kimap/idjob.h>
#include "imapaccount.h"
#include "passwordrequesterinterface.h"
......@@ -474,11 +475,22 @@ void SessionPool::onCapabilitiesTestDone(KJob *job)
QObject::connect(nsJob, &KIMAP::NamespaceJob::result, this, &SessionPool::onNamespacesTestDone);
nsJob->start();
return;
} else if (m_capabilities.contains(QLatin1String("ID"))) {
KIMAP::IdJob *idJob = new KIMAP::IdJob(capJob->session());
idJob->setField("name", m_clientId);
QObject::connect(idJob, &KIMAP::IdJob::result, this, &SessionPool::onIdDone);
idJob->start();
return;
} else {
declareSessionReady(capJob->session());
}
}
void SessionPool::setClientId( const QByteArray &clientId )
{
m_clientId = clientId;
}
void SessionPool::onNamespacesTestDone(KJob *job)
{
KIMAP::NamespaceJob *nsJob = qobject_cast<KIMAP::NamespaceJob *>(job);
......@@ -504,7 +516,26 @@ void SessionPool::onNamespacesTestDone(KJob *job)
nsJob->sharedNamespaces();
}
declareSessionReady(nsJob->session());
if (m_capabilities.contains(QStringLiteral("ID"))) {
KIMAP::IdJob *idJob = new KIMAP::IdJob(nsJob->session());
idJob->setField("name", m_clientId);
QObject::connect(idJob, &KIMAP::IdJob::result, this, &SessionPool::onIdDone);
idJob->start();
return;
} else {
declareSessionReady(nsJob->session());
}
}
void SessionPool::onIdDone( KJob *job )
{
KIMAP::IdJob *idJob = qobject_cast<KIMAP::IdJob*>(job);
//Can happen if we disonnected meanwhile
if (!m_connectingPool.contains(idJob->session())) {
emit connectDone(CancelledError, i18n("Disconnected during login."));
return;
}
declareSessionReady(idJob->session());
}
void SessionPool::onSessionStateChanged(KIMAP::Session::State newState, KIMAP::Session::State oldState)
......
......@@ -71,6 +71,8 @@ public:
KIMAP::SessionUiProxy::Ptr sessionUiProxy() const;
void setSessionUiProxy(KIMAP::SessionUiProxy::Ptr proxy);
void setClientId(const QByteArray &clientId);
bool isConnected() const;
bool connect(ImapAccount *account);
void disconnect(SessionTermination termination = LogoutSession);
......@@ -104,6 +106,7 @@ private Q_SLOTS:
void onLoginDone(KJob *job);
void onCapabilitiesTestDone(KJob *job);
void onNamespacesTestDone(KJob *job);
void onIdDone(KJob *job);
void onSessionStateChanged(KIMAP::Session::State newState, KIMAP::Session::State oldState);
void onSessionDestroyed(QObject *);
......@@ -134,6 +137,7 @@ private:
QList<KIMAP::MailBoxDescriptor> m_personalNamespaces;
QList<KIMAP::MailBoxDescriptor> m_userNamespaces;
QList<KIMAP::MailBoxDescriptor> m_sharedNamespaces;
QByteArray m_clientId;
};
#endif
......@@ -82,6 +82,11 @@ QString KolabResource::defaultName() const
return i18n("Kolab Resource");
}
QByteArray KolabResource::clientId() const
{
return "Kontact Kolab Resource 5/KOLAB";
}
QDialog *KolabResource::createConfigureDialog(WId windowId)
{
SetupServer *dlg = new SetupServer(this, windowId);
......
......@@ -63,6 +63,7 @@ protected:
const Akonadi::Relation::List &removedRelations) Q_DECL_OVERRIDE;
QString defaultName() const Q_DECL_OVERRIDE;
QByteArray clientId() const Q_DECL_OVERRIDE;
private Q_SLOTS:
void retrieveTags();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment