summaryrefslogtreecommitdiffstats
path: root/glib/dbus-gmain.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2004-06-20 15:28:15 +0000
committerHavoc Pennington <hp@redhat.com>2004-06-20 15:28:15 +0000
commit961e6ca41c1e9433055130569ce3492866e2126b (patch)
tree053a3e24565665462a498dee93762a83b5598004 /glib/dbus-gmain.c
parenteed3989ea35a62e5f58ee7fc3f50a23ad0821800 (diff)
2004-06-20 Havoc Pennington <hp@redhat.com>
* dbus/dbus-glib-error-enum.h: autogenerate the GError enum codes from the dbus error names * glib/dbus-glib.h: move to subdir dbus/ since it's included as dbus/dbus-glib.h and that breakage is now visible due to including dbus/dbus-glib.h in dbus-glib-lowlevel.h * glib/dbus-glib.h: s/gproxy/g_proxy/ * dbus/dbus-shared.h: new header to hold stuff shared with binding APIs * dbus/dbus-protocol.h (DBUS_ERROR_*): move errors here rather than dbus-errors.h * glib/dbus-glib.h (dbus_set_g_error): move to dbus-glib-lowlevel.h * glib/dbus-glib.h: remove dbus/dbus.h from here; change a bunch of stuff to enable this * dbus/dbus-glib-lowlevel.h: put dbus/dbus.h here * a bunch of other changes with the same basic "separate glib bindings from dbus.h" theme
Diffstat (limited to 'glib/dbus-gmain.c')
-rw-r--r--glib/dbus-gmain.c121
1 files changed, 112 insertions, 9 deletions
diff --git a/glib/dbus-gmain.c b/glib/dbus-gmain.c
index da2e555d..c0741ac2 100644
--- a/glib/dbus-gmain.c
+++ b/glib/dbus-gmain.c
@@ -1,7 +1,7 @@
/* -*- mode: C; c-file-style: "gnu" -*- */
/* dbus-gmain.c GLib main loop integration
*
- * Copyright (C) 2002, 2003 CodeFactory AB
+ * Copyright (C) 2002, 2003 CodeFactory AB
*
* Licensed under the Academic Free License version 2.0
*
@@ -22,8 +22,10 @@
*/
#include <config.h>
-#include "dbus-glib.h"
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
#include "dbus-gtest.h"
+#include "dbus-gutils.h"
#include <libintl.h>
#define _(x) dgettext (GETTEXT_PACKAGE, x)
@@ -582,16 +584,19 @@ dbus_server_setup_with_g_main (DBusServer *server,
}
/**
- * Calls dbus_bus_get() then calls dbus_connection_setup_with_g_main()
- * on the result and returns the bus connection.
+ * Returns a connection to the given bus. The connection is a global variable
+ * shared with other callers of this function.
+ *
+ * (Internally, calls dbus_bus_get() then calls
+ * dbus_connection_setup_with_g_main() on the result.)
*
* @param type bus type
* @param error address where an error can be returned.
* @returns a DBusConnection
*/
-DBusConnection*
-dbus_bus_get_with_g_main (DBusBusType type,
- GError **error)
+DBusGConnection*
+dbus_g_bus_get (DBusBusType type,
+ GError **error)
{
DBusConnection *connection;
DBusError derror;
@@ -612,7 +617,7 @@ dbus_bus_get_with_g_main (DBusBusType type,
dbus_connection_setup_with_g_main (connection, NULL);
}
- return connection;
+ return DBUS_G_CONNECTION_FROM_CONNECTION (connection);
}
/**
@@ -688,6 +693,104 @@ dbus_message_get_g_type (void)
return our_type;
}
+static DBusGConnection*
+dbus_g_connection_ref (DBusGConnection *gconnection)
+{
+ DBusConnection *c;
+
+ c = DBUS_CONNECTION_FROM_G_CONNECTION (gconnection);
+ dbus_connection_ref (c);
+ return gconnection;
+}
+
+static void
+dbus_g_connection_unref (DBusGConnection *gconnection)
+{
+ DBusConnection *c;
+
+ c = DBUS_CONNECTION_FROM_G_CONNECTION (gconnection);
+ dbus_connection_unref (c);
+}
+
+
+static DBusGMessage*
+dbus_g_message_ref (DBusGMessage *gmessage)
+{
+ DBusMessage *c;
+
+ c = DBUS_MESSAGE_FROM_G_MESSAGE (gmessage);
+ dbus_message_ref (c);
+ return gmessage;
+}
+
+static void
+dbus_g_message_unref (DBusGMessage *gmessage)
+{
+ DBusMessage *c;
+
+ c = DBUS_MESSAGE_FROM_G_MESSAGE (gmessage);
+ dbus_message_unref (c);
+}
+
+/**
+ * Get the GLib type ID for a DBusGConnection boxed type.
+ *
+ * @returns GLib type
+ */
+GType
+dbus_g_connection_get_g_type (void)
+{
+ static GType our_type = 0;
+
+ if (our_type == 0)
+ our_type = g_boxed_type_register_static ("DBusGConnection",
+ (GBoxedCopyFunc) dbus_g_connection_ref,
+ (GBoxedFreeFunc) dbus_g_connection_unref);
+
+ return our_type;
+}
+
+/**
+ * Get the GLib type ID for a DBusGMessage boxed type.
+ *
+ * @returns GLib type
+ */
+GType
+dbus_g_message_get_g_type (void)
+{
+ static GType our_type = 0;
+
+ if (our_type == 0)
+ our_type = g_boxed_type_register_static ("DBusGMessage",
+ (GBoxedCopyFunc) dbus_g_message_ref,
+ (GBoxedFreeFunc) dbus_g_message_unref);
+
+ return our_type;
+}
+
+/**
+ * Get the DBusConnection corresponding to this DBusGConnection.
+ * The return value does not have its refcount incremented.
+ *
+ * @returns DBusConnection
+ */
+DBusConnection*
+dbus_g_connection_get_connection (DBusGConnection *gconnection)
+{
+ return DBUS_CONNECTION_FROM_G_CONNECTION (gconnection);
+}
+
+/**
+ * Get the DBusMessage corresponding to this DBusGMessage.
+ * The return value does not have its refcount incremented.
+ *
+ * @returns DBusMessage
+ */
+DBusMessage*
+dbus_g_message_get_message (DBusGMessage *gmessage)
+{
+ return DBUS_MESSAGE_FROM_G_MESSAGE (gmessage);
+}
/** @} */ /* end of public API */
@@ -698,7 +801,7 @@ dbus_message_get_g_type (void)
* Unit test for GLib main loop integration
* @returns #TRUE on success.
*/
-dbus_bool_t
+gboolean
_dbus_gmain_test (const char *test_data_dir)
{