зеркало из https://github.com/mozilla/pjs.git
more work on playback of offline imap operations NOT YET PART OF BUILD
This commit is contained in:
Родитель
603d6f0dd4
Коммит
b2991581d8
|
@ -35,10 +35,22 @@ static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS1(nsImapOfflineSync, nsIUrlListener)
|
NS_IMPL_ISUPPORTS1(nsImapOfflineSync, nsIUrlListener)
|
||||||
|
|
||||||
nsImapOfflineSync::nsImapOfflineSync(nsIMsgFolder *singleFolderOnly)
|
nsImapOfflineSync::nsImapOfflineSync(nsIMsgWindow *window, nsIMsgFolder *singleFolderOnly)
|
||||||
{
|
{
|
||||||
NS_INIT_REFCNT();
|
NS_INIT_REFCNT();
|
||||||
m_singleFolderToUpdate = singleFolderOnly;
|
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)
|
NS_IMETHODIMP nsImapOfflineSync::OnStartRunningUrl(nsIURI* url)
|
||||||
|
@ -89,34 +101,42 @@ void nsImapOfflineSync::ProcessFlagOperation(nsIMsgOfflineImapOperation *current
|
||||||
if (++currentKeyIndex < m_CurrentKeys.GetSize())
|
if (++currentKeyIndex < m_CurrentKeys.GetSize())
|
||||||
m_currentDB->GetOfflineOpForKey(m_CurrentKeys[currentKeyIndex], PR_FALSE,
|
m_currentDB->GetOfflineOpForKey(m_CurrentKeys[currentKeyIndex], PR_FALSE,
|
||||||
¤tOp);
|
¤tOp);
|
||||||
currentOp->GetFlagOperation(&flagOperation);
|
if (currentOp)
|
||||||
currentOp->GetNewFlags(&newFlags);
|
{
|
||||||
|
currentOp->GetFlagOperation(&flagOperation);
|
||||||
|
currentOp->GetNewFlags(&newFlags);
|
||||||
|
}
|
||||||
} while (currentOp && (flagOperation & nsIMsgOfflineImapOperation::kFlagsChanged) && (newFlags == matchingFlags) );
|
} while (currentOp && (flagOperation & nsIMsgOfflineImapOperation::kFlagsChanged) && (newFlags == matchingFlags) );
|
||||||
|
|
||||||
currentOp = nsnull;
|
currentOp = nsnull;
|
||||||
|
|
||||||
nsCAutoString uids;
|
if (matchingFlagKeys.GetSize() > 0)
|
||||||
nsImapMailFolder::AllocateUidStringFromKeyArray(matchingFlagKeys, uids);
|
{
|
||||||
PRUint32 curFolderFlags;
|
nsCAutoString uids;
|
||||||
m_currentFolder->GetFlags(&curFolderFlags);
|
nsImapMailFolder::AllocateUidStringFromKeyArray(matchingFlagKeys, uids);
|
||||||
|
PRUint32 curFolderFlags;
|
||||||
|
m_currentFolder->GetFlags(&curFolderFlags);
|
||||||
|
|
||||||
if (uids && (curFolderFlags & MSG_FOLDER_FLAG_IMAPBOX))
|
if (uids && (curFolderFlags & MSG_FOLDER_FLAG_IMAPBOX))
|
||||||
{
|
{
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
nsCOMPtr <nsIMsgImapMailFolder> imapFolder = do_QueryInterface(m_currentFolder);
|
nsCOMPtr <nsIMsgImapMailFolder> imapFolder = do_QueryInterface(m_currentFolder);
|
||||||
nsCOMPtr <nsIURI> uriToSetFlags;
|
nsCOMPtr <nsIURI> uriToSetFlags;
|
||||||
if (imapFolder)
|
if (imapFolder)
|
||||||
{
|
|
||||||
rv = imapFolder->SetImapFlags(uids.get(), matchingFlags, getter_AddRefs(uriToSetFlags));
|
|
||||||
if (NS_SUCCEEDED(rv) && uriToSetFlags)
|
|
||||||
{
|
{
|
||||||
nsCOMPtr <nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(uriToSetFlags);
|
rv = imapFolder->SetImapFlags(uids.get(), matchingFlags, getter_AddRefs(uriToSetFlags));
|
||||||
if (mailnewsUrl)
|
if (NS_SUCCEEDED(rv) && uriToSetFlags)
|
||||||
mailnewsUrl->RegisterListener(this);
|
{
|
||||||
|
nsCOMPtr <nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(uriToSetFlags);
|
||||||
|
if (mailnewsUrl)
|
||||||
|
mailnewsUrl->RegisterListener(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ProcessNextOperation();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -239,7 +259,7 @@ void nsImapOfflineSync::ProcessMoveOperation(nsIMsgOfflineImapOperation *current
|
||||||
nsCOMPtr <nsIMsgImapMailFolder> imapFolder = do_QueryInterface(destFolder);
|
nsCOMPtr <nsIMsgImapMailFolder> imapFolder = do_QueryInterface(destFolder);
|
||||||
if (imapFolder)
|
if (imapFolder)
|
||||||
rv = imapFolder->ReplayOfflineMoveCopy(uids.get(), PR_TRUE, destFolder,
|
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);
|
nsCOMPtr <nsIMsgImapMailFolder> imapFolder = do_QueryInterface(destFolder);
|
||||||
if (imapFolder)
|
if (imapFolder)
|
||||||
rv = imapFolder->ReplayOfflineMoveCopy(uids.get(), PR_FALSE, destFolder,
|
rv = imapFolder->ReplayOfflineMoveCopy(uids.get(), PR_FALSE, destFolder,
|
||||||
this, nsnull);
|
this, m_window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -483,7 +503,8 @@ nsresult nsImapOfflineSync::ProcessNextOperation()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_currentFolder->GetFlags(&folderFlags);
|
if (m_currentFolder)
|
||||||
|
m_currentFolder->GetFlags(&folderFlags);
|
||||||
// do the current operation
|
// do the current operation
|
||||||
if (m_currentDB)
|
if (m_currentDB)
|
||||||
{
|
{
|
||||||
|
@ -508,12 +529,17 @@ nsresult nsImapOfflineSync::ProcessNextOperation()
|
||||||
while (currentOp)
|
while (currentOp)
|
||||||
{
|
{
|
||||||
currentOp->GetOperation(&opType);
|
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, ¤tOp);
|
m_currentDB->GetOfflineOpForKey(m_CurrentKeys[m_KeyIndex], PR_FALSE, ¤tOp);
|
||||||
|
else
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we did not find a db record that matches the current playback operation,
|
// if we did not find a db record that matches the current playback operation,
|
||||||
|
@ -612,6 +638,8 @@ nsresult nsImapOfflineSync::ProcessNextOperation()
|
||||||
AdvanceToFirstIMAPFolder();
|
AdvanceToFirstIMAPFolder();
|
||||||
if (m_singleFolderToUpdate)
|
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...
|
// do we have to do anything? Old code would do a start update...
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -635,7 +663,6 @@ nsresult nsImapOfflineSync::ProcessNextOperation()
|
||||||
// MSG_FolderIterator *updateFolderIterator = m_singleFolderToUpdate ? (MSG_FolderIterator *) 0 : m_folderIterator;
|
// 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
|
// 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
|
// If we're using the iterator, m_currentFolder will be set correctly
|
||||||
// nsIMsgFolder * folder = m_singleFolderToUpdate ? m_singleFolderToUpdate : m_currentFolder;
|
// nsIMsgFolder * folder = m_singleFolderToUpdate ? m_singleFolderToUpdate : m_currentFolder;
|
||||||
|
|
|
@ -27,17 +27,17 @@
|
||||||
#include "nsIMsgDatabase.h"
|
#include "nsIMsgDatabase.h"
|
||||||
#include "nsIUrlListener.h"
|
#include "nsIUrlListener.h"
|
||||||
#include "nsIMsgOfflineImapOperation.h"
|
#include "nsIMsgOfflineImapOperation.h"
|
||||||
|
#include "nsIMsgWindow.h"
|
||||||
#include "nsIMsgFolder.h"
|
#include "nsIMsgFolder.h"
|
||||||
|
|
||||||
class nsImapOfflineSync : public nsIUrlListener {
|
class nsImapOfflineSync : public nsIUrlListener {
|
||||||
public: // set to one folder to playback one folder only
|
public: // set to one folder to playback one folder only
|
||||||
nsImapOfflineSync(nsIMsgFolder *singleFolderOnly = nsnull);
|
nsImapOfflineSync(nsIMsgWindow *window, nsIMsgFolder *singleFolderOnly = nsnull);
|
||||||
virtual ~nsImapOfflineSync();
|
virtual ~nsImapOfflineSync();
|
||||||
|
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
NS_DECL_NSIURLLISTENER
|
NS_DECL_NSIURLLISTENER
|
||||||
nsresult ProcessNextOperation();
|
nsresult ProcessNextOperation(); // this kicks off playback
|
||||||
|
|
||||||
PRInt32 GetCurrentUIDValidity() { return mCurrentUIDValidity; }
|
PRInt32 GetCurrentUIDValidity() { return mCurrentUIDValidity; }
|
||||||
void SetCurrentUIDValidity(PRInt32 uidvalidity) { mCurrentUIDValidity = uidvalidity; }
|
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 ProcessingStaleFolderUpdate() { return m_singleFolderToUpdate != nsnull; }
|
||||||
|
|
||||||
PRBool CreateOfflineFolder(nsIMsgFolder *folder);
|
PRBool CreateOfflineFolder(nsIMsgFolder *folder);
|
||||||
|
void SetWindow(nsIMsgWindow *window);
|
||||||
private:
|
private:
|
||||||
PRBool CreateOfflineFolders();
|
PRBool CreateOfflineFolders();
|
||||||
void AdvanceToNextFolder();
|
void AdvanceToNextFolder();
|
||||||
|
@ -62,6 +62,7 @@ private:
|
||||||
|
|
||||||
nsCOMPtr <nsIMsgFolder> m_currentFolder;
|
nsCOMPtr <nsIMsgFolder> m_currentFolder;
|
||||||
nsCOMPtr <nsIMsgFolder> m_singleFolderToUpdate;
|
nsCOMPtr <nsIMsgFolder> m_singleFolderToUpdate;
|
||||||
|
nsCOMPtr <nsIMsgWindow> m_window;
|
||||||
nsMsgKeyArray m_CurrentKeys;
|
nsMsgKeyArray m_CurrentKeys;
|
||||||
PRUint32 m_KeyIndex;
|
PRUint32 m_KeyIndex;
|
||||||
nsCOMPtr <nsIMsgDatabase> m_currentDB;
|
nsCOMPtr <nsIMsgDatabase> m_currentDB;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче