aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Hoa V. DINH <dinh.viet.hoa@gmail.com>2013-04-16 21:42:58 -0700
committerGravatar Hoa V. DINH <dinh.viet.hoa@gmail.com>2013-04-16 21:42:58 -0700
commitf88e4fef5085f72f92d25687e9045fc5a7951688 (patch)
treecb10c9866c6167f79a71d5bdb69ff9b1ca14fa5e
parent4dd70e05283c79fabae6d47ca10802c9371330d3 (diff)
Added support for MD5, JSON
-rw-r--r--.gitmodules3
-rw-r--r--build-mac/mailcore2.xcodeproj/project.pbxproj243
-rw-r--r--src/core/basetypes/MCBaseTypes.h3
-rw-r--r--src/core/basetypes/MCJSON.cpp250
-rw-r--r--src/core/basetypes/MCJSON.h50
-rw-r--r--src/core/basetypes/MCMD5.cpp233
-rw-r--r--src/core/basetypes/MCMD5.h20
-rw-r--r--src/core/basetypes/MCNull.cpp19
-rw-r--r--src/core/basetypes/MCNull.h23
m---------submodules/libjson0
10 files changed, 844 insertions, 0 deletions
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 00000000..7aec2ce0
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "submodules/libjson"]
+ path = submodules/libjson
+ url = git://github.com/dinhviethoa/libjson.git
diff --git a/build-mac/mailcore2.xcodeproj/project.pbxproj b/build-mac/mailcore2.xcodeproj/project.pbxproj
index 7ae406ef..e3d02a20 100644
--- a/build-mac/mailcore2.xcodeproj/project.pbxproj
+++ b/build-mac/mailcore2.xcodeproj/project.pbxproj
@@ -540,6 +540,46 @@
C6D42C1E16AE03D6002BB4F9 /* NSString+MCO.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6D42C1C16AE03D6002BB4F9 /* NSString+MCO.mm */; };
C6D42C2A16AE0507002BB4F9 /* NSData+MCO.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6D42C1916AE03D6002BB4F9 /* NSData+MCO.h */; };
C6D42C2C16AE0509002BB4F9 /* NSString+MCO.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6D42C1B16AE03D6002BB4F9 /* NSString+MCO.h */; };
+ C6D6F7F9171E595D006F5B28 /* MCJSON.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D6F7F7171E595D006F5B28 /* MCJSON.cpp */; };
+ C6D6F7FA171E595D006F5B28 /* MCJSON.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D6F7F7171E595D006F5B28 /* MCJSON.cpp */; };
+ C6D6F8C3171E5C2C006F5B28 /* internalJSONNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D6F807171E5C2C006F5B28 /* internalJSONNode.cpp */; };
+ C6D6F8C4171E5C2C006F5B28 /* internalJSONNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D6F807171E5C2C006F5B28 /* internalJSONNode.cpp */; };
+ C6D6F8C5171E5C2C006F5B28 /* JSONAllocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D6F80A171E5C2C006F5B28 /* JSONAllocator.cpp */; };
+ C6D6F8C6171E5C2C006F5B28 /* JSONAllocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D6F80A171E5C2C006F5B28 /* JSONAllocator.cpp */; };
+ C6D6F8C7171E5C2C006F5B28 /* JSONChildren.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D6F80C171E5C2C006F5B28 /* JSONChildren.cpp */; };
+ C6D6F8C8171E5C2C006F5B28 /* JSONChildren.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D6F80C171E5C2C006F5B28 /* JSONChildren.cpp */; };
+ C6D6F8C9171E5C2C006F5B28 /* JSONDebug.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D6F80E171E5C2C006F5B28 /* JSONDebug.cpp */; };
+ C6D6F8CA171E5C2C006F5B28 /* JSONDebug.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D6F80E171E5C2C006F5B28 /* JSONDebug.cpp */; };
+ C6D6F8CB171E5C2C006F5B28 /* JSONIterators.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D6F817171E5C2C006F5B28 /* JSONIterators.cpp */; };
+ C6D6F8CC171E5C2C006F5B28 /* JSONIterators.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D6F817171E5C2C006F5B28 /* JSONIterators.cpp */; };
+ C6D6F8CD171E5C2C006F5B28 /* JSONMemory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D6F818171E5C2C006F5B28 /* JSONMemory.cpp */; };
+ C6D6F8CE171E5C2C006F5B28 /* JSONMemory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D6F818171E5C2C006F5B28 /* JSONMemory.cpp */; };
+ C6D6F8CF171E5C2C006F5B28 /* JSONNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D6F81B171E5C2C006F5B28 /* JSONNode.cpp */; };
+ C6D6F8D0171E5C2C006F5B28 /* JSONNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D6F81B171E5C2C006F5B28 /* JSONNode.cpp */; };
+ C6D6F8D1171E5C2C006F5B28 /* JSONNode_Mutex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D6F81D171E5C2C006F5B28 /* JSONNode_Mutex.cpp */; };
+ C6D6F8D2171E5C2C006F5B28 /* JSONNode_Mutex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D6F81D171E5C2C006F5B28 /* JSONNode_Mutex.cpp */; };
+ C6D6F8D3171E5C2C006F5B28 /* JSONPreparse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D6F81E171E5C2C006F5B28 /* JSONPreparse.cpp */; };
+ C6D6F8D4171E5C2C006F5B28 /* JSONPreparse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D6F81E171E5C2C006F5B28 /* JSONPreparse.cpp */; };
+ C6D6F8D5171E5C2C006F5B28 /* JSONStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D6F823171E5C2C006F5B28 /* JSONStream.cpp */; };
+ C6D6F8D6171E5C2C006F5B28 /* JSONStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D6F823171E5C2C006F5B28 /* JSONStream.cpp */; };
+ C6D6F8D7171E5C2C006F5B28 /* JSONValidator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D6F825171E5C2C006F5B28 /* JSONValidator.cpp */; };
+ C6D6F8D8171E5C2C006F5B28 /* JSONValidator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D6F825171E5C2C006F5B28 /* JSONValidator.cpp */; };
+ C6D6F8D9171E5C2C006F5B28 /* JSONWorker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D6F827171E5C2C006F5B28 /* JSONWorker.cpp */; };
+ C6D6F8DA171E5C2C006F5B28 /* JSONWorker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D6F827171E5C2C006F5B28 /* JSONWorker.cpp */; };
+ C6D6F8DB171E5C2C006F5B28 /* JSONWriter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D6F829171E5C2C006F5B28 /* JSONWriter.cpp */; };
+ C6D6F8DC171E5C2C006F5B28 /* JSONWriter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D6F829171E5C2C006F5B28 /* JSONWriter.cpp */; };
+ C6D6F8DD171E5C2C006F5B28 /* libjson.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D6F82A171E5C2C006F5B28 /* libjson.cpp */; };
+ C6D6F8DE171E5C2C006F5B28 /* libjson.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D6F82A171E5C2C006F5B28 /* libjson.cpp */; };
+ C6D6F954171E5CB8006F5B28 /* MCMD5.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D6F950171E5CB8006F5B28 /* MCMD5.cpp */; };
+ C6D6F955171E5CB8006F5B28 /* MCMD5.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D6F950171E5CB8006F5B28 /* MCMD5.cpp */; };
+ C6D6F956171E5CB8006F5B28 /* MCNull.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D6F952171E5CB8006F5B28 /* MCNull.cpp */; };
+ C6D6F957171E5CB8006F5B28 /* MCNull.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D6F952171E5CB8006F5B28 /* MCNull.cpp */; };
+ C6D6F958171E5D5C006F5B28 /* MCNull.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6D6F953171E5CB8006F5B28 /* MCNull.h */; };
+ C6D6F959171E5D5E006F5B28 /* MCMD5.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6D6F951171E5CB8006F5B28 /* MCMD5.h */; };
+ C6D6F95A171E5D60006F5B28 /* MCJSON.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6D6F7F8171E595D006F5B28 /* MCJSON.h */; };
+ C6D6F95B171E5D63006F5B28 /* MCNull.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6D6F953171E5CB8006F5B28 /* MCNull.h */; };
+ C6D6F95C171E5D65006F5B28 /* MCJSON.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6D6F7F8171E595D006F5B28 /* MCJSON.h */; };
+ C6D6F95D171E5D67006F5B28 /* MCMD5.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6D6F951171E5CB8006F5B28 /* MCMD5.h */; };
C6EB30DE16B5B8050091F4F1 /* MCObjC.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6EB30DC16B5B7770091F4F1 /* MCObjC.h */; };
C6EB30F716B8C9480091F4F1 /* NSDictionary+MCO.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6EB30F616B8C9480091F4F1 /* NSDictionary+MCO.mm */; };
C6EB30F816B8DED30091F4F1 /* NSDictionary+MCO.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6EB30F516B8C9480091F4F1 /* NSDictionary+MCO.h */; };
@@ -651,10 +691,13 @@
C6F61FAD170288610073032E /* MCOAttachment.h in CopyFiles */,
C6F61FAF170288660073032E /* MCOMessageParser.h in CopyFiles */,
C6F61FB0170288680073032E /* MCOMessagePart.h in CopyFiles */,
+ C6D6F959171E5D5E006F5B28 /* MCMD5.h in CopyFiles */,
C6F61FA0170187B80073032E /* MCOIMAPFolderInfoOperation.h in CopyFiles */,
C6F61FA4170187C30073032E /* MCOIMAPFetchMessagesOperation.h in CopyFiles */,
C6F61FA3170187BD0073032E /* MCOIMAPCopyMessagesOperation.h in CopyFiles */,
+ C6D6F95A171E5D60006F5B28 /* MCJSON.h in CopyFiles */,
C6F61FA2170187BC0073032E /* MCOIMAPAppendMessageOperation.h in CopyFiles */,
+ C6D6F958171E5D5C006F5B28 /* MCNull.h in CopyFiles */,
C6F61FAB170187CE0073032E /* MCOIMAPSearchExpression.h in CopyFiles */,
C6F61FA5170187C50073032E /* MCOIMAPFetchContentOperation.h in CopyFiles */,
C6CCC5CA16FFEA090077A5FC /* MCOIndexSet.h in CopyFiles */,
@@ -821,10 +864,13 @@
C6BA2B121705F4E6003F0E9E /* MCOAttachment.h in CopyFiles */,
C6BA2B131705F4E6003F0E9E /* MCOMessageParser.h in CopyFiles */,
C6BA2B141705F4E6003F0E9E /* MCOMessagePart.h in CopyFiles */,
+ C6D6F95C171E5D65006F5B28 /* MCJSON.h in CopyFiles */,
C6BA2B151705F4E6003F0E9E /* MCOIMAPFolderInfoOperation.h in CopyFiles */,
C6BA2B161705F4E6003F0E9E /* MCOIMAPFetchMessagesOperation.h in CopyFiles */,
C6BA2B171705F4E6003F0E9E /* MCOIMAPCopyMessagesOperation.h in CopyFiles */,
+ C6D6F95D171E5D67006F5B28 /* MCMD5.h in CopyFiles */,
C6BA2B181705F4E6003F0E9E /* MCOIMAPAppendMessageOperation.h in CopyFiles */,
+ C6D6F95B171E5D63006F5B28 /* MCNull.h in CopyFiles */,
C6BA2B191705F4E6003F0E9E /* MCOIMAPSearchExpression.h in CopyFiles */,
C6BA2B1A1705F4E6003F0E9E /* MCOIMAPFetchContentOperation.h in CopyFiles */,
C6BA2B1B1705F4E6003F0E9E /* MCOIndexSet.h in CopyFiles */,
@@ -1237,6 +1283,52 @@
C6D42C1A16AE03D6002BB4F9 /* NSData+MCO.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "NSData+MCO.mm"; sourceTree = "<group>"; };
C6D42C1B16AE03D6002BB4F9 /* NSString+MCO.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+MCO.h"; sourceTree = "<group>"; };
C6D42C1C16AE03D6002BB4F9 /* NSString+MCO.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "NSString+MCO.mm"; sourceTree = "<group>"; };
+ C6D6F7F7171E595D006F5B28 /* MCJSON.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MCJSON.cpp; sourceTree = "<group>"; };
+ C6D6F7F8171E595D006F5B28 /* MCJSON.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCJSON.h; sourceTree = "<group>"; };
+ C6D6F803171E5C2C006F5B28 /* libbase64++.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "libbase64++.h"; sourceTree = "<group>"; };
+ C6D6F805171E5C2C006F5B28 /* mempool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mempool.h; sourceTree = "<group>"; };
+ C6D6F807171E5C2C006F5B28 /* internalJSONNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = internalJSONNode.cpp; sourceTree = "<group>"; };
+ C6D6F808171E5C2C006F5B28 /* internalJSONNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = internalJSONNode.h; sourceTree = "<group>"; };
+ C6D6F809171E5C2C006F5B28 /* JSON_Base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSON_Base64.h; sourceTree = "<group>"; };
+ C6D6F80A171E5C2C006F5B28 /* JSONAllocator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSONAllocator.cpp; sourceTree = "<group>"; };
+ C6D6F80B171E5C2C006F5B28 /* JSONAllocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSONAllocator.h; sourceTree = "<group>"; };
+ C6D6F80C171E5C2C006F5B28 /* JSONChildren.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSONChildren.cpp; sourceTree = "<group>"; };
+ C6D6F80D171E5C2C006F5B28 /* JSONChildren.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSONChildren.h; sourceTree = "<group>"; };
+ C6D6F80E171E5C2C006F5B28 /* JSONDebug.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSONDebug.cpp; sourceTree = "<group>"; };
+ C6D6F80F171E5C2C006F5B28 /* JSONDebug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSONDebug.h; sourceTree = "<group>"; };
+ C6D6F811171E5C2C006F5B28 /* GNU_C.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GNU_C.h; sourceTree = "<group>"; };
+ C6D6F812171E5C2C006F5B28 /* Strings_Defs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Strings_Defs.h; sourceTree = "<group>"; };
+ C6D6F813171E5C2C006F5B28 /* Unknown_C.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Unknown_C.h; sourceTree = "<group>"; };
+ C6D6F814171E5C2C006F5B28 /* Visual_C.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Visual_C.h; sourceTree = "<group>"; };
+ C6D6F815171E5C2C006F5B28 /* JSONDefs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSONDefs.h; sourceTree = "<group>"; };
+ C6D6F816171E5C2C006F5B28 /* JSONGlobals.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSONGlobals.h; sourceTree = "<group>"; };
+ C6D6F817171E5C2C006F5B28 /* JSONIterators.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSONIterators.cpp; sourceTree = "<group>"; };
+ C6D6F818171E5C2C006F5B28 /* JSONMemory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSONMemory.cpp; sourceTree = "<group>"; };
+ C6D6F819171E5C2C006F5B28 /* JSONMemory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSONMemory.h; sourceTree = "<group>"; };
+ C6D6F81A171E5C2C006F5B28 /* JSONMemoryPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSONMemoryPool.h; sourceTree = "<group>"; };
+ C6D6F81B171E5C2C006F5B28 /* JSONNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSONNode.cpp; sourceTree = "<group>"; };
+ C6D6F81C171E5C2C006F5B28 /* JSONNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSONNode.h; sourceTree = "<group>"; };
+ C6D6F81D171E5C2C006F5B28 /* JSONNode_Mutex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSONNode_Mutex.cpp; sourceTree = "<group>"; };
+ C6D6F81E171E5C2C006F5B28 /* JSONPreparse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSONPreparse.cpp; sourceTree = "<group>"; };
+ C6D6F81F171E5C2C006F5B28 /* JSONPreparse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSONPreparse.h; sourceTree = "<group>"; };
+ C6D6F820171E5C2C006F5B28 /* JSONSharedString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSONSharedString.h; sourceTree = "<group>"; };
+ C6D6F821171E5C2C006F5B28 /* JSONSingleton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSONSingleton.h; sourceTree = "<group>"; };
+ C6D6F822171E5C2C006F5B28 /* JSONStats.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSONStats.h; sourceTree = "<group>"; };
+ C6D6F823171E5C2C006F5B28 /* JSONStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSONStream.cpp; sourceTree = "<group>"; };
+ C6D6F824171E5C2C006F5B28 /* JSONStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSONStream.h; sourceTree = "<group>"; };
+ C6D6F825171E5C2C006F5B28 /* JSONValidator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSONValidator.cpp; sourceTree = "<group>"; };
+ C6D6F826171E5C2C006F5B28 /* JSONValidator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSONValidator.h; sourceTree = "<group>"; };
+ C6D6F827171E5C2C006F5B28 /* JSONWorker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSONWorker.cpp; sourceTree = "<group>"; };
+ C6D6F828171E5C2C006F5B28 /* JSONWorker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSONWorker.h; sourceTree = "<group>"; };
+ C6D6F829171E5C2C006F5B28 /* JSONWriter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSONWriter.cpp; sourceTree = "<group>"; };
+ C6D6F82A171E5C2C006F5B28 /* libjson.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = libjson.cpp; sourceTree = "<group>"; };
+ C6D6F82B171E5C2C006F5B28 /* NumberToString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NumberToString.h; sourceTree = "<group>"; };
+ C6D6F8BE171E5C2C006F5B28 /* JSONOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSONOptions.h; sourceTree = "<group>"; };
+ C6D6F8BF171E5C2C006F5B28 /* libjson.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = libjson.h; sourceTree = "<group>"; };
+ C6D6F950171E5CB8006F5B28 /* MCMD5.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MCMD5.cpp; sourceTree = "<group>"; };
+ C6D6F951171E5CB8006F5B28 /* MCMD5.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCMD5.h; sourceTree = "<group>"; };
+ C6D6F952171E5CB8006F5B28 /* MCNull.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MCNull.cpp; sourceTree = "<group>"; };
+ C6D6F953171E5CB8006F5B28 /* MCNull.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCNull.h; sourceTree = "<group>"; };
C6EB30DC16B5B7770091F4F1 /* MCObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCObjC.h; sourceTree = "<group>"; };
C6EB30F516B8C9480091F4F1 /* NSDictionary+MCO.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDictionary+MCO.h"; sourceTree = "<group>"; };
C6EB30F616B8C9480091F4F1 /* NSDictionary+MCO.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "NSDictionary+MCO.mm"; sourceTree = "<group>"; };
@@ -1410,6 +1502,7 @@
isa = PBXGroup;
children = (
C6BD28A1170BD78E00A91AC1 /* mailcore-framework */,
+ C6D6F7FC171E5C2C006F5B28 /* submodules */,
C64EA545169E78B100778456 /* src */,
C64EA7A916A00AF400778456 /* tests */,
C6A81BB517068C0600882C15 /* tests-ios */,
@@ -1598,8 +1691,14 @@
C64EA6AC169E847800778456 /* MCHash.h */,
C64EA6AD169E847800778456 /* MCHashMap.cc */,
C64EA6AE169E847800778456 /* MCHashMap.h */,
+ C6D6F7F7171E595D006F5B28 /* MCJSON.cpp */,
+ C6D6F7F8171E595D006F5B28 /* MCJSON.h */,
+ C6D6F950171E5CB8006F5B28 /* MCMD5.cpp */,
+ C6D6F951171E5CB8006F5B28 /* MCMD5.h */,
C64EA6AF169E847800778456 /* MCLog.cc */,
C64EA6B0169E847800778456 /* MCLog.h */,
+ C6D6F952171E5CB8006F5B28 /* MCNull.cpp */,
+ C6D6F953171E5CB8006F5B28 /* MCNull.h */,
C64EA6B1169E847800778456 /* MCObject.cc */,
C64EA6B2169E847800778456 /* MCObject.h */,
C64EA6B3169E847800778456 /* MCRange.cc */,
@@ -1802,6 +1901,110 @@
path = utils;
sourceTree = "<group>";
};
+ C6D6F7FC171E5C2C006F5B28 /* submodules */ = {
+ isa = PBXGroup;
+ children = (
+ C6D6F7FD171E5C2C006F5B28 /* libjson */,
+ );
+ name = submodules;
+ path = ../submodules;
+ sourceTree = "<group>";
+ };
+ C6D6F7FD171E5C2C006F5B28 /* libjson */ = {
+ isa = PBXGroup;
+ children = (
+ C6D6F800171E5C2C006F5B28 /* _internal */,
+ C6D6F8BE171E5C2C006F5B28 /* JSONOptions.h */,
+ C6D6F8BF171E5C2C006F5B28 /* libjson.h */,
+ );
+ path = libjson;
+ sourceTree = "<group>";
+ };
+ C6D6F800171E5C2C006F5B28 /* _internal */ = {
+ isa = PBXGroup;
+ children = (
+ C6D6F801171E5C2C006F5B28 /* Dependencies */,
+ C6D6F806171E5C2C006F5B28 /* Source */,
+ );
+ path = _internal;
+ sourceTree = "<group>";
+ };
+ C6D6F801171E5C2C006F5B28 /* Dependencies */ = {
+ isa = PBXGroup;
+ children = (
+ C6D6F802171E5C2C006F5B28 /* libbase64++ */,
+ C6D6F804171E5C2C006F5B28 /* mempool++ */,
+ );
+ path = Dependencies;
+ sourceTree = "<group>";
+ };
+ C6D6F802171E5C2C006F5B28 /* libbase64++ */ = {
+ isa = PBXGroup;
+ children = (
+ C6D6F803171E5C2C006F5B28 /* libbase64++.h */,
+ );
+ path = "libbase64++";
+ sourceTree = "<group>";
+ };
+ C6D6F804171E5C2C006F5B28 /* mempool++ */ = {
+ isa = PBXGroup;
+ children = (
+ C6D6F805171E5C2C006F5B28 /* mempool.h */,
+ );
+ path = "mempool++";
+ sourceTree = "<group>";
+ };
+ C6D6F806171E5C2C006F5B28 /* Source */ = {
+ isa = PBXGroup;
+ children = (
+ C6D6F807171E5C2C006F5B28 /* internalJSONNode.cpp */,
+ C6D6F808171E5C2C006F5B28 /* internalJSONNode.h */,
+ C6D6F809171E5C2C006F5B28 /* JSON_Base64.h */,
+ C6D6F80A171E5C2C006F5B28 /* JSONAllocator.cpp */,
+ C6D6F80B171E5C2C006F5B28 /* JSONAllocator.h */,
+ C6D6F80C171E5C2C006F5B28 /* JSONChildren.cpp */,
+ C6D6F80D171E5C2C006F5B28 /* JSONChildren.h */,
+ C6D6F80E171E5C2C006F5B28 /* JSONDebug.cpp */,
+ C6D6F80F171E5C2C006F5B28 /* JSONDebug.h */,
+ C6D6F810171E5C2C006F5B28 /* JSONDefs */,
+ C6D6F815171E5C2C006F5B28 /* JSONDefs.h */,
+ C6D6F816171E5C2C006F5B28 /* JSONGlobals.h */,
+ C6D6F817171E5C2C006F5B28 /* JSONIterators.cpp */,
+ C6D6F818171E5C2C006F5B28 /* JSONMemory.cpp */,
+ C6D6F819171E5C2C006F5B28 /* JSONMemory.h */,
+ C6D6F81A171E5C2C006F5B28 /* JSONMemoryPool.h */,
+ C6D6F81B171E5C2C006F5B28 /* JSONNode.cpp */,
+ C6D6F81C171E5C2C006F5B28 /* JSONNode.h */,
+ C6D6F81D171E5C2C006F5B28 /* JSONNode_Mutex.cpp */,
+ C6D6F81E171E5C2C006F5B28 /* JSONPreparse.cpp */,
+ C6D6F81F171E5C2C006F5B28 /* JSONPreparse.h */,
+ C6D6F820171E5C2C006F5B28 /* JSONSharedString.h */,
+ C6D6F821171E5C2C006F5B28 /* JSONSingleton.h */,
+ C6D6F822171E5C2C006F5B28 /* JSONStats.h */,
+ C6D6F823171E5C2C006F5B28 /* JSONStream.cpp */,
+ C6D6F824171E5C2C006F5B28 /* JSONStream.h */,
+ C6D6F825171E5C2C006F5B28 /* JSONValidator.cpp */,
+ C6D6F826171E5C2C006F5B28 /* JSONValidator.h */,
+ C6D6F827171E5C2C006F5B28 /* JSONWorker.cpp */,
+ C6D6F828171E5C2C006F5B28 /* JSONWorker.h */,
+ C6D6F829171E5C2C006F5B28 /* JSONWriter.cpp */,
+ C6D6F82A171E5C2C006F5B28 /* libjson.cpp */,
+ C6D6F82B171E5C2C006F5B28 /* NumberToString.h */,
+ );
+ path = Source;
+ sourceTree = "<group>";
+ };
+ C6D6F810171E5C2C006F5B28 /* JSONDefs */ = {
+ isa = PBXGroup;
+ children = (
+ C6D6F811171E5C2C006F5B28 /* GNU_C.h */,
+ C6D6F812171E5C2C006F5B28 /* Strings_Defs.h */,
+ C6D6F813171E5C2C006F5B28 /* Unknown_C.h */,
+ C6D6F814171E5C2C006F5B28 /* Visual_C.h */,
+ );
+ path = JSONDefs;
+ sourceTree = "<group>";
+ };
C6F61F771701420A0073032E /* pop */ = {
isa = PBXGroup;
children = (
@@ -2225,6 +2428,23 @@
C6A81BE61706906D00882C15 /* MCOPOPFetchMessagesOperation.mm in Sources */,
C6A81C001707CEE600882C15 /* MCOPOPMessageInfo.mm in Sources */,
C6AC110017114DAF00B715B7 /* MCPOPCheckAccountOperation.cpp in Sources */,
+ C6D6F7F9171E595D006F5B28 /* MCJSON.cpp in Sources */,
+ C6D6F8C3171E5C2C006F5B28 /* internalJSONNode.cpp in Sources */,
+ C6D6F8C5171E5C2C006F5B28 /* JSONAllocator.cpp in Sources */,
+ C6D6F8C7171E5C2C006F5B28 /* JSONChildren.cpp in Sources */,
+ C6D6F8C9171E5C2C006F5B28 /* JSONDebug.cpp in Sources */,
+ C6D6F8CB171E5C2C006F5B28 /* JSONIterators.cpp in Sources */,
+ C6D6F8CD171E5C2C006F5B28 /* JSONMemory.cpp in Sources */,
+ C6D6F8CF171E5C2C006F5B28 /* JSONNode.cpp in Sources */,
+ C6D6F8D1171E5C2C006F5B28 /* JSONNode_Mutex.cpp in Sources */,
+ C6D6F8D3171E5C2C006F5B28 /* JSONPreparse.cpp in Sources */,
+ C6D6F8D5171E5C2C006F5B28 /* JSONStream.cpp in Sources */,
+ C6D6F8D7171E5C2C006F5B28 /* JSONValidator.cpp in Sources */,
+ C6D6F8D9171E5C2C006F5B28 /* JSONWorker.cpp in Sources */,
+ C6D6F8DB171E5C2C006F5B28 /* JSONWriter.cpp in Sources */,
+ C6D6F8DD171E5C2C006F5B28 /* libjson.cpp in Sources */,
+ C6D6F954171E5CB8006F5B28 /* MCMD5.cpp in Sources */,
+ C6D6F956171E5CB8006F5B28 /* MCNull.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -2385,6 +2605,23 @@
C6A81BE71706906D00882C15 /* MCOPOPFetchMessagesOperation.mm in Sources */,
C6A81C011707CEE600882C15 /* MCOPOPMessageInfo.mm in Sources */,
C6AC110117114DAF00B715B7 /* MCPOPCheckAccountOperation.cpp in Sources */,
+ C6D6F7FA171E595D006F5B28 /* MCJSON.cpp in Sources */,
+ C6D6F8C4171E5C2C006F5B28 /* internalJSONNode.cpp in Sources */,
+ C6D6F8C6171E5C2C006F5B28 /* JSONAllocator.cpp in Sources */,
+ C6D6F8C8171E5C2C006F5B28 /* JSONChildren.cpp in Sources */,
+ C6D6F8CA171E5C2C006F5B28 /* JSONDebug.cpp in Sources */,
+ C6D6F8CC171E5C2C006F5B28 /* JSONIterators.cpp in Sources */,
+ C6D6F8CE171E5C2C006F5B28 /* JSONMemory.cpp in Sources */,
+ C6D6F8D0171E5C2C006F5B28 /* JSONNode.cpp in Sources */,
+ C6D6F8D2171E5C2C006F5B28 /* JSONNode_Mutex.cpp in Sources */,
+ C6D6F8D4171E5C2C006F5B28 /* JSONPreparse.cpp in Sources */,
+ C6D6F8D6171E5C2C006F5B28 /* JSONStream.cpp in Sources */,
+ C6D6F8D8171E5C2C006F5B28 /* JSONValidator.cpp in Sources */,
+ C6D6F8DA171E5C2C006F5B28 /* JSONWorker.cpp in Sources */,
+ C6D6F8DC171E5C2C006F5B28 /* JSONWriter.cpp in Sources */,
+ C6D6F8DE171E5C2C006F5B28 /* libjson.cpp in Sources */,
+ C6D6F955171E5CB8006F5B28 /* MCMD5.cpp in Sources */,
+ C6D6F957171E5CB8006F5B28 /* MCNull.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -2434,6 +2671,8 @@
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
+ "JSON_NDEBUG=1",
+ "JSON_ISO_STRICT=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
@@ -2513,6 +2752,10 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "JSON_NDEBUG=1",
+ "JSON_ISO_STRICT=1",
+ );
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
diff --git a/src/core/basetypes/MCBaseTypes.h b/src/core/basetypes/MCBaseTypes.h
index 5ceac315..6d08cdaa 100644
--- a/src/core/basetypes/MCBaseTypes.h
+++ b/src/core/basetypes/MCBaseTypes.h
@@ -9,6 +9,9 @@
#include <MailCore/MCData.h>
#include <MailCore/MCArray.h>
#include <MailCore/MCHashMap.h>
+#include <MailCore/MCJSON.h>
+#include <MailCore/MCMD5.h>
+#include <MailCore/MCNull.h>
#include <MailCore/MCSet.h>
#include <MailCore/MCHash.h>
#include <MailCore/MCLog.h>
diff --git a/src/core/basetypes/MCJSON.cpp b/src/core/basetypes/MCJSON.cpp
new file mode 100644
index 00000000..f6bc5956
--- /dev/null
+++ b/src/core/basetypes/MCJSON.cpp
@@ -0,0 +1,250 @@
+//
+// MCJSON.cpp
+// hermes
+//
+// Created by DINH Viêt Hoà on 4/8/13.
+// Copyright (c) 2013 MailCore. All rights reserved.
+//
+
+#include "MCJSON.h"
+
+#include <string.h>
+
+#include "libjson.h"
+#include "MCNull.h"
+#include <MailCore/MCUtils.h>
+#include <MailCore/MCAssert.h>
+
+using namespace mailcore;
+
+String * JSON::objectToJSONString(Object * object, bool pretty)
+{
+ void * node = objectToJSON(object);
+ char * cstr;
+ if (pretty) {
+ cstr = json_write_formatted(node);
+ }
+ else {
+ cstr = json_write(node);
+ }
+
+ String * result = String::stringWithUTF8Characters(cstr);
+
+ json_free(cstr);
+ json_delete(node);
+
+ return result;
+}
+
+Data * JSON::objectToJSONData(Object * object, bool pretty)
+{
+ void * node = objectToJSON(object);
+ char * cstr;
+ if (pretty) {
+ cstr = json_write_formatted(node);
+ }
+ else {
+ cstr = json_write(node);
+ }
+
+ Data * result = Data::dataWithBytes(cstr, (unsigned int) strlen(cstr));
+
+ json_free(cstr);
+ json_delete(node);
+
+ return result;
+}
+
+Object * JSON::objectFromJSONString(String * json)
+{
+ void * node = json_parse(json->UTF8Characters());
+ Object * object = objectFromJSON(node);
+ json_delete(node);
+ return object;
+}
+
+Object * JSON::objectFromJSONData(Data * json)
+{
+ //printf("rcv: [%.*s]\n", (int) json->length(), json->bytes());
+
+ void * node = json_parse(json->bytes());
+ Object * object = objectFromJSON(node);
+ json_delete(node);
+ return object;
+}
+
+void * JSON::hashMapToJSON(HashMap * hashmap)
+{
+ JSONNODE * result = json_new(JSON_NODE);
+ Array * keys = hashmap->allKeys();
+ for(unsigned int i = 0 ; i < keys->count() ; i ++) {
+ String * key = (String *) keys->objectAtIndex(i);
+ JSONNODE * item = objectToJSON(hashmap->objectForKey(key));
+ json_set_name(item, key->UTF8Characters());
+ json_push_back(result, item);
+ }
+ return result;
+}
+
+void * JSON::arrayToJSON(Array * array)
+{
+ JSONNODE * result = json_new(JSON_ARRAY);
+ for(unsigned int i = 0 ; i < array->count() ; i ++) {
+ Object * value = array->objectAtIndex(i);
+ JSONNODE * item = objectToJSON(value);
+ json_push_back(result, item);
+ }
+ return result;
+}
+
+void * JSON::stringToJSON(String * string)
+{
+ return json_new_a("", string->UTF8Characters());
+}
+
+void * JSON::doubleToJSON(Value * value)
+{
+ switch (value->type()) {
+ case ValueTypeChar:
+ return json_new_f("", value->charValue());
+ case ValueTypeUnsignedChar:
+ return json_new_f("", value->unsignedCharValue());
+ case ValueTypeShort:
+ return json_new_f("", value->shortValue());
+ case ValueTypeUnsignedShort:
+ return json_new_f("", value->unsignedShortValue());
+ case ValueTypeInt:
+ return json_new_f("", value->intValue());
+ case ValueTypeUnsignedInt:
+ return json_new_f("", value->unsignedIntValue());
+ case ValueTypeLong:
+ return json_new_f("", value->longValue());
+ case ValueTypeUnsignedLong:
+ return json_new_f("", value->unsignedLongValue());
+ case ValueTypeLongLong:
+ return json_new_f("", value->longLongValue());
+ case ValueTypeUnsignedLongLong:
+ return json_new_f("", value->unsignedLongLongValue());
+ case ValueTypeFloat:
+ return json_new_f("", value->floatValue());
+ case ValueTypeDouble:
+ return json_new_f("", value->doubleValue());
+ default:
+ return json_new_f("", 0.);
+ }
+}
+
+void * JSON::boolToJSON(Value * value)
+{
+ return json_new_b("", value->boolValue());
+}
+
+void * JSON::nullToJSON(Null * value)
+{
+ return json_new(JSON_NULL);
+}
+
+void * JSON::objectToJSON(Object * object)
+{
+ String * name = object->className();
+ if (name->isEqual(MCSTR("mailcore::Null"))) {
+ return nullToJSON((Null *) object);
+ }
+ else if (name->isEqual(MCSTR("mailcore::Value"))) {
+ Value * value = (Value *) object;
+ if (value->type() == ValueTypeBool) {
+ return boolToJSON(value);
+ }
+ else {
+ return doubleToJSON(value);
+ }
+ }
+ else if (name->isEqual(MCSTR("mailcore::String"))) {
+ return stringToJSON((String *) object);
+ }
+ else if (name->isEqual(MCSTR("mailcore::Array"))) {
+ return arrayToJSON((Array *) object);
+ }
+ else if (name->isEqual(MCSTR("mailcore::HashMap"))) {
+ return hashMapToJSON((HashMap *) object);
+ }
+ else {
+ MCAssert(0);
+ return NULL;
+ }
+}
+
+HashMap * JSON::hashMapFromJSON(void * json)
+{
+ HashMap * result = HashMap::hashMap();
+ JSONNODE_ITERATOR i = json_begin(json);
+ while (i != json_end(json)){
+ json_char * ckey = json_name(*i);
+ String * key = String::stringWithUTF8Characters(ckey);
+ Object * value = objectFromJSON(* i);
+
+ result->setObjectForKey(key, value);
+
+ json_free(ckey);
+ ++i;
+ }
+ return result;
+}
+
+Array * JSON::arrayFromJSON(void * json)
+{
+ Array * result = Array::array();
+ JSONNODE_ITERATOR i = json_begin(json);
+ while (i != json_end(json)){
+ Object * obj = objectFromJSON(* i);
+ result->addObject(obj);
+ ++i;
+ }
+ return result;
+}
+
+String * JSON::stringFromJSON(void * json)
+{
+ json_char * cstr = json_as_string(json);
+ String * result = String::stringWithUTF8Characters(cstr);
+ json_free(cstr);
+ return result;
+}
+
+Value * JSON::doubleFromJSON(void * json)
+{
+ json_number value = json_as_float(json);
+ return Value::valueWithDoubleValue(value);
+}
+
+Value * JSON::boolFromJSON(void * json)
+{
+ json_bool_t value = json_as_bool(json);
+ return Value::valueWithBoolValue(value);
+}
+
+Null * JSON::nullFromJSON(void * json)
+{
+ return Null::null();
+}
+
+Object * JSON::objectFromJSON(void * json)
+{
+ switch (json_type(json)) {
+ case JSON_NULL:
+ return nullFromJSON(json);
+ case JSON_STRING:
+ return stringFromJSON(json);
+ case JSON_NUMBER:
+ return doubleFromJSON(json);
+ case JSON_BOOL:
+ return boolFromJSON(json);
+ case JSON_ARRAY:
+ return arrayFromJSON(json);
+ case JSON_NODE:
+ return hashMapFromJSON(json);
+ default:
+ MCAssert(0);
+ return NULL;
+ }
+}
diff --git a/src/core/basetypes/MCJSON.h b/src/core/basetypes/MCJSON.h
new file mode 100644
index 00000000..4f4ba761
--- /dev/null
+++ b/src/core/basetypes/MCJSON.h
@@ -0,0 +1,50 @@
+//
+// MCJSON.h
+// hermes
+//
+// Created by DINH Viêt Hoà on 4/8/13.
+// Copyright (c) 2013 MailCore. All rights reserved.
+//
+
+#ifndef __MAILCORE_MCJSON_H_
+#define __MAILCORE_MCJSON_H_
+
+#include <MailCore/MCObject.h>
+#include <MailCore/MCHashMap.h>
+#include <MailCore/MCArray.h>
+#include <MailCore/MCValue.h>
+#include <MailCore/MCString.h>
+#include <MailCore/MCData.h>
+
+namespace mailcore {
+
+ class Null;
+
+ class JSON {
+ public:
+ static String * objectToJSONString(Object * object, bool pretty = false);
+ static Data * objectToJSONData(Object * object, bool pretty = false);
+ static Object * objectFromJSONString(String * json);
+ static Object * objectFromJSONData(Data * json);
+
+ private:
+ static void * hashMapToJSON(HashMap * hashmap);
+ static void * arrayToJSON(Array * array);
+ static void * stringToJSON(String * string);
+ static void * doubleToJSON(Value * value);
+ static void * boolToJSON(Value * value);
+ static void * nullToJSON(Null * value);
+ static void * objectToJSON(Object * object);
+
+ static HashMap * hashMapFromJSON(void * json);
+ static Array * arrayFromJSON(void * json);
+ static String * stringFromJSON(void * json);
+ static Value * doubleFromJSON(void * json);
+ static Value * boolFromJSON(void * json);
+ static Null * nullFromJSON(void * json);
+ static Object * objectFromJSON(void * json);
+ };
+
+}
+
+#endif /* defined(__hermes__MCJSON__) */
diff --git a/src/core/basetypes/MCMD5.cpp b/src/core/basetypes/MCMD5.cpp
new file mode 100644
index 00000000..8451db1f
--- /dev/null
+++ b/src/core/basetypes/MCMD5.cpp
@@ -0,0 +1,233 @@
+//
+// MCMD5.cpp
+// hermes
+//
+// Created by DINH Viêt Hoà on 4/11/13.
+// Copyright (c) 2013 MailCore. All rights reserved.
+//
+
+#include "MCMD5.h"
+
+#include <inttypes.h>
+#include <string.h>
+
+using namespace mailcore;
+
+static int is_big_endian(void) {
+ static const int n = 1;
+ return ((char *) &n)[0] == 0;
+}
+
+typedef struct MD5Context {
+ uint32_t buf[4];
+ uint32_t bits[2];
+ unsigned char in[64];
+} MD5_CTX;
+
+static void byteReverse(unsigned char *buf, unsigned longs) {
+ uint32_t t;
+
+ // Forrest: MD5 expect LITTLE_ENDIAN, swap if BIG_ENDIAN
+ if (is_big_endian()) {
+ do {
+ t = (uint32_t) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
+ ((unsigned) buf[1] << 8 | buf[0]);
+ * (uint32_t *) buf = t;
+ buf += 4;
+ } while (--longs);
+ }
+}
+
+#define F1(x, y, z) (z ^ (x & (y ^ z)))
+#define F2(x, y, z) F1(z, x, y)
+#define F3(x, y, z) (x ^ y ^ z)
+#define F4(x, y, z) (y ^ (x | ~z))
+
+#define MD5STEP(f, w, x, y, z, data, s) \
+( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
+
+static void MD5Transform(uint32_t buf[4], uint32_t const in[16]) {
+ register uint32_t a, b, c, d;
+
+ a = buf[0];
+ b = buf[1];
+ c = buf[2];
+ d = buf[3];
+
+ MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
+ MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
+ MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
+ MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
+ MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
+ MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
+ MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
+ MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
+ MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
+ MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
+ MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
+ MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
+ MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
+ MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
+ MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
+ MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
+
+ MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
+ MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
+ MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
+ MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
+ MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
+ MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
+ MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
+ MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
+ MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
+ MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
+ MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
+ MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
+ MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
+ MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
+ MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
+ MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
+
+ MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
+ MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
+ MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
+ MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
+ MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
+ MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
+ MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
+ MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
+ MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
+ MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
+ MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
+ MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
+ MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
+ MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
+ MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
+ MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
+
+ MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
+ MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
+ MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
+ MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
+ MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
+ MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
+ MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
+ MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
+ MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
+ MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
+ MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
+ MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
+ MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
+ MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
+ MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
+ MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
+
+ buf[0] += a;
+ buf[1] += b;
+ buf[2] += c;
+ buf[3] += d;
+}
+
+// Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
+// initialization constants.
+static void MD5Init(MD5_CTX *ctx) {
+ ctx->buf[0] = 0x67452301;
+ ctx->buf[1] = 0xefcdab89;
+ ctx->buf[2] = 0x98badcfe;
+ ctx->buf[3] = 0x10325476;
+
+ ctx->bits[0] = 0;
+ ctx->bits[1] = 0;
+}
+
+static void MD5Update(MD5_CTX *ctx, unsigned char const *buf, unsigned len) {
+ uint32_t t;
+
+ t = ctx->bits[0];
+ if ((ctx->bits[0] = t + ((uint32_t) len << 3)) < t)
+ ctx->bits[1]++;
+ ctx->bits[1] += len >> 29;
+
+ t = (t >> 3) & 0x3f;
+
+ if (t) {
+ unsigned char *p = (unsigned char *) ctx->in + t;
+
+ t = 64 - t;
+ if (len < t) {
+ memcpy(p, buf, len);
+ return;
+ }
+ memcpy(p, buf, t);
+ byteReverse(ctx->in, 16);
+ MD5Transform(ctx->buf, (uint32_t *) ctx->in);
+ buf += t;
+ len -= t;
+ }
+
+ while (len >= 64) {
+ memcpy(ctx->in, buf, 64);
+ byteReverse(ctx->in, 16);
+ MD5Transform(ctx->buf, (uint32_t *) ctx->in);
+ buf += 64;
+ len -= 64;
+ }
+
+ memcpy(ctx->in, buf, len);
+}
+
+static void MD5Final(unsigned char digest[16], MD5_CTX *ctx) {
+ unsigned count;
+ unsigned char *p;
+ uint32_t *a;
+
+ count = (ctx->bits[0] >> 3) & 0x3F;
+
+ p = ctx->in + count;
+ *p++ = 0x80;
+ count = 64 - 1 - count;
+ if (count < 8) {
+ memset(p, 0, count);
+ byteReverse(ctx->in, 16);
+ MD5Transform(ctx->buf, (uint32_t *) ctx->in);
+ memset(ctx->in, 0, 56);
+ } else {
+ memset(p, 0, count - 8);
+ }
+ byteReverse(ctx->in, 14);
+
+ a = (uint32_t *)ctx->in;
+ a[14] = ctx->bits[0];
+ a[15] = ctx->bits[1];
+
+ MD5Transform(ctx->buf, (uint32_t *) ctx->in);
+ byteReverse((unsigned char *) ctx->buf, 4);
+ memcpy(digest, ctx->buf, 16);
+ memset((char *) ctx, 0, sizeof(*ctx));
+}
+
+Data * mailcore::md5Data(Data * data)
+{
+ MD5Context ctx;
+ unsigned char digest[16];
+ Data * result = Data::dataWithCapacity(sizeof(digest));
+
+ MD5Init(&ctx);
+ MD5Update(&ctx, (unsigned char const *) data->bytes(), data->length());
+ MD5Final(digest, &ctx);
+
+ memcpy(result->bytes(), digest, sizeof(digest));
+
+ return result;
+}
+
+String * mailcore::md5String(Data * data)
+{
+ Data * md5data = md5Data(data);
+ String * result = String::string();
+ for(unsigned int i = 0 ; i < md5data->length() ; i ++) {
+ result->appendUTF8Format("%02x", (unsigned char) md5data->bytes()[i]);
+ }
+ return result;
+}
+
diff --git a/src/core/basetypes/MCMD5.h b/src/core/basetypes/MCMD5.h
new file mode 100644
index 00000000..4821f90a
--- /dev/null
+++ b/src/core/basetypes/MCMD5.h
@@ -0,0 +1,20 @@
+//
+// MCMD5.h
+// hermes
+//
+// Created by DINH Viêt Hoà on 4/11/13.
+// Copyright (c) 2013 MailCore. All rights reserved.
+//
+
+#ifndef __MAILCORE_MCMD5_H_
+#define __MAILCORE_MCMD5_H_
+
+#include <MailCore/MCData.h>
+#include <MailCore/MCString.h>
+
+namespace mailcore {
+ Data * md5Data(Data * data);
+ String * md5String(Data * data);
+}
+
+#endif
diff --git a/src/core/basetypes/MCNull.cpp b/src/core/basetypes/MCNull.cpp
new file mode 100644
index 00000000..cdb8335f
--- /dev/null
+++ b/src/core/basetypes/MCNull.cpp
@@ -0,0 +1,19 @@
+//
+// MCNull.cpp
+// hermes
+//
+// Created by DINH Viêt Hoà on 4/9/13.
+// Copyright (c) 2013 MailCore. All rights reserved.
+//
+
+#include "MCNull.h"
+
+using namespace mailcore;
+
+Null * Null::null()
+{
+ Null * result = new Null();
+ result->autorelease();
+ return result;
+}
+
diff --git a/src/core/basetypes/MCNull.h b/src/core/basetypes/MCNull.h
new file mode 100644
index 00000000..345b5fd7
--- /dev/null
+++ b/src/core/basetypes/MCNull.h
@@ -0,0 +1,23 @@
+//
+// MCNull.h
+// hermes
+//
+// Created by DINH Viêt Hoà on 4/9/13.
+// Copyright (c) 2013 MailCore. All rights reserved.
+//
+
+#ifndef __MAILCORE_MCNULL_H_
+#define __MAILCORE_MCNULL_H_
+
+#include <MailCore/MCObject.h>
+
+namespace mailcore {
+
+ class Null : public Object {
+ public:
+ static Null * null();
+ };
+
+}
+
+#endif
diff --git a/submodules/libjson b/submodules/libjson
new file mode 160000
+Subproject fdbe0a6c2a8c1c31a761a91e5014340dcd94fd6