aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/async/imap/MCIMAPFetchContentToFileOperation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/async/imap/MCIMAPFetchContentToFileOperation.cpp')
-rw-r--r--src/async/imap/MCIMAPFetchContentToFileOperation.cpp91
1 files changed, 91 insertions, 0 deletions
diff --git a/src/async/imap/MCIMAPFetchContentToFileOperation.cpp b/src/async/imap/MCIMAPFetchContentToFileOperation.cpp
new file mode 100644
index 00000000..82a1fa23
--- /dev/null
+++ b/src/async/imap/MCIMAPFetchContentToFileOperation.cpp
@@ -0,0 +1,91 @@
+//
+// IMAPFetchContentToFileOperation.cpp
+// mailcore2
+//
+// Created by Dmitry Isaikin on 2/08/16.
+// Copyright (c) 2016 MailCore. All rights reserved.
+//
+
+#include "MCIMAPFetchContentToFileOperation.h"
+
+#include "MCIMAPSession.h"
+#include "MCIMAPAsyncConnection.h"
+
+using namespace mailcore;
+
+IMAPFetchContentToFileOperation::IMAPFetchContentToFileOperation()
+{
+ mUid = 0;
+ mPartID = NULL;
+ mEncoding = Encoding7Bit;
+ mFilename = NULL;
+ mLoadingByChunksEnabled = true;
+ mChunksSize = 2*1024*1024;
+ mEstimatedSize = 0;
+}
+
+IMAPFetchContentToFileOperation::~IMAPFetchContentToFileOperation()
+{
+ MC_SAFE_RELEASE(mPartID);
+ MC_SAFE_RELEASE(mFilename);
+}
+
+void IMAPFetchContentToFileOperation::setUid(uint32_t uid)
+{
+ mUid = uid;
+}
+
+void IMAPFetchContentToFileOperation::setPartID(String * partID)
+{
+ MC_SAFE_REPLACE_COPY(String, mPartID, partID);
+}
+
+void IMAPFetchContentToFileOperation::setEncoding(Encoding encoding)
+{
+ mEncoding = encoding;
+}
+
+void IMAPFetchContentToFileOperation::setFilename(String * filename)
+{
+ MC_SAFE_REPLACE_COPY(String, mFilename, filename);
+}
+
+void IMAPFetchContentToFileOperation::setLoadingByChunksEnabled(bool loadingByChunksEnabled)
+{
+ mLoadingByChunksEnabled = loadingByChunksEnabled;
+}
+
+bool IMAPFetchContentToFileOperation::isLoadingByChunksEnabled()
+{
+ return mLoadingByChunksEnabled;
+}
+
+void IMAPFetchContentToFileOperation::setChunksSize(uint32_t chunksSize)
+{
+ mChunksSize = chunksSize;
+}
+
+uint32_t IMAPFetchContentToFileOperation::chunksSize()
+{
+ return mChunksSize;
+}
+
+void IMAPFetchContentToFileOperation::setEstimatedSize(uint32_t estimatedSize)
+{
+ mEstimatedSize = estimatedSize;
+}
+
+uint32_t IMAPFetchContentToFileOperation::estimatedSize()
+{
+ return mEstimatedSize;
+}
+
+void IMAPFetchContentToFileOperation::main()
+{
+ ErrorCode error = ErrorNone;
+ session()->session()->fetchMessageAttachmentToFileByUID(folder(), mUid, mPartID,
+ mEstimatedSize, mEncoding,
+ mFilename, mChunksSize,
+ this, &error);
+ setError(error);
+}