Bug 114402 - Slashes in the printer name lead to unwanted tree leaves.
Summary: Slashes in the printer name lead to unwanted tree leaves.
Status: CLOSED NOT A BUG
Alias: None
Product: kdeprint
Classification: Unmaintained
Component: general (show other bugs)
Version: unspecified
Platform: Unlisted Binaries Linux
: NOR normal
Target Milestone: ---
Assignee: KDEPrint Devel Mailinglist
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-14 16:43 UTC by Tim Hutt
Modified: 2008-12-31 19:07 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Hutt 2005-10-14 16:43:56 UTC
Version:            (using KDE KDE 3.4.2)
Installed from:    Unspecified Linux

For example, create a printer called:

My B/W Printer

And in the KPrintDialog instead of a plain combo box, it has a tree structure:

+My B
`---W Printer

Crazy :-)

I think the fix is in kdelibs/kdeprint/kprintdialog.cpp on line 571 change:

d->m_printers->insertItem(QPixmap(), QString::fromLatin1("--------"));

To:

d->m_printers->insertItem(QPixmap(), QString::fromLatin1("--------"), true);

Though I haven't tested it.
Comment 1 Tim Hutt 2005-10-14 16:46:21 UTC
Err make that:

d->m_printers->insertItem(SmallIcon(it.current()->pixmap(),0,(it.current()->isValid() ? (int)KIcon::DefaultState : (int)KIcon::LockOverlay)),it.current()->name(),false/*sep*/);

to

d->m_printers->insertItem(SmallIcon(it.current()->pixmap(),0,(it.current()->isValid() ? (int)KIcon::DefaultState : (int)KIcon::LockOverlay)),it.current()->name(),true);
Comment 2 Michael Goffioul 2005-10-17 13:06:22 UTC
The fix proposed is not the correct one because it would completely disable the usefulness of the TreeComboBox class. As the class name tells it, this class is a combobox with a treeview instead of a listbox. This is used in kdeprint to be able to show printers and instances (pseudo-printers) in a nice tree view where the instances are children of the real printer. The fix proposed completely disabled this.

The problem here is that the printer name uses a slash (which is used in KMPrinter::name() to separate the printer and the instance name) and this is not forseen in the simple handling in KPrintDialog.

A direct fix is to set the 3rd argument of "insertItem()" depending on the virtualness of the printer, that is KMPrinter::isVirtual(). Indeed, if the printer is not virtual, then it should be a top-level item.

OTOH, a problem still exists if this "My B/W printer" printer has an instance defined on it. Here, the code could probably easily adapted by making smart use of the KMPrinter available functions: printerName(), instanceName(), isVirtual()... For example, TreeComboBox::insertItem() could accept a string list (instead of a string that it has to decompose itself) and KPrintDialog could directly give as list {mPrinter->printerName(),  mPrinter->instanceName()}.

Michael.
Comment 3 Tim Hutt 2006-08-20 20:54:45 UTC
That's a little silly.

Surely whoever wrote KMPrinter::name() would have forseen slashes in printer names.

Anyway, I've never really used virtual printers, but it seems to me that it KMPrinter should do it properly and split the string up into two separate strings rather than one string separated by a /.

I'll leave that for someone else though!
Comment 4 Michael Goffioul 2006-09-04 11:22:36 UTC
The use of the / as a separator comes from CUPS. KDEPrint uses it to be compatible with CUPS, otherwise virtual printers created by KDEPrint would be unusable by CUPS-only applications.
Comment 5 Kurt Pfeifle 2007-01-13 01:08:28 UTC
Tim,

CUPS specifies that its printer names do not allow for slashes. Slashes are reserved to separate printer instances from the main print queue. (Think of a CUPS printer instance as "print job setting profile of a printer that can be used by just using a name".

You may have a main printer "hp". Then you can create printer instances by the name of

  hp/A3paper
  hp/A4duplex
  hp/landscape_A3

and so on (and set all job options as you want them for each instance). This is supported by KDEPrint.

So by far this is not at all a bug, it is a feature to group CUPS instances.

Cheers,
Kurt
Comment 6 John Layt 2008-12-31 19:07:17 UTC
Closing old Resolved status bug.