diff --git a/sflphone-client-gnome/src/config/accountconfigdialog.c b/sflphone-client-gnome/src/config/accountconfigdialog.c
index 550019774a52be16a6cb66825d48a76f93377547..74d6837bb2fe2c835324e8ad1cecc4a8239444e5 100644
--- a/sflphone-client-gnome/src/config/accountconfigdialog.c
+++ b/sflphone-client-gnome/src/config/accountconfigdialog.c
@@ -66,11 +66,15 @@ GtkWidget * keyExchangeCombo;
 GtkWidget * useSipTlsCheckBox;
 
 GtkWidget * publishedAddressEntry;
+GtkWidget * localAddressLabel;
 GtkWidget * localAddressCombo;
-GtkWidget * useStunRadioButton;
+GtkWidget * useStunCheckBox;
 GtkWidget * sameAsLocalRadioButton;
 GtkWidget * publishedAddrRadioButton;
+GtkWidget * sameAsLocalLabel;
+GtkWidget * publishedAddrLabel;
 GtkWidget * publishedPortSpinBox;
+GtkWidget * localPortLabel;
 GtkWidget * localPortSpinBox;
 GtkWidget * publishedAddressLabel;
 GtkWidget * publishedPortLabel;
@@ -161,6 +165,10 @@ static GtkWidget * create_basic_tab(account_t **a)
 		curMailbox = g_hash_table_lookup(currentAccount->properties, ACCOUNT_MAILBOX);
 	}
 
+	DEBUG("-------- Basic parameters from config");
+	DEBUG("curAccountID %s, curAccountType %s, curAccountEnabled %s, curAlias %s, curHostname %s, curPassword %s, curUsername %s, curMailbox %s\n", curAccountID, curAccountType, curAccountEnabled, curAlias, curHostname, curPassword, curUsername, curMailbox);
+	
+
 	gnome_main_section_new (_("Account Parameters"), &frame);
 	gtk_widget_show(frame);
 
@@ -413,59 +421,163 @@ static void use_sip_tls_cb(GtkWidget *widget, gpointer data)
 {
     if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
         DEBUG("Using sips");
-    	gtk_widget_set_sensitive(GTK_WIDGET(data), TRUE);            
+    	gtk_widget_set_sensitive(GTK_WIDGET(data), TRUE);
+	// Uncheck stun
+	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(useStunCheckBox), FALSE);
+	gtk_widget_set_sensitive(GTK_WIDGET(useStunCheckBox), FALSE);
+	gtk_widget_set_sensitive(GTK_WIDGET(sameAsLocalRadioButton), TRUE);
+        gtk_widget_set_sensitive(GTK_WIDGET(publishedAddrRadioButton), TRUE);
+	gtk_widget_hide(stunServerLabel);
+	gtk_widget_hide(stunServerEntry);
+
+	
+
+	if(!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sameAsLocalRadioButton))) {
+	    gtk_widget_show(publishedAddressEntry);
+            gtk_widget_show(publishedPortSpinBox);
+	    gtk_widget_show(publishedAddressLabel);
+            gtk_widget_show(publishedPortLabel);
+	}
+
     } else {
-        gtk_widget_set_sensitive(GTK_WIDGET(data), FALSE);    
+        gtk_widget_set_sensitive(GTK_WIDGET(data), FALSE);
+	gtk_widget_set_sensitive(GTK_WIDGET(useStunCheckBox), TRUE);
+
+	if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(useStunCheckBox))) {
+	    gtk_widget_set_sensitive(GTK_WIDGET(sameAsLocalRadioButton), FALSE);
+	    gtk_widget_set_sensitive(GTK_WIDGET(publishedAddrRadioButton), FALSE);
+	    gtk_widget_show(stunServerLabel);
+	    gtk_widget_show(stunServerEntry);
+	    gtk_widget_hide(publishedAddressEntry);
+            gtk_widget_hide(publishedPortSpinBox);
+	    gtk_widget_hide(publishedAddressLabel);
+            gtk_widget_hide(publishedPortLabel);
+	}
+	else {
+            gtk_widget_set_sensitive(GTK_WIDGET(sameAsLocalRadioButton), TRUE);
+	    gtk_widget_set_sensitive(GTK_WIDGET(publishedAddrRadioButton), TRUE);
+	    gtk_widget_hide(stunServerLabel);
+            gtk_widget_hide(stunServerEntry);
+	}
+	
     }   
 }
 
+
+static set_published_addr_manually_cb(GtkWidget * widget, gpointer data UNUSED)
+{
+    DEBUG("set_published_addr_manually_cb");
+
+    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
+        DEBUG("Showing manual options");    
+    	gtk_widget_show(publishedPortLabel);            
+    	gtk_widget_show(publishedPortSpinBox);
+    	gtk_widget_show(publishedAddressLabel);                	
+    	gtk_widget_show(publishedAddressEntry);
+    } else {
+        DEBUG("Hiding manual options");   
+    	gtk_widget_hide(publishedPortLabel);            
+    	gtk_widget_hide(publishedPortSpinBox);
+    	gtk_widget_hide(publishedAddressLabel);                	
+    	gtk_widget_hide(publishedAddressEntry);
+    }
+}
+
+static use_stun_cb(GtkWidget * widget, gpointer data UNUSED)
+{
+    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
+        DEBUG("Showing stun options");
+        gtk_widget_show(stunServerLabel);
+        gtk_widget_show(stunServerEntry);
+	gtk_widget_set_sensitive(sameAsLocalRadioButton, FALSE);
+	gtk_widget_set_sensitive(publishedAddrRadioButton, FALSE);
+	gtk_widget_hide(publishedAddressLabel);
+        gtk_widget_hide(publishedPortLabel);
+	gtk_widget_hide(publishedAddressEntry);
+        gtk_widget_hide(publishedPortSpinBox);
+    } else {
+        gtk_widget_hide(stunServerLabel);
+        gtk_widget_hide(stunServerEntry);
+	gtk_widget_set_sensitive(sameAsLocalRadioButton, TRUE);
+	gtk_widget_set_sensitive(publishedAddrRadioButton, TRUE);
+	if(!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sameAsLocalRadioButton))) {
+	    gtk_widget_show(publishedAddressLabel);
+	    gtk_widget_show(publishedPortLabel);
+	    gtk_widget_show(publishedAddressEntry);
+	    gtk_widget_show(publishedPortSpinBox);
+	}
+    }
+ 
+}
+
+static same_as_local_cb(GtkWidget * widget, gpointer data UNUSED)
+{
+    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
+        DEBUG("Same as local");
+		gchar * ip_address = (gchar *) gtk_combo_box_get_active_text(GTK_COMBO_BOX(localAddressCombo));
+	    gtk_entry_set_text(GTK_ENTRY(publishedAddressEntry), ip_address);
+	    
+        gchar * local_port = (gchar *) gtk_entry_get_text(GTK_ENTRY(localPortSpinBox));
+        gtk_spin_button_set_value(GTK_SPIN_BUTTON(publishedPortSpinBox), g_ascii_strtod(local_port, NULL));
+    } 
+}
+
+
+
 GtkWidget * create_security_tab(account_t **a)
 {
-	GtkWidget * frame;
-	GtkWidget * table;
-	GtkWidget * label;
-	GtkWidget * ret;
-	GtkWidget * hbox;
-	GtkWidget * editButton;
+    GtkWidget * frame;
+    GtkWidget * table;
+    GtkWidget * label;
+    GtkWidget * ret;
+    GtkWidget * hbox;
+    GtkWidget * editButton;
     GtkWidget * addButton;
-	GtkCellRenderer * renderer;
+    GtkCellRenderer * renderer;
     GtkTreeViewColumn * treeViewColumn;
     GtkTreeSelection * treeSelection;
 	
-	ret = gtk_vbox_new(FALSE, 10);
+    ret = gtk_vbox_new(FALSE, 10);
     gtk_container_set_border_width(GTK_CONTAINER(ret), 10);
     
-	account_t * currentAccount;
-	currentAccount = *a;
+    account_t * currentAccount;
+    currentAccount = *a;
 	
     gchar * curSRTPEnabled = NULL;
     gchar * curKeyExchange = NULL;
     gchar * curTLSEnabled = NULL;
+
+    gchar* published_address;
+    gchar* published_port;
     
-	// Load from SIP/IAX/Unknown ?
-	if(currentAccount) {	
+    // Load from SIP/IAX/Unknown ?
+    if(currentAccount) {	
         curKeyExchange = g_hash_table_lookup(currentAccount->properties, ACCOUNT_KEY_EXCHANGE);
-		if (curKeyExchange == NULL) {
-		    curKeyExchange = "none";
-		}		
+	if (curKeyExchange == NULL) {
+	    curKeyExchange = "none";
+	}		
 		      		  
         curSRTPEnabled = g_hash_table_lookup(currentAccount->properties, ACCOUNT_SRTP_ENABLED);
         if (curSRTPEnabled == NULL) {
-            curSRTPEnabled = "false";
+	    curSRTPEnabled = "false";
         }
         
         curTLSEnabled = g_hash_table_lookup(currentAccount->properties, TLS_ENABLE);
         if (curTLSEnabled == NULL) {
             curTLSEnabled = "false";
-        } 
+        }
+
+	published_address = g_hash_table_lookup(currentAccount->properties,  PUBLISHED_ADDRESS);
+
+	published_port = g_hash_table_lookup(currentAccount->properties,  PUBLISHED_PORT);
         
         DEBUG("TLS is enabled to %s", curTLSEnabled);       
-	} 
-  	
+    } 
+    
     /* Credentials tree view */
     gnome_main_section_new_with_table (_("Credential"), &frame, &table, 1, 1);
-	gtk_container_set_border_width (GTK_CONTAINER(table), 10);
-	gtk_table_set_row_spacings(GTK_TABLE(table), 10);
+    gtk_container_set_border_width (GTK_CONTAINER(table), 10);
+    gtk_table_set_row_spacings(GTK_TABLE(table), 10);
     gtk_box_pack_start(GTK_BOX(ret), frame, FALSE, FALSE, 0);
 	
     scrolledWindowCredential = gtk_scrolled_window_new(NULL, NULL);
@@ -531,26 +643,29 @@ GtkWidget * create_security_tab(account_t **a)
     g_signal_connect (deleteCredButton, "clicked", G_CALLBACK (delete_credential_cb), treeViewCredential);
     gtk_box_pack_start(GTK_BOX(hbox), deleteCredButton, FALSE, FALSE, 0);
  
- 	 /* SRTP Section */
+
+    /* Security Section */
     gnome_main_section_new_with_table (_("Security"), &frame, &table, 2, 3);
-	gtk_container_set_border_width (GTK_CONTAINER(table), 10);
-	gtk_table_set_row_spacings (GTK_TABLE(table), 10);
+    gtk_container_set_border_width (GTK_CONTAINER(table), 10);
+    gtk_table_set_row_spacings (GTK_TABLE(table), 10);
     gtk_table_set_col_spacings( GTK_TABLE(table), 10);
     gtk_box_pack_start(GTK_BOX(ret), frame, FALSE, FALSE, 0);
 
-	GtkWidget * sipTlsAdvancedButton;
-	sipTlsAdvancedButton = gtk_button_new_from_stock(GTK_STOCK_EDIT);
+    /* TLS subsection */
+    GtkWidget * sipTlsAdvancedButton;
+    sipTlsAdvancedButton = gtk_button_new_from_stock(GTK_STOCK_EDIT);
     gtk_table_attach_defaults(GTK_TABLE(table), sipTlsAdvancedButton, 2, 3, 0, 1);
-	gtk_widget_set_sensitive(GTK_WIDGET(sipTlsAdvancedButton), FALSE);    
+    gtk_widget_set_sensitive(GTK_WIDGET(sipTlsAdvancedButton), FALSE);    
     g_signal_connect(G_OBJECT(sipTlsAdvancedButton), "clicked", G_CALLBACK(show_advanced_tls_options_cb), currentAccount->properties);
     
-	useSipTlsCheckBox = gtk_check_button_new_with_mnemonic(_("Use TLS transport (sips)"));
-	g_signal_connect (useSipTlsCheckBox, "toggled", G_CALLBACK(use_sip_tls_cb), sipTlsAdvancedButton);
-	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(useSipTlsCheckBox), (g_strcmp0(curTLSEnabled, "true") == 0) ? TRUE:FALSE);
-	gtk_table_attach_defaults(GTK_TABLE(table), useSipTlsCheckBox, 0, 2, 0, 1);
+    useSipTlsCheckBox = gtk_check_button_new_with_mnemonic(_("Use TLS transport (sips)"));
+    g_signal_connect (useSipTlsCheckBox, "toggled", G_CALLBACK(use_sip_tls_cb), sipTlsAdvancedButton);
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(useSipTlsCheckBox), (g_strcmp0(curTLSEnabled, "true") == 0) ? TRUE:FALSE);
+    gtk_table_attach_defaults(GTK_TABLE(table), useSipTlsCheckBox, 0, 2, 0, 1);
        	    
+    /* ZRTP subsection */
     label = gtk_label_new_with_mnemonic (_("SRTP key exchange"));
- 	gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
+    gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
     keyExchangeCombo = gtk_combo_box_new_text();
     gtk_label_set_mnemonic_widget (GTK_LABEL (label), keyExchangeCombo);
     gtk_combo_box_append_text(GTK_COMBO_BOX(keyExchangeCombo), "ZRTP");
@@ -575,9 +690,9 @@ GtkWidget * create_security_tab(account_t **a)
     
 	g_signal_connect (G_OBJECT (GTK_COMBO_BOX(keyExchangeCombo)), "changed", G_CALLBACK (key_exchange_changed_cb), currentAccount);
     
-    gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2);
-    gtk_table_attach_defaults(GTK_TABLE(table), keyExchangeCombo, 1, 2, 1, 2);    
-    gtk_table_attach_defaults(GTK_TABLE(table), advancedZrtpButton, 2, 3, 1, 2);
+    gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 5, 6);
+    gtk_table_attach_defaults(GTK_TABLE(table), keyExchangeCombo, 1, 2, 5, 6);    
+    gtk_table_attach_defaults(GTK_TABLE(table), advancedZrtpButton, 2, 3, 5, 6);
 
     gtk_widget_show_all(table);
     
@@ -589,50 +704,13 @@ GtkWidget * create_security_tab(account_t **a)
     gtk_widget_set_size_request(GTK_WIDGET(scrolledWindowCredential), requisitionTable.width, 120);
     	
     gtk_widget_show_all(ret);
+
+    same_as_local_cb(sameAsLocalRadioButton, NULL);
+    set_published_addr_manually_cb(publishedAddrRadioButton, NULL);
     
 	return ret;
 }
 
-static use_stun_cb(GtkWidget * widget, gpointer data UNUSED)
-{
-    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
-        DEBUG("Showing stun options");
-        gtk_widget_show(stunServerLabel);
-        gtk_widget_show(stunServerEntry);
-    } else {
-        gtk_widget_hide(stunServerLabel);
-        gtk_widget_hide(stunServerEntry);
-    }
- 
-}
-
-static same_as_local_cb(GtkWidget * widget, gpointer data UNUSED)
-{
-    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
-        DEBUG("Same as local");
-		gchar * ip_address = (gchar *) gtk_combo_box_get_active_text(GTK_COMBO_BOX(localAddressCombo));
-	    gtk_entry_set_text(GTK_ENTRY(publishedAddressEntry), ip_address);
-	    
-        gchar * local_port = (gchar *) gtk_entry_get_text(GTK_ENTRY(localPortSpinBox));
-        gtk_spin_button_set_value(GTK_SPIN_BUTTON(publishedPortSpinBox), g_ascii_strtod(local_port, NULL));
-    } 
-}
-
-static set_published_addr_manually_cb(GtkWidget * widget, gpointer data UNUSED)
-{
-    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
-        DEBUG("Showing manual options");    
-    	gtk_widget_show(publishedPortLabel);            
-    	gtk_widget_show(publishedPortSpinBox);
-    	gtk_widget_show(publishedAddressLabel);                	
-    	gtk_widget_show(publishedAddressEntry);
-    } else {
-    	gtk_widget_hide(publishedPortLabel);            
-    	gtk_widget_hide(publishedPortSpinBox);
-    	gtk_widget_hide(publishedAddressLabel);                	
-    	gtk_widget_hide(publishedAddressEntry);
-    }
-}
 
 GtkWidget * create_advanced_tab(account_t **a)
 {
@@ -643,169 +721,187 @@ GtkWidget * create_advanced_tab(account_t **a)
 	GtkWidget * hbox;
 	
 	ret = gtk_vbox_new(FALSE, 10);
-    gtk_container_set_border_width(GTK_CONTAINER(ret), 10);
+	gtk_container_set_border_width(GTK_CONTAINER(ret), 10);
     
 	account_t * currentAccount;
 	currentAccount = *a;
 
-    gchar * resolve_once = NULL;
-    gchar * account_expire = NULL;
-    gchar * use_tls;
-    gchar * published_address;
-    gchar * published_port;
-    gchar * local_address;
-    gchar * local_port;
-    gchar * stun_enable;    
-    gchar * stun_server;    
+	gchar * resolve_once = NULL;
+	gchar * account_expire = NULL;
+	gchar * use_tls;
+	gchar * published_address;
+	gchar * published_port;
+	gchar * local_address;
+	gchar * local_port;
+	gchar * stun_enable;    
+	gchar * stun_server;
+	gchar * published_sameas_local;
         
 	// Load from SIP/IAX/Unknown ?
 	if(currentAccount) {
+
 		resolve_once = g_hash_table_lookup(currentAccount->properties, ACCOUNT_RESOLVE_ONCE);
 		account_expire = g_hash_table_lookup(currentAccount->properties, ACCOUNT_REGISTRATION_EXPIRE);
 		use_tls = g_hash_table_lookup(currentAccount->properties,  TLS_ENABLE);
-	    local_port = g_hash_table_lookup(currentAccount->properties, LOCAL_PORT);
+		local_port = g_hash_table_lookup(currentAccount->properties, LOCAL_PORT);
 		local_address = g_hash_table_lookup(currentAccount->properties,  LOCAL_ADDRESS);
 		published_address = g_hash_table_lookup(currentAccount->properties,  PUBLISHED_ADDRESS);
 		published_port = g_hash_table_lookup(currentAccount->properties,  PUBLISHED_PORT);
 		stun_enable = g_hash_table_lookup(currentAccount->properties,  ACCOUNT_SIP_STUN_ENABLED);
-		stun_server = g_hash_table_lookup(currentAccount->properties,  ACCOUNT_SIP_STUN_SERVER);				
+		stun_server = g_hash_table_lookup(currentAccount->properties,  ACCOUNT_SIP_STUN_SERVER);
+		published_sameas_local = g_hash_table_lookup(currentAccount->properties,  PUBLISHED_SAMEAS_LOCAL);
+
+		DEBUG("-------- Advanced parameters from config");
+		DEBUG("resolve_once %s,  account_expire %s, use_tls %s, published_address %s, published_port %s, local_address %s, local_port %s, stun_enable %s, stun_server %s, published_sameas_local %s\n", resolve_once, account_expire, use_tls, published_address, published_port, local_address, local_port, stun_enable, stun_server, published_sameas_local);
 	} 
 
-    gnome_main_section_new_with_table (_("Registration"), &frame, &table, 2, 3);
-    gtk_box_pack_start(GTK_BOX(ret), frame, FALSE, FALSE, 0);
+	gnome_main_section_new_with_table (_("Registration"), &frame, &table, 2, 3);
+	gtk_box_pack_start(GTK_BOX(ret), frame, FALSE, FALSE, 0);
 	gtk_container_set_border_width (GTK_CONTAINER(table), 10);
 	gtk_table_set_row_spacings( GTK_TABLE(table), 5);	
 
 	label = gtk_label_new_with_mnemonic (_("Registration expire"));
 	gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1);
 	gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
-    expireSpinBox = gtk_spin_button_new_with_range(1, 65535, 1);
+	expireSpinBox = gtk_spin_button_new_with_range(1, 65535, 1);
 	gtk_label_set_mnemonic_widget(GTK_LABEL(label), expireSpinBox);
-    gtk_spin_button_set_value(GTK_SPIN_BUTTON(expireSpinBox), g_ascii_strtod(account_expire, NULL));
+	gtk_spin_button_set_value(GTK_SPIN_BUTTON(expireSpinBox), g_ascii_strtod(account_expire, NULL));
 	gtk_table_attach_defaults(GTK_TABLE(table), expireSpinBox, 1, 2, 0, 1);
 
