Skip to content
Snippets Groups Projects
Commit 2f6f1822 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#3218] Fix free_callable_obj_t method related segfaults

parent 26f3f2c2
No related branches found
No related tags found
No related merge requests found
......@@ -38,6 +38,9 @@ GQueue * accountQueue;
/* GCompareFunc to compare a accountID (gchar* and a account_t) */
gint is_accountID_struct ( gconstpointer a, gconstpointer b) {
if(!a || !b)
return 1;
account_t * c = (account_t*)a;
if(strcmp(c->accountID, (gchar*) b) == 0)
{
......@@ -150,7 +153,7 @@ account_list_get_current( )
// So we get the first one
current = account_list_get_by_state (ACCOUNT_STATE_REGISTERED);
if (!current)
return NULL;
return NULL;
return current;
}
......@@ -248,12 +251,14 @@ account_list_get_registered_accounts( void )
{
guint res = 0;
unsigned int i;
for(i=0;i<account_list_get_size();i++)
{
if( account_list_get_nth( i ) -> state == ( ACCOUNT_STATE_REGISTERED ))
res ++;
}
DEBUG(" %d registered accounts" , res );
DEBUG("Account: %d registered accounts" , res );
return res;
}
......
......@@ -60,24 +60,28 @@ sflphone_notify_voice_mail (const gchar* accountID , guint count)
{
gchar *id;
gchar *current_id;
account_t *current;
account_t *current;
// We want to notify only the current account; ie the first in the list
id = g_strdup (accountID);
current_id = account_list_get_current_id ();
DEBUG("sflphone_notify_voice_mail begin");
if (g_strcasecmp (id, current_id) != 0 || account_list_get_size() == 0)
return;
// Set the number of voice messages for the current account
current_account_set_message_number (count);
current = account_list_get_current ();
// Set the number of voice messages for the current account
current_account_set_message_number (count);
current = account_list_get_current ();
// Update the voicemail tool button
update_voicemail_status ();
// Update the voicemail tool button
update_voicemail_status ();
if (current)
notify_voice_mails (count, current);
if (current)
notify_voice_mails (count, current);
DEBUG("sflphone_notify_voice_mail end");
}
/*
......@@ -118,6 +122,8 @@ status_bar_display_account ()
statusbar_pop_message(__MSG_ACCOUNT_DEFAULT);
DEBUG("status_bar_display_account begin");
acc = account_list_get_current ();
if(acc){
status_tray_icon_online(TRUE);
......@@ -133,6 +139,8 @@ status_bar_display_account ()
}
statusbar_push_message( msg , __MSG_ACCOUNT_DEFAULT);
g_free(msg);
DEBUG("status_bar_display_account_end");
}
......@@ -185,11 +193,11 @@ sflphone_hung_up( callable_obj_t * c)
calltree_remove_call(current_calls, c, NULL);
c->_state = CALL_STATE_DIALING;
call_remove_all_errors(c);
free_callable_obj_t(c);
update_actions();
#if GTK_CHECK_VERSION(2,10,0)
status_tray_icon_blink( FALSE );
#endif
free_callable_obj_t(c);
}
static hashtable_free(gpointer key, gpointer value, gpointer user_data)
......@@ -896,12 +904,16 @@ static int _place_registered_call(callable_obj_t * c) {
return -1;
}
DEBUG("place_registered_call begin");
if(g_strcasecmp(c->_accountID, "") != 0) {
current = account_list_get_by_id(c->_accountID);
} else {
current = account_list_get_current();
}
DEBUG("place_registered_call end");
if(current == NULL) {
DEBUG("Unexpected condition: account_t is NULL in %s at %d for accountID %s", __FILE__, __LINE__, c->_accountID);
return -1;
......
......@@ -131,13 +131,43 @@ void call_remove_all_errors(callable_obj_t * call)
void *threaded_clock_incrementer(void *pc) {
int count = 0;
callable_obj_t *call = (callable_obj_t *)pc;
while(call->clockStarted) {
DEBUG("Clock started: %d", call->clockStarted);
DEBUG("Clock: %d\n", count++);
gchar *res;
int duration;
time_t start, current;
set_timestamp(&(call->_time_current));
start = call->_time_start;
current = call->_time_current;
if (current == start)
DEBUG("<small>Duration:</small> 0:00");
// return g_markup_printf_escaped("<small>Duration:</small> 0:00");
duration = (int) difftime(current, start);
if( duration / 60 == 0 )
{
if( duration < 10 )
res = g_markup_printf_escaped("00:0%i", duration);
else
res = g_markup_printf_escaped("00:%i", duration);
}
else
{
if( duration%60 < 10 )
res = g_markup_printf_escaped("%i:0%i" , duration/60 , duration%60);
else
res = g_markup_printf_escaped("%i:%i" , duration/60 , duration%60);
}
// return g_markup_printf_escaped("<small>Duration:</small> %s", res);
DEBUG("%s", res);
sleep(1);
}
}
......@@ -165,6 +195,7 @@ void create_new_call (callable_type_t type, call_state_t state, gchar* callID ,
obj->_trsft_to = "";
set_timestamp (&(obj->_time_start));
set_timestamp (&(obj->_time_current));
set_timestamp (&(obj->_time_stop));
if (g_strcasecmp (callID, "") == 0)
......
......@@ -199,7 +199,7 @@ statusicon_set_tooltip()
// Add a tooltip to the system tray icon
count = account_list_get_registered_accounts();
tip = g_markup_printf_escaped("%s - %s", _("SFLphone"),
g_markup_printf_escaped(n_("%i active account", "%i active accounts", count), count));
g_markup_printf_escaped(n_("%i active account", "%i active accounts", count), count));
gtk_status_icon_set_tooltip(status, tip);
g_free(tip);
......@@ -211,7 +211,7 @@ status_tray_icon_blink(gboolean active)
{
if (status) {
// Set a different icon to notify of an event
active ? gtk_status_icon_set_from_file(status, LOGO_NOTIF)
active ? gtk_status_icon_set_from_file(status, LOGO_NOTIF)
: gtk_status_icon_set_from_file(status, LOGO);
}
}
......
......@@ -47,7 +47,7 @@ call_mailbox( GtkWidget* widget UNUSED, gpointer data UNUSED)
account_id = g_strdup (current->accountID);
create_new_call (CALL, CALL_STATE_DIALING, "", account_id, _("Voicemail"), to, &mailbox_call);
DEBUG("TO : %s" , mailbox_call->_peer_number);
DEBUG("Call: TO : %s" , mailbox_call->_peer_number);
calllist_add( current_calls , mailbox_call );
calltree_add_call( current_calls, mailbox_call, NULL);
update_actions();
......@@ -61,7 +61,6 @@ call_mailbox( GtkWidget* widget UNUSED, gpointer data UNUSED)
static void
call_button( GtkWidget *widget UNUSED, gpointer data UNUSED)
{
DEBUG("------ call_button -----");
callable_obj_t * selectedCall;
callable_obj_t* new_call;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment