#!/usr/local/bin/perl -w # $Id: palm-mailfolder,v 1.4 2000/08/18 22:27:36 mas Exp $ # # Read a mail folder from a Palm. # Copyright 2000 Marc André Selig. # All rights reserved. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ############################################################################### # initialization use strict; use PDA::Pilot; $|=1; use vars qw($opt_f $opt_h $opt_l $opt_p $opt_v); use Getopt::Std; getopts('f:hl:p:v'); if (defined $opt_h) { print <getUserInfo->{name}; $localaddress = $pilotname if not defined $localaddress; my $db = $dlp->open("MailDB") or die "Cannot open MailDB"; my $recnum = $db->getRecords; $dlp->getStatus; # update HotSync status on Palm Display for (my $n = 0; $n < $recnum; $n++) { my $mail = $db->getRecord($n); next if $mail->{archived} or $mail->{deleted} or $mail->{category} != $category; print "From palm " . localtime() . "\n"; if (!defined $mail->{from} or $mail->{from} eq "") { # If there is no From: address, I assume the mail originated on the # Palm: I want as much information as possible on these mails. # On messages from others, I only write those headers I can reproduce # exactly: I do not want to distort anything. if ($mail->{priority} == 2) { print "Precedence: bulk\n"; } elsif ($mail->{priority} == 1) { # do nothing for normal priority } elsif ($mail->{priority} == 0) { print "Precedence: special-delivery\nPriority: urgent\n"; # if it's really urgent, even M$ software should know } print "X-Signature: was present\n" if $mail->{signature}; print "X-Busy: $mail->{busy}\n" if $mail->{busy}; print "X-Addressing: $mail->{addressing}\n" if $mail->{addressing}; print "X-Secret: yes\n" if $mail->{secret}; print "Disposition-Notification-To: $localaddress\n" if $mail->{confirmRead}; print "X-DSN-Requested: yes\n" if $mail->{confirmDelivery}; print "Status: R\n" if $mail->{read}; } if (!defined $mail->{from} or $mail->{from} eq "") { print "From: $localaddress\n"; } else { print "From: $mail->{from}\n"; } print "To: $mail->{to}\n"; print "Subject: $mail->{subject}\n" if $mail->{subject} ne ""; print "\n$mail->{body}\n\n"; } $db->close(); undef $db; # close database undef $dlp; # close connection