From d57b955d70ffaf7a7f8e041dd73328d40da6aeba Mon Sep 17 00:00:00 2001
From: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
Date: Thu, 24 Apr 2008 10:57:10 -0400
Subject: [PATCH] History - Entirely functionnal ?

+ stop desktop notification if an action occured before the timeout
---
 sflphone-gtk/src/actions.c   |  7 +++++++
 sflphone-gtk/src/sflnotify.c | 12 ++++++++++++
 sflphone-gtk/src/sflnotify.h |  5 +++++
 3 files changed, 24 insertions(+)

diff --git a/sflphone-gtk/src/actions.c b/sflphone-gtk/src/actions.c
index 04312bd868..bfc57bc72b 100644
--- a/sflphone-gtk/src/actions.c
+++ b/sflphone-gtk/src/actions.c
@@ -119,6 +119,7 @@ sflphone_hung_up( call_t * c)
 {
   call_list_remove( current_calls, c->callID);
   update_call_tree_remove(current_calls, c);
+  c->state = CALL_STATE_DIALING;
   update_menus();
   status_tray_icon_blink( FALSE );
 }
@@ -231,6 +232,7 @@ sflphone_hang_up()
 			case CALL_STATE_INCOMING:  
 				dbus_refuse (selectedCall);
 				selectedCall->state = CALL_STATE_DIALING;
+				stop_notification();
 				break;
 			case CALL_STATE_TRANSFERT:  
 				dbus_hang_up (selectedCall);
@@ -255,7 +257,10 @@ sflphone_pick_up()
 				sflphone_place_call (selectedCall);
 				break;
 			case CALL_STATE_INCOMING:
+				selectedCall->history_state = INCOMING;
+				update_call_tree( history , selectedCall );
 				dbus_accept (selectedCall);
+				stop_notification();
 				break;
 			case CALL_STATE_HOLD:
 				sflphone_new_call();
@@ -510,9 +515,11 @@ sflphone_keypad( guint keyval, gchar * key)
 						c->history_state = INCOMING;
 						update_call_tree( history , c );
 						dbus_accept(c);
+						stop_notification();
 						break;
 					case 65307: /* ESCAPE */
 						dbus_refuse(c);
+						stop_notification();
 						break;
 				}
 				break;
diff --git a/sflphone-gtk/src/sflnotify.c b/sflphone-gtk/src/sflnotify.c
index 7ff7debd97..fcfca766d3 100644
--- a/sflphone-gtk/src/sflnotify.c
+++ b/sflphone-gtk/src/sflnotify.c
@@ -60,6 +60,8 @@ notify_incoming_call( call_t* c  )
 answer_call_cb( NotifyNotification *notification, gpointer data  )
 {
   call_t* c = (call_t*)g_object_get_data( G_OBJECT( notification ) , "call" );
+  c->history_state = INCOMING;
+  update_call_tree( history , c );
   dbus_accept(c);
   if( __POPUP_WINDOW )
     status_icon_unminimize();
@@ -213,3 +215,13 @@ notify_no_registered_accounts(  )
     g_print("notify(), failed to send notification\n");
   }
 }
+
+void  
+stop_notification( void )
+{
+  if(notify_notification_show( notification , NULL))  
+  {
+    notify_notification_close( notification , NULL);
+    g_object_unref( notification );
+  }
+}
diff --git a/sflphone-gtk/src/sflnotify.h b/sflphone-gtk/src/sflnotify.h
index 5f3bf31304..af383396f6 100644
--- a/sflphone-gtk/src/sflnotify.h
+++ b/sflphone-gtk/src/sflnotify.h
@@ -97,4 +97,9 @@ void ignore_call_cb( NotifyNotification *notification, gpointer data );
  */
 void setup_accounts_cb(NotifyNotification *notification, gpointer data);
 
+/**
+ * Stop and close the current notification if an action occured before the timeout
+ */
+void stop_notification( void );
+
 #endif
-- 
GitLab