aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xbuild-mac/mailcore2.xcodeproj/project.pbxproj4
-rw-r--r--build-windows/build_headers.list3
-rwxr-xr-xsrc/async/imap/MCIMAPAsyncSession.cpp1
-rw-r--r--src/async/nntp/MCNNTPFetchArticleOperation.cpp4
-rw-r--r--src/async/nntp/MCNNTPFetchHeaderOperation.cpp2
-rw-r--r--src/async/nntp/MCNNTPFetchServerTimeOperation.cpp1
-rw-r--r--src/async/nntp/MCNNTPListNewsgroupsOperation.cpp3
-rw-r--r--src/async/smtp/MCSMTPOperation.cpp1
-rw-r--r--src/cmake/public-headers.cmake1
-rw-r--r--src/core/basetypes/MCAssert.c2
-rw-r--r--src/core/basetypes/MCBaseTypes.h1
-rw-r--r--src/core/basetypes/MCData.cpp2
-rw-r--r--src/core/basetypes/MCHTMLCleaner.h4
-rw-r--r--src/core/basetypes/MCLog.cpp8
-rw-r--r--src/core/basetypes/MCString.cpp96
-rw-r--r--src/core/basetypes/MCString.h3
-rw-r--r--src/core/imap/MCIMAPMessage.cpp1
-rwxr-xr-xsrc/core/imap/MCIMAPSession.cpp1
-rw-r--r--src/core/nntp/MCNNTPGroupInfo.cpp2
-rw-r--r--src/core/renderer/MCHTMLRenderer.cpp25
-rw-r--r--src/core/renderer/MCHTMLRendererCallback.cpp4
-rw-r--r--src/core/renderer/MCHTMLRendererCallback.h2
22 files changed, 163 insertions, 8 deletions
diff --git a/build-mac/mailcore2.xcodeproj/project.pbxproj b/build-mac/mailcore2.xcodeproj/project.pbxproj
index 91c25a17..8126042e 100755
--- a/build-mac/mailcore2.xcodeproj/project.pbxproj
+++ b/build-mac/mailcore2.xcodeproj/project.pbxproj
@@ -790,6 +790,8 @@
C6BD28A3170BD84F00A91AC1 /* libMailCore.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C64EA537169E772200778456 /* libMailCore.a */; };
C6BD28AB170BDB6B00A91AC1 /* MCOFramework.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6BD28A9170BDB6B00A91AC1 /* MCOFramework.mm */; };
C6BD28AC170BDEA200A91AC1 /* MailCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C6BD288D170BD71100A91AC1 /* MailCore.framework */; };
+ C6BEC1AA1B1256BA00546519 /* MCHTMLCleaner.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C63CD69016BE566E00DB18F1 /* MCHTMLCleaner.h */; };
+ C6BEC1AB1B1256C100546519 /* MCHTMLCleaner.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C63CD69016BE566E00DB18F1 /* MCHTMLCleaner.h */; };
C6CCC5C716FFE5190077A5FC /* MCORange.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6CCC5C616FFE5190077A5FC /* MCORange.mm */; };
C6CCC5C916FFEA070077A5FC /* MCORange.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6CCC5C816FFE54F0077A5FC /* MCORange.h */; };
C6CCC5CA16FFEA090077A5FC /* MCOIndexSet.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6F5B9F216FEAC6C00D9DABD /* MCOIndexSet.h */; };
@@ -1004,6 +1006,7 @@
dstPath = include/MailCore;
dstSubfolderSpec = 16;
files = (
+ C6BEC1AB1B1256C100546519 /* MCHTMLCleaner.h in CopyFiles */,
27E91D601A80D3F4005A3244 /* MCMXRecordResolverOperation.h in CopyFiles */,
27478E861A76475F004AE621 /* MCOAccountValidator.h in CopyFiles */,
27478E871A76475F004AE621 /* MCAccountValidator.h in CopyFiles */,
@@ -1236,6 +1239,7 @@
dstPath = include/MailCore;
dstSubfolderSpec = 16;
files = (
+ C6BEC1AA1B1256BA00546519 /* MCHTMLCleaner.h in CopyFiles */,
276A65D01A7B7E7D008722C2 /* MCMXRecordResolverOperation.h in CopyFiles */,
27478E881A7647AC004AE621 /* MCOAccountValidator.h in CopyFiles */,
27478E891A7647AC004AE621 /* MCAccountValidator.h in CopyFiles */,
diff --git a/build-windows/build_headers.list b/build-windows/build_headers.list
index e1de1772..7f752f15 100644
--- a/build-windows/build_headers.list
+++ b/build-windows/build_headers.list
@@ -28,6 +28,7 @@ src\core\basetypes\MCLibetpanTypes.h
src\core\basetypes\MCOperationCallback.h
src\core\basetypes\MCIterator.h
src\core\basetypes\MCConnectionLogger.h
+src\core\basetypes\MCHTMLCleaner.h
src\core\abstract\MCAbstractMessagePart.h
src\core\abstract\MCAbstractPart.h
src\core\abstract\MCAbstractMultipart.h
@@ -72,6 +73,7 @@ src\core\provider\MCProvider.h
src\core\provider\MCMailProvidersManager.h
src\core\provider\MCMailProvider.h
src\core\provider\MCNetService.h
+src\core\provider\MCAccountValidator.h
src\async\MCAsync.h
src\async\smtp\MCAsyncSMTP.h
src\async\smtp\MCSMTPAsyncSession.h
@@ -199,3 +201,4 @@ src\objc\provider\MCOProvider.h
src\objc\provider\MCONetService.h
src\objc\provider\MCOMailProvider.h
src\objc\provider\MCOMailProvidersManager.h
+src\objc\provider\MCOAccountValidator.h
diff --git a/src/async/imap/MCIMAPAsyncSession.cpp b/src/async/imap/MCIMAPAsyncSession.cpp
index d9fb38d5..ab1bbd95 100755
--- a/src/async/imap/MCIMAPAsyncSession.cpp
+++ b/src/async/imap/MCIMAPAsyncSession.cpp
@@ -73,6 +73,7 @@ IMAPAsyncSession::IMAPAsyncSession()
mDispatchQueue = dispatch_get_main_queue();
#endif
mGmailUserDisplayName = NULL;
+ mQueueRunning = false;
}
IMAPAsyncSession::~IMAPAsyncSession()
diff --git a/src/async/nntp/MCNNTPFetchArticleOperation.cpp b/src/async/nntp/MCNNTPFetchArticleOperation.cpp
index 1df0dc33..5ebe1a81 100644
--- a/src/async/nntp/MCNNTPFetchArticleOperation.cpp
+++ b/src/async/nntp/MCNNTPFetchArticleOperation.cpp
@@ -17,10 +17,14 @@ NNTPFetchArticleOperation::NNTPFetchArticleOperation()
{
mMessageIndex = 0;
mData = NULL;
+ mGroupName = NULL;
+ mMessageID = NULL;
}
NNTPFetchArticleOperation::~NNTPFetchArticleOperation()
{
+ MC_SAFE_RELEASE(mMessageID);
+ MC_SAFE_RELEASE(mGroupName);
MC_SAFE_RELEASE(mData);
}
diff --git a/src/async/nntp/MCNNTPFetchHeaderOperation.cpp b/src/async/nntp/MCNNTPFetchHeaderOperation.cpp
index 386dc142..a1ca2b6a 100644
--- a/src/async/nntp/MCNNTPFetchHeaderOperation.cpp
+++ b/src/async/nntp/MCNNTPFetchHeaderOperation.cpp
@@ -18,10 +18,12 @@ NNTPFetchHeaderOperation::NNTPFetchHeaderOperation()
{
mMessageIndex = 0;
mHeader = NULL;
+ mGroupName = NULL;
}
NNTPFetchHeaderOperation::~NNTPFetchHeaderOperation()
{
+ MC_SAFE_RELEASE(mGroupName);
MC_SAFE_RELEASE(mHeader);
}
diff --git a/src/async/nntp/MCNNTPFetchServerTimeOperation.cpp b/src/async/nntp/MCNNTPFetchServerTimeOperation.cpp
index 86800733..e71d8722 100644
--- a/src/async/nntp/MCNNTPFetchServerTimeOperation.cpp
+++ b/src/async/nntp/MCNNTPFetchServerTimeOperation.cpp
@@ -15,6 +15,7 @@ using namespace mailcore;
NNTPFetchServerTimeOperation::NNTPFetchServerTimeOperation()
{
+ mTime = -1;
}
NNTPFetchServerTimeOperation::~NNTPFetchServerTimeOperation()
diff --git a/src/async/nntp/MCNNTPListNewsgroupsOperation.cpp b/src/async/nntp/MCNNTPListNewsgroupsOperation.cpp
index 3747bacf..c00b1cc3 100644
--- a/src/async/nntp/MCNNTPListNewsgroupsOperation.cpp
+++ b/src/async/nntp/MCNNTPListNewsgroupsOperation.cpp
@@ -15,6 +15,8 @@ using namespace mailcore;
NNTPListNewsgroupsOperation::NNTPListNewsgroupsOperation()
{
+ mListsSuscribed = false;
+ mGroups = NULL;
}
NNTPListNewsgroupsOperation::~NNTPListNewsgroupsOperation()
@@ -44,5 +46,6 @@ void NNTPListNewsgroupsOperation::main()
} else {
mGroups = session()->session()->listAllNewsgroups(&error);
}
+ MC_SAFE_RETAIN(mGroups);
setError(error);
}
diff --git a/src/async/smtp/MCSMTPOperation.cpp b/src/async/smtp/MCSMTPOperation.cpp
index 9ddcede2..28e1e152 100644
--- a/src/async/smtp/MCSMTPOperation.cpp
+++ b/src/async/smtp/MCSMTPOperation.cpp
@@ -19,6 +19,7 @@ SMTPOperation::SMTPOperation()
{
mSession = NULL;
mError = ErrorNone;
+ mSmtpCallback = NULL;
}
SMTPOperation::~SMTPOperation()
diff --git a/src/cmake/public-headers.cmake b/src/cmake/public-headers.cmake
index 7afb5cdf..ecd17a61 100644
--- a/src/cmake/public-headers.cmake
+++ b/src/cmake/public-headers.cmake
@@ -29,6 +29,7 @@ core/basetypes/MCLibetpanTypes.h
core/basetypes/MCOperationCallback.h
core/basetypes/MCIterator.h
core/basetypes/MCConnectionLogger.h
+core/basetypes/MCHTMLCleaner.h
core/abstract/MCAbstractMessagePart.h
core/abstract/MCAbstractPart.h
core/abstract/MCAbstractMultipart.h
diff --git a/src/core/basetypes/MCAssert.c b/src/core/basetypes/MCAssert.c
index ce9b5703..564f1648 100644
--- a/src/core/basetypes/MCAssert.c
+++ b/src/core/basetypes/MCAssert.c
@@ -9,6 +9,6 @@ void MCAssertInternal(const char * filename, unsigned int line, int cond, const
return;
}
- fprintf(stderr, "%s:%i: assert %s\n", filename, line, condString);
+ fprintf(stderr, "%s:%u: assert %s\n", filename, line, condString);
abort();
}
diff --git a/src/core/basetypes/MCBaseTypes.h b/src/core/basetypes/MCBaseTypes.h
index ce3e1153..3088d4c2 100644
--- a/src/core/basetypes/MCBaseTypes.h
+++ b/src/core/basetypes/MCBaseTypes.h
@@ -26,5 +26,6 @@
#include <MailCore/MCICUTypes.h>
#include <MailCore/MCIterator.h>
#include <MailCore/MCConnectionLogger.h>
+#include <MailCore/MCHTMLCleaner.h>
#endif
diff --git a/src/core/basetypes/MCData.cpp b/src/core/basetypes/MCData.cpp
index d9f14efa..079344da 100644
--- a/src/core/basetypes/MCData.cpp
+++ b/src/core/basetypes/MCData.cpp
@@ -725,10 +725,10 @@ ErrorCode Data::writeToFile(String * filename)
return ErrorFile;
}
size_t result = fwrite(bytes(), length(), 1, f);
+ fclose(f);
if (result == 0) {
return ErrorFile;
}
- fclose(f);
return ErrorNone;
}
diff --git a/src/core/basetypes/MCHTMLCleaner.h b/src/core/basetypes/MCHTMLCleaner.h
index 33e65767..eccf88c9 100644
--- a/src/core/basetypes/MCHTMLCleaner.h
+++ b/src/core/basetypes/MCHTMLCleaner.h
@@ -13,6 +13,8 @@
#include <MailCore/MCString.h>
#include <MailCore/MCUtils.h>
+#ifdef __cplusplus
+
namespace mailcore {
class MAILCORE_EXPORT HTMLCleaner {
@@ -23,3 +25,5 @@ namespace mailcore {
}
#endif
+
+#endif
diff --git a/src/core/basetypes/MCLog.cpp b/src/core/basetypes/MCLog.cpp
index 952229ec..386ac422 100644
--- a/src/core/basetypes/MCLog.cpp
+++ b/src/core/basetypes/MCLog.cpp
@@ -53,9 +53,7 @@ static void logInternalv(FILE * file,
return;
while (1) {
- const char * p = filename;
-
- p = strchr(filename, '/');
+ const char * p = strchr(filename, '/');
if (p == NULL) {
break;
}
@@ -80,7 +78,7 @@ static void logInternalv(FILE * file,
#else
if (0) {
#endif
- fprintf(file, "[%i:main] %s:%i: ", sPid, filename, line);
+ fprintf(file, "[%i:main] %s:%u: ", sPid, filename, line);
}
else {
unsigned long threadValue;
@@ -91,7 +89,7 @@ static void logInternalv(FILE * file,
#else
threadValue = (unsigned long) thread_id;
#endif
- fprintf(file, "[%i:%lx] %s:%i: ", sPid, threadValue, filename, line);
+ fprintf(file, "[%i:%lx] %s:%u: ", sPid, threadValue, filename, line);
}
vfprintf(file, format, argp);
fprintf(file, "\n");
diff --git a/src/core/basetypes/MCString.cpp b/src/core/basetypes/MCString.cpp
index 02c93200..7d7a740e 100644
--- a/src/core/basetypes/MCString.cpp
+++ b/src/core/basetypes/MCString.cpp
@@ -2515,6 +2515,102 @@ Data * String::decodedBase64Data()
return result;
}
+static int hexValue(const char * code) {
+ int value = 0;
+ const char * pch = code;
+ for (;;) {
+ int digit = *pch++;
+ if (digit >= '0' && digit <= '9') {
+ value += digit - '0';
+ }
+ else if (digit >= 'A' && digit <= 'F') {
+ value += digit - 'A' + 10;
+ }
+ else if (digit >= 'a' && digit <= 'f') {
+ value += digit - 'a' + 10;
+ }
+ else {
+ return -1;
+ }
+ if (pch == code + 2) {
+ return value;
+ }
+ value <<= 4;
+ }
+}
+
+String * String::urlDecodedString()
+{
+ Data * sourceData = dataUsingEncoding();
+ const char * source = sourceData->bytes();
+ char * start = (char *) malloc(sourceData->length() + 1);
+ char * dest = start;
+ unsigned int i = 0;
+ while (i < sourceData->length()) {
+ switch (source[i]) {
+ case '%':
+ {
+ if (i + 2 < sourceData->length()) {
+ int value = hexValue(&source[i + 1]);
+ if (value >= 0) {
+ *(dest++) = value;
+ i += 3;
+ }
+ else {
+ *dest++ = '?';
+ i ++;
+ }
+ }
+ else {
+ *dest++ = '?';
+ i ++;
+ }
+ break;
+ }
+ default:
+ {
+ *dest++ = source[i];
+ i ++;
+ break;
+ }
+ }
+ }
+ * dest = 0;
+ String * result = String::stringWithUTF8Characters(start);
+ free(start);
+ return result;
+}
+
+static inline bool isValidUrlChar(char ch) {
+ return strchr("$&+,/:;=?@[]#!'()* ", ch) == NULL;
+}
+
+String * String::urlEncodedString()
+{
+ const char * digits = "0123456789ABCDEF";
+ Data * sourceData = dataUsingEncoding();
+ const char * source = sourceData->bytes();
+ char * start = (char *) malloc(sourceData->length() * 3 + 1);
+ char * dest = start;
+ unsigned int i = 0;
+ while (i < sourceData->length()) {
+ unsigned char ch = (unsigned char) source[i];
+ if (isValidUrlChar(ch)) {
+ *dest++ = ch;
+ } else {
+ *dest++ = '%';
+ *dest++ = digits[(ch >> 4) & 0x0F];
+ *dest++ = digits[ ch & 0x0F];
+ }
+ i ++;
+ }
+ *dest = 0;
+ String * result = String::stringWithUTF8Characters(dest);
+ free(start);
+
+ return result;
+}
+
HashMap * String::serializable()
{
HashMap * result = Object::serializable();
diff --git a/src/core/basetypes/MCString.h b/src/core/basetypes/MCString.h
index cbe5538b..5ee2ad65 100644
--- a/src/core/basetypes/MCString.h
+++ b/src/core/basetypes/MCString.h
@@ -117,6 +117,9 @@ namespace mailcore {
virtual Data * decodedBase64Data();
+ virtual String * urlDecodedString();
+ virtual String * urlEncodedString();
+
public: // private
static String * uniquedStringWithUTF8Characters(const char * UTF8Characters);
diff --git a/src/core/imap/MCIMAPMessage.cpp b/src/core/imap/MCIMAPMessage.cpp
index 2c8ef9b5..530d9075 100644
--- a/src/core/imap/MCIMAPMessage.cpp
+++ b/src/core/imap/MCIMAPMessage.cpp
@@ -26,6 +26,7 @@ void IMAPMessage::init()
mModSeqValue = 0;
mGmailThreadID = 0;
mGmailMessageID = 0;
+ mSize = 0;
}
IMAPMessage::IMAPMessage()
diff --git a/src/core/imap/MCIMAPSession.cpp b/src/core/imap/MCIMAPSession.cpp
index 9fcf8397..d070b853 100755
--- a/src/core/imap/MCIMAPSession.cpp
+++ b/src/core/imap/MCIMAPSession.cpp
@@ -1578,7 +1578,6 @@ void IMAPSession::appendMessageWithCustomFlagsAndDate(String * folder, Data * me
mProgressCallback = progressCallback;
bodyProgress(0, messageData->length());
- flag_list = NULL;
flag_list = flags_to_lep(flags);
if (customFlags != NULL) {
for (unsigned int i = 0 ; i < customFlags->count() ; i ++) {
diff --git a/src/core/nntp/MCNNTPGroupInfo.cpp b/src/core/nntp/MCNNTPGroupInfo.cpp
index 787967f3..8ebe08bc 100644
--- a/src/core/nntp/MCNNTPGroupInfo.cpp
+++ b/src/core/nntp/MCNNTPGroupInfo.cpp
@@ -13,10 +13,12 @@ using namespace mailcore;
void NNTPGroupInfo::init()
{
mMessageCount = 0;
+ mName = NULL;
}
NNTPGroupInfo::NNTPGroupInfo()
{
+ MC_SAFE_RELEASE(mName);
init();
}
diff --git a/src/core/renderer/MCHTMLRenderer.cpp b/src/core/renderer/MCHTMLRenderer.cpp
index 60788d57..e2839610 100644
--- a/src/core/renderer/MCHTMLRenderer.cpp
+++ b/src/core/renderer/MCHTMLRenderer.cpp
@@ -218,6 +218,9 @@ static String * htmlForAbstractMessage(String * folder, AbstractMessage * messag
context.pass = 1;
context.firstAttachment = false;
context.hasTextPart = false;
+
+ htmlCallback->setMixedTextAndAttachmentsModeEnabled(context.hasMixedTextAndAttachments);
+
String * content = htmlForAbstractPart(mainPart, &context);
if (content == NULL)
return NULL;
@@ -274,6 +277,28 @@ static String * htmlForAbstractSinglePart(AbstractPart * part, htmlRendererConte
if (isTextPart(part, context)) {
if (context->pass == 0) {
if (context->state == RENDER_STATE_HAD_ATTACHMENT) {
+#if 0
+ if (part->className()->isEqual(MCSTR("mailcore::IMAPPart"))) {
+ if (mimeType->isEqual(MCSTR("text/plain"))) {
+ Data * data = context->dataCallback->dataForIMAPPart(context->folder, (IMAPPart *) part);
+ if (data != NULL) {
+ if (data->length() == 0) {
+ return NULL;
+ }
+ else if (data->length() == 2) {
+ if (strncmp(data->bytes(), "\r\n", 2) == 0) {
+ return NULL;
+ }
+ }
+ else if (data->length() == 1) {
+ if (strncmp(data->bytes(), "\n", 1) == 0) {
+ return NULL;
+ }
+ }
+ }
+ }
+ }
+#endif
context->state = RENDER_STATE_HAD_ATTACHMENT_THEN_TEXT;
}
return NULL;
diff --git a/src/core/renderer/MCHTMLRendererCallback.cpp b/src/core/renderer/MCHTMLRendererCallback.cpp
index fb492c9e..a3b14341 100644
--- a/src/core/renderer/MCHTMLRendererCallback.cpp
+++ b/src/core/renderer/MCHTMLRendererCallback.cpp
@@ -289,3 +289,7 @@ bool HTMLRendererTemplateCallback::shouldShowPart(AbstractPart * part)
{
return true;
}
+
+void HTMLRendererTemplateCallback::setMixedTextAndAttachmentsModeEnabled(bool enabled)
+{
+}
diff --git a/src/core/renderer/MCHTMLRendererCallback.h b/src/core/renderer/MCHTMLRendererCallback.h
index a12a3e45..4a4fc40f 100644
--- a/src/core/renderer/MCHTMLRendererCallback.h
+++ b/src/core/renderer/MCHTMLRendererCallback.h
@@ -35,6 +35,8 @@ namespace mailcore {
HTMLRendererTemplateCallback();
virtual ~HTMLRendererTemplateCallback();
+ virtual void setMixedTextAndAttachmentsModeEnabled(bool enabled);
+
virtual bool canPreviewPart(AbstractPart * part);
virtual bool shouldShowPart(AbstractPart * part);