Lines 49-54
typedef struct
Link Here
|
49 |
#define PURPLE_ACCOUNT_GET_PRIVATE(account) \ |
49 |
#define PURPLE_ACCOUNT_GET_PRIVATE(account) \ |
50 |
((PurpleAccountPrivate *) (account->priv)) |
50 |
((PurpleAccountPrivate *) (account->priv)) |
51 |
|
51 |
|
|
|
52 |
#ifdef PURPLE_ENABLE_KEYRING |
53 |
#include <gnome-keyring.h> |
54 |
|
55 |
static char * purple_account_get_password_from_keyring (const char *_prpl, const char *_user); |
56 |
static gboolean purple_account_set_password_in_keyring (const char *_prpl, const char *_user, const char *password); |
57 |
#endif |
58 |
|
52 |
/* TODO: Should use PurpleValue instead of this? What about "ui"? */ |
59 |
/* TODO: Should use PurpleValue instead of this? What about "ui"? */ |
53 |
typedef struct |
60 |
typedef struct |
54 |
{ |
61 |
{ |
Lines 378-385
account_to_xmlnode(PurpleAccount *accoun
Link Here
|
378 |
if (purple_account_get_remember_password(account) && |
385 |
if (purple_account_get_remember_password(account) && |
379 |
((tmp = purple_account_get_password(account)) != NULL)) |
386 |
((tmp = purple_account_get_password(account)) != NULL)) |
380 |
{ |
387 |
{ |
|
|
388 |
#ifdef PURPLE_ENABLE_KEYRING |
389 |
purple_account_set_password_in_keyring( purple_account_get_protocol_id(account), |
390 |
purple_account_get_username(account), tmp); |
391 |
#else |
381 |
child = xmlnode_new_child(node, "password"); |
392 |
child = xmlnode_new_child(node, "password"); |
382 |
xmlnode_insert_data(child, tmp, -1); |
393 |
xmlnode_insert_data(child, tmp, -1); |
|
|
394 |
#endif |
383 |
} |
395 |
} |
384 |
|
396 |
|
385 |
if ((tmp = purple_account_get_alias(account)) != NULL) |
397 |
if ((tmp = purple_account_get_alias(account)) != NULL) |
Lines 828-844
parse_account(xmlnode *node)
Link Here
|
828 |
} |
840 |
} |
829 |
|
841 |
|
830 |
ret = purple_account_new(name, _purple_oscar_convert(name, protocol_id)); /* XXX: */ |
842 |
ret = purple_account_new(name, _purple_oscar_convert(name, protocol_id)); /* XXX: */ |
831 |
g_free(name); |
843 |
gboolean got_pwd = FALSE; |
832 |
g_free(protocol_id); |
844 |
#ifdef PURPLE_ENABLE_KEYRING |
833 |
|
845 |
data = purple_account_get_password_from_keyring(protocol_id, name); |
834 |
/* Read the password */ |
846 |
if (data) |
835 |
child = xmlnode_get_child(node, "password"); |
|
|
836 |
if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL)) |
837 |
{ |
847 |
{ |
|
|
848 |
got_pwd = TRUE; |
838 |
purple_account_set_remember_password(ret, TRUE); |
849 |
purple_account_set_remember_password(ret, TRUE); |
839 |
purple_account_set_password(ret, data); |
850 |
purple_account_set_password(ret, data); |
840 |
g_free(data); |
851 |
g_free(data); |
841 |
} |
852 |
} |
|
|
853 |
#endif |
854 |
if (!got_pwd) |
855 |
{ |
856 |
/* Read the password */ |
857 |
child = xmlnode_get_child(node, "password"); |
858 |
if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL)) |
859 |
{ |
860 |
purple_account_set_remember_password(ret, TRUE); |
861 |
purple_account_set_password(ret, data); |
862 |
g_free(data); |
863 |
} |
864 |
} |
865 |
g_free(name); |
866 |
g_free(protocol_id); |
842 |
|
867 |
|
843 |
/* Read the alias */ |
868 |
/* Read the alias */ |
844 |
child = xmlnode_get_child(node, "alias"); |
869 |
child = xmlnode_get_child(node, "alias"); |
Lines 2873-2875
purple_accounts_uninit(void)
Link Here
|
2873 |
purple_signals_disconnect_by_handle(handle); |
2898 |
purple_signals_disconnect_by_handle(handle); |
2874 |
purple_signals_unregister_by_instance(handle); |
2899 |
purple_signals_unregister_by_instance(handle); |
2875 |
} |
2900 |
} |
|
|
2901 |
|
2902 |
#ifdef PURPLE_ENABLE_KEYRING |
2903 |
static char * |
2904 |
purple_account_get_password_from_keyring(const char *_prpl, const char *_user) |
2905 |
{ |
2906 |
GnomeKeyringNetworkPasswordData *found_item; |
2907 |
GnomeKeyringResult result; |
2908 |
GList *matches; |
2909 |
char *password; |
2910 |
|
2911 |
matches = NULL; |
2912 |
|
2913 |
result = gnome_keyring_find_network_password_sync ( |
2914 |
_user, /* user */ |
2915 |
NULL, /* domain */ |
2916 |
"gaim.local", /* server */ |
2917 |
NULL, /* object */ |
2918 |
_prpl, /* protocol */ |
2919 |
NULL, /* authtype */ |
2920 |
1863, /* port */ |
2921 |
&matches); |
2922 |
|
2923 |
if (result != GNOME_KEYRING_RESULT_OK) |
2924 |
return NULL; |
2925 |
|
2926 |
g_assert (matches != NULL && matches->data != NULL); |
2927 |
|
2928 |
found_item = (GnomeKeyringNetworkPasswordData *) matches->data; |
2929 |
|
2930 |
password = g_strdup (found_item->password); |
2931 |
|
2932 |
gnome_keyring_network_password_list_free (matches); |
2933 |
|
2934 |
return password; |
2935 |
} |
2936 |
|
2937 |
static gboolean |
2938 |
purple_account_set_password_in_keyring (const char *_prpl, const char *_user, const char *_password) |
2939 |
{ |
2940 |
GnomeKeyringResult result; |
2941 |
guint32 item_id; |
2942 |
|
2943 |
result = gnome_keyring_set_network_password_sync ( |
2944 |
NULL, /* default keyring */ |
2945 |
_user, /* user */ |
2946 |
NULL, /* domain */ |
2947 |
"gaim.local", /* server */ |
2948 |
NULL, /* object */ |
2949 |
_prpl, /* protocol */ |
2950 |
NULL, /* authtype */ |
2951 |
1863, /* port */ |
2952 |
_password, /* password */ |
2953 |
&item_id); |
2954 |
|
2955 |
return result == GNOME_KEYRING_RESULT_OK; |
2956 |
} |
2957 |
#endif |