Mon, 10 Oct 2022 00:26:06 -0500
Remember CredentialProvider setting while exiting
We were resetting the setting to its default if we had a NULL active provider
id. However, the only time it's valid to call
purple_credential_manager_set_active_provider with a NULL id is during shutdown.
If someone is trying to disable all credential providers, they will be selecting
the noop provider which has a non null id.
Testing Done:
Ran and set the credential provider to libsecret. Closed the program, reopened, verified that libsecret was still selected.
Reviewed at https://reviews.imfreedom.org/r/1918/
| libpurple/purplecredentialmanager.c | file | annotate | diff | comparison | revisions | |
| libpurple/purplecredentialmanager.h | file | annotate | diff | comparison | revisions |
--- a/libpurple/purplecredentialmanager.c Sun Oct 09 04:50:08 2022 -0500 +++ b/libpurple/purplecredentialmanager.c Mon Oct 10 00:26:06 2022 -0500 @@ -443,15 +443,18 @@ g_clear_object(&previous); - /* Finally update the preference. */ - settings = g_settings_new_with_backend("im.pidgin.Purple.Credentials", - purple_core_get_settings_backend()); + /* Finally update the preference if we were given a new id. We assume, that + * a NULL id means we're shutting down and thus shouldn't update the + * setting. + */ if(id != NULL) { + settings = g_settings_new_with_backend("im.pidgin.Purple.Credentials", + purple_core_get_settings_backend()); + g_settings_set_string(settings, "active-provider", id); - } else { - g_settings_reset(settings, "active-provider"); + + g_object_unref(settings); } - g_object_unref(settings); purple_debug_info("credential-manager", "set active provider to '%s'", id);
--- a/libpurple/purplecredentialmanager.h Sun Oct 09 04:50:08 2022 -0500 +++ b/libpurple/purplecredentialmanager.h Mon Oct 10 00:26:06 2022 -0500 @@ -119,6 +119,11 @@ * Changes the active #PurpleCredentialProvider of @manager to provider with an * id of @id. * + * If @id is %NULL, it is assumed that the process is shutting down and that + * the active provider setting will be left intact. If you want to disable the + * active provider and keep running, you should set the active provider to + * [class@Purple.NoopCredentialProvider]. + * * Returns: %TRUE on success or %FALSE with @error set on failure. * * Since: 3.0.0