Skip to content
Snippets Groups Projects
Commit 6c8e8710 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#2623] Added text entry to display local IP address in configurationmanager

parent a5da339b
Branches
Tags
No related merge requests found
......@@ -67,6 +67,7 @@ GtkWidget * advancedZrtpButton;
GtkWidget * keyExchangeCombo;
GtkWidget * useSipTlsCheckBox;
GtkWidget * localAddressEntry;
GtkWidget * publishedAddressEntry;
GtkWidget * localAddressLabel;
GtkWidget * localAddressCombo;
......@@ -562,17 +563,20 @@ static local_interface_changed_cb(GtkWidget * widget, gpointer data UNUSED) {
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(sameAsLocalRadioButton))) {
gchar *local_interface;
gchar *local_address;
gchar *local_iface_name;
gchar *local_iface_addr;
local_iface_addr = g_malloc(36);
local_interface = (gchar *) gtk_combo_box_get_active_text (GTK_COMBO_BOX (localAddressCombo));
local_iface_name = (gchar *) gtk_combo_box_get_active_text (GTK_COMBO_BOX (localAddressCombo));
// sflphone_get_interface_addr_from_name((char *)local_interface);
local_address = dbus_get_address_from_interface_name (local_interface);
sflphone_get_interface_addr_from_name(local_iface_name, &local_iface_addr);
gtk_entry_set_text (GTK_ENTRY(publishedAddressEntry), local_address);
gtk_entry_set_text(GTK_ENTRY(localAddressEntry), local_iface_addr);
gtk_entry_set_text (GTK_ENTRY(publishedAddressEntry), local_iface_addr);
// 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));
g_free(local_iface_addr);
}
}
......@@ -901,7 +905,7 @@ GtkWidget* create_network (account_t **a) {
local_port = g_hash_table_lookup ((*a)->properties, LOCAL_PORT);
}
gnome_main_section_new_with_table (_("Network Interface"), &frame, &table, 2, 2);
gnome_main_section_new_with_table (_("Network Interface"), &frame, &table, 2, 3);
gtk_container_set_border_width (GTK_CONTAINER(table), 10);
gtk_table_set_row_spacings( GTK_TABLE(table), 5);
......@@ -918,7 +922,7 @@ GtkWidget* create_network (account_t **a) {
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);
GtkTreeIter current_local_address_iter = iter;
GtkTreeIter current_local_iface_iter = iter;
gchar ** iface_list = NULL;
// iface_list = (gchar**) dbus_get_all_ip_interface();
iface_list = (gchar**) dbus_get_all_ip_interface_by_name();
......@@ -927,6 +931,11 @@ GtkWidget* create_network (account_t **a) {
// flag to determine if local_address is found
gboolean iface_found = FALSE;
gchar *local_iface_addr;
gchar *local_iface_name;
local_iface_addr= g_malloc(18);
if (iface_list != NULL) {
// fill the iterface combo box
......@@ -938,28 +947,42 @@ GtkWidget* create_network (account_t **a) {
// set the current local address
if (!iface_found && (g_strcmp0(*iface, local_interface) == 0)) {
DEBUG("Setting active local address combo box");
current_local_address_iter = iter;
current_local_iface_iter = iter;
iface_found = TRUE;
}
}
if(!iface_found) {
DEBUG("Did not find local ip address, take fisrt in the list");
gtk_tree_model_get_iter_first(GTK_TREE_MODEL(ipInterfaceListStore), &current_local_address_iter);
gtk_tree_model_get_iter_first(GTK_TREE_MODEL(ipInterfaceListStore), &current_local_iface_iter);
}
}
localAddressCombo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(ipInterfaceListStore));
gtk_label_set_mnemonic_widget (GTK_LABEL (label), 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));
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);
gtk_combo_box_set_active_iter(GTK_COMBO_BOX(localAddressCombo), &current_local_iface_iter);
// Fill the text entry with the ip address of local interface selected
localAddressEntry = gtk_entry_new();
local_iface_name = (gchar *) gtk_combo_box_get_active_text (GTK_COMBO_BOX (localAddressCombo));
sflphone_get_interface_addr_from_name(local_iface_name, &local_iface_addr);
gtk_entry_set_text(GTK_ENTRY(localAddressEntry), local_iface_addr);
gtk_widget_set_sensitive(localAddressEntry, FALSE);
gtk_table_attach ( GTK_TABLE( table ), localAddressEntry, 2, 3, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
g_free(local_iface_addr);
// Local port widget
label = gtk_label_new_with_mnemonic (_("Local port"));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment