[telepathy-doc/master] Drop raw dbus-glib, it's not useful || massively rework Python section

Davyd Madeley davyd at madeley.id.au
Fri Apr 3 02:38:32 PDT 2009


---
 docs/book/C/basics.xml                             |  323 ++++++--------------
 docs/examples/basics_dbus_glib_methods/Makefile.am |    7 -
 docs/examples/basics_dbus_glib_methods/main.c      |  113 -------
 .../basics_dbus_glib_properties/Makefile.am        |    7 -
 docs/examples/basics_dbus_glib_properties/main.c   |   99 ------
 docs/examples/basics_dbus_glib_signals/Makefile.am |    7 -
 docs/examples/basics_dbus_glib_signals/main.c      |   71 -----
 docs/examples/python_simple_presence/example.py    |   12 +-
 8 files changed, 104 insertions(+), 535 deletions(-)
 delete mode 100644 docs/examples/basics_dbus_glib_methods/Makefile.am
 delete mode 100644 docs/examples/basics_dbus_glib_methods/main.c
 delete mode 100644 docs/examples/basics_dbus_glib_properties/Makefile.am
 delete mode 100644 docs/examples/basics_dbus_glib_properties/main.c
 delete mode 100644 docs/examples/basics_dbus_glib_signals/Makefile.am
 delete mode 100644 docs/examples/basics_dbus_glib_signals/main.c

diff --git a/docs/book/C/basics.xml b/docs/book/C/basics.xml
index bb9c05b..b66bd56 100644
--- a/docs/book/C/basics.xml
+++ b/docs/book/C/basics.xml
@@ -373,10 +373,6 @@
      process.
     </para>
 
-    <!--
-    <para>In these examples, we use the FreeDesktop <literal>Notification</literal> system, which should be available on most modern Linux installations. The examples should cause a message to popup from your desktop panel. Note that, like Telepathy, this service is available on the <indexterm><primary>Session Bus</primary></indexterm><literal>Session Bus</literal> rather than the <indexterm><primary>System Bus</primary></indexterm><literal>System Bus</literal>. Services on the <literal>Session Bus</literal> are for the current user's session only. Services on the <literal>System Bus</literal> are shared between all users.</para>
-    -->
-
     <warning id="warning.dbus.sync">
       <title>Always Avoid Synchronous D-Bus Calls</title>
       <!-- this information came from
@@ -479,207 +475,88 @@
 
      <!-- FIXME: should write more here -->
     </sect2>
+   </sect1>
 
-    <sect2 id="sect.basics.dbus.glib">
-      <title>Using D-Bus from C, with glib</title>
+   <sect1 id="sect.basics.language-bindings">
+    <title>Language Bindings</title>
+    <para>
+     As mentioned in <xref linkend="sect.basics.dbus"/>, many programming
+     languages have their own generic ways of using D-Bus APIs. In addition,
+     there are some Telepathy-specific APIs to make the use of Telepathy
+     easier. For instance,
+     <ulink url="http://telepathy.freedesktop.org/wiki/Telepathy%20GLib">telepathy-glib</ulink>
+     provides an API that aims to be more familiar to users of Glib and GTK+.
+     Likewise,
+     <ulink url="http://telepathy.freedesktop.org/wiki/TelepathyQt">Telepathy-Qt</ulink>
+     provides a Qt API for Telepathy and
+     <ulink url="http://telepathy.freedesktop.org/wiki/Telepathy%20Python">Telepathy-Python</ulink> for Python.
+    </para>
 
-      <!-- FIXME: something about dbus-glib
-                  link to
-		  http://dbus.freedesktop.org/doc/dbus-tutorial.html#glib-client
-       -->
+    <para>
+     Remember that, like raw use of D-Bus from these programming languages,
+     the Telepathy language bindings only create <literal>proxies</literal>
+     to the D-Bus objects, providing a way to use their API. The actual
+     objects are instantiated in the service's process.
+    </para>
+    
+    <sect2 id="sect.basics.dbus.language-bindings.python">
+      <title>telepathy-python</title>
 
       <para>
-       Before any method calls can be made or signals connected, via
-       D-Bus, we need to make a connection to the message bus we wish to
-       use (e.g. the system bus, the session bus or some private bus).
-       Generally an application only makes one connection to each bus.
-       <xref linkend="dbus-glib-methods-get-bus"/> shows how to create a
-       connection to a user's session bus.
+       <application>telepathy-python</application> builds on top of the
+       standard <literal>dbus</literal> module for Python.
+       The <literal>telepathy</literal> module provides some convenience
+       classes, as well as enumerations and interface names.
+       If you're planning on using the GLib mainloop you'll also
+       need the <literal>dbus.mainloop.glib</literal> module.
       </para>
 
-      <example id="dbus-glib-methods-get-bus"
-               file="basics_dbus_glib_methods/main.c">
-       <title>Connecting to a Message Bus</title>
-      </example>
-
       <para>
-       In order to interact with a D-Bus object (i.e. call methods or
-       connect signals) we need to create a proxy object for it. A proxy
-       object is a <classname>GObject</classname> that we call methods on
-       in our application. <xref linkend="dbus-glib-methods-get-proxy"/>
-       shows connecting up a proxy object for the desktop notification
-       service.
+       The <literal>telepathy.client</literal> provides the client D-Bus
+       proxy objects. The <literal>telepathy.interfaces</literal> provides
+       the names of Telepathy interfaces (e.g.
+       <literal>CONNECTION_MANAGER</literal>,
+       <literal>CONNECTION_INTERFACE_REQUESTS</literal>,
+       <literal>CHANNEL_TYPE_CONTACT_LIST</literal>, etc.). The
+       <literal>telepathy.constants</literal> module provides named
+       constants in the Telepathy spec (e.g.
+       <literal>CONNECTION_STATUS_CONNECTED</literal>,
+       <literal>HANDLE_TYPE_GROUP</literal>).
       </para>
-      <example id="dbus-glib-methods-get-proxy"
-               file="basics_dbus_glib_methods/main.c">
-       <title>Acquiring a Proxy Object</title>
-      </example>
-
-      <sect3 id="sect.basics.dbus.glib.methods">
-       <title>Calling Methods</title>
-       <para>
-        Method calls in D-Bus should <emphasis>always</emphasis> be made
-        asynchronously, for the reasons
-	outlined in <xref linkend="warning.dbus.sync"/>.
-	<literal>dbus-glib</literal> offers a synchronous way
-	to make method calls, but you should never use it,
-       </para>
-       <para>
-	In <literal>dbus-glib</literal>, method calls are made with the function
-        <function>dbus_g_proxy_begin_call</function>,
-        which takes as its arguments the name of a D-Bus method to call,
-        a callback function to handle the reply, optional user data and the
-        parameters (and types) for the D-Bus method.
-       </para>
-       <para>
-        <xref linkend="dbus-glib-methods-call-method"/> shows calling the
-        D-Bus method <methodname>Notify</methodname> on the previously
-        acquired proxy.
-       </para>
-       
-       <example id="dbus-glib-methods-call-method"
-                file="basics_dbus_glib_methods/main.c">
-        <title>Calling a Method</title>
-       </example>
-
-       <para>
-        In your reply callback, use the function
-        <function>dbus_g_proxy_end_call</function>
-        to collect the return values from the method call. This function can
-        be called outside of the reply callback, but if it is called before
-        the reply has been received, it will block; causing the same problems
-        as synchronous D-Bus calls.
-       </para>
-       <para>
-        <xref linkend="dbus-glib-methods-call-method-subroutine"/> shows a
-        reply callback for the method call above.
-       </para>
-       
-       <example id="dbus-glib-methods-call-method-subroutine"
-                file="basics_dbus_glib_methods/main.c">
-        <title>Calling a Method: Reply Callback</title>
-       </example>
-
-       <important>
-        <para>
-	 Telepathy's <application>telepathy-glib</application> generated
-	 bindings use a different calling convention to raw dbus-glib, that
-	 is considerably simpler as the types are already known. This
-	 is covered in
-	 <xref linkend="sect.basics.language-bindings.telepathy-glib.generated"/>.
-	</para>
-       </important>
-      </sect3>
-
-      <sect3 id="sect.basics.dbus.glib.properties">
-       <title>Using Properties</title>
-       <para>
-        D-Bus properties are available via an additional
-        <ulink url="&url_dbus_spec_base;standard-interfaces-properties"><interfacename>org.freedesktop.DBus.Properties</interfacename></ulink>
-        interface on some objects, which provides the methods
-        <methodname>Get</methodname>, <methodname>Set</methodname> and
-        <methodname>GetAll</methodname> to get or set property values for the
-        object's other interfaces.
-       </para>
-       <para>
-        Currently <literal>dbus-glib</literal> has no specific API for handling
-        properties, so they can only be accessed using the D-Bus method calls.
-        <xref linkend="dbus-glib-properties"/> is therefore very
-	similar to <xref linkend="dbus-glib-methods-call-method"/> presented
-	above.
-       </para>
-
-       <example id="dbus-glib-properties"
-                file="basics_dbus_glib_properties/main.c">
-        <title>Accessing D-Bus Properties Using Methods</title>
-       </example>
-       
-       <important>
-        <para>
-	 Telepathy's <application>telepathy-glib</application> provides a
-	 convenience API for accessing D-Bus properties that you can make on
-	 any <classname>TpProxy</classname> proxy. See
-	 <xref linkend="sect.basics.language-bindings.telepathy-glib.dbus-properties"/>.
-	</para>
-       </important>
-      </sect3>
-
-      <sect3 id="sect.basics.dbus.glib.signals">
-       <title>Handling Signals</title>
-       <para>
-        Handlers for D-Bus signals may be connected with the function
-	<function>dbus_g_proxy_connect_signal</function>.
-	As when calling D-Bus methods, you must specify the expected
-	types, but for signals you must do this in a previous call to
-	<function>dbus_g_proxy_add_signal</function>.
-	The specified callback function will then be called when the signal is
-	emitted.
-       </para>
-       <para>
-        <xref linkend="dbus-glib-signals"/>
-	connects to the &quot;DeviceAdded&quot; signal of
-	the <interface>org.freedesktop.Hal.Manager</interface> interface so it
-	can print a message to the terminal when, for instance, you plug in a
-	USB stick.
-       </para>
-
-       <example id="dbus-glib-signals"
-                file="basics_dbus_glib_signals/main.c">
-	<title>Connecting and Receiving a Signal</title>
-       </example>
-      </sect3>
-
-    </sect2>
-
-    <sect2 id="sect.basics.dbus.python">
-      <title>Using D-Bus from Python</title>
 
       <para>
-       Using D-Bus from Python is done using the <literal>dbus</literal>
-       module. If you're planning on using the GLib mainloop you'll also
-       need the <literal>dbus.mainloop.glib</literal> module.
-      </para>
-
-      <para>
-       <xref linkend="dbus-python-get-bus"/> shows how to configure D-Bus to
+       <xref linkend="ex.basics.dbus.language-bindings.python.mainloop"/>
+       shows how to configure D-Bus to
        use the GLib mainloop for its event dispatching and then makes a
        connection to the session bus.
       </para>
 
-      <example id="dbus-python-get-bus"
-               file="basics_dbus_python_methods/example.py">
-       <title>Connecting to a Message Bus</title>
+      <example id="ex.basics.dbus.language-bindings.python.mainloop"
+               file="python_simple_presence/example.py">
+       <title>Setting Up The Mainloop</title>
       </example>
 
