summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathon Jongsma <jonathon.jongsma@collabora.co.uk>2009-10-20 23:15:09 -0500
committerJonathon Jongsma <jonathon.jongsma@collabora.co.uk>2009-10-20 23:17:14 -0500
commit51ef7524e90caf044df39421d1f8755d6d330170 (patch)
tree8e5c53424a7424e7ac7d8b320e031be36bf6c80a
parent04bb398c622c91700ce62cd288c11346318fa0db (diff)
Treat contacts whose message is "Away" as if they had no message
This allows us to show a localized away message for contacts who didn't set a message. The only reason this dummy 'Away' string exists in teh first place is because IRC requires you to set an away message when you go away.
-rw-r--r--src/idle-contact-manager.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/idle-contact-manager.c b/src/idle-contact-manager.c
index be6d5f1..a421f65 100644
--- a/src/idle-contact-manager.c
+++ b/src/idle-contact-manager.c
@@ -31,6 +31,8 @@
#define CACHE_MAX_ELEMENTS 500
#define CACHE_NUM_EJECT 50 /* number of old elements to eject when we reach the max */
+#define DEFAULT_AWAY_MESSAGE "Away"
+
G_DEFINE_TYPE(IdleContactManager, idle_contact_manager, G_TYPE_OBJECT);
/* properties */
@@ -369,7 +371,7 @@ gboolean idle_contact_manager_set_own_status(IdleContactManager *self,
/* But, the IRC protocol requires some status for the
* away command or otherwise it would be interpreted as
* 'not away' so we tack on a default message here */
- away_msg = "Away";
+ away_msg = DEFAULT_AWAY_MESSAGE;
}
g_snprintf(cmd, IRC_MSG_MAXLEN + 1, "AWAY :%s", away_msg);
idle_connection_send(priv->conn, cmd);
@@ -461,7 +463,11 @@ update_contact_presence(IdleContactManager* mgr, TpHandle contact, IdlePresenceS
IdleContactManagerPrivate *priv = IDLE_CONTACT_MANAGER_GET_PRIVATE(mgr);
GHashTable *params = NULL;
- if (message != NULL) {
+ /* If the away message we receive is the generic default message, just
+ * ignore it so that the user can still get a localized away message instead
+ * of the literal placeholder message */
+ if (message != NULL &&
+ g_ascii_strcasecmp (message, DEFAULT_AWAY_MESSAGE) != 0) {
params = tp_asv_new ("message", G_TYPE_STRING, message, NULL);
}
@@ -478,7 +484,8 @@ update_contact_presence(IdleContactManager* mgr, TpHandle contact, IdlePresenceS
IDLE_DEBUG ("params: %p", params);
if (cached_update && (cached_update->presence->index == presence)
- && (cached_update->presence->optional_arguments != NULL) && (params == NULL)) {
+ && (cached_update->presence->optional_arguments != NULL) && (params == NULL)
+ && message != NULL) {
/* simply update the cached update's time */
IDLE_DEBUG ("Updating current time on the cached update");
g_get_current_time(&cached_update->update_time);