#!/data/asictools/bin/perl -w =head1 NAME XbiffPOP3 - an xbiff for POP3. This tool notifies on a filled POP3 mailbox. =head1 SYNOPSIS XbiffPOP3 [OPTIONS] =head1 OPTIONS Server | s # name of POP3 server (default is mailhost) POP3Id # your id for access to POP3 (default is your account name) PollPeriod # polling period for contaction POP3 server (default is 60) FlashPeriod # flash period (=0 suppresses flashing) (default is 2) ColorSchemeIdle # configure the color for idle state (default is blue) ColorSchemeMail # configure the color for Mail state (default is yellow) ColorSchemeAlarm # configure the color for Alarm state (default is red) help | h # get this help =head1 EXAMPLE XbiffPOP3 --FlashPeriod=5 -s mypop3server =head1 DESCRIPTION This tool notifies the state of your POP3 mailbox: state Idle = no mail in your mailbox state Mail = at least on mail in your mailbox (get this mail with your prefered mailtool. state Alarm = something wrong with POP3 access In order to access POP3 this tool requires your POP3 password. This password won\'t be saved, it is only temporary stored in the running programm, and of course transmitted to your POP3 server. Please enter your password into the first window. For netscape users: switch OFF the automatic download for mails, or this tool will never get any chance to detect newly arrived mails. =head1 AUTHOR B.Weiler, Siemens ICN TR ON EA, 12.98 =head1 PREREQUISITES Mail::POP3Client Tk Tk::Dialog Getopt::Long Pod::Usage =head1 COREQUISITES void =head1 OSNAMES This script is known to work on C =head1 SCRIPT CATEGORIES CPAN =head1 FUNCTIONS =cut #modules --------- use strict; use IgnoreUserlocal; use Mail::POP3Client; use Tk; use Tk::Dialog; use Getopt::Long; use Pod::Usage; #vars --------- my $Passwd; my $Server='mailhost'; my $PollPeriod=60; my $FlashPeriod=4; my %ColorScheme=( Idle => 'darkblue', Mail => 'yellow', Alarm => 'red', ); my $Color=$ColorScheme{Idle}; my $FlashMemo=0; my %Options; my $POP3Id=$ENV{USER}; #predeclaration --------- sub TestPOP3(); sub Flash(); #main --------- #options. pod2usage(-verbose => 2) unless GetOptions(\%Options, qw(Server|s=s POP3Id=s PollPeriod=i FlashPeriod=i ColorSchemeIdle=s ColorSchemeMail=s ColorSchemeAlarm=s help|h )); pod2usage(-verbose => 2) if(exists $Options{help}); $Server=$Options{Server} if(exists $Options{Server}); $PollPeriod=$Options{PollPeriod} if(exists $Options{PollPeriod}); $FlashPeriod=$Options{FlashPeriod} if(exists $Options{FlashPeriod}); $ColorScheme{Idle}=$Options{ColorSchemeIdle} if(exists $Options{ColorSchemeIdle}); $ColorScheme{Mail}=$Options{ColorSchemeMail} if(exists $Options{ColorSchemeMail}); $ColorScheme{Alarm}=$Options{ColorSchemeAlarm} if(exists $Options{ColorSchemeAlarm}); #Tk my $MW = MainWindow->new(-title => "Password entry"); my $PwdTxt=$MW->Text(-width => '40', -height => '1')->pack; $PwdTxt->insert('0.0',"Please enter your POP3 password"); my $PwdEntry=$MW->Entry( # -background => 'white', # -foreground => 'black', -relief => 'raised', -textvariable => \$Passwd, -show => '*', ); $PwdEntry->pack; my $PwdGo=$MW->Button( -text => 'OK', -command => [$MW => 'withdraw'], ); $PwdGo->pack; my $PW=$MW->Toplevel(-bg => 'darkblue', -title =>'Xbiff for POP3 Inbox'); $PW->repeat($PollPeriod*1000,\&TestPOP3); $PW->repeat((($FlashPeriod < 1)? 10: $FlashPeriod)*1000,\&Flash); &MainLoop; #sub's --------- sub TestPOP3(){ my $pop = new Mail::POP3Client($POP3Id,$Passwd,$Server); $Color=$ColorScheme{Idle}; $Color=$ColorScheme{Alarm} unless($pop->Alive); $Color=$ColorScheme{Alarm} unless($pop->State eq 'TRANSACTION'); $Color=$ColorScheme{Alarm} if($pop->Count == -1); $Color= ($pop->Count > 0)? $ColorScheme{Mail}: $ColorScheme{Idle} unless($Color eq $ColorScheme{Alarm}); } sub Flash(){ $FlashMemo=0 if($FlashPeriod == 0); $FlashMemo=not $FlashMemo; $PW->configure(-bg => $FlashMemo? $Color: $ColorScheme{Idle}); $PW->idletasks; #if state Mail try quick clear. TestPOP3() if($Color eq $ColorScheme{Mail}); }