use Carp;
use IO::Socket;
use Net::Cmd;
+#use Text::CSV_XS;
-$VERSION = '0.1'; # $Id: APP.pm,v 1.2 2001-04-10 13:46:43 ivan Exp $
-$APP_VERSION = '2.1';
+$VERSION = '0.2'; # $Id: APP.pm,v 1.3 2001-11-09 21:58:40 ivan Exp $
+$APP_VERSION = '3.3';
@ISA = qw(Net::Cmd IO::Socket::INET);
This is the constructor for a new Net::APP object. C<HOST> and C<PORT>
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 -P none -c -d 8888 -r your.cp.address.and:port
This method will connect to the APP server and execute the I<ver> method.
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<undef> 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<message>, I<code>, I<ok>, and I<status> methods.
+Unless noted below, all commands return a reference to a list containing the
+lines of the reponse, or I<undef> 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<message>, I<code>, I<ok>, and I<status> 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
=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
Doubles double quotes.
-This is untested for strings containing consecutive double quotes.
-
=cut
sub _quote {
=head1 AUTHOR
-Ivan Kohler <ivan-netapp_pod@sisd.com>.
+Ivan Kohler <ivan-netapp_pod@420.am>.
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.2 2001-04-10 13:46:43 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
=head1 SEE ALSO
Critical Path <http://www.cp.net/>,
-Safe Passage Secure Tunnel <http://www.c2.net/products/spst>,
-L<Net::SSLeay>, L<Net::Cmd>, perl(1).
-
-=head1 HISTORY
-
-$Log: APP.pm,v $
-Revision 1.2 2001-04-10 13:46:43 ivan
-update email addresses and CVS information
-
-Revision 1.1.1.1 1999/06/21 10:11:11 ivan
-new project
-
+APP documentation <http://support.cp.net/products/email_messaging/documentation/index.jsp>,
+Safe Passage Secure Tunnel <http://www.int.c2.net/external/?link=spst/index.php3>,
+Stunnel <http://www.stunnel.org>,
+L<IO::Socket>, L<Net::Cmd>, perl(1).
=cut