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();
}
This diff is collapsed.
......@@ -942,7 +942,7 @@ class ManagerImpl
* @param current call id
* @param conference pointer
*/
void processRemainingParticipant (const std::string &current_call_id, Conference *conf);
void processRemainingParticipants(const std::string &current_call_id, Conference *conf);
/**
* Create config directory in home user and return configuration file path
......@@ -978,7 +978,7 @@ class ManagerImpl
Conf::ConfigTree _config;
/** Current Call ID */
std::string _currentCallId2;
std::string currentCallId_;
/** Protected current call access */
ost::Mutex _currentCallMutex;
......
......@@ -93,7 +93,7 @@ account_list_get_by_state (account_state_t state)
}
account_t *
account_list_get_by_id (gchar * accountID)
account_list_get_by_id (const gchar * const accountID)
{
GList * c = g_queue_find_custom (accountQueue, accountID, is_accountID_struct);
......
......@@ -153,7 +153,7 @@ void account_list_free ();
* @param accountID The ID of the account
* @return An account or NULL
*/
account_t * account_list_get_by_id (gchar * accountID);
account_t * account_list_get_by_id (const gchar * const accountID);
/**
* Move the account from an unit up in the account_list
......
......@@ -55,6 +55,7 @@
#include "actions.h"
#include "dbus/dbus.h"
#include "logger.h"
#include "contacts/calltab.h"
#include "contacts/searchbar.h"
#include "contacts/addrbookfactory.h"
#include "icons/icon_factory.h"
......@@ -220,7 +221,7 @@ sflphone_hung_up (callable_obj_t * c)
DEBUG ("SFLphone: Hung up");
calllist_remove_call (current_calls, c->_callID);
calltree_remove_call (current_calls, c, NULL);
calltree_remove_call (current_calls, c);
c->_state = CALL_STATE_DIALING;
call_remove_all_errors (c);
update_actions();
......@@ -368,7 +369,11 @@ sflphone_hang_up()
DEBUG ("SFLphone: Hang up");
if (selectedCall) {
if (selectedConf) {
im_widget_update_state (IM_WIDGET (selectedConf->_im_widget), FALSE);
dbus_hang_up_conference (selectedConf);
}
else if (selectedCall) {
switch (selectedCall->_state) {
case CALL_STATE_DIALING:
dbus_hang_up (selectedCall);
......@@ -411,9 +416,6 @@ sflphone_hang_up()
WARN ("Should not happen in sflphone_hang_up()!");
break;
}
} else if (selectedConf) {
im_widget_update_state (IM_WIDGET (selectedConf->_im_widget), FALSE);
dbus_hang_up_conference (selectedConf);
}
calltree_update_call (history, selectedCall, NULL);
......@@ -454,7 +456,7 @@ sflphone_pick_up()
case CALL_STATE_TRANSFER:
dbus_transfer (selectedCall);
time (&selectedCall->_time_stop);
calltree_remove_call(current_calls, selectedCall, NULL);
calltree_remove_call(current_calls, selectedCall);
calllist_remove_call(current_calls, selectedCall->_callID);
break;
case CALL_STATE_CURRENT:
......@@ -750,7 +752,7 @@ sflphone_keypad (guint keyval, gchar * key)
case GDK_KP_Enter:
dbus_transfer (c);
time (&c->_time_stop);
calltree_remove_call(current_calls, c, NULL);
calltree_remove_call(current_calls, c);
break;
case GDK_Escape:
sflphone_unset_transfer ();
......@@ -897,7 +899,7 @@ sflphone_detach_participant (const gchar* callID)
selectedCall->_confID = NULL;
}
im_widget_update_state (IM_WIDGET (selectedCall->_im_widget), TRUE);
calltree_remove_call (current_calls, selectedCall, NULL);
calltree_remove_call (current_calls, selectedCall);
calltree_add_call (current_calls, selectedCall, NULL);
dbus_detach_participant (selectedCall->_callID);
}
......
......@@ -32,6 +32,7 @@
#include "codeclist.h"
#include "sflphone_const.h"
#include <time.h>
#include "contacts/calltab.h"
#include "contacts/calltree.h"
#include "dbus.h"
#include <unistd.h>
......
......@@ -31,10 +31,9 @@
#ifndef __CALLABLE_OBJ_H__
#define __CALLABLE_OBJ_H__
#include <gtk/gtk.h>
#include <glib/gprintf.h>
#include <stdlib.h>
#include <time.h>
#include <gtk/gtk.h>
/**
* @enum history_state
......@@ -98,7 +97,6 @@ typedef enum {
* This struct holds information about a call.
*/
typedef struct {
callable_type_t _type; // CALL - HISTORY ENTRY - CONTACT
call_state_t _state; // The state of the call
int _state_code; // The numeric state code as defined in SIP or IAX
......@@ -200,8 +198,7 @@ gchar* call_get_peer_name (const gchar*);
*/
gchar* call_get_peer_number (const gchar*);
void
free_callable_obj_t (callable_obj_t *c);
void free_callable_obj_t (callable_obj_t *c);
gchar* get_peer_info (const gchar* const, const gchar* const);
......
......@@ -37,10 +37,8 @@
#include "calltab.h"
#include "calllist.h"
conference_obj_t *create_new_conference (conference_state_t state, const gchar* const confID)
conference_obj_t *create_new_conference(conference_state_t state, const gchar* const confID)
{
conference_obj_t *new_conf;
if (confID == NULL) {
ERROR("Conference: Error: Conference ID is NULL while creating new conference");
return NULL;
......@@ -49,7 +47,7 @@ conference_obj_t *create_new_conference (conference_state_t state, const gchar*
DEBUG ("Conference: Create new conference %s", confID);
// Allocate memory
new_conf = g_new0 (conference_obj_t, 1);
conference_obj_t *new_conf = g_new0(conference_obj_t, 1);
if (!new_conf) {
ERROR("Conference: Error: Could not allocate data ");
return NULL;
......@@ -61,14 +59,9 @@ conference_obj_t *create_new_conference (conference_state_t state, const gchar*
// Set the ID field
new_conf->_confID = g_strdup (confID);
new_conf->participant_list = NULL;
new_conf->participant_number = NULL;
new_conf->_recordfile = NULL;
new_conf->_record_is_playing = FALSE;
// set conference timestamp
time(&new_conf->_time_start);
g_assert(new_conf->_im_widget == NULL);
return new_conf;
}
......@@ -78,11 +71,6 @@ conference_obj_t *create_new_conference_from_details (const gchar *conf_id, GHas
conference_obj_t *new_conf = g_new0 (conference_obj_t, 1);
new_conf->_confID = g_strdup (conf_id);
new_conf->_conference_secured = FALSE;
new_conf->_conf_srtp_enabled = FALSE;
new_conf->participant_list = NULL;
gchar **participants = dbus_get_participant_list (conf_id);
if (participants) {
conference_participant_list_update (participants, new_conf);
......@@ -104,10 +92,6 @@ conference_obj_t *create_new_conference_from_details (const gchar *conf_id, GHas
else if (g_strcasecmp (state_str, "HOLD_REC") == 0)
new_conf->_state = CONFERENCE_STATE_HOLD_RECORD;
new_conf->_recordfile = NULL;
new_conf->_record_is_playing = FALSE;
return new_conf;
}
......@@ -132,7 +116,6 @@ void conference_add_participant_number(const gchar *call_id, conference_obj_t *c
}
gchar *number_account = g_strconcat(call->_peer_number, ",", call->_accountID, NULL);
conf->participant_number = g_slist_append(conf->participant_number, number_account);
}
......@@ -150,22 +133,18 @@ void conference_add_participant (const gchar* call_id, conference_obj_t* conf)
void conference_remove_participant (const gchar* call_id, conference_obj_t* conf)
{
// store the new participant list after removing participant id
conf->participant_list = g_slist_remove (conf->participant_list, (gconstpointer) call_id);
conf->participant_list = g_slist_remove(conf->participant_list, (gconstpointer) call_id);
}
GSList* conference_next_participant (GSList* participant)
{
return g_slist_next (participant);
return g_slist_next(participant);
}
void conference_participant_list_update (gchar** participants, conference_obj_t* conf)
{
gchar* call_id;
gchar** part;
callable_obj_t *call;
DEBUG ("Conference: Participant list update");
if (!conf) {
......@@ -173,9 +152,9 @@ void conference_participant_list_update (gchar** participants, conference_obj_t*
return;
}
for (part = participants; *part; part++) {
call_id = (gchar *) (*part);
call = calllist_get_call(current_calls, call_id);
for (gchar **part = participants; part && *part; part++) {
gchar *call_id = (gchar *) (*part);
callable_obj_t *call = calllist_get_call(current_calls, call_id);
if(call->_confID != NULL) {
g_free(call->_confID);
call->_confID = NULL;
......@@ -187,9 +166,9 @@ void conference_participant_list_update (gchar** participants, conference_obj_t*
conf->participant_list = NULL;
}
for (part = participants; *part; part++) {
call_id = (gchar*) (*part);
call = calllist_get_call(current_calls, call_id);
for (gchar **part = participants; part && *part; part++) {
gchar *call_id = (gchar*) (*part);
callable_obj_t *call = calllist_get_call(current_calls, call_id);
call->_confID = g_strdup(conf->_confID);
conference_add_participant (call_id, conf);
}
......@@ -213,7 +192,7 @@ gchar *serialize_history_conference_entry(conference_obj_t *entry)
time_start = g_strdup_printf ("%i", (int) entry->_time_start);
time_stop = g_strdup_printf ("%i", (int) entry->_time_stop);
peer_name = (entry->_confID == NULL || g_strcasecmp(entry->_confID, "") == 0) ? "empty": entry->_confID;
peer_name = (entry->_confID == NULL || (strlen(entry->_confID) == 0)) ? "empty": entry->_confID;
length = g_slist_length(entry->participant_list);
participant_list = entry->participant_list;
......@@ -228,15 +207,15 @@ gchar *serialize_history_conference_entry(conference_obj_t *entry)
}
result = g_strconcat("9999", separator,
participantstr, separator, // peer number
peer_name, separator,
time_start, separator,
time_stop, separator,
confID, separator,
"empty", separator, // peer AccountID
entry->_recordfile ? entry->_recordfile : "", separator,
"empty", separator,
"empty", NULL);
participantstr, separator, // peer number
peer_name, separator,
time_start, separator,
time_stop, separator,
confID, separator,
"empty", separator, // peer AccountID
entry->_recordfile ? entry->_recordfile : "", separator,
"empty", separator,
"empty", NULL);
return result;
}
......
......@@ -29,6 +29,7 @@
*/
#include "calllist.h"
#include "calltab.h"
#include "calltree.h"
#include "logger.h"
#include "contacts/searchbar.h"
......@@ -38,13 +39,13 @@ static
gint is_callID_callstruct(gconstpointer a, gconstpointer b)
{
const QueueElement *c = a;
if(c == NULL || c->type != HIST_CALL)
return 1;
if (c == NULL || c->type != HIST_CALL)
return 1;
return g_strcasecmp(c->elem.call->_callID, (const gchar *) b);
}
// TODO : sflphoneGTK : try to do this more generic
// TODO : try to do this more generically
void calllist_add_contact (gchar *contact_name, gchar *contact_phone, contact_type_t type, GdkPixbuf *photo)
{
/* Check if the information is valid */
......@@ -54,9 +55,9 @@ void calllist_add_contact (gchar *contact_name, gchar *contact_phone, contact_ty
callable_obj_t *new_call = create_new_call (CONTACT, CALL_STATE_DIALING, "", "", contact_name, contact_phone);
// Attach a pixbuf to a contact
if (photo) {
if (photo)
new_call->_contact_thumbnail = gdk_pixbuf_copy (photo);
} else {
else {
GdkPixbuf *pixbuf;
switch (type) {
case CONTACT_PHONE_BUSINESS:
......@@ -146,9 +147,9 @@ calllist_clean_history (void)
for (guint i = 0; i < size; i++) {
QueueElement* c = calllist_get_nth(history, i);
if (c->type == HIST_CALL)
calltree_remove_call (history, c->elem.call, NULL);
calltree_remove_call (history, c->elem.call);
else if(c->type == HIST_CONFERENCE)
calltree_remove_conference (history, c->elem.conf, NULL);
calltree_remove_conference (history, c->elem.conf);
}
calllist_reset (history);
......@@ -158,16 +159,15 @@ void
calllist_remove_from_history (callable_obj_t* c)
{
calllist_remove_call(history, c->_callID);
calltree_remove_call(history, c, NULL);
calltree_remove_call(history, c);
}
void
calllist_remove_call (calltab_t* tab, const gchar * callID)
{
GList *c = g_queue_find_custom (tab->callQueue, callID, is_callID_callstruct);
if (c == NULL) {
if (c == NULL)
return;
}
QueueElement *element = (QueueElement *)c->data;
if (element->type != HIST_CALL) {
......
......@@ -31,8 +31,8 @@
#ifndef __CALLTAB_H__
#define __CALLTAB_H__
#include <calllist.h>
#include <conferencelist.h>
#include "calllist.h"
#include "conferencelist.h"
#include <gtk/gtk.h>
calltab_t* active_calltree;
......
This diff is collapsed.
......@@ -32,15 +32,6 @@
#ifndef __CALLTREE_H__