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.
395 lines
12 KiB
395 lines
12 KiB
15 years ago
|
#ifndef _IMAPCOMMAND_H
|
||
|
#define _IMAPCOMMAND_H
|
||
|
/**********************************************************************
|
||
|
*
|
||
|
* imapcommand.h - IMAP4rev1 command handler
|
||
|
* Copyright (C) 2000 Sven Carstens
|
||
|
*
|
||
|
* 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
|
||
|
*
|
||
|
*********************************************************************/
|
||
|
|
||
15 years ago
|
#include <tqstringlist.h>
|
||
|
#include <tqstring.h>
|
||
|
#include <tqmap.h>
|
||
15 years ago
|
|
||
|
/**
|
||
|
* @brief encapulate a IMAP command
|
||
|
* @author Svenn Carstens
|
||
|
* @date 2000
|
||
|
* @todo fix the documentation
|
||
|
*/
|
||
|
|
||
|
class imapCommand
|
||
|
{
|
||
|
public:
|
||
|
|
||
|
/**
|
||
|
* @brief Constructor
|
||
|
*/
|
||
|
imapCommand ();
|
||
|
/**
|
||
15 years ago
|
* @fn imapCommand (const TQString & command, const TQString & parameter);
|
||
15 years ago
|
* @brief Constructor
|
||
|
* @param command Imap command
|
||
|
* @param parameter Parameters to the command
|
||
|
* @return none
|
||
|
*/
|
||
15 years ago
|
imapCommand (const TQString & command, const TQString & parameter);
|
||
15 years ago
|
/**
|
||
|
* @fn bool isComplete ();
|
||
|
* @brief is it complete?
|
||
|
* @return whether the command is completed
|
||
|
*/
|
||
|
bool isComplete ();
|
||
|
/**
|
||
15 years ago
|
* @fn const TQString & result ();
|
||
15 years ago
|
* @brief get the result of the command
|
||
|
* @return The result, i.e. first word of the result line, like OK
|
||
|
*/
|
||
15 years ago
|
const TQString & result ();
|
||
15 years ago
|
/**
|
||
15 years ago
|
* @fn const TQString & resultInfo ();
|
||
15 years ago
|
* @brief get information about the result
|
||
|
* @return Information about the result, i.e. the rest of the result line
|
||
|
*/
|
||
15 years ago
|
const TQString & resultInfo ();
|
||
15 years ago
|
/**
|
||
15 years ago
|
* @fn const TQString & parameter ();
|
||
15 years ago
|
* @brief get the parameter
|
||
|
* @return the parameter
|
||
|
*/
|
||
15 years ago
|
const TQString & parameter ();
|
||
15 years ago
|
/**
|
||
15 years ago
|
* @fn const TQString & command ();
|
||
15 years ago
|
* @brief get the command
|
||
|
* @return the command
|
||
|
*/
|
||
15 years ago
|
const TQString & command ();
|
||
15 years ago
|
/**
|
||
15 years ago
|
* @fn const TQString & id ();
|
||
15 years ago
|
* @brief get the id
|
||
|
* @return the id
|
||
|
*/
|
||
15 years ago
|
const TQString & id ();
|
||
15 years ago
|
|
||
|
/**
|
||
15 years ago
|
* @fn void setId (const TQString &);
|
||
15 years ago
|
* @brief set the id
|
||
|
* @param id the id used by the command
|
||
|
* @return none
|
||
|
*/
|
||
15 years ago
|
void setId (const TQString &);
|
||
15 years ago
|
/**
|
||
|
* @fn void setComplete ();
|
||
|
* @brief set the completed state
|
||
|
* @return none
|
||
|
*/
|
||
|
void setComplete ();
|
||
|
/**
|
||
15 years ago
|
* @fn void setResult (const TQString &);
|
||
15 years ago
|
* @brief set the completed state
|
||
|
* @param result the command result
|
||
|
* @return none
|
||
|
*/
|
||
15 years ago
|
void setResult (const TQString &);
|
||
15 years ago
|
/**
|
||
15 years ago
|
* @fn void setResultInfo (const TQString &);
|
||
15 years ago
|
* @brief set the completed state
|
||
|
* @param result the command result information
|
||
|
* @return none
|
||
|
*/
|
||
15 years ago
|
void setResultInfo (const TQString &);
|
||
15 years ago
|
/**
|
||
15 years ago
|
* @fn void setCommand (const TQString &);
|
||
15 years ago
|
* @brief set the command
|
||
|
* @param command the imap command
|
||
|
* @return none
|
||
|
*/
|
||
15 years ago
|
void setCommand (const TQString &);
|
||
15 years ago
|
/**
|
||
15 years ago
|
* @fn void setParameter (const TQString &);
|
||
15 years ago
|
* @brief set the command parameter(s)
|
||
|
* @param parameter the comand parameter(s)
|
||
|
* @return none
|
||
|
*/
|
||
15 years ago
|
void setParameter (const TQString &);
|
||
15 years ago
|
/**
|
||
15 years ago
|
* @fn const TQString getStr ();
|
||
15 years ago
|
* @brief returns the data to send to the server
|
||
|
* The function returns the complete data to be sent to
|
||
|
* the server (\<id\> \<command\> [\<parameter\>])
|
||
|
* @return the data to send to the server
|
||
|
* @todo possibly rename function to be clear of it's purpose
|
||
|
*/
|
||
15 years ago
|
const TQString getStr ();
|
||
15 years ago
|
|
||
|
/**
|
||
|
* @fn static imapCommand *clientNoop ();
|
||
|
* @brief Create a NOOP command
|
||
|
* @return a NOOP imapCommand
|
||
|
*/
|
||
|
static imapCommand *clientNoop ();
|
||
|
/**
|
||
15 years ago
|
* @fn static imapCommand *clientFetch (ulong uid, const TQString & fields, bool nouid = false);
|
||
15 years ago
|
* @brief Create a FETCH command
|
||
|
* @param uid Uid of the message to fetch
|
||
|
* @param fields options to pass to the server
|
||
|
* @param nouid Perform a FETCH or UID FETCH command
|
||
|
* @return a FETCH imapCommand
|
||
|
* Fetch a single uid
|
||
|
*/
|
||
15 years ago
|
static imapCommand *clientFetch (ulong uid, const TQString & fields,
|
||
15 years ago
|
bool nouid = false);
|
||
|
/**
|
||
15 years ago
|
* @fn static imapCommand *clientFetch (ulong fromUid, ulong toUid, const TQString & fields, bool nouid = false);
|
||
15 years ago
|
* @brief Create a FETCH command
|
||
|
* @param fromUid start uid of the messages to fetch
|
||
|
* @param toUid last uid of the messages to fetch
|
||
|
* @param fields options to pass to the server
|
||
|
* @param nouid Perform a FETCH or UID FETCH command
|
||
|
* @return a FETCH imapCommand
|
||
|
* Fetch a range of uids
|
||
|
*/
|
||
|
static imapCommand *clientFetch (ulong fromUid, ulong toUid,
|
||
15 years ago
|
const TQString & fields, bool nouid =
|
||
15 years ago
|
false);
|
||
|
/**
|
||
15 years ago
|
* @fn static imapCommand *clientFetch (const TQString & sequence, const TQString & fields, bool nouid = false);
|
||
15 years ago
|
* @brief Create a FETCH command
|
||
|
* @param sequence a IMAP FETCH sequence string
|
||
|
* @param fields options to pass to the server
|
||
|
* @param nouid Perform a FETCH or UID FETCH command
|
||
|
* @return a FETCH imapCommand
|
||
|
* Fetch a range of uids. The other clientFetch functions are just
|
||
|
* wrappers around this function.
|
||
|
*/
|
||
15 years ago
|
static imapCommand *clientFetch (const TQString & sequence,
|
||
|
const TQString & fields, bool nouid =
|
||
15 years ago
|
false);
|
||
|
/**
|
||
15 years ago
|
* @fn static imapCommand *clientList (const TQString & reference, const TQString & path, bool lsub = false);
|
||
15 years ago
|
* @brief Create a LIST command
|
||
|
* @param reference
|
||
|
* @param path The path to list
|
||
|
* @param lsub Perform a LIST or a LSUB command
|
||
|
* @return a LIST imapCommand
|
||
|
*/
|
||
15 years ago
|
static imapCommand *clientList (const TQString & reference,
|
||
|
const TQString & path, bool lsub = false);
|
||
15 years ago
|
/**
|
||
15 years ago
|
* @fn static imapCommand *clientSelect (const TQString & path, bool examine = false);
|
||
15 years ago
|
* @brief Create a SELECT command
|
||
|
* @param path The path to select
|
||
|
* @param lsub Perform a SELECT or a EXAMINE command
|
||
|
* @return a SELECT imapCommand
|
||
|
*/
|
||
15 years ago
|
static imapCommand *clientSelect (const TQString & path, bool examine =
|
||
15 years ago
|
false);
|
||
|
/**
|
||
|
* @fn static imapCommand *clientClose();
|
||
|
* @brief Create a CLOSE command
|
||
|
* @return a CLOSE imapCommand
|
||
|
*/
|
||
|
static imapCommand *clientClose();
|
||
|
/**
|
||
|
* @brief Create a STATUS command
|
||
|
* @param path
|
||
|
* @param parameters
|
||
|
* @return a STATUS imapCommand
|
||
|
*/
|
||
13 years ago
|
static imapCommand *clienStatus (const TQString & path,
|
||
15 years ago
|
const TQString & parameters);
|
||
15 years ago
|
/**
|
||
|
* @brief Create a COPY command
|
||
|
* @param box
|
||
|
* @param sequence
|
||
|
* @param nouid Perform a COPY or UID COPY command
|
||
|
* @return a COPY imapCommand
|
||
|
*/
|
||
15 years ago
|
static imapCommand *clientCopy (const TQString & box,
|
||
|
const TQString & sequence, bool nouid =
|
||
15 years ago
|
false);
|
||
|
/**
|
||
|
* @brief Create a APPEND command
|
||
|
* @param box
|
||
|
* @param flags
|
||
|
* @param size
|
||
|
* @return a APPEND imapCommand
|
||
|
*/
|
||
15 years ago
|
static imapCommand *clientAppend (const TQString & box,
|
||
|
const TQString & flags, ulong size);
|
||
15 years ago
|
/**
|
||
|
* @brief Create a CREATE command
|
||
|
* @param path
|
||
|
* @return a CREATE imapCommand
|
||
|
*/
|
||
15 years ago
|
static imapCommand *clientCreate (const TQString & path);
|
||
15 years ago
|
/**
|
||
|
* @brief Create a DELETE command
|
||
|
* @param path
|
||
|
* @return a DELETE imapCommand
|
||
|
*/
|
||
15 years ago
|
static imapCommand *clientDelete (const TQString & path);
|
||
15 years ago
|
/**
|
||
|
* @brief Create a SUBSCRIBE command
|
||
|
* @param path
|
||
|
* @return a SUBSCRIBE imapCommand
|
||
|
*/
|
||
15 years ago
|
static imapCommand *clientSubscribe (const TQString & path);
|
||
15 years ago
|
/**
|
||
|
* @brief Create a UNSUBSCRIBE command
|
||
|
* @param path
|
||
|
* @return a UNSUBSCRIBE imapCommand
|
||
|
*/
|
||
15 years ago
|
static imapCommand *clientUnsubscribe (const TQString & path);
|
||
15 years ago
|
/**
|
||
|
* @brief Create a EXPUNGE command
|
||
|
* @return a EXPUNGE imapCommand
|
||
|
*/
|
||
|
static imapCommand *clientExpunge ();
|
||
|
/**
|
||
|
* @brief Create a RENAME command
|
||
|
* @param src Source
|
||
|
* @param dest Destination
|
||
|
* @return a RENAME imapCommand
|
||
|
*/
|
||
15 years ago
|
static imapCommand *clientRename (const TQString & src,
|
||
|
const TQString & dest);
|
||
15 years ago
|
/**
|
||
|
* @brief Create a SEARCH command
|
||
|
* @param search
|
||
|
* @param nouid Perform a UID SEARCH or a SEARCH command
|
||
|
* @return a SEARCH imapCommand
|
||
|
*/
|
||
15 years ago
|
static imapCommand *clientSearch (const TQString & search, bool nouid =
|
||
15 years ago
|
false);
|
||
|
/**
|
||
|
* @brief Create a STORE command
|
||
|
* @param set
|
||
|
* @param item
|
||
|
* @param data
|
||
|
* @param nouid Perform a UID STORE or a STORE command
|
||
|
* @return a STORE imapCommand
|
||
|
*/
|
||
15 years ago
|
static imapCommand *clientStore (const TQString & set, const TQString & item,
|
||
|
const TQString & data, bool nouid = false);
|
||
15 years ago
|
/**
|
||
|
* @brief Create a LOGOUT command
|
||
|
* @return a LOGOUT imapCommand
|
||
|
*/
|
||
|
static imapCommand *clientLogout ();
|
||
|
/**
|
||
|
* @brief Create a STARTTLS command
|
||
|
* @return a STARTTLS imapCommand
|
||
|
*/
|
||
|
static imapCommand *clientStartTLS ();
|
||
|
|
||
|
//////////// ACL support (RFC 2086) /////////////
|
||
|
/**
|
||
|
* @brief Create a SETACL command
|
||
|
* @param box mailbox name
|
||
|
* @param user authentication identifier
|
||
|
* @param acl access right modification (starting with optional +/-)
|
||
|
* @return a SETACL imapCommand
|
||
|
*/
|
||
15 years ago
|
static imapCommand *clientSetACL ( const TQString& box, const TQString& user, const TQString& acl );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* @brief Create a DELETEACL command
|
||
|
* @param box mailbox name
|
||
|
* @param user authentication identifier
|
||
|
* @return a DELETEACL imapCommand
|
||
|
*/
|
||
15 years ago
|
static imapCommand *clientDeleteACL ( const TQString& box, const TQString& user );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* @brief Create a GETACL command
|
||
|
* @param box mailbox name
|
||
|
* @return a GETACL imapCommand
|
||
|
*/
|
||
15 years ago
|
static imapCommand *clientGetACL ( const TQString& box );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* @brief Create a LISTRIGHTS command
|
||
|
* @param box mailbox name
|
||
|
* @param user authentication identifier
|
||
|
* @return a LISTRIGHTS imapCommand
|
||
|
*/
|
||
15 years ago
|
static imapCommand *clientListRights ( const TQString& box, const TQString& user );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* @brief Create a MYRIGHTS command
|
||
|
* @param box mailbox name
|
||
|
* @return a MYRIGHTS imapCommand
|
||
|
*/
|
||
15 years ago
|
static imapCommand *clientMyRights ( const TQString& box );
|
||
15 years ago
|
|
||
|
//////////// ANNOTATEMORE support /////////////
|
||
|
/**
|
||
|
* @brief Create a SETANNOTATION command
|
||
|
* @param box mailbox name
|
||
|
* @param entry entry specifier
|
||
|
* @param attributes map of attribute names + values
|
||
|
* @return a SETANNOTATION imapCommand
|
||
|
*/
|
||
15 years ago
|
static imapCommand *clientSetAnnotation ( const TQString& box, const TQString& entry, const TQMap<TQString, TQString>& attributes );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* @brief Create a GETANNOTATION command
|
||
|
* @param box mailbox name
|
||
|
* @param entry entry specifier
|
||
|
* @param attributeNames attribute specifier
|
||
|
* @return a GETANNOTATION imapCommand
|
||
|
*/
|
||
15 years ago
|
static imapCommand *clientGetAnnotation ( const TQString& box, const TQString& entry, const TQStringList& attributeNames );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* @brief Create a NAMESPACE command
|
||
|
* @return a NAMESPACE imapCommand
|
||
|
*/
|
||
|
static imapCommand *clientNamespace ();
|
||
|
|
||
|
/**
|
||
13 years ago
|
* @brief Create a GETQUOTAROOT command
|
||
15 years ago
|
* @param box mailbox name
|
||
13 years ago
|
* @return a GETQUOTAROOT imapCommand
|
||
15 years ago
|
*/
|
||
15 years ago
|
static imapCommand *clientGetQuotaroot ( const TQString& box );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* @brief Create a custom command
|
||
|
* @param command The custom command
|
||
|
* @param arguments The custom arguments
|
||
|
* @return a custom imapCommand
|
||
|
*/
|
||
15 years ago
|
static imapCommand *clientCustom ( const TQString& command, const TQString& arguments );
|
||
15 years ago
|
|
||
|
protected:
|
||
15 years ago
|
TQString aCommand;
|
||
|
TQString mId;
|
||
15 years ago
|
bool mComplete;
|
||
15 years ago
|
TQString aParameter;
|
||
|
TQString mResult;
|
||
|
TQString mResultInfo;
|
||
15 years ago
|
|
||
|
private:
|
||
|
imapCommand & operator = (const imapCommand &);
|
||
|
};
|
||
|
|
||
|
#endif
|