Changeset 15872 for gsdl/trunk/perllib/plugins/EmailPlugin.pm
- Timestamp:
- 2008-06-05T09:29:32+12:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/perllib/plugins/EmailPlugin.pm
r15865 r15872 1 1 ########################################################################### 2 2 # 3 # E MAILPlug.pm - a plugin for parsing email files3 # EmailPlugin.pm - a plugin for parsing email files 4 4 # 5 5 # A component of the Greenstone digital library software … … 27 27 28 28 29 # E MAILPlug29 # EmailPlugin 30 30 # 31 31 # by Gordon Paynter ([email protected]) … … 63 63 64 64 # 12/05/02 Added usage datastructure - John Thompson 65 package E MAILPlug;65 package EmailPlugin; 66 66 67 67 use strict; … … 69 69 70 70 71 use Split Plug;71 use SplitTextFile; 72 72 use unicode; # gs conv functions 73 73 use gsprintf 'gsprintf'; # translations … … 77 77 78 78 sub BEGIN { 79 @E MAILPlug::ISA = ('SplitPlug');79 @EmailPlugin::ISA = ('SplitTextFile'); 80 80 } 81 81 … … 83 83 my $arguments = 84 84 [ { 'name' => "process_exp", 85 'desc' => "{Bas Plug.process_exp}",85 'desc' => "{BasePlugin.process_exp}", 86 86 'type' => "regexp", 87 87 'reqd' => "no", 88 88 'deft' => &get_default_process_exp() }, 89 89 { 'name' => "no_attachments", 90 'desc' => "{E MAILPlug.no_attachments}",90 'desc' => "{EmailPlugin.no_attachments}", 91 91 'type' => "flag", 92 92 'reqd' => "no" }, 93 93 { 'name' => "headers", 94 'desc' => "{E MAILPlug.headers}",94 'desc' => "{EmailPlugin.headers}", 95 95 'type' => "flag", 96 96 'reqd' => "no" }, 97 97 { 'name' => "split_exp", 98 'desc' => "{E MAILPlug.split_exp}",98 'desc' => "{EmailPlugin.split_exp}", 99 99 'type' => "regexp", 100 100 'reqd' => "no", … … 102 102 ]; 103 103 104 my $options = { 'name' => "E MAILPlug",105 'desc' => "{E MAILPlug.desc}",104 my $options = { 'name' => "EmailPlugin", 105 'desc' => "{EmailPlugin.desc}", 106 106 'abstract' => "no", 107 107 'inherits' => "yes", 108 108 'args' => $arguments }; 109 109 110 # Create a new E MAILPlugobject with which to parse a file.111 # Accomplished by creating a new Bas Plugand using bless to112 # turn it into an E MAILPlug.110 # Create a new EmailPlugin object with which to parse a file. 111 # Accomplished by creating a new BasePlugin and using bless to 112 # turn it into an EmailPlugin. 113 113 114 114 sub new { … … 117 117 push(@$pluginlist, $class); 118 118 119 if(defined $arguments){ push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});}120 if(defined $options) { push(@{$hashArgOptLists->{"OptList"}},$options)};121 122 my $self = new Split Plug($pluginlist, $inputargs, $hashArgOptLists);119 push(@{$hashArgOptLists->{"ArgList"}},@{$arguments}); 120 push(@{$hashArgOptLists->{"OptList"}},$options); 121 122 my $self = new SplitTextFile($pluginlist, $inputargs, $hashArgOptLists); 123 123 124 124 $self->{'assoc_filenames'} = {}; # to save attach names so we don't clobber … … 166 166 167 167 168 print STDERR "<Processing n='$file' p='E MAILPlug'>\n" if ($gli);169 170 gsprintf($outhandle, "E MAILPlug: {common.processing} $file\n")168 print STDERR "<Processing n='$file' p='EmailPlugin'>\n" if ($gli); 169 170 gsprintf($outhandle, "EmailPlugin: {common.processing} $file\n") 171 171 if $self->{'verbosity'} > 1; 172 172 … … 524 524 } 525 525 } else { 526 print $outhandle "E MAILPlug: (warning) couldn't parse MIME boundary\n";526 print $outhandle "EmailPlugin: (warning) couldn't parse MIME boundary\n"; 527 527 } 528 528 # parts start with "--$boundary" … … 540 540 # make sure it is only -- and whitespace 541 541 if ($last !~ /^\-\-\s*$/ms) { 542 print $outhandle "E MAILPlug: (warning) last part of MIME message isn't empty\n";542 print $outhandle "EmailPlugin: (warning) last part of MIME message isn't empty\n"; 543 543 } 544 544 foreach my $message_part (@message_parts) { … … 579 579 # or it was an empty message... 580 580 # do nothing... 581 gsprintf($outhandle, "{Bas Plug.empty_file} - empty body?\n");581 gsprintf($outhandle, "{BasePlugin.empty_file} - empty body?\n"); 582 582 } else { 583 583 $text = $part_text; … … 814 814 } 815 815 open (SAVE, ">$tmpdir/$save_filename") || 816 warn "E MAILPlug: Can't save attachment as $tmpdir/$save_filename: $!";816 warn "EmailPlugin: Can't save attachment as $tmpdir/$save_filename: $!"; 817 817 my $part_text = $message_part; 818 818 $part_text =~ s/(.*?)\r?\n\r?\n//s; # remove header … … 834 834 # &util::rm("$tmpdir/$save_filename"); 835 835 my $outhandle=$self->{'outhandle'}; 836 print $outhandle "E MAILPlug: saving attachment \"$filename\"\n"; #836 print $outhandle "EmailPlugin: saving attachment \"$filename\"\n"; # 837 837 838 838 # be nice if "download" was a translatable macro :( … … 905 905 # rfc2045 also allows binary, which we ignore (for now). 906 906 my $outhandle=$self->{'outhandle'}; 907 print $outhandle "E MAILPlug: unknown transfer encoding: $encoding\n";907 print $outhandle "EmailPlugin: unknown transfer encoding: $encoding\n"; 908 908 return ""; 909 909 } … … 1067 1067 if ($badbytesfound==1) { 1068 1068 # claims to be utf8, but it isn't! 1069 print $outhandle "E MAILPlug: Headers claim utf-8 but bad bytes "1069 print $outhandle "EmailPlugin: Headers claim utf-8 but bad bytes " 1070 1070 . "detected and removed.\n"; 1071 1071 … … 1092 1092 # 1252 has characters between 0x80 and 0x9f, 8859-1 doesn't 1093 1093 if ($$textref =~ m/[\x80-\x9f]/) { 1094 print $outhandle "E MAILPlug: Headers claim ISO charset but MS ";1094 print $outhandle "EmailPlugin: Headers claim ISO charset but MS "; 1095 1095 print $outhandle "codepage 1252 detected.\n"; 1096 1096 $charset = "windows_1252"; … … 1106 1106 # characters out here if this causes problems... 1107 1107 my $outhandle=$self->{'outhandle'}; 1108 print $outhandle "E MAILPlug: falling back to iso-8859-1\n";1108 print $outhandle "EmailPlugin: falling back to iso-8859-1\n"; 1109 1109 $$textref=&unicode::unicode2utf8(&unicode::convert2unicode("iso_8859_1",$textref)); 1110 1110
Note:
See TracChangeset
for help on using the changeset viewer.