| ZConf-Mail documentation | Contained in the ZConf-Mail distribution. |
ZConf::Mail::GUI - Implement various GUI functions for ZConf::Mail.
Version 0.1.0
use ZConf::Mail::GUI;
my $zcmg = ZConf::Mail::GUI->new();
...
This initiates the new the object for this module.
One arguement is taken and that is a hash value.
This is a ZConf::Mail object to use. If it is not specified, a new one will be created.
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.
This is the ZConf::GUI to use. If one is not specified,
This opens a window for composing a message.
This is the account to use. If this is not defined, the default sendable account is used.
An array of To addresses.
An array of CC addresses.
An array of BCC addresses.
An array of files to attach.
This will set the in-reply-to header value.
$zcmg->compose({account=>'smtp/whatever', to=>'foo@bar'});
if($zcmg->{error}){
print "Error!\n";
}
This composes a new message from a URI.
This is the account to use.
This is the URI to use.
$zcmg->composeFromURI({account=>'smtp/whatever', uri=>'mailto:foo@bar'});
if($zcmg->{error}){
print "Error!\n";
}
This manages the accounts.
$zcmg->manageAccounts;
if($self->{error}){
print "Error!\n";
}
This returns the available dailogs.
This returns a list of available windows.
This blanks the error storage and is only meant for internal usage.
It does the following.
$self->{error}=undef;
$self->{errorString}="";
At this time, no windows are supported.
accountmanage
compose
Failed to initialize ZConf::Mail.
Failed to initialize ZConf::GUI.
Backend error.
Missing arguement.
The URI is not a mailto URI.
The URI appears to not contain any to address.
Zane C. Bowers, <vvelox at vvelox.net>
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.
You can find documentation for this module with the perldoc command.
perldoc ZConf::Mail::GUI
You can also look for information at:
Copyright 2008 Zane C. Bowers, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| ZConf-Mail documentation | Contained in the ZConf-Mail distribution. |
package ZConf::Mail::GUI; use warnings; use strict; use ZConf::Mail; use Getopt::Std; use ZConf::GUI; use URI;
our $VERSION = '0.1.0';
sub new{ my %args; if(defined($_[1])){ %args= %{$_[1]}; } my $self={error=>undef, errorString=>undef}; bless $self; #initiates if (!defined($args{zcmail})) { if (!defined($args{zconf})) { $self->{zcm}=ZConf::Mail->new(); }else { $self->{zcm}=ZConf::Mail->new({zconf=>$args{zconf}}); } }else { $self->{zcm}=$args{zcmail}; } #handles it if initializing ZConf::Mail failed if ($self->{zcm}->{error}) { my $errorstring=$self->{zcm}->{errorString}; $errorstring=~s/\"/\\\"/g; my $error='Initializing ZConf::Mail failed. error="'.$self->{zcm}->{error} .'" errorString="'.$self->{zcm}->{errorString}.'"'; $self->{error}=3; $self->{errorString}=$error; warn('ZConf-Mail-GUI new:3: '.$error); return $self; } if (!defined($args{zconf})) { $self->{zconf}=$args{zconf}; }else { $self->{zconf}=$self->{zcm}->{zconf}; } #initializes the GUI $self->{gui}=ZConf::GUI->new({zconf=>$self->{zconf}}); if ($self->{gui}->{error}) { my $errorstring=$self->{gui}->{errorString}; $errorstring=~s/\"/\\\"/g; my $error='Initializing ZConf::GUI failed. error="'.$self->{gui}->{error} .'" errorString="'.$self->{gui}->{errorString}.'"'; $self->{error}=2; $self->{errorString}=$error; warn('ZConf-Mail-GUI new:2: '.$error); return $self; } $self->{useX}=$self->{gui}->useX('ZConf::Mail'); my @preferred=$self->{gui}->which('ZConf::Mail'); my $toeval='use ZConf::Mail::GUI::'.$preferred[0].';'."\n". '$self->{be}=ZConf::Mail::GUI::'.$preferred[0]. '->new({zconf=>$self->{zconf}, useX=>$self->{useX},'. 'zcgui=>$self->{gui}, zcmail=>$self->{zcm}}); return 1'; my $er=eval($toeval); return $self; }
sub compose{ my $self=$_[0]; my %args; if(defined($_[1])){ %args= %{$_[1]}; } $self->errorblank; if (!defined($args{account})) { $args{account}=$self->{zcm}->defaultSendableGet; } #make sure a account is specified if (!defined($args{account})) { $self->{error}='4'; $self->{errorString}='No account specified or there is no default sendable'; warn('ZConf-Mail-GUI compose:4: '.$self->{errorString} ); return undef; } $self->{be}->compose(\%args); if($self->{be}->{error}){ $self->{error}=3; $self->{errorString}='Backend errored. error="'.$self->{be}->{error}.'" '. 'errorString="'.$self->{be}->{errorString}.'"'; warn('ZConf-Mail-GUI compose:3: '.$self->{errorString}); return undef; } return 1; }
sub composeFromURI{ my $self=$_[0]; my %args; if(defined($_[1])){ %args= %{$_[1]}; } $self->errorblank; if (!defined($args{account})) { $args{account}=$self->{zcm}->defaultSendableGet; } #make sure a account is specified if (!defined($args{account})) { $self->{error}='4'; $self->{errorString}='No account specified or there is no default sendable'; warn('ZConf-Mail-GUI composeFromURI:4: '.$self->{errorString} ); return undef; } #make sure a URI is specified. if (!defined($args{uri})) { warn('ZConf-Mail-GUI composFromURIe:4: No URI specified' ); $self->{error}=4; $self->{errorString}='No URI specified.'; return undef; } if (!($args{uri}=~/[Mm][Aa][Ii][Ll][Tt][Oo]\:/)) { $self->{errorString}='Does not appear to be a '; $self->{error}=5; warn('ZConf-Mail-GUI composeFromURI:4: '.$self->{errorString}); return undef; } my $uri=URI->new($args{uri}); my $to=$uri->to; if (!defined($to) || ($to eq '')) { $self->{errorString}='No to address could be found in the URI'; $self->{error}=6; warn('ZConf-Mail-GUI composeFromURI:6: '.$self->{errorString}); return undef; } $self->compose({account=>$args{account}, to=>[$to]}); if ($self->{error}) { warn('ZConf-Mail-GUI compmoseFromURI: compose fialed'); } return 1; }
sub manageAccounts{ my $self=$_[0]; my %args; if(defined($_[1])){ %args= %{$_[1]}; } $self->errorblank; $self->{be}->manageAccounts(\%args); if($self->{be}->{error}){ $self->{error}=3; $self->{errorString}='Backend errored. error="'.$self->{be}->error.'" '. 'errorString="'.$self->{be}->{errorString}.'"'; warn('ZConf-Mail-GUI manageAccounts: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::Runner::GUI