Bug 1904799 - Change nsIDBFolderInfo.GetTransferInfo to return nsIPropertyBag2. r=BenC

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

--HG--
extra : rebase_source : 8ed30c2ed8d4bcd5a98502544273bdece7c9bf75
extra : amend_source : 13338d4678de37016021fa607e55fddd50bc3c9f
This commit is contained in:
Geoff Lankow 2024-06-26 22:06:35 +12:00
Родитель 9b6a5853ab
Коммит b64424c640
6 изменённых файлов: 39 добавлений и 36 удалений

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

@ -22,6 +22,7 @@ interface nsIFile;
interface nsIMsgIdentity;
interface nsIMsgThread;
interface nsIMsgPluggableStore;
interface nsIPropertyBag2;
typedef long nsMsgBiffState;
@ -690,7 +691,7 @@ interface nsIMsgFolder : nsISupports {
*/
attribute long sortOrder;
attribute nsIDBFolderInfo dBTransferInfo;
attribute nsIPropertyBag2 dBTransferInfo;
/**
* Set a string property on the folder.

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

@ -64,6 +64,7 @@
#include "mozilla/Utf8.h"
#include "nsIPromptService.h"
#include "nsEmbedCID.h"
#include "nsIPropertyBag2.h"
#define oneHour 3600000000U
@ -1837,7 +1838,7 @@ nsMsgDBFolder::MatchOrChangeFilterDestination(nsIMsgFolder* newFolder,
}
NS_IMETHODIMP
nsMsgDBFolder::GetDBTransferInfo(nsIDBFolderInfo** aTransferInfo) {
nsMsgDBFolder::GetDBTransferInfo(nsIPropertyBag2** aTransferInfo) {
nsCOMPtr<nsIDBFolderInfo> dbFolderInfo;
nsCOMPtr<nsIMsgDatabase> db;
GetDBFolderInfoAndDB(getter_AddRefs(dbFolderInfo), getter_AddRefs(db));
@ -1846,7 +1847,7 @@ nsMsgDBFolder::GetDBTransferInfo(nsIDBFolderInfo** aTransferInfo) {
}
NS_IMETHODIMP
nsMsgDBFolder::SetDBTransferInfo(nsIDBFolderInfo* aTransferInfo) {
nsMsgDBFolder::SetDBTransferInfo(nsIPropertyBag2* aTransferInfo) {
NS_ENSURE_ARG(aTransferInfo);
nsCOMPtr<nsIDBFolderInfo> dbFolderInfo;
nsCOMPtr<nsIMsgDatabase> db;

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

@ -6,6 +6,8 @@
#include "nsISupports.idl"
#include "MailNewsTypes2.idl"
interface nsIPropertyBag2;
[scriptable, uuid(a72dab4b-b3bd-471e-9a38-1b242b385459)]
interface nsIDBFolderInfo : nsISupports {
attribute long flags;
@ -79,8 +81,8 @@ interface nsIDBFolderInfo : nsISupports {
long long getInt64Property(in string propertyName, in long long defaultValue);
boolean getBooleanProperty(in string propertyName, in boolean defaultValue);
void setBooleanProperty(in string propertyName, in boolean aPropertyValue);
nsIDBFolderInfo GetTransferInfo();
void initFromTransferInfo(in nsIDBFolderInfo transferInfo);
nsIPropertyBag2 GetTransferInfo();
void initFromTransferInfo(in nsIPropertyBag2 transferInfo);
attribute AString locale;
attribute AString mailboxName;

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

@ -9,6 +9,10 @@
#include "nsMsgFolderFlags.h"
#include "nsIMsgDBView.h"
#include "nsImapCore.h"
#include "nsIWritablePropertyBag2.h"
#include "mozilla/SimpleEnumerator.h"
#include "nsIProperty.h"
#include "nsIVariant.h"
static const char* kDBFolderInfoScope = "ns:msg:db:row:scope:dbfolderinfo:all";
static const char* kDBFolderInfoTableKind = "ns:msg:db:table:kind:dbfolderinfo";
@ -669,25 +673,12 @@ NS_IMETHODIMP nsDBFolderInfo::SetFolderName(const nsACString& folderName) {
return SetCharProperty("folderName", folderName);
}
class nsTransferDBFolderInfo : public nsDBFolderInfo {
public:
nsTransferDBFolderInfo();
virtual ~nsTransferDBFolderInfo();
// parallel arrays of properties and values
nsTArray<nsCString> m_properties;
nsTArray<nsCString> m_values;
};
nsTransferDBFolderInfo::nsTransferDBFolderInfo() : nsDBFolderInfo(nullptr) {}
nsTransferDBFolderInfo::~nsTransferDBFolderInfo() {}
/* void GetTransferInfo (out nsIDBFolderInfo transferInfo); */
NS_IMETHODIMP nsDBFolderInfo::GetTransferInfo(nsIDBFolderInfo** transferInfo) {
NS_IMETHODIMP nsDBFolderInfo::GetTransferInfo(nsIPropertyBag2** transferInfo) {
NS_ENSURE_ARG_POINTER(transferInfo);
NS_ENSURE_STATE(m_mdbRow);
RefPtr<nsTransferDBFolderInfo> newInfo = new nsTransferDBFolderInfo;
nsCOMPtr<nsIWritablePropertyBag2> newInfo =
do_CreateInstance("@mozilla.org/hash-property-bag;1");
mdb_count numCells;
mdbYarn cellYarn;
@ -706,12 +697,13 @@ NS_IMETHODIMP nsDBFolderInfo::GetTransferInfo(nsIDBFolderInfo** transferInfo) {
if (NS_SUCCEEDED(err)) {
m_mdb->GetStore()->TokenToString(m_mdb->GetEnv(), cellColumn,
&cellName);
newInfo->m_values.AppendElement(
Substring((const char*)cellYarn.mYarn_Buf,
(const char*)cellYarn.mYarn_Buf + cellYarn.mYarn_Fill));
newInfo->m_properties.AppendElement(
nsAutoCString name(
Substring((const char*)cellName.mYarn_Buf,
(const char*)cellName.mYarn_Buf + cellName.mYarn_Fill));
nsAutoCString value(
Substring((const char*)cellYarn.mYarn_Buf,
(const char*)cellYarn.mYarn_Buf + cellYarn.mYarn_Fill));
newInfo->SetPropertyAsACString(NS_ConvertUTF8toUTF16(name), value);
}
}
}
@ -720,17 +712,24 @@ NS_IMETHODIMP nsDBFolderInfo::GetTransferInfo(nsIDBFolderInfo** transferInfo) {
return NS_OK;
}
/* void InitFromTransferInfo (in nsIDBFolderInfo transferInfo); */
NS_IMETHODIMP nsDBFolderInfo::InitFromTransferInfo(
nsIDBFolderInfo* aTransferInfo) {
nsIPropertyBag2* aTransferInfo) {
NS_ENSURE_ARG(aTransferInfo);
nsTransferDBFolderInfo* transferInfo =
static_cast<nsTransferDBFolderInfo*>(aTransferInfo);
nsCOMPtr<nsISimpleEnumerator> enumerator;
aTransferInfo->GetEnumerator(getter_AddRefs(enumerator));
for (uint32_t i = 0; i < transferInfo->m_values.Length(); i++)
SetCharProperty(transferInfo->m_properties[i].get(),
transferInfo->m_values[i]);
for (const auto& property :
mozilla::SimpleEnumerator<nsIProperty>(enumerator)) {
nsAutoString name;
property->GetName(name);
nsCOMPtr<nsIVariant> variant;
property->GetValue(getter_AddRefs(variant));
nsAutoCString value;
variant->GetAsACString(value);
SetCharProperty(NS_ConvertUTF16toUTF8(name).get(), value);
}
LoadMemberVariables();
return NS_OK;

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

@ -1484,7 +1484,7 @@ NS_IMETHODIMP nsImapMailFolder::EmptyTrash(nsIUrlListener* aListener) {
NS_ENSURE_SUCCESS(rv, rv);
}
nsCOMPtr<nsIDBFolderInfo> transferInfo;
nsCOMPtr<nsIPropertyBag2> transferInfo;
rv = trashFolder->GetDBTransferInfo(getter_AddRefs(transferInfo));
NS_ENSURE_SUCCESS(rv, rv);
// Bulk-delete all the messages by deleting the msf file and storage.
@ -2497,7 +2497,7 @@ NS_IMETHODIMP nsImapMailFolder::UpdateImapMailboxInfo(
do_GetService("@mozilla.org/msgDatabase/msgDBService;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDBFolderInfo> transferInfo;
nsCOMPtr<nsIPropertyBag2> transferInfo;
if (dbFolderInfo)
dbFolderInfo->GetTransferInfo(getter_AddRefs(transferInfo));

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

@ -367,7 +367,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::GetDatabaseWithReparse(
msgDBService->OpenFolderDB(this, true, getter_AddRefs(mDatabase));
if (folderOpen == NS_MSG_ERROR_FOLDER_SUMMARY_OUT_OF_DATE) {
nsCOMPtr<nsIDBFolderInfo> dbFolderInfo;
nsCOMPtr<nsIDBFolderInfo> transferInfo;
nsCOMPtr<nsIPropertyBag2> transferInfo;
if (mDatabase) {
mDatabase->GetDBFolderInfo(getter_AddRefs(dbFolderInfo));
if (dbFolderInfo) {
@ -633,7 +633,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::EmptyTrash(nsIUrlListener* aListener) {
nsCOMPtr<nsIMsgFolder> parentFolder;
rv = trashFolder->GetParent(getter_AddRefs(parentFolder));
if (NS_SUCCEEDED(rv) && parentFolder) {
nsCOMPtr<nsIDBFolderInfo> transferInfo;
nsCOMPtr<nsIPropertyBag2> transferInfo;
trashFolder->GetDBTransferInfo(getter_AddRefs(transferInfo));
trashFolder->SetParent(nullptr);
parentFolder->PropagateDelete(trashFolder, true);