예제 #1
0
    DEBUG_BLOCK
    foreach( Collections::CollectionFactory *factory, factories )
    {
        if( !factory )
            continue;

        const KPluginInfo info = factory->info();
        const QString name = info.pluginName();
        const bool useMySqlServer = Amarok::config( "MySQL" ).readEntry( "UseServer", false );

        bool essential = false;
        if( (useMySqlServer && (name == QLatin1String("amarok_collection-mysqlservercollection"))) ||
            (!useMySqlServer && (name == QLatin1String("amarok_collection-mysqlecollection"))) )
        {
            essential = true;
        }

        bool enabledByDefault = info.isPluginEnabledByDefault();
        bool enabled = Amarok::config( "Plugins" ).readEntry( name + "Enabled", enabledByDefault );
        if( !enabled && !essential )
            continue;

        connect( factory, SIGNAL(newCollection(Collections::Collection*)),
                 this, SLOT(slotNewCollection(Collections::Collection*)) );
        d->factories.append( factory );
        debug() << "initializing" << name;
        factory->init();
        if( name == QLatin1String("amarok_collection-mysqlecollection") )
            m_haveEmbeddedMysql = true;
    }
예제 #2
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;
}
FilterPlugin::FilterPlugin(const KPluginInfo &pluginInfo, KTp::AbstractMessageFilter *instance_):
    name(pluginInfo.pluginName()),
    instance(instance_)
{
    bool ok;
    weight = pluginInfo.service()->property(QLatin1String("X-KDE-PluginInfo-Weight"), QVariant::Int).toInt(&ok);
    if (!ok) {
        weight = 100;
    }
}
void MessageProcessor::Private::unloadFilter(const KPluginInfo &pluginInfo)
{
    QList<FilterPlugin>::Iterator iter = filters.begin();
    for ( ; iter != filters.end(); ++iter) {
        const FilterPlugin &plugin = *iter;

        if (plugin.name == pluginInfo.pluginName()) {
            qCDebug(KTP_COMMONINTERNALS) << "unloading message filter : " << plugin.instance;
            plugin.instance->deleteLater();
            filters.erase(iter);
            return;
        }
    }
}
예제 #5
0
void
Core::slotAllPluginsLoaded()
{
  QValueList<KPluginInfo*> plugins = m_pluginManager->availablePlugins();
  kdDebug()<<"Number of available plugins is "<< plugins.count() <<endl;
  for ( QValueList<KPluginInfo*>::iterator it = plugins.begin(); it != plugins.end(); ++it ) {
    KPluginInfo *i = ( *it );
    kdDebug()<<"\tAvailable plugin "<< i->pluginName()
             <<", comment = "<< i->comment() <<endl;
  }

  if ( !m_stack->visibleWidget() ) {
    m_pluginManager->loadPlugin( "komposer_defaulteditor", PluginManager::LoadAsync );
  }
}
예제 #6
0
 bool canUnload( const KPluginInfo& plugin )
 {
     kDebug() << "checking can unload for:" << plugin.name() << plugin.property("X-KDevelop-LoadMode");
     if( plugin.property( "X-KDevelop-LoadMode" ).toString() == "AlwaysOn" )
     {
         return false;
     }
     QStringList interfaces = plugin.property( "X-KDevelop-Interfaces" ).toStringList();
     kDebug() << "checking dependencies:" << interfaces;
     foreach( const KPluginInfo& info, loadedPlugins.keys() )
     {
         if( info.pluginName() != plugin.pluginName() )
         {
             QStringList dependencies = info.property( "X-KDevelop-IRequired" ).toStringList();
             dependencies += info.property( "X-KDevelop-IOptional" ).toStringList();
             foreach( const QString& dep, dependencies )
             {
                 if( interfaces.contains( dep ) && !canUnload( info ) )
                 {
                     return false;
                 }
             }
         }
     }
예제 #7
0
void PlasmaMuleApplet::contextMenuEvent(QGraphicsSceneContextMenuEvent * event)
{
	QStringList::const_iterator constIterator;
	QMenu menu;

	if (m_catDirs.count() == 1)
	{
		menu.addAction (KIcon("folder"), QString("Default"));
	} else {
		QMenu *open_sub_menu = menu.addMenu("Open Incoming");
		for (constIterator = m_catNames.constBegin(); constIterator != m_catNames.constEnd(); constIterator++)
		{
			open_sub_menu->addAction(KIcon("folder"), "Folder for " + *constIterator);
			if (constIterator != m_catNames.constEnd())
			{
				open_sub_menu->addSeparator();
			}
		}
		menu.addSeparator();
	}

	QClipboard* clipboard = QApplication::clipboard();

	if (!clipboard->text(QClipboard::Clipboard).isEmpty() || !clipboard->text(QClipboard::Selection).isEmpty())
	{
		if (m_catDirs.count() == 1)
		{
			if (!clipboard->text(QClipboard::Clipboard).isEmpty())
			{
				menu.addAction(KIcon("arrow-down-double"), "Download Link from Clipboard");

				if (!clipboard->text(QClipboard::Selection).isEmpty())
				{
					menu.addSeparator();
				}
			}

			if (!clipboard->text(QClipboard::Selection).isEmpty())
			{
				menu.addAction(KIcon("arrow-down-double"), "Download Link from Selection");
			}
		} else	{
			QMenu *download_sub_menu = menu.addMenu("Download Link");

			for (constIterator = m_catNames.constBegin(); constIterator != m_catNames.constEnd(); constIterator++)
			{
				if (!clipboard->text(QClipboard::Clipboard).isEmpty())
				{
					download_sub_menu->addAction(KIcon("arrow-down-double"), "Clipboard->" + *constIterator);

					if (!clipboard->text(QClipboard::Selection).isEmpty())
					{
						download_sub_menu->addSeparator();
					}
				}

				if (!clipboard->text(QClipboard::Selection).isEmpty())
				{
					download_sub_menu->addAction(KIcon("arrow-down-double"), "Selection->" + *constIterator);
				}

				if (constIterator != m_catNames.constEnd())
				{
				download_sub_menu->addSeparator();
				}
			}
		}
	}

	menu.addSeparator();
	menu.addAction(KIcon("documentinfo"), "About");

	QAction* selectedItem = menu.exec(QCursor::pos());
	if (selectedItem)
	{
		if (selectedItem->text() == "About")
		{
			KPluginInfo* service = new KPluginInfo (KService::serviceByDesktopName ("plasma-applet-plasmamule"));
			KAboutData* aboutData = new KAboutData (service->name().toUtf8(),
				service->name().toUtf8(),
				ki18n(service->pluginName().toUtf8()),
				service->version().toUtf8(),
				ki18n(service->comment().toUtf8()),
				KAboutData::License_GPL_V3,
				ki18n(QByteArray()),
				ki18n(QByteArray()),
				service->website().toLatin1(),
				service->email().toLatin1());
			aboutData->addAuthor (ki18n(service->author().toUtf8()),
				ki18n(QByteArray()),
				service->email().toLatin1(),
				service->website().toLatin1());
			aboutData->setTranslator(ki18nc ("NAME OF TRANSLATORS", "Your names"),
				ki18nc("EMAIL OF TRANSLATORS", "Your emails"));
			aboutData->setProgramIconName (service->icon());

			KAboutApplicationDialog* about = new KAboutApplicationDialog(aboutData, KAboutApplicationDialog::HideTranslators);
			about->exec();
		} else if (selectedItem->text().startsWith("Folder for"))
		{
			kDebug(m_debugChannel) << "Opening Folder " << m_catDirs.at(m_catNames.indexOf(selectedItem->text().remove("Folder for ")));
			KUrl url(m_catDirs.at(m_catNames.indexOf(selectedItem->text().remove("Folder for "))) + "/");
			(void) new KRun( url, 0, true );
		} else if (selectedItem->text().startsWith("Download"))
		{
			if (selectedItem->text().remove("Download Link from ") == "Clipboard")
			{
				sendLinkToEngine (clipboard->text(QClipboard::Clipboard), 0, this, m_debugChannel);
			} else {
				sendLinkToEngine (clipboard->text(QClipboard::Selection), 0, this, m_debugChannel);
			}
		} else if (selectedItem->text().startsWith("Clipboard->"))
		{
			sendLinkToEngine (clipboard->text(QClipboard::Clipboard), m_catNames.indexOf(selectedItem->text().remove("Clipboard->")), this, m_debugChannel);
		} else if (selectedItem->text().startsWith("Selection->"))
		{
			sendLinkToEngine (clipboard->text(QClipboard::Selection), m_catNames.indexOf(selectedItem->text().remove("Selection->")), this, m_debugChannel);
		}
	}
}