/** * @brief [SLOT] Add a new plugin and initialize it depending its type * @param type Supported plugin type (see: en_plugin_type) */ void PluginManager::addPluginType(en_plugin_type type) { TRACE << "[PluginManager] Adding new plugin: " << type; if (type == en_plugin_type::PLUGIN_TYPE_MACROS) { /* specific plugin initialization */ MacroPlugin *macro = new MacroPlugin(m_parent, m_settings); connect(macro, &MacroPlugin::unload, this, &PluginManager::removePlugin); connect(macro, &MacroPlugin::sendCmd, this, &PluginManager::sendCmd); /* common plugin initialization */ addPlugin((Plugin *)macro->plugin()); } else if (type == en_plugin_type::PLUGIN_TYPE_NET_PROXY) { NetProxyPlugin *proxy = new NetProxyPlugin(m_parent, m_settings); connect(proxy, &NetProxyPlugin::unload, this, &PluginManager::removePlugin); connect(proxy, &NetProxyPlugin::sendCmd, this, &PluginManager::sendCmd); connect(this, &PluginManager::recvCmd, proxy, &NetProxyPlugin::proxyCmd); /* common plugin initialization */ addPlugin((Plugin *)proxy->plugin()); } else if (type == en_plugin_type::PLUGIN_TYPE_BYTE_COUNTER) { CounterPlugin *counter = new CounterPlugin(m_parent, m_settings); connect(counter, &CounterPlugin::unload, this, &PluginManager::removePlugin); connect(this, &PluginManager::recvCmd, counter, &CounterPlugin::rxBytes); /* common plugin initialization */ addPlugin((Plugin *)counter->plugin()); } }
recordMeta(void) : m_handle(NULL), m_canThread(false) { gem::PluginFactory<gem::plugins::record>::loadPlugins("record"); std::vector<std::string>ids=gem::PluginFactory<gem::plugins::record>::getIDs(); addPlugin(ids, "QT"); addPlugin(ids, "QT4L"); addPlugin(ids); #ifdef __GNUC__ # warning isThreadable #endif #if 0 unsigned int i; for(i=0; i<m_allHandles.size(); i++) { //if(!m_allHandles[i]->isThreadable()) { if(1) { m_canThread=false; break; } } #endif }
void OMXMaster::addVendorPlugin() { #ifdef SAMSUNG_OMX addPlugin("libsomxcore.so"); #else addPlugin("libstagefrighthw.so"); #endif }
IPlugin* load(const char* path) override { char path_with_ext[MAX_PATH_LENGTH]; copyString(path_with_ext, path); const char* ext = #ifdef _WIN32 ".dll"; #elif defined __linux__ ".so"; #else #error Unknown platform #endif if (!PathUtils::hasExtension(path, ext + 1)) catString(path_with_ext, ext); g_log_info.log("Core") << "loading plugin " << path_with_ext; typedef IPlugin* (*PluginCreator)(Engine&); auto* lib = loadLibrary(path_with_ext); if (lib) { PluginCreator creator = (PluginCreator)getLibrarySymbol(lib, "createPlugin"); if (creator) { IPlugin* plugin = creator(m_engine); if (!plugin) { g_log_error.log("Core") << "createPlugin failed."; LUMIX_DELETE(m_engine.getAllocator(), plugin); ASSERT(false); } else { addPlugin(plugin); m_libraries.push(lib); m_library_loaded.invoke(lib); g_log_info.log("Core") << "Plugin loaded."; Debug::StackTree::refreshModuleList(); return plugin; } } else { g_log_error.log("Core") << "No createPlugin function in plugin."; } unloadLibrary(lib); } else { auto* plugin = StaticPluginRegister::create(path, m_engine); if (plugin) { g_log_info.log("Core") << "Plugin loaded."; addPlugin(plugin); return plugin; } g_log_warning.log("Core") << "Failed to load plugin."; } return nullptr; }
Private() { // TODO: Don't link with plugins addPlugin(new BulkTransportCapacityPlugin); addPlugin(new HTTPDownloadPlugin); addPlugin(new UPnPPlugin); addPlugin(new PingPlugin); addPlugin(new DnslookupPlugin); addPlugin(new ReverseDnslookupPlugin); addPlugin(new PacketTrainsPlugin); addPlugin(new PingPlugin); addPlugin(new TraceroutePlugin); addPlugin(new WifiLookupPlugin); }
//----------------------------------------------------------------------------- void ZonePlugin::addSubZones( void ) { AbstractPlugin* parent = getParentPlugin(); ZonePlugin* parentZone = dynamic_cast<ZonePlugin*>(parent); // the root zone if( parentZone == NULL ) { // any subzones present ? if( size() == 0 ) { osScalar colorBase = 0.8f; osScalar colorWhite = 0.3f; osColor kZoneColors[4] = { osColor( colorBase, colorWhite, colorWhite ), osColor( colorBase, colorBase, colorWhite ), osColor( colorWhite, colorBase, colorWhite ), osColor( colorWhite, colorWhite, colorBase ), }; osVector3 halfExtent = getZoneExtent(); halfExtent *= 0.5; osVector3 startOffset = position(); startOffset -= halfExtent; osVector3 offset = startOffset; for( size_t i = 0; i < 4; ++i ) { if( i == 2 ) { offset = startOffset; offset.x += halfExtent.z * 2; } ZonePlugin* subZone = ET_NEW ZonePlugin(); subZone->_zoneId = i; subZone->setZoneCenter( getZoneCenter() + offset ); subZone->setZoneExtent( getZoneExtent() * 0.5f ); subZone->setZoneColor( kZoneColors[i] ); subZone->setBorderWidth( 1.0f ); addPlugin( subZone ); onSubZoneAdded( subZone ); offset.z += halfExtent.z * 2; } addPlugin( ET_NEW CameraPlugin() ); } } }
PluginDependencyGraph tst_PluginDependencyGraph::linearGraph() { auto graph = PluginDependencyGraph{}; graph.addPlugin("p1"); graph.addPlugin("p2"); graph.addPlugin("p3"); graph.addPlugin("p4"); graph.addDependency("p1", "p2"); graph.addDependency("p2", "p3"); graph.addDependency("p3", "p4"); return std::move(graph); }
OMXMaster::OMXMaster() : mVendorLibHandle(NULL) { pid_t pid = getpid(); char filename[20]; snprintf(filename, sizeof(filename), "/proc/%d/comm", pid); int fd = open(filename, O_RDONLY); if (fd < 0) { ALOGW("couldn't determine process name"); strlcpy(mProcessName, "<unknown>", sizeof(mProcessName)); } else { ssize_t len = read(fd, mProcessName, sizeof(mProcessName)); if (len < 2) { ALOGW("couldn't determine process name"); strlcpy(mProcessName, "<unknown>", sizeof(mProcessName)); } else { // the name is newline terminated, so erase the newline mProcessName[len - 1] = 0; } close(fd); } addVendorPlugin(); addPlugin(new SoftOMXPlugin); }
void addPlugins (PluginSpecVector const & plugins) { for (auto const & plugin : plugins) { addPlugin (plugin); } }
void PluginRegistry::init() { // for each directory for( StringsCIter i = impl_->directories.begin(); i != impl_->directories.end(); ++i ) { const std::string& dir = *i; LBLOG( LOG_PLUGIN ) << "Searching plugins in " << dir << std::endl; #ifdef _WIN32 const Strings& files = searchDirectory( dir, ".*Compressor.*\\.dll" ); const char DIRSEP = '\\'; #elif defined (Darwin) const Strings& files = searchDirectory( dir, "lib.*Compressor.*\\.dylib" ); const char DIRSEP = '/'; #else const Strings& files = searchDirectory( dir, "lib.*Compressor.*\\.so" ); const char DIRSEP = '/'; #endif // for each file found in the directory for( StringsCIter j = files.begin(); j != files.end(); ++j ) { // build path + name of library const std::string libraryName = dir.empty() ? *j : dir+DIRSEP+*j; addPlugin( libraryName ); } } }
void SafePluginMap::loadFromList(const char * pluginsList) { const char *pluginDir = pluginsList; for (;*pluginDir;) { StringBuffer thisPlugin; while (*pluginDir && *pluginDir != ENVSEPCHAR) thisPlugin.append(*pluginDir++); if(*pluginDir) pluginDir++; if(!thisPlugin.length()) continue; Owned<IFile> file = createIFile(thisPlugin.str()); if (file->isDirectory() == foundYes) loadFromDirectory(thisPlugin); else { StringBuffer tail; splitFilename(thisPlugin, NULL, NULL, &tail, &tail); addPlugin(thisPlugin, tail.str()); } } }
Analyzer::Analyzer(): mDeviceList( NULL ), mActiveDevice( NULL ) { qRegisterMetaType<IConnection::Pointer>( "IConnection::Pointer" ); qRegisterMetaType<IConnection::Status>( "IConnection::Status" ); /* setup options page */ QObject::connect( &mPluginOptions, SIGNAL(newPlugin( QString )), this, SLOT(addPlugin( QString )) ); QObject::connect( this, SIGNAL(newPlugin( PluginLoader* )), &mPluginOptions, SLOT(addPluginControl( PluginLoader* )) ); DNSOptions* dns_opt = new DNSOptions( &mDnsCache ); Q_ASSERT (dns_opt); /* Add my options pages */ registerOptionsTab( &mPluginOptions ); registerOptionsTab( dns_opt ); /* Start the Connection keeper */ mUpdater.start(); //moveToThread( &mUpdater ); }
std::list<IPlugin*> PluginManager::loadPluginsFromDir(const core::string&path,const core::string& ext) { std::list<IPlugin*> ret; GCPtr<OS::IDirOS> dir=OS::IOSystem::getInstance().createDirSystem(); if(!dir->changeDir(path)) return ret; core::string fileName,base,fext; int cnt=dir->getFilesCount(); for(int i=0;i<cnt;++i){ fileName=dir->getShortFileName(i); core::StringUtil::SplitPathExt(fileName,base,fext); if(fext.equals_ignore_case(ext)) { core::string fullName=dir->getFullFileName(i); int id=addPlugin(fullName); if(id==-1) { gLogManager.log("PluginManager::loadPluginsFromDir()-failed to load plugin: "+fullName,ELL_WARNING,EVL_Heavy); }else ret.push_front(getPlugin(id)); } } return ret; }
OMXMaster::OMXMaster() : mVendorLibHandle(NULL) { addVendorPlugin(); #ifndef NO_OPENCORE addPlugin(new OMXPVCodecsPlugin); #endif }
void KNotify::loadConfig() { qDeleteAll(m_plugins); m_plugins.clear(); addPlugin(new NotifyBySound(this)); addPlugin(new NotifyByPopup(this)); addPlugin(new NotifyByExecute(this)); addPlugin(new NotifyByLogfile(this)); //TODO reactivate on Mac/Win when KWindowSystem::demandAttention will implemented on this system. #ifndef Q_WS_MAC addPlugin(new NotifyByTaskbar(this)); #endif addPlugin(new NotifyByKTTS(this)); KService::List offers = KServiceTypeTrader::self()->query("KNotify/NotifyMethod"); QVariantList args; QString error; foreach (const KService::Ptr service, offers) { KNotifyPlugin *plugin = service->createInstance<KNotifyPlugin>(this, args, &error); if (plugin) { addPlugin(plugin); } else { kDebug() << "Could not load plugin" << service->name() << "due to:" << error; } }
// // Search and load plugins // void App::initPlugins() { QString path; QString dir; settings()->get(KEY_SYSTEM_DIR, dir); dir += QString("/") + PLUGINPATH + QString("/"); // First of all, add the dummy output plugin m_dummyOutPlugin = new DummyOutPlugin(NextPluginID++); connect(m_dummyOutPlugin, SIGNAL(activated(Plugin*)), this, SLOT(slotPluginActivated(Plugin*))); addPlugin(m_dummyOutPlugin); QDir d(dir); d.setFilter(QDir::Files); if (d.exists() == false || d.isReadable() == false) { fprintf(stderr, "Unable to access plugin directory %s.\n", (const char*) dir); return; } QStringList dirlist(d.entryList()); QStringList::Iterator it; for (it = dirlist.begin(); it != dirlist.end(); ++it) { // Ignore everything else than .so files if ((*it).right(2) != QString("so")) { continue; } path = dir + *it; probePlugin(path); } // // Use the output plugin that user has selected previously // QString config; settings()->get(KEY_OUTPUT_PLUGIN, config); Plugin* plugin = searchPlugin(config, Plugin::OutputType); if (plugin != NULL) { m_outputPlugin = static_cast<OutputPlugin*> (plugin); } else { m_outputPlugin = m_dummyOutPlugin; } slotPluginActivated(m_outputPlugin); }
bool PluginRegistry::addLunchboxPlugins() { #ifdef LUNCHBOX_DSO_NAME return addPlugin( LUNCHBOX_DSO_NAME ) || // Found by LDD // Hard-coded compile locations as backup: addPlugin( std::string( LUNCHBOX_BUILD_DIR ) + "lib/" + LUNCHBOX_DSO_NAME ) || # ifdef NDEBUG addPlugin( std::string( LUNCHBOX_BUILD_DIR ) + "lib/Release/" + LUNCHBOX_DSO_NAME ) # else addPlugin( std::string( LUNCHBOX_BUILD_DIR ) + "lib/Debug/" + LUNCHBOX_DSO_NAME ) # endif ; #endif return false; }
void CTKPluginListener::processPlugins(const QList<QSharedPointer<ctkPlugin> >& plugins) { // sort the plugins according to their dependencies const QList<QSharedPointer<ctkPlugin> > sortedPlugins = sortPlugins(plugins); foreach (QSharedPointer<ctkPlugin> plugin, sortedPlugins) { if (isPluginResolved(plugin)) addPlugin(plugin); else removePlugin(plugin); } }
int PluginManager::addPluginFromDLL(GCPtr<OS::IDynamicLibrary> lib){ if(!lib)return -1; PluginCreateFunc func=(PluginCreateFunc)lib->getSymbolName("dllCreatePlugin"); if(!func){ gLogManager.log(mT("dllCreatePlugin() Not Found in Dynamic Lib: ")+core::string(lib->getLibName()),ELL_WARNING); return -1; } GCPtr<IPlugin> p=func(); return addPlugin(p); }
PluginDependencyGraph PluginDependencyGraphBuilder::buildGraph(const std::map<QString, PluginMetadata> &plugins) const { auto result = PluginDependencyGraph{}; for (auto const &plugin : plugins) { result.addPlugin(plugin.first); for (auto const &dependency : plugin.second.dependencies) result.addDependency(plugin.first, dependency); } return result; }
void PluginManager::loadPlugins() { QStringList plugins = settings().value("plugins" SUFFIX).toStringList(); plugins = plugins.toSet().toList(); /* Remove duplicates */ foreach(QString plugin, plugins) { try { addPlugin(plugin); } catch (const std::runtime_error &err) { qDebug() << err.what(); } } }
void SafePluginMap::loadFromDirectory(const char * pluginDirectory) { const char * mask = "*" SharedObjectExtension; Owned<IFile> pluginDir = createIFile(pluginDirectory); Owned<IDirectoryIterator> pluginFiles = pluginDir->directoryFiles(mask,false,false); ForEach(*pluginFiles) { const char *thisPlugin = pluginFiles->query().queryFilename(); StringBuffer tail; splitFilename(thisPlugin, NULL, NULL, &tail, &tail); addPlugin(thisPlugin, tail.str()); } }
PropertyEditorFactory::PropertyEditorFactory() : m_editor{nullptr} , m_parentWidget{nullptr} { addPlugin(new PropertyEditorPlugin< BoolEditor, ColorEditor, EnumEditor, FilePathEditor, FloatingPointEditor, SignedIntegralEditor, StringEditor, UnsignedIntegralEditor>{}); }
void tst_PluginDependencyGraph::pluginsTest() { auto graph = PluginDependencyGraph{}; QCOMPARE(graph.size(), 0); QCOMPARE(graph.plugins(), {}); graph.addPlugin("p1"); QCOMPARE(graph.size(), 1); QCOMPARE(graph.plugins(), {"p1"}); graph.addPlugin("p1"); QCOMPARE(graph.size(), 1); QCOMPARE(graph.plugins(), {"p1"}); graph.addPlugin("p2"); QCOMPARE(graph.size(), 2); QCOMPARE(graph.plugins(), (std::set<QString>{"p1", "p2"})); graph.addDependency("p1", "p2"); QCOMPARE(graph.size(), 2); QCOMPARE(graph.plugins(), (std::set<QString>{"p1", "p2"})); graph.addDependency("p3", "p4"); QCOMPARE(graph.size(), 4); QCOMPARE(graph.plugins(), (std::set<QString>{"p1", "p2", "p3", "p4"})); graph.addDependency("p1", "p5"); QCOMPARE(graph.size(), 5); QCOMPARE(graph.plugins(), (std::set<QString>{"p1", "p2", "p3", "p4", "p5"})); }
void ShaderAssembler::addPlugins(const std::string& source) { if (!m_instance) return; // Parse string const char* const src = source.c_str(); const char* first = strstr(src, "#plugin"); const char* next = src; while (first) { // Move to the end of first #plugin first += 7; // Handle whitespace std::size_t whitespace = 0; while (std::isspace(first[0])) { ++whitespace; first += 1; } // Handle missing opener case if (first[0] != '<') next = first - whitespace; else { const char* opener = first; const char* closer = strchr(opener, '>'); std::string temp(opener + 1, closer); const char* pluginEnd = strstr(first, "#pluginend"); if (!pluginEnd) { JOP_DEBUG_WARNING("Shader plugins not found or invalid formatting!"); return; } addPlugin(temp, std::string(closer + 1, pluginEnd)); next = closer + 1; } first = strstr(next, "#plugin"); } }
void OMXMaster::addVendorPlugin() { mVendorLibHandle = dlopen("libstagefrighthw.so", RTLD_NOW); if (mVendorLibHandle == NULL) { return; } typedef OMXPluginBase *(*CreateOMXPluginFunc)(); CreateOMXPluginFunc createOMXPlugin = (CreateOMXPluginFunc)dlsym( mVendorLibHandle, "_ZN7android15createOMXPluginEv"); if (createOMXPlugin) { addPlugin((*createOMXPlugin)()); } }
/*----------------------------------------------------------------------------*/ void Analyzer::loadSettings() { const QDir app_dir( QApplication::applicationDirPath() ); QSettings settings; int size = settings.beginReadArray( "plugins" ); for (int i = 0; i < size; ++i) { settings.setArrayIndex(i); const QString plugin_file = app_dir.absoluteFilePath( settings.value( "file" ).toString() ); const bool loaded = settings.value( "loaded" ).toBool(); const bool success = addPlugin( plugin_file ); if (!loaded && success) { mPlugins.back()->unload(); } } settings.endArray(); }
modelloaderMeta(void) : m_handle(NULL), m_canThread(true) { gem::PluginFactory<gem::plugins::modelloader>::loadPlugins("model"); std::vector<std::string>ids=gem::PluginFactory<gem::plugins::modelloader>::getIDs(); //addPlugin(ids, "MPEG1"); addPlugin(ids); unsigned int i; for(i=0; i<m_handles.size(); i++) { if(!m_handles[i]->isThreadable()) { m_canThread=false; break; } } }
void pluginManager::addPluginByXML(const char* name) { //fprintf(stderr,"[DEBUG] addPluginByXML(%s)\n",name); XMLDocument doc; doc.LoadFile(name); // TODO add exception handle here const char* libName = doc.FirstChildElement("libname")->GetText(); const char* funcName = doc.FirstChildElement("funcname")->GetText(); const char* freqs = doc.FirstChildElement("freq")->GetText(); int sleepInterval = atoi(freqs); struct arguments A; A.iv = sleepInterval; addPlugin(libName ,funcName ,A); }
void PluginRegistry::init() { // for each directory for( Strings::const_iterator i = _directories.begin(); i != _directories.end(); ++i ) { const std::string& dir = *i; LBLOG( LOG_PLUGIN ) << "Searching plugins in " << dir << std::endl; #ifdef _WIN32 Strings files = lunchbox::searchDirectory( dir, "EqualizerCompressor*.dll"); const char DIRSEP = '\\'; #elif defined (Darwin) Strings files = lunchbox::searchDirectory( dir, "libEqualizerCompressor*.dylib"); Strings oldFiles = lunchbox::searchDirectory( dir, "libeqCompressor*.dylib" ); files.insert( files.end(), oldFiles.begin(), oldFiles.end( )); const char DIRSEP = '/'; #else Strings files = lunchbox::searchDirectory( dir, "libEqualizerCompressor*.so" ); Strings oldFiles = lunchbox::searchDirectory( dir, "libeqCompressor*.so" ); files.insert( files.end(), oldFiles.begin(), oldFiles.end( )); const char DIRSEP = '/'; #endif // for each file found in the directory for( Strings::const_iterator j = files.begin(); j != files.end(); ++j ) { // build path + name of library const std::string libraryName = dir.empty() ? *j : dir + DIRSEP + *j; addPlugin( libraryName ); } } for( Plugins::const_iterator i = _plugins.begin(); i != _plugins.end(); ++i) { Plugin* plugin = *i; plugin->initChildren(); } }