kresources
managerimpl.h
00001 /* 00002 This file is part of libkresources. 00003 00004 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 00005 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 00006 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 00007 00008 This library is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU Library General Public 00010 License as published by the Free Software Foundation; either 00011 version 2 of the License, or (at your option) any later version. 00012 00013 This library is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 Library General Public License for more details. 00017 00018 You should have received a copy of the GNU Library General Public License 00019 along with this library; see the file COPYING.LIB. If not, write to 00020 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00021 Boston, MA 02110-1301, USA. 00022 */ 00023 #ifndef KRESOURCES_MANAGERIMPL_H 00024 #define KRESOURCES_MANAGERIMPL_H 00025 00026 #include "resource.h" 00027 #include <QtCore/QString> 00028 00029 class KConfig; 00030 00031 namespace KRES { 00032 00033 class Resource; 00034 class ManagerNotifier; 00035 00041 class KRESOURCES_EXPORT ManagerImpl : public QObject 00042 { 00043 Q_OBJECT 00044 public: 00045 ManagerImpl( ManagerNotifier *, const QString &family ); 00046 ~ManagerImpl(); 00047 00048 void readConfig( KConfig * ); 00049 void writeConfig( KConfig * ); 00050 00051 void add( Resource *resource ); 00052 void remove( Resource *resource ); 00053 void change( Resource *resource ); 00054 00055 Resource *standardResource(); 00056 void setStandardResource( Resource *resource ); 00057 00058 void setActive( Resource *resource, bool active ); 00059 00060 Resource::List *resourceList(); 00061 00062 QList<Resource *> resources(); 00063 00064 // Get only active or passive resources 00065 QList<Resource *> resources( bool active ); 00066 00067 QStringList resourceNames(); 00068 00069 static QString defaultConfigFile( const QString &family ); 00070 00071 Q_SIGNALS: 00072 void signalKResourceAdded( QString managerId, QString resourceId ); 00073 void signalKResourceModified( QString managerId, QString resourceId ); 00074 void signalKResourceDeleted( QString managerId, QString resourceId ); 00075 00076 private Q_SLOTS: 00077 // dbus calls 00078 void dbusKResourceAdded( const QString &managerId, 00079 const QString &resourceId ); 00080 void dbusKResourceModified( const QString &managerId, 00081 const QString &resourceId ); 00082 void dbusKResourceDeleted( const QString &managerId, 00083 const QString &resourceId ); 00084 00085 private: 00086 void createStandardConfig(); 00087 00088 Resource *readResourceConfig( const QString &identifier, bool checkActive ); 00089 void writeResourceConfig( Resource *resource, bool checkActive ); 00090 00091 void removeResource( Resource *resource ); 00092 Resource *getResource( Resource *resource ); 00093 Resource *getResource( const QString &identifier ); 00094 00095 class ManagerImplPrivate; 00096 ManagerImplPrivate *const d; 00097 }; 00098 00099 } 00100 00101 #endif