Back to index

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

#include <nsMsgMailViewList.h>

Inheritance diagram for nsMsgMailViewList:
Inheritance graph
Collaboration diagram for nsMsgMailViewList:
Collaboration graph

List of all members.

Public Member Functions

nsMsgMailViewList ()
virtual ~nsMsgMailViewList ()
nsIMsgMailView getMailViewAt (in unsigned long mailViewIndex)
void addMailView (in nsIMsgMailView mailView)
void removeMailView (in nsIMsgMailView mailView)
nsIMsgMailView createMailView ()
void save ()

Public Attributes

readonly attribute unsigned long mailViewCount

Protected Member Functions

nsresult LoadMailViews ()
nsresult ConvertFilterListToMailView (nsIMsgFilterList *aFilterList, nsISupportsArray **aMailViewList)
nsresult ConvertMailViewListToFilterList ()

Protected Attributes

nsCOMPtr< nsISupportsArraym_mailViews
nsCOMPtr< nsIMsgFilterListmFilterList

Detailed Description

Definition at line 68 of file nsMsgMailViewList.h.

Constructor & Destructor Documentation

Definition at line 144 of file nsMsgMailViewList.cpp.

Here is the call graph for this function:

Definition at line 153 of file nsMsgMailViewList.cpp.



Member Function Documentation

nsresult nsMsgMailViewList::ConvertFilterListToMailView ( nsIMsgFilterList aFilterList,
nsISupportsArray **  aMailViewList 
) [protected]

Definition at line 304 of file nsMsgMailViewList.cpp.

    nsresult rv = NS_OK;

    nsCOMPtr<nsISupportsArray> mailViewList;

    // iterate over each filter in the list
    nsCOMPtr<nsIMsgFilter> msgFilter;
    PRUint32 numFilters;
    for (PRUint32 index = 0; index < numFilters; index++)
        aFilterList->GetFilterAt(index, getter_AddRefs(msgFilter));
        if (!msgFilter)
        // create a new nsIMsgMailView for this item
        nsCOMPtr<nsIMsgMailView> newMailView; 
        rv = CreateMailView(getter_AddRefs(newMailView));
        NS_ENSURE_SUCCESS(rv, rv);
        nsXPIDLString filterName;

        nsCOMPtr<nsISupportsArray> filterSearchTerms;

        // now append this new mail view to our global list view
        mailViewList->AppendElement(NS_STATIC_CAST(nsISupports*, newMailView));

    NS_IF_ADDREF(*aMailViewList = mailViewList);

    return rv;

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 226 of file nsMsgMailViewList.cpp.

  PRUint32 mailViewCount = 0;
  nsCOMPtr<nsIMsgMailView> mailView;
  nsCOMPtr<nsIMsgFilter> newMailFilter;
  nsXPIDLString mailViewName;
  for (PRUint32 index = 0; index < mailViewCount; index++)
      GetMailViewAt(index, getter_AddRefs(mailView));
      if (!mailView)
      mFilterList->CreateFilter(mailViewName, getter_AddRefs(newMailFilter));
      if (!newMailFilter)

      nsCOMPtr<nsISupportsArray> searchTerms;
      mFilterList->InsertFilterAt(index, newMailFilter);

  return NS_OK;

Here is the call graph for this function:

nsIMsgMailView nsIMsgMailViewList::getMailViewAt ( in unsigned long  mailViewIndex) [inherited]

Definition at line 252 of file nsMsgMailViewList.cpp.

    nsCOMPtr<nsIFile> file;
    nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(file));
    NS_ENSURE_SUCCESS(rv, rv);

    rv = file->AppendNative(nsDependentCString("mailViews.dat"));

    // if the file doesn't exist, we should try to get it from the defaults directory and copy it over
    PRBool exists = PR_FALSE;
    if (!exists)
        nsCOMPtr<nsIMsgMailSession> mailSession = do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
        NS_ENSURE_SUCCESS(rv, rv);
        nsCOMPtr<nsIFile> defaultMessagesFile;
        rv = mailSession->GetDataFilesDir("messenger", getter_AddRefs(defaultMessagesFile));
        rv = defaultMessagesFile->AppendNative(nsDependentCString("mailViews.dat"));

        nsCOMPtr<nsIFileSpec> defaultMailViewSpec;
        rv = NS_NewFileSpecFromIFile(defaultMessagesFile, getter_AddRefs(defaultMailViewSpec));
        // get the profile directory
        rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(defaultMessagesFile));
        // convert to spec
        nsCOMPtr<nsIFileSpec> profileDirSpec;
        rv = NS_NewFileSpecFromIFile(defaultMessagesFile, getter_AddRefs(profileDirSpec));
        // now copy the file over to the profile directory

    nsCOMPtr<nsIFileSpec> mailViewSpec;
    rv = NS_NewFileSpecFromIFile(file, getter_AddRefs(mailViewSpec));
    if (NS_FAILED(rv)) return rv;

    // this is kind of a hack but I think it will be an effective hack. The filter service already knows how to 
    // take a nsIFileSpec and parse the contents into filters which are very similar to mail views. Intead of
    // re-writing all of that dirty parsing code, let's just re-use it then convert the results into a data strcuture
    // we wish to give to our consumers. 
    nsCOMPtr<nsIMsgFilterService> filterService = do_GetService(NS_MSGFILTERSERVICE_CONTRACTID, &rv);
    nsCOMPtr<nsIMsgFilterList> mfilterList;
    rv = filterService->OpenFilterList(mailViewSpec, NULL, NULL, getter_AddRefs(mFilterList));
    NS_ENSURE_SUCCESS(rv, rv);

    // now convert the filter list into our mail view objects, stripping out just the info we need
    ConvertFilterListToMailView(mFilterList, getter_AddRefs(m_mailViews));
    return rv;

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIMsgMailViewList::save ( ) [inherited]

Member Data Documentation

Definition at line 82 of file nsMsgMailViewList.h.

readonly attribute unsigned long nsIMsgMailViewList::mailViewCount [inherited]

Definition at line 51 of file nsIMsgMailViewList.idl.

Definition at line 83 of file nsMsgMailViewList.h.

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