/[mws]/trunk/MWS.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/MWS.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 25 by dpavlin, Sat May 8 16:06:58 2004 UTC revision 41 by dpavlin, Mon May 10 20:26:17 2004 UTC
# Line 4  package MWS; Line 4  package MWS;
4    
5  use strict;  use strict;
6  use warnings;  use warnings;
 use Carp;  
7    
8    use lib '.';
9    
10    use Carp;
11  use Mail::Box::Manager;  use Mail::Box::Manager;
12  use Config::IniFiles;  use Config::IniFiles;
13  use POSIX qw(strftime);  use POSIX qw(strftime);
# Line 16  use Date::Parse; Line 18  use Date::Parse;
18  use POSIX qw(strftime);  use POSIX qw(strftime);
19  use MIME::Base64;  use MIME::Base64;
20    
 #use MWS_plucene;  
 use MWS_swish;  
   
 require Exporter;  
   
 our @ISA = qw(Exporter);  
   
 our %EXPORT_TAGS = ();  
 our @EXPORT_OK;  
 our @EXPORT;  
   
21  our $VERSION = '1.00';  our $VERSION = '1.00';
22    
23  my $folder;     # placeholder for folders  my $folder;     # placeholder for folders
24    
25  my $debug = 2;  my $debug = 1;
26    
27  sub new {  sub new {
28          my $class = shift;          my $class = shift;
29          my $self = {};          my $self = {@_};
30          bless($self, $class);          bless($self, $class);
31    
         my $config_file = shift || die "need index file";  
32    
33          $self->{config} = new Config::IniFiles( -file => $config_file );          my $config_name = $self->{config_file} || croak "need config_file";
34            $config_name =~ s/\.conf.*$//;
35            $self->{config_name} = $config_name;
36    
37          my $index_file = $self->{config}->val('global', 'index') || croak "can't find [index] section in config file with path of index";          $self->{config} = new Config::IniFiles( -file => $self->{config_file} );
38    
39            my $index_dir = $self->{config}->val('global', 'index') || croak "can't find [index] section in config file with path of index";
40    
41          $self->{mgr} = Mail::Box::Manager->new(access => 'r');          $self->{mgr} = Mail::Box::Manager->new(access => 'r');
42          $self->{index_file} = $index_file;          $self->{index_dir} = $index_dir;
43    
44          # placeholder for opened folders          # placeholder for opened folders
45          $self->{folder} = {};          $self->{folder} = {};
# Line 112  sub fmtdate { Line 106  sub fmtdate {
106                  push @out, sprintf($f, $v);                  push @out, sprintf($f, $v);
107          }          }
108    
109  print STDERR "fmtdate: ",join('|',@out),"\n";          print STDERR "fmtdate: ",join('|',@out),"\n" if ($debug == 2);
110    
111          return (wantarray ? @out : join("-",@out));          return (wantarray ? @out : join("-",@out));
112  }  }
# Line 331  sub plain_text_body { Line 325  sub plain_text_body {
325          }          }
326    
327          if (! $body) {          if (! $body) {
328                  $body = "[body of this message not found]\n" if ($debug == 2);                  $body = "[plain/text body not found]" if ($debug == 2);
329                  $body .= $message->decoded->string;                  print STDERR "plain/text body not found\n" if ($debug);
330                    return;
331          }          }
332    
333          # reformat with Text::Autoformat          # reformat with Text::Autoformat
334          my $wrap = $self->{wrap_margin};          my $wrap = $self->{wrap_margin};
335          if ($wrap && $body && $body =~ m/^.{$wrap}..*$/m) {          if ($wrap && $body && $body =~ m/^.{$wrap}..*$/m) {
336                  $body = autoformat($body, {right=>$wrap, all=>1});                  $body = autoformat($body, {right=>$wrap, all=>1});
                 print "reformatted [$wrap]:\n$body\n" if ($debug == 2);  
337                  $body .="\n[reformated using autoformat, margin at $wrap]" if ($debug == 2);                  $body .="\n[reformated using autoformat, margin at $wrap]" if ($debug == 2);
338          }          }
339    

Legend:
Removed from v.25  
changed lines
  Added in v.41

  ViewVC Help
Powered by ViewVC 1.1.26