Commit Graph

355 Commits

Author SHA1 Message Date
Matthias Clasen
20289ad8e1 Fix the value for the print-backends setting
This was broken in the meson conversion, causing
us to default to "" instead of the built print
backends.

Fixes: #3486
2020-12-21 14:10:03 -05:00
Emmanuele Bassi
99e0929d6c build: Use a consistent style for Meson files 2020-12-15 12:46:59 +00:00
Christian Hergert
ee47ddf5fd lpr: fix cast warning 2020-11-18 20:16:40 -08:00
Benjamin Otte
6d7e56bed6 cloudprint: Make compile without warnings 2020-10-27 16:43:34 +01:00
Thomas Lange
0493e89897 Fix the build with cups < 2.2.12
PPD_CUSTOM_UNKNOWN was introduced in cups 2.3.
and has been backported to 2.2.12.
Only handle it when we build against a new enough cups.

Fixes: #2968
2020-10-26 19:16:26 +01:00
Xavier Claessens
1b7a99cb24 Apply 1 suggestion(s) to 1 file(s) 2020-10-22 00:36:23 +00:00
Xavier Claessens
a4aa6d79ad meson: Use feature options for media and print backends
This gracefully disable ffmpeg, gstreamer, cups and cloudprint optional
dependencies when they are not available, while still giving full
control to distributors using -Dauto_features=enabled.
2020-10-17 09:54:47 -04:00
Matthias Clasen
668868fb1f Merge branch 'master' into 'master'
Allow LPR backend to print PDF and PS file formats

See merge request GNOME/gtk!418
2020-10-07 20:51:40 +00:00
Matthias Clasen
028cd1e23a Revert "Fix the build with cups < 2.3"
This reverts commit d761e3cf2c.

I am seeing PPD_CUSTOM_UNKNOWN in the cups headers in our
ci images, and that is cups 2.2.12. So this commit was
mistaken.
2020-10-01 07:59:30 -04:00
Matthias Clasen
c4d350c260 build: Start using meson feature options
Use feature options for things that are optional features,
update the docs.

Visible changes here is that the 'print-backends' option
got renamed to 'print' to go better with 'media', and the
'tracker3' option got renamed to 'tracker'.

For options that have been changed into features, the
syntax now is -Dfeature=enabled or -Dfeature=disabled
or -Dfeature=auto.
2020-08-23 16:45:15 -04:00
Björn Daase
6315cd977c *: Fix spelling mistakes found by codespell 2020-08-21 15:29:34 +02:00
Marek Kasik
5a8f90357d printing: Use original names for remote CUPS printers
CUPS uses resource paths in the form of "printers/printer_name"
or "classes/class_name" so it is enough to remove the "printers/"
or "classes/" prefix and use the string behind it as a name.

There was recently introduced a wrong check for the prefix.
This commit fixes it in the way it was originally intended.
2020-08-20 13:54:02 +02:00
Simon McVittie
afcb9c0e63 cloudprint: Fix redundant declarations
G_DEFINE_DYNAMIC_TYPE declares these functions as static, and
-Werror=redundant-decls won't let us redeclare them. This is the
equivalent of 72c72d0b, but for a different backend.

Signed-off-by: Simon McVittie <smcv@debian.org>
2020-08-08 14:24:31 +01:00
Matthias Clasen
5ecf1431f0 cups: Don't emit a warning if we can't talk to avahi
The g_warning in this case makes the templates test
fail if it can't connect to the system bus (as is the
case for running installed tests in ci).
2020-08-01 23:24:36 -04:00
Matthias Clasen
d761e3cf2c Fix the build with cups < 2.3
PPD_CUSTOM_UNKNOWN was introduced in cups 2.3.
Only handle it when we build against a new enough cups.

Fixes: #2968
2020-07-31 10:01:45 -04:00
Benjamin Otte
3078b180fe Replace "gdouble" with "double" 2020-07-25 00:47:36 +02:00
Benjamin Otte
d375dce9f5 Replace "gchar" with "char" 2020-07-25 00:47:36 +02:00
Benjamin Otte
d7266b25ba Replace "gint" with "int" 2020-07-25 00:47:36 +02:00
Matthias Clasen
06d67d2384 cups: Plug a memory leak
This showed up under asan.
2020-07-09 00:32:17 -04:00
Emmanuele Bassi
979bf5c6fb cups: Use allow/ignore list
Don't use loaded terms like "whitelist" and "blacklist".
2020-06-18 16:58:43 +01:00
Yuri Chornoivan
c0cf839729 Fix minor typos 2020-06-18 10:47:16 +03:00
Martin Blanchard
72c72d0b37 Fix the lpr print backend build (redundant-decls)
Class and instance _init() functions are already declared by
G_DEFINE_DYNAMIC_TYPE ().
2020-06-14 16:14:24 +02:00
Chun-wei Fan
acd9c12667 modules: Fix build on Visual Studio
Visual Studio does not allow decorating functions with '__declspec (dllexport)'
if a prototype exists and is not decorated with '__declspec (dllexport)' as
well, so we cannot just decorate g_io_module_[load|unload|query] in the various
module sources with G_MODULE_EXPORT because the prototypes of these functions
have been marked with _GLIB_EXTERN, which equates to 'extern' unless overridden

Fix this by overriding _GLIB_EXTERN with the appropriate visibility flag, as we
have used to define _GDK_EXTERN.  Unfortunately, we can't just use _GDK_EXTERN
G_MODULE_EXPORT as they may have not been defined yet for our use

Do this across the board for all modules, even if they are not buildable on
Visual Studio nor Windows, for consistency's sake.
2020-06-05 11:16:45 +08:00
Yuri Chornoivan
01bd4cc4e1 Fix minor typos 2020-05-28 11:00:03 +03:00
Matthias Clasen
92d42d4b67 printing: Drop a redundant assignment
This showed up as a warning in static analysis in ci.
2020-05-25 20:56:09 -04:00
Qiu Wenbo
340a8e11b0 Build media backends with common_cflags and export the symbol
Fixes: #2771
2020-05-22 17:00:06 +08:00
Timm Bäder
20b906cee8 Build print backends with common_cflags 2020-05-19 08:32:33 +02:00
Timm Bäder
3bf4c5687c Pass common_cflags to print backends 2020-05-19 08:32:33 +02:00
Emmanuele Bassi
18c11ac94f cups: Disable deprecation warnings
It seems newer releases of CUPS removed the ability to disable
deprecation warnings by defining a pre-processor symbol, so we
have to resort to the usual begin/end ignore deprecation pragmas
to avoid a ton of deprecation warnings.
2020-04-17 23:38:06 +01:00
WGH
de9f0c5505 printing: Fix crash in avahi_service_resolver_cb
printer_name_compressed_strv is NULL-terminated array
of gchar*, which means N+1 memory should be allocated.

Otherwise, if the printer name has no empty components
(which is usually the case), printer_name_compressed_strv[N],
which should contain the NULL sentinel, will actually lie
just outside of allocated memory, which is UB.

