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

KDECore

  • sources
  • kde-4.14
  • kdelibs
  • kdecore
  • auth
kauthactionwatcher.cpp
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2008 Nicola Gigante <nicola.gigante@gmail.com>
3 * Copyright (C) 2009 Dario Freddi <drf@kde.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published by
7 * the Free Software Foundation; either version 2.1 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program; if not, write to the
17 * Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA .
19 */
20 
21 #include "kauthactionwatcher.h"
22 #include "BackendsManager.h"
23 
24 #include <QHash>
25 
26 namespace KAuth
27 {
28 
29 class ActionWatcher::Private
30 {
31 public:
32  Private(ActionWatcher *parent) : q(parent) {}
33 
34  ActionWatcher *q;
35  QString action;
36 
37  void actionStartedSlot(const QString &action);
38  void actionPerformedSlot(const QString &action, const ActionReply &reply);
39  void progressStepSlot(const QString &action, int i);
40  void progressStepSlot(const QString &action, const QVariantMap &data);
41  void statusChangedSlot(const QString &action, Action::AuthStatus status);
42 };
43 
44 static QHash<QString, ActionWatcher *> s_watchers;
45 
46 ActionWatcher::ActionWatcher(const QString &action)
47  : QObject(0)
48  , d(new Private(this))
49 {
50  d->action = action;
51 
52  HelperProxy *helper = BackendsManager::helperProxy();
53 
54  connect(helper, SIGNAL(actionStarted(QString)), this, SLOT(actionStartedSlot(QString)));
55  connect(helper, SIGNAL(actionPerformed(QString,ActionReply)), this, SLOT(actionPerformedSlot(QString,ActionReply)));
56  connect(helper, SIGNAL(progressStep(QString,int)), this, SLOT(progressStepSlot(QString,int)));
57  connect(helper, SIGNAL(progressStep(QString,QVariantMap)), this, SLOT(progressStepSlot(QString,QVariantMap)));
58  connect(BackendsManager::authBackend(), SIGNAL(actionStatusChanged(QString,Action::AuthStatus)),
59  this, SLOT(statusChangedSlot(QString,Action::AuthStatus)));
60 }
61 
62 ActionWatcher::~ActionWatcher()
63 {
64  delete d;
65 }
66 
67 ActionWatcher *ActionWatcher::watcher(const QString &action)
68 {
69  if (!s_watchers.contains(action)) {
70  s_watchers[action] = new ActionWatcher(action);
71  }
72 
73  return s_watchers[action];
74 }
75 
76 QString ActionWatcher::action() const
77 {
78  return d->action;
79 }
80 
81 void ActionWatcher::Private::actionStartedSlot(const QString &taction)
82 {
83  if (taction == action) {
84  emit q->actionStarted();
85  }
86 }
87 
88 void ActionWatcher::Private::actionPerformedSlot(const QString &taction, const ActionReply &reply)
89 {
90  if (taction == action) {
91  emit q->actionPerformed(reply);
92  }
93 }
94 
95 void ActionWatcher::Private::progressStepSlot(const QString &taction, int i)
96 {
97  if (taction == action) {
98  emit q->progressStep(i);
99  }
100 }
101 
102 void ActionWatcher::Private::progressStepSlot(const QString &taction, const QVariantMap &data)
103 {
104  if (taction == action) {
105  emit q->progressStep(data);
106  }
107 }
108 
109 void ActionWatcher::Private::statusChangedSlot(const QString &taction, Action::AuthStatus status)
110 {
111  if (taction == action) {
112  emit q->statusChanged(status);
113  }
114 }
115 
116 } // namespace Auth
117 
118 #include "kauthactionwatcher.moc"
KAuth::HelperProxy
Definition: HelperProxy.h:35
KAuth::BackendsManager::authBackend
static AuthBackend * authBackend()
Definition: BackendsManager.cpp:120
kauthactionwatcher.h
KAuth::ActionWatcher
Class used to receive notifications about the status of an action execution.
Definition: kauthactionwatcher.h:50
QHash
Definition: ksycocafactory.h:28
KAuth::BackendsManager::helperProxy
static HelperProxy * helperProxy()
Definition: BackendsManager.cpp:129
QObject
QString
KAuth::Action::AuthStatus
AuthStatus
The three values returned by authorization methods.
Definition: kauthaction.h:78
KAuth::ActionWatcher::action
QString action() const
Returns the action name associated with this watcher.
Definition: kauthactionwatcher.cpp:76
KAuth::s_watchers
static QHash< QString, ActionWatcher * > s_watchers
Definition: kauthactionwatcher.cpp:44
KAuth::ActionReply
Class that encapsulates a reply coming from the helper after executing an action. ...
Definition: kauthactionreply.h:370
KAuth::HelperSupport::progressStep
void progressStep(int step)
Send a progressStep signal to the caller application.
Definition: kauthhelpersupport.cpp:122
QObject::parent
QObject * parent() const
BackendsManager.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:22:10 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

Skip menu "KDECore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

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