Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends
nsMsgXFGroupThread Class Reference

#include <nsMsgGroupThread.h>

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

List of all members.

Public Member Functions

 nsMsgXFGroupThread ()
virtual ~nsMsgXFGroupThread ()
NS_IMETHOD GetNumChildren (PRUint32 *aNumChildren)
NS_IMETHOD GetChildKeyAt (PRInt32 aIndex, nsMsgKey *aResult)
void AddChild (in nsIMsgDBHdr child, in nsIMsgDBHdr inReplyTo, in boolean threadInThread, in nsIDBChangeAnnouncer announcer)
nsIMsgDBHdr GetChildAt (in long index)
nsMsgKey GetChildKeyAt (in long index)
nsIMsgDBHdr GetChild (in nsMsgKey msgKey)
nsIMsgDBHdr GetChildHdrAt (in long index)
nsIMsgDBHdr GetRootHdr (out long index)
void RemoveChildAt (in long index)
void RemoveChildHdr (in nsIMsgDBHdr child, in nsIDBChangeAnnouncer announcer)
void MarkChildRead (in boolean bRead)
nsIMsgDBHdr GetFirstUnreadChild ()
nsISimpleEnumerator EnumerateMessages (in nsMsgKey parent)

Public Attributes

attribute nsMsgKey threadKey
attribute unsigned long flags
attribute string subject
attribute unsigned long newestMsgDate
readonly attribute unsigned long numChildren
readonly attribute unsigned long numUnreadChildren

Protected Member Functions

void Init ()
nsresult AddChildFromGroupView (nsIMsgDBHdr *child, nsMsgDBView *view)
nsresult RemoveChild (nsMsgKey msgKey)
nsresult RerootThread (nsIMsgDBHdr *newParentOfOldRoot, nsIMsgDBHdr *oldRoot, nsIDBChangeAnnouncer *announcer)
nsresult AddMsgHdrInDateOrder (nsIMsgDBHdr *child, nsMsgDBView *view)
nsresult ReparentNonReferenceChildrenOf (nsIMsgDBHdr *topLevelHdr, nsMsgKey newParentKey, nsIDBChangeAnnouncer *announcer)
nsresult ReparentChildrenOf (nsMsgKey oldParent, nsMsgKey newParent, nsIDBChangeAnnouncer *announcer)
nsresult ChangeUnreadChildCount (PRInt32 delta)
nsresult GetChildHdrForKey (nsMsgKey desiredKey, nsIMsgDBHdr **result, PRInt32 *resultIndex)
PRUint32 NumRealChildren ()

Protected Attributes

nsCOMArray< nsIMsgDBHdrm_hdrs
nsMsgKey m_threadKey
PRUint32 m_numUnreadChildren
PRUint32 m_flags
nsMsgKey m_threadRootKey
PRUint32 m_newestMsgDate
nsMsgKeyArray m_keys
PRBool m_dummy
nsCOMPtr< nsIMsgDatabasem_db

Friends

class nsMsgGroupView

Detailed Description

Definition at line 86 of file nsMsgGroupThread.h.


Constructor & Destructor Documentation

Definition at line 844 of file nsMsgGroupThread.cpp.

{
}

Definition at line 848 of file nsMsgGroupThread.cpp.

{
}

Member Function Documentation

void nsIMsgThread::AddChild ( in nsIMsgDBHdr  child,
in nsIMsgDBHdr  inReplyTo,
in boolean  threadInThread,
in nsIDBChangeAnnouncer  announcer 
) [inherited]

Here is the caller graph for this function:

nsresult nsMsgGroupThread::AddChildFromGroupView ( nsIMsgDBHdr child,
nsMsgDBView view 
) [protected, inherited]

Definition at line 199 of file nsMsgGroupThread.cpp.

