X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=APP.pm;h=e22277e64c04c3bd8a41f45ea3c033642ebdd77e;hb=HEAD;hp=aaa379789654c31ab4009de1fdb668c8c01d5c21;hpb=ff7f79072d14341d7427e12351d56d027d92f589;p=Net-APP.git diff --git a/APP.pm b/APP.pm index aaa3797..e22277e 100644 --- a/APP.pm +++ b/APP.pm @@ -5,9 +5,10 @@ use vars qw($VERSION $APP_VERSION @ISA $AUTOLOAD); use Carp; use IO::Socket; use Net::Cmd; +#use Text::CSV_XS; -$VERSION = '0.1'; # $Id: APP.pm,v 1.1 1999-06-21 10:11:11 ivan Exp $ -$APP_VERSION = '2.1'; +$VERSION = '0.2'; # $Id: APP.pm,v 1.4 2003-06-03 12:28:23 ivan Exp $ +$APP_VERSION = '3.3'; @ISA = qw(Net::Cmd IO::Socket::INET); @@ -65,7 +66,10 @@ been done, all APP commands are accessed via method calls on the object. This is the constructor for a new Net::APP object. C and C specify the host and port to connect to in cleartext. Typically this -connection is proxied via Safe Passage Secure Tunnel to Critical Path. +connection is proxied via Safe Passage Secure Tunnel or Stunnel +http://www.stunnel.org/ using a command such as: + + stunnel -c -P none -c -d 8888 -r your.cp.address.and:port This method will connect to the APP server and execute the I method. @@ -145,14 +149,64 @@ See the Account Provisioning Protocol Developer's Guide for details. Commands need not be in upper case, and options are passed in a hash-like fashion, as a list of key-value pairs. -All options return a reference to a list containing the lines of the reponse, -or I upon failure. The first line is parsed for the status code and -message. You can check the status code and message using the normal Net::Cmd -I, I, I, and I methods. +Unless noted below, all commands return a reference to a list containing the +lines of the reponse, or I upon failure. The first line is parsed for +the status code and message. You can check the status code and message using +the normal Net::Cmd I, I, I, and I methods. -Only the get_num_domain_mailboxes, get_mailbox_availability and +Some methods return additional response information, such as +get_num_domain_mailboxes, get_domain_mailboxes, get_mailbox_availability and get_mailbox_status methods currently return any additional response -information. No attempt is (yet) made to parse this data. +information. Unless specifically noted below, no attempt is (yet) made to +parse this data. + +=item get_domain_mailboxes + +Returns an arrayref of arrayrefs, each with three elements: username, mailbox +type, and workgroup. The protocol calls them: MAILBOX, TYPE, and WORKGROUP. + +=cut + +sub get_domain_mailboxes { + my $self = shift; +# my $command = $AUTOLOAD; +# $command =~ s/.*://; + my $command = 'get_domain_mailboxes'; +# my $csv = new Text::CSV_XS; + $self->_app_command( $command, @_ ); + [ map { chomp; [ map { s/(^"|"$)//g; $_ } + split(/(?<=[^"]")\s+(?="[^"])/, $_) + ] + } + grep { $_ !~ /^,$/ } + splice( @{$self->_app_response}, 2 ) + ]; +} + +=item get_mailbox_forward_only + +Returns the forward email address. + +=cut + +sub get_mailbox_forward_only { + my $self = shift; +# my $command = $AUTOLOAD; +# $command =~ s/.*://; + my $command = 'get_mailbox_forward_only'; + $self->_app_command( $command, @_ ); + + my $lines = $self->_app_response; + + unless ( $lines->[1] =~ /^FORWARD_EMAIL="([^"]+)"$/ ) { + warn $lines->[1]; + $self->set_status ( -1, $lines->[0] ); + return undef; + } + + $1; + +} =item message @@ -167,7 +221,8 @@ of the response is returned by the I method. =item ok -Returns true if the last code was an acceptable response. +Returns true if the last response code was not an error. Since the only +non-error code is 0, this is just the negation of the code method. =cut @@ -260,8 +315,6 @@ These subroutines are not intended to be called by the user. Doubles double quotes. -This is untested for strings containing consecutive double quotes. - =cut sub _quote { @@ -274,34 +327,29 @@ sub _quote { =head1 AUTHOR -Ivan Kohler . +Ivan Kohler . This module is not sponsored or endorsed by Critical Path. =head1 COPYRIGHT -Copyright (c) 1999 Ivan Kohler. -Copyright (c) 1999 Silicon Interactive Software Design. +Copyright (c) 2001 Ivan Kohler. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. -=head1 VERSION +=head1 PROTOCOL VERSION -$Id: APP.pm,v 1.1 1999-06-21 10:11:11 ivan Exp $ - -This module currently implements APP v2.1, as documented in the Account -Provisioning Protocol Developers Guide v2.1. +This module currently implements APP v3.3, as documented in the Account +Provisioning Protocol Developers Guide v3.3. =head1 BUGS The Account Provisioning Protocol Developer's Guide is not publicly available. -It appears that Safe Passage Secure Tunnel establishes a standard SSL -connection. It should be possible to use Net::SSLeay and connect to the APP -server directly. - -Sending values with consecutive double quote characters is untested. +It appears that Safe Passage Secure Tunnel and Stunnel establish standard SSL +connections. It should be possible to use Net::SSLeay and connect to the APP +server directly. Initial prototyping with IO::Socket::SSL was not promising. :( The get_num_domain_mailboxes, get_mailbox_availability and get_mailbox_status methods currently return response information. No attempt is (yet) made to @@ -310,15 +358,10 @@ parse this data. =head1 SEE ALSO Critical Path , -Safe Passage Secure Tunnel , -L, L, perl(1). - -=head1 HISTORY - -$Log: APP.pm,v $ -Revision 1.1 1999-06-21 10:11:11 ivan -Initial revision - +APP documentation , +Safe Passage Secure Tunnel , +Stunnel , +L, L, perl(1). =cut