зеркало из https://github.com/mozilla/pjs.git
more filling out of missing imap methods, use nsIThread...
This commit is contained in:
Родитель
db9fb1d6ed
Коммит
da0e399946
|
@ -24,6 +24,7 @@
|
|||
|
||||
class nsIMAPBodyShellCache;
|
||||
class nsIMAPBodyShell;
|
||||
class nsIImapIncomingServer;
|
||||
|
||||
// 2a8e21fe-e3c4-11d2-a504-0060b0fc04b7
|
||||
|
||||
|
@ -105,7 +106,7 @@ public:
|
|||
NS_IMETHOD GetNumberOfNamespacesForHost(const char *hostname, const char *userName, PRUint32 &result) = 0;
|
||||
NS_IMETHOD GetNamespaceNumberForHost(const char *hostname, const char *userName, PRInt32 n, nsIMAPNamespace * &result) = 0;
|
||||
// ### dmb hoo boy, how are we going to do this?
|
||||
NS_IMETHOD CommitNamespacesForHost(const char *hostname, const char *userName) = 0;
|
||||
NS_IMETHOD CommitNamespacesForHost(nsIImapIncomingServer *server) = 0;
|
||||
NS_IMETHOD FlushUncommittedNamespacesForHost(const char *hostName, const char *userName, PRBool &result) = 0;
|
||||
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ interface nsIImapIncomingServer : nsISupports {
|
|||
attribute boolean offlineDownload;
|
||||
attribute boolean overrideNamespaces;
|
||||
attribute boolean usingSubscription;
|
||||
|
||||
|
||||
nsIURI GetImapConnectionAndLoadUrl(in nsIEventQueue aClientEventQueue,
|
||||
in nsIImapUrl aImapUrl,
|
||||
in nsIUrlListener aUrlListener,
|
||||
|
@ -52,4 +52,5 @@ interface nsIImapIncomingServer : nsISupports {
|
|||
void LoadNextQueuedUrl();
|
||||
|
||||
void RemoveConnection(in nsIImapProtocol aImapConnection);
|
||||
void ResetNamespaceReferences();
|
||||
};
|
||||
|
|
|
@ -62,7 +62,6 @@ public:
|
|||
NS_IMETHOD ProgressStatus(nsIImapProtocol* aProtocol, PRUint32 aMsgId, const char *extraInfo) = 0;
|
||||
NS_IMETHOD PercentProgress(nsIImapProtocol* aProtocol,
|
||||
ProgressInfo* aInfo) = 0;
|
||||
NS_IMETHOD PastPasswordCheck(nsIImapProtocol* aProtocol) = 0;
|
||||
NS_IMETHOD TunnelOutStream(nsIImapProtocol* aProtocol,
|
||||
msg_line_info* aInfo) = 0;
|
||||
NS_IMETHOD ProcessTunnel(nsIImapProtocol* aProtocol,
|
||||
|
|
|
@ -30,5 +30,7 @@ interface nsIImapServerSink : nsISupports {
|
|||
void FEAlertFromServer(in string aString);
|
||||
void CommitNamespaces();
|
||||
void PromptForPassword(out string aString);
|
||||
void SetUserAuthenticated(in boolean authenticated);
|
||||
void SetMailServerUrls(in string manageMailAccount, in string manageLists, in string manageFilters);
|
||||
};
|
||||
|
||||
|
|
|
@ -21,6 +21,9 @@
|
|||
#include "nsIMAPBodyShell.h"
|
||||
#include "nsIMAPNamespace.h"
|
||||
#include "nsISupportsUtils.h"
|
||||
#include "nsIImapIncomingServer.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIMsgIncomingServer.h"
|
||||
|
||||
nsIMAPHostInfo::nsIMAPHostInfo(const char *hostName, const char *userName)
|
||||
{
|
||||
|
@ -42,6 +45,7 @@ nsIMAPHostInfo::nsIMAPHostInfo(const char *hostName, const char *userName)
|
|||
fDeleteIsMoveToTrash = PR_TRUE;
|
||||
fShowDeletedMessages = PR_FALSE;
|
||||
fGotNamespaces = PR_FALSE;
|
||||
fHaveAdminURL = PR_FALSE;
|
||||
fNamespacesOverridable = PR_TRUE;
|
||||
fTempNamespaceList = nsIMAPNamespaceList::CreatensIMAPNamespaceList();
|
||||
}
|
||||
|
@ -112,7 +116,7 @@ nsIMAPHostInfo *nsIMAPHostSessionList::FindHost(const char *hostName, const char
|
|||
// ### should also check userName here, if NON NULL
|
||||
for (host = fHostInfoList; host; host = host->fNextHost)
|
||||
{
|
||||
if (!PL_strcasecmp(hostName, host->fHostName))
|
||||
if (!PL_strcasecmp(hostName, host->fHostName) && !PL_strcasecmp(userName, host->fUserName))
|
||||
return host;
|
||||
}
|
||||
return host;
|
||||
|
@ -566,14 +570,41 @@ NS_IMETHODIMP nsIMAPHostSessionList::GetNamespaceNumberForHost(const char *hostN
|
|||
return (host == NULL) ? NS_ERROR_ILLEGAL_VALUE : NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsIMAPHostSessionList::SetNamespacesPrefForHost(nsIImapIncomingServer *aHost, EIMAPNamespaceType type, char *pref)
|
||||
{
|
||||
if (type == kPersonalNamespace)
|
||||
aHost->SetPersonalNamespace(pref);
|
||||
else if (type == kPublicNamespace)
|
||||
aHost->SetPublicNamespace(pref);
|
||||
else if (type == kOtherUsersNamespace)
|
||||
aHost->SetOtherUsersNamespace(pref);
|
||||
else
|
||||
NS_ASSERTION(PR_FALSE, "bogus namespace type");
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
// do we need this? What should we do about the master thing?
|
||||
// Make sure this is running in the Mozilla thread when called
|
||||
NS_IMETHODIMP nsIMAPHostSessionList::CommitNamespacesForHost(const char *hostName, const char *userName)
|
||||
NS_IMETHODIMP nsIMAPHostSessionList::CommitNamespacesForHost(nsIImapIncomingServer *aHost)
|
||||
{
|
||||
char * hostName = nsnull;
|
||||
char * userName = nsnull;
|
||||
|
||||
if (!aHost)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsCOMPtr <nsIMsgIncomingServer> incomingServer = do_QueryInterface(aHost);
|
||||
if (!incomingServer)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult rv = incomingServer->GetHostName(&hostName);
|
||||
rv = incomingServer->GetUsername(&userName);
|
||||
|
||||
PR_EnterMonitor(gCachedHostInfoMonitor);
|
||||
nsIMAPHostInfo *host = FindHost(hostName, userName);
|
||||
if (host)
|
||||
{
|
||||
host->fGotNamespaces = PR_TRUE; // so we only issue NAMESPACE once per host per session.
|
||||
EIMAPNamespaceType type = kPersonalNamespace;
|
||||
for (int i = 1; i <= 3; i++)
|
||||
{
|
||||
|
@ -596,7 +627,7 @@ NS_IMETHODIMP nsIMAPHostSessionList::CommitNamespacesForHost(const char *hostNam
|
|||
int32 numInNS = host->fNamespaceList->GetNumberOfNamespaces(type);
|
||||
if (numInNS == 0)
|
||||
{
|
||||
// MSG_SetNamespacePrefixes(master, host->fHostName, type, NULL);
|
||||
SetNamespacesPrefForHost(aHost, type, NULL);
|
||||
}
|
||||
else if (numInNS >= 1)
|
||||
{
|
||||
|
@ -620,7 +651,7 @@ NS_IMETHODIMP nsIMAPHostSessionList::CommitNamespacesForHost(const char *hostNam
|
|||
}
|
||||
if (pref)
|
||||
{
|
||||
// MSG_SetNamespacePrefixes(master, host->fHostName, type, pref);
|
||||
SetNamespacesPrefForHost(aHost, type, pref);
|
||||
PR_Free(pref);
|
||||
}
|
||||
}
|
||||
|
@ -630,7 +661,7 @@ NS_IMETHODIMP nsIMAPHostSessionList::CommitNamespacesForHost(const char *hostNam
|
|||
|
||||
// Now reset all of libmsg's namespace references.
|
||||
// Did I mention this needs to be running in the mozilla thread?
|
||||
// MSG_ResetNamespaceReferences(master, host->fHostName);
|
||||
aHost->ResetNamespaceReferences();
|
||||
}
|
||||
PR_ExitMonitor(gCachedHostInfoMonitor);
|
||||
return (host == NULL) ? NS_ERROR_ILLEGAL_VALUE : NS_OK;
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "nspr.h"
|
||||
|
||||
class nsIMAPNamespaceList;
|
||||
class nsIImapIncomingServer;
|
||||
|
||||
class nsIMAPHostInfo
|
||||
{
|
||||
|
@ -130,7 +131,7 @@ public:
|
|||
NS_IMETHOD GetNumberOfNamespacesForHost(const char *hostName, const char *userName, PRUint32 &result);
|
||||
NS_IMETHOD GetNamespaceNumberForHost(const char *hostName, const char *userName, PRInt32 n, nsIMAPNamespace * &result);
|
||||
// ### dmb hoo boy, how are we going to do this?
|
||||
NS_IMETHOD CommitNamespacesForHost(const char *hostName, const char *userName);
|
||||
NS_IMETHOD CommitNamespacesForHost(nsIImapIncomingServer *host);
|
||||
NS_IMETHOD FlushUncommittedNamespacesForHost(const char *hostName, const char *userName, PRBool &result);
|
||||
|
||||
// Hierarchy Delimiters
|
||||
|
@ -145,6 +146,8 @@ public:
|
|||
PRMonitor *gCachedHostInfoMonitor;
|
||||
nsIMAPHostInfo *fHostInfoList;
|
||||
protected:
|
||||
nsresult SetNamespacesPrefForHost(nsIImapIncomingServer *aHost, EIMAPNamespaceType type, char *pref);
|
||||
|
||||
nsIMAPHostInfo *FindHost(const char *hostName, const char *userName);
|
||||
};
|
||||
|
||||
|
|
|
@ -91,7 +91,6 @@ private:
|
|||
nsCOMPtr<nsISupportsArray> m_urlQueue;
|
||||
nsVoidArray m_urlConsumers;
|
||||
PRUint32 m_capability;
|
||||
PRBool m_gotNamespaces;
|
||||
};
|
||||
|
||||
|
||||
|
@ -128,7 +127,6 @@ nsImapIncomingServer::nsImapIncomingServer() : m_rootFolderPath(nsnull)
|
|||
rv = NS_NewISupportsArray(getter_AddRefs(m_connectionCache));
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(m_urlQueue));
|
||||
m_capability = kCapabilityUndefined;
|
||||
m_gotNamespaces = PR_FALSE;
|
||||
}
|
||||
|
||||
nsImapIncomingServer::~nsImapIncomingServer()
|
||||
|
@ -1150,18 +1148,96 @@ NS_IMETHODIMP nsImapIncomingServer::SetCapability(PRUint32 capability)
|
|||
|
||||
NS_IMETHODIMP nsImapIncomingServer::CommitNamespaces()
|
||||
{
|
||||
char * hostName = nsnull;
|
||||
char * userName = nsnull;
|
||||
|
||||
nsresult rv = GetHostName(&hostName);
|
||||
rv = GetUsername(&userName);
|
||||
|
||||
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIImapHostSessionList, hostSession, kCImapHostSessionList, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
m_gotNamespaces = PR_TRUE; // so we only issue NAMESPACE once per host per session.
|
||||
|
||||
return hostSession->CommitNamespacesForHost(hostName, userName);
|
||||
return hostSession->CommitNamespacesForHost(this);
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImapIncomingServer::ResetNamespaceReferences()
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
#if FINISHED_PORTED_NAMESPACE_STUFF
|
||||
int numberOfChildren = GetNumSubFolders();
|
||||
for (int childIndex = 0; childIndex < numberOfChildren; childIndex++)
|
||||
{
|
||||
MSG_IMAPFolderInfoMail *currentChild = (MSG_IMAPFolderInfoMail *) GetSubFolder(childIndex);
|
||||
currentChild->ResetNamespaceReferences();
|
||||
}
|
||||
|
||||
void MSG_IMAPFolderInfoMail::SetFolderIsNamespace(XP_Bool isNamespace)
|
||||
{
|
||||
m_folderIsNamespace = isNamespace;
|
||||
}
|
||||
|
||||
void MSG_IMAPFolderInfoMail::InitializeFolderCreatedOffline()
|
||||
{
|
||||
TIMAPNamespace *ns = IMAPNS_GetNamespaceForFolder(m_host->GetHostName(), GetOnlineName(), '/');
|
||||
SetOnlineHierarchySeparator(IMAPNS_GetDelimiterForNamespace(ns));
|
||||
}
|
||||
|
||||
TIMAPNamespace *MSG_IMAPFolderInfoMail::GetNamespaceForFolder()
|
||||
{
|
||||
if (!m_namespace)
|
||||
{
|
||||
#ifdef DEBUG_bienvenu
|
||||
// Make sure this isn't causing us to open the database
|
||||
XP_ASSERT(m_OnlineHierSeparator != kOnlineHierarchySeparatorUnknown);
|
||||
#endif
|
||||
m_namespace = IMAPNS_GetNamespaceForFolder(m_host->GetHostName(), GetOnlineName(), GetOnlineHierarchySeparator());
|
||||
XP_ASSERT(m_namespace);
|
||||
if (m_namespace)
|
||||
{
|
||||
IMAPNS_SuggestHierarchySeparatorForNamespace(m_namespace, GetOnlineHierarchySeparator());
|
||||
m_folderIsNamespace = IMAPNS_GetFolderIsNamespace(m_host->GetHostName(), GetOnlineName(), GetOnlineHierarchySeparator(), m_namespace);
|
||||
}
|
||||
}
|
||||
return m_namespace;
|
||||
}
|
||||
|
||||
void MSG_IMAPFolderInfoMail::SetNamespaceForFolder(TIMAPNamespace *ns)
|
||||
{
|
||||
#ifdef DEBUG_bienvenu
|
||||
NS_ASSERTION(ns, "null namespace");
|
||||
#endif
|
||||
m_namespace = ns;
|
||||
}
|
||||
|
||||
void MSG_IMAPFolderInfoMail::ResetNamespaceReferences()
|
||||
{
|
||||
// this
|
||||
m_namespace = IMAPNS_GetNamespaceForFolder(GetHostName(), GetOnlineName(), GetOnlineHierarchySeparator());
|
||||
NS_ASSERTION(m_namespace, "resetting null namespace");
|
||||
if (m_namespace)
|
||||
m_folderIsNamespace = IMAPNS_GetFolderIsNamespace(GetHostName(), GetOnlineName(), GetOnlineHierarchySeparator(), m_namespace);
|
||||
else
|
||||
m_folderIsNamespace = FALSE;
|
||||
|
||||
// children
|
||||
int numberOfChildren = GetNumSubFolders();
|
||||
for (int childIndex = 0; childIndex < numberOfChildren; childIndex++)
|
||||
{
|
||||
MSG_IMAPFolderInfoMail *currentChild = (MSG_IMAPFolderInfoMail *) GetSubFolder(childIndex);
|
||||
currentChild->ResetNamespaceReferences();
|
||||
}
|
||||
}
|
||||
|
||||
#endif //FINISHED_PORTED_NAMESPACE_STUFF
|
||||
|
||||
NS_IMETHODIMP nsImapIncomingServer::SetUserAuthenticated(PRBool authenticated)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void SetMailServerUrls (in string manageMailAccount, in string manageLists, in string manageFilters); */
|
||||
NS_IMETHODIMP nsImapIncomingServer::SetMailServerUrls(const char *manageMailAccount, const char *manageLists, const char *manageFilters)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -87,10 +87,10 @@ nsImapMailFolder::nsImapMailFolder() :
|
|||
|
||||
// Get current thread envent queue
|
||||
|
||||
NS_WITH_SERVICE(nsIEventQueueService, pEventQService, kEventQueueServiceCID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && pEventQService)
|
||||
pEventQService->GetThreadEventQueue(PR_GetCurrentThread(),
|
||||
getter_AddRefs(m_eventQueue));
|
||||
// NS_WITH_SERVICE(nsIEventQueueService, pEventQService, kEventQueueServiceCID, &rv);
|
||||
// if (NS_SUCCEEDED(rv) && pEventQService)
|
||||
// pEventQService->GetThreadEventQueue(PR_GetCurrentThread(),
|
||||
// getter_AddRefs(m_eventQueue));
|
||||
m_moveCoalescer = nsnull;
|
||||
m_tempMsgFileSpec = nsSpecialSystemDirectory(nsSpecialSystemDirectory::OS_TemporaryDirectory);
|
||||
m_tempMsgFileSpec += "tempMessage.eml";
|
||||
|
@ -447,7 +447,12 @@ NS_IMETHODIMP nsImapMailFolder::GetMessages(nsISimpleEnumerator* *result)
|
|||
// don't run select if we're already running a url/select...
|
||||
if (NS_SUCCEEDED(rv) && !m_urlRunning && selectFolder)
|
||||
{
|
||||
rv = imapService->SelectFolder(m_eventQueue, this, this, nsnull, nsnull);
|
||||
nsCOMPtr <nsIEventQueue> eventQ;
|
||||
NS_WITH_SERVICE(nsIEventQueueService, pEventQService, kEventQueueServiceCID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && pEventQService)
|
||||
pEventQService->GetThreadEventQueue(PR_GetCurrentThread(),
|
||||
getter_AddRefs(eventQ));
|
||||
rv = imapService->SelectFolder(eventQ, this, this, nsnull, nsnull);
|
||||
m_urlRunning = PR_TRUE;
|
||||
}
|
||||
|
||||
|
@ -1198,7 +1203,12 @@ NS_IMETHODIMP nsImapMailFolder::GetNewMessages()
|
|||
PRUint32 numFolders;
|
||||
rv = rootFolder->GetFoldersWithFlag(MSG_FOLDER_FLAG_INBOX, getter_AddRefs(inbox), 1, &numFolders);
|
||||
}
|
||||
rv = imapService->SelectFolder(m_eventQueue, inbox, this, nsnull, nsnull);
|
||||
nsCOMPtr <nsIEventQueue> eventQ;
|
||||
NS_WITH_SERVICE(nsIEventQueueService, pEventQService, kEventQueueServiceCID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && pEventQService)
|
||||
pEventQService->GetThreadEventQueue(PR_GetCurrentThread(),
|
||||
getter_AddRefs(eventQ));
|
||||
rv = imapService->SelectFolder(eventQ, inbox, this, nsnull, nsnull);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -2865,11 +2875,17 @@ nsImapMailFolder::GetShowAttachmentsInline(nsIImapProtocol* aProtocol,
|
|||
NS_IMETHODIMP
|
||||
nsImapMailFolder::HeaderFetchCompleted(nsIImapProtocol* aProtocol)
|
||||
{
|
||||
nsresult rv;
|
||||
if (mDatabase)
|
||||
mDatabase->Commit(nsMsgDBCommitType::kLargeCommit);
|
||||
if (m_moveCoalescer)
|
||||
{
|
||||
m_moveCoalescer->PlaybackMoves (m_eventQueue);
|
||||
nsCOMPtr <nsIEventQueue> eventQ;
|
||||
NS_WITH_SERVICE(nsIEventQueueService, pEventQService, kEventQueueServiceCID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && pEventQService)
|
||||
pEventQService->GetThreadEventQueue(PR_GetCurrentThread(),
|
||||
getter_AddRefs(eventQ));
|
||||
m_moveCoalescer->PlaybackMoves (eventQ);
|
||||
delete m_moveCoalescer;
|
||||
m_moveCoalescer = nsnull;
|
||||
}
|
||||
|
@ -2977,12 +2993,6 @@ nsImapMailFolder::PercentProgress(nsIImapProtocol* aProtocol,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapMailFolder::PastPasswordCheck(nsIImapProtocol* aProtocol)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapMailFolder::TunnelOutStream(nsIImapProtocol* aProtocol,
|
||||
msg_line_info* aInfo)
|
||||
|
|
|
@ -279,7 +279,6 @@ public:
|
|||
PRUint32 aMsgId, const char *extraInfo);
|
||||
NS_IMETHOD PercentProgress(nsIImapProtocol* aProtocol,
|
||||
ProgressInfo* aInfo);
|
||||
NS_IMETHOD PastPasswordCheck(nsIImapProtocol* aProtocol);
|
||||
NS_IMETHOD TunnelOutStream(nsIImapProtocol* aProtocol,
|
||||
msg_line_info* aInfo);
|
||||
NS_IMETHOD ProcessTunnel(nsIImapProtocol* aProtocol,
|
||||
|
|
|
@ -140,6 +140,13 @@ NS_IMETHODIMP nsImapProtocol::QueryInterface(const nsIID &aIID, void** aInstance
|
|||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIsThreadsafeIID, NS_ISTHREADSAFE_IID);
|
||||
|
||||
if (aIID.Equals(nsCOMTypeInfo<nsIRunnable>::GetIID()))
|
||||
{
|
||||
*aInstancePtr = (nsIRunnable *) this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aIID.Equals(nsIStreamListener::GetIID()))
|
||||
{
|
||||
*aInstancePtr = (nsIStreamListener *) this;
|
||||
|
@ -154,7 +161,7 @@ NS_IMETHODIMP nsImapProtocol::QueryInterface(const nsIID &aIID, void** aInstance
|
|||
}
|
||||
if (aIID.Equals(kISupportsIID))
|
||||
{
|
||||
*aInstancePtr = (void*) ((nsISupports*)this);
|
||||
*aInstancePtr = (void*) ((nsISupports*) (nsIImapProtocol *) this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -268,10 +275,20 @@ nsresult nsImapProtocol::Initialize(nsIImapHostSessionList * aHostSessionList, n
|
|||
m_fetchBodyListMonitor = PR_NewMonitor();
|
||||
|
||||
SetFlag(IMAP_FIRST_PASS_IN_THREAD);
|
||||
m_thread = PR_CreateThread(PR_USER_THREAD, ImapThreadMain, (void*)
|
||||
this, PR_PRIORITY_NORMAL, PR_LOCAL_THREAD,
|
||||
PR_UNJOINABLE_THREAD, 0);
|
||||
NS_ASSERTION(m_thread, "Unable to create imap thread.\n");
|
||||
// m_thread = PR_CreateThread(PR_USER_THREAD, ImapThreadMain, (void*)
|
||||
// this, PR_PRIORITY_NORMAL, PR_LOCAL_THREAD,
|
||||
// PR_UNJOINABLE_THREAD, 0);
|
||||
nsIThread* workerThread = nsnull;
|
||||
|
||||
nsresult rv = NS_NewThread(&workerThread, this, 0, PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,
|
||||
PR_UNJOINABLE_THREAD);
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
NS_ASSERTION(workerThread, "Unable to create imap thread.\n");
|
||||
return rv;
|
||||
}
|
||||
workerThread->GetPRThread(&m_thread);
|
||||
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -518,19 +535,19 @@ void nsImapProtocol::ReleaseUrlState()
|
|||
|
||||
}
|
||||
|
||||
void nsImapProtocol::ImapThreadMain(void *aParm)
|
||||
NS_IMETHODIMP nsImapProtocol::Run()
|
||||
{
|
||||
nsImapProtocol *me = (nsImapProtocol *) aParm;
|
||||
nsImapProtocol *me = this;
|
||||
nsresult result = NS_OK;
|
||||
NS_ASSERTION(me, "Yuk, me is null.\n");
|
||||
|
||||
PR_CEnterMonitor(aParm);
|
||||
PR_CEnterMonitor(this);
|
||||
NS_ASSERTION(me->m_imapThreadIsRunning == PR_FALSE,
|
||||
"Oh. oh. thread is already running. What's wrong here?");
|
||||
if (me->m_imapThreadIsRunning)
|
||||
{
|
||||
PR_CExitMonitor(me);
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -545,7 +562,7 @@ void nsImapProtocol::ImapThreadMain(void *aParm)
|
|||
if (NS_FAILED(result) || !me->m_eventQueue)
|
||||
{
|
||||
PR_CExitMonitor(me);
|
||||
return;
|
||||
return result;
|
||||
}
|
||||
me->m_imapThreadIsRunning = PR_TRUE;
|
||||
PR_CExitMonitor(me);
|
||||
|
@ -578,6 +595,7 @@ void nsImapProtocol::ImapThreadMain(void *aParm)
|
|||
me->m_imapMiscellaneousSink = null_nsCOMPtr();
|
||||
|
||||
NS_RELEASE(me);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool
|
||||
|
@ -702,17 +720,20 @@ nsImapProtocol::ImapThreadMainLoop()
|
|||
|
||||
err = PR_Wait(m_urlReadyToRunMonitor, sleepTime);
|
||||
|
||||
PR_ExitMonitor(m_urlReadyToRunMonitor);
|
||||
if (err == PR_FAILURE && PR_PENDING_INTERRUPT_ERROR == PR_GetError())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// m_eventQueue->ProcessPendingEvents();
|
||||
// m_sinkEventQueue->ProcessPendingEvents();
|
||||
|
||||
if (m_nextUrlReadyToRun && m_runningUrl)
|
||||
ProcessCurrentURL();
|
||||
|
||||
m_nextUrlReadyToRun = PR_FALSE;
|
||||
|
||||
PR_ExitMonitor(m_urlReadyToRunMonitor);
|
||||
}
|
||||
m_imapThreadIsRunning = PR_FALSE;
|
||||
}
|
||||
|
@ -899,7 +920,6 @@ void nsImapProtocol::ProcessCurrentURL()
|
|||
HandleCurrentUrlError();
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(m_runningUrl, &rv);
|
||||
if (NS_SUCCEEDED(rv) && mailnewsurl && m_imapMiscellaneousSink)
|
||||
{
|
||||
|
@ -913,7 +933,7 @@ void nsImapProtocol::ProcessCurrentURL()
|
|||
|
||||
if (m_runningUrl)
|
||||
rv = m_runningUrl->GetCopyState(getter_AddRefs(copyState));
|
||||
if (NS_SUCCEEDED(rv) && m_imapMiscellaneousSink && copyState)
|
||||
if (NS_SUCCEEDED(rv) && GetConnectionStatus() >= 0 && m_imapMiscellaneousSink && copyState)
|
||||
{
|
||||
m_imapMiscellaneousSink->CopyNextStreamMessage(this, copyState);
|
||||
WaitForFEEventCompletion();
|
||||
|
@ -924,7 +944,7 @@ void nsImapProtocol::ProcessCurrentURL()
|
|||
m_runningUrl = null_nsCOMPtr();
|
||||
|
||||
// now try queued urls, now that we've released this connection.
|
||||
if (m_server && m_imapMiscellaneousSink)
|
||||
if (m_server && m_imapMiscellaneousSink && GetConnectionStatus() >= 0)
|
||||
{
|
||||
nsCOMPtr<nsIImapIncomingServer> aImapServer = do_QueryInterface(m_server, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
|
@ -934,6 +954,15 @@ void nsImapProtocol::ProcessCurrentURL()
|
|||
}
|
||||
// release the url as we are done with it...
|
||||
ReleaseUrlState();
|
||||
if (GetConnectionStatus() < 0)
|
||||
{
|
||||
nsCOMPtr<nsIImapIncomingServer> aImapServer = do_QueryInterface(m_server, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
aImapServer->RemoveConnection(this);
|
||||
TellThreadToDie(PR_TRUE);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void nsImapProtocol::ParseIMAPandCheckForNewMail(const char* commandString)
|
||||
|
@ -2845,7 +2874,6 @@ NS_IMETHODIMP nsImapProtocol::GetSupportedUserFlags(PRUint16 *supportedFlags)
|
|||
}
|
||||
void nsImapProtocol::FolderMsgDumpLoop(PRUint32 *msgUids, PRUint32 msgCount, nsIMAPeFetchFields fields)
|
||||
{
|
||||
// PastPasswordCheckEvent();
|
||||
|
||||
PRInt32 msgCountLeft = msgCount;
|
||||
PRUint32 msgsDownloaded = 0;
|
||||
|
@ -4471,6 +4499,22 @@ void nsImapProtocol::XServerInfo()
|
|||
ParseIMAPandCheckForNewMail();
|
||||
}
|
||||
|
||||
void nsImapProtocol::Netscape()
|
||||
{
|
||||
ProgressEventFunctionUsingId (IMAP_GETTING_SERVER_INFO);
|
||||
IncrementCommandTagNumber();
|
||||
|
||||
nsCString command(GetServerCommandTag());
|
||||
|
||||
command.Append(" netscape" CRLF);
|
||||
|
||||
nsresult rv = SendData(command.GetBuffer());
|
||||
if (NS_SUCCEEDED(rv))
|
||||
ParseIMAPandCheckForNewMail();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void nsImapProtocol::XMailboxInfo(const char *mailboxName)
|
||||
{
|
||||
|
||||
|
@ -5670,50 +5714,31 @@ void nsImapProtocol::ProcessAuthenticatedStateURL()
|
|||
void nsImapProtocol::ProcessAfterAuthenticated()
|
||||
{
|
||||
// mscott: ignore admin url stuff for now...
|
||||
#ifdef UNREADY_CODE
|
||||
// if we're a netscape server, and we haven't got the admin url, get it
|
||||
if (!TIMAPHostInfo::GetHostHasAdminURL(fCurrentUrl->GetUrlHost()))
|
||||
PRBool hasAdminUrl = PR_TRUE;
|
||||
|
||||
if (NS_SUCCEEDED(m_hostSessionList->GetHostHasAdminURL(GetImapHostName(), GetImapUserName(), hasAdminUrl))
|
||||
&& !hasAdminUrl)
|
||||
{
|
||||
if (GetServerStateParser().GetCapabilityFlag() & kXServerInfoCapability)
|
||||
if (GetServerStateParser().ServerHasServerInfo())
|
||||
{
|
||||
XServerInfo();
|
||||
if (GetServerStateParser().LastCommandSuccessful())
|
||||
if (GetServerStateParser().LastCommandSuccessful() && m_imapServerSink)
|
||||
{
|
||||
TImapFEEvent *alertEvent =
|
||||
new TImapFEEvent(msgSetMailServerURLs, // function to call
|
||||
this, // access to current entry
|
||||
(void *) fCurrentUrl->GetUrlHost(),
|
||||
PR_TRUE);
|
||||
if (alertEvent)
|
||||
{
|
||||
fFEEventQueue->AdoptEventToEnd(alertEvent);
|
||||
// WaitForFEEventCompletion();
|
||||
}
|
||||
else
|
||||
HandleMemoryFailure();
|
||||
m_imapServerSink->SetMailServerUrls(GetServerStateParser().GetMailAccountUrl(),
|
||||
GetServerStateParser().GetManageListsUrl(),
|
||||
GetServerStateParser().GetManageFiltersUrl());
|
||||
}
|
||||
}
|
||||
else if (GetServerStateParser().GetCapabilityFlag() & kHasXNetscapeCapability)
|
||||
else if (GetServerStateParser().ServerIsNetscape3xServer())
|
||||
{
|
||||
Netscape();
|
||||
if (GetServerStateParser().LastCommandSuccessful())
|
||||
if (GetServerStateParser().LastCommandSuccessful() && m_imapServerSink)
|
||||
{
|
||||
TImapFEEvent *alertEvent =
|
||||
new TImapFEEvent(msgSetMailAccountURL, // function to call
|
||||
this, // access to current entry
|
||||
(void *) fCurrentUrl->GetUrlHost(),
|
||||
PR_TRUE);
|
||||
if (alertEvent)
|
||||
{
|
||||
fFEEventQueue->AdoptEventToEnd(alertEvent);
|
||||
// WaitForFEEventCompletion();
|
||||
}
|
||||
else
|
||||
HandleMemoryFailure();
|
||||
m_imapServerSink->SetMailServerUrls(GetServerStateParser().GetMailAccountUrl(), nsnull, nsnull);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (GetServerStateParser().ServerHasNamespaceCapability())
|
||||
{
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "nsIWebShell.h"
|
||||
#include "nsIMsgIncomingServer.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsIThread.h"
|
||||
|
||||
class nsIMAPMessagePartIDArray;
|
||||
class nsIMsgIncomingServer;
|
||||
|
@ -54,7 +55,7 @@ class nsIWebShell;
|
|||
#define IMAP_CONNECTION_IS_OPEN 0x00000004 /* is the connection currently open? */
|
||||
#define IMAP_WAITING_FOR_DATA 0x00000008
|
||||
|
||||
class nsImapProtocol : public nsIImapProtocol
|
||||
class nsImapProtocol : public nsIImapProtocol, public nsIRunnable
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -64,6 +65,9 @@ public:
|
|||
|
||||
virtual ~nsImapProtocol();
|
||||
|
||||
// nsIRunnable method
|
||||
NS_IMETHOD Run();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// we support the nsIImapProtocol interface
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -221,6 +225,7 @@ public:
|
|||
void Logout();
|
||||
void Noop();
|
||||
void XServerInfo();
|
||||
void Netscape();
|
||||
void XMailboxInfo(const char *mailboxName);
|
||||
void MailboxData();
|
||||
void GetMyRightsForFolder(const char *mailboxName);
|
||||
|
@ -307,7 +312,7 @@ private:
|
|||
PRMonitor *m_fetchBodyListMonitor;
|
||||
|
||||
PRBool m_imapThreadIsRunning;
|
||||
static void ImapThreadMain(void *aParm);
|
||||
// static void ImapThreadMain(void *aParm);
|
||||
void ImapThreadMainLoop(void);
|
||||
PRBool ImapThreadIsRunning();
|
||||
PRInt32 m_connectionStatus;
|
||||
|
|
|
@ -1466,28 +1466,6 @@ nsImapMiscellaneousSinkProxy::PercentProgress(nsIImapProtocol* aProtocol,
|
|||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapMiscellaneousSinkProxy::PastPasswordCheck(nsIImapProtocol* aProtocol)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
NS_ASSERTION (m_protocol == aProtocol, "Ooh ooh, wrong protocol");
|
||||
|
||||
if (PR_GetCurrentThread() == m_thread)
|
||||
{
|
||||
PastPasswordCheckProxyEvent *ev =
|
||||
new PastPasswordCheckProxyEvent(this);
|
||||
if(nsnull == ev)
|
||||
res = NS_ERROR_OUT_OF_MEMORY;
|
||||
else
|
||||
ev->PostEvent(m_eventQueue);
|
||||
}
|
||||
else
|
||||
{
|
||||
res = m_realImapMiscellaneousSink->PastPasswordCheck(aProtocol);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapMiscellaneousSinkProxy::TunnelOutStream(nsIImapProtocol* aProtocol,
|
||||
msg_line_info* aInfo)
|
||||
|
@ -3034,26 +3012,6 @@ PercentProgressProxyEvent::HandleEvent()
|
|||
return res;
|
||||
}
|
||||
|
||||
PastPasswordCheckProxyEvent::PastPasswordCheckProxyEvent(
|
||||
nsImapMiscellaneousSinkProxy* aProxy) :
|
||||
nsImapMiscellaneousSinkProxyEvent(aProxy)
|
||||
{
|
||||
}
|
||||
|
||||
PastPasswordCheckProxyEvent::~PastPasswordCheckProxyEvent()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PastPasswordCheckProxyEvent::HandleEvent()
|
||||
{
|
||||
nsresult res = m_proxy->m_realImapMiscellaneousSink->PastPasswordCheck(
|
||||
m_proxy->m_protocol);
|
||||
if (m_notifyCompletion)
|
||||
m_proxy->m_protocol->NotifyFEEventCompletion();
|
||||
return res;
|
||||
}
|
||||
|
||||
TunnelOutStreamProxyEvent::TunnelOutStreamProxyEvent(
|
||||
nsImapMiscellaneousSinkProxy* aProxy, msg_line_info* aInfo) :
|
||||
nsImapMiscellaneousSinkProxyEvent(aProxy)
|
||||
|
|
|
@ -222,7 +222,6 @@ public:
|
|||
PRUint32 statusMsgId, const char *extraInfo);
|
||||
NS_IMETHOD PercentProgress(nsIImapProtocol* aProtocol,
|
||||
ProgressInfo* aInfo);
|
||||
NS_IMETHOD PastPasswordCheck(nsIImapProtocol* aProtocol);
|
||||
NS_IMETHOD TunnelOutStream(nsIImapProtocol* aProtocol,
|
||||
msg_line_info* aInfo);
|
||||
NS_IMETHOD ProcessTunnel(nsIImapProtocol* aProtocol,
|
||||
|
@ -696,13 +695,6 @@ struct PercentProgressProxyEvent : public nsImapMiscellaneousSinkProxyEvent
|
|||
ProgressInfo m_progressInfo;
|
||||
};
|
||||
|
||||
struct PastPasswordCheckProxyEvent : public nsImapMiscellaneousSinkProxyEvent
|
||||
{
|
||||
PastPasswordCheckProxyEvent(nsImapMiscellaneousSinkProxy* aProxy);
|
||||
virtual ~PastPasswordCheckProxyEvent();
|
||||
NS_IMETHOD HandleEvent();
|
||||
};
|
||||
|
||||
struct TunnelOutStreamProxyEvent : public nsImapMiscellaneousSinkProxyEvent
|
||||
{
|
||||
TunnelOutStreamProxyEvent(nsImapMiscellaneousSinkProxy* aProxy,
|
||||
|
|
Загрузка…
Ссылка в новой задаче