File Coverage

blib/lib/Polycom/App/URI.pm
Criterion Covered Total %
statement 24 26 92.3
branch 3 6 50.0
condition n/a
subroutine 5 5 100.0
pod 2 2 100.0
total 34 39 87.1


line stmt bran cond sub pod time code
1             package Polycom::App::URI;
2 1     1   22756 use strict;
  1         2  
  1         36  
3 1     1   5 use warnings;
  1         2  
  1         30  
4 1     1   5 use Exporter 'import';
  1         6  
  1         326  
5              
6             our @EXPORT_OK = qw(a softkeys);
7             our $VERSION = 0.01;
8              
9             ###################
10             # Exported Subroutines
11             ###################
12             sub a
13             {
14 1     1 1 1253 my ($action, $content) = @_;
15 1         6 return qq($content);
16             }
17             sub softkeys
18             {
19 1     1 1 434 my @items = @_;
20 1         2 my @xml;
21              
22 1         2 my $nextIndex = 1;
23 1         2 foreach my $item (@items)
24             {
25 2         3 my $action = $item->{action};
26              
27             # The "action" parameter is mandatory, but index will be generated if missing,
28             # and leaving "label" blank will instruct the phone to auto-generate a label.
29 2 50       6 if (defined $action)
30             {
31 2         4 my $label = $item->{label};
32 2 50       6 if (!defined $label)
33             {
34 0         0 $label = '';
35             }
36              
37 2         3 my $index = $item->{index};
38 2 50       5 if (!defined $index)
39             {
40 0         0 $index = $nextIndex;
41             }
42 2         2 $nextIndex = $index + 1;
43              
44 2         8 push @xml, qq();
45             }
46             }
47              
48 1         7 return join '', @xml;
49             }
50              
51              
52             =head1 NAME
53              
54             Polycom::App::URI - Module for working with internal URIs used for softkeys and hyperlinks in web applications for Polycom's SoundPoint IP and VVX series VoIP phones
55              
56             =head1 SYNOPSIS
57              
58             use Polycom::App::URI qw(softkeys);
59             use Polycom::App::Push;
60              
61             my $phone = Polycom::App::Push->new(address => "172.23.8.100", username => "Bob", password => "1234");
62              
63             # Send a message to a Polycom phone that provides custom soft keys using the softkeys() subroutine
64             my $message =
65             '

Fire drill at 2:00pm!

'
66             . softkeys(
67             {label => 'Dir', action => 'Key:Directory'},
68             {label => "Exit", action => 'SoftKey:Exit'})
69             . '';
70              
71             $phone->push_message({priority => 'critical', data => $message});
72              
73             =head1 DESCRIPTION
74              
75             The C module is for writing web applications for Polycom's SoundPoint IP and VVX series VoIP phones. It provides facilities for generating XHTML pages for the microbrowser that include custom soft key definitions and hyperlinks that execute phone features such as dialing numbers or accessing the contact directory.
76              
77             =head1 SUBROUTINES
78              
79              
80             =head2 a
81              
82             use Polycom::App::URI qw(a);
83              
84             # Prints 'View the phonebook'
85             print a('Key:Directory', 'View the phonebook');
86              
87             This subroutine can be used when generating dynamic XHTML pages for the microbrowser on SoundPoint IP phones to generate a hyperlink with the specified URI and caption. The first argument is the internal URI, and the second argument is the caption.
88              
89             =head2 softkeys
90              
91             use Polycom::App::URI qw(softkeys);
92              
93             # Prints '
94             # '
95             print softkeys(
96             {index => 1, label => 'Dir', action => 'Key:Directory'},
97             {index => 2, label => "Exit", action => 'SoftKey:Exit'});
98              
99             This subroutine can be used when generating dynamic XHTML pages for the microbrowser on SoundPoint IP phones to place custom soft keys along the bottom of the screen. For VVX series IP phones, you should use the
100              
101             The following parameters are supported:
102              
103             index - the index (1 to 8), relative to the left side of the screen of the soft key.
104             label - the label (1 to 9 characters) to display on the soft key.
105             action - a URI to execute when the user presses the soft key. See the developer's guide for a list of supported URIs.
106              
107             The C parameter is the only mandatory parameter. If no C
108              
109             print softkeys({action => 'Key:Directory'}, {action => 'SoftKey:Exit'});
110              
111             =head1 SEE ALSO
112              
113             I - L
114              
115             C - A module for sending push requests to Polycom VoIP phones.
116              
117             =head1 AUTHOR
118              
119             Zachary Blair, Ezblair@cpan.orgE
120              
121             =head1 COPYRIGHT AND LICENSE
122              
123             Copyright (C) 2012 by Zachary Blair
124              
125             This library is free software; you can redistribute it and/or modify
126             it under the same terms as Perl itself, either Perl version 5.8.8 or,
127             at your option, any later version of Perl 5 you may have available.
128              
129             =cut
130              
131             'Together. Great things happen.';