/soc/2013/ankitkv/gobjectification: a1d2fa3be516: Use g_object_[...

Ankit Vani a at nevitus.org
Mon Sep 16 13:32:33 EDT 2013


Changeset: a1d2fa3be516ad22096bbd8d019c4dcb43881f59
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-09-16 23:02 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/a1d2fa3be516

Description:

Use g_object_[sg]et_data in joinpart

diffstat:

 libpurple/plugins/joinpart.c |  13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diffs (45 lines):

diff --git a/libpurple/plugins/joinpart.c b/libpurple/plugins/joinpart.c
--- a/libpurple/plugins/joinpart.c
+++ b/libpurple/plugins/joinpart.c
@@ -51,10 +51,6 @@ struct joinpart_key
 	char *user;
 };
 
-static GHashTable *users;
-static guint id;
-
-
 static guint joinpart_key_hash(const struct joinpart_key *key)
 {
 	g_return_val_if_fail(key != NULL, 0);
@@ -236,6 +232,8 @@ plugin_query(GError **error)
 static gboolean plugin_load(PurplePlugin *plugin, GError **error)
 {
 	void *conv_handle;
+	GHashTable *users;
+	guint id;
 
 	purple_prefs_add_none("/plugins/core/joinpart");
 
@@ -259,6 +257,9 @@ static gboolean plugin_load(PurplePlugin
 	/* Cleanup every 5 minutes */
 	id = purple_timeout_add_seconds(60 * 5, (GSourceFunc)clean_users_hash, users);
 
+	g_object_set_data(G_OBJECT(plugin), "users", users);
+	g_object_set_data(G_OBJECT(plugin), "id", GUINT_TO_POINTER(id));
+
 	return TRUE;
 }
 
@@ -267,9 +268,9 @@ static gboolean plugin_unload(PurplePlug
 	/* Destroy the hash table. The core plugin code will
 	 * disconnect the signals, and since Purple is single-threaded,
 	 * we don't have to worry one will be called after this. */
-	g_hash_table_destroy(users);
+	g_hash_table_destroy((GHashTable *)g_object_get_data(G_OBJECT(plugin), "users"));
 
-	purple_timeout_remove(id);
+	purple_timeout_remove(GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(plugin), "id")));
 
 	return TRUE;
 }



More information about the Commits mailing list