Bug 345517, try #2, make the browser component use frozen linkage, so that ff+xr builds. This does *not* --enable-libxul by default for Firefox (yet). That will wait until after 1.9a1. Older patch r=darin+mento, revisions r=mano

This commit is contained in:
benjamin@smedbergs.us
2006-11-09 15:02:29 +00:00
parent 5c537d0521
commit 84c6af09b6
51 changed files with 565 additions and 465 deletions

View File

@@ -44,7 +44,8 @@ include $(DEPTH)/config/autoconf.mk
MODULE = bookmarks MODULE = bookmarks
LIBRARY_NAME = bookmarks_s LIBRARY_NAME = bookmarks_s
MOZILLA_INTERNAL_API = 1 FORCE_STATIC_LIB = 1
FORCE_USE_PIC = 1
REQUIRES = xpcom \ REQUIRES = xpcom \
string \ string \
@@ -76,9 +77,5 @@ 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,8 +392,12 @@ 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<nsIInputStream> stream; nsCOMPtr<nsIStringInputStream> stream =
rv = NS_NewCStringInputStream(getter_AddRefs(stream), mBody); do_CreateInstance("@mozilla.org/io/string-input-stream;1");
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;
@@ -853,9 +857,9 @@ nsFeedLoadListener::TryParseAsSimpleRSS ()
} }
// Clean up whitespace // Clean up whitespace
titleStr.CompressWhitespace(); CompressWhitespace(titleStr);
linkStr.Trim("\b\t\r\n "); linkStr.Trim("\b\t\r\n ");
dateStr.CompressWhitespace(); CompressWhitespace(dateStr);
if (titleStr.IsEmpty() && !dateStr.IsEmpty()) if (titleStr.IsEmpty() && !dateStr.IsEmpty())
titleStr.Assign(dateStr); titleStr.Assign(dateStr);

View File

