From d22226076aa2552c9dbedce343ca71fbf25c639e Mon Sep 17 00:00:00 2001 From: Ben Date: Thu, 4 Mar 2010 19:31:23 +0000 Subject: [PATCH] Purple::_connection_error should also call the Component's connection_cb. --- perl/lib/Thrasher/Component.pm | 32 ++++++++++++++++++++------------ perl/lib/Thrasher/Protocol/Purple.pm | 9 +++++++++ 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/perl/lib/Thrasher/Component.pm b/perl/lib/Thrasher/Component.pm index 4194419..ef11a94 100644 --- a/perl/lib/Thrasher/Component.pm +++ b/perl/lib/Thrasher/Component.pm @@ -945,22 +945,30 @@ sub login { } my $login_handler = sub { + # Result from session can be: + # * ref (implies its the Session object) + # * error string + # * undef if there was an error and the Protocol is handling it. my $session_or_error = shift; # Failed login - Section 4.4.2 if (!ref(my $error = $session_or_error)) { - my $packet = [[$NS_COMPONENT, 'presence'], - {to => $full_jid, - from => $self->{component_name}, - type => 'error'}, - [error_tag($error)]]; - $self->xml_out($packet); - - if ($error eq 'not_acceptable') { - # Credential issue - $self->{authentication_errors}->{$jid} = - {registration_info => $registration_info, - error_xml => $packet}; + # Protocol can pass an error here to have XML generated or + # roll its own. + if ($error) { + my $packet = [[$NS_COMPONENT, 'presence'], + {to => $full_jid, + from => $self->{component_name}, + type => 'error'}, + [error_tag($error)]]; + $self->xml_out($packet); + if ($error eq 'not_acceptable') { + # Credential issue + $self->{authentication_errors}->{$jid} = { + registration_info => $registration_info, + error_xml => $packet, + }; + } } return; } diff --git a/perl/lib/Thrasher/Protocol/Purple.pm b/perl/lib/Thrasher/Protocol/Purple.pm index f13fa74..038285b 100644 --- a/perl/lib/Thrasher/Protocol/Purple.pm +++ b/perl/lib/Thrasher/Protocol/Purple.pm @@ -460,6 +460,15 @@ sub _connection_error { _timeout_add(15000, $callback, undef, "Reconnect $session->{full_jid}"); } + + my $continuation = delete($session->{'connection_cb'}); + if ($continuation) { + $continuation->(undef); + } + else { + log("_connection_error($jid): No connection_cb?!!"); + } + # If you want C-end handling, we need to throw some returns above return 1; } -- 2.11.4.GIT