libpurple/plugins/keyrings/kwallet.cpp

Wed, 07 Aug 2013 03:47:13 +0530

author
Ankit Vani <a@nevitus.org>
date
Wed, 07 Aug 2013 03:47:13 +0530
branch
soc.2013.gobjectification.plugins
changeset 36459
b52f5391d12d
parent 36367
891eea799578
parent 34281
ad957d0a467a
child 36502
dfce617913fe
permissions
-rw-r--r--

Merged soc.2013.gobjectification branch

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 */
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
5
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
6 /* purple
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 * 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
9 * 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
10 * source distribution.
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
11 *
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
12 * 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
13 * 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
14 * 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
15 * (at your option) any later version.
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
16 *
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
17 * 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
18 * 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
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
20 * GNU General Public License for more details.
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
21 *
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
22 * 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
23 * 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
24 * 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
25 */
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
26
34076
64e389ae5cc3 Clean up headers and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34073
diff changeset
27 #include "internal.h"
64e389ae5cc3 Clean up headers and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34073
diff changeset
28 #include "account.h"
34146
99bad5c80d1e More password wiping, better password management withing account.c, using actual UI name with KWallet
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34145
diff changeset
29 #include "core.h"
34076
64e389ae5cc3 Clean up headers and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34073
diff changeset
30 #include "debug.h"
64e389ae5cc3 Clean up headers and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34073
diff changeset
31 #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
32 #include "plugins.h"
34076
64e389ae5cc3 Clean up headers and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34073
diff changeset
33 #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
34
34079
fcf75ee4d190 Use a QQueue instead of a STL list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34077
diff changeset
35 #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
36 #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
37 #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
38
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 #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
40 #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
41 #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
42 #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
43
34117
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
44 #define KWALLET_WALLET_NAME KWallet::Wallet::NetworkWallet()
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
45 #define KWALLET_APP_NAME "Libpurple"
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
46 #define KWALLET_FOLDER_NAME "libpurple"
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
47
34097
f6f36bfbe951 Free the keyring when the KWallet plugin is unloaded.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34096
diff changeset
48 PurpleKeyring *keyring_handler = NULL;
34119
8852b9a4dd2a Better usage of QCoreApplication
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34118
diff changeset
49 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
50
34060
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
51 namespace KWalletPlugin {
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
52
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
53 class request
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 public:
34114
c915903f6e43 Get rid of warnings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
56 virtual ~request();
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
57 virtual void detailedAbort(enum PurpleKeyringError error) = 0;
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
58 void abort();
34077
3e4d7e7d3064 Make KWalletPlugin::request class abstract. Unfortunately, this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34076
diff changeset
59 virtual void execute(KWallet::Wallet *wallet) = 0;
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
60
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
61 protected:
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
62 gpointer data;
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
63 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
64 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
65 bool noPassword;
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
66 };
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
67
34079
fcf75ee4d190 Use a QQueue instead of a STL list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34077
diff changeset
68 class engine : private QObject, private QQueue<request*>
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
69 {
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
70 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
71
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
72 public:
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
73 engine();
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
74 ~engine();
34077
3e4d7e7d3064 Make KWalletPlugin::request class abstract. Unfortunately, this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34076
diff changeset
75 void queue(request *req);
34139
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
76 void abortAll();
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
77 static engine *instance(bool create);
34155
567c48f9658c Refactor the keyring API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34154
diff changeset
78 static void closeInstance(void);
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
79
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
80 private slots:
34067
8643ef2b5bf4 This seems to fix compiling the signal stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34062
diff changeset
81 void walletOpened(bool opened);
34117
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
82 void walletClosed();
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
83
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
84 private:
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
85 static engine *pinstance;
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
86
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
87 bool connected;
34110
bda1c52322fe Keyring: more verbosity, handle kwallet connection errors
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34098
diff changeset
88 bool failed;
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
89 bool closing;
34117
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
90 bool externallyClosed;
34123
21aa923e62ad Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34120
diff changeset
91 bool busy;
21aa923e62ad Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34120
diff changeset
92 bool closeAfterBusy;
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
93
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
94 KWallet::Wallet *wallet;
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
95
34117
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
96 void reopenWallet();
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
97 void executeRequests();
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
98 };
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
99
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
100 class save_request : public request
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
101 {
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
102 public:
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
103 save_request(PurpleAccount *account, const char *password,
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
104 PurpleKeyringSaveCallback cb, void *data);
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
105 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
106 void execute(KWallet::Wallet *wallet);
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
107
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
108 private:
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
109 PurpleKeyringSaveCallback callback;
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
110 };
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 class read_request : public request
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
113 {
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
114 public:
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
115 read_request(PurpleAccount *account,
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
116 PurpleKeyringReadCallback cb, void *data);
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
117 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
118 void execute(KWallet::Wallet *wallet);
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
119
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
120 private:
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
121 PurpleKeyringReadCallback callback;
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
122 };
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
34120
50bc553c8c52 Handle the case of disabled KWallet system
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34119
diff changeset
126 static gboolean
50bc553c8c52 Handle the case of disabled KWallet system
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34119
diff changeset
127 kwallet_is_enabled(void)
50bc553c8c52 Handle the case of disabled KWallet system
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34119
diff changeset
128 {
50bc553c8c52 Handle the case of disabled KWallet system
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34119
diff changeset
129 return KWallet::Wallet::isEnabled() ? TRUE : FALSE;
50bc553c8c52 Handle the case of disabled KWallet system
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34119
diff changeset
130 }
50bc553c8c52 Handle the case of disabled KWallet system
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34119
diff changeset
131
34080
098a43dd4835 Initialize pinstance.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34079
diff changeset
132 KWalletPlugin::engine *KWalletPlugin::engine::pinstance = NULL;
098a43dd4835 Initialize pinstance.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34079
diff changeset
133
34114
c915903f6e43 Get rid of warnings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
134 KWalletPlugin::request::~request()
c915903f6e43 Get rid of warnings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34110
diff changeset
135 {
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
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
138 void
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
139 KWalletPlugin::request::abort()
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
140 {
34154
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34152
diff changeset
141 detailedAbort(PURPLE_KEYRING_ERROR_CANCELLED);
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
142 }
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
143
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
144 KWalletPlugin::engine::engine()
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
145 {
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
146 connected = false;
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
147 failed = false;
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
148 closing = false;
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
149 externallyClosed = false;
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
150 wallet = NULL;
34123
21aa923e62ad Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34120
diff changeset
151 busy = false;
21aa923e62ad Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34120
diff changeset
152 closeAfterBusy = false;
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
153
34117
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
154 reopenWallet();
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
155 }
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 void
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
158 KWalletPlugin::engine::reopenWallet()
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
159 {
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
160 if (closing) {
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
161 purple_debug_error("keyring-kwallet",
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
162 "wallet is closing right now\n");
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
163 failed = true;
34117
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
164 return;
34110
bda1c52322fe Keyring: more verbosity, handle kwallet connection errors
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34098
diff changeset
165 }
34117
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
166
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
167 connected = false;
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
168 failed = false;
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
169 externallyClosed = false;
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
170
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
171 wallet = KWallet::Wallet::openWallet(KWALLET_WALLET_NAME, 0,
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
172 KWallet::Wallet::Asynchronous);
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
173 if (wallet == NULL) {
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
174 failed = true;
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
175 purple_debug_error("keyring-kwallet",
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
176 "failed opening a wallet\n");
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
177 return;
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
178 }
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 failed |= !connect(wallet, SIGNAL(walletClosed()),
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
181 SLOT(walletClosed()));
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
182 failed |= !connect(wallet, SIGNAL(walletOpened(bool)),
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
183 SLOT(walletOpened(bool)));
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
184 if (failed) {
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
185 purple_debug_error("keyring-kwallet",
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
186 "failed connecting to wallet signal\n");
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
187 }
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
188 }
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 KWalletPlugin::engine::~engine()
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
191 {
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
192 closing = true;
34139
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
193
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
194 abortAll();
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
195
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
196 delete wallet;
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
197
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
198 if (pinstance == this)
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
199 pinstance = NULL;
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
200 }
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
201
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
202 void
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
203 KWalletPlugin::engine::abortAll()
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
204 {
34127
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
205 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
206
34079
fcf75ee4d190 Use a QQueue instead of a STL list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34077
diff changeset
207 while (!isEmpty()) {
fcf75ee4d190 Use a QQueue instead of a STL list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34077
diff changeset
208 request *req = dequeue();
34077
3e4d7e7d3064 Make KWalletPlugin::request class abstract. Unfortunately, this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34076
diff changeset
209 req->abort();
3e4d7e7d3064 Make KWalletPlugin::request class abstract. Unfortunately, this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34076
diff changeset
210 delete req;
34127
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
211 abortedCount++;
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
212 }
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
213
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
214 if (abortedCount > 0) {
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
215 purple_debug_info("keyring-kwallet", "aborted requests: %d\n",
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
216 abortedCount);
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
217 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
218 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
219
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
220 KWalletPlugin::engine *
34139
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
221 KWalletPlugin::engine::instance(bool create)
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
222 {
34139
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
223 if (pinstance == NULL && create)
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
224 pinstance = new engine;
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
225 return pinstance;
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
226 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
227
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
228 void
34155
567c48f9658c Refactor the keyring API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34154
diff changeset
229 KWalletPlugin::engine::closeInstance(void)
34117
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
230 {
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
231 if (pinstance == NULL)
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
232 return;
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
233 if (pinstance->closing)
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
234 return;
34123
21aa923e62ad Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34120
diff changeset
235 if (pinstance->busy) {
21aa923e62ad Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34120
diff changeset
236 purple_debug_misc("keyring-kwallet",
21aa923e62ad Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34120
diff changeset
237 "current instance is busy, will be freed later\n");
21aa923e62ad Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34120
diff changeset
238 pinstance->closeAfterBusy = true;
21aa923e62ad Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34120
diff changeset
239 } else
21aa923e62ad Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34120
diff changeset
240 delete pinstance;
21aa923e62ad Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34120
diff changeset
241 pinstance = NULL;
34117
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
242 }
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
243
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
244 void
34067
8643ef2b5bf4 This seems to fix compiling the signal stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34062
diff changeset
245 KWalletPlugin::engine::walletOpened(bool opened)
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
246 {
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
247 connected = opened;
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
248
34117
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
249 if (!opened) {
34127
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
250 purple_debug_warning("keyring-kwallet",
51c1bce7f52f Tidying debug messages, signals
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34126
diff changeset
251 "failed to open a wallet\n");
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
252 delete this;
34117
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
253 return;
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
254 }
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
255
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
256 if (!wallet->hasFolder(KWALLET_FOLDER_NAME)) {
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
257 if (!wallet->createFolder(KWALLET_FOLDER_NAME)) {
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
258 purple_debug_error("keyring-kwallet",
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
259 "couldn't create \"" KWALLET_FOLDER_NAME
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
260 "\" folder in wallet\n");
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
261 failed = true;
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 if (!failed)
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
265 wallet->setFolder(KWALLET_FOLDER_NAME);
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
266
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
267 executeRequests();
34117
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
268 }
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
269
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
270 void
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
271 KWalletPlugin::engine::walletClosed()
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
272 {
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
273 if (!closing) {
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
274 purple_debug_info("keyring-kwallet",
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
275 "wallet was externally closed\n");
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
276 externallyClosed = true;
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
277 delete wallet;
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
278 wallet = NULL;
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
279 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
280 }
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 void
34077
3e4d7e7d3064 Make KWalletPlugin::request class abstract. Unfortunately, this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34076
diff changeset
283 KWalletPlugin::engine::queue(request *req)
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
284 {
34079
fcf75ee4d190 Use a QQueue instead of a STL list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34077
diff changeset
285 enqueue(req);
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
286 executeRequests();
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
287 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
288
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
289 void
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
290 KWalletPlugin::engine::executeRequests()
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
291 {
34123
21aa923e62ad Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34120
diff changeset
292 if (closing || busy)
21aa923e62ad Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34120
diff changeset
293 return;
21aa923e62ad Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34120
diff changeset
294 busy = true;
34117
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
295 if (externallyClosed) {
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
296 reopenWallet();
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
297 } 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
298 while (!isEmpty()) {
fcf75ee4d190 Use a QQueue instead of a STL list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34077
diff changeset
299 request *req = dequeue();
34117
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
300 if (connected)
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
301 req->execute(wallet);
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
302 else
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
303 req->abort();
34077
3e4d7e7d3064 Make KWalletPlugin::request class abstract. Unfortunately, this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34076
diff changeset
304 delete req;
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
305 }
34145
fa72f1e5cd77 Some polishing on files modified on this branch (mostly formatting)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34139
diff changeset
306 } else if (purple_debug_is_verbose()) {
34110
bda1c52322fe Keyring: more verbosity, handle kwallet connection errors
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34098
diff changeset
307 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
308 }
34123
21aa923e62ad Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34120
diff changeset
309 busy = false;
21aa923e62ad Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34120
diff changeset
310 if (closeAfterBusy) {
21aa923e62ad Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34120
diff changeset
311 purple_debug_misc("keyring-kwallet",
21aa923e62ad Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34120
diff changeset
312 "instance freed after being busy\n");
21aa923e62ad Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34120
diff changeset
313 delete this;
21aa923e62ad Fix use-after-free
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34120
diff changeset
314 }
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
315 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
316
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
317 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
318 PurpleKeyringSaveCallback cb, void *userdata)
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
319 {
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
320 account = acc;
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
321 data = userdata;
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
322 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
323 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
324 noPassword = (pw == NULL);
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
325 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
326
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
327 KWalletPlugin::read_request::read_request(PurpleAccount *acc,
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
328 PurpleKeyringReadCallback cb, void *userdata)
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
329 {
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
330 account = acc;
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
331 data = userdata;
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
332 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
333 password = QString();
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
334 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
335
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
336 void
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
337 KWalletPlugin::save_request::detailedAbort(enum PurpleKeyringError error)
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
338 {
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
339 GError *gerror;
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
340 if (callback == NULL)
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
341 return;
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
342
34129
52b91b4b8314 Proper error handling when doing a password migration, fixes reverting it.
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34127
diff changeset
343 gerror = g_error_new(PURPLE_KEYRING_ERROR, error,
34199
73d122f25f2b Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34174
diff changeset
344 _("Failed to save password."));
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
345 callback(account, gerror, data);
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
346 g_error_free(gerror);
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
347 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
348
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
349 void
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
350 KWalletPlugin::read_request::detailedAbort(enum PurpleKeyringError error)
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
351 {
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
352 GError *gerror;
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
353 if (callback == NULL)
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
354 return;
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
355
34129
52b91b4b8314 Proper error handling when doing a password migration, fixes reverting it.
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34127
diff changeset
356 gerror = g_error_new(PURPLE_KEYRING_ERROR, error,
34199
73d122f25f2b Localize strings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34174
diff changeset
357 _("Failed to read password."));
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
358 callback(account, NULL, gerror, data);
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
359 g_error_free(gerror);
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
360 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
361
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
362 static QString
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
363 kwallet_account_key(PurpleAccount *account)
34117
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
364 {
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
365 return QString(purple_account_get_protocol_id(account)) + ":" +
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
366 purple_account_get_username(account);
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
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
369 void
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
370 KWalletPlugin::read_request::execute(KWallet::Wallet *wallet)
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
371 {
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
372 int result;
34117
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
373
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
374 g_return_if_fail(wallet != NULL);
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
375
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
376 result = wallet->readPassword(kwallet_account_key(account), password);
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
377
34117
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
378 if (result != 0) {
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
379 purple_debug_warning("keyring-kwallet",
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
380 "failed to read password, result was %d\n", result);
34117
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
381 abort();
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34134
diff changeset
382 return;
34110
bda1c52322fe Keyring: more verbosity, handle kwallet connection errors
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34098
diff changeset
383 }
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34134
diff changeset
384
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34134
diff changeset
385 purple_debug_misc("keyring-kwallet",
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34134
diff changeset
386 "Got password for account %s (%s).\n",
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34134
diff changeset
387 purple_account_get_username(account),
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34134
diff changeset
388 purple_account_get_protocol_id(account));
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34134
diff changeset
389
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34134
diff changeset
390 if (callback != NULL)
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
391 callback(account, password.toUtf8().constData(), NULL, data);
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
392 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
393
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
394 void
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
395 KWalletPlugin::save_request::execute(KWallet::Wallet *wallet)
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
396 {
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
397 int result;
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
398
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
399 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
400
34126
a479dca0f05b Implement removal of KWallet passwords (instead of setting them to blank)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34125
diff changeset
401 if (noPassword)
a479dca0f05b Implement removal of KWallet passwords (instead of setting them to blank)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34125
diff changeset
402 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
403 else {
a479dca0f05b Implement removal of KWallet passwords (instead of setting them to blank)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34125
diff changeset
404 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
405 password);
a479dca0f05b Implement removal of KWallet passwords (instead of setting them to blank)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34125
diff changeset
406 }
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
407
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
408 if (result != 0) {
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
409 purple_debug_warning("keyring-kwallet",
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
410 "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
411 abort();
34136
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34134
diff changeset
412 return;
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34134
diff changeset
413 }
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34134
diff changeset
414
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34134
diff changeset
415 purple_debug_misc("keyring-kwallet",
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34134
diff changeset
416 "Password %s for account %s (%s).\n",
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34134
diff changeset
417 (noPassword ? "removed" : "saved"),
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34134
diff changeset
418 purple_account_get_username(account),
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34134
diff changeset
419 purple_account_get_protocol_id(account));
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34134
diff changeset
420
e9722a935271 Re-implemented GNOME Keyring plugin
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34134
diff changeset
421 if (callback != NULL)
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
422 callback(account, NULL, data);
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
423 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
424
34060
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
425 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
426 {
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
427
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
428 static void
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
429 kwallet_read(PurpleAccount *account, PurpleKeyringReadCallback cb,
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
430 gpointer data)
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
431 {
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
432 KWalletPlugin::read_request *req =
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
433 new KWalletPlugin::read_request(account, cb, data);
34117
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
434
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
435 if (KWallet::Wallet::keyDoesNotExist(KWALLET_WALLET_NAME,
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
436 KWALLET_FOLDER_NAME, kwallet_account_key(account))) {
34154
857c361d3791 Refine keyring error coded
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34152
diff changeset
437 req->detailedAbort(PURPLE_KEYRING_ERROR_NOPASSWORD);
34117
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
438 delete req;
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
439 }
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
440 else
34139
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
441 KWalletPlugin::engine::instance(true)->queue(req);
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
442 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
443
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
444 static void
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
445 kwallet_save(PurpleAccount *account, const char *password,
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
446 PurpleKeyringSaveCallback cb, gpointer data)
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
447 {
34126
a479dca0f05b Implement removal of KWallet passwords (instead of setting them to blank)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34125
diff changeset
448 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
449 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
450 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
451 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
452 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
453 }
a479dca0f05b Implement removal of KWallet passwords (instead of setting them to blank)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34125
diff changeset
454 else
34139
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
455 KWalletPlugin::engine::instance(true)->queue(
34126
a479dca0f05b Implement removal of KWallet passwords (instead of setting them to blank)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34125
diff changeset
456 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
457 data));
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
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
460 static void
34139
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
461 kwallet_cancel(void)
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
462 {
34170
94102637e7c7 Coding style and entry description for GNOME Keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
463 KWalletPlugin::engine *instance =
94102637e7c7 Coding style and entry description for GNOME Keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
464 KWalletPlugin::engine::instance(false);
34139
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
465 if (instance)
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
466 instance->abortAll();
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
467 }
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
468
34146
99bad5c80d1e More password wiping, better password management withing account.c, using actual UI name with KWallet
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34145
diff changeset
469 static void *
99bad5c80d1e More password wiping, better password management withing account.c, using actual UI name with KWallet
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34145
diff changeset
470 kwallet_get_handle(void)
99bad5c80d1e More password wiping, better password management withing account.c, using actual UI name with KWallet
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34145
diff changeset
471 {
99bad5c80d1e More password wiping, better password management withing account.c, using actual UI name with KWallet
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34145
diff changeset
472 static int handle;
99bad5c80d1e More password wiping, better password management withing account.c, using actual UI name with KWallet
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34145
diff changeset
473
99bad5c80d1e More password wiping, better password management withing account.c, using actual UI name with KWallet
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34145
diff changeset
474 return &handle;
99bad5c80d1e More password wiping, better password management withing account.c, using actual UI name with KWallet
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34145
diff changeset
475 }
99bad5c80d1e More password wiping, better password management withing account.c, using actual UI name with KWallet
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34145
diff changeset
476
34152
524edcbc83cb Use purple_core_get_ui_info instead of g_get_application_name
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34146
diff changeset
477 static const char *kwallet_get_ui_name(void)
34146
99bad5c80d1e More password wiping, better password management withing account.c, using actual UI name with KWallet
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34145
diff changeset
478 {
34152
524edcbc83cb Use purple_core_get_ui_info instead of g_get_application_name
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34146
diff changeset
479 GHashTable *ui_info;
524edcbc83cb Use purple_core_get_ui_info instead of g_get_application_name
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34146
diff changeset
480 const char *ui_name = NULL;
524edcbc83cb Use purple_core_get_ui_info instead of g_get_application_name
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34146
diff changeset
481
524edcbc83cb Use purple_core_get_ui_info instead of g_get_application_name
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34146
diff changeset
482 ui_info = purple_core_get_ui_info();
524edcbc83cb Use purple_core_get_ui_info instead of g_get_application_name
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34146
diff changeset
483 if (ui_info != NULL)
524edcbc83cb Use purple_core_get_ui_info instead of g_get_application_name
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34146
diff changeset
484 ui_name = (const char*)g_hash_table_lookup(ui_info, "name");
524edcbc83cb Use purple_core_get_ui_info instead of g_get_application_name
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34146
diff changeset
485 if (ui_name == NULL)
524edcbc83cb Use purple_core_get_ui_info instead of g_get_application_name
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34146
diff changeset
486 ui_name = KWALLET_APP_NAME;
524edcbc83cb Use purple_core_get_ui_info instead of g_get_application_name
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34146
diff changeset
487
524edcbc83cb Use purple_core_get_ui_info instead of g_get_application_name
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34146
diff changeset
488 return ui_name;
34146
99bad5c80d1e More password wiping, better password management withing account.c, using actual UI name with KWallet
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34145
diff changeset
489 }
99bad5c80d1e More password wiping, better password management withing account.c, using actual UI name with KWallet
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34145
diff changeset
490
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
491 static gboolean
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
492 kwallet_load(PurplePlugin *plugin)
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
493 {
34119
8852b9a4dd2a Better usage of QCoreApplication
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34118
diff changeset
494 if (!qCoreApp) {
8852b9a4dd2a Better usage of QCoreApplication
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34118
diff changeset
495 int argc = 0;
8852b9a4dd2a Better usage of QCoreApplication
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34118
diff changeset
496 qCoreApp = new QCoreApplication(argc, NULL);
34152
524edcbc83cb Use purple_core_get_ui_info instead of g_get_application_name
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34146
diff changeset
497 qCoreApp->setApplicationName(kwallet_get_ui_name());
34119
8852b9a4dd2a Better usage of QCoreApplication
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34118
diff changeset
498 }
8852b9a4dd2a Better usage of QCoreApplication
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34118
diff changeset
499
34120
50bc553c8c52 Handle the case of disabled KWallet system
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34119
diff changeset
500 if (!kwallet_is_enabled()) {
50bc553c8c52 Handle the case of disabled KWallet system
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34119
diff changeset
501 purple_debug_info("keyring-kwallet",
50bc553c8c52 Handle the case of disabled KWallet system
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34119
diff changeset
502 "KWallet service is disabled\n");
50bc553c8c52 Handle the case of disabled KWallet system
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34119
diff changeset
503 return FALSE;
50bc553c8c52 Handle the case of disabled KWallet system
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34119
diff changeset
504 }
50bc553c8c52 Handle the case of disabled KWallet system
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34119
diff changeset
505
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
506 keyring_handler = purple_keyring_new();
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
507
34281
ad957d0a467a Keyring (and some GTK): fix translation callbacks
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34199
diff changeset
508 purple_keyring_set_name(keyring_handler, _(KWALLET_NAME));
34060
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
509 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
510 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
511 purple_keyring_set_save_password(keyring_handler, kwallet_save);
34139
37d7d0e22484 Revert existing password migration at exit, allow cancelling kwallet requests
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34136
diff changeset
512 purple_keyring_set_cancel_requests(keyring_handler, kwallet_cancel);
34170
94102637e7c7 Coding style and entry description for GNOME Keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
513 purple_keyring_set_close_keyring(keyring_handler,
94102637e7c7 Coding style and entry description for GNOME Keyring
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
514 KWalletPlugin::engine::closeInstance);
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
515
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
516 purple_keyring_register(keyring_handler);
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
517
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
518 return TRUE;
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
519 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
520
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
521 static gboolean
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
522 kwallet_unload(PurplePlugin *plugin)
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
523 {
34117
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
524 if (purple_keyring_get_inuse() == keyring_handler) {
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
525 purple_debug_warning("keyring-kwallet",
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
526 "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
527 return FALSE;
34117
543818e9829a Better Kwallet integration
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34116
diff changeset
528 }
34096
3d28c3311ad0 Don't allow unloading a plugin if its keyring is active.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34095
diff changeset
529
34146
99bad5c80d1e More password wiping, better password management withing account.c, using actual UI name with KWallet
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34145
diff changeset
530 purple_signals_disconnect_by_handle(kwallet_get_handle());
99bad5c80d1e More password wiping, better password management withing account.c, using actual UI name with KWallet
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34145
diff changeset
531
34155
567c48f9658c Refactor the keyring API
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34154
diff changeset
532 KWalletPlugin::engine::closeInstance();
34096
3d28c3311ad0 Don't allow unloading a plugin if its keyring is active.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34095
diff changeset
533
34125
34c3dbf12e95 Fix some memleaks
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34123
diff changeset
534 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
535 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
536 keyring_handler = NULL;
f6f36bfbe951 Free the keyring when the KWallet plugin is unloaded.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34096
diff changeset
537
34119
8852b9a4dd2a Better usage of QCoreApplication
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34118
diff changeset
538 if (qCoreApp) {
8852b9a4dd2a Better usage of QCoreApplication
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34118
diff changeset
539 delete qCoreApp;
8852b9a4dd2a Better usage of QCoreApplication
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34118
diff changeset
540 qCoreApp = NULL;
8852b9a4dd2a Better usage of QCoreApplication
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34118
diff changeset
541 }
8852b9a4dd2a Better usage of QCoreApplication
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34118
diff changeset
542
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
543 return TRUE;
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
544 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
545
34060
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
546 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
547 {
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
548 PURPLE_PLUGIN_MAGIC, /* magic */
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
549 PURPLE_MAJOR_VERSION, /* major_version */
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
550 PURPLE_MINOR_VERSION, /* minor_version */
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
551 PURPLE_PLUGIN_STANDARD, /* type */
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
552 NULL, /* ui_requirement */
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
553 PURPLE_PLUGIN_FLAG_INVISIBLE, /* flags */
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
554 NULL, /* dependencies */
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
555 PURPLE_PRIORITY_DEFAULT, /* priority */
34174
b9e24fbc6e29 Don't cast const gchar* to gchar*
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34170
diff changeset
556 KWALLET_ID, /* id */
b9e24fbc6e29 Don't cast const gchar* to gchar*
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34170
diff changeset
557 KWALLET_NAME, /* name */
b9e24fbc6e29 Don't cast const gchar* to gchar*
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34170
diff changeset
558 DISPLAY_VERSION, /* version */
b9e24fbc6e29 Don't cast const gchar* to gchar*
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34170
diff changeset
559 "KWallet Keyring Plugin", /* summary */
b9e24fbc6e29 Don't cast const gchar* to gchar*
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34170
diff changeset
560 KWALLET_DESCRIPTION, /* description */
b9e24fbc6e29 Don't cast const gchar* to gchar*
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34170
diff changeset
561 KWALLET_AUTHOR, /* author */
b9e24fbc6e29 Don't cast const gchar* to gchar*
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34170
diff changeset
562 PURPLE_WEBSITE, /* homepage */
34118
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
563 kwallet_load, /* load */
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
564 kwallet_unload, /* unload */
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
565 NULL, /* destroy */
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
566 NULL, /* ui_info */
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
567 NULL, /* extra_info */
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
568 NULL, /* prefs_info */
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
569 NULL, /* actions */
a83c82be880d Kwallet: cosmetic changes, mostly formatting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34117
diff changeset
570 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
571 };
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
572
34116
825c98f8c7f6 Get rid of PURPLE_PLUGIN_FLAG_AUTOLOAD
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34114
diff changeset
573 static void
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
574 init_plugin(PurplePlugin *plugin)
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
575 {
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
576 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
577
34060
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
578 PURPLE_INIT_PLUGIN(kwallet_keyring, init_plugin, plugininfo)
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
579
34060
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
580 } /* extern "C" */
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
581
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
582 #include "kwallet.moc"

mercurial