-rw-r--r-- | libopie2/opiecore/opluginloader.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libopie2/opiecore/opluginloader.cpp b/libopie2/opiecore/opluginloader.cpp index 87e24d4..c2dc239 100644 --- a/libopie2/opiecore/opluginloader.cpp +++ b/libopie2/opiecore/opluginloader.cpp | |||
@@ -501,97 +501,97 @@ bool OGenericPluginLoader::isSorted()const{ | |||
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 | */ |
508 | QString OGenericPluginLoader::unlibify( const QString& str ) { | 508 | QString 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 | */ |
529 | OPluginItem::List OGenericPluginLoader::plugins( const QString& _dir, bool sorted, bool disabled )const { | 529 | OPluginItem::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 | OPluginItem::List lst; | 536 | OPluginItem::List lst; |
537 | 537 | ||
538 | /* | 538 | /* |
539 | * get excluded list and then iterate over them | 539 | * get excluded list and then iterate over them |
540 | * Excluded list contains the name | 540 | * Excluded list contains the name |
541 | * Position is a list with 'name.pos.name.pos.name.pos' | 541 | * Position is a list with 'name.pos.name.pos.name.pos' |
542 | * | 542 | * |
543 | * For the look up we will create two QMap<QString,pos> | 543 | * For the look up we will create two QMap<QString,pos> |
544 | */ | 544 | */ |
545 | QMap<QString, int> positionMap; | 545 | QMap<QString, int> positionMap; |
546 | QMap<QString, int> excludedMap; | 546 | QMap<QString, int> excludedMap; |
547 | 547 | ||
548 | 548 | ||
549 | OConfig cfg( m_dir+"odpplugins" ); | 549 | OConfig cfg( m_dir+"-odpplugins" ); |
550 | cfg.setGroup( _dir ); | 550 | cfg.setGroup( _dir ); |
551 | 551 | ||
552 | 552 | ||
553 | QStringList excludes = cfg.readListEntry( "Excluded", ',' ); | 553 | QStringList excludes = cfg.readListEntry( "Excluded", ',' ); |
554 | for ( QStringList::Iterator it = excludes.begin(); it != excludes.end(); ++it ) | 554 | for ( QStringList::Iterator it = excludes.begin(); it != excludes.end(); ++it ) |
555 | excludedMap.insert( *it, -2 ); | 555 | excludedMap.insert( *it, -2 ); |
556 | 556 | ||
557 | if ( m_isSorted ) { | 557 | if ( m_isSorted ) { |
558 | QStringList pos = cfg.readListEntry( "Positions", '.' ); | 558 | QStringList pos = cfg.readListEntry( "Positions", '.' ); |
559 | QStringList::Iterator it = pos.begin(); | 559 | QStringList::Iterator it = pos.begin(); |
560 | while ( it != pos.end() ) | 560 | while ( it != pos.end() ) |
561 | positionMap.insert( *it++, (*it++).toInt() ); | 561 | positionMap.insert( *it++, (*it++).toInt() ); |
562 | } | 562 | } |
563 | 563 | ||
564 | 564 | ||
565 | 565 | ||
566 | 566 | ||
567 | QStringList list = dir.entryList(); | 567 | QStringList list = dir.entryList(); |
568 | for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 568 | for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
569 | QString str = unlibify( *it ); | 569 | QString str = unlibify( *it ); |
570 | OPluginItem item( str, _dir + "/" + *it ); | 570 | OPluginItem item( str, _dir + "/" + *it ); |
571 | 571 | ||
572 | bool ex = excludedMap.contains( str ); | 572 | bool ex = excludedMap.contains( str ); |
573 | /* | 573 | /* |
574 | * if disabled but we should show all mark it as disabled | 574 | * if disabled but we should show all mark it as disabled |
575 | * else continue because we don't want to add the item | 575 | * else continue because we don't want to add the item |
576 | * else if sorted we assign the right position | 576 | * else if sorted we assign the right position |
577 | */ | 577 | */ |
578 | if ( ex && !disabled) | 578 | if ( ex && !disabled) |
579 | item.setEnabled( false ); | 579 | item.setEnabled( false ); |
580 | else if ( ex && disabled ) | 580 | else if ( ex && disabled ) |
581 | continue; | 581 | continue; |
582 | else if ( sorted ) | 582 | else if ( sorted ) |
583 | item.setPosition( positionMap[str] ); | 583 | item.setPosition( positionMap[str] ); |
584 | 584 | ||
585 | lst.append( item ); | 585 | lst.append( item ); |
586 | } | 586 | } |
587 | 587 | ||
588 | return lst; | 588 | return lst; |
589 | } | 589 | } |
590 | 590 | ||
591 | /** | 591 | /** |
592 | * @internal generate a list of languages from $LANG | 592 | * @internal generate a list of languages from $LANG |
593 | */ | 593 | */ |
594 | QStringList OGenericPluginLoader::languageList() { | 594 | QStringList OGenericPluginLoader::languageList() { |
595 | if ( m_languages.isEmpty() ) { | 595 | if ( m_languages.isEmpty() ) { |
596 | /* | 596 | /* |
597 | * be_BY.CP1251 We will add, be_BY.CP1251,be_BY,be | 597 | * be_BY.CP1251 We will add, be_BY.CP1251,be_BY,be |
@@ -818,73 +818,73 @@ void OPluginManager::save() { | |||
818 | QMap<QString, QStringList> positions; // if positions matter contains splitted up by dirs | 818 | QMap<QString, QStringList> positions; // if positions matter contains splitted up by dirs |
819 | bool sorted = m_loader ? m_loader->isSorted() : m_isSorted; | 819 | bool sorted = m_loader ? m_loader->isSorted() : m_isSorted; |
820 | 820 | ||
821 | /* | 821 | /* |
822 | * We will create some maps for the groups to include positions a | 822 | * We will create some maps for the groups to include positions a |
823 | */ | 823 | */ |
824 | for ( OPluginItem::List::Iterator it = m_plugins.begin(); it != m_plugins.end(); ++it ) { | 824 | for ( OPluginItem::List::Iterator it = m_plugins.begin(); it != m_plugins.end(); ++it ) { |
825 | OPluginItem item = *it; | 825 | OPluginItem item = *it; |
826 | QString path = QFileInfo( item.path() ).filePath(); | 826 | QString path = QFileInfo( item.path() ).filePath(); |
827 | if ( sorted ) { | 827 | if ( sorted ) { |
828 | positions[path].append( item.name() ); | 828 | positions[path].append( item.name() ); |
829 | positions[path].append( QString::number( item.position() ) ); | 829 | positions[path].append( QString::number( item.position() ) ); |
830 | } | 830 | } |
831 | 831 | ||
832 | if ( !item.isEnabled() ) | 832 | if ( !item.isEnabled() ) |
833 | excluded[path].append( item.name() ); | 833 | excluded[path].append( item.name() ); |
834 | } | 834 | } |
835 | 835 | ||
836 | /* | 836 | /* |
837 | * The code below wouldn't work because we can't delete groups/keys from the config | 837 | * The code below wouldn't work because we can't delete groups/keys from the config |
838 | * ### for ODP make Config right! | 838 | * ### for ODP make Config right! |
839 | */ | 839 | */ |
840 | // if ( excluded.isEmpty() && positions.isEmpty() ) return; | 840 | // if ( excluded.isEmpty() && positions.isEmpty() ) return; |
841 | /* | 841 | /* |
842 | * Now safe for each path | 842 | * Now safe for each path |
843 | */ | 843 | */ |
844 | OConfig cfg( configName() ); | 844 | OConfig cfg( configName() ); |
845 | 845 | ||
846 | /* safe excluded items */ | 846 | /* safe excluded items */ |
847 | for ( QMap<QString, QStringList>::Iterator it = excluded.begin(); it != excluded.end(); ++it ) { | 847 | for ( QMap<QString, QStringList>::Iterator it = excluded.begin(); it != excluded.end(); ++it ) { |
848 | OConfigGroupSaver saver( &cfg, it.key() ); | 848 | OConfigGroupSaver saver( &cfg, it.key() ); |
849 | cfg.writeEntry("Excluded", it.data(), ',' ); | 849 | cfg.writeEntry("Excluded", it.data(), ',' ); |
850 | } | 850 | } |
851 | 851 | ||
852 | /* safe positions we could also see if positions.contains(path) and remove/write in the above loop | 852 | /* safe positions we could also see if positions.contains(path) and remove/write in the above loop |
853 | * ### Write a Test Suite that can profile these runs... | 853 | * ### Write a Test Suite that can profile these runs... |
854 | */ | 854 | */ |
855 | for ( QMap<QString, QStringList>::Iterator it = positions.begin(); it != positions.end(); ++it ) { | 855 | for ( QMap<QString, QStringList>::Iterator it = positions.begin(); it != positions.end(); ++it ) { |
856 | OConfigGroupSaver saver( &cfg, it.key() ); | 856 | OConfigGroupSaver saver( &cfg, it.key() ); |
857 | cfg.writeEntry("Positions", it.data(), '.' ); | 857 | cfg.writeEntry("Positions", it.data(), '.' ); |
858 | } | 858 | } |
859 | } | 859 | } |
860 | 860 | ||
861 | /** | 861 | /** |
862 | * @internal | 862 | * @internal |
863 | */ | 863 | */ |
864 | QString OPluginManager::configName()const { | 864 | QString OPluginManager::configName()const { |
865 | QString str = m_loader ? m_loader->name() : m_cfgName; | 865 | QString str = m_loader ? m_loader->name() : m_cfgName; |
866 | return str + "odpplugins"; | 866 | return str + "-odpplugins"; |
867 | } | 867 | } |
868 | 868 | ||
869 | /** | 869 | /** |
870 | * @internal.. replace in m_plugins by path... this is linear search O(n/2) | 870 | * @internal.. replace in m_plugins by path... this is linear search O(n/2) |
871 | */ | 871 | */ |
872 | void OPluginManager::replace( const OPluginItem& item ) { | 872 | void OPluginManager::replace( const OPluginItem& item ) { |
873 | OPluginItem _item; | 873 | OPluginItem _item; |
874 | 874 | ||
875 | /* for all plugins */ | 875 | /* for all plugins */ |
876 | for ( OPluginItem::List::Iterator it=m_plugins.begin();it != m_plugins.end(); ++it ) { | 876 | for ( OPluginItem::List::Iterator it=m_plugins.begin();it != m_plugins.end(); ++it ) { |
877 | _item = *it; | 877 | _item = *it; |
878 | /* if path and name are the same we will remove, readd and return */ | 878 | /* if path and name are the same we will remove, readd and return */ |
879 | if ( _item.path() == item.path() && | 879 | if ( _item.path() == item.path() && |
880 | _item.name() == item.name() ) { | 880 | _item.name() == item.name() ) { |
881 | it = m_plugins.remove( it ); | 881 | it = m_plugins.remove( it ); |
882 | m_plugins.append( item ); | 882 | m_plugins.append( item ); |
883 | return; | 883 | return; |
884 | } | 884 | } |
885 | 885 | ||
886 | } | 886 | } |
887 | } | 887 | } |
888 | 888 | ||
889 | } | 889 | } |
890 | } | 890 | } |