summaryrefslogtreecommitdiff
authorzecke <zecke>2004-08-25 21:53:50 (UTC)
committer zecke <zecke>2004-08-25 21:53:50 (UTC)
commita64c92819cd3106584d9005e42ed972726081a94 (patch) (unidiff)
treef8ac45c7154db71a988cc5a9596587a30b9d9cce
parentdf3e4c8b13c16aeb96e70dbaa2d409f83eed988e (diff)
downloadopie-a64c92819cd3106584d9005e42ed972726081a94.zip
opie-a64c92819cd3106584d9005e42ed972726081a94.tar.gz
opie-a64c92819cd3106584d9005e42ed972726081a94.tar.bz2
Respect the value passed to the method
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/opluginloader.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/libopie2/opiecore/opluginloader.cpp b/libopie2/opiecore/opluginloader.cpp
index e7eddc2..1edf3a1 100644
--- a/libopie2/opiecore/opluginloader.cpp
+++ b/libopie2/opiecore/opluginloader.cpp
@@ -1,55 +1,56 @@
1/* 1/*
2 * LGPLv2 or later 2 * LGPLv2 or later
3 * zecke@handhelds.org 3 * zecke@handhelds.org
4 */ 4 */
5 5
6#include "opluginloader.h" 6#include "opluginloader.h"
7#include "oconfig.h" 7#include "oconfig.h"
8#include "odebug.h"
8 9
9#include <qpe/qpeapplication.h> 10#include <qpe/qpeapplication.h>
10 11
11#include <qdir.h> 12#include <qdir.h>
12#include <qdict.h> 13#include <qdict.h>
13#include <qtl.h> 14#include <qtl.h>
14#include <qfile.h> 15#include <qfile.h>
15 16
16#include <stdlib.h> 17#include <stdlib.h>
17 18
18 19
19 20
20namespace Opie { 21namespace Opie {
21namespace Core { 22namespace Core {
22namespace Internal { 23namespace Internal {
23struct OPluginLibraryHolder { 24struct OPluginLibraryHolder {
24 static OPluginLibraryHolder *self(); 25 static OPluginLibraryHolder *self();
25 QLibrary *ref( const QString& ); 26 QLibrary *ref( const QString& );
26 void deref( QLibrary* ); 27 void deref( QLibrary* );
27private: 28private:
28 29
29 OPluginLibraryHolder(); 30 OPluginLibraryHolder();
30 ~OPluginLibraryHolder(); 31 ~OPluginLibraryHolder();
31 QDict<QLibrary> m_libs; 32 QDict<QLibrary> m_libs;
32 static OPluginLibraryHolder* m_self; 33 static OPluginLibraryHolder* m_self;
33}; 34};
34 35
35 OPluginLibraryHolder* OPluginLibraryHolder::m_self = 0; 36 OPluginLibraryHolder* OPluginLibraryHolder::m_self = 0;
36 OPluginLibraryHolder* OPluginLibraryHolder::self() { 37 OPluginLibraryHolder* OPluginLibraryHolder::self() {
37 if ( !m_self ) 38 if ( !m_self )
38 m_self = new OPluginLibraryHolder; 39 m_self = new OPluginLibraryHolder;
39 40
40 return m_self; 41 return m_self;
41 } 42 }
42 43
43 OPluginLibraryHolder::OPluginLibraryHolder() {} 44 OPluginLibraryHolder::OPluginLibraryHolder() {}
44 OPluginLibraryHolder::~OPluginLibraryHolder() {} 45 OPluginLibraryHolder::~OPluginLibraryHolder() {}
45 46
46 /* 47 /*
47 * We do simple ref counting... We will add the QLibrary again 48 * We do simple ref counting... We will add the QLibrary again
48 * and again to the dictionary and on deref we will pop and pop it 49 * and again to the dictionary and on deref we will pop and pop it
49 * until there are no more library and we will unload and delete the library 50 * until there are no more library and we will unload and delete the library
50 * luckily dlopen does some ref counting as well so we don't need 51 * luckily dlopen does some ref counting as well so we don't need
51 * to hack QPEApplication 52 * to hack QPEApplication
52 */ 53 */
53 QLibrary* OPluginLibraryHolder::ref(const QString& str) { 54 QLibrary* OPluginLibraryHolder::ref(const QString& str) {
54 QLibrary *lib = m_libs[str]; 55 QLibrary *lib = m_libs[str];
55 56
@@ -510,101 +511,102 @@ QString OGenericPluginLoader::unlibify( const QString& str ) {
510#ifdef Q_OS_MACX 511#ifdef Q_OS_MACX
511 return st.left( st.findRev( ".dylib" ) ); 512 return st.left( st.findRev( ".dylib" ) );
512#else 513#else
513 return st.left( st.findRev( ".so" ) ); 514 return st.left( st.findRev( ".so" ) );
514#endif 515#endif
515} 516}
516 517
517/** 518/**
518 * @internal 519 * @internal
519 * 520 *
520 * \brief method to return available plugins. Internal and for reeimplementations 521 * \brief method to return available plugins. Internal and for reeimplementations
521 * 522 *
522 *Return a List of Plugins for a dir and add positions and remove disabled. 523 *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 524 * If a plugin is on the excluded list assign position -2
524 * 525 *
525 * @param dir The dir to look in 526 * @param dir The dir to look in
526 * @param sorted Should positions be read? 527 * @param sorted Should positions be read?
527 * @param disabled Remove excluded from the list 528 * @param disabled Remove excluded from the list
528 */ 529 */
529OPluginItem::List OGenericPluginLoader::plugins( const QString& _dir, bool sorted, bool disabled )const { 530OPluginItem::List OGenericPluginLoader::plugins( const QString& _dir, bool sorted, bool disabled )const {
530#ifdef Q_OS_MACX 531#ifdef Q_OS_MACX
531 QDir dir( _dir, "lib*.dylib" ); 532 QDir dir( _dir, "lib*.dylib" );
532#else 533#else
533 QDir dir( _dir, "lib*.so" ); 534 QDir dir( _dir, "lib*.so" );
534#endif 535#endif
535 536
536 537
537 OPluginItem::List lst; 538 OPluginItem::List lst;
538 539
539 /* 540 /*
540 * get excluded list and then iterate over them 541 * get excluded list and then iterate over them
541 * Excluded list contains the name 542 * Excluded list contains the name
542 * Position is a list with 'name.pos.name.pos.name.pos' 543 * Position is a list with 'name.pos.name.pos.name.pos'
543 * 544 *
544 * For the look up we will create two QMap<QString,pos> 545 * For the look up we will create two QMap<QString,pos>
545 */ 546 */
546 QMap<QString, int> positionMap; 547 QMap<QString, int> positionMap;
547 QMap<QString, int> excludedMap; 548 QMap<QString, int> excludedMap;
548 549
549 550
550 OConfig cfg( m_dir+"-odpplugins" ); 551 OConfig cfg( m_dir+"-odpplugins" );
551 cfg.setGroup( _dir ); 552 cfg.setGroup( _dir );
552 553
553 554
554 QStringList excludes = cfg.readListEntry( "Excluded", ',' ); 555 QStringList excludes = cfg.readListEntry( "Excluded", ',' );
555 for ( QStringList::Iterator it = excludes.begin(); it != excludes.end(); ++it ) 556 for ( QStringList::Iterator it = excludes.begin(); it != excludes.end(); ++it )
556 excludedMap.insert( *it, -2 ); 557 excludedMap.insert( *it, -2 );
557 558
558 if ( m_isSorted ) { 559 if ( sorted ) {
559 QStringList pos = cfg.readListEntry( "Positions", '.' ); 560 QStringList pos = cfg.readListEntry( "Positions", '.' );
560 QStringList::Iterator it = pos.begin(); 561 QStringList::Iterator it = pos.begin();
561 while ( it != pos.end() ) 562 while ( it != pos.end() )
562 positionMap.insert( *it++, (*it++).toInt() ); 563 positionMap.insert( *it++, (*it++).toInt() );
564
563 } 565 }
564 566
565 567
566 568
567 569
568 QStringList list = dir.entryList(); 570 QStringList list = dir.entryList();
569 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 571 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
570 QString str = unlibify( *it ); 572 QString str = unlibify( *it );
571 OPluginItem item( str, _dir + "/" + *it ); 573 OPluginItem item( str, _dir + "/" + *it );
572 574
573 bool ex = excludedMap.contains( str ); 575 bool ex = excludedMap.contains( str );
574 /* 576 /*
575 * if disabled but we should show all mark it as disabled 577 * if disabled but we should show all mark it as disabled
576 * else continue because we don't want to add the item 578 * else continue because we don't want to add the item
577 * else if sorted we assign the right position 579 * else if sorted we assign the right position
578 */ 580 */
579 if ( ex && !disabled) 581 if ( ex && !disabled)
580 item.setEnabled( false ); 582 item.setEnabled( false );
581 else if ( ex && disabled ) 583 else if ( ex && disabled )
582 continue; 584 continue;
583 else if ( sorted ) 585 else if ( sorted )
584 item.setPosition( positionMap[str] ); 586 item.setPosition( positionMap[str] );
585 587
586 lst.append( item ); 588 lst.append( item );
587 } 589 }
588 590
589 return lst; 591 return lst;
590} 592}
591 593
592/** 594/**
593 * @internal generate a list of languages from $LANG 595 * @internal generate a list of languages from $LANG
594 */ 596 */
595QStringList OGenericPluginLoader::languageList() { 597QStringList OGenericPluginLoader::languageList() {
596 if ( m_languages.isEmpty() ) { 598 if ( m_languages.isEmpty() ) {
597 /* 599 /*
598 * be_BY.CP1251 We will add, be_BY.CP1251,be_BY,be 600 * be_BY.CP1251 We will add, be_BY.CP1251,be_BY,be
599 * to our list of languages. 601 * to our list of languages.
600 */ 602 */
601 QString str = ::getenv( "LANG" ); 603 QString str = ::getenv( "LANG" );
602 m_languages += str; 604 m_languages += str;
603 int pos = str.find( '.' ); 605 int pos = str.find( '.' );
604 606
605 if ( pos > 0 ) 607 if ( pos > 0 )
606 m_languages += str.left( pos ); 608 m_languages += str.left( pos );
607 609
608 int n_pos = str.find( '_' ); 610 int n_pos = str.find( '_' );
609 if ( pos > 0 && n_pos >= pos ) 611 if ( pos > 0 && n_pos >= pos )
610 m_languages += str.left( n_pos ); 612 m_languages += str.left( n_pos );