Commit graph

48 commits

Author SHA1 Message Date
Marek Kasik
7b21b22eef printers: Make PpPrintDevice a regular class
Create class PpPrintDevice with properties taken
from the original PpPrintDevice structure.

https://bugzilla.gnome.org/show_bug.cgi?id=749830
2015-07-30 16:28:06 +02:00
Marek Kasik
880cc01550 printers: Don't show the same device multiple times
Pass all discovered devices to 'GroupPhysicalDevices' instead of just
the devices already present in the list and the newly discovered ones.
Replace an existing device in the list if there is a better device
(e.g. replace 'usb:' by 'hp:' device).

https://bugzilla.gnome.org/show_bug.cgi?id=693186
2015-07-13 12:07:59 +02:00
Marek Kasik
b02f7722dd printers: Check whether we have a device name
Check whether we've been able to find a usable name of given device
to avoid dereference of NULL in canonicalize_device_name().

https://bugzilla.gnome.org/show_bug.cgi?id=749896
2015-07-13 11:21:53 +02:00
Marek Kasik
b5b421288c printers: Fix setting of page size
Set 'PageSize' instead of 'media' for new printers since we use PPD
for construction of the combo for selecting of default paper size.
Previously, we've been setting 'media' attribute for new printers.
Attribute 'media' is used by IPP but we set paper size using 'PageSize'
which comes from PPD in the options dialog. Sometimes (quite often) IPP
gets priority over PPD in print systems. Therefore there was inconsistency
of what user set as default paper size on the options dialog and what was used.

Also don't mark IPP and user's local options as default in PpPPDOptionWidget
since it should use just PPD (we can change PPD values only in this widget).
Since we use PPD for setting of paper size in the options dialog, we shouldn't
show a value which user does not change actually (IPP's 'media' vs. PPD's
'PageSize').

https://bugzilla.gnome.org/show_bug.cgi?id=748569
2015-06-12 16:23:45 +02:00
Marek Kasik
80dce1ee4c printers: Remove unused function
Function printer_set_default_media_size() is not used anywhere
in Printer panel.

https://bugzilla.gnome.org/show_bug.cgi?id=748569
2015-06-12 16:23:42 +02:00
Marek Kasik
994bc0735a printers: Strip redundant strings from found devices
Remove strings like "foomatic", "series" from names of found devices.
Remove leading, trailing and recurrent dashes.

https://bugzilla.gnome.org/show_bug.cgi?id=695564
2014-07-31 11:44:17 +02:00
Marek Kasik
88fa618aca printers: Add function shift_string_left() and its test
shift_string_left() shifts given string by 1 character to the left.
test-shift.c tests whether function shift_string_left() works correctly.

https://bugzilla.gnome.org/show_bug.cgi?id=695564
2014-07-31 11:44:17 +02:00
Marek Kasik
6576db1a16 printers: Make pp_devices_list_free() generally available
Move pp_devices_list_free() to pp-utils.h and optimize it
using g_list_free_full().

https://bugzilla.gnome.org/show_bug.cgi?id=695564
2014-07-31 11:44:16 +02:00
Marek Kasik
375c5b0086 printers: Separate canonicalization of device name
Move code for canonicalization of device names to
a separate function for reusability.

https://bugzilla.gnome.org/show_bug.cgi?id=695564
2014-07-31 11:44:16 +02:00
Marek Kasik
190d27b8aa printers: Merge TDevice into PpPrintDevice
PpPrintDevice has grown quite a lot since its introduction.
It contains almost all members of TDevice now.
Merging members of TDevice into PpPrintDevice saves us some work
and allows us to process TDevice's data out of pp-new-printer-dialog.c.

https://bugzilla.gnome.org/show_bug.cgi?id=695564
2014-07-31 11:44:16 +02:00
Marek Kasik
3bd0ba44ae printers: Define missing constant
Define HTTP_URI_STATUS_OK if compiling against CUPS 1.6 or lower.
(HTTP_URI_OK was renamed to HTTP_URI_STATUS_OK in CUPS 1.7.)

https://bugzilla.gnome.org/show_bug.cgi?id=725662
2014-03-04 16:47:11 +01:00
Marek Kasik
fc0a68430f printers: Set hostname for devices with no hostname
Guess hostname of found device if it was not provided before.

CUPS browses its printers as "PrinterName @ ComputerName" or
"PrinterInfo @ ComputerName" through DNS-SD. Get the last part
of that string and set it as hostname.

HPLIP printers have URIs of form
hp:/net/PrinterModel?ip=IPAddress&port=Port or
hp:/net/PrinterModel?ip=IPAddress.

URIs of other protocols are parsed by httpSeparateURI().

https://bugzilla.gnome.org/show_bug.cgi?id=693183
2014-02-26 12:09:36 +01:00
Marek Kasik
1ed138e957 printers: Remove a memory leak
TDevice and PpPrintDevice structures have "host_name" member which
should be freed too.
2014-01-30 14:21:28 +01:00
Daniel Mustieles
2c5951819d Updated FSF's address 2014-01-29 11:27:38 +01:00
Marek Kasik
8cd8d8bdd2 printers: Show all printer devices
Get devices also from backends which are not hard-coded
in pp-utils.c. This is achieved by searching on all
backends with excluding hard-coded ones in the last search.

https://bugzilla.gnome.org/show_bug.cgi?id=693182
2013-03-14 15:15:36 +01:00
Marek Kasik
76d18ec85d printers: Don't crash after changing an option
Use GCancellable when setting a new value of an option.
This prevents Printers panel from crash caused by
calling of option widget's callback on finalized widget.

https://bugzilla.gnome.org/show_bug.cgi?id=694874
2013-03-04 12:05:18 +01:00
Marek Kasik
2bd01a70d3 printers: Make error messages clearer
Point to cups-pk-helper for errors originating from cups-pk-helper.

https://bugzilla.gnome.org/show_bug.cgi?id=689983
2012-12-10 17:05:56 +01:00
Marek Kasik
a153f43b4e printers: Resolve symlink when passing a PPD to CUPS
root is not able to resolve symlinks in /tmp/ created by ordinary users
because of a new policy and PPDs got from CUPS are symlinks to /etc/cups/ppd/*
placed to /tmp/.
Since we need to pass PPD file of original printer to CUPS when renaming
a printer we resolve given symlink and pass original filename to the CUPS.
2012-11-08 13:39:14 +01:00
Marek Kasik
1eb906515f printers: Use GPLv2+ for files created by Marek Kasik
This commit is related to the bug #683420.
2012-09-11 15:02:26 +02:00
Marek Kasik
a0ad46365f printers: Remove redundant functions
Remove functions which are not used anymore. (#683229)
2012-09-04 14:09:06 +02:00
Marek Kasik
9428b7a641 printers: Set longer timeouts
Set longer timeouts for GetBestDrivers, PrinterAddOption and
PrinterAddOptionDefault. These can take more time than already
specified timeouts. (#683229)
2012-09-04 14:09:06 +02:00
Marek Kasik
c34e282bab printers: Return after callback
Return from get_ppds_attribute_async() right after callback
was called. Otherwise the callback could be called twice. (#683229)
2012-09-04 14:09:06 +02:00
Marek Kasik
6f8b9e8825 printers: Allow printer_get_ppd_async() to get PPD from remote host
Adds host_name and port parameters to printer_get_ppd_async(). If host_name
is NULL then it gets the PPD from local CUPS server. (#683229)
2012-09-04 14:09:05 +02:00
Marek Kasik
8695554557 printers: Make get_paper_size_from_locale() available to other source files
Export get_paper_size_from_locale() in pp-utils.h. (#683229)
2012-09-04 14:09:05 +02:00
Marek Kasik
0cb0dab377 printers: Add async method for listing print devices
This commit adds asynchronous function get_cups_devices_async() which
sequentially executes CUPS' backends and returns found devices
by a callback. (#683229)
2012-09-04 14:09:05 +02:00
Marek Kasik
cc2e15a592 printers: Move common constants to pp-utils.h
Move constants which are used in more than one source file
to pp-utils.h. (#683229)
2012-09-04 14:09:05 +02:00
Jiri Popelka
fa5e27d320 Use CUPS-1.6 IPP API getter/setter functions.
CUPS 1.6 makes various structures private and
introduces these ippGet and ippSet functions
for all of the fields in these structures.
http://www.cups.org/str.php?L3928

We define our own accessors when
building against CUPS < 1.6. (#679759)
(modified by Marek Kasik)
2012-08-08 14:35:58 +02:00
Marek Kasik
c6d8b9c825 printers: Place jobs to separate dialog
This commit places list of jobs to separate dialog. The dialog
is updated through calling of pp_jobs_dialog_update()
from "Printers" panel because the panel is already subscribed
to cups notifications.
2012-08-07 14:09:33 +02:00
Marek Kasik
a6b2db1e17 printers: Cancel async operations properly
Don't call callbacks of async functions called
from Printers panel if they were cancelled.
User data are not valid in that case (rhbz#845496).
2012-08-07 11:54:11 +02:00
Marek Kasik
c272aa5eb5 printers: Don't restrict PPD list
Don't restrict PPD list to PPDs with DeviceIDs only.
Extend dictionary of manufacturers names.
2012-08-02 11:47:39 +02:00
Marek Kasik
7ae3027b47 printer: Add "Options" dialog
Add Options dialog which allows users to set more options than current dialog.
The dialog reads printer's PPD file and add its options to the dialog together
with some preselected IPP options (#678637).
All operations in the dialog are asynchronous.
During implementation of this, the option for setting allowed users was removed
because this is not suitable for this panel (the option is intended for
administrators).
2012-07-16 15:26:33 +02:00
Marek Kasik
dd7479caea printers: Allow users to change printer's PPD file
This commit adds popup window which when activated allows
user to select PPD from local database of installed PPDs,
select directly PPD from filesystem or select one from 3
recommended PPDs (#678637).
The popup is activated by clicking on model field (the panel
has to be unlocked). It starts to search for the best PPDs
available immediately after its popup.
All operations are asynchronous.
2012-07-16 13:53:40 +02:00
Marek Kasik
f87e38441d printers: A little correction of previous commit
Correcting a little typo.
2012-04-13 13:16:08 +02:00
Marek Kasik
5272bcc06d printers: Use PrinterAddOption method to set media size
Use new cups-pk-helper's method PrinterAddOption for setting
default media size for new printers. This fixes problem with
setting default media size (#672694).
2012-04-13 13:09:38 +02:00
Robert Ancell
bda149fdd0 printers: Convert unnecessary use of GDBusProxy to using GDBusConnection directly 2012-03-01 09:34:11 +11:00
Robert Ancell
7dd5ae6b94 printers: Port to GDBus 2012-03-01 09:34:11 +11:00
Marek Kasik
5e4e429cd0 Printers: Use g_error_free() instead of g_clear_error ()
Replace g_clear_error() with more appropriate g_error_free()
where suitable. (#658581)
2012-01-23 16:40:36 +01:00
Marek Kasik
07c7ffaf0c Printers: Show correct hostnames for printers
Show correct hostname for each remote printer. G-c-c gets
it from printer-uri-supported or from device-uri CUPS options now.
It also set 'printer-network' icon for remote printers to have them
easily recognizable from local printers.
2012-01-06 13:08:25 +01:00
Bastien Nocera
e9f95249a9 printers: Fix crasher if a or b are NULL in cmp
If a or b are NULL then (c && d) fails, and both a_normalized
and b_normalized are left uninitialised, possibly causing a crash
when we try to free them later.
2011-10-20 15:36:04 +01:00
Marek Kasik
8951bc41a7 Printers: Use system-config-printer's GetBestDrivers method
If available, use DBus method GetBestDriver which determines the best PPD file
for the given printer. This method is available in system-config-printer
since version 1.3.5 (#654742).
2011-08-02 14:20:29 +02:00
Marek Kasik
47fb197d73 Printers: Remove redundant check
Remove check which is not needed.
2011-06-23 13:39:51 +02:00
Marek Kasik
63edb0dcbe Printers: Include cups/ppd.h explicitly
cups/ppd.h is not included by cups/cups.h since CUPS 1.5.
2011-06-20 17:02:39 +02:00
Marek Kasik
8f4895559a Printers: Allow editing of printer name and location
Use CcEditableEntry for editing name and location of local printers
(#649511).
2011-05-27 13:38:15 +02:00
Marek Kasik
8164c8f7f9 printers: Improve search for PPDs for new devices
Improve logic for selecting PPD from available PPDs.
Try to find the best PPD if there is not an exact match
(rhbz#691808, rhbz#691701).
2011-05-06 12:31:42 +02:00
Marek Kasik
7b830a3c6a printers: Cache PPD files for later use
Don't get PPD file from CUPS server every time user needs
an information from it. Have PPD files stored on disk and
delete them on exit.
2011-04-22 14:30:26 +02:00
Marek Kasik
2b3da7feb8 printers: Set default printer properly
Clean "~/.cups/lpoptions" file before setting default printer
on local CUPS server. Store default printer to "~/.cups/lpoptions"
if we are connected to a remote CUPS server (#646100).
2011-04-12 16:43:36 +02:00
Marek Kasik
3349308ea2 printers: Actualize printer list and job list automatically
This patch makes Printers panel to automatically refresh printers list
when a new printer is added or removed. It is refreshed also when a printer
changes its state (to see changes in paused/unpaused state) (rhbz#691718).
It also automatically refresh list of jobs (and also number of active jobs in
main tab) for actual printer (rhbz#691737).
2011-04-05 15:54:09 +02:00
Marek Kasik
3fb4d4af27 printers: Add dialog for adding new printers
The dialog is able to add printers discovered by cupsGetDevices().
It can also add printers from a remote CUPS server by typing
its address and selecting printer we want to add (#640734).
2011-03-07 17:09:00 +01:00