ZConf::Runner - Run a file using a choosen methode, desktop entry or mimetype.
Version 2.1.4
The purpose of this module is to figure out what to do with an object based on it's mimetype. Currently only files are supported.
use ZConf::Runner; my $zcr=ZConf::Runner->new(); if($zcr->{error}){ print "Error!\n"; }
This initializes it.
One arguement is taken and that is a hash value.
This is a zconf object to use instead of initiating a new one.
my $zcr=ZConf::Runner->new(); if($zcr->{error}){ print "Error!\n"; }
This checks to see if a specific action is setup for a mimetype.
Two arguements are accepted. The first is the mimetype. The second is the action.
my $mimetype='image/jpeg'; my $returned=$zcr->actionIsSetup($mimetype, 'edit'); if($zcr->{error}){ print "Error!\n"; if($zcr->{error} eq '7'){ print "Mimetype is not setup.\n"; } } if($returned){ print $mimtetype." is configured already"; }
This is creates a Curses::UI asking what to do.
The first agruement is the action to be performed. The second is the file it is to be performed on. The third is an optional hash. It's accepted keys are as below.
my $returned=$zcr->ask('view', '/tmp/test.rdf', {useX=>0}); if($zcr->{error}){ print "Error!\n"; }else{ if($returned){ print "Action setup.\n"; } }
This runs takes an file and runs it.
The first agruement is the action to be performed.
The second is the file it is to be performed on.
The third is an optional hash. It's accepted keys are as below.
still needs implemented
If this is set to true, exec is used instead of system.
If this is set to true, it will
This fetches an action for a mimetype and returns the do and type as an hash.
The are two required arguements. The first is the mimetype and the second is the action.
my %action=$zcr->getAction('application/vnd.oasis.opendocument.text', 'view'); if($zcr->{error}){ print "Error!\n"; }else{ print "do: '".$action{do}."'\n". "type: '".$action{type}."'\n"; }
This gets what the current set is.
my $set=$zcr->getSet; if($zcr->{error}){ print "Error!\n"; }
This gets a list of actions for a specific mimetype.
There is one required arguement and it is the mimetype.
my @actions=$zcr->listActions('application/vnd.oasis.opendocument.text'); if($zcr->{error}){ print "Error!\n"; }
This fetches a list of currently setup mimetypes.
The are no arguements for this.
my @mimetypes=$zcr->listMimetypes(); if($zcr->{error}){ print "Error!\n"; }
This lists the available sets.
my @sets=$zcr->listSets; if($zcr->{error}){ print "Error!"; }
This creates a new runner. The only required arguement is an hash. Please see the section below for the required hash values.
This is the mimetype for the new runner.
This action that will be done.
This is either 'exec' or 'desktop'.
If the 'exec' is specified as the type the specified program is used to run it. '%f' will be replaced by the filename when it is ran.
If the 'desktop' is specified as the type 'File::MimeInfo::Applications' is used to run it.
$zcr->newRunner({mimetye=>'application/pdf', action=>'view', type=>'exec', do=>'xpdf %f'}) if($zcr->{error}){ print "Error!\n"; }
This checks if a mimetype has been setup already. One arguement is accepted. It is a string containing the name of mimetype.
my $mimetype='image/jpeg'; my $returned=$zcr->mimetypeIsSetup($mimetype); if($zcr->{error}){ print "Error!\n"; } if($returned){ print $mimtetype." is configured already"; }
This reads a specific set. If the set specified is undef, the default set is read.
#read the default set $zcr->readSet(); if($zcr->{error}){ print "Error!\n"; } #read the set 'someSet' $zcr->readSet('someSet'); if($zcr->{error}){ print "Error!\n"; }
This removes an action for a mimetype.
Two arguements are required. The first is the mimetype and the second is the action.
$zcr->removeAction('application/pdf', 'view'); if($self->{error}){ print "Error!\n"; }
This makes sure an action is valid. See the error code for the reason it is not valid.
$zcr->validAction('application/pdf', 'view'); if($self->{error}){ print 'Error:'.$self->{error}.': Action is not valid'; }
This makes sure that the action name is valid.
There is no reason to ever check $zcr->{error} with this as this function will not set it. It just returns a boolean value.
if($zcr->validActionName('some/test')){ print "Error\n"; }
This checks to see if a desktop entry is valid. One value is accept and that is file id name.
if($zcr->validDesktopEntry('xemacs')){ print "xeamcs is not a valid desktop entry\n"; }
This checks if X is available. This is checked for by trying to run 'xhost > /dev/null' and is assumed if a non-zero exit code is returned then it failed and thus X is not available.
if($zcr->Xavailable()){ print "X is available\n"; }
This blanks the error storage and is only meant for internal usage.
It does the following.
$self->{error}=undef; $self->{errorString}="";
The error code is contianed in $zcr->{error} and a extended description can be found in $zcr->{errorString}. If any module ever sets $zcr->{perror} then the error is permanent and none of the methods are usable.
Could not initialize ZConf.
ZConf error.
Failed to create the ZConf config 'runner'.
Missing function arguements.
Invalid action name.
Invalid type.
Mimetype not configured.
Action is not configured.
Missing type for an action.
Invalid action for an type.
'do' is not defined for the action.
Could not determine mimetype.
Desktop entry does not appear to be valid. It could not be found by 'lookup' in 'File::DesktopEntry'.
No desktop entry specified or none exists for this mimetype.
Curses::UI start problem
Curses::UI failed in some manner.
Quit selected.
The OK has been selected and the new runner has been added.
Error Code 14 happened when OK was selected.
'newRunner' errored.
Ask errored.
Zane C. Bowers, <vvelox at vvelox.net>
<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-Runner. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-zconf-runner at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc ZConf::Runner
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=ZConf-Runner
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/ZConf-Runner
CPAN Ratings
http://cpanratings.perl.org/d/ZConf-Runner
Search CPAN
http://search.cpan.org/dist/ZConf-Runner
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.
To install ZConf::Runner, copy and paste the appropriate command in to your terminal.
cpanm
cpanm ZConf::Runner
CPAN shell
perl -MCPAN -e shell install ZConf::Runner
For more information on module installation, please visit the detailed CPAN module installation guide.