Commit 0c895d19 authored by Ronan's avatar Ronan

feat(CMakeLists.txt): find jose and jansson

parent 464d20ba
......@@ -55,8 +55,8 @@ option(ENABLE_MDNS "Build multicast DNS support" NO)
cmake_dependent_option(ENABLE_SPECIFIC_FEATURES "Enable mediarelay specific features" OFF "ENABLE_TRANSCODER" OFF)
if(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}")
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR})
message(STATUS "Setting install rpath to ${CMAKE_INSTALL_RPATH}")
endif()
if(APPLE)
......@@ -249,11 +249,12 @@ find_package(OpenSSL 0.9.8 REQUIRED)
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
include_directories(
src/
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/src/
${SOFIASIPUA_INCLUDE_DIRS}
${ORTP_INCLUDE_DIRS}
${SOFIASIPUA_INCLUDE_DIRS}
src/
src/plugin
)
configure_file(${PROJECT_SOURCE_DIR}/cmake/flexisip-config.h.in ${PROJECT_BINARY_DIR}/flexisip-config.h)
......
############################################################################
# FindJansson.cmake
# Copyright (C) 2018 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 Jansson include files and library
#
# JANSSON_FOUND - System has jansson
# JANSSON_INCLUDE_DIRS - The jansson include directories
# JANSSON_LIBRARIES - The libraries needed to use jansson
find_package(PkgConfig QUIET)
pkg_check_modules(PC_JANSSON QUIET jansson)
find_path(JANSSON_INCLUDE_DIR
NAMES jansson.h
HINTS ${PC_JANSSON_INCLUDE_DIRS}
)
find_library(JANSSON_LIBRARY
NAMES jansson
HINTS ${PC_JANSSON_LIBRARY_DIRS}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Jansson REQUIRED_VARS JANSSON_INCLUDE_DIR JANSSON_LIBRARY)
if(JANSSON_FOUND)
set(JANSSON_LIBRARIES ${JANSSON_LIBRARY})
set(JANSSON_INCLUDE_DIRS ${JANSSON_INCLUDE_DIR})
endif()
mark_as_advanced(JANSSON_INCLUDE_DIR JANSSON_LIBRARY)
############################################################################
# FindJose.cmake
# Copyright (C) 2018 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 Jose include files and library
#
# JOSE_FOUND - System has jose
# JOSE_INCLUDE_DIRS - The jose include directories
# JOSE_LIBRARIES - The libraries needed to use jose
find_package(PkgConfig QUIET)
pkg_check_modules(PC_JOSE QUIET jose)
find_path(JOSE_INCLUDE_DIR
NAMES jose.h
HINTS ${PC_JOSE_INCLUDE_DIRS}
)
find_library(JOSE_LIBRARY
NAMES jose
HINTS ${PC_JOSE_LIBRARY_DIRS}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Jose REQUIRED_VARS JOSE_INCLUDE_DIR JOSE_LIBRARY)
if(JOSE_FOUND)
set(JOSE_LIBRARIES ${JOSE_LIBRARY})
set(JOSE_INCLUDE_DIRS ${JOSE_INCLUDE_DIR})
endif()
mark_as_advanced(JOSE_INCLUDE_DIR JOSE_LIBRARY)
......@@ -258,6 +258,9 @@ install(TARGETS flexisip flexisip_server
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
# Build plugins.
add_subdirectory(plugin/jwe-auth-plugin)
# expression parser tester
if(MEDIASTREAMER2_FOUND)
add_executable(expr test/expr.cc expressionparser.cc expressionparser.hh sipattrextractor.hh utils/flexisip-exception.hh)
......
/*
Flexisip, a flexible SIP proxy server with media capabilities.
Copyright (C) 2010-2018 Belledonne Communications SARL.
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 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef global_hh
#define global_hh
// =============================================================================
#define FLEXISIP_DISABLE_COPY(CLASS) \
CLASS(const CLASS &) = delete; \
CLASS &operator=(const CLASS &) = delete
#endif // ifndef global_hh
......@@ -36,7 +36,7 @@ using namespace std;
class PushNotification;
class PushNotificationContext : public enable_shared_from_this<PushNotificationContext> {
private:
private:
su_timer_t *mTimer; // timer after which push is sent
su_timer_t *mEndTimer; // timer after which push is cleared from global map.
PushNotification *mModule;
......@@ -52,9 +52,11 @@ class PushNotificationContext : public enable_shared_from_this<PushNotificationC
static void __timer_callback(su_root_magic_t *magic, su_timer_t *t, su_timer_arg_t *arg);
static void __end_timer_callback(su_root_magic_t *magic, su_timer_t *t, su_timer_arg_t *arg);
public:
PushNotificationContext(const shared_ptr<OutgoingTransaction> &transaction, PushNotification *module,
const shared_ptr<PushNotificationRequest> &pnr, const string &pn_key);
public:
PushNotificationContext(
const shared_ptr<OutgoingTransaction> &transaction, PushNotification *module,
const shared_ptr<PushNotificationRequest> &pnr, const string &pnKey
);
~PushNotificationContext();
void start(int seconds, bool sendRinging);
void cancel();
......@@ -64,7 +66,7 @@ class PushNotificationContext : public enable_shared_from_this<PushNotificationC
};
class PushNotification : public Module, public ModuleToolbox {
public:
public:
PushNotification(Agent *ag);
virtual ~PushNotification();
void onDeclare(GenericStruct *module_config);
......@@ -76,7 +78,7 @@ class PushNotification : public Module, public ModuleToolbox {
}
void clearNotification(const shared_ptr<PushNotificationContext> &ctx);
private:
private:
bool needsPush(const sip_t *sip);
void makePushNotification(const shared_ptr<MsgSip> &ms, const shared_ptr<OutgoingTransaction> &transaction);
map<string, shared_ptr<PushNotificationContext>> mPendingNotifications; // map of pending push notifications. Its
......@@ -213,7 +215,7 @@ void PushNotification::onDeclare(GenericStruct *module_config) {
" The files should be .pem format, and made of certificate followed by private key. "
"This is also the path to the directory where to find Voice Over IP certificates (certicates to use PushKit)."
"They should bear the appid of the application, suffixed by the release mode and .pem extension, and made of certificate followed by private key. "
"For example: org.linphone.voip.dev.pem org.linphone.voip.prod.pem com.somephone.voip.dev.pem etc...",
"For example: org.linphone.voip.dev.pem org.linphone.voip.prod.pem com.somephone.voip.dev.pem etc...",
"/etc/flexisip/apn"},
{Boolean, "google", "Enable push notification for android devices (for compatibility only)", "true"},
{StringList, "google-projects-api-keys",
......@@ -322,7 +324,6 @@ void PushNotification::makePushNotification(const shared_ptr<MsgSip> &ms,
char type[12];
char deviceToken[256];
char appId[256] = {0};
char pn_key[512] = {0};
char tmp[16]= {0};
char const *params = sip->sip_request->rq_url->url_params;
......@@ -340,8 +341,8 @@ void PushNotification::makePushNotification(const shared_ptr<MsgSip> &ms,
pinfo.mAppId = appId;
// check if another push notification for this device wouldn't be pending
snprintf(pn_key, sizeof(pn_key) - 1, "%s:%s:%s", pinfo.mCallId.c_str(), deviceToken, appId);
auto it = mPendingNotifications.find(pn_key);
string pnKey(pinfo.mCallId + ":" + deviceToken + ":" + appId);
auto it = mPendingNotifications.find(pnKey);
if (it != mPendingNotifications.end()) {
LOGD("Another push notification is pending for this call %s and this device %s, not creating a new one",
pinfo.mCallId.c_str(), deviceToken);
......@@ -455,9 +456,9 @@ void PushNotification::makePushNotification(const shared_ptr<MsgSip> &ms,
if (pn) {
SLOGD << "Creating a push notif context PNR " << pn.get() << " to send in " << time_out << "s";
context = make_shared<PushNotificationContext>(transaction, this, pn, pn_key);
context = make_shared<PushNotificationContext>(transaction, this, pn, pnKey);
context->start(time_out, !pinfo.mSilent);
mPendingNotifications.insert(make_pair(pn_key, context));
mPendingNotifications.insert(make_pair(pnKey, context));
}
}
if (context) /*associate with transaction so that transaction can eventually cancel it if the device answers.*/
......
############################################################################
# CMakeLists.txt
# Copyright (C) 2014-2018 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.
#
############################################################################
project(jwe-auth-plugin VERSION 1.0.0)
set(JWE_AUTH_SOURCES
jwe-auth-plugin.cc
)
find_package(Jansson REQUIRED)
find_package(Jose REQUIRED)
set(JWE_AUTH_LIBRARIES
${FLEXISIP_LIBS}
${JANSSON_LIBRARIES}
${JOSE_LIBRARIES}
)
set(JWE_AUTH_INCLUDES
${FLEXISIP_INCLUDES}
${JANSSON_INCLUDE_DIR}
${JOSE_INCLUDE_DIR}
)
add_library(jweauth SHARED ${JWE_AUTH_SOURCES})
set_target_properties(jweauth PROPERTIES VERSION ${PROJECT_VERSION})
target_link_libraries(jweauth ${JWE_AUTH_LIBRARIES})
target_include_directories(jweauth PUBLIC ${JWE_AUTH_INCLUDES})
install(TARGETS jweauth
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment