<a name="server-tutorial"></a>Writing a UPnP Service</h2></div></div></div>
<div class="simplesect">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
-<a name="idp10638256"></a>Introduction</h2></div></div></div>
+<a name="idp5609200"></a>Introduction</h2></div></div></div>
<p>
This chapter explains how to implement a UPnP service using GUPnP. For
this example we will create a virtual UPnP-enabled light bulb.
</div>
<div class="simplesect">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
-<a name="idp7011344"></a>Defining the Device</h2></div></div></div>
+<a name="idp7391456"></a>Defining the Device</h2></div></div></div>
<p>
The first step is to write the <em class="firstterm">device description</em>
file. This is a short XML document which describes the device and what
</div>
<div class="simplesect">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
-<a name="idp6936832"></a>Defining Services</h2></div></div></div>
+<a name="idm8096"></a>Defining Services</h2></div></div></div>
<p>
Because we are using a standard service we can use the service description
from the specification. This is the <code class="literal">SwitchPower1</code>
</div>
<div class="simplesect">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
-<a name="idp9823184"></a>Implementing the Device</h2></div></div></div>
+<a name="idp6387216"></a>Implementing the Device</h2></div></div></div>
<p>
Before starting to implement the device, some boilerplate code is needed
to initialise GUPnP. GLib types and threading needs to be initialised,
/* Create the GUPnP context with default host and port */
context = gupnp_context_new (NULL, NULL, 0, NULL);</pre>
<p>
- UPnP uses HTTP to provide the device and service description files, so
- next we tell GUPnP to publish them. This is done with
- gupnp_context_host_path() which takes a local filename to send when a
- certain server path is requested.
- </p>
-<pre class="programlisting">gupnp_context_host_path (context, "BinaryLight1.xml", "/BinaryLight1.xml");
-gupnp_context_host_path (context, "SwitchPower1.xml", "/SwitchPower1.xml");</pre>
-<p>
- Next the root device can be created.
+ Next the root device can be created. The name of the device description
+ file can be passed as an absolute file path or a relative path to the
+ second parameter of gupnp_root_device_new(). The service description
+ files referenced in the device description are expected to be at the path
+ given there as well.
</p>
<pre class="programlisting">GUPnPRootDevice *dev;
/* Create the root device object */
-dev = gupnp_root_device_new (context, "/BinaryLight1.xml");
+dev = gupnp_root_device_new (context, "BinaryLight1.xml", ".");
/* Activate the root device, so that it announces itself */
gupnp_root_device_set_available (dev, TRUE);</pre>
<p>
</div>
<div class="simplesect">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
-<a name="idp9829280"></a>Implementing a Service</h2></div></div></div>
+<a name="idp8436720"></a>Implementing a Service</h2></div></div></div>
<p>
To implement a service we first fetch the #GUPnPService from the root
device using gupnp_device_info_get_service() (#GUPnPRootDevice is a
</div>
<div class="simplesect">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
-<a name="idp5162272"></a>Generating Service-specific Wrappers</h2></div></div></div>
+<a name="idp9527792"></a>Generating Service-specific Wrappers</h2></div></div></div>
<p>
Using service-specific wrappers can simplify the implementation of a service.
Wrappers can be generated with <a class="xref" href="gupnp-binding-tool.html" title="gupnp-binding-tool"><span class="refentrytitle">gupnp-binding-tool</span>(1)</a>