Curses-UI-POE
view release on metacpan or search on metacpan
examples/pop3_reader view on Meta::CPAN
#!/usr/bin/perl -w
use strict;
use FindBin;
use lib "$FindBin::RealBin/../lib";
use Curses::UI::POE;
use Curses;
use Net::POP3;
use Mail::Header;
use Mail::Address;
my $cui = new Curses::UI::POE ( -clear_on_exit => 1 );
my $pop3 = undef;
my $connection = undef;
# We do not want STDERR to clutter our screen.
open STDERR, ">/dev/null";
# ----------------------------------------------------------------------
# setup(): Setup the connection
# ----------------------------------------------------------------------
sub check_connection($;)
{
my $buttons = shift;
my $conwin = $buttons->parent;
my $cui = $conwin->root;
foreach my $key ('username','password','host','port')
{
my $obj = $conwin->getobj($key);
my $value = $obj->get;
$connection->{$key} = $value;
# TODO: focus back to entry does not seem to
# move the cursor with it.
if ($value =~ /^\s*$/) {
$cui->error("Missing value for $key field");
$obj->focus;
return;
}
}
return 1;
}
sub setup_connection()
{
my $conwin = $cui->add(
'connection_window', 'Window',
-border => 1,
-ipad => 2,
-height => 15,
-width => 60,
-centered => 1,
-title => "POP3 connection",
);
$conwin->add(
'host_label', 'Label',
-x => 0, -y => 0, -width => 13,
-textalignment => 'right',
-text => 'POP3 host :',
);
$conwin->add(
'host', 'TextEntry',
-x => 14, -y => 0,
-text => 'pop',
);
$conwin->add(
'port_label', 'Label',
-x => 0, -y => 2, -width => 13,
-textalignment => 'right',
-text => 'POP3 port :',
);
$conwin->add(
'port', 'TextEntry',
-x => 14, -y => 2,
-regexp => '/^\d*$/',
-text => '110',
);
$conwin->add(
'username_label', 'Label',
-x => 0, -y => 4, -width => 13,
-textalignment => 'right',
-text => 'Username :',
);
$conwin->add(
'username', 'TextEntry',
-x => 14, -y => 4,
-text => getpwuid($>),
( run in 0.541 second using v1.01-cache-2.11-cpan-39bf76dae61 )