ZConf::Mail::GUI::Curses - The Curses backend for ZConf::Mail::GUI.


ZConf-Mail documentation Contained in the ZConf-Mail distribution.

Index


Code Index:

NAME

Top

ZConf::Mail::GUI::Curses - The Curses backend for ZConf::Mail::GUI.

VERSION

Top

Version 0.1.1

SYNOPSIS

Top

This provides the Curses backend for ZConf::Mail::GUI.

    use ZConf::Mail::GUI::Curses;

    my $zcmail=ZConf::Mail::GUI::Curses->new();

METHODES

Top

new

This initializes it.

One arguement is taken and that is a hash value.

hash values

useX

This is if it should try to use X or not. If it is not defined, ZConf::GUI->useX is used.

zcgui

This is the ZConf::GUI object. A new one will be created if it is

zcmail

This is a ZConf::Mail object to use. If it is not specified, a new one will be created.

zconf

This is the ZConf object to use. If it is not specified the one in the object for zcrunner will be used. If neither zconf or zcrunner is specified, a new one is created.

manageAccounts

Please see the documentation for 'ZConf::MailGUI' for 'manageAccounts'.

compose

Please see compose for 'ZConf::Mail::GUI'.

dialogs

This returns the available dailogs.

windows

This returns a list of available windows.

errorblank

This blanks the error storage and is only meant for internal usage.

It does the following.

    $self->{error}=undef;
    $self->{errorString}="";

dialogs

Top

At this time, no windows are supported.

windows

Top

manageAccounts

compose

HOTKEYS

Top

Please see Curses::UI::TextEditor for the support hot keys.

Additional ones are listed below.

CTRL+a

Attach a file.

CTRL+f

Call the formatter.

CTRL+l

Send.

CTRL+n

Changes to the next tab.

CTRL+p

Changes to the previous tab.

CTRL+q

Exit.

ERROR CODES

Top

1

Coult no initiate ZConf.

2

Missing arguements.

3

Backend script failed.

useX

Top

If useX is true, ther enviromental variable 'TERMINAL' is used for finding what terminal should be used executing the backend script.

AUTHOR

Top

Zane C. Bowers, <vvelox at vvelox.net>

BUGS

Top

Please report any bugs or feature requests to bug-zconf-runner at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=ZConf-Mail. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

Top

You can find documentation for this module with the perldoc command.

    perldoc ZConf::Mail::GUI::Curses




You can also look for information at:

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=ZConf-Mail

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/ZConf-Mail

* CPAN Ratings

http://cpanratings.perl.org/d/ZConf-Mail

* Search CPAN

http://search.cpan.org/dist/ZConf-Mail

ACKNOWLEDGEMENTS

Top

COPYRIGHT & LICENSE

Top


ZConf-Mail documentation Contained in the ZConf-Mail distribution.
package ZConf::Mail::GUI::Curses;

use warnings;
use strict;
use Curses::UI;
use String::ShellQuote;

our $VERSION = '0.1.1';

sub new{
	my %args;
	if(defined($_[1])){
		%args= %{$_[1]};
	}

	my $self={error=>undef, errorString=>undef};
	bless $self;

	#initiates
	if (defined($args{zcmail})) {
		$self->{zcmail}=$args{zcmail};
	}else {
		$self->{zcmail}=ZConf::Mail->new();
	}

	#
	if (defined($args{zconf})) {
		$self->{zconf}=$self->{zcr}->{zconf};
	}else {
		use ZConf;
		$self->{zconf}=ZConf->new();
		if(defined($self->{zconf}->{error})){
			warn("ZConf-Mail-GUI-Curses new:1: Could not initiate ZConf. It failed with '"
				 .$self->{zconf}->{error}."', '".$self->{zconf}->{errorString}."'");
			$self->{error}=1;
			$self->{errorString}="Could not initiate ZConf. It failed with '"
			                     .$self->{zconf}->{error}."', '".
			                     $self->{zconf}->{errorString}."'";
			return $self;
		}
	}

	#
	if (defined($args{useX})) {
		$self->{useX}=$args{useX};
	}else {
		use ZConf::GUI;
		$self->{zcgui}=ZConf::GUI->new({zconf=>$self->{zconf}});
		$self->{useX}=$self->{zcgui}->useX('ZConf::Mail');
	}

	$self->{terminal}='xterm -rv -e ';
	#if the enviromental variable 'TERMINAL' is set, use 
	if(defined($ENV{TERMINAL})){
		$self->{terminal}=$ENV{TERMINAL};
	}


	return $self;
}

