mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-27 07:34:20 +00:00
Bug34051 use nsIFilePicker instead of nsIFileSpecWithUI in mailnews, r=sspitzer, sr=mscott
This commit is contained in:
parent
42e06f4c42
commit
a84a3c73c4
@ -1448,13 +1448,26 @@ NS_IMETHODIMP nsAddressBook::ImportAddressBook()
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIFileSpecWithUI> fileSpec(getter_AddRefs(NS_CreateFileSpecWithUI()));
|
||||
if (!fileSpec)
|
||||
return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIFilePicker> filePicker = do_CreateInstance("@mozilla.org/filepicker;1", &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
filePicker->Init(nsnull, nsnull, nsIFilePicker::modeOpen);
|
||||
|
||||
// XXX: todo "Open File" should be in a string bundle
|
||||
rv = fileSpec->ChooseInputFile("Open File", nsIFileSpecWithUI::eAllFiles, nsnull, nsnull);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
PRInt16 dialogResult;
|
||||
filePicker->Show(&dialogResult);
|
||||
|
||||
if (dialogResult == nsIFilePicker::returnCancel)
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsILocalFile> localFile;
|
||||
rv = filePicker->GetFile(getter_AddRefs(localFile));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsXPIDLCString path;
|
||||
localFile->GetPath(getter_Copies(path));
|
||||
nsCOMPtr<nsIFileSpec> fileSpec = do_CreateInstance("@mozilla.org/filespec;1", &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
fileSpec->SetNativePath(path);
|
||||
|
||||
// todo, check that we have a file, not a directory, and that is readable
|
||||
// and that it is not zero length.
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include "nsIFileSpecWithUI.h"
|
||||
#include "nsICmdLineHandler.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIFileSpec.h"
|
||||
|
||||
#define NC_RDF_NEWABCARD "http://home.netscape.com/NC-rdf#NewCard"
|
||||
#define NC_RDF_DELETE "http://home.netscape.com/NC-rdf#Delete"
|
||||
|
Loading…
x
Reference in New Issue
Block a user