1
/***************************************************************************
2
* Copyright (C) 2010 by Dario Freddi <drf@kde.org> *
4
* This program is free software; you can redistribute it and/or modify *
5
* it under the terms of the GNU General Public License as published by *
6
* the Free Software Foundation; either version 2 of the License, or *
7
* (at your option) any later version. *
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 *
12
* GNU General Public License for more details. *
14
* You should have received a copy of the GNU General Public License *
15
* along with this program; if not, write to the *
16
* Free Software Foundation, Inc., *
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
18
***************************************************************************/
21
#ifndef POWERDEVIL_POWERDEVILPOLICYAGENT_H
22
#define POWERDEVIL_POWERDEVILPOLICYAGENT_H
24
#include <QtCore/QObject>
25
#include <QtCore/QHash>
26
#include <QtCore/QWeakPointer>
28
#include <QtDBus/QDBusContext>
30
#include <kdemacros.h>
32
class QDBusServiceWatcher;
38
class KDE_EXPORT PolicyAgent : public QObject, protected QDBusContext
41
Q_DISABLE_COPY(PolicyAgent)
43
Q_CLASSINFO("D-Bus Interface", "org.kde.Solid.PowerManagement.PolicyAgent")
50
ChangeScreenSettings = 4
52
Q_DECLARE_FLAGS(RequiredPolicies, RequiredPolicy)
54
static PolicyAgent *instance();
56
virtual ~PolicyAgent();
59
* This function performs a policy check on given policies, and returns a set of unsatisfiable policies,
60
* or \c None if all the policies are satisfiable and the action can be carried on.
62
RequiredPolicies requirePolicyCheck(RequiredPolicies policies);
64
RequiredPolicies unavailablePolicies();
68
uint AddInhibition(uint types, const QString &appName, const QString &reason);
69
void ReleaseInhibition(uint cookie);
71
void releaseAllInhibitions();
74
void unavailablePoliciesChanged(PowerDevil::PolicyAgent::RequiredPolicies newpolicies);
77
void onServiceUnregistered(const QString &serviceName);
78
void onConsoleKitRegistered(const QString&);
79
void onConsoleKitUnregistered(const QString&);
80
void onConsoleKitActiveSessionChanged(const QString &activeSession);
83
explicit PolicyAgent(QObject* parent = 0);
86
void startSessionInterruption();
87
void finishSessionInterruption();
89
void addInhibitionTypeHelper(uint cookie, RequiredPolicies types);
91
// This function serves solely for fd.o connector
92
uint addInhibitionWithExplicitDBusService(uint types, const QString &appName,
93
const QString &reason, const QString &service);
96
QWeakPointer< QDBusInterface > m_ckSessionInterface;
97
QWeakPointer< QDBusInterface > m_ckSeatInterface;
98
bool m_sessionIsBeingInterrupted;
100
QHash< uint, QPair< QString, QString > > m_cookieToAppName;
101
QHash< uint, QString > m_cookieToBusService;
102
QHash< RequiredPolicy, QList< uint > > m_typesToCookie;
106
QWeakPointer< QDBusServiceWatcher > m_busWatcher;
107
QWeakPointer< QDBusServiceWatcher > m_ckWatcher;
109
bool m_wasLastActiveSession;
112
friend class FdoConnector;
117
#endif // POWERDEVIL_POWERDEVILPOLICYAGENT_H