Commit 2d9ba63b authored by johan's avatar johan
Browse files

Merge branch 'dev/jni'

parents fe10e195 d35f698d
############################################################################
# CMakeLists.txt
# Copyright (C) 2017 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
############################################################################
include(GNUInstallDirs)
include(CheckSymbolExists)
include(CheckLibraryExists)
include(CMakePushCheckState)
include(CMakePackageConfigHelpers)
cmake_minimum_required(VERSION 3.0)
project(lime VERSION 0.0.1 LANGUAGES CXX C)
set(LIME_SO_VERSION "0")
set(LIME_VERSION ${PROJECT_VERSION})
option(ENABLE_SHARED "Build shared library." ON)
option(ENABLE_STATIC "Build static library." ON)
option(ENABLE_STRICT "Build with strict compile options." YES)
option(ENABLE_CURVE25519 "Enable support of Curve 25519." YES)
option(ENABLE_CURVE448 "Enable support of Curve 448(goldilock)." YES)
option(ENABLE_UNIT_TESTS "Enable compilation of unit tests." YES)
option(ENABLE_PROFILING "Enable profiling, GCC only" NO)
option(ENABLE_C_INTERFACE "Enable support of C89 foreign function interface" NO)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
if(NOT CPACK_GENERATOR AND NOT CMAKE_INSTALL_RPATH AND CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR})
message(STATUS "Setting install rpath to ${CMAKE_INSTALL_RPATH}")
endif()
if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
set(BcToolbox_FIND_COMPONENTS tester)
include("${EP_bctoolbox_CONFIG_DIR}/BcToolboxConfig.cmake")
else()
find_package(BcToolbox 0.5.1 REQUIRED OPTIONAL_COMPONENTS tester)
endif()
find_package(Soci REQUIRED)
include_directories(
include/
src/
${CMAKE_CURRENT_BINARY_DIR}
)
if(MSVC)
include_directories(${MSVC_INCLUDE_DIR})
endif()
set(LIME_INCLUDE_DIRS
${PROJECT_SOURCE_DIR}/include
)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/config.h PROPERTIES GENERATED ON)
set(LIME_CPPFLAGS ${BCTOOLBOX_CPPFLAGS})
if(LIME_CPPFLAGS)
list(REMOVE_DUPLICATES LIME_CPPFLAGS)
add_definitions(${LIME_CPPFLAGS})
endif()
add_definitions("-DLIME_EXPORTS")
set(STRICT_OPTIONS_C)
set(STRICT_OPTIONS_CPP )
set(STRICT_OPTIONS_CXX )
set(STRICT_OPTIONS_OBJC )
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD 99)
if(MSVC)
if(ENABLE_STRICT)
list(APPEND STRICT_OPTIONS_CPP "/WX")
endif()
# avoid conflicts with std::min and std::max
add_definitions("-DNOMINMAX")
else()
if (ENABLE_PROFILING)
list(APPEND STRICT_OPTIONS_CXX "-g -pg")
endif()
#list(APPEND STRICT_OPTIONS_CPP "-Wall" "-Wuninitialized" "-Wno-error=deprecated-declarations") # turn off deprecated-declaration warning to avoid being flooded by soci.h
list(APPEND STRICT_OPTIONS_CPP "-Wall" "-Wuninitialized" "-Wno-deprecated-declarations" "-Wno-missing-field-initializers")
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
list(APPEND STRICT_OPTIONS_CPP "-Qunused-arguments" "-Wno-array-bounds")
endif()
if(APPLE)
list(APPEND STRICT_OPTIONS_CPP "-Wno-error=unknown-warning-option" "-Qunused-arguments" "-Wno-tautological-compare" "-Wno-unused-function" "-Wno-array-bounds")
endif()
if(ENABLE_STRICT)
list(APPEND STRICT_OPTIONS_CPP "-Werror" "-Wextra" "-Wno-unused-parameter" "-fno-strict-aliasing")
endif()
endif()
if(STRICT_OPTIONS_CPP)
list(REMOVE_DUPLICATES STRICT_OPTIONS_CPP)
endif()
if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
set(EXPORT_TARGETS_NAME "LinphoneBuilder")
else()
set(EXPORT_TARGETS_NAME "lime")
endif()
if (ENABLE_CURVE25519)
add_definitions("-DEC25519_ENABLED")
message(STATUS "Support Curve 25519")
endif()
if (ENABLE_CURVE448)
add_definitions("-DEC448_ENABLED")
message(STATUS "Support Curve 448")
endif()
if(ENABLE_C_INTERFACE)
add_definitions("-DFFI_ENABLED")
message(STATUS "Provide C89 interface")
endif()
add_subdirectory(include)
add_subdirectory(src)
if(ENABLE_UNIT_TESTS AND BCTOOLBOX_TESTER_FOUND)
enable_testing()
add_subdirectory(tester)
endif()
export(EXPORT ${EXPORT_TARGETS_NAME}Targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/LimeTargets.cmake"
)
configure_file(cmake/LimeConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/LimeConfig.cmake"
@ONLY
)
set(ConfigPackageLocation "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake")
install(EXPORT ${EXPORT_TARGETS_NAME}Targets
FILE LimeTargets.cmake
DESTINATION ${ConfigPackageLocation}
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/LimeConfig.cmake"
DESTINATION ${ConfigPackageLocation}
)
# Doxygen
find_package(Doxygen)
if (DOXYGEN_FOUND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
add_custom_target(doc
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
endif()
add_subdirectory(build)
############################################################################
# CMakeLists.txt
# Copyright (C) 2017 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
############################################################################
include(GNUInstallDirs)
include(CheckSymbolExists)
include(CheckLibraryExists)
include(CMakePushCheckState)
include(CMakePackageConfigHelpers)
cmake_minimum_required(VERSION 3.0)
project(lime VERSION 0.0.1 LANGUAGES CXX C Java)
set(LIME_SO_VERSION "0")
set(LIME_VERSION ${PROJECT_VERSION})
option(ENABLE_SHARED "Build shared library." YES)
option(ENABLE_STATIC "Build static library." YES)
option(ENABLE_STRICT "Build with strict compile options." YES)
option(ENABLE_CURVE25519 "Enable support of Curve 25519." YES)
option(ENABLE_CURVE448 "Enable support of Curve 448(goldilock)." YES)
option(ENABLE_UNIT_TESTS "Enable compilation of unit tests." YES)
option(ENABLE_PROFILING "Enable profiling, GCC only" NO)
option(ENABLE_C_INTERFACE "Enable support of C89 foreign function interface" NO)
option(ENABLE_JNI "Enable support of Java foreign function interface" NO)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
if(NOT CPACK_GENERATOR AND NOT CMAKE_INSTALL_RPATH AND CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR})
message(STATUS "Setting install rpath to ${CMAKE_INSTALL_RPATH}")
endif()
if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
set(BcToolbox_FIND_COMPONENTS tester)
include("${EP_bctoolbox_CONFIG_DIR}/BcToolboxConfig.cmake")
else()
find_package(BcToolbox 0.5.1 REQUIRED OPTIONAL_COMPONENTS tester)
endif()
find_package(Soci REQUIRED)
include_directories(
include/
src/
${CMAKE_CURRENT_BINARY_DIR}
)
if(MSVC)
include_directories(${MSVC_INCLUDE_DIR})
endif()
set(LIME_INCLUDE_DIRS
${PROJECT_SOURCE_DIR}/include
)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/config.h PROPERTIES GENERATED ON)
set(LIME_CPPFLAGS ${BCTOOLBOX_CPPFLAGS})
if(LIME_CPPFLAGS)
list(REMOVE_DUPLICATES LIME_CPPFLAGS)
add_definitions(${LIME_CPPFLAGS})
endif()
add_definitions("-DLIME_EXPORTS")
set(STRICT_OPTIONS_C)
set(STRICT_OPTIONS_CPP )
set(STRICT_OPTIONS_CXX )
set(STRICT_OPTIONS_OBJC )
if(ENABLE_JNI)
set(CMAKE_CXX_STANDARD 14)
else()
set(CMAKE_CXX_STANDARD 11)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD 99)
if(MSVC)
if(ENABLE_STRICT)
list(APPEND STRICT_OPTIONS_CPP "/WX")
endif()
# avoid conflicts with std::min and std::max
add_definitions("-DNOMINMAX")
else()
if (ENABLE_PROFILING)
list(APPEND STRICT_OPTIONS_CXX "-g -pg")
endif()
#list(APPEND STRICT_OPTIONS_CPP "-Wall" "-Wuninitialized" "-Wno-error=deprecated-declarations") # turn off deprecated-declaration warning to avoid being flooded by soci.h
list(APPEND STRICT_OPTIONS_CPP "-Wall" "-Wuninitialized" "-Wno-deprecated-declarations" "-Wno-missing-field-initializers")
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
list(APPEND STRICT_OPTIONS_CPP "-Qunused-arguments" "-Wno-array-bounds")
endif()
if(APPLE)
list(APPEND STRICT_OPTIONS_CPP "-Wno-error=unknown-warning-option" "-Qunused-arguments" "-Wno-tautological-compare" "-Wno-unused-function" "-Wno-array-bounds")
endif()
if(ENABLE_STRICT)
list(APPEND STRICT_OPTIONS_CPP "-Werror" "-Wextra" "-Wno-unused-parameter" "-fno-strict-aliasing")
endif()
endif()
if(STRICT_OPTIONS_CPP)
list(REMOVE_DUPLICATES STRICT_OPTIONS_CPP)
endif()
if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
set(EXPORT_TARGETS_NAME "LinphoneBuilder")
else()
set(EXPORT_TARGETS_NAME "lime")
endif()
if (ENABLE_CURVE25519)
add_definitions("-DEC25519_ENABLED")
message(STATUS "Support Curve 25519")
endif()
if (ENABLE_CURVE448)
add_definitions("-DEC448_ENABLED")
message(STATUS "Support Curve 448")
endif()
if(ENABLE_C_INTERFACE)
add_definitions("-DFFI_ENABLED")
message(STATUS "Provide C89 interface")
endif()
if(ENABLE_JNI)
message(STATUS "Provide JNI interface")
if (NOT ANDROID)
find_package(JNI REQUIRED)
if (JNI_FOUND)
message (STATUS "JNI_INCLUDE_DIRS=${JNI_INCLUDE_DIRS}")
message (STATUS "JNI_LIBRARIES=${JNI_LIBRARIES}")
endif()
endif()
endif()
add_subdirectory(include)
add_subdirectory(src)
if(ENABLE_UNIT_TESTS AND BCTOOLBOX_TESTER_FOUND)
enable_testing()
add_subdirectory(tester)
endif()
export(EXPORT ${EXPORT_TARGETS_NAME}Targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/LimeTargets.cmake"
)
configure_file(cmake/LimeConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/LimeConfig.cmake"
@ONLY
)
set(ConfigPackageLocation "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake")
install(EXPORT ${EXPORT_TARGETS_NAME}Targets
FILE LimeTargets.cmake
DESTINATION ${ConfigPackageLocation}
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/LimeConfig.cmake"
DESTINATION ${ConfigPackageLocation}
)
# Doxygen
find_package(Doxygen)
if (DOXYGEN_FOUND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
add_custom_target(doc
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
endif()
add_subdirectory(build)
This diff is collapsed.
......@@ -8,6 +8,14 @@ Lime can run the Signal Protocol using elliptic curve 25519 or curve 448-goldilo
It is designed to work jointly with *Linphone*[1] in a multiple devices per user and multiple users per device environment.
License
--------
Copyright (c) 2019 Belledonne Communications SARL under GNU GPLv3 (see *LICENSE.txt*)
The above license excludes the content of *src/jni* directory Copyright (c) 2016 Mapbox covered by its respective license,
see *src/jni/LICENSE.txt*
Dependencies
------------
- *bctoolbox[2]* : portability layer, built with Elliptic Curve Cryptography
......@@ -23,7 +31,6 @@ Build instrucitons
make install
```
Documentation
-------------
......@@ -38,37 +45,57 @@ Comprehensive documentation on implementation choices and built-in protocols in
Testing
-------
To test on local machine, you must run a local X3DH server.
To test on local machine, you must run a local X3DH server.
- A nodejs/sqlite version of UNSECURE X3DH server is provided in *tester/server/nodejs*
See README from this directory for instructions.
- A php/mysql (on docker) version of UNSECURE X3DH server is provided in *tester/server/php*
See README from this directory for instructions.
If a local X3DH server is running with default parameter just run
```
make test
```
To launch a particular test suite, use ctest, running:
```
ctest -R <Test suite name> [--verbose]
```
Test suite names are
- *crypto*: Test the crypto primitives
- *double_ratchet*: Specific to the Double Ratchet protocol
- *hello_world*: Basic Lime test, mostly a demo code. Requires a live X3DH server on localhost
- *lime*: Complete testing of all features provided by the library. Requires a live X3DH server on localhost
- *C_ffi*: Available only if C interface is enabled, test the C89 foreign function interface
- *JNI*: Available only if JNI is enabled, test the Java foreign function interface
Library settings
----------------
Some mostly harmless settings are available in *src/lime_settings.hpp*
Library API
Library APIs
-----------
The C++11 API is available in *include/lime/lime.hpp*
if enabled (see Options), a C89 FFI is provided by *include/lime/lime_ffi.h*
if enabled (see Options), a java FFI is provided by *Lime.jar* located in the build directory in *src/java* subdirectory
Options
-------
- `CMAKE_INSTALL_PREFIX=<string>` : installation prefix
- `CMAKE_PREFIX_PATH=<string>` : prefix where depedencies are installed
- `ENABLE_UNIT_TESTS=NO` : do not compile non-regression tests
- `ENABLE_SHARED=NO` : do not build the shared library.
- `ENABLE_STATIC=NO` : do not build the static library.
- `ENABLE_STRICT=NO` : do not build with strict complier flags e.g. `-Wall -Werror`
- `ENABLE_Curve25519` : Enable support of Curve 25519.
- `ENABLE_Curve448` : Enable support of Curve 448.
- `ENABLE_PROFILING` : Enable code profiling for GCC
- `ENABLE_C_INTERFACE` : Enable support of C89 foreign function interface
- `ENABLE_UNIT_TESTS` : compile non-regression tests (default YES)
- `ENABLE_SHARED` : build the shared library (default YES)
- `ENABLE_STATIC` : build the static library (default YES)
- `ENABLE_STRICT` : build with strict complier flags e.g. `-Wall -Werror` (default YES)
- `ENABLE_CURVE25519` : Enable support of Curve 25519 (default YES)
- `ENABLE_CURVE448` : Enable support of Curve 448 (default YES)
- `ENABLE_PROFILING` : Enable code profiling for GCC (default NO)
- `ENABLE_C_INTERFACE` : Enable support of C89 foreign function interface (default NO)
- `ENABLE_JNI` : Enable support of Java foreign function interface (default NO)
------------------
......
......@@ -65,7 +65,8 @@ namespace lime {
*/
struct RecipientData {
const std::string deviceId; /**< input: recipient deviceId (shall be GRUU) */
lime::PeerDeviceStatus peerStatus; /**< output: after encrypt calls back, it will hold the status of this peer device:\n
lime::PeerDeviceStatus peerStatus; /**< input: if set to fail, this entry will be ignored by the encrypt function\n
output: after encrypt calls back, it will hold the status of this peer device:\n
- unknown: first interaction with this device)
- untrusted: device is kown but we never confirmed its identity public key
- trusted: we already confirmed this device identity public key
......@@ -202,7 +203,7 @@ namespace lime {
* It is advised to capture a copy of cipherMessage and recipients shared_ptr in this callback so they can access
* the output of encryption as it won't be part of the callback parameters.
* @param[in] encryptionPolicy select how to manage the encryption: direct use of Double Ratchet message or encrypt in the cipher message and use the DR message to share the cipher message key
* default is optimized output size mode.
* default is optimized upload size mode.
*/
void encrypt(const std::string &localDeviceId, std::shared_ptr<const std::string> recipientUserId, std::shared_ptr<std::vector<RecipientData>> recipients, std::shared_ptr<const std::vector<uint8_t>> plainMessage, std::shared_ptr<std::vector<uint8_t>> cipherMessage, const limeCallback &callback, lime::EncryptionPolicy encryptionPolicy=lime::EncryptionPolicy::optimizeUploadSize);
......
......@@ -48,13 +48,18 @@ if (ENABLE_C_INTERFACE)
set(LIME_SOURCE_FILES_CXX ${LIME_SOURCE_FILES_CXX} lime_ffi.cpp)
endif()
if (ENABLE_JNI)
set(LIME_SOURCE_FILES_CXX ${LIME_SOURCE_FILES_CXX} lime_jni.cpp)
add_subdirectory(java)
endif()
bc_apply_compile_flags(LIME_SOURCE_FILES_CXX STRICT_OPTIONS_CPP STRICT_OPTIONS_CXX)
if(ENABLE_STATIC)
add_library(lime-static STATIC ${LIME_PRIVATE_HEADER_FILES} ${LIME_SOURCE_FILES_CXX})
set_target_properties(lime-static PROPERTIES OUTPUT_NAME lime)
target_include_directories(lime-static PUBLIC ${BCTOOLBOX_INCLUDE_DIRS} ${SOCI_INCLUDE_DIRS} ${SOCI_INCLUDE_DIRS}/soci)
target_link_libraries(lime-static INTERFACE ${BCTOOLBOX_CORE_LIBRARIES} ${SOCI_LIBRARIES} ${SOCI_sqlite3_PLUGIN})
target_include_directories(lime-static PUBLIC ${BCTOOLBOX_INCLUDE_DIRS} ${SOCI_INCLUDE_DIRS} ${SOCI_INCLUDE_DIRS}/soci ${JNI_INCLUDE_DIRS})
target_link_libraries(lime-static INTERFACE ${BCTOOLBOX_CORE_LIBRARIES} ${SOCI_LIBRARIES} ${SOCI_sqlite3_PLUGIN} ${JNI_LIBRARIES})
if(ENABLE_PROFILING)
set_target_properties(lime-static PROPERTIES LINK_FLAGS "-pg")
endif()
......@@ -62,8 +67,8 @@ endif()
if(ENABLE_SHARED)
add_library(lime SHARED ${LIME_PRIVATE_HEADER_FILES} ${LIME_HEADER_FILES} ${LIME_SOURCE_FILES_CXX})
set_target_properties(lime PROPERTIES VERSION ${LIME_SO_VERSION})
target_include_directories(lime PUBLIC ${BCTOOLBOX_INCLUDE_DIRS} ${SOCI_INCLUDE_DIRS} ${SOCI_INCLUDE_DIRS}/soci)
target_link_libraries(lime PRIVATE ${BCTOOLBOX_CORE_LIBRARIES} ${SOCI_LIBRARIES} ${SOCI_sqlite3_PLUGIN})
target_include_directories(lime PUBLIC ${BCTOOLBOX_INCLUDE_DIRS} ${SOCI_INCLUDE_DIRS} ${SOCI_INCLUDE_DIRS}/soci ${JNI_INCLUDE_DIRS})
target_link_libraries(lime PRIVATE ${BCTOOLBOX_CORE_LIBRARIES} ${SOCI_LIBRARIES} ${SOCI_sqlite3_PLUGIN} ${JNI_LIBRARIES})
# TODO: replace by if(APPLE) when we want to make apple framework on linphone-desktop too
if(IOS)
if(IOS)
......
############################################################################
# CMakeLists.txt
# Copyright (C) 2019 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
############################################################################
find_package(Java REQUIRED)
include(UseJava)
set (LIME_SOURCE_FILES_JAVA
org/linphone/lime/LimeException.java
org/linphone/lime/LimeCurveId.java
org/linphone/lime/LimeEncryptionPolicy.java
org/linphone/lime/LimeOutputBuffer.java
org/linphone/lime/LimePeerDeviceStatus.java
org/linphone/lime/LimeCallbackReturn.java
org/linphone/lime/LimeStatusCallback.java
org/linphone/lime/RecipientData.java
org/linphone/lime/LimePostToX3DH.java
org/linphone/lime/LimeManager.java
)
add_jar(Lime ${LIME_SOURCE_FILES_JAVA})
get_target_property(Lime_jarFile Lime JAR_FILE)
message(STATUS "Lime Jar file ${Lime_jarFile}")
/*
LimeCallbackReturn.java
@author Johan Pascal
@copyright Copyright (C) 2019 Belledonne Communications SARL
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.linphone.lime;
/** @brief Enumeration remapping the lime::CallbackReturn
* - java enumeration is mapped to an int
* - jni code map the same int to the original lime::CallbackReturn
*/
public enum LimeCallbackReturn {
SUCCESS(0),
FAIL(1);
private int native_val; /* Store the native(used by jni) integer value */
private LimeCallbackReturn(int val) {
native_val = val;
}
/**
* @brief static method to get an enum value from the native jni integer(used as returned value by native function)
*
* @param[in] val integer value mapped to the jni enum
*
* @return one of the enumeration value, unknown input will silently default to FAIL
*/
public static LimeCallbackReturn fromNative(int val) {
switch (val) {
case 0:
return LimeCallbackReturn.SUCCESS;
case 1:
default:
return LimeCallbackReturn.FAIL;
}
}
}