• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeutils API Reference
  • KDE Home
  • Contact Us
 

kwallet

  • sources
  • kde-4.12
  • kdeutils
  • kwalletmanager
  • src
  • manager
authorizedappmodel.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2013 Valentin Rusu <kde@rusu.info>
3 
4  This program is free software; you can redistribute it and/or
5  modify it under the terms of the GNU General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; see the file COPYING. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #include "authorizedappmodel.h"
21 
22 #include <kconfiggroup.h>
23 #include <kwallet.h>
24 #include <kdebug.h>
25 #include <QTimer>
26 
27 AuthorizedAppModel::AuthorizedAppModel(KWallet::Wallet* wallet):
28  QStandardItemModel(),
29  _cfg(KSharedConfig::openConfig(QLatin1String( "kwalletrc" ), KConfig::NoGlobals)),
30  _wallet(wallet)
31 {
32  // TODO: handle "Auto Deny" applications
33  // KConfigGroup ad(_cfg, "Auto Deny");
34 
35  KConfigGroup aa(_cfg, "Auto Allow");
36  QString walletName = _wallet->walletName();
37  const QStringList keys = aa.entryMap().keys();
38  Q_FOREACH(QString cfgWalletName, keys) {
39  if (cfgWalletName == walletName) {
40  const QStringList apps = aa.readEntry(cfgWalletName, QStringList());
41  int row = 0;
42  Q_FOREACH(QString appName, apps) {
43  setItem(row, 0, new QStandardItem(appName));
44  setItem(row, 1, new QStandardItem("dummy")); // this item will be hidden by the disconnect button, see below setIndexWidget call
45  _authorizedAppsIndexMap.insert(appName, QPersistentModelIndex(index(row, 0)));
46  row++;
47  }
48  }
49  }
50 }
51 
52 void AuthorizedAppModel::removeApp(QString appName)
53 {
54  if (_authorizedAppsIndexMap.contains(appName)) {
55  QPersistentModelIndex idx = _authorizedAppsIndexMap[appName];
56  if (idx.isValid()) {
57  if (!removeRow(idx.row())) {
58  kDebug() << "Remove row failed for app " << appName;
59  }
60  }
61  } else {
62  kDebug() << "Attempting to remove unknown application " << appName;
63  }
64  QTimer::singleShot(0, this, SLOT(saveConfig()));
65 }
66 
67 void AuthorizedAppModel::saveConfig()
68 {
69  QStringList appList;
70  for (int r=0; r <rowCount(); r++) {
71  appList << item(r)->text();
72  }
73  QString walletName = _wallet->walletName();
74  KConfigGroup config(_cfg, "Auto Allow");
75  config.deleteEntry(walletName);
76  config.writeEntry(_wallet->walletName(), appList);
77  _cfg->sync();
78 }
79 
80 #include "authorizedappmodel.moc"
QStandardItemModel
AuthorizedAppModel::removeApp
void removeApp(QString)
Definition: authorizedappmodel.cpp:52
AuthorizedAppModel::AuthorizedAppModel
AuthorizedAppModel(KWallet::Wallet *wallet)
Definition: authorizedappmodel.cpp:27
authorizedappmodel.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:07:38 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kwallet

Skip menu "kwallet"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeutils API Reference

Skip menu "kdeutils API Reference"
  • ark
  • filelight
  • kcalc
  • kcharselect
  • kdf
  • kfloppy
  • kgpg
  • kremotecontrol
  • ktimer
  • kwallet
  • superkaramba
  • sweeper

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal