コード例 #1
0
/**
 * Loads an ion plugin given a plugin name found via KService.
 */
Plasma::DataEngine *WeatherEngine::loadIon(const QString& plugName)
{
    KPluginInfo foundPlugin;

    foreach(const KPluginInfo &info, Plasma::DataEngineManager::listEngineInfo("weatherengine")) {
        if (info.pluginName() == plugName) {
            foundPlugin = info;
            break;
        }
    }

    if (!foundPlugin.isValid()) {
        return NULL;
    }

    // Load the Ion plugin, store it into a QMap to handle multiple ions.
    Plasma::DataEngine *ion = Plasma::DataEngineManager::self()->loadEngine(foundPlugin.pluginName());
    ion->setObjectName(plugName);
    connect(ion, SIGNAL(sourceAdded(QString)), this, SLOT(newIonSource(QString)));
    connect(ion, SIGNAL(forceUpdate(IonInterface*,QString)), this, SLOT(forceUpdate(IonInterface*,QString)));

    m_ions << plugName;

    return ion;
}
コード例 #2
0
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
	{
コード例 #3
0
RecordItNowPlugin *RecordItNowPluginManager::loadPlugin(const QString &name)
{

    QHashIterator<KPluginInfo, RecordItNowPlugin*> it(m_plugins);
    KPluginInfo info;
    while (it.hasNext()) {
        it.next();
        if (it.key().name().toLower() == name.toLower()) {
            if (it.value()) { // already loaded?
                return it.value();
            } else { // get info and load
                info = it.key();
                break;
            }
        }
    }
    if (!info.isValid()) {
        return 0;
    }

    kDebug() << "load plugin:" << name;

    KService::Ptr service = info.service();
    KPluginLoader loader(service->library());
    KPluginFactory *factory = loader.factory();

    if (!factory) {
        kWarning() << "KPluginFactory could not load the plugin:" << service->library() <<
        "Reason:" << loader.errorString();
        return 0;
    }

    RecordItNowPlugin *plugin = factory->create<RecordItNowPlugin>(this);
    delete factory;
    if (!plugin) {
        kWarning() << "factory::create<>() failed " << service->library();
        return 0;
    }

    return (m_plugins[info] = plugin);

}
コード例 #4
0
void IMEditorWidget::loadContact( KABC::Addressee *addr )
{
  mWidget->lvAddresses->clear();

  // see README for details of how Evolution stores IM addresses (differently)
  const QStringList customs = addr->customs();

  QStringList::ConstIterator it;
  bool isSet = false;
  for ( it = customs.constBegin(); it != customs.constEnd(); ++it ) {
    QString app, name, value;
    splitField( *it, app, name, value );

    if ( app.startsWith( QString::fromLatin1( "messaging/" ) ) ) {
      if ( name == QString::fromLatin1( "All" ) ) {
        const KPluginInfo protocol = protocolFromString( app );
        if ( protocol.isValid() ) {
          const QStringList addresses = value.split( QChar( 0xE000 ), QString::SkipEmptyParts );
          QStringList::ConstIterator end = addresses.constEnd();
          for ( QStringList::ConstIterator it = addresses.constBegin(); it != end; ++it ) {
            IMAddressLVI *imaddresslvi =
              new IMAddressLVI( mWidget->lvAddresses, protocol, *it, Any/*, false*/ );
            if ( !isSet && (*it).trimmed().toLower() == mPreferred.trimmed().toLower() ) {
              imaddresslvi->setPreferred( true );
              isSet = true;  //Only set one item to be preferred
            }
          }
        } else {
          kDebug( 5720 ) <<" no protocol found for:" << app;
        }
      }
    }
  }

  if ( mWidget->lvAddresses->topLevelItem( 0 ) ) {
    mWidget->lvAddresses->topLevelItem( 0 )->setSelected( true );
  }
}