my $sth = $dbh->prepare(
q{
- SELECT messageid,present,inserttime,msgdate,msgfrom,msgto,msgcc,subject
+ SELECT messageid,present,inserttime,msgtype,msgdate,msgfrom,msgto,msgcc,subject
FROM messages
WHERE id = ?
}
$sth->execute($id);
- my ( $msgid, $present, $inserted, $date, $from, $to, $cc, $subj ) =
- @{ $sth->fetch };
+ my ( $msgid, $present, $inserted, $msgtype, $date, $from, $to, $cc, $subj )
+ = @{ $sth->fetch };
$sth->finish;
dbh => $dbh,
present => $present eq "true",
inserted => $inserted,
+ msgtype => $msgtype,
date => Mail::Field::Date->new( 'date', $date ),
from => Mail::Field::AddrList->new( 'from', $from ),
to => Mail::Field::AddrList->new( 'to', $to ),
my $sth = $dbh->prepare(
q{
- SELECT id,present,inserttime,msgdate,msgfrom,msgto,msgcc,subject
+ SELECT id,present,inserttime,msgtype,msgdate,msgfrom,msgto,msgcc,subject
FROM messages
WHERE messageid = ?
}
$sth->finish;
- my ( $id, $present, $inserted, $date, $from, $to, $cc, $subj );
+ my ( $id, $present, $inserted, $msgtype, $date, $from, $to, $cc, $subj );
if ( defined $row ) {
- ( $id, $present, $inserted, $date, $from, $to, $cc, $subj ) = @{$row};
+ ( $id, $present, $inserted, $msgtype, $date, $from, $to, $cc, $subj ) =
+ @{$row};
}
elsif ( $args{Insert} ) {
my $sth = $dbh->prepare(
INSERT into messages (messageid) VALUES (?)
}
);
+
+ $msgtype = "normal";
+
$sth->execute($msgid) or die "Inserting new message";
$id = $dbh->sqlite_last_insert_rowid();
$present = 0;
inserted => $inserted,
id => $id,
msgid => $msgid,
+ msgtype => $msgtype,
date => Mail::Field::Date->new( 'date', $date ),
from => Mail::Field::AddrList->new( 'from', $from ),
to => Mail::Field::AddrList->new( 'to', $to ),
return $self;
}
+sub set_type {
+ my $self = shift;
+ my $type = shift;
+
+ # XXX check type
+
+ my $sth = $self->{dbh}->prepare(
+ q{
+ UPDATE messages
+ SET msgtype=?2
+ WHERE id = ?1}
+ ) or die "prepare type update";
+ $sth->execute( $self->{id}, $type ) or die "execute type update";
+ $sth->finish or die "finish type update";
+
+ $self->{msgtype} = $type;
+}
+
sub update {
my $self = shift;
my $header = shift;
$from ? $from->stringify : undef,
$to ? $to->stringify : undef,
$cc ? $cc->stringify : undef
- ) or die "execute insert";
- $sth->finish or die "finish insert";
+ ) or die "execute update";
+ $sth->finish or die "finish update";
my $irt = $header->get('in-reply-to');
if ( defined $irt ) {