Update of /cvsroot/mahogany/M/src/mail
In directory usw-pr-cvs1:/tmp/cvs-serv21249/src/mail

Modified Files:
        ASMailFolder.cpp HeaderInfoImpl.cpp MMailFolder.cpp 
        MailFolder.cpp MailFolderCC.cpp MailFolderCmn.cpp 
        SendMessageCC.cpp 
Added Files:
        LogCircle.cpp MFui.cpp 
Log Message:
code reorganization: nothing really changed but plenty of things moved around so that 
MailFolder.h contains only MailFolder class and nothing else; some unused code/classes 
removed completely

***** Error reading new file: [Errno 2] No such file or directory: 'LogCircle.cpp'
***** Error reading new file: [Errno 2] No such file or directory: 'MFui.cpp'
Index: ASMailFolder.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/mail/ASMailFolder.cpp,v
retrieving revision 1.61
retrieving revision 1.62
diff -b -u -2 -r1.61 -r1.62
--- ASMailFolder.cpp    19 Dec 2001 12:34:37 -0000      1.61
+++ ASMailFolder.cpp    4 Jul 2002 17:22:37 -0000       1.62
@@ -25,4 +25,9 @@
 #include "Message.h"
 
+#include "Sequence.h"
+#include "UIdArray.h"
+
+#include "MSearch.h"
+
 #include "MailFolder.h"
 #include "ASMailFolder.h"
@@ -36,4 +41,12 @@
 #endif
 
+ASMailFolder::ResultImpl::~ResultImpl()
+{
+   if ( m_Mf )
+      m_Mf->DecRef();
+
+   delete m_Seq;
+}
+
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 
@@ -432,5 +445,5 @@
 {
 public:
-   MT_SearchMessages(ASMailFolder *mf, UserData ud, const class SearchCriterium *crit)
+   MT_SearchMessages(ASMailFolder *mf, UserData ud, const SearchCriterium *crit)
       : MailThread(mf, ud) { m_Criterium = *crit;}
    virtual void WorkFunction(void)
@@ -768,5 +781,5 @@
        @return a Result with a sequence of matching uids.
     */
-   virtual Ticket SearchMessages(const class SearchCriterium *crit, UserData ud)
+   virtual Ticket SearchMessages(const SearchCriterium *crit, UserData ud)
       {
          return (new MT_SearchMessages(this, ud, crit))->Start();

Index: HeaderInfoImpl.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/mail/HeaderInfoImpl.cpp,v
retrieving revision 1.85
retrieving revision 1.86
diff -b -u -2 -r1.85 -r1.86
--- HeaderInfoImpl.cpp  8 Jan 2002 11:26:51 -0000       1.85
+++ HeaderInfoImpl.cpp  4 Jul 2002 17:22:37 -0000       1.86
@@ -42,4 +42,5 @@
 
 #include "Sequence.h"
+#include "UIdArray.h"
 
 #include "MDialogs.h"         // for MProgressInfo

Index: MMailFolder.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/mail/MMailFolder.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -b -u -2 -r1.8 -r1.9
--- MMailFolder.cpp     19 Dec 2001 12:34:38 -0000      1.8
+++ MMailFolder.cpp     4 Jul 2002 17:22:37 -0000       1.9
@@ -266,18 +266,4 @@
 }
 
-/** Utiltiy function to get a textual representation of a message
-    status.
-    @param message status
-    @param mf optional pointer to folder to treat e.g. NNTP separately
-    @return string representation
-    */
-/* static */
-String
-MMailFolder::ConvertMessageStatusToString(int status,
-                                          MailFolder *mf = NULL)
-{
-   MMAILFOLDER_MISSING();
-   return "unknown";
-}
 /** Forward one message.
     @param message message to forward
@@ -433,5 +419,5 @@
 */
 UIdArray *
-MMailFolder::SearchMessages(const class SearchCriterium *crit){ 
MMAILFOLDER_MISSING(); }
+MMailFolder::SearchMessages(const SearchCriterium *crit){ MMAILFOLDER_MISSING(); }
 
 /**@name Access control */

Index: MailFolder.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/mail/MailFolder.cpp,v
retrieving revision 1.280
retrieving revision 1.281
diff -b -u -2 -r1.280 -r1.281
--- MailFolder.cpp      28 Jun 2002 00:43:55 -0000      1.280
+++ MailFolder.cpp      4 Jul 2002 17:22:37 -0000       1.281
@@ -46,4 +46,8 @@
 #include "MailFolder.h"
 
+#include "UIdArray.h"
+#include "MFStatus.h"
+#include "LogCircle.h"
+
 // we use many MailFolderCC methods explicitly currently, this is wrong: we
 // should have some sort of a redirector to emulate virtual static methods
@@ -86,143 +90,4 @@
 
 // ----------------------------------------------------------------------------
-// MLogCircle
-// ----------------------------------------------------------------------------
-
-// remember the 10 last messages by default
-MLogCircle MailFolder::ms_LogCircle(10);
-
-MLogCircle::MLogCircle(int n)
-{
-   m_N = n;
-   m_Messages = new String[m_N];
-   m_Next = 0;
-}
-
-MLogCircle::   ~MLogCircle()
-{
-   delete [] m_Messages;
-}
-
-void
-MLogCircle:: Add(const String &txt)
-{
-   m_Messages[m_Next++] = txt;
-   if(m_Next == m_N)
-      m_Next = 0;
-}
-
-bool
-MLogCircle:: Find(const String needle, String *store) const
-{
-   // searches backwards (most relevant first)
-   // search from m_Next-1 to 0
-   if(m_Next > 0)
-      for(int i = m_Next-1; i >= 0 ; i--)
-      {
-         wxLogTrace("logcircle", "checking msg %d, %s", i, m_Messages[i].c_str());
-         if(m_Messages[i].Contains(needle))
-         {
-            if(store) *store = m_Messages[i];
-            return true;
-         }
-      }
-   // search from m_N-1 down to m_Next:
-   for(int i = m_N-1; i >= m_Next; i--)
-   {
-      wxLogTrace("logcircle", "checking msg %d, %s", i, m_Messages[i].c_str());
-      if(m_Messages[i].Contains(needle))
-      {
-         if(store) *store = m_Messages[i];
-         return true;
-      }
-   }
-
-   return false;
-}
-
-String
-MLogCircle::GetLog(void) const
-{
-   String log;
-   // search from m_Next to m_N
-   int i;
-   for(i = m_Next; i < m_N ; i++)
-      log << m_Messages[i] << '\n';
-         // search from 0 to m_Next-1:
-   for(i = 0; i < m_Next; i++)
-      log << m_Messages[i] << '\n';
-   return log;
-}
-
-/* static */
-void
-MLogCircle::GuessError(void) const
-{
-   String guess,
-          err;
-
-   if ( Find("No such host", &err) )
-   {
-      guess = _("The server name could not be resolved "
-                "(maybe the network connection is down?)");
-   }
-   else if ( Find("User unknown", &err) )
-   {
-      guess = _("One or more email addresses were not recognised.");
-   }
-   // check for various POP3 bad login/password messages
-   else if ( Find("authorization failed", &err) ||
-             Find("password wrong", &err) ||
-             Find("bad password", &err) ||
-             Find("unknown user name", &err) ||
-             Find("Bad authentication", &err) ||
-             Find("Password supplied for", &err) || // ... <email addr> is incorrect
-             Find("Invalid password", &err) ||
-             Find("Invalid login", &err) )
-   {
-      guess = _("Incorrect username or password: "
-                "please verify if they are correct.");
-   }
-   // the SMTP error messages are not redirected to MLogCircle yet anyhow...
-#if 0
-   // SMTP 554 error
-   else if ( Find("recipients failed", &err) )
-   {
-      guess = _("Mail server didn't accept one or more of the message recipients");
-   }
-#endif // 0
-   // these are generated by c-client
-   else if ( Find("INVALID_ADDRESS", &err) ||
-             Find(".SYNTAX-ERROR.", &err) )
-   {
-      guess = _("The message contained an invalid address specification.");
-   }
-   // check for various POP3 server messages telling us that another session
-   // is active
-   else if ( Find("mailbox locked", &err) ||
-             Find("lock busy", &err) ||
-             Find("[IN-USE]", &err) )
-   {
-       guess = _("The mailbox is already opened from another session, "
-                 "please close it first and retry.");
-   }
-
-   if ( !guess.empty() )
-   {
-      wxLogMessage(guess);
-      wxLogMessage(_("The exact error message was: %s"), err.c_str());
-   }
-}
-
-void
-MLogCircle::Clear(void)
-{
-   for(int i = 0; i < m_N; i++)
-   {
-      m_Messages[i].clear();
-   }
-}
-
-// ----------------------------------------------------------------------------
 // MailFolder opening
 // ----------------------------------------------------------------------------
@@ -410,221 +275,4 @@
 }
 
-// ----------------------------------------------------------------------------
-// message size
-// ----------------------------------------------------------------------------
-
-/* static */
-String MailFolder::SizeToString(unsigned long sizeBytes,
-                                unsigned long sizeLines,
-                                MessageSizeShow show,
-                                bool verbose)
-{
-   String s;
-
-   switch ( show )
-   {
-      case MessageSize_Max: // to silence gcc warning
-         FAIL_MSG( "unexpected message size format" );
-         // fall through
-
-      case MessageSize_Automatic:
-         if ( sizeLines > 0 )
-         {
-            s.Printf(_("%lu lines"),  sizeLines);
-            break;
-         }
-         // fall through
-
-      case MessageSize_AutoBytes:
-         if ( sizeBytes == 0 )
-         {
-            s = _("empty");
-         }
-         else if ( sizeBytes < 10*1024 )
-         {
-            s = SizeToString(sizeBytes, 0, MessageSize_Bytes);
-         }
-         else if ( sizeBytes < 10*1024*1024 )
-         {
-            s = SizeToString(sizeBytes, 0, MessageSize_KBytes);
-         }
-         else // Mb
-         {
-            s = SizeToString(sizeBytes, 0, MessageSize_MBytes);
-         }
-         break;
-
-      case MessageSize_Bytes:
-         s.Printf("%lu%s", sizeBytes, verbose ? _(" bytes") : "");
-         break;
-
-      case MessageSize_KBytes:
-         s.Printf(_("%lu%s"), sizeBytes / 1024,
-                              verbose ? _(" kilobytes") : _("Kb"));
-         break;
-
-      case MessageSize_MBytes:
-         s.Printf(_("%lu%s"), sizeBytes / (1024*1024),
-                              verbose ? _(" megabytes") : _("Mb"));
-         break;
-   }
-
-   return s;
-}
-
-// ----------------------------------------------------------------------------
-// message flags
-// ----------------------------------------------------------------------------
-
-/* static */ String
-MailFolder::ConvertMessageStatusToString(int status)
-{
-   String strstatus;
-
-   // in IMAP/cclient the NEW == RECENT && !SEEN while for most people it is
-   // just NEW == !SEEN
-   if ( status & MSG_STAT_RECENT )
-   {
-      // 'R' == RECENT && SEEN (doesn't make much sense if you ask me)
-      strstatus << ((status & MSG_STAT_SEEN) ? 'R' : 'N');
-   }
-   else // !recent
-   {
-      // we're interested in showing the UNSEEN messages
-      strstatus << ((status & MSG_STAT_SEEN) ? ' ' : 'U');
-   }
-
-   strstatus << ((status & MSG_STAT_FLAGGED) ? '*' : ' ')
-             << ((status & MSG_STAT_ANSWERED) ? 'A' : ' ')
-             << ((status & MSG_STAT_DELETED) ? 'D' : ' ');
-
-   return strstatus;
-}
-
-String FormatFolderStatusString(const String& format,
-                                const String& name,
-                                MailFolderStatus *status,
-                                const MailFolder *mf)
-{
-   // this is a wrapper class which catches accesses to MailFolderStatus and
-   // fills it with the info from the real folder if it is not yet initialized
-   class StatusInit
-   {
-   public:
-      StatusInit(MailFolderStatus *status,
-                 const String& name,
-                 const MailFolder *mf)
-         : m_name(name)
-      {
-         m_status = status;
-         m_mf = (MailFolder *)mf; // cast away const for IncRef()
-         SafeIncRef(m_mf);
-
-         // if we already have status, nothing to do
-         m_init = status->IsValid();
-      }
-
-      MailFolderStatus *operator->() const
-      {
-         if ( !m_init )
-         {
-            ((StatusInit *)this)->m_init = true;
-
-            // query the mail folder for info
-            MailFolder *mf;
-            if ( !m_mf )
-            {
-               MFolder_obj mfolder(m_name);
-               mf = MailFolder::OpenFolder(mfolder);
-            }
-            else // already have the folder
-            {
-               mf = m_mf;
-               mf->IncRef();
-            }
-
-            if ( mf )
-            {
-               mf->CountAllMessages(m_status);
-               mf->DecRef();
-            }
-         }
-
-         return m_status;
-      }
-
-      ~StatusInit()
-      {
-         SafeDecRef(m_mf);
-      }
-
-   private:
-      MailFolderStatus *m_status;
-      MailFolder *m_mf;
-      String m_name;
-      bool m_init;
-   } stat(status, name, mf);
-
-   String result;
-   const char *start = format.c_str();
-   for ( const char *p = start; *p; p++ )
-   {
-      if ( *p == '%' )
-      {
-         switch ( *++p )
-         {
-            case '\0':
-               wxLogWarning(_("Unexpected end of string in the status format "
-                              "string '%s'."), start);
-               p--; // avoid going beyond the end of string
-               break;
-
-            case 'f':
-               result += name;
-               break;
-
-            case 'i':               // flagged == important
-               result += strutil_ultoa(stat->flagged);
-               break;
-
-
-            case 't':               // total
-               result += strutil_ultoa(stat->total);
-               break;
-
-            case 'r':               // recent
-               result += strutil_ultoa(stat->recent);
-               break;
-
-            case 'n':               // new
-               result += strutil_ultoa(stat->newmsgs);
-               break;
-
-            case 's':               // search result
-               result += strutil_ultoa(stat->searched);
-               break;
-
-            case 'u':               // unread
-               result += strutil_ultoa(stat->unread);
-               break;
-
-            case '%':
-               result += '%';
-               break;
-
-            default:
-               wxLogWarning(_("Unknown macro '%c%c' in the status format "
-                              "string '%s'."), *(p-1), *p, start);
-         }
-      }
-      else // not a format spec
-      {
-         result += *p;
-      }
-   }
-
-   return result;
-}
-
 /* static */
 bool MailFolder::CanExit(String *which)
@@ -1311,17 +959,4 @@
 // ----------------------------------------------------------------------------
 
-extern String GetSequenceString(const UIdArray *messages)
-{
-   Sequence seq;
-
-   size_t count = messages ? messages->GetCount() : 0;
-   for ( size_t n = 0; n < count; n++ )
-   {
-      seq.Add((*messages)[n]);
-   }
-
-   return seq.GetString();
-}
-
 /* static */
 bool MailFolder::SaveMessageAsMBOX(const String& filename, const char *content)
@@ -1382,4 +1017,12 @@
 
    return ok;
+}
+
+/* static */
+MLogCircle& MailFolder::GetLogCircle(void)
+{
+   static MLogCircle s_LogCircle(10);
+
+   return s_LogCircle;
 }
 

Index: MailFolderCC.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/mail/MailFolderCC.cpp,v
retrieving revision 1.624
retrieving revision 1.625
diff -b -u -2 -r1.624 -r1.625
--- MailFolderCC.cpp    4 Jul 2002 13:53:06 -0000       1.624
+++ MailFolderCC.cpp    4 Jul 2002 17:22:38 -0000       1.625
@@ -37,4 +37,11 @@
 #include "FolderView.h"
 
+#include "UIdArray.h"
+
+#include "MFStatus.h"
+#include "MSearch.h"
+#include "LogCircle.h"
+#include "MFui.h"                      // for SizeToString
+
 #include "AddressCC.h"
 #include "MailFolderCC.h"
@@ -819,65 +826,4 @@
 
 // ----------------------------------------------------------------------------
