Skip to content

Commit

Permalink
Bug 389070 Port bookmarks to frozen linkage (Mechanical changes) r/sr…
Browse files Browse the repository at this point in the history
…=Neil

NPOTB for the firefox freeze.
  • Loading branch information
[email protected] committed Jul 28, 2007
1 parent de04e01 commit 4e5d516
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 30 deletions.
65 changes: 38 additions & 27 deletions xpfe/components/bookmarks/src/nsBookmarksService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@
#include "nsRDFCID.h"
#include "nsISupportsPrimitives.h"
#include "rdf.h"
#include "nsCRT.h"
#include "nsCRTGlue.h"
#include "nsEnumeratorUtils.h"
#include "nsEscape.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsDirectoryServiceDefs.h"
#include "nsDirectoryServiceUtils.h"
#include "nsUnicharUtils.h"

#include "nsISound.h"
Expand Down Expand Up @@ -97,6 +97,17 @@
#include "nsUnicharUtils.h"
#include "nsAutoBuffer.h"

// Tempoarary defines while we convert to the frozen API
#ifdef MOZILLA_INTERNAL_API
#include "nsEscape.h"
#define CaseInsensitiveCompare nsCaseInsensitiveStringComparator()
#endif

#if defined(XP_WIN) || defined(XP_OS2)
#define NS_LINEBREAK "\015\012"
#else
#define NS_LINEBREAK "\012"
#endif

#ifdef XP_WIN
#include <shlobj.h>
Expand Down Expand Up @@ -789,7 +800,7 @@ BookmarkParser::ProcessLine(nsIRDFContainer *container, nsIRDFResource *nodeType
rv = ParseMetaTag(line, getter_AddRefs(mUnicodeDecoder));
}
else if ((offset = line.Find(kOpenHeading, PR_TRUE)) >= 0 &&
nsCRT::IsAsciiDigit(line.CharAt(offset + 2)))
NS_IsAsciiDigit(line.CharAt(offset + 2)))
{
// XXX Ignore <H1> so that bookmarks root _is_ <H1>
if (line.CharAt(offset + 2) != PRUnichar('1'))
Expand Down Expand Up @@ -1078,7 +1089,7 @@ 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;

Expand Down Expand Up @@ -1128,7 +1139,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;
}
Expand Down Expand Up @@ -1161,7 +1172,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;
Expand Down Expand Up @@ -1418,7 +1429,7 @@ 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) {
Expand Down Expand Up @@ -1671,7 +1682,7 @@ nsBookmarksService::Init()

// determine what the name of the Personal Toolbar Folder is...
// first from user preference, then string bundle, then hard-coded default
nsXPIDLCString prefValue;
nsCString prefValue;
rv = prefBranch->GetCharPref("custtoolbar.personal_toolbar_folder", getter_Copies(prefValue));
if (NS_SUCCEEDED(rv) && !prefValue.IsEmpty())
{
Expand All @@ -1698,7 +1709,7 @@ nsBookmarksService::Init()
nsCOMPtr<nsIProfile> profileService(do_GetService(NS_PROFILE_CONTRACTID,&useProfile));
if (NS_SUCCEEDED(useProfile))
{
nsXPIDLString currentProfileName;
nsString currentProfileName;

useProfile = profileService->GetCurrentProfile(getter_Copies(currentProfileName));
if (NS_SUCCEEDED(useProfile))
Expand Down Expand Up @@ -2132,7 +2143,7 @@ nsBookmarksService::OnStopRequest(nsIRequest* request, nsISupports *ctxt,
currentETagLit->GetValueConst(&currentETagStr);
if ((currentETagStr) &&
!eTagValue.Equals(nsDependentString(currentETagStr),
nsCaseInsensitiveStringComparator()))
CaseInsensitiveCompare))
{
changedFlag = PR_TRUE;
}
Expand Down Expand Up @@ -2178,7 +2189,7 @@ nsBookmarksService::OnStopRequest(nsIRequest* request, nsISupports *ctxt,
currentLastModLit->GetValueConst(&currentLastModStr);
if ((currentLastModStr) &&
!lastModValue.Equals(nsDependentString(currentLastModStr),
nsCaseInsensitiveStringComparator()))
CaseInsensitiveCompare))
{
changedFlag = PR_TRUE;
}
Expand Down Expand Up @@ -2222,7 +2233,7 @@ nsBookmarksService::OnStopRequest(nsIRequest* request, nsISupports *ctxt,
currentContentLengthLit->GetValueConst(&currentContentLengthStr);
if ((currentContentLengthStr) &&
!contentLengthValue.Equals(nsDependentString(currentContentLengthStr),
nsCaseInsensitiveStringComparator()))
CaseInsensitiveCompare))
{
changedFlag = PR_TRUE;
}
Expand Down Expand Up @@ -2300,7 +2311,7 @@ nsBookmarksService::OnStopRequest(nsIRequest* request, nsISupports *ctxt,
// update icon?
if (FindInReadable(NS_LITERAL_STRING("icon"),
schedule,
nsCaseInsensitiveStringComparator()))
CaseInsensitiveCompare))
{
nsCOMPtr<nsIRDFLiteral> statusLiteral;
if (NS_SUCCEEDED(rv = gRDF->GetLiteral(NS_LITERAL_STRING("new").get(), getter_AddRefs(statusLiteral))))
Expand All @@ -2322,7 +2333,7 @@ nsBookmarksService::OnStopRequest(nsIRequest* request, nsISupports *ctxt,
// play a sound?
if (FindInReadable(NS_LITERAL_STRING("sound"),
schedule,
nsCaseInsensitiveStringComparator()))
CaseInsensitiveCompare))
{
nsCOMPtr<nsISound> soundInterface =
do_CreateInstance("@mozilla.org/sound;1", &rv);
Expand All @@ -2338,7 +2349,7 @@ nsBookmarksService::OnStopRequest(nsIRequest* request, nsISupports *ctxt,
// show an alert?
if (FindInReadable(NS_LITERAL_STRING("alert"),
schedule,
nsCaseInsensitiveStringComparator()))
CaseInsensitiveCompare))
{
nsCOMPtr<nsIPrompt> prompter;
NS_QueryNotificationCallbacks(channel, prompter);
Expand Down Expand Up @@ -2413,7 +2424,7 @@ nsBookmarksService::OnStopRequest(nsIRequest* request, nsISupports *ctxt,
if ((openURLFlag == PR_TRUE) ||
FindInReadable(NS_LITERAL_STRING("open"),
schedule,
nsCaseInsensitiveStringComparator()))
CaseInsensitiveCompare))
{
if (NS_SUCCEEDED(rv))
{
Expand All @@ -2433,7 +2444,7 @@ nsBookmarksService::OnStopRequest(nsIRequest* request, nsISupports *ctxt,

suppArray->AppendElement(suppString);

nsXPIDLCString chromeUrl;
nsCString chromeUrl;
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
if (NS_SUCCEEDED(rv))
{
Expand All @@ -2443,7 +2454,7 @@ nsBookmarksService::OnStopRequest(nsIRequest* request, nsISupports *ctxt,
{
chromeUrl.AssignLiteral("chrome://navigator/content/navigator.xul");
}
wwatch->OpenWindow(0, chromeUrl, "_blank",
wwatch->OpenWindow(0, chromeUrl.get(), "_blank",
"chrome,dialog=no,all", suppArray,
getter_AddRefs(newWindow));
}
Expand Down Expand Up @@ -2471,25 +2482,25 @@ 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()))
{
if (mBookmarksFile)
{
mBookmarksFile->Remove(PR_FALSE);
}
}
}
else if (mBookmarksFile && !nsCRT::strcmp(aTopic, "profile-after-change"))
else if (mBookmarksFile && !strcmp(aTopic, "profile-after-change"))
{
// The profile has already changed.
rv = LoadBookmarks();
}
else if (!nsCRT::strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID))
else if (!strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID))
{
rv = Flush();
if (NS_SUCCEEDED(rv))
Expand Down Expand Up @@ -2711,7 +2722,7 @@ nsBookmarksService::Compare(const void* aElement1, const void* aElement2, void*
else {
result = ::Compare(nsDependentString(value1),
nsDependentString(value2),
nsCaseInsensitiveStringComparator());
CaseInsensitiveCompare);
}

return result * sortInfo->mDirection;
Expand Down Expand Up @@ -3404,7 +3415,7 @@ nsBookmarksService::RequestCharset(nsIWebNavigation* aWebNavigation,
if (charsetLiteral) {
const PRUnichar* charset;
charsetLiteral->GetValueConst(&charset);
LossyCopyUTF16toASCII(charset, aResult);
LossyCopyUTF16toASCII(nsDependentString(charset), aResult);

return NS_OK;
}
Expand Down Expand Up @@ -3845,7 +3856,7 @@ nsBookmarksService::ParseFavoritesFolder(nsIFile* aDirectory, nsIRDFResource* aP
NS_NAMED_LITERAL_STRING(lnkExt, ".lnk");
PRInt32 lnkExtStart = bookmarkName.Length() - lnkExt.Length();
if (StringEndsWith(bookmarkName, lnkExt,
nsCaseInsensitiveStringComparator()))
CaseInsensitiveCompare))
bookmarkName.Truncate(lnkExtStart);

nsCOMPtr<nsIRDFResource> bookmark;
Expand Down Expand Up @@ -3984,7 +3995,7 @@ nsBookmarksService::GetTransactionManager(nsITransactionManager** aTransactionMa
NS_IMETHODIMP
nsBookmarksService::GetURI(char* *aURI)
{
*aURI = nsCRT::strdup("rdf:bookmarks");
*aURI = NS_strdup("rdf:bookmarks");
if (! *aURI)
return NS_ERROR_OUT_OF_MEMORY;

Expand Down Expand Up @@ -4817,7 +4828,7 @@ nsBookmarksService::exportBookmarks(nsISupportsArray *aArguments)
rv = NS_NewLocalFile(nsDependentString(pathUni), PR_TRUE, getter_AddRefs(file));
NS_ENSURE_SUCCESS(rv, rv);

if (NS_LITERAL_STRING("RDF").Equals(format, nsCaseInsensitiveStringComparator()))
if (NS_LITERAL_STRING("RDF").Equals(format, CaseInsensitiveCompare))
{
nsCOMPtr<nsIURI> uri;
nsresult rv = NS_NewFileURI(getter_AddRefs(uri), file);
Expand Down
6 changes: 3 additions & 3 deletions xpfe/components/bookmarks/src/nsBookmarksService.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#include "nsITimer.h"
#include "nsIRDFNode.h"
#include "nsIBookmarksService.h"
#include "nsString.h"
#include "nsStringGlue.h"
#include "nsIFile.h"
#include "nsIObserver.h"
#include "nsWeakReference.h"
Expand Down Expand Up @@ -93,8 +93,8 @@ class nsBookmarksService : public nsIBookmarksService,

PRUint32 htmlSize;
PRInt32 mUpdateBatchNest;
nsXPIDLString mPersonalToolbarName;
nsXPIDLString mBookmarksRootName;
nsString mPersonalToolbarName;
nsString mBookmarksRootName;
PRBool mDirty;
PRBool mBrowserIcons;
PRBool mAlwaysLoadIcons;
Expand Down

0 comments on commit 4e5d516

Please sign in to comment.