Factor the creation of an mbox-style message separator line into a method. This fixes the bug that in KMComposeWin the value of fromEmail() wasn't checked for being empty and it fixes the bug that dateShortStr() was never checked for being empty (both bugs lead to invalid message separators which is really bad because KMail itself doesn't accept those invalid message separators when it scans an mbox file)

svn path=/trunk/kdepim/; revision=319946
wilder-work
Ingo Klcker 22 years ago
parent dc994b354c
commit 029c007942
  1. 7
      kmcommands.cpp
  2. 2
      kmcomposewin.cpp
  3. 7
      kmfoldermbox.cpp
  4. 16
      kmmessage.cpp
  5. 8
      kmmessage.h

@ -757,10 +757,7 @@ void KMSaveMsgCommand::slotSaveDataReq()
void KMSaveMsgCommand::slotMessageRetrievedForSaving(KMMessage *msg)
{
QCString str( msg->fromEmail() );
if ( str.isEmpty() )
str = "unknown@unknown.invalid";
str = "From " + str + " " + msg->dateShortStr() + "\n";
QCString str( msg->mboxMessageSeparator() );
str += KMFolderMbox::escapeFrom( msg->asString() );
str += "\n";
msg->setTransferInProgress(false);
@ -1349,7 +1346,7 @@ KMCommand::Result KMSetStatusCommand::execute()
f->setStatus( (*it2), mStatus, mToggle );
++it2;
}
kapp->dcopClient()->emitDCOPSignal( "unreadCountChanged()", QByteArray() );
//kapp->dcopClient()->emitDCOPSignal( "unreadCountChanged()", QByteArray() );
return OK;
}

@ -663,7 +663,7 @@ void KMComposeWin::deadLetter()
int fd = open(fname, O_CREAT|O_APPEND|O_WRONLY, S_IWRITE|S_IREAD);
if (fd != -1)
{
QCString startStr = "From " + msg->fromEmail() + " " + msg->dateShortStr() + "\n";
QCString startStr( msg->mboxMessageSeparator() );
::write(fd, startStr, startStr.length());
::write(fd, msgStr, msgStr.length());
::write(fd, "\n", 1);

@ -1008,11 +1008,8 @@ if( fileD1.open( IO_WriteOnly ) ) {
return error;
}
QCString address( aMsg->fromEmail() );
if ( address.isEmpty() )
address = "unknown@unknown.invalid";
fprintf(mStream, "From %s %s\n", address.data(),
(const char *)aMsg->dateShortStr());
QCString messageSeparator( aMsg->mboxMessageSeparator() );
fwrite( messageSeparator.data(), messageSeparator.length(), 1, mStream );
off_t offs = ftell(mStream);
fwrite(msgText, len, 1, mStream);
if (msgText[(int)len-1]!='\n') fwrite("\n\n", 1, 2, mStream);

@ -4435,3 +4435,19 @@ QString KMMessage::bodyToUnicode(const QTextCodec* codec) const {
return codec->toUnicode( bodyDecoded() );
}
//-----------------------------------------------------------------------------
QCString KMMessage::mboxMessageSeparator()
{
QCString str( fromEmail() );
if ( str.isEmpty() )
str = "unknown@unknown.invalid";
QCString dateStr( dateShortStr() );
if ( dateStr.isEmpty() ) {
time_t t = ::time( 0 );
dateStr = ctime( &t );
const int len = dateStr.length();
if ( dateStr[len-1] == '\n' )
dateStr.truncate( len - 1 );
}
return "From " + str + " " + dateStr + "\n";
}

@ -297,6 +297,8 @@ public:
/** Get or set the 'Date' header field */
QString dateStr() const;
/** Returns the message date in asctime format or an empty string if the
message lacks a Date header. */
QCString dateShortStr() const;
QString dateIsoStr() const;
time_t date() const;
@ -860,6 +862,12 @@ public:
void updateAttachmentState(DwBodyPart * part = 0);
/** Returns an mbox message separator line for this message, i.e. a
string of the form
"From local@domain.invalid Sat Jun 12 14:00:00 2004\n".
*/
QCString mboxMessageSeparator();
private:
/** Returns message body with quoting header and indented by the
given indentation string. This is suitable for including the message

Loading…
Cancel
Save