Недавно был пост о том что пароли хранятся в открытом виде:
libpurple # diff -rup account.c_orig account.c
--- account.c_orig 2010-01-15 13:57:27.000000000 +0300
+++ account.c 2010-01-15 16:36:38.000000000 +0300
@@ -41,11 +41,25 @@
#include «util.h»
#include «xmlnode.h»
+#include <gnome-keyring.h>
+
typedef struct
{
PurpleConnectionErrorInfo *current_error;
} PurpleAccountPrivate;
+
+GnomeKeyringPasswordSchema pidgin_schema = {
+ GNOME_KEYRING_ITEM_GENERIC_SECRET,
+ {
+ { «pidgin account», GNOME_KEYRING_ATTRIBUTE_TYPE_STRING },
+ { NULL, 0 }
+ },
+ NULL,
+ NULL,
+ NULL
+};
+
#define PURPLE_ACCOUNT_GET_PRIVATE(account) \
((PurpleAccountPrivate *) (account->priv))
@@ -377,9 +391,18 @@ account_to_xmlnode(PurpleAccount *accoun
if (purple_account_get_remember_password(account) &&
((tmp = purple_account_get_password(account)) != NULL))
- {
- child = xmlnode_new_child(node, «password»);
- xmlnode_insert_data(child, tmp, -1);
+ {
+ if (purple_account_get_use_wallet(account))
+ {
+ child = xmlnode_new_child(node, «wallet»);
+ xmlnode_insert_data(child, «1», -1);
+ gnome_keyring_store_password_sync(&pidgin_schema,NULL,purple_account_get_username(account),tmp,«pidgin account»,purple_account_get_username(account),NULL);
+ }
+ else
+ {
+ child = xmlnode_new_child(node, «password»);
+ xmlnode_insert_data(child, tmp, -1);
+ }
}
if ((tmp = purple_account_get_alias(account)) != NULL)
@@ -804,6 +827,9 @@ parse_account(xmlnode *node)
char *protocol_id = NULL;
char *name = NULL;
char *data;
+
+ char *passwd;
child = xmlnode_get_child(node, «protocol»);
if (child != NULL)
@@ -832,12 +858,43 @@ parse_account(xmlnode *node)
g_free(protocol_id);
/* Read the password */
- child = xmlnode_get_child(node, «password»);
+ child = xmlnode_get_child(node, «wallet»);
if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL))
{
- purple_account_set_remember_password(ret, TRUE);
- purple_account_set_password(ret, data);
- g_free(data);
+ if (strcmp(data,«1») == 0)
+ {
+ /* enabled waallet password storage */
+ purple_account_set_use_wallet(ret, TRUE);
+ if (gnome_keyring_find_password_sync(&pidgin_schema,&passwd,«pidgin account»,purple_account_get_username(ret),NULL) == GNOME_KEYRING_RESULT_OK)
+ {
+ purple_account_set_remember_password(ret, TRUE);
+ purple_account_set_password(ret, passwd);
+ gnome_keyring_free_password(passwd);
+ }
+ }
+ else
+ {
+ purple_account_set_use_wallet(ret, FALSE);
+ g_free(data);
+ child = xmlnode_get_child(node, «password»);
+ if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL))
+ {
+ purple_account_set_remember_password(ret, TRUE);
+ purple_account_set_password(ret, data);
+ g_free(data);
+ }
+ }
+ }
+ else
+ {
+ purple_account_set_use_wallet(ret, FALSE);
+ child = xmlnode_get_child(node, «password»);
+ if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL))
+ {
+ purple_account_set_remember_password(ret, TRUE);
+ purple_account_set_password(ret, data);
+ g_free(data);
+ }
}
/* Read the alias */
@@ -2890,3 +2947,21 @@ purple_accounts_uninit(void)
purple_signals_disconnect_by_handle(handle);
purple_signals_unregister_by_instance(handle);
}
+
+void
+purple_account_set_use_wallet(PurpleAccount *account, gboolean value)
+{
+ g_return_if_fail(account != NULL);
+
+ account->use_wallet = value;
+
+ schedule_accounts_save();
+}
+
+gboolean
+purple_account_get_use_wallet(const PurpleAccount *account)
+{
+ g_return_val_if_fail(account != NULL, FALSE);
+
+ return account->use_wallet;
+}
libpurple # diff -rup account.h_orig account.h
--- account.h_orig 2010-01-15 14:15:48.000000000 +0300
+++ account.h 2010-01-15 15:19:47.000000000 +0300
@@ -119,6 +119,7 @@ struct _PurpleAccount
char *buddy_icon_path; /**< The buddy icon's non-cached path. */
gboolean remember_pass; /**< Remember the password. */
+ gboolean use_wallet;
char *protocol_id; /**< The ID of the protocol. */
@@ -1058,6 +1059,17 @@ void purple_accounts_uninit(void);
/*@}*/
+
+/**************************************************************************/
+/** @name Wallet Subsystem */
+/**************************************************************************/
+/*@{*/
+
+void purple_account_set_use_wallet(PurpleAccount *account, gboolean value);
+gboolean purple_account_get_use_wallet(const PurpleAccount *account);
+
+/*@}*/
+
#ifdef __cplusplus
}
#endif