Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes
nsPop3Sink Class Reference

#include <nsPop3Sink.h>

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

List of all members.

Public Member Functions

 nsPop3Sink ()
virtual ~nsPop3Sink ()
NS_DECL_ISUPPORTS
NS_DECL_NSIPOP3SINK nsresult 
GetServerFolder (nsIMsgFolder **aFolder)
nsresult FindPartialMessages (nsFileSpec *fileSpec)
void CheckPartialMessages (nsIPop3Protocol *protocol)
boolean BeginMailDelivery (in boolean uidlDownload, in nsIMsgWindow msgWindow)
void endMailDelivery (in nsIPop3Protocol protocol)
void AbortMailDelivery (in nsIPop3Protocol protocol)
voidPtr IncorporateBegin (in string uidlString, in nsIURI aURL, in unsigned long flags)
void IncorporateWrite (in string block, in long length)
void IncorporateComplete (in nsIMsgWindow aMsgWindow, in PRInt32 aSize)
void IncorporateAbort (in boolean uidlDownload)
void BiffGetNewMail ()
void SetBiffStateAndUpdateFE (in unsigned long biffState, in long numNewMessages, in boolean notify)
void SetSenderAuthedFlag (in voidPtr closure, in boolean authed)

Static Public Member Functions

static char * GetDummyEnvelope (void)

Public Attributes

attribute boolean userAuthenticated
attribute string mailAccountURL
attribute boolean buildMessageUri
attribute string messageUri
attribute string baseMessageUri
attribute nsIPop3IncomingServer popServer
attribute nsIMsgFolder folder

Protected Member Functions

nsresult WriteLineToMailbox (const char *buffer)
nsresult ReleaseFolderLock ()
nsresult HandleTempDownloadFailed (nsIMsgWindow *msgWindow)

Protected Attributes

PRBool m_authed
PRInt64 m_msgOffset
char * m_accountUrl
PRUint32 m_biffState
PRInt32 m_numNewMessages
PRInt32 m_numNewMessagesInFolder
PRBool m_senderAuthed
char * m_outputBuffer
PRInt32 m_outputBufferSize
nsIPop3IncomingServerm_popServer
nsIMsgFolderm_folder
nsParseNewMailStatem_newMailParser
nsIOFileStreamm_outFileStream
PRBool m_buildMessageUri
PRBool m_downloadingToTempFile
nsFileSpec m_tmpDownloadFileSpec
nsCString m_messageUri
nsXPIDLCString m_baseMessageUri
nsXPIDLCString m_accountKey
nsVoidArray m_partialMsgsArray

Detailed Description

Definition at line 55 of file nsPop3Sink.h.


Constructor & Destructor Documentation

nsPop3Sink::~nsPop3Sink ( ) [virtual]

Definition at line 95 of file nsPop3Sink.cpp.

Here is the call graph for this function:


Member Function Documentation

boolean nsIPop3Sink::BeginMailDelivery ( in boolean  uidlDownload,
in nsIMsgWindow  msgWindow 
) [inherited]

Definition at line 244 of file nsPop3Sink.cpp.

{
  PRUint32 count = m_partialMsgsArray.Count();
  PRBool deleted = PR_FALSE;

  for (PRUint32 i = 0; i < count; i++)
  {
    partialRecord *partialMsg;
    PRBool found = PR_TRUE;
    partialMsg = NS_STATIC_CAST(partialRecord *,m_partialMsgsArray.ElementAt(i));
    protocol->CheckMessage(partialMsg->m_uidl.get(), &found);
    if (!found) {
      m_newMailParser->m_mailDB->DeleteHeader(partialMsg->m_msgDBHdr, nsnull, PR_FALSE, PR_TRUE);
      deleted = PR_TRUE;
    }
    delete partialMsg;
  }
  m_partialMsgsArray.Clear();
  if (deleted) {
    nsCOMPtr<nsIMsgLocalMailFolder> localFolder = do_QueryInterface(m_folder);
    if (localFolder) {
      localFolder->NotifyDelete();
    }
  }
}

Here is the call graph for this function:

Definition at line 179 of file nsPop3Sink.cpp.

{
  nsresult rv;

  nsCOMPtr<nsISimpleEnumerator> messages;
  PRBool hasMore = PR_FALSE;
  PRBool isOpen = PR_FALSE;
  nsLocalFolderScanState folderScanState;
  nsCOMPtr<nsIMsgLocalMailFolder> localFolder = do_QueryInterface(m_folder);

  if (!localFolder)
    return NS_ERROR_FAILURE;  // we need it to grub thru the folder

  rv = m_newMailParser->m_mailDB->EnumerateMessages(getter_AddRefs(messages));
  if (messages)
    messages->HasMoreElements(&hasMore);
  while(hasMore && NS_SUCCEEDED(rv))
  {
    nsCOMPtr<nsISupports> aSupport;
    PRUint32 flags = 0;
    rv = messages->GetNext(getter_AddRefs(aSupport));
    nsCOMPtr<nsIMsgDBHdr> msgDBHdr(do_QueryInterface(aSupport, &rv));
    msgDBHdr->GetFlags(&flags);
    if (flags & MSG_FLAG_PARTIAL)
    {
      // Open the various streams we need to seek and read from the mailbox
      if (!isOpen)
      {
        folderScanState.m_fileSpec = fileSpec;
        rv = localFolder->GetFolderScanState(&folderScanState);
        if (NS_SUCCEEDED(rv))
          isOpen = PR_TRUE;
        else
          break;
      }
      rv = localFolder->GetUidlFromFolder(&folderScanState, msgDBHdr);
      if (!NS_SUCCEEDED(rv))
        break;

      // If we got the uidl, see if this partial message belongs to this
      // account. Add it to the array if so...
      if (folderScanState.m_uidl && 
        !nsCRT::strcasecmp(folderScanState.m_accountKey.get(), m_accountKey))
      {
        partialRecord *partialMsg = new partialRecord();
        if (partialMsg)
        {
          partialMsg->m_uidl = folderScanState.m_uidl;
          partialMsg->m_msgDBHdr = msgDBHdr;
          m_partialMsgsArray.AppendElement(partialMsg);
        }
      }
    }
    messages->HasMoreElements(&hasMore);
  }
  if (isOpen)
    folderScanState.m_fileStream->Close();
  return rv;
}

Here is the call graph for this function:

char * nsPop3Sink::GetDummyEnvelope ( void  ) [static]

Definition at line 655 of file nsPop3Sink.cpp.

{
  static char result[75];
  char *ct;
  time_t now = time ((time_t *) 0);
#if defined (XP_WIN)
  if (now < 0 || now > 0x7FFFFFFF)
         now = 0x7FFFFFFF;
#endif
  ct = ctime(&now);
  PR_ASSERT(ct[24] == nsCRT::CR || ct[24] == nsCRT::LF);
  ct[24] = 0;
  /* This value must be in ctime() format, with English abbreviations.
        strftime("... %c ...") is no good, because it is localized. */
  PL_strcpy(result, "From - ");
  PL_strcpy(result + 7, ct);
  PL_strcpy(result + 7 + 24, MSG_LINEBREAK);
  return result;
}

Definition at line 639 of file nsPop3Sink.cpp.

{
  if (!aFolder) 
    return NS_ERROR_NULL_POINTER;
  if (m_popServer)
  {
    // not sure what this is used for - might be wrong if we have a deferred account.
    nsCOMPtr <nsIMsgIncomingServer> incomingServer = do_QueryInterface(m_popServer);
    if (incomingServer)
      return incomingServer->GetRootFolder(aFolder);
  }
  *aFolder = nsnull;
  return NS_ERROR_NULL_POINTER;
}

Here is the call graph for this function:

Definition at line 730 of file nsPop3Sink.cpp.

{

  nsCOMPtr<nsIMsgStringService> stringService = do_GetService(NS_MSG_POPSTRINGSERVICE_CONTRACTID);
  nsXPIDLString fromStr, subjectStr, confirmString;
  m_newMailParser->m_newMsgHdr->GetMime2DecodedSubject(getter_Copies(subjectStr));
  m_newMailParser->m_newMsgHdr->GetMime2DecodedAuthor(getter_Copies(fromStr));
  const PRUnichar *params[] = { fromStr.get(), subjectStr.get() };
  nsCOMPtr<nsIStringBundle> bundle;
  nsresult rv = stringService->GetBundle(getter_AddRefs(bundle));
  if (NS_SUCCEEDED(rv))
    bundle->FormatStringFromID(POP3_TMP_DOWNLOAD_FAILED, params, 2, getter_Copies(confirmString));
  nsCOMPtr<nsIDOMWindowInternal> parentWindow;
  nsCOMPtr<nsIPromptService> promptService =
      do_GetService(NS_PROMPTSERVICE_CONTRACTID);
  nsCOMPtr<nsIDocShell> docShell;
  if (msgWindow)
  {
    (void) msgWindow->GetRootDocShell(getter_AddRefs(docShell));
    parentWindow = do_QueryInterface(docShell);
  }
  if (promptService && confirmString)
  {
    PRInt32 dlgResult  = -1;
    rv = promptService->ConfirmEx(parentWindow, nsnull, confirmString,
                      (nsIPromptService::BUTTON_TITLE_YES * 
                      nsIPromptService::BUTTON_POS_0) +
                      (nsIPromptService::BUTTON_TITLE_NO * 
                      nsIPromptService::BUTTON_POS_1),
                      nsnull,
                      nsnull,
                      nsnull,
                      nsnull,
                      nsnull,
                      &dlgResult);
    m_newMailParser->m_newMsgHdr = nsnull;

    return (dlgResult == 0) ? NS_OK : NS_MSG_ERROR_COPYING_FROM_TMP_DOWNLOAD;
  }
  return rv;
}

