Commit 87230602 authored by Tristan Matthews's avatar Tristan Matthews

* #7101: fixed segfault in daemon on conference hangup.

gnome-client still has leftover icon that crashes when clicked on.
parent 7732cb16
......@@ -223,7 +223,7 @@ void AudioRtpSession::updateDestinationIpAddress (void)
// This method remove the current destination entry
if (!_queue->forgetDestination (_remote_ip, _remote_port, _remote_port+1))
_warn ("AudioRtpSession: Could not remove previous destination");
_debug("AudioRtpSession: Did not remove previous destination");
// new destination is stored in call
// we just need to recall this method
......
......@@ -43,46 +43,36 @@ Conference::Conference()
Recordable::initRecFileName (_id);
}
Conference::~Conference()
{
}
int Conference::getState()
int Conference::getState() const
{
return _confState;
}
void Conference::setState (ConferenceState state)
{
_confState = state;
}
void Conference::add (std::string participant_id)
void Conference::add(const std::string &participant_id)
{
_participants.insert (participant_id);
}
void Conference::remove (std::string participant_id)
void Conference::remove(const std::string &participant_id)
{
_participants.erase (participant_id);
_participants.erase(participant_id);
}
void Conference::bindParticipant (std::string participant_id)
void Conference::bindParticipant(const std::string &participant_id)
{
ParticipantSet::iterator iter;
for (iter = _participants.begin(); iter != _participants.end(); ++iter)
if (participant_id != *iter)
Manager::instance().getMainBuffer()->bindCallID (participant_id, *iter);
for (ParticipantSet::iterator iter = _participants.begin();
iter != _participants.end(); ++iter)
if (participant_id != *iter)
Manager::instance().getMainBuffer()->bindCallID(participant_id, *iter);
Manager::instance().getMainBuffer()->bindCallID (participant_id);
Manager::instance().getMainBuffer()->bindCallID(participant_id);
}
std::string Conference::getStateStr()
{
switch (_confState) {
......@@ -96,14 +86,11 @@ std::string Conference::getStateStr()
}
}
const ParticipantSet &Conference::getParticipantList()
ParticipantSet Conference::getParticipantList() const
{
return _participants;
}
bool Conference::setRecording()
{
bool recordStatus = Recordable::recAudio.isRecording();
......@@ -130,5 +117,4 @@ bool Conference::setRecording()
}
return recordStatus;
}
......@@ -34,18 +34,12 @@
#include <string>
#include "audio/recordable.h"
#include "call.h"
// class ManagerImpl;
// class Call;
typedef std::set<std::string> ParticipantSet;
class Conference: public Recordable
{
public:
enum ConferenceState {ACTIVE_ATTACHED, ACTIVE_DETACHED, ACTIVE_ATTACHED_REC, ACTIVE_DETACHED_REC, HOLD, HOLD_REC};
/**
......@@ -53,11 +47,6 @@ class Conference: public Recordable
*/
Conference();
/**
* Destructor
*/
~Conference();
/**
* Return the conference id
*/
......@@ -68,7 +57,7 @@ class Conference: public Recordable
/**
* Return the current conference state
*/
int getState();
int getState() const;
/**
* Set conference state
......@@ -83,22 +72,22 @@ class Conference: public Recordable
/**
* Add a new participant to the conference
*/
void add (std::string participant_id);
void add (const std::string &participant_id);
/**
* Remove a participant from the conference
*/
void remove (std::string participant_id);
void remove (const std::string &participant_id);
/**
* Bind a participant to the conference
*/
void bindParticipant (std::string participant_id);
void bindParticipant (const std::string &participant_id);
/**
* Get the participant list for this conference
*/
const ParticipantSet &getParticipantList();
ParticipantSet getParticipantList() const;
/**
* Get recording file ID
......@@ -128,12 +117,6 @@ class Conference: public Recordable
* List of participant ids
*/
ParticipantSet _participants;
/**
* Number of participant
*/
int _nbParticipant;
};
#endif
......@@ -42,37 +42,34 @@
CallManager::CallManager (DBus::Connection& connection)
: DBus::ObjectAdaptor (connection, "/org/sflphone/SFLphone/CallManager")
{
}
{}
void
CallManager::placeCall (const std::string& accountID,
const std::string& callID,
const std::string& to) // Check if a destination number is available
void CallManager::placeCall(const std::string& accountID,
const std::string& callID,
const std::string& to)
{
if (to == "") {
// Check if a destination number is available
if (to.empty())
_debug ("No number entered - Call stopped");
} else {
else
Manager::instance().outgoingCall (accountID, callID, to);
}
}
void
CallManager::placeCallFirstAccount (const std::string& callID,
const std::string& to)
void CallManager::placeCallFirstAccount(const std::string& callID,
const std::string& to)
{
if (to == "") {
using std::vector;
using std::string;
if (to.empty()) {
_warn ("CallManager: Warning: No number entered, call stopped");
return;
}
std::vector< std::string > accountList = Manager::instance().loadAccountOrder();
if (accountList.size() == 0)
vector<string> accountList(Manager::instance().loadAccountOrder());
if (accountList.empty())
accountList = Manager::instance().getAccountList();
std::vector< std::string >::const_iterator iter;
for (iter = accountList.begin(); iter != accountList.end(); ++iter) {
for (vector<string>::const_iterator iter = accountList.begin(); iter != accountList.end(); ++iter) {
if ((*iter != IP2IP_PROFILE) && Manager::instance().getAccount(*iter)->isEnabled()) {
Manager::instance().outgoingCall(*iter, callID, to);
return;
......@@ -96,7 +93,6 @@ void
CallManager::hangUp (const std::string& callID)
{
Manager::instance().hangupCall (callID);
}
void
......@@ -105,7 +101,6 @@ CallManager::hangUpConference (const std::string& confID)
Manager::instance().hangupConference (confID);
}
void
CallManager::hold (const std::string& callID)
{
......@@ -124,20 +119,17 @@ CallManager::transfer (const std::string& callID, const std::string& to)
Manager::instance().transferCall (callID, to);
}
void
CallManager::attendedTransfer (const std::string& transferID, const std::string& targetID)
void CallManager::attendedTransfer (const std::string& transferID, const std::string& targetID)
{
Manager::instance().attendedTransfer(transferID, targetID);
}
void
CallManager::setVolume (const std::string& device, const double& value)
void CallManager::setVolume (const std::string& device, const double& value)
{
if (device == "speaker") {
Manager::instance().setSpkrVolume ( (int) (value*100.0));
} else if (device == "mic") {
Manager::instance().setMicVolume ( (int) (value*100.0));
}
if (device == "speaker")
Manager::instance().setSpkrVolume ( (int) (value * 100.0));
else if (device == "mic")
Manager::instance().setMicVolume ( (int) (value * 100.0));
volumeChanged (device, value);
}
......@@ -145,11 +137,10 @@ CallManager::setVolume (const std::string& device, const double& value)
double
CallManager::getVolume (const std::string& device)
{
if (device == "speaker") {
return Manager::instance().getSpkrVolume() /100.0;
} else if (device == "mic") {
return Manager::instance().getMicVolume() /100.0;
}
if (device == "speaker")
return Manager::instance().getSpkrVolume() / 100.0;
else if (device == "mic")
return Manager::instance().getMicVolume() / 100.0;
return 0;
}
......@@ -279,7 +270,7 @@ CallManager::playDTMF (const std::string& key)
void
CallManager::startTone (const int32_t& start , const int32_t& type)
{
if (start == true) {
if (start) {
if (type == 0)
Manager::instance().playTone();
else
......@@ -292,14 +283,13 @@ CallManager::startTone (const int32_t& start , const int32_t& type)
// for conferencing in order to get
// the right pointer for the given
// callID.
sfl::AudioZrtpSession * CallManager::getAudioZrtpSession (const std::string& callID)
sfl::AudioZrtpSession *
CallManager::getAudioZrtpSession(const std::string& callID)
{
SIPVoIPLink * link = NULL;
link = dynamic_cast<SIPVoIPLink *> (Manager::instance().getAccountLink (""));
SIPVoIPLink * link = dynamic_cast<SIPVoIPLink *>(Manager::instance().getAccountLink(""));
if (!link) {
if (!link)
throw CallManagerException("Failed to get sip link");
}
SIPCall *call;
try {
......@@ -324,8 +314,6 @@ CallManager::setSASVerified (const std::string& callID)
zSession = getAudioZrtpSession (callID);
zSession->SASVerified();
} catch (...) {
return;
// throw;
}
}
......@@ -337,8 +325,6 @@ CallManager::resetSASVerified (const std::string& callID)
zSession = getAudioZrtpSession (callID);
zSession->resetSASVerified();
} catch (...) {
return;
// throw;
}
}
......@@ -350,8 +336,6 @@ CallManager::setConfirmGoClear (const std::string& callID)
zSession = getAudioZrtpSession (callID);
zSession->goClearOk();
} catch (...) {
return;
// throw;
}
}
......@@ -363,8 +347,6 @@ CallManager::requestGoClear (const std::string& callID)
zSession = getAudioZrtpSession (callID);
zSession->requestGoClear();
} catch (...) {
return;
/// throw;
}
}
......@@ -376,8 +358,6 @@ CallManager::acceptEnrollment (const std::string& callID, const bool& accepted)
zSession = getAudioZrtpSession (callID);
zSession->acceptEnrollment (accepted);
} catch (...) {
return;
// throw;
}
}
......@@ -389,14 +369,12 @@ CallManager::setPBXEnrollment (const std::string& callID, const bool& yesNo)
zSession = getAudioZrtpSession (callID);
zSession->setPBXEnrollment (yesNo);
} catch (...) {
return;
// throw;
}
}
void
CallManager::sendTextMessage (const std::string& callID, const std::string& message)
{
if (!Manager::instance().sendTextMessage (callID, message, "Me"))
if (!Manager::instance().sendTextMessage(callID, message, "Me"))
throw CallManagerException();
}
......@@ -68,7 +68,7 @@
#include <sys/stat.h> // mkdir(2)
ManagerImpl::ManagerImpl (void) :
_hasTriedToRegister (false), _config(), _currentCallId2(),
_hasTriedToRegister (false), _config(), currentCallId_(),
_currentCallMutex(), _audiodriver (0),
_dtmfKey (0), _toneMutex(),
_telephoneTone (0), _audiofile (0), _spkr_volume (0),
......@@ -159,25 +159,25 @@ void ManagerImpl::terminate ()
bool ManagerImpl::isCurrentCall (const std::string& callId)
{
return _currentCallId2 == callId;
return currentCallId_ == callId;
}
bool ManagerImpl::hasCurrentCall ()
{
return not _currentCallId2.empty();
return not currentCallId_.empty();
}
const std::string&
ManagerImpl::getCurrentCallId () const
{
return _currentCallId2;
return currentCallId_;
}
void ManagerImpl::switchCall (const std::string& id)
{
ost::MutexLock m (_currentCallMutex);
_debug ("----- Switch current call id to %s -----", id.c_str());
_currentCallId2 = id;
currentCallId_ = id;
}
///////////////////////////////////////////////////////////////////////////////
......@@ -360,7 +360,7 @@ void ManagerImpl::hangupCall (const std::string& callId)
if (conf != NULL) {
// remove this participant
removeParticipant (callId);
processRemainingParticipant (currentCallId, conf);
processRemainingParticipants(currentCallId, conf);
}
} else {
// we are not participating to a conference, current call switched to ""
......@@ -393,18 +393,21 @@ bool ManagerImpl::hangupConference (const std::string& id)
ConferenceMap::iterator iter_conf = _conferencemap.find (id);
std::string currentAccountId;
if (iter_conf != _conferencemap.end()) {
Conference *conf = iter_conf->second;
const ParticipantSet &participants = conf->getParticipantList();
ParticipantSet::const_iterator iter;
for (iter = participants.begin(); iter != participants.end(); ++iter)
hangupCall (*iter);
if (conf) {
ParticipantSet participants(conf->getParticipantList());
for (ParticipantSet::const_iterator iter = participants.begin();
iter != participants.end(); ++iter)
hangupCall(*iter);
}
else {
_error("Manager: No such conference %s", id.c_str());
return false;
}
}
switchCall ("");
switchCall("");
getMainBuffer()->stateInfo();
......@@ -522,7 +525,7 @@ bool ManagerImpl::transferCall (const std::string& callId, const std::string& to
{
if (participToConference(callId)) {
removeParticipant (callId);
processRemainingParticipant (callId, getConferenceFromCallID(callId));
processRemainingParticipants(callId, getConferenceFromCallID(callId));
} else if (!isConference(getCurrentCallId()))
switchCall("");
......@@ -561,7 +564,7 @@ bool ManagerImpl::attendedTransfer(const std::string& transferID, const std::str
return SIPVoIPLink::instance()->attendedTransfer(transferID, targetID);
// Classic call, attached to an account
std::string accountid = getAccountFromCall(transferID);
std::string accountid(getAccountFromCall(transferID));
if (accountid.empty())
return false;
......@@ -627,7 +630,7 @@ void ManagerImpl::removeConference (const std::string& conference_id)
{
_debug ("Manager: Remove conference %s", conference_id.c_str());
_debug ("Manager: number of participant: %d", (int) _conferencemap.size());
_debug ("Manager: number of participants: %u", _conferencemap.size());
ConferenceMap::iterator iter = _conferencemap.find (conference_id);
Conference* conf = NULL;
......@@ -641,14 +644,14 @@ void ManagerImpl::removeConference (const std::string& conference_id)
}
// broadcast a signal over dbus
_dbus.getCallManager()->conferenceRemoved (conference_id);
_dbus.getCallManager()->conferenceRemoved(conference_id);
// We now need to bind the audio to the remain participant
// Unbind main participant audio from conference
getMainBuffer()->unBindAll (Call::DEFAULT_ID);
const ParticipantSet &participants = conf->getParticipantList();
ParticipantSet participants(conf->getParticipantList());
// bind main participant audio to remaining conference call
ParticipantSet::iterator iter_p = participants.begin();
......@@ -657,7 +660,7 @@ void ManagerImpl::removeConference (const std::string& conference_id)
getMainBuffer()->bindCallID (*iter_p, Call::DEFAULT_ID);
// Then remove the conference from the conference map
if (_conferencemap.erase (conference_id) == 1)
if (_conferencemap.erase(conference_id) == 1)
_debug ("Manager: Conference %s removed successfully", conference_id.c_str());
else
_error ("Manager: Error: Cannot remove conference: %s", conference_id.c_str());
......@@ -668,10 +671,8 @@ void ManagerImpl::removeConference (const std::string& conference_id)
Conference*
ManagerImpl::getConferenceFromCallID (const std::string& call_id)
{
std::string account_id;
account_id = getAccountFromCall (call_id);
Call *call = getAccountLink (account_id)->getCall (call_id);
std::string account_id(getAccountFromCall(call_id));
Call *call = getAccountLink(account_id)->getCall(call_id);
ConferenceMap::const_iterator iter = _conferencemap.find (call->getConfId());
......@@ -694,11 +695,11 @@ void ManagerImpl::holdConference (const std::string& id)
conf->getState() == Conference::ACTIVE_DETACHED_REC ||
conf->getState() == Conference::HOLD_REC;
const ParticipantSet &participants = conf->getParticipantList();
ParticipantSet::const_iterator iter;
for (iter = participants.begin(); iter != participants.end(); ++iter) {
switchCall (*iter);
onHoldCall (*iter);
ParticipantSet participants(conf->getParticipantList());
for (ParticipantSet::const_iterator iter = participants.begin();
iter != participants.end(); ++iter) {
switchCall(*iter);
onHoldCall(*iter);
}
conf->setState(isRec ? Conference::HOLD_REC : Conference::HOLD);
......@@ -715,7 +716,7 @@ void ManagerImpl::unHoldConference (const std::string& id)
conf->getState() == Conference::ACTIVE_DETACHED_REC or
conf->getState() == Conference::HOLD_REC;
const ParticipantSet &participants(conf->getParticipantList());
ParticipantSet participants(conf->getParticipantList());
for (ParticipantSet::const_iterator iter = participants.begin(); iter!= participants.end(); ++iter) {
Call *call = getAccountLink(getAccountFromCall(*iter))->getCall(*iter);
......@@ -808,7 +809,7 @@ void ManagerImpl::addParticipant (const std::string& callId, const std::string&
conf->bindParticipant (callId);
}
const ParticipantSet &participants(conf->getParticipantList());
ParticipantSet participants(conf->getParticipantList());
if (participants.empty())
_error("Manager: Error: Participant list is empty for this conference");
......@@ -841,7 +842,7 @@ void ManagerImpl::addMainParticipant (const std::string& conference_id)
if (iter != _conferencemap.end()) {
Conference *conf = iter->second;
const ParticipantSet &participants = conf->getParticipantList();
ParticipantSet participants(conf->getParticipantList());
for (ParticipantSet::const_iterator iter_p = participants.begin();
iter_p != participants.end(); ++iter_p) {
......@@ -1051,7 +1052,7 @@ void ManagerImpl::detachParticipant (const std::string& call_id,
else {
onHoldCall (call_id);
removeParticipant (call_id);
processRemainingParticipant (current_call_id, conf);
processRemainingParticipants(current_call_id, conf);
}
_dbus.getCallManager()->conferenceChanged (conf->getConfID(), conf->getStateStr());
} else {
......@@ -1111,9 +1112,9 @@ void ManagerImpl::removeParticipant (const std::string& call_id)
_dbus.getCallManager()->conferenceChanged (conf->getConfID(), conf->getStateStr());
}
void ManagerImpl::processRemainingParticipant (const std::string &current_call_id, Conference *conf)
void ManagerImpl::processRemainingParticipants(const std::string &current_call_id, Conference *conf)
{
const ParticipantSet &participants = conf->getParticipantList();
ParticipantSet participants(conf->getParticipantList());
size_t n = participants.size();
_debug ("Manager: Process remaining %d participant(s) from conference %s",
n, conf->getConfID().c_str());
......@@ -1123,7 +1124,7 @@ void ManagerImpl::processRemainingParticipant (const std::string &current_call_i
for (ParticipantSet::const_iterator iter_p = participants.begin();
iter_p != participants.end();
++iter_p)
getMainBuffer()->flush (*iter_p);
getMainBuffer()->flush(*iter_p);
getMainBuffer()->flush (Call::DEFAULT_ID);
} else if (n == 1) {
......@@ -1133,7 +1134,7 @@ void ManagerImpl::processRemainingParticipant (const std::string &current_call_i
if (iter_participant != participants.end()) {
// this call is no more a conference participant
std::string currentAccountId(getAccountFromCall (*iter_participant));
std::string currentAccountId(getAccountFromCall(*iter_participant));
Call *call = getAccountLink(currentAccountId)->getCall(*iter_participant);
call->setConfId ("");
......@@ -1146,7 +1147,7 @@ void ManagerImpl::processRemainingParticipant (const std::string &current_call_i
removeConference (conf->getConfID());
} else {
_debug ("Manager: No remaining participant, remove conference");
_debug ("Manager: No remaining participants, remove conference");
removeConference (conf->getConfID());
switchCall ("");
}
......@@ -1169,7 +1170,7 @@ void ManagerImpl::joinConference (const std::string& conf_id1,
return;
}
const ParticipantSet &participants(conf1->getParticipantList());
ParticipantSet participants(conf1->getParticipantList());
for (ParticipantSet::const_iterator iter_p = participants.begin();
iter_p != participants.end(); ++iter_p) {
......@@ -1196,7 +1197,7 @@ void ManagerImpl::addStream (const std::string& call_id)
conf->bindParticipant (call_id);
const ParticipantSet &participants(conf->getParticipantList());
ParticipantSet participants(conf->getParticipantList());
// reset ring buffer for all conference participant
for (ParticipantSet::const_iterator iter_p = participants.begin();
......@@ -1407,7 +1408,7 @@ void ManagerImpl::incomingMessage (const std::string& callID,
if (participToConference (callID)) {
Conference *conf = getConferenceFromCallID (callID);
const ParticipantSet &participants = conf->getParticipantList();
ParticipantSet participants(conf->getParticipantList());
for (ParticipantSet::const_iterator iter_p = participants.begin();
iter_p != participants.end(); ++iter_p) {
......@@ -1450,7 +1451,7 @@ bool ManagerImpl::sendTextMessage (const std::string& callID, const std::string&
if (!conf)
return false;