Bug 1185236 - Shorten print job name when GTK version is older than 3.18.2. r?karlt
Since GTK 3.18.2, GTK allows setting job name with more than 255 bytes.
As result, CUPS received the IPP error. (RFC 2911, Section 4.3.1)
This patch will shorten print job name, if runtime GTK version is older than 3.18.2.
MozReview-Commit-ID: EfB87Bvo6hX
--- a/widget/gtk/nsDeviceContextSpecG.cpp
+++ b/widget/gtk/nsDeviceContextSpecG.cpp
@@ -290,18 +290,24 @@ nsDeviceContextSpecGTK::EnumeratePrinter
nullptr, TRUE);
}
NS_IMETHODIMP
nsDeviceContextSpecGTK::BeginDocument(const nsAString& aTitle,
const nsAString& aPrintToFileName,
int32_t aStartPage, int32_t aEndPage)
{
- mTitle.Truncate();
- AppendUTF16toUTF8(aTitle, mTitle);
+ // Print job names exceeding 255 bytes are safe with GTK version 3.18.2 or
+ // newer. This is a workaround for old GTK.
+ if (gtk_check_version(3,18,2) != nullptr) {
+ PrintTarget::AdjustPrintJobNameForIPP(aTitle, mTitle);
+ } else {
+ CopyUTF16toUTF8(aTitle, mTitle);
+ }
+
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK::EndDocument()
{
if (mToPrinter) {
// At this point, we might have a GtkPrinter set up in nsPrintSettingsGTK,
// or we might not. In the single-process case, we probably will, as this