Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
eacbfb43
Commit
eacbfb43
authored
16 years ago
by
Emmanuel Milou
Browse files
Options
Downloads
Patches
Plain Diff
Migrate STUN configuration to the main config window
parent
edde8c9b
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
sflphone-gtk/src/accountwindow.c
+38
-77
38 additions, 77 deletions
sflphone-gtk/src/accountwindow.c
sflphone-gtk/src/configwindow.c
+637
-496
637 additions, 496 deletions
sflphone-gtk/src/configwindow.c
sflphone-gtk/src/configwindow.h
+2
-0
2 additions, 0 deletions
sflphone-gtk/src/configwindow.h
with
677 additions
and
573 deletions
sflphone-gtk/src/accountwindow.c
+
38
−
77
View file @
eacbfb43
...
...
@@ -34,9 +34,7 @@ account_t * currentAccount;
GtkDialog
*
dialog
;
GtkWidget
*
hbox
;
GtkWidget
*
frame
;
GtkWidget
*
frameNat
;
GtkWidget
*
table
;
GtkWidget
*
tableNat
;
GtkWidget
*
label
;
GtkWidget
*
entryID
;
GtkWidget
*
entryAlias
;
...
...
@@ -45,30 +43,13 @@ GtkWidget * entryEnabled;
GtkWidget
*
entryUsername
;
GtkWidget
*
entryHostname
;
GtkWidget
*
entryPassword
;
GtkWidget
*
stunServer
;
GtkWidget
*
stunEnable
;
GtkWidget
*
entryMailbox
;
/* Signal to entryProtocol 'changed' */
void
change_protocol
(
account_t
*
currentAccount
UNUSED
)
{
gchar
*
proto
=
(
gchar
*
)
gtk_combo_box_get_active_text
(
GTK_COMBO_BOX
(
entryProtocol
));
//g_print("Protocol changed\n");
// toggle sensitivity for: entryUserPart
if
(
strcmp
(
proto
,
"SIP"
)
==
0
)
{
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
(
stunEnable
),
FALSE
);
gtk_widget_set_sensitive
(
GTK_WIDGET
(
stunServer
),
FALSE
);
}
else
{
// Should not get here.
g_print
(
"Unknown protocol: %s
\n
"
,
proto
);
}
(
gchar
*
)
gtk_combo_box_get_active_text
(
GTK_COMBO_BOX
(
entryProtocol
));
}
int
...
...
@@ -81,14 +62,6 @@ 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
)
{
...
...
@@ -106,8 +79,6 @@ show_account_window (account_t * a)
gchar
*
curHostname
=
""
;
gchar
*
curPassword
=
""
;
/* TODO: add curProxy, and add boxes for Proxy support */
gchar
*
stun_enabled
=
"FALSE"
;
gchar
*
stun_server
=
"stun.fwdnet.net:3478"
;
gchar
*
curMailbox
=
"888"
;
// Load from SIP/IAX/Unknown ?
...
...
@@ -123,8 +94,9 @@ show_account_window (account_t * a)
curMailbox
=
g_hash_table_lookup
(
currentAccount
->
properties
,
ACCOUNT_MAILBOX
);
if
(
strcmp
(
curAccountType
,
"SIP"
)
==
0
)
{
stun_enabled
=
g_hash_table_lookup
(
currentAccount
->
properties
,
ACCOUNT_SIP_STUN_ENABLED
);
/*
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
...
...
@@ -251,56 +223,19 @@ show_account_window (account_t * a)
gtk_widget_show_all
(
table
);
gtk_container_set_border_width
(
GTK_CONTAINER
(
table
),
10
);
frameNat
=
gtk_frame_new
(
_
(
"Network Address Translation"
)
);
gtk_box_pack_start
(
GTK_BOX
(
dialog
->
vbox
),
frameNat
,
FALSE
,
FALSE
,
0
);
gtk_widget_show
(
frameNat
);
tableNat
=
gtk_table_new
(
2
,
2
,
FALSE
/* homogeneous */
);
gtk_table_set_row_spacings
(
GTK_TABLE
(
tableNat
),
10
);
gtk_table_set_col_spacings
(
GTK_TABLE
(
tableNat
),
10
);
gtk_widget_show
(
tableNat
);
gtk_container_add
(
GTK_CONTAINER
(
frameNat
)
,
tableNat
);
// NAT detection code section
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
);
#if GTK_CHECK_VERSION(2,12,0)
gtk_widget_set_tooltip_text
(
GTK_WIDGET
(
stunEnable
)
,
_
(
"Enable it if you are behind a firewall, then restart SFLphone"
));
#endif
gtk_table_attach
(
GTK_TABLE
(
tableNat
),
stunEnable
,
0
,
1
,
0
,
1
,
GTK_EXPAND
|
GTK_FILL
,
GTK_EXPAND
|
GTK_FILL
,
0
,
0
);
label
=
gtk_label_new_with_mnemonic
(
_
(
"_STUN Server"
));
gtk_table_attach
(
GTK_TABLE
(
tableNat
),
label
,
0
,
1
,
1
,
2
,
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
);
#if GTK_CHECK_VERSION(2,12,0)
gtk_widget_set_tooltip_text
(
GTK_WIDGET
(
stunServer
)
,
_
(
"Format: name.server:port"
));
#endif
gtk_table_attach
(
GTK_TABLE
(
tableNat
),
stunServer
,
1
,
2
,
1
,
2
,
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_sesitive( GTK_WIDGET(entryUserPart), TRUE);<
}
else
if
(
strcmp
(
curAccountType
,
"IAX"
)
==
0
)
{
gtk_widget_set_sensitive
(
GTK_WIDGET
(
stunEnable
),
FALSE
);
gtk_widget_set_sensitive
(
GTK_WIDGET
(
stunServer
),
FALSE
);
//
gtk_widget_set_sensitive( GTK_WIDGET(stunEnable), FALSE);
//
gtk_widget_set_sensitive( GTK_WIDGET(stunServer), FALSE);
}
else
{
// Disable everything ! ouch!
// Shouldn't get there.
}
gtk_widget_show_all
(
tableNat
);
gtk_container_set_border_width
(
GTK_CONTAINER
(
tableNat
),
10
);
response
=
gtk_dialog_run
(
GTK_DIALOG
(
dialog
));
if
(
response
==
GTK_RESPONSE_ACCEPT
)
{
...
...
@@ -329,12 +264,38 @@ show_account_window (account_t * a)
g_strdup
((
gchar
*
)
gtk_entry_get_text
(
GTK_ENTRY
(
entryMailbox
))));
if
(
strcmp
(
proto
,
"SIP"
)
==
0
)
{
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"
));
guint
i
,
size
;
account_t
*
account
;
gchar
*
stun_srv
;
gchar
*
stun_enable
;
gboolean
flag
=
FALSE
;
size
=
account_list_get_size
();
// If a SIP account already exists, fetch its information about STUN
for
(
i
=
0
;
i
<
size
;
i
++
){
account
=
account_list_get_nth
(
i
);
if
(
strcmp
(
g_hash_table_lookup
(
account
->
properties
,
ACCOUNT_TYPE
),
"SIP"
)
==
0
)
{
stun_srv
=
g_hash_table_lookup
(
account
->
properties
,
ACCOUNT_SIP_STUN_SERVER
);
stun_enable
=
g_hash_table_lookup
(
account
->
properties
,
ACCOUNT_SIP_STUN_ENABLED
);
g_hash_table_replace
(
currentAccount
->
properties
,
g_strdup
(
ACCOUNT_SIP_STUN_SERVER
),
g_strdup
(
stun_srv
));
g_hash_table_replace
(
currentAccount
->
properties
,
g_strdup
(
ACCOUNT_SIP_STUN_ENABLED
),
g_strdup
(
stun_enable
));
flag
=
TRUE
;
break
;
}
}
// Otherelse set a default value
if
(
!
flag
)
{
g_hash_table_replace
(
currentAccount
->
properties
,
g_strdup
(
ACCOUNT_SIP_STUN_SERVER
),
(
gchar
*
)
""
);
g_hash_table_replace
(
currentAccount
->
properties
,
g_strdup
(
ACCOUNT_SIP_STUN_ENABLED
),
"FALSE"
);
}
config_window_set_stun_visible
();
}
/** @todo Verify if it's the best condition to check */
...
...
This diff is collapsed.
Click to expand it.
sflphone-gtk/src/configwindow.c
+
637
−
496
View file @
eacbfb43
...
...
@@ -31,6 +31,7 @@
#include
<stdlib.h>
#include
<stdio.h>
#include
<string.h>
/**
...
...
@@ -49,6 +50,12 @@ GtkWidget *restoreButton;
GtkWidget
*
accountMoveDownButton
;
GtkWidget
*
accountMoveUpButton
;
/* STUN configuration part */
GtkWidget
*
stunEnable
;
GtkWidget
*
stunFrame
;
GtkWidget
*
stunServer
;
GtkWidget
*
applyButton
;
GtkWidget
*
status
;
account_t
*
selectedAccount
;
...
...
@@ -102,11 +109,14 @@ config_window_fill_account_list()
* Delete an account
*/
static
void
delete_account
(
GtkWidget
*
widget
UNUSED
,
gpointer
data
UNUSED
)
delete_account
(
GtkWidget
*
widget
,
gpointer
data
UNUSED
)
{
if
(
selectedAccount
)
{
dbus_remove_account
(
selectedAccount
->
accountID
);
if
(
account_list_get_sip_account_number
()
==
1
&&
strcmp
(
g_hash_table_lookup
(
selectedAccount
->
properties
,
ACCOUNT_TYPE
),
"SIP"
)
==
0
)
gtk_widget_set_sensitive
(
GTK_WIDGET
(
stunFrame
),
FALSE
);
}
}
...
...
@@ -425,7 +435,7 @@ create_accounts_tab()
deleteButton
=
gtk_button_new_from_stock
(
GTK_STOCK_REMOVE
);
g_signal_connect_swapped
(
G_OBJECT
(
deleteButton
),
"clicked"
,
G_CALLBACK
(
delete_account
),
NULL
);
G_CALLBACK
(
delete_account
),
stunFrame
);
gtk_box_pack_start
(
GTK_BOX
(
buttonBox
),
deleteButton
,
FALSE
,
FALSE
,
0
);
gtk_widget_show
(
deleteButton
);
...
...
@@ -436,6 +446,120 @@ create_accounts_tab()
return
ret
;
}
void
stun_state
(
void
)
{
guint
i
,
size
;
gchar
*
stun_enabled
=
"FALSE"
;
account_t
*
account
;
gboolean
stunActive
=
(
gboolean
)
gtk_toggle_button_get_active
(
GTK_TOGGLE_BUTTON
(
stunEnable
));
gtk_widget_set_sensitive
(
GTK_WIDGET
(
stunServer
)
,
stunActive
);
// Check if we actually change the state
size
=
account_list_get_size
();
for
(
i
=
0
;
i
<
size
;
i
++
)
{
account
=
account_list_get_nth
(
i
);
if
(
strcmp
(
g_hash_table_lookup
(
account
->
properties
,
ACCOUNT_TYPE
),
"SIP"
)
==
0
)
{
stun_enabled
=
g_hash_table_lookup
(
account
->
properties
,
ACCOUNT_SIP_STUN_ENABLED
);
break
;
}
}
if
(
(
stunActive
&&
strcmp
(
stun_enabled
,
"FALSE"
)
==
0
)
||
(
!
stunActive
&&
strcmp
(
stun_enabled
,
"TRUE"
)
==
0
)
)
{
gtk_widget_set_sensitive
(
GTK_WIDGET
(
applyButton
)
,
TRUE
);
}
else
gtk_widget_set_sensitive
(
GTK_WIDGET
(
applyButton
)
,
FALSE
);
}
void
update_registration
(
void
)
{
guint
nb_accounts
,
i
;
account_t
*
current
;
nb_accounts
=
account_list_get_size
();
for
(
i
=
0
;
i
<
nb_accounts
;
i
++
){
current
=
account_list_get_nth
(
i
);
// If SIP account, then set the new value
if
(
strcmp
(
g_hash_table_lookup
(
current
->
properties
,
ACCOUNT_TYPE
),
"SIP"
)
==
0
)
{
g_hash_table_replace
(
current
->
properties
,
g_strdup
(
ACCOUNT_SIP_STUN_SERVER
),
g_strdup
((
gchar
*
)
gtk_entry_get_text
(
GTK_ENTRY
(
stunServer
))));
g_hash_table_replace
(
current
->
properties
,
g_strdup
(
ACCOUNT_SIP_STUN_ENABLED
),
g_strdup
(
gtk_toggle_button_get_active
(
GTK_TOGGLE_BUTTON
(
stunEnable
))
?
"TRUE"
:
"FALSE"
));
dbus_set_account_details
(
current
);
}
}
gtk_widget_set_sensitive
(
GTK_WIDGET
(
applyButton
)
,
FALSE
);
}
GtkWidget
*
create_stun_tab
()
{
GtkWidget
*
tableNat
;
gchar
*
stun_server
=
"stun.fwdnet.net:3478"
;
gchar
*
stun_enabled
=
"FALSE"
;
GtkWidget
*
label
;
account_t
*
account
;
guint
i
,
size
;
// All SIP accounts are supposed to have the same STUN configuration
// So let's take the first SIP account we find
size
=
account_list_get_size
();
for
(
i
=
0
;
i
<
size
;
i
++
)
{
account
=
account_list_get_nth
(
i
);
if
(
strcmp
(
g_hash_table_lookup
(
account
->
properties
,
ACCOUNT_TYPE
),
"SIP"
)
==
0
)
{
stun_enabled
=
g_hash_table_lookup
(
account
->
properties
,
ACCOUNT_SIP_STUN_ENABLED
);
stun_server
=
g_hash_table_lookup
(
account
->
properties
,
ACCOUNT_SIP_STUN_SERVER
);
break
;
}
}
tableNat
=
gtk_table_new
(
3
,
2
,
FALSE
/* homogeneous */
);
// NAT detection code section
label
=
gtk_label_new
(
_
(
"Stun parameters will apply to each SIP account created."
));
gtk_table_attach
(
GTK_TABLE
(
tableNat
),
label
,
0
,
2
,
0
,
1
,
GTK_EXPAND
|
GTK_FILL
,
GTK_EXPAND
|
GTK_FILL
,
0
,
0
);
gtk_misc_set_alignment
(
GTK_MISC
(
label
),
0
.
5
,
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
);
#if GTK_CHECK_VERSION(2,12,0)
gtk_widget_set_tooltip_text
(
GTK_WIDGET
(
stunEnable
)
,
_
(
"Enable it if you are behind a firewall"
));
#endif
gtk_table_attach
(
GTK_TABLE
(
tableNat
),
stunEnable
,
0
,
1
,
1
,
2
,
GTK_EXPAND
|
GTK_FILL
,
GTK_EXPAND
|
GTK_FILL
,
0
,
0
);
stunServer
=
gtk_entry_new
();
gtk_label_set_mnemonic_widget
(
GTK_LABEL
(
label
),
stunServer
);
gtk_entry_set_text
(
GTK_ENTRY
(
stunServer
),
stun_server
);
#if GTK_CHECK_VERSION(2,12,0)
gtk_widget_set_tooltip_text
(
GTK_WIDGET
(
stunServer
)
,
_
(
"Format: name.server:port"
));
#endif
gtk_table_attach
(
GTK_TABLE
(
tableNat
),
stunServer
,
1
,
2
,
1
,
2
,
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
)));
applyButton
=
gtk_button_new_from_stock
(
GTK_STOCK_APPLY
);
gtk_widget_set_size_request
(
GTK_WIDGET
(
applyButton
),
100
,
30
);
gtk_widget_set_sensitive
(
GTK_WIDGET
(
applyButton
),
FALSE
);
gtk_table_attach
(
GTK_TABLE
(
tableNat
),
applyButton
,
0
,
2
,
2
,
3
,
GTK_EXPAND
|
GTK_FILL
,
GTK_EXPAND
|
GTK_FILL
,
0
,
0
);
g_signal_connect
(
G_OBJECT
(
applyButton
)
,
"clicked"
,
update_registration
,
NULL
);
gtk_widget_show_all
(
tableNat
);
gtk_container_set_border_width
(
GTK_CONTAINER
(
tableNat
),
15
);
return
tableNat
;
}
GtkWidget
*
create_general_settings
()
{
...
...
@@ -563,8 +687,8 @@ create_general_settings ()
gtk_widget_show
(
hbox
);
gtk_container_add
(
GTK_CONTAINER
(
frame
)
,
hbox
);
GtkWidget
*
applyButton
=
gtk_button_new_
with_label
(
_
(
"Apply"
)
);
gtk_widget_set_size_request
(
applyButton
,
6
0
,
35
);
GtkWidget
*
applyButton
=
gtk_button_new_
from_stock
(
GTK_STOCK_APPLY
);
//
gtk_widget_set_size_request(applyButton,
10
0, 35);
//gtk_widget_set_sensitive( GTK_WIDGET(applyButton), (n==0)?FALSE:TRUE );
label
=
gtk_label_new
(
_
(
"Port:"
));
...
...
@@ -668,6 +792,19 @@ show_accounts_window( void )
gtk_container_add
(
GTK_CONTAINER
(
accountFrame
)
,
tab
);
// Stun Frame, displayed only if at least 1 SIP account is configured
stunFrame
=
gtk_frame_new
(
_
(
"Network Address Translation"
));
gtk_box_pack_start
(
GTK_BOX
(
dialog
->
vbox
),
stunFrame
,
TRUE
,
TRUE
,
0
);
gtk_container_set_border_width
(
GTK_CONTAINER
(
stunFrame
),
10
);
gtk_widget_show
(
stunFrame
);
gtk_container_add
(
GTK_CONTAINER
(
stunFrame
),
create_stun_tab
());
if
(
account_list_get_sip_account_number
()
==
0
)
{
gtk_widget_set_sensitive
(
GTK_WIDGET
(
stunFrame
),
FALSE
);
}
gtk_dialog_run
(
dialog
);
accDialogOpen
=
FALSE
;
...
...
@@ -677,3 +814,7 @@ show_accounts_window( void )
toolbar_update_buttons
();
}
void
config_window_set_stun_visible
()
{
gtk_widget_set_sensitive
(
GTK_WIDGET
(
stunFrame
),
TRUE
);
}
This diff is collapsed.
Click to expand it.
sflphone-gtk/src/configwindow.h
+
2
−
0
View file @
eacbfb43
...
...
@@ -109,4 +109,6 @@ void show_config_window();
*/
void
show_accounts_window
();
void
config_window_set_stun_visible
();
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment