/cpw/tomkiewicz/masterpassword: 825c98f8c7f6: Get rid of PURPLE_...

Tomasz Wasilczyk tomkiewicz at cpw.pidgin.im
Mon Mar 18 17:22:03 EDT 2013


Changeset: 825c98f8c7f603217b5a2124c9cbef63aa203b5c
Author:	 Tomasz Wasilczyk <tomkiewicz at cpw.pidgin.im>
Date:	 2013-03-18 22:21 +0100
Branch:	 soc.2008.masterpassword
URL: https://hg.pidgin.im/cpw/tomkiewicz/masterpassword/rev/825c98f8c7f6

Description:

Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD

diffstat:

 libpurple/core.c                             |   2 +
 libpurple/keyring.c                          |  45 +++++++++++++++++++++++++--
 libpurple/keyring.h                          |   5 +++
 libpurple/plugin.c                           |   6 ---
 libpurple/plugin.h                           |   1 -
 libpurple/plugins/keyrings/gnomekeyring.c    |   3 +-
 libpurple/plugins/keyrings/internalkeyring.c |   3 +-
 libpurple/plugins/keyrings/kwallet.cpp       |   6 +--
 libpurple/plugins/keyrings/secretservice.c   |   3 +-
 9 files changed, 53 insertions(+), 21 deletions(-)

diffs (237 lines):

diff --git a/libpurple/core.c b/libpurple/core.c
--- a/libpurple/core.c
+++ b/libpurple/core.c
@@ -148,6 +148,7 @@ purple_core_init(const char *ui)
 
 	purple_plugins_probe(G_MODULE_SUFFIX);
 
+	purple_keyring_load_plugins();
 	purple_theme_manager_init();
 
 	/* The buddy icon code uses the imgstore, so init it early. */
@@ -221,6 +222,7 @@ purple_core_quit(void)
 
 	/* The SSL plugins must be uninit before they're unloaded */
 	purple_ssl_uninit();
+	purple_keyring_uninit();
 
 	/* Unload all non-loader, non-prpl plugins before shutting down
 	 * subsystems. */
diff --git a/libpurple/keyring.c b/libpurple/keyring.c
--- a/libpurple/keyring.c
+++ b/libpurple/keyring.c
@@ -232,6 +232,7 @@ static GList *purple_keyring_keyrings;  
 static const PurpleKeyring *purple_keyring_inuse;   /* keyring being used         */
 static char *purple_keyring_to_use;
 static guint purple_keyring_pref_cb_id;
+static GList *purple_keyring_loaded_plugins = NULL;
 
 static void
 purple_keyring_pref_cb(const char *pref,
@@ -251,6 +252,30 @@ purple_keyring_pref_cb(const char *pref,
 	purple_keyring_set_inuse(new, FALSE, NULL, data);
 }
 
+void purple_keyring_load_plugins(void)
+{
+	GList *it;
+
+	for (it = purple_plugins_get_all(); it != NULL; it = it->next)
+	{
+		PurplePlugin *plugin = (PurplePlugin *)it->data;
+
+		if (plugin->info == NULL || plugin->info->id == NULL)
+			continue;
+		if (strncmp(plugin->info->id, "keyring-", 8) != 0)
+			continue;
+
+		if (purple_plugin_is_loaded(plugin))
+			continue;
+
+		if (purple_plugin_load(plugin))
+		{
+			purple_keyring_loaded_plugins = g_list_append(
+				purple_keyring_loaded_plugins, plugin);
+		}
+	}
+}
+
 void
 purple_keyring_init(void)
 {
@@ -297,8 +322,20 @@ purple_keyring_init(void)
 void
 purple_keyring_uninit(void)
 {
+	GList *it;
+
 	g_free(purple_keyring_to_use);
-	purple_debug_info("keyring", "purple_keyring_uninit() done.\n");
+
+	for (it = g_list_first(purple_keyring_loaded_plugins); it != NULL;
+		it = g_list_next(it))
+	{
+		PurplePlugin *plugin = (PurplePlugin *)it->data;
+		if (g_list_find(purple_plugins_get_loaded(), plugin) == NULL)
+			continue;
+		purple_plugin_unload(plugin);
+	}
+	g_list_free(purple_keyring_loaded_plugins);
+	purple_keyring_loaded_plugins = NULL;
 }
 
 PurpleKeyring *
@@ -791,7 +828,7 @@ purple_keyring_get_password(PurpleAccoun
 	PurpleKeyringRead read;
 
 	if (account == NULL) {
-		purple_debug_error("keyring", "No account passed to the function.");
+		purple_debug_error("keyring", "No account passed to the function.\n");
 		error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_INVALID,
 			"No account passed to the function.");
 
@@ -804,7 +841,7 @@ purple_keyring_get_password(PurpleAccoun
 		inuse = purple_keyring_get_inuse();
 
 		if (inuse == NULL) {
-			purple_debug_error("keyring", "No keyring configured.");
+			purple_debug_error("keyring", "No keyring configured.\n");
 			error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_NOKEYRING,
 				"No keyring configured.");
 
@@ -817,7 +854,7 @@ purple_keyring_get_password(PurpleAccoun
 			read = purple_keyring_get_read_password(inuse);
 
 			if (read == NULL) {
-				purple_debug_warning("keyring", "Keyring cannot read password.");
+				purple_debug_warning("keyring", "Keyring cannot read password.\n");
 				error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_NOCAP,
 					"Keyring cannot read password.");
 
diff --git a/libpurple/keyring.h b/libpurple/keyring.h
--- a/libpurple/keyring.h
+++ b/libpurple/keyring.h
@@ -227,6 +227,11 @@ PurpleKeyring *purple_keyring_find_keyri
 GList *purple_keyring_get_options(void);
 
 /**
+ * Load keyring plugins.
+ */
+void purple_keyring_load_plugins(void);
+
+/**
  * Prepare stuff at startup.
  */
 void purple_keyring_init(void);
diff --git a/libpurple/plugin.c b/libpurple/plugin.c
--- a/libpurple/plugin.c
+++ b/libpurple/plugin.c
@@ -477,12 +477,6 @@ purple_plugin_probe(const char *filename
 		}
 	}
 
-	if (plugin->info->flags & PURPLE_PLUGIN_FLAG_AUTOLOAD) {
-		purple_debug_info("plugins", "Loading autoload plugin %s\n",
-						plugin->path);
-		purple_plugin_load(plugin);
-	}
-
 	return plugin;
 #else
 	return NULL;
diff --git a/libpurple/plugin.h b/libpurple/plugin.h
--- a/libpurple/plugin.h
+++ b/libpurple/plugin.h
@@ -67,7 +67,6 @@ typedef enum
 #define PURPLE_PRIORITY_LOWEST  -9999
 
 #define PURPLE_PLUGIN_FLAG_INVISIBLE 0x01
-#define PURPLE_PLUGIN_FLAG_AUTOLOAD  0x02
 
 #define PURPLE_PLUGIN_MAGIC 5 /* once we hit 6.0.0 I think we can remove this */
 
diff --git a/libpurple/plugins/keyrings/gnomekeyring.c b/libpurple/plugins/keyrings/gnomekeyring.c
--- a/libpurple/plugins/keyrings/gnomekeyring.c
+++ b/libpurple/plugins/keyrings/gnomekeyring.c
@@ -361,7 +361,7 @@ PurplePluginInfo plugininfo =
 	PURPLE_MINOR_VERSION,		/* minor_version */
 	PURPLE_PLUGIN_STANDARD,		/* type */
 	NULL,						/* ui_requirement */
-	PURPLE_PLUGIN_FLAG_INVISIBLE|PURPLE_PLUGIN_FLAG_AUTOLOAD,	/* flags */
+	PURPLE_PLUGIN_FLAG_INVISIBLE,	/* flags */
 	NULL,						/* dependencies */
 	PURPLE_PRIORITY_DEFAULT,	/* priority */
 	GNOMEKEYRING_ID,			/* id */
@@ -387,7 +387,6 @@ PurplePluginInfo plugininfo =
 static void
 init_plugin(PurplePlugin *plugin)
 {
-	purple_debug_info("keyring-gnome", "Init plugin called.\n");
 }
 
 PURPLE_INIT_PLUGIN(gnome_keyring, init_plugin, plugininfo)
diff --git a/libpurple/plugins/keyrings/internalkeyring.c b/libpurple/plugins/keyrings/internalkeyring.c
--- a/libpurple/plugins/keyrings/internalkeyring.c
+++ b/libpurple/plugins/keyrings/internalkeyring.c
@@ -229,7 +229,7 @@ PurplePluginInfo plugininfo =
 	PURPLE_MINOR_VERSION,				/* minor_version */
 	PURPLE_PLUGIN_STANDARD,				/* type */
 	NULL,								/* ui_requirement */
-	PURPLE_PLUGIN_FLAG_INVISIBLE|PURPLE_PLUGIN_FLAG_AUTOLOAD,	/* flags */
+	PURPLE_PLUGIN_FLAG_INVISIBLE,	/* flags */
 	NULL,								/* dependencies */
 	PURPLE_PRIORITY_DEFAULT,			/* priority */
 	INTERNALKEYRING_ID,					/* id */
@@ -255,7 +255,6 @@ PurplePluginInfo plugininfo =
 static void
 init_plugin(PurplePlugin *plugin)
 {
-	purple_debug_info("keyring-internal", "Init plugin called.\n");
 }
 
 PURPLE_INIT_PLUGIN(internal_keyring, init_plugin, plugininfo)
diff --git a/libpurple/plugins/keyrings/kwallet.cpp b/libpurple/plugins/keyrings/kwallet.cpp
--- a/libpurple/plugins/keyrings/kwallet.cpp
+++ b/libpurple/plugins/keyrings/kwallet.cpp
@@ -399,7 +399,7 @@ PurplePluginInfo plugininfo =
 	PURPLE_MINOR_VERSION,				/* minor_version */
 	PURPLE_PLUGIN_STANDARD,				/* type */
 	NULL,								/* ui_requirement */
-	PURPLE_PLUGIN_FLAG_INVISIBLE|PURPLE_PLUGIN_FLAG_AUTOLOAD,	/* flags */
+	PURPLE_PLUGIN_FLAG_INVISIBLE,	/* flags */
 	NULL,								/* dependencies */
 	PURPLE_PRIORITY_DEFAULT,			/* priority */
 	(char*)KWALLET_ID,							/* id */
@@ -422,11 +422,9 @@ PurplePluginInfo plugininfo =
 	NULL,
 };
 
-void init_plugin(PurplePlugin *plugin);
-void
+static void
 init_plugin(PurplePlugin *plugin)
 {
-	purple_debug_info("keyring-kwallet", "init plugin called.\n");
 }
 
 PURPLE_INIT_PLUGIN(kwallet_keyring, init_plugin, plugininfo)
diff --git a/libpurple/plugins/keyrings/secretservice.c b/libpurple/plugins/keyrings/secretservice.c
--- a/libpurple/plugins/keyrings/secretservice.c
+++ b/libpurple/plugins/keyrings/secretservice.c
@@ -327,7 +327,7 @@ PurplePluginInfo plugininfo =
 	PURPLE_MINOR_VERSION,		/* minor_version */
 	PURPLE_PLUGIN_STANDARD,		/* type */
 	NULL,						/* ui_requirement */
-	PURPLE_PLUGIN_FLAG_INVISIBLE|PURPLE_PLUGIN_FLAG_AUTOLOAD,	/* flags */
+	PURPLE_PLUGIN_FLAG_INVISIBLE,	/* flags */
 	NULL,						/* dependencies */
 	PURPLE_PRIORITY_DEFAULT,	/* priority */
 	SECRETSERVICE_ID,			/* id */
@@ -353,7 +353,6 @@ PurplePluginInfo plugininfo =
 static void
 init_plugin(PurplePlugin *plugin)
 {
-	purple_debug_info("keyring-libsecret", "Init plugin called.\n");
 }
 
 PURPLE_INIT_PLUGIN(secret_service, init_plugin, plugininfo)



More information about the Commits mailing list