Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes
nsImapProtocol Class Reference

#include <nsImapProtocol.h>

Inheritance diagram for nsImapProtocol:
Inheritance graph
[legend]
Collaboration diagram for nsImapProtocol:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSIINPUTSTREAMCALLBACK 
nsImapProtocol ()
virtual ~nsImapProtocol ()
virtual nsresult ProcessProtocolState (nsIURI *url, nsIInputStream *inputStream, PRUint32 sourceOffset, PRUint32 length)
NS_IMETHOD Run ()
 Defines an entry point for a newly created thread.
NS_DECL_NSIIMAPPROTOCOL void CloseStreams ()
PRUint32 CountMessagesInIdString (const char *idString)
void GetShouldDownloadAllHeaders (PRBool *aResult)
void GetArbitraryHeadersToDownload (char **aResult)
virtual void AdjustChunkSize ()
virtual void FetchMessage (const char *messageIds, nsIMAPeFetchFields whatToFetch, PRBool idAreUid, PRUint32 startByte=0, PRUint32 endByte=0, char *part=0)
void FetchTryChunking (const char *messageIds, nsIMAPeFetchFields whatToFetch, PRBool idIsUid, char *part, PRUint32 downloadSize, PRBool tryChunking)
virtual void PipelinedFetchMessageParts (nsCString &uid, nsIMAPMessagePartIDArray *parts)
void FallbackToFetchWholeMsg (const char *messageId, PRUint32 messageSize)
virtual nsresult BeginMessageDownLoad (PRUint32 totalSize, const char *contentType)
virtual void HandleMessageDownLoadLine (const char *line, PRBool isPartialLine, char *lineCopy=nsnull)
virtual void NormalMessageEndDownload ()
virtual void AbortMessageDownLoad ()
virtual void PostLineDownLoadEvent (msg_line_info *downloadLineDontDelete)
virtual void SetMailboxDiscoveryStatus (EMailboxDiscoverStatus status)
virtual EMailboxDiscoverStatus GetMailboxDiscoveryStatus ()
virtual void ProcessMailboxUpdate (PRBool handlePossibleUndo)
void Log (const char *logSubName, const char *extraInfo, const char *logData)
PRBool GetPseudoInterrupted ()
void PseudoInterrupt (PRBool the_interrupt)
PRUint32 GetMessageSize (const char *messageId, PRBool idsAreUids)
PRBool GetSubscribingNow ()
PRBool DeathSignalReceived ()
void ResetProgressInfo ()
void SetActive (PRBool active)
PRBool GetActive ()
PRBool GetShowAttachmentsInline ()
void SetContentModified (IMAP_ContentModifiedType modified)
PRBool GetShouldFetchAllParts ()
PRBool GetIgnoreExpunges ()
char * CreateNewLineFromSocket ()
PRInt32 GetConnectionStatus ()
void SetConnectionStatus (PRInt32 status)
const char * GetImapHostName ()
const char * GetImapUserName ()
const char * GetImapServerKey ()
void NotifyMessageFlags (imapMessageFlagsType flags, nsMsgKey key)
void NotifySearchHit (const char *hitLine)
void DiscoverMailboxSpec (nsImapMailboxSpec *adoptedBoxSpec)
void AlertUserEventUsingId (PRUint32 aMessageId)
void AlertUserEvent (const char *message)
void AlertUserEventFromServer (const char *aServerEvent)
void ProgressEventFunctionUsingId (PRUint32 aMsgId)
void ProgressEventFunctionUsingIdWithString (PRUint32 aMsgId, const char *aExtraInfo)
void PercentProgressUpdateEvent (PRUnichar *message, PRInt32 currentProgress, PRInt32 maxProgress)
void ShowProgress ()
void Copy (const char *messageList, const char *destinationMailbox, PRBool idsAreUid)
void Search (const char *searchCriteria, PRBool useUID, PRBool notifyHit=PR_TRUE)
void Store (const char *aMessageList, const char *aMessageData, PRBool aIdsAreUid)
void ProcessStoreFlags (const char *messageIds, PRBool idsAreUids, imapMessageFlagsType flags, PRBool addFlags)
void IssueUserDefinedMsgCommand (const char *command, const char *messageList)
void FetchMsgAttribute (const char *messageIds, const char *attribute)
void Expunge ()
void UidExpunge (const char *messageSet)
void Close (PRBool shuttingDown=PR_FALSE, PRBool waitForResponse=PR_TRUE)
void Check ()
void SelectMailbox (const char *mailboxName)
void Logout (PRBool shuttingDown=PR_FALSE, PRBool waitForResponse=PR_TRUE)
void Noop ()
void XServerInfo ()
void Netscape ()
void XMailboxInfo (const char *mailboxName)
void XAOL_Option (const char *option)
void MailboxData ()
void GetMyRightsForFolder (const char *mailboxName)
void AutoSubscribeToMailboxIfNecessary (const char *mailboxName)
void Bodystructure (const char *messageId, PRBool idIsUid)
void PipelinedFetchMessageParts (const char *uid, nsIMAPMessagePartIDArray *parts)
nsIImapUrlGetCurrentUrl ()
virtual PRInt32 OpenTunnel (PRInt32 maxNumberOfBytesToRead)
PRBool GetIOTunnellingEnabled ()
PRInt32 GetTunnellingThreshold ()
void CommitNamespacesForHostEvent ()
void CommitCapability ()
void AddFolderRightsForUser (const char *mailboxName, const char *userName, const char *rights)
void ClearAllFolderRights (const char *mailboxName, nsIMAPNamespace *nsForMailbox)
void RefreshFolderACLView (const char *mailboxName, nsIMAPNamespace *nsForMailbox)
nsresult SetFolderAdminUrl (const char *mailboxName)
void HandleMemoryFailure ()
void HandleCurrentUrlError ()
void SetCopyResponseUid (const char *msgIdString)
void UpdateFolderQuotaData (nsCString &aQuotaRoot, PRUint32 aUsed, PRUint32 aMax)
void LoadImapUrl (in nsIURI aUrl, in nsISupports aConsumer)
void IsBusy (out boolean aIsConnectionBusy, out boolean isInboxConnection)
void CanHandleUrl (in nsIImapUrl aImapUrl, out boolean aCanRunUrl, out boolean hasToWait)
void Initialize (in nsIImapHostSessionList aHostSessionList, in nsIImapIncomingServer aServer, in nsIEventQueue aSinkEventQueue)
void NotifyHdrsToDownload (out unsigned long keys, in unsigned long keyCount)
void NotifyBodysToDownload (out unsigned long keys, in unsigned long count)
void GetFlagsForUID (in unsigned long uid, out boolean foundIt, out unsigned short flags, out string customFlags)
void GetSupportedUserFlags (out unsigned short flags)
void GetRunningImapURL (out nsIImapUrl aImapUrl)
void GetRunningUrl (out nsIURI aUrl)
void TellThreadToDie (in boolean isSafeToDie)
void GetLastActiveTimeStamp (out PRTime aTimeStamp)
void pseudoInterruptMsgLoad (in nsIMsgFolder imapFolder, in nsIMsgWindow aMsgWindow, out boolean interrupted)
void GetSelectedMailboxName (out string folderName)
void ResetToAuthenticatedState ()
void OverrideConnectionInfo (in wstring pHost, in unsigned short pPort, in string pCookieData)
void run ()
void onInputStreamReady (in nsIAsyncInputStream aStream)
 Called to indicate that the stream is either readable or closed.

Static Public Member Functions

static PRBool HandlingMultipleMessages (const char *messageIdString)
static void EscapeUserNamePasswordString (const char *strToEscape, nsCString *resultStr)
static void LogImapUrl (const char *logMsg, nsIImapUrl *imapUrl)

Private Types

enum  EMailboxHierarchyNameState {
  kNoOperationInProgress, kDiscoverBaseFolderInProgress, kDiscoverTrashFolderInProgress, kDeleteSubFoldersInProgress,
  kListingForInfoOnly, kListingForInfoAndDiscovery, kDiscoveringNamespacesOnly, kListingForCreate
}

Private Member Functions

void ImapThreadMainLoop (void)
void SetupSinkProxy ()
PRBool GetDeleteIsMoveToTrash ()
PRBool GetShowDeletedMessages ()
PRMonitorGetDataMemberMonitor ()
nsImapServerResponseParserGetServerStateParser ()
void HandleIdleResponses ()
virtual PRBool ProcessCurrentURL ()
void EstablishServerConnection ()
virtual void ParseIMAPandCheckForNewMail (const char *commandString=nsnull, PRBool ignoreBadNOResponses=PR_FALSE)
void PeriodicBiff ()
void SendSetBiffIndicatorEvent (nsMsgBiffState newState)
PRBool CheckNewMail ()
void UpdatedMailboxSpec (nsImapMailboxSpec *aSpec)
void FolderHeaderDump (PRUint32 *msgUids, PRUint32 msgCount)
void FolderMsgDump (PRUint32 *msgUids, PRUint32 msgCount, nsIMAPeFetchFields fields)
void FolderMsgDumpLoop (PRUint32 *msgUids, PRUint32 msgCount, nsIMAPeFetchFields fields)
void WaitForPotentialListOfMsgsToFetch (PRUint32 **msgIdList, PRUint32 &msgCount)
void WaitForPotentialListOfBodysToFetch (PRUint32 **msgIdList, PRUint32 &msgCount)
void HeaderFetchCompleted ()
void UploadMessageFromFile (nsIFileSpec *fileSpec, const char *mailboxName, PRTime date, imapMessageFlagsType flags, nsCString &keywords)
char * CreateEscapedMailboxName (const char *rawName)
void SetupMessageFlagsString (nsCString &flagString, imapMessageFlagsType flags, PRUint16 userFlags)
nsresult SetupWithUrl (nsIURI *aURL, nsISupports *aConsumer)
void ReleaseUrlState (PRBool rerunningUrl)
nsresult SendData (const char *dataBuffer, PRBool aSuppressLogging=PR_FALSE)
void IncrementCommandTagNumber ()
char * GetServerCommandTag ()
void StartTLS ()
nsresult GetPassword (nsXPIDLCString &password)
void Capability ()
void Language ()
void Namespace ()
void InsecureLogin (const char *userName, const char *password)
nsresult AuthLogin (const char *userName, const char *password, eIMAPCapabilityFlag flag)
void ProcessAuthenticatedStateURL ()
void ProcessAfterAuthenticated ()
void ProcessSelectedStateURL ()
PRBool TryToLogon ()
void OnLSubFolders ()
void OnAppendMsgFromFile ()
char * GetFolderPathString ()
char * OnCreateServerSourceFolderPathString ()
char * OnCreateServerDestinationFolderPathString ()
nsresult CreateServerSourceFolderPathString (char **result)
void OnCreateFolder (const char *aSourceMailbox)
void OnEnsureExistsFolder (const char *aSourceMailbox)
void OnSubscribe (const char *aSourceMailbox)
void OnUnsubscribe (const char *aSourceMailbox)
void RefreshACLForFolderIfNecessary (const char *mailboxName)
void RefreshACLForFolder (const char *aSourceMailbox)
void GetACLForFolder (const char *aMailboxName)
void OnRefreshAllACLs ()
void OnListFolder (const char *aSourceMailbox, PRBool aBool)
void OnStatusForFolder (const char *sourceMailbox)
void OnDeleteFolder (const char *aSourceMailbox)
void OnRenameFolder (const char *aSourceMailbox)
void OnMoveFolderHierarchy (const char *aSourceMailbox)
void DeleteFolderAndMsgs (const char *aSourceMailbox)
void RemoveMsgsAndExpunge ()
void FindMailboxesIfNecessary ()
void CreateMailbox (const char *mailboxName)
void DeleteMailbox (const char *mailboxName)
void RenameMailbox (const char *existingName, const char *newName)
PRBool CreateMailboxRespectingSubscriptions (const char *mailboxName)
PRBool DeleteMailboxRespectingSubscriptions (const char *mailboxName)
PRBool RenameMailboxRespectingSubscriptions (const char *existingName, const char *newName, PRBool reallyRename)
void FolderDeleted (const char *mailboxName)
void FolderNotCreated (const char *mailboxName)
void FolderRenamed (const char *oldName, const char *newName)
PRBool FolderIsSelected (const char *mailboxName)
PRBool MailboxIsNoSelectMailbox (const char *mailboxName)
char * CreatePossibleTrashName (const char *prefix)
const char * GetTrashFolderName ()
PRBool FolderNeedsACLInitialized (const char *folderName)
void DiscoverMailboxList ()
void DiscoverAllAndSubscribedBoxes ()
void MailboxDiscoveryFinished ()
void NthLevelChildList (const char *onlineMailboxPrefix, PRInt32 depth)
void Lsub (const char *mailboxPattern, PRBool addDirectoryIfNecessary)
void List (const char *mailboxPattern, PRBool addDirectoryIfNecessary)
void Subscribe (const char *mailboxName)
void Unsubscribe (const char *mailboxName)
void Idle ()
void EndIdle (PRBool waitForResponse=PR_TRUE)
PRBool DeleteSubFolders (const char *aMailboxName, PRBool &aDeleteSelf)
PRBool RenameHierarchyByHand (const char *oldParentMailboxName, const char *newParentMailboxName)
PRBool RetryUrl ()
nsresult GlobalInitialization ()
nsresult Configure (PRInt32 TooFastTime, PRInt32 IdealTime, PRInt32 ChunkAddSize, PRInt32 ChunkSize, PRInt32 ChunkThreshold, PRBool FetchByChunks, PRInt32 MaxChunkSize)
nsresult GetMsgWindow (nsIMsgWindow **aMsgWindow)
void GetQuotaDataIfSupported (const char *aBoxName)
void SetProgressString (PRInt32 stringId)
PRBool CheckNeeded ()

Private Attributes

PRBool m_urlInProgress
nsCOMPtr< nsIImapUrlm_runningUrl
nsImapAction m_imapAction
nsCString m_hostName
char * m_userName
char * m_serverKey
char * m_dataOutputBuf
nsMsgLineStreamBuffer * m_inputStreamBuffer
PRUint32 m_allocatedSize
PRUint32 m_totalDataSize
PRUint32 m_curReadIndex
nsCAutoString m_trashFolderName
nsCOMPtr< nsISocketTransportm_transport
nsCOMPtr< nsIInputStreamm_channelInputStream
nsCOMPtr< nsIOutputStreamm_channelOutputStream
nsCOMPtr< nsIImapMockChannelm_mockChannel
nsCOMPtr< nsIEventQueuem_sinkEventQueue
nsCOMPtr< nsIThreadm_iThread
PRThreadm_thread
PRMonitorm_dataAvailableMonitor
PRMonitorm_urlReadyToRunMonitor
PRMonitorm_pseudoInterruptMonitor
PRMonitorm_dataMemberMonitor
PRMonitorm_threadDeathMonitor
PRMonitorm_waitForBodyIdsMonitor
PRMonitorm_fetchMsgListMonitor
PRMonitorm_fetchBodyListMonitor
PRBool m_imapThreadIsRunning
PRInt32 m_connectionStatus
nsCString m_connectionType
PRBool m_nextUrlReadyToRun
nsWeakPtr m_server
nsCOMPtr< nsIImapMailFolderSinkm_imapMailFolderSink
nsCOMPtr< nsIImapMessageSinkm_imapMessageSink
nsCOMPtr< nsIImapExtensionSinkm_imapExtensionSink
nsCOMPtr
< nsIImapMiscellaneousSink
m_imapMiscellaneousSink
nsCOMPtr< nsIImapServerSinkm_imapServerSink
nsCString m_currentCommand
nsImapServerResponseParser m_parser
PRBool m_fetchMsgListIsNew
PRUint32 m_fetchCount
PRUint32m_fetchMsgIdList
PRBool m_fetchBodyListIsNew
PRUint32 m_fetchBodyCount
PRUint32m_fetchBodyIdList
PRBool m_pseudoInterrupted
PRBool m_active
PRBool m_folderNeedsSubscribing
PRBool m_folderNeedsACLRefreshed
PRBool m_threadShouldDie
nsImapFlagAndUidStatem_flagState
nsMsgBiffState m_currentBiffState
char m_currentServerCommandTag [10]
int m_currentServerCommandTagNumber
PRBool m_trackingTime
PRTime m_startTime
PRTime m_endTime
PRTime m_lastActiveTime
PRInt32 m_tooFastTime
PRInt32 m_idealTime
PRInt32 m_chunkAddSize
PRInt32 m_chunkStartSize
PRBool m_fetchByChunks
PRBool m_ignoreExpunges
PRBool m_useSecAuth
PRInt32 m_socketType
PRInt32 m_chunkSize
PRInt32 m_chunkThreshold
nsMsgImapLineDownloadCache m_downloadLineCache
nsMsgImapHdrXferInfo m_hdrDownloadCache
nsCOMPtr< nsIImapHeaderInfom_curHdrInfo
nsIImapHostSessionListm_hostSessionList
PRBool m_fromHeaderSeen
PRBool m_overRideUrlConnectionInfo
nsCString m_logonHost
nsCString m_logonCookie
PRInt16 m_logonPort
nsXPIDLString mAcceptLanguages
nsXPIDLString m_progressString
PRInt32 m_progressStringId
PRInt32 m_progressIndex
PRInt32 m_progressCount
PRUint32 m_lastProgressStringId
PRInt32 m_lastPercent
PRInt64 m_lastProgressTime
PRBool m_notifySearchHit
PRBool m_checkForNewMailDownloadsHeaders
PRBool m_needNoop
PRBool m_idle
PRBool m_useIdle
PRInt32 m_noopCount
PRBool m_autoSubscribe
PRBool m_autoUnsubscribe
PRBool m_autoSubscribeOnOpen
PRBool m_closeNeededBeforeSelect
PRBool m_retryUrlOnError
EMailboxHierarchyNameState m_hierarchyNameState
EMailboxDiscoverStatus m_discoveryStatus
nsVoidArray m_listedMailboxList
nsVoidArraym_deletableChildren
PRUint32 m_flagChangeCount
PRTime m_lastCheckTime

Detailed Description

Definition at line 154 of file nsImapProtocol.h.


Member Enumeration Documentation

Enumerator:
kNoOperationInProgress 
kDiscoverBaseFolderInProgress 
kDiscoverTrashFolderInProgress 
kDeleteSubFoldersInProgress 
kListingForInfoOnly 
kListingForInfoAndDiscovery 
kDiscoveringNamespacesOnly 
kListingForCreate 

Definition at line 601 of file nsImapProtocol.h.


Constructor & Destructor Documentation

Definition at line 357 of file nsImapProtocol.cpp.

                               : nsMsgProtocol(nsnull),
    m_parser(*this)
{
  m_urlInProgress = PR_FALSE;
  m_idle = PR_FALSE;
  m_retryUrlOnError = PR_FALSE;
  m_useIdle = PR_TRUE; // by default, use it
  m_ignoreExpunges = PR_FALSE;
  m_useSecAuth = PR_FALSE;
  m_socketType = nsIMsgIncomingServer::tryTLS;
  m_connectionStatus = 0;
  m_hostSessionList = nsnull;
  m_flagState = nsnull;
  m_fetchBodyIdList = nsnull;
    
  if (!gInitialized)
    GlobalInitialization();

  // read in the accept languages preference
  nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID)); 
  if (prefBranch)
  {
    nsCOMPtr<nsIPrefLocalizedString> prefString;
    prefBranch->GetComplexValue("intl.accept_languages",
                                NS_GET_IID(nsIPrefLocalizedString),
                                getter_AddRefs(prefString));
    if (prefString)
      prefString->ToString(getter_Copies(mAcceptLanguages));
  }

    // ***** Thread support *****
  m_thread = nsnull;
  m_dataAvailableMonitor = nsnull;
  m_urlReadyToRunMonitor = nsnull;
  m_pseudoInterruptMonitor = nsnull;
  m_dataMemberMonitor = nsnull;
  m_threadDeathMonitor = nsnull;
  m_waitForBodyIdsMonitor = nsnull;
  m_fetchMsgListMonitor = nsnull;
  m_fetchBodyListMonitor = nsnull;
  m_imapThreadIsRunning = PR_FALSE;
  m_currentServerCommandTagNumber = 0;
  m_active = PR_FALSE;
  m_folderNeedsSubscribing = PR_FALSE;
  m_folderNeedsACLRefreshed = PR_FALSE;
  m_threadShouldDie = PR_FALSE;
  m_pseudoInterrupted = PR_FALSE;
  m_nextUrlReadyToRun = PR_FALSE;
  m_trackingTime = PR_FALSE;
  LL_I2L(m_startTime, 0);
  LL_I2L(m_endTime, 0);
  LL_I2L(m_lastActiveTime, 0);
  LL_I2L(m_lastProgressTime, 0);
  ResetProgressInfo();

  m_tooFastTime = 0;
  m_idealTime = 0;
  m_chunkAddSize = 0;
  m_chunkStartSize = 0;
  m_fetchByChunks = PR_TRUE;
  m_chunkSize = 0;
  m_chunkThreshold = 0;
  m_fromHeaderSeen = PR_FALSE;
  m_closeNeededBeforeSelect = PR_FALSE;
  m_needNoop = PR_FALSE;
  m_noopCount = 0;
  m_fetchMsgListIsNew = PR_FALSE;
  m_fetchBodyListIsNew = PR_FALSE;
  m_flagChangeCount = 0;
  m_lastCheckTime = PR_Now();

  m_checkForNewMailDownloadsHeaders = PR_TRUE;  // this should be on by default
  m_hierarchyNameState = kNoOperationInProgress;
  m_discoveryStatus = eContinue;

  m_overRideUrlConnectionInfo = PR_FALSE;
  // m_dataOutputBuf is used by Send Data
  m_dataOutputBuf = (char *) PR_CALLOC(sizeof(char) * OUTPUT_BUFFER_SIZE);
  m_allocatedSize = OUTPUT_BUFFER_SIZE;

  // used to buffer incoming data by ReadNextLine
  m_inputStreamBuffer = new nsMsgLineStreamBuffer(OUTPUT_BUFFER_SIZE, PR_TRUE /* allocate new lines */, PR_FALSE /* leave CRLFs on the returned string */);
  m_currentBiffState = nsIMsgFolder::nsMsgBiffState_Unknown;

  m_hostName.Truncate();
  m_userName = nsnull;
  m_serverKey = nsnull;

  m_progressStringId = 0;

  // since these are embedded in the nsImapProtocol object, but passed
  // through proxied xpcom methods, just AddRef them here.
  m_hdrDownloadCache.AddRef();
  m_downloadLineCache.AddRef();

  // subscription
  m_autoSubscribe = PR_TRUE;
  m_autoUnsubscribe = PR_TRUE;
  m_autoSubscribeOnOpen = PR_TRUE;
  m_deletableChildren = nsnull;

  Configure(gTooFastTime, gIdealTime, gChunkAddSize, gChunkSize,
                    gChunkThreshold, gFetchByChunks, gMaxChunkSize);

  // where should we do this? Perhaps in the factory object?
  if (!IMAP)
    IMAP = PR_NewLogModule("IMAP");
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 3569 of file nsImapProtocol.cpp.

{
  Log("STREAM", "CLOSE", "Abort Message  Download Stream");

  if (m_trackingTime)
    AdjustChunkSize();
  if (!m_downloadLineCache.CacheEmpty())
  {
      msg_line_info *downloadLineDontDelete = m_downloadLineCache.GetCurrentLineInfo();
      PostLineDownLoadEvent(downloadLineDontDelete);
      m_downloadLineCache.ResetCache();
    }

  if (GetServerStateParser().GetDownloadingHeaders())
  {
    if (m_imapMailFolderSink)
      m_imapMailFolderSink->AbortHeaderParseStream(this);
  }
  else if (m_imapMessageSink)
        m_imapMessageSink->AbortMsgWriteStream();

  m_curHdrInfo = nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsImapProtocol::AddFolderRightsForUser ( const char *  mailboxName,
const char *  userName,
const char *  rights 
)

Definition at line 4254 of file nsImapProtocol.cpp.

{
  nsIMAPACLRightsInfo *aclRightsInfo = new nsIMAPACLRightsInfo();
  if (aclRightsInfo)
  {
    nsIMAPNamespace *namespaceForFolder = nsnull;
    NS_ASSERTION (m_hostSessionList, "fatal ... null host session list");
    if (m_hostSessionList)
      m_hostSessionList->GetNamespaceForMailboxForHost(
      GetImapServerKey(), mailboxName,
      namespaceForFolder);
    
    aclRightsInfo->hostName = PL_strdup(GetImapHostName());
    
    if (namespaceForFolder)
      m_runningUrl->AllocateCanonicalPath(
      mailboxName,
      namespaceForFolder->GetDelimiter(), 
      &aclRightsInfo->mailboxName);
    else
      m_runningUrl->AllocateCanonicalPath(mailboxName,
      kOnlineHierarchySeparatorUnknown, 
      &aclRightsInfo->mailboxName);
    
    if (userName)
      aclRightsInfo->userName = PL_strdup(userName);
    else
      aclRightsInfo->userName = NULL;
    aclRightsInfo->rights = PL_strdup(rights);
    
    
    if (aclRightsInfo->hostName && 
      aclRightsInfo->mailboxName && aclRightsInfo->rights && 
      userName ? (aclRightsInfo->userName != NULL) : PR_TRUE)
    {
      if (m_imapServerSink)
      {
        m_imapServerSink->AddFolderRights(mailboxName, userName, rights);
      }
    }
    PR_Free(aclRightsInfo->hostName);
    PR_Free(aclRightsInfo->mailboxName);
    PR_Free(aclRightsInfo->rights);
    PR_Free(aclRightsInfo->userName);
    
    delete aclRightsInfo;
  }
  else
    HandleMemoryFailure();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2702 of file nsImapProtocol.cpp.

{
  PRTime deltaTime;
  PRInt32 deltaInSeconds;

  m_endTime = PR_Now();
  LL_SUB(deltaTime, m_endTime, m_startTime);
  PRTime2Seconds(deltaTime, &deltaInSeconds);
  m_trackingTime = PR_FALSE;
  if (deltaInSeconds < 0)
    return;            // bogus for some reason
  
  if (deltaInSeconds <= m_tooFastTime)
  {
    m_chunkSize += m_chunkAddSize;
    m_chunkThreshold = m_chunkSize + (m_chunkSize / 2);
    // we used to have a max for the chunk size - I don't think that's needed. 
  }
  else if (deltaInSeconds <= m_idealTime)
    return;
  else 
  {
    if (m_chunkSize > m_chunkStartSize)
      m_chunkSize = m_chunkStartSize;
    else if (m_chunkSize > (m_chunkAddSize * 2))
      m_chunkSize -= m_chunkAddSize;
    m_chunkThreshold = m_chunkSize + (m_chunkSize / 2);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4683 of file nsImapProtocol.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4694 of file nsImapProtocol.cpp.

{
    if (m_imapServerSink)
    {
      nsCOMPtr<nsIMsgWindow> msgWindow;
      GetMsgWindow(getter_AddRefs(msgWindow));
      m_imapServerSink->FEAlertFromServer(aServerEvent, msgWindow);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4660 of file nsImapProtocol.cpp.

{
  if (m_imapServerSink)
  {
    PRBool suppressErrorMsg = PR_FALSE;

    nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(m_runningUrl);
    if (mailnewsUrl)
      mailnewsUrl->GetSuppressErrorMsgs(&suppressErrorMsg);

    if (!suppressErrorMsg)
    {
      PRUnichar *progressString = nsnull;
      m_imapServerSink->FormatStringWithHostNameByID(aMessageId, &progressString);
      nsCOMPtr<nsIMsgWindow> msgWindow;
      GetMsgWindow(getter_AddRefs(msgWindow));
      m_imapServerSink->FEAlert(progressString, msgWindow);
      PR_Free(progressString);
    } 
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsImapProtocol::AuthLogin ( const char *  userName,
const char *  password,
eIMAPCapabilityFlag  flag 
) [private]

Definition at line 5103 of file nsImapProtocol.cpp.

{
  ProgressEventFunctionUsingId (IMAP_STATUS_SENDING_AUTH_LOGIN);
  IncrementCommandTagNumber();

  char * currentCommand=nsnull;
  nsresult rv;

  if (flag & kHasCRAMCapability)
  {
      // inform the server that we want to begin a CRAM authentication procedure...
      nsCAutoString command (GetServerCommandTag());
      command.Append(" authenticate CRAM-MD5" CRLF);
      rv = SendData(command.get());
      ParseIMAPandCheckForNewMail();
      if (GetServerStateParser().LastCommandSuccessful()) 
      {
        char *digest = nsnull;
        char *cramDigest = GetServerStateParser().fAuthChallenge;
        char * decodedChallenge = PL_Base64Decode(cramDigest, 
                                                  strlen(cramDigest), nsnull);
        if (m_imapServerSink)
          rv = m_imapServerSink->CramMD5Hash(decodedChallenge, password, &digest);

        PR_Free(decodedChallenge);
        if (NS_SUCCEEDED(rv) && digest)
        {
          nsCAutoString encodedDigest;
          char hexVal[8];

          for (PRUint32 j=0; j<16; j++) 
          {
            PR_snprintf (hexVal,8, "%.2x", 0x0ff & (unsigned short)(digest[j]));
            encodedDigest.Append(hexVal); 
          }

          PR_snprintf(m_dataOutputBuf, OUTPUT_BUFFER_SIZE, "%s %s", userName, encodedDigest.get());
          char *base64Str = PL_Base64Encode(m_dataOutputBuf, nsCRT::strlen(m_dataOutputBuf), nsnull);
          PR_snprintf(m_dataOutputBuf, OUTPUT_BUFFER_SIZE, "%s" CRLF, base64Str);
          PR_Free(base64Str);
          PR_Free(digest);
          rv = SendData(m_dataOutputBuf);
          if (NS_SUCCEEDED(rv))
            ParseIMAPandCheckForNewMail(command.get());
          if (GetServerStateParser().LastCommandSuccessful())
            return NS_OK;
          GetServerStateParser().SetCapabilityFlag(GetServerStateParser().GetCapabilityFlag() & ~kHasCRAMCapability);

        }
    }
  } // if CRAM response was received
  else if (flag & kHasAuthGssApiCapability)
  {
    // Only try GSSAPI once - if it fails, its going to be because we don't
    // have valid credentials
    GetServerStateParser().SetCapabilityFlag(GetServerStateParser().GetCapabilityFlag() & ~(kHasAuthGssApiCapability));

    // We do step1 first, so we don't try GSSAPI against a server which
    // we can't get credentials for.
    nsCAutoString response;
    nsresult gssrv;

    nsCAutoString service("imap@");
    service.Append(GetImapHostName());
    gssrv = DoGSSAPIStep1(service.get(), userName, response);
    NS_ENSURE_SUCCESS(gssrv, gssrv);
    
    nsCAutoString command (GetServerCommandTag());
    command.Append(" authenticate GSSAPI" CRLF);
    rv = SendData(command.get());
    NS_ENSURE_SUCCESS(rv, rv);

    ParseIMAPandCheckForNewMail("AUTH GSSAPI");
    if (GetServerStateParser().LastCommandSuccessful())
    {
      response += CRLF;
      rv = SendData(response.get());
      NS_ENSURE_SUCCESS(rv, rv);
      ParseIMAPandCheckForNewMail(command.get());

      while (GetServerStateParser().LastCommandSuccessful() && 
             NS_SUCCEEDED(gssrv) && gssrv != NS_SUCCESS_AUTH_FINISHED)
      {
        nsCString challengeStr(GetServerStateParser().fAuthChallenge);
        gssrv = DoGSSAPIStep2(challengeStr, response);
        if (NS_SUCCEEDED(gssrv)) 
        {
          response += CRLF;
          rv = SendData(response.get());
        }
        else
          rv = SendData("*" CRLF);

        NS_ENSURE_SUCCESS(rv, rv);
        ParseIMAPandCheckForNewMail(command.get());
      }
      rv = gssrv;
    }
    return rv;
  }
  else if (flag & (kHasAuthNTLMCapability|kHasAuthMSNCapability))
  {
    nsCAutoString command (GetServerCommandTag());
    command.Append((flag & kHasAuthNTLMCapability) ? " authenticate NTLM" CRLF
                                                   : " authenticate MSN" CRLF);
    rv = SendData(command.get());
    ParseIMAPandCheckForNewMail("AUTH NTLM"); // this just waits for ntlm step 1
    if (GetServerStateParser().LastCommandSuccessful()) 
    {
      nsCAutoString cmd;
      rv = DoNtlmStep1(userName, password, cmd);
      if (NS_SUCCEEDED(rv))
      {
        cmd += CRLF;
        rv = SendData(cmd.get());
        if (NS_SUCCEEDED(rv))
        {
          ParseIMAPandCheckForNewMail(command.get());
          if (GetServerStateParser().LastCommandSuccessful()) 
          {
            nsCString challengeStr(GetServerStateParser().fAuthChallenge);
            nsCString response;
            rv = DoNtlmStep2(challengeStr, response);
            if (NS_SUCCEEDED(rv))
            {
              response += CRLF;
              rv = SendData(response.get());
              ParseIMAPandCheckForNewMail(command.get()); 
              if (!GetServerStateParser().LastCommandSuccessful())
                GetServerStateParser().SetCapabilityFlag(GetServerStateParser().GetCapabilityFlag() & ~(kHasAuthNTLMCapability|kHasAuthMSNCapability));
            }
          }
        }
      }
    }
  }
  else if (flag & kHasAuthPlainCapability)
  {
    PR_snprintf(m_dataOutputBuf, OUTPUT_BUFFER_SIZE, "%s authenticate plain" CRLF, GetServerCommandTag());
    rv = SendData(m_dataOutputBuf);
    NS_ENSURE_SUCCESS(rv, rv);
    currentCommand = PL_strdup(m_dataOutputBuf); /* StrAllocCopy(currentCommand, GetOutputBuffer()); */
    ParseIMAPandCheckForNewMail();
    if (GetServerStateParser().LastCommandSuccessful()) 
    {
      char plainstr[512]; // placeholder for "<NUL>userName<NUL>password"
      int len = 1; // count for first <NUL> char
      memset(plainstr, 0, 512);
      PR_snprintf(&plainstr[1], 510, "%s", userName);
      len += PL_strlen(userName);
      len++;  // count for second <NUL> char
      PR_snprintf(&plainstr[len], 511-len, "%s", password);
      len += PL_strlen(password);
    
      char *base64Str = PL_Base64Encode(plainstr, len, nsnull);
      if (base64Str)
      {
        PR_snprintf(m_dataOutputBuf, OUTPUT_BUFFER_SIZE, "%s" CRLF, base64Str);
        PR_Free(base64Str);
        rv = SendData(m_dataOutputBuf, PR_TRUE /* suppress logging */);
        if (NS_SUCCEEDED(rv))
            ParseIMAPandCheckForNewMail(currentCommand);
        if (GetServerStateParser().LastCommandSuccessful())
        {
          PR_Free(currentCommand);
          return NS_OK;
        } // if the last command succeeded
      } // if we got a base 64 encoded string
    } // if the last command succeeded
  } // if auth plain capability

  else if (flag & kHasAuthLoginCapability)
  {
    PR_snprintf(m_dataOutputBuf, OUTPUT_BUFFER_SIZE, "%s authenticate login" CRLF, GetServerCommandTag());
    rv = SendData(m_dataOutputBuf);
    NS_ENSURE_SUCCESS(rv, rv);
    currentCommand = PL_strdup(m_dataOutputBuf);
    ParseIMAPandCheckForNewMail();

    if (GetServerStateParser().LastCommandSuccessful()) 
    {
      char *base64Str = PL_Base64Encode(userName, PL_strlen(userName), nsnull);
      if(base64Str)
      {
        PR_snprintf(m_dataOutputBuf, OUTPUT_BUFFER_SIZE, "%s" CRLF, base64Str);
        PR_Free(base64Str);
        rv = SendData(m_dataOutputBuf, PR_TRUE /* suppress logging */);
        if (NS_SUCCEEDED(rv))
            ParseIMAPandCheckForNewMail(currentCommand);
      }
      if (GetServerStateParser().LastCommandSuccessful()) 
      {
        base64Str = PL_Base64Encode((char*)password, PL_strlen(password), nsnull);
        PR_snprintf(m_dataOutputBuf, OUTPUT_BUFFER_SIZE, "%s" CRLF, base64Str);
        PR_Free(base64Str);
        rv = SendData(m_dataOutputBuf, PR_TRUE /* suppress logging */);
        if (NS_SUCCEEDED(rv))
           ParseIMAPandCheckForNewMail(currentCommand);
        if (GetServerStateParser().LastCommandSuccessful())
        {
          PR_Free(currentCommand);
          return NS_OK;
        }
      } // if last command successful
    } // if last command successful
  } // if has auth login capability

  // Fall back to InsecureLogin() if the user did not request secure authentication
  if (!m_useSecAuth && ! (GetServerStateParser().GetCapabilityFlag() & kLoginDisabled))
    InsecureLogin(userName, password);

  PR_Free(currentCommand);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2564 of file nsImapProtocol.cpp.

{
#ifdef HAVE_PORT
  if (m_folderNeedsSubscribing)  // we don't know about this folder - we need to subscribe to it / list it.
  {
    fHierarchyNameState = kListingForInfoOnly;
    List(mailboxName, PR_FALSE);
    fHierarchyNameState = kNoOperationInProgress;

    // removing and freeing it as we go.
    TIMAPMailboxInfo *mb = NULL;
    int total = XP_ListCount(fListedMailboxList);
    do
    {
      mb = (TIMAPMailboxInfo *) XP_ListRemoveTopObject(fListedMailboxList);
      delete mb;
    } while (mb);

    // if the mailbox exists (it was returned from the LIST response)
    if (total > 0)
    {
      // Subscribe to it, if the pref says so
      if (TIMAPHostInfo::GetHostIsUsingSubscription(fCurrentUrl->GetUrlHost()) && m_autoSubscribeOnOpen)
      {
        XP_Bool lastReportingErrors = GetServerStateParser().GetReportingErrors();
        GetServerStateParser().SetReportingErrors(PR_FALSE);
        Subscribe(mailboxName);
        GetServerStateParser().SetReportingErrors(lastReportingErrors);
      }

      // Always LIST it anyway, to get it into the folder lists,
      // so that we can continue to perform operations on it, at least
      // for this session.
      fHierarchyNameState = kNoOperationInProgress;
      List(mailboxName, PR_FALSE);
    }

    // We should now be subscribed to it, and have it in our folder lists
    // and panes.  Even if something failed, we don't want to try this again.
    m_folderNeedsSubscribing = PR_FALSE;

  }
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsImapProtocol::BeginMessageDownLoad ( PRUint32  totalSize,
const char *  contentType 
) [virtual]

Definition at line 2609 of file nsImapProtocol.cpp.

{
  nsresult rv = NS_OK;
  char *sizeString = PR_smprintf("OPEN Size: %ld", total_message_size);
  Log("STREAM",sizeString,"Begin Message Download Stream");
  PR_Free(sizeString);
  //total_message_size)); 
  if (content_type)
  {
    m_fromHeaderSeen = PR_FALSE;
    if (GetServerStateParser().GetDownloadingHeaders())
    {
      // if we get multiple calls to BeginMessageDownload w/o intervening
      // calls to NormalEndMessageDownload or Abort, then we're just
      // going to fake a NormalMessageEndDownload. This will most likely 
      // cause an empty header to get written to the db, and the user
      // will have to delete the empty header themselves, which
      // should remove the message from the server as well.
      if (m_curHdrInfo)
        NormalMessageEndDownload();
      if (!m_curHdrInfo)
        m_hdrDownloadCache.StartNewHdr(getter_AddRefs(m_curHdrInfo));
      if (m_curHdrInfo)
        m_curHdrInfo->SetMsgSize(total_message_size);
      return NS_OK;
    }
    // if we have a mock channel, that means we have a channel listener who wants the
    // message. So set up a pipe. We'll write the messsage into one end of the pipe
    // and they will read it out of the other end.
    else if (m_channelListener)
    {
      // create a pipe to pump the message into...the output will go to whoever
      // is consuming the message display
      // we create an "infinite" pipe in case we get extremely long lines from the imap server,
      // and the consumer is waiting for a whole line
      rv = NS_NewPipe(getter_AddRefs(m_channelInputStream), getter_AddRefs(m_channelOutputStream), 4096, PR_UINT32_MAX);
      NS_ASSERTION(NS_SUCCEEDED(rv), "NS_NewPipe failed!");
    }
    // else, if we are saving the message to disk!
    else if (m_imapMessageSink /* && m_imapAction == nsIImapUrl::nsImapSaveMessageToDisk */) 
    {
      // we get here when download the inbox for offline use
      nsCOMPtr<nsIFileSpec> fileSpec;
      PRBool addDummyEnvelope = PR_TRUE;
      nsCOMPtr<nsIMsgMessageUrl> msgurl = do_QueryInterface(m_runningUrl);
      msgurl->GetMessageFile(getter_AddRefs(fileSpec));
      msgurl->GetAddDummyEnvelope(&addDummyEnvelope);
      //                m_imapMessageSink->SetupMsgWriteStream(fileSpec, addDummyEnvelope);
      nsXPIDLCString nativePath;
      //        NS_ASSERTION(fileSpec, "no fileSpec!");
      if (fileSpec) 
      {
        fileSpec->GetNativePath(getter_Copies(nativePath));
        rv = m_imapMessageSink->SetupMsgWriteStream(nativePath, addDummyEnvelope);
      }
    }
    if (m_imapMailFolderSink && m_runningUrl)
    {
      nsCOMPtr <nsISupports> copyState;
      if (m_runningUrl)
      {
        m_runningUrl->GetCopyState(getter_AddRefs(copyState));
        if (copyState) // only need this notification during copy
        {
          nsCOMPtr<nsIMsgMailNewsUrl> mailurl = do_QueryInterface(m_runningUrl);
          m_imapMailFolderSink->StartMessage(mailurl);
        }
      }
    }
    
  }
  else
    HandleMemoryFailure();
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsImapProtocol::Bodystructure ( const char *  messageId,
PRBool  idIsUid 
)

Definition at line 2785 of file nsImapProtocol.cpp.

{
  IncrementCommandTagNumber();
  
  nsCString commandString(GetServerCommandTag());
  if (idIsUid)
    commandString.Append(" UID");
  commandString.Append(" fetch ");

  commandString.Append(messageId);
  commandString.Append(" (BODYSTRUCTURE)" CRLF);
            
  nsresult rv = SendData(commandString.get());
  if (NS_SUCCEEDED(rv))
      ParseIMAPandCheckForNewMail(commandString.get());
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIImapProtocol::CanHandleUrl ( in nsIImapUrl  aImapUrl,
out boolean  aCanRunUrl,
out boolean  hasToWait 
) [inherited]

Definition at line 5002 of file nsImapProtocol.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 7599 of file nsImapProtocol.cpp.

{
    //ProgressUpdateEvent("Checking mailbox...");

    IncrementCommandTagNumber();
    
  nsCString command(GetServerCommandTag());
  command.Append(" check" CRLF);
            
    nsresult rv = SendData(command.get());
    if (NS_SUCCEEDED(rv))
    {
        m_flagChangeCount = 0;
        m_lastCheckTime = PR_Now();
        ParseIMAPandCheckForNewMail();
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 7906 of file nsImapProtocol.cpp.

{
  if (m_flagChangeCount >= kFlagChangesBeforeCheck)
    return PR_TRUE;

  PRTime deltaTime;
  PRInt32 deltaInSeconds;
    
  LL_SUB(deltaTime, PR_Now(), m_lastCheckTime);
  PRTime2Seconds(deltaTime, &deltaInSeconds);
    
  return (deltaInSeconds >= kMaxSecondsBeforeCheck);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3937 of file nsImapProtocol.cpp.

void nsImapProtocol::ClearAllFolderRights ( const char *  mailboxName,
nsIMAPNamespace nsForMailbox 
)

Definition at line 4328 of file nsImapProtocol.cpp.

{
  NS_ASSERTION (nsForMailbox, "Oops ... null name space");
    nsIMAPACLRightsInfo *aclRightsInfo = new nsIMAPACLRightsInfo();
  if (aclRightsInfo)
  {
        const char *hostName = GetImapHostName();

    aclRightsInfo->hostName = PL_strdup(hostName);
    if (nsForMailbox)
            m_runningUrl->AllocateCanonicalPath(mailboxName,
                                                nsForMailbox->GetDelimiter(),
                                                &aclRightsInfo->mailboxName); 
    else
            m_runningUrl->AllocateCanonicalPath(
                mailboxName, kOnlineHierarchySeparatorUnknown,
                &aclRightsInfo->mailboxName);


    aclRightsInfo->rights = NULL;
    aclRightsInfo->userName = NULL;

    if (aclRightsInfo->hostName && aclRightsInfo->mailboxName && m_imapMailFolderSink)
        m_imapMailFolderSink->ClearFolderRights();

    PR_Free(aclRightsInfo->hostName);
    PR_Free(aclRightsInfo->mailboxName);
    
    delete aclRightsInfo;
  }
  else
    HandleMemoryFailure();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsImapProtocol::Close ( PRBool  shuttingDown = PR_FALSE,
PRBool  waitForResponse = PR_TRUE 
)

Definition at line 7564 of file nsImapProtocol.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 960 of file nsImapProtocol.cpp.

{
  PR_CEnterMonitor(this);
  if (m_transport)
  {
      // make sure the transport closes (even if someone is still indirectly
      // referencing it).
      m_transport->Close(NS_ERROR_ABORT);
      m_transport = nsnull;
  }
  m_inputStream = nsnull;
  m_outputStream = nsnull;
  m_channelListener = nsnull;
  m_channelContext = nsnull;
  if (m_mockChannel)
  {
      m_mockChannel->Close();
      m_mockChannel = nsnull;
  }
  m_channelInputStream = nsnull;
  m_channelOutputStream = nsnull;
  nsCOMPtr<nsIMsgIncomingServer> me_server = do_QueryReferent(m_server);

  // we must let go of the monitor before calling RemoveConnection to unblock
  // anyone who tries to get a monitor to the protocol object while
  // holding onto a monitor to the server.
  PR_CExitMonitor(this);

  if (me_server)
  {
      nsresult result;
      nsCOMPtr<nsIImapIncomingServer>
          aImapServer(do_QueryInterface(me_server, &result));
      if (NS_SUCCEEDED(result))
          aImapServer->RemoveConnection(this);
      me_server = nsnull;
  }
  m_server = nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4318 of file nsImapProtocol.cpp.

{
    if (m_imapServerSink)
    {
        m_imapServerSink->SetCapability(GetServerStateParser().GetCapabilityFlag());
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4311 of file nsImapProtocol.cpp.

{
    if (m_imapServerSink)
        m_imapServerSink->CommitNamespaces();
}

Here is the caller graph for this function:

nsresult nsImapProtocol::Configure ( PRInt32  TooFastTime,
PRInt32  IdealTime,
PRInt32  ChunkAddSize,
PRInt32  ChunkSize,
PRInt32  ChunkThreshold,
PRBool  FetchByChunks,
PRInt32  MaxChunkSize 
) [private]

Definition at line 466 of file nsImapProtocol.cpp.

{
  m_tooFastTime = TooFastTime;    // secs we read too little too fast
  m_idealTime = IdealTime;    // secs we read enough in good time
  m_chunkAddSize = ChunkAddSize;    // buffer size to add when wasting time
  m_chunkStartSize = m_chunkSize = ChunkSize;
  m_chunkThreshold = ChunkThreshold;
  m_fetchByChunks = FetchByChunks;

  return NS_OK;
}

Here is the caller graph for this function:

void nsImapProtocol::Copy ( const char *  messageList,
const char *  destinationMailbox,
PRBool  idsAreUid 
)

Definition at line 7209 of file nsImapProtocol.cpp.

{
  IncrementCommandTagNumber();
  
  char *escapedDestination = CreateEscapedMailboxName(destinationMailbox);

  // turn messageList back into key array and then back into a message id list,
  // but use the flag state to handle ranges correctly.
  nsCString messageIdList;
  nsMsgKeyArray msgKeys;
  if (idsAreUid)
    ParseUidString(messageList, msgKeys);

  PRInt32 msgCountLeft = msgKeys.GetSize();
  PRUint32 msgsHandled = 0;
  const char *formatString;
  formatString = (idsAreUid)
      ? "%s uid store %s %s"CRLF
      : "%s store %s %s"CRLF;

  do 
  {
    nsCString idString;

    PRUint32 msgsToHandle = msgCountLeft;
    if (idsAreUid)
      AllocateImapUidString(msgKeys.GetArray() + msgsHandled, msgsToHandle, m_flagState, idString);
    else
      idString.Assign(messageList);

    msgsHandled += msgsToHandle;
    msgCountLeft -= msgsToHandle;

    IncrementCommandTagNumber();
    nsCAutoString protocolString(GetServerCommandTag());
    if (idsAreUid)
      protocolString.Append(" uid");
    // If it's a MOVE operation on aol servers then use 'xaol-move' cmd.
    if ((m_imapAction == nsIImapUrl::nsImapOnlineMove) &&
        GetServerStateParser().ServerIsAOLServer())
      protocolString.Append(" xaol-move ");
    else
      protocolString.Append(" copy ");


    protocolString.Append(idString);
    protocolString.Append(" \"");
    protocolString.Append(escapedDestination);
    protocolString.Append("\"" CRLF);
      
    nsresult rv = SendData(protocolString.get());
    if (NS_SUCCEEDED(rv))
       ParseIMAPandCheckForNewMail(protocolString.get());
  }
  while (msgCountLeft > 0 && !DeathSignalReceived());

        
  nsMemory::Free(escapedDestination);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4088 of file nsImapProtocol.cpp.

{
  PRUint32 numberOfMessages = 0;
  char *uidString = PL_strdup(idString);

  if (uidString)
  {
    // This is in the form <id>,<id>, or <id1>:<id2>
    char curChar = *uidString;
    PRBool isRange = PR_FALSE;
    PRInt32 curToken;
    PRInt32 saveStartToken=0;

    for (char *curCharPtr = uidString; curChar && *curCharPtr;)
    {
      char *currentKeyToken = curCharPtr;
      curChar = *curCharPtr;
      while (curChar != ':' && curChar != ',' && curChar != '\0')
        curChar = *curCharPtr++;
      *(curCharPtr - 1) = '\0';
      curToken = atol(currentKeyToken);
      if (isRange)
      {
        while (saveStartToken < curToken)
        {
          numberOfMessages++;
          saveStartToken++;
        }
      }

      numberOfMessages++;
      isRange = (curChar == ':');
      if (isRange)
        saveStartToken = curToken + 1;
    }
    PR_Free(uidString);
  }
  return numberOfMessages;
}

Here is the caller graph for this function:

char * nsImapProtocol::CreateEscapedMailboxName ( const char *  rawName) [private]

Definition at line 2734 of file nsImapProtocol.cpp.

{
  nsCString escapedName(rawName);

  for (PRInt32 strIndex = 0; *rawName; strIndex++)
  {
    char currentChar = *rawName++;
    if ((currentChar == '\\') || (currentChar == '\"'))
    {
      escapedName.Insert('\\', strIndex++);
    }
  }
  return ToNewCString(escapedName);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsImapProtocol::CreateMailbox ( const char *  mailboxName) [private]

Definition at line 6937 of file nsImapProtocol.cpp.

{
  ProgressEventFunctionUsingId (IMAP_STATUS_CREATING_MAILBOX);

  IncrementCommandTagNumber();
  
  char *escapedName = CreateEscapedMailboxName(mailboxName);
  nsCString command(GetServerCommandTag());
  command += " create \"";
  command += escapedName;
  command += "\""CRLF;
               
  nsMemory::Free(escapedName);

  nsresult rv = SendData(command.get());
  if(NS_SUCCEEDED(rv))
    ParseIMAPandCheckForNewMail();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 6919 of file nsImapProtocol.cpp.

{
  CreateMailbox(mailboxName);
  PRBool rv = GetServerStateParser().LastCommandSuccessful();
  if (rv)
  {
    if (m_autoSubscribe) // auto-subscribe is on
    {
      // create succeeded - let's subscribe to it
      PRBool reportingErrors = GetServerStateParser().GetReportingErrors();
      GetServerStateParser().SetReportingErrors(PR_FALSE);
      OnSubscribe(mailboxName);
      GetServerStateParser().SetReportingErrors(reportingErrors);
    }
  }
  return (rv);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4364 of file nsImapProtocol.cpp.

{
  PRBool needMoreData = PR_FALSE;
  char * newLine = nsnull;
  PRUint32 numBytesInLine = 0;
  nsresult rv = NS_OK;
  // we hold a ref to the input stream in case we get cancelled from the
  // ui thread, which releases our ref to the input stream, and can
  // cause the pipe to get deleted before the monitor the read is
  // blocked on gets notified. When that happens, the imap thread
  // will stay blocked.
  nsCOMPtr <nsIInputStream> kungFuGrip = m_inputStream;
  do
  {
    newLine = m_inputStreamBuffer->ReadNextLine(m_inputStream, numBytesInLine, needMoreData, &rv); 
    PR_LOG(IMAP, PR_LOG_DEBUG, ("ReadNextLine [stream=%x nb=%u needmore=%u]\n",
        m_inputStream.get(), numBytesInLine, needMoreData));

  } while (!newLine && NS_SUCCEEDED(rv) && !DeathSignalReceived()); // until we get the next line and haven't been interrupted

  kungFuGrip = nsnull;

  if (NS_FAILED(rv)) 
  {
    switch (rv) 
    {
        case NS_ERROR_UNKNOWN_HOST:
        case NS_ERROR_UNKNOWN_PROXY_HOST:
            AlertUserEventUsingId(IMAP_UNKNOWN_HOST_ERROR);
            break;
        case NS_ERROR_CONNECTION_REFUSED:
        case NS_ERROR_PROXY_CONNECTION_REFUSED:
            AlertUserEventUsingId(IMAP_CONNECTION_REFUSED_ERROR);
            break;
        case NS_ERROR_NET_TIMEOUT:
        case NS_ERROR_NET_RESET:
        case NS_BASE_STREAM_CLOSED:
        case NS_ERROR_NET_INTERRUPT:
          // we should retry on RESET, especially for SSL...
          if ((TestFlag(IMAP_RECEIVED_GREETING) || rv == NS_ERROR_NET_RESET) &&
              m_runningUrl && !m_retryUrlOnError)
          {
            m_runningUrl->SetRerunningUrl(PR_TRUE);
            m_retryUrlOnError = PR_TRUE;
          }
          else if (rv == NS_ERROR_NET_TIMEOUT)
            AlertUserEventUsingId(IMAP_NET_TIMEOUT_ERROR);
          else
            AlertUserEventUsingId(TestFlag(IMAP_RECEIVED_GREETING) 
            ? IMAP_SERVER_DISCONNECTED : IMAP_SERVER_DROPPED_CONNECTION);
          break;
        default:
            break;
    }
  
    nsCAutoString logMsg("clearing IMAP_CONNECTION_IS_OPEN - rv = ");
    logMsg.AppendInt(rv, 16);
    Log("CreateNewLineFromSocket", nsnull, logMsg.get());
    ClearFlag(IMAP_CONNECTION_IS_OPEN);
    TellThreadToDie(PR_FALSE);
  }
  Log("CreateNewLineFromSocket", nsnull, newLine);
  SetConnectionStatus(newLine && numBytesInLine ? 1 : -1); // set > 0 if string is not null or empty
  return newLine;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char * nsImapProtocol::CreatePossibleTrashName ( const char *  prefix) [private]

Definition at line 7009 of file nsImapProtocol.cpp.

{
  nsCString returnTrash(prefix);

  returnTrash += GetTrashFolderName();
  return ToNewCString(returnTrash);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 5630 of file nsImapProtocol.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4136 of file nsImapProtocol.cpp.

{
  nsresult returnValue = NS_OK;
  // ignore mock channel status if we've been pseudo interrupted
  // ### need to make sure we clear pseudo interrupted status appropriately.
  if (!GetPseudoInterrupted() && m_mockChannel) 
  { 
    nsCOMPtr<nsIRequest> request = do_QueryInterface(m_mockChannel);
    if (request) 
      request->GetStatus(&returnValue);
  }
  if (NS_SUCCEEDED(returnValue))   // check the other way of cancelling.
  {
    PR_EnterMonitor(m_threadDeathMonitor);
    returnValue = m_threadShouldDie;
    PR_ExitMonitor(m_threadDeathMonitor);
  }
  return returnValue;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsImapProtocol::DeleteFolderAndMsgs ( const char *  aSourceMailbox) [private]

Definition at line 6463 of file nsImapProtocol.cpp.

{
  RemoveMsgsAndExpunge();
  if (GetServerStateParser().LastCommandSuccessful())
  {
    // All msgs are deleted successfully - let's remove the folder itself.
    PRBool reportingErrors = GetServerStateParser().GetReportingErrors();
    GetServerStateParser().SetReportingErrors(PR_FALSE);
    OnDeleteFolder(sourceMailbox);
    GetServerStateParser().SetReportingErrors(reportingErrors);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsImapProtocol::DeleteMailbox ( const char *  mailboxName) [private]

Definition at line 6956 of file nsImapProtocol.cpp.

{

  // check if this connection currently has the folder to be deleted selected.
  // If so, we should close it because at least some UW servers don't like you deleting
  // a folder you have open.
  if (FolderIsSelected(mailboxName))
    Close();
  
  
  ProgressEventFunctionUsingIdWithString (IMAP_STATUS_DELETING_MAILBOX, mailboxName);

    IncrementCommandTagNumber();
    
    char *escapedName = CreateEscapedMailboxName(mailboxName);
    nsCString command(GetServerCommandTag());
    command += " delete \"";
    command += escapedName;
    command += "\"" CRLF;
    nsMemory::Free(escapedName);
    
    nsresult rv = SendData(command.get());
    if (NS_SUCCEEDED(rv))
        ParseIMAPandCheckForNewMail();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 6107 of file nsImapProtocol.cpp.

{
  PRBool rv = PR_TRUE;
  if (!MailboxIsNoSelectMailbox(mailboxName))
  {
    // Only try to delete it if it really exists
    DeleteMailbox(mailboxName);
    rv = GetServerStateParser().LastCommandSuccessful();
  }

  // We can unsubscribe even if the mailbox doesn't exist.
  if (rv && m_autoUnsubscribe) // auto-unsubscribe is on
  {
    PRBool reportingErrors = GetServerStateParser().GetReportingErrors();
    GetServerStateParser().SetReportingErrors(PR_FALSE);
    Unsubscribe(mailboxName);
    GetServerStateParser().SetReportingErrors(reportingErrors);

  }
  return (rv);
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsImapProtocol::DeleteSubFolders ( const char *  aMailboxName,
PRBool aDeleteSelf 
) [private]

Definition at line 6244 of file nsImapProtocol.cpp.

{
  PRBool deleteSucceeded = PR_TRUE;
  m_deletableChildren = new nsVoidArray();
  
  if (m_deletableChildren)
  {
    PRBool folderDeleted = PR_FALSE;

    m_hierarchyNameState = kDeleteSubFoldersInProgress;
        nsCString pattern(selectedMailbox);
        char onlineDirSeparator = kOnlineHierarchySeparatorUnknown;
        m_runningUrl->GetOnlineSubDirSeparator(&onlineDirSeparator);
        pattern.Append(onlineDirSeparator);
        pattern.Append('*');

    if (!pattern.IsEmpty())
    {
      List(pattern.get(), PR_FALSE);
    }
    m_hierarchyNameState = kNoOperationInProgress;
    
    // this should be a short list so perform a sequential search for the
    // longest name mailbox.  Deleting the longest first will hopefully
        // prevent the server from having problems about deleting parents
        // ** jt - why? I don't understand this.
    PRInt32 numberToDelete = m_deletableChildren->Count();
    PRInt32 outerIndex, innerIndex;

    // intelligently decide if myself(either plain format or following the dir-separator)
    // is in the sub-folder list
    PRBool folderInSubfolderList = PR_FALSE;     // For Performance
    char *selectedMailboxDir = nsnull;
    {
        PRInt32 length = strlen(selectedMailbox);
        selectedMailboxDir = (char *)PR_MALLOC(length+2);
        if( selectedMailboxDir )    // only do the intelligent test if there is enough memory
        {
            strcpy(selectedMailboxDir, selectedMailbox);
            selectedMailboxDir[length] = onlineDirSeparator;
            selectedMailboxDir[length+1] = '\0';
            PRInt32 i;
            for( i=0; i<numberToDelete && !folderInSubfolderList; i++ )
            {
                char *currentName = (char *) m_deletableChildren->ElementAt(i);
                if( !strcmp(currentName, selectedMailbox) || !strcmp(currentName, selectedMailboxDir) )
                    folderInSubfolderList = PR_TRUE;
            }
        }
    }

    deleteSucceeded = GetServerStateParser().LastCommandSuccessful();
    for (outerIndex = 0; 
         (outerIndex < numberToDelete) && deleteSucceeded;
         outerIndex++)
    {
        char* longestName = nsnull;
        PRInt32 longestIndex = 0; // fix bogus warning by initializing
        for (innerIndex = 0; 
             innerIndex < m_deletableChildren->Count();
             innerIndex++)
        {
            char *currentName = 
                (char *) m_deletableChildren->ElementAt(innerIndex);
            if (!longestName || strlen(longestName) < strlen(currentName))
            {
                longestName = currentName;
                longestIndex = innerIndex;
            }
        }
        // the imap parser has already converted to a non UTF7 string in
        // the canonical format so convert it back
        if (longestName)
        {
            char *serverName = nsnull;

            m_deletableChildren->RemoveElementAt(longestIndex);
            m_runningUrl->AllocateServerPath(longestName,
                                             onlineDirSeparator,
                                             &serverName);
            PR_FREEIF(longestName);
            longestName = serverName;
        }
      
      // some imap servers include the selectedMailbox in the list of 
      // subfolders of the selectedMailbox.  Check for this so we don't
            // delete the selectedMailbox (usually the trash and doing an
            // empty trash)       
      // The Cyrus imap server ignores the "INBOX.Trash" constraining
            // string passed to the list command.  Be defensive and make sure
            // we only delete children of the trash
      if (longestName && 
        strcmp(selectedMailbox, longestName) &&
        !strncmp(selectedMailbox, longestName, strlen(selectedMailbox)))
      {
          if( selectedMailboxDir && !strcmp(selectedMailboxDir, longestName) )      // just myself
          {
              if( aDeleteSelf )
              {
                  PRBool deleted = DeleteMailboxRespectingSubscriptions(longestName);
                  if (deleted)
                      FolderDeleted(longestName);
                  folderDeleted = deleted;
                  deleteSucceeded = deleted;
              }
          }
          else
          {
              nsCOMPtr<nsIImapIncomingServer> imapServer = do_QueryReferent(m_server);
              if (imapServer)
                  imapServer->ResetConnection(longestName);
              PRBool deleted = PR_FALSE;
              if( folderInSubfolderList ) // for performance
              {
                  nsVoidArray* pDeletableChildren = m_deletableChildren;
                  m_deletableChildren = nsnull;
                  PRBool folderDeleted = PR_TRUE;
                  deleted = DeleteSubFolders(longestName, folderDeleted);
                  // longestName may have subfolder list including itself
                  if( !folderDeleted )
                  {
                      if (deleted)
                      deleted = DeleteMailboxRespectingSubscriptions(longestName);
                      if (deleted)
                          FolderDeleted(longestName);
                  }
                  m_deletableChildren = pDeletableChildren;
              }
              else
              {
                  deleted = DeleteMailboxRespectingSubscriptions(longestName);
                  if (deleted)
                      FolderDeleted(longestName);
              }
              deleteSucceeded = deleted;
          }
      }
      PR_FREEIF(longestName);
    }

    aDeleteSelf = folderDeleted;  // feedback if myself is deleted
    PR_Free(selectedMailboxDir);

    delete m_deletableChildren;
    m_deletableChildren = nsnull;
  }
  return deleteSucceeded;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 6567 of file nsImapProtocol.cpp.

{
  // used for subscribe pane
  // iterate through all namespaces
  PRUint32 count = 0;
  m_hostSessionList->GetNumberOfNamespacesForHost(GetImapServerKey(), count);
  
  for (PRUint32 i = 0; i < count; i++ )
  {
    nsIMAPNamespace *ns = nsnull;
    
    m_hostSessionList->GetNamespaceNumberForHost(GetImapServerKey(), i,
      ns);
    if (ns &&
      gHideOtherUsersFromList ? (ns->GetType() != kOtherUsersNamespace)
      : PR_TRUE)
    {
      const char *prefix = ns->GetPrefix();
      if (prefix)
      {
        if (!gHideUnusedNamespaces && *prefix &&
        PL_strcasecmp(prefix, "INBOX.")) /* only do it for
        non-empty namespace prefixes */
        {
          // Explicitly discover each Namespace, just so they're
          // there in the subscribe UI 
          nsImapMailboxSpec *boxSpec = new nsImapMailboxSpec;
          if (boxSpec)
          {
            NS_ADDREF(boxSpec);
            boxSpec->folderSelected = PR_FALSE;
            boxSpec->hostName = nsCRT::strdup(GetImapHostName());
            boxSpec->connection = this;
            boxSpec->flagState = nsnull;
            boxSpec->discoveredFromLsub = PR_TRUE;
            boxSpec->onlineVerified = PR_TRUE;
            boxSpec->box_flags = kNoselect;
            boxSpec->hierarchySeparator = ns->GetDelimiter();
            m_runningUrl->AllocateCanonicalPath(
              ns->GetPrefix(), ns->GetDelimiter(),
              &boxSpec->allocatedPathName);
            boxSpec->namespaceForFolder = ns;
            boxSpec->box_flags |= kNameSpace;
            
            switch (ns->GetType())
            {
            case kPersonalNamespace:
              boxSpec->box_flags |= kPersonalMailbox;
              break;
            case kPublicNamespace:
              boxSpec->box_flags |= kPublicMailbox;
              break;
            case kOtherUsersNamespace:
              boxSpec->box_flags |= kOtherUsersMailbox;
              break;
            default: // (kUnknownNamespace)
              break;
            }
            
            DiscoverMailboxSpec(boxSpec);
          }
          else
            HandleMemoryFailure();
        }
        
        nsCAutoString allPattern(prefix);
        allPattern += '*';
        
        nsCAutoString topLevelPattern(prefix);
        topLevelPattern += '%';
        
        nsCAutoString secondLevelPattern;
        
        char delimiter = ns->GetDelimiter();
        if (delimiter)
        {
          // Hierarchy delimiter might be NIL, in which case there's no hierarchy anyway
          secondLevelPattern = prefix;
          secondLevelPattern += '%';
          secondLevelPattern += delimiter;
          secondLevelPattern += '%';
        }
        
        nsresult rv;
        nsCOMPtr<nsIImapIncomingServer> imapServer = do_QueryReferent(m_server, &rv);
        if (NS_FAILED(rv) || !imapServer) return;
        
        if (!allPattern.IsEmpty())
        {
          imapServer->SetDoingLsub(PR_TRUE);
          Lsub(allPattern.get(), PR_TRUE);       // LSUB all the subscribed
        }
        if (!topLevelPattern.IsEmpty())
        {
          imapServer->SetDoingLsub(PR_FALSE);
          List(topLevelPattern.get(), PR_TRUE);  // LIST the top level
        }
        if (!secondLevelPattern.IsEmpty())
        {
          imapServer->SetDoingLsub(PR_FALSE);
          List(secondLevelPattern.get(), PR_TRUE);      // LIST the second level
        }
      }
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 6680 of file nsImapProtocol.cpp.

{
  PRBool usingSubscription = PR_FALSE;

  SetMailboxDiscoveryStatus(eContinue);
  if (GetServerStateParser().ServerHasACLCapability())
    m_hierarchyNameState = kListingForInfoAndDiscovery;
  else
    m_hierarchyNameState = kNoOperationInProgress;

  // Pretend that the Trash folder doesn't exist, so we will rediscover it if we need to.
  m_hostSessionList->SetOnlineTrashFolderExistsForHost(GetImapServerKey(), PR_FALSE);
  m_hostSessionList->GetHostIsUsingSubscription(GetImapServerKey(), usingSubscription);

  // iterate through all namespaces and LSUB them.
  PRUint32 count = 0;
  m_hostSessionList->GetNumberOfNamespacesForHost(GetImapServerKey(), count);
  for (PRUint32 i = 0; i < count; i++ )
  {
    nsIMAPNamespace * ns = nsnull;
    m_hostSessionList->GetNamespaceNumberForHost(GetImapServerKey(),i,ns);
    if (ns)
    {
      const char *prefix = ns->GetPrefix();
      if (prefix)
      {
        // static PRBool gHideUnusedNamespaces = PR_TRUE;
        // mscott -> WARNING!!! i where are we going to get this
                // global variable for unusued name spaces from??? *wince*
        // dmb - we should get this from a per-host preference,
        // I'd say. But for now, just make it PR_TRUE;
        if (!gHideUnusedNamespaces && *prefix &&
                    PL_strcasecmp(prefix, "INBOX."))  // only do it for
                    // non-empty namespace prefixes, and for non-INBOX prefix 
        {
          // Explicitly discover each Namespace, so that we can
                    // create subfolders of them,
          nsImapMailboxSpec *boxSpec = new nsImapMailboxSpec; 
          if (boxSpec)
          {
                     NS_ADDREF(boxSpec);
            boxSpec->folderSelected = PR_FALSE;
            boxSpec->hostName = nsCRT::strdup(GetImapHostName());
            boxSpec->connection = this;
            boxSpec->flagState = nsnull;
            boxSpec->discoveredFromLsub = PR_TRUE;
            boxSpec->onlineVerified = PR_TRUE;
            boxSpec->box_flags = kNoselect;
            boxSpec->hierarchySeparator = ns->GetDelimiter();
            m_runningUrl->AllocateCanonicalPath(
                            ns->GetPrefix(), ns->GetDelimiter(), 
                            &boxSpec->allocatedPathName);  
            boxSpec->namespaceForFolder = ns;
            boxSpec->box_flags |= kNameSpace;

            switch (ns->GetType())
            {
            case kPersonalNamespace:
              boxSpec->box_flags |= kPersonalMailbox;
              break;
            case kPublicNamespace:
              boxSpec->box_flags |= kPublicMailbox;
              break;
            case kOtherUsersNamespace:
              boxSpec->box_flags |= kOtherUsersMailbox;
              break;
            default:  // (kUnknownNamespace)
              break;
            }

            DiscoverMailboxSpec(boxSpec);
          }
          else
            HandleMemoryFailure();
        }

        // now do the folders within this namespace
        nsCString pattern;
        nsCString pattern2;
        if (usingSubscription)
        {
          pattern.Append(prefix);
          pattern.Append("*");
        }
        else
        {
          pattern.Append(prefix);
          pattern.Append("%"); // mscott just need one percent right?
          // pattern = PR_smprintf("%s%%", prefix);
          char delimiter = ns->GetDelimiter();
          if (delimiter)
          {
            // delimiter might be NIL, in which case there's no hierarchy anyway
            pattern2 = prefix;
            pattern2 += "%";
            pattern2 += delimiter;
            pattern2 += "%";
            // pattern2 = PR_smprintf("%s%%%c%%", prefix, delimiter);
          }
        }


        if (usingSubscription) // && !GetSubscribingNow())  should never get here from subscribe pane
          Lsub(pattern.get(), PR_TRUE);
        else
        {
          List(pattern.get(), PR_TRUE);
          List(pattern2.get(), PR_TRUE);
        }
      }
    }
  }

  // explicitly LIST the INBOX if (a) we're not using subscription, or (b) we are using subscription and
  // the user wants us to always show the INBOX.
  PRBool listInboxForHost = PR_FALSE;
  m_hostSessionList->GetShouldAlwaysListInboxForHost(GetImapServerKey(), listInboxForHost);
  if (!usingSubscription || listInboxForHost) 
    List("INBOX", PR_TRUE);

  m_hierarchyNameState = kNoOperationInProgress;

  MailboxDiscoveryFinished();

  // Get the ACLs for newly discovered folders
  if (GetServerStateParser().ServerHasACLCapability())
  {
    PRInt32 total = m_listedMailboxList.Count(), cnt = 0;
    // Let's not turn this off here, since we don't turn it on after
    // GetServerStateParser().SetReportingErrors(PR_FALSE);
    if (total)
    {
      ProgressEventFunctionUsingId(IMAP_GETTING_ACL_FOR_FOLDER);
      nsIMAPMailboxInfo * mb = nsnull;
      do
      {
        if (m_listedMailboxList.Count() == 0)
            break;

        mb = (nsIMAPMailboxInfo *) m_listedMailboxList[0]; // get top element
        m_listedMailboxList.RemoveElementAt(0); // XP_ListRemoveTopObject(fListedMailboxList);
        if (mb)
        {
          if (FolderNeedsACLInitialized(mb->GetMailboxName()))
          {
            char *onlineName = nsnull;
            m_runningUrl->AllocateServerPath(mb->GetMailboxName(), mb->GetDelimiter(), &onlineName);
            if (onlineName)
            {
              RefreshACLForFolder(onlineName);
              PR_Free(onlineName);
            }
          }
          PercentProgressUpdateEvent(NULL, cnt, total);
          delete mb;  // this is the last time we're using the list, so delete the entries here
          cnt++;
        }
      } while (mb && !DeathSignalReceived());
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4497 of file nsImapProtocol.cpp.

{
  nsIMAPNamespace *ns = nsnull;
  
  NS_ASSERTION (m_hostSessionList, "fatal null host session list");
  if (!m_hostSessionList) return;
  
  m_hostSessionList->GetDefaultNamespaceOfTypeForHost(
    GetImapServerKey(), kPersonalNamespace, ns);
  const char *nsPrefix = ns ? ns->GetPrefix() : 0;
  
  switch (m_hierarchyNameState)
  {
  case kListingForCreate:
  case kNoOperationInProgress:
  case kDiscoverTrashFolderInProgress:
  case kListingForInfoAndDiscovery:
    {
      if (ns && nsPrefix) // if no personal namespace, there can be no Trash folder
      {
        PRBool onlineTrashFolderExists = PR_FALSE;
        if (m_hostSessionList)
          m_hostSessionList->GetOnlineTrashFolderExistsForHost(
          GetImapServerKey(), onlineTrashFolderExists);
        
        if (GetDeleteIsMoveToTrash() && // don't set the Trash flag
          // if not using the Trash model
          !onlineTrashFolderExists && 
          PL_strstr(adoptedBoxSpec->allocatedPathName, 
          GetTrashFolderName()))
        {
          PRBool trashExists = PR_FALSE;
          nsCString trashMatch;
          trashMatch.Adopt(CreatePossibleTrashName(nsPrefix));
          {
            char *serverTrashName = nsnull;
            m_runningUrl->AllocateCanonicalPath(
              trashMatch.get(),
              ns->GetDelimiter(), &serverTrashName); 
            if (serverTrashName)
            {
              if (!PL_strncasecmp(serverTrashName, "INBOX/", 6)) // case-insensitive
              {
                trashExists = !PL_strncasecmp(adoptedBoxSpec->allocatedPathName, serverTrashName, 6) && /* "INBOX/" */
                              !PL_strcmp(adoptedBoxSpec->allocatedPathName + 6, serverTrashName + 6);
              }
              else
              {
                trashExists = (PL_strcmp(serverTrashName, adoptedBoxSpec->allocatedPathName) == 0);
              }
              if (m_hostSessionList)
                m_hostSessionList->SetOnlineTrashFolderExistsForHost(GetImapServerKey(), trashExists);
              PR_Free(serverTrashName);
            }
          }
          
          if (trashExists)
            adoptedBoxSpec->box_flags |= kImapTrash;
        }
      }
      
      // Discover the folder (shuttle over to libmsg, yay)
      // Do this only if the folder name is not empty (i.e. the root)
      if (adoptedBoxSpec->allocatedPathName &&
        *adoptedBoxSpec->allocatedPathName)
      {
        nsCString boxNameCopy; 
        
        boxNameCopy = adoptedBoxSpec->allocatedPathName;
        if (m_hierarchyNameState == kListingForCreate)
          adoptedBoxSpec->box_flags |= kNewlyCreatedFolder;
        
        if (m_imapServerSink)
        {
          PRBool newFolder;
          m_imapServerSink->PossibleImapMailbox(boxNameCopy.get(), 
            adoptedBoxSpec->hierarchySeparator,
            adoptedBoxSpec->box_flags, &newFolder);
          // if it's a new folder to the server sink, setting discovery status to
          // eContinueNew will cause us to get the ACL for the new folder.
          if (newFolder)
            SetMailboxDiscoveryStatus(eContinueNew);
          
          PRBool useSubscription = PR_FALSE;
          
          if (m_hostSessionList)
            m_hostSessionList->GetHostIsUsingSubscription(
            GetImapServerKey(),
            useSubscription);
          
          if ((GetMailboxDiscoveryStatus() != eContinue) && 
            (GetMailboxDiscoveryStatus() != eContinueNew) &&
            (GetMailboxDiscoveryStatus() != eListMyChildren))
          {
            SetConnectionStatus(-1);
          }
          else if (!boxNameCopy.IsEmpty() && 
            (GetMailboxDiscoveryStatus() == 
            eListMyChildren) &&
            (!useSubscription || GetSubscribingNow()))
          {
            NS_ASSERTION (PR_FALSE, 
              "we should never get here anymore");
            SetMailboxDiscoveryStatus(eContinue);
          }
          else if (GetMailboxDiscoveryStatus() == eContinueNew)
          {
            if (m_hierarchyNameState ==
              kListingForInfoAndDiscovery &&
              !boxNameCopy.IsEmpty() && 
              !(adoptedBoxSpec->box_flags & kNameSpace))
            {
              // remember the info here also
              nsIMAPMailboxInfo *mb = new
                nsIMAPMailboxInfo(boxNameCopy.get(),
                adoptedBoxSpec->hierarchySeparator); 
              m_listedMailboxList.AppendElement((void*) mb);
            }
            SetMailboxDiscoveryStatus(eContinue);
          }
        }
      }
        }
        NS_IF_RELEASE( adoptedBoxSpec);
        break;
    case kDiscoverBaseFolderInProgress:
      break;
    case kDeleteSubFoldersInProgress:
      {
        NS_ASSERTION(m_deletableChildren, 
          "Oops .. null m_deletableChildren\n");
        m_deletableChildren->AppendElement((void*)
          nsCRT::strdup(adoptedBoxSpec->allocatedPathName));
        PR_FREEIF(adoptedBoxSpec->hostName);
        NS_IF_RELEASE( adoptedBoxSpec);
      }
      break;
    case kListingForInfoOnly:
      {
        //UpdateProgressWindowForUpgrade(adoptedBoxSpec->allocatedPathName);
        ProgressEventFunctionUsingIdWithString(IMAP_DISCOVERING_MAILBOX,
          adoptedBoxSpec->allocatedPathName);
        nsIMAPMailboxInfo *mb = new
          nsIMAPMailboxInfo(adoptedBoxSpec->allocatedPathName,
          adoptedBoxSpec->hierarchySeparator);
        m_listedMailboxList.AppendElement((void*) mb);
        PR_FREEIF(adoptedBoxSpec->allocatedPathName);
        NS_IF_RELEASE(adoptedBoxSpec);
      }
      break;
    case kDiscoveringNamespacesOnly:
      {
        PR_FREEIF(adoptedBoxSpec->allocatedPathName);
        NS_IF_RELEASE(adoptedBoxSpec);
      }
      break;
    default:
      NS_ASSERTION (PR_FALSE, "we aren't supposed to be here");
      break;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsImapProtocol::EndIdle ( PRBool  waitForResponse = PR_TRUE) [private]

Definition at line 7154 of file nsImapProtocol.cpp.

{
  // clear the async wait - otherwise, we seem to have trouble doing a blocking read
  nsCOMPtr <nsIAsyncInputStream> asyncInputStream = do_QueryInterface(m_inputStream);
  if (asyncInputStream)
    asyncInputStream->AsyncWait(nsnull, 0, 0, nsnull);
  nsresult rv = SendData("DONE"CRLF);
  // set a short timeout if we don't want to wait for a response
  if (m_transport && !waitForResponse)
    m_transport->SetTimeout(nsISocketTransport::TIMEOUT_READ_WRITE, 5);
  if (NS_SUCCEEDED(rv))
  {
    m_idle = PR_FALSE;
    ParseIMAPandCheckForNewMail();
  }
  m_imapMailFolderSink = nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsImapProtocol::EscapeUserNamePasswordString ( const char *  strToEscape,
nsCString resultStr 
) [static]

Definition at line 5062 of file nsImapProtocol.cpp.

{
  if (strToEscape) 
  {
    PRUint32 i = 0;
    PRUint32 escapeStrlen = strlen(strToEscape);
    for (i=0; i<escapeStrlen; i++)
    {
        if (strToEscape[i] == '\\' || strToEscape[i] == '\"') 
        {
            resultStr->Append('\\');
        }
        resultStr->Append(strToEscape[i]);
    }
  }
}

Here is the caller graph for this function:

Definition at line 1218 of file nsImapProtocol.cpp.

{
  char * serverResponse = CreateNewLineFromSocket(); // read in the greeting

  // record the fact that we've received a greeting for this connection so we don't ever
  // try to do it again..
  if (serverResponse)
    SetFlag(IMAP_RECEIVED_GREETING);

  if (!nsCRT::strncasecmp(serverResponse, "* OK", 4))
  {
    SetConnectionStatus(0);
  }
  else if (!nsCRT::strncasecmp(serverResponse, "* PREAUTH", 9))
  {
    // we've been pre-authenticated.
    // we can skip the whole password step, right into the
    // kAuthenticated state
    GetServerStateParser().PreauthSetAuthenticatedState();

    if (GetServerStateParser().GetCapabilityFlag() == kCapabilityUndefined)
      Capability();

    if ( !(GetServerStateParser().GetCapabilityFlag() & 
          (kIMAP4Capability | kIMAP4rev1Capability | kIMAP4other) ) )
    {
      // AlertUserEvent_UsingId(MK_MSG_IMAP_SERVER_NOT_IMAP4);
      SetConnectionStatus(-1);        // stop netlib
    }
    else
    {
      // let's record the user as authenticated.
      m_imapServerSink->SetUserAuthenticated(PR_TRUE);

      ProcessAfterAuthenticated();
      // the connection was a success
      SetConnectionStatus(0);
     }
  }
  
  PR_Free(serverResponse); // we don't care about the greeting yet...
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4920 of file nsImapProtocol.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void nsImapProtocol::FallbackToFetchWholeMsg ( const char *  messageId,
PRUint32  messageSize 
)

Definition at line 2889 of file nsImapProtocol.cpp.

{
  if (m_imapMessageSink && m_runningUrl)
  {
    PRBool shouldStoreMsgOffline;
    m_runningUrl->GetShouldStoreMsgOffline(&shouldStoreMsgOffline);
    if (shouldStoreMsgOffline)
      m_imapMessageSink->SetNotifyDownloadedLines(PR_TRUE);
  }
  FetchTryChunking(messageId, kEveryThingRFC822, PR_TRUE, NULL, messageSize, PR_TRUE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsImapProtocol::FetchMessage ( const char *  messageIds,
nsIMAPeFetchFields  whatToFetch,
PRBool  idAreUid,
PRUint32  startByte = 0,
PRUint32  endByte = 0,
char *  part = 0 
) [virtual]

Definition at line 2902 of file nsImapProtocol.cpp.

{
  IncrementCommandTagNumber();
  
  nsCString commandString;
  if (idIsUid)
    commandString = "%s UID fetch";
  else
    commandString = "%s fetch";
  
  switch (whatToFetch) {
  case kEveryThingRFC822:
    m_flagChangeCount++;
    GetServerStateParser().SetFetchingEverythingRFC822(PR_TRUE);
    if (m_trackingTime)
      AdjustChunkSize();      // we started another segment
    m_startTime = PR_Now();     // save start of download time
    m_trackingTime = PR_TRUE;
    if (GetServerStateParser().ServerHasIMAP4Rev1Capability())
    {
      if (GetServerStateParser().GetCapabilityFlag() & kHasXSenderCapability)
        commandString.Append(" %s (XSENDER UID RFC822.SIZE BODY[]");
      else
        commandString.Append(" %s (UID RFC822.SIZE BODY[]");
    }
    else
    {
      if (GetServerStateParser().GetCapabilityFlag() & kHasXSenderCapability)
        commandString.Append(" %s (XSENDER UID RFC822.SIZE RFC822");
      else
        commandString.Append(" %s (UID RFC822.SIZE RFC822");
    }
    if (endByte > 0)
    {
      // if we are retrieving chunks
      char *byterangeString = PR_smprintf("<%ld.%ld>",startByte,endByte);
      if (byterangeString)
      {
        commandString.Append(byterangeString);
        PR_Free(byterangeString);
      }
    }
    commandString.Append(")");
    
    break;
    
  case kEveryThingRFC822Peek:
    {
      const char *formatString = "";
      PRUint32 server_capabilityFlags = GetServerStateParser().GetCapabilityFlag();
      
      GetServerStateParser().SetFetchingEverythingRFC822(PR_TRUE);
      if (server_capabilityFlags & kIMAP4rev1Capability)
      {
        // use body[].peek since rfc822.peek is not in IMAP4rev1
        if (server_capabilityFlags & kHasXSenderCapability)
          formatString = " %s (XSENDER UID RFC822.SIZE BODY.PEEK[]";
        else
          formatString = " %s (UID RFC822.SIZE BODY.PEEK[]";
      }
      else
      {
        if (server_capabilityFlags & kHasXSenderCapability)
          formatString = " %s (XSENDER UID RFC822.SIZE RFC822.peek";
        else
          formatString = " %s (UID RFC822.SIZE RFC822.peek";
      }
      
      commandString.Append(formatString);
      if (endByte > 0)
      {
        // if we are retrieving chunks
        char *byterangeString = PR_smprintf("<%ld.%ld>",startByte,endByte);
        if (byterangeString)
        {
          commandString.Append(byterangeString);
          PR_Free(byterangeString);
        }
      }
      commandString.Append(")");
    }
    break;
  case kHeadersRFC822andUid:
    if (GetServerStateParser().ServerHasIMAP4Rev1Capability())
    {
      PRUint32 server_capabilityFlags = GetServerStateParser().GetCapabilityFlag();
      PRBool aolImapServer = ((server_capabilityFlags & kAOLImapCapability) != 0);
      PRBool downloadAllHeaders = PR_FALSE; 
      // checks if we're filtering on "any header" or running a spam filter requiring all headers
      GetShouldDownloadAllHeaders(&downloadAllHeaders); 
      
      if (!downloadAllHeaders)  // if it's ok -- no filters on any header, etc.
      {
        char *headersToDL = nsnull;
        char *what = nsnull;
        const char *dbHeaders = (gUseEnvelopeCmd) ? IMAP_DB_HEADERS : IMAP_ENV_AND_DB_HEADERS;
        nsXPIDLCString arbitraryHeaders;
        GetArbitraryHeadersToDownload(getter_Copies(arbitraryHeaders));
        for (PRInt32 i = 0; i < gCustomDBHeaders.Count(); i++)
        {
          if (arbitraryHeaders.Find(* (gCustomDBHeaders[i]), PR_TRUE) == kNotFound)
          {
            if (!arbitraryHeaders.IsEmpty())
              arbitraryHeaders.Append(' ');
            arbitraryHeaders.Append(gCustomDBHeaders[i]->get());
          }
        }   
        if (arbitraryHeaders.IsEmpty())
          headersToDL = nsCRT::strdup(dbHeaders);
        else
          headersToDL = PR_smprintf("%s %s",dbHeaders, arbitraryHeaders.get());
        
        if (gUseEnvelopeCmd)
          what = PR_smprintf(" ENVELOPE BODY.PEEK[HEADER.FIELDS (%s)])", headersToDL);
        else
          what = PR_smprintf(" BODY.PEEK[HEADER.FIELDS (%s)])",headersToDL);
        nsCRT::free(headersToDL);
        if (what)
        {
          commandString.Append(" %s (UID ");
          if (aolImapServer)
            commandString.Append(" XAOL.SIZE") ;
          else
            commandString.Append("RFC822.SIZE");
          commandString.Append(" FLAGS");
          commandString.Append(what);
          PR_Free(what);
        }
        else 
        {
          commandString.Append(" %s (UID RFC822.SIZE BODY.PEEK[HEADER] FLAGS)");
        }
      }
      else
        commandString.Append(" %s (UID RFC822.SIZE BODY.PEEK[HEADER] FLAGS)");
    }
    else
      commandString.Append(" %s (UID RFC822.SIZE RFC822.HEADER FLAGS)");
    break;
  case kUid:
    commandString.Append(" %s (UID)");
    break;
  case kFlags:
    GetServerStateParser().SetFetchingFlags(PR_TRUE);
    commandString.Append(" %s (FLAGS)");
    break;
  case kRFC822Size:
    commandString.Append(" %s (RFC822.SIZE)");
    break;
  case kBodyStart:
    {
      PRInt32 numBytesToFetch;
      m_runningUrl->GetNumBytesToFetch(&numBytesToFetch);

      commandString.Append(" %s (UID BODY.PEEK[HEADER.FIELDS (Content-Type Content-Transfer-Encoding)] BODY.PEEK[TEXT]<0.");
      commandString.AppendInt(numBytesToFetch);
      commandString.Append(">)");
    }
    break;
  case kRFC822HeadersOnly:
    if (GetServerStateParser().ServerHasIMAP4Rev1Capability())
    {
      if (part)
      {
        commandString.Append(" %s (BODY[");
        char *what = PR_smprintf("%s.HEADER])", part);
        if (what)
        {
          commandString.Append(what);
          PR_Free(what);
        }
        else
          HandleMemoryFailure();
      }
      else
      {
        // headers for the top-level message
        commandString.Append(" %s (BODY[HEADER])");
      }
    }
    else
      commandString.Append(" %s (RFC822.HEADER)");
    break;
  case kMIMEPart:
    commandString.Append(" %s (BODY.PEEK[%s]");
    if (endByte > 0)
    {
      // if we are retrieving chunks
      char *byterangeString = PR_smprintf("<%ld.%ld>",startByte,endByte);
      if (byterangeString)
      {
        commandString.Append(byterangeString);
        PR_Free(byterangeString);
      }
    }
    commandString.Append(")");
    break;
  case kMIMEHeader:
    commandString.Append(" %s (BODY[%s.MIME])");
    break;
  };
  
  commandString.Append(CRLF);
  
  // since messageIds can be infinitely long, use a dynamic buffer rather than the fixed one
  const char *commandTag = GetServerCommandTag();
  int protocolStringSize = commandString.Length() + strlen(messageIds) + PL_strlen(commandTag) + 1 +
    (part ? PL_strlen(part) : 0);
  char *protocolString = (char *) PR_CALLOC( protocolStringSize );
  
  if (protocolString)
  {
    char *cCommandStr = ToNewCString(commandString);
    if ((whatToFetch == kMIMEPart) ||
      (whatToFetch == kMIMEHeader))
    {
      PR_snprintf(protocolString,                                      // string to create
        protocolStringSize,                                      // max size
        cCommandStr,                                   // format string
        commandTag,                          // command tag
        messageIds,
        part);
    }
    else
    {
      PR_snprintf(protocolString,                                      // string to create
        protocolStringSize,                                      // max size
        cCommandStr,                                   // format string
        commandTag,                          // command tag
        messageIds);
    }
    
    nsresult rv = SendData(protocolString);
    
    nsMemory::Free(cCommandStr);
    if (NS_SUCCEEDED(rv))
      ParseIMAPandCheckForNewMail(protocolString);
    PR_Free(protocolString);
    GetServerStateParser().SetFetchingFlags(PR_FALSE);
    GetServerStateParser().SetFetchingEverythingRFC822(PR_FALSE); // always clear this flag after every fetch....
    if (GetServerStateParser().LastCommandSuccessful() && CheckNeeded())
      Check();
  }
  else
    HandleMemoryFailure();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsImapProtocol::FetchMsgAttribute ( const char *  messageIds,
const char *  attribute 
)

Definition at line 2868 of file nsImapProtocol.cpp.

{
    IncrementCommandTagNumber();
    
    nsCAutoString commandString (GetServerCommandTag());
    commandString.Append(" UID fetch ");
    commandString.Append(messageIds);
    commandString.Append(" (");
    commandString.Append(attribute);
    commandString.Append(")"CRLF);
    nsresult rv = SendData(commandString.get());
      
    if (NS_SUCCEEDED(rv))
       ParseIMAPandCheckForNewMail(commandString.get());
    GetServerStateParser().SetFetchingFlags(PR_FALSE);
    GetServerStateParser().SetFetchingEverythingRFC822(PR_FALSE); // always clear this flag after every fetch....
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsImapProtocol::FetchTryChunking ( const char *  messageIds,
nsIMAPeFetchFields  whatToFetch,
PRBool  idIsUid,
char *  part,
PRUint32  downloadSize,
PRBool  tryChunking 
)

Definition at line 3153 of file nsImapProtocol.cpp.

{
  GetServerStateParser().SetTotalDownloadSize(downloadSize);
  if (m_fetchByChunks && tryChunking &&
        GetServerStateParser().ServerHasIMAP4Rev1Capability() &&
    (downloadSize > (PRUint32) m_chunkThreshold))
  {
    PRUint32 startByte = 0;
    GetServerStateParser().ClearLastFetchChunkReceived();
    while (!DeathSignalReceived() && !GetPseudoInterrupted() && 
      !GetServerStateParser().GetLastFetchChunkReceived() &&
      GetServerStateParser().ContinueParse())
    {
      PRUint32 sizeToFetch = startByte + m_chunkSize > downloadSize ?
        downloadSize - startByte : m_chunkSize;
      FetchMessage(messageIds, 
             whatToFetch,
             idIsUid,
             startByte, sizeToFetch,
             part);
      startByte += sizeToFetch;
      // adjust the message size based on rfc822 size, if we're fetching
      // the whole message, and not just a mime part.
      if (whatToFetch != kMIMEPart)
      {
        PRUint32 newMsgSize = GetServerStateParser().SizeOfMostRecentMessage();
        if (newMsgSize > 0 && newMsgSize != downloadSize)
          downloadSize = newMsgSize;
      }
    }

    // Only abort the stream if this is a normal message download
    // Otherwise, let the body shell abort the stream.
    if ((whatToFetch == kEveryThingRFC822)
      &&
      ((startByte > 0 && (startByte < downloadSize) &&
      (DeathSignalReceived() || GetPseudoInterrupted())) ||
      !GetServerStateParser().ContinueParse()))
    {
      AbortMessageDownLoad();
      PseudoInterrupt(PR_FALSE);
    }
  }
  else
  {
    // small message, or (we're not chunking and not doing bodystructure),
    // or the server is not rev1.
    // Just fetch the whole thing.
    FetchMessage(messageIds, whatToFetch,idIsUid, 0, 0, part);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 6526 of file nsImapProtocol.cpp.

{
    //PR_EnterMonitor(fFindingMailboxesMonitor);
    // biff should not discover mailboxes
  PRBool foundMailboxesAlready = PR_FALSE;
  nsImapAction imapAction;
  nsresult rv = NS_OK;

  // need to do this for every connection in order to see folders.
#ifdef DOING_PSEUDO_MAILBOXES
  // check if this is an aol web mail server by checking for the host name the account wizard sets
  // up for an aol web mail account - the host name itself is not used, but that's what we set it to, 
  // so compare against it. A better solution would be to have the wizard set a special pref property on the
  // server and perhaps we should do that for RTM
  if (GetServerStateParser().ServerIsAOLServer() && GetImapHostName() && !nsCRT::strcmp(GetImapHostName(), "imap.mail.aol.com"))
  {
    PRBool suppressPseudoView = PR_FALSE;
    nsCOMPtr<nsIMsgIncomingServer> server = do_QueryReferent(m_server);
    server->GetBoolAttribute("suppresspseudoview", &suppressPseudoView); 
    if (!suppressPseudoView)
      XAOL_Option("+READMBOX");
  }
#endif

  rv = m_runningUrl->GetImapAction(&imapAction);
  rv = m_hostSessionList->GetHaveWeEverDiscoveredFoldersForHost(GetImapServerKey(), foundMailboxesAlready);
    if (NS_SUCCEEDED(rv) && !foundMailboxesAlready &&
    (imapAction != nsIImapUrl::nsImapBiff) &&
    (imapAction != nsIImapUrl::nsImapDiscoverAllBoxesUrl) &&
    (imapAction != nsIImapUrl::nsImapUpgradeToSubscription) &&
    !GetSubscribingNow())
    {
    DiscoverMailboxList();

    // If we decide to do it, here is where we should check to see if
    // a namespace exists (personal namespace only?) and possibly
    // create it if it doesn't exist.
  }
    //PR_ExitMonitor(fFindingMailboxesMonitor);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsImapProtocol::FolderDeleted ( const char *  mailboxName) [private]

Definition at line 6393 of file nsImapProtocol.cpp.

{
    char onlineDelimiter = kOnlineHierarchySeparatorUnknown;
    char *orphanedMailboxName = nsnull;

    if (mailboxName)
    {
        m_runningUrl->AllocateCanonicalPath(mailboxName, onlineDelimiter,
                                            &orphanedMailboxName);
    if (m_imapServerSink)
      m_imapServerSink->OnlineFolderDelete(orphanedMailboxName);
    }

    PR_FREEIF(orphanedMailboxName);
}

Here is the caller graph for this function:

void nsImapProtocol::FolderHeaderDump ( PRUint32 msgUids,
PRUint32  msgCount 
) [private]

Definition at line 3737 of file nsImapProtocol.cpp.

{
  FolderMsgDump(msgUids, msgCount, kHeadersRFC822andUid);
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsImapProtocol::FolderIsSelected ( const char *  mailboxName) [private]

Definition at line 5997 of file nsImapProtocol.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void nsImapProtocol::FolderMsgDump ( PRUint32 msgUids,
PRUint32  msgCount,
nsIMAPeFetchFields  fields 
) [private]

Definition at line 3742 of file nsImapProtocol.cpp.

{
  // lets worry about this progress stuff later.
  switch (fields) {
  case kHeadersRFC822andUid:
    SetProgressString(IMAP_RECEIVING_MESSAGE_HEADERS_OF);
    break;
  case kFlags:
    SetProgressString(IMAP_RECEIVING_MESSAGE_FLAGS_OF);
    break;
  default:
    SetProgressString(IMAP_FOLDER_RECEIVING_MESSAGE_OF);
    break;
  }
  
  m_progressIndex = 0;
  m_progressCount = msgCount;
  FolderMsgDumpLoop(msgUids, msgCount, fields);
  
  SetProgressString(0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsImapProtocol::FolderMsgDumpLoop ( PRUint32 msgUids,
PRUint32  msgCount,
nsIMAPeFetchFields  fields 
) [private]

Definition at line 3846 of file nsImapProtocol.cpp.

{

  PRInt32 msgCountLeft = msgCount;
  PRUint32 msgsDownloaded = 0;
  do 
  {
    nsCString idString;

    PRUint32 msgsToDownload = msgCountLeft;
    AllocateImapUidString(msgUids + msgsDownloaded, msgsToDownload, m_flagState, idString);  // 20 * 200

    FetchMessage(idString.get(),  fields, PR_TRUE);                  // msg ids are uids                 

    msgsDownloaded += msgsToDownload;
    msgCountLeft -= msgsToDownload;

  }
  while (msgCountLeft > 0 && !DeathSignalReceived());
}     

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsImapProtocol::FolderNeedsACLInitialized ( const char *  folderName) [private]

Definition at line 6842 of file nsImapProtocol.cpp.

{
  PRBool rv = PR_FALSE;

  char *name = PL_strdup(folderName);
  if (!name)
    return PR_FALSE;
  m_imapServerSink->FolderNeedsACLInitialized(name, &rv);

  PR_Free(name);
  return rv;
}

Here is the caller graph for this function:

void nsImapProtocol::FolderNotCreated ( const char *  mailboxName) [private]

Definition at line 6409 of file nsImapProtocol.cpp.

{
    if (folderName && m_imapServerSink)
        m_imapServerSink->OnlineFolderCreateFailed(folderName);
}

Here is the caller graph for this function:

void nsImapProtocol::FolderRenamed ( const char *  oldName,
const char *  newName 
) [private]

Definition at line 6415 of file nsImapProtocol.cpp.

{
  char onlineDelimiter = kOnlineHierarchySeparatorUnknown;
  
  if ((m_hierarchyNameState == kNoOperationInProgress) ||
    (m_hierarchyNameState == kListingForInfoAndDiscovery))
    
  {
    nsXPIDLCString canonicalOldName, canonicalNewName;
    m_runningUrl->AllocateCanonicalPath(oldName,
      onlineDelimiter,
      getter_Copies(canonicalOldName));
    m_runningUrl->AllocateCanonicalPath(newName,
      onlineDelimiter,
      getter_Copies(canonicalNewName));
    nsCOMPtr<nsIMsgWindow> msgWindow;
    GetMsgWindow(getter_AddRefs(msgWindow));
    m_imapServerSink->OnlineFolderRename(msgWindow, canonicalOldName, canonicalNewName);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsImapProtocol::GetACLForFolder ( const char *  aMailboxName) [private]

Definition at line 5805 of file nsImapProtocol.cpp.

{
  IncrementCommandTagNumber();

  nsCString command(GetServerCommandTag());
  char *escapedName = CreateEscapedMailboxName(mailboxName);
  command.Append(" getacl \"");
  command.Append(escapedName);
  command.Append("\"" CRLF);
            
  nsMemory::Free(escapedName);
            
  nsresult rv = SendData(command.get());
  if (NS_SUCCEEDED(rv))
    ParseIMAPandCheckForNewMail();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4199 of file nsImapProtocol.cpp.

Here is the call graph for this function:

Definition at line 2695 of file nsImapProtocol.cpp.

{
  if (m_imapServerSink)
    m_imapServerSink->GetArbitraryHeaders(aResult);
}

Here is the caller graph for this function:

Definition at line 4431 of file nsImapProtocol.cpp.

{
    // ***?? I am not sure we really to guard with monitor for 5.0 ***
    PRInt32 status;
  // mscott -- do we need these monitors? as i was debuggin this I continually
  // locked when entering this monitor...control would never return from this
  // function...
//    PR_CEnterMonitor(this);
    status = m_connectionStatus;
//    PR_CExitMonitor(this);
    return status;
}

Here is the caller graph for this function:

Definition at line 298 of file nsImapProtocol.h.

{return m_runningUrl;}

Here is the caller graph for this function:

Definition at line 4129 of file nsImapProtocol.cpp.

{
    return m_dataMemberMonitor;
}

Here is the caller graph for this function:

Definition at line 7879 of file nsImapProtocol.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIImapProtocol::GetFlagsForUID ( in unsigned long  uid,
out boolean  foundIt,
out unsigned short  flags,
out string  customFlags 
) [inherited]

Here is the caller graph for this function:

Definition at line 5604 of file nsImapProtocol.cpp.

{
  char *sourceMailbox = nsnull;
  char onlineSubDirDelimiter = 0;
  PRUnichar hierarchyDelimiter = 0;
  nsCOMPtr <nsIMsgFolder> msgFolder;

  m_runningUrl->GetOnlineSubDirSeparator(&onlineSubDirDelimiter);
  nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(m_runningUrl);
  mailnewsUrl->GetFolder(getter_AddRefs(msgFolder));
  if (msgFolder)
  {
    nsCOMPtr <nsIMsgImapMailFolder> imapFolder = do_QueryInterface(msgFolder);
    if (imapFolder)
    {
      imapFolder->GetHierarchyDelimiter(&hierarchyDelimiter);
      if (hierarchyDelimiter != kOnlineHierarchySeparatorUnknown
          && onlineSubDirDelimiter != (char) hierarchyDelimiter)
          m_runningUrl->SetOnlineSubDirSeparator ((char) hierarchyDelimiter);
    }
  }
  m_runningUrl->CreateServerSourceFolderPathString(&sourceMailbox);

  return sourceMailbox;
}

Here is the call graph for this function:

Definition at line 236 of file nsImapProtocol.h.

{return m_ignoreExpunges;}

Here is the caller graph for this function:

Definition at line 586 of file nsImapProtocol.cpp.

{
  if (m_runningUrl && m_hostName.IsEmpty())
  {
    nsCOMPtr<nsIURI> url = do_QueryInterface(m_runningUrl);
    url->GetAsciiHost(m_hostName);
  }

  return m_hostName.get();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 607 of file nsImapProtocol.cpp.

{
  nsCOMPtr<nsIMsgIncomingServer> server = do_QueryReferent(m_server);
  if (!m_serverKey && server)
    server->GetKey(&m_serverKey);
  return m_serverKey;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 598 of file nsImapProtocol.cpp.

{
  nsCOMPtr<nsIMsgIncomingServer> server = do_QueryReferent(m_server);
  if (!m_userName && server)
    server->GetUsername(&m_userName);
  return m_userName;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4246 of file nsImapProtocol.cpp.

{
  return PR_FALSE;
//  return gIOTunnelling;
}

Here is the caller graph for this function:

Here is the caller graph for this function:

Definition at line 4479 of file nsImapProtocol.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

PRUint32 nsImapProtocol::GetMessageSize ( const char *  messageId,
PRBool  idsAreUids 
)

Definition at line 4039 of file nsImapProtocol.cpp.

{
  const char *folderFromParser = GetServerStateParser().GetSelectedMailboxName(); 
  if (folderFromParser && messageId)
  {
    char *id = (char *)PR_CALLOC(strlen(messageId) + 1);
    char *folderName;
    PRUint32 size;

    PL_strcpy(id, messageId);

    nsIMAPNamespace *nsForMailbox = nsnull;
        m_hostSessionList->GetNamespaceForMailboxForHost(GetImapServerKey(), folderFromParser,
            nsForMailbox);


    if (nsForMailbox)
          m_runningUrl->AllocateCanonicalPath(
              folderFromParser, nsForMailbox->GetDelimiter(),
              &folderName);
    else
       m_runningUrl->AllocateCanonicalPath(
          folderFromParser,kOnlineHierarchySeparatorUnknown,
          &folderName);

    if (id && folderName)
    {
      if (m_imapMessageSink)
          m_imapMessageSink->GetMessageSizeFromDB(id, idsAreUids, &size);
    }
    PR_FREEIF(id);
    PR_FREEIF(folderName);

    PRUint32 rv = 0;
    if (!DeathSignalReceived())
      rv = size;
    return rv;
  }
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsImapProtocol::GetMsgWindow ( nsIMsgWindow **  aMsgWindow) [private]

Definition at line 7617 of file nsImapProtocol.cpp.

{
    nsresult rv = NS_OK;
    nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl =
        do_QueryInterface(m_runningUrl, &rv);
    if (NS_FAILED(rv)) return rv;
    rv = mailnewsUrl->GetMsgWindow(aMsgWindow);
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 5976 of file nsImapProtocol.cpp.

{
  IncrementCommandTagNumber();

  nsCString command(GetServerCommandTag());
  char *escapedName = CreateEscapedMailboxName(mailboxName);
    
  if (MailboxIsNoSelectMailbox(escapedName))
    return; // Don't issue myrights on Noselect folder

  command.Append(" myrights \"");
  command.Append(escapedName);
  command.Append("\"" CRLF);
            
  nsMemory::Free(escapedName);
            
  nsresult rv = SendData(command.get());
  if (NS_SUCCEEDED(rv))
    ParseIMAPandCheckForNewMail();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 7627 of file nsImapProtocol.cpp.

{
  nsCOMPtr<nsIMsgWindow> msgWindow;

  if (password.IsEmpty() && m_imapServerSink &&
      !(m_useSecAuth && GetServerStateParser().GetCapabilityFlag() & kHasAuthGssApiCapability))
  {
    nsresult rv = GetMsgWindow(getter_AddRefs(msgWindow));
    if (NS_FAILED(rv)) return rv;
    // need to copy password, because in the case of Cancel,
    // GetPasswordWithUI will set the password pointer to null.
    char *pPassword = ToNewCString(m_lastPasswordSent);
    char *savePassword = pPassword;
    rv = m_imapServerSink->PromptForPassword(&pPassword, msgWindow);
    PR_Free(savePassword);
    if (rv == NS_MSG_PASSWORD_PROMPT_CANCELLED)
      return NS_ERROR_ABORT;
    password.Adopt(pPassword);
  }
  m_lastPasswordSent = password;
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4172 of file nsImapProtocol.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void nsImapProtocol::GetQuotaDataIfSupported ( const char *  aBoxName) [private]

Definition at line 7844 of file nsImapProtocol.cpp.

{
  // If server doesn't have quota support, don't do anything
  if (! (GetServerStateParser().GetCapabilityFlag() & kQuotaCapability))
    return;

  // If it's an aol server then only issue cmd for INBOX (since all
  // other AOL mailboxes are virtual and don't support all imap cmds).
  nsresult rv;
  nsCOMPtr<nsIImapIncomingServer> imapServer = do_QueryReferent(m_server, &rv);
  if (NS_FAILED(rv))
    return;
  nsXPIDLCString redirectorType;
  imapServer->GetRedirectorType(getter_Copies(redirectorType));
  if (redirectorType.EqualsLiteral("aol") && PL_strcasecmp("Inbox", aBoxName))
    return;

  IncrementCommandTagNumber();

  nsCAutoString quotacommand;
  quotacommand = nsDependentCString(GetServerCommandTag())
               + NS_LITERAL_CSTRING(" getquotaroot \"")
               + nsDependentCString(aBoxName)
               + NS_LITERAL_CSTRING("\"" CRLF);

  NS_ASSERTION(m_imapMailFolderSink, "m_imapMailFolderSink is null!");
  if (m_imapMailFolderSink)
    m_imapMailFolderSink->SetFolderQuotaCommandIssued(PR_TRUE);

  nsresult quotarv = SendData(quotacommand.get());
  if (NS_SUCCEEDED(quotarv))
    ParseIMAPandCheckForNewMail(nsnull, PR_TRUE); // don't display errors.
}

Here is the call graph for this function:

Here is the caller graph for this function:

Here is the caller graph for this function:

Definition at line 1949 of file nsImapProtocol.cpp.

Definition at line 391 of file nsImapProtocol.h.

{ return m_parser; };

Definition at line 2688 of file nsImapProtocol.cpp.

{
  if (m_imapMailFolderSink)
    m_imapMailFolderSink->GetShouldDownloadAllHeaders(aResult);
}

Here is the caller graph for this function:

Definition at line 4224 of file nsImapProtocol.cpp.

{
  if (m_runningUrl  && !DeathSignalReceived())
  {
    nsImapContentModifiedType contentModified;
    if (NS_SUCCEEDED(m_runningUrl->GetContentModified(&contentModified)))
      return (contentModified == IMAP_CONTENT_FORCE_CONTENT_NOT_MODIFIED);
  }
  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4208 of file nsImapProtocol.cpp.

{
  PRBool showAttachmentsInline = PR_TRUE;
  if (m_imapServerSink)
    m_imapServerSink->GetShowAttachmentsInline(&showAttachmentsInline);
  return showAttachmentsInline;

}

Here is the caller graph for this function:

Definition at line 7889 of file nsImapProtocol.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4490 of file nsImapProtocol.cpp.

{
    // ***** code me *****
    return PR_FALSE;// ***** for now
}

Here is the caller graph for this function:

void nsIImapProtocol::GetSupportedUserFlags ( out unsigned short  flags) [inherited]

Here is the caller graph for this function:

Definition at line 7017 of file nsImapProtocol.cpp.

{
  if (m_trashFolderName.IsEmpty())
  {
    nsCOMPtr<nsIImapIncomingServer> server = do_QueryReferent(m_server);
    if (server)
    {
      nsXPIDLString trashFolderName;
      if (NS_SUCCEEDED(server->GetTrashFolderName(getter_Copies(trashFolderName))))
      {
        CopyUTF16toMUTF7(trashFolderName, m_trashFolderName);
      }
    }
  }
  
  return m_trashFolderName.get();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4240 of file nsImapProtocol.cpp.

{
  return 0;
//  return gTunnellingThreshold;
}

Here is the caller graph for this function:

Definition at line 327 of file nsImapProtocol.cpp.

{
    gInitialized = PR_TRUE;
    nsresult rv;
    nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv)); 
    NS_ENSURE_SUCCESS(rv, rv);

    prefBranch->GetIntPref("mail.imap.chunk_fast", &gTooFastTime);   // secs we read too little too fast
    prefBranch->GetIntPref("mail.imap.chunk_ideal", &gIdealTime);    // secs we read enough in good time
    prefBranch->GetIntPref("mail.imap.chunk_add", &gChunkAddSize);   // buffer size to add when wasting time
    prefBranch->GetIntPref("mail.imap.chunk_size", &gChunkSize);
    prefBranch->GetIntPref("mail.imap.min_chunk_size_threshold", &gChunkThreshold);
    prefBranch->GetIntPref("mail.imap.max_chunk_size", &gMaxChunkSize);
    prefBranch->GetBoolPref("mail.imap.hide_other_users",
                            &gHideOtherUsersFromList);
    prefBranch->GetBoolPref("mail.imap.hide_unused_namespaces",
                            &gHideUnusedNamespaces);
    prefBranch->GetIntPref("mail.imap.noop_check_count", &gPromoteNoopToCheckCount);
    prefBranch->GetBoolPref("mail.imap.use_envelope_cmd",
                            &gUseEnvelopeCmd);
    prefBranch->GetBoolPref("mail.imap.use_literal_plus", &gUseLiteralPlus);
    prefBranch->GetBoolPref("mail.imap.expunge_after_delete", &gExpungeAfterDelete);
    prefBranch->GetBoolPref("mail.imap.check_deleted_before_expunge", &gCheckDeletedBeforeExpunge);
    prefBranch->GetIntPref("mailnews.tcptimeout", &gResponseTimeout);
    nsXPIDLCString customDBHeaders;
    prefBranch->GetCharPref("mailnews.customDBHeaders", getter_Copies(customDBHeaders));
    gCustomDBHeaders.ParseString(customDBHeaders, " ");
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4957 of file nsImapProtocol.cpp.

{
#ifdef UNREADY_CODE
  if (fCurrentUrl->GetIMAPurlType() == TIMAPUrl::kSelectFolder)
  {
    // let the front end know the select failed so they
    // don't leave the view without a database.
    nsImapMailboxSpec *notSelectedSpec = new nsImapMailboxSpec;
    if (notSelectedSpec)
    {
      NS_ADDREF(notSelectedSpec);
      notSelectedSpec->allocatedPathName = fCurrentUrl->CreateCanonicalSourceFolderPathString();
      notSelectedSpec->hostName = fCurrentUrl->GetUrlHost();
      notSelectedSpec->folderSelected = PR_FALSE;
      notSelectedSpec->flagState = NULL;
      notSelectedSpec->onlineVerified = PR_FALSE;
      UpdatedMailboxSpec(notSelectedSpec);
    }
  }
  else 
#endif
    // this is to handle a move/copy failing, especially because the user
    // cancelled the password prompt.
  nsresult res;
  res = m_runningUrl->GetImapAction(&m_imapAction);
    if (m_imapAction == nsIImapUrl::nsImapOfflineToOnlineMove || m_imapAction == nsIImapUrl::nsImapAppendMsgFromFile
      || m_imapAction == nsIImapUrl::nsImapAppendDraftFromFile)
  {
    if (m_imapMailFolderSink)
      m_imapMailFolderSink->OnlineCopyCompleted(this, ImapOnlineCopyStateType::kFailedCopy);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1198 of file nsImapProtocol.cpp.

{
  // PRInt32 oldRecent = GetServerStateParser().NumberOfRecentMessages();
  nsCAutoString commandBuffer(GetServerCommandTag());
  commandBuffer.Append(" IDLE"CRLF);

  do
  {
    ParseIMAPandCheckForNewMail(commandBuffer.get());
  }
  while (m_inputStreamBuffer->NextLineAvailable() && GetServerStateParser().Connected());

  //  if (oldRecent != GetServerStateParser().NumberOfRecentMessages())
  //  We might check that something actually changed, but for now we can
  // just assume it. OnNewIdleMessages must run a url, so that
  // we'll go back into asyncwait mode.
  if (GetServerStateParser().Connected() && m_imapMailFolderSink)
    m_imapMailFolderSink->OnNewIdleMessages();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4948 of file nsImapProtocol.cpp.

{
    PR_CEnterMonitor(this);
    // **** jefft fix me!!!!!! ******
    // m_imapThreadIsRunning = PR_FALSE;
    // SetConnectionStatus(-1);
    PR_CExitMonitor(this);
}

Here is the caller graph for this function:

void nsImapProtocol::HandleMessageDownLoadLine ( const char *  line,
PRBool  isPartialLine,
char *  lineCopy = nsnull 
) [virtual]

Definition at line 3328 of file nsImapProtocol.cpp.

{
  NS_PRECONDITION(lineCopy == nsnull || !PL_strcmp(line, lineCopy),
                  "line and lineCopy must contain the same string");    
  const char *messageLine = line;
  PRUint32 lineLength = strlen(messageLine);
  const char *cEndOfLine = messageLine + lineLength;
  char *localMessageLine = nsnull;

  // If we obtain a partial line (due to fetching by chunks), we do not
  // add/modify the end-of-line terminator.
  if (!isPartialLine)
  {
    // Change this line to native line termination, duplicate if necessary.
    // Do not assume that the line really ends in CRLF
    // to start with, even though it is supposed to be RFC822

    // note: usually canonicalLineEnding==FALSE 
    PRBool canonicalLineEnding = PR_FALSE;
    nsCOMPtr<nsIMsgMessageUrl> msgUrl = do_QueryInterface(m_runningUrl);

    if (m_imapAction == nsIImapUrl::nsImapSaveMessageToDisk && msgUrl)
      msgUrl->GetCanonicalLineEnding(&canonicalLineEnding);
  
    NS_PRECONDITION(MSG_LINEBREAK_LEN == 1 ||
                    MSG_LINEBREAK_LEN == 2 && !PL_strcmp(CRLF, MSG_LINEBREAK),
                    "violated assumptions on MSG_LINEBREAK");
    if (MSG_LINEBREAK_LEN == 1 && !canonicalLineEnding)
    {
      PRBool lineEndsWithCRorLF = lineLength >= 1 &&
        (cEndOfLine[-1] == nsCRT::CR || cEndOfLine[-1] == nsCRT::LF);
      char *endOfLine;
      if (lineCopy && lineEndsWithCRorLF)  // true for most lines
      {
        endOfLine = lineCopy + lineLength;
        messageLine = lineCopy;
      }
      else
      {
        // leave enough room for one more char, MSG_LINEBREAK[0]
        localMessageLine = (char *) PR_MALLOC(lineLength + 2);
        if (!localMessageLine) // memory failure
          return;
        PL_strcpy(localMessageLine, line);
        endOfLine = localMessageLine + lineLength;
        messageLine = localMessageLine;
      }
      
      if (lineLength >= 2 &&
        endOfLine[-2] == nsCRT::CR &&
        endOfLine[-1] == nsCRT::LF)
      {
        if(lineLength>=3 && endOfLine[-3] == nsCRT::CR) // CRCRLF
        {
          endOfLine--;
          lineLength--;
        }
        /* CRLF -> CR or LF */
        endOfLine[-2] = MSG_LINEBREAK[0];
        endOfLine[-1] = '\0';
        lineLength--;
      }
      else if (lineLength >= 1 &&
        ((endOfLine[-1] == nsCRT::CR) || (endOfLine[-1] == nsCRT::LF)))
      {
        /* CR -> LF or LF -> CR */
        endOfLine[-1] = MSG_LINEBREAK[0];
      }
      else // no eol characters at all
      {
        endOfLine[0] = MSG_LINEBREAK[0]; // CR or LF
        endOfLine[1] = '\0';
        lineLength++;
      }
    }
    else  // enforce canonical CRLF linebreaks
    {
      if (lineLength==0 || lineLength == 1 && cEndOfLine[-1] == nsCRT::LF)
      {
        messageLine = CRLF;
        lineLength = 2;
      }
      else if (cEndOfLine[-1] != nsCRT::LF || cEndOfLine[-2] != nsCRT::CR ||
               lineLength >=3 && cEndOfLine[-3] == nsCRT::CR)
      {
        // The line does not end in CRLF (or it ends in CRCRLF).
        // Copy line and leave enough room for two more chars (CR and LF).
        localMessageLine = (char *) PR_MALLOC(lineLength + 3);
        if (!localMessageLine) // memory failure
            return;
        PL_strcpy(localMessageLine, line);
        char *endOfLine = localMessageLine + lineLength;
        messageLine = localMessageLine;

        if (lineLength>=3 && endOfLine[-1] == nsCRT::LF && 
            endOfLine[-2] == nsCRT::CR)
        {
          // CRCRLF -> CRLF
          endOfLine[-2] = nsCRT::LF;
          endOfLine[-1] = '\0';
          lineLength--;
        }
        else if ((endOfLine[-1] == nsCRT::CR) || (endOfLine[-1] == nsCRT::LF))
        {
          // LF -> CRLF or CR -> CRLF 
          endOfLine[-1] = nsCRT::CR;
          endOfLine[0]  = nsCRT::LF;
          endOfLine[1]  = '\0';
          lineLength++;
        }
        else // no eol characters at all
        {
          endOfLine[0] = nsCRT::CR;
          endOfLine[1] = nsCRT::LF;
          endOfLine[2] = '\0';
          lineLength += 2;
        }
      }
    }
  }
  NS_ASSERTION(lineLength == PL_strlen(messageLine), "lineLength not accurate");

  // check if sender obtained via XSENDER server extension matches "From:" field
  const char *xSenderInfo = GetServerStateParser().GetXSenderInfo();
  if (xSenderInfo && *xSenderInfo && !m_fromHeaderSeen)
  {
    if (!PL_strncmp("From: ", messageLine, 6))
    {
      m_fromHeaderSeen = PR_TRUE;
      if (PL_strstr(messageLine, xSenderInfo) != NULL)
          // Adding a X-Mozilla-Status line here is not very elegant but it
          // works.  Another X-Mozilla-Status line is added to the message when
          // downloading to a local folder; this new line will also contain the
          // 'authed' flag we are adding here.  (If the message is again
          // uploaded to the server, this flag is lost.)
          // 0x0200 == MSG_FLAG_SENDER_AUTHED
          HandleMessageDownLoadLine("X-Mozilla-Status: 0200\r\n", PR_FALSE);
      GetServerStateParser().FreeXSenderInfo();
    }
  }
  
  if (GetServerStateParser().GetDownloadingHeaders())
  {
    if (!m_curHdrInfo)
      BeginMessageDownLoad(GetServerStateParser().SizeOfMostRecentMessage(), MESSAGE_RFC822);
    if (m_curHdrInfo)
      m_curHdrInfo->CacheLine(messageLine, GetServerStateParser().CurrentResponseUID());
    PR_Free(localMessageLine);
    return;
  }
  // if this line is for a different message, or the incoming line is too big
  if (((m_downloadLineCache.CurrentUID() != GetServerStateParser().CurrentResponseUID()) && !m_downloadLineCache.CacheEmpty()) ||
    (m_downloadLineCache.SpaceAvailable() < lineLength + 1) )
  {
    if (!m_downloadLineCache.CacheEmpty())
    {
      msg_line_info *downloadLineDontDelete = m_downloadLineCache.GetCurrentLineInfo();
      // post ODA lines....
      PostLineDownLoadEvent(downloadLineDontDelete);
    }
    m_downloadLineCache.ResetCache();
  }
  
  // so now the cache is flushed, but this string might still be to big
  if (m_downloadLineCache.SpaceAvailable() < lineLength + 1)
  {
    // has to be dynamic to pass to other win16 thread
    msg_line_info *downLoadInfo = (msg_line_info *) PR_CALLOC(sizeof(msg_line_info));
    if (downLoadInfo)
    {
      downLoadInfo->adoptedMessageLine = messageLine;
      downLoadInfo->uidOfMessage = GetServerStateParser().CurrentResponseUID();
      PostLineDownLoadEvent(downLoadInfo);
      PR_Free(downLoadInfo);
    }
  }
  else
    m_downloadLineCache.CacheLine(messageLine, GetServerStateParser().CurrentResponseUID());

  PR_Free(localMessageLine);
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsImapProtocol::HandlingMultipleMessages ( const char *  messageIdString) [static]

Definition at line 4082 of file nsImapProtocol.cpp.

{
  return (PL_strchr(messageIdString,',') != nsnull ||
        PL_strchr(messageIdString,':') != nsnull);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3868 of file nsImapProtocol.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void nsImapProtocol::Idle ( ) [private]

Definition at line 7126 of file nsImapProtocol.cpp.

{
  IncrementCommandTagNumber();
  
  if (m_urlInProgress)
    return;
  nsCAutoString command (GetServerCommandTag());
  command += " IDLE"CRLF;
  nsresult rv = SendData(command.get());  
  if (NS_SUCCEEDED(rv))
  {
      m_idle = PR_TRUE;
      // we'll just get back a continuation char at first.
      // + idling...
      ParseIMAPandCheckForNewMail();
      // this will cause us to get notified of data or the socket getting closed.
      // That notification will occur on the socket transport thread - we just
      // need to poke a monitor so the imap thread will do a blocking read
      // and parse the data.
      nsCOMPtr <nsIAsyncInputStream> asyncInputStream = do_QueryInterface(m_inputStream);
      if (asyncInputStream)
        asyncInputStream->AsyncWait(this, 0, 0, nsnull);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1130 of file nsImapProtocol.cpp.

{
  PR_LOG(IMAP, PR_LOG_DEBUG, ("ImapThreadMainLoop entering [this=%x]\n", this));

  PRIntervalTime sleepTime = kImapSleepTime;
  while (!DeathSignalReceived())
  {
    nsresult rv = NS_OK;
    PRBool readyToRun;

    // wait for an URL to process...
    {
      nsAutoMonitor mon(m_urlReadyToRunMonitor);

      while (NS_SUCCEEDED(rv) && !DeathSignalReceived() && !m_nextUrlReadyToRun)
        rv = mon.Wait(sleepTime);

      readyToRun = m_nextUrlReadyToRun;
      m_nextUrlReadyToRun = PR_FALSE;
    }

    if (NS_FAILED(rv) && PR_PENDING_INTERRUPT_ERROR == PR_GetError()) 
    {
      printf("error waiting for monitor\n");
      break;
    }

    if (readyToRun && m_runningUrl)
    {
      //
      // NOTE: Though we cleared m_nextUrlReadyToRun above, it may have been
      //       set by LoadImapUrl, which runs on the main thread.  Because of this,
      //       we must not try to clear m_nextUrlReadyToRun here.
      //
      if (ProcessCurrentURL())
      {
        m_nextUrlReadyToRun = PR_TRUE;
        m_imapMailFolderSink = nsnull;
      }
      else
      {
        // see if we want to go into idle mode. Might want to check a pref here too.
        if (m_useIdle && !m_urlInProgress && GetServerStateParser().GetCapabilityFlag() & kHasIdleCapability
          && GetServerStateParser().GetIMAPstate() 
                == nsImapServerResponseParser::kFolderSelected)
        {
          Idle(); // for now, lets just do it. We'll probably want to use a timer
        }
        else // if not idle, don't need to remember folder sink
          m_imapMailFolderSink = nsnull;
      }
    }
    else if (m_idle)
    {
      HandleIdleResponses();
    }
    if (!GetServerStateParser().Connected())
      break;
#ifdef DEBUG_bienvenu
    else
      printf("ready to run but no url and not idle\n");
#endif
  }
  m_imapThreadIsRunning = PR_FALSE;

  PR_LOG(IMAP, PR_LOG_DEBUG, ("ImapThreadMainLoop leaving [this=%x]\n", this));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1944 of file nsImapProtocol.cpp.

{
    sprintf(m_curre