bool MainWindow::clientArgs(QStringList& args, QString& app) { app = appConfig().synergyc(); if (!QFile::exists(app)) { if (QMessageBox::warning(this, tr("Synergy client not found"), tr("The executable for the synergy client does not exist. Do you want to browse for the synergy client now?"), QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return false; app = SettingsDialog::browseForSynergyc(this, appConfig().synergyProgramDir(), appConfig().synergycName()); if (app.isEmpty()) return false; appConfig().setSynergyc(app); } if (m_pLineEditHostname->text().isEmpty()) { QMessageBox::warning(this, tr("Hostname is empty"), tr("Please fill in a hostname for the synergy client to connect to.")); return false; } args << m_pLineEditHostname->text() + ":" + QString::number(appConfig().port()); return true; }
bool SettingsDialog::on_m_pButtonBrowseSynergyc_clicked() { QString fileName = browseForSynergyc(this, appConfig().synergyProgramDir(), appConfig().synergycName()); if (!fileName.isEmpty()) { m_pLineEditSynergyc->setText(fileName); return true; } return false; }
bool MainWindow::serverArgs(QStringList& args, QString& app) { app = appPath(appConfig().synergysName(), appConfig().synergys()); if (!QFile::exists(app)) { if (QMessageBox::warning(this, tr("Synergy server not found"), tr("The executable for the synergy server does not exist. Do you want to browse for the synergy server now?"), QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return false; app = SettingsDialog::browseForSynergys(this, appConfig().synergyProgramDir(), appConfig().synergysName()); if (app.isEmpty()) return false; appConfig().setSynergys(app); } if (appConfig().logToFile()) { appConfig().persistLogDir(); args << "--log" << appConfig().logFilename(); } args << "-c" << configFilename() << "--address" << address(); return true; }
QString MainWindow::appPath(const QString& name, const QString& defaultPath) { QString app; if (appConfig().autoDetectPaths()) { // actually returns bool, but ignore for now appConfig().detectPath(name, app); } else { app = defaultPath; } return app; }
bool MainWindow::serverArgs(QStringList& args, QString& app) { app = appConfig().synergys(); if (!QFile::exists(app)) { if (QMessageBox::warning(this, tr("Synergy server not found"), tr("The executable for the synergy server does not exist. Do you want to browse for the synergy server now?"), QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return false; app = SettingsDialog::browseForSynergys(this, appConfig().synergyProgramDir(), appConfig().synergysName()); if (app.isEmpty()) return false; appConfig().setSynergys(app); } if (m_pRadioInternalConfig->isChecked()) { m_pTempConfigFile = new QTemporaryFile(); if (!m_pTempConfigFile->open()) { QMessageBox::critical(this, tr("Cannot write configuration file"), tr("The temporary configuration file required to start synergy can not be written.")); return false; } serverConfig().save(*m_pTempConfigFile); args << "-c" << m_pTempConfigFile->fileName(); m_pTempConfigFile->close(); // the file will be removed from disk when the object is deleted; this happens in stopSynergy() } else { if (!QFile::exists(m_pLineEditConfigFile->text())) { if (QMessageBox::warning(this, tr("Configuration filename invalid"), tr("You have not filled in a valid configuration file for the synergy server. " "Do you want to browse for the configuration file now?"), QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes || !on_m_pButtonBrowseConfigFile_clicked()) return false; } args << "-c" << m_pLineEditConfigFile->text(); } args << "--address" << (!appConfig().interface().isEmpty() ? appConfig().interface() : "") + ":" + QString::number(appConfig().port()); return true; }
void SettingsDialog::accept() { appConfig().setAutoConnect(m_pCheckBoxAutoConnect->isChecked()); appConfig().setScreenName(m_pLineEditScreenName->text()); appConfig().setPort(m_pSpinBoxPort->value()); appConfig().setInterface(m_pLineEditInterface->text()); appConfig().setProcessMode((ProcessMode)m_pComboProcessMode->currentIndex()); appConfig().setLogLevel(m_pComboLogLevel->currentIndex()); appConfig().setLogToFile(m_pCheckBoxLogToFile->isChecked()); appConfig().setLogFilename(m_pLineEditLogFilename->text()); appConfig().setAutoStart(m_pCheckBoxAutoStart->isChecked()); appConfig().setAutoHide(m_pCheckBoxAutoHide->isChecked()); QDialog::accept(); }
void SettingsDialog::accept() { appConfig().setAutoConnect(m_pCheckBoxAutoConnect->isChecked()); appConfig().setSynergyc(m_pLineEditSynergyc->text()); appConfig().setSynergys(m_pLineEditSynergys->text()); appConfig().setScreenName(m_pLineEditScreenName->text()); appConfig().setPort(m_pSpinBoxPort->value()); appConfig().setInterface(m_pLineEditInterface->text()); appConfig().setLogLevel(m_pComboLogLevel->currentIndex()); appConfig().setAutoDetectPaths(m_pCheckBoxAutoDetectPaths->isChecked()); appConfig().setLogToFile(m_pCheckBoxLogToFile->isChecked()); appConfig().setLogFilename(m_pLineEditLogFilename->text()); QDialog::accept(); }
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), MainWindowBase(), m_Settings(), m_AppConfig(&m_Settings), m_pSynergy(NULL), m_SynergyState(synergyDisconnected), m_ServerConfig(&m_Settings, 5, 3), m_pTempConfigFile(NULL), m_pLogDialog(new LogDialog(this, synergyProcess())), m_pTrayIcon(NULL), m_pTrayIconMenu(NULL) { setupUi(this); createTrayIcon(); createMenuBar(); loadSettings(); initConnections(); // HACK - surely window should be visible by default? setVisible(true); if (appConfig().autoConnect()) startSynergy(); }
void SSLManager::initPassphraseHandler(bool server) { if (server && _ptrServerPassphraseHandler) return; if (!server && _ptrClientPassphraseHandler) return; std::string prefix = server ? CFG_SERVER_PREFIX : CFG_CLIENT_PREFIX; Poco::Util::AbstractConfiguration& config = appConfig(); std::string className(config.getString(prefix + CFG_DELEGATE_HANDLER, VAL_DELEGATE_HANDLER)); const PrivateKeyFactory* pFactory = 0; if (privateKeyFactoryMgr().hasFactory(className)) { pFactory = privateKeyFactoryMgr().getFactory(className); } if (pFactory) { if (server) _ptrServerPassphraseHandler = pFactory->create(server); else _ptrClientPassphraseHandler = pFactory->create(server); } else throw Poco::Util::UnknownOptionException(std::string("No passphrase handler known with the name ") + className); }
void SSLManager::initCertificateHandler(bool server) { if (server && _ptrServerCertificateHandler) return; if (!server && _ptrClientCertificateHandler) return; std::string prefix = server ? CFG_SERVER_PREFIX : CFG_CLIENT_PREFIX; Poco::Util::AbstractConfiguration& config = appConfig(); std::string className(config.getString(prefix+CFG_CERTIFICATE_HANDLER, VAL_CERTIFICATE_HANDLER)); const CertificateHandlerFactory* pFactory = 0; if (certificateHandlerFactoryMgr().hasFactory(className)) { pFactory = certificateHandlerFactoryMgr().getFactory(className); } if (pFactory) { if (server) _ptrServerCertificateHandler = pFactory->create(true); else _ptrClientCertificateHandler = pFactory->create(false); } else throw Poco::Util::UnknownOptionException(std::string("No InvalidCertificate handler known with the name ") + className); }
SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), Ui::SettingsDialogBase(), m_AppConfig(config) { setupUi(this); m_pCheckBoxAutoConnect->setChecked(appConfig().autoConnect()); m_pLineEditScreenName->setText(appConfig().screenName()); m_pSpinBoxPort->setValue(appConfig().port()); m_pLineEditInterface->setText(appConfig().interface()); m_pComboProcessMode->setCurrentIndex(appConfig().processMode()); m_pComboLogLevel->setCurrentIndex(appConfig().logLevel()); m_pCheckBoxLogToFile->setChecked(appConfig().logToFile()); m_pLineEditLogFilename->setText(appConfig().logFilename()); m_pCheckBoxAutoStart->setChecked(appConfig().autoStart()); m_pCheckBoxAutoHide->setChecked(appConfig().autoHide()); }
void MainWindow::startSynergy() { stopSynergy(); QString app; QStringList args; args << "-f" << "--debug" << appConfig().logLevelText(); if (!appConfig().screenName().isEmpty()) args << "--name" << appConfig().screenName(); if (appConfig().gameDevice()) { args << "--game-device"; } setSynergyProcess(new QProcess(this)); if ((synergyType() == synergyClient && !clientArgs(args, app)) || (synergyType() == synergyServer && !serverArgs(args, app))) { stopSynergy(); return; } connect(synergyProcess(), SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(synergyFinished(int, QProcess::ExitStatus))); connect(synergyProcess(), SIGNAL(readyReadStandardOutput()), m_pLogDialog, SLOT(readSynergyOutput())); connect(synergyProcess(), SIGNAL(readyReadStandardError()), m_pLogDialog, SLOT(readSynergyOutput())); m_pLogDialog->append(tr("\n\nRunning synergy: %1 %2\n\n").arg(app).arg(args.join(" "))); synergyProcess()->start(app, args); if (!synergyProcess()->waitForStarted()) { stopSynergy(); QMessageBox::warning(this, tr("Program can not be started"), QString(tr("The executable<br><br>%1<br><br>could not be successfully started, although it does exist. Please check if you have sufficient permissions to run this program.").arg(app))); return; } setSynergyState(synergyConnected); }
SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), Ui::SettingsDialogBase(), m_AppConfig(config), m_SuppressElevateWarning(false), m_SuppressEncryptionWarning(false) { setupUi(this); m_Locale.fillLanguageComboBox(m_pComboLanguage); m_pLineEditScreenName->setText(appConfig().screenName()); m_pSpinBoxPort->setValue(appConfig().port()); m_pLineEditInterface->setText(appConfig().interface()); m_pComboLogLevel->setCurrentIndex(appConfig().logLevel()); m_pCheckBoxLogToFile->setChecked(appConfig().logToFile()); m_pLineEditLogFilename->setText(appConfig().logFilename()); setIndexFromItemData(m_pComboLanguage, appConfig().language()); m_pCheckBoxAutoHide->setChecked(appConfig().getAutoHide()); #if defined(Q_OS_WIN) m_SuppressElevateWarning = true; m_pCheckBoxElevateMode->setChecked(appConfig().elevateMode()); m_SuppressElevateWarning = false; m_pCheckBoxAutoHide->hide(); #else // elevate checkbox is only useful on ms windows. m_pCheckBoxElevateMode->hide(); #endif if (!PluginManager::exist(networkSecurity)) { m_pGroupNetworkSecurity->setEnabled(false); m_pCheckBoxEnableCrypto->setChecked(false); } else { m_SuppressEncryptionWarning = true; m_pCheckBoxEnableCrypto->setChecked(m_AppConfig.getCryptoEnabled()); m_SuppressEncryptionWarning = false; } }
SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), Ui::SettingsDialogBase(), m_AppConfig(config) { setupUi(this); m_pCheckBoxAutoConnect->setChecked(appConfig().autoConnect()); m_pLineEditScreenName->setText(appConfig().screenName()); m_pSpinBoxPort->setValue(appConfig().port()); m_pLineEditInterface->setText(appConfig().interface()); m_pComboLogLevel->setCurrentIndex(appConfig().logLevel()); m_pCheckBoxLogToFile->setChecked(appConfig().logToFile()); m_pLineEditLogFilename->setText(appConfig().logFilename()); #ifdef Q_OS_WIN m_pCheckBoxGameDevice->setChecked(appConfig().gameDevice()); #else m_pCheckBoxGameDevice->setEnabled(false); #endif }
bool PluginLauncher::launch( Poco::Util::Application& app ) { bool launched(false); if(_libName.length() > 0) { try { _sharedLib.unload(); Poco::Util::LayeredConfiguration& appConfig(app.config()); SLAString appDir(appConfig.getString("application.dir")); SLAString libPath(appDir); libPath += _libName; libPath += sl::getSharedLibSuffix(); _sharedLib.load(libPath); nlFunc_launchLayer* launchLayerFunc = queryLaunchLayerFunction(); nlFunc_launch* launchFunc = queryLaunchFunction(); if(launchFunc /*&& !launchLayerFunc*/) { launchFunc(); launched = true; } else { if(launchLayerFunc) { int returnCode(sl::CocosAppDelegate::launch(launchLayerFunc)); launched = (returnCode == 0); } else { SL_PROCESS_APP()->log( ELogType_Error, "failed to queryLaunchFunction lib: %s", _libName.c_str()); SL_PROCESS_APP()->log( ELogType_Error, "failed to queryLaunchLayerFunction lib: %s", _libName.c_str()); } } _sharedLib.unload(); } catch ( ... ) { app.logger().error("failed to launch lib: %s", _libName.c_str()); } } return launched; }
void SettingsDialog::accept() { appConfig().setAutoConnect(m_pCheckBoxAutoConnect->isChecked()); appConfig().setScreenName(m_pLineEditScreenName->text()); appConfig().setPort(m_pSpinBoxPort->value()); appConfig().setInterface(m_pLineEditInterface->text()); appConfig().setLogLevel(m_pComboLogLevel->currentIndex()); appConfig().setLogToFile(m_pCheckBoxLogToFile->isChecked()); appConfig().setLogFilename(m_pLineEditLogFilename->text()); appConfig().setAutoStart(m_pCheckBoxAutoStart->isChecked()); appConfig().setAutoHide(m_pCheckBoxAutoHide->isChecked()); appConfig().setGameModeIndex(m_pComboBoxGameDevice->currentIndex()); appConfig().setGamePollingDynamic(m_pRadioButtonGamePollDynamic->isChecked()); appConfig().setGamePollingFrequency(m_pSpinBoxGamePoll->value()); QDialog::accept(); }
void SettingsDialog::accept() { appConfig().setScreenName(m_pLineEditScreenName->text()); appConfig().setPort(m_pSpinBoxPort->value()); appConfig().setInterface(m_pLineEditInterface->text()); appConfig().setLogLevel(m_pComboLogLevel->currentIndex()); appConfig().setLogToFile(m_pCheckBoxLogToFile->isChecked()); appConfig().setLogFilename(m_pLineEditLogFilename->text()); appConfig().setLanguage(m_pComboLanguage->itemData(m_pComboLanguage->currentIndex()).toString()); appConfig().setElevateMode(m_pCheckBoxElevateMode->isChecked()); appConfig().setAutoHide(m_pCheckBoxAutoHide->isChecked()); appConfig().setCryptoEnabled(m_pCheckBoxEnableCrypto->isChecked()); appConfig().saveSettings(); QDialog::accept(); }
void SSLManager::initDefaultContext(bool server) { if (server && _ptrDefaultServerContext) return; if (!server && _ptrDefaultClientContext) return; Poco::Crypto::OpenSSLInitializer openSSLInitializer; initEvents(server); Poco::Util::AbstractConfiguration& config = appConfig(); #ifdef OPENSSL_FIPS bool fipsEnabled = config.getBool(CFG_FIPS_MODE, VAL_FIPS_MODE); if (fipsEnabled && !Poco::Crypto::OpenSSLInitializer::isFIPSEnabled()) { Poco::Crypto::OpenSSLInitializer::enableFIPSMode(true); } #endif std::string prefix = server ? CFG_SERVER_PREFIX : CFG_CLIENT_PREFIX; // mandatory options std::string privKeyFile = config.getString(prefix + CFG_PRIV_KEY_FILE, ""); std::string certFile = config.getString(prefix + CFG_CERTIFICATE_FILE, privKeyFile); std::string caLocation = config.getString(prefix + CFG_CA_LOCATION, ""); if (server && certFile.empty() && privKeyFile.empty()) throw SSLException("Configuration error: no certificate file has been specified"); // optional options for which we have defaults defined Context::VerificationMode verMode = VAL_VER_MODE; if (config.hasProperty(prefix + CFG_VER_MODE)) { // either: none, relaxed, strict, once std::string mode = config.getString(prefix + CFG_VER_MODE); verMode = Utility::convertVerificationMode(mode); } int verDepth = config.getInt(prefix + CFG_VER_DEPTH, VAL_VER_DEPTH); bool loadDefCA = config.getBool(prefix + CFG_ENABLE_DEFAULT_CA, VAL_ENABLE_DEFAULT_CA); std::string cipherList = config.getString(prefix + CFG_CIPHER_LIST, VAL_CIPHER_LIST); cipherList = config.getString(prefix + CFG_CYPHER_LIST, cipherList); // for backwards compatibility bool requireTLSv1 = config.getBool(prefix + CFG_REQUIRE_TLSV1, false); bool requireTLSv1_1 = config.getBool(prefix + CFG_REQUIRE_TLSV1_1, false); bool requireTLSv1_2 = config.getBool(prefix + CFG_REQUIRE_TLSV1_2, false); Context::Usage usage; if (server) { if (requireTLSv1_2) usage = Context::TLSV1_2_SERVER_USE; else if (requireTLSv1_1) usage = Context::TLSV1_1_SERVER_USE; else if (requireTLSv1) usage = Context::TLSV1_SERVER_USE; else usage = Context::SERVER_USE; _ptrDefaultServerContext = new Context(usage, privKeyFile, certFile, caLocation, verMode, verDepth, loadDefCA, cipherList); } else { if (requireTLSv1_2) usage = Context::TLSV1_2_CLIENT_USE; else if (requireTLSv1_1) usage = Context::TLSV1_1_CLIENT_USE; else if (requireTLSv1) usage = Context::TLSV1_CLIENT_USE; else usage = Context::CLIENT_USE; _ptrDefaultClientContext = new Context(usage, privKeyFile, certFile, caLocation, verMode, verDepth, loadDefCA, cipherList); } bool cacheSessions = config.getBool(prefix + CFG_CACHE_SESSIONS, false); if (server) { std::string sessionIdContext = config.getString(prefix + CFG_SESSION_ID_CONTEXT, config.getString("application.name", "")); _ptrDefaultServerContext->enableSessionCache(cacheSessions, sessionIdContext); if (config.hasProperty(prefix + CFG_SESSION_CACHE_SIZE)) { int cacheSize = config.getInt(prefix + CFG_SESSION_CACHE_SIZE); _ptrDefaultServerContext->setSessionCacheSize(cacheSize); } if (config.hasProperty(prefix + CFG_SESSION_TIMEOUT)) { int timeout = config.getInt(prefix + CFG_SESSION_TIMEOUT); _ptrDefaultServerContext->setSessionTimeout(timeout); } } else { _ptrDefaultClientContext->enableSessionCache(cacheSessions); } bool extendedVerification = config.getBool(prefix + CFG_EXTENDED_VERIFICATION, false); if (server) _ptrDefaultServerContext->enableExtendedCertificateVerification(extendedVerification); else _ptrDefaultClientContext->enableExtendedCertificateVerification(extendedVerification); }
void MainWindow::on_m_pActionServices_triggered() { WindowsServices dlg(this, appConfig()); dlg.exec(); }
void SettingsDialog::reject() { QSynergyApplication::getInstance()->switchTranslator(appConfig().language()); QDialog::reject(); }
void MainWindow::on_m_pActionSettings_triggered() { SettingsDialog dlg(this, appConfig()); dlg.exec(); }
void MainWindow::on_m_pActionAbout_triggered() { AboutDialog dlg(this, appConfig().synergyc()); dlg.exec(); }
QString MainWindow::address() { return (!appConfig().interface().isEmpty() ? appConfig().interface() : "") + ":" + QString::number(appConfig().port()); }
void MainWindow::on_m_pButtonConfigureServer_clicked() { ServerConfigDialog dlg(this, serverConfig(), appConfig().screenName()); dlg.exec(); }
void SSLManager::initDefaultContext(bool server) { if (server && _ptrDefaultServerContext) return; if (!server && _ptrDefaultClientContext) return; initEvents(server); const std::string prefix = server ? CFG_SERVER_PREFIX : CFG_CLIENT_PREFIX; Poco::Util::AbstractConfiguration& config = appConfig(); std::string certName = config.getString(prefix + CFG_CERT_NAME, VAL_CERT_NAME); std::string certPath = config.getString(prefix + CFG_CERT_PATH, VAL_CERT_PATH); std::string certStore = config.getString(prefix + CFG_CERT_STORE, VAL_CERT_STORE); bool requireTLSv1 = config.getBool(prefix + CFG_REQUIRE_TLSV1, false); bool requireTLSv1_1 = config.getBool(prefix + CFG_REQUIRE_TLSV1_1, false); bool requireTLSv1_2 = config.getBool(prefix + CFG_REQUIRE_TLSV1_2, false); // optional options for which we have defaults defined Context::VerificationMode verMode = VAL_VER_MODE; if (config.hasProperty(prefix + CFG_VER_MODE)) { // either: none, relaxed, strict, once std::string mode = config.getString(prefix + CFG_VER_MODE); verMode = Utility::convertVerificationMode(mode); } bool revocChecking = config.getBool(prefix + CFG_REVOCATION_CHECK, VAL_REVOCATION_CHECK); bool trustRoots = config.getBool(prefix + CFG_TRUST_ROOTS, VAL_TRUST_ROOTS); bool useMachineStore = config.getBool(prefix + CFG_USE_MACHINE_STORE, VAL_USE_MACHINE_STORE); bool useStrongCrypto = config.getBool(prefix + CFG_USE_STRONG_CRYPTO, VAL_USE_STRONG_CRYPTO); int options = 0; if (revocChecking) options |= Context::OPT_PERFORM_REVOCATION_CHECK; if (trustRoots) options |= Context::OPT_TRUST_ROOTS_WIN_CERT_STORE; if (useMachineStore) options |= Context::OPT_USE_MACHINE_STORE; if (useStrongCrypto) options |= Context::OPT_USE_STRONG_CRYPTO; if (!certPath.empty()) { options |= Context::OPT_LOAD_CERT_FROM_FILE; certName = certPath; } Context::Usage usage; if (server) { if (requireTLSv1_2) usage = Context::TLSV1_2_SERVER_USE; else if (requireTLSv1_1) usage = Context::TLSV1_1_SERVER_USE; else if (requireTLSv1) usage = Context::TLSV1_SERVER_USE; else usage = Context::SERVER_USE; _ptrDefaultServerContext = new Context(usage, certName, verMode, options, certStore); } else { if (requireTLSv1_2) usage = Context::TLSV1_2_CLIENT_USE; else if (requireTLSv1_1) usage = Context::TLSV1_1_CLIENT_USE; else if (requireTLSv1) usage = Context::TLSV1_CLIENT_USE; else usage = Context::CLIENT_USE; _ptrDefaultClientContext = new Context(usage, certName, verMode, options, certStore); } }