21 #include <QtDBus/QtDBus>
22 #include <kaboutdata.h>
23 #include <kapplication.h>
24 #include <ksharedconfig.h>
26 #include <kpluginfactory.h>
27 #include <kpluginloader.h>
28 #include <kinputdialog.h>
31 #include <kauthaction.h>
35 #include <QPushButton>
36 #include <QVBoxLayout>
37 #include <ktoolinvocation.h>
38 #include <kconfiggroup.h>
39 #include <kmessagebox.h>
40 #include <kstandarddirs.h>
41 #define KWALLETMANAGERINTERFACE "org.kde.KWallet"
43 K_PLUGIN_FACTORY(KWalletFactory, registerPlugin<KWalletConfig>();)
44 K_EXPORT_PLUGIN(KWalletFactory(
"kcmkwallet"))
48 :
KCModule(KWalletFactory::componentData(), parent, args),
49 _cfg(KSharedConfig::openConfig(
QLatin1String( "kwalletrc" ), KConfig::NoGlobals)) {
52 new KAboutData(I18N_NOOP(
"kcmkwallet"), 0,
53 ki18n(
"KDE Wallet Control Module"),
54 0, KLocalizedString(), KAboutData::License_GPL,
55 ki18n(
"(c) 2003 George Staikos"));
56 about->addAuthor(ki18n(
"George Staikos"), KLocalizedString(),
"staikos@kde.org");
57 setAboutData( about );
59 setNeedsAuthorization(
true);
67 connect(_wcw->_enabled, SIGNAL(clicked()),
this, SLOT(configChanged()));
68 connect(_wcw->_launchManager, SIGNAL(clicked()),
this, SLOT(configChanged()));
69 connect(_wcw->_autocloseManager, SIGNAL(clicked()),
this, SLOT(configChanged()));
70 connect(_wcw->_autoclose, SIGNAL(clicked()),
this, SLOT(configChanged()));
71 connect(_wcw->_closeIdle, SIGNAL(clicked()),
this, SLOT(configChanged()));
72 connect(_wcw->_openPrompt, SIGNAL(clicked()),
this, SLOT(configChanged()));
73 connect(_wcw->_screensaverLock, SIGNAL(clicked()),
this, SLOT(configChanged()));
74 connect(_wcw->_localWalletSelected, SIGNAL(clicked()),
this, SLOT(configChanged()));
75 connect(_wcw->_idleTime, SIGNAL(valueChanged(
int)),
this, SLOT(configChanged()));
76 connect(_wcw->_launch, SIGNAL(clicked()),
this, SLOT(launchManager()));
77 connect(_wcw->_newWallet, SIGNAL(clicked()),
this, SLOT(newNetworkWallet()));
78 connect(_wcw->_newLocalWallet, SIGNAL(clicked()),
this, SLOT(newLocalWallet()));
79 connect(_wcw->_localWallet, SIGNAL(activated(
int)),
this, SLOT(configChanged()));
80 connect(_wcw->_defaultWallet, SIGNAL(activated(
int)),
this, SLOT(configChanged()));
81 connect(_wcw->_accessList, SIGNAL(customContextMenuRequested(
QPoint)),
this, SLOT(customContextMenuRequested(
QPoint)));
83 _wcw->_accessList->setAllColumnsShowFocus(
true);
84 _wcw->_accessList->setContextMenuPolicy(Qt::CustomContextMenu);
88 _wcw->_launch->hide();
99 const QString p1( _wcw->_localWallet->currentText() );
100 const QString p2( _wcw->_defaultWallet->currentText() );
102 _wcw->_localWallet->clear();
103 _wcw->_defaultWallet->clear();
105 const QStringList wl = KWallet::Wallet::walletList();
106 _wcw->_localWallet->addItems(wl);
107 _wcw->_defaultWallet->addItems(wl);
111 _wcw->_localWallet->setCurrentIndex(index);
116 _wcw->_defaultWallet->setCurrentIndex(index);
124 const QString n = KInputDialog::getText(i18n(
"New Wallet"),
125 i18n(
"Please choose a name for the new wallet:"),
134 KWallet::Wallet *w = KWallet::Wallet::openWallet(n, topLevelWidget()->winId());
152 _wcw->_localWallet->setCurrentIndex(_wcw->_localWallet->findText(n));
166 _wcw->_defaultWallet->setCurrentIndex(_wcw->_defaultWallet->findText(n));
174 KToolInvocation::startServiceByDesktopName(
QLatin1String(
"kwalletmanager_show" ));
188 KConfigGroup config(_cfg,
"Wallet");
189 _wcw->_enabled->setChecked(config.readEntry(
"Enabled",
true));
190 _wcw->_openPrompt->setChecked(config.readEntry(
"Prompt on Open",
false));
191 _wcw->_launchManager->setChecked(config.readEntry(
"Launch Manager",
false));
192 _wcw->_autocloseManager->setChecked(! config.readEntry(
"Leave Manager Open",
false));
193 _wcw->_screensaverLock->setChecked(config.readEntry(
"Close on Screensaver",
false));
194 _wcw->_autoclose->setChecked(!config.readEntry(
"Leave Open",
false));
195 _wcw->_closeIdle->setChecked(config.readEntry(
"Close When Idle",
false));
196 _wcw->_idleTime->setValue(config.readEntry(
"Idle Timeout", 10));
197 if (config.hasKey(
"Default Wallet")) {
198 int defaultWallet_idx = _wcw->_defaultWallet->findText(config.readEntry(
"Default Wallet"));
199 if (defaultWallet_idx != -1) {
200 _wcw->_defaultWallet->setCurrentIndex(defaultWallet_idx);
202 _wcw->_defaultWallet->setCurrentIndex(0);
205 _wcw->_defaultWallet->setCurrentIndex(0);
207 if (config.hasKey(
"Local Wallet")) {
208 _wcw->_localWalletSelected->setChecked( !config.readEntry(
"Use One Wallet",
false) );
209 int localWallet_idx = _wcw->_localWallet->findText(config.readEntry(
"Local Wallet"));
210 if (localWallet_idx != -1) {
211 _wcw->_localWallet->setCurrentIndex(localWallet_idx);
213 _wcw->_localWallet->setCurrentIndex(0);
216 _wcw->_localWalletSelected->setChecked(
false);
218 _wcw->_accessList->clear();
219 KConfigGroup ad(_cfg,
"Auto Deny");
220 KConfigGroup aa(_cfg,
"Auto Allow");
227 QString path = KGlobal::dirs()->locateLocal(
"data",
QString(
"kwallet/%1.kwl").arg(walletName));
230 KConfigGroup cfgAllow = KSharedConfig::openConfig(
"kwalletrc")->group(
"Auto Allow");
231 cfgAllow.deleteEntry(walletName);
233 KConfigGroup cfgDeny = KSharedConfig::openConfig(
"kwalletrc")->group(
"Auto Deny");
234 cfgDeny.deleteEntry(walletName);
256 _wcw->_accessList->header()->setResizeMode(QHeaderView::ResizeToContents);
263 KAuth::Action *action = authAction();
265 kDebug() <<
"There's no authAction, not saving settings";
268 action->setArguments(args);
270 KAuth::ActionReply reply = action->execute();
272 if (reply.failed()) {
273 if (reply.type() == KAuth::ActionReply::KAuthError){
274 kDebug() <<
"Save action was not authorized!";
275 KMessageBox::error(
this, i18n(
"Sorry, the system security policy didn't allow you to save the changes."), i18n(
"KDE Wallet Control Module"));
277 KMessageBox::error(
this, reply.errorDescription(), i18n(
"KDE Wallet Control Module"));
278 kDebug() <<
"Save action failed. Not saving the settings.";
284 KConfigGroup config(_cfg,
"Wallet");
285 config.writeEntry(
"Enabled", _wcw->_enabled->isChecked());
286 config.writeEntry(
"Launch Manager", _wcw->_launchManager->isChecked());
287 config.writeEntry(
"Leave Manager Open", !_wcw->_autocloseManager->isChecked());
288 config.writeEntry(
"Leave Open", !_wcw->_autoclose->isChecked());
289 config.writeEntry(
"Close When Idle", _wcw->_closeIdle->isChecked());
290 config.writeEntry(
"Idle Timeout", _wcw->_idleTime->value());
291 config.writeEntry(
"Prompt on Open", _wcw->_openPrompt->isChecked());
292 config.writeEntry(
"Close on Screensaver", _wcw->_screensaverLock->isChecked());
294 config.writeEntry(
"Use One Wallet", !_wcw->_localWalletSelected->isChecked());
295 if (_wcw->_localWalletSelected->isChecked()) {
296 config.writeEntry(
"Local Wallet", _wcw->_localWallet->currentText());
298 config.deleteEntry(
"Local Wallet");
301 if (_wcw->_defaultWallet->currentIndex() != -1) {
302 config.writeEntry(
"Default Wallet", _wcw->_defaultWallet->currentText());
304 config.deleteEntry(
"Default Wallet");
308 _cfg->deleteGroup(
"Auto Allow");
309 _cfg->deleteGroup(
"Auto Deny");
310 config = _cfg->group(
"Auto Allow");
311 for (
int i = 0; i < _wcw->_accessList->topLevelItemCount(); ++i) {
314 for (
int j = 0; j < parentItem->
childCount(); ++j) {
316 if (childItem->
text(2) == i18n(
"Always Allow")) {
317 al << childItem->
text(1);
320 config.writeEntry(parentItem->
text(0), al);
323 config = _cfg->group(
"Auto Deny");
324 for (
int i = 0; i < _wcw->_accessList->topLevelItemCount(); ++i) {
327 for (
int j = 0; j < parentItem->
childCount(); ++j) {
329 if (childItem->
text(2) == i18n(
"Always Deny")) {
330 al << childItem->
text(1);
333 config.writeEntry(parentItem->
text(0), al);
339 if (KWallet::Wallet::isEnabled()) {
348 _wcw->_enabled->setChecked(
true);
349 _wcw->_openPrompt->setChecked(
false);
350 _wcw->_launchManager->setChecked(
true);
351 _wcw->_autocloseManager->setChecked(
false);
352 _wcw->_screensaverLock->setChecked(
false);
353 _wcw->_autoclose->setChecked(
true);
354 _wcw->_closeIdle->setChecked(
false);
355 _wcw->_idleTime->setValue(10);
356 _wcw->_defaultWallet->setCurrentIndex(0);
357 _wcw->_localWalletSelected->setChecked(
false);
358 _wcw->_localWallet->setCurrentIndex( 0 );
359 _wcw->_accessList->clear();
365 return i18n(
"This configuration module allows you to configure the KDE wallet system.");
371 if (item && item->
parent()) {
374 m->addAction( i18n(
"&Delete" ),
this, SLOT(
deleteEntry()), Qt::Key_Delete);
383 if (items.
count() == 1 && items[0] ) {
389 #include "konfigurator.moc"
#define KWALLETMANAGERINTERFACE
QDBusConnection sessionBus()
QString quickHelp() const
QDBusMessage call(const QString &method, const QVariant &arg1, const QVariant &arg2, const QVariant &arg3, const QVariant &arg4, const QVariant &arg5, const QVariant &arg6, const QVariant &arg7, const QVariant &arg8)
int count(const T &value) const
void customContextMenuRequested(const QPoint &pos)
int removeAll(const T &value)
void setMargin(int margin)
int indexOf(const QRegExp &rx, int from) const
const_iterator constEnd() const
const_iterator constBegin() const
QString text(int column) const
void setSpacing(int spacing)