/*
- * "$Id: printers.c 5373 2006-04-06 20:03:32Z mike $"
+ * "$Id: printers.c 5686 2006-06-21 21:02:56Z mike $"
*
* Printer routines for the Common UNIX Printing System (CUPS).
*
*/
#include "cupsd.h"
+#include <cups/dir.h>
/*
{
int i; /* Looping var */
ipp_attribute_t *attr; /* Attribute data */
+ cups_dir_t *dir; /* Notifier directory */
+ cups_dentry_t *dent; /* Notifier directory entry */
+ cups_array_t *notifiers; /* Notifier array */
+ char filename[1024], /* Filename */
+ *notifier; /* Current notifier */
static const int nups[] = /* number-up-supported values */
{ 1, 2, 4, 6, 9, 16 };
static const ipp_orient_t orients[4] =/* orientation-requested-supported values */
ippAddInteger(CommonData, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
"notify-max-events-supported", MaxEvents);
- /* notify-notify-events-default */
+ /* notify-events-default */
ippAddString(CommonData, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
"notify-events-default", NULL, "job-completed");
- /* notify-notify-events-supported */
+ /* notify-events-supported */
ippAddStrings(CommonData, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
"notify-events-supported",
(int)(sizeof(notify_events) / sizeof(notify_events[0])),
ippAddString(CommonData, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
"notify-pull-method-supported", NULL, "ippget");
- /* TODO: scan notifier directory */
/* notify-schemes-supported */
- ippAddString(CommonData, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
- "notify-schemes-supported", NULL, "mailto");
+ snprintf(filename, sizeof(filename), "%s/notifier", ServerBin);
+ if ((dir = cupsDirOpen(filename)) != NULL)
+ {
+ notifiers = cupsArrayNew((cups_array_func_t)strcmp, NULL);
+
+ while ((dent = cupsDirRead(dir)) != NULL)
+ if (S_ISREG(dent->fileinfo.st_mode) &&
+ (dent->fileinfo.st_mode & S_IXOTH) != 0)
+ cupsArrayAdd(notifiers, _cupsStrAlloc(dent->filename));
+
+ if (cupsArrayCount(notifiers) > 0)
+ {
+ attr = ippAddStrings(CommonData, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "notify-schemes-supported",
+ cupsArrayCount(notifiers), NULL, NULL);
+
+ for (i = 0, notifier = (char *)cupsArrayFirst(notifiers);
+ notifier;
+ i ++, notifier = (char *)cupsArrayNext(notifiers))
+ attr->values[i].string.text = notifier;
+ }
+
+ cupsArrayDelete(notifiers);
+ }
/* number-up-supported */
ippAddIntegers(CommonData, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
dp = (cupsd_printer_t *)cupsArrayNext(Printers))
if (dp != p && (dp->type & CUPS_PRINTER_DEFAULT))
{
- DefaultPrinter = p;
+ DefaultPrinter = dp;
break;
}
}
* Rename the printer...
*/
- cupsdSetStringf(&p->name, name);
+ cupsdSetString(&p->name, name);
/*
* Reset printer attributes...
type;
type = mimeNextType(MimeDatabase))
{
- if (!strcasecmp(type->super, "application") &&
- !strcasecmp(type->type, "octet-stream"))
- continue;
-
snprintf(mimetype, sizeof(mimetype), "%s/%s", type->super, type->type);
if ((filters = mimeFilter(MimeDatabase, type, p->filetype, NULL)) != NULL)
* Add the file formats that can be filtered...
*/
+ if ((type = mimeType(MimeDatabase, "application", "octet-stream")) == NULL ||
+ !cupsArrayFind(p->filetypes, type))
+ i = 1;
+ else
+ i = 0;
attr = ippAddStrings(p->attrs, IPP_TAG_PRINTER, IPP_TAG_MIMETYPE,
"document-format-supported",
cupsArrayCount(p->filetypes) + 1, NULL, NULL);
- attr->values[0].string.text = _cupsStrAlloc("application/octet-stream");
+ if (i)
+ attr->values[0].string.text = _cupsStrAlloc("application/octet-stream");
- for (i = 1, type = (mime_type_t *)cupsArrayFirst(p->filetypes);
+ for (type = (mime_type_t *)cupsArrayFirst(p->filetypes);
type;
i ++, type = (mime_type_t *)cupsArrayNext(p->filetypes))
{
{
char filename[1024]; /* Interface script filename */
cups_file_t *fp; /* Interface script file */
-
+ ipp_attribute_t *attr; /* Attribute data */
/*
/*
- * End of "$Id: printers.c 5373 2006-04-06 20:03:32Z mike $".
+ * End of "$Id: printers.c 5686 2006-06-21 21:02:56Z mike $".
*/