+
 	entryResolveNameOnlyOnce = gtk_check_button_new_with_mnemonic(_("_Comply with RFC 3263"));
 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(entryResolveNameOnlyOnce),
 			g_strcasecmp(resolve_once,"false") == 0 ? TRUE: FALSE);
 	gtk_table_attach_defaults( GTK_TABLE( table ), entryResolveNameOnlyOnce, 0, 2, 1, 2);
 	gtk_widget_set_sensitive( GTK_WIDGET( entryResolveNameOnlyOnce ) , TRUE );
 	
-    gnome_main_section_new_with_table (_("Network"), &frame, &table, 2, 3);
-    gtk_box_pack_start(GTK_BOX(ret), frame, FALSE, FALSE, 0);
-    gtk_container_set_border_width (GTK_CONTAINER(table), 10);
+	
+	gnome_main_section_new_with_table (_("Network Interface"), &frame, &table, 2, 2);
+	gtk_box_pack_start(GTK_BOX(ret), frame, FALSE, FALSE, 0);
+	gtk_container_set_border_width (GTK_CONTAINER(table), 10);
 	gtk_table_set_row_spacings( GTK_TABLE(table), 5);
 		
-    /**
-     * Retreive the list of IP interface from the 
-     * the daemon and build the combo box.
-     */
+	/**
+	 * Retreive the list of IP interface from the 
+	 * the daemon and build the combo box.
+	 */
    
-    GtkListStore * ipInterfaceListStore; 
-    GtkTreeIter iter;
+	GtkListStore * ipInterfaceListStore; 
+	GtkTreeIter iter;
     
-    ipInterfaceListStore =  gtk_list_store_new( 1, G_TYPE_STRING );
-	label = gtk_label_new_with_mnemonic (_("Local address"));    
-	gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
-	gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
+	ipInterfaceListStore =  gtk_list_store_new( 1, G_TYPE_STRING );
+	localAddressLabel = gtk_label_new_with_mnemonic (_("Local address"));    
+	gtk_table_attach ( GTK_TABLE( table ), localAddressLabel, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
+	gtk_misc_set_alignment(GTK_MISC (localAddressLabel), 0, 0.5);
 			
-    GtkTreeIter current_local_address_iter = iter;   
-    gchar ** iface_list = NULL;
-    iface_list = (gchar**) dbus_get_all_ip_interface();
-    gchar ** iface = NULL;
+	GtkTreeIter current_local_address_iter = iter;   
+	gchar ** iface_list = NULL;
+	iface_list = (gchar**) dbus_get_all_ip_interface();
+	gchar ** iface = NULL;
     
-    if (iface_list != NULL) {
-        for (iface = iface_list; *iface; iface++) {         
+	if (iface_list != NULL) {
+	  for (iface = iface_list; *iface; iface++) {         
             DEBUG("Interface %s", *iface);            
             gtk_list_store_append(ipInterfaceListStore, &iter );
             gtk_list_store_set(ipInterfaceListStore, &iter, 0, *iface, -1 );
 
-            if (g_strcmp0(*iface, local_address) == 0) {
+	    if (g_strcmp0(*iface, local_address) == 0) {
                 DEBUG("Setting active local address combo box");
                 current_local_address_iter = iter;
             }
-        }
-    }
+	  }
+	}
     
-    localAddressCombo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(ipInterfaceListStore));
-	gtk_label_set_mnemonic_widget(GTK_LABEL(label), localAddressCombo);
+	localAddressCombo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(ipInterfaceListStore));
+	gtk_label_set_mnemonic_widget(GTK_LABEL(localAddressLabel), localAddressCombo);
 	gtk_table_attach ( GTK_TABLE( table ), localAddressCombo, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
-    g_object_unref(G_OBJECT(ipInterfaceListStore));	
+	g_object_unref(G_OBJECT(ipInterfaceListStore));	
     
-    GtkCellRenderer * ipInterfaceCellRenderer;
-    ipInterfaceCellRenderer = gtk_cell_renderer_text_new();
-    gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(localAddressCombo), ipInterfaceCellRenderer, TRUE);
-    gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(localAddressCombo), ipInterfaceCellRenderer, "text", 0, NULL);
-    gtk_combo_box_set_active_iter(GTK_COMBO_BOX(localAddressCombo), &current_local_address_iter);
-
-    /**
-     * Local port
-     */	    
-	label = gtk_label_new_with_mnemonic (_("Local port"));
-	gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2);
-	gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
-    localPortSpinBox = gtk_spin_button_new_with_range(1, 65535, 1);
-	gtk_label_set_mnemonic_widget (GTK_LABEL (label), localPortSpinBox);
-    gtk_spin_button_set_value(GTK_SPIN_BUTTON(localPortSpinBox), g_ascii_strtod(local_port, NULL));
+	GtkCellRenderer * ipInterfaceCellRenderer;
+	ipInterfaceCellRenderer = gtk_cell_renderer_text_new();
+	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(localAddressCombo), ipInterfaceCellRenderer, TRUE);
+	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(localAddressCombo), ipInterfaceCellRenderer, "text", 0, NULL);
+	gtk_combo_box_set_active_iter(GTK_COMBO_BOX(localAddressCombo), &current_local_address_iter);
+
+
+	/**
+	 * Local port
+	 */	    
+	localPortLabel = gtk_label_new_with_mnemonic (_("Local port"));
+	gtk_table_attach_defaults(GTK_TABLE(table), localPortLabel, 0, 1, 1, 2);
+	gtk_misc_set_alignment(GTK_MISC (localPortLabel), 0, 0.5);
+	localPortSpinBox = gtk_spin_button_new_with_range(1, 65535, 1);
+	gtk_label_set_mnemonic_widget (GTK_LABEL (localPortLabel), localPortSpinBox);
+	gtk_spin_button_set_value(GTK_SPIN_BUTTON(localPortSpinBox), g_ascii_strtod(local_port, NULL));
+
 	gtk_table_attach_defaults(GTK_TABLE(table), localPortSpinBox, 1, 2, 1, 2);
 
-	label = gtk_label_new_with_mnemonic (_("Set published address and port:"));
-	gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 2, 2, 3);
-	gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
 
