kioslaves/imap4
imaplist.cc00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include "rfcdecoder.h"
00043 #include "imaplist.h"
00044 #include "imapparser.h"
00045
00046 #include <kdebug.h>
00047
00048 imapList::imapList ():noInferiors_ (false),
00049 noSelect_ (false), marked_ (false), unmarked_ (false),
00050 hasChildren_ (false), hasNoChildren_ (false)
00051 {
00052 }
00053
00054 imapList::imapList (const imapList & lr):hierarchyDelimiter_ (lr.hierarchyDelimiter_),
00055 name_ (lr.name_),
00056 noInferiors_ (lr.noInferiors_),
00057 noSelect_ (lr.noSelect_), marked_ (lr.marked_), unmarked_ (lr.unmarked_),
00058 hasChildren_ (lr.hasChildren_), hasNoChildren_ (lr.hasNoChildren_),
00059 attributes_ (lr.attributes_)
00060 {
00061 }
00062
00063 imapList & imapList::operator = (const imapList & lr)
00064 {
00065
00066 if (this == &lr)
00067 return *this;
00068
00069 hierarchyDelimiter_ = lr.hierarchyDelimiter_;
00070 name_ = lr.name_;
00071 noInferiors_ = lr.noInferiors_;
00072 noSelect_ = lr.noSelect_;
00073 marked_ = lr.marked_;
00074 unmarked_ = lr.unmarked_;
00075 hasChildren_ = lr.hasChildren_;
00076 hasNoChildren_ = lr.hasNoChildren_;
00077 attributes_ = lr.attributes_;
00078
00079 return *this;
00080 }
00081
00082 imapList::imapList (const QString & inStr):noInferiors_ (false),
00083 noSelect_ (false),
00084 marked_ (false), unmarked_ (false), hasChildren_ (false),
00085 hasNoChildren_ (false)
00086 {
00087 parseString s;
00088 s.data.duplicate(inStr.latin1(), inStr.length());
00089
00090 if (s[0] != '(')
00091 return;
00092
00093 s.pos++;
00094
00095 parseAttributes( s );
00096
00097 s.pos++;
00098 imapParser::skipWS (s);
00099
00100 hierarchyDelimiter_ = imapParser::parseOneWordC(s);
00101 if (hierarchyDelimiter_ == "NIL")
00102 hierarchyDelimiter_ = QString::null;
00103 name_ = rfcDecoder::fromIMAP (imapParser::parseOneWord (s));
00104 }
00105
00106 void imapList::parseAttributes( parseString & str )
00107 {
00108 QCString attribute, orig;
00109
00110 while ( !str.isEmpty () && str[0] != ')' )
00111 {
00112 orig = imapParser::parseOneWordC(str);
00113 attributes_ << orig;
00114 attribute = orig.lower();
00115 if (-1 != attribute.find ("\\noinferiors"))
00116 noInferiors_ = true;
00117 else if (-1 != attribute.find ("\\noselect"))
00118 noSelect_ = true;
00119 else if (-1 != attribute.find ("\\marked"))
00120 marked_ = true;
00121 else if (-1 != attribute.find ("\\unmarked"))
00122 unmarked_ = true;
00123 else if (-1 != attribute.find ("\\haschildren"))
00124 hasChildren_ = true;
00125 else if (-1 != attribute.find ("\\hasnochildren"))
00126 hasNoChildren_ = true;
00127 else
00128 kdDebug(7116) << "imapList::imapList: bogus attribute " << attribute << endl;
00129 }
00130 }
00131
|