Update gupnp to 0.20.5 (fdeb6f9f)
[profile/ivi/GUPnP.git] / doc / html / server-tutorial.html
index 6af8629..f1ec040 100644 (file)
@@ -24,7 +24,7 @@
 <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="idp5533472"></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.
 <p>
       Before any code can be written, the device and services that it implement
       need to be described in XML.  Although this can be frustrating, if you are
-      implementing a standardised service (see <a class="ulink" href="http://upnp.org/standardizeddcps/" target="_top">http://upnp.org/standardizeddcps/</a> for the list of standard devices
-      and services) then the service description is already written for you and
-      the device description is trivial.  UPnP has standardised <a class="ulink" href="http://upnp.org/standardizeddcps/lighting.asp" target="_top">Lighting
+      implementing a standardised service (see <a class="ulink" href="http://upnp.org/sdcps-and-certification/standards/sdcps/" target="_top">http://upnp.org/sdcps-and-certification/standards/sdcps/</a> for the
+      list of standard devices and services) then the service description is
+      already written for you and the device description is trivial.  UPnP has
+      standardised <a class="ulink" href="http://upnp.org/specs/ha/lighting/" target="_top">Lighting
       Controls</a>, so we'll be using the device and service types defined
       there.
     </p>
 </div>
 <div class="simplesect">
 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
-<a name="idp5617312"></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
-      services it provides (for more details see the <a class="ulink" href="http://upnp.org/specs/arch/UPnP-DeviceArchitecture-v1.0.pdf" target="_top">UPnP
+      services it provides (for more details see the <a class="ulink" href="http://upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.0.pdf" target="_top">UPnP
       Device Architecture</a> specification, section 2.1).  We'll be using
       the <code class="literal">BinaryLight1</code> device type, but if none of the
       existing device types are suitable a custom device type can be created.
 </div>
 <div class="simplesect">
 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
-<a name="idp1676336"></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>
 <p>
       For the full specification of the service definition file, including a
       complete list of valid <code class="sgmltag-element">dataType</code>s, see section 2.3 of
-      the <a class="ulink" href="http://upnp.org/specs/arch/UPnP-DeviceArchitecture-v1.0.pdf" target="_top">UPnP
+      the <a class="ulink" href="http://upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.0.pdf" target="_top">UPnP
       Device Architecture</a>.
     </p>
 </div>
 <div class="simplesect">
 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
-<a name="idp1669600"></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,
     </p>
 <pre class="programlisting">GUPnPContext *context;
 /* Initialize required subsystems */
-g_type_init ();
+#if !GLIB_CHECK_VERSION(2,35,0)
+  g_type_init ();
+#endif
 /* 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>
@@ -246,7 +245,7 @@ gupnp_root_device_set_available (dev, TRUE);</pre>
 </div>
 <div class="simplesect">
 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
-<a name="idp1673360"></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
@@ -355,7 +354,7 @@ g_signal_connect (service, "query-variable::Status", G_CALLBACK (query_status_cb
 </div>
 <div class="simplesect">
 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
-<a name="idp3428664"></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>