diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/basetypes/MCArray.cpp | 5 | ||||
-rw-r--r-- | src/core/basetypes/MCHTMLCleaner.cpp | 4 | ||||
-rw-r--r-- | src/core/basetypes/MCLibetpan.cpp | 3 | ||||
-rw-r--r-- | src/core/basetypes/MCLibetpan.h | 1 | ||||
-rw-r--r-- | src/core/basetypes/MCRange.cpp | 4 | ||||
-rw-r--r-- | src/core/basetypes/MCString.cpp | 24 | ||||
-rw-r--r-- | src/core/nntp/MCNNTPSession.cpp | 9 | ||||
-rw-r--r-- | src/core/zip/MCZip.cpp | 1 | ||||
-rw-r--r-- | src/core/zip/MiniZip/ioapi.c | 2 |
9 files changed, 45 insertions, 8 deletions
diff --git a/src/core/basetypes/MCArray.cpp b/src/core/basetypes/MCArray.cpp index 9fa69ccb..d1d02a26 100644 --- a/src/core/basetypes/MCArray.cpp +++ b/src/core/basetypes/MCArray.cpp @@ -10,6 +10,7 @@ #include "MCLog.h" #include "MCUtils.h" #include "MCIterator.h" +#include "MCAndroid.h" using namespace mailcore; @@ -232,6 +233,10 @@ void Array::sortArray(int (* compare)(void * a, void * b, void * context), void sizeof(*carray_data(mArray)), (int(*)(void *, const void *, const void *)) sortCompare, &data); +#elif defined(ANDROID) || defined(__ANDROID__) + android_qsort_r(carray_data(mArray), carray_count(mArray), + sizeof(* carray_data(mArray)), &data, + (int (*)(void *, const void *, const void *)) sortCompare); #else qsort_r(carray_data(mArray), carray_count(mArray), sizeof(* carray_data(mArray)), diff --git a/src/core/basetypes/MCHTMLCleaner.cpp b/src/core/basetypes/MCHTMLCleaner.cpp index 81145c9e..f3ff9c21 100644 --- a/src/core/basetypes/MCHTMLCleaner.cpp +++ b/src/core/basetypes/MCHTMLCleaner.cpp @@ -11,6 +11,10 @@ #include "MCString.h" #include "MCData.h" +#if defined(ANDROID) || defined(__ANDROID__) +typedef unsigned long ulong; +#endif + #include <tidy.h> #include <buffio.h> diff --git a/src/core/basetypes/MCLibetpan.cpp b/src/core/basetypes/MCLibetpan.cpp index 51a27430..91806110 100644 --- a/src/core/basetypes/MCLibetpan.cpp +++ b/src/core/basetypes/MCLibetpan.cpp @@ -16,7 +16,6 @@ using namespace mailcore; -static time_t mkgmtime(struct tm * tmp); static int tmcomp(struct tm * atmp, struct tm * btmp); INITIALIZE(Libetpan) @@ -178,7 +177,7 @@ static int tmcomp(struct tm * atmp, struct tm * btmp) return result; } -static time_t mkgmtime(struct tm * tmp) +time_t mailcore::mkgmtime(struct tm * tmp) { int dir; int bits; diff --git a/src/core/basetypes/MCLibetpan.h b/src/core/basetypes/MCLibetpan.h index 41024137..4e3bfe97 100644 --- a/src/core/basetypes/MCLibetpan.h +++ b/src/core/basetypes/MCLibetpan.h @@ -19,6 +19,7 @@ namespace mailcore { time_t timestampFromIMAPDate(struct mailimap_date_time * date_time); struct mailimf_date_time * dateFromTimestamp(time_t timeval); struct mailimap_date_time * imapDateFromTimestamp(time_t timeval); + time_t mkgmtime(struct tm * tmp); } diff --git a/src/core/basetypes/MCRange.cpp b/src/core/basetypes/MCRange.cpp index d99e3dec..fb6b3486 100644 --- a/src/core/basetypes/MCRange.cpp +++ b/src/core/basetypes/MCRange.cpp @@ -12,6 +12,10 @@ #include <sys/param.h> #endif +#if defined(ANDROID) || defined(__ANDROID__) +#include "MCAndroid.h" +#endif + using namespace mailcore; Range mailcore::RangeEmpty = {UINT64_MAX, 0}; diff --git a/src/core/basetypes/MCString.cpp b/src/core/basetypes/MCString.cpp index b3beeb40..90d7b227 100644 --- a/src/core/basetypes/MCString.cpp +++ b/src/core/basetypes/MCString.cpp @@ -13,7 +13,7 @@ #include <unicode/ucnv.h> #include <unicode/utypes.h> #endif -#ifndef _MSC_VER +#if !defined(_MSC_VER) && !defined(ANDROID) && !defined(__ANDROID__) #include <uuid/uuid.h> #endif #include <pthread.h> @@ -1384,6 +1384,26 @@ String * String::extractedSubjectAndKeepBracket(bool keepBracket) return str; } +#if defined(ANDROID) || defined(__ANDROID__) + +String * String::uuidString() +{ + char buffer[38]; + FILE * f = fopen("/proc/sys/kernel/random/uuid", "r"); + if (f == NULL) { + return NULL; + } + if (fgets(buffer, sizeof(buffer), f) == NULL) { + fclose(f); + return NULL; + } + buffer[38] = 0; + fclose(f); + return String::stringWithUTF8Characters(buffer); +} + +#else + #ifndef _MSC_VER String * String::uuidString() { @@ -1400,6 +1420,8 @@ String * String::uuidString() } #endif +#endif + unsigned int String::replaceOccurrencesOfString(String * occurrence, String * replacement) { unsigned int count; diff --git a/src/core/nntp/MCNNTPSession.cpp b/src/core/nntp/MCNNTPSession.cpp index 4f50f46e..44765a3e 100644 --- a/src/core/nntp/MCNNTPSession.cpp +++ b/src/core/nntp/MCNNTPSession.cpp @@ -17,6 +17,7 @@ #include "MCMessageHeader.h" #include "MCConnectionLoggerUtils.h" #include "MCCertificateUtils.h" +#include "MCLibetpan.h" #define NNTP_DEFAULT_PORT 119 #define NNTPS_DEFAULT_PORT 563 @@ -504,21 +505,21 @@ time_t NNTPSession::fetchServerDate(ErrorCode * pError) { loginIfNeeded(pError); if (* pError != ErrorNone) { - return NULL; + return (time_t) -1; } r = newsnntp_date(mNNTP, &time); if (r == NEWSNNTP_ERROR_STREAM) { * pError = ErrorConnection; - return NULL; + return (time_t) -1; } else if (r != NEWSNNTP_NO_ERROR) { * pError = ErrorServerDate; - return NULL; + return (time_t) -1; } - result = timegm(&time); + result = mkgmtime(&time); * pError = ErrorNone; return result; diff --git a/src/core/zip/MCZip.cpp b/src/core/zip/MCZip.cpp index 6e700732..620aeb06 100644 --- a/src/core/zip/MCZip.cpp +++ b/src/core/zip/MCZip.cpp @@ -8,6 +8,7 @@ #include <sys/types.h> #ifndef _MSC_VER #include <dirent.h> +#include <unistd.h> #endif #include <sys/stat.h> #include <time.h> diff --git a/src/core/zip/MiniZip/ioapi.c b/src/core/zip/MiniZip/ioapi.c index 9b04a2a8..58c8fc64 100644 --- a/src/core/zip/MiniZip/ioapi.c +++ b/src/core/zip/MiniZip/ioapi.c @@ -16,7 +16,7 @@ #include "ioapi.h" -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(ANDROID) || defined(__ANDROID__) #define off64_t off_t #define fopen64 fopen #define ftello64 ftello |