diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /comm/mailnews/search/src/nsMsgSearchValue.cpp | |
parent | Initial commit. (diff) | |
download | thunderbird-upstream.tar.xz thunderbird-upstream.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'comm/mailnews/search/src/nsMsgSearchValue.cpp')
-rw-r--r-- | comm/mailnews/search/src/nsMsgSearchValue.cpp | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/comm/mailnews/search/src/nsMsgSearchValue.cpp b/comm/mailnews/search/src/nsMsgSearchValue.cpp new file mode 100644 index 0000000000..55f88b5fd2 --- /dev/null +++ b/comm/mailnews/search/src/nsMsgSearchValue.cpp @@ -0,0 +1,96 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "MailNewsTypes.h" +#include "nsMsgSearchValue.h" +#include "nsIMsgFolder.h" +#include "nsMsgUtils.h" +#include "nsString.h" + +nsMsgSearchValueImpl::nsMsgSearchValueImpl(nsMsgSearchValue* aInitialValue) { + mValue = *aInitialValue; +} + +nsMsgSearchValueImpl::~nsMsgSearchValueImpl() {} + +NS_IMPL_ISUPPORTS(nsMsgSearchValueImpl, nsIMsgSearchValue) + +NS_IMPL_GETSET(nsMsgSearchValueImpl, Priority, nsMsgPriorityValue, + mValue.u.priority) +NS_IMPL_GETSET(nsMsgSearchValueImpl, Status, uint32_t, mValue.u.msgStatus) +NS_IMPL_GETSET(nsMsgSearchValueImpl, Size, uint32_t, mValue.u.size) +NS_IMPL_GETSET(nsMsgSearchValueImpl, MsgKey, nsMsgKey, mValue.u.key) +NS_IMPL_GETSET(nsMsgSearchValueImpl, Age, int32_t, mValue.u.age) +NS_IMPL_GETSET(nsMsgSearchValueImpl, Date, PRTime, mValue.u.date) +NS_IMPL_GETSET(nsMsgSearchValueImpl, Attrib, nsMsgSearchAttribValue, + mValue.attribute) +NS_IMPL_GETSET(nsMsgSearchValueImpl, JunkStatus, uint32_t, mValue.u.junkStatus) +NS_IMPL_GETSET(nsMsgSearchValueImpl, JunkPercent, uint32_t, + mValue.u.junkPercent) + +NS_IMETHODIMP +nsMsgSearchValueImpl::GetFolder(nsIMsgFolder** aResult) { + NS_ENSURE_ARG_POINTER(aResult); + NS_ENSURE_TRUE(mValue.attribute == nsMsgSearchAttrib::FolderInfo, + NS_ERROR_ILLEGAL_VALUE); + NS_IF_ADDREF(*aResult = mValue.u.folder); + return NS_OK; +} + +NS_IMETHODIMP +nsMsgSearchValueImpl::SetFolder(nsIMsgFolder* aValue) { + NS_ENSURE_TRUE(mValue.attribute == nsMsgSearchAttrib::FolderInfo, + NS_ERROR_ILLEGAL_VALUE); + mValue.u.folder = aValue; + return NS_OK; +} + +NS_IMETHODIMP +nsMsgSearchValueImpl::GetStr(nsAString& aResult) { + NS_ENSURE_TRUE(IS_STRING_ATTRIBUTE(mValue.attribute), NS_ERROR_ILLEGAL_VALUE); + aResult = mValue.utf16String; + return NS_OK; +} + +NS_IMETHODIMP +nsMsgSearchValueImpl::SetStr(const nsAString& aValue) { + NS_ENSURE_TRUE(IS_STRING_ATTRIBUTE(mValue.attribute), NS_ERROR_ILLEGAL_VALUE); + CopyUTF16toUTF8(aValue, mValue.utf8String); + mValue.utf16String = aValue; + return NS_OK; +} + +NS_IMETHODIMP +nsMsgSearchValueImpl::ToString(nsAString& aResult) { + aResult.AssignLiteral("[nsIMsgSearchValue: "); + if (IS_STRING_ATTRIBUTE(mValue.attribute)) { + aResult.Append(mValue.utf16String); + return NS_OK; + } + + switch (mValue.attribute) { + case nsMsgSearchAttrib::Priority: + case nsMsgSearchAttrib::Date: + case nsMsgSearchAttrib::MsgStatus: + case nsMsgSearchAttrib::MessageKey: + case nsMsgSearchAttrib::Size: + case nsMsgSearchAttrib::AgeInDays: + case nsMsgSearchAttrib::FolderInfo: + case nsMsgSearchAttrib::JunkStatus: + case nsMsgSearchAttrib::JunkPercent: { + nsAutoString tempInt; + tempInt.AppendInt(mValue.attribute); + + aResult.AppendLiteral("type="); + aResult.Append(tempInt); + } break; + default: + NS_ERROR("Unknown search value type"); + } + + aResult.Append(']'); + + return NS_OK; +} |