27 #include <tqstringlist.h>
28 #include <tqvaluelist.h>
29 #include <tqptrlist.h>
30 #include <tqasciidict.h>
32 #include <tdeio/authinfo.h>
33 #include <tdeio/slavebase.h>
36 #include "imapcommand.h"
39 #include "mailheader.h"
56 char operator[](uint i)
const {
return data[i + pos]; }
57 bool isEmpty()
const {
return pos >= data.size(); }
58 TQCString cstr()
const
60 if (pos >= data.size())
return TQCString();
61 return TQCString(data.data() + pos, data.size() - pos + 1);
63 int find(
char c,
int index = 0)
65 int res = data.find(c, index + pos);
66 return (res == -1) ? res : (res - pos);
69 void takeLeft(TQCString& dest, uint len)
const
72 tqmemmove(dest.data(), data.data() + pos, len);
75 void takeLeftNoResize(TQCString& dest, uint len)
const
77 tqmemmove(dest.data(), data.data() + pos, len);
80 void takeMid(TQCString& dest, uint start, uint len)
const
83 tqmemmove(dest.data(), data.data() + pos + start, len);
86 void takeMidNoResize(TQCString& dest, uint start, uint len)
const
88 tqmemmove(dest.data(), data.data() + pos + start, len);
97 if( pos < data.size() ) {
98 return data.size() - pos;
103 void fromString(
const TQString &s)
106 data.duplicate(s.latin1(), s.length());
125 if (myHeader)
delete myHeader;
141 void setSize (ulong inSize)
150 void setUid (ulong inUid)
159 void setFlags (ulong inFlags)
168 void setDate (
const TQCString & _str)
174 if (myHeader)
delete myHeader;
178 myDate = TQCString();
207 virtual ~ imapParser ();
210 enum IMAP_STATE getState () {
return currentState; }
212 void setState(
enum IMAP_STATE state) { currentState = state; }
215 const TQString getCurrentBox ()
241 bool clientLogin (
const TQString & aUser,
const TQString & aPass, TQString & resultInfo);
251 bool clientAuthenticate (TDEIO::SlaveBase *slave, TDEIO::AuthInfo &ai,
const TQString & aFTQDN,
252 const TQString & aAuth,
bool isSSL, TQString & resultInfo);
267 void parseRecent (ulong value,
parseString & result);
269 void parseResult (TQByteArray & result,
parseString & rest,
270 const TQString & command = TQString());
288 void parseExists (ulong value,
parseString & result);
290 void parseExpunge (ulong value,
parseString & result);
314 void parseFetch (ulong value,
parseString & inWords);
319 void parseAddressList (
parseString & inWords, TQPtrList<mailAddress>& list);
321 const mailAddress& parseAddress (
parseString & inWords, mailAddress& buffer);
328 TQString & section,
mimeHeader * inHeader = 0);
335 TQAsciiDict < TQString > parseParameters (
parseString & inWords);
341 TQAsciiDict < TQString > parseDisposition (
parseString & inWords);
346 virtual void parseRelay (
const TQByteArray & buffer);
350 virtual void parseRelay (ulong);
353 virtual bool parseRead (TQByteArray & buffer, ulong len, ulong relay = 0);
356 virtual bool parseReadLine (TQByteArray & buffer, ulong relay = 0);
359 virtual void parseWriteLine (
const TQString &);
367 TQCString parseLiteralC(
parseString & inWords,
bool relay =
false,
368 bool stopAtBracket =
false,
int *outlen = 0);
369 inline TQByteArray parseLiteral (
parseString & inWords,
bool relay =
false,
370 bool stopAtBracket =
false) {
374 TQCString tmp = parseLiteralC(inWords, relay, stopAtBracket, &len);
375 return TQByteArray().duplicate(tmp.data(), len);
380 static TQCString b2c(
const TQByteArray &ba)
381 {
return TQCString(ba.data(), ba.size() + 1); }
384 static TQCString parseOneWordC (
parseString & inWords,
385 bool stopAtBracket = FALSE,
int *len = 0);
388 static bool parseOneNumber (
parseString & inWords, ulong & num);
391 static void parseURL (
const KURL & _url, TQString & _box, TQString & _section,
392 TQString & _type, TQString & _uid, TQString & _validity,
399 imapCache *getLastHandled ()
405 const TQStringList & getResults ()
411 const imapInfo & geStatus ()
416 const imapInfo & getSelected ()
421 const TQByteArray & getContinuation ()
427 bool hasCapability (
const TQString &);
429 void removeCapability (
const TQString & cap);
434 while (!inWords.isEmpty() &&
435 ((c = inWords[0]) ==
' ' || c ==
'\t' || c ==
'\r' || c ==
'\n'))
442 TQString namespaceForBox(
const TQString & box );
448 enum IMAP_STATE currentState;
460 TQStringList imapCapabilities;
463 TQValueList < imapList > listResponses;
466 TQPtrList < imapCommand > sentQueue;
467 TQPtrList < imapCommand > completeQueue;
472 TQStringList unhandled;
475 TQByteArray continuation;
479 imapCache *lastHandled;
481 ulong commandCounter;
484 TQStringList lastResults;
490 TQMap<TQString, TQString> namespaceToDelimiter;
496 TQStringList imapNamespaces;
501 imapParser & operator = (
const imapParser &);
encapulate a IMAP command
a string used during parsing the string allows you to move the effective start of the string using st...
static TQString fromIMAP(const TQString &src)
Convert an IMAP mailbox to a Unicode path.