sub manageAccounts{
	my $self=$_[0];
	my %args;
	if (defined($_[1])) {
		%args= %{$_[1]};
	}

	$self->errorblank;

	my $command='curses-zcmailacountmanage -s '.shell_quote($self->{zcmail}->getSet);

	if ($self->{useX}) {
		$command=$self->{terminal}.shell_quote($command);
	}

	system($command);
	my $exitcode=$? >> 8;

	#error if it got a -1... not in path
	if ($? == -1) {
		$self->{error}=2;
		$self->{errorString}='"curses-zcmailacountmanage" is not in the path.';
		warn('ZConf-Mail-GUI-Curses manageAccounts:2: '.$self->{errorString});
		return undef;
	}

	#error if it is something other than 0
	if (!($? == 0)) {
		$self->{error}=3;
		$self->{errorString}='The backend script exited with a non-zero, "'.$exitcode.'"';
		warn('ZConf-Mail-GUI-Curses manageAccounts:3: '.$self->{errorString});
		return undef;		
	}

	return 1;
}


sub compose{
	my $self=$_[0];
	my %args;
	if(defined($_[1])){
		%args= %{$_[1]};
	}

	$self->errorblank;

	if (!defined($args{account})) {
		$args{account}=$self->{zcmail}->defaultSendableGet;
	}

	#make sure a account is specified
	if (!defined($args{account})) {
		warn('ZConf-Mail-GUI compose:4: No account specified' );
		$self->{error}='4';
		$self->{errorString}='No account specified.';
		return undef;
	}

	#to
	my $to='';
	if (defined($args{to}[0])) {
		$to='-t ';
		my $toJ=join(',', @{$args{to}});
		$to=$to.shell_quote($toJ);
	}

	#cc
	my $cc='';
	if (defined($args{cc}[0])) {
		$cc='-c ';
		my $ccJ=join(',', @{$args{cc}});
		$cc=$cc.shell_quote($ccJ);
	}

	#bcc
	my $bcc='';
	if (defined($args{bcc}[0])) {
		$bcc='-b ';
		my $bccJ=join(',', @{$args{to}[0]});
		$bcc=$bcc.shell_quote($bccJ);
	}

	#replyto
	my $replyto='';
	if (defined($args{'in-reply-to'})) {
		$replyto=shell_quote($args{'in-reply-to'});
		$replyto='-r '.$replyto;
	}

	#account
	my $account='-a '.shell_quote($args{account});

	#files
	my $files='';
	if (defined($args{files}[0])) {
		$files='-f ';
		my $filesJ=join(',', @{$args{files}});
		$files=$files.shell_quote($filesJ);
	}

	my $command='curses-zcmailcompose '.$account.' '.$to.' '.$cc.' '.
	            $bcc.' '.$replyto.' '.$files;

	if ($self->{useX}) {
		$command=$self->{terminal}.shell_quote($command);
	}

	system($command);
	my $exitcode=$? >> 8;

	#error if it got a -1... not in path
	if ($? == -1) {
		$self->{error}=2;
		$self->{errorString}='"curses-zcmailacountmanage" is not in the path.';
		warn('ZConf-Mail-GUI-Curses compose:2: '.$self->{errorString});
		return undef;
	}

	#error if it is something other than 0
	if (!($? == 0)) {
		$self->{error}=3;
		$self->{errorString}='The backend script exited with a non-zero, "'.$exitcode.'"';
		warn('ZConf-Mail-GUI-Curses compose:3: '.$self->{errorString});
		return undef;		
	}

	return 1;
}

sub dialogs{
	return undef;
}

sub windows{
	return ('accountmanage', 'compose');
}

#blanks the error flags
sub errorblank{
	my $self=$_[0];

	$self->{error}=undef;
	$self->{errorString}="";

	return 1;
}

1; # End of ZConf::Mail::GUI::Curses