Ignore:
Timestamp:
2008-06-05T09:29:32+12:00 (16 years ago)
Author:
kjdon
Message:

plugin overhaul: plugins renamed to xxPlugin, and in some cases the names are made more sensible. They now use the new base plugins. Hopefully we have better code reuse. Some of the plugins still need work done as I didn't want to spend another month doing this before committing it. Alos, I haven't really tested anything yet...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/perllib/plugins/EmailPlugin.pm

    r15865 r15872  
    11###########################################################################
    22#
    3 # EMAILPlug.pm - a plugin for parsing email files
     3# EmailPlugin.pm - a plugin for parsing email files
    44#
    55# A component of the Greenstone digital library software
     
    2727
    2828
    29 # EMAILPlug
     29# EmailPlugin
    3030#
    3131# by Gordon Paynter ([email protected])
     
    6363
    6464# 12/05/02 Added usage datastructure - John Thompson
    65 package EMAILPlug;
     65package EmailPlugin;
    6666
    6767use strict;
     
    6969
    7070
    71 use SplitPlug;
     71use SplitTextFile;
    7272use unicode;  # gs conv functions
    7373use gsprintf 'gsprintf'; # translations
     
    7777
    7878sub BEGIN {
    79     @EMAILPlug::ISA = ('SplitPlug');
     79    @EmailPlugin::ISA = ('SplitTextFile');
    8080}
    8181
     
    8383my $arguments =
    8484    [ { 'name' => "process_exp",
    85     'desc' => "{BasPlug.process_exp}",
     85    'desc' => "{BasePlugin.process_exp}",
    8686    'type' => "regexp",
    8787    'reqd' => "no",
    8888    'deft' => &get_default_process_exp() },
    8989      { 'name' => "no_attachments",
    90     'desc' => "{EMAILPlug.no_attachments}",
     90    'desc' => "{EmailPlugin.no_attachments}",
    9191    'type' => "flag",
    9292    'reqd' => "no" },
    9393      { 'name' => "headers",
    94     'desc' => "{EMAILPlug.headers}",
     94    'desc' => "{EmailPlugin.headers}",
    9595    'type' => "flag",
    9696    'reqd' => "no" },
    9797      { 'name' => "split_exp",
    98     'desc' => "{EMAILPlug.split_exp}",
     98    'desc' => "{EmailPlugin.split_exp}",
    9999    'type' => "regexp",
    100100    'reqd' => "no",
     
    102102      ];
    103103
    104 my $options = { 'name'     => "EMAILPlug",
    105         'desc'     => "{EMAILPlug.desc}",
     104my $options = { 'name'     => "EmailPlugin",
     105        'desc'     => "{EmailPlugin.desc}",
    106106        'abstract' => "no",
    107107        'inherits' => "yes",
    108108        'args'     => $arguments };
    109109
    110 # Create a new EMAILPlug object with which to parse a file.
    111 # Accomplished by creating a new BasPlug and using bless to
    112 # turn it into an EMAILPlug.
     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.
    113113
    114114sub new {
     
    117117    push(@$pluginlist, $class);
    118118
    119     if(defined $arguments){ push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});}
    120     if(defined $options) { push(@{$hashArgOptLists->{"OptList"}},$options)};
    121 
    122     my $self = new SplitPlug($pluginlist, $inputargs, $hashArgOptLists);
     119    push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
     120    push(@{$hashArgOptLists->{"OptList"}},$options);
     121
     122    my $self = new SplitTextFile($pluginlist, $inputargs, $hashArgOptLists);
    123123
    124124    $self->{'assoc_filenames'} = {}; # to save attach names so we don't clobber
     
    166166
    167167
    168     print STDERR "<Processing n='$file' p='EMAILPlug'>\n" if ($gli);
    169 
    170     gsprintf($outhandle, "EMAILPlug: {common.processing} $file\n")
     168    print STDERR "<Processing n='$file' p='EmailPlugin'>\n" if ($gli);
     169
     170    gsprintf($outhandle, "EmailPlugin: {common.processing} $file\n")
    171171    if $self->{'verbosity'} > 1;
    172172
     
    524524        }
    525525    } else {
    526         print $outhandle "EMAILPlug: (warning) couldn't parse MIME boundary\n";
     526        print $outhandle "EmailPlugin: (warning) couldn't parse MIME boundary\n";
    527527    }
    528528    # parts start with "--$boundary"
     
    540540    # make sure it is only -- and whitespace
    541541    if ($last !~ /^\-\-\s*$/ms) {
    542         print $outhandle "EMAILPlug: (warning) last part of MIME message isn't empty\n";
     542        print $outhandle "EmailPlugin: (warning) last part of MIME message isn't empty\n";
    543543    }
    544544    foreach my $message_part (@message_parts) {
     
    579579        # or it was an empty message...
    580580        # do nothing...
    581         gsprintf($outhandle, "{BasPlug.empty_file} - empty body?\n");
     581        gsprintf($outhandle, "{BasePlugin.empty_file} - empty body?\n");
    582582        } else {
    583583        $text = $part_text;
     
    814814        }
    815815        open (SAVE, ">$tmpdir/$save_filename") ||
    816         warn "EMAILPlug: Can't save attachment as $tmpdir/$save_filename: $!";
     816        warn "EmailPlugin: Can't save attachment as $tmpdir/$save_filename: $!";
    817817        my $part_text = $message_part;
    818818        $part_text =~ s/(.*?)\r?\n\r?\n//s; # remove header
     
    834834#           &util::rm("$tmpdir/$save_filename");
    835835        my $outhandle=$self->{'outhandle'};
    836         print $outhandle "EMAILPlug: saving attachment \"$filename\"\n"; #
     836        print $outhandle "EmailPlugin: saving attachment \"$filename\"\n"; #
    837837       
    838838        # be nice if "download" was a translatable macro :(
     
    905905        # rfc2045 also allows binary, which we ignore (for now).
    906906        my $outhandle=$self->{'outhandle'};
    907         print $outhandle "EMAILPlug: unknown transfer encoding: $encoding\n";
     907        print $outhandle "EmailPlugin: unknown transfer encoding: $encoding\n";
    908908        return "";
    909909    }
     
    10671067      if ($badbytesfound==1) {
    10681068          # claims to be utf8, but it isn't!
    1069           print $outhandle "EMAILPlug: Headers claim utf-8 but bad bytes "
     1069          print $outhandle "EmailPlugin: Headers claim utf-8 but bad bytes "
    10701070          . "detected and removed.\n";
    10711071
     
    10921092      # 1252 has characters between 0x80 and 0x9f, 8859-1 doesn't
    10931093      if ($$textref =~ m/[\x80-\x9f]/) {
    1094       print $outhandle "EMAILPlug: Headers claim ISO charset but MS ";
     1094      print $outhandle "EmailPlugin: Headers claim ISO charset but MS ";
    10951095      print $outhandle "codepage 1252 detected.\n";
    10961096      $charset = "windows_1252";
     
    11061106      # characters out here if this causes problems...
    11071107      my $outhandle=$self->{'outhandle'};
    1108       print $outhandle "EMAILPlug: falling back to iso-8859-1\n";
     1108      print $outhandle "EmailPlugin: falling back to iso-8859-1\n";
    11091109      $$textref=&unicode::unicode2utf8(&unicode::convert2unicode("iso_8859_1",$textref));
    11101110
Note: See TracChangeset for help on using the changeset viewer.