diff --git a/build-android/jni/Android.mk b/build-android/jni/Android.mk
index 9664823..f54ff73 100644
--- a/build-android/jni/Android.mk
+++ b/build-android/jni/Android.mk
@@ -18,14 +18,14 @@ LOCAL_CPPFLAGS += -std=c++14 -DANDROID_STL=c++_shared
STUB = $(shell sh $(LOCAL_PATH)/../takeOutHeaderFiles.sh $(LOCAL_PATH)/../../../pEpEngine/ $(LOCAL_PATH)/../../)
$(info $(STUB))
-LIB_PEP_ADAPTER_INCLUDE_FILES := $(wildcard $(LOCAL_PATH)/../../*.h*)
+LIB_PEP_ADAPTER_INCLUDE_FILES := $(wildcard $(LOCAL_PATH)/../../src/*.h*)
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../pEpEngine/build-android/include \
$(LIB_PEP_ADAPTER_INCLUDE_FILES:%=%)
LOCAL_EXPORT_C_INCLUDES += $(LOCAL_PATH)../include
-LOCAL_SRC_FILES += $(wildcard $(LOCAL_PATH)/../../*.cc)
+LOCAL_SRC_FILES += $(wildcard $(LOCAL_PATH)/../../src/*.cc)
include $(BUILD_STATIC_LIBRARY)
diff --git a/build-android/takeOutHeaderFiles.sh b/build-android/takeOutHeaderFiles.sh
index 70260f8..3677b77 100755
--- a/build-android/takeOutHeaderFiles.sh
+++ b/build-android/takeOutHeaderFiles.sh
@@ -6,5 +6,5 @@ engine_dir="$1"
adapter_dir="$2"
mkdir -p "$engine_dir/build-android/include/pEp"
-cp $2/*.h* "$engine_dir/build-android/include/pEp"
+cp $2/src/*.h* "$engine_dir/build-android/include/pEp"
diff --git a/build-windows/libpEpAdapter.vcxproj b/build-windows/libpEpAdapter.vcxproj
index eabd4a5..0471158 100644
--- a/build-windows/libpEpAdapter.vcxproj
+++ b/build-windows/libpEpAdapter.vcxproj
@@ -86,30 +86,31 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/build-windows/libpEpAdapter.vcxproj.filters b/build-windows/libpEpAdapter.vcxproj.filters
index ccbd6b4..1b95d5f 100644
--- a/build-windows/libpEpAdapter.vcxproj.filters
+++ b/build-windows/libpEpAdapter.vcxproj.filters
@@ -18,72 +18,75 @@
-
+
Source Files
-
+
Source Files
-
+
Source Files
-
+
Source Files
-
+
Source Files
-
+
Source Files
-
+
Source Files
-
+
Source Files
-
+
Source Files
-
+
Header Files
-
+
Header Files
-
+
Header Files
-
- Source Files
+
+ Header Files
+
+
+ Header Files
-
+
Header Files
-
+
Header Files
-
+
Header Files
-
+
Header Files
-
+
Header Files
-
+
Header Files
-
+
Header Files
-
+
Header Files
-
+
Header Files
diff --git a/src/message_cache.cc b/src/message_cache.cc
index b8cfaf3..e83bad3 100644
--- a/src/message_cache.cc
+++ b/src/message_cache.cc
@@ -196,7 +196,7 @@ namespace pEp {
return false;
}
- static ::message *empty_message_copy(const ::message *src, std::string _id = "")
+ static ::message *empty_message_copy(const ::message *src, std::string _id = "", bool get_longmsg = false)
{
if (!src)
return nullptr;
@@ -207,12 +207,32 @@ namespace pEp {
dst->id = dup(src->id);
- if (!emptystr(src->shortmsg))
- dst->shortmsg = dup(src->shortmsg);
- else if (!emptystr(src->longmsg))
- dst->longmsg = dup("pEp");
- else if (!emptystr(src->longmsg_formatted))
- dst->longmsg_formatted = dup("");
+ if (get_longmsg) {
+ if (!emptystr(src->shortmsg)) {
+ dst->shortmsg = dup(src->shortmsg);
+ }
+ // We need either longmsg or longmsg_formatted for a "message preview".
+ if (!emptystr(src->longmsg)) {
+ dst->longmsg = dup(src->longmsg);
+ } else {
+ if (!emptystr(src->longmsg_formatted)) {
+ dst->longmsg_formatted = dup(src->longmsg_formatted);
+ }
+ }
+ } else {
+ // It is a pEp convention to return at least one of shortmsg, longmsg or longmsg_formatted.
+ if (!emptystr(src->shortmsg)) {
+ dst->shortmsg = dup(src->shortmsg);
+ } else {
+ if (!emptystr(src->longmsg)) {
+ dst->longmsg = dup("pEp");
+ } else {
+ if (!emptystr(src->longmsg_formatted)) {
+ dst->longmsg_formatted = dup("");
+ }
+ }
+ }
+ }
// attachments are never copied
@@ -313,7 +333,7 @@ namespace pEp {
::message *_dst = nullptr;
PEP_STATUS status = ::decrypt_message(session, src, &_dst, keylist, rating, flags);
- *dst = empty_message_copy(_dst, _id);
+ *dst = empty_message_copy(_dst, _id, true);
{
std::lock_guard l(_mtx);
diff --git a/test/test_message_cache.cc b/test/test_message_cache.cc
index a7d275a..6c35b1b 100644
--- a/test/test_message_cache.cc
+++ b/test/test_message_cache.cc
@@ -46,6 +46,7 @@ int main(int argc, char **argv)
src->dir = ::PEP_dir_outgoing;
::message *dst = nullptr;
+ cout << "cache_encrypt_message()" << endl;
status = MessageCache::cache_encrypt_message(
Adapter::session(),
src,
@@ -66,13 +67,14 @@ int main(int argc, char **argv)
mime = nullptr;
status = MessageCache::cache_mime_encode_message(MessageCache::msg_src, src, false, &mime, false);
assert(status == PEP_STATUS_OK);
-
- cout << mime << endl;
+ cout << "cache_mime_encode_message()" << endl;
+ cout << "mime: " << endl << mime << endl;
// add to cache
::free_message(src);
src = nullptr;
+ cout << "cache_mime_decode_message" << endl;
status = MessageCache::cache_mime_decode_message(mime, strlen(mime), &src, &has_possible_pEp_msg);
assert(status == PEP_STATUS_OK);
@@ -83,6 +85,7 @@ int main(int argc, char **argv)
::PEP_decrypt_flags_t flags = 0;
::stringlist_t *keylist = nullptr;
+ cout << "cache_decrypt_message" << endl;
status = MessageCache::cache_decrypt_message(
Adapter::session(),
src,
@@ -99,12 +102,13 @@ int main(int argc, char **argv)
free(mime);
mime = nullptr;
+ cout << "cache_mime_encode_message" << endl;
status = MessageCache::cache_mime_encode_message(MessageCache::msg_src, src, false, &mime, false);
assert(src->longmsg == nullptr);
assert(src->attachments == nullptr);
- cout << mime << endl;
+ cout << "mime: " << endl << mime << endl;
free(mime);
::free_message(src);