Plugin *PluginManager::loadPluginInternal( const QString &pluginId ) { //kDebug( 14010 ) << pluginId; KPluginInfo info = infoForPluginId( pluginId ); if ( !info.isValid() ) { kWarning( 14010 ) << "Unable to find a plugin named '" << pluginId << "'!"; return 0L; } if ( _kpmp->loadedPlugins.contains( info ) ) return _kpmp->loadedPlugins[ info ]; QString error; Plugin *plugin = KServiceTypeTrader::createInstanceFromQuery<Plugin>( QString::fromLatin1( "Kopete/Plugin" ), QString::fromLatin1( "[X-KDE-PluginInfo-Name]=='%1'" ).arg( pluginId ), this, QVariantList(), &error ); if ( plugin ) { _kpmp->loadedPlugins.insert( info, plugin ); info.setPluginEnabled( true ); connect( plugin, SIGNAL(destroyed(QObject*)), this, SLOT(slotPluginDestroyed(QObject*)) ); connect( plugin, SIGNAL(readyForUnload()), this, SLOT(slotPluginReadyForUnload()) ); kDebug( 14010 ) << "Successfully loaded plugin '" << pluginId << "'"; emit pluginLoaded( plugin ); Protocol* protocol = dynamic_cast<Protocol*>( plugin ); if ( protocol ) emit protocolLoaded( protocol ); } else {
void AccountShared::useProtocolFactory(ProtocolFactory *factory) { Protocol *oldProtocolHandler = ProtocolHandler; if (ProtocolHandler) { disconnect(ProtocolHandler, SIGNAL(statusChanged(Account, Status)), this, SIGNAL(statusChanged())); disconnect(ProtocolHandler, SIGNAL(contactStatusChanged(Contact, Status)), this, SIGNAL(buddyStatusChanged(Contact, Status))); disconnect(ProtocolHandler, SIGNAL(connected(Account)), this, SIGNAL(connected())); disconnect(ProtocolHandler, SIGNAL(disconnected(Account)), this, SIGNAL(disconnected())); storeStatus(StatusChangerManager::instance()->manuallySetStatus(this)); setDisconnectStatus(); } if (!factory) { setDetails(0); ProtocolHandler = 0; emit protocolUnloaded(); } else { ProtocolHandler = factory->createProtocolHandler(this); setDetails(factory->createAccountDetails(this)); emit protocolLoaded(); } if (oldProtocolHandler) delete oldProtocolHandler; if (ProtocolHandler) { connect(ProtocolHandler, SIGNAL(statusChanged(Account, Status)), this, SIGNAL(statusChanged())); connect(ProtocolHandler, SIGNAL(contactStatusChanged(Contact, Status)), this, SIGNAL(buddyStatusChanged(Contact, Status))); connect(ProtocolHandler, SIGNAL(connected(Account)), this, SIGNAL(connected())); connect(ProtocolHandler, SIGNAL(disconnected(Account)), this, SIGNAL(disconnected())); } }