Example #1
0
static int _dest_cb(void *user_data, unsigned flags, cups_dest_t *dest)
{
  const dt_prtctl_t *pctl = (dt_prtctl_t *)user_data;
  const char *psvalue = cupsGetOption("printer-state", dest->num_options, dest->options);

  // check that the printer is ready
  if (psvalue!=NULL && strtol(psvalue, NULL, 10) < IPP_PRINTER_STOPPED)
  {
    dt_printer_info_t *pr = dt_get_printer_info(dest->name);
    if (pctl->cb) pctl->cb(pr, pctl->user_data);
    free(pr);
  }
  else
    dt_print(DT_DEBUG_PRINT, "[print] skip printer %s as stopped\n", dest->name);

  return 1;
}
Example #2
-1
GList *dt_get_printers(void)
{
  cups_dest_t *dests;
  int num_dests = cupsGetDests(&dests);
  int k;
  GList *result = NULL;

  for (k=0; k<num_dests; k++)
  {
    const cups_dest_t *dest = &dests[k];
    const char *psvalue = cupsGetOption("printer-state", dest->num_options, dest->options);

    // check that the printer is ready
    if (strtol(psvalue, NULL, 10) < IPP_PRINTER_STOPPED)
    {
      dt_printer_info_t *pr = dt_get_printer_info(dest->name);
      result = g_list_append(result,pr);
    }
    else
      dt_print(DT_DEBUG_PRINT, "[print] skip printer %s as stopped\n", dest->name);
  }

  cupsFreeDests(num_dests, dests);

  return result;
}