00001
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 "imaplist.h"
00043 #include "imapparser.h"
00044
00045 #include <kimap/rfccodecs.h>
00046
00047 #include <kdebug.h>
00048
00049 imapList::imapList (): parser_(0), noInferiors_ (false),
00050 noSelect_ (false), marked_ (false), unmarked_ (false),
00051 hasChildren_ (false), hasNoChildren_ (false)
00052 {
00053 }
00054
00055 imapList::imapList (const imapList & lr):parser_(lr.parser_),
00056 hierarchyDelimiter_ (lr.hierarchyDelimiter_),
00057 name_ (lr.name_),
00058 noInferiors_ (lr.noInferiors_),
00059 noSelect_ (lr.noSelect_), marked_ (lr.marked_), unmarked_ (lr.unmarked_),
00060 hasChildren_ (lr.hasChildren_), hasNoChildren_ (lr.hasNoChildren_),
00061 attributes_ (lr.attributes_)
00062 {
00063 }
00064
00065 imapList & imapList::operator = (const imapList & lr)
00066 {
00067
00068 if (this == &lr)
00069 return *this;
00070
00071 parser_ = lr.parser_;
00072 hierarchyDelimiter_ = lr.hierarchyDelimiter_;
00073 name_ = lr.name_;
00074 noInferiors_ = lr.noInferiors_;
00075 noSelect_ = lr.noSelect_;
00076 marked_ = lr.marked_;
00077 unmarked_ = lr.unmarked_;
00078 hasChildren_ = lr.hasChildren_;
00079 hasNoChildren_ = lr.hasNoChildren_;
00080 attributes_ = lr.attributes_;
00081
00082 return *this;
00083 }
00084
00085 imapList::imapList (const QString & inStr, imapParser &parser)
00086 : parser_(&parser),
00087 noInferiors_ (false),
00088 noSelect_ (false),
00089 marked_ (false), unmarked_ (false), hasChildren_ (false),
00090 hasNoChildren_ (false)
00091 {
00092 parseString s;
00093 s.data = inStr.toLatin1();
00094
00095 if (s[0] != '(')
00096 return;
00097
00098 s.pos++;
00099
00100 parseAttributes( s );
00101
00102 s.pos++;
00103 parser_->skipWS (s);
00104
00105 hierarchyDelimiter_ = QString::fromLatin1 (parser_->parseOneWord(s));
00106 if (hierarchyDelimiter_ == "NIL")
00107 hierarchyDelimiter_.clear();
00108 name_ = QString::fromUtf8 (KIMAP::decodeImapFolderName (parser_->parseLiteral (s)));
00109 }
00110
00111 void imapList::parseAttributes( parseString & str )
00112 {
00113
00114 while ( !str.isEmpty () && str[0] != ')' )
00115 {
00116 QString orig = QString::fromLatin1( parser_->parseOneWord(str) );
00117 attributes_ << orig;
00118 QString attribute = orig.toLower();
00119 if ( attribute.contains ("\\noinferiors"))
00120 noInferiors_ = true;
00121 else if ( attribute.contains ("\\noselect"))
00122 noSelect_ = true;
00123 else if ( attribute.contains ("\\marked"))
00124 marked_ = true;
00125 else if ( attribute.contains ("\\unmarked"))
00126 unmarked_ = true;
00127 else if ( attribute.contains ("\\haschildren"))
00128 hasChildren_ = true;
00129 else if ( attribute.contains ("\\hasnochildren"))
00130 hasNoChildren_ = true;
00131 else
00132 kDebug(7116) <<"imapList::imapList: bogus attribute" << attribute;
00133 }
00134 }
00135