@@ -66,11 +66,10 @@
#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"
@@ -94,6 +93,13 @@
#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;
@@ -631,6 +637,8 @@ 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=\"";
@@ -857,7 +865,7 @@ BookmarkParser::DecodeBuffer(nsString &line, char *buf, PRUint32 aLength)
} }
else else
{ {
line.AppendWithConversion(buf, aLength); line.Append(NS_ConvertASCIItoUTF16(buf, aLength));
} }
return NS_OK; return NS_OK;
} }
@@ -922,7 +930,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 &&
nsCRT::IsAsciiDigit(line.CharAt(offset + 2))) NS_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'))
@@ -1056,27 +1064,27 @@ BookmarkParser::Unescape(nsString &text)
while((offset = text.FindChar((PRUnichar('&')), offset)) >= 0) while((offset = text.FindChar((PRUnichar('&')), offset)) >= 0)
{ {
if (Substring(text, offset, 4).Equals(NS_LITERAL_STRING("&lt;"), nsCaseInsensitiveStringComparator())) if (Substring(text, offset, 4).LowerCaseEqualsLiteral("&lt;"))
{ {
text.Cut(offset, 4); text.Cut(offset, 4);
text.Insert(PRUnichar('<'), offset); text.Insert(PRUnichar('<'), offset);
} }
else if (Substring(text, offset, 4).Equals(NS_LITERAL_STRING("&gt;"), nsCaseInsensitiveStringComparator())) else if (Substring(text, offset, 4).LowerCaseEqualsLiteral("&gt;"))
{ {
text.Cut(offset, 4); text.Cut(offset, 4);
text.Insert(PRUnichar('>'), offset); text.Insert(PRUnichar('>'), offset);
} }
else if (Substring(text, offset, 5).Equals(NS_LITERAL_STRING("&amp;"), nsCaseInsensitiveStringComparator())) else if (Substring(text, offset, 5).LowerCaseEqualsLiteral("&amp;"))
{ {
text.Cut(offset, 5); text.Cut(offset, 5);
text.Insert(PRUnichar('&'), offset); text.Insert(PRUnichar('&'), offset);
} }
else if (Substring(text, offset, 6).Equals(NS_LITERAL_STRING("&quot;"), nsCaseInsensitiveStringComparator())) else if (Substring(text, offset, 6).LowerCaseEqualsLiteral("&quot;"))
{ {
text.Cut(offset, 6); text.Cut(offset, 6);
text.Insert(PRUnichar('\"'), offset); text.Insert(PRUnichar('\"'), offset);
} }
else if (Substring(text, offset, 5).Equals(NS_LITERAL_STRING("&#39;"))) else if (Substring(text, offset, 5).LowerCaseEqualsLiteral("&#39;"))
{ {
text.Cut(offset, 5); text.Cut(offset, 5);
text.Insert(PRUnichar('\''), offset); text.Insert(PRUnichar('\''), offset);
@@ -1102,11 +1110,10 @@ 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; nsAutoString httpEquiv(Substring(aLine, start, end - start));
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.EqualsIgnoreCase("Content-Type")) if (!httpEquiv.LowerCaseEqualsLiteral("content-type"))
return NS_OK; return NS_OK;
// get the CONTENT attribute // get the CONTENT attribute
@@ -1117,16 +1124,15 @@ 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; nsAutoString content(Substring(aLine, start, end - start));
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);
nsCAutoString charset; NS_LossyConvertUTF16toASCII charset(Substring(content, start,
charset.AssignWithConversion(Substring(content, start, content.Length() - 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
@@ -1199,13 +1205,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, PR_TRUE, attrStart); attrStart = aLine.Find(kOpenAnchor, attrStart, PR_TRUE);
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, PR_TRUE, attrStart); attrStart = aLine.Find(kOpenHeading, attrStart, PR_TRUE);
if (attrStart < 0) return NS_ERROR_UNEXPECTED; if (attrStart < 0) return NS_ERROR_UNEXPECTED;
attrStart += sizeof(kOpenHeading)-1; attrStart += sizeof(kOpenHeading)-1;
} }
@@ -1219,16 +1225,14 @@ BookmarkParser::ParseBookmarkInfo(BookmarkField *fields, PRBool isBookmarkFlag,
// loop over attributes // loop over attributes
while((attrStart < lineLen) && (aLine[attrStart] != '>')) while((attrStart < lineLen) && (aLine[attrStart] != '>'))
{ {
while(nsCRT::IsAsciiSpace(aLine[attrStart])) ++attrStart; while(NS_IsAsciiWhitespace(aLine[attrStart])) ++attrStart;
PRBool fieldFound = PR_FALSE; PRBool fieldFound = PR_FALSE;
nsAutoString id; NS_ConvertASCIItoUTF16 id(kIDEquals);
id.AssignWithConversion(kIDEquals);
for (BookmarkField *field = fields; field->mName; ++field) for (BookmarkField *field = fields; field->mName; ++field)
{ {
nsAutoString name; NS_ConvertASCIItoUTF16 name(field->mName);
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
@@ -1241,7 +1245,8 @@ 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 (aLine.Find(field->mName, PR_TRUE, attrStart, 1) == attrStart) if (Substring(aLine, attrStart, name.Length()).
Equals(name, CaseInsensitiveCompare))
{ {
attrStart += strlen(field->mName); attrStart += strlen(field->mName);
@@ -1250,8 +1255,8 @@ BookmarkParser::ParseBookmarkInfo(BookmarkField *fields, PRBool isBookmarkFlag,
if (termQuote > attrStart) if (termQuote > attrStart)
{ {
// process data // process data
nsAutoString data; nsAutoString data(Substring(aLine, attrStart,
aLine.Mid(data, attrStart, termQuote-attrStart); termQuote-attrStart));
attrStart = termQuote + 1; attrStart = termQuote + 1;
fieldFound = PR_TRUE; fieldFound = PR_TRUE;
@@ -1281,7 +1286,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] != '>') &&
(!nsCRT::IsAsciiSpace(aLine[attrStart]))) (!NS_IsAsciiWhitespace(aLine[attrStart])))
{ {
++attrStart; ++attrStart;
} }
@@ -1317,7 +1322,7 @@ BookmarkParser::ParseBookmarkInfo(BookmarkField *fields, PRBool isBookmarkFlag,
PRBool isIEFavoriteRoot = PR_FALSE; PRBool isIEFavoriteRoot = PR_FALSE;
if (!mIEFavoritesRoot.IsEmpty()) if (!mIEFavoritesRoot.IsEmpty())
{ {
if (!nsCRT::strcmp(mIEFavoritesRoot.get(), bookmarkURI)) if (!strcmp(mIEFavoritesRoot.get(), bookmarkURI))
{ {
mFoundIEFavoritesRoot = PR_TRUE; mFoundIEFavoritesRoot = PR_TRUE;
isIEFavoriteRoot = PR_TRUE; isIEFavoriteRoot = PR_TRUE;
@@ -1364,8 +1369,8 @@ BookmarkParser::ParseBookmarkInfo(BookmarkField *fields, PRBool isBookmarkFlag,
if (nameEnd > attrStart) if (nameEnd > attrStart)
{ {
nsAutoString name; nsAutoString name(Substring(aLine, attrStart,
aLine.Mid(name, attrStart, nameEnd-attrStart); nameEnd-attrStart));
if (!name.IsEmpty()) if (!name.IsEmpty())
{ {
Unescape(name); Unescape(name);
@@ -1440,8 +1445,7 @@ 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.SetCharAt('\"',offset); url.Replace(offset, sizeof(kEscape22) - 1, '\"');
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
@@ -1453,7 +1457,8 @@ 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.Assign(NS_LITERAL_STRING("http://") + url); url.AssignLiteral("http://");
url.Append(url);
} }
} }
@@ -1478,9 +1483,9 @@ BookmarkParser::ParseLiteral(nsIRDFResource *arc, nsString& aValue, nsIRDFNode**
{ {
if (gCharsetAlias) if (gCharsetAlias)
{ {
nsCAutoString charset; charset.AssignWithConversion(aValue); NS_LossyConvertUTF16toASCII charset(aValue);
gCharsetAlias->GetPreferred(charset, charset); gCharsetAlias->GetPreferred(charset, charset);
aValue.AssignWithConversion(charset.get()); CopyASCIItoUTF16(charset, aValue);
} }
} }
else if (arc == kWEB_LastPingETag) else if (arc == kWEB_LastPingETag)
@@ -1503,13 +1508,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())
{ {
PRInt32 err; theDate = aValue.ToInteger(&rv); // ignored.
theDate = aValue.ToInteger(&err); // ignored.
} }
if (theDate == 0) return NS_RDF_NO_VALUE; if (theDate == 0) return NS_RDF_NO_VALUE;
@@ -1519,7 +1524,6 @@ 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))))
{ {
@@ -1581,17 +1585,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(nsCRT::IsAsciiSpace(aLine[attrStart])) while(NS_IsAsciiWhitespace(aLine[attrStart]))
++attrStart; ++attrStart;
if (aLine.Find(kNameEquals, PR_TRUE, attrStart, 1) == attrStart) { if (Substring(aLine, attrStart, sizeof(kNameEqualsLC) - 1).LowerCaseEqualsLiteral(kNameEqualsLC)) {
attrStart += sizeof(kNameEquals) - 1; attrStart += sizeof(kNameEqualsLC) - 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; nsAutoString name(Substring(aLine, attrStart,
aLine.Mid(name, attrStart, termQuote - attrStart); termQuote - attrStart));
attrStart = termQuote + 1; attrStart = termQuote + 1;
if (!name.IsEmpty()) { if (!name.IsEmpty()) {
nsCOMPtr<nsIRDFLiteral> nameLiteral; nsCOMPtr<nsIRDFLiteral> nameLiteral;
@@ -1777,8 +1781,7 @@ nsresult
nsBookmarksService::getLocaleString(const char *key, nsString &str) nsBookmarksService::getLocaleString(const char *key, nsString &str)
{ {
PRUnichar *keyUni = nsnull; PRUnichar *keyUni = nsnull;
nsAutoString keyStr; NS_ConvertASCIItoUTF16 keyStr(key);
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)))
@@ -1845,16 +1848,14 @@ nsBookmarksService::ExamineBookmarkSchedule(nsIRDFResource *theBookmark, PRBool
PRInt32 slashOffset; PRInt32 slashOffset;
if ((slashOffset = schedule.FindChar(PRUnichar('|'))) >= 0) if ((slashOffset = schedule.FindChar(PRUnichar('|'))) >= 0)
{ {
nsAutoString daySection; nsAutoString daySection(StringTail(schedule, slashOffset));
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; nsAutoString hourRange(StringTail(schedule, slashOffset));
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
@@ -1862,29 +1863,26 @@ nsBookmarksService::ExamineBookmarkSchedule(nsIRDFResource *theBookmark, PRBool
PRInt32 dashOffset; PRInt32 dashOffset;
if ((dashOffset = hourRange.FindChar(PRUnichar('-'))) >= 1) if ((dashOffset = hourRange.FindChar(PRUnichar('-'))) >= 1)
{ {
nsAutoString startStr, endStr; nsAutoString endStr(StringTail(hourRange,
hourRange.Length() - dashOffset - 1));
nsAutoString startStr(StringHead(hourRange, dashOffset));
hourRange.Right(endStr, hourRange.Length() - dashOffset - 1); nsresult rv2;
hourRange.Left(startStr, dashOffset); startHour = startStr.ToInteger(&rv2);
if (NS_FAILED(rv2)) startHour = -1;
PRInt32 errorCode2 = 0; endHour = endStr.ToInteger(&rv2);
startHour = startStr.ToInteger(&errorCode2); if (NS_FAILED(rv2)) endHour = -1;
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; nsAutoString durationStr(StringHead(schedule, slashOffset));
schedule.Left(durationStr, slashOffset);
schedule.Cut(0, slashOffset+1); schedule.Cut(0, slashOffset+1);
// get duration // get duration
PRInt32 errorCode = 0; duration = durationStr.ToInteger(&rv2);
duration = durationStr.ToInteger(&errorCode); if (NS_FAILED(rv2)) duration = -1;
if (errorCode) duration = -1;
// what's left is the notification options // what's left is the notification options
notificationMethod = schedule; notificationMethod = schedule;
@@ -2169,7 +2167,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),
nsCaseInsensitiveStringComparator())) CaseInsensitiveCompare))
{ {
changedFlag = PR_TRUE; changedFlag = PR_TRUE;
} }
@@ -2215,7 +2213,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),
nsCaseInsensitiveStringComparator())) CaseInsensitiveCompare))
{ {
changedFlag = PR_TRUE; changedFlag = PR_TRUE;
} }
@@ -2259,7 +2257,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),
nsCaseInsensitiveStringComparator())) CaseInsensitiveCompare))
{ {
changedFlag = PR_TRUE; changedFlag = PR_TRUE;
} }
@@ -2335,9 +2333,7 @@ nsBookmarksService::OnStopRequest(nsIRequest* request, nsISupports *ctxt,
} }
// update icon? // update icon?
if (FindInReadable(NS_LITERAL_STRING("icon"), if (schedule.Find("icon", PR_TRUE) != -1)
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))))
@@ -2357,9 +2353,7 @@ nsBookmarksService::OnStopRequest(nsIRequest* request, nsISupports *ctxt,
} }
// play a sound? // play a sound?
if (FindInReadable(NS_LITERAL_STRING("sound"), if (schedule.Find("sound", PR_TRUE))
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))
@@ -2372,9 +2366,7 @@ nsBookmarksService::OnStopRequest(nsIRequest* request, nsISupports *ctxt,
PRBool openURLFlag = PR_FALSE; PRBool openURLFlag = PR_FALSE;
// show an alert? // show an alert?
if (FindInReadable(NS_LITERAL_STRING("alert"), if (schedule.Find("alert", PR_TRUE))
schedule,
nsCaseInsensitiveStringComparator()))
{ {
nsCOMPtr<nsIPrompt> prompter; nsCOMPtr<nsIPrompt> prompter;
NS_QueryNotificationCallbacks(channel, prompter); NS_QueryNotificationCallbacks(channel, prompter);
@@ -2447,9 +2439,7 @@ 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) ||
FindInReadable(NS_LITERAL_STRING("open"), schedule.Find("open", PR_TRUE))
schedule,
nsCaseInsensitiveStringComparator()))
{ {
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
{ {
@@ -2493,12 +2483,12 @@ NS_IMETHODIMP nsBookmarksService::Observe(nsISupports *aSubject, const char *aTo
{ {
nsresult rv = NS_OK; nsresult rv = NS_OK;
if (!nsCRT::strcmp(aTopic, "profile-before-change")) if (!strcmp(aTopic, "profile-before-change"))
{ {
// The profile has not changed yet. // The profile has not changed yet.
rv = Flush(); rv = Flush();
if (!nsCRT::strcmp(someData, NS_LITERAL_STRING("shutdown-cleanse").get())) if (!NS_strcmp(someData, NS_LITERAL_STRING("shutdown-cleanse").get()))
{ {
nsCOMPtr<nsIFile> bookmarksFile; nsCOMPtr<nsIFile> bookmarksFile;
@@ -2510,13 +2500,13 @@ NS_IMETHODIMP nsBookmarksService::Observe(nsISupports *aSubject, const char *aTo
} }
} }
} }
else if (!nsCRT::strcmp(aTopic, "profile-after-change")) else if (!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 (!nsCRT::strcmp(aTopic, "quit-application")) else if (!strcmp(aTopic, "quit-application"))
{ {
rv = Flush(); rv = Flush();
} }
@@ -3491,7 +3481,7 @@ nsBookmarksService::RequestCharset(nsIWebNavigation* aWebNavigation,
if (charsetLiteral) { if (charsetLiteral) {
const PRUnichar *charset; const PRUnichar *charset;
charsetLiteral->GetValueConst(&charset); charsetLiteral->GetValueConst(&charset);
LossyCopyUTF16toASCII(charset, aResult); LossyCopyUTF16toASCII(nsDependentString(charset), aResult);
return NS_OK; return NS_OK;
} }
@@ -3704,7 +3694,7 @@ nsBookmarksService::GetLastModifiedFolders(nsISimpleEnumerator **aResult)
NS_IMETHODIMP NS_IMETHODIMP
nsBookmarksService::GetURI(char* *aURI) nsBookmarksService::GetURI(char* *aURI)
{ {
*aURI = nsCRT::strdup("rdf:bookmarks"); *aURI = NS_strdup("rdf:bookmarks");
if (! *aURI) if (! *aURI)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@@ -4277,7 +4267,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, nsCaseInsensitiveStringComparator())) if (format && NS_LITERAL_STRING("RDF").Equals(format, CaseInsensitiveCompare))
{ {
nsCOMPtr<nsIURI> uri; nsCOMPtr<nsIURI> uri;
nsresult rv = NS_NewFileURI(getter_AddRefs(uri), file); nsresult rv = NS_NewFileURI(getter_AddRefs(uri), file);
@@ -4636,13 +4626,13 @@ nsBookmarksService::InitDataSource()
// create livemark bookmarks // create livemark bookmarks
{ {
nsXPIDLString lmloadingName; nsString 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..."));
} }
nsXPIDLString lmfailedName; nsString 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."));
@@ -4815,7 +4805,7 @@ nsBookmarksService::LoadBookmarks()
} }
// Sets the default bookmarks root name. // Sets the default bookmarks root name.
nsXPIDLString brName; nsString 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
@@ -5150,6 +5140,53 @@ 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)
@@ -5160,19 +5197,15 @@ nsBookmarksService::WriteBookmarkIdAndName(nsIRDFDataSource *aDs,
// output ID // output ID
// <A ... ID="rdf:#$Rd48+1">Name</A> // <A ... ID="rdf:#$Rd48+1">Name</A>
// ^^^^^^^^^^^^^^^^^^ // ^^^^^^^^^^^^^^^^^^
const char *id = nsnull; nsCString id;
rv = aChild->GetValueConst(&id); rv = aChild->GetValueUTF8(id);
if (NS_SUCCEEDED(rv) && (id)) if (NS_SUCCEEDED(rv))
{ {
char *escapedID = nsEscapeHTML(id); EscapeHTML(id);
if (escapedID) rv |= aStrm->Write(kSpaceStr, sizeof(kSpaceStr)-1, &dummy);
{ rv |= aStrm->Write(kIDEquals, sizeof(kIDEquals)-1, &dummy);
rv |= aStrm->Write(kSpaceStr, sizeof(kSpaceStr)-1, &dummy); rv |= aStrm->Write(id.get(), id.Length(), &dummy);
rv |= aStrm->Write(kIDEquals, sizeof(kIDEquals)-1, &dummy); rv |= aStrm->Write(kQuoteStr, sizeof(kQuoteStr)-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>
@@ -5199,12 +5232,8 @@ nsBookmarksService::WriteBookmarkIdAndName(nsIRDFDataSource *aDs,
return NS_OK; return NS_OK;
// see bug #65098 // see bug #65098
char *escapedAttrib = nsEscapeHTML(name.get()); EscapeHTML(name);
if (escapedAttrib) rv = aStrm->Write(name.get(), name.Length(), &dummy);
{
rv = aStrm->Write(escapedAttrib, strlen(escapedAttrib), &dummy);
NS_Free(escapedAttrib);
}
return rv; return rv;
} }
@@ -5232,48 +5261,38 @@ nsBookmarksService::WriteBookmarkProperties(nsIRDFDataSource *aDs,
} }
} }
char *attribute = ToNewUTF8String(literalString); NS_ConvertUTF16toUTF8 attribute(literalString);
if (nsnull != attribute) if (aIsFirst == PR_FALSE)
{ {
if (aIsFirst == PR_FALSE) rv |= aStrm->Write(kSpaceStr, sizeof(kSpaceStr)-1, &dummy);
{ }
rv |= aStrm->Write(kSpaceStr, sizeof(kSpaceStr)-1, &dummy);
}
if (!literalString.IsEmpty()) 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)
{ {
// 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 rv |= aStrm->Write(kQuoteStr, sizeof(kQuoteStr)-1, &dummy);
// back to a build from before we started escaping. }
if (aProperty == kNC_URL || aProperty == kNC_FeedURL) else
{
EscapeHTML(attribute);
rv |= aStrm->Write(aHtmlAttrib, strlen(aHtmlAttrib), &dummy);
rv |= aStrm->Write(attribute.get(), attribute.Length(), &dummy);
if (aProperty == kNC_Description)
{ {
rv |= aStrm->Write(aHtmlAttrib, strlen(aHtmlAttrib), &dummy); rv |= aStrm->Write(kNL, sizeof(kNL)-1, &dummy);
rv |= aStrm->Write(attribute, strlen(attribute), &dummy);
rv |= aStrm->Write(kQuoteStr, sizeof(kQuoteStr)-1, &dummy);
} }
else else
{ {
char *escapedAttrib = nsEscapeHTML(attribute); rv |= aStrm->Write(kQuoteStr, sizeof(kQuoteStr)-1, &dummy);
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;
} }
} }
} }
@@ -5344,7 +5363,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))
{ {
aResult.AssignWithConversion(p); CopyASCIItoUTF16(nsDependentCString(p), aResult);
} }
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 "nsString.h" #include "nsStringAPI.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;
nsXPIDLString mPersonalToolbarName; nsString mPersonalToolbarName;
PRBool mBookmarksAvailable; PRBool mBookmarksAvailable;
PRBool mDirty; PRBool mDirty;
PRBool mBrowserIcons; PRBool mBrowserIcons;

View File

@@ -45,25 +45,22 @@
#include "nsIRDFObserver.h" #include "nsIRDFObserver.h"
#include "nsIRDFService.h" #include "nsIRDFService.h"
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
#include "nsXPIDLString.h" #include "nsServiceManagerUtils.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(kRDFServiceCID); nsCOMPtr<nsIRDFService> rdf = do_GetService("@mozilla.org/rdf/rdf-service;1");
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;
@@ -207,7 +204,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"));
nsXPIDLCString dsURI; nsCString 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;
@@ -216,9 +213,9 @@ nsForwardProxyDataSource::GetURI(char* *uri)
theURI += dsURI; theURI += dsURI;
} }
if ((*uri = nsCRT::strdup(theURI.get())) == nsnull) { *uri = ToNewCString(theURI);
if (*uri == nsnull)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
}
return NS_OK; return NS_OK;
} }

View File

@@ -8,10 +8,9 @@ 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
MOZILLA_INTERNAL_API = 1 FORCE_SHARED_LIB = 1
REQUIRES = \ REQUIRES = \
docshell \ docshell \
@@ -75,17 +74,12 @@ 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 += \
$(LIBS_DIR) \ $(call EXPAND_LIBNAME_PATH,unicharutil_external_s,$(LIBXUL_DIST)/lib) \
$(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,8 +49,7 @@ SHORT_LIBNAME = brwsrdir
endif endif
IS_COMPONENT = 1 IS_COMPONENT = 1
MODULE_NAME = BrowserDirProvider MODULE_NAME = BrowserDirProvider
EXPORT_LIBRARY = 1 FORCE_SHARED_LIB = 1
MOZILLA_INTERNAL_API = 1
REQUIRES = \ REQUIRES = \
xpcom \ xpcom \
@@ -61,6 +60,9 @@ REQUIRES = \
CPPSRCS = nsBrowserDirectoryProvider.cpp CPPSRCS = nsBrowserDirectoryProvider.cpp
EXTRA_DSO_LDOPTS = $(MOZ_COMPONENT_LIBS) EXTRA_DSO_LDOPTS = \
$(XPCOM_GLUE_LDOPTS) \
$(NSPR_LIBS) \
$(NULL)
include $(topsrcdir)/config/rules.mk include $(topsrcdir)/config/rules.mk

View File

@@ -48,9 +48,12 @@
#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 "nsString.h" #include "nsServiceManagerUtils.h"
#include "nsStringAPI.h"
#include "nsXULAppAPI.h" #include "nsXULAppAPI.h"
class nsBrowserDirectoryProvider : class nsBrowserDirectoryProvider :
@@ -118,7 +121,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) {
nsXPIDLCString path; nsCString 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,6 +43,8 @@ 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 \
@@ -56,8 +58,4 @@ 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,13 +43,14 @@
#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"
@@ -98,9 +99,12 @@ nsFeedSniffer::ConvertEncodedData(nsIRequest* request,
converter->OnStartRequest(request, nsnull); converter->OnStartRequest(request, nsnull);
nsCOMPtr<nsIInputStream> rawStream; nsCOMPtr<nsIStringInputStream> rawStream =
rv = NS_NewByteInputStream(getter_AddRefs(rawStream), do_CreateInstance(NS_STRINGINPUTSTREAM_CONTRACTID);
(const char*)data, length); if (!rawStream)
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);
@@ -112,6 +116,14 @@ 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
@@ -148,13 +160,13 @@ HasAttachmentDisposition(nsIHttpChannel* httpChannel)
// Content-Disposition: ; filename="file" // Content-Disposition: ; filename="file"
// screen those out here. // screen those out here.
!dispToken.IsEmpty() && !dispToken.IsEmpty() &&
!dispToken.LowerCaseEqualsLiteral("inline") && !StringBeginsWithLowercaseLiteral(dispToken, "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.
!dispToken.EqualsIgnoreCase("filename", 8)) && !StringBeginsWithLowercaseLiteral(dispToken, "filename")) &&
// Also in use is Content-Disposition: name="file" // Also in use is Content-Disposition: name="file"
!dispToken.EqualsIgnoreCase("name", 4)) !StringBeginsWithLowercaseLiteral(dispToken, "name"))
// We have a content-disposition of "attachment" or unknown // We have a content-disposition of "attachment" or unknown
return PR_TRUE; return PR_TRUE;
} }
@@ -163,6 +175,20 @@ 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.
@@ -173,54 +199,38 @@ HasAttachmentDisposition(nsIHttpChannel* httpChannel)
* 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 dataString * @param start
* The data being sniffed * The beginning of the data being sniffed
* @param substring * @param end
* The substring being tested for document-element-ness * The end of the data being sniffed, right before the substring that
* @param indicator * was found.
* An iterator initialized to the end of |substring|, located in * @returns PR_TRUE if the found substring is the documentElement, PR_FALSE
* |dataString|
* @returns PR_TRUE if the substring is the documentElement, PR_FALSE
* otherwise. * otherwise.
*/ */
static PRBool static PRBool
IsDocumentElement(nsACString& dataString, const nsACString& substring, IsDocumentElement(const char *start, const char* end)
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 (FindCharInReadable('<', start, end)) { while ( (start = FindChar('<', start, end)) ) {
++start; ++start;
if (start == endOfString) if (start >= end)
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 != '!')
// Check to see if the string following the '<' is our indicator substring. return PR_FALSE;
// 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 .. > -->
if (!FindCharInReadable('>', start, end)) start = FindChar('>', start, end);
if (!start)
return PR_FALSE; return PR_FALSE;
// Reset end again ++start;
dataString.EndReading(end);
} }
return PR_TRUE; return PR_TRUE;
} }
@@ -236,17 +246,16 @@ IsDocumentElement(nsACString& dataString, const nsACString& substring,
* otherwise. * otherwise.
*/ */
static PRBool static PRBool
ContainsTopLevelSubstring(nsACString& dataString, const nsACString& substring) ContainsTopLevelSubstring(nsACString& dataString, const char *substring)
{ {
nsACString::const_iterator start, end; PRInt32 offset = dataString.Find(substring);
if (offset == -1)
return PR_FALSE;
dataString.BeginReading(start); const char *begin = dataString.BeginReading();
dataString.EndReading(end);
PRBool isFeed = FindInReadable(substring, start, end); // Only do the validation when we find the substring.
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
@@ -323,32 +332,22 @@ 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, nsDependentCSubstring dataString((const char*)testData, length);
(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, NS_LITERAL_CSTRING("<rss")); isFeed = ContainsTopLevelSubstring(dataString, "<rss");
// Atom 1.0 // Atom 1.0
if (!isFeed) if (!isFeed)
isFeed = ContainsTopLevelSubstring(dataString, NS_LITERAL_CSTRING("<feed")); isFeed = ContainsTopLevelSubstring(dataString, "<feed");
// RSS 1.0 // RSS 1.0
if (!isFeed) { if (!isFeed) {
isFeed = ContainsTopLevelSubstring(dataString, NS_LITERAL_CSTRING("<rdf:RDF")); isFeed = ContainsTopLevelSubstring(dataString, "<rdf:RDF") &&
if (isFeed) { dataString.Find(NS_RDF) &&
dataString.BeginReading(start_iter); dataString.Find(NS_RSS);
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 "nsString.h" #include "nsStringAPI.h"
class nsFeedSniffer : public nsIContentSniffer, nsIStreamListener class nsFeedSniffer : public nsIContentSniffer, nsIStreamListener
{ {

View File

@@ -43,7 +43,8 @@ include $(DEPTH)/config/autoconf.mk
MODULE = migration MODULE = migration
LIBRARY_NAME = migration_s LIBRARY_NAME = migration_s
MOZILLA_INTERNAL_API = 1 FORCE_STATIC_LIB = 1
FORCE_USE_PIC = 1
REQUIRES = \ REQUIRES = \
xpcom \ xpcom \
@@ -63,7 +64,7 @@ REQUIRES = \
docshell \ docshell \
xulapp \ xulapp \
$(NULL) $(NULL)
ifdef MOZ_PLACES ifdef MOZ_PLACES
REQUIRES += places REQUIRES += places
endif endif
@@ -102,9 +103,5 @@ 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,9 +95,10 @@ 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));
PRInt32 stringErr; nsresult stringErr;
portValue = port.ToInteger(&stringErr); portValue = port.ToInteger(&stringErr);
aPrefs->SetIntPref(aPortPref, portValue); if (NS_SUCCEEDED(stringErr))
aPrefs->SetIntPref(aPortPref, portValue);
} }
else else
SetUnicharPref(aPref, hostPort, aPrefs); SetUnicharPref(aPref, hostPort, aPrefs);
@@ -267,11 +268,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);
nsXPIDLString sourceName; nsString sourceName;
bundle->GetStringFromName(aImportSourceNameKey, getter_Copies(sourceName)); bundle->GetStringFromName(aImportSourceNameKey, getter_Copies(sourceName));
const PRUnichar* sourceNameStrings[] = { sourceName.get() }; const PRUnichar* sourceNameStrings[] = { sourceName.get() };
nsXPIDLString importedBookmarksTitle; nsString 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,7 +60,9 @@
#include "nsIPrefBranch.h" #include "nsIPrefBranch.h"
#include "nsIFile.h" #include "nsIFile.h"
#include "nsString.h" #include "nsStringAPI.h"
#include "nsCOMPtr.h"
class nsIProfileStartup; class nsIProfileStartup;

View File

@@ -42,6 +42,7 @@
#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 "nsString.h" #include "nsStringAPI.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,7 +37,6 @@
#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"
@@ -53,12 +52,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
@@ -289,7 +288,7 @@ nsDogbertProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
if (!mProfiles) { if (!mProfiles) {
nsresult rv; nsresult rv;
rv = NS_NewISupportsArray(getter_AddRefs(mProfiles)); mProfiles = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIFile> regFile; nsCOMPtr<nsIFile> regFile;
@@ -361,7 +360,7 @@ nsDogbertProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
mSourceProfile = profileFile; mSourceProfile = profileFile;
rv = NS_NewISupportsArray(getter_AddRefs(mProfiles)); mProfiles = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsISupportsString> nameString nsCOMPtr<nsISupportsString> nameString
@@ -566,7 +565,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) == nsCRT::CR || buffer.CharAt(0) == nsCRT::LF) { buffer.CharAt(0) == '\r' || buffer.CharAt(0) == '\n') {
fileOutputStream->Write(buffer.get(), buffer.Length(), &written); fileOutputStream->Write(buffer.get(), buffer.Length(), &written);
continue; continue;
} }
@@ -583,10 +582,12 @@ 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
nsCAutoString prefix, expiresString, suffix; const nsDependentCSubstring prefix =
buffer.Mid(prefix, hostIndex, expiresIndex-hostIndex-1); Substring(buffer, hostIndex, expiresIndex-hostIndex-1);
buffer.Mid(expiresString, expiresIndex, nameIndex-expiresIndex-1); const nsDependentCSubstring expiresString =
buffer.Mid(suffix, nameIndex, buffer.Length()-nameIndex); Substring(buffer, expiresIndex, nameIndex-expiresIndex-1);
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);
@@ -643,7 +644,7 @@ nsDogbertProfileMigrator::MigrateDogbertBookmarks()
dogbertPrefsFile->Append(PREF_FILE_NAME_IN_4x); dogbertPrefsFile->Append(PREF_FILE_NAME_IN_4x);
psvc->ReadUserPrefs(dogbertPrefsFile); psvc->ReadUserPrefs(dogbertPrefsFile);
nsXPIDLCString toolbarName; nsCString 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
@@ -663,5 +664,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); targetBookmarksFile, toolbarName.get());
} }

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 "nsString.h" #include "nsStringAPI.h"
#ifdef XP_MACOSX #ifdef XP_MACOSX
#define NEED_TO_FIX_4X_COOKIES 1 #define NEED_TO_FIX_4X_COOKIES 1

