[Galago-commits] r2563 - in
branches/galago-daemon/protocol-cleanup: . src
galago-commits at freedesktop.org
galago-commits at freedesktop.org
Tue Feb 7 00:51:03 PST 2006
Author: chipx86
Date: 2006-02-07 00:51:00 -0800 (Tue, 07 Feb 2006)
New Revision: 2563
Modified:
branches/galago-daemon/protocol-cleanup/ChangeLog
branches/galago-daemon/protocol-cleanup/src/presence.c
Log:
When a status is added, compute the object path and send it back to the caller.
Modified: branches/galago-daemon/protocol-cleanup/ChangeLog
===================================================================
--- branches/galago-daemon/protocol-cleanup/ChangeLog 2006-02-07 08:50:35 UTC (rev 2562)
+++ branches/galago-daemon/protocol-cleanup/ChangeLog 2006-02-07 08:51:00 UTC (rev 2563)
@@ -1,3 +1,9 @@
+Tue Feb 07 00:50:39 PST 2006 Christian Hammond <chipx86 at chipx86.com>
+
+ * src/presence.c:
+ - When a status is added, compute the object path and send it back
+ to the caller.
+
Mon Feb 06 01:10:05 PST 2006 Christian Hammond <chipx86 at chipx86.com>
* src/person-list.c:
Modified: branches/galago-daemon/protocol-cleanup/src/presence.c
===================================================================
--- branches/galago-daemon/protocol-cleanup/src/presence.c 2006-02-07 08:50:35 UTC (rev 2562)
+++ branches/galago-daemon/protocol-cleanup/src/presence.c 2006-02-07 08:51:00 UTC (rev 2563)
@@ -22,6 +22,14 @@
#include "meta-presence.h"
#include "utils.h"
+static char *
+galagod_status_generate_path(GalagoPresence *presence, GalagoStatus *status)
+{
+ return g_strdup_printf("%s/%s",
+ galago_object_get_dbus_path(GALAGO_OBJECT(presence)),
+ galago_status_get_id(status));
+}
+
static void
_galagod_dbus_presence_emit_status_added(GalagoPresence *presence,
GalagoStatus *status)
@@ -71,24 +79,41 @@
GalagodCoCo *coco, GalagoPresence *presence)
{
GalagoStatus *status;
- GalagodMetaPresence *meta_presence;
+ GalagodMetaPresence *meta_presence = GALAGOD_META_PRESENCE(presence);
GalagoPresence *main_presence;
DBusMessageIter iter;
+ DBusMessage *reply;
const GList* l;
const char *status_id;
int status_weight = 0;
+ char *obj_path;
- meta_presence = GALAGOD_META_PRESENCE(presence);
-
dbus_message_iter_init(message, &iter);
status = galago_dbus_message_iter_get_object(&iter, GALAGO_TYPE_STATUS);
- dbus_message_iter_next(&iter);
+ /* Pull out the status ID and object path, and set it back on the status */
status_id = galago_status_get_id(status);
+ obj_path = galagod_status_generate_path(presence, status);
+ galago_object_set_dbus_path(GALAGO_OBJECT(status), obj_path);
+ /* Send the reply containing the object path. */
+ reply = dbus_message_new_method_return(message);
+ dbus_message_iter_init_append(reply, &iter);
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &obj_path);
+ dbus_connection_send(dbus_conn, reply, NULL);
+ dbus_message_unref(reply);
+ g_free(obj_path);
+
if (!galago_presence_has_status(presence, status_id))
- galago_presence_add_status(presence, galago_status_duplicate(status));
+ {
+ GalagoStatus *dup_status = galago_status_duplicate(status);
+ obj_path = galagod_status_generate_path(presence, dup_status);
+ galago_object_set_dbus_path(GALAGO_OBJECT(dup_status), obj_path);
+ g_free(obj_path);
+ galago_presence_add_status(presence, dup_status);
+ }
+
for (l = galagod_meta_presence_get_presences(meta_presence);
l != NULL;
l = l->next)
@@ -103,25 +128,24 @@
main_presence = galagod_meta_presence_get_presence(meta_presence);
- if (status_weight > 0)
+ if (status_weight > 0 &&
+ !galago_presence_has_status(main_presence, status_id))
{
- if (!galago_presence_has_status(main_presence, status_id))
- {
- galago_context_push(galagod_get_context());
+ GalagoStatus *dup_status;
- galago_presence_add_status(main_presence,
- galago_status_duplicate(status));
+ galago_context_push(galagod_get_context());
+ dup_status = galago_status_duplicate(status);
+ obj_path = galagod_status_generate_path(main_presence, dup_status);
+ galago_object_set_dbus_path(GALAGO_OBJECT(dup_status), obj_path);
+ g_free(obj_path);
+ galago_presence_add_status(main_presence, dup_status);
+ galago_context_pop();
- galago_context_pop();
-
- _galagod_dbus_presence_emit_status_added(main_presence, status);
- }
+ _galagod_dbus_presence_emit_status_added(main_presence, status);
}
g_object_unref(status);
- galagod_dbus_send_empty_reply(dbus_conn, message);
-
return DBUS_HANDLER_RESULT_HANDLED;
}
More information about the galago-commits
mailing list