Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Member Functions | Events | Private Member Functions | Private Attributes
nsMessenger Class Reference

#include <nsMessenger.h>

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

List of all members.

Public Member Functions

 nsMessenger ()
virtual ~nsMessenger ()
NS_DECL_ISUPPORTS
NS_DECL_NSIMESSENGER
NS_DECL_NSIOBSERVER
NS_DECL_NSIFOLDERLISTENER
nsresult 
Alert (const char *stringName)
nsresult SaveAttachment (nsIFileSpec *fileSpec, const char *unescapedUrl, const char *messageUri, const char *contentType, void *closure)
nsresult PromptIfFileExists (nsFileSpec &fileSpec)
nsresult DetachAttachments (PRUint32 aCount, const char **aContentTypeArray, const char **aUrlArray, const char **aDisplayNameArray, const char **aMessageUriArray, nsCStringArray *saveFileUris)
nsresult SaveAllAttachments (PRUint32 count, const char **contentTypeArray, const char **urlArray, const char **displayNameArray, const char **messageUriArray, PRBool detaching)
void setDisplayCharset (in string aCharset)
void SetWindow (in nsIDOMWindowInternal ptr, in nsIMsgWindow msgWindow)
void DeleteFolders (in nsIRDFCompositeDataSource db, in nsIRDFResource parentFolder, in nsIRDFResource folder)
void CopyMessages (in nsIRDFCompositeDataSource database, in nsIRDFResource srcResource, in nsIRDFResource dstResource, in nsISupportsArray messages, in boolean isMove)
void CopyFolders (in nsIRDFCompositeDataSource database, in nsIRDFResource dstResource, in nsISupportsArray folders, in boolean isMoveFolder)
void OpenURL (in string aURL)
void loadURL (in nsIDOMWindowInternal ptr, in string aURL)
 load a custom message by url, e.g load a attachment as a email
void launchExternalURL (in string aURL)
void RenameFolder (in nsIRDFCompositeDataSource db, in nsIRDFResource folder, in wstring name)
void CompactFolder (in nsIRDFCompositeDataSource db, in nsIRDFResource folder, in boolean forAll)
void EmptyTrash (in nsIRDFCompositeDataSource db, in nsIRDFResource folder)
boolean CanUndo ()
boolean CanRedo ()
unsigned long GetUndoTransactionType ()
unsigned long GetRedoTransactionType ()
void Undo (in nsIMsgWindow msgWindow)
void Redo (in nsIMsgWindow msgWindow)
void sendUnsentMessages (in nsIMsgIdentity aIdentity, in nsIMsgWindow aMsgWindow)
void SetDocumentCharset (in string characterSet)
void saveAs (in string aURI, in boolean aAsFile, in nsIMsgIdentity aIdentity, in wstring aMsgFilename)
void openAttachment (in string contentTpe, in string url, in string displayName, in string messageUri, in boolean isExternalAttachment)
void saveAttachment (in string contentTpe, in string url, in string displayName, in string messageUri, in boolean isExternalAttachment)
void saveAllAttachments (in unsigned long count,[array, size_is(count)] in string contentTypeArray,[array, size_is(count)] in string urlArray,[array, size_is(count)] in string displayNameArray,[array, size_is(count)] in string messageUriArray)
void detachAttachment (in string contentTpe, in string url, in string displayName, in string messageUri, in boolean saveFirst)
void detachAllAttachments (in unsigned long count,[array, size_is(count)] in string contentTypeArray,[array, size_is(count)] in string urlArray,[array, size_is(count)] in string displayNameArray,[array, size_is(count)] in string messageUriArray, in boolean saveFirst)
nsILocalFile saveAttachmentToFolder (in string contentType, in string url, in string displayName, in string messageUri, in nsILocalFile aDestFolder)
nsIMsgMessageService messageServiceFromURI (in string aUri)
nsIMsgDBHdr msgHdrFromURI (in string aUri)
string getMsgUriAtNavigatePos (in long aPos)
string getFolderUriAtNavigatePos (in long aPos)
void getNavigateHistory (out unsigned long aCurPos, out unsigned long aCount,[array, size_is(aCount)] out string aHistory)
void observe (in nsISupports aSubject, in string aTopic, in wstring aData)
 Observe will be called when there is a notification for the topic |aTopic|.
