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 <qstring.h>
00027 #include <qptrlist.h>
00028 #include <qdict.h>
00029 
00030 #include "manageriface.h"
00031 #include <kresources/resource.h>
00032 
00033 class KConfig;
00034 
00035 namespace KRES {
00036 
00037 class Resource;
00038 class Factory;
00039 class ManagerNotifier;
00040 
00046 class KRESOURCES_EXPORT ManagerImpl : virtual public ManagerIface
00047 {
00048   public:
00049     ManagerImpl( ManagerNotifier *, const QString &family );
00050     ~ManagerImpl();
00051 
00052     void readConfig( KConfig * );
00053     void writeConfig( KConfig * );
00054 
00055     void add( Resource *resource );
00056     void remove( Resource *resource );
00057     void change( Resource *resource );
00058 
00059     Resource *standardResource();
00060     void setStandardResource( Resource *resource );
00061 
00062     void setActive( Resource *resource, bool active );
00063 
00064     Resource::List *resourceList();
00065 
00066     QPtrList<Resource> resources();
00067 
00068     // Get only active or passive resources
00069     QPtrList<Resource> resources( bool active );
00070 
00071     QStringList resourceNames();
00072 
00073     static QString defaultConfigFile( const QString &family );
00074 
00075   private:
00076     // dcop calls
00077     void dcopKResourceAdded( QString managerId, QString resourceId );
00078     void dcopKResourceModified( QString managerId, QString resourceId );
00079     void dcopKResourceDeleted( QString managerId, QString resourceId );
00080 
00081   private:
00082     void createStandardConfig();
00083 
00084     Resource *readResourceConfig( const QString& identifier, bool checkActive );
00085     void writeResourceConfig( Resource *resource, bool checkActive );
00086 
00087     void removeResource( Resource *resource );
00088     Resource *getResource( Resource *resource );
00089     Resource *getResource( const QString& identifier );
00090 
00091     ManagerNotifier *mNotifier;
00092     QString mFamily;
00093     KConfig *mConfig;
00094     KConfig *mStdConfig;
00095     Resource *mStandard;
00096     Factory *mFactory;
00097     Resource::List mResources;
00098     QString mId;
00099     bool mConfigRead;
00100 
00101     class ManagerImplPrivate;
00102     ManagerImplPrivate *d;
00103 };
00104 
00105 }
00106 
00107 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys