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

git-svn-id: svn://10.0.0.236/trunk@215030 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
benjamin%smedbergs.us 2006-11-09 15:02:29 +00:00
parent a0ef0d41c5
commit b75752771b
51 changed files with 565 additions and 465 deletions

View File

@ -44,7 +44,8 @@ include $(DEPTH)/config/autoconf.mk
MODULE = bookmarks
LIBRARY_NAME = bookmarks_s
MOZILLA_INTERNAL_API = 1
FORCE_STATIC_LIB = 1
FORCE_USE_PIC = 1
REQUIRES = xpcom \
string \
@ -76,9 +77,5 @@ CPPSRCS = nsBookmarksService.cpp \
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

View File

@ -392,8 +392,12 @@ nsFeedLoadListener::TryParseAsRDF ()
if (NS_FAILED(rv)) return rv;
if (!listener) return NS_ERROR_FAILURE;
nsCOMPtr<nsIInputStream> stream;
rv = NS_NewCStringInputStream(getter_AddRefs(stream), mBody);
nsCOMPtr<nsIStringInputStream> stream =
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;
nsCOMPtr<nsIChannel> channel;
@ -853,9 +857,9 @@ nsFeedLoadListener::TryParseAsSimpleRSS ()
}
// Clean up whitespace
titleStr.CompressWhitespace();
CompressWhitespace(titleStr);
linkStr.Trim("\b\t\r\n ");
dateStr.CompressWhitespace();
CompressWhitespace(dateStr);
if (titleStr.IsEmpty() && !dateStr.IsEmpty())
titleStr.Assign(dateStr);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -43,7 +43,8 @@ include $(DEPTH)/config/autoconf.mk
MODULE = migration
LIBRARY_NAME = migration_s
MOZILLA_INTERNAL_API = 1
FORCE_STATIC_LIB = 1
FORCE_USE_PIC = 1
REQUIRES = \
xpcom \
@ -63,7 +64,7 @@ REQUIRES = \
docshell \
xulapp \
$(NULL)
ifdef MOZ_PLACES
REQUIRES += places
endif
@ -102,9 +103,5 @@ CPPSRCS += nsSafariProfileMigrator.cpp \
$(NULL)
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

View File

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

View File

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

View File

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

View File

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

View File

@ -37,7 +37,6 @@
#include "nsAppDirectoryServiceDefs.h"
#include "nsBrowserProfileMigratorUtils.h"
#include "nsCRT.h"
#include "nsDogbertProfileMigrator.h"
#include "nsICookieManager2.h"
#include "nsIFile.h"
@ -53,12 +52,12 @@
#include "nsISupportsPrimitives.h"
#include "nsNetCID.h"
#include "nsNetUtil.h"
#include "nsReadableUtils.h"
#include "prprf.h"
#include "prenv.h"
#include "nsEscape.h"
#include "NSReg.h"
#include "nsDirectoryServiceDefs.h"
#include "nsDirectoryServiceUtils.h"
#include <stdlib.h>
#ifndef MAXPATHLEN
#ifdef _MAX_PATH
@ -289,7 +288,7 @@ nsDogbertProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
if (!mProfiles) {
nsresult rv;
rv = NS_NewISupportsArray(getter_AddRefs(mProfiles));
mProfiles = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIFile> regFile;
@ -361,7 +360,7 @@ nsDogbertProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
mSourceProfile = profileFile;
rv = NS_NewISupportsArray(getter_AddRefs(mProfiles));
mProfiles = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsISupportsString> nameString
@ -566,7 +565,7 @@ nsDogbertProfileMigrator::FixDogbertCookies()
// skip line if it is a comment or null line
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);
continue;
}
@ -583,10 +582,12 @@ nsDogbertProfileMigrator::FixDogbertCookies()
continue;
// separate the expires field from the rest of the cookie line
nsCAutoString prefix, expiresString, suffix;
buffer.Mid(prefix, hostIndex, expiresIndex-hostIndex-1);
buffer.Mid(expiresString, expiresIndex, nameIndex-expiresIndex-1);
buffer.Mid(suffix, nameIndex, buffer.Length()-nameIndex);
const nsDependentCSubstring prefix =
Substring(buffer, hostIndex, expiresIndex-hostIndex-1);
const nsDependentCSubstring expiresString =
Substring(buffer, expiresIndex, nameIndex-expiresIndex-1);
const nsDependentCSubstring suffix =
Substring(buffer, nameIndex, buffer.Length()-nameIndex);
// correct the expires field
char* expiresCString = ToNewCString(expiresString);
@ -643,7 +644,7 @@ nsDogbertProfileMigrator::MigrateDogbertBookmarks()
dogbertPrefsFile->Append(PREF_FILE_NAME_IN_4x);
psvc->ReadUserPrefs(dogbertPrefsFile);
nsXPIDLCString toolbarName;
nsCString toolbarName;
nsCOMPtr<nsIPrefBranch> branch(do_QueryInterface(psvc));
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
@ -663,5 +664,5 @@ nsDogbertProfileMigrator::MigrateDogbertBookmarks()
targetBookmarksFile->Append(BOOKMARKS_FILE_NAME_IN_5x);
return AnnotatePersonalToolbarFolder(sourceBookmarksFile,
targetBookmarksFile, toolbarName);
targetBookmarksFile, toolbarName.get());
}

View File

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

View File

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

View File

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

View File

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

View File

@ -20,6 +20,7 @@
*
* Contributor(s):
* Ben Goodger <ben@bengoodger.com>
* Benjamin Smedberg <benjamin@smedbergs.us>
*
* 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
@ -45,6 +46,8 @@
#include "nsIStringBundle.h"
#include "nsISupportsArray.h"
#include "nsISupportsPrimitives.h"
#include "nsServiceManagerUtils.h"
#include "nsIProperties.h"
#define MACIE_BOOKMARKS_FILE_NAME NS_LITERAL_STRING("Favorites.html")
#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));
NS_ENSURE_SUCCESS(rv, rv);
nsXPIDLString toolbarFolderNameMacIE;
nsString toolbarFolderNameMacIE;
bundle->GetStringFromName(NS_LITERAL_STRING("toolbarFolderNameMacIE").get(),
getter_Copies(toolbarFolderNameMacIE));
nsCAutoString ctoolbarFolderNameMacIE;

View File

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

View File

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

View File

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

View File

@ -20,6 +20,7 @@
*
* Contributor(s):
* Ben Goodger <ben@bengoodger.com>
* Benjamin Smedberg <benjamin@smedbergs.us>
*
* 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
@ -42,6 +43,7 @@
#include "nsIServiceManager.h"
#include "nsISupportsArray.h"
#include "nsISupportsPrimitives.h"
#include "nsServiceManagerUtils.h"
///////////////////////////////////////////////////////////////////////////////
// nsOmniWebProfileMigrator

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -43,7 +43,7 @@
#include "nsDirectoryServiceDefs.h"
#include "nsIPrefService.h"
#include "prenv.h"
#include "nsString.h"
#include "nsStringAPI.h"
#include "nsIGConfService.h"
#include "nsIGnomeVFSService.h"
#include "nsIStringBundle.h"
@ -56,10 +56,10 @@
#include "imgIRequest.h"
#include "imgIContainer.h"
#include "nsIImage.h"
#include "prprf.h"
#ifdef MOZ_WIDGET_GTK2
#include "nsIImageToPixbuf.h"
#endif
#include "nsColor.h"
#include <glib.h>
#include <glib-object.h>
@ -217,12 +217,13 @@ nsGNOMEShellService::SetDefaultBrowser(PRBool aClaimAllTypes,
nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
nsCAutoString schemeList;
nsCAutoString appKeyValue(mAppPath + NS_LITERAL_CSTRING(" \"%s\""));
nsCAutoString appKeyValue(mAppPath);
appKeyValue.Append(" \"%s\"");
unsigned int i;
for (i = 0; i < NS_ARRAY_LENGTH(appProtocols); ++i) {
schemeList.Append(nsDependentCString(appProtocols[i].name)
+ NS_LITERAL_CSTRING(","));
schemeList.Append(nsDependentCString(appProtocols[i].name));
schemeList.Append(',');
if (appProtocols[i].essential || aClaimAllTypes) {
gconf->SetAppForProtocol(nsDependentCString(appProtocols[i].name),
@ -242,7 +243,7 @@ nsGNOMEShellService::SetDefaultBrowser(PRBool aClaimAllTypes,
bundleService->CreateBundle(BRAND_PROPERTIES, getter_AddRefs(brandBundle));
NS_ENSURE_TRUE(brandBundle, NS_ERROR_FAILURE);
nsXPIDLString brandShortName, brandFullName;
nsString brandShortName, brandFullName;
brandBundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(),
getter_Copies(brandShortName));
brandBundle->GetStringFromName(NS_LITERAL_STRING("brandFullName").get(),
@ -279,7 +280,7 @@ nsGNOMEShellService::SetDefaultBrowser(PRBool aClaimAllTypes,
if (lastSlash == -1) {
NS_ERROR("no slash in executable path?");
} else {
iconFilePath.Truncate(lastSlash);
iconFilePath.SetLength(lastSlash);
nsCOMPtr<nsILocalFile> iconFile;
NS_NewNativeLocalFile(iconFilePath, PR_FALSE, getter_AddRefs(iconFile));
if (iconFile) {
@ -400,7 +401,7 @@ nsGNOMEShellService::SetDesktopBackground(nsIDOMElement* aElement,
nsCAutoString filePath(PR_GetEnv("HOME"));
// get the product brand name from localized strings
nsXPIDLString brandName;
nsString brandName;
nsCID bundleCID = NS_STRINGBUNDLESERVICE_CID;
nsCOMPtr<nsIStringBundleService> bundleService(do_GetService(bundleCID));
if (bundleService) {
@ -415,10 +416,10 @@ nsGNOMEShellService::SetDesktopBackground(nsIDOMElement* aElement,
}
// build the file name
filePath.Append(NS_LITERAL_CSTRING("/") +
NS_ConvertUTF16toUTF8(brandName) +
NS_LITERAL_CSTRING("_wallpaper.png"));
filePath.Append('/');
filePath.Append(NS_ConvertUTF16toUTF8(brandName));
filePath.Append("_wallpaper.png");
// write the image to a file in the home dir
rv = WriteImage(filePath, gfxFrame);
@ -447,6 +448,59 @@ nsGNOMEShellService::SetDesktopBackground(nsIDOMElement* aElement,
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
nsGNOMEShellService::GetDesktopBackgroundColor(PRUint32 *aColor)
{
@ -463,26 +517,36 @@ nsGNOMEShellService::GetDesktopBackgroundColor(PRUint32 *aColor)
// Chop off the leading '#' character
background.Cut(0, 1);
nscolor rgb;
if (!NS_ASCIIHexToRGB(background, &rgb))
return NS_ERROR_FAILURE;
PRUint8 red, green, blue;
if (!HexToRGB(background, red, green, blue))
return NS_ERROR_FAILURE;
// 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;
}
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
nsGNOMEShellService::SetDesktopBackgroundColor(PRUint32 aColor)
{
nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
unsigned char red = (aColor >> 16);
unsigned char green = (aColor >> 8) & 0xff;
unsigned char blue = aColor & 0xff;
nsCAutoString colorString;
NS_RGBToASCIIHex(NS_RGB(red, green, blue), colorString);
nsCString colorString;
ColorToHex(aColor, colorString);
gconf->SetString(NS_LITERAL_CSTRING(kDesktopColorKey), colorString);
@ -556,7 +620,7 @@ nsGNOMEShellService::OpenApplicationWithURI(nsILocalFile* aApplication, const ns
if (NS_FAILED(rv))
return rv;
const nsPromiseFlatCString& spec = PromiseFlatCString(aURI);
const nsCString spec(aURI);
const char* specStr = spec.get();
PRUint32 pid;
return process->Run(PR_FALSE, &specStr, 1, &pid);

View File

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

View File

@ -21,6 +21,7 @@
* Contributor(s):
* Ben Goodger <ben@mozilla.org> (Original Author)
* Asaf Romano <mozilla.mano@sent.com>
* Benjamin Smedberg <benjamin@smedbergs.us>
*
* 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
@ -52,7 +53,7 @@
#include "nsMacShellService.h"
#include "nsNetUtil.h"
#include "nsShellService.h"
#include "nsString.h"
#include "nsStringAPI.h"
#include <CoreFoundation/CoreFoundation.h>
#include <Carbon/Carbon.h>
@ -468,7 +469,7 @@ nsMacShellService::OpenApplicationWithURI(nsILocalFile* aApplication, const nsAC
if (NS_FAILED(rv))
return rv;
const nsPromiseFlatCString& spec = PromiseFlatCString(aURI);
const nsCString spec(aURI);
const UInt8* uriString = (const UInt8*)spec.get();
CFURLRef uri = ::CFURLCreateWithBytes(NULL, uriString, aURI.Length(),
kCFStringEncodingUTF8, NULL);

View File

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

View File

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

View File

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

View File

@ -284,11 +284,18 @@ ifneq (,$(FORCE_SHARED_LIB)$(FORCE_USE_PIC))
_ENABLE_PIC=1
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,
# make sure that the entry points are translated and
# the module is built static.
ifdef IS_COMPONENT
ifdef EXPORT_LIBRARY
ifneq (,$(BUILD_STATIC_LIBS))
ifdef MODULE_NAME
DEFINES += -DXPCOM_TRANSLATE_NSGM_ENTRY_POINT=1
@ -296,6 +303,7 @@ FORCE_STATIC_LIB=1
endif
endif
endif
endif
# Determine if module being compiled is destined
# to be merged into libxul

View File

@ -347,11 +347,11 @@ endif
LOOP_OVER_DIRS = \
@$(EXIT_ON_ERROR) \
$(foreach dir,$(DIRS),$(UPDATE_TITLE) $(MAKE) -C $(dir) $@; )
$(foreach dir,$(DIRS),$(UPDATE_TITLE) $(MAKE) -C $(dir) $@; ) true
LOOP_OVER_TOOL_DIRS = \
@$(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
@ -571,13 +571,13 @@ STATIC_DIRS += $(foreach tier,$(TIERS),$(tier_$(tier)_staticdirs))
default all alldep::
$(EXIT_ON_ERROR) \
$(foreach tier,$(TIERS),$(MAKE) tier_$(tier); )
$(foreach tier,$(TIERS),$(MAKE) tier_$(tier); ) true
else
default all::
@$(EXIT_ON_ERROR) \
$(foreach dir,$(STATIC_DIRS),$(MAKE) -C $(dir); )
$(foreach dir,$(STATIC_DIRS),$(MAKE) -C $(dir); ) true
$(MAKE) export
$(MAKE) libs
$(MAKE) tools
@ -598,24 +598,24 @@ export_tier_%:
@echo "$@"
@$(MAKE_TIER_SUBMAKEFILES)
@$(EXIT_ON_ERROR) \
$(foreach dir,$(tier_$*_dirs),$(MAKE) -C $(dir) export; )
$(foreach dir,$(tier_$*_dirs),$(MAKE) -C $(dir) export; ) true
libs_tier_%:
@echo "$@"
@$(MAKE_TIER_SUBMAKEFILES)
@$(EXIT_ON_ERROR) \
$(foreach dir,$(tier_$*_dirs),$(MAKE) -C $(dir) libs; )
$(foreach dir,$(tier_$*_dirs),$(MAKE) -C $(dir) libs; ) true
tools_tier_%:
@echo "$@"
@$(MAKE_TIER_SUBMAKEFILES)
@$(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))::
@echo "$@: $($@_staticdirs) $($@_dirs)"
@$(EXIT_ON_ERROR) \
$(foreach dir,$($@_staticdirs),$(MAKE) -C $(dir); )
$(foreach dir,$($@_staticdirs),$(MAKE) -C $(dir); ) true
$(MAKE) export_$@
$(MAKE) libs_$@
@ -658,7 +658,7 @@ tools:: $(SUBMAKEFILES) $(MAKE_DIRS)
+$(LOOP_OVER_DIRS)
ifdef TOOL_DIRS
@$(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
#

View File

@ -342,7 +342,7 @@ static PRBool ns_strnimatch(const PRUnichar *aStr, const char* aSubstring,
if (!NS_IsAscii(*aStr))
return PR_FALSE;
if (NS_ToLower((char) *aStr) != *aSubstring)
if (NS_ToLower((char) *aStr) != NS_ToLower(*aSubstring))
return PR_FALSE;
}
@ -350,7 +350,7 @@ static PRBool ns_strnimatch(const PRUnichar *aStr, const char* aSubstring,
}
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) =
aIgnoreCase ? ns_strnimatch : ns_strnmatch;
@ -358,6 +358,9 @@ nsAString::Find(const char *aStr, PRBool aIgnoreCase) const
const char_type *begin, *end;
PRUint32 selflen = BeginReading(&begin, &end);
if (aOffset > selflen)
return -1;
PRUint32 otherlen = strlen(aStr);
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
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)) {
return cur - begin;
}
@ -682,7 +685,7 @@ nsACString::Find(const char_type *aStr, PRUint32 aLen, ComparatorFunc c) const
end -= aLen;
for (const char_type *cur = begin; cur <= end; ++cur) {
if (!c(begin, aStr, aLen))
if (!c(cur, aStr, aLen))
return cur - begin;
}
return -1;

View File

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