diff options
| author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-08-30 12:57:49 -0500 |
|---|---|---|
| committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-08-30 12:57:49 -0500 |
| commit | 1d86a2adb82a0c0c1b98e5196a3e6bbda0e46287 (patch) | |
| tree | 51bb543c0b9195690652ec15f95d9a8227891cc0 /knetworkmanager-0.9/src/knetworkmanager-pluginmanager.cpp | |
| parent | bf231a0d0362758f167da389222e271acb2ebd90 (diff) | |
| download | tdenetworkmanager-1d86a2adb82a0c0c1b98e5196a3e6bbda0e46287.tar.gz tdenetworkmanager-1d86a2adb82a0c0c1b98e5196a3e6bbda0e46287.zip | |
Move directory to new location
Diffstat (limited to 'knetworkmanager-0.9/src/knetworkmanager-pluginmanager.cpp')
| -rw-r--r-- | knetworkmanager-0.9/src/knetworkmanager-pluginmanager.cpp | 184 |
1 files changed, 0 insertions, 184 deletions
diff --git a/knetworkmanager-0.9/src/knetworkmanager-pluginmanager.cpp b/knetworkmanager-0.9/src/knetworkmanager-pluginmanager.cpp deleted file mode 100644 index 7654ccd..0000000 --- a/knetworkmanager-0.9/src/knetworkmanager-pluginmanager.cpp +++ /dev/null @@ -1,184 +0,0 @@ -/*************************************************************************** - * - * knetworkmanager-pluginmanager.cpp - A NetworkManager frontend for KDE - * - * Copyright (C) 2006 Novell, Inc. - * - * Author: Helmut Schaa <hschaa@suse.de>, <helmut.schaa@gmx.de> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - **************************************************************************/ - -#include <kplugininfo.h> -#include <kparts/componentfactory.h> -#include <kdebug.h> -#include <klocale.h> - -#include "knetworkmanager-pluginmanager.h" - -PluginManager* PluginManager::_instance; - -PluginManager* PluginManager::getInstance() -{ - if (_instance) - return _instance; - return new PluginManager(TQT_TQOBJECT(KNetworkManager::getInstance()), "pluginmanager"); -} - -PluginManager::PluginManager(TQObject* parent, const char* name) - : TQObject(parent, name) -{ - // get list of available plugins - this->_plugins = KPluginInfo::fromServices( KTrader::self()->query( TQString::fromLatin1( "KNetworkManager/Plugin" ))); - - // a bit debug output - for(TQValueList<KPluginInfo*>::ConstIterator it = _plugins.begin(); it != _plugins.end(); ++it) - kdDebug() << k_funcinfo << TQString("Found Plugin '%1'").arg((*it)->pluginName()) << endl; -} - -PluginManager::~PluginManager() -{ - // delete all loaded plugins - while(!_loadedPlugins.empty()) - { - PluginMap::Iterator it = _loadedPlugins.begin(); - _loadedPlugins.remove(it); - } - - // delete all available plugininfos - while(!_plugins.empty()) - { - TQValueList<KPluginInfo*>::Iterator it = _plugins.begin(); - delete *it; - _plugins.remove(it); - } -} - -TQStringList PluginManager::getPluginList(const TQString& serviceType, const TQString& property, const TQString& value) const -{ - TQStringList ret; - // find a suitable plugin - for(TQValueList<KPluginInfo*>::ConstIterator it = _plugins.begin(); it != _plugins.end(); ++it) - { - if ((*it)->service()->serviceTypes().contains(serviceType) > 0) - if ((*it)->property(property).toString().contains(value)) - ret.append( (*it)->pluginName() ); - } - return ret; -} - -Plugin* PluginManager::getPlugin(const TQString& pluginID) -{ - KPluginInfo* info = infoForPluginID(pluginID); - if (_loadedPlugins.contains(info)) - { - return _loadedPlugins[info]; - } - else - { - return loadPlugin(pluginID); - } - return NULL; -} - -const KPluginInfo* PluginManager::getPluginInfo(const TQString& pluginID) -{ - return infoForPluginID(pluginID); -} - -const KPluginInfo* PluginManager::getPluginInfo(const Plugin* plugin) -{ - for(PluginMap::ConstIterator it = _loadedPlugins.begin(); it != _loadedPlugins.end(); ++it) - { - if (it.data() == plugin) - return it.key(); - } - return NULL; -} - -void PluginManager::loadAllPlugins() -{ - // iterate over all plugins - for(TQValueList<KPluginInfo*>::ConstIterator it = _plugins.begin(); it != _plugins.end(); ++it) - { - // load Plugin - loadPlugin((*it)->pluginName()); - } -} - - -Plugin* PluginManager::loadPlugin(const TQString& pluginID) -{ - // try to load Plugin - int error = 0; - KPluginInfo* info = infoForPluginID(pluginID); - Plugin *plugin = KParts::ComponentFactory::createInstanceFromQuery<Plugin>( TQString::fromLatin1( "KNetworkManager/Plugin" ), - TQString::fromLatin1( "[X-KDE-PluginInfo-Name]=='%1'" ).arg( pluginID ), this, 0, TQStringList(), &error ); - - // plugin loaded? - if (plugin) - { - kdDebug() << k_funcinfo << TQString(i18n("successfully loaded plugin '%1'")).arg(info->pluginName()) << endl; - _loadedPlugins.insert(info, plugin); - } - else - { - // error - switch( error ) - { - case KParts::ComponentFactory::ErrNoServiceFound: - kdDebug( ) << k_funcinfo << "No service implementing the given mimetype " - << "and fullfilling the given constraint expression can be found." << endl; - break; - - case KParts::ComponentFactory::ErrServiceProvidesNoLibrary: - kdDebug( ) << "the specified service provides no shared library." << endl; - break; - - case KParts::ComponentFactory::ErrNoLibrary: - kdDebug( ) << "the specified library could not be loaded." << endl; - break; - - case KParts::ComponentFactory::ErrNoFactory: - kdDebug( ) << "the library does not export a factory for creating components." << endl; - break; - - case KParts::ComponentFactory::ErrNoComponent: - kdDebug( ) << "the factory does not support creating components of the specified type." << endl; - break; - } - - kdDebug() << k_funcinfo << "Loading plugin '" << pluginID << "' failed, KLibLoader reported error: '" << endl - << KLibLoader::self()->lastErrorMessage() << "'" << endl; - - } - - return plugin; -} - -KPluginInfo * PluginManager::infoForPluginID( const TQString& pluginID ) const -{ - TQValueList<KPluginInfo *>::ConstIterator it; - for ( it = this->_plugins.begin(); it != this->_plugins.end(); ++it ) - { - if ( ( *it )->pluginName() == pluginID ) - return *it; - } - - return 0L; -} - -#include "knetworkmanager-pluginmanager.moc" |
