--- a/finch/gntui.c Mon Oct 18 01:51:02 2021 -0500
+++ b/finch/gntui.c Mon Oct 18 02:01:37 2021 -0500
@@ -42,8 +42,41 @@
+finch_history_init(GError **error) { + PurpleHistoryManager *manager = NULL; + PurpleHistoryAdapter *adapter = NULL; + gchar *filename = NULL; + const gchar *id = NULL; + manager = purple_history_manager_get_default(); + /* Attempt to create the config directory. */ + g_mkdir_with_parents(purple_config_dir(), 0700); + filename = g_build_filename(purple_config_dir(), "history.db", NULL); + adapter = purple_sqlite_history_adapter_new(filename); + id = purple_history_adapter_get_id(adapter); + if(!purple_history_manager_register(manager, adapter, error)) { + g_clear_object(&adapter); + /* The manager adds a ref to the adapter on registration, so we can remove + g_clear_object(&adapter); + return purple_history_manager_set_active(manager, id, error); #ifdef _WIN32 /* TODO: don't change it when using FHS under win32 */
gnt_set_config_dir(purple_user_dir());
@@ -52,6 +85,12 @@
+ if(!finch_history_init(&error)) { + g_critical("failed to initialize the history api: %s", + error != NULL ? error->message : "unknown"); purple_prefs_add_none("/purple/gnt");
--- a/libpurple/purplehistorymanager.c Mon Oct 18 01:51:02 2021 -0500
+++ b/libpurple/purplehistorymanager.c Mon Oct 18 02:01:37 2021 -0500
@@ -148,40 +148,7 @@
purple_history_manager_startup(void) {
if(default_manager == NULL) {
- PurpleHistoryAdapter *adapter = NULL;
- gchar *filename = NULL;
- filename = g_build_filename(purple_config_dir(), "history.db", NULL);
- adapter = purple_sqlite_history_adapter_new(filename);
default_manager = g_object_new(PURPLE_TYPE_HISTORY_MANAGER, NULL);
- if(!purple_history_manager_register(default_manager, adapter, &error)) {
- g_warning("Failed to register sqlite history adapter: %s", error->message);
- g_warning("Failed to register sqlite history adapter: Unknown reason");
- g_clear_object(&adapter);
- purple_history_manager_set_active(default_manager,
- purple_history_adapter_get_id(adapter),
- g_warning("Failed to activate %s: %s",
- purple_history_adapter_get_id(adapter), error->message);
- g_clear_object(&adapter);
--- a/libpurple/tests/test_ui.c Mon Oct 18 01:51:02 2021 -0500
+++ b/libpurple/tests/test_ui.c Mon Oct 18 02:01:37 2021 -0500
@@ -65,8 +65,35 @@
+test_ui_init_history(GError **error) { + PurpleHistoryManager *manager = NULL; + PurpleHistoryAdapter *adapter = NULL; + const gchar *id = NULL; + manager = purple_history_manager_get_default(); + adapter = purple_sqlite_history_adapter_new(":memory:"); + id = purple_history_adapter_get_id(adapter); + if(!purple_history_manager_register(manager, adapter, error)) { + g_clear_object(&adapter); + /* The manager adds a ref to the adapter on registration, so we can remove + g_clear_object(&adapter); + return purple_history_manager_set_active(manager, id, error); test_ui_purple_init(void) {
/* libpurple's built-in DNS resolution forks processes to perform
* blocking lookups without blocking the main process. It does not
@@ -79,9 +106,6 @@
/* set the magic PURPLE_PLUGINS_SKIP environment variable */
g_setenv("PURPLE_PLUGINS_SKIP", "1", TRUE);
- /* Set a custom user directory (optional) */
- purple_util_set_user_dir(TEST_DATA_DIR);
/* We do not want any debugging for now to keep the noise to a minimum. */
purple_debug_set_enabled(FALSE);
@@ -104,11 +128,11 @@
- /* Set path to search for plugins. The core (libpurple) takes care of loading the
- * core-plugins, which includes the in-tree protocols. So it is not essential to add
- * any path here, but it might be desired, especially for ui-specific plugins. */
- purple_plugins_add_search_path(TEST_DATA_DIR);
- purple_plugins_refresh();
+ if(!test_ui_init_history(&error)) { + g_critical("failed to initialize the history api: %s", + error ? error->message : "unknown"); /* Load the preferences. */
--- a/pidgin/libpidgin.c Mon Oct 18 01:51:02 2021 -0500
+++ b/pidgin/libpidgin.c Mon Oct 18 02:01:37 2021 -0500
@@ -190,11 +190,46 @@
purple_debug_set_ui(PURPLE_DEBUG_UI(ui));
+pidgin_history_init(GError **error) { + PurpleHistoryManager *manager = NULL; + PurpleHistoryAdapter *adapter = NULL; + gchar *filename = NULL; + const gchar *id = NULL; + manager = purple_history_manager_get_default(); + /* Attempt to create the config_dir. We don't care about the result as the + * logging adapter will fail with a better error than us failing to create + g_mkdir_with_parents(purple_config_dir(), 0700); + filename = g_build_filename(purple_config_dir(), "history.db", NULL); + adapter = purple_sqlite_history_adapter_new(filename); + id = purple_history_adapter_get_id(adapter); + if(!purple_history_manager_register(manager, adapter, error)) { + g_clear_object(&adapter); + /* The manager adds a ref to the adapter on registration, so we can remove + g_clear_object(&adapter); + return purple_history_manager_set_active(manager, id, error); PurpleProtocolManager *protocol_manager = NULL;
GtkIconTheme *theme = NULL;
theme = gtk_icon_theme_get_default();
@@ -216,6 +251,12 @@
purple_protocol_manager_foreach(protocol_manager,
purple_ui_protocol_foreach_theme_cb, NULL);
+ if(!pidgin_history_init(&error)) { + g_critical("failed to initialize the history api: %s", + error != NULL ? error->message : "unknown"); /* Set the UI operation structures. */