Bug 1842384 - Make setStringProperty work properly for non-ascii values. r=leftmostcat

The idl needs to use a modern string type. Non-ascii doesn't survive passed through XPCOM when the type is `string`.

Differential Revision: https://phabricator.services.mozilla.com/D186157

--HG--
extra : amend_source : 6d9d9f8734b3d8a654967cd0f704db43860cccce
This commit is contained in:
Magnus Melin 2023-08-16 10:58:13 +01:00
Родитель 28e6c01859
Коммит 84291c7d76
24 изменённых файлов: 152 добавлений и 170 удалений

Просмотреть файл

@ -226,11 +226,8 @@
}
if (this.showPreview) {
// Get the preview text as a UTF-8 encoded string.
msgBox.querySelector(".folderSummary-previewText").textContent =
decodeURIComponent(
escape(msgHdr.getStringProperty("preview") || "")
);
msgHdr.getStringProperty("preview") || "";
}
this.appendChild(msgBox);
haveMsgsToShow = true;
@ -287,11 +284,8 @@
}
if (this.showPreview) {
// Get the preview text as a UTF-8 encoded string.
msgBox.querySelector(".folderSummary-previewText").textContent =
decodeURIComponent(
escape(msgHdr.getStringProperty("preview") || "")
);
msgHdr.getStringProperty("preview") || "";
}
this.appendChild(msgBox);
}

Просмотреть файл

