line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MMS::Mail::Provider::UK3; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
19668
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use base 'MMS::Mail::Provider'; |
|
1
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
828
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6365
|
use MMS::Mail::Message::Parsed; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
9
|
1
|
|
|
1
|
|
962
|
use HTML::TableExtract; |
|
1
|
|
|
|
|
19958
|
|
|
1
|
|
|
|
|
8
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
MMS::Mail::Provider::UK3 - This provides a class for parsing an MMS::Mail::Message object that has been sent via the UK 3 network. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 VERSION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Version 0.02 |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
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 3 network. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 METHODS |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
The following are the top-level methods of the MMS::Mail::Parser::UK3 class. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 Constructor |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=over |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=item C |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Return a new MMS::Mail::Provider::UK3 object. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=back |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 Regular Methods |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=over |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=item C MMS::Mail::Message |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
The C 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<< >> |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 BUGS |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
58
|
|
|
|
|
|
|
C, or through the web interface at |
59
|
|
|
|
|
|
|
L. |
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 SUPPORT |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
perldoc MMS::Mail::Provider::UK3 |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
You can also look for information at: |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=over 4 |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
L |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=item * CPAN Ratings |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
L |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
L |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=item * Search CPAN |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
L |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=back |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Copyright 2006 Rob Lee, all rights reserved. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
98
|
|
|
|
|
|
|
under the same terms as Perl itself. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=cut |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub parse { |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
105
|
0
|
|
|
|
|
|
my $message = shift; |
106
|
|
|
|
|
|
|
|
107
|
0
|
0
|
|
|
|
|
unless (defined $message) { |
108
|
0
|
|
|
|
|
|
return undef; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
my $parsed = new MMS::Mail::Message::Parsed(message=>$message); |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
my $htmltext=undef; |
114
|
0
|
|
|
|
|
|
foreach my $element (@{$parsed->attachments}) { |
|
0
|
|
|
|
|
|
|
115
|
0
|
0
|
|
|
|
|
if ($element->mime_type eq 'text/html') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
$htmltext = $element->bodyhandle->as_string; |
117
|
|
|
|
|
|
|
} elsif ($element->mime_type =~ /jpeg$/) { |
118
|
0
|
|
|
|
|
|
my $header = $element->head; |
119
|
0
|
0
|
|
|
|
|
if ($header->recommended_filename() !~ /^images\//) { |
120
|
0
|
|
|
|
|
|
$parsed->add_image($element); |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
} elsif ($element->mime_type =~ /^video/) { |
123
|
0
|
|
|
|
|
|
$parsed->add_video($element); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
0
|
0
|
|
|
|
|
unless (defined $htmltext) { |
128
|
0
|
|
|
|
|
|
return undef; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
0
|
|
|
|
|
|
my $te1 = new HTML::TableExtract( depth => 2, count => 2 ); |
132
|
0
|
|
|
|
|
|
$te1->parse($htmltext); |
133
|
0
|
|
|
|
|
|
foreach my $ts1 ($te1->table_states) { |
134
|
0
|
|
|
|
|
|
foreach my $row1 ($ts1->rows) { |
135
|
0
|
|
|
|
|
|
foreach my $ele (@$row1) { |
136
|
0
|
0
|
0
|
|
|
|
if ((defined $ele) && ($ele ne '')) { |
137
|
0
|
|
|
|
|
|
$parsed->header_subject($ele); |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
0
|
|
|
|
|
|
my $te2 = new HTML::TableExtract( depth => 3, count => 2 ); |
144
|
0
|
|
|
|
|
|
$te2->parse($htmltext); |
145
|
0
|
|
|
|
|
|
my $text; |
146
|
0
|
|
|
|
|
|
foreach my $ts2 ($te2->table_states) { |
147
|
0
|
|
|
|
|
|
foreach my $row2 ($ts2->rows) { |
148
|
0
|
|
|
|
|
|
$text = join('\n', @$row2); |
149
|
|
|
|
|
|
|
} |
150
|
0
|
0
|
0
|
|
|
|
if ((defined $text) && $text ne "") { |
151
|
0
|
|
|
|
|
|
$parsed->body_text($text); |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
# Set mobile number property to a VALID number |
156
|
0
|
0
|
|
|
|
|
if ($parsed->header_from =~ /<(.+)\/(.+)>/) { |
157
|
0
|
|
|
|
|
|
$parsed->phone_number('00'.$1); |
158
|
0
|
|
|
|
|
|
return $parsed; |
159
|
|
|
|
|
|
|
} else { |
160
|
0
|
|
|
|
|
|
return undef; |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
1; # End of MMS::Mail::Provider::UK3 |