#!/usr/bin/perl -w
## $Id: prontoget,v 1.3 2001/02/03 13:59:02 muhri Exp $
use strict;
use vars qw(%prefs $libpath $conn $locale $locale_installed);

BEGIN { 
 $libpath = $0;
 $libpath =~ s!/[^/]+$!!;
 $libpath =~ s!/bin$!/lib/pronto!;
 if (! -e $libpath) { die _("Can't find required files in $libpath"); };
}
use lib "$libpath";
use lib "$libpath/modules/lib/perl5/site_perl/5.005";

require "prontolib.pl";
use Pronto::Get;
use Pronto::Data::Message;
use Pronto::Crypt;
use Pronto::Crypt::GPG;
$SIG{SEGV} = $SIG{TERM} = $SIG{QUIT} = $SIG{KILL} = \&quit;

read_prefs();

# check for currently running copy of cscget
#
if (open(TMP,"<$prefs{'MailDir'}/prontoget.running")) {
	my $proc = <TMP>;
	if(kill (0,$proc)) {
		printf(_("Prontoget is already running. if this is not true, please delete\n
		prontoget.running in ") . $prefs{'MailDir'} . "\n");
		exit;
	} 
	else {
		close(TMP);
		unlink "$prefs{'MailDir'}/prontoget.running";
	}
}

$conn = &open_db_conn;
my ($acctarg, $interarg) = @ARGV;
$Pronto::Get::inter = $interarg;
$Pronto::Get::acct = $acctarg;
$Pronto::Get::called_from_get = 1;
&Pronto::Get::get();

sub quit {
	if(open(TMP,"<$prefs{'MailDir'}/pronto.running")) {
		my $proc = <TMP>;
        	close(TMP);
        	if(kill(0,$proc)) {
	        	kill('USR2',$proc);
        	}
	}
}

