diff options
author | Simon McVittie <smcv@debian.org> | 2017-11-01 15:48:27 +0000 |
---|---|---|
committer | Simon McVittie <smcv@debian.org> | 2017-11-01 16:08:48 +0000 |
commit | 93f9fe7b9c009e89ca9a0c32e07176fb8ab9839d (patch) | |
tree | 03b298cefe60ad5303754697ec750f4f5665ab67 | |
parent | b433ea03e9523faf8e0479062e368cb01727b745 (diff) | |
download | dbus-glib-93f9fe7b9c009e89ca9a0c32e07176fb8ab9839d.tar.gz |
Move dbus_g_connection_open() etc. from dbus-gmain.c to dbus-glib.c
This will facilitate conversion of dbus-gmain.[ch], which are the only
part of GDBus that is not awful, into a separate library or a
submodule or something.
Signed-off-by: Simon McVittie <smcv@debian.org>
-rw-r--r-- | dbus/dbus-glib.c | 182 | ||||
-rw-r--r-- | dbus/dbus-gmain.c | 187 |
2 files changed, 181 insertions, 188 deletions
diff --git a/dbus/dbus-glib.c b/dbus/dbus-glib.c index 9b89cda..66bab44 100644 --- a/dbus/dbus-glib.c +++ b/dbus/dbus-glib.c @@ -22,10 +22,11 @@ */ #include <config.h> -#include "dbus-glib.h" -#include "dbus-glib-lowlevel.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 <string.h> @@ -411,3 +412,180 @@ 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 + * + * Deprecated: New code should use GDBus instead. The closest equivalent + * is g_dbus_connection_new_for_address_sync(). + */ +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_connection_open_private: + * @address: address of the connection to open + * @context: the #GMainContext or %NULL for default context + * @error: address where an error can be returned. + * + * Returns a private connection to the given address; this + * connection does not talk to a bus daemon and thus the caller + * must set up any authentication by itself. If the address + * refers to a message bus, the caller must call dbus_bus_register(). + * + * (Internally, calls dbus_connection_open_private() then calls + * dbus_connection_setup_with_g_main() on the result.) + * + * Returns: (transfer full): a #DBusGConnection + * + * Deprecated: New code should use GDBus instead. The closest equivalent + * is g_dbus_connection_new_for_address_sync(). + */ +DBusGConnection * +dbus_g_connection_open_private (const gchar *address, + 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_connection_open_private (address, &derror); + if (connection == NULL) + { + dbus_set_g_error (error, &derror); + dbus_error_free (&derror); + return NULL; + } + + dbus_connection_setup_with_g_main (connection, context); + + 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 + * + * Deprecated: New code should use GDBus instead. The closest equivalent + * is g_bus_get_sync(). + */ +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 + * + * Deprecated: New code should use GDBus instead. The closest equivalent + * is g_bus_get_sync(). + */ +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 b7eef23..3c3c72e 100644 --- a/dbus/dbus-gmain.c +++ b/dbus/dbus-gmain.c @@ -23,15 +23,7 @@ */ #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: @@ -666,180 +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 - * - * Deprecated: New code should use GDBus instead. The closest equivalent - * is g_dbus_connection_new_for_address_sync(). - */ -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_connection_open_private: - * @address: address of the connection to open - * @context: the #GMainContext or %NULL for default context - * @error: address where an error can be returned. - * - * Returns a private connection to the given address; this - * connection does not talk to a bus daemon and thus the caller - * must set up any authentication by itself. If the address - * refers to a message bus, the caller must call dbus_bus_register(). - * - * (Internally, calls dbus_connection_open_private() then calls - * dbus_connection_setup_with_g_main() on the result.) - * - * Returns: (transfer full): a #DBusGConnection - * - * Deprecated: New code should use GDBus instead. The closest equivalent - * is g_dbus_connection_new_for_address_sync(). - */ -DBusGConnection * -dbus_g_connection_open_private (const gchar *address, - 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_connection_open_private (address, &derror); - if (connection == NULL) - { - dbus_set_g_error (error, &derror); - dbus_error_free (&derror); - return NULL; - } - - dbus_connection_setup_with_g_main (connection, context); - - 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 - * - * Deprecated: New code should use GDBus instead. The closest equivalent - * is g_bus_get_sync(). - */ -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 - * - * Deprecated: New code should use GDBus instead. The closest equivalent - * is g_bus_get_sync(). - */ -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); -} |