CAPS Universe documentation  1.0.4
All you need to know to be successful
Functions

Report printing provider's state. More...

Functions

int caps_pp_state_update (struct caps_pp_handle *instance, enum caps_printing_provider_state state, enum caps_printing_provider_reason reason, const char *message)
 

Detailed Description

Talk to the printing coordinator to inform it about the state of a printing device or the printing provider/driver itself

If you have retrieved a new job and "starting the engines":

@ LIBCAPS_PP_REASON_NONE
Definition: libcapsppcommon.h:157
@ LIBCAPS_PP_STATE_PREPARING
Definition: libcapsppcommon.h:144
int caps_pp_state_update(struct caps_pp_handle *instance, enum caps_printing_provider_state state, enum caps_printing_provider_reason reason, const char *message)
Definition: libcapsprovider.c:283

If you start to process the print job:

@ LIBCAPS_PP_STATE_PROCESSING
Definition: libcapsppcommon.h:145

If you have finished the last print job:

@ LIBCAPS_PP_STATE_IDLE
Definition: libcapsppcommon.h:143

If you miss media to print on:

@ LIBCAPS_PP_REASON_MEDIA_NEEDED
Definition: libcapsppcommon.h:159
@ LIBCAPS_PP_STATE_STOPPED
Definition: libcapsppcommon.h:142
Note
In this case no more print jobs will be queued for your printer until you leave this state again.

If your devices detects some media jam:

const char *message = NLS_("Open reverse cover and remove media");
@ LIBCAPS_PP_REASON_MEDIA_JAM
Definition: libcapsppcommon.h:160
#define NLS_(string)
National Language Support related.
Definition: libcapsbase-local.h:61
Note
This example also reports a possible solution for the user. It shows as well how NLS works, by marking the help text with NLS_(…).

Sometimes the attention of the user is required. The printing provider still works as expected, but announces the need for attention with the LIBCAPS_PP_REASON_ATTENTION reason. Since this reason requires an explaining message, for a user attention both is required.

Example: the printer device is low on ink/toner

This attention can be combined with all other activity unless the reason is used otherwise.

const char *message = NLS_("Low on ink and need some love");
@ LIBCAPS_PP_REASON_ATTENTION
Definition: libcapsppcommon.h:158

Example: the printer device is out of ink/toner and cannot continue

const char *message = NLS_("Out of ink and need more love");

Function Documentation

◆ caps_pp_state_update()

int caps_pp_state_update ( struct caps_pp_handle instance,
enum caps_printing_provider_state  state,
enum caps_printing_provider_reason  reason,
const char *  message 
)

Update the printing provider's/driver's state to inform clients

Parameters
[in]instanceProvider instance
[in]stateThe printer's new state
[in]reasonThe new reason for this state
[in]messageAn optional message (can be NULL, read precondition below)
Return values
0on success
-ENODEVPrinter is already gone (should not happen, maybe related to -EPERM)
-EPERMCalling provider isn't the owner of this printer or print job

This call is a simple 'report' type. It is for information only (e.g. printer is idle for example). Refer Printer State Definitions for state details.

Note
The human readable message contained in message should be in plain english, but you should mark it as a translateable string if it is very special. This function tries to translate this message into the local language first by using the printing provider's NLS domain and then by it's own NLS domain (if it is a common sentence shared by all printing providers for example).

Refer Common Printer State Messages already translated messages.

Attention
The new state is limited to one of the active states. Refer Printer State Definitions for ActiveState and TearDownState for details.
Note
If the preconditions aren't met, this function does not return (intentional)
Precondition
state must be valid
If reason is LIBCAPS_PP_REASON_ATTENTION a detailed message must provided
The application needs to activate NLS via setlocale() to make this translation mechanism work
Postcondition
This call dispatches a provider change notifier on the DBUS interface.

Developer's corner

The communication with the printing coordinator:

The full call stack:

Note
Counterpart is dbus_SetPrinterState_dispatch()