You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
136 lines
4.2 KiB
136 lines
4.2 KiB
15 years ago
|
/**********************************************************************
|
||
|
*
|
||
4 years ago
|
* imapinfo.cpp - IMAP4rev1 EXAMINE / SELECT handler
|
||
17 years ago
|
* Copyright (C) 2000 Sven Carstens <s.carstens@gmx.de>
|
||
15 years ago
|
*
|
||
|
* This program is free software; you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU General Public License as published by
|
||
|
* the Free Software Foundation; either version 2 of the License, or
|
||
|
* (at your option) any later version.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU General Public License
|
||
|
* along with this program; if not, write to the Free Software
|
||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
*
|
||
|
* Send comments and bug fixes to
|
||
|
*
|
||
|
*********************************************************************/
|
||
|
|
||
|
/*
|
||
|
References:
|
||
|
RFC 2060 - Internet Message Access Protocol - Version 4rev1 - December 1996
|
||
|
RFC 2192 - IMAP URL Scheme - September 1997
|
||
|
RFC 1731 - IMAP Authentication Mechanisms - December 1994
|
||
|
(Discusses KERBEROSv4, GSSAPI, and S/Key)
|
||
|
RFC 2195 - IMAP/POP AUTHorize Extension for Simple Challenge/Response
|
||
|
- September 1997 (CRAM-MD5 authentication method)
|
||
|
RFC 2104 - HMAC: Keyed-Hashing for Message Authentication - February 1997
|
||
|
|
||
|
Supported URLs:
|
||
|
imap://server/ - Prompt for user/pass, list all folders in home directory
|
||
|
imap://user:pass@server/ - Uses LOGIN to log in
|
||
|
imap://user;AUTH=method:pass@server/ - Uses AUTHENTICATE to log in
|
||
|
|
||
|
imap://server/folder/ - List messages in folder
|
||
|
*/
|
||
|
|
||
|
#include "rfcdecoder.h"
|
||
|
#include "imaplist.h"
|
||
|
#include "imapparser.h"
|
||
|
|
||
|
#include <kdebug.h>
|
||
|
|
||
|
imapList::imapList (): parser_(0), noInferiors_ (false),
|
||
|
noSelect_ (false), marked_ (false), unmarked_ (false),
|
||
|
hasChildren_ (false), hasNoChildren_ (false)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
imapList::imapList (const imapList & lr):parser_(lr.parser_),
|
||
|
hierarchyDelimiter_ (lr.hierarchyDelimiter_),
|
||
|
name_ (lr.name_),
|
||
|
noInferiors_ (lr.noInferiors_),
|
||
|
noSelect_ (lr.noSelect_), marked_ (lr.marked_), unmarked_ (lr.unmarked_),
|
||
|
hasChildren_ (lr.hasChildren_), hasNoChildren_ (lr.hasNoChildren_),
|
||
|
attributes_ (lr.attributes_)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
imapList & imapList::operator = (const imapList & lr)
|
||
|
{
|
||
|
// Avoid a = a.
|
||
|
if (this == &lr)
|
||
|
return *this;
|
||
|
|
||
|
parser_ = lr.parser_;
|
||
|
hierarchyDelimiter_ = lr.hierarchyDelimiter_;
|
||
|
name_ = lr.name_;
|
||
|
noInferiors_ = lr.noInferiors_;
|
||
|
noSelect_ = lr.noSelect_;
|
||
|
marked_ = lr.marked_;
|
||
|
unmarked_ = lr.unmarked_;
|
||
|
hasChildren_ = lr.hasChildren_;
|
||
|
hasNoChildren_ = lr.hasNoChildren_;
|
||
|
attributes_ = lr.attributes_;
|
||
|
|
||
|
return *this;
|
||
|
}
|
||
|
|
||
14 years ago
|
imapList::imapList (const TQString & inStr, imapParser &parser)
|
||
15 years ago
|
: parser_(&parser),
|
||
|
noInferiors_ (false),
|
||
|
noSelect_ (false),
|
||
|
marked_ (false), unmarked_ (false), hasChildren_ (false),
|
||
|
hasNoChildren_ (false)
|
||
|
{
|
||
|
parseString s;
|
||
|
s.data.duplicate(inStr.latin1(), inStr.length());
|
||
|
|
||
|
if (s[0] != '(')
|
||
|
return; //not proper format for us
|
||
|
|
||
|
s.pos++; // tie off (
|
||
|
|
||
|
parseAttributes( s );
|
||
|
|
||
|
s.pos++; // tie off )
|
||
|
parser_->skipWS (s);
|
||
|
|
||
|
hierarchyDelimiter_ = parser_->parseOneWordC(s);
|
||
|
if (hierarchyDelimiter_ == "NIL")
|
||
14 years ago
|
hierarchyDelimiter_ = TQString();
|
||
15 years ago
|
name_ = rfcDecoder::fromIMAP (parser_->parseLiteral (s)); // decode modified UTF7
|
||
|
}
|
||
|
|
||
|
void imapList::parseAttributes( parseString & str )
|
||
|
{
|
||
14 years ago
|
TQCString attribute, orig;
|
||
15 years ago
|
|
||
|
while ( !str.isEmpty () && str[0] != ')' )
|
||
|
{
|
||
|
orig = parser_->parseOneWordC(str);
|
||
|
attributes_ << orig;
|
||
|
attribute = orig.lower();
|
||
13 years ago
|
if (-1 != attribute.find ("\\noinferiors"))
|
||
15 years ago
|
noInferiors_ = true;
|
||
13 years ago
|
else if (-1 != attribute.find ("\\noselect"))
|
||
15 years ago
|
noSelect_ = true;
|
||
13 years ago
|
else if (-1 != attribute.find ("\\marked"))
|
||
15 years ago
|
marked_ = true;
|
||
13 years ago
|
else if (-1 != attribute.find ("\\unmarked"))
|
||
15 years ago
|
unmarked_ = true;
|
||
13 years ago
|
else if (-1 != attribute.find ("\\haschildren"))
|
||
15 years ago
|
hasChildren_ = true;
|
||
13 years ago
|
else if (-1 != attribute.find ("\\hasnochildren"))
|
||
15 years ago
|
hasNoChildren_ = true;
|
||
|
else
|
||
|
kdDebug(7116) << "imapList::imapList: bogus attribute " << attribute << endl;
|
||
|
}
|
||
|
}
|
||
|
|