Mercurial > pidgin.yaz
changeset 31824:4f2aac5967bb
Make the simple silence suppression stuff optional per-account. Fixes #13180.
committer: John Bailey <rekkanoryo@rekkanoryo.org>
author | jakub.adam@ktknet.cz |
---|---|
date | Sun, 13 Mar 2011 18:17:14 +0000 |
parents | d72d728226dc |
children | ad7380e10f2a |
files | libpurple/account.c libpurple/account.h libpurple/media/backend-fs2.c pidgin/gtkaccount.c |
diffstat | 4 files changed, 92 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/account.c Sun Mar 13 18:14:04 2011 +0000 +++ b/libpurple/account.c Sun Mar 13 18:17:14 2011 +0000 @@ -1936,6 +1936,20 @@ } } +gboolean +purple_account_get_silence_suppression(const PurpleAccount *account) +{ + return purple_account_get_bool(account, "silence-suppression", FALSE); +} + +void +purple_account_set_silence_suppression(PurpleAccount *account, gboolean value) +{ + g_return_if_fail(account != NULL); + + purple_account_set_bool(account, "silence-suppression", value); +} + void purple_account_clear_settings(PurpleAccount *account) {
--- a/libpurple/account.h Sun Mar 13 18:14:04 2011 +0000 +++ b/libpurple/account.h Sun Mar 13 18:17:14 2011 +0000 @@ -513,6 +513,24 @@ PurpleGetPublicAliasFailureCallback failure_cb); /** + * Return whether silence suppression is used during voice call. + * + * @param account The account. + * + * @return @c TRUE if suppression is used, or @c FALSE if not. + */ +gboolean purple_account_get_silence_suppression(const PurpleAccount *account); + +/** + * Sets whether silence suppression is used during voice call. + * + * @param account The account. + * @param value @c TRUE if suppression should be used. + */ +void purple_account_set_silence_suppression(PurpleAccount *account, + gboolean value); + +/** * Clears all protocol-specific settings on an account. * * @param account The account.
--- a/libpurple/media/backend-fs2.c Sun Mar 13 18:14:04 2011 +0000 +++ b/libpurple/media/backend-fs2.c Sun Mar 13 18:17:14 2011 +0000 @@ -155,13 +155,7 @@ static void purple_media_backend_fs2_init(PurpleMediaBackendFs2 *self) -{ - PurpleMediaBackendFs2Private *priv = - PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(self); - - priv->silence_threshold = purple_prefs_get_int( - "/purple/media/audio/silence_threshold") / 100.0; -} +{} static gboolean event_probe_cb(GstPad *srcpad, GstEvent *event, gboolean release_pad) @@ -817,9 +811,11 @@ if (!strncmp(name, "sendlevel_", 10)) { session = get_session(self, name+10); - percent = gst_msg_db_to_percent(msg, "decay"); - g_object_set(session->srcvalve, - "drop", (percent < priv->silence_threshold), NULL); + if (priv->silence_threshold > 0) { + percent = gst_msg_db_to_percent(msg, "decay"); + g_object_set(session->srcvalve, + "drop", (percent < priv->silence_threshold), NULL); + } } g_free(name); @@ -1255,6 +1251,13 @@ return FALSE; } + if (purple_account_get_silence_suppression( + purple_media_get_account(priv->media))) + priv->silence_threshold = purple_prefs_get_int( + "/purple/media/audio/silence_threshold") / 100.0; + else + priv->silence_threshold = 0; + pipeline = purple_media_manager_get_pipeline( purple_media_get_manager(priv->media));
--- a/pidgin/gtkaccount.c Sun Mar 13 18:14:04 2011 +0000 +++ b/pidgin/gtkaccount.c Sun Mar 13 18:17:14 2011 +0000 @@ -143,6 +143,10 @@ GtkWidget *proxy_user_entry; GtkWidget *proxy_pass_entry; + /* Voice & Video Options*/ + GtkWidget *voice_frame; + GtkWidget *suppression_check; + } AccountPrefsDialog; static AccountsWindow *accounts_window = NULL; @@ -159,6 +163,7 @@ static void add_user_options(AccountPrefsDialog *dialog, GtkWidget *parent); static void add_protocol_options(AccountPrefsDialog *dialog); static void add_proxy_options(AccountPrefsDialog *dialog, GtkWidget *parent); +static void add_voice_options(AccountPrefsDialog *dialog); static GtkWidget * add_pref_box(AccountPrefsDialog *dialog, GtkWidget *parent, @@ -237,6 +242,7 @@ add_login_options(dialog, dialog->top_vbox); add_user_options(dialog, dialog->top_vbox); add_protocol_options(dialog); + add_voice_options(dialog); gtk_widget_grab_focus(dialog->protocol_menu); @@ -1163,6 +1169,39 @@ G_CALLBACK(proxy_type_changed_cb), dialog); } +static void +add_voice_options(AccountPrefsDialog *dialog) +{ +#ifdef USE_VV + if (!dialog->prpl_info || !dialog->prpl_info->initiate_media) { + if (dialog->voice_frame) { + gtk_widget_destroy(dialog->voice_frame); + dialog->voice_frame = NULL; + dialog->suppression_check = NULL; + } + return; + } + + if (!dialog->voice_frame) { + dialog->voice_frame = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER); + gtk_container_set_border_width(GTK_CONTAINER(dialog->voice_frame), + PIDGIN_HIG_BORDER); + + dialog->suppression_check = + gtk_check_button_new_with_mnemonic(_("Use _silence suppression")); + gtk_box_pack_start(GTK_BOX(dialog->voice_frame), dialog->suppression_check, + FALSE, FALSE, 0); + + gtk_notebook_append_page(GTK_NOTEBOOK(dialog->notebook), + dialog->voice_frame, gtk_label_new_with_mnemonic(_("_Voice and Video"))); + gtk_widget_show_all(dialog->voice_frame); + } + + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->suppression_check), + purple_account_get_silence_suppression(dialog->account)); +#endif +} + static gboolean account_win_destroy_cb(GtkWidget *w, GdkEvent *event, AccountPrefsDialog *dialog) @@ -1437,6 +1476,12 @@ proxy_info = NULL; } + /* Voice and Video settings */ + if (dialog->voice_frame) { + purple_account_set_silence_suppression(account, + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->suppression_check))); + } + /* If this is a new account, add it to our list */ if (new_acct) purple_accounts_add(account); @@ -1558,6 +1603,8 @@ gtk_widget_show(dbox); add_proxy_options(dialog, dbox); + add_voice_options(dialog); + /* Cancel button */ pidgin_dialog_add_button(GTK_DIALOG(win), GTK_STOCK_CANCEL, G_CALLBACK(cancel_account_prefs_cb), dialog);