NAME
CallBackery::Plugin - Reporter base class
SYNOPSIS
use CallBackery::GuiPlugin::Abstract;
DESCRIPTION
The abstract base class for callbackery gui classes.
ATTRIBUTES
config
The Plugin instance specific config section from the master config file.
name
The PLUGIN instance 'name' as specified in the *** PLUGIN:... ***
section.
user
The current user object
tabName
What should the tab holding this plugin be called
true
true value
false
false value
grammar
Returns the Config::Grammar parser for the configuration of this reporter.
controller
the current controller
app
the app object
log
the log object
screenCfg
returns the information for building a plugin configuration screen.
checkAccess()
Check if the current user may access the Plugin. Override in the Child class to limit accessibility. By default plugins are not accessible unless you have numeric UID or the word __CONFIG
. The CallBackery::Command::shell sets the userId to __SHELL
. If a plugin should be configurable interactively it must allow access to the __SHELL
user.
stateFiles
a list of files that contain the state of the settings configured by this plugin this is used both for backup purposes and to replicate the settings to a second installation.
unconfigureFiles
a list of files to be removed when 'unConfiguring' a device
eventActions
A map of callbacks, which will be called according events in the system. The following events are available:
configChanged
METHODS
All the methods of Mojo::Base plus:
makeRxValidator(rx,error)
Create a regular expression base validator function. The supplied regular expression gets anchored front and back automatically.
filterHashKey(data,key)
Walks a hash/array structure and removes all occurrences of the given key. CODE references get turned into 'true' values and JSON true/false get passed on.
processData(arguments)
take the data from the plug-in screen and process them
getData(arguments)
receive current data for plug-in screen content
reConfigure
re-generate all configuration that does not require direct user input. This function may be called from within action handlers to apply newly acquired data to to the running system.
validateData(arguments)
validate user supplied data prior to acting on it
mergeGrammar
a very simpleminded grammar merger with no recursion. For identical keys, the later instance winns.
varCompiler
returns a compiler sub reference for use in configuration variables or _text sections with perl syntax. The resulting sub will provide access to the a hash called $variableName.
massageConfig($cfg)
allow the plugin to 'massage' the config hash ... doing this requires deep knowledge of the cfg structure ...
renderTemplate(template,destination)
render the given template and write the result into the given file. These templates support the Mojo::Template language enhanced by the command L('Plugin::key')
which looks up values from the config database. The convention is that each plugin writes data in it's own namespace.
If the destination already exists, the method compares the current content with the new one. It will only update the file if the content differs.
The method returns 0 when there was no change and 1 when a new version of the file was written.
These additional command are available to the templates
slurp(file)
getConfigValue(key)
read a config value
setConfigValue(key)
read a config value
system(args)
a version of the system function that makes sure to NOT to inherit any extra filehandles to the kids and sends the output of the call system log file. I would suggest to use this in preference to the normal system function. Especially when launching daemons since Mojo seems to fiddle with $^F and will thus inherit open sockets to child processes.
If the binary name starts with -, the output will be ignored ... this can be necessar for programs starting daemons that do not close their output. Otherwhise you will read the output of the daemon and NOT terminate. We are also using kill 0 to check if the process is still active.
LICENSE
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
COPYRIGHT
Copyright (c) 2013 by OETIKER+PARTNER AG. All rights reserved.
AUTHOR
Tobias Oetiker <tobi@oetiker.ch>
HISTORY
2013-12-16 to 1.0 first version