NAME

ZConf::Runner - Run a file using a choosen methode, desktop entry or mimetype.

VERSION

Version 0.0.0

SYNOPSIS

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();

FUNCTIONS

new

This initializes it.

There is only on arg supported currently and that is an hash that will be passed directly to ZConf->new.

my $zcr=ZConf::Runner->new();

actionIsSetup

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";
}

ask

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.

args hash

useX

This is a boolean value that determines if should spawn a xterm instance to when calling ask. The default terminal is 'xterm -rv -e', but this can be changed by setting '$ENT{TERMINAL}'.

The default is true.

my $returned=$zcr->ask('view', '/tmp/test.rdf', {useX=>0});
if($zcr->{error}){
    print "Error!\n";
}else{
    if($returned){
        print "Action setup.\n";
    }
}

askGUI

This accepts two arguements. The first is the action and the second is the object.

This function exits what ever is running as it is not possible of exit Curses::UI's main loop. For a list of what the exit codes mean, please see the secion 'EXIT CODES'.

This is not meant to be called really except for by ask.

do

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.

args hash

still needs implemented

exec

If this is set to true, exec is used instead of system.

ask

If this is set to true, it will

useX

This is a boolean value that determines if should spawn a xterm instance to when calling ask.

The default is true.

#run it with the edit action, but if it has not been setup,
#then don't ask
$zcr->do('edit', '/tmp/test.rdf', {ask=>0})

#run it with the edit action, but if it has not been setup,
#then ask
$zcr->do('edit', '/tmp/test.rdf', {ask=>1})

#run it using the edit action... when it is ran it will also use
#exec instead of system
$zcr->do('edit', '/tmp/test.rdf', {ask=>1, exec=>1})

getAction

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";
}

listActions

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";
}

listMimetypes

This fetches a list of currently setup mimetypes.

The are no arguements for this.

my @mimetypes=$zcr->listMimetypes();
if($zcr->{error}){
    print "Error!\n";
}

newRunner

This creates a new runner. The only required arguement is an hash. Please see the section below for the required hash values.

hash args

mimetype

This is the mimetype for the new runner.

action

This action that will be done.

type

This is either 'exec' or 'desktop'.

do

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";
}

mimetypeIsSetup

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";
}

removeAction

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";
}

validAction

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';
}

validActionName

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";
}

validDesktopEntry

This checks to see if a desktop entry is valid. One value is accept and that is file id name.

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->validDesktopEntry('xemacs')){
    print "xeamcs is not a valid desktop entry\n";
}

Xavailable

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.

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->Xavailable()){
    print "X is available\n";
}

errorBlank

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

It does the following.

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

ERROR CODES

1

Could not initialize ZConf.

2

ZConf error.

3

Failed to create the ZConf config 'runner'.

4

Missing function arguements.

5

Invalid action name.

6

Invalid type.

7

Mimetype not configured.

8

Action is not configured.

9

Missing type for an action.

10

Invalid action for an type.

11

'do' is not defined for the action.

12

Could not determine mimetype.

13

Desktop entry does not appear to be valid. It could not be found by 'lookup' in 'File::DesktopEntry'.

14

No desktop entry specified or none exists for this mimetype.

15

Curses::UI start problem

16

Curses::UI failed in some manner.

EXIT CODES

14

Quit selected.

15

The OK has been selected and the new runner has been added.

16

Error Code 14 happened when OK was selected.

17

'newRunner' errored.

AUTHOR

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

BUGS

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.

SUPPORT

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

perldoc ZConf::Runner

You can also look for information at:

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

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.