-      <para>
-       In order to interact with a D-Bus object (i.e. call methods or
-       connect signals) we need to create a proxy object for it. A proxy
-       object is a Python object that we call methods on
-       in our application.
-      </para>
-
-      <para>
-       <xref linkend="dbus-python-get-proxy"/> shows how to acquire a proxy
-       object <classname>/org/freedesktop/Notifications</classname> binding
-       the <interfacename>org.freedesktop.Notifications</interfacename>
-       interface.
-      </para>
-
-      <example id="dbus-python-get-proxy"
-               file="basics_dbus_python_methods/example.py">
-       <title>Acquiring a Proxy Object</title>
-      </example>
+      <sect3 id="sect.basics.dbus.language-bindings.python.proxies">
+       <title>Proxy Objects</title>
+       <para>
+        In order to interact with a D-Bus object (i.e. call methods or
+        connect signals) we need to create a proxy object for it. A proxy
+        object is a Python object that we call methods on
+        in our application.
+       </para>
+      </sect3>
 
-      <sect3 id="sect.basics.dbus.python.methods">
+      <sect3 id="sect.basics.dbus.language-bindings.python.methods">
        <title>Calling Methods</title>
        <para>
-	<xref linkend="dbus-python-call-method"/>
-	uses <indexterm><primary>Python</primary></indexterm>
-	Python to call the <methodname>Notify</methodname> method on the
-	proxy object acquired in <xref linkend="dbus-python-get-proxy"/>
-	above. Proxy objects in Python bind D-Bus methods into their local
-	namespace (unlike when using dbus-glib, where the method name is
-	passed as a string).
+        D-Bus method calls on a proxy object look like any other Python
+	method call. Python's D-Bus support can automatically convert native
+	Python types into D-Bus types and back, so no complicated type
+	marshalling is required.
+	<xref linkend="ex.basics.dbus.language-bindings.python.methods.call"/>
+	shows calling the <methodname>RequestConnection</methodname> method
+	(more on this in
+	<xref linkend="sect.connection.obtaining.connection-manager"/>).
        </para>
 
        <para>
@@ -689,80 +566,66 @@
 	<emphasis>always</emphasis> be made asynchronously, for the reasons
 	outlined in <xref linkend="warning.dbus.sync"/>. Python features
 	such as inline functions and lambdas are permitted as callback
-	functions.
+	functions. The parameters to a callback are specified by the D-Bus
+	return type, e.g.
+	<xref linkend="ex.basics.dbus.language-bindings.python.methods.cb"/>.
        </para>
 
-       <example id="dbus-python-call-method"
-                file="basics_dbus_python_methods/example.py">
+       <example id="ex.basics.dbus.language-bindings.python.methods.call"
+                file="python_simple_presence/example.py">
         <title>Calling a Method</title>
        </example>
+       
+       <example id="ex.basics.dbus.language-bindings.python.methods.cb"
+                file="python_simple_presence/example.py">
+        <title>Method Callback</title>
+       </example>
       </sect3>
 
-      <sect3 id="sect.basics.dbus.python.properties">
+      <sect3 id="sect.basics.dbus.language-bindings.python.props">
        <title>Using Properties</title>
        <para>
-        D-Bus properties are available via an additional
+        D-Bus properties are available via the
 	<ulink url="&url_dbus_spec_base;standard-interfaces-properties"><interfacename>org.freedesktop.DBus.Properties</interfacename></ulink>
-        interface on some objects, which provides the methods
+        interface, which provides the
         <methodname>Get</methodname>, <methodname>Set</methodname> and
-        <methodname>GetAll</methodname> to get or set property values for the
-        object's other interfaces.
+        <methodname>GetAll</methodname> methods
+	to get or set property values for the object's other interfaces.
        </para>
        <para>
         Python D-Bus currently has no specific API for dealing with
 	properties, so they must be accessed through the D-Bus method calls.
-	<xref linkend="dbus-python-properties"/> is therefore very similar to
-	<xref linkend="dbus-python-call-method"/> presented above.
+	<xref linkend="ex.basics.dbus.language-bindings.python.props"/>
+	is therefore very similar to
+	<xref linkend="ex.basics.dbus.language-bindings.python.methods.call"/>
+	presented above.
        </para>
-       <example id="dbus-python-properties"
-                file="basics_dbus_python_properties/example.py">
+
+       <example id="ex.basics.dbus.language-bindings.python.props"
+                file="python_simple_presence/example.py">
         <title>Accessing D-Bus Properties Using Methods</title>
        </example>
       </sect3>
 
-      <sect3 id="sect.basics.dbus.python.signals">
+      <sect3 id="sect.basics.dbus.language-bindings.python.signals">
        <title>Handling Signals</title>
        <para>
         D-Bus signal handlers may be specified in Python with the proxy object's
 	<ulink url="&url_dbus_python_base;dbus.proxies.Interface-class.html#connect_to_signal"><methodname>connect_to_signal</methodname></ulink>
 	method. The specified callback function will then be called when the
-	signal is emitted. <xref linkend="dbus-python-signals"/> connects to
-	the &quot;DeviceAdded&quot; signal of the
-	<interfacename>org.freedesktop.Hal.Manager</interfacename> interface
-	so it can print a message to the terminal when, for instance, you plug
-	in a USB stick.
+	signal is emitted.
+	<xref linkend="ex.basics.dbus.language-bindings.python.signals"/>
+	connects to the <methodname>NewChannels</methodname> signal in
+	Telepathy.
        </para>
 
-       <example id="dbus-python-signals"
-	        file="basics_dbus_python_signals/example.py">
-	<title>Connecting and Receiving a Signal</title>
+       <example id="ex.basics.dbus.language-bindings.python.signals"
+	        file="python_simple_presence/example.py">
+	<title>Connecting a Signal</title>
        </example>	
       </sect3>
 
     </sect2>
-   </sect1>
-
-   <sect1 id="sect.basics.language-bindings">
-    <title>Language Bindings</title>
-    <para>
-     As mentioned in <xref linkend="sect.basics.dbus"/>, many programming
-     languages have their own generic ways of using D-Bus APIs. In addition,
-     there are some Telepathy-specific APIs to make the use of Telepathy
-     easier. For instance,
-     <ulink url="http://telepathy.freedesktop.org/wiki/Telepathy%20GLib">telepathy-glib</ulink>
-     provides an API that aims to be more familiar to users of Glib and GTK+.
-     Likewise,
-     <ulink url="http://telepathy.freedesktop.org/wiki/TelepathyQt">Telepathy-Qt</ulink>
-     provides a Qt API for Telepathy and
-     <ulink url="http://telepathy.freedesktop.org/wiki/Telepathy%20Python">Telepathy-Python</ulink> for Python.
-    </para>
-
-    <para>
-     Remember that, like raw use of D-Bus from these programming languages,
-     the Telepathy language bindings only create <literal>proxies</literal>
-     to the D-Bus objects, providing a way to use their API. The actual
-     objects are instantiated in the service's process.
-    </para>
   
     <sect2 id="sect.basics.language-bindings.telepathy-glib">
       <title>telepathy-glib</title>
diff --git a/docs/examples/basics_dbus_glib_methods/Makefile.am b/docs/examples/basics_dbus_glib_methods/Makefile.am
deleted file mode 100644
index d0a304f..0000000
--- a/docs/examples/basics_dbus_glib_methods/Makefile.am
+++ /dev/null
@@ -1,7 +0,0 @@
-include $(top_srcdir)/docs/examples/Makefile.am_fragment
-
-#Build the executable, but don't install it.
-noinst_PROGRAMS = example
-
-example_SOURCES = main.c
-
diff --git a/docs/examples/basics_dbus_glib_methods/main.c b/docs/examples/basics_dbus_glib_methods/main.c
deleted file mode 100644
index 0cbec89..0000000
--- a/docs/examples/basics_dbus_glib_methods/main.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/* Copyright 2009 Collabora Ltd
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <dbus/dbus-glib.h>
-#include <glib.h>
-
-GMainLoop *mainloop = NULL;
-
-/* begin dbus-glib-methods-call-method-subroutine */
-void on_proxy_call_notify (DBusGProxy *proxy,
-  DBusGProxyCall *call_id,
-  void *user_data)
-{
-  GError *error = 0;
-  guint result = 0;
-  dbus_g_proxy_end_call (proxy, call_id, &error, 
-    G_TYPE_UINT, &result, /* Return value. */
-    G_TYPE_INVALID);
-
-  if (error)
-    {
-      g_printf ("dbus_g_proxy_begin_call() failed: %s\n", error->message);
-      g_clear_error (&error);
-    }
-  else
-    {
-      g_printf ("dbus_g_proxy_begin_call() succeeded, returning %u\n", result);
-    }
-
-/* end dbus-glib-methods-call-method-subroutine */
-  /* Stop the main loop to allow main() to finish, 
-   * stopping the program: */
-  g_main_loop_quit (mainloop);
-}
-
-int
-main (int argc, char **argv)
-{
-  g_type_init ();
-
-  /* Create the main loop: */
-  mainloop = g_main_loop_new (NULL, FALSE);
-
-  /* begin dbus-glib-methods-get-bus */
-  /* Connect to the bus: */
-  GError *error = 0;
-  DBusGConnection *connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
-  if (error)
-    {
-      g_printf ("dbus_g_bus_get() failed: %s\n", error->message);
-      g_clear_error (&error);
-      g_main_loop_quit (mainloop);
-      return 1;
-    }
-  /* end dbus-glib-methods-get-bus */
-
-  /* begin dbus-glib-methods-get-proxy */
-  /* Get a proxy for the remote object: */
-  DBusGProxy *proxy = dbus_g_proxy_new_for_name (connection,
-    "org.freedesktop.Notifications", /* name */
-    "/org/freedesktop/Notifications", /* path */
-    "org.freedesktop.Notifications"); /* interface */
-  /* end dbus-glib-methods-get-proxy */
-
-  /* Call a method on the interface  of the remote object: */
-
-  /* begin dbus-glib-methods-call-method */
-  /* Create an empty GHashTable for one of the parameters: */
-  GHashTable* actions = g_hash_table_new (NULL, NULL);  
-
-  /* Call the method: */
-  dbus_g_proxy_begin_call (proxy, "Notify", 
-    &on_proxy_call_notify, NULL, /* user_data */ 
-    NULL, /* destroy notification */
-    G_TYPE_STRING, "dbus-glib example",
-    G_TYPE_UINT, 0,
-    G_TYPE_STRING, "", /* icon_name */ 
-    G_TYPE_STRING, "Example Notification",
-    G_TYPE_STRING, "This is an example notification via dbus-glib.",
-    G_TYPE_STRV, 0,
-    dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), actions,
-    G_TYPE_INT, 0,
-    G_TYPE_INVALID,
-    G_TYPE_INT,
-    G_TYPE_INVALID);
-  g_hash_table_unref (actions);
-  actions = NULL;
-  /* end dbus-glib-methods-call-method */
-
-  /* Run the main loop, 
-   * to keep our application alive while we wait for responses from D-Bus.
-   * This function returns when we call g_main_loop_quit() from elsewhere.
-   */
-  g_main_loop_run (mainloop);
-
-  /* Clean up: */
-  g_main_loop_unref (mainloop);
-
-  return 0;
-}
diff --git a/docs/examples/basics_dbus_glib_properties/Makefile.am b/docs/examples/basics_dbus_glib_properties/Makefile.am
deleted file mode 100644
index d0a304f..0000000
--- a/docs/examples/basics_dbus_glib_properties/Makefile.am
+++ /dev/null
@@ -1,7 +0,0 @@
-include $(top_srcdir)/docs/examples/Makefile.am_fragment
-
-#Build the executable, but don't install it.
-noinst_PROGRAMS = example
-
-example_SOURCES = main.c
-
diff --git a/docs/examples/basics_dbus_glib_properties/main.c b/docs/examples/basics_dbus_glib_properties/main.c
deleted file mode 100644
index b4a3547..0000000
--- a/docs/examples/basics_dbus_glib_properties/main.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/* Copyright 2009 Collabora Ltd
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <dbus/dbus-glib.h>
-#include <glib.h>
-
-GMainLoop *mainloop = NULL;
-
-void on_proxy_call_get (DBusGProxy *proxy,
-  DBusGProxyCall *call_id,
-  void *user_data)
-{
-  GError *error = 0;
-  GValue result = {0, };
-  dbus_g_proxy_end_call (proxy, call_id, &error, 
-    G_TYPE_VALUE, &result, /* Return value. */
-    G_TYPE_INVALID);
-
-  if (error)
-    {
-      g_printf ("dbus_g_proxy_begin_call() failed: %s\n", error->message);
-      g_clear_error (&error);
-    }
-  else
-    {
-      gchar* as_string = g_strdup_value_contents (&result);
-      g_printf ("dbus_g_proxy_begin_call() succeeded, returning type=%s, value=%s\n", 
-        G_VALUE_TYPE_NAME(&result), as_string);
-      g_free (as_string);
-    }
-
-  g_value_unset (&result);
-
-  /* Stop the main loop to allow main() to finish, 
-   * stopping the program: */
-  g_main_loop_quit (mainloop);
-}
-
-int
-main (int argc, char **argv)
-{
-  g_type_init ();
-
-  /* Create the main loop: */
-  mainloop = g_main_loop_new (NULL, FALSE);
-
-  /* Connect to the bus: */
-  GError *error = 0;
-  DBusGConnection *connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
-  if (error)
-    {
-      g_printf ("dbus_g_bus_get() failed: %s\n", error->message);
-      g_clear_error (&error);
-      g_main_loop_quit (mainloop);
-      return 1;
-    }
-
-  /* Get a proxy for the Properties interface of a remote object: */
-  DBusGProxy *proxy = dbus_g_proxy_new_for_name (connection,
-    "org.freedesktop.Telepathy.Connection.salut.local_xmpp.Murray_20Cumming", /* name */
-    "/org/freedesktop/Telepathy/Connection/salut/local_xmpp/Murray_20Cumming", /* path */
-    "org.freedesktop.DBus.Properties"); /* interface */
-
-  /* Call the Properties.Get method on the interface of the remote object: */
-
-  /* Call the Get method to get a property value: */
-  dbus_g_proxy_begin_call (proxy, "Get" /* property name */,
-    &on_proxy_call_get, NULL, /* user_data */ 
-    NULL, /* destroy notification */
-    G_TYPE_STRING, "org.freedesktop.Telepathy.Connection", /* interface name */
-    G_TYPE_STRING, "SelfHandle", /* property name */
-    G_TYPE_INVALID,
-    G_TYPE_VALUE,
-    G_TYPE_INVALID);
-
-  /* Run the main loop, 
-   * to keep our application alive while we wait for responses from D-Bus.
-   * This function returns when we call g_main_loop_quit() from elsewhere.
-   */
-  g_main_loop_run (mainloop);
-
-  /* Clean up: */
-  g_main_loop_unref (mainloop);
-
-  return 0;
-}
diff --git a/docs/examples/basics_dbus_glib_signals/Makefile.am b/docs/examples/basics_dbus_glib_signals/Makefile.am
deleted file mode 100644
index d0a304f..0000000
--- a/docs/examples/basics_dbus_glib_signals/Makefile.am
+++ /dev/null
@@ -1,7 +0,0 @@
-include $(top_srcdir)/docs/examples/Makefile.am_fragment
-
-#Build the executable, but don't install it.
-noinst_PROGRAMS = example
-
-example_SOURCES = main.c
-
diff --git a/docs/examples/basics_dbus_glib_signals/main.c b/docs/examples/basics_dbus_glib_signals/main.c
deleted file mode 100644
index c2e54b8..0000000
--- a/docs/examples/basics_dbus_glib_signals/main.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/* Copyright 2009 Collabora Ltd
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <dbus/dbus-glib.h>
-#include <glib.h>
-
-GMainLoop *mainloop = NULL;
-
-void on_proxy_signal_device_added (DBusGProxy *object, const char *path,
-  gpointer user_data)
-{
-  g_print("Signal: Device Added: path=%s\n", path);
-}
-
-int
-main (int argc, char **argv)
-{
-  g_type_init ();
-
-  /* Create the main loop: */
-  mainloop = g_main_loop_new (NULL, FALSE);
-
-  /* Connect to the bus: */
-  GError *error = 0;
-  DBusGConnection *connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
-  if (error)
-    {
-      g_printf ("dbus_g_bus_get() failed: %s\n", error->message);
-      g_clear_error (&error);
-      g_main_loop_quit (mainloop);
-      return 1;
-    }
-
-  /* Get a proxy for the remote object: */
-  DBusGProxy *proxy = dbus_g_proxy_new_for_name (connection,
-    "org.freedesktop.Hal", /* name */
-    "/org/freedesktop/Hal/Manager", /* path */
-    "org.freedesktop.Hal.Manager"); /* interface */
-
-
-  /* Connect to a signal on the interface: */
-  /* TODO: This doesn't work, though the Python example does. */
-  dbus_g_proxy_add_signal (proxy, "DeviceAdded", G_TYPE_STRING, G_TYPE_INVALID);
-  dbus_g_proxy_connect_signal (proxy, "DeviceAdded", 
-    G_CALLBACK (on_proxy_signal_device_added), NULL, NULL);
-
-
-  /* Run the main loop, 
-   * to keep our application alive while we wait for responses from D-Bus.
-   * This function returns when we call g_main_loop_quit() from elsewhere.
-   */
-  g_main_loop_run (mainloop);
-
-  /* Clean up: */
-  g_main_loop_unref (mainloop);
-
-  return 0;
-}
diff --git a/docs/examples/python_simple_presence/example.py b/docs/examples/python_simple_presence/example.py
index 2c03228..56bfcac 100755
--- a/docs/examples/python_simple_presence/example.py
+++ b/docs/examples/python_simple_presence/example.py
@@ -3,8 +3,10 @@
 import sys
 
 import gobject
+# begin ex.basics.dbus.language-bindings.python.mainloop
 import dbus.mainloop.glib
 dbus.mainloop.glib.DBusGMainLoop(set_as_default = True)
+# end ex.basics.dbus.language-bindings.python.mainloop
 
 import telepathy
 import telepathy.client
@@ -37,6 +39,7 @@ class Example (object):
         self.cm = cm = reg.GetManager('gabble')
 
         # get the parameters required to make a Jabber connection
+        # begin ex.basics.dbus.language-bindings.python.methods.call
         cm[CONNECTION_MANAGER].RequestConnection('jabber',
             {
                 'account':  account,
@@ -44,6 +47,7 @@ class Example (object):
             },
             reply_handler = self.request_connection_cb,
             error_handler = self.error_cb)
+        # end ex.basics.dbus.language-bindings.python.methods.call
 
         self.loop = gobject.MainLoop()
         try:
@@ -64,8 +68,10 @@ class Example (object):
         self.conn[CONNECTION].Disconnect(reply_handler = self.generic_reply,
                                          error_handler = self.error_cb)
 
+    # begin ex.basics.dbus.language-bindings.python.methods.cb
     def request_connection_cb (self, bus_name, object_path):
         print bus_name, object_path
+        # end ex.basics.dbus.language-bindings.python.methods.cb
         self.conn = conn = telepathy.client.Connection(bus_name, object_path)
 
         conn[CONNECTION].connect_to_signal('StatusChanged',
@@ -171,14 +177,18 @@ class Example (object):
                                       'deny',
                                       'known')
 
-            # get the open channels
+            # get the open channelsA
+            # begin ex.basics.dbus.language-bindings.python.signals
             conn[CONNECTION_INTERFACE_REQUESTS].connect_to_signal(
                                     'NewChannels',
                                     self.get_channels_cb)
+            # end ex.basics.dbus.language-bindings.python.signals
+            # begin ex.basics.dbus.language-bindings.python.props
             conn[DBUS_PROPERTIES].Get(CONNECTION_INTERFACE_REQUESTS,
                                     'Channels',
                                     reply_handler = self.get_channels_cb,
                                     error_handler = self.error_cb)
+            # end ex.basics.dbus.language-bindings.python.props
 
         if CONNECTION_INTERFACE_SIMPLE_PRESENCE in interfaces:
             # begin ex.connection.presence.set-presence
-- 
1.5.6.5




More information about the telepathy-commits mailing list