Ejemplo n.º 1
0
int main(int argc,char **argv)
{
  KAboutData aboutData("korgplugins", 0,ki18n("KOrgPlugins"),"0.1");
  KCmdLineArgs::init(argc,argv,&aboutData);

  KApplication app;

  KService::List plugins = KOCore::self()->availablePlugins();
  KService::List::ConstIterator it;
  for(it = plugins.constBegin(); it != plugins.constEnd(); ++it) {
    kDebug() << "Plugin:" << (*it)->desktopEntryName() << "("
             << (*it)->name() << ")";
    KOrg::Plugin *p = KOCore::self()->loadPlugin(*it);
    if (!p) {
      kDebug() << "Plugin loading failed.";
    } else {
      kDebug() << "PLUGIN INFO:" << p->info();
    }
  }

#ifndef KORG_NOPRINTER
  plugins = KOCore::self()->availablePrintPlugins();
  for(it = plugins.constBegin(); it != plugins.constEnd(); ++it) {
    kDebug() << "Print plugin:" << (*it)->desktopEntryName() << "("
             << (*it)->name() << ")";
    KOrg::PrintPlugin *p = KOCore::self()->loadPrintPlugin(*it);
    if (!p) {
      kDebug() << "Print plugin loading failed.";
    } else {
      kDebug() << "PRINT PLUGIN INFO:" << p->info();
    }
  }
#endif

  plugins = KOCore::self()->availableParts();
  for(it = plugins.constBegin(); it != plugins.constEnd(); ++it) {
    kDebug() << "Part:" << (*it)->desktopEntryName() << "("
             << (*it)->name() << ")";
    KOrg::Part *p = KOCore::self()->loadPart(*it,0);
    if (!p) {
      kDebug() << "Part loading failed.";
    } else {
      kDebug() << "PART INFO:" << p->info();
    }
  }

  plugins = KOCore::self()->availableCalendarDecorations();
  for(it = plugins.constBegin(); it != plugins.constEnd(); ++it) {
    kDebug() << "CalendarDecoration:" << (*it)->desktopEntryName() << "("
             << (*it)->name() << ")";
    KOrg::CalendarDecoration::Decoration *p = KOCore::self()->loadCalendarDecoration(*it);
    if (!p) {
      kDebug() << "Calendar decoration loading failed.";
    } else {
      kDebug() << "CALENDAR DECORATION INFO:" << p->info();
    }
  }

}
Ejemplo n.º 2
0
void PluginManager::loadPlugins()
{
    KService::List offers = KServiceTypeTrader::self()->query(QLatin1String("KTpAccountsKCM/AccountUiPlugin"));

    KService::List::const_iterator iter;
    for (iter = offers.constBegin(); iter < offers.constEnd(); ++iter) {
       QString error;
       KService::Ptr service = *iter;

        KPluginFactory *factory = KPluginLoader(service->library()).factory();

        if (!factory) {
            qWarning() << "KPluginFactory could not load the plugin:" << service->library();
            continue;
        }

       AbstractAccountUiPlugin *plugin = factory->create<AbstractAccountUiPlugin>(this);

       if (plugin) {
           qDebug() << "Loaded plugin:" << service->name();
           m_plugins.append(plugin);
       } else {
           qDebug() << error;
       }
    }
}
KParts::Factory* IPartController::findPartFactory ( const QString& mimetype, const QString& parttype, const QString& preferredName )
{
    // parttype may be a interface type not derived from KParts/ReadOnlyPart
    const KService::List offers = KMimeTypeTrader::self()->query( mimetype,
                                        QString::fromLatin1( "KParts/ReadOnlyPart" ),
                                        QString::fromLatin1( "'%1' in ServiceTypes" ).arg( parttype ) );
    if ( ! offers.isEmpty() )
    {
        KService::Ptr ptr;
        // if there is a preferred plugin we'll take it
        if ( !preferredName.isEmpty() )
        {
            KService::List::ConstIterator it;
            for ( it = offers.constBegin(); it != offers.constEnd(); ++it )
            {
                if ( ( *it ) ->desktopEntryName() == preferredName )
                {
                    ptr = ( *it );
                    break;
                }
            }
        }
        // else we just take the first in the list
        if ( !ptr )
        {
            ptr = offers.first();
        }
        KPluginLoader loader( QFile::encodeName( ptr->library() ) );
        return static_cast<KParts::Factory*>( loader.factory() );
    }
                                                                                                  
    return 0;
}
Ejemplo n.º 4
0
PluginLoader::PluginLoader()
{
    KService::List offers = KServiceTypeTrader::self()->query("KdeConnect/Plugin");
    for(KService::List::const_iterator iter = offers.constBegin(); iter != offers.constEnd(); ++iter) {
        KService::Ptr service = *iter;
        plugins[service->library()] = service;
    }
}
Ejemplo n.º 5
0
ToggleViewGUIClient::ToggleViewGUIClient( KonqMainWindow *mainWindow )
: QObject( mainWindow )
{
  m_mainWindow = mainWindow;

  KService::List offers = KServiceTypeTrader::self()->query( "Browser/View" );
  KService::List::Iterator it = offers.begin();
  while ( it != offers.end() )
  {
    QVariant prop = (*it)->property( "X-KDE-BrowserView-Toggable" );
    QVariant orientation = (*it)->property( "X-KDE-BrowserView-ToggableView-Orientation" );

    if ( !prop.isValid() || !prop.toBool() ||
         !orientation.isValid() || orientation.toString().isEmpty() )
    {
      offers.erase( it );
      it = offers.begin();
    }
    else
      ++it;
  }

  m_empty = ( offers.count() == 0 );

  if ( m_empty )
    return;

  KService::List::ConstIterator cIt = offers.constBegin();
  KService::List::ConstIterator cEnd = offers.constEnd();
  for (; cIt != cEnd; ++cIt )
  {
    QString description = i18n( "Show %1" ,  (*cIt)->name() );
    QString name = (*cIt)->desktopEntryName();
    //kDebug() << "ToggleViewGUIClient: name=" << name;
    KToggleAction *action = new KToggleAction( description, this );
    mainWindow->actionCollection()->addAction( name.toLatin1(), action );

    // HACK
    if ( (*cIt)->icon() != "unknown" )
      action->setIcon( KIcon((*cIt)->icon()) );

    connect( action, SIGNAL(toggled(bool)),
             this, SLOT(slotToggleView(bool)) );

    m_actions.insert( name, action );

    QVariant orientation = (*cIt)->property( "X-KDE-BrowserView-ToggableView-Orientation" );
    bool horizontal = orientation.toString().toLower() == "horizontal";
    m_mapOrientation.insert( name, horizontal );
  }

  connect( m_mainWindow, SIGNAL(viewAdded(KonqView*)),
           this, SLOT(slotViewAdded(KonqView*)) );
  connect( m_mainWindow, SIGNAL(viewRemoved(KonqView*)),
           this, SLOT(slotViewRemoved(KonqView*)) );
}
Ejemplo n.º 6
0
void Navigator::insertKCMDocs( const QString &name, NavigatorItem *topItem, const QString &type )
{
  kDebug(1400) << "Requested KCM documents for ID" << name;
  QString systemsettingskontrolconstraint = "[X-KDE-System-Settings-Parent-Category] != ''";
  QString konquerorcontrolconstraint = "[X-KDE-PluginKeyword] == 'khtml_general'\
                                     or [X-KDE-PluginKeyword] == 'performance'\
                                     or [X-KDE-PluginKeyword] == 'bookmarks'";
  QString filemanagercontrolconstraint = "[X-KDE-PluginKeyword] == 'behavior'\
                                       or [X-KDE-PluginKeyword] == 'dolphinviewmodes'\
                                       or [X-KDE-PluginKeyword] == 'dolphinnavigation'\
                                       or [X-KDE-PluginKeyword] == 'dolphinservices'\
                                       or [X-KDE-PluginKeyword] == 'dolphingeneral'\
                                       or [X-KDE-PluginKeyword] == 'trash'";
  QString browsercontrolconstraint = "[X-KDE-PluginKeyword] == 'khtml_behavior'\
                                   or [X-KDE-PluginKeyword] == 'proxy'\
                                   or [X-KDE-PluginKeyword] == 'khtml_appearance'\
                                   or [X-KDE-PluginKeyword] == 'khtml_filter'\
                                   or [X-KDE-PluginKeyword] == 'cache'\
                                   or [X-KDE-PluginKeyword] == 'cookie'\
                                   or [X-KDE-PluginKeyword] == 'useragent'\
                                   or [X-KDE-PluginKeyword] == 'khtml_java_js'\
                                   or [X-KDE-PluginKeyword] == 'khtml_plugins'";
/* missing in browsercontrolconstraint
History                 no X-KDE-PluginKeyword in kcmhistory.desktop
*/
  QString othercontrolconstraint = "[X-KDE-PluginKeyword] == 'cgi'";

  KService::List list;

  if ( type == QString("kcontrol") ) {
    list = KServiceTypeTrader::self()->query( "KCModule", systemsettingskontrolconstraint );
  } else if ( type == QString("konquerorcontrol") ) {
    list = KServiceTypeTrader::self()->query( "KCModule", konquerorcontrolconstraint );
  } else if ( type == QString("browsercontrol") ) {
    list = KServiceTypeTrader::self()->query( "KCModule", browsercontrolconstraint );
  } else if ( type == QString("filemanagercontrol") ) {
    list = KServiceTypeTrader::self()->query( "KCModule", filemanagercontrolconstraint );
  } else if ( type == QString("othercontrol") ) {
    list = KServiceTypeTrader::self()->query( "KCModule", othercontrolconstraint );
  } else if ( type == QString("kinfocenter") ) {
    list = KServiceTypeTrader::self()->query( "KCModule", "[X-KDE-ParentApp] == 'kinfocenter'" );
  }

  for ( KService::List::const_iterator it = list.constBegin(); it != list.constEnd(); ++it )
  {
    KService::Ptr s = (*it);
    KCModuleInfo m = KCModuleInfo(s);
    QString desktopFile = KStandardDirs::locate( "services", m.fileName() );
    createItemFromDesktopFile( topItem, desktopFile );
    }
    topItem->sortChildren( 0, Qt::AscendingOrder /* ascending */ );
}
Ejemplo n.º 7
0
int main( int argc, char **argv )
{
    QCoreApplication app(argc, argv);

    KLocalizedString::setApplicationDomain("ktraderclient");
    KAboutData aboutData(QLatin1String("ktraderclient"), i18n("KTraderClient"), QLatin1String(PROJECT_VERSION));
    aboutData.addAuthor(i18n("David Faure"), QString(), "*****@*****.**");

    aboutData.setShortDescription(i18n("A command-line tool for querying the KDE trader system"));
    QCommandLineParser parser;
    KAboutData::setApplicationData(aboutData);
    parser.addVersionOption();
    parser.addHelpOption();
    aboutData.setupCommandLine(&parser);

    parser.addOption(QCommandLineOption(QStringList() << QLatin1String("mimetype"), i18n("A mimetype"), QLatin1String("mimetype")));
    parser.addOption(QCommandLineOption(QStringList() << QLatin1String("servicetype"), i18n("A servicetype, like KParts/ReadOnlyPart or KMyApp/Plugin"), QLatin1String("servicetype")));
    parser.addOption(QCommandLineOption(QStringList() << QLatin1String("constraint"), i18n("A constraint expressed in the trader query language"), QLatin1String("constraint")));

    parser.addOption(QCommandLineOption(QStringList() << QLatin1String("short"), i18n("Output only paths to desktop files")));

    parser.process(app);
    aboutData.processCommandLine(&parser);

    const QString mimetype = parser.value("mimetype");
    QString servicetype = parser.value("servicetype");
    const QString constraint = parser.value("constraint");
    const bool outputProperties = !parser.isSet("short");

    if ( mimetype.isEmpty() && servicetype.isEmpty() )
        parser.showHelp();

    if ( !mimetype.isEmpty() )
        printf( "mimetype is : %s\n", qPrintable( mimetype ) );
    if ( !servicetype.isEmpty() )
        printf( "servicetype is : %s\n", qPrintable( servicetype ) );
    if ( !constraint.isEmpty() )
        printf( "constraint is : %s\n", qPrintable( constraint ) );

    KService::List offers;
    if ( !mimetype.isEmpty() ) {
        if ( servicetype.isEmpty() )
            servicetype = "Application";
        offers = KMimeTypeTrader::self()->query( mimetype, servicetype, constraint );
    }
    else
        offers = KServiceTypeTrader::self()->query( servicetype, constraint );

    printf("got %d offers.\n", offers.count());

    int i = 0;
    KService::List::ConstIterator it = offers.constBegin();
    const KService::List::ConstIterator end = offers.constEnd();
    for (; it != end; ++it, ++i )
    {
        if (outputProperties) {
            printf("---- Offer %d ----\n", i);
            QStringList props = (*it)->propertyNames();
            QStringList::ConstIterator propIt = props.constBegin();
            QStringList::ConstIterator propEnd = props.constEnd();
            for (; propIt != propEnd; ++propIt )
            {
                QVariant prop = (*it)->property( *propIt );

                if ( !prop.isValid() )
                {
                    printf("Invalid property %s\n", (*propIt).toLocal8Bit().data());
                    continue;
                }

                QString outp = *propIt;
                outp += " : '";

                switch ( prop.type() )
                {
                    case QVariant::StringList:
                        outp += prop.toStringList().join(" - ");
                        break;
                    case QVariant::Bool:
                        outp += prop.toBool() ? "TRUE" : "FALSE";
                        break;
                    default:
                        outp += prop.toString();
                        break;
                }

                if ( !outp.isEmpty() )
                    printf("%s'\n", outp.toLocal8Bit().constData());
            }
        } else {
            printf("%s\n", (*it)->entryPath().toLocal8Bit().constData());
        }
    }
    return 0;
}
Ejemplo n.º 8
0
bool MigrateManagerInternal::lookupDrivers()
{
    if (!lookupDriversNeeded)
        return true;

    if (qApp) {
        connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(slotAppQuits()));
    }