-	useStunRadioButton = gtk_radio_button_new_with_mnemonic(NULL,_("Using STUN "));
-	gtk_table_attach_defaults(GTK_TABLE(table), useStunRadioButton, 0, 2, 3, 4);
-	gtk_widget_set_sensitive (GTK_WIDGET(useStunRadioButton),
+	/**
+	 *  Published address field
+	 */ 
+	gnome_main_section_new_with_table (_("Published address"), &frame, &table, 2, 3);
+	gtk_box_pack_start(GTK_BOX(ret), frame, FALSE, FALSE, 0);
+	gtk_container_set_border_width (GTK_CONTAINER(table), 10);
+	gtk_table_set_row_spacings( GTK_TABLE(table), 5);
+
+
+	useStunCheckBox = gtk_check_button_new_with_mnemonic(_("Using STUN"));
+	gtk_table_attach_defaults(GTK_TABLE(table), useStunCheckBox, 0, 1, 0, 1);
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(useStunCheckBox), 
+			g_strcasecmp(stun_enable, "true") == 0 ? TRUE: FALSE);
+	gtk_widget_set_sensitive (GTK_WIDGET(useStunCheckBox),
 			g_strcasecmp(use_tls,"true") == 0 ? FALSE: TRUE);
-	
-	sameAsLocalRadioButton = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(useStunRadioButton), _("Same as local parameters"));
-	gtk_table_attach_defaults(GTK_TABLE(table), sameAsLocalRadioButton, 0, 2, 4, 5);
 
-	publishedAddrRadioButton = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(useStunRadioButton), _("Manually"));
-	gtk_table_attach_defaults(GTK_TABLE(table), publishedAddrRadioButton, 0, 2, 5, 6);
+	stunServerLabel = gtk_label_new_with_mnemonic (_("STUN server URL"));
+	gtk_table_attach_defaults(GTK_TABLE(table), stunServerLabel, 0, 1, 1, 2);
+	gtk_misc_set_alignment(GTK_MISC(stunServerLabel), 0, 0.5);
+	stunServerEntry = gtk_entry_new();
+	gtk_label_set_mnemonic_widget(GTK_LABEL(stunServerLabel), stunServerEntry);
+	gtk_entry_set_text(GTK_ENTRY(stunServerEntry), stun_server);
+	gtk_table_attach_defaults(GTK_TABLE(table), stunServerEntry, 1, 2, 1, 2);
+
+	sameAsLocalRadioButton = gtk_radio_button_new_with_mnemonic_from_widget(NULL, _("Same as local parameters"));
+	gtk_table_attach_defaults(GTK_TABLE(table), sameAsLocalRadioButton, 0, 2, 3, 4);
 
-    gtk_widget_show_all(ret);
+	publishedAddrRadioButton = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(sameAsLocalRadioButton), _("Set published address and port:"));
+	gtk_table_attach_defaults(GTK_TABLE(table), publishedAddrRadioButton, 0, 2, 4, 5);
+
+	if(g_strcasecmp(published_sameas_local, "true") == 0) {
+	    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(sameAsLocalRadioButton), TRUE);
+	} else {
+	    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(publishedAddrRadioButton), TRUE);
+	}
+
+	gtk_widget_show_all(ret);
+
+	use_stun_cb (GTK_WIDGET (useStunCheckBox), NULL);
     		
 	publishedAddressLabel = gtk_label_new_with_mnemonic (_("Published address"));
-	gtk_table_attach_defaults( GTK_TABLE(table), publishedAddressLabel, 0, 1, 6, 7);
+	gtk_table_attach_defaults( GTK_TABLE(table), publishedAddressLabel, 0, 1, 5, 6);
 	gtk_misc_set_alignment(GTK_MISC (publishedAddressLabel), 0, 0.5);
 	publishedAddressEntry = gtk_entry_new();
 	gtk_label_set_mnemonic_widget (GTK_LABEL (publishedAddressLabel), publishedAddressEntry);
 	gtk_entry_set_text(GTK_ENTRY(publishedAddressEntry), published_address);
-	gtk_table_attach_defaults( GTK_TABLE(table), publishedAddressEntry, 1, 2, 6, 7);
+	gtk_table_attach_defaults( GTK_TABLE(table), publishedAddressEntry, 1, 2, 5, 6);
 		
 	publishedPortLabel = gtk_label_new_with_mnemonic(_("Published port"));
-	gtk_table_attach_defaults(GTK_TABLE(table), publishedPortLabel, 0, 1, 7, 8);
+	gtk_table_attach_defaults(GTK_TABLE(table), publishedPortLabel, 0, 1, 6, 7);
 	gtk_misc_set_alignment(GTK_MISC(publishedPortLabel), 0, 0.5);
-    publishedPortSpinBox = gtk_spin_button_new_with_range(1, 65535, 1);
+	publishedPortSpinBox = gtk_spin_button_new_with_range(1, 65535, 1);
 	gtk_label_set_mnemonic_widget(GTK_LABEL (publishedPortLabel), publishedPortSpinBox);
-    gtk_spin_button_set_value(GTK_SPIN_BUTTON(publishedPortSpinBox), g_ascii_strtod(published_port, NULL));
-	gtk_table_attach_defaults(GTK_TABLE(table), publishedPortSpinBox, 1, 2, 7, 8);
+	gtk_spin_button_set_value(GTK_SPIN_BUTTON(publishedPortSpinBox), g_ascii_strtod(published_port, NULL));
 
-	stunServerLabel = gtk_label_new_with_mnemonic (_("STUN server URL"));
-	gtk_table_attach_defaults(GTK_TABLE(table), stunServerLabel, 0, 1, 8, 9);
-	gtk_misc_set_alignment(GTK_MISC(stunServerLabel), 0, 0.5);
-	stunServerEntry = gtk_entry_new();
-	gtk_label_set_mnemonic_widget(GTK_LABEL(stunServerLabel), stunServerEntry);
-	gtk_entry_set_text(GTK_ENTRY(stunServerEntry), stun_server);
-	gtk_table_attach_defaults(GTK_TABLE(table), stunServerEntry, 1, 2, 8, 9);
+	gtk_table_attach_defaults(GTK_TABLE(table), publishedPortSpinBox, 1, 2, 6, 7);
 	 
-	use_stun_cb (GTK_WIDGET (useStunRadioButton), NULL);
+	use_stun_cb (GTK_WIDGET (useStunCheckBox), NULL);
 
-    // This will trigger a signal, and the above two
-    // widgets need to be instanciated before that.
-	g_signal_connect(useStunRadioButton, "toggled", G_CALLBACK(use_stun_cb), useStunRadioButton);		    		
+	// This will trigger a signal, and the above two
+	// widgets need to be instanciated before that.
+	g_signal_connect(useStunCheckBox, "toggled", G_CALLBACK(use_stun_cb), useStunCheckBox);		    		
 	g_signal_connect(sameAsLocalRadioButton, "toggled", G_CALLBACK(same_as_local_cb), sameAsLocalRadioButton);   
-	g_signal_connect(publishedAddrRadioButton, "toggled", G_CALLBACK(set_published_addr_manually_cb), publishedAddrRadioButton);		
-	
-    if (g_strcasecmp(stun_enable,"true") == 0)	{
-        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(useStunRadioButton), TRUE);
-    } else if ((g_strcasecmp(published_address, local_address) == 0) 
-            && (g_strcasecmp(published_port, local_port) == 0)) {
-        	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(sameAsLocalRadioButton), TRUE);	    
-    } else {
-        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(publishedAddrRadioButton), TRUE);
-    }
-	
+	g_signal_connect(publishedAddrRadioButton, "toggled", G_CALLBACK(set_published_addr_manually_cb), publishedAddrRadioButton);
+
 	return ret;
 }
 
