From b97419e234514dbb7b1d6bd3606058bf299ddb63 Mon Sep 17 00:00:00 2001 From: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> Date: Mon, 12 May 2008 17:20:23 -0400 Subject: [PATCH] Duplicate call_t struct when calling from the history The struct was reused when calling a number from the history, instead of being reallocated It should be reallocated so that the previous struct could be changed --- sflphone-gtk/src/calltree.c | 22 ++++++++++++++-------- sflphone-gtk/src/timestamp.c | 2 +- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/sflphone-gtk/src/calltree.c b/sflphone-gtk/src/calltree.c index 4820b05b1b..a27601147f 100644 --- a/sflphone-gtk/src/calltree.c +++ b/sflphone-gtk/src/calltree.c @@ -69,21 +69,27 @@ button_pressed(GtkWidget* widget, GdkEventButton *event, gpointer user_data) call_button( GtkWidget *widget, gpointer data ) { call_t * selectedCall; + call_t* newCall = g_new0 (call_t, 1); printf("Call button pressed\n"); if(call_list_get_size(current_calls)>0) sflphone_pick_up(); else if(call_list_get_size(active_calltree) > 0){ printf("Calling a called num\n"); selectedCall = call_get_selected(active_calltree); - if(!selectedCall->to){ - selectedCall->to = call_get_number(selectedCall); - selectedCall->from = g_strconcat("\"\" <", selectedCall->to, ">",NULL); - } + + newCall->to = g_strdup(call_get_number(selectedCall)); + newCall->from = g_strconcat("\"\" <", call_get_number(selectedCall), ">",NULL); + newCall->state = CALL_STATE_DIALING; + newCall->callID = g_new0(gchar, 30); + g_sprintf(newCall->callID, "%d", rand()); + newCall->_start = 0; + newCall->_stop = 0; + gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(historyButton), FALSE); - printf("call : from : %s to %s\n", selectedCall->from, selectedCall->to); - call_list_add(current_calls, selectedCall); - update_call_tree_add(current_calls, selectedCall); - sflphone_place_call(selectedCall); + printf("call : from : %s to %s\n", newCall->from, newCall->to); + call_list_add(current_calls, newCall); + update_call_tree_add(current_calls, newCall); + sflphone_place_call(newCall); }else sflphone_new_call(); } diff --git a/sflphone-gtk/src/timestamp.c b/sflphone-gtk/src/timestamp.c index ab8ff3c2d1..91d50c4c4c 100644 --- a/sflphone-gtk/src/timestamp.c +++ b/sflphone-gtk/src/timestamp.c @@ -41,7 +41,7 @@ process_call_duration( call_t* c ) gchar * res; g_print("Start = %i - Stop = %i - Call duration = %i\n", c->_start , c->_stop , (int)(c->_stop - c->_start)); - if( c->_stop == 0 ) + if( c->history_state == MISSED && c->_stop == 0 ) return g_markup_printf_escaped("<small>Missed call</small>"); int duration = c->_stop - c->_start; -- GitLab