Commit 4d433286 authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

The user can set the codec preferences in the config window

The user can select a codec among the supported one's in the audio settings tab of the config window.
The call is made with only this codec.

TODO: use the other supported codecs to place a call, if the selected one doesn't work
parent a0383a08
......@@ -156,6 +156,7 @@ sflphone_init()
dbus_register(getpid(), "Gtk+ Client");
sflphone_fill_account_list();
sflphone_set_default_account();
sflphone_get_codec_list();
return TRUE;
}
}
......@@ -569,3 +570,16 @@ sflphone_set_default_account( )
account_list_set_default(default_id);
}
/* Internal to action - get the codec list */
gchar**
sflphone_get_codec_list()
{
int i=0;
gchar** codecs = (gchar**)dbus_codec_list();
while(codecs[i]!=NULL){
printf("%s\n", codecs[i]);
i++;
}
}
......@@ -104,4 +104,6 @@ void sflphone_place_call ( call_t * c );
void sflphone_fill_account_list();
void sflphone_set_default_account();
gchar** sflphone_get_codec_list();
#endif
......@@ -280,7 +280,7 @@ create_toolbar (){
toolbar = ret;
gtk_toolbar_set_orientation(GTK_TOOLBAR(ret), GTK_ORIENTATION_HORIZONTAL);
//gtk_toolbar_set_style(GTK_TOOLBAR(ret), GTK_TOOLBAR_BOTH);
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");
......@@ -319,7 +319,7 @@ create_toolbar (){
image = gtk_image_new_from_file( ICONS_DIR "/transfert.svg");
transfertButton = gtk_toggle_tool_button_new ();
gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(transfertButton), image);
gtk_tool_button_set_label(GTK_TOOL_BUTTON(transfertButton), "Transfert");
gtk_tool_button_set_label(GTK_TOOL_BUTTON(transfertButton), "Transfer");
gtk_widget_set_state( GTK_WIDGET(transfertButton), GTK_STATE_INSENSITIVE);
transfertButtonConnId = g_signal_connect (G_OBJECT (transfertButton), "toggled",
G_CALLBACK (transfert), NULL);
......
......@@ -30,6 +30,7 @@
/** Local variables */
gboolean dialogOpen = FALSE;
GtkListStore *account_store;
GtkListStore *codec_store;
GtkWidget * addButton;
GtkWidget * editButton;
GtkWidget * deleteButton;
......@@ -69,6 +70,28 @@ config_window_fill_account_list ()
gtk_widget_set_sensitive( GTK_WIDGET(defaultButton), FALSE);
}
}
config_window_fill_codec_list()
{
if(dialogOpen)
{
GtkTreeIter iter;
gtk_list_store_clear(codec_store);
int i=0;
gchar** codecs = (gchar**)dbus_codec_list();
while(codecs[i]!=NULL)
{
gtk_list_store_append (codec_store, &iter);
gtk_list_store_set(codec_store, &iter,0,codecs[i],-1);
i++;
}
}
}
/**
* Delete an account
*/
......@@ -146,6 +169,20 @@ select_account(GtkTreeSelection *sel, GtkTreeModel *model)
}
static void
select_codec( GtkComboBox* wid)
{
guint item = gtk_combo_box_get_active(wid);
/* now we want this selected codec to be used as the preferred codec */
/* ie first in the list in the user config */
gchar** codecs = (gchar**)dbus_codec_list();
gchar* tmp;
tmp = codecs[0];
codecs[0] = codecs[item];
codecs[item]=tmp;
dbus_set_prefered_codec(codecs);
}
void
bold_if_default_account(GtkTreeViewColumn *col,
GtkCellRenderer *rend,
......@@ -282,6 +319,56 @@ create_accounts_tab()
return ret;
}
GtkWidget*
create_audio_tab ()
{
GtkWidget* ret;
GtkWidget* label;
GtkWidget* combo_box;
GtkWidget* hbox1;
GtkTreeIter iter;
GtkCellRenderer *renderer;
ret = gtk_vbox_new(FALSE, 10);
gtk_container_set_border_width (GTK_CONTAINER (ret), 10);
label = gtk_label_new("Set your audio preferences.");
gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
gtk_box_pack_start(GTK_BOX(ret), label, FALSE, TRUE, 0);
gtk_widget_show(label);
hbox1 = gtk_label_new("Available Codecs");
gtk_misc_set_alignment(GTK_MISC(hbox1), 0, 0.5);
gtk_box_pack_start(GTK_BOX(ret), hbox1, FALSE, TRUE, 0);
gtk_widget_show(hbox1);
codec_store = gtk_list_store_new(1, G_TYPE_STRING);
combo_box = gtk_combo_box_new_with_model(GTK_TREE_MODEL (codec_store));
gtk_label_set_mnemonic_widget(GTK_LABEL(hbox1), combo_box);
renderer = gtk_cell_renderer_text_new();
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo_box), renderer, TRUE);
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo_box), renderer, "text",0,NULL);
gtk_box_pack_start(GTK_BOX(ret), combo_box, FALSE, TRUE,0);
gtk_combo_box_set_active(combo_box, 0);
g_signal_connect (G_OBJECT (combo_box), "changed",
G_CALLBACK (select_codec),
NULL);
gtk_widget_show(combo_box);
gtk_widget_show_all(ret);
config_window_fill_codec_list();
return ret;
}
void
show_config_window ()
{
......@@ -308,10 +395,16 @@ show_config_window ()
gtk_widget_show(notebook);
/* Create tabs */
// Accounts tab
tab = create_accounts_tab();
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), tab, gtk_label_new("Accounts"));
gtk_notebook_page_num(GTK_NOTEBOOK(notebook), tab);
// Audio tab
tab = create_audio_tab();
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), tab, gtk_label_new("Audio Settings"));
gtk_notebook_page_num(GTK_NOTEBOOK(notebook), tab);
gtk_dialog_run (dialog);
dialogOpen = FALSE;
......
......@@ -147,7 +147,6 @@ accounts_changed_cb (DBusGProxy *proxy,
g_print ("Accounts changed\n");
sflphone_fill_account_list();
config_window_fill_account_list();
//fast_fill_account_list();
}
gboolean
......@@ -660,3 +659,58 @@ dbus_unregister(int pid)
g_print ("DBus called unregister() on instanceProxy\n");
}
}
gchar **
dbus_codec_list()
{
g_print("Before");
GError *error = NULL;
char ** array;
org_sflphone_SFLphone_ConfigurationManager_get_codec_list (
configurationManagerProxy,
&array,
&error);
g_print("After");
if (error)
{
g_printerr ("Failed to call get_codec_list() on ConfigurationManager: %s\n",
error->message);
g_error_free (error);
}
else
{
g_print ("DBus called get_codec_list() on ConfigurationManager\n");
}
return array;
}
void
dbus_set_prefered_codec(const gchar** codecList)
{
g_print("Before");
GError *error = NULL;
org_sflphone_SFLphone_ConfigurationManager_set_codec_prefered_order (
configurationManagerProxy,
codecList,
&error);
g_print("After");
if (error)
{
g_printerr ("Failed to call set_prefered_codec() on ConfigurationManager: %s\n",
error->message);
g_error_free (error);
}
else
{
g_print ("DBus called set_prefered_codec() on ConfigurationManager\n");
}
}
......@@ -53,6 +53,8 @@ gdouble dbus_get_volume(const gchar * device);
void dbus_play_dtmf(const gchar * key);
gchar* dbus_get_default_account();
void dbus_set_default_account(gchar * accountID);
gchar** dbus_codec_list();
/* Instance */
void dbus_register( int pid, gchar * name);
......
/*
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Copyright (C) 2004-2007 Savoir-Faire Linux inc.
* Author: Yan Morin <yan.morin@savoirfairelinux.com>
* Author: Laurielle Lea <laurielle.lea@savoirfairelinux.com>
* Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
......@@ -66,3 +67,20 @@ CodecDescriptorMap::setActive(const std::string& codecDescription)
iter++;
}
}
void
CodecDescriptorMap::setInactive(const std::string& codecDescription)
{
CodecMap::iterator iter = _codecMap.begin();
while(iter!=_codecMap.end()) {
if (iter->second!=0) {
if (iter->second->getDescription() == codecDescription) {
iter->second->setActive(false);
break;
}
}
iter++;
}
}
......@@ -71,6 +71,7 @@ public:
* @param codecDescription is the same as with getCodec(number)->getDescription()
*/
void setActive(const std::string& codecDescription);
void setInactive(const std::string& codecDescription);
private:
CodecMap _codecMap;
};
......
......@@ -100,6 +100,7 @@ ConfigurationManager::getRingtoneList( )
ConfigurationManager::getCodecList( )
{
_debug("ConfigurationManager::getCodecList received\n");
return Manager::instance().getCodecList();
}
......
......@@ -1086,9 +1086,14 @@ ManagerImpl::initAudioCodec (void)
{
_debugInit("Active Codecs");
// TODO: need to be more dynamic...
_codecDescriptorMap.setActive(getConfigString(AUDIO, CODEC1));
_codecDescriptorMap.setActive(getConfigString(AUDIO, CODEC2));
_codecDescriptorMap.setActive(getConfigString(AUDIO, CODEC3));
//_codecDescriptorMap.setActive(getConfigString(AUDIO, CODEC1));
//_codecDescriptorMap.setActive(getConfigString(AUDIO, CODEC2));
//_codecDescriptorMap.setActive(getConfigString(AUDIO, CODEC3));
_codecDescriptorMap.setActive(getConfigString("Audio", "Codecs.codec1"));
//_codecDescriptorMap.setActive(getConfigString("Audio", "Codec.codec2"));
//_codecDescriptorMap.setActive(getConfigString("Audio", "Codec.codec3"));
}
/**
......@@ -1103,9 +1108,34 @@ ManagerImpl::setCodecsOrder(const std::vector< ::DBus::String >& codecs)
* (appeler saveConfig ?), et de sauver pour les Codecs, le _codecName
* de chaque codec, et non pas la _description. Faut s'assurer de ça
* auprès de D-Bus aussi.*/
_debug("Set codecs preferred order: UNIMPLEMENTED YET :)\n");
std::vector<std::string> list = codecs;
_codecDescriptorMap.setActive(list[0]);
_codecDescriptorMap.setInactive(list[1]);
_codecDescriptorMap.setInactive(list[2]);
setConfig("Audio", "Codecs.codec1", list[0]);
setConfig("Audio", "Codecs.codec2", list[1]);
setConfig("Audio", "Codecs.codec3", list[2]);
}
/**
* Get the list of codecs
*/
std::vector< std::string >
ManagerImpl::getCodecList( void )
{
std::vector< std::string > v;
std::string codec;
codec = getConfigString(AUDIO, "Codecs.codec1");
v.push_back(codec);
codec = getConfigString(AUDIO, "Codecs.codec2");
v.push_back(codec);
codec = getConfigString(AUDIO, "Codecs.codec3");
v.push_back(codec);
return v;
}
/**
* Initialization: Main Thread
......
......@@ -268,6 +268,13 @@ public:
*/
void setCodecsOrder(const std::vector< ::DBus::String >& codecs);
/**
* Get the list of codecs we supports
* @ return The list of the codecs
*/
std::vector< ::DBus::String > getCodecList( void );
/*
* Set an account as default
......@@ -437,7 +444,7 @@ private:
Conf::ConfigTree _config;
bool getCountryTones(const std::string& sequenceId);
void sendCountryTone(const std::string& sequenceId, int index, const std::string& name);
/**
......
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