Commit 139085be authored by Rafaël Carré's avatar Rafaël Carré

Remove AccountID type and AccountNULL define

parent d9e03c00
......@@ -33,7 +33,7 @@
#include "account.h"
#include "manager.h"
Account::Account (const AccountID& accountID, const std::string &type) :
Account::Account (const std::string& accountID, const std::string &type) :
_accountID (accountID)
, _link (NULL)
, _enabled (true)
......
......@@ -48,8 +48,6 @@ class VoIPLink;
* It contains account, configuration, VoIP Link and Calls (inside the VoIPLink)
*/
typedef std::string AccountID;
/** Contains all the state an Voip can be in */
typedef enum RegistrationState {
Unregistered,
......@@ -64,8 +62,6 @@ typedef enum RegistrationState {
NumberOfState
} RegistrationState;
#define AccountNULL ""
// Account identifier
#define ACCOUNT_ID "Account.id"
......@@ -155,7 +151,7 @@ class Account : public Serializable
public:
Account (const AccountID& accountID, const std::string &type);
Account (const std::string& accountID, const std::string &type);
/**
* Virtual destructor
......@@ -187,7 +183,7 @@ class Account : public Serializable
* Get the account ID
* @return constant account id
*/
const AccountID& getAccountID() const {
const std::string& getAccountID() const {
return _accountID;
}
......@@ -368,7 +364,7 @@ class Account : public Serializable
/**
* Account ID are assign in constructor and shall not changed
*/
AccountID _accountID;
std::string _accountID;
/**
* Account login information: username
......
......@@ -45,7 +45,7 @@ AccountCreator::~AccountCreator()
}
Account*
AccountCreator::createAccount (AccountType type, AccountID accountID)
AccountCreator::createAccount (AccountType type, std::string accountID)
{
switch (type) {
......
......@@ -53,7 +53,7 @@ class AccountCreator
* @param type type of the account
* @param accountID accountID (must be unique for each account)
*/
static Account* createAccount (AccountType type, AccountID accountID);
static Account* createAccount (AccountType type, std::string accountID);
private:
/** Hidden constructor */
......
......@@ -65,7 +65,7 @@ void AudioRtpFactory::initAudioRtpConfig (SIPCall *ca)
stop();
}
AccountID accountId(Manager::instance().getAccountFromCall (ca->getCallId()));
std::string accountId(Manager::instance().getAccountFromCall (ca->getCallId()));
_debug ("AudioRtpFactory: Init rtp session for account %s", accountId.c_str());
......@@ -78,7 +78,7 @@ void AudioRtpFactory::initAudioRtpConfig (SIPCall *ca)
registerAccount(account, accountId);
}
void AudioRtpFactory::registerAccount(Account * /*account*/, const AccountID & /* id */)
void AudioRtpFactory::registerAccount(Account * /*account*/, const std::string & /* id */)
{
_srtpEnabled = false;
_keyExchangeProtocol = Symmetric;
......@@ -86,7 +86,7 @@ void AudioRtpFactory::registerAccount(Account * /*account*/, const AccountID & /
}
void AudioRtpFactory::registerAccount(SIPAccount *sipaccount, const AccountID& accountId)
void AudioRtpFactory::registerAccount(SIPAccount *sipaccount, const std::string& accountId)
{
_srtpEnabled = sipaccount->getSrtpEnable();
std::string tempkey(sipaccount->getSrtpKeyExchange());
......
......@@ -33,7 +33,7 @@
#include <stdexcept>
#include <cc++/thread.h>
#include "account.h" // for typedef of AccountID (std::string)
#include "account.h" // for typedef of std::string (std::string)
#include <ccrtp/CryptoContext.h>
#include "sip/SdesNegotiator.h"
......@@ -190,8 +190,8 @@ class AudioRtpFactory
void sendDtmfDigit (int digit);
private:
void registerAccount(Account *account, const AccountID &id);
void registerAccount(SIPAccount *account, const AccountID &id);
void registerAccount(Account *account, const std::string &id);
void registerAccount(SIPAccount *account, const std::string &id);
void * _rtpSession;
RtpMethod _rtpSessionType;
ost::Mutex _audioRtpThreadMutex;
......
......@@ -358,7 +358,7 @@ CallManager::startTone (const int32_t& start , const int32_t& type)
sfl::AudioZrtpSession * CallManager::getAudioZrtpSession (const std::string& callID)
{
SIPVoIPLink * link = NULL;
link = dynamic_cast<SIPVoIPLink *> (Manager::instance().getAccountLink (AccountNULL));
link = dynamic_cast<SIPVoIPLink *> (Manager::instance().getAccountLink (""));
if (!link) {
throw CallManagerException("Failed to get sip link");
......
......@@ -35,7 +35,7 @@
#include "iaxvoiplink.h"
#include "manager.h"
IAXAccount::IAXAccount (const AccountID& accountID)
IAXAccount::IAXAccount (const std::string& accountID)
: Account (accountID, "iax2")
{
_link = new IAXVoIPLink (accountID);
......
......@@ -40,7 +40,7 @@
class IAXAccount : public Account
{
public:
IAXAccount (const AccountID& accountID);
IAXAccount (const std::string& accountID);
~IAXAccount();
......
......@@ -57,7 +57,7 @@ namespace {
const char * const URLHOOK_COMMAND = "Hooks.url_command";
} // end anonymous namespace
IAXVoIPLink::IAXVoIPLink (const AccountID& accountID) : VoIPLink (accountID)
IAXVoIPLink::IAXVoIPLink (const std::string& accountID) : VoIPLink (accountID)
, _evThread (NULL)
, _regSession (NULL)
, _nextRefreshStamp (0)
......@@ -422,7 +422,7 @@ IAXVoIPLink::getIAXCall (const CallID& id)
void
IAXVoIPLink::sendRegister (AccountID id UNUSED) throw(VoipLinkException)
IAXVoIPLink::sendRegister (std::string id UNUSED) throw(VoipLinkException)
{
_debug ("IAX: Sending registration");
......@@ -468,7 +468,7 @@ IAXVoIPLink::sendRegister (AccountID id UNUSED) throw(VoipLinkException)
}
void
IAXVoIPLink::sendUnregister (AccountID id UNUSED) throw(VoipLinkException)
IAXVoIPLink::sendUnregister (std::string id UNUSED) throw(VoipLinkException)
{
_debug ("IAXVoipLink: Send unregister");
......@@ -764,8 +764,8 @@ IAXVoIPLink::iaxOutgoingInvite (IAXCall* call)
wait = 0;
/** @todo Make preference dynamic, and configurable */
audio_format_preferred = call->getFirstMatchingFormat (call->getSupportedFormat (getAccountID ()), getAccountID ());
audio_format_capability = call->getSupportedFormat (getAccountID ());
audio_format_preferred = call->getFirstMatchingFormat (call->getSupportedFormat (getAccountID()), getAccountID());
audio_format_capability = call->getSupportedFormat (getAccountID());
_debug ("IAX New call: %s", strNum.c_str());
iax_call (newsession, username.c_str(), username.c_str(), strNum.c_str(), lang, wait, audio_format_preferred, audio_format_capability);
......@@ -1095,7 +1095,7 @@ IAXVoIPLink::iaxHandleRegReply (iax_event* event)
//new_voicemails = processIAXMsgCount(event->ies.msgcount);
//_debug("iax voicemail number notification: %i", new_voicemails);
// Notify the client if new voicemail waiting for the current account
//account_id = getAccountID();
//account_id = getstd::string();
//Manager::instance().startVoiceMessageNotification(account_id.c_str(), new_voicemails);
iax_destroy (_regSession);
......@@ -1189,9 +1189,9 @@ IAXVoIPLink::iaxHandlePrecallEvent (iax_event* event)
* l'établissement du codec de transmission */
// Remote lists its capabilities
int format = call->getFirstMatchingFormat (event->ies.capability, getAccountID ());
int format = call->getFirstMatchingFormat (event->ies.capability, getAccountID());
// Remote asks for preferred codec voiceformat
int pref_format = call->getFirstMatchingFormat (event->ies.format, getAccountID ());
int pref_format = call->getFirstMatchingFormat (event->ies.format, getAccountID());
// Priority to remote's suggestion. In case it's a forwarding, no transcoding
// will be needed from the server, thus less latency.
......
......@@ -62,7 +62,7 @@ class IAXVoIPLink : public VoIPLink
* Constructor
* @param accountID The account containing the voip link
*/
IAXVoIPLink (const AccountID& accountID);
IAXVoIPLink (const std::string& accountID);
/**
* Destructor
......@@ -95,7 +95,7 @@ class IAXVoIPLink : public VoIPLink
* Send out registration
* @return bool The new registration state (are we registered ?)
*/
virtual void sendRegister (AccountID id) throw(VoipLinkException);
virtual void sendRegister (std::string id) throw(VoipLinkException);
/**
* Destroy registration session
......@@ -104,7 +104,7 @@ class IAXVoIPLink : public VoIPLink
* @return bool true if we're registered upstream
* false otherwise
*/
virtual void sendUnregister (AccountID id) throw(VoipLinkException);
virtual void sendUnregister (std::string id) throw(VoipLinkException);
/**
* Create a new outgoing call
......
This diff is collapsed.
......@@ -76,10 +76,10 @@ class HistoryManager;
class SIPAccount;
/** Define a type for a AccountMap container */
typedef std::map<AccountID, Account*> AccountMap;
typedef std::map<std::string, Account*> AccountMap;
/** Define a type for a CallID to AccountID Map inside ManagerImpl */
typedef std::map<CallID, AccountID> CallAccountMap;
/** Define a type for a CallID to std::string Map inside ManagerImpl */
typedef std::map<CallID, std::string> CallAccountMap;
typedef std::map<CallID, Call::CallConfiguration> CallConfigMap;
......@@ -199,7 +199,7 @@ class ManagerImpl
* @return bool true on success
* false otherwise
*/
bool outgoingCall (const AccountID&, const CallID&, const std::string&, const std::string& = "");
bool outgoingCall (const std::string&, const CallID&, const std::string&, const std::string& = "");
/**
* Functions which occur with a user's action
......@@ -434,7 +434,7 @@ class ManagerImpl
* @param accountId an account id
* @return bool True if the call was added correctly
*/
bool incomingCall (Call* call, const AccountID& accountId);
bool incomingCall (Call* call, const std::string& accountId);
/**
* Notify the user that the recipient of the call has answered and the put the
......@@ -477,7 +477,7 @@ class ManagerImpl
* @param accountId The account identifier
* @param nb_msg The number of messages
*/
void startVoiceMessageNotification (const AccountID& accountId, int nb_msg);
void startVoiceMessageNotification (const std::string& accountId, int nb_msg);
/**
* Notify the client through DBus that registration state has been updated
......@@ -517,7 +517,7 @@ class ManagerImpl
* @param accountID The account identifier
* @return std::map< std::string, std::string > The account details
*/
std::map< std::string, std::string > getAccountDetails (const AccountID& accountID);
std::map< std::string, std::string > getAccountDetails (const std::string& accountID);
/**
* Retrieve details about a given call
......@@ -574,14 +574,14 @@ class ManagerImpl
* purge from configuration.
* @param accountID The account unique ID
*/
void removeAccount (const AccountID& accountID);
void removeAccount (const std::string& accountID);
/**
* Deletes all credentials defined for an account
* @param accountID The account unique ID
*/
void deleteAllCredential (const AccountID& accountID);
void deleteAllCredential (const std::string& accountID);
/**
* Get current codec name
......@@ -687,25 +687,25 @@ class ManagerImpl
* @return int 1 if enabled
* 0 otherwise
*/
int isRingtoneEnabled (const AccountID& id);
int isRingtoneEnabled (const std::string& id);
/**
* Set the ringtone option
* Inverse current value
*/
void ringtoneEnabled (const AccountID& id);
void ringtoneEnabled (const std::string& id);
/**
* Get the ringtone
* @return gchar* The file name selected as a ringtone
*/
std::string getRingtoneChoice (const AccountID& id);
std::string getRingtoneChoice (const std::string& id);
/**
* Set a ringtone
* @param tone The file name of the ringtone
*/
void setRingtoneChoice (const std::string&, const AccountID& id);
void setRingtoneChoice (const std::string&, const std::string& id);
/**
* Get the recording path from configuration tree
......@@ -997,7 +997,7 @@ class ManagerImpl
/**
* Handle played music when an incoming call occurs
*/
void ringtone (const AccountID& accountID);
void ringtone (const std::string& accountID);
/**
* Handle played music when a congestion occurs
......@@ -1353,15 +1353,15 @@ class ManagerImpl
public:
/** Associate a new CallID to a AccountID
/** Associate a new CallID to a std::string
* Protected by mutex
* @param callID the new CallID not in the list yet
* @param accountID the known accountID present in accountMap
* @return bool True if the new association is create
*/
bool associateCallToAccount (const CallID& callID, const AccountID& accountID);
bool associateCallToAccount (const CallID& callID, const std::string& accountID);
/** Remove a CallID/AccountID association
/** Remove a CallID/std::string association
* Protected by mutex
* @param callID the CallID to remove
* @return bool True if association is removed
......@@ -1411,7 +1411,7 @@ class ManagerImpl
* @return bool True if the account exists
* false otherwise
*/
bool accountExists (const AccountID& accountID);
bool accountExists (const std::string& accountID);
/**
* Get a list of serialized history entries
......@@ -1429,25 +1429,25 @@ class ManagerImpl
* @param accountID account ID to get
* @return Account* The account pointer or 0
*/
Account* getAccount (const AccountID& accountID);
Account* getAccount (const std::string& accountID);
/** Return the AccountID from a CallID
/** Return the std::string from a CallID
* Protected by mutex
* @param callID the CallID in the list
* @return AccountID The accountID associated or "" if the callID is not found
* @return std::string The accountID associated or "" if the callID is not found
*/
AccountID getAccountFromCall (const CallID& callID);
std::string getAccountFromCall (const CallID& callID);
/**
* Get the voip link from the account pointer
* @param accountID Account ID to get
* @return VoIPLink* The voip link from the account pointer or 0
*/
VoIPLink* getAccountLink (const AccountID& accountID=AccountNULL);
VoIPLink* getAccountLink (const std::string& accountID="");
VoIPLink* getSIPAccountLink (void);
AccountID getAccountIdFromNameAndServer (const std::string& userName, const std::string& server);
std::string getAccountIdFromNameAndServer (const std::string& userName, const std::string& server);
int getLocalIp2IpPort();
......
......@@ -165,9 +165,9 @@ void ManagerImpl::restartPJSIP (void)
this->registerCurSIPAccounts ();
}
VoIPLink* ManagerImpl::getAccountLink (const AccountID& accountID)
VoIPLink* ManagerImpl::getAccountLink (const std::string& accountID)
{
if (accountID!=AccountNULL) {
if (accountID!="") {
Account* acc = getAccount (accountID);
if (acc) {
......@@ -199,7 +199,7 @@ VoIPLink* ManagerImpl::getSIPAccountLink()
return NULL;
}
pjsip_regc *getSipRegcFromID (const AccountID& id UNUSED)
pjsip_regc *getSipRegcFromID (const std::string& id UNUSED)
{
/*SIPAccount *tmp = dynamic_cast<SIPAccount *>getAccount(id);
if(tmp != NULL)
......
......@@ -89,7 +89,7 @@ static void free_cred(pjsip_cred_info *cred)
}
} // end anonymous namespace
SIPAccount::SIPAccount (const AccountID& accountID)
SIPAccount::SIPAccount (const std::string& accountID)
: Account (accountID, "SIP")
, _routeSet ("")
, _pool (NULL)
......
......@@ -155,7 +155,7 @@ class SIPAccount : public Account
* Constructor
* @param accountID The account identifier
*/
SIPAccount (const AccountID& accountID);
SIPAccount (const std::string& accountID);
/* Copy Constructor */
SIPAccount (const SIPAccount& rh);
......
......@@ -151,7 +151,7 @@ std::string fetchHeaderValue (pjsip_msg *msg, std::string field);
/**
* Helper function that retreive IP address from local udp transport
*/
std::string getLocalAddressAssociatedToAccount (AccountID id);
std::string getLocalAddressAssociatedToAccount (std::string id);
/*
* The global pool factory
......@@ -187,7 +187,7 @@ UrlHook *urlhook;
/**
* Get the number of voicemail waiting in a SIP message
*/
void setVoicemailInfo (AccountID account, pjsip_msg_body *body);
void setVoicemailInfo (std::string account, pjsip_msg_body *body);
pj_bool_t stun_sock_on_status_cb (pj_stun_sock *stun_sock, pj_stun_sock_op op, pj_status_t status);
pj_bool_t stun_sock_on_rx_data_cb (pj_stun_sock *stun_sock, void *pkt, unsigned pkt_len, const pj_sockaddr_t *src_addr, unsigned addr_len);
......@@ -289,7 +289,7 @@ void onCallTransfered (pjsip_inv_session *inv, pjsip_rx_data *rdata);
SIPVoIPLink* SIPVoIPLink::_instance = NULL;
SIPVoIPLink::SIPVoIPLink (const AccountID& accountID)
SIPVoIPLink::SIPVoIPLink (const std::string& accountID)
: VoIPLink (accountID)
, _nbTryListenAddr (2) // number of times to try to start SIP listener
, _regPort (atoi (DEFAULT_SIP_PORT))
......@@ -314,7 +314,7 @@ SIPVoIPLink::~SIPVoIPLink()
}
SIPVoIPLink* SIPVoIPLink::instance (const AccountID& id)
SIPVoIPLink* SIPVoIPLink::instance (const std::string& id)
{
if (!_instance) {
......@@ -393,7 +393,7 @@ SIPVoIPLink::getEvent()
}
void SIPVoIPLink::sendRegister (AccountID id) throw(VoipLinkException)
void SIPVoIPLink::sendRegister (std::string id) throw(VoipLinkException)
{
int expire_value = 0;
......@@ -607,7 +607,7 @@ void SIPVoIPLink::sendRegister (AccountID id) throw(VoipLinkException)
}
}
void SIPVoIPLink::sendUnregister (AccountID id) throw(VoipLinkException)
void SIPVoIPLink::sendUnregister (std::string id) throw(VoipLinkException)
{
pj_status_t status = 0;
......@@ -820,7 +820,7 @@ SIPVoIPLink::hangup (const CallID& id) throw (VoipLinkException)
throw VoipLinkException("Call is NULL while hanging up");
}
AccountID account_id = Manager::instance().getAccountFromCall (id);
std::string account_id = Manager::instance().getAccountFromCall (id);
SIPAccount *account = dynamic_cast<SIPAccount *> (Manager::instance().getAccount (account_id));
if(account == NULL) {
throw VoipLinkException("Could not find account for this call");
......@@ -1138,7 +1138,7 @@ SIPVoIPLink::transfer (const CallID& id, const std::string& to) throw (VoipLinkE
call->stopRecording();
AccountID account_id = Manager::instance().getAccountFromCall (id);
std::string account_id = Manager::instance().getAccountFromCall (id);
SIPAccount *account = dynamic_cast<SIPAccount *> (Manager::instance().getAccount (account_id));
if (account == NULL) {
throw VoipLinkException("Could not find account");
......@@ -1390,7 +1390,7 @@ SIPVoIPLink::getCurrentCodecName(const CallID& id)
return name;
}
std::string SIPVoIPLink::getUseragentName (const AccountID& id)
std::string SIPVoIPLink::getUseragentName (const std::string& id)
{
/*
useragent << PROGNAME << "/" << PACKAGE_VERSION;
......@@ -1419,7 +1419,7 @@ SIPVoIPLink::carryingDTMFdigits (const CallID& id, char code)
return false;
}
AccountID accountID = Manager::instance().getAccountFromCall (id);
std::string accountID = Manager::instance().getAccountFromCall (id);
SIPAccount *account = static_cast<SIPAccount *> (Manager::instance().getAccount (accountID));
if (!account) {
......@@ -1546,7 +1546,7 @@ SIPVoIPLink::SIPStartCall (SIPCall* call, const std::string& subject UNUSED)
_error ("UserAgent: pool capacity %d", pj_pool_get_capacity (_pool));
_error ("UserAgent: pool size %d", pj_pool_get_used_size (_pool));
AccountID id = Manager::instance().getAccountFromCall (call->getCallId());
std::string id = Manager::instance().getAccountFromCall (call->getCallId());
// Get the basic information about the callee account
SIPAccount * account = NULL;
......@@ -2057,7 +2057,7 @@ bool SIPVoIPLink::pjsipInit()
return PJ_SUCCESS;
}
pj_status_t SIPVoIPLink::stunServerResolve (AccountID id)
pj_status_t SIPVoIPLink::stunServerResolve (std::string id)
{
pj_str_t stunServer;
pj_uint16_t stunPort;
......@@ -2116,7 +2116,7 @@ pj_status_t SIPVoIPLink::stunServerResolve (AccountID id)
bool SIPVoIPLink::acquireTransport (const AccountID& accountID)
bool SIPVoIPLink::acquireTransport (const std::string& accountID)
{
SIPAccount* account = dynamic_cast<SIPAccount *> (Manager::instance().getAccount (accountID));
......@@ -2219,7 +2219,7 @@ bool SIPVoIPLink::createDefaultSipUdpTransport()
_regPort = RANDOM_SIP_PORT;
_debug ("UserAgent: Trying to initialize SIP listener on port %d", _regPort);
// If no AccountID specified, pointer to transport is stored in _localUDPTransport
// If no std::string specified, pointer to transport is stored in _localUDPTransport
errPjsip = createUdpTransport();
if (errPjsip != PJ_SUCCESS) {
......@@ -2245,7 +2245,7 @@ void SIPVoIPLink::createDefaultSipTlsListener()
}
void SIPVoIPLink::createTlsListener (const AccountID& accountID)
void SIPVoIPLink::createTlsListener (const std::string& accountID)
{
pjsip_tpfactory *tls;
......@@ -2309,7 +2309,7 @@ void SIPVoIPLink::createTlsListener (const AccountID& accountID)
}
bool SIPVoIPLink::createSipTransport (AccountID id)
bool SIPVoIPLink::createSipTransport (std::string id)
{
SIPAccount* account = dynamic_cast<SIPAccount *> (Manager::instance().getAccount (id));
......@@ -2389,7 +2389,7 @@ bool SIPVoIPLink::addTransportToMap (std::string key, pjsip_transport* transport
}
int SIPVoIPLink::createUdpTransport (AccountID id)
int SIPVoIPLink::createUdpTransport (std::string id)
{
pj_status_t status;
......@@ -2717,7 +2717,7 @@ int SIPVoIPLink::findLocalPortFromUri (const std::string& uri, pjsip_transport *
}
pj_status_t SIPVoIPLink::createTlsTransport (const AccountID& accountID, std::string remoteAddr)
pj_status_t SIPVoIPLink::createTlsTransport (const std::string& accountID, std::string remoteAddr)
{
pj_status_t success;
......@@ -2755,7 +2755,7 @@ pj_status_t SIPVoIPLink::createTlsTransport (const AccountID& accountID, std::st
return success;
}
pj_status_t SIPVoIPLink::createAlternateUdpTransport (AccountID id)
pj_status_t SIPVoIPLink::createAlternateUdpTransport (std::string id)
{
pj_sockaddr_in boundAddr;
pjsip_host_port a_name;
......@@ -2868,7 +2868,7 @@ pj_status_t SIPVoIPLink::createAlternateUdpTransport (AccountID id)
}
void SIPVoIPLink::shutdownSipTransport (const AccountID& accountID)
void SIPVoIPLink::shutdownSipTransport (const std::string& accountID)
{
_debug ("UserAgent: Shutdown Sip Transport");
......@@ -3104,7 +3104,7 @@ static void dns_cb (pj_status_t status, void *token, const struct pjsip_server_a