diff --git a/sflphone-client-gnome/src/actions.c b/sflphone-client-gnome/src/actions.c index ea216ca988ea9840bc075e6840e10e6378afa7ab..471232a392d12d202d76ee1593fea2754ccee341 100644 --- a/sflphone-client-gnome/src/actions.c +++ b/sflphone-client-gnome/src/actions.c @@ -178,6 +178,7 @@ void sflphone_fill_account_list (void) { gchar** accountID; unsigned int i; int count; + GQueue *codeclist; count = current_account_get_message_number (); @@ -274,11 +275,13 @@ void sflphone_fill_account_list (void) { a->protocol_state_description = g_hash_table_lookup(details, REGISTRATION_STATE_DESCRIPTION); // Attach a codec list to each account - account_create_codec_list (&a); + // account_create_codec_list (&a); } // Set the current account message number current_account_set_message_number (count); + + sflphone_fill_codec_list (); } gboolean sflphone_init() { @@ -309,7 +312,7 @@ gboolean sflphone_init() { // Fetch the ip2ip profile sflphone_fill_ip2ip_profile(); - // Fetch the audio codecs + // Fetch the audio codecs at startup. // sflphone_fill_codec_list(); // Fetch the conference list @@ -1062,24 +1065,16 @@ void sflphone_fill_codec_list () { account_t *current = NULL; gchar** codecs = NULL; - // Clear the list of codecs supported by the application. - // This is a global list inherited by all accounts - // system_codec_list_clear (); - codecs = (gchar**) dbus_codec_list (); - - // If no codecs are available, problem ... Application has to quit - if (codecs != NULL) - { - account_list_size = account_list_get_size (); - - for (i=0; i<account_list_size; i++) - { - current = account_list_get_nth (i); - if (current) { - sflphone_fill_codec_list_per_account (current, codecs); - } + account_list_size = account_list_get_size (); + + for (i=0; i<account_list_size; i++) + { + current = account_list_get_nth (i); + if (current) { + sflphone_fill_codec_list_per_account (¤t); } } + /* if (codec_list_get_size() == 0) { @@ -1090,53 +1085,55 @@ void sflphone_fill_codec_list () { }*/ } -void sflphone_fill_codec_list_per_account (account_t *account, gchar **system_wide_codecs) { +void sflphone_fill_codec_list_per_account (account_t **account) { gchar **order; gchar** details; gchar** pl; gchar *accountID; GQueue *codeclist; + gboolean active = FALSE; - order = (gchar**) dbus_get_active_codec_list (account->accountID); - codeclist = account->codecs; + order = (gchar**) dbus_get_active_codec_list ((*account)->accountID); + codeclist = (*account)->codecs; // First clean the list codec_list_clear (&codeclist); for (pl=order; *order; order++) { - codec_t * c = g_new0 (codec_t, 1); - c->_payload = atoi (*order); - details = (gchar **) dbus_codec_details (c->_payload); - - c->name = details[0]; - c->is_active = TRUE; - c->sample_rate = atoi (details[1]); - c->_bitrate = atof (details[2]); - c->_bandwidth = atof (details[3]); - codec_list_add (c, &codeclist); - g_print ("Adding codec %s\n", c->name); + codec_t * cpy; + // Each account will have a copy of the system-wide capabilities + codec_create_new_from_caps (codec_list_get_by_payload ((gconstpointer) atoi (*order), NULL), &cpy); + if (cpy) { + cpy->is_active = TRUE; + codec_list_add (cpy, &codeclist); + } + else + ERROR ("Couldn't find codec \n"); } - for (pl=system_wide_codecs; *system_wide_codecs; system_wide_codecs++) - { - details = (gchar **) dbus_codec_details (atoi (*system_wide_codecs)); - if (codec_list_get_by_payload ((gconstpointer)(size_t) atoi (*system_wide_codecs))!=NULL){ - // does nothing - the codec is already in the list, so is active. - } - else{ - codec_t* c = g_new0 (codec_t, 1); - c->_payload = atoi (*system_wide_codecs); - c->name = details[0]; - c->is_active = FALSE; - c->sample_rate = atoi (details[1]); - c->_bitrate = atof (details[2]); - c->_bandwidth = atof (details[3]); - codec_list_add (c, &codeclist); - } - } - account->codecs = codeclist; + // Test here if we just added some active codec. + active = (codeclist->length == 0) ? FALSE : FALSE; + + guint caps_size = codec_list_get_size (), i=0; + + for (i=0; i<caps_size; i++) { + + codec_t * current_cap = capabilities_get_nth (i); + // Check if this codec has already been enabled for this account + if (codec_list_get_by_payload ( (gconstpointer) current_cap->_payload, codeclist) == NULL) { + // codec_t *cpy; + // codec_create_new_from_caps (current_cap, &cpy); + current_cap->is_active = active; + codec_list_add (current_cap, &codeclist); + } + else { + } + + } + + (*account)->codecs = codeclist; } void sflphone_fill_call_list (void) @@ -1203,7 +1200,6 @@ void sflphone_fill_conference_list(void) calltree_add_conference (current_calls, conf); } } - } void sflphone_fill_history (void) diff --git a/sflphone-client-gnome/src/actions.h b/sflphone-client-gnome/src/actions.h index 17c276b492ee085525a21e72bb4b097628d39258..41466b7eacc108e32d1a1120cd61a4689ea99103 100644 --- a/sflphone-client-gnome/src/actions.h +++ b/sflphone-client-gnome/src/actions.h @@ -179,7 +179,7 @@ void sflphone_set_current_account(); */ void sflphone_fill_codec_list (); -void sflphone_fill_codec_list_per_account (account_t *, gchar**); +void sflphone_fill_codec_list_per_account (account_t **); void sflphone_add_participant(); diff --git a/sflphone-client-gnome/src/codeclist.c b/sflphone-client-gnome/src/codeclist.c index 72b49128a1972f5af4183998a43e174fb3f4ceff..6d038148fbe6fe26bf066085a8a419d9aa3aea16 100644 --- a/sflphone-client-gnome/src/codeclist.c +++ b/sflphone-client-gnome/src/codeclist.c @@ -54,10 +54,13 @@ void codec_list_init (GQueue **queue) { void codec_capabilities_load (void) { - gchar **codecs = NULL, **pl = NULL; + gchar **codecs = NULL, **pl = NULL, **specs = NULL; + guint payload; // Create the queue object that will contain the global list of audio codecs - g_queue_free (codecsCapabilities); + if (codecsCapabilities != NULL) + g_queue_free (codecsCapabilities); + codecsCapabilities = g_queue_new(); // This is a global list inherited by all accounts @@ -67,7 +70,9 @@ void codec_capabilities_load (void) { for (pl=codecs; *codecs; codecs++) { codec_t *c; - codec_create_new (atoi (*codecs), TRUE, &c); + payload = atoi (*codecs); + specs = (gchar **) dbus_codec_details (payload); + codec_create_new_with_specs (payload, specs, TRUE, &c); g_queue_push_tail (codecsCapabilities, (gpointer*) c); } @@ -91,12 +96,19 @@ void account_create_codec_list (account_t **acc) { g_queue_free (_codecs); _codecs = g_queue_new (); - _codecs = g_queue_copy (codecsCapabilities); + // _codecs = g_queue_copy (codecsCapabilities); (*acc)->codecs = _codecs; // order = (gchar**) dbus_get_active_codec_list (acc->accountID); } +void account_set_codec_list (account_t **acc) { + + // Reset the codec list + // account_create_codec_list (a); + +} + void codec_create_new (gint payload, gboolean active, codec_t **c) { codec_t *codec; @@ -129,10 +141,27 @@ void codec_create_new_with_specs (gint payload, gchar **specs, gboolean active, *c = codec; } +void codec_create_new_from_caps (codec_t *original, codec_t **copy) { + + codec_t *codec; + + codec = g_new0 (codec_t, 1); + codec->_payload = original->_payload; + codec->name = original->name; + codec->sample_rate = original->sample_rate; + codec->_bitrate = original->_bitrate; + codec->_bandwidth = original->_bandwidth; + codec->is_active = original->is_active; + + *copy = codec; +} + void codec_list_clear (GQueue **queue) { - g_queue_free (*queue); + if (*queue != NULL) + g_queue_free (*queue); + *queue = g_queue_new(); } @@ -179,9 +208,13 @@ codec_t* codec_list_get_by_name (const gchar* name) { return NULL; } -codec_t* codec_list_get_by_payload (gconstpointer payload) { +codec_t* codec_list_get_by_payload (gconstpointer payload, GQueue *q) { + + // If NULL is passed as argument, we look into the global capabilities + if (q == NULL) + q = codecsCapabilities; - GList * c = g_queue_find_custom(codecsCapabilities, payload, is_payload_codecstruct); + GList * c = g_queue_find_custom (q, payload, is_payload_codecstruct); if(c) return (codec_t *)c->data; else @@ -192,6 +225,11 @@ codec_t* codec_list_get_nth (guint index, GQueue *q) { return g_queue_peek_nth (q, index); } +codec_t* capabilities_get_nth (guint index) { + + return g_queue_peek_nth (codecsCapabilities, index); +} + void codec_set_prefered_order (guint index, GQueue *q) { codec_t * prefered = codec_list_get_nth (index, q); @@ -199,43 +237,55 @@ void codec_set_prefered_order (guint index, GQueue *q) { g_queue_push_head (q, prefered); } -void codec_list_move_codec_up (guint index) { +void codec_list_move_codec_up (guint index, GQueue **q) { DEBUG("Codec list Size: %i \n", codec_list_get_size ()); + GQueue *tmp = *q; + if (index != 0) { - gpointer codec = g_queue_pop_nth (codecsCapabilities, index); - g_queue_push_nth (codecsCapabilities, codec, index-1); + gpointer codec = g_queue_pop_nth (tmp, index); + g_queue_push_nth (tmp, codec, index-1); } + + *q = tmp; + } -void codec_list_move_codec_down (guint index) { +void codec_list_move_codec_down (guint index, GQueue **q) { DEBUG("Codec list Size: %i \n",codec_list_get_size()); - if (index != codecsCapabilities->length) + GQueue *tmp = *q; + + if (index != tmp->length) { - gpointer codec = g_queue_pop_nth (codecsCapabilities, index); - g_queue_push_nth (codecsCapabilities, codec, index+1); + gpointer codec = g_queue_pop_nth (tmp, index); + g_queue_push_nth (tmp, codec, index+1); } + + *q = tmp; + } void codec_list_update_to_daemon (account_t *acc) { - /* - // String listing of all codecs payloads + // String listing codecs payloads const gchar** codecList; // Length of the codec list - int length = codecsCapabilities->length; + int length = acc->codecs->length; // Initiate double array char list for one string codecList = (void*)malloc(sizeof(void*)); // Get all codecs in queue - int i, c = 0; - DEBUG("List of active codecs :"); + int c = 0; + unsigned int i = 0; + + g_print ("List of active codecs :\n"); + for(i = 0; i < length; i++) { codec_t* currentCodec = codec_list_get_nth (i, acc->codecs); @@ -245,6 +295,7 @@ void codec_list_update_to_daemon (account_t *acc) { // Save only if active if(currentCodec->is_active) { + g_print ("Codec %s\n", currentCodec->name); // Reallocate memory each time more than one active codec is found if(c!=0) codecList = (void*)realloc(codecList, (c+1)*sizeof(void*)); @@ -254,7 +305,7 @@ void codec_list_update_to_daemon (account_t *acc) { // Put payload string in char array sprintf(payload, "%d", currentCodec->_payload); strcpy((char*)*(codecList+c), payload); - DEBUG(" %s", *(codecList+c)); + g_print(" %s", *(codecList+c)); c++; } } @@ -265,14 +316,13 @@ void codec_list_update_to_daemon (account_t *acc) { *(codecList+c) = NULL; // call dbus function with array of strings - dbus_set_active_codec_list (codecList); + dbus_set_active_codec_list (codecList, acc->accountID); // Delete memory for(i = 0; i < c; i++) { free((gchar*)*(codecList+i)); } free(codecList); - */ } GQueue* get_system_codec_list (void) { diff --git a/sflphone-client-gnome/src/codeclist.h b/sflphone-client-gnome/src/codeclist.h index fc46baf79fcc8ada67222e281607d3ca7f976c7f..165fd1029d63914231c50bedf0d268ddae216386 100644 --- a/sflphone-client-gnome/src/codeclist.h +++ b/sflphone-client-gnome/src/codeclist.h @@ -104,6 +104,7 @@ codec_t * codec_list_get_by_name(const gchar * name); * @return codec_t* A codec or NULL */ codec_t* codec_list_get_nth (guint index, GQueue *q); +codec_t* capabilities_get_nth (guint index); /** * Set the prefered codec first in the codec list @@ -115,20 +116,20 @@ void codec_set_prefered_order (guint index, GQueue *q); * Move the codec from an unit up in the codec_list * @param index The current index in the list */ -void codec_list_move_codec_up (guint index); +void codec_list_move_codec_up (guint index, GQueue **q); /** * Move the codec from an unit down in the codec_list * @param index The current index in the list */ -void codec_list_move_codec_down (guint index); +void codec_list_move_codec_down (guint index, GQueue **q); /** * Notify modifications on codecs to the server */ void codec_list_update_to_daemon (account_t *acc); -codec_t* codec_list_get_by_payload(gconstpointer payload); +codec_t* codec_list_get_by_payload (gconstpointer payload, GQueue *q); GQueue* get_system_codec_list (void); @@ -152,6 +153,8 @@ void codec_create_new (gint payload, gboolean active, codec_t **c); */ void codec_create_new_with_specs (gint payload, gchar **specs, gboolean active, codec_t **c); + +void codec_create_new_from_caps (codec_t *original, codec_t **copy); /* * Attach a codec list to a specific account * diff --git a/sflphone-client-gnome/src/config/accountconfigdialog.c b/sflphone-client-gnome/src/config/accountconfigdialog.c index fbe634efa1f7b244a2217eb259f93fa98f60ab25..badb1556a6994fcaf052ef62ac375a6ba5daed2d 100644 --- a/sflphone-client-gnome/src/config/accountconfigdialog.c +++ b/sflphone-client-gnome/src/config/accountconfigdialog.c @@ -1073,6 +1073,7 @@ show_account_window (account_t * a) currentAccount = g_new0(account_t, 1); currentAccount->properties = dbus_account_details(NULL); currentAccount->accountID = "new"; + sflphone_fill_codec_list_per_account (¤tAccount); DEBUG("Account is NULL. Will fetch default values\n"); } @@ -1242,6 +1243,9 @@ show_account_window (account_t * a) } + // Perpetuate changes to the deamon + codec_list_update_to_daemon (currentAccount); + } gtk_widget_destroy (GTK_WIDGET(dialog)); diff --git a/sflphone-client-gnome/src/config/audioconf.c b/sflphone-client-gnome/src/config/audioconf.c index 831c83fe482c0bc5620a83488ef626e23b1dacd4..079134601716679b2d24f718ef73f78fdff18db4 100644 --- a/sflphone-client-gnome/src/config/audioconf.c +++ b/sflphone-client-gnome/src/config/audioconf.c @@ -35,15 +35,15 @@ GtkWidget *pulse; GtkWidget *alsabox; GtkWidget *alsa_conf; GtkWidget *noise_conf; - + // Codec properties ID enum { - COLUMN_CODEC_ACTIVE, - COLUMN_CODEC_NAME, - COLUMN_CODEC_FREQUENCY, - COLUMN_CODEC_BITRATE, - COLUMN_CODEC_BANDWIDTH, - CODEC_COLUMN_COUNT + COLUMN_CODEC_ACTIVE, + COLUMN_CODEC_NAME, + COLUMN_CODEC_FREQUENCY, + COLUMN_CODEC_BITRATE, + COLUMN_CODEC_BANDWIDTH, + CODEC_COLUMN_COUNT }; /** @@ -51,388 +51,392 @@ enum { */ void preferences_dialog_fill_codec_list (account_t **a) { - GtkListStore *codecStore; - GtkTreeIter iter; + GtkListStore *codecStore; + GtkTreeIter iter; GQueue *current; - // Get model of view and clear it - codecStore = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (codecTreeView))); - gtk_list_store_clear (codecStore); - if (a) { + // Get model of view and clear it + codecStore = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (codecTreeView))); + gtk_list_store_clear (codecStore); + + if ((*a) != NULL) { current = (*a)->codecs; - g_print ("%s\n", (*a)->accountID); } else { // Failover current = get_system_codec_list (); } - // Insert codecs - unsigned int i; - for(i = 0; i < codec_list_get_size (); i++) - { - codec_t *c = codec_list_get_nth (i, current); - if (c) - { + + // Insert codecs + unsigned int i; + for(i = 0; i < current->length; i++) + { + codec_t *c = codec_list_get_nth (i, current); + if (c) + { DEBUG ("%s", c->name); - gtk_list_store_append (codecStore, &iter); - gtk_list_store_set (codecStore, &iter, - COLUMN_CODEC_ACTIVE, c->is_active, // Active - COLUMN_CODEC_NAME, c->name, // Name - COLUMN_CODEC_FREQUENCY, g_strdup_printf("%d kHz", c->sample_rate/1000), // Frequency (kHz) - COLUMN_CODEC_BITRATE, g_strdup_printf("%.1f kbps", c->_bitrate), // Bitrate (kbps) - COLUMN_CODEC_BANDWIDTH, g_strdup_printf("%.1f kbps", c->_bandwidth), // Bandwidth (kpbs) - -1); - } - } + gtk_list_store_append (codecStore, &iter); + gtk_list_store_set (codecStore, &iter, + COLUMN_CODEC_ACTIVE, c->is_active, // Active + COLUMN_CODEC_NAME, c->name, // Name + COLUMN_CODEC_FREQUENCY, g_strdup_printf("%d kHz", c->sample_rate/1000), // Frequency (kHz) + COLUMN_CODEC_BITRATE, g_strdup_printf("%.1f kbps", c->_bitrate), // Bitrate (kbps) + COLUMN_CODEC_BANDWIDTH, g_strdup_printf("%.1f kbps", c->_bandwidth), // Bandwidth (kpbs) + -1); + } + } } /** * Fill store with output audio plugins */ - void + void preferences_dialog_fill_output_audio_plugin_list() { - GtkTreeIter iter; - gchar** list; - gchar* managerName; - - gtk_list_store_clear(pluginlist); - - // Call dbus to retreive list - list = dbus_get_output_audio_plugin_list(); - // For each API name included in list - int c = 0; - - if (list != NULL){ - for(managerName = list[c]; managerName != NULL; managerName = list[c]) - { - c++; - gtk_list_store_append(pluginlist, &iter); - gtk_list_store_set(pluginlist, &iter, 0 , managerName, -1); - } - } - list = NULL; + GtkTreeIter iter; + gchar** list; + gchar* managerName; + + gtk_list_store_clear(pluginlist); + + // Call dbus to retreive list + list = dbus_get_output_audio_plugin_list(); + // For each API name included in list + int c = 0; + + if (list != NULL){ + for(managerName = list[c]; managerName != NULL; managerName = list[c]) + { + c++; + gtk_list_store_append(pluginlist, &iter); + gtk_list_store_set(pluginlist, &iter, 0 , managerName, -1); + } + } + list = NULL; } /** * Fill output audio device store */ - void + void preferences_dialog_fill_output_audio_device_list() { - GtkTreeIter iter; - gchar** list; - gchar** audioDevice; - int index; - - gtk_list_store_clear(outputlist); - - // Call dbus to retreive list - list = dbus_get_audio_output_device_list(); - - // For each device name included in list - int c = 0; - for(audioDevice = list; *list ; list++) - { - index = dbus_get_audio_device_index( *list ); - gtk_list_store_append(outputlist, &iter); - gtk_list_store_set(outputlist, &iter, 0, *list, 1, index, -1); - c++; - } + GtkTreeIter iter; + gchar** list; + gchar** audioDevice; + int index; + + gtk_list_store_clear(outputlist); + + // Call dbus to retreive list + list = dbus_get_audio_output_device_list(); + + // For each device name included in list + int c = 0; + for(audioDevice = list; *list ; list++) + { + index = dbus_get_audio_device_index( *list ); + gtk_list_store_append(outputlist, &iter); + gtk_list_store_set(outputlist, &iter, 0, *list, 1, index, -1); + c++; + } } /** * Select active output audio device */ - void + void select_active_output_audio_device() { - if( SHOW_ALSA_CONF ) - { - - GtkTreeModel* model; - GtkTreeIter iter; - gchar** devices; - int currentDeviceIndex; - int deviceIndex; - - // Select active output device on server - devices = dbus_get_current_audio_devices_index(); - currentDeviceIndex = atoi(devices[0]); - DEBUG("audio device index for output = %d", currentDeviceIndex); - model = gtk_combo_box_get_model(GTK_COMBO_BOX(output)); - - // Find the currently set output device - gtk_tree_model_get_iter_first(model, &iter); - do { - gtk_tree_model_get(model, &iter, 1, &deviceIndex, -1); - if(deviceIndex == currentDeviceIndex) - { - // Set current iteration the active one - gtk_combo_box_set_active_iter(GTK_COMBO_BOX(output), &iter); - return; - } - } while(gtk_tree_model_iter_next(model, &iter)); - - // No index was found, select first one - WARN("Warning : No active output device found"); - gtk_combo_box_set_active(GTK_COMBO_BOX(output), 0); - } + if( SHOW_ALSA_CONF ) + { + + GtkTreeModel* model; + GtkTreeIter iter; + gchar** devices; + int currentDeviceIndex; + int deviceIndex; + + // Select active output device on server + devices = dbus_get_current_audio_devices_index(); + currentDeviceIndex = atoi(devices[0]); + DEBUG("audio device index for output = %d", currentDeviceIndex); + model = gtk_combo_box_get_model(GTK_COMBO_BOX(output)); + + // Find the currently set output device + gtk_tree_model_get_iter_first(model, &iter); + do { + gtk_tree_model_get(model, &iter, 1, &deviceIndex, -1); + if(deviceIndex == currentDeviceIndex) + { + // Set current iteration the active one + gtk_combo_box_set_active_iter(GTK_COMBO_BOX(output), &iter); + return; + } + } while(gtk_tree_model_iter_next(model, &iter)); + + // No index was found, select first one + WARN("Warning : No active output device found"); + gtk_combo_box_set_active(GTK_COMBO_BOX(output), 0); + } } /** * Fill input audio device store */ - void + void preferences_dialog_fill_input_audio_device_list() { - GtkTreeIter iter; - gchar** list; - gchar** audioDevice; - int index ; - gtk_list_store_clear(inputlist); - - // Call dbus to retreive list - list = dbus_get_audio_input_device_list(); - - // For each device name included in list - //int c = 0; - for(audioDevice = list; *list; list++) - { - index = dbus_get_audio_device_index( *list ); - gtk_list_store_append(inputlist, &iter); - gtk_list_store_set(inputlist, &iter, 0, *list, 1, index, -1); - //c++; - } + GtkTreeIter iter; + gchar** list; + gchar** audioDevice; + int index ; + gtk_list_store_clear(inputlist); + + // Call dbus to retreive list + list = dbus_get_audio_input_device_list(); + + // For each device name included in list + //int c = 0; + for(audioDevice = list; *list; list++) + { + index = dbus_get_audio_device_index( *list ); + gtk_list_store_append(inputlist, &iter); + gtk_list_store_set(inputlist, &iter, 0, *list, 1, index, -1); + //c++; + } } /** * Select active input audio device */ - void + void select_active_input_audio_device() { - if( SHOW_ALSA_CONF) - { - - GtkTreeModel* model; - GtkTreeIter iter; - gchar** devices; - int currentDeviceIndex; - int deviceIndex; - - // Select active input device on server - devices = dbus_get_current_audio_devices_index(); - currentDeviceIndex = atoi(devices[1]); - model = gtk_combo_box_get_model(GTK_COMBO_BOX(input)); - - // Find the currently set input device - gtk_tree_model_get_iter_first(model, &iter); - do { - gtk_tree_model_get(model, &iter, 1, &deviceIndex, -1); - if(deviceIndex == currentDeviceIndex) - { - // Set current iteration the active one - gtk_combo_box_set_active_iter(GTK_COMBO_BOX(input), &iter); - return; - } - } while(gtk_tree_model_iter_next(model, &iter)); - - // No index was found, select first one - WARN("Warning : No active input device found"); - gtk_combo_box_set_active(GTK_COMBO_BOX(input), 0); - } + if( SHOW_ALSA_CONF) + { + + GtkTreeModel* model; + GtkTreeIter iter; + gchar** devices; + int currentDeviceIndex; + int deviceIndex; + + // Select active input device on server + devices = dbus_get_current_audio_devices_index(); + currentDeviceIndex = atoi(devices[1]); + model = gtk_combo_box_get_model(GTK_COMBO_BOX(input)); + + // Find the currently set input device + gtk_tree_model_get_iter_first(model, &iter); + do { + gtk_tree_model_get(model, &iter, 1, &deviceIndex, -1); + if(deviceIndex == currentDeviceIndex) + { + // Set current iteration the active one + gtk_combo_box_set_active_iter(GTK_COMBO_BOX(input), &iter); + return; + } + } while(gtk_tree_model_iter_next(model, &iter)); + + // No index was found, select first one + WARN("Warning : No active input device found"); + gtk_combo_box_set_active(GTK_COMBO_BOX(input), 0); + } } /** * Select the output audio plugin by calling the server */ - static void + static void select_output_audio_plugin(GtkComboBox* widget, gpointer data UNUSED) { - GtkTreeModel* model; - GtkTreeIter iter; - int comboBoxIndex; - gchar* pluginName; - - comboBoxIndex = gtk_combo_box_get_active(widget); - - if(comboBoxIndex >= 0) - { - model = gtk_combo_box_get_model(widget); - gtk_combo_box_get_active_iter(widget, &iter); - gtk_tree_model_get(model, &iter, 0, &pluginName, -1); - dbus_set_output_audio_plugin(pluginName); - //update_combo_box( pluginName); - } + GtkTreeModel* model; + GtkTreeIter iter; + int comboBoxIndex; + gchar* pluginName; + + comboBoxIndex = gtk_combo_box_get_active(widget); + + if(comboBoxIndex >= 0) + { + model = gtk_combo_box_get_model(widget); + gtk_combo_box_get_active_iter(widget, &iter); + gtk_tree_model_get(model, &iter, 0, &pluginName, -1); + dbus_set_output_audio_plugin(pluginName); + //update_combo_box( pluginName); + } } /** * Select active output audio plugin */ - void + void select_active_output_audio_plugin() { - GtkTreeModel* model; - GtkTreeIter iter; - gchar* pluginname; - gchar* tmp; - - // Select active output device on server - pluginname = dbus_get_current_audio_output_plugin(); - tmp = pluginname; - model = gtk_combo_box_get_model(GTK_COMBO_BOX(plugin)); - - // Find the currently alsa plugin - gtk_tree_model_get_iter_first(model, &iter); - do { - gtk_tree_model_get(model, &iter, 0, &pluginname , -1); - if( g_strcasecmp( tmp , pluginname ) == 0 ) - { - // Set current iteration the active one - gtk_combo_box_set_active_iter(GTK_COMBO_BOX(plugin), &iter); - //update_combo_box( plugin ); - return; - } - } while(gtk_tree_model_iter_next(model, &iter)); - - // No index was found, select first one - WARN("Warning : No active output device found"); - gtk_combo_box_set_active(GTK_COMBO_BOX(plugin), 0); + GtkTreeModel* model; + GtkTreeIter iter; + gchar* pluginname; + gchar* tmp; + + // Select active output device on server + pluginname = dbus_get_current_audio_output_plugin(); + tmp = pluginname; + model = gtk_combo_box_get_model(GTK_COMBO_BOX(plugin)); + + // Find the currently alsa plugin + gtk_tree_model_get_iter_first(model, &iter); + do { + gtk_tree_model_get(model, &iter, 0, &pluginname , -1); + if( g_strcasecmp( tmp , pluginname ) == 0 ) + { + // Set current iteration the active one + gtk_combo_box_set_active_iter(GTK_COMBO_BOX(plugin), &iter); + //update_combo_box( plugin ); + return; + } + } while(gtk_tree_model_iter_next(model, &iter)); + + // No index was found, select first one + WARN("Warning : No active output device found"); + gtk_combo_box_set_active(GTK_COMBO_BOX(plugin), 0); } /** * Set the audio output device on the server with its index */ - static void + static void select_audio_output_device(GtkComboBox* comboBox, gpointer data UNUSED) { - GtkTreeModel* model; - GtkTreeIter iter; - int comboBoxIndex; - int deviceIndex; + GtkTreeModel* model; + GtkTreeIter iter; + int comboBoxIndex; + int deviceIndex; - comboBoxIndex = gtk_combo_box_get_active(comboBox); + comboBoxIndex = gtk_combo_box_get_active(comboBox); - if(comboBoxIndex >= 0) - { - model = gtk_combo_box_get_model(comboBox); - gtk_combo_box_get_active_iter(comboBox, &iter); - gtk_tree_model_get(model, &iter, 1, &deviceIndex, -1); + if(comboBoxIndex >= 0) + { + model = gtk_combo_box_get_model(comboBox); + gtk_combo_box_get_active_iter(comboBox, &iter); + gtk_tree_model_get(model, &iter, 1, &deviceIndex, -1); - dbus_set_audio_output_device(deviceIndex); - } + dbus_set_audio_output_device(deviceIndex); + } } /** * Set the audio input device on the server with its index */ - static void + static void select_audio_input_device(GtkComboBox* comboBox, gpointer data UNUSED) { - GtkTreeModel* model; - GtkTreeIter iter; - int comboBoxIndex; - int deviceIndex; + GtkTreeModel* model; + GtkTreeIter iter; + int comboBoxIndex; + int deviceIndex; - comboBoxIndex = gtk_combo_box_get_active(comboBox); + comboBoxIndex = gtk_combo_box_get_active(comboBox); - if(comboBoxIndex >= 0) - { - model = gtk_combo_box_get_model(comboBox); - gtk_combo_box_get_active_iter(comboBox, &iter); - gtk_tree_model_get(model, &iter, 1, &deviceIndex, -1); + if(comboBoxIndex >= 0) + { + model = gtk_combo_box_get_model(comboBox); + gtk_combo_box_get_active_iter(comboBox, &iter); + gtk_tree_model_get(model, &iter, 1, &deviceIndex, -1); - dbus_set_audio_input_device(deviceIndex); - } + dbus_set_audio_input_device(deviceIndex); + } } /** * Toggle move buttons on if a codec is selected, off elsewise */ - static void + static void select_codec(GtkTreeSelection *selection, GtkTreeModel *model) { - GtkTreeIter iter; - - if(!gtk_tree_selection_get_selected(selection, &model, &iter)) - { - gtk_widget_set_sensitive(GTK_WIDGET(codecMoveUpButton), FALSE); - gtk_widget_set_sensitive(GTK_WIDGET(codecMoveDownButton), FALSE); - } - else - { - gtk_widget_set_sensitive(GTK_WIDGET(codecMoveUpButton), TRUE); - gtk_widget_set_sensitive(GTK_WIDGET(codecMoveDownButton), TRUE); - } + GtkTreeIter iter; + + if(!gtk_tree_selection_get_selected(selection, &model, &iter)) + { + gtk_widget_set_sensitive(GTK_WIDGET(codecMoveUpButton), FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(codecMoveDownButton), FALSE); + } + else + { + gtk_widget_set_sensitive(GTK_WIDGET(codecMoveUpButton), TRUE); + gtk_widget_set_sensitive(GTK_WIDGET(codecMoveDownButton), TRUE); + } } /** * Toggle active value of codec on click and update changes to the deamon * and in configuration files */ - static void + static void codec_active_toggled (GtkCellRendererToggle *renderer UNUSED, gchar *path, gpointer data ) { - GtkTreeIter iter; - GtkTreePath *treePath; - GtkTreeModel *model; - gboolean active; - char* name; - char* srate; - codec_t* codec; + GtkTreeIter iter; + GtkTreePath *treePath; + GtkTreeModel *model; + gboolean active; + char* name; + char* srate; + codec_t* codec; account_t *acc; - // Get path of clicked codec active toggle box - treePath = gtk_tree_path_new_from_string(path); - model = gtk_tree_view_get_model (GTK_TREE_VIEW (codecTreeView)); - gtk_tree_model_get_iter(model, &iter, treePath); + // Get path of clicked codec active toggle box + treePath = gtk_tree_path_new_from_string(path); + model = gtk_tree_view_get_model (GTK_TREE_VIEW (codecTreeView)); + gtk_tree_model_get_iter(model, &iter, treePath); // Retrieve userdata acc = (account_t*) data; - // Get active value and name at iteration - gtk_tree_model_get(model, &iter, - COLUMN_CODEC_ACTIVE, &active, - COLUMN_CODEC_NAME, &name, - COLUMN_CODEC_FREQUENCY, &srate, - -1); - - // printf("%s, %s\n", name, srate); - - // codec_list_get_by_name(name); - if ((g_strcasecmp(name,"speex")==0) && (g_strcasecmp(srate,"8 kHz")==0)) - codec = codec_list_get_by_payload((gconstpointer) 110); - else if ((g_strcasecmp(name,"speex")==0) && (g_strcasecmp(srate,"16 kHz")==0)) - codec = codec_list_get_by_payload((gconstpointer) 111); - else if ((g_strcasecmp(name,"speex")==0) && (g_strcasecmp(srate,"32 kHz")==0)) - codec = codec_list_get_by_payload((gconstpointer) 112); - else - codec = codec_list_get_by_name(name); - - // Toggle active value - active = !active; - - // Store value - gtk_list_store_set(GTK_LIST_STORE(model), &iter, - COLUMN_CODEC_ACTIVE, active, - -1); - - gtk_tree_path_free(treePath); - - // Modify codec queue to represent change - if (active) - codec_set_active (codec); - else - codec_set_inactive (codec); - - // Perpetuate changes to the deamon - codec_list_update_to_daemon (acc); + if (!acc) + ERROR ("Aie, no account selected"); + + // Get active value and name at iteration + gtk_tree_model_get(model, &iter, + COLUMN_CODEC_ACTIVE, &active, + COLUMN_CODEC_NAME, &name, + COLUMN_CODEC_FREQUENCY, &srate, + -1); + + printf("%s, %s\n", name, srate); + + // codec_list_get_by_name(name); + if ((g_strcasecmp(name,"speex")==0) && (g_strcasecmp(srate,"8 kHz")==0)) + codec = codec_list_get_by_payload((gconstpointer) 110, NULL); + else if ((g_strcasecmp(name,"speex")==0) && (g_strcasecmp(srate,"16 kHz")==0)) + codec = codec_list_get_by_payload((gconstpointer) 111, NULL); + else if ((g_strcasecmp(name,"speex")==0) && (g_strcasecmp(srate,"32 kHz")==0)) + codec = codec_list_get_by_payload((gconstpointer) 112, NULL); + else + codec = codec_list_get_by_name(name); + + // Toggle active value + active = !active; + + // Store value + gtk_list_store_set(GTK_LIST_STORE(model), &iter, + COLUMN_CODEC_ACTIVE, active, + -1); + + gtk_tree_path_free(treePath); + + // Modify codec queue to represent change + if (active) + codec_set_active (codec); + else + codec_set_inactive (codec); + + // Perpetuate changes to the deamon + // codec_list_update_to_daemon (acc); } /** @@ -441,59 +445,60 @@ codec_active_toggled (GtkCellRendererToggle *renderer UNUSED, gchar *path, gpoin */ static void codec_move (gboolean moveUp, gpointer data) { - GtkTreeIter iter; - GtkTreeIter *iter2; - GtkTreeView *treeView; - GtkTreeModel *model; - GtkTreeSelection *selection; - GtkTreePath *treePath; - gchar *path; + GtkTreeIter iter; + GtkTreeIter *iter2; + GtkTreeView *treeView; + GtkTreeModel *model; + GtkTreeSelection *selection; + GtkTreePath *treePath; + gchar *path; account_t *acc; + GQueue *acc_q; - // Get view, model and selection of codec store - model = gtk_tree_view_get_model(GTK_TREE_VIEW(codecTreeView)); - selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(codecTreeView)); + // Get view, model and selection of codec store + model = gtk_tree_view_get_model(GTK_TREE_VIEW(codecTreeView)); + selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(codecTreeView)); // Retrieve the user data acc = (account_t*) data; + if (acc) + acc_q = acc->codecs; + + // Find selected iteration and create a copy + gtk_tree_selection_get_selected(GTK_TREE_SELECTION(selection), &model, &iter); + iter2 = gtk_tree_iter_copy(&iter); + + // Find path of iteration + path = gtk_tree_model_get_string_from_iter(GTK_TREE_MODEL(model), &iter); + treePath = gtk_tree_path_new_from_string(path); + gint *indices = gtk_tree_path_get_indices(treePath); + gint indice = indices[0]; + + // Depending on button direction get new path + if(moveUp) + gtk_tree_path_prev(treePath); + else + gtk_tree_path_next(treePath); + gtk_tree_model_get_iter(model, &iter, treePath); + + // Swap iterations if valid + if(gtk_list_store_iter_is_valid(GTK_LIST_STORE(model), &iter)) + gtk_list_store_swap(GTK_LIST_STORE(model), &iter, iter2); + + // Scroll to new position + gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (codecTreeView), treePath, NULL, FALSE, 0, 0); + + // Free resources + gtk_tree_path_free(treePath); + gtk_tree_iter_free(iter2); + g_free(path); + + // Perpetuate changes in codec queue + if(moveUp) + codec_list_move_codec_up (indice, &acc_q); + else + codec_list_move_codec_down (indice, &acc_q); - // Find selected iteration and create a copy - gtk_tree_selection_get_selected(GTK_TREE_SELECTION(selection), &model, &iter); - iter2 = gtk_tree_iter_copy(&iter); - - // Find path of iteration - path = gtk_tree_model_get_string_from_iter(GTK_TREE_MODEL(model), &iter); - treePath = gtk_tree_path_new_from_string(path); - gint *indices = gtk_tree_path_get_indices(treePath); - gint indice = indices[0]; - - // Depending on button direction get new path - if(moveUp) - gtk_tree_path_prev(treePath); - else - gtk_tree_path_next(treePath); - gtk_tree_model_get_iter(model, &iter, treePath); - - // Swap iterations if valid - if(gtk_list_store_iter_is_valid(GTK_LIST_STORE(model), &iter)) - gtk_list_store_swap(GTK_LIST_STORE(model), &iter, iter2); - - // Scroll to new position - gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (codecTreeView), treePath, NULL, FALSE, 0, 0); - - // Free resources - gtk_tree_path_free(treePath); - gtk_tree_iter_free(iter2); - g_free(path); - - // Perpetuate changes in codec queue - if(moveUp) - codec_list_move_codec_up (indice); - else - codec_list_move_codec_down (indice); - - // Perpetuate changes to the deamon - codec_list_update_to_daemon (acc); } /** @@ -501,417 +506,417 @@ static void codec_move (gboolean moveUp, gpointer data) { */ static void codec_move_up (GtkButton *button UNUSED, gpointer data) { - // Change tree view ordering and get indice changed - codec_move (TRUE, data); + // Change tree view ordering and get indice changed + codec_move (TRUE, data); } /** * Called from move down codec button signal */ static void codec_move_down(GtkButton *button UNUSED, gpointer data) { - - // Change tree view ordering and get indice changed - codec_move (FALSE, data); + + // Change tree view ordering and get indice changed + codec_move (FALSE, data); } - int + int is_ringtone_enabled( void ) { - return dbus_is_ringtone_enabled(); + return dbus_is_ringtone_enabled(); } - void + void ringtone_enabled( void ) { - dbus_ringtone_enabled(); + dbus_ringtone_enabled(); } - void + 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* tone = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER( chooser )); + dbus_set_ringtone_choice( tone ); } - gchar* + gchar* get_ringtone_choice( void ) { - return dbus_get_ringtone_choice(); + return dbus_get_ringtone_choice(); } GtkWidget* codecs_box (account_t **a) { - GtkWidget *ret; - GtkWidget *scrolledWindow; - GtkWidget *buttonBox; - - GtkListStore *codecStore; - GtkCellRenderer *renderer; - GtkTreeSelection *treeSelection; - GtkTreeViewColumn *treeViewColumn; - - ret = gtk_hbox_new(FALSE, 10); - gtk_container_set_border_width(GTK_CONTAINER(ret), 10); - - scrolledWindow = gtk_scrolled_window_new(NULL, NULL); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledWindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledWindow), GTK_SHADOW_IN); - - gtk_box_pack_start(GTK_BOX(ret), scrolledWindow, TRUE, TRUE, 0); - codecStore = gtk_list_store_new(CODEC_COLUMN_COUNT, - G_TYPE_BOOLEAN, // Active - G_TYPE_STRING, // Name - G_TYPE_STRING, // Frequency - G_TYPE_STRING, // Bit rate - G_TYPE_STRING // Bandwith + GtkWidget *ret; + GtkWidget *scrolledWindow; + GtkWidget *buttonBox; + + GtkListStore *codecStore; + GtkCellRenderer *renderer; + GtkTreeSelection *treeSelection; + GtkTreeViewColumn *treeViewColumn; + + ret = gtk_hbox_new(FALSE, 10); + gtk_container_set_border_width(GTK_CONTAINER(ret), 10); + + scrolledWindow = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledWindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledWindow), GTK_SHADOW_IN); + + gtk_box_pack_start(GTK_BOX(ret), scrolledWindow, TRUE, TRUE, 0); + codecStore = gtk_list_store_new(CODEC_COLUMN_COUNT, + G_TYPE_BOOLEAN, // Active + G_TYPE_STRING, // Name + G_TYPE_STRING, // Frequency + G_TYPE_STRING, // Bit rate + G_TYPE_STRING // Bandwith ); - // Create codec tree view with list store - codecTreeView = gtk_tree_view_new_with_model(GTK_TREE_MODEL(codecStore)); + // Create codec tree view with list store + codecTreeView = gtk_tree_view_new_with_model(GTK_TREE_MODEL(codecStore)); - // Get tree selection manager - treeSelection = gtk_tree_view_get_selection(GTK_TREE_VIEW(codecTreeView)); - g_signal_connect(G_OBJECT(treeSelection), "changed", - G_CALLBACK (select_codec), - codecStore); + // Get tree selection manager + treeSelection = gtk_tree_view_get_selection(GTK_TREE_VIEW(codecTreeView)); + g_signal_connect(G_OBJECT(treeSelection), "changed", + G_CALLBACK (select_codec), + codecStore); - // Active column - renderer = gtk_cell_renderer_toggle_new(); - treeViewColumn = gtk_tree_view_column_new_with_attributes("", renderer, "active", COLUMN_CODEC_ACTIVE, NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(codecTreeView), treeViewColumn); + // Active column + renderer = gtk_cell_renderer_toggle_new(); + treeViewColumn = gtk_tree_view_column_new_with_attributes("", renderer, "active", COLUMN_CODEC_ACTIVE, NULL); + gtk_tree_view_append_column(GTK_TREE_VIEW(codecTreeView), treeViewColumn); - // Toggle codec active property on clicked - g_signal_connect(G_OBJECT(renderer), "toggled", G_CALLBACK(codec_active_toggled), (gpointer)codecTreeView); + // Toggle codec active property on clicked + g_signal_connect(G_OBJECT(renderer), "toggled", G_CALLBACK (codec_active_toggled), (gpointer) codecTreeView); - // Name column - renderer = gtk_cell_renderer_text_new(); - treeViewColumn = gtk_tree_view_column_new_with_attributes(_("Name"), renderer, "markup", COLUMN_CODEC_NAME, NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(codecTreeView), treeViewColumn); + // Name column + renderer = gtk_cell_renderer_text_new(); + treeViewColumn = gtk_tree_view_column_new_with_attributes(_("Name"), renderer, "markup", COLUMN_CODEC_NAME, NULL); + gtk_tree_view_append_column(GTK_TREE_VIEW(codecTreeView), treeViewColumn); - // Bit rate column - renderer = gtk_cell_renderer_text_new(); - treeViewColumn = gtk_tree_view_column_new_with_attributes(_("Frequency"), renderer, "text", COLUMN_CODEC_FREQUENCY, NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(codecTreeView), treeViewColumn); + // Bit rate column + renderer = gtk_cell_renderer_text_new(); + treeViewColumn = gtk_tree_view_column_new_with_attributes(_("Frequency"), renderer, "text", COLUMN_CODEC_FREQUENCY, NULL); + gtk_tree_view_append_column(GTK_TREE_VIEW(codecTreeView), treeViewColumn); - // Bandwith column - renderer = gtk_cell_renderer_text_new(); - treeViewColumn = gtk_tree_view_column_new_with_attributes(_("Bitrate"), renderer, "text", COLUMN_CODEC_BITRATE, NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(codecTreeView), treeViewColumn); + // Bandwith column + renderer = gtk_cell_renderer_text_new(); + treeViewColumn = gtk_tree_view_column_new_with_attributes(_("Bitrate"), renderer, "text", COLUMN_CODEC_BITRATE, NULL); + gtk_tree_view_append_column(GTK_TREE_VIEW(codecTreeView), treeViewColumn); - // Frequency column - renderer = gtk_cell_renderer_text_new(); - treeViewColumn = gtk_tree_view_column_new_with_attributes(_("Bandwidth"), renderer, "text", COLUMN_CODEC_BANDWIDTH, NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(codecTreeView), treeViewColumn); + // Frequency column + renderer = gtk_cell_renderer_text_new(); + treeViewColumn = gtk_tree_view_column_new_with_attributes(_("Bandwidth"), renderer, "text", COLUMN_CODEC_BANDWIDTH, NULL); + gtk_tree_view_append_column(GTK_TREE_VIEW(codecTreeView), treeViewColumn); - g_object_unref(G_OBJECT(codecStore)); - gtk_container_add(GTK_CONTAINER(scrolledWindow), codecTreeView); + g_object_unref(G_OBJECT(codecStore)); + gtk_container_add(GTK_CONTAINER(scrolledWindow), codecTreeView); - // Create button box - buttonBox = gtk_vbox_new(FALSE, 0); - gtk_container_set_border_width(GTK_CONTAINER(buttonBox), 10); - gtk_box_pack_start(GTK_BOX(ret), buttonBox, FALSE, FALSE, 0); + // Create button box + buttonBox = gtk_vbox_new(FALSE, 0); + gtk_container_set_border_width(GTK_CONTAINER(buttonBox), 10); + gtk_box_pack_start(GTK_BOX(ret), buttonBox, FALSE, FALSE, 0); - codecMoveUpButton = gtk_button_new_from_stock(GTK_STOCK_GO_UP); - gtk_widget_set_sensitive(GTK_WIDGET(codecMoveUpButton), FALSE); - gtk_box_pack_start(GTK_BOX(buttonBox), codecMoveUpButton, FALSE, FALSE, 0); - g_signal_connect(G_OBJECT(codecMoveUpButton), "clicked", G_CALLBACK(codec_move_up), a); + codecMoveUpButton = gtk_button_new_from_stock(GTK_STOCK_GO_UP); + gtk_widget_set_sensitive(GTK_WIDGET(codecMoveUpButton), FALSE); + gtk_box_pack_start(GTK_BOX(buttonBox), codecMoveUpButton, FALSE, FALSE, 0); + g_signal_connect(G_OBJECT(codecMoveUpButton), "clicked", G_CALLBACK(codec_move_up), *a); - codecMoveDownButton = gtk_button_new_from_stock(GTK_STOCK_GO_DOWN); - gtk_widget_set_sensitive(GTK_WIDGET(codecMoveDownButton), FALSE); - gtk_box_pack_start(GTK_BOX(buttonBox), codecMoveDownButton, FALSE, FALSE, 0); - g_signal_connect(G_OBJECT(codecMoveDownButton), "clicked", G_CALLBACK(codec_move_down), a); + codecMoveDownButton = gtk_button_new_from_stock(GTK_STOCK_GO_DOWN); + gtk_widget_set_sensitive(GTK_WIDGET(codecMoveDownButton), FALSE); + gtk_box_pack_start(GTK_BOX(buttonBox), codecMoveDownButton, FALSE, FALSE, 0); + g_signal_connect(G_OBJECT(codecMoveDownButton), "clicked", G_CALLBACK(codec_move_down), *a); - preferences_dialog_fill_codec_list (a); + preferences_dialog_fill_codec_list (a); - return ret; + return ret; } - void + void select_audio_manager( void ) { - DEBUG("audio manager selected\n"); + DEBUG("audio manager selected\n"); - if( !SHOW_ALSA_CONF && !gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(pulse) ) ) - { - dbus_set_audio_manager( ALSA ); - DEBUG(" display alsa conf panel"); - alsabox = alsa_box(); - gtk_container_add( GTK_CONTAINER(alsa_conf ) , alsabox); - gtk_widget_show( alsa_conf ); - gtk_widget_set_sensitive(GTK_WIDGET(alsa_conf), TRUE); + if( !SHOW_ALSA_CONF && !gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(pulse) ) ) + { + dbus_set_audio_manager( ALSA ); + DEBUG(" display alsa conf panel"); + alsabox = alsa_box(); + gtk_container_add( GTK_CONTAINER(alsa_conf ) , alsabox); + gtk_widget_show( alsa_conf ); + gtk_widget_set_sensitive(GTK_WIDGET(alsa_conf), TRUE); gtk_action_set_sensitive (GTK_ACTION (volumeToggle), TRUE); - } - else if( SHOW_ALSA_CONF && gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(pulse) )) - { - dbus_set_audio_manager( PULSEAUDIO ); - DEBUG(" remove alsa conf panel"); - gtk_container_remove( GTK_CONTAINER(alsa_conf) , alsabox ); - gtk_widget_hide( alsa_conf ); + } + else if( SHOW_ALSA_CONF && gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(pulse) )) + { + dbus_set_audio_manager( PULSEAUDIO ); + DEBUG(" remove alsa conf panel"); + gtk_container_remove( GTK_CONTAINER(alsa_conf) , alsabox ); + gtk_widget_hide( alsa_conf ); if (gtk_toggle_action_get_active ( GTK_TOGGLE_ACTION (volumeToggle))) { - main_window_volume_controls(FALSE); - dbus_set_volume_controls (FALSE); - gtk_toggle_action_set_active ( GTK_TOGGLE_ACTION (volumeToggle), FALSE); + main_window_volume_controls(FALSE); + dbus_set_volume_controls (FALSE); + gtk_toggle_action_set_active ( GTK_TOGGLE_ACTION (volumeToggle), FALSE); } gtk_action_set_sensitive (GTK_ACTION (volumeToggle), FALSE); - } else { - DEBUG("alsa conf panel...nothing"); - } + } else { + DEBUG("alsa conf panel...nothing"); + } } GtkWidget* alsa_box() { - GtkWidget *ret; - GtkWidget *table; - GtkWidget *item; - GtkCellRenderer *renderer; - - ret = gtk_hbox_new(FALSE, 10); - gtk_widget_show( ret ); - - table = gtk_table_new(4, 3, FALSE); - gtk_table_set_col_spacing(GTK_TABLE(table), 0, 40); - gtk_box_pack_start( GTK_BOX(ret) , table , TRUE , TRUE , 1); - gtk_widget_show(table); - - DEBUG("plugin"); - item = gtk_label_new(_("ALSA plugin")); - gtk_misc_set_alignment(GTK_MISC(item), 0, 0.5); - gtk_table_attach(GTK_TABLE(table), item, 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0); - gtk_widget_show( item ); - // Set choices of audio managers - pluginlist = gtk_list_store_new(1, G_TYPE_STRING); - preferences_dialog_fill_output_audio_plugin_list(); - plugin = gtk_combo_box_new_with_model(GTK_TREE_MODEL(pluginlist)); - select_active_output_audio_plugin(); - gtk_label_set_mnemonic_widget(GTK_LABEL(item), plugin); - g_signal_connect(G_OBJECT(plugin), "changed", G_CALLBACK(select_output_audio_plugin), plugin); - - // Set rendering - renderer = gtk_cell_renderer_text_new(); - gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(plugin), renderer, TRUE); - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(plugin), renderer, "text", 0, NULL); - gtk_table_attach(GTK_TABLE(table), plugin, 2, 3, 1, 2, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0); - gtk_widget_show(plugin); - - // Device : Output device - // Create title label - DEBUG("output"); - item = gtk_label_new(_("Output")); - gtk_misc_set_alignment(GTK_MISC(item), 0, 0.5); - gtk_table_attach(GTK_TABLE(table), item, 1, 2, 2, 3, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0); - gtk_widget_show(item); - // Set choices of output devices - outputlist = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT); - preferences_dialog_fill_output_audio_device_list(); - output = gtk_combo_box_new_with_model(GTK_TREE_MODEL(outputlist)); - select_active_output_audio_device(); - gtk_label_set_mnemonic_widget(GTK_LABEL(item), output); - g_signal_connect(G_OBJECT(output), "changed", G_CALLBACK(select_audio_output_device), output); - - // Set rendering - renderer = gtk_cell_renderer_text_new(); - gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(output), renderer, TRUE); - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(output), renderer, "text", 0, NULL); - gtk_table_attach(GTK_TABLE(table), output, 2, 3, 2, 3, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0); - gtk_widget_show(output); - - // Device : Input device - // Create title label - DEBUG("input"); - item = gtk_label_new(_("Input")); - gtk_misc_set_alignment(GTK_MISC(item), 0, 0.5); - gtk_table_attach(GTK_TABLE(table), item, 1, 2, 3, 4, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0); - gtk_widget_show(item); - - // Set choices of output devices - inputlist = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT); - preferences_dialog_fill_input_audio_device_list(); - input = gtk_combo_box_new_with_model(GTK_TREE_MODEL(inputlist)); - select_active_input_audio_device(); - gtk_label_set_mnemonic_widget(GTK_LABEL(item), input); - g_signal_connect(G_OBJECT(input), "changed", G_CALLBACK(select_audio_input_device), input); - - // Set rendering - renderer = gtk_cell_renderer_text_new(); - gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(input), renderer, TRUE); - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(input), renderer, "text", 0, NULL); - gtk_table_attach(GTK_TABLE(table), input, 2, 3, 3, 4, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0); - gtk_widget_show(input); - - gtk_widget_show_all(ret); - - DEBUG("done"); - return ret; + GtkWidget *ret; + GtkWidget *table; + GtkWidget *item; + GtkCellRenderer *renderer; + + ret = gtk_hbox_new(FALSE, 10); + gtk_widget_show( ret ); + + table = gtk_table_new(4, 3, FALSE); + gtk_table_set_col_spacing(GTK_TABLE(table), 0, 40); + gtk_box_pack_start( GTK_BOX(ret) , table , TRUE , TRUE , 1); + gtk_widget_show(table); + + DEBUG("plugin"); + item = gtk_label_new(_("ALSA plugin")); + gtk_misc_set_alignment(GTK_MISC(item), 0, 0.5); + gtk_table_attach(GTK_TABLE(table), item, 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0); + gtk_widget_show( item ); + // Set choices of audio managers + pluginlist = gtk_list_store_new(1, G_TYPE_STRING); + preferences_dialog_fill_output_audio_plugin_list(); + plugin = gtk_combo_box_new_with_model(GTK_TREE_MODEL(pluginlist)); + select_active_output_audio_plugin(); + gtk_label_set_mnemonic_widget(GTK_LABEL(item), plugin); + g_signal_connect(G_OBJECT(plugin), "changed", G_CALLBACK(select_output_audio_plugin), plugin); + + // Set rendering + renderer = gtk_cell_renderer_text_new(); + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(plugin), renderer, TRUE); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(plugin), renderer, "text", 0, NULL); + gtk_table_attach(GTK_TABLE(table), plugin, 2, 3, 1, 2, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0); + gtk_widget_show(plugin); + + // Device : Output device + // Create title label + DEBUG("output"); + item = gtk_label_new(_("Output")); + gtk_misc_set_alignment(GTK_MISC(item), 0, 0.5); + gtk_table_attach(GTK_TABLE(table), item, 1, 2, 2, 3, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0); + gtk_widget_show(item); + // Set choices of output devices + outputlist = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT); + preferences_dialog_fill_output_audio_device_list(); + output = gtk_combo_box_new_with_model(GTK_TREE_MODEL(outputlist)); + select_active_output_audio_device(); + gtk_label_set_mnemonic_widget(GTK_LABEL(item), output); + g_signal_connect(G_OBJECT(output), "changed", G_CALLBACK(select_audio_output_device), output); + + // Set rendering + renderer = gtk_cell_renderer_text_new(); + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(output), renderer, TRUE); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(output), renderer, "text", 0, NULL); + gtk_table_attach(GTK_TABLE(table), output, 2, 3, 2, 3, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0); + gtk_widget_show(output); + + // Device : Input device + // Create title label + DEBUG("input"); + item = gtk_label_new(_("Input")); + gtk_misc_set_alignment(GTK_MISC(item), 0, 0.5); + gtk_table_attach(GTK_TABLE(table), item, 1, 2, 3, 4, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0); + gtk_widget_show(item); + + // Set choices of output devices + inputlist = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT); + preferences_dialog_fill_input_audio_device_list(); + input = gtk_combo_box_new_with_model(GTK_TREE_MODEL(inputlist)); + select_active_input_audio_device(); + gtk_label_set_mnemonic_widget(GTK_LABEL(item), input); + g_signal_connect(G_OBJECT(input), "changed", G_CALLBACK(select_audio_input_device), input); + + // Set rendering + renderer = gtk_cell_renderer_text_new(); + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(input), renderer, TRUE); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(input), renderer, "text", 0, NULL); + gtk_table_attach(GTK_TABLE(table), input, 2, 3, 3, 4, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0); + gtk_widget_show(input); + + gtk_widget_show_all(ret); + + DEBUG("done"); + return ret; } GtkWidget* noise_box() { - GtkWidget *ret; - GtkWidget *enableVoiceActivity; - GtkWidget *enableNoiseReduction; - - // check button to enable ringtones - ret = gtk_hbox_new( TRUE , 1); - - enableVoiceActivity = gtk_check_button_new_with_mnemonic( _("_Voice Activity Detection")); - //TODO Use the value from D-BUS - gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(enableVoiceActivity), FALSE ); - gtk_box_pack_start( GTK_BOX(ret) , enableVoiceActivity , TRUE , TRUE , 1); - //TODO Enable it - //gtk_widget_set_sensitive(GTK_WIDGET(noise_conf), FALSE); - //TODO Add a callback function - //g_signal_connect(G_OBJECT( enableNoiseReduction) , "clicked" , NULL , NULL); - - - enableNoiseReduction = gtk_check_button_new_with_mnemonic( _("_Noise Reduction (Narrow-Band Companding)")); - //TODO Use the value from D-BUS - gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(enableNoiseReduction), FALSE ); - gtk_box_pack_start( GTK_BOX(ret) , enableNoiseReduction , TRUE , TRUE , 1); - //TODO Enable it - // gtk_widget_set_sensitive(GTK_WIDGET(noise_conf), FALSE); - //TODO Add a callback function - //g_signal_connect(G_OBJECT( enableNoiseReduction) , "clicked" , NULL , NULL); - - return ret; + GtkWidget *ret; + GtkWidget *enableVoiceActivity; + GtkWidget *enableNoiseReduction; + + // check button to enable ringtones + ret = gtk_hbox_new( TRUE , 1); + + enableVoiceActivity = gtk_check_button_new_with_mnemonic( _("_Voice Activity Detection")); + //TODO Use the value from D-BUS + gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(enableVoiceActivity), FALSE ); + gtk_box_pack_start( GTK_BOX(ret) , enableVoiceActivity , TRUE , TRUE , 1); + //TODO Enable it + //gtk_widget_set_sensitive(GTK_WIDGET(noise_conf), FALSE); + //TODO Add a callback function + //g_signal_connect(G_OBJECT( enableNoiseReduction) , "clicked" , NULL , NULL); + + + enableNoiseReduction = gtk_check_button_new_with_mnemonic( _("_Noise Reduction (Narrow-Band Companding)")); + //TODO Use the value from D-BUS + gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(enableNoiseReduction), FALSE ); + gtk_box_pack_start( GTK_BOX(ret) , enableNoiseReduction , TRUE , TRUE , 1); + //TODO Enable it + // gtk_widget_set_sensitive(GTK_WIDGET(noise_conf), FALSE); + //TODO Add a callback function + //g_signal_connect(G_OBJECT( enableNoiseReduction) , "clicked" , NULL , NULL); + + return ret; } static void record_path_changed( GtkFileChooser *chooser , GtkLabel *label UNUSED) { - DEBUG("record_path_changed"); + DEBUG("record_path_changed"); - gchar* path; - path = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER( chooser )); - DEBUG("path2 %s", path); - dbus_set_record_path( path ); + gchar* path; + path = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER( chooser )); + DEBUG("path2 %s", path); + dbus_set_record_path( path ); } GtkWidget* create_audio_configuration() { - // Main widget - GtkWidget *ret; - // Sub boxes - GtkWidget *box; - GtkWidget *frame; - - ret = gtk_vbox_new(FALSE, 10); - gtk_container_set_border_width(GTK_CONTAINER(ret), 10); - - GtkWidget *alsa; - GtkWidget *table; - - gnome_main_section_new_with_table (_("Sound Manager"), &frame, &table, 1, 2); - gtk_box_pack_start(GTK_BOX(ret), frame, FALSE, FALSE, 0); - - int audio_manager = dbus_get_audio_manager(); - gboolean pulse_audio = FALSE; - if (audio_manager == PULSEAUDIO) { - pulse_audio = TRUE; - } - - pulse = gtk_radio_button_new_with_mnemonic( NULL , _("_Pulseaudio")); - gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(pulse), pulse_audio); - gtk_table_attach ( GTK_TABLE( table ), pulse, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - alsa = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(pulse), _("_ALSA")); - gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(alsa), !pulse_audio); - g_signal_connect(G_OBJECT(alsa), "clicked", G_CALLBACK(select_audio_manager), NULL); - gtk_table_attach ( GTK_TABLE( table ), alsa, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - // Box for the ALSA configuration - gnome_main_section_new (_("ALSA settings"), &alsa_conf); - gtk_box_pack_start(GTK_BOX(ret), alsa_conf, FALSE, FALSE, 0); - gtk_widget_show( alsa_conf ); - if( SHOW_ALSA_CONF ) - { - // Box for the ALSA configuration - printf("ALSA Created \n"); - alsabox = alsa_box(); - gtk_container_add( GTK_CONTAINER(alsa_conf) , alsabox ); - gtk_widget_hide( alsa_conf ); - } - - // Recorded file saving path - GtkWidget *label; - GtkWidget *folderChooser; - gchar *dftPath; - - /* Get the path where to save audio files */ - dftPath = dbus_get_record_path (); - DEBUG("load recording path %s\n", dftPath); - - gnome_main_section_new_with_table (_("Recordings"), &frame, &table, 1, 2); - gtk_box_pack_start(GTK_BOX(ret), frame, FALSE, FALSE, 0); - - // label - label = gtk_label_new(_("Destination folder")); - gtk_table_attach( GTK_TABLE(table), label, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 5); - - // folder chooser button - folderChooser = gtk_file_chooser_button_new(_("Select a folder"), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); - gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER( folderChooser), dftPath); - 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; - - 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 ) , NULL); - gtk_table_attach ( GTK_TABLE( table ), enableTone, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - // file chooser button - fileChooser = gtk_file_chooser_button_new(_("Choose a ringtone"), GTK_FILE_CHOOSER_ACTION_OPEN); - 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()); - 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); - - gtk_widget_show_all(ret); - - if(!pulse_audio) { - gtk_widget_show(alsa_conf); - } - else{ - gtk_widget_hide(alsa_conf); - } - - return ret; + // Main widget + GtkWidget *ret; + // Sub boxes + GtkWidget *box; + GtkWidget *frame; + + ret = gtk_vbox_new(FALSE, 10); + gtk_container_set_border_width(GTK_CONTAINER(ret), 10); + + GtkWidget *alsa; + GtkWidget *table; + + gnome_main_section_new_with_table (_("Sound Manager"), &frame, &table, 1, 2); + gtk_box_pack_start(GTK_BOX(ret), frame, FALSE, FALSE, 0); + + int audio_manager = dbus_get_audio_manager(); + gboolean pulse_audio = FALSE; + if (audio_manager == PULSEAUDIO) { + pulse_audio = TRUE; + } + + pulse = gtk_radio_button_new_with_mnemonic( NULL , _("_Pulseaudio")); + gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(pulse), pulse_audio); + gtk_table_attach ( GTK_TABLE( table ), pulse, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + alsa = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(pulse), _("_ALSA")); + gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(alsa), !pulse_audio); + g_signal_connect(G_OBJECT(alsa), "clicked", G_CALLBACK(select_audio_manager), NULL); + gtk_table_attach ( GTK_TABLE( table ), alsa, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + // Box for the ALSA configuration + gnome_main_section_new (_("ALSA settings"), &alsa_conf); + gtk_box_pack_start(GTK_BOX(ret), alsa_conf, FALSE, FALSE, 0); + gtk_widget_show( alsa_conf ); + if( SHOW_ALSA_CONF ) + { + // Box for the ALSA configuration + printf("ALSA Created \n"); + alsabox = alsa_box(); + gtk_container_add( GTK_CONTAINER(alsa_conf) , alsabox ); + gtk_widget_hide( alsa_conf ); + } + + // Recorded file saving path + GtkWidget *label; + GtkWidget *folderChooser; + gchar *dftPath; + + /* Get the path where to save audio files */ + dftPath = dbus_get_record_path (); + DEBUG("load recording path %s\n", dftPath); + + gnome_main_section_new_with_table (_("Recordings"), &frame, &table, 1, 2); + gtk_box_pack_start(GTK_BOX(ret), frame, FALSE, FALSE, 0); + + // label + label = gtk_label_new(_("Destination folder")); + gtk_table_attach( GTK_TABLE(table), label, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 5); + + // folder chooser button + folderChooser = gtk_file_chooser_button_new(_("Select a folder"), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); + gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER( folderChooser), dftPath); + 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; + + 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 ) , NULL); + gtk_table_attach ( GTK_TABLE( table ), enableTone, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + // file chooser button + fileChooser = gtk_file_chooser_button_new(_("Choose a ringtone"), GTK_FILE_CHOOSER_ACTION_OPEN); + 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()); + 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); + + gtk_widget_show_all(ret); + + if(!pulse_audio) { + gtk_widget_show(alsa_conf); + } + else{ + gtk_widget_hide(alsa_conf); + } + + return ret; } GtkWidget* create_codecs_configuration (account_t **a) { - // Main widget - GtkWidget *ret, *codecs, *box, *frame; + // Main widget + GtkWidget *ret, *codecs, *box, *frame; - ret = gtk_vbox_new(FALSE, 10); - gtk_container_set_border_width(GTK_CONTAINER(ret), 10); + ret = gtk_vbox_new(FALSE, 10); + gtk_container_set_border_width(GTK_CONTAINER(ret), 10); - // Box for the codecs - gnome_main_section_new (_("Codecs"), &codecs); - gtk_box_pack_start (GTK_BOX(ret), codecs, FALSE, FALSE, 0); - gtk_widget_set_size_request (GTK_WIDGET (codecs), -1, 200); - gtk_widget_show (codecs); - box = codecs_box (a); - gtk_container_add (GTK_CONTAINER (codecs) , box); + // Box for the codecs + gnome_main_section_new (_("Codecs"), &codecs); + gtk_box_pack_start (GTK_BOX(ret), codecs, FALSE, FALSE, 0); + gtk_widget_set_size_request (GTK_WIDGET (codecs), -1, 200); + gtk_widget_show (codecs); + box = codecs_box (a); + gtk_container_add (GTK_CONTAINER (codecs) , box); - gtk_widget_show_all(ret); + gtk_widget_show_all(ret); - return ret; + return ret; } diff --git a/sflphone-client-gnome/src/dbus/configurationmanager-introspec.xml b/sflphone-client-gnome/src/dbus/configurationmanager-introspec.xml index a32f4b94ec0947e2b259f371a73a175c3576592a..e7532d16cb2d161e29d042941a59fffd0d49ae1b 100644 --- a/sflphone-client-gnome/src/dbus/configurationmanager-introspec.xml +++ b/sflphone-client-gnome/src/dbus/configurationmanager-introspec.xml @@ -156,6 +156,7 @@ <method name="setActiveCodecList"> <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="VectorString"/> <arg type="as" name="list" direction="in"/> + <arg type="s" name="accountID" direction="in"/> </method> diff --git a/sflphone-client-gnome/src/dbus/dbus.c b/sflphone-client-gnome/src/dbus/dbus.c index bec4e18f04ab89b89f074f8f8cb149d7c318c052..433d151e04e7f4af9f142ae32cdafa90a0309851 100644 --- a/sflphone-client-gnome/src/dbus/dbus.c +++ b/sflphone-client-gnome/src/dbus/dbus.c @@ -1272,13 +1272,14 @@ gchar** dbus_get_active_codec_list (gchar *accountID) { } void -dbus_set_active_codec_list(const gchar** list) +dbus_set_active_codec_list(const gchar** list, const gchar *accountID) { GError *error = NULL; org_sflphone_SFLphone_ConfigurationManager_set_active_codec_list ( configurationManagerProxy, list, + accountID, &error); if (error) diff --git a/sflphone-client-gnome/src/dbus/dbus.h b/sflphone-client-gnome/src/dbus/dbus.h index 9a0ee27a88b909a7c2a300202f218f7eceb95d8e..d4c7b8a2aafa875f647e665db4c07eea02389aee 100644 --- a/sflphone-client-gnome/src/dbus/dbus.h +++ b/sflphone-client-gnome/src/dbus/dbus.h @@ -233,7 +233,7 @@ gchar** dbus_get_active_codec_list (gchar *accountID); * ConfigurationManager - Set the list of codecs used for media negociation * @param list The list of codecs */ -void dbus_set_active_codec_list( const gchar** list ); +void dbus_set_active_codec_list (const gchar** list, const gchar*); /** * CallManager - return the codec name diff --git a/sflphone-common/src/account.cpp b/sflphone-common/src/account.cpp index 3db5040d9268aab6addef5e92e02c9dde8f8e8bd..e54a278be7f88fccafbf048e77c1c5625441c3eb 100644 --- a/sflphone-common/src/account.cpp +++ b/sflphone-common/src/account.cpp @@ -23,13 +23,13 @@ #include "manager.h" Account::Account (const AccountID& accountID, std::string type) : - _accountID (accountID) - , _link (NULL) - , _enabled (false) - , _type (type) - , _codecOrder () + _accountID (accountID) + , _link (NULL) + , _enabled (false) + , _type (type) + , _codecOrder () { - setRegistrationState (Unregistered); + setRegistrationState (Unregistered); } Account::~Account() @@ -38,17 +38,17 @@ Account::~Account() void Account::loadConfig() { - std::string p; + std::string p; - p = Manager::instance().getConfigString (_accountID , CONFIG_ACCOUNT_TYPE); + p = Manager::instance().getConfigString (_accountID , CONFIG_ACCOUNT_TYPE); #ifdef USE_IAX - _enabled = (Manager::instance().getConfigString (_accountID, CONFIG_ACCOUNT_ENABLE) == "true") ? true : false; + _enabled = (Manager::instance().getConfigString (_accountID, CONFIG_ACCOUNT_ENABLE) == "true") ? true : false; #else - if (p == "IAX") - _enabled = false; - else - _enabled = (Manager::instance().getConfigString (_accountID, CONFIG_ACCOUNT_ENABLE) == "true") ? true : false; + if (p == "IAX") + _enabled = false; + else + _enabled = (Manager::instance().getConfigString (_accountID, CONFIG_ACCOUNT_ENABLE) == "true") ? true : false; #endif @@ -57,48 +57,58 @@ void Account::loadConfig() { void Account::setRegistrationState (RegistrationState state) { - if (state != _registrationState) { - _debug ("Account::setRegistrationState"); - _registrationState = state; + if (state != _registrationState) { + _debug ("Account::setRegistrationState"); + _registrationState = state; - // Notify the client - Manager::instance().connectionStatusNotification(); - } + // Notify the client + Manager::instance().connectionStatusNotification(); + } } void Account::loadAudioCodecs (void) { // if the user never set the codec list, use the default configuration for this account - if (Manager::instance ().getConfigString (AUDIO, "ActiveCodecs") == "") { + if (Manager::instance ().getConfigString (_accountID, "ActiveCodecs") == "") { _warn ("use the default order"); Manager::instance ().getCodecDescriptorMap ().setDefaultOrder(); - } - - // else retrieve the one set in the user config file - else { - std::vector<std::string> active_list = Manager::instance ().retrieveActiveCodecs(); - setActiveCodecs (active_list); - } + } + + // else retrieve the one set in the user config file + else { + std::vector<std::string> active_list = Manager::instance ().retrieveActiveCodecs(); + // This property is now set per account basis + std::string s = Manager::instance ().getConfigString (_accountID, "ActiveCodecs"); + setActiveCodecs (Manager::instance ().unserialize (s)); + } } void Account::setActiveCodecs (const std::vector <std::string> &list) { - _codecOrder.clear(); - // list contains the ordered payload of active codecs picked by the user for this account - // we used the CodecOrder vector to save the order. - int i=0; - int payload; - size_t size = list.size(); + _codecOrder.clear(); + // list contains the ordered payload of active codecs picked by the user for this account + // we used the CodecOrder vector to save the order. + int i=0; + int payload; + size_t size = list.size(); - _warn ("set the custom order %i", list.size ()); + _warn ("set the custom order %i", list.size ()); _warn ("Setting active codec list"); - while ( (unsigned int) i < size) { - payload = std::atoi (list[i].data()); - _warn ("Adding codec with RTP payload=%i", payload); - //if (Manager::instance ().getCodecDescriptorMap ().isCodecLoaded (payload)) { - _codecOrder.push_back ( (AudioCodecType) payload); - //} - i++; - } + while ( (unsigned int) i < size) { + payload = std::atoi (list[i].data()); + _warn ("Adding codec with RTP payload=%i", payload); + //if (Manager::instance ().getCodecDescriptorMap ().isCodecLoaded (payload)) { + _codecOrder.push_back ( (AudioCodecType) payload); + //} + i++; + } + + // setConfig + std::string s = Manager::instance ().serialize (list); + _warn ("Setting codec with payload number %s to the active list", s.c_str()); + // Set the config per account + Manager::instance().setConfig (_accountID, "ActiveCodecs", s); + + } diff --git a/sflphone-common/src/dbus/configurationmanager-introspec.xml b/sflphone-common/src/dbus/configurationmanager-introspec.xml index a32f4b94ec0947e2b259f371a73a175c3576592a..e7532d16cb2d161e29d042941a59fffd0d49ae1b 100644 --- a/sflphone-common/src/dbus/configurationmanager-introspec.xml +++ b/sflphone-common/src/dbus/configurationmanager-introspec.xml @@ -156,6 +156,7 @@ <method name="setActiveCodecList"> <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="VectorString"/> <arg type="as" name="list" direction="in"/> + <arg type="s" name="accountID" direction="in"/> </method> diff --git a/sflphone-common/src/dbus/configurationmanager.cpp b/sflphone-common/src/dbus/configurationmanager.cpp index 64571106c482e53f1a3e1f8ef41c7bdde5fa1af9..8a0c1c99058a7dde008023a8953f6d6d02bde7c2 100644 --- a/sflphone-common/src/dbus/configurationmanager.cpp +++ b/sflphone-common/src/dbus/configurationmanager.cpp @@ -458,11 +458,19 @@ std::vector<std::string> ConfigurationManager::getActiveCodecList (const std::st return v; } -void -ConfigurationManager::setActiveCodecList (const std::vector< std::string >& list) +void ConfigurationManager::setActiveCodecList (const std::vector< std::string >& list, const std::string& accountID) { _debug ("ConfigurationManager::setActiveCodecList received"); - Manager::instance().setActiveCodecList (list); + + Account *acc; + unsigned int i=0; + size_t size; + + // Save the codecs list per account + acc = Manager::instance ().getAccount (accountID); + if (acc != NULL) { + acc->setActiveCodecs (list); + } } // Audio devices related methods diff --git a/sflphone-common/src/dbus/configurationmanager.h b/sflphone-common/src/dbus/configurationmanager.h index 864522d66b85c7fa077ad0111c060362c887b2ad..b4cfbc4dc4fa7a640b6ffb314d33779be6eb00b1 100644 --- a/sflphone-common/src/dbus/configurationmanager.h +++ b/sflphone-common/src/dbus/configurationmanager.h @@ -59,7 +59,7 @@ public: std::vector< std::string > getSupportedTlsMethod(void); std::vector< std::string > getCodecDetails( const int32_t& payload ); std::vector< std::string > getActiveCodecList (const std::string& accountID); - void setActiveCodecList( const std::vector< std::string >& list ); + void setActiveCodecList (const std::vector< std::string >& list, const std::string& accountID); std::vector< std::string > getInputAudioPluginList(); std::vector< std::string > getOutputAudioPluginList(); diff --git a/sflphone-common/src/iax/iaxcall.cpp b/sflphone-common/src/iax/iaxcall.cpp index 73486d8e310dc7b1ba6cbcad8dcae82bf9019df0..be152908e611ac9411a290615fccfc678568cb2d 100644 --- a/sflphone-common/src/iax/iaxcall.cpp +++ b/sflphone-common/src/iax/iaxcall.cpp @@ -19,6 +19,7 @@ */ #include "iaxcall.h" +#include "manager.h" #include "global.h" // for _debug IAXCall::IAXCall (const CallID& id, Call::CallType type) : Call (id, type), _session (NULL) @@ -73,15 +74,22 @@ IAXCall::setFormat (int format) int -IAXCall::getSupportedFormat() +IAXCall::getSupportedFormat (std::string accountID) { CodecOrder map; int format = 0; unsigned int iter; + Account *account; _info ("IAX get supported format: "); - map = getCodecMap().getActiveCodecs(); + account = Manager::instance().getAccount (accountID); + if (account != NULL) { + map = account->getActiveCodecs(); + } + else { + _error ("No IAx account could be found"); + } for (iter=0 ; iter < map.size() ; iter++) { switch (map[iter]) { @@ -120,7 +128,7 @@ IAXCall::getSupportedFormat() } -int IAXCall::getFirstMatchingFormat (int needles, account_id) { +int IAXCall::getFirstMatchingFormat (int needles, std::string accountID) { Account *account; CodecOrder map; @@ -129,7 +137,7 @@ int IAXCall::getFirstMatchingFormat (int needles, account_id) { _debug ("IAX get first matching codec: "); - account = Manager::instance().getAccount (account_id); + account = Manager::instance().getAccount (accountID); if (account != NULL) { map = account->getActiveCodecs(); } diff --git a/sflphone-common/src/iax/iaxcall.h b/sflphone-common/src/iax/iaxcall.h index 8cb424ba2560cb8244bb037894160200a610b1ad..12dc670428640ae08f22e922ed1810471ce7ff4e 100644 --- a/sflphone-common/src/iax/iaxcall.h +++ b/sflphone-common/src/iax/iaxcall.h @@ -75,7 +75,7 @@ public: /** * @return int The bitwise list of supported formats */ - int getSupportedFormat(); + int getSupportedFormat (std::string accountID); /** * Return a format (int) with the first matching codec selected. @@ -90,7 +90,7 @@ public: * @param needles The format(s) (bitwise) you are looking for to match * @return int The matching format, thus 0 if none matches */ - int getFirstMatchingFormat(int needles, AccountID account_id); + int getFirstMatchingFormat(int needles, std::string accountID); // AUDIO /** diff --git a/sflphone-common/src/iax/iaxvoiplink.cpp b/sflphone-common/src/iax/iaxvoiplink.cpp index 1953f6b9769002e42bed611a72935e6e22da6052..9139b07b3be0d76540082bb26f86a85a26fb447b 100644 --- a/sflphone-common/src/iax/iaxvoiplink.cpp +++ b/sflphone-common/src/iax/iaxvoiplink.cpp @@ -712,8 +712,8 @@ IAXVoIPLink::iaxOutgoingInvite (IAXCall* call) wait = 0; /** @todo Make preference dynamic, and configurable */ - audio_format_preferred = call->getFirstMatchingFormat (call->getSupportedFormat (account->getActiveCodecs ())); - audio_format_capability = call->getSupportedFormat (account->getActiveCodecs ()); + audio_format_preferred = call->getFirstMatchingFormat (call->getSupportedFormat (getAccountID ()), getAccountID ()); + audio_format_capability = call->getSupportedFormat (getAccountID ()); _debug ("IAX New call: %s", strNum.c_str()); iax_call (newsession, username.c_str(), username.c_str(), strNum.c_str(), lang, wait, audio_format_preferred, audio_format_capability); diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index 1c87bb03c2dbaea8ae62578450df48cca7a4d6b6..0f404b23d28ab2e28a0af0e0d19128ec3df80bed 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -2404,22 +2404,6 @@ ManagerImpl::initAudioCodec (void) }*/ } -/* - * TODO Set the active codecs list per account - */ -void ManagerImpl::setActiveCodecList (const std::vector< std::string >& list) { - - _warn ("Set active codecs list"); - // TODO Save the codec list per account - _codecDescriptorMap.saveActiveCodecs (list); - - // setConfig - std::string s = serialize (list); - _warn ("Setting codec with payload number %s to the active list", s.c_str()); - // Set the config per account - setConfig ("Audio", "ActiveCodecs", s); -} - /* * TODO Retrieve the active codec list per account */ diff --git a/sflphone-common/src/managerimpl.h b/sflphone-common/src/managerimpl.h index a4a871d1e4f1d8a8b1a3437c683db95f1089f8b2..7aaa89a4a669a496cfe49cef6d4027e5f13de278 100644 --- a/sflphone-common/src/managerimpl.h +++ b/sflphone-common/src/managerimpl.h @@ -795,12 +795,6 @@ class ManagerImpl { */ std::vector< ::std::string > getActiveCodecList( void ); - /** - * Set the list of the active codecs - * @param list The new list of active codecs - */ - void setActiveCodecList( const std::vector< ::std::string >& list); - /* * Notify the client that an error occured * @param errCode The error code. Could be: ALSA_CAPTURE_ERROR diff --git a/sflphone-common/src/sip/sipvoiplink.cpp b/sflphone-common/src/sip/sipvoiplink.cpp index ae7826fdf947f5905df37d36d0a09d987c96e4e3..950975d5a0225f165a5731fd8fd8787f8dbfd63b 100644 --- a/sflphone-common/src/sip/sipvoiplink.cpp +++ b/sflphone-common/src/sip/sipvoiplink.cpp @@ -1579,7 +1579,7 @@ bool SIPVoIPLink::new_ip_to_ip_call (const CallID& id, const std::string& to) // Building the local SDP offer call->getLocalSDP()->set_ip_address (addrSdp); - call->getLocalSDP()->create_initial_offer(); + call->getLocalSDP()->create_initial_offer(account->getActiveCodecs ()); // If no account already set, use the default one created at pjsip initialization if (account->getAccountTransport() == NULL) {