Commit 6bc094b2 authored by David Redondo's avatar David Redondo 🏎

Select a fallback backend if the prior ones are not supported

This allows us falling back to something else if our preferred backend
is not supported at runtime.
parent 8de6ba60
......@@ -54,11 +54,20 @@ NetworkPlugin::NetworkPlugin(QObject *parent, const QVariantList &args)
d->allDevices = new AllDevicesObject(d->container);
using creationFunction = std::add_pointer_t<NetworkBackend *(NetworkPlugin *parent)>;
std::vector<creationFunction> backendFunctions;
#ifdef NETWORKMANAGER_FOUND
d->backend = new NetworkManagerBackend(this);
backendFunctions.emplace_back([](NetworkPlugin *parent) -> NetworkBackend* {return new NetworkManagerBackend(parent);});
#endif
if (!d->backend || !d->backend->isSupported()) {
delete d->backend;
for (auto func : backendFunctions) {
auto backend = func(this);
if (backend->isSupported()) {
d->backend = backend;
break;
}
delete backend;
}
if (!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