Mon, 02 Sep 2013 19:50:32 +0530
Fix keyring plugin names passed to PURPLE_PLUGIN_INIT
|
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.") |
|
36642
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36505
diff
changeset
|
39 | #define WINCRED_AUTHORS {"Tomek Wasilczyk (tomkiewicz@cpw.pidgin.im)", NULL} |
|
34171
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
40 | #define WINCRED_ID "keyring-wincred" |
|
36502
dfce617913fe
Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents:
36459
diff
changeset
|
41 | #define WINCRED_DOMAIN (g_quark_from_static_string(WINCRED_ID)) |
|
34171
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
42 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
43 | #define WINCRED_MAX_TARGET_NAME 256 |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
44 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
45 | static PurpleKeyring *keyring_handler = NULL; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
46 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
47 | static gunichar2 * |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
48 | wincred_get_target_name(PurpleAccount *account) |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
49 | { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
50 | 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
|
51 | gunichar2 *target_name_utf16; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
52 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
53 | 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
|
54 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
55 | 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
|
56 | purple_account_get_protocol_id(account), |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
57 | purple_account_get_username(account)); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
58 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
59 | 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
|
60 | NULL, NULL, NULL); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
61 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
62 | if (target_name_utf16 == NULL) { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
63 | 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
|
64 | "name\n"); |
|
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 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
67 | return target_name_utf16; |
|
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 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
70 | static void |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
71 | wincred_read(PurpleAccount *account, PurpleKeyringReadCallback cb, |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
72 | gpointer data) |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
73 | { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
74 | GError *error = NULL; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
75 | gunichar2 *target_name = NULL; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
76 | gchar *password; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
77 | PCREDENTIALW credential; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
78 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
79 | g_return_if_fail(account != NULL); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
80 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
81 | target_name = wincred_get_target_name(account); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
82 | g_return_if_fail(target_name != NULL); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
83 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
84 | 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
|
85 | DWORD error_code = GetLastError(); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
86 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
87 | if (error_code == ERROR_NOT_FOUND) { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
88 | if (purple_debug_is_verbose()) { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
89 | purple_debug_misc("keyring-wincred", |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
90 | "No password found for account %s\n", |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
91 | purple_account_get_username(account)); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
92 | } |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
93 | error = g_error_new(PURPLE_KEYRING_ERROR, |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
94 | PURPLE_KEYRING_ERROR_NOPASSWORD, |
|
34199
73d122f25f2b
Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34172
diff
changeset
|
95 | _("Password not found.")); |
|
34171
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
96 | } 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
|
97 | purple_debug_error("keyring-wincred", |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
98 | "Cannot read password, no valid logon " |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
99 | "session\n"); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
100 | error = g_error_new(PURPLE_KEYRING_ERROR, |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
101 | PURPLE_KEYRING_ERROR_ACCESSDENIED, |
|
34199
73d122f25f2b
Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34172
diff
changeset
|
102 | _("Cannot read password, no valid logon " |
|
73d122f25f2b
Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34172
diff
changeset
|
103 | "session.")); |
|
34171
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
104 | } else { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
105 | purple_debug_error("keyring-wincred", |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
106 | "Cannot read password, error %lx\n", |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
107 | error_code); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
108 | error = g_error_new(PURPLE_KEYRING_ERROR, |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
109 | PURPLE_KEYRING_ERROR_BACKENDFAIL, |
|
34199
73d122f25f2b
Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34172
diff
changeset
|
110 | _("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
|
111 | } |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
112 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
113 | if (cb != NULL) |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
114 | cb(account, NULL, error, data); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
115 | g_error_free(error); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
116 | return; |
|
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 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
119 | 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
|
120 | credential->CredentialBlobSize / sizeof(gunichar2), |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
121 | NULL, NULL, NULL); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
122 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
123 | memset(credential->CredentialBlob, 0, credential->CredentialBlobSize); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
124 | CredFree(credential); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
125 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
126 | if (password == NULL) { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
127 | purple_debug_error("keyring-wincred", |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
128 | "Cannot convert password\n"); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
129 | error = g_error_new(PURPLE_KEYRING_ERROR, |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
130 | PURPLE_KEYRING_ERROR_BACKENDFAIL, |
|
34199
73d122f25f2b
Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34172
diff
changeset
|
131 | _("Cannot read password (unicode error).")); |
|
34172
db03a0efc8b4
More debug messages for wincred keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34171
diff
changeset
|
132 | } else { |
|
db03a0efc8b4
More debug messages for wincred keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34171
diff
changeset
|
133 | purple_debug_misc("keyring-wincred", |
|
34199
73d122f25f2b
Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34172
diff
changeset
|
134 | _("Got password for account %s.\n"), |
|
34172
db03a0efc8b4
More debug messages for wincred keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34171
diff
changeset
|
135 | purple_account_get_username(account)); |
|
34171
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 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
138 | if (cb != NULL) |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
139 | cb(account, password, error, data); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
140 | if (error != NULL) |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
141 | g_error_free(error); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
142 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
143 | purple_str_wipe(password); |
|
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 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
146 | static void |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
147 | wincred_save(PurpleAccount *account, const gchar *password, |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
148 | PurpleKeyringSaveCallback cb, gpointer data) |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
149 | { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
150 | GError *error = NULL; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
151 | gunichar2 *target_name = NULL; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
152 | gunichar2 *username_utf16 = NULL; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
153 | gunichar2 *password_utf16 = NULL; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
154 | CREDENTIALW credential; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
155 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
156 | g_return_if_fail(account != NULL); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
157 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
158 | target_name = wincred_get_target_name(account); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
159 | g_return_if_fail(target_name != NULL); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
160 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
161 | if (password == NULL) |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
162 | { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
163 | 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
|
164 | purple_debug_misc("keyring-wincred", "Password for " |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
165 | "account %s removed\n", |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
166 | purple_account_get_username(account)); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
167 | } else { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
168 | DWORD error_code = GetLastError(); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
169 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
170 | if (error_code == ERROR_NOT_FOUND) { |
|
34172
db03a0efc8b4
More debug messages for wincred keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34171
diff
changeset
|
171 | if (purple_debug_is_verbose()) { |
|
db03a0efc8b4
More debug messages for wincred keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34171
diff
changeset
|
172 | purple_debug_misc("keyring-wincred", |
|
db03a0efc8b4
More debug messages for wincred keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34171
diff
changeset
|
173 | "Password for account %s was already " |
|
db03a0efc8b4
More debug messages for wincred keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34171
diff
changeset
|
174 | "removed.\n", |
|
db03a0efc8b4
More debug messages for wincred keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34171
diff
changeset
|
175 | purple_account_get_username(account)); |
|
db03a0efc8b4
More debug messages for wincred keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34171
diff
changeset
|
176 | } |
|
34171
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
177 | } 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
|
178 | purple_debug_error("keyring-wincred", |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
179 | "Cannot remove password, no valid " |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
180 | "logon session\n"); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
181 | error = g_error_new(PURPLE_KEYRING_ERROR, |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
182 | PURPLE_KEYRING_ERROR_ACCESSDENIED, |
|
34199
73d122f25f2b
Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34172
diff
changeset
|
183 | _("Cannot remove password, no valid " |
|
73d122f25f2b
Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34172
diff
changeset
|
184 | "logon session.")); |
|
34171
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
185 | } else { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
186 | purple_debug_error("keyring-wincred", |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
187 | "Cannot remove password, error %lx\n", |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
188 | error_code); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
189 | error = g_error_new(PURPLE_KEYRING_ERROR, |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
190 | PURPLE_KEYRING_ERROR_BACKENDFAIL, |
|
34199
73d122f25f2b
Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34172
diff
changeset
|
191 | _("Cannot remove password (error %lx)."), |
|
34171
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
192 | error_code); |
|
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 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
196 | if (cb != NULL) |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
197 | cb(account, error, data); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
198 | if (error != NULL) |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
199 | g_error_free(error); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
200 | return; |
|
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 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
203 | 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
|
204 | -1, NULL, NULL, NULL); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
205 | 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
|
206 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
207 | if (username_utf16 == NULL || password_utf16 == NULL) { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
208 | g_free(username_utf16); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
209 | purple_utf16_wipe(password_utf16); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
210 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
211 | 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
|
212 | "username or password\n"); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
213 | g_return_if_reached(); |
|
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 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
216 | memset(&credential, 0, sizeof(CREDENTIALW)); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
217 | credential.Type = CRED_TYPE_GENERIC; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
218 | credential.TargetName = target_name; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
219 | 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
|
220 | credential.CredentialBlob = (LPBYTE)password_utf16; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
221 | credential.Persist = CRED_PERSIST_LOCAL_MACHINE; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
222 | credential.UserName = username_utf16; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
223 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
224 | if (!CredWriteW(&credential, 0)) { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
225 | DWORD error_code = GetLastError(); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
226 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
227 | 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
|
228 | purple_debug_error("keyring-wincred", |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
229 | "Cannot store password, no valid logon " |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
230 | "session\n"); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
231 | error = g_error_new(PURPLE_KEYRING_ERROR, |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
232 | PURPLE_KEYRING_ERROR_ACCESSDENIED, |
|
34199
73d122f25f2b
Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34172
diff
changeset
|
233 | _("Cannot remove password, no valid logon " |
|
73d122f25f2b
Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34172
diff
changeset
|
234 | "session.")); |
|
34171
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
235 | } else { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
236 | purple_debug_error("keyring-wincred", |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
237 | "Cannot store password, error %lx\n", |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
238 | error_code); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
239 | error = g_error_new(PURPLE_KEYRING_ERROR, |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
240 | PURPLE_KEYRING_ERROR_BACKENDFAIL, |
|
34199
73d122f25f2b
Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34172
diff
changeset
|
241 | _("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
|
242 | } |
|
34172
db03a0efc8b4
More debug messages for wincred keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34171
diff
changeset
|
243 | } else { |
|
db03a0efc8b4
More debug messages for wincred keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34171
diff
changeset
|
244 | purple_debug_misc("keyring-wincred", |
|
db03a0efc8b4
More debug messages for wincred keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34171
diff
changeset
|
245 | "Password updated for account %s.\n", |
|
db03a0efc8b4
More debug messages for wincred keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34171
diff
changeset
|
246 | purple_account_get_username(account)); |
|
34171
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 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
249 | g_free(target_name); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
250 | g_free(username_utf16); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
251 | purple_utf16_wipe(password_utf16); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
252 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
253 | if (cb != NULL) |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
254 | cb(account, error, data); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
255 | if (error != NULL) |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
256 | g_error_free(error); |
|
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 | |
|
36502
dfce617913fe
Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents:
36459
diff
changeset
|
259 | static PurplePluginInfo * |
|
dfce617913fe
Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents:
36459
diff
changeset
|
260 | plugin_query(GError **error) |
|
dfce617913fe
Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents:
36459
diff
changeset
|
261 | { |
|
36642
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36505
diff
changeset
|
262 | const gchar * const authors[] = WINCRED_AUTHORS; |
|
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36505
diff
changeset
|
263 | |
|
36502
dfce617913fe
Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents:
36459
diff
changeset
|
264 | return purple_plugin_info_new( |
|
dfce617913fe
Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents:
36459
diff
changeset
|
265 | "id", WINCRED_ID, |
|
dfce617913fe
Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents:
36459
diff
changeset
|
266 | "name", WINCRED_NAME, |
|
dfce617913fe
Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents:
36459
diff
changeset
|
267 | "version", DISPLAY_VERSION, |
|
dfce617913fe
Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents:
36459
diff
changeset
|
268 | "category", N_("Keyring"), |
|
dfce617913fe
Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents:
36459
diff
changeset
|
269 | "summary", WINCRED_SUMMARY, |
|
dfce617913fe
Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents:
36459
diff
changeset
|
270 | "description", WINCRED_DESCRIPTION, |
|
36642
b8ba53daa445
Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents:
36505
diff
changeset
|
271 | "authors", authors, |
|
36502
dfce617913fe
Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents:
36459
diff
changeset
|
272 | "website", PURPLE_WEBSITE, |
|
36505
60c161851325
Integrated purple ABI requirement into GPlugin's "abi-version" property
Ankit Vani <a@nevitus.org>
parents:
36502
diff
changeset
|
273 | "abi-version", PURPLE_ABI_VERSION, |
|
36653
4084c34c051d
Override gplugin info's "flags" property. Added PURPLE_PLUGIN_INFO_FLAGS_INTERNAL and PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD.
Ankit Vani <a@nevitus.org>
parents:
36642
diff
changeset
|
274 | "flags", PURPLE_PLUGIN_INFO_FLAGS_INTERNAL, |
|
36502
dfce617913fe
Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents:
36459
diff
changeset
|
275 | NULL |
|
dfce617913fe
Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents:
36459
diff
changeset
|
276 | ); |
|
dfce617913fe
Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents:
36459
diff
changeset
|
277 | } |
|
dfce617913fe
Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents:
36459
diff
changeset
|
278 | |
|
34171
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
279 | static gboolean |
|
36502
dfce617913fe
Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents:
36459
diff
changeset
|
280 | plugin_load(PurplePlugin *plugin, GError **error) |
|
34171
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 | keyring_handler = purple_keyring_new(); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
283 | |
|
34281
ad957d0a467a
Keyring (and some GTK): fix translation callbacks
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34199
diff
changeset
|
284 | purple_keyring_set_name(keyring_handler, _(WINCRED_NAME)); |
|
34171
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
285 | 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
|
286 | 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
|
287 | 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
|
288 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
289 | purple_keyring_register(keyring_handler); |
|
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 | return TRUE; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
292 | } |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
293 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
294 | static gboolean |
|
36502
dfce617913fe
Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents:
36459
diff
changeset
|
295 | plugin_unload(PurplePlugin *plugin, GError **error) |
|
34171
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
296 | { |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
297 | if (purple_keyring_get_inuse() == keyring_handler) { |
|
36502
dfce617913fe
Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents:
36459
diff
changeset
|
298 | g_set_error(error, WINCRED_DOMAIN, 0, "The keyring is currently " |
|
dfce617913fe
Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents:
36459
diff
changeset
|
299 | "in use."); |
|
34171
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
300 | purple_debug_warning("keyring-wincred", |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
301 | "keyring in use, cannot unload\n"); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
302 | return FALSE; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
303 | } |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
304 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
305 | purple_keyring_unregister(keyring_handler); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
306 | purple_keyring_free(keyring_handler); |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
307 | keyring_handler = NULL; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
308 | |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
309 | return TRUE; |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
310 | } |
|
a23f3228c465
New keyring: store passwords using Windows credentials
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
311 | |
|
36656
3e21d5b61c2b
Fix keyring plugin names passed to PURPLE_PLUGIN_INIT
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
312 | PURPLE_PLUGIN_INIT(wincred_keyring, plugin_query, plugin_load, plugin_unload); |