diff --git a/mozilla/netwerk/streamconv/converters/nsIndexedToHTML.cpp b/mozilla/netwerk/streamconv/converters/nsIndexedToHTML.cpp index 8abc338e5fe..630dde81af5 100644 --- a/mozilla/netwerk/streamconv/converters/nsIndexedToHTML.cpp +++ b/mozilla/netwerk/streamconv/converters/nsIndexedToHTML.cpp @@ -57,9 +57,6 @@ nsIndexedToHTML::Init(nsIStreamListener* aListener) { mListener = aListener; - nsCOMPtr localeServ = do_GetService(NS_LOCALESERVICE_CONTRACTID); - localeServ->GetApplicationLocale(getter_AddRefs(mLocale)); - mDateTime = do_CreateInstance(kDateTimeFormatCID, &rv); nsCOMPtr sbs = @@ -198,9 +195,7 @@ nsIndexedToHTML::OnStartRequest(nsIRequest* request, nsISupports *aContext) { buffer.Append(NS_LITERAL_STRING("\">\n")); } - buffer.Append(NS_LITERAL_STRING("\n
\n"));
-
-    buffer.Append(NS_LITERAL_STRING("

")); + buffer.Append(NS_LITERAL_STRING("\n\n

")); char* escaped = nsEscapeHTML(spec); nsAutoString escapedSpec; escapedSpec.AssignWithConversion(escaped); @@ -215,8 +210,7 @@ nsIndexedToHTML::OnStartRequest(nsIRequest* request, nsISupports *aContext) { if (NS_FAILED(rv)) return rv; buffer.Append(title); - buffer.Append(NS_LITERAL_STRING("

\n")); - buffer.Append(NS_LITERAL_STRING("
\n")); + buffer.Append(NS_LITERAL_STRING("\n
\n")); //buffer.Append(NS_LITERAL_STRING("\n")); @@ -256,7 +250,7 @@ nsIndexedToHTML::OnStopRequest(nsIRequest* request, nsISupports *aContext, nsresult aStatus) { nsresult rv = NS_OK; nsString buffer; - buffer.Assign(NS_LITERAL_STRING("
NameSizeLast modified

\n")); + buffer.Assign(NS_LITERAL_STRING("
\n")); nsCOMPtr inputData; nsCOMPtr inputDataSup; @@ -296,15 +290,14 @@ nsIndexedToHTML::OnIndexAvailable(nsIRequest *aRequest, nsString pushBuffer; - pushBuffer.Append(NS_LITERAL_STRING("\n ")); - pushBuffer.Append(NS_LITERAL_STRING("\n GetLocation(getter_Copies(loc)); pushBuffer.AppendWithConversion(loc); - pushBuffer.Append(NS_LITERAL_STRING("\"> GetType(&type); @@ -318,51 +311,62 @@ nsIndexedToHTML::OnIndexAvailable(nsIRequest *aRequest, pushBuffer.Append(NS_LITERAL_STRING("internal-gopher-unknown")); break; } - pushBuffer.Append(NS_LITERAL_STRING("\"> ")); + pushBuffer.Append(NS_LITERAL_STRING("\">")); + + + if (type == nsIDirIndex::TYPE_SYMLINK) + pushBuffer.Append(NS_LITERAL_STRING("")); nsXPIDLString tmp; aIndex->GetDescription(getter_Copies(tmp)); PRUnichar* escaped = nsEscapeHTML2(tmp.get(), tmp.Length()); pushBuffer.Append(escaped); nsMemory::Free(escaped); - pushBuffer.Append(NS_LITERAL_STRING("")); - pushBuffer.Append(NS_LITERAL_STRING("\n")); - pushBuffer.Append(NS_LITERAL_STRING(" ")); + if (type == nsIDirIndex::TYPE_SYMLINK) + pushBuffer.Append(NS_LITERAL_STRING("")); + pushBuffer.Append(NS_LITERAL_STRING("\n")); + PRUint32 size; aIndex->GetSize(&size); if (size != PRUint32(-1) && type != nsIDirIndex::TYPE_DIRECTORY && type != nsIDirIndex::TYPE_SYMLINK) { - pushBuffer.AppendInt(size); + nsAutoString sizeString; + FormatSizeString(size, sizeString); + pushBuffer.Append(sizeString); + pushBuffer.Append(NS_LITERAL_STRING(" ")); // for a little extra space } else { pushBuffer.Append(NS_LITERAL_STRING(" ")); } - pushBuffer.Append(NS_LITERAL_STRING("\n")); - - pushBuffer.Append(NS_LITERAL_STRING(" ")); - + pushBuffer.Append(NS_LITERAL_STRING("\n ")); PRTime t; aIndex->GetLastModified(&t); if (t == -1) { - pushBuffer.Append(NS_LITERAL_STRING(" ")); + pushBuffer.Append(NS_LITERAL_STRING(" \n  ")); } else { nsAutoString formatted; - mDateTime->FormatPRTime(mLocale, + mDateTime->FormatPRTime(nsnull, kDateFormatShort, + kTimeFormatNone, + t, + formatted); + pushBuffer.Append(formatted); + pushBuffer.Append(NS_LITERAL_STRING("\n ")); + mDateTime->FormatPRTime(nsnull, + kDateFormatNone, kTimeFormatSeconds, t, formatted); pushBuffer.Append(formatted); } - pushBuffer.Append(NS_LITERAL_STRING("\n")); - pushBuffer.Append(NS_LITERAL_STRING("\n")); + pushBuffer.Append(NS_LITERAL_STRING("\n\n")); nsCOMPtr inputData; nsCOMPtr inputDataSup; @@ -383,8 +387,21 @@ nsIndexedToHTML::OnIndexAvailable(nsIRequest *aRequest, return rv; } +void nsIndexedToHTML::FormatSizeString(PRUint32 inSize, nsString& outSizeString) +{ + outSizeString.Truncate(); + if (inSize == 0) { + outSizeString.Append(NS_LITERAL_STRING(" ")); + } else { + // round up to the nearest Kilobyte + PRUint32 upperSize = (inSize + 1023) / 1024; + outSizeString.AppendInt(upperSize); + outSizeString.Append(NS_LITERAL_STRING(" KB")); + } +} + nsIndexedToHTML::nsIndexedToHTML() { - NS_INIT_REFCNT(); + NS_INIT_ISUPPORTS(); } nsIndexedToHTML::~nsIndexedToHTML() { diff --git a/mozilla/netwerk/streamconv/converters/nsIndexedToHTML.h b/mozilla/netwerk/streamconv/converters/nsIndexedToHTML.h index 06c9ecfbe8f..00a6ae4a7b3 100644 --- a/mozilla/netwerk/streamconv/converters/nsIndexedToHTML.h +++ b/mozilla/netwerk/streamconv/converters/nsIndexedToHTML.h @@ -45,7 +45,6 @@ #include "nsIStreamConverter.h" #include "nsXPIDLString.h" #include "nsIDirIndexListener.h" -#include "nsILocaleService.h" #include "nsIDateTimeFormat.h" #include "nsIStringBundle.h" @@ -82,11 +81,14 @@ public: return rv; } +protected: + + void FormatSizeString(PRUint32 inSize, nsString& outSizeString); + protected: nsCOMPtr mParser; nsCOMPtr mListener; // final listener (consumer) - nsCOMPtr mLocale; nsCOMPtr mDateTime; nsCOMPtr mBundle; };