Improve Publishing progress and error notification, b=148425, r=brade, sr=hewitt
git-svn-id: svn://10.0.0.236/trunk@122734 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -343,10 +343,12 @@ var nsSaveCommand =
|
||||
// Always allow saving when editing a remote document,
|
||||
// otherwise the document modified state would prevent that
|
||||
// when you first open a remote file.
|
||||
var docUrl = GetDocumentUrl();
|
||||
return window.editorShell && window.editorShell.documentEditable &&
|
||||
(window.editorShell.documentModified || window.gHTMLSourceChanged ||
|
||||
IsUrlAboutBlank(docUrl) || GetScheme(docUrl) != "file");
|
||||
try {
|
||||
var docUrl = GetDocumentUrl();
|
||||
return window.editorShell && window.editorShell.documentEditable &&
|
||||
(window.editorShell.documentModified || window.gHTMLSourceChanged ||
|
||||
IsUrlAboutBlank(docUrl) || GetScheme(docUrl) != "file");
|
||||
} catch (e) {return false;}
|
||||
},
|
||||
|
||||
doCommand: function(aCommand)
|
||||
@@ -448,9 +450,11 @@ var nsPublishCommand =
|
||||
// Always allow publishing when editing a local document,
|
||||
// otherwise the document modified state would prevent that
|
||||
// when you first open any local file.
|
||||
var docUrl = GetDocumentUrl();
|
||||
return window.editorShell.documentModified || window.gHTMLSourceChanged
|
||||
|| IsUrlAboutBlank(docUrl) || GetScheme(docUrl) == "file";
|
||||
try {
|
||||
var docUrl = GetDocumentUrl();
|
||||
return window.editorShell.documentModified || window.gHTMLSourceChanged
|
||||
|| IsUrlAboutBlank(docUrl) || GetScheme(docUrl) == "file";
|
||||
} catch (e) {return false;}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
@@ -833,6 +837,10 @@ const gShowDebugOutputSecurityChange = false;
|
||||
const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
|
||||
const nsIChannel = Components.interfaces.nsIChannel;
|
||||
|
||||
const kErrorBindingAborted = 2152398850;
|
||||
const kErrorBindingRedirected = 2152398851;
|
||||
const kFileNotFound = 2152857618;
|
||||
|
||||
var gEditorOutputProgressListener =
|
||||
{
|
||||
onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus)
|
||||
@@ -853,7 +861,7 @@ var gEditorOutputProgressListener =
|
||||
|
||||
if (gShowDebugOutputStateChange)
|
||||
{
|
||||
dump("***** onStateChange request: " + requestSpec + "\n");
|
||||
dump("\n***** onStateChange request: " + requestSpec + "\n");
|
||||
dump(" state flags: ");
|
||||
|
||||
if (aStateFlags & nsIWebProgressListener.STATE_START)
|
||||
@@ -867,25 +875,24 @@ var gEditorOutputProgressListener =
|
||||
|
||||
DumpDebugStatus(aStatus);
|
||||
}
|
||||
// The rest only concerns publishing, so bail out if no dialog
|
||||
if (!gProgressDialog)
|
||||
return;
|
||||
|
||||
// Detect start of file upload of any file:
|
||||
// (We ignore any START messages after gPersistObj says publishing is finished
|
||||
if ((aStateFlags & nsIWebProgressListener.STATE_START)
|
||||
&& requestSpec && gProgressDialog)
|
||||
&& gPersistObj && requestSpec
|
||||
&& (gPersistObj.currentState != gPersistObj.PERSIST_STATE_FINISHED))
|
||||
{
|
||||
try {
|
||||
// Add url to progress dialog's list showing each file uploading
|
||||
// Note that even though we create dialog before calling OutputFileWithPersistAPI,
|
||||
// we can get here before dialog is initialized.
|
||||
// This will cause exception calling AddProgressListitem,
|
||||
// But we'll add any missed files in dialog later
|
||||
gProgressDialog.SetProgressStatus(GetFilename(requestSpec), "busy");
|
||||
} catch(e) {
|
||||
dump(" Exception error calling SetProgressStatus\n");
|
||||
}
|
||||
} catch(e) {}
|
||||
}
|
||||
|
||||
// Detect end of file upload of any file:
|
||||
if ((aStateFlags & nsIWebProgressListener.STATE_STOP))
|
||||
if (aStateFlags & nsIWebProgressListener.STATE_STOP)
|
||||
{
|
||||
// ignore aStatus == kErrorBindingAborted; check http response for possible errors
|
||||
try {
|
||||
@@ -906,108 +913,84 @@ var gEditorOutputProgressListener =
|
||||
aStatus = 0;
|
||||
}
|
||||
|
||||
// We abort publishing for all errors except if image src file is not found
|
||||
var abortPublishing = (aStatus != 0 && aStatus != kFileNotFound);
|
||||
|
||||
// Notify progress dialog when we receive the STOP
|
||||
// notification for a file if there was an error
|
||||
// or for a successful finish only if
|
||||
// destination url is contains the publishing location
|
||||
if (gProgressDialog &&
|
||||
(aStatus != 0
|
||||
|| requestSpec && requestSpec.indexOf(gPublishData.publishUrl) == 0))
|
||||
// or a successful finish
|
||||
// (Check requestSpec to be sure message is for destination url)
|
||||
if (aStatus != 0
|
||||
|| (requestSpec && requestSpec.indexOf(GetScheme(gPublishData.publishUrl)) == 0))
|
||||
{
|
||||
try {
|
||||
gProgressDialog.SetProgressFinished(GetFilename(requestSpec), aStatus);
|
||||
} catch(e) {}
|
||||
}
|
||||
|
||||
if (aStatus)
|
||||
|
||||
if (abortPublishing)
|
||||
{
|
||||
// Cancel the publish
|
||||
// Cancel publishing
|
||||
gPersistObj.cancelSave();
|
||||
gProgressDialog.SetProgressStatusCancel();
|
||||
|
||||
//XXX TODO: we should provide more meaningful errors (if possible)
|
||||
var failedStr = GetString("PublishFailed");
|
||||
|
||||
// XXX We don't have error codes in IDL !!!
|
||||
// Give better error messages for cases we know about:
|
||||
if (aStatus == 2152398868) // Bad directory
|
||||
{
|
||||
var requestFilename = requestSpec ? GetFilename(requestSpec) : "";
|
||||
var dir = (gPublishData.filename == requestFilename) ?
|
||||
gPublishData.docDir : gPublishData.otherDir;
|
||||
|
||||
failedStr = GetString("PublishDirFailed").replace(/%dir%/, gPublishData.docDir);
|
||||
if (gProgressDialog)
|
||||
gProgressDialog.SetStatusMessage(failedStr);
|
||||
|
||||
// Remove directory from saved prefs
|
||||
RemovePublishSubdirectoryFromPrefs(gPublishData, dir);
|
||||
}
|
||||
|
||||
// Do not do any commands after failure
|
||||
// Don't do any commands after failure
|
||||
gCommandAfterPublishing = null;
|
||||
|
||||
// Show error in progress dialog and let user close it
|
||||
if (gProgressDialog)
|
||||
{
|
||||
try {
|
||||
// Tell dialog final status value so it can show appropriate message
|
||||
gProgressDialog.SetProgressFinished(null, aStatus);
|
||||
} catch (e) {
|
||||
dump(" **** EXCEPTION ERROR CALLING ProgressDialog.SetProgressFinished\n");
|
||||
AlertWithTitle(GetString("Publish"), failedStr);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// In case we ever get final alert with no dialog
|
||||
AlertWithTitle(GetString("Publish"), failedStr);
|
||||
// Notify progress dialog that we're finished
|
||||
// and keep open to show error
|
||||
gProgressDialog.SetProgressFinished(null,0);
|
||||
|
||||
// Final cleanup
|
||||
FinishPublishing();
|
||||
}
|
||||
return; // we don't want to change location or reset mod count, etc.
|
||||
// We don't want to change location or reset mod count, etc.
|
||||
return;
|
||||
}
|
||||
|
||||
if ((aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK))
|
||||
// STATE_IS_NETWORK signals end of publishing, as does the gPersistObj.currentState
|
||||
if (aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK
|
||||
&& gPersistObj.currentState == gPersistObj.PERSIST_STATE_FINISHED)
|
||||
{
|
||||
// All files are finished uploading
|
||||
|
||||
// Publishing succeeded...
|
||||
try {
|
||||
// Get the new docUrl from the "browse location" in case "publish location" was FTP
|
||||
var urlstring = GetDocUrlFromPublishData(gPublishData);
|
||||
|
||||
window.editorShell.doAfterSave(true, urlstring); // we need to update the url before notifying listeners
|
||||
var editor = window.editorShell.editor.QueryInterface(Components.interfaces.nsIEditor);
|
||||
editor.resetModificationCount();
|
||||
// this should cause notification to listeners that doc has changed
|
||||
|
||||
// Set UI based on whether we're editing a remote or local url
|
||||
SetSaveAndPublishUI(urlstring);
|
||||
|
||||
} catch (e) {}
|
||||
|
||||
// Save publishData to prefs
|
||||
if (gPublishData)
|
||||
if (gPersistObj.result == 0)
|
||||
{
|
||||
if (gPublishData.savePublishData)
|
||||
{
|
||||
// We published successfully, so we can safely
|
||||
// save docDir and otherDir to prefs
|
||||
gPublishData.saveDirs = true;
|
||||
SavePublishDataToPrefs(gPublishData);
|
||||
}
|
||||
else
|
||||
SavePassword(gPublishData);
|
||||
}
|
||||
// All files are finished and publishing succeeded (some images may have failed)
|
||||
try {
|
||||
// Get the new docUrl from the "browse location" in case "publish location" was FTP
|
||||
var urlstring = GetDocUrlFromPublishData(gPublishData);
|
||||
|
||||
// Ask progress dialog to close, but it may not
|
||||
// if user checked checkbox to keep it open
|
||||
if (gProgressDialog)
|
||||
window.editorShell.doAfterSave(true, urlstring); // we need to update the url before notifying listeners
|
||||
var editor = window.editorShell.editor.QueryInterface(Components.interfaces.nsIEditor);
|
||||
// this should cause notification to listeners that doc has changed
|
||||
editor.resetModificationCount();
|
||||
|
||||
// Set UI based on whether we're editing a remote or local url
|
||||
SetSaveAndPublishUI(urlstring);
|
||||
|
||||
} catch (e) {}
|
||||
|
||||
// Save publishData to prefs
|
||||
if (gPublishData)
|
||||
{
|
||||
if (gPublishData.savePublishData)
|
||||
{
|
||||
// We published successfully, so we can safely
|
||||
// save docDir and otherDir to prefs
|
||||
gPublishData.saveDirs = true;
|
||||
SavePublishDataToPrefs(gPublishData);
|
||||
}
|
||||
else
|
||||
SavePassword(gPublishData);
|
||||
}
|
||||
|
||||
// Ask progress dialog to close, but it may not
|
||||
// if user checked checkbox to keep it open
|
||||
gProgressDialog.RequestCloseDialog();
|
||||
}
|
||||
else
|
||||
FinishPublishing();
|
||||
{
|
||||
// We previously aborted publishing because of error:
|
||||
// Calling gPersistObj.cancelSave() resulted in a non-zero gPersistObj.result,
|
||||
// so notify progress dialog we're finished
|
||||
gProgressDialog.SetProgressFinished(null,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -1015,8 +998,12 @@ var gEditorOutputProgressListener =
|
||||
onProgressChange : function(aWebProgress, aRequest, aCurSelfProgress,
|
||||
aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress)
|
||||
{
|
||||
if (!gPersistObj)
|
||||
return;
|
||||
|
||||
if (gShowDebugOutputProgress)
|
||||
{
|
||||
dump("\n onProgressChange: gPersistObj.result="+gPersistObj.result+"\n");
|
||||
try {
|
||||
var channel = aRequest.QueryInterface(nsIChannel);
|
||||
dump("***** onProgressChange request: " + channel.URI.spec + "\n");
|
||||
@@ -1025,17 +1012,12 @@ var gEditorOutputProgressListener =
|
||||
dump("***** self: "+aCurSelfProgress+" / "+aMaxSelfProgress+"\n");
|
||||
dump("***** total: "+aCurTotalProgress+" / "+aMaxTotalProgress+"\n\n");
|
||||
|
||||
if (gPersistObj)
|
||||
{
|
||||
if(gPersistObj.currentState == gPersistObj.PERSIST_STATE_READY)
|
||||
dump(" Persister is ready to save data\n\n");
|
||||
else if(gPersistObj.currentState == gPersistObj.PERSIST_STATE_SAVING)
|
||||
dump(" Persister is saving data.\n\n");
|
||||
else if(gPersistObj.currentState == gPersistObj.PERSIST_STATE_FINISHED)
|
||||
{
|
||||
dump(" PERSISTER HAS FINISHED SAVING DATA\n\n\n");
|
||||
}
|
||||
}
|
||||
if (gPersistObj.currentState == gPersistObj.PERSIST_STATE_READY)
|
||||
dump(" Persister is ready to save data\n\n");
|
||||
else if (gPersistObj.currentState == gPersistObj.PERSIST_STATE_SAVING)
|
||||
dump(" Persister is saving data.\n\n");
|
||||
else if (gPersistObj.currentState == gPersistObj.PERSIST_STATE_FINISHED)
|
||||
dump(" PERSISTER HAS FINISHED SAVING DATA\n\n\n");
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1270,82 +1252,82 @@ function PromptUsernameAndPassword(dlgTitle, text, savePW, userObj, pwObj)
|
||||
return ret;
|
||||
}
|
||||
|
||||
const kErrorBindingAborted = 2152398850;
|
||||
|
||||
function DumpDebugStatus(aStatus)
|
||||
{
|
||||
// see nsError.h and netCore.h and ftpCore.h
|
||||
const kErrorBindingRedirected = 2152398851;
|
||||
|
||||
if (aStatus == kErrorBindingAborted)
|
||||
dump("***** status is NS_BINDING_ABORTED\n");
|
||||
dump("***** status is NS_BINDING_ABORTED\n");
|
||||
else if (aStatus == kErrorBindingRedirected)
|
||||
dump("***** status is NS_BINDING_REDIRECTED\n");
|
||||
else if (aStatus == 2152398859) // in netCore.h
|
||||
dump("***** status is ALREADY_CONNECTED\n");
|
||||
else if (aStatus == 2152398860) // in netCore.h
|
||||
dump("***** status is NOT_CONNECTED\n");
|
||||
else if (aStatus == 2152398861) // in nsISocketTransportService.idl
|
||||
dump("***** status is NO_SERVER_ON_THIS_PORT\n");
|
||||
else if (aStatus == 2152398862) // in nsISocketTransportService.idl
|
||||
dump("***** status is TIMEOUT_ERROR\n");
|
||||
else if (aStatus == 2152398863) // in netCore.h
|
||||
dump("***** status is IN_PROGRESS\n");
|
||||
else if (aStatus == 2152398864) // 0x804b0010 in netCore.h
|
||||
dump("***** status is OFFLINE\n");
|
||||
else if (aStatus == 2152398865) // in netCore.h
|
||||
dump("***** status is NO_CONTENT\n");
|
||||
else if (aStatus == 2152398867) // in netCore.h
|
||||
dump("***** status is NO_ACCESS_TO_PORT\n");
|
||||
else if (aStatus == 2152398868) // in nsISocketTransportService.idl
|
||||
dump("***** status is NETWORK_RESET\n");
|
||||
else if (aStatus == 2152398869) // in ftpCore.h
|
||||
dump("***** status is FTP_LOGIN_ERROR\n");
|
||||
else if (aStatus == 2152398870) // in ftpCore.h
|
||||
dump("***** status is FTP_CHANGE_DIR_ERROR\n");
|
||||
else if (aStatus == 2152398871) // in ftpCore.h
|
||||
dump("***** status is FTP_PASV_ERROR\n");
|
||||
else if (aStatus == 2152398872) // in ftpCore.h
|
||||
dump("***** status is FTP_PWD_ERROR\n");
|
||||
|
||||
dump("***** status is NS_BINDING_REDIRECTED\n");
|
||||
else if (aStatus == 2152398859) // in netCore.h 11
|
||||
dump("***** status is ALREADY_CONNECTED\n");
|
||||
else if (aStatus == 2152398860) // in netCore.h 12
|
||||
dump("***** status is NOT_CONNECTED\n");
|
||||
else if (aStatus == 2152398861) // in nsISocketTransportService.idl 13
|
||||
dump("***** status is CONNECTION_REFUSED\n");
|
||||
else if (aStatus == 2152398862) // in nsISocketTransportService.idl 14
|
||||
dump("***** status is NET_TIMEOUT\n");
|
||||
else if (aStatus == 2152398863) // in netCore.h 15
|
||||
dump("***** status is IN_PROGRESS\n");
|
||||
else if (aStatus == 2152398864) // 0x804b0010 in netCore.h 16
|
||||
dump("***** status is OFFLINE\n");
|
||||
else if (aStatus == 2152398865) // in netCore.h 17
|
||||
dump("***** status is NO_CONTENT\n");
|
||||
else if (aStatus == 2152398866) // in netCore.h 18
|
||||
dump("***** status is UNKNOWN_PROTOCOL\n");
|
||||
else if (aStatus == 2152398867) // in netCore.h 19
|
||||
dump("***** status is PORT_ACCESS_NOT_ALLOWED\n");
|
||||
else if (aStatus == 2152398868) // in nsISocketTransportService.idl 20
|
||||
dump("***** status is NET_RESET\n");
|
||||
else if (aStatus == 2152398869) // in ftpCore.h 21
|
||||
dump("***** status is FTP_LOGIN\n");
|
||||
else if (aStatus == 2152398870) // in ftpCore.h 22
|
||||
dump("***** status is FTP_CWD\n");
|
||||
else if (aStatus == 2152398871) // in ftpCore.h 23
|
||||
dump("***** status is FTP_PASV\n");
|
||||
else if (aStatus == 2152398872) // in ftpCore.h 24
|
||||
dump("***** status is FTP_PWD\n");
|
||||
else if (aStatus == 2152857601)
|
||||
dump("***** status is UNRECOGNIZED_PATH\n");
|
||||
dump("***** status is UNRECOGNIZED_PATH\n");
|
||||
else if (aStatus == 2152857602)
|
||||
dump("***** status is UNRESOLABLE SYMLINK\n");
|
||||
dump("***** status is UNRESOLABLE SYMLINK\n");
|
||||
else if (aStatus == 2152857604)
|
||||
dump("***** status is UNKNOWN_TYPE\n");
|
||||
dump("***** status is UNKNOWN_TYPE\n");
|
||||
else if (aStatus == 2152857605)
|
||||
dump("***** status is DESTINATION_NOT_DIR\n");
|
||||
dump("***** status is DESTINATION_NOT_DIR\n");
|
||||
else if (aStatus == 2152857606)
|
||||
dump("***** status is TARGET_DOES_NOT_EXIST\n");
|
||||
dump("***** status is TARGET_DOES_NOT_EXIST\n");
|
||||
else if (aStatus == 2152857608)
|
||||
dump("***** status is ALREADY_EXISTS\n");
|
||||
dump("***** status is ALREADY_EXISTS\n");
|
||||
else if (aStatus == 2152857609)
|
||||
dump("***** status is INVALID_PATH\n");
|
||||
dump("***** status is INVALID_PATH\n");
|
||||
else if (aStatus == 2152857610)
|
||||
dump("***** status is DISK_FULL\n");
|
||||
dump("***** status is DISK_FULL\n");
|
||||
else if (aStatus == 2152857612)
|
||||
dump("***** status is NOT_DIRECTORY\n");
|
||||
dump("***** status is NOT_DIRECTORY\n");
|
||||
else if (aStatus == 2152857613)
|
||||
dump("***** status is IS_DIRECTORY\n");
|
||||
dump("***** status is IS_DIRECTORY\n");
|
||||
else if (aStatus == 2152857614)
|
||||
dump("***** status is IS_LOCKED\n");
|
||||
dump("***** status is IS_LOCKED\n");
|
||||
else if (aStatus == 2152857615)
|
||||
dump("***** status is TOO_BIG\n");
|
||||
dump("***** status is TOO_BIG\n");
|
||||
else if (aStatus == 2152857616)
|
||||
dump("***** status is NO_DEVICE_SPACE\n");
|
||||
dump("***** status is NO_DEVICE_SPACE\n");
|
||||
else if (aStatus == 2152857617)
|
||||
dump("***** status is NAME_TOO_LONG\n");
|
||||
else if (aStatus == 2152857618) // 0x80520012
|
||||
dump("***** status is FILE_NOT_FOUND\n");
|
||||
dump("***** status is NAME_TOO_LONG\n");
|
||||
else if (aStatus == 2152857618) // 80520012
|
||||
dump("***** status is FILE_NOT_FOUND\n");
|
||||
else if (aStatus == 2152857619)
|
||||
dump("***** status is READ_ONLY\n");
|
||||
dump("***** status is READ_ONLY\n");
|
||||
else if (aStatus == 2152857620)
|
||||
dump("***** status is DIR_NOT_EMPTY\n");
|
||||
dump("***** status is DIR_NOT_EMPTY\n");
|
||||
else if (aStatus == 2152857621)
|
||||
dump("***** status is ACCESS_DENIED\n");
|
||||
dump("***** status is ACCESS_DENIED\n");
|
||||
else if (aStatus == 2152398878)
|
||||
dump("***** status is ? (No connection or time out?)\n");
|
||||
else
|
||||
dump("***** status is " + aStatus + "\n");
|
||||
dump("***** status is " + aStatus + "\n");
|
||||
}
|
||||
|
||||
// Update any data that the user supplied in a prompt dialog
|
||||
|
||||
@@ -54,13 +54,24 @@ BeforeValidate=before validating the document
|
||||
# LOCALIZATION NOTE (SaveFilePrompt): Don't translate %title% and %reason% (this is the reason for asking user to close, such as "before closing")
|
||||
SaveFilePrompt=Save changes to "%title%" %reason%?
|
||||
SaveFileFailed=Saving file failed!
|
||||
PublishFailed=Publishing failed!
|
||||
PublishNoAccess=No access to
|
||||
# LOCALIZATION NOTE (PublishDirFailed): Don't translate %dir%
|
||||
PublishDirFailed=%dir% doesn't exist at this site
|
||||
PublishCompleted=Publishing completed
|
||||
PublishSomeFileFailed=Some files failed to publish
|
||||
PublishFTPUsernamePrompt=Please supply both user name and password when using FTP to publish.
|
||||
|
||||
# Publishing error strings:
|
||||
# LOCALIZATION NOTE Don't translate %dir% or %file% in the Publishing error strings:
|
||||
FileNotFound=%file% not found.
|
||||
SubdirDoesNotExist=The subdirectory "%dir%" doesn't exist on this site or the filename "%file%" is already in use by another subdirectory.
|
||||
FilenameIsSubdir=The filename "%file%" is already in use by another subdirectory.
|
||||
ServerNotAvailable=The server is not available. Check your connection and try again later.
|
||||
Offline=You are currently offline. Click the icon near the lower-right corner of any window to go online.
|
||||
DiskFull=There is not enough disk space available to save the file "%file%."
|
||||
NameTooLong=The filename or subdirectory name is too long.
|
||||
AccessDenied=You do not have permission to publish to this location.
|
||||
UnknownPublishError=Unknown publishing error occurred.
|
||||
PublishFailed=Publishing failed.
|
||||
PublishCompleted=Publishing completed.
|
||||
AllFilesPublished=All files published
|
||||
# LOCALIZATION NOTE Don't translate %x% or %total%
|
||||
FailedFileMsg=%x% of %total% files failed to publish.
|
||||
# End-Publishing error strings
|
||||
Prompt=Prompt
|
||||
# LOCALIZATION NOTE (PromptFTPUsernamePassword): Don't translate %host%
|
||||
PromptFTPUsernamePassword=Enter username and password for FTP server at %host%
|
||||
@@ -71,7 +82,7 @@ Send=Send
|
||||
## LOCALIZATION NOTE (PublishProgressCaption, PublishToSite, AbandonChanges): Don't translate %title%
|
||||
PublishProgressCaption=Publishing: %title%
|
||||
PublishToSite=Publishing to Site: %title%
|
||||
AbandonChanges=Abandon unsaved changes to %title% and reload page?
|
||||
AbandonChanges=Abandon unsaved changes to "%title%" and reload page?
|
||||
DocumentTitle=Page Title
|
||||
NeedDocTitle=Please enter a title for the current page.
|
||||
DocTitleHelp=This identifies the page in the window title and bookmarks.
|
||||
|
||||
@@ -26,12 +26,56 @@ var gPublishData;
|
||||
var gPersistObj;
|
||||
var gTotalFileCount = 0;
|
||||
var gSucceededCount = 0;
|
||||
var gFinishedCount = 0;
|
||||
var gFinished = false;
|
||||
var gFinalMessage="";
|
||||
var gPublishingFailed = false;
|
||||
var gFileNotFound = false;
|
||||
var gStatusMessage="";
|
||||
|
||||
var gTimerID;
|
||||
var gAllowEnterKey = false;
|
||||
|
||||
// Publishing error codes
|
||||
// These are translated from C++ error code strings like this:
|
||||
// kFileNotFound = "FILE_NOT_FOUND",
|
||||
const kNetReset = 2152398868; // nsISocketTransportService.idl
|
||||
const kFileNotFound = 2152857618;
|
||||
const kNotConnected = 2152398860; // in netCore.h
|
||||
const kConnectionRefused = 2152398861; // nsISocketTransportService.idl
|
||||
const kNetTimeout = 2152398862; // nsISocketTransportService.idl
|
||||
const kNoConnectionOrTimeout = 2152398878;
|
||||
const kPortAccessNotAllowed = 2152398867; // netCore.h
|
||||
const kOffline = 2152398865; // netCore.h
|
||||
const kDiskFull = 2152857610;
|
||||
const kNoDeviceSpace = 2152857616;
|
||||
const kNameTooLong = 2152857617;
|
||||
const kAccessDenied = 2152857621;
|
||||
|
||||
// These are more errors that I don't think we encounter during publishing,
|
||||
// so we don't have error strings yet. Let's keep them here for future reference
|
||||
//const kUnrecognizedPath = 2152857601;
|
||||
//const kUnresolvableSymlink = 2152857602;
|
||||
//const kUnknownType = 2152857604;
|
||||
//const kDestinationNotDir = 2152857605;
|
||||
//const kTargetDoesNotExist = 2152857606;
|
||||
//const kAlreadyExists = 2152857608;
|
||||
//const kInvalidPath = 2152857609;
|
||||
//const kNotDirectory = 2152857612;
|
||||
//const kIsDirectory = 2152857613;
|
||||
//const kIsLocked = 2152857614;
|
||||
//const kTooBig = 2152857615;
|
||||
//const kReadOnly = 2152857619;
|
||||
//const kDirectoryNotEmpty = 2152857620;
|
||||
//const kErrorBindingRedirected = 2152398851;
|
||||
//const kAlreadyConnected = 2152398859; // in netCore.h
|
||||
//const kInProgress = 2152398863; // netCore.h
|
||||
//const kNoContent = 2152398865; // netCore.h
|
||||
//const kUnknownProtocol = 2152398866 // netCore.h
|
||||
//const kFtpLogin = 2152398869; // ftpCore.h
|
||||
//const kFtpCWD = 2152398870; // ftpCore.h
|
||||
//const kFtpPasv = 2152398871; // ftpCore.h
|
||||
//const kFtpPwd = 2152398872; // ftpCore.h
|
||||
|
||||
|
||||
function Startup()
|
||||
{
|
||||
if (!InitEditorShell())
|
||||
@@ -45,10 +89,11 @@ function Startup()
|
||||
return;
|
||||
}
|
||||
|
||||
gDialog.FileList = document.getElementById("FileList");
|
||||
gDialog.StatusMessage = document.getElementById("StatusMessage");
|
||||
gDialog.KeepOpen = document.getElementById("KeepOpen");
|
||||
gDialog.Close = document.documentElement.getButton("cancel");
|
||||
gDialog.FileList = document.getElementById("FileList");
|
||||
gDialog.FinalStatusMessage = document.getElementById("FinalStatusMessage");
|
||||
gDialog.StatusMessage = document.getElementById("StatusMessage");
|
||||
gDialog.KeepOpen = document.getElementById("KeepOpen");
|
||||
gDialog.Close = document.documentElement.getButton("cancel");
|
||||
|
||||
SetWindowLocation();
|
||||
window.title = GetString("PublishProgressCaption").replace(/%title%/, editorShell.GetDocumentTitle());
|
||||
@@ -148,42 +193,109 @@ function SetProgressStatus(filename, status)
|
||||
|
||||
function SetProgressFinished(filename, networkStatus)
|
||||
{
|
||||
var abortPublishing = false;
|
||||
if (filename)
|
||||
{
|
||||
var status = networkStatus ? "failed" : "done";
|
||||
if (networkStatus == 0)
|
||||
gSucceededCount++;
|
||||
|
||||
if (SetProgressStatus(filename, status))
|
||||
gFinishedCount++;
|
||||
SetProgressStatus(filename, status);
|
||||
}
|
||||
|
||||
if (networkStatus != 0)
|
||||
if (networkStatus != 0) // Error condition
|
||||
{
|
||||
// XXX Interpret networkStatus and call SetStatusMessage() with
|
||||
// appropriate error description.
|
||||
if (!gPublishData.publishOtherFiles || filename == gPublishData.filename)
|
||||
gFinalMessage = GetString("PublishFailed");
|
||||
else
|
||||
gFinalMessage = GetString("PublishSomeFileFailed");
|
||||
// We abort on all errors except if image file was not found
|
||||
abortPublishing = networkStatus != kFileNotFound;
|
||||
|
||||
// Mark all remaining files as "failed"
|
||||
if (abortPublishing)
|
||||
{
|
||||
gPublishingFailed = true;
|
||||
SetProgressStatusCancel();
|
||||
gDialog.FinalStatusMessage.value = GetString("PublishFailed");
|
||||
}
|
||||
|
||||
switch (networkStatus)
|
||||
{
|
||||
case kFileNotFound:
|
||||
gFileNotFound = true;
|
||||
if (filename)
|
||||
gStatusMessage = GetString("FileNotFound").replace(/%file%/, filename);
|
||||
break;
|
||||
case kNetReset:
|
||||
// We get this when subdir doesn't exist AND
|
||||
// if filename used is same as an existing subdir
|
||||
var dir = (gPublishData.filename == filename) ?
|
||||
gPublishData.docDir : gPublishData.otherDir;
|
||||
|
||||
if (dir)
|
||||
{
|
||||
// This is the ambiguous case when we can't tell if subdir or filename is bad
|
||||
// Remove terminal "/" from dir string and insert into message
|
||||
gStatusMessage = GetString("SubdirDoesNotExist").replace(/%dir%/, dir.slice(0, dir.length-1));
|
||||
gStatusMessage = gStatusMessage.replace(/%file%/, filename);
|
||||
|
||||
// Remove directory from saved prefs
|
||||
// XXX Note that if subdir is good,
|
||||
// but filename = next level subdirectory name,
|
||||
// we really shouldn't remove subdirectory,
|
||||
// but it's impossible to differentiate this case!
|
||||
RemovePublishSubdirectoryFromPrefs(gPublishData, dir);
|
||||
}
|
||||
else if (filename)
|
||||
gStatusMessage = GetString("FilenameIsSubdir").replace(/%file%/, filename);
|
||||
|
||||
break;
|
||||
case kNotConnected:
|
||||
case kConnectionRefused:
|
||||
case kNetTimeout:
|
||||
case kNoConnectionOrTimeout:
|
||||
case kPortAccessNotAllowed:
|
||||
gStatusMessage = GetString("ServerNotAvailable");
|
||||
break;
|
||||
case kOffline:
|
||||
gStatusMessage = GetString("Offline");
|
||||
break;
|
||||
case kDiskFull:
|
||||
case kNoDeviceSpace:
|
||||
if (filename)
|
||||
gStatusMessage = GetString("DiskFull").replace(/%file%/, filename);
|
||||
break;
|
||||
case kNameTooLong:
|
||||
if (filename)
|
||||
gStatusMessage = GetString("NameTooLong").replace(/%file%/, filename);
|
||||
break;
|
||||
case kAccessDenied:
|
||||
if (filename)
|
||||
gStatusMessage = GetString("AccessDenied").replace(/%file%/, filename);
|
||||
break;
|
||||
case kUnknownType:
|
||||
default:
|
||||
gStatusMessage = GetString("UnknownPublishError")
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (gFinishedCount == gTotalFileCount || !filename)
|
||||
else if (!filename)
|
||||
{
|
||||
gFinished = true;
|
||||
gDialog.Close.setAttribute("label", GetString("Close"));
|
||||
gFinalMessage = GetString("PublishCompleted");
|
||||
if (!gStatusMessage)
|
||||
gStatusMessage = GetString(gPublishingFailed ? "UnknownPublishError" : "AllFilesPublished");
|
||||
|
||||
// Now allow "Enter/Return" key to close the dialog
|
||||
AllowDefaultButton();
|
||||
}
|
||||
if (gFinalMessage)
|
||||
SetStatusMessage(gFinalMessage);
|
||||
}
|
||||
|
||||
function SetStatusMessage(message)
|
||||
{
|
||||
gDialog.StatusMessage.value = message;
|
||||
window.sizeToContent();
|
||||
if (gPublishingFailed || gFileNotFound)
|
||||
{
|
||||
// Show "Troubleshooting" button to help solving problems
|
||||
// and key for successful / failed files
|
||||
document.getElementById("failureBox").hidden = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (gStatusMessage)
|
||||
SetStatusMessage(gStatusMessage);
|
||||
}
|
||||
|
||||
function CheckKeepOpen()
|
||||
@@ -222,6 +334,11 @@ function AllowDefaultButton()
|
||||
gAllowEnterKey = true;
|
||||
}
|
||||
|
||||
function doTroubleshooting()
|
||||
{
|
||||
openHelp("comp-doc-publish-troubleshooting");
|
||||
}
|
||||
|
||||
function onEnterKey()
|
||||
{
|
||||
if (gAllowEnterKey)
|
||||
@@ -237,12 +354,42 @@ function RequestCloseDialog()
|
||||
// Leave window open a minimum amount of time
|
||||
gTimerID = setTimeout("CloseDialog();", 3000);
|
||||
}
|
||||
// Finish progress messages, settings buttons etc.
|
||||
SetProgressFinished(null,0);
|
||||
|
||||
// Now allow "Enter/Return" key to close the dialog
|
||||
AllowDefaultButton();
|
||||
// Set "completed" message if we succeeded
|
||||
// (Some image files may have failed,
|
||||
// but we don't abort publishing for that)
|
||||
if (!gPublishingFailed)
|
||||
{
|
||||
gDialog.FinalStatusMessage.value = GetString("PublishCompleted");
|
||||
if (gFileNotFound && gTotalFileCount-gSucceededCount)
|
||||
{
|
||||
// Show number of files that failed to upload
|
||||
gStatusMessage =
|
||||
(GetString("FailedFileMsg").replace(/%x%/,(gTotalFileCount-gSucceededCount)))
|
||||
.replace(/%total%/,gTotalFileCount);
|
||||
|
||||
// If window remains open, be sure final message is set
|
||||
SetStatusMessage(gFinalMessage);
|
||||
SetStatusMessage(gStatusMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function SetStatusMessage(message)
|
||||
{
|
||||
// Status message is a child of <description> element
|
||||
// so text can wrap to multiple lines if necessary
|
||||
if (gDialog.StatusMessage.firstChild)
|
||||
{
|
||||
gDialog.StatusMessage.firstChild.data = message;
|
||||
}
|
||||
else
|
||||
{
|
||||
var textNode = document.createTextNode(message);
|
||||
if (textNode)
|
||||
gDialog.StatusMessage.appendChild(textNode);
|
||||
}
|
||||
window.sizeToContent();
|
||||
}
|
||||
|
||||
function CloseDialog()
|
||||
@@ -253,4 +400,3 @@ function CloseDialog()
|
||||
window.close();
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,9 +39,11 @@
|
||||
|
||||
<!-- Methods common to all editor dialogs -->
|
||||
<script type="application/x-javascript" src="chrome://editor/content/editorUtilities.js"/>
|
||||
<script type="application/x-javascript" src="chrome://editor/content/publishprefs.js"/>
|
||||
<script type="application/x-javascript" src="chrome://editor/content/EdDialogCommon.js"/>
|
||||
<script type="application/x-javascript" src="chrome://editor/content/EditorPublishProgress.js"/>
|
||||
<script type="application/x-javascript" src="chrome://global/content/dialogOverlay.js" />
|
||||
<script type="application/x-javascript" src="chrome://help/content/contextHelp.js"/>
|
||||
|
||||
<spacer id="location" offsetY="50" persist="offsetX offsetY"/>
|
||||
<broadcaster id="args" value=""/>
|
||||
@@ -70,20 +72,20 @@
|
||||
</groupbox>
|
||||
<groupbox>
|
||||
<caption><label value="&fileList.label;"/></caption>
|
||||
<vbox align="center" style="max-width:60em">
|
||||
<label id="StatusMessage" class="bold" value="&status.label;"/>
|
||||
<vbox align="center" style="max-width:30em">
|
||||
<label id="FinalStatusMessage" class="bold" value="&status.label;"/>
|
||||
</vbox>
|
||||
<description id="StatusMessage" class="wrap" style="max-width:30em; min-height: 1em"/>
|
||||
<vbox flex="1">
|
||||
<listbox id="FileList" rows="1"/>
|
||||
</vbox>
|
||||
<hbox align="center">
|
||||
<spacer class="bigspacer"/>
|
||||
<hbox align="center" id="failureBox" hidden="true">
|
||||
<image class="progressitem" progress="done"/>
|
||||
<label value="&succeeded.label;"/>
|
||||
<spacer class="bigspacer"/>
|
||||
<spacer class="bigspacer"/>
|
||||
<image class="progressitem" progress="failed"/>
|
||||
<label value="&failed.label;"/>
|
||||
<button label="&troubleshooting.label;" accesskey="&troubleshooting.accessKey;" oncommand="doTroubleshooting();"/>
|
||||
</hbox>
|
||||
</groupbox>
|
||||
<checkbox id="KeepOpen" label="&keepOpen;" oncommand="CheckKeepOpen();" persist="checked"/>
|
||||
|
||||
@@ -32,4 +32,7 @@
|
||||
<!ENTITY filenameHeader.label "Filename">
|
||||
<!ENTITY succeeded.label "Succeeded">
|
||||
<!ENTITY failed.label "Failed">
|
||||
<!ENTITY troubleshooting.label "Troubleshooting">
|
||||
<!ENTITY troubleshooting.accessKey "T">
|
||||
|
||||
<!ENTITY keepOpen "Keep this window open after publishing is complete.">
|
||||
|
||||
Reference in New Issue
Block a user