removing rest of old Jabber code
authorsboyette <sboyette@9efc2488-bf62-4759-914b-345cdb29e865>
Fri, 8 Aug 2008 21:05:57 +0000 (21:05 +0000)
committersboyette <sboyette@9efc2488-bf62-4759-914b-345cdb29e865>
Fri, 8 Aug 2008 21:05:57 +0000 (21:05 +0000)
git-svn-id: svn://svn.open-ils.org/OpenSRF/branches/sboyette@1399 9efc2488-bf62-4759-914b-345cdb29e865

src/perl/lib/OpenSRF/Transport/Jabber/JInbound.pm [deleted file]
src/perl/lib/OpenSRF/Transport/Jabber/JMessageWrapper.pm [deleted file]
src/perl/lib/OpenSRF/Transport/Jabber/JPeerConnection.pm [deleted file]
src/perl/lib/OpenSRF/Transport/Jabber/JabberClient.pm [deleted file]

diff --git a/src/perl/lib/OpenSRF/Transport/Jabber/JInbound.pm b/src/perl/lib/OpenSRF/Transport/Jabber/JInbound.pm
deleted file mode 100644 (file)
index a381274..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-package OpenSRF::Transport::Jabber::JInbound;
-use strict;use warnings;
-use base qw/OpenSRF::Transport::Jabber::JabberClient/;
-use OpenSRF::EX;
-use OpenSRF::Utils::Config;
-use OpenSRF::Utils::Logger qw(:level);
-
-my $logger = "OpenSRF::Utils::Logger";
-
-=head1 Description
-
-This is the jabber connection where all incoming client requests will be accepted.
-This connection takes the data, passes it off to the system then returns to take
-more data.  Connection params are all taken from the config file and the values
-retreived are based on the $app name passed into new().
-
-This service should be loaded at system startup.
-
-=cut
-
-# XXX This will be overhauled to connect as a component instead of as
-# a user.  all in good time, though.
-
-{
-       my $unix_sock;
-       sub unix_sock { return $unix_sock; }
-       my $instance;
-
-       sub new {
-               my( $class, $app ) = @_;
-               $class = ref( $class ) || $class;
-               if( ! $instance ) {
-                       my $app_state = $app . "_inbound";
-                       my $config = OpenSRF::Utils::Config->current;
-
-                       if( ! $config ) {
-                               throw OpenSRF::EX::Jabber( "No suitable config found" );
-                       }
-
-                       my $host                        = $config->transport->server->primary;
-                       my $username    = $config->transport->users->$app;
-                       my $password    = $config->transport->auth->password;
-                       my $debug               = $config->transport->llevel->$app_state;
-                       my $log                 = $config->transport->log->$app_state;
-                       my $resource    = "system";
-
-
-                       my $self = __PACKAGE__->SUPER::new( 
-                                       username                => $username,
-                                       host                    => $host,
-                                       resource                => $resource,
-                                       password                => $password,
-                                       log_file                => $log,
-                                       debug                   => $debug,
-                                       );
-                                       
-                                       
-                       my $f = $config->dirs->sock_dir;
-                       $unix_sock = join( "/", $f, $config->unix_sock->$app );
-                       bless( $self, $class );
-                       $instance = $self;
-               }
-               $instance->SetCallBacks( message => \&handle_message );
-               return $instance;
-       }
-
-}
-       
-# ---
-# All incoming messages are passed untouched to the Unix Server for processing.  The
-# Unix socket is closed by the Unix Server as soon as it has received all of the
-# data.  This means we can go back to accepting more incoming connection.
-# -----
-sub handle_message { 
-       my $sid = shift;
-       my $message = shift;
-
-       my $packet = $message->GetXML();
-
-       $logger->transport( "JInbound $$ received $packet", INTERNAL );
-
-       # Send the packet to the unix socket for processing.
-       my $sock = unix_sock();
-       my $socket;
-       my $x = 0;
-       for( ;$x != 5; $x++ ) { #try 5 times
-               if( $socket = IO::Socket::UNIX->new( Peer => $sock  ) ) {
-                       last;
-               }
-       }
-       if( $x == 5 ) {
-               throw OpenSRF::EX::Socket( 
-                       "Unable to connect to UnixServer: socket-file: $sock \n :=> $! " );
-       }
-       print $socket $packet;
-       close( $socket );
-}
-
-
-1;
-
diff --git a/src/perl/lib/OpenSRF/Transport/Jabber/JMessageWrapper.pm b/src/perl/lib/OpenSRF/Transport/Jabber/JMessageWrapper.pm
deleted file mode 100644 (file)
index 15a6de5..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-package OpenSRF::Transport::Jabber::JMessageWrapper;
-use Jabber::NodeFactory;
-use Net::Jabber qw(Client);
-use Net::Jabber::Message;
-use base qw/ Net::Jabber::Message OpenSRF /;
-use OpenSRF::Utils::Logger qw(:level);
-use strict; use warnings;
-
-=head1 Description
-
-OpenSRF::Transport::Jabber::JMessageWrapper
-
-Provides a means to extract information about a Jabber
-message when all you have is the raw XML.  The API
-implemented here should be implemented by any Transport
-helper/MessageWrapper class.
-
-=cut
-
-sub DESTROY{}
-
-my $logger = "OpenSRF::Utils::Logger";
-my $_node_factory = Jabber::NodeFactory->new( fromstr => 1 );
-
-
-=head2 new( Net::Jabber::Message/$raw_xml )
-
-Pass in the raw Jabber message as XML and create a new 
-JMessageWrapper
-
-=cut
-
-sub new {
-       my( $class, $xml ) = @_;
-       $class = ref( $class ) || $class;
-
-       return undef unless( $xml );
-       
-       my $self;
-
-       if( ref( $xml ) ) {
-               $self = $xml;
-       } else {
-               $logger->transport( "MWrapper got: " . $xml, INTERNAL );
-               my $node = $_node_factory->newNodeFromStr( $xml );
-               $self = $class->SUPER::new();
-               $self->SetFrom( $node->attr('from') );
-               $self->SetThread( $node->getTag('thread')->data );
-               $self->SetBody( $node->getTag('body')->data );
-       }
-
-       bless( $self, $class );
-
-       $logger->transport( "MessageWrapper $self after blessing", INTERNAL );
-
-       return $self;
-
-}
-
-=head2 get_remote_id
-
-Returns the JID (user@host/resource) of the remote user
-
-=cut
-sub get_remote_id {
-       my( $self ) = @_;
-       return $self->GetFrom();
-}
-
-=head2 get_sess_id
-
-Returns the Jabber thread associated with this message
-
-=cut
-sub get_sess_id {
-       my( $self ) = @_;
-       return $self->GetThread();
-}
-
-=head2 get_body
-
-Returns the message body of the Jabber message
-
-=cut
-sub get_body {
-       my( $self ) = @_;
-       return $self->GetBody();
-}
-
-
-1;
diff --git a/src/perl/lib/OpenSRF/Transport/Jabber/JPeerConnection.pm b/src/perl/lib/OpenSRF/Transport/Jabber/JPeerConnection.pm
deleted file mode 100644 (file)
index 766de42..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-package OpenSRF::Transport::Jabber::JPeerConnection;
-use strict;
-use base qw/OpenSRF::Transport::Jabber::JabberClient/;
-use OpenSRF::Utils::Config;
-use OpenSRF::Utils::Logger qw(:level);
-
-=head1 Description
-
-Represents a single connection to a remote peer.  The 
-Jabber values are loaded from the config file.  
-
-Subclasses OpenSRF::Transport::JabberClient.
-
-=cut
-
-=head2 new()
-
-       new( $appname );
-
-       The $appname parameter tells this class how to find the correct
-       Jabber username, password, etc to connect to the server.
-
-=cut
-
-our $main_instance;
-our %apps_hash;
-
-sub retrieve { 
-       my( $class, $app ) = @_;
-       my @keys = keys %apps_hash;
-       OpenSRF::Utils::Logger->transport( 
-                       "Requesting peer for $app and we have @keys", INTERNAL );
-       return $apps_hash{$app};
-}
-
-
-
-sub new {
-       my( $class, $app ) = @_;
-       my $config = OpenSRF::Utils::Config->current;
-
-       if( ! $config ) {
-               throw OpenSRF::EX::Config( "No suitable config found" );
-       }
-
-       my $app_stat    = $app . "_peer";
-       my $host                        = $config->transport->server->primary;
-       my $username    = $config->transport->users->$app;
-       my $password    = $config->transport->auth->password;
-       my $debug               = $config->transport->llevel->$app_stat;
-       my $log                 = $config->transport->log->$app_stat;
-       my $resource    = $config->env->hostname . "_$$";
-
-       OpenSRF::EX::Config->throw( "JPeer could not load all necesarry values from config" )
-               unless ( $host and $username and $password and $resource );
-
-
-       my $self = __PACKAGE__->SUPER::new( 
-               username                => $username,
-               host                    => $host,
-               resource                => $resource,
-               password                => $password,
-               log_file                => $log,
-               debug                   => $debug,
-               );      
-                                       
-        bless( $self, $class );
-
-        $self->SetCallBacks( message => sub {
-                        my $msg = $_[1];
-                        OpenSRF::Utils::Logger->transport( 
-                                "JPeer passing \n$msg \n to Transport->handler for $app", INTERNAL );
-                        OpenSRF::Transport->handler( $app, $msg ); } );
-
-       $apps_hash{$app} = $self;
-       return $apps_hash{$app};
-}
-       
-1;
-
diff --git a/src/perl/lib/OpenSRF/Transport/Jabber/JabberClient.pm b/src/perl/lib/OpenSRF/Transport/Jabber/JabberClient.pm
deleted file mode 100644 (file)
index 50eb6ae..0000000
+++ /dev/null
@@ -1,277 +0,0 @@
-package OpenSRF::Transport::Jabber::JabberClient;
-use strict; use warnings;
-use OpenSRF::EX;
-use Net::Jabber qw( Client );
-use base qw( OpenSRF Net::Jabber::Client );
-use OpenSRF::Utils::Logger qw(:level);
-
-=head1 Description
-
-OpenSRF::Transport::Jabber::JabberClient
-
-Subclasses Net::Jabber::Client and, hence, provides the same
-functionality.  What it provides in addition is mainly some logging
-and exception throwing on the call to 'initialize()', which sets
-up the connection and authentication.
-
-=cut
-
-my $logger = "OpenSRF::Utils::Logger";
-
-sub DESTROY{};
-
-
-=head2 new()
-
-Creates a new JabberClient object.  The parameters should be self explanatory.
-If not, see Net::Jabber::Client for more.  
-
-debug and log_file are not required if you don't care to log the activity, 
-however all other parameters are.
-
-%params:
-
-       host
-       username
-       resource        
-       password
-       debug    
-       log_file
-
-=cut
-
-sub new {
-
-       my( $class, %params ) = @_;
-
-       $class = ref( $class ) || $class;
-
-       my $host                        = $params{'host'}                       || return undef;
-       my $username    = $params{'username'}   || return undef;
-       my $resource    = $params{'resource'}   || return undef;
-       my $password    = $params{'password'}   || return undef;
-       my $debug               = $params{'debug'};              
-       my $log_file    = $params{'log_file'};
-
-       my $self;
-
-       if( $debug and $log_file ) {
-               $self = Net::Jabber::Client->new( 
-                               debuglevel => $debug, debugfile => $log_file );
-       }
-       else { $self = Net::Jabber::Client->new(); }
-
-       bless( $self, $class );
-
-       $self->host( $host );
-       $self->username( $username );
-       $self->resource( $resource );
-       $self->password( $password );
-
-       $logger->transport( "Creating Jabber instance: $host, $username, $resource",
-                       $logger->INFO );
-
-       $self->SetCallBacks( send => 
-                       sub { $logger->transport( "JabberClient in 'send' callback: @_", INTERNAL ); } );
-
-
-       return $self;
-}
-
-# -------------------------------------------------
-
-=head2 gather()
-
-Gathers all Jabber messages sitting in the collection queue 
-and hands them each to their respective callbacks.  This call
-does not block (calls Process(0))
-
-=cut
-
-sub gather { my $self = shift; $self->Process( 0 ); }
-
-# -------------------------------------------------
-
-=head2 listen()
-
-Blocks and gathers incoming messages as they arrive.  Does not return
-unless an error occurs.
-
-Throws an OpenSRF::EX::JabberException if the call to Process ever fails.
-
-=cut
-sub listen {
-       my $self = shift;
-       while(1) {
-               my $o = $self->process( -1 );
-               if( ! defined( $o ) ) {
-                       throw OpenSRF::EX::Jabber( "Listen Loop failed at 'Process()'" );
-               }
-       }
-}
-
-# -------------------------------------------------
-
-sub password {
-       my( $self, $password ) = @_;
-       $self->{'oils:password'} = $password if $password;
-       return $self->{'oils:password'};
-}
-
-# -------------------------------------------------
-
-sub username {
-       my( $self, $username ) = @_;
-       $self->{'oils:username'} = $username if $username;
-       return $self->{'oils:username'};
-}
-       
-# -------------------------------------------------
-
-sub resource {
-       my( $self, $resource ) = @_;
-       $self->{'oils:resource'} = $resource if $resource;
-       return $self->{'oils:resource'};
-}
-
-# -------------------------------------------------
-
-sub host {
-       my( $self, $host ) = @_;
-       $self->{'oils:host'} = $host if $host;
-       return $self->{'oils:host'};
-}
-
-# -------------------------------------------------
-
-=head2 send()
-
-       Sends a Jabber message.
-       
-       %params:
-               to                      - The JID of the recipient
-               thread  - The Jabber thread
-               body            - The body of the message
-
-=cut
-
-sub send {
-       my( $self, %params ) = @_;
-
-       my $to = $params{'to'} || return undef;
-       my $body = $params{'body'} || return undef;
-       my $thread = $params{'thread'};
-
-       my $msg = Net::Jabber::Message->new();
-
-       $msg->SetTo( $to );
-       $msg->SetThread( $thread ) if $thread;
-       $msg->SetBody( $body );
-
-       $logger->transport( 
-                       "JabberClient Sending message to $to with thread $thread and body: \n$body", INTERNAL );
-
-       $self->Send( $msg );
-}
-
-
-=head2 inintialize()
-
-Connect to the server and log in.  
-
-Throws an OpenSRF::EX::JabberException if we cannot connect
-to the server or if the authentication fails.
-
-=cut
-
-# --- The logging lines have been commented out until we decide 
-# on which log files we're using.
-
-sub initialize {
-
-       my $self = shift;
-
-       my $host                        = $self->host; 
-       my $username    = $self->username;
-       my $resource    = $self->resource;
-       my $password    = $self->password;
-
-       my $jid = "$username\@$host\/$resource";
-
-       # --- 5 tries to connect to the jabber server
-       my $x = 0;
-       for( ; $x != 5; $x++ ) {
-               $logger->transport( "$jid: Attempting to connecto to server...$x", WARN );
-               if( $self->Connect( 'hostname' => $host ) ) {
-                       last; 
-               }
-               else { sleep 3; }
-       }
-
-       if( $x == 5 ) {
-               die "could not connect to server $!\n";
-               throw OpenSRF::EX::Jabber( " Could not connect to Jabber server" );
-       }
-
-       $logger->transport( "Logging into jabber as $jid " .
-                       "from " . ref( $self ), DEBUG );
-
-       # --- Log in
-       my @a = $self->AuthSend( 'username' => $username, 
-               'password' => $password, 'resource' => $resource );
-
-       if( $a[0] eq "ok" ) { 
-               $logger->transport( " * $jid: Jabber authenticated and connected", DEBUG );
-       }
-       else {
-               throw OpenSRF::EX::Jabber( " * $jid: Unable to authenticate: @a" );
-       }
-
-       return $self;
-}
-
-sub construct {
-       my( $class, $app ) = @_;
-       $logger->transport("Constructing new Jabber connection for $app", INTERNAL );
-       $class->peer_handle( 
-                       $class->new( $app )->initialize() );
-}
-
-sub process {
-
-       my( $self, $timeout ) = @_;
-       if( ! $timeout ) { $timeout = 0; }
-
-       unless( $self->Connected() ) {
-               OpenSRF::EX::Jabber->throw( 
-                 "This JabberClient instance is no longer connected to the server", ERROR );
-       }
-
-       my $val;
-
-       if( $timeout eq "-1" ) {
-               $val = $self->Process();
-       }
-       else { $val = $self->Process( $timeout ); }
-
-       if( $timeout eq "-1" ) { $timeout = " "; }
-       
-       if( ! defined( $val ) ) {
-               OpenSRF::EX::Jabber->throw( 
-                 "Call to Net::Jabber::Client->Process( $timeout ) failed", ERROR );
-       }
-       elsif( ! $val ) {
-               $logger->transport( 
-                       "Call to Net::Jabber::Client->Process( $timeout ) returned 0 bytes of data", DEBUG );
-       }
-       elsif( $val ) {
-               $logger->transport( 
-                       "Call to Net::Jabber::Client->Process( $timeout ) successfully returned data", INTERNAL );
-       }
-
-       return $val;
-
-}
-
-
-1;