Commit dc04093f authored by Arjen Hiemstra's avatar Arjen Hiemstra
Browse files

Make NetworkManager an optional requirement for the Network plugin

Otherwise things fail to build when it is not available (primarily on
FreeBSD).
parent 9fe9d1c7
......@@ -39,11 +39,16 @@ find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
NewStuff
Notifications
WindowSystem
NetworkManagerQt
)
find_package(KSysGuard REQUIRED)
find_package(KF5NetworkManagerQt ${KF5_MIN_VERSION})
set_package_properties(KF5NetworkManagerQt PROPERTIES
TYPE RECOMMENDED
PURPOSE "Provides an improved backend for Network statistics"
)
add_definitions(-DQT_NO_URL_CAST_FROM_STRING)
add_definitions(-DQT_USE_QSTRINGBUILDER)
#add_definitions(-DQT_NO_CAST_FROM_ASCII)
......
......@@ -2,11 +2,19 @@ set(KSYSGUARD_NETWORK_PLUGIN_SOURCES
NetworkPlugin.cpp
NetworkDevice.cpp
NetworkBackend.cpp
NetworkManagerBackend.cpp
AllDevicesObject.cpp
)
if (KF5NetworkManagerQt_FOUND)
set(KSYSGUARD_NETWORK_PLUGIN_SOURCES ${KSYSGUARD_NETWORK_PLUGIN_SOURCES} NetworkManagerBackend.cpp)
add_definitions(-DNETWORKMANAGER_FOUND)
endif()
add_library(ksysguard_globalplugin_network MODULE ${KSYSGUARD_NETWORK_PLUGIN_SOURCES})
target_link_libraries(ksysguard_globalplugin_network Qt5::Core Qt5::Gui Qt5::DBus KSysGuard::StatsBackend KF5::CoreAddons KF5::I18n KF5::NetworkManagerQt)
target_link_libraries(ksysguard_globalplugin_network Qt5::Core Qt5::Gui Qt5::DBus KSysGuard::StatsBackend KF5::CoreAddons KF5::I18n)
if (KF5NetworkManagerQt_FOUND)
target_link_libraries(ksysguard_globalplugin_network KF5::NetworkManagerQt)
endif()
install(TARGETS ksysguard_globalplugin_network DESTINATION ${KDE_INSTALL_PLUGINDIR}/ksysguard)
......@@ -27,9 +27,13 @@
#include <SensorContainer.h>
#include "NetworkDevice.h"
#include "NetworkManagerBackend.h"
#include "NetworkBackend.h"
#include "AllDevicesObject.h"
#ifdef NETWORKMANAGER_FOUND
#include "NetworkManagerBackend.h"
#endif
class NetworkPrivate
{
public:
......@@ -50,8 +54,10 @@ NetworkPlugin::NetworkPlugin(QObject *parent, const QVariantList &args)
d->allDevices = new AllDevicesObject(d->container);
#ifdef NETWORKMANAGER_FOUND
d->backend = new NetworkManagerBackend(this);
if (!d->backend->isSupported()) {
#endif
if (!d->backend || !d->backend->isSupported()) {
delete d->backend;
qWarning() << "Unable to start backend, network information not available.";
return;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment