aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/libraries/include/llmozlib2.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:34 -0500
committerJacek Antonelli2008-08-15 23:45:34 -0500
commitcd17687f01420952712a500107e0f93e7ab8d5f8 (patch)
treece48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/libraries/include/llmozlib2.h
parentSecond Life viewer sources 1.19.0.5 (diff)
downloadmeta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz
Second Life viewer sources 1.19.1.0
Diffstat (limited to '')
-rw-r--r--linden/libraries/include/llmozlib2.h (renamed from linden/libraries/include/llmozlib.h)188
1 files changed, 123 insertions, 65 deletions
diff --git a/linden/libraries/include/llmozlib.h b/linden/libraries/include/llmozlib2.h
index 647820b..1dd71dc 100644
--- a/linden/libraries/include/llmozlib.h
+++ b/linden/libraries/include/llmozlib2.h
@@ -1,33 +1,40 @@
1/** 1/* ***** BEGIN LICENSE BLOCK *****
2 * @file llmozlib.h 2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 * @brief Linden Lab Mozilla wrapper.
4 * 3 *
5 * $LicenseInfo:firstyear=2006&license=viewergpl$ 4 * The contents of this file are subject to the Mozilla Public License Version
6 * 5 * 1.1 (the "License"); you may not use this file except in compliance with
7 * Copyright (c) 2006-2008, Linden Research, Inc. 6 * the License. You may obtain a copy of the License at
8 * 7 * http://www.mozilla.org/MPL/
9 * Second Life Viewer Source Code 8 *
10 * The source code in this file ("Source Code") is provided by Linden Lab 9 * Software distributed under the License is distributed on an "AS IS" basis,
11 * to you under the terms of the GNU General Public License, version 2.0 10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * ("GPL"), unless you have obtained a separate licensing agreement 11 * for the specific language governing rights and limitations under the
13 * ("Other License"), formally executed by you and Linden Lab. Terms of 12 * License.
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or 13 *
15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 14 * The Original Code is Linden Lab Inc. (http://lindenlab.com) code.
16 * 15 *
17 * There are special exceptions to the terms and conditions of the GPL as 16 * The Initial Developer of the Original Code is:
18 * it is applied to this Source Code. View the full text of the exception 17 * Callum Prentice (callum@ubrowser.com)
19 * in the file doc/FLOSS-exception.txt in this software distribution, or 18 *
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception 19 * Portions created by the Initial Developer are Copyright (C) 2006
21 * 20 * the Initial Developer. All Rights Reserved.
22 * By copying, modifying or distributing this software, you acknowledge 21 *
23 * that you have read and understood your obligations described above, 22 * Contributor(s):
24 * and agree to abide by those obligations. 23 * Callum Prentice (callum@ubrowser.com)
25 * 24 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO 25 * Alternatively, the contents of this file may be used under the terms of
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, 26 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * COMPLETENESS OR PERFORMANCE. 27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * $/LicenseInfo$ 28 * in which case the provisions of the GPL or the LGPL are applicable instead
30 */ 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 ***** */
31 38
32#ifndef LLMOZLIB_H 39#ifndef LLMOZLIB_H
33#define LLMOZLIB_H 40#define LLMOZLIB_H
@@ -43,23 +50,48 @@ class LLEmbeddedBrowserWindow;
43class LLEmbeddedBrowserWindowEvent 50class LLEmbeddedBrowserWindowEvent
44{ 51{
45 public: 52 public:
46 LLEmbeddedBrowserWindowEvent( int eventWindowIdIn ) : 53 LLEmbeddedBrowserWindowEvent( int eventWindowIdIn, std::string uriIn ) :
47 mEventWindowId( eventWindowIdIn ) 54 mEventWindowId( eventWindowIdIn ),
55 mEventUri( uriIn )
48 { 56 {
49 }; 57 };
50 58
51 LLEmbeddedBrowserWindowEvent( int eventWindowIdIn, int intValIn ) : 59 // single int passed with the event - e.g. progress
60 LLEmbeddedBrowserWindowEvent( int eventWindowIdIn, std::string uriIn, int intValIn ) :
52 mEventWindowId( eventWindowIdIn ), 61 mEventWindowId( eventWindowIdIn ),
62 mEventUri( uriIn ),
53 mIntVal( intValIn ) 63 mIntVal( intValIn )
54 { 64 {
55 }; 65 };
56 66
57 LLEmbeddedBrowserWindowEvent( int eventWindowIdIn, std::string stringValIn ) : 67 // string passed with the event
68 LLEmbeddedBrowserWindowEvent( int eventWindowIdIn, std::string uriIn, std::string stringValIn ) :
58 mEventWindowId( eventWindowIdIn ), 69 mEventWindowId( eventWindowIdIn ),
70 mEventUri( uriIn ),
59 mStringVal( stringValIn ) 71 mStringVal( stringValIn )
60 { 72 {
61 }; 73 };
62 74
75 // string and an int passed with the event
76 LLEmbeddedBrowserWindowEvent( int eventWindowIdIn, std::string uriIn, std::string stringValIn, int intValIn ) :
77 mEventWindowId( eventWindowIdIn ),
78 mEventUri( uriIn ),
79 mStringVal( stringValIn ),
80 mIntVal( intValIn )
81 {
82 };
83
84 // 4 ints passed (semantically as a rectangle but could be anything - didn't want to make a RECT type structure)
85 LLEmbeddedBrowserWindowEvent( int eventWindowIdIn, std::string uriIn, int xIn, int yIn, int widthIn, int heightIn ) :
86 mEventWindowId( eventWindowIdIn ),
87 mEventUri( uriIn ),
88 mXVal( xIn ),
89 mYVal( yIn ),
90 mWidthVal( widthIn ),
91 mHeightVal( heightIn )
92 {
93 };
94
63 virtual ~LLEmbeddedBrowserWindowEvent() 95 virtual ~LLEmbeddedBrowserWindowEvent()
64 { 96 {
65 }; 97 };
@@ -69,6 +101,11 @@ class LLEmbeddedBrowserWindowEvent
69 return mEventWindowId; 101 return mEventWindowId;
70 }; 102 };
71 103
104 std::string getEventUri() const
105 {
106 return mEventUri;
107 };
108
72 int getIntValue() const 109 int getIntValue() const
73 { 110 {
74 return mIntVal; 111 return mIntVal;
@@ -79,31 +116,45 @@ class LLEmbeddedBrowserWindowEvent
79 return mStringVal; 116 return mStringVal;
80 }; 117 };
81 118
119 void getRectValue( int& xOut, int& yOut, int& widthOut, int& heightOut ) const
120 {
121 xOut = mXVal;
122 yOut = mYVal;
123 widthOut = mWidthVal;
124 heightOut = mHeightVal;
125 };
126
82 private: 127 private:
83 int mEventWindowId; 128 int mEventWindowId;
129 std::string mEventUri;
84 int mIntVal; 130 int mIntVal;
85 std::string mStringVal; 131 std::string mStringVal;
132 int mXVal;
133 int mYVal;
134 int mWidthVal;
135 int mHeightVal;
86}; 136};
87 137
88//////////////////////////////////////////////////////////////////////////////// 138////////////////////////////////////////////////////////////////////////////////
89// Override these methods to observe browser events 139// derrive from this class and override these methods to observe these events
90class LLEmbeddedBrowserWindowObserver 140class LLEmbeddedBrowserWindowObserver
91{ 141{
92 public: 142 public:
93 virtual ~LLEmbeddedBrowserWindowObserver() { }; 143 virtual ~LLEmbeddedBrowserWindowObserver() { };
94
95 typedef LLEmbeddedBrowserWindowEvent EventType; 144 typedef LLEmbeddedBrowserWindowEvent EventType;
145
146 virtual void onPageChanged( const EventType& eventIn ) { };
96 virtual void onNavigateBegin( const EventType& eventIn ) { }; 147 virtual void onNavigateBegin( const EventType& eventIn ) { };
97 virtual void onNavigateComplete( const EventType& eventIn ) { }; 148 virtual void onNavigateComplete( const EventType& eventIn ) { };
98 virtual void onUpdateProgress( const EventType& eventIn ) { }; 149 virtual void onUpdateProgress( const EventType& eventIn ) { };
99 virtual void onStatusTextChange( const EventType& eventIn ) { }; 150 virtual void onStatusTextChange( const EventType& eventIn ) { };
100 virtual void onLocationChange( const EventType& eventIn ) { }; 151 virtual void onLocationChange( const EventType& eventIn ) { };
101 virtual void onClickLinkHref( const EventType& eventIn ) { }; 152 virtual void onClickLinkHref( const EventType& eventIn ) { };
102 virtual void onClickLinkSecondLife( const EventType& eventIn ) { }; 153 virtual void onClickLinkNoFollow( const EventType& eventIn ) { };
103}; 154};
104 155
105//////////////////////////////////////////////////////////////////////////////// 156////////////////////////////////////////////////////////////////////////////////
106// 157// main library class
107class LLMozLib 158class LLMozLib
108{ 159{
109 public: 160 public:
@@ -113,30 +164,31 @@ class LLMozLib
113 static LLMozLib* getInstance(); 164 static LLMozLib* getInstance();
114 165
115 // housekeeping 166 // housekeeping
116 bool init( std::string applicationDirIn, std::string componentDirIn, std::string profileDirIn ); 167 bool init( std::string applicationDir, std::string componentDir, std::string profileDir, void* nativeWindowHandleIn );
117 bool reset(); 168 bool reset();
118 bool enableProxy( bool proxyEnabledIn, std::string proxyHostNameIn, int proxyPortIn );
119 bool clearCache(); 169 bool clearCache();
120 bool enableCookies( bool enabledIn );
121 bool clearAllCookies();
122 bool enablePlugins( bool enabledIn );
123 int getLastError(); 170 int getLastError();
124 const std::string getVersion(); 171 const std::string getVersion();
125 void setBrowserAgentId( std::string idIn ); 172 void setBrowserAgentId( std::string idIn );
173 bool enableProxy( bool proxyEnabledIn, std::string proxyHostNameIn, int proxyPortIn );
174 bool enableCookies( bool enabledIn );
175 bool clearAllCookies();
176 bool enablePlugins( bool enabledIn );
126 177
127 // browser window 178 // browser window - creation/deletion, mutation etc.
128 int createBrowserWindow( void* nativeWindowHandleIn, int browserWindowWidthIn, int browserWindowHeightIn ); 179 int createBrowserWindow( int browserWindowWidthIn, int browserWindowHeightIn );
129 bool destroyBrowserWindow( int browserWindowIdIn ); 180 bool destroyBrowserWindow( int browserWindowIdIn );
130 bool setSize( int browserWindowIdIn, int widthIn, int heightIn ); 181 bool setSize( int browserWindowIdIn, int widthIn, int heightIn );
131 bool scrollByLines( int browserWindowIdIn, int linesIn ); 182 bool scrollByLines( int browserWindowIdIn, int linesIn );
132 void setBackgroundColor( int browserWindowIdIn, int redIn, int greenIn, int blueIn ); 183 bool setBackgroundColor( int browserWindowIdIn, const int redIn, const int greenIn, const int blueIn );
133 bool setCaretColor( int browserWindowIdIn, const int redIn, const int greenIn, const int blueIn ); 184 bool setCaretColor( int browserWindowIdIn, const int redIn, const int greenIn, const int blueIn );
185 bool setEnabled( int browserWindowIdIn, bool enabledIn );
134 186
135 // observer interface 187 // add/remove yourself as an observer on browser events - see LLEmbeddedBrowserWindowObserver declaration
136 bool addObserver( int browserWindowIdIn, LLEmbeddedBrowserWindowObserver* subjectIn ); 188 bool addObserver( int browserWindowIdIn, LLEmbeddedBrowserWindowObserver* subjectIn );
137 bool remObserver( int browserWindowIdIn, LLEmbeddedBrowserWindowObserver* subjectIn ); 189 bool remObserver( int browserWindowIdIn, LLEmbeddedBrowserWindowObserver* subjectIn );
138 190
139 // navigation 191 // navigation - self explanatory
140 bool navigateTo( int browserWindowIdIn, const std::string uriIn ); 192 bool navigateTo( int browserWindowIdIn, const std::string uriIn );
141 bool navigateStop( int browserWindowIdIn ); 193 bool navigateStop( int browserWindowIdIn );
142 bool canNavigateBack( int browserWindowIdIn ); 194 bool canNavigateBack( int browserWindowIdIn );
@@ -144,39 +196,45 @@ class LLMozLib
144 bool canNavigateForward( int browserWindowIdIn ); 196 bool canNavigateForward( int browserWindowIdIn );
145 bool navigateForward( int browserWindowIdIn ); 197 bool navigateForward( int browserWindowIdIn );
146 198
199 // javascript access/control
200 std::string evaluateJavascript( int browserWindowIdIn, const std::string scriptIn );
201
147 // set/clear URL to redirect to when a 404 page is reached 202 // set/clear URL to redirect to when a 404 page is reached
148 bool set404RedirectUrl( int browser_window_in, std::string redirect_url ); 203 bool set404RedirectUrl( int browser_window_in, std::string redirect_url );
149 bool clr404RedirectUrl( int browser_window_in ); 204 bool clr404RedirectUrl( int browser_window_in );
150 205
151 // access to rendered bitmap data 206 // access to rendered bitmap data
152 const unsigned char* grabBrowserWindow( int browserWindowIdIn ); 207 const unsigned char* grabBrowserWindow( int browserWindowIdIn ); // renders page to memory and returns pixels
153 const unsigned char* getBrowserWindowPixels( int browserWindowIdIn ); 208 const unsigned char* getBrowserWindowPixels( int browserWindowIdIn ); // just returns pixels - no render
154 const int getBrowserWidth( int browserWindowIdIn ); 209 const bool flipWindow( int browserWindowIdIn, bool flipIn ); // optionally flip window (pixels) you get back
155 const int getBrowserHeight( int browserWindowIdIn ); 210 const int getBrowserWidth( int browserWindowIdIn ); // current browser width (can vary slightly after page is rendered)
156 const int getBrowserDepth( int browserWindowIdIn ); 211 const int getBrowserHeight( int browserWindowIdIn ); // current height
157 const int getBrowserRowSpan( int browserWindowIdIn ); 212 const int getBrowserDepth( int browserWindowIdIn ); // depth in bytes
213 const int getBrowserRowSpan( int browserWindowIdIn ); // width in pixels * depth in bytes
158 214
159 // mouse/keyboard interaction 215 // mouse/keyboard interaction
160 bool mouseDown( int browserWindowIdIn, int xPosIn, int yPosIn ); 216 bool mouseDown( int browserWindowIdIn, int xPosIn, int yPosIn ); // send a mouse down event to a browser window at given XY in browser space
161 bool mouseUp( int browserWindowIdIn, int xPosIn, int yPosIn ); 217 bool mouseUp( int browserWindowIdIn, int xPosIn, int yPosIn ); // send a mouse up event to a browser window at given XY in browser space
162 218 bool mouseMove( int browserWindowIdIn, int xPosIn, int yPosIn ); // send a mouse move event to a browser window at given XY in browser space
163 // send a mouse left button double click to a browser window at given XY in browser space 219 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
164 bool mouseLeftDoubleClick( int browserWindowIdIn, int xPosIn, int yPosIn ); 220 bool keyPress( int browserWindowIdIn, int keyCodeIn ); // send a key press event to a browser window
165 221 bool unicodeInput ( int browserWindowIdIn, unsigned long uni_char ); // send a unicode keypress event to a browser window
166 bool mouseMove( int browserWindowIdIn, int xPosIn, int yPosIn ); 222 bool focusBrowser( int browserWindowIdIn, bool focusBrowserIn ); // set/remove focus to given browser window
167 bool keyPress( int browserWindowIdIn, int keyCodeIn ); 223
168 bool unicodeInput ( int browserWindowIdIn, unsigned long uni_char ); 224 // accessor/mutator for scheme that browser doesn't follow - e.g. secondlife.com://
169 bool focusBrowser( int browserWindowIdIn, bool focusBrowserIn ); 225 void setNoFollowScheme( int browserWindowIdIn, std::string schemeIn );
226 std::string getNoFollowScheme( int browserWindowIdIn );
170 227
171 private: 228 private:
172 LLMozLib(); 229 LLMozLib();
173 LLEmbeddedBrowserWindow* getBrowserWindowFromWindowId( int browserWindowIdIn ); 230 LLEmbeddedBrowserWindow* getBrowserWindowFromWindowId( int browserWindowIdIn );
174 static LLMozLib* sInstance; 231 static LLMozLib* sInstance;
175 const int mMaxBrowserWindows; 232 const int mMaxBrowserWindows;
176 LLEmbeddedBrowserWindow** mBrowserWindowList; 233 typedef std::map< int, LLEmbeddedBrowserWindow* > BrowserWindowMap;
234 typedef std::map< int, LLEmbeddedBrowserWindow* >::iterator BrowserWindowMapIter;
235 BrowserWindowMap mBrowserWindowMap;
177}; 236};
178 237
179
180// Mozilla virtual keycodes. 238// Mozilla virtual keycodes.
181// We don't want to suck in Mozilla headers so we copy these consts 239// We don't want to suck in Mozilla headers so we copy these consts
182// from nsIDOMKeyEvent.idl. 240// from nsIDOMKeyEvent.idl.