29#include <pjsip/sip_transport_tls.h>
30#include <pjsip/sip_types.h>
31#include <pjsip-ua/sip_regc.h>
56 std::shared_ptr<SIPAccount const>
shared()
const
60 std::weak_ptr<SIPAccount>
weak()
64 std::weak_ptr<SIPAccount const>
weak()
const
84 return std::make_unique<SipAccountConfig>(
getAccountID());
287 std::string
getToUri(
const std::string& username)
const override;
320 receivedParameter_ = received;
339 via_addr_.port =
rPort;
344 void setTransport(
const std::shared_ptr<SipTransport>& =
nullptr);
346 virtual inline std::shared_ptr<SipTransport>
getTransport() {
return transport_; }
356 MatchRank matches(std::string_view username, std::string_view hostname)
const override;
382 const std::vector<libjami::MediaMap>&
mediaList)
override;
392 const std::string& from,
393 const std::vector<libjami::MediaMap>&
mediaList,
394 const std::shared_ptr<SipTransport>&
sipTr = {})
override;
399 const std::string& deviceId,
400 const std::map<std::string, std::string>& payloads,
428 const std::map<std::string, std::string>& data);
436 bool initContactAddress();
437 void updateContactHeader();
439 void setCredentials(
const std::vector<SipAccountConfig::Credentials>&
creds);
445 std::shared_ptr<Call> newRegisteredAccountCall(
const std::string&
id,
const std::string&
toUrl);
452 bool SIPStartCall(std::shared_ptr<SIPCall>& call);
454 void usePublishedAddressPortInVIA();
455 void useUPnPAddressPortInVIA();
456 bool fullMatch(std::string_view username, std::string_view hostname)
const;
457 bool userMatch(std::string_view username)
const;
458 bool hostnameMatch(std::string_view hostname)
const;
459 bool proxyMatch(std::string_view hostname)
const;
475 std::uniform_int_distribution<int> delay10ZeroDist_ {-10000, 10000};
476 std::uniform_int_distribution<unsigned int> delay10PosDist_ {0, 10000};
478 void scheduleReregistration();
479 void autoReregTimerCb();
481 std::shared_ptr<SipTransport> transport_ {};
483 std::shared_ptr<TlsListener> tlsListener_ {};
504 void initTlsConfiguration();
515 void initStunConfiguration();
523 static std::string getLoginName();
533 static std::string printContactHeader(
const std::string& username,
534 const std::string& displayName,
535 const std::string& address,
538 const std::string& deviceKey = {});
543 dhtnet::IpAddr hostIp_;
559 std::vector<pjsip_cred_info> cred_;
574 pj_str_t stunServerName_ {
nullptr, 0};
590 std::pair<int, std::string> registrationStateDetailed_;
595 std::string receivedParameter_;
608 std::string publishedIpStr_ {};
614 std::string upnpIpAddr_;
616 mutable std::mutex contactMutex_;
618 std::string contactHeader_;
620 dhtnet::IpAddr contactAddress_ {};
626 SIPPresence* presence_;
const std::string & getAccountID() const
Get the account ID.
void editConfig(std::function< void(AccountConfig &config)> &&edit)
const AccountConfig & config() const
std::string getStunServer() const
void destroyRegistrationInfo()
std::string getToUri(const std::string &username) const override
This method adds the correct scheme, hostname and append the ;transport= parameter at the end of the ...
void pushNotificationReceived(const std::string &from, const std::map< std::string, std::string > &data)
To be called by clients with relevant data when a push notification is received.
std::unique_ptr< AccountConfig > buildConfig() const override
void editConfig(std::function< void(SipAccountConfig &conf)> &&edit)
bool setPushNotificationConfig(const std::map< std::string, std::string > &data) override
bool isStunEnabled() const override
void resetAutoRegistration()
pj_bool_t active
Flag of reregister status.
virtual void setRegistrationState(RegistrationState state, int code=0, const std::string &detail_str={}) override
Set the registration state of the specified link.
void loadConfig() override
Actually useless, since config loading is done in init()
const pjsip_cred_info * getCredInfo() const
const SipAccountConfig & config() const
void doUnregister(bool forceShutdownConnections=false) override
Send unregistration.
dhtnet::IpAddr getContactAddress() const
Get the contact address.
pj_uint16_t getStunPort() const override
static constexpr auto ACCOUNT_TYPE
unsigned attempt_cnt
Attempt counter.
pjsip_tpselector getTransportSelector()
Shortcut for SipTransport::getTransportSelector(account.getTransport()).
void updateDialogViaSentBy(pjsip_dialog *dlg)
unsigned getCredentialCount() const
Get the number of credentials defined for this account.
bool setPushNotificationToken(const std::string &pushDeviceToken="") override
void enablePresence(const bool &enable)
Activate the module.
pjsip_host_port getHostPortFromSTUN(pj_pool_t *pool)
bool isIP2IP() const override
Returns true if this is the IP2IP account.
static const std::vector< std::string > & getSupportedTlsCiphers()
bool isRegistrationRefreshEnabled() const
void sendRegister()
Build and send SIP registration request.
std::shared_ptr< SIPCall > newIncomingCall(const std::string &from, const std::vector< libjami::MediaMap > &mediaList, const std::shared_ptr< SipTransport > &sipTr={}) override
Create incoming SIPCall.
MatchRank matches(std::string_view username, std::string_view hostname) const override
std::shared_ptr< SIPAccount > shared()
pjsip_transport_type_e getTransportType() const
pjsip_host_port * getViaAddr()
std::string_view getAccountType() const override
uint16_t getLocalPort() const
Get the port on which the transport/listener should use, or is actually using.
dhtnet::IpAddr createBindingAddress()
Create the Ip address that the transport uses.
virtual std::map< std::string, std::string > getVolatileAccountDetails() const override
Retrieve volatile details such as recent registration errors.
bool hasServiceRoute() const
void setActiveCodecs(const std::vector< unsigned > &list) override
Update both the codec order structure and the codec string used for SDP offer and configuration respe...
std::string getContactHeader() const
Get the contact header.
std::weak_ptr< SIPAccount > weak()
pj_str_t getStunServerName() const
bool hasCredentials() const
SIPPresence * getPresence() const
Presence management.
std::weak_ptr< SIPAccount const > weak() const
void setLocalPort(uint16_t port)
bool checkNATAddress(pjsip_regc_cbparam *param, pj_pool_t *pool)
Update NAT address, Via and Contact header from the REGISTER response.
void connectivityChanged() override
Inform the account that the network status has changed.
std::string getFromUri() const override
void setTransport(const std::shared_ptr< SipTransport > &=nullptr)
void setRegistrationInfo(pjsip_regc *regc)
Set the registration structure that is used for PJSIP in the registration process; @pram A pointer to...
std::shared_ptr< Call > newOutgoingCall(std::string_view toUrl, const std::vector< libjami::MediaMap > &mediaList) override
Create outgoing SIPCall.
void supportPresence(int function, bool enable)
Activate the publish/subscribe.
void sendUnregister()
Build and send SIP unregistration request.
pj_uint16_t getTlsListenerPort() const
Get the local port for TLS listener.
pj_timer_entry timer
Timer for reregistration.
static const std::vector< std::string > & getSupportedTlsProtocols()
std::string getServiceRoute() const
virtual bool isTlsEnabled() const override
Determine if TLS is enabled for this account.
unsigned getRegistrationExpire() const
A client sendings a REGISTER request MAY suggest an expiration interval that indicates how long the c...
void setReceivedParameter(const std::string &received)
virtual void sendMessage(const std::string &to, const std::string &deviceId, const std::map< std::string, std::string > &payloads, uint64_t id, bool retryOnTimeout=true, bool onlyConnected=false) override
void updateProfile(const std::string &displayName, const std::string &avatar, const std::string &fileType, int32_t flag) override
updates SIP account profile
const std::string & getReceivedParameter() const
void onRegister(pjsip_regc_cbparam *param)
pjsip_tls_setting * getTlsSetting()
std::map< std::string, std::string > getTlsSettings() const
Return the TLS settings, mainly used to return security information to a client application.
virtual bool getSrtpFallback() const override
bool isSrtpEnabled() const override
std::string getUserUri() const override
bool isRegistered() const
Registration flag.
virtual std::shared_ptr< SipTransport > getTransport()
void doRegister() override
Initialize the SIP voip link with the account parameters and send registration.
std::vector< std::map< std::string, std::string > > getCredentials() const
pjsip_regc * getRegistrationInfo()
Get the registration structure that is used for PJSIP in the registration process.
std::shared_ptr< SIPAccount const > shared() const
std::string getServerUri() const
In the current version, "srv" uri is obtained in the preformatted way: hostname:port.
static constexpr int DEFAULT_SIP_PORT
constexpr const pj_str_t CONST_PJ_STR(T(&a)[N]) noexcept
RegistrationState
Contains all the Registration states for an account can be in.
void emitSignal(Args... args)
std::vector< pj_ssl_cipher > CipherArray
static constexpr std::string_view ACCOUNT_TYPE_SIP
Simple macro to hide class' copy constructor and assignment operator.
#define NON_COPYABLE(ClassName)
std::string stunServer
The STUN server hostname (optional), used to provide the public IP address in case the softphone stay...
bool srtpFallback
Determine if the softphone should fallback on non secured media channel if SRTP negotiation fails.
std::vector< std::map< std::string, std::string > > getCredentials() const
bool stunEnabled
Determine if STUN public address resolution is required to register this account.
uint16_t localPort
Local port to whih this account is bound.
unsigned registrationExpire
Network settings.
uint16_t tlsListenerPort
The TLS listener port.
std::string serviceRoute
Input Outbound Proxy Server Address.
std::vector< Credentials > credentials
KeyExchangeProtocol srtpKeyExchange
Specifies the type of key exchange used for SRTP, if any.
bool registrationRefreshEnabled