Diffstat (limited to 'microkde/kresources/factory.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/kresources/factory.cpp | 44 |
1 files changed, 39 insertions, 5 deletions
diff --git a/microkde/kresources/factory.cpp b/microkde/kresources/factory.cpp index f82e94c..7a5c2f6 100644 --- a/microkde/kresources/factory.cpp +++ b/microkde/kresources/factory.cpp @@ -38,9 +38,9 @@ using namespace KRES; QDict<Factory> *Factory::mSelves = 0; static KStaticDeleter< QDict<Factory> > staticDeleter; -Factory *Factory::self( const QString& resourceFamily ) +Factory *Factory::self( const QString& resourceFamily) { Factory *factory = 0; @@ -51,16 +51,16 @@ Factory *Factory::self( const QString& resourceFamily ) factory = mSelves->find( resourceFamily ); if ( !factory ) { - factory = new Factory( resourceFamily ); + factory = new Factory( resourceFamily); mSelves->insert( resourceFamily, factory ); } return factory; } -Factory::Factory( const QString& resourceFamily ) : +Factory::Factory( const QString& resourceFamily) : mResourceFamily( resourceFamily ) { //US so far we have three types available for resourceFamily "contact" // and that are "file", "dir", "ldap" @@ -186,8 +186,42 @@ ConfigWidget *Factory::configWidget( const QString& type, QWidget *parent ) return wdg; } +SyncWidget *Factory::syncWidget( const QString& type, QWidget *parent ) +{ + if ( type.isEmpty() || !mTypeMap.contains( type ) ) + return 0; + +//US KService::Ptr ptr = mTypeMap[ type ]; +//US KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); + PluginInfo* pi = mTypeMap[ type ]; + KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() ); + if ( !factory ) { + qDebug("KRES::Factory::syncWidget(): Factory creation failed for library %s", pi->library.latin1()); + kdDebug() << "KRES::Factory::syncWidget(): Factory creation failed" << endl; + return 0; + } + + PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory ); + + if ( !pluginFactory ) { + qDebug("KRES::Factory::syncWidget(): no plugin factory for library %s", pi->library.latin1()); + kdDebug() << "KRES::Factory::syncWidget(): no plugin factory." << endl; + return 0; + } + + SyncWidget *wdg = pluginFactory->syncWidget( 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(); @@ -210,9 +244,9 @@ QString Factory::typeDescription( const QString &type ) const PluginInfo* pi = mTypeMap[ type ]; return pi->descriptionLabel; } -Resource *Factory::resource( const QString& type, const KConfig *config ) +Resource *Factory::resource( const QString& type, const KConfig *config, bool syncable ) { if ( type.isEmpty() || !mTypeMap.contains( type ) ) @@ -241,9 +275,9 @@ Resource *Factory::resource( const QString& type, const KConfig *config ) kdDebug() << "KRES::Factory::resource(): no plugin factory." << endl; return 0; } - Resource *resource = pluginFactory->resource( config ); + Resource *resource = pluginFactory->resource( config, syncable ); 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; |