threesms.pm untested

filter: Statementstmt 0.0% 0 / 78 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 18 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 105 CC 3 SCAR 10.3
CC
3
Cov
0%
_init
6.0
_is_valid_number
6.0
_format_number
2.0
CRAP 2.8
1 #
2 # $Id$
3  
4 package WWW::SMS::IE::threesms;
5  
6 =head1 NAME
7  
8 WWW::SMS::IE::threesms - A module to send SMS messages using the website of
9 Three Ireland
10  
11 =head1 SYNOPSIS
12  
13 require WWW::SMS::IE::iesms;
14 require WWW::SMS::IE::threesms;
15  
16 my $carrier = new WWW::SMS::IE::threesms;
17  
18 if ($carrier->login('0831234567', 'password'))
19 {
20 my $retval = $carrier->send('+353865551234', 'Hello World!');
21  
22 if (!$retval)
23 {
24 print $carrier->error() . "\n";
25 }
26 }
27  
28 =head1 DESCRIPTION
29  
30 L<WWW::SMS::IE::threesms> is a class to send SMS messages via the command line
31 using the website of Three Ireland -- http://www.three.ie/
32  
33 For more information see L<WWW::SMS::IE::iesms>
34  
35 =cut
36  
37 use strict;
38 use warnings;
39 use vars qw( $VERSION );
40 $VERSION = sprintf("0.%02d", q$Revision: 352 $ =~ /(\d+)/);
41  
42 @WWW::SMS::IE::threesms::ISA = qw{WWW::SMS::IE::iesms};
43  
44 use constant LOGIN_START_STEP => 0;
45 use constant LOGIN_END_STEP => 2;
46 use constant SEND_START_STEP => 3;
47 use constant SEND_END_STEP => undef;
48 use constant REMAINING_MESSAGES_MATCH => 1;
49 use constant ACTION_FILE => "threesms.action";
50 use constant SIMULATED_DELAY_MIN => 0;
51 use constant SIMULATED_DELAY_MAX => 0;
52 use constant SIMULATED_DELAY_PERCHAR => 0;
53 use constant MINIMUM_MESSAGE_LENGTH => 1;
54  
55 sub _init
56 {
57 my $self = shift;
58  
59 $self->_log_debug("creating new instance of three carrier");
60  
61 $self->_login_start_step(LOGIN_START_STEP);
62 $self->_login_end_step(LOGIN_END_STEP);
63 $self->_send_start_step(SEND_START_STEP);
64 $self->_send_end_step(SEND_END_STEP);
65 $self->_remaining_messages_match(REMAINING_MESSAGES_MATCH);
66 $self->_action_file(ACTION_FILE);
67 $self->_simulated_delay_max(SIMULATED_DELAY_MAX);
68 $self->_simulated_delay_min(SIMULATED_DELAY_MIN);
69 $self->_simulated_delay_perchar(SIMULATED_DELAY_PERCHAR);
70
71 $self->full_name("Three Ireland");
72 $self->domain_name("three.ie");
73  
74 if ($self->is_win32())
75 {
76 $self->config_dir($ENV{TMP});
77 $self->config_file($self->_get_home_dir() . "threesms.ini");
78 $self->message_file("threesms_lastmsg.txt");
79 $self->history_file("threesms_history.txt");
80 $self->cookie_file("threesms.cookie");
81 $self->action_state_file("threesms.state");
82 }
83 else
84 {
85 $self->config_dir($self->_get_home_dir() . "/.threesms/");
86 $self->config_file("config");
87 $self->message_file("lastmsg");
88 $self->history_file("history");
89 $self->cookie_file(".cookie");
90 $self->action_state_file(".state");
91 }
92 }
93  
94 sub _format_number
95 {
96 my ($self, $number) = @_;
97  
98 $number =~ s/^0/353/;
99 $number =~ s/^\+//;
100  
101 return $number;
102 }
103  
104 sub _is_valid_number
105 {
106 my ($self, $number) = @_;
107  
108 if ($number !~ /^\+353/)
109 {
110 $self->validate_number_error("Three webtexts can only be sent to Irish mobile numbers");
111 return 0;
112 }
113  
114 return 1;
115 }
116  
117 sub min_length
118 {
119 return MINIMUM_MESSAGE_LENGTH;
120 }
121  
122 sub is_three
123 {
124 return 1;
125 }
126  
127 =head1 DISCLAIMER
128  
129 The author accepts no responsibility nor liability for your use of this
130 software. Please read the terms and conditions of the website of your mobile
131 provider before using the program.
132  
133 =head1 SEE ALSO
134  
135 L<WWW::SMS::IE::iesms>,
136 L<WWW::SMS::IE::vodasms>,
137 L<WWW::SMS::IE::meteorsms>
138  
139 L<http://www.mackers.com/projects/o2sms/>
140  
141 =head1 AUTHOR
142  
143 David McNamara (me.at.mackers.dot.com)
144  
145 =head1 COPYRIGHT
146  
147 Copyright 2000-2006 David McNamara
148  
149 This program is free software; you can redistribute it and/or modify it under
150 the same terms as Perl itself.
151  
152 =cut
153  
154 1;