summaryrefslogtreecommitdiff
path: root/noncore/unsupported/mail2/libmail/imapbase.cpp
Unidiff
Diffstat (limited to 'noncore/unsupported/mail2/libmail/imapbase.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/unsupported/mail2/libmail/imapbase.cpp36
1 files changed, 29 insertions, 7 deletions
diff --git a/noncore/unsupported/mail2/libmail/imapbase.cpp b/noncore/unsupported/mail2/libmail/imapbase.cpp
index 9a2ba47..4753f43 100644
--- a/noncore/unsupported/mail2/libmail/imapbase.cpp
+++ b/noncore/unsupported/mail2/libmail/imapbase.cpp
@@ -50,16 +50,20 @@ void IMAPBase::writeCommands()
50 if (!_writingAllowed) return; 50 if (!_writingAllowed) return;
51 51
52 QStringList::Iterator it; 52 QStringList::Iterator it;
53 for (it = _commandQueue.begin(); it != _commandQueue.end(); it++) { 53 for (it = _commandQueue.begin(); it != _commandQueue.end(); it++) {
54 if (!(*it).isEmpty() && _writingAllowed) { 54 if (!(*it).isEmpty() && _writingAllowed) {
55#ifndef QT_NO_DEBUG 55#ifndef QT_NO_DEBUG
56 qDebug("IMAP > " + (*it).stripWhiteSpace()); 56 qDebug("IMAP > " + (*it).stripWhiteSpace().local8Bit ());
57#endif 57#endif
58 _socket->writeBlock((*it).latin1(), (*it).length()); 58 _socket->writeBlock((*it).latin1(), (*it).length());
59 _writingAllowed = false; 59 _writingAllowed = false;
60 if (( *it ). find ( QRegExp ( "^[a-z][0-9]+ " )) == 0 )
61 _lasttag = (*it).left(2);
62
63 connect(_socket, SIGNAL(readyRead()), SLOT(slotDataAvailiable()));
60 _commandQueue.remove(it); 64 _commandQueue.remove(it);
61 break; 65 break;
62 } 66 }
63 } 67 }
64} 68}
65 69
@@ -90,21 +94,39 @@ void IMAPBase::slotConnected()
90void IMAPBase::slotDisconnected() 94void IMAPBase::slotDisconnected()
91{ 95{
92 _connected = false; 96 _connected = false;
93 emit disconnected(); 97 emit disconnected();
94} 98}
95 99
100#include <unistd.h>
101
96void IMAPBase::slotDataAvailiable() 102void IMAPBase::slotDataAvailiable()
97{ 103{
104 static bool firstline = true;
105
98 while (_socket->canReadLine()) { 106 while (_socket->canReadLine()) {
99 _data += _socket->readLine(); 107 QString tmp = _socket-> readLine ( );
100 if (_socket->atEnd()) { 108
101#ifndef QT_NO_DEBUG 109 _data += tmp;
102 qDebug("IMAP < " + _data.stripWhiteSpace()); 110 qDebug ( "New Line [%d]: '%s'\n", _connected ? 1 : 0, tmp.latin1( ));
103#endif 111
112 if ( firstline || tmp. left(2) == _lasttag ) {
113 firstline = false;
114
115 // if ( _socket-> atEnd ( ))
116 qDebug ( "at end -> emitting\n" );
117
118 QObject::disconnect(_socket, SIGNAL(readyRead()), this, SLOT(slotDataAvailiable()));
104 emit dataReceived(_data); 119 emit dataReceived(_data);
120 _data = QString::null;
105 _writingAllowed = true; 121 _writingAllowed = true;
106 _data = QString(0);
107 } 122 }
108 } 123 }
109} 124}
110 125
126void IMAPBase::tryRead ( QString &data )
127{
128 qDebug ( "Trying to read...\n" );
129
130 while ( _socket-> canReadLine ( ))
131 data += _socket-> readLine ( );
132}