| 1 | # | ||
| 2 | # $Id: o2sms.pm 352 2008-11-27 16:16:41Z mackers $ | ||
| 3 | |||
| 4 | package WWW::SMS::IE::o2sms; | ||
| 5 | |||
| 6 | =head1 NAME | ||
| 7 | |||
| 8 | WWW::SMS::IE::o2sms - A module to send SMS messages using the website of | ||
| 9 | O2 Ireland | ||
| 10 | |||
| 11 | =head1 SYNOPSIS | ||
| 12 | |||
| 13 | require WWW::SMS::IE::iesms; | ||
| 14 | require WWW::SMS::IE::o2sms; | ||
| 15 | |||
| 16 | my $carrier = new WWW::SMS::IE::o2sms; | ||
| 17 | |||
| 18 | if ($carrier->login('o2_user', '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::o2sms> is a class to send SMS messages via the command line | ||
| 31 | using the website of O2 Ireland -- http://www.o2.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::o2sms::ISA = qw{WWW::SMS::IE::iesms}; | ||
| 43 | |||
| 44 | use constant LOGIN_START_STEP => 0; | ||
| 45 | use constant LOGIN_END_STEP => 6; | ||
| 46 | use constant SEND_START_STEP => 7; | ||
| 47 | use constant SEND_END_STEP => undef; | ||
| 48 | use constant REMAINING_MESSAGES_MATCH => 1; | ||
| 49 | use constant ACTION_FILE => "o2sms.action"; | ||
| 50 | use constant SIMULATED_DELAY_MIN => 0; | ||
| 51 | use constant SIMULATED_DELAY_MAX => 0; | ||
| 52 | use constant SIMULATED_DELAY_PERCHAR => 0; | ||
| 53 | |||
| 54 | sub _init | ||
| 55 | { | ||
| 56 | my $self = shift; | ||
| 57 | |||
| 58 | $self->_log_debug("creating new instance of o2sms carrier"); | ||
| 59 | |||
| 60 | $self->_login_start_step(LOGIN_START_STEP); | ||
| 61 | $self->_login_end_step(LOGIN_END_STEP); | ||
| 62 | $self->_send_start_step(SEND_START_STEP); | ||
| 63 | $self->_send_end_step(SEND_END_STEP); | ||
| 64 | $self->_remaining_messages_match(REMAINING_MESSAGES_MATCH); | ||
| 65 | $self->_action_file(ACTION_FILE); | ||
| 66 | $self->_simulated_delay_max(SIMULATED_DELAY_MAX); | ||
| 67 | $self->_simulated_delay_min(SIMULATED_DELAY_MIN); | ||
| 68 | $self->_simulated_delay_perchar(SIMULATED_DELAY_PERCHAR); | ||
| 69 | |||
| 70 | $self->full_name("O2 Ireland"); | ||
| 71 | $self->domain_name("o2.ie"); | ||
| 72 | |||
| 73 | if ($self->is_win32()) | ||
| 74 | { | ||
| 75 | $self->config_dir($ENV{TMP}); | ||
| 76 | $self->config_file($self->_get_home_dir() . "o2sms.ini"); | ||
| 77 | $self->message_file("o2sms_lastmsg.txt"); | ||
| 78 | $self->history_file("o2sms_history.txt"); | ||
| 79 | $self->cookie_file("o2sms.cookie"); | ||
| 80 | $self->action_state_file("o2sms.state"); | ||
| 81 | } | ||
| 82 | else | ||
| 83 | { | ||
| 84 | $self->config_dir($self->_get_home_dir() . "/.o2sms/"); | ||
| 85 | $self->config_file("config"); | ||
| 86 | $self->message_file("lastmsg"); | ||
| 87 | $self->history_file("history"); | ||
| 88 | $self->cookie_file(".cookie"); | ||
| 89 | $self->action_state_file(".state"); | ||
| 90 | } | ||
| 91 | } | ||
| 92 | |||
| 93 | sub _format_number | ||
| 94 | { | ||
| 95 | my ($self, $number) = @_; | ||
| 96 | |||
| 97 | $number =~ s/^\+//; | ||
| 98 | |||
| 99 | return $number; | ||
| 100 | } | ||
| 101 | |||
| 102 | sub is_o2 | ||
| 103 | { | ||
| 104 | return 1; | ||
| 105 | } | ||
| 106 | |||
| 107 | =head1 DISCLAIMER | ||
| 108 | |||
| 109 | The author accepts no responsibility nor liability for your use of this | ||
| 110 | software. Please read the terms and conditions of the website of your mobile | ||
| 111 | provider before using the program. | ||
| 112 | |||
| 113 | =head1 SEE ALSO | ||
| 114 | |||
| 115 | L<WWW::SMS::IE::iesms>, | ||
| 116 | L<WWW::SMS::IE::vodasms>, | ||
| 117 | L<WWW::SMS::IE::meteorsms> | ||
| 118 | |||
| 119 | L<http://www.mackers.com/projects/o2sms/> | ||
| 120 | |||
| 121 | =head1 AUTHOR | ||
| 122 | |||
| 123 | David McNamara (me.at.mackers.dot.com) | ||
| 124 | |||
| 125 | =head1 COPYRIGHT | ||
| 126 | |||
| 127 | Copyright 2000-2006 David McNamara | ||
| 128 | |||
| 129 | This program is free software; you can redistribute it and/or modify it under | ||
| 130 | the same terms as Perl itself. | ||
| 131 | |||
| 132 | =cut | ||
| 133 | |||
| 134 | 1; |