Here is the call graph for this function:

void nsIPop3Sink::IncorporateAbort ( in boolean  uidlDownload) [inherited]
voidPtr nsIPop3Sink::IncorporateBegin ( in string  uidlString,
in nsIURI  aURL,
in unsigned long  flags 
) [inherited]
void nsIPop3Sink::IncorporateComplete ( in nsIMsgWindow  aMsgWindow,
in PRInt32  aSize 
) [inherited]
void nsIPop3Sink::IncorporateWrite ( in string  block,
in long  length 
) [inherited]

Definition at line 507 of file nsPop3Sink.cpp.

{
  nsresult result = NS_OK;
  if (!m_folder) 
    return result;
  PRBool haveSemaphore;
  nsCOMPtr <nsISupports> supports = do_QueryInterface(NS_STATIC_CAST(nsIPop3Sink*, this));
  result = m_folder->TestSemaphore(supports, &haveSemaphore);
  if(NS_SUCCEEDED(result) && haveSemaphore)
    result = m_folder->ReleaseSemaphore(supports);
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIPop3Sink::SetBiffStateAndUpdateFE ( in unsigned long  biffState,
in long  numNewMessages,
in boolean  notify 
) [inherited]
void nsIPop3Sink::SetSenderAuthedFlag ( in voidPtr  closure,
in boolean  authed 
) [inherited]
nsresult nsPop3Sink::WriteLineToMailbox ( const char *  buffer) [protected]

Definition at line 706 of file nsPop3Sink.cpp.

{
  
  if (buffer)
  {
    PRInt32 bufferLen = PL_strlen(buffer);
    if (m_newMailParser) // HandleLine should really take a const char *...
      m_newMailParser->HandleLine((char *) buffer, bufferLen);
    // The following (!m_outFileStream etc) was added to make sure that we don't write somewhere 
    // where for some reason or another we can't write to and lose the messages
    // See bug 62480
    if (!m_outFileStream)
      return NS_ERROR_OUT_OF_MEMORY;
    
    NS_ASSERTION(m_outFileStream->eof(), "we are not writing to end-of-file");
    
    if (!m_outFileStream->eof())
      m_outFileStream->seek(PR_SEEK_END, 0);
    PRInt32 bytes = m_outFileStream->write(buffer,bufferLen);
    if (bytes != bufferLen) return NS_ERROR_FAILURE;
  }
  return NS_OK;
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 51 of file nsIPop3Sink.idl.

Definition at line 49 of file nsIPop3Sink.idl.

Definition at line 74 of file nsIPop3Sink.idl.

Definition at line 97 of file nsPop3Sink.h.

char* nsPop3Sink::m_accountUrl [protected]

Definition at line 77 of file nsPop3Sink.h.

Definition at line 75 of file nsPop3Sink.h.

Definition at line 96 of file nsPop3Sink.h.

Definition at line 78 of file nsPop3Sink.h.

Definition at line 92 of file nsPop3Sink.h.

Definition at line 93 of file nsPop3Sink.h.

Definition at line 86 of file nsPop3Sink.h.

Definition at line 95 of file nsPop3Sink.h.

Definition at line 76 of file nsPop3Sink.h.

Definition at line 87 of file nsPop3Sink.h.

Definition at line 79 of file nsPop3Sink.h.

Definition at line 80 of file nsPop3Sink.h.

Definition at line 91 of file nsPop3Sink.h.

char* nsPop3Sink::m_outputBuffer [protected]

Definition at line 82 of file nsPop3Sink.h.

Definition at line 83 of file nsPop3Sink.h.

Definition at line 98 of file nsPop3Sink.h.

Definition at line 84 of file nsPop3Sink.h.

Definition at line 81 of file nsPop3Sink.h.

Definition at line 94 of file nsPop3Sink.h.

Definition at line 48 of file nsIPop3Sink.idl.

Definition at line 50 of file nsIPop3Sink.idl.

Definition at line 73 of file nsIPop3Sink.idl.

Definition at line 47 of file nsIPop3Sink.idl.


The documentation for this class was generated from the following files: