summaryrefslogtreecommitdiff
authorzecke <zecke>2004-05-29 18:43:13 (UTC)
committer zecke <zecke>2004-05-29 18:43:13 (UTC)
commit43c1ce80bc5faf16fe9d86c4685512659f5180bc (patch) (unidiff)
treeebd64b019954d702a39bad96d3324bbe79d7f9b6
parentf568ff9c68bdc61cbc4482f9b2c6e1096cecaae0 (diff)
downloadopie-43c1ce80bc5faf16fe9d86c4685512659f5180bc.zip
opie-43c1ce80bc5faf16fe9d86c4685512659f5180bc.tar.gz
opie-43c1ce80bc5faf16fe9d86c4685512659f5180bc.tar.bz2
Make Enabled/Disabled work.
Problem was /home/ich/foo//plugins/foo where /home/ich/foo/ was OPIEDIR and we added /
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/opluginloader.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/libopie2/opiecore/opluginloader.cpp b/libopie2/opiecore/opluginloader.cpp
index 3d286e5..e7eddc2 100644
--- a/libopie2/opiecore/opluginloader.cpp
+++ b/libopie2/opiecore/opluginloader.cpp
@@ -156,508 +156,509 @@ bool OPluginItem::isEmpty()const {
156 * operator to test equalness of two OPluginItem 156 * operator to test equalness of two OPluginItem
157 */ 157 */
158bool OPluginItem::operator==( const OPluginItem& r )const{ 158bool OPluginItem::operator==( const OPluginItem& r )const{
159 if ( m_pos != r.m_pos ) return false; 159 if ( m_pos != r.m_pos ) return false;
160 if ( m_enabled != r.m_enabled) return false; 160 if ( m_enabled != r.m_enabled) return false;
161 if ( m_name != r.m_name ) return false; 161 if ( m_name != r.m_name ) return false;
162 if ( m_path != r.m_path ) return false; 162 if ( m_path != r.m_path ) return false;
163 return true; 163 return true;
164} 164}
165 165
166/** 166/**
167 * \brief test non equality 167 * \brief test non equality
168 * operator to test non-equalness of two OPluginItem 168 * operator to test non-equalness of two OPluginItem
169 */ 169 */
170bool OPluginItem::operator!=( const OPluginItem& r )const{ 170bool OPluginItem::operator!=( const OPluginItem& r )const{
171 return !( *this == r ); 171 return !( *this == r );
172} 172}
173 173
174/** 174/**
175 * \brief returns the name of the plugin 175 * \brief returns the name of the plugin
176 * return the name of this Plugin 176 * return the name of this Plugin
177 */ 177 */
178QString OPluginItem::name()const { 178QString OPluginItem::name()const {
179 return m_name; 179 return m_name;
180} 180}
181 181
182/** 182/**
183 * \brief return the path of the plugin 183 * \brief return the path of the plugin
184 */ 184 */
185QString OPluginItem::path()const { 185QString OPluginItem::path()const {
186 return m_path; 186 return m_path;
187} 187}
188 188
189/** 189/**
190 * \brief Return if this item is enabled. 190 * \brief Return if this item is enabled.
191 */ 191 */
192bool OPluginItem::isEnabled()const { 192bool OPluginItem::isEnabled()const {
193 return m_enabled; 193 return m_enabled;
194} 194}
195 195
196/** 196/**
197 * \brief return the position of a plugin. 197 * \brief return the position of a plugin.
198 * return the position of the item 198 * return the position of the item
199 * -1 is the default value and means normally that the whole items are unsorted. 199 * -1 is the default value and means normally that the whole items are unsorted.
200 * Higher numbers belong to an upper position. With plugins with the postions 20,19,5,3 200 * Higher numbers belong to an upper position. With plugins with the postions 20,19,5,3
201 * the item with pos 20 would be the first in the list returned by the OGenericPluginLoader 201 * the item with pos 20 would be the first in the list returned by the OGenericPluginLoader
202 * 202 *
203 * @see OGenericPluginLoader::allAvailable 203 * @see OGenericPluginLoader::allAvailable
204 * @see OGenericPluginLoader::filtered 204 * @see OGenericPluginLoader::filtered
205 */ 205 */
206int OPluginItem::position()const{ 206int OPluginItem::position()const{
207 return m_pos; 207 return m_pos;
208} 208}
209 209
210/** 210/**
211 * \brief set the name of a plugin 211 * \brief set the name of a plugin
212 * Set the name of the Plugin Item 212 * Set the name of the Plugin Item
213 * @param name 213 * @param name
214 */ 214 */
215void OPluginItem::setName( const QString& name ) { 215void OPluginItem::setName( const QString& name ) {
216 m_name = name; 216 m_name = name;
217} 217}
218 218
219/** 219/**
220 * \brief set the path of a plugin 220 * \brief set the path of a plugin
221 * Set the path of Plugin Item. The path must be absolute. 221 * Set the path of Plugin Item. The path must be absolute.
222 * @param name The path of the plugin 222 * @param name The path of the plugin
223 */ 223 */
224void OPluginItem::setPath( const QString& name ) { 224void OPluginItem::setPath( const QString& name ) {
225 m_path = name; 225 m_path = name;
226} 226}
227 227
228/** 228/**
229 * \brief enable or disable the to load attribute 229 * \brief enable or disable the to load attribute
230 * Set the Enabled attribute. Such changes won't be saved. If you want to save it 230 * Set the Enabled attribute. Such changes won't be saved. If you want to save it
231 * use a OPluginManager to configure your plugins manually or Opie::Ui::OPluginConfig 231 * use a OPluginManager to configure your plugins manually or Opie::Ui::OPluginConfig
232 * for a graphical frontend. 232 * for a graphical frontend.
233 * 233 *
234 * @param enabled Enable or Disable the Enabled Attribute 234 * @param enabled Enable or Disable the Enabled Attribute
235 */ 235 */
236void OPluginItem::setEnabled( bool enabled ) { 236void OPluginItem::setEnabled( bool enabled ) {
237 m_enabled = enabled; 237 m_enabled = enabled;
238} 238}
239 239
240/** 240/**
241 * \brief Set the position. 241 * \brief Set the position.
242 * Set the position 242 * Set the position
243 * @param pos The position 243 * @param pos The position
244 * 244 *
245 * @see position() 245 * @see position()
246 */ 246 */
247void OPluginItem::setPosition( int pos ) { 247void OPluginItem::setPosition( int pos ) {
248 m_pos = pos; 248 m_pos = pos;
249} 249}
250 250
251 251
252 252
253/** 253/**
254 * \brief create a PluginLoader 254 * \brief create a PluginLoader
255 * 255 *
256 * Create a PluginLoader autoDelete is set to false 256 * Create a PluginLoader autoDelete is set to false
257 * 257 *
258 * \code 258 * \code
259 * Opie::Core::OGenericPluginLoader loader("myapp-plugin"); 259 * Opie::Core::OGenericPluginLoader loader("myapp-plugin");
260 * Opie::Core::OPluginItem::List lst = loader.filtered(); 260 * Opie::Core::OPluginItem::List lst = loader.filtered();
261 * for(Opie::Core::OPluginItem::List::Iterator it = lst.begin(); it!=lst.end();++it){ 261 * for(Opie::Core::OPluginItem::List::Iterator it = lst.begin(); it!=lst.end();++it){
262 * MyIface* iface = static_cast<MyIface*>(loader.load(*it,IID_MyIface)); 262 * MyIface* iface = static_cast<MyIface*>(loader.load(*it,IID_MyIface));
263 * } 263 * }
264 * \endcode 264 * \endcode
265 * 265 *
266 * \code 266 * \code
267 * Opie::Core::OGenericPluginLoader loader("myapp-plugin"); 267 * Opie::Core::OGenericPluginLoader loader("myapp-plugin");
268 * Opie::Core::OPluginItem::List lst = loader.filtered(); 268 * Opie::Core::OPluginItem::List lst = loader.filtered();
269 * for(Opie::Core::OPluginItem::List::Iterator it = lst.begin(); it!=lst.end();++it){ 269 * for(Opie::Core::OPluginItem::List::Iterator it = lst.begin(); it!=lst.end();++it){
270 * MyIface* iface = static_cast<MyIface*>(loader.load(*it,IID_MyIface)); 270 * MyIface* iface = static_cast<MyIface*>(loader.load(*it,IID_MyIface));
271 * } 271 * }
272 * ... 272 * ...
273 * loader.clear(); 273 * loader.clear();
274 * 274 *
275 * \endcode 275 * \endcode
276 * 276 *
277 * @param name The name of the plugin directory. 277 * @param name The name of the plugin directory.
278 * @param isSorted Tell the PluginLoader if your Plugins are sorted 278 * @param isSorted Tell the PluginLoader if your Plugins are sorted
279 */ 279 */
280OGenericPluginLoader::OGenericPluginLoader( const QString& name, bool isSorted) 280OGenericPluginLoader::OGenericPluginLoader( const QString& name, bool isSorted)
281 : m_dir( name ), m_autoDelete( false ), m_isSafeMode( false ), 281 : m_dir( name ), m_autoDelete( false ), m_isSafeMode( false ),
282 m_isSorted( isSorted ) 282 m_isSorted( isSorted )
283{ 283{
284 setPluginDir( QPEApplication::qpeDir() + "/plugins/"+name ); 284 setPluginDir( QPEApplication::qpeDir() + "plugins/"+name );
285 readConfig(); 285 readConfig();
286} 286}
287 287
288 288
289/** 289/**
290 * \brief simple d'tor that cleans up depending on autoDelete 290 * \brief simple d'tor that cleans up depending on autoDelete
291 * 291 *
292 * calls clear if autoDelete is true. This will release all interfaces 292 * calls clear if autoDelete is true. This will release all interfaces
293 * and remove the library from this process if the refcount falls to zero 293 * and remove the library from this process if the refcount falls to zero
294 */ 294 */
295OGenericPluginLoader::~OGenericPluginLoader() { 295OGenericPluginLoader::~OGenericPluginLoader() {
296 if ( m_autoDelete ) 296 if ( m_autoDelete )
297 clear(); 297 clear();
298} 298}
299 299
300/** 300/**
301 * \brief Enable or disable autoDelete on destruction 301 * \brief Enable or disable autoDelete on destruction
302 * 302 *
303 * enable autoDelete. This will call clear on the d'tor 303 * enable autoDelete. This will call clear on the d'tor
304 * 304 *
305 * @see ~OGenericPluginLoader 305 * @see ~OGenericPluginLoader
306 * @see clear() 306 * @see clear()
307 */ 307 */
308void OGenericPluginLoader::setAutoDelete( bool t ) { 308void OGenericPluginLoader::setAutoDelete( bool t ) {
309 m_autoDelete = t; 309 m_autoDelete = t;
310} 310}
311 311
312/** 312/**
313 * \brief See if autoDelete is enabled. 313 * \brief See if autoDelete is enabled.
314 */ 314 */
315bool OGenericPluginLoader::autoDelete()const{ 315bool OGenericPluginLoader::autoDelete()const{
316 return m_autoDelete; 316 return m_autoDelete;
317} 317}
318 318
319/** 319/**
320 * \brief unload all loaded Plugins 320 * \brief unload all loaded Plugins
321 * 321 *
322 * This will unload all returned QUnknownInterfaces by load. Unload 322 * This will unload all returned QUnknownInterfaces by load. Unload
323 * will be called. 323 * will be called.
324 */ 324 */
325void OGenericPluginLoader::clear() { 325void OGenericPluginLoader::clear() {
326 QPtrDictIterator<QLibrary> it( m_library ); 326 QPtrDictIterator<QLibrary> it( m_library );
327 for ( ;it.current(); ) 327 for ( ;it.current(); )
328 unload( static_cast<QUnknownInterface*>( it.currentKey() ) ); 328 unload( static_cast<QUnknownInterface*>( it.currentKey() ) );
329} 329}
330 330
331/** 331/**
332 * \brief unload the Plugin and the accompanied Resources. 332 * \brief unload the Plugin and the accompanied Resources.
333 * 333 *
334 * This will take the iface from the internal QPtrDict, Release it, 334 * This will take the iface from the internal QPtrDict, Release it,
335 * and deref the libray used. 335 * and deref the libray used.
336 * The visibility depends on the QPtrDict. 336 * The visibility depends on the QPtrDict.
337 * @see QPtrDict::insert 337 * @see QPtrDict::insert
338 */ 338 */
339void OGenericPluginLoader::unload( QUnknownInterface* iface ) { 339void OGenericPluginLoader::unload( QUnknownInterface* iface ) {
340 if ( !iface ) 340 if ( !iface )
341 return; 341 return;
342 342
343 iface->release(); 343 iface->release();
344 Internal::OPluginLibraryHolder::self()->deref( m_library.take( iface ) ); 344 Internal::OPluginLibraryHolder::self()->deref( m_library.take( iface ) );
345} 345}
346 346
347/** 347/**
348 * \brief The name of the plugins. 348 * \brief The name of the plugins.
349 * 349 *
350 * Return the name/type you specified in the constructor. 350 * Return the name/type you specified in the constructor.
351 * This is at least used by the OPluginManager to find the right config 351 * This is at least used by the OPluginManager to find the right config
352 */ 352 */
353QString OGenericPluginLoader::name()const { 353QString OGenericPluginLoader::name()const {
354 return m_dir; 354 return m_dir;
355} 355}
356 356
357 357
358/** 358/**
359 * \brief See if loading of a plugin segfaulted 359 * \brief See if loading of a plugin segfaulted
360 * This tells you 360 * This tells you
361 * if by previous tries to load, loading crashed your application. 361 * if by previous tries to load, loading crashed your application.
362 * If isInSafeMode you can use the GUI to configure the plugins prior to loading 362 * If isInSafeMode you can use the GUI to configure the plugins prior to loading
363 * 363 *
364 * @return true if prior loading failed 364 * @return true if prior loading failed
365 */ 365 */
366bool OGenericPluginLoader::isInSafeMode()const { 366bool OGenericPluginLoader::isInSafeMode()const {
367 return m_isSafeMode; 367 return m_isSafeMode;
368} 368}
369 369
370 370
371/** 371/**
372 * \brief Return all Plugins found in the plugins dirs. 372 * \brief Return all Plugins found in the plugins dirs.
373 * Return the list of all available plugins. This will go through all plugin 373 * Return the list of all available plugins. This will go through all plugin
374 * directories and search for your type of plugins ( by subdir ) 374 * directories and search for your type of plugins ( by subdir )
375 * 375 *
376 * @param sorted Tell if you want to have the positions sorted. This only makes sense if you 376 * @param sorted Tell if you want to have the positions sorted. This only makes sense if you
377 */ 377 */
378OPluginItem::List OGenericPluginLoader::allAvailable( bool sorted )const { 378OPluginItem::List OGenericPluginLoader::allAvailable( bool sorted )const {
379 OPluginItem::List lst; 379 OPluginItem::List lst;
380 for ( QStringList::ConstIterator it = m_plugDirs.begin(); it != m_plugDirs.end(); ++it ) 380 for ( QStringList::ConstIterator it = m_plugDirs.begin(); it != m_plugDirs.end(); ++it )
381 lst += plugins( *it, sorted, false ); 381 lst += plugins( *it, sorted, false );
382 382
383 if ( sorted ) 383 if ( sorted )
384 qHeapSort( lst ); 384 qHeapSort( lst );
385 return lst; 385 return lst;
386} 386}
387 387
388/** 388/**
389 * \brief Return only the enabled plugins 389 * \brief Return only the enabled plugins
390 * Return only activated plugins. 390 * Return only activated plugins.
391 * 391 *
392 * @param sorted If the list should be sorted 392 * @param sorted If the list should be sorted
393 */ 393 */
394OPluginItem::List OGenericPluginLoader::filtered( bool sorted )const { 394OPluginItem::List OGenericPluginLoader::filtered( bool sorted )const {
395 OPluginItem::List lst; 395 OPluginItem::List lst;
396 for ( QStringList::ConstIterator it = m_plugDirs.begin(); it != m_plugDirs.end(); ++it ) 396 for ( QStringList::ConstIterator it = m_plugDirs.begin(); it != m_plugDirs.end(); ++it )
397 lst += plugins( *it, sorted, true ); 397 lst += plugins( *it, sorted, true );
398 398
399 if ( sorted ) 399 if ( sorted )
400 qHeapSort( lst ); 400 qHeapSort( lst );
401 return lst; 401 return lst;
402} 402}
403 403
404 404
405/** 405/**
406 * \brief Load a OPluginItem for the specified interface 406 * \brief Load a OPluginItem for the specified interface
407 * This will open the resource of the OPluginItem::path() and then will query 407 * This will open the resource of the OPluginItem::path() and then will query
408 * if the Interface specified in the uuid is available and then will manage the 408 * if the Interface specified in the uuid is available and then will manage the
409 * resource and Interface. 409 * resource and Interface.
410 * 410 *
411 * @param item The OPluginItem that should be loaded 411 * @param item The OPluginItem that should be loaded
412 * @param uuid The Interface to query for 412 * @param uuid The Interface to query for
413 * 413 *
414 * @return Either 0 in case of failure or the Plugin as QUnknownInterface* 414 * @return Either 0 in case of failure or the Plugin as QUnknownInterface*
415 */ 415 */
416QUnknownInterface* OGenericPluginLoader::load( const OPluginItem& item, const QUuid& uuid) { 416QUnknownInterface* OGenericPluginLoader::load( const OPluginItem& item, const QUuid& uuid) {
417 /* 417 /*
418 * Check if there could be a library 418 * Check if there could be a library
419 */ 419 */
420 QString pa = item.path(); 420 QString pa = item.path();
421 if ( pa.isEmpty() ) 421 if ( pa.isEmpty() )
422 return 0l; 422 return 0l;
423 423
424 /* 424 /*
425 * See if we get a library 425 * See if we get a library
426 * return if we've none 426 * return if we've none
427 */ 427 */
428 setSafeMode( pa, true ); 428 setSafeMode( pa, true );
429 QLibrary *lib = Internal::OPluginLibraryHolder::self()->ref( pa ); 429 QLibrary *lib = Internal::OPluginLibraryHolder::self()->ref( pa );
430 if ( !lib ) { 430 if ( !lib ) {
431 setSafeMode(); 431 setSafeMode();
432 return 0l; 432 return 0l;
433 } 433 }
434 434
435 /** 435 /**
436 * try to load the plugin and just in case initialize the pointer to a pointer again 436 * try to load the plugin and just in case initialize the pointer to a pointer again
437 */ 437 */
438 QUnknownInterface* iface=0; 438 QUnknownInterface* iface=0;
439 if ( lib->queryInterface( uuid, &iface ) == QS_OK ) { 439 if ( lib->queryInterface( uuid, &iface ) == QS_OK ) {
440 installTranslators(pa.left( pa.find("."))); 440 installTranslators(pa.left( pa.find(".")));
441 m_library.insert( iface, lib ); 441 m_library.insert( iface, lib );
442 }else 442 }else
443 iface = 0; 443 iface = 0;
444 444
445 setSafeMode(); 445 setSafeMode();
446 446
447 return iface; 447 return iface;
448} 448}
449 449
450/** 450/**
451 * @internal and reads in the safe mode 451 * @internal and reads in the safe mode
452 */ 452 */
453void OGenericPluginLoader::readConfig() { 453void OGenericPluginLoader::readConfig() {
454 454
455 455
456/* read the config for SafeMode */ 456/* read the config for SafeMode */
457 OConfig conf( m_dir + "-odpplugins" ); 457 OConfig conf( m_dir + "-odpplugins" );
458 conf.setGroup( "General" ); 458 conf.setGroup( "General" );
459 m_isSafeMode = conf.readBoolEntry( "SafeMode", false ); 459 m_isSafeMode = conf.readBoolEntry( "SafeMode", false );
460} 460}
461 461
462/** 462/**
463 * @internal Enter or leave SafeMode 463 * @internal Enter or leave SafeMode
464 */ 464 */
465void OGenericPluginLoader::setSafeMode(const QString& str, bool b) { 465void OGenericPluginLoader::setSafeMode(const QString& str, bool b) {
466 OConfig conf( m_dir + "-odpplugins" ); 466 OConfig conf( m_dir + "-odpplugins" );
467 conf.setGroup( "General" ); 467 conf.setGroup( "General" );
468 conf.writeEntry( "SafeMode", b ); 468 conf.writeEntry( "SafeMode", b );
469 conf.writeEntry( "CrashedPlugin", str ); 469 conf.writeEntry( "CrashedPlugin", str );
470} 470}
471 471
472/** 472/**
473 * @internal 473 * @internal
474 * 474 *
475 * Set the List of Plugin Dirs to lst. Currently only QPEApplication::qpeDir()+"/plugins/"+mytype 475 * Set the List of Plugin Dirs to lst. Currently only QPEApplication::qpeDir()+"/plugins/"+mytype
476 * is used as plugin dir 476 * is used as plugin dir
477 */ 477 */
478void OGenericPluginLoader::setPluginDirs( const QStringList& lst ) { 478void OGenericPluginLoader::setPluginDirs( const QStringList& lst ) {
479 m_plugDirs = lst; 479 m_plugDirs = lst;
480} 480}
481 481
482/** 482/**
483 * 483 *
484 * @internal 484 * @internal
485 * Set the Plugin Dir to str. Str will be the only element in the list of plugin dirs 485 * Set the Plugin Dir to str. Str will be the only element in the list of plugin dirs
486 */ 486 */
487void OGenericPluginLoader::setPluginDir( const QString& str) { 487void OGenericPluginLoader::setPluginDir( const QString& str) {
488 m_plugDirs.clear(); 488 m_plugDirs.clear();
489 m_plugDirs.append( str ); 489 m_plugDirs.append( str );
490} 490}
491 491
492 492
493/** 493/**
494 * @internal 494 * @internal
495 */ 495 */
496bool OGenericPluginLoader::isSorted()const{ 496bool OGenericPluginLoader::isSorted()const{
497 return m_isSorted; 497 return m_isSorted;
498} 498}
499 499
500/* 500/*
501 * make libfoo.so.1.0.0 -> foo on UNIX 501 * make libfoo.so.1.0.0 -> foo on UNIX
502 * make libfoo.dylib -> foo on MAC OS X Unix 502 * make libfoo.dylib -> foo on MAC OS X Unix
503 * windows is obviously missing 503 * windows is obviously missing
504 */ 504 */
505/** 505/**
506 * @internal 506 * @internal
507 */ 507 */
508QString OGenericPluginLoader::unlibify( const QString& str ) { 508QString OGenericPluginLoader::unlibify( const QString& str ) {
509 QString st = str.mid( str.find( "lib" )+3 ); 509 QString st = str.mid( str.find( "lib" )+3 );
510#ifdef Q_OS_MACX 510#ifdef Q_OS_MACX
511 return st.left( st.findRev( ".dylib" ) ); 511 return st.left( st.findRev( ".dylib" ) );
512#else 512#else
513 return st.left( st.findRev( ".so" ) ); 513 return st.left( st.findRev( ".so" ) );
514#endif 514#endif
515} 515}
516 516
517/** 517/**
518 * @internal 518 * @internal
519 * 519 *
520 * \brief method to return available plugins. Internal and for reeimplementations 520 * \brief method to return available plugins. Internal and for reeimplementations
521 * 521 *
522 *Return a List of Plugins for a dir and add positions and remove disabled. 522 *Return a List of Plugins for a dir and add positions and remove disabled.
523 * If a plugin is on the excluded list assign position -2 523 * If a plugin is on the excluded list assign position -2
524 * 524 *
525 * @param dir The dir to look in 525 * @param dir The dir to look in
526 * @param sorted Should positions be read? 526 * @param sorted Should positions be read?
527 * @param disabled Remove excluded from the list 527 * @param disabled Remove excluded from the list
528 */ 528 */
529OPluginItem::List OGenericPluginLoader::plugins( const QString& _dir, bool sorted, bool disabled )const { 529OPluginItem::List OGenericPluginLoader::plugins( const QString& _dir, bool sorted, bool disabled )const {
530#ifdef Q_OS_MACX 530#ifdef Q_OS_MACX
531 QDir dir( _dir, "lib*.dylib" ); 531 QDir dir( _dir, "lib*.dylib" );
532#else 532#else
533 QDir dir( _dir, "lib*.so" ); 533 QDir dir( _dir, "lib*.so" );
534#endif 534#endif
535 535
536
536 OPluginItem::List lst; 537 OPluginItem::List lst;
537 538
538 /* 539 /*
539 * get excluded list and then iterate over them 540 * get excluded list and then iterate over them
540 * Excluded list contains the name 541 * Excluded list contains the name
541 * Position is a list with 'name.pos.name.pos.name.pos' 542 * Position is a list with 'name.pos.name.pos.name.pos'
542 * 543 *
543 * For the look up we will create two QMap<QString,pos> 544 * For the look up we will create two QMap<QString,pos>
544 */ 545 */
545 QMap<QString, int> positionMap; 546 QMap<QString, int> positionMap;
546 QMap<QString, int> excludedMap; 547 QMap<QString, int> excludedMap;
547 548
548 549
549 OConfig cfg( m_dir+"-odpplugins" ); 550 OConfig cfg( m_dir+"-odpplugins" );
550 cfg.setGroup( _dir ); 551 cfg.setGroup( _dir );
551 552
552 553
553 QStringList excludes = cfg.readListEntry( "Excluded", ',' ); 554 QStringList excludes = cfg.readListEntry( "Excluded", ',' );
554 for ( QStringList::Iterator it = excludes.begin(); it != excludes.end(); ++it ) 555 for ( QStringList::Iterator it = excludes.begin(); it != excludes.end(); ++it )
555 excludedMap.insert( *it, -2 ); 556 excludedMap.insert( *it, -2 );
556 557
557 if ( m_isSorted ) { 558 if ( m_isSorted ) {
558 QStringList pos = cfg.readListEntry( "Positions", '.' ); 559 QStringList pos = cfg.readListEntry( "Positions", '.' );
559 QStringList::Iterator it = pos.begin(); 560 QStringList::Iterator it = pos.begin();
560 while ( it != pos.end() ) 561 while ( it != pos.end() )
561 positionMap.insert( *it++, (*it++).toInt() ); 562 positionMap.insert( *it++, (*it++).toInt() );
562 } 563 }
563 564
564 565
565 566
566 567
567 QStringList list = dir.entryList(); 568 QStringList list = dir.entryList();
568 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 569 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
569 QString str = unlibify( *it ); 570 QString str = unlibify( *it );
570 OPluginItem item( str, _dir + "/" + *it ); 571 OPluginItem item( str, _dir + "/" + *it );
571 572
572 bool ex = excludedMap.contains( str ); 573 bool ex = excludedMap.contains( str );
573 /* 574 /*
574 * if disabled but we should show all mark it as disabled 575 * if disabled but we should show all mark it as disabled
575 * else continue because we don't want to add the item 576 * else continue because we don't want to add the item
576 * else if sorted we assign the right position 577 * else if sorted we assign the right position
577 */ 578 */
578 if ( ex && !disabled) 579 if ( ex && !disabled)
579 item.setEnabled( false ); 580 item.setEnabled( false );
580 else if ( ex && disabled ) 581 else if ( ex && disabled )
581 continue; 582 continue;
582 else if ( sorted ) 583 else if ( sorted )
583 item.setPosition( positionMap[str] ); 584 item.setPosition( positionMap[str] );
584 585
585 lst.append( item ); 586 lst.append( item );
586 } 587 }
587 588
588 return lst; 589 return lst;
589} 590}
590 591
591/** 592/**
592 * @internal generate a list of languages from $LANG 593 * @internal generate a list of languages from $LANG
593 */ 594 */
594QStringList OGenericPluginLoader::languageList() { 595QStringList OGenericPluginLoader::languageList() {
595 if ( m_languages.isEmpty() ) { 596 if ( m_languages.isEmpty() ) {
596 /* 597 /*
597 * be_BY.CP1251 We will add, be_BY.CP1251,be_BY,be 598 * be_BY.CP1251 We will add, be_BY.CP1251,be_BY,be
598 * to our list of languages. 599 * to our list of languages.
599 */ 600 */
600 QString str = ::getenv( "LANG" ); 601 QString str = ::getenv( "LANG" );
601 m_languages += str; 602 m_languages += str;
602 int pos = str.find( '.' ); 603 int pos = str.find( '.' );
603 604
604 if ( pos > 0 ) 605 if ( pos > 0 )
605 m_languages += str.left( pos ); 606 m_languages += str.left( pos );
606 607
607 int n_pos = str.find( '_' ); 608 int n_pos = str.find( '_' );
608 if ( pos > 0 && n_pos >= pos ) 609 if ( pos > 0 && n_pos >= pos )
609 m_languages += str.left( n_pos ); 610 m_languages += str.left( n_pos );
610 611
611 } 612 }
612 return m_languages; 613 return m_languages;
613} 614}
614 615
615/** 616/**
616 * @internal 617 * @internal
617 * Tries to install languages using the languageList for the type 618 * Tries to install languages using the languageList for the type
618 */ 619 */
619void OGenericPluginLoader::installTranslators(const QString& type) { 620void OGenericPluginLoader::installTranslators(const QString& type) {
620 QStringList lst = languageList(); 621 QStringList lst = languageList();
621 622
622 /* 623 /*
623 * for each language and maybe later for each language dir... 624 * for each language and maybe later for each language dir...
624 * try to load a Translator 625 * try to load a Translator
625 */ 626 */
626 for ( QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { 627 for ( QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) {
627 QTranslator* trans = new QTranslator( qApp ); 628 QTranslator* trans = new QTranslator( qApp );
628 QString tfn = QPEApplication::qpeDir()+"/i18n/" + *it + "/" + type + ".qm" ; 629 QString tfn = QPEApplication::qpeDir()+"/i18n/" + *it + "/" + type + ".qm" ;
629 630
630 /* 631 /*
631 * If loaded then install else clean up and don't leak 632 * If loaded then install else clean up and don't leak
632 */ 633 */
633 if ( trans->load( tfn ) ) 634 if ( trans->load( tfn ) )
634 qApp->installTranslator( trans ); 635 qApp->installTranslator( trans );
635 else 636 else
636 delete trans; 637 delete trans;
637 } 638 }
638} 639}
639 640
640/** 641/**
641 * \brief Simple c'tor. 642 * \brief Simple c'tor.
642 * 643 *
643 * Simple C'tor same as the one of the base class. Additional this 644 * Simple C'tor same as the one of the base class. Additional this
644 * class can cast for you if you nee it. 645 * class can cast for you if you nee it.
645 * 646 *
646 * 647 *
647 * @param name The name of your plugin class 648 * @param name The name of your plugin class
648 * @param sorted If plugins are sorted 649 * @param sorted If plugins are sorted
649 * 650 *
650 * @see OGenericPluginLoader 651 * @see OGenericPluginLoader
651 */ 652 */
652OPluginLoader::OPluginLoader( const QString& name, bool sorted ) 653OPluginLoader::OPluginLoader( const QString& name, bool sorted )
653 : OGenericPluginLoader( name, sorted ) 654 : OGenericPluginLoader( name, sorted )
654{ 655{
655} 656}
656 657
657/** 658/**
658 * d'tor 659 * d'tor
659 * @see OGenericPluginLoader::~OGenericPluginLoader 660 * @see OGenericPluginLoader::~OGenericPluginLoader
660 */ 661 */
661OPluginLoader::~OPluginLoader() { 662OPluginLoader::~OPluginLoader() {
662} 663}
663 664