summaryrefslogtreecommitdiffabout
path: root/microkde
Side-by-side diff
Diffstat (limited to 'microkde') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kresources/factory.cpp26
-rw-r--r--microkde/kresources/managerimpl.cpp2
-rw-r--r--microkde/microkde.pro8
3 files changed, 35 insertions, 1 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
@@ -1,84 +1,89 @@
/*
This file is part of libkresources.
Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
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;
}
Factory::Factory( const QString& resourceFamily) :
mResourceFamily( resourceFamily )
{
//US so far we have three types available for resourceFamily "contact"
// and that are "file", "dir", "ldap"
/*US
KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin", QString( "[X-KDE-ResourceFamily] == '%1'" )
.arg( resourceFamily ) );
KTrader::OfferList::ConstIterator it;
for ( it = plugins.begin(); it != plugins.end(); ++it ) {
QVariant type = (*it)->property( "X-KDE-ResourceType" );
if ( !type.toString().isEmpty() )
mTypeMap.insert( type.toString(), *it );
}
*/
//US new
PluginInfo* info = new PluginInfo;
info->library = "microkabc_file";
info->nameLabel = i18n( "file" );
info->descriptionLabel = i18n( "One file" );
mTypeMap.insert( "file", info );
@@ -174,83 +179,104 @@ ConfigWidget *Factory::configWidget( const QString& type, QWidget *parent )
if ( !pluginFactory ) {
qDebug("KRES::Factory::configWidget(): no plugin factory for library %s", pi->library.latin1());
kdDebug() << "KRES::Factory::configWidget(): no plugin factory." << endl;
return 0;
}
ConfigWidget *wdg = pluginFactory->configWidget( parent );
if ( !wdg ) {
//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl;
qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1());
return 0;
}
return wdg;
}
QString Factory::typeName( const QString &type ) const
{
if ( type.isEmpty() || !mTypeMap.contains( type ) )
return QString();
//US KService::Ptr ptr = mTypeMap[ type ];
//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
}
diff --git a/microkde/kresources/managerimpl.cpp b/microkde/kresources/managerimpl.cpp
index 566b8f4..a6d2007 100644
--- a/microkde/kresources/managerimpl.cpp
+++ b/microkde/kresources/managerimpl.cpp
@@ -1,90 +1,92 @@
/*
This file is part of libkresources.
Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
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.
*/
/*
Enhanced Version of the file for platform independent KDE tools.
Copyright (c) 2004 Ulf Schenk
$Id$
*/
#include <kglobal.h>
#include <kapplication.h>
#include <kdebug.h>
#include <kconfig.h>
#include <kstandarddirs.h>
#include <qfile.h>
#include "resource.h"
#include "factory.h"
#include "managerimpl.h"
+
+
using namespace KRES;
ManagerImpl::ManagerImpl( const QString &family )
: mFamily( family ), mConfig( 0 ), mStdConfig( 0 ), mStandard( 0 ),
mFactory( 0 )
{
kdDebug(5650) << "ManagerImpl::ManagerImpl()" << endl;
}
ManagerImpl::~ManagerImpl()
{
kdDebug(5650) << "ManagerImpl::~ManagerImpl()" << endl;
Resource::List::ConstIterator it;
for ( it = mResources.begin(); it != mResources.end(); ++it ) {
delete *it;
}
delete mStdConfig;
}
void ManagerImpl::createStandardConfig()
{
if ( !mStdConfig ) {
QString file = locateLocal( "data", KGlobal::getAppName()
+ "/kresources/" + mFamily + "rc" );
if ( mFamily == "tmpcontact" ) {
if (QFile::exists ( file ) ){
QFile::remove ( file );
qDebug("removed tmp rc file: %s ", file.latin1());
}
}
mStdConfig = new KConfig( file );
}
mConfig = mStdConfig;
}
void ManagerImpl::readConfig( KConfig *cfg )
{
kdDebug(5650) << "ManagerImpl::readConfig()" << endl;
delete mFactory;
mFactory = Factory::self( mFamily );
diff --git a/microkde/microkde.pro b/microkde/microkde.pro
index 9016260..783ec34 100644
--- a/microkde/microkde.pro
+++ b/microkde/microkde.pro
@@ -1,68 +1,74 @@
TEMPLATE = lib
CONFIG += qt warn_on
+include( ../variables.pri )
#INCLUDEPATH += $(QTDIR)/include .
#DEPENDPATH += $(QTDIR)/include
INCLUDEPATH += . ../ ../kabc ./kdecore ./kdeui ./kio/kfile ./kio/kio
#LIBS += -lqtcompat
TARGET = microkde
DESTDIR= ../bin
DEFINES += DESKTOP_VERSION KDE_QT_ONLY
unix : {
+staticlib: {
+INCLUDEPATH += ../kabc/plugins
+DEFINES += STATIC_RESOURCES
+}
+
+
OBJECTS_DIR = obj/unix
MOC_DIR = moc/unix
}
win32: {
DEFINES += _WIN32_
OBJECTS_DIR = obj/win
MOC_DIR = moc/win
}
-include( ../variables.pri )
HEADERS = \
qlayoutengine_p.h \
KDGanttMinimizeSplitter.h \
kapplication.h \
kaudioplayer.h \
kcalendarsystem.h \
kcalendarsystemgregorian.h \
kcolorbutton.h \
kcolordialog.h \
kcombobox.h \
kconfig.h \
kdatetbl.h \
kdebug.h \
kdialog.h \
kdialogbase.h \
keditlistbox.h \
kemailsettings.h \
kfiledialog.h \
kfontdialog.h \
kglobal.h \
kglobalsettings.h \
kiconloader.h \
klineedit.h \
klineeditdlg.h \
kmessagebox.h \
knotifyclient.h \
kprinter.h \
kprocess.h \
krestrictedline.h \
krun.h \
ksimpleconfig.h \
kstaticdeleter.h \
ksystemtray.h \
ktempfile.h \
ktextedit.h \
kunload.h \
kurl.h \
kdeui/kguiitem.h \
kdeui/kcmodule.h \
kdeui/kbuttonbox.h \
kdeui/klistbox.h \
kdeui/klistview.h \
kdeui/kjanuswidget.h \
kdeui/kseparator.h \
kdeui/knuminput.h \