more work on playback of offline imap operations NOT YET PART OF BUILD

This commit is contained in:
bienvenu%netscape.com 2001-01-30 15:29:11 +00:00
Родитель 603d6f0dd4
Коммит b2991581d8
2 изменённых файлов: 60 добавлений и 32 удалений

Просмотреть файл

@ -35,10 +35,22 @@ static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
NS_IMPL_ISUPPORTS1(nsImapOfflineSync, nsIUrlListener)
nsImapOfflineSync::nsImapOfflineSync(nsIMsgFolder *singleFolderOnly)
nsImapOfflineSync::nsImapOfflineSync(nsIMsgWindow *window, nsIMsgFolder *singleFolderOnly)
{
NS_INIT_REFCNT();
m_singleFolderToUpdate = singleFolderOnly;
m_window = window;
mCurrentPlaybackOpType = nsIMsgOfflineImapOperation::kFlagsChanged;
m_mailboxupdatesStarted = PR_FALSE;
}
nsImapOfflineSync::~nsImapOfflineSync()
{
}
void nsImapOfflineSync::SetWindow(nsIMsgWindow *window)
{
m_window = window;
}
NS_IMETHODIMP nsImapOfflineSync::OnStartRunningUrl(nsIURI* url)
@ -89,12 +101,17 @@ void nsImapOfflineSync::ProcessFlagOperation(nsIMsgOfflineImapOperation *current
if (++currentKeyIndex < m_CurrentKeys.GetSize())
m_currentDB->GetOfflineOpForKey(m_CurrentKeys[currentKeyIndex], PR_FALSE,
&currentOp);
if (currentOp)
{
currentOp->GetFlagOperation(&flagOperation);
currentOp->GetNewFlags(&newFlags);
}
} while (currentOp && (flagOperation & nsIMsgOfflineImapOperation::kFlagsChanged) && (newFlags == matchingFlags) );
currentOp = nsnull;
if (matchingFlagKeys.GetSize() > 0)
{
nsCAutoString uids;
nsImapMailFolder::AllocateUidStringFromKeyArray(matchingFlagKeys, uids);
PRUint32 curFolderFlags;
@ -118,6 +135,9 @@ void nsImapOfflineSync::ProcessFlagOperation(nsIMsgOfflineImapOperation *current
}
}
else
ProcessNextOperation();
}
void
nsImapOfflineSync::ProcessAppendMsgOperation(nsIMsgOfflineImapOperation *currentOp, PRInt32 opType)
@ -239,7 +259,7 @@ void nsImapOfflineSync::ProcessMoveOperation(nsIMsgOfflineImapOperation *current
nsCOMPtr <nsIMsgImapMailFolder> imapFolder = do_QueryInterface(destFolder);
if (imapFolder)
rv = imapFolder->ReplayOfflineMoveCopy(uids.get(), PR_TRUE, destFolder,
this, nsnull);
this, m_window);
}
}
}
@ -299,7 +319,7 @@ void nsImapOfflineSync::ProcessCopyOperation(nsIMsgOfflineImapOperation *current
nsCOMPtr <nsIMsgImapMailFolder> imapFolder = do_QueryInterface(destFolder);
if (imapFolder)
rv = imapFolder->ReplayOfflineMoveCopy(uids.get(), PR_FALSE, destFolder,
this, nsnull);
this, m_window);
}
}
}
@ -483,6 +503,7 @@ nsresult nsImapOfflineSync::ProcessNextOperation()
}
if (m_currentFolder)
m_currentFolder->GetFlags(&folderFlags);
// do the current operation
if (m_currentDB)
@ -508,12 +529,17 @@ nsresult nsImapOfflineSync::ProcessNextOperation()
while (currentOp)
{
currentOp->GetOperation(&opType);
if (opType & mCurrentPlaybackOpType)
++m_KeyIndex;
if (! (opType & mCurrentPlaybackOpType))
{
currentOp = nsnull;
if (++m_KeyIndex < m_CurrentKeys.GetSize())
if (m_KeyIndex < m_CurrentKeys.GetSize())
m_currentDB->GetOfflineOpForKey(m_CurrentKeys[m_KeyIndex], PR_FALSE, &currentOp);
else
break;
}
else
break;
}
// if we did not find a db record that matches the current playback operation,
@ -612,6 +638,8 @@ nsresult nsImapOfflineSync::ProcessNextOperation()
AdvanceToFirstIMAPFolder();
if (m_singleFolderToUpdate)
{
m_singleFolderToUpdate->ClearFlag(MSG_FOLDER_FLAG_OFFLINEEVENTS);
m_singleFolderToUpdate->UpdateFolder(m_window);
// do we have to do anything? Old code would do a start update...
}
else
@ -635,7 +663,6 @@ nsresult nsImapOfflineSync::ProcessNextOperation()
// MSG_FolderIterator *updateFolderIterator = m_singleFolderToUpdate ? (MSG_FolderIterator *) 0 : m_folderIterator;
// we are done playing commands back, now queue up the sync with each imap folder
// If we're using the iterator, m_currentFolder will be set correctly
// nsIMsgFolder * folder = m_singleFolderToUpdate ? m_singleFolderToUpdate : m_currentFolder;

Просмотреть файл

@ -27,17 +27,17 @@
#include "nsIMsgDatabase.h"
#include "nsIUrlListener.h"
#include "nsIMsgOfflineImapOperation.h"
#include "nsIMsgWindow.h"
#include "nsIMsgFolder.h"
class nsImapOfflineSync : public nsIUrlListener {
public: // set to one folder to playback one folder only
nsImapOfflineSync(nsIMsgFolder *singleFolderOnly = nsnull);
nsImapOfflineSync(nsIMsgWindow *window, nsIMsgFolder *singleFolderOnly = nsnull);
virtual ~nsImapOfflineSync();
NS_DECL_ISUPPORTS
NS_DECL_NSIURLLISTENER
nsresult ProcessNextOperation();
nsresult ProcessNextOperation(); // this kicks off playback
PRInt32 GetCurrentUIDValidity() { return mCurrentUIDValidity; }
void SetCurrentUIDValidity(PRInt32 uidvalidity) { mCurrentUIDValidity = uidvalidity; }
@ -46,7 +46,7 @@ public: // set to one folder to playback one folder only
PRBool ProcessingStaleFolderUpdate() { return m_singleFolderToUpdate != nsnull; }
PRBool CreateOfflineFolder(nsIMsgFolder *folder);
void SetWindow(nsIMsgWindow *window);
private:
PRBool CreateOfflineFolders();
void AdvanceToNextFolder();
@ -62,6 +62,7 @@ private:
nsCOMPtr <nsIMsgFolder> m_currentFolder;
nsCOMPtr <nsIMsgFolder> m_singleFolderToUpdate;
nsCOMPtr <nsIMsgWindow> m_window;
nsMsgKeyArray m_CurrentKeys;
PRUint32 m_KeyIndex;
nsCOMPtr <nsIMsgDatabase> m_currentDB;