[Galago-commits] r2575 - in trunk/libgalago: . docs/protocol
libgalago tests
galago-commits at freedesktop.org
galago-commits at freedesktop.org
Sun Feb 12 03:23:37 PST 2006
Author: chipx86
Date: 2006-02-12 03:23:31 -0800 (Sun, 12 Feb 2006)
New Revision: 2575
Modified:
trunk/libgalago/ChangeLog
trunk/libgalago/docs/protocol/protocol.hh
trunk/libgalago/libgalago/galago-context.c
trunk/libgalago/libgalago/galago-context.h
trunk/libgalago/libgalago/galago-core.c
trunk/libgalago/libgalago/galago-person.c
trunk/libgalago/libgalago/galago-person.h
trunk/libgalago/libgalago/galago-private.h
trunk/libgalago/tests/check-libgalago.c
trunk/libgalago/tests/presence-feed.c
Log:
Move to the new method of handling person IDs. Now, an ID should only be set when creating a person if the feed can tie that ID to the person at a later date (for example, eds-feed uses the person ID from the database).
Internally, we now use a per-session handle ID for keeping track of state and storing in the cache. While there is a public function for retrieving this, there's no reason for apps to really use it.
Modified: trunk/libgalago/ChangeLog
===================================================================
--- trunk/libgalago/ChangeLog 2006-02-09 08:35:51 UTC (rev 2574)
+++ trunk/libgalago/ChangeLog 2006-02-12 11:23:31 UTC (rev 2575)
@@ -1,3 +1,22 @@
+Sun Feb 12 03:21:46 PST 2006 Christian Hammond <chipx86 at chipx86.com>
+
+ * docs/protocol/protocol.hh:
+ * libgalago/galago-context.c:
+ * libgalago/galago-context.h:
+ * libgalago/galago-core.c:
+ * libgalago/galago-person.c:
+ * libgalago/galago-person.h:
+ * libgalago/galago-private.h:
+ * tests/check-libgalago.c:
+ * tests/presence-feed.c:
+ - Move to the new method of handling person IDs. Now, an ID should
+ only be set when creating a person if the feed can tie that ID to
+ the person at a later date (for example, eds-feed uses the person ID
+ from the database). Internally, we now use a per-session handle ID
+ for keeping track of state and storing in the cache. While there is a
+ public function for retrieving this, there's no reason for apps to
+ really use it.
+
Thu Feb 09 00:08:19 PST 2006 Christian Hammond <chipx86 at chipx86.com>
* libgalago/Makefile.am:
Modified: trunk/libgalago/docs/protocol/protocol.hh
===================================================================
--- trunk/libgalago/docs/protocol/protocol.hh 2006-02-09 08:35:51 UTC (rev 2574)
+++ trunk/libgalago/docs/protocol/protocol.hh 2006-02-12 11:23:31 UTC (rev 2575)
@@ -370,9 +370,10 @@
class Person
{
public:
- string ObjPath; //!< Object path of the person.
- string Id; //!< The person's ID.
- bool IsMe; //!< Flag specifying if this person is the "Me" person.
+ string ObjPath; //!< Object path of the person.
+ string Id; //!< The person's ID.
+ string sessionId; //<! Client-defined per-session handle ID.
+ bool IsMe; //!< Flag specifying if this person is the "Me" person.
/**
* @name Methods
Modified: trunk/libgalago/libgalago/galago-context.c
===================================================================
--- trunk/libgalago/libgalago/galago-context.c 2006-02-09 08:35:51 UTC (rev 2574)
+++ trunk/libgalago/libgalago/galago-context.c 2006-02-12 11:23:31 UTC (rev 2575)
@@ -55,9 +55,17 @@
char *id;
GalagoOrigin origin;
-} ServicePersonCacheKey;
+} ServiceCacheKey;
+typedef struct
+{
+ char *id;
+ char *session_id;
+ GalagoOrigin origin;
+} PersonCacheKey;
+
+
/**************************************************************************
* Object initialization
**************************************************************************/
@@ -79,25 +87,53 @@
}
static guint
-cache_key_hash(gconstpointer key)
+service_cache_key_hash(gconstpointer key)
{
- return g_str_hash(((ServicePersonCacheKey *)key)->id);
+ return g_str_hash(((ServiceCacheKey *)key)->id);
}
+static guint
+person_cache_key_hash(gconstpointer key)
+{
+ return g_str_hash(((PersonCacheKey *)key)->session_id);
+}
+
static gboolean
-cache_key_equal(gconstpointer a, gconstpointer b)
+service_cache_key_equal(gconstpointer a, gconstpointer b)
{
- ServicePersonCacheKey *key1 = (ServicePersonCacheKey *)a;
- ServicePersonCacheKey *key2 = (ServicePersonCacheKey *)b;
+ ServiceCacheKey *key1 = (ServiceCacheKey *)a;
+ ServiceCacheKey *key2 = (ServiceCacheKey *)b;
- return (g_str_equal(key1->id, key2->id) &&
- key1->origin == key2->origin);
+#if 0
+ g_assert(key1->id != NULL || key1->session_id != NULL);
+ g_assert(key2->id != NULL || key2->session_id != NULL);
+#endif
+
+ return key1->origin == key2->origin && g_str_equal(key1->id, key2->id);
}
+static gboolean
+person_cache_key_equal(gconstpointer a, gconstpointer b)
+{
+ PersonCacheKey *key1 = (PersonCacheKey *)a;
+ PersonCacheKey *key2 = (PersonCacheKey *)b;
+
+#if 0
+ g_assert(key1->id != NULL || key1->session_id != NULL);
+ g_assert(key2->id != NULL || key2->session_id != NULL);
+#endif
+
+ return key1->origin == key2->origin &&
+ ((key1->id != NULL && key2->id != NULL &&
+ g_str_equal(key1->id, key2->id)) ||
+ (key1->session_id != NULL && key2->session_id != NULL &&
+ g_str_equal(key1->session_id, key2->session_id)));
+}
+
static void
-cache_key_destroy(void *ptr)
+service_cache_key_destroy(void *ptr)
{
- ServicePersonCacheKey *key = (ServicePersonCacheKey *)ptr;
+ ServiceCacheKey *key = (ServiceCacheKey *)ptr;
if (key->id != NULL)
g_free(key->id);
@@ -106,17 +142,31 @@
}
static void
+person_cache_key_destroy(void *ptr)
+{
+ PersonCacheKey *key = (PersonCacheKey *)ptr;
+
+ if (key->id != NULL)
+ g_free(key->id);
+
+ if (key->session_id != NULL)
+ g_free(key->session_id);
+
+ g_free(key);
+}
+
+static void
galago_context_init(GalagoContext *context)
{
context->priv = g_new0(GalagoContextPrivate, 1);
context->priv->services_table =
- g_hash_table_new_full(cache_key_hash, cache_key_equal,
- cache_key_destroy, NULL);
+ g_hash_table_new_full(service_cache_key_hash, service_cache_key_equal,
+ service_cache_key_destroy, NULL);
context->priv->people_table =
- g_hash_table_new_full(cache_key_hash, cache_key_equal,
- cache_key_destroy, NULL);
+ g_hash_table_new_full(person_cache_key_hash, person_cache_key_equal,
+ person_cache_key_destroy, NULL);
context->priv->obj_tree =
g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
@@ -228,7 +278,7 @@
void
galago_context_add_service(GalagoService *service)
{
- ServicePersonCacheKey *key;
+ ServiceCacheKey *key;
GalagoContext *context;
g_return_if_fail(galago_is_initted());
@@ -238,7 +288,7 @@
context = galago_context_get();
g_return_if_fail(context != NULL);
- key = g_new0(ServicePersonCacheKey, 1);
+ key = g_new0(ServiceCacheKey, 1);
key->id = g_ascii_strdown(galago_service_get_id(service), -1);
key->origin = galago_object_get_origin(GALAGO_OBJECT(service));
@@ -260,7 +310,7 @@
g_assert_not_reached();
}
- cache_key_destroy(key);
+ service_cache_key_destroy(key);
return;
}
@@ -294,7 +344,7 @@
galago_context_remove_service(GalagoService *service)
{
GalagoContext *context;
- ServicePersonCacheKey key;
+ ServiceCacheKey key;
g_return_if_fail(galago_is_initted());
g_return_if_fail(service != NULL);
@@ -338,7 +388,7 @@
{
GalagoContext *context;
GalagoService *service;
- ServicePersonCacheKey key;
+ ServiceCacheKey key;
g_return_val_if_fail(galago_is_initted(), NULL);
g_return_val_if_fail(id != NULL, NULL);
@@ -382,11 +432,63 @@
}
}
+static void
+add_person_to_table(GalagoPerson *person)
+{
+ GalagoContext *context = galago_context_get();
+ const char *id = galago_person_get_id(person);
+ const char *session_id = galago_person_get_session_id(person);
+ PersonCacheKey *key;
+
+ key = g_new0(PersonCacheKey, 1);
+ key->id = (id == NULL ? NULL : g_ascii_strdown(id, -1));
+ key->session_id = g_strdup(session_id);
+ key->origin = galago_object_get_origin(GALAGO_OBJECT(person));
+ g_hash_table_replace(context->priv->people_table, key, person);
+}
+
+static void
+remove_person_from_table(GalagoPerson *person)
+{
+ GalagoContext *context = galago_context_get();
+ PersonCacheKey key;
+ const char *old_id = g_object_get_data(G_OBJECT(person),
+ "_galago_old_id");
+
+ if (old_id == NULL)
+ return;
+
+ key.id = g_ascii_strdown(galago_person_get_id(person), -1);
+ key.session_id = g_strdup(galago_person_get_session_id(person));
+ key.origin = galago_object_get_origin(GALAGO_OBJECT(person));
+ g_hash_table_remove(context->priv->people_table, &key);
+ g_free(key.id);
+}
+
+static void
+person_id_changed_cb(GalagoPerson *person)
+{
+ const char *id = galago_person_get_id(person);
+ const char *old_id = g_object_get_data(G_OBJECT(person),
+ "_galago_old_id");
+
+ if (!strcmp(id, old_id))
+ return;
+
+ remove_person_from_table(person);
+ add_person_to_table(person);
+
+ g_object_set_data_full(G_OBJECT(person), "_galago_old_id",
+ (id == NULL ? NULL : g_strdup(id)), g_free);
+}
+
void
galago_context_add_person(GalagoPerson *person)
{
GalagoContext *context;
- ServicePersonCacheKey *key;
+ const char *session_id;
+ GalagoOrigin origin;
+ unsigned int signal_id;
g_return_if_fail(galago_is_initted());
g_return_if_fail(person != NULL);
@@ -395,32 +497,35 @@
context = galago_context_get();
g_return_if_fail(context != NULL);
- key = g_new0(ServicePersonCacheKey, 1);
- key->id = g_ascii_strdown(galago_person_get_id(person), -1);
- key->origin = galago_object_get_origin(GALAGO_OBJECT(person));
+ origin = galago_object_get_origin(GALAGO_OBJECT(person));
+ session_id = galago_person_get_session_id(person);
- if (galago_context_get_person(key->id, key->origin) != NULL)
+ if (session_id != NULL)
{
- switch (key->origin)
+ if (galago_context_get_person_with_session_id(session_id, origin)
+ != NULL)
{
- case GALAGO_LOCAL:
- g_warning("A local person with ID %s has already been added.",
- key->id);
- break;
+ switch (origin)
+ {
+ case GALAGO_LOCAL:
+ g_warning("A local person with seesion ID %s has already "
+ "been added.", session_id);
+ break;
- case GALAGO_REMOTE:
- g_warning("A remote person with ID %s has already been added.",
- key->id);
- break;
+ case GALAGO_REMOTE:
+ g_warning("A remote person with session ID %s has already "
+ "been added.", session_id);
+ break;
- default:
- g_assert_not_reached();
+ default:
+ g_assert_not_reached();
+ }
+
+ return;
}
-
- return;
}
- switch (key->origin)
+ switch (origin)
{
case GALAGO_LOCAL:
context->priv->local.people =
@@ -436,8 +541,13 @@
g_assert_not_reached();
}
- g_hash_table_insert(context->priv->people_table, key, person);
+ signal_id = g_signal_connect(G_OBJECT(person), "notify::id",
+ G_CALLBACK(person_id_changed_cb), NULL);
+ g_object_set_data(G_OBJECT(person), "_galago_id_signal_id",
+ GINT_TO_POINTER(signal_id));
+ add_person_to_table(person);
+
if (context->priv->ops != NULL &&
context->priv->ops->person_added != NULL)
{
@@ -449,7 +559,7 @@
galago_context_remove_person(GalagoPerson *person)
{
GalagoContext *context;
- ServicePersonCacheKey key;
+ unsigned int signal_id;
g_return_if_fail(galago_is_initted());
g_return_if_fail(person != NULL);
@@ -458,10 +568,7 @@
context = galago_context_get();
g_return_if_fail(context != NULL);
- key.id = g_ascii_strdown(galago_person_get_id(person), -1);
- key.origin = galago_object_get_origin(GALAGO_OBJECT(person));
-
- switch (key.origin)
+ switch (galago_object_get_origin(GALAGO_OBJECT(person)))
{
case GALAGO_LOCAL:
context->priv->local.people =
@@ -477,10 +584,15 @@
g_assert_not_reached();
}
- g_hash_table_remove(context->priv->people_table, &key);
+ remove_person_from_table(person);
- g_free(key.id);
+ signal_id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(person),
+ "_galago_id_signal_id"));
+ if (signal_id > 0)
+ g_signal_handler_disconnect(person, signal_id);
+ g_object_set_data(G_OBJECT(person), "_galago_id_signal_id", NULL);
+
if (context->priv->ops != NULL &&
context->priv->ops->person_removed != NULL)
{
@@ -493,7 +605,7 @@
{
GalagoContext *context;
GalagoPerson *person;
- ServicePersonCacheKey key;
+ PersonCacheKey key;
g_return_val_if_fail(galago_is_initted(), FALSE);
g_return_val_if_fail(id != NULL, NULL);
@@ -502,16 +614,44 @@
context = galago_context_get();
g_return_val_if_fail(context != NULL, NULL);
- key.id = g_ascii_strdown(id, -1);
- key.origin = origin;
+ key.id = g_ascii_strdown(id, -1);
+ key.session_id = g_ascii_strdown(id, -1); // XXX
+ key.origin = origin;
person = g_hash_table_lookup(context->priv->people_table, &key);
g_free(key.id);
+ g_free(key.session_id); // XXX
return person;
}
+GalagoPerson *
+galago_context_get_person_with_session_id(const char *session_id,
+ GalagoOrigin origin)
+{
+ GalagoContext *context;
+ GalagoPerson *person;
+ PersonCacheKey key;
+
+ g_return_val_if_fail(galago_is_initted(), FALSE);
+ g_return_val_if_fail(session_id != NULL, NULL);
+ g_return_val_if_fail(GALAGO_ORIGIN_IS_VALID(origin), NULL);
+
+ context = galago_context_get();
+ g_return_val_if_fail(context != NULL, NULL);
+
+ key.id = NULL;
+ key.session_id = g_ascii_strdown(session_id, -1);
+ key.origin = origin;
+
+ person = g_hash_table_lookup(context->priv->people_table, &key);
+
+ g_free(key.session_id);
+
+ return person;
+}
+
GList *
galago_context_get_people(GalagoOrigin origin)
{
Modified: trunk/libgalago/libgalago/galago-context.h
===================================================================
--- trunk/libgalago/libgalago/galago-context.h 2006-02-09 08:35:51 UTC (rev 2574)
+++ trunk/libgalago/libgalago/galago-context.h 2006-02-12 11:23:31 UTC (rev 2575)
@@ -120,6 +120,17 @@
GalagoPerson *galago_context_get_person(const char *id, GalagoOrigin origin);
/**
+ * Returns the person with the specified session ID.
+ *
+ * @param id The person's session ID.
+ * @param origin The object's origin.
+ *
+ * @return The person, if found, or NULL.
+ */
+GalagoPerson *galago_context_get_person_with_session_id(const char *session_id,
+ GalagoOrigin origin);
+
+/**
* Returns a list of all people.
*
* @param origin The object's origin.
Modified: trunk/libgalago/libgalago/galago-core.c
===================================================================
--- trunk/libgalago/libgalago/galago-core.c 2006-02-09 08:35:51 UTC (rev 2574)
+++ trunk/libgalago/libgalago/galago-core.c 2006-02-12 11:23:31 UTC (rev 2575)
@@ -1378,7 +1378,7 @@
DBusConnection *dbus_conn;
DBusMessage *message, *reply;
DBusMessageIter iter;
- const char *obj_path;
+ const char *obj_path, *uid, *session_id;
DBusError error;
g_signal_emit(_core, signals[PERSON_ADDED], 0, person);
@@ -1416,8 +1416,12 @@
dbus_message_iter_init(reply, &iter);
dbus_message_iter_get_basic(&iter, &obj_path);
+ dbus_message_iter_get_basic(&iter, &uid);
+// dbus_message_iter_get_basic(&iter, &session_id);
galago_object_set_dbus_path(GALAGO_OBJECT(person), obj_path);
+ _galago_person_set_id(person, uid);
+// _galago_person_set_session_id(person, session_id);
}
static void
Modified: trunk/libgalago/libgalago/galago-person.c
===================================================================
--- trunk/libgalago/libgalago/galago-person.c 2006-02-09 08:35:51 UTC (rev 2574)
+++ trunk/libgalago/libgalago/galago-person.c 2006-02-12 11:23:31 UTC (rev 2575)
@@ -31,6 +31,7 @@
struct _GalagoPersonPrivate
{
char *id;
+ char *session_id;
GalagoImage *photo;
GHashTable *accounts_table;
GList *accounts;
@@ -47,6 +48,7 @@
{
PROP_0,
PROP_ID,
+ PROP_SESSION_ID,
PROP_PHOTO
};
@@ -61,7 +63,9 @@
/* galago-core.c */
GalagoAccount *_galago_core_calc_priority_account(const GalagoPerson *person);
-static GalagoPerson *_galago_person_new(const char *id, GalagoOrigin origin,
+static GalagoPerson *_galago_person_new(const char *id,
+ const char *session_id,
+ GalagoOrigin origin,
const char *obj_path);
static void _galago_dbus_person_set_photo(GalagoPerson *person,
GalagoImage *photo);
@@ -138,10 +142,16 @@
g_object_class_install_property(gobject_class, PROP_ID,
g_param_spec_string("id", "ID",
- "The person's unique ID",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ "The person's unique ID",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property(gobject_class, PROP_SESSION_ID,
+ g_param_spec_string("session_id", "Session ID",
+ "The person's session ID",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
g_object_class_install_property(gobject_class, PROP_PHOTO,
g_param_spec_object("photo", "Photo",
"The person's unique ID",
@@ -225,15 +235,17 @@
const GalagoObject *object)
{
GalagoPerson *person = (GalagoPerson *)object;
- const char *obj_path, *id;
+ const char *obj_path, *session_id, *id;
gboolean is_me;
- obj_path = galago_object_get_dbus_path(GALAGO_OBJECT(person));
- id = galago_person_get_id(person);
- is_me = galago_person_is_me(person);
+ obj_path = galago_object_get_dbus_path(GALAGO_OBJECT(person));
+ id = galago_person_get_id(person);
+ session_id = galago_person_get_session_id(person);
+ is_me = galago_person_is_me(person);
galago_dbus_message_iter_append_string_or_nil(iter, obj_path);
- dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &id);
+ galago_dbus_message_iter_append_string_or_nil(iter, id);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &session_id);
dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &is_me);
}
@@ -241,21 +253,24 @@
galago_person_dbus_message_get(DBusMessageIter *iter)
{
GalagoPerson *person;
- const char *obj_path, *uid;
+ const char *obj_path, *uid, *session_id;
gboolean me;
obj_path = galago_dbus_message_iter_get_string_or_nil(iter);
dbus_message_iter_next(iter);
- dbus_message_iter_get_basic(iter, &uid);
+ uid = galago_dbus_message_iter_get_string_or_nil(iter);
dbus_message_iter_next(iter);
+ dbus_message_iter_get_basic(iter, &session_id);
+ dbus_message_iter_next(iter);
+
dbus_message_iter_get_basic(iter, &me);
if (me)
uid = GALAGO_ME_ID;
- person = _galago_person_new(uid, GALAGO_REMOTE, obj_path);
+ person = _galago_person_new(uid, session_id, GALAGO_REMOTE, obj_path);
return person;
}
@@ -277,6 +292,7 @@
{
return g_strdup(DBUS_TYPE_STRING_AS_STRING // obj path
DBUS_TYPE_STRING_AS_STRING // id
+ DBUS_TYPE_STRING_AS_STRING // session id
DBUS_TYPE_BOOLEAN_AS_STRING); // me
}
@@ -292,6 +308,10 @@
person->priv->id = g_value_dup_string(value);
break;
+ case PROP_SESSION_ID:
+ person->priv->session_id = g_value_dup_string(value);
+ break;
+
case PROP_PHOTO:
galago_person_set_photo(person,
GALAGO_IMAGE(g_value_get_object(value)));
@@ -315,6 +335,10 @@
g_value_set_string(value, galago_person_get_id(person));
break;
+ case PROP_SESSION_ID:
+ g_value_set_string(value, galago_person_get_session_id(person));
+ break;
+
case PROP_PHOTO:
g_value_set_object(value, galago_person_get_photo(person, TRUE));
break;
@@ -330,19 +354,28 @@
* GalagoPerson API
**************************************************************************/
static GalagoPerson *
-_galago_person_new(const char *uid, GalagoOrigin origin, const char *obj_path)
+_galago_person_new(const char *uid, const char *session_id,
+ GalagoOrigin origin, const char *obj_path)
{
- GalagoPerson *person;
+ GalagoPerson *person = NULL;
- g_return_val_if_fail(galago_is_initted(), NULL);
- g_return_val_if_fail(uid != NULL && *uid != '\0', NULL);
+ g_return_val_if_fail(galago_is_initted(), NULL);
- person = galago_context_get_person(uid, origin);
+ if (session_id != NULL)
+ {
+ person = galago_context_get_person_with_session_id(session_id,
+ origin);
+ }
+ else if (uid != NULL)
+ {
+ person = galago_context_get_person(uid, origin);
+ }
if (person == NULL)
{
person = g_object_new(GALAGO_TYPE_PERSON,
"id", uid,
+ "session_id", session_id,
"origin", origin,
NULL);
@@ -359,10 +392,20 @@
GalagoPerson *
galago_create_person(const char *uid)
{
- g_return_val_if_fail(galago_is_initted(), NULL);
- g_return_val_if_fail(uid != NULL && *uid != '\0', NULL);
+ static gulong next_session_id_index = 1;
+ char *session_id = NULL;
+ GalagoPerson *person;
- return _galago_person_new(uid, GALAGO_LOCAL, NULL);
+ g_return_val_if_fail(galago_is_initted(), NULL);
+
+ session_id = g_strdup_printf("session-id-%ld", next_session_id_index++);
+
+ person = _galago_person_new(uid, session_id, GALAGO_LOCAL, NULL);
+
+ if (session_id != NULL)
+ g_free(session_id);
+
+ return person;
}
void
@@ -374,9 +417,7 @@
if (galago_person_is_me(person))
return;
- g_free(person->priv->id);
-
- person->priv->id = g_strdup(GALAGO_ME_ID);
+ _galago_person_set_id(person, GALAGO_ME_ID);
}
gboolean
@@ -385,9 +426,35 @@
g_return_val_if_fail(person != NULL, FALSE);
g_return_val_if_fail(GALAGO_IS_PERSON(person), FALSE);
- return !strcmp(person->priv->id, GALAGO_ME_ID);
+ return person->priv->id != NULL &&
+ !strcmp(person->priv->id, GALAGO_ME_ID);
}
+void
+_galago_person_set_id(GalagoPerson *person, const char *id)
+{
+ g_return_if_fail(person != NULL);
+ g_return_if_fail(GALAGO_IS_PERSON(person));
+
+ if (person->priv->id != NULL)
+ g_free(person->priv->id);
+
+ person->priv->id = (id == NULL ? NULL : g_strdup(id));
+}
+
+void
+_galago_person_set_session_id(GalagoPerson *person, const char *session_id)
+{
+ g_return_if_fail(person != NULL);
+ g_return_if_fail(GALAGO_IS_PERSON(person));
+
+ if (person->priv->session_id != NULL)
+ g_free(person->priv->session_id);
+
+ person->priv->session_id =
+ (session_id == NULL ? NULL : g_strdup(session_id));
+}
+
const char *
galago_person_get_id(const GalagoPerson *person)
{
@@ -398,6 +465,15 @@
}
const char *
+galago_person_get_session_id(const GalagoPerson *person)
+{
+ g_return_val_if_fail(person != NULL, NULL);
+ g_return_val_if_fail(GALAGO_IS_PERSON(person), NULL);
+
+ return person->priv->session_id;
+}
+
+const char *
galago_person_get_display_name(const GalagoPerson *person)
{
static char buffer[BUFSIZ];
@@ -673,7 +749,6 @@
return account;
}
-
/**************************************************************************
* D-BUS Functions
**************************************************************************/
Modified: trunk/libgalago/libgalago/galago-person.h
===================================================================
--- trunk/libgalago/libgalago/galago-person.h 2006-02-09 08:35:51 UTC (rev 2574)
+++ trunk/libgalago/libgalago/galago-person.h 2006-02-12 11:23:31 UTC (rev 2575)
@@ -161,6 +161,15 @@
const char *galago_person_get_id(const GalagoPerson *person);
/**
+ * Returns a person's session ID.
+ *
+ * @param person The person.
+ *
+ * @return The person's session ID.
+ */
+const char *galago_person_get_session_id(const GalagoPerson *person);
+
+/**
* Returns the display name of a person, if any.
*
* The returned display name is from a static buffer. If you wish to store
Modified: trunk/libgalago/libgalago/galago-private.h
===================================================================
--- trunk/libgalago/libgalago/galago-private.h 2006-02-09 08:35:51 UTC (rev 2574)
+++ trunk/libgalago/libgalago/galago-private.h 2006-02-12 11:23:31 UTC (rev 2575)
@@ -116,6 +116,10 @@
void _galago_person_remove_account(GalagoPerson *person,
GalagoAccount *account);
+void _galago_person_set_id(GalagoPerson *person, const char *id);
+void _galago_person_set_session_id(GalagoPerson *person,
+ const char *session_id);
+
GalagoPresence *_galago_presence_new(GalagoAccount *account,
const char *obj_path);
Modified: trunk/libgalago/tests/check-libgalago.c
===================================================================
--- trunk/libgalago/tests/check-libgalago.c 2006-02-09 08:35:51 UTC (rev 2574)
+++ trunk/libgalago/tests/check-libgalago.c 2006-02-12 11:23:31 UTC (rev 2575)
@@ -30,6 +30,12 @@
return galago_create_person("dummy-person");
}
+static GalagoPerson *
+make_dummy_person_with_id(const char *id)
+{
+ return galago_create_person(id);
+}
+
static GalagoService *
make_dummy_service(void)
{
@@ -92,6 +98,11 @@
fail_unless(person != NULL, "Unable to create person");
fail_unless(galago_object_get_dbus_path(GALAGO_OBJECT(person)) != NULL,
"Object path not set on the new person");
+
+ person = make_dummy_person_with_id(NULL);
+ fail_unless(person != NULL, "Unable to create ID-less person");
+ fail_unless(galago_object_get_dbus_path(GALAGO_OBJECT(person)) != NULL,
+ "Object path not set on the new ID-less person");
}
END_TEST
Modified: trunk/libgalago/tests/presence-feed.c
===================================================================
--- trunk/libgalago/tests/presence-feed.c 2006-02-09 08:35:51 UTC (rev 2574)
+++ trunk/libgalago/tests/presence-feed.c 2006-02-12 11:23:31 UTC (rev 2575)
@@ -75,7 +75,7 @@
galago_presence_add_status(presence, status);
/* Add contacts to our Jabber account */
- person = galago_create_person("cae-1");
+ person = galago_create_person(NULL);
contact = galago_service_create_account(jabber_service, person,
"caedan at jabber.org");
presence = galago_account_create_presence(contact);
More information about the galago-commits
mailing list