From 4e7e439df50f2e6c38396214c1e6153b30e85e93 Mon Sep 17 00:00:00 2001
From: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
Date: Tue, 13 May 2008 10:16:47 -0400
Subject: [PATCH] Fix the hold case for call duration

---
 sflphone-gtk/src/actions.c  |  7 ++++---
 sflphone-gtk/src/calltree.c | 35 +++++++++++++++++++----------------
 2 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/sflphone-gtk/src/actions.c b/sflphone-gtk/src/actions.c
index 88a758bc5c..123590364c 100644
--- a/sflphone-gtk/src/actions.c
+++ b/sflphone-gtk/src/actions.c
@@ -347,10 +347,11 @@ sflphone_busy( call_t * c )
 void 
 sflphone_current( call_t * c )
 {
-	c->state = CALL_STATE_CURRENT;
-	update_call_tree(current_calls,c);
-	update_menus();
+  if( c->state != CALL_STATE_HOLD )
 	(void) time(&c->_start);
+  c->state = CALL_STATE_CURRENT;
+  update_call_tree(current_calls,c);
+  update_menus();
 }
 
 void 
diff --git a/sflphone-gtk/src/calltree.c b/sflphone-gtk/src/calltree.c
index 61dfb6eac5..bffd121ad9 100644
--- a/sflphone-gtk/src/calltree.c
+++ b/sflphone-gtk/src/calltree.c
@@ -81,30 +81,33 @@ button_pressed(GtkWidget* widget, GdkEventButton *event, gpointer user_data)
   static void 
 call_button( GtkWidget *widget, gpointer   data )
 {
-  call_t * selectedCall;
+  call_t * selectedCall = call_get_selected(active_calltree);
   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)
+    {
+      printf("Calling a called num\n");
     
-    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", newCall->from, newCall->to);
-    call_list_add(current_calls, newCall);
-    update_call_tree_add(current_calls, newCall);
-    sflphone_place_call(newCall);
+      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;
+
+      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);
+      if( active_calltree == history )  switch_tab();
+    }
   }else
     sflphone_new_call();
+    if( active_calltree == history )  switch_tab();
 }
 
 /**
-- 
GitLab