Update of /cvsroot/mahogany/M/src/mail
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv20191/src/mail
Modified Files:
MFPool.cpp MailFolder.cpp
Log Message:
close all opened folders when the machine is suspended and reopen them on resume
Index: MFPool.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/mail/MFPool.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -b -u -2 -r1.11 -r1.12
--- MFPool.cpp 27 May 2006 15:13:56 -0000 1.11
+++ MFPool.cpp 27 May 2006 16:27:12 -0000 1.12
@@ -31,4 +31,5 @@
#include "lists.h"
+#include "MFolder.h"
#include "mail/Driver.h"
#include "mail/FolderPool.h"
@@ -54,5 +55,22 @@
String spec;
- MFConnection(MailFolder *mf_, const String& s) : spec(s) { mf = mf_; }
+ // also cache the MFolder which can be used to (re)open this mf later
+ MFolder *folder;
+
+
+ MFConnection(MailFolder *mf_, const String& spec_, const MFolder *folder_)
+ : spec(spec_)
+ {
+ mf = mf_;
+ folder = const_cast<MFolder *>(folder_);
+ if ( folder )
+ folder->IncRef();
+ }
+
+ ~MFConnection()
+ {
+ if ( folder )
+ folder->DecRef();
+ }
};
@@ -107,5 +125,5 @@
void Reset() { SetPool(gs_pool.begin()); }
- MailFolder *GetAndAdvance(String *driverName)
+ MailFolder *GetAndAdvance(String *driverName, MFolder **pFolder)
{
if ( m_iterPool == gs_pool.end() )
@@ -116,8 +134,13 @@
SetPool(++m_iterPool);
- return GetAndAdvance(driverName);
+ return GetAndAdvance(driverName, pFolder);
}
MailFolder *mf = m_iterConn->mf;
+ if ( pFolder )
+ {
+ *pFolder = m_iterConn->folder;
+ (*pFolder)->IncRef();
+ }
++m_iterConn;
@@ -226,5 +249,5 @@
CHECK_RET( !conn, _T("MFPool::Add(): folder already in the pool") );
- pool->connections.push_back(new MFConnection(mf, spec));
+ pool->connections.push_back(new MFConnection(mf, spec, folder));
wxLogTrace(TRACE_MFPOOL, _T("Added '%s' to the pool."),
mf->GetName().c_str());
@@ -306,15 +329,17 @@
/* static */
-MailFolder *MFPool::GetFirst(Cookie& cookie, String *driverName)
+MailFolder *
+MFPool::GetFirst(Cookie& cookie, String *driverName, MFolder **pFolder)
{
cookie.m_impl->Reset();
- return GetNext(cookie, driverName);
+ return GetNext(cookie, driverName, pFolder);
}
/* static */
-MailFolder *MFPool::GetNext(Cookie& cookie, String *driverName)
+MailFolder *
+MFPool::GetNext(Cookie& cookie, String *driverName, MFolder **pFolder)
{
- return cookie.m_impl->GetAndAdvance(driverName);
+ return cookie.m_impl->GetAndAdvance(driverName, pFolder);
}
Index: MailFolder.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/mail/MailFolder.cpp,v
retrieving revision 1.319
retrieving revision 1.320
diff -b -u -2 -r1.319 -r1.320
--- MailFolder.cpp 12 Feb 2006 19:09:01 -0000 1.319
+++ MailFolder.cpp 27 May 2006 16:27:12 -0000 1.320
@@ -299,13 +299,17 @@
/* static */
int
-MailFolder::CloseAll()
+MailFolder::CloseAll(MFolderList *opened)
{
// count the number of folders we close
size_t n = 0;
+ // if requested, also return the folders we closed
+ MFolder *folder = NULL;
+ MFolder ** const pFolder = opened ? &folder : NULL;
+
MFPool::Cookie cookie;
- for ( MailFolder *mf = MFPool::GetFirst(cookie);
+ for ( MailFolder *mf = MFPool::GetFirst(cookie, NULL, pFolder);
mf;
- mf = MFPool::GetNext(cookie), n++ )
+ mf = MFPool::GetNext(cookie, NULL, pFolder), n++ )
{
// if we want to close all folders we almost surely don't want to keep
@@ -316,4 +320,7 @@
MEventManager::Send(new MEventFolderClosedData(mf));
+ if ( opened )
+ opened->push_back(folder);
+
mf->DecRef();
}
-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
Mahogany-cvsupdates mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates