Mon, 29 Jul 2013 11:52:27 +0530
Renamed plugin.[ch] to plugins.[ch], since we (will) no longer have a PurplePlugin structure.
|
34171
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
1 | /** |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
2 | * @file wincred.c Passwords storage using Windows credentials |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
3 | * @ingroup plugins |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
4 | */ |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
5 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
6 | /* purple |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
7 | * |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
8 | * Purple is the legal property of its developers, whose names are too numerous |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
9 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
10 | * source distribution. |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
11 | * |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
12 | * This program is free software; you can redistribute it and/or modify |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
13 | * it under the terms of the GNU General Public License as published by |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
14 | * the Free Software Foundation; either version 2 of the License, or |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
15 | * (at your option) any later version. |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
16 | * |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
17 | * This program is distributed in the hope that it will be useful, |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
20 | * GNU General Public License for more details. |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
21 | * |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
22 | * You should have received a copy of the GNU General Public License |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
23 | * along with this program ; if not, write to the Free Software |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
25 | */ |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
26 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
27 | #include "debug.h" |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
28 | #include "internal.h" |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
29 | #include "keyring.h" |
|
36367
891eea799578
Renamed plugin.[ch] to plugins.[ch], since we (will) no longer have a PurplePlugin structure.
Ankit Vani <a@nevitus.org>
parents:
34199
diff
changeset
|
30 | #include "plugins.h" |
|
34171
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
31 | #include "version.h" |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
32 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
33 | #include <wincred.h> |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
34 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
35 | #define WINCRED_NAME N_("Windows credentials") |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
36 | #define WINCRED_SUMMARY N_("Store passwords using Windows credentials") |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
37 | #define WINCRED_DESCRIPTION N_("This plugin stores passwords using Windows " \ |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
38 | "credentials.") |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
39 | #define WINCRED_AUTHOR "Tomek Wasilczyk (tomkiewicz@cpw.pidgin.im)" |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
40 | #define WINCRED_ID "keyring-wincred" |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
41 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
42 | #define WINCRED_MAX_TARGET_NAME 256 |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
43 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
44 | static PurpleKeyring *keyring_handler = NULL; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
45 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
46 | static gunichar2 * |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
47 | wincred_get_target_name(PurpleAccount *account) |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
48 | { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
49 | gchar target_name_utf8[WINCRED_MAX_TARGET_NAME]; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
50 | gunichar2 *target_name_utf16; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
51 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
52 | g_return_val_if_fail(account != NULL, NULL); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
53 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
54 | g_snprintf(target_name_utf8, WINCRED_MAX_TARGET_NAME, "libpurple_%s_%s", |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
55 | purple_account_get_protocol_id(account), |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
56 | purple_account_get_username(account)); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
57 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
58 | target_name_utf16 = g_utf8_to_utf16(target_name_utf8, -1, |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
59 | NULL, NULL, NULL); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
60 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
61 | if (target_name_utf16 == NULL) { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
62 | purple_debug_fatal("keyring-wincred", "Couldn't convert target " |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
63 | "name\n"); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
64 | } |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
65 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
66 | return target_name_utf16; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
67 | } |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
68 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
69 | static void |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
70 | wincred_read(PurpleAccount *account, PurpleKeyringReadCallback cb, |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
71 | gpointer data) |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
72 | { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
73 | GError *error = NULL; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
74 | gunichar2 *target_name = NULL; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
75 | gchar *password; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
76 | PCREDENTIALW credential; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
77 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
78 | g_return_if_fail(account != NULL); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
79 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
80 | target_name = wincred_get_target_name(account); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
81 | g_return_if_fail(target_name != NULL); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
82 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
83 | if (!CredReadW(target_name, CRED_TYPE_GENERIC, 0, &credential)) { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
84 | DWORD error_code = GetLastError(); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
85 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
86 | if (error_code == ERROR_NOT_FOUND) { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
87 | if (purple_debug_is_verbose()) { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
88 | purple_debug_misc("keyring-wincred", |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
89 | "No password found for account %s\n", |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
90 | purple_account_get_username(account)); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
91 | } |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
92 | error = g_error_new(PURPLE_KEYRING_ERROR, |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
93 | PURPLE_KEYRING_ERROR_NOPASSWORD, |
|
34199
73d122f25f2b
Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34172
diff
changeset
|
94 | _("Password not found.")); |
|
34171
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
95 | } else if (error_code == ERROR_NO_SUCH_LOGON_SESSION) { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
96 | purple_debug_error("keyring-wincred", |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
97 | "Cannot read password, no valid logon " |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
98 | "session\n"); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
99 | error = g_error_new(PURPLE_KEYRING_ERROR, |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
100 | PURPLE_KEYRING_ERROR_ACCESSDENIED, |
|
34199
73d122f25f2b
Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34172
diff
changeset
|
101 | _("Cannot read password, no valid logon " |
|
73d122f25f2b
Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34172
diff
changeset
|
102 | "session.")); |
|
34171
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
103 | } else { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
104 | purple_debug_error("keyring-wincred", |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
105 | "Cannot read password, error %lx\n", |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
106 | error_code); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
107 | error = g_error_new(PURPLE_KEYRING_ERROR, |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
108 | PURPLE_KEYRING_ERROR_BACKENDFAIL, |
|
34199
73d122f25f2b
Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34172
diff
changeset
|
109 | _("Cannot read password (error %lx)."), error_code); |
|
34171
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
110 | } |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
111 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
112 | if (cb != NULL) |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
113 | cb(account, NULL, error, data); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
114 | g_error_free(error); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
115 | return; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
116 | } |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
117 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
118 | password = g_utf16_to_utf8((gunichar2*)credential->CredentialBlob, |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
119 | credential->CredentialBlobSize / sizeof(gunichar2), |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
120 | NULL, NULL, NULL); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
121 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
122 | memset(credential->CredentialBlob, 0, credential->CredentialBlobSize); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
123 | CredFree(credential); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
124 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
125 | if (password == NULL) { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
126 | purple_debug_error("keyring-wincred", |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
127 | "Cannot convert password\n"); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
128 | error = g_error_new(PURPLE_KEYRING_ERROR, |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
129 | PURPLE_KEYRING_ERROR_BACKENDFAIL, |
|
34199
73d122f25f2b
Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34172
diff
changeset
|
130 | _("Cannot read password (unicode error).")); |
|
34172
db03a0efc8b4
More debug messages for wincred keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34171
diff
changeset
|
131 | } else { |
|
db03a0efc8b4
More debug messages for wincred keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34171
diff
changeset
|
132 | purple_debug_misc("keyring-wincred", |
|
34199
73d122f25f2b
Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34172
diff
changeset
|
133 | _("Got password for account %s.\n"), |
|
34172
db03a0efc8b4
More debug messages for wincred keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34171
diff
changeset
|
134 | purple_account_get_username(account)); |
|
34171
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
135 | } |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
136 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
137 | if (cb != NULL) |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
138 | cb(account, password, error, data); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
139 | if (error != NULL) |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
140 | g_error_free(error); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
141 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
142 | purple_str_wipe(password); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
143 | } |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
144 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
145 | static void |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
146 | wincred_save(PurpleAccount *account, const gchar *password, |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
147 | PurpleKeyringSaveCallback cb, gpointer data) |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
148 | { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
149 | GError *error = NULL; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
150 | gunichar2 *target_name = NULL; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
151 | gunichar2 *username_utf16 = NULL; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
152 | gunichar2 *password_utf16 = NULL; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
153 | CREDENTIALW credential; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
154 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
155 | g_return_if_fail(account != NULL); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
156 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
157 | target_name = wincred_get_target_name(account); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
158 | g_return_if_fail(target_name != NULL); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
159 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
160 | if (password == NULL) |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
161 | { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
162 | if (CredDeleteW(target_name, CRED_TYPE_GENERIC, 0)) { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
163 | purple_debug_misc("keyring-wincred", "Password for " |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
164 | "account %s removed\n", |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
165 | purple_account_get_username(account)); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
166 | } else { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
167 | DWORD error_code = GetLastError(); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
168 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
169 | if (error_code == ERROR_NOT_FOUND) { |
|
34172
db03a0efc8b4
More debug messages for wincred keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34171
diff
changeset
|
170 | if (purple_debug_is_verbose()) { |
|
db03a0efc8b4
More debug messages for wincred keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34171
diff
changeset
|
171 | purple_debug_misc("keyring-wincred", |
|
db03a0efc8b4
More debug messages for wincred keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34171
diff
changeset
|
172 | "Password for account %s was already " |
|
db03a0efc8b4
More debug messages for wincred keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34171
diff
changeset
|
173 | "removed.\n", |
|
db03a0efc8b4
More debug messages for wincred keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34171
diff
changeset
|
174 | purple_account_get_username(account)); |
|
db03a0efc8b4
More debug messages for wincred keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34171
diff
changeset
|
175 | } |
|
34171
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
176 | } else if (error_code == ERROR_NO_SUCH_LOGON_SESSION) { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
177 | purple_debug_error("keyring-wincred", |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
178 | "Cannot remove password, no valid " |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
179 | "logon session\n"); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
180 | error = g_error_new(PURPLE_KEYRING_ERROR, |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
181 | PURPLE_KEYRING_ERROR_ACCESSDENIED, |
|
34199
73d122f25f2b
Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34172
diff
changeset
|
182 | _("Cannot remove password, no valid " |
|
73d122f25f2b
Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34172
diff
changeset
|
183 | "logon session.")); |
|
34171
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
184 | } else { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
185 | purple_debug_error("keyring-wincred", |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
186 | "Cannot remove password, error %lx\n", |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
187 | error_code); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
188 | error = g_error_new(PURPLE_KEYRING_ERROR, |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
189 | PURPLE_KEYRING_ERROR_BACKENDFAIL, |
|
34199
73d122f25f2b
Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34172
diff
changeset
|
190 | _("Cannot remove password (error %lx)."), |
|
34171
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
191 | error_code); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
192 | } |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
193 | } |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
194 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
195 | if (cb != NULL) |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
196 | cb(account, error, data); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
197 | if (error != NULL) |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
198 | g_error_free(error); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
199 | return; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
200 | } |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
201 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
202 | username_utf16 = g_utf8_to_utf16(purple_account_get_username(account), |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
203 | -1, NULL, NULL, NULL); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
204 | password_utf16 = g_utf8_to_utf16(password, -1, NULL, NULL, NULL); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
205 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
206 | if (username_utf16 == NULL || password_utf16 == NULL) { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
207 | g_free(username_utf16); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
208 | purple_utf16_wipe(password_utf16); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
209 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
210 | purple_debug_fatal("keyring-wincred", "Couldn't convert " |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
211 | "username or password\n"); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
212 | g_return_if_reached(); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
213 | } |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
214 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
215 | memset(&credential, 0, sizeof(CREDENTIALW)); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
216 | credential.Type = CRED_TYPE_GENERIC; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
217 | credential.TargetName = target_name; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
218 | credential.CredentialBlobSize = purple_utf16_size(password_utf16) - 2; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
219 | credential.CredentialBlob = (LPBYTE)password_utf16; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
220 | credential.Persist = CRED_PERSIST_LOCAL_MACHINE; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
221 | credential.UserName = username_utf16; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
222 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
223 | if (!CredWriteW(&credential, 0)) { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
224 | DWORD error_code = GetLastError(); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
225 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
226 | if (error_code == ERROR_NO_SUCH_LOGON_SESSION) { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
227 | purple_debug_error("keyring-wincred", |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
228 | "Cannot store password, no valid logon " |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
229 | "session\n"); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
230 | error = g_error_new(PURPLE_KEYRING_ERROR, |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
231 | PURPLE_KEYRING_ERROR_ACCESSDENIED, |
|
34199
73d122f25f2b
Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34172
diff
changeset
|
232 | _("Cannot remove password, no valid logon " |
|
73d122f25f2b
Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34172
diff
changeset
|
233 | "session.")); |
|
34171
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
234 | } else { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
235 | purple_debug_error("keyring-wincred", |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
236 | "Cannot store password, error %lx\n", |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
237 | error_code); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
238 | error = g_error_new(PURPLE_KEYRING_ERROR, |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
239 | PURPLE_KEYRING_ERROR_BACKENDFAIL, |
|
34199
73d122f25f2b
Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34172
diff
changeset
|
240 | _("Cannot store password (error %lx)."), error_code); |
|
34171
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
241 | } |
|
34172
db03a0efc8b4
More debug messages for wincred keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34171
diff
changeset
|
242 | } else { |
|
db03a0efc8b4
More debug messages for wincred keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34171
diff
changeset
|
243 | purple_debug_misc("keyring-wincred", |
|
db03a0efc8b4
More debug messages for wincred keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34171
diff
changeset
|
244 | "Password updated for account %s.\n", |
|
db03a0efc8b4
More debug messages for wincred keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34171
diff
changeset
|
245 | purple_account_get_username(account)); |
|
34171
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
246 | } |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
247 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
248 | g_free(target_name); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
249 | g_free(username_utf16); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
250 | purple_utf16_wipe(password_utf16); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
251 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
252 | if (cb != NULL) |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
253 | cb(account, error, data); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
254 | if (error != NULL) |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
255 | g_error_free(error); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
256 | } |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
257 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
258 | static gboolean |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
259 | wincred_load(PurplePlugin *plugin) |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
260 | { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
261 | keyring_handler = purple_keyring_new(); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
262 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
263 | purple_keyring_set_name(keyring_handler, WINCRED_NAME); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
264 | purple_keyring_set_id(keyring_handler, WINCRED_ID); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
265 | purple_keyring_set_read_password(keyring_handler, wincred_read); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
266 | purple_keyring_set_save_password(keyring_handler, wincred_save); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
267 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
268 | purple_keyring_register(keyring_handler); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
269 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
270 | return TRUE; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
271 | } |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
272 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
273 | static gboolean |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
274 | wincred_unload(PurplePlugin *plugin) |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
275 | { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
276 | if (purple_keyring_get_inuse() == keyring_handler) { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
277 | purple_debug_warning("keyring-wincred", |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
278 | "keyring in use, cannot unload\n"); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
279 | return FALSE; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
280 | } |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
281 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
282 | purple_keyring_unregister(keyring_handler); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
283 | purple_keyring_free(keyring_handler); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
284 | keyring_handler = NULL; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
285 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
286 | return TRUE; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
287 | } |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
288 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
289 | PurplePluginInfo plugininfo = |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
290 | { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
291 | PURPLE_PLUGIN_MAGIC, /* magic */ |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
292 | PURPLE_MAJOR_VERSION, /* major_version */ |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
293 | PURPLE_MINOR_VERSION, /* minor_version */ |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
294 | PURPLE_PLUGIN_STANDARD, /* type */ |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
295 | NULL, /* ui_requirement */ |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
296 | PURPLE_PLUGIN_FLAG_INVISIBLE, /* flags */ |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
297 | NULL, /* dependencies */ |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
298 | PURPLE_PRIORITY_DEFAULT, /* priority */ |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
299 | WINCRED_ID, /* id */ |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
300 | WINCRED_NAME, /* name */ |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
301 | DISPLAY_VERSION, /* version */ |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
302 | WINCRED_SUMMARY, /* summary */ |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
303 | WINCRED_DESCRIPTION, /* description */ |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
304 | WINCRED_AUTHOR, /* author */ |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
305 | PURPLE_WEBSITE, /* homepage */ |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
306 | wincred_load, /* load */ |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
307 | wincred_unload, /* unload */ |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
308 | NULL, /* destroy */ |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
309 | NULL, /* ui_info */ |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
310 | NULL, /* extra_info */ |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
311 | NULL, /* prefs_info */ |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
312 | NULL, /* actions */ |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
313 | NULL, NULL, NULL, NULL /* padding */ |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
314 | }; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
315 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
316 | static void |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
317 | init_plugin(PurplePlugin *plugin) |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
318 | { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
319 | } |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
320 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
321 | PURPLE_INIT_PLUGIN(wincred_keyring, init_plugin, plugininfo) |