I am attempting to listen for printer state changes (e.g. paper jam, paused...) The following code gives a "Bad notify-recipient-uri" response, then locks on ippReadFile and does not release when the printer is paused/unpaused.
int main()
{
http_t *http = httpConnectEncrypt(cupsServer(), ippPort(),
cupsEncryption());
ipp_t *request = ippNewRequest(IPP_CREATE_PRINTER_SUBSCRIPTION);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
NULL, "ipp://localhost:631/printers/Generic-text-only");
ippAddString(request, IPP_TAG_SUBSCRIPTION, IPP_TAG_URI, "notify-recipient-uri",
NULL, "cups_test://");
ippAddString(request, IPP_TAG_SUBSCRIPTION, IPP_TAG_KEYWORD, "notify-events",
NULL, "printer-state-changed");
ipp_t *response = cupsDoRequest(http, request, "/");
while (1)
{
ipp_state_t state;
ipp_t *event = ippNew();
while ((state = ippReadFile(0, event)) != IPP_DATA)
{
printf("%s\n","Got Data");
}
printf("%s\n","Repeating");
ippDelete(event);
}
}
After sifting through the printers attributes I found a notify-schemes-supported
attribute set to "dbus". I was not able to change the attribute with IPP_SET_PRINTER_ATTRIBUTES
. Any ideas on how to get this to work?