Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Static Private Member Functions
nsAttachmentState Class Reference
Collaboration diagram for nsAttachmentState:
Collaboration graph

List of all members.

Public Member Functions

 nsAttachmentState ()
 ~nsAttachmentState ()
nsresult Init (PRUint32 aCount, const char **aContentTypeArray, const char **aUrlArray, const char **aDisplayNameArray, const char **aMessageUriArray)
nsresult PrepareForAttachmentDelete ()

Public Attributes

PRUint32 mCount
PRUint32 mCurIndex

Static Private Member Functions

static int SortAttachmentsByPartId (const void *aLeft, const void *aRight, void *)

Detailed Description

Definition at line 2621 of file nsMessenger.cpp.

Constructor & Destructor Documentation

Definition at line 2642 of file nsMessenger.cpp.

Definition at line 2649 of file nsMessenger.cpp.

  delete[] mAttachmentArray;

Member Function Documentation

nsresult nsAttachmentState::Init ( PRUint32  aCount,
const char **  aContentTypeArray,
const char **  aUrlArray,
const char **  aDisplayNameArray,
const char **  aMessageUriArray 

Definition at line 2655 of file nsMessenger.cpp.

  NS_ABORT_IF_FALSE(aCount > 0, "count is invalid");

  mCount = aCount;
  mCurIndex = 0;
  delete[] mAttachmentArray;

  mAttachmentArray = new msgAttachment[aCount];
  if (!mAttachmentArray) 

  for(PRUint32 u = 0; u < aCount; ++u)
    if (!mAttachmentArray[u].Init(aContentTypeArray[u], aUrlArray[u], 
      aDisplayNameArray[u], aMessageUriArray[u]))
      return NS_ERROR_OUT_OF_MEMORY;

  return NS_OK;

Here is the caller graph for this function:

Definition at line 2680 of file nsMessenger.cpp.

  // this must be called before any processing
  if (mCurIndex != 0)
    return NS_ERROR_FAILURE;

  // this prepares the attachment list for use in deletion. In order to prepare, we
  // sort the attachments in numerical ascending order on their part id, remove all
  // duplicates and remove any subparts which will be removed automatically by the
  // removal of the parent.
  // e.g. the attachment list processing (showing only part ids)
  // before: 1.11, 1.3, 1.2,,
  // sorted: 1.2,, 1.3,, 1.11
  // after:  1.2, 1.3,, 1.11

  // sort
  NS_QuickSort(mAttachmentArray, mCount, sizeof(msgAttachment), SortAttachmentsByPartId, nsnull);

  // remove duplicates and sub-items
  int nCompare;
  for(PRUint32 u = 1; u < mCount;)
    nCompare = ::CompareAttachmentPartId(mAttachmentArray[u-1].mUrl, mAttachmentArray[u].mUrl);
    if (nCompare == 0 || nCompare == -2) // [u-1] is the same as or a parent of [u]
      // shuffle the array down (and thus keeping the sorted order)
      // this will get rid of the current unnecessary element
      for (PRUint32 i = u + 1; i < mCount; ++i)

  return NS_OK;

Here is the call graph for this function:

Here is the caller graph for this function:

int nsAttachmentState::SortAttachmentsByPartId ( const void aLeft,
const void aRight,
) [static, private]

Definition at line 2724 of file nsMessenger.cpp.

  msgAttachment & attachLeft  = *((msgAttachment*) aLeft);
  msgAttachment & attachRight = *((msgAttachment*) aRight);
  return ::CompareAttachmentPartId(attachLeft.mUrl, attachRight.mUrl);

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

Definition at line 2639 of file nsMessenger.cpp.

Definition at line 2637 of file nsMessenger.cpp.

Definition at line 2638 of file nsMessenger.cpp.

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