Telephony-Asterisk-AMI-0.006/0000755000175000017500000000000012637604230013764 5ustar cjmcjmTelephony-Asterisk-AMI-0.006/lib/0000755000175000017500000000000012637604230014532 5ustar cjmcjmTelephony-Asterisk-AMI-0.006/lib/Telephony/0000755000175000017500000000000012637604230016501 5ustar cjmcjmTelephony-Asterisk-AMI-0.006/lib/Telephony/Asterisk/0000755000175000017500000000000012637604230020266 5ustar cjmcjmTelephony-Asterisk-AMI-0.006/lib/Telephony/Asterisk/AMI.pm0000644000175000017500000004000712637604230021233 0ustar cjmcjm#--------------------------------------------------------------------- package Telephony::Asterisk::AMI; # # Copyright 2015 Christopher J. Madsen # # Author: Christopher J. Madsen # Created: 31 Oct 2015 # # This program is free software; you can redistribute it and/or modify # it under the same terms as Perl itself. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either the # GNU General Public License or the Artistic License for more details. # # ABSTRACT: Simple Asterisk Manager Interface client #--------------------------------------------------------------------- use 5.008; use strict; use warnings; use Carp (); use IO::Socket::IP (); our $VERSION = '0.006'; # This file is part of Telephony-Asterisk-AMI 0.006 (December 26, 2015) my $EOL = "\r\n"; #===================================================================== sub new { my $class = shift; my $args = (@_ == 1) ? shift : { @_ }; my $self = bless { Debug_FH => ($args->{Debug_FH} || ($args->{Debug} ? *STDERR : undef)), Event_Callback => $args->{Event_Callback}, Host => $args->{Host} || 'localhost', Port => $args->{Port} || 5038, ActionID => $args->{ActionID} || 1, }, $class; for my $key (qw(Username Secret)) { defined( $self->{$key} = $args->{$key} ) or Carp::croak("Required parameter '$key' not defined"); } $self; } # end new #--------------------------------------------------------------------- sub connect { my $self = shift; # Open a socket to Asterisk. # IO::Socket::IP->new reports error in $@ local $@; $self->{socket} = IO::Socket::IP->new( Type => IO::Socket::IP::SOCK_STREAM(), PeerHost => $self->{Host}, PeerService => $self->{Port}, ); unless ($self->{socket}) { $self->{error} = "Connection failed: $@"; return undef; } # Verify that we've connected to Asterisk Call Manager my $id = readline($self->{socket}); unless (defined $id) { $self->{error} = "Connection closed without input: $!"; undef $self->{socket}; return undef; } chomp $id; print { $self->{Debug_FH} } "<< $id\n" if $self->{Debug_FH}; if ($id =~ m!^Asterisk Call Manager/(.+)!) { $self->{protocol} = $1; } else { $self->{error} = "Unknown Protocol"; undef $self->{socket}; return undef; } # Automatically log in using Username/Secret my $response = $self->action({ Action => 'Login', Username => $self->{Username}, Secret => $self->{Secret}, }); # If login failed, set error unless ($response->{Response} eq 'Success') { $self->{error} = "Login failed: $response->{Message}"; undef $self->{socket}; return undef; } # Login successful 1; } # end connect #--------------------------------------------------------------------- sub disconnect { my $self = shift; my $response = $self->action({Action => 'Logoff'}); # If logoff failed, set error unless ($response->{Response} eq 'Goodbye') { $self->{error} = "Logoff failed: $response->{Message}"; undef $self->{socket}; return undef; } unless ($self->{socket}->close) { $self->{error} = "Closing socket failed: $!"; undef $self->{socket}; return undef; } undef $self->{socket}; # Logoff successful 1; } # end disconnect #--------------------------------------------------------------------- sub action { my $self = shift; # Send the request to Asterisk my $id = $self->send_action(@_) or return { Response => 'Error', Message => $self->{error}, }; # Read responses until we get the response to this action while (1) { my $response = $self->read_response; # If this is the response to the action we just sent, # or there was an error, return it. no warnings 'uninitialized'; if (($response->{ActionID} eq $id) || ($response->{Response} eq 'Error')) { return $response; } # If there is an event callback, send it this event if ($self->{Event_Callback}) { $self->{Event_Callback}->($response); } } # end infinite loop waiting for response } # end action #--------------------------------------------------------------------- sub send_action { my $self = shift; my $act = (@_ == 1) ? shift : { @_ }; Carp::croak("Required parameter 'Action' not defined") unless $act->{Action}; # Check that the connection is open unless ($self->{socket}) { $self->{error} = "Not connected to Asterisk!"; return undef; } # Assemble the message to send to Asterisk my $id = $self->{ActionID}++; my $message = "ActionID: $id$EOL"; for my $key (sort keys %$act) { if (ref $act->{$key}) { $message .= "$key: $_$EOL" for @{ $act->{$key} }; } else { $message .= "$key: $act->{$key}$EOL"; } } $message .= $EOL; # Message ends with blank line # If debugging, print out the message before sending it if ($self->{Debug_FH}) { my $debug = $message; $debug =~ s/\r//g; $debug =~ s/^/>> /mg; print { $self->{Debug_FH} } $debug; } # Send the request to Asterisk unless (print { $self->{socket} } $message) { $self->{error} = "Writing to socket failed: $!"; return undef; } $id; } # end send_action #--------------------------------------------------------------------- sub read_response { my $self = shift; # Check that the connection is open my $socket = $self->{socket}; unless ($socket) { return { Response => 'Error', Message => $self->{error} = "Not connected to Asterisk!", }; } # Read a response terminated by a blank line local $/ = $EOL; my $debug_fh = $self->{Debug_FH}; my ($line, %response); undef $!; while ($line = <$socket>) { chomp $line; print $debug_fh "<< $line\n" if $debug_fh; return \%response unless length $line; # Remove the key from the "Key: Value" line # If the line is not in that format, ignore it. $line =~ s/^([^:]+): // or next; if (not exists $response{$1}) { # First occurrence of this key, save as string $response{$1} = $line; } elsif (ref $response{$1}) { # Third or more occurrence of this key, append to arrayref push @{ $response{$1} }, $line; } else { # Second occurrence of this key, convert to arrayref $response{$1} = [ $response{$1}, $line ]; } } # end while reading from $socket # There was a communication failure; return an error. return { Response => 'Error', Message => $self->{error} = "Reading from socket failed: $!", }; } # end read_response #--------------------------------------------------------------------- sub error { shift->{error} } #===================================================================== # Package Return Value: 1; __END__ =head1 NAME Telephony::Asterisk::AMI - Simple Asterisk Manager Interface client =head1 VERSION This document describes version 0.006 of Telephony::Asterisk::AMI, released December 26, 2015. =head1 SYNOPSIS use Telephony::Asterisk::AMI (); my $ami = Telephony::Asterisk::AMI->new( Username => 'user', Secret => 'password', ); $ami->connect or die $ami->error; my $response = $ami->action(Action => 'Ping'); $ami->disconnect or die $ami->error; =head1 DESCRIPTION Telephony::Asterisk::AMI is a simple client for the Asterisk Manager Interface. It's better documented and less buggy than L, and has fewer prerequisites than L. It uses L, so it should support either IPv4 or IPv6. If you need a more sophisticated client (especially for use in an event-driven program), try Asterisk::AMI. =head1 METHODS =head2 Constructor =head3 new $ami = Telephony::Asterisk::AMI->new(%args); Constructs a new C<$ami> object. The C<%args> may be passed as a hashref or a list of S value >>> pairs. This does not do any network communication; you must call L to open the connection before doing anything else. The parameters are: =over =item C The AMI username to use when logging in. (required) =item C The AMI secret (password) to use when logging in. (required) =item C The hostname to connect to. You can also specify C as a single string. (default: localhost). =item C The port number to connect to (if no port was specified with C). (default: 5038) =item C The ActionID to start at. Each call to L increments the ActionID. (Note: The L & L methods also consume an ActionID for the implicit Login & Logoff actions.) (default: 1) =item C If set to a true value, sets C to C (unless it was already set to a different value). (default: false) =item C A filehandle to write a transcript of the communications to. Lines sent to Asterisk are prefixed with C<<< >> >>>, and lines received from Asterisk are prefixed with C<<< << >>>. (default: no transcript) =item C A coderef that is called when an event is received from Asterisk while the L method is waiting for a response. The event data is passed as a hashref, just like the return value of the C method. You MUST NOT call any methods on C<$ami> from inside the callback. (default: events are ignored) =back The constructor throws an exception if a required parameter is omitted. =head2 Main Methods =head3 connect $success = $ami->connect; Opens the connection to Asterisk and logs in. C<$success> is true if the login was successful, or C on error. On failure, you can get the error message with C<< $ami->error >>. =head3 disconnect $success = $ami->disconnect; Logs off of Asterisk and closes the connection. C<$success> is true if the logoff was successful, or C on error. On failure, you can get the error message with C<< $ami->error >>. After a successful call to C, you may call C again to reestablish the connection. =head3 action $response = $ami->action(%args); Sends an action request to Asterisk and returns the response. The C<%args> may be passed as a hashref or a list of S value >>> pairs, where the keys are the Asterisk field names. To create more than one instance of a field, make the value an arrayref. The only required key is C. (Asterisk may require other keys depending on the value of C, but that is not enforced by this module.) Do not pass an C in C<%args>. The ActionID is provided automatically. The C<$response> is a hashref formed from Asterisk's response in the same format as C<%args>. It will have a C key whose value is either C or C. Unless it's an error response, it will also have an C key whose value is the ActionID assigned to it. (An error response might or might not have an ActionID.) Any events that are received while waiting for the response to the action are dispatched to the C (if any). If no callback was provided, events are discarded. If you have not called the C method (or it failed), calling C will return a manufactured Error response with Message "Not connected to Asterisk!" and set C<< $ami->error >>. If communication with Asterisk fails, it will return a manufactured Error response with Message "Writing to socket failed: %s" or "Reading from socket failed: %s" and set C<< $ami->error >>. =head3 error $error_message = $ami->error; If communication with Asterisk fails, this method will return an error message describing the problem. If Asterisk returns "Response: Error" for some action, that does not set C<< $ami->error >>. The exceptions are the automatic Login and Logoff actions performed by the L and L methods, which do set C on failure. It returns C if there has been no communication error. =head2 Low-Level Methods You shouldn't normally need to use these methods, but sometimes you need more control over the communication with Asterisk. =head3 send_action $actionid = $ami->send_action(%args); Sends an action request to Asterisk and returns the ActionID. The C<%args> are the same as for L. Do not pass an C in C<%args>. The ActionID is provided automatically and returned. If you have not called the C method (or it failed), calling C will return C and set C<< $ami->error >> to "Not connected to Asterisk!". If communication with Asterisk fails, it will return C and set C<< $ami->error >> to "Writing to socket failed: %s". =head3 read_response $response = $ami->read_response; Reads a single message from Asterisk. Blocks until a message arrives. The C method waits for the response, so C is only useful for reading events (or if you used the low-level C method). It returns a hashref in the same format as the return value of the C method. See that for details. Note that events received by C are not delivered to the C (if any). The callback is used only for events that are received during the execution of the C method. If you have not called the C method (or it failed), calling C will return a manufactured Error response with Message "Not connected to Asterisk!" and set C<< $ami->error >>. If communication with Asterisk fails, it will return a manufactured Error response with Message "Reading from socket failed: %s" and set C<< $ami->error >>. =head1 SEE ALSO L L is a more sophisticated AMI client better suited for event-driven programs. If you're using L, you may want L. =head1 DIAGNOSTICS =over =item C You omitted a required parameter from a method call. =back =head1 CONFIGURATION AND ENVIRONMENT Telephony::Asterisk::AMI requires no configuration files or environment variables. =head1 DEPENDENCIES Telephony::Asterisk::AMI depends on L, which became a core module with Perl 5.20. There are no other non-core dependencies. =head1 INCOMPATIBILITIES None reported. =head1 BUGS AND LIMITATIONS No bugs have been reported. =head1 AUTHOR Christopher J. Madsen S >>> Please report any bugs or feature requests to S >>> or through the web interface at L<< http://rt.cpan.org/Public/Bug/Report.html?Queue=Telephony-Asterisk-AMI >>. You can follow or contribute to Telephony-Asterisk-AMI's development at L<< https://github.com/madsen/Telephony-Asterisk-AMI >>. =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2015 by Christopher J. Madsen. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =head1 DISCLAIMER OF WARRANTY BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENSE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. =cut Telephony-Asterisk-AMI-0.006/xt/0000755000175000017500000000000012637604230014417 5ustar cjmcjmTelephony-Asterisk-AMI-0.006/xt/author/0000755000175000017500000000000012637604230015721 5ustar cjmcjmTelephony-Asterisk-AMI-0.006/xt/author/pod-coverage.t0000644000175000017500000000033412637604230020461 0ustar cjmcjm#!perl # This file was automatically generated by Dist::Zilla::Plugin::PodCoverageTests. use Test::Pod::Coverage 1.08; use Pod::Coverage::TrustPod; all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' }); Telephony-Asterisk-AMI-0.006/xt/author/pod-syntax.t0000644000175000017500000000025212637604230020213 0ustar cjmcjm#!perl # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use strict; use warnings; use Test::More; use Test::Pod 1.41; all_pod_files_ok(); Telephony-Asterisk-AMI-0.006/Makefile.PL0000644000175000017500000000230012637604230015731 0ustar cjmcjm# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.041. use strict; use warnings; use 5.008; use ExtUtils::MakeMaker; my %WriteMakefileArgs = ( "ABSTRACT" => "Simple Asterisk Manager Interface client", "AUTHOR" => "Christopher J. Madsen ", "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => 0 }, "DISTNAME" => "Telephony-Asterisk-AMI", "LICENSE" => "perl", "MIN_PERL_VERSION" => "5.008", "NAME" => "Telephony::Asterisk::AMI", "PREREQ_PM" => { "Carp" => 0, "IO::Socket::IP" => 0 }, "TEST_REQUIRES" => { "Exporter" => "5.57", "Test::More" => "0.88", "Tie::Handle" => 0 }, "VERSION" => "0.006", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "Carp" => 0, "Exporter" => "5.57", "IO::Socket::IP" => 0, "Test::More" => "0.88", "Tie::Handle" => 0 ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); Telephony-Asterisk-AMI-0.006/t/0000755000175000017500000000000012637604230014227 5ustar cjmcjmTelephony-Asterisk-AMI-0.006/t/00-all_prereqs.t0000644000175000017500000000533112637604230017144 0ustar cjmcjm#!perl use strict; use warnings; # This doesn't use Test::More because I don't want to clutter %INC # with modules that aren't prerequisites. my $test = 0; my $tests_completed; sub ok ($$) { my ($ok, $name) = @_; printf "%sok %d - %s\n", ($ok ? '' : 'not '), ++$test, $name; return $ok; } # end ok END { ok(0, 'unknown failure') unless defined $tests_completed; print "1..$tests_completed\n"; } sub get_version { my ($package) = @_; local $@; my $version = eval { $package->VERSION }; defined $version ? $version : 'undef'; } # end get_version TEST: { ok(open(META, ') { last if /^\s*"prereqs" : \{\s*\z/; } # end while ok(defined $_, 'found prereqs') or last TEST; while () { last if /^\s*\},?\s*\z/; ok(/^\s*"(.+)" : \{\s*\z/, "found phase $1") or last TEST; my $phase = $1; while () { last if /^\s*\},?\s*\z/; next if /^\s*"[^"]+"\s*:\s*\{\s*\},?\s*\z/; ok(/^\s*"(.+)" : \{\s*\z/, "found relationship $phase $1") or last TEST; my $rel = $1; while () { last if /^\s*\},?\s*\z/; ok(/^\s*"([^"]+)"\s*:\s*(\S+?),?\s*\z/, "found prereq $1") or last TEST; my ($prereq, $version) = ($1, $2); next if $phase ne 'runtime' or $prereq eq 'perl'; # Need a special case for if.pm, because "require if;" is a syntax error. my $loaded = ($prereq eq 'if') ? eval "require '$prereq.pm'; 1" : eval "require $prereq; 1"; if ($rel eq 'requires') { ok($loaded, "loaded $prereq") or print STDERR "\n# ERROR: Wanted: $prereq $version\n"; } else { ok(1, ($loaded ? 'loaded' : 'failed to load') . " $prereq"); } if ($loaded and not ($version eq '"0"' or eval "'$prereq'->VERSION($version); 1")) { printf STDERR "\n# WARNING: Got: %s %s\n# Wanted: %s %s\n", $prereq, get_version($prereq), $prereq, $version; } } # end while in prerequisites } # end while in relationship } # end while in phase close META; # Print version of all loaded modules: if ($ENV{AUTOMATED_TESTING} or (@ARGV and ($ARGV[0] eq '-v' or $ARGV[0] eq '--verbose'))) { print STDERR "# Listing %INC\n"; my @packages = grep { s/\.pm\Z// and do { s![\\/]!::!g; 1 } } sort keys %INC; my $len = 0; for (@packages) { $len = length if length > $len } $len = 68 if $len > 68; for my $package (@packages) { printf STDERR "# %${len}s %s\n", $package, get_version($package); } } # end if AUTOMATED_TESTING } # end TEST $tests_completed = $test; Telephony-Asterisk-AMI-0.006/t/20-ami-events.t0000644000175000017500000001566512637604230016720 0ustar cjmcjm#! /usr/local/bin/perl #--------------------------------------------------------------------- # Test Telephony::Asterisk::AMI with active Event_Callback # # Copyright 2015 Christopher J. Madsen #--------------------------------------------------------------------- use 5.008; use strict; use warnings; use Test::More 0.88 tests => 31; # done_testing use t::Fake_Socket; use Telephony::Asterisk::AMI (); set_input(<<'END INPUT 1'); Asterisk Call Manager/2.8.0 Response: Success ActionID: 1 Message: Authentication accepted Event: FullyBooted Privilege: system,all Status: Fully Booted Event: SuccessfulAuth Privilege: security,all EventTV: 2015-11-28T11:56:38.090-0600 Severity: Informational Service: AMI EventVersion: 1 AccountID: monitor SessionID: 0x7fdef0015978 LocalAddress: IPV4/TCP/0.0.0.0/5038 RemoteAddress: IPV4/TCP/127.0.0.1/34314 UsingPassword: 0 SessionTV: 2015-11-28T11:56:38.090-0600 Response: Error ActionID: 2 Message: Extension does not exist. Event: InOrder Single: This field appears once. Double: This field appears Double: two times. Triple: This field appears Triple: three Triple: times. Event: MixedOrder Double: This field appears Triple: This field appears Single: This field appears once. Triple: three Double: two times. Triple: times. Response: Success ActionID: 3 Ping: Pong Timestamp: 1448733398.096444 Response: Success ActionID: 4 CoreStartupDate: 2015-11-15 CoreStartupTime: 10:41:57 CoreReloadDate: 2015-11-15 CoreReloadTime: 15:36:37 CoreCurrentCalls: 0 Response: Success ActionID: 5 Single: This field appears once. Double: This field appears Double: two times. Triple: This field appears Triple: three Triple: times. Response: Success ActionID: 6 Double: This field appears Triple: This field appears Single: This field appears once. Triple: three Double: two times. Triple: times. Response: Goodbye ActionID: 7 Message: Thanks for all the fish. END INPUT 1 my @events; my $ami = Telephony::Asterisk::AMI->new( Username => 'user', Secret => 'secret', Event_Callback => sub { push @events, @_ }, #Debug => 1, ); isa_ok($ami, 'Telephony::Asterisk::AMI'); is_deeply(\@events, [], 'no events from constructor'); @events = (); #..................................................................... ok($ami->connect, "connected"); is_deeply( socket_args, { Type => IO::Socket::IP::SOCK_STREAM(), PeerHost => 'localhost', PeerService => 5038, }, 'socket args correct'); is($ami->error, undef, 'connect did not set error'); is_deeply(\@events, [], 'no events from connect'); @events = (); is(socket_output, "ActionID: 1\r\nAction: Login\r\nSecret: secret\r\nUsername: user\r\n\r\n", 'connect output correct'); #..................................................................... is_deeply( $ami->action({ Action => 'Originate', Channel => 'LOCAL/invalid', Exten => '100', Context => 'default', Priority => '1', Variable => [ 'VAR1=v1', 'VAR2=v2' ], }), { ActionID => 2, Message => "Extension does not exist.", Response => "Error", }, 'Originate error'); is($ami->error, undef, 'Originate did not set error'); is_deeply(\@events, [ { Event => "FullyBooted", Privilege => "system,all", Status => "Fully Booted", }, { Event => "SuccessfulAuth", AccountID => "monitor", EventTV => "2015-11-28T11:56:38.090-0600", EventVersion => 1, LocalAddress => "IPV4/TCP/0.0.0.0/5038", Privilege => "security,all", RemoteAddress => "IPV4/TCP/127.0.0.1/34314", Service => "AMI", SessionID => "0x7fdef0015978", SessionTV => "2015-11-28T11:56:38.090-0600", Severity => "Informational", UsingPassword => 0, }, ], 'events during Originate'); @events = (); is(socket_output, "ActionID: 2\r\nAction: Originate\r\nChannel: LOCAL/invalid\r\n" . "Context: default\r\nExten: 100\r\nPriority: 1\r\n" . "Variable: VAR1=v1\r\nVariable: VAR2=v2\r\n\r\n", 'Originate output correct'); #..................................................................... is_deeply( $ami->action(Action => 'Ping'), { ActionID => 3, Ping => "Pong", Response => "Success", Timestamp => "1448733398.096444", }, 'Ping successful'); is($ami->error, undef, 'Ping did not set error'); is_deeply(\@events, [ { Event => "InOrder", Single => "This field appears once.", Double => ["This field appears", "two times."], Triple => ["This field appears", "three", "times."], }, { Event => "MixedOrder", Single => "This field appears once.", Double => ["This field appears", "two times."], Triple => ["This field appears", "three", "times."], }, ], 'events during Ping'); @events = (); is(socket_output, "ActionID: 3\r\nAction: Ping\r\n\r\n", 'Ping output correct'); #..................................................................... is_deeply( $ami->action(Action => 'CoreStatus'), { ActionID => 4, CoreCurrentCalls => 0, CoreReloadDate => "2015-11-15", CoreReloadTime => "15:36:37", CoreStartupDate => "2015-11-15", CoreStartupTime => "10:41:57", Response => "Success", }, 'CoreStatus successful'); is($ami->error, undef, 'CoreStatus did not set error'); is_deeply(\@events, [], 'no events during CoreStatus'); @events = (); is(socket_output, "ActionID: 4\r\nAction: CoreStatus\r\n\r\n", 'CoreStatus output correct'); #..................................................................... is_deeply( $ami->action(Action => 'TestInput'), { ActionID => 5, Response => "Success", Single => 'This field appears once.', Double => [ 'This field appears', 'two times.' ], Triple => [ 'This field appears', 'three', 'times.' ], }, 'TestInput successful'); is($ami->error, undef, 'TestInput did not set error'); is_deeply(\@events, [], 'no events during TestInput'); @events = (); is(socket_output, "ActionID: 5\r\nAction: TestInput\r\n\r\n", 'TestInput output correct'); #..................................................................... is_deeply( $ami->action(Action => 'TestInputMixed'), { ActionID => 6, Response => "Success", Single => 'This field appears once.', Double => [ 'This field appears', 'two times.' ], Triple => [ 'This field appears', 'three', 'times.' ], }, 'TestInputMixed successful'); is($ami->error, undef, 'TestInputMixed did not set error'); is_deeply(\@events, [], 'no events during TestInputMixed'); @events = (); is(socket_output, "ActionID: 6\r\nAction: TestInputMixed\r\n\r\n", 'TestInputMixed output correct'); #..................................................................... ok($ami->disconnect, 'disconnected'); is($ami->error, undef, 'disconnect did not set error'); is_deeply(\@events, [], 'no events from disconnect'); @events = (); is(socket_output, "ActionID: 7\r\nAction: Logoff\r\n\r\n", 'disconnect output correct'); done_testing; Telephony-Asterisk-AMI-0.006/t/Fake_Socket.pm0000644000175000017500000001134212637604230016744 0ustar cjmcjm#--------------------------------------------------------------------- package t::Fake_Socket; # # Copyright 2015 Christopher J. Madsen # # Author: Christopher J. Madsen # Created: 26 Dec 2015 # # This program is free software; you can redistribute it and/or modify # it under the same terms as Perl itself. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either the # GNU General Public License or the Artistic License for more details. # # ABSTRACT: Fake socket class for testing Telephony::Asterisk::AMI #--------------------------------------------------------------------- our $VERSION = '0.006'; # VERSION # This file is part of Telephony-Asterisk-AMI 0.006 (December 26, 2015) use 5.008; use strict; use warnings; use IO::Socket::IP (); use Tie::Handle (); use Exporter 5.57 'import'; # exported import method our @EXPORT = qw(set_input socket_args socket_output); our @ISA = qw(Tie::Handle); #===================================================================== # Socket implementation #--------------------------------------------------------------------- my (@input, $output, $socket_args); sub TIEHANDLE { $output = ''; bless {}, shift; } sub READLINE { shift @input } sub WRITE { my ($self, $data, $length, $offset) = @_; $output .= substr($data, $offset, $length); 1; } sub CLOSE { 1 } #===================================================================== # Monkey-patch IO::Socket::IP to return a t::Fake_Socket instead #--------------------------------------------------------------------- { no warnings 'redefine'; sub IO::Socket::IP::new { my ($class, %args) = @_; $socket_args = \%args; tie *t::Fake_Socket::SOCKET_FH, 't::Fake_Socket'; *t::Fake_Socket::SOCKET_FH; } # end IO::Socket::IP::new } #===================================================================== # Exported subroutines #--------------------------------------------------------------------- # Set up the @input array from a string sub set_input { @input = split(/\r?\n/, shift, -1); $_ .= "\r\n" for @input; } # end set_input # Return the current $socket_args sub socket_args { $socket_args; } # Return the current $output and clear it sub socket_output { substr($output, 0, length($output), ''); } #===================================================================== # Package Return Value: 1; __END__ =head1 NAME t::Fake_Socket - Fake socket class for testing Telephony::Asterisk::AMI =head1 VERSION This document describes version 0.006 of t::Fake_Socket, released December 26, 2015. =head1 CONFIGURATION AND ENVIRONMENT t::Fake_Socket requires no configuration files or environment variables. =head1 INCOMPATIBILITIES None reported. =head1 BUGS AND LIMITATIONS No bugs have been reported. =head1 AUTHOR Christopher J. Madsen S >>> Please report any bugs or feature requests to S >>> or through the web interface at L<< http://rt.cpan.org/Public/Bug/Report.html?Queue=Telephony-Asterisk-AMI >>. You can follow or contribute to Telephony-Asterisk-AMI's development at L<< https://github.com/madsen/Telephony-Asterisk-AMI >>. =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2015 by Christopher J. Madsen. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =head1 DISCLAIMER OF WARRANTY BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENSE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. =cut Telephony-Asterisk-AMI-0.006/t/00-load.t0000644000175000017500000000036512637604230015554 0ustar cjmcjm#! /usr/bin/perl #--------------------------------------------------------------------- use Test::More tests => 1; BEGIN { use_ok('Telephony::Asterisk::AMI'); } diag("Testing Telephony::Asterisk::AMI $Telephony::Asterisk::AMI::VERSION"); Telephony-Asterisk-AMI-0.006/t/10-ami.t0000644000175000017500000001250012637604230015376 0ustar cjmcjm#! /usr/local/bin/perl #--------------------------------------------------------------------- # Test Telephony::Asterisk::AMI # # Copyright 2015 Christopher J. Madsen #--------------------------------------------------------------------- use 5.008; use strict; use warnings; use Test::More 0.88 tests => 23; # done_testing use t::Fake_Socket; use Telephony::Asterisk::AMI (); set_input(<<'END INPUT 1'); Asterisk Call Manager/2.8.0 Response: Success ActionID: 1 Message: Authentication accepted Event: FullyBooted Privilege: system,all Status: Fully Booted Event: SuccessfulAuth Privilege: security,all EventTV: 2015-11-28T11:56:38.090-0600 Severity: Informational Service: AMI EventVersion: 1 AccountID: monitor SessionID: 0x7fdef0015978 LocalAddress: IPV4/TCP/0.0.0.0/5038 RemoteAddress: IPV4/TCP/127.0.0.1/34314 UsingPassword: 0 SessionTV: 2015-11-28T11:56:38.090-0600 Response: Error ActionID: 2 Message: Extension does not exist. Event: InOrder Single: This field appears once. Double: This field appears Double: two times. Triple: This field appears Triple: three Triple: times. Event: MixedOrder Double: This field appears Triple: This field appears Single: This field appears once. Triple: three Double: two times. Triple: times. Response: Success ActionID: 3 Ping: Pong Timestamp: 1448733398.096444 Response: Success ActionID: 4 CoreStartupDate: 2015-11-15 CoreStartupTime: 10:41:57 CoreReloadDate: 2015-11-15 CoreReloadTime: 15:36:37 CoreCurrentCalls: 0 Response: Success ActionID: 5 Single: This field appears once. Double: This field appears Double: two times. Triple: This field appears Triple: three Triple: times. Response: Success ActionID: 6 Double: This field appears Triple: This field appears Single: This field appears once. Triple: three Double: two times. Triple: times. Response: Goodbye ActionID: 7 Message: Thanks for all the fish. END INPUT 1 my $ami = Telephony::Asterisk::AMI->new( Username => 'user', Secret => 'secret', #Debug => 1, ); isa_ok($ami, 'Telephony::Asterisk::AMI'); #..................................................................... ok($ami->connect, "connected"); is_deeply( socket_args, { Type => IO::Socket::IP::SOCK_STREAM(), PeerHost => 'localhost', PeerService => 5038, }, 'socket args correct'); is($ami->error, undef, 'connect did not set error'); is(socket_output, "ActionID: 1\r\nAction: Login\r\nSecret: secret\r\nUsername: user\r\n\r\n", 'connect output correct'); #..................................................................... is_deeply( $ami->action({ Action => 'Originate', Channel => 'LOCAL/invalid', Exten => '100', Context => 'default', Priority => '1', Variable => [ 'VAR1=v1', 'VAR2=v2' ], }), { ActionID => 2, Message => "Extension does not exist.", Response => "Error", }, 'Originate error'); is($ami->error, undef, 'Originate did not set error'); is(socket_output, "ActionID: 2\r\nAction: Originate\r\nChannel: LOCAL/invalid\r\n" . "Context: default\r\nExten: 100\r\nPriority: 1\r\n" . "Variable: VAR1=v1\r\nVariable: VAR2=v2\r\n\r\n", 'Originate output correct'); #..................................................................... is_deeply( $ami->action(Action => 'Ping'), { ActionID => 3, Ping => "Pong", Response => "Success", Timestamp => "1448733398.096444", }, 'Ping successful'); is($ami->error, undef, 'Ping did not set error'); is(socket_output, "ActionID: 3\r\nAction: Ping\r\n\r\n", 'Ping output correct'); #..................................................................... is_deeply( $ami->action(Action => 'CoreStatus'), { ActionID => 4, CoreCurrentCalls => 0, CoreReloadDate => "2015-11-15", CoreReloadTime => "15:36:37", CoreStartupDate => "2015-11-15", CoreStartupTime => "10:41:57", Response => "Success", }, 'CoreStatus successful'); is($ami->error, undef, 'CoreStatus did not set error'); is(socket_output, "ActionID: 4\r\nAction: CoreStatus\r\n\r\n", 'CoreStatus output correct'); #..................................................................... is_deeply( $ami->action(Action => 'TestInput'), { ActionID => 5, Response => "Success", Single => 'This field appears once.', Double => [ 'This field appears', 'two times.' ], Triple => [ 'This field appears', 'three', 'times.' ], }, 'TestInput successful'); is($ami->error, undef, 'TestInput did not set error'); is(socket_output, "ActionID: 5\r\nAction: TestInput\r\n\r\n", 'TestInput output correct'); #..................................................................... is_deeply( $ami->action(Action => 'TestInputMixed'), { ActionID => 6, Response => "Success", Single => 'This field appears once.', Double => [ 'This field appears', 'two times.' ], Triple => [ 'This field appears', 'three', 'times.' ], }, 'TestInputMixed successful'); is($ami->error, undef, 'TestInputMixed did not set error'); is(socket_output, "ActionID: 6\r\nAction: TestInputMixed\r\n\r\n", 'TestInputMixed output correct'); #..................................................................... ok($ami->disconnect, 'disconnected'); is($ami->error, undef, 'disconnect did not set error'); is(socket_output, "ActionID: 7\r\nAction: Logoff\r\n\r\n", 'disconnect output correct'); done_testing; Telephony-Asterisk-AMI-0.006/META.json0000644000175000017500000002471412637604230015415 0ustar cjmcjm{ "abstract" : "Simple Asterisk Manager Interface client", "author" : [ "Christopher J. Madsen " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 5.041, CPAN::Meta::Converter version 2.142690", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Telephony-Asterisk-AMI", "no_index" : { "directory" : [ "t" ] }, "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "develop" : { "requires" : { "Pod::Coverage::TrustPod" : "0", "Test::More" : "0", "Test::Pod" : "1.41", "Test::Pod::Coverage" : "1.08" } }, "runtime" : { "requires" : { "Carp" : "0", "IO::Socket::IP" : "0", "perl" : "5.008" } }, "test" : { "requires" : { "Exporter" : "5.57", "Test::More" : "0.88", "Tie::Handle" : "0" } } }, "release_status" : "stable", "resources" : { "repository" : { "type" : "git", "url" : "git://github.com/madsen/Telephony-Asterisk-AMI.git", "web" : "https://github.com/madsen/Telephony-Asterisk-AMI" } }, "version" : "0.006", "x_Dist_Zilla" : { "perl" : { "version" : "5.018002" }, "plugins" : [ { "class" : "Dist::Zilla::Plugin::FileFinder::ByName", "name" : "TestModules", "version" : "5.041" }, { "class" : "Dist::Zilla::Plugin::OurPkgVersion", "name" : "OurPkgVersion", "version" : "0.005001" }, { "class" : "Dist::Zilla::Plugin::VersionFromModule", "name" : "CJM/VersionFromModule", "version" : "0.08" }, { "class" : "Dist::Zilla::Plugin::GatherDir", "config" : { "Dist::Zilla::Plugin::GatherDir" : { "exclude_filename" : [], "exclude_match" : [], "follow_symlinks" : 0, "include_dotfiles" : 0, "prefix" : "", "prune_directory" : [], "root" : "." } }, "name" : "CJM/GatherDir", "version" : "5.041" }, { "class" : "Dist::Zilla::Plugin::PruneCruft", "name" : "CJM/PruneCruft", "version" : "5.041" }, { "class" : "Dist::Zilla::Plugin::ManifestSkip", "name" : "CJM/ManifestSkip", "version" : "5.041" }, { "class" : "Dist::Zilla::Plugin::MetaJSON", "name" : "CJM/MetaJSON", "version" : "5.041" }, { "class" : "Dist::Zilla::Plugin::MetaYAML", "name" : "CJM/MetaYAML", "version" : "5.041" }, { "class" : "Dist::Zilla::Plugin::License", "name" : "CJM/License", "version" : "5.041" }, { "class" : "Dist::Zilla::Plugin::Test::PrereqsFromMeta", "name" : "CJM/Test::PrereqsFromMeta", "version" : "4.23" }, { "class" : "Dist::Zilla::Plugin::PodSyntaxTests", "name" : "CJM/PodSyntaxTests", "version" : "5.041" }, { "class" : "Dist::Zilla::Plugin::PodCoverageTests", "name" : "CJM/PodCoverageTests", "version" : "5.041" }, { "class" : "Dist::Zilla::Plugin::PodLoom", "config" : { "Pod::Loom version" : "0.08" }, "name" : "CJM/PodLoom", "version" : "5.001" }, { "class" : "Dist::Zilla::Plugin::MakeMaker", "config" : { "Dist::Zilla::Role::TestRunner" : { "default_jobs" : 1 } }, "name" : "CJM/MakeMaker", "version" : "5.041" }, { "class" : "Dist::Zilla::Plugin::RunExtraTests", "config" : { "Dist::Zilla::Role::TestRunner" : { "default_jobs" : 1 } }, "name" : "CJM/RunExtraTests", "version" : "0.011" }, { "class" : "Dist::Zilla::Plugin::MetaConfig", "name" : "CJM/MetaConfig", "version" : "5.041" }, { "class" : "Dist::Zilla::Plugin::MatchManifest", "name" : "CJM/MatchManifest", "version" : "4.02" }, { "class" : "Dist::Zilla::Plugin::RecommendedPrereqs", "name" : "CJM/RecommendedPrereqs", "version" : "4.21" }, { "class" : "Dist::Zilla::Plugin::CheckPrereqsIndexed", "name" : "CJM/CheckPrereqsIndexed", "version" : "0.009" }, { "class" : "Dist::Zilla::Plugin::GitVersionCheckCJM", "name" : "CJM/GitVersionCheckCJM", "version" : "4.27" }, { "class" : "Dist::Zilla::Plugin::TemplateCJM", "name" : "CJM/TemplateCJM", "version" : "5.001" }, { "class" : "Dist::Zilla::Plugin::Repository", "name" : "CJM/Repository", "version" : "0.19" }, { "class" : "Dist::Zilla::Plugin::Git::Check", "config" : { "Dist::Zilla::Plugin::Git::Check" : { "untracked_files" : "die" }, "Dist::Zilla::Role::Git::DirtyFiles" : { "allow_dirty" : [ "Changes" ], "allow_dirty_match" : [], "changelog" : "Changes" }, "Dist::Zilla::Role::Git::Repo" : { "repo_root" : "." } }, "name" : "CJM/@Git/Check", "version" : "2.034" }, { "class" : "Dist::Zilla::Plugin::Git::Commit", "config" : { "Dist::Zilla::Plugin::Git::Commit" : { "add_files_in" : [], "commit_msg" : "Updated Changes for %{MMMM d, yyyy}d%{ trial}t release of %v", "time_zone" : "local" }, "Dist::Zilla::Role::Git::DirtyFiles" : { "allow_dirty" : [ "Changes" ], "allow_dirty_match" : [], "changelog" : "Changes" }, "Dist::Zilla::Role::Git::Repo" : { "repo_root" : "." } }, "name" : "CJM/@Git/Commit", "version" : "2.034" }, { "class" : "Dist::Zilla::Plugin::Git::Tag", "config" : { "Dist::Zilla::Plugin::Git::Tag" : { "branch" : null, "signed" : 0, "tag" : "0.006", "tag_format" : "%v%t", "tag_message" : "Tagged %N %v%{ (trial release)}t", "time_zone" : "local" }, "Dist::Zilla::Role::Git::Repo" : { "repo_root" : "." } }, "name" : "CJM/@Git/Tag", "version" : "2.034" }, { "class" : "Dist::Zilla::Plugin::Git::Push", "config" : { "Dist::Zilla::Plugin::Git::Push" : { "push_to" : [ "github master" ], "remotes_must_exist" : 1 }, "Dist::Zilla::Role::Git::Repo" : { "repo_root" : "." } }, "name" : "CJM/@Git/Push", "version" : "2.034" }, { "class" : "Dist::Zilla::Plugin::TestRelease", "name" : "CJM/TestRelease", "version" : "5.041" }, { "class" : "Dist::Zilla::Plugin::UploadToCPAN", "name" : "CJM/UploadToCPAN", "version" : "5.041" }, { "class" : "Dist::Zilla::Plugin::ArchiveRelease", "name" : "CJM/ArchiveRelease", "version" : "4.26" }, { "class" : "Dist::Zilla::Plugin::AutoPrereqs", "name" : "AutoPrereqs", "version" : "5.041" }, { "class" : "Dist::Zilla::Plugin::Metadata", "name" : "Metadata", "version" : "3.03" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":InstallModules", "version" : "5.041" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":IncModules", "version" : "5.041" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":TestFiles", "version" : "5.041" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExtraTestFiles", "version" : "5.041" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExecFiles", "version" : "5.041" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":PerlExecFiles", "version" : "5.041" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ShareFiles", "version" : "5.041" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":MainModule", "version" : "5.041" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":AllFiles", "version" : "5.041" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":NoFiles", "version" : "5.041" } ], "zilla" : { "class" : "Dist::Zilla::Dist::Builder", "config" : { "is_trial" : "0" }, "version" : "5.041" } } } Telephony-Asterisk-AMI-0.006/META.yml0000644000175000017500000001466612637604230015252 0ustar cjmcjm--- abstract: 'Simple Asterisk Manager Interface client' author: - 'Christopher J. Madsen ' build_requires: Exporter: 5.57 Test::More: 0.88 Tie::Handle: 0 configure_requires: ExtUtils::MakeMaker: 0 dynamic_config: 0 generated_by: 'Dist::Zilla version 5.041, CPAN::Meta::Converter version 2.142690' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Telephony-Asterisk-AMI no_index: directory: - t requires: Carp: 0 IO::Socket::IP: 0 perl: 5.008 resources: repository: git://github.com/madsen/Telephony-Asterisk-AMI.git version: 0.006 x_Dist_Zilla: perl: version: 5.018002 plugins: - class: Dist::Zilla::Plugin::FileFinder::ByName name: TestModules version: 5.041 - class: Dist::Zilla::Plugin::OurPkgVersion name: OurPkgVersion version: 0.005001 - class: Dist::Zilla::Plugin::VersionFromModule name: CJM/VersionFromModule version: 0.08 - class: Dist::Zilla::Plugin::GatherDir config: Dist::Zilla::Plugin::GatherDir: exclude_filename: [] exclude_match: [] follow_symlinks: 0 include_dotfiles: 0 prefix: '' prune_directory: [] root: '.' name: CJM/GatherDir version: 5.041 - class: Dist::Zilla::Plugin::PruneCruft name: CJM/PruneCruft version: 5.041 - class: Dist::Zilla::Plugin::ManifestSkip name: CJM/ManifestSkip version: 5.041 - class: Dist::Zilla::Plugin::MetaJSON name: CJM/MetaJSON version: 5.041 - class: Dist::Zilla::Plugin::MetaYAML name: CJM/MetaYAML version: 5.041 - class: Dist::Zilla::Plugin::License name: CJM/License version: 5.041 - class: Dist::Zilla::Plugin::Test::PrereqsFromMeta name: CJM/Test::PrereqsFromMeta version: 4.23 - class: Dist::Zilla::Plugin::PodSyntaxTests name: CJM/PodSyntaxTests version: 5.041 - class: Dist::Zilla::Plugin::PodCoverageTests name: CJM/PodCoverageTests version: 5.041 - class: Dist::Zilla::Plugin::PodLoom config: Pod::Loom version: 0.08 name: CJM/PodLoom version: 5.001 - class: Dist::Zilla::Plugin::MakeMaker config: Dist::Zilla::Role::TestRunner: default_jobs: 1 name: CJM/MakeMaker version: 5.041 - class: Dist::Zilla::Plugin::RunExtraTests config: Dist::Zilla::Role::TestRunner: default_jobs: 1 name: CJM/RunExtraTests version: 0.011 - class: Dist::Zilla::Plugin::MetaConfig name: CJM/MetaConfig version: 5.041 - class: Dist::Zilla::Plugin::MatchManifest name: CJM/MatchManifest version: 4.02 - class: Dist::Zilla::Plugin::RecommendedPrereqs name: CJM/RecommendedPrereqs version: 4.21 - class: Dist::Zilla::Plugin::CheckPrereqsIndexed name: CJM/CheckPrereqsIndexed version: 0.009 - class: Dist::Zilla::Plugin::GitVersionCheckCJM name: CJM/GitVersionCheckCJM version: 4.27 - class: Dist::Zilla::Plugin::TemplateCJM name: CJM/TemplateCJM version: 5.001 - class: Dist::Zilla::Plugin::Repository name: CJM/Repository version: 0.19 - class: Dist::Zilla::Plugin::Git::Check config: Dist::Zilla::Plugin::Git::Check: untracked_files: die Dist::Zilla::Role::Git::DirtyFiles: allow_dirty: - Changes allow_dirty_match: [] changelog: Changes Dist::Zilla::Role::Git::Repo: repo_root: '.' name: CJM/@Git/Check version: 2.034 - class: Dist::Zilla::Plugin::Git::Commit config: Dist::Zilla::Plugin::Git::Commit: add_files_in: [] commit_msg: 'Updated Changes for %{MMMM d, yyyy}d%{ trial}t release of %v' time_zone: local Dist::Zilla::Role::Git::DirtyFiles: allow_dirty: - Changes allow_dirty_match: [] changelog: Changes Dist::Zilla::Role::Git::Repo: repo_root: '.' name: CJM/@Git/Commit version: 2.034 - class: Dist::Zilla::Plugin::Git::Tag config: Dist::Zilla::Plugin::Git::Tag: branch: ~ signed: 0 tag: 0.006 tag_format: '%v%t' tag_message: 'Tagged %N %v%{ (trial release)}t' time_zone: local Dist::Zilla::Role::Git::Repo: repo_root: '.' name: CJM/@Git/Tag version: 2.034 - class: Dist::Zilla::Plugin::Git::Push config: Dist::Zilla::Plugin::Git::Push: push_to: - 'github master' remotes_must_exist: 1 Dist::Zilla::Role::Git::Repo: repo_root: '.' name: CJM/@Git/Push version: 2.034 - class: Dist::Zilla::Plugin::TestRelease name: CJM/TestRelease version: 5.041 - class: Dist::Zilla::Plugin::UploadToCPAN name: CJM/UploadToCPAN version: 5.041 - class: Dist::Zilla::Plugin::ArchiveRelease name: CJM/ArchiveRelease version: 4.26 - class: Dist::Zilla::Plugin::AutoPrereqs name: AutoPrereqs version: 5.041 - class: Dist::Zilla::Plugin::Metadata name: Metadata version: 3.03 - class: Dist::Zilla::Plugin::FinderCode name: ':InstallModules' version: 5.041 - class: Dist::Zilla::Plugin::FinderCode name: ':IncModules' version: 5.041 - class: Dist::Zilla::Plugin::FinderCode name: ':TestFiles' version: 5.041 - class: Dist::Zilla::Plugin::FinderCode name: ':ExtraTestFiles' version: 5.041 - class: Dist::Zilla::Plugin::FinderCode name: ':ExecFiles' version: 5.041 - class: Dist::Zilla::Plugin::FinderCode name: ':PerlExecFiles' version: 5.041 - class: Dist::Zilla::Plugin::FinderCode name: ':ShareFiles' version: 5.041 - class: Dist::Zilla::Plugin::FinderCode name: ':MainModule' version: 5.041 - class: Dist::Zilla::Plugin::FinderCode name: ':AllFiles' version: 5.041 - class: Dist::Zilla::Plugin::FinderCode name: ':NoFiles' version: 5.041 zilla: class: Dist::Zilla::Dist::Builder config: is_trial: 0 version: 5.041 Telephony-Asterisk-AMI-0.006/MANIFEST0000644000175000017500000000033212637604230015113 0ustar cjmcjmChanges LICENSE MANIFEST META.json META.yml Makefile.PL README lib/Telephony/Asterisk/AMI.pm t/00-all_prereqs.t t/00-load.t t/10-ami.t t/20-ami-events.t t/Fake_Socket.pm xt/author/pod-coverage.t xt/author/pod-syntax.t Telephony-Asterisk-AMI-0.006/LICENSE0000644000175000017500000004370612637604230015003 0ustar cjmcjmThis software is copyright (c) 2015 by Christopher J. Madsen. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2015 by Christopher J. Madsen. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Suite 500, Boston, MA 02110-1335 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2015 by Christopher J. Madsen. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End Telephony-Asterisk-AMI-0.006/Changes0000644000175000017500000000113412637604230015256 0ustar cjmcjmRevision history for Telephony-Asterisk-AMI 0.006 2015-12-26 - No functional changes - Add tests for Event_Callback (20-ami-events.t) 0.005 2015-12-19 - No functional changes - Clarify docs for read_response method 0.004 2015-11-28 - No functional changes - Add tests (10-ami.t) 0.003 2015-11-14 - Add send_action and read_response methods - Fix docs for error method (disconnect can set it) 0.002 2015-11-07 - Validate Asterisk Call Manager header in connect method - Add disconnect method - In action method, check that the connection is open 0.001 2015-10-31 - Initial release Telephony-Asterisk-AMI-0.006/README0000644000175000017500000000204012637604230014640 0ustar cjmcjmTelephony-Asterisk-AMI version 0.006, released December 26, 2015 This module is a simple client for the Asterisk Manager Interface. It's better documented and less buggy than Asterisk::Manager, and has fewer prerequisites than Asterisk::AMI. If you need a more sophisticated client (especially for use in an event-driven program), try Asterisk::AMI. INSTALLATION To install this module, run the following commands: perl Makefile.PL make make test make install DEPENDENCIES Package Minimum Version --------------- --------------- perl 5.8.0 Carp IO::Socket::IP CHANGES Here's what's new in version 0.006 of Telephony-Asterisk-AMI: (See the file "Changes" for the full revision history.) - No functional changes - Add tests for Event_Callback (20-ami-events.t) COPYRIGHT AND LICENSE This software is copyright (c) 2015 by Christopher J. Madsen. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.