コード例 #1
0
ファイル: pluginmanager.cpp プロジェクト: tmarques/waheela
void
PluginManager::showAbout( const QString &constraint )
{
    KTrader::OfferList offers = query( constraint );

    if ( offers.isEmpty() )
        return;

    KService::Ptr s = offers.front();

    const QString body = "<tr><td>%1</td><td>%2</td></tr>";

    QString str  = "<html><body><table width=\"100%\" border=\"1\">";

    str += body.arg( i18n( "Name" ),                s->name() );
    str += body.arg( i18n( "Library" ),             s->library() );
    str += body.arg( i18n( "Authors" ),             s->property( "X-KDE-amaroK-authors" ).toStringList().join( "\n" ) );
    str += body.arg( i18n( "Email" ),               s->property( "X-KDE-amaroK-email" ).toStringList().join( "\n" ) );
    str += body.arg( i18n( "Version" ),             s->property( "X-KDE-amaroK-version" ).toString() );
    str += body.arg( i18n( "Framework Version" ),   s->property( "X-KDE-amaroK-framework-version" ).toString() );

    str += "</table></body></html>";

    KMessageBox::information( 0, str, i18n( "Plugin Information" ) );
}
コード例 #2
0
ファイル: searchprovider.cpp プロジェクト: Fat-Zer/tdebase
SearchProvider::SearchProvider(const KService::Ptr service)
               : m_dirty(false)
{
    m_desktopEntryName = service->desktopEntryName();
    m_name = service->name();
    m_query = service->property("Query").toString();
    m_keys = service->property("Keys").toStringList();
    m_charset = service->property("Charset").toString();
}
コード例 #3
0
ファイル: searchprovider.cpp プロジェクト: KDE/kio
SearchProvider::SearchProvider(const KService::Ptr service)
               : m_dirty(false)
{
    setDesktopEntryName(service->desktopEntryName());
    setName(service->name());
    setKeys(service->property(QStringLiteral("Keys")).toStringList());

    m_query = service->property(QStringLiteral("Query")).toString();
    m_charset = service->property(QStringLiteral("Charset")).toString();
}
コード例 #4
0
ファイル: kplugininfo.cpp プロジェクト: crayonink/calligra-2
KPluginInfo::KPluginInfo( const KService::Ptr service )
: d( new KPluginInfoPrivate )
{
    if (!service) {
        d = 0; // isValid() == false
        return;
    }
    d->service = service;
    d->entryPath = service->entryPath();

    if ( service->isDeleted() )
    {
        d->hidden = true;
        return;
    }

    d->name = service->name();
    d->comment = service->comment();
    d->icon = service->icon();
    d->author = service->property( QLatin1String("X-KDE-PluginInfo-Author") ).toString();
    d->email = service->property( QLatin1String("X-KDE-PluginInfo-Email") ).toString();
    d->pluginName = service->property( QLatin1String("X-KDE-PluginInfo-Name") ).toString();
    d->version = service->property( QLatin1String("X-KDE-PluginInfo-Version") ).toString();
    d->website = service->property( QLatin1String("X-KDE-PluginInfo-Website") ).toString();
    d->category = service->property( QLatin1String("X-KDE-PluginInfo-Category") ).toString();
    d->license = service->property( QLatin1String("X-KDE-PluginInfo-License") ).toString();
    d->dependencies =
        service->property( QLatin1String("X-KDE-PluginInfo-Depends") ).toStringList();
    QVariant tmp = service->property( QLatin1String("X-KDE-PluginInfo-EnabledByDefault") );
    d->enabledbydefault = tmp.isValid() ? tmp.toBool() : false;
}
コード例 #5
0
void KatapultSettings::loadDisplayPlugins()
{
	if(_display != 0)
	{
		delete _display;
		_display = 0;
	}
	
	_displayNames.clear();
	_displayIds.clear();
	
	KTrader::OfferList offers = KTrader::self()->query("Katapult/Display");
	KTrader::OfferList::ConstIterator it;
	KService::Ptr lastservice;
	for(it = offers.begin(); it != offers.end(); ++it)
	{
		KService::Ptr service = *it;
		lastservice = service;
		
		_displayNames.append(service->name());
		if(!service->property("X-Katapult-ID", QVariant::String).toString().isEmpty())
			_displayIds.append(service->property("X-Katapult-ID", QVariant::String).toString());
		else
			_displayIds.append(service->name());

		if(_displayIds.last() == _displayName)
		{
			int errCode = 0;
			_display = KParts::ComponentFactory::createInstanceFromService<KatapultDisplay>
				(service, 0, 0, QStringList(), &errCode);
		}
	}
	if(_display != 0)
	{
		KConfigGroup group(kapp->config(), QString("Displays/%1").arg(_displayName));
		_display->readSettings(&group);
	}
	else
	{
		_displayName = _displayIds.last();
		
		int errCode = 0;
		_display = KParts::ComponentFactory::createInstanceFromService<KatapultDisplay>
			(lastservice, 0, 0, QStringList(), &errCode);
			
		KConfigGroup group(kapp->config(), QString("Displays/%1").arg(_displayName));
		_display->readSettings(&group);
	}
}
コード例 #6
0
Info::Private::Private(const KService::Ptr& aPtr)
        : ptr(aPtr)
        , instanceCaption(aPtr->name())
        , groupName(aPtr->genericName())
        , itemIconName(aPtr->property("X-Kexi-ItemIcon", QVariant::String).toString())
        , objectName(aPtr->property("X-Kexi-TypeName", QVariant::String).toString())
        , partClass(aPtr->property("X-Kexi-Class", QVariant::String).toString())
        , broken(false)
        , idStoredInPartDatabase(false)
{
    bool dataView = true;
    getBooleanProperty(aPtr, "X-Kexi-SupportsDataView", &dataView);
    if (dataView) {
        supportedViewModes |= Kexi::DataViewMode;
    }
    bool designView = true;
    getBooleanProperty(aPtr, "X-Kexi-SupportsDesignView", &designView);
    if (designView) {
        supportedViewModes |= Kexi::DesignViewMode;
    }
    bool textView = false;
    getBooleanProperty(aPtr, "X-Kexi-SupportsTextView", &textView);
    if (textView) {
        supportedViewModes |= Kexi::TextViewMode;
    }
    dataView = true;
    getBooleanProperty(aPtr, "X-Kexi-SupportsDataViewInUserMode", &dataView);
    if (dataView) {
        supportedUserViewModes |= Kexi::DataViewMode;
    }
    designView = false;
    getBooleanProperty(aPtr, "X-Kexi-SupportsDesignViewInUserMode", &designView);
    if (designView) {
        supportedUserViewModes |= Kexi::DesignViewMode;
    }
    textView = false;
    getBooleanProperty(aPtr, "X-Kexi-SupportsTextViewInUserMode", &textView);
    if (textView) {
        supportedUserViewModes |= Kexi::TextViewMode;
    }
    
    isVisibleInNavigator = true;
    getBooleanProperty(aPtr, "X-Kexi-NoObject", &isVisibleInNavigator);

    isPropertyEditorAlwaysVisibleInDesignMode = true;
    getBooleanProperty(aPtr, "X-Kexi-PropertyEditorAlwaysVisibleInDesignMode",
                       &isPropertyEditorAlwaysVisibleInDesignMode);
}
コード例 #7
0
ファイル: main.cpp プロジェクト: fluxer/kde-workspace
bool KCMInit::runModule(const QString &libName, KService::Ptr service)
{
    QLibrary lib(libName);
    if (lib.load()) {
        QVariant tmp = service->property("X-KDE-Init-Symbol", QVariant::String);
        QString kcminit;
        if ( tmp.isValid() ) {
            kcminit = tmp.toString();
            if( !kcminit.startsWith( QLatin1String( "kcminit_" ) ) )
                kcminit = "kcminit_" + kcminit;
        } else {
            kcminit = "kcminit_" + libName;
        }

        // get the kcminit_ function
        void *init = lib.resolve(kcminit.toUtf8());
        if (init) {
            // initialize the module
            kDebug(1208) << "Initializing " << libName << ": " << kcminit;

            void (*func)() = (void(*)())init;
            func();
            return true;
        } else {
            kDebug(1208) << "Module" << libName << "does not actually have a kcminit function";
        }
    }
    return false;
}
コード例 #8
0
PluginData PluginLoader::instantiatePluginForDevice(const QString& name, Device* device) const
{
    PluginData ret;

    KService::Ptr service = plugins[name];
    if (!service) {
        kDebug(kdeconnect_kded()) << "Plugin unknown" << name;
        return ret;
    }

    KPluginFactory *factory = KPluginLoader(service->library()).factory();
    if (!factory) {
        kDebug(kdeconnect_kded()) << "KPluginFactory could not load the plugin:" << service->library();
        return ret;
    }

    ret.interfaces = service->property("X-KdeConnect-SupportedPackageType", QVariant::StringList).toStringList();

    QVariant deviceVariant = QVariant::fromValue<Device*>(device);

    //FIXME any reason to use QObject in template param instead KdeConnectPlugin?
    ret.plugin = factory->create<KdeConnectPlugin>(device, QVariantList() << deviceVariant);
    if (!ret.plugin) {
        kDebug(kdeconnect_kded()) << "Error loading plugin";
        return ret;
    }

    kDebug(kdeconnect_kded()) << "Loaded plugin:" << service->name();
    return ret;
}
コード例 #9
0
void ExtensionMgr::loadExtension(const QString& name) {
  KService::List sl = KServiceType::offers("Kst Extension");
  for (KService::List::ConstIterator it = sl.begin(); it != sl.end(); ++it) {
    KService::Ptr service = *it;
    if (name == service->property("Name").toString()) {
      loadExtension(service);
      return;
    }
  }
}
コード例 #10
0
KexiMigrate* MigrateManagerInternal::driver(const QString& name)
{
    if (!lookupDrivers())
        return 0;

    clearError();
    KexiDBDbg << "loading" << name;

    KexiMigrate *drv = name.isEmpty() ? 0 : m_drivers.value(name.toLatin1().toLower());
    if (drv)
        return drv; //cached

    if (!m_services_lcase.contains(name.toLower())) {
        setError(ERR_DRIVERMANAGER,
                 i18n("Could not find import/export database driver \"%1\".", name));
        return 0;
    }

    KService::Ptr ptr = *(m_services_lcase.find(name.toLower()));
    QString srv_name = ptr->property("X-Kexi-MigrationDriverName").toString();

    KexiDBDbg << "library:" << ptr->library();

    KPluginLoader loader(ptr->library());
    const uint foundMajor = (loader.pluginVersion() >> 16) & 0xff;
    const uint foundMinor = (loader.pluginVersion() >> 8) & 0xff;
    if (!KexiMigration::version().matches(foundMajor, foundMinor)) {
        setError(ERR_INCOMPAT_DRIVER_VERSION,
                 i18n(
                     "Incompatible migration driver's \"%1\" version: found version %2, expected version %3.",
                     name,
                     QString("%1.%2").arg(foundMajor).arg(foundMinor),
                     QString("%1.%2").arg(KexiMigration::version().major).arg(KexiMigration::version().minor))
                );
        return 0;
    }

    KPluginFactory *factory = loader.factory();
    if (factory)
        drv = factory->create<KexiMigrate>(this);

    if (!drv) {
        setError(ERR_DRIVERMANAGER,
                 i18n("Could not load import/export database driver \"%1\".", name));
        return 0;
    }
    KexiDBDbg << "loading succeeded:" << name;
    KexiDBDbg << "drv=" << (long)drv;

    drv->setObjectName(srv_name);
    m_drivers.insert(name.toLatin1().toLower(), drv); //cache it
    return drv;
}
コード例 #11
0
void ExtensionMgr::loadExtension(const KService::Ptr& service) {
  int err = 0;
  QString name = service->property("Name").toString();
  KstExtension *e = KParts::ComponentFactory::createInstanceFromService<KstExtension>(service, _window, 0, QStringList(), &err);
  if (e) {
    connect(e, SIGNAL(unregister()), this, SLOT(unregister()));
    KstDebug::self()->log(i18n("Kst Extension %1 loaded.").arg(name));
    doRegister(name,e);
  } else {
    KstDebug::self()->log(i18n("Error trying to load Kst extension %1.  Code=%2, \"%3\"").arg(name).arg(err).arg(err == KParts::ComponentFactory::ErrNoLibrary ? i18n("Library not found [%1].").arg(KLibLoader::self()->lastErrorMessage()) : KLibLoader::self()->lastErrorMessage()), KstDebug::Error);
  }
}
コード例 #12
0
ファイル: main.cpp プロジェクト: fluxer/kde-workspace
void KCMInit::runModules( int phase )
{
  for(KService::List::Iterator it = list.begin();
      it != list.end();
      ++it) {
      KService::Ptr service = (*it);

      QVariant tmp = service->property("X-KDE-Init-Library", QVariant::String);
      QString library;
      if( tmp.isValid() )
      {
          library = tmp.toString();
          if( !library.startsWith( QLatin1String( "kcminit_" ) ) )
              library = QLatin1String( "kcminit_" ) + library;
      }
      else
      {
          library = service->library();
      }

      if (library.isEmpty()) {
          continue; // Skip
      }

      // see ksmserver's README for the description of the phases
      QVariant vphase = service->property("X-KDE-Init-Phase", QVariant::Int );
      int libphase = 1;
      if( vphase.isValid() )
          libphase = vphase.toInt();

      if( phase != -1 && libphase != phase )
          continue;

      // try to load the library
      if (!alreadyInitialized.contains(library)) {
          runModule(library, service);
          alreadyInitialized.append(library);
      }
  }
}
コード例 #13
0
void KatapultSettings::loadCatalogPlugins()
{
	_activeCatalogs.clear();
	_catalogNames.clear();
	_catalogIds.clear();
	ActionRegistry::self()->clear();

	KTrader::OfferList offers = KTrader::self()->query("Katapult/Catalog");
	KTrader::OfferList::ConstIterator it;
	for(it = offers.begin(); it != offers.end(); ++it)
	{
		QString id;
		
		KService::Ptr service = *it;
		KatapultCatalog *catalog;
		
		if(!service->property("X-Katapult-ID", QVariant::String).toString().isEmpty())
			id = service->property("X-Katapult-ID", QVariant::String).toString();
		else
			id = service->name();
		
		_catalogNames.append(service->name());
		_catalogIds.append(id);
		
		if(_activeCatalogNames.contains(id))
		{
			int errCode = 0;
			catalog = KParts::ComponentFactory::createInstanceFromService<KatapultCatalog>
				(service, 0, 0, QStringList(), &errCode);
			if(catalog != 0)
			{
				KConfigGroup group(kapp->config(), QString("Catalogs/%1").arg(id));
				catalog->readSettings(&group);
				catalog->initialize();
				_activeCatalogs.insert(id, catalog);
			}
		}
	}
}
コード例 #14
0
void PluginSelection::readConfig()
{
  const KTrader::OfferList offers = KTrader::self()->query(
      QString::fromLatin1( "Kontact/Plugin" ),
      QString( "[X-KDE-KontactPluginVersion] == %1" ).arg( KONTACT_PLUGIN_VERSION ) );

  int activeComponent = 0;
  mPluginCombo->clear();
  for ( KService::List::ConstIterator it = offers.begin(); it != offers.end(); ++it ) {
    KService::Ptr service = *it;
    // skip summary only plugins
    QVariant var = service->property( "X-KDE-KontactPluginHasPart" );
    if ( var.isValid() && var.toBool() == false )
      continue;
    mPluginCombo->insertItem( service->name() );
    mPluginList.append( service );

    if ( service->property("X-KDE-PluginInfo-Name").toString() == mItem->value() )
      activeComponent = mPluginList.count() - 1;
  }

  mPluginCombo->setCurrentItem( activeComponent );
}
コード例 #15
0
QString MigrateManager::driverForMimeType(const QString &mimeType)
{
    if (!d_int->lookupDrivers()) {
        kDebug() << "lookupDrivers() failed";
        setError(d_int);
        return 0;
    }

    KService::Ptr ptr = d_int->m_services_by_mimetype[mimeType.toLower()];
    if (!ptr) {
        kWarning() << "No such mimetype" << mimeType;
        return QString();
    }

    return ptr->property("X-Kexi-MigrationDriverName").toString();
}
コード例 #16
0
ファイル: misc.cpp プロジェクト: serghei/kde3-kdevelop
static KDevCompilerOptions *createCompilerOptions( const QString &name, QObject *parent )
{
	KService::Ptr service = KService::serviceByDesktopName( name );
	if ( !service )
	{
		kdDebug( 9020 ) << "Can't find service " << name << endl;
		return 0;
	}


    KLibFactory *factory = KLibLoader::self()->factory(QFile::encodeName(service->library()));
    if (!factory) {
        QString errorMessage = KLibLoader::self()->lastErrorMessage();
        kdDebug(9020) << "There was an error loading the module " << service->name() << endl <<
	    "The diagnostics is:" << endl << errorMessage << endl;
        exit(1);
    }

    QStringList args;
    QVariant prop = service->property("X-KDevelop-Args");
    if (prop.isValid())
        args = QStringList::split(" ", prop.toString());

    QObject *obj = factory->create(parent, service->name().latin1(),
                                   "KDevCompilerOptions", args);

    if (!obj->inherits("KDevCompilerOptions")) {
        kdDebug(9020) << "Component does not inherit KDevCompilerOptions" << endl;
        return 0;
    }
    KDevCompilerOptions *dlg = (KDevCompilerOptions*) obj;

    return dlg;

/*
	QStringList args;
	QVariant prop = service->property( "X-KDevelop-Args" );
	if ( prop.isValid() )
		args = QStringList::split( " ", prop.toString() );

	return KParts::ComponentFactory
	       ::createInstanceFromService<KDevCompilerOptions>( service, parent,
	                                                         service->name().latin1(), args );*/
}
コード例 #17
0
void DesktopViewProxy::fileOpen()
{
    KisDocumentEntry entry = KisDocumentEntry::queryByMimeType(KIS_MIME_TYPE);
    KService::Ptr service = entry.service();
    const QStringList mimeFilter = KisImportExportManager::mimeFilter(KIS_MIME_TYPE,
                                                               KisImportExportManager::Import,
                                                               service->property("X-KDE-ExtraNativeMimeTypes").toStringList());


    KoFileDialog dialog(d->desktopWindow, KoFileDialog::OpenFile, "OpenDocument");
    dialog.setCaption(i18n("Open Document"));
    dialog.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation));
    dialog.setMimeTypeFilters(mimeFilter);
    QString filename = dialog.url();
    if (filename.isEmpty()) return;

    DocumentManager::instance()->recentFileManager()->addRecent(filename);

    QProcess::startDetached(qApp->applicationFilePath(), QStringList() << filename, QDir::currentPath());
}
コード例 #18
0
int KDCOPServiceStarter::findServiceFor( const QString& serviceType,
                                         const QString& _constraint,
                                         const QString& preferences,
                                         QString *error, QCString* pDcopService,
                                         int flags )
{
    // Ask the trader which service is preferred for this servicetype
    // We want one that provides a DCOP interface
    QString constraint = _constraint;
    if ( !constraint.isEmpty() )
        constraint += " and ";
    constraint += "exist [X-DCOP-ServiceName]";
    KTrader::OfferList offers = KTrader::self()->query(serviceType, "Application", constraint, preferences);
    if ( offers.isEmpty() ) {
        if ( error )
            *error = i18n("No service implementing %1").arg( serviceType );
        kdWarning() << "KDCOPServiceStarter: No service implementing " << serviceType << endl;
        return -1;
    }
    KService::Ptr ptr = offers.first();
    QCString dcopService = ptr->property("X-DCOP-ServiceName").toString().latin1();

    if ( !kapp->dcopClient()->isApplicationRegistered( dcopService ) )
    {
        QString error;
        if ( startServiceFor( serviceType, constraint, preferences, &error, &dcopService, flags ) != 0 )
        {
            kdDebug() << "KDCOPServiceStarter: Couldn't start service: " << error << endl;
            return -2;
        }
    }
    kdDebug() << "KDCOPServiceStarter: DCOP service is available now, as " << dcopService << endl;
    if ( pDcopService )
        *pDcopService = dcopService;
    return 0;
}
コード例 #19
0
ファイル: pluginmanager.cpp プロジェクト: tmarques/waheela
void
PluginManager::dump( const KService::Ptr service )
{
    #define ENDLI endl << Debug::indent()

    kdDebug()
      << ENDLI
      << "PluginManager Service Info:" << ENDLI
      << "---------------------------" << ENDLI
      << "name                          : " << service->name() << ENDLI
      << "library                       : " << service->library() << ENDLI
      << "desktopEntryPath              : " << service->desktopEntryPath() << ENDLI
      << "X-KDE-amaroK-plugintype       : " << service->property( "X-KDE-amaroK-plugintype" ).toString() << ENDLI
      << "X-KDE-amaroK-name             : " << service->property( "X-KDE-amaroK-name" ).toString() << ENDLI
      << "X-KDE-amaroK-authors          : " << service->property( "X-KDE-amaroK-authors" ).toStringList() << ENDLI
      << "X-KDE-amaroK-rank             : " << service->property( "X-KDE-amaroK-rank" ).toString() << ENDLI
      << "X-KDE-amaroK-version          : " << service->property( "X-KDE-amaroK-version" ).toString() << ENDLI
      << "X-KDE-amaroK-framework-version: " << service->property( "X-KDE-amaroK-framework-version" ).toString()
      << endl
      << endl;

    #undef ENDLI
}
コード例 #20
0
ファイル: main.cpp プロジェクト: Flameeyes/kdedtester
int main(int argc, char **argv)
{
	KAboutData about("kdedtester", I18N_NOOP("KDED Module tester"), version, description,
		     KAboutData::License_GPL, "(C) 2004 Diego 'Flameeyes' Pettenò", 0, 0, "*****@*****.**");
	about.addAuthor( "Diego 'Flameeyes' Pettenò", 0, "*****@*****.**" );
	KCmdLineArgs::init(argc, argv, &about);
	KCmdLineArgs::addCmdLineOptions( options );
	KApplication app;

	// no session.. just start up normally
	KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
	
	if ( args->count() == 0 )
	{
		kdError() << "You must call kdedtester with a valid kded module name." << endl;
		return -1;
	}

	/// @todo do something with the command line args here
	QCString modulename = args->arg(0);
	args->clear();
	
	if ( modulename.isEmpty() )
	{
		kdError() << "You must call kdedtester with a valid kded module name." << endl;
		return -1;
	}
	
	KService::Ptr s = KService::serviceByDesktopPath("kded/"+modulename+".desktop");
	if ( ! s || s->library().isEmpty() )
	{
		kdError() << "Unable to load the service for requested module." << endl;
		return -2;
	}
	
	// get the library loader instance
	KLibLoader *loader = KLibLoader::self();
	
	QVariant v = s->property("X-KDE-Factory");
	QString factory = v.isValid() ? v.toString() : QString::null;
	if (factory.isEmpty())
		factory = s->library();

	factory = "create_" + factory;
	QString libname = "kded_"+s->library();
	
	kdWarning() << "Recap: the factory is '" << factory << "', and the library '" << libname << "'." << endl;

	KLibrary *lib = loader->library(QFile::encodeName(libname));
	if ( ! lib )
	{
		kdWarning() << "Library not found, trying '" << libname << "' instead" << endl
			<< "KLibLoader says: " << loader->lastErrorMessage() << endl;
		
		libname.prepend("lib");
		lib = loader->library(QFile::encodeName(libname));
	}
	
	if ( ! lib )
	{
		kdError() << "Library still not found. Exiting." << endl
			<< "KLibLoader says: " << loader->lastErrorMessage() << endl;
		return -3;
	}
	
	void *create = lib->symbol(QFile::encodeName(factory));
	if ( ! create )
	{
		kdError() << "Unable to find factory symbol into library. Exiting." << endl;
		loader->unloadLibrary(QFile::encodeName(libname));
		return -4;
	}
	
        KDEDModule* (*func)(const QCString &);
        func = (KDEDModule* (*)(const QCString &)) create;
	
	KDEDModule *module = func(modulename);
	if ( ! module )
	{
		kdError() << "Factory returned NULL module. Exiting." << endl;
		loader->unloadLibrary(QFile::encodeName(libname));
		return -5;
	}
	
	delete module;
	loader->unloadLibrary(QFile::encodeName(libname));
	kdWarning() << "Module loaded (and already unloaded) correctly." << endl;
	return 0;
}
コード例 #21
0
ファイル: konqfactory.cpp プロジェクト: blue-shell/folderview
KonqViewFactory KonqFactory::createView( const QString &serviceType,
                                         const QString &serviceName,
                                         KService::Ptr *serviceImpl,
                                         KService::List *partServiceOffers,
                                         KService::List *appServiceOffers,
					 bool forceAutoEmbed )
{
  kDebug() << "Trying to create view for" << serviceType << serviceName;

  // We need to get those in any case
  KService::List offers, appOffers;

  // Query the trader
  getOffers( serviceType, &offers, &appOffers );

  if ( partServiceOffers )
     (*partServiceOffers) = offers;
  if ( appServiceOffers )
     (*appServiceOffers) = appOffers;

  // We ask ourselves whether to do it or not only if no service was specified.
  // If it was (from the View menu or from RMB + Embedding service), just do it.
  forceAutoEmbed = forceAutoEmbed || !serviceName.isEmpty();
  // Or if we have no associated app anyway, then embed.
  forceAutoEmbed = forceAutoEmbed || ( appOffers.isEmpty() && !offers.isEmpty() );
  // Or if the associated app is konqueror itself, then embed.
  if ( !appOffers.isEmpty() )
    forceAutoEmbed = forceAutoEmbed || KonqMainWindow::isMimeTypeAssociatedWithSelf( serviceType, appOffers.first() );

  if ( ! forceAutoEmbed )
  {
    if ( ! KonqFMSettings::settings()->shouldEmbed( serviceType ) )
    {
      kDebug() << "KonqFMSettings says: don't embed this servicetype";
      return KonqViewFactory();
    }
  }

    KService::Ptr service;

    // Look for this service
    if (!serviceName.isEmpty()) {
        KService::List::const_iterator it = offers.constBegin();
        for ( ; it != offers.constEnd() && !service ; ++it ) {
            if ( (*it)->desktopEntryName() == serviceName ) {
                kDebug() << "Found requested service" << serviceName;
                service = *it;
            }
        }
    }

    KonqViewFactory viewFactory;
    if (service) {
        kDebug() << "Trying to open lib for requested service " << service->desktopEntryName();
        viewFactory = tryLoadingService(service);
        // If this fails, then return an error.
        // When looking for konq_sidebartng or konq_aboutpage, we don't want to end up
        // with khtml or another Browser/View part in case of an error...
    } else {
        KService::List::Iterator it = offers.begin();
        for ( ; viewFactory.isNull() /* exit as soon as we get one */ && it != offers.end() ; ++it ) {
            service = (*it);
            // Allowed as default ?
            QVariant prop = service->property( "X-KDE-BrowserView-AllowAsDefault" );
            kDebug() << service->desktopEntryName() << " : X-KDE-BrowserView-AllowAsDefault is valid : " << prop.isValid();
            if ( !prop.isValid() || prop.toBool() ) { // defaults to true
                //kDebug() << "Trying to open lib for service " << service->name();
                viewFactory = tryLoadingService(service);
                // If this works, we exit the loop.
            } else {
                kDebug() << "Not allowed as default " << service->desktopEntryName();
            }
        }
    }

    if (serviceImpl)
        (*serviceImpl) = service;

    if (viewFactory.isNull()) {
        if (offers.isEmpty())
            kWarning() << "no part was associated with" << serviceType;
        else
            kWarning() << "no part could be loaded"; // full error was shown to user already
        return viewFactory;
    }

    QVariantList args;
    const QVariant prop = service->property( "X-KDE-BrowserView-Args" );
    if (prop.isValid()) {
        Q_FOREACH(const QString& str, prop.toString().split(' '))
            args << QVariant(str);
    }
コード例 #22
0
ファイル: thumbnail.cpp プロジェクト: Fat-Zer/tdebase
void ThumbnailProtocol::get(const KURL &url)
{
    m_mimeType = metaData("mimeType");
    kdDebug(7115) << "Wanting MIME Type:" << m_mimeType << endl;
#ifdef THUMBNAIL_HACK
    // ### HACK
    bool direct=false;
    if (m_mimeType.isEmpty())
    {
        kdDebug(7115) << "PATH: " << url.path() << endl;
        TQFileInfo info(url.path());
        if (info.isDir())
        {
            // We cannot process a directory
            error(TDEIO::ERR_IS_DIRECTORY,url.path());
            return;
        }
        else if (!info.exists())
        {
            // The file does not exist
            error(TDEIO::ERR_DOES_NOT_EXIST,url.path());
            return;
        }
        else if (!info.isReadable())
        {
            // The file is not readable!
            error(TDEIO::ERR_COULD_NOT_READ,url.path());
            return;
        }
        m_mimeType = KMimeType::findByURL(url)->name();
        kdDebug(7115) << "Guessing MIME Type:" << m_mimeType << endl;
        direct=true; // thumbnail: was probably called from Konqueror
    }
#endif

    if (m_mimeType.isEmpty())
    {
        error(TDEIO::ERR_INTERNAL, i18n("No MIME Type specified."));
        return;
    }

    m_width = metaData("width").toInt();
    m_height = metaData("height").toInt();
    int iconSize = metaData("iconSize").toInt();

    if (m_width < 0 || m_height < 0)
    {
        error(TDEIO::ERR_INTERNAL, i18n("No or invalid size specified."));
        return;
    }
#ifdef THUMBNAIL_HACK
    else if (!m_width || !m_height)
    {
        kdDebug(7115) << "Guessing height, width, icon size!" << endl;
        m_width=128;
        m_height=128;
        iconSize=128;
    }
#endif

    if (!iconSize)
        iconSize = TDEGlobal::iconLoader()->currentSize(TDEIcon::Desktop);
    if (iconSize != m_iconSize)
        m_iconDict.clear();
    m_iconSize = iconSize;

    m_iconAlpha = metaData("iconAlpha").toInt();
    if (m_iconAlpha)
        m_iconAlpha = (m_iconAlpha << 24) | 0xffffff;

    TQImage img;

    TDEConfigGroup group( TDEGlobal::config(), "PreviewSettings" );

    
    // ### KFMI
    bool kfmiThumb = false;
    if (group.readBoolEntry( "UseFileThumbnails", true )) {
        KService::Ptr service =
            KServiceTypeProfile::preferredService( m_mimeType, "KFilePlugin");

        if ( service && service->isValid() && /*url.isLocalFile() && */
            service->property("SupportsThumbnail").toBool())
        {
            KFileMetaInfo info(url.path(), m_mimeType, KFileMetaInfo::Thumbnail);
            if (info.isValid())
            {
                KFileMetaInfoItem item = info.item(KFileMimeTypeInfo::Thumbnail);
                if (item.isValid() && item.value().type() == TQVariant::Image)
                {
                    img = item.value().toImage();
                    kdDebug(7115) << "using KFMI for the thumbnail\n";
                    kfmiThumb = true;
                }
            }
        }
    }
    ThumbCreator::Flags flags = ThumbCreator::None;

    if (!kfmiThumb)
    {
        kdDebug(7115) << "using thumb creator for the thumbnail\n";
        TQString plugin = metaData("plugin");
#ifdef THUMBNAIL_HACK
        if (plugin.isEmpty())
        {
            TDETrader::OfferList plugins = TDETrader::self()->query("ThumbCreator");
            TQMap<TQString, KService::Ptr> mimeMap;
    
            for (TDETrader::OfferList::ConstIterator it = plugins.begin(); it != plugins.end(); ++it)
            {
                TQStringList mimeTypes = (*it)->property("MimeTypes").toStringList();
                for (TQStringList::ConstIterator mt = mimeTypes.begin(); mt != mimeTypes.end(); ++mt)
                {
                    if  ((*mt)==m_mimeType)
                    {
                        plugin=(*it)->library();
                        break;
                    }
                }
                if (!plugin.isEmpty())
                    break;
            }
        }
        kdDebug(7115) << "Guess plugin: " << plugin << endl;
#endif
        if (plugin.isEmpty())
        {
            error(TDEIO::ERR_INTERNAL, i18n("No plugin specified."));
            return;
        }
        
        ThumbCreator *creator = m_creators[plugin];
        if (!creator)
        {
            // Don't use KLibFactory here, this is not a TQObject and
            // neither is ThumbCreator
            KLibrary *library = KLibLoader::self()->library(TQFile::encodeName(plugin));
            if (library)
            {
                newCreator create = (newCreator)library->symbol("new_creator");
                if (create)
                    creator = create();
            }
            if (!creator)
            {
                error(TDEIO::ERR_INTERNAL, i18n("Cannot load ThumbCreator %1").arg(plugin));
                return;
            }
            m_creators.insert(plugin, creator);
        }

        if (!creator->create(url.path(), m_width, m_height, img))
        {
            error(TDEIO::ERR_INTERNAL, i18n("Cannot create thumbnail for %1").arg(url.path()));
            return;
        }
        flags = creator->flags();
    }

    if (img.width() > m_width || img.height() > m_height)
    {
        double imgRatio = (double)img.height() / (double)img.width();
        if (imgRatio > (double)m_height / (double)m_width)
            img = img.smoothScale( int(TQMAX((double)m_height / imgRatio, 1)), m_height);
        else
            img = img.smoothScale(m_width, int(TQMAX((double)m_width * imgRatio, 1)));
    }

// ### FIXME
#ifndef USE_KINSTANCE
    if (flags & ThumbCreator::DrawFrame)
    {
        TQPixmap pix;
        pix.convertFromImage(img);
        int x2 = pix.width() - 1;
        int y2 = pix.height() - 1;
        // paint a black rectangle around the "page"
        TQPainter p;
        p.begin( &pix );
        p.setPen( TQColor( 48, 48, 48 ));
        p.drawLine( x2, 0, x2, y2 );
        p.drawLine( 0, y2, x2, y2 );
        p.setPen( TQColor( 215, 215, 215 ));
        p.drawLine( 0, 0, x2, 0 );
        p.drawLine( 0, 0, 0, y2 );
        p.end();

        const TQBitmap *mask = pix.mask();
        if ( mask ) // need to update it so we can see the frame
        {
            TQBitmap bitmap( *mask );
            TQPainter painter;
            painter.begin( &bitmap );
            painter.drawLine( x2, 0, x2, y2 );
            painter.drawLine( 0, y2, x2, y2 );
            painter.drawLine( 0, 0, x2, 0 );
            painter.drawLine( 0, 0, 0, y2 );
            painter.end();

            pix.setMask( bitmap );
        }

        img = pix.convertToImage();
    }
#endif

    if ((flags & ThumbCreator::BlendIcon) && TDEGlobal::iconLoader()->alphaBlending(TDEIcon::Desktop))
    {
        // blending the mimetype icon in
        TQImage icon = getIcon();

        int x = img.width() - icon.width() - 4;
        x = TQMAX( x, 0 );
        int y = img.height() - icon.height() - 6;
        y = TQMAX( y, 0 );
        KImageEffect::blendOnLower( x, y, icon, img );
    }

    if (img.isNull())
    {
        error(TDEIO::ERR_INTERNAL, i18n("Failed to create a thumbnail."));
        return;
    }

    const TQString shmid = metaData("shmid");
    if (shmid.isEmpty())
    {
#ifdef THUMBNAIL_HACK
        if (direct)
        {
            // If thumbnail was called directly from Konqueror, then the image needs to be raw
            //kdDebug(7115) << "RAW IMAGE TO STREAM" << endl;
            TQBuffer buf;
            if (!buf.open(IO_WriteOnly))
            {
                error(TDEIO::ERR_INTERNAL, i18n("Could not write image."));
                return;
            }
            img.save(&buf,"PNG");
            buf.close();
            data(buf.buffer());
        }
        else
#endif
        {
            TQByteArray imgData;
            TQDataStream stream( imgData, IO_WriteOnly );
            //kdDebug(7115) << "IMAGE TO STREAM" << endl;
            stream << img;
            data(imgData);
        }
    }
    else
    {
        TQByteArray imgData;
        TQDataStream stream( imgData, IO_WriteOnly );
        //kdDebug(7115) << "IMAGE TO SHMID" << endl;
        void *shmaddr = shmat(shmid.toInt(), 0, 0);
        if (shmaddr == (void *)-1)
        {
            error(TDEIO::ERR_INTERNAL, i18n("Failed to attach to shared memory segment %1").arg(shmid));
            return;
        }
        if (img.width() * img.height() > m_width * m_height)
        {
            error(TDEIO::ERR_INTERNAL, i18n("Image is too big for the shared memory segment"));
            shmdt((char*)shmaddr);
            return;
        }
        if( img.depth() != 32 )           // TDEIO::PreviewJob and this code below completely
            img = img.convertDepth( 32 ); // ignores colortable :-/, so make sure there is none
        stream << img.width() << img.height() << img.depth()
               << img.hasAlphaBuffer();
        memcpy(shmaddr, img.bits(), img.numBytes());
        shmdt((char*)shmaddr);
        data(imgData);
    }
    finished();
}
コード例 #23
0
ファイル: evachatview.cpp プロジェクト: MagicGroup/eva
/*
   we just simplify the process. if we use KParts::BrowserExtension, we have to do
   lots extra work, adding so much classes. so just hack like following.

   grab useful code from TDEHTMLPopupGUIClient(tdehtml_ext.cpp),
   and change a little bit to fit our needs

*/
void EvaChatView::slotPopupMenu( const TQString & _url, const TQPoint & point )
{
    menu->clear();

    bool isImage = false;
    bool hasSelection = TDEHTMLPart::hasSelection();
    KURL url = KURL(_url);

    if(d) delete d;
    d = new MenuPrivateData;
    d->m_url = url;


    DOM::Element e = nodeUnderMouse();
    if ( !e.isNull() && (e.elementId() == ID_IMG) ) {
        DOM::HTMLImageElement ie = static_cast<DOM::HTMLImageElement>(e);
        TQString src = ie.src().string();
        d->m_imageURL = KURL(src);
        d->m_suggestedFilename = src.right(src.length() - src.findRev("/") -1);
        isImage=true;
    }


    TDEAction *action = 0L;

    if(hasSelection) {
        //action =  new TDEAction( i18n( "&Copy Text" ), TDEShortcut("Ctrl+C"), this, SLOT( copy() ),
        //			actionCollection(), "copy" );
        //action = KStdAction::copy( browserExtension(), SLOT(copy()), actionCollection(), "copy");
        //action->setText(i18n("&Copy Text"));
        //action->setEnabled(true);
        copyAction->plug(menu);

        // search text
        TQString selectedText = TDEHTMLPart::selectedText();
        if ( selectedText.length()>18 ) {
            selectedText.truncate(15);
            selectedText+="...";
        }
#ifdef HAS_KONTQUEROR
        // Fill search provider entries
        TDEConfig config("kuriikwsfilterrc");
        config.setGroup("General");
        const TQString defaultEngine = config.readEntry("DefaultSearchEngine", "google");
        const char keywordDelimiter = config.readNumEntry("KeywordDelimiter", ':');


        // default search provider
        KService::Ptr service = KService::serviceByDesktopPath(TQString("searchproviders/%1.desktop").arg(defaultEngine));

        // search provider icon
        TQPixmap icon;
        KURIFilterData data;
        TQStringList list;
        const TQString defaultSearchProviderPrefix = *(service->property("Keys").toStringList().begin()) + keywordDelimiter;
        data.setData( defaultSearchProviderPrefix + TQString("some keyword") );
        list << "kurisearchfilter" << "kuriikwsfilter";

        TQString name;
        if ( KURIFilter::self()->filterURI(data, list) ) {
            TQString iconPath = locate("cache", KMimeType::favIconForURL(data.uri()) + ".png");
            if ( iconPath.isEmpty() )
                icon = SmallIcon("edit-find");
            else
                icon = TQPixmap( iconPath );

            name = service->name();
        } else {
            icon = SmallIcon("google");
            name = "Google";
        }

        action = new TDEAction( i18n( "Search '%1' at %2" ).arg( selectedText ).arg( name ), icon, 0, this,
                                SLOT( searchProvider() ), actionCollection(), "searchProvider" );
        action->plug(menu);

        // favorite search providers
        TQStringList favoriteEngines;
        favoriteEngines = config.readListEntry("FavoriteSearchEngines"); // for KDE 3.2 API compatibility
        if(favoriteEngines.isEmpty())
            favoriteEngines << "google" << "google_groups" << "google_news" << "webster" << "dmoz" << "wikipedia";

        if ( !favoriteEngines.isEmpty()) {
            TDEActionMenu* providerList = new TDEActionMenu( i18n( "Search '%1' At" ).arg( selectedText ), actionCollection(), "searchProviderList" );
            bool hasSubMenus = false;
            TQStringList::ConstIterator it = favoriteEngines.begin();
            for ( ; it != favoriteEngines.end(); ++it ) {
                if (*it==defaultEngine)
                    continue;
                service = KService::serviceByDesktopPath(TQString("searchproviders/%1.desktop").arg(*it));
                if (!service)
                    continue;
                const TQString searchProviderPrefix = *(service->property("Keys").toStringList().begin()) + keywordDelimiter;
                data.setData( searchProviderPrefix + "some keyword" );

                if ( KURIFilter::self()->filterURI(data, list) ) {
                    TQString iconPath = locate("cache", KMimeType::favIconForURL(data.uri()) + ".png");
                    if ( iconPath.isEmpty() )
                        icon = SmallIcon("edit-find");
                    else
                        icon = TQPixmap( iconPath );
                    name = service->name();

                    providerList->insert( new TDEAction( name, icon, 0, this,
                                                         SLOT( searchProvider() ), actionCollection(), TQString( "searchProvider" + searchProviderPrefix ).latin1() ) );
                    hasSubMenus = true;
                }
            }
            if(hasSubMenus) providerList->plug(menu);
        }
#endif // HAS_KONTQUEROR
        if ( selectedText.contains("://") && KURL(selectedText).isValid() ) {
            action = new TDEAction( i18n( "Open '%1'" ).arg( selectedText ), "window_new", 0,
                                    this, SLOT( openSelection() ), actionCollection(), "openSelection" );
            action->plug(menu);
        }
    }
    if ( !url.isEmpty() ) {
        if (url.protocol() == "mailto")	{
            action = new TDEAction( i18n( "Copy Email Address" ), 0, this, SLOT( slotCopyLinkLocation() ),
                                    actionCollection(), "copylinklocation" );
            action->plug(menu);
        } else {
            action = new TDEAction( i18n( "Copy &Link Address" ), 0, this, SLOT( slotCopyLinkLocation() ),
                                    actionCollection(), "copylinklocation" );
            action->plug(menu);
        }
    }

    if (isImage)	{
#ifndef QT_NO_MIMECLIPBOARD
        action = (new TDEAction( i18n( "Copy Image" ), 0, this, SLOT( slotCopyImage() ),
                                 actionCollection(), "copyimage" ));
        action->plug(menu);
#endif
        action = new TDEAction( i18n( "Save Image As..." ), 0, this, SLOT( slotSaveImageAs() ),
                                actionCollection(), "saveimageas" );
        action->plug(menu);

        action = new TDEAction( i18n( "Save As Custom Smiley"), 0, this, SLOT( slotSaveAsCustomSmiley() ),
                                actionCollection(), "saveascustomsmiley" );
        action->plug(menu);
    }

    if(menu->count()) menu->popup(point);
}
コード例 #24
0
ファイル: kinetd.cpp プロジェクト: serghei/kde3-kdenetwork
void PortListener::loadConfig(KService::Ptr s) {
	m_valid = true;
	m_autoPortRange = 0;
	m_enabled = true;
	m_argument = QString::null;
	m_multiInstance = false;

	QVariant vid, vport, vautoport, venabled, vargument, vmultiInstance, vurl,
	  vsattributes, vslifetime, vdname, vdtype, vddata;

	m_execPath = s->exec().utf8();
	vid = s->property("X-KDE-KINETD-id");
	vport = s->property("X-KDE-KINETD-port");
	vautoport = s->property("X-KDE-KINETD-autoPortRange");
	venabled = s->property("X-KDE-KINETD-enabled");
	vargument = s->property("X-KDE-KINETD-argument");
	vmultiInstance = s->property("X-KDE-KINETD-multiInstance");
	vurl = s->property("X-KDE-KINETD-serviceURL");
	vsattributes = s->property("X-KDE-KINETD-serviceAttributes");
	vslifetime = s->property("X-KDE-KINETD-serviceLifetime");
	vdname = s->property("X-KDE-KINETD-DNSSD-Name");
	vdtype = s->property("X-KDE-KINETD-DNSSD-Type");
	vddata = s->property("X-KDE-KINETD-DNSSD-Properties");

	if (!vid.isValid()) {
		kdDebug() << "Kinetd cannot load service "<<m_serviceName
			  <<": no id set" << endl;
		m_valid = false;
		return;
	}

	if (!vport.isValid()) {
		kdDebug() << "Kinetd cannot load service "<<m_serviceName
			  <<": invalid port" << endl;
		m_valid = false;
		return;
	}

	m_serviceName = vid.toString();
	m_serviceLifetime = vslifetime.toInt();
	if (m_serviceLifetime < 120) // never less than 120 s
		m_serviceLifetime = 120;
	m_portBase = vport.toInt();
	if (vautoport.isValid())
		m_autoPortRange = vautoport.toInt();
	if (venabled.isValid())
		m_enabled = venabled.toBool();
	if (vargument.isValid())
		m_argument = vargument.toString();
	if (vmultiInstance.isValid())
		m_multiInstance = vmultiInstance.toBool();
	if (vurl.isValid()) {
		m_serviceURL = vurl.toString();
		m_registerService = true;
	}
	else {
		m_serviceURL = QString::null;
		m_registerService = false;
	}
	if (vsattributes.isValid()) {
		m_serviceAttributes = vsattributes.toString();
	}
	else
		m_serviceAttributes = "";
	if (vddata.isValid()) {
		QStringList attrs = vddata.toStringList();
		for (QStringList::iterator it=attrs.begin();
		it!=attrs.end();it++) {
		    QString key = (*it).section('=',0,0);
		    QString value =  processServiceTemplate((*it).section('=',1))[0];
		    if (!key.isEmpty()) m_dnssdData[key]=value;
		    }
	}
	if (vdname.isValid() && vdtype.isValid()) {
		m_dnssdName = processServiceTemplate(vdname.toString())[0];
		m_dnssdType = vdtype.toString();
		m_dnssdRegister = true;
		kdDebug() << "DNS-SD register is enabled\n";
	}
	else 
	        m_dnssdRegister = false;
		

	m_slpLifetimeEnd = QDateTime::currentDateTime().addSecs(m_serviceLifetime);
	m_defaultPortBase = m_portBase;
	m_defaultAutoPortRange = m_autoPortRange;

	m_config->setGroup("ListenerConfig");
	m_enabled = m_config->readBoolEntry("enabled_" + m_serviceName,
					    m_enabled);
	m_portBase = m_config->readNumEntry("port_base_" + m_serviceName,
					    m_portBase);
	m_autoPortRange = m_config->readNumEntry("auto_port_range_" + m_serviceName,
						 m_autoPortRange);
	QDateTime nullTime;
	m_expirationTime = m_config->readDateTimeEntry("enabled_expiration_"+m_serviceName,
						     &nullTime);
	if ((!m_expirationTime.isNull()) && (m_expirationTime < QDateTime::currentDateTime()))
		m_enabled = false;
	m_registerService = m_config->readBoolEntry("enabled_srvreg_"+m_serviceName,
						     m_registerService);
}
コード例 #25
0
void ShareJob::start()
{
    //KService::Ptr service = KService::serviceByStorageId("plasma-share-pastebincom.desktop");
    KService::Ptr service = KService::serviceByStorageId(destination());
    if (!service) {
        showError(i18n("Could not find the provider with the specified destination"));
        return;
    }

    QString pluginName =
        service->property("X-KDE-PluginInfo-Name", QVariant::String).toString();

    const QString path =
        KStandardDirs::locate("data", "plasma/shareprovider/" + pluginName + '/' );

    if (path.isEmpty()) {
        showError(i18n("Invalid path for the requested provider"));
        return;
    }

    m_package = new Plasma::Package(path, ShareProvider::packageStructure());
    if (m_package->isValid()) {
        const QString mainscript =
            m_package->path() + m_package->structure()->contentsPrefixPaths().at(0) +
            m_package->structure()->path("mainscript");

        if (!QFile::exists(mainscript)) {
            showError(i18n("Selected provider does not have a valid script file"));
            return;
        }

        const QString interpreter =
            Kross::Manager::self().interpreternameForFile(mainscript);

        if (interpreter.isEmpty()) {
            showError(i18n("Selected provider does not provide a supported script file"));
            return;
        }

        m_action = new Kross::Action(parent(), pluginName);
        if (m_action) {
            m_provider = new ShareProvider(this);
            connect(m_provider, SIGNAL(readyToPublish()), this, SLOT(publish()));
            connect(m_provider, SIGNAL(finished(QString)),
                    this, SLOT(showResult(QString)));
            connect(m_provider, SIGNAL(finishedError(QString)),
                    this, SLOT(showError(QString)));

            // automatically connects signals and slots with the script
            m_action->addObject(m_provider, "provider",
                                Kross::ChildrenInterface::AutoConnectSignals);

            // set the main script file and load it
            m_action->setFile(mainscript);
            m_action->trigger();

            // check for any errors
            if(m_action->hadError()) {
                showError(i18n("Error trying to execute script"));
                return;
            }

            // do the work together with the loaded plugin
            const QStringList functions = m_action->functionNames();
            if (!functions.contains("url") || !functions.contains("contentKey") ||
                !functions.contains("setup")) {
                showError(i18n("Could not find all required functions"));
                return;
            }

            // call the methods from the plugin
            const QString url =
                m_action->callFunction("url", QVariantList()).toString();
            m_provider->setUrl(url);

            // setup the method (get/post)
            QVariant vmethod;
            if (functions.contains("method")) {
                vmethod =
                    m_action->callFunction("method", QVariantList()).toString();
            }

            // default is POST (if the plugin does not specify one method)
            const QString method = vmethod.isValid() ? vmethod.toString() : "POST";
            m_provider->setMethod(method);

            // setup the provider
            QVariant setup = m_action->callFunction("setup", QVariantList());

            // get the content from the parameters, set the url and add the file
            // then we can wait the signal to publish the information
            const QString contentKey =
                m_action->callFunction("contentKey", QVariantList()).toString();

            const QString content(parameters()["content"].toString());
            m_provider->addPostFile(contentKey, content);
        }
    }
}
コード例 #26
0
KstApp::KstApp(QWidget *parent, const char* name)
: KMainWindow(parent, name) {

  clearWFlags(WDestructiveClose);

  stopping = false;
  config = kapp->config();
  initStatusBar();

  initDocument();
  initView();

  /* create dialogs */
  debugDialog = new KstDebugDialogI(this);
  plotDialog = new KstPlotDialogI(doc, this);
  dataManager = new KstDataManagerI(doc, this);
  filterListEditor = new FilterListEditor(this);
  viewScalarsDialog = new KstViewScalarsDialogI(this);
  viewVectorsDialog = new KstViewVectorsDialogI(this);
  changeFileDialog = new KstChangeFileDialogI(this);
  changeNptsDialog = new KstChangeNptsDialogI(this);
  quickCurvesDialog = new KstQuickCurvesDialogI(this);
  quickPSDDialog = new KstQuickPSDDialogI(this);
  graphFileDialog = new KstGraphFileDialogI(this);
  vectorSaveDialog = new VectorSaveDialog(this);
  
  connect(KstVectorDialogI::globalInstance(), SIGNAL(modified()), doc, SLOT(wasModified()));
  connect(KstCurveDialogI::globalInstance(), SIGNAL(modified()), doc, SLOT(wasModified()));
  connect(KstEqDialogI::globalInstance(), SIGNAL(modified()), doc, SLOT(wasModified()));
  connect(KstHsDialogI::globalInstance(), SIGNAL(modified()), doc, SLOT(wasModified()));
  connect(KstPsdDialogI::globalInstance(), SIGNAL(modified()), doc, SLOT(wasModified()));
  connect(KstPluginDialogI::globalInstance(), SIGNAL(modified()), doc, SLOT(wasModified()));
  connect(KstEventMonitorI::globalInstance(), SIGNAL(modified()), doc, SLOT(wasModified()));
  
  initActions();

  readOptions();

  _updateThread = new UpdateThread(doc);
  _updateThread->setUpdateTime(KstSettings::globalSettings()->plotUpdateTimer);
  _updateThread->start();

  connect(doc,  SIGNAL(newFrameMsg(int)),
          this, SLOT(slotUpdateFrameMsg(int)));
  connect(view, SIGNAL(newStatusMsg(const QString &)),
          this, SLOT(slotUpdateStatusMsg(const QString &)));
  connect(view, SIGNAL(newDataMsg(const QString &)),
          this, SLOT(slotUpdateDataMsg(const QString &)));

  /*** Plot Dialog signals */
  connect(changeFileDialog, SIGNAL(docChanged()),
          this,             SLOT(registerDocChange()));
  connect(changeNptsDialog, SIGNAL(docChanged()),
          this,             SLOT(registerDocChange()));
  connect(quickCurvesDialog,SIGNAL(docChanged()),
          this,             SLOT(registerDocChange()));
  connect(quickPSDDialog,   SIGNAL(docChanged()),
          this,             SLOT(registerDocChange()));
  connect(filterListEditor, SIGNAL(docChanged()),
          this,             SLOT(registerDocChange()));
  connect(graphFileDialog,  SIGNAL(graphFileReq(const QString &,int,int)),
          view,             SLOT(printToGraphicsFile(const QString &,int,int)));

  /*** label dialog ***/
  connect(view->labelDialog, SIGNAL(applied()),
          this, SLOT(registerDocChange()));

  /*** plot dialog ***/
  connect(plotDialog, SIGNAL(docChanged()), this, SLOT(registerDocChange()));

  /*** ***/
  connect(doc, SIGNAL(dataChanged()), this, SLOT(updateDialogs()));

  connect(dataManager, SIGNAL(editDataVector(const QString &)),
          KstVectorDialogI::globalInstance(), SLOT(show_I(const QString &)));

  connect(dataManager->OpenPlotDialog, SIGNAL(clicked()),
          this, SLOT(showPlotDialog()));

  setAutoSaveSettings("KST-KMainWindow", true);
  _dcopIface = new KstIfaceImpl(doc, this);
  view->forceUpdate();

  connect(this, SIGNAL(settingsChanged()), this, SLOT(slotSettingsChanged()));

  QTimer::singleShot(0, this, SLOT(updateActions()));

  // Load any extensions
  ExtensionMgr *mgr = ExtensionMgr::self();
  mgr->setWindow(this);
  KService::List sl = KServiceType::offers("Kst Extension");
  for (KService::List::ConstIterator it = sl.begin(); it != sl.end(); ++it) {
    KService::Ptr service = *it;
    QString name = service->property("Name").toString();
    if (!mgr->enabled(name) && !service->property("X-Kst-Enabled").toBool()) {
      continue;
    }
    mgr->loadExtension(service);
  }
}
コード例 #27
0
void PluginSelection::writeConfig()
{
  KService::Ptr ptr = *( mPluginList.at( mPluginCombo->currentItem() ) );
  mItem->setValue( ptr->property("X-KDE-PluginInfo-Name").toString() );
}
コード例 #28
0
ファイル: kexipartinfo.cpp プロジェクト: crayonink/calligra-2
Info::Private::Private(const KService::Ptr& aPtr)
        : ptr(aPtr)
        , instanceCaption(aPtr->name())
        , groupName(aPtr->genericName())
//        , mimeType(aPtr->property("X-Kexi-TypeMime").toString())
        , itemIconName(aPtr->property("X-Kexi-ItemIcon", QVariant::String).toString())
        , objectName(aPtr->property("X-Kexi-TypeName", QVariant::String).toString())
//        , projectPartID( aPtr->property("X-Kexi-TypeId").toInt() )
        , partClass(aPtr->property("X-Kexi-Class", QVariant::String).toString())
        , broken(false)
        , idStoredInPartDatabase(false)
{
    bool dataView = true;
    getBooleanProperty(aPtr, "X-Kexi-SupportsDataView", &dataView);
    if (dataView) {
        supportedViewModes |= Kexi::DataViewMode;
    }
    bool designView = true;
    getBooleanProperty(aPtr, "X-Kexi-SupportsDesignView", &designView);
    if (designView) {
        supportedViewModes |= Kexi::DesignViewMode;
    }
    bool textView = false;
    getBooleanProperty(aPtr, "X-Kexi-SupportsTextView", &textView);
    if (textView) {
        supportedViewModes |= Kexi::TextViewMode;
    }
    dataView = true;
    getBooleanProperty(aPtr, "X-Kexi-SupportsDataViewInUserMode", &dataView);
    if (dataView) {
        supportedUserViewModes |= Kexi::DataViewMode;
    }
    designView = false;
    getBooleanProperty(aPtr, "X-Kexi-SupportsDesignViewInUserMode", &designView);
    if (designView) {
        supportedUserViewModes |= Kexi::DesignViewMode;
    }
    textView = false;
    getBooleanProperty(aPtr, "X-Kexi-SupportsTextViewInUserMode", &textView);
    if (textView) {
        supportedUserViewModes |= Kexi::TextViewMode;
    }
    
    isVisibleInNavigator = true;
    getBooleanProperty(aPtr, "X-Kexi-NoObject", &isVisibleInNavigator);

    isPropertyEditorAlwaysVisibleInDesignMode = true;
    getBooleanProperty(aPtr, "X-Kexi-PropertyEditorAlwaysVisibleInDesignMode",
                       &isPropertyEditorAlwaysVisibleInDesignMode);

#if 0
    if (projectPartID == 0) {
        if (isVisibleInNavigator) {
            kWarning() << "Could not found project part ID! (name: '" << objectName 
                << "'). Possible problem with installation of the .desktop files for Kexi plugins";
            isVisibleInNavigator = false;
        }
        projectPartID = -1;
    }
#endif
}
コード例 #29
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;
}
コード例 #30
0
ファイル: kemoticons.cpp プロジェクト: vasi/kdelibs
bool priorityLessThan(const KService::Ptr &s1, const KService::Ptr &s2)
{
    return (s1->property("X-KDE-Priority").toInt() > s2->property("X-KDE-Priority").toInt());
}