зеркало из https://github.com/mozilla/pjs.git
Switch to nsIFilePicker, b=34051,39036 r=alecf
This commit is contained in:
Родитель
aa3ceb1ea4
Коммит
a7859214f0
|
@ -421,6 +421,18 @@ function ShowAddressComplete( good)
|
||||||
alert( str);
|
alert( str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function CreateNewFileSpecFromPath( inPath)
|
||||||
|
{
|
||||||
|
var file = Components.classes["component://netscape/filespec"].createInstance();
|
||||||
|
if (file != null) {
|
||||||
|
file = file.QueryInterface( Components.interfaces.nsIFileSpec);
|
||||||
|
if (file != null) {
|
||||||
|
file.nativePath = inPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return( file);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Import Settings from a specific module, returns false if it failed
|
Import Settings from a specific module, returns false if it failed
|
||||||
|
@ -448,15 +460,29 @@ function ImportSettings( module, newAccount, error) {
|
||||||
if (location.value != null) {
|
if (location.value != null) {
|
||||||
// Settings were not found, however, they are specified
|
// Settings were not found, however, they are specified
|
||||||
// in a file, so ask the user for the settings file.
|
// in a file, so ask the user for the settings file.
|
||||||
var filePicker = Components.classes["component://netscape/filespecwithui"].createInstance();
|
var filePicker = Components.classes["component://mozilla/filepicker"].createInstance();
|
||||||
if (filePicker != null) {
|
if (filePicker != null) {
|
||||||
filePicker = filePicker.QueryInterface( Components.interfaces.nsIFileSpecWithUI);
|
filePicker = filePicker.QueryInterface( Components.interfaces.nsIFilePicker);
|
||||||
if (filePicker != null) {
|
if (filePicker != null) {
|
||||||
// filePicker.create( window.top, GetBundleString( 'ImportSelectSettings'), filePicker.modeLoad);
|
var file = null;
|
||||||
try {
|
try {
|
||||||
filePicker.chooseInputFile( GetBundleString( 'ImportSelectSettings'), filePicker.eAllFiles, null, null);
|
filePicker.init( top.window, GetBundleString( 'ImportSelectSettings'), Components.interfaces.nsIFilePicker.modeOpen);
|
||||||
setIntf.SetLocation( filePicker.QueryInterface( Components.interfaces.nsIFileSpec));
|
filePicker.appendFilters( Components.interfaces.nsIFilePicker.filterAll);
|
||||||
} catch( ex) {
|
filePicker.show();
|
||||||
|
if (filePicker.file && (filePicker.file.path.length > 0))
|
||||||
|
file = CreateNewFileSpecFromPath( filePicker.file.path);
|
||||||
|
else
|
||||||
|
file = null;
|
||||||
|
}
|
||||||
|
catch(ex) {
|
||||||
|
file = null;
|
||||||
|
error.value = null;
|
||||||
|
return( false);
|
||||||
|
}
|
||||||
|
if (file != null) {
|
||||||
|
setIntf.SetLocation( file);
|
||||||
|
}
|
||||||
|
else {
|
||||||
error.value = null;
|
error.value = null;
|
||||||
return( false);
|
return( false);
|
||||||
}
|
}
|
||||||
|
@ -521,13 +547,18 @@ function ImportMail( module, success, error) {
|
||||||
if (loc == null) {
|
if (loc == null) {
|
||||||
// No location found, check to see if we can ask the user.
|
// No location found, check to see if we can ask the user.
|
||||||
if (mailInterface.GetStatus( "canUserSetLocation") != 0) {
|
if (mailInterface.GetStatus( "canUserSetLocation") != 0) {
|
||||||
var filePicker = Components.classes["component://netscape/filespecwithui"].createInstance();
|
var filePicker = Components.classes["component://mozilla/filepicker"].createInstance();
|
||||||
if (filePicker != null) {
|
if (filePicker != null) {
|
||||||
filePicker = filePicker.QueryInterface( Components.interfaces.nsIFileSpecWithUI);
|
filePicker = filePicker.QueryInterface( Components.interfaces.nsIFilePicker);
|
||||||
if (filePicker != null) {
|
if (filePicker != null) {
|
||||||
try {
|
try {
|
||||||
filePicker.chooseDirectory( GetBundleString( 'ImportSelectMailDir'));
|
filePicker.init( top.window, GetBundleString( 'ImportSelectMailDir'), Components.interfaces.nsIFilePicker.modeGetFolder);
|
||||||
mailInterface.SetData( "mailLocation", CreateNewFileSpec( filePicker.QueryInterface( Components.interfaces.nsIFileSpec)));
|
filePicker.appendFilters( Components.interfaces.nsIFilePicker.filterAll);
|
||||||
|
filePicker.show();
|
||||||
|
if (filePicker.file && (filePicker.file.path.length > 0))
|
||||||
|
mailInterface.SetData( "mailLocation", CreateNewFileSpecFromPath( filePicker.file.path));
|
||||||
|
else
|
||||||
|
return( false);
|
||||||
} catch( ex) {
|
} catch( ex) {
|
||||||
// don't show an error when we return!
|
// don't show an error when we return!
|
||||||
return( false);
|
return( false);
|
||||||
|
@ -612,9 +643,9 @@ function ImportAddress( module, success, error) {
|
||||||
return( false);
|
return( false);
|
||||||
}
|
}
|
||||||
|
|
||||||
var filePicker = Components.classes["component://netscape/filespecwithui"].createInstance();
|
var filePicker = Components.classes["component://mozilla/filepicker"].createInstance();
|
||||||
if (filePicker != null) {
|
if (filePicker != null) {
|
||||||
filePicker = filePicker.QueryInterface( Components.interfaces.nsIFileSpecWithUI);
|
filePicker = filePicker.QueryInterface( Components.interfaces.nsIFilePicker);
|
||||||
if (filePicker == null) {
|
if (filePicker == null) {
|
||||||
error.data = GetBundleString( 'ImportAddressNotFound');
|
error.data = GetBundleString( 'ImportAddressNotFound');
|
||||||
return( false);
|
return( false);
|
||||||
|
@ -632,8 +663,13 @@ function ImportAddress( module, success, error) {
|
||||||
if (addInterface.GetStatus( "supportsMultiple") != 0) {
|
if (addInterface.GetStatus( "supportsMultiple") != 0) {
|
||||||
// ask for dir
|
// ask for dir
|
||||||
try {
|
try {
|
||||||
filePicker.chooseDirectory( GetBundleString( 'ImportSelectAddrDir'));
|
filePicker.init( top.window, GetBundleString( 'ImportSelectAddrDir'), Components.interfaces.nsIFilePicker.modeGetFolder);
|
||||||
file = filePicker.QueryInterface( Components.interfaces.nsIFileSpec);
|
filePicker.appendFilters( Components.interfaces.nsIFilePicker.filterAll);
|
||||||
|
filePicker.show();
|
||||||
|
if (filePicker.file && (filePicker.file.path.length > 0))
|
||||||
|
file = filePicker.file.path;
|
||||||
|
else
|
||||||
|
file = null;
|
||||||
} catch( ex) {
|
} catch( ex) {
|
||||||
file = null;
|
file = null;
|
||||||
}
|
}
|
||||||
|
@ -641,8 +677,13 @@ function ImportAddress( module, success, error) {
|
||||||
else {
|
else {
|
||||||
// ask for file
|
// ask for file
|
||||||
try {
|
try {
|
||||||
filePicker.chooseInputFile( GetBundleString( 'ImportSelectAddrFile'), filePicker.eAllFiles, null, null);
|
filePicker.init( top.window, GetBundleString( 'ImportSelectAddrFile'), Components.interfaces.nsIFilePicker.modeOpen);
|
||||||
file = filePicker.QueryInterface( Components.interfaces.nsIFileSpec);
|
filePicker.appendFilters( Components.interfaces.nsIFilePicker.filterAll);
|
||||||
|
filePicker.show();
|
||||||
|
if (filePicker.file && (filePicker.file.path.length > 0))
|
||||||
|
file = filePicker.file.path;
|
||||||
|
else
|
||||||
|
file = null;
|
||||||
} catch( ex) {
|
} catch( ex) {
|
||||||
file = null;
|
file = null;
|
||||||
}
|
}
|
||||||
|
@ -652,7 +693,7 @@ function ImportAddress( module, success, error) {
|
||||||
return( false);
|
return( false);
|
||||||
}
|
}
|
||||||
|
|
||||||
file = CreateNewFileSpec( file);
|
file = CreateNewFileSpecFromPath( file);
|
||||||
|
|
||||||
addInterface.SetData( "addressLocation", file);
|
addInterface.SetData( "addressLocation", file);
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче