summaryrefslogtreecommitdiffabout
path: root/microkde
Unidiff
Diffstat (limited to 'microkde') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kresources/factory.cpp54
1 files changed, 33 insertions, 21 deletions
diff --git a/microkde/kresources/factory.cpp b/microkde/kresources/factory.cpp
index 2253de4..f82e94c 100644
--- a/microkde/kresources/factory.cpp
+++ b/microkde/kresources/factory.cpp
@@ -42,5 +42,5 @@ static KStaticDeleter< QDict<Factory> > staticDeleter;
42Factory *Factory::self( const QString& resourceFamily ) 42Factory *Factory::self( const QString& resourceFamily )
43{ 43{
44 44
45 45
46 Factory *factory = 0; 46 Factory *factory = 0;
@@ -55,5 +55,5 @@ Factory *Factory::self( const QString& resourceFamily )
55 factory = new Factory( resourceFamily ); 55 factory = new Factory( resourceFamily );
56 mSelves->insert( resourceFamily, factory ); 56 mSelves->insert( resourceFamily, factory );
57 } 57 }
58 58
59 return factory; 59 return factory;
@@ -65,6 +65,6 @@ Factory::Factory( const QString& resourceFamily ) :
65//US so far we have three types available for resourceFamily "contact" 65//US so far we have three types available for resourceFamily "contact"
66// and that are "file", "dir", "ldap" 66// and that are "file", "dir", "ldap"
67/*US 67/*US
68 68
69 KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin", QString( "[X-KDE-ResourceFamily] == '%1'" ) 69 KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin", QString( "[X-KDE-ResourceFamily] == '%1'" )
70 .arg( resourceFamily ) ); 70 .arg( resourceFamily ) );
@@ -75,7 +75,7 @@ Factory::Factory( const QString& resourceFamily ) :
75 mTypeMap.insert( type.toString(), *it ); 75 mTypeMap.insert( type.toString(), *it );
76 } 76 }
77*/ 77*/
78 78
79//US new 79//US new
80 PluginInfo* info = new PluginInfo; 80 PluginInfo* info = new PluginInfo;
81 info->library = "microkabc_file"; 81 info->library = "microkabc_file";
@@ -89,5 +89,5 @@ Factory::Factory( const QString& resourceFamily ) :
89 info->descriptionLabel = i18n( "Choose a directory with may files" ); 89 info->descriptionLabel = i18n( "Choose a directory with may files" );
90 mTypeMap.insert( "dir", info ); 90 mTypeMap.insert( "dir", info );
91 91
92 info = new PluginInfo; 92 info = new PluginInfo;
93 info->library = "microkabc_ldap"; 93 info->library = "microkabc_ldap";
@@ -96,5 +96,5 @@ Factory::Factory( const QString& resourceFamily ) :
96 mTypeMap.insert( "ldap", info ); 96 mTypeMap.insert( "ldap", info );
97 97
98 //US add opie plugin only, if the library exists 98 //US add opie plugin only, if the library exists.
99 QString libname = "microkabc_opie"; 99 QString libname = "microkabc_opie";
100 QString path = KLibLoader::findLibrary( QFile::encodeName( libname ) ); 100 QString path = KLibLoader::findLibrary( QFile::encodeName( libname ) );
@@ -108,5 +108,5 @@ Factory::Factory( const QString& resourceFamily ) :
108 } 108 }
109 109
110 //US add qtopia plugin only, if the library exists 110 //US add qtopia plugin only, if the library exists.
111 libname = "microkabc_qtopia"; 111 libname = "microkabc_qtopia";
112 path = KLibLoader::findLibrary( QFile::encodeName( libname ) ); 112 path = KLibLoader::findLibrary( QFile::encodeName( libname ) );
@@ -119,5 +119,17 @@ Factory::Factory( const QString& resourceFamily ) :
119 mTypeMap.insert( "qtopia", info ); 119 mTypeMap.insert( "qtopia", info );
120 } 120 }
121 121
122 //US add sharp plugin only, if the library exists.
123 libname = "microkabc_sharpdtm";
124 path = KLibLoader::findLibrary( QFile::encodeName( libname ) );
125 if ( !path.isEmpty() )
126 {
127 info = new PluginInfo;
128 info->library = libname;
129 info->nameLabel = i18n( "sharp" );
130 info->descriptionLabel = i18n( "Sharp DTM Addressbook." );
131 mTypeMap.insert( "sharp", info );
132 }
133
122 134
123} 135}
@@ -131,7 +143,7 @@ QStringList Factory::typeNames() const
131//US method QMap::keys() not available yet. SO collect the data manually 143//US method QMap::keys() not available yet. SO collect the data manually
132//US return mTypeMap.keys(); 144//US return mTypeMap.keys();
133 145
134 QStringList result; 146 QStringList result;
135 147
136 QMap<QString, PluginInfo*>::ConstIterator it; 148 QMap<QString, PluginInfo*>::ConstIterator it;
137 for( it = mTypeMap.begin(); it != mTypeMap.end(); ++it ) { 149 for( it = mTypeMap.begin(); it != mTypeMap.end(); ++it ) {
@@ -173,5 +185,5 @@ ConfigWidget *Factory::configWidget( const QString& type, QWidget *parent )
173 } 185 }
174 return wdg; 186 return wdg;
175 187
176} 188}
177 189
@@ -181,10 +193,10 @@ QString Factory::typeName( const QString &type ) const
181 return QString(); 193 return QString();
182 194
183 195
184//US KService::Ptr ptr = mTypeMap[ type ]; 196//US KService::Ptr ptr = mTypeMap[ type ];
185//US return ptr->name(); 197//US return ptr->name();
186 PluginInfo* pi = mTypeMap[ type ]; 198 PluginInfo* pi = mTypeMap[ type ];
187 return pi->nameLabel; 199 return pi->nameLabel;
188 200
189} 201}
190 202
@@ -202,10 +214,10 @@ QString Factory::typeDescription( const QString &type ) const
202Resource *Factory::resource( const QString& type, const KConfig *config ) 214Resource *Factory::resource( const QString& type, const KConfig *config )
203{ 215{
204 216
205 217
206 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 218 if ( type.isEmpty() || !mTypeMap.contains( type ) )
207 return 0; 219 return 0;
208 220
209/*US load the lib not dynamicly. !! 221/*US load the lib not dynamicly. !!
210 KService::Ptr ptr = mTypeMap[ type ]; 222 KService::Ptr ptr = mTypeMap[ type ];
211 KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); 223 KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() );
@@ -222,5 +234,5 @@ Resource *Factory::resource( const QString& type, const KConfig *config )
222 return 0; 234 return 0;
223 } 235 }
224 236
225 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory ); 237 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory );
226 238
@@ -230,7 +242,7 @@ Resource *Factory::resource( const QString& type, const KConfig *config )
230 return 0; 242 return 0;
231 } 243 }
232 244
233 Resource *resource = pluginFactory->resource( config ); 245 Resource *resource = pluginFactory->resource( config );
234 if ( !resource ) { 246 if ( !resource ) {
235//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; 247//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl;
236 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); 248 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1());
@@ -239,5 +251,5 @@ Resource *Factory::resource( const QString& type, const KConfig *config )
239 251
240 resource->setType( type ); 252 resource->setType( type );
241 253
242 return resource; 254 return resource;
243} 255}