void WebProcessProxy::sendDidGetPlugins(uint64_t requestID, PassOwnPtr<Vector<PluginInfo> > pluginInfos) { ASSERT(isMainThread()); OwnPtr<Vector<PluginInfo> > plugins(pluginInfos); #if PLATFORM(MAC) // Add built-in PDF last, so that it's not used when a real plug-in is installed. // NOTE: This has to be done on the main thread as it calls localizedString(). if (!m_context->omitPDFSupport()) plugins->append(BuiltInPDFView::pluginInfo()); #endif send(Messages::WebProcess::DidGetPlugins(requestID, *plugins), 0); }
PendingLoggerEntitiesImpl::PendingLoggerEntitiesImpl(const Tp::AccountPtr &account, QObject* parent): PendingLoggerEntities(account, parent) { if (plugins().isEmpty()) { emitFinished(); return; } Q_FOREACH (KTp::AbstractLoggerPlugin *plugin, plugins()) { if (!plugin->handlesAccount(account)) { continue; } PendingLoggerOperation *op = plugin->queryEntities(account); if (!op) { continue; } connect(op, SIGNAL(finished(KTp::PendingLoggerOperation*)), this, SLOT(operationFinished(KTp::PendingLoggerOperation*))); mRunningOps << op; } }
/****************************************************************************** * Returns all installed plugin classes derived from the given type. ******************************************************************************/ QVector<OvitoObjectType*> PluginManager::listClasses(const OvitoObjectType& superClass, bool skipAbstract) { QVector<OvitoObjectType*> result; for(Plugin* plugin : plugins()) { for(OvitoObjectType* clazz : plugin->classes()) { if(!skipAbstract || !clazz->isAbstract()) { if(clazz->isDerivedFrom(superClass)) result.push_back(clazz); } } } return result; }
void BackendSelection::load() { // NOTE: for phonon5 this should move into the library in some form. m_backends.clear(); // Read already configured order. QList<QString> iidPreference; QSettings settings("kde.org", "libphonon"); const int size = settings.beginReadArray("Backends"); qDebug() << settings.fileName(); for (int i = 0; i < size; ++i) { settings.setArrayIndex(i); iidPreference.append(settings.value("iid").toString()); } settings.endArray(); const QLatin1Literal suffix("/" PHONON_LIB_SONAME "_backend/"); const QStringList paths = QCoreApplication::libraryPaths(); qDebug() << "libpaths" << paths; QList<struct BackendDescriptor> backendList; foreach (const QString &path, paths) { const QString libPath = path + suffix; const QDir dir(libPath); if (!dir.exists()) { qDebug() << Q_FUNC_INFO << dir.absolutePath() << "does not exist"; continue; } QStringList plugins(dir.entryList(QDir::Files)); foreach (const QString &plugin, plugins) { BackendDescriptor bd = BackendDescriptor(libPath + plugin); if (bd.isValid) { int preference = iidPreference.indexOf(bd.iid); if (preference != -1) bd.preference = preference; backendList.append(bd); } } qSort(backendList); }
LoadEffectFlags AbstractEffectLoader::readConfig(const QString &effectName, bool defaultValue) const { Q_ASSERT(m_config); KConfigGroup plugins(m_config, QStringLiteral("Plugins")); const QString key = effectName + QStringLiteral("Enabled"); // do we have a key for the effect? if (plugins.hasKey(key)) { // we have a key in the config, so read the enabled state const bool load = plugins.readEntry(key, defaultValue); return load ? LoadEffectFlags(LoadEffectFlag::Load) : LoadEffectFlags(); } // we don't have a key, so we just use the enabled by default value if (defaultValue) { return LoadEffectFlag::Load | LoadEffectFlag::CheckDefaultFunction; } return LoadEffectFlags(); }
// Plugin-property command methods. bool qtractorPluginPropertyCommand::redo (void) { qtractorPlugin *pPlugin = plugins().first(); if (pPlugin == NULL) return false; // Save the current toggled state alright... QVariant value; #ifdef CONFIG_LV2_PATCH qtractorPluginType *pType = pPlugin->type(); qtractorLv2Plugin *pLv2Plugin = NULL; qtractorLv2Plugin::Property *pLv2Prop = NULL; if (pType && pType->typeHint() == qtractorPluginType::Lv2) pLv2Plugin = static_cast<qtractorLv2Plugin *> (pPlugin); if (pLv2Plugin) { const LV2_URID key = m_iProperty; const char *pszKey = qtractorLv2Plugin::lv2_urid_unmap(key); if (pszKey) { pLv2Prop = pLv2Plugin->lv2_properties().value(pszKey, NULL); if (pLv2Prop) { value = pLv2Prop->value(); pLv2Prop->setValue(m_value); pLv2Plugin->lv2_property_update(key); } } } #endif m_value = value; // Update the form, showing it up as necessary... pPlugin->updateFormDirtyCount(); // Update any GUI editor... // pPlugin->idleEditor(); // FIXME: Might no work the first time... pPlugin->refreshForm(); return true; }
DlgPrefPlaylist::DlgPrefPlaylist(QWidget * parent, ConfigObject<ConfigValue> * config) : QWidget(parent), m_pconfig(config) { setupUi(this); slotUpdate(); checkbox_ID3_sync->setVisible(false); /* m_pPluginDownloader = new PluginDownloader(this); //Disable the M4A button if the plugin is present on disk. setupM4AButton(); //Disable M4A Button after download completes successfully. connect(m_pPluginDownloader, SIGNAL(downloadFinished()), this, SLOT(slotM4ADownloadFinished())); connect(m_pPluginDownloader, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(slotM4ADownloadProgress(qint64, qint64))); */ connect(PushButtonBrowsePlaylist, SIGNAL(clicked()), this, SLOT(slotBrowseDir())); //connect(pushButtonM4A, SIGNAL(clicked()), this, SLOT(slotM4ACheck())); connect(pushButtonExtraPlugins, SIGNAL(clicked()), this, SLOT(slotExtraPlugins())); bool enablePromoGroupbox = false; #ifdef __PROMO__ enablePromoGroupbox = PromoTracksFeature::isSupported(config); #endif if (!enablePromoGroupbox) { groupBoxBundledSongs->hide(); } // plugins are loaded in src/main.cpp way early in boot so this is safe // here, doesn't need done at every slotUpdate QStringList plugins(SoundSourceProxy::supportedFileExtensionsByPlugins()); if (plugins.length() > 0) { pluginsLabel->setText(plugins.join(", ")); } }
DlgPrefPlaylist::DlgPrefPlaylist(QWidget * parent, ConfigObject<ConfigValue> * config) : QWidget(parent), m_pconfig(config) { setupUi(this); slotUpdate(); checkbox_ID3_sync->setVisible(false); connect(PushButtonBrowsePlaylist, SIGNAL(clicked()), this, SLOT(slotBrowseDir())); //connect(pushButtonM4A, SIGNAL(clicked()), this, SLOT(slotM4ACheck())); connect(pushButtonExtraPlugins, SIGNAL(clicked()), this, SLOT(slotExtraPlugins())); // plugins are loaded in src/main.cpp way early in boot so this is safe // here, doesn't need done at every slotUpdate QStringList plugins(SoundSourceProxy::supportedFileExtensionsByPlugins()); if (plugins.length() > 0) { pluginsLabel->setText(plugins.join(", ")); } }
// Plugin-move command methods. bool qtractorMovePluginCommand::redo (void) { qtractorPlugin *pPlugin = plugins().first(); if (pPlugin == NULL) return false; if (m_pPluginList == NULL) return false; qtractorSession *pSession = qtractorSession::getInstance(); if (pSession == NULL) return false; // pSession->lock(); // Save the previous track alright... qtractorPlugin *pNextPlugin = pPlugin->next(); qtractorPluginList *pPluginList = pPlugin->list(); // Move it... m_pPluginList->movePlugin(pPlugin, nextPlugin()); // Swap it nice, finally. m_pPluginList = pPluginList; setNextPlugin(pNextPlugin); // pSession->unlock(); qtractorMainForm *pMainForm = qtractorMainForm::getInstance(); if (pMainForm) { qtractorTracks *pTracks = pMainForm->tracks(); if (pTracks) { pTracks->clearSelect(); pTracks->updateTrackList(); pTracks->updateTrackView(); } } return true; }
Q_DECL_EXPORT int main(int argc, char *argv[]) { QApplication app(argc, argv); app.setOrganizationName("MusiKloud2"); app.setApplicationName("MusiKloud2"); app.setApplicationVersion(VERSION_NUMBER); app.setWindowIcon(QIcon::fromTheme("musikloud2")); const QStringList args = app.arguments(); const int verbosity = args.indexOf("-v") + 1; if ((verbosity > 1) && (verbosity < args.size())) { Logger::setVerbosity(qMax(1, args.at(verbosity).toInt())); } else { Logger::setFileName(Settings::loggerFileName()); Logger::setVerbosity(Settings::loggerVerbosity()); } QScopedPointer<AudioPlayer> player(AudioPlayer::instance()); QScopedPointer<Settings> settings(Settings::instance()); QScopedPointer<PluginManager> plugins(PluginManager::instance()); QScopedPointer<SoundCloud> soundcloud(SoundCloud::instance()); QScopedPointer<Transfers> transfers(Transfers::instance()); initDatabase(); Settings::setNetworkProxy(); SoundCloud::init(); plugins.data()->load(); transfers.data()->restore(); if (Settings::restorePlaybackQueueOnStartup()) { player.data()->restoreQueue(); } MainWindow window; window.show(); return app.exec(); }
// Plugin-preset command methods. bool qtractorPluginProgramCommand::redo (void) { qtractorPlugin *pPlugin = plugins().first(); if (pPlugin == NULL) return false; // Save the current toggled state alright... qtractorPluginList::MidiProgramSubject *pMidiProgramSubject = (pPlugin->list())->midiProgramSubject(); if (pMidiProgramSubject == NULL) return false; const int iBank = pMidiProgramSubject->bank(); const int iProg = pMidiProgramSubject->prog(); pMidiProgramSubject->setProgram(m_iBank, m_iProg); m_iBank = iBank; m_iProg = iProg; return true; }
/****************************************************************************** * Searches the plugin directories for installed plugins and * loads their XML manifests. ******************************************************************************/ void PluginManager::registerPlugins() { // Register the built-in classes of the core. _corePlugin = new NativePlugin(QStringLiteral(":/core/Core.json")); registerPlugin(_corePlugin); // Scan the plugin directories for installed plugins. for(QDir pluginDir : pluginDirs()) { if(!pluginDir.exists()) throw Exception(tr("Failed to scan the plugin directory. Path %1 does not exist.").arg(pluginDir.path())); // List all manifest files. pluginDir.setNameFilters(QStringList("*.json")); pluginDir.setFilter(QDir::Files); // Load each manifest file in the plugin directory. for(const QString& file : pluginDir.entryList()) { QString filePath = pluginDir.absoluteFilePath(file); try { Plugin* plugin = new NativePlugin(filePath); registerPlugin(plugin); } catch(Exception& ex) { ex.prependGeneralMessage(tr("Failed to load plugin manifest:\n\n%1").arg(filePath)); ex.showError(); } } } // Load the core plugin. corePlugin()->loadPlugin(); // Load all other plugins too. for(Plugin* plugin : plugins()) { plugin->loadPlugin(); } }
// Plugin-preset command methods. bool qtractorPresetPluginCommand::redo (void) { qtractorPlugin *pPlugin = plugins().first(); if (pPlugin == NULL) return false; // Save the current toggled state alright... const QString sPreset = pPlugin->preset(); const QStringList vlist = pPlugin->valueList(); pPlugin->setPreset(m_sPreset); pPlugin->setValueList(m_vlist); pPlugin->realizeValues(); pPlugin->releaseValues(); // Swap it nice, finally. m_sPreset = sPreset; m_vlist = vlist; // Update the form, showing it up as necessary... pPlugin->refreshForm(); return true; }
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"})); }
// This code is mainly borrowed from QGIS desktop Python plugin initialization bool QgsServerPlugins::initPlugins( QgsServerInterface *interface ) { QString pythonlibName( "qgispython" ); #if defined(Q_OS_MAC) || defined(Q_OS_LINUX) pythonlibName.prepend( QgsApplication::libraryPath() ); #endif #ifdef __MINGW32__ pythonlibName.prepend( "lib" ); #endif QString version = QString( "%1.%2.%3" ).arg( QGis::QGIS_VERSION_INT / 10000 ).arg( QGis::QGIS_VERSION_INT / 100 % 100 ).arg( QGis::QGIS_VERSION_INT % 100 ); QgsDebugMsg( QString( "load library %1 (%2)" ).arg( pythonlibName ).arg( version ) ); QLibrary pythonlib( pythonlibName, version ); // It's necessary to set these two load hints, otherwise Python library won't work correctly // see http://lists.kde.org/?l=pykde&m=117190116820758&w=2 pythonlib.setLoadHints( QLibrary::ResolveAllSymbolsHint | QLibrary::ExportExternalSymbolsHint ); if ( !pythonlib.load() ) { pythonlib.setFileName( pythonlibName ); if ( !pythonlib.load() ) { QgsDebugMsg( QString( "Couldn't load Python support library: %1" ).arg( pythonlib.errorString() ) ); return FALSE; } } QgsDebugMsg( "Python support library loaded successfully." ); typedef QgsPythonUtils*( *inst )(); inst pythonlib_inst = ( inst ) cast_to_fptr( pythonlib.resolve( "instance" ) ); if ( !pythonlib_inst ) { //using stderr on purpose because we want end users to see this [TS] QgsDebugMsg( QString( "Couldn't resolve python support library's instance() symbol." ) ); return FALSE; } QgsDebugMsg( "Python support library's instance() symbol resolved." ); mPythonUtils = pythonlib_inst(); mPythonUtils->initServerPython( interface ); if ( mPythonUtils && mPythonUtils->isEnabled() ) { QgsDebugMsg( "Python support ENABLED :-)" ); } else { QgsDebugMsg( "Python support FAILED :-(" ); return FALSE; } //Init plugins: loads a list of installed plugins and filter them //for "server" metadata QListIterator<QString> plugins( mPythonUtils->pluginList() ); bool atLeastOneEnabled = FALSE; while ( plugins.hasNext() ) { QString pluginName = plugins.next(); QString pluginService = mPythonUtils->getPluginMetadata( pluginName, "server" ); if ( pluginService == "True" ) { if ( mPythonUtils->loadPlugin( pluginName ) ) { if ( mPythonUtils->startServerPlugin( pluginName ) ) { atLeastOneEnabled = TRUE; mServerPlugins.append( pluginName ); QgsMessageLog::logMessage( QString( "Server plugin %1 loaded!" ).arg( pluginName ), "Server", QgsMessageLog::INFO ); } else { QgsMessageLog::logMessage( QString( "Error loading server plugin %1" ).arg( pluginName ), "Server", QgsMessageLog::CRITICAL ); } } else { QgsMessageLog::logMessage( QString( "Error starting server plugin %1" ).arg( pluginName ), "Server", QgsMessageLog::CRITICAL ); } } } return mPythonUtils && mPythonUtils->isEnabled() && atLeastOneEnabled; }
DlgPrefLibrary::DlgPrefLibrary(QWidget * parent, UserSettingsPointer config, Library *pLibrary) : DlgPreferencePage(parent), m_dirListModel(), m_pconfig(config), m_pLibrary(pLibrary), m_baddedDirectory(false), m_iOriginalTrackTableRowHeight(Library::kDefaultRowHeightPx) { setupUi(this); slotUpdate(); checkbox_ID3_sync->setVisible(false); connect(this, SIGNAL(requestAddDir(QString)), m_pLibrary, SLOT(slotRequestAddDir(QString))); connect(this, SIGNAL(requestRemoveDir(QString, Library::RemovalType)), m_pLibrary, SLOT(slotRequestRemoveDir(QString, Library::RemovalType))); connect(this, SIGNAL(requestRelocateDir(QString,QString)), m_pLibrary, SLOT(slotRequestRelocateDir(QString,QString))); connect(PushButtonAddDir, SIGNAL(clicked()), this, SLOT(slotAddDir())); connect(PushButtonRemoveDir, SIGNAL(clicked()), this, SLOT(slotRemoveDir())); connect(PushButtonRelocateDir, SIGNAL(clicked()), this, SLOT(slotRelocateDir())); //connect(pushButtonM4A, SIGNAL(clicked()), this, SLOT(slotM4ACheck())); connect(pushButtonExtraPlugins, SIGNAL(clicked()), this, SLOT(slotExtraPlugins())); // plugins are loaded in src/main.cpp way early in boot so this is safe // here, doesn't need done at every slotUpdate QStringList plugins(SoundSourceProxy::getSupportedFileExtensionsByPlugins()); if (plugins.length() > 0) { pluginsLabel->setText(plugins.join(", ")); } // Set default direction as stored in config file int rowHeight = m_pLibrary->getTrackTableRowHeight(); spinBoxRowHeight->setValue(rowHeight); connect(spinBoxRowHeight, SIGNAL(valueChanged(int)), this, SLOT(slotRowHeightValueChanged(int))); connect(libraryFontButton, SIGNAL(clicked()), this, SLOT(slotSelectFont())); connect(this, SIGNAL(setTrackTableFont(QFont)), m_pLibrary, SLOT(slotSetTrackTableFont(QFont))); connect(this, SIGNAL(setTrackTableRowHeight(int)), m_pLibrary, SLOT(slotSetTrackTableRowHeight(int))); // TODO(XXX) this string should be extracted from the soundsources QString builtInFormatsStr = "Ogg Vorbis, FLAC, WAVe, AIFF"; #if defined(__MAD__) || defined(__APPLE__) builtInFormatsStr += ", MP3"; #endif #ifdef __OPUS__ builtInFormatsStr += ", Opus"; #endif #ifdef _MODPLUG_ builtInFormatsStr += ", ModPlug"; #endif builtInFormats->setText(builtInFormatsStr); }
/** * Setups the game environment and enters * the titlescreen or game loops. */ static int do_gameloop(const std::vector<std::string>& args) { srand(time(nullptr)); commandline_options cmdline_opts = commandline_options(args); game_config::wesnoth_program_dir = filesystem::directory_name(args[0]); int finished = process_command_args(cmdline_opts); if(finished != -1) { return finished; } boost::scoped_ptr<game_launcher> game( new game_launcher(cmdline_opts,args[0].c_str())); const int start_ticks = SDL_GetTicks(); init_locale(); bool res; // do initialize fonts before reading the game config, to have game // config error messages displayed. fonts will be re-initialized later // when the language is read from the game config. res = font::load_font_config(); if(res == false) { std::cerr << "could not initialize fonts\n"; // The most common symptom of a bogus data dir path -- warn the user. warn_early_init_failure(); return 1; } res = game->init_language(); if(res == false) { std::cerr << "could not initialize the language\n"; return 1; } res = game->init_video(); if(res == false) { std::cerr << "could not initialize display\n"; return 1; } res = image::update_from_preferences(); if(res == false) { std::cerr << "could not initialize image preferences\n"; return 1; } if(preferences::joystick_support_enabled()) { res = game->init_joystick(); if(res == false) { std::cerr << "could not initialize joystick\n"; } } check_fpu(); const cursor::manager cursor_manager; cursor::set(cursor::WAIT); #if (defined(_X11) && !defined(__APPLE__)) || defined(_WIN32) SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE); #endif gui2::init(); const gui2::event::tmanager gui_event_manager; game_config_manager config_manager(cmdline_opts, game->video(), game->jump_to_editor()); gui2::tloadscreen::display(game->video(), [&res, &config_manager]() { gui2::tloadscreen::progress("load config"); res = config_manager.init_game_config(game_config_manager::NO_FORCE_RELOAD); if(res == false) { std::cerr << "could not initialize game config\n"; return; } gui2::tloadscreen::progress("init fonts"); res = font::load_font_config(); if(res == false) { std::cerr << "could not re-initialize fonts for the current language\n"; return; } gui2::tloadscreen::progress("refresh addons"); refresh_addon_version_info_cache(); }); if(res == false) { return 1; } config tips_of_day; LOG_CONFIG << "time elapsed: "<< (SDL_GetTicks() - start_ticks) << " ms\n"; plugins_manager plugins_man(new application_lua_kernel(&game->video())); plugins_context::Reg const callbacks[] = { { "play_multiplayer", std::bind(&game_launcher::play_multiplayer, game.get())}, }; plugins_context::aReg const accessors[] = { { "command_line", std::bind(&commandline_options::to_config, &cmdline_opts)}, }; plugins_context plugins("titlescreen", callbacks, accessors); plugins.set_callback("exit", std::bind(&safe_exit, std::bind(get_int, std::placeholders::_1, "code", 0)), false); for (;;) { // reset the TC, since a game can modify it, and it may be used // by images in add-ons or campaigns dialogs image::set_team_colors(); statistics::fresh_stats(); if (!game->is_loading()) { const config &cfg = config_manager.game_config().child("titlescreen_music"); if (cfg) { sound::play_music_repeatedly(game_config::title_music); for (const config &i : cfg.child_range("music")) { sound::play_music_config(i); } sound::commit_music_changes(); } else { sound::empty_playlist(); sound::stop_music(); } } handle_lua_script_args(&*game,cmdline_opts); plugins.play_slice(); plugins.play_slice(); if(cmdline_opts.unit_test) { if(cmdline_opts.timeout) { std::cerr << "The wesnoth built-in timeout feature has been removed.\n" << std::endl; std::cerr << "Please use a platform-specific script which will kill the overtime process instead.\n" << std::endl; std::cerr << "For examples in bash, or in windows cmd, see the forums, or the wesnoth repository." << std::endl; std::cerr << "The bash script is called `run_wml_tests`, the windows script is part of the VC project.\n" << std::endl; } int worker_result = game->unit_test(); std::cerr << ((worker_result == 0) ? "PASS TEST " : "FAIL TEST ") << ((worker_result == 3) ? "(INVALID REPLAY)" : "") << ((worker_result == 4) ? "(ERRORED REPLAY)" : "") << ": "<<*cmdline_opts.unit_test << std::endl; return worker_result; } if(game->play_test() == false) { return 0; } if(game->play_screenshot_mode() == false) { return 0; } if(game->play_render_image_mode() == false) { return 0; } //Start directly a campaign if(game->goto_campaign() == false){ if (game->jump_to_campaign_id().empty()) continue; //Go to main menu else return 1; //we got an error starting the campaign from command line } //Start directly a multiplayer //Eventually with a specified server if(game->goto_multiplayer() == false){ continue; //Go to main menu } //Start directly a commandline multiplayer game if(game->play_multiplayer_commandline() == false) { return 0; } if (game->goto_editor() == false) { return 0; } gui2::ttitle_screen::tresult res = game->is_loading() ? gui2::ttitle_screen::LOAD_GAME : gui2::ttitle_screen::NOTHING; preferences::load_hotkeys(); const font::floating_label_context label_manager; cursor::set(cursor::NORMAL); if(res == gui2::ttitle_screen::NOTHING) { gui2::ttitle_screen dlg; dlg.show(game->video()); res = static_cast<gui2::ttitle_screen::tresult>(dlg.get_retval()); } game_launcher::RELOAD_GAME_DATA should_reload = game_launcher::RELOAD_DATA; if(res == gui2::ttitle_screen::QUIT_GAME) { LOG_GENERAL << "quitting game...\n"; return 0; } else if(res == gui2::ttitle_screen::LOAD_GAME) { if(game->load_game() == false) { game->clear_loaded_game(); res = gui2::ttitle_screen::NOTHING; continue; } should_reload = game_launcher::NO_RELOAD_DATA; } else if(res == gui2::ttitle_screen::TUTORIAL) { game->set_tutorial(); } else if(res == gui2::ttitle_screen::NEW_CAMPAIGN) { if(game->new_campaign() == false) { continue; } should_reload = game_launcher::NO_RELOAD_DATA; } else if(res == gui2::ttitle_screen::MULTIPLAYER) { game_config::debug = game_config::mp_debug; if(game->play_multiplayer() == false) { continue; } } else if(res == gui2::ttitle_screen::CHANGE_LANGUAGE) { try { if (game->change_language()) { tips_of_day.clear(); t_string::reset_translations(); image::flush_cache(); } } catch ( std::runtime_error & e ) { gui2::show_error_message(game->video(), e.what()); } continue; } else if(res == gui2::ttitle_screen::EDIT_PREFERENCES) { game->show_preferences(); continue; } else if(res == gui2::ttitle_screen::SHOW_ABOUT) { about::show_about(game->video()); continue; } else if(res == gui2::ttitle_screen::SHOW_HELP) { help::help_manager help_manager(&config_manager.game_config()); help::show_help(game->video()); continue; } else if(res == gui2::ttitle_screen::GET_ADDONS) { // NOTE: we need the help_manager to get access to the Add-ons // section in the game help! help::help_manager help_manager(&config_manager.game_config()); if(manage_addons(game->video())) { config_manager.reload_changed_game_config(); } continue; } else if(res == gui2::ttitle_screen::CORES) { int current = 0; std::vector<config> cores; for (const config& core : game_config_manager::get()->game_config().child_range("core")) { cores.push_back(core); if (core["id"] == preferences::core_id()) current = cores.size() -1; } gui2::tcore_selection core_dlg(cores, current); if (core_dlg.show(game->video())) { int core_index = core_dlg.get_choice(); const std::string& core_id = cores[core_index]["id"]; preferences::set_core_id(core_id); config_manager.reload_changed_game_config(); } continue; } else if(res == gui2::ttitle_screen::RELOAD_GAME_DATA) { gui2::tloadscreen::display(game->video(), [&config_manager]() { config_manager.reload_changed_game_config(); image::flush_cache(); }); continue; } else if(res == gui2::ttitle_screen::START_MAP_EDITOR) { game->start_editor(); continue; } game->launch_game(should_reload); } }
bool WsModulesLoader::load() { Json::Value root; Json::Reader reader; std::ifstream plugins(GlobalConfig::PluginsPropertiesPath.c_str(), std::ifstream::binary); bool bOk = reader.parse(plugins, root, false); if ( !bOk ) { LOG(DEBUG) << reader.getFormatedErrorMessages(); return false; } //Json::Value module = modules[iMod]; // crash Json::Value modules = root["modules"]; Json::Value::Members mbrs = modules.getMemberNames(); bool bDebug = false; #if GDDEBUG == 1 bDebug = true; #endif for (int iMod = 0; iMod < mbrs.size(); ++iMod) { LOG(DEBUG) << "WsModulesLoader::load Loading module " << mbrs[iMod] << " debug mode = " << bDebug; Json::Value module = modules[mbrs[iMod]]; Json::Value::Members attributes = module.getMemberNames(); for (int iAtt = 0; iAtt < attributes.size(); ++iAtt) { if ( attributes[iAtt] == "soName" ) { std::string soName = module.get(attributes[iAtt], "").asString(); if ( bDebug ) boost::replace_first(soName, ".so", "d.so"); // Important not RTLD_NOW because a derived module can also load a shared object // and in this step is make in the dynlib initialization process (_init, _fini Ctor/Dtor) void* hndl = dlopen(soName.c_str(), RTLD_LAZY); if ( hndl == NULL ) { LOG(ERROR) << "WsModulesLoader::load dlopen error soName = " << soName << " error = " << dlerror(); continue; } LOG(DEBUG) << "WsModulesLoader::load Loading module " << soName; pf_wsModule func = (pf_wsModule) dlsym(hndl, "buildModule"); WsModule* pModule = func(); WsModuleLoader* ml = new WsModuleLoader(); ml->dlfcnHandler = hndl; ml->module = pModule; m_vModules.push_back(ml); pModule->setSoName(soName); // std::string p = WApplication::instance()->appRoot() + WApplication::instance()->internalPath(); // pModule->setSysPath(p); for (int iAtt2 = 0; iAtt2 < attributes.size(); ++iAtt2) { if ( attributes[iAtt2] == "moduleName" ) { std::string moduleName = module.get(attributes[iAtt2], "").asString(); pModule->setModuleName(moduleName); } if ( attributes[iAtt2] == "fileName" ) { std::string fileName = module.get(attributes[iAtt2], "").asString(); pModule->setFileName(fileName); } if ( attributes[iAtt2] == "extension" || attributes[iAtt2] == "extensions" ) { std::string extensions = module.get(attributes[iAtt2], "").asString(); pModule->setExtensions(extensions); } if ( attributes[iAtt2] == "prefix" ) { std::string prefix = module.get(attributes[iAtt2], "").asString(); pModule->setPrefix(prefix); } if ( attributes[iAtt2] == "hideImages" ) { std::string hideImages = module.get(attributes[iAtt2], "false").asString(); if ( hideImages == "true" ) pModule->setHideImages(true); } if ( attributes[iAtt2] == "options" ) { Json::Value options = module[attributes[iAtt2]]; Json::Value::Members optAttrs = options.getMemberNames(); for (int iOpt = 0; iOpt < optAttrs.size(); ++iOpt) { Json::Value val = options[optAttrs[iOpt]]; LOG(DEBUG) << "WsModuleLoader::load options " << optAttrs[iOpt] << " value = " << val.asString(); if ( val.type() == Json::nullValue ) continue; if ( val.type() == Json::intValue ) pModule->setOption(optAttrs[iOpt], val.asInt()); if ( val.type() == Json::uintValue ) pModule->setOption(optAttrs[iOpt], val.asUInt()); if ( val.type() == Json::realValue ) pModule->setOption(optAttrs[iOpt], val.asDouble()); if ( val.type() == Json::stringValue ) pModule->setOption(optAttrs[iOpt], val.asString()); if ( val.type() == Json::booleanValue ) pModule->setOption(optAttrs[iOpt], val.asBool()); } } } if ( module["loadOnStartup"] != Json::Value::null && module["loadOnStartup"].asBool()) { LOG(DEBUG) << "WsModuleLoader::load running Module " << pModule->moduleName(); //fprintf(stderr, "WsModuleLoader :: running Module %s\n",pModule->moduleName().c_str()); pModule->createContents(); pModule->setLoaded(); } else { LOG(DEBUG) << "WsModuleLoader::load running Module else clause " << module["loadOnStartup"].asString(); //fprintf(stderr, "WsModuleLoader ::else clause%s\n", module["loadOnStartup"].asString().c_str() ); } } } } return true; }
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; }
int main() { typedef rmn::resource_node< rmn::ResourceDataAny<rmn::ResourceSyncPolicyNone> > resource_node; typedef resource_node::node_ptr resource_node_ptr; resource_node_ptr root(new resource_node); root->set_name("/"); // std::cerr << root; { // create some nodes... resource_node_ptr app(new resource_node); app->set_name("app"); root->add_child(app); resource_node_ptr sys(new resource_node); sys->set_name("sys"); root->add_child(sys); resource_node_ptr plugins(new resource_node); plugins->set_name("plugins"); app->add_child(plugins); plugins->create_child("plug1"); plugins->create_child("plug2", std::string("plug2_data")); plugins->create_child("plug3", 6); plugins->build_nodes("video/gui"); plugins->build_nodes("/app/video2/gui"); // should be denied plugins->build_nodes("/app/video3/gui", true); // should be allowed, side-construction is enabled. plugins->create_child("plug4", "plug4_data"); // this will store it as std::string! // std::cerr << "Data: " << plugins->get_child_node("plug3")->get_data<int>(); // std::cerr << root; } std::cerr << "--- begin dump root:\n"; std::cerr << root; std::cerr << "--- end dump root\n"; std::cerr << "--- build path test: -----------------\n"; std::cerr << "root->build_nodes(\"/app/video/gui\"); - 2 times;" << "\n"; root->build_nodes("/app/video/gui"); root->build_nodes("/app/video/gui"); std::cerr << "--- /app/fingor/gui, /app/fingor/state, /app/biocalc/gui, /sys/conf/video ... " << "\n"; root->build_nodes("/app/fingor/gui"); root->build_nodes("/app/fingor/state"); root->build_nodes("/app/biocalc/gui"); root->build_nodes("sys/conf/video"); root->build_nodes("sys/conf/fingor"); root->build_nodes("/sys/conf/biocalc"); std::cerr << "--- root dump:" << "\n"; std::cerr << root; /* std::cerr << "--- get_path test: -------\n"; std::cerr << "sys->get_path():\t" ; std::cerr << sys->get_path() << "\n"; std::cerr << "plugins->get_path():\t" ; std::cerr << plugins->get_path() << "\n"; std::cerr << "plug2->get_path():\t" ; std::cerr << plug2->get_path() << "\n"; */ std::cerr << "--- find_node test: -------\n"; resource_node_ptr n; std::cerr << ((n = root->find_node("/sys/conf/fingor")) ? n->get_name() : "NULL") << "\n"; std::cerr << ((n = root->find_node("/sys/conf/fingor/nonexistent")) ? n->get_name() : "NULL") << "\n"; std::cerr << ((n = root->find_node("state")) ? n->get_name() : "NULL") << "\n"; std::cerr << ((n = root->find_node("sys")) ? n->get_name() : "NULL") << "\n"; std::cerr << ((n = root->find_node("/state")) ? n->get_name() : "NULL") << "\n"; std::cerr << ((n = root->find_node("video/")) ? n->get_name() : "NULL") << "\n"; /* std::cerr << "--- root dump:" << "\n"; std::cerr << root; */ // this throws exception // root->get_data<int>(); // empty root->find_node("/app/plugins/plug3")->get_data<std::string>(); // int -> string return EXIT_SUCCESS; }
bool FactoryPrivate::createBackend() { #ifndef QT_NO_LIBRARY Q_ASSERT(m_backendObject == 0); #ifndef QT_NO_PHONON_PLATFORMPLUGIN PlatformPlugin *f = globalFactory->platformPlugin(); if (f) { m_backendObject = f->createBackend(); } #endif //QT_NO_PHONON_PLATFORMPLUGIN if (!m_backendObject) { ensureLibraryPathSet(); // could not load a backend through the platform plugin. Falling back to the default // (finding the first loadable backend). const QLatin1String suffix("/phonon_backend/"); const QStringList paths = QCoreApplication::libraryPaths(); for (int i = 0; i < paths.count(); ++i) { const QString libPath = paths.at(i) + suffix; const QDir dir(libPath); if (!dir.exists()) { pDebug() << Q_FUNC_INFO << dir.absolutePath() << "does not exist"; continue; } QStringList plugins(dir.entryList(QDir::Files)); #ifdef Q_OS_SYMBIAN /* On Symbian OS we might have two plugins, one which uses Symbian * MMF framework("mmf"), and one which uses Real Networks's * Helix("hxphonon"). We prefer the latter because it's more * sophisticated, so we make sure the Helix backend is attempted * to be loaded first, and the MMF backend is used for backup. */ { const int helix = plugins.indexOf(QLatin1String("hxphonon")); if (helix != -1) plugins.move(helix, 0); } #endif const QStringList files = dir.entryList(QDir::Files); for (int i = 0; i < files.count(); ++i) { QPluginLoader pluginLoader(libPath + files.at(i)); if (!pluginLoader.load()) { pDebug() << Q_FUNC_INFO << " load failed:" << pluginLoader.errorString(); continue; } pDebug() << pluginLoader.instance(); m_backendObject = pluginLoader.instance(); if (m_backendObject) { break; } // no backend found, don't leave an unused plugin in memory pluginLoader.unload(); } if (m_backendObject) { break; } } if (!m_backendObject) { pWarning() << Q_FUNC_INFO << "phonon backend plugin could not be loaded"; return false; } } connect(m_backendObject, SIGNAL(objectDescriptionChanged(ObjectDescriptionType)), SLOT(objectDescriptionChanged(ObjectDescriptionType))); return true; #else //QT_NO_LIBRARY pWarning() << Q_FUNC_INFO << "Trying to use Phonon with QT_NO_LIBRARY defined. " "That is currently not supported"; return false; #endif }
/** * Register a transcoding plug-in at this engine * * @param plugin the plug-in descriptor */ void trans_register_plugin(TransPlugin *plugin) { llist_add(plugins(), plugin); plugin->init(); }
/** * Setups the game environment and enters * the titlescreen or game loops. */ static int do_gameloop(const std::vector<std::string>& args) { srand(time(nullptr)); commandline_options cmdline_opts = commandline_options(args); game_config::wesnoth_program_dir = filesystem::directory_name(args[0]); int finished = process_command_args(cmdline_opts); if(finished != -1) { #ifdef _WIN32 if(lg::using_own_console()) { std::cerr << "Press enter to continue..." << std::endl; std::cin.get(); } #endif return finished; } const std::unique_ptr<game_launcher> game(new game_launcher(cmdline_opts, args[0].c_str())); const int start_ticks = SDL_GetTicks(); init_locale(); bool res; // Do initialize fonts before reading the game config, to have game // config error messages displayed. fonts will be re-initialized later // when the language is read from the game config. res = font::load_font_config(); if(res == false) { std::cerr << "could not initialize fonts\n"; // The most common symptom of a bogus data dir path -- warn the user. warn_early_init_failure(); return 1; } res = game->init_language(); if(res == false) { std::cerr << "could not initialize the language\n"; return 1; } res = game->init_video(); if(res == false) { std::cerr << "could not initialize display\n"; return 1; } res = image::update_from_preferences(); if(res == false) { std::cerr << "could not initialize image preferences\n"; return 1; } if(preferences::joystick_support_enabled()) { res = game->init_joystick(); if(res == false) { std::cerr << "could not initialize joystick\n"; } } check_fpu(); const cursor::manager cursor_manager; cursor::set(cursor::WAIT); #if(defined(_X11) && !defined(__APPLE__)) || defined(_WIN32) SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE); #endif gui2::init(); const gui2::event::manager gui_event_manager; game_config_manager config_manager(cmdline_opts, game->jump_to_editor()); gui2::dialogs::loading_screen::display([&res, &config_manager]() { gui2::dialogs::loading_screen::progress(loading_stage::load_config); res = config_manager.init_game_config(game_config_manager::NO_FORCE_RELOAD); if(res == false) { std::cerr << "could not initialize game config\n"; return; } gui2::dialogs::loading_screen::progress(loading_stage::init_fonts); res = font::load_font_config(); if(res == false) { std::cerr << "could not re-initialize fonts for the current language\n"; return; } gui2::dialogs::loading_screen::progress(loading_stage::refresh_addons); refresh_addon_version_info_cache(); }); if(res == false) { return 1; } LOG_CONFIG << "time elapsed: " << (SDL_GetTicks() - start_ticks) << " ms\n"; plugins_manager plugins_man(new application_lua_kernel); plugins_context::Reg const callbacks[] { {"play_multiplayer", std::bind(&game_launcher::play_multiplayer, game.get(), game_launcher::MP_CONNECT)}, }; plugins_context::aReg const accessors[] { {"command_line", std::bind(&commandline_options::to_config, &cmdline_opts)}, }; plugins_context plugins("titlescreen", callbacks, accessors); plugins.set_callback("exit", [](const config& cfg) { safe_exit(cfg["code"].to_int(0)); }, false); for(;;) { // reset the TC, since a game can modify it, and it may be used // by images in add-ons or campaigns dialogs image::set_team_colors(); statistics::fresh_stats(); if(!game->is_loading()) { const config& cfg = config_manager.game_config().child("titlescreen_music"); if(cfg) { sound::play_music_repeatedly(game_config::title_music); for(const config& i : cfg.child_range("music")) { sound::play_music_config(i); } sound::commit_music_changes(); } else { sound::empty_playlist(); sound::stop_music(); } } handle_lua_script_args(&*game, cmdline_opts); plugins.play_slice(); plugins.play_slice(); if(cmdline_opts.unit_test) { if(cmdline_opts.timeout) { std::cerr << "The wesnoth built-in timeout feature has been removed.\n" << std::endl; std::cerr << "Please use a platform-specific script which will kill the overtime process instead.\n" << std::endl; std::cerr << "For examples in bash, or in windows cmd, see the forums, or the wesnoth repository." << std::endl; std::cerr << "The bash script is called `run_wml_tests`, the windows script is part of the VC project.\n" << std::endl; } int worker_result = game->unit_test(); std::cerr << ((worker_result == 0) ? "PASS TEST " : "FAIL TEST ") << ((worker_result == 3) ? "(INVALID REPLAY)" : "") << ((worker_result == 4) ? "(ERRORED REPLAY)" : "") << ": " << *cmdline_opts.unit_test << std::endl; return worker_result; } if(game->play_test() == false) { return 0; } if(game->play_screenshot_mode() == false) { return 0; } if(game->play_render_image_mode() == false) { return 0; } // Start directly a campaign if(game->goto_campaign() == false) { if(game->jump_to_campaign_id().empty()) continue; // Go to main menu else return 1; // we got an error starting the campaign from command line } // Start directly a multiplayer // Eventually with a specified server if(game->goto_multiplayer() == false) { continue; // Go to main menu } // Start directly a commandline multiplayer game if(game->play_multiplayer_commandline() == false) { return 0; } if(game->goto_editor() == false) { return 0; } preferences::load_hotkeys(); const font::floating_label_context label_manager; cursor::set(cursor::NORMAL); game_launcher::RELOAD_GAME_DATA should_reload = game_launcher::RELOAD_DATA; // If loading a game, skip the titlescreen entirely if(game->is_loading()) { if(!game->load_game()) { game->clear_loaded_game(); } game->launch_game(should_reload); continue; } gui2::dialogs::title_screen dlg(*game); /* * Quick explanation of the titlscreen loop: * * The dialog's redraw_background_ flag is initialized as true in the constructor, so the dialog will always * display at least once when this loop is executed. Each time it's opened, the aforementioned flag is set to * false, and any selection that results in leaving the dialog simply sets the window's retval and proceeds to * the appropriate action. * * Certain actions (such as window resizing) set the flag to true, which allows the dialog to reopen with any * layout changes such as those dictated by window resolution. */ while(dlg.get_retval() == gui2::dialogs::title_screen::REDRAW_BACKGROUND) { dlg.show(); } switch(dlg.get_retval()) { case gui2::dialogs::title_screen::QUIT_GAME: LOG_GENERAL << "quitting game...\n"; return 0; case gui2::dialogs::title_screen::MP_CONNECT: game_config::debug = game_config::mp_debug; if(!game->play_multiplayer(game_launcher::MP_CONNECT)) { continue; } break; case gui2::dialogs::title_screen::MP_HOST: game_config::debug = game_config::mp_debug; if(!game->play_multiplayer(game_launcher::MP_HOST)) { continue; } break; case gui2::dialogs::title_screen::MP_LOCAL: game_config::debug = game_config::mp_debug; if(!game->play_multiplayer(game_launcher::MP_LOCAL)) { continue; } break; case gui2::dialogs::title_screen::RELOAD_GAME_DATA: gui2::dialogs::loading_screen::display([&config_manager]() { config_manager.reload_changed_game_config(); image::flush_cache(); }); break; case gui2::dialogs::title_screen::MAP_EDITOR: game->start_editor(); break; case gui2::dialogs::title_screen::SHOW_ABOUT: gui2::dialogs::end_credits::display(); break; case gui2::dialogs::title_screen::LAUNCH_GAME: game->launch_game(should_reload); break; case gui2::dialogs::title_screen::REDRAW_BACKGROUND: break; } } }
PanelPluginsModel::~PanelPluginsModel() { qDeleteAll(plugins()); }
bool CliApplication::run(int &pRes) { // See what needs doing with the CLI options, if anything pRes = 0; // By default, everything is fine enum Option { NoOption, AboutOption, CommandOption, ExcludeOption, HelpOption, IncludeOption, PluginsOption, ResetOption, StatusOption, VersionOption }; Option option = NoOption; QStringList appArguments = qApp->arguments(); QStringList arguments = QStringList(); appArguments.removeFirst(); // Note: we remove the first argument since it corresponds to the full path // to our executable, which we are not interested in... static const QString A = "-a"; static const QString About = "--about"; static const QString C = "-c"; static const QString Command = "--command"; static const QString E = "-e"; static const QString Exclude = "--exclude"; static const QString H = "-h"; static const QString Help = "--help"; static const QString I = "-i"; static const QString Include = "--include"; static const QString P = "-p"; static const QString Plugins = "--plugins"; static const QString R = "-r"; static const QString Reset = "--reset"; static const QString S = "-s"; static const QString Status = "--status"; static const QString V = "-v"; static const QString Version = "--version"; for (const auto &appArgument : appArguments) { if ( (option == CommandOption) || (option == ExcludeOption) || (option == IncludeOption)) { // Keep track of the arguments passed to a command, an exclude or an // include call arguments << appArgument; } else if ((appArgument == A) || (appArgument == About)) { if (option == NoOption) { option = AboutOption; } else { pRes = -1; } } else if ((appArgument == C) || (appArgument == Command)) { if (option == NoOption) { option = CommandOption; } else { pRes = -1; } } else if ((appArgument == E) || (appArgument == Exclude)) { if (option == NoOption) { option = ExcludeOption; } else { pRes = -1; } } else if ((appArgument == H) || (appArgument == Help)) { if (option == NoOption) { option = HelpOption; } else { pRes = -1; } } else if ((appArgument == I) || (appArgument == Include)) { if (option == NoOption) { option = IncludeOption; } else { pRes = -1; } } else if ((appArgument == P) || (appArgument == Plugins)) { if (option == NoOption) { option = PluginsOption; } else { pRes = -1; } } else if ((appArgument == R) || (appArgument == Reset)) { if (option == NoOption) { option = ResetOption; } else { pRes = -1; } } else if ((appArgument == S) || (appArgument == Status)) { if (option == NoOption) { option = StatusOption; } else { pRes = -1; } } else if ((appArgument == V) || (appArgument == Version)) { if (option == NoOption) { option = VersionOption; } else { pRes = -1; } } else if (appArgument.startsWith('-')) { // The user provided at least one unknown option pRes = -1; break; } } // Handle the option the user requested, if any if (pRes == 0) { switch (option) { case NoOption: return false; case AboutOption: if (appArguments.count() != 1) { pRes = -1; help(); } else { about(); } break; case CommandOption: // Make sure that we have at least one argument (which would be the // command itself) before loading the plugins and then sending the // command to the plugin(s) if (arguments.isEmpty()) { pRes = -1; help(); } else { loadPlugins(); QString command = arguments.first(); arguments.removeFirst(); if (!CliApplication::command(command, arguments, pRes)) { pRes = -1; help(); } } break; case ExcludeOption: // Make sure that we have at least one argument (i.e. the name of a // plugin) if (arguments.isEmpty()) { pRes = -1; help(); } else { exclude(arguments); } break; case HelpOption: if (appArguments.count() != 1) { pRes = -1; help(); } else { help(); } break; case IncludeOption: // Make sure that we have at least one argument (i.e. the name of a // plugin) if (arguments.isEmpty()) { pRes = -1; help(); } else { include(arguments); } break; case PluginsOption: if (appArguments.count() != 1) { pRes = -1; help(); } else { loadPlugins(); plugins(); } break; case ResetOption: if (appArguments.count() != 1) { pRes = -1; help(); } else { reset(); } break; case StatusOption: if (appArguments.count() != 1) { pRes = -1; help(); } else { loadPlugins(); status(); } break; case VersionOption: if (appArguments.count() != 1) { pRes = -1; help(); } else { version(); } break; } } else { help(); } return true; }