Fix build without systemd support

This commit is contained in:
Martchus 2019-07-13 12:57:35 +02:00
parent 2112b00347
commit 335913c8ca
4 changed files with 14 additions and 2 deletions

View File

@ -32,7 +32,9 @@ class MiscTests : public TestFixture {
CPPUNIT_TEST(testParsingConfig); CPPUNIT_TEST(testParsingConfig);
CPPUNIT_TEST(testSplittingArguments); CPPUNIT_TEST(testSplittingArguments);
CPPUNIT_TEST(testUtils); CPPUNIT_TEST(testUtils);
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
CPPUNIT_TEST(testService); CPPUNIT_TEST(testService);
#endif
CPPUNIT_TEST(testConnectionSettingsAndLoadingSelfSignedCert); CPPUNIT_TEST(testConnectionSettingsAndLoadingSelfSignedCert);
CPPUNIT_TEST(testSyncthingDir); CPPUNIT_TEST(testSyncthingDir);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
@ -43,7 +45,9 @@ public:
void testParsingConfig(); void testParsingConfig();
void testSplittingArguments(); void testSplittingArguments();
void testUtils(); void testUtils();
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
void testService(); void testService();
#endif
void testConnectionSettingsAndLoadingSelfSignedCert(); void testConnectionSettingsAndLoadingSelfSignedCert();
void testSyncthingDir(); void testSyncthingDir();
@ -137,6 +141,7 @@ void MiscTests::testUtils()
CPPUNIT_ASSERT(!isLocal(QUrl(QStringLiteral("http://157.3.52.34")))); CPPUNIT_ASSERT(!isLocal(QUrl(QStringLiteral("http://157.3.52.34"))));
} }
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
/*! /*!
* \brief Tests SyncthingService class, but error case with non-existant service so far. * \brief Tests SyncthingService class, but error case with non-existant service so far.
*/ */
@ -152,6 +157,7 @@ void MiscTests::testService()
service.toggleRunning(); service.toggleRunning();
service.setEnabled(true); service.setEnabled(true);
} }
#endif
void MiscTests::testConnectionSettingsAndLoadingSelfSignedCert() void MiscTests::testConnectionSettingsAndLoadingSelfSignedCert()
{ {

View File

@ -62,7 +62,9 @@ SyncthingApplet::SyncthingApplet(QObject *parent, const QVariantList &data)
, m_currentConnectionConfig(-1) , m_currentConnectionConfig(-1)
, m_initialized(false) , m_initialized(false)
{ {
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
m_notifier.setService(&m_service); m_notifier.setService(&m_service);
#endif
qmlRegisterUncreatableMetaObject(Data::staticMetaObject, "martchus.syncthingplasmoid", 0, 6, "Data", QStringLiteral("only enums")); qmlRegisterUncreatableMetaObject(Data::staticMetaObject, "martchus.syncthingplasmoid", 0, 6, "Data", QStringLiteral("only enums"));
} }
@ -221,7 +223,11 @@ void SyncthingApplet::setCurrentConnectionConfigIndex(int index)
bool SyncthingApplet::isStartStopEnabled() const bool SyncthingApplet::isStartStopEnabled() const
{ {
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
return Settings::values().systemd.showButton; return Settings::values().systemd.showButton;
#else
return false;
#endif
} }
bool SyncthingApplet::areNotificationsAvailable() const bool SyncthingApplet::areNotificationsAvailable() const

View File

@ -578,7 +578,7 @@ Settings::Launcher::LauncherStatus TrayWidget::handleLauncherStatusChanged()
const auto launcherStatus = applyLauncherSettings(false, systemdStatus.relevant, systemdStatus.showStartStopButton); const auto launcherStatus = applyLauncherSettings(false, systemdStatus.relevant, systemdStatus.showStartStopButton);
const auto showStartStopButton = systemdStatus.showStartStopButton || launcherStatus.showStartStopButton; const auto showStartStopButton = systemdStatus.showStartStopButton || launcherStatus.showStartStopButton;
#else #else
const auto launcherStatus = applyLauncherSettings(reconnectRequired); const auto launcherStatus = applyLauncherSettings(false);
const auto showStartStopButton = launcherStatus.showStartStopButton; const auto showStartStopButton = launcherStatus.showStartStopButton;
#endif #endif
m_ui->startStopPushButton->setVisible(showStartStopButton); m_ui->startStopPushButton->setVisible(showStartStopButton);

View File

@ -5,8 +5,8 @@
#include "../../connector/syncthingnotifier.h" #include "../../connector/syncthingnotifier.h"
#include "../../connector/syncthingprocess.h" #include "../../connector/syncthingprocess.h"
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
#include "../../connector/syncthingconnection.h" #include "../../connector/syncthingconnection.h"
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
#include "../../connector/syncthingservice.h" #include "../../connector/syncthingservice.h"
#endif #endif