diff --git a/widgets/CMakeLists.txt b/widgets/CMakeLists.txt index 535d035..c15339b 100644 --- a/widgets/CMakeLists.txt +++ b/widgets/CMakeLists.txt @@ -90,16 +90,27 @@ use_syncthingconnector() find_package(syncthingmodel ${META_APP_VERSION} REQUIRED) use_syncthingmodel() +# configure libsyncthing option(USE_LIBSYNCTHING "whether libsyncthing should be included for the launcher" OFF) if(USE_LIBSYNCTHING) find_package(syncthing ${META_APP_VERSION} REQUIRED) use_syncthing() set_source_files_properties( misc/syncthinglauncher.cpp - PROPERTIES COMPILE_DEFINITIONS SYNCTHING_WIDGETS_USE_LIBSYNCTHING + PROPERTIES COMPILE_DEFINITIONS SYNCTHINGWIDGETS_USE_LIBSYNCTHING ) endif() +# configure logging JavaScript events to stderr +option(SYNCTHING_WIDGETS_LOG_JAVASCRIPT_CONSOLE "enables logging JavaScript events of webview to stderr" OFF) +if(SYNCTHING_WIDGETS_LOG_JAVASCRIPT_CONSOLE) + set_property( + SOURCE webview/webpage.cpp + APPEND PROPERTY COMPILE_DEFINITIONS SYNCTHINGWIDGETS_LOG_JAVASCRIPT_CONSOLE + ) + message(WARNING "JavaScript console of web view will be logged to stderr") +endif() + # link also explicitely against the following Qt 5 modules list(APPEND ADDITIONAL_QT_MODULES Network Concurrent) diff --git a/widgets/misc/syncthinglauncher.cpp b/widgets/misc/syncthinglauncher.cpp index 8f49f21..3917976 100644 --- a/widgets/misc/syncthinglauncher.cpp +++ b/widgets/misc/syncthinglauncher.cpp @@ -25,7 +25,7 @@ SyncthingLauncher::SyncthingLauncher(QObject *parent) bool SyncthingLauncher::isLibSyncthingAvailable() { -#ifdef SYNCTHING_WIDGETS_USE_LIBSYNCTHING +#ifdef SYNCTHINGWIDGETS_USE_LIBSYNCTHING return true; #else return false; @@ -76,7 +76,7 @@ void SyncthingLauncher::terminate() m_process.stopSyncthing(); } else if (m_future.isRunning()) { m_manuallyStopped = true; -#ifdef SYNCTHING_WIDGETS_USE_LIBSYNCTHING +#ifdef SYNCTHINGWIDGETS_USE_LIBSYNCTHING LibSyncthing::stopSyncthing(); #endif } @@ -89,7 +89,7 @@ void SyncthingLauncher::kill() m_process.stopSyncthing(); } else if (m_future.isRunning()) { m_manuallyStopped = true; -#ifdef SYNCTHING_WIDGETS_USE_LIBSYNCTHING +#ifdef SYNCTHINGWIDGETS_USE_LIBSYNCTHING // FIXME: any change to try harder? LibSyncthing::stopSyncthing(); #endif @@ -117,7 +117,7 @@ static const char *const logLevelStrings[] = { void SyncthingLauncher::handleLoggingCallback(LibSyncthing::LogLevel level, const char *message, size_t messageSize) { -#ifdef SYNCTHING_WIDGETS_USE_LIBSYNCTHING +#ifdef SYNCTHINGWIDGETS_USE_LIBSYNCTHING if (level < LibSyncthing::LogLevel::Info) { return; } @@ -138,7 +138,7 @@ void SyncthingLauncher::handleLoggingCallback(LibSyncthing::LogLevel level, cons void SyncthingLauncher::runLibSyncthing(const LibSyncthing::RuntimeOptions &runtimeOptions) { -#ifdef SYNCTHING_WIDGETS_USE_LIBSYNCTHING +#ifdef SYNCTHINGWIDGETS_USE_LIBSYNCTHING LibSyncthing::setLoggingCallback(bind(&SyncthingLauncher::handleLoggingCallback, this, _1, _2, _3)); const auto exitCode = LibSyncthing::runSyncthing(runtimeOptions); emit exited(static_cast(exitCode), exitCode == 0 ? QProcess::NormalExit : QProcess::CrashExit); @@ -151,7 +151,7 @@ void SyncthingLauncher::runLibSyncthing(const LibSyncthing::RuntimeOptions &runt void SyncthingLauncher::runLibSyncthing(const std::vector &arguments) { -#ifdef SYNCTHING_WIDGETS_USE_LIBSYNCTHING +#ifdef SYNCTHINGWIDGETS_USE_LIBSYNCTHING LibSyncthing::setLoggingCallback(bind(&SyncthingLauncher::handleLoggingCallback, this, _1, _2, _3)); const auto exitCode = LibSyncthing::runSyncthing(arguments); emit exited(static_cast(exitCode), exitCode == 0 ? QProcess::NormalExit : QProcess::CrashExit); diff --git a/widgets/webview/webpage.cpp b/widgets/webview/webpage.cpp index ab4ee54..f5756df 100644 --- a/widgets/webview/webpage.cpp +++ b/widgets/webview/webpage.cpp @@ -26,6 +26,10 @@ #include #endif +#ifdef SYNCTHINGWIDGETS_LOG_JAVASCRIPT_CONSOLE +#include +#endif + using namespace Data; namespace QtGui { @@ -260,6 +264,9 @@ void WebPage::injectJavaScripts(bool ok) */ void WebPage::processJavaScriptConsoleMessage(const QString &message) { +#ifdef SYNCTHINGWIDGETS_LOG_JAVASCRIPT_CONSOLE + std::cerr << "JS console: " << message.toLocal8Bit().data() << std::endl; +#endif if (message.startsWith(QLatin1String("nativeInterface.showFolderPathSelection: "))) { showFolderPathSelection(message.mid(41)); }