mirror of
https://github.com/RetroShare/libretroshare.git
synced 2026-09-12 19:50:03 +05:00
Improve CMake and WebUI support
CMake add option to build WebUI support CMake install also implementation headers, we need to do this because libretroshare doesn't encapsulate implementeation well so C++ user needs also implementation headers, not only the public ones to compile CMake properly links thread and dl libs CMake use proper flags for status messages CMake use more target_* specific functions WebUI improve error checking and reporting Move test utility header to tests directory
This commit is contained in:
parent
9bd02834a9
commit
449fcbc3f2
118
CMakeLists.txt
118
CMakeLists.txt
@ -122,10 +122,22 @@ option(
|
||||
|
||||
set(
|
||||
RS_DATA_DIR
|
||||
"${CMAKE_INSTALL_PREFIX}/share/retroshare"
|
||||
CACHE STRING
|
||||
"${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}"
|
||||
CACHE PATH
|
||||
"Path where to install RetroShare system wide data" )
|
||||
|
||||
set(
|
||||
RS_INCLUDE_INSTALL_DIR
|
||||
"${CMAKE_INSTALL_PREFIX}/include/${PROJECT_NAME}"
|
||||
CACHE PATH
|
||||
"Path where to install libretroshare headers" )
|
||||
|
||||
set(
|
||||
RS_LIB_INSTALL_DIR
|
||||
"${CMAKE_INSTALL_LIBDIR}"
|
||||
CACHE STRING
|
||||
"Path where to install libretroshare compiled library" )
|
||||
|
||||
option(
|
||||
RS_EXPORT_JNI_ONLOAD
|
||||
"Export libretroshare JNI_OnLoad. See src/rs_android/rsjni.cpp for details"
|
||||
@ -142,6 +154,13 @@ option(
|
||||
"Enable when compiling libretroshare for Android"
|
||||
OFF )
|
||||
|
||||
cmake_dependent_option(
|
||||
RS_WEBUI
|
||||
"Enable RetroShare Web UI support"
|
||||
OFF
|
||||
"RS_JSON_API"
|
||||
OFF )
|
||||
|
||||
################################################################################
|
||||
|
||||
find_package(Git REQUIRED)
|
||||
@ -182,6 +201,8 @@ if(RS_LIBRETROSHARE_SHARED)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
endif(RS_LIBRETROSHARE_SHARED)
|
||||
|
||||
## As of today libretroshare doesn't hide implementation details properly so it
|
||||
## is necessary to flag all implementation headers as public
|
||||
target_include_directories(
|
||||
${PROJECT_NAME}
|
||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src" )
|
||||
@ -192,8 +213,17 @@ set_target_properties(
|
||||
|
||||
install(
|
||||
TARGETS ${PROJECT_NAME}
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
PUBLIC_HEADER DESTINATION include/retroshare )
|
||||
LIBRARY DESTINATION "${RS_LIB_INSTALL_DIR}"
|
||||
PUBLIC_HEADER DESTINATION "${RS_INCLUDE_INSTALL_DIR}" )
|
||||
|
||||
## As of today libretroshare doesn't hide implementation details properly so it
|
||||
## is necessary to install private headers too
|
||||
foreach(P_HEADER ${RS_IMPLEMENTATION_HEADERS})
|
||||
get_filename_component(P_DIR "${P_HEADER}" DIRECTORY)
|
||||
install(
|
||||
FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/${P_HEADER}"
|
||||
DESTINATION "${RS_INCLUDE_INSTALL_DIR}/${P_DIR}" )
|
||||
endforeach()
|
||||
|
||||
if(RS_DEVELOPMENT_BUILD)
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE "-O0")
|
||||
@ -203,6 +233,12 @@ if(RS_ANDROID)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE log)
|
||||
endif(RS_ANDROID)
|
||||
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE ${CMAKE_DL_LIBS})
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE Threads::Threads)
|
||||
|
||||
find_package(OpenSSL REQUIRED)
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE ${OPENSSL_INCLUDE_DIR})
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE OpenSSL::SSL OpenSSL::Crypto)
|
||||
@ -212,7 +248,7 @@ target_link_libraries(${PROJECT_NAME} PRIVATE OpenSSL::SSL OpenSSL::Crypto)
|
||||
set(OPENPGPSDK_DEVEL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../openpgpsdk/")
|
||||
if(EXISTS "${OPENPGPSDK_DEVEL_DIR}/.git" )
|
||||
message(
|
||||
CHECK_PASS
|
||||
STATUS
|
||||
"openpgpsdk submodule found at ${OPENPGPSDK_DEVEL_DIR} using it" )
|
||||
add_subdirectory("${OPENPGPSDK_DEVEL_DIR}" "${CMAKE_BINARY_DIR}/openpgpsdk")
|
||||
else()
|
||||
@ -235,7 +271,7 @@ if(RS_BITDHT)
|
||||
set(BITDHT_DEVEL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../libbitdht/")
|
||||
if(EXISTS "${BITDHT_DEVEL_DIR}/.git" )
|
||||
message(
|
||||
CHECK_PASS
|
||||
STATUS
|
||||
"BitDHT submodule found at ${BITDHT_DEVEL_DIR} using it" )
|
||||
add_subdirectory(${BITDHT_DEVEL_DIR} ${CMAKE_BINARY_DIR}/bitdht)
|
||||
set(RS_BITDHT_DIR "${BITDHT_DEVEL_DIR}")
|
||||
@ -253,15 +289,17 @@ if(RS_BITDHT)
|
||||
set(RS_BITDHT_DIR "${bitdht_SOURCE_DIR}")
|
||||
endif()
|
||||
|
||||
add_compile_definitions(RS_USE_BITDHT)
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC RS_USE_BITDHT)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE bitdht)
|
||||
|
||||
if(RS_BITDHT_STUNNER)
|
||||
add_compile_definitions(RS_USE_DHT_STUNNER)
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC RS_USE_DHT_STUNNER)
|
||||
|
||||
if(RS_BITDHT_STUNNER_EXT_IP)
|
||||
# TODO: Refactor this define to use proper naming
|
||||
add_compile_definitions(ALLOW_DHT_STUNNER)
|
||||
# TODO: Refactor this define to use proper prefix and then flag as
|
||||
# public
|
||||
target_compile_definitions(
|
||||
${PROJECT_NAME} PRIVATE ALLOW_DHT_STUNNER )
|
||||
endif(RS_BITDHT_STUNNER_EXT_IP)
|
||||
endif(RS_BITDHT_STUNNER)
|
||||
endif(RS_BITDHT)
|
||||
@ -318,7 +356,8 @@ if(RS_JSON_API)
|
||||
"${JSONAPI_GENERATOR_OUTPUT_DIR}/jsonapi-includes.inl"
|
||||
"${JSONAPI_GENERATOR_OUTPUT_DIR}/jsonapi-wrappers.inl" )
|
||||
|
||||
include_directories(${JSONAPI_GENERATOR_OUTPUT_DIR})
|
||||
target_include_directories(
|
||||
${PROJECT_NAME} PRIVATE "${JSONAPI_GENERATOR_OUTPUT_DIR}" )
|
||||
|
||||
set(BUILD_TESTS OFF CACHE BOOL "Do not build restbed tests")
|
||||
set(BUILD_SSL OFF CACHE BOOL "Do not build restbed SSL support")
|
||||
@ -340,8 +379,10 @@ if(RS_JSON_API)
|
||||
)
|
||||
FetchContent_MakeAvailable(restbed)
|
||||
|
||||
## TODO: work around target_include_directories should be added upstream
|
||||
include_directories(${restbed_SOURCE_DIR}/source/)
|
||||
## TODO: Temporary work around target_include_directories PUBLIC should be
|
||||
## added upstream
|
||||
target_include_directories(
|
||||
${PROJECT_NAME} PRIVATE ${restbed_SOURCE_DIR}/source/ )
|
||||
|
||||
## TODO: work around target_link_libraries should be added upstream
|
||||
## The workaround doesn't work as per documentation
|
||||
@ -350,9 +391,9 @@ if(RS_JSON_API)
|
||||
#link_directories(${restbed_BINARY_DIR})
|
||||
endif(NOT RS_ANDROID)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE restbed)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE restbed-static)
|
||||
|
||||
add_compile_definitions(RS_JSONAPI)
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC RS_JSONAPI)
|
||||
endif(RS_JSON_API)
|
||||
|
||||
################################################################################
|
||||
@ -361,7 +402,7 @@ if(RS_FORUM_DEEP_INDEX)
|
||||
find_package(Xapian REQUIRED)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE ${XAPIAN_LIBRARIES})
|
||||
|
||||
add_compile_definitions(RS_DEEP_FORUMS_INDEX)
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC RS_DEEP_FORUMS_INDEX)
|
||||
endif(RS_FORUM_DEEP_INDEX)
|
||||
|
||||
################################################################################
|
||||
@ -379,12 +420,15 @@ if(RS_SQLCIPHER)
|
||||
PRIVATE "${RS_SQL_LIB_INCLUDE}/sqlcipher" )
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE ${RS_SQL_LIB})
|
||||
else()
|
||||
add_compile_definitions(NO_SQLCIPHER)
|
||||
# TODO: Refactor this define to use proper prefix and then flag as
|
||||
# public
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE NO_SQLCIPHER)
|
||||
find_package(SQLite3 REQUIRED)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE SQLite::SQLite3)
|
||||
endif()
|
||||
|
||||
add_compile_definitions(
|
||||
target_compile_definitions(
|
||||
${PROJECT_NAME} PRIVATE
|
||||
SQLITE_HAS_CODEC
|
||||
RS_ENABLE_GXS
|
||||
GXS_ENABLE_SYNC_MSGS
|
||||
@ -395,27 +439,31 @@ add_compile_definitions(
|
||||
V07_NON_BACKWARD_COMPATIBLE_CHANGE_003 )
|
||||
|
||||
if(RS_V07_BREAKING_CHANGES)
|
||||
add_compile_definitions(
|
||||
target_compile_definitions(
|
||||
${PROJECT_NAME} PRIVATE
|
||||
V07_NON_BACKWARD_COMPATIBLE_CHANGE_004
|
||||
V07_NON_BACKWARD_COMPATIBLE_CHANGE_UNNAMED )
|
||||
endif()
|
||||
|
||||
if(RS_DH_PRIME_INIT_CHECK)
|
||||
add_compile_definitions(RS_DISABLE_DIFFIE_HELLMAN_INIT_CHECK)
|
||||
target_compile_definitions(
|
||||
${PROJECT_NAME} PRIVATE RS_DISABLE_DIFFIE_HELLMAN_INIT_CHECK )
|
||||
endif(RS_DH_PRIME_INIT_CHECK)
|
||||
|
||||
if(RS_MINIUPNPC)
|
||||
add_compile_definitions(RS_USE_LIBMINIUPNPC)
|
||||
target_compile_definitions(
|
||||
${PROJECT_NAME} PUBLIC RS_USE_LIBMINIUPNPC )
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE miniupnpc)
|
||||
endif(RS_MINIUPNPC)
|
||||
|
||||
if(RS_LIBUPNP)
|
||||
message(FATAL_ERROR "UPnP support via libupnp is currently not supported")
|
||||
#add_compile_definitions(RS_USE_LIBUPNP)
|
||||
#target_compile_definitions(${PROJECT_NAME} PUBLIC RS_USE_LIBUPNP)
|
||||
endif(RS_LIBUPNP)
|
||||
|
||||
if(RS_GXS_SEND_ALL)
|
||||
add_compile_definitions(RS_GXS_SEND_ALL)
|
||||
target_compile_definitions(
|
||||
${PROJECT_NAME} PUBLIC RS_GXS_SEND_ALL )
|
||||
endif(RS_GXS_SEND_ALL)
|
||||
|
||||
if(RS_BRODCAST_DISCOVERY)
|
||||
@ -434,36 +482,43 @@ if(RS_BRODCAST_DISCOVERY)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE udp-discovery)
|
||||
|
||||
## TODO: Temporary work around target_include_directories should be added
|
||||
## upstream
|
||||
include_directories(${udp-discovery-cpp_SOURCE_DIR})
|
||||
## TODO: Temporary work around target_include_directories PUBLIC should be
|
||||
## added upstream
|
||||
target_include_directories(
|
||||
${PROJECT_NAME} PRIVATE "${udp-discovery-cpp_SOURCE_DIR}" )
|
||||
endif(RS_BRODCAST_DISCOVERY)
|
||||
|
||||
if(NOT RS_WARN_DEPRECATED)
|
||||
add_compile_definitions(RS_NO_WARN_DEPRECATED)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE RS_NO_WARN_DEPRECATED)
|
||||
target_compile_options(
|
||||
${PROJECT_NAME} PRIVATE
|
||||
-Wno-deprecated -Wno-deprecated-declarations )
|
||||
endif(NOT RS_WARN_DEPRECATED)
|
||||
|
||||
if(RS_WARN_LESS)
|
||||
add_compile_definitions(RS_NO_WARN_CPP)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE RS_NO_WARN_CPP)
|
||||
|
||||
target_compile_options(
|
||||
${PROJECT_NAME} PRIVATE
|
||||
-Wno-cpp -Wno-inconsistent-missing-override )
|
||||
endif(RS_WARN_LESS)
|
||||
|
||||
if(RS_WEBUI)
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC RS_WEBUI)
|
||||
endif(RS_WEBUI)
|
||||
|
||||
################################################################################
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
add_compile_definitions(RS_DATA_DIR="${RS_DATA_DIR}")
|
||||
target_compile_definitions(
|
||||
${PROJECT_NAME} PUBLIC RS_DATA_DIR="${RS_DATA_DIR}" )
|
||||
endif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
|
||||
################################################################################
|
||||
|
||||
if(RS_EXPORT_JNI_ONLOAD)
|
||||
add_compile_definitions(RS_LIBRETROSHARE_EXPORT_JNI_ONLOAD)
|
||||
target_compile_definitions(
|
||||
${PROJECT_NAME} PUBLIC RS_LIBRETROSHARE_EXPORT_JNI_ONLOAD )
|
||||
endif(RS_EXPORT_JNI_ONLOAD)
|
||||
|
||||
################################################################################
|
||||
@ -480,7 +535,8 @@ if(RS_ANDROID)
|
||||
)
|
||||
FetchContent_MakeAvailable(jni-hpp)
|
||||
|
||||
include_directories(${jni-hpp_SOURCE_DIR}/include)
|
||||
target_include_directories(
|
||||
${PROJECT_NAME} PRIVATE "${jni-hpp_SOURCE_DIR}/include" )
|
||||
endif(RS_ANDROID)
|
||||
#endif(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
||||
|
||||
|
||||
@ -53,12 +53,29 @@ list(
|
||||
chat/distantchat.cc
|
||||
chat/p3chatservice.cc
|
||||
chat/rschatitems.cc
|
||||
chat/distributedchat.cc
|
||||
chat/distributedchat.cc )
|
||||
|
||||
list(
|
||||
APPEND RS_IMPLEMENTATION_HEADERS
|
||||
chat/distantchat.h
|
||||
chat/distributedchat.h
|
||||
chat/p3chatservice.h
|
||||
chat/rschatitems.h )
|
||||
|
||||
list(
|
||||
APPEND RS_SOURCES
|
||||
crypto/chacha20.cpp
|
||||
crypto/hashstream.cc
|
||||
crypto/rsaes.cc
|
||||
crypto/rscrypto.cpp )
|
||||
|
||||
list(
|
||||
APPEND RS_IMPLEMENTATION_HEADERS
|
||||
crypto/chacha20.h
|
||||
crypto/hashstream.h
|
||||
crypto/rsaes.h
|
||||
crypto/rscrypto.h )
|
||||
|
||||
if(RS_BITDHT)
|
||||
list(
|
||||
APPEND RS_PUBLIC_HEADERS
|
||||
@ -72,6 +89,12 @@ if(RS_BITDHT)
|
||||
dht/p3bitdht_peernet.cc
|
||||
dht/p3bitdht_peers.cc
|
||||
dht/p3bitdht_relay.cc )
|
||||
|
||||
list(
|
||||
APPEND RS_IMPLEMENTATION_HEADERS
|
||||
dht/connectstatebox.h
|
||||
dht/p3bitdht.h
|
||||
dht/stunaddrassist.h )
|
||||
endif(RS_BITDHT)
|
||||
|
||||
list(
|
||||
@ -95,12 +118,45 @@ list(
|
||||
ft/ftextralist.cc
|
||||
ft/ftserver.cc )
|
||||
|
||||
list(
|
||||
APPEND RS_IMPLEMENTATION_HEADERS
|
||||
file_sharing/directory_list.h
|
||||
file_sharing/directory_storage.h
|
||||
file_sharing/directory_updater.h
|
||||
file_sharing/dir_hierarchy.h
|
||||
file_sharing/filelist_io.h
|
||||
file_sharing/file_sharing_defaults.h
|
||||
file_sharing/hash_cache.h
|
||||
file_sharing/p3filelists.h
|
||||
file_sharing/rsfilelistitems.h
|
||||
ft/ftchunkmap.h
|
||||
ft/ftcontroller.h
|
||||
ft/ftdata.h
|
||||
ft/ftdatamultiplex.h
|
||||
ft/ftextralist.h
|
||||
ft/ftfilecreator.h
|
||||
ft/ftfileprovider.h
|
||||
ft/ftfilesearch.h
|
||||
ft/ftsearch.h
|
||||
ft/ftserver.h
|
||||
ft/fttransfermodule.h
|
||||
ft/ftturtlefiletransferitem.h )
|
||||
|
||||
list(
|
||||
APPEND RS_SOURCES
|
||||
grouter/groutermatrix.cc
|
||||
grouter/grouteritems.cc
|
||||
grouter/p3grouter.cc )
|
||||
|
||||
list(
|
||||
APPEND RS_IMPLEMENTATION_HEADERS
|
||||
grouter/groutercache.h
|
||||
grouter/grouterclientservice.h
|
||||
grouter/grouteritems.h
|
||||
grouter/groutermatrix.h
|
||||
grouter/groutertypes.h
|
||||
grouter/p3grouter.h )
|
||||
|
||||
list(
|
||||
APPEND RS_SOURCES
|
||||
gxs/rsgxsdata.cc
|
||||
@ -116,16 +172,47 @@ list(
|
||||
gxs/rsgenexchange.cc
|
||||
gxs/rsgxsnetservice.cc )
|
||||
|
||||
list(
|
||||
APPEND RS_IMPLEMENTATION_HEADERS
|
||||
gxs/gxssecurity.h
|
||||
gxs/gxstokenqueue.h
|
||||
gxs/rsdataservice.h
|
||||
gxs/rsgds.h
|
||||
gxs/rsgenexchange.h
|
||||
gxs/rsgixs.h
|
||||
gxs/rsgroups.h
|
||||
gxs/rsgxsdataaccess.h
|
||||
gxs/rsgxsdata.h
|
||||
gxs/rsgxs.h
|
||||
gxs/rsgxsnetservice.h
|
||||
gxs/rsgxsnettunnel.h
|
||||
gxs/rsgxsnetutils.h
|
||||
gxs/rsgxsnotify.h
|
||||
gxs/rsgxsrequesttypes.h
|
||||
gxs/rsgxsutil.h
|
||||
gxs/rsnxs.h
|
||||
gxs/rsnxsobserver.h )
|
||||
|
||||
list(
|
||||
APPEND RS_SOURCES
|
||||
gxstrans/p3gxstransitems.cc
|
||||
gxstrans/p3gxstrans.cc )
|
||||
|
||||
list(
|
||||
APPEND RS_IMPLEMENTATION_HEADERS
|
||||
gxstrans/p3gxstrans.h
|
||||
gxstrans/p3gxstransitems.h )
|
||||
|
||||
list(
|
||||
APPEND RS_SOURCES
|
||||
gxstunnel/rsgxstunnelitems.cc
|
||||
gxstunnel/p3gxstunnel.cc )
|
||||
|
||||
list(
|
||||
APPEND RS_IMPLEMENTATION_HEADERS
|
||||
gxstunnel/p3gxstunnel.h
|
||||
gxstunnel/rsgxstunnelitems.h )
|
||||
|
||||
if(RS_JSON_API)
|
||||
list(
|
||||
APPEND RS_PUBLIC_HEADERS
|
||||
@ -134,6 +221,11 @@ if(RS_JSON_API)
|
||||
list(
|
||||
APPEND RS_SOURCES
|
||||
jsonapi/jsonapi.cpp )
|
||||
|
||||
list(
|
||||
APPEND RS_IMPLEMENTATION_HEADERS
|
||||
jsonapi/jsonapi.h
|
||||
jsonapi/jsonapiitems.h )
|
||||
endif(RS_JSON_API)
|
||||
|
||||
list(
|
||||
@ -144,6 +236,14 @@ list(
|
||||
pgp/pgpkeyutil.cc
|
||||
pgp/rscertificate.cc )
|
||||
|
||||
list(
|
||||
APPEND RS_IMPLEMENTATION_HEADERS
|
||||
pgp/openpgpsdkhandler.h
|
||||
pgp/pgpauxutils.h
|
||||
pgp/pgphandler.h
|
||||
pgp/pgpkeyutil.h
|
||||
pgp/rscertificate.h )
|
||||
|
||||
#./plugins/dlfcn_win32.cc
|
||||
#./plugins/dlfcn_win32.h
|
||||
#./plugins/pluginmanager.h
|
||||
@ -154,6 +254,10 @@ list(
|
||||
APPEND RS_SOURCES
|
||||
plugins/pluginmanager.cc )
|
||||
|
||||
list(
|
||||
APPEND RS_IMPLEMENTATION_HEADERS
|
||||
plugins/pluginmanager.h )
|
||||
|
||||
list(
|
||||
APPEND RS_SOURCES
|
||||
pqi/pqibin.cc
|
||||
@ -188,6 +292,48 @@ list(
|
||||
pqi/pqissl.cc
|
||||
pqi/pqisslpersongrp.cc )
|
||||
|
||||
list(
|
||||
APPEND RS_IMPLEMENTATION_HEADERS
|
||||
pqi/authgpg.h
|
||||
pqi/authssl.h
|
||||
pqi/p3cfgmgr.h
|
||||
pqi/p3historymgr.h
|
||||
pqi/p3linkmgr.h
|
||||
pqi/p3netmgr.h
|
||||
pqi/p3notify.h
|
||||
pqi/p3peermgr.h
|
||||
pqi/p3servicecontrol.h
|
||||
pqi/p3upnpmgr.h
|
||||
pqi/pqiassist.h
|
||||
pqi/pqi_base.h
|
||||
pqi/pqibin.h
|
||||
pqi/pqifdbin.h
|
||||
pqi/pqi.h
|
||||
pqi/pqihandler.h
|
||||
pqi/pqihash.h
|
||||
pqi/pqiindic.h
|
||||
pqi/pqiipset.h
|
||||
pqi/pqilistener.h
|
||||
pqi/pqiloopback.h
|
||||
pqi/pqimonitor.h
|
||||
pqi/pqinetstatebox.h
|
||||
pqi/pqinetwork.h
|
||||
pqi/pqipersongrp.h
|
||||
pqi/pqiperson.h
|
||||
pqi/pqiqos.h
|
||||
pqi/pqiqosstreamer.h
|
||||
pqi/pqiservice.h
|
||||
pqi/pqiservicemonitor.h
|
||||
pqi/pqissl.h
|
||||
pqi/pqissllistener.h
|
||||
pqi/pqisslpersongrp.h
|
||||
pqi/pqisslproxy.h
|
||||
pqi/pqissludp.h
|
||||
pqi/pqistore.h
|
||||
pqi/pqistreamer.h
|
||||
pqi/pqithreadstreamer.h
|
||||
pqi/sslfns.h )
|
||||
|
||||
#./pqi/pqissli2psam3.cpp
|
||||
#./pqi/pqissli2psam3.h
|
||||
|
||||
@ -229,6 +375,34 @@ list(
|
||||
APPEND RS_SOURCES
|
||||
rsitems/rsnxsitems.cc )
|
||||
|
||||
list(
|
||||
APPEND RS_IMPLEMENTATION_HEADERS
|
||||
rsitems/itempriorities.h
|
||||
rsitems/rsbanlistitems.h
|
||||
rsitems/rsbwctrlitems.h
|
||||
rsitems/rsconfigitems.h
|
||||
rsitems/rsfiletransferitems.h
|
||||
rsitems/rsgxschannelitems.h
|
||||
rsitems/rsgxscircleitems.h
|
||||
rsitems/rsgxscommentitems.h
|
||||
rsitems/rsgxsforumitems.h
|
||||
rsitems/rsgxsiditems.h
|
||||
rsitems/rsgxsitems.h
|
||||
rsitems/rsgxsrecognitems.h
|
||||
rsitems/rsgxsreputationitems.h
|
||||
rsitems/rsgxsupdateitems.h
|
||||
rsitems/rsheartbeatitems.h
|
||||
rsitems/rshistoryitems.h
|
||||
rsitems/rsitem.h
|
||||
rsitems/rsmsgitems.h
|
||||
rsitems/rsnxsitems.h
|
||||
rsitems/rspluginitems.h
|
||||
rsitems/rsposteditems.h
|
||||
rsitems/rsrttitems.h
|
||||
rsitems/rsserviceids.h
|
||||
rsitems/rsserviceinfoitems.h
|
||||
rsitems/rsstatusitems.h )
|
||||
|
||||
list(
|
||||
APPEND RS_SOURCES
|
||||
rsserver/p3status.cc
|
||||
@ -243,6 +417,17 @@ list(
|
||||
rsserver/rsaccounts.cc
|
||||
rsserver/rsinit.cc )
|
||||
|
||||
list(
|
||||
APPEND RS_IMPLEMENTATION_HEADERS
|
||||
rsserver/p3face.h
|
||||
rsserver/p3history.h
|
||||
rsserver/p3msgs.h
|
||||
rsserver/p3peers.h
|
||||
rsserver/p3serverconfig.h
|
||||
rsserver/p3status.h
|
||||
rsserver/rsaccounts.h
|
||||
rsserver/rsloginhandler.h )
|
||||
|
||||
list(
|
||||
APPEND RS_SOURCES
|
||||
serialiser/rsbaseserial.cc
|
||||
@ -264,6 +449,30 @@ list(
|
||||
serialiser/rstypeserializer.cc
|
||||
serialiser/rsserial.cc )
|
||||
|
||||
list(
|
||||
APPEND RS_IMPLEMENTATION_HEADERS
|
||||
serialiser/rsbaseserial.h
|
||||
serialiser/rsserial.h
|
||||
serialiser/rsserializable.h
|
||||
serialiser/rsserializer.h
|
||||
serialiser/rstlvaddrs.h
|
||||
serialiser/rstlvbanlist.h
|
||||
serialiser/rstlvbase.h
|
||||
serialiser/rstlvbinary.h
|
||||
serialiser/rstlvfileitem.h
|
||||
serialiser/rstlvgenericmap.h
|
||||
serialiser/rstlvgenericmap.inl
|
||||
serialiser/rstlvgenericparam.h
|
||||
serialiser/rstlvidset.h
|
||||
serialiser/rstlvimage.h
|
||||
serialiser/rstlvitem.h
|
||||
serialiser/rstlvkeys.h
|
||||
serialiser/rstlvkeyvalue.h
|
||||
serialiser/rstlvlist.h
|
||||
serialiser/rstlvmaps.h
|
||||
serialiser/rstlvstring.h
|
||||
serialiser/rstypeserializer.h )
|
||||
|
||||
# ./services/autoproxy
|
||||
#./services/autoproxy/p3i2psam3.cpp
|
||||
#./services/autoproxy/p3i2psam3.h
|
||||
@ -287,6 +496,26 @@ list(
|
||||
services/p3gxschannels.cc
|
||||
services/p3gxsforums.cc )
|
||||
|
||||
list(
|
||||
APPEND RS_IMPLEMENTATION_HEADERS
|
||||
services/p3banlist.h
|
||||
services/p3bwctrl.h
|
||||
services/p3gxschannels.h
|
||||
services/p3gxscircles.h
|
||||
services/p3gxscommon.h
|
||||
services/p3gxsforums.h
|
||||
services/p3gxsreputation.h
|
||||
services/p3heartbeat.h
|
||||
services/p3idservice.h
|
||||
services/p3msgservice.h
|
||||
services/p3postbase.h
|
||||
services/p3posted.h
|
||||
services/p3rtt.h
|
||||
services/p3service.h
|
||||
services/p3serviceinfo.h
|
||||
services/p3statusservice.h
|
||||
services/rseventsservice.h )
|
||||
|
||||
#./services/p3wiki.cc
|
||||
#./services/p3wiki.h
|
||||
#./services/p3wire.cc
|
||||
@ -309,6 +538,10 @@ if(RS_BRODCAST_DISCOVERY)
|
||||
list(
|
||||
APPEND RS_SOURCES
|
||||
services/broadcastdiscoveryservice.cc )
|
||||
|
||||
list(
|
||||
APPEND RS_IMPLEMENTATION_HEADERS
|
||||
services/broadcastdiscoveryservice.h )
|
||||
endif(RS_BRODCAST_DISCOVERY)
|
||||
|
||||
list(
|
||||
@ -320,10 +553,24 @@ list(
|
||||
tcponudp/bss_tou.cc
|
||||
tcponudp/udprelay.cc )
|
||||
|
||||
list(
|
||||
APPEND RS_IMPLEMENTATION_HEADERS
|
||||
tcponudp/bio_tou.h
|
||||
tcponudp/rsudpstack.h
|
||||
tcponudp/tcppacket.h
|
||||
tcponudp/tcpstream.h
|
||||
tcponudp/tou.h
|
||||
tcponudp/udppeer.h
|
||||
tcponudp/udprelay.h )
|
||||
|
||||
if(RS_BITDHT_STUNNER)
|
||||
list(
|
||||
APPEND RS_SOURCES
|
||||
tcponudp/udpstunner.cc )
|
||||
|
||||
list(
|
||||
APPEND RS_IMPLEMENTATION_HEADERS
|
||||
tcponudp/udpstunner.h )
|
||||
endif(RS_BITDHT_STUNNER)
|
||||
|
||||
list(
|
||||
@ -331,6 +578,14 @@ list(
|
||||
turtle/rsturtleitem.cc
|
||||
turtle/p3turtle.cc )
|
||||
|
||||
list(
|
||||
APPEND RS_IMPLEMENTATION_HEADERS
|
||||
turtle/p3turtle.h
|
||||
turtle/rsturtleitem.h
|
||||
turtle/turtleclientservice.h
|
||||
turtle/turtlestatistics.h
|
||||
turtle/turtletypes.h )
|
||||
|
||||
list(
|
||||
APPEND RS_SOURCES
|
||||
util/contentvalue.cc
|
||||
@ -360,14 +615,67 @@ list(
|
||||
util/rsnet_ss.cc
|
||||
util/rsthreads.cc )
|
||||
|
||||
# util/i2pcommon.cpp
|
||||
# util/i2pcommon.cpp
|
||||
# util/i2pcommon.h
|
||||
|
||||
list(
|
||||
APPEND RS_IMPLEMENTATION_HEADERS
|
||||
util/argstream.h
|
||||
util/contentvalue.h
|
||||
util/cxx11retrocompat.h
|
||||
util/cxx14retrocompat.h
|
||||
util/cxx17retrocompat.h
|
||||
util/cxx23retrocompat.h
|
||||
util/dnsresolver.h
|
||||
util/extaddrfinder.h
|
||||
util/folderiterator.h
|
||||
util/radix32.h
|
||||
util/radix64.h
|
||||
util/retrodb.h
|
||||
util/rsbase64.h
|
||||
util/rsdbbind.h
|
||||
util/rsdebug.h
|
||||
util/rsdebuglevel0.h
|
||||
util/rsdebuglevel1.h
|
||||
util/rsdebuglevel2.h
|
||||
util/rsdebuglevel3.h
|
||||
util/rsdebuglevel4.h
|
||||
util/rsdeprecate.h
|
||||
util/rsdir.h
|
||||
util/rsdiscspace.h
|
||||
util/rsendian.h
|
||||
util/rsfile.h
|
||||
util/rsinitedptr.h
|
||||
util/rsjson.h
|
||||
util/rskbdinput.cc
|
||||
util/rskbdinput.h
|
||||
util/rsmemcache.h
|
||||
util/rsmemory.h
|
||||
util/rsnet.h
|
||||
util/rsprint.h
|
||||
util/rsrandom.h
|
||||
util/rsrecogn.h
|
||||
util/rsstd.h
|
||||
util/rsstring.h
|
||||
util/rsthreads.cc
|
||||
util/rsthreads.h
|
||||
util/rstickevent.h
|
||||
util/rstime.h
|
||||
util/rsurl.h
|
||||
util/rswin.h
|
||||
util/smallobject.h
|
||||
util/stacktrace.h )
|
||||
|
||||
if(RS_FORUM_DEEP_INDEX)
|
||||
list(
|
||||
APPEND RS_SOURCES
|
||||
deep_search/commonutils.cpp
|
||||
deep_search/forumsindex.cpp )
|
||||
|
||||
list(
|
||||
APPEND RS_IMPLEMENTATION_HEADERS
|
||||
deep_search/commonutils.hpp
|
||||
deep_search/forumsindex.hpp )
|
||||
endif(RS_FORUM_DEEP_INDEX)
|
||||
|
||||
|
||||
@ -384,11 +692,21 @@ list(
|
||||
gossipdiscovery/gossipdiscoveryitems.cc
|
||||
gossipdiscovery/p3gossipdiscovery.cc )
|
||||
|
||||
if(RS_MINIUPNPC)
|
||||
list(
|
||||
APPEND RS_SOURCES
|
||||
rs_upnp/upnphandler_miniupnp.cc
|
||||
rs_upnp/upnputil.cc )
|
||||
APPEND RS_IMPLEMENTATION_HEADERS
|
||||
gossipdiscovery/gossipdiscoveryitems.h
|
||||
gossipdiscovery/p3gossipdiscovery.h )
|
||||
|
||||
if(RS_MINIUPNPC)
|
||||
list(
|
||||
APPEND RS_SOURCES
|
||||
rs_upnp/upnphandler_miniupnp.cc
|
||||
rs_upnp/upnputil.cc )
|
||||
|
||||
list(
|
||||
APPEND RS_IMPLEMENTATION_HEADERS
|
||||
rs_upnp/upnphandler_miniupnp.h
|
||||
rs_upnp/upnputil.h )
|
||||
endif(RS_MINIUPNPC)
|
||||
|
||||
#./rs_upnp/UPnPBase.cpp
|
||||
@ -402,10 +720,22 @@ if(RS_ANDROID)
|
||||
rs_android/errorconditionwrap.cpp
|
||||
rs_android/retroshareserviceandroid.cpp
|
||||
rs_android/rsjni.cpp )
|
||||
|
||||
list(
|
||||
APPEND RS_IMPLEMENTATION_HEADERS
|
||||
rs_android/androidcoutcerrcatcher.hpp
|
||||
rs_android/ifaddrs-android.h
|
||||
rs_android/largefile_retrocompat.hpp
|
||||
rs_android/LocalArray.h
|
||||
rs_android/retroshareserviceandroid.hpp
|
||||
rs_android/rsjni.hpp
|
||||
rs_android/ScopedFd.h )
|
||||
endif()
|
||||
|
||||
list(
|
||||
APPEND RS_SOURCES
|
||||
pqi/rstcpsocket.cc
|
||||
pqi/pqiproxy.cc
|
||||
tor/AddOnionCommand.cpp
|
||||
tor/AuthenticateCommand.cpp
|
||||
tor/CryptoKey.cpp
|
||||
@ -419,6 +749,40 @@ list(
|
||||
tor/TorControlCommand.cpp
|
||||
tor/TorControlSocket.cpp
|
||||
tor/TorProcess.cpp
|
||||
tor/TorManager.cpp
|
||||
pqi/rstcpsocket.cc
|
||||
pqi/pqiproxy.cc )
|
||||
tor/TorManager.cpp )
|
||||
|
||||
list(
|
||||
APPEND RS_IMPLEMENTATION_HEADERS
|
||||
pqi/pqiproxy.h
|
||||
pqi/rstcpsocket.h
|
||||
tor/AddOnionCommand.h
|
||||
tor/AuthenticateCommand.h
|
||||
tor/bytearray.h
|
||||
tor/CryptoKey.h
|
||||
tor/GetConfCommand.h
|
||||
tor/HiddenService.h
|
||||
tor/PendingOperation.h
|
||||
tor/ProtocolInfoCommand.h
|
||||
tor/SetConfCommand.h
|
||||
tor/StrUtil.h
|
||||
tor/TorControlCommand.h
|
||||
tor/TorControl.h
|
||||
tor/TorControlSocket.h
|
||||
tor/TorManager.h
|
||||
tor/TorProcess.h
|
||||
tor/TorTypes.h
|
||||
tor/Useful.h )
|
||||
|
||||
if(RS_WEBUI)
|
||||
list(
|
||||
APPEND RS_PUBLIC_HEADERS
|
||||
retroshare/rswebui.h )
|
||||
|
||||
list(
|
||||
APPEND RS_SOURCES
|
||||
jsonapi/p3webui.cc )
|
||||
|
||||
list(
|
||||
APPEND RS_IMPLEMENTATION_HEADERS
|
||||
jsonapi/p3webui.h )
|
||||
endif(RS_WEBUI)
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
* RetroShare Web User Interface
|
||||
*
|
||||
* Copyright (C) 2019 Cyril Soler <csoler@users.sourceforge.net>
|
||||
* Copyright (C) 2022 Gioacchino Mazzurco <gio@eigenlab.org>
|
||||
* Copyright (C) 2022 Asociación Civil Altermundi <info@altermundi.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License as published by the
|
||||
@ -33,8 +35,7 @@
|
||||
#include "retroshare/rswebui.h"
|
||||
#include "rsserver/rsaccounts.h"
|
||||
#include "retroshare/rsjsonapi.h"
|
||||
|
||||
#define DEBUG_RS_WEBUI 1
|
||||
#include "util/rsdir.h"
|
||||
|
||||
/*extern*/ RsWebUi* rsWebUi = new p3WebUI;
|
||||
|
||||
@ -110,6 +111,9 @@ std::vector< std::shared_ptr<restbed::Resource> > p3WebUI::getResources() const
|
||||
|
||||
if(rtab.empty())
|
||||
{
|
||||
/* TODO: better not hardcode file names here so the C++ code can remain
|
||||
* the same and WebUI modified indipendently */
|
||||
|
||||
auto resource1 = std::make_shared< restbed::Resource >();
|
||||
resource1->set_paths( {
|
||||
"/{filename: index.html}",
|
||||
@ -160,37 +164,51 @@ std::vector< std::shared_ptr<restbed::Resource> > p3WebUI::getResources() const
|
||||
rtab.push_back(resource6);
|
||||
}
|
||||
|
||||
return rtab;
|
||||
return rtab;
|
||||
}
|
||||
|
||||
|
||||
void p3WebUI::setHtmlFilesDirectory(const std::string& html_dir)
|
||||
std::error_condition p3WebUI::setHtmlFilesDirectory(const std::string& html_dir)
|
||||
{
|
||||
_base_directory = html_dir;
|
||||
RS_DBG("html_dir: ", html_dir);
|
||||
|
||||
if(!RsDirUtil::checkDirectory(html_dir))
|
||||
{
|
||||
RS_ERR(html_dir, " is not a directory");
|
||||
return std::errc::not_a_directory;
|
||||
}
|
||||
|
||||
if(!RsDirUtil::fileExists(html_dir+"/index.html"))
|
||||
{
|
||||
RS_ERR(html_dir, " doesn't seems a valid webui dir lacks index.html");
|
||||
return std::errc::no_such_file_or_directory;
|
||||
}
|
||||
|
||||
_base_directory = html_dir;
|
||||
return std::error_condition();
|
||||
}
|
||||
|
||||
bool p3WebUI::isRunning() const
|
||||
{ return rsJsonApi->isRunning() && rsJsonApi->hasResourceProvider(*this); }
|
||||
|
||||
void p3WebUI::setUserPassword(const std::string& passwd)
|
||||
std::error_condition p3WebUI::setUserPassword(const std::string& passwd)
|
||||
{
|
||||
RsDbg() << __PRETTY_FUNCTION__ << " Updating webui token with new passwd \""
|
||||
<< passwd << "\"" << std::endl;
|
||||
RS_DBG("Updating webui token with new password");
|
||||
|
||||
if(rsJsonApi->authorizeUser("webui",passwd)) // (bool)std::error_condition is true when there is an error.
|
||||
std::cerr << "(EE) Cannot register webui token. Some error occurred when calling authorizeUser()" << std::endl;
|
||||
auto err = rsJsonApi->authorizeUser("webui", passwd);
|
||||
if(err)
|
||||
RS_ERR("Cannot register webui token, authorizeUser(...) return ", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
bool p3WebUI::restart()
|
||||
std::error_condition p3WebUI::restart()
|
||||
{
|
||||
rsJsonApi->registerResourceProvider(*this);
|
||||
rsJsonApi->restart();
|
||||
return true;
|
||||
return rsJsonApi->restart();
|
||||
}
|
||||
|
||||
bool p3WebUI::stop()
|
||||
std::error_condition p3WebUI::stop()
|
||||
{
|
||||
rsJsonApi->unregisterResourceProvider(*this);
|
||||
rsJsonApi->restart();
|
||||
return true;
|
||||
return rsJsonApi->restart();
|
||||
}
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
* RetroShare Web User Interface
|
||||
*
|
||||
* Copyright (C) 2019 Cyril Soler <csoler@users.sourceforge.net>
|
||||
* Copyright (C) 2022 Gioacchino Mazzurco <gio@eigenlab.org>
|
||||
* Copyright (C) 2022 Asociación Civil Altermundi <info@altermundi.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License as published by the
|
||||
@ -33,15 +35,18 @@ class p3WebUI: public RsWebUi, public JsonApiResourceProvider
|
||||
public:
|
||||
~p3WebUI() override = default;
|
||||
|
||||
// implements RsWebUI
|
||||
/// implements RsWebUI
|
||||
virtual std::error_condition setHtmlFilesDirectory(
|
||||
const std::string& html_dir ) override;
|
||||
virtual std::error_condition setUserPassword(
|
||||
const std::string& passwd ) override;
|
||||
|
||||
virtual void setHtmlFilesDirectory(const std::string& html_dir) override;
|
||||
virtual void setUserPassword(const std::string& passwd) override;
|
||||
virtual std::error_condition restart() override;
|
||||
virtual std::error_condition stop() override;
|
||||
|
||||
virtual bool restart() override ;
|
||||
virtual bool stop() override ;
|
||||
bool isRunning() const override;
|
||||
// implements JsonApiResourceProvider
|
||||
|
||||
virtual std::vector<std::shared_ptr<restbed::Resource> > getResources() const override;
|
||||
/// implements JsonApiResourceProvider
|
||||
virtual std::vector<std::shared_ptr<restbed::Resource> > getResources()
|
||||
const override;
|
||||
};
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
* RetroShare Web User Interface public header
|
||||
*
|
||||
* Copyright (C) 2019 Cyril Soler <csoler@users.sourceforge.net>
|
||||
* Copyright (C) 2022 Gioacchino Mazzurco <gio@eigenlab.org>
|
||||
* Copyright (C) 2022 Asociación Civil Altermundi <info@altermundi.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Lesser General Public License as published by the Free
|
||||
@ -23,6 +25,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
|
||||
class RsWebUi;
|
||||
|
||||
@ -42,27 +45,30 @@ public:
|
||||
* @brief Restart WebUI
|
||||
* @jsonapi{development}
|
||||
*/
|
||||
virtual bool restart() = 0;
|
||||
virtual std::error_condition restart() = 0;
|
||||
|
||||
/**
|
||||
* @brief Stop WebUI
|
||||
* @jsonapi{development}
|
||||
*/
|
||||
virtual bool stop() = 0;
|
||||
virtual std::error_condition stop() = 0;
|
||||
|
||||
/**
|
||||
* @brief Set WebUI static files directory, need restart to apply
|
||||
* @param[in] htmlDir directory path
|
||||
* @jsonapi{development}
|
||||
*/
|
||||
virtual void setHtmlFilesDirectory(const std::string& htmlDir) = 0;
|
||||
virtual std::error_condition setHtmlFilesDirectory(
|
||||
const std::string& htmlDir ) = 0;
|
||||
|
||||
/**
|
||||
* @brief Set WebUI user password
|
||||
* @param[in] password new password for WebUI
|
||||
* @return if some error occurred return details about it
|
||||
* @jsonapi{development}
|
||||
*/
|
||||
virtual void setUserPassword(const std::string& password) =0;
|
||||
virtual std::error_condition setUserPassword(
|
||||
const std::string& password ) = 0;
|
||||
|
||||
/**
|
||||
* @brief check if WebUI is running
|
||||
|
||||
Loading…
Reference in New Issue
Block a user