Update of /cvsroot/mahogany/M/src/gui
In directory usw-pr-cvs1:/tmp/cvs-serv28878/src/gui
Modified Files:
wxSubfoldersDialog.cpp
Log Message:
use newly added ListEventReceiever
Index: wxSubfoldersDialog.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxSubfoldersDialog.cpp,v
retrieving revision 1.68
retrieving revision 1.69
diff -b -u -2 -r1.68 -r1.69
--- wxSubfoldersDialog.cpp 12 Sep 2002 02:36:50 -0000 1.68
+++ wxSubfoldersDialog.cpp 8 Oct 2002 21:27:01 -0000 1.69
@@ -44,4 +44,5 @@
#include "ASMailFolder.h"
+#include "ListReceiver.h"
#include "gui/wxDialogLayout.h"
@@ -104,5 +105,5 @@
// subfolders from the ASMailFolder
class wxSubfoldersTree : public wxTreeCtrl,
- public MEventReceiver
+ public ListEventReceiver
{
public:
@@ -123,6 +124,9 @@
void OnTreeExpanding(wxTreeEvent& event);
- // event processing function
- virtual bool OnMEvent(MEventData& event);
+ // list event processing functions
+ virtual void OnListFolder(const String& path, char delim, long flags);
+
+ // called when the last folder is received
+ virtual void OnNoMoreFolders();
private:
@@ -130,7 +134,4 @@
wxTreeItemId OnNewFolder(String& name);
- // called when the last folder is received
- void OnNoMoreFolders();
-
// insert a new item named "name" under parent if it doesn't exist yet in
// alphabetical order; returns the id of the (new) item
@@ -140,7 +141,4 @@
wxString GetRelativePath(wxTreeItemId id) const;
- // MEventReceiver cookie for the event manager
- void *m_regCookie;
-
// the progress meter
MProgressInfo *m_progressInfo;
@@ -260,5 +258,5 @@
// event receiver for the list events
-class ListFolderEventReceiver : public MEventReceiver
+class ListFolderEventReceiver : public ListEventReceiver
{
public:
@@ -278,6 +276,7 @@
size_t AddAllFolders(MFolder *folder, ASMailFolder *mailFolder);
- // event processing function
- virtual bool OnMEvent(MEventData& event);
+ // list folder events processing function
+ virtual void OnListFolder(const String& path, char delim, long flags);
+ virtual void OnNoMoreFolders();
private:
@@ -352,7 +351,4 @@
m_reference = m_mailFolder->GetImapSpec();
- m_regCookie = MEventManager::Register(*this, MEventId_ASFolderResult);
- ASSERT_MSG( m_regCookie, _T("can't register with event manager"));
-
m_progressInfo = (MProgressInfo *)NULL;
m_chDelimiter = m_mailFolder->GetFolderDelimiter();
@@ -456,10 +452,14 @@
// now OnNewFolder() and OnNoMoreFolders() will be called
- (void)m_mailFolder->ListFolders
+ //
+ // NB: the cast below is needed as ListEventReceiver compares the user
+ // data in the results it gets with "this" and its this pointer is
+ // different from our "this" as we use multiple inheritance
+ m_mailFolder->ListFolders
(
"%", // everything at this tree level
FALSE, // subscribed only?
reference, // path relative to the folder
- this // data to pass to the callback
+ (ListEventReceiver *)this // data for the callback
);
@@ -479,48 +479,11 @@
}
-// needed to be able to use DECLARE_AUTOREF() macro
-typedef ASMailFolder::ResultFolderExists ASFolderExistsResult;
-DECLARE_AUTOPTR(ASFolderExistsResult);
-
-bool wxSubfoldersTree::OnMEvent(MEventData& event)
+void wxSubfoldersTree::OnListFolder(const String& spec, char delim, long attr)
{
- // we're only subscribed to the ASFolder events
- CHECK( event.GetId() == MEventId_ASFolderResult, FALSE,
- _T("unexpected event type") );
-
- MEventASFolderResultData &data = (MEventASFolderResultData &)event;
-
- ASFolderExistsResult_obj result((ASFolderExistsResult *)data.GetResult());
-
- // is this message really for us?
- if ( result->GetUserData() != this )
- {
- // no: continue with other event handlers
- return TRUE;
- }
-
- if ( result->GetOperation() != ASMailFolder::Op_ListFolders )
- {
- FAIL_MSG( _T("unexpected operation notification") );
-
- // eat the event - it was for us but we didn't process it...
- return FALSE;
- }
-
// usually, all folders will have a non NUL delimiter ('.' for news, '/'
// for everything else), but IMAP INBOX is special and can have a NUL one
- ASSERT_MSG( result->GetDelimiter() == m_chDelimiter ||
- !result->GetDelimiter(),
+ ASSERT_MSG( delim == m_chDelimiter || !delim,
_T("unexpected delimiter returned by ListFolders") );
- // is it the special event which signals that there will be no more of
- // folders?
- wxString spec = result->GetName();
- if ( !spec )
- {
- OnNoMoreFolders();
- }
- else // normal folder event
- {
if ( m_nFoldersRetrieved > PROGRESS_THRESHOLD )
{
@@ -549,5 +512,4 @@
if ( id.IsOk() )
{
- long attr = result->GetAttributes();
if ( !(attr & ASMailFolder::ATT_NOINFERIORS) )
{
@@ -578,8 +540,4 @@
wxLogDebug(_T("Folder specification '%s' unexpected."), spec.c_str());
}
- }
-
- // we don't want anyone else to receive this message - it was for us only
- return FALSE;
}
@@ -677,6 +635,4 @@
m_folder->DecRef();
m_mailFolder->DecRef();
-
- MEventManager::Deregister(m_regCookie);
}
@@ -1178,36 +1134,7 @@
}
-bool ListFolderEventReceiver::OnMEvent(MEventData& event)
+void
+ListFolderEventReceiver::OnNoMoreFolders()
{
- // we're only subscribed to the ASFolder events
- CHECK( event.GetId() == MEventId_ASFolderResult, FALSE,
- _T("unexpected event type") );
-
- MEventASFolderResultData &data = (MEventASFolderResultData &)event;
-
- ASFolderExistsResult_obj result((ASFolderExistsResult *)data.GetResult());
-
- // is this message really for us?
- if ( result->GetUserData() != this )
- {
- // no: continue with other event handlers
- return TRUE;
- }
-
- if ( result->GetOperation() != ASMailFolder::Op_ListFolders )
- {
- FAIL_MSG( _T("unexpected operation notification") );
-
- // eat the event - it was for us but we didn't process it...
- return FALSE;
- }
-
- char chDelimiter = result->GetDelimiter();
-
- // is it the special event which signals that there will be no more of
- // folders?
- wxString spec = result->GetName();
- if ( !spec )
- {
// no more folders
m_finished = true;
@@ -1223,7 +1150,11 @@
MEventManager::DispatchPending();
}
- }
- else // normal folder event
- {
+}
+
+void
+ListFolderEventReceiver::OnListFolder(const String& spec,
+ char chDelimiter,
+ long attr)
+{
// count the number of folders retrieved and show progress
m_nFoldersRetrieved++;
@@ -1276,5 +1207,4 @@
{
int flags = m_flagsParent;
- long attr = result->GetAttributes();
if ( attr & ASMailFolder::ATT_NOINFERIORS )
{
@@ -1322,8 +1252,4 @@
wxLogDebug(_T("Folder specification '%s' unexpected."), spec.c_str());
}
- }
-
- // we don't want anyone else to receive this message - it was for us only
- return FALSE;
}
-------------------------------------------------------
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