Revision: 7346
          http://mahogany.svn.sourceforge.net/mahogany/?rev=7346&view=rev
Author:   vadz
Date:     2007-08-27 13:49:07 -0700 (Mon, 27 Aug 2007)

Log Message:
-----------
don't assert if we fail to get the message envelope, this is normal in case of 
network problems

Modified Paths:
--------------
    trunk/M/include/MessageCC.h
    trunk/M/src/mail/MessageCC.cpp

Modified: trunk/M/include/MessageCC.h
===================================================================
--- trunk/M/include/MessageCC.h 2007-08-27 20:38:22 UTC (rev 7345)
+++ trunk/M/include/MessageCC.h 2007-08-27 20:49:07 UTC (rev 7346)
@@ -176,10 +176,17 @@
    /// get the envelope information only (faster than GetBody!)
    void GetEnvelope();
 
-   /// get the envelope information only if necessary
-   void CheckEnvelope() const
-      { if ( !m_Envelope ) ((MessageCC *)this)->GetEnvelope(); }
+   /// get the envelope information and return true if ok, false if we failed
+   /// (this can happen, notably in case of network problems)
+   bool CheckEnvelope() const
+   {
+      if ( m_Envelope )
+         return true;
 
+      const_cast<MessageCC*>(this)->GetEnvelope();
+      return m_Envelope != NULL;
+   }
+
    /// get the cache element for this message
    MESSAGECACHE *GetCacheElement() const;
 

Modified: trunk/M/src/mail/MessageCC.cpp
===================================================================
--- trunk/M/src/mail/MessageCC.cpp      2007-08-27 20:38:22 UTC (rev 7345)
+++ trunk/M/src/mail/MessageCC.cpp      2007-08-27 20:49:07 UTC (rev 7346)
@@ -169,10 +169,9 @@
 
 String MessageCC::Subject(void) const
 {
-   CheckEnvelope();
+   if ( !CheckEnvelope() )
+      return String();
 
-   CHECK( m_Envelope, String(), _T("should have envelope in Subject()") );
-
    return MIME::DecodeHeader(wxString::From8BitData(m_Envelope->subject));
 }
 
@@ -184,10 +183,9 @@
 
 String MessageCC::Date(void) const
 {
-   CheckEnvelope();
+   if ( !CheckEnvelope() )
+      return String();
 
-   CHECK( m_Envelope, String(), _T("should have envelope in Date()") );
-
    return wxString::FromAscii((char *)m_Envelope->date);
 }
 
@@ -199,17 +197,17 @@
 String
 MessageCC::GetId(void) const
 {
-   CheckEnvelope();
+   if ( !CheckEnvelope() )
+      return String();
 
-   CHECK( m_Envelope, String(), _T("should have envelope in GetId()") );
-
    return wxString::FromAscii(m_Envelope->message_id);
 }
 
 String
 MessageCC::GetNewsgroups(void) const
 {
-   CheckEnvelope();
+   if ( !CheckEnvelope() )
+      return String();
 
    CHECK( m_Envelope, String(), _T("should have envelope in GetNewsgroups()") 
);
 
@@ -219,20 +217,18 @@
 String
 MessageCC::GetReferences(void) const
 {
-   CheckEnvelope();
+   if ( !CheckEnvelope() )
+      return String();
 
-   CHECK( m_Envelope, String(), _T("should have envelope in GetReferences()") 
);
-
    return wxString::FromAscii(m_Envelope->references);
 }
 
 String
 MessageCC::GetInReplyTo(void) const
 {
-   CheckEnvelope();
+   if ( !CheckEnvelope() )
+      return String();
 
-   CHECK( m_Envelope, String(), _T("should have envelope in GetInReplyTo()") );
-
    return wxString::FromAscii(m_Envelope->in_reply_to);
 }
 
@@ -379,8 +375,8 @@
 ADDRESS *
 MessageCC::GetAddressStruct(MessageAddressType type) const
 {
-   CheckEnvelope();
-   CHECK( m_Envelope, NULL, _T("no envelope in GetAddressStruct()") );
+   if ( !CheckEnvelope() )
+      return NULL;
 
    ADDRESS *addr;
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Mahogany-cvsupdates mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to