tdeioslave/imap4

imaplist.cpp
1/**********************************************************************
2 *
3 * imapinfo.cpp - IMAP4rev1 EXAMINE / SELECT handler
4 * Copyright (C) 2000 Sven Carstens <s.carstens@gmx.de>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 *
20 * Send comments and bug fixes to
21 *
22 *********************************************************************/
23
24/*
25 References:
26 RFC 2060 - Internet Message Access Protocol - Version 4rev1 - December 1996
27 RFC 2192 - IMAP URL Scheme - September 1997
28 RFC 1731 - IMAP Authentication Mechanisms - December 1994
29 (Discusses KERBEROSv4, GSSAPI, and S/Key)
30 RFC 2195 - IMAP/POP AUTHorize Extension for Simple Challenge/Response
31 - September 1997 (CRAM-MD5 authentication method)
32 RFC 2104 - HMAC: Keyed-Hashing for Message Authentication - February 1997
33
34 Supported URLs:
35 imap://server/ - Prompt for user/pass, list all folders in home directory
36 imap://user:pass@server/ - Uses LOGIN to log in
37 imap://user;AUTH=method:pass@server/ - Uses AUTHENTICATE to log in
38
39 imap://server/folder/ - List messages in folder
40 */
41
42#include "rfcdecoder.h"
43#include "imaplist.h"
44#include "imapparser.h"
45
46#include <kdebug.h>
47
48imapList::imapList (): parser_(0), noInferiors_ (false),
49noSelect_ (false), marked_ (false), unmarked_ (false),
50hasChildren_ (false), hasNoChildren_ (false)
51{
52}
53
54imapList::imapList (const imapList & lr):parser_(lr.parser_),
55hierarchyDelimiter_ (lr.hierarchyDelimiter_),
56name_ (lr.name_),
57noInferiors_ (lr.noInferiors_),
58noSelect_ (lr.noSelect_), marked_ (lr.marked_), unmarked_ (lr.unmarked_),
59hasChildren_ (lr.hasChildren_), hasNoChildren_ (lr.hasNoChildren_),
60attributes_ (lr.attributes_)
61{
62}
63
64imapList & imapList::operator = (const imapList & lr)
65{
66 // Avoid a = a.
67 if (this == &lr)
68 return *this;
69
70 parser_ = lr.parser_;
71 hierarchyDelimiter_ = lr.hierarchyDelimiter_;
72 name_ = lr.name_;
73 noInferiors_ = lr.noInferiors_;
74 noSelect_ = lr.noSelect_;
75 marked_ = lr.marked_;
76 unmarked_ = lr.unmarked_;
77 hasChildren_ = lr.hasChildren_;
78 hasNoChildren_ = lr.hasNoChildren_;
79 attributes_ = lr.attributes_;
80
81 return *this;
82}
83
84imapList::imapList (const TQString & inStr, imapParser &parser)
85: parser_(&parser),
86noInferiors_ (false),
87noSelect_ (false),
88marked_ (false), unmarked_ (false), hasChildren_ (false),
89hasNoChildren_ (false)
90{
92 s.data.duplicate(inStr.latin1(), inStr.length());
93
94 if (s[0] != '(')
95 return; //not proper format for us
96
97 s.pos++; // tie off (
98
99 parseAttributes( s );
100
101 s.pos++; // tie off )
102 parser_->skipWS (s);
103
104 hierarchyDelimiter_ = parser_->parseOneWordC(s);
105 if (hierarchyDelimiter_ == "NIL")
106 hierarchyDelimiter_ = TQString();
107 name_ = rfcDecoder::fromIMAP (parser_->parseLiteral (s)); // decode modified UTF7
108}
109
110void imapList::parseAttributes( parseString & str )
111{
112 TQCString attribute, orig;
113
114 while ( !str.isEmpty () && str[0] != ')' )
115 {
116 orig = parser_->parseOneWordC(str);
117 attributes_ << orig;
118 attribute = orig.lower();
119 if (-1 != attribute.find ("\\noinferiors"))
120 noInferiors_ = true;
121 else if (-1 != attribute.find ("\\noselect"))
122 noSelect_ = true;
123 else if (-1 != attribute.find ("\\marked"))
124 marked_ = true;
125 else if (-1 != attribute.find ("\\unmarked"))
126 unmarked_ = true;
127 else if (-1 != attribute.find ("\\haschildren"))
128 hasChildren_ = true;
129 else if (-1 != attribute.find ("\\hasnochildren"))
130 hasNoChildren_ = true;
131 else
132 kdDebug(7116) << "imapList::imapList: bogus attribute " << attribute << endl;
133 }
134}
135
a string used during parsing the string allows you to move the effective start of the string using st...
Definition: imapparser.h:53
static TQString fromIMAP(const TQString &src)
Convert an IMAP mailbox to a Unicode path.
Definition: rfcdecoder.cpp:55