From 66a485d2527787bddf4363f75e4e976985987450 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 19 Mar 2010 17:26:37 +0000 Subject: [PATCH] Map XMPP dnd to PURPLE_STATUS_UNAVAILABLE. --- perl/lib/Thrasher/Protocol/Purple.pm | 3 +++ thpresence.c | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/perl/lib/Thrasher/Protocol/Purple.pm b/perl/lib/Thrasher/Protocol/Purple.pm index 91133e2..365c10d 100644 --- a/perl/lib/Thrasher/Protocol/Purple.pm +++ b/perl/lib/Thrasher/Protocol/Purple.pm @@ -899,6 +899,9 @@ sub user_presence_update { elsif ($show eq 'xa' || $show eq 'xaway') { $purple_status = $purple_presence{'xaway'}; } + elsif ($show eq 'dnd') { + $purple_status = $purple_presence{'unavailable'}; + } else { logger("Unknown type/show of [$type/$show] (show is completely unrecognized)"); } diff --git a/thpresence.c b/thpresence.c index b44e350..5713073 100644 --- a/thpresence.c +++ b/thpresence.c @@ -30,7 +30,15 @@ void thrasher_set_presence (PurpleAccount *pa, PurpleStatusPrimitive primitive, PurpleStatusType *type; char *status_id = NULL; - /* Get the status_id so we can create a new type */ + /* Get the status_id so we can create a new type. + * + * Differs from purple_primitive_get_id_from_type() because + * purple_account_set_status() will fail if we send an invalid + * status ID for the account and we want to keep consistent with + * what the Perl-side supports. E.g. PURPLE_STATUS_UNAVAILABLE: + * prpls have it as "dnd" while _get_id_from_type() gives + * "unavailable". + */ switch (primitive) { case PURPLE_STATUS_UNSET: @@ -44,7 +52,7 @@ void thrasher_set_presence (PurpleAccount *pa, PurpleStatusPrimitive primitive, status_id = g_strdup("available"); break; case PURPLE_STATUS_UNAVAILABLE: - status_id = g_strdup("unavailable"); + status_id = g_strdup("dnd"); break; case PURPLE_STATUS_INVISIBLE: /* Currently unsupported */ -- 2.11.4.GIT