@ -13,8 +13,8 @@ interface nsIUTF8StringEnumerator;
[scriptable, uuid(3c11ddbe-c805-40c5-b9c9-d065fad5d0be)]
interface nsIMsgDBHdr : nsISupports
{
void setStringProperty(in string propertyName, in string propertyValue);
string getStringProperty(in string propertyName);
void setStringProperty(in string propertyName, in AUTF8String propertyValue);
AUTF8String getStringProperty(in string propertyName);
unsigned long getUint32Property(in string propertyName);
void setUint32Property(in string propertyName,
in unsigned long propertyVal);

Просмотреть файл

@ -1985,8 +1985,7 @@ AttachmentDeleter::OnStopRequest(nsIRequest* aRequest, nsresult aStatusCode) {
mMsgFile->Clone(getter_AddRefs(clone));
if (copyService) {
nsCString originalKeys;
mOriginalMessage->GetStringProperty("keywords",
getter_Copies(originalKeys));
mOriginalMessage->GetStringProperty("keywords", originalKeys);
rv = copyService->CopyFileMessage(clone, mMessageFolder, mOriginalMessage,
false, mOrigMsgFlags, originalKeys,
listenerCopyService, mMsgWindow);

Просмотреть файл

@ -939,7 +939,7 @@ nsMsgDBFolder::GetMsgInputStream(nsIMsgDBHdr* aMsgHdr,
nsresult rv = GetMsgStore(getter_AddRefs(msgStore));
NS_ENSURE_SUCCESS(rv, rv);
nsCString storeToken;
rv = aMsgHdr->GetStringProperty("storeToken", getter_Copies(storeToken));
rv = aMsgHdr->GetStringProperty("storeToken", storeToken);
NS_ENSURE_SUCCESS(rv, rv);
// Handle legacy DB which has mbox offset but no storeToken.
@ -956,7 +956,7 @@ nsMsgDBFolder::GetMsgInputStream(nsIMsgDBHdr* aMsgHdr,
uint64_t offset;
aMsgHdr->GetMessageOffset(&offset);
storeToken = nsPrintfCString("%" PRIu64, offset);
rv = aMsgHdr->SetStringProperty("storeToken", storeToken.get());
rv = aMsgHdr->SetStringProperty("storeToken", storeToken);
NS_ENSURE_SUCCESS(rv, rv);
}
@ -2280,12 +2280,12 @@ nsMsgDBFolder::OnMessageClassified(const nsACString& aMsgURI,
msgJunkScore.AppendInt(aClassification == nsIJunkMailPlugin::JUNK
? nsIJunkMailPlugin::IS_SPAM_SCORE
: nsIJunkMailPlugin::IS_HAM_SCORE);
mDatabase->SetStringProperty(msgKey, "junkscore", msgJunkScore.get());
mDatabase->SetStringProperty(msgKey, "junkscoreorigin", "plugin");
mDatabase->SetStringProperty(msgKey, "junkscore", msgJunkScore);
mDatabase->SetStringProperty(msgKey, "junkscoreorigin", "plugin"_ns);
nsAutoCString strPercent;
strPercent.AppendInt(aJunkPercent);
mDatabase->SetStringProperty(msgKey, "junkpercent", strPercent.get());
mDatabase->SetStringProperty(msgKey, "junkpercent", strPercent);
if (aClassification == nsIJunkMailPlugin::JUNK) {
// IMAP has its own way of marking read.
@ -2344,7 +2344,7 @@ nsMsgDBFolder::OnMessageTraitsClassified(const nsACString& aMsgURI,
traitId.InsertLiteral("bayespercent/", 0);
nsAutoCString strPercent;
strPercent.AppendInt(aPercents[i]);
mDatabase->SetStringPropertyByHdr(msgHdr, traitId.get(), strPercent.get());
mDatabase->SetStringPropertyByHdr(msgHdr, traitId.get(), strPercent);
}
return NS_OK;
}
@ -2559,7 +2559,7 @@ nsMsgDBFolder::CallFilterPlugins(nsIMsgWindow* aMsgWindow, bool* aFiltersRun) {
{
MOZ_LOG(FILTERLOGMODULE, LogLevel::Info, ("Spam filter"));
nsCString junkScore;
msgHdr->GetStringProperty("junkscore", getter_Copies(junkScore));
msgHdr->GetStringProperty("junkscore", junkScore);
if (!junkScore.IsEmpty()) {
// ignore already scored messages.
MOZ_LOG(FILTERLOGMODULE, LogLevel::Info,
@ -2573,8 +2573,8 @@ nsMsgDBFolder::CallFilterPlugins(nsIMsgWindow* aMsgWindow, bool* aFiltersRun) {
// mark this msg as non-junk, because we whitelisted it.
nsAutoCString msgJunkScore;
msgJunkScore.AppendInt(nsIJunkMailPlugin::IS_HAM_SCORE);
database->SetStringProperty(msgKey, "junkscore", msgJunkScore.get());
database->SetStringProperty(msgKey, "junkscoreorigin", "whitelist");
database->SetStringProperty(msgKey, "junkscore", msgJunkScore);
database->SetStringProperty(msgKey, "junkscoreorigin", "whitelist"_ns);
MOZ_LOG(FILTERLOGMODULE, LogLevel::Info,
("Message whitelisted, skipping"));
break; // skip this msg since it's in the white list
@ -4459,9 +4459,8 @@ nsMsgDBFolder::SetJunkScoreForMessages(
for (auto message : aMessages) {
nsMsgKey msgKey;
(void)message->GetMessageKey(&msgKey);
mDatabase->SetStringProperty(msgKey, "junkscore",
PromiseFlatCString(junkScore).get());
mDatabase->SetStringProperty(msgKey, "junkscoreorigin", "filter");
mDatabase->SetStringProperty(msgKey, "junkscore", junkScore);
mDatabase->SetStringProperty(msgKey, "junkscoreorigin", "filter"_ns);
}
}
return NS_OK;
@ -5348,7 +5347,7 @@ nsresult nsMsgDBFolder::GetMsgPreviewTextFromStream(nsIMsgDBHdr* msgHdr,
// replaces all tabs and line returns with a space,
// then trims off leading and trailing white space
msgBody.CompressWhitespace();
msgHdr->SetStringProperty("preview", msgBody.get());
msgHdr->SetStringProperty("preview", msgBody);
return rv;
}
@ -5392,7 +5391,7 @@ NS_IMETHODIMP nsMsgDBFolder::AddKeywordsToMessages(
nsCString keywords;
for (auto message : aMessages) {
message->GetStringProperty("keywords", getter_Copies(keywords));
message->GetStringProperty("keywords", keywords);
nsTArray<nsCString> keywordArray;
ParseString(aKeywords, ' ', keywordArray);
uint32_t addCount = 0;
@ -5407,7 +5406,7 @@ NS_IMETHODIMP nsMsgDBFolder::AddKeywordsToMessages(
// avoid using the message key to set the string property, because
// in the case of filters running on incoming pop3 mail with quarantining
// turned on, the message key is wrong.
mDatabase->SetStringPropertyByHdr(message, "keywords", keywords.get());
mDatabase->SetStringPropertyByHdr(message, "keywords", keywords);
if (addCount) NotifyPropertyFlagChanged(message, kKeywords, 0, addCount);
}
@ -5428,7 +5427,7 @@ NS_IMETHODIMP nsMsgDBFolder::RemoveKeywordsFromMessages(
// If the tag is also a label, we should remove the label too...
for (auto message : aMessages) {
rv = message->GetStringProperty("keywords", getter_Copies(keywords));
rv = message->GetStringProperty("keywords", keywords);
uint32_t removeCount = 0;
for (uint32_t j = 0; j < keywordArray.Length(); j++) {
int32_t startOffset, length;
@ -5449,7 +5448,7 @@ NS_IMETHODIMP nsMsgDBFolder::RemoveKeywordsFromMessages(
}
if (removeCount) {
mDatabase->SetStringPropertyByHdr(message, "keywords", keywords.get());
mDatabase->SetStringPropertyByHdr(message, "keywords", keywords);
NotifyPropertyFlagChanged(message, kKeywords, removeCount, 0);
}
}

Просмотреть файл

@ -316,7 +316,7 @@ static void UpdateCachedName(nsIMsgDBHdr* aHdr, const char* header_field,
// Save name.
newCachedName.Append(NS_ConvertUTF16toUTF8(newName));
aHdr->SetStringProperty(header_field, newCachedName.get());
aHdr->SetStringProperty(header_field, newCachedName);
}
nsresult nsMsgDBView::FetchAuthor(nsIMsgDBHdr* aHdr, nsAString& aSenderString) {
@ -328,7 +328,7 @@ nsresult nsMsgDBView::FetchAuthor(nsIMsgDBHdr* aHdr, nsAString& aSenderString) {
prefs->GetIntPref("mail.displayname.version", &currentDisplayNameVersion);
prefs->GetBoolPref("mail.showCondensedAddresses", &showCondensedAddresses);
aHdr->GetStringProperty("sender_name", getter_Copies(unparsedAuthor));
aHdr->GetStringProperty("sender_name", unparsedAuthor);
// If the author is already computed, use it.
if (!unparsedAuthor.IsEmpty()) {
@ -429,7 +429,7 @@ nsresult nsMsgDBView::FetchRecipients(nsIMsgDBHdr* aHdr,
prefs->GetIntPref("mail.displayname.version", &currentDisplayNameVersion);
prefs->GetBoolPref("mail.showCondensedAddresses", &showCondensedAddresses);
aHdr->GetStringProperty("recipient_names", getter_Copies(recipients));
aHdr->GetStringProperty("recipient_names", recipients);
if (!recipients.IsEmpty()) {
nsCString cachedRecipients;
@ -733,7 +733,7 @@ nsresult nsMsgDBView::FetchKeywords(nsIMsgDBHdr* aHdr,
NS_ENSURE_SUCCESS(rv, rv);
}
nsCString keywords;
aHdr->GetStringProperty("keywords", getter_Copies(keywords));
aHdr->GetStringProperty("keywords", keywords);
keywordString = keywords;
return NS_OK;
}
@ -788,7 +788,7 @@ nsresult nsMsgDBView::FetchTags(nsIMsgDBHdr* aHdr, nsAString& aTagString) {
nsString tags;
nsCString keywords;
aHdr->GetStringProperty("keywords", getter_Copies(keywords));
aHdr->GetStringProperty("keywords", keywords);
nsTArray<nsCString> keywordsArray;
ParseString(keywords, ' ', keywordsArray);
@ -1007,7 +1007,7 @@ nsresult nsMsgDBView::UpdateDisplayMessage(nsMsgViewIndex viewPosition) {
FetchSubject(msgHdr, m_flags[viewPosition], subject);
nsCString keywords;
rv = msgHdr->GetStringProperty("keywords", getter_Copies(keywords));
rv = msgHdr->GetStringProperty("keywords", keywords);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIMsgFolder> folder = m_viewFolder ? m_viewFolder : m_folder;
@ -1193,11 +1193,11 @@ nsMsgDBView::GetRowProperties(int32_t index, nsAString& properties) {
properties.AppendLiteral(" imapdeleted");
nsCString imageSize;
msgHdr->GetStringProperty("imageSize", getter_Copies(imageSize));
msgHdr->GetStringProperty("imageSize", imageSize);
if (!imageSize.IsEmpty()) properties.AppendLiteral(" hasimage");
nsCString junkScoreStr;
msgHdr->GetStringProperty("junkscore", getter_Copies(junkScoreStr));
msgHdr->GetStringProperty("junkscore", junkScoreStr);
if (!junkScoreStr.IsEmpty()) {
if (junkScoreStr.ToInteger(&rv) == nsIJunkMailPlugin::IS_SPAM_SCORE)
properties.AppendLiteral(" junk");
@ -1315,11 +1315,11 @@ nsMsgDBView::GetCellProperties(int32_t aRow, nsTreeColumn* col,
properties.AppendLiteral(" imapdeleted");
nsCString imageSize;
msgHdr->GetStringProperty("imageSize", getter_Copies(imageSize));
msgHdr->GetStringProperty("imageSize", imageSize);
if (!imageSize.IsEmpty()) properties.AppendLiteral(" hasimage");
nsCString junkScoreStr;
msgHdr->GetStringProperty("junkscore", getter_Copies(junkScoreStr));
msgHdr->GetStringProperty("junkscore", junkScoreStr);
if (!junkScoreStr.IsEmpty()) {
if (junkScoreStr.ToInteger(&rv) == nsIJunkMailPlugin::IS_SPAM_SCORE)
properties.AppendLiteral(" junk");
@ -1346,7 +1346,7 @@ nsMsgDBView::GetCellProperties(int32_t aRow, nsTreeColumn* col,
// I'm not sure anyone uses the kw- property, though it could be nice
// for people wanting to extend the thread pane.
nsCString keywordProperty;
msgHdr->GetStringProperty("keywords", getter_Copies(keywordProperty));
msgHdr->GetStringProperty("keywords", keywordProperty);
if (!keywordProperty.IsEmpty()) {
NS_ConvertUTF8toUTF16 keywords(keywordProperty);
int32_t spaceIndex = 0;
@ -1626,7 +1626,7 @@ nsMsgDBView::GetCellValue(int32_t aRow, nsTreeColumn* aCol, nsAString& aValue) {
case 'j':
if (colID.EqualsLiteral("junkStatusCol") && JunkControlsEnabled(aRow)) {
nsCString junkScoreStr;
msgHdr->GetStringProperty("junkscore", getter_Copies(junkScoreStr));
msgHdr->GetStringProperty("junkscore", junkScoreStr);
// Only need to assign a real value for junk, it's empty already
// as it should be for non-junk.
if (!junkScoreStr.IsEmpty() &&
@ -1948,7 +1948,7 @@ nsMsgDBView::CellTextForColumn(int32_t aRow, const nsAString& aColumnName,
case 'j': {
if (aColumnName.EqualsLiteral("junkStatusCol")) {
nsCString junkScoreStr;
msgHdr->GetStringProperty("junkscore", getter_Copies(junkScoreStr));
msgHdr->GetStringProperty("junkscore", junkScoreStr);
CopyASCIItoUTF16(junkScoreStr, aValue);
}
break;
@ -2104,8 +2104,7 @@ nsMsgDBView::CycleCell(int32_t row, nsTreeColumn* col) {
nsresult rv = GetMsgHdrForViewIndex(row, getter_AddRefs(msgHdr));
if (NS_SUCCEEDED(rv) && msgHdr) {
nsCString junkScoreStr;
rv =
msgHdr->GetStringProperty("junkscore", getter_Copies(junkScoreStr));
rv = msgHdr->GetStringProperty("junkscore", junkScoreStr);
if (junkScoreStr.IsEmpty() ||
(junkScoreStr.ToInteger(&rv) == nsIJunkMailPlugin::IS_HAM_SCORE)) {
ApplyCommandToIndices(nsMsgViewCommandType::junk,
@ -3220,13 +3219,11 @@ nsresult nsMsgDBView::SetMsgHdrJunkStatus(nsIJunkMailPlugin* aJunkPlugin,
nsMsgJunkStatus aNewClassification) {
// Get the old junk score.
nsCString junkScoreStr;
nsresult rv =
aMsgHdr->GetStringProperty("junkscore", getter_Copies(junkScoreStr));
nsresult rv = aMsgHdr->GetStringProperty("junkscore", junkScoreStr);
// And the old origin.
nsCString oldOriginStr;
rv = aMsgHdr->GetStringProperty("junkscoreorigin",
getter_Copies(oldOriginStr));
rv = aMsgHdr->GetStringProperty("junkscoreorigin", oldOriginStr);
// If this was not classified by the user, say so.
nsMsgJunkStatus oldUserClassification;
@ -3268,7 +3265,7 @@ nsresult nsMsgDBView::SetMsgHdrJunkStatus(nsIJunkMailPlugin* aJunkPlugin,
// and told us the junk status of this message.
// Set origin first so that listeners on the junkscore will
// know the correct origin.
rv = db->SetStringProperty(msgKey, "junkscoreorigin", "user");
rv = db->SetStringProperty(msgKey, "junkscoreorigin", "user"_ns);
NS_ASSERTION(NS_SUCCEEDED(rv), "SetStringPropertyByIndex failed");
// Set the junk score on the message itself.
@ -3276,7 +3273,7 @@ nsresult nsMsgDBView::SetMsgHdrJunkStatus(nsIJunkMailPlugin* aJunkPlugin,
msgJunkScore.AppendInt(aNewClassification == nsIJunkMailPlugin::JUNK
? nsIJunkMailPlugin::IS_SPAM_SCORE
: nsIJunkMailPlugin::IS_HAM_SCORE);
db->SetStringProperty(msgKey, "junkscore", msgJunkScore.get());
db->SetStringProperty(msgKey, "junkscore", msgJunkScore);
NS_ENSURE_SUCCESS(rv, rv);
return rv;
@ -3803,7 +3800,7 @@ nsresult nsMsgDBView::GetLongField(nsIMsgDBHdr* msgHdr,
break;
case nsMsgViewSortType::byJunkStatus: {
nsCString junkScoreStr;
rv = msgHdr->GetStringProperty("junkscore", getter_Copies(junkScoreStr));
rv = msgHdr->GetStringProperty("junkscore", junkScoreStr);
// Unscored messages should come before messages that are scored
// junkScoreStr is "", and "0" - "100"; normalize to 0 - 101.
*result = junkScoreStr.IsEmpty() ? (0) : atoi(junkScoreStr.get()) + 1;

Просмотреть файл

@ -816,7 +816,7 @@ nsresult nsFolderCompactState::FlushBuffer() {
nsAutoCString keywords;
if (m_curSrcHdr) {
m_curSrcHdr->GetFlags(&msgFlags);
m_curSrcHdr->GetStringProperty("keywords", getter_Copies(keywords));
m_curSrcHdr->GetStringProperty("keywords", keywords);
// growKeywords is set if msgStore didn't have enough room to edit
// X-Mozilla-* headers in situ. We'll rewrite all those headers
// regardless but we still want to clear it.
@ -935,7 +935,7 @@ nsresult nsOfflineStoreCompactState::CopyNextMessage(bool& done) {
nsresult rv =
m_db->GetMsgHdrForKey(m_keys[m_curIndex], getter_AddRefs(hdr));
NS_ENSURE_SUCCESS(rv, rv);
hdr->GetStringProperty("pendingRemoval", getter_Copies(pendingRemoval));
hdr->GetStringProperty("pendingRemoval", pendingRemoval);
if (!pendingRemoval.IsEmpty()) {
m_curIndex++;
// Turn off offline flag for message, since after the compact is
@ -944,7 +944,7 @@ nsresult nsOfflineStoreCompactState::CopyNextMessage(bool& done) {
hdr->AndFlags(~nsMsgMessageFlags::Offline, &resultFlags);
// We need to clear this in case the user changes the offline retention
// settings.
hdr->SetStringProperty("pendingRemoval", "");
hdr->SetStringProperty("pendingRemoval", ""_ns);
continue;
}
m_messageUri.Truncate(); // clear the previous message uri
@ -1015,8 +1015,7 @@ nsOfflineStoreCompactState::OnStopRequest(nsIRequest* request,
if (msgHdr) {
if (NS_SUCCEEDED(status)) {
msgHdr->SetMessageOffset(m_startOfNewMsg);
char storeToken[100];
PR_snprintf(storeToken, sizeof(storeToken), "%lld", m_startOfNewMsg);
nsCString storeToken = nsPrintfCString("%" PRIu64, m_startOfNewMsg);
msgHdr->SetStringProperty("storeToken", storeToken);
msgHdr->SetOfflineMessageSize(m_offlineMsgSize);
} else {
@ -1166,8 +1165,7 @@ nsFolderCompactState::EndCopy(nsIURI* uri, nsresult status) {
}
m_curSrcHdr = nullptr;
if (newMsgHdr) {
char storeToken[100];
PR_snprintf(storeToken, sizeof(storeToken), "%lld", m_startOfNewMsg);
nsCString storeToken = nsPrintfCString("%" PRIu64, m_startOfNewMsg);
newMsgHdr->SetStringProperty("storeToken", storeToken);
newMsgHdr->SetMessageOffset(m_startOfNewMsg);
uint64_t msgSize = endOfMsg - m_startOfNewMsg;

Просмотреть файл

@ -451,8 +451,7 @@ NS_IMETHODIMP nsMsgPurgeService::OnSearchHit(nsIMsgDBHdr* aMsgHdr,
//
// see bug #194090
nsCString junkScoreStr;
nsresult rv =
aMsgHdr->GetStringProperty("junkscore", getter_Copies(junkScoreStr));
nsresult rv = aMsgHdr->GetStringProperty("junkscore", junkScoreStr);
NS_ENSURE_SUCCESS(rv, rv);
MOZ_LOG(MsgPurgeLogModule, mozilla::LogLevel::Info,

Просмотреть файл

@ -231,8 +231,7 @@ nsMsgQuickSearchDBView::OnHdrPropertyChanged(nsIMsgDBHdr* aHdrChanged,
return NS_OK;
nsCString originStr;
(void)aHdrChanged->GetStringProperty("junkscoreorigin",
getter_Copies(originStr));
(void)aHdrChanged->GetStringProperty("junkscoreorigin", originStr);
// check for "plugin" with only first character for performance
bool plugin = (originStr.get()[0] == 'p');

Просмотреть файл

@ -151,8 +151,7 @@ nsMsgXFVirtualFolderDBView::OnHdrPropertyChanged(
if (index == nsMsgViewIndex_None) return NS_OK;
nsCString originStr;
(void)aHdrChanged->GetStringProperty("junkscoreorigin",
getter_Copies(originStr));
(void)aHdrChanged->GetStringProperty("junkscoreorigin", originStr);
// Check for "plugin" with only first character for performance.
bool plugin = (originStr.get()[0] == 'p');

Просмотреть файл

@ -1529,13 +1529,12 @@ nsresult nsMsgCompose::CreateMessage(const nsACString& originalMsgURI,
if (msgDBHdr) {
nsCString queuedDisposition;
msgDBHdr->GetStringProperty(QUEUED_DISPOSITION_PROPERTY,
getter_Copies(queuedDisposition));
queuedDisposition);
// We need to retrieve the original URI from the database so we can
// set the disposition flags correctly if the draft is a reply or
// forwarded message.
nsCString originalMsgURIfromDB;
msgDBHdr->GetStringProperty(ORIG_URI_PROPERTY,
getter_Copies(originalMsgURIfromDB));
msgDBHdr->GetStringProperty(ORIG_URI_PROPERTY, originalMsgURIfromDB);
mOriginalMsgURI = originalMsgURIfromDB;
if (!queuedDisposition.IsEmpty()) {
if (queuedDisposition.EqualsLiteral("replied"))
@ -2814,7 +2813,7 @@ NS_IMETHODIMP nsMsgCompose::RememberQueuedDisposition() {
rv = GetMsgDBHdrFromURI(curDraftIdURL, getter_AddRefs(draftHdr));
NS_ENSURE_SUCCESS(rv, rv);
draftHdr->GetStringProperty(QUEUED_DISPOSITION_PROPERTY,
getter_Copies(dispositionSetting));
dispositionSetting);
}
}
@ -2859,13 +2858,12 @@ NS_IMETHODIMP nsMsgCompose::RememberQueuedDisposition() {
identityKey.get());
} else if (msgHdr) {
if (!mOriginalMsgURI.IsEmpty()) {
msgHdr->SetStringProperty(ORIG_URI_PROPERTY, mOriginalMsgURI.get());
msgHdr->SetStringProperty(ORIG_URI_PROPERTY, mOriginalMsgURI);
if (!dispositionSetting.IsEmpty())
msgHdr->SetStringProperty(QUEUED_DISPOSITION_PROPERTY,
dispositionSetting.get());
dispositionSetting);
}
msgHdr->SetStringProperty(HEADER_X_MOZILLA_IDENTITY_KEY,
identityKey.get());
msgHdr->SetStringProperty(HEADER_X_MOZILLA_IDENTITY_KEY, identityKey);
}
}
return NS_OK;

Просмотреть файл

@ -674,7 +674,7 @@ NS_IMETHODIMP nsMsgTemplateReplyHelper::OnStopRunningUrl(nsIURI* aUrl,
do_CreateInstance("@mozilla.org/messengercompose/composefields;1", &rv);
nsCString replyTo;
mHdrToReplyTo->GetStringProperty("replyTo", getter_Copies(replyTo));
mHdrToReplyTo->GetStringProperty("replyTo", replyTo);
if (replyTo.IsEmpty()) mHdrToReplyTo->GetAuthor(getter_Copies(replyTo));
compFields->SetTo(NS_ConvertUTF8toUTF16(replyTo));
@ -847,7 +847,7 @@ NS_IMETHODIMP nsMsgComposeService::ReplyWithTemplate(
helper->mIdentity = identity;
nsAutoCString replyTo;
aMsgHdr->GetStringProperty("replyTo", getter_Copies(replyTo));
aMsgHdr->GetStringProperty("replyTo", replyTo);
if (replyTo.IsEmpty()) aMsgHdr->GetAuthor(getter_Copies(replyTo));
if (replyTo.IsEmpty()) return NS_ERROR_FAILURE; // nowhere to send the reply

Просмотреть файл

@ -564,8 +564,7 @@ nsresult nsMsgSendLater::StartNextMailFileSend(nsresult prevStatus) {
if (NS_FAILED(rv) && !messageService) return NS_ERROR_FACTORY_NOT_LOADED;
nsCString identityKey;
rv = mMessage->GetStringProperty(HEADER_X_MOZILLA_IDENTITY_KEY,
getter_Copies(identityKey));
rv = mMessage->GetStringProperty(HEADER_X_MOZILLA_IDENTITY_KEY, identityKey);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIMsgIdentity> identity;
@ -765,10 +764,8 @@ nsresult nsMsgSendLater::SetOrigMsgDisposition() {
// or forward of.
nsCString originalMsgURIs;
nsCString queuedDisposition;
mMessage->GetStringProperty(ORIG_URI_PROPERTY,
getter_Copies(originalMsgURIs));
mMessage->GetStringProperty(QUEUED_DISPOSITION_PROPERTY,
getter_Copies(queuedDisposition));
mMessage->GetStringProperty(ORIG_URI_PROPERTY, originalMsgURIs);
mMessage->GetStringProperty(QUEUED_DISPOSITION_PROPERTY, queuedDisposition);
if (!queuedDisposition.IsEmpty()) {
nsTArray<nsCString> uriArray;
ParseString(originalMsgURIs, ',', uriArray);

Просмотреть файл

@ -379,7 +379,7 @@ interface nsIMsgDatabase : nsIDBChangeAnnouncer {
in nsIDBChangeListener instigator);
void markOffline(in nsMsgKey key, in boolean offline,
in nsIDBChangeListener instigator);
void setStringProperty(in nsMsgKey aKey, in string aProperty, in string aValue);
void setStringProperty(in nsMsgKey aKey, in string aProperty, in AUTF8String aValue);
/**
* Set the value of a string property in a message header
*
@ -387,7 +387,7 @@ interface nsIMsgDatabase : nsIDBChangeAnnouncer {
* @param aProperty the property to change
* @param aValue new value for the property
*/
void setStringPropertyByHdr(in nsIMsgDBHdr msgHdr, in string aProperty, in string aValue);
void setStringPropertyByHdr(in nsIMsgDBHdr msgHdr, in string aProperty, in AUTF8String aValue);
/**
* Set the value of a uint32 property in a message header.

Просмотреть файл

@ -29,6 +29,7 @@
#include "nsMemory.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "nsPrintfCString.h"
#include "nsMsgDatabaseEnumerators.h"
#include "nsIMemoryReporter.h"
#include "nsIWeakReferenceUtils.h"
@ -2125,7 +2126,7 @@ NS_IMETHODIMP nsMsgDatabase::MarkOffline(nsMsgKey key, bool offline,
NS_IMETHODIMP nsMsgDatabase::SetStringProperty(nsMsgKey aKey,
const char* aProperty,
const char* aValue) {
const nsACString& aValue) {
nsCOMPtr<nsIMsgDBHdr> msgHdr;
nsresult rv = GetMsgHdrForKey(aKey, getter_AddRefs(msgHdr));
if (NS_FAILED(rv) || !msgHdr)
@ -2135,7 +2136,7 @@ NS_IMETHODIMP nsMsgDatabase::SetStringProperty(nsMsgKey aKey,
NS_IMETHODIMP nsMsgDatabase::SetStringPropertyByHdr(nsIMsgDBHdr* msgHdr,
const char* aProperty,
const char* aValue) {
const nsACString& aValue) {
// don't do notifications if message not yet added to database.
// Ignore errors (consequences of failure are minor).
bool notify = true;
@ -2144,7 +2145,7 @@ NS_IMETHODIMP nsMsgDatabase::SetStringPropertyByHdr(nsIMsgDBHdr* msgHdr,
ContainsKey(key, &notify);
nsCString oldValue;
nsresult rv = msgHdr->GetStringProperty(aProperty, getter_Copies(oldValue));
nsresult rv = msgHdr->GetStringProperty(aProperty, oldValue);
NS_ENSURE_SUCCESS(rv, rv);
// if no change to this string property, bail out
@ -2176,7 +2177,7 @@ NS_IMETHODIMP nsMsgDatabase::SetStringPropertyByHdr(nsIMsgDBHdr* msgHdr,
// if this is the junk score property notify, as long as we're not going
// from no value to non junk
if (!strcmp(aProperty, "junkscore") &&
!(oldValue.IsEmpty() && !strcmp(aValue, "0")))
!(oldValue.IsEmpty() && aValue.Equals("0")))
NotifyJunkScoreChanged(nullptr);
nsTObserverArray<nsCOMPtr<nsIDBChangeListener>>::ForwardIterator listeners(

Просмотреть файл

@ -207,17 +207,19 @@ NS_IMETHODIMP nsMsgHdr::MarkFlagged(bool bFlagged) {
}
NS_IMETHODIMP nsMsgHdr::SetStringProperty(const char* propertyName,
const char* propertyValue) {
const nsACString& propertyValue) {
NS_ENSURE_ARG_POINTER(propertyName);
if (!m_mdb || !m_mdbRow) return NS_ERROR_NULL_POINTER;
return m_mdb->SetProperty(m_mdbRow, propertyName, propertyValue);
return m_mdb->SetProperty(m_mdbRow, propertyName,
PromiseFlatCString(propertyValue).get());
}
NS_IMETHODIMP nsMsgHdr::GetStringProperty(const char* propertyName,
char** aPropertyValue) {
nsACString& aPropertyValue) {
NS_ENSURE_ARG_POINTER(propertyName);
if (!m_mdb || !m_mdbRow) return NS_ERROR_NULL_POINTER;
return m_mdb->GetProperty(m_mdbRow, propertyName, aPropertyValue);
return m_mdb->GetProperty(m_mdbRow, propertyName,
getter_Copies(aPropertyValue));
}
NS_IMETHODIMP nsMsgHdr::GetUint32Property(const char* propertyName,
@ -384,13 +386,17 @@ NS_IMETHODIMP nsMsgHdr::GetPriority(nsMsgPriorityValue* result) {
// And I'm not sure if we should short circuit it here,
// or at a higher level where it might be more efficient.
NS_IMETHODIMP nsMsgHdr::SetAccountKey(const char* aAccountKey) {
return SetStringProperty("account", aAccountKey);
return SetStringProperty("account", nsDependentCString(aAccountKey));
}
NS_IMETHODIMP nsMsgHdr::GetAccountKey(char** aResult) {
NS_ENSURE_ARG_POINTER(aResult);
return GetStringProperty("account", aResult);
nsCString key;
nsresult rv = GetStringProperty("account", key);
NS_ENSURE_SUCCESS(rv, rv);
*aResult = ToNewCString(key);
return NS_OK;
}
NS_IMETHODIMP nsMsgHdr::GetMessageOffset(uint64_t* result) {
@ -407,7 +413,7 @@ NS_IMETHODIMP nsMsgHdr::GetMessageOffset(uint64_t* result) {
// message even if the assert passes).
#ifdef DEBUG
nsCString tok;
GetStringProperty("storeToken", getter_Copies(tok));
GetStringProperty("storeToken", tok);
nsPrintfCString err("Missing .messageOffset (key=%u, storeToken='%s')",
m_messageKey, tok.get());
NS_WARNING(err.get());

Просмотреть файл

@ -1324,7 +1324,7 @@ NS_IMETHODIMP nsImapMailFolder::MarkPendingRemoval(nsIMsgDBHdr* aHdr,
NS_ENSURE_ARG_POINTER(aHdr);
uint32_t offlineMessageSize;
aHdr->GetOfflineMessageSize(&offlineMessageSize);
aHdr->SetStringProperty("pendingRemoval", aMark ? "1" : "");
aHdr->SetStringProperty("pendingRemoval", aMark ? "1"_ns : ""_ns);
if (!aMark) return NS_OK;
nsresult rv = GetDatabase();
NS_ENSURE_SUCCESS(rv, rv);
@ -3031,9 +3031,9 @@ nsresult nsImapMailFolder::NormalEndHeaderParseStream(
flagState->GetCustomAttribute(m_curMsgUid, "X-GM-MSGID"_ns, msgIDValue);
flagState->GetCustomAttribute(m_curMsgUid, "X-GM-THRID"_ns, threadIDValue);
flagState->GetCustomAttribute(m_curMsgUid, "X-GM-LABELS"_ns, labelsValue);
newMsgHdr->SetStringProperty("X-GM-MSGID", msgIDValue.get());
newMsgHdr->SetStringProperty("X-GM-THRID", threadIDValue.get());
newMsgHdr->SetStringProperty("X-GM-LABELS", labelsValue.get());
newMsgHdr->SetStringProperty("X-GM-MSGID", msgIDValue);
newMsgHdr->SetStringProperty("X-GM-THRID", threadIDValue);
newMsgHdr->SetStringProperty("X-GM-LABELS", labelsValue);
}
m_msgParser->Clear(); // clear out parser, because it holds onto a msg hdr.
@ -3451,9 +3451,8 @@ NS_IMETHODIMP nsImapMailFolder::ApplyFilterHit(nsIMsgFilter* filter,
int32_t junkScore;
filterAction->GetJunkScore(&junkScore);
junkScoreStr.AppendInt(junkScore);
rv = mDatabase->SetStringProperty(msgKey, "junkscore",
junkScoreStr.get());
mDatabase->SetStringProperty(msgKey, "junkscoreorigin", "filter");
rv = mDatabase->SetStringProperty(msgKey, "junkscore", junkScoreStr);
mDatabase->SetStringProperty(msgKey, "junkscoreorigin", "filter"_ns);
// If score is available, set up to store junk status on server.
if (junkScore == nsIJunkMailPlugin::IS_SPAM_SCORE ||
@ -4502,30 +4501,29 @@ nsresult nsImapMailFolder::HandleCustomFlags(nsMsgKey uidOfMessage,
nsCaseInsensitiveCStringComparator)) {
nsAutoCString msgJunkScore;
msgJunkScore.AppendInt(nsIJunkMailPlugin::IS_HAM_SCORE);
mDatabase->SetStringProperty(uidOfMessage, "junkscore", msgJunkScore.get());
mDatabase->SetStringProperty(uidOfMessage, "junkscore", msgJunkScore);
} else if (FindInReadable("Junk"_ns, keywords,
nsCaseInsensitiveCStringComparator)) {
uint32_t newFlags;
dbHdr->AndFlags(~nsMsgMessageFlags::New, &newFlags);
nsAutoCString msgJunkScore;
msgJunkScore.AppendInt(nsIJunkMailPlugin::IS_SPAM_SCORE);
mDatabase->SetStringProperty(uidOfMessage, "junkscore", msgJunkScore.get());
mDatabase->SetStringProperty(uidOfMessage, "junkscore", msgJunkScore);
} else
messageClassified = false;
if (messageClassified) {
// only set the junkscore origin if it wasn't set before.
nsCString existingProperty;
dbHdr->GetStringProperty("junkscoreorigin",
getter_Copies(existingProperty));
dbHdr->GetStringProperty("junkscoreorigin", existingProperty);
if (existingProperty.IsEmpty())
dbHdr->SetStringProperty("junkscoreorigin", "imapflag");
dbHdr->SetStringProperty("junkscoreorigin", "imapflag"_ns);
}
if (!(userFlags & kImapMsgSupportUserFlag)) {
nsCString localKeywords;
nsCString prevKeywords;
dbHdr->GetStringProperty("keywords", getter_Copies(localKeywords));
dbHdr->GetStringProperty("prevkeywords", getter_Copies(prevKeywords));
dbHdr->GetStringProperty("keywords", localKeywords);
dbHdr->GetStringProperty("prevkeywords", prevKeywords);
// localKeywords: tags currently stored in database for the message.
// keywords: tags stored in server and obtained when flags for the message
// were last fetched. (Parameter of this function.)
@ -4537,7 +4535,7 @@ nsresult nsImapMailFolder::HandleCustomFlags(nsMsgKey uidOfMessage,
// clang-format on
// Store keywords to detect changes on next call of this function.
dbHdr->SetStringProperty("prevkeywords", keywords.get());
dbHdr->SetStringProperty("prevkeywords", keywords);
// Parse the space separated strings into arrays.
nsTArray<nsCString> localKeywordArray;
@ -4574,10 +4572,10 @@ nsresult nsImapMailFolder::HandleCustomFlags(nsMsgKey uidOfMessage,
MOZ_LOG(IMAP_KW, mozilla::LogLevel::Debug,
("combinedKeywords stored = |%s|", combinedKeywords.get()));
// combinedKeywords are tags being stored in database for the message.
return dbHdr->SetStringProperty("keywords", combinedKeywords.get());
return dbHdr->SetStringProperty("keywords", combinedKeywords);
}
return (userFlags & kImapMsgSupportUserFlag)
? dbHdr->SetStringProperty("keywords", keywords.get())
? dbHdr->SetStringProperty("keywords", keywords)
: NS_OK;
}
@ -4832,7 +4830,7 @@ nsImapMailFolder::GetCurMoveCopyMessageInfo(nsIImapUrl* runningUrl,
// setup the custom imap keywords, which includes the message keywords
// plus any junk status
nsCString junkscore;
message->GetStringProperty("junkscore", getter_Copies(junkscore));
message->GetStringProperty("junkscore", junkscore);
bool isJunk = false, isNotJunk = false;
if (!junkscore.IsEmpty()) {
if (junkscore.EqualsLiteral("0"))
@ -4842,7 +4840,7 @@ nsImapMailFolder::GetCurMoveCopyMessageInfo(nsIImapUrl* runningUrl,
}
nsCString keywords; // MsgFindKeyword can't use nsACString
message->GetStringProperty("keywords", getter_Copies(keywords));
message->GetStringProperty("keywords", keywords);
int32_t start;
int32_t length;
bool hasJunk = MsgFindKeyword("junk"_ns, keywords, &start, &length);
@ -6918,7 +6916,7 @@ void nsImapMailFolder::SetPendingAttributes(
for (auto msgDBHdr : messages) {
if (!(supportedUserFlags & kImapMsgSupportUserFlag)) {
nsCString keywords;
msgDBHdr->GetStringProperty("keywords", getter_Copies(keywords));
msgDBHdr->GetStringProperty("keywords", keywords);
if (!keywords.IsEmpty())
mDatabase->SetAttributeOnPendingHdr(msgDBHdr, "keywords",
keywords.get());
@ -6936,7 +6934,7 @@ void nsImapMailFolder::SetPendingAttributes(
if (dontPreserveEx.Find(propertyEx) != kNotFound) continue;
nsCString sourceString;
msgDBHdr->GetStringProperty(property.get(), getter_Copies(sourceString));
msgDBHdr->GetStringProperty(property.get(), sourceString);
mDatabase->SetAttributeOnPendingHdr(msgDBHdr, property.get(),
sourceString.get());
}
@ -6955,7 +6953,7 @@ void nsImapMailFolder::SetPendingAttributes(
nsCString storeToken;
msgDBHdr->GetMessageOffset(&messageOffset);
msgDBHdr->GetOfflineMessageSize(&messageSize);
msgDBHdr->GetStringProperty("storeToken", getter_Copies(storeToken));
msgDBHdr->GetStringProperty("storeToken", storeToken);
if (messageSize) {
mDatabase->SetUint32AttributeOnPendingHdr(msgDBHdr, "offlineMsgSize",
messageSize);
@ -8591,7 +8589,7 @@ NS_IMETHODIMP nsImapMailFolder::FetchMsgPreviewText(
rv = GetMessageHeader(aKeysToFetch[i], getter_AddRefs(msgHdr));
NS_ENSURE_SUCCESS(rv, rv);
// ignore messages that already have a preview body.
msgHdr->GetStringProperty("preview", getter_Copies(prevBody));
msgHdr->GetStringProperty("preview", prevBody);
if (!prevBody.IsEmpty()) continue;
/* check if message is in memory cache or offline store. */
@ -8913,7 +8911,7 @@ nsresult nsImapMailFolder::GetOfflineMsgFolder(nsMsgKey msgKey,
if (isGMail) {
nsCString labels;
nsTArray<nsCString> labelNames;
hdr->GetStringProperty("X-GM-LABELS", getter_Copies(labels));
hdr->GetStringProperty("X-GM-LABELS", labels);
ParseString(labels, ' ', labelNames);
nsCOMPtr<nsIMsgFolder> rootFolder;
nsCOMPtr<nsIMsgImapMailFolder> subFolder;
@ -8958,7 +8956,7 @@ nsresult nsImapMailFolder::GetOfflineMsgFolder(nsMsgKey msgKey,
if (db) {
nsCOMPtr<nsIMsgDBHdr> retHdr;
nsCString gmMsgID;
hdr->GetStringProperty("X-GM-MSGID", getter_Copies(gmMsgID));
hdr->GetStringProperty("X-GM-MSGID", gmMsgID);
rv = db->GetMsgHdrForGMMsgID(gmMsgID.get(),
getter_AddRefs(retHdr));
if (NS_FAILED(rv)) return rv;
@ -9004,7 +9002,7 @@ nsresult nsImapMailFolder::GetOfflineFileStream(nsMsgKey msgKey,
NS_ENSURE_SUCCESS(rv, rv);
nsCString gmMsgID;
hdr->GetStringProperty("X-GM-MSGID", getter_Copies(gmMsgID));
hdr->GetStringProperty("X-GM-MSGID", gmMsgID);
nsCOMPtr<nsIMsgDatabase> db;
offlineFolder->GetMsgDatabase(getter_AddRefs(db));
rv = db->GetMsgHdrForGMMsgID(gmMsgID.get(), getter_AddRefs(hdr));

Просмотреть файл

@ -2074,8 +2074,8 @@ void nsMsgLocalMailFolder::CopyHdrPropertiesWithSkipList(
if (dontPreserveEx.Find(propertyEx) != -1) // -1 is not found
continue;
srcHdr->GetStringProperty(property.get(), getter_Copies(sourceString));
destHdr->SetStringProperty(property.get(), sourceString.get());
srcHdr->GetStringProperty(property.get(), sourceString);
destHdr->SetStringProperty(property.get(), sourceString);
}
}
@ -3411,7 +3411,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::FetchMsgPreviewText(
nsresult rv = GetMessageHeader(aKeysToFetch[i], getter_AddRefs(msgHdr));
NS_ENSURE_SUCCESS(rv, rv);
// ignore messages that already have a preview body.
msgHdr->GetStringProperty("preview", getter_Copies(prevBody));
msgHdr->GetStringProperty("preview", prevBody);
if (!prevBody.IsEmpty()) continue;
rv = GetMsgInputStream(msgHdr, getter_AddRefs(inputStream));
@ -3453,15 +3453,15 @@ NS_IMETHODIMP nsMsgLocalMailFolder::UpdateNewMsgHdr(nsIMsgDBHdr* aOldHdr,
// Preserve keywords manually, since they are set as don't preserve.
nsCString keywordString;
aOldHdr->GetStringProperty("keywords", getter_Copies(keywordString));
aNewHdr->SetStringProperty("keywords", keywordString.get());
aOldHdr->GetStringProperty("keywords", keywordString);
aNewHdr->SetStringProperty("keywords", keywordString);
// If the junk score was set by the plugin, remove junkscore to force a new
// junk analysis, this time using the body.
nsCString junkScoreOrigin;
aOldHdr->GetStringProperty("junkscoreorigin", getter_Copies(junkScoreOrigin));
aOldHdr->GetStringProperty("junkscoreorigin", junkScoreOrigin);
if (junkScoreOrigin.EqualsLiteral("plugin"))
aNewHdr->SetStringProperty("junkscore", "");
aNewHdr->SetStringProperty("junkscore", ""_ns);
return NS_OK;
}

Просмотреть файл

@ -31,6 +31,7 @@
#include "nsIMsgFolderCompactor.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "nsPrintfCString.h"
#include "nsQuarantinedOutputStream.h"
#include "mozilla/Preferences.h"
#include "mozilla/SlicedInputStream.h"
@ -631,10 +632,9 @@ nsresult nsMsgBrkMBoxStore::InternalGetNewMsgOutputStream(
}
if (*aNewMsgHdr) {
char storeToken[100];
PR_snprintf(storeToken, sizeof(storeToken), "%lld", filePos);
(*aNewMsgHdr)->SetMessageOffset(filePos);
nsCString storeToken = nsPrintfCString("%" PRId64, filePos);
(*aNewMsgHdr)->SetStringProperty("storeToken", storeToken);
(*aNewMsgHdr)->SetMessageOffset(filePos);
}
return rv;
}

Просмотреть файл

@ -90,17 +90,17 @@ nsresult nsMsgFileHdr::ReadFile() {
}
NS_IMETHODIMP nsMsgFileHdr::SetStringProperty(const char* propertyName,
const char* propertyValue) {
const nsACString& propertyValue) {
return NS_OK;
}
NS_IMETHODIMP nsMsgFileHdr::GetStringProperty(const char* propertyName,
char** _retval) {
nsACString& _retval) {
if (!strcmp(propertyName, "dummyMsgUrl")) {
*_retval = strdup(mUri.get());
_retval = mUri;
return NS_OK;
}
*_retval = strdup("");
_retval.Truncate();
return NS_OK;
}

Просмотреть файл

@ -596,7 +596,7 @@ nsMsgMaildirStore::GetNewMsgOutputStream(nsIMsgFolder* aFolder,
NS_ENSURE_SUCCESS(rv, rv);
newFile->GetNativeLeafName(newName);
// save the file name in the message header - otherwise no way to retrieve it
(*aNewMsgHdr)->SetStringProperty("storeToken", newName.get());
(*aNewMsgHdr)->SetStringProperty("storeToken", newName);
return MsgNewBufferedFileOutputStream(aResult, newFile,
PR_WRONLY | PR_CREATE_FILE, 00600);
}
@ -610,7 +610,7 @@ nsMsgMaildirStore::DiscardNewMessage(nsIOutputStream* aOutputStream,
aOutputStream->Close();
// file path is stored in message header property "storeToken"
nsAutoCString fileName;
aNewHdr->GetStringProperty("storeToken", getter_Copies(fileName));
aNewHdr->GetStringProperty("storeToken", fileName);
if (fileName.IsEmpty()) return NS_ERROR_FAILURE;
nsCOMPtr<nsIFile> path;
@ -645,7 +645,7 @@ nsMsgMaildirStore::FinishNewMessage(nsIOutputStream* aOutputStream,
// tmp filename is stored in "storeToken".
// By now we'll have the Message-ID, which we'll base the final filename on.
nsAutoCString tmpName;
aNewHdr->GetStringProperty("storeToken", getter_Copies(tmpName));
aNewHdr->GetStringProperty("storeToken", tmpName);
if (tmpName.IsEmpty()) {
NS_ERROR("FinishNewMessage - no storeToken in msg hdr!!");
return NS_ERROR_FAILURE;
@ -739,7 +739,7 @@ nsMsgMaildirStore::FinishNewMessage(nsIOutputStream* aOutputStream,
rv = fromPath->MoveToNative(curPath, toName);
NS_ENSURE_SUCCESS(rv, rv);
// Update the db to reflect the final filename.
aNewHdr->SetStringProperty("storeToken", toName.get());
aNewHdr->SetStringProperty("storeToken", toName);
return NS_OK;
}
@ -760,7 +760,7 @@ nsMsgMaildirStore::MoveNewlyDownloadedMessage(nsIMsgDBHdr* aHdr,
// file path is stored in message header property
nsAutoCString fileName;
aHdr->GetStringProperty("storeToken", getter_Copies(fileName));
aHdr->GetStringProperty("storeToken", fileName);
if (fileName.IsEmpty()) {
NS_ERROR("FinishNewMessage - no storeToken in msg hdr!!");
return NS_ERROR_FAILURE;
@ -819,7 +819,7 @@ nsMsgMaildirStore::MoveNewlyDownloadedMessage(nsIMsgDBHdr* aHdr,
rv = existingPath->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0600);
NS_ENSURE_SUCCESS(rv, rv);
existingPath->GetNativeLeafName(fileName);
newHdr->SetStringProperty("storeToken", fileName.get());
newHdr->SetStringProperty("storeToken", fileName);
}
rv = fromPath->MoveToNative(toPath, fileName);
@ -843,7 +843,7 @@ nsMsgMaildirStore::MoveNewlyDownloadedMessage(nsIMsgDBHdr* aHdr,
newHdr->GetMessageKey(&msgKey);
if (!(newFlags & nsMsgMessageFlags::Read)) {
nsCString junkScoreStr;
(void)newHdr->GetStringProperty("junkscore", getter_Copies(junkScoreStr));
(void)newHdr->GetStringProperty("junkscore", junkScoreStr);
if (atoi(junkScoreStr.get()) != nsIJunkMailPlugin::IS_SPAM_SCORE) {
newHdr->OrFlags(nsMsgMessageFlags::New, &newFlags);
destMailDB->AddToNewList(msgKey);
@ -920,7 +920,7 @@ NS_IMETHODIMP nsMsgMaildirStore::DeleteMessages(
nsresult rv = folder->GetFilePath(getter_AddRefs(path));
NS_ENSURE_SUCCESS(rv, rv);
nsAutoCString fileName;
msgHdr->GetStringProperty("storeToken", getter_Copies(fileName));
msgHdr->GetStringProperty("storeToken", fileName);
if (fileName.IsEmpty()) {
MOZ_LOG(MailDirLog, mozilla::LogLevel::Info,
@ -1021,7 +1021,7 @@ nsMsgMaildirStore::CopyMessages(bool aIsMove,
srcHdr->GetMessageKey(&srcKey);
msgTxn->AddSrcKey(srcKey);
nsAutoCString fileName;
srcHdr->GetStringProperty("storeToken", getter_Copies(fileName));
srcHdr->GetStringProperty("storeToken", fileName);
if (fileName.IsEmpty()) {
MOZ_LOG(MailDirLog, mozilla::LogLevel::Info,
("GetMsgInputStream - empty storeToken!!"));
@ -1054,7 +1054,7 @@ nsMsgMaildirStore::CopyMessages(bool aIsMove,
rv = destDB->CopyHdrFromExistingHdr(nsMsgKey_None, srcHdr, true,
getter_AddRefs(destHdr));
NS_ENSURE_SUCCESS(rv, rv);
destHdr->SetStringProperty("storeToken", fileName.get());
destHdr->SetStringProperty("storeToken", fileName);
aDstHdrs.AppendElement(destHdr);
nsMsgKey dstKey;
destHdr->GetMessageKey(&dstKey);
@ -1167,7 +1167,7 @@ nsresult MaildirStoreParser::ParseNextMessage(nsIFile* aFile) {
m_db->AddNewHdrToDB(newMsgHdr, true);
nsAutoCString storeToken;
aFile->GetNativeLeafName(storeToken);
newMsgHdr->SetStringProperty("storeToken", storeToken.get());
newMsgHdr->SetStringProperty("storeToken", storeToken);
}
NS_ENSURE_SUCCESS(rv, rv);
return rv;
@ -1275,7 +1275,7 @@ nsresult nsMsgMaildirStore::GetOutputStream(
nsIMsgDBHdr* aHdr, nsCOMPtr<nsIOutputStream>& aOutputStream) {
// file name is stored in message header property "storeToken"
nsAutoCString fileName;
aHdr->GetStringProperty("storeToken", getter_Copies(fileName));
aHdr->GetStringProperty("storeToken", fileName);
if (fileName.IsEmpty()) return NS_ERROR_FAILURE;
nsCOMPtr<nsIMsgFolder> folder;

Просмотреть файл

@ -40,6 +40,7 @@
#include "nsIMsgCopyService.h"
#include "nsICryptoHash.h"
#include "nsIStringBundle.h"
#include "nsPrintfCString.h"
#include "nsIMsgFilterCustomAction.h"
#include <ctype.h>
#include "nsIMsgPluggableStore.h"
@ -328,8 +329,7 @@ void nsMsgMailboxParser::UpdateDBFolderInfo(nsIMsgDatabase* mailDB) {
int32_t nsMsgMailboxParser::PublishMsgHeader(nsIMsgWindow* msgWindow) {
FinishHeader();
if (m_newMsgHdr) {
char storeToken[100];
PR_snprintf(storeToken, sizeof(storeToken), "%lld", m_envelope_pos);
nsCString storeToken = nsPrintfCString("%" PRIu64, m_envelope_pos);
m_newMsgHdr->SetStringProperty("storeToken", storeToken);
m_newMsgHdr->SetMessageOffset(m_envelope_pos);
@ -1250,7 +1250,8 @@ nsresult nsParseMailMessageState::FinalizeHeaders() {
// set the "replyTo" attribute on the msg hdr.
if (replyTo && (!sender || replyTo->length != sender->length ||
strncmp(replyTo->value, sender->value, sender->length)))
m_newMsgHdr->SetStringProperty("replyTo", replyTo->value);
m_newMsgHdr->SetStringProperty("replyTo",
nsDependentCString(replyTo->value));
if (sender) m_newMsgHdr->SetAuthor(sender->value);
if (recipient == &m_newsgroups) {
/* In the case where the recipient is a newsgroup, truncate the string
@ -1413,8 +1414,7 @@ nsresult nsParseMailMessageState::FinalizeHeaders() {
// When there are many keywords, some may not have been written
// to the message file, so add extra keywords from the backup
nsAutoCString oldKeywords;
m_newMsgHdr->GetStringProperty("keywords",
getter_Copies(oldKeywords));
m_newMsgHdr->GetStringProperty("keywords", oldKeywords);
nsTArray<nsCString> newKeywordArray, oldKeywordArray;
ParseString(
Substring(keywords->value, keywords->value + keywords->length),
@ -1428,16 +1428,17 @@ nsresult nsParseMailMessageState::FinalizeHeaders() {
if (i) newKeywords.Append(' ');
newKeywords.Append(newKeywordArray[i]);
}
m_newMsgHdr->SetStringProperty("keywords", newKeywords.get());
m_newMsgHdr->SetStringProperty("keywords", newKeywords);
}
for (uint32_t i = 0; i < m_customDBHeaders.Length(); i++) {
if (m_customDBHeaderValues[i].length)
m_newMsgHdr->SetStringProperty(m_customDBHeaders[i].get(),
m_customDBHeaderValues[i].value);
m_newMsgHdr->SetStringProperty(
m_customDBHeaders[i].get(),
nsDependentCString(m_customDBHeaderValues[i].value));
// The received header is accumulated separately
if (m_customDBHeaders[i].EqualsLiteral("received") &&
!m_receivedValue.IsEmpty())
m_newMsgHdr->SetStringProperty("received", m_receivedValue.get());
m_newMsgHdr->SetStringProperty("received", m_receivedValue);
}
if (content_type) {
char* substring = PL_strstr(content_type->value, "charset");
@ -1695,7 +1696,7 @@ void nsParseNewMailState::ApplyFilters(bool* pMoved, nsIMsgWindow* msgWindow) {
char* headers = m_headers.GetBuffer();
uint32_t headersSize = m_headers.GetBufferPos();
nsAutoCString tok;
msgHdr->GetStringProperty("storeToken", getter_Copies(tok));
msgHdr->GetStringProperty("storeToken", tok);
if (m_filterList) {
MOZ_LOG(FILTERLOGMODULE, LogLevel::Info,
("(Local) Running filters on 1 message (%s)", tok.get()));
@ -1938,8 +1939,8 @@ NS_IMETHODIMP nsParseNewMailState::ApplyFilterHit(nsIMsgFilter* filter,
filterAction->GetJunkScore(&junkScore);
junkScoreStr.AppendInt(junkScore);
if (junkScore == nsIJunkMailPlugin::IS_SPAM_SCORE) msgIsNew = false;
rv = msgHdr->SetStringProperty("junkscore", junkScoreStr.get());
msgHdr->SetStringProperty("junkscoreorigin", "filter");
rv = msgHdr->SetStringProperty("junkscore", junkScoreStr);
msgHdr->SetStringProperty("junkscoreorigin", "filter"_ns);
} break;
case nsMsgFilterAction::Forward: {
nsCString forwardTo;
@ -2305,7 +2306,7 @@ nsresult nsParseNewMailState::MoveIncorporatedMessage(nsIMsgDBHdr* mailHdr,
newHdr->GetMessageKey(&msgKey);
if (!(newFlags & nsMsgMessageFlags::Read)) {
nsCString junkScoreStr;
(void)newHdr->GetStringProperty("junkscore", getter_Copies(junkScoreStr));
(void)newHdr->GetStringProperty("junkscore", junkScoreStr);
if (atoi(junkScoreStr.get()) == nsIJunkMailPlugin::IS_HAM_SCORE) {
newHdr->OrFlags(nsMsgMessageFlags::New, &newFlags);
destMailDB->AddToNewList(msgKey);

Просмотреть файл

@ -404,7 +404,7 @@ MimeObjectClass* mime_find_class(const char* content_type, MimeHeaders* hdrs,
getMsgHdrForCurrentURL(opts, getter_AddRefs(msgHdr));
if (msgHdr) {
nsCString junkScoreStr;
(void)msgHdr->GetStringProperty("junkscore", getter_Copies(junkScoreStr));
(void)msgHdr->GetStringProperty("junkscore", junkScoreStr);
if (html_as == 0 && junkScoreStr.get() && atoi(junkScoreStr.get()) > 50)
html_as = 3; // 3 == Simple HTML
} // if msgHdr

Просмотреть файл

@ -503,13 +503,13 @@ nsresult nsMsgSearchOfflineMail::ProcessSearchTerm(
}
case nsMsgSearchAttrib::Keywords: {
nsCString keywords;
msgToMatch->GetStringProperty("keywords", getter_Copies(keywords));
msgToMatch->GetStringProperty("keywords", keywords);
err = aTerm->MatchKeyword(keywords, &result);
break;
}
case nsMsgSearchAttrib::JunkStatus: {
nsCString junkScoreStr;
msgToMatch->GetStringProperty("junkscore", getter_Copies(junkScoreStr));
msgToMatch->GetStringProperty("junkscore", junkScoreStr);
err = aTerm->MatchJunkStatus(junkScoreStr.get(), &result);
break;
}
@ -521,17 +521,15 @@ nsresult nsMsgSearchOfflineMail::ProcessSearchTerm(
nsresult rv;
nsCString junkScoreOriginStr;
nsCString junkPercentStr;
msgToMatch->GetStringProperty("junkscoreorigin",
getter_Copies(junkScoreOriginStr));
msgToMatch->GetStringProperty("junkpercent",
getter_Copies(junkPercentStr));
msgToMatch->GetStringProperty("junkscoreorigin", junkScoreOriginStr);
msgToMatch->GetStringProperty("junkpercent", junkPercentStr);
if (junkScoreOriginStr.EqualsLiteral("plugin") &&
!junkPercentStr.IsEmpty()) {
junkPercent = junkPercentStr.ToInteger(&rv);
NS_ENSURE_SUCCESS(rv, rv);
} else {
nsCString junkScoreStr;
msgToMatch->GetStringProperty("junkscore", getter_Copies(junkScoreStr));
msgToMatch->GetStringProperty("junkscore", junkScoreStr);
// When junk status is not set (uncertain) we'll set the value to ham.
if (junkScoreStr.IsEmpty())
junkPercent = nsIJunkMailPlugin::IS_HAM_SCORE;
@ -545,8 +543,7 @@ nsresult nsMsgSearchOfflineMail::ProcessSearchTerm(
}
case nsMsgSearchAttrib::JunkScoreOrigin: {
nsCString junkScoreOriginStr;
msgToMatch->GetStringProperty("junkscoreorigin",
getter_Copies(junkScoreOriginStr));
msgToMatch->GetStringProperty("junkscoreorigin", junkScoreOriginStr);
err = aTerm->MatchJunkScoreOrigin(junkScoreOriginStr.get(), &result);
break;
}

Просмотреть файл

@ -646,7 +646,7 @@ nsresult nsMsgSearchTerm::MatchArbitraryHeader(
bool result = !matchExpected;
nsCString dbHdrValue;
msg->GetStringProperty(m_arbitraryHeader.get(), getter_Copies(dbHdrValue));
msg->GetStringProperty(m_arbitraryHeader.get(), dbHdrValue);
if (!dbHdrValue.IsEmpty()) {
// Match value with the other info. It doesn't check all header occurrences,
// so we use it only if we match and do line by line headers parsing
@ -748,7 +748,7 @@ NS_IMETHODIMP nsMsgSearchTerm::MatchHdrProperty(nsIMsgDBHdr* aHdr,
NS_ENSURE_ARG_POINTER(aHdr);
nsCString dbHdrValue;
aHdr->GetStringProperty(m_hdrProperty.get(), getter_Copies(dbHdrValue));
aHdr->GetStringProperty(m_hdrProperty.get(), dbHdrValue);
return MatchString(dbHdrValue, nullptr, aResult);
}