~ubuntu-branches/ubuntu/oneiric/dbus-glib/oneiric-updates

« back to all changes in this revision

Viewing changes to test/interfaces/test-server.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2006-11-01 10:51:01 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061101105101-2dbr969h8k05n1b2
Tags: 0.72-0ubuntu1
* Sync with pkg-utopia SVN. This is infact 0.72-1 which sits in NEW
* New upstream release
* debian/control:
  + Require libdbus-1-dev (>= 0.94) and libglib2.0-dev (>= 2.6)
  + Add build dependency on gtk-doc-tools (>= 1.4)
* debian/control,
  debian/libdbus-glib-1-doc.install:
  + Add libdbus-glib-1-doc package

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdlib.h>
 
2
#include "dbus/dbus-glib.h"
 
3
#include "tools/dbus-glib-bindings.h"
 
4
#include "test-objects.h"
 
5
 
 
6
#define TEST_NAMESPACE "org.freedesktop.DBus.GLib.Test.Interfaces"
 
7
#define TEST_OBJECT_PATH "/org/freedesktop/DBus/GLib/Test/Interfaces"
 
8
 
 
9
static GMainLoop *loop = NULL;
 
10
 
 
11
int
 
12
main (int    argc, 
 
13
      char **argv)
 
14
{
 
15
        DBusGConnection *connection;
 
16
        DBusGProxy *proxy;
 
17
        GError *error = NULL;
 
18
        guint32 ret;
 
19
        TestBeatlesSong *song;
 
20
 
 
21
        g_type_init ();
 
22
 
 
23
        /* Get the connection and ensure the name is not used yet */
 
24
        connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
 
25
        if (connection == NULL) {
 
26
                g_warning ("Failed to make connection to session bus: %s",
 
27
                           error->message);
 
28
                g_error_free (error);
 
29
                exit(1);
 
30
        }
 
31
                
 
32
        proxy = dbus_g_proxy_new_for_name (connection, DBUS_SERVICE_DBUS,
 
33
                                           DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
 
34
        if (!org_freedesktop_DBus_request_name (proxy, TEST_NAMESPACE,
 
35
                                                0, &ret, &error)) {
 
36
                g_warning ("There was an error requesting the name: %s",
 
37
                           error->message);
 
38
                g_error_free (error);
 
39
                exit(1);
 
40
        }
 
41
        
 
42
        if (ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
 
43
                /* Someone else registered the name before us */
 
44
                exit(1);
 
45
        }
 
46
                
 
47
        song = test_beatles_song_new ();
 
48
                
 
49
        /* Register the app on the bus */
 
50
        dbus_g_connection_register_g_object (connection,
 
51
                                             TEST_OBJECT_PATH,
 
52
                                             G_OBJECT (song));
 
53
 
 
54
        loop = g_main_loop_new (NULL, FALSE);
 
55
        g_main_loop_run (loop);
 
56
}