aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/libraries/include/llmozlib2.h
diff options
context:
space:
mode:
Diffstat (limited to 'linden/libraries/include/llmozlib2.h')
-rw-r--r--linden/libraries/include/llmozlib2.h383
1 files changed, 0 insertions, 383 deletions
diff --git a/linden/libraries/include/llmozlib2.h b/linden/libraries/include/llmozlib2.h
deleted file mode 100644
index d85caf9..0000000
--- a/linden/libraries/include/llmozlib2.h
+++ /dev/null
@@ -1,383 +0,0 @@
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 Linden Lab Inc. (http://lindenlab.com) code.
15 *
16 * The Initial Developer of the Original Code is:
17 * Callum Prentice (callum@ubrowser.com)
18 *
19 * Portions created by the Initial Developer are Copyright (C) 2006
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 * Callum Prentice (callum@ubrowser.com)
24 *
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
36 *
37 * ***** END LICENSE BLOCK ***** */
38
39#ifndef LLMOZLIB_H
40#define LLMOZLIB_H
41
42#include <string>
43#include <map>
44
45class LLEmbeddedBrowser;
46class LLEmbeddedBrowserWindow;
47
48////////////////////////////////////////////////////////////////////////////////
49// data class that is passed with an event
50class LLEmbeddedBrowserWindowEvent
51{
52 public:
53 LLEmbeddedBrowserWindowEvent( int eventWindowIdIn, std::string uriIn ) :
54 mEventWindowId( eventWindowIdIn ),
55 mEventUri( uriIn )
56 {
57 };
58
59 // single int passed with the event - e.g. progress
60 LLEmbeddedBrowserWindowEvent( int eventWindowIdIn, std::string uriIn, int intValIn ) :
61 mEventWindowId( eventWindowIdIn ),
62 mEventUri( uriIn ),
63 mIntVal( intValIn )
64 {
65 };
66
67 // string passed with the event
68 LLEmbeddedBrowserWindowEvent( int eventWindowIdIn, std::string uriIn, std::string stringValIn ) :
69 mEventWindowId( eventWindowIdIn ),
70 mEventUri( uriIn ),
71 mStringVal( stringValIn )
72 {
73 };
74
75 // 2 strings passed with the event
76 LLEmbeddedBrowserWindowEvent( int eventWindowIdIn, std::string uriIn, std::string stringValIn, std::string stringVal2In ) :
77 mEventWindowId( eventWindowIdIn ),
78 mEventUri( uriIn ),
79 mStringVal( stringValIn ),
80 mStringVal2( stringVal2In )
81 {
82 };
83
84 // string and an int passed with the event
85 LLEmbeddedBrowserWindowEvent( int eventWindowIdIn, std::string uriIn, std::string stringValIn, int intValIn ) :
86 mEventWindowId( eventWindowIdIn ),
87 mEventUri( uriIn ),
88 mStringVal( stringValIn ),
89 mIntVal( intValIn )
90 {
91 };
92
93 // 4 ints passed (semantically as a rectangle but could be anything - didn't want to make a RECT type structure)
94 LLEmbeddedBrowserWindowEvent( int eventWindowIdIn, std::string uriIn, int xIn, int yIn, int widthIn, int heightIn ) :
95 mEventWindowId( eventWindowIdIn ),
96 mEventUri( uriIn ),
97 mXVal( xIn ),
98 mYVal( yIn ),
99 mWidthVal( widthIn ),
100 mHeightVal( heightIn )
101 {
102 };
103
104 virtual ~LLEmbeddedBrowserWindowEvent()
105 {
106 };
107
108 int getEventWindowId() const
109 {
110 return mEventWindowId;
111 };
112
113 std::string getEventUri() const
114 {
115 return mEventUri;
116 };
117
118 int getIntValue() const
119 {
120 return mIntVal;
121 };
122
123 std::string getStringValue() const
124 {
125 return mStringVal;
126 };
127
128 std::string getStringValue2() const
129 {
130 return mStringVal2;
131 };
132
133 void getRectValue( int& xOut, int& yOut, int& widthOut, int& heightOut ) const
134 {
135 xOut = mXVal;
136 yOut = mYVal;
137 widthOut = mWidthVal;
138 heightOut = mHeightVal;
139 };
140
141 private:
142 int mEventWindowId;
143 std::string mEventUri;
144 int mIntVal;
145 std::string mStringVal;
146 std::string mStringVal2;
147 int mXVal;
148 int mYVal;
149 int mWidthVal;
150 int mHeightVal;
151};
152
153////////////////////////////////////////////////////////////////////////////////
154// derrive from this class and override these methods to observe these events
155class LLEmbeddedBrowserWindowObserver
156{
157 public:
158 virtual ~LLEmbeddedBrowserWindowObserver() { };
159 typedef LLEmbeddedBrowserWindowEvent EventType;
160
161 virtual void onPageChanged( const EventType& eventIn ) { };
162 virtual void onNavigateBegin( const EventType& eventIn ) { };
163 virtual void onNavigateComplete( const EventType& eventIn ) { };
164 virtual void onUpdateProgress( const EventType& eventIn ) { };
165 virtual void onStatusTextChange( const EventType& eventIn ) { };
166 virtual void onLocationChange( const EventType& eventIn ) { };
167 virtual void onClickLinkHref( const EventType& eventIn ) { };
168 virtual void onClickLinkNoFollow( const EventType& eventIn ) { };
169};
170
171////////////////////////////////////////////////////////////////////////////////
172// main library class
173class LLMozLib
174{
175 public:
176 virtual ~LLMozLib();
177
178 // singleton access
179 static LLMozLib* getInstance();
180
181 // housekeeping
182 bool init( std::string applicationDir, std::string componentDir, std::string profileDir, void* nativeWindowHandleIn );
183 bool reset();
184 bool clearCache();
185 int getLastError();
186 const std::string getVersion();
187 void setBrowserAgentId( std::string idIn );
188 bool enableProxy( bool proxyEnabledIn, std::string proxyHostNameIn, int proxyPortIn );
189 bool enableCookies( bool enabledIn );
190 bool clearAllCookies();
191 bool enablePlugins( bool enabledIn );
192
193 // browser window - creation/deletion, mutation etc.
194 int createBrowserWindow( int browserWindowWidthIn, int browserWindowHeightIn );
195 bool destroyBrowserWindow( int browserWindowIdIn );
196 bool setSize( int browserWindowIdIn, int widthIn, int heightIn );
197 bool scrollByLines( int browserWindowIdIn, int linesIn );
198 bool setBackgroundColor( int browserWindowIdIn, const int redIn, const int greenIn, const int blueIn );
199 bool setCaretColor( int browserWindowIdIn, const int redIn, const int greenIn, const int blueIn );
200 bool setEnabled( int browserWindowIdIn, bool enabledIn );
201
202 // add/remove yourself as an observer on browser events - see LLEmbeddedBrowserWindowObserver declaration
203 bool addObserver( int browserWindowIdIn, LLEmbeddedBrowserWindowObserver* subjectIn );
204 bool remObserver( int browserWindowIdIn, LLEmbeddedBrowserWindowObserver* subjectIn );
205
206 // navigation - self explanatory
207 bool navigateTo( int browserWindowIdIn, const std::string uriIn );
208 bool navigateStop( int browserWindowIdIn );
209 bool canNavigateBack( int browserWindowIdIn );
210 bool navigateBack( int browserWindowIdIn );
211 bool canNavigateForward( int browserWindowIdIn );
212 bool navigateForward( int browserWindowIdIn );
213
214 // javascript access/control
215 std::string evaluateJavascript( int browserWindowIdIn, const std::string scriptIn );
216
217 // set/clear URL to redirect to when a 404 page is reached
218 bool set404RedirectUrl( int browser_window_in, std::string redirect_url );
219 bool clr404RedirectUrl( int browser_window_in );
220
221 // access to rendered bitmap data
222 const unsigned char* grabBrowserWindow( int browserWindowIdIn ); // renders page to memory and returns pixels
223 const unsigned char* getBrowserWindowPixels( int browserWindowIdIn ); // just returns pixels - no render
224 const bool flipWindow( int browserWindowIdIn, bool flipIn ); // optionally flip window (pixels) you get back
225 const int getBrowserWidth( int browserWindowIdIn ); // current browser width (can vary slightly after page is rendered)
226 const int getBrowserHeight( int browserWindowIdIn ); // current height
227 const int getBrowserDepth( int browserWindowIdIn ); // depth in bytes
228 const int getBrowserRowSpan( int browserWindowIdIn ); // width in pixels * depth in bytes
229
230 // mouse/keyboard interaction
231 bool mouseDown( int browserWindowIdIn, int xPosIn, int yPosIn ); // send a mouse down event to a browser window at given XY in browser space
232 bool mouseUp( int browserWindowIdIn, int xPosIn, int yPosIn ); // send a mouse up event to a browser window at given XY in browser space
233 bool mouseMove( int browserWindowIdIn, int xPosIn, int yPosIn ); // send a mouse move event to a browser window at given XY in browser space
234 bool mouseLeftDoubleClick( int browserWindowIdIn, int xPosIn, int yPosIn ); // send a mouse left button double click to a browser window at given XY in browser space
235 bool keyPress( int browserWindowIdIn, int keyCodeIn ); // send a key press event to a browser window
236 bool unicodeInput ( int browserWindowIdIn, unsigned long uni_char ); // send a unicode keypress event to a browser window
237 bool focusBrowser( int browserWindowIdIn, bool focusBrowserIn ); // set/remove focus to given browser window
238
239 // accessor/mutator for scheme that browser doesn't follow - e.g. secondlife.com://
240 void setNoFollowScheme( int browserWindowIdIn, std::string schemeIn );
241 std::string getNoFollowScheme( int browserWindowIdIn );
242
243 private:
244 LLMozLib();
245 LLEmbeddedBrowserWindow* getBrowserWindowFromWindowId( int browserWindowIdIn );
246 static LLMozLib* sInstance;
247 const int mMaxBrowserWindows;
248 typedef std::map< int, LLEmbeddedBrowserWindow* > BrowserWindowMap;
249 typedef std::map< int, LLEmbeddedBrowserWindow* >::iterator BrowserWindowMapIter;
250 BrowserWindowMap mBrowserWindowMap;
251};
252
253// Mozilla virtual keycodes.
254// We don't want to suck in Mozilla headers so we copy these consts
255// from nsIDOMKeyEvent.idl.
256
257const unsigned long LL_DOM_VK_CANCEL = 0x03;
258const unsigned long LL_DOM_VK_HELP = 0x06;
259const unsigned long LL_DOM_VK_BACK_SPACE = 0x08;
260const unsigned long LL_DOM_VK_TAB = 0x09;
261const unsigned long LL_DOM_VK_CLEAR = 0x0C;
262const unsigned long LL_DOM_VK_RETURN = 0x0D;
263const unsigned long LL_DOM_VK_ENTER = 0x0E;
264const unsigned long LL_DOM_VK_SHIFT = 0x10;
265const unsigned long LL_DOM_VK_CONTROL = 0x11;
266const unsigned long LL_DOM_VK_ALT = 0x12;
267const unsigned long LL_DOM_VK_PAUSE = 0x13;
268const unsigned long LL_DOM_VK_CAPS_LOCK = 0x14;
269const unsigned long LL_DOM_VK_ESCAPE = 0x1B;
270const unsigned long LL_DOM_VK_SPACE = 0x20;
271const unsigned long LL_DOM_VK_PAGE_UP = 0x21;
272const unsigned long LL_DOM_VK_PAGE_DOWN = 0x22;
273const unsigned long LL_DOM_VK_END = 0x23;
274const unsigned long LL_DOM_VK_HOME = 0x24;
275const unsigned long LL_DOM_VK_LEFT = 0x25;
276const unsigned long LL_DOM_VK_UP = 0x26;
277const unsigned long LL_DOM_VK_RIGHT = 0x27;
278const unsigned long LL_DOM_VK_DOWN = 0x28;
279const unsigned long LL_DOM_VK_PRINTSCREEN = 0x2C;
280const unsigned long LL_DOM_VK_INSERT = 0x2D;
281const unsigned long LL_DOM_VK_DELETE = 0x2E;
282
283// LL_DOM_VK_0 - LL_DOM_VK_9 match their ASCII values
284const unsigned long LL_DOM_VK_0 = 0x30;
285const unsigned long LL_DOM_VK_1 = 0x31;
286const unsigned long LL_DOM_VK_2 = 0x32;
287const unsigned long LL_DOM_VK_3 = 0x33;
288const unsigned long LL_DOM_VK_4 = 0x34;
289const unsigned long LL_DOM_VK_5 = 0x35;
290const unsigned long LL_DOM_VK_6 = 0x36;
291const unsigned long LL_DOM_VK_7 = 0x37;
292const unsigned long LL_DOM_VK_8 = 0x38;
293const unsigned long LL_DOM_VK_9 = 0x39;
294
295const unsigned long LL_DOM_VK_SEMICOLON = 0x3B;
296const unsigned long LL_DOM_VK_EQUALS = 0x3D;
297
298// LL_DOM_VK_A - LL_DOM_VK_Z match their ASCII values
299const unsigned long LL_DOM_VK_A = 0x41;
300const unsigned long LL_DOM_VK_B = 0x42;
301const unsigned long LL_DOM_VK_C = 0x43;
302const unsigned long LL_DOM_VK_D = 0x44;
303const unsigned long LL_DOM_VK_E = 0x45;
304const unsigned long LL_DOM_VK_F = 0x46;
305const unsigned long LL_DOM_VK_G = 0x47;
306const unsigned long LL_DOM_VK_H = 0x48;
307const unsigned long LL_DOM_VK_I = 0x49;
308const unsigned long LL_DOM_VK_J = 0x4A;
309const unsigned long LL_DOM_VK_K = 0x4B;
310const unsigned long LL_DOM_VK_L = 0x4C;
311const unsigned long LL_DOM_VK_M = 0x4D;
312const unsigned long LL_DOM_VK_N = 0x4E;
313const unsigned long LL_DOM_VK_O = 0x4F;
314const unsigned long LL_DOM_VK_P = 0x50;
315const unsigned long LL_DOM_VK_Q = 0x51;
316const unsigned long LL_DOM_VK_R = 0x52;
317const unsigned long LL_DOM_VK_S = 0x53;
318const unsigned long LL_DOM_VK_T = 0x54;
319const unsigned long LL_DOM_VK_U = 0x55;
320const unsigned long LL_DOM_VK_V = 0x56;
321const unsigned long LL_DOM_VK_W = 0x57;
322const unsigned long LL_DOM_VK_X = 0x58;
323const unsigned long LL_DOM_VK_Y = 0x59;
324const unsigned long LL_DOM_VK_Z = 0x5A;
325
326const unsigned long LL_DOM_VK_CONTEXT_MENU = 0x5D;
327
328const unsigned long LL_DOM_VK_NUMPAD0 = 0x60;
329const unsigned long LL_DOM_VK_NUMPAD1 = 0x61;
330const unsigned long LL_DOM_VK_NUMPAD2 = 0x62;
331const unsigned long LL_DOM_VK_NUMPAD3 = 0x63;
332const unsigned long LL_DOM_VK_NUMPAD4 = 0x64;
333const unsigned long LL_DOM_VK_NUMPAD5 = 0x65;
334const unsigned long LL_DOM_VK_NUMPAD6 = 0x66;
335const unsigned long LL_DOM_VK_NUMPAD7 = 0x67;
336const unsigned long LL_DOM_VK_NUMPAD8 = 0x68;
337const unsigned long LL_DOM_VK_NUMPAD9 = 0x69;
338const unsigned long LL_DOM_VK_MULTIPLY = 0x6A;
339const unsigned long LL_DOM_VK_ADD = 0x6B;
340const unsigned long LL_DOM_VK_SEPARATOR = 0x6C;
341const unsigned long LL_DOM_VK_SUBTRACT = 0x6D;
342const unsigned long LL_DOM_VK_DECIMAL = 0x6E;
343const unsigned long LL_DOM_VK_DIVIDE = 0x6F;
344const unsigned long LL_DOM_VK_F1 = 0x70;
345const unsigned long LL_DOM_VK_F2 = 0x71;
346const unsigned long LL_DOM_VK_F3 = 0x72;
347const unsigned long LL_DOM_VK_F4 = 0x73;
348const unsigned long LL_DOM_VK_F5 = 0x74;
349const unsigned long LL_DOM_VK_F6 = 0x75;
350const unsigned long LL_DOM_VK_F7 = 0x76;
351const unsigned long LL_DOM_VK_F8 = 0x77;
352const unsigned long LL_DOM_VK_F9 = 0x78;
353const unsigned long LL_DOM_VK_F10 = 0x79;
354const unsigned long LL_DOM_VK_F11 = 0x7A;
355const unsigned long LL_DOM_VK_F12 = 0x7B;
356const unsigned long LL_DOM_VK_F13 = 0x7C;
357const unsigned long LL_DOM_VK_F14 = 0x7D;
358const unsigned long LL_DOM_VK_F15 = 0x7E;
359const unsigned long LL_DOM_VK_F16 = 0x7F;
360const unsigned long LL_DOM_VK_F17 = 0x80;
361const unsigned long LL_DOM_VK_F18 = 0x81;
362const unsigned long LL_DOM_VK_F19 = 0x82;
363const unsigned long LL_DOM_VK_F20 = 0x83;
364const unsigned long LL_DOM_VK_F21 = 0x84;
365const unsigned long LL_DOM_VK_F22 = 0x85;
366const unsigned long LL_DOM_VK_F23 = 0x86;
367const unsigned long LL_DOM_VK_F24 = 0x87;
368
369const unsigned long LL_DOM_VK_NUM_LOCK = 0x90;
370const unsigned long LL_DOM_VK_SCROLL_LOCK = 0x91;
371
372const unsigned long LL_DOM_VK_COMMA = 0xBC;
373const unsigned long LL_DOM_VK_PERIOD = 0xBE;
374const unsigned long LL_DOM_VK_SLASH = 0xBF;
375const unsigned long LL_DOM_VK_BACK_QUOTE = 0xC0;
376const unsigned long LL_DOM_VK_OPEN_BRACKET = 0xDB;
377const unsigned long LL_DOM_VK_BACK_SLASH = 0xDC;
378const unsigned long LL_DOM_VK_CLOSE_BRACKET = 0xDD;
379const unsigned long LL_DOM_VK_QUOTE = 0xDE;
380
381const unsigned long LL_DOM_VK_META = 0xE0;
382
383#endif // LLMOZLIB_H