зеркало из https://github.com/mozilla/pjs.git
fix fast delete breaking delete, r=mscott 32742
This commit is contained in:
Родитель
ef6741cbff
Коммит
9e5e574372
|
@ -63,6 +63,7 @@ interface nsIImapIncomingServer : nsISupports {
|
||||||
attribute boolean fetchByChunks;
|
attribute boolean fetchByChunks;
|
||||||
attribute boolean mimePartsOnDemand;
|
attribute boolean mimePartsOnDemand;
|
||||||
attribute boolean isAOLServer;
|
attribute boolean isAOLServer;
|
||||||
|
attribute boolean aOLMailboxView;
|
||||||
void GetImapConnectionAndLoadUrl(in nsIEventQueue aClientEventQueue,
|
void GetImapConnectionAndLoadUrl(in nsIEventQueue aClientEventQueue,
|
||||||
in nsIImapUrl aImapUrl,
|
in nsIImapUrl aImapUrl,
|
||||||
in nsISupports aConsumer);
|
in nsISupports aConsumer);
|
||||||
|
|
|
@ -124,7 +124,7 @@ NS_IMETHODIMP nsImapIncomingServer::SetKey(const char * aKey) // override nsMsg
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
hostSession->AddHostToList(aKey);
|
hostSession->AddHostToList(aKey);
|
||||||
nsMsgImapDeleteModel deleteModel;
|
nsMsgImapDeleteModel deleteModel = nsMsgImapDeleteModels::MoveToTrash; // default to trash
|
||||||
GetDeleteModel(&deleteModel);
|
GetDeleteModel(&deleteModel);
|
||||||
hostSession->SetDeleteIsMoveToTrashForHost(aKey, deleteModel == nsMsgImapDeleteModels::MoveToTrash);
|
hostSession->SetDeleteIsMoveToTrashForHost(aKey, deleteModel == nsMsgImapDeleteModels::MoveToTrash);
|
||||||
hostSession->SetShowDeletedMessagesForHost(aKey, deleteModel == nsMsgImapDeleteModels::IMAPDelete);
|
hostSession->SetShowDeletedMessagesForHost(aKey, deleteModel == nsMsgImapDeleteModels::IMAPDelete);
|
||||||
|
@ -224,6 +224,9 @@ NS_IMPL_SERVERPREF_BOOL(nsImapIncomingServer, FetchByChunks,
|
||||||
NS_IMPL_SERVERPREF_BOOL(nsImapIncomingServer, MimePartsOnDemand,
|
NS_IMPL_SERVERPREF_BOOL(nsImapIncomingServer, MimePartsOnDemand,
|
||||||
"mime_parts_on_demand");
|
"mime_parts_on_demand");
|
||||||
|
|
||||||
|
NS_IMPL_SERVERPREF_BOOL(nsImapIncomingServer, AOLMailboxView,
|
||||||
|
"aol_mailbox_view");
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsImapIncomingServer::GetIsAOLServer(PRBool *aBool)
|
nsImapIncomingServer::GetIsAOLServer(PRBool *aBool)
|
||||||
{
|
{
|
||||||
|
@ -249,41 +252,43 @@ nsImapIncomingServer::GetImapConnectionAndLoadUrl(nsIEventQueue * aClientEventQu
|
||||||
nsIImapUrl* aImapUrl,
|
nsIImapUrl* aImapUrl,
|
||||||
nsISupports* aConsumer)
|
nsISupports* aConsumer)
|
||||||
{
|
{
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
nsCOMPtr <nsIImapProtocol> aProtocol;
|
nsCOMPtr <nsIImapProtocol> aProtocol;
|
||||||
|
|
||||||
rv = CreateImapConnection(aClientEventQueue, aImapUrl, getter_AddRefs(aProtocol));
|
rv = CreateImapConnection(aClientEventQueue, aImapUrl, getter_AddRefs(aProtocol));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(aImapUrl, &rv);
|
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(aImapUrl, &rv);
|
||||||
if (aProtocol)
|
if (aProtocol)
|
||||||
|
{
|
||||||
|
rv = aProtocol->LoadUrl(mailnewsurl, aConsumer);
|
||||||
|
// *** jt - in case of the time out situation or the connection gets
|
||||||
|
// terminated by some unforseen problems let's give it a second chance
|
||||||
|
// to run the url
|
||||||
|
if (NS_FAILED(rv))
|
||||||
{
|
{
|
||||||
|
NS_ASSERTION(PR_FALSE, "shouldn't get an error loading url");
|
||||||
rv = aProtocol->LoadUrl(mailnewsurl, aConsumer);
|
rv = aProtocol->LoadUrl(mailnewsurl, aConsumer);
|
||||||
// *** jt - in case of the time out situation or the connection gets
|
|
||||||
// terminated by some unforseen problems let's give it a second chance
|
|
||||||
// to run the url
|
|
||||||
if (NS_FAILED(rv))
|
|
||||||
{
|
|
||||||
rv = aProtocol->LoadUrl(mailnewsurl, aConsumer);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// *** jt - alert user that error has occurred
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // unable to get an imap connection to run the url; add to the url
|
{
|
||||||
// queue
|
// *** jt - alert user that error has occurred
|
||||||
PR_CEnterMonitor(this);
|
|
||||||
nsCOMPtr <nsISupports> supports(do_QueryInterface(aImapUrl));
|
|
||||||
if (supports)
|
|
||||||
m_urlQueue->AppendElement(supports);
|
|
||||||
m_urlConsumers.AppendElement((void*)aConsumer);
|
|
||||||
NS_IF_ADDREF(aConsumer);
|
|
||||||
PR_CExitMonitor(this);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // unable to get an imap connection to run the url; add to the url
|
||||||
|
// queue
|
||||||
|
PR_CEnterMonitor(this);
|
||||||
|
nsCOMPtr <nsISupports> supports(do_QueryInterface(aImapUrl));
|
||||||
|
// printf("queueing imap url \n");
|
||||||
|
if (supports)
|
||||||
|
m_urlQueue->AppendElement(supports);
|
||||||
|
m_urlConsumers.AppendElement((void*)aConsumer);
|
||||||
|
NS_IF_ADDREF(aConsumer);
|
||||||
|
PR_CExitMonitor(this);
|
||||||
|
}
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
// checks to see if there are any queued urls on this incoming server,
|
// checks to see if there are any queued urls on this incoming server,
|
||||||
|
@ -291,49 +296,53 @@ nsImapIncomingServer::GetImapConnectionAndLoadUrl(nsIEventQueue * aClientEventQu
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsImapIncomingServer::LoadNextQueuedUrl(PRBool *aResult)
|
nsImapIncomingServer::LoadNextQueuedUrl(PRBool *aResult)
|
||||||
{
|
{
|
||||||
PRUint32 cnt = 0;
|
PRUint32 cnt = 0;
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
PRBool urlRun = PR_FALSE;
|
PRBool urlRun = PR_FALSE;
|
||||||
|
|
||||||
PR_CEnterMonitor(this);
|
PR_CEnterMonitor(this);
|
||||||
m_urlQueue->Count(&cnt);
|
m_urlQueue->Count(&cnt);
|
||||||
if (cnt > 0)
|
|
||||||
|
// printf("loading next url, cnt = %ld\n", cnt);
|
||||||
|
|
||||||
|
if (cnt > 0)
|
||||||
|
{
|
||||||
|
nsCOMPtr<nsISupports>
|
||||||
|
aSupport(getter_AddRefs(m_urlQueue->ElementAt(0)));
|
||||||
|
nsCOMPtr<nsIImapUrl>
|
||||||
|
aImapUrl(do_QueryInterface(aSupport, &rv));
|
||||||
|
|
||||||
|
if (aImapUrl)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsISupports>
|
nsISupports *aConsumer =
|
||||||
aSupport(getter_AddRefs(m_urlQueue->ElementAt(0)));
|
(nsISupports*)m_urlConsumers.ElementAt(0);
|
||||||
nsCOMPtr<nsIImapUrl>
|
|
||||||
aImapUrl(do_QueryInterface(aSupport, &rv));
|
|
||||||
|
|
||||||
if (aImapUrl)
|
NS_IF_ADDREF(aConsumer);
|
||||||
{
|
|
||||||
nsISupports *aConsumer =
|
|
||||||
(nsISupports*)m_urlConsumers.ElementAt(0);
|
|
||||||
|
|
||||||
NS_IF_ADDREF(aConsumer);
|
nsCOMPtr <nsIImapProtocol> protocolInstance ;
|
||||||
|
rv = CreateImapConnection(nsnull, aImapUrl,
|
||||||
|
getter_AddRefs(protocolInstance));
|
||||||
|
if (NS_SUCCEEDED(rv) && protocolInstance)
|
||||||
|
{
|
||||||
|
nsCOMPtr<nsIURI> url = do_QueryInterface(aImapUrl, &rv);
|
||||||
|
if (NS_SUCCEEDED(rv) && url)
|
||||||
|
{
|
||||||
|
rv = protocolInstance->LoadUrl(url, aConsumer);
|
||||||
|
NS_ASSERTION(NS_SUCCEEDED(rv), "failed running queued url");
|
||||||
|
urlRun = PR_TRUE;
|
||||||
|
}
|
||||||
|
m_urlQueue->RemoveElementAt(0);
|
||||||
|
m_urlConsumers.RemoveElementAt(0);
|
||||||
|
}
|
||||||
|
|
||||||
nsCOMPtr <nsIImapProtocol> protocolInstance ;
|
NS_IF_RELEASE(aConsumer);
|
||||||
rv = CreateImapConnection(nsnull, aImapUrl,
|
|
||||||
getter_AddRefs(protocolInstance));
|
|
||||||
if (NS_SUCCEEDED(rv) && protocolInstance)
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsIURI> url = do_QueryInterface(aImapUrl, &rv);
|
|
||||||
if (NS_SUCCEEDED(rv) && url)
|
|
||||||
{
|
|
||||||
rv = protocolInstance->LoadUrl(url, aConsumer);
|
|
||||||
urlRun = PR_TRUE;
|
|
||||||
}
|
|
||||||
m_urlQueue->RemoveElementAt(0);
|
|
||||||
m_urlConsumers.RemoveElementAt(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IF_RELEASE(aConsumer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (aResult)
|
if (aResult)
|
||||||
*aResult = urlRun;
|
*aResult = urlRun;
|
||||||
|
|
||||||
PR_CExitMonitor(this);
|
PR_CExitMonitor(this);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -397,65 +406,72 @@ nsImapIncomingServer::CreateImapConnection(nsIEventQueue *aEventQueue,
|
||||||
nsIImapProtocol ** aImapConnection)
|
nsIImapProtocol ** aImapConnection)
|
||||||
{
|
{
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
PRBool canRunUrl = PR_FALSE;
|
PRBool canRunUrlImmediately = PR_FALSE;
|
||||||
PRBool hasToWait = PR_FALSE;
|
PRBool canRunButBusy = PR_FALSE;
|
||||||
nsCOMPtr<nsIImapProtocol> connection;
|
nsCOMPtr<nsIImapProtocol> connection;
|
||||||
nsCOMPtr<nsIImapProtocol> freeConnection;
|
nsCOMPtr<nsIImapProtocol> freeConnection;
|
||||||
PRBool isBusy = PR_FALSE;
|
PRBool isBusy = PR_FALSE;
|
||||||
PRBool isInboxConnection = PR_FALSE;
|
PRBool isInboxConnection = PR_FALSE;
|
||||||
nsXPIDLCString redirectorType;
|
nsXPIDLCString redirectorType;
|
||||||
|
|
||||||
PR_CEnterMonitor(this);
|
PR_CEnterMonitor(this);
|
||||||
|
|
||||||
GetRedirectorType(getter_Copies(redirectorType));
|
GetRedirectorType(getter_Copies(redirectorType));
|
||||||
PRBool redirectLogon = ((const char *) redirectorType && nsCRT::strlen((const char *) redirectorType) > 0);
|
PRBool redirectLogon = ((const char *) redirectorType && nsCRT::strlen((const char *) redirectorType) > 0);
|
||||||
|
|
||||||
PRInt32 maxConnections = 5; // default to be five
|
PRInt32 maxConnections = 5; // default to be five
|
||||||
rv = GetMaximumConnectionsNumber(&maxConnections);
|
rv = GetMaximumConnectionsNumber(&maxConnections);
|
||||||
if (NS_FAILED(rv) || maxConnections == 0)
|
if (NS_FAILED(rv) || maxConnections == 0)
|
||||||
{
|
{
|
||||||
maxConnections = 5;
|
maxConnections = 5;
|
||||||
rv = SetMaximumConnectionsNumber(maxConnections);
|
rv = SetMaximumConnectionsNumber(maxConnections);
|
||||||
}
|
}
|
||||||
else if (maxConnections < 2)
|
else if (maxConnections < 2)
|
||||||
{ // forced to use at least 2
|
{ // forced to use at least 2
|
||||||
maxConnections = 2;
|
maxConnections = 2;
|
||||||
rv = SetMaximumConnectionsNumber(maxConnections);
|
rv = SetMaximumConnectionsNumber(maxConnections);
|
||||||
}
|
}
|
||||||
|
|
||||||
*aImapConnection = nsnull;
|
*aImapConnection = nsnull;
|
||||||
// iterate through the connection cache for a connection that can handle this url.
|
// iterate through the connection cache for a connection that can handle this url.
|
||||||
PRUint32 cnt;
|
PRUint32 cnt;
|
||||||
nsCOMPtr<nsISupports> aSupport;
|
nsCOMPtr<nsISupports> aSupport;
|
||||||
|
|
||||||
rv = m_connectionCache->Count(&cnt);
|
rv = m_connectionCache->Count(&cnt);
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
for (PRUint32 i = 0; i < cnt && !canRunUrl && !hasToWait; i++)
|
// loop until we find a connection that can run the url, or doesn't have to wait?
|
||||||
|
for (PRUint32 i = 0; i < cnt && !canRunUrlImmediately && !canRunButBusy; i++)
|
||||||
{
|
{
|
||||||
aSupport = getter_AddRefs(m_connectionCache->ElementAt(i));
|
aSupport = getter_AddRefs(m_connectionCache->ElementAt(i));
|
||||||
connection = do_QueryInterface(aSupport);
|
connection = do_QueryInterface(aSupport);
|
||||||
if (connection)
|
if (connection)
|
||||||
rv = connection->CanHandleUrl(aImapUrl, &canRunUrl, &hasToWait);
|
rv = connection->CanHandleUrl(aImapUrl, &canRunUrlImmediately, &canRunButBusy);
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
{
|
{
|
||||||
connection = null_nsCOMPtr();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!freeConnection && !canRunUrl && !hasToWait && connection)
|
|
||||||
{
|
|
||||||
rv = connection->IsBusy(&isBusy, &isInboxConnection);
|
|
||||||
if (NS_FAILED(rv)) continue;
|
|
||||||
if (!isBusy && !isInboxConnection)
|
|
||||||
freeConnection = connection;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ConnectionTimeOut(connection))
|
|
||||||
connection = null_nsCOMPtr();
|
connection = null_nsCOMPtr();
|
||||||
if (ConnectionTimeOut(freeConnection))
|
continue;
|
||||||
freeConnection = null_nsCOMPtr();
|
}
|
||||||
|
// if we haven't found a free connection, and this connection
|
||||||
|
// is wrong, but it's not busy.
|
||||||
|
if (!freeConnection && !canRunUrlImmediately && !canRunButBusy && connection)
|
||||||
|
{
|
||||||
|
rv = connection->IsBusy(&isBusy, &isInboxConnection);
|
||||||
|
if (NS_FAILED(rv))
|
||||||
|
continue;
|
||||||
|
if (!isBusy && !isInboxConnection)
|
||||||
|
freeConnection = connection;
|
||||||
|
}
|
||||||
|
// don't leave this loop with connection set if we can't use it!
|
||||||
|
if (!canRunButBusy && !canRunUrlImmediately)
|
||||||
|
connection = null_nsCOMPtr();
|
||||||
|
}
|
||||||
|
|
||||||
if (redirectLogon && (!connection || !canRunUrl))
|
if (ConnectionTimeOut(connection))
|
||||||
|
connection = null_nsCOMPtr();
|
||||||
|
if (ConnectionTimeOut(freeConnection))
|
||||||
|
freeConnection = null_nsCOMPtr();
|
||||||
|
|
||||||
|
if (redirectLogon && (!connection || !canRunUrlImmediately))
|
||||||
{
|
{
|
||||||
// here's where we'd start the asynchronous process of requesting a connection to the
|
// here's where we'd start the asynchronous process of requesting a connection to the
|
||||||
// AOL Imap server and getting back an ip address, port #, and cookie.
|
// AOL Imap server and getting back an ip address, port #, and cookie.
|
||||||
|
@ -470,34 +486,34 @@ nsImapIncomingServer::CreateImapConnection(nsIEventQueue *aEventQueue,
|
||||||
rv = mailnewsUrl->GetMsgWindow(getter_AddRefs(aMsgWindow));
|
rv = mailnewsUrl->GetMsgWindow(getter_AddRefs(aMsgWindow));
|
||||||
|
|
||||||
RequestOverrideInfo(aMsgWindow);
|
RequestOverrideInfo(aMsgWindow);
|
||||||
hasToWait = PR_TRUE;
|
canRunButBusy = PR_TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if we got here and we have a connection, then we should return it!
|
// if we got here and we have a connection, then we should return it!
|
||||||
if (canRunUrl && connection)
|
if (canRunUrlImmediately && connection)
|
||||||
{
|
{
|
||||||
*aImapConnection = connection;
|
*aImapConnection = connection;
|
||||||
NS_IF_ADDREF(*aImapConnection);
|
NS_IF_ADDREF(*aImapConnection);
|
||||||
}
|
}
|
||||||
else if (hasToWait)
|
else if (canRunButBusy)
|
||||||
{
|
{
|
||||||
// do nothing; return NS_OK; for queuing
|
// do nothing; return NS_OK; for queuing
|
||||||
}
|
}
|
||||||
else if (cnt < ((PRUint32)maxConnections) && aEventQueue)
|
else if (cnt < ((PRUint32)maxConnections) && aEventQueue)
|
||||||
{
|
{
|
||||||
rv = CreateProtocolInstance(aEventQueue, aImapConnection);
|
rv = CreateProtocolInstance(aEventQueue, aImapConnection);
|
||||||
}
|
}
|
||||||
else if (freeConnection)
|
else if (freeConnection)
|
||||||
{
|
{
|
||||||
*aImapConnection = freeConnection;
|
*aImapConnection = freeConnection;
|
||||||
NS_IF_ADDREF(*aImapConnection);
|
NS_IF_ADDREF(*aImapConnection);
|
||||||
}
|
}
|
||||||
else // cannot get anyone to handle the url queue it
|
else // cannot get anyone to handle the url queue it
|
||||||
{
|
{
|
||||||
// queue the url
|
// queue the url
|
||||||
}
|
}
|
||||||
|
|
||||||
PR_CExitMonitor(this);
|
PR_CExitMonitor(this);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1439,7 +1455,7 @@ NS_IMETHODIMP nsImapIncomingServer::PseudoInterruptMsgLoad(nsIImapUrl *aImapUrl,
|
||||||
{
|
{
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
PRBool canRunUrl = PR_FALSE;
|
PRBool canRunUrl = PR_FALSE;
|
||||||
PRBool hasToWait = PR_FALSE;
|
PRBool canRunButBusy = PR_FALSE;
|
||||||
nsCOMPtr<nsIImapProtocol> connection;
|
nsCOMPtr<nsIImapProtocol> connection;
|
||||||
|
|
||||||
PR_CEnterMonitor(this);
|
PR_CEnterMonitor(this);
|
||||||
|
@ -1451,7 +1467,7 @@ NS_IMETHODIMP nsImapIncomingServer::PseudoInterruptMsgLoad(nsIImapUrl *aImapUrl,
|
||||||
|
|
||||||
rv = m_connectionCache->Count(&cnt);
|
rv = m_connectionCache->Count(&cnt);
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
for (PRUint32 i = 0; i < cnt && !canRunUrl && !hasToWait; i++)
|
for (PRUint32 i = 0; i < cnt && !canRunUrl && !canRunButBusy; i++)
|
||||||
{
|
{
|
||||||
aSupport = getter_AddRefs(m_connectionCache->ElementAt(i));
|
aSupport = getter_AddRefs(m_connectionCache->ElementAt(i));
|
||||||
connection = do_QueryInterface(aSupport);
|
connection = do_QueryInterface(aSupport);
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "nsIImapServerSink.h"
|
#include "nsIImapServerSink.h"
|
||||||
#include "nsIStringBundle.h"
|
#include "nsIStringBundle.h"
|
||||||
#include "nsIMsgLogonRedirector.h"
|
#include "nsIMsgLogonRedirector.h"
|
||||||
|
#include "nsINntpProtocol.h"
|
||||||
|
|
||||||
/* get some implementation from nsMsgIncomingServer */
|
/* get some implementation from nsMsgIncomingServer */
|
||||||
class nsImapIncomingServer : public nsMsgIncomingServer,
|
class nsImapIncomingServer : public nsMsgIncomingServer,
|
||||||
|
|
|
@ -758,6 +758,8 @@ NS_IMETHODIMP nsImapMailFolder::GetHierarchyDelimiter(PRUnichar *aHierarchyDelim
|
||||||
|
|
||||||
NS_IMETHODIMP nsImapMailFolder::SetBoxFlags(PRInt32 aBoxFlags)
|
NS_IMETHODIMP nsImapMailFolder::SetBoxFlags(PRInt32 aBoxFlags)
|
||||||
{
|
{
|
||||||
|
ReadDBFolderInfo(PR_FALSE);
|
||||||
|
|
||||||
m_boxFlags = aBoxFlags;
|
m_boxFlags = aBoxFlags;
|
||||||
PRUint32 newFlags = mFlags;
|
PRUint32 newFlags = mFlags;
|
||||||
|
|
||||||
|
@ -771,10 +773,11 @@ NS_IMETHODIMP nsImapMailFolder::SetBoxFlags(PRInt32 aBoxFlags)
|
||||||
newFlags |= MSG_FOLDER_FLAG_TRASH;
|
newFlags |= MSG_FOLDER_FLAG_TRASH;
|
||||||
else
|
else
|
||||||
newFlags &= ~MSG_FOLDER_FLAG_TRASH;
|
newFlags &= ~MSG_FOLDER_FLAG_TRASH;
|
||||||
if (m_boxFlags & kImapSent)
|
// imap code doesn't seem to be setting this flag, so we shouldn't be either :-(
|
||||||
newFlags |= MSG_FOLDER_FLAG_SENTMAIL;
|
// if (m_boxFlags & kImapSent)
|
||||||
else
|
// newFlags |= MSG_FOLDER_FLAG_SENTMAIL;
|
||||||
newFlags &= ~MSG_FOLDER_FLAG_SENTMAIL;
|
// else
|
||||||
|
// newFlags &= ~MSG_FOLDER_FLAG_SENTMAIL;
|
||||||
if (m_boxFlags & kNoselect)
|
if (m_boxFlags & kNoselect)
|
||||||
newFlags |= MSG_FOLDER_FLAG_IMAP_NOSELECT;
|
newFlags |= MSG_FOLDER_FLAG_IMAP_NOSELECT;
|
||||||
else
|
else
|
||||||
|
@ -1161,6 +1164,8 @@ NS_IMETHODIMP nsImapMailFolder::ReadFromFolderCacheElem(nsIMsgFolderCacheElement
|
||||||
rv = element->GetStringProperty("onlineName", getter_Copies(onlineName));
|
rv = element->GetStringProperty("onlineName", getter_Copies(onlineName));
|
||||||
if (NS_SUCCEEDED(rv) && (const char *) onlineName && nsCRT::strlen((const char *) onlineName))
|
if (NS_SUCCEEDED(rv) && (const char *) onlineName && nsCRT::strlen((const char *) onlineName))
|
||||||
m_onlineFolderName.Assign(onlineName);
|
m_onlineFolderName.Assign(onlineName);
|
||||||
|
if (!nsCRT::strcasecmp((const char *) onlineName, "Sent"))
|
||||||
|
printf("loading folder cache elem for %s flags = %lx", (const char *) onlineName, mFlags);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1415,6 +1420,8 @@ NS_IMETHODIMP nsImapMailFolder::DeleteMessages(nsISupportsArray *messages,
|
||||||
rv = rootFolder->GetFoldersWithFlag(MSG_FOLDER_FLAG_TRASH,
|
rv = rootFolder->GetFoldersWithFlag(MSG_FOLDER_FLAG_TRASH,
|
||||||
1, &numFolders,
|
1, &numFolders,
|
||||||
getter_AddRefs(trashFolder));
|
getter_AddRefs(trashFolder));
|
||||||
|
NS_ASSERTION(NS_SUCCEEDED(rv) && trashFolder != 0, "couldn't find trash");
|
||||||
|
|
||||||
// if we can't find the trash, we'll just have to do an imap delete and pretend this is the trash
|
// if we can't find the trash, we'll just have to do an imap delete and pretend this is the trash
|
||||||
if (NS_FAILED(rv) || !trashFolder)
|
if (NS_FAILED(rv) || !trashFolder)
|
||||||
deleteImmediatelyNoTrash = PR_TRUE;
|
deleteImmediatelyNoTrash = PR_TRUE;
|
||||||
|
@ -3074,82 +3081,89 @@ nsImapMailFolder::OnStopRunningUrl(nsIURI *aUrl, nsresult aExitCode)
|
||||||
mailUrl->GetMsgWindow(getter_AddRefs(aWindow));
|
mailUrl->GetMsgWindow(getter_AddRefs(aWindow));
|
||||||
if (session)
|
if (session)
|
||||||
session->IsFolderOpenInWindow(this, &folderOpen);
|
session->IsFolderOpenInWindow(this, &folderOpen);
|
||||||
|
#ifdef DEBUG_bienvenu1
|
||||||
|
nsXPIDLCString urlSpec;
|
||||||
|
aUrl->GetSpec(getter_Copies(urlSpec));
|
||||||
|
printf("stop running url %s\n", (const char *) urlSpec);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (imapUrl)
|
if (imapUrl)
|
||||||
|
{
|
||||||
|
nsImapAction imapAction = nsIImapUrl::nsImapTest;
|
||||||
|
imapUrl->GetImapAction(&imapAction);
|
||||||
|
switch(imapAction)
|
||||||
{
|
{
|
||||||
nsImapAction imapAction = nsIImapUrl::nsImapTest;
|
case nsIImapUrl::nsImapDeleteMsg:
|
||||||
imapUrl->GetImapAction(&imapAction);
|
case nsIImapUrl::nsImapOnlineMove:
|
||||||
switch(imapAction)
|
case nsIImapUrl::nsImapOnlineCopy:
|
||||||
|
if (m_copyState)
|
||||||
|
{
|
||||||
|
if (NS_SUCCEEDED(aExitCode))
|
||||||
{
|
{
|
||||||
case nsIImapUrl::nsImapDeleteMsg:
|
if (folderOpen)
|
||||||
case nsIImapUrl::nsImapOnlineMove:
|
UpdateFolder(aWindow);
|
||||||
case nsIImapUrl::nsImapOnlineCopy:
|
else
|
||||||
if (m_copyState)
|
UpdatePendingCounts(PR_TRUE, PR_FALSE);
|
||||||
|
if (m_copyState->m_isMove)
|
||||||
|
{
|
||||||
|
nsCOMPtr<nsIMsgFolder> srcFolder;
|
||||||
|
srcFolder =
|
||||||
|
do_QueryInterface(m_copyState->m_srcSupport,
|
||||||
|
&rv);
|
||||||
|
nsCOMPtr<nsIMsgDatabase> srcDB;
|
||||||
|
if (NS_SUCCEEDED(rv))
|
||||||
|
rv = srcFolder->GetMsgDatabase(aWindow,
|
||||||
|
getter_AddRefs(srcDB));
|
||||||
|
if (NS_SUCCEEDED(rv) && srcDB)
|
||||||
{
|
{
|
||||||
if (NS_SUCCEEDED(aExitCode))
|
nsCOMPtr<nsImapMoveCopyMsgTxn> msgTxn;
|
||||||
{
|
nsMsgKeyArray srcKeyArray;
|
||||||
if (folderOpen)
|
msgTxn =
|
||||||
UpdateFolder(aWindow);
|
do_QueryInterface(m_copyState->m_undoMsgTxn);
|
||||||
else
|
if (msgTxn)
|
||||||
UpdatePendingCounts(PR_TRUE, PR_FALSE);
|
msgTxn->GetSrcKeyArray(srcKeyArray);
|
||||||
if (m_copyState->m_isMove)
|
srcDB->DeleteMessages(&srcKeyArray, nsnull);
|
||||||
{
|
NotifyDeleteOrMoveMessagesCompleted(srcFolder);
|
||||||
nsCOMPtr<nsIMsgFolder> srcFolder;
|
|
||||||
srcFolder =
|
|
||||||
do_QueryInterface(m_copyState->m_srcSupport,
|
|
||||||
&rv);
|
|
||||||
nsCOMPtr<nsIMsgDatabase> srcDB;
|
|
||||||
if (NS_SUCCEEDED(rv))
|
|
||||||
rv = srcFolder->GetMsgDatabase(aWindow,
|
|
||||||
getter_AddRefs(srcDB));
|
|
||||||
if (NS_SUCCEEDED(rv) && srcDB)
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsImapMoveCopyMsgTxn> msgTxn;
|
|
||||||
nsMsgKeyArray srcKeyArray;
|
|
||||||
msgTxn =
|
|
||||||
do_QueryInterface(m_copyState->m_undoMsgTxn);
|
|
||||||
if (msgTxn)
|
|
||||||
msgTxn->GetSrcKeyArray(srcKeyArray);
|
|
||||||
srcDB->DeleteMessages(&srcKeyArray, nsnull);
|
|
||||||
NotifyDeleteOrMoveMessagesCompleted(srcFolder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (m_transactionManager)
|
|
||||||
m_transactionManager->Do(m_copyState->m_undoMsgTxn);
|
|
||||||
}
|
|
||||||
ClearCopyState(aExitCode);
|
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
case nsIImapUrl::nsImapAddMsgFlags:
|
if (m_transactionManager)
|
||||||
// this isn't really right - we'd like to know we were
|
m_transactionManager->Do(m_copyState->m_undoMsgTxn);
|
||||||
// deleting a message to start with, but it probably
|
|
||||||
// won't do any harm.
|
|
||||||
NotifyDeleteOrMoveMessagesCompleted(this);
|
|
||||||
|
|
||||||
break;
|
|
||||||
case nsIImapUrl::nsImapAppendMsgFromFile:
|
|
||||||
case nsIImapUrl::nsImapAppendDraftFromFile:
|
|
||||||
if (m_copyState)
|
|
||||||
{
|
|
||||||
if (folderOpen)
|
|
||||||
UpdateFolder(aWindow);
|
|
||||||
else
|
|
||||||
UpdatePendingCounts(PR_TRUE, PR_FALSE);
|
|
||||||
m_copyState->m_curIndex++;
|
|
||||||
if (m_copyState->m_curIndex >= m_copyState->m_totalCount)
|
|
||||||
{
|
|
||||||
if (m_transactionManager && m_copyState->m_undoMsgTxn)
|
|
||||||
m_transactionManager->Do(m_copyState->m_undoMsgTxn);
|
|
||||||
ClearCopyState(aExitCode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case nsIImapUrl::nsImapRenameFolder:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
ClearCopyState(aExitCode);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case nsIImapUrl::nsImapAddMsgFlags:
|
||||||
|
// this isn't really right - we'd like to know we were
|
||||||
|
// deleting a message to start with, but it probably
|
||||||
|
// won't do any harm.
|
||||||
|
NotifyDeleteOrMoveMessagesCompleted(this);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case nsIImapUrl::nsImapAppendMsgFromFile:
|
||||||
|
case nsIImapUrl::nsImapAppendDraftFromFile:
|
||||||
|
if (m_copyState)
|
||||||
|
{
|
||||||
|
if (folderOpen)
|
||||||
|
UpdateFolder(aWindow);
|
||||||
|
else
|
||||||
|
UpdatePendingCounts(PR_TRUE, PR_FALSE);
|
||||||
|
m_copyState->m_curIndex++;
|
||||||
|
if (m_copyState->m_curIndex >= m_copyState->m_totalCount)
|
||||||
|
{
|
||||||
|
if (m_transactionManager && m_copyState->m_undoMsgTxn)
|
||||||
|
m_transactionManager->Do(m_copyState->m_undoMsgTxn);
|
||||||
|
ClearCopyState(aExitCode);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
NS_ASSERTION(PR_FALSE, "not clearing copy state");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case nsIImapUrl::nsImapRenameFolder:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// give base class a chance to send folder loaded notification...
|
// give base class a chance to send folder loaded notification...
|
||||||
rv = nsMsgDBFolder::OnStopRunningUrl(aUrl, aExitCode);
|
rv = nsMsgDBFolder::OnStopRunningUrl(aUrl, aExitCode);
|
||||||
// query it for a mailnews interface for now....
|
// query it for a mailnews interface for now....
|
||||||
|
@ -3785,6 +3799,11 @@ nsImapMailFolder::CopyMessages(nsIMsgFolder* srcFolder,
|
||||||
NS_GET_IID(nsImapMoveCopyMsgTxn),
|
NS_GET_IID(nsImapMoveCopyMsgTxn),
|
||||||
getter_AddRefs(m_copyState->m_undoMsgTxn) );
|
getter_AddRefs(m_copyState->m_undoMsgTxn) );
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NS_ASSERTION(PR_FALSE, "online copy failed");
|
||||||
|
ClearCopyState(rv);
|
||||||
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
return rv;
|
return rv;
|
||||||
|
@ -3943,9 +3962,10 @@ nsImapMailFolder::InitCopyState(nsISupports* srcSupport,
|
||||||
PRBool selectedState,
|
PRBool selectedState,
|
||||||
nsIMsgCopyServiceListener* listener)
|
nsIMsgCopyServiceListener* listener)
|
||||||
{
|
{
|
||||||
nsresult rv = NS_ERROR_NULL_POINTER;
|
nsresult rv = NS_OK;
|
||||||
|
|
||||||
if (!srcSupport || !messages) return rv;
|
if (!srcSupport || !messages) return NS_ERROR_NULL_POINTER;
|
||||||
|
// NS_ASSERTION(!m_copyState, "move/copy already in progress");
|
||||||
if (m_copyState) return NS_ERROR_FAILURE;
|
if (m_copyState) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
nsImapMailCopyState* copyState = new nsImapMailCopyState();
|
nsImapMailCopyState* copyState = new nsImapMailCopyState();
|
||||||
|
|
|
@ -428,12 +428,14 @@ nsImapProtocol::GetImapServerKey()
|
||||||
void
|
void
|
||||||
nsImapProtocol::SetupSinkProxy()
|
nsImapProtocol::SetupSinkProxy()
|
||||||
{
|
{
|
||||||
|
nsresult res = NS_ERROR_FAILURE;
|
||||||
|
NS_ASSERTION(!m_imapMiscellaneousSink, "shouldn't be non-null here");
|
||||||
|
|
||||||
if (m_runningUrl)
|
if (m_runningUrl)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(m_sinkEventQueue && m_thread, "fatal... null sink event queue or thread");
|
NS_ASSERTION(m_sinkEventQueue && m_thread, "fatal... null sink event queue or thread");
|
||||||
nsresult res;
|
|
||||||
|
|
||||||
nsCOMPtr<nsIProxyObjectManager> proxyManager(do_GetService(kProxyObjectManagerCID));
|
nsCOMPtr<nsIProxyObjectManager> proxyManager(do_GetService(kProxyObjectManagerCID, &res));
|
||||||
if (proxyManager) // if we don't get one of these are as good as dead...
|
if (proxyManager) // if we don't get one of these are as good as dead...
|
||||||
{
|
{
|
||||||
if (!m_imapMailFolderSink)
|
if (!m_imapMailFolderSink)
|
||||||
|
@ -484,6 +486,7 @@ nsImapProtocol::SetupSinkProxy()
|
||||||
m_thread);
|
m_thread);
|
||||||
m_imapMiscellaneousSink = do_QueryInterface(miscSink);
|
m_imapMiscellaneousSink = do_QueryInterface(miscSink);
|
||||||
}
|
}
|
||||||
|
NS_ASSERTION(NS_SUCCEEDED(res), "couldn't get proxies");
|
||||||
}
|
}
|
||||||
if (!m_imapServerSink)
|
if (!m_imapServerSink)
|
||||||
{
|
{
|
||||||
|
@ -495,9 +498,13 @@ nsImapProtocol::SetupSinkProxy()
|
||||||
aImapServerSink,
|
aImapServerSink,
|
||||||
PROXY_SYNC | PROXY_ALWAYS,
|
PROXY_SYNC | PROXY_ALWAYS,
|
||||||
getter_AddRefs(m_imapServerSink));
|
getter_AddRefs(m_imapServerSink));
|
||||||
|
NS_ASSERTION(NS_SUCCEEDED(res), "couldn't get proxies");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
NS_ASSERTION(PR_FALSE, "can't get proxy service");
|
||||||
}
|
}
|
||||||
|
NS_ASSERTION(NS_SUCCEEDED(res), "couldn't get proxies");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup With Url is intended to set up data which is held on a PER URL basis and not
|
// Setup With Url is intended to set up data which is held on a PER URL basis and not
|
||||||
|
@ -849,13 +856,13 @@ nsImapProtocol::ImapThreadMainLoop()
|
||||||
{
|
{
|
||||||
PRIntervalTime sleepTime = kImapSleepTime;
|
PRIntervalTime sleepTime = kImapSleepTime;
|
||||||
// ****** please implement PR_LOG 'ing ******
|
// ****** please implement PR_LOG 'ing ******
|
||||||
while (ImapThreadIsRunning() && !DeathSignalReceived())
|
while (ImapThreadIsRunning() && !DeathSignalReceived())
|
||||||
{
|
{
|
||||||
// if we are making our first pass through this loop and
|
// if we are making our first pass through this loop and
|
||||||
// we already have a url to process then jump right in and
|
// we already have a url to process then jump right in and
|
||||||
// process the current url. Don't try to wait for the monitor
|
// process the current url. Don't try to wait for the monitor
|
||||||
// the first time because it may have already been signaled.
|
// the first time because it may have already been signaled.
|
||||||
// But make sure we have a channel first, or ProcessCurrentUrl will fail.
|
// But make sure we have a channel first, or ProcessCurrentUrl will fail.
|
||||||
if (TestFlag(IMAP_FIRST_PASS_IN_THREAD) && m_runningUrl && m_channel)
|
if (TestFlag(IMAP_FIRST_PASS_IN_THREAD) && m_runningUrl && m_channel)
|
||||||
{
|
{
|
||||||
// if we launched another url, just loop around and process it.
|
// if we launched another url, just loop around and process it.
|
||||||
|
@ -870,24 +877,25 @@ nsImapProtocol::ImapThreadMainLoop()
|
||||||
|
|
||||||
PRStatus err;
|
PRStatus err;
|
||||||
|
|
||||||
err = PR_Wait(m_urlReadyToRunMonitor, sleepTime);
|
err = PR_Wait(m_urlReadyToRunMonitor, sleepTime);
|
||||||
|
|
||||||
PR_ExitMonitor(m_urlReadyToRunMonitor);
|
PR_ExitMonitor(m_urlReadyToRunMonitor);
|
||||||
if (err == PR_FAILURE && PR_PENDING_INTERRUPT_ERROR == PR_GetError())
|
if (err == PR_FAILURE && PR_PENDING_INTERRUPT_ERROR == PR_GetError())
|
||||||
{
|
{
|
||||||
|
printf("error waiting for monitor\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// m_eventQueue->ProcessPendingEvents();
|
// m_eventQueue->ProcessPendingEvents();
|
||||||
// m_sinkEventQueue->ProcessPendingEvents();
|
// m_sinkEventQueue->ProcessPendingEvents();
|
||||||
|
|
||||||
if (m_nextUrlReadyToRun && m_runningUrl)
|
if (m_nextUrlReadyToRun && m_runningUrl)
|
||||||
|
{
|
||||||
|
m_nextUrlReadyToRun = PR_FALSE;
|
||||||
ProcessCurrentURL();
|
ProcessCurrentURL();
|
||||||
|
|
||||||
m_nextUrlReadyToRun = PR_FALSE;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
m_imapThreadIsRunning = PR_FALSE;
|
}
|
||||||
|
m_imapThreadIsRunning = PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsImapProtocol::EstablishServerConnection()
|
void nsImapProtocol::EstablishServerConnection()
|
||||||
|
@ -1029,6 +1037,10 @@ PRBool nsImapProtocol::ProcessCurrentURL()
|
||||||
SetFlag(IMAP_CONNECTION_IS_OPEN);
|
SetFlag(IMAP_CONNECTION_IS_OPEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_ASSERTION(m_imapMiscellaneousSink, "null sink");
|
||||||
|
if (!m_imapMiscellaneousSink)
|
||||||
|
SetupSinkProxy(); // try this again. Evil, but I'm desperate.
|
||||||
|
|
||||||
// we used to check if the current running url was
|
// we used to check if the current running url was
|
||||||
// Reinitialize the parser
|
// Reinitialize the parser
|
||||||
GetServerStateParser().InitializeState();
|
GetServerStateParser().InitializeState();
|
||||||
|
@ -1037,6 +1049,11 @@ PRBool nsImapProtocol::ProcessCurrentURL()
|
||||||
// acknowledge that we are running the url now..
|
// acknowledge that we are running the url now..
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(m_runningUrl, &rv);
|
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(m_runningUrl, &rv);
|
||||||
|
#ifdef DEBUG_bienvenu1
|
||||||
|
nsXPIDLCString urlSpec;
|
||||||
|
mailnewsurl->GetSpec(getter_Copies(urlSpec));
|
||||||
|
printf("processing url %s\n", (const char *) urlSpec);
|
||||||
|
#endif
|
||||||
if (NS_SUCCEEDED(rv) && mailnewsurl && m_imapMiscellaneousSink)
|
if (NS_SUCCEEDED(rv) && mailnewsurl && m_imapMiscellaneousSink)
|
||||||
{
|
{
|
||||||
m_imapMiscellaneousSink->SetUrlState(this, mailnewsurl, PR_TRUE,
|
m_imapMiscellaneousSink->SetUrlState(this, mailnewsurl, PR_TRUE,
|
||||||
|
@ -1121,6 +1138,8 @@ PRBool nsImapProtocol::ProcessCurrentURL()
|
||||||
// url.
|
// url.
|
||||||
WaitForFEEventCompletion();
|
WaitForFEEventCompletion();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
NS_ASSERTION(PR_FALSE, "missing url or sink");
|
||||||
|
|
||||||
// if we are set up as a channel, we should notify our channel listener that we are starting...
|
// if we are set up as a channel, we should notify our channel listener that we are starting...
|
||||||
// so pass in ourself as the channel and not the underlying socket or file channel the protocol
|
// so pass in ourself as the channel and not the underlying socket or file channel the protocol
|
||||||
|
@ -1137,6 +1156,10 @@ PRBool nsImapProtocol::ProcessCurrentURL()
|
||||||
WaitForFEEventCompletion();
|
WaitForFEEventCompletion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG_bienvenu1
|
||||||
|
mailnewsurl->GetSpec(getter_Copies(urlSpec));
|
||||||
|
printf("end processing url %s\n", (const char *) urlSpec);
|
||||||
|
#endif
|
||||||
// this is so hokey...we MUST clear any local references to the url
|
// this is so hokey...we MUST clear any local references to the url
|
||||||
// BEFORE calling ReleaseUrlState
|
// BEFORE calling ReleaseUrlState
|
||||||
mailnewsurl = nsnull;
|
mailnewsurl = nsnull;
|
||||||
|
@ -1144,11 +1167,12 @@ PRBool nsImapProtocol::ProcessCurrentURL()
|
||||||
// release the url as we are done with it...
|
// release the url as we are done with it...
|
||||||
ReleaseUrlState();
|
ReleaseUrlState();
|
||||||
ResetProgressInfo();
|
ResetProgressInfo();
|
||||||
|
m_urlInProgress = PR_FALSE;
|
||||||
// now try queued urls, now that we've released this connection.
|
// now try queued urls, now that we've released this connection.
|
||||||
if (m_imapServerSink && GetConnectionStatus() >= 0)
|
if (m_imapServerSink && GetConnectionStatus() >= 0)
|
||||||
{
|
{
|
||||||
rv = m_imapServerSink->LoadNextQueuedUrl(&anotherUrlRun);
|
rv = m_imapServerSink->LoadNextQueuedUrl(&anotherUrlRun);
|
||||||
SetFlag(IMAP_FIRST_PASS_IN_THREAD);
|
SetFlag(IMAP_FIRST_PASS_IN_THREAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetConnectionStatus() < 0)
|
if (GetConnectionStatus() < 0)
|
||||||
|
@ -1342,7 +1366,14 @@ nsresult nsImapProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer)
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
if (aURL)
|
if (aURL)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_bienvenu1
|
||||||
|
nsXPIDLCString urlSpec;
|
||||||
|
aURL->GetSpec(getter_Copies(urlSpec));
|
||||||
|
printf("loading url %s\n", (const char *) urlSpec);
|
||||||
|
#endif
|
||||||
|
m_urlInProgress = PR_TRUE;
|
||||||
rv = SetupWithUrl(aURL, aConsumer);
|
rv = SetupWithUrl(aURL, aConsumer);
|
||||||
|
NS_ASSERTION(NS_SUCCEEDED(rv), "error setting up imap url");
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
SetupSinkProxy(); // generate proxies for all of the event sinks in the url
|
SetupSinkProxy(); // generate proxies for all of the event sinks in the url
|
||||||
m_lastActiveTime = PR_Now();
|
m_lastActiveTime = PR_Now();
|
||||||
|
@ -1364,6 +1395,9 @@ nsresult nsImapProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer)
|
||||||
PR_ExitMonitor(m_urlReadyToRunMonitor);
|
PR_ExitMonitor(m_urlReadyToRunMonitor);
|
||||||
|
|
||||||
} // if we have an imap url and a transport
|
} // if we have an imap url and a transport
|
||||||
|
else
|
||||||
|
NS_ASSERTION(PR_FALSE, "missing channel or running url");
|
||||||
|
|
||||||
} // if we received a url!
|
} // if we received a url!
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
|
@ -1375,30 +1409,33 @@ NS_IMETHODIMP nsImapProtocol::IsBusy(PRBool *aIsConnectionBusy,
|
||||||
if (!aIsConnectionBusy || !isInboxConnection)
|
if (!aIsConnectionBusy || !isInboxConnection)
|
||||||
return NS_ERROR_NULL_POINTER;
|
return NS_ERROR_NULL_POINTER;
|
||||||
NS_LOCK_INSTANCE();
|
NS_LOCK_INSTANCE();
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
*aIsConnectionBusy = PR_FALSE;
|
*aIsConnectionBusy = PR_FALSE;
|
||||||
*isInboxConnection = PR_FALSE;
|
*isInboxConnection = PR_FALSE;
|
||||||
if (!m_channel)
|
if (!m_channel)
|
||||||
{
|
{
|
||||||
// ** jt -- something is really wrong kill the thread
|
// ** jt -- something is really wrong kill the thread
|
||||||
TellThreadToDie(PR_FALSE);
|
TellThreadToDie(PR_FALSE);
|
||||||
rv = NS_ERROR_FAILURE;
|
rv = NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (m_runningUrl) // do we have a url? That means we're working on
|
if (m_urlInProgress) // do we have a url? That means we're working on it...
|
||||||
// it...
|
*aIsConnectionBusy = PR_TRUE;
|
||||||
*aIsConnectionBusy = PR_TRUE;
|
|
||||||
if (GetServerStateParser().GetSelectedMailboxName() &&
|
|
||||||
PL_strcasecmp(GetServerStateParser().GetSelectedMailboxName(),
|
|
||||||
"Inbox") == 0)
|
|
||||||
*isInboxConnection = PR_TRUE;
|
|
||||||
|
|
||||||
}
|
if (GetServerStateParser().GetSelectedMailboxName() &&
|
||||||
|
PL_strcasecmp(GetServerStateParser().GetSelectedMailboxName(),
|
||||||
|
"Inbox") == 0)
|
||||||
|
*isInboxConnection = PR_TRUE;
|
||||||
|
|
||||||
|
}
|
||||||
NS_UNLOCK_INSTANCE();
|
NS_UNLOCK_INSTANCE();
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// canRunUrl means the connection is not busy, and is in the selcted state
|
||||||
|
// for the desired folder (or authenticated).
|
||||||
|
// has to wait means it's in the right selected state, but busy.
|
||||||
NS_IMETHODIMP nsImapProtocol::CanHandleUrl(nsIImapUrl * aImapUrl,
|
NS_IMETHODIMP nsImapProtocol::CanHandleUrl(nsIImapUrl * aImapUrl,
|
||||||
PRBool * aCanRunUrl,
|
PRBool * aCanRunUrl,
|
||||||
PRBool * hasToWait)
|
PRBool * hasToWait)
|
||||||
|
@ -1409,110 +1446,115 @@ NS_IMETHODIMP nsImapProtocol::CanHandleUrl(nsIImapUrl * aImapUrl,
|
||||||
NS_LOCK_INSTANCE();
|
NS_LOCK_INSTANCE();
|
||||||
|
|
||||||
*aCanRunUrl = PR_FALSE; // assume guilty until proven otherwise...
|
*aCanRunUrl = PR_FALSE; // assume guilty until proven otherwise...
|
||||||
*hasToWait = PR_FALSE;
|
*hasToWait = PR_FALSE;
|
||||||
|
|
||||||
PRBool isBusy = PR_FALSE;
|
PRBool isBusy = PR_FALSE;
|
||||||
PRBool isInboxConnection = PR_FALSE;
|
PRBool isInboxConnection = PR_FALSE;
|
||||||
|
|
||||||
if (!m_channel)
|
if (!m_channel)
|
||||||
|
{
|
||||||
|
// *** jt -- something is really wrong; it could be the dialer gave up
|
||||||
|
// the connection or ip binding has been release by the operating
|
||||||
|
// system; tell thread to die and return error failure
|
||||||
|
TellThreadToDie(PR_FALSE);
|
||||||
|
rv = NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IsBusy(&isBusy, &isInboxConnection);
|
||||||
|
|
||||||
|
PRBool inSelectedState = GetServerStateParser().GetIMAPstate() ==
|
||||||
|
nsImapServerResponseParser::kFolderSelected;
|
||||||
|
|
||||||
|
nsCString curUrlFolderName;
|
||||||
|
if (inSelectedState)
|
||||||
{
|
{
|
||||||
// *** jt -- something is really wrong; it could be the dialer gave up
|
curUrlFolderName =
|
||||||
// the connection or ip binding has been release by the operating
|
GetServerStateParser().GetSelectedMailboxName();
|
||||||
// system; tell thread to die and return error failure
|
|
||||||
TellThreadToDie(PR_FALSE);
|
|
||||||
rv = NS_ERROR_FAILURE;
|
|
||||||
}
|
}
|
||||||
else
|
else if (isBusy)
|
||||||
{
|
{
|
||||||
IsBusy(&isBusy, &isInboxConnection);
|
nsImapState curUrlImapState;
|
||||||
|
m_runningUrl->GetRequiredImapState(&curUrlImapState);
|
||||||
PRBool inSelectedState = GetServerStateParser().GetIMAPstate() ==
|
if (curUrlImapState == nsIImapUrl::nsImapSelectedState)
|
||||||
nsImapServerResponseParser::kFolderSelected;
|
|
||||||
|
|
||||||
nsCString curUrlFolderName;
|
|
||||||
if (inSelectedState)
|
|
||||||
{
|
{
|
||||||
curUrlFolderName =
|
curUrlFolderName = OnCreateServerSourceFolderPathString();
|
||||||
GetServerStateParser().GetSelectedMailboxName();
|
inSelectedState = PR_TRUE;
|
||||||
}
|
|
||||||
else if (isBusy)
|
|
||||||
{
|
|
||||||
nsImapState curUrlImapState;
|
|
||||||
m_runningUrl->GetRequiredImapState(&curUrlImapState);
|
|
||||||
if (curUrlImapState == nsIImapUrl::nsImapSelectedState)
|
|
||||||
{
|
|
||||||
curUrlFolderName = OnCreateServerSourceFolderPathString();
|
|
||||||
inSelectedState = PR_TRUE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nsImapState imapState;
|
nsImapState imapState;
|
||||||
aImapUrl->GetRequiredImapState(&imapState);
|
aImapUrl->GetRequiredImapState(&imapState);
|
||||||
|
|
||||||
PRBool isSelectedStateUrl = imapState ==
|
PRBool isSelectedStateUrl = imapState ==
|
||||||
nsIImapUrl::nsImapSelectedState;
|
nsIImapUrl::nsImapSelectedState;
|
||||||
|
|
||||||
nsCOMPtr<nsIMsgMailNewsUrl> msgUrl = do_QueryInterface(aImapUrl);
|
nsCOMPtr<nsIMsgMailNewsUrl> msgUrl = do_QueryInterface(aImapUrl);
|
||||||
nsCOMPtr<nsIMsgIncomingServer> server;
|
nsCOMPtr<nsIMsgIncomingServer> server;
|
||||||
rv = msgUrl->GetServer(getter_AddRefs(server));
|
rv = msgUrl->GetServer(getter_AddRefs(server));
|
||||||
if (NS_SUCCEEDED(rv))
|
if (NS_SUCCEEDED(rv))
|
||||||
{
|
{
|
||||||
// compare host/user between url and connection.
|
// compare host/user between url and connection.
|
||||||
char * urlHostName = nsnull;
|
char * urlHostName = nsnull;
|
||||||
char * urlUserName = nsnull;
|
char * urlUserName = nsnull;
|
||||||
rv = server->GetHostName(&urlHostName);
|
rv = server->GetHostName(&urlHostName);
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
rv = server->GetUsername(&urlUserName);
|
rv = server->GetUsername(&urlUserName);
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
if ((!GetImapHostName() ||
|
if ((!GetImapHostName() ||
|
||||||
PL_strcasecmp(urlHostName, GetImapHostName()) == 0) &&
|
PL_strcasecmp(urlHostName, GetImapHostName()) == 0) &&
|
||||||
(!GetImapUserName() ||
|
(!GetImapUserName() ||
|
||||||
PL_strcasecmp(urlUserName, GetImapUserName()) == 0))
|
PL_strcasecmp(urlUserName, GetImapUserName()) == 0))
|
||||||
{
|
{
|
||||||
if (isSelectedStateUrl)
|
if (isSelectedStateUrl)
|
||||||
{
|
{
|
||||||
if (inSelectedState)
|
if (inSelectedState)
|
||||||
{
|
{
|
||||||
// *** jt - in selected state can only run url with
|
// *** jt - in selected state can only run url with
|
||||||
// matching foldername
|
// matching foldername
|
||||||
char *srcFolderName = nsnull;
|
char *folderNameForProposedUrl = nsnull;
|
||||||
rv = aImapUrl->CreateServerSourceFolderPathString(
|
rv = aImapUrl->CreateServerSourceFolderPathString(
|
||||||
&srcFolderName);
|
&folderNameForProposedUrl);
|
||||||
if (NS_SUCCEEDED(rv) && srcFolderName)
|
if (NS_SUCCEEDED(rv) && folderNameForProposedUrl)
|
||||||
{
|
{
|
||||||
PRBool isInbox =
|
PRBool isInbox =
|
||||||
PL_strcasecmp("Inbox", srcFolderName) == 0;
|
PL_strcasecmp("Inbox", folderNameForProposedUrl) == 0;
|
||||||
if (curUrlFolderName.Length() > 0)
|
if (curUrlFolderName.Length() > 0)
|
||||||
{
|
{
|
||||||
PRBool matched = isInbox ?
|
PRBool matched = isInbox ?
|
||||||
PL_strcasecmp(curUrlFolderName.GetBuffer(),
|
PL_strcasecmp(curUrlFolderName.GetBuffer(),
|
||||||
srcFolderName) == 0 :
|
folderNameForProposedUrl) == 0 :
|
||||||
PL_strcmp(curUrlFolderName.GetBuffer(),
|
PL_strcmp(curUrlFolderName.GetBuffer(),
|
||||||
srcFolderName) == 0;
|
folderNameForProposedUrl) == 0;
|
||||||
if (matched)
|
if (matched)
|
||||||
{
|
{
|
||||||
if (isBusy)
|
if (isBusy)
|
||||||
*hasToWait = PR_TRUE;
|
*hasToWait = PR_TRUE;
|
||||||
else
|
else
|
||||||
*aCanRunUrl = PR_TRUE;
|
*aCanRunUrl = PR_TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PR_FREEIF(srcFolderName);
|
#ifdef DEBUG_bienvenu1
|
||||||
}
|
printf("proposed url = %s folder for connection %s has To Wait = %s can run = %s\n",
|
||||||
}
|
folderNameForProposedUrl, curUrlFolderName.GetBuffer(),
|
||||||
else // *** jt - an authenticated state url can be run in either
|
(*hasToWait) ? "TRUE" : "FALSE", (*aCanRunUrl) ? "TRUE" : "FALSE");
|
||||||
// authenticated or selected state
|
#endif
|
||||||
{
|
PR_FREEIF(folderNameForProposedUrl);
|
||||||
if (!isBusy)
|
}
|
||||||
*aCanRunUrl = PR_TRUE;
|
}
|
||||||
}
|
else // *** jt - an authenticated state url can be run in either
|
||||||
|
// authenticated or selected state
|
||||||
|
{
|
||||||
|
if (!isBusy)
|
||||||
|
*aCanRunUrl = PR_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
PR_FREEIF(urlHostName);
|
PR_FREEIF(urlHostName);
|
||||||
PR_FREEIF(urlUserName);
|
PR_FREEIF(urlUserName);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
NS_UNLOCK_INSTANCE();
|
NS_UNLOCK_INSTANCE();
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -5182,6 +5224,12 @@ void nsImapProtocol::FindMailboxesIfNecessary()
|
||||||
nsImapAction imapAction;
|
nsImapAction imapAction;
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
|
|
||||||
|
// need to do this for every connection in order to see folders.
|
||||||
|
#ifdef DOING_PSEUDO_MAILBOXES
|
||||||
|
if (GetServerStateParser().ServerIsAOLServer())
|
||||||
|
XAOL_Option("+READMBOX");
|
||||||
|
#endif
|
||||||
|
|
||||||
rv = m_runningUrl->GetImapAction(&imapAction);
|
rv = m_runningUrl->GetImapAction(&imapAction);
|
||||||
rv = m_hostSessionList->GetHaveWeEverDiscoveredFoldersForHost(GetImapServerKey(), foundMailboxesAlready);
|
rv = m_hostSessionList->GetHaveWeEverDiscoveredFoldersForHost(GetImapServerKey(), foundMailboxesAlready);
|
||||||
if (NS_SUCCEEDED(rv) && !foundMailboxesAlready &&
|
if (NS_SUCCEEDED(rv) && !foundMailboxesAlready &&
|
||||||
|
@ -5209,6 +5257,7 @@ void nsImapProtocol::FindMailboxesIfNecessary()
|
||||||
void nsImapProtocol::DiscoverMailboxList()
|
void nsImapProtocol::DiscoverMailboxList()
|
||||||
{
|
{
|
||||||
PRBool usingSubscription = PR_FALSE;
|
PRBool usingSubscription = PR_FALSE;
|
||||||
|
|
||||||
SetMailboxDiscoveryStatus(eContinue);
|
SetMailboxDiscoveryStatus(eContinue);
|
||||||
if (GetServerStateParser().ServerHasACLCapability())
|
if (GetServerStateParser().ServerHasACLCapability())
|
||||||
m_hierarchyNameState = kListingForInfoAndDiscovery;
|
m_hierarchyNameState = kListingForInfoAndDiscovery;
|
||||||
|
@ -5986,6 +6035,20 @@ void nsImapProtocol::Close()
|
||||||
ParseIMAPandCheckForNewMail();
|
ParseIMAPandCheckForNewMail();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void nsImapProtocol::XAOL_Option(const char *option)
|
||||||
|
{
|
||||||
|
IncrementCommandTagNumber();
|
||||||
|
|
||||||
|
nsCString command(GetServerCommandTag());
|
||||||
|
command.Append(" XAOL-OPTION ");
|
||||||
|
command.Append(option);
|
||||||
|
command.Append(CRLF);
|
||||||
|
|
||||||
|
nsresult rv = SendData(command.GetBuffer());
|
||||||
|
if (NS_SUCCEEDED(rv))
|
||||||
|
ParseIMAPandCheckForNewMail();
|
||||||
|
}
|
||||||
|
|
||||||
void nsImapProtocol::Check()
|
void nsImapProtocol::Check()
|
||||||
{
|
{
|
||||||
//ProgressUpdateEvent("Checking mailbox...");
|
//ProgressUpdateEvent("Checking mailbox...");
|
||||||
|
|
|
@ -250,6 +250,7 @@ public:
|
||||||
void XServerInfo();
|
void XServerInfo();
|
||||||
void Netscape();
|
void Netscape();
|
||||||
void XMailboxInfo(const char *mailboxName);
|
void XMailboxInfo(const char *mailboxName);
|
||||||
|
void XAOL_Option(const char *option);
|
||||||
void MailboxData();
|
void MailboxData();
|
||||||
void GetMyRightsForFolder(const char *mailboxName);
|
void GetMyRightsForFolder(const char *mailboxName);
|
||||||
void AutoSubscribeToMailboxIfNecessary(const char *mailboxName);
|
void AutoSubscribeToMailboxIfNecessary(const char *mailboxName);
|
||||||
|
@ -287,8 +288,8 @@ public:
|
||||||
const char* msgIdString);
|
const char* msgIdString);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// the following flag is used to determine when a url is currently being run. It is cleared on calls
|
// the following flag is used to determine when a url is currently being run. It is cleared when we
|
||||||
// to ::StopBinding and it is set whenever we call Load on a url
|
// finish processng a url and it is set whenever we call Load on a url
|
||||||
PRBool m_urlInProgress;
|
PRBool m_urlInProgress;
|
||||||
PRBool m_socketIsOpen;
|
PRBool m_socketIsOpen;
|
||||||
PRBool m_gotFEEventCompletion;
|
PRBool m_gotFEEventCompletion;
|
||||||
|
|
|
@ -655,6 +655,8 @@ void nsImapServerResponseParser::response_data()
|
||||||
xserverinfo_data();
|
xserverinfo_data();
|
||||||
else if (!PL_strcasecmp(fNextToken, "XMAILBOXINFO"))
|
else if (!PL_strcasecmp(fNextToken, "XMAILBOXINFO"))
|
||||||
xmailboxinfo_data();
|
xmailboxinfo_data();
|
||||||
|
else if (!PL_strcasecmp(fNextToken, "XAOL-OPTION"))
|
||||||
|
skip_to_CRLF();
|
||||||
else
|
else
|
||||||
SetSyntaxError(PR_TRUE);
|
SetSyntaxError(PR_TRUE);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -110,6 +110,7 @@ public:
|
||||||
PRBool ServerHasNamespaceCapability() { return ((fCapabilityFlag & kNamespaceCapability) != 0); }
|
PRBool ServerHasNamespaceCapability() { return ((fCapabilityFlag & kNamespaceCapability) != 0); }
|
||||||
PRBool ServerIsNetscape3xServer() { return fServerIsNetscape3xServer; }
|
PRBool ServerIsNetscape3xServer() { return fServerIsNetscape3xServer; }
|
||||||
PRBool ServerHasServerInfo() {return ((fCapabilityFlag & kXServerInfoCapability) != 0); }
|
PRBool ServerHasServerInfo() {return ((fCapabilityFlag & kXServerInfoCapability) != 0); }
|
||||||
|
PRBool ServerIsAOLServer() {return ((fCapabilityFlag & kAOLImapCapability) != 0); }
|
||||||
void ResetCapabilityFlag() ;
|
void ResetCapabilityFlag() ;
|
||||||
|
|
||||||
const char *GetMailAccountUrl() { return fMailAccountUrl; }
|
const char *GetMailAccountUrl() { return fMailAccountUrl; }
|
||||||
|
|
|
@ -181,14 +181,14 @@ nsImapService::SelectFolder(nsIEventQueue * aClientEventQueue,
|
||||||
|
|
||||||
if (NS_SUCCEEDED(rv))
|
if (NS_SUCCEEDED(rv))
|
||||||
{
|
{
|
||||||
nsXPIDLCString folderName;
|
nsXPIDLCString folderName;
|
||||||
GetFolderName(aImapMailFolder, getter_Copies(folderName));
|
GetFolderName(aImapMailFolder, getter_Copies(folderName));
|
||||||
urlSpec.Append("/select>");
|
urlSpec.Append("/select>");
|
||||||
urlSpec.Append(hierarchySeparator);
|
urlSpec.Append(hierarchySeparator);
|
||||||
urlSpec.Append((const char *) folderName);
|
urlSpec.Append((const char *) folderName);
|
||||||
rv = mailNewsUrl->SetSpec((char *) urlSpec.GetBuffer());
|
rv = mailNewsUrl->SetSpec((char *) urlSpec.GetBuffer());
|
||||||
if (NS_SUCCEEDED(rv))
|
if (NS_SUCCEEDED(rv))
|
||||||
rv = GetImapConnectionAndLoadUrl(aClientEventQueue,
|
rv = GetImapConnectionAndLoadUrl(aClientEventQueue,
|
||||||
imapUrl,
|
imapUrl,
|
||||||
nsnull,
|
nsnull,
|
||||||
aURL);
|
aURL);
|
||||||
|
@ -1618,7 +1618,7 @@ nsImapService::OnlineMessageCopy(nsIEventQueue* aClientEventQueue,
|
||||||
GetFolderName(aDstFolder, getter_Copies(folderName));
|
GetFolderName(aDstFolder, getter_Copies(folderName));
|
||||||
urlSpec.Append((const char *) folderName);
|
urlSpec.Append((const char *) folderName);
|
||||||
|
|
||||||
rv = uri->SetSpec((char *) urlSpec.GetBuffer());
|
rv = uri->SetSpec((char *) urlSpec.GetBuffer());
|
||||||
if (NS_SUCCEEDED(rv))
|
if (NS_SUCCEEDED(rv))
|
||||||
rv = GetImapConnectionAndLoadUrl(aClientEventQueue, imapUrl,
|
rv = GetImapConnectionAndLoadUrl(aClientEventQueue, imapUrl,
|
||||||
nsnull, aURL);
|
nsnull, aURL);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче