/soc/2013/ankitkv/gobjectification: dfce617913fe: Refactored key...
Ankit Vani
a at nevitus.org
Sat Aug 10 19:26:43 EDT 2013
Changeset: dfce617913fe08b003360940c310fddfea6a20dd
Author: Ankit Vani <a at nevitus.org>
Date: 2013-08-11 04:56 +0530
Branch: soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/dfce617913fe
Description:
Refactored keyrings to use the new API
diffstat:
libpurple/plugins/keyrings/gnomekeyring.c | 61 ++++++++-----------
libpurple/plugins/keyrings/internalkeyring.c | 82 ++++++++++++---------------
libpurple/plugins/keyrings/kwallet.cpp | 60 ++++++++-----------
libpurple/plugins/keyrings/secretservice.c | 71 +++++++++--------------
libpurple/plugins/keyrings/wincred.c | 59 ++++++++-----------
5 files changed, 140 insertions(+), 193 deletions(-)
diffs (truncated from 504 to 300 lines):
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
@@ -39,6 +39,7 @@
"GNOME Keyring.")
#define GNOMEKEYRING_AUTHOR "Tomek Wasilczyk (tomkiewicz at cpw.pidgin.im)"
#define GNOMEKEYRING_ID "keyring-gnomekeyring"
+#define GNOMEKEYRING_DOMAIN (g_quark_from_static_string(GNOMEKEYRING_ID))
static PurpleKeyring *keyring_handler = NULL;
static GList *request_queue = NULL;
@@ -377,10 +378,30 @@ gnomekeyring_close(void)
gnomekeyring_cancel();
}
+static PurplePluginInfo *
+plugin_query(GError **error)
+{
+ return purple_plugin_info_new(
+ "id", GNOMEKEYRING_ID,
+ "name", GNOMEKEYRING_NAME,
+ "version", DISPLAY_VERSION,
+ "category", N_("Keyring"),
+ "summary", "GNOME Keyring Plugin",
+ "description", GNOMEKEYRING_DESCRIPTION,
+ "author", GNOMEKEYRING_AUTHOR,
+ "website", PURPLE_WEBSITE,
+ "purple-abi", PURPLE_ABI_VERSION,
+ "flags", GPLUGIN_PLUGIN_INFO_FLAGS_INTERNAL,
+ NULL
+ );
+}
+
static gboolean
-gnomekeyring_load(PurplePlugin *plugin)
+plugin_load(PurplePlugin *plugin, GError **error)
{
if (!gnome_keyring_is_available()) {
+ g_set_error(error, GNOMEKEYRING_DOMAIN, 0, "GNOME Keyring service is "
+ "disabled.");
purple_debug_info("keyring-gnome", "GNOME Keyring service is "
"disabled\n");
return FALSE;
@@ -402,9 +423,11 @@ gnomekeyring_load(PurplePlugin *plugin)
}
static gboolean
-gnomekeyring_unload(PurplePlugin *plugin)
+plugin_unload(PurplePlugin *plugin, GError **error)
{
if (purple_keyring_get_inuse() == keyring_handler) {
+ g_set_error(error, GNOMEKEYRING_DOMAIN, 0, "The keyring is currently "
+ "in use.");
purple_debug_warning("keyring-gnome",
"keyring in use, cannot unload\n");
return FALSE;
@@ -419,36 +442,4 @@ gnomekeyring_unload(PurplePlugin *plugin
return TRUE;
}
-PurplePluginInfo plugininfo =
-{
- PURPLE_PLUGIN_MAGIC, /* magic */
- PURPLE_MAJOR_VERSION, /* major_version */
- PURPLE_MINOR_VERSION, /* minor_version */
- PURPLE_PLUGIN_STANDARD, /* type */
- NULL, /* ui_requirement */
- PURPLE_PLUGIN_FLAG_INVISIBLE, /* flags */
- NULL, /* dependencies */
- PURPLE_PRIORITY_DEFAULT, /* priority */
- GNOMEKEYRING_ID, /* id */
- GNOMEKEYRING_NAME, /* name */
- DISPLAY_VERSION, /* version */
- "GNOME Keyring Plugin", /* summary */
- GNOMEKEYRING_DESCRIPTION, /* description */
- GNOMEKEYRING_AUTHOR, /* author */
- PURPLE_WEBSITE, /* homepage */
- gnomekeyring_load, /* load */
- gnomekeyring_unload, /* unload */
- NULL, /* destroy */
- NULL, /* ui_info */
- NULL, /* extra_info */
- NULL, /* prefs_info */
- NULL, /* actions */
- NULL, NULL, NULL, NULL /* padding */
-};
-
-static void
-init_plugin(PurplePlugin *plugin)
-{
-}
-
-PURPLE_INIT_PLUGIN(gnome_keyring, init_plugin, plugininfo)
+PURPLE_PLUGIN_INIT(gnome_keyring, plugin_query, plugin_load, plugin_unload);
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
@@ -40,6 +40,7 @@
"storage behaviour for libpurple.")
#define INTKEYRING_AUTHOR "Tomek Wasilczyk (tomkiewicz at cpw.pidgin.im)"
#define INTKEYRING_ID PURPLE_DEFAULT_KEYRING
+#define INTKEYRING_DOMAIN (g_quark_from_static_string(INTKEYRING_ID))
#define INTKEYRING_VERIFY_STR "[verification-string]"
#define INTKEYRING_PBKDF2_ITERATIONS 10000
@@ -954,9 +955,39 @@ intkeyring_apply_settings(void *notify_h
return TRUE;
}
+static PurplePluginInfo *
+plugin_query(GError **error)
+{
+ return purple_plugin_info_new(
+ "id", INTKEYRING_ID,
+ "name", INTKEYRING_NAME,
+ "version", DISPLAY_VERSION,
+ "category", N_("Keyring"),
+ "summary", "Internal Keyring Plugin",
+ "description", INTKEYRING_DESCRIPTION,
+ "author", INTKEYRING_AUTHOR,
+ "website", PURPLE_WEBSITE,
+ "purple-abi", PURPLE_ABI_VERSION,
+ "flags", GPLUGIN_PLUGIN_INFO_FLAGS_INTERNAL,
+ NULL
+ );
+}
+
static gboolean
-intkeyring_load(PurplePlugin *plugin)
+plugin_load(PurplePlugin *plugin, GError **error)
{
+ purple_prefs_add_none("/plugins/keyrings");
+ purple_prefs_add_none("/plugins/keyrings/internal");
+ purple_prefs_add_bool(INTKEYRING_PREFS "encrypt_passwords", FALSE);
+ purple_prefs_add_string(INTKEYRING_PREFS "encryption_method",
+ INTKEYRING_ENCRYPTION_METHOD);
+ purple_prefs_add_int(INTKEYRING_PREFS "pbkdf2_desired_iterations",
+ INTKEYRING_PBKDF2_ITERATIONS);
+ purple_prefs_add_int(INTKEYRING_PREFS "pbkdf2_iterations",
+ INTKEYRING_PBKDF2_ITERATIONS);
+ purple_prefs_add_string(INTKEYRING_PREFS "pbkdf2_salt", "");
+ purple_prefs_add_string(INTKEYRING_PREFS "key_verifier", "");
+
keyring_handler = purple_keyring_new();
purple_keyring_set_name(keyring_handler, _(INTKEYRING_NAME));
@@ -982,9 +1013,11 @@ intkeyring_load(PurplePlugin *plugin)
}
static gboolean
-intkeyring_unload(PurplePlugin *plugin)
+plugin_unload(PurplePlugin *plugin, GError **error)
{
if (purple_keyring_get_inuse() == keyring_handler) {
+ g_set_error(error, INTKEYRING_DOMAIN, 0, "The keyring is currently "
+ "in use.");
purple_debug_warning("keyring-internal",
"keyring in use, cannot unload\n");
return FALSE;
@@ -1006,47 +1039,4 @@ intkeyring_unload(PurplePlugin *plugin)
return TRUE;
}
-PurplePluginInfo plugininfo =
-{
- PURPLE_PLUGIN_MAGIC, /* magic */
- PURPLE_MAJOR_VERSION, /* major_version */
- PURPLE_MINOR_VERSION, /* minor_version */
- PURPLE_PLUGIN_STANDARD, /* type */
- NULL, /* ui_requirement */
- PURPLE_PLUGIN_FLAG_INVISIBLE, /* flags */
- NULL, /* dependencies */
- PURPLE_PRIORITY_DEFAULT, /* priority */
- INTKEYRING_ID, /* id */
- INTKEYRING_NAME, /* name */
- DISPLAY_VERSION, /* version */
- "Internal Keyring Plugin", /* summary */
- INTKEYRING_DESCRIPTION, /* description */
- INTKEYRING_AUTHOR, /* author */
- PURPLE_WEBSITE, /* homepage */
- intkeyring_load, /* load */
- intkeyring_unload, /* unload */
- NULL, /* destroy */
- NULL, /* ui_info */
- NULL, /* extra_info */
- NULL, /* prefs_info */
- NULL, /* actions */
- NULL, NULL, NULL, NULL /* padding */
-};
-
-static void
-init_plugin(PurplePlugin *plugin)
-{
- purple_prefs_add_none("/plugins/keyrings");
- purple_prefs_add_none("/plugins/keyrings/internal");
- purple_prefs_add_bool(INTKEYRING_PREFS "encrypt_passwords", FALSE);
- purple_prefs_add_string(INTKEYRING_PREFS "encryption_method",
- INTKEYRING_ENCRYPTION_METHOD);
- purple_prefs_add_int(INTKEYRING_PREFS "pbkdf2_desired_iterations",
- INTKEYRING_PBKDF2_ITERATIONS);
- purple_prefs_add_int(INTKEYRING_PREFS "pbkdf2_iterations",
- INTKEYRING_PBKDF2_ITERATIONS);
- purple_prefs_add_string(INTKEYRING_PREFS "pbkdf2_salt", "");
- purple_prefs_add_string(INTKEYRING_PREFS "key_verifier", "");
-}
-
-PURPLE_INIT_PLUGIN(internal_keyring, init_plugin, plugininfo)
+PURPLE_PLUGIN_INIT(gnome_keyring, plugin_query, plugin_load, plugin_unload);
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
@@ -40,6 +40,7 @@
#define KWALLET_DESCRIPTION N_("This plugin will store passwords in KWallet.")
#define KWALLET_AUTHOR "QuLogic (qulogic[at]pidgin.im)"
#define KWALLET_ID "keyring-kwallet"
+#define KWALLET_DOMAIN (g_quark_from_static_string(KWALLET_ID))
#define KWALLET_WALLET_NAME KWallet::Wallet::NetworkWallet()
#define KWALLET_APP_NAME "Libpurple"
@@ -488,8 +489,26 @@ static const char *kwallet_get_ui_name(v
return ui_name;
}
+static PurplePluginInfo *
+plugin_query(GError **error)
+{
+ return purple_plugin_info_new(
+ "id", KWALLET_ID,
+ "name", KWALLET_NAME,
+ "version", DISPLAY_VERSION,
+ "category", N_("Keyring"),
+ "summary", "KWallet Keyring Plugin",
+ "description", KWALLET_DESCRIPTION,
+ "author", KWALLET_AUTHOR,
+ "website", PURPLE_WEBSITE,
+ "purple-abi", PURPLE_ABI_VERSION,
+ "flags", GPLUGIN_PLUGIN_INFO_FLAGS_INTERNAL,
+ NULL
+ );
+}
+
static gboolean
-kwallet_load(PurplePlugin *plugin)
+plugin_load(PurplePlugin *plugin, GError **error)
{
if (!qCoreApp) {
int argc = 0;
@@ -498,6 +517,7 @@ kwallet_load(PurplePlugin *plugin)
}
if (!kwallet_is_enabled()) {
+ g_set_error(error, KWALLET_DOMAIN, 0, "KWallet service is disabled.");
purple_debug_info("keyring-kwallet",
"KWallet service is disabled\n");
return FALSE;
@@ -519,9 +539,11 @@ kwallet_load(PurplePlugin *plugin)
}
static gboolean
-kwallet_unload(PurplePlugin *plugin)
+plugin_unload(PurplePlugin *plugin, GError **error)
{
if (purple_keyring_get_inuse() == keyring_handler) {
+ g_set_error(error, KWALLET_DOMAIN, 0, "The keyring is currently "
+ "in use.");
purple_debug_warning("keyring-kwallet",
"keyring in use, cannot unload\n");
return FALSE;
@@ -543,39 +565,7 @@ kwallet_unload(PurplePlugin *plugin)
return TRUE;
}
-PurplePluginInfo plugininfo =
-{
- PURPLE_PLUGIN_MAGIC, /* magic */
- PURPLE_MAJOR_VERSION, /* major_version */
- PURPLE_MINOR_VERSION, /* minor_version */
- PURPLE_PLUGIN_STANDARD, /* type */
- NULL, /* ui_requirement */
- PURPLE_PLUGIN_FLAG_INVISIBLE, /* flags */
- NULL, /* dependencies */
- PURPLE_PRIORITY_DEFAULT, /* priority */
- KWALLET_ID, /* id */
- KWALLET_NAME, /* name */
- DISPLAY_VERSION, /* version */
- "KWallet Keyring Plugin", /* summary */
- KWALLET_DESCRIPTION, /* description */
- KWALLET_AUTHOR, /* author */
- PURPLE_WEBSITE, /* homepage */
- kwallet_load, /* load */
- kwallet_unload, /* unload */
- NULL, /* destroy */
- NULL, /* ui_info */
- NULL, /* extra_info */
- NULL, /* prefs_info */
- NULL, /* actions */
- NULL, NULL, NULL, NULL /* padding */
-};
-
-static void
More information about the Commits
mailing list