From ec23c3bdc895f5e2ea77cf55363704bfe369f702 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Thu, 24 May 2018 10:37:27 +0200 Subject: [PATCH] fix(linphone): add some fixes for Windows + add a export symbol for internal classes --- include/linphone/core_utils.h | 4 +- include/linphone/utils/general.h | 4 +- src/CMakeLists.txt | 1 + src/c-wrapper/internal/c-sal.h | 6 +-- .../local-conference-event-handler-p.h | 2 +- src/conference/participant.cpp | 6 --- src/conference/participant.h | 8 ++- src/content/header/header.cpp | 12 ++--- src/content/header/header.h | 3 +- src/db/abstract/abstract-db.h | 3 +- src/db/main-db.h | 2 +- src/object/base-object-p.h | 3 +- src/object/object-p.h | 13 ++++- src/sal/sal.cpp | 6 +-- src/utils/general-internal.h | 51 +++++++++++++++++++ 15 files changed, 94 insertions(+), 30 deletions(-) create mode 100644 src/utils/general-internal.h diff --git a/include/linphone/core_utils.h b/include/linphone/core_utils.h index aaac2e5ab..18d0f8807 100644 --- a/include/linphone/core_utils.h +++ b/include/linphone/core_utils.h @@ -122,9 +122,9 @@ LINPHONE_PUBLIC void linphone_core_stop_dtmf_stream(LinphoneCore* lc); typedef bool_t (*LinphoneCoreIterateHook)(void *data); -void linphone_core_add_iterate_hook(LinphoneCore *lc, LinphoneCoreIterateHook hook, void *hook_data); +LINPHONE_PUBLIC void linphone_core_add_iterate_hook(LinphoneCore *lc, LinphoneCoreIterateHook hook, void *hook_data); -void linphone_core_remove_iterate_hook(LinphoneCore *lc, LinphoneCoreIterateHook hook, void *hook_data); +LINPHONE_PUBLIC void linphone_core_remove_iterate_hook(LinphoneCore *lc, LinphoneCoreIterateHook hook, void *hook_data); #ifdef __cplusplus } diff --git a/include/linphone/utils/general.h b/include/linphone/utils/general.h index 829d4bda5..87f4a4808 100644 --- a/include/linphone/utils/general.h +++ b/include/linphone/utils/general.h @@ -53,9 +53,9 @@ LINPHONE_BEGIN_NAMESPACE #define LINPHONE_PUBLIC #else #ifdef LINPHONE_EXPORTS - #define LINPHONE_PUBLIC __declspec(dllexport) + #define LINPHONE_PUBLIC __declspec(dllexport) #else - #define LINPHONE_PUBLIC __declspec(dllimport) + #define LINPHONE_PUBLIC __declspec(dllimport) #endif #endif #else diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 351cf9022..49cfb5db9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -210,6 +210,7 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES search/magic-search.h search/search-result.h utils/background-task.h + utils/general-internal.h utils/payload-type-handler.h variant/variant.h xml/conference-info.h diff --git a/src/c-wrapper/internal/c-sal.h b/src/c-wrapper/internal/c-sal.h index f34c4ee5f..c7bd15ef6 100644 --- a/src/c-wrapper/internal/c-sal.h +++ b/src/c-wrapper/internal/c-sal.h @@ -94,10 +94,10 @@ extern "C" { const char* sal_transport_to_string(SalTransport transport); SalTransport sal_transport_parse(const char*); /* Address manipulation API*/ -SalAddress * sal_address_new(const char *uri); +LINPHONE_PUBLIC SalAddress * sal_address_new(const char *uri); SalAddress * sal_address_clone(const SalAddress *addr); SalAddress * sal_address_ref(SalAddress *addr); -void sal_address_unref(SalAddress *addr); +LINPHONE_PUBLIC void sal_address_unref(SalAddress *addr); const char *sal_address_get_scheme(const SalAddress *addr); const char *sal_address_get_display_name(const SalAddress* addr); const char *sal_address_get_display_name_unquoted(const SalAddress *addr); @@ -119,7 +119,7 @@ void sal_address_clean(SalAddress *addr); char *sal_address_as_string(const SalAddress *u); char *sal_address_as_string_uri_only(const SalAddress *u); void sal_address_destroy(SalAddress *u); -void sal_address_set_param(SalAddress *u,const char* name,const char* value); +LINPHONE_PUBLIC void sal_address_set_param(SalAddress *u,const char* name,const char* value); void sal_address_set_transport(SalAddress* addr,SalTransport transport); void sal_address_set_transport_name(SalAddress* addr,const char* transport); void sal_address_set_method_param(SalAddress *addr, const char *method); diff --git a/src/conference/handlers/local-conference-event-handler-p.h b/src/conference/handlers/local-conference-event-handler-p.h index a4ad08b2a..2c79157b8 100644 --- a/src/conference/handlers/local-conference-event-handler-p.h +++ b/src/conference/handlers/local-conference-event-handler-p.h @@ -32,7 +32,7 @@ LINPHONE_BEGIN_NAMESPACE class Participant; class ParticipantDevice; -class LocalConferenceEventHandlerPrivate : public ObjectPrivate { +class LINPHONE_INTERNAL_PUBLIC LocalConferenceEventHandlerPrivate : public ObjectPrivate { public: void notifyFullState (const std::string ¬ify, const std::shared_ptr &device); void notifyAllExcept (const std::string ¬ify, const std::shared_ptr &exceptParticipant); diff --git a/src/conference/participant.cpp b/src/conference/participant.cpp index f72094c7f..3d3c4e472 100644 --- a/src/conference/participant.cpp +++ b/src/conference/participant.cpp @@ -111,10 +111,4 @@ bool Participant::isAdmin () const { return d->isAdmin; } -// ============================================================================= - -ostream & operator<< (ostream &strm, const shared_ptr &participant) { - return strm << "'" << participant->getAddress().asString() << "'"; -} - LINPHONE_END_NAMESPACE diff --git a/src/conference/participant.h b/src/conference/participant.h index f1d9f1040..5d59188f4 100644 --- a/src/conference/participant.h +++ b/src/conference/participant.h @@ -23,8 +23,8 @@ #include #include "address/identity-address.h" -#include "object/object.h" #include "conference/params/call-session-params.h" +#include "object/object.h" // ============================================================================= @@ -34,6 +34,7 @@ class ClientGroupChatRoom; class ParticipantPrivate; class Participant : public Object { + // TODO: Remove... It's ugly. friend class Call; friend class CallPrivate; friend class ClientGroupChatRoom; @@ -67,7 +68,10 @@ private: L_DISABLE_COPY(Participant); }; -std::ostream & operator<< (std::ostream &strm, const std::shared_ptr &participant); +inline std::ostream &operator<< (std::ostream &os, const Participant &participant) { + return os << participant.getAddress().asString(); + return os; +} LINPHONE_END_NAMESPACE diff --git a/src/content/header/header.cpp b/src/content/header/header.cpp index 5924cdf5b..519ae2db3 100644 --- a/src/content/header/header.cpp +++ b/src/content/header/header.cpp @@ -45,7 +45,7 @@ Header::Header (const string &name, const string &value) : ClonableObject(*new H setValue(value); return; } - + string parsedValue = value.substr(0, posParam); string params = value.substr(posParam + 1); string token; @@ -167,7 +167,7 @@ string Header::asString () const { stringstream asString; if (!getName().empty()) { asString << getName() << ":"; - } + } asString << getValue(); for (const auto ¶m : getParameters()) { asString << param.asString(); @@ -175,9 +175,9 @@ string Header::asString () const { return asString.str(); } -ostream &operator<<(ostream& stream, const Header& header) { - stream << header.asString(); - return stream; +ostream &operator<< (ostream &os, const Header& header) { + os << header.asString(); + return os; } -LINPHONE_END_NAMESPACE \ No newline at end of file +LINPHONE_END_NAMESPACE diff --git a/src/content/header/header.h b/src/content/header/header.h index 583572523..e0541538a 100644 --- a/src/content/header/header.h +++ b/src/content/header/header.h @@ -60,7 +60,8 @@ public: const HeaderParam &getParameter (const std::string ¶mName) const; std::string asString () const; - friend std::ostream &operator<<(std::ostream&, const Header&); + + LINPHONE_PUBLIC friend std::ostream &operator<< (std::ostream &os, const Header &header); protected: explicit Header (HeaderPrivate &p); diff --git a/src/db/abstract/abstract-db.h b/src/db/abstract/abstract-db.h index a6b401dd8..ff367f764 100644 --- a/src/db/abstract/abstract-db.h +++ b/src/db/abstract/abstract-db.h @@ -21,6 +21,7 @@ #define _L_ABSTRACT_DB_H_ #include "object/object.h" +#include "utils/general-internal.h" // ============================================================================= @@ -28,7 +29,7 @@ LINPHONE_BEGIN_NAMESPACE class AbstractDbPrivate; -class AbstractDb : public Object { +class LINPHONE_INTERNAL_PUBLIC AbstractDb : public Object { public: enum Backend { Mysql, diff --git a/src/db/main-db.h b/src/db/main-db.h index 53d471dbc..b43f4a7ae 100644 --- a/src/db/main-db.h +++ b/src/db/main-db.h @@ -42,7 +42,7 @@ class MainDbKey; class MainDbPrivate; class ParticipantDevice; -class MainDb : public AbstractDb, public CoreAccessor { +class LINPHONE_INTERNAL_PUBLIC MainDb : public AbstractDb, public CoreAccessor { template friend class DbTransaction; diff --git a/src/object/base-object-p.h b/src/object/base-object-p.h index 9c5120a15..ee1099e3a 100644 --- a/src/object/base-object-p.h +++ b/src/object/base-object-p.h @@ -23,12 +23,13 @@ #include "linphone/utils/general.h" #include "object-head-p.h" +#include "utils/general-internal.h" // ============================================================================= LINPHONE_BEGIN_NAMESPACE -class BaseObjectPrivate { +class LINPHONE_INTERNAL_PUBLIC BaseObjectPrivate { L_OBJECT_PRIVATE; public: diff --git a/src/object/object-p.h b/src/object/object-p.h index 122ce8d34..2b2d0d351 100644 --- a/src/object/object-p.h +++ b/src/object/object-p.h @@ -27,7 +27,14 @@ LINPHONE_BEGIN_NAMESPACE -class ObjectPrivate : public BaseObjectPrivate { +#ifdef _WIN32 + // TODO: Avoid this error. + // Disable C4251 triggered by std::recursive_mutex. + #pragma warning(push) + #pragma warning(disable: 4251) +#endif // ifdef _WIN32 + +class LINPHONE_INTERNAL_PUBLIC ObjectPrivate : public BaseObjectPrivate { protected: inline const Object::Lock &getLock () const { return lock; @@ -39,6 +46,10 @@ private: L_DECLARE_PUBLIC(Object); }; +#ifdef _WIN32 + #pragma warning(pop) +#endif // ifdef _WIN32 + LINPHONE_END_NAMESPACE #endif // ifndef _L_OBJECT_P_H_ diff --git a/src/sal/sal.cpp b/src/sal/sal.cpp index cc4aa6658..71c2e169e 100644 --- a/src/sal/sal.cpp +++ b/src/sal/sal.cpp @@ -973,7 +973,7 @@ LINPHONE_PUBLIC void sal_set_dns_user_hosts_file(Sal *sal, const char *hosts_fil sal->setDnsUserHostsFile(hosts_file); } -void *sal_get_stack_impl(Sal *sal) { +LINPHONE_PUBLIC void *sal_get_stack_impl(Sal *sal) { return sal->getStackImpl(); } @@ -1020,11 +1020,11 @@ LINPHONE_PUBLIC belle_sip_resolver_context_t *sal_resolve_a(Sal *sal, const char return sal->resolveA(name, port, family, cb, data); } -Sal *sal_op_get_sal(SalOp *op) { +LINPHONE_PUBLIC Sal *sal_op_get_sal(SalOp *op) { return op->getSal(); } -SalOp *sal_create_refer_op(Sal *sal) { +LINPHONE_PUBLIC SalOp *sal_create_refer_op(Sal *sal) { return new SalReferOp(sal); } diff --git a/src/utils/general-internal.h b/src/utils/general-internal.h new file mode 100644 index 000000000..c2e765339 --- /dev/null +++ b/src/utils/general-internal.h @@ -0,0 +1,51 @@ +/* + * general-internal.h + * 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 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. + */ + +#ifndef _L_GENERAL_INTERNAL_H_ +#define _L_GENERAL_INTERNAL_H_ + +#include "linphone/utils/general.h" + +// ============================================================================= + +LINPHONE_BEGIN_NAMESPACE + +// ----------------------------------------------------------------------------- +// Export. +// ----------------------------------------------------------------------------- + +#ifndef LINPHONE_INTERNAL_PUBLIC + #if defined(_MSC_VER) + #ifdef LINPHONE_STATIC + #define LINPHONE_INTERNAL_PUBLIC + #else + #ifdef LINPHONE_EXPORTS + #define LINPHONE_INTERNAL_PUBLIC __declspec(dllexport) + #else + #define LINPHONE_INTERNAL_PUBLIC __declspec(dllimport) + #endif + #endif + #else + #define LINPHONE_INTERNAL_PUBLIC + #endif +#endif + +LINPHONE_END_NAMESPACE + +#endif // ifndef _L_GENERAL_INTERNAL_H_