[Galago-commits] r2527 - in branches/libgalago/protocol-cleanup: .
libgalago
galago-commits at freedesktop.org
galago-commits at freedesktop.org
Fri Feb 3 02:16:18 PST 2006
Author: chipx86
Date: 2006-02-03 02:16:15 -0800 (Fri, 03 Feb 2006)
New Revision: 2527
Modified:
branches/libgalago/protocol-cleanup/ChangeLog
branches/libgalago/protocol-cleanup/libgalago/galago-account.c
branches/libgalago/protocol-cleanup/libgalago/galago-account.h
branches/libgalago/protocol-cleanup/libgalago/galago-core.c
branches/libgalago/protocol-cleanup/libgalago/galago-presence.c
branches/libgalago/protocol-cleanup/libgalago/galago-private.h
Log:
- Replace SetPresence/UnsetPresence calls with CreatePresence/RemovePresence. CreatePresence now returns the object path of the presence object, so we no longer compute this ourselves.
- Listen for PresenceCreated and PresenceDeleted D-BUS signals instead of PresenceSet and PresenceUnset signals.
- Change the GalagoAccount presence signals to be presence_created and presence_deleted.
- Remove _galago_account_set_person().
Modified: branches/libgalago/protocol-cleanup/ChangeLog
===================================================================
--- branches/libgalago/protocol-cleanup/ChangeLog 2006-02-03 08:47:27 UTC (rev 2526)
+++ branches/libgalago/protocol-cleanup/ChangeLog 2006-02-03 10:16:15 UTC (rev 2527)
@@ -1,3 +1,20 @@
+Fri Feb 03 02:13:42 PST 2006 Christian Hammond <chipx86 at chipx86.com>
+
+ * libgalago/galago-account.c:
+ * libgalago/galago-account.h:
+ * libgalago/galago-core.c:
+ * libgalago/galago-presence.c:
+ * libgalago/galago-private.h:
+ - Replace SetPresence/UnsetPresence calls with
+ CreatePresence/RemovePresence. CreatePresence now returns the
+ object path of the presence object, so we no longer compute this
+ ourselves.
+ - Listen for PresenceCreated and PresenceDeleted D-BUS signals instead
+ of PresenceSet and PresenceUnset signals.
+ - Change the GalagoAccount presence signals to be presence_created
+ and presence_deleted.
+ - Remove _galago_account_set_person().
+
Thu Feb 02 23:57:48 PST 2006 Christian Hammond <chipx86 at chipx86.com>
* libgalago/galago-account.c:
Modified: branches/libgalago/protocol-cleanup/libgalago/galago-account.c
===================================================================
--- branches/libgalago/protocol-cleanup/libgalago/galago-account.c 2006-02-03 08:47:27 UTC (rev 2526)
+++ branches/libgalago/protocol-cleanup/libgalago/galago-account.c 2006-02-03 10:16:15 UTC (rev 2527)
@@ -57,15 +57,14 @@
{
CONNECTION_STATE_CHANGED,
DISPLAY_NAME_CHANGED,
- PRESENCE_SET,
+ PRESENCE_CREATED,
+ PRESENCE_DELETED,
AVATAR_SET,
CONTACT_ADDED,
CONTACT_REMOVED,
LAST_SIGNAL
};
-static void _galago_dbus_account_set_presence(GalagoAccount *account,
- GalagoPresence *presence);
static void _galago_dbus_account_set_avatar(GalagoAccount *account,
GalagoImage *avatar);
static void _galago_dbus_account_add_contact(GalagoAccount *account,
@@ -130,16 +129,25 @@
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
- signals[PRESENCE_SET] =
- g_signal_new("presence_set",
+ signals[PRESENCE_CREATED] =
+ g_signal_new("presence_created",
G_TYPE_FROM_CLASS(klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET(GalagoAccountClass, presence_set),
+ G_STRUCT_OFFSET(GalagoAccountClass, presence_created),
NULL, NULL,
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1,
G_TYPE_POINTER);
+ signals[PRESENCE_DELETED] =
+ g_signal_new("presence_deleted",
+ G_TYPE_FROM_CLASS(klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET(GalagoAccountClass, presence_deleted),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
signals[AVATAR_SET] =
g_signal_new("avatar_set",
G_TYPE_FROM_CLASS(klass),
@@ -185,7 +193,7 @@
g_object_class_install_property(gobject_class, PROP_PRESENCE,
g_param_spec_object("presence", "Presence",
"The account's presence",
- GALAGO_TYPE_PRESENCE, G_PARAM_READWRITE));
+ GALAGO_TYPE_PRESENCE, G_PARAM_READABLE));
g_object_class_install_property(gobject_class, PROP_AVATAR,
g_param_spec_object("avatar", "Avatar",
@@ -343,16 +351,14 @@
static void
galago_account_dbus_push_full(GalagoObject *object)
{
- GalagoAccount *account;
+ GalagoAccount *account = GALAGO_ACCOUNT(object);
GList *l;
- account = (GalagoAccount *)object;
+ galago_dbus_object_push_full(
+ GALAGO_OBJECT(galago_account_get_presence(account, FALSE)));
+ galago_dbus_object_push_full(
+ GALAGO_OBJECT(galago_account_get_avatar(account, FALSE)));
- _galago_dbus_account_set_presence(account,
- galago_account_get_presence(account, FALSE));
- _galago_dbus_account_set_avatar(account,
- galago_account_get_avatar(account, FALSE));
-
for (l = galago_account_get_contacts(account, FALSE);
l != NULL;
l = l->next)
@@ -393,11 +399,6 @@
account->priv->person = (GalagoPerson *)g_value_get_object(value);
break;
- case PROP_PRESENCE:
- _galago_account_set_presence(account,
- (GalagoPresence *)g_value_get_object(value));
- break;
-
case PROP_AVATAR:
galago_account_set_avatar(account,
(GalagoImage *)g_value_get_object(value));
@@ -606,24 +607,6 @@
_galago_person_add_account(person, account);
}
-void
-_galago_account_set_person(GalagoAccount *account, GalagoPerson *person)
-{
- g_return_if_fail(account != NULL);
- g_return_if_fail(person != NULL);
- g_return_if_fail(GALAGO_IS_ACCOUNT(account));
- g_return_if_fail(GALAGO_IS_PERSON(person));
- g_return_if_fail(galago_object_get_origin(GALAGO_OBJECT(person)) ==
- galago_object_get_origin(GALAGO_OBJECT(account)));
-
- if (account->priv->person == person)
- return;
-
- _galago_person_remove_account(account->priv->person, account);
- account->priv->person = person;
- _galago_person_add_account(person, account);
-}
-
GalagoPerson *
galago_account_get_person(const GalagoAccount *account)
{
@@ -835,36 +818,6 @@
return account->priv->contacts;
}
-void
-_galago_account_set_presence(GalagoAccount *account, GalagoPresence *presence)
-{
- g_return_if_fail(account != NULL);
- g_return_if_fail(GALAGO_IS_ACCOUNT(account));
-
- if (account->priv->presence == presence)
- return;
-
- if (account->priv->presence != NULL)
- {
- GalagoPresence *old_presence = account->priv->presence;
-
- account->priv->presence = NULL;
-
- if (!GALAGO_OBJECT_HAS_FLAG(old_presence,
- GALAGO_OBJECT_IN_DESTRUCTION))
- {
- g_object_unref(old_presence);
- }
- }
-
- account->priv->presence = presence;
-
- if (GALAGO_OBJECT_IS_LOCAL(account))
- _galago_dbus_account_set_presence(account, presence);
-
- g_signal_emit(account, signals[PRESENCE_SET], 0, presence);
-}
-
GalagoPresence *
galago_account_create_presence(GalagoAccount *account)
{
@@ -942,31 +895,64 @@
return account->priv->avatar;
}
-
-/**************************************************************************
- * D-BUS Functions
- **************************************************************************/
-static void
-_galago_dbus_account_set_presence(GalagoAccount *account,
- GalagoPresence *presence)
+void
+_galago_account_set_presence(GalagoAccount *account, GalagoPresence *presence)
{
- if (!galago_is_connected() || !galago_is_feed())
- return;
+ g_return_if_fail(account != NULL);
+ g_return_if_fail(GALAGO_IS_ACCOUNT(account));
- if (presence == NULL)
+ if (account->priv->presence != NULL)
{
- galago_dbus_send_message(GALAGO_OBJECT(account),
- "UnsetPresence", NULL);
+ GalagoPresence *old_presence = account->priv->presence;
+
+ account->priv->presence = NULL;
+
+ if (!GALAGO_OBJECT_HAS_FLAG(old_presence,
+ GALAGO_OBJECT_IN_DESTRUCTION))
+ {
+ g_object_unref(old_presence);
+ }
+
+ account->priv->presence = NULL;
}
- else
- {
- galago_dbus_send_message(GALAGO_OBJECT(account), "SetPresence",
- galago_value_new_object(GALAGO_TYPE_PRESENCE,
- G_OBJECT(presence)),
- NULL);
- }
+
+ account->priv->presence = presence;
+
+ g_signal_emit(account, signals[PRESENCE_DELETED], 0);
}
+void
+_galago_account_presence_created(GalagoAccount *account,
+ GalagoPresence *presence)
+{
+ g_return_if_fail(account != NULL);
+ g_return_if_fail(GALAGO_IS_ACCOUNT(account));
+ g_return_if_fail(presence != NULL);
+ g_return_if_fail(GALAGO_IS_PRESENCE(presence));
+
+ /*
+ * We should already have account->priv->presence set, since that's
+ * done in the constructor.
+ */
+
+ g_signal_emit(account, signals[PRESENCE_CREATED], 0, presence);
+}
+
+void
+_galago_account_presence_deleted(GalagoAccount *account)
+{
+ g_return_if_fail(account != NULL);
+ g_return_if_fail(GALAGO_IS_ACCOUNT(account));
+
+ _galago_account_set_presence(account, NULL);
+
+ g_signal_emit(account, signals[PRESENCE_DELETED], 0);
+}
+
+
+/**************************************************************************
+ * D-BUS Functions
+ **************************************************************************/
static void
_galago_dbus_account_set_avatar(GalagoAccount *account, GalagoImage *avatar)
{
Modified: branches/libgalago/protocol-cleanup/libgalago/galago-account.h
===================================================================
--- branches/libgalago/protocol-cleanup/libgalago/galago-account.h 2006-02-03 08:47:27 UTC (rev 2526)
+++ branches/libgalago/protocol-cleanup/libgalago/galago-account.h 2006-02-03 10:16:15 UTC (rev 2527)
@@ -2,10 +2,10 @@
* @file libgalago/galago-account.h Galago Account API
* @ingroup Presence
*
+ * @Copyright (C) 2004-2005 Christian Hammond
+ *
* #GalagoAccount models a single account a #GalagoPerson has with a
* provider (a #GalagoService).
- *
- * @Copyright (C) 2004-2005 Christian Hammond
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -62,7 +62,8 @@
/* Signals */
void (*connection_state_changed)(GalagoAccount *account);
void (*display_name_changed)(GalagoAccount *account);
- void (*presence_set)(GalagoAccount *account, GalagoPresence *presence);
+ void (*presence_created)(GalagoAccount *account, GalagoPresence *presence);
+ void (*presence_deleted)(GalagoAccount *account);
void (*avatar_set)(GalagoAccount *account, GalagoImage *image);
void (*contact_added)(GalagoAccount *account, GalagoAccount *contact);
void (*contact_removed)(GalagoAccount *account, GalagoAccount *contact);
Modified: branches/libgalago/protocol-cleanup/libgalago/galago-core.c
===================================================================
--- branches/libgalago/protocol-cleanup/libgalago/galago-core.c 2006-02-03 08:47:27 UTC (rev 2526)
+++ branches/libgalago/protocol-cleanup/libgalago/galago-core.c 2006-02-03 10:16:15 UTC (rev 2527)
@@ -536,19 +536,27 @@
* Account
*/
else if (dbus_message_is_signal(message, GALAGO_DBUS_ACCOUNT_INTERFACE,
- "PresenceSet"))
+ "PresenceCreated"))
{
- galago_dbus_message_iter_get_object(&iter, GALAGO_TYPE_PRESENCE);
+ GalagoAccount *account;
+ GalagoPresence *presence;
+
+ account = GALAGO_ACCOUNT(galago_context_get_object(path));
+ presence = galago_dbus_message_iter_get_object(&iter,
+ GALAGO_TYPE_PRESENCE);
+ g_assert(galago_account_get_presence(account, FALSE) == presence);
+
+ _galago_account_presence_created(account, presence);
}
else if (dbus_message_is_signal(message, GALAGO_DBUS_ACCOUNT_INTERFACE,
- "PresenceUnset"))
+ "PresenceDeleted"))
{
GalagoAccount *account;
account = GALAGO_ACCOUNT(galago_context_get_object(path));
if (account != NULL)
- _galago_account_set_presence(account, NULL);
+ _galago_account_presence_deleted(account);
}
else if (dbus_message_is_signal(message, GALAGO_DBUS_ACCOUNT_INTERFACE,
"Connected"))
Modified: branches/libgalago/protocol-cleanup/libgalago/galago-presence.c
===================================================================
--- branches/libgalago/protocol-cleanup/libgalago/galago-presence.c 2006-02-03 08:47:27 UTC (rev 2526)
+++ branches/libgalago/protocol-cleanup/libgalago/galago-presence.c 2006-02-03 10:16:15 UTC (rev 2527)
@@ -54,6 +54,10 @@
LAST_SIGNAL
};
+static void _galago_dbus_account_create_presence(GalagoAccount *account,
+ GalagoPresence *presence);
+static void _galago_dbus_account_destroy_presence(GalagoAccount *account,
+ GalagoPresence *presence);
static void _galago_presence_remove_status(GalagoPresence *presence,
GalagoStatus *status);
@@ -176,10 +180,11 @@
account = galago_presence_get_account(presence);
- if (account != NULL &&
+ if (account != NULL && GALAGO_OBJECT_IS_LOCAL(presence) &&
galago_account_get_presence(account, FALSE) == presence)
{
_galago_account_set_presence(account, NULL);
+ _galago_dbus_account_destroy_presence(account, presence);
}
if (presence->priv != NULL)
@@ -290,7 +295,7 @@
static void
galago_presence_get_property(GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
+ GValue *value, GParamSpec *pspec)
{
GalagoPresence *presence = GALAGO_PRESENCE(object);
@@ -327,7 +332,10 @@
NULL);
galago_context_pop();
- galago_object_set_dbus_path(GALAGO_OBJECT(presence), obj_path);
+ if (obj_path == NULL)
+ _galago_dbus_account_create_presence(account, presence);
+ else
+ galago_object_set_dbus_path(GALAGO_OBJECT(presence), obj_path);
_galago_account_set_presence(account, presence);
}
@@ -773,3 +781,33 @@
}
}
}
+
+static void
+_galago_dbus_account_create_presence(GalagoAccount *account,
+ GalagoPresence *presence)
+{
+ char *obj_path;
+
+ if (!galago_is_connected() || !galago_is_feed())
+ return;
+
+ obj_path = galago_dbus_send_message_with_reply(
+ GALAGO_OBJECT(account), "CreatePresence",
+ galago_value_new(GALAGO_VALUE_TYPE_STRING, NULL, NULL),
+ NULL);
+
+ g_assert(obj_path != NULL);
+
+ galago_object_set_dbus_path(GALAGO_OBJECT(presence), obj_path);
+ g_free(obj_path);
+}
+
+static void
+_galago_dbus_account_destroy_presence(GalagoAccount *account,
+ GalagoPresence *presence)
+{
+ if (!galago_is_connected() || !galago_is_feed())
+ return;
+
+ galago_dbus_send_message(GALAGO_OBJECT(account), "DestroyPresence", NULL);
+}
Modified: branches/libgalago/protocol-cleanup/libgalago/galago-private.h
===================================================================
--- branches/libgalago/protocol-cleanup/libgalago/galago-private.h 2006-02-03 08:47:27 UTC (rev 2526)
+++ branches/libgalago/protocol-cleanup/libgalago/galago-private.h 2006-02-03 10:16:15 UTC (rev 2527)
@@ -55,6 +55,11 @@
GalagoPerson *person,
const char *username,
const char *obj_path);
+
+void _galago_account_presence_created(GalagoAccount *account,
+ GalagoPresence *presence);
+void _galago_account_presence_deleted(GalagoAccount *account);
+
/**
* Sets the account's presence.
*
More information about the galago-commits
mailing list