summaryrefslogtreecommitdiff
authorzecke <zecke>2004-09-12 23:18:37 (UTC)
committer zecke <zecke>2004-09-12 23:18:37 (UTC)
commitf05a19bd1e248ea8cea29d361a1a8085ca145c6a (patch) (side-by-side diff)
treeae7204968f4e8841232a976eb9cc341db65dca50
parent8123b75c55cb5140ae5b0c5aeddb4644a0a8ffbb (diff)
downloadopie-f05a19bd1e248ea8cea29d361a1a8085ca145c6a.zip
opie-f05a19bd1e248ea8cea29d361a1a8085ca145c6a.tar.gz
opie-f05a19bd1e248ea8cea29d361a1a8085ca145c6a.tar.bz2
If there is no 'excluded' plugin the excluded-list wasn't made
empty and the old/prior setting still was used. This fix makes sure that an empty string is written if no plugin is excluded
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiecore/opluginloader.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/libopie2/opiecore/opluginloader.cpp b/libopie2/opiecore/opluginloader.cpp
index 1edf3a1..b8b6b79 100644
--- a/libopie2/opiecore/opluginloader.cpp
+++ b/libopie2/opiecore/opluginloader.cpp
@@ -514,122 +514,126 @@ QString OGenericPluginLoader::unlibify( const QString& str ) {
return st.left( st.findRev( ".so" ) );
#endif
}
/**
* @internal
*
* \brief method to return available plugins. Internal and for reeimplementations
*
*Return a List of Plugins for a dir and add positions and remove disabled.
* If a plugin is on the excluded list assign position -2
*
* @param dir The dir to look in
* @param sorted Should positions be read?
* @param disabled Remove excluded from the list
*/
OPluginItem::List OGenericPluginLoader::plugins( const QString& _dir, bool sorted, bool disabled )const {
#ifdef Q_OS_MACX
QDir dir( _dir, "lib*.dylib" );
#else
QDir dir( _dir, "lib*.so" );
#endif
OPluginItem::List lst;
/*
* get excluded list and then iterate over them
* Excluded list contains the name
* Position is a list with 'name.pos.name.pos.name.pos'
*
* For the look up we will create two QMap<QString,pos>
*/
QMap<QString, int> positionMap;
QMap<QString, int> excludedMap;
OConfig cfg( m_dir+"-odpplugins" );
cfg.setGroup( _dir );
QStringList excludes = cfg.readListEntry( "Excluded", ',' );
for ( QStringList::Iterator it = excludes.begin(); it != excludes.end(); ++it )
excludedMap.insert( *it, -2 );
if ( sorted ) {
QStringList pos = cfg.readListEntry( "Positions", '.' );
QStringList::Iterator it = pos.begin();
- while ( it != pos.end() )
- positionMap.insert( *it++, (*it++).toInt() );
+ QString tmp; int i;
+ while ( it != pos.end() ) {
+ tmp = *it++; i = (*it++).toInt();
+ positionMap.insert( tmp, i );
+ }
}
QStringList list = dir.entryList();
for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
QString str = unlibify( *it );
OPluginItem item( str, _dir + "/" + *it );
bool ex = excludedMap.contains( str );
/*
* if disabled but we should show all mark it as disabled
* else continue because we don't want to add the item
* else if sorted we assign the right position
*/
if ( ex && !disabled)
item.setEnabled( false );
else if ( ex && disabled )
continue;
else if ( sorted )
item.setPosition( positionMap[str] );
+
lst.append( item );
}
return lst;
}
/**
* @internal generate a list of languages from $LANG
*/
QStringList OGenericPluginLoader::languageList() {
if ( m_languages.isEmpty() ) {
/*
* be_BY.CP1251 We will add, be_BY.CP1251,be_BY,be
* to our list of languages.
*/
QString str = ::getenv( "LANG" );
m_languages += str;
int pos = str.find( '.' );
if ( pos > 0 )
m_languages += str.left( pos );
int n_pos = str.find( '_' );
if ( pos > 0 && n_pos >= pos )
m_languages += str.left( n_pos );
}
return m_languages;
}
/**
* @internal
* Tries to install languages using the languageList for the type
*/
void OGenericPluginLoader::installTranslators(const QString& type) {
QStringList lst = languageList();
/*
* for each language and maybe later for each language dir...
* try to load a Translator
*/
for ( QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) {
QTranslator* trans = new QTranslator( qApp );
QString tfn = QPEApplication::qpeDir()+"/i18n/" + *it + "/" + type + ".qm" ;
/*
* If loaded then install else clean up and don't leak
*/
@@ -789,96 +793,99 @@ void OPluginManager::setEnabled( const OPluginItem& _item, bool b ) {
* For the name and the list of plugins this does only try to find out the crashed plugin
*/
void OPluginManager::load() {
OConfig cfg( configName() );
cfg.setGroup( "General" );
QString crashedPath = cfg.readEntry( "CrashedPlugin" );
/* if we've a loader this applies if we were called from the first part */
if ( m_loader )
m_plugins = m_loader->allAvailable( m_loader->isSorted() );
/* fast and normal route if we did not crash... */
if ( crashedPath.isEmpty() )
return;
/* lets try to find the plugin path and this way the associated item */
for ( OPluginItem::List::Iterator it = m_plugins.begin(); it != m_plugins.end(); ++it )
if ( (*it).path() == crashedPath ) {
m_crashed = *it;
break;
}
}
/**
* \brief Save the values and this way make it available.
*
* Save the current set of data. A call to @see OGenericPluginLoader::filtered
* now would return your saved changes.
*/
void OPluginManager::save() {
QMap<QString, QStringList> excluded; // map for path to excluded name
QMap<QString, QStringList> positions; // if positions matter contains splitted up by dirs
bool sorted = m_loader ? m_loader->isSorted() : m_isSorted;
/*
* We will create some maps for the groups to include positions a
*/
for ( OPluginItem::List::Iterator it = m_plugins.begin(); it != m_plugins.end(); ++it ) {
OPluginItem item = *it;
QString path = QFileInfo( item.path() ).dirPath(true);
if ( sorted ) {
positions[path].append( item.name() );
positions[path].append( QString::number( item.position() ) );
}
if ( !item.isEnabled() )
excluded[path].append( item.name() );
+ if ( !excluded.contains( path ) )
+ excluded[path] = QString::null;
+
}
/*
* The code below wouldn't work because we can't delete groups/keys from the config
* ### for ODP make Config right!
*/
// if ( excluded.isEmpty() && positions.isEmpty() ) return;
/*
* Now safe for each path
*/
OConfig cfg( configName() );
/* safe excluded items */
for ( QMap<QString, QStringList>::Iterator it = excluded.begin(); it != excluded.end(); ++it ) {
OConfigGroupSaver saver( &cfg, it.key() );
cfg.writeEntry("Excluded", it.data(), ',' );
}
/* safe positions we could also see if positions.contains(path) and remove/write in the above loop
* ### Write a Test Suite that can profile these runs...
*/
for ( QMap<QString, QStringList>::Iterator it = positions.begin(); it != positions.end(); ++it ) {
OConfigGroupSaver saver( &cfg, it.key() );
cfg.writeEntry("Positions", it.data(), '.' );
}
}
/**
* @internal
*/
QString OPluginManager::configName()const {
QString str = m_loader ? m_loader->name() : m_cfgName;
return str + "-odpplugins";
}
/**
* @internal.. replace in m_plugins by path... this is linear search O(n/2)
*/
void OPluginManager::replace( const OPluginItem& item ) {
OPluginItem _item;
/* for all plugins */
for ( OPluginItem::List::Iterator it=m_plugins.begin();it != m_plugins.end(); ++it ) {
_item = *it;
/* if path and name are the same we will remove, readd and return */
if ( _item.path() == item.path() &&
_item.name() == item.name() ) {
it = m_plugins.remove( it );