Curses-UI-POE

 view release on metacpan or  search on metacpan

examples/pop3_reader  view on Meta::CPAN

		# 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($>),
	);

	$conwin->add(
		'password_label', 'Label',	
		-x => 0, -y => 6, -width => 13,
		-textalignment => 'right',
		-text => 'Password :',
	);

	$conwin->add(
		'password', 'TextEntry',
		-x => 14, -y => 6,
		-password => '*',
		-text => '',
	)->focus;

	my $buttons = $conwin->add(
		'buttons', 'Buttonbox',
		-x => 14, -y => 8,
		-buttons => [
		    { -label => '< Connect >',
		      -onpress => sub {
		          my $this = shift;
		          if (check_connection($this)) {
			      if (pop3_connect()) {
			          $this->parent->loose_focus;
			      }
			  }
		      },
		    },
		    { -label => '< Quit >',
		      -onpress => sub {exit} },
		],
	);

	$conwin->modalfocus;
	$cui->delete('connection_window')
}

# ----------------------------------------------------------------------
# pop3_connect(): Connect to the POP3 server and exit if it fails
# ----------------------------------------------------------------------

sub pop3_connect()
{
	$cui->progress(
		-message => "Connecting to the POP3 server...",
		-max => 4,
		-pos => 1,
	);

	my $error = 0;

	$pop3 = Net::POP3->new(
		$connection->{host},
		Port => $connection->{port},
		Timeout => 0,
	);

	if (not $pop3) {



( run in 2.187 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )