Commit 85f8f62d authored by Olivier Andrieu's avatar Olivier Andrieu

* doc/dbus-specification.xml: document ServiceOwnerChanged signal.

* bus/driver.c, bus/driver.h, bus/services.c: Use ServiceOwnerChanged
signal instead of ServiceCreated and ServiceDeleted.

* bus/dispatch.c: update testcase for the new signal.
parent 64b63e84
2004-09-24 Olivier Andrieu <oliv__a@users.sourceforge.net>
* doc/dbus-specification.xml: document ServiceOwnerChanged
signal.
* bus/driver.c, bus/driver.h, bus/services.c: Use
ServiceOwnerChanged signal instead of ServiceCreated and
ServiceDeleted.
* bus/dispatch.c: update testcase for the new signal.
2004-09-20 Jon Trowbridge <trow@ximian.com>
Patch from Nat Friedman <nat@novell.com>
......
This diff is collapsed.
......@@ -39,20 +39,25 @@ static dbus_bool_t bus_driver_send_welcome_message (DBusConnection *connection,
DBusError *error);
dbus_bool_t
bus_driver_send_service_deleted (const char *service_name,
BusTransaction *transaction,
DBusError *error)
bus_driver_send_service_owner_changed (const char *service_name,
const char *old_owner,
const char *new_owner,
BusTransaction *transaction,
DBusError *error)
{
DBusMessage *message;
dbus_bool_t retval;
const char null_service[] = { '\000' };
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
_dbus_verbose ("sending service deleted: %s\n", service_name);
_dbus_verbose ("sending service owner changed: %s [%s -> %s]", service_name,
old_owner ? old_owner : null_service,
new_owner ? new_owner : null_service);
message = dbus_message_new_signal (DBUS_PATH_ORG_FREEDESKTOP_DBUS,
DBUS_INTERFACE_ORG_FREEDESKTOP_DBUS,
"ServiceDeleted");
"ServiceOwnerChanged");
if (message == NULL)
{
......@@ -60,62 +65,25 @@ bus_driver_send_service_deleted (const char *service_name,
return FALSE;
}
if (!dbus_message_set_sender (message, DBUS_SERVICE_ORG_FREEDESKTOP_DBUS) ||
!dbus_message_append_args (message,
if (!dbus_message_set_sender (message, DBUS_SERVICE_ORG_FREEDESKTOP_DBUS))
goto oom;
if (!dbus_message_append_args (message,
DBUS_TYPE_STRING, service_name,
DBUS_TYPE_STRING, old_owner ? old_owner : null_service,
DBUS_TYPE_STRING, new_owner ? new_owner : null_service,
DBUS_TYPE_INVALID))
{
dbus_message_unref (message);
BUS_SET_OOM (error);
return FALSE;
}
goto oom;
retval = bus_dispatch_matches (transaction, NULL, NULL, message, error);
dbus_message_unref (message);
return retval;
}
dbus_bool_t
bus_driver_send_service_created (const char *service_name,
BusTransaction *transaction,
DBusError *error)
{
DBusMessage *message;
dbus_bool_t retval;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
message = dbus_message_new_signal (DBUS_PATH_ORG_FREEDESKTOP_DBUS,
DBUS_INTERFACE_ORG_FREEDESKTOP_DBUS,
"ServiceCreated");
if (message == NULL)
{
BUS_SET_OOM (error);
return FALSE;
}
if (!dbus_message_set_sender (message, DBUS_SERVICE_ORG_FREEDESKTOP_DBUS))
{
dbus_message_unref (message);
BUS_SET_OOM (error);
return FALSE;
}
if (!dbus_message_append_args (message,
DBUS_TYPE_STRING, service_name,
DBUS_TYPE_INVALID))
{
dbus_message_unref (message);
BUS_SET_OOM (error);
return FALSE;
}
retval = bus_dispatch_matches (transaction, NULL, NULL, message, error);
oom:
dbus_message_unref (message);
return retval;
BUS_SET_OOM (error);
return FALSE;
}
dbus_bool_t
......
......@@ -32,9 +32,6 @@ dbus_bool_t bus_driver_handle_message (DBusConnection *connection,
BusTransaction *transaction,
DBusMessage *message,
DBusError *error);
dbus_bool_t bus_driver_send_service_deleted (const char *service_name,
BusTransaction *transaction,
DBusError *error);
dbus_bool_t bus_driver_send_service_lost (DBusConnection *connection,
const char *service_name,
BusTransaction *transaction,
......@@ -43,8 +40,10 @@ dbus_bool_t bus_driver_send_service_acquired (DBusConnection *connection,
const char *service_name,
BusTransaction *transaction,
DBusError *error);
dbus_bool_t bus_driver_send_service_created (const char *service_name,
BusTransaction *transaction,
DBusError *error);
dbus_bool_t bus_driver_send_service_owner_changed (const char *service_name,
const char *old_owner,
const char *new_owner,
BusTransaction *transaction,
DBusError *error);
#endif /* BUS_DRIVER_H */
......@@ -164,7 +164,10 @@ bus_registry_ensure (BusRegistry *registry,
return NULL;
}
if (!bus_driver_send_service_created (service->name, transaction, error))
if (!bus_driver_send_service_owner_changed (service->name,
NULL,
bus_connection_get_name (owner_if_created),
transaction, error))
{
bus_service_unref (service);
return NULL;
......@@ -726,20 +729,31 @@ bus_service_remove_owner (BusService *service,
}
else if (_dbus_list_length_is_one (&service->owners))
{
if (!bus_driver_send_service_deleted (service->name,
transaction, error))
if (!bus_driver_send_service_owner_changed (service->name,
bus_connection_get_name (owner),
NULL,
transaction, error))
return FALSE;
}
else
{
DBusList *link;
DBusConnection *new_owner;
link = _dbus_list_get_first_link (&service->owners);
_dbus_assert (link != NULL);
link = _dbus_list_get_next_link (&service->owners, link);
_dbus_assert (link != NULL);
new_owner = link->data;
if (!bus_driver_send_service_owner_changed (service->name,
bus_connection_get_name (owner),
bus_connection_get_name (new_owner),
transaction, error))
return FALSE;
/* This will be our new owner */
if (!bus_driver_send_service_acquired (link->data,
if (!bus_driver_send_service_acquired (new_owner,
service->name,
transaction,
error))
......
......@@ -2277,19 +2277,14 @@
<para>
This message is sent to a specific application when it loses primary
ownership of a service.
[FIXME instead of ServiceLost/ServiceCreated going only to
a specific app, why not just OwnerChanged that covers both
lost and created and changed owner and deleted]
</para>
</sect3>
<sect3 id="bus-messages-service-created">
<title><literal>org.freedesktop.DBus.ServiceCreated</literal></title>
<sect3 id="bus-messages-service-owner-changed">
<title><literal>org.freedesktop.DBus.ServiceOwnerChanged</literal></title>
<para>
As a method:
<programlisting>
ServiceCreated (in STRING service_name)
ServiceOwnerChanged (STRING service_name, STRING old_owner, STRING new_owner)
</programlisting>
Message arguments:
<informaltable>
......@@ -2309,46 +2304,15 @@
</row>
<row>
<entry>1</entry>
<entry>UINT32</entry>
<entry>Flags</entry>
<entry>STRING</entry>
<entry>Base service of previous owner, empty string if the
service is newly created</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
<para>
This message is broadcast to all applications when a service has been
successfully registered on the message bus.
</para>
</sect3>
<sect3 id="bus-messages-service-deleted">
<title><literal>org.freedesktop.DBus.ServiceDeleted</literal></title>
<para>
As a method:
<programlisting>
ServiceDeleted (in STRING service_name)
</programlisting>
Message arguments:
<informaltable>
<tgroup cols="3">
<thead>
<row>
<entry>Argument</entry>
<entry>Type</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>0</entry>
<entry>STRING</entry>
<entry>Name of the service</entry>
</row>
<row>
<entry>1</entry>
<entry>UINT32</entry>
<entry>Flags</entry>
<entry>2</entry>
<entry>STRING</entry>
<entry>Base service of new owner, empty string if the
service is no longer available</entry>
</row>
</tbody>
</tgroup>
......@@ -2356,7 +2320,8 @@
</para>
<para>
This message is broadcast to all applications when a service has been
deleted from the message bus.
successfully registered on the message bus, has been deleted
or its primary owner has changed.
</para>
</sect3>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment