--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/plugins/joinpart/im.pidgin.Purple.plugin.JoinPart.gschema.xml Mon Sep 12 10:01:28 2022 -0500
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?> + <schema path="/plugins/joinpart/" id="im.pidgin.Purple.plugin.JoinPart"> + <key name="threshold" type="i"> + <range min="0" max="1000"/> + <summary>Room size threshold</summary> + The number of people that must be in a room for this plugin to have any + <key name="delay" type="i"> + <range min="0" max="480"/><!-- 8 hours maximum --> + <summary>Delay</summary> + The number of minutes before a person is considered to have stopped + being part of active conversation. + <key name="hide-buddies" type="b"> + <default>false</default> + <summary>Hide buddies</summary> + Whether to apply hiding rules to buddies also. --- a/libpurple/plugins/joinpart/joinpart.c Mon Sep 12 05:08:59 2022 -0500
+++ b/libpurple/plugins/joinpart/joinpart.c Mon Sep 12 10:01:28 2022 -0500
@@ -31,20 +31,18 @@
+#define SETTINGS_SCHEMA_ID "im.pidgin.Purple.plugin.JoinPart" -/* The number of minutes before a person is considered
- * to have stopped being part of active conversation. */
-#define DELAY_PREF "/plugins/core/joinpart/delay"
-#define DELAY_DEFAULT 10
+/* The number of minutes before a person is considered to have stopped being + * part of active conversation. */ +#define DELAY_PREF "delay" -/* The number of people that must be in a room for this
- * plugin to have any effect */
-#define THRESHOLD_PREF "/plugins/core/joinpart/threshold"
-#define THRESHOLD_DEFAULT 20
+/* The number of people that must be in a room for this plugin to have any +#define THRESHOLD_PREF "threshold" -#define HIDE_BUDDIES_PREF "/plugins/core/joinpart/hide_buddies"
-#define HIDE_BUDDIES_DEFAULT FALSE
+#define HIDE_BUDDIES_PREF "hide-buddies" @@ -61,10 +59,11 @@
static gboolean joinpart_key_equal(const struct joinpart_key *a, const struct joinpart_key *b)
+ } else if (b == NULL) { return (a->conv == b->conv) && purple_strequal(a->user, b->user);
@@ -80,6 +79,7 @@
static gboolean should_hide_notice(PurpleConversation *conv, const char *name,
+ GSettings *settings = NULL; PurpleChatConversation *chat;
@@ -88,27 +88,37 @@
g_return_val_if_fail(conv != NULL, FALSE);
g_return_val_if_fail(PURPLE_IS_CHAT_CONVERSATION(conv), FALSE);
+ settings = g_settings_new_with_backend(SETTINGS_SCHEMA_ID, + purple_core_get_settings_backend()); /* If the room is small, don't bother. */
chat = PURPLE_CHAT_CONVERSATION(conv);
- threshold = purple_prefs_get_int(THRESHOLD_PREF);
- if (purple_chat_conversation_get_users_count(chat) < threshold)
+ threshold = g_settings_get_int(settings, THRESHOLD_PREF); + if (purple_chat_conversation_get_users_count(chat) < threshold) { + g_object_unref(settings); - if (!purple_prefs_get_bool(HIDE_BUDDIES_PREF) &&
- purple_blist_find_buddy(purple_conversation_get_account(conv), name))
+ if (!g_settings_get_boolean(settings, HIDE_BUDDIES_PREF) && + purple_blist_find_buddy(purple_conversation_get_account(conv), name)) { + g_object_unref(settings); /* Only show the notice if the user has spoken recently. */
key.user = (gchar *)name;
last_said = g_hash_table_lookup(users, &key);
- int delay = purple_prefs_get_int(DELAY_PREF);
- if (delay > 0 && (*last_said + (delay * 60)) >= time(NULL))
+ if (last_said != NULL) { + int delay = g_settings_get_int(settings, DELAY_PREF); + if (delay > 0 && (*last_said + (delay * 60)) >= time(NULL)) { + g_object_unref(settings); + g_object_unref(settings); @@ -137,13 +147,10 @@
last_said = g_hash_table_lookup(users, &key);
+ if (last_said != NULL) { /* They just said something, so update the time. */
struct joinpart_key *key2;
key2 = g_new(struct joinpart_key, 1);
@@ -166,8 +173,16 @@
static gboolean clean_users_hash(GHashTable *users)
- int delay = purple_prefs_get_int(DELAY_PREF);
- time_t limit = time(NULL) - (60 * delay);
+ GSettings *settings = NULL; + settings = g_settings_new_with_backend(SETTINGS_SCHEMA_ID, + purple_core_get_settings_backend()); + delay = g_settings_get_int(settings, DELAY_PREF); + g_object_unref(settings); + limit = time(NULL) - (60 * delay); g_hash_table_foreach_remove(users, (GHRFunc)check_expire_time, &limit);
@@ -237,12 +252,6 @@
- purple_prefs_add_none("/plugins/core/joinpart");
- purple_prefs_add_int(DELAY_PREF, DELAY_DEFAULT);
- purple_prefs_add_int(THRESHOLD_PREF, THRESHOLD_DEFAULT);
- purple_prefs_add_bool(HIDE_BUDDIES_PREF, HIDE_BUDDIES_DEFAULT);
users = g_hash_table_new_full((GHashFunc)joinpart_key_hash,
(GEqualFunc)joinpart_key_equal,
(GDestroyNotify)joinpart_key_destroy,
--- a/libpurple/plugins/joinpart/meson.build Mon Sep 12 05:08:59 2022 -0500
+++ b/libpurple/plugins/joinpart/meson.build Mon Sep 12 10:01:28 2022 -0500
@@ -4,4 +4,14 @@
install : true, install_dir : PURPLE_PLUGINDIR)
+ 'im.pidgin.Purple.plugin.JoinPart.gschema.xml', +install_data(settings_schemas, install_dir: schemas_dir) +gnome.post_install(glib_compile_schemas: true) +# Compile the schemas in the current directory; this is only useful for testing +gnome.compile_schemas(depend_files: files(settings_schemas)) devenv.append('PURPLE_PLUGIN_PATH', meson.current_build_dir())