| 1 | package MMS::Mail::Provider::UK02; | ||||||||||||||||||
| 2 | |||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 5 | |||||||||||||||||||
| 6 | 2 | ▶ | use base 'MMS::Mail::Provider'; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 7 | |||||||||||||||||||
| 8 | 2 | ▶ | use MIME::Entity; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 9 | 2 | ▶ | use MMS::Mail::Message::Parsed; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 10 | |||||||||||||||||||
| 11 | =head1 NAME | ||||||||||||||||||
| 12 | |||||||||||||||||||
| 13 | MMS::Mail::Provider::UK02 - This provides a class for parsing an MMS::Mail::Message object that has been sent via the UK 02 network. | ||||||||||||||||||
| 14 | |||||||||||||||||||
| 15 | =head1 VERSION | ||||||||||||||||||
| 16 | |||||||||||||||||||
| 17 | Version 0.08 | ||||||||||||||||||
| 18 | |||||||||||||||||||
| 19 | =cut | ||||||||||||||||||
| 20 | |||||||||||||||||||
| 21 | 2 | our $VERSION = '0.08'; | |||||||||||||||||
| 22 | |||||||||||||||||||
| 23 | =head1 SYNOPSIS | ||||||||||||||||||
| 24 | |||||||||||||||||||
| 25 | This class provides a parse method for parsing an MMS::Mail::Message object into an MMS::Mail::Message::Parsed object for MMS messages sent from the UK 02 network. | ||||||||||||||||||
| 26 | |||||||||||||||||||
| 27 | =head1 METHODS | ||||||||||||||||||
| 28 | |||||||||||||||||||
| 29 | The following are the top-level methods of the MMS::Mail::Parser::02 class. | ||||||||||||||||||
| 30 | |||||||||||||||||||
| 31 | =head2 Constructor | ||||||||||||||||||
| 32 | |||||||||||||||||||
| 33 | =over | ||||||||||||||||||
| 34 | |||||||||||||||||||
| 35 | =item C<new()> | ||||||||||||||||||
| 36 | |||||||||||||||||||
| 37 | Return a new MMS::Mail::Provider::02 object. | ||||||||||||||||||
| 38 | |||||||||||||||||||
| 39 | =back | ||||||||||||||||||
| 40 | |||||||||||||||||||
| 41 | =head2 Regular Methods | ||||||||||||||||||
| 42 | |||||||||||||||||||
| 43 | =over | ||||||||||||||||||
| 44 | |||||||||||||||||||
| 45 | =item C<parse> MMS::Mail::Message | ||||||||||||||||||
| 46 | |||||||||||||||||||
| 47 | The C<parse> method is called as an instance method. It parses the MMS::Mail::Message object and returns an MMS::Mail::Message::Parsed object. | ||||||||||||||||||
| 48 | |||||||||||||||||||
| 49 | =back | ||||||||||||||||||
| 50 | |||||||||||||||||||
| 51 | =head1 AUTHOR | ||||||||||||||||||
| 52 | |||||||||||||||||||
| 53 | Rob Lee, C<< <robl at robl.co.uk> >> | ||||||||||||||||||
| 54 | |||||||||||||||||||
| 55 | =head1 BUGS | ||||||||||||||||||
| 56 | |||||||||||||||||||
| 57 | Please report any bugs or feature requests to | ||||||||||||||||||
| 58 | C<bug-mms-mail-provider-uk02@rt.cpan.org>, or through the web interface at | ||||||||||||||||||
| 59 | L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MMS-Mail-Provider-UK02>. | ||||||||||||||||||
| 60 | I will be notified, and then you'll automatically be notified of progress on | ||||||||||||||||||
| 61 | your bug as I make changes. | ||||||||||||||||||
| 62 | |||||||||||||||||||
| 63 | =head1 NOTES | ||||||||||||||||||
| 64 | |||||||||||||||||||
| 65 | Please read the Perl artistic license ('perldoc perlartistic') : | ||||||||||||||||||
| 66 | |||||||||||||||||||
| 67 | 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED | ||||||||||||||||||
| 68 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES | ||||||||||||||||||
| 69 | OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||||||||||||||||||
| 70 | |||||||||||||||||||
| 71 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||||||
| 72 | |||||||||||||||||||
| 73 | Thanks to Sam for the sample message. | ||||||||||||||||||
| 74 | Thanks to Col M for the message format update and patch | ||||||||||||||||||
| 75 | |||||||||||||||||||
| 76 | As per usual this module is sprinkled with a little Deb magic. | ||||||||||||||||||
| 77 | |||||||||||||||||||
| 78 | =head1 COPYRIGHT & LICENSE | ||||||||||||||||||
| 79 | |||||||||||||||||||
| 80 | Copyright 2005 Rob Lee, all rights reserved. | ||||||||||||||||||
| 81 | |||||||||||||||||||
| 82 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||
| 83 | under the same terms as Perl itself. | ||||||||||||||||||
| 84 | |||||||||||||||||||
| 85 | =head1 SEE ALSO | ||||||||||||||||||
| 86 | |||||||||||||||||||
| 87 | L<MMS::Mail::Message>, L<MMS::Mail::Message::Parsed>, L<MMS::Mail::Provider> | ||||||||||||||||||
| 88 | |||||||||||||||||||
| 89 | =cut | ||||||||||||||||||
| 90 | |||||||||||||||||||
| 91 | 0 | ▶ | sub parse { | ||||||||||||||||
|
Subroutine
parse: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||
| 92 | |||||||||||||||||||
| 93 | 0 | my $self = shift; | |||||||||||||||||
| 94 | 0 | my $message = shift; | |||||||||||||||||
| 95 | |||||||||||||||||||
| 96 | 0 | ▶ | unless (defined $message) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 97 | 0 | return undef; | |||||||||||||||||
| 98 | } | ||||||||||||||||||
| 99 | |||||||||||||||||||
| 100 | 0 | my $skiptext = "You have received a Media Message"; | |||||||||||||||||
| 101 | |||||||||||||||||||
| 102 | 0 | my $parsed = new MMS::Mail::Message::Parsed(message=>$message); | |||||||||||||||||
| 103 | |||||||||||||||||||
| 104 | 0 | $parsed->header_subject($message->header_subject); | |||||||||||||||||
| 105 | |||||||||||||||||||
| 106 | 0 | foreach my $element (@{$parsed->attachments}) { | |||||||||||||||||
| 107 | 0 | ▶ | if ($element->mime_type eq 'text/plain') { | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 108 | 0 | ▶ | if ($element->bodyhandle->as_string !~ /$skiptext/m) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 109 | 0 | $parsed->body_text($element->bodyhandle->as_string); | |||||||||||||||||
| 110 | } | ||||||||||||||||||
| 111 | } elsif ($element->mime_type =~ /jpeg$/) { | ||||||||||||||||||
| 112 | 0 | $parsed->add_image($element); | |||||||||||||||||
| 113 | } elsif ($element->mime_type =~ /^video/) { | ||||||||||||||||||
| 114 | 0 | $parsed->add_video($element); | |||||||||||||||||
| 115 | } | ||||||||||||||||||
| 116 | } | ||||||||||||||||||
| 117 | # Set mobile number property to a VALID number | ||||||||||||||||||
| 118 | 0 | ▶ | if ($parsed->header_from =~ /<(.*)>/) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 119 | 0 | $parsed->phone_number($self->retrieve_phone_number($1)); | |||||||||||||||||
| 120 | } | ||||||||||||||||||
| 121 | 0 | return $parsed; | |||||||||||||||||
| 122 | |||||||||||||||||||
| 123 | } | ||||||||||||||||||
| 124 | |||||||||||||||||||
| 125 | |||||||||||||||||||
| 126 | 2 | 1; # End of MMS::Mail::Provider::UK02 | |||||||||||||||||