From cde2d55d840fc3980f21c9c1a474fdb2704d0437 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Wed, 25 Feb 2015 16:57:16 +0100 Subject: [PATCH 1/4] Fix charset issue with sqlite3_open() sqlite3_open() requires that the path is encoded into UTF-8 --- configure.ac | 3 +++ coreapi/message_storage.c | 40 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index d696bf31b..f428f8dad 100644 --- a/configure.ac +++ b/configure.ac @@ -852,6 +852,9 @@ if test x$enable_msg_storage != xfalse; then fi if test "$found_sqlite" = "yes"; then SQLITE3_CFLAGS+="-DMSG_STORAGE_ENABLED" + if test "$build_macos" = "yes" -o "$ios_found"="yes"; then + SQLITE3_LIBS+=" -liconv" + fi enable_msg_storage=true else if test x$enable_msg_storage = xtrue; then diff --git a/coreapi/message_storage.c b/coreapi/message_storage.c index 91fd8e333..d42d19236 100644 --- a/coreapi/message_storage.c +++ b/coreapi/message_storage.c @@ -25,6 +25,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define PRIu64 "I64u" #endif +#ifndef WIN32 +#include +#include +#include +#else +#include +#endif + +#define MAX_PATH_SIZE 1024 + #include "sqlite3.h" static ORTP_INLINE LinphoneChatMessage* get_transient_message(LinphoneChatRoom* cr, unsigned int storage_id){ @@ -579,6 +589,34 @@ void linphone_core_message_storage_set_debug(LinphoneCore *lc, bool_t debug){ } } +static int _linphone_sqlite3_open(const char *db_file, sqlite3 **db) { +#ifdef ANDROID + return sqlite3_open(db_file, db); +#elif defined(WIN32) + int ret; + wchar_t db_file_utf16[MAX_PATH_SIZE]; + ret = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, db_file, MAX_PATH_SIZE, db_file_utf16, MAX_PATH_SIZE); + if(ret == 0) db_file_utf16[0] = '\0'; + return sqlite3_open16(db_file_utf16, db); +#else + char db_file_locale[MAX_PATH_SIZE] = {'\0'}; + char db_file_utf8[MAX_PATH_SIZE] = ""; + char *inbuf=db_file_locale, *outbuf=db_file_utf8; + size_t inbyteleft = MAX_PATH_SIZE, outbyteleft = MAX_PATH_SIZE; + iconv_t cb; + + strncpy(db_file_locale, db_file, MAX_PATH_SIZE-1); + cb = iconv_open("UTF-8", nl_langinfo(CODESET)); + if(cb != (iconv_t)-1) { + int ret; + ret = iconv(cb, &inbuf, &inbyteleft, &outbuf, &outbyteleft); + if(ret == -1) db_file_utf8[0] = '\0'; + iconv_close(cb); + } + return sqlite3_open(db_file_utf8, db); +#endif +} + void linphone_core_message_storage_init(LinphoneCore *lc){ int ret; const char *errmsg; @@ -586,7 +624,7 @@ void linphone_core_message_storage_init(LinphoneCore *lc){ linphone_core_message_storage_close(lc); - ret=sqlite3_open(lc->chat_db_file,&db); + ret=_linphone_sqlite3_open(lc->chat_db_file,&db); if(ret != SQLITE_OK) { errmsg=sqlite3_errmsg(db); ms_error("Error in the opening: %s.\n", errmsg); From 76350ee45b904cb5601a62204f8e676f7ec12159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Wed, 25 Feb 2015 17:15:46 +0100 Subject: [PATCH 2/4] Fix configure issue --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index f428f8dad..92b8fe3dd 100644 --- a/configure.ac +++ b/configure.ac @@ -852,7 +852,7 @@ if test x$enable_msg_storage != xfalse; then fi if test "$found_sqlite" = "yes"; then SQLITE3_CFLAGS+="-DMSG_STORAGE_ENABLED" - if test "$build_macos" = "yes" -o "$ios_found"="yes"; then + if test "$build_macos" = "yes" -o "$ios_found" = "yes"; then SQLITE3_LIBS+=" -liconv" fi enable_msg_storage=true From ea39673fff59fcfc6d3b1795e5a281cf24445963 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 25 Feb 2015 21:40:53 +0100 Subject: [PATCH 3/4] repair build --- mediastreamer2 | 2 +- oRTP | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mediastreamer2 b/mediastreamer2 index 3e04d7979..e35a1e71b 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 3e04d797963618ea8db5226f0519b2f8074dbc70 +Subproject commit e35a1e71bdc64bc914b866b1a66815d5e47f8a01 diff --git a/oRTP b/oRTP index d515df047..496b5b1fd 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit d515df047678da3777b5e4691dc069c6837f77bf +Subproject commit 496b5b1fd0053bf94e5e0fcecf9cd43713820ca1 From 0d4048dbdfbdf309264f9e28217ffde5faccef1e Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 25 Feb 2015 21:55:39 +0100 Subject: [PATCH 4/4] fix android compilation --- coreapi/message_storage.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/coreapi/message_storage.c b/coreapi/message_storage.c index d42d19236..cfee1c873 100644 --- a/coreapi/message_storage.c +++ b/coreapi/message_storage.c @@ -26,9 +26,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #endif #ifndef WIN32 -#include -#include -#include +#ifndef ANDROID +# include +# include +# include +#endif #else #include #endif