summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/mail2/libmail/imaphandler.cpp9
-rw-r--r--noncore/unsupported/mail2/libmail/imaphandler.h2
2 files changed, 10 insertions, 1 deletions
diff --git a/noncore/unsupported/mail2/libmail/imaphandler.cpp b/noncore/unsupported/mail2/libmail/imaphandler.cpp
index 66c92c5..730a004 100644
--- a/noncore/unsupported/mail2/libmail/imaphandler.cpp
+++ b/noncore/unsupported/mail2/libmail/imaphandler.cpp
@@ -1,31 +1,32 @@
#include "imapresponse.h"
#include "imaphandler.h"
#include "imapbase.h"
IMAPHandler::IMAPHandler(const Account &account)
: QObject(), _account(account)
{
+ _ready = false;
_loggingin = false;
_loggedin = false;
_tag = 0;
_ibase = new IMAPBase(account);
connect(_ibase, SIGNAL(dataReceived(const QString &)), SLOT(slotDataReceived(const QString &)));
connect(_ibase, SIGNAL(lookingUpHost()), SLOT(slotLookingUpHost()));
connect(_ibase, SIGNAL(hostFound()), SLOT(slotHostFound()));
connect(_ibase, SIGNAL(connected()), SLOT(slotConnected()));
connect(_ibase, SIGNAL(disconnected()), SLOT(slotDisconnected()));
connect(_ibase, SIGNAL(error(int)), SLOT(slotError(int)));
}
void IMAPHandler::doLogin()
{
if (_loggedin) return;
if (_loggingin) return;
_loggingin = true;
iLogin(_account.user(), _account.pass());
}
QString IMAPHandler::iCapability()
{
@@ -268,48 +269,56 @@ QString IMAPHandler::iUid(const QString &command, const QString &arguments)
QString IMAPHandler::iX(const QString &commandAtom, const QString &arguments)
{
doLogin();
_ibase->sendCommand(QString("%1 X%2 %3\r\n")
.arg(tag())
.arg(commandAtom)
.arg(arguments));
return tag(false);
}
QString IMAPHandler::escape(const QString &in)
{
QString in_ = in;
return in_.replace(QRegExp("\""), "\\\"");
}
QString IMAPHandler::tag(bool count)
{
return QString("a%1").arg(count ? _tag++ : _tag);
}
void IMAPHandler::slotDataReceived(const QString &data)
{
+ if (!_ready) {
+ // The first data is always the greeting string.
+ // We can ignore it.
+ _ready = true;
+ return;
+ }
+
+
IMAPResponseParser parser(data);
IMAPResponse response = parser.response();
response.setImapHandler(this);
if (!_loggingin) emit gotResponse(response);
else {
if (response.statusResponse().status() == IMAPResponseEnums::OK) {
_loggingin = false;
_loggedin = true;
qWarning("OK. Logged in. Leaving loggingin state.");
} else {
_loggingin = false;
emit IMAPError(IMAPBase::IMAPErrLoginFailed);
}
}
}
void IMAPHandler::slotLookingUpHost()
{
emit IMAPLookingUpHost();
}
void IMAPHandler::slotHostFound()
{
diff --git a/noncore/unsupported/mail2/libmail/imaphandler.h b/noncore/unsupported/mail2/libmail/imaphandler.h
index 8cb42db..cc47a85 100644
--- a/noncore/unsupported/mail2/libmail/imaphandler.h
+++ b/noncore/unsupported/mail2/libmail/imaphandler.h
@@ -58,29 +58,29 @@ signals:
void IMAPLookingUpHost();
void IMAPHostFound();
void IMAPConnected();
void IMAPDisconnected();
void IMAPError(int err);
protected:
void doLogin();
QString escape(const QString &in);
QString tag(bool count = true);
protected slots:
void slotDataReceived(const QString &data);
void slotLookingUpHost();
void slotHostFound();
void slotConnected();
void slotDisconnected();
void slotError(int err);
private:
Account _account;
IMAPBase *_ibase;
unsigned int _tag;
- bool _loggingin, _loggedin;
+ bool _ready, _loggingin, _loggedin;
};
#endif