diff options
author | Hoa V. Dinh <dinh.viet.hoa@gmail.com> | 2015-07-13 15:33:07 -0700 |
---|---|---|
committer | Hoa V. Dinh <dinh.viet.hoa@gmail.com> | 2015-07-13 15:33:07 -0700 |
commit | 89f75cec935430b410e1c3e26ce884548a834afa (patch) | |
tree | 713b8a887a2ee7052743c4c80dc5ec7d283aee33 | |
parent | 1eace1dc1c2e181988c77ceb8ec83918572bf9d1 (diff) |
Fixed #1164: merged #1169 manually. Fixed zipping on iOS device, running with sandbox.
-rwxr-xr-x | build-mac/mailcore2.xcodeproj/project.pbxproj | 8 | ||||
-rw-r--r-- | src/cmake/core.cmake | 5 | ||||
-rw-r--r-- | src/core/zip/MCZip.cpp | 19 | ||||
-rw-r--r-- | unittest/unittest.cpp | 4 |
4 files changed, 30 insertions, 6 deletions
diff --git a/build-mac/mailcore2.xcodeproj/project.pbxproj b/build-mac/mailcore2.xcodeproj/project.pbxproj index 8126042e..5bb57df9 100755 --- a/build-mac/mailcore2.xcodeproj/project.pbxproj +++ b/build-mac/mailcore2.xcodeproj/project.pbxproj @@ -178,6 +178,8 @@ BD6272981A13FF2A00129AA8 /* test-all-mac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BD6272961A13FF2A00129AA8 /* test-all-mac.mm */; }; BD6272991A13FF2A00129AA8 /* test-all-mac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BD6272961A13FF2A00129AA8 /* test-all-mac.mm */; }; BD63713B177DFF080094121B /* MCLibetpan.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BD637139177DFF080094121B /* MCLibetpan.cpp */; }; + BD7C0F461B545CE2003337DF /* MCZipMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BD7C0F451B545CE2003337DF /* MCZipMac.mm */; }; + BD7C0F471B545CE2003337DF /* MCZipMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BD7C0F451B545CE2003337DF /* MCZipMac.mm */; }; BDCD7C5B1A5B1C2C0001DCC3 /* MCErrorMessage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BDCD7C591A5B1C2C0001DCC3 /* MCErrorMessage.cpp */; }; BDCD7C5C1A5B1C2C0001DCC3 /* MCErrorMessage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BDCD7C591A5B1C2C0001DCC3 /* MCErrorMessage.cpp */; }; BDCD7CC31A70771B0001DCC3 /* csdetect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BDCD7C6A1A70771B0001DCC3 /* csdetect.cpp */; }; @@ -1563,6 +1565,8 @@ BD62729C1A158DA900129AA8 /* MCWin32.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCWin32.h; sourceTree = "<group>"; }; BD637139177DFF080094121B /* MCLibetpan.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MCLibetpan.cpp; sourceTree = "<group>"; }; BD63713A177DFF080094121B /* MCLibetpan.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCLibetpan.h; sourceTree = "<group>"; }; + BD7C0F451B545CE2003337DF /* MCZipMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MCZipMac.mm; sourceTree = "<group>"; }; + BD7C0F481B545D0B003337DF /* MCZipPrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MCZipPrivate.h; sourceTree = "<group>"; }; BDCD7C591A5B1C2C0001DCC3 /* MCErrorMessage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MCErrorMessage.cpp; sourceTree = "<group>"; }; BDCD7C5A1A5B1C2C0001DCC3 /* MCErrorMessage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCErrorMessage.h; sourceTree = "<group>"; }; BDCD7C6A1A70771B0001DCC3 /* csdetect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = csdetect.cpp; sourceTree = "<group>"; }; @@ -2947,6 +2951,8 @@ C6E665A91796500B0063F2CF /* zip */ = { isa = PBXGroup; children = ( + BD7C0F481B545D0B003337DF /* MCZipPrivate.h */, + BD7C0F451B545CE2003337DF /* MCZipMac.mm */, C6E665AA1796500B0063F2CF /* MCZip.cpp */, C6E665AB1796500B0063F2CF /* MCZip.h */, C6E665AC1796500B0063F2CF /* MiniZip */, @@ -3644,6 +3650,7 @@ C6CF62B9175324CE006398B9 /* MCOMailProvider.mm in Sources */, C6CF62BB175324CE006398B9 /* MCOMailProvidersManager.mm in Sources */, 84D7378F199C02A8005124E5 /* MCONNTPDisconnectOperation.mm in Sources */, + BD7C0F461B545CE2003337DF /* MCZipMac.mm in Sources */, C6CF62BD175324CE006398B9 /* MCONetService.mm in Sources */, C6EFFBCC1833334900CFF656 /* MCOIMAPMultiDisconnectOperation.mm in Sources */, C6CF62C6175324F0006398B9 /* MCMailProvider.cpp in Sources */, @@ -3915,6 +3922,7 @@ C668E2CD1735CB8900A2BB47 /* MCAutoreleasePoolMac.mm in Sources */, C6CF62BA175324CE006398B9 /* MCOMailProvider.mm in Sources */, C6CF62BC175324CE006398B9 /* MCOMailProvidersManager.mm in Sources */, + BD7C0F471B545CE2003337DF /* MCZipMac.mm in Sources */, 84D73790199C02A8005124E5 /* MCONNTPDisconnectOperation.mm in Sources */, C6CF62BE175324CE006398B9 /* MCONetService.mm in Sources */, C6EFFBCD1833334900CFF656 /* MCOIMAPMultiDisconnectOperation.mm in Sources */, diff --git a/src/cmake/core.cmake b/src/cmake/core.cmake index ac2e6ea8..963b02ce 100644 --- a/src/cmake/core.cmake +++ b/src/cmake/core.cmake @@ -19,6 +19,10 @@ IF(APPLE) core/rfc822/MCMessageParserMac.mm ) + set(zip_files_apple + core/zip/MCZipMac.mm + ) + set(core_includes_apple "${CMAKE_CURRENT_SOURCE_DIR}/core/basetypes/icu-ucsdet" "${CMAKE_CURRENT_SOURCE_DIR}/core/basetypes/icu-ucsdet/include" @@ -149,6 +153,7 @@ set(zip_files core/zip/MiniZip/ioapi.c core/zip/MiniZip/unzip.c core/zip/MiniZip/zip.c + ${zip_files_apple} ) set(security_files diff --git a/src/core/zip/MCZip.cpp b/src/core/zip/MCZip.cpp index a9879c9f..69e7fc6e 100644 --- a/src/core/zip/MCZip.cpp +++ b/src/core/zip/MCZip.cpp @@ -1,6 +1,7 @@ #include "MCWin32.h" // Should be included first. #include "MCZip.h" +#include "MCZipPrivate.h" #include "zip.h" #include "unzip.h" @@ -166,23 +167,33 @@ static ErrorCode addFile(zipFile file, String * path) return ErrorNone; } -String * mailcore::CreateTemporaryZipFileFromFolder(String * folder) +#ifndef __APPLE__ +String * mailcore::TemporaryDirectoryForZip() { char tempdir[] = "/tmp/mailcore2-XXXXXX"; char * result = mkdtemp(tempdir); if (result == NULL) { return NULL; } + return String::stringWithFileSystemRepresentation(tempdir); +} +#endif + +String * mailcore::CreateTemporaryZipFileFromFolder(String * folder) +{ + String * tempDirectoryString = TemporaryDirectoryForZip(); + + if (tempDirectoryString == NULL) { + return NULL; + } - String * tempDirectoryString = String::stringWithFileSystemRepresentation(tempdir); String * path = tempDirectoryString->stringByAppendingPathComponent(folder->lastPathComponent())->stringByAppendingUTF8Format(".zip"); ErrorCode err = CreateZipFileFromFolder(path, folder); if (err != ErrorNone) { - unlink(path->fileSystemRepresentation()); - unlink(tempdir); return NULL; } + unlink(tempDirectoryString->fileSystemRepresentation()); return path; } diff --git a/unittest/unittest.cpp b/unittest/unittest.cpp index f2368810..8db7cc04 100644 --- a/unittest/unittest.cpp +++ b/unittest/unittest.cpp @@ -167,11 +167,11 @@ static Array * pathsInDirectory(String * directory) static void prepareHeaderForUnitTest(MessageHeader * header) { time_t now = time(NULL); - if (fabs(now - header->date()) <= 2) { + if (fabs((double) (now - header->date())) <= 2) { // Date might be generated, set to known date. header->setDate(referenceDate()); } - if (fabs(header->receivedDate() - now) <= 2) { + if (fabs((double) (header->receivedDate() - now)) <= 2) { // Date might be generated, set to known date. header->setReceivedDate(referenceDate()); } |