@@ -871,17 +967,17 @@ show_account_window (account_t * a)
 
 	currentAccount = a;   
 	
-    if (currentAccount == NULL) {
+	if (currentAccount == NULL) {
 		currentAccount = g_new0(account_t, 1);
 		currentAccount->properties = dbus_account_details(NULL);
 		currentAccount->accountID = "new";    
-        DEBUG("Account is NULL. Will fetch default values\n");      
-    }
+		DEBUG("Account is NULL. Will fetch default values\n");      
+	}
     
 	dialog = GTK_DIALOG(gtk_dialog_new_with_buttons (_("Account settings"),
 				GTK_WINDOW(get_main_window()),
 				GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
-	    		GTK_STOCK_CANCEL,
+				GTK_STOCK_CANCEL,
 				GTK_RESPONSE_CANCEL,
 				GTK_STOCK_APPLY,				
 				GTK_RESPONSE_ACCEPT,
@@ -905,14 +1001,14 @@ show_account_window (account_t * a)
 	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), advanced_tab, gtk_label_new(_("Advanced")));
 	gtk_notebook_page_num(GTK_NOTEBOOK(notebook), advanced_tab);
 		
-    /* Security */
-    security_tab = create_security_tab(&currentAccount);
+	/* Security */
+	security_tab = create_security_tab(&currentAccount);
 	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), security_tab, gtk_label_new(_("Security")));
 	gtk_notebook_page_num(GTK_NOTEBOOK(notebook),security_tab);
 		    	
 	gtk_notebook_set_current_page( GTK_NOTEBOOK( notebook) ,  0);
 
-    g_signal_emit_by_name(protocolComboBox, "changed", NULL);
+	g_signal_emit_by_name(protocolComboBox, "changed", NULL);
     
 	response = gtk_dialog_run (GTK_DIALOG (dialog));
 
@@ -943,64 +1039,94 @@ show_account_window (account_t * a)
 				g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(entryMailbox))));
 		g_hash_table_replace(currentAccount->properties,
 				g_strdup(ACCOUNT_REGISTRATION_EXPIRE),
-				g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(expireSpinBox))));				
-        
+				g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(expireSpinBox))));   
+
+
 		if (strcmp(proto, "SIP") == 0) {
 			
 			g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_SIP_STUN_ENABLED), 
-					            g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(useStunRadioButton)) ? "true":"false"));
+					            g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(useStunCheckBox)) ? "true":"false"));
 
 			g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_SIP_STUN_SERVER), 
 					            g_strdup(gtk_entry_get_text(GTK_ENTRY(stunServerEntry))));
 
 			gchar* keyExchange = (gchar *)gtk_combo_box_get_active_text(GTK_COMBO_BOX(keyExchangeCombo));
-            if (g_strcasecmp(keyExchange, "ZRTP") == 0) {
-                g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_SRTP_ENABLED), g_strdup("true"));
-                g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_KEY_EXCHANGE), g_strdup(ZRTP));
-            } else {
-                g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_SRTP_ENABLED), g_strdup("false"));
-            }
+			if (g_strcasecmp(keyExchange, "ZRTP") == 0) {
+			  g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_SRTP_ENABLED), g_strdup("true"));
+			  g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_KEY_EXCHANGE), g_strdup(ZRTP));
+			} else {
+			  g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_SRTP_ENABLED), g_strdup("false"));
+			}
     		
-    		g_hash_table_replace(currentAccount->properties, g_strdup(TLS_ENABLE), 
-    		g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(useSipTlsCheckBox)) ? "true":"false"));
+			g_hash_table_replace(currentAccount->properties, g_strdup(TLS_ENABLE), 
+					     g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(useSipTlsCheckBox)) ? "true":"false"));
+
+			g_hash_table_replace(currentAccount->properties, g_strdup(PUBLISHED_SAMEAS_LOCAL), g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sameAsLocalRadioButton)) ? "true":"false"));	
 
-    		g_hash_table_replace(currentAccount->properties,
+			g_hash_table_replace(currentAccount->properties,
     				g_strdup(LOCAL_PORT),
     				g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(localPortSpinBox))));	
 
-    		g_hash_table_replace(currentAccount->properties,
+			g_hash_table_replace(currentAccount->properties,
     				g_strdup(LOCAL_ADDRESS),
 			        g_strdup((gchar *)gtk_combo_box_get_active_text(GTK_COMBO_BOX(localAddressCombo))));
 
-    		g_hash_table_replace(currentAccount->properties,
+			g_hash_table_replace(currentAccount->properties,
     				g_strdup(PUBLISHED_PORT),
-    				g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(publishedPortSpinBox))));	
+    				g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(publishedPortSpinBox))));
 
-    		g_hash_table_replace(currentAccount->properties,
+			g_hash_table_replace(currentAccount->properties,
     				g_strdup(PUBLISHED_ADDRESS),
-    				g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(publishedAddressEntry))));	    
+    				g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(publishedAddressEntry))));
+			DEBUG("-------- Basic parameters to ne written in config");
+			DEBUG("curAccountID %s, curAccountType %s, curAlias %s, curHostname %s, curPassword %s, curUsername %s, curMailbox %s\n", 
+			      (gchar *)currentAccount->accountID, 
+			      (gchar *)gtk_combo_box_get_active_text(GTK_COMBO_BOX(protocolComboBox)), 
+			      (gchar *)gtk_entry_get_text(GTK_ENTRY(entryAlias)), 
+			      (gchar *)gtk_entry_get_text(GTK_ENTRY(entryHostname)), 
+			      (gchar *)gtk_entry_get_text(GTK_ENTRY(entryPassword)), 
+			      (gchar *)gtk_entry_get_text(GTK_ENTRY(entryUsername)),
+			      (gchar *)gtk_entry_get_text(GTK_ENTRY(entryMailbox))
+			      );
+
+
+			DEBUG("-------- Advanced parameters to be written");
+			DEBUG("resolve_once %s,  account_expire %s, use_tls %s, published_address %s, published_port %s, local_address %s, local_port %s, stun_enable %s, stun_server %s\n", 
+			      gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(entryResolveNameOnlyOnce)) ? "false": "true",
+			      (gchar *)gtk_entry_get_text(GTK_ENTRY(expireSpinBox)), 
+			      gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(useSipTlsCheckBox)) ? "true":"false",
+			      (gchar *)gtk_entry_get_text(GTK_ENTRY(publishedPortSpinBox)), 
+			      (gchar *)gtk_entry_get_text(GTK_ENTRY(publishedAddressEntry)),
+			      (gchar *)gtk_entry_get_text(GTK_ENTRY(localPortSpinBox)), 
+			      (gchar *)gtk_combo_box_get_active_text(GTK_COMBO_BOX(localAddressCombo)),
+			      gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(useStunCheckBox)) ? "true":"false",
+			      gtk_entry_get_text(GTK_ENTRY(stunServerEntry))
+			      );
+	    
 		}
 
