[Galago-commits] r2528 - branches/galago-daemon/protocol-cleanup/src
galago-commits at freedesktop.org
galago-commits at freedesktop.org
Fri Feb 3 02:18:22 PST 2006
Author: chipx86
Date: 2006-02-03 02:18:19 -0800 (Fri, 03 Feb 2006)
New Revision: 2528
Modified:
branches/galago-daemon/protocol-cleanup/src/account.c
branches/galago-daemon/protocol-cleanup/src/core.c
branches/galago-daemon/protocol-cleanup/src/filter.h
branches/galago-daemon/protocol-cleanup/src/meta-person.c
branches/galago-daemon/protocol-cleanup/src/meta-presence.c
branches/galago-daemon/protocol-cleanup/src/person.c
branches/galago-daemon/protocol-cleanup/src/presence.c
Log:
- Move to using CreatePresence, RemovePresence, PresenceCreated, and PresenceDeleted instead of SetPresence, UnsetPresence, PresenceSet, and PresenceUnset.
- CreatePresence now computes and returns the object path.
- CoCo.AddPerson now computes the object path of the person.
Modified: branches/galago-daemon/protocol-cleanup/src/account.c
===================================================================
--- branches/galago-daemon/protocol-cleanup/src/account.c 2006-02-03 10:16:15 UTC (rev 2527)
+++ branches/galago-daemon/protocol-cleanup/src/account.c 2006-02-03 10:18:19 UTC (rev 2528)
@@ -306,87 +306,96 @@
}
static DBusHandlerResult
-set_unset_presence(DBusConnection *dbus_conn, DBusMessage *message,
- GalagodCoCo *coco, GalagoAccount *account,
- GalagoPresence *presence)
+account_create_presence(DBusConnection *dbus_conn, DBusMessage *message,
+ GalagodCoCo *coco, GalagoAccount *account)
{
+ DBusMessage *reply;
+ DBusMessageIter iter;
GalagodMetaAccount *meta_account;
GalagodMetaPresence *meta_presence = NULL;
GalagoAccount *main_account;
- GalagoPresence *main_presence = NULL;
+ GalagoPresence *main_presence;
+ GalagoPresence *presence;
+ const char *obj_path;
+ gboolean new_presence = FALSE;
meta_account = GALAGOD_META_ACCOUNT(account);
main_account = galagod_meta_account_get_account(meta_account);
main_presence = galago_account_get_presence(main_account, FALSE);
- if (main_presence != NULL)
- meta_presence = GALAGOD_META_PRESENCE(main_presence);
+ presence = galago_account_get_presence(account, FALSE);
if (presence == NULL)
{
- GalagoPresence *old_presence;
+ char *new_obj_path;
- old_presence = galago_account_get_presence(account, FALSE);
+ presence = galago_account_create_presence(account);
+ g_object_set_data(G_OBJECT(presence), "coco", coco);
+ new_obj_path = galagod_presence_generate_path(presence);
+ galago_object_set_dbus_path(GALAGO_OBJECT(presence), new_obj_path);
+ g_free(new_obj_path);
- if (meta_presence != NULL && old_presence != NULL)
- {
- galagod_meta_presence_remove_presence(meta_presence, old_presence);
-
- if (galagod_meta_presence_get_presences(meta_presence) == NULL)
- {
- galagod_meta_presence_destroy(meta_presence);
-
- _galagod_dbus_account_emit(main_account, "PresenceUnset");
- }
- }
+ new_presence = TRUE;
}
else
{
- gboolean new_presence = FALSE;
+ meta_presence = GALAGOD_META_PRESENCE(main_presence);
+ }
- if (meta_presence == NULL)
- {
- meta_presence = galagod_meta_presence_new(meta_account);
- new_presence = TRUE;
- }
+ if (meta_presence == NULL)
+ {
+ meta_presence = galagod_meta_presence_new(meta_account);
+ new_presence = TRUE;
+ }
- g_object_set_data(G_OBJECT(presence), "coco", coco);
-
+ if (new_presence)
+ {
galagod_meta_presence_add_presence(meta_presence, presence);
-
- if (new_presence)
- {
- _galagod_dbus_account_emit_with_object(main_account, "PresenceSet",
- presence);
- }
+ _galagod_dbus_account_emit_with_object(main_account, "PresenceCreated",
+ presence);
}
- _galago_account_set_presence(account, presence);
+ reply = dbus_message_new_method_return(message);
+ dbus_message_iter_init_append(reply, &iter);
+ obj_path = galago_object_get_dbus_path(GALAGO_OBJECT(presence));
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &obj_path);
+ dbus_connection_send(dbus_conn, reply, NULL);
+ dbus_message_unref(reply);
- galagod_dbus_send_empty_reply(dbus_conn, message);
-
return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
-account_set_presence(DBusConnection *dbus_conn, DBusMessage *message,
- GalagodCoCo *coco, GalagoAccount *account)
+account_destroy_presence(DBusConnection *dbus_conn, DBusMessage *message,
+ GalagodCoCo *coco, GalagoAccount *account)
{
- GalagoPresence *presence;
- DBusMessageIter iter;
+ GalagodMetaAccount *meta_account;
+ GalagodMetaPresence *meta_presence = NULL;
+ GalagoAccount *main_account;
+ GalagoPresence *main_presence = NULL;
+ GalagoPresence *old_presence;
- dbus_message_iter_init(message, &iter);
- presence = galago_dbus_message_iter_get_object(&iter,
- GALAGO_TYPE_PRESENCE);
+ meta_account = GALAGOD_META_ACCOUNT(account);
+ main_account = galagod_meta_account_get_account(meta_account);
+ main_presence = galago_account_get_presence(main_account, FALSE);
- return set_unset_presence(dbus_conn, message, coco, account, presence);
-}
+ if (main_presence != NULL)
+ meta_presence = GALAGOD_META_PRESENCE(main_presence);
-static DBusHandlerResult
-account_unset_presence(DBusConnection *dbus_conn, DBusMessage *message,
- GalagodCoCo *coco, GalagoAccount *account)
-{
- return set_unset_presence(dbus_conn, message, coco, account, NULL);
+ old_presence = galago_account_get_presence(account, FALSE);
+
+ if (meta_presence != NULL && old_presence != NULL)
+ {
+ galagod_meta_presence_remove_presence(meta_presence, old_presence);
+
+ if (galagod_meta_presence_get_presences(meta_presence) == NULL)
+ {
+ galagod_meta_presence_destroy(meta_presence);
+ _galagod_dbus_account_emit(main_account, "PresenceDeleted");
+ }
+ }
+
+ return DBUS_HANDLER_RESULT_HANDLED;
}
static DBusHandlerResult
@@ -401,11 +410,13 @@
main_account =
galagod_meta_account_get_account(GALAGOD_META_ACCOUNT(account));
presence = galago_account_get_presence(main_account, FALSE);
+ printf("-- Looking up presence for account %p\n", main_account);
if (presence == NULL)
{
GalagoService *service = galago_account_get_service(main_account);
+ printf("Returning error: no presence\n");
reply = galagod_object_not_found_error_new(message,
"The presence on account '%s' on service '%s' could not be found.",
galago_account_get_username(main_account),
@@ -413,6 +424,7 @@
}
else
{
+ printf("Returning presence\n");
reply = dbus_message_new_method_return(message);
dbus_message_iter_init_append(reply, &iter);
galago_dbus_message_iter_append_object(&iter, GALAGO_OBJECT(presence));
@@ -557,9 +569,9 @@
GALAGOD_COMMAND("GetContact", account_get_contact),
GALAGOD_COMMAND("GetContacts", account_get_contacts),
GALAGOD_COMMAND("GetContactsCount", account_get_contacts_count),
- GALAGOD_COMMAND("SetPresence", account_set_presence),
GALAGOD_COMMAND("GetPresence", account_get_presence),
- GALAGOD_COMMAND("UnsetPresence", account_unset_presence),
+ GALAGOD_COMMAND("CreatePresence", account_create_presence),
+ GALAGOD_COMMAND("DestroyPresence", account_destroy_presence),
GALAGOD_COMMAND("SetAvatar", account_set_avatar),
GALAGOD_COMMAND("GetAvatar", account_get_avatar),
GALAGOD_COMMAND("UnsetAvatar", account_unset_avatar),
Modified: branches/galago-daemon/protocol-cleanup/src/core.c
===================================================================
--- branches/galago-daemon/protocol-cleanup/src/core.c 2006-02-03 10:16:15 UTC (rev 2527)
+++ branches/galago-daemon/protocol-cleanup/src/core.c 2006-02-03 10:18:19 UTC (rev 2528)
@@ -80,20 +80,34 @@
}
static DBusHandlerResult
-coco_add_person(DBusConnection *conn, DBusMessage *message, GalagodCoCo *coco)
+coco_add_person(DBusConnection *dbus_conn, DBusMessage *message,
+ GalagodCoCo *coco)
{
+ DBusMessage *reply;
+ DBusMessageIter iter;
GalagoPerson *person;
- DBusMessageIter iter;
+ char *obj_path;
dbus_message_iter_init(message, &iter);
person = galago_dbus_message_iter_get_object(&iter, GALAGO_TYPE_PERSON);
g_object_set_data(G_OBJECT(person), "coco", coco);
+ /* Send the reply containing the object path. */
+ reply = dbus_message_new_method_return(message);
+ dbus_message_iter_init_append(reply, &iter);
+
+ obj_path = galagod_person_generate_path(person);
+ galago_object_set_dbus_path(GALAGO_OBJECT(person), obj_path);
+ 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);
+
galagod_people_add(person);
- galagod_dbus_send_empty_reply(conn, message);
-
return DBUS_HANDLER_RESULT_HANDLED;
}
Modified: branches/galago-daemon/protocol-cleanup/src/filter.h
===================================================================
--- branches/galago-daemon/protocol-cleanup/src/filter.h 2006-02-03 10:16:15 UTC (rev 2527)
+++ branches/galago-daemon/protocol-cleanup/src/filter.h 2006-02-03 10:18:19 UTC (rev 2528)
@@ -81,9 +81,11 @@
void galagod_account_add_filter(GalagoAccount *account);
void galagod_account_remove_filter(GalagoAccount *account);
+char *galagod_person_generate_path(GalagoPerson *person);
void galagod_person_add_filter(GalagoPerson *person);
void galagod_person_remove_filter(GalagoPerson *person);
+char *galagod_presence_generate_path(GalagoPresence *presence);
void galagod_presence_add_filter(GalagoPresence *presence);
void galagod_presence_remove_filter(GalagoPresence *presence);
Modified: branches/galago-daemon/protocol-cleanup/src/meta-person.c
===================================================================
--- branches/galago-daemon/protocol-cleanup/src/meta-person.c 2006-02-03 10:16:15 UTC (rev 2527)
+++ branches/galago-daemon/protocol-cleanup/src/meta-person.c 2006-02-03 10:18:19 UTC (rev 2528)
@@ -46,13 +46,16 @@
galagod_meta_person_new(void)
{
GalagodMetaPerson *meta_person;
+ char *obj_path;
meta_person = g_new0(GalagodMetaPerson, 1);
galago_context_push(galagod_get_context());
-
meta_person->person = galago_create_person(galagod_get_uid());
+ obj_path = galagod_person_generate_path(meta_person->person);
+ galago_object_set_dbus_path(GALAGO_OBJECT(meta_person->person), obj_path);
+ g_free(obj_path);
galago_context_pop();
g_object_set_data(G_OBJECT(meta_person->person),
Modified: branches/galago-daemon/protocol-cleanup/src/meta-presence.c
===================================================================
--- branches/galago-daemon/protocol-cleanup/src/meta-presence.c 2006-02-03 10:16:15 UTC (rev 2527)
+++ branches/galago-daemon/protocol-cleanup/src/meta-presence.c 2006-02-03 10:18:19 UTC (rev 2528)
@@ -41,8 +41,6 @@
dbus_message_iter_append_basic(&iter, DBUS_TYPE_BOOLEAN, &idle);
dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT32, &idle_start_time);
- g_message("Sending idle = %d, idle_start_time = %ld", idle, idle_start_time);
-
dbus_connection_send(galago_get_dbus_conn(), message, NULL);
dbus_message_unref(message);
}
@@ -52,15 +50,19 @@
{
GalagodMetaPresence *meta_presence;
GalagoAccount *main_account;
+ char *obj_path;
g_return_val_if_fail(meta_account != NULL, NULL);
meta_presence = g_new0(GalagodMetaPresence, 1);
-
main_account = galagod_meta_account_get_account(meta_account);
-
meta_presence->presence = galago_account_create_presence(main_account);
+ obj_path = galagod_presence_generate_path(meta_presence->presence);
+ galago_object_set_dbus_path(GALAGO_OBJECT(meta_presence->presence),
+ obj_path);
+ g_free(obj_path);
+
g_object_set_data(G_OBJECT(meta_presence->presence),
"meta-presence", meta_presence);
Modified: branches/galago-daemon/protocol-cleanup/src/person.c
===================================================================
--- branches/galago-daemon/protocol-cleanup/src/person.c 2006-02-03 10:16:15 UTC (rev 2527)
+++ branches/galago-daemon/protocol-cleanup/src/person.c 2006-02-03 10:18:19 UTC (rev 2528)
@@ -283,6 +283,18 @@
GALAGOD_COMMAND_LAST
};
+char *
+galagod_person_generate_path(GalagoPerson *person)
+{
+ GalagodCoCo *coco = g_object_get_data(G_OBJECT(person), "coco");
+
+ return g_strdup_printf("%s/people/%s",
+ (coco == NULL
+ ? galago_context_get_obj_path_prefix()
+ : galago_object_get_dbus_path(GALAGO_OBJECT(coco))),
+ galago_dbus_normalize_name(galago_person_get_id(person)));
+}
+
void
galagod_person_add_filter(GalagoPerson *person)
{
Modified: branches/galago-daemon/protocol-cleanup/src/presence.c
===================================================================
--- branches/galago-daemon/protocol-cleanup/src/presence.c 2006-02-03 10:16:15 UTC (rev 2527)
+++ branches/galago-daemon/protocol-cleanup/src/presence.c 2006-02-03 10:18:19 UTC (rev 2528)
@@ -225,6 +225,14 @@
GALAGOD_COMMAND_LAST
};
+char *
+galagod_presence_generate_path(GalagoPresence *presence)
+{
+ return g_strdup_printf("%s/presence",
+ galago_object_get_dbus_path(
+ GALAGO_OBJECT(galago_presence_get_account(presence))));
+}
+
void
galagod_presence_add_filter(GalagoPresence *presence)
{
More information about the galago-commits
mailing list