Commit c3a19abb authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

NAT detection implementation

The user can choose in the account window if he wants to enable STUN
parent dba411ad
......@@ -37,6 +37,8 @@
#define ACCOUNT_SIP_AUTH_NAME "SIP.username"
#define ACCOUNT_SIP_PASSWORD "SIP.password"
#define ACCOUNT_SIP_PROXY "SIP.proxy"
#define ACCOUNT_SIP_STUN_SERVER "STUN.server"
#define ACCOUNT_SIP_STUN_ENABLED "STUN.enable"
#define ACCOUNT_IAX_FULL_NAME "IAX.fullName"
#define ACCOUNT_IAX_HOST "IAX.host"
......
......@@ -41,6 +41,8 @@ GtkWidget * entryUserPart;
GtkWidget * entryHostPart;
GtkWidget * entryUsername;
GtkWidget * entryPassword;
GtkWidget * stunServer;
GtkWidget * stunEnable;
/**
......@@ -62,10 +64,14 @@ change_protocol (account_t * currentAccount)
// toggle sensitivity for: entryUserPart
if (strcmp(proto, "SIP") == 0) {
gtk_widget_set_sensitive( GTK_WIDGET(entryUserPart), TRUE);
gtk_widget_set_sensitive( GTK_WIDGET(entryUserPart), TRUE);
gtk_widget_set_sensitive( GTK_WIDGET(stunEnable), TRUE);
gtk_widget_set_sensitive( GTK_WIDGET(stunServer), TRUE);
}
else if (strcmp(proto, "IAX") == 0) {
gtk_widget_set_sensitive( GTK_WIDGET(entryUserPart), FALSE);
gtk_widget_set_sensitive( GTK_WIDGET(stunEnable), FALSE);
gtk_widget_set_sensitive( GTK_WIDGET(stunServer), FALSE);
}
else {
// Should not get here.
......@@ -83,6 +89,14 @@ is_iax_enabled(void)
return FALSE;
}
void
stun_state( void )
{
gboolean stunActive = (gboolean)gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( stunEnable ));
gtk_widget_set_sensitive( GTK_WIDGET( stunServer ) , stunActive );
}
void
show_account_window (account_t * a)
{
......@@ -100,6 +114,8 @@ show_account_window (account_t * a)
gchar * curUsername = "";
gchar * curFullName = "";
/* TODO: add curProxy, and add boxes for Proxy support */
gchar * stun_enabled = "FALSE";
gchar * stun_server= "";
// Load from SIP/IAX/Unknown ?
if(a)
......@@ -120,6 +136,8 @@ show_account_window (account_t * a)
curUsername = g_hash_table_lookup(currentAccount->properties, ACCOUNT_SIP_AUTH_NAME);
curFullName = g_hash_table_lookup(currentAccount->properties, ACCOUNT_SIP_FULL_NAME);
curUserPart = g_hash_table_lookup(currentAccount->properties, ACCOUNT_SIP_USER_PART);
stun_enabled = g_hash_table_lookup(currentAccount->properties, ACCOUNT_SIP_STUN_ENABLED);
stun_server = g_hash_table_lookup(currentAccount->properties, ACCOUNT_SIP_STUN_SERVER);
}
}
else
......@@ -132,14 +150,16 @@ show_account_window (account_t * a)
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_OK,
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE,
GTK_RESPONSE_ACCEPT,
NULL));
gtk_dialog_set_has_separator(dialog, TRUE);
gtk_container_set_border_width (GTK_CONTAINER(dialog), 0);
table = gtk_table_new ( 8, 2 , FALSE /* homogeneous */);
table = gtk_table_new ( 8, 4 , FALSE/* homogeneous */);
gtk_table_set_row_spacings( GTK_TABLE(table), 10);
gtk_table_set_col_spacings( GTK_TABLE(table), 10);
......@@ -164,7 +184,7 @@ show_account_window (account_t * a)
// strcmp(g_hash_table_lookup(currentAccount->properties, ACCOUNT_REGISTER),"TRUE") == 0 ? TRUE: FALSE);
//gtk_table_attach ( GTK_TABLE( table ), entryRegister, 0, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
label = gtk_label_new_with_mnemonic (_("_Alias:"));
label = gtk_label_new_with_mnemonic (_("_Alias"));
gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
entryName = gtk_entry_new();
......@@ -242,13 +262,37 @@ show_account_window (account_t * a)
gtk_entry_set_text(GTK_ENTRY(entryPassword), curPassword);
gtk_table_attach ( GTK_TABLE( table ), entryPassword, 1, 2, 9, 10, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
// NAT detection code section
label = gtk_label_new("");
gtk_label_set_markup(GTK_LABEL( label ),_("<b>NAT Detection</b>"));
gtk_table_attach( GTK_TABLE( table ), label, 3, 4, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
stunEnable = gtk_check_button_new_with_mnemonic(_("E_nable STUN"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stunEnable),
strcmp(stun_enabled,"TRUE") == 0 ? TRUE: FALSE);
g_signal_connect( G_OBJECT (GTK_TOGGLE_BUTTON(stunEnable)) , "toggled" , G_CALLBACK( stun_state ), NULL);
gtk_widget_set_tooltip_text( GTK_WIDGET( stunEnable ) , _("Enable it if you are behind a firewall, then restart SFLphone"));
gtk_table_attach ( GTK_TABLE( table ), stunEnable, 3, 4, 4, 5, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
label = gtk_label_new_with_mnemonic(_("S_TUN Server"));
gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 5, 6, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
stunServer = gtk_entry_new();
gtk_label_set_mnemonic_widget (GTK_LABEL (label), stunServer);
gtk_entry_set_text(GTK_ENTRY(stunServer), stun_server);
gtk_widget_set_tooltip_text( GTK_WIDGET( stunServer ) , _("Format: name.server:port"));
gtk_table_attach ( GTK_TABLE( table ), stunServer, 3, 4, 5, 6, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_widget_set_sensitive( GTK_WIDGET( stunServer ), gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stunEnable)));
// Toggle enabled/disabled widgets
if (strcmp(curAccountType, "SIP") == 0) {
//gtk_widget_set_sensitive( GTK_WIDGET(entryUserPart), TRUE);<
//gtk_widget_set_sesitive( GTK_WIDGET(entryUserPart), TRUE);<
}
else if (strcmp(curAccountType, "IAX") == 0) {
gtk_widget_set_sensitive( GTK_WIDGET(entryUserPart), FALSE);
gtk_widget_set_sensitive( GTK_WIDGET(stunEnable), FALSE);
gtk_widget_set_sensitive( GTK_WIDGET(stunServer), FALSE);
}
else {
// Disable everything ! ouch!
......@@ -297,6 +341,12 @@ show_account_window (account_t * a)
g_hash_table_replace(currentAccount->properties,
g_strdup(ACCOUNT_SIP_PASSWORD),
g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(entryPassword))));
g_hash_table_replace(currentAccount->properties,
g_strdup(ACCOUNT_SIP_STUN_SERVER),
g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(stunServer))));
g_hash_table_replace(currentAccount->properties,
g_strdup(ACCOUNT_SIP_STUN_ENABLED),
g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stunEnable)) ? "TRUE": "FALSE"));
}
else if (strcmp(proto, "IAX") == 0) { /* Protocol = IAX */
g_hash_table_replace(currentAccount->properties,
......
......@@ -283,7 +283,7 @@ create_toolbar (){
gtk_toolbar_set_style(GTK_TOOLBAR(ret), GTK_TOOLBAR_ICONS);
image = gtk_image_new_from_file( ICONS_DIR "/call.svg");
callButton = gtk_tool_button_new (image, _("Place a Call"));
callButton = gtk_tool_button_new (image, _("Place a call"));
gtk_widget_set_tooltip_text(GTK_WIDGET(callButton), _("Place a call"));
g_signal_connect (G_OBJECT (callButton), "clicked",
G_CALLBACK (call_button), NULL);
......
......@@ -879,7 +879,7 @@ create_accounts_tab()
);
treeView = gtk_tree_view_new_with_model(GTK_TREE_MODEL(accountStore));
//gtk_widget_set_tooltip_text( GTK_WIDGET( treeView ) , _("Double-click to edit the information on this account"));
treeSelection = gtk_tree_view_get_selection(GTK_TREE_VIEW (treeView));
g_signal_connect(G_OBJECT (treeSelection), "changed",
G_CALLBACK (select_account),
......@@ -942,7 +942,8 @@ create_accounts_tab()
gtk_box_pack_start(GTK_BOX(buttonBox), deleteButton, FALSE, FALSE, 0);
gtk_widget_show(deleteButton);
defaultButton = gtk_button_new_with_mnemonic(_("Set as Default"));
defaultButton = gtk_button_new_with_mnemonic(_("Default"));
gtk_widget_set_tooltip_text( GTK_WIDGET( defaultButton ) , _("Set the selected account as the default one to make calls"));
g_signal_connect_swapped(G_OBJECT(defaultButton), "clicked",
G_CALLBACK(default_account), NULL);
gtk_box_pack_start(GTK_BOX(buttonBox), defaultButton, FALSE, FALSE, 0);
......
......@@ -106,6 +106,7 @@ help_about ( void * foo)
"Julien Plissonneau Duquene <julien.plissonneau.duquene@savoirfairelinux.com>",
"Alexandre Bourget <alexandre.bourget@savoirfairelinux.com>",
"Pierre-Luc Beaudoin <pierre-luc@squidy.info>",
"Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>"
"Jean-Philippe Barrette-LaPierre",
"Laurielle Lea",
NULL};
......@@ -440,10 +441,14 @@ create_view_menu()
GtkWidget * menu;
GtkWidget * root_menu;
GtkWidget * menu_items;
GtkWidget * submenu;
GtkWidget * submenu_items;
menu = gtk_menu_new ();
menu_items = gtk_check_menu_item_new_with_mnemonic (_("_Dialpad"));
gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM ( menu_items ), TRUE);
main_window_dialpad(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu_items)));
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
g_signal_connect(G_OBJECT (menu_items), "toggled",
G_CALLBACK (view_dial_pad),
......@@ -458,14 +463,19 @@ create_view_menu()
NULL);
gtk_widget_show (menu_items);
menu_items = gtk_check_menu_item_new_with_mnemonic (_("_Toolbar"));
menu_items = gtk_menu_item_new_with_mnemonic(_("_Toolbar"));
// ICON / TEXT / BOTH
submenu_items = gtk_check_menu_item_new_with_mnemonic(_("Only Icons"));
gtk_menu_item_set_submenu (GTK_MENU_ITEM (submenu_items), menu_items);
submenu_items = gtk_check_menu_item_new_with_mnemonic(_("Only Text"));
gtk_menu_item_set_submenu (GTK_MENU_ITEM (submenu_items), menu_items);
submenu_items = gtk_check_menu_item_new_with_mnemonic(_("Icons & Text"));
gtk_menu_item_set_submenu (GTK_MENU_ITEM (submenu_items), menu_items);
gtk_widget_show( menu_items );
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
gtk_widget_set_sensitive( GTK_WIDGET(menu_items), FALSE);
g_signal_connect(G_OBJECT (menu_items), "toggled",
G_CALLBACK (view_dial_pad),
NULL);
gtk_widget_show (menu_items);
root_menu = gtk_menu_item_new_with_mnemonic (_("_View"));
gtk_menu_item_set_submenu (GTK_MENU_ITEM (root_menu), menu);
......
......@@ -21,7 +21,7 @@ msgid "Pick up"
msgstr "Décrocher"
msgid "Place a call"
msgstr "Nouvel Appel"
msgstr "Appeler"
msgid "On _Hold"
msgstr "_Mettre en attente"
......@@ -32,14 +32,14 @@ msgstr "Mettre en attente"
msgid "Off Hold"
msgstr "Reprendre"
msgid "Tranfer"
msgid "Transfer"
msgstr "Transférer"
msgid "_New call"
msgstr "_Nouvel appel"
msgid "_Call"
msgstr "_Appeler"
msgstr "_Actions"
msgid "_Edit"
msgstr "_Options"
......@@ -70,8 +70,8 @@ msgstr "_Protocole"
msgid "Status"
msgstr "Statut"
msgid "Set as Default"
msgstr "Choisir par Défaut"
msgid "Default"
msgstr "Défaut"
msgid "Account settings"
msgstr "Configuration des comptes"
......@@ -79,6 +79,10 @@ msgstr "Configuration des comptes"
msgid "_Enabled"
msgstr "_Activé"
msgid "_Alias"
msgstr "A_lias"
msgid "Unknown"
msgstr "Inconnu"
......@@ -92,11 +96,29 @@ msgid "_Host part"
msgstr "_Serveur"
msgid "U_sername"
msgstr "U_sager"
msgstr "Usa_ger"
msgid "_Password"
msgstr "_Mot de passe"
msgid "<b>NAT Detection</b>"
msgstr "<b>Détection NAT</b>"
msgid "E_nable STUN"
msgstr "A_ctiver STUN"
msgid "S_TUN Server"
msgstr "S_erveur STUN"
msgid "Format: name.server:port"
msgstr "Format: nom.serveur:port"
msgid "Enable it if you are behind a firewall, then restart SFLphone"
msgstr "À activer si vous êtes derrière un pare-feu, puis redémarrez SFLphone"
msgid "Set the selected account as the default one to make calls"
msgstr "Utiliser le compte sélectionné pour passer des appels par défaut"
# audio settings
msgid "Output peripheral"
msgstr "Périphérique de sortie"
......@@ -161,3 +183,10 @@ msgstr "En cours..."
msgid "Invalid"
msgstr "Non valide"
# Sliders
msgid "Speakers volume"
msgstr "Volume des hauts-parleurs"
msgid "Mic volume"
msgstr "Volume du micro"
......@@ -45,8 +45,9 @@ typedef std::string AccountID;
#define SIP_PASSWORD "SIP.password"
#define SIP_HOST_PART "SIP.hostPart"
#define SIP_PROXY "SIP.proxy"
#define SIP_STUN_SERVER "STUN.STUNserver"
#define SIP_USE_STUN "STUN.useStun"
#define SIP_STUN_SERVER "STUN.server"
#define SIP_USE_STUN "STUN.enable"
#define SIP_STUN_PORT "STUN.port"
/**
* Class account is an interface to protocol account (SIPAccount, IAXAccount)
......
......@@ -2010,9 +2010,9 @@ ManagerImpl::setAccountDetails( const ::DBus::String& accountID,
setConfig(accountID, SIP_PASSWORD, (*details.find(SIP_PASSWORD)).second);
setConfig(accountID, SIP_HOST_PART, (*details.find(SIP_HOST_PART)).second);
//setConfig(accountID, SIP_PROXY, (*details.find(SIP_PROXY)).second);
//setConfig(accountID, SIP_STUN_SERVER,(*details.find(SIP_STUN_SERVER)).second);
//setConfig(accountID, SIP_USE_STUN,
// (*details.find(SIP_USE_STUN)).second == "TRUE" ? "1" : "0");
setConfig(accountID, SIP_STUN_SERVER,(*details.find(SIP_STUN_SERVER)).second);
setConfig(accountID, SIP_USE_STUN,
(*details.find(SIP_USE_STUN)).second == "TRUE" ? "1" : "0");
}
else if (accountType == "IAX") {
setConfig(accountID, IAX_FULL_NAME, (*details.find(IAX_FULL_NAME)).second);
......
......@@ -43,7 +43,7 @@ SIPAccount::registerVoIPLink()
int useStun = Manager::instance().getConfigInt(_accountID,SIP_USE_STUN);
SIPVoIPLink* thislink = dynamic_cast<SIPVoIPLink*> (_link);
thislink->setStunServer(Manager::instance().getConfigString(_accountID,DFT_STUN_SERVER));
thislink->setStunServer(Manager::instance().getConfigString(_accountID,SIP_STUN_SERVER));
thislink->setUseStun( useStun!=0 ? true : false);
_link->init();
......
......@@ -48,8 +48,6 @@
#define PLAY_TONES "DTMF.playTones"
#define PULSE_LENGTH "DTMF.pulseLength"
#define SEND_DTMF_AS "DTMF.sendDTMFas"
#define STUN_SERVER "STUN.STUNserver"
#define USE_STUN "STUN.useStun"
#define ALSA_CARD_ID_IN "Alsa.cardID_In"
#define ALSA_CARD_ID_OUT "Alsa.cardID_Out"
#define ALSA_SAMPLE_RATE "Alsa.sampleRate"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment