diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2011-08-24 16:57:06 +0100 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2011-09-22 12:00:33 +0100 |
commit | 58deafac362cf6c4f88ba9530a1a8540ed2d87a9 (patch) | |
tree | bb3a2b5a05f4f763191ab9452d39e7d2f43d2bd5 | |
parent | 4262bf247c15042e0fde9e08201296573a5ce192 (diff) |
Move dbus_g_bus_get_private, dbus_g_bus_get, dbus_g_connection_open to dbus-glib.c
These aren't really part of the main-loop integration.
-rw-r--r-- | dbus/dbus-glib.c | 127 | ||||
-rw-r--r-- | dbus/dbus-gmain.c | 146 |
2 files changed, 135 insertions, 138 deletions
diff --git a/dbus/dbus-glib.c b/dbus/dbus-glib.c index 5a17e15..e4f9af8 100644 --- a/dbus/dbus-glib.c +++ b/dbus/dbus-glib.c @@ -1,7 +1,9 @@ /* -*- mode: C; c-file-style: "gnu" -*- */ /* dbus-glib.c General GLib binding stuff * - * Copyright (C) 2004 Red Hat, Inc. + * Copyright © 2002-2003 CodeFactory AB + * Copyright © 2004-2005 Red Hat, Inc. + * Copyright © 2011 Nokia Corporation * * Licensed under the Academic Free License version 2.1 * @@ -27,6 +29,7 @@ #include "dbus-gtest.h" #include "dbus-gutils.h" #include "dbus-gobject.h" +#include "dbus-gvalue.h" #include <string.h> /** @@ -341,3 +344,125 @@ dbus_g_message_get_message (DBusGMessage *gmessage) { return DBUS_MESSAGE_FROM_G_MESSAGE (gmessage); } + +/** + * dbus_g_connection_open: + * @address: address of the connection to open + * @error: address where an error can be returned. + * + * Returns a connection to the given address. + * + * (Internally, calls dbus_connection_open() then calls + * dbus_connection_setup_with_g_main() on the result.) + * + * Returns: a DBusConnection + */ +DBusGConnection* +dbus_g_connection_open (const gchar *address, + GError **error) +{ + DBusConnection *connection; + DBusError derror; + + g_return_val_if_fail (error == NULL || *error == NULL, NULL); + + _dbus_g_value_types_init (); + + dbus_error_init (&derror); + + connection = dbus_connection_open (address, &derror); + if (connection == NULL) + { + dbus_set_g_error (error, &derror); + dbus_error_free (&derror); + return NULL; + } + + /* does nothing if it's already been done */ + dbus_connection_setup_with_g_main (connection, NULL); + + return DBUS_G_CONNECTION_FROM_CONNECTION (connection); +} + +/** + * dbus_g_bus_get: + * @type: bus type + * @error: address where an error can be returned. + * + * 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.) + * + * Returns: a DBusConnection + */ +DBusGConnection* +dbus_g_bus_get (DBusBusType type, + GError **error) +{ + DBusConnection *connection; + DBusError derror; + + g_return_val_if_fail (error == NULL || *error == NULL, NULL); + + _dbus_g_value_types_init (); + + dbus_error_init (&derror); + + connection = dbus_bus_get (type, &derror); + if (connection == NULL) + { + dbus_set_g_error (error, &derror); + dbus_error_free (&derror); + return NULL; + } + + /* does nothing if it's already been done */ + dbus_connection_setup_with_g_main (connection, NULL); + + return DBUS_G_CONNECTION_FROM_CONNECTION (connection); +} + +/** + * dbus_g_bus_get_private: + * @type: bus type + * @context: Mainloop context to attach to + * @error: address where an error can be returned. + * + * Returns a connection to the given bus. The connection will be a private + * non-shared connection and should be closed when usage is complete. + * + * Internally this function calls dbus_bus_get_private() then calls + * dbus_connection_setup_with_g_main() on the result; see the documentation + * of the former function for more information on private connections. + * + * Returns: a DBusConnection + */ +DBusGConnection* +dbus_g_bus_get_private (DBusBusType type, + GMainContext *context, + GError **error) +{ + DBusConnection *connection; + DBusError derror; + + g_return_val_if_fail (error == NULL || *error == NULL, NULL); + + _dbus_g_value_types_init (); + + dbus_error_init (&derror); + + connection = dbus_bus_get_private (type, &derror); + if (connection == NULL) + { + dbus_set_g_error (error, &derror); + dbus_error_free (&derror); + return NULL; + } + + /* does nothing if it's already been done */ + dbus_connection_setup_with_g_main (connection, context); + + return DBUS_G_CONNECTION_FROM_CONNECTION (connection); +} diff --git a/dbus/dbus-gmain.c b/dbus/dbus-gmain.c index 40e2d49..3cf743a 100644 --- a/dbus/dbus-gmain.c +++ b/dbus/dbus-gmain.c @@ -1,11 +1,12 @@ /* -*- mode: C; c-file-style: "gnu" -*- */ -/* dbus-gmain.c GLib main loop integration +/* dbus-gmain.c - GLib main loop integration for dbus-1 * - * Copyright (C) 2002, 2003 CodeFactory AB - * Copyright (C) 2005 Red Hat, Inc. + * Copyright © 2002-2003 CodeFactory AB + * Copyright © 2003-2005 Red Hat, Inc. + * Copyright © 2011 Nokia Corporation * * Licensed under the Academic Free License version 2.1 - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -15,23 +16,16 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA * */ #include <config.h> -#include <dbus/dbus-glib.h> -#include <dbus/dbus-glib-lowlevel.h> -#include "dbus-gtest.h" -#include "dbus-gutils.h" -#include "dbus-gvalue.h" -#include "dbus-gobject.h" -#include "dbus-gvalue-utils.h" -#include "dbus-gsignature.h" -#include <string.h> +#include <dbus/dbus-gmain.h> /* * DBusGMessageQueue: @@ -664,125 +658,3 @@ dbus_server_setup_with_g_main (DBusServer *server, nomem: g_error ("Not enough memory to set up DBusServer for use with GLib"); } - -/** - * dbus_g_connection_open: - * @address: address of the connection to open - * @error: address where an error can be returned. - * - * Returns a connection to the given address. - * - * (Internally, calls dbus_connection_open() then calls - * dbus_connection_setup_with_g_main() on the result.) - * - * Returns: a DBusConnection - */ -DBusGConnection* -dbus_g_connection_open (const gchar *address, - GError **error) -{ - DBusConnection *connection; - DBusError derror; - - g_return_val_if_fail (error == NULL || *error == NULL, NULL); - - _dbus_g_value_types_init (); - - dbus_error_init (&derror); - - connection = dbus_connection_open (address, &derror); - if (connection == NULL) - { - dbus_set_g_error (error, &derror); - dbus_error_free (&derror); - return NULL; - } - - /* does nothing if it's already been done */ - dbus_connection_setup_with_g_main (connection, NULL); - - return DBUS_G_CONNECTION_FROM_CONNECTION (connection); -} - -/** - * dbus_g_bus_get: - * @type: bus type - * @error: address where an error can be returned. - * - * 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.) - * - * Returns: a DBusConnection - */ -DBusGConnection* -dbus_g_bus_get (DBusBusType type, - GError **error) -{ - DBusConnection *connection; - DBusError derror; - - g_return_val_if_fail (error == NULL || *error == NULL, NULL); - - _dbus_g_value_types_init (); - - dbus_error_init (&derror); - - connection = dbus_bus_get (type, &derror); - if (connection == NULL) - { - dbus_set_g_error (error, &derror); - dbus_error_free (&derror); - return NULL; - } - - /* does nothing if it's already been done */ - dbus_connection_setup_with_g_main (connection, NULL); - - return DBUS_G_CONNECTION_FROM_CONNECTION (connection); -} - -/** - * dbus_g_bus_get_private: - * @type: bus type - * @context: Mainloop context to attach to - * @error: address where an error can be returned. - * - * Returns a connection to the given bus. The connection will be a private - * non-shared connection and should be closed when usage is complete. - * - * Internally this function calls dbus_bus_get_private() then calls - * dbus_connection_setup_with_g_main() on the result; see the documentation - * of the former function for more information on private connections. - * - * Returns: a DBusConnection - */ -DBusGConnection* -dbus_g_bus_get_private (DBusBusType type, - GMainContext *context, - GError **error) -{ - DBusConnection *connection; - DBusError derror; - - g_return_val_if_fail (error == NULL || *error == NULL, NULL); - - _dbus_g_value_types_init (); - - dbus_error_init (&derror); - - connection = dbus_bus_get_private (type, &derror); - if (connection == NULL) - { - dbus_set_g_error (error, &derror); - dbus_error_free (&derror); - return NULL; - } - - /* does nothing if it's already been done */ - dbus_connection_setup_with_g_main (connection, context); - - return DBUS_G_CONNECTION_FROM_CONNECTION (connection); -} |