1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
# $Id: Print.pm,v 1.3 2001/03/19 01:19:27 muhri Exp $
# -*- perl -*-
package Pronto::Print;
use strict;
use SelfLoader;
1;
__DATA__
sub print_message {
my ($flag) = @_;
my ($msgid, $child, $forrep, $sql, $query, $print, $printed);
$forrep = 4;
$msgid = &Pronto::MessageList::get_selected_msgid();
if (! $msgid) {
&main::err_dialog(_("Select the message You want to print!"));
return 1;
}
$sql = "select contenttype from messages where id = $msgid";
$query = $main::conn->prepare($sql);
$query->execute();
my ($type) = ($query->fetchrow_array());
if ($type =~/html/) { &main::err_dialog(_("Can't print HTML Messages yet"));
return 1;
}
if ($flag eq "withheader") {
$print->{'format'} = new Gtk::Text;
my $header = &Pronto::Read::view_message($main::conn, $msgid, $print->{'format'}, 4, $forrep, undef, undef, undef, undef, undef, "n");
my $body = &Pronto::Read::view_message($main::conn, $msgid, $print->{'format'}, 2, $forrep, undef, undef, undef, undef, undef, "n");
$printed = $print->{'format'}->get_chars(0, -1);
} elsif ($flag eq "body") {
$print->{'format'} = new Gtk::Text;
my $body = &Pronto::Read::view_message($main::conn, $msgid, $print->{'format'}, 2, $forrep, undef, undef, undef, undef, undef, "y");
$printed = $print->{'format'}->get_chars(0, -1);
}
open (TMP, ">$main::prefs{'MailDir'}/tmp/printed$msgid");
print TMP "$printed";
close TMP;
unless ($child = fork) { die "cannot fork: $~" unless defined $child;
exec("$main::prefs{'PrintCommand'} $main::prefs{'MailDir'}/tmp/printed$msgid");
}
return 1;
}
|