From 391a8d3898d773e7e4a2b5e24f8196ecd089b66b Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 6 Jun 2014 01:09:25 +0200 Subject: [PATCH] Save area in additional sql table column 'area'. Allows messages from multiple areas to be saved in the same database table. Enables implementation of an OUTBOUND table. --- apps/scan.pl | 15 ++++++++------- docs/msgbase.txt | 1 + modules/MSGBASE.pm | 6 ++++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/apps/scan.pl b/apps/scan.pl index b4f1a65..3359852 100755 --- a/apps/scan.pl +++ b/apps/scan.pl @@ -115,17 +115,18 @@ sub handle_mail($) { my ($mail) = @_; - if(!$mail->{area}) { + my $area = $mail->{area}; + if(!$area) { # NETMAIL # (TODO) check special destinations - $mail->{area} = $CONFIG::config{netmail}; + $area = $CONFIG::config{netmail}; } - $handles{$mail->{area}} = MSGBASE::area_open($mail->{area}) - unless($handles{$mail->{area}}); - $counter{$mail->{area}} = 0 unless(defined $counter{$mail->{area}}); - if(MSGBASE::mail_add($handles{$mail->{area}}, $mail)) { - $counter{$mail->{area}}++; + $handles{$area} = MSGBASE::area_open($area) + unless($handles{$area}); + $counter{$area} = 0 unless(defined $counter{$area}); + if(MSGBASE::mail_add($handles{$area}, $mail)) { + $counter{$area}++; } return(1); diff --git a/docs/msgbase.txt b/docs/msgbase.txt index 618660c..5f78b95 100644 --- a/docs/msgbase.txt +++ b/docs/msgbase.txt @@ -9,6 +9,7 @@ SQLite: Each AREA is saved in a file AREANAME.area, with a single AREANAME -------- id - integer, primary key +area - text from - text - convert MISC::fido2text fname - text to - text - convert MISC::fido2text diff --git a/modules/MSGBASE.pm b/modules/MSGBASE.pm index 8394d94..1b5845f 100644 --- a/modules/MSGBASE.pm +++ b/modules/MSGBASE.pm @@ -88,6 +88,7 @@ sub area_open($) ) or die("Can't connect to $file"); $dbh->do("CREATE TABLE IF NOT EXISTS '$table' ( 'id' INTEGER PRIMARY KEY, + 'area' TEXT, 'from' TEXT, 'fname' TEXT, 'to' TEXT, 'tname' TEXT, 'date' TEXT, 'time' TEXT, @@ -160,12 +161,13 @@ sub mail_add($$) # store mail in msgbase my $rows = $handle->{dbh}->do("INSERT INTO $handle->{table} - ('from', 'fname', 'to', 'tname', 'date', 'time', + ('area', 'from', 'fname', 'to', 'tname', 'date', 'time', 'subj', 'body', 'msgid', 'reply', 'path', 'seen', 'state', 'transfer', 'file') VALUES - (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);", + (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);", undef, ( + $mail->{area}, MISC::fido2text($mail->{from}), $mail->{fname}, MISC::fido2text($mail->{to}), $mail->{tname}, MISC::date2text($mail->{date}), -- 2.30.2