void IDEApplication::initializePlugins() { qDebug() << "initializePlugins: loading the plugins in " PLUGIN_PATH; mPluginLoader = new QPluginLoader(this); mPluginLoader->setLoadHints(QLibrary::ResolveAllSymbolsHint | QLibrary::ExportExternalSymbolsHint); QDir pluginDir(PLUGIN_PATH); QString fileName; bool ok; foreach(const QString &entry, pluginDir.entryList(QDir::Files, QDir::Name)) { fileName = pluginDir.filePath(entry); mPluginLoader->setFileName(fileName); ok = mPluginLoader->load(); qDebug() << "Loading" << entry << "result:" << ok; if (ok) { IDEPluginInterface *plugin = dynamic_cast<IDEPluginInterface *>(mPluginLoader->instance()); ok = plugin != NULL && plugin->setup(this); qDebug() << "Initializing" << entry << "result:" << ok; } else qDebug() << mPluginLoader->errorString(); } }
PluginManagerPrivate::PluginManagerPrivate(int argc, char **argv) : EventReceiver(LowPriority) { m_argc = argc; m_argv = argv; app_name = *argv; for (argv++, argc--; argc > 0; argv++, argc--){ args.push_back(string(*argv)); } m_base = 0; m_bLoaded = false; m_bInInit = true; QStringList pluginsList; QDir pluginDir(app_file("plugins").c_str()); #ifdef WIN32 pluginsList = pluginDir.entryList("*.dll"); #else pluginsList = pluginDir.entryList("*.so"); #endif m_bAbort = false; for (QStringList::Iterator it = pluginsList.begin(); it != pluginsList.end(); ++it){ QString f = *it; int p = f.findRev('.'); if (p > 0) f = f.left(p); pluginInfo info; info.plugin = NULL; #ifdef WIN32 info.name = strdup(QFile::encodeName(f.lower())); #else info.name = strdup(QFile::encodeName(f)); #endif info.config = NULL; info.bDisabled = false; info.bNoCreate = false; info.bFromCfg = false; info.module = NULL; info.info = NULL; info.base = 0; plugins.push_back(info); } sort(plugins.begin(), plugins.end(), cmp_plugin); for (vector<pluginInfo>::iterator itp = plugins.begin(); itp != plugins.end(); ++itp){ create((*itp)); if (m_bAbort) return; } m_bInInit = false; Event eStart(EventInit); eStart.process(); for (list<string>::iterator it_args = args.begin(); it_args != args.end(); ++it_args){ if ((*it_args).length()){ usage((*it_args).c_str()); break; } } }
int main(int argc, char *argv[]) { if (argc == 3) { if (QString("--detached") == argv[1]) { QProcess::startDetached(pluginDir() + appName + " --standalone " + argv[2]); return EXIT_SUCCESS; } else if (QString("--standalone") == argv[1]) { if (QString("openoffice.org") == argv[2] || QString("msoffice") == argv[2]) { return startApp(argc, argv, argv[1]); } else { printHelp(); return EXIT_SUCCESS; } } } else if (argc == 1) { return startApp(argc, argv, "openoffice.org"); } else { printHelp(); return EXIT_SUCCESS; } }
void CPluginLoader::init() { wxFileName pluginDir(wxGetCwd(), wxT("")); pluginDir.AppendDir(wxT("plugins")); wxDir dir(pluginDir.GetPath()); wxLogMessage("Scanning plugins from \"%s\"", dir.GetName()); if ( !dir.IsOpened() ) return; wxString filename; bool next = dir.GetFirst(&filename, wxT("hz*.dll"), wxDIR_FILES); while (next) { wxFileName dllFileName(pluginDir.GetPath(), filename); TPluginDescriptor desc; TPluginInfo info; info.libHandle = new wxDynamicLibrary(); if (info.libHandle->Load(dllFileName.GetFullPath(), wxDL_DEFAULT/*|wxDL_QUIET*/)) { wxLogMessage("\"%s\": Successfully loaded", dllFileName.GetFullPath()); wxString symbolName; #ifdef _MSC_VER symbolName = wxT("?CreatePlugin@@YAPAVIPluginApi@@PAVIPluginRegistry@@@Z"); #else symbolName = wxT("_Z12CreatePluginP15IPluginRegistry"); #endif if (info.libHandle->HasSymbol(symbolName)) { CREATEPLUGIN pfnCreatePlugin = (CREATEPLUGIN)info.libHandle->GetSymbol(symbolName); info.plugin = pfnCreatePlugin(this); info.plugin->getInfo(desc); info.strFilename = filename; info.strName = wxString::FromAscii(desc.pszShortName); info.strDescription = wxString::FromAscii(desc.pszLongName); info.strVersion = wxString::FromAscii(desc.pszVersion); info.pluginId = desc.pluginId; // Store plugin info m_Plugins.push_back(info); // Add locale catalog of plugin wxGetApp().getLocale().AddCatalog(dllFileName.GetName()); } else { wxLogWarning("\"%s\": No valid plugin", dllFileName.GetFullPath()); info.libHandle->Unload(); delete info.libHandle; } } else { wxLogWarning("\"%s\": Can't load plugin", dllFileName.GetFullPath()); delete info.libHandle; } next = dir.GetNext(&filename); } }
PluginDB::PluginDB() { SettingsStore ss; m_engine_paths = ss.pluginEnginePaths(); QDir pluginDir(pluginsPath()); if (!pluginDir.exists()) { pluginDir.mkpath(pluginsPath()); } }
static void loadPluginDir(const QString& s, const PluginType t) { if (debugMsg) qWarning("scan plugin dir <%s>\n", s.toLatin1().constData()); #ifdef __WINDOWS__ QDir pluginDir(s, QString("*.dll")); #else QDir pluginDir(s, QString("*.so")); #endif if (pluginDir.exists()) { QFileInfoList list = pluginDir.entryInfoList(); QFileInfoList::iterator it = list.begin(); while (it != list.end()) { // Disable known broken plugins that may crash oom on startup QStringList blacklist; blacklist.append("dssi-vst.so"); blacklist.append("liteon_biquad-vst.so"); blacklist.append("liteon_biquad-vst_64bit.so"); blacklist.append("fx_blur-vst.so"); blacklist.append("fx_blur-vst_64bit.so"); blacklist.append("Scrubby_64bit.so"); blacklist.append("Skidder_64bit.so"); blacklist.append("libwormhole2_64bit.so"); blacklist.append("vexvst.so"); if (blacklist.contains( ((QFileInfo*)&*it)->fileName()) ) { ++it; continue; } loadPluginLib(&*it, t); ++it; } } }
PluginWidget::PluginWidget() : m_isDirty(false) { ui.setupUi(this); readSettings(); connectSignalsToSlots(); m_PluginsPath = PluginRunner::pluginsPath(); QDir pluginDir(m_PluginsPath); if (!pluginDir.exists() ) { pluginDir.mkpath(m_PluginsPath); } }
inline void KNMusicBackendBass::loadPlugin(const QString &dirPath) { //Get the dynamic linked library suffix name. QString dylibSuffix; #ifdef Q_OS_WIN dylibSuffix=QString("dll"); #endif #ifdef Q_OS_MACX dylibSuffix=QString("dylib"); #endif #ifdef Q_OS_LINUX dylibSuffix=QString("so"); #endif //Check if we have already get the suffix for current OS. if(dylibSuffix.isEmpty()) { //Ignore the load request if we cannot get the suffix. return; } //Get the plugin directory. QDir pluginDir(dirPath); //Check the diretory existence. if(!pluginDir.exists()) { return; } //Get all the file from the plugin dir. QFileInfoList pluginList=pluginDir.entryInfoList(); //Check all the file. for(auto i=pluginList.constBegin(); i!=pluginList.constEnd(); ++i) { //If the item is file, and the suffix is dynamic linked library, then //we have to tried to load the plugin. if((*i).isFile() && (*i).suffix().toLower()==dylibSuffix) { //Load the plugin. HPLUGIN plugin= //For windows, we have to use stdWString. #ifdef Q_OS_WIN BASS_PluginLoad((*i).absoluteFilePath().toStdWString().data(), 0); #endif #ifdef Q_OS_UNIX BASS_PluginLoad((*i).absoluteFilePath().toStdString().data(), 0); #endif //Add the plugin to the plugin list. m_pluginList.append(plugin); } } }
const QList<QByteArray> VlcMediaPlayer::GenerateVlcParameters() { QList<QByteArray> params; params << QByteArray("--intf=dummy"); // No interface // --plugin-path lib startup parameter is only supported and needed in VLC 1.x. // For >=2.0.0 the plugins are located in <tundra_install_dir>/plugins/vlcplugins. // VLC will always look recursively for plugins (5 levels) from /plugins. QString vlcLibVersion(libvlc_get_version()); if (vlcLibVersion.startsWith("1")) { QString folderToFind = "vlcplugins"; QDir pluginDir(Application::InstallationDirectory()); if (pluginDir.exists(folderToFind)) pluginDir.cd(folderToFind); else { // This most likely means we are running // inside a IDE from the viewer projects folder. // as in tundra/Viewer/{RelWithDebInfo|Debug|Release} while (!pluginDir.exists("bin")) { if (!pluginDir.cdUp()) { LogWarning("VlcMediaPlayer: Cannot find vlcplugins folder for plugins, starting without specifying plugin path."); return params; } } pluginDir.cd("bin"); pluginDir.cd(folderToFind); } // Validate if (!pluginDir.absolutePath().endsWith(folderToFind)) { LogWarning("VlcMediaPlayer: Cannot find vlcplugins folder for plugins, starting without specifying plugin path."); return params; } // Set plugin path to start params QString pluginPath = QLatin1Literal("--plugin-path=") % QDir::toNativeSeparators(pluginDir.absolutePath()); params << QFile::encodeName(pluginPath); } return params; }
modelDataSettingsManager::modelDataSettingsManager(){ int i; modelDataSettingsInterface *settingsPlugin; printf("Loading settings plugins:\n"); // Load plugins... QDir pluginDir("plugins"); QStringList pluginFiles; pluginDir.setNameFilters(QStringList(QString("*.so"))); pluginFiles=pluginDir.entryList(); for (i=0;i<pluginFiles.count();i++){ // printf("Trying to load - %s\n",pluginFiles[i].toAscii().data()); QPluginLoader loader(pluginDir.path()+"/"+pluginFiles[i]); settingsPlugin = qobject_cast<modelDataSettingsInterface *> (loader.instance()); if (settingsPlugin){ printf("%s\t-\t%s\n", settingsPlugin->pluginName().toAscii().data(), settingsPlugin->pluginDescription().toAscii().data()); settings.append(settingsPlugin); } } }
PluginManager::PluginManager(string plugin_dir) { fs::path pluginDir(plugin_dir); if (!fs::exists(pluginDir) || !fs::is_directory(pluginDir)) throw PluginException(plugin_dir + " is not a directory"); fs::directory_iterator end_iter; for(fs::directory_iterator dir_iter(pluginDir); dir_iter != end_iter; ++dir_iter) { if(fs::is_regular_file(dir_iter->status()) ) { string filename = (*dir_iter).path().filename().string(); loadPlugin(filename); } } watcher = new FileWatcher(plugin_dir, boost::bind(&PluginManager::fileChanged, this, _1, _2, _3)); }
QStringList QgsPythonUtilsImpl::pluginList() { QDir pluginDir( QgsPythonUtilsImpl::pluginsPath(), "*", QDir::Name | QDir::IgnoreCase, QDir::Dirs | QDir::NoDotAndDotDot ); QDir homePluginDir( QgsPythonUtilsImpl::homePluginsPath(), "*", QDir::Name | QDir::IgnoreCase, QDir::Dirs | QDir::NoDotAndDotDot ); QStringList pluginList = pluginDir.entryList(); for ( uint i = 0; i < homePluginDir.count(); i++ ) { QString packageName = homePluginDir[i]; if ( !pluginList.contains( packageName ) ) pluginList.append( packageName ); } return pluginList; }
bool Player::prepare() { //Init Gst // QString caps_value = "audio/x-raw"; // On mac we bundle the gstreamer plugins with knowthelist #if defined(Q_OS_DARWIN) QString scanner_path; QString plugin_path; QString registry_filename; QDir pd(QCoreApplication::applicationDirPath() + "/../plugins"); scanner_path = QCoreApplication::applicationDirPath() + "/../plugins/gst-plugin-scanner"; plugin_path = QCoreApplication::applicationDirPath() + "/../plugins/gstreamer"; registry_filename = QDesktopServices::storageLocation(QDesktopServices::DataLocation) + QString("/gst-registry-%1-bin").arg(QCoreApplication::applicationVersion()); if ( pd.exists()) setenv("GST_PLUGIN_SCANNER", scanner_path.toLocal8Bit().constData(), 1); if ( pd.exists()) { setenv("GST_PLUGIN_PATH", plugin_path.toLocal8Bit().constData(), 1); // Never load plugins from anywhere else. setenv("GST_PLUGIN_SYSTEM_PATH", plugin_path.toLocal8Bit().constData(), 1); } if (!registry_filename.isEmpty()) { setenv("GST_REGISTRY", registry_filename.toLocal8Bit().constData(), 1); } #elif defined(Q_OS_WIN32) QString plugin_path = QCoreApplication::applicationDirPath() + "/plugins"; QDir pluginDir(plugin_path); if ( pluginDir.exists()) _putenv_s("GST_PLUGIN_PATH", plugin_path.toLocal8Bit()); #endif //_putenv_s("GST_DEBUG", "*:4"); //win //setenv("GST_DEBUG", "*:3", 1); //unix gst_init (0, 0); //prepare GstElement *dec, *conv,*resample,*sink, *gain, *audio, *vol, *level, *equalizer; GstElement *levelout; GstPad *audiopad; GstCaps *caps; pipeline = gst_pipeline_new ("pipeline"); bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); #ifdef GST_API_VERSION_1 dec = gst_element_factory_make ("decodebin", "decoder"); #else dec = gst_element_factory_make ("decodebin2", "decoder"); caps_value = "audio/x-raw-int"; #endif caps = gst_caps_new_simple (caps_value.toLatin1().data(), "channels", G_TYPE_INT, 2, NULL); g_signal_connect (dec, "pad-added", G_CALLBACK (cb_newpad), this); gst_bin_add (GST_BIN (pipeline), dec); audio = gst_bin_new ("audiobin"); conv = gst_element_factory_make ("audioconvert", "aconv"); resample = gst_element_factory_make ("audioresample", "resample"); audiopad = gst_element_get_static_pad (conv, "sink"); gain = gst_element_factory_make ("audioamplify", "gain"); level = gst_element_factory_make ("level", "levelintern"); vol = gst_element_factory_make ("volume", "volume"); levelout = gst_element_factory_make ("level", "levelout"); equalizer = gst_element_factory_make ("equalizer-3bands", "equalizer"); sink = gst_element_factory_make ("autoaudiosink", "sink"); g_object_set (level, "message", TRUE, NULL); g_object_set (levelout, "message", TRUE, NULL); g_object_set (level, "peak-ttl", 300000000000, NULL); gst_bin_add_many (GST_BIN (audio), conv, resample, level, gain, equalizer, levelout, vol, sink, NULL); gst_element_link (conv,resample); gst_element_link_filtered (resample, level, caps); gst_element_link (level, gain); gst_element_link (gain, equalizer); gst_element_link (equalizer, vol); gst_element_link_filtered (vol, levelout, caps); gst_element_link (levelout,sink); gst_element_add_pad (audio, gst_ghost_pad_new ("sink", audiopad)); gst_bin_add (GST_BIN (pipeline), audio); GstElement *l_src; l_src = gst_element_factory_make ("filesrc", "localsrc"); gst_bin_add_many (GST_BIN (pipeline), l_src, NULL); gst_element_set_state (l_src, GST_STATE_NULL); gst_element_link ( l_src,dec); #ifdef GST_API_VERSION_1 gst_bus_set_sync_handler (bus, bus_cb, this, NULL); #else gst_bus_set_sync_handler (bus, bus_cb, this); #endif gst_object_unref (audiopad); return pipeline; }
void LibraryManager::scanPlugins() { void* fct = NULL; boost::filesystem::directory_iterator end_iter; std::string extension = EXTENSION_LIB; Settings* setting = Settings::getInstance(); std::string fctname = "getLibraryName"; for (std::vector<std::string>::iterator it = setting->PluginFolders.begin(); it != setting->PluginFolders.end(); ++it) { boost::filesystem::path pluginDir(*it); if (boost::filesystem::exists(pluginDir) && boost::filesystem::is_directory(pluginDir)) { LOG(LogLevel::PLUGINS) << "Scanning library folder " << pluginDir.string() << " ..."; for (boost::filesystem::directory_iterator dir_iter(pluginDir); dir_iter != end_iter; ++dir_iter) { LOG(LogLevel::PLUGINS) << "Checking library " << dir_iter->path().filename().string() << "..."; if ((boost::filesystem::is_regular_file(dir_iter->status()) || boost::filesystem::is_symlink(dir_iter->status())) && dir_iter->path().extension() == extension && (hasEnding(dir_iter->path().filename().string(), enumType[LibraryManager::CARDS_TYPE] + extension) || hasEnding(dir_iter->path().filename().string(), enumType[LibraryManager::READERS_TYPE] + extension) || hasEnding(dir_iter->path().filename().string(), enumType[LibraryManager::UNIFIED_TYPE] + extension))) { try { if (libLoaded.find(dir_iter->path().filename().string()) == libLoaded.end()) { IDynLibrary* lib = newDynLibrary(dir_iter->path().string()); fct = lib->getSymbol(fctname.c_str()); if (fct != NULL) { LOG(LogLevel::PLUGINS) << "Library " << dir_iter->path().filename().string() << " loaded."; libLoaded[dir_iter->path().filename().string()] = lib; } else { LOG(LogLevel::PLUGINS) << "Cannot found library entry point in " << dir_iter->path().filename().string() << ". Skipped."; delete lib; } } else { LOG(LogLevel::PLUGINS) << "Library " << dir_iter->path().filename().string() << " already loaded. Skipped."; } } catch (const std::exception &e) { LOG(LogLevel::ERRORS) << "Something bad happened when handling " << dir_iter->path().filename().string() << ": " << e.what(); } } else { LOG(LogLevel::PLUGINS) << "File " << dir_iter->path().filename().string() << " does not match excepted filenames. Skipped."; } } } else { LOG(LogLevel::WARNINGS) << "Cannot found plug-in folder " << (*it); } } }
bool AP_Win32App::initialize(void) { bool bSuccess = true; const char * szUserPrivateDirectory = getUserPrivateDirectory(); bool bVerified = s_createDirectoryIfNecessary(szUserPrivateDirectory); UT_return_val_if_fail (bVerified, false); // create templates directory UT_String sTemplates = szUserPrivateDirectory; sTemplates += "/templates"; s_createDirectoryIfNecessary(sTemplates.c_str()); // load the preferences. m_prefs = new AP_Win32Prefs(); UT_return_val_if_fail (m_prefs, false); m_prefs->fullInit(); // now that preferences are established, let the xap init m_pClipboard = new AP_Win32Clipboard(); UT_return_val_if_fail (m_pClipboard, false); m_pEMC = AP_GetEditMethods(); UT_return_val_if_fail (m_pEMC, false); m_pBindingSet = new AP_BindingSet(m_pEMC); UT_return_val_if_fail (m_pBindingSet, false); m_pMenuActionSet = AP_CreateMenuActionSet(); UT_return_val_if_fail (m_pMenuActionSet,false); m_pToolbarActionSet = AP_CreateToolbarActionSet(); UT_return_val_if_fail (m_pToolbarActionSet,false); ////////////////////////////////////////////////////////////////// // load the dialog and message box strings ////////////////////////////////////////////////////////////////// { // assume we will be using the builtin set (either as the main // set or as the fallback set). AP_BuiltinStringSet * pBuiltinStringSet = new AP_BuiltinStringSet(this,AP_PREF_DEFAULT_StringSet); UT_return_val_if_fail (pBuiltinStringSet, false); m_pStringSet = pBuiltinStringSet; // see if we should load an alternate set from the disk const char * szDirectory = NULL; const char * szStringSet = NULL; if ( (getPrefsValue(AP_PREF_KEY_StringSet,&szStringSet)) && (szStringSet) && (*szStringSet) && (g_ascii_strcasecmp(szStringSet,AP_PREF_DEFAULT_StringSet) != 0)) { getPrefsValueDirectory(true,AP_PREF_KEY_StringSetDirectory,&szDirectory); UT_return_val_if_fail ((szDirectory) && (*szDirectory), false); char * szPathname = (char *)UT_calloc(sizeof(char),strlen(szDirectory)+strlen(szStringSet)+100); UT_return_val_if_fail (szPathname, false); sprintf(szPathname,"%s%s%s.strings", szDirectory, ((szDirectory[strlen(szDirectory)-1]=='\\') ? "" : "\\"), szStringSet); AP_DiskStringSet * pDiskStringSet = new AP_DiskStringSet(this); UT_return_val_if_fail (pDiskStringSet, false); if (pDiskStringSet->loadStringsFromDisk(szPathname)) { pDiskStringSet->setFallbackStringSet(m_pStringSet); m_pStringSet = pDiskStringSet; UT_Language_updateLanguageNames(); UT_DEBUGMSG(("Using StringSet [%s]\n",szPathname)); } else { UT_DEBUGMSG(("Unable to load StringSet [%s] -- using builtin strings instead.\n",szPathname)); DELETEP(pDiskStringSet); } g_free(szPathname); } } // AP_App::initilize() calls for us XAP_Win32App::initialize() if (! AP_App::initialize()) return false; // let various window types register themselves if (!AP_Win32Frame::RegisterClass(this)) { UT_DEBUGMSG(("couldn't register class\n")); return false; } ////////////////////////////////////////////////////////////////// // Initialize the importers/exporters ////////////////////////////////////////////////////////////////// IE_ImpExp_RegisterXP (); ////////////////////////////////////////////////////////////////// // initializes the spell checker. ////////////////////////////////////////////////////////////////// { #if ENABLE_SPELL SpellManager::instance(); #endif } // Now we have the strings loaded we can populate the field names correctly int i; for (i = 0; fp_FieldTypes[i].m_Type != FPFIELDTYPE_END; i++) { (&fp_FieldTypes[i])->m_Desc = m_pStringSet->getValue(fp_FieldTypes[i].m_DescId); UT_DEBUGMSG(("Setting field type desc for type %d, desc=%s\n", fp_FieldTypes[i].m_Type, fp_FieldTypes[i].m_Desc)); } for (i = 0; fp_FieldFmts[i].m_Tag != NULL; i++) { (&fp_FieldFmts[i])->m_Desc = m_pStringSet->getValue(fp_FieldFmts[i].m_DescId); UT_DEBUGMSG(("Setting field desc for field %s, desc=%s\n", fp_FieldFmts[i].m_Tag, fp_FieldFmts[i].m_Desc)); } /////////////////////////////////////////////////////////////////////// /// Build a labelset so the plugins can add themselves to something /// /////////////////////////////////////////////////////////////////////// const char * szMenuLabelSetName = NULL; if (getPrefsValue( AP_PREF_KEY_StringSet, (const gchar**)&szMenuLabelSetName) && (szMenuLabelSetName) && (*szMenuLabelSetName)) { ; } else szMenuLabelSetName = AP_PREF_DEFAULT_StringSet; getMenuFactory()->buildMenuLabelSet(szMenuLabelSetName); ////////////////////////////////////////////////////////////////// // Check for necessary DLLs now that we can do localized error messages ////////////////////////////////////////////////////////////////// // Ensure that common control DLL is loaded HINSTANCE hinstCC = LoadLibraryW(L"comctl32.dll"); UT_return_val_if_fail (hinstCC, false); InitCommonControlsEx_fn pInitCommonControlsEx = NULL; if( hinstCC != NULL ) pInitCommonControlsEx = (InitCommonControlsEx_fn)GetProcAddress( hinstCC, "InitCommonControlsEx"); if( pInitCommonControlsEx != NULL ) { INITCOMMONCONTROLSEX icex; icex.dwSize = sizeof(INITCOMMONCONTROLSEX); icex.dwICC = ICC_COOL_CLASSES | ICC_BAR_CLASSES // load the rebar and toolbar | ICC_TAB_CLASSES | ICC_UPDOWN_CLASS // and tab and spin controls | ICC_STANDARD_CLASSES; pInitCommonControlsEx(&icex); } else { InitCommonControls(); UT_Win32LocaleString err; err.fromUTF8 (m_pStringSet->getValue(AP_STRING_ID_WINDOWS_COMCTL_WARNING)); MessageBoxW(NULL, err.c_str(), NULL, MB_OK); } ////////////////////////////////////////////////////////////////// // load the all Plugins from the correct directory ////////////////////////////////////////////////////////////////// #ifndef DISABLE_BUILTIN_PLUGINS abi_register_builtin_plugins(); #endif bool bLoadPlugins = true; bool bFound = getPrefsValueBool(XAP_PREF_KEY_AutoLoadPlugins,&bLoadPlugins); if(bLoadPlugins || !bFound) { WCHAR szPath[PATH_MAX]; WCHAR szPlugin[PATH_MAX]; _getExeDir( szPath, PATH_MAX); #ifdef _MSC_VER lstrcatW(szPath, L"..\\plugins\\*.dll"); #else #define ABI_WIDE_STRING(t) L ## t lstrcatW(szPath, ABI_WIDE_STRING("..\\lib\\" PACKAGE L"-" ABIWORD_SERIES L"\\plugins\\*.dll")); #endif WIN32_FIND_DATAW cfile; HANDLE findtag = FindFirstFileW( szPath, &cfile ); if( findtag != INVALID_HANDLE_VALUE ) { do { _getExeDir( szPlugin, PATH_MAX ); #ifdef _MSC_VER lstrcatW( szPlugin, L"..\\plugins\\" ); #else lstrcatW( szPlugin, ABI_WIDE_STRING("..\\lib\\" PACKAGE L"-" ABIWORD_SERIES L"\\plugins\\" )); #endif lstrcatW( szPlugin, cfile.cFileName ); XAP_ModuleManager::instance().loadModule( getUTF8String(szPlugin) ); } while( FindNextFileW ( findtag, &cfile ) ); FindClose( findtag ); } UT_String pluginName( getUserPrivateDirectory() ); UT_String pluginDir( getUserPrivateDirectory() ); pluginDir += "\\AbiWord\\plugins\\*.dll"; UT_Win32LocaleString str; str.fromUTF8(pluginDir.c_str()); findtag = FindFirstFileW( str.c_str(), &cfile ); if( findtag != INVALID_HANDLE_VALUE ) { do { pluginName = getUserPrivateDirectory(); pluginName += "\\AbiWord\\plugins\\"; pluginName += getUTF8String(cfile.cFileName); XAP_ModuleManager::instance().loadModule( pluginName.c_str() ); } while( FindNextFileW( findtag, &cfile ) ); FindClose( findtag ); } } return bSuccess; }
Controller::Controller(QString datadir, QString size, bool maximize, QObject *parent) : QObject(parent) { qRegisterMetaType<Image*>("Image"); qmlRegisterInterface<QAbstractItemModel >("QAbstractItemModel"); #if defined(Q_OS_ANDROID) QDir current=QDir::current(); current.cdUp(); Controller::cachePath=current.absolutePath()+"/cache"; Controller::dataPath=current.absolutePath()+"/files"; #else mViewer.setIcon(QIcon(":/images/icon512.png")); QString baseBase=datadir!="" ? datadir : QDir::homePath()+"/.TvSeriesOrganizer"; Controller::cachePath=baseBase+"/cache"; Controller::dataPath=baseBase+"/data"; QDir dir; dir.mkpath(Controller::cachePath); dir.mkpath(Controller::dataPath); #endif Series::dataPath=Controller::dataPath; QQmlNetworkAccessManagerFactoryWithCache * factory=new QQmlNetworkAccessManagerFactoryWithCache(cachePath); mViewer.engine()->setNetworkAccessManagerFactory(factory); QQmlContext *ctxt = mViewer.rootContext(); #if defined(Q_OS_ANDROID) mViewer.showExpanded(); ctxt->setContextProperty("awidth",mViewer.width()); ctxt->setContextProperty("aheight",mViewer.height()); #else QStringList cSize=size.split("x"); ctxt->setContextProperty("awidth",cSize[0].toInt()); ctxt->setContextProperty("aheight",cSize[1].toInt()); if(maximize) { QTimer * maximizeTimer=new QTimer(); maximizeTimer->setInterval(0); maximizeTimer->setSingleShot(true); connect(maximizeTimer,&QTimer::timeout,[this](){mViewer.showMaximized();}); maximizeTimer->start(); } #endif SignalList<Plugin*> * pluginList=new SignalList<Plugin*>(); QDir pluginDir(QCoreApplication::applicationDirPath()+"/plugin/"); for(QFileInfo fileInfo : pluginDir.entryInfoList(QDir::Files)) { QPluginLoader loader(fileInfo.absoluteFilePath()); QObject *plugin = loader.instance(); if(plugin) { AbstractPlugin * plug = qobject_cast<AbstractPlugin *>(plugin); Plugin * plug2=new Plugin(plug,this); pluginList->append(plug2); } } ctxt->setContextProperty("noPlugin",pluginList->size()==0); ctxt->setContextProperty("pluginModel",new SignalListAdapter<Plugin*>(pluginList,"plugin")); QNetworkAccessManager * networkAccessManager=new QNetworkAccessManager(this); DiskCache * diskCache=new DiskCache(networkAccessManager,this); TheTvDBAPI * theTvDBAPI=new TheTvDBAPI(Controller::cachePath,"http://thetvdb.com",TheTvDBAPIKey,networkAccessManager,diskCache,this); theTvDBAPI->updateCache([this,theTvDBAPI,ctxt,maximize,diskCache]() { mSeriesList=new SeriesList(theTvDBAPI,nullptr,this); mSeriesList->loadSeries(Controller::dataPath+"/myseries.txt"); ctxt->setContextProperty("seriesList", mSeriesList); TraktTvAPI* traktTvAPI = new TraktTvAPI(Controller::cachePath,mSeriesList,"http://api.trakt.tv",TraktTvAPIKey,theTvDBAPI,diskCache,this); SeriesListList * seriesListList=new SeriesListList(traktTvAPI,this); ctxt->setContextProperty("seriesListList", seriesListList); Settings::declareSettingsQml(); Settings * settings=new Settings(dataPath,this); ctxt->setContextProperty("settings", settings); mViewer.setSource(QUrl("qrc:/view/MainView.qml")); #if !defined(Q_OS_ANDROID) if(!maximize) mViewer.showExpanded(); #endif //qDebug()<<mViewer.size(); //mViewer.setMaximumSize(mViewer.size()); //mViewer.setMinimumSize(mViewer.size()-QSize(10,10)); }); }
std::vector<QString> FeatureExtractionPluginFactory::getPluginIdentifiers() { Profiler profiler("FeatureExtractionPluginFactory::getPluginIdentifiers"); std::vector<QString> rv; std::vector<QString> path = getPluginPath(); for (std::vector<QString>::iterator i = path.begin(); i != path.end(); ++i) { #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: scanning directory " << i->toStdString() << std::endl; #endif QDir pluginDir(*i, PLUGIN_GLOB, QDir::Name | QDir::IgnoreCase, QDir::Files | QDir::Readable); for (unsigned int j = 0; j < pluginDir.count(); ++j) { QString soname = pluginDir.filePath(pluginDir[j]); #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: trying potential library " << soname.toStdString() << std::endl; #endif void *libraryHandle = DLOPEN(soname, RTLD_LAZY | RTLD_LOCAL); if (!libraryHandle) { std::cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: Failed to load library " << soname.toStdString() << ": " << DLERROR() << std::endl; continue; } #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: It's a library all right, checking for descriptor" << std::endl; #endif VampGetPluginDescriptorFunction fn = (VampGetPluginDescriptorFunction) DLSYM(libraryHandle, "vampGetPluginDescriptor"); if (!fn) { std::cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: No descriptor function in " << soname.toStdString() << std::endl; if (DLCLOSE(libraryHandle) != 0) { std::cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: Failed to unload library " << soname.toStdString() << std::endl; } continue; } #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: Vamp descriptor found" << std::endl; #endif const VampPluginDescriptor *descriptor = 0; int index = 0; std::map<std::string, int> known; bool ok = true; while ((descriptor = fn(VAMP_API_VERSION, index))) { if (known.find(descriptor->identifier) != known.end()) { std::cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: Plugin library " << soname.toStdString() << " returns the same plugin identifier \"" << descriptor->identifier << "\" at indices " << known[descriptor->identifier] << " and " << index << std::endl; std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: Avoiding this library (obsolete API?)" << std::endl; ok = false; break; } else { known[descriptor->identifier] = index; } ++index; } if (ok) { index = 0; while ((descriptor = fn(VAMP_API_VERSION, index))) { QString id = PluginIdentifier::createIdentifier ("vamp", soname, descriptor->identifier); rv.push_back(id); #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: Found plugin id " << id.toStdString() << " at index " << index << std::endl; #endif ++index; } } if (DLCLOSE(libraryHandle) != 0) { std::cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: Failed to unload library " << soname.toStdString() << std::endl; } } } generateTaxonomy(); return rv; }
void QgsPluginManager::getPluginDescriptions() { QString sharedLibExtension; #ifdef WIN32 sharedLibExtension = "*.dll"; #else sharedLibExtension = "*.so*"; #endif // check all libs in the current ans user plugins directories, and get name and descriptions QSettings settings; QStringList myPathList( lblPluginDir->text() ); QString myPaths = settings.value( "plugins/searchPathsForPlugins", "" ).toString(); if ( !myPaths.isEmpty() ) { myPathList.append( myPaths.split( "|" ) ); } for ( int j = 0; j < myPathList.size(); ++j ) { QString myPluginDir = myPathList.at( j ); QDir pluginDir( myPluginDir, sharedLibExtension, QDir::Name | QDir::IgnoreCase, QDir::Files | QDir::NoSymLinks ); if ( pluginDir.count() == 0 ) { QMessageBox::information( this, tr( "No Plugins" ), tr( "No QGIS plugins found in %1" ).arg( myPluginDir ) ); return; } QgsDebugMsg( "PLUGIN MANAGER:" ); for ( uint i = 0; i < pluginDir.count(); i++ ) { QString lib = QString( "%1/%2" ).arg( myPluginDir ).arg( pluginDir[i] ); #ifdef TESTLIB // This doesn't work on WIN32 and causes problems with plugins // on OS X (the code doesn't cause a problem but including dlfcn.h // renders plugins unloadable) #if !defined(WIN32) && !defined(Q_OS_MACX) // test code to help debug loading problems // This doesn't work on WIN32 and causes problems with plugins // on OS X (the code doesn't cause a problem but including dlfcn.h // renders plugins unloadable) //void *handle = dlopen((const char *) lib, RTLD_LAZY); void *handle = dlopen( lib.toLocal8Bit().data(), RTLD_LAZY | RTLD_GLOBAL ); if ( !handle ) { QgsDebugMsg( "Error in dlopen: " ); QgsDebugMsg( dlerror() ); } else { QgsDebugMsg( "dlopen suceeded for " + lib ); dlclose( handle ); } #endif //#ifndef WIN32 && Q_OS_MACX #endif //#ifdef TESTLIB QgsDebugMsg( "Examining: " + lib ); QLibrary *myLib = new QLibrary( lib ); bool loaded = myLib->load(); if ( !loaded ) { QgsDebugMsg( QString( "Failed to load: %1 (%2)" ).arg( myLib->fileName() ).arg( myLib->errorString() ) ); delete myLib; continue; } QgsDebugMsg( "Loaded library: " + myLib->fileName() ); // Don't bother with libraries that are providers //if(!myLib->resolve("isProvider")) //MH: Replaced to allow for plugins that are linked to providers //type is only used in non-provider plugins if ( !myLib->resolve( "type" ) ) { delete myLib; continue; } // resolve the metadata from plugin name_t *pName = ( name_t * ) cast_to_fptr( myLib->resolve( "name" ) ); description_t *pDesc = ( description_t * ) cast_to_fptr( myLib->resolve( "description" ) ); category_t *pCat = ( category_t * ) cast_to_fptr( myLib->resolve( "category" ) ); version_t *pVersion = ( version_t * ) cast_to_fptr( myLib->resolve( "version" ) ); icon_t* pIcon = ( icon_t * ) cast_to_fptr( myLib->resolve( "icon" ) ); // show the values (or lack of) for each function if ( pName ) { QgsDebugMsg( "Plugin name: " + pName() ); } else { QgsDebugMsg( "Plugin name not returned when queried" ); } if ( pDesc ) { QgsDebugMsg( "Plugin description: " + pDesc() ); } else { QgsDebugMsg( "Plugin description not returned when queried" ); } if ( pCat ) { QgsDebugMsg( "Plugin category: " + pCat() ); } else { QgsDebugMsg( "Plugin category not returned when queried" ); } if ( pVersion ) { QgsDebugMsg( "Plugin version: " + pVersion() ); } else { QgsDebugMsg( "Plugin version not returned when queried" ); } if ( pIcon ) { QgsDebugMsg( "Plugin icon: " + pIcon() ); } if ( !pName || !pDesc || !pVersion ) { QgsDebugMsg( "Failed to get name, description, or type for " + myLib->fileName() ); delete myLib; continue; } QString pluginName = pName(); QString pluginDesc = pDesc(); // if no category defined - use default value QString pluginCat = ( pCat ? pCat() : tr( "Plugins" ) ); QString pluginVersion = pVersion(); QString pluginIconFileName = ( pIcon ? pIcon() : QString() ); QString baseName = QFileInfo( lib ).baseName(); QString myLibraryName = pluginDir[i]; // filtering will be done on the display role so give it name and desription // user wont see this text since we are using a custome delegate QStandardItem * mypDetailItem = new QStandardItem( pluginName + " - " + pluginDesc ); mypDetailItem->setData( myLibraryName, PLUGIN_LIBRARY_ROLE ); mypDetailItem->setData( myPluginDir, PLUGIN_DIRECTORY_ROLE ); mypDetailItem->setData( baseName, PLUGIN_BASE_NAME_ROLE ); //for matching in registry later QgsDetailedItemData myData; myData.setTitle( pluginName ); myData.setDetail( pluginDesc ); myData.setCategory( tr( "Installed in %1 menu/toolbar" ).arg( pluginCat ) ); myData.setRenderAsWidget( false ); myData.setCheckable( true ); myData.setChecked( false ); //start unchecked - we will check it later if needed if ( pluginIconFileName.isEmpty() ) myData.setIcon( QPixmap( QgsApplication::defaultThemePath() + "/plugin.png" ) ); else myData.setIcon( QPixmap( pluginIconFileName ) ); QgsDebugMsg( "Getting an instance of the QgsPluginRegistry" ); // check to see if the plugin is loaded and set the checkbox accordingly QgsPluginRegistry *pRegistry = QgsPluginRegistry::instance(); // get the library using the plugin description if ( !pRegistry->isLoaded( baseName ) ) { QgsDebugMsg( "Couldn't find plugin in the registry" ); } else { QgsDebugMsg( "Found plugin in the registry" ); // TODO: this check shouldn't be necessary, plugin base names must be unique if ( pRegistry->library( baseName ) == myLib->fileName() ) { // set the checkbox myData.setChecked( true ); } } QVariant myVariant = qVariantFromValue( myData ); mypDetailItem->setData( myVariant, PLUGIN_DATA_ROLE ); // Add items to model mModelPlugins->appendRow( mypDetailItem ); delete myLib; } } }
Ogre::Root* OgreSetup::createOgreSystem() { ConfigService& configSrv(EmberServices::getSingleton().getConfigService()); if (configSrv.getPrefix() != "") { //We need to set the current directory to the prefix before trying to load Ogre. //The reason for this is that Ogre loads a lot of dynamic modules, and in some build configuration //(like AppImage) the lookup path for some of these are based on the installation directory of Ember. if (chdir(configSrv.getPrefix().c_str())) { S_LOG_WARNING("Failed to change to the prefix directory '" << configSrv.getPrefix() << "'. Ogre loading might fail."); } } std::string pluginExtension = ".so"; mRoot = new Ogre::Root("", "ogre.cfg", ""); //we will try to load the plugins from series of different location, with the hope of getting at least one right std::vector<std::string> pluginLocations; if (configSrv.itemExists("ogre", "plugins")) { std::string plugins(configSrv.getValue("ogre", "plugins")); //if it's defined in the config, use that location first if (configSrv.itemExists("ogre", "plugindir")) { std::string pluginDir(configSrv.getValue("ogre", "plugindir")); pluginLocations.push_back(pluginDir); } #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 pluginExtension = ".dll"; pluginLocations.push_back("."); //on windows we'll bundle the dll files in the same directory as the executable #elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX pluginExtension = ".so"; std::string pluginDir = configSrv.getPrefix(); pluginDir += "/lib/OGRE"; pluginLocations.push_back(pluginDir); #ifdef ENABLE_BINRELOC //binreloc might be used char* br_libdir = br_find_lib_dir(br_strcat(PREFIX, "/lib")); std::string libDir(br_libdir); free(br_libdir); pluginLocations.push_back(libDir + "/OGRE"); #endif #ifdef OGRE_PLUGINDIR //also try with the plugindir defined for Ogre pluginLocations.push_back(OGRE_PLUGINDIR); #endif //enter the usual locations if Ogre is installed system wide, with local installations taking precedence pluginLocations.push_back("/usr/local/lib/OGRE"); pluginLocations.push_back("/usr/lib/OGRE"); #elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE // On Mac, plugins are found in Resources in the Main (Application) bundle, then in the Ogre framework bundle pluginExtension = ""; std::string pluginDir = configSrv.getSharedDataDirectory(); pluginLocations.push_back(pluginDir); pluginDir += "/../Plugins"; pluginLocations.push_back(pluginDir); pluginLocations.push_back(""); #endif Tokeniser tokeniser(plugins, ","); std::string token = tokeniser.nextToken(); while (token != "") { std::string pluginPath; bool pluginLoaded = false; for (std::vector<std::string>::iterator I = pluginLocations.begin(); I != pluginLocations.end(); ++I) { pluginPath = (*I) + "/" + token + pluginExtension; S_LOG_INFO("Trying to load the plugin '" << pluginPath << "'."); try { mRoot->loadPlugin(pluginPath); pluginLoaded = true; break; } catch (...) { pluginPath = (*I) + "/" + token + "_d" + pluginExtension; S_LOG_INFO("Trying to load the plugin '" << pluginPath << "'."); try { mRoot->loadPlugin(pluginPath); pluginLoaded = true; break; } catch (...) { } } } if (pluginLoaded) { S_LOG_INFO("Successfully loaded the plugin '" << token << "' from '" << pluginPath << "'."); } else { S_LOG_FAILURE("Failed to load the plugin '" << token << "'!"); } token = tokeniser.nextToken(); } } if (chdir(configSrv.getEmberDataDirectory().c_str())) { S_LOG_WARNING("Failed to change to the data directory '" << configSrv.getEmberDataDirectory() << "'."); } return mRoot; }
void CPluginManager::loadPlugins() { #ifdef Q_OS_WIN const char* pluginPath = "../plugins/"; #else const char* pluginPath = "plugins/"; #endif #if defined(Q_OS_MAC) || defined(Q_OS_MACX) || defined(Q_OS_MAC64) struct stat stFileInfo; QString filePath = pluginPath; if (!stat((filePath = QString(pluginPath)).toLatin1().constData(), &stFileInfo)) { // the script is in a plugin folder in the same folder as a distributed application } else if (!stat((filePath = QString("nesicide.app/Contents/Resources/")+pluginPath).toLatin1().constData(), &stFileInfo)) { // normal path to scripts when dubbel clicking on an application } else if (!stat((filePath = QString("../../../")+pluginPath).toLatin1().constData(), &stFileInfo)) { // the script is in a plugin folder in the same folder as an application that's debugged with Qt } else if (!stat((filePath = QString("../Resources/")+pluginPath).toLatin1().constData(), &stFileInfo)) { // path to find scripts when using the Qt debuger } else { // no more place to look for the script, bailing out... lua will do the error handling though } QDir pluginDir(filePath.toLatin1().constData()); #else QDir pluginDir(pluginPath); #endif QStringList pluginFiles; QDomElement pluginDocElement; int i; generalTextLogger->write ( "<strong>Loading plugins...</strong>" ); pluginFiles = pluginDir.entryList(QStringList("*.plugin"),QDir::Files); for ( i = 0; i < pluginFiles.size(); i++ ) { generalTextLogger->write ( pluginFiles[i] + ": " ); QFile pluginFile ( pluginDir.absoluteFilePath(pluginFiles[i]) ); pluginFile.open(QIODevice::ReadOnly|QIODevice::Text); if ( pluginFile.isOpen() ) { QDomDocument* plugin = new QDomDocument(); //QDomNode logicNode; //QDomElement logicElement; plugin->setContent(&pluginFile); plugins.insert(pluginFiles[i],plugin); pluginDocElement = plugin->documentElement(); generalTextLogger->write ( " caption: " + pluginDocElement.attribute("caption") ); generalTextLogger->write ( " author: " + pluginDocElement.attribute("author") ); generalTextLogger->write ( " version: " + pluginDocElement.attribute("version") ); QDomNodeList logicNodeList = pluginDocElement.elementsByTagName("logic"); if (!logicNodeList.isEmpty()) { // only read the first logic node QDomNode logicNode = logicNodeList.item(0); QDomNode logicScript = logicNode.firstChild(); if (logicScript.nodeType() == QDomNode::CDATASectionNode) { QString luascript = logicScript.toText().data(); if (luascript.length() != 0) { generalTextLogger->write ( " loading logic" ); if (report(globalLuaInstance, luaL_dostring(globalLuaInstance, luascript.toLatin1()))) { continue; // ignore rest of the plugin and continue with next one if we couldn't load the script } } } QString onLoad = logicNode.toElement().attribute("onLoad"); if (!onLoad.isEmpty()) { //onLoad generalTextLogger->write ( " call onLoadFunc \"" + onLoad + "\""); lua_getglobal(globalLuaInstance, onLoad.toLatin1()); if (report(globalLuaInstance, lua_pcall(globalLuaInstance, 0, LUA_MULTRET, 0))) { continue; } } } pluginFile.close(); } generalTextLogger->write ( "done." ); } generalTextLogger->write ( "<strong>Done loading plugins.</strong>" ); }