/* ---------------------------------------------------------------------------------------------------- */
/**
+ * g_dbus_request_name:
+ * @connection: a #GDBusConnection
+ * @name: well-known bus name (name to request)
+ * @flags: a set of flags from the GBusNameOwnerFlags enumeration
+ * @error: return location for error or %NULL
+ *
+ * Synchronously acquires name on the bus and returns status code.
+ *
+ * The calling thread is blocked until a reply is received.
+ *
+ * Returns: status code or %G_BUS_REQUEST_NAME_FLAGS_ERROR
+ * if @error is set.
+ *
+ * Since: 2.4x
+ */
+GBusRequestNameReplyFlags
+g_dbus_request_name (GDBusConnection *connection,
+ const gchar *name,
+ GBusNameOwnerFlags flags,
+ GError **error)
+{
+ GVariant *result;
+ guint32 request_name_reply;
+
+ g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), G_BUS_RELEASE_NAME_FLAGS_ERROR);
+ g_return_val_if_fail (g_dbus_is_name (name) && !g_dbus_is_unique_name (name), G_BUS_RELEASE_NAME_FLAGS_ERROR);
+ g_return_val_if_fail (error == NULL || *error == NULL, G_BUS_RELEASE_NAME_FLAGS_ERROR);
+
+ if (G_IS_KDBUS_CONNECTION (connection->stream))
+ result = _g_kdbus_RequestName (connection, name, flags, error);
+ else
+ result = g_dbus_connection_call_sync (connection, "org.freedesktop.DBus", "/org/freedesktop/DBus",
+ "org.freedesktop.DBus", "RequestName",
+ g_variant_new ("(su)", name, flags), G_VARIANT_TYPE ("(u)"),
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, error);
+
+ if (result != NULL)
+ {
+ g_variant_get (result, "(u)", &request_name_reply);
+ g_variant_unref (result);
+ }
+ else
+ request_name_reply = G_BUS_REQUEST_NAME_FLAGS_ERROR;
+
+ return (GBusRequestNameReplyFlags) request_name_reply;
+}
+
+/**
+ * g_dbus_release_name:
+ * @connection: a #GDBusConnection
+ * @name: well-known bus name (name to release)
+ * @error: return location for error or %NULL
+ *
+ * Synchronously releases name on the bus and returns status code.
+ *
+ * The calling thread is blocked until a reply is received.
+ *
+ * Returns: status code or %G_BUS_RELEASE_NAME_FLAGS_ERROR
+ * if @error is set.
+ *
+ * Since: 2.4x
+ */
+GBusReleaseNameReplyFlags
+g_dbus_release_name (GDBusConnection *connection,
+ const gchar *name,
+ GError **error)
+{
+ GVariant *result;
+ guint32 release_name_reply;
+
+ g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), G_BUS_RELEASE_NAME_FLAGS_ERROR);
+ g_return_val_if_fail (g_dbus_is_name (name) && !g_dbus_is_unique_name (name), G_BUS_RELEASE_NAME_FLAGS_ERROR);
+ g_return_val_if_fail (error == NULL || *error == NULL, G_BUS_RELEASE_NAME_FLAGS_ERROR);
+
+ if (G_IS_KDBUS_CONNECTION (connection->stream))
+ result = _g_kdbus_ReleaseName (connection, name, error);
+ else
+ result = g_dbus_connection_call_sync (connection, "org.freedesktop.DBus", "/org/freedesktop/DBus",
+ "org.freedesktop.DBus", "ReleaseName",
+ g_variant_new ("(s)", name), G_VARIANT_TYPE ("(u)"),
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, error);
+
+ if (result != NULL)
+ {
+ g_variant_get (result, "(u)", &release_name_reply);
+ g_variant_unref (result);
+ }
+ else
+ release_name_reply = G_BUS_RELEASE_NAME_FLAGS_ERROR;
+
+ return (GBusReleaseNameReplyFlags) release_name_reply;
+}
+
+/**
* g_dbus_get_bus_id:
* @connection: a #GDBusConnection
* @error: return location for error or %NULL
/* ---------------------------------------------------------------------------------------------------- */
GLIB_AVAILABLE_IN_2_40
+guint32 g_dbus_request_name (GDBusConnection *connection,
+ const gchar *name,
+ GBusNameOwnerFlags flags,
+ GError **error);
+GLIB_AVAILABLE_IN_2_40
+guint32 g_dbus_release_name (GDBusConnection *connection,
+ const gchar *name,
+ GError **error);
+GLIB_AVAILABLE_IN_2_40
gchar *g_dbus_get_bus_id (GDBusConnection *connection,
GError **error);
GLIB_AVAILABLE_IN_2_40
} GBusNameOwnerFlags;
/**
+ * GBusRequestNameReplyFlags:
+ * @G_BUS_REQUEST_NAME_FLAGS_ERROR: Error flag.
+ * @G_BUS_REQUEST_NAME_FLAGS_PRIMARY_OWNER: Caller is now the primary owner of the name, replacing any previous owner.
+ * @G_BUS_REQUEST_NAME_FLAGS_IN_QUEUE: The name already had an owner, the application will be placed in a queue.
+ * @G_BUS_REQUEST_NAME_FLAGS_EXISTS: The name already has an owner.
+ * @G_BUS_REQUEST_NAME_FLAGS_ALREADY_OWNER: The application trying to request ownership of a name is already the owner of it.
+ *
+ * Flags used in g_dbus_request_name().
+ *
+ * Since: 2.4x
+ */
+typedef enum
+{
+ G_BUS_REQUEST_NAME_FLAGS_ERROR = 0,
+ G_BUS_REQUEST_NAME_FLAGS_PRIMARY_OWNER = 1,
+ G_BUS_REQUEST_NAME_FLAGS_IN_QUEUE = 2,
+ G_BUS_REQUEST_NAME_FLAGS_EXISTS = 3,
+ G_BUS_REQUEST_NAME_FLAGS_ALREADY_OWNER = 4
+} GBusRequestNameReplyFlags;
+
+/**
+ * GBusReleaseNameReplyFlags:
+ * @G_BUS_RELEASE_NAME_FLAGS_ERROR: Error flag.
+ * @G_BUS_RELEASE_NAME_FLAGS_RELEASED: The caller has released his claim on the given name.
+ * @G_BUS_RELEASE_NAME_FLAGS_NON_EXISTENT: The given name does not exist on this bus
+ * @G_BUS_RELEASE_NAME_FLAGS_NOT_OWNER: The caller not waiting in the queue to own this name
+ *
+ * Flags used in g_dbus_release_name().
+ *
+ * Since: 2.4x
+ */
+typedef enum
+{
+ G_BUS_RELEASE_NAME_FLAGS_ERROR = 0,
+ G_BUS_RELEASE_NAME_FLAGS_RELEASED = 1,
+ G_BUS_RELEASE_NAME_FLAGS_NON_EXISTENT = 2,
+ G_BUS_RELEASE_NAME_FLAGS_NOT_OWNER = 3
+} GBusReleaseNameReplyFlags;
+
+/**
* GBusNameWatcherFlags:
* @G_BUS_NAME_WATCHER_FLAGS_NONE: No flags set.
* @G_BUS_NAME_WATCHER_FLAGS_AUTO_START: If no-one owns the name when
G_BUS_CREDS_SELINUX_CONTEXT = 4
} GBusCredentialsFlags;
-/* GBusNameOwnerReturnFlags */
-typedef enum
-{
- G_BUS_REQUEST_NAME_REPLY_PRIMARY_OWNER = 1, /* Caller is now the primary owner of the name, replacing any previous owner */
- G_BUS_REQUEST_NAME_REPLY_IN_QUEUE = 2, /* The name already had an owner, the application will be placed in a queue */
- G_BUS_REQUEST_NAME_REPLY_EXISTS = 3, /* The name already has an owner */
- G_BUS_REQUEST_NAME_REPLY_ALREADY_OWNER = 4 /* The application trying to request ownership of a name is already the owner of it */
-} GBusNameOwnerReturnFlags;
-
-/* GBusReleaseNameReturnFlags */
-typedef enum
-{
- G_BUS_RELEASE_NAME_REPLY_RELEASED = 1, /* The caller has released his claim on the given name */
- G_BUS_RELEASE_NAME_REPLY_NON_EXISTENT = 2, /* The given name does not exist on this bus*/
- G_BUS_RELEASE_NAME_REPLY_NOT_OWNER = 3 /* The caller not waiting in the queue to own this name*/
-} GBusReleaseNameReturnFlags;
-
/* GKdbusPrivate struct */
struct _GKdbusPrivate
{
gssize len, size;
gint status, ret;
- status = G_BUS_REQUEST_NAME_REPLY_PRIMARY_OWNER;
+ status = G_BUS_REQUEST_NAME_FLAGS_PRIMARY_OWNER;
kdbus = _g_kdbus_connection_get_kdbus (G_KDBUS_CONNECTION (g_dbus_connection_get_stream (connection)));
if (kdbus == NULL)
if (ret < 0)
{
if (errno == EEXIST)
- status = G_BUS_REQUEST_NAME_REPLY_EXISTS;
+ status = G_BUS_REQUEST_NAME_FLAGS_EXISTS;
else if (errno == EALREADY)
- status = G_BUS_REQUEST_NAME_REPLY_ALREADY_OWNER;
+ status = G_BUS_REQUEST_NAME_FLAGS_ALREADY_OWNER;
else
{
g_set_error (error, G_IO_ERROR,
}
if (kdbus_name->flags & KDBUS_NAME_IN_QUEUE)
- status = G_BUS_REQUEST_NAME_REPLY_IN_QUEUE;
+ status = G_BUS_REQUEST_NAME_FLAGS_IN_QUEUE;
result = g_variant_new ("(u)", status);
gssize len, size;
gint status, ret;
- status = G_BUS_RELEASE_NAME_REPLY_RELEASED;
+ status = G_BUS_RELEASE_NAME_FLAGS_RELEASED;
kdbus = _g_kdbus_connection_get_kdbus (G_KDBUS_CONNECTION (g_dbus_connection_get_stream (connection)));
if (kdbus == NULL)
if (ret < 0)
{
if (errno == ESRCH)
- status = G_BUS_RELEASE_NAME_REPLY_NON_EXISTENT;
+ status = G_BUS_RELEASE_NAME_FLAGS_NON_EXISTENT;
else if (errno == EADDRINUSE)
- status = G_BUS_RELEASE_NAME_REPLY_NOT_OWNER;
+ status = G_BUS_RELEASE_NAME_FLAGS_NOT_OWNER;
else
{
g_set_error (error, G_IO_ERROR,