|
| 1 | +#include "nsISupports.idl" |
| 2 | + |
| 3 | +interface nsIDOMElement; |
| 4 | +interface nsIDOMEvent; |
| 5 | +interface nsIDOMEventTarget; |
| 6 | +interface nsILocalFile; |
| 7 | +interface nsIVariant; |
| 8 | +interface mozIStorageConnection; |
| 9 | + |
| 10 | +interface xdIGestureService; |
| 11 | +interface xdIGestureHandler; |
| 12 | +interface xdIGestureObserver; |
| 13 | +interface xdIGestureMapping; |
| 14 | +interface xdIGestureCommand; |
| 15 | + |
| 16 | + |
| 17 | +[scriptable, uuid(1d26f3e7-d92e-4bcc-ac79-9624bb181308)] |
| 18 | +interface xdIGestureService : nsISupports |
| 19 | +{ |
| 20 | + |
| 21 | + /** |
| 22 | + * A wrapper function to create instance of xdIGestureObserver. |
| 23 | + */ |
| 24 | + xdIGestureHandler createHandler(); |
| 25 | + |
| 26 | + /** |
| 27 | + * Registers a mapping to service for later use. |
| 28 | + * @param aID The id of the mapping to identify it. It must equal to |
| 29 | + * the database table name which preserves the user mapping. |
| 30 | + * @param aURI The URI of RDF datasource which preserves the default mapping. |
| 31 | + * @param aName The name of the mapping. |
| 32 | + */ |
| 33 | + void registerMapping(in AUTF8String aID, in string aURI, in AUTF8String aName); |
| 34 | + |
| 35 | + /** |
| 36 | + * Returns a registered mapping from service. |
| 37 | + * At the first-time calling, creates instance of xdIGestureMapping and initializes it. |
| 38 | + * @throws NS_ERROR_NOT_INITIALIZED if the mapping is not registered. |
| 39 | + */ |
| 40 | + xdIGestureMapping getMapping(in AUTF8String aID); |
| 41 | + |
| 42 | + /** |
| 43 | + * A special version of getMapping, which returns the mapping for browser. |
| 44 | + */ |
| 45 | + xdIGestureMapping getMappingForBrowser(); |
| 46 | + |
| 47 | + /** |
| 48 | + * Returns meta data of all registered mappings. |
| 49 | + */ |
| 50 | + nsIVariant getMappingsInfo(); |
| 51 | + |
| 52 | + /** |
| 53 | + * Backups all user mappings to a file. |
| 54 | + */ |
| 55 | + void backupMappings(in nsILocalFile aFile); |
| 56 | + |
| 57 | + /** |
| 58 | + * Restores all user mappings from a file. |
| 59 | + */ |
| 60 | + void restoreMappings(in nsILocalFile aFile); |
| 61 | + |
| 62 | + /** |
| 63 | + * Returns database connection. |
| 64 | + * @param aForceOpen false: Returns null if database file doesn't exist. |
| 65 | + * true : Returns connection regardless of the file existence. |
| 66 | + */ |
| 67 | + mozIStorageConnection getDBConnection(in boolean aForceOpen); |
| 68 | + |
| 69 | + /** |
| 70 | + * Returns localized string from string bundle. |
| 71 | + */ |
| 72 | + wstring getLocaleString(in wstring aName); |
| 73 | + |
| 74 | +}; |
| 75 | + |
| 76 | + |
| 77 | +[scriptable, uuid(ca559550-8ab4-41c5-a72f-fd931322cc7e)] |
| 78 | +interface xdIGestureHandler : nsISupports |
| 79 | +{ |
| 80 | + |
| 81 | + /** |
| 82 | + * Get DOM element at the starting point of current mouse gesture. |
| 83 | + */ |
| 84 | + readonly attribute nsIDOMEventTarget sourceNode; |
| 85 | + |
| 86 | + /** |
| 87 | + * This method starts to handle mouse gestures at |nsIDOMEventTarget| |
| 88 | + * and register |xdIGestureObserver| as a observer, |
| 89 | + * which responds to mouse gestures. |
| 90 | + * @param aDrawArea The element where an user can perform gestures. |
| 91 | + * @param aObserver The gesture observer which is called back from handler. |
| 92 | + */ |
| 93 | + void attach(in nsIDOMElement aDrawArea, in xdIGestureObserver aObserver); |
| 94 | + |
| 95 | + /** |
| 96 | + * This method stops to handle mouse gestures. |
| 97 | + */ |
| 98 | + void detach(); |
| 99 | + |
| 100 | + /** |
| 101 | + * This method opens a popup at pointer and aborts the current mouse gesture. |
| 102 | + */ |
| 103 | + void openPopupAtPointer(in nsIDOMElement aPopup); |
| 104 | + |
| 105 | +}; |
| 106 | + |
| 107 | + |
| 108 | +[scriptable, uuid(c0db6b26-01d2-4060-91ff-b54af54bdd92)] |
| 109 | +interface xdIGestureObserver : nsISupports |
| 110 | +{ |
| 111 | + |
| 112 | + /** |
| 113 | + * Called when the direction is changed in progress of mouse gesture. |
| 114 | + */ |
| 115 | + void onDirectionChanged(in nsIDOMEvent event, in ACString aDirectionChain); |
| 116 | + |
| 117 | + /** |
| 118 | + * Called when user perform mouse gesture. |
| 119 | + */ |
| 120 | + void onMouseGesture(in nsIDOMEvent event, in ACString aDirectionChain); |
| 121 | + |
| 122 | + /** |
| 123 | + * Called when user perform some extra gestures. |
| 124 | + */ |
| 125 | + void onExtraGesture(in nsIDOMEvent event, in ACString aGestureType); |
| 126 | + |
| 127 | +}; |
| 128 | + |
| 129 | + |
| 130 | +[scriptable, uuid(d7018e80-d6da-4cbc-b77f-8dca4d95bbbf)] |
| 131 | +interface xdIGestureMapping : nsISupports |
| 132 | +{ |
| 133 | + |
| 134 | + /** |
| 135 | + * Types of commands. |
| 136 | + */ |
| 137 | + const unsigned short TYPE_CATEGORY = 0; |
| 138 | + const unsigned short TYPE_NORMAL = 1; |
| 139 | + const unsigned short TYPE_SCRIPT = 2; |
| 140 | + |
| 141 | + /** |
| 142 | + * The id of mapping, which equals to the table name. |
| 143 | + */ |
| 144 | + readonly attribute AUTF8String id; |
| 145 | + |
| 146 | + /** |
| 147 | + * The name of the mapping. |
| 148 | + */ |
| 149 | + readonly attribute AUTF8String name; |
| 150 | + |
| 151 | + /** |
| 152 | + * Initializes mapping. |
| 153 | + */ |
| 154 | + void init(in AUTF8String aID, in string aURI, in AUTF8String aName); |
| 155 | + |
| 156 | + /** |
| 157 | + * Finalizes mapping. |
| 158 | + */ |
| 159 | + void finalize(); |
| 160 | + |
| 161 | + /** |
| 162 | + * Returns xdIGestureCommand object for given direction. |
| 163 | + * Returns undefined if there are no definition for the given direction. |
| 164 | + */ |
| 165 | + xdIGestureCommand getCommandForDirection(in ACString aDirection); |
| 166 | + |
| 167 | + /** |
| 168 | + * Opens options window to configure mapping. |
| 169 | + */ |
| 170 | + void configure(); |
| 171 | + |
| 172 | + /** |
| 173 | + * Returns 2D array of mapping. |
| 174 | + */ |
| 175 | + nsIVariant getMappingArray(); |
| 176 | + |
| 177 | + /** |
| 178 | + * Flushes user mapping to local disk. |
| 179 | + */ |
| 180 | + void saveUserMapping(in nsIVariant aItems); |
| 181 | + |
| 182 | + /** |
| 183 | + * API for third-party extensions to add script-type commands. |
| 184 | + * Does not add command if there is one which has same script. |
| 185 | + * @param aItems Array of JavaScript object which has the following properties: |
| 186 | + * name : name of the command. |
| 187 | + * script : script of the command. |
| 188 | + * direction: default normal gesture to be assigned to the command (e.g. "LRUD"). |
| 189 | + */ |
| 190 | + void addScriptCommands(in nsIVariant aItems); |
| 191 | + |
| 192 | +}; |
| 193 | + |
| 194 | + |
| 195 | +[scriptable, uuid(2a8d26ee-6b43-4e73-9352-7632c128b006)] |
| 196 | +interface xdIGestureCommand : nsISupports |
| 197 | +{ |
| 198 | + |
| 199 | + /** |
| 200 | + * Represents the type of the command. |
| 201 | + */ |
| 202 | + readonly attribute PRUint8 type; |
| 203 | + |
| 204 | + /** |
| 205 | + * Represents the localized name of the command. |
| 206 | + */ |
| 207 | + readonly attribute AString name; |
| 208 | + |
| 209 | + /** |
| 210 | + * Represents the value of the command. |
| 211 | + */ |
| 212 | + readonly attribute AString value; |
| 213 | + |
| 214 | + /** |
| 215 | + * Represents the direction of the command. |
| 216 | + */ |
| 217 | + readonly attribute ACString direction; |
| 218 | + |
| 219 | +}; |
| 220 | + |
| 221 | + |
0 commit comments