Merge lp:~ahayzen/qtubuntu-print/empty-branch-for-bileto into lp:qtubuntu-print

Proposed by Andrew Hayzen
Status: Merged
Approved by: Michael Sheldon
Approved revision: 26
Merged at revision: 2
Proposed branch: lp:~ahayzen/qtubuntu-print/empty-branch-for-bileto
Merge into: lp:qtubuntu-print
Diff against target: 1359 lines (+732/-306)
23 files modified
.bzr-builddeb/default.conf (+2/-0)
CMakeLists.txt (+90/-0)
COPYING (+165/-0)
constants.h (+34/-0)
debian/changelog (+2/-2)
debian/control (+19/-10)
debian/copyright (+14/-24)
debian/qtubuntu-print.install (+1/-0)
debian/qtubuntu-print.sh (+7/-0)
debian/rules (+7/-20)
i18n.cpp (+40/-0)
i18n.h (+35/-0)
main.cpp (+22/-19)
pdf-plugin.pro (+0/-28)
po/CMakeLists.txt (+30/-0)
po/qtubuntu-print.pot (+36/-0)
qtubuntu-print.json (+1/-1)
qubuntuprintdevice.cpp (+28/-18)
qubuntuprintdevice_p.h (+22/-19)
qubuntuprintengine.cpp (+85/-81)
qubuntuprintengine_p.h (+24/-22)
qubuntuprintsupport.cpp (+49/-45)
qubuntuprintsupport_p.h (+19/-17)
To merge this branch: bzr merge lp:~ahayzen/qtubuntu-print/empty-branch-for-bileto
Reviewer Review Type Date Requested Status
Michael Sheldon (community) Approve
Ken VanDine packaging Approve
Review via email: mp+312858@code.launchpad.net

Commit message

* Initial commit

Description of the change

* Empty commit

To post a comment you must log in.
3. By Andrew Hayzen

* Set the section to libs

4. By Andrew Hayzen

* Fix build depends, qmake etc for building in clean env

5. By Andrew Hayzen

* Change peer's ID to ubuntu-printing-app

6. By Andrew Hayzen

* Rename everything from pdfsupport/pdfplugin to qtubuntu-print

7. By Andrew Hayzen

* Tweaks to content-hub exporting

8. By Andrew Hayzen

* Define printing app id

Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

The user visible strings in: http://bazaar.launchpad.net/~ahayzen/qtubuntu-print/empty-branch-for-bileto/view/head:/qubuntuprintdevice.cpp need to be translatable

I think you should probably also add a dependency on ubuntu-printing-app since the plugin isn't usable without it.

It might be better to use your Canonical email address for the Maintainer and changelog entries?

review: Needs Fixing
Revision history for this message
Andrew Hayzen (ahayzen) wrote :

I think the fileName that is generated should have a random hash in it, to prevent two identical filenames if two print requests were done rapidly.

In closePrintDevice, the file should probably only be exported when the output filename has been set by us.

I have offline changes that attempt to disable options like copies, collate when using the printing service (as they don't make sense). Will check if they work and if they do include them.

9. By Andrew Hayzen

* Change use of file to use QTemporaryFile
* Only export to content-hub if the outputFilename was set by us
* Update name in copyright to qtubuntu-print
* Update changelog and control to use canonical email address

Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

The #ifdefs for the headers are still named based on the PDF plugin (QPDFSUPPORT_H, QPDFENGINE_H, QPDFDEVICE_H), they should be updated to reflect the new filenames

review: Needs Fixing
10. By Andrew Hayzen

* Fix ifdef names missed in migration to qtubuntu-print

11. By Andrew Hayzen

* Migrate to CMake
* Get translations working
* Ensure use of fully qualified import names

12. By Andrew Hayzen

* Add dh-translations and pkg-config as depends
* FIx debian build not being able to find main.moc

Revision history for this message
Andrew Hayzen (ahayzen) wrote :

I believe I have fixed all the issues, please rereview :-)

Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

All looks good to me now :)

review: Approve
13. By Andrew Hayzen

* Change ubuntu-printing-app to be a recommends of qtubuntu-print

14. By Andrew Hayzen

* Show warning widget when transfer could not be created due to missing ubuntu-printing-app

15. By Andrew Hayzen

* Change dialog title to "Printing Failed"

16. By Andrew Hayzen

* If the transfer state is aborted then it has failed and don't try to charge

Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Changes work nicely :)

review: Approve
Revision history for this message
Ken VanDine (ken-vandine) wrote :

Packaging review:

debian/copyright
  * GPL-3.0+ should really be GPL-3.0. However this is a library so I think LGPL is probably more suitable than GPL, but I'm not a lawyer.
  * If the license and the copyright is the same, you don't need the Files: debian/* section at all.
  * Remove the comments at the bottom, that was meant to be template documentation
  * You need to include a copy of the license with the source, copy the correct license file to COPYING in the root of the project

debian/rules:
  * Please remove any unused code in the file

You need to use split mode to get the sources properly, please add the following file to the project. Look at content-hub for an example:
cat .bzr-builddeb/default.conf
[BUILDDEB]
split = True

review: Needs Fixing (packaging)
17. By Andrew Hayzen

* Add bzr-builddeb config
* Add COPYING to the root of the project
* Remove comments from copyright and rules that aren't needed
* Remove the debian/* section in the copyright it isn't needed
* Change debian/copyright from GPL-3.0+ to GPL-3.0

Revision history for this message
Andrew Hayzen (ahayzen) wrote :

Fixed the issues you have found, I'm going to check with Bill which license he would prefer.

Please rereview :-)

One other thing I wondered is now that we are able to detect when a peer doesn't exist this could first try to export to the snap peer snap.ubuntu-printing-app.ubuntu-printing-app and then to the debian peer ubuntu-printing-app. If both fail then it could show the dialog, what do you think? Also I'm going to check with Bill to see what his plan was regarding how ubuntu-printing-app should be distributed (eg as it's own snap or within the unity8 one).

18. By Andrew Hayzen

* Add script which is installed under /etc/profile.d/ to set QT_PRINTER_MODULE when running under unity8 deb edition

19. By Andrew Hayzen

* Change to using LGPL instead of GPL

20. By Andrew Hayzen

* Change the name to "Ubuntu Printing Service"
* Create a constants.h file which holds consts used across the library
* Regenerate the pot

21. By Andrew Hayzen

* Pass APP_ID as argument so it is not translated

22. By Andrew Hayzen

* Add constants.h file to bzr

Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Changes look good to me :)

review: Approve
23. By Ken VanDine

* Packaging cleanup, mostly just quieting down lintian. I also ran wrap-and-sort to format debian/control to match our other packages

24. By Andrew Hayzen

* Add missing define to prevent loading constants.h twice

25. By Andrew Hayzen

* Re-add qt5-default otherwise qmake command embedded in cmake fails with "qmake: could not find a Qt installation of ''"

26. By Andrew Hayzen

* Remove qt5-default and pass -qt=qt5 to qmake

Revision history for this message
Ken VanDine (ken-vandine) wrote :

Packaging changes look good now

review: Approve (packaging)
Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Changes look good

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory '.bzr-builddeb'
2=== added file '.bzr-builddeb/default.conf'
3--- .bzr-builddeb/default.conf 1970-01-01 00:00:00 +0000
4+++ .bzr-builddeb/default.conf 2017-02-21 14:15:06 +0000
5@@ -0,0 +1,2 @@
6+[BUILDDEB]
7+split = True
8
9=== added file 'CMakeLists.txt'
10--- CMakeLists.txt 1970-01-01 00:00:00 +0000
11+++ CMakeLists.txt 2017-02-21 14:15:06 +0000
12@@ -0,0 +1,90 @@
13+project(qtubuntu-print)
14+cmake_minimum_required(VERSION 2.8.9)
15+
16+# Load translation tools
17+find_program(INTLTOOL_MERGE intltool-merge)
18+if(NOT INTLTOOL_MERGE)
19+ message(FATAL_ERROR "Could not find intltool-merge, please install the intltool package")
20+endif()
21+
22+find_program(INTLTOOL_EXTRACT intltool-extract)
23+if(NOT INTLTOOL_EXTRACT)
24+ message(FATAL_ERROR "Could not find intltool-extract, please install the intltool package")
25+endif()
26+
27+# Set the vars
28+set(CMAKE_AUTOMOC ON)
29+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -Wextra")
30+
31+# Find packages
32+find_package(Qt5Core)
33+find_package(Qt5DBus)
34+find_package(Qt5PrintSupport)
35+find_package(Qt5Widgets)
36+find_package(PkgConfig REQUIRED)
37+pkg_check_modules(CONTENTHUB REQUIRED libcontent-hub)
38+
39+# Replicate qmake CONFIG += plugin
40+add_definitions(${QT_DEFINITIONS})
41+add_definitions(-DQT_PLUGIN)
42+add_definitions(-DQT_NO_DEBUG)
43+add_definitions(-DQT_SHARED)
44+
45+# Disable use of cups in Qt print support
46+add_definitions(-DQT_NO_CUPS)
47+
48+# Setup include directories
49+include(GNUInstallDirs)
50+
51+include_directories(
52+ ${CMAKE_CURRENT_SOURCE_DIR}
53+ ${CMAKE_CURRENT_BINARY_DIR}
54+ ${Qt5Core_INCLUDE_DIRS}
55+ ${Qt5Core_PRIVATE_INCLUDE_DIRS}
56+ ${Qt5DBus_INCLUDE_DIRS}
57+ ${Qt5PrintSupport_INCLUDE_DIRS}
58+ ${Qt5PrintSupport_PRIVATE_INCLUDE_DIRS}
59+ ${LIBCONTENT_HUB_INCLUDE_DIRS}
60+)
61+
62+# Setup the library sources and name
63+set(LIBNAME qtubuntu-print)
64+
65+set(
66+ qtubuntu_print_SRC
67+ constants.h
68+ i18n.cpp
69+ main.cpp
70+ qubuntuprintdevice.cpp
71+ qubuntuprintengine.cpp
72+ qubuntuprintsupport.cpp
73+)
74+
75+add_library(${LIBNAME} SHARED ${qtubuntu_print_SRC})
76+
77+qt5_use_modules(${LIBNAME} Core DBus PrintSupport Widgets)
78+target_link_libraries(${LIBNAME} content-hub)
79+
80+
81+# Install the plugin file
82+execute_process(
83+ COMMAND qmake -qt=qt5 -query QT_INSTALL_PLUGINS
84+ OUTPUT_VARIABLE QT_INSTALL_PLUGINS_DIR
85+ OUTPUT_STRIP_TRAILING_WHITESPACE
86+ )
87+install(TARGETS ${LIBNAME} DESTINATION ${QT_INSTALL_PLUGINS_DIR}/printsupport)
88+
89+
90+# Setup gettext defs and include po directory
91+set(GETTEXT_PACKAGE "qtubuntu-print")
92+add_definitions(-DI18N_DOMAIN="${GETTEXT_PACKAGE}")
93+
94+add_subdirectory(po)
95+
96+
97+# Show files in QtC
98+file(GLOB QTC_FILES
99+ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
100+ *.cpp *.h *.json)
101+
102+add_custom_target(qtubuntu_print_qtc_files DEPENDS main.cpp SOURCES ${QTC_FILES})
103
104=== added file 'COPYING'
105--- COPYING 1970-01-01 00:00:00 +0000
106+++ COPYING 2017-02-21 14:15:06 +0000
107@@ -0,0 +1,165 @@
108+ GNU LESSER GENERAL PUBLIC LICENSE
109+ Version 3, 29 June 2007
110+
111+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
112+ Everyone is permitted to copy and distribute verbatim copies
113+ of this license document, but changing it is not allowed.
114+
115+
116+ This version of the GNU Lesser General Public License incorporates
117+the terms and conditions of version 3 of the GNU General Public
118+License, supplemented by the additional permissions listed below.
119+
120+ 0. Additional Definitions.
121+
122+ As used herein, "this License" refers to version 3 of the GNU Lesser
123+General Public License, and the "GNU GPL" refers to version 3 of the GNU
124+General Public License.
125+
126+ "The Library" refers to a covered work governed by this License,
127+other than an Application or a Combined Work as defined below.
128+
129+ An "Application" is any work that makes use of an interface provided
130+by the Library, but which is not otherwise based on the Library.
131+Defining a subclass of a class defined by the Library is deemed a mode
132+of using an interface provided by the Library.
133+
134+ A "Combined Work" is a work produced by combining or linking an
135+Application with the Library. The particular version of the Library
136+with which the Combined Work was made is also called the "Linked
137+Version".
138+
139+ The "Minimal Corresponding Source" for a Combined Work means the
140+Corresponding Source for the Combined Work, excluding any source code
141+for portions of the Combined Work that, considered in isolation, are
142+based on the Application, and not on the Linked Version.
143+
144+ The "Corresponding Application Code" for a Combined Work means the
145+object code and/or source code for the Application, including any data
146+and utility programs needed for reproducing the Combined Work from the
147+Application, but excluding the System Libraries of the Combined Work.
148+
149+ 1. Exception to Section 3 of the GNU GPL.
150+
151+ You may convey a covered work under sections 3 and 4 of this License
152+without being bound by section 3 of the GNU GPL.
153+
154+ 2. Conveying Modified Versions.
155+
156+ If you modify a copy of the Library, and, in your modifications, a
157+facility refers to a function or data to be supplied by an Application
158+that uses the facility (other than as an argument passed when the
159+facility is invoked), then you may convey a copy of the modified
160+version:
161+
162+ a) under this License, provided that you make a good faith effort to
163+ ensure that, in the event an Application does not supply the
164+ function or data, the facility still operates, and performs
165+ whatever part of its purpose remains meaningful, or
166+
167+ b) under the GNU GPL, with none of the additional permissions of
168+ this License applicable to that copy.
169+
170+ 3. Object Code Incorporating Material from Library Header Files.
171+
172+ The object code form of an Application may incorporate material from
173+a header file that is part of the Library. You may convey such object
174+code under terms of your choice, provided that, if the incorporated
175+material is not limited to numerical parameters, data structure
176+layouts and accessors, or small macros, inline functions and templates
177+(ten or fewer lines in length), you do both of the following:
178+
179+ a) Give prominent notice with each copy of the object code that the
180+ Library is used in it and that the Library and its use are
181+ covered by this License.
182+
183+ b) Accompany the object code with a copy of the GNU GPL and this license
184+ document.
185+
186+ 4. Combined Works.
187+
188+ You may convey a Combined Work under terms of your choice that,
189+taken together, effectively do not restrict modification of the
190+portions of the Library contained in the Combined Work and reverse
191+engineering for debugging such modifications, if you also do each of
192+the following:
193+
194+ a) Give prominent notice with each copy of the Combined Work that
195+ the Library is used in it and that the Library and its use are
196+ covered by this License.
197+
198+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
199+ document.
200+
201+ c) For a Combined Work that displays copyright notices during
202+ execution, include the copyright notice for the Library among
203+ these notices, as well as a reference directing the user to the
204+ copies of the GNU GPL and this license document.
205+
206+ d) Do one of the following:
207+
208+ 0) Convey the Minimal Corresponding Source under the terms of this
209+ License, and the Corresponding Application Code in a form
210+ suitable for, and under terms that permit, the user to
211+ recombine or relink the Application with a modified version of
212+ the Linked Version to produce a modified Combined Work, in the
213+ manner specified by section 6 of the GNU GPL for conveying
214+ Corresponding Source.
215+
216+ 1) Use a suitable shared library mechanism for linking with the
217+ Library. A suitable mechanism is one that (a) uses at run time
218+ a copy of the Library already present on the user's computer
219+ system, and (b) will operate properly with a modified version
220+ of the Library that is interface-compatible with the Linked
221+ Version.
222+
223+ e) Provide Installation Information, but only if you would otherwise
224+ be required to provide such information under section 6 of the
225+ GNU GPL, and only to the extent that such information is
226+ necessary to install and execute a modified version of the
227+ Combined Work produced by recombining or relinking the
228+ Application with a modified version of the Linked Version. (If
229+ you use option 4d0, the Installation Information must accompany
230+ the Minimal Corresponding Source and Corresponding Application
231+ Code. If you use option 4d1, you must provide the Installation
232+ Information in the manner specified by section 6 of the GNU GPL
233+ for conveying Corresponding Source.)
234+
235+ 5. Combined Libraries.
236+
237+ You may place library facilities that are a work based on the
238+Library side by side in a single library together with other library
239+facilities that are not Applications and are not covered by this
240+License, and convey such a combined library under terms of your
241+choice, if you do both of the following:
242+
243+ a) Accompany the combined library with a copy of the same work based
244+ on the Library, uncombined with any other library facilities,
245+ conveyed under the terms of this License.
246+
247+ b) Give prominent notice with the combined library that part of it
248+ is a work based on the Library, and explaining where to find the
249+ accompanying uncombined form of the same work.
250+
251+ 6. Revised Versions of the GNU Lesser General Public License.
252+
253+ The Free Software Foundation may publish revised and/or new versions
254+of the GNU Lesser General Public License from time to time. Such new
255+versions will be similar in spirit to the present version, but may
256+differ in detail to address new problems or concerns.
257+
258+ Each version is given a distinguishing version number. If the
259+Library as you received it specifies that a certain numbered version
260+of the GNU Lesser General Public License "or any later version"
261+applies to it, you have the option of following the terms and
262+conditions either of that published version or of any later version
263+published by the Free Software Foundation. If the Library as you
264+received it does not specify a version number of the GNU Lesser
265+General Public License, you may choose any version of the GNU Lesser
266+General Public License ever published by the Free Software Foundation.
267+
268+ If the Library as you received it specifies that a proxy can decide
269+whether future versions of the GNU Lesser General Public License shall
270+apply, that proxy's public statement of acceptance of any version is
271+permanent authorization for you to choose that version for the
272+Library.
273
274=== added file 'constants.h'
275--- constants.h 1970-01-01 00:00:00 +0000
276+++ constants.h 2017-02-21 14:15:06 +0000
277@@ -0,0 +1,34 @@
278+/*
279+ * Copyright (C) 2017 Canonical Ltd
280+ *
281+ * This file is part of qtubuntu-print.
282+ *
283+ * qtubuntu-print is free software; you can redistribute it and/or modify
284+ * it under the terms of the GNU Lesser General Public License as published by
285+ * the Free Software Foundation; version 3.
286+ *
287+ * qtubuntu-print is distributed in the hope that it will be useful,
288+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
289+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
290+ * GNU Lesser General Public License for more details.
291+ *
292+ * You should have received a copy of the GNU Lesser General Public License
293+ * along with qtubuntu-print. If not, see <http://www.gnu.org/licenses/>.
294+ *
295+ * Authored-by: Andrew Hayzen <andrew.hayzen@canonical.com>
296+ */
297+#include "i18n.h"
298+
299+#ifndef CONSTANTS_H
300+#define CONSTANTS_H
301+
302+QT_BEGIN_NAMESPACE
303+
304+#define APP_ID "ubuntu-printing-app"
305+#define I18N_DOMAIN "qtubuntu-print"
306+#define JSON_KEY "qtubuntu-print"
307+#define PRINTER_NAME __("Ubuntu Printing Service")
308+
309+QT_END_NAMESPACE
310+
311+#endif // CONSTANTS_H
312
313=== modified file 'debian/changelog'
314--- debian/changelog 2016-12-08 18:51:07 +0000
315+++ debian/changelog 2017-02-21 14:15:06 +0000
316@@ -1,5 +1,5 @@
317-qtubuntu-print (0.1-1) unstable; urgency=medium
318+qtubuntu-print (0.1-1) UNRELEASED; urgency=medium
319
320 * Initial release
321
322- -- Andrew Hayzen <ahayzen@gmail.com> Thu, 08 Dec 2016 17:54:28 +0000
323+ -- Andrew Hayzen <andrew.hayzen@canonical.com> Thu, 08 Dec 2016 17:54:28 +0000
324
325=== modified file 'debian/control'
326--- debian/control 2016-12-08 18:51:07 +0000
327+++ debian/control 2017-02-21 14:15:06 +0000
328@@ -1,20 +1,29 @@
329 Source: qtubuntu-print
330-Section: unknown
331+Section: libs
332 Priority: optional
333-Maintainer: Andrew Hayzen <ahayzen@gmail.com>
334-Build-Depends: debhelper (>=9),
335- libcontent-hub-dev,
336- qt5-default,
337- qt5-qmake
338-Standards-Version: 3.9.6
339+Maintainer: Andrew Hayzen <andrew.hayzen@canonical.com>
340+Build-Depends: cmake (>= 2.8.9),
341+ debhelper (>=9),
342+ dh-translations,
343+ libcontent-hub-dev,
344+ libqt5printsupport5,
345+ libqt5widgets5,
346+ pkg-config,
347+ qt5-qmake,
348+ qtbase5-dev,
349+ qtbase5-private-dev
350+Standards-Version: 3.9.7
351 Homepage: http://launchpad.net/qtubuntu-print
352 Vcs-Bzr: https://code.launchpad.net/~phablet-team/qtubuntu-print/trunk
353
354 Package: qtubuntu-print
355 Architecture: any
356-Depends: ${shlibs:Depends}, ${misc:Depends},
357- content-hub,
358- qt5-default
359+Depends: content-hub,
360+ libqt5printsupport5,
361+ libqt5widgets5,
362+ ${misc:Depends},
363+ ${shlibs:Depends}
364+Recommends: ubuntu-printing-app
365 Description: Print plugin for Qt sending PDFs over content-hub
366 A printing plugin for Qt which creates a PDF and sends it
367 over content-hub to a destination app.
368
369=== modified file 'debian/copyright'
370--- debian/copyright 2016-12-08 18:51:07 +0000
371+++ debian/copyright 2017-02-21 14:15:06 +0000
372@@ -1,33 +1,23 @@
373 Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
374-Upstream-Name: qt5-pdf-content-hub-print-plugin
375-Source: <url://example.com>
376+Upstream-Name: qtubuntu-print
377+Source: https://code.launchpad.net/qtubuntu-print
378
379 Files: *
380 Copyright: 2016 Canonical Ltd.
381-License: GPL-3.0+
382-
383-Files: debian/*
384-Copyright: 2016 Canonical Ltd.
385-License: GPL-3.0+
386-
387-License: GPL-3.0+
388+License: LGPL-3
389+
390+License: LGPL-3
391 This program is free software: you can redistribute it and/or modify
392- it under the terms of the GNU General Public License as published by
393- the Free Software Foundation, either version 3 of the License, or
394- (at your option) any later version.
395+ it under the terms of the GNU Lesser General Public License as published by
396+ the Free Software Foundation, either version 3 of the License.
397 .
398 This package is distributed in the hope that it will be useful,
399 but WITHOUT ANY WARRANTY; without even the implied warranty of
400 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
401- GNU General Public License for more details.
402- .
403- You should have received a copy of the GNU General Public License
404- along with this program. If not, see <https://www.gnu.org/licenses/>.
405- .
406- On Debian systems, the complete text of the GNU General
407- Public License version 3 can be found in "/usr/share/common-licenses/GPL-3".
408-
409-# Please also look if there are files or directories which have a
410-# different copyright/license attached and list them here.
411-# Please avoid picking licenses with terms that are more restrictive than the
412-# packaged work, as it may make Debian's contributions unacceptable upstream.
413+ GNU Lesser General Public License for more details.
414+ .
415+ You should have received a copy of the GNU Lesser General Public License
416+ along with this program. If not, see <http://www.gnu.org/licenses/>.
417+ .
418+ On Debian systems, the complete text of the GNU Lesser General
419+ Public License version 3 can be found in "/usr/share/common-licenses/LGPL-3".
420
421=== added file 'debian/qtubuntu-print.install'
422--- debian/qtubuntu-print.install 1970-01-01 00:00:00 +0000
423+++ debian/qtubuntu-print.install 2017-02-21 14:15:06 +0000
424@@ -0,0 +1,1 @@
425+debian/qtubuntu-print.sh etc/profile.d/
426
427=== added file 'debian/qtubuntu-print.sh'
428--- debian/qtubuntu-print.sh 1970-01-01 00:00:00 +0000
429+++ debian/qtubuntu-print.sh 2017-02-21 14:15:06 +0000
430@@ -0,0 +1,7 @@
431+# Exports the QT_PRINTER_MODULE from the qtubuntu-print package
432+
433+case $XDG_SESSION_DESKTOP in
434+ ubuntu-touch|unity8*)
435+ export QT_PRINTER_MODULE=qtubuntu-print
436+ ;;
437+esac
438
439=== modified file 'debian/rules'
440--- debian/rules 2016-12-08 18:51:07 +0000
441+++ debian/rules 2017-02-21 14:15:06 +0000
442@@ -1,25 +1,12 @@
443 #!/usr/bin/make -f
444-# See debhelper(7) (uncomment to enable)
445-# output every command that modifies files on the build system.
446-#export DH_VERBOSE = 1
447-
448-
449-# see FEATURE AREAS in dpkg-buildflags(1)
450-#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
451-
452-# see ENVIRONMENT in dpkg-buildflags(1)
453-# package maintainers to append CFLAGS
454-#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
455-# package maintainers to append LDFLAGS
456-#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
457-
458+
459+export DEB_BUILD_MAINT_OPTIONS=hardening=+all
460+
461+CPPFLAGS:=$(shell dpkg-buildflags --get CPPFLAGS)
462+CFLAGS:=$(shell dpkg-buildflags --get CFLAGS) $(CPPFLAGS)
463+CXXFLAGS:=$(shell dpkg-buildflags --get CXXFLAGS) $(CPPFLAGS)
464+LDFLAGS:=$(shell dpkg-buildflags --get LDFLAGS)
465
466 %:
467 dh $@
468
469-
470-# dh_make generated override targets
471-# This is example for Cmake (See https://bugs.debian.org/641051 )
472-#override_dh_auto_configure:
473-# dh_auto_configure -- # -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)
474-
475
476=== added file 'i18n.cpp'
477--- i18n.cpp 1970-01-01 00:00:00 +0000
478+++ i18n.cpp 2017-02-21 14:15:06 +0000
479@@ -0,0 +1,40 @@
480+/*
481+ * Copyright © 2014, 2017 Canonical Ltd.
482+ *
483+ * This file is part of qtubuntu-print.
484+ *
485+ * qtubuntu-print is free software; you can redistribute it and/or modify
486+ * it under the terms of the GNU Lesser General Public License as published by
487+ * the Free Software Foundation; version 3.
488+ *
489+ * qtubuntu-print is distributed in the hope that it will be useful,
490+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
491+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
492+ * GNU Lesser General Public License for more details.
493+ *
494+ * You should have received a copy of the GNU Lesser General Public License
495+ * along with qtubuntu-print. If not, see <http://www.gnu.org/licenses/>.
496+ *
497+ * Authored by: Ken VanDine <ken.vandine@canonical.com>
498+ * Andrew Hayzen <andrew.hayzen@canonical.com>
499+ */
500+
501+#define NO_TR_OVERRIDE
502+#include "i18n.h"
503+
504+#include <libintl.h>
505+
506+QT_BEGIN_NAMESPACE
507+
508+void initTr(const char *domain, const char *localeDir)
509+{
510+ bindtextdomain(domain, localeDir);
511+ textdomain(domain);
512+}
513+
514+QString __(const char *text, const char *domain)
515+{
516+ return QString::fromUtf8(dgettext(domain, text));
517+}
518+
519+QT_END_NAMESPACE
520
521=== added file 'i18n.h'
522--- i18n.h 1970-01-01 00:00:00 +0000
523+++ i18n.h 2017-02-21 14:15:06 +0000
524@@ -0,0 +1,35 @@
525+/*
526+ * Copyright © 2014, 2017 Canonical Ltd.
527+ *
528+ * This file is part of qtubuntu-print.
529+ *
530+ * qtubuntu-print is free software; you can redistribute it and/or modify
531+ * it under the terms of the GNU Lesser General Public License as published by
532+ * the Free Software Foundation; version 3.
533+ *
534+ * qtubuntu-print is distributed in the hope that it will be useful,
535+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
536+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
537+ * GNU Lesser General Public License for more details.
538+ *
539+ * You should have received a copy of the GNU Lesser General Public License
540+ * along with qtubuntu-print. If not, see <http://www.gnu.org/licenses/>.
541+ *
542+ * Authored by: Ken VanDine <ken.vandine@canonical.com>
543+ * Andrew Hayzen <andrew.hayzen@canonical.com>
544+ */
545+
546+#ifndef I18N_H
547+#define I18N_H
548+
549+#include <QtCore/QString>
550+
551+QT_BEGIN_NAMESPACE
552+
553+void initTr(const char *domain, const char *localeDir);
554+QString __(const char *text, const char *domain = 0);
555+
556+QT_END_NAMESPACE
557+
558+#endif // I18N_H
559+
560
561=== modified file 'main.cpp'
562--- main.cpp 2016-12-08 18:51:07 +0000
563+++ main.cpp 2017-02-21 14:15:06 +0000
564@@ -1,46 +1,49 @@
565 /*
566- * Copyright (C) 2016 Canonical Ltd
567- *
568- * This program is free software: you can redistribute it and/or modify
569- * it under the terms of the GNU General Public License version 3 as
570- * published by the Free Software Foundation.
571- *
572- * This program is distributed in the hope that it will be useful,
573+ * Copyright (C) 2016-2017 Canonical Ltd
574+ *
575+ * This file is part of qtubuntu-print.
576+ *
577+ * qtubuntu-print is free software; you can redistribute it and/or modify
578+ * it under the terms of the GNU Lesser General Public License as published by
579+ * the Free Software Foundation; version 3.
580+ *
581+ * qtubuntu-print is distributed in the hope that it will be useful,
582 * but WITHOUT ANY WARRANTY; without even the implied warranty of
583 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
584- * GNU General Public License for more details.
585+ * GNU Lesser General Public License for more details.
586 *
587- * You should have received a copy of the GNU General Public License
588- * along with this program. If not, see <http://www.gnu.org/licenses/>.
589+ * You should have received a copy of the GNU Lesser General Public License
590+ * along with qtubuntu-print. If not, see <http://www.gnu.org/licenses/>.
591 *
592 * Authored-by: Andrew Hayzen <andrew.hayzen@canonical.com>
593 */
594-#include <qpa/qplatformprintplugin.h>
595+#include <QtPrintSupport/qpa/qplatformprintplugin.h>
596 #include <QtCore/QStringList>
597
598-#include "qpdfsupport_p.h"
599+#include "constants.h"
600+#include "qubuntuprintsupport_p.h"
601
602 QT_BEGIN_NAMESPACE
603
604-class QPDFSupportPlugin : public QPlatformPrinterSupportPlugin
605+class QUbuntuPrintSupportPlugin : public QPlatformPrinterSupportPlugin
606 {
607 Q_OBJECT
608- Q_PLUGIN_METADATA(IID QPlatformPrinterSupportFactoryInterface_iid FILE "pdf.json")
609+ Q_PLUGIN_METADATA(IID QPlatformPrinterSupportFactoryInterface_iid FILE "qtubuntu-print.json")
610
611 public:
612 QStringList keys() const;
613 QPlatformPrinterSupport *create(const QString &) Q_DECL_OVERRIDE;
614 };
615
616-QStringList QPDFSupportPlugin::keys() const
617+QStringList QUbuntuPrintSupportPlugin::keys() const
618 {
619- return QStringList(QStringLiteral("pdfsupport"));
620+ return QStringList(QStringLiteral(JSON_KEY));
621 }
622
623-QPlatformPrinterSupport *QPDFSupportPlugin::create(const QString &key)
624+QPlatformPrinterSupport *QUbuntuPrintSupportPlugin::create(const QString &key)
625 {
626- if (key.compare(key, QLatin1String("pdfsupport"), Qt::CaseInsensitive) == 0)
627- return new QPDFSupport;
628+ if (key.compare(key, QLatin1String(JSON_KEY), Qt::CaseInsensitive) == 0)
629+ return new QUbuntuPrintSupport;
630 return 0;
631 }
632
633
634=== removed file 'pdf-plugin.pro'
635--- pdf-plugin.pro 2016-12-08 18:51:07 +0000
636+++ pdf-plugin.pro 1970-01-01 00:00:00 +0000
637@@ -1,28 +0,0 @@
638-TARGET = pdfsupport
639-TEMPLATE = lib
640-
641-QT += dbus printsupport printsupport-private
642-
643-target.path += $$[QT_INSTALL_PLUGINS]/printsupport
644-
645-CONFIG += plugin
646-INSTALLS += target
647-
648-DEFINES += "QT_NO_CUPS"
649-
650-HEADERS += \
651- qpdfsupport_p.h \
652- qpdfengine_p.h \
653- qpdfdevice_p.h
654-
655-SOURCES += main.cpp \
656- qpdfsupport.cpp \
657- qpdfengine.cpp \
658- qpdfdevice.cpp
659-
660-DISTFILES += \
661- pdf.json
662-
663-OTHER_FILES += pdf.json
664-
665-unix|win32: LIBS += -lcontent-hub
666
667=== added directory 'po'
668=== added file 'po/CMakeLists.txt'
669--- po/CMakeLists.txt 1970-01-01 00:00:00 +0000
670+++ po/CMakeLists.txt 2017-02-21 14:15:06 +0000
671@@ -0,0 +1,30 @@
672+project(qtubuntu-print-translations)
673+
674+include(FindGettext)
675+find_program(GETTEXT_XGETTEXT_EXECUTABLE xgettext)
676+
677+set(DOMAIN ${GETTEXT_PACKAGE})
678+set(POT_FILE ${DOMAIN}.pot)
679+file(GLOB PO_FILES *.po)
680+
681+add_custom_target(${POT_FILE} ALL
682+ COMMAND touch ${POT_FILE}
683+ COMMAND ${GETTEXT_XGETTEXT_EXECUTABLE} -o ${POT_FILE}
684+ -D ${CMAKE_SOURCE_DIR}
685+ --from-code=UTF-8
686+ --c++ --qt --add-comments=TRANSLATORS
687+ --keyword=__
688+ -j
689+ --package-name=qtubuntu-print
690+ --copyright-holder='Canonical Ltd.'
691+ ${qtubuntu_print_SRC}
692+ COMMAND ${CMAKE_COMMAND} -E copy ${POT_FILE} ${CMAKE_CURRENT_SOURCE_DIR})
693+
694+foreach(PO_FILE ${PO_FILES})
695+ get_filename_component(LANG ${PO_FILE} NAME_WE)
696+ gettext_process_po_files(${LANG} ALL PO_FILES ${PO_FILE})
697+ set(INSTALL_DIR ${CMAKE_INSTALL_LOCALEDIR}/${LANG}/LC_MESSAGES)
698+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${LANG}.gmo
699+ DESTINATION ${INSTALL_DIR}
700+ RENAME ${DOMAIN}.mo)
701+endforeach(PO_FILE)
702
703=== added file 'po/qtubuntu-print.pot'
704--- po/qtubuntu-print.pot 1970-01-01 00:00:00 +0000
705+++ po/qtubuntu-print.pot 2017-02-21 14:15:06 +0000
706@@ -0,0 +1,36 @@
707+# SOME DESCRIPTIVE TITLE.
708+# Copyright (C) YEAR Canonical Ltd.
709+# This file is distributed under the same license as the qtubuntu-print package.
710+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
711+#
712+#, fuzzy
713+msgid ""
714+msgstr ""
715+"Project-Id-Version: qtubuntu-print\n"
716+"Report-Msgid-Bugs-To: \n"
717+"POT-Creation-Date: 2017-02-16 15:47+0000\n"
718+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
719+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
720+"Language-Team: LANGUAGE <LL@li.org>\n"
721+"Language: \n"
722+"MIME-Version: 1.0\n"
723+"Content-Type: text/plain; charset=CHARSET\n"
724+"Content-Transfer-Encoding: 8bit\n"
725+
726+#: constants.h:27
727+msgid "Ubuntu Printing Service"
728+msgstr ""
729+
730+#: qubuntuprintdevice.cpp:39
731+msgid "Internal"
732+msgstr ""
733+
734+#: qubuntuprintengine.cpp:114
735+msgid "Printing failed"
736+msgstr ""
737+
738+#. TRANSLATORS: %0 is the name of the application (ubuntu-printing-app)
739+#: qubuntuprintengine.cpp:116
740+#, qt-format
741+msgid "Unable to find %0, please ensure that it is installed"
742+msgstr ""
743
744=== renamed file 'pdf.json' => 'qtubuntu-print.json'
745--- pdf.json 2016-12-08 18:51:07 +0000
746+++ qtubuntu-print.json 2017-02-21 14:15:06 +0000
747@@ -1,3 +1,3 @@
748 {
749- "Keys": [ "pdfsupport" ]
750+ "Keys": [ "qtubuntu-print" ]
751 }
752
753=== renamed file 'qpdfdevice.cpp' => 'qubuntuprintdevice.cpp'
754--- qpdfdevice.cpp 2016-12-08 18:51:07 +0000
755+++ qubuntuprintdevice.cpp 2017-02-21 14:15:06 +0000
756@@ -1,28 +1,33 @@
757 /*
758- * Copyright (C) 2016 Canonical Ltd
759- *
760- * This program is free software: you can redistribute it and/or modify
761- * it under the terms of the GNU General Public License version 3 as
762- * published by the Free Software Foundation.
763- *
764- * This program is distributed in the hope that it will be useful,
765+ * Copyright (C) 2016-2017 Canonical Ltd
766+ *
767+ * This file is part of qtubuntu-print.
768+ *
769+ * qtubuntu-print is free software; you can redistribute it and/or modify
770+ * it under the terms of the GNU Lesser General Public License as published by
771+ * the Free Software Foundation; version 3.
772+ *
773+ * qtubuntu-print is distributed in the hope that it will be useful,
774 * but WITHOUT ANY WARRANTY; without even the implied warranty of
775 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
776- * GNU General Public License for more details.
777+ * GNU Lesser General Public License for more details.
778 *
779- * You should have received a copy of the GNU General Public License
780- * along with this program. If not, see <http://www.gnu.org/licenses/>.
781+ * You should have received a copy of the GNU Lesser General Public License
782+ * along with qtubuntu-print. If not, see <http://www.gnu.org/licenses/>.
783 *
784 * Authored-by: Andrew Hayzen <andrew.hayzen@canonical.com>
785 */
786-#include "qpdfdevice_p.h"
787-
788-QPDFDevice::QPDFDevice()
789+
790+#include "constants.h"
791+#include "i18n.h"
792+#include "qubuntuprintdevice_p.h"
793+
794+QUbuntuPrintDevice::QUbuntuPrintDevice()
795 {
796
797 }
798
799-QPDFDevice::QPDFDevice(const QString &id)
800+QUbuntuPrintDevice::QUbuntuPrintDevice(const QString &id)
801 {
802 Q_UNUSED(id)
803
804@@ -30,12 +35,17 @@
805 // and QPrinter ends up thinking it is not a NativePrinter
806 // which then allows the user to change the output filename
807 m_id = id;
808- m_name = QStringLiteral(PRINTER_NAME);
809- m_location = QStringLiteral("Internal");
810- m_makeAndModel = QStringLiteral("PDF Printing Service");
811+ m_name = PRINTER_NAME;
812+ m_location = __("Internal");
813+ m_makeAndModel = PRINTER_NAME;
814+
815+ // Disable collate, copies and duplex as they don't make sense
816+ m_supportsCollateCopies = false;
817+ m_supportsMultipleCopies = false;
818+ m_haveDuplexModes = false;
819 }
820
821-bool QPDFDevice::isValid() const
822+bool QUbuntuPrintDevice::isValid() const
823 {
824 return true;
825 }
826
827=== renamed file 'qpdfdevice_p.h' => 'qubuntuprintdevice_p.h'
828--- qpdfdevice_p.h 2016-12-08 18:51:07 +0000
829+++ qubuntuprintdevice_p.h 2017-02-21 14:15:06 +0000
830@@ -1,36 +1,39 @@
831 /*
832- * Copyright (C) 2016 Canonical Ltd
833- *
834- * This program is free software: you can redistribute it and/or modify
835- * it under the terms of the GNU General Public License version 3 as
836- * published by the Free Software Foundation.
837- *
838- * This program is distributed in the hope that it will be useful,
839+ * Copyright (C) 2016-2017 Canonical Ltd
840+ *
841+ * This file is part of qtubuntu-print.
842+ *
843+ * qtubuntu-print is free software; you can redistribute it and/or modify
844+ * it under the terms of the GNU Lesser General Public License as published by
845+ * the Free Software Foundation; version 3.
846+ *
847+ * qtubuntu-print is distributed in the hope that it will be useful,
848 * but WITHOUT ANY WARRANTY; without even the implied warranty of
849 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
850- * GNU General Public License for more details.
851+ * GNU Lesser General Public License for more details.
852 *
853- * You should have received a copy of the GNU General Public License
854- * along with this program. If not, see <http://www.gnu.org/licenses/>.
855+ * You should have received a copy of the GNU Lesser General Public License
856+ * along with qtubuntu-print. If not, see <http://www.gnu.org/licenses/>.
857 *
858 * Authored-by: Andrew Hayzen <andrew.hayzen@canonical.com>
859 */
860-#ifndef QPDFDEVICE_H
861-#define QPDFDEVICE_H
862+#ifndef QUBUNTUPRINTDEVICE_H
863+#define QUBUNTUPRINTDEVICE_H
864
865-#include <qpa/qplatformprintdevice.h>
866+#include <QtCore/QString>
867+#include <QtPrintSupport/qpa/qplatformprintdevice.h>
868
869 QT_BEGIN_NAMESPACE
870
871-#define PRINTER_NAME "Printing Service"
872-
873-class QPDFDevice : public QPlatformPrintDevice
874+class QUbuntuPrintDevice : public QPlatformPrintDevice
875 {
876 public:
877- QPDFDevice();
878- explicit QPDFDevice(const QString &id);
879+ QUbuntuPrintDevice();
880+ explicit QUbuntuPrintDevice(const QString &id);
881
882 bool isValid() const Q_DECL_OVERRIDE;
883 };
884
885-#endif // QPDFDEVICE_H
886+QT_END_NAMESPACE
887+
888+#endif // QUBUNTUPRINTDEVICE_H
889
890=== renamed file 'qpdfengine.cpp' => 'qubuntuprintengine.cpp'
891--- qpdfengine.cpp 2016-12-08 18:51:07 +0000
892+++ qubuntuprintengine.cpp 2017-02-21 14:15:06 +0000
893@@ -1,17 +1,19 @@
894 /*
895- * Copyright (C) 2016 Canonical Ltd
896- *
897- * This program is free software: you can redistribute it and/or modify
898- * it under the terms of the GNU General Public License version 3 as
899- * published by the Free Software Foundation.
900- *
901- * This program is distributed in the hope that it will be useful,
902+ * Copyright (C) 2016-2017 Canonical Ltd
903+ *
904+ * This file is part of qtubuntu-print.
905+ *
906+ * qtubuntu-print is free software; you can redistribute it and/or modify
907+ * it under the terms of the GNU Lesser General Public License as published by
908+ * the Free Software Foundation; version 3.
909+ *
910+ * qtubuntu-print is distributed in the hope that it will be useful,
911 * but WITHOUT ANY WARRANTY; without even the implied warranty of
912 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
913- * GNU General Public License for more details.
914+ * GNU Lesser General Public License for more details.
915 *
916- * You should have received a copy of the GNU General Public License
917- * along with this program. If not, see <http://www.gnu.org/licenses/>.
918+ * You should have received a copy of the GNU Lesser General Public License
919+ * along with qtubuntu-print. If not, see <http://www.gnu.org/licenses/>.
920 *
921 * Authored-by: Andrew Hayzen <andrew.hayzen@canonical.com>
922 */
923@@ -22,107 +24,109 @@
924 #include <com/ubuntu/content/transfer.h>
925 #include <com/ubuntu/content/type.h>
926
927-#include <QDebug>
928+#include <QtCore/QDebug>
929 #include <QtCore/QDateTime>
930 #include <QtCore/QDir>
931-#include <QtCore/QFile>
932-#include <QtCore/QFileInfo>
933 #include <QtCore/QStandardPaths>
934+#include <QtCore/QTemporaryFile>
935 #include <QtCore/QUrl>
936-
937-#include "qpdfdevice_p.h"
938-#include "qpdfengine_p.h"
939+#include <QtWidgets/QMessageBox>
940+
941+#include "constants.h"
942+#include "i18n.h"
943+
944+#include "qubuntuprintdevice_p.h"
945+#include "qubuntuprintengine_p.h"
946
947 QT_BEGIN_NAMESPACE
948
949-QPDFEngine::QPDFEngine(QPrinter::PrinterMode m)
950- : QPdfPrintEngine(*new QPDFEnginePrivate(m))
951-{
952- Q_D(QPDFEngine);
953-}
954-
955-QPDFEngine::~QPDFEngine()
956-{
957-
958-}
959-
960-QPDFEnginePrivate::QPDFEnginePrivate(QPrinter::PrinterMode m)
961+QUbuntuPrintEngine::QUbuntuPrintEngine(QPrinter::PrinterMode m)
962+ : QPdfPrintEngine(*new QUbuntuPrintEnginePrivate(m))
963+{
964+ Q_D(QUbuntuPrintEngine);
965+}
966+
967+QUbuntuPrintEngine::~QUbuntuPrintEngine()
968+{
969+
970+}
971+
972+QUbuntuPrintEnginePrivate::QUbuntuPrintEnginePrivate(QPrinter::PrinterMode m)
973 : QPdfPrintEnginePrivate(m),
974 m_output_filename_auto(false)
975 {
976 }
977
978-QPDFEnginePrivate::~QPDFEnginePrivate()
979+QUbuntuPrintEnginePrivate::~QUbuntuPrintEnginePrivate()
980 {
981
982 }
983
984-bool QPDFEnginePrivate::openPrintDevice()
985+bool QUbuntuPrintEnginePrivate::openPrintDevice()
986 {
987 if (outDevice)
988 return false;
989
990 if (outputFileName.isEmpty()) {
991- QDir dir(QStandardPaths::writableLocation(QStandardPaths::TempLocation));
992-
993- if (!dir.exists()) {
994- dir.mkpath(".");
995+ QTemporaryFile *file = new QTemporaryFile();
996+
997+ if (file->open()) {
998+ outputFileName = file->fileName();
999+ m_output_filename_auto = true;
1000+
1001+ outDevice = file;
1002+ } else {
1003+ qDebug() << "Failed to open file";
1004+ delete file;
1005+ return false;
1006 }
1007-
1008- QFileInfo fileInfo(dir.path(), QDateTime::currentDateTime().toString(Qt::ISODate));
1009- outputFileName = fileInfo.absoluteFilePath();
1010- m_output_filename_auto = true;
1011- }
1012-
1013- QFile *file = new QFile(outputFileName);
1014-
1015- if (!file->open(QFile::WriteOnly|QFile::Truncate)) {
1016- qDebug() << "Cannot write to the location.";
1017- delete file;
1018- return false;
1019- }
1020-
1021- outDevice = file;
1022+ }
1023
1024 return true;
1025 }
1026
1027-void QPDFEnginePrivate::closePrintDevice()
1028+void QUbuntuPrintEnginePrivate::closePrintDevice()
1029 {
1030+ if (m_output_filename_auto) {
1031+ // ensure file is closed and flushed
1032+ if (outDevice) {
1033+ outDevice->close();
1034+ }
1035+
1036+ // Transfer via content-hub
1037+ com::ubuntu::content::Hub *hub = com::ubuntu::content::Hub::Client::instance();
1038+ com::ubuntu::content::Peer peer = com::ubuntu::content::Peer{APP_ID};
1039+
1040+ QVector<com::ubuntu::content::Item> items;
1041+
1042+ // Content-hub needs file:///path not closePrintDevice/path
1043+ QUrl url(outputFileName);
1044+ url.setScheme("file");
1045+ items.append(com::ubuntu::content::Item(url.toString()));
1046+
1047+ com::ubuntu::content::Transfer *transfer = hub->create_export_to_peer(peer);
1048+
1049+ if (transfer != Q_NULLPTR && transfer->state() != com::ubuntu::content::Transfer::aborted) {
1050+ transfer->charge(items);
1051+ } else {
1052+ qWarning() << "Transfer failed to create, likely cannot find Peer:" << APP_ID;
1053+ QMessageBox::warning(Q_NULLPTR,
1054+ __("Printing failed"),
1055+ // TRANSLATORS: %0 is the name of the application (ubuntu-printing-app)
1056+ __("Unable to find %0, please ensure that it is installed").arg(APP_ID));
1057+ }
1058+
1059+ // If we set the filename, reset it
1060+ m_output_filename_auto = false;
1061+ outputFileName = "";
1062+ }
1063+
1064 QPdfPrintEnginePrivate::closePrintDevice();
1065
1066 if (outDevice) {
1067 outDevice->close();
1068- }
1069-
1070- // Transfer via content-hub
1071- com::ubuntu::content::Hub *hub = com::ubuntu::content::Hub::Client::instance();
1072- com::ubuntu::content::Type documentType = com::ubuntu::content::Type::Known::documents();
1073-
1074-// QVector<com::ubuntu::content::Peer> peers = hub->known_destinations_for_type(documentType);
1075-// com::ubuntu::content::Peer peer = peers.at(1);
1076-
1077- com::ubuntu::content::Peer peer = com::ubuntu::content::Peer{"destination-app.ahayzen_destination-app_0.1"}; // pdfviewer.sverzegnassi_pdfviewer_2.2.261"};
1078-
1079- QVector<com::ubuntu::content::Item> items;
1080-
1081- // Content-hub needs file:///path not /path
1082- QUrl url(outputFileName);
1083- url.setScheme("file");
1084- items.append(com::ubuntu::content::Item(url.toString()));
1085-
1086- com::ubuntu::content::Transfer *transfer = hub->create_export_to_peer_for_type(peer, documentType);
1087-
1088- if (transfer != nullptr) {
1089- transfer->start();
1090- transfer->charge(items);
1091- } else {
1092- qWarning() << "Transfer failed to create, likely cannot find Peer: destination-app.ahayzen_destination-app_0.1";
1093- }
1094-
1095- // If we set the filename, reset it
1096- if (m_output_filename_auto) {
1097- m_output_filename_auto = false;
1098- outputFileName = "";
1099+
1100+ delete outDevice;
1101+ outDevice = Q_NULLPTR;
1102 }
1103 }
1104
1105=== renamed file 'qpdfengine_p.h' => 'qubuntuprintengine_p.h'
1106--- qpdfengine_p.h 2016-12-08 18:51:07 +0000
1107+++ qubuntuprintengine_p.h 2017-02-21 14:15:06 +0000
1108@@ -1,43 +1,45 @@
1109 /*
1110- * Copyright (C) 2016 Canonical Ltd
1111- *
1112- * This program is free software: you can redistribute it and/or modify
1113- * it under the terms of the GNU General Public License version 3 as
1114- * published by the Free Software Foundation.
1115- *
1116- * This program is distributed in the hope that it will be useful,
1117+ * Copyright (C) 2016-2017 Canonical Ltd
1118+ *
1119+ * This file is part of qtubuntu-print.
1120+ *
1121+ * qtubuntu-print is free software; you can redistribute it and/or modify
1122+ * it under the terms of the GNU Lesser General Public License as published by
1123+ * the Free Software Foundation; version 3.
1124+ *
1125+ * qtubuntu-print is distributed in the hope that it will be useful,
1126 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1127 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1128- * GNU General Public License for more details.
1129+ * GNU Lesser General Public License for more details.
1130 *
1131- * You should have received a copy of the GNU General Public License
1132- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1133+ * You should have received a copy of the GNU Lesser General Public License
1134+ * along with qtubuntu-print. If not, see <http://www.gnu.org/licenses/>.
1135 *
1136 * Authored-by: Andrew Hayzen <andrew.hayzen@canonical.com>
1137 */
1138-#ifndef QPDFENGINE_H
1139-#define QPDFENGINE_H
1140+#ifndef QUBUNTUPRINTENGINE_H
1141+#define QUBUNTUPRINTENGINE_H
1142
1143 #include <QtPrintSupport/private/qprintengine_pdf_p.h>
1144
1145 QT_BEGIN_NAMESPACE
1146
1147-class QPDFEnginePrivate;
1148+class QUbuntuPrintEnginePrivate;
1149
1150-class QPDFEngine : public QPdfPrintEngine
1151+class QUbuntuPrintEngine : public QPdfPrintEngine
1152 {
1153- Q_DECLARE_PRIVATE(QPDFEngine)
1154+ Q_DECLARE_PRIVATE(QUbuntuPrintEngine)
1155 public:
1156- QPDFEngine(QPrinter::PrinterMode m);
1157- virtual ~QPDFEngine();
1158+ QUbuntuPrintEngine(QPrinter::PrinterMode m);
1159+ virtual ~QUbuntuPrintEngine();
1160 };
1161
1162-class QPDFEnginePrivate : public QPdfPrintEnginePrivate
1163+class QUbuntuPrintEnginePrivate : public QPdfPrintEnginePrivate
1164 {
1165- Q_DECLARE_PUBLIC(QPDFEngine)
1166+ Q_DECLARE_PUBLIC(QUbuntuPrintEngine)
1167 public:
1168- QPDFEnginePrivate(QPrinter::PrinterMode m);
1169- ~QPDFEnginePrivate();
1170+ QUbuntuPrintEnginePrivate(QPrinter::PrinterMode m);
1171+ ~QUbuntuPrintEnginePrivate();
1172
1173 bool openPrintDevice() Q_DECL_OVERRIDE;
1174 void closePrintDevice() Q_DECL_OVERRIDE;
1175@@ -47,4 +49,4 @@
1176
1177 QT_END_NAMESPACE
1178
1179-#endif // QPDFENGINE_H
1180+#endif // QUBUNTUPRINTENGINE_H
1181
1182=== renamed file 'qpdfsupport.cpp' => 'qubuntuprintsupport.cpp'
1183--- qpdfsupport.cpp 2016-12-08 18:51:07 +0000
1184+++ qubuntuprintsupport.cpp 2017-02-21 14:15:06 +0000
1185@@ -1,63 +1,67 @@
1186-#include "qpdfsupport_p.h"
1187 /*
1188- * Copyright (C) 2016 Canonical Ltd
1189- *
1190- * This program is free software: you can redistribute it and/or modify
1191- * it under the terms of the GNU General Public License version 3 as
1192- * published by the Free Software Foundation.
1193- *
1194- * This program is distributed in the hope that it will be useful,
1195+ * Copyright (C) 2016-2017 Canonical Ltd
1196+ *
1197+ * This file is part of qtubuntu-print.
1198+ *
1199+ * qtubuntu-print is free software; you can redistribute it and/or modify
1200+ * it under the terms of the GNU Lesser General Public License as published by
1201+ * the Free Software Foundation; version 3.
1202+ *
1203+ * qtubuntu-print is distributed in the hope that it will be useful,
1204 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1205 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1206- * GNU General Public License for more details.
1207+ * GNU Lesser General Public License for more details.
1208 *
1209- * You should have received a copy of the GNU General Public License
1210- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1211+ * You should have received a copy of the GNU Lesser General Public License
1212+ * along with qtubuntu-print. If not, see <http://www.gnu.org/licenses/>.
1213 *
1214 * Authored-by: Andrew Hayzen <andrew.hayzen@canonical.com>
1215 */
1216 #include <QtPrintSupport/qprintengine.h>
1217 #include <QtPrintSupport/private/qprintdevice_p.h>
1218
1219-#include "qpdfdevice_p.h"
1220-#include "qpdfengine_p.h"
1221+#include "constants.h"
1222+#include "i18n.h"
1223+#include "qubuntuprintdevice_p.h"
1224+#include "qubuntuprintengine_p.h"
1225+#include "qubuntuprintsupport_p.h"
1226
1227 QT_BEGIN_NAMESPACE
1228
1229-QPDFSupport::QPDFSupport()
1230-{
1231-
1232-}
1233-
1234-QPDFSupport::~QPDFSupport()
1235-{
1236-
1237-}
1238-
1239-QPrintEngine *QPDFSupport::createNativePrintEngine(QPrinter::PrinterMode printerMode)
1240-{
1241- return new QPDFEngine(printerMode);
1242-}
1243-
1244-QPaintEngine *QPDFSupport::createPaintEngine(QPrintEngine *printEngine, QPrinter::PrinterMode printerMode)
1245+QUbuntuPrintSupport::QUbuntuPrintSupport()
1246+{
1247+ initTr(I18N_DOMAIN, NULL);
1248+}
1249+
1250+QUbuntuPrintSupport::~QUbuntuPrintSupport()
1251+{
1252+
1253+}
1254+
1255+QPrintEngine *QUbuntuPrintSupport::createNativePrintEngine(QPrinter::PrinterMode printerMode)
1256+{
1257+ return new QUbuntuPrintEngine(printerMode);
1258+}
1259+
1260+QPaintEngine *QUbuntuPrintSupport::createPaintEngine(QPrintEngine *printEngine, QPrinter::PrinterMode printerMode)
1261 {
1262 Q_UNUSED(printerMode)
1263- return static_cast<QPDFEngine *>(printEngine);
1264-}
1265-
1266-QPrintDevice QPDFSupport::createPrintDevice(const QString &id)
1267-{
1268- return QPlatformPrinterSupport::createPrintDevice(new QPDFDevice(id));
1269-}
1270-
1271-QStringList QPDFSupport::availablePrintDeviceIds() const
1272-{
1273- return QStringList(QStringLiteral(PRINTER_NAME));
1274-}
1275-
1276-QString QPDFSupport::defaultPrintDeviceId() const
1277-{
1278- return QStringLiteral(PRINTER_NAME);
1279+ return static_cast<QUbuntuPrintEngine *>(printEngine);
1280+}
1281+
1282+QPrintDevice QUbuntuPrintSupport::createPrintDevice(const QString &id)
1283+{
1284+ return QPlatformPrinterSupport::createPrintDevice(new QUbuntuPrintDevice(id));
1285+}
1286+
1287+QStringList QUbuntuPrintSupport::availablePrintDeviceIds() const
1288+{
1289+ return QStringList(PRINTER_NAME);
1290+}
1291+
1292+QString QUbuntuPrintSupport::defaultPrintDeviceId() const
1293+{
1294+ return PRINTER_NAME;
1295 }
1296
1297 QT_END_NAMESPACE
1298
1299=== renamed file 'qpdfsupport_p.h' => 'qubuntuprintsupport_p.h'
1300--- qpdfsupport_p.h 2016-12-08 18:51:07 +0000
1301+++ qubuntuprintsupport_p.h 2017-02-21 14:15:06 +0000
1302@@ -1,33 +1,35 @@
1303 /*
1304- * Copyright (C) 2016 Canonical Ltd
1305- *
1306- * This program is free software: you can redistribute it and/or modify
1307- * it under the terms of the GNU General Public License version 3 as
1308- * published by the Free Software Foundation.
1309- *
1310- * This program is distributed in the hope that it will be useful,
1311+ * Copyright (C) 2016-2017 Canonical Ltd
1312+ *
1313+ * This file is part of qtubuntu-print.
1314+ *
1315+ * qtubuntu-print is free software; you can redistribute it and/or modify
1316+ * it under the terms of the GNU Lesser General Public License as published by
1317+ * the Free Software Foundation; version 3.
1318+ *
1319+ * qtubuntu-print is distributed in the hope that it will be useful,
1320 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1321 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1322- * GNU General Public License for more details.
1323+ * GNU Lesser General Public License for more details.
1324 *
1325- * You should have received a copy of the GNU General Public License
1326- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1327+ * You should have received a copy of the GNU Lesser General Public License
1328+ * along with qtubuntu-print. If not, see <http://www.gnu.org/licenses/>.
1329 *
1330 * Authored-by: Andrew Hayzen <andrew.hayzen@canonical.com>
1331 */
1332-#ifndef QPDFSUPPORT_H
1333-#define QPDFSUPPORT_H
1334+#ifndef QUBUNTUPRINTSUPPORT_H
1335+#define QUBUNTUPRINTSUPPORT_H
1336
1337-#include <qpa/qplatformprintersupport.h>
1338+#include <QtPrintSupport/qpa/qplatformprintersupport.h>
1339 #include <QtCore/qstringlist.h>
1340
1341 QT_BEGIN_NAMESPACE
1342
1343-class QPDFSupport : public QPlatformPrinterSupport
1344+class QUbuntuPrintSupport : public QPlatformPrinterSupport
1345 {
1346 public:
1347- QPDFSupport();
1348- ~QPDFSupport();
1349+ QUbuntuPrintSupport();
1350+ ~QUbuntuPrintSupport();
1351
1352 QPrintEngine *createNativePrintEngine(QPrinter::PrinterMode printerMode) Q_DECL_OVERRIDE;
1353 QPaintEngine *createPaintEngine(QPrintEngine *printEngine, QPrinter::PrinterMode) Q_DECL_OVERRIDE;
1354@@ -39,4 +41,4 @@
1355
1356 QT_END_NAMESPACE
1357
1358-#endif // QPDFSUPPORT_H
1359+#endif // QUBUNTUPRINTSUPPORT_H

Subscribers

People subscribed via source and target branches

to all changes: