/embedding/components/windowwatcher/public/nsIPromptService.idl

http://github.com/zpao/v8monkey · IDL · 378 lines · 75 code · 19 blank · 284 comment · 0 complexity · e482673eac3d88563b192f2037f015df MD5 · raw file

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4. *
  5. * The contents of this file are subject to the Mozilla Public License Version
  6. * 1.1 (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. * http://www.mozilla.org/MPL/
  9. *
  10. * Software distributed under the License is distributed on an "AS IS" basis,
  11. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. * for the specific language governing rights and limitations under the
  13. * License.
  14. *
  15. * The Original Code is mozilla.org code.
  16. *
  17. * The Initial Developer of the Original Code is
  18. * Netscape Communications Corporation.
  19. * Portions created by the Initial Developer are Copyright (C) 2001
  20. * the Initial Developer. All Rights Reserved.
  21. *
  22. * Contributor(s):
  23. *
  24. * Alternatively, the contents of this file may be used under the terms of
  25. * either the GNU General Public License Version 2 or later (the "GPL"), or
  26. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27. * in which case the provisions of the GPL or the LGPL are applicable instead
  28. * of those above. If you wish to allow use of your version of this file only
  29. * under the terms of either the GPL or the LGPL, and not to allow others to
  30. * use your version of this file under the terms of the MPL, indicate your
  31. * decision by deleting the provisions above and replace them with the notice
  32. * and other provisions required by the GPL or the LGPL. If you do not delete
  33. * the provisions above, a recipient may use your version of this file under
  34. * the terms of any one of the MPL, the GPL or the LGPL.
  35. *
  36. * ***** END LICENSE BLOCK ***** */
  37. #include "nsISupports.idl"
  38. interface nsIDOMWindow;
  39. /**
  40. * This is the interface to the embeddable prompt service; the service that
  41. * implements nsIPrompt. Its interface is designed to be just nsIPrompt, each
  42. * method modified to take a parent window parameter.
  43. *
  44. * Accesskeys can be attached to buttons and checkboxes by inserting an &
  45. * before the accesskey character in the checkbox message or button title. For
  46. * a real &, use && instead. (A "button title" generally refers to the text
  47. * label of a button.)
  48. *
  49. * One note: in all cases, the parent window parameter can be null. However,
  50. * these windows are all intended to have parents. So when no parent is
  51. * specified, the implementation should try hard to find a suitable foster
  52. * parent.
  53. *
  54. * Implementations are free to choose how they present the various button
  55. * types. For example, while prompts that give the user a choice between OK
  56. * and Cancel are required to return a boolean value indicating whether or not
  57. * the user accepted the prompt (pressed OK) or rejected the prompt (pressed
  58. * Cancel), the implementation of this interface could very well speak the
  59. * prompt to the user instead of rendering any visual user-interface. The
  60. * standard button types are merely idioms used to convey the nature of the
  61. * choice the user is to make.
  62. *
  63. * Because implementations of this interface may loosely interpret the various
  64. * button types, it is advised that text messages passed to these prompts do
  65. * not refer to the button types by name. For example, it is inadvisable to
  66. * tell the user to "Press OK to proceed." Instead, such a prompt might be
  67. * rewritten to ask the user: "Would you like to proceed?"
  68. */
  69. [scriptable, uuid(1630C61A-325E-49ca-8759-A31B16C47AA5)]
  70. interface nsIPromptService : nsISupports
  71. {
  72. /**
  73. * Puts up an alert dialog with an OK button.
  74. *
  75. * @param aParent
  76. * The parent window or null.
  77. * @param aDialogTitle
  78. * Text to appear in the title of the dialog.
  79. * @param aText
  80. * Text to appear in the body of the dialog.
  81. */
  82. void alert(in nsIDOMWindow aParent,
  83. in wstring aDialogTitle,
  84. in wstring aText);
  85. /**
  86. * Puts up an alert dialog with an OK button and a labeled checkbox.
  87. *
  88. * @param aParent
  89. * The parent window or null.
  90. * @param aDialogTitle
  91. * Text to appear in the title of the dialog.
  92. * @param aText
  93. * Text to appear in the body of the dialog.
  94. * @param aCheckMsg
  95. * Text to appear with the checkbox.
  96. * @param aCheckState
  97. * Contains the initial checked state of the checkbox when this method
  98. * is called and the final checked state after this method returns.
  99. */
  100. void alertCheck(in nsIDOMWindow aParent,
  101. in wstring aDialogTitle,
  102. in wstring aText,
  103. in wstring aCheckMsg,
  104. inout boolean aCheckState);
  105. /**
  106. * Puts up a dialog with OK and Cancel buttons.
  107. *
  108. * @param aParent
  109. * The parent window or null.
  110. * @param aDialogTitle
  111. * Text to appear in the title of the dialog.
  112. * @param aText
  113. * Text to appear in the body of the dialog.
  114. *
  115. * @return true for OK, false for Cancel
  116. */
  117. boolean confirm(in nsIDOMWindow aParent,
  118. in wstring aDialogTitle,
  119. in wstring aText);
  120. /**
  121. * Puts up a dialog with OK and Cancel buttons and a labeled checkbox.
  122. *
  123. * @param aParent
  124. * The parent window or null.
  125. * @param aDialogTitle
  126. * Text to appear in the title of the dialog.
  127. * @param aText
  128. * Text to appear in the body of the dialog.
  129. * @param aCheckMsg
  130. * Text to appear with the checkbox.
  131. * @param aCheckState
  132. * Contains the initial checked state of the checkbox when this method
  133. * is called and the final checked state after this method returns.
  134. *
  135. * @return true for OK, false for Cancel
  136. */
  137. boolean confirmCheck(in nsIDOMWindow aParent,
  138. in wstring aDialogTitle,
  139. in wstring aText,
  140. in wstring aCheckMsg,
  141. inout boolean aCheckState);
  142. /**
  143. * Button Flags
  144. *
  145. * The following flags are combined to form the aButtonFlags parameter passed
  146. * to confirmEx. See confirmEx for more information on how the flags may be
  147. * combined.
  148. */
  149. /**
  150. * Button Position Flags
  151. */
  152. const unsigned long BUTTON_POS_0 = 1;
  153. const unsigned long BUTTON_POS_1 = 1 << 8;
  154. const unsigned long BUTTON_POS_2 = 1 << 16;
  155. /**
  156. * Button Title Flags (used to set the labels of buttons in the prompt)
  157. */
  158. const unsigned long BUTTON_TITLE_OK = 1;
  159. const unsigned long BUTTON_TITLE_CANCEL = 2;
  160. const unsigned long BUTTON_TITLE_YES = 3;
  161. const unsigned long BUTTON_TITLE_NO = 4;
  162. const unsigned long BUTTON_TITLE_SAVE = 5;
  163. const unsigned long BUTTON_TITLE_DONT_SAVE = 6;
  164. const unsigned long BUTTON_TITLE_REVERT = 7;
  165. const unsigned long BUTTON_TITLE_IS_STRING = 127;
  166. /**
  167. * Button Default Flags (used to select which button is the default one)
  168. */
  169. const unsigned long BUTTON_POS_0_DEFAULT = 0;
  170. const unsigned long BUTTON_POS_1_DEFAULT = 1 << 24;
  171. const unsigned long BUTTON_POS_2_DEFAULT = 1 << 25;
  172. /**
  173. * Causes the buttons to be initially disabled. They are enabled after a
  174. * timeout expires. The implementation may interpret this loosely as the
  175. * intent is to ensure that the user does not click through a security dialog
  176. * too quickly. Strictly speaking, the implementation could choose to ignore
  177. * this flag.
  178. */
  179. const unsigned long BUTTON_DELAY_ENABLE = 1 << 26;
  180. /**
  181. * Selects the standard set of OK/Cancel buttons.
  182. */
  183. const unsigned long STD_OK_CANCEL_BUTTONS = (BUTTON_TITLE_OK * BUTTON_POS_0) +
  184. (BUTTON_TITLE_CANCEL * BUTTON_POS_1);
  185. /**
  186. * Selects the standard set of Yes/No buttons.
  187. */
  188. const unsigned long STD_YES_NO_BUTTONS = (BUTTON_TITLE_YES * BUTTON_POS_0) +
  189. (BUTTON_TITLE_NO * BUTTON_POS_1);
  190. /**
  191. * Puts up a dialog with up to 3 buttons and an optional, labeled checkbox.
  192. *
  193. * @param aParent
  194. * The parent window or null.
  195. * @param aDialogTitle
  196. * Text to appear in the title of the dialog.
  197. * @param aText
  198. * Text to appear in the body of the dialog.
  199. * @param aButtonFlags
  200. * A combination of Button Flags.
  201. * @param aButton0Title
  202. * Used when button 0 uses TITLE_IS_STRING
  203. * @param aButton1Title
  204. * Used when button 1 uses TITLE_IS_STRING
  205. * @param aButton2Title
  206. * Used when button 2 uses TITLE_IS_STRING
  207. * @param aCheckMsg
  208. * Text to appear with the checkbox. Null if no checkbox.
  209. * @param aCheckState
  210. * Contains the initial checked state of the checkbox when this method
  211. * is called and the final checked state after this method returns.
  212. *
  213. * @return index of the button pressed.
  214. *
  215. * Buttons are numbered 0 - 2. The implementation can decide whether the
  216. * sequence goes from right to left or left to right. Button 0 is the
  217. * default button unless one of the Button Default Flags is specified.
  218. *
  219. * A button may use a predefined title, specified by one of the Button Title
  220. * Flags values. Each title value can be multiplied by a position value to
  221. * assign the title to a particular button. If BUTTON_TITLE_IS_STRING is
  222. * used for a button, the string parameter for that button will be used. If
  223. * the value for a button position is zero, the button will not be shown.
  224. *
  225. * In general, aButtonFlags is constructed per the following example:
  226. *
  227. * aButtonFlags = (BUTTON_POS_0) * (BUTTON_TITLE_AAA) +
  228. * (BUTTON_POS_1) * (BUTTON_TITLE_BBB) +
  229. * BUTTON_POS_1_DEFAULT;
  230. *
  231. * where "AAA" and "BBB" correspond to one of the button titles.
  232. */
  233. PRInt32 confirmEx(in nsIDOMWindow aParent,
  234. in wstring aDialogTitle,
  235. in wstring aText,
  236. in unsigned long aButtonFlags,
  237. in wstring aButton0Title,
  238. in wstring aButton1Title,
  239. in wstring aButton2Title,
  240. in wstring aCheckMsg,
  241. inout boolean aCheckState);
  242. /**
  243. * Puts up a dialog with an edit field and an optional, labeled checkbox.
  244. *
  245. * @param aParent
  246. * The parent window or null.
  247. * @param aDialogTitle
  248. * Text to appear in the title of the dialog.
  249. * @param aText
  250. * Text to appear in the body of the dialog.
  251. * @param aValue
  252. * Contains the default value for the dialog field when this method
  253. * is called (null value is ok). Upon return, if the user pressed
  254. * OK, then this parameter contains a newly allocated string value.
  255. * Otherwise, the parameter's value is unmodified.
  256. * @param aCheckMsg
  257. * Text to appear with the checkbox. If null, check box will not be shown.
  258. * @param aCheckState
  259. * Contains the initial checked state of the checkbox when this method
  260. * is called and the final checked state after this method returns.
  261. *
  262. * @return true for OK, false for Cancel.
  263. */
  264. boolean prompt(in nsIDOMWindow aParent,
  265. in wstring aDialogTitle,
  266. in wstring aText,
  267. inout wstring aValue,
  268. in wstring aCheckMsg,
  269. inout boolean aCheckState);
  270. /**
  271. * Puts up a dialog with an edit field, a password field, and an optional,
  272. * labeled checkbox.
  273. *
  274. * @param aParent
  275. * The parent window or null.
  276. * @param aDialogTitle
  277. * Text to appear in the title of the dialog.
  278. * @param aText
  279. * Text to appear in the body of the dialog.
  280. * @param aUsername
  281. * Contains the default value for the username field when this method
  282. * is called (null value is ok). Upon return, if the user pressed OK,
  283. * then this parameter contains a newly allocated string value.
  284. * Otherwise, the parameter's value is unmodified.
  285. * @param aPassword
  286. * Contains the default value for the password field when this method
  287. * is called (null value is ok). Upon return, if the user pressed OK,
  288. * then this parameter contains a newly allocated string value.
  289. * Otherwise, the parameter's value is unmodified.
  290. * @param aCheckMsg
  291. * Text to appear with the checkbox. If null, check box will not be shown.
  292. * @param aCheckState
  293. * Contains the initial checked state of the checkbox when this method
  294. * is called and the final checked state after this method returns.
  295. *
  296. * @return true for OK, false for Cancel.
  297. */
  298. boolean promptUsernameAndPassword(in nsIDOMWindow aParent,
  299. in wstring aDialogTitle,
  300. in wstring aText,
  301. inout wstring aUsername,
  302. inout wstring aPassword,
  303. in wstring aCheckMsg,
  304. inout boolean aCheckState);
  305. /**
  306. * Puts up a dialog with a password field and an optional, labeled checkbox.
  307. *
  308. * @param aParent
  309. * The parent window or null.
  310. * @param aDialogTitle
  311. * Text to appear in the title of the dialog.
  312. * @param aText
  313. * Text to appear in the body of the dialog.
  314. * @param aPassword
  315. * Contains the default value for the password field when this method
  316. * is called (null value is ok). Upon return, if the user pressed OK,
  317. * then this parameter contains a newly allocated string value.
  318. * Otherwise, the parameter's value is unmodified.
  319. * @param aCheckMsg
  320. * Text to appear with the checkbox. If null, check box will not be shown.
  321. * @param aCheckState
  322. * Contains the initial checked state of the checkbox when this method
  323. * is called and the final checked state after this method returns.
  324. *
  325. * @return true for OK, false for Cancel.
  326. */
  327. boolean promptPassword(in nsIDOMWindow aParent,
  328. in wstring aDialogTitle,
  329. in wstring aText,
  330. inout wstring aPassword,
  331. in wstring aCheckMsg,
  332. inout boolean aCheckState);
  333. /**
  334. * Puts up a dialog box which has a list box of strings from which the user
  335. * may make a single selection.
  336. *
  337. * @param aParent
  338. * The parent window or null.
  339. * @param aDialogTitle
  340. * Text to appear in the title of the dialog.
  341. * @param aText
  342. * Text to appear in the body of the dialog.
  343. * @param aCount
  344. * The length of the aSelectList array parameter.
  345. * @param aSelectList
  346. * The list of strings to display.
  347. * @param aOutSelection
  348. * Contains the index of the selected item in the list when this
  349. * method returns true.
  350. *
  351. * @return true for OK, false for Cancel.
  352. */
  353. boolean select(in nsIDOMWindow aParent,
  354. in wstring aDialogTitle,
  355. in wstring aText,
  356. in PRUint32 aCount,
  357. [array, size_is(aCount)] in wstring aSelectList,
  358. out long aOutSelection);
  359. };