From fbb9b97c0bc8c8da672f8fe71daf595cc6e8da46 Mon Sep 17 00:00:00 2001 From: "scott%scott-macgregor.org" Date: Sun, 4 Jan 2004 04:44:01 +0000 Subject: [PATCH] Bug #66868 --> Location of profile is incorrect shown when the path contains non-ascii chars Patch by Mike Kaply r=dougt sr=tor git-svn-id: svn://10.0.0.236/trunk@150864 18797224-902f-48f8-a5cc-f745e15eee43 --- .../prefs/resources/content/AccountManager.js | 4 +-- mozilla/xpcom/obsolete/nsFileSpecImpl.cpp | 29 +++++++++++++++++++ mozilla/xpcom/obsolete/nsIFileSpec.idl | 2 ++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/mozilla/mailnews/base/prefs/resources/content/AccountManager.js b/mozilla/mailnews/base/prefs/resources/content/AccountManager.js index a3619ce96c2..2a60df958b0 100644 --- a/mozilla/mailnews/base/prefs/resources/content/AccountManager.js +++ b/mozilla/mailnews/base/prefs/resources/content/AccountManager.js @@ -992,7 +992,7 @@ function getFormElementValue(formElement) { formElement.getAttribute("datatype") == "nsIFileSpec") { if (formElement.value) { var filespec = Components.classes["@mozilla.org/filespec;1"].createInstance(Components.interfaces.nsIFileSpec); - filespec.nativePath = formElement.value; + filespec.setUnicodePath(formElement.value); return filespec; } return null; @@ -1065,7 +1065,7 @@ function setFormElementValue(formElement, value) { if (value) { var filespec = value.QueryInterface(Components.interfaces.nsIFileSpec); try { - formElement.value = filespec.nativePath; + formElement.value = filespec.getUnicodePath(); } catch (ex) { dump("Still need to fix uninitialized filespec problem!\n"); } diff --git a/mozilla/xpcom/obsolete/nsFileSpecImpl.cpp b/mozilla/xpcom/obsolete/nsFileSpecImpl.cpp index fc155573ada..7234a7fcfa0 100644 --- a/mozilla/xpcom/obsolete/nsFileSpecImpl.cpp +++ b/mozilla/xpcom/obsolete/nsFileSpecImpl.cpp @@ -42,6 +42,7 @@ #include "nsFileStream.h" #include "nsILocalFile.h" +#include "nsNativeCharsetUtils.h" #include "prmem.h" @@ -211,6 +212,34 @@ NS_IMETHODIMP nsFileSpecImpl::SetNativePath(const char * aNativePath) return NS_OK; } +//---------------------------------------------------------------------------------------- +NS_IMETHODIMP nsFileSpecImpl::GetUnicodePath(PRUnichar * *aUnicodePath) +//---------------------------------------------------------------------------------------- +{ + TEST_OUT_PTR(aUnicodePath) + nsAutoString unicode; + nsCAutoString native; + native = mFileSpec.GetNativePathCString(); + NS_CopyNativeToUnicode(native, unicode); + *aUnicodePath = nsCRT::strdup(unicode.get()); + if (!*aUnicodePath) + return NS_ERROR_OUT_OF_MEMORY; + return NS_OK; +} + +//---------------------------------------------------------------------------------------- +NS_IMETHODIMP nsFileSpecImpl::SetUnicodePath(const PRUnichar * aUnicodePath) +//---------------------------------------------------------------------------------------- +{ + nsAutoString unicode; + nsCAutoString native; + + unicode = aUnicodePath; + NS_CopyUnicodeToNative(unicode, native); + mFileSpec = native.get(); + return NS_OK; +} + //---------------------------------------------------------------------------------------- NS_IMETHODIMP nsFileSpecImpl::GetNSPRPath(char * *aNSPRPath) //---------------------------------------------------------------------------------------- diff --git a/mozilla/xpcom/obsolete/nsIFileSpec.idl b/mozilla/xpcom/obsolete/nsIFileSpec.idl index 7f3371108be..51120c0aced 100644 --- a/mozilla/xpcom/obsolete/nsIFileSpec.idl +++ b/mozilla/xpcom/obsolete/nsIFileSpec.idl @@ -154,6 +154,8 @@ interface nsIFileSpec : nsISupports void seek(in long offset); long tell(); void endLine(); + wstring getUnicodePath(); + void setUnicodePath(in wstring aUnicodePath); };