diff --git a/bin/dbus/dbuscallmanager.h b/bin/dbus/dbuscallmanager.h index 3ba1cb18310f6e2ef11332b5d51ae516da6c42ec..9b3135fe0fa3de0dbec732e82ddc83536aee7d54 100644 --- a/bin/dbus/dbuscallmanager.h +++ b/bin/dbus/dbuscallmanager.h @@ -25,6 +25,7 @@ #include <map> #include <string> +#include "dring/def.h" #include "dbus_cpp.h" #if __GNUC__ >= 5 || (__GNUC__ >=4 && __GNUC_MINOR__ >= 6) @@ -45,7 +46,7 @@ #include <stdexcept> -class DBusCallManager : +class DRING_PUBLIC DBusCallManager : public cx::ring::Ring::CallManager_adaptor, public DBus::IntrospectableAdaptor, public DBus::ObjectAdaptor diff --git a/bin/dbus/dbusclient.h b/bin/dbus/dbusclient.h index 2caae1e8c5e4db0f78e26e44d5beb4ae35252086..4afecd9aac5b5334d7ffe5b4df32980d572d501f 100644 --- a/bin/dbus/dbusclient.h +++ b/bin/dbus/dbusclient.h @@ -25,6 +25,7 @@ #include "config.h" #endif // HAVE_CONFIG_H +#include "dring/def.h" #include "dring.h" #include <memory> @@ -43,7 +44,7 @@ namespace DBus { class DefaultTimeout; } -class DBusClient { +class DRING_PUBLIC DBusClient { public: DBusClient(int flags, bool persistent); ~DBusClient(); diff --git a/bin/dbus/dbusconfigurationmanager.h b/bin/dbus/dbusconfigurationmanager.h index 20b3e21db4762b7c0b1dc5189f2a25ebbd0d4b01..c03595a462d67b623406cbdda152cba34bcb4290 100644 --- a/bin/dbus/dbusconfigurationmanager.h +++ b/bin/dbus/dbusconfigurationmanager.h @@ -29,6 +29,7 @@ #include <map> #include <string> +#include "dring/def.h" #include "dbus_cpp.h" #include "dring/datatransfer_interface.h" @@ -51,7 +52,7 @@ using RingDBusMessage = DBus::Struct<std::string, std::map<std::string, std::string>, uint64_t>; -class DBusConfigurationManager : +class DRING_PUBLIC DBusConfigurationManager : public cx::ring::Ring::ConfigurationManager_adaptor, public DBus::IntrospectableAdaptor, public DBus::ObjectAdaptor diff --git a/bin/dbus/dbusinstance.h b/bin/dbus/dbusinstance.h index e420e60526ed1e8f68c0912feb13d48a39815278..746d00b9544dfe76178fa70a7b9b7b6463203bf2 100644 --- a/bin/dbus/dbusinstance.h +++ b/bin/dbus/dbusinstance.h @@ -21,6 +21,8 @@ #ifndef __RING_DBUSINSTANCE_H__ #define __RING_DBUSINSTANCE_H__ +#include "dring/def.h" + #include <functional> #if __GNUC__ >= 5 || (__GNUC__ >=4 && __GNUC_MINOR__ >= 6) @@ -37,7 +39,7 @@ #pragma GCC diagnostic warning "-Wunused-but-set-variable" #endif -class DBusInstance : +class DRING_PUBLIC DBusInstance : public cx::ring::Ring::Instance_adaptor, public DBus::IntrospectableAdaptor, public DBus::ObjectAdaptor diff --git a/bin/dbus/dbuspresencemanager.h b/bin/dbus/dbuspresencemanager.h index 72db9cb56d5f1ae42747a3fc5b5f5ed2169c5f5e..6b36b44d0c75e38af5c05e0b096e4671815db81d 100644 --- a/bin/dbus/dbuspresencemanager.h +++ b/bin/dbus/dbuspresencemanager.h @@ -25,6 +25,7 @@ #include <map> #include <string> +#include "dring/def.h" #include "dbus_cpp.h" #if __GNUC__ >= 5 || (__GNUC__ >=4 && __GNUC_MINOR__ >= 6) @@ -43,7 +44,7 @@ #pragma GCC diagnostic warning "-Wunused-but-set-variable" #endif -class DBusPresenceManager : +class DRING_PUBLIC DBusPresenceManager : public cx::ring::Ring::PresenceManager_adaptor, public DBus::IntrospectableAdaptor, public DBus::ObjectAdaptor diff --git a/bin/dbus/dbusvideomanager.h b/bin/dbus/dbusvideomanager.h index d66f16778bae3cb0264c7854b44a55686a31068c..2148eb89d8ded6bb7344f7a3230edd5f9e4c5dfb 100644 --- a/bin/dbus/dbusvideomanager.h +++ b/bin/dbus/dbusvideomanager.h @@ -23,6 +23,7 @@ #include <map> #include <string> +#include "dring/def.h" #include "dbus_cpp.h" #if __GNUC__ >= 5 || (__GNUC__ >=4 && __GNUC_MINOR__ >= 6) @@ -41,7 +42,7 @@ #pragma GCC diagnostic warning "-Wunused-but-set-variable" #endif -class DBusVideoManager : +class DRING_PUBLIC DBusVideoManager : public cx::ring::Ring::VideoManager_adaptor, public DBus::IntrospectableAdaptor, public DBus::ObjectAdaptor diff --git a/configure.ac b/configure.ac index 1e11ca24c207d84363b2dcc157869abb7677b1a0..a53a77dc1aab386ec3d3f3cd391425f7f49b398b 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ dnl Ring - configure.ac for automake 1.9 and autoconf 2.59 dnl Process this file with autoconf to produce a configure script. AC_PREREQ([2.65]) -AC_INIT([Ring Daemon],[5.2.0],[ring@gnu.org],[ring]) +AC_INIT([Ring Daemon],[6.0.0],[ring@gnu.org],[ring]) AC_COPYRIGHT([[Copyright (c) Savoir-faire Linux 2004-2018]]) AC_REVISION([$Revision$]) @@ -191,6 +191,18 @@ AC_COMPILE_IFELSE( AC_MSG_RESULT([$CLANG]) +dnl define DRING_BUILD because we are building libring, not using it +dnl if building shared library, define dring_EXPORTS +AC_MSG_CHECKING([if compiling shared library]) +CPPFLAGS="${CPPFLAGS} -fvisibility=hidden -DDRING_BUILD " +AS_IF([test "x$enable_shared" == "xyes"], [ + RING_SHARED=yes + CPPFLAGS="${CPPFLAGS} -Ddring_EXPORTS " +],[ + RING_SHARED=no +]) +AC_MSG_RESULT([$RING_SHARED]) + dnl dnl Check for the contrib directory dnl diff --git a/doc/doxygen/core-doc.cfg.in b/doc/doxygen/core-doc.cfg.in index b27b529c07ea406d48a4c3f11e2c5de164b6434d..abff1802e775068640c7cc3ca673cdec7ec834e9 100644 --- a/doc/doxygen/core-doc.cfg.in +++ b/doc/doxygen/core-doc.cfg.in @@ -31,7 +31,7 @@ PROJECT_NAME = "Ring Daemon" # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = 5.2.0 +PROJECT_NUMBER = 6.0.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer diff --git a/src/Makefile.am b/src/Makefile.am index 75bc80b27899f8d7a6804d25accf89735fa8cfc8..34136d76dfe40a71ef05f1001084e4eb5053464b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -165,7 +165,8 @@ nobase_include_HEADERS= dring/dring.h \ dring/account_const.h \ dring/call_const.h \ dring/presence_const.h \ - dring/media_const.h + dring/media_const.h \ + dring/def.h if RING_VIDEO nobase_include_HEADERS+= \ diff --git a/src/dring/account_const.h b/src/dring/account_const.h index 1dbb87cba1bf18c12ee62ae97bb93cba54d2d3b5..30afde9c40b70a67b4016ba0c3ea5f9c23f90650 100644 --- a/src/dring/account_const.h +++ b/src/dring/account_const.h @@ -21,6 +21,8 @@ #ifndef DRING_ACCOUNT_H #define DRING_ACCOUNT_H +#include "def.h" + //Defined in windows.h #ifdef ERROR #undef ERROR diff --git a/src/dring/call_const.h b/src/dring/call_const.h index 0edd8bcc9c97a22d8fc30821fa97b7cb9d7f9a9d..02b4f94295b169d37e067fd4a21e9f6020827d93 100644 --- a/src/dring/call_const.h +++ b/src/dring/call_const.h @@ -20,6 +20,8 @@ #ifndef DRING_CALL_H #define DRING_CALL_H +#include "def.h" + namespace DRing { namespace Call { diff --git a/src/dring/callmanager_interface.h b/src/dring/callmanager_interface.h index eed3204ff5b52487b89774041f0afe614bf0fad8..d00ca8066a306c255e21feb7757b1a52a9aab09f 100644 --- a/src/dring/callmanager_interface.h +++ b/src/dring/callmanager_interface.h @@ -22,6 +22,8 @@ #ifndef DRING_CALLMANAGERI_H #define DRING_CALLMANAGERI_H +#include "def.h" + #include <stdexcept> #include <map> #include <memory> @@ -33,161 +35,161 @@ namespace DRing { -[[deprecated("Replaced by registerSignalHandlers")]] +[[deprecated("Replaced by registerSignalHandlers")]] DRING_PUBLIC void registerCallHandlers(const std::map<std::string, std::shared_ptr<CallbackWrapperBase>>&); /* Call related methods */ -std::string placeCall(const std::string& accountID, const std::string& to); -std::string placeCall(const std::string& accountID, const std::string& to, const std::map<std::string, std::string>& VolatileCallDetails); - -bool refuse(const std::string& callID); -bool accept(const std::string& callID); -bool hangUp(const std::string& callID); -bool hold(const std::string& callID); -bool unhold(const std::string& callID); -bool muteLocalMedia(const std::string& callid, const std::string& mediaType, bool mute); -bool transfer(const std::string& callID, const std::string& to); -bool attendedTransfer(const std::string& transferID, const std::string& targetID); -std::map<std::string, std::string> getCallDetails(const std::string& callID); -std::vector<std::string> getCallList(); +DRING_PUBLIC std::string placeCall(const std::string& accountID, const std::string& to); +DRING_PUBLIC std::string placeCall(const std::string& accountID, const std::string& to, const std::map<std::string, std::string>& VolatileCallDetails); + +DRING_PUBLIC bool refuse(const std::string& callID); +DRING_PUBLIC bool accept(const std::string& callID); +DRING_PUBLIC bool hangUp(const std::string& callID); +DRING_PUBLIC bool hold(const std::string& callID); +DRING_PUBLIC bool unhold(const std::string& callID); +DRING_PUBLIC bool muteLocalMedia(const std::string& callid, const std::string& mediaType, bool mute); +DRING_PUBLIC bool transfer(const std::string& callID, const std::string& to); +DRING_PUBLIC bool attendedTransfer(const std::string& transferID, const std::string& targetID); +DRING_PUBLIC std::map<std::string, std::string> getCallDetails(const std::string& callID); +DRING_PUBLIC std::vector<std::string> getCallList(); /* Conference related methods */ -void removeConference(const std::string& conference_id); -bool joinParticipant(const std::string& sel_callID, const std::string& drag_callID); -void createConfFromParticipantList(const std::vector<std::string>& participants); -bool isConferenceParticipant(const std::string& call_id); -bool addParticipant(const std::string& callID, const std::string& confID); -bool addMainParticipant(const std::string& confID); -bool detachLocalParticipant(); -bool detachParticipant(const std::string& callID); -bool joinConference(const std::string& sel_confID, const std::string& drag_confID); -bool hangUpConference(const std::string& confID); -bool holdConference(const std::string& confID); -bool unholdConference(const std::string& confID); -std::vector<std::string> getConferenceList(); -std::vector<std::string> getParticipantList(const std::string& confID); -std::vector<std::string> getDisplayNames(const std::string& confID); -std::string getConferenceId(const std::string& callID); -std::map<std::string, std::string> getConferenceDetails(const std::string& callID); +DRING_PUBLIC void removeConference(const std::string& conference_id); +DRING_PUBLIC bool joinParticipant(const std::string& sel_callID, const std::string& drag_callID); +DRING_PUBLIC void createConfFromParticipantList(const std::vector<std::string>& participants); +DRING_PUBLIC bool isConferenceParticipant(const std::string& call_id); +DRING_PUBLIC bool addParticipant(const std::string& callID, const std::string& confID); +DRING_PUBLIC bool addMainParticipant(const std::string& confID); +DRING_PUBLIC bool detachLocalParticipant(); +DRING_PUBLIC bool detachParticipant(const std::string& callID); +DRING_PUBLIC bool joinConference(const std::string& sel_confID, const std::string& drag_confID); +DRING_PUBLIC bool hangUpConference(const std::string& confID); +DRING_PUBLIC bool holdConference(const std::string& confID); +DRING_PUBLIC bool unholdConference(const std::string& confID); +DRING_PUBLIC std::vector<std::string> getConferenceList(); +DRING_PUBLIC std::vector<std::string> getParticipantList(const std::string& confID); +DRING_PUBLIC std::vector<std::string> getDisplayNames(const std::string& confID); +DRING_PUBLIC std::string getConferenceId(const std::string& callID); +DRING_PUBLIC std::map<std::string, std::string> getConferenceDetails(const std::string& callID); /* Statistic related methods */ -void startSmartInfo(uint32_t refreshTimeMs); -void stopSmartInfo(); +DRING_PUBLIC void startSmartInfo(uint32_t refreshTimeMs); +DRING_PUBLIC void stopSmartInfo(); /* File Playback methods */ -bool startRecordedFilePlayback(const std::string& filepath); -void stopRecordedFilePlayback(); +DRING_PUBLIC bool startRecordedFilePlayback(const std::string& filepath); +DRING_PUBLIC void stopRecordedFilePlayback(); /* General audio methods */ -bool toggleRecording(const std::string& callID); +DRING_PUBLIC bool toggleRecording(const std::string& callID); /* DEPRECATED */ -void setRecording(const std::string& callID); +DRING_PUBLIC void setRecording(const std::string& callID); -void recordPlaybackSeek(double value); -bool getIsRecording(const std::string& callID); -std::string getCurrentAudioCodecName(const std::string& callID); -void playDTMF(const std::string& key); -void startTone(int32_t start, int32_t type); +DRING_PUBLIC void recordPlaybackSeek(double value); +DRING_PUBLIC bool getIsRecording(const std::string& callID); +DRING_PUBLIC std::string getCurrentAudioCodecName(const std::string& callID); +DRING_PUBLIC void playDTMF(const std::string& key); +DRING_PUBLIC void startTone(int32_t start, int32_t type); -bool switchInput(const std::string& callID, const std::string& resource); +DRING_PUBLIC bool switchInput(const std::string& callID, const std::string& resource); /* Security related methods */ -void setSASVerified(const std::string& callID); -void resetSASVerified(const std::string& callID); -void setConfirmGoClear(const std::string& callID); -void requestGoClear(const std::string& callID); -void acceptEnrollment(const std::string& callID, bool accepted); +DRING_PUBLIC void setSASVerified(const std::string& callID); +DRING_PUBLIC void resetSASVerified(const std::string& callID); +DRING_PUBLIC void setConfirmGoClear(const std::string& callID); +DRING_PUBLIC void requestGoClear(const std::string& callID); +DRING_PUBLIC void acceptEnrollment(const std::string& callID, bool accepted); /* Instant messaging */ -void sendTextMessage(const std::string& callID, const std::map<std::string, std::string>& messages, const std::string& from, bool isMixed); +DRING_PUBLIC void sendTextMessage(const std::string& callID, const std::map<std::string, std::string>& messages, const std::string& from, bool isMixed); // Call signal type definitions -struct CallSignal { - struct StateChange { +struct DRING_PUBLIC CallSignal { + struct DRING_PUBLIC StateChange { constexpr static const char* name = "StateChange"; using cb_type = void(const std::string&, const std::string&, int); }; - struct TransferFailed { + struct DRING_PUBLIC TransferFailed { constexpr static const char* name = "TransferFailed"; using cb_type = void(void); }; - struct TransferSucceeded { + struct DRING_PUBLIC TransferSucceeded { constexpr static const char* name = "TransferSucceeded"; using cb_type = void(void); }; - struct RecordPlaybackStopped { + struct DRING_PUBLIC RecordPlaybackStopped { constexpr static const char* name = "RecordPlaybackStopped"; using cb_type = void(const std::string&); }; - struct VoiceMailNotify { + struct DRING_PUBLIC VoiceMailNotify { constexpr static const char* name = "VoiceMailNotify"; using cb_type = void(const std::string&, int32_t); }; - struct IncomingMessage { + struct DRING_PUBLIC IncomingMessage { constexpr static const char* name = "IncomingMessage"; using cb_type = void(const std::string&, const std::string&, const std::map<std::string, std::string>&); }; - struct IncomingCall { + struct DRING_PUBLIC IncomingCall { constexpr static const char* name = "IncomingCall"; using cb_type = void(const std::string&, const std::string&, const std::string&); }; - struct RecordPlaybackFilepath { + struct DRING_PUBLIC RecordPlaybackFilepath { constexpr static const char* name = "RecordPlaybackFilepath"; using cb_type = void(const std::string&, const std::string&); }; - struct ConferenceCreated { + struct DRING_PUBLIC ConferenceCreated { constexpr static const char* name = "ConferenceCreated"; using cb_type = void(const std::string&); }; - struct ConferenceChanged { + struct DRING_PUBLIC ConferenceChanged { constexpr static const char* name = "ConferenceChanged"; using cb_type = void(const std::string&, const std::string&); }; - struct UpdatePlaybackScale { + struct DRING_PUBLIC UpdatePlaybackScale { constexpr static const char* name = "UpdatePlaybackScale"; using cb_type = void(const std::string&, unsigned, unsigned); }; - struct ConferenceRemoved { + struct DRING_PUBLIC ConferenceRemoved { constexpr static const char* name = "ConferenceRemoved"; using cb_type = void(const std::string&); }; - struct NewCallCreated { + struct DRING_PUBLIC NewCallCreated { constexpr static const char* name = "NewCallCreated"; using cb_type = void(const std::string&, const std::string&, const std::string&); }; - struct SipCallStateChanged { + struct DRING_PUBLIC SipCallStateChanged { constexpr static const char* name = "SipCallStateChanged"; using cb_type = void(const std::string&, const std::string&, int); }; - struct RecordingStateChanged { + struct DRING_PUBLIC RecordingStateChanged { constexpr static const char* name = "RecordingStateChanged"; using cb_type = void(const std::string&, int); }; - struct SecureSdesOn { + struct DRING_PUBLIC SecureSdesOn { constexpr static const char* name = "SecureSdesOn"; using cb_type = void(const std::string&); }; - struct SecureSdesOff { + struct DRING_PUBLIC SecureSdesOff { constexpr static const char* name = "SecureSdesOff"; using cb_type = void(const std::string&); }; - struct RtcpReportReceived { + struct DRING_PUBLIC RtcpReportReceived { constexpr static const char* name = "RtcpReportReceived"; using cb_type = void(const std::string&, const std::map<std::string, int>&); }; - struct PeerHold { + struct DRING_PUBLIC PeerHold { constexpr static const char* name = "PeerHold"; using cb_type = void(const std::string&, bool); }; - struct VideoMuted { + struct DRING_PUBLIC VideoMuted { constexpr static const char* name = "VideoMuted"; using cb_type = void(const std::string&, bool); }; - struct AudioMuted { + struct DRING_PUBLIC AudioMuted { constexpr static const char* name = "AudioMuted"; using cb_type = void(const std::string&, bool); }; - struct SmartInfo { + struct DRING_PUBLIC SmartInfo { constexpr static const char* name = "SmartInfo"; using cb_type = void(const std::map<std::string, std::string>&); }; diff --git a/src/dring/configurationmanager_interface.h b/src/dring/configurationmanager_interface.h index b6c2458432c2c8261357b700293cadc9b5a318a0..52206690a6f57b2f2470e61c99c4907d47a14458 100644 --- a/src/dring/configurationmanager_interface.h +++ b/src/dring/configurationmanager_interface.h @@ -25,6 +25,8 @@ #pragma once +#include "def.h" + #include <vector> #include <map> #include <memory> @@ -40,279 +42,279 @@ namespace DRing { -[[deprecated("Replaced by registerSignalHandlers")]] +[[deprecated("Replaced by registerSignalHandlers")]] DRING_PUBLIC void registerConfHandlers(const std::map<std::string, std::shared_ptr<CallbackWrapperBase>>&); -struct Message +struct DRING_PUBLIC Message { std::string from; std::map<std::string, std::string> payloads; uint64_t received; }; -std::map<std::string, std::string> getAccountDetails(const std::string& accountID); -std::map<std::string, std::string> getVolatileAccountDetails(const std::string& accountID); -void setAccountDetails(const std::string& accountID, const std::map<std::string, std::string>& details); -std::map<std::string, std::string> testAccountICEInitialization(const std::string& accountID); -void setAccountActive(const std::string& accountID, bool active); -std::map<std::string, std::string> getAccountTemplate(const std::string& accountType); -std::string addAccount(const std::map<std::string, std::string>& details); -bool exportOnRing(const std::string& accountID, const std::string& password); -bool exportToFile(const std::string& accountID, const std::string& destinationPath); -bool revokeDevice(const std::string& accountID, const std::string& password, const std::string& deviceID); -std::map<std::string, std::string> getKnownRingDevices(const std::string& accountID); -bool changeAccountPassword(const std::string& accountID, const std::string& password_old, const std::string& password_new); - -bool lookupName(const std::string& account, const std::string& nameserver, const std::string& name); -bool lookupAddress(const std::string& account, const std::string& nameserver, const std::string& address); -bool registerName(const std::string& account, const std::string& password, const std::string& name); - -void removeAccount(const std::string& accountID); -void setAccountEnabled(const std::string& accountID, bool enable); -std::vector<std::string> getAccountList(); -void sendRegister(const std::string& accountID, bool enable); -void registerAllAccounts(void); -uint64_t sendAccountTextMessage(const std::string& accountID, const std::string& to, const std::map<std::string, std::string>& payloads); -std::vector<Message> getLastMessages(const std::string& accountID, const uint64_t& base_timestamp); -int getMessageStatus(uint64_t id); - - -std::map<std::string, std::string> getTlsDefaultSettings(); - -std::vector<unsigned> getCodecList(); -std::vector<std::string> getSupportedTlsMethod(); -std::vector<std::string> getSupportedCiphers(const std::string& accountID); -std::map<std::string, std::string> getCodecDetails(const std::string& accountID, const unsigned& codecId); -bool setCodecDetails(const std::string& accountID, const unsigned& codecId, const std::map<std::string, std::string>& details); -std::vector<unsigned> getActiveCodecList(const std::string& accountID); - -void setActiveCodecList(const std::string& accountID, const std::vector<unsigned>& list); - -std::vector<std::string> getAudioPluginList(); -void setAudioPlugin(const std::string& audioPlugin); -std::vector<std::string> getAudioOutputDeviceList(); -void setAudioOutputDevice(int32_t index); -void setAudioInputDevice(int32_t index); -void setAudioRingtoneDevice(int32_t index); -std::vector<std::string> getAudioInputDeviceList(); -std::vector<std::string> getCurrentAudioDevicesIndex(); -int32_t getAudioInputDeviceIndex(const std::string& name); -int32_t getAudioOutputDeviceIndex(const std::string& name); -std::string getCurrentAudioOutputPlugin(); -bool getNoiseSuppressState(); -void setNoiseSuppressState(bool state); - -bool isAgcEnabled(); -void setAgcState(bool enabled); - -void muteDtmf(bool mute); -bool isDtmfMuted(); - -bool isCaptureMuted(); -void muteCapture(bool mute); -bool isPlaybackMuted(); -void mutePlayback(bool mute); -bool isRingtoneMuted(); -void muteRingtone(bool mute); - -std::string getAudioManager(); -bool setAudioManager(const std::string& api); - -std::string getRecordPath(); -void setRecordPath(const std::string& recPath); -bool getIsAlwaysRecording(); -void setIsAlwaysRecording(bool rec); - -void setHistoryLimit(int32_t days); -int32_t getHistoryLimit(); - -void setRingingTimeout(int32_t timeout); -int32_t getRingingTimeout(); - -void setAccountsOrder(const std::string& order); - -std::map<std::string, std::string> getHookSettings(); -void setHookSettings(const std::map<std::string, std::string>& settings); - -std::vector<std::map<std::string, std::string>> getCredentials(const std::string& accountID); -void setCredentials(const std::string& accountID, const std::vector<std::map<std::string, std::string>>& details); - -std::string getAddrFromInterfaceName(const std::string& iface); - -std::vector<std::string> getAllIpInterface(); -std::vector<std::string> getAllIpInterfaceByName(); - -std::map<std::string, std::string> getShortcuts(); -void setShortcuts(const std::map<std::string, std::string> &shortcutsMap); - -void setVolume(const std::string& device, double value); -double getVolume(const std::string& device); +DRING_PUBLIC std::map<std::string, std::string> getAccountDetails(const std::string& accountID); +DRING_PUBLIC std::map<std::string, std::string> getVolatileAccountDetails(const std::string& accountID); +DRING_PUBLIC void setAccountDetails(const std::string& accountID, const std::map<std::string, std::string>& details); +DRING_PUBLIC std::map<std::string, std::string> testAccountICEInitialization(const std::string& accountID); +DRING_PUBLIC void setAccountActive(const std::string& accountID, bool active); +DRING_PUBLIC std::map<std::string, std::string> getAccountTemplate(const std::string& accountType); +DRING_PUBLIC std::string addAccount(const std::map<std::string, std::string>& details); +DRING_PUBLIC bool exportOnRing(const std::string& accountID, const std::string& password); +DRING_PUBLIC bool exportToFile(const std::string& accountID, const std::string& destinationPath); +DRING_PUBLIC bool revokeDevice(const std::string& accountID, const std::string& password, const std::string& deviceID); +DRING_PUBLIC std::map<std::string, std::string> getKnownRingDevices(const std::string& accountID); +DRING_PUBLIC bool changeAccountPassword(const std::string& accountID, const std::string& password_old, const std::string& password_new); + +DRING_PUBLIC bool lookupName(const std::string& account, const std::string& nameserver, const std::string& name); +DRING_PUBLIC bool lookupAddress(const std::string& account, const std::string& nameserver, const std::string& address); +DRING_PUBLIC bool registerName(const std::string& account, const std::string& password, const std::string& name); + +DRING_PUBLIC void removeAccount(const std::string& accountID); +DRING_PUBLIC void setAccountEnabled(const std::string& accountID, bool enable); +DRING_PUBLIC std::vector<std::string> getAccountList(); +DRING_PUBLIC void sendRegister(const std::string& accountID, bool enable); +DRING_PUBLIC void registerAllAccounts(void); +DRING_PUBLIC uint64_t sendAccountTextMessage(const std::string& accountID, const std::string& to, const std::map<std::string, std::string>& payloads); +DRING_PUBLIC std::vector<Message> getLastMessages(const std::string& accountID, const uint64_t& base_timestamp); +DRING_PUBLIC int getMessageStatus(uint64_t id); + + +DRING_PUBLIC std::map<std::string, std::string> getTlsDefaultSettings(); + +DRING_PUBLIC std::vector<unsigned> getCodecList(); +DRING_PUBLIC std::vector<std::string> getSupportedTlsMethod(); +DRING_PUBLIC std::vector<std::string> getSupportedCiphers(const std::string& accountID); +DRING_PUBLIC std::map<std::string, std::string> getCodecDetails(const std::string& accountID, const unsigned& codecId); +DRING_PUBLIC bool setCodecDetails(const std::string& accountID, const unsigned& codecId, const std::map<std::string, std::string>& details); +DRING_PUBLIC std::vector<unsigned> getActiveCodecList(const std::string& accountID); + +DRING_PUBLIC void setActiveCodecList(const std::string& accountID, const std::vector<unsigned>& list); + +DRING_PUBLIC std::vector<std::string> getAudioPluginList(); +DRING_PUBLIC void setAudioPlugin(const std::string& audioPlugin); +DRING_PUBLIC std::vector<std::string> getAudioOutputDeviceList(); +DRING_PUBLIC void setAudioOutputDevice(int32_t index); +DRING_PUBLIC void setAudioInputDevice(int32_t index); +DRING_PUBLIC void setAudioRingtoneDevice(int32_t index); +DRING_PUBLIC std::vector<std::string> getAudioInputDeviceList(); +DRING_PUBLIC std::vector<std::string> getCurrentAudioDevicesIndex(); +DRING_PUBLIC int32_t getAudioInputDeviceIndex(const std::string& name); +DRING_PUBLIC int32_t getAudioOutputDeviceIndex(const std::string& name); +DRING_PUBLIC std::string getCurrentAudioOutputPlugin(); +DRING_PUBLIC bool getNoiseSuppressState(); +DRING_PUBLIC void setNoiseSuppressState(bool state); + +DRING_PUBLIC bool isAgcEnabled(); +DRING_PUBLIC void setAgcState(bool enabled); + +DRING_PUBLIC void muteDtmf(bool mute); +DRING_PUBLIC bool isDtmfMuted(); + +DRING_PUBLIC bool isCaptureMuted(); +DRING_PUBLIC void muteCapture(bool mute); +DRING_PUBLIC bool isPlaybackMuted(); +DRING_PUBLIC void mutePlayback(bool mute); +DRING_PUBLIC bool isRingtoneMuted(); +DRING_PUBLIC void muteRingtone(bool mute); + +DRING_PUBLIC std::string getAudioManager(); +DRING_PUBLIC bool setAudioManager(const std::string& api); + +DRING_PUBLIC std::string getRecordPath(); +DRING_PUBLIC void setRecordPath(const std::string& recPath); +DRING_PUBLIC bool getIsAlwaysRecording(); +DRING_PUBLIC void setIsAlwaysRecording(bool rec); + +DRING_PUBLIC void setHistoryLimit(int32_t days); +DRING_PUBLIC int32_t getHistoryLimit(); + +DRING_PUBLIC void setRingingTimeout(int32_t timeout); +DRING_PUBLIC int32_t getRingingTimeout(); + +DRING_PUBLIC void setAccountsOrder(const std::string& order); + +DRING_PUBLIC std::map<std::string, std::string> getHookSettings(); +DRING_PUBLIC void setHookSettings(const std::map<std::string, std::string>& settings); + +DRING_PUBLIC std::vector<std::map<std::string, std::string>> getCredentials(const std::string& accountID); +DRING_PUBLIC void setCredentials(const std::string& accountID, const std::vector<std::map<std::string, std::string>>& details); + +DRING_PUBLIC std::string getAddrFromInterfaceName(const std::string& iface); + +DRING_PUBLIC std::vector<std::string> getAllIpInterface(); +DRING_PUBLIC std::vector<std::string> getAllIpInterfaceByName(); + +DRING_PUBLIC std::map<std::string, std::string> getShortcuts(); +DRING_PUBLIC void setShortcuts(const std::map<std::string, std::string> &shortcutsMap); + +DRING_PUBLIC void setVolume(const std::string& device, double value); +DRING_PUBLIC double getVolume(const std::string& device); /* * Security */ -std::map<std::string, std::string> validateCertificate(const std::string& accountId, const std::string& certificate); -std::map<std::string, std::string> validateCertificatePath(const std::string& accountId, +DRING_PUBLIC std::map<std::string, std::string> validateCertificate(const std::string& accountId, const std::string& certificate); +DRING_PUBLIC std::map<std::string, std::string> validateCertificatePath(const std::string& accountId, const std::string& certificatePath, const std::string& privateKey, const std::string& privateKeyPassword, const std::string& caList); -std::map<std::string, std::string> getCertificateDetails(const std::string& certificate); -std::map<std::string, std::string> getCertificateDetailsPath(const std::string& certificatePath, const std::string& privateKey, const std::string& privateKeyPassword); +DRING_PUBLIC std::map<std::string, std::string> getCertificateDetails(const std::string& certificate); +DRING_PUBLIC std::map<std::string, std::string> getCertificateDetailsPath(const std::string& certificatePath, const std::string& privateKey, const std::string& privateKeyPassword); -std::vector<std::string> getPinnedCertificates(); +DRING_PUBLIC std::vector<std::string> getPinnedCertificates(); -std::vector<std::string> pinCertificate(const std::vector<uint8_t>& certificate, bool local); -bool unpinCertificate(const std::string& certId); +DRING_PUBLIC std::vector<std::string> pinCertificate(const std::vector<uint8_t>& certificate, bool local); +DRING_PUBLIC bool unpinCertificate(const std::string& certId); -void pinCertificatePath(const std::string& path); -unsigned unpinCertificatePath(const std::string& path); +DRING_PUBLIC void pinCertificatePath(const std::string& path); +DRING_PUBLIC unsigned unpinCertificatePath(const std::string& path); -bool pinRemoteCertificate(const std::string& accountId, const std::string& certId); -bool setCertificateStatus(const std::string& account, const std::string& certId, const std::string& status); -std::vector<std::string> getCertificatesByStatus(const std::string& account, const std::string& status); +DRING_PUBLIC bool pinRemoteCertificate(const std::string& accountId, const std::string& certId); +DRING_PUBLIC bool setCertificateStatus(const std::string& account, const std::string& certId, const std::string& status); +DRING_PUBLIC std::vector<std::string> getCertificatesByStatus(const std::string& account, const std::string& status); /* contact requests */ -std::vector<std::map<std::string, std::string>> getTrustRequests(const std::string& accountId); -bool acceptTrustRequest(const std::string& accountId, const std::string& from); -bool discardTrustRequest(const std::string& accountId, const std::string& from); -void sendTrustRequest(const std::string& accountId, const std::string& to, const std::vector<uint8_t>& payload = {}); +DRING_PUBLIC std::vector<std::map<std::string, std::string>> getTrustRequests(const std::string& accountId); +DRING_PUBLIC bool acceptTrustRequest(const std::string& accountId, const std::string& from); +DRING_PUBLIC bool discardTrustRequest(const std::string& accountId, const std::string& from); +DRING_PUBLIC void sendTrustRequest(const std::string& accountId, const std::string& to, const std::vector<uint8_t>& payload = {}); /* Contacts */ -void addContact(const std::string& accountId, const std::string& uri); -void removeContact(const std::string& accountId, const std::string& uri, bool ban); -std::map<std::string, std::string> getContactDetails(const std::string& accountId, const std::string& uri); -std::vector<std::map<std::string, std::string>> getContacts(const std::string& accountId); +DRING_PUBLIC void addContact(const std::string& accountId, const std::string& uri); +DRING_PUBLIC void removeContact(const std::string& accountId, const std::string& uri, bool ban); +DRING_PUBLIC std::map<std::string, std::string> getContactDetails(const std::string& accountId, const std::string& uri); +DRING_PUBLIC std::vector<std::map<std::string, std::string>> getContacts(const std::string& accountId); /* * Import/Export accounts */ -int exportAccounts(std::vector<std::string> accountIDs, std::string filepath, std::string password); -int importAccounts(std::string archivePath, std::string password); +DRING_PUBLIC int exportAccounts(std::vector<std::string> accountIDs, std::string filepath, std::string password); +DRING_PUBLIC int importAccounts(std::string archivePath, std::string password); /* * Network connectivity */ -void connectivityChanged(); +DRING_PUBLIC void connectivityChanged(); /* Dht proxy */ /** * Start or stop to use the proxy for account */ -void enableProxyClient(const std::string& accountID, bool enable); +DRING_PUBLIC void enableProxyClient(const std::string& accountID, bool enable); /** * Set the device push notification token (for all accounts). * If set, proxy clients will use push notifications. * Set to empty to disable push notifications. */ -void setPushNotificationToken(const std::string& pushDeviceToken); +DRING_PUBLIC void setPushNotificationToken(const std::string& pushDeviceToken); /** * To be called by clients with relevant data when a push notification is received. */ -void pushNotificationReceived(const std::string& from, const std::map<std::string, std::string>& data); +DRING_PUBLIC void pushNotificationReceived(const std::string& from, const std::map<std::string, std::string>& data); -struct AudioSignal { - struct DeviceEvent { +struct DRING_PUBLIC AudioSignal { + struct DRING_PUBLIC DeviceEvent { constexpr static const char* name = "audioDeviceEvent"; using cb_type = void(void); }; }; // Configuration signal type definitions -struct ConfigurationSignal { - struct VolumeChanged { +struct DRING_PUBLIC ConfigurationSignal { + struct DRING_PUBLIC VolumeChanged { constexpr static const char* name = "VolumeChanged"; using cb_type = void(const std::string& /*device*/, double /*value*/); }; - struct AccountsChanged { + struct DRING_PUBLIC AccountsChanged { constexpr static const char* name = "AccountsChanged"; using cb_type = void(void); }; - struct Error { + struct DRING_PUBLIC Error { constexpr static const char* name = "Error"; using cb_type = void(int /*alert*/); }; // TODO: move those to AccountSignal in next API breakage - struct AccountDetailsChanged { + struct DRING_PUBLIC AccountDetailsChanged { constexpr static const char* name = "AccountDetailsChanged"; using cb_type = void(const std::string& /*account_id*/, const std::map<std::string, std::string>& /* details */); }; - struct StunStatusFailed { + struct DRING_PUBLIC StunStatusFailed { constexpr static const char* name = "StunStatusFailed"; using cb_type = void(const std::string& /*account_id*/); }; - struct RegistrationStateChanged { + struct DRING_PUBLIC RegistrationStateChanged { constexpr static const char* name = "RegistrationStateChanged"; using cb_type = void(const std::string& /*account_id*/, const std::string& /*state*/, int /*detailsCode*/, const std::string& /*detailsStr*/); }; - struct VolatileDetailsChanged { + struct DRING_PUBLIC VolatileDetailsChanged { constexpr static const char* name = "VolatileDetailsChanged"; using cb_type = void(const std::string& /*account_id*/, const std::map<std::string, std::string>& /* details */); }; - struct IncomingAccountMessage { + struct DRING_PUBLIC IncomingAccountMessage { constexpr static const char* name = "IncomingAccountMessage"; using cb_type = void(const std::string& /*account_id*/, const std::string& /*from*/, const std::map<std::string, std::string>& /*payloads*/); }; - struct AccountMessageStatusChanged { + struct DRING_PUBLIC AccountMessageStatusChanged { constexpr static const char* name = "AccountMessageStatusChanged"; using cb_type = void(const std::string& /*account_id*/, uint64_t /*message_id*/, const std::string& /*to*/, int /*state*/); }; - struct IncomingTrustRequest { + struct DRING_PUBLIC IncomingTrustRequest { constexpr static const char* name = "IncomingTrustRequest"; using cb_type = void(const std::string& /*account_id*/, const std::string& /*from*/, const std::vector<uint8_t>& payload, time_t received); }; - struct ContactAdded { + struct DRING_PUBLIC ContactAdded { constexpr static const char* name = "ContactAdded"; using cb_type = void(const std::string& /*account_id*/, const std::string& /*uri*/, bool confirmed); }; - struct ContactRemoved { + struct DRING_PUBLIC ContactRemoved { constexpr static const char* name = "ContactRemoved"; using cb_type = void(const std::string& /*account_id*/, const std::string& /*uri*/, bool banned); }; - struct ExportOnRingEnded { + struct DRING_PUBLIC ExportOnRingEnded { constexpr static const char* name = "ExportOnRingEnded"; using cb_type = void(const std::string& /*account_id*/, int state, const std::string& pin); }; - struct NameRegistrationEnded { + struct DRING_PUBLIC NameRegistrationEnded { constexpr static const char* name = "NameRegistrationEnded"; using cb_type = void(const std::string& /*account_id*/, int state, const std::string& name); }; - struct KnownDevicesChanged { + struct DRING_PUBLIC KnownDevicesChanged { constexpr static const char* name = "KnownDevicesChanged"; using cb_type = void(const std::string& /*account_id*/, const std::map<std::string, std::string>& devices); }; - struct RegisteredNameFound { + struct DRING_PUBLIC RegisteredNameFound { constexpr static const char* name = "RegisteredNameFound"; using cb_type = void(const std::string& /*account_id*/, int state, const std::string& /*address*/, const std::string& /*name*/); }; - struct CertificatePinned { + struct DRING_PUBLIC CertificatePinned { constexpr static const char* name = "CertificatePinned"; using cb_type = void(const std::string& /*certId*/); }; - struct CertificatePathPinned { + struct DRING_PUBLIC CertificatePathPinned { constexpr static const char* name = "CertificatePathPinned"; using cb_type = void(const std::string& /*path*/, const std::vector<std::string>& /*certId*/); }; - struct CertificateExpired { + struct DRING_PUBLIC CertificateExpired { constexpr static const char* name = "CertificateExpired"; using cb_type = void(const std::string& /*certId*/); }; - struct CertificateStateChanged { + struct DRING_PUBLIC CertificateStateChanged { constexpr static const char* name = "CertificateStateChanged"; using cb_type = void(const std::string& /*account_id*/, const std::string& /*certId*/, const std::string& /*state*/); }; - struct MediaParametersChanged { + struct DRING_PUBLIC MediaParametersChanged { constexpr static const char* name = "MediaParametersChanged"; using cb_type = void(const std::string& /*accountId*/); }; - struct MigrationEnded { + struct DRING_PUBLIC MigrationEnded { constexpr static const char* name = "MigrationEnded"; using cb_type = void(const std::string& /*accountId*/, const std::string& /*state*/); }; - struct DeviceRevocationEnded { + struct DRING_PUBLIC DeviceRevocationEnded { constexpr static const char* name = "DeviceRevocationEnded"; using cb_type = void(const std::string& /*accountId*/, const std::string& /*device*/, int /*status*/); }; @@ -321,17 +323,17 @@ struct ConfigurationSignal { * information only accessible through their respective platform APIs */ #if defined(__ANDROID__) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS) - struct GetHardwareAudioFormat { + struct DRING_PUBLIC GetHardwareAudioFormat { constexpr static const char* name = "GetHardwareAudioFormat"; using cb_type = void(std::vector<int32_t>* /* params_ret */); }; #endif #if defined(__ANDROID__) || defined(RING_UWP) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS) - struct GetAppDataPath { + struct DRING_PUBLIC GetAppDataPath { constexpr static const char* name = "GetAppDataPath"; using cb_type = void(const std::string& name, std::vector<std::string>* /* path_ret */); }; - struct GetDeviceName { + struct DRING_PUBLIC GetDeviceName { constexpr static const char* name = "GetDeviceName"; using cb_type = void(std::vector<std::string>* /* path_ret */); }; @@ -339,8 +341,8 @@ struct ConfigurationSignal { }; // Can be used when a client's stdout is not available -struct DebugSignal { - struct MessageSend { +struct DRING_PUBLIC DebugSignal { + struct DRING_PUBLIC MessageSend { constexpr static const char* name = "MessageSend"; using cb_type = void(const std::string&); }; diff --git a/src/dring/datatransfer_interface.h b/src/dring/datatransfer_interface.h index b7ca5cbc326a0de9ed81edac4717c0faec5327c7..72985f3710ff4e947398992d93c61e340f1a7762 100644 --- a/src/dring/datatransfer_interface.h +++ b/src/dring/datatransfer_interface.h @@ -21,6 +21,8 @@ #ifndef DRING_DATATRANSFERI_H #define DRING_DATATRANSFERI_H +#include "def.h" + #include "dring.h" #include <string> @@ -31,12 +33,12 @@ namespace DRing { -[[deprecated("Replaced by registerSignalHandlers")]] +[[deprecated("Replaced by registerSignalHandlers")]] DRING_PUBLIC void registerDataXferHandlers(const std::map<std::string, std::shared_ptr<CallbackWrapperBase>>&); using DataTransferId = uint64_t; -enum class DataTransferEventCode : uint32_t +enum class DRING_PUBLIC DataTransferEventCode : uint32_t { invalid=0, created, @@ -52,7 +54,7 @@ enum class DataTransferEventCode : uint32_t timeout_expired, }; -enum class DataTransferError : uint32_t +enum class DRING_PUBLIC DataTransferError : uint32_t { success=0, unknown, @@ -61,12 +63,12 @@ enum class DataTransferError : uint32_t }; /// Bit definition for DataTransferInfo.flags field -enum class DataTransferFlags +enum class DRING_PUBLIC DataTransferFlags { direction=0, ///< 0: outgoing, 1: incoming }; -struct DataTransferInfo +struct DRING_PUBLIC DataTransferInfo { std::string accountId; ///< Identifier of the emiter/receiver account DataTransferEventCode lastEvent { DataTransferEventCode::invalid }; ///< Latest event code sent to the user @@ -79,7 +81,7 @@ struct DataTransferInfo std::string mimetype; ///< MimeType of transferred data (https://www.iana.org/assignments/media-types/media-types.xhtml) }; -std::vector<DataTransferId> dataTransferList() noexcept; +DRING_PUBLIC std::vector<DataTransferId> dataTransferList() noexcept; /// Asynchronously send a file to a peer using given account connection. /// @@ -105,7 +107,7 @@ std::vector<DataTransferId> dataTransferList() noexcept; /// the processing is asynchronous. Application will be signaled throught DataTransferEvent signal /// for such event. There is no reserved or special values on DataTransferId type. /// -DataTransferError sendFile(const DataTransferInfo& info, DataTransferId& id) noexcept; +DRING_PUBLIC DataTransferError sendFile(const DataTransferInfo& info, DataTransferId& id) noexcept; /// Accept an incoming file transfer. /// @@ -122,7 +124,7 @@ DataTransferError sendFile(const DataTransferInfo& info, DataTransferId& id) noe /// \return DataTransferError::invalid_argument if id is unknown. /// \note unknown \a id results to a no-op call. /// -DataTransferError acceptFileTransfer(const DataTransferId& id, const std::string& file_path, +DRING_PUBLIC DataTransferError acceptFileTransfer(const DataTransferId& id, const std::string& file_path, int64_t offset) noexcept; /// Refuse or abort an outgoing or an incoming file transfer. @@ -137,7 +139,7 @@ DataTransferError acceptFileTransfer(const DataTransferId& id, const std::string /// \return DataTransferError::invalid_argument if id is unknown. /// \note unknown \a id results to a no-op call. /// -DataTransferError cancelDataTransfer(const DataTransferId& id) noexcept; +DataTransferError cancelDataTransfer(const DataTransferId& id) noexcept DRING_PUBLIC; /// Return some information on given data transfer. /// @@ -147,7 +149,7 @@ DataTransferError cancelDataTransfer(const DataTransferId& id) noexcept; /// \return DataTransferError::invalid_argument if id is unknown. /// \note \a info structure is in undefined state in case of error. /// -DataTransferError dataTransferInfo(const DataTransferId& id, DataTransferInfo& info) noexcept; +DRING_PUBLIC DataTransferError dataTransferInfo(const DataTransferId& id, DataTransferInfo& info) noexcept; /// Return the amount of sent/received bytes of an existing data transfer. /// @@ -158,13 +160,13 @@ DataTransferError dataTransferInfo(const DataTransferId& id, DataTransferInfo& i /// \return DataTransferError::success if \a total and \a progress is set with valid values. /// DataTransferError::invalid_argument if the id is unknown. /// -DataTransferError dataTransferBytesProgress(const DataTransferId& id, int64_t& total, +DRING_PUBLIC DataTransferError dataTransferBytesProgress(const DataTransferId& id, int64_t& total, int64_t& progress) noexcept; // Signals -struct DataTransferSignal +struct DRING_PUBLIC DataTransferSignal { - struct DataTransferEvent + struct DRING_PUBLIC DataTransferEvent { constexpr static const char* name = "DataTransferEvent"; using cb_type = void(const DataTransferId& transferId, int eventCode); diff --git a/src/dring/def.h b/src/dring/def.h new file mode 100644 index 0000000000000000000000000000000000000000..827dd54b47b4bcb9706b71d71e9d5636526b6ae7 --- /dev/null +++ b/src/dring/def.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2018 Savoir-faire Linux Inc. + * + * Author: Adrien Béraud <adrien.beraud@savoirfairelinux.com> + * Author: Philippe Gorley <philippe.gorley@savoirfairelinux.com> + * + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#pragma once + +// Generic helper definitions for shared library support +#if defined _WIN32 || defined __CYGWIN__ + #define DRING_IMPORT __declspec(dllimport) + #define DRING_EXPORT __declspec(dllexport) + #define DRING_HIDDEN +#else + #define DRING_IMPORT __attribute__ ((visibility ("default"))) + #define DRING_EXPORT __attribute__ ((visibility ("default"))) + #define DRING_HIDDEN __attribute__ ((visibility ("hidden"))) +#endif + +// Now we use the generic helper definitions above to define DRING_PUBLIC and DRING_LOCAL. +// DRING_PUBLIC is used for the public API symbols. It is either DLL imports or DLL exports (or does nothing for static build) +// DRING_LOCAL is used for non-api symbols. + +#ifdef dring_EXPORTS // defined if DRing is compiled as a shared library + #ifdef DRING_BUILD // defined if we are building the DRing shared library (instead of using it) + #define DRING_PUBLIC DRING_EXPORT + #else + #define DRING_PUBLIC DRING_IMPORT + #endif // DRING_BUILD + #define DRING_LOCAL DRING_HIDDEN +#else // dring_EXPORTS is not defined: this means DRing is a static lib. + #define DRING_PUBLIC + #define DRING_LOCAL +#endif // dring_EXPORTS diff --git a/src/dring/dring.h b/src/dring/dring.h index 4c9d12a67bf8860298f4f73462198d6f760e3aae..e7c08ac314d84aea06787ba30c24719783635889 100644 --- a/src/dring/dring.h +++ b/src/dring/dring.h @@ -21,6 +21,8 @@ #ifndef DRING_H #define DRING_H +#include "def.h" + #include <vector> #include <functional> #include <string> @@ -40,7 +42,7 @@ enum InitFlag { /** * Return the library version as string. */ -const char* version() noexcept; +DRING_PUBLIC const char* version() noexcept; /** * Initialize globals, create underlaying daemon. @@ -48,18 +50,18 @@ const char* version() noexcept; * @param flags Flags to customize this initialization * @returns true if initialization succeed else false. */ -bool init(enum InitFlag flags) noexcept; +DRING_PUBLIC bool init(enum InitFlag flags) noexcept; /** * Start asynchronously daemon created by init(). * @returns true if daemon started successfully */ -bool start(const std::string& config_file={}) noexcept; +DRING_PUBLIC bool start(const std::string& config_file={}) noexcept; /** * Stop and freeing any resource allocated by daemon */ -void fini() noexcept; +DRING_PUBLIC void fini() noexcept; /* External Callback Dynamic Utilities * @@ -82,7 +84,7 @@ void fini() noexcept; * Used conjointly with std::shared_ptr to hide the concrete class. * See CallbackWrapper template for details. */ -class CallbackWrapperBase {}; +class DRING_PUBLIC CallbackWrapperBase {}; /* Concrete class of CallbackWrapperBase. * This class wraps callbacks of a specific signature. @@ -142,7 +144,7 @@ exportable_callback(std::function<typename Ts::cb_type>&& func) { (std::forward<std::function<typename Ts::cb_type>>(func))); } -void registerSignalHandlers(const std::map<std::string, std::shared_ptr<CallbackWrapperBase>>&); +DRING_PUBLIC void registerSignalHandlers(const std::map<std::string, std::shared_ptr<CallbackWrapperBase>>&); } // namespace DRing diff --git a/src/dring/media_const.h b/src/dring/media_const.h index bb9c1009167b8e7ea787166c49fd3e237b2c06f2..8e542a83f30f7eb814ef59825a7c7d3aa3e28fc4 100644 --- a/src/dring/media_const.h +++ b/src/dring/media_const.h @@ -20,6 +20,8 @@ #ifndef DRING_MEDIA_H #define DRING_MEDIA_H +#include "def.h" + namespace DRing { namespace Media { diff --git a/src/dring/presence_const.h b/src/dring/presence_const.h index ba1724dd362d40dbe64042ff7f5e505aadb4fdb2..37eee2fc4b303545f0685d1214e7718412f348d2 100644 --- a/src/dring/presence_const.h +++ b/src/dring/presence_const.h @@ -20,6 +20,8 @@ #ifndef DRING_PRESENCE_CONST_H #define DRING_PRESENCE_CONST_H +#include "def.h" + namespace DRing { namespace Presence { diff --git a/src/dring/presencemanager_interface.h b/src/dring/presencemanager_interface.h index ce403fba88a869c3ca315e13c89b0c2f316dbf32..c5ff7df5be35837a2e83ae4d557efde3b59b5182 100644 --- a/src/dring/presencemanager_interface.h +++ b/src/dring/presencemanager_interface.h @@ -21,6 +21,8 @@ #ifndef DRING_PRESENCEMANAGERI_H #define DRING_PRESENCEMANAGERI_H +#include "def.h" + #include <vector> #include <map> #include <string> @@ -31,31 +33,31 @@ namespace DRing { -[[deprecated("Replaced by registerSignalHandlers")]] +[[deprecated("Replaced by registerSignalHandlers")]] DRING_PUBLIC void registerPresHandlers(const std::map<std::string, std::shared_ptr<CallbackWrapperBase>>&); /* Presence subscription/Notification. */ -void publish(const std::string& accountID, bool status, const std::string& note); -void answerServerRequest(const std::string& uri, bool flag); -void subscribeBuddy(const std::string& accountID, const std::string& uri, bool flag); -std::vector<std::map<std::string, std::string>> getSubscriptions(const std::string& accountID); -void setSubscriptions(const std::string& accountID, const std::vector<std::string>& uris); +DRING_PUBLIC void publish(const std::string& accountID, bool status, const std::string& note); +DRING_PUBLIC void answerServerRequest(const std::string& uri, bool flag); +DRING_PUBLIC void subscribeBuddy(const std::string& accountID, const std::string& uri, bool flag); +DRING_PUBLIC std::vector<std::map<std::string, std::string>> getSubscriptions(const std::string& accountID); +DRING_PUBLIC void setSubscriptions(const std::string& accountID, const std::vector<std::string>& uris); // Presence signal type definitions -struct PresenceSignal { - struct NewServerSubscriptionRequest { +struct DRING_PUBLIC PresenceSignal { + struct DRING_PUBLIC NewServerSubscriptionRequest { constexpr static const char* name = "NewServerSubscriptionRequest"; using cb_type = void(const std::string& /*remote*/); }; - struct ServerError { + struct DRING_PUBLIC ServerError { constexpr static const char* name = "ServerError"; using cb_type = void(const std::string& /*account_id*/, const std::string& /*error*/, const std::string& /*msg*/); }; - struct NewBuddyNotification { + struct DRING_PUBLIC NewBuddyNotification { constexpr static const char* name = "NewBuddyNotification"; using cb_type = void(const std::string& /*account_id*/, const std::string& /*buddy_uri*/, int /*status*/, const std::string& /*line_status*/); }; - struct SubscriptionStateChanged { + struct DRING_PUBLIC SubscriptionStateChanged { constexpr static const char* name = "SubscriptionStateChanged"; using cb_type = void(const std::string& /*account_id*/, const std::string& /*buddy_uri*/, int /*state*/); }; diff --git a/src/dring/security_const.h b/src/dring/security_const.h index 03572477ed1dab4bea3f53522144cdf95c92e661..dade8efc780c82c3fc6623e7b9634a6a046b565d 100644 --- a/src/dring/security_const.h +++ b/src/dring/security_const.h @@ -20,6 +20,8 @@ #ifndef DRING_SECURITY_H #define DRING_SECURITY_H +#include "def.h" + namespace DRing { namespace Certificate { diff --git a/src/dring/videomanager_interface.h b/src/dring/videomanager_interface.h index 6212f40620a8ee3d5343043fc63216918429d897..95160e4a79c527d65ac6c63eb9c90c5845b2162c 100644 --- a/src/dring/videomanager_interface.h +++ b/src/dring/videomanager_interface.h @@ -28,6 +28,8 @@ struct AVFrame; struct AVPacket; } +#include "def.h" + #include <memory> #include <vector> #include <map> @@ -43,11 +45,11 @@ struct AVPacket; namespace DRing { -[[deprecated("Replaced by registerSignalHandlers")]] +[[deprecated("Replaced by registerSignalHandlers")]] DRING_PUBLIC void registerVideoHandlers(const std::map<std::string, std::shared_ptr<CallbackWrapperBase>>&); /* FrameBuffer is a generic video frame container */ -struct FrameBuffer { +struct DRING_PUBLIC FrameBuffer { uint8_t* ptr {nullptr}; // data as a plain raw pointer std::size_t ptrSize {0}; // size in byte of ptr array int format {0}; // as listed by AVPixelFormat (avutils/pixfmt.h) @@ -56,7 +58,7 @@ struct FrameBuffer { std::vector<uint8_t> storage; }; -struct SinkTarget { +struct DRING_PUBLIC SinkTarget { using FrameBufferPtr = std::unique_ptr<FrameBuffer>; std::function<FrameBufferPtr(std::size_t bytes)> pull; std::function<void(FrameBufferPtr)> push; @@ -125,76 +127,76 @@ private: using VideoCapabilities = std::map<std::string, std::map<std::string, std::vector<std::string>>>; -std::vector<std::string> getDeviceList(); -VideoCapabilities getCapabilities(const std::string& name); -std::map<std::string, std::string> getSettings(const std::string& name); -void applySettings(const std::string& name, const std::map<std::string, std::string>& settings); -void setDefaultDevice(const std::string& name); +DRING_PUBLIC std::vector<std::string> getDeviceList(); +DRING_PUBLIC VideoCapabilities getCapabilities(const std::string& name); +DRING_PUBLIC std::map<std::string, std::string> getSettings(const std::string& name); +DRING_PUBLIC void applySettings(const std::string& name, const std::map<std::string, std::string>& settings); +DRING_PUBLIC void setDefaultDevice(const std::string& name); -std::map<std::string, std::string> getDeviceParams(const std::string& name); +DRING_PUBLIC std::map<std::string, std::string> getDeviceParams(const std::string& name); -std::string getDefaultDevice(); -std::string getCurrentCodecName(const std::string& callID); -void startCamera(); -void stopCamera(); -bool hasCameraStarted(); -bool switchInput(const std::string& resource); -bool switchToCamera(); -void registerSinkTarget(const std::string& sinkId, const SinkTarget& target); +DRING_PUBLIC std::string getDefaultDevice(); +DRING_PUBLIC std::string getCurrentCodecName(const std::string& callID); +DRING_PUBLIC void startCamera(); +DRING_PUBLIC void stopCamera(); +DRING_PUBLIC bool hasCameraStarted(); +DRING_PUBLIC bool switchInput(const std::string& resource); +DRING_PUBLIC bool switchToCamera(); +DRING_PUBLIC void registerSinkTarget(const std::string& sinkId, const SinkTarget& target); -std::string startLocalRecorder(const bool& audioOnly, const std::string& filepath); -void stopLocalRecorder(const std::string& filepath); +DRING_PUBLIC std::string startLocalRecorder(const bool& audioOnly, const std::string& filepath); +DRING_PUBLIC void stopLocalRecorder(const std::string& filepath); #if defined(__ANDROID__) || defined(RING_UWP) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS) -void addVideoDevice(const std::string &node, const std::vector<std::map<std::string, std::string>>* devInfo=nullptr); -void removeVideoDevice(const std::string &node); -void* obtainFrame(int length); -void releaseFrame(void* frame); +DRING_PUBLIC void addVideoDevice(const std::string &node, const std::vector<std::map<std::string, std::string>>* devInfo=nullptr); +DRING_PUBLIC void removeVideoDevice(const std::string &node); +DRING_PUBLIC void* obtainFrame(int length); +DRING_PUBLIC void releaseFrame(void* frame); -VideoFrame* getNewFrame(); -void publishFrame(); +DRING_PUBLIC VideoFrame* getNewFrame(); +DRING_PUBLIC void publishFrame(); #endif -bool getDecodingAccelerated(); -void setDecodingAccelerated(bool state); +DRING_PUBLIC bool getDecodingAccelerated(); +DRING_PUBLIC void setDecodingAccelerated(bool state); // Video signal type definitions -struct VideoSignal { - struct DeviceEvent { +struct DRING_PUBLIC VideoSignal { + struct DRING_PUBLIC DeviceEvent { constexpr static const char* name = "DeviceEvent"; using cb_type = void(void); }; - struct DecodingStarted { + struct DRING_PUBLIC DecodingStarted { constexpr static const char* name = "DecodingStarted"; using cb_type = void(const std::string& /*id*/, const std::string& /*shm_path*/, int /*w*/, int /*h*/, bool /*is_mixer*/id); }; - struct DecodingStopped { + struct DRING_PUBLIC DecodingStopped { constexpr static const char* name = "DecodingStopped"; using cb_type = void(const std::string& /*id*/, const std::string& /*shm_path*/, bool /*is_mixer*/); }; #if __ANDROID__ - struct SetParameters { + struct DRING_PUBLIC SetParameters { constexpr static const char* name = "SetParameters"; using cb_type = void(const std::string& device, const int format, const int width, const int height, const int rate); }; - struct GetCameraInfo { + struct DRING_PUBLIC GetCameraInfo { constexpr static const char* name = "GetCameraInfo"; using cb_type = void(const std::string& device, std::vector<int> *formats, std::vector<unsigned> *sizes, std::vector<unsigned> *rates); }; #endif - struct StartCapture { + struct DRING_PUBLIC StartCapture { constexpr static const char* name = "StartCapture"; using cb_type = void(const std::string& /*device*/); }; - struct StopCapture { + struct DRING_PUBLIC StopCapture { constexpr static const char* name = "StopCapture"; using cb_type = void(void); }; - struct DeviceAdded { + struct DRING_PUBLIC DeviceAdded { constexpr static const char* name = "DeviceAdded"; using cb_type = void(const std::string& /*device*/); }; - struct ParametersChanged { + struct DRING_PUBLIC ParametersChanged { constexpr static const char* name = "ParametersChanged"; using cb_type = void(const std::string& /*device*/); }; diff --git a/src/fileutils.h b/src/fileutils.h index 45c8fe5c5d8d1d95e30d3da0317b27750446abbc..f1e1550017160c00bc85fc0d2366ae6abf92c4f7 100644 --- a/src/fileutils.h +++ b/src/fileutils.h @@ -27,6 +27,8 @@ #include <mutex> #include <cstdio> +#include "dring/def.h" + #ifndef _MSC_VER #define PROTECTED_GETENV(str) ({char *envvar_ = getenv((str)); \ envvar_ ? envvar_ : "";}) @@ -65,7 +67,7 @@ namespace ring { namespace fileutils { * @param parents default mode for all created directories except the last */ bool check_dir(const char *path, mode_t dir=0755, mode_t parents=0755); - void set_program_dir(char *program_path); + DRING_PUBLIC void set_program_dir(char *program_path); // public because bin/main.cpp uses it std::string expand_path(const std::string &path); bool isDirectoryWritable(const std::string &directory);