From 0125dceecac0d18e8c486b624fd2670095a92eb9 Mon Sep 17 00:00:00 2001 From: Ben Date: Thu, 15 Apr 2010 23:31:44 +0000 Subject: [PATCH] MSN prpl lacks a status type for the EXTENDED_AWAY primitive. --- perl/lib/Thrasher/Protocol/Purple.pm | 17 +++++++++++++++++ perl/lib/Thrasher/Protocol/Purple/MSN.pm | 12 ++++++++++++ thpresence.c | 4 ++++ 3 files changed, 33 insertions(+) diff --git a/perl/lib/Thrasher/Protocol/Purple.pm b/perl/lib/Thrasher/Protocol/Purple.pm index 8fa7a7c..4a942be 100644 --- a/perl/lib/Thrasher/Protocol/Purple.pm +++ b/perl/lib/Thrasher/Protocol/Purple.pm @@ -912,7 +912,16 @@ sub user_presence_update { logger("Unknown type/show of [$type/$show] (show is completely unrecognized)"); } + ($status, $purple_status) = $self->process_outgoing_purple_status( + $session, + $type, + $show, + $status, + $purple_status, + ); + if (defined($purple_status)) { + debug("thrasher_action_presence($session->{jid}, $purple_status, $status)"); THPPW::thrasher_action_presence( Encode::encode("UTF-8", $session->{jid}), $purple_status, # integer does not need encoding @@ -923,6 +932,14 @@ sub user_presence_update { #debug("User presence update: type: $type, show: $show, purple: $purple_status, status: $status"); } +# A chance for the prpl-specific subclass to override the decision +# made by user_presence_update(). +sub process_outgoing_purple_status { + my ($self, $session, $type, $show, $message, $purple_status) = @_; + + return ($message, $purple_status); +} + # Don't do anything with this right now. sub user_targeted_presence_update { return; diff --git a/perl/lib/Thrasher/Protocol/Purple/MSN.pm b/perl/lib/Thrasher/Protocol/Purple/MSN.pm index c6184d6..74d4052 100644 --- a/perl/lib/Thrasher/Protocol/Purple/MSN.pm +++ b/perl/lib/Thrasher/Protocol/Purple/MSN.pm @@ -12,11 +12,23 @@ Live Messenger, or whatever they're calling it this week. use base "Thrasher::Protocol::Purple"; use Thrasher::Log qw(log debug); +use Thrasher::Protocol::Purple::Vars qw(%purple_presence); sub prpl { return "prpl-msn"; } +sub process_outgoing_purple_status { + my ($self, $session, $type, $show, $message, $purple_status) = @_; + + if ($purple_status == $purple_presence{'xaway'}) { + # MSN prpl lacks a status type for the EXTENDED_AWAY primitive. + $purple_status = $purple_presence{'away'}; + } + + return ($message, $purple_status); +} + sub fake_up_a_legacy_name { my ($self, $user_jid, $jid, $legacy_guess) = @_; diff --git a/thpresence.c b/thpresence.c index be5921e..f1e4cd7 100644 --- a/thpresence.c +++ b/thpresence.c @@ -36,6 +36,7 @@ void thrasher_set_presence (PurpleAccount *pa, PurpleStatusPrimitive primitive, if (type) { const char *status_id = purple_status_type_get_id(type); + purple_debug_info("thrasher", "found status with ID: %s\n", status_id); PurplePresence *presence = purple_presence_new_for_account(pa); PurpleStatus *status = purple_status_new(type, presence); if (message && purple_status_get_attr_value(status, "message")) { @@ -45,5 +46,8 @@ void thrasher_set_presence (PurpleAccount *pa, PurpleStatusPrimitive primitive, else purple_account_set_status(pa, status_id, TRUE, NULL); } + else { + purple_debug_info("thrasher", "No status type found\n"); + } } -- 2.11.4.GIT