Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:EKrava
kdepim3
kdepim3-gentoo-fix-imap4.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File kdepim3-gentoo-fix-imap4.patch of Package kdepim3
--- a/kioslaves/imap4/imap4.cc +++ b/kioslaves/imap4/imap4.cc @@ -167,9 +167,7 @@ { outputBufferIndex = 0; mySSL = isSSL; - readBuffer[0] = 0x00; relayEnabled = false; - readBufferLen = 0; cacheOutput = false; decodeContent = false; mTimeOfLastNoop = QDateTime(); @@ -702,66 +700,60 @@ bool IMAP4Protocol::parseReadLine (QByteArray & buffer, ulong relay) { - if (myHost.isEmpty()) return FALSE; - - while (true) { - ssize_t copyLen = 0; - if (readBufferLen > 0) - { - while (copyLen < readBufferLen && readBuffer[copyLen] != '\n') copyLen++; - if (copyLen < readBufferLen) copyLen++; - if (relay > 0) - { - QByteArray relayData; - - if (copyLen < (ssize_t) relay) - relay = copyLen; - relayData.setRawData (readBuffer, relay); - parseRelay (relayData); - relayData.resetRawData (readBuffer, relay); -// kdDebug(7116) << "relayed : " << relay << "d" << endl; - } - // append to buffer - { - QBuffer stream (buffer); - - stream.open (IO_WriteOnly); - stream.at (buffer.size ()); - stream.writeBlock (readBuffer, copyLen); - stream.close (); -// kdDebug(7116) << "appended " << copyLen << "d got now " << buffer.size() << endl; - } - - readBufferLen -= copyLen; - if (readBufferLen) - memmove(readBuffer, &readBuffer[copyLen], readBufferLen); - if (buffer[buffer.size() - 1] == '\n') return TRUE; - } + // FIXME (Serghei): i'm not sure about role of "relay" + + if(myHost.isEmpty()) + return false; + + // default error + int errorStatus = ERR_CONNECTION_BROKEN; + + // open buffer stream + QBuffer stream(buffer); + stream.open(IO_WriteOnly); + stream.at(buffer.size()); + + for (;;) + { if (!isConnectionValid()) { kdDebug(7116) << "parseReadLine - connection broken" << endl; - error (ERR_CONNECTION_BROKEN, myHost); - setState(ISTATE_CONNECT); - closeConnection(); - return FALSE; - } - if (!waitForResponse( responseTimeout() )) - { - error(ERR_SERVER_TIMEOUT, myHost); - setState(ISTATE_CONNECT); - closeConnection(); - return FALSE; - } - readBufferLen = read(readBuffer, IMAP_BUFFER - 1); - if (readBufferLen == 0) - { - kdDebug(7116) << "parseReadLine: readBufferLen == 0 - connection broken" << endl; - error (ERR_CONNECTION_BROKEN, myHost); - setState(ISTATE_CONNECT); - closeConnection(); - return FALSE; - } - } + break; + } + + if (!waitForResponse(responseTimeout())) + { + kdDebug(7116) << "parseReadLine - connection timeout" << endl; + errorStatus = ERR_SERVER_TIMEOUT; + break; + } + + char buf[4096]; + int len = readLine(buf, sizeof(buf)); + + if (0 >= len) + { + kdDebug(7116) << "parseReadLine - read line error" << endl; + break; + } + + stream.writeBlock(buf, len); + + // len is always bigger than zero, + // is safe to substract it by 1 + if ('\n' == buf[len - 1]) + { + stream.close(); + return true; + } + } + + // error + stream.close(); + error(errorStatus, myHost); + setState(ISTATE_CONNECT); + closeConnection(); + return false; } void @@ -2008,7 +2000,6 @@ sentQueue.clear(); lastHandled = 0; currentBox = QString::null; - readBufferLen = 0; } bool IMAP4Protocol::makeLogin () @@ -2640,16 +2631,12 @@ ssize_t IMAP4Protocol::myRead(void *data, ssize_t len) { - if (readBufferLen) - { - ssize_t copyLen = (len < readBufferLen) ? len : readBufferLen; - memcpy(data, readBuffer, copyLen); - readBufferLen -= copyLen; - if (readBufferLen) memcpy(readBuffer, &readBuffer[copyLen], readBufferLen); - return copyLen; - } - if (!isConnectionValid()) return 0; - waitForResponse( responseTimeout() ); + if (!isConnectionValid()) + return 0; + + if (!waitForResponse(responseTimeout())) + return 0; + return read(data, len); }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor