35#include <opendht/rng.h>
46#pragma GCC diagnostic push
47#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
48#include <yaml-cpp/yaml.h>
49#pragma GCC diagnostic pop
54#include <dhtnet/upnp/upnp_control.h>
55#include <dhtnet/ip_utils.h>
57#include <fmt/ranges.h>
59using namespace std::literals;
70 : rand(
Manager::instance().getSeededRandomEngine())
71 , accountID_(accountId)
73 , idPath_(fileutils::get_data_dir() / accountId)
84 for (
const auto& callId : callSet_.
getCallIds())
102 throw std::runtime_error(
"Failed to create a UPNP Controller instance!");
110 const std::string& detail_str)
144 *std::static_pointer_cast<SystemAudioCodecInfo>(
systemCodec)));
149 *std::static_pointer_cast<SystemVideoCodecInfo>(
systemCodec)));
178std::map<std::string, std::string>
185std::map<std::string, std::string>
189 auto path =
idPath_ /
"profile.vcf";
190 if (!std::filesystem::exists(path))
193 }
catch (
const std::exception&
e) {
233 [](
const std::shared_ptr<SystemCodecInfo>&
a,
234 const std::shared_ptr<SystemCodecInfo>&
b) {
return a->order <
b->order; });
240#define CASE_STATE(X) \
241 case RegistrationState::X: \
269std::map<std::string, std::string>
275 auto audioCodec = std::static_pointer_cast<jami::SystemAudioCodecInfo>(codec);
279 auto videoCodec = std::static_pointer_cast<jami::SystemVideoCodecInfo>(codec);
316std::shared_ptr<SystemCodecInfo>
322 && (
codecIt->mediaType & mediaType))
329std::shared_ptr<SystemCodecInfo>
335 && (
codecIt->mediaType & mediaType))
342std::shared_ptr<SystemCodecInfo>
347 if ((
codecIt->payloadType == payload)
348 && (
codecIt->mediaType & mediaType))
361 std::vector<unsigned>
idList;
375 std::vector<unsigned>
idList;
377 if (
codecIt->mediaType & mediaType)
390 if (
codecIt->mediaType & mediaType)
413std::vector<std::shared_ptr<SystemCodecInfo>>
443 config_->defaultModerators.insert(uri);
449 config_->defaultModerators.erase(uri);
469 auto platform = data.find(
"platform");
470 auto topic = data.find(
"topic");
471 auto token = data.find(
"token");
481 if (token != data.end() &&
config_->deviceKey != token->second) {
482 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::map< std::string, std::string > getProfileVcard() const
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)
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
RegistrationState
Contains all the Registration states for an account can be in.
@ ERROR_SERVICE_UNAVAILABLE
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[]
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.
std::map< std::string, std::string > toMap(std::string_view content)
Payload to vCard.