CAPS Universe documentation
1.0.4
All you need to know to be successful
|
Register a printing service and define its capabilities. More...
A simple example without error handling:
struct caps_pp_handle * caps_pp_instance_create | ( | struct caps_arg_parser * | parser | ) |
Create a provider instance handle
[out] | parser | Where to store an argument parser definition |
This is the first call to be done in order to create a printing provider. All further functions mentioned here depend on its return value.
The returned instance handle is incomplete and needs to be completed via caps_pp_instance_register()
The returned argument parser definition must be used within the application's caps_arg_parser_process() call as its child parser in order to parse the command line arguments for generic libcapsprovider specific and required arguments.
Mainly the parser
will extract the --driver-ini
(e.g. CAPS_DRIVER_INI_NAME) and --parameter-dir
(e.g. CAPS_PARAM_DIRECTORY_NAME) command line parameter settings for further processing in caps_pp_instance_runtime_prepare().
int caps_pp_instance_runtime_prepare | ( | struct caps_pp_handle * | instance | ) |
Prepare the printer driver's run-time configuration from a list of INI files
[in] | instance | Provider instance handle |
0 | on success |
-EINVAL | Insufficient command line parameter information |
negative | errno else |
This is the second call to the library after caps_pp_instance_create().
Since this functions expects already parsed and processed command line arguments you must first use the returned parser
child node from the caps_pp_instance_create() in your local caps_arg_parser_process() call and then call caps_pp_instance_runtime_prepare() as the next step.
The already processed command line parameters are used here to read in the run-time configuration for this specific printing provider/driver and its specific and corresponding printing device.
If this call returns successfully, run-time settings based on the corresponding INI files are available and can be retrieved via caps_pp_instance_runtime_param_get(). This can be used to tweak the printer's information (refer caps_pp_instance_runtime_setup()).
The run-time settings contain the following merged INI file content and - important - in this order:
--driver-ini
parameter--parameter-dir
command line parameter.Since the INI files get merged into one data set, the latter INI file can overwrite key/values from its predecessor.
In case of failure, do not continue to work with instance
, except caps_pp_instance_destroy() - and after that terminate gracefully!
More details can be found in Printing Device INI files hierarchy
The used information expected in the INI files are described in Device Description INI files: section [info], Printing Device Parameters INI files: section [info] for user adaption and Device Description INI files: section [ppd].
int caps_pp_instance_runtime_implant | ( | struct caps_pp_handle * | instance, |
const char * | level, | ||
const char * | section, | ||
const char * | key, | ||
const char * | value | ||
) |
Implant run-time information (development feature)
[in] | instance | Provider instance handle |
[in] | level | INI file's 'level' value ('user', 'defaults' or 'base', refer _caps_pp_get_priorized_option() for details) |
[in] | section | INI file's 'section' value (for example 'info') |
[in] | key | INI file's 'key' value (for example 'name' or 'brief') |
[in] | value | INI file's 'value' value (can be NULL if 'key' is of type boolean) |
0 | on success |
negative | errno else |
This feature is more a developer's feature. It's intended to test a printing driver, without to make the big loop over all kind of INI file setup. It helps to avoid the call to caps_pp_instance_runtime_prepare() and replaces its function.
In case of failure, do not continue to work with instance
, except caps_pp_instance_destroy() - and after that terminate gracefully!
const char * caps_pp_instance_runtime_param_get | ( | struct caps_pp_handle * | instance, |
const char * | section, | ||
const char * | name | ||
) |
Get the value from the specified section/name parameter out of the run-time configuration
[in] | instance | Provider instance handle or instance |
[in] | section | Section name to read the parameter from (can be NULL) |
[in] | name | Name of the parameter |
string | Pointer to the parameter's value |
NULL | If the key does not exist |
This function can be called after caps_pp_instance_runtime_prepare() was called once to retrieve run-time configurations.
To the developer: if you add some keys to make your driver work, don't forget to add some meaningful defaults for these keys to your driver-default INI. And add some documentation, when and why and to what to change these defaults on demand.
void caps_pp_instance_mime_setup | ( | struct caps_pp_handle * | instance, |
const struct caps_supported_mime_list * | mimes | ||
) |
Setup the supported MIME formats for this printing provider
[in] | instance | Provider instance handle |
[in] | mimes | List of nativly supported MIME types |
This is the third call to the library after caps_pp_instance_create().
This call must be done before the call of caps_pp_instance_register(), e.g. the supported MIME types cannot be changed after the registration anymore.
void caps_pp_instance_runtime_setup | ( | struct caps_pp_handle * | instance, |
const struct caps_ppd_base * | cpb | ||
) |
Setup the printer provider's/driver's information
[in] | instance | Provider instance |
[in] | cpb | Printer feature description |
This call can be done more than once. Each call will re-new the corresponding information locally and at the printing coordinator remotely.
Normally this information is static. But maybe your printer can detect any change of its available media at run-time and the driver can read this back. In this case it can forward a new provider's/driver's information to the coordinator on the change.
int caps_pp_instance_register | ( | struct caps_pp_handle * | instance | ) |
Register this printing provider/driver instance at the printing coordinator
[in] | instance | Provider instance handle to register |
0 | on success |
-EIO | Connection to or communication with the CAPS universe service RPC failed |
-EBUSY | Failed to register at the CAPS universe service RPC or some part of the setup seems already done (should not happen!) |
-ENOMSG | Failed to attach to the CAPS universe service notifiers |
-EINVAL | Bad/unexpected reply from the CAPS universe service RPC or printer name is missing |
-ENODEV | Unknown printer ID (should not happen, we're just registering it) |
-EPERM | Permission rejected (should not happen, we're just registering it) |
This is the forth call to the library after caps_pp_instance_create(), caps_pp_instance_runtime_prepare() and caps_pp_instance_mime_setup().
The communication with the printing coordinator:
The full call stack:
void caps_pp_instance_unregister | ( | struct caps_pp_handle * | instance | ) |
Unregister this printing provider/driver instance at the printing coordinator
[in] | instance | Provider instance to unregister |
The internal state of the provider will be set to:
The communication with the printing coordinator:
The full call stack:
void caps_pp_instance_destroy | ( | struct caps_pp_handle * | instance | ) |
Free all provider instance resources
[in] | instance | Provider instance handle to destroy |
If not already done yet, this function will call caps_pp_instance_unregister() as well.
struct caps_ppd_options_table * caps_pp_ppd_options_get | ( | struct caps_pp_handle * | instance | ) |
Get a copy of the instance's default PPD options
[in] | instance | Library instance |
This copy is required to apply the device specific printing parameters to it (for each individual print job). Don't forget to free the returned default PPD options table.
instance
has no PPD options. void caps_pp_instance_domain_add | ( | struct caps_pp_handle * | instance, |
const char * | domain | ||
) |
Add further NLS domains to support more detailed status messages from different sources
[in] | instance | Provider instance |
[in] | domain | NLS domain name to add |
caps_pp_job_state_update() and caps_pp_state_update() can deal with up to two different NLS domains by default to translate a given message into a local language:
But there are additional libraries which can add state messages like libcapsdriver does. Thus, more NLS domains need to be searched in order to support their individual translations.