void OnItemAdded (in nsIRDFResource parentItem, in nsISupports item)
void OnItemRemoved (in nsIRDFResource parentItem, in nsISupports item)
void OnItemPropertyChanged (in nsIRDFResource item, in nsIAtom property, in string oldValue, in string newValue)
void OnItemIntPropertyChanged (in nsIRDFResource item, in nsIAtom property, in long oldValue, in long newValue)
void OnItemBoolPropertyChanged (in nsIRDFResource item, in nsIAtom property, in boolean oldValue, in boolean newValue)
void OnItemUnicharPropertyChanged (in nsIRDFResource item, in nsIAtom property, in wstring oldValue, in wstring newValue)
void OnItemPropertyFlagChanged (in nsIMsgDBHdr item, in nsIAtom property, in unsigned long oldFlag, in unsigned long newFlag)
void OnItemEvent (in nsIMsgFolder item, in nsIAtom event)

Public Attributes

const long eUnknown = 0
const long eDeleteMsg = 1
const long eMoveMsg = 2
const long eCopyMsg = 3
readonly attribute
nsITransactionManager 
transactionManager
attribute boolean sendingUnsentMsgs
readonly attribute string lastDisplayedMessageUri
attribute long navigatePos
const folderListenerNotifyFlagValue added = 0x1
const folderListenerNotifyFlagValue removed = 0x2
const folderListenerNotifyFlagValue propertyChanged = 0x4
const folderListenerNotifyFlagValue intPropertyChanged = 0x8
const folderListenerNotifyFlagValue boolPropertyChanged = 0x10
const folderListenerNotifyFlagValue unicharPropertyChanged = 0x20
const folderListenerNotifyFlagValue propertyFlagChanged = 0x40

Protected Member Functions

nsresult DoDelete (nsIRDFCompositeDataSource *db, nsISupportsArray *srcArray, nsISupportsArray *deletedArray)
nsresult DoCommand (nsIRDFCompositeDataSource *db, const nsACString &command, nsISupportsArray *srcArray, nsISupportsArray *arguments)
const nsAdoptingString GetString (const nsAFlatString &aStringName)
nsresult InitStringBundle ()
nsresult PromptIfDeleteAttachments (PRBool saveFirst, PRUint32 count, const char **displayNameArray)
void AddMsgUrlToNavigateHistory (const char *aURL)

Events

const
folderListenerNotifyFlagValue=0 
x80
const folderListenerNotifyFlagValue all = 0xFFFFFFFF

Private Member Functions

nsresult GetLastSaveDirectory (nsILocalFile **aLastSaveAsDir)
nsresult SetLastSaveDirectory (nsILocalFile *aLocalFile)
nsresult SetDisplayProperties ()

Private Attributes

nsString mId
voidmScriptObject
nsCOMPtr< nsITransactionManagermTxnMgr
nsCOMPtr< nsIDOMWindowmWindow
nsCOMPtr< nsIMsgWindowmMsgWindow
nsCOMPtr< nsIDocShellmDocShell
nsCOMPtr< nsIStringBundlemStringBundle
nsCString mCurrentDisplayCharset
nsCOMPtr< nsISupports > mSearchContext
nsCString mLastDisplayURI
PRBool mSendingUnsentMsgs
nsCString mNavigatingToUri
nsCStringArray mLoadedMsgHistory
PRInt32 mCurHistoryPos

Detailed Description

Definition at line 53 of file nsMessenger.h.


Constructor & Destructor Documentation

Definition at line 325 of file nsMessenger.cpp.

{
  mScriptObject = nsnull;
  mMsgWindow = nsnull;
  mStringBundle = nsnull;
  mSendingUnsentMsgs = PR_FALSE;
  mCurHistoryPos = -2; // first message selected goes at position 0.
  //   InitializeFolderRoot();
}

Definition at line 335 of file nsMessenger.cpp.

{
    // Release search context.
    mSearchContext = nsnull;
}

Member Function Documentation

void nsMessenger::AddMsgUrlToNavigateHistory ( const char *  aURL) [protected]

Definition at line 580 of file nsMessenger.cpp.

{
  // mNavigatingToUri is set to a url if we're already doing a back/forward,
  // in which case we don't want to add the url to the history list.
  // Or if the entry at the cur history pos is the same as what we're loading, don't
  // add it to the list.
  if (!mNavigatingToUri.Equals(aURL) && (mCurHistoryPos < 0 || !mLoadedMsgHistory[mCurHistoryPos]->Equals(aURL)))
  {
    mNavigatingToUri = aURL;
    nsXPIDLCString curLoadedFolderUri;
    nsCOMPtr <nsIMsgFolder> curLoadedFolder;
    
    mMsgWindow->GetOpenFolder(getter_AddRefs(curLoadedFolder));
    // for virtual folders, we want to select the right folder,
    // which isn't the same as the folder specified in the msg uri.
    // So add the uri for the currently loaded folder to the history list.
    if (curLoadedFolder)
      curLoadedFolder->GetURI(getter_Copies(curLoadedFolderUri));
    
    mLoadedMsgHistory.InsertCStringAt(mNavigatingToUri, mCurHistoryPos++ + 2);
    mLoadedMsgHistory.InsertCStringAt(curLoadedFolderUri, mCurHistoryPos++ + 2);
    // we may want to prune this history if it gets large, but I think it's
    // more interesting to prune the back and forward menu.
  }
}

