42 |
|
|
43 |
$self->{config} = new Config::IniFiles( -file => $config_file ); |
$self->{config} = new Config::IniFiles( -file => $config_file ); |
44 |
|
|
45 |
my $index_file = $self->{config}->val('global', 'index') || croak "can't find [index] section in config file with path of index"; |
$self->{config_file} = $config_file; |
46 |
|
$config_file =~ s/\.conf.*$//; |
47 |
|
$self->{config_name} = $config_file; |
48 |
|
|
49 |
|
my $index_dir = $self->{config}->val('global', 'index') || croak "can't find [index] section in config file with path of index"; |
50 |
|
|
51 |
$self->{mgr} = Mail::Box::Manager->new(access => 'r'); |
$self->{mgr} = Mail::Box::Manager->new(access => 'r'); |
52 |
$self->{index_file} = $index_file; |
$self->{index_dir} = $index_dir; |
53 |
|
|
54 |
# placeholder for opened folders |
# placeholder for opened folders |
55 |
$self->{folder} = {}; |
$self->{folder} = {}; |
70 |
$v = join('',sort split(/\s+/,$v)); |
$v = join('',sort split(/\s+/,$v)); |
71 |
$v =~ s/\W+//g; |
$v =~ s/\W+//g; |
72 |
|
|
73 |
return $v; |
return lc($v); |
74 |
} |
} |
75 |
|
|
76 |
# reset tables for search results |
# reset tables for search results |
226 |
|
|
227 |
$self->{'curr_result'} = 0; |
$self->{'curr_result'} = 0; |
228 |
|
|
229 |
|
$self->reset_counters; |
230 |
|
|
231 |
print STDERR "$results results\n" if ($debug == 2); |
print STDERR "$results results\n" if ($debug == 2); |
232 |
|
|
233 |
return $results || 'error'; |
return $results || 'error'; |
334 |
} |
} |
335 |
} |
} |
336 |
|
|
337 |
|
if (! $body) { |
338 |
|
$body = "[plain/text body not found]" if ($debug == 2); |
339 |
|
print STDERR "plain/text body not found\n" if ($debug); |
340 |
|
return; |
341 |
|
} |
342 |
|
|
343 |
# reformat with Text::Autoformat |
# reformat with Text::Autoformat |
344 |
my $wrap = $self->{wrap_margin}; |
my $wrap = $self->{wrap_margin}; |
345 |
if ($wrap && $body && $body =~ m/^.{$wrap}..*$/m) { |
if ($wrap && $body && $body =~ m/^.{$wrap}..*$/m) { |
|
$body =~ s/[\r\n]/\n/gs; |
|
346 |
$body = autoformat($body, {right=>$wrap, all=>1}); |
$body = autoformat($body, {right=>$wrap, all=>1}); |
347 |
$body .="\n[reformated using autoformat, margin at $wrap]" if ($debug == 2); |
$body .="\n[reformated using autoformat, margin at $wrap]" if ($debug == 2); |
348 |
} |
} |
386 |
print STDERR "$id stored in cache\n" if ($debug == 2); |
print STDERR "$id stored in cache\n" if ($debug == 2); |
387 |
} else { |
} else { |
388 |
print STDERR "fetch_result_by_id($id) in cache\n" if ($debug == 2); |
print STDERR "fetch_result_by_id($id) in cache\n" if ($debug == 2); |
389 |
|
foreach my $p (qw(from to cc bcc)) { |
390 |
|
foreach my $v (@{$row->{$p}}) { |
391 |
|
$self->add_counter($p,$v); |
392 |
|
} |
393 |
|
} |
394 |
|
|
395 |
|
$self->add_counter_calendar($row->{date_utime}); |
396 |
} |
} |
397 |
|
|
398 |
return $row; |
return $row; |