/* * Copyright (C) 2004-2016 Savoir-faire Linux Inc. * * Author: Pierre-Luc Beaudoin * Author: Alexandre Bourget * Author: Emmanuel Milou * Author: Guillaume Carmel-Archambault * Author: Guillaume Roguez * Author: Adrien Béraud * * 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 #include #include #include #include #include #include "dring.h" #include "security_const.h" namespace DRing { void registerConfHandlers(const std::map>&); std::map getAccountDetails(const std::string& accountID); std::map getVolatileAccountDetails(const std::string& accountID); void setAccountDetails(const std::string& accountID, const std::map& details); std::map testAccountICEInitialization(const std::string& accountID); void setAccountActive(const std::string& accountID, bool active); std::map getAccountTemplate(const std::string& accountType); std::string addAccount(const std::map& details); bool exportOnRing(const std::string& accountID, const std::string& password); std::map getKnownRingDevices(const std::string& accountID); 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 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& payloads); int getMessageStatus(uint64_t id); std::map getTlsDefaultSettings(); std::vector getCodecList(); std::vector getSupportedTlsMethod(); std::vector getSupportedCiphers(const std::string& accountID); std::map getCodecDetails(const std::string& accountID, const unsigned& codecId); bool setCodecDetails(const std::string& accountID, const unsigned& codecId, const std::map& details); std::vector getActiveCodecList(const std::string& accountID); void setActiveCodecList(const std::string& accountID, const std::vector& list); std::vector getAudioPluginList(); void setAudioPlugin(const std::string& audioPlugin); std::vector getAudioOutputDeviceList(); void setAudioOutputDevice(int32_t index); void setAudioInputDevice(int32_t index); void setAudioRingtoneDevice(int32_t index); std::vector getAudioInputDeviceList(); std::vector 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 setAccountsOrder(const std::string& order); std::map getHookSettings(); void setHookSettings(const std::map& settings); std::vector> getCredentials(const std::string& accountID); void setCredentials(const std::string& accountID, const std::vector>& details); std::string getAddrFromInterfaceName(const std::string& iface); std::vector getAllIpInterface(); std::vector getAllIpInterfaceByName(); std::map getShortcuts(); void setShortcuts(const std::map &shortcutsMap); void setVolume(const std::string& device, double value); double getVolume(const std::string& device); /* * Security */ std::map validateCertificate(const std::string& accountId, const std::string& certificate); std::map validateCertificatePath(const std::string& accountId, const std::string& certificatePath, const std::string& privateKey, const std::string& privateKeyPassword, const std::string& caList); std::map getCertificateDetails(const std::string& certificate); std::map getCertificateDetailsPath(const std::string& certificatePath, const std::string& privateKey, const std::string& privateKeyPassword); std::vector getPinnedCertificates(); std::vector pinCertificate(const std::vector& certificate, bool local); bool unpinCertificate(const std::string& certId); void pinCertificatePath(const std::string& path); 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 getCertificatesByStatus(const std::string& account, const std::string& status); /* contact requests */ std::map 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& payload = {}); /* * Import/Export accounts */ int exportAccounts(std::vector accountIDs, std::string filepath, std::string password); int importAccounts(std::string archivePath, std::string password); /* * Network connectivity */ void connectivityChanged(); struct AudioSignal { struct DeviceEvent { constexpr static const char* name = "audioDeviceEvent"; using cb_type = void(void); }; }; // Configuration signal type definitions struct ConfigurationSignal { struct VolumeChanged { constexpr static const char* name = "VolumeChanged"; using cb_type = void(const std::string& /*device*/, double /*value*/); }; struct AccountsChanged { constexpr static const char* name = "AccountsChanged"; using cb_type = void(void); }; struct Error { constexpr static const char* name = "Error"; using cb_type = void(int /*alert*/); }; // TODO: move those to AccountSignal in next API breakage struct StunStatusFailed { constexpr static const char* name = "StunStatusFailed"; using cb_type = void(const std::string& /*account_id*/); }; struct 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 { constexpr static const char* name = "VolatileDetailsChanged"; using cb_type = void(const std::string& /*account_id*/, const std::map& /* details */); }; struct IncomingAccountMessage { constexpr static const char* name = "IncomingAccountMessage"; using cb_type = void(const std::string& /*account_id*/, const std::string& /*from*/, const std::map& /*payloads*/); }; struct 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 { constexpr static const char* name = "IncomingTrustRequest"; using cb_type = void(const std::string& /*account_id*/, const std::string& /*from*/, const std::vector& payload, time_t received); }; struct ExportOnRingEnded { constexpr static const char* name = "ExportOnRingEnded"; using cb_type = void(const std::string& /*account_id*/, int state, const std::string& pin); }; struct NameRegistrationEnded { constexpr static const char* name = "NameRegistrationEnded"; using cb_type = void(const std::string& /*account_id*/, int state, const std::string& name); }; struct KnownDevicesChanged { constexpr static const char* name = "KnownDevicesChanged"; using cb_type = void(const std::string& /*account_id*/, const std::map& devices); }; struct 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 { constexpr static const char* name = "CertificatePinned"; using cb_type = void(const std::string& /*certId*/); }; struct CertificatePathPinned { constexpr static const char* name = "CertificatePathPinned"; using cb_type = void(const std::string& /*path*/, const std::vector& /*certId*/); }; struct CertificateExpired { constexpr static const char* name = "CertificateExpired"; using cb_type = void(const std::string& /*certId*/); }; struct 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 { constexpr static const char* name = "MediaParametersChanged"; using cb_type = void(const std::string& /*accountId*/); }; #ifdef __ANDROID__ /** * These are special getters for Android so the daemon can retreive * some informations only accessible through Java APIs */ struct GetHardwareAudioFormat { constexpr static const char* name = "GetHardwareAudioFormat"; using cb_type = void(std::vector* /* params_ret */); }; struct GetAppDataPath { constexpr static const char* name = "GetAppDataPath"; using cb_type = void(const std::string& name, std::vector* /* path_ret */); }; #endif }; // Can be used when a client's stdout is not available struct DebugSignal { struct MessageSend { constexpr static const char* name = "MessageSend"; using cb_type = void(const std::string&); }; }; } // namespace DRing