Here is the call graph for this function:

nsresult nsMessenger::Alert ( const char *  stringName)

Definition at line 1325 of file nsMessenger.cpp.

{
    nsresult rv = NS_OK;

    if (mDocShell)
    {
        nsCOMPtr<nsIPrompt> dialog(do_GetInterface(mDocShell));

        if (dialog) {
            rv = dialog->Alert(nsnull,
                               GetString(NS_ConvertASCIItoUCS2(stringName)).get());
        }
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

boolean nsIMessenger::CanRedo ( ) [inherited]
boolean nsIMessenger::CanUndo ( ) [inherited]
void nsIMessenger::CopyFolders ( in nsIRDFCompositeDataSource  database,
in nsIRDFResource  dstResource,
in nsISupportsArray  folders,
in boolean  isMoveFolder 
) [inherited]
void nsIMessenger::CopyMessages ( in nsIRDFCompositeDataSource  database,
in nsIRDFResource  srcResource,
in nsIRDFResource  dstResource,
in nsISupportsArray  messages,
in boolean  isMove 
) [inherited]
void nsIMessenger::detachAllAttachments ( in unsigned long  count,
[array, size_is(count)] in string  contentTypeArray,
[array, size_is(count)] in string  urlArray,
[array, size_is(count)] in string  displayNameArray,
[array, size_is(count)] in string  messageUriArray,
in boolean  saveFirst 
) [inherited]
void nsIMessenger::detachAttachment ( in string  contentTpe,
in string  url,
in string  displayName,
in string  messageUri,
in boolean  saveFirst 
) [inherited]
nsresult nsMessenger::DetachAttachments ( PRUint32  aCount,
const char **  aContentTypeArray,
const char **  aUrlArray,
const char **  aDisplayNameArray,
const char **  aMessageUriArray,
nsCStringArray *  saveFileUris 
)

Definition at line 3139 of file nsMessenger.cpp.

{
  if (NS_FAILED(PromptIfDeleteAttachments(saveFileUris != nsnull, aCount, aDisplayNameArray)))
    return NS_OK;
  nsresult rv = NS_OK;


  // ensure that our arguments are valid
//  char * partId;
  for (PRUint32 u = 0; u < aCount; ++u)
  {
    // ensure all of the message URI are the same, we cannot process 
    // attachments from different messages
    if (u > 0 && 0 != nsCRT::strcmp(aMessageUriArray[0], aMessageUriArray[u]))
    {
      rv = NS_ERROR_INVALID_ARG;
      break;
    }

    // ensure that we don't have deleted messages in this list
    if (0 == nsCRT::strcmp(aContentTypeArray[u], MIMETYPE_DELETED))
    {
      rv = NS_ERROR_INVALID_ARG;
      break;
    }

    // for the moment we prevent any attachments other than root level
    // attachments being deleted (i.e. you can't delete attachments from a
    // email forwarded as an attachment). We do this by ensuring that the
    // part id only has a single period in it (e.g. "1.2").
    //TODO: support non-root level attachment delete
//    partId = ::GetAttachmentPartId(aUrlArray[u]);
//    if (!partId || PL_strchr(partId, '.') != PL_strrchr(partId, '.'))
//    {
//      rv = NS_ERROR_INVALID_ARG;
//      break;
//    }
  }
  if (NS_FAILED(rv))
  {
    Alert("deleteAttachmentFailure");
    return rv;
  }

  //TODO: ensure that nothing else is processing this message uri at the same time

  //TODO: if any of the selected attachments are messages that contain other 
  // attachments we need to warn the user that all sub-attachments of those
  // messages will also be deleted. Best to display a list of them.

  // get the listener for running the url
  nsDelAttachListener * listener = new nsDelAttachListener;
  if (!listener) 
    return NS_ERROR_OUT_OF_MEMORY;
  nsCOMPtr<nsISupports> listenerSupports; // auto-delete of the listener with error
  listener->QueryInterface(NS_GET_IID(nsISupports), getter_AddRefs(listenerSupports));

  if (saveFileUris)
    listener->mDetachedFileUris = *saveFileUris;
  // create the attachments for use by the listener
  nsAttachmentState * attach = new nsAttachmentState;
  if (!attach) 
    return NS_ERROR_OUT_OF_MEMORY;
  rv = attach->Init(aCount, aContentTypeArray, aUrlArray, aDisplayNameArray, aMessageUriArray);
  if (NS_SUCCEEDED(rv))
    rv = attach->PrepareForAttachmentDelete();
  if (NS_FAILED(rv)) 
  {
    delete attach;
    return rv;
  }

  // initialize our listener with the attachments and details. The listener takes ownership
  // of 'attach' immediately irrespective of the return value (error or not).
  return listener->StartProcessing(this, mMsgWindow, attach, saveFileUris != nsnull);
}

Here is the call graph for this function:

nsresult nsMessenger::DoCommand ( nsIRDFCompositeDataSource db,
const nsACString &  command,
nsISupportsArray srcArray,
nsISupportsArray arguments 
) [protected]

Definition at line 1342 of file nsMessenger.cpp.

{

       nsresult rv;

    nsCOMPtr<nsIRDFService> rdfService(do_GetService(kRDFServiceCID, &rv));
       if(NS_FAILED(rv))
              return rv;

       nsCOMPtr<nsIRDFResource> commandResource;
       rv = rdfService->GetResource(command, getter_AddRefs(commandResource));
       if(NS_SUCCEEDED(rv))
       {
              rv = db->DoCommand(srcArray, commandResource, argumentArray);
       }

       return rv;

}

Here is the call graph for this function:

nsresult nsMessenger::DoDelete ( nsIRDFCompositeDataSource db,
nsISupportsArray srcArray,
nsISupportsArray deletedArray 
) [protected]
nsresult nsMessenger::GetLastSaveDirectory ( nsILocalFile **  aLastSaveAsDir) [private]

Definition at line 2298 of file nsMessenger.cpp.

{
  nsresult rv;
  nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
  NS_ENSURE_SUCCESS(rv,rv);

  // this can fail, and it will, on the first time we call it, as there is no default for this pref.
  nsCOMPtr <nsILocalFile> localFile;
  rv = prefBranch->GetComplexValue(MESSENGER_SAVE_DIR_PREF_NAME, NS_GET_IID(nsILocalFile), getter_AddRefs(localFile));
  if (NS_SUCCEEDED(rv)) {
    NS_IF_ADDREF(*aLastSaveDir = localFile);
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIMessenger::getNavigateHistory ( out unsigned long  aCurPos,
out unsigned long  aCount,
[array, size_is(aCount)] out string  aHistory 
) [inherited]
unsigned long nsIMessenger::GetRedoTransactionType ( ) [inherited]
const nsAdoptingString nsMessenger::GetString ( const nsAFlatString aStringName) [protected]

Definition at line 2234 of file nsMessenger.cpp.

{
    nsresult rv = NS_OK;
    PRUnichar *ptrv = nsnull;

    if (!mStringBundle)
        rv = InitStringBundle();

    if (mStringBundle)
        rv = mStringBundle->GetStringFromName(aStringName.get(), &ptrv);

    if (NS_FAILED(rv) || !ptrv)
        ptrv = ToNewUnicode(aStringName);

    return nsAdoptingString(ptrv);
}

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned long nsIMessenger::GetUndoTransactionType ( ) [inherited]

Definition at line 2215 of file nsMessenger.cpp.

{
    nsresult res = NS_OK;
    if (!mStringBundle)
    {
              const char propertyURL[] = MESSENGER_STRING_URL;

              nsCOMPtr<nsIStringBundleService> sBundleService = 
                       do_GetService(NS_STRINGBUNDLE_CONTRACTID, &res);
              if (NS_SUCCEEDED(res) && (nsnull != sBundleService)) 
              {
                     res = sBundleService->CreateBundle(propertyURL,
                                               getter_AddRefs(mStringBundle));
              }
    }
    return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIMessenger::loadURL ( in nsIDOMWindowInternal  ptr,
in string  aURL 
) [inherited]

load a custom message by url, e.g load a attachment as a email

void nsIObserver::observe ( in nsISupports  aSubject,
in string  aTopic,
in wstring  aData 
) [inherited]

Observe will be called when there is a notification for the topic |aTopic|.

This assumes that the object implementing this interface has been registered with an observer service such as the nsIObserverService.

If you expect multiple topics/subjects, the impl is responsible for filtering.

You should not modify, add, remove, or enumerate notifications in the implemention of observe.

Parameters:
aSubject: Notification specific interface pointer.
aTopic: The notification topic or subject.
aData: Notification specific wide string. subject event.
void nsIFolderListener::OnItemAdded ( in nsIRDFResource  parentItem,
in nsISupports  item 
) [inherited]

Here is the caller graph for this function:

void nsIFolderListener::OnItemBoolPropertyChanged ( in nsIRDFResource  item,
in nsIAtom  property,
in boolean  oldValue,
in boolean  newValue 
) [inherited]

Here is the caller graph for this function:

void nsIFolderListener::OnItemEvent ( in nsIMsgFolder  item,
in nsIAtom  event 
) [inherited]

Here is the caller graph for this function:

void nsIFolderListener::OnItemIntPropertyChanged ( in nsIRDFResource  item,
in nsIAtom  property,
in long  oldValue,
in long  newValue 
) [inherited]

Here is the caller graph for this function:

void nsIFolderListener::OnItemPropertyChanged ( in nsIRDFResource  item,
in nsIAtom  property,
in string  oldValue,
in string  newValue 
) [inherited]
void nsIFolderListener::OnItemPropertyFlagChanged ( in nsIMsgDBHdr  item,
in nsIAtom  property,
in unsigned long  oldFlag,
in unsigned long  newFlag 
) [inherited]

Here is the caller graph for this function:

void nsIFolderListener::OnItemRemoved ( in nsIRDFResource  parentItem,
in nsISupports  item 
) [inherited]
void nsIFolderListener::OnItemUnicharPropertyChanged ( in nsIRDFResource  item,
in nsIAtom  property,
in wstring  oldValue,
in wstring  newValue 
) [inherited]
void nsIMessenger::openAttachment ( in string  contentTpe,
in string  url,
in string  displayName,
in string  messageUri,
in boolean  isExternalAttachment 
) [inherited]
void nsIMessenger::OpenURL ( in string  aURL) [inherited]
nsresult nsMessenger::PromptIfDeleteAttachments ( PRBool  saveFirst,
PRUint32  count,
const char **  displayNameArray 
) [protected]

Definition at line 3222 of file nsMessenger.cpp.

{
  nsresult rv = NS_ERROR_FAILURE;

  nsCOMPtr<nsIPrompt> dialog(do_GetInterface(mDocShell));
  if (!dialog) return rv;

  if (!mStringBundle)
  {
    rv = InitStringBundle();
    NS_ENSURE_SUCCESS(rv, rv);
  }

  // create the list of attachments we are removing
  nsXPIDLString displayString;
  nsXPIDLString attachmentList;
  for (PRUint32 u = 0; u < aCount; ++u)
  {
    rv = ConvertAndSanitizeFileName(aDisplayNameArray[u], getter_Copies(displayString), nsnull);
    if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
    attachmentList.Append(displayString);
    attachmentList.Append(PRUnichar('\n'));
  }
  const PRUnichar *formatStrings[] = { attachmentList.get() };

  // format the message and display
  nsXPIDLString promptMessage;
  const PRUnichar * propertyName = aSaveFirst ? 
    NS_LITERAL_STRING("detachAttachments").get() : NS_LITERAL_STRING("deleteAttachments").get();
  rv = mStringBundle->FormatStringFromName(propertyName, formatStrings, 1,getter_Copies(promptMessage));
  NS_ENSURE_SUCCESS(rv, rv);

  PRBool dialogResult = PR_FALSE;
  rv = dialog->Confirm(nsnull, promptMessage, &dialogResult);
  NS_ENSURE_SUCCESS(rv, rv);
  
  return dialogResult ? NS_OK : NS_ERROR_FAILURE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 486 of file nsMessenger.cpp.

{
    nsresult rv = NS_ERROR_FAILURE;
    if (fileSpec.Exists())
    {
        nsCOMPtr<nsIPrompt> dialog(do_GetInterface(mDocShell));
        if (!dialog) return rv;
        nsAutoString path;
        PRBool dialogResult = PR_FALSE;
        nsXPIDLString errorMessage;

        NS_CopyNativeToUnicode(
            nsDependentCString(fileSpec.GetNativePathCString()), path);
        const PRUnichar *pathFormatStrings[] = { path.get() };

        if (!mStringBundle)
        {
            rv = InitStringBundle();
            if (NS_FAILED(rv)) return rv;
        }
        rv = mStringBundle->FormatStringFromName(NS_LITERAL_STRING("fileExists").get(),
                                                 pathFormatStrings, 1,
                                                 getter_Copies(errorMessage));
        if (NS_FAILED(rv)) return rv;
        rv = dialog->Confirm(nsnull, errorMessage, &dialogResult);
        if (NS_FAILED(rv)) return rv;

        if (dialogResult)
        {
            return NS_OK; // user says okay to replace
        }
        else
        {
            // if we don't re-init the path for redisplay the picker will
            // show the full path, not just the file name
            nsCOMPtr<nsILocalFile> currentFile = do_CreateInstance("@mozilla.org/file/local;1");
            if (!currentFile) return NS_ERROR_FAILURE;

            rv = currentFile->InitWithPath(path);
            if (NS_FAILED(rv)) return rv;

            nsAutoString leafName;
            currentFile->GetLeafName(leafName);
            if (!leafName.IsEmpty())
                path.Assign(leafName); // path should be a copy of leafName

            nsCOMPtr<nsIFilePicker> filePicker =
                do_CreateInstance("@mozilla.org/filepicker;1", &rv);
            if (NS_FAILED(rv)) return rv;
            filePicker->Init(mWindow,
                             GetString(NS_LITERAL_STRING("SaveAttachment")),
                             nsIFilePicker::modeSave);
            filePicker->SetDefaultString(path);
            filePicker->AppendFilters(nsIFilePicker::filterAll);

            nsCOMPtr <nsILocalFile> lastSaveDir;
            rv = GetLastSaveDirectory(getter_AddRefs(lastSaveDir));
            if (NS_SUCCEEDED(rv) && lastSaveDir) {
              filePicker->SetDisplayDirectory(lastSaveDir);
            }

            PRInt16 dialogReturn;
            rv = filePicker->Show(&dialogReturn);
            if (NS_FAILED(rv) || dialogReturn == nsIFilePicker::returnCancel) {
                // XXX todo
                // don't overload the return value like this
                // change this function to have an out boolean
                // that we check to see if the user cancelled
                return NS_ERROR_FAILURE;
            }

            nsCOMPtr<nsILocalFile> localFile;
            nsCAutoString filePath;

            rv = filePicker->GetFile(getter_AddRefs(localFile));
            if (NS_FAILED(rv)) return rv;

            rv = SetLastSaveDirectory(localFile);
            NS_ENSURE_SUCCESS(rv,rv);

            rv = localFile->GetNativePath(filePath);
            if (NS_FAILED(rv)) return rv;

            fileSpec = filePath.get();
            return NS_OK;
        }
    }
    else
    {
        return NS_OK;
    }
    return rv;
}

Here is the call graph for this function:

void nsIMessenger::Redo ( in nsIMsgWindow  msgWindow) [inherited]
void nsIMessenger::RenameFolder ( in nsIRDFCompositeDataSource  db,
in nsIRDFResource  folder,
in wstring  name 
) [inherited]
nsresult nsMessenger::SaveAllAttachments ( PRUint32  count,
const char **  contentTypeArray,
const char **  urlArray,
const char **  displayNameArray,
const char **  messageUriArray,
PRBool  detaching 
)

Definition at line 954 of file nsMessenger.cpp.

{
  if (!count)
    return NS_ERROR_INVALID_ARG;
  return SaveAllAttachments(count, contentTypeArray, urlArray, displayNameArray, messageUriArray, PR_FALSE);
}
void nsIMessenger::saveAllAttachments ( in unsigned long  count,
[array, size_is(count)] in string  contentTypeArray,
[array, size_is(count)] in string  urlArray,
[array, size_is(count)] in string  displayNameArray,
[array, size_is(count)] in string  messageUriArray 
) [inherited]
void nsIMessenger::saveAs ( in string  aURI,
in boolean  aAsFile,
in nsIMsgIdentity  aIdentity,
in wstring  aMsgFilename 
) [inherited]
NS_IMETHODIMP nsMessenger::SaveAttachment ( nsIFileSpec fileSpec,
const char *  unescapedUrl,
const char *  messageUri,
const char *  contentType,
void closure 
)

Definition at line 732 of file nsMessenger.cpp.

{
  nsIMsgMessageService * messageService = nsnull;
  nsSaveAllAttachmentsState *saveState= (nsSaveAllAttachmentsState*) closure;
  nsCOMPtr<nsIMsgMessageFetchPartService> fetchService;
  nsCAutoString urlString;
  nsCOMPtr<nsIURI> URL;
  nsCAutoString fullMessageUri(messageUri);

  // XXX todo
  // document the ownership model of saveListener
  // whacky ref counting here...what's the deal? when does saveListener get released? it's not clear.
  nsSaveMsgListener *saveListener = new nsSaveMsgListener(fileSpec, this);
  if (!saveListener)
    return NS_ERROR_OUT_OF_MEMORY;

  NS_ADDREF(saveListener);

  saveListener->m_contentType = contentType;
  if (saveState)
  {
    saveListener->m_saveAllAttachmentsState = saveState;
    if (saveState->m_detachingAttachments)
    {

      nsFileSpec realSpec;
      fileSpec->GetFileSpec(&realSpec);

      // Create nsILocalFile from a nsFileSpec.
      nsCOMPtr<nsILocalFile> outputFile;
      nsresult rv = NS_FileSpecToIFile(&realSpec, getter_AddRefs(outputFile)); 
      NS_ENSURE_SUCCESS(rv, rv);

      nsCOMPtr<nsIURI> outputURI;
      rv = NS_NewFileURI(getter_AddRefs(outputURI), outputFile);
      NS_ENSURE_SUCCESS(rv, rv);
      nsCAutoString fileUriSpec;
      outputURI->GetSpec(fileUriSpec);
      saveState->m_savedFiles.AppendCString(fileUriSpec);
    }
  }

  urlString = url;
  // strip out ?type=application/x-message-display because it confuses libmime

  PRInt32 typeIndex = urlString.Find("?type=application/x-message-display");
  if (typeIndex != kNotFound)
  {
    urlString.Cut(typeIndex, sizeof("?type=application/x-message-display") - 1);
    // we also need to replace the next '&' with '?'
    PRInt32 firstPartIndex = urlString.FindChar('&');
    if (firstPartIndex != kNotFound)
      urlString.SetCharAt('?', firstPartIndex);
  }

  urlString.ReplaceSubstring("/;section", "?section");
  nsresult rv = CreateStartupUrl(urlString.get(), getter_AddRefs(URL));

  if (NS_SUCCEEDED(rv))
  {
    rv = GetMessageServiceFromURI(messageUri, &messageService);
    if (NS_SUCCEEDED(rv))
    {
      fetchService = do_QueryInterface(messageService);
      // if the message service has a fetch part service then we know we can fetch mime parts...
      if (fetchService)
      {
        PRInt32 sectionPos = urlString.Find("?section");
        nsCString mimePart;
        urlString.Right(mimePart, urlString.Length() - sectionPos);
        fullMessageUri.Append(mimePart);
   
        messageUri = fullMessageUri.get();
      }

      nsCOMPtr<nsIStreamListener> convertedListener;
      saveListener->QueryInterface(NS_GET_IID(nsIStreamListener),
                                 getter_AddRefs(convertedListener));

#if !defined(XP_MAC) && !defined(XP_MACOSX)
      // if the content type is bin hex we are going to do a hokey hack and make sure we decode the bin hex 
      // when saving an attachment to disk..
      if (contentType && !nsCRT::strcasecmp(APPLICATION_BINHEX, contentType))
      {
        nsCOMPtr<nsIStreamListener> listener (do_QueryInterface(convertedListener));
        nsCOMPtr<nsIStreamConverterService> streamConverterService = do_GetService("@mozilla.org/streamConverters;1", &rv);
        nsCOMPtr<nsISupports> channelSupport = do_QueryInterface(saveListener->m_channel);
          
        rv = streamConverterService->AsyncConvertData(APPLICATION_BINHEX,
                                                      "*/*", 
                                                      listener,
                                                      channelSupport,
                                                      getter_AddRefs(convertedListener));
      }
#endif
      if (fetchService)
        rv = fetchService->FetchMimePart(URL, messageUri, convertedListener, mMsgWindow, nsnull,nsnull);
      else
        rv = messageService->DisplayMessage(messageUri, convertedListener, mMsgWindow, nsnull, nsnull, nsnull); 
    } // if we got a message service
  } // if we created a url

  if (NS_FAILED(rv))
  {
      NS_IF_RELEASE(saveListener);
      Alert("saveAttachmentFailed");
  }
  return rv;
}

Here is the call graph for this function:

void nsIMessenger::saveAttachment ( in string  contentTpe,
in string  url,
in string  displayName,
in string  messageUri,
in boolean  isExternalAttachment 
) [inherited]
nsILocalFile nsIMessenger::saveAttachmentToFolder ( in string  contentType,
in string  url,
in string  displayName,
in string  messageUri,
in nsILocalFile  aDestFolder 
) [inherited]
void nsIMessenger::sendUnsentMessages ( in nsIMsgIdentity  aIdentity,
in nsIMsgWindow  aMsgWindow 
) [inherited]
void nsIMessenger::setDisplayCharset ( in string  aCharset) [inherited]

Definition at line 454 of file nsMessenger.cpp.

{
  // For now, the only property we will set is allowPlugins but we might do more in the future...

  nsresult rv;

  if (!mDocShell)
    return NS_ERROR_FAILURE;
 
  PRBool allowPlugins = PR_FALSE;

  nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
  if (NS_SUCCEEDED(rv))
    prefBranch->GetBoolPref(MAILNEWS_ALLOW_PLUGINS_PREF_NAME, &allowPlugins);
  
  return mDocShell->SetAllowPlugins(allowPlugins);
}

Here is the call graph for this function:

void nsIMessenger::SetDocumentCharset ( in string  characterSet) [inherited]

Definition at line 2314 of file nsMessenger.cpp.

{
  nsresult rv;
  nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
  NS_ENSURE_SUCCESS(rv,rv);

  nsCOMPtr <nsIFile> file = do_QueryInterface(aLocalFile, &rv);
  NS_ENSURE_SUCCESS(rv,rv);

  // if the file is a directory, just use it for the last dir chosen
  // otherwise, use the parent of the file as the last dir chosen.
  // IsDirectory() will return error on saving a file, as the
  // file doesn't exist yet.
  PRBool isDirectory;
  rv = file->IsDirectory(&isDirectory);
  if (NS_SUCCEEDED(rv) && isDirectory) {
    rv = prefBranch->SetComplexValue(MESSENGER_SAVE_DIR_PREF_NAME, NS_GET_IID(nsILocalFile), aLocalFile);
    NS_ENSURE_SUCCESS(rv,rv);
  }
  else {
    nsCOMPtr <nsIFile> parent;
    rv = file->GetParent(getter_AddRefs(parent));
    NS_ENSURE_SUCCESS(rv,rv);
   
    nsCOMPtr <nsILocalFile> parentLocalFile = do_QueryInterface(parent, &rv);
    NS_ENSURE_SUCCESS(rv,rv);

    rv = prefBranch->SetComplexValue(MESSENGER_SAVE_DIR_PREF_NAME, NS_GET_IID(nsILocalFile), parentLocalFile);
    NS_ENSURE_SUCCESS(rv,rv);
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIMessenger::SetWindow ( in nsIDOMWindowInternal  ptr,
in nsIMsgWindow  msgWindow 
) [inherited]
void nsIMessenger::Undo ( in nsIMsgWindow  msgWindow) [inherited]

Member Data Documentation

Definition at line 49 of file nsIFolderListener.idl.

Definition at line 69 of file nsIFolderListener.idl.

Definition at line 57 of file nsIMessenger.idl.

Definition at line 55 of file nsIMessenger.idl.

Definition at line 56 of file nsIMessenger.idl.

Definition at line 54 of file nsIMessenger.idl.

Definition at line 63 of file nsIFolderListener.idl.

Definition at line 120 of file nsIMessenger.idl.

Definition at line 121 of file nsMessenger.h.

Definition at line 113 of file nsMessenger.h.

Definition at line 108 of file nsMessenger.h.

Definition at line 101 of file nsMessenger.h.

Definition at line 116 of file nsMessenger.h.

nsCStringArray nsMessenger::mLoadedMsgHistory [private]

Definition at line 120 of file nsMessenger.h.

Definition at line 107 of file nsMessenger.h.

Definition at line 119 of file nsMessenger.h.

Definition at line 102 of file nsMessenger.h.

nsCOMPtr<nsISupports> nsMessenger::mSearchContext [private]

Definition at line 115 of file nsMessenger.h.

Definition at line 118 of file nsMessenger.h.

Definition at line 111 of file nsMessenger.h.

Definition at line 103 of file nsMessenger.h.

Definition at line 106 of file nsMessenger.h.

Definition at line 133 of file nsIMessenger.idl.

Definition at line 57 of file nsIFolderListener.idl.

Definition at line 81 of file nsIFolderListener.idl.

Definition at line 53 of file nsIFolderListener.idl.

Definition at line 118 of file nsIMessenger.idl.

Definition at line 61 of file nsIMessenger.idl.

Definition at line 75 of file nsIFolderListener.idl.


Event Documentation

Definition at line 90 of file nsIFolderListener.idl.

Definition at line 87 of file nsIFolderListener.idl.


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