|
#include <CImapConnect.h>

Public Member Functions | |
| CImapConnect () | |
| Default constructor */. | |
| ~CImapConnect () | |
| Destructor, closes the connection if it's open. */. | |
| void | command (std::string cmd, const std::string &arg1="", const std::string &arg2="") |
| const sptk::CStrings & | response () const |
| Returns reference to a last command response. */. | |
| void | cmd_capability () |
| Retrieves server's capabilities in response(). */. | |
| void | cmd_noop () |
| Sends NOOP command. */. | |
| void | cmd_logout () |
| Logs out from the current session. */. | |
| void | cmd_login (std::string user, std::string password) |
| void | cmd_select (std::string mail_box, int32_t &total_msgs) |
| void | cmd_examine (std::string mail_box) |
| void | cmd_subscribe (std::string mail_box) |
| void | cmd_unsubscribe (std::string mail_box) |
| void | cmd_create (std::string mail_box) |
| void | cmd_delete (std::string mail_box) |
| void | cmd_rename (std::string mail_box, std::string new_name) |
| void | cmd_list (std::string mail_box_mask, bool decode=false) |
| void | cmd_append (std::string mail_box, const CBuffer &message) |
| void | cmd_close () |
| Closes the connection with the server. */. | |
| void | cmd_expunge () |
| Expanges the deleted messages in the current mail box. */. | |
| void | cmd_search_all (std::string &result) |
| Reatrieves all the messages list in the current mail box. */. | |
| void | cmd_search_new (std::string &result) |
| Reatrieves the new messages list in the current mail box. */. | |
| void | cmd_fetch_headers (int32_t msg_id, CFieldList &result) |
| void | cmd_fetch_message (int32_t msg_id, CFieldList &result) |
| std::string | cmd_fetch_flags (int32_t msg_id) |
| void | cmd_store_flags (int32_t msg_id, const char *flags) |
Protected Member Functions | |
| std::string | sendCommand (std::string cmd) |
| Sends a command to the server, but doesn't retrieve the server response. | |
| bool | getResponse (std::string ident) |
| Gets a response from the server for a previously sent command, identified by the ident. | |
| void | parseSearch (std::string &result) |
| Parses the result of SEARCH command in response. Returns results in result parameter. | |
| void | parseMessage (CFieldList &result, bool headersOnly) |
| Parses server response as a message data (after the appropriate command) to the set of fields. | |
| void | parseFolderList () |
| Parses server response as a folder list (after the appropriate command), and converts the response to it. | |
Class CImapConnect is used to communicate with IMAP 4 servers. It implements the most popular commands of IMAP protocol to build a simple IMAP client.
| void sptk::CImapConnect::cmd_append | ( | std::string | mail_box, | |
| const CBuffer & | message | |||
| ) |
Appends the message to the mail box.
| mail_box | std::string, the name of the mail box | |
| message | CBuffer, the RFC-2060 defined message |
| void sptk::CImapConnect::cmd_create | ( | std::string | mail_box | ) | [inline] |
Creates the new mail box.
| mail_box | std::string, the name of the mail box |
References command().
| void sptk::CImapConnect::cmd_delete | ( | std::string | mail_box | ) | [inline] |
Deletes the new mail box.
| mail_box | std::string, the name of the mail box |
References command().
| void sptk::CImapConnect::cmd_examine | ( | std::string | mail_box | ) | [inline] |
Retrieves the mail box information into response().
| mail_box | std::string, the name of the mail box |
References command().
| std::string sptk::CImapConnect::cmd_fetch_flags | ( | int32_t | msg_id | ) |
Gets message flags
| msg_id | int, the message identifier |
| void sptk::CImapConnect::cmd_fetch_headers | ( | int32_t | msg_id, | |
| CFieldList & | result | |||
| ) |
Reatrieves the headers for the message.
| msg_id | int32_t, the message identifier | |
| result | CFieldList, the message headers information |
| void sptk::CImapConnect::cmd_fetch_message | ( | int32_t | msg_id, | |
| CFieldList & | result | |||
| ) |
Reatrieves the message information.
| msg_id | int, the message identifier | |
| result | CFieldList, the complete message information |
| void sptk::CImapConnect::cmd_list | ( | std::string | mail_box_mask, | |
| bool | decode = false | |||
| ) |
Retrieves the list of mail boxes.
| mail_box_mask | std::string, the mask for the mail box names | |
| decode | bool, true if you want to convert the response into plain folder list. |
| void sptk::CImapConnect::cmd_login | ( | std::string | user, | |
| std::string | password | |||
| ) |
Logs in the server. The server name or address should be defined with the call of host() method.
| user | std::string, user name on the server | |
| password | std::string, user password on the server |
| void sptk::CImapConnect::cmd_rename | ( | std::string | mail_box, | |
| std::string | new_name | |||
| ) | [inline] |
Renames the new mail box.
| mail_box | std::string, the name of the mail box | |
| new_name | std::string, the new name of the mail box |
References command().
| void sptk::CImapConnect::cmd_select | ( | std::string | mail_box, | |
| int32_t & | total_msgs | |||
| ) |
Selects the mail box for future operations.
| mail_box | std::string, the name of the mail box | |
| total_msgs | int32_t&, returns the total messages in the mail box |
| void sptk::CImapConnect::cmd_store_flags | ( | int32_t | msg_id, | |
| const char * | flags | |||
| ) |
Sets message flags
| msg_id | int, the message identifier | |
| flags | const char *, the message flags |
| void sptk::CImapConnect::cmd_subscribe | ( | std::string | mail_box | ) | [inline] |
Subscribes the mail box to the user.
| mail_box | std::string, the name of the mail box |
References command().
| void sptk::CImapConnect::cmd_unsubscribe | ( | std::string | mail_box | ) | [inline] |
Unsubscribes the mail box from the user.
| mail_box | std::string, the name of the mail box |
References command().
| void sptk::CImapConnect::command | ( | std::string | cmd, | |
| const std::string & | arg1 = "", |
|||
| const std::string & | arg2 = "" | |||
| ) |
Sends a command with the arguments. Arguments (if any) are automatically enquoted with double-quotes. The command is also appended with the new line characters (CRLF).
| cmd | std::string, IMAP4 command | |
| arg1 | std::string, optional command argument1 | |
| arg2 | std::string, optional command argument2 |
Referenced by cmd_capability(), cmd_close(), cmd_create(), cmd_delete(), cmd_examine(), cmd_expunge(), cmd_logout(), cmd_noop(), cmd_rename(), cmd_subscribe(), and cmd_unsubscribe().
| bool sptk::CImapConnect::getResponse | ( | std::string | ident | ) | [protected] |
Gets a response from the server for a previously sent command, identified by the ident.
| ident | std::string, the command identifier returned by prior sendCommand(). |
| void sptk::CImapConnect::parseFolderList | ( | ) | [protected] |
Parses server response as a folder list (after the appropriate command), and converts the response to it.
As a result, the response contains the plain list of folders.
| void sptk::CImapConnect::parseMessage | ( | CFieldList & | result, | |
| bool | headersOnly | |||
| ) | [protected] |
Parses server response as a message data (after the appropriate command) to the set of fields.
| result | CFieldList, the set of fields with the message information. | |
| headersOnly | bool, true if we don't want to retrieve message body. |
| void sptk::CImapConnect::parseSearch | ( | std::string & | result | ) | [protected] |
Parses the result of SEARCH command in response. Returns results in result parameter.
| result | std::string, returns the search results. |
| std::string sptk::CImapConnect::sendCommand | ( | std::string | cmd | ) | [protected] |
Sends a command to the server, but doesn't retrieve the server response.
The new line characters (CRLF) are added to the end of every command.
| cmd | std::string, the complete text of IMAP4 command |