43 #include "imapparser.h"
47 imapInfo::imapInfo ():count_ (0),
55 countAvailable_ (false),
56 recentAvailable_ (false),
57 unseenAvailable_ (false),
58 uidValidityAvailable_ (false),
59 uidNextAvailable_ (false),
60 flagsAvailable_ (false),
61 permanentFlagsAvailable_ (false), readWriteAvailable_ (false)
65 imapInfo::imapInfo (
const imapInfo & mi):count_ (mi.count_),
68 uidValidity_ (mi.uidValidity_),
69 uidNext_ (mi.uidNext_),
71 permanentFlags_ (mi.permanentFlags_),
72 readWrite_ (mi.readWrite_),
73 countAvailable_ (mi.countAvailable_),
74 recentAvailable_ (mi.recentAvailable_),
75 unseenAvailable_ (mi.unseenAvailable_),
76 uidValidityAvailable_ (mi.uidValidityAvailable_),
77 uidNextAvailable_ (mi.uidNextAvailable_),
78 flagsAvailable_ (mi.flagsAvailable_),
79 permanentFlagsAvailable_ (mi.permanentFlagsAvailable_),
80 readWriteAvailable_ (mi.readWriteAvailable_)
84 imapInfo & imapInfo::operator = (
const imapInfo & mi)
93 uidValidity_ = mi.uidValidity_;
94 uidNext_ = mi.uidNext_;
96 permanentFlags_ = mi.permanentFlags_;
97 readWrite_ = mi.readWrite_;
98 countAvailable_ = mi.countAvailable_;
99 recentAvailable_ = mi.recentAvailable_;
100 unseenAvailable_ = mi.unseenAvailable_;
101 uidValidityAvailable_ = mi.uidValidityAvailable_;
102 uidNextAvailable_ = mi.uidNextAvailable_;
103 flagsAvailable_ = mi.flagsAvailable_;
104 permanentFlagsAvailable_ = mi.permanentFlagsAvailable_;
105 readWriteAvailable_ = mi.readWriteAvailable_;
110 imapInfo::imapInfo (
const TQStringList & list):count_ (0),
118 countAvailable_ (false),
119 recentAvailable_ (false),
120 unseenAvailable_ (false),
121 uidValidityAvailable_ (false),
122 uidNextAvailable_ (false),
123 flagsAvailable_ (false),
124 permanentFlagsAvailable_ (false), readWriteAvailable_ (false)
126 for (TQStringList::ConstIterator it (list.begin ()); it != list.end (); ++it)
130 line.truncate(line.length() - 2);
131 TQStringList tokens(TQStringList::split (
' ', line));
133 kdDebug(7116) <<
"Processing: " << line << endl;
134 if (tokens[0] !=
"*")
137 if (tokens[1] ==
"OK")
139 if (tokens[2] ==
"[UNSEEN")
140 setUnseen (tokens[3].left (tokens[3].length () - 1).toULong ());
142 else if (tokens[2] ==
"[UIDVALIDITY")
143 setUidValidity (tokens[3].left (tokens[3].length () - 1).toULong ());
145 else if (tokens[2] ==
"[UIDNEXT")
146 setUidNext (tokens[3].left (tokens[3].length () - 1).toULong ());
148 else if (tokens[2] ==
"[PERMANENTFLAGS")
150 int flagsStart = line.find(
'(');
151 int flagsEnd = line.find(
')');
153 kdDebug(7116) <<
"Checking permFlags from " << flagsStart <<
" to " << flagsEnd << endl;
154 if ((-1 != flagsStart) && (-1 != flagsEnd) && flagsStart < flagsEnd)
155 setPermanentFlags (_flags (line.mid (flagsStart, flagsEnd).latin1()));
158 else if (tokens[2] ==
"[READ-WRITE")
162 else if (tokens[2] ==
"[READ-ONLY")
164 setReadWrite (
false);
168 kdDebug(7116) <<
"unknown token2: " << tokens[2] << endl;
171 else if (tokens[1] ==
"FLAGS")
173 int flagsStart = line.find (
'(');
174 int flagsEnd = line.find (
')');
176 if ((-1 != flagsStart) && (-1 != flagsEnd) && flagsStart < flagsEnd)
177 setFlags (_flags (line.mid (flagsStart, flagsEnd).latin1() ));
181 if (tokens[2] ==
"EXISTS")
182 setCount (tokens[1].toULong ());
184 else if (tokens[2] ==
"RECENT")
185 setRecent (tokens[1].toULong ());
188 kdDebug(7116) <<
"unknown token1/2: " << tokens[1] <<
" " << tokens[2] << endl;
194 ulong imapInfo::_flags (
const TQCString & inFlags)
198 flagsString.data.duplicate(inFlags.data(), inFlags.length());
199 if ( flagsString.isEmpty() ) {
203 if (flagsString[0] ==
'(')
206 while (!flagsString.isEmpty () && flagsString[0] !=
')')
208 TQCString entry = imapParser::parseOneWordC(flagsString).upper();
210 if (entry.isEmpty ())
212 else if (0 != entry.contains (
"\\SEEN"))
214 else if (0 != entry.contains (
"\\ANSWERED"))
216 else if (0 != entry.contains (
"\\FLAGGED"))
218 else if (0 != entry.contains (
"\\DELETED"))
220 else if (0 != entry.contains (
"\\DRAFT"))
222 else if (0 != entry.contains (
"\\RECENT"))
224 else if (0 != entry.contains (
"\\*"))
228 else if ( entry.contains(
"KMAILFORWARDED" ) || entry.contains(
"$FORWARDED" ) )
229 flags = flags | Forwarded;
230 else if ( entry.contains(
"KMAILTODO" ) || entry.contains(
"$TODO" ) )
231 flags = flags | Todo;
232 else if ( entry.contains(
"KMAILWATCHED" ) || entry.contains(
"$WATCHED" ) )
233 flags = flags | Watched;
234 else if ( entry.contains(
"KMAILIGNORED" ) || entry.contains(
"$IGNORED" ) )
235 flags = flags | Ignored;
a string used during parsing the string allows you to move the effective start of the string using st...