View File

@@ -42,6 +42,7 @@
#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 "nsString.h" #include "nsStringAPI.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,12 +45,13 @@
#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 "nsString.h" #include "nsDirectoryServiceUtils.h"
#include "nsStringAPI.h"
#include "plstr.h" #include "plstr.h"
#include "prio.h" #include "prio.h"
#include "prmem.h" #include "prmem.h"
@@ -91,7 +92,6 @@
#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.Truncate(6); tmp.SetLength(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,9 +916,8 @@ 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);
nsAutoString suffix; if (StringTail(itemNameString, 11).
itemNameString.Right(suffix, 11); LowerCaseEqualsLiteral(":stringdata")) {
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;
@@ -973,7 +972,7 @@ nsIEProfileMigrator::KeyIsURI(const nsAString& aKey, char** aRealm)
uri->GetHost(host); uri->GetHost(host);
realm.Append(host); realm.Append(host);
*aRealm = nsCRT::strdup(realm.get()); *aRealm = ToNewCString(realm);
return validScheme; return validScheme;
} }
} }
@@ -996,15 +995,14 @@ 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);
nsAutoString suffix; if (StringTail(itemNameString, 11).
itemNameString.Right(suffix, 11); LowerCaseEqualsLiteral(":stringdata")) {
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).
nsXPIDLCString realm; nsCString 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);
@@ -1021,7 +1019,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
nsCRT::free(sd->realm); NS_Free(sd->realm);
delete sd; delete sd;
} }
} }
@@ -1124,12 +1122,11 @@ 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);
nsAutoString suffix; if (StringTail(itemNameString, 11).
itemNameString.Right(suffix, 11); LowerCaseEqualsLiteral(":stringdata")) {
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);
nsXPIDLCString realm; nsCString 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;
@@ -1208,12 +1205,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));
nsXPIDLString sourceNameIE; nsString 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() };
nsXPIDLString importedIEFavsTitle; nsString 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));
@@ -1280,7 +1277,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; PRInt64 keywordsFolder = 0;
#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;
@@ -1299,12 +1296,12 @@ nsIEProfileMigrator::CopySmartKeywords(nsIRDFResource* aParentFolder)
break; break;
if (!keywordsFolder) { if (!keywordsFolder) {
nsXPIDLString sourceNameIE; nsString 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() };
nsXPIDLString importedIESearchUrlsTitle; nsString 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
@@ -1337,13 +1334,13 @@ nsIEProfileMigrator::CopySmartKeywords(nsIRDFResource* aParentFolder)
NS_ConvertUTF8toUTF16 host(hostCStr); NS_ConvertUTF8toUTF16 host(hostCStr);
const PRUnichar* nameStrings[] = { host.get() }; const PRUnichar* nameStrings[] = { host.get() };
nsXPIDLString keywordName; nsString 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() };
nsXPIDLString keywordDesc; nsString 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));
@@ -1369,7 +1366,7 @@ nsIEProfileMigrator::CopySmartKeywords(nsIRDFResource* aParentFolder)
} }
void void
nsIEProfileMigrator::ResolveShortcut(const nsAFlatString &aFileName, char** aOutURL) nsIEProfileMigrator::ResolveShortcut(const nsString &aFileName, char** aOutURL)
{ {
HRESULT result; HRESULT result;
@@ -1463,8 +1460,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,
nsCaseInsensitiveStringComparator())) CaseInsensitiveCompare))
bookmarkName.Truncate(lnkExtStart); bookmarkName.SetLength(lnkExtStart);
#ifdef MOZ_PLACES_BOOKMARKS #ifdef MOZ_PLACES_BOOKMARKS
nsCOMPtr<nsIURI> bookmarkURI; nsCOMPtr<nsIURI> bookmarkURI;
@@ -1557,8 +1554,7 @@ nsIEProfileMigrator::ParseFavoritesFolder(nsIFile* aDirectory,
nsCAutoString extension; nsCAutoString extension;
url->GetFileExtension(extension); url->GetFileExtension(extension);
if (!extension.Equals(NS_LITERAL_CSTRING("url"), if (!extension.Equals("url", CaseInsensitiveCompare))
nsCaseInsensitiveCStringComparator()))
continue; continue;
nsAutoString name(Substring(bookmarkName, 0, nsAutoString name(Substring(bookmarkName, 0,
@@ -1567,7 +1563,7 @@ nsIEProfileMigrator::ParseFavoritesFolder(nsIFile* aDirectory,
nsAutoString path; nsAutoString path;
currFile->GetPath(path); currFile->GetPath(path);
nsXPIDLCString resolvedURL; nsCString resolvedURL;
ResolveShortcut(path, getter_Copies(resolvedURL)); ResolveShortcut(path, getter_Copies(resolvedURL));
#ifdef MOZ_PLACES_BOOKMARKS #ifdef MOZ_PLACES_BOOKMARKS
@@ -1715,7 +1711,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, nsCaseInsensitiveCStringComparator())) if (!fileOwner.Equals(username, CaseInsensitiveCompare))
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 nsAFlatString &aFileName, char** aOutURL); void ResolveShortcut(const nsString &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,6 +20,7 @@
* *
* 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
@@ -45,6 +46,8 @@
#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")
@@ -196,7 +199,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);
nsXPIDLString toolbarFolderNameMacIE; nsString 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 "nsString.h" #include "nsStringAPI.h"
class nsMacIEProfileMigrator : public nsIBrowserProfileMigrator class nsMacIEProfileMigrator : public nsIBrowserProfileMigrator
{ {

View File

@@ -37,7 +37,6 @@
#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"
@@ -52,8 +51,6 @@
#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"
@@ -175,8 +172,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
nsXPIDLString profileName; nsString profileName;
CopyUTF8toUTF16(profileStr, profileName); CopyUTF8toUTF16(nsDependentCString(profileStr), profileName);
nsCOMPtr<nsISupportsString> profileNameString( nsCOMPtr<nsISupportsString> profileNameString(
do_CreateInstance("@mozilla.org/supports-string;1")); do_CreateInstance("@mozilla.org/supports-string;1"));
@@ -227,7 +224,7 @@ nsNetscapeProfileMigratorBase::GetWString(void* aTransform, nsIPrefBranch* aBran
getter_AddRefs(prefValue)); getter_AddRefs(prefValue));
if (NS_SUCCEEDED(rv) && prefValue) { if (NS_SUCCEEDED(rv) && prefValue) {
nsXPIDLString data; nsString data;
prefValue->ToString(getter_Copies(data)); prefValue->ToString(getter_Copies(data));
xform->stringValue = ToNewCString(NS_ConvertUTF16toUTF8(data)); xform->stringValue = ToNewCString(NS_ConvertUTF16toUTF8(data));
@@ -242,7 +239,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"));
nsAutoString data; data.AssignWithConversion(xform->stringValue); NS_ConvertUTF8toUTF16 data(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);
} }
@@ -341,7 +338,6 @@ 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;
@@ -381,18 +377,19 @@ 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
buffer.BeginWriting(iter); char *iter = buffer.BeginWriting();
*(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 nsASingleFragmentCString &host = Substring(buffer, hostIndex, isDomainIndex - hostIndex - 1); const nsDependentCSubstring host =
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(':') != kNotFound) host.FindChar(':') != -1)
continue; continue;
// create a new nsCookie and assign the data. // create a new nsCookie and assign the data.
@@ -458,7 +455,7 @@ nsNetscapeProfileMigratorBase::LocateSignonsFile(char** aResult)
nsCAutoString extn; nsCAutoString extn;
url->GetFileExtension(extn); url->GetFileExtension(extn);
if (extn.EqualsIgnoreCase("s")) { if (extn.Equals("s", CaseInsensitiveCompare)) {
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 "nsString.h" #include "nsStringAPI.h"
class nsIFile; class nsIFile;
class nsIPrefBranch; class nsIPrefBranch;

View File

@@ -20,6 +20,7 @@
* *
* 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
@@ -42,6 +43,7 @@
#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 "nsString.h" #include "nsStringAPI.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,8 +67,6 @@
#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>
@@ -217,7 +215,9 @@ NS_IMETHODIMP
nsOperaProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult) nsOperaProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
{ {
if (!mProfiles) { if (!mProfiles) {
nsresult rv = NS_NewISupportsArray(getter_AddRefs(mProfiles)); nsresult rv;
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"));
nsAutoString data; data.AssignWithConversion(xform->stringValue); NS_ConvertASCIItoUTF16 data(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)) {
PRInt32 strerr; nsresult 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((PRInt32*) &rv); *aResult = val.ToInteger(&rv);
return rv; return rv;
} }
@@ -874,7 +874,7 @@ nsOperaCookieMigrator::AddCookieOverride(nsIPermissionManager* aManager)
{ {
nsresult rv; nsresult rv;
nsXPIDLCString domain; nsCString 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.
nsXPIDLCString domain; nsCString domain;
SynthesizeDomain(getter_Copies(domain)); SynthesizeDomain(getter_Copies(domain));
nsXPIDLCString path; nsCString 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
PRInt32 err; nsresult 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) {
nsXPIDLString sourceNameOpera; nsString 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() };
nsXPIDLString importedOperaHotlistTitle; nsString 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;
nsXPIDLString sourceNameOpera; nsString 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() };
nsXPIDLString importedSearchUrlsTitle; nsString 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);
nsAutoString host; host.AssignWithConversion(hostCStr.get()); NS_ConvertASCIItoUTF16 host(hostCStr);
const PRUnichar* descStrings[] = { NS_ConvertUTF8toUTF16(keyword).get(), host.get() }; const PRUnichar* descStrings[] = { NS_ConvertUTF8toUTF16(keyword).get(), host.get() };
nsXPIDLString keywordDesc; nsString 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,7 +1340,6 @@ 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);
@@ -1349,7 +1348,7 @@ nsOperaProfileMigrator::ParseBookmarksFolder(nsILineInputStream* aStream,
if (!moreData) break; if (!moreData) break;
CopyUTF8toUTF16(cBuffer, buffer); CopyUTF8toUTF16(cBuffer, buffer);
nsXPIDLString data; nsString 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:
@@ -1415,10 +1414,10 @@ nsOperaProfileMigrator::ParseBookmarksFolder(nsILineInputStream* aStream,
if (NS_FAILED(rv)) if (NS_FAILED(rv))
continue; continue;
#endif #endif
name = empty; name.Truncate();
url.AssignWithConversion(empty); url.Truncate();
keyword = empty; keyword.Truncate();
description = empty; description.Truncate();
onToolbar = PR_FALSE; onToolbar = PR_FALSE;
} }
} }
@@ -1440,7 +1439,7 @@ nsOperaProfileMigrator::ParseBookmarksFolder(nsILineInputStream* aStream,
continue; continue;
rv = ParseBookmarksFolder(aStream, itemRes, aToolbar, aBMS); rv = ParseBookmarksFolder(aStream, itemRes, aToolbar, aBMS);
#endif #endif
name = empty; name.Truncate();
} }
} }
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 "nsString.h" #include "nsStringAPI.h"
#include "nsVoidArray.h" #include "nsVoidArray.h"
class nsICookieManager2; class nsICookieManager2;

View File

@@ -36,7 +36,6 @@
* ***** 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"
@@ -173,11 +172,11 @@ nsPhoenixProfileMigrator::GetMigrateData(const PRUnichar* aProfile,
aReplace, mSourceProfile, aResult); aReplace, mSourceProfile, aResult);
// Now locate passwords // Now locate passwords
nsXPIDLCString signonsFileName; nsCString signonsFileName;
GetSignonFileName(aReplace, getter_Copies(signonsFileName)); GetSignonFileName(aReplace, getter_Copies(signonsFileName));
if (!signonsFileName.IsEmpty()) { if (!signonsFileName.IsEmpty()) {
nsAutoString fileName; fileName.AssignWithConversion(signonsFileName); NS_ConvertASCIItoUTF16 fileName(signonsFileName);
nsCOMPtr<nsIFile> sourcePasswordsFile; nsCOMPtr<nsIFile> sourcePasswordsFile;
mSourceProfile->Clone(getter_AddRefs(sourcePasswordsFile)); mSourceProfile->Clone(getter_AddRefs(sourcePasswordsFile));
sourcePasswordsFile->Append(fileName); sourcePasswordsFile->Append(fileName);
@@ -229,11 +228,9 @@ NS_IMETHODIMP
nsPhoenixProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult) nsPhoenixProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
{ {
if (!mProfileNames && !mProfileLocations) { if (!mProfileNames && !mProfileLocations) {
nsresult rv = NS_NewISupportsArray(getter_AddRefs(mProfileNames)); mProfileNames = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID);
if (NS_FAILED(rv)) return rv; mProfileLocations = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID);
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();
@@ -257,11 +254,14 @@ 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(do_QueryElementAt(mProfileNames, i)); nsCOMPtr<nsISupportsString> str;
nsXPIDLString profileName; mProfileNames->QueryElementAt(i, NS_GET_IID(nsISupportsString),
getter_AddRefs(str));
nsString profileName;
str->GetData(profileName); str->GetData(profileName);
if (profileName.Equals(aProfile)) { if (profileName.Equals(aProfile)) {
mSourceProfile = do_QueryElementAt(mProfileLocations, i); mProfileLocations->QueryElementAt(i, NS_GET_IID(nsILocalFile),
getter_AddRefs(mSourceProfile));
break; break;
} }
} }
@@ -397,7 +397,7 @@ nsPhoenixProfileMigrator::CopyPasswords(PRBool aReplace)
{ {
nsresult rv; nsresult rv;
nsXPIDLCString signonsFileName; nsCString 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;
nsAutoString fileName; fileName.AssignWithConversion(signonsFileName); NS_ConvertASCIItoUTF16 fileName(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 "nsString.h" #include "nsStringAPI.h"
class nsIFile; class nsIFile;
class nsIPrefBranch; class nsIPrefBranch;

View File

@@ -42,6 +42,7 @@
#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"
@@ -51,13 +52,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 "nsReadableUtils.h" #include "nsStringAPI.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"
@@ -65,7 +66,6 @@
#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 = nsCAutoString contractID(NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX);
NS_LITERAL_CSTRING(NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX) + key; contractID.Append(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 =
NS_NewISupportsArray(getter_AddRefs(params)); do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID);
if (!ww || !params) return NS_ERROR_FAILURE; if (!ww || !params) return NS_ERROR_FAILURE;
params->AppendElement(cstr); params->AppendElement(cstr);
@@ -187,20 +187,18 @@ 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;
nsAString::const_iterator start, end; PRInt32 len = value.Find(NS_LITERAL_STRING(".exe"), CaseInsensitiveCompare);
value.BeginReading(start); if (len == -1)
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.CharAt(1) != ':') if (value.get()[1] != ':') {
++start; start = 1;
--len;
}
nsDependentSubstring filePath(start, end); const nsDependentSubstring filePath(Substring(value, start, len));
// 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 &&
!nsCRT::strcmp(gCharsets[i].webkitLabel, encodingStr)) !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)
{ {
nsXPIDLCString associatedLangGroup; nsCString 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)
{ {
nsXPIDLCString associatedLangGroup; nsCString 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));
nsXPIDLString sourceNameSafari; nsString 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() };
nsXPIDLString importedSafariBookmarksTitle; nsString 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,7 +1144,9 @@ 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 + NS_LITERAL_CSTRING("/userContent.css"); nsCAutoString path(userChromeDirPath);
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 "nsString.h" #include "nsStringAPI.h"
#include <CoreFoundation/CoreFoundation.h> #include <CoreFoundation/CoreFoundation.h>

View File

@@ -36,7 +36,6 @@
* ***** 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"
@@ -161,11 +160,11 @@ nsSeamonkeyProfileMigrator::GetMigrateData(const PRUnichar* aProfile,
aReplace, mSourceProfile, aResult); aReplace, mSourceProfile, aResult);
// Now locate passwords // Now locate passwords
nsXPIDLCString signonsFileName; nsCString signonsFileName;
GetSignonFileName(aReplace, getter_Copies(signonsFileName)); GetSignonFileName(aReplace, getter_Copies(signonsFileName));
if (!signonsFileName.IsEmpty()) { if (!signonsFileName.IsEmpty()) {
nsAutoString fileName; fileName.AssignWithConversion(signonsFileName); NS_ConvertASCIItoUTF16 fileName(signonsFileName);
nsCOMPtr<nsIFile> sourcePasswordsFile; nsCOMPtr<nsIFile> sourcePasswordsFile;
mSourceProfile->Clone(getter_AddRefs(sourcePasswordsFile)); mSourceProfile->Clone(getter_AddRefs(sourcePasswordsFile));
sourcePasswordsFile->Append(fileName); sourcePasswordsFile->Append(fileName);
@@ -217,11 +216,9 @@ NS_IMETHODIMP
nsSeamonkeyProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult) nsSeamonkeyProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
{ {
if (!mProfileNames && !mProfileLocations) { if (!mProfileNames && !mProfileLocations) {
nsresult rv = NS_NewISupportsArray(getter_AddRefs(mProfileNames)); mProfileNames = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID);
if (NS_FAILED(rv)) return rv; mProfileLocations = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID);
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();
@@ -255,7 +252,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) {
nsXPIDLString data; nsString data;
prefValue->ToString(getter_Copies(data)); prefValue->ToString(getter_Copies(data));
nsCAutoString val; nsCAutoString val;
@@ -280,11 +277,14 @@ 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(do_QueryElementAt(mProfileNames, i)); nsCOMPtr<nsISupportsString> str;
nsXPIDLString profileName; mProfileNames->QueryElementAt(i, NS_GET_IID(nsISupportsString),
getter_AddRefs(str));
nsString profileName;
str->GetData(profileName); str->GetData(profileName);
if (profileName.Equals(aProfile)) { if (profileName.Equals(aProfile)) {
mSourceProfile = do_QueryElementAt(mProfileLocations, i); mProfileLocations->QueryElementAt(i, NS_GET_IID(nsILocalFile),
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);
PL_strfree(pref->stringValue); NS_Free(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;
nsXPIDLCString signonsFileName; nsCString 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;
nsAutoString fileName; fileName.AssignWithConversion(signonsFileName); NS_ConvertASCIItoUTF16 fileName(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 "nsString.h" #include "nsStringAPI.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,8 +43,9 @@
#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 "nsString.h" #include "nsStringAPI.h"
NS_IMPL_ISUPPORTS4(nsDocNavStartProgressListener, NS_IMPL_ISUPPORTS4(nsDocNavStartProgressListener,
nsIDocNavStartProgressListener, nsIDocNavStartProgressListener,
@@ -332,7 +333,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.Truncate(pos); uriString.SetLength(pos);
} }
mCallback->OnDocNavStart(request, uriString); mCallback->OnDocNavStart(request, uriString);

View File

@@ -43,7 +43,8 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk include $(DEPTH)/config/autoconf.mk
MODULE = shellservice MODULE = shellservice
MOZILLA_INTERNAL_API = 1 FORCE_STATIC_LIB = 1
FORCE_USE_PIC = 1
REQUIRES = \ REQUIRES = \
xpcom \ xpcom \
@@ -79,8 +80,6 @@ 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 "nsString.h" #include "nsStringAPI.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,12 +217,13 @@ 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 + NS_LITERAL_CSTRING(" \"%s\"")); nsCAutoString appKeyValue(mAppPath);
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));
+ NS_LITERAL_CSTRING(",")); schemeList.Append(',');
if (appProtocols[i].essential || aClaimAllTypes) { if (appProtocols[i].essential || aClaimAllTypes) {
gconf->SetAppForProtocol(nsDependentCString(appProtocols[i].name), gconf->SetAppForProtocol(nsDependentCString(appProtocols[i].name),
@@ -242,7 +243,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);
nsXPIDLString brandShortName, brandFullName; nsString 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(),
@@ -279,7 +280,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.Truncate(lastSlash); iconFilePath.SetLength(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) {
@@ -400,7 +401,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
nsXPIDLString brandName; nsString 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) {
@@ -415,10 +416,10 @@ nsGNOMEShellService::SetDesktopBackground(nsIDOMElement* aElement,
} }
// build the file name // build the file name
filePath.Append(NS_LITERAL_CSTRING("/") + filePath.Append('/');
NS_ConvertUTF16toUTF8(brandName) + filePath.Append(NS_ConvertUTF16toUTF8(brandName));
NS_LITERAL_CSTRING("_wallpaper.png")); filePath.Append("_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);
@@ -447,6 +448,59 @@ 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)
{ {
@@ -463,26 +517,36 @@ nsGNOMEShellService::GetDesktopBackgroundColor(PRUint32 *aColor)
// Chop off the leading '#' character // Chop off the leading '#' character
background.Cut(0, 1); background.Cut(0, 1);
nscolor rgb; PRUint8 red, green, blue;
if (!NS_ASCIIHexToRGB(background, &rgb)) if (!HexToRGB(background, red, green, blue))
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 = (NS_GET_R(rgb) << 16 | NS_GET_G(rgb) << 8 | NS_GET_B(rgb)); *aColor = (red << 16 | green << 8 | blue);
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);
unsigned char red = (aColor >> 16); nsCString colorString;
unsigned char green = (aColor >> 8) & 0xff; ColorToHex(aColor, colorString);
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);
@@ -556,7 +620,7 @@ nsGNOMEShellService::OpenApplicationWithURI(nsILocalFile* aApplication, const ns
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return rv;
const nsPromiseFlatCString& spec = PromiseFlatCString(aURI); const nsCString spec(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 "nsString.h" #include "nsStringAPI.h"
class nsGNOMEShellService : public nsIShellService class nsGNOMEShellService : public nsIShellService
{ {

View File

@@ -21,6 +21,7 @@
* 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
@@ -52,7 +53,7 @@
#include "nsMacShellService.h" #include "nsMacShellService.h"
#include "nsNetUtil.h" #include "nsNetUtil.h"
#include "nsShellService.h" #include "nsShellService.h"
#include "nsString.h" #include "nsStringAPI.h"
#include <CoreFoundation/CoreFoundation.h> #include <CoreFoundation/CoreFoundation.h>
#include <Carbon/Carbon.h> #include <Carbon/Carbon.h>
@@ -468,7 +469,7 @@ nsMacShellService::OpenApplicationWithURI(nsILocalFile* aApplication, const nsAC
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return rv;
const nsPromiseFlatCString& spec = PromiseFlatCString(aURI); const nsCString spec(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,6 +41,7 @@
#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,7 +42,6 @@
#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"
@@ -57,7 +56,6 @@
#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"
@@ -457,8 +455,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.EqualsIgnoreCase(currValue) && !dataLongPath.Equals(currValue, CaseInsensitiveCompare) &&
!dataShortPath.EqualsIgnoreCase(currValue)) { !dataShortPath.Equals(currValue, CaseInsensitiveCompare)) {
// 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;
@@ -534,12 +532,13 @@ 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
nsXPIDLString brandFullName; nsString 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_CopyUnicodeToNative(brandFullName, nativeFullName); NS_UTF16ToCString(brandFullName, NS_CSTRING_ENCODING_NATIVE_FILESYSTEM,
nativeFullName);
nsCAutoString key1(NS_LITERAL_CSTRING(SMI)); nsCAutoString key1(NS_LITERAL_CSTRING(SMI));
key1.Append(exeName); key1.Append(exeName);
@@ -548,35 +547,39 @@ 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(NS_LITERAL_CSTRING(SMI "%APPEXE%\\shell\\properties")); nsCAutoString optionsKey(SMI);
optionsKey.ReplaceSubstring("%APPEXE%", exeName.get()); optionsKey.Append(exeName);
optionsKey.Append("\\shell\\properties");
nsCAutoString safeModeKey(NS_LITERAL_CSTRING(SMI "%APPEXE%\\shell\\safemode")); nsCAutoString safeModeKey(SMI);
safeModeKey.ReplaceSubstring("%APPEXE%", exeName.get()); safeModeKey.Append(exeName);
safeModeKey.Append("\\shell\\safemode");
nsXPIDLString brandShortName; nsString 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
nsXPIDLString optionsTitle; nsString 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
nsXPIDLString safeModeTitle; nsString 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_CopyUnicodeToNative(optionsTitle, nativeTitle); NS_UTF16ToCString(optionsTitle, NS_CSTRING_ENCODING_NATIVE_FILESYSTEM,
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_CopyUnicodeToNative(safeModeTitle, nativeTitle); NS_UTF16ToCString(safeModeTitle, NS_CSTRING_ENCODING_NATIVE_FILESYSTEM,
nativeTitle);
SetRegKey(safeModeKey.get(), "", nativeTitle.get(), aClaimAllTypes, SetRegKey(safeModeKey.get(), "", nativeTitle.get(), aClaimAllTypes,
aForAllUsers); aForAllUsers);
@@ -778,7 +781,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"
nsXPIDLString fileLeafName; nsString fileLeafName;
rv = shellBundle->GetStringFromName rv = shellBundle->GetStringFromName
(NS_LITERAL_STRING("desktopBackgroundLeafNameWin").get(), (NS_LITERAL_STRING("desktopBackgroundLeafNameWin").get(),
getter_Copies(fileLeafName)); getter_Copies(fileLeafName));
@@ -1054,7 +1057,7 @@ nsWindowsShellService::OpenApplicationWithURI(nsILocalFile* aApplication, const
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return rv;
const nsPromiseFlatCString& spec = PromiseFlatCString(aURI); const nsCString spec(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,6 +211,8 @@ 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,6 +220,8 @@ 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,11 +284,18 @@ 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
@@ -296,6 +303,7 @@ 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) $@; ) $(foreach dir,$(DIRS),$(UPDATE_TITLE) $(MAKE) -C $(dir) $@; ) true
LOOP_OVER_TOOL_DIRS = \ LOOP_OVER_TOOL_DIRS = \
@$(EXIT_ON_ERROR) \ @$(EXIT_ON_ERROR) \
$(foreach dir,$(TOOL_DIRS),$(UPDATE_TITLE) $(MAKE) -C $(dir) $@; ) $(foreach dir,$(TOOL_DIRS),$(UPDATE_TITLE) $(MAKE) -C $(dir) $@; ) true
# #
# 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); ) $(foreach tier,$(TIERS),$(MAKE) tier_$(tier); ) true
else else
default all:: default all::
@$(EXIT_ON_ERROR) \ @$(EXIT_ON_ERROR) \
$(foreach dir,$(STATIC_DIRS),$(MAKE) -C $(dir); ) $(foreach dir,$(STATIC_DIRS),$(MAKE) -C $(dir); ) true
$(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; ) $(foreach dir,$(tier_$*_dirs),$(MAKE) -C $(dir) export; ) true
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; ) $(foreach dir,$(tier_$*_dirs),$(MAKE) -C $(dir) libs; ) true
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; ) $(foreach dir,$(tier_$*_dirs),$(MAKE) -C $(dir) tools; ) true
$(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); ) $(foreach dir,$($@_staticdirs),$(MAKE) -C $(dir); ) true
$(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; ) $(foreach dir,$(TOOL_DIRS),$(UPDATE_TITLE) $(MAKE) -C $(dir) libs; ) true
endif endif
# #

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) != *aSubstring) if (NS_ToLower((char) *aStr) != NS_ToLower(*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, PRBool aIgnoreCase) const nsAString::Find(const char *aStr, PRUint32 aOffset, 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,6 +358,9 @@ nsAString::Find(const char *aStr, 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)
@@ -366,7 +369,7 @@ nsAString::Find(const char *aStr, 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; cur <= end; ++cur) { for (const char_type *cur = begin + aOffset; cur <= end; ++cur) {
if (match(cur, aStr, otherlen)) { if (match(cur, aStr, otherlen)) {
return cur - begin; return cur - begin;
} }
@@ -682,7 +685,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(begin, aStr, aLen)) if (!c(cur, aStr, aLen))
return cur - begin; return cur - begin;
} }
return -1; return -1;

View File

@@ -229,7 +229,10 @@ 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