BEmailMessage: added missing const, Date() returns time_t.
* Added missing const to some getter methods. * Date() now tries to parse the date of the mail, and return it as a time_t; you can still retrieve the actual string via HeaderField("Date") if you have to. * Mail now shows the time in the local time zone, and with the current locale.
This commit is contained in:
parent
66078c7911
commit
7bdee8beab
@ -55,13 +55,13 @@ public:
|
||||
// addresses the message appropriately, but ForwardMessage()
|
||||
// leaves it unaddressed.
|
||||
|
||||
const char* To();
|
||||
const char* From();
|
||||
const char* ReplyTo();
|
||||
const char* CC();
|
||||
const char* Subject();
|
||||
const char* Date();
|
||||
int Priority();
|
||||
const char* To() const;
|
||||
const char* From() const;
|
||||
const char* ReplyTo() const;
|
||||
const char* CC() const;
|
||||
const char* Subject() const;
|
||||
time_t Date() const;
|
||||
int Priority() const;
|
||||
|
||||
void SetSubject(const char* to,
|
||||
uint32 charset = B_MAIL_NULL_CONVERSION,
|
||||
|
@ -38,6 +38,7 @@ of their respective holders. All rights reserved.
|
||||
#include <stdio.h>
|
||||
|
||||
#include <ControlLook.h>
|
||||
#include <DateTimeFormat.h>
|
||||
#include <E-mail.h>
|
||||
#include <LayoutBuilder.h>
|
||||
#include <Locale.h>
|
||||
@ -429,6 +430,22 @@ THeaderView::Date() const
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
THeaderView::SetDate(time_t date)
|
||||
{
|
||||
fDate = date;
|
||||
|
||||
if (fDateView != NULL) {
|
||||
BDateTimeFormat formatter;
|
||||
|
||||
BString string;
|
||||
formatter.Format(string, date, B_FULL_DATE_FORMAT,
|
||||
B_MEDIUM_TIME_FORMAT);
|
||||
SetDate(string);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
THeaderView::SetDate(const char* date)
|
||||
{
|
||||
@ -505,8 +522,12 @@ THeaderView::SetFromMessage(BEmailMessage* mail)
|
||||
SetAccount(accountName);
|
||||
|
||||
// Set the date on this message
|
||||
const char* dateField = mail->Date();
|
||||
SetDate(dateField != NULL ? dateField : B_TRANSLATE("Unknown"));
|
||||
time_t date = mail->Date();
|
||||
if (date <= 0) {
|
||||
const char* dateField = mail->HeaderField("Date");
|
||||
SetDate(dateField != NULL ? dateField : B_TRANSLATE("Unknown"));
|
||||
} else
|
||||
SetDate(date);
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
@ -79,6 +79,7 @@ public:
|
||||
|
||||
bool IsDateEmpty() const;
|
||||
const char* Date() const;
|
||||
void SetDate(time_t date);
|
||||
void SetDate(const char* date);
|
||||
|
||||
int32 AccountID() const;
|
||||
@ -102,6 +103,7 @@ private:
|
||||
AddressTextControl* fBccControl;
|
||||
BTextControl* fSubjectControl;
|
||||
BStringView* fDateView;
|
||||
time_t fDate;
|
||||
bool fIncoming;
|
||||
bool fResending;
|
||||
};
|
||||
|
@ -2177,7 +2177,7 @@ TMailWindow::Reply(entry_ref* ref, TMailWindow* window, uint32 type)
|
||||
if (address.Length() <= 0)
|
||||
address = B_TRANSLATE("(Address unavailable)");
|
||||
|
||||
BString date(mail->Date());
|
||||
BString date(mail->HeaderField("Date"));
|
||||
if (date.Length() <= 0)
|
||||
date = B_TRANSLATE("(Date unavailable)");
|
||||
|
||||
|
@ -226,28 +226,28 @@ BEmailMessage::ForwardMessage(bool accountFromMail, bool includeAttachments)
|
||||
|
||||
|
||||
const char*
|
||||
BEmailMessage::To()
|
||||
BEmailMessage::To() const
|
||||
{
|
||||
return HeaderField("To");
|
||||
}
|
||||
|
||||
|
||||
const char*
|
||||
BEmailMessage::From()
|
||||
BEmailMessage::From() const
|
||||
{
|
||||
return HeaderField("From");
|
||||
}
|
||||
|
||||
|
||||
const char*
|
||||
BEmailMessage::ReplyTo()
|
||||
BEmailMessage::ReplyTo() const
|
||||
{
|
||||
return HeaderField("Reply-To");
|
||||
}
|
||||
|
||||
|
||||
const char*
|
||||
BEmailMessage::CC()
|
||||
BEmailMessage::CC() const
|
||||
{
|
||||
return HeaderField("Cc");
|
||||
// Note case of CC is "Cc" in our internal headers.
|
||||
@ -255,21 +255,25 @@ BEmailMessage::CC()
|
||||
|
||||
|
||||
const char*
|
||||
BEmailMessage::Subject()
|
||||
BEmailMessage::Subject() const
|
||||
{
|
||||
return HeaderField("Subject");
|
||||
}
|
||||
|
||||
|
||||
const char*
|
||||
BEmailMessage::Date()
|
||||
time_t
|
||||
BEmailMessage::Date() const
|
||||
{
|
||||
return HeaderField("Date");
|
||||
const char* dateField = HeaderField("Date");
|
||||
if (dateField == NULL)
|
||||
return -1;
|
||||
|
||||
return ParseDateWithTimeZone(dateField);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
BEmailMessage::Priority()
|
||||
BEmailMessage::Priority() const
|
||||
{
|
||||
int priorityNumber;
|
||||
const char* priorityString;
|
||||
|
Loading…
Reference in New Issue
Block a user