diff --git a/kmcommands.cpp b/kmcommands.cpp index 95fda4cf5..450b07078 100644 --- a/kmcommands.cpp +++ b/kmcommands.cpp @@ -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; } diff --git a/kmcomposewin.cpp b/kmcomposewin.cpp index 7e365d153..a96c1a1a5 100644 --- a/kmcomposewin.cpp +++ b/kmcomposewin.cpp @@ -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); diff --git a/kmfoldermbox.cpp b/kmfoldermbox.cpp index 4d74f47b1..e1a631be0 100644 --- a/kmfoldermbox.cpp +++ b/kmfoldermbox.cpp @@ -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); diff --git a/kmmessage.cpp b/kmmessage.cpp index 2b02aa60b..2dee0288b 100644 --- a/kmmessage.cpp +++ b/kmmessage.cpp @@ -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"; +} diff --git a/kmmessage.h b/kmmessage.h index 03d928300..0f3dd7bf4 100644 --- a/kmmessage.h +++ b/kmmessage.h @@ -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