Bug 128905 nsIPromptService.idl confirmEx is poorly prototyped

[api] change confirmEx from void w/ out of buttonPressed to PRInt32 buttonPressed w/ one less parameter.
fixes and cleans up callers
r=ccarlen sr=scc a=asa
This commit is contained in:
timeless%mac.com 2002-04-05 08:13:27 +00:00
Родитель d6081dd2fc
Коммит dda079660d
12 изменённых файлов: 117 добавлений и 164 удалений

Просмотреть файл

@ -1102,18 +1102,18 @@ var gEditorOutputProgressListener =
if (!promptServ)
return;
promptServ.confirmEx(window, dlgTitle, text, nsIPromptService.STD_OK_CANCEL_BUTTONS,
"", "", "", checkBoxLabel, checkObj, outButtonPressed);
outButtonPressed = promptServ.confirmEx(window, dlgTitle, text, nsIPromptService.STD_OK_CANCEL_BUTTONS,
"", "", "", checkBoxLabel, checkObj);
},
confirmEx : function(dlgTitle, text, btnFlags, btn0Title, btn1Title, btn2Title, checkBoxLabel, checkVal, outBtnPressed)
confirmEx : function(dlgTitle, text, btnFlags, btn0Title, btn1Title, btn2Title, checkBoxLabel, checkVal)
{
var promptServ = GetPromptService();
if (!promptServ)
return;
promptServ.confirmEx(window, dlgTitle, text, btnFlags,
return promptServ.confirmEx(window, dlgTitle, text, btnFlags,
btn0Title, btn1Title, btn2Title,
checkBoxLabel, checkVal, outBtnPressed);
checkBoxLabel, checkVal);
},
prompt : function(dlgTitle, text, inoutText, checkBoxLabel, checkObj)
{
@ -1773,10 +1773,10 @@ var nsRevertCommand =
var msg = GetString("AbandonChanges").replace(/%title%/,title);
promptService.confirmEx(window, GetString("RevertCaption"), msg,
result = promptService.confirmEx(window, GetString("RevertCaption"), msg,
(promptService.BUTTON_TITLE_REVERT * promptService.BUTTON_POS_0) +
(promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1),
null, null, null, null, {value:0}, result);
null, null, null, null, {value:0});
// Reload page if first button (Revert) was pressed
if(result.value == 0)

Просмотреть файл

@ -511,9 +511,11 @@ function CheckAndSaveDocument(command, allowDontSave)
promptFlags += doPublish ?
(promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_2)
: (promptService.BUTTON_TITLE_DONT_SAVE * promptService.BUTTON_POS_2);
promptService.confirmEx(window, dialogTitle, dialogMsg, promptFlags,
button1Title, null, button3Title, null, {value:0}, result);
result = promptService.confirmEx(
window, dialogTitle, dialogMsg, promptFlags,
button1Title, null, button3Title, null, {value:0}
);
if (result.value == 0)
{

Просмотреть файл

@ -74,15 +74,13 @@ function ConfirmWithTitle(title, message, okButtonText, cancelButtonText)
if (promptService)
{
var result = {value:0};
var okFlag = okButtonText ? promptService.BUTTON_TITLE_IS_STRING : promptService.BUTTON_TITLE_OK;
var cancelFlag = cancelButtonText ? promptService.BUTTON_TITLE_IS_STRING : promptService.BUTTON_TITLE_CANCEL;
promptService.confirmEx(window, title, message,
return promptService.confirmEx(window, title, message,
(okFlag * promptService.BUTTON_POS_0) +
(cancelFlag * promptService.BUTTON_POS_1),
okButtonText, cancelButtonText, null, null, {value:0}, result);
return (result.value == 0);
okButtonText, cancelButtonText, null, null, {value:0}) == 0;
}
return false;
}

Просмотреть файл

@ -100,7 +100,7 @@ interface nsIPromptService : nsISupports
* @param button2Title Used when button 2 uses TITLE_IS_STRING
* @param checkMsg null if no checkbox
* @param checkValue
* @param buttonPressed
* @return buttonPressed
*
* Buttons are numbered 0 - 2. The implementation can decide whether
* the sequence goes from right to left or left to right.
@ -132,7 +132,7 @@ interface nsIPromptService : nsISupports
const unsigned long STD_OK_CANCEL_BUTTONS = (BUTTON_TITLE_OK * BUTTON_POS_0) +
(BUTTON_TITLE_CANCEL * BUTTON_POS_1);
void confirmEx(in nsIDOMWindow parent,
PRInt32 confirmEx(in nsIDOMWindow parent,
in wstring dialogTitle,
in wstring text,
in unsigned long buttonFlags,
@ -140,8 +140,7 @@ interface nsIPromptService : nsISupports
in wstring button1Title,
in wstring button2Title,
in wstring checkMsg,
inout boolean checkValue,
out PRInt32 buttonPressed);
inout boolean checkValue);
/**
* Puts up a dialog with an edit field and an optional checkbox.

Просмотреть файл

@ -156,16 +156,14 @@ function onCancel()
if (accountCount < 1) {
var confirmMsg = gPrefsBundle.getString("cancelWizard");
var confirmTitle = gPrefsBundle.getString("accountWizard");
var result = {value:0};
promptService.confirmEx(window, confirmTitle, confirmMsg,
var result = promptService.confirmEx(window, confirmTitle, confirmMsg,
(promptService.BUTTON_TITLE_IS_STRING*promptService.BUTTON_POS_0)+
(promptService.BUTTON_TITLE_IS_STRING*promptService.BUTTON_POS_1),
gPrefsBundle.getString('WizardExit'),
gPrefsBundle.getString('WizardContinue'),
null, null, {value:0}, result);
null, null, {value:0});
if (result.value == 1)
if (result == 1)
closeWizard = false;
}

Просмотреть файл

@ -97,46 +97,32 @@ function PromptSendMessages()
InitServices();
if (gPromptService) {
var buttonPressed = {value:0};
var checkValue = {value:true};
gPromptService.confirmEx(window,
gOfflinePromptsBundle.getString('sendMessagesWindowTitle'),
gOfflinePromptsBundle.getString('sendMessagesLabel'),
(gPromptService.BUTTON_TITLE_IS_STRING * gPromptService.BUTTON_POS_0) +
(gPromptService.BUTTON_TITLE_IS_STRING * gPromptService.BUTTON_POS_2) +
(gPromptService.BUTTON_TITLE_IS_STRING * gPromptService.BUTTON_POS_1),
gOfflinePromptsBundle.getString('sendMessagesSendButtonLabel'),
gOfflinePromptsBundle.getString('sendMessagesCancelButtonLabel'),
gOfflinePromptsBundle.getString('sendMessagesNoSendButtonLabel'),
gOfflinePromptsBundle.getString('sendMessagesCheckboxLabel'),
checkValue, buttonPressed);
if(buttonPressed) {
if(buttonPressed.value == 0) {
if(checkValue.value)
gMailOfflinePrefs.setIntPref("offline.send.unsent_messages", 0);
else
gMailOfflinePrefs.setIntPref("offline.send.unsent_messages", 1);
gOfflineManager.goOnline(true /* sendUnsentMessages */,
true /* playbackOfflineImapOperations */,
msgWindow);
return true;
}
else if(buttonPressed.value == 1) {
return false;
}
else if(buttonPressed.value == 2) {
if(checkValue.value)
gMailOfflinePrefs.setIntPref("offline.send.unsent_messages", 0);
else
gMailOfflinePrefs.setIntPref("offline.send.unsent_messages", 2);
gOfflineManager.goOnline(false /* sendUnsentMessages */,
true /* playbackOfflineImapOperations */,
msgWindow);
return true;
}
var buttonPressed = gPromptService.confirmEx(window,
gOfflinePromptsBundle.getString('sendMessagesWindowTitle'),
gOfflinePromptsBundle.getString('sendMessagesLabel'),
gPromptService.BUTTON_TITLE_IS_STRING * (gPromptService.BUTTON_POS_0 +
gPromptService.BUTTON_POS_1 + gPromptService.BUTTON_POS_2),
gOfflinePromptsBundle.getString('sendMessagesSendButtonLabel'),
gOfflinePromptsBundle.getString('sendMessagesCancelButtonLabel'),
gOfflinePromptsBundle.getString('sendMessagesNoSendButtonLabel'),
gOfflinePromptsBundle.getString('sendMessagesCheckboxLabel'),
checkValue);
if(buttonPressed == 0) {
gMailOfflinePrefs.setIntPref("offline.send.unsent_messages", !checkValue.value);
gOfflineManager.goOnline(true, true, msgWindow);
return true;
}
if(buttonPressed == 1) {
return false;
}
if(buttonPressed == 2) {
gMailOfflinePrefs.setIntPref("offline.send.unsent_messages", 2*!checkValue.value);
gOfflineManager.goOnline(false, true, msgWindow);
return true;
}
}
return false;
}
// prompt for downlading messages while going offline, and synchronise
@ -146,43 +132,32 @@ function PromptDownloadMessages()
InitServices();
if(gPromptService) {
var buttonPressed = {value:0};
var checkValue = {value:true};
gPromptService.confirmEx(window,
gOfflinePromptsBundle.getString('downloadMessagesWindowTitle'),
gOfflinePromptsBundle.getString('downloadMessagesLabel'),
(gPromptService.BUTTON_TITLE_IS_STRING * gPromptService.BUTTON_POS_0) +
(gPromptService.BUTTON_TITLE_IS_STRING * gPromptService.BUTTON_POS_2) +
(gPromptService.BUTTON_TITLE_IS_STRING * gPromptService.BUTTON_POS_1),
gOfflinePromptsBundle.getString('downloadMessagesDownloadButtonLabel'),
gOfflinePromptsBundle.getString('downloadMessagesCancelButtonLabel'),
gOfflinePromptsBundle.getString('downloadMessagesNoDownloadButtonLabel'),
gOfflinePromptsBundle.getString('downloadMessagesCheckboxLabel'),
checkValue, buttonPressed);
if(buttonPressed) {
if(buttonPressed.value == 0) {
if(checkValue.value)
gMailOfflinePrefs.setIntPref("offline.download.download_messages", 0);
else
gMailOfflinePrefs.setIntPref("offline.download.download_messages", 1);
// download news, download mail, send unsent messages, go offline when done, msg window
gOfflineManager.synchronizeForOffline(true, true, false, true, msgWindow);
return true;
}
else if(buttonPressed.value == 1) {
return false;
}
else if(buttonPressed.value == 2) {
if(checkValue.value)
gMailOfflinePrefs.setIntPref("offline.download.download_messages", 0);
else
gMailOfflinePrefs.setIntPref("offline.download.download_messages", 2);
// download news, download mail, send unsent messages, go offline when done, msg window
gOfflineManager.synchronizeForOffline(false, false, false, true, msgWindow);
return true;
}
var buttonPressed = gPromptService.confirmEx(window,
gOfflinePromptsBundle.getString('downloadMessagesWindowTitle'),
gOfflinePromptsBundle.getString('downloadMessagesLabel'),
gPromptService.BUTTON_TITLE_IS_STRING * (gPromptService.BUTTON_POS_0 +
gPromptService.BUTTON_POS_1 + gPromptService.BUTTON_POS_2),
gOfflinePromptsBundle.getString('downloadMessagesDownloadButtonLabel'),
gOfflinePromptsBundle.getString('downloadMessagesCancelButtonLabel'),
gOfflinePromptsBundle.getString('downloadMessagesNoDownloadButtonLabel'),
gOfflinePromptsBundle.getString('downloadMessagesCheckboxLabel'),
checkValue);
if(buttonPressed == 0) {
gMailOfflinePrefs.setIntPref("offline.download.download_messages", !checkValue.value);
gOfflineManager.synchronizeForOffline(true, true, false, true, msgWindow);
return true;
}
if(buttonPressed == 1) {
return false;
}
if(buttonPressed == 2) {
gMailOfflinePrefs.setIntPref("offline.download.download_messages", 2*!checkValue.value);
gOfflineManager.synchronizeForOffline(false, false, false, true, msgWindow);
return true;
}
}
return false;
}
// online?

