Update of /cvsroot/mahogany/M/src/mail
In directory usw-pr-cvs1:/tmp/cvs-serv15592/src/mail
Modified Files:
MailFolderCC.cpp MailFolderCmn.cpp VFolder.cpp
Log Message:
1. more code refactoring to be able to use it from MFVirt: this time
the expunge event generation moved to MFCmn from MFCC
2. search now uses MFVirt and it even works -- as long as you don't try
to delete the messages from the search results folder
Index: MailFolderCC.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/mail/MailFolderCC.cpp,v
retrieving revision 1.634
retrieving revision 1.635
diff -b -u -2 -r1.634 -r1.635
--- MailFolderCC.cpp 17 Jul 2002 14:43:55 -0000 1.634
+++ MailFolderCC.cpp 17 Jul 2002 19:22:52 -0000 1.635
@@ -1703,7 +1703,4 @@
}
- m_expungedMsgnos =
- m_expungedPositions = NULL;
-
m_gotUnprocessedNewMail =
m_InCritical = false;
@@ -1729,16 +1726,4 @@
}
- // normally this one should be deleted as well but POP3 server never sends
- // us mm_expunged() (well, because it never expunges the messages until we
- // close the folder but by this time the notifications are blocked) so in
- // this case it may be left lying around
- if ( m_expungedMsgnos )
- {
- FAIL_MSG( "m_expungedMsgnos unexpectedly != NULL" );
-
- delete m_expungedMsgnos;
- delete m_expungedPositions;
- }
-
m_Profile->DecRef();
m_mfolder->DecRef();
@@ -2337,19 +2322,4 @@
// ----------------------------------------------------------------------------
-void MailFolderCC::DiscardExpungeData()
-{
- if ( m_expungedMsgnos )
- {
- // harmless but not supposed to happen
- ASSERT_MSG( m_expungedPositions, "can't be NULL if m_expungedMsgnos!" );
-
- delete m_expungedMsgnos;
- delete m_expungedPositions;
-
- m_expungedMsgnos = NULL;
- m_expungedPositions = NULL;
- }
-}
-
void
MailFolderCC::Close()
@@ -3203,7 +3173,7 @@
// for some types of folders (IMAP) mm_exists() is called from
// mail_expunge() but for the others (POP) it isn't and we have to call
- // it ourselves: check is based on the fact that m_expungedMsgnos is
+ // it ourselves: check is based on the fact that m_expungeData is
// reset in mm_exists handler
- if ( m_expungedMsgnos )
+ if ( m_expungeData )
{
RequestUpdateAfterExpunge();
@@ -4321,45 +4291,4 @@
// ----------------------------------------------------------------------------
-void MailFolderCC::RequestUpdateAfterExpunge()
-{
- CHECK_RET( m_expungedMsgnos, "shouldn't be called if we didn't expunge" );
-
- // FIXME: we ignore IsUpdateSuspended() here, should we? and if not,
- // what to do?
-
- // we can update the status faster here as we have decremented the
- // number of recent/unseen/... when the messages were deleted (before
- // being expunged), so we just have to update the total now
- //
- // NB: although this has all chances to break down with manual expunge
- // or even with automatic one due to race condition (if the
- // message status changed from outside...) - but this is so much
- // faster and the problem is not really fatal that I still prefer
- // to do it like this
- MailFolderStatus status;
- MfStatusCache *mfStatusCache = MfStatusCache::Get();
- if ( mfStatusCache->GetStatus(GetName(), &status) )
- {
- // caller is supposed to check for this!
- CHECK_RET( m_MailStream, "UpdateStatusAfterExpunge(): dead stream" );
-
- status.total = m_MailStream->nmsgs;
-
- mfStatusCache->UpdateStatus(GetName(), status);
- }
-
- // tell GUI to update
- wxLogTrace(TRACE_MF_EVENTS, "Sending FolderExpunged event for folder '%s'",
- GetName().c_str());
-
- MEventManager::Send(new MEventFolderExpungeData(this,
- m_expungedMsgnos,
- m_expungedPositions));
-
- // MEventFolderExpungeData() will delete them
- m_expungedMsgnos =
- m_expungedPositions = NULL;
-}
-
void MailFolderCC::OnMailExists(struct mail_stream *stream, MsgnoType msgnoMax)
{
@@ -4413,6 +4342,6 @@
m_gotUnprocessedNewMail = true;
- // NB: if we have m_expungedMsgnos, leave them for now and don't
- // discard them as we used to do because if all new mail is
+ // NB: if we have m_expungeData, leave it for now and don't
+ // discard it as we used to do because if all new mail is
// filtered away, we'd still have to notify the GUI about these
// expunged messages
@@ -4447,5 +4376,5 @@
{
// anything expunged?
- if ( m_expungedMsgnos )
+ if ( m_expungeData )
{
RequestUpdateAfterExpunge();
@@ -4479,16 +4408,15 @@
// after all mm_expunged() as it is much faster to delete all
// messages at once instead of one at a time
- if ( !m_expungedMsgnos )
+ if ( !m_expungeData )
{
// create new arrays
- m_expungedMsgnos = new wxArrayInt;
- m_expungedPositions = new wxArrayInt;
+ m_expungeData = new ExpungeData;
}
// add the msgno to the list of expunged messages
- m_expungedMsgnos->Add(msgno);
+ m_expungeData->msgnos.Add(msgno);
// and remember its position as well
- m_expungedPositions->Add(m_headers->GetPosFromIdx(idx));
+ m_expungeData->positions.Add(m_headers->GetPosFromIdx(idx));
}
@@ -4628,5 +4556,5 @@
{
// we might want to notify about the delayed message expunging
- if ( m_expungedMsgnos )
+ if ( m_expungeData )
{
RequestUpdateAfterExpunge();
Index: MailFolderCmn.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/mail/MailFolderCmn.cpp,v
retrieving revision 1.100
retrieving revision 1.101
diff -b -u -2 -r1.100 -r1.101
--- MailFolderCmn.cpp 17 Jul 2002 14:43:56 -0000 1.100
+++ MailFolderCmn.cpp 17 Jul 2002 19:22:52 -0000 1.101
@@ -613,4 +613,5 @@
m_statusChangeData = NULL;
+ m_expungeData = NULL;
m_MEventReceiver = new MfCmnEventReceiver(this);
@@ -630,4 +631,13 @@
}
+ // normally this one should be deleted as well
+ if ( m_expungeData )
+ {
+ FAIL_MSG( "m_expungeData unexpectedly != NULL" );
+
+ delete m_expungeData;
+ }
+
+
delete m_Timer;
delete m_MEventReceiver;
@@ -2192,4 +2202,56 @@
// MEventMsgStatusData will delete them
m_statusChangeData = NULL;
+}
+
+// ----------------------------------------------------------------------------
+// MailFolderCmn expunge data
+// ----------------------------------------------------------------------------
+
+void MailFolderCmn::DiscardExpungeData()
+{
+ if ( m_expungeData )
+ {
+ delete m_expungeData;
+
+ m_expungeData = NULL;
+ }
+}
+
+void MailFolderCmn::RequestUpdateAfterExpunge()
+{
+ CHECK_RET( m_expungeData, "shouldn't be called if we didn't expunge" );
+
+ // FIXME: we ignore IsUpdateSuspended() here, should we? and if not,
+ // what to do?
+
+ // we can update the status faster here as we have decremented the
+ // number of recent/unseen/... when the messages were deleted (before
+ // being expunged), so we just have to update the total now
+ //
+ // NB: although this has all chances to break down with manual expunge
+ // or even with automatic one due to race condition (if the
+ // message status changed from outside...) - but this is so much
+ // faster and the problem is not really fatal that I still prefer
+ // to do it like this
+ MailFolderStatus status;
+ MfStatusCache *mfStatusCache = MfStatusCache::Get();
+ if ( mfStatusCache->GetStatus(GetName(), &status) )
+ {
+ // caller is supposed to check for this!
+ CHECK_RET( IsOpened(), "RequestUpdateAfterExpunge(): closed folder?" );
+
+ status.total = GetMessageCount();
+
+ mfStatusCache->UpdateStatus(GetName(), status);
+ }
+
+ // tell GUI to update
+ wxLogTrace(TRACE_MF_EVENTS, "Sending FolderExpunged event for folder '%s'",
+ GetName().c_str());
+
+ MEventManager::Send(new MEventFolderExpungeData(this, m_expungeData));
+
+ // MEventFolderExpungeData() will delete the data
+ m_expungeData = NULL;
}
Index: VFolder.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/mail/VFolder.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -b -u -2 -r1.4 -r1.5
--- VFolder.cpp 17 Jul 2002 14:43:56 -0000 1.4
+++ VFolder.cpp 17 Jul 2002 19:22:52 -0000 1.5
@@ -289,8 +289,26 @@
CHECK_RET( cookie < GetMsgCount(), "invalid UID in MailFolderVirt" );
+ CHECK_RET( m_headers, "no HeaderInfoList in MailFolderVirt::DeleteMsg()?" );
+
+ // collect the information about the expunged messages to notify the GUI
+ // about them later
+ if ( !m_expungeData )
+ {
+ m_expungeData = new ExpungeData;
+ }
+
+ // the cookie already contains the index of the next item so normally we
+ // should decrement it but it's already ok as msgno, so use it first and
+ // decrement later to make it the correct index
+ m_expungeData->msgnos.Add(cookie--);
+ m_expungeData->positions.Add(m_headers->GetPosFromIdx(cookie));
+
+ // also let the headers object know that this header doesn't exist any more
+ m_headers->OnRemove(cookie);
+
+ // finally, really delete the message
delete m_messages[cookie];
- // the indices are now shifted, so modify the cookie
- m_messages.RemoveAt(cookie--);
+ m_messages.RemoveAt(cookie);
}
@@ -336,28 +354,25 @@
break;
- Sequence subseq;
- subseq.Add(msg->mf->GetMsgnoFromUID(msg->uid));
+ HeaderInfoList_obj hil = msg->mf->GetHeaders();
- // we rely on the fact that headers array contains pointers to HeaderInfo
- // objects so we can fill them by passing the same pointer to
- // GetHeaderInfo()
- HeaderInfo * const hi = headers[count++];
+ HeaderInfo * const hiDst = headers[count++];
+ const HeaderInfo * const hiSrc = hil->GetEntryUId(msg->uid);
+ if ( !hiSrc )
+ {
+ FAIL_MSG( "failed to get header info in virtual folder" );
+ break;
+ }
- ArrayHeaderInfo subhdrs;
- subhdrs.Add(hi);
+ *hiDst = *hiSrc;
- if ( msg->mf->GetHeaderInfo(subhdrs, subseq) )
- {
- // override some fields
+ // override some fields:
// UID must refer to this folder, not the other one (notice that count
// is already incremented, as it should be -- UIDs == msgnos start
// from 1, not 0)
- hi->m_UId = count;
+ hiDst->m_UId = count;
// and we maintain our own, independent flags
- hi->m_Status = msg->flags;
- }
- //else: what to do on failure? (FIXME)
+ hiDst->m_Status = msg->flags;
}
@@ -603,4 +618,9 @@
DeleteMsg(cookie);
}
+ }
+
+ if ( m_expungeData )
+ {
+ RequestUpdateAfterExpunge();
}
}
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates