From 6a4a30034edc7d7b3f0a824e9b38f43d4b9910df Mon Sep 17 00:00:00 2001 From: libec Date: Wed, 4 Nov 2015 10:27:51 +0100 Subject: adds support to send custom IMAP command --- src/async/imap/MCAsyncIMAP.h | 1 + src/async/imap/MCIMAPAsyncSession.cpp | 12 ++++++++ src/async/imap/MCIMAPAsyncSession.h | 2 ++ src/async/imap/MCIMAPCustomCommandOperation.cpp | 36 ++++++++++++++++++++++++ src/async/imap/MCIMAPCustomCommandOperation.h | 37 +++++++++++++++++++++++++ 5 files changed, 88 insertions(+) create mode 100644 src/async/imap/MCIMAPCustomCommandOperation.cpp create mode 100644 src/async/imap/MCIMAPCustomCommandOperation.h (limited to 'src/async/imap') diff --git a/src/async/imap/MCAsyncIMAP.h b/src/async/imap/MCAsyncIMAP.h index 8a490aa8..aa6d6b68 100755 --- a/src/async/imap/MCAsyncIMAP.h +++ b/src/async/imap/MCAsyncIMAP.h @@ -33,5 +33,6 @@ #include #include #include +#include #endif diff --git a/src/async/imap/MCIMAPAsyncSession.cpp b/src/async/imap/MCIMAPAsyncSession.cpp index ab1bbd95..15d546d5 100755 --- a/src/async/imap/MCIMAPAsyncSession.cpp +++ b/src/async/imap/MCIMAPAsyncSession.cpp @@ -42,6 +42,7 @@ #include "MCIMAPDisconnectOperation.h" #include "MCIMAPNoopOperation.h" #include "MCIMAPMessageRenderingOperation.h" +#include "MCIMAPCustomCommandOperation.h" #define DEFAULT_MAX_CONNECTIONS 3 @@ -536,6 +537,17 @@ IMAPFetchContentOperation * IMAPAsyncSession::fetchMessageByNumberOperation(Stri return op; } +IMAPCustomCommandOperation * IMAPAsyncSession::sendCustomCommand(String *command, bool urgent) +{ + + IMAPCustomCommandOperation *op = new IMAPCustomCommandOperation(); + op->setMainSession(this); + op->setCustomCommand(command); + op->setUrgent(urgent); + op->autorelease(); + return op; +} + IMAPFetchContentOperation * IMAPAsyncSession::fetchMessageAttachmentByNumberOperation(String * folder, uint32_t number, String * partID, Encoding encoding, bool urgent) { diff --git a/src/async/imap/MCIMAPAsyncSession.h b/src/async/imap/MCIMAPAsyncSession.h index 86378926..42fedcfb 100755 --- a/src/async/imap/MCIMAPAsyncSession.h +++ b/src/async/imap/MCIMAPAsyncSession.h @@ -40,6 +40,7 @@ namespace mailcore { class IMAPSession; class IMAPIdentity; class OperationQueueCallback; + class IMAPCustomCommandOperation; class MAILCORE_EXPORT IMAPAsyncSession : public Object { public: @@ -135,6 +136,7 @@ namespace mailcore { Encoding encoding, bool urgent = false); virtual IMAPFetchContentOperation * fetchMessageByNumberOperation(String * folder, uint32_t number, bool urgent = false); + virtual IMAPCustomCommandOperation * sendCustomCommand(String *command, bool urgent); virtual IMAPFetchContentOperation * fetchMessageAttachmentByNumberOperation(String * folder, uint32_t number, String * partID, Encoding encoding, bool urgent = false); diff --git a/src/async/imap/MCIMAPCustomCommandOperation.cpp b/src/async/imap/MCIMAPCustomCommandOperation.cpp new file mode 100644 index 00000000..692c8f7d --- /dev/null +++ b/src/async/imap/MCIMAPCustomCommandOperation.cpp @@ -0,0 +1,36 @@ +// +// MCIMAPCustomCommandOperation.cpp +// mailcore2 +// +// Created by Libor Huspenina on 18/10/2015. +// Copyright © 2015 MailCore. All rights reserved. +// + +#include "MCIMAPCustomCommandOperation.h" + +#include "MCIMAPSession.h" +#include "MCIMAPAsyncConnection.h" + +using namespace mailcore; + +IMAPCustomCommandOperation::IMAPCustomCommandOperation() +{ + mCustomCommand = NULL; +} + +IMAPCustomCommandOperation::~IMAPCustomCommandOperation() +{ + MC_SAFE_RELEASE(mCustomCommand); +} + +void IMAPCustomCommandOperation::setCustomCommand(mailcore::String * command) +{ + mCustomCommand = command; +} + +void IMAPCustomCommandOperation::main() +{ + + session()->session()->sendCustomCommand(mCustomCommand); + +} diff --git a/src/async/imap/MCIMAPCustomCommandOperation.h b/src/async/imap/MCIMAPCustomCommandOperation.h new file mode 100644 index 00000000..83e6c11f --- /dev/null +++ b/src/async/imap/MCIMAPCustomCommandOperation.h @@ -0,0 +1,37 @@ +// +// MCIMAPCustomCommandOperation.h +// mailcore2 +// +// Created by Libor Huspenina on 18/10/2015. +// Copyright © 2015 MailCore. All rights reserved. +// + +#ifndef MAILCORE_MCIMAPCUSTOMCOMMANDOPERATION_H + +#define MAILCORE_MCIMAPCUSTOMCOMMANDOPERATION_H + +#include + +#ifdef __cplusplus + +namespace mailcore { + + class MAILCORE_EXPORT IMAPCustomCommandOperation : public IMAPOperation { + public: + IMAPCustomCommandOperation(); + virtual ~IMAPCustomCommandOperation(); + + virtual void setCustomCommand(String *command); + + public: // subclass behavior + virtual void main(); + + private: + String * mCustomCommand; + }; + +} + +#endif + +#endif -- cgit v1.2.3