From 48487d518fb21666e7c813162a96eba25d86cdfc Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Thu, 21 Sep 2017 14:12:08 +0200 Subject: [PATCH] feat(c-wrapper): avoid usage of extern init... --- coreapi/callbacks.c | 2 +- coreapi/chat.c | 2 +- coreapi/chat_file_transfer.c | 2 +- coreapi/linphonecall.c | 2 +- coreapi/linphonecore.c | 4 +-- coreapi/proxy.c | 2 +- coreapi/quality_reporting.c | 2 +- src/CMakeLists.txt | 3 +- src/address/address.cpp | 2 +- src/c-wrapper/api/c-address.cpp | 4 +-- src/c-wrapper/api/c-call-params.cpp | 8 +---- src/c-wrapper/api/c-chat-message-cbs.cpp | 5 ++-- src/c-wrapper/api/c-chat-message.cpp | 20 +++++-------- src/c-wrapper/api/c-chat-room-cbs.cpp | 3 +- src/c-wrapper/api/c-chat-room.cpp | 14 +++------ src/c-wrapper/api/c-event-log.cpp | 8 +---- src/c-wrapper/api/c-participant.cpp | 2 +- src/c-wrapper/c-wrapper.h | 38 ++++++++++++++++++++++++ src/c-wrapper/{ => internal}/c-tools.h | 2 +- src/chat/chat-room.cpp | 5 ++-- src/chat/client-group-chat-room.cpp | 5 +--- src/chat/real-time-text-chat-room.cpp | 3 +- src/conference/session/call-session.cpp | 2 +- src/conference/session/media-session.cpp | 2 +- 24 files changed, 75 insertions(+), 67 deletions(-) create mode 100644 src/c-wrapper/c-wrapper.h rename src/c-wrapper/{ => internal}/c-tools.h (99%) diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index 4efc734c7..e7d79f0cf 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -33,7 +33,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include #endif -#include "c-wrapper/c-tools.h" +#include "c-wrapper/c-wrapper.h" #include "call/call-p.h" #include "conference/session/call-session.h" #include "conference/session/call-session-p.h" diff --git a/coreapi/chat.c b/coreapi/chat.c index bb2036b65..08c0af543 100644 --- a/coreapi/chat.c +++ b/coreapi/chat.c @@ -35,7 +35,7 @@ #include "ortp/b64.h" #include "linphone/wrapper_utils.h" -#include "c-wrapper/c-tools.h" +#include "c-wrapper/c-wrapper.h" #include "chat/basic-chat-room.h" #include "chat/client-group-chat-room.h" #include "chat/real-time-text-chat-room.h" diff --git a/coreapi/chat_file_transfer.c b/coreapi/chat_file_transfer.c index f8da29ad0..8f8e86a01 100644 --- a/coreapi/chat_file_transfer.c +++ b/coreapi/chat_file_transfer.c @@ -25,7 +25,7 @@ #include "linphone/core.h" #include "private.h" -#include "c-wrapper/c-tools.h" +#include "c-wrapper/c-wrapper.h" #include "chat/chat-room.h" LinphoneChatMessage *linphone_chat_room_create_file_transfer_message(LinphoneChatRoom *cr, const LinphoneContent *initial_content) { diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 9f7dbbc25..dded5e4ef 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -45,7 +45,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // For migration purpose. #include "address/address-p.h" -#include "c-wrapper/c-tools.h" +#include "c-wrapper/c-wrapper.h" #include "call/call.h" #include "call/call-p.h" #include "conference/params/media-session-params-p.h" diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 0bda10aae..4f2412b6f 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -49,7 +49,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // For migration purpose. #include "address/address-p.h" -#include "c-wrapper/c-tools.h" +#include "c-wrapper/c-wrapper.h" #ifdef INET6 #ifndef _WIN32 @@ -66,7 +66,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "TargetConditionals.h" #endif -#include "c-wrapper/c-tools.h" +#include "c-wrapper/c-wrapper.h" #include "call/call-p.h" #include "conference/params/media-session-params-p.h" diff --git a/coreapi/proxy.c b/coreapi/proxy.c index 5d6e72bb0..db61462b2 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -31,7 +31,7 @@ Copyright (C) 2000 Simon MORLAT (simon.morlat@linphone.org) // For migration purpose. #include "address/address-p.h" -#include "c-wrapper/c-tools.h" +#include "c-wrapper/c-wrapper.h" /*store current config related to server location*/ static void linphone_proxy_config_store_server_config(LinphoneProxyConfig* cfg) { diff --git a/coreapi/quality_reporting.c b/coreapi/quality_reporting.c index 20afecf9d..44e0b1d2d 100644 --- a/coreapi/quality_reporting.c +++ b/coreapi/quality_reporting.c @@ -34,7 +34,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // For migration purpose. #include "address/address-p.h" -#include "c-wrapper/c-tools.h" +#include "c-wrapper/c-wrapper.h" #define STR_REASSIGN(dest, src) {\ if (dest != NULL) \ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a7febd197..3915f3584 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -23,7 +23,8 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES address/address-p.h address/address.h - c-wrapper/c-tools.h + c-wrapper/c-wrapper.h + c-wrapper/internal/c-tools.h call/call-listener.h call/call-p.h call/call.h diff --git a/src/address/address.cpp b/src/address/address.cpp index 5bd7226d8..054bad63c 100644 --- a/src/address/address.cpp +++ b/src/address/address.cpp @@ -20,7 +20,7 @@ #include "sal/sal.h" #include "address-p.h" -#include "c-wrapper/c-tools.h" +#include "c-wrapper/c-wrapper.h" #include "logger/logger.h" #include "address.h" diff --git a/src/c-wrapper/api/c-address.cpp b/src/c-wrapper/api/c-address.cpp index 78e166181..703876a33 100644 --- a/src/c-wrapper/api/c-address.cpp +++ b/src/c-wrapper/api/c-address.cpp @@ -16,10 +16,8 @@ * along with this program. If not, see . */ -#include "linphone/api/c-address.h" - #include "address/address.h" -#include "c-wrapper/c-tools.h" +#include "c-wrapper/c-wrapper.h" // ============================================================================= diff --git a/src/c-wrapper/api/c-call-params.cpp b/src/c-wrapper/api/c-call-params.cpp index 5356da94a..4d4c35a7f 100644 --- a/src/c-wrapper/api/c-call-params.cpp +++ b/src/c-wrapper/api/c-call-params.cpp @@ -16,15 +16,9 @@ * along with this program. If not, see . */ -#include "linphone/call_params.h" - -// TODO: Remove me later. -#include "private.h" - -#include "c-wrapper/c-tools.h" +#include "c-wrapper/c-wrapper.h" #include "conference/params/call-session-params-p.h" #include "conference/params/media-session-params-p.h" -#include "conference/params/media-session-params.h" // ============================================================================= diff --git a/src/c-wrapper/api/c-chat-message-cbs.cpp b/src/c-wrapper/api/c-chat-message-cbs.cpp index 3fbae1a2d..cecd05c63 100644 --- a/src/c-wrapper/api/c-chat-message-cbs.cpp +++ b/src/c-wrapper/api/c-chat-message-cbs.cpp @@ -18,8 +18,7 @@ #include "linphone/api/c-chat-message-cbs.h" -// TODO: Remove me later. -#include "private.h" +#include "c-wrapper/c-wrapper.h" // ============================================================================= @@ -66,7 +65,7 @@ void linphone_chat_message_cbs_set_user_data (LinphoneChatMessageCbs *cbs, void cbs->userData = ud; } -LinphoneChatMessageCbsMsgStateChangedCb +LinphoneChatMessageCbsMsgStateChangedCb linphone_chat_message_cbs_get_msg_state_changed(const LinphoneChatMessageCbs *cbs) { return cbs->msg_state_changed; } diff --git a/src/c-wrapper/api/c-chat-message.cpp b/src/c-wrapper/api/c-chat-message.cpp index fa615343c..afb079ff4 100644 --- a/src/c-wrapper/api/c-chat-message.cpp +++ b/src/c-wrapper/api/c-chat-message.cpp @@ -16,21 +16,17 @@ * along with this program. If not, see . */ -#include "linphone/chat.h" -#include "linphone/wrapper_utils.h" +#include "linphone/api/c-chat-message.h" #include "linphone/utils/utils.h" +#include "linphone/wrapper_utils.h" + #include "ortp/b64.h" -// TODO: Remove me later. -#include "private.h" - -#include "chat/chat-room.h" +#include "c-wrapper/c-wrapper.h" +#include "chat/chat-message-p.h" #include "chat/chat-room-p.h" #include "chat/real-time-text-chat-room-p.h" #include "content/content-type.h" -#include "c-wrapper/c-tools.h" -#include "chat/chat-message.h" -#include "chat/chat-message-p.h" // ============================================================================= @@ -626,9 +622,9 @@ LinphoneChatMessageCbs *linphone_chat_message_get_callbacks(const LinphoneChatMe } static bool_t file_transfer_in_progress_and_valid(LinphoneChatMessage* msg) { - return (linphone_chat_message_get_chat_room(msg) && - linphone_chat_room_get_core(linphone_chat_message_get_chat_room(msg)) && - linphone_chat_message_get_http_request(msg) && + return (linphone_chat_message_get_chat_room(msg) && + linphone_chat_room_get_core(linphone_chat_message_get_chat_room(msg)) && + linphone_chat_message_get_http_request(msg) && !belle_http_request_is_cancelled(linphone_chat_message_get_http_request(msg))); } diff --git a/src/c-wrapper/api/c-chat-room-cbs.cpp b/src/c-wrapper/api/c-chat-room-cbs.cpp index f83f5c5ea..34b78e27e 100644 --- a/src/c-wrapper/api/c-chat-room-cbs.cpp +++ b/src/c-wrapper/api/c-chat-room-cbs.cpp @@ -18,8 +18,7 @@ #include "linphone/api/c-chat-room-cbs.h" -// TODO: Remove me later. -#include "private.h" +#include "c-wrapper/c-wrapper.h" // ============================================================================= diff --git a/src/c-wrapper/api/c-chat-room.cpp b/src/c-wrapper/api/c-chat-room.cpp index dc5481d95..35bef9a47 100644 --- a/src/c-wrapper/api/c-chat-room.cpp +++ b/src/c-wrapper/api/c-chat-room.cpp @@ -16,19 +16,15 @@ * along with this program. If not, see . */ -#include "linphone/chat.h" -#include "linphone/wrapper_utils.h" - // TODO: Remove me later. -#include "private.h" +#include "linphone/chat.h" -#include "c-wrapper/c-tools.h" +#include "linphone/api/c-chat-room.h" + +#include "c-wrapper/c-wrapper.h" #include "chat/basic-chat-room.h" -#include "chat/chat-room-p.h" -#include "chat/chat-room.h" #include "chat/client-group-chat-room.h" #include "chat/real-time-text-chat-room-p.h" -#include "chat/real-time-text-chat-room.h" // ============================================================================= @@ -37,8 +33,6 @@ using namespace std; -extern LinphoneParticipant *_linphone_Participant_init (); - static void _linphone_chat_room_constructor (LinphoneChatRoom *cr); static void _linphone_chat_room_destructor (LinphoneChatRoom *cr); diff --git a/src/c-wrapper/api/c-event-log.cpp b/src/c-wrapper/api/c-event-log.cpp index d65bce511..77e0c53d2 100644 --- a/src/c-wrapper/api/c-event-log.cpp +++ b/src/c-wrapper/api/c-event-log.cpp @@ -19,7 +19,7 @@ #include "linphone/api/c-chat-message.h" #include "linphone/api/c-event-log.h" -#include "c-wrapper/c-tools.h" +#include "c-wrapper/c-wrapper.h" #include "call/call.h" #include "chat/chat-message.h" #include "event-log/call-event.h" @@ -73,9 +73,6 @@ LinphoneCallEvent *linphone_call_event_new (LinphoneEventLogType type, LinphoneC return call_event; } -// TODO: REMOVE ME. -extern LinphoneCall *_linphone_Call_init (); - LinphoneCall *linphone_call_event_get_call (const LinphoneCallEvent *call_event) { return L_GET_C_BACK_PTR( L_GET_CPP_PTR_FROM_C_STRUCT( @@ -137,9 +134,6 @@ LinphoneChatMessageEvent *linphone_chat_message_event_new (LinphoneChatMessage * return chat_message_event; } -// TODO: REMOVE ME. -extern LinphoneChatMessage *_linphone_ChatMessage_init (); - LinphoneChatMessage *linphone_chat_message_event_get_chat_message (const LinphoneChatMessageEvent *chat_message_event) { return L_GET_C_BACK_PTR( L_GET_CPP_PTR_FROM_C_STRUCT( diff --git a/src/c-wrapper/api/c-participant.cpp b/src/c-wrapper/api/c-participant.cpp index ea947d6f9..05e0169ff 100644 --- a/src/c-wrapper/api/c-participant.cpp +++ b/src/c-wrapper/api/c-participant.cpp @@ -18,7 +18,7 @@ #include "linphone/api/c-participant.h" -#include "c-wrapper/c-tools.h" +#include "c-wrapper/c-wrapper.h" #include "conference/participant.h" // ============================================================================= diff --git a/src/c-wrapper/c-wrapper.h b/src/c-wrapper/c-wrapper.h new file mode 100644 index 000000000..90f0fb112 --- /dev/null +++ b/src/c-wrapper/c-wrapper.h @@ -0,0 +1,38 @@ +/* + * c-wrapper.h + * Copyright (C) 2017 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 . + */ + +#ifndef _C_WRAPPER_H_ +#define _C_WRAPPER_H_ + +#include "linphone/api/c-types.h" + +#include "internal/c-tools.h" + +// ============================================================================= + +#define L_REGISTER_TYPE(C_TYPE) \ + extern Linphone ## C_TYPE *_linphone_ ## C_TYPE ## _init (); + +// ============================================================================= + +L_REGISTER_TYPE(Call); +L_REGISTER_TYPE(ChatMessage); +L_REGISTER_TYPE(ChatRoom); +L_REGISTER_TYPE(Participant); + +#endif // ifndef _C_WRAPPER_H_ diff --git a/src/c-wrapper/c-tools.h b/src/c-wrapper/internal/c-tools.h similarity index 99% rename from src/c-wrapper/c-tools.h rename to src/c-wrapper/internal/c-tools.h index 0375ad567..71294bdcd 100644 --- a/src/c-wrapper/c-tools.h +++ b/src/c-wrapper/internal/c-tools.h @@ -1,5 +1,5 @@ /* - * c-tools.h + * c-wrapper.h * Copyright (C) 2017 Belledonne Communications SARL * * This program is free software: you can redistribute it and/or modify diff --git a/src/chat/chat-room.cpp b/src/chat/chat-room.cpp index aad0b9e34..b34123947 100644 --- a/src/chat/chat-room.cpp +++ b/src/chat/chat-room.cpp @@ -18,10 +18,10 @@ #include +#include "linphone/api/c-chat-message.h" #include "linphone/utils/utils.h" -#include "linphone/api/c-chat-message.h" -#include "c-wrapper/c-tools.h" +#include "c-wrapper/c-wrapper.h" #include "chat-room-p.h" #include "content/content-type.h" #include "imdn.h" @@ -29,7 +29,6 @@ #include "chat-room.h" -extern LinphoneChatRoom * _linphone_ChatRoom_init(); #define GET_BACK_PTR(object) L_GET_C_BACK_PTR(object->shared_from_this(), ChatRoom) // ============================================================================= diff --git a/src/chat/client-group-chat-room.cpp b/src/chat/client-group-chat-room.cpp index 92ad4dd72..9cd3592e0 100644 --- a/src/chat/client-group-chat-room.cpp +++ b/src/chat/client-group-chat-room.cpp @@ -17,15 +17,12 @@ */ #include "client-group-chat-room-p.h" -#include "c-wrapper/c-tools.h" +#include "c-wrapper/c-wrapper.h" #include "conference/participant-p.h" #include "logger/logger.h" // ============================================================================= -extern LinphoneChatRoom * _linphone_ChatRoom_init(); -extern LinphoneParticipant * _linphone_Participant_init(); - using namespace std; LINPHONE_BEGIN_NAMESPACE diff --git a/src/chat/real-time-text-chat-room.cpp b/src/chat/real-time-text-chat-room.cpp index 2c21e2016..b1d75d301 100644 --- a/src/chat/real-time-text-chat-room.cpp +++ b/src/chat/real-time-text-chat-room.cpp @@ -21,10 +21,9 @@ #include "linphone/utils/utils.h" #include "real-time-text-chat-room-p.h" -#include "c-wrapper/c-tools.h" +#include "c-wrapper/c-wrapper.h" #include "logger/logger.h" -extern LinphoneChatRoom * _linphone_ChatRoom_init(); #define GET_BACK_PTR(object) L_GET_C_BACK_PTR(object->shared_from_this(), ChatRoom) // ============================================================================= diff --git a/src/conference/session/call-session.cpp b/src/conference/session/call-session.cpp index fb00b8990..7054a20d8 100644 --- a/src/conference/session/call-session.cpp +++ b/src/conference/session/call-session.cpp @@ -18,7 +18,7 @@ #include -#include "c-wrapper/c-tools.h" +#include "c-wrapper/c-wrapper.h" #include "address/address-p.h" #include "conference/session/call-session-p.h" diff --git a/src/conference/session/media-session.cpp b/src/conference/session/media-session.cpp index 49b90280a..1613e6282 100644 --- a/src/conference/session/media-session.cpp +++ b/src/conference/session/media-session.cpp @@ -20,7 +20,7 @@ #include #include "address/address-p.h" -#include "c-wrapper/c-tools.h" +#include "c-wrapper/c-wrapper.h" #include "conference/session/media-session-p.h" #include "call/call-p.h" #include "conference/participant-p.h"