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

KDECore

  • 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
26namespace KAuth
27{
28
29class ActionWatcher::Private
30{
31public:
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
44static QHash<QString, ActionWatcher *> s_watchers;
45
46ActionWatcher::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
62ActionWatcher::~ActionWatcher()
63{
64 delete d;
65}
66
67ActionWatcher *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
76QString ActionWatcher::action() const
77{
78 return d->action;
79}
80
81void ActionWatcher::Private::actionStartedSlot(const QString &taction)
82{
83 if (taction == action) {
84 emit q->actionStarted();
85 }
86}
87
88void ActionWatcher::Private::actionPerformedSlot(const QString &taction, const ActionReply &reply)
89{
90 if (taction == action) {
91 emit q->actionPerformed(reply);
92 }
93}
94
95void ActionWatcher::Private::progressStepSlot(const QString &taction, int i)
96{
97 if (taction == action) {
98 emit q->progressStep(i);
99 }
100}
101
102void ActionWatcher::Private::progressStepSlot(const QString &taction, const QVariantMap &data)
103{
104 if (taction == action) {
105 emit q->progressStep(data);
106 }
107}
108
109void 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"
BackendsManager.h
KAuth::ActionReply
Class that encapsulates a reply coming from the helper after executing an action.
Definition: kauthactionreply.h:371
KAuth::ActionWatcher
Class used to receive notifications about the status of an action execution.
Definition: kauthactionwatcher.h:51
KAuth::Action::AuthStatus
AuthStatus
The three values returned by authorization methods.
Definition: kauthaction.h:78
KAuth::BackendsManager::authBackend
static AuthBackend * authBackend()
Definition: BackendsManager.cpp:120
KAuth::BackendsManager::helperProxy
static HelperProxy * helperProxy()
Definition: BackendsManager.cpp:129
KAuth::HelperProxy
Definition: HelperProxy.h:36
QHash
Definition: ksycocafactory.h:28
QObject
QString
kauthactionwatcher.h
KAuth
Definition: AuthBackend.cpp:24
KAuth::s_watchers
static QHash< QString, ActionWatcher * > s_watchers
Definition: kauthactionwatcher.cpp:44
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 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-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 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
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