Просмотреть файл

@ -1399,41 +1399,37 @@ function InitPrompts()
// prompt for getting messages when offline
function PromptGetMessagesOffline()
{
var buttonPressed = false;
InitPrompts();
if (gPromptService) {
var buttonPressed = {value:0};
var checkValue = {value:false};
gPromptService.confirmEx(window,
buttonPressed = gPromptService.confirmEx(window,
gOfflinePromptsBundle.getString('getMessagesOfflineWindowTitle'),
gOfflinePromptsBundle.getString('getMessagesOfflineLabel'),
(gPromptService.BUTTON_TITLE_IS_STRING * gPromptService.BUTTON_POS_0) +
(gPromptService.BUTTON_TITLE_CANCEL * gPromptService.BUTTON_POS_1),
gOfflinePromptsBundle.getString('getMessagesOfflineGoButtonLabel'),
null, null, null, checkValue, buttonPressed);
if(buttonPressed) {
return buttonPressed.value;
}
null, null, null, checkValue);
}
return buttonPressed;
}
// prompt for sending messages when offline
function PromptSendMessagesOffline()
{
var buttonPressed = false;
InitPrompts();
if (gPromptService) {
var buttonPressed = {value:0};
var checkValue= {value:false};
gPromptService.confirmEx(window,
buttonPressed = gPromptService.confirmEx(window,
gOfflinePromptsBundle.getString('sendMessagesOfflineWindowTitle'),
gOfflinePromptsBundle.getString('sendMessagesOfflineLabel'),
(gPromptService.BUTTON_TITLE_IS_STRING * gPromptService.BUTTON_POS_0) +
(gPromptService.BUTTON_TITLE_CANCEL * gPromptService.BUTTON_POS_1),
gOfflinePromptsBundle.getString('sendMessagesOfflineGoButtonLabel'),
null, null, null, checkValue, buttonPressed);
if(buttonPressed) {
return buttonPressed.value;
}
}
return buttonPressed;
}
function GetFolderMessages()

Просмотреть файл

@ -1716,9 +1716,8 @@ function SendMessageWithCheck()
var warn = sPrefs.getBoolPref("mail.warn_on_send_accel_key");
if (warn) {
var buttonPressed = {value:1};
var checkValue = {value:false};
gPromptService.confirmEx(window,
var buttonPressed = gPromptService.confirmEx(window,
sComposeMsgsBundle.getString('sendMessageCheckWindowTitle'),
sComposeMsgsBundle.getString('sendMessageCheckLabel'),
(gPromptService.BUTTON_TITLE_IS_STRING * gPromptService.BUTTON_POS_0) +
@ -1726,8 +1725,8 @@ function SendMessageWithCheck()
sComposeMsgsBundle.getString('sendMessageCheckSendButtonLabel'),
null, null,
sComposeMsgsBundle.getString('CheckMsg'),
checkValue, buttonPressed);
if (!buttonPressed || buttonPressed.value != 0) {
checkValue);
if (buttonPressed != 0) {
return;
}
if (checkValue.value) {
@ -2010,31 +2009,27 @@ function ComposeCanClose()
{
if (gSendOrSaveOperationInProgress)
{
var result;
var result;
if (gPromptService)
{
var promptTitle = sComposeMsgsBundle.getString("quitComposeWindowTitle");
var promptMsg = sComposeMsgsBundle.getString("quitComposeWindowMessage");
var quitButtonLabel = sComposeMsgsBundle.getString("quitComposeWindowQuitButtonLabel");
var waitButtonLabel = sComposeMsgsBundle.getString("quitComposeWindowWaitButtonLabel");
if (gPromptService)
{
var promptTitle = sComposeMsgsBundle.getString("quitComposeWindowTitle");
var promptMsg = sComposeMsgsBundle.getString("quitComposeWindowMessage");
var quitButtonLabel = sComposeMsgsBundle.getString("quitComposeWindowQuitButtonLabel");
var waitButtonLabel = sComposeMsgsBundle.getString("quitComposeWindowWaitButtonLabel");
result = {value:0};
gPromptService.confirmEx(window, promptTitle, promptMsg,
result = gPromptService.confirmEx(window, promptTitle, promptMsg,
(gPromptService.BUTTON_TITLE_IS_STRING*gPromptService.BUTTON_POS_0) +
(gPromptService.BUTTON_TITLE_IS_STRING*gPromptService.BUTTON_POS_1),
waitButtonLabel, quitButtonLabel, null, null, {value:0}, result);
waitButtonLabel, quitButtonLabel, null, null, {value:0});
if (result.value == 1)
{
gMsgCompose.abort();
return true;
}
else
{
return false;
}
if (result == 1)
{
gMsgCompose.abort();
return true;
}
return false;
}
}
dump("XXX changed? " + gContentChanged + "," + gMsgCompose.bodyModified + "\n");
@ -2046,31 +2041,26 @@ function ComposeCanClose()
window.focus();
if (gPromptService)
{
result = {value:0};
gPromptService.confirmEx(window,
result = gPromptService.confirmEx(window,
sComposeMsgsBundle.getString("saveDlogTitle"),
sComposeMsgsBundle.getString("saveDlogMessage"),
(gPromptService.BUTTON_TITLE_SAVE * gPromptService.BUTTON_POS_0) +
(gPromptService.BUTTON_TITLE_CANCEL * gPromptService.BUTTON_POS_1) +
(gPromptService.BUTTON_TITLE_DONT_SAVE * gPromptService.BUTTON_POS_2),
null, null, null,
null, {value:0}, result);
if (result)
null, {value:0});
switch (result)
{
switch (result.value)
{
case 0: //Save
if (LastToClose())
NotifyQuitApplication();
gCloseWindowAfterSave = true;
SaveAsDraft();
return false;
case 1: //Cancel
return false;
case 2: //Don't Save
break;
}
case 0: //Save
if (LastToClose())
NotifyQuitApplication();
gCloseWindowAfterSave = true;
SaveAsDraft();
return false;
case 1: //Cancel
return false;
case 2: //Don't Save
break;
}
}

Просмотреть файл

@ -85,15 +85,14 @@ interface nsIPrompt : nsISupports
const unsigned long STD_OK_CANCEL_BUTTONS = (BUTTON_TITLE_OK * BUTTON_POS_0) +
(BUTTON_TITLE_CANCEL * BUTTON_POS_1);
void confirmEx(in wstring dialogTitle,
PRInt32 confirmEx(in wstring dialogTitle,
in wstring text,
in unsigned long buttonFlags,
in wstring button0Title,
in wstring button1Title,
in wstring button2Title,
in wstring checkMsg,
inout boolean checkValue,
out PRInt32 buttonPressed);
inout boolean checkValue);
boolean prompt(in wstring dialogTitle,
in wstring text,

Просмотреть файл

@ -162,17 +162,16 @@ function ConfirmDelete()
if (pathExists) {
dialogText = gProfileManagerBundle.getFormattedString("deleteprofile", [path]);
dialogText = dialogText.replace(/\s*<html:br\/>/g,"\n");
var buttonPressed = {value:0}
promptService.confirmEx(window, dialogTitle, dialogText,
var buttonPressed = promptService.confirmEx(window, dialogTitle, dialogText,
(promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_0) +
(promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1) +
(promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_2),
gProfileManagerBundle.getString("dontDeleteFiles"),
null,
gProfileManagerBundle.getString("deleteFiles"),
null, {value:0}, buttonPressed);
if (buttonPressed.value != 1)
DeleteProfile(buttonPressed.value == 2);
null, {value:0});
if (buttonPressed != 1)
DeleteProfile(buttonPressed == 2);
}
else
DeleteProfile(false);

Просмотреть файл

@ -369,17 +369,15 @@ var homeButtonObserver = {
function openHomeDialog(aURL)
{
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
var pressedVal = { };
var promptTitle = gNavigatorBundle.getString("droponhometitle");
var promptMsg = gNavigatorBundle.getString("droponhomemsg");
var okButton = gNavigatorBundle.getString("droponhomeokbutton");
promptService.confirmEx(window, promptTitle, promptMsg,
var pressedVal = promptService.confirmEx(window, promptTitle, promptMsg,
(promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_0) +
(promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1),
okButton, null, null, null, {value:0}, pressedVal);
okButton, null, null, null, {value:0});
if (pressedVal.value == 0) {
if (pressedVal == 0) {
nsPreferences.setUnicharPref("browser.startup.homepage", aURL);
setTooltipText("home-button", aURL);
}

Просмотреть файл

@ -240,16 +240,15 @@ var nsUpdateDatasourceObserver =
var button1Text = unBundle.GetStringFromName("noThanks");
var checkMsg = unBundle.GetStringFromName("dontAskAgain");
var checkVal = {value:0};
var result = {value:1}; // default to "No Thanks" in case user clicks `x'
promptService.confirmEx(winWatcher.activeWindow, title, desc,
var result = promptService.confirmEx(winWatcher.activeWindow, title, desc,
(promptService.BUTTON_POS_0 * promptService.BUTTON_TITLE_IS_STRING) +
(promptService.BUTTON_POS_1 * promptService.BUTTON_TITLE_IS_STRING),
button0Text, button1Text, null, checkMsg, checkVal, result);
button0Text, button1Text, null, checkMsg, checkVal);
// user wants update now so open new window
// (result.value => 0 is button0)
if (result.value == 0)
// (result => 0 is button0)
if (result == 0)
winWatcher.openWindow(winWatcher.activeWindow, updateInfo.URL,
"_blank", "", null);