Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Member Functions | Private Attributes
nsComm4xMail Class Reference

#include <nsComm4xMail.h>

List of all members.

Public Member Functions

 nsComm4xMail ()
virtual ~nsComm4xMail ()
virtual nsresult FindMailboxes (nsIFileSpec *pRoot, nsISupportsArray **ppArray)

Private Member Functions

nsresult ScanMailDir (nsIFileSpec *pFolder, nsISupportsArray *pArray, nsIImportService *pImport)
nsresult IterateMailDir (nsIFileSpec *pFolder, nsISupportsArray *pArray, nsIImportService *pImport)
nsresult FoundMailbox (nsIFileSpec *mailFile, nsAutoString *pName, nsISupportsArray *pArray, nsIImportService *pImport)

Private Attributes

PRUint32 m_depth

Detailed Description

Definition at line 50 of file nsComm4xMail.h.


Constructor & Destructor Documentation

Definition at line 99 of file nsComm4xMail.cpp.

{
}

Definition at line 103 of file nsComm4xMail.cpp.

{
}

Member Function Documentation

nsresult nsComm4xMail::FindMailboxes ( nsIFileSpec pRoot,
nsISupportsArray **  ppArray 
) [virtual]

Definition at line 107 of file nsComm4xMail.cpp.

{
    nsresult rv = NS_NewISupportsArray(ppArray);
    if (NS_FAILED(rv)) {
        IMPORT_LOG0("FAILED to allocate the nsISupportsArray\n");
        return rv;
    }
        
    nsCOMPtr<nsIImportService> impSvc(do_GetService(NS_IMPORTSERVICE_CONTRACTID, &rv));
    if (NS_FAILED(rv))
        return rv;
    
    m_depth = 0;

    return (ScanMailDir(pRoot, *ppArray, impSvc));
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsComm4xMail::FoundMailbox ( nsIFileSpec mailFile,
nsAutoString pName,
nsISupportsArray pArray,
nsIImportService pImport 
) [private]

Definition at line 206 of file nsComm4xMail.cpp.

{
    nsCOMPtr<nsIImportMailboxDescriptor>    desc;

    nsXPIDLCString pPath;
    mailFile->GetNativePath(getter_Copies(pPath));
    if (!pPath.IsEmpty())
      IMPORT_LOG2("Found comm4x mailbox: %s, m_depth = %d\n", pPath.get(), m_depth);
    else
      IMPORT_LOG2("Can't get native path but found comm4x mailbox: %s, m_depth = %d\n", NS_ConvertUTF16toUTF8(*pName).get(), m_depth);

    nsresult rv = pImport->CreateNewMailboxDescriptor(getter_AddRefs(desc));
    if (NS_SUCCEEDED(rv)) {
        PRUint32        sz = 0;
        mailFile->GetFileSize(&sz);    
        desc->SetDisplayName(pName->get());
        desc->SetDepth(m_depth);
        desc->SetSize(sz);
        nsCOMPtr <nsIFileSpec> pSpec;
        desc->GetFileSpec(getter_AddRefs(pSpec));
        if (pSpec) {
            pSpec->FromFileSpec(mailFile);
        }
        nsCOMPtr <nsISupports> pInterface = do_QueryInterface(desc);
        if (pInterface)
            pArray->AppendElement(pInterface);
    }
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsComm4xMail::IterateMailDir ( nsIFileSpec pFolder,
nsISupportsArray pArray,
nsIImportService pImport 
) [private]

Definition at line 144 of file nsComm4xMail.cpp.

{
    nsCOMPtr<nsIDirectoryIterator>    dir;
    nsresult rv = NS_NewDirectoryIterator(getter_AddRefs(dir));
    if (NS_FAILED(rv))
        return rv;

    PRBool    exists = PR_FALSE;
    rv = dir->Init(pFolder, PR_TRUE);
    if (NS_FAILED(rv))
        return rv;

    rv = dir->Exists(&exists);
    if (NS_FAILED(rv))
        return rv;
    
    PRBool                    isFile;
    nsCOMPtr<nsIFileSpec>    entry;
    nsXPIDLCString                    pName;
    nsXPIDLCString                 dirName;
    nsAutoString currentFolderNameStr;
    PRBool                    isDirectory;
    nsAutoString ext;

    while (exists && NS_SUCCEEDED(rv)) {
        rv = dir->GetCurrentSpec(getter_AddRefs(entry));
        if (NS_SUCCEEDED(rv)) {
            rv = entry->GetLeafName(getter_Copies(pName));
            NS_CopyNativeToUnicode(pName, currentFolderNameStr);
            isFile = PR_FALSE;
            entry->IsFile(&isFile);
            if (isFile) {
                if (!nsShouldIgnoreFile(currentFolderNameStr)) {
                    rv = FoundMailbox(entry, &currentFolderNameStr, pArray, pImport);
                    if (NS_FAILED(rv))
                        return rv;
                    entry->GetNativePath(getter_Copies(dirName));
                    dirName.Append(".sbd");
                    rv = entry->SetNativePath(dirName.get());
                    if (NS_FAILED(rv))
                        return rv;
                    exists = PR_FALSE;
                    entry->Exists(&exists);
                    isDirectory = PR_FALSE;
                    entry->IsDirectory(&isDirectory);
                    if (exists && isDirectory) {
                        rv = ScanMailDir (entry, pArray, pImport);
                        if (NS_FAILED(rv))
                            return rv;
                    }

                }
            }
        }
        rv = dir->Next();
        if (NS_SUCCEEDED(rv))
            rv = dir->Exists(&exists);
    }

    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsComm4xMail::ScanMailDir ( nsIFileSpec pFolder,
nsISupportsArray pArray,
nsIImportService pImport 
) [private]

Definition at line 125 of file nsComm4xMail.cpp.

{
    
    nsCOMPtr<nsIFileSpec>    descMap;
    nsresult                rv;

    if (NS_FAILED(rv = NS_NewFileSpec(getter_AddRefs(descMap))))
        return rv;

    m_depth++;

    descMap->FromFileSpec(pFolder);
    rv = IterateMailDir(pFolder, pArray, pImport);
    
    m_depth--;

    return rv;            
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 64 of file nsComm4xMail.h.


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