1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 *
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
8 *
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
13 *
14 * The Original Code is autocomplete code.
15 *
16 * The Initial Developer of the Original Code is
17 * Google Inc.
18 * Portions created by the Initial Developer are Copyright (C) 2005
19 * the Initial Developer. All Rights Reserved.
20 *
21 * Contributor(s):
22 * Brett Wilson <brettw@gmail.com>
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
38 #include "nsISupports.idl"
39 #include "nsIAutoCompleteResult.idl"
40
41 interface nsIAutoCompleteSimpleResultListener;
42
43 /**
44 * This class implements nsIAutoCompleteResult and provides simple methods
45 * for setting the value and result items. It can be used whenever some basic
46 * auto complete results are needed that can be pre-generated and filled into
47 * an array.
48 */
49
50 [scriptable, uuid(f9841787-ad26-49e6-a2dd-ba9020ee1c64)]
51 interface nsIAutoCompleteSimpleResult : nsIAutoCompleteResult
52 {
53 /**
54 * A writer for the readonly attribute 'searchString' which should contain
55 * the string that the user typed.
56 */
57 void setSearchString(in AString aSearchString);
58
59 /**
60 * A writer for the readonly attribute 'errorDescription'.
61 */
62 void setErrorDescription(in AString aErrorDescription);
63
64 /**
65 * A writer for the readonly attribute 'defaultIndex' which should contain
66 * the index of the list that will be selected by default (normally 0).
67 */
68 void setDefaultIndex(in long aDefaultIndex);
69
70 /**
71 * A writer for the readonly attribute 'searchResult' which should contain
72 * one of the constants nsIAutoCompleteResult.RESULT_* indicating the success
73 * of the search.
74 */
75 void setSearchResult(in unsigned short aSearchResult);
76
77 /**
78 * Appends a result item consisting of the given value, comment, image and style.
79 * This is how you add results. Note: image and style are optional.
80 */
81 void appendMatch(in AString aValue, in AString aComment,
82 [optional] in AString aImage,
83 [optional] in AString aStyle);
84
85 /**
86 * Sets a listener for changes in the result.
87 */
88 void setListener(in nsIAutoCompleteSimpleResultListener aListener);
89 };
90
91 [scriptable, uuid(004efdc5-1989-4874-8a7a-345bf2fa33af)]
92 interface nsIAutoCompleteSimpleResultListener : nsISupports
93 {
94 /**
95 * Dispatched after a value is removed from the result.
96 * @param aResult
97 * The result from which aValue has been removed.
98 * @param aValue
99 * The removed value.
100 * @param aRemoveFromDb
101 * Whether the value should be removed from persistent storage as well.
102 */
103 void onValueRemoved(in nsIAutoCompleteSimpleResult aResult, in AString aValue,
104 in boolean aRemoveFromDb);
105 };