libpurple/plugins/keyrings/kwallet.cpp

Mon, 07 Nov 2011 07:27:59 +0000

author
Elliott Sales de Andrade <qulogic@pidgin.im>
date
Mon, 07 Nov 2011 07:27:59 +0000
branch
soc.2008.masterpassword
changeset 34062
7879224489fd
parent 34061
3de7a25ccb7e
child 34067
8643ef2b5bf4
permissions
-rw-r--r--

Hey, I think this almost compiles now!

34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
1 /**
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
2 * @file kwallet.cpp KWallet password storage
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
3 * @ingroup plugins
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
4 *
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
5 * @todo
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
6 * cleanup error handling and reporting
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
7 * refuse unloading when active (in internal keyring too)
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
8 */
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
9
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
10 /* purple
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 * 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
13 * 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
14 * source distribution.
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
15 *
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
16 * 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
17 * 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
18 * 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
19 * (at your option) any later version.
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
20 *
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
21 * 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
22 * 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
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
24 * GNU General Public License for more details.
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 * 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
27 * along with this program ; if not, write to the Free Software
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
28 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
29 */
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
30
34014
647e174899a9 Took stuff from kwallet.cpp out of the extern "C" {}
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 34005
diff changeset
31 #ifdef HAVE_CONFIG_H
647e174899a9 Took stuff from kwallet.cpp out of the extern "C" {}
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 34005
diff changeset
32 #include <config.h>
647e174899a9 Took stuff from kwallet.cpp out of the extern "C" {}
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 34005
diff changeset
33 #endif
647e174899a9 Took stuff from kwallet.cpp out of the extern "C" {}
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 34005
diff changeset
34
647e174899a9 Took stuff from kwallet.cpp out of the extern "C" {}
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 34005
diff changeset
35 #ifndef PURPLE_PLUGINS
647e174899a9 Took stuff from kwallet.cpp out of the extern "C" {}
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 34005
diff changeset
36 #define PURPLE_PLUGINS
647e174899a9 Took stuff from kwallet.cpp out of the extern "C" {}
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 34005
diff changeset
37 #endif
647e174899a9 Took stuff from kwallet.cpp out of the extern "C" {}
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 34005
diff changeset
38
647e174899a9 Took stuff from kwallet.cpp out of the extern "C" {}
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 34005
diff changeset
39 #include <glib.h>
647e174899a9 Took stuff from kwallet.cpp out of the extern "C" {}
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 34005
diff changeset
40
647e174899a9 Took stuff from kwallet.cpp out of the extern "C" {}
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 34005
diff changeset
41 #include "account.h"
647e174899a9 Took stuff from kwallet.cpp out of the extern "C" {}
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 34005
diff changeset
42 #include "version.h"
647e174899a9 Took stuff from kwallet.cpp out of the extern "C" {}
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 34005
diff changeset
43 #include "keyring.h"
647e174899a9 Took stuff from kwallet.cpp out of the extern "C" {}
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 34005
diff changeset
44 #include "debug.h"
647e174899a9 Took stuff from kwallet.cpp out of the extern "C" {}
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 34005
diff changeset
45 #include "plugin.h"
647e174899a9 Took stuff from kwallet.cpp out of the extern "C" {}
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 34005
diff changeset
46 #include "internal.h"
34060
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
47 #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
48
34060
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
49 #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
50 #define KWALLET_VERSION "0.3b"
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
51 #define KWALLET_DESCRIPTION N_("This plugin will store passwords in KWallet.")
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
52 #define KWALLET_AUTHOR "Scrouaf (scrouaf[at]soc.pidgin.im)"
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
53 #define KWALLET_ID "core-scrouaf-kwallet"
34014
647e174899a9 Took stuff from kwallet.cpp out of the extern "C" {}
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 34005
diff changeset
54
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
55 PurpleKeyring *keyring_handler;
34014
647e174899a9 Took stuff from kwallet.cpp out of the extern "C" {}
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents: 34005
diff changeset
56
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
57 #define ERR_KWALLETPLUGIN kwallet_plugin_error_domain()
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
58
34060
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
59 namespace KWalletPlugin {
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
60
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
61 class request
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
62 {
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
63 public:
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
64 virtual void abort();
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
65 virtual void execute(KWallet::Wallet *wallet);
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
66
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
67 protected:
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
68 gpointer data;
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
69 PurpleAccount *account;
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
70 QString *password;
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
71 };
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
72
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
73 class engine
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
74 {
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
75 public:
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
76 engine();
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
77 ~engine();
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
78 void queue(request req);
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
79 static engine *Instance();
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
80
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
81 /* signal:*/
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
82 void walletopened(bool opened);
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:
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
85 bool connected;
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
86 KWallet::Wallet *wallet;
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
87 std::list<request> requests;
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
88 static engine *pinstance;
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
89
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
90 /* KApplication *app; */
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
91 void ExecuteRequests();
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
92 };
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
93
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
94 class save_request : public request
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
95 {
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
96 public:
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
97 save_request(PurpleAccount *account, const char *password, PurpleKeyringSaveCallback cb, void *data);
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
98 void abort();
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
99 void execute(KWallet::Wallet *wallet);
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
100
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
101 private:
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
102 PurpleKeyringSaveCallback callback;
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
103 };
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
104
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
105 class read_request : public request
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
106 {
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
107 public:
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
108 read_request(PurpleAccount *account, PurpleKeyringReadCallback cb, void *data);
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
109 void abort();
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
110 void execute(KWallet::Wallet *wallet);
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 private:
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
113 PurpleKeyringReadCallback callback;
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
114 };
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
115
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
116 static GQuark
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
117 kwallet_plugin_error_domain(void)
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
118 {
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
119 return g_quark_from_static_string("KWallet keyring");
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
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
124 KWalletPlugin::engine::engine()
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
125 {
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
126 /* KAboutData aboutData("libpurple_plugin", N_("LibPurple KWallet Plugin"), "", "", KAboutData::License_GPL, "");
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
127 KCmdLineArgs::init( &aboutData );
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
128 app = new KApplication(false, false); */
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
129
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
130 connected = FALSE;
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
131 wallet = KWallet::Wallet::openWallet(KWallet::Wallet::NetworkWallet(), 0, KWallet::Wallet::Asynchronous);
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
132 QObject::connect(wallet, SIGNAL(KWallet::Wallet::walletOpened(bool)), SLOT(walletopened(bool)));
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
133 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
134
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
135 KWalletPlugin::engine::~engine()
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
136 {
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
137 std::list<request>::iterator it;
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
138
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
139 for(it = requests.begin(); it != requests.end(); it++) {
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
140 it->abort();
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
141 requests.pop_front();
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
142 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
143
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
144 KWallet::Wallet::closeWallet(KWallet::Wallet::NetworkWallet(), TRUE);
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
145 delete wallet;
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
146 pinstance = NULL;
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
147 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
148
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
149 KWalletPlugin::engine *
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
150 KWalletPlugin::engine::Instance()
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
151 {
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
152 if (pinstance == NULL)
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
153 pinstance = new engine;
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
154 return pinstance;
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
155 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
156
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
157 void
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
158 KWalletPlugin::engine::walletopened(bool opened)
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
159 {
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
160 std::list<request>::iterator it;
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
161
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
162 connected = opened;
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
163
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
164 if (opened) {
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
165 ExecuteRequests();
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
166 } else {
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
167 for (it = requests.begin(); it != requests.end(); it++) {
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
168 it->abort();
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
169 requests.pop_front();
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
170 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
171 delete this;
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
172 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
173 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
174
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
175 void
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
176 KWalletPlugin::engine::queue(request req)
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
177 {
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
178 requests.push_back(req);
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
179 ExecuteRequests();
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
180 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
181
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
182 void
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
183 KWalletPlugin::engine::ExecuteRequests()
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
184 {
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
185 std::list<request>::iterator it;
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
186
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
187 if (connected) {
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
188 for (it = requests.begin(); it != requests.end(); it++) {
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
189 it->execute(wallet);
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
190 requests.pop_front();
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
191 delete it;
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
192 }
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
193 }
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
194 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
195
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
196 KWalletPlugin::save_request::save_request(PurpleAccount *acc, const char *pw, PurpleKeyringSaveCallback cb, void *userdata)
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
197 {
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
198 account = acc;
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
199 data = userdata;
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
200 callback = cb;
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
201 password = new QString(pw);
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
202 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
203
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
204 KWalletPlugin::read_request::read_request(PurpleAccount *acc, PurpleKeyringReadCallback cb, void *userdata)
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
205 {
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
206 account = acc;
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
207 data = userdata;
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
208 callback = cb;
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
209 password = NULL;
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
210 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
211
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
212 void
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
213 KWalletPlugin::save_request::abort()
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
214 {
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
215 GError *error;
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
216 if (callback != NULL) {
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
217 error = g_error_new(ERR_KWALLETPLUGIN,
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
218 PURPLE_KEYRING_ERROR_UNKNOWN,
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
219 "Failed to save password");
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
220 callback(account, error, data);
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
221 g_error_free(error);
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
222 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
223 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
224
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
225 void
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
226 KWalletPlugin::read_request::abort()
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
227 {
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
228 GError *error;
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
229 if (callback != NULL) {
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
230 error = g_error_new(ERR_KWALLETPLUGIN,
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
231 PURPLE_KEYRING_ERROR_UNKNOWN,
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
232 "Failed to read password");
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
233 callback(account, NULL, error, data);
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
234 g_error_free(error);
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
235 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
236 }
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 void
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
239 KWalletPlugin::read_request::execute(KWallet::Wallet *wallet)
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
240 {
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
241 int result;
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
242 QString key;
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
243
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
244 key = QString("purple-") + purple_account_get_username(account) + " " + purple_account_get_protocol_id(account);
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
245 result = wallet.readPassword(key, password);
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
246
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
247 if (result != 0)
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
248 abort();
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
249 else if (callback != NULL)
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
250 callback(account, (const char *)password, NULL, data);
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
251 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
252
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
253 void
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
254 KWalletPlugin::save_request::execute(KWallet::Wallet *wallet)
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
255 {
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
256 int result;
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
257 QString key;
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
258
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
259 key = QString("purple-") + purple_account_get_username(account) + " " + purple_account_get_protocol_id(account);
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
260 result = wallet.writePassword(key, password);
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
261
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
262 if (result != 0)
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
263 abort();
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
264 else if (callback != NULL)
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
265 callback(account, NULL, data);
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
266 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
267
34060
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
268 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
269 {
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
270
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
271 static void
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
272 kwallet_read(PurpleAccount *account,
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
273 PurpleKeyringReadCallback cb,
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
274 gpointer data)
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
275 {
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
276 KWalletPlugin::read_request req(account, cb, data);
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
277 KWalletPlugin::engine::Instance()->queue(req);
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
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
280 static void
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
281 kwallet_save(PurpleAccount *account,
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
282 const char *password,
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
283 PurpleKeyringSaveCallback cb,
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
284 gpointer data)
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
285 {
34060
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
286 KWalletPlugin::save_request req(account, password, cb, data);
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
287 KWalletPlugin::engine::Instance()->queue(req);
34005
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
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
290 static void
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
291 kwallet_close(GError **error)
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
292 {
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
293 delete KWalletPlugin::engine::Instance();
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
294 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
295
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
296 static gboolean
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
297 kwallet_import(PurpleAccount *account,
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
298 const char *mode,
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
299 const char *data,
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
300 GError **error)
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
301 {
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
302 return TRUE;
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
303 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
304
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
305 static gboolean
34034
f508fa47f2ac Reformat many things.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34033
diff changeset
306 kwallet_export(PurpleAccount *account,
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
307 const char **mode,
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
308 char **data,
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
309 GError **error,
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
310 GDestroyNotify *destroy)
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
311 {
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
312 *mode = NULL;
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
313 *data = NULL;
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
314 destroy = NULL;
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
315
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
316 return TRUE;
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
317 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
318
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
319 static gboolean
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
320 kwallet_load(PurplePlugin *plugin)
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
321 {
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
322 keyring_handler = purple_keyring_new();
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
323
34060
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
324 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
325 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
326 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
327 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
328 purple_keyring_set_close_keyring(keyring_handler, kwallet_close);
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
329 /* purple_keyring_set_change_master(keyring_handler, kwallet_change_master);*/
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
330 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
331 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
332
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
333 purple_keyring_register(keyring_handler);
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 return TRUE;
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
336 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
337
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
338 static gboolean
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
339 kwallet_unload(PurplePlugin *plugin)
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
340 {
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
341 kwallet_close(NULL);
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
342 return TRUE;
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
343 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
344
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
345 static void
34060
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
346 kwallet_destroy(PurplePlugin *plugin)
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
347 {
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
348 kwallet_close(NULL);
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
349 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
350
34060
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
351 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
352 {
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
353 PURPLE_PLUGIN_MAGIC, /* magic */
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
354 PURPLE_MAJOR_VERSION, /* major_version */
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
355 PURPLE_MINOR_VERSION, /* minor_version */
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
356 PURPLE_PLUGIN_STANDARD, /* type */
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
357 NULL, /* ui_requirement */
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
358 PURPLE_PLUGIN_FLAG_INVISIBLE|PURPLE_PLUGIN_FLAG_AUTOLOAD, /* flags */
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
359 NULL, /* dependencies */
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
360 PURPLE_PRIORITY_DEFAULT, /* priority */
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
361 KWALLET_ID, /* id */
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
362 KWALLET_NAME, /* name */
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
363 KWALLET_VERSION, /* version */
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
364 "KWallet Keyring Plugin", /* summary */
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
365 KWALLET_DESCRIPTION, /* description */
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
366 KWALLET_AUTHOR, /* author */
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
367 "N/A", /* homepage */
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
368 kwallet_load, /* load */
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
369 kwallet_unload, /* unload */
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
370 kwallet_destroy, /* destroy */
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
371 NULL, /* ui_info */
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
372 NULL, /* extra_info */
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
373 NULL, /* prefs_info */
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
374 NULL, /* actions */
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
375 NULL, /* padding... */
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
376 NULL,
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
377 NULL,
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
378 NULL,
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
379 };
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
380
34062
7879224489fd Hey, I think this almost compiles now!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34061
diff changeset
381 void init_plugin(PurplePlugin *plugin);
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
382 void
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
383 init_plugin(PurplePlugin *plugin)
34033
910f2ed3988b Remove trailing whitespace.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34032
diff changeset
384 {
34060
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
385 purple_debug_info("keyring-kwallet", "init plugin called.\n");
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
386 }
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
387
34060
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
388 PURPLE_INIT_PLUGIN(kwallet_keyring, init_plugin, plugininfo)
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
389
34060
1ff15466f569 This should hopefully namespace things correctly. I'll admit that the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34035
diff changeset
390 } /* extern "C" */
34005
592e6e8213a9 Cleanup in gnomekeyring.c
Vivien Bernet-Rollande <scrouaf@soc.pidgin.im>
parents:
diff changeset
391

mercurial