{
  PRUint32 newHdrFlags = 0;
  PRUint32 msgDate;
  nsMsgKey newHdrKey = 0;
  
  child->GetFlags(&newHdrFlags);
  child->GetMessageKey(&newHdrKey);
  child->GetDateInSeconds(&msgDate);
  if (msgDate > m_newestMsgDate)
    SetNewestMsgDate(msgDate);

  child->AndFlags(~(MSG_FLAG_WATCHED | MSG_FLAG_IGNORED), &newHdrFlags);
  PRUint32 numChildren;
  
  // get the num children before we add the new header.
  GetNumChildren(&numChildren);
  
  // if this is an empty thread, set the root key to this header's key
  if (numChildren == 0)
    m_threadRootKey = newHdrKey;
  
  if (! (newHdrFlags & MSG_FLAG_READ))
    ChangeUnreadChildCount(1);

  return AddMsgHdrInDateOrder(child, view);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgGroupThread::AddMsgHdrInDateOrder ( nsIMsgDBHdr child,
nsMsgDBView view 
) [protected, inherited]

Definition at line 172 of file nsMsgGroupThread.cpp.

{
  nsresult ret = NS_OK;
  nsMsgKey newHdrKey;
  child->GetMessageKey(&newHdrKey);
  PRUint32 insertIndex = 0;
  // since we're sorted by date, we could do a binary search for the 
  // insert point. Or, we could start at the end...
  if (m_keys.GetSize() > 0)
  {
    nsMsgViewSortTypeValue  sortType;
    nsMsgViewSortOrderValue sortOrder;
    (void) view->GetSortType(&sortType);
    (void) view->GetSortOrder(&sortOrder);
    nsMsgViewSortOrderValue threadSortOrder = 
      (sortType == nsMsgViewSortType::byDate
        && sortOrder == nsMsgViewSortOrder::descending) ? 
          nsMsgViewSortOrder::descending : nsMsgViewSortOrder::ascending;
    // sort by date within group
    insertIndex = view->GetInsertIndexHelper(child, &m_keys, threadSortOrder, nsMsgViewSortType::byDate);
  }
  m_keys.InsertAt(insertIndex, newHdrKey);
  if (!insertIndex)
    m_threadRootKey = newHdrKey;
  return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgGroupThread::ChangeUnreadChildCount ( PRInt32  delta) [protected, inherited]

Definition at line 730 of file nsMsgGroupThread.cpp.

Here is the caller graph for this function:

Here is the caller graph for this function:

nsIMsgDBHdr nsIMsgThread::GetChild ( in nsMsgKey  msgKey) [inherited]

Here is the caller graph for this function:

nsIMsgDBHdr nsIMsgThread::GetChildAt ( in long  index) [inherited]

Here is the caller graph for this function:

nsresult nsMsgGroupThread::GetChildHdrForKey ( nsMsgKey  desiredKey,
nsIMsgDBHdr **  result,
PRInt32 resultIndex 
) [protected, inherited]

Definition at line 736 of file nsMsgGroupThread.cpp.

{
  PRUint32 numChildren;
  PRUint32 childIndex = 0;
  nsresult rv = NS_OK;        // XXX or should this default to an error?
  
  if (!result)
    return NS_ERROR_NULL_POINTER;
  
  GetNumChildren(&numChildren);
  
  if ((PRInt32) numChildren < 0)
    numChildren = 0;
  
  for (childIndex = 0; childIndex < numChildren; childIndex++)
  {
    rv = GetChildHdrAt(childIndex, result);
    if (NS_SUCCEEDED(rv) && *result)
    {
      nsMsgKey msgKey;
      // we're only doing one level of threading, so check if caller is
      // asking for children of the first message in the thread or not.
      // if not, we will tell him there are no children.
      (*result)->GetMessageKey(&msgKey);
      
      if (msgKey == desiredKey)
        break;
      NS_RELEASE(*result);
    }
  }
  if (resultIndex)
    *resultIndex = childIndex;
  
  return rv;
}

Here is the call graph for this function:

nsMsgKey nsIMsgThread::GetChildKeyAt ( in long  index) [inherited]

Here is the caller graph for this function:

Definition at line 859 of file nsMsgGroupThread.cpp.

{
  NS_ASSERTION(PR_FALSE, "shouldn't call this");
  return NS_ERROR_NOT_IMPLEMENTED;
}

Here is the caller graph for this function:

Definition at line 852 of file nsMsgGroupThread.cpp.

{
  NS_ENSURE_ARG_POINTER(aNumChildren);
  *aNumChildren = m_hdrs.Count();
  return NS_OK;
}

Here is the call graph for this function:

nsIMsgDBHdr nsIMsgThread::GetRootHdr ( out long  index) [inherited]

Here is the caller graph for this function:

void nsMsgGroupThread::Init ( void  ) [protected, inherited]

Definition at line 55 of file nsMsgGroupThread.cpp.

Here is the caller graph for this function:

void nsIMsgThread::MarkChildRead ( in boolean  bRead) [inherited]
PRUint32 nsMsgGroupThread::NumRealChildren ( ) [protected, inherited]

Definition at line 118 of file nsMsgGroupThread.cpp.

{
  return m_keys.GetSize() - ((m_dummy) ? 1 : 0);
}

Here is the caller graph for this function:

nsresult nsMsgGroupThread::RemoveChild ( nsMsgKey  msgKey) [protected, inherited]

Definition at line 299 of file nsMsgGroupThread.cpp.

{
  PRUint32 childIndex = m_keys.IndexOf(msgKey);
  if (childIndex != kNotFound)
    m_keys.RemoveAt(childIndex);
  return NS_OK;
}
void nsIMsgThread::RemoveChildAt ( in long  index) [inherited]

Here is the caller graph for this function:

void nsIMsgThread::RemoveChildHdr ( in nsIMsgDBHdr  child,
in nsIDBChangeAnnouncer  announcer 
) [inherited]
nsresult nsMsgGroupThread::ReparentChildrenOf ( nsMsgKey  oldParent,
nsMsgKey  newParent,
nsIDBChangeAnnouncer announcer 
) [protected, inherited]

Definition at line 340 of file nsMsgGroupThread.cpp.

{
  nsresult rv = NS_OK;
  
  PRUint32 numChildren;
  PRUint32 childIndex = 0;
  
  GetNumChildren(&numChildren);
  
  nsCOMPtr <nsIMsgDBHdr> curHdr;
  if (numChildren > 0)
  {
    for (childIndex = 0; childIndex < numChildren; childIndex++)
    {
      rv = GetChildHdrAt(childIndex, getter_AddRefs(curHdr));
      if (NS_SUCCEEDED(rv) && curHdr)
      {
        nsMsgKey threadParent;
        
        curHdr->GetThreadParent(&threadParent);
        if (threadParent == oldParent)
        {
          nsMsgKey curKey;
          
          curHdr->SetThreadParent(newParent);
          curHdr->GetMessageKey(&curKey);
          if (announcer)
            announcer->NotifyParentChangedAll(curKey, oldParent, newParent, nsnull);
          // if the old parent was the root of the thread, then only the first child gets 
          // promoted to root, and other children become children of the new root.
          if (newParent == nsMsgKey_None)
          {
            m_threadRootKey = curKey;
            newParent = curKey;
          }
        }
      }
    }
  }
  return rv;
}

Here is the call graph for this function:

nsresult nsMsgGroupThread::ReparentNonReferenceChildrenOf ( nsIMsgDBHdr topLevelHdr,
nsMsgKey  newParentKey,
nsIDBChangeAnnouncer announcer 
) [protected, inherited]

Definition at line 227 of file nsMsgGroupThread.cpp.

{
#if 0
  nsCOMPtr <nsIMsgDBHdr> curHdr;
  PRUint32 numChildren;
  PRUint32 childIndex = 0;
  
  GetNumChildren(&numChildren);
  for (childIndex = 0; childIndex < numChildren; childIndex++)
  {
    nsMsgKey msgKey;
    
    topLevelHdr->GetMessageKey(&msgKey);
    nsresult ret = GetChildHdrAt(childIndex, getter_AddRefs(curHdr));
    if (NS_SUCCEEDED(ret) && curHdr)
    {
      nsMsgKey oldThreadParent, curHdrKey;
      nsIMsgDBHdr *curMsgHdr = curHdr;
      curHdr->GetThreadParent(&oldThreadParent);
      curHdr->GetMessageKey(&curHdrKey);
      if (oldThreadParent == msgKey && curHdrKey != newParentKey && topLevelMsgHdr->IsParentOf(curHdr))
      {
        curHdr->GetThreadParent(&oldThreadParent);
        curHdr->SetThreadParent(newParentKey);
        // OK, this is a reparenting - need to send notification
        if (announcer)
          announcer->NotifyParentChangedAll(curHdrKey, oldThreadParent, newParentKey, nsnull);
      }
    }
  }
#endif
  return NS_OK;
}

Here is the call graph for this function:

nsresult nsMsgGroupThread::RerootThread ( nsIMsgDBHdr newParentOfOldRoot,
nsIMsgDBHdr oldRoot,
nsIDBChangeAnnouncer announcer 
) [protected, inherited]

Friends And Related Function Documentation

friend class nsMsgGroupView [friend, inherited]

Definition at line 52 of file nsMsgGroupThread.h.


Member Data Documentation

attribute unsigned long nsIMsgThread::flags [inherited]

Definition at line 49 of file nsIMsgThread.idl.

Definition at line 83 of file nsMsgGroupThread.h.

PRBool nsMsgGroupThread::m_dummy [protected, inherited]

Definition at line 82 of file nsMsgGroupThread.h.

PRUint32 nsMsgGroupThread::m_flags [protected, inherited]

Definition at line 78 of file nsMsgGroupThread.h.

Definition at line 95 of file nsMsgGroupThread.h.

nsMsgKeyArray nsMsgGroupThread::m_keys [protected, inherited]

Definition at line 81 of file nsMsgGroupThread.h.

Definition at line 80 of file nsMsgGroupThread.h.

Definition at line 77 of file nsMsgGroupThread.h.

nsMsgKey nsMsgGroupThread::m_threadKey [protected, inherited]

Definition at line 76 of file nsMsgGroupThread.h.

Definition at line 79 of file nsMsgGroupThread.h.

Definition at line 51 of file nsIMsgThread.idl.

readonly attribute unsigned long nsIMsgThread::numChildren [inherited]

Definition at line 52 of file nsIMsgThread.idl.

readonly attribute unsigned long nsIMsgThread::numUnreadChildren [inherited]

Definition at line 53 of file nsIMsgThread.idl.

Definition at line 50 of file nsIMsgThread.idl.

Definition at line 48 of file nsIMsgThread.idl.


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