//! @todo for Qt-only version check for KComponentData wrapper
//  KexiDBWarn << "cannot work without KComponentData (KGlobal::mainComponent()==0)!";
//  setError("Driver Manager cannot work without KComponentData (KGlobal::mainComponent()==0)!");

    lookupDriversNeeded = false;
    clearError();
    KService::List tlist = KServiceTypeTrader::self()->query("Kexi/MigrationDriver");
    KService::List::ConstIterator it(tlist.constBegin());
    for (; it != tlist.constEnd(); ++it) {
        KService::Ptr ptr = (*it);
        QString srv_name = ptr->property("X-Kexi-MigrationDriverName").toString();
        if (srv_name.isEmpty()) {
            KexiDBWarn << "X-Kexi-MigrationDriverName must be set for migration driver"
            << ptr->property("Name").toString() << "service!\n -- skipped!";
            continue;
        }
        if (m_services_lcase.contains(srv_name.toLower())) {
            continue;
        }

//! @todo could be merged. Copied from KexiDB::DriverManager.
//<COPIED>
        QString srv_ver_str = ptr->property("X-Kexi-KexiMigrationVersion").toString();
        QStringList lst(srv_ver_str.split('.'));
        int minor_ver, major_ver;
        bool ok = (lst.count() == 2);
        if (ok)
            major_ver = lst[0].toUInt(&ok);
        if (ok)
            minor_ver = lst[1].toUInt(&ok);
#if 0 //temp. disable
        if (!ok) {
            KexiDBWarn << "problem with detecting" << srv_name.toLower() << "driver's version -- skipping it!";
            possibleProblems += QString("\"%1\" migration driver has unrecognized version; "
                                        "required driver version is \"%2.%3\"")
                                .arg(srv_name.toLower())
                                .arg(KexiMigration::version().major).arg(KexiMigration::version().minor);
            continue;
        }
        if (!KexiMigration::version().matches(major_ver, minor_ver)) {
            KexiDBWarn << QString("'%1' driver"
                                  " has version '%2' but required migration driver version is '%3.%4'\n"
                                  " -- skipping this driver!").arg(srv_name.toLower()).arg(srv_ver_str)
            .arg(KexiMigration::version().major).arg(KexiMigration::version().minor);
            possibleProblems += QString("\"%1\" migration driver has version \"%2\" "
                                        "but required driver version is \"%3.%4\"")
                                .arg(srv_name.toLower()).arg(srv_ver_str)
                                .arg(KexiMigration::version().major).arg(KexiMigration::version().minor);
            continue;
        }
#endif
//</COPIED>

        QString mime = ptr->property("X-Kexi-FileDBDriverMime").toString().toLower();
        QString drvType = ptr->property("X-Kexi-MigrationDriverType").toString().toLower();
        if (drvType == "file") {
            if (!mime.isEmpty()) {
                if (!m_services_by_mimetype.contains(mime)) {
                    m_services_by_mimetype.insert(mime, ptr);
                } else {
                    KexiDBWarn << "more than one driver for" << mime << "mime type!";
                }
            }
        }
        m_services.insert(srv_name, ptr);
        m_services_lcase.insert(srv_name.toLower(), ptr);
        KexiDBDbg << "registered driver:" << ptr->name() << '(' << ptr->library() << ")";
    }

    if (tlist.isEmpty()) {
        setError(ERR_DRIVERMANAGER, i18n("Could not find any import/export database drivers."));
        return false;
    }
    return true;
}
Ejemplo n.º 9
0
int main( int argc, char **argv )
{
  KCmdLineArgs::init( argc, argv, "ktraderclient", 0, ki18n("KTraderClient"), "0.0" , ki18n("A command-line tool for querying the KDE trader system"));


  KCmdLineOptions options;

  options.add("mimetype <mimetype>", ki18n("A mimetype"));

  options.add("servicetype <servicetype>", ki18n("A servicetype, like KParts/ReadOnlyPart or KMyApp/Plugin"));

  options.add("constraint <constraint>", ki18n("A constraint expressed in the trader query language"));

  KCmdLineArgs::addCmdLineOptions( options );

  KApplication app( false ); // no GUI

  KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

  const QString mimetype = args->getOption( "mimetype" );
  QString servicetype = args->getOption( "servicetype" );
  const QString constraint = args->getOption( "constraint" );

  if ( mimetype.isEmpty() && servicetype.isEmpty() )
      KCmdLineArgs::usage();

  if ( !mimetype.isEmpty() )
      printf( "mimetype is : %s\n", qPrintable( mimetype ) );
  if ( !servicetype.isEmpty() )
      printf( "servicetype is : %s\n", qPrintable( servicetype ) );
  if ( !constraint.isEmpty() )
      printf( "constraint is : %s\n", qPrintable( constraint ) );

  KService::List offers;
  if ( !mimetype.isEmpty() ) {
      if ( servicetype.isEmpty() )
          servicetype = "Application";
     offers = KMimeTypeTrader::self()->query( mimetype, servicetype, constraint );
  }
  else
     offers = KServiceTypeTrader::self()->query( servicetype, constraint );

  printf("got %d offers.\n", offers.count());

  int i = 0;
  KService::List::ConstIterator it = offers.constBegin();
  const KService::List::ConstIterator end = offers.constEnd();
  for (; it != end; ++it, ++i )
  {
    printf("---- Offer %d ----\n", i);
    QStringList props = (*it)->propertyNames();
    QStringList::ConstIterator propIt = props.constBegin();
    QStringList::ConstIterator propEnd = props.constEnd();
    for (; propIt != propEnd; ++propIt )
    {
      QVariant prop = (*it)->property( *propIt );

      if ( !prop.isValid() )
      {
        printf("Invalid property %s\n", (*propIt).toLocal8Bit().data());
	continue;
      }

      QString outp = *propIt;
      outp += " : '";

      switch ( prop.type() )
      {
        case QVariant::StringList:
          outp += prop.toStringList().join(" - ");
        break;
        case QVariant::Bool:
          outp += prop.toBool() ? "TRUE" : "FALSE";
          break;
        default:
          outp += prop.toString();
        break;
      }

      if ( !outp.isEmpty() )
        printf("%s'\n", outp.toLocal8Bit().data());
    }
  }
  return 0;
}