From 1aef40b4802a9865ed354b5ea8ac82744690356d Mon Sep 17 00:00:00 2001
From: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
Date: Tue, 17 Nov 2009 11:23:59 -0500
Subject: [PATCH] [#2384] Tags incoming call as direct SIP call, if applicable

---
 lang/fr/fr.po                           |  2 +-
 sflphone-client-gnome/po/fr/fr.po       |  5 +-
 sflphone-client-gnome/src/accountlist.h | 17 ++++---
 sflphone-client-gnome/src/actions.c     | 61 +++++++++++++++----------
 sflphone-client-gnome/src/dbus/dbus.c   |  3 +-
 5 files changed, 49 insertions(+), 39 deletions(-)

diff --git a/lang/fr/fr.po b/lang/fr/fr.po
index 0f7f47cfed..53c670db0e 100644
--- a/lang/fr/fr.po
+++ b/lang/fr/fr.po
@@ -80,7 +80,7 @@ msgstr ""
 
 #: ../sflphone-client-gnome/src/actions.c:879
 msgid "Direct SIP call"
-msgstr "Appels IP"
+msgstr "Appel direct SIP"
 
 #: ../sflphone-client-gnome/src/actions.c:1071
 #, c-format
diff --git a/sflphone-client-gnome/po/fr/fr.po b/sflphone-client-gnome/po/fr/fr.po
index d402e0c484..53c670db0e 100644
--- a/sflphone-client-gnome/po/fr/fr.po
+++ b/sflphone-client-gnome/po/fr/fr.po
@@ -80,7 +80,7 @@ msgstr ""
 
 #: ../sflphone-client-gnome/src/actions.c:879
 msgid "Direct SIP call"
-msgstr "Appels IP"
+msgstr "Appel direct SIP"
 
 #: ../sflphone-client-gnome/src/actions.c:1071
 #, c-format
@@ -303,8 +303,9 @@ msgid "About SFLphone"
 msgstr "A propos de SFLphone"
 
 #: ../sflphone-client-gnome/src/uimanager.c:654
+#, fuzzy
 msgid "Call"
-msgstr "Actions"
+msgstr "_Actions"
 
 #: ../sflphone-client-gnome/src/uimanager.c:655
 #: ../sflphone-client-gnome/src/uimanager.c:1119
diff --git a/sflphone-client-gnome/src/accountlist.h b/sflphone-client-gnome/src/accountlist.h
index cf87d3ca8e..9823a9a387 100644
--- a/sflphone-client-gnome/src/accountlist.h
+++ b/sflphone-client-gnome/src/accountlist.h
@@ -64,15 +64,14 @@ typedef enum
   */
 
 typedef struct  {
-  gchar * accountID;
-  account_state_t state;
-  gchar * protocol_state_description;
-  guint protocol_state_code;  
-  GHashTable * properties;
-  GPtrArray * credential_information;
-
-  guint _messages_number;
-
+ 	gchar * accountID;
+  	account_state_t state;
+  	gchar * protocol_state_description;
+  	guint protocol_state_code;  
+  	GHashTable * properties;
+  	GPtrArray * credential_information;
+
+  	guint _messages_number;
 } account_t;
 
 
diff --git a/sflphone-client-gnome/src/actions.c b/sflphone-client-gnome/src/actions.c
index b0bbe93cc7..598a91f7c7 100644
--- a/sflphone-client-gnome/src/actions.c
+++ b/sflphone-client-gnome/src/actions.c
@@ -58,6 +58,32 @@ sflphone_notify_voice_mail (const gchar* accountID , guint count)
 		notify_voice_mails (count, current);
 }
 
+/*
+ * Place a call with the current account.
+ * If there is no default account selected, place a call with the first
+ * registered account of the account list
+ * Else, check if it an IP call. if not, popup an error message
+ */
+ 
+static gboolean _is_direct_call(callable_obj_t * c) {
+
+    if(g_strcasecmp(c->_accountID, EMPTY_ENTRY) == 0) {
+        if(!g_str_has_prefix (c->_peer_number, "sip:")) {
+            gchar * new_number = g_strconcat("sip:", c->_peer_number, NULL);
+            g_free(c->_peer_number);
+            c->_peer_number = new_number;
+        }
+        return 1;
+    }
+
+    if(g_str_has_prefix (c->_peer_number, "sip:")) {
+        return 1;
+    }
+
+    return 0;
+}
+
+
     void
 status_bar_display_account ()
 {
@@ -528,12 +554,22 @@ sflphone_display_transfer_status(const gchar* message)
     void
 sflphone_incoming_call (callable_obj_t * c)
 {
+	gchar *msg = "";
+
     c->_history_state = MISSED;
     calllist_add ( current_calls, c );
     calllist_add( history, c );
     calltree_add_call( current_calls, c, NULL);
     update_actions();
     calltree_display (current_calls);
+	
+	// Change the status bar if we are dealing with a direct SIP call
+    if(_is_direct_call(c)) {
+		msg = g_markup_printf_escaped (_("Direct SIP call"));
+        statusbar_pop_message(__MSG_ACCOUNT_DEFAULT);
+        statusbar_push_message( msg , __MSG_ACCOUNT_DEFAULT);
+        g_free(msg);
+	}
 }
 
     void
@@ -769,31 +805,6 @@ sflphone_keypad( guint keyval, gchar * key)
     }
 }
 
-/*
- * Place a call with the current account.
- * If there is no default account selected, place a call with the first
- * registered account of the account list
- * Else, check if it an IP call. if not, popup an error message
- */
- 
-static gboolean _is_direct_call(callable_obj_t * c) {
-
-    if(g_strcasecmp(c->_accountID, EMPTY_ENTRY) == 0) {
-        if(!g_str_has_prefix (c->_peer_number, "sip:")) {
-            gchar * new_number = g_strconcat("sip:", c->_peer_number, NULL);
-            g_free(c->_peer_number);
-            c->_peer_number = new_number;
-        }
-        return 1;
-    }
-
-    if(g_str_has_prefix (c->_peer_number, "sip:")) {
-        return 1;
-    }
-
-    return 0;
-}
-
 static int _place_direct_call(const callable_obj_t * c) {
     if (c->_state == CALL_STATE_DIALING) {
         dbus_place_call (c);
diff --git a/sflphone-client-gnome/src/dbus/dbus.c b/sflphone-client-gnome/src/dbus/dbus.c
index 7f9f0f7329..3a5798348a 100644
--- a/sflphone-client-gnome/src/dbus/dbus.c
+++ b/sflphone-client-gnome/src/dbus/dbus.c
@@ -50,8 +50,7 @@ incoming_call_cb (DBusGProxy *proxy UNUSED,
         const gchar* from,
         void * foo  UNUSED )
 {
-    DEBUG("Incoming call! %s", callID);
-    DEBUG("    from: %s", from);
+    DEBUG("Incoming call (%s) from %s", callID, from);
 
     callable_obj_t * c;
     gchar *peer_name, *peer_number;
-- 
GitLab