backing out 345517 due to leak test bustage

This commit is contained in:
pavlov%pavlov.net 2006-11-10 04:42:03 +00:00
parent 8c4c24c99c
commit 0b5a3c2706
55 changed files with 468 additions and 568 deletions

View File

@ -249,7 +249,7 @@ ifeq ($(OS_ARCH),WINNT)
# Set it to 256k. See bug 127069. # Set it to 256k. See bug 127069.
# #
ifndef GNU_CC ifndef GNU_CC
LDFLAGS += /HEAP:0x40000 LDFLAGS += /HEAP:0x40000 /fixed:no
endif endif
endif endif

View File

@ -44,8 +44,7 @@ include $(DEPTH)/config/autoconf.mk
MODULE = bookmarks MODULE = bookmarks
LIBRARY_NAME = bookmarks_s LIBRARY_NAME = bookmarks_s
FORCE_STATIC_LIB = 1 MOZILLA_INTERNAL_API = 1
FORCE_USE_PIC = 1
REQUIRES = xpcom \ REQUIRES = xpcom \
string \ string \
@ -77,5 +76,9 @@ CPPSRCS = nsBookmarksService.cpp \
EXTRA_COMPONENTS = nsBookmarkTransactionManager.js EXTRA_COMPONENTS = nsBookmarkTransactionManager.js
# we don't want the shared lib, but we want to force the creation of a
# static lib.
FORCE_STATIC_LIB = 1
include $(topsrcdir)/config/rules.mk include $(topsrcdir)/config/rules.mk

View File

@ -392,12 +392,8 @@ nsFeedLoadListener::TryParseAsRDF ()
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
if (!listener) return NS_ERROR_FAILURE; if (!listener) return NS_ERROR_FAILURE;
nsCOMPtr<nsIStringInputStream> stream = nsCOMPtr<nsIInputStream> stream;
do_CreateInstance("@mozilla.org/io/string-input-stream;1"); rv = NS_NewCStringInputStream(getter_AddRefs(stream), mBody);
if (!stream)
return NS_ERROR_FAILURE;
rv = stream->SetData(mBody.get(), mBody.Length());
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIChannel> channel; nsCOMPtr<nsIChannel> channel;
@ -857,9 +853,9 @@ nsFeedLoadListener::TryParseAsSimpleRSS ()
} }
// Clean up whitespace // Clean up whitespace
CompressWhitespace(titleStr); titleStr.CompressWhitespace();
linkStr.Trim("\b\t\r\n "); linkStr.Trim("\b\t\r\n ");
CompressWhitespace(dateStr); dateStr.CompressWhitespace();
if (titleStr.IsEmpty() && !dateStr.IsEmpty()) if (titleStr.IsEmpty() && !dateStr.IsEmpty())
titleStr.Assign(dateStr); titleStr.Assign(dateStr);

View File

@ -66,10 +66,11 @@
#include "nsRDFCID.h" #include "nsRDFCID.h"
#include "nsISupportsPrimitives.h" #include "nsISupportsPrimitives.h"
#include "rdf.h" #include "rdf.h"
#include "nsCRT.h"
#include "nsEnumeratorUtils.h" #include "nsEnumeratorUtils.h"
#include "nsEscape.h"
#include "nsAppDirectoryServiceDefs.h" #include "nsAppDirectoryServiceDefs.h"
#include "nsDirectoryServiceDefs.h" #include "nsDirectoryServiceDefs.h"
#include "nsDirectoryServiceUtils.h"
#include "nsUnicharUtils.h" #include "nsUnicharUtils.h"
#include "nsISound.h" #include "nsISound.h"
@ -93,13 +94,6 @@
#include "nsIWebNavigation.h" #include "nsIWebNavigation.h"
#include "plbase64.h" #include "plbase64.h"
#include "nsCRTGlue.h"
#if defined(XP_WIN) || defined(XP_OS2)
#define NS_LINEBREAK "\015\012"
#else
#define NS_LINEBREAK "\012"
#endif
nsIRDFResource *kNC_IEFavoritesRoot; nsIRDFResource *kNC_IEFavoritesRoot;
nsIRDFResource *kNC_SystemBookmarksStaticRoot; nsIRDFResource *kNC_SystemBookmarksStaticRoot;
@ -637,8 +631,6 @@ static const char kOpenMeta[] = "<META ";
static const char kPersonalToolbarFolderEquals[] = "PERSONAL_TOOLBAR_FOLDER=\""; static const char kPersonalToolbarFolderEquals[] = "PERSONAL_TOOLBAR_FOLDER=\"";
static const char kNameEquals[] = "NAME=\""; static const char kNameEquals[] = "NAME=\"";
static const char kNameEqualsLC[] = "name=\"";
static const char kHREFEquals[] = "HREF=\""; static const char kHREFEquals[] = "HREF=\"";
static const char kTargetEquals[] = "TARGET=\""; static const char kTargetEquals[] = "TARGET=\"";
static const char kAddDateEquals[] = "ADD_DATE=\""; static const char kAddDateEquals[] = "ADD_DATE=\"";
@ -865,7 +857,7 @@ BookmarkParser::DecodeBuffer(nsString &line, char *buf, PRUint32 aLength)
} }
else else
{ {
line.Append(NS_ConvertASCIItoUTF16(buf, aLength)); line.AppendWithConversion(buf, aLength);
} }
return NS_OK; return NS_OK;
} }
@ -930,7 +922,7 @@ BookmarkParser::ProcessLine(nsIRDFContainer *container, nsIRDFResource *nodeType
} }
} }
else if ((offset = line.Find(kOpenHeading, PR_TRUE)) >= 0 && else if ((offset = line.Find(kOpenHeading, PR_TRUE)) >= 0 &&
NS_IsAsciiDigit(line.CharAt(offset + 2))) nsCRT::IsAsciiDigit(line.CharAt(offset + 2)))
{ {
nsCOMPtr<nsIRDFResource> dummy; nsCOMPtr<nsIRDFResource> dummy;
if (line.CharAt(offset + 2) != PRUnichar('1')) if (line.CharAt(offset + 2) != PRUnichar('1'))
@ -1064,27 +1056,27 @@ BookmarkParser::Unescape(nsString &text)
while((offset = text.FindChar((PRUnichar('&')), offset)) >= 0) while((offset = text.FindChar((PRUnichar('&')), offset)) >= 0)
{ {
if (Substring(text, offset, 4).LowerCaseEqualsLiteral("&lt;")) if (Substring(text, offset, 4).Equals(NS_LITERAL_STRING("&lt;"), nsCaseInsensitiveStringComparator()))
{ {
text.Cut(offset, 4); text.Cut(offset, 4);
text.Insert(PRUnichar('<'), offset); text.Insert(PRUnichar('<'), offset);
} }
else if (Substring(text, offset, 4).LowerCaseEqualsLiteral("&gt;")) else if (Substring(text, offset, 4).Equals(NS_LITERAL_STRING("&gt;"), nsCaseInsensitiveStringComparator()))
{ {
text.Cut(offset, 4); text.Cut(offset, 4);
text.Insert(PRUnichar('>'), offset); text.Insert(PRUnichar('>'), offset);
} }
else if (Substring(text, offset, 5).LowerCaseEqualsLiteral("&amp;")) else if (Substring(text, offset, 5).Equals(NS_LITERAL_STRING("&amp;"), nsCaseInsensitiveStringComparator()))
{ {
text.Cut(offset, 5); text.Cut(offset, 5);
text.Insert(PRUnichar('&'), offset); text.Insert(PRUnichar('&'), offset);
} }
else if (Substring(text, offset, 6).LowerCaseEqualsLiteral("&quot;")) else if (Substring(text, offset, 6).Equals(NS_LITERAL_STRING("&quot;"), nsCaseInsensitiveStringComparator()))
{ {
text.Cut(offset, 6); text.Cut(offset, 6);
text.Insert(PRUnichar('\"'), offset); text.Insert(PRUnichar('\"'), offset);
} }
else if (Substring(text, offset, 5).LowerCaseEqualsLiteral("&#39;")) else if (Substring(text, offset, 5).Equals(NS_LITERAL_STRING("&#39;")))
{ {
text.Cut(offset, 5); text.Cut(offset, 5);
text.Insert(PRUnichar('\''), offset); text.Insert(PRUnichar('\''), offset);
@ -1110,10 +1102,11 @@ BookmarkParser::ParseMetaTag(const nsString &aLine, nsIUnicodeDecoder **decoder)
start += (sizeof(kHTTPEquivEquals) - 1); start += (sizeof(kHTTPEquivEquals) - 1);
// ...and find the next so we can chop the HTTP-EQUIV attribute // ...and find the next so we can chop the HTTP-EQUIV attribute
PRInt32 end = aLine.FindChar(PRUnichar('"'), start); PRInt32 end = aLine.FindChar(PRUnichar('"'), start);
nsAutoString httpEquiv(Substring(aLine, start, end - start)); nsAutoString httpEquiv;
aLine.Mid(httpEquiv, start, end - start);
// if HTTP-EQUIV isn't "Content-Type", just ignore the META tag // if HTTP-EQUIV isn't "Content-Type", just ignore the META tag
if (!httpEquiv.LowerCaseEqualsLiteral("content-type")) if (!httpEquiv.EqualsIgnoreCase("Content-Type"))
return NS_OK; return NS_OK;
// get the CONTENT attribute // get the CONTENT attribute
@ -1124,15 +1117,16 @@ BookmarkParser::ParseMetaTag(const nsString &aLine, nsIUnicodeDecoder **decoder)
start += (sizeof(kContentEquals) - 1); start += (sizeof(kContentEquals) - 1);
// ...and find the next so we can chop the CONTENT attribute // ...and find the next so we can chop the CONTENT attribute
end = aLine.FindChar(PRUnichar('"'), start); end = aLine.FindChar(PRUnichar('"'), start);
nsAutoString content(Substring(aLine, start, end - start)); nsAutoString content;
aLine.Mid(content, start, end - start);
// look for the charset value // look for the charset value
start = content.Find(kCharsetEquals, PR_TRUE); start = content.Find(kCharsetEquals, PR_TRUE);
NS_ASSERTION(start >= 0, "no 'charset=' string: how'd we get here?"); NS_ASSERTION(start >= 0, "no 'charset=' string: how'd we get here?");
if (start < 0) return NS_ERROR_UNEXPECTED; if (start < 0) return NS_ERROR_UNEXPECTED;
start += (sizeof(kCharsetEquals)-1); start += (sizeof(kCharsetEquals)-1);
NS_LossyConvertUTF16toASCII charset(Substring(content, start, nsCAutoString charset;
content.Length() - start)); charset.AssignWithConversion(Substring(content, start, content.Length() - start));
if (charset.Length() < 1) return NS_ERROR_UNEXPECTED; if (charset.Length() < 1) return NS_ERROR_UNEXPECTED;
// found a charset, now try and get a decoder from it to Unicode // found a charset, now try and get a decoder from it to Unicode
@ -1205,13 +1199,13 @@ BookmarkParser::ParseBookmarkInfo(BookmarkField *fields, PRBool isBookmarkFlag,
PRInt32 attrStart=0; PRInt32 attrStart=0;
if (isBookmarkFlag == PR_TRUE) if (isBookmarkFlag == PR_TRUE)
{ {
attrStart = aLine.Find(kOpenAnchor, attrStart, PR_TRUE); attrStart = aLine.Find(kOpenAnchor, PR_TRUE, attrStart);
if (attrStart < 0) return NS_ERROR_UNEXPECTED; if (attrStart < 0) return NS_ERROR_UNEXPECTED;
attrStart += sizeof(kOpenAnchor)-1; attrStart += sizeof(kOpenAnchor)-1;
} }
else else
{ {
attrStart = aLine.Find(kOpenHeading, attrStart, PR_TRUE); attrStart = aLine.Find(kOpenHeading, PR_TRUE, attrStart);
if (attrStart < 0) return NS_ERROR_UNEXPECTED; if (attrStart < 0) return NS_ERROR_UNEXPECTED;
attrStart += sizeof(kOpenHeading)-1; attrStart += sizeof(kOpenHeading)-1;
} }
@ -1225,14 +1219,16 @@ BookmarkParser::ParseBookmarkInfo(BookmarkField *fields, PRBool isBookmarkFlag,
// loop over attributes // loop over attributes
while((attrStart < lineLen) && (aLine[attrStart] != '>')) while((attrStart < lineLen) && (aLine[attrStart] != '>'))
{ {
while(NS_IsAsciiWhitespace(aLine[attrStart])) ++attrStart; while(nsCRT::IsAsciiSpace(aLine[attrStart])) ++attrStart;
PRBool fieldFound = PR_FALSE; PRBool fieldFound = PR_FALSE;
NS_ConvertASCIItoUTF16 id(kIDEquals); nsAutoString id;
id.AssignWithConversion(kIDEquals);
for (BookmarkField *field = fields; field->mName; ++field) for (BookmarkField *field = fields; field->mName; ++field)
{ {
NS_ConvertASCIItoUTF16 name(field->mName); nsAutoString name;
name.AssignWithConversion(field->mName);
if (mIsImportOperation && name.Equals(id)) if (mIsImportOperation && name.Equals(id))
// For import operations, we don't want to save the unique // For import operations, we don't want to save the unique
// identifier for folders, because this can cause bugs like // identifier for folders, because this can cause bugs like
@ -1245,8 +1241,7 @@ BookmarkParser::ParseBookmarkInfo(BookmarkField *fields, PRBool isBookmarkFlag,
// We don't want to assert a BTF arc twice. // We don't want to assert a BTF arc twice.
continue; continue;
if (Substring(aLine, attrStart, name.Length()). if (aLine.Find(field->mName, PR_TRUE, attrStart, 1) == attrStart)
Equals(name, CaseInsensitiveCompare))
{ {
attrStart += strlen(field->mName); attrStart += strlen(field->mName);
@ -1255,8 +1250,8 @@ BookmarkParser::ParseBookmarkInfo(BookmarkField *fields, PRBool isBookmarkFlag,
if (termQuote > attrStart) if (termQuote > attrStart)
{ {
// process data // process data
nsAutoString data(Substring(aLine, attrStart, nsAutoString data;
termQuote-attrStart)); aLine.Mid(data, attrStart, termQuote-attrStart);
attrStart = termQuote + 1; attrStart = termQuote + 1;
fieldFound = PR_TRUE; fieldFound = PR_TRUE;
@ -1286,7 +1281,7 @@ BookmarkParser::ParseBookmarkInfo(BookmarkField *fields, PRBool isBookmarkFlag,
{ {
// skip to next attribute // skip to next attribute
while((attrStart < lineLen) && (aLine[attrStart] != '>') && while((attrStart < lineLen) && (aLine[attrStart] != '>') &&
(!NS_IsAsciiWhitespace(aLine[attrStart]))) (!nsCRT::IsAsciiSpace(aLine[attrStart])))
{ {
++attrStart; ++attrStart;
} }
@ -1322,7 +1317,7 @@ BookmarkParser::ParseBookmarkInfo(BookmarkField *fields, PRBool isBookmarkFlag,
PRBool isIEFavoriteRoot = PR_FALSE; PRBool isIEFavoriteRoot = PR_FALSE;
if (!mIEFavoritesRoot.IsEmpty()) if (!mIEFavoritesRoot.IsEmpty())
{ {
if (!strcmp(mIEFavoritesRoot.get(), bookmarkURI)) if (!nsCRT::strcmp(mIEFavoritesRoot.get(), bookmarkURI))
{ {
mFoundIEFavoritesRoot = PR_TRUE; mFoundIEFavoritesRoot = PR_TRUE;
isIEFavoriteRoot = PR_TRUE; isIEFavoriteRoot = PR_TRUE;
@ -1369,8 +1364,8 @@ BookmarkParser::ParseBookmarkInfo(BookmarkField *fields, PRBool isBookmarkFlag,
if (nameEnd > attrStart) if (nameEnd > attrStart)
{ {
nsAutoString name(Substring(aLine, attrStart, nsAutoString name;
nameEnd-attrStart)); aLine.Mid(name, attrStart, nameEnd-attrStart);
if (!name.IsEmpty()) if (!name.IsEmpty())
{ {
Unescape(name); Unescape(name);
@ -1445,7 +1440,8 @@ BookmarkParser::ParseResource(nsIRDFResource *arc, nsString& url, nsIRDFNode** a
PRInt32 offset; PRInt32 offset;
while ((offset = url.Find(kEscape22)) >= 0) while ((offset = url.Find(kEscape22)) >= 0)
{ {
url.Replace(offset, sizeof(kEscape22) - 1, '\"'); url.SetCharAt('\"',offset);
url.Cut(offset + 1, sizeof(kEscape22) - 2);
} }
// XXX At this point, the URL may be relative. 4.5 called into // XXX At this point, the URL may be relative. 4.5 called into
@ -1457,8 +1453,7 @@ BookmarkParser::ParseResource(nsIRDFResource *arc, nsString& url, nsIRDFNode** a
// if we don't have a protocol scheme, add "http://" as a default scheme // if we don't have a protocol scheme, add "http://" as a default scheme
if (url.FindChar(PRUnichar(':')) < 0) if (url.FindChar(PRUnichar(':')) < 0)
{ {
url.AssignLiteral("http://"); url.Assign(NS_LITERAL_STRING("http://") + url);
url.Append(url);
} }
} }
@ -1483,9 +1478,9 @@ BookmarkParser::ParseLiteral(nsIRDFResource *arc, nsString& aValue, nsIRDFNode**
{ {
if (gCharsetAlias) if (gCharsetAlias)
{ {
NS_LossyConvertUTF16toASCII charset(aValue); nsCAutoString charset; charset.AssignWithConversion(aValue);
gCharsetAlias->GetPreferred(charset, charset); gCharsetAlias->GetPreferred(charset, charset);
CopyASCIItoUTF16(charset, aValue); aValue.AssignWithConversion(charset.get());
} }
} }
else if (arc == kWEB_LastPingETag) else if (arc == kWEB_LastPingETag)
@ -1508,13 +1503,13 @@ BookmarkParser::ParseLiteral(nsIRDFResource *arc, nsString& aValue, nsIRDFNode**
nsresult nsresult
BookmarkParser::ParseDate(nsIRDFResource *arc, nsString& aValue, nsIRDFNode** aResult) BookmarkParser::ParseDate(nsIRDFResource *arc, nsString& aValue, nsIRDFNode** aResult)
{ {
nsresult rv;
*aResult = nsnull; *aResult = nsnull;
PRInt32 theDate = 0; PRInt32 theDate = 0;
if (!aValue.IsEmpty()) if (!aValue.IsEmpty())
{ {
theDate = aValue.ToInteger(&rv); // ignored. PRInt32 err;
theDate = aValue.ToInteger(&err); // ignored.
} }
if (theDate == 0) return NS_RDF_NO_VALUE; if (theDate == 0) return NS_RDF_NO_VALUE;
@ -1524,6 +1519,7 @@ BookmarkParser::ParseDate(nsIRDFResource *arc, nsString& aValue, nsIRDFNode** aR
LL_I2L(million, PR_USEC_PER_SEC); LL_I2L(million, PR_USEC_PER_SEC);
LL_MUL(dateVal, temp, million); LL_MUL(dateVal, temp, million);
nsresult rv;
nsCOMPtr<nsIRDFDate> result; nsCOMPtr<nsIRDFDate> result;
if (NS_FAILED(rv = gRDF->GetDateLiteral(dateVal, getter_AddRefs(result)))) if (NS_FAILED(rv = gRDF->GetDateLiteral(dateVal, getter_AddRefs(result))))
{ {
@ -1585,17 +1581,17 @@ BookmarkParser::ParseBookmarkSeparator(const nsString &aLine, const nsCOMPtr<nsI
attrStart += sizeof(kSeparator)-1; attrStart += sizeof(kSeparator)-1;
while((attrStart < lineLen) && (aLine[attrStart] != '>')) { while((attrStart < lineLen) && (aLine[attrStart] != '>')) {
while(NS_IsAsciiWhitespace(aLine[attrStart])) while(nsCRT::IsAsciiSpace(aLine[attrStart]))
++attrStart; ++attrStart;
if (Substring(aLine, attrStart, sizeof(kNameEqualsLC) - 1).LowerCaseEqualsLiteral(kNameEqualsLC)) { if (aLine.Find(kNameEquals, PR_TRUE, attrStart, 1) == attrStart) {
attrStart += sizeof(kNameEqualsLC) - 1; attrStart += sizeof(kNameEquals) - 1;
// skip to terminating quote of string // skip to terminating quote of string
PRInt32 termQuote = aLine.FindChar(PRUnichar('\"'), attrStart); PRInt32 termQuote = aLine.FindChar(PRUnichar('\"'), attrStart);
if (termQuote > attrStart) { if (termQuote > attrStart) {
nsAutoString name(Substring(aLine, attrStart, nsAutoString name;
termQuote - attrStart)); aLine.Mid(name, attrStart, termQuote - attrStart);
attrStart = termQuote + 1; attrStart = termQuote + 1;
if (!name.IsEmpty()) { if (!name.IsEmpty()) {
nsCOMPtr<nsIRDFLiteral> nameLiteral; nsCOMPtr<nsIRDFLiteral> nameLiteral;
@ -1781,7 +1777,8 @@ nsresult
nsBookmarksService::getLocaleString(const char *key, nsString &str) nsBookmarksService::getLocaleString(const char *key, nsString &str)
{ {
PRUnichar *keyUni = nsnull; PRUnichar *keyUni = nsnull;
NS_ConvertASCIItoUTF16 keyStr(key); nsAutoString keyStr;
keyStr.AssignWithConversion(key);
nsresult rv = NS_RDF_NO_VALUE; nsresult rv = NS_RDF_NO_VALUE;
if (mBundle && (NS_SUCCEEDED(rv = mBundle->GetStringFromName(keyStr.get(), &keyUni))) if (mBundle && (NS_SUCCEEDED(rv = mBundle->GetStringFromName(keyStr.get(), &keyUni)))
@ -1848,14 +1845,16 @@ nsBookmarksService::ExamineBookmarkSchedule(nsIRDFResource *theBookmark, PRBool
PRInt32 slashOffset; PRInt32 slashOffset;
if ((slashOffset = schedule.FindChar(PRUnichar('|'))) >= 0) if ((slashOffset = schedule.FindChar(PRUnichar('|'))) >= 0)
{ {
nsAutoString daySection(StringTail(schedule, slashOffset)); nsAutoString daySection;
schedule.Left(daySection, slashOffset);
schedule.Cut(0, slashOffset+1); schedule.Cut(0, slashOffset+1);
if (daySection.Find(dayNum) >= 0) if (daySection.Find(dayNum) >= 0)
{ {
// ok, we should be checking today. Within hour range? // ok, we should be checking today. Within hour range?
if ((slashOffset = schedule.FindChar(PRUnichar('|'))) >= 0) if ((slashOffset = schedule.FindChar(PRUnichar('|'))) >= 0)
{ {
nsAutoString hourRange(StringTail(schedule, slashOffset)); nsAutoString hourRange;
schedule.Left(hourRange, slashOffset);
schedule.Cut(0, slashOffset+1); schedule.Cut(0, slashOffset+1);
// now have the "hour-range" segment of the string // now have the "hour-range" segment of the string
@ -1863,26 +1862,29 @@ nsBookmarksService::ExamineBookmarkSchedule(nsIRDFResource *theBookmark, PRBool
PRInt32 dashOffset; PRInt32 dashOffset;
if ((dashOffset = hourRange.FindChar(PRUnichar('-'))) >= 1) if ((dashOffset = hourRange.FindChar(PRUnichar('-'))) >= 1)
{ {
nsAutoString endStr(StringTail(hourRange, nsAutoString startStr, endStr;
hourRange.Length() - dashOffset - 1));
nsAutoString startStr(StringHead(hourRange, dashOffset));
nsresult rv2; hourRange.Right(endStr, hourRange.Length() - dashOffset - 1);
startHour = startStr.ToInteger(&rv2); hourRange.Left(startStr, dashOffset);
if (NS_FAILED(rv2)) startHour = -1;
endHour = endStr.ToInteger(&rv2); PRInt32 errorCode2 = 0;
if (NS_FAILED(rv2)) endHour = -1; startHour = startStr.ToInteger(&errorCode2);
if (errorCode2) startHour = -1;
endHour = endStr.ToInteger(&errorCode2);
if (errorCode2) endHour = -1;
if ((startHour >=0) && (endHour >=0)) if ((startHour >=0) && (endHour >=0))
{ {
if ((slashOffset = schedule.FindChar(PRUnichar('|'))) >= 0) if ((slashOffset = schedule.FindChar(PRUnichar('|'))) >= 0)
{ {
nsAutoString durationStr(StringHead(schedule, slashOffset)); nsAutoString durationStr;
schedule.Left(durationStr, slashOffset);
schedule.Cut(0, slashOffset+1); schedule.Cut(0, slashOffset+1);
// get duration // get duration
duration = durationStr.ToInteger(&rv2); PRInt32 errorCode = 0;
if (NS_FAILED(rv2)) duration = -1; duration = durationStr.ToInteger(&errorCode);
if (errorCode) duration = -1;
// what's left is the notification options // what's left is the notification options
notificationMethod = schedule; notificationMethod = schedule;
@ -2167,7 +2169,7 @@ nsBookmarksService::OnStopRequest(nsIRequest* request, nsISupports *ctxt,
currentETagLit->GetValueConst(&currentETagStr); currentETagLit->GetValueConst(&currentETagStr);
if ((currentETagStr) && if ((currentETagStr) &&
!eTagValue.Equals(nsDependentString(currentETagStr), !eTagValue.Equals(nsDependentString(currentETagStr),
CaseInsensitiveCompare)) nsCaseInsensitiveStringComparator()))
{ {
changedFlag = PR_TRUE; changedFlag = PR_TRUE;
} }
@ -2213,7 +2215,7 @@ nsBookmarksService::OnStopRequest(nsIRequest* request, nsISupports *ctxt,
currentLastModLit->GetValueConst(&currentLastModStr); currentLastModLit->GetValueConst(&currentLastModStr);
if ((currentLastModStr) && if ((currentLastModStr) &&
!lastModValue.Equals(nsDependentString(currentLastModStr), !lastModValue.Equals(nsDependentString(currentLastModStr),
CaseInsensitiveCompare)) nsCaseInsensitiveStringComparator()))
{ {
changedFlag = PR_TRUE; changedFlag = PR_TRUE;
} }
@ -2257,7 +2259,7 @@ nsBookmarksService::OnStopRequest(nsIRequest* request, nsISupports *ctxt,
currentContentLengthLit->GetValueConst(&currentContentLengthStr); currentContentLengthLit->GetValueConst(&currentContentLengthStr);
if ((currentContentLengthStr) && if ((currentContentLengthStr) &&
!contentLengthValue.Equals(nsDependentString(currentContentLengthStr), !contentLengthValue.Equals(nsDependentString(currentContentLengthStr),
CaseInsensitiveCompare)) nsCaseInsensitiveStringComparator()))
{ {
changedFlag = PR_TRUE; changedFlag = PR_TRUE;
} }
@ -2333,7 +2335,9 @@ nsBookmarksService::OnStopRequest(nsIRequest* request, nsISupports *ctxt,
} }
// update icon? // update icon?
if (schedule.Find("icon", PR_TRUE) != -1) if (FindInReadable(NS_LITERAL_STRING("icon"),
schedule,
nsCaseInsensitiveStringComparator()))
{ {
nsCOMPtr<nsIRDFLiteral> statusLiteral; nsCOMPtr<nsIRDFLiteral> statusLiteral;
if (NS_SUCCEEDED(rv = gRDF->GetLiteral(NS_LITERAL_STRING("new").get(), getter_AddRefs(statusLiteral)))) if (NS_SUCCEEDED(rv = gRDF->GetLiteral(NS_LITERAL_STRING("new").get(), getter_AddRefs(statusLiteral))))
@ -2353,7 +2357,9 @@ nsBookmarksService::OnStopRequest(nsIRequest* request, nsISupports *ctxt,
} }
// play a sound? // play a sound?
if (schedule.Find("sound", PR_TRUE)) if (FindInReadable(NS_LITERAL_STRING("sound"),
schedule,
nsCaseInsensitiveStringComparator()))
{ {
nsCOMPtr<nsISound> soundInterface = do_CreateInstance("@mozilla.org/sound;1", &rv); nsCOMPtr<nsISound> soundInterface = do_CreateInstance("@mozilla.org/sound;1", &rv);
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
@ -2366,7 +2372,9 @@ nsBookmarksService::OnStopRequest(nsIRequest* request, nsISupports *ctxt,
PRBool openURLFlag = PR_FALSE; PRBool openURLFlag = PR_FALSE;
// show an alert? // show an alert?
if (schedule.Find("alert", PR_TRUE)) if (FindInReadable(NS_LITERAL_STRING("alert"),
schedule,
nsCaseInsensitiveStringComparator()))
{ {
nsCOMPtr<nsIPrompt> prompter; nsCOMPtr<nsIPrompt> prompter;
NS_QueryNotificationCallbacks(channel, prompter); NS_QueryNotificationCallbacks(channel, prompter);
@ -2439,7 +2447,9 @@ nsBookmarksService::OnStopRequest(nsIRequest* request, nsISupports *ctxt,
// open the URL in a new window? // open the URL in a new window?
if ((openURLFlag == PR_TRUE) || if ((openURLFlag == PR_TRUE) ||
schedule.Find("open", PR_TRUE)) FindInReadable(NS_LITERAL_STRING("open"),
schedule,
nsCaseInsensitiveStringComparator()))
{ {
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
{ {
@ -2483,12 +2493,12 @@ NS_IMETHODIMP nsBookmarksService::Observe(nsISupports *aSubject, const char *aTo
{ {
nsresult rv = NS_OK; nsresult rv = NS_OK;
if (!strcmp(aTopic, "profile-before-change")) if (!nsCRT::strcmp(aTopic, "profile-before-change"))
{ {
// The profile has not changed yet. // The profile has not changed yet.
rv = Flush(); rv = Flush();
if (!NS_strcmp(someData, NS_LITERAL_STRING("shutdown-cleanse").get())) if (!nsCRT::strcmp(someData, NS_LITERAL_STRING("shutdown-cleanse").get()))
{ {
nsCOMPtr<nsIFile> bookmarksFile; nsCOMPtr<nsIFile> bookmarksFile;
@ -2500,13 +2510,13 @@ NS_IMETHODIMP nsBookmarksService::Observe(nsISupports *aSubject, const char *aTo
} }
} }
} }
else if (!strcmp(aTopic, "profile-after-change")) else if (!nsCRT::strcmp(aTopic, "profile-after-change"))
{ {
// The profile has aleady changed. // The profile has aleady changed.
rv = LoadBookmarks(); rv = LoadBookmarks();
} }
#ifdef MOZ_PHOENIX #ifdef MOZ_PHOENIX
else if (!strcmp(aTopic, "quit-application")) else if (!nsCRT::strcmp(aTopic, "quit-application"))
{ {
rv = Flush(); rv = Flush();
} }
@ -3481,7 +3491,7 @@ nsBookmarksService::RequestCharset(nsIWebNavigation* aWebNavigation,
if (charsetLiteral) { if (charsetLiteral) {
const PRUnichar *charset; const PRUnichar *charset;
charsetLiteral->GetValueConst(&charset); charsetLiteral->GetValueConst(&charset);
LossyCopyUTF16toASCII(nsDependentString(charset), aResult); LossyCopyUTF16toASCII(charset, aResult);
return NS_OK; return NS_OK;
} }
@ -3694,7 +3704,7 @@ nsBookmarksService::GetLastModifiedFolders(nsISimpleEnumerator **aResult)
NS_IMETHODIMP NS_IMETHODIMP
nsBookmarksService::GetURI(char* *aURI) nsBookmarksService::GetURI(char* *aURI)
{ {
*aURI = NS_strdup("rdf:bookmarks"); *aURI = nsCRT::strdup("rdf:bookmarks");
if (! *aURI) if (! *aURI)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -4267,7 +4277,7 @@ nsBookmarksService::exportBookmarks(nsISupportsArray *aArguments)
rv = NS_NewLocalFile(nsDependentString(pathUni), PR_TRUE, getter_AddRefs(file)); rv = NS_NewLocalFile(nsDependentString(pathUni), PR_TRUE, getter_AddRefs(file));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
if (format && NS_LITERAL_STRING("RDF").Equals(format, CaseInsensitiveCompare)) if (format && NS_LITERAL_STRING("RDF").Equals(format, nsCaseInsensitiveStringComparator()))
{ {
nsCOMPtr<nsIURI> uri; nsCOMPtr<nsIURI> uri;
nsresult rv = NS_NewFileURI(getter_AddRefs(uri), file); nsresult rv = NS_NewFileURI(getter_AddRefs(uri), file);
@ -4626,13 +4636,13 @@ nsBookmarksService::InitDataSource()
// create livemark bookmarks // create livemark bookmarks
{ {
nsString lmloadingName; nsXPIDLString lmloadingName;
rv = mBundle->GetStringFromName(NS_LITERAL_STRING("BookmarksLivemarkLoading").get(), getter_Copies(lmloadingName)); rv = mBundle->GetStringFromName(NS_LITERAL_STRING("BookmarksLivemarkLoading").get(), getter_Copies(lmloadingName));
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
lmloadingName.Assign(NS_LITERAL_STRING("Live Bookmark loading...")); lmloadingName.Assign(NS_LITERAL_STRING("Live Bookmark loading..."));
} }
nsString lmfailedName; nsXPIDLString lmfailedName;
rv = mBundle->GetStringFromName(NS_LITERAL_STRING("BookmarksLivemarkFailed").get(), getter_Copies(lmfailedName)); rv = mBundle->GetStringFromName(NS_LITERAL_STRING("BookmarksLivemarkFailed").get(), getter_Copies(lmfailedName));
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
lmfailedName.Assign(NS_LITERAL_STRING("Live Bookmark feed failed to load.")); lmfailedName.Assign(NS_LITERAL_STRING("Live Bookmark feed failed to load."));
@ -4805,7 +4815,7 @@ nsBookmarksService::LoadBookmarks()
} }
// Sets the default bookmarks root name. // Sets the default bookmarks root name.
nsString brName; nsXPIDLString brName;
rv = mBundle->GetStringFromName(NS_LITERAL_STRING("BookmarksRoot").get(), getter_Copies(brName)); rv = mBundle->GetStringFromName(NS_LITERAL_STRING("BookmarksRoot").get(), getter_Copies(brName));
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
// remove any previous NC_Name assertion // remove any previous NC_Name assertion
@ -5140,53 +5150,6 @@ nsBookmarksService::WriteBookmarksContainer(nsIRDFDataSource *ds,
return NS_OK; return NS_OK;
} }
/**
* Escape HTML-special characters in a string.
*/
static void
EscapeHTML(nsACString &data)
{
const char *begin, *end;
PRUint32 len = data.BeginReading(&begin, &end);
for (PRUint32 pos = 0; pos < len; ++pos) {
PRUint32 longer;
switch (begin[pos]) {
case '<':
data.Replace(pos, 1, "&lt;");
longer = 3;
break;
case '>':
data.Replace(pos, 1, "&gt;");
longer = 3;
break;
case '&':
data.Replace(pos, 1, "&amp;");
longer = 4;
break;
case '"':
data.Replace(pos, 1, "&quot;");
longer = 5;
break;
case '\'':
data.Replace(pos, 1, "&#39;");
longer = 4;
break;
default:
continue;
}
pos += longer;
len = data.BeginReading(&begin, &end);
}
}
nsresult nsresult
nsBookmarksService::WriteBookmarkIdAndName(nsIRDFDataSource *aDs, nsBookmarksService::WriteBookmarkIdAndName(nsIRDFDataSource *aDs,
nsIOutputStream* aStrm, nsIRDFResource* aChild) nsIOutputStream* aStrm, nsIRDFResource* aChild)
@ -5197,15 +5160,19 @@ nsBookmarksService::WriteBookmarkIdAndName(nsIRDFDataSource *aDs,
// output ID // output ID
// <A ... ID="rdf:#$Rd48+1">Name</A> // <A ... ID="rdf:#$Rd48+1">Name</A>
// ^^^^^^^^^^^^^^^^^^ // ^^^^^^^^^^^^^^^^^^
nsCString id; const char *id = nsnull;
rv = aChild->GetValueUTF8(id); rv = aChild->GetValueConst(&id);
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv) && (id))
{ {
EscapeHTML(id); char *escapedID = nsEscapeHTML(id);
rv |= aStrm->Write(kSpaceStr, sizeof(kSpaceStr)-1, &dummy); if (escapedID)
rv |= aStrm->Write(kIDEquals, sizeof(kIDEquals)-1, &dummy); {
rv |= aStrm->Write(id.get(), id.Length(), &dummy); rv |= aStrm->Write(kSpaceStr, sizeof(kSpaceStr)-1, &dummy);
rv |= aStrm->Write(kQuoteStr, sizeof(kQuoteStr)-1, &dummy); rv |= aStrm->Write(kIDEquals, sizeof(kIDEquals)-1, &dummy);
rv |= aStrm->Write(escapedID, strlen(escapedID), &dummy);
rv |= aStrm->Write(kQuoteStr, sizeof(kQuoteStr)-1, &dummy);
NS_Free(escapedID);
}
} }
// <A ... ID="rdf:#$Rd48+1">Name</A> // <A ... ID="rdf:#$Rd48+1">Name</A>
@ -5232,8 +5199,12 @@ nsBookmarksService::WriteBookmarkIdAndName(nsIRDFDataSource *aDs,
return NS_OK; return NS_OK;
// see bug #65098 // see bug #65098
EscapeHTML(name); char *escapedAttrib = nsEscapeHTML(name.get());
rv = aStrm->Write(name.get(), name.Length(), &dummy); if (escapedAttrib)
{
rv = aStrm->Write(escapedAttrib, strlen(escapedAttrib), &dummy);
NS_Free(escapedAttrib);
}
return rv; return rv;
} }
@ -5261,38 +5232,48 @@ nsBookmarksService::WriteBookmarkProperties(nsIRDFDataSource *aDs,
} }
} }
NS_ConvertUTF16toUTF8 attribute(literalString); char *attribute = ToNewUTF8String(literalString);
if (aIsFirst == PR_FALSE) if (nsnull != attribute)
{ {
rv |= aStrm->Write(kSpaceStr, sizeof(kSpaceStr)-1, &dummy); if (aIsFirst == PR_FALSE)
}
if (!literalString.IsEmpty())
{
// We don't HTML-escape URL properties (we instead
// URL-escape double-quotes in them--see above) so that
// URLs with ampersands don't break if the user switches
// back to a build from before we started escaping.
if (aProperty == kNC_URL || aProperty == kNC_FeedURL)
{ {
rv |= aStrm->Write(aHtmlAttrib, strlen(aHtmlAttrib), &dummy); rv |= aStrm->Write(kSpaceStr, sizeof(kSpaceStr)-1, &dummy);
rv |= aStrm->Write(attribute.get(), attribute.Length(), &dummy);
rv |= aStrm->Write(kQuoteStr, sizeof(kQuoteStr)-1, &dummy);
} }
else
if (!literalString.IsEmpty())
{ {
EscapeHTML(attribute); // We don't HTML-escape URL properties (we instead
rv |= aStrm->Write(aHtmlAttrib, strlen(aHtmlAttrib), &dummy); // URL-escape double-quotes in them--see above) so that
rv |= aStrm->Write(attribute.get(), attribute.Length(), &dummy); // URLs with ampersands don't break if the user switches
if (aProperty == kNC_Description) // back to a build from before we started escaping.
if (aProperty == kNC_URL || aProperty == kNC_FeedURL)
{ {
rv |= aStrm->Write(kNL, sizeof(kNL)-1, &dummy); rv |= aStrm->Write(aHtmlAttrib, strlen(aHtmlAttrib), &dummy);
rv |= aStrm->Write(attribute, strlen(attribute), &dummy);
rv |= aStrm->Write(kQuoteStr, sizeof(kQuoteStr)-1, &dummy);
} }
else else
{ {
rv |= aStrm->Write(kQuoteStr, sizeof(kQuoteStr)-1, &dummy); char *escapedAttrib = nsEscapeHTML(attribute);
if (escapedAttrib)
{
rv |= aStrm->Write(aHtmlAttrib, strlen(aHtmlAttrib), &dummy);
rv |= aStrm->Write(escapedAttrib, strlen(escapedAttrib), &dummy);
if (aProperty == kNC_Description)
{
rv |= aStrm->Write(kNL, sizeof(kNL)-1, &dummy);
}
else
{
rv |= aStrm->Write(kQuoteStr, sizeof(kQuoteStr)-1, &dummy);
}
NS_Free(escapedAttrib);
escapedAttrib = nsnull;
}
} }
} }
NS_Free(attribute);
attribute = nsnull;
} }
} }
} }
@ -5363,7 +5344,7 @@ nsBookmarksService::GetTextForNode(nsIRDFNode* aNode, nsString& aResult)
const char *p = nsnull; const char *p = nsnull;
if (NS_SUCCEEDED(rv = resource->GetValueConst( &p )) && (p)) if (NS_SUCCEEDED(rv = resource->GetValueConst( &p )) && (p))
{ {
CopyASCIItoUTF16(nsDependentCString(p), aResult); aResult.AssignWithConversion(p);
} }
NS_RELEASE(resource); NS_RELEASE(resource);
} }

View File

@ -48,7 +48,7 @@
#include "nsITimer.h" #include "nsITimer.h"
#include "nsIRDFNode.h" #include "nsIRDFNode.h"
#include "nsIBookmarksService.h" #include "nsIBookmarksService.h"
#include "nsStringAPI.h" #include "nsString.h"
#include "nsIFile.h" #include "nsIFile.h"
#include "nsIObserver.h" #include "nsIObserver.h"
#include "nsWeakReference.h" #include "nsWeakReference.h"
@ -88,7 +88,7 @@ protected:
PRUint32 htmlSize; PRUint32 htmlSize;
PRInt32 mUpdateBatchNest; PRInt32 mUpdateBatchNest;
nsString mPersonalToolbarName; nsXPIDLString mPersonalToolbarName;
PRBool mBookmarksAvailable; PRBool mBookmarksAvailable;
PRBool mDirty; PRBool mDirty;
PRBool mBrowserIcons; PRBool mBrowserIcons;

View File

@ -45,22 +45,25 @@
#include "nsIRDFObserver.h" #include "nsIRDFObserver.h"
#include "nsIRDFService.h" #include "nsIRDFService.h"
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
#include "nsServiceManagerUtils.h" #include "nsXPIDLString.h"
#include "nsStringAPI.h"
#include "rdf.h" #include "rdf.h"
#include "nsRDFCID.h" #include "nsRDFCID.h"
#include "nsCRT.h"
#include "nsEnumeratorUtils.h" #include "nsEnumeratorUtils.h"
#include "nsForwardProxyDataSource.h" #include "nsForwardProxyDataSource.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
nsresult nsresult
nsForwardProxyDataSource::Init(void) nsForwardProxyDataSource::Init(void)
{ {
nsresult rv; nsresult rv;
// do we need to initialize our globals? // do we need to initialize our globals?
nsCOMPtr<nsIRDFService> rdf = do_GetService("@mozilla.org/rdf/rdf-service;1"); nsCOMPtr<nsIRDFService> rdf = do_GetService(kRDFServiceCID);
if (!rdf) { if (!rdf) {
NS_WARNING ("unable to get RDF service"); NS_WARNING ("unable to get RDF service");
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -204,7 +207,7 @@ nsForwardProxyDataSource::GetURI(char* *uri)
nsCAutoString theURI(NS_LITERAL_CSTRING("x-rdf-infer:forward-proxy")); nsCAutoString theURI(NS_LITERAL_CSTRING("x-rdf-infer:forward-proxy"));
nsCString dsURI; nsXPIDLCString dsURI;
rv = mDS->GetURI(getter_Copies(dsURI)); rv = mDS->GetURI(getter_Copies(dsURI));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
@ -213,9 +216,9 @@ nsForwardProxyDataSource::GetURI(char* *uri)
theURI += dsURI; theURI += dsURI;
} }
*uri = ToNewCString(theURI); if ((*uri = nsCRT::strdup(theURI.get())) == nsnull) {
if (*uri == nsnull)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
}
return NS_OK; return NS_OK;
} }

View File

@ -8,9 +8,10 @@ include $(DEPTH)/config/autoconf.mk
MODULE = browsercomps MODULE = browsercomps
LIBRARY_NAME = browsercomps LIBRARY_NAME = browsercomps
SHORT_LIBNAME = brwsrcmp SHORT_LIBNAME = brwsrcmp
EXPORT_LIBRARY = 1
IS_COMPONENT = 1 IS_COMPONENT = 1
MODULE_NAME = nsBrowserCompsModule MODULE_NAME = nsBrowserCompsModule
FORCE_SHARED_LIB = 1 MOZILLA_INTERNAL_API = 1
REQUIRES = \ REQUIRES = \
docshell \ docshell \
@ -74,12 +75,17 @@ LOCAL_INCLUDES += -I$(srcdir)/../safebrowsing/src
SHARED_LIBRARY_LIBS += ../safebrowsing/src/$(LIB_PREFIX)safebrowsing_s.$(LIB_SUFFIX) SHARED_LIBRARY_LIBS += ../safebrowsing/src/$(LIB_PREFIX)safebrowsing_s.$(LIB_SUFFIX)
endif endif
# Link to gkgfx for GNOME shell service
ifeq ($(MOZ_WIDGET_TOOLKIT), gtk2)
EXTRA_DSO_LIBS += gkgfx
endif
EXTRA_DSO_LDOPTS += \ EXTRA_DSO_LDOPTS += \
$(call EXPAND_LIBNAME_PATH,unicharutil_external_s,$(LIBXUL_DIST)/lib) \ $(LIBS_DIR) \
$(EXTRA_DSO_LIBS) \
$(MOZ_UNICHARUTIL_LIBS) \ $(MOZ_UNICHARUTIL_LIBS) \
$(LIBXUL_DIST)/../modules/libreg/src/$(LIB_PREFIX)mozreg_s.$(LIB_SUFFIX) \ $(LIBXUL_DIST)/../modules/libreg/src/$(LIB_PREFIX)mozreg_s.$(LIB_SUFFIX) \
$(MOZ_JS_LIBS) \ $(MOZ_JS_LIBS) \
$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) \
$(MOZ_COMPONENT_LIBS) \ $(MOZ_COMPONENT_LIBS) \
$(NULL) $(NULL)

View File

@ -49,7 +49,8 @@ SHORT_LIBNAME = brwsrdir
endif endif
IS_COMPONENT = 1 IS_COMPONENT = 1
MODULE_NAME = BrowserDirProvider MODULE_NAME = BrowserDirProvider
FORCE_SHARED_LIB = 1 EXPORT_LIBRARY = 1
MOZILLA_INTERNAL_API = 1
REQUIRES = \ REQUIRES = \
xpcom \ xpcom \
@ -60,9 +61,6 @@ REQUIRES = \
CPPSRCS = nsBrowserDirectoryProvider.cpp CPPSRCS = nsBrowserDirectoryProvider.cpp
EXTRA_DSO_LDOPTS = \ EXTRA_DSO_LDOPTS = $(MOZ_COMPONENT_LIBS)
$(XPCOM_GLUE_LDOPTS) \
$(NSPR_LIBS) \
$(NULL)
include $(topsrcdir)/config/rules.mk include $(topsrcdir)/config/rules.mk

View File

@ -48,12 +48,9 @@
#include "nsAppDirectoryServiceDefs.h" #include "nsAppDirectoryServiceDefs.h"
#include "nsDirectoryServiceDefs.h" #include "nsDirectoryServiceDefs.h"
#include "nsCategoryManagerUtils.h" #include "nsCategoryManagerUtils.h"
#include "nsComponentManagerUtils.h"
#include "nsCOMArray.h" #include "nsCOMArray.h"
#include "nsDirectoryServiceUtils.h"
#include "nsIGenericFactory.h" #include "nsIGenericFactory.h"
#include "nsServiceManagerUtils.h" #include "nsString.h"
#include "nsStringAPI.h"
#include "nsXULAppAPI.h" #include "nsXULAppAPI.h"
class nsBrowserDirectoryProvider : class nsBrowserDirectoryProvider :
@ -121,7 +118,7 @@ nsBrowserDirectoryProvider::GetFile(const char *aKey, PRBool *aPersist,
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID)); nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefs) { if (prefs) {
nsCString path; nsXPIDLCString path;
rv = prefs->GetCharPref("browser.bookmarks.file", getter_Copies(path)); rv = prefs->GetCharPref("browser.bookmarks.file", getter_Copies(path));
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
NS_NewNativeLocalFile(path, PR_TRUE, (nsILocalFile**)(nsIFile**) getter_AddRefs(file)); NS_NewNativeLocalFile(path, PR_TRUE, (nsILocalFile**)(nsIFile**) getter_AddRefs(file));

View File

@ -43,8 +43,6 @@ include $(DEPTH)/config/autoconf.mk
MODULE = browser_feeds MODULE = browser_feeds
LIBRARY_NAME = browser_feeds_s LIBRARY_NAME = browser_feeds_s
FORCE_STATIC_LIB = 1
FORCE_USE_PIC = 1
EXTRA_PP_COMPONENTS = \ EXTRA_PP_COMPONENTS = \
FeedConverter.js \ FeedConverter.js \
@ -58,4 +56,8 @@ CPPSRCS = nsFeedSniffer.cpp nsAboutFeeds.cpp
LOCAL_INCLUDES = -I$(srcdir)/../../build LOCAL_INCLUDES = -I$(srcdir)/../../build
FORCE_STATIC_LIB = 1
MOZILLA_INTERNAL_API = 1
include $(topsrcdir)/config/rules.mk include $(topsrcdir)/config/rules.mk

View File

@ -43,14 +43,13 @@
#include "nsNetCID.h" #include "nsNetCID.h"
#include "nsXPCOM.h" #include "nsXPCOM.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsString.h"
#include "nsStringStream.h" #include "nsStringStream.h"
#include "nsBrowserCompsCID.h" #include "nsBrowserCompsCID.h"
#include "nsICategoryManager.h" #include "nsICategoryManager.h"
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
#include "nsComponentManagerUtils.h"
#include "nsServiceManagerUtils.h"
#include "nsIStreamConverterService.h" #include "nsIStreamConverterService.h"
#include "nsIStreamConverter.h" #include "nsIStreamConverter.h"
@ -99,12 +98,9 @@ nsFeedSniffer::ConvertEncodedData(nsIRequest* request,
converter->OnStartRequest(request, nsnull); converter->OnStartRequest(request, nsnull);
nsCOMPtr<nsIStringInputStream> rawStream = nsCOMPtr<nsIInputStream> rawStream;
do_CreateInstance(NS_STRINGINPUTSTREAM_CONTRACTID); rv = NS_NewByteInputStream(getter_AddRefs(rawStream),
if (!rawStream) (const char*)data, length);
return NS_ERROR_FAILURE;
rv = rawStream->SetData((const char*)data, length);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = converter->OnDataAvailable(request, nsnull, rawStream, 0, length); rv = converter->OnDataAvailable(request, nsnull, rawStream, 0, length);
@ -116,14 +112,6 @@ nsFeedSniffer::ConvertEncodedData(nsIRequest* request,
return rv; return rv;
} }
template<int N>
static PRBool
StringBeginsWithLowercaseLiteral(nsAString& aString,
const char (&aSubstring)[N])
{
return StringHead(aString, N).LowerCaseEqualsLiteral(aSubstring);
}
// XXXsayrer put this in here to get on the branch with minimal delay. // XXXsayrer put this in here to get on the branch with minimal delay.
// Trunk really needs to factor this out. This is the third usage. // Trunk really needs to factor this out. This is the third usage.
PRBool PRBool
@ -160,13 +148,13 @@ HasAttachmentDisposition(nsIHttpChannel* httpChannel)
// Content-Disposition: ; filename="file" // Content-Disposition: ; filename="file"
// screen those out here. // screen those out here.
!dispToken.IsEmpty() && !dispToken.IsEmpty() &&
!StringBeginsWithLowercaseLiteral(dispToken, "inline") && !dispToken.LowerCaseEqualsLiteral("inline") &&
// Broken sites just send // Broken sites just send
// Content-Disposition: filename="file" // Content-Disposition: filename="file"
// without a disposition token... screen those out. // without a disposition token... screen those out.
!StringBeginsWithLowercaseLiteral(dispToken, "filename")) && !dispToken.EqualsIgnoreCase("filename", 8)) &&
// Also in use is Content-Disposition: name="file" // Also in use is Content-Disposition: name="file"
!StringBeginsWithLowercaseLiteral(dispToken, "name")) !dispToken.EqualsIgnoreCase("name", 4))
// We have a content-disposition of "attachment" or unknown // We have a content-disposition of "attachment" or unknown
return PR_TRUE; return PR_TRUE;
} }
@ -175,20 +163,6 @@ HasAttachmentDisposition(nsIHttpChannel* httpChannel)
return PR_FALSE; return PR_FALSE;
} }
/**
* @return the first occurrence of a character within a string buffer,
* or nsnull if not found
*/
static const char*
FindChar(char c, const char *begin, const char *end)
{
for (; begin < end; ++begin) {
if (*begin == c)
return begin;
}
return nsnull;
}
/** /**
* *
* Determine if a substring is the "documentElement" in the document. * Determine if a substring is the "documentElement" in the document.
@ -199,38 +173,54 @@ FindChar(char c, const char *begin, const char *end)
* another type, e.g. a HTML document, and we don't want to show the preview * another type, e.g. a HTML document, and we don't want to show the preview
* page if the document isn't actually a feed. * page if the document isn't actually a feed.
* *
* @param start * @param dataString
* The beginning of the data being sniffed * The data being sniffed
* @param end * @param substring
* The end of the data being sniffed, right before the substring that * The substring being tested for document-element-ness
* was found. * @param indicator
* @returns PR_TRUE if the found substring is the documentElement, PR_FALSE * An iterator initialized to the end of |substring|, located in
* |dataString|
* @returns PR_TRUE if the substring is the documentElement, PR_FALSE
* otherwise. * otherwise.
*/ */
static PRBool static PRBool
IsDocumentElement(const char *start, const char* end) IsDocumentElement(nsACString& dataString, const nsACString& substring,
nsACString::const_iterator& indicator)
{ {
nsACString::const_iterator start, end, endOfString;
dataString.BeginReading(start);
endOfString = end = indicator;
// For every tag in the buffer, check to see if it's a PI, Doctype or // For every tag in the buffer, check to see if it's a PI, Doctype or
// comment, our desired substring or something invalid. // comment, our desired substring or something invalid.
while ( (start = FindChar('<', start, end)) ) { while (FindCharInReadable('<', start, end)) {
++start; ++start;
if (start >= end) if (start == endOfString)
return PR_FALSE; return PR_FALSE;
// Check to see if the character following the '<' is either '?' or '!' // Check to see if the character following the '<' is either '?' or '!'
// (processing instruction or doctype or comment)... these are valid nodes // (processing instruction or doctype or comment)... these are valid nodes
// to have in the prologue. // to have in the prologue.
if (*start != '?' && *start != '!') if (*start != '?' && *start != '!') {
return PR_FALSE; // Check to see if the string following the '<' is our indicator substring.
// If it's not, it's an indication that the indicator substring was
// embedded in some other kind of document, e.g. HTML.
return substring.Equals(Substring(--start, indicator));
}
// Reset end so we can re-scan the entire remaining section of the
// string, and advance start so we don't loop infinitely.
dataString.EndReading(end);
// Now advance the iterator until the '>' (We do this because we don't want // Now advance the iterator until the '>' (We do this because we don't want
// to sniff indicator substrings that are embedded within other nodes, e.g. // to sniff indicator substrings that are embedded within other nodes, e.g.
// comments: <!-- <rdf:RDF .. > --> // comments: <!-- <rdf:RDF .. > -->
start = FindChar('>', start, end); if (!FindCharInReadable('>', start, end))
if (!start)
return PR_FALSE; return PR_FALSE;
++start; // Reset end again
dataString.EndReading(end);
} }
return PR_TRUE; return PR_TRUE;
} }
@ -246,16 +236,17 @@ IsDocumentElement(const char *start, const char* end)
* otherwise. * otherwise.
*/ */
static PRBool static PRBool
ContainsTopLevelSubstring(nsACString& dataString, const char *substring) ContainsTopLevelSubstring(nsACString& dataString, const nsACString& substring)
{ {
PRInt32 offset = dataString.Find(substring); nsACString::const_iterator start, end;
if (offset == -1)
return PR_FALSE;
const char *begin = dataString.BeginReading(); dataString.BeginReading(start);
dataString.EndReading(end);
// Only do the validation when we find the substring. PRBool isFeed = FindInReadable(substring, start, end);
return IsDocumentElement(begin, begin + offset);
// Only do the validation when we find the substring.
return isFeed ? IsDocumentElement(dataString, substring, end) : isFeed;
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -332,22 +323,32 @@ nsFeedSniffer::GetMIMETypeFromContent(nsIRequest* request,
length = MAX_BYTES; length = MAX_BYTES;
// Thus begins the actual sniffing. // Thus begins the actual sniffing.
nsDependentCSubstring dataString((const char*)testData, length); nsDependentCSubstring dataString((const char*)testData,
(const char*)testData + length);
nsACString::const_iterator start_iter, end_iter;
PRBool isFeed = PR_FALSE; PRBool isFeed = PR_FALSE;
// RSS 0.91/0.92/2.0 // RSS 0.91/0.92/2.0
isFeed = ContainsTopLevelSubstring(dataString, "<rss"); isFeed = ContainsTopLevelSubstring(dataString, NS_LITERAL_CSTRING("<rss"));
// Atom 1.0 // Atom 1.0
if (!isFeed) if (!isFeed)
isFeed = ContainsTopLevelSubstring(dataString, "<feed"); isFeed = ContainsTopLevelSubstring(dataString, NS_LITERAL_CSTRING("<feed"));
// RSS 1.0 // RSS 1.0
if (!isFeed) { if (!isFeed) {
isFeed = ContainsTopLevelSubstring(dataString, "<rdf:RDF") && isFeed = ContainsTopLevelSubstring(dataString, NS_LITERAL_CSTRING("<rdf:RDF"));
dataString.Find(NS_RDF) && if (isFeed) {
dataString.Find(NS_RSS); dataString.BeginReading(start_iter);
dataString.EndReading(end_iter);
isFeed = FindInReadable(NS_LITERAL_CSTRING(NS_RDF), start_iter, end_iter);
if (isFeed) {
dataString.BeginReading(start_iter);
dataString.EndReading(end_iter);
isFeed = FindInReadable(NS_LITERAL_CSTRING(NS_RSS), start_iter, end_iter);
}
}
} }
// If we sniffed a feed, coerce our internal type // If we sniffed a feed, coerce our internal type

View File

@ -39,7 +39,7 @@
#include "nsIGenericFactory.h" #include "nsIGenericFactory.h"
#include "nsIContentSniffer.h" #include "nsIContentSniffer.h"
#include "nsIStreamListener.h" #include "nsIStreamListener.h"
#include "nsStringAPI.h" #include "nsString.h"
class nsFeedSniffer : public nsIContentSniffer, nsIStreamListener class nsFeedSniffer : public nsIContentSniffer, nsIStreamListener
{ {

View File

@ -43,8 +43,7 @@ include $(DEPTH)/config/autoconf.mk
MODULE = migration MODULE = migration
LIBRARY_NAME = migration_s LIBRARY_NAME = migration_s
FORCE_STATIC_LIB = 1 MOZILLA_INTERNAL_API = 1
FORCE_USE_PIC = 1
REQUIRES = \ REQUIRES = \
xpcom \ xpcom \
@ -64,7 +63,7 @@ REQUIRES = \
docshell \ docshell \
xulapp \ xulapp \
$(NULL) $(NULL)
ifdef MOZ_PLACES ifdef MOZ_PLACES
REQUIRES += places REQUIRES += places
endif endif
@ -103,5 +102,9 @@ CPPSRCS += nsSafariProfileMigrator.cpp \
$(NULL) $(NULL)
endif endif
# we don't want the shared lib, but we want to force the creation of a
# static lib.
FORCE_STATIC_LIB = 1
include $(topsrcdir)/config/rules.mk include $(topsrcdir)/config/rules.mk

View File

@ -95,10 +95,9 @@ void SetProxyPref(const nsAString& aHostPort, const char* aPref,
if (portDelimOffset > 0) { if (portDelimOffset > 0) {
SetUnicharPref(aPref, Substring(hostPort, 0, portDelimOffset), aPrefs); SetUnicharPref(aPref, Substring(hostPort, 0, portDelimOffset), aPrefs);
nsAutoString port(Substring(hostPort, portDelimOffset + 1)); nsAutoString port(Substring(hostPort, portDelimOffset + 1));
nsresult stringErr; PRInt32 stringErr;
portValue = port.ToInteger(&stringErr); portValue = port.ToInteger(&stringErr);
if (NS_SUCCEEDED(stringErr)) aPrefs->SetIntPref(aPortPref, portValue);
aPrefs->SetIntPref(aPortPref, portValue);
} }
else else
SetUnicharPref(aPref, hostPort, aPrefs); SetUnicharPref(aPref, hostPort, aPrefs);
@ -268,11 +267,11 @@ ImportBookmarksHTML(nsIFile* aBookmarksFile,
rv = bundleService->CreateBundle(MIGRATION_BUNDLE, getter_AddRefs(bundle)); rv = bundleService->CreateBundle(MIGRATION_BUNDLE, getter_AddRefs(bundle));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
nsString sourceName; nsXPIDLString sourceName;
bundle->GetStringFromName(aImportSourceNameKey, getter_Copies(sourceName)); bundle->GetStringFromName(aImportSourceNameKey, getter_Copies(sourceName));
const PRUnichar* sourceNameStrings[] = { sourceName.get() }; const PRUnichar* sourceNameStrings[] = { sourceName.get() };
nsString importedBookmarksTitle; nsXPIDLString importedBookmarksTitle;
bundle->FormatStringFromName(NS_LITERAL_STRING("importedBookmarksFolder").get(), bundle->FormatStringFromName(NS_LITERAL_STRING("importedBookmarksFolder").get(),
sourceNameStrings, 1, sourceNameStrings, 1,
getter_Copies(importedBookmarksTitle)); getter_Copies(importedBookmarksTitle));

View File

@ -60,9 +60,7 @@
#include "nsIPrefBranch.h" #include "nsIPrefBranch.h"
#include "nsIFile.h" #include "nsIFile.h"
#include "nsStringAPI.h" #include "nsString.h"
#include "nsCOMPtr.h"
class nsIProfileStartup; class nsIProfileStartup;

View File

@ -42,7 +42,6 @@
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
#include "nsISupportsArray.h" #include "nsISupportsArray.h"
#include "nsISupportsPrimitives.h" #include "nsISupportsPrimitives.h"
#include "nsServiceManagerUtils.h"
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// nsCaminoProfileMigrator // nsCaminoProfileMigrator

View File

@ -41,7 +41,7 @@
#include "nsIBrowserProfileMigrator.h" #include "nsIBrowserProfileMigrator.h"
#include "nsIObserverService.h" #include "nsIObserverService.h"
#include "nsISupportsArray.h" #include "nsISupportsArray.h"
#include "nsStringAPI.h" #include "nsString.h"
class nsCaminoProfileMigrator : public nsIBrowserProfileMigrator class nsCaminoProfileMigrator : public nsIBrowserProfileMigrator
{ {
@ -58,4 +58,4 @@ private:
nsCOMPtr<nsIObserverService> mObserverService; nsCOMPtr<nsIObserverService> mObserverService;
}; };
#endif #endif

View File

@ -37,6 +37,7 @@
#include "nsAppDirectoryServiceDefs.h" #include "nsAppDirectoryServiceDefs.h"
#include "nsBrowserProfileMigratorUtils.h" #include "nsBrowserProfileMigratorUtils.h"
#include "nsCRT.h"
#include "nsDogbertProfileMigrator.h" #include "nsDogbertProfileMigrator.h"
#include "nsICookieManager2.h" #include "nsICookieManager2.h"
#include "nsIFile.h" #include "nsIFile.h"
@ -52,12 +53,12 @@
#include "nsISupportsPrimitives.h" #include "nsISupportsPrimitives.h"
#include "nsNetCID.h" #include "nsNetCID.h"
#include "nsNetUtil.h" #include "nsNetUtil.h"
#include "nsReadableUtils.h"
#include "prprf.h" #include "prprf.h"
#include "prenv.h" #include "prenv.h"
#include "nsEscape.h"
#include "NSReg.h" #include "NSReg.h"
#include "nsDirectoryServiceDefs.h" #include "nsDirectoryServiceDefs.h"
#include "nsDirectoryServiceUtils.h"
#include <stdlib.h>
#ifndef MAXPATHLEN #ifndef MAXPATHLEN
#ifdef _MAX_PATH #ifdef _MAX_PATH
@ -288,7 +289,7 @@ nsDogbertProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
if (!mProfiles) { if (!mProfiles) {
nsresult rv; nsresult rv;
mProfiles = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, &rv); rv = NS_NewISupportsArray(getter_AddRefs(mProfiles));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIFile> regFile; nsCOMPtr<nsIFile> regFile;
@ -360,7 +361,7 @@ nsDogbertProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
mSourceProfile = profileFile; mSourceProfile = profileFile;
mProfiles = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, &rv); rv = NS_NewISupportsArray(getter_AddRefs(mProfiles));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsISupportsString> nameString nsCOMPtr<nsISupportsString> nameString
@ -565,7 +566,7 @@ nsDogbertProfileMigrator::FixDogbertCookies()
// skip line if it is a comment or null line // skip line if it is a comment or null line
if (buffer.IsEmpty() || buffer.CharAt(0) == '#' || if (buffer.IsEmpty() || buffer.CharAt(0) == '#' ||
buffer.CharAt(0) == '\r' || buffer.CharAt(0) == '\n') { buffer.CharAt(0) == nsCRT::CR || buffer.CharAt(0) == nsCRT::LF) {
fileOutputStream->Write(buffer.get(), buffer.Length(), &written); fileOutputStream->Write(buffer.get(), buffer.Length(), &written);
continue; continue;
} }
@ -582,12 +583,10 @@ nsDogbertProfileMigrator::FixDogbertCookies()
continue; continue;
// separate the expires field from the rest of the cookie line // separate the expires field from the rest of the cookie line
const nsDependentCSubstring prefix = nsCAutoString prefix, expiresString, suffix;
Substring(buffer, hostIndex, expiresIndex-hostIndex-1); buffer.Mid(prefix, hostIndex, expiresIndex-hostIndex-1);
const nsDependentCSubstring expiresString = buffer.Mid(expiresString, expiresIndex, nameIndex-expiresIndex-1);
Substring(buffer, expiresIndex, nameIndex-expiresIndex-1); buffer.Mid(suffix, nameIndex, buffer.Length()-nameIndex);
const nsDependentCSubstring suffix =
Substring(buffer, nameIndex, buffer.Length()-nameIndex);
// correct the expires field // correct the expires field
char* expiresCString = ToNewCString(expiresString); char* expiresCString = ToNewCString(expiresString);
@ -644,7 +643,7 @@ nsDogbertProfileMigrator::MigrateDogbertBookmarks()
dogbertPrefsFile->Append(PREF_FILE_NAME_IN_4x); dogbertPrefsFile->Append(PREF_FILE_NAME_IN_4x);
psvc->ReadUserPrefs(dogbertPrefsFile); psvc->ReadUserPrefs(dogbertPrefsFile);
nsCString toolbarName; nsXPIDLCString toolbarName;
nsCOMPtr<nsIPrefBranch> branch(do_QueryInterface(psvc)); nsCOMPtr<nsIPrefBranch> branch(do_QueryInterface(psvc));
rv = branch->GetCharPref("custtoolbar.personal_toolbar_folder", getter_Copies(toolbarName)); rv = branch->GetCharPref("custtoolbar.personal_toolbar_folder", getter_Copies(toolbarName));
// If the pref wasn't set in the user's 4.x preferences, there's no way we can "Fix" the // If the pref wasn't set in the user's 4.x preferences, there's no way we can "Fix" the
@ -664,5 +663,5 @@ nsDogbertProfileMigrator::MigrateDogbertBookmarks()
targetBookmarksFile->Append(BOOKMARKS_FILE_NAME_IN_5x); targetBookmarksFile->Append(BOOKMARKS_FILE_NAME_IN_5x);
return AnnotatePersonalToolbarFolder(sourceBookmarksFile, return AnnotatePersonalToolbarFolder(sourceBookmarksFile,
targetBookmarksFile, toolbarName.get()); targetBookmarksFile, toolbarName);
} }

View File

@ -43,7 +43,7 @@
#include "nsIObserverService.h" #include "nsIObserverService.h"
#include "nsISupportsArray.h" #include "nsISupportsArray.h"
#include "nsNetscapeProfileMigratorBase.h" #include "nsNetscapeProfileMigratorBase.h"
#include "nsStringAPI.h" #include "nsString.h"
#ifdef XP_MACOSX #ifdef XP_MACOSX
#define NEED_TO_FIX_4X_COOKIES 1 #define NEED_TO_FIX_4X_COOKIES 1

View File

@ -42,7 +42,6 @@
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
#include "nsISupportsArray.h" #include "nsISupportsArray.h"
#include "nsISupportsPrimitives.h" #include "nsISupportsPrimitives.h"
#include "nsServiceManagerUtils.h"
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// nsICabProfileMigrator // nsICabProfileMigrator

View File

@ -41,7 +41,7 @@
#include "nsIBrowserProfileMigrator.h" #include "nsIBrowserProfileMigrator.h"
#include "nsIObserverService.h" #include "nsIObserverService.h"
#include "nsISupportsArray.h" #include "nsISupportsArray.h"
#include "nsStringAPI.h" #include "nsString.h"
class nsICabProfileMigrator : public nsIBrowserProfileMigrator class nsICabProfileMigrator : public nsIBrowserProfileMigrator
{ {
@ -58,4 +58,4 @@ private:
nsCOMPtr<nsIObserverService> mObserverService; nsCOMPtr<nsIObserverService> mObserverService;
}; };
#endif #endif

View File

@ -45,13 +45,12 @@
#include "nsAppDirectoryServiceDefs.h" #include "nsAppDirectoryServiceDefs.h"
#include "nsBrowserProfileMigratorUtils.h" #include "nsBrowserProfileMigratorUtils.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsCRTGlue.h"
#include "nsNetCID.h" #include "nsNetCID.h"
#include "nsDocShellCID.h" #include "nsDocShellCID.h"
#include "nsDebug.h" #include "nsDebug.h"
#include "nsDependentString.h"
#include "nsDirectoryServiceDefs.h" #include "nsDirectoryServiceDefs.h"
#include "nsDirectoryServiceUtils.h" #include "nsString.h"
#include "nsStringAPI.h"
#include "plstr.h" #include "plstr.h"
#include "prio.h" #include "prio.h"
#include "prmem.h" #include "prmem.h"
@ -92,6 +91,7 @@
#include "nsIBookmarksService.h" #include "nsIBookmarksService.h"
#endif #endif
#include "nsIStringBundle.h" #include "nsIStringBundle.h"
#include "nsCRT.h"
#include "nsNetUtil.h" #include "nsNetUtil.h"
#include "nsToolkitCompsCID.h" #include "nsToolkitCompsCID.h"
#include "nsUnicharUtils.h" #include "nsUnicharUtils.h"
@ -873,7 +873,7 @@ nsIEProfileMigrator::MigrateSiteAuthSignons(IPStore* aPStore)
} }
nsAutoString tmp(itemName); nsAutoString tmp(itemName);
tmp.SetLength(6); tmp.Truncate(6);
if (tmp.Equals(NS_LITERAL_STRING("DPAPI:"))) // often FTP logins if (tmp.Equals(NS_LITERAL_STRING("DPAPI:"))) // often FTP logins
password = NULL; // We can't handle these yet password = NULL; // We can't handle these yet
@ -916,8 +916,9 @@ nsIEProfileMigrator::GetSignonsListFromPStore(IPStore* aPStore, nsVoidArray* aSi
hr = aPStore->ReadItem(0, &IEPStoreAutocompGUID, &IEPStoreAutocompGUID, itemName, &count, &data, NULL, 0); hr = aPStore->ReadItem(0, &IEPStoreAutocompGUID, &IEPStoreAutocompGUID, itemName, &count, &data, NULL, 0);
if (SUCCEEDED(hr) && data) { if (SUCCEEDED(hr) && data) {
nsAutoString itemNameString(itemName); nsAutoString itemNameString(itemName);
if (StringTail(itemNameString, 11). nsAutoString suffix;
LowerCaseEqualsLiteral(":stringdata")) { itemNameString.Right(suffix, 11);
if (suffix.EqualsIgnoreCase(":StringData")) {
// :StringData contains the saved data // :StringData contains the saved data
const nsAString& key = Substring(itemNameString, 0, itemNameString.Length() - 11); const nsAString& key = Substring(itemNameString, 0, itemNameString.Length() - 11);
char* realm = nsnull; char* realm = nsnull;
@ -972,7 +973,7 @@ nsIEProfileMigrator::KeyIsURI(const nsAString& aKey, char** aRealm)
uri->GetHost(host); uri->GetHost(host);
realm.Append(host); realm.Append(host);
*aRealm = ToNewCString(realm); *aRealm = nsCRT::strdup(realm.get());
return validScheme; return validScheme;
} }
} }
@ -995,14 +996,15 @@ nsIEProfileMigrator::ResolveAndMigrateSignons(IPStore* aPStore, nsVoidArray* aSi
hr = aPStore->ReadItem(0, &IEPStoreAutocompGUID, &IEPStoreAutocompGUID, itemName, &count, &data, NULL, 0); hr = aPStore->ReadItem(0, &IEPStoreAutocompGUID, &IEPStoreAutocompGUID, itemName, &count, &data, NULL, 0);
if (SUCCEEDED(hr) && data) { if (SUCCEEDED(hr) && data) {
nsAutoString itemNameString(itemName); nsAutoString itemNameString(itemName);
if (StringTail(itemNameString, 11). nsAutoString suffix;
LowerCaseEqualsLiteral(":stringdata")) { itemNameString.Right(suffix, 11);
if (suffix.EqualsIgnoreCase(":StringData")) {
// :StringData contains the saved data // :StringData contains the saved data
const nsAString& key = Substring(itemNameString, 0, itemNameString.Length() - 11); const nsAString& key = Substring(itemNameString, 0, itemNameString.Length() - 11);
// Assume all keys that are valid URIs are signons, not saved form data, and that // Assume all keys that are valid URIs are signons, not saved form data, and that
// all keys that aren't valid URIs are form field names (containing form data). // all keys that aren't valid URIs are form field names (containing form data).
nsCString realm; nsXPIDLCString realm;
if (!KeyIsURI(key, getter_Copies(realm))) { if (!KeyIsURI(key, getter_Copies(realm))) {
// Search the data for a username that matches one of the found signons. // Search the data for a username that matches one of the found signons.
EnumerateUsernames(key, (PRUnichar*)data, (count/sizeof(PRUnichar)), aSignonsFound); EnumerateUsernames(key, (PRUnichar*)data, (count/sizeof(PRUnichar)), aSignonsFound);
@ -1019,7 +1021,7 @@ nsIEProfileMigrator::ResolveAndMigrateSignons(IPStore* aPStore, nsVoidArray* aSi
for (PRInt32 i = 0; i < signonCount; ++i) { for (PRInt32 i = 0; i < signonCount; ++i) {
SignonData* sd = (SignonData*)aSignonsFound->ElementAt(i); SignonData* sd = (SignonData*)aSignonsFound->ElementAt(i);
::CoTaskMemFree(sd->user); // |sd->user| is a pointer to the start of a buffer that also contains sd->pass ::CoTaskMemFree(sd->user); // |sd->user| is a pointer to the start of a buffer that also contains sd->pass
NS_Free(sd->realm); nsCRT::free(sd->realm);
delete sd; delete sd;
} }
} }
@ -1122,11 +1124,12 @@ nsIEProfileMigrator::CopyFormData(PRBool aReplace)
hr = PStore->ReadItem(0, &IEPStoreAutocompGUID, &IEPStoreAutocompGUID, itemName, &count, &data, NULL, 0); hr = PStore->ReadItem(0, &IEPStoreAutocompGUID, &IEPStoreAutocompGUID, itemName, &count, &data, NULL, 0);
if (SUCCEEDED(hr) && data) { if (SUCCEEDED(hr) && data) {
nsAutoString itemNameString(itemName); nsAutoString itemNameString(itemName);
if (StringTail(itemNameString, 11). nsAutoString suffix;
LowerCaseEqualsLiteral(":stringdata")) { itemNameString.Right(suffix, 11);
if (suffix.EqualsIgnoreCase(":StringData")) {
// :StringData contains the saved data // :StringData contains the saved data
const nsAString& key = Substring(itemNameString, 0, itemNameString.Length() - 11); const nsAString& key = Substring(itemNameString, 0, itemNameString.Length() - 11);
nsCString realm; nsXPIDLCString realm;
if (!KeyIsURI(key, getter_Copies(realm))) { if (!KeyIsURI(key, getter_Copies(realm))) {
nsresult rv = AddDataToFormHistory(key, (PRUnichar*)data, (count/sizeof(PRUnichar))); nsresult rv = AddDataToFormHistory(key, (PRUnichar*)data, (count/sizeof(PRUnichar)));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
@ -1205,12 +1208,12 @@ nsIEProfileMigrator::CopyFavorites(PRBool aReplace) {
nsCOMPtr<nsIStringBundle> bundle; nsCOMPtr<nsIStringBundle> bundle;
bundleService->CreateBundle(TRIDENTPROFILE_BUNDLE, getter_AddRefs(bundle)); bundleService->CreateBundle(TRIDENTPROFILE_BUNDLE, getter_AddRefs(bundle));
nsString sourceNameIE; nsXPIDLString sourceNameIE;
bundle->GetStringFromName(NS_LITERAL_STRING("sourceNameIE").get(), bundle->GetStringFromName(NS_LITERAL_STRING("sourceNameIE").get(),
getter_Copies(sourceNameIE)); getter_Copies(sourceNameIE));
const PRUnichar* sourceNameStrings[] = { sourceNameIE.get() }; const PRUnichar* sourceNameStrings[] = { sourceNameIE.get() };
nsString importedIEFavsTitle; nsXPIDLString importedIEFavsTitle;
bundle->FormatStringFromName(NS_LITERAL_STRING("importedBookmarksFolder").get(), bundle->FormatStringFromName(NS_LITERAL_STRING("importedBookmarksFolder").get(),
sourceNameStrings, 1, getter_Copies(importedIEFavsTitle)); sourceNameStrings, 1, getter_Copies(importedIEFavsTitle));
@ -1277,7 +1280,7 @@ nsIEProfileMigrator::CopySmartKeywords(nsIRDFResource* aParentFolder)
nsresult rv; nsresult rv;
nsCOMPtr<nsINavBookmarksService> bms(do_GetService(NS_NAVBOOKMARKSSERVICE_CONTRACTID, &rv)); nsCOMPtr<nsINavBookmarksService> bms(do_GetService(NS_NAVBOOKMARKSSERVICE_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
PRInt64 keywordsFolder = 0; PRInt64 keywordsFolder;
#else #else
nsCOMPtr<nsIBookmarksService> bms(do_GetService("@mozilla.org/browser/bookmarks-service;1")); nsCOMPtr<nsIBookmarksService> bms(do_GetService("@mozilla.org/browser/bookmarks-service;1"));
nsCOMPtr<nsIRDFResource> keywordsFolder, bookmark; nsCOMPtr<nsIRDFResource> keywordsFolder, bookmark;
@ -1296,12 +1299,12 @@ nsIEProfileMigrator::CopySmartKeywords(nsIRDFResource* aParentFolder)
break; break;
if (!keywordsFolder) { if (!keywordsFolder) {
nsString sourceNameIE; nsXPIDLString sourceNameIE;
bundle->GetStringFromName(NS_LITERAL_STRING("sourceNameIE").get(), bundle->GetStringFromName(NS_LITERAL_STRING("sourceNameIE").get(),
getter_Copies(sourceNameIE)); getter_Copies(sourceNameIE));
const PRUnichar* sourceNameStrings[] = { sourceNameIE.get() }; const PRUnichar* sourceNameStrings[] = { sourceNameIE.get() };
nsString importedIESearchUrlsTitle; nsXPIDLString importedIESearchUrlsTitle;
bundle->FormatStringFromName(NS_LITERAL_STRING("importedSearchURLsFolder").get(), bundle->FormatStringFromName(NS_LITERAL_STRING("importedSearchURLsFolder").get(),
sourceNameStrings, 1, getter_Copies(importedIESearchUrlsTitle)); sourceNameStrings, 1, getter_Copies(importedIESearchUrlsTitle));
#ifdef MOZ_PLACES_BOOKMARKS #ifdef MOZ_PLACES_BOOKMARKS
@ -1334,13 +1337,13 @@ nsIEProfileMigrator::CopySmartKeywords(nsIRDFResource* aParentFolder)
NS_ConvertUTF8toUTF16 host(hostCStr); NS_ConvertUTF8toUTF16 host(hostCStr);
const PRUnichar* nameStrings[] = { host.get() }; const PRUnichar* nameStrings[] = { host.get() };
nsString keywordName; nsXPIDLString keywordName;
nsresult rv = bundle->FormatStringFromName( nsresult rv = bundle->FormatStringFromName(
NS_LITERAL_STRING("importedSearchURLsTitle").get(), NS_LITERAL_STRING("importedSearchURLsTitle").get(),
nameStrings, 1, getter_Copies(keywordName)); nameStrings, 1, getter_Copies(keywordName));
const PRUnichar* descStrings[] = { keyName.get(), host.get() }; const PRUnichar* descStrings[] = { keyName.get(), host.get() };
nsString keywordDesc; nsXPIDLString keywordDesc;
rv = bundle->FormatStringFromName( rv = bundle->FormatStringFromName(
NS_LITERAL_STRING("importedSearchUrlDesc").get(), NS_LITERAL_STRING("importedSearchUrlDesc").get(),
descStrings, 2, getter_Copies(keywordDesc)); descStrings, 2, getter_Copies(keywordDesc));
@ -1366,7 +1369,7 @@ nsIEProfileMigrator::CopySmartKeywords(nsIRDFResource* aParentFolder)
} }
void void
nsIEProfileMigrator::ResolveShortcut(const nsString &aFileName, char** aOutURL) nsIEProfileMigrator::ResolveShortcut(const nsAFlatString &aFileName, char** aOutURL)
{ {
HRESULT result; HRESULT result;
@ -1460,8 +1463,8 @@ nsIEProfileMigrator::ParseFavoritesFolder(nsIFile* aDirectory,
NS_NAMED_LITERAL_STRING(lnkExt, ".lnk"); NS_NAMED_LITERAL_STRING(lnkExt, ".lnk");
PRInt32 lnkExtStart = bookmarkName.Length() - lnkExt.Length(); PRInt32 lnkExtStart = bookmarkName.Length() - lnkExt.Length();
if (StringEndsWith(bookmarkName, lnkExt, if (StringEndsWith(bookmarkName, lnkExt,
CaseInsensitiveCompare)) nsCaseInsensitiveStringComparator()))
bookmarkName.SetLength(lnkExtStart); bookmarkName.Truncate(lnkExtStart);
#ifdef MOZ_PLACES_BOOKMARKS #ifdef MOZ_PLACES_BOOKMARKS
nsCOMPtr<nsIURI> bookmarkURI; nsCOMPtr<nsIURI> bookmarkURI;
@ -1554,7 +1557,8 @@ nsIEProfileMigrator::ParseFavoritesFolder(nsIFile* aDirectory,
nsCAutoString extension; nsCAutoString extension;
url->GetFileExtension(extension); url->GetFileExtension(extension);
if (!extension.Equals("url", CaseInsensitiveCompare)) if (!extension.Equals(NS_LITERAL_CSTRING("url"),
nsCaseInsensitiveCStringComparator()))
continue; continue;
nsAutoString name(Substring(bookmarkName, 0, nsAutoString name(Substring(bookmarkName, 0,
@ -1563,7 +1567,7 @@ nsIEProfileMigrator::ParseFavoritesFolder(nsIFile* aDirectory,
nsAutoString path; nsAutoString path;
currFile->GetPath(path); currFile->GetPath(path);
nsCString resolvedURL; nsXPIDLCString resolvedURL;
ResolveShortcut(path, getter_Copies(resolvedURL)); ResolveShortcut(path, getter_Copies(resolvedURL));
#ifdef MOZ_PLACES_BOOKMARKS #ifdef MOZ_PLACES_BOOKMARKS
@ -1711,7 +1715,7 @@ nsIEProfileMigrator::CopyCookies(PRBool aReplace)
nsCAutoString fileName; nsCAutoString fileName;
cookieFile->GetNativeLeafName(fileName); cookieFile->GetNativeLeafName(fileName);
const nsACString &fileOwner = Substring(fileName, 0, usernameLength); const nsACString &fileOwner = Substring(fileName, 0, usernameLength);
if (!fileOwner.Equals(username, CaseInsensitiveCompare)) if (!fileOwner.Equals(username, nsCaseInsensitiveCStringComparator()))
continue; continue;
// ensure the contents buffer is large enough to hold the entire file // ensure the contents buffer is large enough to hold the entire file

View File

@ -89,7 +89,7 @@ protected:
nsresult AddDataToFormHistory(const nsAString& aKey, PRUnichar* data, unsigned long len); nsresult AddDataToFormHistory(const nsAString& aKey, PRUnichar* data, unsigned long len);
nsresult CopyFavorites(PRBool aReplace); nsresult CopyFavorites(PRBool aReplace);
void ResolveShortcut(const nsString &aFileName, char** aOutURL); void ResolveShortcut(const nsAFlatString &aFileName, char** aOutURL);
#ifdef MOZ_PLACES_BOOKMARKS #ifdef MOZ_PLACES_BOOKMARKS
nsresult ParseFavoritesFolder(nsIFile* aDirectory, nsresult ParseFavoritesFolder(nsIFile* aDirectory,
PRInt64 aParentFolder, PRInt64 aParentFolder,

View File

@ -20,7 +20,6 @@
* *
* Contributor(s): * Contributor(s):
* Ben Goodger <ben@bengoodger.com> * Ben Goodger <ben@bengoodger.com>
* Benjamin Smedberg <benjamin@smedbergs.us>
* *
* Alternatively, the contents of this file may be used under the terms of * Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or * either the GNU General Public License Version 2 or later (the "GPL"), or
@ -46,8 +45,6 @@
#include "nsIStringBundle.h" #include "nsIStringBundle.h"
#include "nsISupportsArray.h" #include "nsISupportsArray.h"
#include "nsISupportsPrimitives.h" #include "nsISupportsPrimitives.h"
#include "nsServiceManagerUtils.h"
#include "nsIProperties.h"
#define MACIE_BOOKMARKS_FILE_NAME NS_LITERAL_STRING("Favorites.html") #define MACIE_BOOKMARKS_FILE_NAME NS_LITERAL_STRING("Favorites.html")
#define MACIE_PREFERENCES_FOLDER_NAME NS_LITERAL_STRING("Explorer") #define MACIE_PREFERENCES_FOLDER_NAME NS_LITERAL_STRING("Explorer")
@ -199,7 +196,7 @@ nsMacIEProfileMigrator::CopyBookmarks(PRBool aReplace)
rv = bundleService->CreateBundle(MIGRATION_BUNDLE, getter_AddRefs(bundle)); rv = bundleService->CreateBundle(MIGRATION_BUNDLE, getter_AddRefs(bundle));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
nsString toolbarFolderNameMacIE; nsXPIDLString toolbarFolderNameMacIE;
bundle->GetStringFromName(NS_LITERAL_STRING("toolbarFolderNameMacIE").get(), bundle->GetStringFromName(NS_LITERAL_STRING("toolbarFolderNameMacIE").get(),
getter_Copies(toolbarFolderNameMacIE)); getter_Copies(toolbarFolderNameMacIE));
nsCAutoString ctoolbarFolderNameMacIE; nsCAutoString ctoolbarFolderNameMacIE;

View File

@ -41,7 +41,7 @@
#include "nsIBrowserProfileMigrator.h" #include "nsIBrowserProfileMigrator.h"
#include "nsIObserverService.h" #include "nsIObserverService.h"
#include "nsISupportsArray.h" #include "nsISupportsArray.h"
#include "nsStringAPI.h" #include "nsString.h"
class nsMacIEProfileMigrator : public nsIBrowserProfileMigrator class nsMacIEProfileMigrator : public nsIBrowserProfileMigrator
{ {

View File

@ -37,6 +37,7 @@
#include "nsAppDirectoryServiceDefs.h" #include "nsAppDirectoryServiceDefs.h"
#include "nsBrowserProfileMigratorUtils.h" #include "nsBrowserProfileMigratorUtils.h"
#include "nsCRT.h"
#include "nsICookieManager2.h" #include "nsICookieManager2.h"
#include "nsIFile.h" #include "nsIFile.h"
#include "nsILineInputStream.h" #include "nsILineInputStream.h"
@ -51,6 +52,8 @@
#include "nsIURL.h" #include "nsIURL.h"
#include "nsNetscapeProfileMigratorBase.h" #include "nsNetscapeProfileMigratorBase.h"
#include "nsNetUtil.h" #include "nsNetUtil.h"
#include "nsReadableUtils.h"
#include "nsXPIDLString.h"
#include "prtime.h" #include "prtime.h"
#include "prprf.h" #include "prprf.h"
@ -172,8 +175,8 @@ nsNetscapeProfileMigratorBase::GetProfileDataFromRegistry(nsILocalFile* aRegistr
aProfileLocations->AppendElement(dir); aProfileLocations->AppendElement(dir);
// Get the profile name and add it to the names array // Get the profile name and add it to the names array
nsString profileName; nsXPIDLString profileName;
CopyUTF8toUTF16(nsDependentCString(profileStr), profileName); CopyUTF8toUTF16(profileStr, profileName);
nsCOMPtr<nsISupportsString> profileNameString( nsCOMPtr<nsISupportsString> profileNameString(
do_CreateInstance("@mozilla.org/supports-string;1")); do_CreateInstance("@mozilla.org/supports-string;1"));
@ -224,7 +227,7 @@ nsNetscapeProfileMigratorBase::GetWString(void* aTransform, nsIPrefBranch* aBran
getter_AddRefs(prefValue)); getter_AddRefs(prefValue));
if (NS_SUCCEEDED(rv) && prefValue) { if (NS_SUCCEEDED(rv) && prefValue) {
nsString data; nsXPIDLString data;
prefValue->ToString(getter_Copies(data)); prefValue->ToString(getter_Copies(data));
xform->stringValue = ToNewCString(NS_ConvertUTF16toUTF8(data)); xform->stringValue = ToNewCString(NS_ConvertUTF16toUTF8(data));
@ -239,7 +242,7 @@ nsNetscapeProfileMigratorBase::SetWStringFromASCII(void* aTransform, nsIPrefBran
PrefTransform* xform = (PrefTransform*)aTransform; PrefTransform* xform = (PrefTransform*)aTransform;
if (xform->prefHasValue) { if (xform->prefHasValue) {
nsCOMPtr<nsIPrefLocalizedString> pls(do_CreateInstance("@mozilla.org/pref-localizedstring;1")); nsCOMPtr<nsIPrefLocalizedString> pls(do_CreateInstance("@mozilla.org/pref-localizedstring;1"));
NS_ConvertUTF8toUTF16 data(xform->stringValue); nsAutoString data; data.AssignWithConversion(xform->stringValue);
pls->SetData(data.get()); pls->SetData(data.get());
return aBranch->SetComplexValue(xform->targetPrefName ? xform->targetPrefName : xform->sourcePrefName, NS_GET_IID(nsIPrefLocalizedString), pls); return aBranch->SetComplexValue(xform->targetPrefName ? xform->targetPrefName : xform->sourcePrefName, NS_GET_IID(nsIPrefLocalizedString), pls);
} }
@ -338,6 +341,7 @@ nsNetscapeProfileMigratorBase::ImportNetscapeCookies(nsIFile* aCookiesFile)
nsCAutoString buffer; nsCAutoString buffer;
PRBool isMore = PR_TRUE; PRBool isMore = PR_TRUE;
PRInt32 hostIndex = 0, isDomainIndex, pathIndex, secureIndex, expiresIndex, nameIndex, cookieIndex; PRInt32 hostIndex = 0, isDomainIndex, pathIndex, secureIndex, expiresIndex, nameIndex, cookieIndex;
nsASingleFragmentCString::char_iterator iter;
PRInt32 numInts; PRInt32 numInts;
PRInt64 expires; PRInt64 expires;
PRBool isDomain; PRBool isDomain;
@ -377,19 +381,18 @@ nsNetscapeProfileMigratorBase::ImportNetscapeCookies(nsIFile* aCookiesFile)
// check the expirytime first - if it's expired, ignore // check the expirytime first - if it's expired, ignore
// nullstomp the trailing tab, to avoid copying the string // nullstomp the trailing tab, to avoid copying the string
char *iter = buffer.BeginWriting(); buffer.BeginWriting(iter);
*(iter += nameIndex - 1) = char(0); *(iter += nameIndex - 1) = char(0);
numInts = PR_sscanf(buffer.get() + expiresIndex, "%lld", &expires); numInts = PR_sscanf(buffer.get() + expiresIndex, "%lld", &expires);
if (numInts != 1 || nsInt64(expires) < currentTime) if (numInts != 1 || nsInt64(expires) < currentTime)
continue; continue;
isDomain = Substring(buffer, isDomainIndex, pathIndex - isDomainIndex - 1).Equals(kTrue); isDomain = Substring(buffer, isDomainIndex, pathIndex - isDomainIndex - 1).Equals(kTrue);
const nsDependentCSubstring host = const nsASingleFragmentCString &host = Substring(buffer, hostIndex, isDomainIndex - hostIndex - 1);
Substring(buffer, hostIndex, isDomainIndex - hostIndex - 1);
// check for bad legacy cookies (domain not starting with a dot, or containing a port), // check for bad legacy cookies (domain not starting with a dot, or containing a port),
// and discard // and discard
if (isDomain && !host.IsEmpty() && host.First() != '.' || if (isDomain && !host.IsEmpty() && host.First() != '.' ||
host.FindChar(':') != -1) host.FindChar(':') != kNotFound)
continue; continue;
// create a new nsCookie and assign the data. // create a new nsCookie and assign the data.
@ -455,7 +458,7 @@ nsNetscapeProfileMigratorBase::LocateSignonsFile(char** aResult)
nsCAutoString extn; nsCAutoString extn;
url->GetFileExtension(extn); url->GetFileExtension(extn);
if (extn.Equals("s", CaseInsensitiveCompare)) { if (extn.EqualsIgnoreCase("s")) {
url->GetFileName(fileName); url->GetFileName(fileName);
break; break;
} }

View File

@ -41,7 +41,7 @@
#include "nsILocalFile.h" #include "nsILocalFile.h"
#include "nsIStringBundle.h" #include "nsIStringBundle.h"
#include "nsISupportsArray.h" #include "nsISupportsArray.h"
#include "nsStringAPI.h" #include "nsString.h"
class nsIFile; class nsIFile;
class nsIPrefBranch; class nsIPrefBranch;

View File

@ -20,7 +20,6 @@
* *
* Contributor(s): * Contributor(s):
* Ben Goodger <ben@bengoodger.com> * Ben Goodger <ben@bengoodger.com>
* Benjamin Smedberg <benjamin@smedbergs.us>
* *
* Alternatively, the contents of this file may be used under the terms of * Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or * either the GNU General Public License Version 2 or later (the "GPL"), or
@ -43,7 +42,6 @@
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
#include "nsISupportsArray.h" #include "nsISupportsArray.h"
#include "nsISupportsPrimitives.h" #include "nsISupportsPrimitives.h"
#include "nsServiceManagerUtils.h"
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// nsOmniWebProfileMigrator // nsOmniWebProfileMigrator

View File

@ -41,7 +41,7 @@
#include "nsIBrowserProfileMigrator.h" #include "nsIBrowserProfileMigrator.h"
#include "nsIObserverService.h" #include "nsIObserverService.h"
#include "nsISupportsArray.h" #include "nsISupportsArray.h"
#include "nsStringAPI.h" #include "nsString.h"
class nsOmniWebProfileMigrator : public nsIBrowserProfileMigrator class nsOmniWebProfileMigrator : public nsIBrowserProfileMigrator
{ {
@ -58,4 +58,4 @@ private:
nsCOMPtr<nsIObserverService> mObserverService; nsCOMPtr<nsIObserverService> mObserverService;
}; };
#endif #endif

View File

@ -37,8 +37,8 @@
#include "nsAppDirectoryServiceDefs.h" #include "nsAppDirectoryServiceDefs.h"
#include "nsBrowserProfileMigratorUtils.h" #include "nsBrowserProfileMigratorUtils.h"
#include "nsCRT.h"
#include "nsDirectoryServiceDefs.h" #include "nsDirectoryServiceDefs.h"
#include "nsDirectoryServiceUtils.h"
#include "nsDocShellCID.h" #include "nsDocShellCID.h"
#ifdef MOZ_PLACES_BOOKMARKS #ifdef MOZ_PLACES_BOOKMARKS
#include "nsINavBookmarksService.h" #include "nsINavBookmarksService.h"
@ -67,6 +67,8 @@
#include "nsISupportsPrimitives.h" #include "nsISupportsPrimitives.h"
#include "nsNetUtil.h" #include "nsNetUtil.h"
#include "nsOperaProfileMigrator.h" #include "nsOperaProfileMigrator.h"
#include "nsReadableUtils.h"
#include "nsString.h"
#include "nsToolkitCompsCID.h" #include "nsToolkitCompsCID.h"
#ifdef XP_WIN #ifdef XP_WIN
#include <windows.h> #include <windows.h>
@ -215,9 +217,7 @@ NS_IMETHODIMP
nsOperaProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult) nsOperaProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
{ {
if (!mProfiles) { if (!mProfiles) {
nsresult rv; nsresult rv = NS_NewISupportsArray(getter_AddRefs(mProfiles));
mProfiles = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIProperties> fileLocator(do_GetService("@mozilla.org/file/directory_service;1")); nsCOMPtr<nsIProperties> fileLocator(do_GetService("@mozilla.org/file/directory_service;1"));
@ -379,7 +379,7 @@ nsOperaProfileMigrator::SetWString(void* aTransform, nsIPrefBranch* aBranch)
{ {
PrefTransform* xform = (PrefTransform*)aTransform; PrefTransform* xform = (PrefTransform*)aTransform;
nsCOMPtr<nsIPrefLocalizedString> pls(do_CreateInstance("@mozilla.org/pref-localizedstring;1")); nsCOMPtr<nsIPrefLocalizedString> pls(do_CreateInstance("@mozilla.org/pref-localizedstring;1"));
NS_ConvertASCIItoUTF16 data(xform->stringValue); nsAutoString data; data.AssignWithConversion(xform->stringValue);
pls->SetData(data.get()); pls->SetData(data.get());
return aBranch->SetComplexValue(xform->targetPrefName, NS_GET_IID(nsIPrefLocalizedString), pls); return aBranch->SetComplexValue(xform->targetPrefName, NS_GET_IID(nsIPrefLocalizedString), pls);
} }
@ -443,7 +443,7 @@ nsOperaProfileMigrator::CopyPreferences(PRBool aReplace)
transform->keyName, transform->keyName,
val); val);
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
nsresult strerr; PRInt32 strerr;
switch (transform->type) { switch (transform->type) {
case _OPM(STRING): case _OPM(STRING):
transform->stringValue = ToNewCString(val); transform->stringValue = ToNewCString(val);
@ -550,7 +550,7 @@ nsOperaProfileMigrator::GetInteger(nsINIParser &aParser,
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return rv;
*aResult = val.ToInteger(&rv); *aResult = val.ToInteger((PRInt32*) &rv);
return rv; return rv;
} }
@ -874,7 +874,7 @@ nsOperaCookieMigrator::AddCookieOverride(nsIPermissionManager* aManager)
{ {
nsresult rv; nsresult rv;
nsCString domain; nsXPIDLCString domain;
SynthesizeDomain(getter_Copies(domain)); SynthesizeDomain(getter_Copies(domain));
nsCOMPtr<nsIURI> uri(do_CreateInstance("@mozilla.org/network/standard-url;1")); nsCOMPtr<nsIURI> uri(do_CreateInstance("@mozilla.org/network/standard-url;1"));
if (!uri) if (!uri)
@ -896,10 +896,10 @@ nsOperaCookieMigrator::AddCookie(nsICookieManager2* aManager)
{ {
// This is where we use the information gathered in all the other // This is where we use the information gathered in all the other
// states to add a cookie to the Firebird/Firefox Cookie Manager. // states to add a cookie to the Firebird/Firefox Cookie Manager.
nsCString domain; nsXPIDLCString domain;
SynthesizeDomain(getter_Copies(domain)); SynthesizeDomain(getter_Copies(domain));
nsCString path; nsXPIDLCString path;
SynthesizePath(getter_Copies(path)); SynthesizePath(getter_Copies(path));
mCookieOpen = PR_FALSE; mCookieOpen = PR_FALSE;
@ -1006,7 +1006,7 @@ nsOperaProfileMigrator::CopyHistory(PRBool aReplace)
break; break;
case LASTVISIT: case LASTVISIT:
// Opera time format is a second offset, PRTime is a microsecond offset // Opera time format is a second offset, PRTime is a microsecond offset
nsresult err; PRInt32 err;
lastVisitDate = buffer.ToInteger(&err); lastVisitDate = buffer.ToInteger(&err);
PRInt64 temp, million; PRInt64 temp, million;
@ -1067,12 +1067,12 @@ nsOperaProfileMigrator::CopyBookmarks(PRBool aReplace)
nsCOMPtr<nsIStringBundle> bundle; nsCOMPtr<nsIStringBundle> bundle;
bundleService->CreateBundle(MIGRATION_BUNDLE, getter_AddRefs(bundle)); bundleService->CreateBundle(MIGRATION_BUNDLE, getter_AddRefs(bundle));
if (!aReplace) { if (!aReplace) {
nsString sourceNameOpera; nsXPIDLString sourceNameOpera;
bundle->GetStringFromName(NS_LITERAL_STRING("sourceNameOpera").get(), bundle->GetStringFromName(NS_LITERAL_STRING("sourceNameOpera").get(),
getter_Copies(sourceNameOpera)); getter_Copies(sourceNameOpera));
const PRUnichar* sourceNameStrings[] = { sourceNameOpera.get() }; const PRUnichar* sourceNameStrings[] = { sourceNameOpera.get() };
nsString importedOperaHotlistTitle; nsXPIDLString importedOperaHotlistTitle;
bundle->FormatStringFromName(NS_LITERAL_STRING("importedBookmarksFolder").get(), bundle->FormatStringFromName(NS_LITERAL_STRING("importedBookmarksFolder").get(),
sourceNameStrings, 1, sourceNameStrings, 1,
getter_Copies(importedOperaHotlistTitle)); getter_Copies(importedOperaHotlistTitle));
@ -1135,12 +1135,12 @@ nsOperaProfileMigrator::CopySmartKeywords(nsIBookmarksService* aBMS,
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return NS_OK; return NS_OK;
nsString sourceNameOpera; nsXPIDLString sourceNameOpera;
aBundle->GetStringFromName(NS_LITERAL_STRING("sourceNameOpera").get(), aBundle->GetStringFromName(NS_LITERAL_STRING("sourceNameOpera").get(),
getter_Copies(sourceNameOpera)); getter_Copies(sourceNameOpera));
const PRUnichar* sourceNameStrings[] = { sourceNameOpera.get() }; const PRUnichar* sourceNameStrings[] = { sourceNameOpera.get() };
nsString importedSearchUrlsTitle; nsXPIDLString importedSearchUrlsTitle;
aBundle->FormatStringFromName(NS_LITERAL_STRING("importedSearchURLsFolder").get(), aBundle->FormatStringFromName(NS_LITERAL_STRING("importedSearchURLsFolder").get(),
sourceNameStrings, 1, sourceNameStrings, 1,
getter_Copies(importedSearchUrlsTitle)); getter_Copies(importedSearchUrlsTitle));
@ -1207,10 +1207,10 @@ nsOperaProfileMigrator::CopySmartKeywords(nsIBookmarksService* aBMS,
nsCAutoString hostCStr; nsCAutoString hostCStr;
uri->GetHost(hostCStr); uri->GetHost(hostCStr);
NS_ConvertASCIItoUTF16 host(hostCStr); nsAutoString host; host.AssignWithConversion(hostCStr.get());
const PRUnichar* descStrings[] = { NS_ConvertUTF8toUTF16(keyword).get(), host.get() }; const PRUnichar* descStrings[] = { NS_ConvertUTF8toUTF16(keyword).get(), host.get() };
nsString keywordDesc; nsXPIDLString keywordDesc;
aBundle->FormatStringFromName(NS_LITERAL_STRING("importedSearchUrlDesc").get(), aBundle->FormatStringFromName(NS_LITERAL_STRING("importedSearchUrlDesc").get(),
descStrings, 2, getter_Copies(keywordDesc)); descStrings, 2, getter_Copies(keywordDesc));
@ -1340,6 +1340,7 @@ nsOperaProfileMigrator::ParseBookmarksFolder(nsILineInputStream* aStream,
nsAutoString name, keyword, description; nsAutoString name, keyword, description;
nsCAutoString url; nsCAutoString url;
PRBool onToolbar = PR_FALSE; PRBool onToolbar = PR_FALSE;
NS_NAMED_LITERAL_STRING(empty, "");
do { do {
nsCAutoString cBuffer; nsCAutoString cBuffer;
rv = aStream->ReadLine(cBuffer, &moreData); rv = aStream->ReadLine(cBuffer, &moreData);
@ -1348,7 +1349,7 @@ nsOperaProfileMigrator::ParseBookmarksFolder(nsILineInputStream* aStream,
if (!moreData) break; if (!moreData) break;
CopyUTF8toUTF16(cBuffer, buffer); CopyUTF8toUTF16(cBuffer, buffer);
nsString data; nsXPIDLString data;
LineType type = GetLineType(buffer, getter_Copies(data)); LineType type = GetLineType(buffer, getter_Copies(data));
switch(type) { switch(type) {
case LineType_FOLDER: case LineType_FOLDER:
@ -1414,10 +1415,10 @@ nsOperaProfileMigrator::ParseBookmarksFolder(nsILineInputStream* aStream,
if (NS_FAILED(rv)) if (NS_FAILED(rv))
continue; continue;
#endif #endif
name.Truncate(); name = empty;
url.Truncate(); url.AssignWithConversion(empty);
keyword.Truncate(); keyword = empty;
description.Truncate(); description = empty;
onToolbar = PR_FALSE; onToolbar = PR_FALSE;
} }
} }
@ -1439,7 +1440,7 @@ nsOperaProfileMigrator::ParseBookmarksFolder(nsILineInputStream* aStream,
continue; continue;
rv = ParseBookmarksFolder(aStream, itemRes, aToolbar, aBMS); rv = ParseBookmarksFolder(aStream, itemRes, aToolbar, aBMS);
#endif #endif
name.Truncate(); name = empty;
} }
} }
break; break;

View File

@ -43,7 +43,7 @@
#include "nsIBrowserProfileMigrator.h" #include "nsIBrowserProfileMigrator.h"
#include "nsIObserverService.h" #include "nsIObserverService.h"
#include "nsISupportsArray.h" #include "nsISupportsArray.h"
#include "nsStringAPI.h" #include "nsString.h"
#include "nsVoidArray.h" #include "nsVoidArray.h"
class nsICookieManager2; class nsICookieManager2;

View File

@ -36,6 +36,7 @@
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
#include "nsBrowserProfileMigratorUtils.h" #include "nsBrowserProfileMigratorUtils.h"
#include "nsCRT.h"
#include "nsDirectoryServiceDefs.h" #include "nsDirectoryServiceDefs.h"
#include "nsIObserverService.h" #include "nsIObserverService.h"
#include "nsIPrefService.h" #include "nsIPrefService.h"
@ -172,11 +173,11 @@ nsPhoenixProfileMigrator::GetMigrateData(const PRUnichar* aProfile,
aReplace, mSourceProfile, aResult); aReplace, mSourceProfile, aResult);
// Now locate passwords // Now locate passwords
nsCString signonsFileName; nsXPIDLCString signonsFileName;
GetSignonFileName(aReplace, getter_Copies(signonsFileName)); GetSignonFileName(aReplace, getter_Copies(signonsFileName));
if (!signonsFileName.IsEmpty()) { if (!signonsFileName.IsEmpty()) {
NS_ConvertASCIItoUTF16 fileName(signonsFileName); nsAutoString fileName; fileName.AssignWithConversion(signonsFileName);
nsCOMPtr<nsIFile> sourcePasswordsFile; nsCOMPtr<nsIFile> sourcePasswordsFile;
mSourceProfile->Clone(getter_AddRefs(sourcePasswordsFile)); mSourceProfile->Clone(getter_AddRefs(sourcePasswordsFile));
sourcePasswordsFile->Append(fileName); sourcePasswordsFile->Append(fileName);
@ -228,9 +229,11 @@ NS_IMETHODIMP
nsPhoenixProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult) nsPhoenixProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
{ {
if (!mProfileNames && !mProfileLocations) { if (!mProfileNames && !mProfileLocations) {
mProfileNames = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID); nsresult rv = NS_NewISupportsArray(getter_AddRefs(mProfileNames));
mProfileLocations = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID); if (NS_FAILED(rv)) return rv;
NS_ENSURE_TRUE(mProfileNames && mProfileLocations, NS_ERROR_UNEXPECTED);
rv = NS_NewISupportsArray(getter_AddRefs(mProfileLocations));
if (NS_FAILED(rv)) return rv;
// Fills mProfileNames and mProfileLocations // Fills mProfileNames and mProfileLocations
FillProfileDataFromPhoenixRegistry(); FillProfileDataFromPhoenixRegistry();
@ -254,14 +257,11 @@ nsPhoenixProfileMigrator::GetSourceProfile(const PRUnichar* aProfile)
PRUint32 count; PRUint32 count;
mProfileNames->Count(&count); mProfileNames->Count(&count);
for (PRUint32 i = 0; i < count; ++i) { for (PRUint32 i = 0; i < count; ++i) {
nsCOMPtr<nsISupportsString> str; nsCOMPtr<nsISupportsString> str(do_QueryElementAt(mProfileNames, i));
mProfileNames->QueryElementAt(i, NS_GET_IID(nsISupportsString), nsXPIDLString profileName;
getter_AddRefs(str));
nsString profileName;
str->GetData(profileName); str->GetData(profileName);
if (profileName.Equals(aProfile)) { if (profileName.Equals(aProfile)) {
mProfileLocations->QueryElementAt(i, NS_GET_IID(nsILocalFile), mSourceProfile = do_QueryElementAt(mProfileLocations, i);
getter_AddRefs(mSourceProfile));
break; break;
} }
} }
@ -397,7 +397,7 @@ nsPhoenixProfileMigrator::CopyPasswords(PRBool aReplace)
{ {
nsresult rv; nsresult rv;
nsCString signonsFileName; nsXPIDLCString signonsFileName;
if (!aReplace) if (!aReplace)
return NS_OK; return NS_OK;
@ -417,7 +417,7 @@ nsPhoenixProfileMigrator::CopyPasswords(PRBool aReplace)
if (signonsFileName.IsEmpty()) if (signonsFileName.IsEmpty())
return NS_ERROR_FILE_NOT_FOUND; return NS_ERROR_FILE_NOT_FOUND;
NS_ConvertASCIItoUTF16 fileName(signonsFileName); nsAutoString fileName; fileName.AssignWithConversion(signonsFileName);
return aReplace ? CopyFile(fileName, fileName) : NS_OK; return aReplace ? CopyFile(fileName, fileName) : NS_OK;
} }

View File

@ -43,7 +43,7 @@
#include "nsIObserverService.h" #include "nsIObserverService.h"
#include "nsISupportsArray.h" #include "nsISupportsArray.h"
#include "nsNetscapeProfileMigratorBase.h" #include "nsNetscapeProfileMigratorBase.h"
#include "nsStringAPI.h" #include "nsString.h"
class nsIFile; class nsIFile;
class nsIPrefBranch; class nsIPrefBranch;

View File

@ -42,7 +42,6 @@
#include "nsIDOMWindowInternal.h" #include "nsIDOMWindowInternal.h"
#include "nsILocalFile.h" #include "nsILocalFile.h"
#include "nsIObserverService.h" #include "nsIObserverService.h"
#include "nsIProperties.h"
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
#include "nsISupportsPrimitives.h" #include "nsISupportsPrimitives.h"
#include "nsISupportsArray.h" #include "nsISupportsArray.h"
@ -52,13 +51,13 @@
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsBrowserCompsCID.h" #include "nsBrowserCompsCID.h"
#include "nsComponentManagerUtils.h"
#include "nsDirectoryServiceDefs.h" #include "nsDirectoryServiceDefs.h"
#include "nsServiceManagerUtils.h"
#include "nsCRT.h"
#include "NSReg.h" #include "NSReg.h"
#include "nsStringAPI.h" #include "nsReadableUtils.h"
#include "nsUnicharUtils.h" #include "nsUnicharUtils.h"
#include "nsString.h"
#ifdef XP_WIN #ifdef XP_WIN
#include <windows.h> #include <windows.h>
#include "nsIWindowsRegKey.h" #include "nsIWindowsRegKey.h"
@ -66,6 +65,7 @@
#endif #endif
#include "nsAutoPtr.h" #include "nsAutoPtr.h"
#include "nsNativeCharsetUtils.h"
#ifndef MAXPATHLEN #ifndef MAXPATHLEN
#ifdef _MAX_PATH #ifdef _MAX_PATH
@ -95,8 +95,8 @@ nsProfileMigrator::Migrate(nsIProfileStartup* aStartup)
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
if (!bpm) { if (!bpm) {
nsCAutoString contractID(NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX); nsCAutoString contractID =
contractID.Append(key); NS_LITERAL_CSTRING(NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX) + key;
bpm = do_CreateInstance(contractID.get()); bpm = do_CreateInstance(contractID.get());
if (!bpm) return NS_ERROR_FAILURE; if (!bpm) return NS_ERROR_FAILURE;
@ -123,8 +123,8 @@ nsProfileMigrator::Migrate(nsIProfileStartup* aStartup)
// By opening the Migration FE with a supplied bpm, it will automatically // By opening the Migration FE with a supplied bpm, it will automatically
// migrate from it. // migrate from it.
nsCOMPtr<nsIWindowWatcher> ww(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); nsCOMPtr<nsIWindowWatcher> ww(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
nsCOMPtr<nsISupportsArray> params = nsCOMPtr<nsISupportsArray> params;
do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID); NS_NewISupportsArray(getter_AddRefs(params));
if (!ww || !params) return NS_ERROR_FAILURE; if (!ww || !params) return NS_ERROR_FAILURE;
params->AppendElement(cstr); params->AppendElement(cstr);
@ -187,18 +187,20 @@ nsProfileMigrator::GetDefaultBrowserMigratorKey(nsACString& aKey,
if (NS_FAILED(regKey->ReadStringValue(EmptyString(), value))) if (NS_FAILED(regKey->ReadStringValue(EmptyString(), value)))
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
PRInt32 len = value.Find(NS_LITERAL_STRING(".exe"), CaseInsensitiveCompare); nsAString::const_iterator start, end;
if (len == -1) value.BeginReading(start);
value.EndReading(end);
nsAString::const_iterator tmp = start;
if (!FindInReadable(NS_LITERAL_STRING(".exe"), tmp, end,
nsCaseInsensitiveStringComparator()))
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
PRUint32 start = 0;
// skip an opening quotation mark if present // skip an opening quotation mark if present
if (value.get()[1] != ':') { if (value.CharAt(1) != ':')
start = 1; ++start;
--len;
}
const nsDependentSubstring filePath(Substring(value, start, len)); nsDependentSubstring filePath(start, end);
// We want to find out what the default browser is but the path in and of itself // We want to find out what the default browser is but the path in and of itself
// isn't enough. Why? Because sometimes on Windows paths get truncated like so: // isn't enough. Why? Because sometimes on Windows paths get truncated like so:

View File

@ -38,8 +38,8 @@
#include "nsAppDirectoryServiceDefs.h" #include "nsAppDirectoryServiceDefs.h"
#include "nsBrowserProfileMigratorUtils.h" #include "nsBrowserProfileMigratorUtils.h"
#include "nsCRT.h"
#include "nsDirectoryServiceDefs.h" #include "nsDirectoryServiceDefs.h"
#include "nsDirectoryServiceUtils.h"
#include "nsDocShellCID.h" #include "nsDocShellCID.h"
#ifdef MOZ_PLACES_BOOKMARKS #ifdef MOZ_PLACES_BOOKMARKS
#include "nsINavBookmarksService.h" #include "nsINavBookmarksService.h"
@ -476,7 +476,7 @@ nsSafariProfileMigrator::SetDefaultEncoding(void* aTransform, nsIPrefBranch* aBr
for (PRUint16 i = 0; (charsetIndex == -1) && for (PRUint16 i = 0; (charsetIndex == -1) &&
i < (sizeof(gCharsets) / sizeof(gCharsets[0])); ++i) { i < (sizeof(gCharsets) / sizeof(gCharsets[0])); ++i) {
if (gCharsets[i].webkitLabelLength == encodingLength && if (gCharsets[i].webkitLabelLength == encodingLength &&
!strcmp(gCharsets[i].webkitLabel, encodingStr)) !nsCRT::strcmp(gCharsets[i].webkitLabel, encodingStr))
charsetIndex = (PRInt16)i; charsetIndex = (PRInt16)i;
} }
if (charsetIndex == -1) // Default to "Western" if (charsetIndex == -1) // Default to "Western"
@ -654,7 +654,7 @@ nsSafariProfileMigrator::SetDisplayImages(void* aTransform, nsIPrefBranch* aBran
nsresult nsresult
nsSafariProfileMigrator::SetFontName(void* aTransform, nsIPrefBranch* aBranch) nsSafariProfileMigrator::SetFontName(void* aTransform, nsIPrefBranch* aBranch)
{ {
nsCString associatedLangGroup; nsXPIDLCString associatedLangGroup;
nsresult rv = aBranch->GetCharPref("migration.associatedLangGroup", nsresult rv = aBranch->GetCharPref("migration.associatedLangGroup",
getter_Copies(associatedLangGroup)); getter_Copies(associatedLangGroup));
if (NS_FAILED(rv)) if (NS_FAILED(rv))
@ -670,7 +670,7 @@ nsSafariProfileMigrator::SetFontName(void* aTransform, nsIPrefBranch* aBranch)
nsresult nsresult
nsSafariProfileMigrator::SetFontSize(void* aTransform, nsIPrefBranch* aBranch) nsSafariProfileMigrator::SetFontSize(void* aTransform, nsIPrefBranch* aBranch)
{ {
nsCString associatedLangGroup; nsXPIDLCString associatedLangGroup;
nsresult rv = aBranch->GetCharPref("migration.associatedLangGroup", nsresult rv = aBranch->GetCharPref("migration.associatedLangGroup",
getter_Copies(associatedLangGroup)); getter_Copies(associatedLangGroup));
if (NS_FAILED(rv)) if (NS_FAILED(rv))
@ -916,12 +916,12 @@ nsSafariProfileMigrator::CopyBookmarks(PRBool aReplace)
nsCOMPtr<nsIStringBundle> bundle; nsCOMPtr<nsIStringBundle> bundle;
bundleService->CreateBundle(MIGRATION_BUNDLE, getter_AddRefs(bundle)); bundleService->CreateBundle(MIGRATION_BUNDLE, getter_AddRefs(bundle));
nsString sourceNameSafari; nsXPIDLString sourceNameSafari;
bundle->GetStringFromName(NS_LITERAL_STRING("sourceNameSafari").get(), bundle->GetStringFromName(NS_LITERAL_STRING("sourceNameSafari").get(),
getter_Copies(sourceNameSafari)); getter_Copies(sourceNameSafari));
const PRUnichar* sourceNameStrings[] = { sourceNameSafari.get() }; const PRUnichar* sourceNameStrings[] = { sourceNameSafari.get() };
nsString importedSafariBookmarksTitle; nsXPIDLString importedSafariBookmarksTitle;
bundle->FormatStringFromName(NS_LITERAL_STRING("importedBookmarksFolder").get(), bundle->FormatStringFromName(NS_LITERAL_STRING("importedBookmarksFolder").get(),
sourceNameStrings, 1, sourceNameStrings, 1,
getter_Copies(importedSafariBookmarksTitle)); getter_Copies(importedSafariBookmarksTitle));
@ -1144,9 +1144,7 @@ nsSafariProfileMigrator::ProfileHasContentStyleSheet(PRBool *outExists)
rv = userChromeDir->GetNativePath(userChromeDirPath); rv = userChromeDir->GetNativePath(userChromeDirPath);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
nsCAutoString path(userChromeDirPath); nsCAutoString path = userChromeDirPath + NS_LITERAL_CSTRING("/userContent.css");
path.Append("/userContent.css");
nsCOMPtr<nsILocalFile> file; nsCOMPtr<nsILocalFile> file;
rv = NS_NewNativeLocalFile(path, PR_FALSE, rv = NS_NewNativeLocalFile(path, PR_FALSE,
getter_AddRefs(file)); getter_AddRefs(file));

View File

@ -42,7 +42,7 @@
#include "nsIBrowserProfileMigrator.h" #include "nsIBrowserProfileMigrator.h"
#include "nsIObserverService.h" #include "nsIObserverService.h"
#include "nsISupportsArray.h" #include "nsISupportsArray.h"
#include "nsStringAPI.h" #include "nsString.h"
#include <CoreFoundation/CoreFoundation.h> #include <CoreFoundation/CoreFoundation.h>

View File

@ -36,6 +36,7 @@
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
#include "nsBrowserProfileMigratorUtils.h" #include "nsBrowserProfileMigratorUtils.h"
#include "nsCRT.h"
#include "nsDirectoryServiceDefs.h" #include "nsDirectoryServiceDefs.h"
#include "nsICookieManager2.h" #include "nsICookieManager2.h"
#include "nsIObserverService.h" #include "nsIObserverService.h"
@ -160,11 +161,11 @@ nsSeamonkeyProfileMigrator::GetMigrateData(const PRUnichar* aProfile,
aReplace, mSourceProfile, aResult); aReplace, mSourceProfile, aResult);
// Now locate passwords // Now locate passwords
nsCString signonsFileName; nsXPIDLCString signonsFileName;
GetSignonFileName(aReplace, getter_Copies(signonsFileName)); GetSignonFileName(aReplace, getter_Copies(signonsFileName));
if (!signonsFileName.IsEmpty()) { if (!signonsFileName.IsEmpty()) {
NS_ConvertASCIItoUTF16 fileName(signonsFileName); nsAutoString fileName; fileName.AssignWithConversion(signonsFileName);
nsCOMPtr<nsIFile> sourcePasswordsFile; nsCOMPtr<nsIFile> sourcePasswordsFile;
mSourceProfile->Clone(getter_AddRefs(sourcePasswordsFile)); mSourceProfile->Clone(getter_AddRefs(sourcePasswordsFile));
sourcePasswordsFile->Append(fileName); sourcePasswordsFile->Append(fileName);
@ -216,9 +217,11 @@ NS_IMETHODIMP
nsSeamonkeyProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult) nsSeamonkeyProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
{ {
if (!mProfileNames && !mProfileLocations) { if (!mProfileNames && !mProfileLocations) {
mProfileNames = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID); nsresult rv = NS_NewISupportsArray(getter_AddRefs(mProfileNames));
mProfileLocations = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID); if (NS_FAILED(rv)) return rv;
NS_ENSURE_TRUE(mProfileNames && mProfileLocations, NS_ERROR_UNEXPECTED);
rv = NS_NewISupportsArray(getter_AddRefs(mProfileLocations));
if (NS_FAILED(rv)) return rv;
// Fills mProfileNames and mProfileLocations // Fills mProfileNames and mProfileLocations
FillProfileDataFromSeamonkeyRegistry(); FillProfileDataFromSeamonkeyRegistry();
@ -252,7 +255,7 @@ nsSeamonkeyProfileMigrator::GetSourceHomePageURL(nsACString& aResult)
NS_GET_IID(nsIPrefLocalizedString), NS_GET_IID(nsIPrefLocalizedString),
getter_AddRefs(prefValue)); getter_AddRefs(prefValue));
if (NS_SUCCEEDED(rv) && prefValue) { if (NS_SUCCEEDED(rv) && prefValue) {
nsString data; nsXPIDLString data;
prefValue->ToString(getter_Copies(data)); prefValue->ToString(getter_Copies(data));
nsCAutoString val; nsCAutoString val;
@ -277,14 +280,11 @@ nsSeamonkeyProfileMigrator::GetSourceProfile(const PRUnichar* aProfile)
PRUint32 count; PRUint32 count;
mProfileNames->Count(&count); mProfileNames->Count(&count);
for (PRUint32 i = 0; i < count; ++i) { for (PRUint32 i = 0; i < count; ++i) {
nsCOMPtr<nsISupportsString> str; nsCOMPtr<nsISupportsString> str(do_QueryElementAt(mProfileNames, i));
mProfileNames->QueryElementAt(i, NS_GET_IID(nsISupportsString), nsXPIDLString profileName;
getter_AddRefs(str));
nsString profileName;
str->GetData(profileName); str->GetData(profileName);
if (profileName.Equals(aProfile)) { if (profileName.Equals(aProfile)) {
mProfileLocations->QueryElementAt(i, NS_GET_IID(nsILocalFile), mSourceProfile = do_QueryElementAt(mProfileLocations, i);
getter_AddRefs(mSourceProfile));
break; break;
} }
} }
@ -570,7 +570,7 @@ nsSeamonkeyProfileMigrator::WriteFontsBranch(nsIPrefService* aPrefService,
switch (pref->type) { switch (pref->type) {
case nsIPrefBranch::PREF_STRING: case nsIPrefBranch::PREF_STRING:
rv = branch->SetCharPref(pref->prefName, pref->stringValue); rv = branch->SetCharPref(pref->prefName, pref->stringValue);
NS_Free(pref->stringValue); PL_strfree(pref->stringValue);
pref->stringValue = nsnull; pref->stringValue = nsnull;
break; break;
case nsIPrefBranch::PREF_BOOL: case nsIPrefBranch::PREF_BOOL:
@ -673,13 +673,13 @@ nsSeamonkeyProfileMigrator::CopyPasswords(PRBool aReplace)
{ {
nsresult rv; nsresult rv;
nsCString signonsFileName; nsXPIDLCString signonsFileName;
GetSignonFileName(aReplace, getter_Copies(signonsFileName)); GetSignonFileName(aReplace, getter_Copies(signonsFileName));
if (signonsFileName.IsEmpty()) if (signonsFileName.IsEmpty())
return NS_ERROR_FILE_NOT_FOUND; return NS_ERROR_FILE_NOT_FOUND;
NS_ConvertASCIItoUTF16 fileName(signonsFileName); nsAutoString fileName; fileName.AssignWithConversion(signonsFileName);
if (aReplace) if (aReplace)
rv = CopyFile(fileName, fileName); rv = CopyFile(fileName, fileName);
else { else {

View File

@ -43,7 +43,7 @@
#include "nsIObserverService.h" #include "nsIObserverService.h"
#include "nsISupportsArray.h" #include "nsISupportsArray.h"
#include "nsNetscapeProfileMigratorBase.h" #include "nsNetscapeProfileMigratorBase.h"
#include "nsStringAPI.h" #include "nsString.h"
class nsIFile; class nsIFile;
class nsIPrefBranch; class nsIPrefBranch;

View File

@ -43,8 +43,8 @@ include $(DEPTH)/config/autoconf.mk
MODULE = safebrowsing MODULE = safebrowsing
LIBRARY_NAME = safebrowsing_s LIBRARY_NAME = safebrowsing_s
MOZILLA_INTERNAL_API = 1
FORCE_STATIC_LIB = 1 FORCE_STATIC_LIB = 1
FORCE_USE_PIC = 1
REQUIRES = \ REQUIRES = \
necko \ necko \

View File

@ -43,9 +43,8 @@
#include "nsITimer.h" #include "nsITimer.h"
#include "nsIURI.h" #include "nsIURI.h"
#include "nsIWebProgress.h" #include "nsIWebProgress.h"
#include "nsComponentManagerUtils.h"
#include "nsServiceManagerUtils.h" #include "nsServiceManagerUtils.h"
#include "nsStringAPI.h" #include "nsString.h"
NS_IMPL_ISUPPORTS4(nsDocNavStartProgressListener, NS_IMPL_ISUPPORTS4(nsDocNavStartProgressListener,
nsIDocNavStartProgressListener, nsIDocNavStartProgressListener,
@ -333,7 +332,7 @@ nsDocNavStartProgressListener::Observe(nsISupports *subject, const char *topic,
// We don't care about URL fragments so we take that off. // We don't care about URL fragments so we take that off.
PRInt32 pos = uriString.FindChar('#'); PRInt32 pos = uriString.FindChar('#');
if (pos > -1) { if (pos > -1) {
uriString.SetLength(pos); uriString.Truncate(pos);
} }
mCallback->OnDocNavStart(request, uriString); mCallback->OnDocNavStart(request, uriString);

View File

@ -43,8 +43,7 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk include $(DEPTH)/config/autoconf.mk
MODULE = shellservice MODULE = shellservice
FORCE_STATIC_LIB = 1 MOZILLA_INTERNAL_API = 1
FORCE_USE_PIC = 1
REQUIRES = \ REQUIRES = \
xpcom \ xpcom \
@ -80,6 +79,8 @@ ifdef CPPSRCS
LIBRARY_NAME = shellservice_s LIBRARY_NAME = shellservice_s
endif endif
FORCE_STATIC_LIB = 1
include $(topsrcdir)/config/rules.mk include $(topsrcdir)/config/rules.mk
DEFINES += -DMOZ_APP_NAME=\"$(MOZ_APP_NAME)\" DEFINES += -DMOZ_APP_NAME=\"$(MOZ_APP_NAME)\"

View File

@ -43,7 +43,7 @@
#include "nsDirectoryServiceDefs.h" #include "nsDirectoryServiceDefs.h"
#include "nsIPrefService.h" #include "nsIPrefService.h"
#include "prenv.h" #include "prenv.h"
#include "nsStringAPI.h" #include "nsString.h"
#include "nsIGConfService.h" #include "nsIGConfService.h"
#include "nsIGnomeVFSService.h" #include "nsIGnomeVFSService.h"
#include "nsIStringBundle.h" #include "nsIStringBundle.h"
@ -56,10 +56,10 @@
#include "imgIRequest.h" #include "imgIRequest.h"
#include "imgIContainer.h" #include "imgIContainer.h"
#include "nsIImage.h" #include "nsIImage.h"
#include "prprf.h"
#ifdef MOZ_WIDGET_GTK2 #ifdef MOZ_WIDGET_GTK2
#include "nsIImageToPixbuf.h" #include "nsIImageToPixbuf.h"
#endif #endif
#include "nsColor.h"
#include <glib.h> #include <glib.h>
#include <glib-object.h> #include <glib-object.h>
@ -217,13 +217,12 @@ nsGNOMEShellService::SetDefaultBrowser(PRBool aClaimAllTypes,
nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID); nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
nsCAutoString schemeList; nsCAutoString schemeList;
nsCAutoString appKeyValue(mAppPath); nsCAutoString appKeyValue(mAppPath + NS_LITERAL_CSTRING(" \"%s\""));
appKeyValue.Append(" \"%s\"");
unsigned int i; unsigned int i;
for (i = 0; i < NS_ARRAY_LENGTH(appProtocols); ++i) { for (i = 0; i < NS_ARRAY_LENGTH(appProtocols); ++i) {
schemeList.Append(nsDependentCString(appProtocols[i].name)); schemeList.Append(nsDependentCString(appProtocols[i].name)
schemeList.Append(','); + NS_LITERAL_CSTRING(","));
if (appProtocols[i].essential || aClaimAllTypes) { if (appProtocols[i].essential || aClaimAllTypes) {
gconf->SetAppForProtocol(nsDependentCString(appProtocols[i].name), gconf->SetAppForProtocol(nsDependentCString(appProtocols[i].name),
@ -243,7 +242,7 @@ nsGNOMEShellService::SetDefaultBrowser(PRBool aClaimAllTypes,
bundleService->CreateBundle(BRAND_PROPERTIES, getter_AddRefs(brandBundle)); bundleService->CreateBundle(BRAND_PROPERTIES, getter_AddRefs(brandBundle));
NS_ENSURE_TRUE(brandBundle, NS_ERROR_FAILURE); NS_ENSURE_TRUE(brandBundle, NS_ERROR_FAILURE);
nsString brandShortName, brandFullName; nsXPIDLString brandShortName, brandFullName;
brandBundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(), brandBundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(),
getter_Copies(brandShortName)); getter_Copies(brandShortName));
brandBundle->GetStringFromName(NS_LITERAL_STRING("brandFullName").get(), brandBundle->GetStringFromName(NS_LITERAL_STRING("brandFullName").get(),
@ -280,7 +279,7 @@ nsGNOMEShellService::SetDefaultBrowser(PRBool aClaimAllTypes,
if (lastSlash == -1) { if (lastSlash == -1) {
NS_ERROR("no slash in executable path?"); NS_ERROR("no slash in executable path?");
} else { } else {
iconFilePath.SetLength(lastSlash); iconFilePath.Truncate(lastSlash);
nsCOMPtr<nsILocalFile> iconFile; nsCOMPtr<nsILocalFile> iconFile;
NS_NewNativeLocalFile(iconFilePath, PR_FALSE, getter_AddRefs(iconFile)); NS_NewNativeLocalFile(iconFilePath, PR_FALSE, getter_AddRefs(iconFile));
if (iconFile) { if (iconFile) {
@ -401,7 +400,7 @@ nsGNOMEShellService::SetDesktopBackground(nsIDOMElement* aElement,
nsCAutoString filePath(PR_GetEnv("HOME")); nsCAutoString filePath(PR_GetEnv("HOME"));
// get the product brand name from localized strings // get the product brand name from localized strings
nsString brandName; nsXPIDLString brandName;
nsCID bundleCID = NS_STRINGBUNDLESERVICE_CID; nsCID bundleCID = NS_STRINGBUNDLESERVICE_CID;
nsCOMPtr<nsIStringBundleService> bundleService(do_GetService(bundleCID)); nsCOMPtr<nsIStringBundleService> bundleService(do_GetService(bundleCID));
if (bundleService) { if (bundleService) {
@ -416,10 +415,10 @@ nsGNOMEShellService::SetDesktopBackground(nsIDOMElement* aElement,
} }
// build the file name // build the file name
filePath.Append('/'); filePath.Append(NS_LITERAL_CSTRING("/") +
filePath.Append(NS_ConvertUTF16toUTF8(brandName)); NS_ConvertUTF16toUTF8(brandName) +
filePath.Append("_wallpaper.png"); NS_LITERAL_CSTRING("_wallpaper.png"));
// write the image to a file in the home dir // write the image to a file in the home dir
rv = WriteImage(filePath, gfxFrame); rv = WriteImage(filePath, gfxFrame);
@ -448,59 +447,6 @@ nsGNOMEShellService::SetDesktopBackground(nsIDOMElement* aElement,
return rv; return rv;
} }
// In: pointer to two characters CC
// Out: parsed color number
static PRUint8
HexToNum(char ch)
{
if ('0' <= ch && '9' >= ch)
return ch - '0';
if ('A' <= ch && 'F' >= ch)
return ch - 'A';
if ('a' <= ch && 'f' >= ch)
return ch - 'a';
return 0;
}
// In: 3 or 6-character RRGGBB hex string
// Out: component colors
static PRBool
HexToRGB(const nsCString& aColorSpec,
PRUint8 &aRed,
PRUint8 &aGreen,
PRUint8 &aBlue)
{
const char *buf = aColorSpec.get();
if (aColorSpec.Length() == 6) {
aRed = HexToNum(buf[0]) >> 4 |
HexToNum(buf[1]);
aGreen = HexToNum(buf[2]) >> 4 |
HexToNum(buf[3]);
aBlue = HexToNum(buf[4]) >> 4 |
HexToNum(buf[5]);
return PR_TRUE;
}
if (aColorSpec.Length() == 3) {
aRed = HexToNum(buf[0]);
aGreen = HexToNum(buf[1]);
aBlue = HexToNum(buf[2]);
aRed |= aRed >> 4;
aGreen |= aGreen >> 4;
aBlue |= aBlue >> 4;
return PR_TRUE;
}
return PR_FALSE;
}
NS_IMETHODIMP NS_IMETHODIMP
nsGNOMEShellService::GetDesktopBackgroundColor(PRUint32 *aColor) nsGNOMEShellService::GetDesktopBackgroundColor(PRUint32 *aColor)
{ {
@ -517,36 +463,26 @@ nsGNOMEShellService::GetDesktopBackgroundColor(PRUint32 *aColor)
// Chop off the leading '#' character // Chop off the leading '#' character
background.Cut(0, 1); background.Cut(0, 1);
PRUint8 red, green, blue; nscolor rgb;
if (!HexToRGB(background, red, green, blue)) if (!NS_ASCIIHexToRGB(background, &rgb))
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
// The result must be in RGB order with the high 8 bits zero. // The result must be in RGB order with the high 8 bits zero.
*aColor = (red << 16 | green << 8 | blue); *aColor = (NS_GET_R(rgb) << 16 | NS_GET_G(rgb) << 8 | NS_GET_B(rgb));
return NS_OK; return NS_OK;
} }
static void
ColorToHex(PRUint32 aColor, nsCString& aResult)
{
char *buf = aResult.BeginWriting(7);
if (!buf)
return;
PRUint8 red = (aColor >> 16);
PRUint8 green = (aColor >> 8) & 0xff;
PRUint8 blue = aColor & 0xff;
PR_snprintf(buf, 8, "#%02x%02x%02x", red, green, blue);
}
NS_IMETHODIMP NS_IMETHODIMP
nsGNOMEShellService::SetDesktopBackgroundColor(PRUint32 aColor) nsGNOMEShellService::SetDesktopBackgroundColor(PRUint32 aColor)
{ {
nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID); nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
nsCString colorString; unsigned char red = (aColor >> 16);
ColorToHex(aColor, colorString); unsigned char green = (aColor >> 8) & 0xff;
unsigned char blue = aColor & 0xff;
nsCAutoString colorString;
NS_RGBToASCIIHex(NS_RGB(red, green, blue), colorString);
gconf->SetString(NS_LITERAL_CSTRING(kDesktopColorKey), colorString); gconf->SetString(NS_LITERAL_CSTRING(kDesktopColorKey), colorString);
@ -620,7 +556,7 @@ nsGNOMEShellService::OpenApplicationWithURI(nsILocalFile* aApplication, const ns
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return rv;
const nsCString spec(aURI); const nsPromiseFlatCString& spec = PromiseFlatCString(aURI);
const char* specStr = spec.get(); const char* specStr = spec.get();
PRUint32 pid; PRUint32 pid;
return process->Run(PR_FALSE, &specStr, 1, &pid); return process->Run(PR_FALSE, &specStr, 1, &pid);

View File

@ -38,7 +38,7 @@
#define nsgnomeshellservice_h____ #define nsgnomeshellservice_h____
#include "nsIShellService.h" #include "nsIShellService.h"
#include "nsStringAPI.h" #include "nsString.h"
class nsGNOMEShellService : public nsIShellService class nsGNOMEShellService : public nsIShellService
{ {

View File

@ -21,7 +21,6 @@
* Contributor(s): * Contributor(s):
* Ben Goodger <ben@mozilla.org> (Original Author) * Ben Goodger <ben@mozilla.org> (Original Author)
* Asaf Romano <mozilla.mano@sent.com> * Asaf Romano <mozilla.mano@sent.com>
* Benjamin Smedberg <benjamin@smedbergs.us>
* *
* Alternatively, the contents of this file may be used under the terms of * Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or * either the GNU General Public License Version 2 or later (the "GPL"), or
@ -53,7 +52,7 @@
#include "nsMacShellService.h" #include "nsMacShellService.h"
#include "nsNetUtil.h" #include "nsNetUtil.h"
#include "nsShellService.h" #include "nsShellService.h"
#include "nsStringAPI.h" #include "nsString.h"
#include <CoreFoundation/CoreFoundation.h> #include <CoreFoundation/CoreFoundation.h>
#include <Carbon/Carbon.h> #include <Carbon/Carbon.h>
@ -469,7 +468,7 @@ nsMacShellService::OpenApplicationWithURI(nsILocalFile* aApplication, const nsAC
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return rv;
const nsCString spec(aURI); const nsPromiseFlatCString& spec = PromiseFlatCString(aURI);
const UInt8* uriString = (const UInt8*)spec.get(); const UInt8* uriString = (const UInt8*)spec.get();
CFURLRef uri = ::CFURLCreateWithBytes(NULL, uriString, aURI.Length(), CFURLRef uri = ::CFURLCreateWithBytes(NULL, uriString, aURI.Length(),
kCFStringEncodingUTF8, NULL); kCFStringEncodingUTF8, NULL);

View File

@ -41,7 +41,6 @@
#include "nsIMacShellService.h" #include "nsIMacShellService.h"
#include "nsIWebProgressListener.h" #include "nsIWebProgressListener.h"
#include "nsILocalFile.h" #include "nsILocalFile.h"
#include "nsCOMPtr.h"
class nsMacShellService : public nsIMacShellService, class nsMacShellService : public nsIMacShellService,
public nsIWebProgressListener public nsIWebProgressListener

View File

@ -42,6 +42,7 @@
#include "gfxIImageFrame.h" #include "gfxIImageFrame.h"
#include "imgIContainer.h" #include "imgIContainer.h"
#include "imgIRequest.h" #include "imgIRequest.h"
#include "nsCRT.h"
#include "nsIDOMDocument.h" #include "nsIDOMDocument.h"
#include "nsIDOMElement.h" #include "nsIDOMElement.h"
#include "nsIDOMHTMLImageElement.h" #include "nsIDOMHTMLImageElement.h"
@ -56,6 +57,7 @@
#include "nsIProcess.h" #include "nsIProcess.h"
#include "nsICategoryManager.h" #include "nsICategoryManager.h"
#include "nsBrowserCompsCID.h" #include "nsBrowserCompsCID.h"
#include "nsNativeCharsetUtils.h"
#include "nsDirectoryServiceUtils.h" #include "nsDirectoryServiceUtils.h"
#include "nsAppDirectoryServiceDefs.h" #include "nsAppDirectoryServiceDefs.h"
#include "shlobj.h" #include "shlobj.h"
@ -455,8 +457,8 @@ nsWindowsShellService::IsDefaultBrowser(PRBool aStartupCheck, PRBool* aIsDefault
// Close the key we opened. // Close the key we opened.
::RegCloseKey(theKey); ::RegCloseKey(theKey);
if (REG_FAILED(result) || if (REG_FAILED(result) ||
!dataLongPath.Equals(currValue, CaseInsensitiveCompare) && !dataLongPath.EqualsIgnoreCase(currValue) &&
!dataShortPath.Equals(currValue, CaseInsensitiveCompare)) { !dataShortPath.EqualsIgnoreCase(currValue)) {
// Key wasn't set, or was set to something else (something else became the default browser) // Key wasn't set, or was set to something else (something else became the default browser)
*aIsDefaultBrowser = PR_FALSE; *aIsDefaultBrowser = PR_FALSE;
break; break;
@ -532,13 +534,12 @@ nsWindowsShellService::SetDefaultBrowser(PRBool aClaimAllTypes, PRBool aForAllUs
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
// Create the Start Menu item if it doesn't exist // Create the Start Menu item if it doesn't exist
nsString brandFullName; nsXPIDLString brandFullName;
brandBundle->GetStringFromName(NS_LITERAL_STRING("brandFullName").get(), brandBundle->GetStringFromName(NS_LITERAL_STRING("brandFullName").get(),
getter_Copies(brandFullName)); getter_Copies(brandFullName));
nsCAutoString nativeFullName; nsCAutoString nativeFullName;
// For the now, we use 'A' APIs (see bug 240272, 239279) // For the now, we use 'A' APIs (see bug 240272, 239279)
NS_UTF16ToCString(brandFullName, NS_CSTRING_ENCODING_NATIVE_FILESYSTEM, NS_CopyUnicodeToNative(brandFullName, nativeFullName);
nativeFullName);
nsCAutoString key1(NS_LITERAL_CSTRING(SMI)); nsCAutoString key1(NS_LITERAL_CSTRING(SMI));
key1.Append(exeName); key1.Append(exeName);
@ -547,39 +548,35 @@ nsWindowsShellService::SetDefaultBrowser(PRBool aClaimAllTypes, PRBool aForAllUs
aForAllUsers); aForAllUsers);
// Set the Options and Safe Mode start menu context menu item labels // Set the Options and Safe Mode start menu context menu item labels
nsCAutoString optionsKey(SMI); nsCAutoString optionsKey(NS_LITERAL_CSTRING(SMI "%APPEXE%\\shell\\properties"));
optionsKey.Append(exeName); optionsKey.ReplaceSubstring("%APPEXE%", exeName.get());
optionsKey.Append("\\shell\\properties");
nsCAutoString safeModeKey(SMI); nsCAutoString safeModeKey(NS_LITERAL_CSTRING(SMI "%APPEXE%\\shell\\safemode"));
safeModeKey.Append(exeName); safeModeKey.ReplaceSubstring("%APPEXE%", exeName.get());
safeModeKey.Append("\\shell\\safemode");
nsString brandShortName; nsXPIDLString brandShortName;
brandBundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(), brandBundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(),
getter_Copies(brandShortName)); getter_Copies(brandShortName));
const PRUnichar* brandNameStrings[] = { brandShortName.get() }; const PRUnichar* brandNameStrings[] = { brandShortName.get() };
// Set the Options menu item // Set the Options menu item
nsString optionsTitle; nsXPIDLString optionsTitle;
bundle->FormatStringFromName(NS_LITERAL_STRING("optionsLabel").get(), bundle->FormatStringFromName(NS_LITERAL_STRING("optionsLabel").get(),
brandNameStrings, 1, getter_Copies(optionsTitle)); brandNameStrings, 1, getter_Copies(optionsTitle));
// Set the Safe Mode menu item // Set the Safe Mode menu item
nsString safeModeTitle; nsXPIDLString safeModeTitle;
bundle->FormatStringFromName(NS_LITERAL_STRING("safeModeLabel").get(), bundle->FormatStringFromName(NS_LITERAL_STRING("safeModeLabel").get(),
brandNameStrings, 1, getter_Copies(safeModeTitle)); brandNameStrings, 1, getter_Copies(safeModeTitle));
// Set the registry keys // Set the registry keys
nsCAutoString nativeTitle; nsCAutoString nativeTitle;
// For the now, we use 'A' APIs (see bug 240272, 239279) // For the now, we use 'A' APIs (see bug 240272, 239279)
NS_UTF16ToCString(optionsTitle, NS_CSTRING_ENCODING_NATIVE_FILESYSTEM, NS_CopyUnicodeToNative(optionsTitle, nativeTitle);
nativeTitle);
SetRegKey(optionsKey.get(), "", nativeTitle.get(), aClaimAllTypes, SetRegKey(optionsKey.get(), "", nativeTitle.get(), aClaimAllTypes,
aForAllUsers); aForAllUsers);
// For the now, we use 'A' APIs (see bug 240272, 239279) // For the now, we use 'A' APIs (see bug 240272, 239279)
NS_UTF16ToCString(safeModeTitle, NS_CSTRING_ENCODING_NATIVE_FILESYSTEM, NS_CopyUnicodeToNative(safeModeTitle, nativeTitle);
nativeTitle);
SetRegKey(safeModeKey.get(), "", nativeTitle.get(), aClaimAllTypes, SetRegKey(safeModeKey.get(), "", nativeTitle.get(), aClaimAllTypes,
aForAllUsers); aForAllUsers);
@ -781,7 +778,7 @@ nsWindowsShellService::SetDesktopBackground(nsIDOMElement* aElement,
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
// e.g. "Desktop Background.bmp" // e.g. "Desktop Background.bmp"
nsString fileLeafName; nsXPIDLString fileLeafName;
rv = shellBundle->GetStringFromName rv = shellBundle->GetStringFromName
(NS_LITERAL_STRING("desktopBackgroundLeafNameWin").get(), (NS_LITERAL_STRING("desktopBackgroundLeafNameWin").get(),
getter_Copies(fileLeafName)); getter_Copies(fileLeafName));
@ -1057,7 +1054,7 @@ nsWindowsShellService::OpenApplicationWithURI(nsILocalFile* aApplication, const
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return rv;
const nsCString spec(aURI); const nsPromiseFlatCString& spec = PromiseFlatCString(aURI);
const char* specStr = spec.get(); const char* specStr = spec.get();
PRUint32 pid; PRUint32 pid;
return process->Run(PR_FALSE, &specStr, 1, &pid); return process->Run(PR_FALSE, &specStr, 1, &pid);

View File

@ -211,8 +211,6 @@ bin/components/nsSessionStore.js
bin/components/sessionstore.xpt bin/components/sessionstore.xpt
bin/components/nsURLFormatter.js bin/components/nsURLFormatter.js
bin/components/urlformatter.xpt bin/components/urlformatter.xpt
bin/components/libbrowserdirprovider.so
bin/components/libbrowsercomps.so
; Safe Browsing ; Safe Browsing
bin/components/nsSafebrowsingApplication.js bin/components/nsSafebrowsingApplication.js

View File

@ -220,8 +220,6 @@ bin\components\nsSessionStore.js
bin\components\sessionstore.xpt bin\components\sessionstore.xpt
bin\components\nsURLFormatter.js bin\components\nsURLFormatter.js
bin\components\urlformatter.xpt bin\components\urlformatter.xpt
bin\components\browserdirprovider.dll
bin\components\brwsrcmp.dll
; Safe Browsing ; Safe Browsing
bin\components\nsSafebrowsingApplication.js bin\components\nsSafebrowsingApplication.js

View File

@ -284,18 +284,11 @@ ifneq (,$(FORCE_SHARED_LIB)$(FORCE_USE_PIC))
_ENABLE_PIC=1 _ENABLE_PIC=1
endif endif
# In Firefox, all components are linked into either libxul or the static
# meta-component, and should be compiled with PIC.
ifdef MOZ_META_COMPONENT
_ENABLE_PIC=1
endif
# If module is going to be merged into the nsStaticModule, # If module is going to be merged into the nsStaticModule,
# make sure that the entry points are translated and # make sure that the entry points are translated and
# the module is built static. # the module is built static.
ifdef IS_COMPONENT ifdef IS_COMPONENT
ifdef EXPORT_LIBRARY
ifneq (,$(BUILD_STATIC_LIBS)) ifneq (,$(BUILD_STATIC_LIBS))
ifdef MODULE_NAME ifdef MODULE_NAME
DEFINES += -DXPCOM_TRANSLATE_NSGM_ENTRY_POINT=1 DEFINES += -DXPCOM_TRANSLATE_NSGM_ENTRY_POINT=1
@ -303,7 +296,6 @@ FORCE_STATIC_LIB=1
endif endif
endif endif
endif endif
endif
# Determine if module being compiled is destined # Determine if module being compiled is destined
# to be merged into libxul # to be merged into libxul

View File

@ -347,11 +347,11 @@ endif
LOOP_OVER_DIRS = \ LOOP_OVER_DIRS = \
@$(EXIT_ON_ERROR) \ @$(EXIT_ON_ERROR) \
$(foreach dir,$(DIRS),$(UPDATE_TITLE) $(MAKE) -C $(dir) $@; ) true $(foreach dir,$(DIRS),$(UPDATE_TITLE) $(MAKE) -C $(dir) $@; )
LOOP_OVER_TOOL_DIRS = \ LOOP_OVER_TOOL_DIRS = \
@$(EXIT_ON_ERROR) \ @$(EXIT_ON_ERROR) \
$(foreach dir,$(TOOL_DIRS),$(UPDATE_TITLE) $(MAKE) -C $(dir) $@; ) true $(foreach dir,$(TOOL_DIRS),$(UPDATE_TITLE) $(MAKE) -C $(dir) $@; )
# #
# Now we can differentiate between objects used to build a library, and # Now we can differentiate between objects used to build a library, and
@ -571,13 +571,13 @@ STATIC_DIRS += $(foreach tier,$(TIERS),$(tier_$(tier)_staticdirs))
default all alldep:: default all alldep::
$(EXIT_ON_ERROR) \ $(EXIT_ON_ERROR) \
$(foreach tier,$(TIERS),$(MAKE) tier_$(tier); ) true $(foreach tier,$(TIERS),$(MAKE) tier_$(tier); )
else else
default all:: default all::
@$(EXIT_ON_ERROR) \ @$(EXIT_ON_ERROR) \
$(foreach dir,$(STATIC_DIRS),$(MAKE) -C $(dir); ) true $(foreach dir,$(STATIC_DIRS),$(MAKE) -C $(dir); )
$(MAKE) export $(MAKE) export
$(MAKE) libs $(MAKE) libs
$(MAKE) tools $(MAKE) tools
@ -598,24 +598,24 @@ export_tier_%:
@echo "$@" @echo "$@"
@$(MAKE_TIER_SUBMAKEFILES) @$(MAKE_TIER_SUBMAKEFILES)
@$(EXIT_ON_ERROR) \ @$(EXIT_ON_ERROR) \
$(foreach dir,$(tier_$*_dirs),$(MAKE) -C $(dir) export; ) true $(foreach dir,$(tier_$*_dirs),$(MAKE) -C $(dir) export; )
libs_tier_%: libs_tier_%:
@echo "$@" @echo "$@"
@$(MAKE_TIER_SUBMAKEFILES) @$(MAKE_TIER_SUBMAKEFILES)
@$(EXIT_ON_ERROR) \ @$(EXIT_ON_ERROR) \
$(foreach dir,$(tier_$*_dirs),$(MAKE) -C $(dir) libs; ) true $(foreach dir,$(tier_$*_dirs),$(MAKE) -C $(dir) libs; )
tools_tier_%: tools_tier_%:
@echo "$@" @echo "$@"
@$(MAKE_TIER_SUBMAKEFILES) @$(MAKE_TIER_SUBMAKEFILES)
@$(EXIT_ON_ERROR) \ @$(EXIT_ON_ERROR) \
$(foreach dir,$(tier_$*_dirs),$(MAKE) -C $(dir) tools; ) true $(foreach dir,$(tier_$*_dirs),$(MAKE) -C $(dir) tools; )
$(foreach tier,$(TIERS),tier_$(tier)):: $(foreach tier,$(TIERS),tier_$(tier))::
@echo "$@: $($@_staticdirs) $($@_dirs)" @echo "$@: $($@_staticdirs) $($@_dirs)"
@$(EXIT_ON_ERROR) \ @$(EXIT_ON_ERROR) \
$(foreach dir,$($@_staticdirs),$(MAKE) -C $(dir); ) true $(foreach dir,$($@_staticdirs),$(MAKE) -C $(dir); )
$(MAKE) export_$@ $(MAKE) export_$@
$(MAKE) libs_$@ $(MAKE) libs_$@
@ -658,7 +658,7 @@ tools:: $(SUBMAKEFILES) $(MAKE_DIRS)
+$(LOOP_OVER_DIRS) +$(LOOP_OVER_DIRS)
ifdef TOOL_DIRS ifdef TOOL_DIRS
@$(EXIT_ON_ERROR) \ @$(EXIT_ON_ERROR) \
$(foreach dir,$(TOOL_DIRS),$(UPDATE_TITLE) $(MAKE) -C $(dir) libs; ) true $(foreach dir,$(TOOL_DIRS),$(UPDATE_TITLE) $(MAKE) -C $(dir) libs; )
endif endif
# #

View File

@ -46,7 +46,7 @@
#define NS_SIDE_BOTTOM 2 #define NS_SIDE_BOTTOM 2
#define NS_SIDE_LEFT 3 #define NS_SIDE_LEFT 3
#if defined(MOZ_ENABLE_LIBXUL) || !defined(MOZILLA_INTERNAL_API) #ifdef MOZ_ENABLE_LIBXUL
# define NS_GFX # define NS_GFX
# define NS_GFX_(type) type # define NS_GFX_(type) type
# define NS_GFX_STATIC_MEMBER_(type) type # define NS_GFX_STATIC_MEMBER_(type) type

View File

@ -39,7 +39,7 @@
#define nsICharsetAlias_h___ #define nsICharsetAlias_h___
#include "nscore.h" #include "nscore.h"
#include "nsStringGlue.h" #include "nsString.h"
#include "nsISupports.h" #include "nsISupports.h"
/* 0b4028d6-7473-4958-9b3c-4dee46bf68cb */ /* 0b4028d6-7473-4958-9b3c-4dee46bf68cb */

View File

@ -38,7 +38,7 @@
#ifndef nsIPlatformCharset_h__ #ifndef nsIPlatformCharset_h__
#define nsIPlatformCharset_h__ #define nsIPlatformCharset_h__
#include "nsStringGlue.h" #include "nsString.h"
#include "nsISupports.h" #include "nsISupports.h"
// Interface ID for our nsIPlatformCharset interface // Interface ID for our nsIPlatformCharset interface

View File

@ -342,7 +342,7 @@ static PRBool ns_strnimatch(const PRUnichar *aStr, const char* aSubstring,
if (!NS_IsAscii(*aStr)) if (!NS_IsAscii(*aStr))
return PR_FALSE; return PR_FALSE;
if (NS_ToLower((char) *aStr) != NS_ToLower(*aSubstring)) if (NS_ToLower((char) *aStr) != *aSubstring)
return PR_FALSE; return PR_FALSE;
} }
@ -350,7 +350,7 @@ static PRBool ns_strnimatch(const PRUnichar *aStr, const char* aSubstring,
} }
PRInt32 PRInt32
nsAString::Find(const char *aStr, PRUint32 aOffset, PRBool aIgnoreCase) const nsAString::Find(const char *aStr, PRBool aIgnoreCase) const
{ {
PRBool (*match)(const PRUnichar*, const char*, PRUint32) = PRBool (*match)(const PRUnichar*, const char*, PRUint32) =
aIgnoreCase ? ns_strnimatch : ns_strnmatch; aIgnoreCase ? ns_strnimatch : ns_strnmatch;
@ -358,9 +358,6 @@ nsAString::Find(const char *aStr, PRUint32 aOffset, PRBool aIgnoreCase) const
const char_type *begin, *end; const char_type *begin, *end;
PRUint32 selflen = BeginReading(&begin, &end); PRUint32 selflen = BeginReading(&begin, &end);
if (aOffset > selflen)
return -1;
PRUint32 otherlen = strlen(aStr); PRUint32 otherlen = strlen(aStr);
if (otherlen > selflen) if (otherlen > selflen)
@ -369,7 +366,7 @@ nsAString::Find(const char *aStr, PRUint32 aOffset, PRBool aIgnoreCase) const
// We want to stop searching otherlen characters before the end of the string // We want to stop searching otherlen characters before the end of the string
end -= otherlen; end -= otherlen;
for (const char_type *cur = begin + aOffset; cur <= end; ++cur) { for (const char_type *cur = begin; cur <= end; ++cur) {
if (match(cur, aStr, otherlen)) { if (match(cur, aStr, otherlen)) {
return cur - begin; return cur - begin;
} }
@ -685,7 +682,7 @@ nsACString::Find(const char_type *aStr, PRUint32 aLen, ComparatorFunc c) const
end -= aLen; end -= aLen;
for (const char_type *cur = begin; cur <= end; ++cur) { for (const char_type *cur = begin; cur <= end; ++cur) {
if (!c(cur, aStr, aLen)) if (!c(begin, aStr, aLen))
return cur - begin; return cur - begin;
} }
return -1; return -1;

View File

@ -229,10 +229,7 @@ public:
* *
* @return the offset of aStr, or -1 if not found. * @return the offset of aStr, or -1 if not found.
*/ */
NS_HIDDEN_(PRInt32) Find(const char *aStr, PRBool aIgnoreCase = PR_FALSE) const NS_HIDDEN_(PRInt32) Find(const char *aStr, PRBool aIgnoreCase = PR_FALSE) const;
{ return Find(aStr, 0, aIgnoreCase); }
NS_HIDDEN_(PRInt32) Find(const char *aStr, PRUint32 aOffset, PRBool aIgnoreCase = PR_FALSE) const;
/** /**
* Search for the offset of the first occurrence of a character in a * Search for the offset of the first occurrence of a character in a