本文整理汇总了C++中PluginLoader::getPluginInfo方法的典型用法代码示例。如果您正苦于以下问题:C++ PluginLoader::getPluginInfo方法的具体用法?C++ PluginLoader::getPluginInfo怎么用?C++ PluginLoader::getPluginInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PluginLoader
的用法示例。
在下文中一共展示了PluginLoader::getPluginInfo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: reloadPlugins
void Device::reloadPlugins()
{
QHash<QString, KdeConnectPlugin*> newPluginMap;
QMultiMap<QString, KdeConnectPlugin*> newPluginsByIncomingInterface;
QMultiMap<QString, KdeConnectPlugin*> newPluginsByOutgoingInterface;
if (isPaired() && isReachable()) { //Do not load any plugin for unpaired devices, nor useless loading them for unreachable devices
KConfigGroup pluginStates = KSharedConfig::openConfig(pluginsConfigFile())->group("Plugins");
PluginLoader* loader = PluginLoader::instance();
//Code borrowed from KWin
foreach (const QString& pluginName, loader->getPluginList()) {
QString enabledKey = pluginName + QString::fromLatin1("Enabled");
bool isPluginEnabled = (pluginStates.hasKey(enabledKey) ? pluginStates.readEntry(enabledKey, false)
: loader->getPluginInfo(pluginName).isEnabledByDefault());
if (isPluginEnabled) {
KdeConnectPlugin* plugin = m_plugins.take(pluginName);
QStringList incomingInterfaces, outgoingInterfaces;
if (plugin) {
incomingInterfaces = m_pluginsByIncomingInterface.keys(plugin);
outgoingInterfaces = m_pluginsByOutgoingInterface.keys(plugin);
} else {
const KPluginMetaData service = loader->getPluginInfo(pluginName);
incomingInterfaces = KPluginMetaData::readStringList(service.rawData(), "X-KdeConnect-SupportedPackageType");
outgoingInterfaces = KPluginMetaData::readStringList(service.rawData(), "X-KdeConnect-OutgoingPackageType");
}
//If we don't find intersection with the received on one end and the sent on the other, we don't
//let the plugin stay
//Also, if no capabilities are specified on the other end, we don't apply this optimizaton, as
//we assume that the other client doesn't know about capabilities.
if (!m_incomingCapabilities.isEmpty() && !m_outgoingCapabilities.isEmpty()
&& (m_incomingCapabilities & outgoingInterfaces.toSet()).isEmpty()
&& (m_outgoingCapabilities & incomingInterfaces.toSet()).isEmpty()
) {
delete plugin;
continue;
}
if (!plugin) {
plugin = loader->instantiatePluginForDevice(pluginName, this);
}
foreach(const QString& interface, incomingInterfaces) {
newPluginsByIncomingInterface.insert(interface, plugin);
}
foreach(const QString& interface, outgoingInterfaces) {
newPluginsByOutgoingInterface.insert(interface, plugin);
}
newPluginMap[pluginName] = plugin;
}
示例2: reloadPlugins
void Device::reloadPlugins()
{
QHash<QString, KdeConnectPlugin*> newPluginMap;
QMultiMap<QString, KdeConnectPlugin*> newPluginsByIncomingInterface;
QMultiMap<QString, KdeConnectPlugin*> newPluginsByOutgoingInterface;
QSet<QString> supportedIncomingInterfaces;
QSet<QString> supportedOutgoingInterfaces;
QStringList unsupportedPlugins;
if (isPaired() && isReachable()) { //Do not load any plugin for unpaired devices, nor useless loading them for unreachable devices
KConfigGroup pluginStates = KSharedConfig::openConfig(pluginsConfigFile())->group("Plugins");
PluginLoader* loader = PluginLoader::instance();
const bool deviceSupportsCapabilities = !m_incomingCapabilities.isEmpty() || !m_outgoingCapabilities.isEmpty();
foreach (const QString& pluginName, loader->getPluginList()) {
const KPluginMetaData service = loader->getPluginInfo(pluginName);
const QSet<QString> incomingInterfaces = KPluginMetaData::readStringList(service.rawData(), "X-KdeConnect-SupportedPackageType").toSet();
const QSet<QString> outgoingInterfaces = KPluginMetaData::readStringList(service.rawData(), "X-KdeConnect-OutgoingPackageType").toSet();
const bool pluginEnabled = isPluginEnabled(pluginName);
if (pluginEnabled) {
supportedIncomingInterfaces += incomingInterfaces;
supportedOutgoingInterfaces += outgoingInterfaces;
}
//If we don't find intersection with the received on one end and the sent on the other, we don't
//let the plugin stay
//Also, if no capabilities are specified on the other end, we don't apply this optimizaton, as
//we assume that the other client doesn't know about capabilities.
const bool capabilitiesSupported = deviceSupportsCapabilities && (!incomingInterfaces.isEmpty() || !outgoingInterfaces.isEmpty());
if (capabilitiesSupported
&& (m_incomingCapabilities & outgoingInterfaces).isEmpty()
&& (m_outgoingCapabilities & incomingInterfaces).isEmpty()
) {
qCWarning(KDECONNECT_CORE) << "not loading " << pluginName << "because of unmatched capabilities";
unsupportedPlugins.append(pluginName);
continue;
}
if (pluginEnabled) {
KdeConnectPlugin* plugin = m_plugins.take(pluginName);
if (!plugin) {
plugin = loader->instantiatePluginForDevice(pluginName, this);
}
foreach(const QString& interface, incomingInterfaces) {
newPluginsByIncomingInterface.insert(interface, plugin);
}
foreach(const QString& interface, outgoingInterfaces) {
newPluginsByOutgoingInterface.insert(interface, plugin);
}
newPluginMap[pluginName] = plugin;
}