Fri, 22 Mar 2013 22:39:12 +0100
Proper error handling when doing a password migration, fixes reverting it.
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
1 | /** |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
2 | * @file kwallet.cpp KWallet password storage |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
3 | * @ingroup plugins |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
4 | * |
|
34033
910f2ed3988b
Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34032
diff
changeset
|
5 | * @todo |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
6 | * cleanup error handling and reporting |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
7 | */ |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
8 | |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
9 | /* purple |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
10 | * |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
11 | * Purple is the legal property of its developers, whose names are too numerous |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
12 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
13 | * source distribution. |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
14 | * |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
15 | * This program is free software; you can redistribute it and/or modify |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
16 | * it under the terms of the GNU General Public License as published by |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
17 | * the Free Software Foundation; either version 2 of the License, or |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
18 | * (at your option) any later version. |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
19 | * |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
20 | * This program is distributed in the hope that it will be useful, |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
23 | * GNU General Public License for more details. |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
24 | * |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
25 | * You should have received a copy of the GNU General Public License |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
26 | * along with this program ; if not, write to the Free Software |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
28 | */ |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
29 | |
|
34076
64e389ae5cc3
Clean up headers and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34073
diff
changeset
|
30 | #include "internal.h" |
|
64e389ae5cc3
Clean up headers and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34073
diff
changeset
|
31 | #include "account.h" |
|
64e389ae5cc3
Clean up headers and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34073
diff
changeset
|
32 | #include "debug.h" |
|
64e389ae5cc3
Clean up headers and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34073
diff
changeset
|
33 | #include "keyring.h" |
|
64e389ae5cc3
Clean up headers and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34073
diff
changeset
|
34 | #include "plugin.h" |
|
64e389ae5cc3
Clean up headers and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34073
diff
changeset
|
35 | #include "version.h" |
|
34014
647e174899a9
Took stuff from kwallet.cpp out of the extern "C" {}
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
34005
diff
changeset
|
36 | |
|
34079
fcf75ee4d190
Use a QQueue instead of a STL list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34077
diff
changeset
|
37 | #include <QQueue> |
|
34085
26a50ff943ed
Add a QCoreApplication to process events, which is a bit lighter
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34084
diff
changeset
|
38 | #include <QCoreApplication> |
|
34060
1ff15466f569
This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34035
diff
changeset
|
39 | #include <kwallet.h> |
|
34014
647e174899a9
Took stuff from kwallet.cpp out of the extern "C" {}
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
34005
diff
changeset
|
40 | |
|
34060
1ff15466f569
This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34035
diff
changeset
|
41 | #define KWALLET_NAME N_("KWallet") |
|
1ff15466f569
This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34035
diff
changeset
|
42 | #define KWALLET_DESCRIPTION N_("This plugin will store passwords in KWallet.") |
|
34094
551d0e8ae7fb
I'm pretty sure I wrote most of this plugin, since it didn't do
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34093
diff
changeset
|
43 | #define KWALLET_AUTHOR "QuLogic (qulogic[at]pidgin.im)" |
|
34093
c8197603fa20
Use better keyring IDs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34089
diff
changeset
|
44 | #define KWALLET_ID "keyring-kwallet" |
|
34014
647e174899a9
Took stuff from kwallet.cpp out of the extern "C" {}
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
34005
diff
changeset
|
45 | |
|
34117
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
46 | #define KWALLET_WALLET_NAME KWallet::Wallet::NetworkWallet() |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
47 | #define KWALLET_APP_NAME "Libpurple" |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
48 | #define KWALLET_FOLDER_NAME "libpurple" |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
49 | |
|
34097
f6f36bfbe951
Free the keyring when the KWallet plugin is unloaded.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34096
diff
changeset
|
50 | PurpleKeyring *keyring_handler = NULL; |
|
34119
8852b9a4dd2a
Better usage of QCoreApplication
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34118
diff
changeset
|
51 | QCoreApplication *qCoreApp = NULL; |
|
34014
647e174899a9
Took stuff from kwallet.cpp out of the extern "C" {}
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
34005
diff
changeset
|
52 | |
|
34060
1ff15466f569
This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34035
diff
changeset
|
53 | namespace KWalletPlugin { |
|
34062
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
54 | |
|
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
55 | class request |
|
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
56 | { |
|
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
57 | public: |
|
34114
c915903f6e43
Get rid of warnings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34110
diff
changeset
|
58 | virtual ~request(); |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
59 | virtual void detailedAbort(enum PurpleKeyringError error) = 0; |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
60 | void abort(); |
|
34077
3e4d7e7d3064
Make KWalletPlugin::request class abstract. Unfortunately, this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34076
diff
changeset
|
61 | virtual void execute(KWallet::Wallet *wallet) = 0; |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
62 | |
|
34062
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
63 | protected: |
|
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
64 | gpointer data; |
|
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
65 | PurpleAccount *account; |
|
34072
5450e39dd3c5
It appears that a QString can be treated as if it were a value type.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34071
diff
changeset
|
66 | QString password; |
|
34126
a479dca0f05b
Implement removal of KWallet passwords (instead of setting them to blank)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34125
diff
changeset
|
67 | bool noPassword; |
|
34062
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
68 | }; |
|
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
69 | |
|
34079
fcf75ee4d190
Use a QQueue instead of a STL list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34077
diff
changeset
|
70 | class engine : private QObject, private QQueue<request*> |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
71 | { |
|
34084
e94dd262b20a
Fix signal handling. On this side, it's a slot, not a signal.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34081
diff
changeset
|
72 | Q_OBJECT |
|
e94dd262b20a
Fix signal handling. On this side, it's a slot, not a signal.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34081
diff
changeset
|
73 | |
|
34062
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
74 | public: |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
75 | engine(); |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
76 | ~engine(); |
|
34077
3e4d7e7d3064
Make KWalletPlugin::request class abstract. Unfortunately, this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34076
diff
changeset
|
77 | void queue(request *req); |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
78 | static engine *instance(); |
|
34117
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
79 | static void closeInstance(); |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
80 | |
|
34084
e94dd262b20a
Fix signal handling. On this side, it's a slot, not a signal.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34081
diff
changeset
|
81 | private slots: |
|
34067
8643ef2b5bf4
This seems to fix compiling the signal stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34062
diff
changeset
|
82 | void walletOpened(bool opened); |
|
34117
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
83 | void walletClosed(); |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
84 | |
|
34062
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
85 | private: |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
86 | static engine *pinstance; |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
87 | |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
88 | bool connected; |
|
34110
bda1c52322fe
Keyring: more verbosity, handle kwallet connection errors
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34098
diff
changeset
|
89 | bool failed; |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
90 | bool closing; |
|
34117
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
91 | bool externallyClosed; |
|
34123
21aa923e62ad
Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34120
diff
changeset
|
92 | bool busy; |
|
21aa923e62ad
Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34120
diff
changeset
|
93 | bool closeAfterBusy; |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
94 | |
|
34062
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
95 | KWallet::Wallet *wallet; |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
96 | |
|
34117
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
97 | void reopenWallet(); |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
98 | void executeRequests(); |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
99 | }; |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
100 | |
|
34062
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
101 | class save_request : public request |
|
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
102 | { |
|
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
103 | public: |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
104 | save_request(PurpleAccount *account, const char *password, |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
105 | PurpleKeyringSaveCallback cb, void *data); |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
106 | void detailedAbort(enum PurpleKeyringError error); |
|
34062
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
107 | void execute(KWallet::Wallet *wallet); |
|
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
108 | |
|
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
109 | private: |
|
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
110 | PurpleKeyringSaveCallback callback; |
|
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
111 | }; |
|
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
112 | |
|
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
113 | class read_request : public request |
|
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
114 | { |
|
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
115 | public: |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
116 | read_request(PurpleAccount *account, |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
117 | PurpleKeyringReadCallback cb, void *data); |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
118 | void detailedAbort(enum PurpleKeyringError error); |
|
34062
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
119 | void execute(KWallet::Wallet *wallet); |
|
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
120 | |
|
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
121 | private: |
|
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
122 | PurpleKeyringReadCallback callback; |
|
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
123 | }; |
|
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
124 | |
|
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
125 | } |
|
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
126 | |
|
34120
50bc553c8c52
Handle the case of disabled KWallet system
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34119
diff
changeset
|
127 | static gboolean |
|
50bc553c8c52
Handle the case of disabled KWallet system
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34119
diff
changeset
|
128 | kwallet_is_enabled(void) |
|
50bc553c8c52
Handle the case of disabled KWallet system
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34119
diff
changeset
|
129 | { |
|
50bc553c8c52
Handle the case of disabled KWallet system
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34119
diff
changeset
|
130 | return KWallet::Wallet::isEnabled() ? TRUE : FALSE; |
|
50bc553c8c52
Handle the case of disabled KWallet system
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34119
diff
changeset
|
131 | } |
|
50bc553c8c52
Handle the case of disabled KWallet system
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34119
diff
changeset
|
132 | |
|
34080
098a43dd4835
Initialize pinstance.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34079
diff
changeset
|
133 | KWalletPlugin::engine *KWalletPlugin::engine::pinstance = NULL; |
|
098a43dd4835
Initialize pinstance.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34079
diff
changeset
|
134 | |
|
34114
c915903f6e43
Get rid of warnings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34110
diff
changeset
|
135 | KWalletPlugin::request::~request() |
|
c915903f6e43
Get rid of warnings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34110
diff
changeset
|
136 | { |
|
c915903f6e43
Get rid of warnings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34110
diff
changeset
|
137 | } |
|
c915903f6e43
Get rid of warnings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34110
diff
changeset
|
138 | |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
139 | void |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
140 | KWalletPlugin::request::abort() |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
141 | { |
|
34129
52b91b4b8314
Proper error handling when doing a password migration, fixes reverting it.
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34127
diff
changeset
|
142 | detailedAbort(PURPLE_KEYRING_ERROR_NOCHANNEL); |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
143 | } |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
144 | |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
145 | KWalletPlugin::engine::engine() |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
146 | { |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
147 | connected = false; |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
148 | failed = false; |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
149 | closing = false; |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
150 | externallyClosed = false; |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
151 | wallet = NULL; |
|
34123
21aa923e62ad
Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34120
diff
changeset
|
152 | busy = false; |
|
21aa923e62ad
Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34120
diff
changeset
|
153 | closeAfterBusy = false; |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
154 | |
|
34117
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
155 | reopenWallet(); |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
156 | } |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
157 | |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
158 | void |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
159 | KWalletPlugin::engine::reopenWallet() |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
160 | { |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
161 | if (closing) { |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
162 | purple_debug_error("keyring-kwallet", |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
163 | "wallet is closing right now\n"); |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
164 | failed = true; |
|
34117
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
165 | return; |
|
34110
bda1c52322fe
Keyring: more verbosity, handle kwallet connection errors
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34098
diff
changeset
|
166 | } |
|
34117
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
167 | |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
168 | connected = false; |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
169 | failed = false; |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
170 | externallyClosed = false; |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
171 | |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
172 | wallet = KWallet::Wallet::openWallet(KWALLET_WALLET_NAME, 0, |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
173 | KWallet::Wallet::Asynchronous); |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
174 | if (wallet == NULL) { |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
175 | failed = true; |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
176 | purple_debug_error("keyring-kwallet", |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
177 | "failed opening a wallet\n"); |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
178 | return; |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
179 | } |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
180 | |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
181 | failed |= !connect(wallet, SIGNAL(walletClosed()), |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
182 | SLOT(walletClosed())); |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
183 | failed |= !connect(wallet, SIGNAL(walletOpened(bool)), |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
184 | SLOT(walletOpened(bool))); |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
185 | if (failed) { |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
186 | purple_debug_error("keyring-kwallet", |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
187 | "failed connecting to wallet signal\n"); |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
188 | } |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
189 | } |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
190 | |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
191 | KWalletPlugin::engine::~engine() |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
192 | { |
|
34087
b9798bef2af2
Don't crash if we're closing while the instance is already in the midst
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34085
diff
changeset
|
193 | closing = true; |
|
34127
51c1bce7f52f
Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34126
diff
changeset
|
194 | int abortedCount = 0; |
|
34087
b9798bef2af2
Don't crash if we're closing while the instance is already in the midst
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34085
diff
changeset
|
195 | |
|
34079
fcf75ee4d190
Use a QQueue instead of a STL list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34077
diff
changeset
|
196 | while (!isEmpty()) { |
|
fcf75ee4d190
Use a QQueue instead of a STL list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34077
diff
changeset
|
197 | request *req = dequeue(); |
|
34077
3e4d7e7d3064
Make KWalletPlugin::request class abstract. Unfortunately, this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34076
diff
changeset
|
198 | req->abort(); |
|
3e4d7e7d3064
Make KWalletPlugin::request class abstract. Unfortunately, this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34076
diff
changeset
|
199 | delete req; |
|
34127
51c1bce7f52f
Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34126
diff
changeset
|
200 | abortedCount++; |
|
51c1bce7f52f
Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34126
diff
changeset
|
201 | } |
|
51c1bce7f52f
Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34126
diff
changeset
|
202 | |
|
51c1bce7f52f
Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34126
diff
changeset
|
203 | if (abortedCount > 0) { |
|
51c1bce7f52f
Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34126
diff
changeset
|
204 | purple_debug_info("keyring-kwallet", "aborted requests: %d\n", |
|
51c1bce7f52f
Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34126
diff
changeset
|
205 | abortedCount); |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
206 | } |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
207 | |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
208 | delete wallet; |
|
34117
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
209 | |
|
34123
21aa923e62ad
Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34120
diff
changeset
|
210 | if (pinstance == this) |
|
21aa923e62ad
Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34120
diff
changeset
|
211 | pinstance = NULL; |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
212 | } |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
213 | |
|
34062
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
214 | KWalletPlugin::engine * |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
215 | KWalletPlugin::engine::instance() |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
216 | { |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
217 | if (pinstance == NULL) |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
218 | pinstance = new engine; |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
219 | return pinstance; |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
220 | } |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
221 | |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
222 | void |
|
34117
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
223 | KWalletPlugin::engine::closeInstance() |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
224 | { |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
225 | if (pinstance == NULL) |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
226 | return; |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
227 | if (pinstance->closing) |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
228 | return; |
|
34123
21aa923e62ad
Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34120
diff
changeset
|
229 | if (pinstance->busy) { |
|
21aa923e62ad
Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34120
diff
changeset
|
230 | purple_debug_misc("keyring-kwallet", |
|
21aa923e62ad
Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34120
diff
changeset
|
231 | "current instance is busy, will be freed later\n"); |
|
21aa923e62ad
Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34120
diff
changeset
|
232 | pinstance->closeAfterBusy = true; |
|
21aa923e62ad
Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34120
diff
changeset
|
233 | } else |
|
21aa923e62ad
Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34120
diff
changeset
|
234 | delete pinstance; |
|
21aa923e62ad
Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34120
diff
changeset
|
235 | pinstance = NULL; |
|
34117
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
236 | } |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
237 | |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
238 | void |
|
34067
8643ef2b5bf4
This seems to fix compiling the signal stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34062
diff
changeset
|
239 | KWalletPlugin::engine::walletOpened(bool opened) |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
240 | { |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
241 | connected = opened; |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
242 | |
|
34117
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
243 | if (!opened) { |
|
34127
51c1bce7f52f
Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34126
diff
changeset
|
244 | purple_debug_warning("keyring-kwallet", |
|
51c1bce7f52f
Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34126
diff
changeset
|
245 | "failed to open a wallet\n"); |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
246 | delete this; |
|
34117
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
247 | return; |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
248 | } |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
249 | |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
250 | if (!wallet->hasFolder(KWALLET_FOLDER_NAME)) { |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
251 | if (!wallet->createFolder(KWALLET_FOLDER_NAME)) { |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
252 | purple_debug_error("keyring-kwallet", |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
253 | "couldn't create \"" KWALLET_FOLDER_NAME |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
254 | "\" folder in wallet\n"); |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
255 | failed = true; |
|
34117
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
256 | } |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
257 | } |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
258 | if (!failed) |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
259 | wallet->setFolder(KWALLET_FOLDER_NAME); |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
260 | |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
261 | executeRequests(); |
|
34117
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
262 | } |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
263 | |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
264 | void |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
265 | KWalletPlugin::engine::walletClosed() |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
266 | { |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
267 | if (!closing) { |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
268 | purple_debug_info("keyring-kwallet", |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
269 | "wallet was externally closed\n"); |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
270 | externallyClosed = true; |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
271 | delete wallet; |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
272 | wallet = NULL; |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
273 | } |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
274 | } |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
275 | |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
276 | void |
|
34077
3e4d7e7d3064
Make KWalletPlugin::request class abstract. Unfortunately, this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34076
diff
changeset
|
277 | KWalletPlugin::engine::queue(request *req) |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
278 | { |
|
34079
fcf75ee4d190
Use a QQueue instead of a STL list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34077
diff
changeset
|
279 | enqueue(req); |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
280 | executeRequests(); |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
281 | } |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
282 | |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
283 | void |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
284 | KWalletPlugin::engine::executeRequests() |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
285 | { |
|
34123
21aa923e62ad
Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34120
diff
changeset
|
286 | if (closing || busy) |
|
21aa923e62ad
Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34120
diff
changeset
|
287 | return; |
|
21aa923e62ad
Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34120
diff
changeset
|
288 | busy = true; |
|
34117
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
289 | if (externallyClosed) { |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
290 | reopenWallet(); |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
291 | } else if (connected || failed) { |
|
34079
fcf75ee4d190
Use a QQueue instead of a STL list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34077
diff
changeset
|
292 | while (!isEmpty()) { |
|
fcf75ee4d190
Use a QQueue instead of a STL list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34077
diff
changeset
|
293 | request *req = dequeue(); |
|
34117
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
294 | if (connected) |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
295 | req->execute(wallet); |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
296 | else |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
297 | req->abort(); |
|
34077
3e4d7e7d3064
Make KWalletPlugin::request class abstract. Unfortunately, this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34076
diff
changeset
|
298 | delete req; |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
299 | } |
|
34110
bda1c52322fe
Keyring: more verbosity, handle kwallet connection errors
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34098
diff
changeset
|
300 | } else { |
|
bda1c52322fe
Keyring: more verbosity, handle kwallet connection errors
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34098
diff
changeset
|
301 | purple_debug_misc("keyring-kwallet", "not yet connected\n"); |
|
34062
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
302 | } |
|
34123
21aa923e62ad
Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34120
diff
changeset
|
303 | busy = false; |
|
21aa923e62ad
Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34120
diff
changeset
|
304 | if (closeAfterBusy) { |
|
21aa923e62ad
Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34120
diff
changeset
|
305 | purple_debug_misc("keyring-kwallet", |
|
21aa923e62ad
Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34120
diff
changeset
|
306 | "instance freed after being busy\n"); |
|
21aa923e62ad
Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34120
diff
changeset
|
307 | delete this; |
|
21aa923e62ad
Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34120
diff
changeset
|
308 | } |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
309 | } |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
310 | |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
311 | KWalletPlugin::save_request::save_request(PurpleAccount *acc, const char *pw, |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
312 | PurpleKeyringSaveCallback cb, void *userdata) |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
313 | { |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
314 | account = acc; |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
315 | data = userdata; |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
316 | callback = cb; |
|
34072
5450e39dd3c5
It appears that a QString can be treated as if it were a value type.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34071
diff
changeset
|
317 | password = QString(pw); |
|
34126
a479dca0f05b
Implement removal of KWallet passwords (instead of setting them to blank)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34125
diff
changeset
|
318 | noPassword = (pw == NULL); |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
319 | } |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
320 | |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
321 | KWalletPlugin::read_request::read_request(PurpleAccount *acc, |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
322 | PurpleKeyringReadCallback cb, void *userdata) |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
323 | { |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
324 | account = acc; |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
325 | data = userdata; |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
326 | callback = cb; |
|
34072
5450e39dd3c5
It appears that a QString can be treated as if it were a value type.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34071
diff
changeset
|
327 | password = QString(); |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
328 | } |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
329 | |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
330 | void |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
331 | KWalletPlugin::save_request::detailedAbort(enum PurpleKeyringError error) |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
332 | { |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
333 | GError *gerror; |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
334 | if (callback == NULL) |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
335 | return; |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
336 | |
|
34129
52b91b4b8314
Proper error handling when doing a password migration, fixes reverting it.
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34127
diff
changeset
|
337 | gerror = g_error_new(PURPLE_KEYRING_ERROR, error, |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
338 | "Failed to save password"); |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
339 | callback(account, gerror, data); |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
340 | g_error_free(gerror); |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
341 | } |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
342 | |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
343 | void |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
344 | KWalletPlugin::read_request::detailedAbort(enum PurpleKeyringError error) |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
345 | { |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
346 | GError *gerror; |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
347 | if (callback == NULL) |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
348 | return; |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
349 | |
|
34129
52b91b4b8314
Proper error handling when doing a password migration, fixes reverting it.
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34127
diff
changeset
|
350 | gerror = g_error_new(PURPLE_KEYRING_ERROR, error, |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
351 | "Failed to read password"); |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
352 | callback(account, NULL, gerror, data); |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
353 | g_error_free(gerror); |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
354 | } |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
355 | |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
356 | static QString |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
357 | kwallet_account_key(PurpleAccount *account) |
|
34117
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
358 | { |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
359 | return QString(purple_account_get_protocol_id(account)) + ":" + |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
360 | purple_account_get_username(account); |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
361 | } |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
362 | |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
363 | void |
|
34062
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
364 | KWalletPlugin::read_request::execute(KWallet::Wallet *wallet) |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
365 | { |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
366 | int result; |
|
34117
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
367 | |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
368 | g_return_if_fail(wallet != NULL); |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
369 | |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
370 | result = wallet->readPassword(kwallet_account_key(account), password); |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
371 | |
|
34117
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
372 | if (result != 0) { |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
373 | purple_debug_warning("keyring-kwallet", |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
374 | "failed to read password, result was %d\n", result); |
|
34117
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
375 | abort(); |
|
34110
bda1c52322fe
Keyring: more verbosity, handle kwallet connection errors
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34098
diff
changeset
|
376 | } |
|
34127
51c1bce7f52f
Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34126
diff
changeset
|
377 | else if (callback != NULL) { |
|
51c1bce7f52f
Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34126
diff
changeset
|
378 | purple_debug_misc("keyring-kwallet", |
|
51c1bce7f52f
Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34126
diff
changeset
|
379 | "Got password for account %s (%s).\n", |
|
51c1bce7f52f
Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34126
diff
changeset
|
380 | purple_account_get_username(account), |
|
51c1bce7f52f
Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34126
diff
changeset
|
381 | purple_account_get_protocol_id(account)); |
|
34072
5450e39dd3c5
It appears that a QString can be treated as if it were a value type.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34071
diff
changeset
|
382 | callback(account, password.toUtf8().constData(), NULL, data); |
|
34127
51c1bce7f52f
Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34126
diff
changeset
|
383 | } |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
384 | } |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
385 | |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
386 | void |
|
34062
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
387 | KWalletPlugin::save_request::execute(KWallet::Wallet *wallet) |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
388 | { |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
389 | int result; |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
390 | |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
391 | g_return_if_fail(wallet != NULL); |
|
34110
bda1c52322fe
Keyring: more verbosity, handle kwallet connection errors
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34098
diff
changeset
|
392 | |
|
34126
a479dca0f05b
Implement removal of KWallet passwords (instead of setting them to blank)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34125
diff
changeset
|
393 | if (noPassword) |
|
a479dca0f05b
Implement removal of KWallet passwords (instead of setting them to blank)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34125
diff
changeset
|
394 | result = wallet->removeEntry(kwallet_account_key(account)); |
|
a479dca0f05b
Implement removal of KWallet passwords (instead of setting them to blank)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34125
diff
changeset
|
395 | else { |
|
a479dca0f05b
Implement removal of KWallet passwords (instead of setting them to blank)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34125
diff
changeset
|
396 | result = wallet->writePassword(kwallet_account_key(account), |
|
a479dca0f05b
Implement removal of KWallet passwords (instead of setting them to blank)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34125
diff
changeset
|
397 | password); |
|
a479dca0f05b
Implement removal of KWallet passwords (instead of setting them to blank)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34125
diff
changeset
|
398 | } |
|
34033
910f2ed3988b
Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34032
diff
changeset
|
399 | |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
400 | if (result != 0) { |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
401 | purple_debug_warning("keyring-kwallet", |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
402 | "failed to write password, result was %d\n", result); |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
403 | abort(); |
|
34127
51c1bce7f52f
Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34126
diff
changeset
|
404 | } else if (callback != NULL) { |
|
51c1bce7f52f
Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34126
diff
changeset
|
405 | purple_debug_misc("keyring-kwallet", |
|
51c1bce7f52f
Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34126
diff
changeset
|
406 | "Password %s for account %s (%s).\n", |
|
51c1bce7f52f
Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34126
diff
changeset
|
407 | (noPassword ? "removed" : "saved"), |
|
51c1bce7f52f
Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34126
diff
changeset
|
408 | purple_account_get_username(account), |
|
51c1bce7f52f
Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34126
diff
changeset
|
409 | purple_account_get_protocol_id(account)); |
|
34062
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
410 | callback(account, NULL, data); |
|
34127
51c1bce7f52f
Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34126
diff
changeset
|
411 | } |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
412 | } |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
413 | |
|
34060
1ff15466f569
This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34035
diff
changeset
|
414 | extern "C" |
|
1ff15466f569
This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34035
diff
changeset
|
415 | { |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
416 | |
|
34062
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
417 | static void |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
418 | kwallet_read(PurpleAccount *account, PurpleKeyringReadCallback cb, |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
419 | gpointer data) |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
420 | { |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
421 | KWalletPlugin::read_request *req = |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
422 | new KWalletPlugin::read_request(account, cb, data); |
|
34117
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
423 | |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
424 | if (KWallet::Wallet::keyDoesNotExist(KWALLET_WALLET_NAME, |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
425 | KWALLET_FOLDER_NAME, kwallet_account_key(account))) { |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
426 | req->detailedAbort(PURPLE_KEYRING_ERROR_NOPASSWD); |
|
34117
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
427 | delete req; |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
428 | } |
|
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
429 | else |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
430 | KWalletPlugin::engine::instance()->queue(req); |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
431 | } |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
432 | |
|
34062
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
433 | static void |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
434 | kwallet_save(PurpleAccount *account, const char *password, |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
435 | PurpleKeyringSaveCallback cb, gpointer data) |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
436 | { |
|
34126
a479dca0f05b
Implement removal of KWallet passwords (instead of setting them to blank)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34125
diff
changeset
|
437 | if (password == NULL && KWallet::Wallet::keyDoesNotExist( |
|
a479dca0f05b
Implement removal of KWallet passwords (instead of setting them to blank)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34125
diff
changeset
|
438 | KWALLET_WALLET_NAME, KWALLET_FOLDER_NAME, |
|
a479dca0f05b
Implement removal of KWallet passwords (instead of setting them to blank)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34125
diff
changeset
|
439 | kwallet_account_key(account))) { |
|
a479dca0f05b
Implement removal of KWallet passwords (instead of setting them to blank)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34125
diff
changeset
|
440 | if (cb != NULL) |
|
a479dca0f05b
Implement removal of KWallet passwords (instead of setting them to blank)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34125
diff
changeset
|
441 | cb(account, NULL, data); |
|
a479dca0f05b
Implement removal of KWallet passwords (instead of setting them to blank)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34125
diff
changeset
|
442 | } |
|
a479dca0f05b
Implement removal of KWallet passwords (instead of setting them to blank)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34125
diff
changeset
|
443 | else |
|
a479dca0f05b
Implement removal of KWallet passwords (instead of setting them to blank)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34125
diff
changeset
|
444 | KWalletPlugin::engine::instance()->queue( |
|
a479dca0f05b
Implement removal of KWallet passwords (instead of setting them to blank)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34125
diff
changeset
|
445 | new KWalletPlugin::save_request(account, password, cb, |
|
a479dca0f05b
Implement removal of KWallet passwords (instead of setting them to blank)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34125
diff
changeset
|
446 | data)); |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
447 | } |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
448 | |
|
34062
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
449 | static void |
|
34034
f508fa47f2ac
Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34033
diff
changeset
|
450 | kwallet_close(GError **error) |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
451 | { |
|
34117
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
452 | KWalletPlugin::engine::closeInstance(); |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
453 | } |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
454 | |
|
34062
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
455 | static gboolean |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
456 | kwallet_import(PurpleAccount *account, const char *mode, const char *data, |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
457 | GError **error) |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
458 | { |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
459 | return TRUE; |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
460 | } |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
461 | |
|
34062
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
462 | static gboolean |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
463 | kwallet_export(PurpleAccount *account, const char **mode, char **data, |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
464 | GError **error, GDestroyNotify *destroy) |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
465 | { |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
466 | *mode = NULL; |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
467 | *data = NULL; |
|
34073
5da1137555a8
There seems to be an asterisk missing here.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34072
diff
changeset
|
468 | *destroy = NULL; |
|
34062
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
469 | |
|
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
470 | return TRUE; |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
471 | } |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
472 | |
|
34062
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
473 | static gboolean |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
474 | kwallet_load(PurplePlugin *plugin) |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
475 | { |
|
34119
8852b9a4dd2a
Better usage of QCoreApplication
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34118
diff
changeset
|
476 | if (!qCoreApp) { |
|
8852b9a4dd2a
Better usage of QCoreApplication
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34118
diff
changeset
|
477 | int argc = 0; |
|
8852b9a4dd2a
Better usage of QCoreApplication
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34118
diff
changeset
|
478 | qCoreApp = new QCoreApplication(argc, NULL); |
|
8852b9a4dd2a
Better usage of QCoreApplication
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34118
diff
changeset
|
479 | qCoreApp->setApplicationName(KWALLET_APP_NAME); |
|
8852b9a4dd2a
Better usage of QCoreApplication
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34118
diff
changeset
|
480 | } |
|
8852b9a4dd2a
Better usage of QCoreApplication
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34118
diff
changeset
|
481 | |
|
34120
50bc553c8c52
Handle the case of disabled KWallet system
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34119
diff
changeset
|
482 | if (!kwallet_is_enabled()) { |
|
50bc553c8c52
Handle the case of disabled KWallet system
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34119
diff
changeset
|
483 | purple_debug_info("keyring-kwallet", |
|
50bc553c8c52
Handle the case of disabled KWallet system
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34119
diff
changeset
|
484 | "KWallet service is disabled\n"); |
|
50bc553c8c52
Handle the case of disabled KWallet system
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34119
diff
changeset
|
485 | return FALSE; |
|
50bc553c8c52
Handle the case of disabled KWallet system
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34119
diff
changeset
|
486 | } |
|
50bc553c8c52
Handle the case of disabled KWallet system
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34119
diff
changeset
|
487 | |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
488 | keyring_handler = purple_keyring_new(); |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
489 | |
|
34060
1ff15466f569
This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34035
diff
changeset
|
490 | purple_keyring_set_name(keyring_handler, KWALLET_NAME); |
|
1ff15466f569
This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34035
diff
changeset
|
491 | purple_keyring_set_id(keyring_handler, KWALLET_ID); |
|
1ff15466f569
This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34035
diff
changeset
|
492 | purple_keyring_set_read_password(keyring_handler, kwallet_read); |
|
1ff15466f569
This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34035
diff
changeset
|
493 | purple_keyring_set_save_password(keyring_handler, kwallet_save); |
|
1ff15466f569
This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34035
diff
changeset
|
494 | purple_keyring_set_close_keyring(keyring_handler, kwallet_close); |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
495 | /* purple_keyring_set_change_master */ |
|
34062
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
496 | purple_keyring_set_import_password(keyring_handler, kwallet_import); |
|
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
497 | purple_keyring_set_export_password(keyring_handler, kwallet_export); |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
498 | |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
499 | purple_keyring_register(keyring_handler); |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
500 | |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
501 | return TRUE; |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
502 | } |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
503 | |
|
34062
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
504 | static gboolean |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
505 | kwallet_unload(PurplePlugin *plugin) |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
506 | { |
|
34117
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
507 | if (purple_keyring_get_inuse() == keyring_handler) { |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
508 | purple_debug_warning("keyring-kwallet", |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
509 | "keyring in use, cannot unload\n"); |
|
34096
3d28c3311ad0
Don't allow unloading a plugin if its keyring is active.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34095
diff
changeset
|
510 | return FALSE; |
|
34117
543818e9829a
Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34116
diff
changeset
|
511 | } |
|
34096
3d28c3311ad0
Don't allow unloading a plugin if its keyring is active.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34095
diff
changeset
|
512 | |
|
34062
7879224489fd
Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34061
diff
changeset
|
513 | kwallet_close(NULL); |
|
34096
3d28c3311ad0
Don't allow unloading a plugin if its keyring is active.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34095
diff
changeset
|
514 | |
|
34125
34c3dbf12e95
Fix some memleaks
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34123
diff
changeset
|
515 | purple_keyring_unregister(keyring_handler); |
|
34097
f6f36bfbe951
Free the keyring when the KWallet plugin is unloaded.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34096
diff
changeset
|
516 | purple_keyring_free(keyring_handler); |
|
f6f36bfbe951
Free the keyring when the KWallet plugin is unloaded.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34096
diff
changeset
|
517 | keyring_handler = NULL; |
|
f6f36bfbe951
Free the keyring when the KWallet plugin is unloaded.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34096
diff
changeset
|
518 | |
|
34119
8852b9a4dd2a
Better usage of QCoreApplication
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34118
diff
changeset
|
519 | if (qCoreApp) { |
|
8852b9a4dd2a
Better usage of QCoreApplication
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34118
diff
changeset
|
520 | delete qCoreApp; |
|
8852b9a4dd2a
Better usage of QCoreApplication
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34118
diff
changeset
|
521 | qCoreApp = NULL; |
|
8852b9a4dd2a
Better usage of QCoreApplication
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34118
diff
changeset
|
522 | } |
|
8852b9a4dd2a
Better usage of QCoreApplication
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34118
diff
changeset
|
523 | |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
524 | return TRUE; |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
525 | } |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
526 | |
|
34060
1ff15466f569
This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34035
diff
changeset
|
527 | PurplePluginInfo plugininfo = |
|
1ff15466f569
This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34035
diff
changeset
|
528 | { |
|
34118
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
529 | PURPLE_PLUGIN_MAGIC, /* magic */ |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
530 | PURPLE_MAJOR_VERSION, /* major_version */ |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
531 | PURPLE_MINOR_VERSION, /* minor_version */ |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
532 | PURPLE_PLUGIN_STANDARD, /* type */ |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
533 | NULL, /* ui_requirement */ |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
534 | PURPLE_PLUGIN_FLAG_INVISIBLE, /* flags */ |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
535 | NULL, /* dependencies */ |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
536 | PURPLE_PRIORITY_DEFAULT, /* priority */ |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
537 | (char*)KWALLET_ID, /* id */ |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
538 | (char*)KWALLET_NAME, /* name */ |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
539 | (char*)DISPLAY_VERSION, /* version */ |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
540 | (char*)"KWallet Keyring Plugin", /* summary */ |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
541 | (char*)KWALLET_DESCRIPTION, /* description */ |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
542 | (char*)KWALLET_AUTHOR, /* author */ |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
543 | (char*)PURPLE_WEBSITE, /* homepage */ |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
544 | kwallet_load, /* load */ |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
545 | kwallet_unload, /* unload */ |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
546 | NULL, /* destroy */ |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
547 | NULL, /* ui_info */ |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
548 | NULL, /* extra_info */ |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
549 | NULL, /* prefs_info */ |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
550 | NULL, /* actions */ |
|
a83c82be880d
Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34117
diff
changeset
|
551 | NULL, NULL, NULL, NULL /* padding */ |
|
34060
1ff15466f569
This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34035
diff
changeset
|
552 | }; |
|
1ff15466f569
This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34035
diff
changeset
|
553 | |
|
34116
825c98f8c7f6
Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34114
diff
changeset
|
554 | static void |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
555 | init_plugin(PurplePlugin *plugin) |
|
34033
910f2ed3988b
Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34032
diff
changeset
|
556 | { |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
557 | } |
|
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
558 | |
|
34060
1ff15466f569
This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34035
diff
changeset
|
559 | PURPLE_INIT_PLUGIN(kwallet_keyring, init_plugin, plugininfo) |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
560 | |
|
34060
1ff15466f569
This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34035
diff
changeset
|
561 | } /* extern "C" */ |
|
34005
592e6e8213a9
Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff
changeset
|
562 | |
|
34084
e94dd262b20a
Fix signal handling. On this side, it's a slot, not a signal.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34081
diff
changeset
|
563 | #include "kwallet.moc" |