aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar libec <libor.huspenina@gmail.com>2015-11-06 08:45:37 +0100
committerGravatar libec <libor.huspenina@gmail.com>2015-11-06 08:45:37 +0100
commitd0408d75fd7ead8f36acc60155d49e236850f7ce (patch)
treefc91730f8860bfcb11cbbaae0f0083ce32ac0382 /src
parentb331a5bfe5e26f68099ecb5e02041b0260da24eb (diff)
Adds imap response string to custom command operation
Diffstat (limited to 'src')
-rwxr-xr-xsrc/async/imap/MCIMAPAsyncConnection.cpp1
-rw-r--r--src/async/imap/MCIMAPCustomCommandOperation.cpp16
-rw-r--r--src/async/imap/MCIMAPCustomCommandOperation.h2
-rwxr-xr-xsrc/core/imap/MCIMAPSession.cpp8
-rwxr-xr-xsrc/core/imap/MCIMAPSession.h2
-rw-r--r--src/objc/imap/MCOIMAPCustomCommandOperation.h2
-rw-r--r--src/objc/imap/MCOIMAPCustomCommandOperation.mm11
7 files changed, 26 insertions, 16 deletions
diff --git a/src/async/imap/MCIMAPAsyncConnection.cpp b/src/async/imap/MCIMAPAsyncConnection.cpp
index c03422ff..0dc29ee0 100755
--- a/src/async/imap/MCIMAPAsyncConnection.cpp
+++ b/src/async/imap/MCIMAPAsyncConnection.cpp
@@ -38,6 +38,7 @@
#include "MCIMAPAsyncSession.h"
#include "MCConnectionLogger.h"
#include "MCIMAPMessageRenderingOperation.h"
+#include "MCIMAPCustomCommandOperation.h"
#include "MCIMAPIdentity.h"
using namespace mailcore;
diff --git a/src/async/imap/MCIMAPCustomCommandOperation.cpp b/src/async/imap/MCIMAPCustomCommandOperation.cpp
index 692c8f7d..61e0e655 100644
--- a/src/async/imap/MCIMAPCustomCommandOperation.cpp
+++ b/src/async/imap/MCIMAPCustomCommandOperation.cpp
@@ -16,21 +16,27 @@ using namespace mailcore;
IMAPCustomCommandOperation::IMAPCustomCommandOperation()
{
mCustomCommand = NULL;
+ mResponse = NULL;
}
IMAPCustomCommandOperation::~IMAPCustomCommandOperation()
{
MC_SAFE_RELEASE(mCustomCommand);
+ MC_SAFE_RELEASE(mResponse);
}
-void IMAPCustomCommandOperation::setCustomCommand(mailcore::String * command)
+void IMAPCustomCommandOperation::setCustomCommand(String * command)
{
- mCustomCommand = command;
+ MC_SAFE_REPLACE_COPY(String, mCustomCommand, command);
}
-void IMAPCustomCommandOperation::main()
+String * IMAPCustomCommandOperation::response()
{
+ return mResponse;
+}
- session()->session()->sendCustomCommand(mCustomCommand);
-
+void IMAPCustomCommandOperation::main()
+{
+ mResponse = session()->session()->sendCustomCommand(mCustomCommand);
+ MC_SAFE_RETAIN(mResponse);
}
diff --git a/src/async/imap/MCIMAPCustomCommandOperation.h b/src/async/imap/MCIMAPCustomCommandOperation.h
index 83e6c11f..a2ce20fe 100644
--- a/src/async/imap/MCIMAPCustomCommandOperation.h
+++ b/src/async/imap/MCIMAPCustomCommandOperation.h
@@ -22,12 +22,14 @@ namespace mailcore {
virtual ~IMAPCustomCommandOperation();
virtual void setCustomCommand(String *command);
+ virtual String * response();
public: // subclass behavior
virtual void main();
private:
String * mCustomCommand;
+ String * mResponse;
};
}
diff --git a/src/core/imap/MCIMAPSession.cpp b/src/core/imap/MCIMAPSession.cpp
index 656168fa..69d80cc7 100755
--- a/src/core/imap/MCIMAPSession.cpp
+++ b/src/core/imap/MCIMAPSession.cpp
@@ -996,13 +996,11 @@ static uint64_t get_mod_sequence_value(mailimap * session)
return mod_sequence_value;
}
-void IMAPSession::sendCustomCommand(String * command)
+String * IMAPSession::sendCustomCommand(String * command)
{
- int r;
-
- MCLog("custom command");
-
mailimap_custom_command(mImap, MCUTF8(command));
+ String *response = String::stringWithUTF8Characters(mImap->imap_response);
+ return response;
}
void IMAPSession::select(String * folder, ErrorCode * pError)
diff --git a/src/core/imap/MCIMAPSession.h b/src/core/imap/MCIMAPSession.h
index 0447e372..8b1db9cb 100755
--- a/src/core/imap/MCIMAPSession.h
+++ b/src/core/imap/MCIMAPSession.h
@@ -107,7 +107,7 @@ namespace mailcore {
IndexSet * numbers,
IMAPProgressCallback * progressCallback,
Array * extraHeaders, ErrorCode * pError);
- virtual void sendCustomCommand(String * command);
+ virtual String * sendCustomCommand(String * command);
virtual Data * fetchMessageByUID(String * folder, uint32_t uid,
IMAPProgressCallback * progressCallback, ErrorCode * pError);
diff --git a/src/objc/imap/MCOIMAPCustomCommandOperation.h b/src/objc/imap/MCOIMAPCustomCommandOperation.h
index 87124533..e23d29e7 100644
--- a/src/objc/imap/MCOIMAPCustomCommandOperation.h
+++ b/src/objc/imap/MCOIMAPCustomCommandOperation.h
@@ -16,7 +16,7 @@
NS_ASSUME_NONNULL_BEGIN
@interface MCOIMAPCustomCommandOperation : MCOIMAPBaseOperation
-- (void)start:(void(^)(NSError * __nullable error))completionBlock;
+- (void)start:(void(^)(NSString * __nullable response, NSError * __nullable error))completionBlock;
@end
NS_ASSUME_NONNULL_END
diff --git a/src/objc/imap/MCOIMAPCustomCommandOperation.mm b/src/objc/imap/MCOIMAPCustomCommandOperation.mm
index a9193477..b4fb15a6 100644
--- a/src/objc/imap/MCOIMAPCustomCommandOperation.mm
+++ b/src/objc/imap/MCOIMAPCustomCommandOperation.mm
@@ -9,11 +9,12 @@
#import "MCOIMAPCustomCommandOperation.h"
#include "MCAsyncIMAP.h"
+#include "MCIMAPCustomCommandOperation.h"
#import "MCOOperation+Private.h"
#import "MCOUtils.h"
-typedef void (^CompletionType)(NSError *error);
+typedef void (^CompletionType)(NSString * __nullable response, NSError * __nullable error);
@implementation MCOIMAPCustomCommandOperation {
CompletionType _completionBlock;
@@ -38,7 +39,7 @@ typedef void (^CompletionType)(NSError *error);
[super dealloc];
}
-- (void)start:(void(^)(NSError * __nullable error))completionBlock
+- (void)start:(void(^)(NSString * __nullable response, NSError * __nullable error))completionBlock
{
_completionBlock = [completionBlock copy];
[self start];
@@ -58,9 +59,11 @@ typedef void (^CompletionType)(NSError *error);
nativeType *op = MCO_NATIVE_INSTANCE;
if (op->error() == mailcore::ErrorNone) {
- _completionBlock(nil);
+ NSString *response = [NSString mco_stringWithMCString:op->response()];
+ _completionBlock(response, nil);
} else {
- _completionBlock([NSError mco_errorWithErrorCode:op->error()]);
+ NSError *error = [NSError mco_errorWithErrorCode:op->error()];
+ _completionBlock(nil, error);
}
[_completionBlock release];
_completionBlock = nil;