libpurple/plugins/keyrings/kwallet.cpp

Sat, 23 Mar 2013 01:06:28 +0100

author
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
date
Sat, 23 Mar 2013 01:06:28 +0100
branch
soc.2008.masterpassword
changeset 34131
e56d3dd7b0e4
parent 34129
52b91b4b8314
child 34133
96fcf3176777
permissions
-rw-r--r--

Track migrating passwords in prefs window

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

mercurial