|
#include <ImapConnect.h>
Public Member Functions | |
| ImapConnect ()=default | |
| void | command (const String &cmd, const String &arg1="", const String &arg2="") |
| const Strings & | response () const |
| void | cmd_capability () |
| void | cmd_noop () |
| void | cmd_logout () |
| void | cmd_login (const String &user, const String &password) |
| void | cmd_select (const String &mail_box, int32_t &total_msgs) |
| void | cmd_examine (const String &mail_box) |
| void | cmd_subscribe (const String &mail_box) |
| void | cmd_unsubscribe (const String &mail_box) |
| void | cmd_create (const String &mail_box) |
| void | cmd_delete (const String &mail_box) |
| void | cmd_rename (const String &mail_box, const String &new_name) |
| void | cmd_list (const String &mail_box_mask, bool decode=false) |
| void | cmd_append (const String &mail_box, const Buffer &message) |
| void | cmd_close () |
| void | cmd_expunge () |
| void | cmd_search_all (String &result) |
| void | cmd_search_new (String &result) |
| void | cmd_fetch_headers (int32_t msg_id, FieldList &result) |
| void | cmd_fetch_message (int32_t msg_id, FieldList &result) |
| String | cmd_fetch_flags (int32_t msg_id) |
| void | cmd_store_flags (int32_t msg_id, const char *flags) |
Public Member Functions inherited from sptk::TCPSocket | |
| TCPSocket (SOCKET_ADDRESS_FAMILY domain=AF_INET, int32_t type=SOCK_STREAM, int32_t protocol=0) | |
| ~TCPSocket () override | |
| void | setProxy (std::shared_ptr< Proxy > proxy) |
| void | close () noexcept override |
| virtual bool | accept (SOCKET &clientSocketFD, struct sockaddr_in &clientInfo, std::chrono::milliseconds timeout) |
| size_t | socketBytes () override |
| bool | readyToRead (std::chrono::milliseconds timeout) override |
| size_t | readLine (char *buffer, size_t size, char delimiter='\n') |
| size_t | readLine (Buffer &buffer, char delimiter='\n') |
| size_t | readLine (String &s, char delimiter='\n') |
| size_t | read (uint8_t *buffer, size_t size, sockaddr_in *from=nullptr) override |
| size_t | read (Buffer &buffer, size_t size, sockaddr_in *from=nullptr) override |
| size_t | read (String &buffer, size_t size, sockaddr_in *from=nullptr) override |
| template<typename T > | |
| size_t | read (T &value, sockaddr_in *from=nullptr) |
Public Member Functions inherited from sptk::BaseSocket | |
| SOCKET | fd () const |
| void | open_addr (OpenMode openMode=OpenMode::CREATE, const sockaddr_in *addr=nullptr, std::chrono::milliseconds timeout=std::chrono::milliseconds(0)) |
| BaseSocket (SOCKET_ADDRESS_FAMILY domain=AF_INET, int32_t type=SOCK_STREAM, int32_t protocol=0) | |
| BaseSocket (const BaseSocket &other)=delete | |
| BaseSocket (BaseSocket &&other) noexcept=default | |
| virtual | ~BaseSocket () |
| Destructor. | |
| BaseSocket & | operator= (const BaseSocket &other)=delete |
| BaseSocket & | operator= (BaseSocket &&other) noexcept=default |
| void | blockingMode (bool blocking) |
| virtual size_t | socketBytes () |
| virtual void | attach (SOCKET socketHandle, bool accept) |
| virtual SOCKET | detach () |
| void | host (const Host &host) |
| const Host & | host () const |
| void | open (const Host &host=Host(), OpenMode openMode=OpenMode::CONNECT, bool blockingMode=true, std::chrono::milliseconds timeoutMS=std::chrono::milliseconds(0)) |
| void | open (const struct sockaddr_in &address, OpenMode openMode=OpenMode::CONNECT, bool blockingMode=true, std::chrono::milliseconds timeoutMS=std::chrono::milliseconds(0)) |
| void | bind (const char *address, uint32_t portNumber) |
| void | listen (uint16_t portNumber=0) |
| virtual void | close () noexcept |
| bool | active () const |
| int32_t | control (int flag, const uint32_t *check) const |
| void | setOption (int level, int option, int value) const |
| void | getOption (int level, int option, int &value) const |
| virtual size_t | recv (uint8_t *buffer, size_t len) |
| virtual size_t | send (const uint8_t *buffer, size_t len) |
| virtual size_t | read (uint8_t *buffer, size_t size, sockaddr_in *from) |
| virtual size_t | read (uint8_t *buffer, size_t size) |
| virtual size_t | read (Buffer &buffer, size_t size, sockaddr_in *from) |
| size_t | read (Buffer &buffer, size_t size) |
| virtual size_t | read (String &buffer, size_t size, sockaddr_in *from) |
| size_t | read (String &buffer, size_t size) |
| virtual size_t | write (const uint8_t *buffer, size_t size, const sockaddr_in *peer) |
| size_t | write (const uint8_t *buffer, size_t size) |
| virtual size_t | write (const Buffer &buffer, const sockaddr_in *peer) |
| size_t | write (const Buffer &buffer) |
| virtual size_t | write (const String &buffer, const sockaddr_in *peer) |
| size_t | write (const String &buffer) |
| virtual bool | readyToRead (std::chrono::milliseconds timeout) |
| virtual bool | readyToWrite (std::chrono::milliseconds timeout) |
| bool | blockingMode () const |
| Return current blocking mode state. More... | |
Protected Member Functions | |
| String | sendCommand (const String &cmd) |
| bool | getResponse (const String &ident) |
| void | parseSearch (String &result) const |
| void | parseMessage (FieldList &result, bool headersOnly) |
| void | parseFolderList () |
Protected Member Functions inherited from sptk::TCPSocket | |
| TCPSocketReader & | reader () |
| void | _open (const Host &host, OpenMode openMode, bool blockingMode, std::chrono::milliseconds timeout) override |
| void | _open (const struct sockaddr_in &address, OpenMode openMode, bool blockingMode, std::chrono::milliseconds timeout) override |
| Proxy * | proxy () |
Protected Member Functions inherited from sptk::BaseSocket | |
| void | setSocketFD (SOCKET socket) |
| int32_t | domain () const |
| int32_t | type () const |
| int32_t | protocol () const |
| virtual void | _open (const Host &host, OpenMode openMode, bool blockingMode, std::chrono::milliseconds timeoutMS) |
| virtual void | _open (const struct sockaddr_in &address, OpenMode openMode, bool blockingMode, std::chrono::milliseconds timeoutMS) |
Additional Inherited Members | |
Public Types inherited from sptk::BaseSocket | |
| enum class | OpenMode : uint8_t { CREATE , CONNECT , BIND } |
IMAP socket
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.
|
default |
Default constructor
Appends the message to the mail box.
| mail_box | std::string, the name of the mail box |
| message | CBuffer, the RFC-2060 defined message |
|
inline |
IMAPv4 commands - any state
Retrieves server's capabilities in response().
|
inline |
Closes the connection with the server.
|
inline |
Creates the new mail box.
| mail_box | std::string, the name of the mail box |
|
inline |
Deletes the new mail box.
| mail_box | std::string, the name of the mail box |
|
inline |
Retrieves the mail box information into response().
| mail_box | std::string, the name of the mail box |
|
inline |
Expanges the deleted messages in the current mail box.
| String sptk::ImapConnect::cmd_fetch_flags | ( | int32_t | msg_id | ) |
Gets message flags
| msg_id | int, the message identifier |
| void sptk::ImapConnect::cmd_fetch_headers | ( | int32_t | msg_id, |
| FieldList & | result | ||
| ) |
Reatrieves the headers for the message.
| msg_id | int32_t, the message identifier |
| result | CFieldList, the message headers information |
| void sptk::ImapConnect::cmd_fetch_message | ( | int32_t | msg_id, |
| FieldList & | result | ||
| ) |
Reatrieves the message information.
| msg_id | int, the message identifier |
| result | CFieldList, the complete message information |
| void sptk::ImapConnect::cmd_list | ( | const 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. |
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 |
|
inline |
Logs out from the current session.
|
inline |
Sends NOOP command.
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 |
| void sptk::ImapConnect::cmd_search_all | ( | String & | result | ) |
Reatrieves all the messages list in the current mail box.
| void sptk::ImapConnect::cmd_search_new | ( | String & | result | ) |
Reatrieves the new messages list in the current mail box.
| void sptk::ImapConnect::cmd_select | ( | const String & | mail_box, |
| int32_t & | total_msgs | ||
| ) |
Selects the mail box for future operations.
| mail_box | const std::string&, the name of the mail box |
| total_msgs | int32_t&, returns the total messages in the mail box |
| void sptk::ImapConnect::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 |
|
inline |
Subscribes the mail box to the user.
| mail_box | std::string, the name of the mail box |
|
inline |
Unsubscribes the mail box from the user.
| mail_box | std::string, the name of the mail box |
| void sptk::ImapConnect::command | ( | const String & | cmd, |
| const String & | arg1 = "", |
||
| const 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 |
|
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(). |
|
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.
|
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. |
|
protected |
Parses the result of SEARCH command in response. Returns results in result parameter
| result | std::string, returns the search results. |
|
inline |
Returns reference to a last command response.
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 |