diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:48:06 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:48:06 +0000 |
commit | 47c8a359c5276062c4bc17f0e82410f29081b502 (patch) | |
tree | 2d54a5f60a5b74067632f9ef6df58c2bc38155e6 /kopete/libkopete/kopetepluginmanager.cpp | |
parent | 6f82532777a35e0e60bbd2b290b2e93e646f349b (diff) | |
download | tdenetwork-47c8a359c5276062c4bc17f0e82410f29081b502.tar.gz tdenetwork-47c8a359c5276062c4bc17f0e82410f29081b502.zip |
Trinity Qt initial conversion
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1157648 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kopete/libkopete/kopetepluginmanager.cpp')
-rw-r--r-- | kopete/libkopete/kopetepluginmanager.cpp | 124 |
1 files changed, 62 insertions, 62 deletions
diff --git a/kopete/libkopete/kopetepluginmanager.cpp b/kopete/libkopete/kopetepluginmanager.cpp index 8f613a86..1aff9e9f 100644 --- a/kopete/libkopete/kopetepluginmanager.cpp +++ b/kopete/libkopete/kopetepluginmanager.cpp @@ -27,11 +27,11 @@ #include <valgrind/valgrind.h> #endif -#include <qapplication.h> -#include <qfile.h> -#include <qregexp.h> -#include <qtimer.h> -#include <qvaluestack.h> +#include <tqapplication.h> +#include <tqfile.h> +#include <tqregexp.h> +#include <tqtimer.h> +#include <tqvaluestack.h> #include <kapplication.h> #include <kdebug.h> @@ -56,11 +56,11 @@ public: Private() : shutdownMode( StartingUp ), isAllPluginsLoaded(false) {} // All available plugins, regardless of category, and loaded or not - QValueList<KPluginInfo *> plugins; + TQValueList<KPluginInfo *> plugins; // Dict of all currently loaded plugins, mapping the KPluginInfo to // a plugin - typedef QMap<KPluginInfo *, Plugin *> InfoToPluginMap; + typedef TQMap<KPluginInfo *, Plugin *> InfoToPluginMap; InfoToPluginMap loadedPlugins; // The plugin manager's mode. The mode is StartingUp until loadAllPlugins() @@ -71,7 +71,7 @@ public: ShutdownMode shutdownMode; // Plugins pending for loading - QValueStack<QString> pluginsToLoad; + TQValueStack<TQString> pluginsToLoad; static KStaticDeleter<PluginManager> deleter; @@ -89,10 +89,10 @@ PluginManager* PluginManager::self() return s_self; } -PluginManager::PluginManager() : QObject( qApp ), d( new Private ) +PluginManager::PluginManager() : TQObject( qApp ), d( new Private ) { - d->plugins = KPluginInfo::fromServices( KTrader::self()->query( QString::fromLatin1( "Kopete/Plugin" ), - QString::fromLatin1( "[X-Kopete-Version] == 1000900" ) ) ); + d->plugins = KPluginInfo::fromServices( KTrader::self()->query( TQString::fromLatin1( "Kopete/Plugin" ), + TQString::fromLatin1( "[X-Kopete-Version] == 1000900" ) ) ); // We want to add a reference to the application's event loop so we // can remain in control when all windows are removed. @@ -119,13 +119,13 @@ PluginManager::~PluginManager() delete d; } -QValueList<KPluginInfo *> PluginManager::availablePlugins( const QString &category ) const +TQValueList<KPluginInfo *> PluginManager::availablePlugins( const TQString &category ) const { if ( category.isEmpty() ) return d->plugins; - QValueList<KPluginInfo *> result; - QValueList<KPluginInfo *>::ConstIterator it; + TQValueList<KPluginInfo *> result; + TQValueList<KPluginInfo *>::ConstIterator it; for ( it = d->plugins.begin(); it != d->plugins.end(); ++it ) { if ( ( *it )->category() == category ) @@ -135,7 +135,7 @@ QValueList<KPluginInfo *> PluginManager::availablePlugins( const QString &catego return result; } -PluginList PluginManager::loadedPlugins( const QString &category ) const +PluginList PluginManager::loadedPlugins( const TQString &category ) const { PluginList result; @@ -205,17 +205,17 @@ void PluginManager::shutdown() kdDebug(14010) << k_funcinfo << "Running under valgrind, disabling plugin unload timeout guard" << endl; else #endif - QTimer::singleShot( 3000, this, SLOT( slotShutdownTimeout() ) ); + TQTimer::singleShot( 3000, this, TQT_SLOT( slotShutdownTimeout() ) ); } void PluginManager::slotPluginReadyForUnload() { - // Using QObject::sender() is on purpose here, because otherwise all + // Using TQObject::sender() is on purpose here, because otherwise all // plugins would have to pass 'this' as parameter, which makes the API // less clean for plugin authors // FIXME: I don't buy the above argument. Add a Kopete::Plugin::emitReadyForUnload(void), // and make readyForUnload be passed a plugin. - Richard - Plugin *plugin = dynamic_cast<Plugin *>( const_cast<QObject *>( sender() ) ); + Plugin *plugin = dynamic_cast<Plugin *>( const_cast<TQObject *>( sender() ) ); kdDebug( 14010 ) << k_funcinfo << plugin->pluginId() << "ready for unload" << endl; if ( !plugin ) { @@ -234,12 +234,12 @@ void PluginManager::slotShutdownTimeout() if ( d->shutdownMode == Private::DoneShutdown ) return; - QStringList remaining; + TQStringList remaining; for ( Private::InfoToPluginMap::ConstIterator it = d->loadedPlugins.begin(); it != d->loadedPlugins.end(); ++it ) remaining.append( it.data()->pluginId() ); kdWarning( 14010 ) << k_funcinfo << "Some plugins didn't shutdown in time!" << endl - << "Remaining plugins: " << remaining.join( QString::fromLatin1( ", " ) ) << endl + << "Remaining plugins: " << remaining.join( TQString::fromLatin1( ", " ) ) << endl << "Forcing Kopete shutdown now." << endl; slotShutdownDone(); @@ -259,29 +259,29 @@ void PluginManager::loadAllPlugins() // FIXME: We need session management here - Martijn KConfig *config = KGlobal::config(); - if ( config->hasGroup( QString::fromLatin1( "Plugins" ) ) ) + if ( config->hasGroup( TQString::fromLatin1( "Plugins" ) ) ) { - QMap<QString, bool> pluginsMap; + TQMap<TQString, bool> pluginsMap; - QMap<QString, QString> entries = config->entryMap( QString::fromLatin1( "Plugins" ) ); - QMap<QString, QString>::Iterator it; + TQMap<TQString, TQString> entries = config->entryMap( TQString::fromLatin1( "Plugins" ) ); + TQMap<TQString, TQString>::Iterator it; for ( it = entries.begin(); it != entries.end(); ++it ) { - QString key = it.key(); - if ( key.endsWith( QString::fromLatin1( "Enabled" ) ) ) - pluginsMap.insert( key.left( key.length() - 7 ), (it.data() == QString::fromLatin1( "true" )) ); + TQString key = it.key(); + if ( key.endsWith( TQString::fromLatin1( "Enabled" ) ) ) + pluginsMap.insert( key.left( key.length() - 7 ), (it.data() == TQString::fromLatin1( "true" )) ); } - QValueList<KPluginInfo *> plugins = availablePlugins( QString::null ); - QValueList<KPluginInfo *>::ConstIterator it2 = plugins.begin(); - QValueList<KPluginInfo *>::ConstIterator end = plugins.end(); + TQValueList<KPluginInfo *> plugins = availablePlugins( TQString::null ); + TQValueList<KPluginInfo *>::ConstIterator it2 = plugins.begin(); + TQValueList<KPluginInfo *>::ConstIterator end = plugins.end(); for ( ; it2 != end; ++it2 ) { // Protocols are loaded automatically so they aren't always in Plugins group. (fixes bug 167113) - if ( (*it2)->category() == QString::fromLatin1( "Protocols" ) ) + if ( (*it2)->category() == TQString::fromLatin1( "Protocols" ) ) continue; - QString pluginName = (*it2)->pluginName(); + TQString pluginName = (*it2)->pluginName(); bool inMap = pluginsMap.contains( pluginName ); if ( (inMap && pluginsMap[pluginName]) || (!inMap && (*it2)->isPluginEnabledByDefault()) ) { @@ -301,9 +301,9 @@ void PluginManager::loadAllPlugins() else { // we had no config, so we load any plugins that should be loaded by default. - QValueList<KPluginInfo *> plugins = availablePlugins( QString::null ); - QValueList<KPluginInfo *>::ConstIterator it = plugins.begin(); - QValueList<KPluginInfo *>::ConstIterator end = plugins.end(); + TQValueList<KPluginInfo *> plugins = availablePlugins( TQString::null ); + TQValueList<KPluginInfo *>::ConstIterator it = plugins.begin(); + TQValueList<KPluginInfo *>::ConstIterator end = plugins.end(); for ( ; it != end; ++it ) { if ( (*it)->isPluginEnabledByDefault() ) @@ -311,7 +311,7 @@ void PluginManager::loadAllPlugins() } } // Schedule the plugins to load - QTimer::singleShot( 0, this, SLOT( slotLoadNextPlugin() ) ); + TQTimer::singleShot( 0, this, TQT_SLOT( slotLoadNextPlugin() ) ); } void PluginManager::slotLoadNextPlugin() @@ -327,26 +327,26 @@ void PluginManager::slotLoadNextPlugin() return; } - QString key = d->pluginsToLoad.pop(); + TQString key = d->pluginsToLoad.pop(); loadPluginInternal( key ); // Schedule the next run unconditionally to avoid code duplication on the // allPluginsLoaded() signal's handling. This has the added benefit that // the signal is delayed one event loop, so the accounts are more likely // to be instantiated. - QTimer::singleShot( 0, this, SLOT( slotLoadNextPlugin() ) ); + TQTimer::singleShot( 0, this, TQT_SLOT( slotLoadNextPlugin() ) ); } -Plugin * PluginManager::loadPlugin( const QString &_pluginId, PluginLoadMode mode /* = LoadSync */ ) +Plugin * PluginManager::loadPlugin( const TQString &_pluginId, PluginLoadMode mode /* = LoadSync */ ) { - QString pluginId = _pluginId; + TQString pluginId = _pluginId; // Try to find legacy code // FIXME: Find any cases causing this, remove them, and remove this too - Richard - if ( pluginId.endsWith( QString::fromLatin1( ".desktop" ) ) ) + if ( pluginId.endsWith( TQString::fromLatin1( ".desktop" ) ) ) { kdWarning( 14010 ) << "Trying to use old-style API!" << endl << kdBacktrace() << endl; - pluginId = pluginId.remove( QRegExp( QString::fromLatin1( ".desktop$" ) ) ); + pluginId = pluginId.remove( TQRegExp( TQString::fromLatin1( ".desktop$" ) ) ); } if ( mode == LoadSync ) @@ -356,12 +356,12 @@ Plugin * PluginManager::loadPlugin( const QString &_pluginId, PluginLoadMode mod else { d->pluginsToLoad.push( pluginId ); - QTimer::singleShot( 0, this, SLOT( slotLoadNextPlugin() ) ); + TQTimer::singleShot( 0, this, TQT_SLOT( slotLoadNextPlugin() ) ); return 0L; } } -Plugin *PluginManager::loadPluginInternal( const QString &pluginId ) +Plugin *PluginManager::loadPluginInternal( const TQString &pluginId ) { //kdDebug( 14010 ) << k_funcinfo << pluginId << endl; @@ -376,16 +376,16 @@ Plugin *PluginManager::loadPluginInternal( const QString &pluginId ) return d->loadedPlugins[ info ]; int error = 0; - Plugin *plugin = KParts::ComponentFactory::createInstanceFromQuery<Plugin>( QString::fromLatin1( "Kopete/Plugin" ), - QString::fromLatin1( "[X-KDE-PluginInfo-Name]=='%1'" ).arg( pluginId ), this, 0, QStringList(), &error ); + Plugin *plugin = KParts::ComponentFactory::createInstanceFromQuery<Plugin>( TQString::fromLatin1( "Kopete/Plugin" ), + TQString::fromLatin1( "[X-KDE-PluginInfo-Name]=='%1'" ).arg( pluginId ), this, 0, TQStringList(), &error ); if ( plugin ) { d->loadedPlugins.insert( info, plugin ); info->setPluginEnabled( true ); - connect( plugin, SIGNAL( destroyed( QObject * ) ), this, SLOT( slotPluginDestroyed( QObject * ) ) ); - connect( plugin, SIGNAL( readyForUnload() ), this, SLOT( slotPluginReadyForUnload() ) ); + connect( plugin, TQT_SIGNAL( destroyed( TQObject * ) ), this, TQT_SLOT( slotPluginDestroyed( TQObject * ) ) ); + connect( plugin, TQT_SIGNAL( readyForUnload() ), this, TQT_SLOT( slotPluginReadyForUnload() ) ); kdDebug( 14010 ) << k_funcinfo << "Successfully loaded plugin '" << pluginId << "'" << endl; @@ -424,7 +424,7 @@ Plugin *PluginManager::loadPluginInternal( const QString &pluginId ) return plugin; } -bool PluginManager::unloadPlugin( const QString &spec ) +bool PluginManager::unloadPlugin( const TQString &spec ) { //kdDebug(14010) << k_funcinfo << spec << endl; if( Plugin *thePlugin = plugin( spec ) ) @@ -438,7 +438,7 @@ bool PluginManager::unloadPlugin( const QString &spec ) -void PluginManager::slotPluginDestroyed( QObject *plugin ) +void PluginManager::slotPluginDestroyed( TQObject *plugin ) { for ( Private::InfoToPluginMap::Iterator it = d->loadedPlugins.begin(); it != d->loadedPlugins.end(); ++it ) @@ -454,14 +454,14 @@ void PluginManager::slotPluginDestroyed( QObject *plugin ) { // Use a timer to make sure any pending deleteLater() calls have // been handled first - QTimer::singleShot( 0, this, SLOT( slotShutdownDone() ) ); + TQTimer::singleShot( 0, this, TQT_SLOT( slotShutdownDone() ) ); } } -Plugin* PluginManager::plugin( const QString &_pluginId ) const +Plugin* PluginManager::plugin( const TQString &_pluginId ) const { // Hack for compatibility with Plugin::pluginId(), which returns // classname() instead of the internal name. Changing that is not easy @@ -470,9 +470,9 @@ Plugin* PluginManager::plugin( const QString &_pluginId ) const // For now, just transform FooProtocol to kopete_foo. // FIXME: In the future we'll need to change this nevertheless to unify // the handling - Martijn - QString pluginId = _pluginId; - if ( pluginId.endsWith( QString::fromLatin1( "Protocol" ) ) ) - pluginId = QString::fromLatin1( "kopete_" ) + _pluginId.lower().remove( QString::fromLatin1( "protocol" ) ); + TQString pluginId = _pluginId; + if ( pluginId.endsWith( TQString::fromLatin1( "Protocol" ) ) ) + pluginId = TQString::fromLatin1( "kopete_" ) + _pluginId.lower().remove( TQString::fromLatin1( "protocol" ) ); // End hack KPluginInfo *info = infoForPluginId( pluginId ); @@ -485,9 +485,9 @@ Plugin* PluginManager::plugin( const QString &_pluginId ) const return 0L; } -KPluginInfo * PluginManager::infoForPluginId( const QString &pluginId ) const +KPluginInfo * PluginManager::infoForPluginId( const TQString &pluginId ) const { - QValueList<KPluginInfo *>::ConstIterator it; + TQValueList<KPluginInfo *>::ConstIterator it; for ( it = d->plugins.begin(); it != d->plugins.end(); ++it ) { if ( ( *it )->pluginName() == pluginId ) @@ -498,21 +498,21 @@ KPluginInfo * PluginManager::infoForPluginId( const QString &pluginId ) const } -bool PluginManager::setPluginEnabled( const QString &_pluginId, bool enabled /* = true */ ) +bool PluginManager::setPluginEnabled( const TQString &_pluginId, bool enabled /* = true */ ) { - QString pluginId = _pluginId; + TQString pluginId = _pluginId; KConfig *config = KGlobal::config(); config->setGroup( "Plugins" ); // FIXME: What is this for? This sort of thing is kconf_update's job - Richard - if ( !pluginId.startsWith( QString::fromLatin1( "kopete_" ) ) ) - pluginId.prepend( QString::fromLatin1( "kopete_" ) ); + if ( !pluginId.startsWith( TQString::fromLatin1( "kopete_" ) ) ) + pluginId.prepend( TQString::fromLatin1( "kopete_" ) ); if ( !infoForPluginId( pluginId ) ) return false; - config->writeEntry( pluginId + QString::fromLatin1( "Enabled" ), enabled ); + config->writeEntry( pluginId + TQString::fromLatin1( "Enabled" ), enabled ); config->sync(); return true; |