-	    /* Set new credentials if any */
+		
+
+		/* Set new credentials if any */
 	    
-        DEBUG("Setting credentials"); 
-
-        /* This hack is necessary because of the way the 
-        * configuration file is made (.ini at that time).
-        * and deleting account per account is too much 
-        * of a trouble. 
-        */
-        dbus_delete_all_credential(currentAccount);
+		DEBUG("Setting credentials"); 
+
+		/* This hack is necessary because of the way the 
+		 * configuration file is made (.ini at that time).
+		 * and deleting account per account is too much 
+		 * of a trouble. 
+		 */
+		dbus_delete_all_credential(currentAccount);
         
-        GPtrArray * credential = getNewCredential(currentAccount->properties);         
-        currentAccount->credential_information = credential;
-        if(currentAccount->credential_information != NULL) {
-            int i;
-            for(i = 0; i < currentAccount->credential_information->len; i++) {
-                dbus_set_credential(currentAccount, i);
-            }
-            dbus_set_number_of_credential(currentAccount, currentAccount->credential_information->len);
-        }
+		GPtrArray * credential = getNewCredential(currentAccount->properties);         
+		currentAccount->credential_information = credential;
+		if(currentAccount->credential_information != NULL) {
+		  int i;
+		  for(i = 0; i < currentAccount->credential_information->len; i++) {
+		    dbus_set_credential(currentAccount, i);
+		  }
+		  dbus_set_number_of_credential(currentAccount, currentAccount->credential_information->len);
+		}
         
 		/** @todo Verify if it's the best condition to check */
 		if (g_strcasecmp(currentAccount->accountID, "new") == 0) {
diff --git a/sflphone-client-gnome/src/sflphone_const.h b/sflphone-client-gnome/src/sflphone_const.h
index f12ed3f30c69bcabe02b79f0cc663f5d99f698b6..1e55bef1c8faa943e710fa41c9090b0b8a464fcb 100644
--- a/sflphone-client-gnome/src/sflphone_const.h
+++ b/sflphone-client-gnome/src/sflphone_const.h
@@ -84,6 +84,7 @@
 #define TLS_NEGOTIATION_TIMEOUT_SEC         "TLS.negotiationTimeoutSec"
 #define TLS_NEGOTIATION_TIMEOUT_MSEC        "TLS.negotiationTimemoutMsec"
 
+#define PUBLISHED_SAMEAS_LOCAL              "Account.publishedSameAsLocal"
 #define LOCAL_PORT                          "Account.localPort"
 #define LOCAL_ADDRESS                       "Account.localAddress"
 #define PUBLISHED_PORT                      "Account.publishedPort"
diff --git a/sflphone-common/src/account.h b/sflphone-common/src/account.h
index 324ec2d0d6c51b573fae076c77b1adcb2e5278cf..3d6c36b8b2275bac68a0dc4c0f2ef64417bcb588 100644
--- a/sflphone-common/src/account.h
+++ b/sflphone-common/src/account.h
@@ -70,6 +70,7 @@ typedef enum RegistrationState {
 #define REALM                               "realm"
 #define DEFAULT_REALM                       "*"
 
+#define PUBLISHED_SAMEAS_LOCAL              "Account.publishedSameAsLocal"
 #define LOCAL_PORT                          "Account.localPort"
 #define LOCAL_ADDRESS                       "Account.localAddress"
 #define PUBLISHED_PORT                      "Account.publishedPort"
diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp
index 9dde9c3752c4c21ac9f21cfe0c6ae81609b51e75..3e93b7642cea610f6016b3ad06534aaf44772ce9 100644
--- a/sflphone-common/src/managerimpl.cpp
+++ b/sflphone-common/src/managerimpl.cpp
@@ -2277,6 +2277,7 @@ ManagerImpl::initConfigFile (bool load_user_value, std::string alternate)
     _config.addDefaultValue (std::pair<std::string, std::string> (TLS_REQUIRE_CLIENT_CERTIFICATE, TRUE_STR), IP2IP_PROFILE);
     _config.addDefaultValue (std::pair<std::string, std::string> (TLS_NEGOTIATION_TIMEOUT_SEC, "2"), IP2IP_PROFILE);
     _config.addDefaultValue (std::pair<std::string, std::string> (TLS_NEGOTIATION_TIMEOUT_MSEC, "0"), IP2IP_PROFILE);
+    _config.addDefaultValue (std::pair<std::string, std::string> (PUBLISHED_SAMEAS_LOCAL, TRUE_STR), IP2IP_PROFILE);
     _config.addDefaultValue (std::pair<std::string, std::string> (LOCAL_PORT, DEFAULT_SIP_PORT), IP2IP_PROFILE);
     _config.addDefaultValue (std::pair<std::string, std::string> (PUBLISHED_PORT, DEFAULT_SIP_PORT), IP2IP_PROFILE);
     _config.addDefaultValue (std::pair<std::string, std::string> (LOCAL_ADDRESS, DEFAULT_ADDRESS), IP2IP_PROFILE);
@@ -3418,7 +3419,7 @@ ManagerImpl::setConfig (const std::string& section, const std::string& name, int
 
 void ManagerImpl::setAccountsOrder (const std::string& order)
 {
-    _debug ("Set accounts order : %s\n", order.c_str());
+    _debug ("Setcreate accounts order : %s\n", order.c_str());
     // Set the new config
     setConfig (PREFERENCES, CONFIG_ACCOUNTS_ORDER, order);
 }
@@ -3491,6 +3492,7 @@ std::map< std::string, std::string > ManagerImpl::getAccountDetails (const Accou
     a.insert (std::pair<std::string, std::string> (AUTHENTICATION_USERNAME, getConfigString (accountID, AUTHENTICATION_USERNAME)));
     a.insert (std::pair<std::string, std::string> (CONFIG_ACCOUNT_MAILBOX, getConfigString (accountID, CONFIG_ACCOUNT_MAILBOX)));
     a.insert (std::pair<std::string, std::string> (CONFIG_ACCOUNT_REGISTRATION_EXPIRE, getConfigString (accountID, CONFIG_ACCOUNT_REGISTRATION_EXPIRE)));
+    a.insert (std::pair<std::string, std::string> (PUBLISHED_SAMEAS_LOCAL, getConfigString (accountID, PUBLISHED_SAMEAS_LOCAL)));
     a.insert (std::pair<std::string, std::string> (LOCAL_ADDRESS, getConfigString (accountID, LOCAL_ADDRESS)));
     a.insert (std::pair<std::string, std::string> (PUBLISHED_ADDRESS, getConfigString (accountID, PUBLISHED_ADDRESS)));
     a.insert (std::pair<std::string, std::string> (LOCAL_PORT, getConfigString (accountID, LOCAL_PORT)));
@@ -3724,6 +3726,7 @@ void ManagerImpl::setAccountDetails (const std::string& accountID, const std::ma
 
     std::string hostname;
     std::string displayName;
+    std::string publishedSameasLocal;
     std::string localAddress;
     std::string publishedAddress;
     std::string localPort;
@@ -3759,6 +3762,10 @@ void ManagerImpl::setAccountDetails (const std::string& accountID, const std::ma
         displayName = iter->second;
     }
 
+    if ( (iter = map_cpy.find (PUBLISHED_SAMEAS_LOCAL)) != map_cpy.end()) {
+        publishedSameasLocal = iter->second;
+    }
+
     if ( (iter = map_cpy.find (LOCAL_ADDRESS)) != map_cpy.end()) {
         localAddress = iter->second;
     }
@@ -3885,6 +3892,7 @@ void ManagerImpl::setAccountDetails (const std::string& accountID, const std::ma
 
     setConfig (accountID, HOSTNAME, hostname);
 
+    setConfig (accountID, PUBLISHED_SAMEAS_LOCAL, publishedSameasLocal);
     setConfig (accountID, LOCAL_ADDRESS, localAddress);
     setConfig (accountID, PUBLISHED_ADDRESS, publishedAddress);
     setConfig (accountID, LOCAL_PORT, localPort);
diff --git a/sflphone-common/src/sip/sipaccount.cpp b/sflphone-common/src/sip/sipaccount.cpp
index f3e99400ea406c80abd60e7a477980dc2416a6d6..297985f2ed6bbeae6bcd8406ef4626d8627bd1d6 100644
--- a/sflphone-common/src/sip/sipaccount.cpp
+++ b/sflphone-common/src/sip/sipaccount.cpp
@@ -25,24 +25,25 @@
 #include <pwd.h>
 
 SIPAccount::SIPAccount (const AccountID& accountID)
-        : Account (accountID, "sip")
-        , _regc (NULL)
-        , _bRegister (false)
-        , _registrationExpire ("")
-        , _localIpAddress ("")
-        , _publishedIpAddress ("")
-        , _actualSessionAddress ("")
-        , _localPort (atoi (DEFAULT_SIP_PORT))
-        , _publishedPort (atoi (DEFAULT_SIP_PORT))
-        , _actualSessionPort (atoi (DEFAULT_SIP_PORT))
-        , _transportType (PJSIP_TRANSPORT_UNSPECIFIED)
-        , _resolveOnce (false)
-        , _credentialCount (0)
-        , _cred (NULL)
-        , _realm (DEFAULT_REALM)
-        , _authenticationUsername ("")
-        , _tlsSetting (NULL)
-        , _displayName ("")
+	: Account (accountID, "sip")
+	, _regc (NULL)
+	, _bRegister (false)
+	, _registrationExpire ("")
+	, _publishedSameasLocal(true)
+	, _localIpAddress ("")
+	, _publishedIpAddress ("")
+	, _actualSessionAddress ("")
+	, _localPort (atoi (DEFAULT_SIP_PORT))
+	, _publishedPort (atoi (DEFAULT_SIP_PORT))
+	, _actualSessionPort (atoi (DEFAULT_SIP_PORT))
+	, _transportType (PJSIP_TRANSPORT_UNSPECIFIED)
+	, _resolveOnce (false)
+	, _credentialCount (0)
+	, _cred (NULL)
+	, _realm (DEFAULT_REALM)
+	, _authenticationUsername ("")
+	, _tlsSetting (NULL)
+	, _displayName ("")
 {
     /* SIPVoIPlink is used as a singleton, because we want to have only one link for all the SIP accounts created */
     /* So instead of creating a new instance, we just fetch the static instance, or create one if it is not yet */
diff --git a/sflphone-common/src/sip/sipaccount.h b/sflphone-common/src/sip/sipaccount.h
index 7a5b9af4be3a508d54954b6c41a8e037f843ac4e..50fe17d8f1637d623cc047d7635793a9e2536847 100644
--- a/sflphone-common/src/sip/sipaccount.h
+++ b/sflphone-common/src/sip/sipaccount.h
@@ -143,7 +143,7 @@ class SIPAccount : public Account
          */
         inline bool isTlsEnabled(void) { return (_transportType == PJSIP_TRANSPORT_TLS) ? true: false; }
 		
-		/**
+	/**
          * @return bool Tells if current transport for that 
          * account is set to OTHER.
          */
@@ -188,6 +188,21 @@ class SIPAccount : public Account
          */
         std::string getContactHeader(const std::string& address, const std::string& port);
 
+
+	/**
+	 * Get a flag which determine the usage in sip headers of either the local 
+	 * IP address and port (_localAddress and _localPort) or to an address set 
+	 * manually (_publishedAddress and _publishedPort). 
+	 */ 
+	bool getPublishedSameasLocal(){ return _publishedSameasLocal; }
+
+	/**
+	 * Set a flag which determine the usage in sip headers of either the local 
+	 * IP address and port (_localAddress and _localPort) or to an address set 
+	 * manually (_publishedAddress and _publishedPort). 
+	 */ 
+	void setPublishedSameasLocal(bool published){ _publishedSameasLocal = published; }
+
         /**
          * Get the port on which the transport/listener should use, or is
          * actually using.
@@ -249,17 +264,17 @@ class SIPAccount : public Account
          */
         inline pjsip_transport_type_e getTransportType(void) { return _transportType; }
         
-		inline pjsip_transport* getAccountTransport (void) { return _transport; }
+	inline pjsip_transport* getAccountTransport (void) { return _transport; }
 
-		inline void setAccountTransport (pjsip_transport *transport) { _transport = transport; }
+	inline void setAccountTransport (pjsip_transport *transport) { _transport = transport; }
 
-		inline std::string getSessionAddress () { return _actualSessionAddress; }
+	inline std::string getSessionAddress () { return _actualSessionAddress; }
+	
+	inline void setSessionAddress (std::string addr) { _actualSessionAddress = addr; }
+	
+	inline pj_uint16_t getSessionPort () { return _actualSessionPort; }
 
-		inline void setSessionAddress (std::string addr) { _actualSessionAddress = addr; }
-		
-		inline pj_uint16_t getSessionPort () { return _actualSessionPort; }
-
-		inline void setSessionPort (pj_uint16_t port) { _actualSessionPort = port; }
+	inline void setSessionPort (pj_uint16_t port) { _actualSessionPort = port; }
 
 
     private: 
@@ -312,6 +327,10 @@ class SIPAccount : public Account
 
         // Network settings
         std::string _registrationExpire;
+
+	// Flag which determine if _localIpAddress or _publishedIpAddress is used in 
+        // sip headers
+	bool _publishedSameasLocal;
                 
         std::string _localIpAddress;
         std::string _publishedIpAddress;