From 9405eda25697b5796c6a20f308d1b7382f22294b Mon Sep 17 00:00:00 2001 From: "cbiesinger%web.de" Date: Tue, 25 Feb 2003 19:02:00 +0000 Subject: [PATCH] 190020 r=timeless sr=alecf GetResource should take AUTF8String --- chrome/src/nsChromeRegistry.cpp | 49 +- chrome/src/nsChromeRegistry.h | 2 +- content/xul/content/src/nsXULElement.cpp | 2 +- content/xul/document/src/nsXULDocument.cpp | 16 +- .../xul/templates/src/nsXULContentUtils.cpp | 14 +- .../xul/templates/src/nsXULSortService.cpp | 28 +- .../templates/src/nsXULTemplateBuilder.cpp | 14 +- .../xul/templates/src/nsXULTreeBuilder.cpp | 5 +- .../addrbook/src/nsAbAddressCollecter.cpp | 2 +- .../addrbook/src/nsAbAutoCompleteSession.cpp | 11 +- .../addrbook/src/nsAbAutoCompleteSession.h | 2 +- mailnews/addrbook/src/nsAbCardProperty.cpp | 15 +- mailnews/addrbook/src/nsAbCardProperty.h | 2 +- mailnews/addrbook/src/nsAbLDAPDirFactory.cpp | 4 +- mailnews/addrbook/src/nsAbLDAPDirectory.cpp | 2 +- mailnews/addrbook/src/nsAbMDBDirFactory.cpp | 2 +- mailnews/addrbook/src/nsAbMDBDirectory.cpp | 9 +- mailnews/addrbook/src/nsAbView.cpp | 2 +- .../addrbook/src/nsAddbookProtocolHandler.cpp | 2 +- mailnews/addrbook/src/nsAddrDatabase.cpp | 2 +- mailnews/addrbook/src/nsAddressBook.cpp | 15 +- mailnews/addrbook/src/nsAddressBook.h | 2 +- .../addrbook/src/nsDirectoryDataSource.cpp | 32 +- .../base/search/src/nsMsgFilterDataSource.cpp | 8 +- .../search/src/nsMsgFilterDelegateFactory.cpp | 2 +- mailnews/base/search/src/nsMsgSearchTerm.cpp | 2 +- mailnews/base/src/nsMessenger.cpp | 27 +- mailnews/base/src/nsMessenger.h | 2 +- mailnews/base/src/nsMsgAccountManagerDS.cpp | 69 ++- mailnews/base/src/nsMsgFolderDataSource.cpp | 96 ++-- mailnews/base/src/nsMsgPurgeService.cpp | 2 +- mailnews/base/src/nsSubscribableServer.cpp | 14 +- mailnews/base/src/nsSubscribeDataSource.cpp | 17 +- mailnews/base/util/nsMsgFolder.cpp | 2 +- mailnews/base/util/nsMsgIdentity.cpp | 2 +- mailnews/base/util/nsMsgUtils.cpp | 4 +- mailnews/compose/src/nsMsgCompose.cpp | 8 +- mailnews/compose/src/nsMsgCompose.h | 2 +- mailnews/compose/src/nsMsgCopy.cpp | 2 +- mailnews/compose/src/nsMsgSend.cpp | 4 +- mailnews/compose/src/nsSmtpDataSource.cpp | 15 +- .../extensions/palmsync/src/nsAbIPCCard.cpp | 10 +- mailnews/imap/src/nsImapIncomingServer.cpp | 4 +- mailnews/imap/src/nsImapMailFolder.cpp | 8 +- mailnews/imap/src/nsImapMailFolder.h | 2 +- mailnews/imap/src/nsImapService.cpp | 2 +- mailnews/import/src/nsImportAddressBooks.cpp | 3 +- mailnews/local/src/nsLocalMailFolder.cpp | 4 +- mailnews/local/src/nsMailboxService.cpp | 2 +- mailnews/local/src/nsParseMailbox.cpp | 4 +- mailnews/local/src/nsParseMailbox.h | 2 +- mailnews/local/src/nsPop3Service.cpp | 2 +- mailnews/news/src/nsNewsFolder.cpp | 2 +- mailnews/news/src/nsNntpService.cpp | 4 +- rdf/base/idl/nsIRDFService.idl | 4 +- rdf/base/src/nsContainerEnumerator.cpp | 2 +- rdf/base/src/nsRDFContainer.cpp | 5 +- rdf/base/src/nsRDFContainerUtils.cpp | 30 +- rdf/base/src/nsRDFContentSink.cpp | 32 +- rdf/base/src/nsRDFService.cpp | 83 +-- rdf/base/src/nsRDFXMLSerializer.cpp | 18 +- rdf/chrome/src/nsChromeRegistry.cpp | 49 +- rdf/chrome/src/nsChromeRegistry.h | 2 +- rdf/datasource/src/nsFileSystemDataSource.cpp | 61 +- .../exthandler/nsExternalHelperAppService.cpp | 35 +- .../bookmarks/src/nsBookmarksService.cpp | 163 ++++-- .../directory/nsDirectoryViewer.cpp | 35 +- .../src/nsDownloadManager.cpp | 30 +- .../history/src/nsGlobalHistory.cpp | 531 +++++++++++++++++- xpfe/components/intl/nsCharsetMenu.cpp | 58 +- .../related/src/nsRelatedLinksHandler.cpp | 36 +- .../search/src/nsInternetSearchService.cpp | 167 ++++-- .../search/src/nsLocalSearchService.cpp | 23 +- .../urlbarhistory/src/nsUrlbarHistory.cpp | 5 +- .../windowds/nsWindowDataSource.cpp | 11 +- 75 files changed, 1311 insertions(+), 630 deletions(-) diff --git a/chrome/src/nsChromeRegistry.cpp b/chrome/src/nsChromeRegistry.cpp index e6886d573b9f..e7d923430c95 100644 --- a/chrome/src/nsChromeRegistry.cpp +++ b/chrome/src/nsChromeRegistry.cpp @@ -326,49 +326,64 @@ nsChromeRegistry::Init() (nsISupports**)&mRDFContainerUtils); NS_ENSURE_SUCCESS(rv, rv); - rv = mRDFService->GetResource(kURICHROME_selectedSkin, getter_AddRefs(mSelectedSkin)); + rv = mRDFService->GetResource(nsDependentCString(kURICHROME_selectedSkin), + getter_AddRefs(mSelectedSkin)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource"); - rv = mRDFService->GetResource(kURICHROME_selectedLocale, getter_AddRefs(mSelectedLocale)); + rv = mRDFService->GetResource(nsDependentCString(kURICHROME_selectedLocale), + getter_AddRefs(mSelectedLocale)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource"); - rv = mRDFService->GetResource(kURICHROME_baseURL, getter_AddRefs(mBaseURL)); + rv = mRDFService->GetResource(nsDependentCString(kURICHROME_baseURL), + getter_AddRefs(mBaseURL)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource"); - rv = mRDFService->GetResource(kURICHROME_packages, getter_AddRefs(mPackages)); + rv = mRDFService->GetResource(nsDependentCString(kURICHROME_packages), + getter_AddRefs(mPackages)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource"); - rv = mRDFService->GetResource(kURICHROME_package, getter_AddRefs(mPackage)); + rv = mRDFService->GetResource(nsDependentCString(kURICHROME_package), + getter_AddRefs(mPackage)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource"); - rv = mRDFService->GetResource(kURICHROME_name, getter_AddRefs(mName)); + rv = mRDFService->GetResource(nsDependentCString(kURICHROME_name), + getter_AddRefs(mName)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource"); - rv = mRDFService->GetResource(kURICHROME_image, getter_AddRefs(mImage)); + rv = mRDFService->GetResource(nsDependentCString(kURICHROME_image), + getter_AddRefs(mImage)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource"); - rv = mRDFService->GetResource(kURICHROME_locType, getter_AddRefs(mLocType)); + rv = mRDFService->GetResource(nsDependentCString(kURICHROME_locType), + getter_AddRefs(mLocType)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource"); - rv = mRDFService->GetResource(kURICHROME_allowScripts, getter_AddRefs(mAllowScripts)); + rv = mRDFService->GetResource(nsDependentCString(kURICHROME_allowScripts), + getter_AddRefs(mAllowScripts)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource"); - rv = mRDFService->GetResource(kURICHROME_hasOverlays, getter_AddRefs(mHasOverlays)); + rv = mRDFService->GetResource(nsDependentCString(kURICHROME_hasOverlays), + getter_AddRefs(mHasOverlays)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource"); - rv = mRDFService->GetResource(kURICHROME_hasStylesheets, getter_AddRefs(mHasStylesheets)); + rv = mRDFService->GetResource(nsDependentCString(kURICHROME_hasStylesheets), + getter_AddRefs(mHasStylesheets)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource"); - rv = mRDFService->GetResource(kURICHROME_skinVersion, getter_AddRefs(mSkinVersion)); + rv = mRDFService->GetResource(nsDependentCString(kURICHROME_skinVersion), + getter_AddRefs(mSkinVersion)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource"); - rv = mRDFService->GetResource(kURICHROME_localeVersion, getter_AddRefs(mLocaleVersion)); + rv = mRDFService->GetResource(nsDependentCString(kURICHROME_localeVersion), + getter_AddRefs(mLocaleVersion)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource"); - rv = mRDFService->GetResource(kURICHROME_packageVersion, getter_AddRefs(mPackageVersion)); + rv = mRDFService->GetResource(nsDependentCString(kURICHROME_packageVersion), + getter_AddRefs(mPackageVersion)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource"); - rv = mRDFService->GetResource(kURICHROME_disabled, getter_AddRefs(mDisabled)); + rv = mRDFService->GetResource(nsDependentCString(kURICHROME_disabled), + getter_AddRefs(mDisabled)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource"); nsCOMPtr observerService = @@ -1251,11 +1266,11 @@ nsChromeRegistry::LoadDataSource(const nsACString &aFileName, //////////////////////////////////////////////////////////////////////////////// nsresult -nsChromeRegistry::GetResource(const nsCString& aURL, +nsChromeRegistry::GetResource(const nsACString& aURL, nsIRDFResource** aResult) { nsresult rv = NS_OK; - if (NS_FAILED(rv = mRDFService->GetResource(aURL.get(), aResult))) { + if (NS_FAILED(rv = mRDFService->GetResource(aURL, aResult))) { NS_ERROR("Unable to retrieve a resource for this URL."); *aResult = nsnull; return rv; diff --git a/chrome/src/nsChromeRegistry.h b/chrome/src/nsChromeRegistry.h index c6a9e448cfaf..feb861dd1057 100644 --- a/chrome/src/nsChromeRegistry.h +++ b/chrome/src/nsChromeRegistry.h @@ -93,7 +93,7 @@ protected: nsresult GetDynamicDataSource(nsIURI *aChromeURL, PRBool aIsOverlay, PRBool aUseProfile, PRBool aCreateDS, nsIRDFDataSource **aResult); nsresult GetDynamicInfo(nsIURI *aChromeURL, PRBool aIsOverlay, nsISimpleEnumerator **aResult); - nsresult GetResource(const nsCString& aChromeType, nsIRDFResource** aResult); + nsresult GetResource(const nsACString& aChromeType, nsIRDFResource** aResult); nsresult UpdateDynamicDataSource(nsIRDFDataSource *aDataSource, nsIRDFResource *aResource, diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp index 99905a79a37e..28a506615dcf 100644 --- a/content/xul/content/src/nsXULElement.cpp +++ b/content/xul/content/src/nsXULElement.cpp @@ -3448,7 +3448,7 @@ nsXULElement::GetResource(nsIRDFResource** aResource) } if (rv == NS_CONTENT_ATTR_HAS_VALUE) { - rv = gRDFService->GetUnicodeResource(id.get(), aResource); + rv = gRDFService->GetUnicodeResource(id, aResource); if (NS_FAILED(rv)) return rv; } else { diff --git a/content/xul/document/src/nsXULDocument.cpp b/content/xul/document/src/nsXULDocument.cpp index c028c8a84096..c3ce9575fa78 100644 --- a/content/xul/document/src/nsXULDocument.cpp +++ b/content/xul/document/src/nsXULDocument.cpp @@ -3076,7 +3076,8 @@ nsXULDocument::Persist(nsIContent* aElement, PRInt32 aNameSpaceID, if (NS_FAILED(rv)) return rv; nsCOMPtr attr; - rv = gRDFService->GetResource(NS_LossyConvertUCS2toASCII(attrstr).get(), getter_AddRefs(attr)); + rv = gRDFService->GetUnicodeResource(nsDependentString(attrstr), + getter_AddRefs(attr)); if (NS_FAILED(rv)) return rv; // Turn the value into a literal @@ -3124,7 +3125,7 @@ nsXULDocument::Persist(nsIContent* aElement, PRInt32 aNameSpaceID, if (NS_FAILED(rv)) return rv; nsCOMPtr doc; - rv = gRDFService->GetResource(docurl.get(), getter_AddRefs(doc)); + rv = gRDFService->GetResource(docurl, getter_AddRefs(doc)); if (NS_FAILED(rv)) return rv; PRBool hasAssertion; @@ -4416,9 +4417,12 @@ nsXULDocument::Init() NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF Service"); if (NS_FAILED(rv)) return rv; - gRDFService->GetResource(NC_NAMESPACE_URI "persist", &kNC_persist); - gRDFService->GetResource(NC_NAMESPACE_URI "attribute", &kNC_attribute); - gRDFService->GetResource(NC_NAMESPACE_URI "value", &kNC_value); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "persist"), + &kNC_persist); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "attribute"), + &kNC_attribute); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "value"), + &kNC_value); rv = CallCreateInstance(kHTMLElementFactoryCID, &gHTMLElementFactory); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get HTML element factory"); @@ -4900,7 +4904,7 @@ nsXULDocument::ApplyPersistentAttributes() mDocumentURL->GetSpec(docurl); nsCOMPtr doc; - gRDFService->GetResource(docurl.get(), getter_AddRefs(doc)); + gRDFService->GetResource(docurl, getter_AddRefs(doc)); nsCOMPtr persisted; mLocalStore->GetTargets(doc, kNC_persist, PR_TRUE, getter_AddRefs(persisted)); diff --git a/content/xul/templates/src/nsXULContentUtils.cpp b/content/xul/templates/src/nsXULContentUtils.cpp index fec74049a621..9fb9f95c89ac 100644 --- a/content/xul/templates/src/nsXULContentUtils.cpp +++ b/content/xul/templates/src/nsXULContentUtils.cpp @@ -100,10 +100,10 @@ nsXULContentUtils::Init() return rv; } -#define XUL_RESOURCE(ident, uri) \ - PR_BEGIN_MACRO \ - rv = gRDF->GetResource((uri), &(ident)); \ - if (NS_FAILED(rv)) return rv; \ +#define XUL_RESOURCE(ident, uri) \ + PR_BEGIN_MACRO \ + rv = gRDF->GetResource(NS_LITERAL_CSTRING(uri), &(ident)); \ + if (NS_FAILED(rv)) return rv; \ PR_END_MACRO #define XUL_LITERAL(ident, val) \ @@ -253,7 +253,7 @@ nsXULContentUtils::GetElementRefResource(nsIContent* aElement, nsIRDFResource** // the protocol), uriStr will be untouched. NS_MakeAbsoluteURI(uri, uri, url); - rv = gRDF->GetUnicodeResource(uri.get(), aResult); + rv = gRDF->GetUnicodeResource(uri, aResult); } else { rv = GetElementResource(aElement, aResult); @@ -391,7 +391,7 @@ nsXULContentUtils::MakeElementResource(nsIDocument* aDocument, const nsAString& rv = MakeElementURI(aDocument, aID, uri); if (NS_FAILED(rv)) return rv; - rv = gRDF->GetResource(uri.get(), aResult); + rv = gRDF->GetResource(uri, aResult); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create resource"); if (NS_FAILED(rv)) return rv; @@ -475,7 +475,7 @@ nsXULContentUtils::GetResource(PRInt32 aNameSpaceID, const nsAString& aAttribute uri.Append(aAttribute); - rv = gRDF->GetUnicodeResource(uri.get(), aResult); + rv = gRDF->GetUnicodeResource(uri, aResult); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource"); if (NS_FAILED(rv)) return rv; diff --git a/content/xul/templates/src/nsXULSortService.cpp b/content/xul/templates/src/nsXULSortService.cpp index aebc1d969307..252080fae265 100644 --- a/content/xul/templates/src/nsXULSortService.cpp +++ b/content/xul/templates/src/nsXULSortService.cpp @@ -808,7 +808,7 @@ XULSortServiceImpl::GetNodeValue(nsIContent *node1, sortPtr sortInfo, PRBool fir if (NS_SUCCEEDED(rv = node1->GetAttr(kNameSpaceID_None, nsXULAtoms::id, htmlID)) && (rv == NS_CONTENT_ATTR_HAS_VALUE)) { - if (NS_FAILED(rv = gRDFService->GetUnicodeResource(htmlID.get(), getter_AddRefs(res1)))) + if (NS_FAILED(rv = gRDFService->GetUnicodeResource(htmlID, getter_AddRefs(res1)))) res1 = nsnull; } } @@ -886,7 +886,7 @@ XULSortServiceImpl::GetNodeValue(contentSortInfo *info1, sortPtr sortInfo, PRBoo if (NS_SUCCEEDED(rv = node1->GetAttr(kNameSpaceID_None, nsXULAtoms::id, htmlID)) && (rv == NS_CONTENT_ATTR_HAS_VALUE)) { - if (NS_FAILED(rv = gRDFService->GetUnicodeResource(htmlID.get(), getter_AddRefs(res1)))) + if (NS_FAILED(rv = gRDFService->GetUnicodeResource(htmlID, getter_AddRefs(res1)))) res1 = nsnull; info1->resource = res1; } @@ -1333,38 +1333,38 @@ XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsRDFSort sortState->sortPropertySort = nsnull; sortState->sortPropertySort2 = nsnull; - rv = gRDFService->GetUnicodeResource(sortResource.get(), getter_AddRefs(sortInfo.sortProperty)); + rv = gRDFService->GetUnicodeResource(sortResource, getter_AddRefs(sortInfo.sortProperty)); if (NS_FAILED(rv)) return rv; sortState->sortResource = sortResource; sortState->sortProperty = sortInfo.sortProperty; nsAutoString resourceUrl = sortResource; resourceUrl.Append(NS_LITERAL_STRING("?collation=true")); - rv = gRDFService->GetUnicodeResource(resourceUrl.get(), getter_AddRefs(sortInfo.sortPropertyColl)); + rv = gRDFService->GetUnicodeResource(resourceUrl, getter_AddRefs(sortInfo.sortPropertyColl)); if (NS_FAILED(rv)) return rv; sortState->sortPropertyColl = sortInfo.sortPropertyColl; resourceUrl = sortResource; resourceUrl.Append(NS_LITERAL_STRING("?sort=true")); - rv = gRDFService->GetUnicodeResource(resourceUrl.get(), getter_AddRefs(sortInfo.sortPropertySort)); + rv = gRDFService->GetUnicodeResource(resourceUrl, getter_AddRefs(sortInfo.sortPropertySort)); if (NS_FAILED(rv)) return rv; sortState->sortPropertySort = sortInfo.sortPropertySort; if (!sortResource2.IsEmpty()) { - rv = gRDFService->GetUnicodeResource(sortResource2.get(), getter_AddRefs(sortInfo.sortProperty2)); + rv = gRDFService->GetUnicodeResource(sortResource2, getter_AddRefs(sortInfo.sortProperty2)); if (NS_FAILED(rv)) return rv; sortState->sortResource2 = sortResource2; sortState->sortProperty2 = sortInfo.sortProperty2; resourceUrl = sortResource2; resourceUrl.Append(NS_LITERAL_STRING("?collation=true")); - rv = gRDFService->GetUnicodeResource(resourceUrl.get(), getter_AddRefs(sortInfo.sortPropertyColl2)); + rv = gRDFService->GetUnicodeResource(resourceUrl, getter_AddRefs(sortInfo.sortPropertyColl2)); if (NS_FAILED(rv)) return rv; sortState->sortPropertyColl2 = sortInfo.sortPropertyColl2; resourceUrl = sortResource2; resourceUrl.Append(NS_LITERAL_STRING("?sort=true")); - rv = gRDFService->GetUnicodeResource(resourceUrl.get(), getter_AddRefs(sortInfo.sortPropertySort2)); + rv = gRDFService->GetUnicodeResource(resourceUrl, getter_AddRefs(sortInfo.sortPropertySort2)); if (NS_FAILED(rv)) return rv; sortState->sortPropertySort2 = sortInfo.sortPropertySort2; } @@ -1625,33 +1625,33 @@ XULSortServiceImpl::Sort(nsIDOMNode* node, const nsAString& sortResource, const GetSortColumnInfo(contentNode, unused, unused, sortResource2, sortInfo.inbetweenSeparatorSort); // build resource url for first sort resource - rv = gRDFService->GetUnicodeResource(PromiseFlatString(sortResource).get(), getter_AddRefs(sortInfo.sortProperty)); + rv = gRDFService->GetUnicodeResource(sortResource, getter_AddRefs(sortInfo.sortProperty)); if (NS_FAILED(rv)) return rv; nsAutoString resourceUrl; resourceUrl.Assign(sortResource); resourceUrl.Append(NS_LITERAL_STRING("?collation=true")); - rv = gRDFService->GetUnicodeResource(resourceUrl.get(), getter_AddRefs(sortInfo.sortPropertyColl)); + rv = gRDFService->GetUnicodeResource(resourceUrl, getter_AddRefs(sortInfo.sortPropertyColl)); if (NS_FAILED(rv)) return rv; resourceUrl.Assign(sortResource); resourceUrl.Append(NS_LITERAL_STRING("?sort=true")); - rv = gRDFService->GetUnicodeResource(resourceUrl.get(), getter_AddRefs(sortInfo.sortPropertySort)); + rv = gRDFService->GetUnicodeResource(resourceUrl, getter_AddRefs(sortInfo.sortPropertySort)); if (NS_FAILED(rv)) return rv; // build resource url for second sort resource if (!sortResource2.IsEmpty()) { - rv = gRDFService->GetUnicodeResource(sortResource2.get(), getter_AddRefs(sortInfo.sortProperty2)); + rv = gRDFService->GetUnicodeResource(sortResource2, getter_AddRefs(sortInfo.sortProperty2)); if (NS_FAILED(rv)) return rv; resourceUrl = sortResource2; resourceUrl.Append(NS_LITERAL_STRING("?collation=true")); - rv = gRDFService->GetUnicodeResource(resourceUrl.get(), getter_AddRefs(sortInfo.sortPropertyColl2)); + rv = gRDFService->GetUnicodeResource(resourceUrl, getter_AddRefs(sortInfo.sortPropertyColl2)); if (NS_FAILED(rv)) return rv; resourceUrl = sortResource2; resourceUrl.Append(NS_LITERAL_STRING("?sort=true")); - rv = gRDFService->GetUnicodeResource(resourceUrl.get(), getter_AddRefs(sortInfo.sortPropertySort2)); + rv = gRDFService->GetUnicodeResource(resourceUrl, getter_AddRefs(sortInfo.sortPropertySort2)); if (NS_FAILED(rv)) return rv; } diff --git a/content/xul/templates/src/nsXULTemplateBuilder.cpp b/content/xul/templates/src/nsXULTemplateBuilder.cpp index 86af7b25bc37..bdd7d625b37d 100644 --- a/content/xul/templates/src/nsXULTemplateBuilder.cpp +++ b/content/xul/templates/src/nsXULTemplateBuilder.cpp @@ -1317,7 +1317,7 @@ nsXULTemplateBuilder::ComputeContainmentProperties() containment.Mid(propertyStr, offset, end - offset); nsCOMPtr property; - rv = gRDFService->GetUnicodeResource(propertyStr.get(), getter_AddRefs(property)); + rv = gRDFService->GetUnicodeResource(propertyStr, getter_AddRefs(property)); if (NS_FAILED(rv)) return rv; rv = mContainmentProperties.Add(property); @@ -1797,7 +1797,7 @@ nsXULTemplateBuilder::CompileTripleCondition(nsTemplateRule* aRule, if (subject[0] == PRUnichar('?')) svar = mRules.LookupSymbol(subject.get(), PR_TRUE); else - gRDFService->GetUnicodeResource(subject.get(), getter_AddRefs(sres)); + gRDFService->GetUnicodeResource(subject, getter_AddRefs(sres)); // predicate nsAutoString predicate; @@ -1811,7 +1811,7 @@ nsXULTemplateBuilder::CompileTripleCondition(nsTemplateRule* aRule, return NS_OK; } else { - gRDFService->GetUnicodeResource(predicate.get(), getter_AddRefs(pres)); + gRDFService->GetUnicodeResource(predicate, getter_AddRefs(pres)); } // object @@ -1826,7 +1826,7 @@ nsXULTemplateBuilder::CompileTripleCondition(nsTemplateRule* aRule, else if (object.FindChar(':') != -1) { // XXXwaterson evil. // treat as resource nsCOMPtr resource; - gRDFService->GetUnicodeResource(object.get(), getter_AddRefs(resource)); + gRDFService->GetUnicodeResource(object, getter_AddRefs(resource)); onode = do_QueryInterface(resource); } else { @@ -2010,7 +2010,7 @@ nsXULTemplateBuilder::CompileBinding(nsTemplateRule* aRule, return NS_OK; } else { - gRDFService->GetUnicodeResource(predicate.get(), getter_AddRefs(pred)); + gRDFService->GetUnicodeResource(predicate, getter_AddRefs(pred)); } // object @@ -2144,7 +2144,7 @@ nsXULTemplateBuilder::CompileSimpleRule(nsIContent* aRuleElement, nsCOMPtr target; if (value.FindChar(':') != -1) { // XXXwaterson WRONG WRONG WRONG! nsCOMPtr resource; - rv = gRDFService->GetUnicodeResource(value.get(), getter_AddRefs(resource)); + rv = gRDFService->GetUnicodeResource(value, getter_AddRefs(resource)); if (NS_FAILED(rv)) return rv; target = do_QueryInterface(resource); @@ -2285,7 +2285,7 @@ nsXULTemplateBuilder::AddBindingsFor(nsXULTemplateBuilder* aThis, const nsAString& propertyStr = Substring(aVariable, PRUint32(4), aVariable.Length() - 4); nsCOMPtr property; - gRDFService->GetUnicodeResource(nsAutoString(propertyStr).get(), getter_AddRefs(property)); + gRDFService->GetUnicodeResource(propertyStr, getter_AddRefs(property)); if (! rule->HasBinding(aThis->mMemberVar, property, var)) // In the simple syntax, the binding is always from the diff --git a/content/xul/templates/src/nsXULTreeBuilder.cpp b/content/xul/templates/src/nsXULTreeBuilder.cpp index d8d16f8083a5..56a0af4358e6 100644 --- a/content/xul/templates/src/nsXULTreeBuilder.cpp +++ b/content/xul/templates/src/nsXULTreeBuilder.cpp @@ -331,8 +331,9 @@ nsXULTreeBuilder::Init() if (NS_FAILED(rv)) return rv; if (gRefCnt++ == 0) { - gRDFService->GetResource(RDF_NAMESPACE_URI "type", &kRDF_type); - gRDFService->GetResource(NC_NAMESPACE_URI "BookmarkSeparator", &kNC_BookmarkSeparator); + gRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "type"), &kRDF_type); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "BookmarkSeparator"), + &kNC_BookmarkSeparator); } // Try to acquire a collation object for sorting diff --git a/mailnews/addrbook/src/nsAbAddressCollecter.cpp b/mailnews/addrbook/src/nsAbAddressCollecter.cpp index 3746c360b44b..ab02c8641ea4 100644 --- a/mailnews/addrbook/src/nsAbAddressCollecter.cpp +++ b/mailnews/addrbook/src/nsAbAddressCollecter.cpp @@ -344,7 +344,7 @@ nsresult nsAbAddressCollecter::SetAbURI(const char *aURI) NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr resource; - rv = rdfService->GetResource(m_abURI.get(), getter_AddRefs(resource)); + rv = rdfService->GetResource(m_abURI, getter_AddRefs(resource)); NS_ENSURE_SUCCESS(rv, rv); m_directory = do_QueryInterface(resource, &rv); diff --git a/mailnews/addrbook/src/nsAbAutoCompleteSession.cpp b/mailnews/addrbook/src/nsAbAutoCompleteSession.cpp index 44fbf6d29444..c9209fac15bb 100644 --- a/mailnews/addrbook/src/nsAbAutoCompleteSession.cpp +++ b/mailnews/addrbook/src/nsAbAutoCompleteSession.cpp @@ -570,10 +570,10 @@ nsAbAutoCompleteSession::SearchReplicatedLDAPDirectories(nsIPref *aPref, nsAbAut URI = NS_LITERAL_CSTRING("moz-abmdbdirectory://") + fileName; // and then search the replicated directory - return SearchDirectory(URI.get(), searchStr, searchSubDirectory, results); + return SearchDirectory(URI, searchStr, searchSubDirectory, results); } -nsresult nsAbAutoCompleteSession::SearchDirectory(const char *aURI, nsAbAutoCompleteSearchString* searchStr, PRBool searchSubDirectory, nsIAutoCompleteResults* results) +nsresult nsAbAutoCompleteSession::SearchDirectory(const nsACString& aURI, nsAbAutoCompleteSearchString* searchStr, PRBool searchSubDirectory, nsIAutoCompleteResults* results) { nsresult rv = NS_OK; nsCOMPtr rdfService(do_GetService("@mozilla.org/rdf/rdf-service;1", &rv)); @@ -598,7 +598,7 @@ nsresult nsAbAutoCompleteSession::SearchDirectory(const char *aURI, nsAbAutoComp if (!searchDuringLocalAutocomplete) return NS_OK; - if (nsCRT::strcmp(kAllDirectoryRoot, aURI)) + if (!aURI.Equals(NS_LITERAL_CSTRING(kAllDirectoryRoot))) rv = SearchCards(directory, searchStr, results); if (!searchSubDirectory) @@ -622,7 +622,7 @@ nsresult nsAbAutoCompleteSession::SearchDirectory(const char *aURI, nsAbAutoComp { nsXPIDLCString URI; subResource->GetValue(getter_Copies(URI)); - rv = SearchDirectory(URI.get(), searchStr, PR_TRUE, results); + rv = SearchDirectory(URI, searchStr, PR_TRUE, results); } } } @@ -746,7 +746,8 @@ NS_IMETHODIMP nsAbAutoCompleteSession::OnStartLookup(const PRUnichar *uSearchStr nsresult rv1,rv2; if (enableLocalAutocomplete) { - rv1 = SearchDirectory(kAllDirectoryRoot, &searchStrings, PR_TRUE, results); + rv1 = SearchDirectory(NS_LITERAL_CSTRING(kAllDirectoryRoot), &searchStrings, + PR_TRUE, results); NS_ASSERTION(NS_SUCCEEDED(rv1), "searching all local directories failed"); } else diff --git a/mailnews/addrbook/src/nsAbAutoCompleteSession.h b/mailnews/addrbook/src/nsAbAutoCompleteSession.h index 048ffba7be78..3a38eeda65bc 100644 --- a/mailnews/addrbook/src/nsAbAutoCompleteSession.h +++ b/mailnews/addrbook/src/nsAbAutoCompleteSession.h @@ -127,7 +127,7 @@ private: #define MAX_NUMBER_OF_EMAIL_ADDRESSES 2 nsresult SearchCards(nsIAbDirectory* directory, nsAbAutoCompleteSearchString* searchStr, nsIAutoCompleteResults* results); - nsresult SearchDirectory(const char *aURI, nsAbAutoCompleteSearchString* searchStr, PRBool searchSubDirectory, nsIAutoCompleteResults* results); + nsresult SearchDirectory(const nsACString& aURI, nsAbAutoCompleteSearchString* searchStr, PRBool searchSubDirectory, nsIAutoCompleteResults* results); nsresult SearchPreviousResults(nsAbAutoCompleteSearchString *uSearchString, nsIAutoCompleteResults *previousSearchResult, nsIAutoCompleteResults* results); nsresult SearchReplicatedLDAPDirectories(nsIPref *aPrefs, nsAbAutoCompleteSearchString* searchStr, PRBool searchSubDirectory, nsIAutoCompleteResults* results); diff --git a/mailnews/addrbook/src/nsAbCardProperty.cpp b/mailnews/addrbook/src/nsAbCardProperty.cpp index ce261ebd3ee2..d52a5475fc10 100644 --- a/mailnews/addrbook/src/nsAbCardProperty.cpp +++ b/mailnews/addrbook/src/nsAbCardProperty.cpp @@ -123,12 +123,10 @@ nsAbCardProperty::nsAbCardProperty(void) m_PreferMailFormat = nsIAbPreferMailFormat::unknown; m_IsMailList = PR_FALSE; - m_MailListURI = nsnull; } nsAbCardProperty::~nsAbCardProperty(void) { - CRTFREEIF(m_MailListURI); } NS_IMPL_ISUPPORTS1(nsAbCardProperty, nsIAbCard) @@ -185,12 +183,10 @@ NS_IMETHODIMP nsAbCardProperty::GetMailListURI(char **aMailListURI) { if (aMailListURI) { - if (m_MailListURI) - *aMailListURI = nsCRT::strdup(m_MailListURI); - else - *aMailListURI = nsCRT::strdup(""); - - return NS_OK; + *aMailListURI = ToNewCString(m_MailListURI); + if (*aMailListURI) + return NS_OK; + return NS_ERROR_OUT_OF_MEMORY; } else return NS_ERROR_NULL_POINTER; @@ -200,8 +196,7 @@ NS_IMETHODIMP nsAbCardProperty::SetMailListURI(const char *aMailListURI) { if (aMailListURI) { - nsCRT::free (m_MailListURI); - m_MailListURI = nsCRT::strdup(aMailListURI); + m_MailListURI = aMailListURI; return NS_OK; } else diff --git a/mailnews/addrbook/src/nsAbCardProperty.h b/mailnews/addrbook/src/nsAbCardProperty.h index f5baee2ee9d0..f6dc30a21142 100644 --- a/mailnews/addrbook/src/nsAbCardProperty.h +++ b/mailnews/addrbook/src/nsAbCardProperty.h @@ -129,7 +129,7 @@ protected: PRUint32 m_PreferMailFormat; PRBool m_IsMailList; - char* m_MailListURI; + nsCString m_MailListURI; private: nsresult AppendData(const char *aAttrName, mozITXTToHTMLConv *aConv, nsString &aResult); diff --git a/mailnews/addrbook/src/nsAbLDAPDirFactory.cpp b/mailnews/addrbook/src/nsAbLDAPDirFactory.cpp index d9a7575cb1cd..890e8692a7e6 100644 --- a/mailnews/addrbook/src/nsAbLDAPDirFactory.cpp +++ b/mailnews/addrbook/src/nsAbLDAPDirFactory.cpp @@ -112,10 +112,10 @@ NS_IMETHODIMP nsAbLDAPDirFactory::CreateDirectory(nsIAbDirectoryProperties *aPro */ nsCAutoString bridgeURI; bridgeURI = NS_LITERAL_CSTRING(kLDAPDirectoryRoot) + prefName; - rv = rdf->GetResource(bridgeURI.get(), getter_AddRefs(resource)); + rv = rdf->GetResource(bridgeURI, getter_AddRefs(resource)); } else { - rv = rdf->GetResource(uri.get(), getter_AddRefs(resource)); + rv = rdf->GetResource(uri, getter_AddRefs(resource)); } NS_ENSURE_SUCCESS(rv, rv); diff --git a/mailnews/addrbook/src/nsAbLDAPDirectory.cpp b/mailnews/addrbook/src/nsAbLDAPDirectory.cpp index 534f87d8b612..e3f3a849a6f9 100644 --- a/mailnews/addrbook/src/nsAbLDAPDirectory.cpp +++ b/mailnews/addrbook/src/nsAbLDAPDirectory.cpp @@ -226,7 +226,7 @@ NS_IMETHODIMP nsAbLDAPDirectory::GetChildCards(nsIEnumerator** result) localDirectoryURI = NS_LITERAL_CSTRING("moz-abmdbdirectory://") + fileName + NS_LITERAL_CSTRING("?") + mQueryString; nsCOMPtr resource; - rv = rdfService->GetResource(localDirectoryURI.get(), getter_AddRefs(resource)); + rv = rdfService->GetResource(localDirectoryURI, getter_AddRefs(resource)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr directory = do_QueryInterface(resource, &rv); diff --git a/mailnews/addrbook/src/nsAbMDBDirFactory.cpp b/mailnews/addrbook/src/nsAbMDBDirFactory.cpp index 993c21483491..4ea5d95b55d2 100644 --- a/mailnews/addrbook/src/nsAbMDBDirFactory.cpp +++ b/mailnews/addrbook/src/nsAbMDBDirFactory.cpp @@ -119,7 +119,7 @@ NS_IMETHODIMP nsAbMDBDirFactory::CreateDirectory(nsIAbDirectoryProperties *aProp NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr resource; - rv = rdf->GetResource(uri.get(), getter_AddRefs(resource)); + rv = rdf->GetResource(uri, getter_AddRefs(resource)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr directory(do_QueryInterface(resource, &rv)); diff --git a/mailnews/addrbook/src/nsAbMDBDirectory.cpp b/mailnews/addrbook/src/nsAbMDBDirectory.cpp index 8b980e068acd..bc06b1747805 100644 --- a/mailnews/addrbook/src/nsAbMDBDirectory.cpp +++ b/mailnews/addrbook/src/nsAbMDBDirectory.cpp @@ -320,7 +320,7 @@ NS_IMETHODIMP nsAbMDBDirectory::AddDirectory(const char *uriName, nsIAbDirectory NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr res; - rv = rdf->GetResource(uriName, getter_AddRefs(res)); + rv = rdf->GetResource(nsDependentCString(uriName), getter_AddRefs(res)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr directory(do_QueryInterface(res, &rv)); @@ -438,7 +438,7 @@ NS_IMETHODIMP nsAbMDBDirectory::DeleteCards(nsISupportsArray *cards) NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr resource; - rv = gRDFService->GetResource(mURINoQuery.get(), getter_AddRefs(resource)); + rv = gRDFService->GetResource(mURINoQuery, getter_AddRefs(resource)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr directory = do_QueryInterface(resource, &rv); @@ -513,7 +513,8 @@ NS_IMETHODIMP nsAbMDBDirectory::DeleteCards(nsISupportsArray *cards) if(NS_SUCCEEDED(rv)) { nsCOMPtr listResource; - rv = rdfService->GetResource(listUri, getter_AddRefs(listResource)); + rv = rdfService->GetResource(nsDependentCString(listUri), + getter_AddRefs(listResource)); nsCOMPtr listDir = do_QueryInterface(listResource, &rv); if(NS_SUCCEEDED(rv)) { @@ -932,7 +933,7 @@ NS_IMETHODIMP nsAbMDBDirectory::StartSearch() // Get the directory without the query nsCOMPtr resource; - rv = gRDFService->GetResource (mURINoQuery.get(), getter_AddRefs(resource)); + rv = gRDFService->GetResource (mURINoQuery, getter_AddRefs(resource)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr directory(do_QueryInterface(resource, &rv)); diff --git a/mailnews/addrbook/src/nsAbView.cpp b/mailnews/addrbook/src/nsAbView.cpp index 52e82c27db9b..ed5a0cbfcb06 100644 --- a/mailnews/addrbook/src/nsAbView.cpp +++ b/mailnews/addrbook/src/nsAbView.cpp @@ -219,7 +219,7 @@ NS_IMETHODIMP nsAbView::Init(const char *aURI, nsIAbViewListener *abViewListener NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr resource; - rv = rdfService->GetResource(aURI, getter_AddRefs(resource)); + rv = rdfService->GetResource(nsDependentCString(aURI), getter_AddRefs(resource)); NS_ENSURE_SUCCESS(rv, rv); mDirectory = do_QueryInterface(resource, &rv); diff --git a/mailnews/addrbook/src/nsAddbookProtocolHandler.cpp b/mailnews/addrbook/src/nsAddbookProtocolHandler.cpp index 8564da189637..da718f38182e 100644 --- a/mailnews/addrbook/src/nsAddbookProtocolHandler.cpp +++ b/mailnews/addrbook/src/nsAddbookProtocolHandler.cpp @@ -231,7 +231,7 @@ nsAddbookProtocolHandler::GeneratePrintOutput(nsIAddbookUrl *addbookUrl, uri.Insert(':', pos); nsCOMPtr resource; - rv = rdfService->GetResource(uri.get(), getter_AddRefs(resource)); + rv = rdfService->GetResource(uri, getter_AddRefs(resource)); NS_ENSURE_SUCCESS(rv,rv); nsCOMPtr directory = do_QueryInterface(resource, &rv); diff --git a/mailnews/addrbook/src/nsAddrDatabase.cpp b/mailnews/addrbook/src/nsAddrDatabase.cpp index 939af70be397..1ac27c3ccb5b 100644 --- a/mailnews/addrbook/src/nsAddrDatabase.cpp +++ b/mailnews/addrbook/src/nsAddrDatabase.cpp @@ -3589,7 +3589,7 @@ NS_IMETHODIMP nsAddrDatabase::AddListDirNode(nsIMdbRow * listRow) char* file = m_dbName.GetLeafName(); char *parentUri = PR_smprintf("%s%s", kMDBDirectoryRoot, file); - rv = rdfService->GetResource( parentUri, getter_AddRefs(parentResource)); + rv = rdfService->GetResource(nsDependentCString(parentUri), getter_AddRefs(parentResource)); nsCOMPtr parentDir; rv = proxyMgr->GetProxyForObject( NS_UI_THREAD_EVENTQ, NS_GET_IID( nsIAbDirectory), parentResource, PROXY_SYNC | PROXY_ALWAYS, getter_AddRefs( parentDir)); diff --git a/mailnews/addrbook/src/nsAddressBook.cpp b/mailnews/addrbook/src/nsAddressBook.cpp index dc9fcb18a67c..1016eac21374 100644 --- a/mailnews/addrbook/src/nsAddressBook.cpp +++ b/mailnews/addrbook/src/nsAddressBook.cpp @@ -129,7 +129,8 @@ NS_IMETHODIMP nsAddressBook::NewAddressBook(nsIAbDirectoryProperties *aPropertie NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr parentResource; - rv = rdfService->GetResource(kAllDirectoryRoot, getter_AddRefs(parentResource)); + rv = rdfService->GetResource(NS_LITERAL_CSTRING(kAllDirectoryRoot), + getter_AddRefs(parentResource)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr parentDir = do_QueryInterface(parentResource, &rv); @@ -146,11 +147,11 @@ NS_IMETHODIMP nsAddressBook::DeleteAddressBooks NS_ENSURE_ARG_POINTER(aParentDir); NS_ENSURE_ARG_POINTER(aResourceArray); - return DoCommand(aDS, NC_RDF_DELETE, aParentDir, aResourceArray); + return DoCommand(aDS, NS_LITERAL_CSTRING(NC_RDF_DELETE), aParentDir, aResourceArray); } nsresult nsAddressBook::DoCommand(nsIRDFDataSource* db, - const char *command, + const nsACString& command, nsISupportsArray *srcArray, nsISupportsArray *argumentArray) { @@ -434,13 +435,11 @@ nsresult AddressBookParser::ParseFile() nsCOMPtr rdfService = do_GetService (NS_RDF_CONTRACTID "/rdf-service;1", &rv); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr parentResource; - char *parentUri = PR_smprintf("%s", kAllDirectoryRoot); - rv = rdfService->GetResource(parentUri, getter_AddRefs(parentResource)); + rv = rdfService->GetResource(NS_LITERAL_CSTRING(kAllDirectoryRoot), + getter_AddRefs(parentResource)); nsCOMPtr parentDir = do_QueryInterface(parentResource); if (!parentDir) return NS_ERROR_NULL_POINTER; - if (parentUri) - PR_smprintf_free(parentUri); if (PL_strcmp(fileName, kPersonalAddressbook) == 0) { @@ -1649,7 +1648,7 @@ nsresult nsAddressBook::AppendLDIFForMailList(nsIAbCard *aCard, nsACString &aRes NS_ENSURE_SUCCESS(rv,rv); nsCOMPtr resource; - rv = rdfService->GetResource(mailListURI.get(), getter_AddRefs(resource)); + rv = rdfService->GetResource(mailListURI, getter_AddRefs(resource)); NS_ENSURE_SUCCESS(rv,rv); nsCOMPtr mailList = do_QueryInterface(resource, &rv); diff --git a/mailnews/addrbook/src/nsAddressBook.h b/mailnews/addrbook/src/nsAddressBook.h index d4ff21116b8f..3b0f45117ab2 100644 --- a/mailnews/addrbook/src/nsAddressBook.h +++ b/mailnews/addrbook/src/nsAddressBook.h @@ -147,7 +147,7 @@ public: CMDLINEHANDLER_REGISTERPROC_DECLS protected: - nsresult DoCommand(nsIRDFDataSource *db, const char * command, + nsresult DoCommand(nsIRDFDataSource *db, const nsACString& command, nsISupportsArray *srcArray, nsISupportsArray *arguments); nsresult GetAbDatabaseFromFile(char* pDbFile, nsIAddrDatabase **db); diff --git a/mailnews/addrbook/src/nsDirectoryDataSource.cpp b/mailnews/addrbook/src/nsDirectoryDataSource.cpp index 5362bca1401a..7cdcc9ab3fbb 100644 --- a/mailnews/addrbook/src/nsDirectoryDataSource.cpp +++ b/mailnews/addrbook/src/nsDirectoryDataSource.cpp @@ -132,26 +132,36 @@ nsAbDirectoryDataSource::Init() rv = rdf->RegisterDataSource(this, PR_FALSE); NS_ENSURE_SUCCESS(rv,rv); - - rv = rdf->GetResource(NC_RDF_CHILD, getter_AddRefs(kNC_Child)); + + rv = rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_CHILD), + getter_AddRefs(kNC_Child)); NS_ENSURE_SUCCESS(rv,rv); - rv = rdf->GetResource(NC_RDF_DIRNAME, getter_AddRefs(kNC_DirName)); + rv = rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_DIRNAME), + getter_AddRefs(kNC_DirName)); NS_ENSURE_SUCCESS(rv,rv); - rv = rdf->GetResource(NC_RDF_CARDCHILD, getter_AddRefs(kNC_CardChild)); + rv = rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_CARDCHILD), + getter_AddRefs(kNC_CardChild)); NS_ENSURE_SUCCESS(rv,rv); - rv = rdf->GetResource(NC_RDF_DIRURI, getter_AddRefs(kNC_DirUri)); + rv = rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_DIRURI), + getter_AddRefs(kNC_DirUri)); NS_ENSURE_SUCCESS(rv,rv); - rv = rdf->GetResource(NC_RDF_ISMAILLIST, getter_AddRefs(kNC_IsMailList)); + rv = rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_ISMAILLIST), + getter_AddRefs(kNC_IsMailList)); NS_ENSURE_SUCCESS(rv,rv); - rv = rdf->GetResource(NC_RDF_ISREMOTE, getter_AddRefs(kNC_IsRemote)); + rv = rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_ISREMOTE), + getter_AddRefs(kNC_IsRemote)); NS_ENSURE_SUCCESS(rv,rv); - rv = rdf->GetResource(NC_RDF_ISSECURE, getter_AddRefs(kNC_IsSecure)); + rv = rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_ISSECURE), + getter_AddRefs(kNC_IsSecure)); NS_ENSURE_SUCCESS(rv,rv); - rv = rdf->GetResource(NC_RDF_ISWRITEABLE, getter_AddRefs(kNC_IsWriteable)); + rv = rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_ISWRITEABLE), + getter_AddRefs(kNC_IsWriteable)); NS_ENSURE_SUCCESS(rv,rv); - rv = rdf->GetResource(NC_RDF_DELETE, getter_AddRefs(kNC_Delete)); + rv = rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_DELETE), + getter_AddRefs(kNC_Delete)); NS_ENSURE_SUCCESS(rv,rv); - rv = rdf->GetResource(NC_RDF_DELETECARDS, getter_AddRefs(kNC_DeleteCards)); + rv = rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_DELETECARDS), + getter_AddRefs(kNC_DeleteCards)); NS_ENSURE_SUCCESS(rv,rv); rv = createNode(NS_LITERAL_STRING("true").get(), getter_AddRefs(kTrueLiteral)); NS_ENSURE_SUCCESS(rv,rv); diff --git a/mailnews/base/search/src/nsMsgFilterDataSource.cpp b/mailnews/base/search/src/nsMsgFilterDataSource.cpp index 3fb620dfc806..c367750e29f0 100644 --- a/mailnews/base/search/src/nsMsgFilterDataSource.cpp +++ b/mailnews/base/search/src/nsMsgFilterDataSource.cpp @@ -93,9 +93,9 @@ nsMsgFilterDataSource::initGlobalObjects(nsIRDFService *rdf) rdf->GetLiteral(NS_LITERAL_STRING("true").get(), getter_AddRefs(kTrueLiteral)); - rdf->GetResource(NC_RDF_CHILD, getter_AddRefs(kNC_Child)); - rdf->GetResource(NC_RDF_NAME, getter_AddRefs(kNC_Name)); - rdf->GetResource(NC_RDF_ENABLED, getter_AddRefs(kNC_Enabled)); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_CHILD), getter_AddRefs(kNC_Child)); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_NAME), getter_AddRefs(kNC_Name)); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_ENABLED), getter_AddRefs(kNC_Enabled)); NS_NewISupportsArray(getter_AddRefs(mFilterListArcsOut)); mFilterListArcsOut->AppendElement(kNC_Child); @@ -336,7 +336,7 @@ nsMsgFilterDataSource::getFilterListTargets(nsIMsgFilterList *aFilterList, Recycle(utf8Name); nsCOMPtr filterResource; - rv = getRDFService()->GetResource(filterUri.get(), + rv = getRDFService()->GetResource(filterUri, getter_AddRefs(filterResource)); if (NS_SUCCEEDED(rv)) aResult->AppendElement(filterResource); diff --git a/mailnews/base/search/src/nsMsgFilterDelegateFactory.cpp b/mailnews/base/search/src/nsMsgFilterDelegateFactory.cpp index 16d7a9c6bf9c..c51afae69def 100644 --- a/mailnews/base/search/src/nsMsgFilterDelegateFactory.cpp +++ b/mailnews/base/search/src/nsMsgFilterDelegateFactory.cpp @@ -210,7 +210,7 @@ nsMsgFilterDelegateFactory::getFilterList(const char *aUri, NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr filterListResource; - rdf->GetResource(folderUri.get(), getter_AddRefs(filterListResource)); + rdf->GetResource(folderUri, getter_AddRefs(filterListResource)); NS_ENSURE_SUCCESS(rv, rv); return filterListResource->GetDelegate("filter", diff --git a/mailnews/base/search/src/nsMsgSearchTerm.cpp b/mailnews/base/search/src/nsMsgSearchTerm.cpp index 88520f226454..356190627fd6 100644 --- a/mailnews/base/search/src/nsMsgSearchTerm.cpp +++ b/mailnews/base/search/src/nsMsgSearchTerm.cpp @@ -865,7 +865,7 @@ nsresult nsMsgSearchTerm::InitializeAddressBook() NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr resource; - rv = rdfService->GetResource(m_value.string, getter_AddRefs(resource)); + rv = rdfService->GetResource(nsDependentCString(m_value.string), getter_AddRefs(resource)); NS_ENSURE_SUCCESS(rv, rv); mDirectory = do_QueryInterface(resource, &rv); diff --git a/mailnews/base/src/nsMessenger.cpp b/mailnews/base/src/nsMessenger.cpp index c7c5b4d6d63d..aea03cb7e89f 100644 --- a/mailnews/base/src/nsMessenger.cpp +++ b/mailnews/base/src/nsMessenger.cpp @@ -1059,7 +1059,7 @@ nsMessenger::Alert(const char *stringName) } nsresult -nsMessenger::DoCommand(nsIRDFCompositeDataSource* db, const char *command, +nsMessenger::DoCommand(nsIRDFCompositeDataSource* db, const nsACString& command, nsISupportsArray *srcArray, nsISupportsArray *argumentArray) { @@ -1103,9 +1103,9 @@ nsMessenger::DeleteMessages(nsIRDFCompositeDataSource *database, folderArray->AppendElement(srcFolderResource); if(reallyDelete) - rv = DoCommand(database, NC_RDF_REALLY_DELETE, folderArray, resourceArray); + rv = DoCommand(database, NS_LITERAL_CSTRING(NC_RDF_REALLY_DELETE), folderArray, resourceArray); else - rv = DoCommand(database, NC_RDF_DELETE, folderArray, resourceArray); + rv = DoCommand(database, NS_LITERAL_CSTRING(NC_RDF_DELETE), folderArray, resourceArray); return rv; @@ -1139,7 +1139,7 @@ NS_IMETHODIMP nsMessenger::DeleteFolders(nsIRDFCompositeDataSource *db, parentArray->AppendElement(parentResource); deletedArray->AppendElement(deletedFolderResource); - rv = DoCommand(db, NC_RDF_DELETE, parentArray, deletedArray); + rv = DoCommand(db, NS_LITERAL_CSTRING(NC_RDF_DELETE), parentArray, deletedArray); return NS_OK; } @@ -1172,7 +1172,10 @@ nsMessenger::CopyMessages(nsIRDFCompositeDataSource *database, NS_ENSURE_SUCCESS(rv, rv); folderArray->AppendElement(dstResource); - rv = DoCommand(database, isMove ? (char *)NC_RDF_MOVE : (char *)NC_RDF_COPY, folderArray, argumentArray); + if (isMove) + rv = DoCommand(database, NS_LITERAL_CSTRING(NC_RDF_MOVE), folderArray, argumentArray); + else + rv = DoCommand(database, NS_LITERAL_CSTRING(NC_RDF_COPY), folderArray, argumentArray); return rv; } @@ -1208,7 +1211,10 @@ nsMessenger::CopyFolders(nsIRDFCompositeDataSource *database, folderArray->AppendElement(dstResource); - return DoCommand(database, isMoveFolder ? NC_RDF_MOVEFOLDER : NC_RDF_COPYFOLDER, folderArray, argumentArray); + if (isMoveFolder) + return DoCommand(database, NS_LITERAL_CSTRING(NC_RDF_MOVEFOLDER), folderArray, argumentArray); + + return DoCommand(database, NS_LITERAL_CSTRING(NC_RDF_COPYFOLDER), folderArray, argumentArray); } @@ -1234,7 +1240,7 @@ nsMessenger::RenameFolder(nsIRDFCompositeDataSource* db, rdfService->GetLiteral(name, getter_AddRefs(nameLiteral)); argsArray->AppendElement(nameLiteral); - rv = DoCommand(db, NC_RDF_RENAME, folderArray, argsArray); + rv = DoCommand(db, NS_LITERAL_CSTRING(NC_RDF_RENAME), folderArray, argsArray); } return rv; } @@ -1251,7 +1257,10 @@ nsMessenger::CompactFolder(nsIRDFCompositeDataSource* db, rv = NS_NewISupportsArray(getter_AddRefs(folderArray)); if (NS_FAILED(rv)) return rv; folderArray->AppendElement(folderResource); - rv = DoCommand(db, NS_CONST_CAST(char*, forAll ? NC_RDF_COMPACTALL : NC_RDF_COMPACT), folderArray, nsnull); + if (forAll) + rv = DoCommand(db, NS_LITERAL_CSTRING(NC_RDF_COMPACTALL), folderArray, nsnull); + else + rv = DoCommand(db, NS_LITERAL_CSTRING(NC_RDF_COMPACT), folderArray, nsnull); if (NS_SUCCEEDED(rv) && mTxnMgr) mTxnMgr->Clear(); return rv; @@ -1269,7 +1278,7 @@ nsMessenger::EmptyTrash(nsIRDFCompositeDataSource* db, rv = NS_NewISupportsArray(getter_AddRefs(folderArray)); if (NS_FAILED(rv)) return rv; folderArray->AppendElement(folderResource); - rv = DoCommand(db, NC_RDF_EMPTYTRASH, folderArray, nsnull); + rv = DoCommand(db, NS_LITERAL_CSTRING(NC_RDF_EMPTYTRASH), folderArray, nsnull); if (NS_SUCCEEDED(rv) && mTxnMgr) mTxnMgr->Clear(); return rv; diff --git a/mailnews/base/src/nsMessenger.h b/mailnews/base/src/nsMessenger.h index b589f7043e27..ca182329a16a 100644 --- a/mailnews/base/src/nsMessenger.h +++ b/mailnews/base/src/nsMessenger.h @@ -69,7 +69,7 @@ public: protected: nsresult DoDelete(nsIRDFCompositeDataSource* db, nsISupportsArray *srcArray, nsISupportsArray *deletedArray); - nsresult DoCommand(nsIRDFCompositeDataSource *db, const char * command, nsISupportsArray *srcArray, + nsresult DoCommand(nsIRDFCompositeDataSource *db, const nsACString& command, nsISupportsArray *srcArray, nsISupportsArray *arguments); PRUnichar *GetString(const PRUnichar *aStringName); nsresult InitStringBundle(); diff --git a/mailnews/base/src/nsMsgAccountManagerDS.cpp b/mailnews/base/src/nsMsgAccountManagerDS.cpp index c84ff0e79fa2..d04bc93ac3ec 100644 --- a/mailnews/base/src/nsMsgAccountManagerDS.cpp +++ b/mailnews/base/src/nsMsgAccountManagerDS.cpp @@ -159,38 +159,55 @@ nsMsgAccountManagerDataSource::nsMsgAccountManagerDataSource() // do per-class initialization here if (gAccountManagerResourceRefCnt++ == 0) { - getRDFService()->GetResource(NC_RDF_CHILD, &kNC_Child); - getRDFService()->GetResource(NC_RDF_NAME, &kNC_Name); - getRDFService()->GetResource(NC_RDF_FOLDERTREENAME, &kNC_FolderTreeName); - getRDFService()->GetResource(NC_RDF_FOLDERTREESIMPLENAME, &kNC_FolderTreeSimpleName); - getRDFService()->GetResource(NC_RDF_NAME_SORT, &kNC_NameSort); - getRDFService()->GetResource(NC_RDF_FOLDERTREENAME_SORT, &kNC_FolderTreeNameSort); - getRDFService()->GetResource(NC_RDF_PAGETAG, &kNC_PageTag); - getRDFService()->GetResource(NC_RDF_ISDEFAULTSERVER, &kNC_IsDefaultServer); - getRDFService()->GetResource(NC_RDF_SUPPORTSFILTERS, &kNC_SupportsFilters); - getRDFService()->GetResource(NC_RDF_CANGETMESSAGES, &kNC_CanGetMessages); - getRDFService()->GetResource(NC_RDF_CANGETINCOMINGMESSAGES, &kNC_CanGetIncomingMessages); - getRDFService()->GetResource(NC_RDF_ACCOUNT, &kNC_Account); - getRDFService()->GetResource(NC_RDF_SERVER, &kNC_Server); - getRDFService()->GetResource(NC_RDF_IDENTITY, &kNC_Identity); - getRDFService()->GetResource(NC_RDF_PAGETITLE_MAIN, &kNC_PageTitleMain); - getRDFService()->GetResource(NC_RDF_PAGETITLE_SERVER, &kNC_PageTitleServer); - getRDFService()->GetResource(NC_RDF_PAGETITLE_COPIES, &kNC_PageTitleCopies); - getRDFService()->GetResource(NC_RDF_PAGETITLE_OFFLINEANDDISKSPACE, &kNC_PageTitleOfflineAndDiskSpace); - getRDFService()->GetResource(NC_RDF_PAGETITLE_DISKSPACE, &kNC_PageTitleDiskSpace); - getRDFService()->GetResource(NC_RDF_PAGETITLE_ADDRESSING, &kNC_PageTitleAddressing); - getRDFService()->GetResource(NC_RDF_PAGETITLE_ADVANCED, &kNC_PageTitleAdvanced); - getRDFService()->GetResource(NC_RDF_PAGETITLE_SMTP, &kNC_PageTitleSMTP); - getRDFService()->GetResource(NC_RDF_PAGETITLE_FAKEACCOUNT, &kNC_PageTitleFakeAccount); + getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_CHILD), &kNC_Child); + getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_NAME), &kNC_Name); + getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_FOLDERTREENAME), + &kNC_FolderTreeName); + getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_FOLDERTREESIMPLENAME), + &kNC_FolderTreeSimpleName); + getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_NAME_SORT), &kNC_NameSort); + getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_FOLDERTREENAME_SORT), + &kNC_FolderTreeNameSort); + getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_PAGETAG), &kNC_PageTag); + getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_ISDEFAULTSERVER), + &kNC_IsDefaultServer); + getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_SUPPORTSFILTERS), + &kNC_SupportsFilters); + getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_CANGETMESSAGES), + &kNC_CanGetMessages); + getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_CANGETINCOMINGMESSAGES), + &kNC_CanGetIncomingMessages); + getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_ACCOUNT), &kNC_Account); + getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_SERVER), &kNC_Server); + getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_IDENTITY), &kNC_Identity); + getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_PAGETITLE_MAIN), + &kNC_PageTitleMain); + getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_PAGETITLE_SERVER), + &kNC_PageTitleServer); + getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_PAGETITLE_COPIES), + &kNC_PageTitleCopies); + getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_PAGETITLE_OFFLINEANDDISKSPACE), + &kNC_PageTitleOfflineAndDiskSpace); + getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_PAGETITLE_DISKSPACE), + &kNC_PageTitleDiskSpace); + getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_PAGETITLE_ADDRESSING), + &kNC_PageTitleAddressing); + getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_PAGETITLE_ADVANCED), + &kNC_PageTitleAdvanced); + getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_PAGETITLE_SMTP), + &kNC_PageTitleSMTP); + getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_PAGETITLE_FAKEACCOUNT), + &kNC_PageTitleFakeAccount); - getRDFService()->GetResource(NC_RDF_ACCOUNTROOT, &kNC_AccountRoot); + getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_ACCOUNTROOT), + &kNC_AccountRoot); getRDFService()->GetLiteral(NS_LITERAL_STRING("true").get(), &kTrueLiteral); // eventually these need to exist in some kind of array // that's easily extensible - getRDFService()->GetResource(NC_RDF_SETTINGS, &kNC_Settings); + getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_SETTINGS), &kNC_Settings); kDefaultServerAtom = NS_NewAtom("DefaultServer"); } @@ -758,7 +775,7 @@ nsMsgAccountManagerDataSource::appendGenericSetting(const char *name, nsISupport resourceStr = NC_RDF_PAGETITLE_PREFIX; resourceStr += name; - nsresult rv = getRDFService()->GetResource(resourceStr.get(), getter_AddRefs(resource)); + nsresult rv = getRDFService()->GetResource(resourceStr, getter_AddRefs(resource)); NS_ENSURE_SUCCESS(rv,rv); // AppendElement will addref. diff --git a/mailnews/base/src/nsMsgFolderDataSource.cpp b/mailnews/base/src/nsMsgFolderDataSource.cpp index 46ad5fe12969..fbf72b1107cb 100644 --- a/mailnews/base/src/nsMsgFolderDataSource.cpp +++ b/mailnews/base/src/nsMsgFolderDataSource.cpp @@ -135,56 +135,56 @@ nsMsgFolderDataSource::nsMsgFolderDataSource() nsIRDFService* rdf = getRDFService(); if (gFolderResourceRefCnt++ == 0) { - rdf->GetResource(NC_RDF_CHILD, &kNC_Child); - rdf->GetResource(NC_RDF_FOLDER, &kNC_Folder); - rdf->GetResource(NC_RDF_NAME, &kNC_Name); - rdf->GetResource(NC_RDF_OPEN, &kNC_Open); - rdf->GetResource(NC_RDF_FOLDERTREENAME, &kNC_FolderTreeName); - rdf->GetResource(NC_RDF_FOLDERTREESIMPLENAME, &kNC_FolderTreeSimpleName); - rdf->GetResource(NC_RDF_NAME_SORT, &kNC_NameSort); - rdf->GetResource(NC_RDF_FOLDERTREENAME_SORT, &kNC_FolderTreeNameSort); - rdf->GetResource(NC_RDF_SPECIALFOLDER, &kNC_SpecialFolder); - rdf->GetResource(NC_RDF_SERVERTYPE, &kNC_ServerType); - rdf->GetResource(NC_RDF_REDIRECTORTYPE, &kNC_RedirectorType); - rdf->GetResource(NC_RDF_CANCREATEFOLDERSONSERVER, &kNC_CanCreateFoldersOnServer); - rdf->GetResource(NC_RDF_CANFILEMESSAGESONSERVER, &kNC_CanFileMessagesOnServer); - rdf->GetResource(NC_RDF_ISSERVER, &kNC_IsServer); - rdf->GetResource(NC_RDF_ISSECURE, &kNC_IsSecure); - rdf->GetResource(NC_RDF_CANSUBSCRIBE, &kNC_CanSubscribe); - rdf->GetResource(NC_RDF_SUPPORTSOFFLINE, &kNC_SupportsOffline); - rdf->GetResource(NC_RDF_CANFILEMESSAGES, &kNC_CanFileMessages); - rdf->GetResource(NC_RDF_CANCREATESUBFOLDERS, &kNC_CanCreateSubfolders); - rdf->GetResource(NC_RDF_CANRENAME, &kNC_CanRename); - rdf->GetResource(NC_RDF_CANCOMPACT, &kNC_CanCompact); - rdf->GetResource(NC_RDF_TOTALMESSAGES, &kNC_TotalMessages); - rdf->GetResource(NC_RDF_TOTALUNREADMESSAGES, &kNC_TotalUnreadMessages); - rdf->GetResource(NC_RDF_FOLDERSIZE, &kNC_FolderSize); - rdf->GetResource(NC_RDF_CHARSET, &kNC_Charset); - rdf->GetResource(NC_RDF_BIFFSTATE, &kNC_BiffState); - rdf->GetResource(NC_RDF_HASUNREADMESSAGES, &kNC_HasUnreadMessages); - rdf->GetResource(NC_RDF_NEWMESSAGES, &kNC_NewMessages); - rdf->GetResource(NC_RDF_SUBFOLDERSHAVEUNREADMESSAGES, &kNC_SubfoldersHaveUnreadMessages); - rdf->GetResource(NC_RDF_NOSELECT, &kNC_NoSelect); - rdf->GetResource(NC_RDF_IMAPSHARED, &kNC_ImapShared); - rdf->GetResource(NC_RDF_SYNCHRONIZE, &kNC_Synchronize); - rdf->GetResource(NC_RDF_SYNCDISABLED, &kNC_SyncDisabled); - rdf->GetResource(NC_RDF_CANSEARCHMESSAGES, &kNC_CanSearchMessages); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_CHILD), &kNC_Child); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_FOLDER), &kNC_Folder); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_NAME), &kNC_Name); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_OPEN), &kNC_Open); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_FOLDERTREENAME), &kNC_FolderTreeName); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_FOLDERTREESIMPLENAME), &kNC_FolderTreeSimpleName); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_NAME_SORT), &kNC_NameSort); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_FOLDERTREENAME_SORT), &kNC_FolderTreeNameSort); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_SPECIALFOLDER), &kNC_SpecialFolder); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_SERVERTYPE), &kNC_ServerType); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_REDIRECTORTYPE), &kNC_RedirectorType); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_CANCREATEFOLDERSONSERVER), &kNC_CanCreateFoldersOnServer); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_CANFILEMESSAGESONSERVER), &kNC_CanFileMessagesOnServer); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_ISSERVER), &kNC_IsServer); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_ISSECURE), &kNC_IsSecure); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_CANSUBSCRIBE), &kNC_CanSubscribe); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_SUPPORTSOFFLINE), &kNC_SupportsOffline); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_CANFILEMESSAGES), &kNC_CanFileMessages); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_CANCREATESUBFOLDERS), &kNC_CanCreateSubfolders); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_CANRENAME), &kNC_CanRename); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_CANCOMPACT), &kNC_CanCompact); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_TOTALMESSAGES), &kNC_TotalMessages); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_TOTALUNREADMESSAGES), &kNC_TotalUnreadMessages); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_FOLDERSIZE), &kNC_FolderSize); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_CHARSET), &kNC_Charset); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_BIFFSTATE), &kNC_BiffState); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_HASUNREADMESSAGES), &kNC_HasUnreadMessages); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_NEWMESSAGES), &kNC_NewMessages); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_SUBFOLDERSHAVEUNREADMESSAGES), &kNC_SubfoldersHaveUnreadMessages); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_NOSELECT), &kNC_NoSelect); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_IMAPSHARED), &kNC_ImapShared); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_SYNCHRONIZE), &kNC_Synchronize); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_SYNCDISABLED), &kNC_SyncDisabled); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_CANSEARCHMESSAGES), &kNC_CanSearchMessages); - rdf->GetResource(NC_RDF_DELETE, &kNC_Delete); - rdf->GetResource(NC_RDF_REALLY_DELETE, &kNC_ReallyDelete); - rdf->GetResource(NC_RDF_NEWFOLDER, &kNC_NewFolder); - rdf->GetResource(NC_RDF_GETNEWMESSAGES, &kNC_GetNewMessages); - rdf->GetResource(NC_RDF_COPY, &kNC_Copy); - rdf->GetResource(NC_RDF_MOVE, &kNC_Move); - rdf->GetResource(NC_RDF_COPYFOLDER, &kNC_CopyFolder); - rdf->GetResource(NC_RDF_MOVEFOLDER, &kNC_MoveFolder); - rdf->GetResource(NC_RDF_MARKALLMESSAGESREAD, + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_DELETE), &kNC_Delete); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_REALLY_DELETE), &kNC_ReallyDelete); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_NEWFOLDER), &kNC_NewFolder); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_GETNEWMESSAGES), &kNC_GetNewMessages); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_COPY), &kNC_Copy); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_MOVE), &kNC_Move); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_COPYFOLDER), &kNC_CopyFolder); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_MOVEFOLDER), &kNC_MoveFolder); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_MARKALLMESSAGESREAD), &kNC_MarkAllMessagesRead); - rdf->GetResource(NC_RDF_COMPACT, &kNC_Compact); - rdf->GetResource(NC_RDF_COMPACTALL, &kNC_CompactAll); - rdf->GetResource(NC_RDF_RENAME, &kNC_Rename); - rdf->GetResource(NC_RDF_EMPTYTRASH, &kNC_EmptyTrash); - rdf->GetResource(NC_RDF_DOWNLOADFLAGGED, &kNC_DownloadFlagged); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_COMPACT), &kNC_Compact); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_COMPACTALL), &kNC_CompactAll); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_RENAME), &kNC_Rename); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_EMPTYTRASH), &kNC_EmptyTrash); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_DOWNLOADFLAGGED), &kNC_DownloadFlagged); kTotalMessagesAtom = NS_NewAtom("TotalMessages"); kTotalUnreadMessagesAtom = NS_NewAtom("TotalUnreadMessages"); diff --git a/mailnews/base/src/nsMsgPurgeService.cpp b/mailnews/base/src/nsMsgPurgeService.cpp index 7f36512055f2..f914e90c05b2 100644 --- a/mailnews/base/src/nsMsgPurgeService.cpp +++ b/mailnews/base/src/nsMsgPurgeService.cpp @@ -164,7 +164,7 @@ nsresult nsMsgPurgeService::AddServer(nsIMsgIncomingServer *server) NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr resource; - rv = rdf->GetResource(junkFolderURI.get(), getter_AddRefs(resource)); + rv = rdf->GetResource(junkFolderURI, getter_AddRefs(resource)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr junkFolder = do_QueryInterface(resource, &rv); diff --git a/mailnews/base/src/nsSubscribableServer.cpp b/mailnews/base/src/nsSubscribableServer.cpp index 3ba391a6ddf0..10ba789b5189 100644 --- a/mailnews/base/src/nsSubscribableServer.cpp +++ b/mailnews/base/src/nsSubscribableServer.cpp @@ -77,10 +77,12 @@ nsSubscribableServer::Init() rv = EnsureRDFService(); NS_ENSURE_SUCCESS(rv,rv); - rv = mRDFService->GetResource(NC_NAMESPACE_URI "child",getter_AddRefs(kNC_Child)); + rv = mRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "child"), + getter_AddRefs(kNC_Child)); NS_ENSURE_SUCCESS(rv,rv); - rv = mRDFService->GetResource(NC_NAMESPACE_URI "Subscribed",getter_AddRefs(kNC_Subscribed)); + rv = mRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Subscribed"), + getter_AddRefs(kNC_Subscribed)); NS_ENSURE_SUCCESS(rv,rv); rv = mRDFService->GetLiteral(NS_LITERAL_STRING("true").get(),getter_AddRefs(kTrueLiteral)); @@ -260,9 +262,9 @@ nsSubscribableServer::NotifyAssert(SubscribeTreeNode *subjectNode, nsIRDFResourc rv = EnsureRDFService(); NS_ENSURE_SUCCESS(rv,rv); - rv = mRDFService->GetResource(subjectUri.get(), getter_AddRefs(subject)); + rv = mRDFService->GetResource(subjectUri, getter_AddRefs(subject)); NS_ENSURE_SUCCESS(rv,rv); - rv = mRDFService->GetResource(objectUri.get(), getter_AddRefs(object)); + rv = mRDFService->GetResource(objectUri, getter_AddRefs(object)); NS_ENSURE_SUCCESS(rv,rv); rv = Notify(subject, property, object, PR_TRUE, PR_FALSE); @@ -306,7 +308,7 @@ nsSubscribableServer::NotifyChange(SubscribeTreeNode *subjectNode, nsIRDFResourc rv = EnsureRDFService(); NS_ENSURE_SUCCESS(rv,rv); - rv = mRDFService->GetResource(subjectUri.get(), getter_AddRefs(subject)); + rv = mRDFService->GetResource(subjectUri, getter_AddRefs(subject)); NS_ENSURE_SUCCESS(rv,rv); if (value) { @@ -798,7 +800,7 @@ nsSubscribableServer::GetChildren(const char *path, nsISupportsArray *array) NS_ENSURE_SUCCESS(rv,rv); // todo, is this creating nsMsgFolders? - mRDFService->GetResource(uri.get(), getter_AddRefs(res)); + mRDFService->GetResource(uri, getter_AddRefs(res)); array->AppendElement(res); current = current->prevSibling; diff --git a/mailnews/base/src/nsSubscribeDataSource.cpp b/mailnews/base/src/nsSubscribeDataSource.cpp index e53e0269046d..b0f89bef2fbc 100644 --- a/mailnews/base/src/nsSubscribeDataSource.cpp +++ b/mailnews/base/src/nsSubscribeDataSource.cpp @@ -83,19 +83,24 @@ nsSubscribeDataSource::Init() NS_ENSURE_SUCCESS(rv,rv); if (!mRDFService) return NS_ERROR_FAILURE; - rv = mRDFService->GetResource(NC_NAMESPACE_URI "child",getter_AddRefs(kNC_Child)); + rv = mRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "child"), + getter_AddRefs(kNC_Child)); NS_ENSURE_SUCCESS(rv,rv); - rv = mRDFService->GetResource(NC_NAMESPACE_URI "Name",getter_AddRefs(kNC_Name)); + rv = mRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Name"), + getter_AddRefs(kNC_Name)); NS_ENSURE_SUCCESS(rv,rv); - rv = mRDFService->GetResource(NC_NAMESPACE_URI "LeafName",getter_AddRefs(kNC_LeafName)); + rv = mRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "LeafName"), + getter_AddRefs(kNC_LeafName)); NS_ENSURE_SUCCESS(rv,rv); - rv = mRDFService->GetResource(NC_NAMESPACE_URI "Subscribed",getter_AddRefs(kNC_Subscribed)); + rv = mRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Subscribed"), + getter_AddRefs(kNC_Subscribed)); NS_ENSURE_SUCCESS(rv,rv); - rv = mRDFService->GetResource(NC_NAMESPACE_URI "ServerType",getter_AddRefs(kNC_ServerType)); + rv = mRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "ServerType"), + getter_AddRefs(kNC_ServerType)); NS_ENSURE_SUCCESS(rv,rv); rv = mRDFService->GetLiteral(NS_LITERAL_STRING("true").get(),getter_AddRefs(kTrueLiteral)); @@ -183,7 +188,7 @@ nsSubscribeDataSource::GetTarget(nsIRDFResource *source, if (!(const char *)childUri) return NS_RDF_NO_VALUE; nsCOMPtr childResource; - rv = mRDFService->GetResource((const char *)childUri, getter_AddRefs(childResource)); + rv = mRDFService->GetResource(childUri, getter_AddRefs(childResource)); NS_ENSURE_SUCCESS(rv,rv); return childResource->QueryInterface(NS_GET_IID(nsIRDFNode), (void**) target); diff --git a/mailnews/base/util/nsMsgFolder.cpp b/mailnews/base/util/nsMsgFolder.cpp index a8494940ea1d..65705fa17c5c 100644 --- a/mailnews/base/util/nsMsgFolder.cpp +++ b/mailnews/base/util/nsMsgFolder.cpp @@ -427,7 +427,7 @@ nsMsgFolder::FindSubFolder(const char *subFolderName, nsIFolder **aFolder) uri.Append(subFolderName); nsCOMPtr res; - rv = rdf->GetResource(uri.get(), getter_AddRefs(res)); + rv = rdf->GetResource(uri, getter_AddRefs(res)); if (NS_FAILED(rv)) return rv; diff --git a/mailnews/base/util/nsMsgIdentity.cpp b/mailnews/base/util/nsMsgIdentity.cpp index c61807271592..a8a614dd77c0 100644 --- a/mailnews/base/util/nsMsgIdentity.cpp +++ b/mailnews/base/util/nsMsgIdentity.cpp @@ -535,7 +535,7 @@ nsMsgIdentity::setFolderPref(const char *prefname, const char *value) rv = setCharPref(prefname, value); if (NS_SUCCEEDED(rv)) { - rv = rdf->GetResource(value, getter_AddRefs(res)); + rv = rdf->GetResource(nsDependentCString(value), getter_AddRefs(res)); if (NS_SUCCEEDED(rv) && res) { folder = do_QueryInterface(res, &rv); diff --git a/mailnews/base/util/nsMsgUtils.cpp b/mailnews/base/util/nsMsgUtils.cpp index d69f5a41c2a2..1ba5b5e353e3 100644 --- a/mailnews/base/util/nsMsgUtils.cpp +++ b/mailnews/base/util/nsMsgUtils.cpp @@ -547,7 +547,7 @@ nsresult GetExistingFolder(const char *aFolderURI, nsIMsgFolder **aFolder) NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr resource; - rv = rdf->GetResource(aFolderURI, getter_AddRefs(resource)); + rv = rdf->GetResource(nsDependentCString(aFolderURI), getter_AddRefs(resource)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr thisFolder; @@ -655,7 +655,7 @@ GetOrCreateFolder(const nsACString &aURI, nsIUrlListener *aListener) // get the corresponding RDF resource // RDF will create the folder resource if it doesn't already exist nsCOMPtr resource; - rv = rdf->GetResource(nsCAutoString(aURI).get(), getter_AddRefs(resource)); + rv = rdf->GetResource(aURI, getter_AddRefs(resource)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr folderResource; diff --git a/mailnews/compose/src/nsMsgCompose.cpp b/mailnews/compose/src/nsMsgCompose.cpp index c335f687222c..7368076269b4 100644 --- a/mailnews/compose/src/nsMsgCompose.cpp +++ b/mailnews/compose/src/nsMsgCompose.cpp @@ -3552,10 +3552,10 @@ static nsresult OpenAddressBook(const char * dbUri, nsIAddrDatabase** aDatabase) return rv; } -nsresult nsMsgCompose::GetABDirectories(const char * dirUri, nsISupportsArray* directoriesArray, PRBool searchSubDirectory) +nsresult nsMsgCompose::GetABDirectories(const nsACString& dirUri, nsISupportsArray* directoriesArray, PRBool searchSubDirectory) { static PRBool collectedAddressbookFound; - if (nsCRT::strcmp(dirUri, kMDBDirectoryRoot) == 0) + if (dirUri.Equals(NS_LITERAL_CSTRING(kMDBDirectoryRoot))) collectedAddressbookFound = PR_FALSE; nsresult rv = NS_OK; @@ -3621,7 +3621,7 @@ nsresult nsMsgCompose::GetABDirectories(const char * dirUri, nsISupportsArray* d } directoriesArray->InsertElementAt(directory, pos); - rv = GetABDirectories((const char *)uri, directoriesArray, PR_TRUE); + rv = GetABDirectories(uri, directoriesArray, PR_TRUE); } } } while (NS_SUCCEEDED(subDirectories->Next())); @@ -3791,7 +3791,7 @@ NS_IMETHODIMP nsMsgCompose::CheckAndPopulateRecipients(PRBool populateMailList, if (NS_SUCCEEDED(rv) && addrbookDirArray) { nsString dirPath; - GetABDirectories(kAllDirectoryRoot, addrbookDirArray, PR_TRUE); + GetABDirectories(NS_LITERAL_CSTRING(kAllDirectoryRoot), addrbookDirArray, PR_TRUE); PRInt32 nbrRecipients; PRUint32 nbrAddressbook; diff --git a/mailnews/compose/src/nsMsgCompose.h b/mailnews/compose/src/nsMsgCompose.h index 5d772079d918..ba8dbab448bf 100644 --- a/mailnews/compose/src/nsMsgCompose.h +++ b/mailnews/compose/src/nsMsgCompose.h @@ -118,7 +118,7 @@ private: nsresult _SendMsg(MSG_DeliverMode deliverMode, nsIMsgIdentity *identity, PRBool entityConversionDone); nsresult CreateMessage(const char * originalMsgURI, MSG_ComposeType type, nsIMsgCompFields* compFields); void CleanUpRecipients(nsString& recipients); - nsresult GetABDirectories(const char * dirUri, nsISupportsArray* directoriesArray, PRBool searchSubDirectory); + nsresult GetABDirectories(const nsACString& dirUri, nsISupportsArray* directoriesArray, PRBool searchSubDirectory); nsresult BuildMailListArray(nsIAddrDatabase* database, nsIAbDirectory* parentDir, nsISupportsArray* array); nsresult GetMailListAddresses(nsString& name, nsISupportsArray* mailListArray, nsISupportsArray** addresses); nsresult TagConvertible(nsIDOMNode *node, PRInt32 *_retval); diff --git a/mailnews/compose/src/nsMsgCopy.cpp b/mailnews/compose/src/nsMsgCopy.cpp index dba1f6ca0e9e..46ea3cc10ef4 100644 --- a/mailnews/compose/src/nsMsgCopy.cpp +++ b/mailnews/compose/src/nsMsgCopy.cpp @@ -444,7 +444,7 @@ LocateMessageFolder(nsIMsgIdentity *userIdentity, // get the corresponding RDF resource // RDF will create the folder resource if it doesn't already exist nsCOMPtr resource; - rv = rdf->GetResource(aFolderURI, getter_AddRefs(resource)); + rv = rdf->GetResource(nsDependentCString(aFolderURI), getter_AddRefs(resource)); if (NS_FAILED(rv)) return rv; nsCOMPtr folderResource; diff --git a/mailnews/compose/src/nsMsgSend.cpp b/mailnews/compose/src/nsMsgSend.cpp index de5867f77d7d..d8f767665c46 100644 --- a/mailnews/compose/src/nsMsgSend.cpp +++ b/mailnews/compose/src/nsMsgSend.cpp @@ -3647,7 +3647,7 @@ PRBool nsMsgComposeAndSend::CanSaveMessagesToFolder(const char *folderURL) return PR_FALSE; nsCOMPtr resource; - rv = rdf->GetResource(folderURL, getter_AddRefs(resource)); + rv = rdf->GetResource(nsDependentCString(folderURL), getter_AddRefs(resource)); if (NS_FAILED(rv)) return PR_FALSE; @@ -4288,7 +4288,7 @@ nsMsgComposeAndSend::MimeDoFCC(nsFileSpec *input_file, if (rdfService) { nsCOMPtr res; - rdfService->GetResource(turi, getter_AddRefs(res)); + rdfService->GetResource(nsDependentCString(turi), getter_AddRefs(res)); nsCOMPtr folder = do_QueryInterface(res); if (folder) folder->GetName(getter_Copies(folderName)); diff --git a/mailnews/compose/src/nsSmtpDataSource.cpp b/mailnews/compose/src/nsSmtpDataSource.cpp index bbd373ee688e..317e41fc0330 100644 --- a/mailnews/compose/src/nsSmtpDataSource.cpp +++ b/mailnews/compose/src/nsSmtpDataSource.cpp @@ -88,12 +88,15 @@ nsSmtpDataSource::initGlobalObjects() nsCOMPtr rdf = do_GetService(kRDFServiceCID, &rv); if (NS_FAILED(rv)) return rv; - rdf->GetResource(NC_RDF_CHILD, getter_AddRefs(kNC_Child)); - rdf->GetResource(NC_RDF_NAME, getter_AddRefs(kNC_Name)); - rdf->GetResource(NC_RDF_KEY, getter_AddRefs(kNC_Key)); - rdf->GetResource(NC_RDF_SMTPSERVERS, getter_AddRefs(kNC_SmtpServers)); - rdf->GetResource(NC_RDF_ISDEFAULT, getter_AddRefs(kNC_IsDefaultServer)); - rdf->GetResource(NC_RDF_ISSESSIONDEFAULT, getter_AddRefs(kNC_IsSessionDefaultServer)); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_CHILD), getter_AddRefs(kNC_Child)); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_NAME), getter_AddRefs(kNC_Name)); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_KEY), getter_AddRefs(kNC_Key)); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_SMTPSERVERS), + getter_AddRefs(kNC_SmtpServers)); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_ISDEFAULT), + getter_AddRefs(kNC_IsDefaultServer)); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_ISSESSIONDEFAULT), + getter_AddRefs(kNC_IsSessionDefaultServer)); nsAutoString trueStr(NS_LITERAL_STRING("true")); rdf->GetLiteral(trueStr.get(), getter_AddRefs(kTrueLiteral)); diff --git a/mailnews/extensions/palmsync/src/nsAbIPCCard.cpp b/mailnews/extensions/palmsync/src/nsAbIPCCard.cpp index 3e66498c5a9c..602a45e84ec8 100644 --- a/mailnews/extensions/palmsync/src/nsAbIPCCard.cpp +++ b/mailnews/extensions/palmsync/src/nsAbIPCCard.cpp @@ -421,7 +421,7 @@ PRBool nsAbIPCCard::Equals(nsABCOMCardStruct * card, nsStringArray & differingAt differingAttrs.AppendString(NS_LITERAL_STRING(kMailListName)); if(card->mailListURI) { nsCAutoString str(card->mailListURI); - if (str.Compare(m_MailListURI, PR_TRUE)) + if (str.Equals(m_MailListURI, nsCaseInsensitiveCStringComparator())) differingAttrs.AppendString(NS_LITERAL_STRING(kMailListDescription)); } @@ -582,10 +582,9 @@ NS_IMETHODIMP nsAbIPCCard::Equals(nsIAbCard *card, PRBool *_retval) if (isMailList != m_IsMailList) return NS_OK; - nsCAutoString tempStr(m_MailListURI); nsXPIDLCString str2; card->GetMailListURI(getter_Copies(str2)); - if (tempStr.Compare(str2.get(), PR_TRUE)) + if (m_MailListURI.Equals(str2, nsCaseInsensitiveCStringComparator())) return NS_OK; *_retval = PR_TRUE; @@ -744,10 +743,7 @@ nsresult nsAbIPCCard::GetABCOMCardStruct(PRBool isUnicode, nsABCOMCardStruct * c card->preferMailFormat = m_PreferMailFormat; card->isMailList = m_IsMailList; - if(m_MailListURI) { - card->mailListURI = new char[strlen(m_MailListURI)+1]; - strcpy(card->mailListURI, m_MailListURI); - } + card->mailListURI = m_MailListURI; return NS_OK; } diff --git a/mailnews/imap/src/nsImapIncomingServer.cpp b/mailnews/imap/src/nsImapIncomingServer.cpp index a752a8a210db..f61cc3da6876 100644 --- a/mailnews/imap/src/nsImapIncomingServer.cpp +++ b/mailnews/imap/src/nsImapIncomingServer.cpp @@ -1055,7 +1055,7 @@ nsresult nsImapIncomingServer::GetPFCForStringId(PRBool createIfMissing, PRInt32 NS_ENSURE_SUCCESS(rv,rv); nsCOMPtr res; - rv = rdf->GetResource(pfcMailUri.get(), getter_AddRefs(res)); + rv = rdf->GetResource(pfcMailUri, getter_AddRefs(res)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr parentToCreate = do_QueryInterface(res, &rv); @@ -1572,7 +1572,7 @@ nsresult nsImapIncomingServer::GetFolder(const char* name, nsIMsgFolder** pFolde nsCOMPtr rdf(do_GetService(kRDFServiceCID, &rv)); if (NS_FAILED(rv)) return rv; nsCOMPtr res; - rv = rdf->GetResource(uriString.get(), getter_AddRefs(res)); + rv = rdf->GetResource(uriString, getter_AddRefs(res)); if (NS_SUCCEEDED(rv)) { nsCOMPtr folder(do_QueryInterface(res, &rv)); diff --git a/mailnews/imap/src/nsImapMailFolder.cpp b/mailnews/imap/src/nsImapMailFolder.cpp index 7d13dbbcbcbc..c20d35fffb44 100644 --- a/mailnews/imap/src/nsImapMailFolder.cpp +++ b/mailnews/imap/src/nsImapMailFolder.cpp @@ -341,7 +341,7 @@ NS_IMETHODIMP nsImapMailFolder::AddSubfolderWithPath(nsAutoString *name, nsIFile } nsCOMPtr res; - rv = rdf->GetResource(uriStr, getter_AddRefs(res)); + rv = rdf->GetUnicodeResource(uri, getter_AddRefs(res)); if (NS_FAILED(rv)) return rv; @@ -820,7 +820,7 @@ NS_IMETHODIMP nsImapMailFolder::CreateClientSubfolderInfo(const char *folderName uri.Append('/'); uri.AppendWithConversion(parentName); - rv = rdf->GetResource(uri.get(), + rv = rdf->GetResource(uri, getter_AddRefs(res)); if (NS_FAILED(rv)) return rv; parentFolder = do_QueryInterface(res, &rv); @@ -971,7 +971,7 @@ NS_IMETHODIMP nsImapMailFolder::CreateStorageIfMissing(nsIUrlListener* urlListen nsCOMPtr rdf(do_GetService(kRDFServiceCID, &status)); if (NS_FAILED(status)) return status; nsCOMPtr resource; - status = rdf->GetResource(parentName.get(), getter_AddRefs(resource)); + status = rdf->GetResource(parentName, getter_AddRefs(resource)); if (NS_FAILED(status)) return status; msgParent = do_QueryInterface(resource, &status); @@ -3310,7 +3310,7 @@ NS_IMETHODIMP nsImapMailFolder::FetchCustomMsgAttribute(const char *attribute, c nsresult nsImapMailFolder::MoveIncorporatedMessage(nsIMsgDBHdr *mailHdr, nsIMsgDatabase *sourceDB, - const char *destFolderUri, + const nsACString& destFolderUri, nsIMsgFilter *filter, nsIMsgWindow *msgWindow) { diff --git a/mailnews/imap/src/nsImapMailFolder.h b/mailnews/imap/src/nsImapMailFolder.h index 930d45a61270..39d96009958b 100644 --- a/mailnews/imap/src/nsImapMailFolder.h +++ b/mailnews/imap/src/nsImapMailFolder.h @@ -344,7 +344,7 @@ public: nsresult MoveIncorporatedMessage(nsIMsgDBHdr *mailHdr, nsIMsgDatabase *sourceDB, - const char *destFolder, + const nsACString& destFolder, nsIMsgFilter *filter, nsIMsgWindow *msgWindow); virtual nsresult SpamFilterClassifyMessage(const char *aURI, nsIMsgWindow *aMsgWindow, nsIJunkMailPlugin *aJunkMailPlugin); diff --git a/mailnews/imap/src/nsImapService.cpp b/mailnews/imap/src/nsImapService.cpp index 4922dea458e5..16d64d4411bc 100644 --- a/mailnews/imap/src/nsImapService.cpp +++ b/mailnews/imap/src/nsImapService.cpp @@ -874,7 +874,7 @@ nsresult nsImapService::DecomposeImapURI(const char * aMessageURI, nsIMsgFolder NS_ENSURE_SUCCESS(rv,rv); nsCOMPtr res; - rv = rdf->GetResource(folderURI.get(), getter_AddRefs(res)); + rv = rdf->GetResource(folderURI, getter_AddRefs(res)); NS_ENSURE_SUCCESS(rv,rv); rv = res->QueryInterface(NS_GET_IID(nsIMsgFolder), (void **) aFolder); diff --git a/mailnews/import/src/nsImportAddressBooks.cpp b/mailnews/import/src/nsImportAddressBooks.cpp index 997a022dfba6..cbc09bc762c2 100644 --- a/mailnews/import/src/nsImportAddressBooks.cpp +++ b/mailnews/import/src/nsImportAddressBooks.cpp @@ -803,7 +803,8 @@ nsIAddrDatabase *GetAddressBook( const PRUnichar *name, PRBool makeNew) NS_WITH_PROXIED_SERVICE(nsIRDFService, rdfService, kRDFServiceCID, NS_UI_THREAD_EVENTQ, &rv); if (NS_SUCCEEDED(rv)) { nsCOMPtr parentResource; - rv = rdfService->GetResource( kAllDirectoryRoot, getter_AddRefs(parentResource)); + rv = rdfService->GetResource(NS_LITERAL_CSTRING(kAllDirectoryRoot), + getter_AddRefs(parentResource)); nsCOMPtr parentDir; /* * TODO diff --git a/mailnews/local/src/nsLocalMailFolder.cpp b/mailnews/local/src/nsLocalMailFolder.cpp index 5899b612eda7..940fbc6863b4 100644 --- a/mailnews/local/src/nsLocalMailFolder.cpp +++ b/mailnews/local/src/nsLocalMailFolder.cpp @@ -280,7 +280,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::AddSubfolder(nsAutoString *name, return NS_MSG_FOLDER_EXISTS; nsCOMPtr res; - rv = rdf->GetResource(uri.get(), getter_AddRefs(res)); + rv = rdf->GetResource(uri, getter_AddRefs(res)); if (NS_FAILED(rv)) return rv; @@ -773,7 +773,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::CreateStorageIfMissing(nsIUrlListener* aUrlL NS_ENSURE_SUCCESS(rv,rv); nsCOMPtr resource; - rv = rdf->GetResource(parentName.get(), getter_AddRefs(resource)); + rv = rdf->GetResource(parentName, getter_AddRefs(resource)); NS_ENSURE_SUCCESS(rv,rv); msgParent = do_QueryInterface(resource, &rv); diff --git a/mailnews/local/src/nsMailboxService.cpp b/mailnews/local/src/nsMailboxService.cpp index 96ea406b383e..451a9bc90b77 100644 --- a/mailnews/local/src/nsMailboxService.cpp +++ b/mailnews/local/src/nsMailboxService.cpp @@ -553,7 +553,7 @@ nsMailboxService::DecomposeMailboxURI(const char * aMessageURI, nsIMsgFolder ** NS_ENSURE_SUCCESS(rv,rv); nsCOMPtr res; - rv = rdf->GetResource(folderURI.get(), getter_AddRefs(res)); + rv = rdf->GetResource(folderURI, getter_AddRefs(res)); NS_ENSURE_SUCCESS(rv,rv); rv = res->QueryInterface(NS_GET_IID(nsIMsgFolder), (void **) aFolder); diff --git a/mailnews/local/src/nsParseMailbox.cpp b/mailnews/local/src/nsParseMailbox.cpp index 6ff948d92620..33d0f796db07 100644 --- a/mailnews/local/src/nsParseMailbox.cpp +++ b/mailnews/local/src/nsParseMailbox.cpp @@ -1679,7 +1679,7 @@ NS_IMETHODIMP nsParseNewMailState::ApplyFilterHit(nsIMsgFilter *filter, nsIMsgWi if ((const char*)actionTargetFolderUri && nsCRT::strcasecmp(m_inboxUri, actionTargetFolderUri)) { - nsresult err = MoveIncorporatedMessage(msgHdr, m_mailDB, (const char *) actionTargetFolderUri, filter, msgWindow); + nsresult err = MoveIncorporatedMessage(msgHdr, m_mailDB, actionTargetFolderUri, filter, msgWindow); if (NS_SUCCEEDED(err)) { if (loggingEnabled) @@ -1739,7 +1739,7 @@ int nsParseNewMailState::MarkFilteredMessageRead(nsIMsgDBHdr *msgHdr) nsresult nsParseNewMailState::MoveIncorporatedMessage(nsIMsgDBHdr *mailHdr, nsIMsgDatabase *sourceDB, - const char *destFolderUri, + const nsACString& destFolderUri, nsIMsgFilter *filter, nsIMsgWindow *msgWindow) { diff --git a/mailnews/local/src/nsParseMailbox.h b/mailnews/local/src/nsParseMailbox.h index 67ae2b9799cb..c002d693debe 100644 --- a/mailnews/local/src/nsParseMailbox.h +++ b/mailnews/local/src/nsParseMailbox.h @@ -252,7 +252,7 @@ protected: virtual nsresult GetTrashFolder(nsIMsgFolder **pTrashFolder); virtual nsresult MoveIncorporatedMessage(nsIMsgDBHdr *mailHdr, nsIMsgDatabase *sourceDB, - const char *destFolder, + const nsACString& destFolder, nsIMsgFilter *filter, nsIMsgWindow *msgWindow); virtual int MarkFilteredMessageRead(nsIMsgDBHdr *msgHdr); diff --git a/mailnews/local/src/nsPop3Service.cpp b/mailnews/local/src/nsPop3Service.cpp index b14010cebe20..9ea14a5f5ad7 100644 --- a/mailnews/local/src/nsPop3Service.cpp +++ b/mailnews/local/src/nsPop3Service.cpp @@ -289,7 +289,7 @@ NS_IMETHODIMP nsPop3Service::NewURI(const nsACString &aSpec, nsCOMPtr rdfService(do_GetService(kRDFServiceCID, &rv)); if (NS_FAILED(rv)) return rv; - rv = rdfService->GetResource(folderUri.get(), + rv = rdfService->GetResource(folderUri, getter_AddRefs(resource)); if (NS_FAILED(rv)) return rv; nsCOMPtr folder = do_QueryInterface(resource, &rv); diff --git a/mailnews/news/src/nsNewsFolder.cpp b/mailnews/news/src/nsNewsFolder.cpp index 37a2c6b50f8c..f93eba940272 100644 --- a/mailnews/news/src/nsNewsFolder.cpp +++ b/mailnews/news/src/nsNewsFolder.cpp @@ -225,7 +225,7 @@ nsMsgNewsFolder::AddNewsgroup(const char *name, const char *setStr, nsIMsgFolder uri.Append(escapedName.get()); nsCOMPtr res; - rv = rdf->GetResource(uri.get(), getter_AddRefs(res)); + rv = rdf->GetResource(uri, getter_AddRefs(res)); if (NS_FAILED(rv)) return rv; nsCOMPtr folder(do_QueryInterface(res, &rv)); diff --git a/mailnews/news/src/nsNntpService.cpp b/mailnews/news/src/nsNntpService.cpp index a166ac27e8a0..bd5f60bf67e6 100644 --- a/mailnews/news/src/nsNntpService.cpp +++ b/mailnews/news/src/nsNntpService.cpp @@ -621,10 +621,10 @@ nsNntpService::GetFolderFromUri(const char *uri, nsIMsgFolder **folder) if ((strlen(uri) > kNntpRootURILen) && nsCRT::strncmp(uri, kNntpRootURI, kNntpRootURILen) == 0) { nsCAutoString uriStr(kNewsRootURI); uriStr.Append(uri+kNntpRootURILen); - rv = rdf->GetResource(uriStr.get(), getter_AddRefs(res)); + rv = rdf->GetResource(uriStr, getter_AddRefs(res)); } else { - rv = rdf->GetResource(uri, getter_AddRefs(res)); + rv = rdf->GetResource(nsDependentCString(uri), getter_AddRefs(res)); } NS_ENSURE_SUCCESS(rv,rv); diff --git a/rdf/base/idl/nsIRDFService.idl b/rdf/base/idl/nsIRDFService.idl index 386ed1cc85a6..1f9f0ae4f85b 100644 --- a/rdf/base/idl/nsIRDFService.idl +++ b/rdf/base/idl/nsIRDFService.idl @@ -49,13 +49,13 @@ interface nsIRDFService : nsISupports { // caches resources that are in-use, so multiple calls to GetResource() // for the same uri will return identical pointers. FindResource // is used to find out whether there already exists a resource corresponding to that url. - nsIRDFResource GetResource(in string aURI); + nsIRDFResource GetResource(in AUTF8String aURI); // Construct an RDF resource from a Unicode URI. This is provided // as a convenience method, allowing automatic, in-line C++ // conversion from nsString objects. The uri will // be converted to a single-byte representation internally. - nsIRDFResource GetUnicodeResource(in wstring aURI); + nsIRDFResource GetUnicodeResource(in AString aURI); nsIRDFResource GetAnonymousResource(); diff --git a/rdf/base/src/nsContainerEnumerator.cpp b/rdf/base/src/nsContainerEnumerator.cpp index 76da27a7a71c..59344dbba5a4 100644 --- a/rdf/base/src/nsContainerEnumerator.cpp +++ b/rdf/base/src/nsContainerEnumerator.cpp @@ -123,7 +123,7 @@ ContainerEnumeratorImpl::Init() if (! rdf) return NS_ERROR_FAILURE; - rv = rdf->GetResource(RDF_NAMESPACE_URI "nextVal", &kRDF_nextVal); + rv = rdf->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "nextVal"), &kRDF_nextVal); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource"); if (NS_FAILED(rv)) return rv; diff --git a/rdf/base/src/nsRDFContainer.cpp b/rdf/base/src/nsRDFContainer.cpp index 73fe8fc03cd2..2a0a77cb61d0 100644 --- a/rdf/base/src/nsRDFContainer.cpp +++ b/rdf/base/src/nsRDFContainer.cpp @@ -421,7 +421,8 @@ RDFContainerImpl::Init() NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service"); if (NS_FAILED(rv)) return rv; - rv = gRDFService->GetResource(RDF_NAMESPACE_URI "nextVal", &kRDF_nextVal); + rv = gRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "nextVal"), + &kRDF_nextVal); if (NS_FAILED(rv)) return rv; rv = nsServiceManager::GetService(kRDFContainerUtilsCID, @@ -739,7 +740,7 @@ RDFContainerImpl::GetNextValue(nsIRDFResource** aResult) nextValStr.Append("_"); nextValStr.AppendInt(nextVal, 10); - rv = gRDFService->GetResource(nextValStr.get(), aResult); + rv = gRDFService->GetResource(nextValStr, aResult); if (NS_FAILED(rv)) return rv; // Now increment the RDF:nextVal property. diff --git a/rdf/base/src/nsRDFContainerUtils.cpp b/rdf/base/src/nsRDFContainerUtils.cpp index 7a74eef93ab5..1fc1e4a009fc 100644 --- a/rdf/base/src/nsRDFContainerUtils.cpp +++ b/rdf/base/src/nsRDFContainerUtils.cpp @@ -157,18 +157,11 @@ RDFContainerUtilsImpl::IndexToOrdinalResource(PRInt32 aIndex, nsIRDFResource **a if (aIndex <= 0) return NS_ERROR_ILLEGAL_VALUE; - // 16 digits should be plenty to hold a decimal version of a - // PRInt32. - char buf[sizeof(kRDFNameSpaceURI) + 16 + 1]; - - PL_strcpy(buf, kRDFNameSpaceURI); - buf[sizeof(kRDFNameSpaceURI) - 1] = '_'; + nsCAutoString uri(kRDFNameSpaceURI); + uri.Append('_'); + uri.AppendInt(aIndex); - PR_snprintf(buf + sizeof(kRDFNameSpaceURI), 16, "%ld", aIndex); - - nsresult rv; - - rv = gRDFService->GetResource(buf, aOrdinal); + nsresult rv = gRDFService->GetResource(uri, aOrdinal); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get ordinal resource"); if (NS_FAILED(rv)) return rv; @@ -371,11 +364,16 @@ RDFContainerUtilsImpl::RDFContainerUtilsImpl() NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service"); if (NS_SUCCEEDED(rv)) { - gRDFService->GetResource(RDF_NAMESPACE_URI "instanceOf", &kRDF_instanceOf); - gRDFService->GetResource(RDF_NAMESPACE_URI "nextVal", &kRDF_nextVal); - gRDFService->GetResource(RDF_NAMESPACE_URI "Bag", &kRDF_Bag); - gRDFService->GetResource(RDF_NAMESPACE_URI "Seq", &kRDF_Seq); - gRDFService->GetResource(RDF_NAMESPACE_URI "Alt", &kRDF_Alt); + gRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "instanceOf"), + &kRDF_instanceOf); + gRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "nextVal"), + &kRDF_nextVal); + gRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "Bag"), + &kRDF_Bag); + gRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "Seq"), + &kRDF_Seq); + gRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "Alt"), + &kRDF_Alt); gRDFService->GetLiteral(NS_LITERAL_STRING("1").get(), &kOne); } } diff --git a/rdf/base/src/nsRDFContentSink.cpp b/rdf/base/src/nsRDFContentSink.cpp index 1202c856ccf4..aab7f44aa60e 100644 --- a/rdf/base/src/nsRDFContentSink.cpp +++ b/rdf/base/src/nsRDFContentSink.cpp @@ -334,12 +334,18 @@ RDFContentSinkImpl::RDFContentSinkImpl() NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service"); if (NS_SUCCEEDED(rv)) { - rv = gRDFService->GetResource(RDF_NAMESPACE_URI "type", &kRDF_type); - rv = gRDFService->GetResource(RDF_NAMESPACE_URI "instanceOf", &kRDF_instanceOf); - rv = gRDFService->GetResource(RDF_NAMESPACE_URI "Alt", &kRDF_Alt); - rv = gRDFService->GetResource(RDF_NAMESPACE_URI "Bag", &kRDF_Bag); - rv = gRDFService->GetResource(RDF_NAMESPACE_URI "Seq", &kRDF_Seq); - rv = gRDFService->GetResource(RDF_NAMESPACE_URI "nextVal", &kRDF_nextVal); + rv = gRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "type"), + &kRDF_type); + rv = gRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "instanceOf"), + &kRDF_instanceOf); + rv = gRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "Alt"), + &kRDF_Alt); + rv = gRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "Bag"), + &kRDF_Bag); + rv = gRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "Seq"), + &kRDF_Seq); + rv = gRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "nextVal"), + &kRDF_nextVal); } @@ -764,7 +770,7 @@ RDFContentSinkImpl::ParseText(nsIRDFNode **aResult) case eRDFContentSinkParseMode_Resource: { nsIRDFResource *result; - gRDFService->GetUnicodeResource(value.get(), &result); + gRDFService->GetUnicodeResource(value, &result); *aResult = result; } break; @@ -958,7 +964,7 @@ RDFContentSinkImpl::GetIdAboutAttribute(const PRUnichar** aAttributes, rdf_MakeAbsoluteURI(NS_ConvertUTF8toUCS2(docURI), uri); - return gRDFService->GetUnicodeResource(uri.get(), aResource); + return gRDFService->GetUnicodeResource(uri, aResource); } else if (attr.get() == kIdAtom) { if (aIsAnonymous) @@ -979,7 +985,7 @@ RDFContentSinkImpl::GetIdAboutAttribute(const PRUnichar** aAttributes, rdf_MakeAbsoluteURI(NS_ConvertUTF8toUCS2(docURI), name); - return gRDFService->GetUnicodeResource(name.get(), aResource); + return gRDFService->GetUnicodeResource(name, aResource); } else if (attr.get() == kAboutEachAtom) { // XXX we don't deal with aboutEach... @@ -1033,7 +1039,7 @@ RDFContentSinkImpl::GetResourceAttribute(const PRUnichar** aAttributes, mDocumentURL->GetSpec(documentURL); rdf_MakeAbsoluteURI(NS_ConvertUTF8toUCS2(documentURL), uri); - return gRDFService->GetUnicodeResource(uri.get(), aResource); + return gRDFService->GetUnicodeResource(uri, aResource); } } return NS_ERROR_FAILURE; @@ -1096,7 +1102,7 @@ RDFContentSinkImpl::AddProperties(const PRUnichar** aAttributes, // Add the assertion to RDF nsCOMPtr property; - gRDFService->GetResource(propertyStr.get(), getter_AddRefs(property)); + gRDFService->GetResource(propertyStr, getter_AddRefs(property)); nsCOMPtr target; gRDFService->GetLiteral(v.get(), getter_AddRefs(target)); @@ -1238,7 +1244,7 @@ RDFContentSinkImpl::OpenObject(const PRUnichar* aName, typeStr += NS_ConvertUCS2toUTF8(attrName); nsCOMPtr type; - rv = gRDFService->GetResource(typeStr.get(), getter_AddRefs(type)); + rv = gRDFService->GetResource(typeStr, getter_AddRefs(type)); if (NS_FAILED(rv)) return rv; rv = mDataSource->Assert(source, kRDF_type, type, PR_TRUE); @@ -1277,7 +1283,7 @@ RDFContentSinkImpl::OpenProperty(const PRUnichar* aName, const PRUnichar** aAttr } nsCOMPtr property; - rv = gRDFService->GetResource(propertyStr.get(), getter_AddRefs(property)); + rv = gRDFService->GetResource(propertyStr, getter_AddRefs(property)); if (NS_FAILED(rv)) return rv; // See if they've specified a 'resource' attribute, in which case diff --git a/rdf/base/src/nsRDFService.cpp b/rdf/base/src/nsRDFService.cpp index b3798c62941e..bba9ee57f5db 100644 --- a/rdf/base/src/nsRDFService.cpp +++ b/rdf/base/src/nsRDFService.cpp @@ -105,8 +105,7 @@ protected: PLDHashTable mDates; PLDHashTable mBlobs; - char mLastURIPrefix[16]; - PRInt32 mLastPrefixlen; + nsCAutoString mLastURIPrefix; nsCOMPtr mLastFactory; nsCOMPtr mDefaultResourceFactory; @@ -859,8 +858,7 @@ IntImpl::EqualsInt(nsIRDFInt* intValue, PRBool* result) // RDFServiceImpl RDFServiceImpl::RDFServiceImpl() - : mNamedDataSources(nsnull), - mLastPrefixlen(0) + : mNamedDataSources(nsnull) { } @@ -983,23 +981,20 @@ IsLegalSchemeCharacter(const char aChar) NS_IMETHODIMP -RDFServiceImpl::GetResource(const char* aURI, nsIRDFResource** aResource) +RDFServiceImpl::GetResource(const nsACString& aURI, nsIRDFResource** aResource) { // Sanity checks - NS_PRECONDITION(aURI != nsnull, "null ptr"); - if (! aURI) - return NS_ERROR_NULL_POINTER; - NS_PRECONDITION(aResource != nsnull, "null ptr"); if (! aResource) return NS_ERROR_NULL_POINTER; - PR_LOG(gLog, PR_LOG_DEBUG, ("rdfserv get-resource %s", aURI)); + const nsAFlatCString& flatURI = PromiseFlatCString(aURI); + PR_LOG(gLog, PR_LOG_DEBUG, ("rdfserv get-resource %s", flatURI.get())); // First, check the cache to see if we've already created and // registered this thing. PLDHashEntryHdr *hdr = - PL_DHashTableOperate(&mResources, aURI, PL_DHASH_LOOKUP); + PL_DHashTableOperate(&mResources, flatURI.get(), PL_DHASH_LOOKUP); if (PL_DHASH_ENTRY_IS_BUSY(hdr)) { ResourceHashEntry *entry = NS_STATIC_CAST(ResourceHashEntry *, hdr); @@ -1020,50 +1015,32 @@ RDFServiceImpl::GetResource(const char* aURI, nsIRDFResource** aResource) // // XXX Although it's really not correct, we'll allow underscore // characters ('_'), too. - const char* p = aURI; - while (IsLegalSchemeCharacter(*p)) + nsACString::const_iterator p, end; + aURI.BeginReading(p); + aURI.EndReading(end); + while (IsLegalSchemeCharacter(*p) && p != end) ++p; nsresult rv; nsCOMPtr factory; - PRUint32 prefixlen = 0; + nsACString::const_iterator begin; + aURI.BeginReading(begin); if (*p == ':') { // There _was_ a scheme. First see if it's the same scheme // that we just tried to use... - prefixlen = (p - aURI); - - if ((mLastFactory) && ((PRInt32)prefixlen == mLastPrefixlen) && - (aURI[0] == mLastURIPrefix[0]) && - (0 == PL_strncmp(aURI, mLastURIPrefix, prefixlen))) { + if (mLastFactory && mLastURIPrefix.Equals(Substring(begin, p))) factory = mLastFactory; - } else { // Try to find a factory using the component manager. - static const char kRDFResourceFactoryContractIDPrefix[] - = NS_RDF_RESOURCE_FACTORY_CONTRACTID_PREFIX; - - PRInt32 pos = p - aURI; - PRInt32 len = pos + sizeof(kRDFResourceFactoryContractIDPrefix) - 1; - - // Safely convert to a C-string for the XPCOM APIs - char buf[128]; - char* contractID = buf; - if (len >= PRInt32(sizeof buf)) - contractID = (char *)nsMemory::Alloc(len + 1); - - if (contractID == nsnull) - return NS_ERROR_OUT_OF_MEMORY; - - PL_strcpy(contractID, kRDFResourceFactoryContractIDPrefix); - PL_strncpy(contractID + sizeof(kRDFResourceFactoryContractIDPrefix) - 1, aURI, pos); - contractID[len] = '\0'; + nsACString::const_iterator begin; + aURI.BeginReading(begin); + nsCAutoString contractID; + contractID = NS_LITERAL_CSTRING(NS_RDF_RESOURCE_FACTORY_CONTRACTID_PREFIX) + + Substring(begin, p); nsCID cid; - rv = nsComponentManager::ContractIDToClassID(contractID, &cid); - - if (contractID != buf) - nsCRT::free(contractID); + rv = nsComponentManager::ContractIDToClassID(contractID.get(), &cid); if (NS_SUCCEEDED(rv)) { rv = nsComponentManager::FindFactory(cid, getter_AddRefs(factory)); @@ -1071,10 +1048,9 @@ RDFServiceImpl::GetResource(const char* aURI, nsIRDFResource** aResource) if (NS_FAILED(rv)) return rv; // Store the factory in our one-element cache. - if ((prefixlen > 0) && (prefixlen < sizeof(mLastURIPrefix))) { + if (p != begin) { mLastFactory = factory; - PL_strncpyz(mLastURIPrefix, aURI, prefixlen + 1); - mLastPrefixlen = prefixlen; + mLastURIPrefix = Substring(begin, p); } } } @@ -1088,10 +1064,9 @@ RDFServiceImpl::GetResource(const char* aURI, nsIRDFResource** aResource) factory = mDefaultResourceFactory; // Store the factory in our one-element cache. - if ((prefixlen > 0) && (prefixlen < sizeof(mLastURIPrefix))) { + if (p != begin) { mLastFactory = factory; - PL_strncpyz(mLastURIPrefix, aURI, prefixlen + 1); - mLastPrefixlen = prefixlen; + mLastURIPrefix = Substring(begin, p); } } @@ -1101,7 +1076,7 @@ RDFServiceImpl::GetResource(const char* aURI, nsIRDFResource** aResource) // Now initialize it with it's URI. At this point, the resource // implementation should register itself with the RDF service. - rv = result->Init(aURI); + rv = result->Init(flatURI.get()); if (NS_FAILED(rv)) { NS_ERROR("unable to initialize resource"); NS_RELEASE(result); @@ -1113,13 +1088,9 @@ RDFServiceImpl::GetResource(const char* aURI, nsIRDFResource** aResource) } NS_IMETHODIMP -RDFServiceImpl::GetUnicodeResource(const PRUnichar* aURI, nsIRDFResource** aResource) +RDFServiceImpl::GetUnicodeResource(const nsAString& aURI, nsIRDFResource** aResource) { - NS_PRECONDITION(aURI != nsnull, "null ptr"); - if (! aURI) - return NS_ERROR_NULL_POINTER; - - return GetResource(NS_ConvertUCS2toUTF8(aURI).get(), aResource); + return GetResource(NS_ConvertUCS2toUTF8(aURI), aResource); } @@ -1166,7 +1137,7 @@ static PRInt32 kShift = 6; } nsIRDFResource* resource; - rv = GetResource(s.get(), &resource); + rv = GetResource(s, &resource); if (NS_FAILED(rv)) return rv; // XXX an ugly but effective way to make sure that this diff --git a/rdf/base/src/nsRDFXMLSerializer.cpp b/rdf/base/src/nsRDFXMLSerializer.cpp index feba9c1b5f91..40236f6d2ca8 100644 --- a/rdf/base/src/nsRDFXMLSerializer.cpp +++ b/rdf/base/src/nsRDFXMLSerializer.cpp @@ -60,22 +60,28 @@ nsRDFXMLSerializer::Create(nsISupports* aOuter, REFNSIID aIID, void** aResult) nsCOMPtr rdf = do_GetService("@mozilla.org/rdf/rdf-service;1", &rv); if (NS_FAILED(rv)) break; - rv = rdf->GetResource(RDF_NAMESPACE_URI "instanceOf", &kRDF_instanceOf); + rv = rdf->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "instanceOf"), + &kRDF_instanceOf); if (NS_FAILED(rv)) break; - rv = rdf->GetResource(RDF_NAMESPACE_URI "type", &kRDF_type); + rv = rdf->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "type"), + &kRDF_type); if (NS_FAILED(rv)) break; - rv = rdf->GetResource(RDF_NAMESPACE_URI "nextVal", &kRDF_nextVal); + rv = rdf->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "nextVal"), + &kRDF_nextVal); if (NS_FAILED(rv)) break; - rv = rdf->GetResource(RDF_NAMESPACE_URI "Bag", &kRDF_Bag); + rv = rdf->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "Bag"), + &kRDF_Bag); if (NS_FAILED(rv)) break; - rv = rdf->GetResource(RDF_NAMESPACE_URI "Seq", &kRDF_Seq); + rv = rdf->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "Seq"), + &kRDF_Seq); if (NS_FAILED(rv)) break; - rv = rdf->GetResource(RDF_NAMESPACE_URI "Alt", &kRDF_Alt); + rv = rdf->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "Alt"), + &kRDF_Alt); if (NS_FAILED(rv)) break; rv = nsServiceManager::GetService("@mozilla.org/rdf/container-utils;1", diff --git a/rdf/chrome/src/nsChromeRegistry.cpp b/rdf/chrome/src/nsChromeRegistry.cpp index e6886d573b9f..e7d923430c95 100644 --- a/rdf/chrome/src/nsChromeRegistry.cpp +++ b/rdf/chrome/src/nsChromeRegistry.cpp @@ -326,49 +326,64 @@ nsChromeRegistry::Init() (nsISupports**)&mRDFContainerUtils); NS_ENSURE_SUCCESS(rv, rv); - rv = mRDFService->GetResource(kURICHROME_selectedSkin, getter_AddRefs(mSelectedSkin)); + rv = mRDFService->GetResource(nsDependentCString(kURICHROME_selectedSkin), + getter_AddRefs(mSelectedSkin)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource"); - rv = mRDFService->GetResource(kURICHROME_selectedLocale, getter_AddRefs(mSelectedLocale)); + rv = mRDFService->GetResource(nsDependentCString(kURICHROME_selectedLocale), + getter_AddRefs(mSelectedLocale)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource"); - rv = mRDFService->GetResource(kURICHROME_baseURL, getter_AddRefs(mBaseURL)); + rv = mRDFService->GetResource(nsDependentCString(kURICHROME_baseURL), + getter_AddRefs(mBaseURL)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource"); - rv = mRDFService->GetResource(kURICHROME_packages, getter_AddRefs(mPackages)); + rv = mRDFService->GetResource(nsDependentCString(kURICHROME_packages), + getter_AddRefs(mPackages)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource"); - rv = mRDFService->GetResource(kURICHROME_package, getter_AddRefs(mPackage)); + rv = mRDFService->GetResource(nsDependentCString(kURICHROME_package), + getter_AddRefs(mPackage)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource"); - rv = mRDFService->GetResource(kURICHROME_name, getter_AddRefs(mName)); + rv = mRDFService->GetResource(nsDependentCString(kURICHROME_name), + getter_AddRefs(mName)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource"); - rv = mRDFService->GetResource(kURICHROME_image, getter_AddRefs(mImage)); + rv = mRDFService->GetResource(nsDependentCString(kURICHROME_image), + getter_AddRefs(mImage)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource"); - rv = mRDFService->GetResource(kURICHROME_locType, getter_AddRefs(mLocType)); + rv = mRDFService->GetResource(nsDependentCString(kURICHROME_locType), + getter_AddRefs(mLocType)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource"); - rv = mRDFService->GetResource(kURICHROME_allowScripts, getter_AddRefs(mAllowScripts)); + rv = mRDFService->GetResource(nsDependentCString(kURICHROME_allowScripts), + getter_AddRefs(mAllowScripts)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource"); - rv = mRDFService->GetResource(kURICHROME_hasOverlays, getter_AddRefs(mHasOverlays)); + rv = mRDFService->GetResource(nsDependentCString(kURICHROME_hasOverlays), + getter_AddRefs(mHasOverlays)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource"); - rv = mRDFService->GetResource(kURICHROME_hasStylesheets, getter_AddRefs(mHasStylesheets)); + rv = mRDFService->GetResource(nsDependentCString(kURICHROME_hasStylesheets), + getter_AddRefs(mHasStylesheets)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource"); - rv = mRDFService->GetResource(kURICHROME_skinVersion, getter_AddRefs(mSkinVersion)); + rv = mRDFService->GetResource(nsDependentCString(kURICHROME_skinVersion), + getter_AddRefs(mSkinVersion)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource"); - rv = mRDFService->GetResource(kURICHROME_localeVersion, getter_AddRefs(mLocaleVersion)); + rv = mRDFService->GetResource(nsDependentCString(kURICHROME_localeVersion), + getter_AddRefs(mLocaleVersion)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource"); - rv = mRDFService->GetResource(kURICHROME_packageVersion, getter_AddRefs(mPackageVersion)); + rv = mRDFService->GetResource(nsDependentCString(kURICHROME_packageVersion), + getter_AddRefs(mPackageVersion)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource"); - rv = mRDFService->GetResource(kURICHROME_disabled, getter_AddRefs(mDisabled)); + rv = mRDFService->GetResource(nsDependentCString(kURICHROME_disabled), + getter_AddRefs(mDisabled)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource"); nsCOMPtr observerService = @@ -1251,11 +1266,11 @@ nsChromeRegistry::LoadDataSource(const nsACString &aFileName, //////////////////////////////////////////////////////////////////////////////// nsresult -nsChromeRegistry::GetResource(const nsCString& aURL, +nsChromeRegistry::GetResource(const nsACString& aURL, nsIRDFResource** aResult) { nsresult rv = NS_OK; - if (NS_FAILED(rv = mRDFService->GetResource(aURL.get(), aResult))) { + if (NS_FAILED(rv = mRDFService->GetResource(aURL, aResult))) { NS_ERROR("Unable to retrieve a resource for this URL."); *aResult = nsnull; return rv; diff --git a/rdf/chrome/src/nsChromeRegistry.h b/rdf/chrome/src/nsChromeRegistry.h index c6a9e448cfaf..feb861dd1057 100644 --- a/rdf/chrome/src/nsChromeRegistry.h +++ b/rdf/chrome/src/nsChromeRegistry.h @@ -93,7 +93,7 @@ protected: nsresult GetDynamicDataSource(nsIURI *aChromeURL, PRBool aIsOverlay, PRBool aUseProfile, PRBool aCreateDS, nsIRDFDataSource **aResult); nsresult GetDynamicInfo(nsIURI *aChromeURL, PRBool aIsOverlay, nsISimpleEnumerator **aResult); - nsresult GetResource(const nsCString& aChromeType, nsIRDFResource** aResult); + nsresult GetResource(const nsACString& aChromeType, nsIRDFResource** aResult); nsresult UpdateDynamicDataSource(nsIRDFDataSource *aDataSource, nsIRDFResource *aResource, diff --git a/rdf/datasource/src/nsFileSystemDataSource.cpp b/rdf/datasource/src/nsFileSystemDataSource.cpp index eaf2f94084a5..ef0e18d5fcb2 100644 --- a/rdf/datasource/src/nsFileSystemDataSource.cpp +++ b/rdf/datasource/src/nsFileSystemDataSource.cpp @@ -98,7 +98,6 @@ static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_C #define NS_MOZICON_SCHEME "moz-icon:" -static const char kURINC_FileSystemRoot[] = "NC:FilesRoot"; static const char kFileProtocol[] = "file://"; @@ -294,8 +293,10 @@ FileSystemDataSource::FileSystemDataSource(void) { ieFavoritesDir = nsCRT::strdup(ieFavoritesURI); } - gRDFService->GetResource(NC_NAMESPACE_URI "IEFavorite", &kNC_IEFavoriteObject); - gRDFService->GetResource(NC_NAMESPACE_URI "IEFavoriteFolder", &kNC_IEFavoriteFolder); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "IEFavorite"), + &kNC_IEFavoriteObject); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "IEFavoriteFolder"), + &kNC_IEFavoriteFolder); #endif #ifdef XP_BEOS @@ -310,22 +311,35 @@ FileSystemDataSource::FileSystemDataSource(void) } #endif - gRDFService->GetResource(kURINC_FileSystemRoot, &kNC_FileSystemRoot); - gRDFService->GetResource(NC_NAMESPACE_URI "child", &kNC_Child); - gRDFService->GetResource(NC_NAMESPACE_URI "Name", &kNC_Name); - gRDFService->GetResource(NC_NAMESPACE_URI "URL", &kNC_URL); - gRDFService->GetResource(NC_NAMESPACE_URI "Icon", &kNC_Icon); - gRDFService->GetResource(NC_NAMESPACE_URI "Content-Length", &kNC_Length); - gRDFService->GetResource(NC_NAMESPACE_URI "IsDirectory", &kNC_IsDirectory); - gRDFService->GetResource(WEB_NAMESPACE_URI "LastModifiedDate", &kWEB_LastMod); - gRDFService->GetResource(NC_NAMESPACE_URI "FileSystemObject", &kNC_FileSystemObject); - gRDFService->GetResource(NC_NAMESPACE_URI "pulse", &kNC_pulse); + gRDFService->GetResource(NS_LITERAL_CSTRING("NC:FilesRoot"), + &kNC_FileSystemRoot); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "child"), + &kNC_Child); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Name"), + &kNC_Name); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "URL"), + &kNC_URL); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Icon"), + &kNC_Icon); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Content-Length"), + &kNC_Length); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "IsDirectory"), + &kNC_IsDirectory); + gRDFService->GetResource(NS_LITERAL_CSTRING(WEB_NAMESPACE_URI "LastModifiedDate"), + &kWEB_LastMod); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "FileSystemObject"), + &kNC_FileSystemObject); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "pulse"), + &kNC_pulse); - gRDFService->GetResource(RDF_NAMESPACE_URI "instanceOf", &kRDF_InstanceOf); - gRDFService->GetResource(RDF_NAMESPACE_URI "type", &kRDF_type); + gRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "instanceOf"), + &kRDF_InstanceOf); + gRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "type"), + &kRDF_type); #ifdef USE_NC_EXTENSION - gRDFService->GetResource(NC_NAMESPACE_URI "extension", &kNC_extension); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "extension"), + &kNC_extension); #endif gRDFService->GetLiteral(NS_LITERAL_STRING("true").get(), &kLiteralTrue); gRDFService->GetLiteral(NS_LITERAL_STRING("false").get(), &kLiteralFalse); @@ -1141,7 +1155,7 @@ FileSystemDataSource::GetVolumeList(nsISimpleEnumerator** aResult) #endif #if defined(XP_UNIX) || defined(XP_BEOS) - gRDFService->GetResource("file:///", getter_AddRefs(vol)); + gRDFService->GetResource(NS_LITERAL_CSTRING("file:///"), getter_AddRefs(vol)); volumes->AppendElement(vol); #endif @@ -1307,13 +1321,8 @@ FileSystemDataSource::GetFolderList(nsIRDFResource *source, PRBool allowHidden, continue; } - // XXX We should use nsIFile::GetUnicodeLeafName(). - // But currently mozilla's xpcom/io is not unicode normalization. - // And URI cannot use UTF-8 (On RFC2396, URI should use UTF-8) - // So, we uses nsIFile::GetNativeLeafName() for performance... - - nsCAutoString leafStr; - if (NS_FAILED(rv = aFile->GetNativeLeafName(leafStr))) + nsAutoString leafStr; + if (NS_FAILED(rv = aFile->GetLeafName(leafStr))) break; if (leafStr.IsEmpty()) continue; @@ -1325,7 +1334,7 @@ FileSystemDataSource::GetFolderList(nsIRDFResource *source, PRBool allowHidden, fullURI.Append('/'); } - char *escLeafStr = nsEscape(leafStr.get(), url_Path); + char *escLeafStr = nsEscape(NS_ConvertUCS2toUTF8(leafStr).get(), url_Path); leafStr.Truncate(); if (!escLeafStr) @@ -1354,7 +1363,7 @@ FileSystemDataSource::GetFolderList(nsIRDFResource *source, PRBool allowHidden, } nsCOMPtr fileRes; - gRDFService->GetResource(fullURI.get(), getter_AddRefs(fileRes)); + gRDFService->GetResource(fullURI, getter_AddRefs(fileRes)); nameArray->AppendElement(fileRes); diff --git a/uriloader/exthandler/nsExternalHelperAppService.cpp b/uriloader/exthandler/nsExternalHelperAppService.cpp index 56f602f2a5d5..d8d370fd283e 100644 --- a/uriloader/exthandler/nsExternalHelperAppService.cpp +++ b/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -234,15 +234,24 @@ nsresult nsExternalHelperAppService::InitDataSource() // initialize our resources if we haven't done so already... if (!kNC_Description) { - rdf->GetResource(NC_RDF_DESCRIPTION, getter_AddRefs(kNC_Description)); - rdf->GetResource(NC_RDF_VALUE, getter_AddRefs(kNC_Value)); - rdf->GetResource(NC_RDF_FILEEXTENSIONS,getter_AddRefs(kNC_FileExtensions)); - rdf->GetResource(NC_RDF_PATH, getter_AddRefs(kNC_Path)); - rdf->GetResource(NC_RDF_SAVETODISK, getter_AddRefs(kNC_SaveToDisk)); - rdf->GetResource(NC_RDF_USESYSTEMDEFAULT,getter_AddRefs(kNC_UseSystemDefault)); - rdf->GetResource(NC_RDF_HANDLEINTERNAL,getter_AddRefs(kNC_HandleInternal)); - rdf->GetResource(NC_RDF_ALWAYSASK, getter_AddRefs(kNC_AlwaysAsk)); - rdf->GetResource(NC_RDF_PRETTYNAME, getter_AddRefs(kNC_PrettyName)); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_DESCRIPTION), + getter_AddRefs(kNC_Description)); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_VALUE), + getter_AddRefs(kNC_Value)); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_FILEEXTENSIONS), + getter_AddRefs(kNC_FileExtensions)); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_PATH), + getter_AddRefs(kNC_Path)); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_SAVETODISK), + getter_AddRefs(kNC_SaveToDisk)); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_USESYSTEMDEFAULT), + getter_AddRefs(kNC_UseSystemDefault)); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_HANDLEINTERNAL), + getter_AddRefs(kNC_HandleInternal)); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_ALWAYSASK), + getter_AddRefs(kNC_AlwaysAsk)); + rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_PRETTYNAME), + getter_AddRefs(kNC_PrettyName)); } mDataSourceInitialized = PR_TRUE; @@ -527,7 +536,7 @@ nsresult nsExternalHelperAppService::FillContentHandlerProperties(const char * a contentTypeHandlerNodeName.Append(aContentType); nsCOMPtr contentTypeHandlerNodeResource; - aRDFService->GetResource(contentTypeHandlerNodeName.get(), getter_AddRefs(contentTypeHandlerNodeResource)); + aRDFService->GetResource(contentTypeHandlerNodeName, getter_AddRefs(contentTypeHandlerNodeResource)); NS_ENSURE_TRUE(contentTypeHandlerNodeResource, NS_ERROR_FAILURE); // that's not good! we have an error in the rdf file // now process the application handler information @@ -562,7 +571,7 @@ nsresult nsExternalHelperAppService::FillContentHandlerProperties(const char * a nsCAutoString externalAppNodeName (NC_CONTENT_NODE_EXTERNALAPP_PREFIX); externalAppNodeName.Append(aContentType); nsCOMPtr externalAppNodeResource; - aRDFService->GetResource(externalAppNodeName.get(), getter_AddRefs(externalAppNodeResource)); + aRDFService->GetResource(externalAppNodeName, getter_AddRefs(externalAppNodeResource)); if (externalAppNodeResource) { @@ -602,7 +611,7 @@ PRBool nsExternalHelperAppService::MIMETypeIsInDataSource(const char * aContentT // Get the mime type resource. nsCOMPtr contentTypeNodeResource; - rv = rdf->GetResource(contentTypeNodeName.get(), getter_AddRefs(contentTypeNodeResource)); + rv = rdf->GetResource(contentTypeNodeName, getter_AddRefs(contentTypeNodeResource)); if (NS_FAILED(rv)) return PR_FALSE; // Test that there's a #value arc from the mimetype resource to the mimetype literal string. @@ -644,7 +653,7 @@ nsresult nsExternalHelperAppService::GetMIMEInfoForMimeTypeFromDS(const char * a // Get the mime type resource. nsCOMPtr contentTypeNodeResource; - rv = rdf->GetResource(contentTypeNodeName.get(), getter_AddRefs(contentTypeNodeResource)); + rv = rdf->GetResource(contentTypeNodeName, getter_AddRefs(contentTypeNodeResource)); NS_ENSURE_SUCCESS(rv, rv); // we need a way to determine if this content type resource is really in the graph or not... diff --git a/xpfe/components/bookmarks/src/nsBookmarksService.cpp b/xpfe/components/bookmarks/src/nsBookmarksService.cpp index d6047f492f2f..a508d83daae2 100644 --- a/xpfe/components/bookmarks/src/nsBookmarksService.cpp +++ b/xpfe/components/bookmarks/src/nsBookmarksService.cpp @@ -194,56 +194,98 @@ bm_AddRefGlobals() NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get charset alias service"); if (NS_FAILED(rv)) return rv; - gRDF->GetResource(kURINC_BookmarksRoot, &kNC_BookmarksRoot); - gRDF->GetResource(kURINC_IEFavoritesRoot, &kNC_IEFavoritesRoot); - gRDF->GetResource(kURINC_SystemBookmarksStaticRoot, &kNC_SystemBookmarksStaticRoot); - gRDF->GetResource(kURINC_NewBookmarkFolder, &kNC_NewBookmarkFolder); - gRDF->GetResource(kURINC_PersonalToolbarFolder, &kNC_PersonalToolbarFolder); - gRDF->GetResource(kURINC_NewSearchFolder, &kNC_NewSearchFolder); + gRDF->GetResource(NS_LITERAL_CSTRING(kURINC_BookmarksRoot), + &kNC_BookmarksRoot); + gRDF->GetResource(NS_LITERAL_CSTRING(kURINC_IEFavoritesRoot), + &kNC_IEFavoritesRoot); + gRDF->GetResource(NS_LITERAL_CSTRING(kURINC_SystemBookmarksStaticRoot), + &kNC_SystemBookmarksStaticRoot); + gRDF->GetResource(NS_LITERAL_CSTRING(kURINC_NewBookmarkFolder), + &kNC_NewBookmarkFolder); + gRDF->GetResource(NS_LITERAL_CSTRING(kURINC_PersonalToolbarFolder), + &kNC_PersonalToolbarFolder); + gRDF->GetResource(NS_LITERAL_CSTRING(kURINC_NewSearchFolder), + &kNC_NewSearchFolder); - gRDF->GetResource(NC_NAMESPACE_URI "Bookmark", &kNC_Bookmark); - gRDF->GetResource(NC_NAMESPACE_URI "BookmarkSeparator", &kNC_BookmarkSeparator); - gRDF->GetResource(NC_NAMESPACE_URI "BookmarkAddDate", &kNC_BookmarkAddDate); - gRDF->GetResource(NC_NAMESPACE_URI "Description", &kNC_Description); - gRDF->GetResource(NC_NAMESPACE_URI "Folder", &kNC_Folder); - gRDF->GetResource(NC_NAMESPACE_URI "FolderType", &kNC_FolderType); - gRDF->GetResource(NC_NAMESPACE_URI "FolderGroup", &kNC_FolderGroup); - gRDF->GetResource(NC_NAMESPACE_URI "IEFavorite", &kNC_IEFavorite); - gRDF->GetResource(NC_NAMESPACE_URI "IEFavoriteFolder", &kNC_IEFavoriteFolder); - gRDF->GetResource(NC_NAMESPACE_URI "Name", &kNC_Name); - gRDF->GetResource(NC_NAMESPACE_URI "Icon", &kNC_Icon); - gRDF->GetResource(NC_NAMESPACE_URI "ShortcutURL", &kNC_ShortcutURL); - gRDF->GetResource(NC_NAMESPACE_URI "URL", &kNC_URL); - gRDF->GetResource(RDF_NAMESPACE_URI "type", &kRDF_type); - gRDF->GetResource(RDF_NAMESPACE_URI "nextVal", &kRDF_nextVal); + gRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Bookmark"), + &kNC_Bookmark); + gRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "BookmarkSeparator"), + &kNC_BookmarkSeparator); + gRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "BookmarkAddDate"), + &kNC_BookmarkAddDate); + gRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Description"), + &kNC_Description); + gRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Folder"), + &kNC_Folder); + gRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "FolderType"), + &kNC_FolderType); + gRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "FolderGroup"), + &kNC_FolderGroup); + gRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "IEFavorite"), + &kNC_IEFavorite); + gRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "IEFavoriteFolder"), + &kNC_IEFavoriteFolder); + gRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Name"), + &kNC_Name); + gRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Icon"), + &kNC_Icon); + gRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "ShortcutURL"), + &kNC_ShortcutURL); + gRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "URL"), + &kNC_URL); + gRDF->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "type"), + &kRDF_type); + gRDF->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "nextVal"), + &kRDF_nextVal); - gRDF->GetResource(WEB_NAMESPACE_URI "LastModifiedDate", &kWEB_LastModifiedDate); - gRDF->GetResource(WEB_NAMESPACE_URI "LastVisitDate", &kWEB_LastVisitDate); - gRDF->GetResource(WEB_NAMESPACE_URI "LastCharset", &kWEB_LastCharset); + gRDF->GetResource(NS_LITERAL_CSTRING(WEB_NAMESPACE_URI "LastModifiedDate"), + &kWEB_LastModifiedDate); + gRDF->GetResource(NS_LITERAL_CSTRING(WEB_NAMESPACE_URI "LastVisitDate"), + &kWEB_LastVisitDate); + gRDF->GetResource(NS_LITERAL_CSTRING(WEB_NAMESPACE_URI "LastCharset"), + &kWEB_LastCharset); - gRDF->GetResource(WEB_NAMESPACE_URI "Schedule", &kWEB_Schedule); - gRDF->GetResource(WEB_NAMESPACE_URI "ScheduleFlag", &kWEB_ScheduleActive); - gRDF->GetResource(WEB_NAMESPACE_URI "status", &kWEB_Status); - gRDF->GetResource(WEB_NAMESPACE_URI "LastPingDate", &kWEB_LastPingDate); - gRDF->GetResource(WEB_NAMESPACE_URI "LastPingETag", &kWEB_LastPingETag); - gRDF->GetResource(WEB_NAMESPACE_URI "LastPingModDate", &kWEB_LastPingModDate); - gRDF->GetResource(WEB_NAMESPACE_URI "LastPingContentLen", &kWEB_LastPingContentLen); + gRDF->GetResource(NS_LITERAL_CSTRING(WEB_NAMESPACE_URI "Schedule"), + &kWEB_Schedule); + gRDF->GetResource(NS_LITERAL_CSTRING(WEB_NAMESPACE_URI "ScheduleFlag"), + &kWEB_ScheduleActive); + gRDF->GetResource(NS_LITERAL_CSTRING(WEB_NAMESPACE_URI "status"), + &kWEB_Status); + gRDF->GetResource(NS_LITERAL_CSTRING(WEB_NAMESPACE_URI "LastPingDate"), + &kWEB_LastPingDate); + gRDF->GetResource(NS_LITERAL_CSTRING(WEB_NAMESPACE_URI "LastPingETag"), + &kWEB_LastPingETag); + gRDF->GetResource(NS_LITERAL_CSTRING(WEB_NAMESPACE_URI "LastPingModDate"), + &kWEB_LastPingModDate); + gRDF->GetResource(NS_LITERAL_CSTRING(WEB_NAMESPACE_URI "LastPingContentLen"), + &kWEB_LastPingContentLen); - gRDF->GetResource(NC_NAMESPACE_URI "parent", &kNC_Parent); + gRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "parent"), &kNC_Parent); gRDF->GetLiteral(NS_LITERAL_STRING("true").get(), &kTrueLiteral); - gRDF->GetResource(NC_NAMESPACE_URI "command?cmd=newbookmark", &kNC_BookmarkCommand_NewBookmark); - gRDF->GetResource(NC_NAMESPACE_URI "command?cmd=newfolder", &kNC_BookmarkCommand_NewFolder); - gRDF->GetResource(NC_NAMESPACE_URI "command?cmd=newseparator", &kNC_BookmarkCommand_NewSeparator); - gRDF->GetResource(NC_NAMESPACE_URI "command?cmd=deletebookmark", &kNC_BookmarkCommand_DeleteBookmark); - gRDF->GetResource(NC_NAMESPACE_URI "command?cmd=deletebookmarkfolder", &kNC_BookmarkCommand_DeleteBookmarkFolder); - gRDF->GetResource(NC_NAMESPACE_URI "command?cmd=deletebookmarkseparator", &kNC_BookmarkCommand_DeleteBookmarkSeparator); - gRDF->GetResource(NC_NAMESPACE_URI "command?cmd=setnewbookmarkfolder", &kNC_BookmarkCommand_SetNewBookmarkFolder); - gRDF->GetResource(NC_NAMESPACE_URI "command?cmd=setpersonaltoolbarfolder",&kNC_BookmarkCommand_SetPersonalToolbarFolder); - gRDF->GetResource(NC_NAMESPACE_URI "command?cmd=setnewsearchfolder", &kNC_BookmarkCommand_SetNewSearchFolder); - gRDF->GetResource(NC_NAMESPACE_URI "command?cmd=import", &kNC_BookmarkCommand_Import); - gRDF->GetResource(NC_NAMESPACE_URI "command?cmd=export", &kNC_BookmarkCommand_Export); + gRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "command?cmd=newbookmark"), + &kNC_BookmarkCommand_NewBookmark); + gRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "command?cmd=newfolder"), + &kNC_BookmarkCommand_NewFolder); + gRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "command?cmd=newseparator"), + &kNC_BookmarkCommand_NewSeparator); + gRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "command?cmd=deletebookmark"), + &kNC_BookmarkCommand_DeleteBookmark); + gRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "command?cmd=deletebookmarkfolder"), + &kNC_BookmarkCommand_DeleteBookmarkFolder); + gRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "command?cmd=deletebookmarkseparator"), + &kNC_BookmarkCommand_DeleteBookmarkSeparator); + gRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "command?cmd=setnewbookmarkfolder"), + &kNC_BookmarkCommand_SetNewBookmarkFolder); + gRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "command?cmd=setpersonaltoolbarfolder"), + &kNC_BookmarkCommand_SetPersonalToolbarFolder); + gRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "command?cmd=setnewsearchfolder"), + &kNC_BookmarkCommand_SetNewSearchFolder); + gRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "command?cmd=import"), + &kNC_BookmarkCommand_Import); + gRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "command?cmd=export"), + &kNC_BookmarkCommand_Export); } return NS_OK; } @@ -580,13 +622,13 @@ BookmarkParser::Init(nsFileSpec *fileSpec, nsIRDFDataSource *aDataSource, for (field = gBookmarkFieldTable; field->mName; ++field) { str = field->mPropertyName; - rv = gRDF->GetResource(str.get(), &field->mProperty); + rv = gRDF->GetResource(str, &field->mProperty); if (NS_FAILED(rv)) return(rv); } for (field = gBookmarkHeaderFieldTable; field->mName; ++field) { str = field->mPropertyName; - rv = gRDF->GetResource(str.get(), &field->mProperty); + rv = gRDF->GetResource(str, &field->mProperty); if (NS_FAILED(rv)) return(rv); } @@ -964,7 +1006,7 @@ BookmarkParser::CreateAnonymousResource(nsIRDFResource** aResult) nsCAutoString uri(URINC_BOOKMARKS_ROOT_STRING "#$"); // let the compiler concat literals uri.AppendInt(++gNext, 16); - return gRDF->GetResource(uri.get(), aResult); + return gRDF->GetResource(uri, aResult); } @@ -1336,7 +1378,7 @@ BookmarkParser::ParseResource(nsIRDFResource *arc, nsString& url, nsIRDFNode** a nsresult rv; nsCOMPtr result; - rv = gRDF->GetUnicodeResource(url.get(), getter_AddRefs(result)); + rv = gRDF->GetUnicodeResource(url, getter_AddRefs(result)); if (NS_FAILED(rv)) return rv; return result->QueryInterface(NS_GET_IID(nsIRDFNode), (void**) aResult); } @@ -1471,7 +1513,7 @@ BookmarkParser::AddBookmark(nsCOMPtr aContainer, } nsCOMPtr bookmark; - if (NS_FAILED(rv = gRDF->GetResource(fullurlC.get(), getter_AddRefs(bookmark) ))) + if (NS_FAILED(rv = gRDF->GetResource(fullurlC, getter_AddRefs(bookmark) ))) { NS_ERROR("unable to get bookmark resource"); return(rv); @@ -2712,7 +2754,7 @@ nsBookmarksService::CreateBookmark(const PRUnichar* aName, const char* aURL, // Resource: Bookmark ID nsCOMPtr bookmarkResource; - rv = gRDF->GetResource(aURL, getter_AddRefs(bookmarkResource)); + rv = gRDF->GetResource(nsDependentCString(aURL), getter_AddRefs(bookmarkResource)); if (NS_FAILED(rv)) return rv; @@ -2892,7 +2934,7 @@ nsBookmarksService::IsBookmarked(const char *aURI, PRBool *isBookmarkedFlag) nsresult rv; nsCOMPtr bookmark; - if (NS_FAILED(rv = gRDF->GetResource(aURI, getter_AddRefs(bookmark)))) + if (NS_FAILED(rv = gRDF->GetResource(nsDependentCString(aURI), getter_AddRefs(bookmark)))) return(rv); rv = IsBookmarkedInternal(bookmark, isBookmarkedFlag); @@ -2911,7 +2953,7 @@ nsBookmarksService::GetLastCharset(const char *aURI, PRUnichar **aLastCharset) nsCOMPtr bookmark; nsresult rv = nsnull; - if (NS_SUCCEEDED(rv = gRDF->GetResource(aURI, getter_AddRefs(bookmark) ))) + if (NS_SUCCEEDED(rv = gRDF->GetResource(nsDependentCString(aURI), getter_AddRefs(bookmark) ))) { // Note: always use mInner!! Otherwise, could get into an infinite loop // due to Assert/Change calling UpdateBookmarkLastModifiedDate() @@ -2947,7 +2989,7 @@ nsBookmarksService::UpdateBookmarkIcon(const char *aURL, const PRUnichar *iconUR { nsresult rv; nsCOMPtr bookmark; - if (NS_FAILED(rv = gRDF->GetResource(aURL, getter_AddRefs(bookmark) ))) + if (NS_FAILED(rv = gRDF->GetResource(nsDependentCString(aURL), getter_AddRefs(bookmark) ))) { NS_ERROR("unable to get bookmark resource"); return(rv); @@ -2972,7 +3014,7 @@ nsBookmarksService::RemoveBookmarkIcon(const char *aURL, const PRUnichar *iconUR { nsresult rv; nsCOMPtr bookmark; - if (NS_FAILED(rv = gRDF->GetResource(aURL, getter_AddRefs(bookmark) ))) + if (NS_FAILED(rv = gRDF->GetResource(nsDependentCString(aURL), getter_AddRefs(bookmark) ))) { NS_ERROR("unable to get bookmark resource"); return(rv); @@ -2998,7 +3040,7 @@ nsBookmarksService::UpdateLastVisitedDate(const char *aURL, const PRUnichar *aCh nsCOMPtr bookmark; nsresult rv; - if (NS_SUCCEEDED(rv = gRDF->GetResource(aURL, getter_AddRefs(bookmark) ))) + if (NS_SUCCEEDED(rv = gRDF->GetResource(nsDependentCString(aURL), getter_AddRefs(bookmark) ))) { // Note: always use mInner!! Otherwise, could get into an infinite loop // due to Assert/Change calling UpdateBookmarkLastModifiedDate() @@ -3720,7 +3762,7 @@ nsBookmarksService::getResourceFromLiteralNode(nsIRDFNode *node, nsIRDFResource { return(NS_ERROR_NULL_POINTER); } - rv = gRDF->GetUnicodeResource(newURL, res); + rv = gRDF->GetUnicodeResource(nsDependentString(newURL), res); return(rv); } @@ -4203,7 +4245,7 @@ nsBookmarksService::insertBookmarkItem(nsIRDFResource *aRelativeNode, const PRUnichar* uURL = nsnull; bookmarkURILiteral->GetValueConst(&uURL); if (uURL) { - rv = gRDF->GetUnicodeResource(uURL, getter_AddRefs(newResource)); + rv = gRDF->GetUnicodeResource(nsDependentString(uURL), getter_AddRefs(newResource)); if (NS_FAILED(rv)) return rv; } } @@ -4940,9 +4982,11 @@ nsBookmarksService::LoadBookmarks() nsCOMPtr systemFolderResource; #if defined(XP_WIN) - rv = gRDF->GetResource(systemBookmarksURL, getter_AddRefs(systemFolderResource)); + rv = gRDF->GetResource(nsDependentCString(systemBookmarksURL), + getter_AddRefs(systemFolderResource)); #elif defined(XP_MAC) - rv = gRDF->GetResource(kURINC_IEFavoritesRoot, getter_AddRefs(systemFolderResource)); + rv = gRDF->GetResource(NS_LITERAL_CSTRING(kURINC_IEFavoritesRoot), + getter_AddRefs(systemFolderResource)); #endif rv = container->RemoveElement(systemFolderResource, PR_TRUE); @@ -4976,7 +5020,8 @@ nsBookmarksService::LoadBookmarks() } #elif defined(XP_WIN) || defined(XP_BEOS) nsCOMPtr systemFolderResource; - rv = gRDF->GetResource(systemBookmarksURL, getter_AddRefs(systemFolderResource)); + rv = gRDF->GetResource(nsDependentCString(systemBookmarksURL), + getter_AddRefs(systemFolderResource)); if (NS_SUCCEEDED(rv)) { nsAutoString systemBookmarksFolderTitle; diff --git a/xpfe/components/directory/nsDirectoryViewer.cpp b/xpfe/components/directory/nsDirectoryViewer.cpp index cd175ed5cb42..eaacb1816777 100644 --- a/xpfe/components/directory/nsDirectoryViewer.cpp +++ b/xpfe/components/directory/nsDirectoryViewer.cpp @@ -315,7 +315,7 @@ nsHTTPIndex::OnStartRequest(nsIRequest *request, nsISupports* aContext) uri->GetSpec(entryuriC); nsCOMPtr entry; - rv = mDirRDF->GetResource(entryuriC.get(), getter_AddRefs(entry)); + rv = mDirRDF->GetResource(entryuriC, getter_AddRefs(entry)); NS_ConvertUTF8toUCS2 uriUnicode(entryuriC); @@ -439,7 +439,7 @@ nsHTTPIndex::OnIndexAvailable(nsIRequest* aRequest, nsISupports *aContext, } nsCOMPtr entry; - rv = mDirRDF->GetResource(entryuriC.get(), getter_AddRefs(entry)); + rv = mDirRDF->GetResource(entryuriC, getter_AddRefs(entry)); // At this point, we'll (hopefully) have found the filename and // constructed a resource for it, stored in entry. So now take a @@ -603,17 +603,26 @@ nsHTTPIndex::CommonInit() if (NS_FAILED(rv)) return rv; - mDirRDF->GetResource(NC_NAMESPACE_URI "child", getter_AddRefs(kNC_Child)); - mDirRDF->GetResource(NC_NAMESPACE_URI "loading", getter_AddRefs(kNC_Loading)); - mDirRDF->GetResource(NC_NAMESPACE_URI "Comment", getter_AddRefs(kNC_Comment)); - mDirRDF->GetResource(NC_NAMESPACE_URI "URL", getter_AddRefs(kNC_URL)); - mDirRDF->GetResource(NC_NAMESPACE_URI "Name", getter_AddRefs(kNC_Description)); - mDirRDF->GetResource(NC_NAMESPACE_URI "Content-Length", getter_AddRefs(kNC_ContentLength)); - mDirRDF->GetResource("http://home.netscape.com/WEB-rdf#LastModifiedDate", + mDirRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "child"), + getter_AddRefs(kNC_Child)); + mDirRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "loading"), + getter_AddRefs(kNC_Loading)); + mDirRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Comment"), + getter_AddRefs(kNC_Comment)); + mDirRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "URL"), + getter_AddRefs(kNC_URL)); + mDirRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Name"), + getter_AddRefs(kNC_Description)); + mDirRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Content-Length"), + getter_AddRefs(kNC_ContentLength)); + mDirRDF->GetResource(NS_LITERAL_CSTRING(WEB_NAMESPACE_URI "LastModifiedDate"), getter_AddRefs(kNC_LastModified)); - mDirRDF->GetResource(NC_NAMESPACE_URI "Content-Type", getter_AddRefs(kNC_ContentType)); - mDirRDF->GetResource(NC_NAMESPACE_URI "File-Type", getter_AddRefs(kNC_FileType)); - mDirRDF->GetResource(NC_NAMESPACE_URI "IsContainer", getter_AddRefs(kNC_IsContainer)); + mDirRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Content-Type"), + getter_AddRefs(kNC_ContentType)); + mDirRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "File-Type"), + getter_AddRefs(kNC_FileType)); + mDirRDF->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "IsContainer"), + getter_AddRefs(kNC_IsContainer)); rv = mDirRDF->GetLiteral(NS_LITERAL_STRING("true").get(), getter_AddRefs(kTrueLiteral)); if (NS_FAILED(rv)) return(rv); @@ -667,7 +676,7 @@ nsHTTPIndex::Init(nsIURI* aBaseURL) // Mark the base url as a container nsCOMPtr baseRes; - mDirRDF->GetResource(mBaseURL.get(), getter_AddRefs(baseRes)); + mDirRDF->GetResource(mBaseURL, getter_AddRefs(baseRes)); Assert(baseRes, kNC_IsContainer, kTrueLiteral, PR_TRUE); return NS_OK; diff --git a/xpfe/components/download-manager/src/nsDownloadManager.cpp b/xpfe/components/download-manager/src/nsDownloadManager.cpp index fa8b9be065a6..4652abbece9e 100644 --- a/xpfe/components/download-manager/src/nsDownloadManager.cpp +++ b/xpfe/components/download-manager/src/nsDownloadManager.cpp @@ -136,15 +136,15 @@ nsDownloadManager::Init() rv = CallGetService(kRDFServiceCID, &gRDFService); if (NS_FAILED(rv)) return rv; - gRDFService->GetResource("NC:DownloadsRoot", &gNC_DownloadsRoot); - gRDFService->GetResource(NC_NAMESPACE_URI "File", &gNC_File); - gRDFService->GetResource(NC_NAMESPACE_URI "URL", &gNC_URL); - gRDFService->GetResource(NC_NAMESPACE_URI "Name", &gNC_Name); - gRDFService->GetResource(NC_NAMESPACE_URI "ProgressMode", &gNC_ProgressMode); - gRDFService->GetResource(NC_NAMESPACE_URI "ProgressPercent", &gNC_ProgressPercent); - gRDFService->GetResource(NC_NAMESPACE_URI "Transferred", &gNC_Transferred); - gRDFService->GetResource(NC_NAMESPACE_URI "DownloadState", &gNC_DownloadState); - gRDFService->GetResource(NC_NAMESPACE_URI "StatusText", &gNC_StatusText); + gRDFService->GetResource(NS_LITERAL_CSTRING("NC:DownloadsRoot"), &gNC_DownloadsRoot); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "File"), &gNC_File); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "URL"), &gNC_URL); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Name"), &gNC_Name); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "ProgressMode"), &gNC_ProgressMode); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "ProgressPercent"), &gNC_ProgressPercent); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Transferred"), &gNC_Transferred); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "DownloadState"), &gNC_DownloadState); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "StatusText"), &gNC_StatusText); nsCAutoString downloadsDB; rv = GetProfileDownloadsFileURL(downloadsDB); @@ -287,7 +287,7 @@ nsDownloadManager::AssertProgressInfoFor(const nsACString& aTargetPath) nsCOMPtr res; nsCOMPtr literal; - gRDFService->GetResource(PromiseFlatCString(aTargetPath).get(), getter_AddRefs(res)); + gRDFService->GetResource(aTargetPath, getter_AddRefs(res)); DownloadState state; internalDownload->GetDownloadState(&state); @@ -434,7 +434,7 @@ nsDownloadManager::AddDownload(nsIURI* aSource, NS_ConvertUCS2toUTF8 utf8Path(path); nsCOMPtr downloadRes; - gRDFService->GetResource(utf8Path.get(), getter_AddRefs(downloadRes)); + gRDFService->GetResource(utf8Path, getter_AddRefs(downloadRes)); nsCOMPtr node; @@ -443,7 +443,7 @@ nsDownloadManager::AddDownload(nsIURI* aSource, aSource->GetSpec(spec); nsCOMPtr urlResource; - gRDFService->GetResource(spec.get(), getter_AddRefs(urlResource)); + gRDFService->GetResource(spec, getter_AddRefs(urlResource)); mDataSource->GetTarget(downloadRes, gNC_URL, PR_TRUE, getter_AddRefs(node)); if (node) rv = mDataSource->Change(downloadRes, gNC_URL, node, urlResource); @@ -472,7 +472,7 @@ nsDownloadManager::AddDownload(nsIURI* aSource, // Assert file information nsCOMPtr fileResource; - gRDFService->GetResource(utf8Path.get(), getter_AddRefs(fileResource)); + gRDFService->GetResource(utf8Path, getter_AddRefs(fileResource)); rv = mDataSource->Assert(downloadRes, gNC_File, fileResource, PR_TRUE); if (NS_FAILED(rv)) return rv; @@ -605,7 +605,7 @@ nsDownloadManager::RemoveDownload(const nsACString & aTargetPath) if (NS_FAILED(rv)) return rv; nsCOMPtr res; - gRDFService->GetResource(PromiseFlatCString(aTargetPath).get(), getter_AddRefs(res)); + gRDFService->GetResource(aTargetPath, getter_AddRefs(res)); // remove all the arcs for this resource, and then remove it from the Seq nsCOMPtr arcs; @@ -1241,7 +1241,7 @@ nsDownload::SetDisplayName(const PRUnichar* aDisplayName) nsresult rv = mTarget->GetPath(path); if (NS_FAILED(rv)) return rv; - gRDFService->GetResource(NS_ConvertUCS2toUTF8(path).get(), getter_AddRefs(res)); + gRDFService->GetUnicodeResource(path, getter_AddRefs(res)); gRDFService->GetLiteral(aDisplayName, getter_AddRefs(nameLiteral)); ds->Assert(res, gNC_Name, nameLiteral, PR_TRUE); diff --git a/xpfe/components/history/src/nsGlobalHistory.cpp b/xpfe/components/history/src/nsGlobalHistory.cpp index af5b606c1259..c15cd190957d 100644 --- a/xpfe/components/history/src/nsGlobalHistory.cpp +++ b/xpfe/components/history/src/nsGlobalHistory.cpp @@ -638,7 +638,7 @@ nsGlobalHistory::AddPageToDatabase(const char *aURL, // For notifying observers, later... nsCOMPtr url; - rv = gRDFService->GetResource(aURL, getter_AddRefs(url)); + rv = gRDFService->GetResource(nsDependentCString(aURL, len), getter_AddRefs(url)); if (NS_FAILED(rv)) return rv; nsCOMPtr date; @@ -978,7 +978,7 @@ nsGlobalHistory::SetPageTitle(const char *aURL, const PRUnichar *aTitle) // ...and update observers nsCOMPtr url; - rv = gRDFService->GetResource(aURL, getter_AddRefs(url)); + rv = gRDFService->GetResource(nsDependentCString(aURL), getter_AddRefs(url)); if (NS_FAILED(rv)) return rv; nsCOMPtr name; @@ -1018,7 +1018,7 @@ nsGlobalHistory::RemovePage(const char *aURL) if (!mBatchesInProgress) { // get the resource so we can do the notification nsCOMPtr oldRowResource; - gRDFService->GetResource(aURL, getter_AddRefs(oldRowResource)); + gRDFService->GetResource(nsDependentCString(aURL), getter_AddRefs(oldRowResource)); NotifyFindUnassertions(oldRowResource, row); } @@ -1139,7 +1139,7 @@ nsGlobalHistory::RemoveMatchingRows(rowMatchCallback aMatchFunc, const char* startPtr = (const char*) yarn.mYarn_Buf; nsCAutoString uri(Substring(startPtr, startPtr+yarn.mYarn_Fill)); - rv = gRDFService->GetResource(uri.get(), getter_AddRefs(resource)); + rv = gRDFService->GetResource(uri, getter_AddRefs(resource)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource"); if (NS_FAILED(rv)) continue; @@ -1244,7 +1244,7 @@ nsGlobalHistory::HidePage(const char *aURL) // HasAssertion() correctly checks the Hidden column to show that // the row is hidden nsCOMPtr urlResource; - rv = gRDFService->GetResource(aURL, getter_AddRefs(urlResource)); + rv = gRDFService->GetResource(nsDependentCString(aURL), getter_AddRefs(urlResource)); if (NS_FAILED(rv)) return rv; return NotifyFindUnassertions(urlResource, row); } @@ -1675,7 +1675,7 @@ nsGlobalHistory::GetTarget(nsIRDFResource* aSource, if (NS_FAILED(rv)) return rv; nsCOMPtr resource; - rv = gRDFService->GetResource(str.get(), + rv = gRDFService->GetResource(str, getter_AddRefs(resource)); if (NS_FAILED(rv)) return rv; @@ -2313,20 +2313,32 @@ nsGlobalHistory::Init() NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service"); if (NS_FAILED(rv)) return rv; - gRDFService->GetResource(NC_NAMESPACE_URI "Page", &kNC_Page); - gRDFService->GetResource(NC_NAMESPACE_URI "Date", &kNC_Date); - gRDFService->GetResource(NC_NAMESPACE_URI "FirstVisitDate", + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Page"), + &kNC_Page); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Date"), + &kNC_Date); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "FirstVisitDate"), &kNC_FirstVisitDate); - gRDFService->GetResource(NC_NAMESPACE_URI "VisitCount", &kNC_VisitCount); - gRDFService->GetResource(NC_NAMESPACE_URI "AgeInDays", &kNC_AgeInDays); - gRDFService->GetResource(NC_NAMESPACE_URI "Name", &kNC_Name); - gRDFService->GetResource(NC_NAMESPACE_URI "Name?sort=true", &kNC_NameSort); - gRDFService->GetResource(NC_NAMESPACE_URI "Hostname", &kNC_Hostname); - gRDFService->GetResource(NC_NAMESPACE_URI "Referrer", &kNC_Referrer); - gRDFService->GetResource(NC_NAMESPACE_URI "child", &kNC_child); - gRDFService->GetResource(NC_NAMESPACE_URI "URL", &kNC_URL); - gRDFService->GetResource("NC:HistoryRoot", &kNC_HistoryRoot); - gRDFService->GetResource("NC:HistoryByDate", &kNC_HistoryByDate); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "VisitCount"), + &kNC_VisitCount); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "AgeInDays"), + &kNC_AgeInDays); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Name"), + &kNC_Name); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Name?sort=true"), + &kNC_NameSort); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Hostname"), + &kNC_Hostname); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Referrer"), + &kNC_Referrer); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "child"), + &kNC_child); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "URL"), + &kNC_URL); + gRDFService->GetResource(NS_LITERAL_CSTRING("NC:HistoryRoot"), + &kNC_HistoryRoot); + gRDFService->GetResource(NS_LITERAL_CSTRING("NC:HistoryByDate"), + &kNC_HistoryByDate); } // register this as a named data source with the RDF service @@ -2961,7 +2973,7 @@ nsGlobalHistory::GetRootDayQueries(nsISimpleEnumerator **aResult) uri = prefix; uri.AppendInt(i); uri.Append("&groupby=Hostname"); - rv = gRDFService->GetResource(uri.get(), getter_AddRefs(finduri)); + rv = gRDFService->GetResource(uri, getter_AddRefs(finduri)); if (NS_FAILED(rv)) continue; rv = CreateFindEnumerator(finduri, getter_AddRefs(findEnumerator)); if (NS_FAILED(rv)) continue; @@ -2973,7 +2985,7 @@ nsGlobalHistory::GetRootDayQueries(nsISimpleEnumerator **aResult) uri = FIND_BY_AGEINDAYS_PREFIX "isgreater" "&text="; uri.AppendInt(i-1); uri.Append("&groupby=Hostname"); - rv = gRDFService->GetResource(uri.get(), getter_AddRefs(finduri)); + rv = gRDFService->GetResource(uri, getter_AddRefs(finduri)); if (NS_SUCCEEDED(rv)) { rv = CreateFindEnumerator(finduri, getter_AddRefs(findEnumerator)); if (NS_SUCCEEDED(rv)) { @@ -3241,7 +3253,7 @@ nsGlobalHistory::NotifyFindAssertions(nsIRDFResource *aSource, query.terms.AppendElement((void *)&ageterm); GetFindUriPrefix(query, PR_TRUE, findUri); - gRDFService->GetResource(findUri.get(), getter_AddRefs(childFindResource)); + gRDFService->GetResource(findUri, getter_AddRefs(childFindResource)); NotifyAssert(kNC_HistoryByDate, kNC_child, childFindResource); query.terms.Clear(); @@ -3256,7 +3268,7 @@ nsGlobalHistory::NotifyFindAssertions(nsIRDFResource *aSource, query.terms.AppendElement((void *)&hostterm); GetFindUriPrefix(query, PR_FALSE, findUri); - gRDFService->GetResource(findUri.get(), getter_AddRefs(childFindResource)); + gRDFService->GetResource(findUri, getter_AddRefs(childFindResource)); NotifyAssert(parentFindResource, kNC_child, childFindResource); query.terms.Clear(); @@ -3269,13 +3281,13 @@ nsGlobalHistory::NotifyFindAssertions(nsIRDFResource *aSource, query.groupBy = kToken_HostnameColumn; // create groupby=Hostname GetFindUriPrefix(query, PR_TRUE, findUri); - gRDFService->GetResource(findUri.get(), getter_AddRefs(parentFindResource)); + gRDFService->GetResource(findUri, getter_AddRefs(parentFindResource)); query.groupBy = 0; // create Hostname= query.terms.AppendElement((void *)&hostterm); GetFindUriPrefix(query, PR_FALSE, findUri); findUri.Append(hostname); // append - gRDFService->GetResource(findUri.get(), getter_AddRefs(childFindResource)); + gRDFService->GetResource(findUri, getter_AddRefs(childFindResource)); NotifyAssert(parentFindResource, kNC_child, childFindResource); @@ -3334,7 +3346,7 @@ nsGlobalHistory::NotifyFindUnassertions(nsIRDFResource *aSource, query.terms.AppendElement((void *)&hostterm); GetFindUriPrefix(query, PR_FALSE, findUri); - gRDFService->GetResource(findUri.get(), getter_AddRefs(findResource)); + gRDFService->GetResource(findUri, getter_AddRefs(findResource)); NotifyUnassert(findResource, kNC_child, aSource); @@ -3344,7 +3356,7 @@ nsGlobalHistory::NotifyFindUnassertions(nsIRDFResource *aSource, query.terms.AppendElement((void *)&hostterm); GetFindUriPrefix(query, PR_FALSE, findUri); - gRDFService->GetResource(findUri.get(), getter_AddRefs(findResource)); + gRDFService->GetResource(findUri, getter_AddRefs(findResource)); NotifyUnassert(findResource, kNC_child, aSource); return NS_OK; @@ -3516,7 +3528,7 @@ nsGlobalHistory::URLEnumerator::ConvertToISupports(nsIMdbRow* aRow, nsISupports* nsCOMPtr resource; const char* startPtr = (const char*) yarn.mYarn_Buf; rv = gRDFService->GetResource( - nsCAutoString(Substring(startPtr, startPtr+yarn.mYarn_Fill)).get(), + Substring(startPtr, startPtr+yarn.mYarn_Fill), getter_AddRefs(resource)); if (NS_FAILED(rv)) return rv; @@ -3815,7 +3827,7 @@ nsGlobalHistory::SearchEnumerator::ConvertToISupports(nsIMdbRow* aRow, const char* startPtr = (const char*)yarn.mYarn_Buf; rv = gRDFService->GetResource( - nsCAutoString(Substring(startPtr, startPtr+yarn.mYarn_Fill)).get(), + Substring(startPtr, startPtr+yarn.mYarn_Fill), getter_AddRefs(resource)); if (NS_FAILED(rv)) return rv; @@ -3839,7 +3851,7 @@ nsGlobalHistory::SearchEnumerator::ConvertToISupports(nsIMdbRow* aRow, findUri.Append(Substring(startPtr, startPtr+groupByValue.mYarn_Fill)); findUri.Append('\0'); - rv = gRDFService->GetResource(findUri.get(), getter_AddRefs(resource)); + rv = gRDFService->GetResource(findUri, getter_AddRefs(resource)); if (NS_FAILED(rv)) return rv; *aResult = resource; @@ -3980,6 +3992,465 @@ nsGlobalHistory::OnStopLookup() return NS_OK; } +<<<<<<< nsGlobalHistory.cpp + +/** + * + * The input features into the autocomplete perceptron are as follows: + * + * Features 1 = Frequency and recency metric for page in history + * (domain = positive real numbers) + * Value decays fast with age of page + * Uses HISTORY_FAST_DECAY_CONSTANT + * Features 2 = Frequency and recency metric for page in history + * (high for newer, more accessed pages) + * Value decays slowly with age of page + * Uses HISTORY_SLOW_DECAY_CONSTANT + * Features 3 = Was the url typed by the user? + * (domain = 0 or 1) + * Features 4 = Recency metric for page in bookmarks + * (domain = real number between 0 and 1) + * Value decays fast with age of bookmark + * Uses BOOKMARKS_FAST_DECAY_CONSTANT + * Features 5 = Recency metric for page in bookmarks + * (domain = real number between 0 and 1) + * Value decays slowly with age of bookmark + * Uses BOOKMARKS_SLOW_DECAY_CONSTANT + * + * Features 1 and Feature 2 details: + * + * As an example, say a page was first seen on Day 1 and accessed from then + * until today (Day 4) with the following schedule: + * + * (Day 1, D times), (Day 2, C times), (Day 3, B times), (Day 4, A times) + * + * Then, the frequency+recency metric calculation for the page will be: + * + * FRMetric = A + (B * G) + (C * G^2) + (D * G^3) + * + * where G is the decay constant that takes values between 0 and 1. + * Values close to 1 lead to slow decay with age. + * Values close to 0 lead to fast decay with age. + * + * Feature 4 and Feature 5 only care about recency not frequency. + * + * So, if a bookmark was added X days earlier, + * + * Bookmark Feature Value = G^X. + * + * where G is the decay constant that takes values between 0 and 1. + * Values close to 1 lead to slow decay with age. + * Values close to 0 lead to fast decay with age. + * + * The rest of the url related features: + * + * Feature 6: Whether url ends in .htm or .html + * Feature 7: Is it a .com URL? + * Feature 8: Is it a .edu URL? + * Feature 9: Is it a .org URL? + * Feature 10: Is it a .net URL? + * Feature 11: Is it a .gov URL? + * Feature 12: Does the URL contain a ~ ? + * Feature 13: Does the URL start with http:* ? + * Feature 14: Does the URL start with ftp:// ? + * Feature 15: Does the URL start with file:// ? + * Feature 16: Does the URL start with gopher:// ? + * Feature 17: Does the URL start with https:// ? + * Feature 18: Does the host name end in a two letter country code? + * Feature 19: Number of /s in the URL. + * Feature 20: Number of ?s in the URL. + * Feature 21: Number of &s in the URL. + * Feature 22: Number of =s in the URL. + * Feature 23: Number of #s in the URL. + * Feature 24: Number of +s in the URL. + * Feature 25: Number of .s in the URL. + * Feature 26: Number of numerical [0-9] characters in the URL + * Feature 27: Number of alphabetical [a-zA-Z] characters in the URL + * Feature 28: Number of non-alphanumeric, non-[/?&=#+.] characters in the URL + * Feature 29: Number of .s in the hostname + * Feature 30: Number of numerical [0-9] characters in the hostname + * Feature 31: Number of alphabetical [a-zA-Z] characters in the hostname + * Feature 32: Number of non-alphanumeric, non-[/?&=#+.] characters in the hostname + * Feature 33: Number of .s in the hostname if we omit initial "www." or "ftp." (if any) + * Feature 34: Number of .s in the hostname if we omit ending ".XX" country code (if any) + * Feature 35: Number of .s in the hostname if we omit initial "www." or "ftp" + * and ending ".XX" country code (if any) + * Feature 36: Number of characters in URL + * Feature 37: Number of characters in hostname + * Feature 38: Number of characters in hostname excluding initial "www." or "ftp." + * Feature 39: Number of characters in URL excluding hostname + * Feature 40: Number of characters in web page title + * Feature 41: Is this a google search url? + * Feature 42: Is this a netscape search url? + * Feature 43: Is this a yahoo search url? + * Feature 44: Dummy input hardcoded to 1 + */ + +nsresult +nsGlobalHistory::FillInputFeatures(nsAString &aUrl, + PRFloat64 *aFeatures) +{ + nsCOMPtr row; + nsresult rv = NS_OK; + PRInt32 ageInDays; + PRInt64 lastDate; + static nsCOMPtr bs = + do_GetService(NS_BOOKMARKS_SERVICE_CONTRACTID, &rv); + + nsCOMPtr uri; + nsCAutoString curl, chost, cpath; + rv = NS_NewURI(getter_AddRefs(uri), aUrl); + if (NS_SUCCEEDED(rv) && uri) { + uri->GetSpec(curl); + uri->GetHost(chost); + uri->GetPath(cpath); + } + nsAutoString url(NS_ConvertUTF8toUCS2(curl).get()); + nsAutoString path(NS_ConvertUTF8toUCS2(cpath).get()); + nsAutoString host(NS_ConvertUTF8toUCS2(chost).get()); + ToLowerCase(url); + ToLowerCase(host); + ToLowerCase(path); + + // Calculate the input features for this training example. + rv = FindRow(kToken_URLColumn, curl.get(), + getter_AddRefs(row)); + if (NS_FAILED(rv)) return rv; + + // First, get the page in history related input features + rv = GetRowValue(row, kToken_FRFastDecayColumn, &aFeatures[0]); + if (NS_FAILED(rv)) return rv; + + rv = GetRowValue(row, kToken_LastVisitDateColumn, &lastDate); + if (NS_FAILED(rv)) return rv; + + ageInDays = GetAgeInDays(NormalizeTime(GetNow()), lastDate); + + aFeatures[0] *= pow(HISTORY_FAST_DECAY_CONSTANT, (PRFloat64) ageInDays); + + rv = GetRowValue(row, kToken_FRSlowDecayColumn, &aFeatures[1]); + if (NS_FAILED(rv)) return rv; + + aFeatures[1] *= pow(HISTORY_SLOW_DECAY_CONSTANT, (PRFloat64) ageInDays); + + aFeatures[2] = HasCell(mEnv, row, kToken_TypedColumn); + + // Second, calculate the bookmark related input features. + aFeatures[3] = aFeatures[4] = 0; + if (bs) { + PRBool bookmarked; + rv = bs->IsBookmarked(curl.get(), &bookmarked); + if (NS_SUCCEEDED(rv) && bookmarked) { + // Get the date when the bookmark was added. + PRInt64 addDate; + nsCOMPtr rdfRes; + + if (NS_SUCCEEDED(rv = gRDFService->GetResource(curl, + getter_AddRefs(rdfRes)))) { + nsCOMPtr bookmarkDS = do_QueryInterface(bs, &rv); + if (NS_SUCCEEDED(rv) && bookmarkDS) { + nsCOMPtr nodeType; + rv = bookmarkDS->GetTarget(rdfRes, kRDF_Type, PR_TRUE, + getter_AddRefs(nodeType)); + if (NS_SUCCEEDED(rv)) { + if (nodeType == kNC_Bookmark) { + nsCOMPtr node; + rv = bookmarkDS->GetTarget(rdfRes, kNC_BookmarkAddDate, PR_TRUE, + getter_AddRefs(node)); + if (rv != NS_RDF_NO_VALUE && node) { + nsCOMPtr rdfDate = do_QueryInterface(node, &rv); + if (NS_SUCCEEDED(rv) && rdfDate) { + rv = rdfDate->GetValue(&addDate); + } + } + } + } + } + } + + if (NS_SUCCEEDED(rv)) { + ageInDays = GetAgeInDays(NormalizeTime(GetNow()), addDate); + aFeatures[3] = pow(BOOKMARK_FAST_DECAY_CONSTANT, ageInDays); + aFeatures[4] = pow(BOOKMARK_SLOW_DECAY_CONSTANT, ageInDays); + } + } + } + + // Feature 6: Whether url ends in .htm or .html + nsAString::const_iterator start, end; + + path.BeginReading(start); + path.EndReading(end); + aFeatures[5] = FindInReadable(NS_LITERAL_STRING(".htm"), start, end); + + // Feature 7: Is it a .com URL? + host.BeginReading(start); + host.EndReading(end); + aFeatures[6] = FindInReadable(NS_LITERAL_STRING(".com"), start, end); + + // Feature 8: Is it a .edu URL? + host.BeginReading(start); + host.EndReading(end); + aFeatures[7] = FindInReadable(NS_LITERAL_STRING(".edu"), start, end); + + // Feature 9: Is it a .org URL? + host.BeginReading(start); + host.EndReading(end); + aFeatures[8] = FindInReadable(NS_LITERAL_STRING(".org"), start, end); + + // Feature 10: Is it a .net URL? + host.BeginReading(start); + host.EndReading(end); + aFeatures[9] = FindInReadable(NS_LITERAL_STRING(".net"), start, end); + + // Feature 11: Is it a .gov URL? + host.BeginReading(start); + host.EndReading(end); + aFeatures[10] = FindInReadable(NS_LITERAL_STRING(".gov"), start, end); + + // Feature 12: Does the URL contain a ~ ? + path.BeginReading(start); + path.EndReading(end); + aFeatures[11] = FindInReadable(NS_LITERAL_STRING("~"), start, end); + + // Feature 13: Does the URL start with http:// ? + PRBool isScheme; + aFeatures[12] = aFeatures[13] = aFeatures[14] = aFeatures[15] = aFeatures[16] = 0; + if (NS_SUCCEEDED(uri->SchemeIs("http", &isScheme))) { + aFeatures[12] = isScheme; + } + // Feature 14: Does the URL start with ftp:// ? + else if (NS_SUCCEEDED(uri->SchemeIs("ftp", &isScheme))) { + aFeatures[13] = isScheme; + } + // Feature 15: Does the URL start with file:// ? + else if (NS_SUCCEEDED(uri->SchemeIs("file", &isScheme))) { + aFeatures[14] = isScheme; + } + // Feature 16: Does the URL start with gopher:// ? + else if (NS_SUCCEEDED(uri->SchemeIs("gopher", &isScheme))) { + aFeatures[15] = isScheme; + } + // Feature 17: Does the URL start with https:// ? + else if (NS_SUCCEEDED(uri->SchemeIs("https", &isScheme))) { + aFeatures[16] = isScheme; + } + + // Feature 18: Does the host name end in a two letter country code? + PRInt32 hostLength = host.Length(); + if (host[hostLength - 1] == '.') { + // Skip trailing dots in hostname if it exists. This will catch cases like + // http://www.state.ca.us./state/portal/myca_homepage.jsp + aFeatures[17] = (host.RFindChar('.', hostLength - 2) == (hostLength - 4)); + } + else { + aFeatures[17] = (host.RFindChar('.') == ((hostLength - 1) - 2)); + } + + // Feature 19: Number of /s in the URL. + aFeatures[18] = 0; + // Feature 20: Number of ?s in the URL. + aFeatures[19] = 0; + // Feature 21: Number of &s in the URL. + aFeatures[20] = 0; + // Feature 22: Number of =s in the URL. + aFeatures[21] = 0; + // Feature 23: Number of #s in the URL. + aFeatures[22] = 0; + // Feature 24: Number of +s in the URL. + aFeatures[23] = 0; + // Feature 25: Number of .s in the URL. + aFeatures[24] = 0; + // Feature 26: Number of numerical [0-9] characters in the URL + aFeatures[25] = 0; + // Feature 27: Number of alphabetical [a-zA-Z] characters in the URL + aFeatures[26] = 0; + // Feature 28: Number of non-alphanumeric, non-[/?&=#+.] characters in the URL + aFeatures[27] = 0; + + url.BeginReading(start); + url.EndReading(end); + + PRUint32 size, i; + for ( ; start != end; start.advance(size)) { + const PRUnichar* buf = start.get(); + size = start.size_forward(); + + // fragment at 'buf' is 'size' characters long + for (i = 0; i < size; *buf++, i++) { + switch (*buf) { + case '/': + ++aFeatures[18]; + break; + + case '?': + ++aFeatures[19]; + break; + + case '&': + ++aFeatures[20]; + break; + + case '=': + ++aFeatures[21]; + break; + + case '#': + ++aFeatures[22]; + break; + + case '+': + ++aFeatures[23]; + break; + + case '.': + ++aFeatures[24]; + break; + + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + ++aFeatures[25]; + break; + + default: + if (isalpha(*buf)) + ++aFeatures[26]; + else + ++aFeatures[27]; + } + } + } + + // Calculate a bunch of hostname related features. + + // Feature 29: Number of .s in the hostname + aFeatures[28] = 0; + // Feature 30: Number of numerical [0-9] characters in the hostname + aFeatures[29] = 0; + // Feature 31: Number of alphabetical [a-zA-Z] characters in the hostname + aFeatures[30] = 0; + // Feature 32: Number of non-alphanumeric, non-[.] characters in the hostname + aFeatures[31] = 0; + + size = chost.Length(); + for (i = 0; i < size; i++) { + switch (chost[i]) { + case '.': + ++aFeatures[28]; + break; + + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + ++aFeatures[29]; + break; + + default: + if (isalpha(chost[i])) + ++aFeatures[30]; + else + ++aFeatures[31]; + } + } + + // Feature 33: Number of .s in the hostname if we omit initial "www." or "ftp." (if any) + aFeatures[32] = aFeatures[28]; + // Feature 34: Number of .s in the hostname if we omit ending ".XX" country code (if any) + aFeatures[33] = aFeatures[28]; + // Feature 35: Number of .s in the hostname if we omit initial "www." or "ftp" + // and ending ".XX" country code (if any) + aFeatures[34] = aFeatures[28]; + // Feature 36: Number of characters in hostname + aFeatures[35] = chost.Length(); + // Feature 37: Number of characters in hostname excluding initial "www." or "ftp." + aFeatures[36] = aFeatures[35]; + + if (chost.Find("www.") == 0 || chost.Find("ftp.") == 0) { + --aFeatures[32]; + --aFeatures[34]; + aFeatures[36] -= 4; + } + + if (aFeatures[17]) { + --aFeatures[33]; + --aFeatures[34]; + } + + // Feature 38: Number of characters in URL + aFeatures[37] = url.Length(); + + // Feature 39: Number of characters in URL excluding hostname + aFeatures[38] = aFeatures[37] - aFeatures[35]; + + // Feature 40: Number of characters in web page title + nsAutoString title; + rv = GetRowValue(row, kToken_NameColumn, title); + if (NS_FAILED(rv)) return rv; + aFeatures[39] = title.Length(); + + // Feature 41: Is this a google search url? + url.BeginReading(start); + url.EndReading(end); + aFeatures[40] = FindInReadable(NS_LITERAL_STRING("http://www.google.com/search"), start, end); + + // Feature 42: Is this a netscape search url? + url.BeginReading(start); + url.EndReading(end); + aFeatures[41] = FindInReadable(NS_LITERAL_STRING("http://search.netscape.com/nscp_results.adp"), start, end); + + // Feature 43: Is this a yahoo search url? + url.BeginReading(start); + url.EndReading(end); + aFeatures[42] = FindInReadable(NS_LITERAL_STRING("http://search.yahoo.com/bin/search"), start, end); + + // Feature 44: This is a dummy input hardcoded to 1. It allows + // the perceptron to represent functions that do not pass through the + // origin. + aFeatures[43] = 1; + + return rv; +} + +nsresult +nsGlobalHistory::WriteURLData(nsAString& aURL, PRFloat64* aURLFeatures) +{ + nsCOMPtr row; + nsresult rv = NS_OK; + nsCAutoString dateStr, IDStr; + PRInt64 rowID; + + if (!mURLDataFile || !aURLFeatures) + return NS_ERROR_FAILURE; + + // Calculate the input features for this training example. + rv = FindRowAndID(kToken_URLColumn, NS_ConvertUCS2toUTF8(aURL).get(), + getter_AddRefs(row), &rowID); + if (NS_FAILED(rv)) return rv; + + if (!rowID) { + AssignUniqueURLID(row, &rowID); + } + + PRInt64ToChars(rowID, IDStr); + + fprintf(mURLDataFile, "\n", dateStr.get()); + + PRInt32 i; + for (i = 0; i < AC_NUM_URL_FEATURES - 1; i++) { + fprintf(mURLDataFile, "%.2f, ", aURLFeatures[i]); + } + + fprintf(mURLDataFile, "%.2f\n\n", aURLFeatures[i]); + + return NS_OK; +} + +======= +>>>>>>> 1.173 NS_IMETHODIMP nsGlobalHistory::OnAutoComplete(const PRUnichar *searchString, nsIAutoCompleteResults *previousSearchResult, diff --git a/xpfe/components/intl/nsCharsetMenu.cpp b/xpfe/components/intl/nsCharsetMenu.cpp index 0d02ef2cbdde..e324d28e5e2d 100644 --- a/xpfe/components/intl/nsCharsetMenu.cpp +++ b/xpfe/components/intl/nsCharsetMenu.cpp @@ -459,7 +459,8 @@ nsCharsetMenu::nsCharsetMenu() res = nsComponentManager::CreateInstance(kRDFInMemoryDataSourceCID, nsnull, NS_GET_IID(nsIRDFDataSource), (void**) &mInner); - mRDFService->GetResource(kURINC_BrowserCharsetMenuRoot, &kNC_BrowserCharsetMenuRoot); + mRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_BrowserCharsetMenuRoot), + &kNC_BrowserCharsetMenuRoot); } //get pref service @@ -635,22 +636,37 @@ nsresult nsCharsetMenu::Init() if (NS_FAILED(res)) return res; //initialize all remaining RDF template nodes - mRDFService->GetResource(kURINC_BrowserAutodetMenuRoot, &kNC_BrowserAutodetMenuRoot); - mRDFService->GetResource(kURINC_BrowserMoreCharsetMenuRoot, &kNC_BrowserMoreCharsetMenuRoot); - mRDFService->GetResource(kURINC_BrowserMore1CharsetMenuRoot, &kNC_BrowserMore1CharsetMenuRoot); - mRDFService->GetResource(kURINC_BrowserMore2CharsetMenuRoot, &kNC_BrowserMore2CharsetMenuRoot); - mRDFService->GetResource(kURINC_BrowserMore3CharsetMenuRoot, &kNC_BrowserMore3CharsetMenuRoot); - mRDFService->GetResource(kURINC_BrowserMore4CharsetMenuRoot, &kNC_BrowserMore4CharsetMenuRoot); - mRDFService->GetResource(kURINC_BrowserMore5CharsetMenuRoot, &kNC_BrowserMore5CharsetMenuRoot); - mRDFService->GetResource(kURINC_MaileditCharsetMenuRoot, &kNC_MaileditCharsetMenuRoot); - mRDFService->GetResource(kURINC_MailviewCharsetMenuRoot, &kNC_MailviewCharsetMenuRoot); - mRDFService->GetResource(kURINC_ComposerCharsetMenuRoot, &kNC_ComposerCharsetMenuRoot); - mRDFService->GetResource(kURINC_DecodersRoot, &kNC_DecodersRoot); - mRDFService->GetResource(kURINC_Name, &kNC_Name); - mRDFService->GetResource(kURINC_Checked, &kNC_Checked); - mRDFService->GetResource(kURINC_CharsetDetector, &kNC_CharsetDetector); - mRDFService->GetResource(kURINC_BookmarkSeparator, &kNC_BookmarkSeparator); - mRDFService->GetResource(kURINC_type, &kRDF_type); + mRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_BrowserAutodetMenuRoot), + &kNC_BrowserAutodetMenuRoot); + mRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_BrowserMoreCharsetMenuRoot), + &kNC_BrowserMoreCharsetMenuRoot); + mRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_BrowserMore1CharsetMenuRoot), + &kNC_BrowserMore1CharsetMenuRoot); + mRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_BrowserMore2CharsetMenuRoot), + &kNC_BrowserMore2CharsetMenuRoot); + mRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_BrowserMore3CharsetMenuRoot), + &kNC_BrowserMore3CharsetMenuRoot); + mRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_BrowserMore4CharsetMenuRoot), + &kNC_BrowserMore4CharsetMenuRoot); + mRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_BrowserMore5CharsetMenuRoot), + &kNC_BrowserMore5CharsetMenuRoot); + mRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_MaileditCharsetMenuRoot), + &kNC_MaileditCharsetMenuRoot); + mRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_MailviewCharsetMenuRoot), + &kNC_MailviewCharsetMenuRoot); + mRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_ComposerCharsetMenuRoot), + &kNC_ComposerCharsetMenuRoot); + mRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_DecodersRoot), + &kNC_DecodersRoot); + mRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_Name), + &kNC_Name); + mRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_Checked), + &kNC_Checked); + mRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_CharsetDetector), + &kNC_CharsetDetector); + mRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_BookmarkSeparator), + &kNC_BookmarkSeparator); + mRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_type), &kRDF_type); nsIRDFContainerUtils * rdfUtil = NULL; res = nsServiceManager::GetService(kRDFContainerUtilsCID, @@ -728,9 +744,7 @@ nsresult nsCharsetMenu::SetCharsetCheckmark(nsString * aCharset, if (NS_FAILED(res)) return res; // find RDF node for given charset - char csID[256]; - aCharset->ToCString(csID, sizeof(csID)); - res = mRDFService->GetResource(csID, getter_AddRefs(node)); + res = mRDFService->GetUnicodeResource(*aCharset, getter_AddRefs(node)); if (NS_FAILED(res)) return res; // set checkmark value @@ -1258,9 +1272,7 @@ nsresult nsCharsetMenu::AddMenuItemToContainer( id.Append(cs); // Make up a unique ID and create the RDF NODE - char csID[256]; - id.ToCString(csID, sizeof(csID)); - res = mRDFService->GetResource(csID, getter_AddRefs(node)); + res = mRDFService->GetUnicodeResource(id, getter_AddRefs(node)); if (NS_FAILED(res)) return res; const PRUnichar * title = aItem->mTitle.get(); diff --git a/xpfe/components/related/src/nsRelatedLinksHandler.cpp b/xpfe/components/related/src/nsRelatedLinksHandler.cpp index 7f193c6834c6..a347e608d431 100644 --- a/xpfe/components/related/src/nsRelatedLinksHandler.cpp +++ b/xpfe/components/related/src/nsRelatedLinksHandler.cpp @@ -228,14 +228,22 @@ RelatedLinksStreamListener::Init() NS_RELEASE(charsetConv); } - gRDFService->GetResource(NC_NAMESPACE_URI "child", &kNC_Child); - gRDFService->GetResource(NC_NAMESPACE_URI "Name", &kNC_Name); - gRDFService->GetResource(NC_NAMESPACE_URI "URL", &kNC_URL); - gRDFService->GetResource(NC_NAMESPACE_URI "loading", &kNC_loading); - gRDFService->GetResource(NC_NAMESPACE_URI "BookmarkSeparator", &kNC_BookmarkSeparator); - gRDFService->GetResource(NC_NAMESPACE_URI "RelatedLinksTopic", &kNC_RelatedLinksTopic); - gRDFService->GetResource(RDF_NAMESPACE_URI "type", &kRDF_type); - gRDFService->GetResource(kURINC_RelatedLinksRoot, &kNC_RelatedLinksRoot); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "child"), + &kNC_Child); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Name"), + &kNC_Name); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "URL"), + &kNC_URL); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "loading"), + &kNC_loading); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "BookmarkSeparator"), + &kNC_BookmarkSeparator); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "RelatedLinksTopic"), + &kNC_RelatedLinksTopic); + gRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "type"), + &kRDF_type); + gRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_RelatedLinksRoot), + &kNC_RelatedLinksRoot); } mParentArray.AppendElement(kNC_RelatedLinksRoot); @@ -624,10 +632,14 @@ RelatedLinksHandlerImpl::Init() (nsISupports**) &gRDFService); if (NS_FAILED(rv)) return rv; - gRDFService->GetResource(kURINC_RelatedLinksRoot, &kNC_RelatedLinksRoot); - gRDFService->GetResource(RDF_NAMESPACE_URI "type", &kRDF_type); - gRDFService->GetResource(NC_NAMESPACE_URI "RelatedLinksTopic", &kNC_RelatedLinksTopic); - gRDFService->GetResource(NC_NAMESPACE_URI "child", &kNC_Child); + gRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_RelatedLinksRoot), + &kNC_RelatedLinksRoot); + gRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "type"), + &kRDF_type); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "RelatedLinksTopic"), + &kNC_RelatedLinksTopic); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "child"), + &kNC_Child); nsCOMPtr prefServ(do_GetService(kPrefCID, &rv)); mRLServerURL = new nsString(); diff --git a/xpfe/components/search/src/nsInternetSearchService.cpp b/xpfe/components/search/src/nsInternetSearchService.cpp index e71f93088365..fc0dabf2ede9 100755 --- a/xpfe/components/search/src/nsInternetSearchService.cpp +++ b/xpfe/components/search/src/nsInternetSearchService.cpp @@ -433,57 +433,106 @@ InternetSearchDataSource::InternetSearchDataSource(void) NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF container utils"); - gRDFService->GetResource(kURINC_SearchEngineRoot, &kNC_SearchEngineRoot); - gRDFService->GetResource(kURINC_LastSearchRoot, &kNC_LastSearchRoot); - gRDFService->GetResource(kURINC_SearchResultsSitesRoot, &kNC_SearchResultsSitesRoot); - gRDFService->GetResource(kURINC_FilterSearchURLsRoot, &kNC_FilterSearchURLsRoot); - gRDFService->GetResource(kURINC_FilterSearchSitesRoot, &kNC_FilterSearchSitesRoot); - gRDFService->GetResource(kURINC_SearchCategoryRoot, &kNC_SearchCategoryRoot); - gRDFService->GetResource(NC_NAMESPACE_URI "SearchMode", &kNC_LastSearchMode); + gRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_SearchEngineRoot), + &kNC_SearchEngineRoot); + gRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_LastSearchRoot), + &kNC_LastSearchRoot); + gRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_SearchResultsSitesRoot), + &kNC_SearchResultsSitesRoot); + gRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_FilterSearchURLsRoot), + &kNC_FilterSearchURLsRoot); + gRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_FilterSearchSitesRoot), + &kNC_FilterSearchSitesRoot); + gRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_SearchCategoryRoot), + &kNC_SearchCategoryRoot); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "SearchMode"), + &kNC_LastSearchMode); - gRDFService->GetResource(NC_NAMESPACE_URI "searchtype", &kNC_SearchType); - gRDFService->GetResource(NC_NAMESPACE_URI "SearchResult", &kNC_SearchResult); - gRDFService->GetResource(NC_NAMESPACE_URI "ref", &kNC_Ref); - gRDFService->GetResource(NC_NAMESPACE_URI "child", &kNC_Child); - gRDFService->GetResource(NC_NAMESPACE_URI "title", &kNC_Title); - gRDFService->GetResource(NC_NAMESPACE_URI "data", &kNC_Data); - gRDFService->GetResource(NC_NAMESPACE_URI "Name", &kNC_Name); - gRDFService->GetResource(NC_NAMESPACE_URI "Description", &kNC_Description); - gRDFService->GetResource(NC_NAMESPACE_URI "Version", &kNC_Version); - gRDFService->GetResource(NC_NAMESPACE_URI "actionButton", &kNC_actionButton); - gRDFService->GetResource(NC_NAMESPACE_URI "actionBar", &kNC_actionBar); - gRDFService->GetResource(NC_NAMESPACE_URI "searchForm", &kNC_searchForm); - gRDFService->GetResource(NC_NAMESPACE_URI "LastText", &kNC_LastText); - gRDFService->GetResource(NC_NAMESPACE_URI "URL", &kNC_URL); - gRDFService->GetResource(RDF_NAMESPACE_URI "instanceOf", &kRDF_InstanceOf); - gRDFService->GetResource(RDF_NAMESPACE_URI "type", &kRDF_type); - gRDFService->GetResource(NC_NAMESPACE_URI "loading", &kNC_loading); - gRDFService->GetResource(NC_NAMESPACE_URI "HTML", &kNC_HTML); - gRDFService->GetResource(NC_NAMESPACE_URI "Icon", &kNC_Icon); - gRDFService->GetResource(NC_NAMESPACE_URI "StatusIcon", &kNC_StatusIcon); - gRDFService->GetResource(NC_NAMESPACE_URI "Banner", &kNC_Banner); - gRDFService->GetResource(NC_NAMESPACE_URI "Site", &kNC_Site); - gRDFService->GetResource(NC_NAMESPACE_URI "Relevance", &kNC_Relevance); - gRDFService->GetResource(NC_NAMESPACE_URI "Relevance?sort=true", &kNC_RelevanceSort); - gRDFService->GetResource(NC_NAMESPACE_URI "Date", &kNC_Date); - gRDFService->GetResource(NC_NAMESPACE_URI "PageRank", &kNC_PageRank); - gRDFService->GetResource(NC_NAMESPACE_URI "Engine", &kNC_Engine); - gRDFService->GetResource(NC_NAMESPACE_URI "Price", &kNC_Price); - gRDFService->GetResource(NC_NAMESPACE_URI "Price?sort=true", &kNC_PriceSort); - gRDFService->GetResource(NC_NAMESPACE_URI "Availability", &kNC_Availability); - gRDFService->GetResource(NC_NAMESPACE_URI "BookmarkSeparator", &kNC_BookmarkSeparator); - gRDFService->GetResource(NC_NAMESPACE_URI "Update", &kNC_Update); - gRDFService->GetResource(NC_NAMESPACE_URI "UpdateIcon", &kNC_UpdateIcon); - gRDFService->GetResource(NC_NAMESPACE_URI "UpdateCheckDays", &kNC_UpdateCheckDays); - gRDFService->GetResource(WEB_NAMESPACE_URI "LastPingDate", &kWEB_LastPingDate); - gRDFService->GetResource(WEB_NAMESPACE_URI "LastPingModDate", &kWEB_LastPingModDate); - gRDFService->GetResource(WEB_NAMESPACE_URI "LastPingContentLen", &kWEB_LastPingContentLen); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "searchtype"), + &kNC_SearchType); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "SearchResult"), + &kNC_SearchResult); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "ref"), + &kNC_Ref); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "child"), + &kNC_Child); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "title"), + &kNC_Title); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "data"), + &kNC_Data); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Name"), + &kNC_Name); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Description"), + &kNC_Description); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Version"), + &kNC_Version); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "actionButton"), + &kNC_actionButton); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "actionBar"), + &kNC_actionBar); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "searchForm"), + &kNC_searchForm); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "LastText"), + &kNC_LastText); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "URL"), + &kNC_URL); + gRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "instanceOf"), + &kRDF_InstanceOf); + gRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "type"), + &kRDF_type); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "loading"), + &kNC_loading); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "HTML"), + &kNC_HTML); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Icon"), + &kNC_Icon); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "StatusIcon"), + &kNC_StatusIcon); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Banner"), + &kNC_Banner); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Site"), + &kNC_Site); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Relevance"), + &kNC_Relevance); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Relevance?sort=true"), + &kNC_RelevanceSort); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Date"), + &kNC_Date); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "PageRank"), + &kNC_PageRank); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Engine"), + &kNC_Engine); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Price"), + &kNC_Price); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Price?sort=true"), + &kNC_PriceSort); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Availability"), + &kNC_Availability); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "BookmarkSeparator"), + &kNC_BookmarkSeparator); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Update"), + &kNC_Update); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "UpdateIcon"), + &kNC_UpdateIcon); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "UpdateCheckDays"), + &kNC_UpdateCheckDays); + gRDFService->GetResource(NS_LITERAL_CSTRING(WEB_NAMESPACE_URI "LastPingDate"), + &kWEB_LastPingDate); + gRDFService->GetResource(NS_LITERAL_CSTRING(WEB_NAMESPACE_URI "LastPingModDate"), + &kWEB_LastPingModDate); + gRDFService->GetResource(NS_LITERAL_CSTRING(WEB_NAMESPACE_URI "LastPingContentLen"), + &kWEB_LastPingContentLen); - gRDFService->GetResource(NC_NAMESPACE_URI "command?cmd=addtobookmarks", &kNC_SearchCommand_AddToBookmarks); - gRDFService->GetResource(NC_NAMESPACE_URI "command?cmd=addquerytobookmarks", &kNC_SearchCommand_AddQueryToBookmarks); - gRDFService->GetResource(NC_NAMESPACE_URI "command?cmd=filterresult", &kNC_SearchCommand_FilterResult); - gRDFService->GetResource(NC_NAMESPACE_URI "command?cmd=filtersite", &kNC_SearchCommand_FilterSite); - gRDFService->GetResource(NC_NAMESPACE_URI "command?cmd=clearfilters", &kNC_SearchCommand_ClearFilters); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "command?cmd=addtobookmarks"), + &kNC_SearchCommand_AddToBookmarks); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "command?cmd=addquerytobookmarks"), + &kNC_SearchCommand_AddQueryToBookmarks); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "command?cmd=filterresult"), + &kNC_SearchCommand_FilterResult); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "command?cmd=filtersite"), + &kNC_SearchCommand_FilterSite); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "command?cmd=clearfilters"), + &kNC_SearchCommand_ClearFilters); gRDFService->GetLiteral(NS_LITERAL_STRING("true").get(), &kTrueLiteral); @@ -1066,7 +1115,7 @@ InternetSearchDataSource::GetTarget(nsIRDFResource *source, nsCOMPtr category; nsCAutoString caturiC; caturiC.AssignWithConversion(catURI); - if (NS_FAILED(rv = gRDFService->GetResource(caturiC.get(), + if (NS_FAILED(rv = gRDFService->GetResource(caturiC, getter_AddRefs(category)))) return(rv); @@ -1185,7 +1234,7 @@ InternetSearchDataSource::GetTargets(nsIRDFResource *source, nsCOMPtr category; nsCAutoString caturiC; caturiC.AssignWithConversion(catURI); - if (NS_FAILED(rv = gRDFService->GetResource(caturiC.get(), + if (NS_FAILED(rv = gRDFService->GetResource(caturiC, getter_AddRefs(category)))) return(rv); @@ -1309,7 +1358,7 @@ InternetSearchDataSource::GetCategoryList() categoryStr.AppendWithConversion(catResURI); nsCOMPtr searchCategoryRes; - if (NS_FAILED(rv = gRDFService->GetUnicodeResource(categoryStr.get(), + if (NS_FAILED(rv = gRDFService->GetUnicodeResource(categoryStr, getter_AddRefs(searchCategoryRes)))) break; nsCOMPtr categoryContainer; @@ -1523,7 +1572,7 @@ InternetSearchDataSource::HasArcOut(nsIRDFResource *source, nsIRDFResource *aArc if (!uri) return(NS_ERROR_UNEXPECTED); nsCOMPtr category; - if (NS_FAILED(rv = gRDFService->GetResource(uri, + if (NS_FAILED(rv = gRDFService->GetResource(nsDependentCString(uri), getter_AddRefs(category)))) return(rv); @@ -1616,7 +1665,7 @@ InternetSearchDataSource::ArcLabelsOut(nsIRDFResource *source, if (!uri) return(NS_ERROR_UNEXPECTED); nsCOMPtr category; - if (NS_FAILED(rv = gRDFService->GetResource(uri, + if (NS_FAILED(rv = gRDFService->GetResource(nsDependentCString(uri), getter_AddRefs(category)))) return(rv); @@ -2481,7 +2530,7 @@ InternetSearchDataSource::GetInternetSearchURL(const char *searchEngineURI, nsresult rv; nsCOMPtr engine; - if (NS_FAILED(rv = gRDFService->GetResource(searchEngineURI, getter_AddRefs(engine)))) + if (NS_FAILED(rv = gRDFService->GetResource(nsDependentCString(searchEngineURI), getter_AddRefs(engine)))) return(rv); if (!engine) return(NS_ERROR_UNEXPECTED); @@ -3113,7 +3162,7 @@ InternetSearchDataSource::BeginSearchRequest(nsIRDFResource *source, PRBool doNe #endif nsCOMPtr engine; - gRDFService->GetResource(baseFilename, getter_AddRefs(engine)); + gRDFService->GetResource(nsDependentCString(baseFilename), getter_AddRefs(engine)); nsCRT::free(baseFilename); baseFilename = nsnull; if (!engine) continue; @@ -4021,7 +4070,7 @@ InternetSearchDataSource::SaveEngineInfoIntoGraph(nsIFile *file, nsIFile *icon, searchURL.Append(NS_LITERAL_STRING(".src")); } - if (NS_FAILED(rv = gRDFService->GetUnicodeResource(searchURL.get(), + if (NS_FAILED(rv = gRDFService->GetUnicodeResource(searchURL, getter_AddRefs(searchRes)))) return(rv); // save the basename reference @@ -4029,7 +4078,7 @@ InternetSearchDataSource::SaveEngineInfoIntoGraph(nsIFile *file, nsIFile *icon, { basename.InsertWithConversion(kURINC_SearchCategoryEngineBasenamePrefix, 0); - if (NS_FAILED(rv = gRDFService->GetUnicodeResource(basename.get(), + if (NS_FAILED(rv = gRDFService->GetUnicodeResource(basename, getter_AddRefs(categoryRes)))) return(rv); nsCOMPtr searchLiteral; @@ -4112,7 +4161,7 @@ InternetSearchDataSource::SaveEngineInfoIntoGraph(nsIFile *file, nsIFile *icon, nsAutoString catList; catList.AssignWithConversion(kURINC_SearchCategoryPrefix); catList.AppendWithConversion(catURI); - gRDFService->GetUnicodeResource(catList.get(), getter_AddRefs(catRes)); + gRDFService->GetUnicodeResource(catList, getter_AddRefs(catRes)); } nsCOMPtr container; diff --git a/xpfe/components/search/src/nsLocalSearchService.cpp b/xpfe/components/search/src/nsLocalSearchService.cpp index 4ebcfa554575..243b87942096 100755 --- a/xpfe/components/search/src/nsLocalSearchService.cpp +++ b/xpfe/components/search/src/nsLocalSearchService.cpp @@ -102,14 +102,21 @@ LocalSearchDataSource::LocalSearchDataSource(void) PR_ASSERT(NS_SUCCEEDED(rv)); - gRDFService->GetResource(NC_NAMESPACE_URI "child", &kNC_Child); - gRDFService->GetResource(NC_NAMESPACE_URI "Name", &kNC_Name); - gRDFService->GetResource(NC_NAMESPACE_URI "URL", &kNC_URL); - gRDFService->GetResource(NC_NAMESPACE_URI "FindObject", &kNC_FindObject); - gRDFService->GetResource(NC_NAMESPACE_URI "pulse", &kNC_pulse); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "child"), + &kNC_Child); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "Name"), + &kNC_Name); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "URL"), + &kNC_URL); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "FindObject"), + &kNC_FindObject); + gRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "pulse"), + &kNC_pulse); - gRDFService->GetResource(RDF_NAMESPACE_URI "instanceOf", &kRDF_InstanceOf); - gRDFService->GetResource(RDF_NAMESPACE_URI "type", &kRDF_type); + gRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "instanceOf"), + &kRDF_InstanceOf); + gRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "type"), + &kRDF_type); gLocalSearchDataSource = this; } @@ -573,7 +580,7 @@ LocalSearchDataSource::parseFindURL(nsIRDFResource *u, nsISupportsArray *array) continue; nsCOMPtr property; - rv = gRDFService->GetUnicodeResource(tokens[1].value.get(), + rv = gRDFService->GetUnicodeResource(tokens[1].value, getter_AddRefs(property)); if (NS_FAILED(rv) || (rv == NS_RDF_NO_VALUE) || !property) diff --git a/xpfe/components/urlbarhistory/src/nsUrlbarHistory.cpp b/xpfe/components/urlbarhistory/src/nsUrlbarHistory.cpp index 30934a4a85a3..30f43330d962 100644 --- a/xpfe/components/urlbarhistory/src/nsUrlbarHistory.cpp +++ b/xpfe/components/urlbarhistory/src/nsUrlbarHistory.cpp @@ -95,8 +95,9 @@ nsUrlbarHistory::nsUrlbarHistory():mLength(0) //printf("$$$$ Got RDF SERVICE $$$$\n"); res = gRDFService->GetDataSource("rdf:localstore", getter_AddRefs(mDataSource)); - res = gRDFService->GetResource("http://home.netscape.com/NC-rdf#child", &kNC_CHILD); - res = gRDFService->GetResource("nc:urlbar-history", &kNC_URLBARHISTORY); + res = gRDFService->GetResource(NS_LITERAL_CSTRING("http://home.netscape.com/NC-rdf#child"), + &kNC_CHILD); + res = gRDFService->GetResource(NS_LITERAL_CSTRING("nc:urlbar-history"), &kNC_URLBARHISTORY); } // Get the pref service res = nsServiceManager::GetService(kPrefServiceCID, NS_GET_IID(nsIPref), diff --git a/xpfe/components/windowds/nsWindowDataSource.cpp b/xpfe/components/windowds/nsWindowDataSource.cpp index be163f931c1f..b742cd0da07d 100644 --- a/xpfe/components/windowds/nsWindowDataSource.cpp +++ b/xpfe/components/windowds/nsWindowDataSource.cpp @@ -72,9 +72,9 @@ nsWindowDataSource::Init() rv = CallGetService("@mozilla.org/rdf/rdf-service;1", &gRDFService); if (NS_FAILED(rv)) return rv; - gRDFService->GetResource(kURINC_WindowRoot, &kNC_WindowRoot); - gRDFService->GetResource(kURINC_Name, &kNC_Name); - gRDFService->GetResource(kURINC_KeyIndex, &kNC_KeyIndex); + gRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_WindowRoot), &kNC_WindowRoot); + gRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_Name), &kNC_Name); + gRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_KeyIndex), &kNC_KeyIndex); } mInner = do_CreateInstance("@mozilla.org/rdf/datasource;1?name=in-memory-datasource", &rv); @@ -225,7 +225,7 @@ nsWindowDataSource::OnOpenWindow(nsIXULWindow *window) windowId.AppendInt(windowCount++, 10); nsCOMPtr windowResource; - gRDFService->GetResource(windowId.get(), getter_AddRefs(windowResource)); + gRDFService->GetResource(windowId, getter_AddRefs(windowResource)); nsVoidKey key(window); mWindowResources.Put(&key, windowResource); @@ -355,7 +355,8 @@ nsWindowDataSource::GetWindowForResource(const char *aResourceString, nsIDOMWindowInternal** aResult) { nsCOMPtr windowResource; - gRDFService->GetResource(aResourceString, getter_AddRefs(windowResource)); + gRDFService->GetResource(nsDependentCString(aResourceString), + getter_AddRefs(windowResource)); // now reverse-lookup in the hashtable findWindowClosure closure = { windowResource.get(), nsnull };