21#include <tools/datetime.hxx>
24#include <rtl/character.hxx>
31void INetMIMEMessage::SetHeaderField_Impl (
33 const OUString &rValue,
54 "Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
55 "Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
58static sal_uInt16
ParseNumber(std::string_view rStr,
size_t& nIndex)
61 while ((
n < rStr.size())
62 && rtl::isAsciiDigit(
static_cast<unsigned char>(rStr[
n])))
71static sal_uInt16
ParseMonth(std::string_view rStr,
size_t& nIndex)
74 while ((
n < rStr.size())
75 && rtl::isAsciiAlpha(
static_cast<unsigned char>(rStr[
n])))
78 std::string_view aMonth(rStr.substr(
nIndex, 3));
82 for (
i = 0;
i < 12;
i++)
87bool INetMIMEMessage::ParseDateField (
88 std::u16string_view rDateFieldW,
DateTime& rDateTime)
91 RTL_TEXTENCODING_ASCII_US));
93 if (aDateField.isEmpty())
return false;
95 if (aDateField.indexOf(
':') != -1)
102 (aDateField[nIndex] ==
' '))
107 (rtl::isAsciiAlpha (
static_cast<unsigned char>(aDateField[nIndex])) ||
108 (aDateField[nIndex] ==
',') ))
112 (aDateField[nIndex] ==
' '))
115 if (rtl::isAsciiAlpha (
static_cast<unsigned char>(aDateField[nIndex])))
118 if ((aDateField.getLength() - nIndex) < 20)
return false;
128 sal_uInt16 nYear =
ParseNumber (aDateField, nIndex);
129 if (nYear < 100) nYear += 1900;
135 if ((aDateField.getLength() - nIndex) < 17)
return false;
141 if (nYear < 100) nYear += 1900;
150 if (cPossiblePlusMinus ==
'+' || cPossiblePlusMinus ==
'-')
153 bool bEast = (aDateField[
nIndex++] ==
'+');
154 sal_uInt16 nOffset =
ParseNumber (aDateField, nIndex);
158 aDiff.SetHour (nOffset / 100);
159 aDiff.SetMin (nOffset % 100);
161 aDiff.SetNanoSec (0);
175 aDelta.SetTime (aDateField.toInt32() * 100);
181 rDateTime.
SetDate (aNow.GetDate());
182 rDateTime.
SetTime (aNow.GetTime());
191 !((rDateTime.
GetSec() > 59) ||
192 (rDateTime.
GetMin() > 59) ||
204INetMIMEMessage::INetMIMEMessage()
211INetMIMEMessage::~INetMIMEMessage()
215void INetMIMEMessage::SetMIMEVersion (
const OUString& rVersion)
217 SetHeaderField_Impl (
222void INetMIMEMessage::SetContentDisposition (
const OUString& rDisposition)
224 SetHeaderField_Impl (
229void INetMIMEMessage::SetContentType (
const OUString& rType)
231 SetHeaderField_Impl (
236void INetMIMEMessage::SetContentTransferEncoding (
237 const OUString& rEncoding)
239 SetHeaderField_Impl (
244OUString INetMIMEMessage::GetDefaultContentType()
246 if (pParent !=
nullptr)
248 OUString aParentCT (pParent->GetContentType());
249 if (aParentCT.isEmpty())
250 aParentCT = pParent->GetDefaultContentType();
252 if (aParentCT.equalsIgnoreAsciiCase(
"multipart/digest"))
253 return "message/rfc822";
255 return "text/plain; charset=us-ascii";
258void INetMIMEMessage::EnableAttachMultipartFormDataChild()
267 sal_uInt64 nThis =
reinterpret_cast< sal_uIntPtr
>( this );
270 static_cast< unsigned int >(aCurTime.GetTime()),
271 static_cast< unsigned int >(nThis));
272 m_aBoundary =
"------------_4D48";
273 m_aBoundary += sTail;
276 SetMIMEVersion(
"1.0");
278 "multipart/form-data; boundary=" + OUString::fromUtf8(m_aBoundary));
279 SetContentTransferEncoding(
"7bit");
282void INetMIMEMessage::AttachChild(std::unique_ptr<INetMIMEMessage> pChildMsg)
284 assert(IsContainer());
287 pChildMsg->pParent =
this;
288 aChildren.push_back( std::move(pChildMsg) );
void SetDate(sal_Int32 nNewDate)
bool IsValidAndGregorian() const
If the represented date is valid (1<=month<=12, 1<=day<=(28,29,30,31) depending on month/year) AND is...
void SetMonth(sal_uInt16 nNewMonth)
nNewMonth must be <100
void SetYear(sal_Int16 nNewYear)
nNewYear must be != 0
void SetDay(sal_uInt16 nNewDay)
nNewDay must be <100
static sal_uInt16 ParseNumber(std::string_view rStr, size_t &nIndex)
const std::map< InetMessageMime, const char * > ImplINetMIMEMessageHeaderData
static sal_uInt16 ParseMonth(std::string_view rStr, size_t &nIndex)
static const char * months[12]
@ CONTENT_TRANSFER_ENCODING
bool isdigitAsciiString(std::string_view rString)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
bool equalsIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
int sprintf(char(&s)[N], char const *format, T &&... arguments)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)