Browse Source

Merge branch 'Release_2.1'

pull/8/head
heck 4 years ago
parent
commit
768e02a6a4
  1. 4
      build-android/jni/Android.mk
  2. 2
      build-android/takeOutHeaderFiles.sh
  3. 45
      build-windows/libpEpAdapter.vcxproj
  4. 49
      build-windows/libpEpAdapter.vcxproj.filters
  5. 36
      src/message_cache.cc
  6. 10
      test/test_message_cache.cc

4
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)

2
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"

45
build-windows/libpEpAdapter.vcxproj

@ -86,30 +86,31 @@
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\Adapter.cc" />
<ClCompile Include="..\callback_dispatcher.cc" />
<ClCompile Include="..\call_with_lock.cc" />
<ClCompile Include="..\constant_time_algo.cc" />
<ClCompile Include="..\message_cache.cc" />
<ClCompile Include="..\passphrase_cache.cc" />
<ClCompile Include="..\pEpLog.cc" />
<ClCompile Include="..\slurp.cc" />
<ClCompile Include="..\status_to_string.cc" />
<ClCompile Include="..\src\Adapter.cc" />
<ClCompile Include="..\src\callback_dispatcher.cc" />
<ClCompile Include="..\src\call_with_lock.cc" />
<ClCompile Include="..\src\constant_time_algo.cc" />
<ClCompile Include="..\src\message_cache.cc" />
<ClCompile Include="..\src\passphrase_cache.cc" />
<ClCompile Include="..\src\pEpLog.cc" />
<ClCompile Include="..\src\slurp.cc" />
<ClCompile Include="..\src\status_to_string.cc" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\Adapter.hh" />
<ClInclude Include="..\Adapter.hxx" />
<ClInclude Include="..\callback_dispatcher.hh" />
<ClInclude Include="..\constant_time_algo.hh" />
<ClInclude Include="..\locked_queue.hh" />
<ClInclude Include="..\message_cache.hh" />
<ClInclude Include="..\passphrase_cache.hh" />
<ClInclude Include="..\passphrase_cache.hxx" />
<ClInclude Include="..\pc_container.hh" />
<ClInclude Include="..\pEpLog.hh" />
<ClInclude Include="..\Semaphore.hh" />
<ClInclude Include="..\slurp.hh" />
<ClInclude Include="..\status_to_string.hh" />
<ClInclude Include="..\src\Adapter.hh" />
<ClInclude Include="..\src\Adapter.hxx" />
<ClInclude Include="..\src\callback_dispatcher.hh" />
<ClInclude Include="..\src\call_with_lock.hh" />
<ClInclude Include="..\src\constant_time_algo.hh" />
<ClInclude Include="..\src\locked_queue.hh" />
<ClInclude Include="..\src\message_cache.hh" />
<ClInclude Include="..\src\passphrase_cache.hh" />
<ClInclude Include="..\src\passphrase_cache.hxx" />
<ClInclude Include="..\src\pc_container.hh" />
<ClInclude Include="..\src\pEpLog.hh" />
<ClInclude Include="..\src\Semaphore.hh" />
<ClInclude Include="..\src\slurp.hh" />
<ClInclude Include="..\src\status_to_string.hh" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\pEpEngine\build-windows\pEpEngine.vcxproj">

49
build-windows/libpEpAdapter.vcxproj.filters

@ -18,72 +18,75 @@
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\Adapter.cc">
<ClCompile Include="..\src\Adapter.cc">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\status_to_string.cc">
<ClCompile Include="..\src\call_with_lock.cc">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\call_with_lock.cc">
<ClCompile Include="..\src\callback_dispatcher.cc">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\slurp.cc">
<ClCompile Include="..\src\constant_time_algo.cc">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\passphrase_cache.cc">
<ClCompile Include="..\src\message_cache.cc">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\callback_dispatcher.cc">
<ClCompile Include="..\src\passphrase_cache.cc">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\message_cache.cc">
<ClCompile Include="..\src\pEpLog.cc">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\constant_time_algo.cc">
<ClCompile Include="..\src\slurp.cc">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\pEpLog.cc">
<ClCompile Include="..\src\status_to_string.cc">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\Adapter.hh">
<ClInclude Include="..\src\call_with_lock.hh">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\locked_queue.hh">
<ClInclude Include="..\src\Adapter.hh">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\pc_container.hh">
<ClInclude Include="..\src\Adapter.hxx">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\Adapter.hxx">
<Filter>Source Files</Filter>
<ClInclude Include="..\src\callback_dispatcher.hh">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\constant_time_algo.hh">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\status_to_string.hh">
<ClInclude Include="..\src\locked_queue.hh">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\slurp.hh">
<ClInclude Include="..\src\message_cache.hh">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\passphrase_cache.hh">
<ClInclude Include="..\src\passphrase_cache.hh">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\passphrase_cache.hxx">
<ClInclude Include="..\src\passphrase_cache.hxx">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\callback_dispatcher.hh">
<ClInclude Include="..\src\pc_container.hh">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\Semaphore.hh">
<ClInclude Include="..\src\pEpLog.hh">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\message_cache.hh">
<ClInclude Include="..\src\Semaphore.hh">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\constant_time_algo.hh">
<ClInclude Include="..\src\slurp.hh">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\pEpLog.hh">
<ClInclude Include="..\src\status_to_string.hh">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>

36
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("<pEp/>");
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("<pEp/>");
}
}
}
}
// 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<std::mutex> l(_mtx);

10
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);

Loading…
Cancel
Save