Commit eaacee5e authored by Rafaël Carré's avatar Rafaël Carré
Browse files

* #6558 : remove account creator

parent 25e7d660
......@@ -42,7 +42,6 @@ noinst_HEADERS = \
global.h \
eventthread.h \
account.h \
accountcreator.h \
call.h \
logger.h \
numbercleaner.h \
......@@ -96,7 +95,6 @@ libsflphone_la_SOURCES = conference.cpp \
managerimpl.cpp \
managerimpl_registration.cpp \
eventthread.cpp \
accountcreator.cpp \
call.cpp \
account.cpp \
logger.cpp \
......
/*
* Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010, 2011 Savoir-Faire Linux Inc.
* Author: Alexandre Bourget <alexandre.bourget@savoirfairelinux.com>
* Author: Yan Morin <yan.morin@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#include "accountcreator.h"
#include "sip/sipaccount.h"
#if HAVE_IAX
#include "iax/iaxaccount.h"
#endif
AccountCreator::AccountCreator()
{
}
AccountCreator::~AccountCreator()
{
}
Account*
AccountCreator::createAccount (AccountType type, std::string accountID)
{
switch (type) {
case SIP_ACCOUNT: {
_debug ("AccountCreator: create account %s", accountID.c_str());
return new SIPAccount (accountID);
break;
}
case SIP_DIRECT_IP_ACCOUNT: {
_debug ("AccountCreator: create account IP2IP_PROFILE");
return new SIPAccount (IP2IP_PROFILE);
break;
}
#if HAVE_IAX
case IAX_ACCOUNT: {
_debug ("AccountCreator: create account %s", accountID.c_str());
return new IAXAccount (accountID);
break;
}
#endif
default:
_error ("AccountCreator: Error: unknown account type");
}
return 0;
}
/*
* Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010, 2011 Savoir-Faire Linux Inc.
* Author: Alexandre Bourget <alexandre.bourget@savoirfairelinux.com>
* Author: Yan Morin <yan.morin@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#ifndef ACCOUNTCREATOR_H
#define ACCOUNTCREATOR_H
#include "account.h"
class Account;
/**
* @file accountcreator.h
* @brief Create protocol-specific account
*/
class AccountCreator
{
public:
~AccountCreator();
/**
* Public account type
*/
enum AccountType {SIP_ACCOUNT, SIP_DIRECT_IP_ACCOUNT, IAX_ACCOUNT };
/**
* Create a new account or null
* @param type type of the account
* @param accountID accountID (must be unique for each account)
*/
static Account* createAccount (AccountType type, std::string accountID);
private:
/** Hidden constructor */
AccountCreator();
};
#endif
......@@ -336,7 +336,7 @@ CallManager::getCurrentCallID()
void
CallManager::playDTMF (const std::string& key)
{
Manager::instance().sendDtmf (Manager::instance().getCurrentCallId(), key.c_str() [0]);
Manager::instance().sendDtmf (Manager::instance().getCurrentCallId(), key.data() [0]);
}
void
......
......@@ -40,12 +40,12 @@
#include "dbus/callmanager.h"
#include "global.h"
#include "sip/sipaccount.h"
#include "iax/iaxaccount.h"
#include "audio/alsa/alsalayer.h"
#include "audio/pulseaudio/pulselayer.h"
#include "audio/sound/tonelist.h"
#include "history/historymanager.h"
#include "accountcreator.h" // create new account
#include "sip/sipvoiplink.h"
#include "iax/iaxvoiplink.h"
#include "manager.h"
......@@ -1562,14 +1562,8 @@ bool ManagerImpl::sendDtmf (const std::string& id, char code)
_debug ("Manager: Send DTMF for call %s", id.c_str());
std::string accountid = getAccountFromCall (id);
playDtmf (code);
CallAccountMap::iterator iter = _callAccountMap.find (id);
bool returnValue = getAccountLink (accountid)->carryingDTMFdigits (id, code);
return returnValue;
return getAccountLink (accountid)->carryingDTMFdigits (id, code);
}
//THREAD=Main | VoIPLink
......@@ -3395,14 +3389,12 @@ std::string ManagerImpl::addAccount (
/** @todo Verify the uniqueness, in case a program adds accounts, two in a row. */
Account* newAccount;
Account* newAccount = NULL;
if (accountType == "SIP") {
newAccount = AccountCreator::createAccount (AccountCreator::SIP_ACCOUNT,
newAccountID);
newAccount = new SIPAccount(newAccountID);
newAccount->setVoIPLink();
} else if (accountType == "IAX") {
newAccount = AccountCreator::createAccount (AccountCreator::IAX_ACCOUNT,
newAccountID);
newAccount = new IAXAccount(newAccountID);
} else {
_error ("Unknown %s param when calling addAccount(): %s",
CONFIG_ACCOUNT_TYPE, accountType.c_str());
......@@ -3543,14 +3535,8 @@ void ManagerImpl::loadIptoipProfile()
_debug ("Manager: Create default \"account\" (used as default UDP transport)");
// build a default IP2IP account with default parameters
_directIpAccount = AccountCreator::createAccount (AccountCreator::SIP_DIRECT_IP_ACCOUNT, "");
_directIpAccount = new SIPAccount(IP2IP_PROFILE);
_accountMap[IP2IP_PROFILE] = _directIpAccount;
_accountMap[""] = _directIpAccount;
if (_directIpAccount == NULL) {
_error ("Manager: Failed to create default \"account\"");
return;
}
// If configuration file parsed, load saved preferences
if (_setupLoaded) {
......@@ -3634,9 +3620,9 @@ short ManagerImpl::loadAccountMap()
// Create a default account for specific type
if (accountType == "SIP" && accountid != "IP2IP")
tmpAccount = AccountCreator::createAccount (AccountCreator::SIP_ACCOUNT, accountid);
tmpAccount = new SIPAccount(accountid);
else if (accountType == "IAX" and accountid != "IP2IP")
tmpAccount = AccountCreator::createAccount (AccountCreator::IAX_ACCOUNT, accountid);
tmpAccount = new IAXAccount(accountid);
// Fill account with configuration preferences
if (tmpAccount != NULL) {
......
......@@ -2655,31 +2655,15 @@ pj_status_t SIPVoIPLink::createAlternateUdpTransport (SIPAccount *account)
}
void SIPVoIPLink::shutdownSipTransport (const std::string& accountID)
void SIPVoIPLink::shutdownSipTransport (SIPAccount *account)
{
_debug ("UserAgent: Shutdown Sip Transport");
SIPAccount* account = dynamic_cast<SIPAccount *> (Manager::instance().getAccount (accountID));
if (!account)
return;
if (account->getAccountTransport()) {
_debug ("Transport bound to account, decrease ref count");
// decrease reference count added by pjsip_regc_send
// PJSIP's IDLE timer is set if counter reach 0
// there is still problems when account registration fails, so comment it for now
// status = pjsip_transport_dec_ref(account->getAccountTransport());
// detach transport from this account
pjsip_transport *tr = account->getAccountTransport();
if (tr) {
pjsip_transport_dec_ref(tr);
account->setAccountTransport (NULL);
}
}
std::string SIPVoIPLink::parseDisplayName(char * buffer)
......@@ -2843,11 +2827,6 @@ void setVoicemailInfo (std::string account, pjsip_msg_body *body)
Manager::instance().startVoiceMessageNotification (account, voicemail);
}
void SIPVoIPLink::SIPHandleReinvite (SIPCall *call UNUSED)
{
_debug ("UserAgent: Handle reinvite");
}
// This callback is called when the invite session state has changed
void invite_session_state_changed_cb (pjsip_inv_session *inv, pjsip_event *e)
{
......@@ -2939,8 +2918,6 @@ void sdp_request_offer_cb (pjsip_inv_session *inv, const pjmedia_sdp_session *of
call->getLocalSDP()->startNegotiation();
pjsip_inv_set_sdp_answer (call->getInvSession(), call->getLocalSDP()->getLocalSdpSession());
SIPVoIPLink *link = dynamic_cast<SIPVoIPLink *> (Manager::instance().getAccountLink (accId));
link->SIPHandleReinvite (call);
}
void sdp_create_offer_cb (pjsip_inv_session *inv, pjmedia_sdp_session **p_offer)
......@@ -3262,7 +3239,7 @@ void registration_cb (struct pjsip_regc_cbparam *param)
account->setRegistrationState (ErrorAuth);
account->setRegister (false);
SIPVoIPLink::instance ()->shutdownSipTransport (account->getAccountID());
SIPVoIPLink::instance ()->shutdownSipTransport (account);
return;
}
......@@ -3311,14 +3288,14 @@ void registration_cb (struct pjsip_regc_cbparam *param)
account->setRegister (false);
SIPVoIPLink::instance ()->shutdownSipTransport (account->getAccountID());
SIPVoIPLink::instance ()->shutdownSipTransport (account);
} else {
if (account->isRegister())
account->setRegistrationState (Registered);
else {
account->setRegistrationState (Unregistered);
SIPVoIPLink::instance ()->shutdownSipTransport (account->getAccountID());
SIPVoIPLink::instance ()->shutdownSipTransport (account);
}
}
}
......
......@@ -276,15 +276,6 @@ class SIPVoIPLink : public VoIPLink
*/
void SIPCallReleased (SIPCall *call);
/**
* Handle a re-invite request by the remote peer.
* A re-invite is an invite request inside a dialog.
* When receiving a re-invite, we updated information
* concerning medias
* @param sip call
*/
void SIPHandleReinvite (SIPCall *call);
pj_caching_pool *getMemoryPoolFactory();
/**
......@@ -363,7 +354,7 @@ class SIPVoIPLink : public VoIPLink
* putting its reference counter to zero. PJSIP assumes transport destruction since
* this action can be delayed by ongoing SIP transactions.
*/
void shutdownSipTransport (const std::string& accountID);
void shutdownSipTransport (SIPAccount *account);
/**
* Send a SIP message to a call identified by its callid
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment