mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 20:05:49 +00:00
Replace time_t by PRTime
This commit is contained in:
parent
8a76dfda1a
commit
9c8e49df80
Binary file not shown.
@ -36,6 +36,8 @@
|
||||
#include "nsEscape.h"
|
||||
#include "nsFileSpec.h"
|
||||
|
||||
#include "nsTime.h"
|
||||
|
||||
class nsIMessage;
|
||||
class nsIMsgFolder;
|
||||
|
||||
|
@ -42,8 +42,8 @@ public:
|
||||
NS_IMETHOD SetUint32Property(const char *propertyName, PRUint32 propertyVal) = 0;
|
||||
NS_IMETHOD GetNumReferences(PRUint16 *result) = 0;
|
||||
NS_IMETHOD GetStringReference(PRInt32 refNum, nsString2 &resultReference) = 0;
|
||||
NS_IMETHOD GetDate(time_t *result) = 0;
|
||||
NS_IMETHOD SetDate(time_t date) = 0;
|
||||
NS_IMETHOD GetDate(PRTime *result) = 0;
|
||||
NS_IMETHOD SetDate(PRTime date) = 0;
|
||||
NS_IMETHOD SetMessageId(const char *messageId) = 0;
|
||||
NS_IMETHOD SetReferences(const char *references) = 0;
|
||||
NS_IMETHOD SetCCList(const char *ccList) = 0;
|
||||
|
@ -166,7 +166,7 @@ typedef struct nsMsgSearchValue
|
||||
{
|
||||
char *string;
|
||||
nsMsgPriority priority;
|
||||
time_t date;
|
||||
PRTime date;
|
||||
PRUint32 msgStatus; /* see MSG_FLAG in msgcom.h */
|
||||
PRUint32 size;
|
||||
nsMsgKey key;
|
||||
@ -370,18 +370,18 @@ public:
|
||||
PRUint32 headersSize, /* size of the NULL terminated list of headers */
|
||||
PRBool ForFilters /* true if we are filtering */);
|
||||
nsresult MatchString (nsString2 *, const char *charset, PRBool body = FALSE);
|
||||
nsresult MatchDate (time_t);
|
||||
nsresult MatchDate (PRTime);
|
||||
nsresult MatchStatus (PRUint32);
|
||||
nsresult MatchPriority (nsMsgPriority);
|
||||
nsresult MatchSize (PRUint32);
|
||||
nsresult MatchRfc822String(const char *, const char *charset);
|
||||
nsresult MatchAge (time_t);
|
||||
nsresult MatchAge (PRTime);
|
||||
|
||||
nsresult EnStreamNew (nsString2 &stream);
|
||||
nsresult DeStream (char *, PRInt16 length);
|
||||
nsresult DeStreamNew (char *, PRInt16 length);
|
||||
|
||||
nsresult GetLocalTimes (time_t, time_t, struct tm &, struct tm &);
|
||||
nsresult GetLocalTimes (PRTime, PRTime, PRExplodedTime &, PRExplodedTime &);
|
||||
|
||||
PRBool IsBooleanOpAND() { return m_booleanOp == nsMsgSearchBooleanAND ? PR_TRUE : PR_FALSE;}
|
||||
nsMsgSearchBooleanOp GetBooleanOp() {return m_booleanOp;}
|
||||
|
@ -207,7 +207,7 @@ NS_IMETHODIMP nsMsgFilter::GetAction(nsMsgRuleActionType *type, void **value)
|
||||
NS_IMETHODIMP nsMsgFilter::LogRuleHit(nsOutputStream *stream, nsIMsgDBHdr *msgHdr)
|
||||
{
|
||||
char *filterName = "";
|
||||
time_t date;
|
||||
PRTime date;
|
||||
char dateStr[40]; /* 30 probably not enough */
|
||||
nsMsgRuleActionType actionType;
|
||||
void *value;
|
||||
@ -218,8 +218,9 @@ NS_IMETHODIMP nsMsgFilter::LogRuleHit(nsOutputStream *stream, nsIMsgDBHdr *msgHd
|
||||
GetAction(&actionType, &value);
|
||||
nsresult res;
|
||||
res = msgHdr->GetDate(&date);
|
||||
struct tm* tmTime = localtime(&date);
|
||||
strftime(dateStr, 100, "%m/%d/%Y %I:%M %p", tmTime);
|
||||
PRExplodedTime exploded;
|
||||
PR_ExplodeTime(date, PR_LocalTimeParameters, &exploded);
|
||||
PR_FormatTimeUSEnglish(dateStr, 100, "%m/%d/%Y %I:%M %p", &exploded);
|
||||
|
||||
msgHdr->GetAuthor(author);
|
||||
msgHdr->GetSubject(subject);
|
||||
|
@ -535,7 +535,7 @@ nsresult nsMsgSearchOfflineMail::MatchTerms(nsIMsgDBHdr *msgToMatch,
|
||||
break;
|
||||
case nsMsgSearchAttribDate:
|
||||
{
|
||||
time_t date;
|
||||
PRTime date;
|
||||
msgToMatch->GetDate(&date);
|
||||
err = pTerm->MatchDate (date);
|
||||
}
|
||||
@ -567,7 +567,7 @@ nsresult nsMsgSearchOfflineMail::MatchTerms(nsIMsgDBHdr *msgToMatch,
|
||||
break;
|
||||
case nsMsgSearchAttribAgeInDays:
|
||||
{
|
||||
time_t date;
|
||||
PRTime date;
|
||||
msgToMatch->GetDate(&date);
|
||||
err = pTerm->MatchAge (date);
|
||||
}
|
||||
|
@ -322,16 +322,13 @@ nsresult nsMsgSearchTerm::OutputValue(nsString2 &outputStr)
|
||||
{
|
||||
case nsMsgSearchAttribDate:
|
||||
{
|
||||
struct tm *p = localtime(&m_value.u.date);
|
||||
if (p)
|
||||
{
|
||||
// wow, so tm_mon is 0 based, tm_mday is 1 based.
|
||||
char dateBuf[100];
|
||||
strftime (dateBuf, sizeof(dateBuf), "%d-%b-%Y", p);
|
||||
outputStr += dateBuf;
|
||||
}
|
||||
else
|
||||
outputStr += "01/01/70";
|
||||
PRExplodedTime exploded;
|
||||
PR_ExplodeTime(m_value.u.date, PR_LocalTimeParameters, &exploded);
|
||||
|
||||
// wow, so tm_mon is 0 based, tm_mday is 1 based.
|
||||
char dateBuf[100];
|
||||
PR_FormatTimeUSEnglish (dateBuf, sizeof(dateBuf), "%d-%b-%Y", &exploded);
|
||||
outputStr += dateBuf;
|
||||
break;
|
||||
}
|
||||
case nsMsgSearchAttribMsgStatus:
|
||||
@ -884,50 +881,40 @@ nsresult nsMsgSearchTerm::MatchRfc822String (const char *string, const char *cha
|
||||
}
|
||||
|
||||
|
||||
nsresult nsMsgSearchTerm::GetLocalTimes (time_t a, time_t b, struct tm &aTm, struct tm &bTm)
|
||||
nsresult nsMsgSearchTerm::GetLocalTimes (PRTime a, PRTime b, PRExplodedTime &aExploded, PRExplodedTime &bExploded)
|
||||
{
|
||||
// Isolate the RTL time weirdnesses here:
|
||||
// (1) Must copy the tm since localtime has a static tm
|
||||
// (2) localtime can fail if it doesn't like the time_t. Must check the tm* for nsnull
|
||||
|
||||
struct tm *p = localtime(&a);
|
||||
if (p)
|
||||
{
|
||||
memcpy (&aTm, p, sizeof(struct tm));
|
||||
p = localtime(&b);
|
||||
if (p)
|
||||
{
|
||||
memcpy (&bTm, p, sizeof(struct tm));
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
PR_ExplodeTime(a, PR_LocalTimeParameters, &aExploded);
|
||||
PR_ExplodeTime(b, PR_LocalTimeParameters, &bExploded);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult nsMsgSearchTerm::MatchDate (time_t dateToMatch)
|
||||
nsresult nsMsgSearchTerm::MatchDate (PRTime dateToMatch)
|
||||
{
|
||||
nsresult err = NS_COMFALSE;
|
||||
nsTime t_date(dateToMatch);
|
||||
|
||||
switch (m_operator)
|
||||
{
|
||||
case nsMsgSearchOpIsBefore:
|
||||
if (dateToMatch < m_value.u.date)
|
||||
if (t_date < nsTime(m_value.u.date))
|
||||
err = NS_OK;
|
||||
break;
|
||||
case nsMsgSearchOpIsAfter:
|
||||
{
|
||||
time_t adjustedDate = m_value.u.date + 60*60*24; // we want to be greater than the next day....
|
||||
if (dateToMatch > adjustedDate)
|
||||
nsTime adjustedDate = nsTime(m_value.u.date);
|
||||
adjustedDate += 60*60*24; // we want to be greater than the next day....
|
||||
if (t_date > adjustedDate)
|
||||
err = NS_OK;
|
||||
}
|
||||
break;
|
||||
case nsMsgSearchOpIs:
|
||||
{
|
||||
struct tm tmToMatch, tmThis;
|
||||
PRExplodedTime tmToMatch, tmThis;
|
||||
if (NS_OK == GetLocalTimes (dateToMatch, m_value.u.date, tmToMatch, tmThis))
|
||||
{
|
||||
if (tmThis.tm_year == tmToMatch.tm_year &&
|
||||
tmThis.tm_mon == tmToMatch.tm_mon &&
|
||||
tmThis.tm_month == tmToMatch.tm_month &&
|
||||
tmThis.tm_mday == tmToMatch.tm_mday)
|
||||
err = NS_OK;
|
||||
}
|
||||
@ -935,11 +922,11 @@ nsresult nsMsgSearchTerm::MatchDate (time_t dateToMatch)
|
||||
break;
|
||||
case nsMsgSearchOpIsnt:
|
||||
{
|
||||
struct tm tmToMatch, tmThis;
|
||||
PRExplodedTime tmToMatch, tmThis;
|
||||
if (NS_OK == GetLocalTimes (dateToMatch, m_value.u.date, tmToMatch, tmThis))
|
||||
{
|
||||
if (tmThis.tm_year != tmToMatch.tm_year ||
|
||||
tmThis.tm_mon != tmToMatch.tm_mon ||
|
||||
tmThis.tm_month != tmToMatch.tm_month ||
|
||||
tmThis.tm_mday != tmToMatch.tm_mday)
|
||||
err = NS_OK;
|
||||
}
|
||||
@ -952,7 +939,7 @@ nsresult nsMsgSearchTerm::MatchDate (time_t dateToMatch)
|
||||
}
|
||||
|
||||
|
||||
nsresult nsMsgSearchTerm::MatchAge (time_t msgDate)
|
||||
nsresult nsMsgSearchTerm::MatchAge (PRTime msgDate)
|
||||
{
|
||||
nsresult err = NS_COMFALSE;
|
||||
#ifdef DO_AGE_YET
|
||||
|
@ -588,12 +588,26 @@ nsMsgMessageDataSource::createMessageDateNode(nsIMessage *message,
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
PRInt32 error;
|
||||
time_t aTime = date.ToInteger(&error, 16);
|
||||
struct tm* tmTime = localtime(&aTime);
|
||||
PRUint32 aLong = date.ToInteger(&error, 16);
|
||||
// As the time is stored in seconds, we need to multiply it by PR_USEC_PER_SEC,
|
||||
// to get back a valid 64 bits value
|
||||
PRInt64 microSecondsPerSecond, intermediateResult;
|
||||
PRTime aTime;
|
||||
LL_I2L(microSecondsPerSecond, PR_USEC_PER_SEC);
|
||||
LL_UI2L(intermediateResult, aLong);
|
||||
LL_MUL(aTime, intermediateResult, microSecondsPerSecond);
|
||||
|
||||
PRExplodedTime explode;
|
||||
PR_ExplodeTime(aTime, PR_LocalTimeParameters, &explode);
|
||||
|
||||
nsString dateString;
|
||||
|
||||
|
||||
/* ducarroz: FormatTMTime doesn't seems to work correctly on Mac and doen't work with PRExplodedTime!
|
||||
I will use PR_FormatTime until FormatTMTime is fixed.
|
||||
if(mDateTimeFormat)
|
||||
rv = mDateTimeFormat->FormatTMTime(mApplicationLocale, kDateFormatShort, kTimeFormatNoSeconds,
|
||||
tmTime, dateString);
|
||||
(tm*)&explode, dateString);
|
||||
//Ensure that we always have some string for the date.
|
||||
if(!mDateTimeFormat || NS_FAILED(rv))
|
||||
{
|
||||
@ -601,6 +615,11 @@ nsMsgMessageDataSource::createMessageDateNode(nsIMessage *message,
|
||||
rv = NS_OK;
|
||||
}
|
||||
if(NS_SUCCEEDED(rv))
|
||||
*/
|
||||
char buffer[128];
|
||||
PR_FormatTime(buffer, sizeof(buffer), "%m/%d/%Y %I:%M %p", &explode);
|
||||
dateString = buffer;
|
||||
|
||||
rv = createNode(dateString, target);
|
||||
return rv;
|
||||
}
|
||||
|
@ -283,9 +283,12 @@ nsresult nsMsgNotificationManager::AddNewMailNotification(nsIMsgFolder *folder)
|
||||
}
|
||||
|
||||
//Supposedly rdf will convert this into a localized time string.
|
||||
time_t currentTime = time(nsnull);
|
||||
struct tm *localTime = localtime(¤tTime);
|
||||
timeStampString = asctime(localTime);
|
||||
PRExplodedTime explode;
|
||||
PR_ExplodeTime( PR_Now(), PR_LocalTimeParameters, &explode);
|
||||
char buffer[128];
|
||||
PR_FormatTime(buffer, sizeof(buffer), "%m/%d/%Y %I:%M %p", &explode);
|
||||
timeStampString = buffer;
|
||||
|
||||
rv = rdfService->GetLiteral(timeStampString.GetUnicode(), getter_AddRefs(timeStamp));
|
||||
if(NS_SUCCEEDED(rv))
|
||||
{
|
||||
|
Binary file not shown.
@ -99,7 +99,7 @@ NS_IMETHODIMP nsMessage::GetStringReference(PRInt32 refNum, nsString2 &resultRef
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMessage::GetDate(time_t *result)
|
||||
NS_IMETHODIMP nsMessage::GetDate(PRTime *result)
|
||||
{
|
||||
if(mMsgHdr)
|
||||
return mMsgHdr->GetDate(result);
|
||||
@ -107,7 +107,7 @@ NS_IMETHODIMP nsMessage::GetDate(time_t *result)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMessage::SetDate(time_t date)
|
||||
NS_IMETHODIMP nsMessage::SetDate(PRTime date)
|
||||
{
|
||||
if(mMsgHdr)
|
||||
return mMsgHdr->SetDate(date);
|
||||
|
@ -46,8 +46,8 @@ public:
|
||||
NS_IMETHOD SetUint32Property(const char *propertyName, PRUint32 propertyVal);
|
||||
NS_IMETHOD GetNumReferences(PRUint16 *result);
|
||||
NS_IMETHOD GetStringReference(PRInt32 refNum, nsString2 &resultReference);
|
||||
NS_IMETHOD GetDate(time_t *result);
|
||||
NS_IMETHOD SetDate(time_t date);
|
||||
NS_IMETHOD GetDate(PRTime *result);
|
||||
NS_IMETHOD SetDate(PRTime date);
|
||||
NS_IMETHOD SetMessageId(const char *messageId);
|
||||
NS_IMETHOD SetReferences(const char *references);
|
||||
NS_IMETHOD SetCCList(const char *ccList);
|
||||
|
Binary file not shown.
@ -23,7 +23,7 @@
|
||||
#include "nsINetService.h"
|
||||
#include "nsMailHeaders.h"
|
||||
#include "nsMsgI18N.h"
|
||||
#include "xp_time.h"
|
||||
//#include "xp_time.h"
|
||||
#include "nsMsgCompPrefs.h"
|
||||
#include "nsIMsgHeaderParser.h"
|
||||
#include "nsIMimeURLUtils.h"
|
||||
@ -836,7 +836,9 @@ GenerateGlobalRandomBytes(unsigned char *buf, PRInt32 len)
|
||||
{
|
||||
/* Seed the random-number generator with current time so that
|
||||
* the numbers will be different every time we run. */
|
||||
srand( (unsigned)time( NULL ) );
|
||||
PRInt32 aTime;
|
||||
LL_L2I(aTime, PR_Now());
|
||||
srand( (unsigned)aTime );
|
||||
firstTime = PR_FALSE;
|
||||
}
|
||||
|
||||
@ -1102,7 +1104,14 @@ GIVE_UP_ON_CONTENT_BASE:
|
||||
char *
|
||||
msg_generate_message_id (nsIMsgIdentity *identity)
|
||||
{
|
||||
time_t now = XP_TIME();
|
||||
PRUint32 now;
|
||||
PRTime prNow = PR_Now();
|
||||
PRInt64 microSecondsPerSecond, intermediateResult;
|
||||
|
||||
LL_I2L(microSecondsPerSecond, PR_USEC_PER_SEC);
|
||||
LL_DIV(intermediateResult, prNow, microSecondsPerSecond);
|
||||
LL_L2UI(now, intermediateResult);
|
||||
|
||||
PRUint32 salt = 0;
|
||||
const char *host = 0;
|
||||
|
||||
|
@ -104,9 +104,9 @@ public:
|
||||
nsresult AddToNewMDB();
|
||||
// accessor methods.
|
||||
|
||||
PRBool AddLaterKey(nsMsgKey key, time_t *until);
|
||||
PRBool AddLaterKey(nsMsgKey key, PRTime until);
|
||||
PRInt32 GetNumLatered();
|
||||
nsMsgKey GetLateredAt(PRInt32 laterIndex, time_t *pUntil);
|
||||
nsMsgKey GetLateredAt(PRInt32 laterIndex, PRTime pUntil);
|
||||
void RemoveLateredAt(PRInt32 laterIndex);
|
||||
|
||||
void SetViewType(PRInt32 viewType);
|
||||
|
@ -125,7 +125,7 @@ public:
|
||||
NS_IMETHOD HasAttachments(nsMsgKey key, PRBool *pHasThem) = 0;
|
||||
|
||||
NS_IMETHOD MarkAllRead(nsMsgKeyArray *thoseMarked) = 0;
|
||||
NS_IMETHOD MarkReadByDate (time_t te, time_t endDate, nsMsgKeyArray *markedIds) = 0;
|
||||
NS_IMETHOD MarkReadByDate (PRTime te, PRTime endDate, nsMsgKeyArray *markedIds) = 0;
|
||||
|
||||
NS_IMETHOD DeleteMessages(nsMsgKeyArray* nsMsgKeys, nsIDBChangeListener *instigator) = 0;
|
||||
NS_IMETHOD DeleteMessage(nsMsgKey key,
|
||||
@ -136,7 +136,7 @@ public:
|
||||
|
||||
NS_IMETHOD UndoDelete(nsIMsgDBHdr *msgHdr) = 0;
|
||||
|
||||
NS_IMETHOD MarkLater(nsMsgKey key, time_t *until) = 0;
|
||||
NS_IMETHOD MarkLater(nsMsgKey key, PRTime until) = 0;
|
||||
NS_IMETHOD MarkMarked(nsMsgKey key, PRBool mark,
|
||||
nsIDBChangeListener *instigator) = 0;
|
||||
NS_IMETHOD MarkOffline(nsMsgKey key, PRBool offline,
|
||||
|
@ -139,7 +139,7 @@ public:
|
||||
NS_IMETHOD HasAttachments(nsMsgKey key, PRBool *pHasThem);
|
||||
|
||||
NS_IMETHOD MarkAllRead(nsMsgKeyArray *thoseMarked);
|
||||
NS_IMETHOD MarkReadByDate (time_t te, time_t endDate, nsMsgKeyArray *markedIds);
|
||||
NS_IMETHOD MarkReadByDate (PRTime te, PRTime endDate, nsMsgKeyArray *markedIds);
|
||||
|
||||
NS_IMETHOD DeleteMessages(nsMsgKeyArray* nsMsgKeys, nsIDBChangeListener *instigator);
|
||||
NS_IMETHOD DeleteMessage(nsMsgKey key,
|
||||
@ -150,7 +150,7 @@ public:
|
||||
|
||||
NS_IMETHOD UndoDelete(nsIMsgDBHdr *msgHdr);
|
||||
|
||||
NS_IMETHOD MarkLater(nsMsgKey key, time_t *until);
|
||||
NS_IMETHOD MarkLater(nsMsgKey key, PRTime until);
|
||||
NS_IMETHOD MarkMarked(nsMsgKey key, PRBool mark,
|
||||
nsIDBChangeListener *instigator);
|
||||
NS_IMETHOD MarkOffline(nsMsgKey key, PRBool offline,
|
||||
@ -214,6 +214,10 @@ public:
|
||||
static struct mdbYarn *UInt32ToYarn(struct mdbYarn *yarn, PRUint32 i);
|
||||
static void YarnTonsString(struct mdbYarn *yarn, nsString *str);
|
||||
static void YarnToUInt32(struct mdbYarn *yarn, PRUint32 *i);
|
||||
|
||||
// helper functions to convert a 64bits PRTime into a 32bits value (compatible time_t) and vice versa.
|
||||
static void PRTime2Seconds(PRTime prTime, PRUint32 *seconds);
|
||||
static void Seconds2PRTime(PRUint32 seconds, PRTime *prTime);
|
||||
|
||||
static void CleanupCache();
|
||||
#ifdef DEBUG
|
||||
|
@ -40,8 +40,8 @@ public:
|
||||
NS_IMETHOD SetUint32Property(const char *propertyName, PRUint32 propertyVal);
|
||||
NS_IMETHOD GetNumReferences(PRUint16 *result);
|
||||
NS_IMETHOD GetStringReference(PRInt32 refNum, nsString2 &resultReference);
|
||||
NS_IMETHOD GetDate(time_t *result);
|
||||
NS_IMETHOD SetDate(time_t date);
|
||||
NS_IMETHOD GetDate(PRTime *result);
|
||||
NS_IMETHOD SetDate(PRTime date);
|
||||
NS_IMETHOD SetMessageId(const char *messageId);
|
||||
NS_IMETHOD SetReferences(const char *references);
|
||||
NS_IMETHOD SetCCList(const char *ccList);
|
||||
@ -111,7 +111,7 @@ protected:
|
||||
|
||||
nsMsgKey m_threadId;
|
||||
nsMsgKey m_messageKey; //news: article number, mail mbox offset, imap uid...
|
||||
time_t m_date;
|
||||
PRTime m_date;
|
||||
PRUint32 m_messageSize; // lines for news articles, bytes for mail messages
|
||||
PRUint32 m_statusOffset; // offset in a local mail message of the mozilla status hdr
|
||||
PRUint32 m_flags;
|
||||
|
@ -339,8 +339,11 @@ nsDBFolderInfo::ChangeExpungedBytes(PRInt32 delta)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool nsDBFolderInfo::AddLaterKey(nsMsgKey key, time_t *until)
|
||||
PRBool nsDBFolderInfo::AddLaterKey(nsMsgKey key, PRTime until)
|
||||
{
|
||||
//ducarroz: if until represente a folder time stamp,
|
||||
// therefore it should be declared as a PRInt32.
|
||||
// Else, it should be a PRTime.
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
@ -349,8 +352,11 @@ PRInt32 nsDBFolderInfo::GetNumLatered()
|
||||
return 0;
|
||||
}
|
||||
|
||||
nsMsgKey nsDBFolderInfo::GetLateredAt(PRInt32 laterIndex, time_t *pUntil)
|
||||
nsMsgKey nsDBFolderInfo::GetLateredAt(PRInt32 laterIndex, PRTime pUntil)
|
||||
{
|
||||
//ducarroz: if until represente a folder time stamp,
|
||||
// therefore it should be declared as a PRInt32.
|
||||
// Else, it should be a PRTime.
|
||||
return nsMsgKey_None;
|
||||
}
|
||||
|
||||
|
@ -100,8 +100,7 @@ NS_IMETHODIMP nsMailDatabase::Open(nsIFileSpec *aFolderName, PRBool create, nsIM
|
||||
{
|
||||
PRInt32 numNewMessages;
|
||||
PRUint32 folderSize;
|
||||
PRInt32 folderDateInSeconds;
|
||||
time_t folderDate;
|
||||
PRInt32 folderDate;
|
||||
nsFileSpec::TimeStamp actualFolderTimeStamp;
|
||||
|
||||
mailDB->m_folderSpec->GetModDate(actualFolderTimeStamp) ;
|
||||
@ -109,8 +108,7 @@ NS_IMETHODIMP nsMailDatabase::Open(nsIFileSpec *aFolderName, PRBool create, nsIM
|
||||
|
||||
folderInfo->GetNumNewMessages(&numNewMessages);
|
||||
folderInfo->GetFolderSize(&folderSize);
|
||||
folderInfo->GetFolderDate(&folderDateInSeconds);
|
||||
folderDate = folderDateInSeconds;
|
||||
folderInfo->GetFolderDate(&folderDate);
|
||||
if (folderSize != mailDB->m_folderSpec->GetFileSize()||
|
||||
folderDate != actualFolderTimeStamp ||
|
||||
numNewMessages < 0)
|
||||
@ -360,8 +358,7 @@ void nsMailDatabase::UpdateFolderFlag(nsIMsgDBHdr *mailHdr, PRBool bSet,
|
||||
{
|
||||
nsFileSpec::TimeStamp actualFolderTimeStamp;
|
||||
m_folderSpec->GetModDate(actualFolderTimeStamp) ;
|
||||
|
||||
|
||||
|
||||
m_dbFolderInfo->SetFolderSize(m_folderSpec->GetFileSize());
|
||||
m_dbFolderInfo->SetFolderDate(actualFolderTimeStamp);
|
||||
}
|
||||
@ -525,20 +522,14 @@ nsresult nsMailDatabase::PrePopulate()
|
||||
{
|
||||
nsIMsgDBHdr *msg;
|
||||
nsMsgHdr *newHdr = NULL;
|
||||
PRTime resultTime, intermediateResult, microSecondsPerSecond;
|
||||
resultTime = PR_Now();
|
||||
time_t resDate;
|
||||
|
||||
LL_I2L(microSecondsPerSecond, PR_USEC_PER_SEC);
|
||||
LL_DIV(intermediateResult, resultTime, microSecondsPerSecond);
|
||||
LL_L2I(resDate, intermediateResult);
|
||||
PRTime now = PR_Now();
|
||||
|
||||
nsresult rv = CreateNewHdr(1, &msg);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
newHdr = NS_STATIC_CAST(nsMsgHdr*, msg); // closed system, cast ok
|
||||
newHdr->SetAuthor("bird@celtics.com (Larry Bird)");
|
||||
newHdr->SetSubject("Why the Lakers suck");
|
||||
newHdr->SetDate(resDate);
|
||||
newHdr->SetDate(now);
|
||||
newHdr->SetRecipients("riley@heat.com (Pat Riley)", PR_FALSE);
|
||||
AddNewHdrToDB (newHdr, PR_TRUE);
|
||||
newHdr->Release();
|
||||
@ -548,7 +539,7 @@ nsresult nsMailDatabase::PrePopulate()
|
||||
newHdr = NS_STATIC_CAST(nsMsgHdr*, msg); // closed system, cast ok
|
||||
newHdr->SetAuthor("shaq@brick.com (Shaquille O'Neal)");
|
||||
newHdr->SetSubject("Anyone here know how to shoot free throws?");
|
||||
newHdr->SetDate(resDate);
|
||||
newHdr->SetDate(now);
|
||||
AddNewHdrToDB (newHdr, PR_TRUE);
|
||||
newHdr->Release();
|
||||
|
||||
@ -557,7 +548,7 @@ nsresult nsMailDatabase::PrePopulate()
|
||||
newHdr = NS_STATIC_CAST(nsMsgHdr*, msg); // closed system, cast ok
|
||||
newHdr->SetAuthor("dj@celtics.com (Dennis Johnson)");
|
||||
newHdr->SetSubject("Has anyone seen my jump shot?");
|
||||
newHdr->SetDate(resDate);
|
||||
newHdr->SetDate(now);
|
||||
AddNewHdrToDB (newHdr, PR_TRUE);
|
||||
newHdr->Release();
|
||||
|
||||
@ -566,7 +557,7 @@ nsresult nsMailDatabase::PrePopulate()
|
||||
newHdr = NS_STATIC_CAST(nsMsgHdr*, msg); // closed system, cast ok
|
||||
newHdr->SetAuthor("sichting@celtics.com (Jerry Sichting)");
|
||||
newHdr->SetSubject("Tips for fighting 7' 4\" guys");
|
||||
newHdr->SetDate(resDate);
|
||||
newHdr->SetDate(now);
|
||||
AddNewHdrToDB (newHdr, PR_TRUE);
|
||||
newHdr->Release();
|
||||
return NS_OK;
|
||||
|
@ -1360,7 +1360,7 @@ NS_IMETHODIMP nsMsgDatabase::MarkAllRead(nsMsgKeyArray *thoseMarked)
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgDatabase::MarkReadByDate (time_t startDate, time_t endDate, nsMsgKeyArray *markedIds)
|
||||
NS_IMETHODIMP nsMsgDatabase::MarkReadByDate (PRTime startDate, PRTime endDate, nsMsgKeyArray *markedIds)
|
||||
{
|
||||
nsresult rv;
|
||||
nsMsgHdr *pHeader;
|
||||
@ -1371,15 +1371,21 @@ NS_IMETHODIMP nsMsgDatabase::MarkReadByDate (time_t startDate, time_t endDate, n
|
||||
rv = EnumerateMessages(&hdrs);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsTime t_startDate(startDate);
|
||||
nsTime t_endDate(endDate);
|
||||
|
||||
for (hdrs->First(); hdrs->IsDone() != NS_OK; hdrs->Next())
|
||||
{
|
||||
rv = hdrs->CurrentItem((nsISupports**)&pHeader);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "nsMsgDBEnumerator broken");
|
||||
if (NS_FAILED(rv)) break;
|
||||
|
||||
time_t headerDate;
|
||||
PRTime headerDate;
|
||||
(void)pHeader->GetDate(&headerDate);
|
||||
if (headerDate > startDate && headerDate <= endDate)
|
||||
nsTime t_headerDate(headerDate);
|
||||
|
||||
if (t_headerDate > t_startDate && t_headerDate <= t_endDate)
|
||||
{
|
||||
PRBool isRead;
|
||||
nsMsgKey key;
|
||||
@ -1400,7 +1406,7 @@ NS_IMETHODIMP nsMsgDatabase::MarkReadByDate (time_t startDate, time_t endDate, n
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgDatabase::MarkLater(nsMsgKey key, time_t *until)
|
||||
NS_IMETHODIMP nsMsgDatabase::MarkLater(nsMsgKey key, PRTime until)
|
||||
{
|
||||
PR_ASSERT(m_dbFolderInfo);
|
||||
if (m_dbFolderInfo != NULL)
|
||||
@ -2165,6 +2171,25 @@ nsresult nsMsgDatabase::UInt32ToRowCellColumn(nsIMdbRow *row, mdb_token columnTo
|
||||
*pResult = result;
|
||||
}
|
||||
|
||||
/* static */void nsMsgDatabase::PRTime2Seconds(PRTime prTime, PRUint32 *seconds)
|
||||
{
|
||||
PRInt64 microSecondsPerSecond, intermediateResult;
|
||||
|
||||
LL_I2L(microSecondsPerSecond, PR_USEC_PER_SEC);
|
||||
LL_DIV(intermediateResult, prTime, microSecondsPerSecond);
|
||||
LL_L2UI((*seconds), intermediateResult);
|
||||
}
|
||||
|
||||
/* static */void nsMsgDatabase::Seconds2PRTime(PRUint32 seconds, PRTime *prTime)
|
||||
{
|
||||
PRInt64 microSecondsPerSecond, intermediateResult;
|
||||
|
||||
LL_I2L(microSecondsPerSecond, PR_USEC_PER_SEC);
|
||||
LL_UI2L(intermediateResult, seconds);
|
||||
LL_MUL((*prTime), intermediateResult, microSecondsPerSecond);
|
||||
}
|
||||
|
||||
|
||||
PRUint32 nsMsgDatabase::GetCurVersion()
|
||||
{
|
||||
return kMsgDBVersion;
|
||||
|
@ -40,8 +40,8 @@ void nsMsgHdr::Init()
|
||||
m_cachedValuesInitialized = PR_FALSE;
|
||||
m_statusOffset = -1;
|
||||
m_messageKey = nsMsgKey_None;
|
||||
m_date = 0;
|
||||
m_messageSize = 0;
|
||||
m_date = LL_ZERO;
|
||||
m_csID = 0;
|
||||
m_flags = 0;
|
||||
m_mdbRow = NULL;
|
||||
@ -65,8 +65,10 @@ nsresult nsMsgHdr::InitCachedValues()
|
||||
|
||||
err = GetUInt32Column(m_mdb->m_flagsColumnToken, &m_flags);
|
||||
err = GetUInt32Column(m_mdb->m_messageSizeColumnToken, &m_messageSize);
|
||||
|
||||
err = GetUInt32Column(m_mdb->m_dateColumnToken, &uint32Value);
|
||||
m_date = uint32Value;
|
||||
nsMsgDatabase::Seconds2PRTime(uint32Value, &m_date);
|
||||
|
||||
err = GetUInt32Column(m_mdb->m_messageThreadIdColumnToken, &m_threadId);
|
||||
err = GetUInt32Column(m_mdb->m_numReferencesColumnToken, &uint32Value);
|
||||
if (NS_SUCCEEDED(err))
|
||||
@ -246,7 +248,7 @@ NS_IMETHODIMP nsMsgHdr::GetStringReference(PRInt32 refNum, nsString2 &resultRefe
|
||||
return err;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgHdr::GetDate(time_t *result)
|
||||
NS_IMETHODIMP nsMsgHdr::GetDate(PRTime *result)
|
||||
{
|
||||
*result = m_date;
|
||||
return NS_OK;
|
||||
@ -382,9 +384,12 @@ NS_IMETHODIMP nsMsgHdr::SetStatusOffset(PRUint32 statusOffset)
|
||||
return SetUInt32Column(statusOffset, m_mdb->m_statusOffsetColumnToken);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgHdr::SetDate(time_t date)
|
||||
NS_IMETHODIMP nsMsgHdr::SetDate(PRTime date)
|
||||
{
|
||||
return SetUInt32Column((PRUint32) date, m_mdb->m_dateColumnToken);
|
||||
m_date = date;
|
||||
PRUint32 seconds;
|
||||
nsMsgDatabase::PRTime2Seconds(date, &seconds);
|
||||
return SetUInt32Column((PRUint32) seconds, m_mdb->m_dateColumnToken);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgHdr::GetStatusOffset(PRUint32 *result)
|
||||
|
Binary file not shown.
Binary file not shown.
@ -1234,19 +1234,10 @@ int nsParseMailMessageState::FinalizeHeaders()
|
||||
if (references != nsnull)
|
||||
m_newMsgHdr->SetReferences(references->value);
|
||||
if (date) {
|
||||
time_t resDate = 0;
|
||||
PRTime resultTime, intermediateResult, microSecondsPerSecond;
|
||||
PRTime resultTime;
|
||||
PRStatus timeStatus = PR_ParseTimeString (date->value, PR_FALSE, &resultTime);
|
||||
|
||||
LL_I2L(microSecondsPerSecond, PR_USEC_PER_SEC);
|
||||
LL_DIV(intermediateResult, resultTime, microSecondsPerSecond);
|
||||
LL_L2I(resDate, intermediateResult);
|
||||
if (resDate < 0)
|
||||
resDate = 0;
|
||||
|
||||
// no reason to store milliseconds, since they aren't specified
|
||||
if (PR_SUCCESS == timeStatus)
|
||||
m_newMsgHdr->SetDate(resDate);
|
||||
m_newMsgHdr->SetDate(nsTime(resultTime));
|
||||
}
|
||||
if (priority)
|
||||
m_newMsgHdr->SetPriority(priority->value);
|
||||
|
@ -614,21 +614,14 @@ nsNNTPNewsgroupList::ParseLine(char *line, PRUint32 * message_number)
|
||||
|
||||
GET_TOKEN ();
|
||||
if (line) {
|
||||
time_t resDate = 0;
|
||||
PRTime resultTime, intermediateResult, microSecondsPerSecond;
|
||||
PRStatus status = PR_ParseTimeString (line, PR_FALSE, &resultTime);
|
||||
LL_I2L(microSecondsPerSecond, PR_USEC_PER_SEC);
|
||||
LL_DIV(intermediateResult, resultTime, microSecondsPerSecond);
|
||||
LL_L2I(resDate, intermediateResult);
|
||||
if (resDate < 0)
|
||||
resDate = 0;
|
||||
|
||||
// no reason to store milliseconds, since they aren't specified
|
||||
PRTime date;
|
||||
PRStatus status = PR_ParseTimeString (line, PR_FALSE, &date);
|
||||
if (PR_SUCCESS == status) {
|
||||
|
||||
#ifdef DEBUG_NEWS
|
||||
printf("date = %s, %ld\n", line, resDate);
|
||||
printf("date = %s, %ld\n", line, date);
|
||||
#endif
|
||||
rv = newMsgHdr->SetDate(resDate); /* date */
|
||||
rv = newMsgHdr->SetDate(date); /* date */
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user