Save area in additional sql table column 'area'.
authorSebastian <basti@notizbuch>
Thu, 5 Jun 2014 23:09:25 +0000 (01:09 +0200)
committerSebastian <basti@notizbuch>
Thu, 5 Jun 2014 23:09:25 +0000 (01:09 +0200)
Allows messages from multiple areas to be saved in the same
database table. Enables implementation of an OUTBOUND table.

apps/scan.pl
docs/msgbase.txt
modules/MSGBASE.pm

index b4f1a6560f25250bb8f40b2c4e6a70ea119324a7..3359852b44ffb9250a162a1ff547dbef1c2f4f1d 100755 (executable)
@@ -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);
index 618660c89b64bc9bc63fd4d286273c5522bcbfaa..5f78b955cdaebe8b5da85cec12c0c8ca5e6d7208 100644 (file)
@@ -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
index 8394d948056ac82fae7d6158c58046223705baf5..1b5845fd7de1b6d76b567ca0246b5e97536b0b25 100644 (file)
@@ -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}),