summaryrefslogtreecommitdiffabout
path: root/microkde/kresources/factory.cpp
Side-by-side diff
Diffstat (limited to 'microkde/kresources/factory.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kresources/factory.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/microkde/kresources/factory.cpp b/microkde/kresources/factory.cpp
index a3b7fff..5fbfa68 100644
--- a/microkde/kresources/factory.cpp
+++ b/microkde/kresources/factory.cpp
@@ -13,48 +13,53 @@
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <kdebug.h>
#include <klocale.h>
#include <ksimpleconfig.h>
#include <kstandarddirs.h>
#include <kstaticdeleter.h>
//#ifndef DESKTOP_VERSION
#include <klibloader.h>
//#endif
#include <qfile.h>
#include "resource.h"
#include "factory.h"
+#ifdef STATIC_RESOURCES
+#include <file/resourcefile.h>
+#include <dir/resourcedir.h>
+#include <qtopia/resourceqtopia.h>
+#endif
using namespace KRES;
QDict<Factory> *Factory::mSelves = 0;
static KStaticDeleter< QDict<Factory> > staticDeleter;
Factory *Factory::self( const QString& resourceFamily)
{
Factory *factory = 0;
if ( !mSelves )
{
mSelves = staticDeleter.setObject( new QDict<Factory> );
}
factory = mSelves->find( resourceFamily );
if ( !factory ) {
factory = new Factory( resourceFamily);
mSelves->insert( resourceFamily, factory );
}
return factory;
}
@@ -198,59 +203,80 @@ QString Factory::typeName( const QString &type ) const
//US return ptr->name();
PluginInfo* pi = mTypeMap[ type ];
return pi->nameLabel;
}
QString Factory::typeDescription( const QString &type ) const
{
if ( type.isEmpty() || !mTypeMap.contains( type ) )
return QString();
//US KService::Ptr ptr = mTypeMap[ type ];
//US return ptr->comment();
PluginInfo* pi = mTypeMap[ type ];
return pi->descriptionLabel;
}
Resource *Factory::resource( const QString& type, const KConfig *config )
{
if ( type.isEmpty() || !mTypeMap.contains( type ) )
return 0;
+#ifdef STATIC_RESOURCES
+ qDebug("NEW STATIC RESOURCE %s", type.latin1());
+ Resource *resource = 0;
+ if ( type == "file" ) {
+ resource = (Resource *) new KABC::ResourceFile( config );
+ } else if ( type == "dir" ) {
+ resource = new KABC::ResourceDir( config );
+ } else if ( type == "qtopia" ) {
+ resource = new KABC::ResourceQtopia( config );
+ }
+ if ( !resource)
+ qDebug("Factory::resource:: resources are statically linked. resource type %s is not supported ",type.latin1() );
+ else
+ resource->setType( type );
+ return resource;
+#else
+
+
+
/*US load the lib not dynamicly. !!
KService::Ptr ptr = mTypeMap[ type ];
KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() );
if ( !factory ) {
kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl;
return 0;
}
*/
PluginInfo* pi = mTypeMap[ type ];
KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() );
if ( !factory ) {
qDebug("KRES::Factory::resource(): Factory creation failed for library %s", pi->library.latin1());
kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl;
return 0;
}
PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory );
if ( !pluginFactory ) {
qDebug("KRES::Factory::resource(): no plugin factory for library %s", pi->library.latin1());
kdDebug() << "KRES::Factory::resource(): no plugin factory." << endl;
return 0;
}
Resource *resource = pluginFactory->resource( config );
if ( !resource ) {
//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl;
qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1());
return 0;
}
resource->setType( type );
return resource;
+
+#endif
}