In my case, it led to crashes inside g_strjoinv
when Print... dialog is opened in evince.

    #0  0x00007fad2ce1bad7 in __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:96
    #1  0x00007fad2d04d88d in g_strjoinv (separator=separator@entry=0x7fad0c9bc508 "-", str_array=str_array@entry=0x556b017f0200) at ../glib-2.60.7/glib/gstrfuncs.c:2585
    #2  0x00007fad0c9b8a89 in avahi_service_resolver_cb (source_object=<optimized out>, res=<optimized out>, user_data=0x7fad08020ee0) at /var/tmp/portage/x11-libs/gtk+-3.24.13/work/gtk+-3.24.13/modules/printbackends/cups/gtkprintbackendcups.c:3223
    #3  0x00007fad2d1f8ed3 in g_task_return_now (task=0x556b017a8b00 [GTask]) at ../glib-2.60.7/gio/gtask.c:1209
    #4  0x00007fad2d1f987d in g_task_return (task=0x556b017a8b00 [GTask], type=<optimized out>) at ../glib-2.60.7/gio/gtask.c:1278
    #5  0x00007fad2d1f9dec in g_task_return (type=G_TASK_RETURN_SUCCESS, task=<optimized out>) at ../glib-2.60.7/gio/gtask.c:1678
    #6  0x00007fad2d1f9dec in g_task_return_pointer (task=<optimized out>, result=<optimized out>, result_destroy=<optimized out>) at ../glib-2.60.7/gio/gtask.c:1683
    #7  0x00007fad2d24b6af in g_dbus_connection_call_done (source=<optimized out>, result=0x556b017a8bc0, user_data=0x556b017a8b00) at ../glib-2.60.7/gio/gdbusconnection.c:5747
    #8  0x00007fad2d1f8ed3 in g_task_return_now (task=0x556b017a8bc0 [GTask]) at ../glib-2.60.7/gio/gtask.c:1209
    #9  0x00007fad2d1f8f09 in complete_in_idle_cb (task=0x556b017a8bc0) at ../glib-2.60.7/gio/gtask.c:1223
    #10 0x00007fad2d02d2c0 in g_main_dispatch (context=0x556b00eee090) at ../glib-2.60.7/glib/gmain.c:3189
    #11 0x00007fad2d02d2c0 in g_main_context_dispatch (context=context@entry=0x556b00eee090) at ../glib-2.60.7/glib/gmain.c:3854
    #12 0x00007fad2d02d658 in g_main_context_iterate (context=context@entry=0x556b00eee090, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../glib-2.60.7/glib/gmain.c:3927
    #13 0x00007fad2d02d6df in g_main_context_iteration (context=context@entry=0x556b00eee090, may_block=may_block@entry=1) at ../glib-2.60.7/glib/gmain.c:3988
    #14 0x00007fad2d22248d in g_application_run (application=0x556b0116f130 [EvApplication], argc=<optimized out>, argv=<optimized out>) at ../glib-2.60.7/gio/gapplication.c:2519
    #15 0x0000556b002e55a1 in  ()
    #16 0x00007fad2ccd6f1b in __libc_start_main (main=0x556b002e50d0, argc=2, argv=0x7ffe1057fa88, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffe1057fa78) at ../csu/libc-start.c:308
    #17 0x0000556b002e567a in  ()

    (gdb) p printer_name_compressed_strv[0]
    $4 = (gchar *) 0x556d4a4be430 "Brother"
    (gdb) p printer_name_compressed_strv[1]
    $5 = (gchar *) 0x7f9dbc011090 "MFC"
    (gdb) p printer_name_compressed_strv[2]
    $6 = (gchar *) 0x556d4a51ba50 "7860DW"
    (gdb) p printer_name_compressed_strv[3]
    $7 = (gchar *) 0x401 <error: Cannot access memory at address 0x401>
2020-01-23 20:32:05 +03:00
Robert Ancell
83867f9cbf Add missing (closure) GIR annotations 2020-01-13 14:26:50 +13:00
Marek Kasik
6ddc214e68 printing: Fill device URI for non-Avahi printers
Device URI was not filled for non-Avahi printers by my previous commit.
I've added it back. It was a mistake during rebasing of the patch
to current master.
2019-12-13 17:53:14 +01:00
Marek Kasik
a6e3fc2d2f printing: Fix getting info for standalone IPP printers
Create printer name from name of the advertised service
for standalone IPP printers as opposed to CUPS printers
advertised via Avahi which get name from their
resource path.
This is similar to what cups-filters does.

Pass GtkPrinter class to request for printer info
so that it does not need to be searched for
(such search could fail for standalone IPP printers).

https://gitlab.gnome.org/GNOME/gtk/issues/1509
2019-12-12 17:08:30 +01:00
Marek Kasik
e54049bc26 printing: Don't show Rejecting Jobs when we don't know
Set reasonable default values for printers discovered
by Avahi which do not have 'printer-type' attribute.
This is the case for network printers which were not
published by CUPS.

Related to the issue #1509.
2019-12-12 17:08:30 +01:00
Marek Kasik
58cfa3fd49 printing: Get PPD from original host if needed
Try to get PPD from original host if there is no PPD for remote printer
on current CUPS server.
2019-09-19 18:35:23 +02:00
Christoph Reiter
72814c54a8 meson: cups: use cups-config for looking up cups
We were looking for the cups headers and the cups lib in the default locations
which for example breaks with OpenBSD where the cups headers are under /usr/local/include/

Instead just use the "cups" dependency type from meson which internally uses cups-config.

See #1967

Ported to master from !963
2019-07-01 21:52:06 +02:00
Christoph Reiter
4d4e02c9d0 build/cups: remove checks for httpGetAuthString and http_t.authstring
httpGetAuthString() was added with cups 1.3 and we depend on a newer version
now. The direct field access was a fallback in case httpGetAuthString()
was missing, so this can also be dropped.

Ported to master from !938
2019-07-01 21:34:44 +02:00
Matthias Clasen
15f4c40a91 Rename gtkprintbackend.h to gtkprintbackendprivate.h
Follow the naming convention for private headers.
2019-05-26 22:23:52 +00:00
Matthias Clasen
cb2369bf70 Rename gtkprinter-private.h
Name this header gtkprinterprivate.h, following
our convention for private headers.
2019-05-26 16:29:57 -04:00
Emmanuele Bassi
3377133d19 Require CUPS >= 2.0
Drop support for versions of CUPS < 2.0, to simplify the backend code
and drop a lot of conditional blocks.
2019-05-07 18:30:47 +02:00
Emmanuele Bassi
ed31ea3773 cups: Use non-deprecated API
The http* family of functions was deprecated after CUPS 1.7. We can
conditionally use it when built against a newer version of CUPS. The
additional parameters are taken directly from the fallback values
inside CUPS itself.
2019-05-07 18:30:47 +02:00
Emmanuele Bassi
feddf5a694 Detect CUPS ≥ 1.7
We support CUPS ≥ 1.2, but we use API that was introduced and deprecated
at a later point.
2019-05-07 18:30:47 +02:00
Till Kamppeter
c6ea37144c print: Check unknown option values whether they are actually custom settings
Additional code improvements and fixes:

- Use g_regex_match_simple() instead of sscanf()
- Added spaces between function names and left parantheses
- Set always correct custom page size
- Added page_setup field to CupsOptionsData data structure
- Replaced tab indentions by spaces
- Moved #define out of add_cups_options() function, removed line breaks from regular expressions
2019-04-04 16:39:18 +00:00
Emmanuele Bassi
1b6734346c modules: Drop the plus
Use 'GTK' consistently.
2019-02-05 10:30:33 +01:00
Sean Farley
99dfdfcd5e Allow LPR backend to print PDF and PS file formats
At least from GTK v3.22.30, the code disallows attempts to print PDF and
PS files using the LPR backend. Although it is not easy or possible for
GTK to determine if the printer can print these formats by querying lpr,
the print backend should allow lpr to try.

There are two uses cases:
- A filter is being used by lpr, specified in the printcap file, to process the
  files prior to printing them.
- The printer can print PDF and PS files directly. There are many printers that
  can print these formats, so GTK should allow for the possibility.
2018-11-17 13:04:35 -05:00
Matthias Clasen
8755d884f3 Remove a lot of Since annotations
4.0 will represent a clean epoch. We don't want to have
lots of noise in the docs about 2.x or 3.x.
2018-06-25 19:55:04 -04:00
Mohammed Sadiq
fd4bfd5050 build: Fix compiler warnings 2018-06-11 21:12:41 +05:30
Adrian Johnson
b0bb7f3da4 Add gtk_printer_get_hard_margins_for_paper_size
to retreive paper size specific hard margins and use this
to set the hard margins in the print context.
(modified by Marek Kasik <mkasik@redhat.com>)

https://bugzilla.gnome.org/show_bug.cgi?id=686109
2018-04-26 14:19:55 +02:00
Emmanuele Bassi
14c8a603e3 Terminate strncpy() buffers correctly
When using strncpy() with a buffer we need to account for the
terminating NUL character. GCC 8 started warning when using PPD_MAX_NAME
as the buffer length for strncpy() because the buffer we're copying into
has the same length — which means that the terminating NUL may be
skipped if the source string has a length of PPD_MAX_NAME.

The appropriate way to handle the case where we're copying a source with
a length bigger than of PPD_MAX_NAME is, as reported in the strncpy()
documentation, to copy `PPD_MAX_NAME - 1` bytes, and explicitly NUL
terminate the destination buffer. This has the additional benefit of
avoiding the compiler warning.
2018-04-10 14:54:45 +01:00
Benjamin Otte
87fa7ff314 build: Fix printbackends
There's no "auto" option anymore, so remove checks for that option.
2018-03-18 19:08:28 +01:00