[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdepim/kmail
From:       Ingo Klöcker <kloecker () kde ! org>
Date:       2004-06-12 13:24:02
Message-ID: 20040612132402.AE8C69145 () office ! kde ! org
[Download RAW message or body]

CVS commit by kloecker: 

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)


  M +2 -5      kmcommands.cpp   1.153
  M +1 -1      kmcomposewin.cpp   1.835
  M +2 -5      kmfoldermbox.cpp   1.109
  M +16 -0     kmmessage.cpp   1.474
  M +8 -0      kmmessage.h   1.168


--- kdepim/kmail/kmmessage.h  #1.167:1.168
@@ -298,4 +298,6 @@ 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;
@@ -861,4 +863,10 @@ 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

--- kdepim/kmail/kmcommands.cpp  #1.152:1.153
@@ -758,8 +758,5 @@ 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";
@@ -1350,5 +1347,5 @@ KMCommand::Result KMSetStatusCommand::ex
      ++it2;
   }
-  kapp->dcopClient()->emitDCOPSignal( "unreadCountChanged()", QByteArray() );
+  //kapp->dcopClient()->emitDCOPSignal( "unreadCountChanged()", QByteArray() );
 
   return OK;

--- kdepim/kmail/kmcomposewin.cpp  #1.834:1.835
@@ -664,5 +664,5 @@ void KMComposeWin::deadLetter()
   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());

--- kdepim/kmail/kmfoldermbox.cpp  #1.108:1.109
@@ -1009,9 +1009,6 @@ if( fileD1.open( IO_WriteOnly ) ) {
   }
 
-  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);

--- kdepim/kmail/kmmessage.cpp  #1.473:1.474
@@ -4436,2 +4436,18 @@ QString KMMessage::bodyToUnicode(const Q
 }
 
+//-----------------------------------------------------------------------------
+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";
+}


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic