Exemplo n.º 1
0
static KstDataSourcePtr findPluginFor(const QString& filename, const QString& type) {
    KstDataSourcePtr plugin;

    scanPlugins();

    if (!type.isEmpty()) {
        for (KST::PluginInfoList::ConstIterator it = pluginInfo.begin(); it != pluginInfo.end(); ++it) {
            if ((*it)->provides(type)) {
                plugin = (*it)->create(filename, type);
                break;
            }
        }

        return plugin;
    }

    for (KST::PluginInfoList::ConstIterator it = pluginInfo.begin(); it != pluginInfo.end(); ++it) {
        if ((*it)->understands(filename)) {
            plugin = (*it)->create(filename);
            if (plugin) {
                break;
            }
        }
    }

    return plugin;
}
Exemplo n.º 2
0
QStringList KstDataSource::pluginList() {
  QStringList rc;

  if (pluginInfo.isEmpty()) {
    scanPlugins();
  }

  for (KST::PluginInfoList::ConstIterator it = pluginInfo.begin(); it != pluginInfo.end(); ++it) {
    rc += (*it)->service->property("Name").toString();
  }

  return rc;
}
Exemplo n.º 3
0
bool KstDataSource::pluginHasConfigWidget(const QString& plugin) {
  if (pluginInfo.isEmpty()) {
    scanPlugins();
  }

  KST::PluginInfoList info = Q3DeepCopy<KST::PluginInfoList>(pluginInfo);

  for (KST::PluginInfoList::ConstIterator it = info.begin(); it != info.end(); ++it) {
    if ((*it)->service->property("Name").toString() == plugin) {
      return (*it)->hasConfigWidget();
    }
  }

  return false;
}
Exemplo n.º 4
0
void KstDataSource::cleanupForExit() {
  pluginInfo.clear();
  qSettingsObject = 0L;
  for (QMap<QString,QString>::Iterator i = urlMap.begin(); i != urlMap.end(); ++i) {
    KIO::NetAccess::removeTempFile(*i);
  }
  urlMap.clear();
}
Exemplo n.º 5
0
KstDataSourceConfigWidget* KstDataSource::configWidgetForPlugin(const QString& plugin) {
  if (pluginInfo.isEmpty()) {
    scanPlugins();
  }

  KST::PluginInfoList info = Q3DeepCopy<KST::PluginInfoList>(pluginInfo);

  for (KST::PluginInfoList::ConstIterator it = info.begin(); it != info.end(); ++it) {
    if (KST::DataSourcePlugin *p = kst_cast<KST::DataSourcePlugin>(*it)) {
      if (p->service->property("Name").toString() == plugin) {
        return p->configWidget(qSettingsObject, QString::null);
      }
    }
  }

  return 0L;
}
Exemplo n.º 6
0
// Scans for plugins and stores the information for them in "pluginInfo"
static void scanPlugins() {
    KST::PluginInfoList tmpList;

    KstDebug::self()->log(i18n("Scanning for data-source plugins."));

    KService::List sl = KServiceType::offers("Kst Data Source");
    for (KService::List::ConstIterator it = sl.begin(); it != sl.end(); ++it) {
        for (KST::PluginInfoList::ConstIterator i2 = pluginInfo.begin(); i2 != pluginInfo.end(); ++i2) {
            if ((*i2)->service == *it) {
                tmpList.append(*i2);
                continue;
            }
        }

        KstSharedPtr<KST::Plugin> p = new KST::Plugin(*it);
        tmpList.append(p);
    }

    // This cleans up plugins that have been uninstalled and adds in new ones.
    // Since it is a shared pointer it can't dangle anywhere.
    pluginInfo = tmpList;
}
Exemplo n.º 7
0
static QList<PluginSortContainer> bestPluginsForSource(const QString& filename, const QString& type) {
  QList<PluginSortContainer> bestPlugins;

  if (pluginInfo.isEmpty()) {
    scanPlugins();
  }

  KST::PluginInfoList info = Q3DeepCopy<KST::PluginInfoList>(pluginInfo);

  if (!type.isEmpty()) {
    for (KST::PluginInfoList::iterator it = info.begin(); it != info.end(); ++it) {
      if (KST::DataSourcePlugin *p = dynamic_cast<KST::DataSourcePlugin*>((*it).data())) {
        if (p && p->provides(type)) {
          PluginSortContainer psc;
          psc.match = 100;
          psc.plugin = p;
          bestPlugins.append(psc);
          
          return bestPlugins;
        }
      }
    }
  }

  for (KST::PluginInfoList::ConstIterator it = info.begin(); it != info.end(); ++it) {
    PluginSortContainer psc;
    if (KST::DataSourcePlugin *p = kst_cast<KST::DataSourcePlugin>(*it)) {
      if ((psc.match = p->understands(qSettingsObject, filename)) > 0) {
        psc.plugin = p;
        bestPlugins.append(psc);
      }
    }
  }

  qSort(bestPlugins);

  return bestPlugins;
}