mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 07:26:15 +01:00
gdbus: Move protocol constants from gdbusdaemon into gdbusprivate.h
These well-known flags and replies are part of the D-Bus Specification, and also exist with the same names in libdbus header files. Moving them into a private header means that unit tests like gdbus-proxy-threads and gdbus-subscribe don't have to reinvent them. Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
parent
b0e8612a3b
commit
7401577074
@ -541,8 +541,7 @@ g_application_impl_attempt_primary (GApplicationImpl *impl,
|
|||||||
g_variant_get (reply, "(u)", &rval);
|
g_variant_get (reply, "(u)", &rval);
|
||||||
g_variant_unref (reply);
|
g_variant_unref (reply);
|
||||||
|
|
||||||
/* DBUS_REQUEST_NAME_REPLY_EXISTS: 3 */
|
impl->primary = (rval != DBUS_REQUEST_NAME_REPLY_EXISTS);
|
||||||
impl->primary = (rval != 3);
|
|
||||||
|
|
||||||
if (!impl->primary && impl->name_lost_signal)
|
if (!impl->primary && impl->name_lost_signal)
|
||||||
{
|
{
|
||||||
|
@ -33,26 +33,6 @@
|
|||||||
|
|
||||||
#include "gdbus-daemon-generated.h"
|
#include "gdbus-daemon-generated.h"
|
||||||
|
|
||||||
/* Owner flags */
|
|
||||||
#define DBUS_NAME_FLAG_ALLOW_REPLACEMENT 0x1 /**< Allow another service to become the primary owner if requested */
|
|
||||||
#define DBUS_NAME_FLAG_REPLACE_EXISTING 0x2 /**< Request to replace the current primary owner */
|
|
||||||
#define DBUS_NAME_FLAG_DO_NOT_QUEUE 0x4 /**< If we can not become the primary owner do not place us in the queue */
|
|
||||||
|
|
||||||
/* Replies to request for a name */
|
|
||||||
#define DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER 1 /**< Service has become the primary owner of the requested name */
|
|
||||||
#define DBUS_REQUEST_NAME_REPLY_IN_QUEUE 2 /**< Service could not become the primary owner and has been placed in the queue */
|
|
||||||
#define DBUS_REQUEST_NAME_REPLY_EXISTS 3 /**< Service is already in the queue */
|
|
||||||
#define DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER 4 /**< Service is already the primary owner */
|
|
||||||
|
|
||||||
/* Replies to releasing a name */
|
|
||||||
#define DBUS_RELEASE_NAME_REPLY_RELEASED 1 /**< Service was released from the given name */
|
|
||||||
#define DBUS_RELEASE_NAME_REPLY_NON_EXISTENT 2 /**< The given name does not exist on the bus */
|
|
||||||
#define DBUS_RELEASE_NAME_REPLY_NOT_OWNER 3 /**< Service is not an owner of the given name */
|
|
||||||
|
|
||||||
/* Replies to service starts */
|
|
||||||
#define DBUS_START_REPLY_SUCCESS 1 /**< Service was auto started */
|
|
||||||
#define DBUS_START_REPLY_ALREADY_RUNNING 2 /**< Service was already running */
|
|
||||||
|
|
||||||
#define IDLE_TIMEOUT_MSEC 3000
|
#define IDLE_TIMEOUT_MSEC 3000
|
||||||
|
|
||||||
struct _GDBusDaemon
|
struct _GDBusDaemon
|
||||||
|
@ -319,20 +319,20 @@ request_name_cb (GObject *source_object,
|
|||||||
|
|
||||||
switch (request_name_reply)
|
switch (request_name_reply)
|
||||||
{
|
{
|
||||||
case 1: /* DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER */
|
case DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER:
|
||||||
/* We got the name - now listen for NameLost and NameAcquired */
|
/* We got the name - now listen for NameLost and NameAcquired */
|
||||||
call_acquired_handler (client);
|
call_acquired_handler (client);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2: /* DBUS_REQUEST_NAME_REPLY_IN_QUEUE */
|
case DBUS_REQUEST_NAME_REPLY_IN_QUEUE:
|
||||||
/* Waiting in line - listen for NameLost and NameAcquired */
|
/* Waiting in line - listen for NameLost and NameAcquired */
|
||||||
call_lost_handler (client);
|
call_lost_handler (client);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/* assume we couldn't get the name - explicit fallthrough */
|
/* assume we couldn't get the name - explicit fallthrough */
|
||||||
case 3: /* DBUS_REQUEST_NAME_REPLY_EXISTS */
|
case DBUS_REQUEST_NAME_REPLY_EXISTS:
|
||||||
case 4: /* DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER */
|
case DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER:
|
||||||
/* Some other part of the process is already owning the name */
|
/* Some other part of the process is already owning the name */
|
||||||
call_lost_handler (client);
|
call_lost_handler (client);
|
||||||
unsubscribe = TRUE;
|
unsubscribe = TRUE;
|
||||||
@ -954,7 +954,7 @@ g_bus_unown_name (guint owner_id)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_variant_get (result, "(u)", &release_name_reply);
|
g_variant_get (result, "(u)", &release_name_reply);
|
||||||
if (release_name_reply != 1 /* DBUS_RELEASE_NAME_REPLY_RELEASED */)
|
if (release_name_reply != DBUS_RELEASE_NAME_REPLY_RELEASED)
|
||||||
{
|
{
|
||||||
g_warning ("Unexpected reply %d when releasing name %s", release_name_reply, client->name);
|
g_warning ("Unexpected reply %d when releasing name %s", release_name_reply, client->name);
|
||||||
}
|
}
|
||||||
|
@ -457,11 +457,11 @@ start_service_by_name_cb (GObject *source_object,
|
|||||||
guint32 start_service_result;
|
guint32 start_service_result;
|
||||||
g_variant_get (result, "(u)", &start_service_result);
|
g_variant_get (result, "(u)", &start_service_result);
|
||||||
|
|
||||||
if (start_service_result == 1) /* DBUS_START_REPLY_SUCCESS */
|
if (start_service_result == DBUS_START_REPLY_SUCCESS)
|
||||||
{
|
{
|
||||||
invoke_get_name_owner (client);
|
invoke_get_name_owner (client);
|
||||||
}
|
}
|
||||||
else if (start_service_result == 2) /* DBUS_START_REPLY_ALREADY_RUNNING */
|
else if (start_service_result == DBUS_START_REPLY_ALREADY_RUNNING)
|
||||||
{
|
{
|
||||||
invoke_get_name_owner (client);
|
invoke_get_name_owner (client);
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,26 @@ G_BEGIN_DECLS
|
|||||||
#define DBUS_INTERFACE_DBUS DBUS_SERVICE_DBUS
|
#define DBUS_INTERFACE_DBUS DBUS_SERVICE_DBUS
|
||||||
#define DBUS_PATH_DBUS "/org/freedesktop/DBus"
|
#define DBUS_PATH_DBUS "/org/freedesktop/DBus"
|
||||||
|
|
||||||
|
/* Owner flags */
|
||||||
|
#define DBUS_NAME_FLAG_ALLOW_REPLACEMENT 0x1 /**< Allow another service to become the primary owner if requested */
|
||||||
|
#define DBUS_NAME_FLAG_REPLACE_EXISTING 0x2 /**< Request to replace the current primary owner */
|
||||||
|
#define DBUS_NAME_FLAG_DO_NOT_QUEUE 0x4 /**< If we can not become the primary owner do not place us in the queue */
|
||||||
|
|
||||||
|
/* Replies to request for a name */
|
||||||
|
#define DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER 1 /**< Service has become the primary owner of the requested name */
|
||||||
|
#define DBUS_REQUEST_NAME_REPLY_IN_QUEUE 2 /**< Service could not become the primary owner and has been placed in the queue */
|
||||||
|
#define DBUS_REQUEST_NAME_REPLY_EXISTS 3 /**< Service is already in the queue */
|
||||||
|
#define DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER 4 /**< Service is already the primary owner */
|
||||||
|
|
||||||
|
/* Replies to releasing a name */
|
||||||
|
#define DBUS_RELEASE_NAME_REPLY_RELEASED 1 /**< Service was released from the given name */
|
||||||
|
#define DBUS_RELEASE_NAME_REPLY_NON_EXISTENT 2 /**< The given name does not exist on the bus */
|
||||||
|
#define DBUS_RELEASE_NAME_REPLY_NOT_OWNER 3 /**< Service is not an owner of the given name */
|
||||||
|
|
||||||
|
/* Replies to service starts */
|
||||||
|
#define DBUS_START_REPLY_SUCCESS 1 /**< Service was auto started */
|
||||||
|
#define DBUS_START_REPLY_ALREADY_RUNNING 2 /**< Service was already running */
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
typedef struct GDBusWorker GDBusWorker;
|
typedef struct GDBusWorker GDBusWorker;
|
||||||
|
@ -1563,8 +1563,8 @@ async_init_start_service_by_name_cb (GDBusConnection *connection,
|
|||||||
"(u)",
|
"(u)",
|
||||||
&start_service_result);
|
&start_service_result);
|
||||||
g_variant_unref (result);
|
g_variant_unref (result);
|
||||||
if (start_service_result == 1 || /* DBUS_START_REPLY_SUCCESS */
|
if (start_service_result == DBUS_START_REPLY_SUCCESS ||
|
||||||
start_service_result == 2) /* DBUS_START_REPLY_ALREADY_RUNNING */
|
start_service_result == DBUS_START_REPLY_ALREADY_RUNNING)
|
||||||
{
|
{
|
||||||
/* continue to invoke GetNameOwner() */
|
/* continue to invoke GetNameOwner() */
|
||||||
}
|
}
|
||||||
|
@ -28,18 +28,9 @@
|
|||||||
|
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
|
|
||||||
|
#include "gdbusprivate.h"
|
||||||
#include "gdbus-tests.h"
|
#include "gdbus-tests.h"
|
||||||
|
|
||||||
#ifdef HAVE_DBUS1
|
|
||||||
# include <dbus/dbus-shared.h>
|
|
||||||
#else
|
|
||||||
# define DBUS_INTERFACE_DBUS "org.freedesktop.DBus"
|
|
||||||
# define DBUS_PATH_DBUS "/org/freedesktop/DBus"
|
|
||||||
# define DBUS_SERVICE_DBUS "org.freedesktop.DBus"
|
|
||||||
# define DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER 1
|
|
||||||
# define DBUS_RELEASE_NAME_REPLY_RELEASED 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MY_NAME "com.example.Test.Myself"
|
#define MY_NAME "com.example.Test.Myself"
|
||||||
/* This many threads create and destroy GDBusProxy instances, in addition
|
/* This many threads create and destroy GDBusProxy instances, in addition
|
||||||
* to the main thread processing their NameOwnerChanged signals.
|
* to the main thread processing their NameOwnerChanged signals.
|
||||||
|
@ -5,14 +5,9 @@
|
|||||||
|
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
|
|
||||||
|
#include "gdbusprivate.h"
|
||||||
#include "gdbus-tests.h"
|
#include "gdbus-tests.h"
|
||||||
|
|
||||||
/* From the D-Bus Specification */
|
|
||||||
#define DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER 1
|
|
||||||
|
|
||||||
#define DBUS_SERVICE_DBUS "org.freedesktop.DBus"
|
|
||||||
#define DBUS_PATH_DBUS "/org/freedesktop/DBus"
|
|
||||||
#define DBUS_INTERFACE_DBUS DBUS_SERVICE_DBUS
|
|
||||||
#define NAME_OWNER_CHANGED "NameOwnerChanged"
|
#define NAME_OWNER_CHANGED "NameOwnerChanged"
|
||||||
|
|
||||||
/* A signal that each connection emits to indicate that it has finished
|
/* A signal that each connection emits to indicate that it has finished
|
||||||
|
Loading…
Reference in New Issue
Block a user