diff options
author | James Willcox <jwillcox@gnome.org> | 2003-05-14 02:40:41 +0000 |
---|---|---|
committer | James Willcox <jwillcox@gnome.org> | 2003-05-14 02:40:41 +0000 |
commit | e9cb382daf7cef6396d1777c99f27a050f7ad4a8 (patch) | |
tree | e3cdadde817c2c2d285462ad9d1354a3bc54ec49 /dbus | |
parent | d4e80132af03363a2f861cfd611847ee8758aed9 (diff) |
2003-05-13 James Willcox <jwillcox@gnome.org>
* configure.in:
* bus/activation.c: (bus_activation_service_created),
(bus_activation_activate_service):
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_send_service_lost),
(bus_driver_send_service_acquired),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services):
* bus/session.conf.in:
* dbus/dbus-bus.c: (dbus_bus_acquire_service),
(dbus_bus_service_exists), (dbus_bus_activate_service):
* dbus/dbus-bus.h:
Add some convenience API which lets you activate a service, and did a
bunch of s/0/DBUS_TYPE_INVALID/ in calls to dbus_message_append_args()
and dbus_message_get_args()
Diffstat (limited to 'dbus')
-rw-r--r-- | dbus/dbus-bus.c | 77 | ||||
-rw-r--r-- | dbus/dbus-bus.h | 6 | ||||
-rw-r--r-- | dbus/dbus-message.c | 4 |
3 files changed, 80 insertions, 7 deletions
diff --git a/dbus/dbus-bus.c b/dbus/dbus-bus.c index 9627341e..dee9b9f7 100644 --- a/dbus/dbus-bus.c +++ b/dbus/dbus-bus.c @@ -465,7 +465,7 @@ dbus_bus_register (DBusConnection *connection, goto out; else if (!dbus_message_get_args (reply, error, DBUS_TYPE_STRING, &name, - 0)) + DBUS_TYPE_INVALID)) goto out; bd->base_service = name; @@ -576,7 +576,7 @@ dbus_bus_acquire_service (DBusConnection *connection, if (!dbus_message_append_args (message, DBUS_TYPE_STRING, service_name, DBUS_TYPE_UINT32, flags, - 0)) + DBUS_TYPE_INVALID)) { dbus_message_unref (message); _DBUS_SET_OOM (error); @@ -603,7 +603,7 @@ dbus_bus_acquire_service (DBusConnection *connection, if (!dbus_message_get_args (reply, error, DBUS_TYPE_UINT32, &service_result, - 0)) + DBUS_TYPE_INVALID)) { _DBUS_ASSERT_ERROR_IS_SET (error); dbus_message_unref (reply); @@ -647,7 +647,7 @@ dbus_bus_service_exists (DBusConnection *connection, if (!dbus_message_append_args (message, DBUS_TYPE_STRING, service_name, - 0)) + DBUS_TYPE_INVALID)) { dbus_message_unref (message); _DBUS_SET_OOM (error); @@ -665,7 +665,7 @@ dbus_bus_service_exists (DBusConnection *connection, if (!dbus_message_get_args (reply, error, DBUS_TYPE_UINT32, &exists, - 0)) + DBUS_TYPE_INVALID)) { _DBUS_ASSERT_ERROR_IS_SET (error); return FALSE; @@ -674,4 +674,71 @@ dbus_bus_service_exists (DBusConnection *connection, return (exists != FALSE); } +/** + * Activates a given service + * + * @param connection the connection + * @param service_name the service name + * @param flags the flags + * @param result a place to store the result of the activation, which will + * be one of DBUS_ACTIVATION_REPLY_ACTIVATED or + * DBUS_ACTIVATION_REPLY_ALREADY_ACTIVE if successful. Pass NULL if you + * don't care about the result. + * @param error location to store any errors + * @returns #TRUE if the activation succeeded, #FALSE if not + * + * @todo document what the flags do + */ +dbus_bool_t +dbus_bus_activate_service (DBusConnection *connection, + const char *service_name, + dbus_uint32_t flags, + dbus_uint32_t *result, + DBusError *error) +{ + DBusMessage *msg; + DBusMessage *reply; + + msg = dbus_message_new (DBUS_MESSAGE_ACTIVATE_SERVICE, + DBUS_SERVICE_DBUS); + + if (!dbus_message_append_args (msg, DBUS_TYPE_STRING, service_name, + DBUS_TYPE_UINT32, flags, DBUS_TYPE_INVALID)) + { + dbus_message_unref (msg); + _DBUS_SET_OOM (error); + return FALSE; + } + + reply = dbus_connection_send_with_reply_and_block (connection, msg, + -1, error); + dbus_message_unref (msg); + + if (reply == NULL) + { + _DBUS_ASSERT_ERROR_IS_SET (error); + return FALSE; + } + + if (dbus_set_error_from_message (error, reply)) + { + _DBUS_ASSERT_ERROR_IS_SET (error); + dbus_message_unref (reply); + return FALSE; + } + + if (result != NULL && + !dbus_message_get_args (reply, error, DBUS_TYPE_UINT32, + result, DBUS_TYPE_INVALID)) + { + _DBUS_ASSERT_ERROR_IS_SET (error); + dbus_message_unref (reply); + return FALSE; + } + + dbus_message_unref (reply); + return TRUE; +} + + /** @} */ diff --git a/dbus/dbus-bus.h b/dbus/dbus-bus.h index e3ec054c..a62a746b 100644 --- a/dbus/dbus-bus.h +++ b/dbus/dbus-bus.h @@ -53,6 +53,12 @@ dbus_bool_t dbus_bus_service_exists (DBusConnection *connection, const char *service_name, DBusError *error); +dbus_bool_t dbus_bus_activate_service (DBusConnection *connection, + const char *service_name, + dbus_uint32_t flags, + dbus_uint32_t *reply, + DBusError *error); + DBUS_END_DECLS; #endif /* DBUS_BUS_H */ diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index 7c89d734..4d80425b 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -1229,7 +1229,7 @@ dbus_message_get_destination (DBusMessage *message) * followed by the value to add. Array values are specified by an int * typecode followed by a pointer to the array followed by an int * giving the length of the array. The argument list must be - * terminated with DBUS_TYPE_INVALID. + * terminated with #DBUS_TYPE_INVALID. * * This function doesn't support dicts or non-fundamental arrays. * @@ -1421,7 +1421,7 @@ dbus_message_append_args_valist (DBusMessage *message, * Gets arguments from a message given a variable argument list. * The variable argument list should contain the type of the * argumen followed by a pointer to where the value should be - * stored. The list is terminated with 0. + * stored. The list is terminated with #DBUS_TYPE_INVALID. * * @param message the message * @param error error to be filled in on failure |