bug 147419 remove print(|.<modulename>)(|.printer_<printername>).filename pref reading code r=roc
authorKarl Tomlinson <karlt+@karlt.net>
Wed, 10 Jun 2015 19:11:49 +1200
changeset 280075 c9672130312513f65dc7b6c1df10310798a96db0
parent 280074 d799f63ed244f82b93b51b3343b6beef73b6dd3c
child 280076 86f5957e60f9f5b2e466ea2f02a46955bbfc50a8
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-beta@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs147419
milestone41.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 147419 remove print(|.<modulename>)(|.printer_<printername>).filename pref reading code r=roc There are no default pref values, and even if some have been set, the value is subsequently overridden by the print.print_to_filename pref, which exists if saved from a previous nsPrintSettingsGTK.
widget/gtk/nsDeviceContextSpecG.cpp
--- a/widget/gtk/nsDeviceContextSpecG.cpp
+++ b/widget/gtk/nsDeviceContextSpecG.cpp
@@ -369,76 +369,16 @@ NS_IMETHODIMP nsDeviceContextSpecGTK::En
     umask(mask);
     // If you're not familiar with umasks, they contain the bits of what NOT to set in the permissions
     // (thats because files and directories have different numbers of bits for their permissions)
     destFile->SetPermissions(0666 & ~(mask));
   }
   return NS_OK;
 }
 
-/* Get prefs for printer
- * Search order:
- * - Get prefs per printer name and module name
- * - Get prefs per printer name
- * - Get prefs per module name
- * - Get prefs
- */
-static
-nsresult CopyPrinterCharPref(const char *modulename, const char *printername,
-                             const char *prefname, nsCString &return_buf)
-{
-  DO_PR_DEBUG_LOG(("CopyPrinterCharPref('%s', '%s', '%s')\n", modulename, printername, prefname));
-
-  nsresult rv = NS_ERROR_FAILURE;
- 
-  if (printername && modulename) {
-    /* Get prefs per printer name and module name */
-    nsPrintfCString name("print.%s.printer_%s.%s", modulename, printername, prefname);
-    DO_PR_DEBUG_LOG(("trying to get '%s'\n", name.get()));
-    rv = Preferences::GetCString(name.get(), &return_buf);
-  }
-  
-  if (NS_FAILED(rv)) { 
-    if (printername) {
-      /* Get prefs per printer name */
-      nsPrintfCString name("print.printer_%s.%s", printername, prefname);
-      DO_PR_DEBUG_LOG(("trying to get '%s'\n", name.get()));
-      rv = Preferences::GetCString(name.get(), &return_buf);
-    }
-
-    if (NS_FAILED(rv)) {
-      if (modulename) {
-        /* Get prefs per module name */
-        nsPrintfCString name("print.%s.%s", modulename, prefname);
-        DO_PR_DEBUG_LOG(("trying to get '%s'\n", name.get()));
-        rv = Preferences::GetCString(name.get(), &return_buf);
-      }
-      
-      if (NS_FAILED(rv)) {
-        /* Get prefs */
-        nsPrintfCString name("print.%s", prefname);
-        DO_PR_DEBUG_LOG(("trying to get '%s'\n", name.get()));
-        rv = Preferences::GetCString(name.get(), &return_buf);
-      }
-    }
-  }
-
-#ifdef PR_LOG  
-  if (NS_SUCCEEDED(rv)) {
-    DO_PR_DEBUG_LOG(("CopyPrinterCharPref returning '%s'.\n", return_buf.get()));
-  }
-  else
-  {
-    DO_PR_DEBUG_LOG(("CopyPrinterCharPref failure.\n"));
-  }
-#endif /* PR_LOG */
-
-  return rv;
-}
-
 //  Printer Enumerator
 nsPrinterEnumeratorGTK::nsPrinterEnumeratorGTK()
 {
 }
 
 NS_IMPL_ISUPPORTS(nsPrinterEnumeratorGTK, nsIPrinterEnumerator)
 
 NS_IMETHODIMP nsPrinterEnumeratorGTK::GetPrinterNameList(nsIStringEnumerator **aPrinterNameList)
@@ -498,38 +438,28 @@ NS_IMETHODIMP nsPrinterEnumeratorGTK::In
   printerName.Assign(NS_ConvertUTF16toUTF8(aPrinterName));
   DO_PR_DEBUG_LOG(("printerName='%s'\n", printerName.get()));
   
   PrintMethod type = pmInvalid;
   rv = nsDeviceContextSpecGTK::GetPrintMethod(printerName, type);
   if (NS_FAILED(rv))
     return rv;
 
-  /* "Demangle" postscript printer name */
-  if (type == pmPostScript) {
-    /* Strip the printing method name from the printer,
-     * e.g. turn "PostScript/foobar" to "foobar" */
-    int32_t slash = printerName.FindChar('/');
-    if (kNotFound != slash)
-      printerName.Cut(0, slash + 1);
-  }
-  
   /* Set filename */
   nsAutoCString filename;
-  if (NS_FAILED(CopyPrinterCharPref(nullptr, printerName, "filename", filename))) {
-    const char *path;
+  const char *path;
   
-    if (!(path = PR_GetEnv("PWD")))
-      path = PR_GetEnv("HOME");
+  if (!(path = PR_GetEnv("PWD")))
+    path = PR_GetEnv("HOME");
   
-    if (path)
-      filename = nsPrintfCString("%s/mozilla.pdf", path);
-    else
-      filename.AssignLiteral("mozilla.pdf");
-  }  
+  if (path)
+    filename = nsPrintfCString("%s/mozilla.pdf", path);
+  else
+    filename.AssignLiteral("mozilla.pdf");
+
   DO_PR_DEBUG_LOG(("Setting default filename to '%s'\n", filename.get()));
   aPrintSettings->SetToFileName(NS_ConvertUTF8toUTF16(filename).get());
 
   aPrintSettings->SetIsInitializedFromPrinter(true);
 
   if (type == pmPostScript) {
     DO_PR_DEBUG_LOG(("InitPrintSettingsFromPrinter() for PostScript printer\n"));