Commit 36406122 authored by Alexandre Savard's avatar Alexandre Savard

[#2841] Move ringtone preferences in account window

parent da6696cb
......@@ -38,6 +38,7 @@
#include <accountconfigdialog.h>
#include <zrtpadvanceddialog.h>
#include <tlsadvanceddialog.h>
#include <audioconf.h>
// From version 2.16, gtk provides the functionalities libsexy used to provide
#if GTK_CHECK_VERSION(2,16,0)
......@@ -97,6 +98,8 @@ GtkWidget * publishedAddressLabel;
GtkWidget * publishedPortLabel;
GtkWidget * stunServerLabel;
GtkWidget * stunServerEntry;
GtkWidget * enableTone;
GtkWidget * fileChooser;
GtkWidget * displayNameEntry;
......@@ -1207,6 +1210,27 @@ GtkWidget* create_advanced_tab (account_t **a) {
return ret;
}
void ringtone_enabled(GtkWidget *widget UNUSED, gpointer fileChooser, const gchar *accountID)
{
gboolean isEnabled = gtk_widget_get_sensitive(GTK_WIDGET(fileChooser));
if(isEnabled) {
gtk_widget_set_sensitive(GTK_WIDGET(fileChooser), FALSE);
// dbus_ringtone_enabled(accountID);
}
else {
gtk_widget_set_sensitive(GTK_WIDGET(fileChooser), TRUE);
// dbus_ringtone_enabled(accountID);
}
}
void ringtone_changed( GtkFileChooser *chooser , GtkLabel *label UNUSED, const gchar *accountID)
{
// gchar* tone = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER( chooser ));
// dbus_set_ringtone_choice( tone, accountID);
}
GtkWidget* create_codecs_configuration (account_t **a) {
// Main widget
......@@ -1253,6 +1277,37 @@ GtkWidget* create_codecs_configuration (account_t **a) {
gtk_table_attach ( GTK_TABLE( table ), sipinfo, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
}
// Box for the ringtones
gnome_main_section_new_with_table (_("Ringtones"), &frame, &table, 1, 2);
gtk_box_pack_start(GTK_BOX(ret), frame, FALSE, FALSE, 0);
fileChooser = gtk_file_chooser_button_new(_("Choose a ringtone"), GTK_FILE_CHOOSER_ACTION_OPEN);
p = g_hash_table_lookup(currentAccount->properties, g_strdup(CONFIG_RINGTONE_ENABLED));
gboolean ringtoneEnabled = (g_strcmp0(p, "true") == 0) ? TRUE : FALSE;
enableTone = gtk_check_button_new_with_mnemonic( _("_Enable ringtones"));
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(enableTone), ringtoneEnabled);
g_signal_connect(G_OBJECT( enableTone) , "clicked" , G_CALLBACK( ringtone_enabled ), fileChooser);
gtk_table_attach ( GTK_TABLE( table ), enableTone, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
// file chooser button
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER( fileChooser) , g_get_home_dir());
p = g_hash_table_lookup(currentAccount->properties, g_strdup(CONFIG_RINGTONE_PATH));
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER( fileChooser) , p);
gtk_widget_set_sensitive(GTK_WIDGET(fileChooser), ringtoneEnabled);
g_signal_connect( G_OBJECT( fileChooser ) , "selection_changed" , G_CALLBACK( ringtone_changed ) , NULL );
GtkFileFilter *filter = gtk_file_filter_new();
gtk_file_filter_set_name( filter , _("Audio Files") );
gtk_file_filter_add_pattern(filter , "*.wav" );
gtk_file_filter_add_pattern(filter , "*.ul" );
gtk_file_filter_add_pattern(filter , "*.au" );
gtk_file_chooser_add_filter( GTK_FILE_CHOOSER( fileChooser ) , filter);
gtk_table_attach ( GTK_TABLE( table ), fileChooser, 0, 1, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_widget_show_all(ret);
return ret;
......
......@@ -629,33 +629,6 @@ static void codec_move_down(GtkButton *button UNUSED, gpointer data) {
codec_move (FALSE, data);
}
int
is_ringtone_enabled( void )
{
return dbus_is_ringtone_enabled();
}
void
ringtone_enabled(GtkWidget *widget UNUSED, gpointer fileChooser)
{
dbus_ringtone_enabled();
gtk_widget_set_sensitive(GTK_WIDGET(fileChooser), dbus_is_ringtone_enabled());
}
void
ringtone_changed( GtkFileChooser *chooser , GtkLabel *label UNUSED)
{
gchar* tone = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER( chooser ));
dbus_set_ringtone_choice( tone );
}
gchar*
get_ringtone_choice( void )
{
return dbus_get_ringtone_choice();
}
GtkWidget* codecs_box (account_t **a)
{
GtkWidget *ret;
......@@ -900,27 +873,6 @@ GtkWidget* alsa_box()
gtk_table_attach(GTK_TABLE(table), input, 2, 3, 3, 4, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0);
gtk_widget_show(input);
DEBUG("Audio: Configuration rintgtone");
item = gtk_label_new(_("Ringtone"));
gtk_misc_set_alignment(GTK_MISC(item), 0, 0.5);
gtk_table_attach(GTK_TABLE(table), item, 1, 2, 4, 5, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0);
gtk_widget_show(item);
// set choices of ringtone devices
ringtonelist = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
preferences_dialog_fill_ringtone_audio_device_list();
ringtone = gtk_combo_box_new_with_model(GTK_TREE_MODEL(ringtonelist));
select_active_ringtone_audio_device();
gtk_label_set_mnemonic_widget(GTK_LABEL(item), output);
g_signal_connect(G_OBJECT(ringtone), "changed", G_CALLBACK(select_audio_ringtone_device), output);
// Set rendering
renderer = gtk_cell_renderer_text_new();
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(ringtone), renderer, TRUE);
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(ringtone), renderer, "text", 0, NULL);
gtk_table_attach(GTK_TABLE(table), ringtone, 2, 3, 4, 5, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0);
gtk_widget_show(ringtone);
gtk_widget_show_all(ret);
DEBUG("done");
......@@ -1008,31 +960,6 @@ GtkWidget* create_audio_configuration()
g_signal_connect( G_OBJECT( folderChooser ) , "selection_changed" , G_CALLBACK( record_path_changed ) , NULL );
gtk_table_attach(GTK_TABLE(table), folderChooser, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 5);
// Box for the ringtones
gnome_main_section_new_with_table (_("Ringtones"), &frame, &table, 1, 2);
gtk_box_pack_start(GTK_BOX(ret), frame, FALSE, FALSE, 0);
GtkWidget *enableTone;
GtkWidget *fileChooser = gtk_file_chooser_button_new(_("Choose a ringtone"), GTK_FILE_CHOOSER_ACTION_OPEN);
enableTone = gtk_check_button_new_with_mnemonic( _("_Enable ringtones"));
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(enableTone), dbus_is_ringtone_enabled() );
g_signal_connect(G_OBJECT( enableTone) , "clicked" , G_CALLBACK( ringtone_enabled ) , fileChooser);
gtk_table_attach ( GTK_TABLE( table ), enableTone, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
// file chooser button
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER( fileChooser) , g_get_home_dir());
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER( fileChooser) , get_ringtone_choice());
gtk_widget_set_sensitive(GTK_WIDGET(fileChooser), dbus_is_ringtone_enabled());
g_signal_connect( G_OBJECT( fileChooser ) , "selection_changed" , G_CALLBACK( ringtone_changed ) , NULL );
GtkFileFilter *filter = gtk_file_filter_new();
gtk_file_filter_set_name( filter , _("Audio Files") );
gtk_file_filter_add_pattern(filter , "*.wav" );
gtk_file_filter_add_pattern(filter , "*.ul" );
gtk_file_filter_add_pattern(filter , "*.au" );
gtk_file_chooser_add_filter( GTK_FILE_CHOOSER( fileChooser ) , filter);
gtk_table_attach ( GTK_TABLE( table ), fileChooser, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
// Box for the voice enhancement configuration
gnome_main_section_new_with_table (_("Voice enhancement settings"), &frame, &table, 2, 1);
......
......@@ -338,6 +338,7 @@
<tp:docstring>
Return true if ringtone is enabled, false otherwise
</tp:docstring>
<arg type="s" name="accountID" direction="in"/>
<arg type="i" name="bool" direction="out">
<tp:docstring>
</tp:docstring>
......@@ -348,12 +349,14 @@
<tp:docstring>
Unused
</tp:docstring>
<arg type="s" name="accountID" direction="in"/>
</method>
<method name="getRingtoneChoice" tp:name-for-bindings="getRingtoneChoice">
<tp:docstring>
Get current ringtone .au file selected
</tp:docstring>
<arg type="s" name="accountID" direction="in"/>
<arg type="s" name="tone" direction="out">
<tp:docstring>
</tp:docstring>
......@@ -364,6 +367,7 @@
<tp:docstring>
Set current ringtone .au file from list acquired using <tp:member-ref>getAccountList</tp:member-ref>
</tp:docstring>
<arg type="s" name="accountID" direction="in"/>
<arg type="s" name="tone" direction="in">
<tp:docstring>
A valid .au file path
......
......@@ -1572,12 +1572,12 @@ dbus_set_noise_suppress_state(gchar* state)
gchar*
dbus_get_ringtone_choice()
dbus_get_ringtone_choice(const gchar *accountID)
{
gchar* tone;
GError* error = NULL;
org_sflphone_SFLphone_ConfigurationManager_get_ringtone_choice(
configurationManagerProxy, &tone, &error);
configurationManagerProxy, accountID, &tone, &error);
if (error)
{
g_error_free(error);
......@@ -1586,11 +1586,11 @@ dbus_get_ringtone_choice()
}
void
dbus_set_ringtone_choice(const gchar* tone)
dbus_set_ringtone_choice(const gchar *accountID, const gchar* tone)
{
GError* error = NULL;
org_sflphone_SFLphone_ConfigurationManager_set_ringtone_choice(
configurationManagerProxy, tone, &error);
configurationManagerProxy, accountID, tone, &error);
if (error)
{
g_error_free(error);
......@@ -1598,12 +1598,12 @@ dbus_set_ringtone_choice(const gchar* tone)
}
int
dbus_is_ringtone_enabled()
dbus_is_ringtone_enabled(const gchar *accountID)
{
int res;
GError* error = NULL;
org_sflphone_SFLphone_ConfigurationManager_is_ringtone_enabled(
configurationManagerProxy, &res, &error);
configurationManagerProxy, accountID, &res, &error);
if (error)
{
g_error_free(error);
......@@ -1612,11 +1612,13 @@ dbus_is_ringtone_enabled()
}
void
dbus_ringtone_enabled()
dbus_ringtone_enabled(const gchar *accountID)
{
DEBUG("DBUS: Ringtone enabled %s", accountID);
GError* error = NULL;
org_sflphone_SFLphone_ConfigurationManager_ringtone_enabled(
configurationManagerProxy, &error);
configurationManagerProxy, accountID, &error);
if (error)
{
g_error_free(error);
......
......@@ -370,25 +370,25 @@ int dbus_is_iax2_enabled( void );
* @return int 1 if enabled
* 0 otherwise
*/
int dbus_is_ringtone_enabled( void );
int dbus_is_ringtone_enabled( const gchar *accountID );
/**
* ConfigurationManager - Set the ringtone option
* Inverse current value
*/
void dbus_ringtone_enabled( void );
void dbus_ringtone_enabled( const gchar *accountID );
/**
* ConfigurationManager - Get the ringtone
* @return gchar* The file name selected as a ringtone
*/
gchar* dbus_get_ringtone_choice( void );
gchar* dbus_get_ringtone_choice( const gchar *accountID );
/**
* ConfigurationManager - Set a ringtone
* @param tone The file name of the ringtone
*/
void dbus_set_ringtone_choice( const gchar* tone );
void dbus_set_ringtone_choice( const gchar *accountID, const gchar* tone );
/**
* ConfigurationManager - Set the dialpad visible or not
......
......@@ -91,6 +91,9 @@
#define ZRTP "1"
#define SDES "2"
#define CONFIG_RINGTONE_PATH "Account.ringtonePath"
#define CONFIG_RINGTONE_ENABLED "Account.ringtoneEnabled"
#define TLS_LISTENER_PORT "TLS.listenerPort"
#define TLS_ENABLE "TLS.enable"
#define TLS_PORT "TLS.port"
......
......@@ -317,7 +317,7 @@
Provide a list of playback device from ALSA
</tp:docstring>
<annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="VectorString"/>
<arg type="as" name="list" direction="out">
<arg type="as" name="+list" direction="out">
<tp:docstring>
</tp:docstring>
</arg>
......@@ -338,6 +338,7 @@
<tp:docstring>
Return true if ringtone is enabled, false otherwise
</tp:docstring>
<arg type="s" name="accountID" direction="in" />
<arg type="i" name="bool" direction="out">
<tp:docstring>
</tp:docstring>
......@@ -346,14 +347,15 @@
<method name="ringtoneEnabled" tp:name-for-bindings="ringtoneEnabled">
<tp:docstring>
Unused
</tp:docstring>
<arg type="s" name="accountID" direction="in"/>
</method>
<method name="getRingtoneChoice" tp:name-for-bindings="getRingtoneChoice">
<tp:docstring>
Get current ringtone .au file selected
</tp:docstring>
<arg type="s" name="accountID" direction="in"/>
<arg type="s" name="tone" direction="out">
<tp:docstring>
</tp:docstring>
......@@ -364,6 +366,7 @@
<tp:docstring>
Set current ringtone .au file from list acquired using <tp:member-ref>getAccountList</tp:member-ref>
</tp:docstring>
<arg type="s" name="accountID" direction="in"/>
<arg type="s" name="tone" direction="in">
<tp:docstring>
A valid .au file path
......
......@@ -541,20 +541,20 @@ int32_t ConfigurationManager::isIax2Enabled(void) {
return Manager::instance().isIax2Enabled();
}
void ConfigurationManager::ringtoneEnabled(void) {
Manager::instance().ringtoneEnabled();
void ConfigurationManager::ringtoneEnabled(const std::string& accountID) {
Manager::instance().ringtoneEnabled(accountID);
}
int32_t ConfigurationManager::isRingtoneEnabled(void) {
return Manager::instance().isRingtoneEnabled();
int32_t ConfigurationManager::isRingtoneEnabled(const std::string& accountID) {
return Manager::instance().isRingtoneEnabled(accountID);
}
std::string ConfigurationManager::getRingtoneChoice(void) {
return Manager::instance().getRingtoneChoice();
std::string ConfigurationManager::getRingtoneChoice(const std::string& accountID) {
return Manager::instance().getRingtoneChoice(accountID);
}
void ConfigurationManager::setRingtoneChoice(const std::string& tone) {
Manager::instance().setRingtoneChoice(tone);
void ConfigurationManager::setRingtoneChoice(const std::string& accountID, const std::string& tone) {
Manager::instance().setRingtoneChoice(accountID, tone);
}
std::string ConfigurationManager::getRecordPath(void) {
......
......@@ -103,10 +103,10 @@ public:
bool isMd5CredentialHashing (void);
void setMd5CredentialHashing (const bool& enabled);
int32_t isIax2Enabled( void );
int32_t isRingtoneEnabled( void );
void ringtoneEnabled( void );
std::string getRingtoneChoice( void );
void setRingtoneChoice( const std::string& tone );
int32_t isRingtoneEnabled( const std::string& accountID );
void ringtoneEnabled( const std::string& accountID );
std::string getRingtoneChoice( const std::string& accountID );
void setRingtoneChoice( const std::string& accountID, const std::string& tone );
std::string getRecordPath( void );
void setRecordPath(const std::string& recPath );
......
......@@ -1914,7 +1914,14 @@ void ManagerImpl::ringtone () {
_debug("Manager: Ringtone");
if (isRingtoneEnabled()) {
Account *account = getAccount(IP2IP_PROFILE);
if(!account) {
_warn("Manager: Warning: invalid account in ringtone");
return;
}
if (account->getRingtoneEnabled()) {
_debug ("Manager: Tone is enabled");
//TODO Comment this because it makes the daemon crashes since the main thread
......@@ -2350,17 +2357,31 @@ int ManagerImpl::isIax2Enabled (void) {
#endif
}
int ManagerImpl::isRingtoneEnabled (void) {
return preferences.getRingtoneEnabled() ? 1 : 0;
int ManagerImpl::isRingtoneEnabled (const AccountID& id) {
Account *account = getAccount(id);
if(!account) {
_warn("Manager: Warning: invalid account in ringtone enabled");
return 0;
}
return account->getRingtoneEnabled() ? 1 : 0;
}
void ManagerImpl::ringtoneEnabled (void) {
void ManagerImpl::ringtoneEnabled (const AccountID& id) {
Account *account = getAccount(id);
if(!account) {
_warn("Manager: Warning: invalid account in ringtone enabled");
return;
}
preferences.getRingtoneEnabled() ? preferences.setRingtoneEnabled(false) : preferences.setRingtoneEnabled(true);
account->getRingtoneEnabled() ? account->setRingtoneEnabled(false) : account->setRingtoneEnabled(true);
}
std::string ManagerImpl::getRingtoneChoice (void) {
std::string ManagerImpl::getRingtoneChoice (const AccountID& id) {
// retreive specified account id
Account *account = getAccount(IP2IP_PROFILE);
......@@ -2388,7 +2409,7 @@ std::string ManagerImpl::getRingtoneChoice (void) {
return tone_path;
}
void ManagerImpl::setRingtoneChoice (const std::string& tone) {
void ManagerImpl::setRingtoneChoice (const std::string& tone, const AccountID& id) {
_debug("Manager: Set ringtone path %s to account", tone.c_str());
......
......@@ -613,25 +613,25 @@ class ManagerImpl {
* @return int 1 if enabled
* 0 otherwise
*/
int isRingtoneEnabled( void );
int isRingtoneEnabled( const AccountID& id );
/**
* Set the ringtone option
* Inverse current value
*/
void ringtoneEnabled( void );
void ringtoneEnabled( const AccountID& id );
/**
* Get the ringtone
* @return gchar* The file name selected as a ringtone
*/
std::string getRingtoneChoice( void );
std::string getRingtoneChoice( const AccountID& id);
/**
* Set a ringtone
* @param tone The file name of the ringtone
*/
void setRingtoneChoice( const std::string& );
void setRingtoneChoice( const std::string&, const AccountID& id);
/**
* Get the recording path from configuration tree
......
......@@ -81,7 +81,6 @@
#define WINDOW_POSITION_Y "Window.positionY"
#define SHOW_STATUSICON "Statusicon.show"
#define IP2IP_PROFILE "IP2IP"
#define SIGNALISATION "VoIPLink" /** Section Signalisation */
#define ZRTP_ZIDFILE "zidFile" /** The filename used for storing ZIDs */
......
Markdown is supported
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