diff options
author | Nicolas Dufresne <nicolas.dufresne@collabora.co.uk> | 2011-03-22 19:21:48 -0400 |
---|---|---|
committer | Nicolas Dufresne <nicolas.dufresne@collabora.co.uk> | 2011-03-25 14:03:04 -0400 |
commit | 29ee71548ed00054947ae76022f0fabc6602cdd5 (patch) | |
tree | 5c4ddd503c0b61163a75fde6668de7da5f8b286e /telepathy-logger/entity.c | |
parent | 8fb76e8733f2719c3f64e9baa0801ee9ef257798 (diff) | |
download | telepathy-logger-29ee71548ed00054947ae76022f0fabc6602cdd5.tar.gz |
Add private helper to serialize TplEntityType into a string
Diffstat (limited to 'telepathy-logger/entity.c')
-rw-r--r-- | telepathy-logger/entity.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/telepathy-logger/entity.c b/telepathy-logger/entity.c index f816e8d..504e0c5 100644 --- a/telepathy-logger/entity.c +++ b/telepathy-logger/entity.c @@ -62,6 +62,14 @@ enum PROP_AVATAR_TOKEN }; +static const gchar * entity_types[] = { + "unknown", + "contact", + "room", + "self" +}; + + static void tpl_entity_finalize (GObject *obj) { @@ -379,3 +387,24 @@ _tpl_entity_compare (TplEntity *a, else return 1; } + + +TplEntityType +_tpl_entity_type_from_str (const gchar *type_str) +{ + guint i; + for (i = 0; i < G_N_ELEMENTS (entity_types); ++i) + if (!tp_strdiff (type_str, entity_types[i])) + return (TplEntityType) i; + + /* default case */ + return TPL_ENTITY_UNKNOWN; +} + + +const gchar * +_tpl_entity_type_to_str (TplEntityType type) +{ + g_return_val_if_fail (G_N_ELEMENTS (entity_types) >= type, "unknown"); + return entity_types[type]; +} |