From 23b894cb28f659ff8e5863a14bea4bbf55bd428c Mon Sep 17 00:00:00 2001
From: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
Date: Thu, 4 Feb 2010 12:44:12 -0500
Subject: [PATCH] [#2518] Add a specific status for IP2IP_PROFILE

---
 sflphone-client-gnome/src/accountlist.c |  5 ++++-
 sflphone-client-gnome/src/accountlist.h |  5 +++--
 sflphone-client-gnome/src/actions.c     |  3 +++
 sflphone-common/src/managerimpl.cpp     | 26 +++++++++++++++++--------
 4 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/sflphone-client-gnome/src/accountlist.c b/sflphone-client-gnome/src/accountlist.c
index 3f5dbe4c05..d02e23c5fe 100644
--- a/sflphone-client-gnome/src/accountlist.c
+++ b/sflphone-client-gnome/src/accountlist.c
@@ -161,7 +161,7 @@ void account_list_set_current (account_t *current)
 }
 
 
-const gchar * account_state_name(account_state_t s)
+const gchar * account_state_name (account_state_t s)
 {
 	gchar * state;
 	switch(s)
@@ -193,6 +193,9 @@ const gchar * account_state_name(account_state_t s)
 		case ACCOUNT_STATE_ERROR_EXIST_STUN:
 			state = _("Stun server invalid");
 			break;
+		case IP2IP_PROFILE_STATUS:
+			state = _("Ready");
+			break;
 		default:
 			state = _("Invalid");
 			break;
diff --git a/sflphone-client-gnome/src/accountlist.h b/sflphone-client-gnome/src/accountlist.h
index 1d7cff710a..bb2de67319 100644
--- a/sflphone-client-gnome/src/accountlist.h
+++ b/sflphone-client-gnome/src/accountlist.h
@@ -50,8 +50,9 @@ typedef enum
    /** Stun server configuration error. The account is not registered */
    ACCOUNT_STATE_ERROR_CONF_STUN,
    /** Stun server is not existing. The account is not registered */
-   ACCOUNT_STATE_ERROR_EXIST_STUN
-
+   ACCOUNT_STATE_ERROR_EXIST_STUN,
+   /** IP profile status **/
+   IP2IP_PROFILE_STATUS
 } account_state_t;
 
 /** @struct account_t
diff --git a/sflphone-client-gnome/src/actions.c b/sflphone-client-gnome/src/actions.c
index a427845ede..ffe115d09b 100644
--- a/sflphone-client-gnome/src/actions.c
+++ b/sflphone-client-gnome/src/actions.c
@@ -265,6 +265,9 @@ void sflphone_fill_account_list (void) {
         {
             a->state = ACCOUNT_STATE_ERROR_EXIST_STUN;
         }
+		else if (strcmp (status, "READY") == 0) {
+			a->state = IP2IP_PROFILE_STATUS;
+		}
         else
         {
             a->state = ACCOUNT_STATE_INVALID;
diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp
index 17d59b27c6..84582f2cac 100644
--- a/sflphone-common/src/managerimpl.cpp
+++ b/sflphone-common/src/managerimpl.cpp
@@ -52,6 +52,7 @@
 #include <sys/stat.h>  // mkdir(2)
 #include <pwd.h>       // getpwuid
 
+#define DIRECT_IP_CALL	"IP CALL"
 
 #define fill_config_str(name, value) \
   (_config.addConfigTreeItem(section, Conf::ConfigTreeItem(std::string(name), std::string(value), type_str)))
@@ -3368,7 +3369,9 @@ std::map< std::string, std::string > ManagerImpl::getAccountDetails (const Accou
         _debug ("Cannot getAccountDetails on a non-existing accountID %s. Defaults will be used.", accountID.c_str());
     }
 
-    a.insert (std::pair<std::string, std::string> (CONFIG_ACCOUNT_ALIAS, getConfigString (accountID, CONFIG_ACCOUNT_ALIAS)));
+	// The IP profile does not allow to set an alias
+    (accountID == IP2IP_PROFILE) ? a.insert (std::pair<std::string, std::string> (CONFIG_ACCOUNT_ALIAS, DIRECT_IP_CALL)) : 
+									a.insert (std::pair<std::string, std::string> (CONFIG_ACCOUNT_ALIAS, getConfigString (accountID, CONFIG_ACCOUNT_ALIAS)));
 
     a.insert (std::pair<std::string, std::string> (CONFIG_ACCOUNT_ENABLE, getConfigString (accountID, CONFIG_ACCOUNT_ENABLE)));
     a.insert (std::pair<std::string, std::string> (CONFIG_ACCOUNT_RESOLVE_ONCE, getConfigString (accountID, CONFIG_ACCOUNT_RESOLVE_ONCE)));
@@ -3394,17 +3397,24 @@ std::map< std::string, std::string > ManagerImpl::getAccountDetails (const Accou
     std::string registrationStateDescription;
 
     if (account != NULL) {
-        state = account->getRegistrationState();
-        int code = account->getRegistrationStateDetailed().first;
-        std::stringstream out;
-        out << code;
-        registrationStateCode = out.str();
-        registrationStateDescription = account->getRegistrationStateDetailed().second;
+		if (accountID == IP2IP_PROFILE) {
+			registrationStateCode = EMPTY_FIELD;
+			registrationStateDescription = "Direct IP call";
+		}
+		else {
+			state = account->getRegistrationState();
+			int code = account->getRegistrationStateDetailed().first;
+			std::stringstream out;
+			out << code;
+			registrationStateCode = out.str();
+			registrationStateDescription = account->getRegistrationStateDetailed().second;
+		}
     } else {
         state = Unregistered;
     }
 
-    a.insert (std::pair<std::string, std::string> (REGISTRATION_STATUS, mapStateNumberToString (state)));
+    (accountID == IP2IP_PROFILE) ? a.insert (std::pair<std::string, std::string> (REGISTRATION_STATUS, "READY")) : 
+								a.insert (std::pair<std::string, std::string> (REGISTRATION_STATUS, mapStateNumberToString (state)));
 
     a.insert (std::pair<std::string, std::string> (REGISTRATION_STATE_CODE, registrationStateCode));
     a.insert (std::pair<std::string, std::string> (REGISTRATION_STATE_DESCRIPTION, registrationStateDescription));
-- 
GitLab