Commit graph

87 commits

Author SHA1 Message Date
Tobias Wiese
284ddccf0e printers: Fix size calculation for normalized printer name
The worst-case size of the normalized printer name is twice the
original length (if a space is inserted between each character) plus one
byte for the terminating null byte.

Fixes #2619

Signed-off-by: Tobias Wiese <tobias@tobiaswiese.com>
2023-08-24 10:15:24 +02:00
Robert Ancell
f9fd2587ca printers: Fix missing const on string parameter 2022-05-11 12:16:25 +12:00
Corey Berla
df51bed16c printers: Check for invalid characters in printer names
Currently when you rename a printer through the print details page
there is no indication of errors produced by CUPS, most notable
about any invalid characters used. Adds a function to check
for invalid characters and shows a warning to users.  No
attempt will be made to rename the printer if it contains an
invalid character.  Users are currently shown an elevation prompt
before this fix
https://www.cups.org/doc/man-lpstat.html

Partially addresses #1008
2022-05-10 05:11:51 +00:00
Robert Ancell
2ee5f1422a printers: Ensure PPD copy is always deleted 2021-02-15 10:34:32 +13:00
Robert Ancell
797c36dc0a printers: Improve memory management of backend list 2021-02-15 10:34:32 +13:00
Robert Ancell
5b086c44e8 printers: Don't pass ownership in get_all_ppds_async callback 2021-02-15 10:34:32 +13:00
Robert Ancell
98fd38278a printers: Don't pass ownership in get_ipp_attributes_async callback 2021-02-15 10:34:32 +13:00
Robert Ancell
d970ae48b4 printers: Don't pass ownership in get_ppd_names_async callback 2021-02-15 10:34:32 +13:00
Robert Ancell
0d913f7283 printers: Remove use of goto 2021-02-15 10:34:32 +13:00
Robert Ancell
cede2f5a81 printers: Use g_autoptr for utility functions 2021-02-15 10:34:32 +13:00
Robert Ancell
005b18f2f1 printers: Make helper functions for callback data 2021-02-15 10:34:32 +13:00
Robert Ancell
7bbbef5fde printers: Fix autoptr object not being initialized to NULL.
Won't cause a problem in this case but should be done for safety.

Introduced in ad226b420c
2020-11-02 09:25:04 +13:00
Robert Ancell
509beee6dc printers: Fix leak of printer name in callbacks.
printer_set_ppd_async and printer_set_ppd_file_async copy the printer name, but
this isn't freed in any cases that use these callback (the string isn't even
used at all).
2020-10-29 23:10:05 +00:00
Robert Ancell
ad226b420c printers: Use g_autoptr with GThread 2020-10-30 11:42:14 +13:00
Robert Ancell
5f4599d649 printers: Don't pass GFile references around
An internal GTask will hold a reference to it for the duration of the async call.
2020-09-22 21:23:04 +00:00
Robert Ancell
f3bf0080d7 printers: Don't pass GDBusConnection references around
An internal GTask will hold a reference to it for the duration of the async call.
2020-09-22 21:23:04 +00:00
Robert Ancell
b2c5056031 printers: Use g_autoptr 2020-09-22 21:23:04 +00:00
Robert Ancell
ec23d22ada printers: Use g_clear_object 2020-09-22 21:23:04 +00:00
Yuri Chornoivan
e7050ab6f4 Fix minor typos 2020-07-20 10:38:09 +03:00
Robert Ancell
bc648d9c92 printers: Replace PpDevicesList with standard GPtrArray 2020-07-20 14:14:44 +12:00
Robert Ancell
02d001564a printers: Simplify D-Bus error case branches 2020-03-30 03:24:58 +00:00
Robert Ancell
e256dd57c3 printers: Replace D-Bus unrefs with g_autoptr
This case could leak the GDBusConnection
2020-03-30 03:24:58 +00:00
Robert Ancell
6b79e7ffa1 printers: Replace D-Bus unrefs with g_autoptr 2020-03-30 03:24:58 +00:00
Robert Ancell
2b9815dbf8 printers: Remove unnecessary checks on result of g_variant_get
This always returns a value or hits an assertion.
2020-03-30 03:24:58 +00:00
Robert Ancell
815db8f404 printers: Replace explicit g_variant_unref calls with g_autoptr 2020-03-30 03:24:58 +00:00
Robert Ancell
3a7533da1b printers: Use g_autoptr for the results of D-Bus calls 2020-03-30 03:24:58 +00:00
Robert Ancell
67074b7aea printers: Fix GVariantIter leaks 2020-03-30 03:24:58 +00:00
Robert Ancell
9065850b92 printers: Replace g_variant_iter_next_value with the simpler g_variant_iter_next 2020-03-30 03:24:58 +00:00
Philip Chimento
389ee0dfe5 printers: Use CUPS httpConnect2() if available
In CUPS 1.7 httpConnect() and httpConnectEncrypt() were deprecated and
replaced with httpConnect2(). This checks if httpConnect2() is available
and if so, replaces the uses of the deprecated functions.

In the CUPS source code, httpConnect() and httpConnectEncrypt() are now
wrappers around httpConnect2(), so we make sure to use the same
arguments as in the CUPS source code so the two code paths are sure to
be identical:
2c030c7a06/cups/http.c (L412)
2c030c7a06/cups/http.c (L477)
2019-09-16 14:09:40 -07:00
Robert Ancell
e9b9966e7d printers: Use g_autoptr with strings 2019-02-05 10:26:15 +13:00
Robert Ancell
fb09d9c090 printers: Use g_error_matches where appropriate 2018-12-10 10:13:28 +13:00
Robert Ancell
877445cbaf printers: Use g_autoptr for GError handling 2018-09-17 15:19:21 +00:00
Robert Ancell
09465579b7 printers: Use const for manufacturer string 2018-08-02 10:02:15 +00:00
Felipe Borges
1df4da54fc printers: Drop cups_get_jobs_async
pp_printer_get_jobs_async does the job with more modern GLib API
(GTask).

https://bugzilla.gnome.org/show_bug.cgi?id=779313
2017-03-06 16:07:07 +01:00
Felipe Borges
16d32c4e33 printers: renew cups subscriptions asynchronously
https://bugzilla.gnome.org/show_bug.cgi?id=748336
2016-03-10 11:04:27 +01:00
Felipe Borges
9f9c63fe8d printers: cancel cups subscriptions asynchronously
https://bugzilla.gnome.org/show_bug.cgi?id=748336
2016-03-02 17:16:15 +01:00
Felipe Borges
8baaa81a39 printers: redesign the Printer Jobs Dialog
Update the Printer Jobs Dialog to match the current designs at
https://wiki.gnome.org/Design/SystemSettings/Printers

https://bugzilla.gnome.org/show_bug.cgi?id=755626
2016-01-21 15:08:05 +01:00
Marek Kasik
cb07ee03a0 printers: Use GtkListStore for device list
Remove the GList holding printing devices and use already present
GtkListStore for this in the New printer dialog.

This avoids us to install wrong printer when there is more devices
with the same name since we have GtkTreeIter of the selected row.

Use GtkTreeModelFilter for filtering of current devices.

Update test for canonicalize_device_name() since I had to change one
of its parameters.

https://bugzilla.gnome.org/show_bug.cgi?id=749830
2015-08-03 16:56:41 +02:00
Marek Kasik
60bf057bab printers: Merge device-class and is-network-device properties
'device-class' property of PpPrintDevice can contain "network"
or "direct" values. This information can be stored in already
present property 'is-network-device' as well.

https://bugzilla.gnome.org/show_bug.cgi?id=749830
2015-07-30 16:28:09 +02:00
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