Example #1
0
void cPluginManager::findPlugins ()
{
  pluginInfo.clear ();
  KPluginInfo::List pi = KPluginInfo::fromServices (KServiceTypeTrader::self()->query (
      QString::fromLatin1("KMuddy/Plugin"),
      QString::fromLatin1("(Type == 'Service') and ([X-KMuddy-Version] == 2)")));
  
  // fill in the associative array with plugin info
  KPluginInfo::List::Iterator it;
  for (it = pi.begin(); it != pi.end(); ++it) {
    KPluginInfo info = *it;
    kDebug() << "Found plugin: " << info.name();
    pluginInfo[info.name()] = info;
  }
}
void KCMKontactSummary::load()
{
  KService::List offers = KServiceTypeTrader::self()->query(
      QString::fromLatin1( "Kontact/Plugin" ),
      QString( "[X-KDE-KontactPluginVersion] == %1" ).arg( KONTACT_PLUGIN_VERSION ) );

  QStringList activeSummaries;

  KConfig config( "kontact_summaryrc" );
  KConfigGroup grp( &config, QString() );
  if ( !grp.hasKey( "ActiveSummaries" ) ) {
    activeSummaries << "kontact_kaddressbookplugin";
    activeSummaries << "kontact_specialdatesplugin";
    activeSummaries << "kontact_korganizerplugin";
    activeSummaries << "kontact_todoplugin";
    activeSummaries << "kontact_knotesplugin";
    activeSummaries << "kontact_kmailplugin";
    activeSummaries << "kontact_weatherplugin";
    activeSummaries << "kontact_newstickerplugin";
    activeSummaries << "kontact_plannerplugin";
  } else {
    activeSummaries = grp.readEntry( "ActiveSummaries", QStringList() );
  }

  mPluginView->clear();

  KPluginInfo::List pluginList =
    KPluginInfo::fromServices( offers, KConfigGroup( &config, "Plugins" ) );
  KPluginInfo::List::Iterator it;
  for ( it = pluginList.begin(); it != pluginList.end(); ++it ) {
    it->load();

    if ( !it->isPluginEnabled() ) {
      continue;
    }

    QVariant var = it->property( "X-KDE-KontactPluginHasSummary" );
    if ( var.isValid() && var.toBool() == true ) {
      PluginItem *item = new PluginItem( *it, mPluginView );

      if ( activeSummaries.contains( it->pluginName() ) ) {
        item->setCheckState( 0, Qt::Checked );
      } else {
        item->setCheckState( 0, Qt::Unchecked );
      }
    }
  }
}