diff options
author | Xavier Claessens <xclaesse@src.gnome.org> | 2007-05-02 20:38:49 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2007-05-02 20:38:49 +0800 |
commit | 59f3e5480f8b20dcea7d7b19682a5c2f67260cdd (patch) | |
tree | f441f3eea5f7540923d2631ec27a4c3e2936decf /libempathy | |
parent | 6e1d5d1bf7e4c1bbac9d1d76fe967acf0dc423d1 (diff) | |
download | gsoc2013-empathy-59f3e5480f8b20dcea7d7b19682a5c2f67260cdd.tar gsoc2013-empathy-59f3e5480f8b20dcea7d7b19682a5c2f67260cdd.tar.gz gsoc2013-empathy-59f3e5480f8b20dcea7d7b19682a5c2f67260cdd.tar.bz2 gsoc2013-empathy-59f3e5480f8b20dcea7d7b19682a5c2f67260cdd.tar.lz gsoc2013-empathy-59f3e5480f8b20dcea7d7b19682a5c2f67260cdd.tar.xz gsoc2013-empathy-59f3e5480f8b20dcea7d7b19682a5c2f67260cdd.tar.zst gsoc2013-empathy-59f3e5480f8b20dcea7d7b19682a5c2f67260cdd.zip |
[darcs-to-svn @ Fix setting presence]
svn path=/trunk/; revision=23
Diffstat (limited to 'libempathy')
-rw-r--r-- | libempathy/empathy-contact-list.c | 44 | ||||
-rw-r--r-- | libempathy/gossip-contact.c | 2 | ||||
-rw-r--r-- | libempathy/gossip-presence.c | 93 | ||||
-rw-r--r-- | libempathy/gossip-presence.h | 33 |
4 files changed, 82 insertions, 90 deletions
diff --git a/libempathy/empathy-contact-list.c b/libempathy/empathy-contact-list.c index 1a8640026..9ed83df70 100644 --- a/libempathy/empathy-contact-list.c +++ b/libempathy/empathy-contact-list.c @@ -192,7 +192,6 @@ static void contact_list_parse_presence_foreach (guint static void contact_list_presences_table_foreach (const gchar *state_str, GHashTable *presences_table, GossipPresence **presence); -static GossipPresenceState contact_list_presence_state_from_str (const gchar *str); enum { CONTACT_ADDED, @@ -1728,9 +1727,11 @@ contact_list_parse_presence_foreach (guint handle, (GHFunc) contact_list_presences_table_foreach, &presence); - gossip_debug (DEBUG_DOMAIN, "Presence changed for %s (%d)", + gossip_debug (DEBUG_DOMAIN, "Presence changed for %s (%d) to %s (%d)", gossip_contact_get_name (contact), - handle); + handle, + presence ? gossip_presence_get_status (presence) : "unset", + presence ? gossip_presence_get_state (presence) : MC_PRESENCE_UNSET); contact_list_block_contact (list, contact); gossip_contact_set_presence (contact, presence); @@ -1742,19 +1743,19 @@ contact_list_presences_table_foreach (const gchar *state_str, GHashTable *presences_table, GossipPresence **presence) { - GossipPresenceState state; - const GValue *message; + McPresence state; + const GValue *message; + + state = gossip_presence_state_from_str (state_str); + if ((state == MC_PRESENCE_UNSET) || (state == MC_PRESENCE_OFFLINE)) { + return; + } if (*presence) { g_object_unref (*presence); *presence = NULL; } - state = contact_list_presence_state_from_str (state_str); - if (state == GOSSIP_PRESENCE_STATE_UNAVAILABLE) { - return; - } - *presence = gossip_presence_new (); gossip_presence_set_state (*presence, state); @@ -1765,26 +1766,3 @@ contact_list_presences_table_foreach (const gchar *state_str, } } -static GossipPresenceState -contact_list_presence_state_from_str (const gchar *str) -{ - if (strcmp (str, "available") == 0) { - return GOSSIP_PRESENCE_STATE_AVAILABLE; - } else if ((strcmp (str, "dnd") == 0) || (strcmp (str, "busy") == 0)) { - return GOSSIP_PRESENCE_STATE_BUSY; - } else if ((strcmp (str, "away") == 0) || (strcmp (str, "brb") == 0)) { - return GOSSIP_PRESENCE_STATE_AWAY; - } else if (strcmp (str, "xa") == 0) { - return GOSSIP_PRESENCE_STATE_EXT_AWAY; - } else if (strcmp (str, "hidden") == 0) { - return GOSSIP_PRESENCE_STATE_HIDDEN; - } else if (strcmp (str, "offline") == 0) { - return GOSSIP_PRESENCE_STATE_UNAVAILABLE; - } else if (strcmp (str, "chat") == 0) { - /* We don't support chat, so treat it like available. */ - return GOSSIP_PRESENCE_STATE_AVAILABLE; - } - - return GOSSIP_PRESENCE_STATE_AVAILABLE; -} - diff --git a/libempathy/gossip-contact.c b/libempathy/gossip-contact.c index fc0569021..68be90cd9 100644 --- a/libempathy/gossip-contact.c +++ b/libempathy/gossip-contact.c @@ -642,7 +642,7 @@ gossip_contact_get_status (GossipContact *contact) status = gossip_presence_get_status (priv->presence); if (!status) { - GossipPresenceState state; + McPresence state; state = gossip_presence_get_state (priv->presence); status = gossip_presence_state_get_default_status (state); diff --git a/libempathy/gossip-presence.c b/libempathy/gossip-presence.c index 2857b7612..1b04abc8f 100644 --- a/libempathy/gossip-presence.c +++ b/libempathy/gossip-presence.c @@ -34,20 +34,20 @@ typedef struct _GossipPresencePriv GossipPresencePriv; struct _GossipPresencePriv { - GossipPresenceState state; - gchar *status; - GossipTime timestamp; + McPresence state; + gchar *status; + GossipTime timestamp; }; -static void presence_finalize (GObject *object); -static void presence_get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *pspec); -static void presence_set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec); +static void presence_finalize (GObject *object); +static void presence_get_property (GObject *object, + guint param_id, + GValue *value, + GParamSpec *pspec); +static void presence_set_property (GObject *object, + guint param_id, + const GValue *value, + GParamSpec *pspec); enum { PROP_0, @@ -73,9 +73,9 @@ gossip_presence_class_init (GossipPresenceClass *class) g_param_spec_int ("state", "Presence State", "The current state of the presence", - GOSSIP_PRESENCE_STATE_AVAILABLE, - GOSSIP_PRESENCE_STATE_EXT_AWAY, - GOSSIP_PRESENCE_STATE_AVAILABLE, + MC_PRESENCE_UNSET, + LAST_MC_PRESENCE, + MC_PRESENCE_AVAILABLE, G_PARAM_READWRITE)); g_object_class_install_property (object_class, PROP_STATUS, @@ -95,7 +95,7 @@ gossip_presence_init (GossipPresence *presence) priv = GET_PRIV (presence); - priv->state = GOSSIP_PRESENCE_STATE_AVAILABLE; + priv->state = MC_PRESENCE_AVAILABLE; priv->status = NULL; priv->timestamp = gossip_time_get_current (); } @@ -166,8 +166,8 @@ gossip_presence_new (void) } GossipPresence * -gossip_presence_new_full (GossipPresenceState state, - const gchar *status) +gossip_presence_new_full (McPresence state, + const gchar *status) { return g_object_new (GOSSIP_TYPE_PRESENCE, "state", state, @@ -188,13 +188,13 @@ gossip_presence_get_status (GossipPresence *presence) return priv->status; } -GossipPresenceState +McPresence gossip_presence_get_state (GossipPresence *presence) { GossipPresencePriv *priv; g_return_val_if_fail (GOSSIP_IS_PRESENCE (presence), - GOSSIP_PRESENCE_STATE_AVAILABLE); + MC_PRESENCE_AVAILABLE); priv = GET_PRIV (presence); @@ -202,8 +202,8 @@ gossip_presence_get_state (GossipPresence *presence) } void -gossip_presence_set_state (GossipPresence *presence, - GossipPresenceState state) +gossip_presence_set_state (GossipPresence *presence, + McPresence state) { GossipPresencePriv *priv; @@ -267,26 +267,47 @@ gossip_presence_sort_func (gconstpointer a, } const gchar * -gossip_presence_state_get_default_status (GossipPresenceState state) +gossip_presence_state_get_default_status (McPresence state) { switch (state) { - case GOSSIP_PRESENCE_STATE_AVAILABLE: + case MC_PRESENCE_AVAILABLE: return _("Available"); - break; - - case GOSSIP_PRESENCE_STATE_BUSY: + case MC_PRESENCE_DO_NOT_DISTURB: return _("Busy"); - break; - - case GOSSIP_PRESENCE_STATE_AWAY: - case GOSSIP_PRESENCE_STATE_EXT_AWAY: + case MC_PRESENCE_AWAY: + case MC_PRESENCE_EXTENDED_AWAY: return _("Away"); - break; - - case GOSSIP_PRESENCE_STATE_HIDDEN: - case GOSSIP_PRESENCE_STATE_UNAVAILABLE: + case MC_PRESENCE_HIDDEN: return _("Unavailable"); + case MC_PRESENCE_OFFLINE: + return _("Offline"); + default: + return NULL; } - return _("Available"); + return NULL; } + +McPresence +gossip_presence_state_from_str (const gchar *str) +{ + if (strcmp (str, "available") == 0) { + return MC_PRESENCE_AVAILABLE; + } else if ((strcmp (str, "dnd") == 0) || (strcmp (str, "busy") == 0)) { + return MC_PRESENCE_DO_NOT_DISTURB; + } else if ((strcmp (str, "away") == 0) || (strcmp (str, "brb") == 0)) { + return MC_PRESENCE_AWAY; + } else if ((strcmp (str, "xa") == 0) || (strcmp (str, "ext_away") == 0)) { + return MC_PRESENCE_EXTENDED_AWAY; + } else if (strcmp (str, "hidden") == 0) { + return MC_PRESENCE_HIDDEN; + } else if (strcmp (str, "offline") == 0) { + return MC_PRESENCE_OFFLINE; + } else if (strcmp (str, "chat") == 0) { + /* We don't support chat, so treat it like available. */ + return MC_PRESENCE_AVAILABLE; + } + + return MC_PRESENCE_AVAILABLE; +} + diff --git a/libempathy/gossip-presence.h b/libempathy/gossip-presence.h index 12648e6f7..4aa2aa668 100644 --- a/libempathy/gossip-presence.h +++ b/libempathy/gossip-presence.h @@ -22,6 +22,7 @@ #define __GOSSIP_PRESENCE_H__ #include <glib-object.h> +#include <libmissioncontrol/mission-control.h> G_BEGIN_DECLS @@ -43,29 +44,21 @@ struct _GossipPresenceClass { GObjectClass parent_class; }; -typedef enum { - GOSSIP_PRESENCE_STATE_AVAILABLE, - GOSSIP_PRESENCE_STATE_BUSY, - GOSSIP_PRESENCE_STATE_AWAY, - GOSSIP_PRESENCE_STATE_EXT_AWAY, - GOSSIP_PRESENCE_STATE_HIDDEN, /* When you appear offline to others */ - GOSSIP_PRESENCE_STATE_UNAVAILABLE, -} GossipPresenceState; - GType gossip_presence_get_type (void) G_GNUC_CONST; GossipPresence * gossip_presence_new (void); -GossipPresence * gossip_presence_new_full (GossipPresenceState state, - const gchar *status); -GossipPresenceState gossip_presence_get_state (GossipPresence *presence); -const gchar * gossip_presence_get_status (GossipPresence *presence); -void gossip_presence_set_state (GossipPresence *presence, - GossipPresenceState state); -void gossip_presence_set_status (GossipPresence *presence, - const gchar *status); -gint gossip_presence_sort_func (gconstpointer a, - gconstpointer b); -const gchar * gossip_presence_state_get_default_status (GossipPresenceState state); +GossipPresence * gossip_presence_new_full (McPresence state, + const gchar *status); +McPresence gossip_presence_get_state (GossipPresence *presence); +const gchar * gossip_presence_get_status (GossipPresence *presence); +void gossip_presence_set_state (GossipPresence *presence, + McPresence state); +void gossip_presence_set_status (GossipPresence *presence, + const gchar *status); +gint gossip_presence_sort_func (gconstpointer a, + gconstpointer b); +const gchar * gossip_presence_state_get_default_status (McPresence state); +McPresence gossip_presence_state_from_str (const gchar *str); G_END_DECLS |