solid: remove HUpnp backend

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2021-07-05 04:00:20 +03:00
parent e9b8f27026
commit 6729cc66d1
20 changed files with 2 additions and 1572 deletions

View file

@ -215,13 +215,6 @@ set_package_properties(GSSAPI PROPERTIES
PURPOSE "A MIT or HEIMDAL flavor of GSSAPI can be used"
)
macro_optional_find_package(HUpnp)
set_package_properties(HUpnp PROPERTIES
URL "http://www.herqq.org"
PURPOSE "Allows Solid to provide information about UPnP devices on the network"
TYPE OPTIONAL
)
# v143+ required for udev_monitor_filter_add_match_subsystem_devtype()
macro_optional_find_package(UDev 143)
set_package_properties(UDev PROPERTIES

View file

@ -8,7 +8,6 @@ set(module_install_dir ${KDE4_DATA_INSTALL_DIR}/cmake/modules)
# are listed explicitly:
set(cmakeFilesDontInstall
FindLibRaw.cmake
FindHUpnp.cmake
FindMPV.cmake
FindUDev.cmake
FindAvahi.cmake

View file

@ -1,35 +0,0 @@
# Try to find HUPnP library, once done this will define:
#
# HUPNP_FOUND - system has HUPnP
# HUPNP_INCLUDE_DIR - the LIBHUpnp include directory
# HUPNP_LIBS - the LIBHUpnp libraries
# HUPNP_VERSION_STRING - The version of HUpnp
# HUPNP_VERSION_MAJOR - The major version of HUpnp
# HUPNP_VERSION_MINOR - The minor version of HUpnp
# HUPNP_VERSION_PATCH - The patch version of HUpnp
#
# Copyright (c) 2010, Paulo Romulo Alves Barros <paulo.romulo@kdemail.net>
# The minimum HUpnp version we require
if(NOT HUpnp_FIND_VERSION)
set(HUpnp_FIND_VERSION "0.9.1")
endif()
find_path( HUPNP_INCLUDE_DIR HUpnpCore/HUpnp )
find_library( HUPNP_LIBS NAMES HUpnp HUpnp1 )
if( HUPNP_INCLUDE_DIR AND EXISTS "${HUPNP_INCLUDE_DIR}/HUpnpCore/public/hupnpinfo.h" )
file( STRINGS "${HUPNP_INCLUDE_DIR}/HUpnpCore/public/hupnpinfo.h" HUPNP_INFO_H REGEX "^#define HUPNP_CORE_.*_VERSION .*$" )
string( REGEX REPLACE ".*HUPNP_CORE_MAJOR_VERSION ([0-9]+).*" "\\1" HUPNP_VERSION_MAJOR "${HUPNP_INFO_H}" )
string( REGEX REPLACE ".*HUPNP_CORE_MINOR_VERSION ([0-9]+).*" "\\1" HUPNP_VERSION_MINOR "${HUPNP_INFO_H}" )
string( REGEX REPLACE ".*HUPNP_CORE_PATCH_VERSION ([0-9]+).*" "\\1" HUPNP_VERSION_PATCH "${HUPNP_INFO_H}" )
set( HUPNP_VERSION_STRING "${HUPNP_VERSION_MAJOR}.${HUPNP_VERSION_MINOR}.${HUPNP_VERSION_PATCH}" )
endif()
include( FindPackageHandleStandardArgs )
find_package_handle_standard_args( HUpnp REQUIRED_VARS HUPNP_INCLUDE_DIR HUPNP_LIBS
VERSION_VAR HUPNP_VERSION_STRING )
mark_as_advanced( HUPNP_INCLUDE_DIR HUPNP_LIBS )

View file

@ -115,21 +115,6 @@ if(ENABLE_TESTING)
)
endif()
if(HUPNP_FOUND)
include_directories(${HUPNP_INCLUDE_DIR})
message(STATUS "Building Solid UPnP backend.")
set(solid_LIB_SRCS ${solid_LIB_SRCS}
backends/upnp/upnpdevice.cpp
backends/upnp/upnpdevicemanager.cpp
backends/upnp/upnpdeviceinterface.cpp
backends/upnp/upnpmediaserver.cpp
backends/upnp/upnpinternetgateway.cpp
backends/upnp/upnpcontrolpoint.cpp
)
set(solid_OPTIONAL_LIBS ${solid_OPTIONAL_LIBS} ${HUPNP_LIBS})
endif()
if(UDEV_FOUND)
include_directories(${UDEV_INCLUDES})
message(STATUS "Building Solid UDev backend.")

View file

@ -80,4 +80,4 @@ namespace Fstab
}
}
}
#endif // SOLID_BACKENDS_UPNP_UPNP_DEVICE_H
#endif // SOLID_BACKENDS_FSTAB_FSTAB_DEVICE_H

View file

@ -36,6 +36,7 @@ class DeviceInterface : public QObject, virtual public Solid::Ifaces::DeviceInte
{
Q_OBJECT
Q_INTERFACES(Solid::Ifaces::DeviceInterface)
public:
DeviceInterface(UDevDevice *device);
virtual ~DeviceInterface();

View file

@ -1,105 +0,0 @@
/*
Copyright 2010 Paulo Romulo Alves Barros <paulo.romulo@kdemail.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QtCore/qdebug.h>
#include <HUpnpCore/HClientDevice>
#include <HUpnpCore/HDeviceInfo>
#include <HUpnpCore/HUdn>
#include <HUpnpCore/HDiscoveryType>
#include "upnpcontrolpoint.h"
namespace Solid
{
namespace Backends
{
namespace UPnP
{
UPnPControlPoint::UPnPControlPoint() :
m_controlPoint(new Herqq::Upnp::HControlPoint(this))
{
if (!m_controlPoint->init())
{
qDebug() << "control point init error:" << m_controlPoint->errorDescription();
return;
}
}
UPnPControlPoint::~UPnPControlPoint()
{
delete m_controlPoint;
}
UPnPControlPoint* UPnPControlPoint::inst = 0;
UPnPControlPoint* UPnPControlPoint::instance()
{
if (!inst)
{
inst = new UPnPControlPoint;
}
return inst;
}
QMutex UPnPControlPoint::mutex;
UPnPControlPoint* UPnPControlPoint::acquireInstance()
{
mutex.lock();
return instance();
}
void UPnPControlPoint::releaseInstance()
{
mutex.unlock();
}
Herqq::Upnp::HControlPoint* UPnPControlPoint::controlPoint()
{
return m_controlPoint;
}
QStringList UPnPControlPoint::allDevices()
{
QStringList result;
Herqq::Upnp::HDiscoveryType discoveryType = Herqq::Upnp::HDiscoveryType::createDiscoveryTypeForRootDevices();
Herqq::Upnp::HClientDevices list = m_controlPoint->rootDevices();
for (int i = 0; i < list.size(); ++i)
{
Herqq::Upnp::HClientDevice* device = list[i];
Herqq::Upnp::HDeviceInfo info = device->info();
result << ( QString::fromLatin1("/org/kde/upnp") + '/' + info.udn().toString() );
qDebug() << "Found device:" << ( QString::fromLatin1("/org/kde/upnp") + '/' + info.udn().toString() );
// listing only root devices
}
return result;
}
}
}
}

View file

@ -1,67 +0,0 @@
/*
Copyright 2010 Paulo Romulo Alves Barros <paulo.romulo@kdemail.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SOLID_BACKENDS_UPNP_UPNPCONTROLPOINT_H
#define SOLID_BACKENDS_UPNP_UPNPCONTROLPOINT_H
#include <QtCore/QObject>
#include <QtCore/QMutex>
#include <HUpnpCore/HClientDevice>
#include <HUpnpCore/HControlPoint>
#include <QtCore/QStringList>
namespace Solid
{
namespace Backends
{
namespace UPnP
{
class UPnPControlPoint : public QObject
{
public:
static UPnPControlPoint* acquireInstance();
static void releaseInstance();
Herqq::Upnp::HControlPoint* controlPoint();
QStringList allDevices();
virtual ~UPnPControlPoint();
private:
explicit UPnPControlPoint();
static UPnPControlPoint* instance();
static UPnPControlPoint* inst;
static QMutex mutex;
Herqq::Upnp::HControlPoint* m_controlPoint;
};
}
}
}
#endif // SOLID_BACKENDS_UPNP_UPNPCONTROLPOINT_H

View file

@ -1,246 +0,0 @@
/*
Copyright 2010 Paulo Romulo Alves Barros <paulo.romulo@kdemail.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "upnpdevice.h"
#include "upnpmediaserver.h"
#include "upnpinternetgateway.h"
#include <HUpnpCore/HResourceType>
#include <HUpnpCore/HDeviceInfo>
#include <HUpnpCore/HUdn>
#include <QtCore/QUrl>
namespace Solid
{
namespace Backends
{
namespace UPnP
{
static QMap<QString, QString> makeTypeIconMap()
{
QMap<QString, QString> ret;
ret.insert("BasicDevice:1", "network-server");
ret.insert("WLANAccessPointDevice:1", "network-wireless");
ret.insert("PrinterBasic:1", "printer");
ret.insert("PrinterEnhanced:1", "printer");
ret.insert("Scanner:1", "scanner");
ret.insert("MediaServer:1", "folder-remote");
ret.insert("MediaServer:2", "folder-remote");
ret.insert("MediaServer:3", "folder-remote");
ret.insert("MediaRenderer:1", "video-television");
ret.insert("MediaRenderer:2", "video-television");
ret.insert("SolarProtectionBlind:1", "device");
ret.insert("DigitalSecurityCamera:1", "camera");
ret.insert("HVAC:1", "device");
ret.insert("LightingControls:1", "light");
ret.insert("RemoteUIClientDevice:1", "device");
ret.insert("RemoteUIServerDevice:1", "device");
ret.insert("RAClient:1", "device");
ret.insert("RAServer:1", "device");
ret.insert("RADiscoveryAgent:1", "device");
ret.insert("Unknown", "device");
ret.insert("InternetGatewayDevice:1", "network-server");
ret.insert("LANDevice:1", "network-wired");
ret.insert("WANDevice:1", "network-wired");
ret.insert("WANConnectionDevice:1", "network-wired");
ret.insert("WFADevice:1", "network-wireless");
return ret;
}
static const QMap<QString, QString> typeIconMap = makeTypeIconMap();
UPnPDevice::UPnPDevice(const Herqq::Upnp::HClientDevice* device) :
Solid::Ifaces::Device(),
m_device(device),
m_specVersion(device->info().deviceType().toString(Herqq::Upnp::HResourceType::Version)),
m_deviceType(device->info().deviceType().toString(Herqq::Upnp::HResourceType::TypeSuffix | Herqq::Upnp::HResourceType::Version))
{
}
UPnPDevice::~UPnPDevice()
{
}
const Herqq::Upnp::HClientDevice* UPnPDevice::device() const
{
return m_device;
}
QString UPnPDevice::udi() const
{
const Herqq::Upnp::HDeviceInfo deviceInfo = device()->info();
if (!deviceInfo.udn().isValid(Herqq::Upnp::LooseChecks))
{
qWarning("This device UDN is not a valid one!");
}
QString udn = deviceInfo.udn().toString();
return QString::fromLatin1("/org/kde/upnp/%1").arg(udn);
}
QString UPnPDevice::parentUdi() const
{
const Herqq::Upnp::HClientDevice* parent = device()->parentDevice();
if (parent)
{
Herqq::Upnp::HDeviceInfo parentInfo = parent->info();
if (!parentInfo.udn().isValid(Herqq::Upnp::LooseChecks))
{
qWarning("This device UDN is not a valid one!");
}
return QString::fromLatin1("/org/kde/upnp/%1").arg(parentInfo.udn().toString());
}
return QString::fromLatin1("/org/kde/upnp");
}
QString UPnPDevice::vendor() const
{
const Herqq::Upnp::HDeviceInfo deviceInfo = device()->info();
QString vendor = deviceInfo.manufacturer();
return vendor;
}
QString UPnPDevice::product() const
{
const Herqq::Upnp::HDeviceInfo deviceInfo = device()->info();
QString model = deviceInfo.modelName();
return model;
}
QString UPnPDevice::icon() const
{
const Herqq::Upnp::HDeviceInfo deviceInfo = device()->info();
if (typeIconMap.contains(deviceType()))
{
return typeIconMap[deviceType()];
}
return QString::fromLatin1("network-server");
}
QStringList UPnPDevice::emblems() const
{
return QStringList();
}
QString UPnPDevice::description() const
{
QString desc = device()->info().friendlyName();
if (desc.isEmpty()) {
QString ipAddress = device()->locations()[0].toString(QUrl::RemoveScheme | QUrl::RemovePort | QUrl::RemovePath).mid(2);
if (isMediaServer()) {
desc = QString::fromLatin1("Media Server on %1").arg(ipAddress);
} else if (isInternetGatewayDevice()) {
desc = QString::fromLatin1("Internet Gateway on %1").arg(ipAddress);
} else {
desc = QString::fromLatin1("UPnP Device on %1").arg(ipAddress);
}
}
return desc;
}
bool UPnPDevice::isMediaServer() const
{
return deviceType().startsWith(QString::fromLatin1("MediaServer"));
}
bool UPnPDevice::isInternetGatewayDevice() const
{
return deviceType().startsWith(QString::fromLatin1("InternetGatewayDevice"));
}
bool UPnPDevice::queryDeviceInterface(const Solid::DeviceInterface::Type& type) const
{
if (type == Solid::DeviceInterface::StorageAccess)
{
if (isMediaServer())
{
return true;
}
else
{
return false;
}
}
else if (type == Solid::DeviceInterface::InternetGateway)
{
if (isInternetGatewayDevice())
{
return true;
}
}
return false;
}
QObject* UPnPDevice::createDeviceInterface(const Solid::DeviceInterface::Type& type)
{
if (type == Solid::DeviceInterface::StorageAccess)
{
if (isMediaServer())
{
return new Solid::Backends::UPnP::UPnPMediaServer(this);
}
else
{
return 0;
}
}
else if (type == Solid::DeviceInterface::InternetGateway)
{
if (isInternetGatewayDevice())
{
return new Solid::Backends::UPnP::UPnPInternetGateway(this);
}
}
return 0;
}
bool UPnPDevice::isValid() const
{
return m_device->info().isValid(Herqq::Upnp::LooseChecks);
}
const QString UPnPDevice::specVersion() const
{
return m_specVersion;
}
const QString UPnPDevice::deviceType() const
{
return m_deviceType;
}
}
}
}

View file

@ -1,85 +0,0 @@
/*
Copyright 2010 Paulo Romulo Alves Barros <paulo.romulo@kdemail.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SOLID_BACKENDS_UPNP_UPNP_DEVICE_H
#define SOLID_BACKENDS_UPNP_UPNP_DEVICE_H
#include <solid/ifaces/device.h>
#include <HUpnpCore/HClientDevice>
namespace Solid
{
namespace Backends
{
namespace UPnP
{
class UPnPDevice : public Solid::Ifaces::Device
{
Q_OBJECT
public:
explicit UPnPDevice(const Herqq::Upnp::HClientDevice* device);
virtual ~UPnPDevice();
virtual QString udi() const;
virtual QString parentUdi() const;
virtual QString vendor() const;
virtual QString product() const;
virtual QString icon() const;
virtual QStringList emblems() const;
virtual QString description() const;
virtual bool queryDeviceInterface(const Solid::DeviceInterface::Type& type) const;
virtual QObject* createDeviceInterface(const Solid::DeviceInterface::Type& type);
bool isValid() const;
const Herqq::Upnp::HClientDevice* device() const;
const QString specVersion() const;
const QString deviceType() const;
bool isMediaServer() const;
bool isInternetGatewayDevice() const;
protected:
const Herqq::Upnp::HClientDevice* m_device;
const QString m_specVersion;
const QString m_deviceType;
};
}
}
}
#endif // SOLID_BACKENDS_UPNP_UPNP_DEVICE_H

View file

@ -1,49 +0,0 @@
/*
Copyright 2010 Paulo Romulo Alves Barros <paulo.romulo@kdemail.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "upnpdeviceinterface.h"
#include <solid/backends/upnp/upnpdevice.h>
namespace Solid
{
namespace Backends
{
namespace UPnP
{
UPnPDeviceInterface::UPnPDeviceInterface(Solid::Backends::UPnP::UPnPDevice* device) :
QObject(device),
m_upnpDevice(device)
{
}
UPnPDeviceInterface::~UPnPDeviceInterface()
{
}
const Solid::Backends::UPnP::UPnPDevice* UPnPDeviceInterface::upnpDevice() const
{
return m_upnpDevice;
}
}
}
}

View file

@ -1,58 +0,0 @@
/*
Copyright 2010 Paulo Romulo Alves Barros <paulo.romulo@kdemail.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SOLID_BACKENDS_UPNP_DEVICE_INTERFACE_H
#define SOLID_BACKENDS_UPNP_DEVICE_INTERFACE_H
#include <solid/ifaces/deviceinterface.h>
#include <solid/backends/upnp/upnpdevice.h>
#include <QtCore/QObject>
namespace Solid
{
namespace Backends
{
namespace UPnP
{
class UPnPDeviceInterface : public QObject, virtual public Solid::Ifaces::DeviceInterface
{
Q_OBJECT
Q_INTERFACES(Solid::Ifaces::DeviceInterface)
public:
explicit UPnPDeviceInterface(Solid::Backends::UPnP::UPnPDevice* device);
virtual ~UPnPDeviceInterface();
public:
const Solid::Backends::UPnP::UPnPDevice* upnpDevice() const;
private:
const Solid::Backends::UPnP::UPnPDevice* m_upnpDevice;
};
}
}
}
#endif // SOLID_BACKENDS_UPNP_DEVICE_INTERFACE_H

View file

@ -1,148 +0,0 @@
/*
Copyright 2010 Paulo Romulo Alves Barros <paulo.romulo@kdemail.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "upnpdevicemanager.h"
#include "upnpdevice.h"
#include <QtCore/qdebug.h>
#include <QtCore/QList>
#include <QtCore/QMap>
#include <HUpnpCore/HDiscoveryType>
#include <HUpnpCore/HDeviceInfo>
#include <HUpnpCore/HClientDevice>
#include <HUpnpCore/HUdn>
#include "../shared/rootdevice.h"
using namespace Solid::Backends::UPnP;
using namespace Solid::Backends::Shared;
UPnPDeviceManager::UPnPDeviceManager(QObject* parent) :
Solid::Ifaces::DeviceManager(parent),
m_supportedInterfaces()
//m_upnpControlPoint(Solid::Backends::UPnP::UPnPControlPoint::instance())
{
UPnPControlPoint* upnpControlPoint = UPnPControlPoint::acquireInstance();
connect(
upnpControlPoint->controlPoint(),
SIGNAL(rootDeviceOnline(Herqq::Upnp::HClientDevice*)),
this,
SLOT(rootDeviceOnline(Herqq::Upnp::HClientDevice*)));
connect(
upnpControlPoint->controlPoint(),
SIGNAL(rootDeviceOffline(Herqq::Upnp::HClientDevice*)),
this,
SLOT(rootDeviceOffline(Herqq::Upnp::HClientDevice*)));
UPnPControlPoint::releaseInstance();
m_supportedInterfaces << Solid::DeviceInterface::StorageAccess;
}
UPnPDeviceManager::~UPnPDeviceManager()
{
}
QString UPnPDeviceManager::udiPrefix() const
{
return QString::fromLatin1("/org/kde/upnp");
}
QSet< Solid::DeviceInterface::Type > UPnPDeviceManager::supportedInterfaces() const
{
return m_supportedInterfaces;
}
QStringList UPnPDeviceManager::allDevices()
{
QStringList result;
result << udiPrefix();
UPnPControlPoint* upnpControlPoint = UPnPControlPoint::acquireInstance();
result+= upnpControlPoint->allDevices();
UPnPControlPoint::releaseInstance();
return result;
}
QStringList UPnPDeviceManager::devicesFromQuery(const QString& parentUdi, Solid::DeviceInterface::Type type)
{
Q_UNUSED(parentUdi)
Q_UNUSED(type)
return QStringList(); //FIXME implement it!
}
QObject *UPnPDeviceManager::createDevice(const QString& udi)
{
if (udi==udiPrefix()) {
RootDevice *root = new RootDevice(udiPrefix());
root->setProduct(tr("UPnP Devices"));
root->setDescription(tr("UPnP devices detected on your network"));
root->setIcon("network-server");
return root;
}
QString udnFromUdi = udi.mid(udiPrefix().length() + 1);
Herqq::Upnp::HUdn udn(udnFromUdi);
if (udn.isValid(Herqq::Upnp::LooseChecks))
{
UPnPControlPoint* upnpControlPoint = UPnPControlPoint::acquireInstance();
Herqq::Upnp::HClientDevice* device = upnpControlPoint->controlPoint()->device(udn);
UPnPControlPoint::releaseInstance();
if (device)
{
return new Solid::Backends::UPnP::UPnPDevice(device);
}
}
return 0;
}
void UPnPDeviceManager::rootDeviceOnline(Herqq::Upnp::HClientDevice* device)
{
QString udn = device->info().udn().toString();
qDebug() << "UPnP device entered:" << udn;
emit deviceAdded(udiPrefix() + '/' + udn);
}
void UPnPDeviceManager::rootDeviceOffline(Herqq::Upnp::HClientDevice* device)
{
QString udn = device->info().udn().toString();
qDebug() << "UPnP device gone:" << udn;
emit deviceRemoved(udiPrefix() + '/' + udn);
UPnPControlPoint* upnpControlPoint = UPnPControlPoint::acquireInstance();
upnpControlPoint->controlPoint()->removeRootDevice(device);
UPnPControlPoint::releaseInstance();
}

View file

@ -1,75 +0,0 @@
/*
Copyright 2010 Paulo Romulo Alves Barros <paulo.romulo@kdemail.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SOLID_BACKENDS_UPNP_UPNP_DEVICE_MANAGER_H
#define SOLID_BACKENDS_UPNP_UPNP_DEVICE_MANAGER_H
#include <solid/ifaces/devicemanager.h>
#include <QtCore/QSet>
#include <QtCore/QStringList>
#include <HUpnpCore/HClientDevice>
#include <HUpnpCore/HControlPoint>
#include "upnpcontrolpoint.h"
namespace Solid
{
namespace Backends
{
namespace UPnP
{
class UPnPDeviceManager : public Solid::Ifaces::DeviceManager
{
Q_OBJECT
public:
explicit UPnPDeviceManager(QObject* parent = 0);
virtual ~UPnPDeviceManager();
virtual QString udiPrefix() const;
virtual QSet<Solid::DeviceInterface::Type> supportedInterfaces() const;
virtual QStringList allDevices();
virtual QStringList devicesFromQuery(const QString &parentUdi, Solid::DeviceInterface::Type type = Solid::DeviceInterface::Unknown);
virtual QObject *createDevice(const QString &udi);
public Q_SLOTS:
void rootDeviceOnline(Herqq::Upnp::HClientDevice*);
void rootDeviceOffline(Herqq::Upnp::HClientDevice*);
private:
QSet<Solid::DeviceInterface::Type> m_supportedInterfaces;
//Solid::Backends::UPnP::UPnPControlPoint* m_upnpControlPoint;
};
}
}
}
#endif // SOLID_BACKENDS_UPNP_UPNP_DEVICE_MANAGER_H

View file

@ -1,404 +0,0 @@
/*
Copyright 2010 Paulo Romulo Alves Barros <paulo.romulo@kdemail.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "upnpinternetgateway.h"
#include <HUpnpCore/HDeviceInfo>
#include <HUpnpCore/HServiceId>
#include <HUpnpCore/HClientAction>
#include <HUpnpCore/HActionInfo>
#include <HUpnpCore/HActionArguments>
#include <HUpnpCore/HClientStateVariable>
#include <QtCore/qdebug.h>
namespace Solid
{
namespace Backends
{
namespace UPnP
{
UPnPInternetGateway::UPnPInternetGateway(UPnPDevice* device) :
UPnPDeviceInterface(device),
activeConnections(QStringList())
{
numberOfConnections = 0;
}
UPnPInternetGateway::~UPnPInternetGateway()
{
}
void UPnPInternetGateway::setEnabledForInternet(bool enabled) const
{
Herqq::Upnp::HClientDevices embeddedDevices = upnpDevice()->device()->embeddedDevices();
Herqq::Upnp::HClientDevice* wanDevice = getDevice(QString::fromLatin1("WANDevice"), embeddedDevices);
if (wanDevice) {
Herqq::Upnp::HClientService* wanCommonIfaceConfigService = wanDevice->serviceById(Herqq::Upnp::HServiceId("urn:upnp-org:serviceId:WANCommonInterfaceConfig"));
if (wanCommonIfaceConfigService) {
Herqq::Upnp::HClientAction* setEnabledForInternetAction = wanCommonIfaceConfigService->actions()[QString::fromLatin1("SetEnabledForInternet")];
if (setEnabledForInternetAction) {
Herqq::Upnp::HActionArguments inArgs = setEnabledForInternetAction->info().inputArguments();
inArgs["NewEnabledForInternet"].setValue(enabled);
connect(setEnabledForInternetAction,
SIGNAL(invokeComplete(Herqq::Upnp::HClientAction*,Herqq::Upnp::HClientActionOp)),
this,
SLOT(setEnabledForInternetInvokeCallback(Herqq::Upnp::HClientAction*,Herqq::Upnp::HClientActionOp)));
qDebug() << "setEnabledForInternetAction begin invoke";
Herqq::Upnp::HClientActionOp id = setEnabledForInternetAction->beginInvoke(inArgs);
} else {
qWarning() << "Unable to retrieve SetEnabledForInternet action for this device:" << upnpDevice()->udi();
qWarning() << "Maybe the device doesn't implement, since it's an optional action. See the service description XML.";
}
} else {
qWarning() << "Unable to retrieve WANCommonInterfaceConfig service for this device:" << upnpDevice()->udi();
}
} else {
qWarning() << "Unable to retrieve WANDevice for this device:" << upnpDevice()->udi();
}
}
void UPnPInternetGateway::setEnabledForInternetInvokeCallback(Herqq::Upnp::HClientAction *action, const Herqq::Upnp::HClientActionOp &invocationID)
{
qDebug() << "setEnabledForInternetAction callback";
Herqq::Upnp::HClientAction* setEnabledForInternetAction = action;
if (invocationID.returnValue() == Herqq::Upnp::UpnpSuccess) {
qDebug() << "setEnabledForInternetAction invocation successful";
Herqq::Upnp::HActionArguments inArgs = setEnabledForInternetAction->info().inputArguments();
bool enabled = inArgs["NewEnabledForInternet"].value().toBool();
emit enabledForInternet(enabled);
} else {
qDebug() << "setEnabledForInternetAction invocation failed";
}
}
Herqq::Upnp::HClientDevice* UPnPInternetGateway::getDevice(const QString typePreffix, Herqq::Upnp::HClientDevices& devices) const
{
foreach(Herqq::Upnp::HClientDevice* device, devices) {
QString deviceType = device->info().deviceType().toString(Herqq::Upnp::HResourceType::TypeSuffix |
Herqq::Upnp::HResourceType::Version);
if (deviceType.startsWith(typePreffix)) {
return device;
};
}
return 0;
}
Solid::InternetGateway::InternetStatus UPnPInternetGateway::isEnabledForInternet() const
{
Herqq::Upnp::HClientDevices embeddedDevices = upnpDevice()->device()->embeddedDevices();
Herqq::Upnp::HClientDevice* wanDevice = getDevice(QString::fromLatin1("WANDevice"), embeddedDevices);
if (wanDevice) {
Herqq::Upnp::HClientService* wanCommonIfaceConfigService = wanDevice->serviceById(Herqq::Upnp::HServiceId("urn:upnp-org:serviceId:WANCommonInterfaceConfig"));
if (wanCommonIfaceConfigService) {
const Herqq::Upnp::HClientStateVariable* enabledForInternetVariable = wanCommonIfaceConfigService->stateVariables()[QString::fromLatin1("EnabledForInternet")];
if (enabledForInternetVariable) {
bool enabled = enabledForInternetVariable->value().toBool();
return enabled ? Solid::InternetGateway::InternetEnabled : Solid::InternetGateway::InternetDisabled;
} else {
qWarning() << "Unable to retrieve EnabledForInternet state variable for this device:" << upnpDevice()->udi();
qWarning() << "Maybe the device doesn't implement, since it's optional. See the service description XML.";
return Solid::InternetGateway::UnknownStatus;
}
} else {
qWarning() << "Unable to retrieve WANCommonInterfaceConfig service for this device:" << upnpDevice()->udi();
return Solid::InternetGateway::UnknownStatus;
}
} else {
qWarning() << "Unable to retrieve WANDevice for this device:" << upnpDevice()->udi();
return Solid::InternetGateway::UnknownStatus;
}
}
void UPnPInternetGateway::deletePortMapping(const QString& remoteHost, qint16 externalPort, const Solid::InternetGateway::NetworkProtocol& mappingProtocol)
{
Herqq::Upnp::HClientDevices embeddedDevices = upnpDevice()->device()->embeddedDevices();
Herqq::Upnp::HClientDevice* wanDevice = getDevice(QString::fromLatin1("WANDevice"), embeddedDevices);
if (wanDevice) {
Herqq::Upnp::HClientService* wanConnectionService = getWANConnectionService(wanDevice);
if (wanConnectionService) {
Herqq::Upnp::HClientAction* deletePortMappingAction = wanConnectionService->actions()[QString::fromLatin1("DeletePortMapping")];
if (deletePortMappingAction) {
Herqq::Upnp::HActionArguments inArgs = deletePortMappingAction->info().inputArguments();
inArgs["NewRemoteHost"].setValue(remoteHost);
inArgs["NewExternalPort"].setValue(externalPort);
if (mappingProtocol == Solid::InternetGateway::TCP) {
inArgs["NewProtocol"].setValue(QString::fromLatin1("TCP"));
} else {
inArgs["NewProtocol"].setValue(QString::fromLatin1("UDP"));
}
connect(deletePortMappingAction,
SIGNAL(invokeComplete(Herqq::Upnp::HClientAction*,Herqq::Upnp::HClientActionOp)),
this,
SLOT(deletePortMappingInvokeCallback(Herqq::Upnp::HClientAction*,Herqq::Upnp::HClientActionOp)));
qDebug() << "deletePortMappingAction begin invoke";
qDebug() << "inArgs:"
<< inArgs["NewRemoteHost"].value().toString()
<< inArgs["NewExternalPort"].value().toInt()
<< inArgs["NewProtocol"].value().toString();
Herqq::Upnp::HClientActionOp id = deletePortMappingAction->beginInvoke(inArgs);
} else {
qWarning() << "Unable to retrieve DeletePortMapping action for this device:" << upnpDevice()->udi();
}
} else {
qWarning() << "Unable to retrieve WAN*Connection (* = {IP, PPP}) service for this device:" << upnpDevice()->udi();
}
} else {
qWarning() << "Unable to retrieve WANDevice for this device:" << upnpDevice()->udi();
}
}
void UPnPInternetGateway::deletePortMappingInvokeCallback(Herqq::Upnp::HClientAction *action, const Herqq::Upnp::HClientActionOp &invocationID)
{
qDebug() << "deletePortMappingAction callback";
Herqq::Upnp::HClientAction* deletePortMappingAction = action;
if (invocationID.returnValue() == Herqq::Upnp::UpnpSuccess) {
qDebug() << "deletePortMapping Action invocation successful" << invocationID.returnValue();
Herqq::Upnp::HActionArguments inArgs = deletePortMappingAction->info().inputArguments();
QString newRemoteHost = inArgs["NewRemoteHost"].value().toString();
int newExternalPort = inArgs["NewExternalPort"].value().toInt();
QString newProtocol = inArgs["NewProtocol"].value().toString();
Solid::InternetGateway::NetworkProtocol protocol;
if (newProtocol == QString::fromLatin1("TCP")) {
protocol = Solid::InternetGateway::TCP;
} else {
protocol = Solid::InternetGateway::UDP;
}
emit portMappingDeleted(newRemoteHost, newExternalPort, protocol);
} else {
qDebug() << "deletePortMapping Action invocation failed";
}
}
Herqq::Upnp::HClientService* UPnPInternetGateway::getWANConnectionService(Herqq::Upnp::HClientDevice* device) const
{
Herqq::Upnp::HClientDevices embeddedDevices = device->embeddedDevices();
Herqq::Upnp::HClientDevice* wanConnectionDevice = getDevice(QString::fromLatin1("WANConnectionDevice"), embeddedDevices);
Herqq::Upnp::HClientService* service = 0;
service = wanConnectionDevice->serviceById(Herqq::Upnp::HServiceId("urn:upnp-org:serviceId:WANPPPConnection"));
if (service)
return service;
service = wanConnectionDevice->serviceById(Herqq::Upnp::HServiceId("urn:upnp-org:serviceId:WANIPConnection"));
return service;
}
void UPnPInternetGateway::addPortMapping(const QString& remoteHost, qint16 externalPort, const Solid::InternetGateway::NetworkProtocol& mappingProtocol,
qint16 internalPort, const QString& internalClient)
{
Herqq::Upnp::HClientDevices embeddedDevices = upnpDevice()->device()->embeddedDevices();
Herqq::Upnp::HClientDevice* wanDevice = getDevice(QString::fromLatin1("WANDevice"), embeddedDevices);
if (wanDevice) {
Herqq::Upnp::HClientService* wanConnectionService = getWANConnectionService(wanDevice);
if (wanConnectionService) {
Herqq::Upnp::HClientAction* addPortMappingAction = wanConnectionService->actions()[QString::fromLatin1("AddPortMapping")];
if (addPortMappingAction) {
Herqq::Upnp::HActionArguments inArgs = addPortMappingAction->info().inputArguments();
inArgs["NewRemoteHost"].setValue(remoteHost);
inArgs["NewExternalPort"].setValue(externalPort);
if (mappingProtocol == Solid::InternetGateway::TCP) {
inArgs["NewProtocol"].setValue(QString::fromLatin1("TCP"));
} else {
inArgs["NewProtocol"].setValue(QString::fromLatin1("UDP"));
}
inArgs["NewInternalPort"].setValue(internalPort);
inArgs["NewInternalClient"].setValue(internalClient);
inArgs["NewEnabled"].setValue(true);
inArgs["NewPortMappingDescription"].setValue(QString());
inArgs["NewLeaseDuration"].setValue(0);
connect(addPortMappingAction,
SIGNAL(invokeComplete(Herqq::Upnp::HClientAction*,Herqq::Upnp::HClientActionOp)),
this,
SLOT(addPortMappingInvokeCallback(Herqq::Upnp::HClientAction*,Herqq::Upnp::HClientActionOp)));
qDebug() << "addPortMappingAction begin invoke";
qDebug() << "inArgs:"
<< inArgs["NewRemoteHost"].value().toString()
<< inArgs["NewExternalPort"].value().toInt()
<< inArgs["NewProtocol"].value().toString()
<< inArgs["NewInternalPort"].value().toInt()
<< inArgs["NewInternalClient"].value().toString()
<< inArgs["NewEnabled"].value().toBool()
<< inArgs["NewPortMappingDescription"].value().toString()
<< inArgs["NewLeaseDuration"].value().toLongLong();
Herqq::Upnp::HClientActionOp id = addPortMappingAction->beginInvoke(inArgs);
} else {
qWarning() << "Unable to retrieve AddPortMapping action for this device:" << upnpDevice()->udi();
}
} else {
qWarning() << "Unable to retrieve WAN*Connection (* = {IP, PPP}) service for this device:" << upnpDevice()->udi();
}
} else {
qWarning() << "Unable to retrieve WANDevice for this device:" << upnpDevice()->udi();
}
}
void UPnPInternetGateway::addPortMappingInvokeCallback(Herqq::Upnp::HClientAction *action, const Herqq::Upnp::HClientActionOp &invocationID)
{
qDebug() << "addPortMappingAction callback";
Herqq::Upnp::HClientAction* addPortMappingAction = action;
if (invocationID.returnValue() == Herqq::Upnp::UpnpSuccess) {
qDebug() << "addPortMapping Action invocation successful" << invocationID.returnValue();
Herqq::Upnp::HActionArguments inArgs = addPortMappingAction->info().inputArguments();
QString newRemoteHost = inArgs["NewRemoteHost"].value().toString();
int newExternalPort = inArgs["NewExternalPort"].value().toInt();
QString newProtocol = inArgs["NewProtocol"].value().toString();
Solid::InternetGateway::NetworkProtocol protocol;
if (newProtocol == QString::fromLatin1("TCP")) {
protocol = Solid::InternetGateway::TCP;
} else {
protocol = Solid::InternetGateway::UDP;
}
int newInternalPort = inArgs["NewInternalPort"].value().toInt();
QString newInternalClient = inArgs["NewInternalClient"].value().toString();
emit portMappingAdded(newRemoteHost, newExternalPort, protocol, newInternalPort, newInternalClient);
} else {
qDebug() << "addPortMapping Action invocation failed" << invocationID.returnValue();
}
}
int UPnPInternetGateway::getNumberOfActiveConnections()
{
Herqq::Upnp::HClientDevices embeddedDevices = upnpDevice()->device()->embeddedDevices();
Herqq::Upnp::HClientDevice* wanDevice = getDevice(QString::fromLatin1("WANDevice"), embeddedDevices);
if (wanDevice) {
Herqq::Upnp::HClientService* wanCommonIfaceConfigService = wanDevice->serviceById(Herqq::Upnp::HServiceId("urn:upnp-org:serviceId:WANCommonInterfaceConfig"));
if (wanCommonIfaceConfigService) {
const Herqq::Upnp::HClientStateVariable* numberOfActiveConnections = wanCommonIfaceConfigService->stateVariables()[QString::fromLatin1("NumberOfActiveConnections")];
if (numberOfActiveConnections) {
int number = numberOfActiveConnections->value().toInt();
numberOfConnections = number;
return number;
} else {
qWarning() << "Unable to retrieve NumberOfActiveConnections state variable for this device:" << upnpDevice()->udi();
qWarning() << "Maybe the device doesn't implement, since it's optional. See the service description XML.";
return -1;
}
} else {
qWarning() << "Unable to retrieve WANCommonInterfaceConfig service for this device:" << upnpDevice()->udi();
return -1;
}
} else {
qWarning() << "Unable to retrieve WANDevice for this device:" << upnpDevice()->udi();
return -1;
}
}
void UPnPInternetGateway::requestCurrentConnections()
{
Herqq::Upnp::HClientDevices embeddedDevices = upnpDevice()->device()->embeddedDevices();
Herqq::Upnp::HClientDevice* wanDevice = getDevice(QString::fromLatin1("WANDevice"), embeddedDevices);
if (wanDevice) {
Herqq::Upnp::HClientService* wanCommonIfaceConfigService = wanDevice->serviceById(Herqq::Upnp::HServiceId("urn:upnp-org:serviceId:WANCommonInterfaceConfig"));
if (wanCommonIfaceConfigService) {
Herqq::Upnp::HClientAction* getActiveConnectionAction = wanCommonIfaceConfigService->actions()[QString::fromLatin1("GetActiveConnection")];
if (getActiveConnectionAction) {
int numberOfActiveConnections = getNumberOfActiveConnections();
if (numberOfActiveConnections > 0) {
connect(getActiveConnectionAction,
SIGNAL(invokeComplete(Herqq::Upnp::HClientAction*,Herqq::Upnp::HClientActionOp)),
this,
SLOT(getActiveConnectionActionInvokeCallback(Herqq::Upnp::HClientAction*,Herqq::Upnp::HClientActionOp)));
for (int i = 0; i < numberOfActiveConnections; ++i) {
Herqq::Upnp::HActionArguments inArgs = getActiveConnectionAction->info().inputArguments();
inArgs["NewActiveConnectionIndex"].setValue(i);
qDebug() << "getActiveConnectionAction begin invoke" << i;
Herqq::Upnp::HClientActionOp id = getActiveConnectionAction->beginInvoke(inArgs);
}
}
} else {
qWarning() << "Unable to retrieve GetActiveConnection action for this device:" << upnpDevice()->udi();
qWarning() << "Maybe the device doesn't implement, since it's an optional action. See the service description XML.";
}
} else {
qWarning() << "Unable to retrieve WANCommonInterfaceConfig service for this device:" << upnpDevice()->udi();
}
} else {
qWarning() << "Unable to retrieve WANDevice for this device:" << upnpDevice()->udi();
}
}
void UPnPInternetGateway::getActiveConnectionActionInvokeCallback(Herqq::Upnp::HClientAction *action, const Herqq::Upnp::HClientActionOp &invocationID)
{
qDebug() << "getActiveConnectionAction callback";
Herqq::Upnp::HActionArguments outArgs = invocationID.outputArguments();
Herqq::Upnp::HClientAction* getActiveConnectionAction = action;
if (invocationID.returnValue() == Herqq::Upnp::UpnpSuccess) {
qDebug() << "getActiveConnection Action invocation successful" << invocationID.returnValue();
QString conn = outArgs["ActiveConnectionDeviceContainer"].value().toString();
activeConnections << conn;
} else {
qDebug() << "getActiveConnection Action invocation failed";
}
if (activeConnections.count() == numberOfConnections) {
emit currentConnectionsDataIsReady(activeConnections);
}
}
QStringList UPnPInternetGateway::currentConnections() const
{
return activeConnections;
}
}
}
}

View file

@ -1,97 +0,0 @@
/*
Copyright 2010 Paulo Romulo Alves Barros <paulo.romulo@kdemail.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SOLID_BACKENDS_UPNP_UPNPINTERNETGATEWAY_H
#define SOLID_BACKENDS_UPNP_UPNPINTERNETGATEWAY_H
#include <solid/ifaces/internetgateway.h>
#include "upnpdeviceinterface.h"
#include <HUpnpCore/HClientActionOp>
#include <HUpnpCore/HClientDevice>
#include <HUpnpCore/HClientService>
namespace Solid
{
namespace Backends
{
namespace UPnP
{
class UPnPInternetGateway : public Solid::Backends::UPnP::UPnPDeviceInterface, virtual public Solid::Ifaces::InternetGateway
{
Q_OBJECT
Q_INTERFACES(Solid::Ifaces::InternetGateway)
public:
explicit UPnPInternetGateway(UPnPDevice* device);
virtual ~UPnPInternetGateway();
virtual void setEnabledForInternet(bool enabled) const;
virtual Solid::InternetGateway::InternetStatus isEnabledForInternet() const;
virtual void deletePortMapping(const QString& remoteHost, qint16 externalPort, const Solid::InternetGateway::NetworkProtocol& mappingProtocol);
virtual void addPortMapping(const QString& remoteHost, qint16 externalPort, const Solid::InternetGateway::NetworkProtocol& mappingProtocol,
qint16 internalPort, const QString& internalClient);
virtual void requestCurrentConnections();
virtual QStringList currentConnections() const;
private:
Herqq::Upnp::HClientDevice* getDevice(const QString typePreffix, Herqq::Upnp::HClientDevices& devices) const;
Herqq::Upnp::HClientService* getWANConnectionService(Herqq::Upnp::HClientDevice* device) const;
int getNumberOfActiveConnections();
QStringList activeConnections;
int numberOfConnections;
private slots:
void setEnabledForInternetInvokeCallback(Herqq::Upnp::HClientAction *action, const Herqq::Upnp::HClientActionOp &invocationID);
void deletePortMappingInvokeCallback(Herqq::Upnp::HClientAction *action, const Herqq::Upnp::HClientActionOp &invocationID);
void addPortMappingInvokeCallback(Herqq::Upnp::HClientAction *action, const Herqq::Upnp::HClientActionOp &invocationID);
void getActiveConnectionActionInvokeCallback(Herqq::Upnp::HClientAction *action, const Herqq::Upnp::HClientActionOp &invocationID);
Q_SIGNALS:
void enabledForInternet(bool enabled);
void portMappingDeleted(const QString& remoteHost, qint16 externalPort, const Solid::InternetGateway::NetworkProtocol& mappingProtocol);
void portMappingAdded(const QString& remoteHost, qint16 externalPort, const Solid::InternetGateway::NetworkProtocol& mappingProtocol,
qint16 internalPort, const QString& internalClient);
void currentConnectionsDataIsReady(QStringList currentConnections);
};
}
}
}
#endif // SOLID_BACKENDS_UPNP_UPNPINTERNETGATEWAY_H

View file

@ -1,95 +0,0 @@
/*
Copyright 2010 Paulo Romulo Alves Barros <paulo.romulo@kdemail.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "upnpmediaserver.h"
#include <HUpnpCore/HDeviceInfo>
#include <HUpnpCore/HUdn>
#include <QtCore/QUrl>
#include <QtCore/QTimer>
namespace Solid
{
namespace Backends
{
namespace UPnP
{
UPnPMediaServer::UPnPMediaServer(UPnPDevice* device) :
UPnPDeviceInterface(device)
{
}
UPnPMediaServer::~UPnPMediaServer()
{
}
bool UPnPMediaServer::isAccessible() const
{
return upnpDevice()->isValid();
}
QString UPnPMediaServer::filePath() const
{
if (isAccessible())
{
QString scheme = "upnp-ms:";
QString udn = upnpDevice()->device()->info().udn().toString();
QString uuid = udn.mid(5); //udn without the uuid: preffix
return (scheme + QString::fromLatin1("//") + uuid);
}
return QString();
}
bool UPnPMediaServer::isIgnored() const
{
return false;
}
bool UPnPMediaServer::setup()
{
QTimer::singleShot(0, this, SLOT(onSetupTimeout()));
return true;
}
bool UPnPMediaServer::teardown()
{
QTimer::singleShot(0, this, SLOT(onTeardownTimeout()));
return true;
}
void UPnPMediaServer::onSetupTimeout()
{
emit setupDone(Solid::NoError, QVariant(), upnpDevice()->udi());
}
void UPnPMediaServer::onTeardownTimeout()
{
emit teardownDone(Solid::NoError, QVariant(), upnpDevice()->udi());
}
}
}
}

View file

@ -1,75 +0,0 @@
/*
Copyright 2010 Paulo Romulo Alves Barros <paulo.romulo@kdemail.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SOLID_BACKENDS_UPNP_STORAGEACCESS_H
#define SOLID_BACKENDS_UPNP_STORAGEACCESS_H
#include <solid/ifaces/storageaccess.h>
#include <solid/backends/upnp/upnpdeviceinterface.h>
namespace Solid
{
namespace Backends
{
namespace UPnP
{
class UPnPMediaServer : public Solid::Backends::UPnP::UPnPDeviceInterface, virtual public Solid::Ifaces::StorageAccess
{
Q_OBJECT
Q_INTERFACES(Solid::Ifaces::StorageAccess)
public:
explicit UPnPMediaServer(UPnPDevice* device);
virtual ~UPnPMediaServer();
virtual bool isAccessible() const;
virtual QString filePath() const;
virtual bool isIgnored() const;
virtual bool setup();
virtual bool teardown();
private Q_SLOTS:
void onSetupTimeout();
void onTeardownTimeout();
Q_SIGNALS:
void accessibilityChanged(bool accessible, const QString &udi);
void setupDone(Solid::ErrorType error, QVariant data, const QString &udi);
void teardownDone(Solid::ErrorType error, QVariant data, const QString &udi);
void setupRequested(const QString &udi);
void teardownRequested(const QString &udi);
};
}
}
}
#endif // SOLID_BACKENDS_UPNP_STORAGEACCESS_H

View file

@ -21,4 +21,3 @@
#cmakedefine ENABLE_TESTING
#cmakedefine UDEV_FOUND
#cmakedefine HUPNP_FOUND

View file

@ -33,10 +33,6 @@
#include "backends/udev/udevmanager.h"
#endif
#if defined(HUPNP_FOUND)
#include "backends/upnp/upnpdevicemanager.h"
#endif
Solid::ManagerBasePrivate::ManagerBasePrivate()
{
}
@ -61,10 +57,6 @@ void Solid::ManagerBasePrivate::loadBackends()
#if defined(UDEV_FOUND)
m_backends << new Solid::Backends::UDev::UDevManager(0);
#endif
#if defined(HUPNP_FOUND)
m_backends << new Solid::Backends::UPnP::UPnPDeviceManager(0);
#endif
}
QList<QObject*> Solid::ManagerBasePrivate::managerBackends() const