36#include <dhtnet/ip_utils.h>
37#include <dhtnet/upnp/upnp_control.h>
63constexpr static const char RINGDIR[] =
"ringtones";
72 :
std::runtime_error(
"VoipLinkException occurred: " +
str)
83class Account :
public std::enable_shared_from_this<Account>
99 virtual std::unique_ptr<AccountConfig>
buildConfig()
const = 0;
118 throw std::runtime_error(
"Account doesn't have a configuration");
163 virtual bool isIP2IP()
const {
return false; }
187 const std::vector<libjami::MediaMap>&
mediaList)
196 const std::map<std::string, std::string>& ,
356 virtual bool handleMessage(
const std::shared_ptr<dht::crypto::Certificate>& ,
358 const std::pair<std::string, std::string>& )
415 std::shared_ptr<Call>
getCall(
const std::string& callId)
const
417 return callSet_.
getCall(callId);
425 void attach(
const std::shared_ptr<Call>& call) { callSet_.
add(call); }
426 bool detach(
const std::shared_ptr<Call>& call) {
return callSet_.
remove(call); }
529static inline std::ostream&
virtual std::string getFromUri() const =0
virtual ~Account()
Virtual destructor.
std::string getDisplayName() const
bool isEnabled() const
Tell if the account is enable or not.
RegistrationState getRegistrationState() const
bool iceCompIdRfc5245Compliant_
void enableIceCompIdRfc5245Compliance(bool enable)
virtual bool setPushNotificationConfig(const std::map< std::string, std::string > &data)
bool hasActiveCodec(MediaType mediaType) const
virtual void flush()
This method is called to request removal of possible account traces on the system,...
bool removeConference(const std::string &confId)
friend class ConfigurationTest
virtual void doRegister()=0
Register the account.
virtual void setIsComposing(const std::string &, bool)
virtual void updateUpnpController()
void loadDefaultCodecs()
Helper function used to load the default codec order from the codec factory.
std::shared_ptr< SystemCodecInfo > searchCodecById(unsigned codecId, MediaType mediaType)
void enableIceForMedia(bool enable)
static std::vector< unsigned > getDefaultCodecsId()
std::vector< std::shared_ptr< SystemCodecInfo > > accountCodecInfoList_
Vector containing all account codecs (set of system codecs with custom parameters)
const std::string & getAccountID() const
Get the account ID.
virtual std::string_view getAccountType() const =0
void setCodecInactive(unsigned codecId)
void attach(const std::shared_ptr< Conference > &conf)
virtual void setRegistrationState(RegistrationState state, int detail_code=0, const std::string &detail_str={})
Set the registration state of the specified link.
bool isReadReceiptEnabled() const
std::vector< unsigned > getActiveCodecs(MediaType mediaType=MEDIA_ALL) const
virtual void updateProfile(const std::string &, const std::string &, const std::string &, int32_t)=0
void setEnabled(bool enable)
std::vector< std::string > getConferenceList() const
static std::string getDefaultUserAgent()
Build the user-agent string.
virtual void setActiveCodecs(const std::vector< unsigned > &list)
Update both the codec order structure and the codec string used for SDP offer and configuration respe...
const std::string accountID_
Account ID are assign in constructor and shall not changed.
virtual void connectivityChanged()
Inform the account that the network status has changed.
static bool meetMinimumRequiredVersion(const std::vector< unsigned > &jamiVersion, const std::vector< unsigned > &minRequiredVersion)
std::shared_ptr< SystemCodecInfo > searchCodecByName(const std::string &name, MediaType mediaType)
private account codec searching functions
bool isRendezVous() const
RegistrationState registrationState_
std::mt19937_64 rand
Random generator engine Logical account state shall never rely on the state of the random generator.
void setActive(bool active) noexcept
virtual bool cancelMessage(uint64_t)
virtual std::map< std::string, std::string > getNearbyPeers() const
virtual void doUnregister(bool forceShutdownConnections=false)=0
Unregister the account.
bool isAllModerators() const
void enableVideo(bool enable)
const std::string & getUsername() const
std::map< std::string, std::string > getAccountDetails() const
bool isIceCompIdRfc5245Compliant() const
std::filesystem::path idPath_
path to account
bool detach(const std::shared_ptr< Call > &call)
bool isEmptyOffersEnabled() const
std::shared_ptr< SystemCodecContainer > systemCodecContainer_
Vector containing all system codecs (with default parameters)
std::filesystem::path getRingtonePath() const
std::shared_ptr< Call > getCall(const std::string &callId) const
bool isComposingEnabled() const
void addDefaultModerator(const std::string &peerURI)
bool isActive() const noexcept
Tell if the account is activated (can currently be used).
static std::string mapStateNumberToString(RegistrationState state)
virtual std::map< std::string, std::string > getVolatileAccountDetails() const
std::vector< std::shared_ptr< SystemCodecInfo > > getActiveAccountCodecInfoList(MediaType mediaType) const
std::shared_ptr< Conference > getConference(const std::string &confId) const
std::vector< unsigned > getAccountCodecInfoIdList(MediaType mediaType) const
std::mutex upnp_mtx
UPnP IGD controller and the mutex to access it.
void removeDefaultModerator(const std::string &peerURI)
virtual im::MessageStatus getMessageStatus(uint64_t) const
Return the status corresponding to the token.
virtual std::vector< libjami::Message > getLastMessages(const uint64_t &)
static const std::string DEFAULT_USER_AGENT
std::map< std::string, std::string > getProfileVcard() const
std::unique_ptr< AccountConfig > config_
bool isIceForMediaEnabled() const
dhtnet::IpAddr getUPnPIpAddress() const
Get the UPnP IP (external router) address.
std::recursive_mutex configurationMutex_
std::string getMailBox() const
virtual std::unique_ptr< AccountConfig > buildConfig() const =0
const std::filesystem::path & getPath() const
virtual bool isIP2IP() const
Returns true if this is the IP2IP account.
bool autoLoadConversations_
Auto load conversations when creatinf convModule()
std::set< std::string > getDefaultModerators() const
bool isLocalModeratorsEnabled() const
bool getRingtoneEnabled() const
virtual bool handleMessage(const std::shared_ptr< dht::crypto::Certificate > &, const std::string &, const std::pair< std::string, std::string > &)
const std::string & getUserAgentName()
Get the user-agent.
virtual bool setMessageDisplayed(const std::string &, const std::string &, int)
void editConfig(std::function< void(AccountConfig &config)> &&edit)
virtual bool setPushNotificationTopic(const std::string &topic="")
bool isAutoAnswerEnabled() const
void setConfig(std::unique_ptr< AccountConfig > &&config)
const std::string & getAlias() const
void setCodecActive(unsigned codecId)
void enableAutoLoadConversations(bool enable)
void hangupCalls()
Free all ressources related to this account.
bool getUPnPActive() const
returns whether or not UPnP is enabled and active ie: if it is able to make port mappings
const AccountConfig & config() const
std::shared_ptr< SystemCodecInfo > searchCodecByPayload(unsigned payload, MediaType mediaType)
std::vector< std::string > getCallList() const
virtual std::shared_ptr< Call > newOutgoingCall(std::string_view toUrl, const std::vector< libjami::MediaMap > &mediaList)=0
Create a new outgoing call.
bool active_
Tells if the account is active now.
bool isVideoEnabled() const
virtual uint64_t sendTextMessage(const std::string &, const std::string &, const std::map< std::string, std::string > &, uint64_t=0, bool=false)
If supported, send a text message from this account.
std::filesystem::path ringtonePath_
Ringtone .au file used for this account.
void attach(const std::shared_ptr< Call > &call)
static std::map< std::string, std::string > getDefaultCodecDetails(const unsigned &codecId)
void setAllCodecsActive(MediaType mediaType, bool active)
virtual void saveConfig() const
virtual bool setPushNotificationToken(const std::string &pushDeviceToken="")
bool isDenySecondCallEnabled() const
const std::string & getHostname() const
virtual void loadConfig()
Load the settings in this account.
std::shared_ptr< dhtnet::upnp::Controller > upnpCtrl_
void setAccountDetails(const std::map< std::string, std::string > &details)
bool remove(const std::shared_ptr< Call > &call)
std::vector< std::string > getCallIds() const
void add(const std::shared_ptr< Call > &call)
std::vector< std::string > getConferenceIds() const
std::shared_ptr< Conference > getConference(const std::string &conferenceId) const
bool removeConference(const std::string &confId)
std::shared_ptr< Call > getCall(const std::string &callId) const
VoipLinkException(const std::string &str="")
RegistrationState
Contains all the Registration states for an account can be in.
void emitSignal(Args... args)
static constexpr const char RINGDIR[]
static constexpr uint64_t JAMI_ID_MAX_VAL
static std::ostream & operator<<(std::ostream &os, const Account &acc)
Simple macro to hide class' copy constructor and assignment operator.
#define NON_COPYABLE(ClassName)
bool ringtoneEnabled
Play ringtone when receiving a call.
bool localModeratorsEnabled
bool enabled
True if the account is enabled.
std::string alias
A user-defined name for this account.
std::string hostname
SIP hostname (SIP account) or DHT bootstrap nodes (Jami account)
bool allModeratorsEnabled
bool autoAnswerEnabled
If true, automatically answer calls to this account.
std::set< std::string > defaultModerators
bool denySecondCallEnabled
If true, automatically deny new calls when already in one call to this account.
virtual std::map< std::string, std::string > toMap() const
std::string mailbox
Account mail box.
bool sendReadReceipt
If true, send displayed status (and emit to the client)
bool isRendezVous
If true mix calls into a conference.
std::string displayName
Display name when calling.
bool videoEnabled
Allows user to temporarily disable video calling.
bool sendComposing
If true, send composing status (and emit to the client)