Bug 1751784 - Re-initialize static C++ variables in nsMsgDBFolder.cpp and nsMsgDBView.cpp when locale changes. r=benc

--HG--
extra : amend_source : c280a960d023b6604b6c482047885a373a98f990
This commit is contained in:
Rachel Martin 2022-02-17 12:28:23 +02:00
Родитель 96be3cc78e
Коммит 11edc27a48
13 изменённых файлов: 192 добавлений и 155 удалений

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

@ -343,6 +343,9 @@ MailGlue.prototype = {
Cc["@mozilla.org/msgFolder/msgFolderService;1"]
.getService(Ci.nsIMsgFolderService)
.initializeFolderStrings();
Cc["@mozilla.org/msgDBView/msgDBViewService;1"]
.getService(Ci.nsIMsgDBViewService)
.initializeDBViewStrings();
this._beforeUIStartup();
break;
case "mail-startup-done":
@ -356,6 +359,15 @@ MailGlue.prototype = {
Cc["@mozilla.org/msgFolder/msgFolderService;1"]
.getService(Ci.nsIMsgFolderService)
.initializeFolderStrings();
Cc["@mozilla.org/msgDBView/msgDBViewService;1"]
.getService(Ci.nsIMsgDBViewService)
.initializeDBViewStrings();
let windows = Services.wm.getEnumerator("mail:3pane");
while (windows.hasMoreElements()) {
let win = windows.getNext();
win.document.getElementById("threadTree")?.invalidate();
}
// XXX TODO: Work required here to refresh the folder tree.
break;
case "handle-xul-text-link":
this._handleLink(aSubject, aData);

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

@ -196,6 +196,19 @@ interface nsMsgNavigationType : nsISupports
const nsMsgNavigationTypeValue toggleSubthreadKilled = 23;
};
/*
* The contract ID for this component is @mozilla.org/msgDBView/msgDBViewService;1.
*/
[scriptable, uuid(bcf6afbe-7d4f-11ec-9092-eb4fed0a5aaa)]
interface nsIMsgDBViewService : nsISupports
{
/**
* JS-callable service to initialize static variables in nsMsgDBView.cpp
* upon initialization or when locale changes.
*/
void initializeDBViewStrings();
};
[scriptable, uuid(fe8a2326-4dd0-11e5-8b8a-206a8aa7a25c)]
interface nsIMsgDBView : nsISupports
{

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

@ -34,6 +34,10 @@ typedef long nsMsgDispositionState;
[scriptable, uuid(5639c204-48ac-4115-897f-3b16821fe118)]
interface nsIMsgFolderService : nsISupports
{
/**
* JS-callable service to initialize static variables in nsMsgDBFolder.cpp
* upon initialization or when locale changes.
*/
void initializeFolderStrings();
};

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

@ -356,6 +356,18 @@
} \
}
//
// nsMsgDBViewService
//
#define NS_MSGDBVIEWSERVICE_CONTRACTID \
"@mozilla.org/msgDBView/msgDBViewService;1"
#define NS_MSGDBVIEWSERVICE_CID \
{ \
0xbcf6afbe, 0x7d4f, 0x11ec, { \
0x90, 0x92, 0xeb, 0x4f, 0xed, 0x0a, 0x5a, 0xaa \
} \
}
//
// nsMsgAccountManager
//

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

@ -13,6 +13,8 @@ MOZ_SERVICE(CopyService, nsIMsgCopyService,
"@mozilla.org/messenger/messagecopyservice;1")
MOZ_SERVICE(DBService, nsIMsgDBService,
"@mozilla.org/msgDatabase/msgDBService;1")
MOZ_SERVICE(DBViewService, nsIMsgDBViewService,
"@mozilla.org/msgDBView/msgDBViewService;1")
MOZ_SERVICE(FolderService, nsIMsgFolderService,
"@mozilla.org/msgFolder/msgFolderService;1")
MOZ_SERVICE(FilterService, nsIMsgFilterService,

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

@ -19,6 +19,7 @@
#include "nsIMsgComposeService.h"
#include "nsIMsgCopyService.h"
#include "nsIMsgDatabase.h"
#include "nsIMsgDBView.h"
#include "nsIMsgFilterService.h"
#include "nsIMsgFolderNotificationService.h"
#include "nsIMsgHeaderParser.h"

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

@ -155,6 +155,7 @@ NS_IMPL_ISUPPORTS(nsMsgFolderService, nsIMsgFolderService)
NS_IMETHODIMP nsMsgFolderService::InitializeFolderStrings() {
nsMsgDBFolder::initializeStrings();
nsMsgDBFolder::gInitializeStringsDone = true;
nsMsgDBFolder::gIsEnglishApp = -1;
return NS_OK;
}
@ -174,6 +175,10 @@ nsString nsMsgDBFolder::kLocalizedBrandShortName;
nsrefcnt nsMsgDBFolder::mInstanceCount = 0;
bool nsMsgDBFolder::gInitializeStringsDone = false;
// This is used in `nonEnglishApp()` to determine localised
// folders strings.
// -1: not retrieved yet, 1: English, 0: non-English.
int nsMsgDBFolder::gIsEnglishApp;
// We define strings for folder properties and events.
// Properties:
@ -3109,18 +3114,15 @@ NS_IMETHODIMP nsMsgDBFolder::GetPrettyName(nsAString& name) {
return GetName(name);
}
// -1: not retrieved yet, 1: English, 0: non-English.
static int isEnglish = -1;
static bool nonEnglishApp() {
if (isEnglish == -1) {
if (nsMsgDBFolder::gIsEnglishApp == -1) {
nsAutoCString locale;
mozilla::intl::LocaleService::GetInstance()->GetAppLocaleAsBCP47(locale);
isEnglish =
nsMsgDBFolder::gIsEnglishApp =
(locale.EqualsLiteral("en") || StringBeginsWith(locale, "en-"_ns)) ? 1
: 0;
}
return isEnglish ? false : true;
return nsMsgDBFolder::gIsEnglishApp ? false : true;
}
static bool hasTrashName(const nsAString& name) {

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

@ -114,6 +114,7 @@ class nsMsgDBFolder : public nsSupportsWeakReference,
nsresult GetMsgPreviewTextFromStream(nsIMsgDBHdr* msgHdr,
nsIInputStream* stream);
nsresult HandleAutoCompactEvent(nsIMsgWindow* aMsgWindow);
static int gIsEnglishApp;
protected:
virtual ~nsMsgDBFolder();

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

@ -52,23 +52,35 @@
#include "mozilla/intl/AppDateTimeFormat.h"
using namespace mozilla::mailnews;
nsrefcnt nsMsgDBView::gInstanceCount = 0;
char16_t* nsMsgDBView::kHighestPriorityString = nullptr;
char16_t* nsMsgDBView::kHighPriorityString = nullptr;
char16_t* nsMsgDBView::kLowestPriorityString = nullptr;
char16_t* nsMsgDBView::kLowPriorityString = nullptr;
char16_t* nsMsgDBView::kNormalPriorityString = nullptr;
char16_t* nsMsgDBView::kReadString = nullptr;
char16_t* nsMsgDBView::kRepliedString = nullptr;
char16_t* nsMsgDBView::kForwardedString = nullptr;
char16_t* nsMsgDBView::kRedirectedString = nullptr;
char16_t* nsMsgDBView::kNewString = nullptr;
nsString nsMsgDBView::kHighestPriorityString;
nsString nsMsgDBView::kHighPriorityString;
nsString nsMsgDBView::kLowestPriorityString;
nsString nsMsgDBView::kLowPriorityString;
nsString nsMsgDBView::kNormalPriorityString;
nsString nsMsgDBView::kReadString;
nsString nsMsgDBView::kRepliedString;
nsString nsMsgDBView::kForwardedString;
nsString nsMsgDBView::kRedirectedString;
nsString nsMsgDBView::kNewString;
nsString nsMsgDBView::kTodayString;
nsString nsMsgDBView::kYesterdayString;
nsString nsMsgDBView::kLastWeekString;
nsString nsMsgDBView::kTwoWeeksAgoString;
nsString nsMsgDBView::kOldMailString;
nsString nsMsgDBView::kFutureDateString;
bool nsMsgDBView::m_dateFormatsInitialized = false;
nsDateFormatSelectorComm nsMsgDBView::m_dateFormatDefault = kDateFormatShort;
nsDateFormatSelectorComm nsMsgDBView::m_dateFormatThisWeek = kDateFormatShort;
nsDateFormatSelectorComm nsMsgDBView::m_dateFormatToday = kDateFormatNone;
nsString nsMsgDBView::m_connectorPattern;
nsCOMPtr<nsIStringBundle> nsMsgDBView::mMessengerStringBundle;
nsString nsMsgDBView::mLabelPrefDescriptions[PREF_LABELS_MAX];
static const uint32_t kMaxNumSortColumns = 2;
static void GetCachedName(const nsCString& unparsedString,
@ -94,6 +106,19 @@ class viewSortInfo {
bool ascendingSort;
};
NS_IMPL_ISUPPORTS(nsMsgDBViewService, nsIMsgDBViewService)
NS_IMETHODIMP nsMsgDBViewService::InitializeDBViewStrings() {
nsMsgDBView::InitializeLiterals();
nsMsgDBView::InitLabelStrings();
nsMsgDBView::m_connectorPattern.Truncate();
nsMsgDBView::mMessengerStringBundle = nullptr;
// Initialize date display format.
if (!nsMsgDBView::m_dateFormatsInitialized) {
nsMsgDBView::InitDisplayFormats();
}
return NS_OK;
}
NS_IMPL_ADDREF(nsMsgDBView)
NS_IMPL_RELEASE(nsMsgDBView)
@ -142,48 +167,32 @@ nsMsgDBView::nsMsgDBView() {
mRemovingRow = false;
m_saveRestoreSelectionDepth = 0;
mRecentlyDeletedArrayIndex = 0;
// Initialize any static atoms or unicode strings.
if (gInstanceCount == 0) {
InitializeLiterals();
InitDisplayFormats();
}
InitLabelStrings();
gInstanceCount++;
}
void nsMsgDBView::InitializeLiterals() {
// Priority strings.
kHighestPriorityString = GetString(u"priorityHighest");
kHighPriorityString = GetString(u"priorityHigh");
kLowestPriorityString = GetString(u"priorityLowest");
kLowPriorityString = GetString(u"priorityLow");
kNormalPriorityString = GetString(u"priorityNormal");
GetString(u"priorityHighest", kHighestPriorityString);
GetString(u"priorityHigh", kHighPriorityString);
GetString(u"priorityLowest", kLowestPriorityString);
GetString(u"priorityLow", kLowPriorityString);
GetString(u"priorityNormal", kNormalPriorityString);
kReadString = GetString(u"read");
kRepliedString = GetString(u"replied");
kForwardedString = GetString(u"forwarded");
kRedirectedString = GetString(u"redirected");
kNewString = GetString(u"new");
GetString(u"read", kReadString);
GetString(u"replied", kRepliedString);
GetString(u"forwarded", kForwardedString);
GetString(u"redirected", kRedirectedString);
GetString(u"new", kNewString);
GetString(u"today", kTodayString);
GetString(u"yesterday", kYesterdayString);
GetString(u"last7Days", kLastWeekString);
GetString(u"last14Days", kTwoWeeksAgoString);
GetString(u"older", kOldMailString);
GetString(u"futureDate", kFutureDateString);
}
nsMsgDBView::~nsMsgDBView() {
if (m_db) m_db->RemoveListener(this);
gInstanceCount--;
if (gInstanceCount <= 0) {
free(kHighestPriorityString);
free(kHighPriorityString);
free(kLowestPriorityString);
free(kLowPriorityString);
free(kNormalPriorityString);
free(kReadString);
free(kRepliedString);
free(kForwardedString);
free(kRedirectedString);
free(kNewString);
}
}
nsresult nsMsgDBView::InitLabelStrings() {
@ -193,34 +202,33 @@ nsresult nsMsgDBView::InitLabelStrings() {
for (int32_t i = 0; i < PREF_LABELS_MAX; i++) {
prefString.Assign(PREF_LABELS_DESCRIPTION);
prefString.AppendInt(i + 1);
rv = GetPrefLocalizedString(prefString.get(), mLabelPrefDescriptions[i]);
rv = GetPrefLocalizedString(prefString.get(),
nsMsgDBView::mLabelPrefDescriptions[i]);
}
return rv;
}
// Helper function used to fetch strings from the messenger string bundle
char16_t* nsMsgDBView::GetString(const char16_t* aStringName) {
void nsMsgDBView::GetString(const char16_t* aStringName, nsAString& aValue) {
nsresult res = NS_ERROR_UNEXPECTED;
nsAutoString str;
if (!mMessengerStringBundle) {
if (!nsMsgDBView::mMessengerStringBundle) {
static const char propertyURL[] = MESSENGER_STRING_URL;
nsCOMPtr<nsIStringBundleService> sBundleService =
mozilla::services::GetStringBundleService();
if (sBundleService)
res = sBundleService->CreateBundle(
propertyURL, getter_AddRefs(mMessengerStringBundle));
propertyURL, getter_AddRefs(nsMsgDBView::mMessengerStringBundle));
}
if (mMessengerStringBundle)
if (nsMsgDBView::mMessengerStringBundle)
res = mMessengerStringBundle->GetStringFromName(
NS_ConvertUTF16toUTF8(aStringName).get(), str);
NS_ConvertUTF16toUTF8(aStringName).get(), aValue);
if (NS_SUCCEEDED(res))
return ToNewUnicode(str);
else
return NS_xstrdup(aStringName);
if (NS_FAILED(res)) {
aValue = aStringName;
}
}
// Helper function used to fetch localized strings from the prefs
@ -391,7 +399,9 @@ nsresult nsMsgDBView::FetchAuthor(nsIMsgDBHdr* aHdr, nsAString& aSenderString) {
if (multipleAuthors) {
aSenderString.AppendLiteral(" ");
aSenderString.Append(GetString(u"andOthers"));
nsAutoString val;
GetString(u"andOthers", val);
aSenderString.Append(val);
}
UpdateCachedName(aHdr, "sender_name", aSenderString);
@ -629,12 +639,7 @@ nsresult nsMsgDBView::FetchDate(nsIMsgDBHdr* aHdr, nsAString& aDateString,
components, &explodedMsgTime, weekdayString);
NS_ENSURE_SUCCESS(rv, rv);
// Note that this `static` value will need revisiting once M-C
// can switch locales without a restart of the application.
// For now, it's a cheap cache to avoid getting locale and
// connector pattern all the time.
static nsString connectorPattern;
if (connectorPattern.IsEmpty()) {
if (nsMsgDBView::m_connectorPattern.IsEmpty()) {
nsAutoCString locale;
AutoTArray<nsCString, 10> regionalPrefsLocales;
mozilla::intl::LocaleService::GetInstance()->GetRegionalPrefsLocales(
@ -643,10 +648,10 @@ nsresult nsMsgDBView::FetchDate(nsIMsgDBHdr* aHdr, nsAString& aDateString,
nsAutoCString str;
mozilla::intl::OSPreferences::GetInstance()
->GetDateTimeConnectorPattern(locale, str);
connectorPattern = NS_ConvertUTF8toUTF16(str);
nsMsgDBView::m_connectorPattern = NS_ConvertUTF8toUTF16(str);
}
nsAutoString pattern(connectorPattern);
nsAutoString pattern(nsMsgDBView::m_connectorPattern);
int32_t ind = pattern.Find(u"{1}"_ns);
if (ind != kNotFound) {
pattern.Replace(ind, 3, weekdayString);
@ -860,7 +865,7 @@ nsresult nsMsgDBView::FetchLabel(nsIMsgDBHdr* aHdr, nsAString& aLabelString) {
}
// We need to subtract 1 because mLabelPrefDescriptions is 0 based.
aLabelString = mLabelPrefDescriptions[label - 1];
aLabelString = nsMsgDBView::mLabelPrefDescriptions[label - 1];
return NS_OK;
}
@ -1691,17 +1696,13 @@ nsMsgDBView::GetCellValue(int32_t aRow, nsTreeColumn* aCol, nsAString& aValue) {
case 'a':
if (colID.EqualsLiteral("attachmentCol") &&
flags & nsMsgMessageFlags::Attachment) {
nsString tmp_str;
tmp_str.Adopt(GetString(u"messageHasAttachment"));
aValue.Assign(tmp_str);
GetString(u"messageHasAttachment", aValue);
}
break;
case 'f':
if (colID.EqualsLiteral("flaggedCol") &&
flags & nsMsgMessageFlags::Marked) {
nsString tmp_str;
tmp_str.Adopt(GetString(u"messageHasFlag"));
aValue.Assign(tmp_str);
GetString(u"messageHasFlag", aValue);
}
break;
case 'j':
@ -1727,11 +1728,10 @@ nsMsgDBView::GetCellValue(int32_t aRow, nsTreeColumn* aCol, nsAString& aValue) {
if (isContainer) {
IsContainerEmpty(aRow, &isContainerEmpty);
if (!isContainerEmpty) {
nsString tmp_str;
IsContainerOpen(aRow, &isContainerOpen);
tmp_str.Adopt(GetString(isContainerOpen ? u"messageExpanded"
: u"messageCollapsed"));
aValue.Assign(tmp_str);
GetString(
isContainerOpen ? u"messageExpanded" : u"messageCollapsed",
aValue);
}
}
}
@ -1739,9 +1739,7 @@ nsMsgDBView::GetCellValue(int32_t aRow, nsTreeColumn* aCol, nsAString& aValue) {
case 'u':
if (colID.EqualsLiteral("unreadButtonColHeader") &&
!(flags & nsMsgMessageFlags::Read)) {
nsString tmp_str;
tmp_str.Adopt(GetString(u"messageUnread"));
aValue.Assign(tmp_str);
GetString(u"messageUnread", aValue);
}
break;
default:
@ -3114,11 +3112,11 @@ nsresult nsMsgDBView::DeleteMessages(nsIMsgWindow* window,
nsString confirmString;
nsString checkboxText;
nsString buttonApplyNowText;
dialogTitle.Adopt(GetString(u"confirmMsgDelete.title"));
checkboxText.Adopt(GetString(u"confirmMsgDelete.dontAsk.label"));
buttonApplyNowText.Adopt(GetString(u"confirmMsgDelete.delete.label"));
GetString(u"confirmMsgDelete.title", dialogTitle);
GetString(u"confirmMsgDelete.dontAsk.label", checkboxText);
GetString(u"confirmMsgDelete.delete.label", buttonApplyNowText);
confirmString.Adopt(GetString(warningName.get()));
GetString(warningName.get(), confirmString);
const uint32_t buttonFlags =
(nsIPrompt::BUTTON_TITLE_IS_STRING * nsIPrompt::BUTTON_POS_0) +
@ -7438,9 +7436,7 @@ static void getDateFormatPref(nsIPrefBranch *_prefBranch,
}
nsresult nsMsgDBView::InitDisplayFormats() {
m_dateFormatDefault = kDateFormatShort;
m_dateFormatThisWeek = kDateFormatShort;
m_dateFormatToday = kDateFormatNone;
m_dateFormatsInitialized = true;
nsresult rv = NS_OK;
nsCOMPtr<nsIPrefService> prefs =

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

@ -85,6 +85,17 @@ struct IdKey : public IdUint32 {
nsTArray<uint8_t> key;
};
class nsMsgDBViewService final : public nsIMsgDBViewService {
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIMSGDBVIEWSERVICE
nsMsgDBViewService(){};
protected:
~nsMsgDBViewService(){};
};
// This is an abstract implementation class.
// The actual view objects will be instances of sub-classes of this class.
class nsMsgDBView : public nsIMsgDBView,
@ -92,6 +103,7 @@ class nsMsgDBView : public nsIMsgDBView,
public nsITreeView,
public nsIJunkMailClassificationListener {
public:
friend class nsMsgDBViewService;
nsMsgDBView();
NS_DECL_ISUPPORTS
@ -112,19 +124,25 @@ class nsMsgDBView : public nsIMsgDBView,
protected:
virtual ~nsMsgDBView();
static nsrefcnt gInstanceCount;
static nsString kHighestPriorityString;
static nsString kHighPriorityString;
static nsString kLowestPriorityString;
static nsString kLowPriorityString;
static nsString kNormalPriorityString;
static char16_t* kHighestPriorityString;
static char16_t* kHighPriorityString;
static char16_t* kLowestPriorityString;
static char16_t* kLowPriorityString;
static char16_t* kNormalPriorityString;
static nsString kReadString;
static nsString kRepliedString;
static nsString kForwardedString;
static nsString kRedirectedString;
static nsString kNewString;
static char16_t* kReadString;
static char16_t* kRepliedString;
static char16_t* kForwardedString;
static char16_t* kRedirectedString;
static char16_t* kNewString;
// Used for group views.
static nsString kTodayString;
static nsString kYesterdayString;
static nsString kLastWeekString;
static nsString kTwoWeeksAgoString;
static nsString kOldMailString;
static nsString kFutureDateString;
RefPtr<mozilla::dom::XULTreeElement> mTree;
nsCOMPtr<nsIMsgJSTree> mJSTree;
@ -392,16 +410,17 @@ class nsMsgDBView : public nsIMsgDBView,
bool* resultToggleState);
bool OfflineMsgSelected(nsTArray<nsMsgViewIndex> const& selection);
bool NonDummyMsgSelected(nsTArray<nsMsgViewIndex> const& selection);
char16_t* GetString(const char16_t* aStringName);
nsresult GetPrefLocalizedString(const char* aPrefName, nsString& aResult);
static void GetString(const char16_t* aStringName, nsAString& aValue);
static nsresult GetPrefLocalizedString(const char* aPrefName,
nsString& aResult);
nsresult AppendKeywordProperties(const nsACString& keywords,
nsAString& properties, bool* tagAdded);
nsresult InitLabelStrings(void);
static nsresult InitLabelStrings(void);
nsresult CopyDBView(nsMsgDBView* aNewMsgDBView,
nsIMessenger* aMessengerInstance,
nsIMsgWindow* aMsgWindow,
nsIMsgDBViewCommandUpdater* aCmdUpdater);
void InitializeLiterals();
static void InitializeLiterals();
virtual int32_t FindLevelInThread(nsIMsgDBHdr* msgHdr,
nsMsgViewIndex startOfThread,
nsMsgViewIndex viewIndex);
@ -474,10 +493,10 @@ class nsMsgDBView : public nsIMsgDBView,
nsWeakPtr mMsgWindowWeak;
// We push command update notifications to the UI from this.
nsCOMPtr<nsIMsgDBViewCommandUpdater> mCommandUpdater;
nsCOMPtr<nsIStringBundle> mMessengerStringBundle;
static nsCOMPtr<nsIStringBundle> mMessengerStringBundle;
// Used for the preference labels.
nsString mLabelPrefDescriptions[PREF_LABELS_MAX];
static nsString mLabelPrefDescriptions[PREF_LABELS_MAX];
nsString mLabelPrefColors[PREF_LABELS_MAX];
// Used to determine when to start and end junk plugin batches.
@ -521,9 +540,12 @@ class nsMsgDBView : public nsIMsgDBView,
static nsresult InitDisplayFormats();
private:
static bool m_dateFormatsInitialized;
static nsDateFormatSelectorComm m_dateFormatDefault;
static nsDateFormatSelectorComm m_dateFormatThisWeek;
static nsDateFormatSelectorComm m_dateFormatToday;
static nsString m_connectorPattern;
bool ServerSupportsFilterAfterTheFact();
nsresult PerformActionsOnJunkMsgs(bool msgsAreJunk);

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

@ -759,7 +759,6 @@ nsMsgGroupView::CellTextForColumn(int32_t aRow, const nsAString& aColumnName,
bool rcvDate = false;
msgHdr->GetFlags(&flags);
aValue.Truncate();
nsString tmp_str;
switch (m_sortType) {
case nsMsgViewSortType::byReceived:
rcvDate = true;
@ -769,41 +768,23 @@ nsMsgGroupView::CellTextForColumn(int32_t aRow, const nsAString& aColumnName,
GetAgeBucketValue(msgHdr, &ageBucket, rcvDate);
switch (ageBucket) {
case 1:
if (m_kTodayString.IsEmpty())
m_kTodayString.Adopt(GetString(u"today"));
aValue.Assign(m_kTodayString);
aValue.Assign(nsMsgDBView::kTodayString);
break;
case 2:
if (m_kYesterdayString.IsEmpty())
m_kYesterdayString.Adopt(GetString(u"yesterday"));
aValue.Assign(m_kYesterdayString);
aValue.Assign(nsMsgDBView::kYesterdayString);
break;
case 3:
if (m_kLastWeekString.IsEmpty())
m_kLastWeekString.Adopt(GetString(u"last7Days"));
aValue.Assign(m_kLastWeekString);
aValue.Assign(nsMsgDBView::kLastWeekString);
break;
case 4:
if (m_kTwoWeeksAgoString.IsEmpty())
m_kTwoWeeksAgoString.Adopt(GetString(u"last14Days"));
aValue.Assign(m_kTwoWeeksAgoString);
aValue.Assign(nsMsgDBView::kTwoWeeksAgoString);
break;
case 5:
if (m_kOldMailString.IsEmpty())
m_kOldMailString.Adopt(GetString(u"older"));
aValue.Assign(m_kOldMailString);
aValue.Assign(nsMsgDBView::kOldMailString);
break;
default:
// Future date, error/spoofed.
if (m_kFutureDateString.IsEmpty())
m_kFutureDateString.Adopt(GetString(u"futureDate"));
aValue.Assign(m_kFutureDateString);
aValue.Assign(nsMsgDBView::kFutureDateString);
break;
}
break;
@ -817,22 +798,19 @@ nsMsgGroupView::CellTextForColumn(int32_t aRow, const nsAString& aColumnName,
case nsMsgViewSortType::byStatus:
rv = FetchStatus(m_flags[aRow], aValue);
if (aValue.IsEmpty()) {
tmp_str.Adopt(GetString(u"messagesWithNoStatus"));
aValue.Assign(tmp_str);
GetString(u"messagesWithNoStatus", aValue);
}
break;
case nsMsgViewSortType::byTags:
rv = FetchTags(msgHdr, aValue);
if (aValue.IsEmpty()) {
tmp_str.Adopt(GetString(u"untaggedMessages"));
aValue.Assign(tmp_str);
GetString(u"untaggedMessages", aValue);
}
break;
case nsMsgViewSortType::byPriority:
FetchPriority(msgHdr, aValue);
if (aValue.IsEmpty()) {
tmp_str.Adopt(GetString(u"noPriority"));
aValue.Assign(tmp_str);
GetString(u"noPriority", aValue);
}
break;
case nsMsgViewSortType::byAccount:
@ -842,16 +820,14 @@ nsMsgGroupView::CellTextForColumn(int32_t aRow, const nsAString& aColumnName,
FetchRecipients(msgHdr, aValue);
break;
case nsMsgViewSortType::byAttachments:
tmp_str.Adopt(GetString(flags & nsMsgMessageFlags::Attachment
? u"attachments"
: u"noAttachments"));
aValue.Assign(tmp_str);
GetString(flags & nsMsgMessageFlags::Attachment ? u"attachments"
: u"noAttachments",
aValue);
break;
case nsMsgViewSortType::byFlagged:
tmp_str.Adopt(GetString(flags & nsMsgMessageFlags::Marked
? u"groupFlagged"
: u"notFlagged"));
aValue.Assign(tmp_str);
GetString(
flags & nsMsgMessageFlags::Marked ? u"groupFlagged" : u"notFlagged",
aValue);
break;
// byLocation is a special case; we don't want to have duplicate
// all this logic in nsMsgSearchDBView, and its hash key is what we

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

@ -74,14 +74,6 @@ class nsMsgGroupView : public nsMsgDBView {
nsInterfaceHashtable<nsStringHashKey, nsIMsgThread> m_groupsTable;
PRExplodedTime m_lastCurExplodedTime{0};
bool m_dayChanged;
private:
nsString m_kTodayString;
nsString m_kYesterdayString;
nsString m_kLastWeekString;
nsString m_kTwoWeeksAgoString;
nsString m_kOldMailString;
nsString m_kFutureDateString;
};
#endif

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

@ -297,6 +297,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgSearchDBView)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgXFVirtualFolderDBView)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgQuickSearchDBView)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgGroupView)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgDBViewService)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgOfflineManager)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgProgress)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSpamSettings)
@ -339,6 +340,7 @@ NS_DEFINE_NAMED_CID(NS_MSGSEARCHDBVIEW_CID);
NS_DEFINE_NAMED_CID(NS_MSGQUICKSEARCHDBVIEW_CID);
NS_DEFINE_NAMED_CID(NS_MSG_XFVFDBVIEW_CID);
NS_DEFINE_NAMED_CID(NS_MSG_GROUPDBVIEW_CID);
NS_DEFINE_NAMED_CID(NS_MSGDBVIEWSERVICE_CID);
NS_DEFINE_NAMED_CID(NS_MSGOFFLINEMANAGER_CID);
NS_DEFINE_NAMED_CID(NS_MSGPROGRESS_CID);
NS_DEFINE_NAMED_CID(NS_SPAMSETTINGS_CID);
@ -691,6 +693,7 @@ const mozilla::Module::CIDEntry kMailNewsCIDs[] = {
{&kNS_MSG_XFVFDBVIEW_CID, false, NULL,
nsMsgXFVirtualFolderDBViewConstructor},
{&kNS_MSG_GROUPDBVIEW_CID, false, NULL, nsMsgGroupViewConstructor},
{&kNS_MSGDBVIEWSERVICE_CID, false, NULL, nsMsgDBViewServiceConstructor},
{&kNS_MSGOFFLINEMANAGER_CID, false, NULL, nsMsgOfflineManagerConstructor},
{&kNS_MSGPROGRESS_CID, false, NULL, nsMsgProgressConstructor},
{&kNS_SPAMSETTINGS_CID, false, NULL, nsSpamSettingsConstructor},
@ -879,6 +882,7 @@ const mozilla::Module::ContractIDEntry kMailNewsContracts[] = {
{NS_MSGQUICKSEARCHDBVIEW_CONTRACTID, &kNS_MSGQUICKSEARCHDBVIEW_CID},
{NS_MSGXFVFDBVIEW_CONTRACTID, &kNS_MSG_XFVFDBVIEW_CID},
{NS_MSGGROUPDBVIEW_CONTRACTID, &kNS_MSG_GROUPDBVIEW_CID},
{NS_MSGDBVIEWSERVICE_CONTRACTID, &kNS_MSGDBVIEWSERVICE_CID},
{NS_MSGOFFLINEMANAGER_CONTRACTID, &kNS_MSGOFFLINEMANAGER_CID},
{NS_MSGPROGRESS_CONTRACTID, &kNS_MSGPROGRESS_CID},
{NS_SPAMSETTINGS_CONTRACTID, &kNS_SPAMSETTINGS_CID},