32#include <opendht/rng.h>
42#pragma GCC diagnostic push
43#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
44#include <yaml-cpp/yaml.h>
45#pragma GCC diagnostic pop
49#include <dhtnet/upnp/upnp_control.h>
50#include <dhtnet/ip_utils.h>
52#include <fmt/ranges.h>
54using namespace std::literals;
65 : rand(
Manager::instance().getSeededRandomEngine())
66 , accountID_(accountId)
68 , idPath_(fileutils::get_data_dir() / accountId)
79 for (
const auto& callId : callSet_.
getCallIds())
97 throw std::runtime_error(
"Failed to create a UPNP Controller instance!");
137 std::make_shared<SystemAudioCodecInfo>(*std::static_pointer_cast<SystemAudioCodecInfo>(
systemCodec)));
142 std::make_shared<SystemVideoCodecInfo>(*std::static_pointer_cast<SystemVideoCodecInfo>(
systemCodec)));
173std::map<std::string, std::string>
184 auto path =
idPath_ /
"profile.vcf";
185 if (!std::filesystem::exists(path))
188 }
catch (
const std::exception&
e) {
228 [](
const std::shared_ptr<SystemCodecInfo>&
a,
const std::shared_ptr<SystemCodecInfo>&
b) {
229 return a->order <
b->order;
236#define CASE_STATE(X) \
237 case RegistrationState::X: \
265std::map<std::string, std::string>
271 auto audioCodec = std::static_pointer_cast<jami::SystemAudioCodecInfo>(codec);
275 auto videoCodec = std::static_pointer_cast<jami::SystemVideoCodecInfo>(codec);
312std::shared_ptr<SystemCodecInfo>
324std::shared_ptr<SystemCodecInfo>
336std::shared_ptr<SystemCodecInfo>
341 if ((
codecIt->payloadType == payload) && (
codecIt->mediaType & mediaType))
354 std::vector<unsigned>
idList;
368 std::vector<unsigned>
idList;
370 if (
codecIt->mediaType & mediaType)
383 if (
codecIt->mediaType & mediaType)
406std::vector<std::shared_ptr<SystemCodecInfo>>
436 config_->defaultModerators.insert(uri);
442 config_->defaultModerators.erase(uri);
462 auto platform = data.find(
"platform");
463 auto topic = data.find(
"topic");
464 auto token = data.find(
"token");
474 if (token != data.end() &&
config_->deviceKey != token->second) {
475 config_->deviceKey = token->second;
Interface to protocol account (ex: SIPAccount) It can be enable on loading or activate after.
Account specific keys/constants that must be shared in daemon and clients.
virtual ~Account()
Virtual destructor.
virtual bool setPushNotificationConfig(const std::map< std::string, std::string > &data)
bool hasActiveCodec(MediaType mediaType) const
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)
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.
void setCodecInactive(unsigned codecId)
virtual void setRegistrationState(RegistrationState state, int detail_code=0, const std::string &detail_str={})
Set the registration state of the specified link.
std::vector< unsigned > getActiveCodecs(MediaType mediaType=MEDIA_ALL) 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.
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
RegistrationState registrationState_
std::filesystem::path idPath_
path to account
std::shared_ptr< SystemCodecContainer > systemCodecContainer_
Vector containing all system codecs (with default parameters)
void addDefaultModerator(const std::string &peerURI)
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::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)
static const std::string DEFAULT_USER_AGENT
std::unique_ptr< AccountConfig > config_
dhtnet::IpAddr getUPnPIpAddress() const
Get the UPnP IP (external router) address.
std::recursive_mutex configurationMutex_
const std::string & getUserAgentName()
Get the user-agent.
void setCodecActive(unsigned codecId)
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)
vCard::utils::VCardData getProfileVcard() const
bool active_
Tells if the account is active now.
std::filesystem::path ringtonePath_
Ringtone .au file used for this account.
static std::map< std::string, std::string > getDefaultCodecDetails(const unsigned &codecId)
void setAllCodecsActive(MediaType mediaType, bool active)
virtual void saveConfig() const
virtual void loadConfig()
Load the settings in this account.
std::shared_ptr< dhtnet::upnp::Controller > upnpCtrl_
Account(const std::string &accountID)
std::vector< std::string > getCallIds() const
Manager (controller) of daemon.
static LIBJAMI_TEST_EXPORT Manager & instance()
void saveConfig()
Save config to file.
bool hangupCall(const std::string &accountId, const std::string &callId)
Functions which occur with a user's action Hangup the call.
#define JAMI_ERROR(formatstr,...)
#define JAMI_WARNING(formatstr,...)
static const char *const CONFIG_ACCOUNT_REGISTRATION_STATUS
std::filesystem::path getFullPath(const std::filesystem::path &base, const std::filesystem::path &path)
If path is relative, it is appended to base.
const std::filesystem::path & get_resource_dir_path()
Get the resource directory path that was set with set_resource_dir_path.
std::string loadTextFile(const std::filesystem::path &path, const std::filesystem::path &default_dir)
static constexpr int version
std::map< std::string, std::string, std::less<> > VCardData
VCardData toMap(std::string_view content)
Payload to vCard.
decltype(getGlobalInstance< SystemCodecContainer >) & getSystemCodecContainer
static constexpr const char TRUE_STR[]
constexpr std::string_view platform()
void emitSignal(Args... args)
static constexpr const char FALSE_STR[]
RegistrationState
Contains all the Registration states for an account can be in.
@ ERROR_SERVICE_UNAVAILABLE
static constexpr const char RINGDIR[]
static void runOnMainThread(Callback &&cb)
constexpr const char *const DEFAULT_RINGTONE_PATH
static constexpr const char ERROR_GENERIC[]
static constexpr const char ACTIVE[]
const char * version() noexcept
Return the library version as string.