-// FolderListing stuff (TODO: move elsewhere, i.e. in MailFolderCmn)
-// ----------------------------------------------------------------------------
-
-class FolderListingEntryCC : public FolderListingEntry
-{
-public:
-   /// The folder's name.
-   virtual const String &GetName(void) const
-      { return m_folderName;}
-   /// The folder's attribute.
-   virtual long GetAttribute(void) const
-      { return m_Attr; }
-   FolderListingEntryCC(const String &name, long attr)
-      : m_folderName(name)
-      { m_Attr = attr; }
-private:
-   const String &m_folderName;
-   long          m_Attr;
-};
-
-/** This class holds the listings of a server's folders. */
-class FolderListingCC : public FolderListing
-{
-public:
-   /// Return the delimiter character for entries in the hierarchy.
-   virtual char GetDelimiter(void) const
-      { return m_Del; }
-   /// Returns the number of entries.
-   virtual size_t CountEntries(void) const
-      { return m_list.size(); }
-   /// Returns the first entry.
-   virtual const FolderListingEntry * GetFirstEntry(iterator &i) const
-      {
-         i = m_list.begin();
-         if ( i != m_list.end() )
-            return (*i);
-         else
-            return NULL;
-      }
-   /// Returns the next entry.
-   virtual const FolderListingEntry * GetNextEntry(iterator &i) const
-      {
-         i++;
-         if ( i != m_list.end())
-            return (*i);
-         else
-            return NULL;
-      }
-   /** For our use only. */
-   void SetDelimiter(char del)
-      { m_Del = del; }
-   void Add( FolderListingEntry *entry )
-      {
-         m_list.push_back(entry);
-      }
-private:
-   char m_Del;
-   FolderListingList m_list;
-};
-
-// ----------------------------------------------------------------------------
 // Various locker classes
 // ----------------------------------------------------------------------------
@@ -1210,8 +1156,14 @@
    {
       String msg;
-      msg.Printf(_("Reading %s..."),
-                 MailFolder::SizeToString(m_readTotal, 0,
+      msg.Printf
+          (
+            _("Reading %s..."),
+            SizeToString
+            (
+               m_readTotal,
+               0,
                                           MessageSize_AutoBytes,
-                                          true /* verbose */).c_str()
+               SizeToString_Verbose
+            ).c_str()
                 );
 
@@ -1850,6 +1802,4 @@
    Init();
 
-   m_FolderListing = NULL;
-
    m_ASMailFolder = NULL;
 
@@ -5746,8 +5696,7 @@
 {
    MailFolderCC *mf = LookupObject(stream);
-   CHECK_RET(mf,"NULL mailfolder");
-   CHECK_RET(mf->m_FolderListing,"NULL mailfolder listing");
-   mf->m_FolderListing->SetDelimiter(delim);
-   mf->m_FolderListing->Add(new FolderListingEntryCC(name, attrib));
+   CHECK_RET(mf, "NULL mailfolder");
+
+   wxFAIL_MSG( "TODO" );
 }
 
@@ -6033,5 +5982,5 @@
    String spec = MailFolder::GetImapSpec(protocol, 0, mailboxname, host, "");
    return (subscribe ? mail_subscribe (NIL, (char *)spec.c_str())
-           : mail_unsubscribe (NIL, (char *)spec.c_str()) ) != NIL;
+                     : mail_unsubscribe (NIL, (char *)spec.c_str())) != NIL;
 }
 

Index: MailFolderCmn.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/mail/MailFolderCmn.cpp,v
retrieving revision 1.94
retrieving revision 1.95
diff -b -u -2 -r1.94 -r1.95
--- MailFolderCmn.cpp   15 Jun 2002 22:34:25 -0000      1.94
+++ MailFolderCmn.cpp   4 Jul 2002 17:22:38 -0000       1.95
@@ -41,4 +41,7 @@
 #include "MPython.h"
 
+#include "Sequence.h"
+#include "UIdArray.h"
+
 #include "MFolder.h"
 #include "MFilter.h"
@@ -51,7 +54,11 @@
 
 #include "MThread.h"
-
 #include "MFCache.h"
 
+#include "Composer.h"
+
+#include "MailFolderCmn.h"
+#include "MFPrivate.h"
+
 #include <wx/timer.h>
 #include <wx/datetime.h>
@@ -60,9 +67,4 @@
 
 #include "wx/persctrl.h"      // for wxPFileSelector
-
-#include "Composer.h"
-
-#include "MailFolderCmn.h"
-#include "MFPrivate.h"
 
 // ----------------------------------------------------------------------------

Index: SendMessageCC.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/mail/SendMessageCC.cpp,v
retrieving revision 1.193
retrieving revision 1.194
diff -b -u -2 -r1.193 -r1.194
--- SendMessageCC.cpp   15 Jun 2002 11:42:27 -0000      1.193
+++ SendMessageCC.cpp   4 Jul 2002 17:22:38 -0000       1.194
@@ -39,4 +39,6 @@
 #include "MFolder.h"
 
+#include "LogCircle.h"
+
 #include "MThread.h"
 



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Caffeinated soap. No kidding.
http://thinkgeek.com/sf
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to