From fdb0bc090dcde12cc960305354f2e978f1746d7e Mon Sep 17 00:00:00 2001 From: Farnabaz Date: Fri, 8 Jun 2018 16:55:35 +0430 Subject: [PATCH] feat(IMAPSession): add support for moveMessagesOpeation to java library --- .../IMAPMoveMessagesOperation.java | 12 ++++++++++ src/java/com/libmailcore/IMAPSession.java | 3 +++ ..._libmailcore_IMAPMoveMessagesOperation.cpp | 22 ++++++++++++++++++ ...om_libmailcore_IMAPMoveMessagesOperation.h | 23 +++++++++++++++++++ .../native/com_libmailcore_IMAPSession.cpp | 10 ++++++++ src/java/native/com_libmailcore_IMAPSession.h | 8 +++++++ 6 files changed, 78 insertions(+) create mode 100644 src/java/com/libmailcore/IMAPMoveMessagesOperation.java create mode 100644 src/java/native/com_libmailcore_IMAPMoveMessagesOperation.cpp create mode 100644 src/java/native/com_libmailcore_IMAPMoveMessagesOperation.h diff --git a/src/java/com/libmailcore/IMAPMoveMessagesOperation.java b/src/java/com/libmailcore/IMAPMoveMessagesOperation.java new file mode 100644 index 000000000..eab74818e --- /dev/null +++ b/src/java/com/libmailcore/IMAPMoveMessagesOperation.java @@ -0,0 +1,12 @@ +package com.libmailcore; + +import java.util.Map; + +/** Operation to move IMAP messages. */ +public class IMAPMoveMessagesOperation extends IMAPOperation { + /** + Returns a map of the UIDs of the messages in the source folder to the UIDs of + the messages in the destination folder. + */ + public native Map uidMapping(); +} diff --git a/src/java/com/libmailcore/IMAPSession.java b/src/java/com/libmailcore/IMAPSession.java index 27ab84610..b59453081 100644 --- a/src/java/com/libmailcore/IMAPSession.java +++ b/src/java/com/libmailcore/IMAPSession.java @@ -160,6 +160,9 @@ public IMAPAppendMessageOperation appendMessageOperation(String folder, byte[] m /** Returns an operation to copy messages to a folder. */ public native IMAPCopyMessagesOperation copyMessagesOperation(String folder, IndexSet uids, String destFolder); + /** Returns an operation to move messages to a folder. */ + public native IMAPMoveMessagesOperation moveMessagesOperation(String folder, IndexSet uids, String destFolder); + /** Returns an operation to expunge messages after they've been marked as deleted. */ public native IMAPOperation expungeOperation(String folder); diff --git a/src/java/native/com_libmailcore_IMAPMoveMessagesOperation.cpp b/src/java/native/com_libmailcore_IMAPMoveMessagesOperation.cpp new file mode 100644 index 000000000..be6f974b4 --- /dev/null +++ b/src/java/native/com_libmailcore_IMAPMoveMessagesOperation.cpp @@ -0,0 +1,22 @@ +#include "com_libmailcore_IMAPMoveMessagesOperation.h" + +#include "MCBaseTypes.h" +#include "JavaHandle.h" +#include "TypesUtils.h" +#include "MCIMAPMoveMessagesOperation.h" + +using namespace mailcore; + +#define nativeType IMAPMoveMessagesOperation +#define javaType nativeType + +JNIEXPORT jobject JNICALL Java_com_libmailcore_IMAPMoveMessagesOperation_uidMapping + (JNIEnv * env, jobject obj) +{ + MC_POOL_BEGIN; + jobject result = MC_JAVA_BRIDGE_GET(uidMapping); + MC_POOL_END; + return result; +} + +MC_JAVA_BRIDGE diff --git a/src/java/native/com_libmailcore_IMAPMoveMessagesOperation.h b/src/java/native/com_libmailcore_IMAPMoveMessagesOperation.h new file mode 100644 index 000000000..d4dede646 --- /dev/null +++ b/src/java/native/com_libmailcore_IMAPMoveMessagesOperation.h @@ -0,0 +1,23 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class com_libmailcore_IMAPMoveMessagesOperation */ + +#ifndef _Included_com_libmailcore_IMAPMoveMessagesOperation +#define _Included_com_libmailcore_IMAPMoveMessagesOperation +#ifdef __cplusplus +extern "C" { +#endif +#undef com_libmailcore_IMAPMoveMessagesOperation_serialVersionUID +#define com_libmailcore_IMAPMoveMessagesOperation_serialVersionUID 1LL +/* + * Class: com_libmailcore_IMAPMoveMessagesOperation + * Method: uidMapping + * Signature: ()Ljava/util/Map; + */ +JNIEXPORT jobject JNICALL Java_com_libmailcore_IMAPMoveMessagesOperation_uidMapping + (JNIEnv *, jobject); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/java/native/com_libmailcore_IMAPSession.cpp b/src/java/native/com_libmailcore_IMAPSession.cpp index 59422f35f..8be3a37f4 100644 --- a/src/java/native/com_libmailcore_IMAPSession.cpp +++ b/src/java/native/com_libmailcore_IMAPSession.cpp @@ -175,6 +175,16 @@ JNIEXPORT jobject JNICALL Java_com_libmailcore_IMAPSession_copyMessagesOperation return result; } +JNIEXPORT jobject JNICALL Java_com_libmailcore_IMAPSession_moveMessagesOperation + (JNIEnv * env, jobject obj, jstring sourcePath, jobject uids, jstring destPath) +{ + MC_POOL_BEGIN; + jobject result = MC_TO_JAVA(MC_JAVA_NATIVE_INSTANCE->moveMessagesOperation(MC_FROM_JAVA(String, sourcePath), + MC_FROM_JAVA(IndexSet, uids), MC_FROM_JAVA(String, destPath))); + MC_POOL_END; + return result; +} + JNIEXPORT jobject JNICALL Java_com_libmailcore_IMAPSession_expungeOperation (JNIEnv * env, jobject obj, jstring path) { diff --git a/src/java/native/com_libmailcore_IMAPSession.h b/src/java/native/com_libmailcore_IMAPSession.h index 8d6ee73cb..2ed1f374e 100644 --- a/src/java/native/com_libmailcore_IMAPSession.h +++ b/src/java/native/com_libmailcore_IMAPSession.h @@ -329,6 +329,14 @@ JNIEXPORT jobject JNICALL Java_com_libmailcore_IMAPSession_appendMessageOperatio JNIEXPORT jobject JNICALL Java_com_libmailcore_IMAPSession_copyMessagesOperation (JNIEnv *, jobject, jstring, jobject, jstring); +/* + * Class: com_libmailcore_IMAPSession + * Method: moveMessagesOperation + * Signature: (Ljava/lang/String;Lcom/libmailcore/IndexSet;Ljava/lang/String;)Lcom/libmailcore/IMAPMoveMessagesOperation; + */ +JNIEXPORT jobject JNICALL Java_com_libmailcore_IMAPSession_moveMessagesOperation + (JNIEnv *, jobject, jstring, jobject, jstring); + /* * Class: com_libmailcore_IMAPSession * Method: expungeOperation