kioslaves/imap4

imaplist.cc

00001 /**********************************************************************
00002  *
00003  *   imapinfo.cc  - IMAP4rev1 EXAMINE / SELECT handler
00004  *   Copyright (C) 2000 Sven Carstens
00005  *
00006  *   This program is free software; you can redistribute it and/or modify
00007  *   it under the terms of the GNU General Public License as published by
00008  *   the Free Software Foundation; either version 2 of the License, or
00009  *   (at your option) any later version.
00010  *
00011  *   This program is distributed in the hope that it will be useful,
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *   GNU General Public License for more details.
00015  *
00016  *   You should have received a copy of the GNU General Public License
00017  *   along with this program; if not, write to the Free Software
00018  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  *   Send comments and bug fixes to
00021  *
00022  *********************************************************************/
00023 
00024 /*
00025   References:
00026     RFC 2060 - Internet Message Access Protocol - Version 4rev1 - December 1996
00027     RFC 2192 - IMAP URL Scheme - September 1997
00028     RFC 1731 - IMAP Authentication Mechanisms - December 1994
00029                (Discusses KERBEROSv4, GSSAPI, and S/Key)
00030     RFC 2195 - IMAP/POP AUTHorize Extension for Simple Challenge/Response
00031              - September 1997 (CRAM-MD5 authentication method)
00032     RFC 2104 - HMAC: Keyed-Hashing for Message Authentication - February 1997
00033 
00034   Supported URLs:
00035     imap://server/ - Prompt for user/pass, list all folders in home directory
00036     imap://user:pass@server/ - Uses LOGIN to log in
00037     imap://user;AUTH=method:pass@server/ - Uses AUTHENTICATE to log in
00038 
00039     imap://server/folder/ - List messages in folder
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   // Avoid a = a.
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;                     //not proper format for us
00092 
00093   s.pos++;  // tie off (
00094 
00095   parseAttributes( s );
00096 
00097   s.pos++;  // tie off )
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));  // decode modified UTF7
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 
KDE Home | KDE Accessibility Home | Description of Access Keys