Re: [Utopia] [patch] HAL backend for CUPS
- From: "John (J5) Palmieri" <johnp redhat com>
- To: Joe Shaw <joeshaw novell com>
- Cc: utopia-list gnome org
- Subject: Re: [Utopia] [patch] HAL backend for CUPS
- Date: Thu, 17 Jun 2004 11:14:34 -0400
On Thu, 2004-06-17 at 10:42, Joe Shaw wrote:
> On Wed, 2004-06-16 at 15:47 -0400, John (J5) Palmieri wrote:
> > Here is a little patch to this that fixes the hal backend so that it
> > uses the first argument (argv[0]) as the URI. There is also a fix that
> > outputs a dummy printer when no printers are found. This is needed
> > because when cups starts up it enumerates the backends by executing them
> > without arguments and parses their output. If no printers are plugged
> > in and hal does not output a dummy printer you will not be able to use
> > lpadmin to add a hal device since it will assume there is no hal
> > backend. In other words the hal:// URI will be filtered out as an
> > invalid URI.
>
> Ugh. I really don't like the idea of having an "Unknown" entry in the
> HAL backend. This was part of the reason why I was doing it in the
> first place, because the USB backend has so many unknown ones that it's
> really ugly (and exposes device nodes to the user...)
This is the way the IPP backend works so that is why I did it.
>
> Does CUPS ever query the backends except initially at startup?
IT looks through the devices and compares the protocol (ex. usb:// or
hal://) to existing devices. If there is no existing devices on the hal
backend then all attempts to set DeviceURI to hal://... fail. Since
backends are only queried at startup if there is no hal device plugged
in it does not register the hal backend. CUPS is broken in this
respect. If it wants to check backends it should have a separate
structure instead of iterating over the known devices. One way to go
about this is as you suggest, check if the backend returned successfully
and if there is no devices (no output) create a dummy device
internally. The other way is to hard code "hal" into the backend
checks. Everything so far is just hacks. The real fix would be to
create a new list of known backends and have it check against that. I
am hesitant to make that sort of change though.
> I
> thought it didn't (my own experiments with USB indicated this), and if
> so the "Unknown" HAL entry probably isn't necessary at all.
> I'm not totally sure, but to me the cleaner way to address the whole
> issue of zero-devices vs. backend-error would be for the code which
> spawns the backends to check the return code of the backend. If it's 0,
> then there are no backends, otherwise some error happened.
>
> The argv[0] thing is weird but it seems fine.
>
> Joe
> > --- cups-1.1.20/backend/hal.c.hal 2004-06-11 16:00:35.000000000 -0400
> > +++ cups-1.1.20/backend/hal.c 2004-06-16 14:16:59.000000000 -0400
> > @@ -66,6 +66,8 @@
> >
> > printer_list = hal_find_device_by_capability (hal_ctx, "printer",
> > &num_printers);
> > + if (num_printers == 0)
> > + printf("direct hal \"Unknown\" \"Hal printing backend\"\n");
> >
> > for (i = 0; i < num_printers; i++) {
> > const char *vendor, *product, *description;
> > @@ -169,7 +171,6 @@
> > unsigned char status; /* Port status (off-line, out-of-paper, etc.) */
> > #endif /* __linux */
> >
> > -
> > /*
> > * Make sure status messages are not buffered...
> > */
> > @@ -201,7 +202,7 @@
> > }
> > else if (argc < 6 || argc > 7)
> > {
> > - fputs("Usage: hal URI job-id user title copies options [file]\n", stderr);
> > + fputs("Usage: URI job-id user title copies options [file]\n", stderr);
> > return (1);
> > }
> >
> > @@ -230,11 +231,11 @@
> > copies = atoi(argv[4]);
> > }
> >
> > - device_file = get_device_file (argv[1]);
> > + device_file = get_device_file (argv[0]);
> >
> > if (device_file == NULL) {
> > fprintf (stderr, "ERROR: Unable to open HAL device \"%s\"\n",
> > - argv[1]);
> > + argv[0]);
> > return 1;
> > }
> >
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]