1 | /* |
2 | This file is part of libkresources. |
3 | |
4 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> |
5 | Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> |
6 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> |
7 | |
8 | This library is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU Library General Public |
10 | License as published by the Free Software Foundation; either |
11 | version 2 of the License, or (at your option) any later version. |
12 | |
13 | This library is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | Library General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU Library General Public License |
19 | along with this library; see the file COPYING.LIB. If not, write to |
20 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
21 | Boston, MA 02110-1301, USA. |
22 | */ |
23 | #ifndef KRESOURCES_MANAGERIMPL_H |
24 | #define KRESOURCES_MANAGERIMPL_H |
25 | |
26 | #include "resource.h" |
27 | #include <QtCore/QString> |
28 | |
29 | class KConfig; |
30 | |
31 | namespace KRES { |
32 | |
33 | class Resource; |
34 | class ManagerNotifier; |
35 | |
36 | /** |
37 | @internal |
38 | |
39 | Do not use this class directly. Use ResourceManager instead |
40 | */ |
41 | class KRESOURCES_EXPORT ManagerImpl : public QObject |
42 | { |
43 | Q_OBJECT |
44 | public: |
45 | ManagerImpl( ManagerNotifier *, const QString &family ); |
46 | ~ManagerImpl(); |
47 | |
48 | void readConfig( KConfig * ); |
49 | void writeConfig( KConfig * ); |
50 | |
51 | void add( Resource *resource ); |
52 | void remove( Resource *resource ); |
53 | void change( Resource *resource ); |
54 | |
55 | Resource *standardResource(); |
56 | void setStandardResource( Resource *resource ); |
57 | |
58 | void setActive( Resource *resource, bool active ); |
59 | |
60 | Resource::List *resourceList(); |
61 | |
62 | QList<Resource *> resources(); |
63 | |
64 | // Get only active or passive resources |
65 | QList<Resource *> resources( bool active ); |
66 | |
67 | QStringList resourceNames(); |
68 | |
69 | static QString defaultConfigFile( const QString &family ); |
70 | |
71 | Q_SIGNALS: |
72 | void signalKResourceAdded( QString managerId, QString resourceId ); |
73 | void signalKResourceModified( QString managerId, QString resourceId ); |
74 | void signalKResourceDeleted( QString managerId, QString resourceId ); |
75 | |
76 | private Q_SLOTS: |
77 | // dbus calls |
78 | void dbusKResourceAdded( const QString &managerId, |
79 | const QString &resourceId ); |
80 | void dbusKResourceModified( const QString &managerId, |
81 | const QString &resourceId ); |
82 | void dbusKResourceDeleted( const QString &managerId, |
83 | const QString &resourceId ); |
84 | |
85 | private: |
86 | void createStandardConfig(); |
87 | |
88 | Resource *readResourceConfig( const QString &identifier, bool checkActive ); |
89 | void writeResourceConfig( Resource *resource, bool checkActive ); |
90 | |
91 | void removeResource( Resource *resource ); |
92 | Resource *getResource( Resource *resource ); |
93 | Resource *getResource( const QString &identifier ); |
94 | |
95 | class ManagerImplPrivate; |
96 | ManagerImplPrivate *const d; |
97 | }; |
98 | |
99 | } |
100 | |
101 | #endif |
102 | |