[2778] in BarnOwl Developers
[PATCH 2/3] Merged probably correct changes from upstream (XML::Stream version 1.23).
daemon@ATHENA.MIT.EDU (Jason Gross)
Sun Nov 14 10:20:42 2010
From: Jason Gross <jgross@MIT.EDU>
To: barnowl-dev@mit.edu
Date: Sun, 14 Nov 2010 10:20:37 -0500
In-Reply-To: <1289748038-5882-1-git-send-email-jgross@mit.edu>
See ticket #152. (https://barnowl.mit.edu:444/ticket/152) This merges
significant changes from XML::Stream version 1.23. I'm pretty sure the
code does the same thing as our's, but I know neither perl nor the
surrounding code well enough to verify this. This commit message should
be changed before these changes are merged upstream, possibly justifying
why the new code from v. 1.23 is the same as our old code.
---
perl/modules/Jabber/lib/XML/Stream.pm | 34 +++++++++++++++++---
.../Jabber/lib/XML/Stream/IO/Select/Win32.pm | 29 +++++++++++++++++
perl/modules/Jabber/lib/XML/Stream/Node.pm | 2 +-
3 files changed, 59 insertions(+), 6 deletions(-)
create mode 100644 perl/modules/Jabber/lib/XML/Stream/IO/Select/Win32.pm
diff --git a/perl/modules/Jabber/lib/XML/Stream.pm b/perl/modules/Jabber/lib/XML/Stream.pm
index a0b99cd..e3723b0 100644
--- a/perl/modules/Jabber/lib/XML/Stream.pm
+++ b/perl/modules/Jabber/lib/XML/Stream.pm
@@ -1214,10 +1214,24 @@ sub OpenFile
}
);
- $self->{SIDS}->{newconnection}->{select} =
- new IO::Select($self->{SIDS}->{newconnection}->{sock});
+ # select is not implemented for filehandles on win32 (see perlport)
+ # so we fake it out using XML::Stream::IO::Select::Win32
+ if ( $^O =~ /mswin32/i ) {
+ $self->{SIDS}->{newconnection}->{select}
+ = new XML::Stream::IO::Select::Win32(
+ $self->{SIDS}->{newconnection}->{sock});
- $self->{SELECT} = new IO::Select($self->{SIDS}->{newconnection}->{sock});
+ $self->{SELECT}
+ = new XML::Stream::IO::Select::Win32(
+ $self->{SIDS}->{newconnection}->{sock});
+ }
+ else {
+ $self->{SIDS}->{newconnection}->{select}
+ = new IO::Select($self->{SIDS}->{newconnection}->{sock});
+
+ $self->{SELECT}
+ = new IO::Select($self->{SIDS}->{newconnection}->{sock});
+ }
$self->{SIDS}->{newconnection}->{status} = 0;
@@ -2114,16 +2128,26 @@ sub SASLClient
my $mechanisms = $self->GetStreamFeature($sid,"xmpp-sasl");
return unless defined($mechanisms);
+
+ # Here we assume that if 'to' is available, then a domain is being
+ # specified that does not match the hostname of the jabber server
+ # and that we should use that to form the bare JID for SASL auth.
+ my $domain .= $self->{SIDS}->{$sid}->{to}
+ ? $self->{SIDS}->{$sid}->{to}
+ : $self->{SIDS}->{$sid}->{hostname};
+
+ my $authname = $username . '@' . $domain;
my $sasl = new Authen::SASL(mechanism=>join(" ",@{$mechanisms}),
callback=>{
-# authname => $username."@".$self->{SIDS}->{$sid}->{hostname},
+ authname => $authname,
+
user => $username,
pass => $password
}
);
- $self->{SIDS}->{$sid}->{sasl}->{client} = $sasl->client_new('xmpp', $self->{SIDS}->{$sid}->{hostname});
+ $self->{SIDS}->{$sid}->{sasl}->{client} = $sasl->client_new('xmpp', $domain);
$self->{SIDS}->{$sid}->{sasl}->{username} = $username;
$self->{SIDS}->{$sid}->{sasl}->{password} = $password;
$self->{SIDS}->{$sid}->{sasl}->{authed} = 0;
diff --git a/perl/modules/Jabber/lib/XML/Stream/IO/Select/Win32.pm b/perl/modules/Jabber/lib/XML/Stream/IO/Select/Win32.pm
new file mode 100644
index 0000000..b2a9511
--- /dev/null
+++ b/perl/modules/Jabber/lib/XML/Stream/IO/Select/Win32.pm
@@ -0,0 +1,29 @@
+package XML::Stream::IO::Select::Win32;
+
+=head1 NAME
+
+XML::Stream::IO::Select::Win32 - Fake filehandle support for XML::Stream
+
+=head1 SYNOPSIS
+
+ You should have no reason to use this directly.
+
+=cut
+
+use strict;
+use warnings;
+
+use vars qw( $VERSION );
+
+$VERSION = "1.23";
+
+use base 'IO::Select';
+
+sub can_read {
+ my $vec = shift;
+ my $timeout = shift;
+
+ $vec->handles();
+}
+
+1;
diff --git a/perl/modules/Jabber/lib/XML/Stream/Node.pm b/perl/modules/Jabber/lib/XML/Stream/Node.pm
index 7c22105..6797deb 100644
--- a/perl/modules/Jabber/lib/XML/Stream/Node.pm
+++ b/perl/modules/Jabber/lib/XML/Stream/Node.pm
@@ -408,7 +408,7 @@ sub copy
{
if ($child->get_tag() eq "__xmlstream__:node:cdata")
{
- $new_node->add_cdata($self->get_cdata());
+ $new_node->add_cdata($child->children());
}
else
{
--
1.7.1