[Tests] Fix a typo in the Upload Sync Controller's error management

Signed-off-by: Regis Merlino <regis.merlino@intel.com>
[test] Survive a missing ServiceResetToken in dsc

Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com>
[test] Save changed ServiceResetToken in configuration

Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com>
[Documentation] Fix URL to MediaServer2Spec

This page does not exist yet.

Signed-off-by: Martin Flaska <flegy@flegy.sk>
[Configuration] Remove libdleyna-server .pc file

Fix issue #113: <https://github.com/01org/dleyna-server/issues/113>

Signed-off-by: Ludovic Ferrandis <ludovic.ferrandis@intel.com>
[Server] cosmetics

- Some identation fixes

Signed-off-by: Christophe Guiraud <christophe.guiraud@intel.com>
[Device] Add Energy Management features

- Add a Wake method to DBus MediaDevice interface, this method
can be invoked to wake-up a sleeping device by sending the
appropriate WOL magic packet.
Information to be used for the magic packet formatting will be
retrieved from the device context.

- Add a DLS_INTERFACE_PROP_SLEEPING boolean property to DBus
MediaDevice interface, this property reflects the sleeping
state of the MediaServer.
The property is not present if the Energy Management service
isn't supported by the device embedding the MediaServer.

The DLS_INTERFACE_PROP_SLEEPING property is updated based on
the EM service NetworkInterfaceInfo evented state variable.

The DLS_INTERFACE_PROP_SLEEPING property is set to FALSE by
default at the device construction.

NetworkInterfaceInfo information are XML encoded, relevant
information are parsed with the help of libxml2.
dleyna-server has now a direct dependency on libxml2.
a new xml-util.c file with its header provides libxml2 helpers.
XML extracted information are stored into the matching device
context.
The matching device context is selected based on the interface
ip address and the device uuid.
A device is considered as in sleeping state if its network
interface is up.

- Add a DLS_INTERFACE_PROP_ROOT_UDN string property, if present
this property contains the UDN of the root device embedding a
MediaServer sub-device.

- Update the device contruction to allow the usage of a
MediaServer even if it is sub-device, in the same as way if it
was the root device from the application layer perpective.
We ask now to be notified for all upnp:rootdevice and we filter
those who are MediaServer or have a sub device of this type.
(recursive lookup in the device child hierarchy if any).
Only the first MediaServer device found will be considered.
we also retrieve the Energy Management service proxy from the
root device if it is available and else we use the first one
that we found by doing a recursive lookup in the device child
hierarchy. we use it to be notified of its NetworkInterfaceInfo
evented state variable changes.

- As we have now to handle multiple device proxies (CDS, EMS),
we use now a struct dls_service_t to gather cds and ems services
related information (GUPnPServiceProxy *proxy, gboolean subscribed,
guint timeout_id) in the device context.

- Add the Wake Method to the python test application.

- Documentation updated.

Signed-off-by: Christophe Guiraud <christophe.guiraud@intel.com>
[Device] Add wake packet sending support

- Add the wake method implementation
A bytes buffer is computed from the wake on pattern hex string.
The buffer is sent according to the device wake transport method.
Wake transport methods TCP/UDP unicast and UDP broadcast
are supported.
If the device is not sleeping, the function returns with no error.
The TCP data sending is implemented with GSocketClient. It is done
asynchronously and so can be cancelled.
UDP data sending uses GSocket.
The default wake packet port 9 is used.

Signed-off-by: Christophe Guiraud <christophe.guiraud@intel.com>
[Device] Add sleeping device memory cache

 when the last context of a sleeping device is notified as
unavailable, instead of having the device and its context deleted,
the device is kept alive, the lost server notification is not
broadcasted, the device is moved from the "device_udn_map" to a
"sleeping device udn" map and the context is stored
in a new device structure context field "sleeping_device_context".
All pending operations related to the device will also be cancelled.

The GetServer() request returns now the devices available in the
"sleeping device udn" map in addition to those in the "device udn map".

when a get_prop request is done on a device with a
sleeping_device_context available this one is used to perform the
request.

all Dbus requests other than "get_prop" and "wake" invoked on a device
with a sleeping_device_context available fail with an error
"DLEYNA_ERROR_OPERATION_FAILED".

when a new device proxy is notified as available, if it belongs to the
"sleeping device udn" map, then it is removed from the
"sleeping device udn" map and detroyed, the lost server notification
is then broadcasted. The new proxy device is then constructed as usual.

Signed-off-by: Christophe Guiraud <christophe.guiraud@intel.com>
[Device] Retrieve sleeping state via GetInterfaceInfo action

Some devices may continue to send SSDP messages even if they are
asleep. Thus we cannot assume that a device is awake just because we
can discover it. If a device is dicovered we need to retrieve it's
sleeping state via the UPnP GetInterfaceInfo action.

Signed-off-by: Christophe Guiraud <christophe.guiraud@intel.com>
[Device] Improve Network Interface info and device context matching

- The matching of the Network Interface information with the device
context was previously based on both the IP address and the device UUID.
In the case where no matching is found with this method, another try is
done by just using the device UUID match.
- Optimize the lookup by only adding to the network info list the
element matching the device UUID.
- The device context Network interface info IP address is used for the
wake-on packet sending.
- Fix UDP error initialization.

Signed-off-by: Christophe Guiraud <christophe.guiraud@intel.com>
[Device] Move the network interface info storage

The network interface info which is used for the device wake-on
is now stored in the dls_device_t structure instead of the
dls_device_context_t structure.
This makes more sense since we only store the one network interface
info element (the best matching) whatever the device context count
of a device.

Signed-off-by: Christophe Guiraud <christophe.guiraud@intel.com>
[Device] Improve sleeping context lookup

- Add missing context Ip address idx initialization.
- Use UDP-Broadcast as default wake transport if none is provided
in the network interface info data.

Signed-off-by: Christophe Guiraud <christophe.guiraud@intel.com>
[Device] Sleeping devices cache cleanup

When a sleeping device is removed from the network we persist it
in our memory cache device->sleeping_context to keep possible the
call of its wake method.
This patch delete a sleeping device persisted in memory cache if after
we call its wake method (successfully or not) we have not received any
alive sign from the device for a timeout based on the device LPE estimated
wake-on delay if it can be retrieved or a default one (30 seconds)
if none is provided.

Signed-off-by: Christophe Guiraud <christophe.guiraud@intel.com>
[Device] Fix wake-on ip address used for broadcast

When the wake-on method is UDP broadcast, we now use the broadcast
IP address of the active context newtork interface.
if the broadcast IP address can't be retrieved, we use the IP address
provided in the network interface info.

Signed-off-by: Christophe Guiraud <christophe.guiraud@intel.com>
[Deprecated API] Use new API instead of deprecated

Use instead gssdp_client_get_host_ip of gupnp_context_get_host_ip

Fix issue #104: <https://github.com/01org/dleyna-server/issues/104>

Signed-off-by: Ludovic Ferrandis <ludovic.ferrandis@intel.com>
[upnp] Use "port" setting when creating GUPnPContextManager

Fixes #140.

Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com>