Introduced xulrunner extensions from llmozlib2, and got things working under linux

This commit is contained in:
Robert Osfield
2008-11-17 10:36:55 +00:00
parent fa65527fee
commit 39646d2dff
12 changed files with 2253 additions and 1389 deletions

View File

@@ -2,6 +2,7 @@ SET(TARGET_SRC
llembeddedbrowser.cpp
llembeddedbrowserwindow.cpp
llmozlib2.cpp
nsProfileDirServiceProvider.cpp
osgbrowser.cpp
)
@@ -9,6 +10,9 @@ SET(TARGET_H
llembeddedbrowser.h
llembeddedbrowserwindow.h
llmozlib2.h
nsProfileDirServiceProvider.h
nsProfileLock.h
nsProfileStringTypes.h
)
ADD_DEFINITIONS(-DMOZILLA_INTERNAL_API)
@@ -35,6 +39,12 @@ INCLUDE_DIRECTORIES( ${GLUT_INCLUDE_DIR}
/usr/include/xulrunner/profdirserviceprovider
/usr/include/xulrunner/nkcache
/usr/include/xulrunner/xulapp
/usr/include/xulrunner/profile
/usr/include/xulrunner/appshell
/usr/include/xulrunner/xpcom_obsolete
/usr/include/xulrunner/intl
/usr/include/xulrunner/windowwatcher
/usr/include/xulrunner/xpconnect
)
LINK_DIRECTORIES( ${XUL_LIB_DIRS})
SET(TARGET_EXTERNAL_LIBRARIES ${XUL_LIBRARIES} ${GLUT_glut_LIBRARY})

View File

@@ -136,10 +136,6 @@ bool LLEmbeddedBrowser::init( std::string applicationDir,
{
mNativeWindowHandle = nativeWindowHandleIn;
std::cout<<"applicationDir "<<applicationDir<<std::endl;
std::cout<<"componentDir "<<componentDir<<std::endl;
std::cout<<"profileDir "<<profileDir<<std::endl;
NS_ConvertUTF8toUTF16 applicationDirUTF16(applicationDir.c_str());
NS_ConvertUTF8toUTF16 componentDirUTF16(componentDir.c_str());
NS_ConvertUTF8toUTF16 profileDirUTF16(profileDir.c_str());
@@ -148,8 +144,6 @@ bool LLEmbeddedBrowser::init( std::string applicationDir,
nsresult result = NS_NewLocalFile( applicationDirUTF16, PR_FALSE, getter_AddRefs( applicationDirNative ) );
if ( NS_FAILED( result ) )
{
std::cout<<"NS_NewLocalFile failed"<<std::endl;
setLastError( 0x1000 );
return false;
};
@@ -158,8 +152,6 @@ bool LLEmbeddedBrowser::init( std::string applicationDir,
result = NS_NewLocalFile( componentDirUTF16 , PR_FALSE, getter_AddRefs( componentDirNative ) );
if ( NS_FAILED( result ) )
{
std::cout<<"NS_NewLocalFile failed 2"<<std::endl;
setLastError( 0x1001 );
return false;
};
@@ -167,14 +159,10 @@ bool LLEmbeddedBrowser::init( std::string applicationDir,
result = XRE_InitEmbedding( componentDirNative, applicationDirNative, nsnull, nsnull, 0 );
if ( NS_FAILED( result ) )
{
std::cout<<"XRE_InitEmbedding failed"<<std::endl;
setLastError( 0x1002 );
return false;
};
std::cout<<"XRE_InitEmbedding succeeded"<<std::endl;
nsCOMPtr< nsILocalFile > profileDirNative;
result = NS_NewLocalFile( profileDirUTF16 , PR_TRUE, getter_AddRefs( profileDirNative ) );
if ( NS_FAILED( result ) )
@@ -182,7 +170,6 @@ bool LLEmbeddedBrowser::init( std::string applicationDir,
setLastError( 0x1007 );
return false;
};
#if 0
nsCOMPtr< nsProfileDirServiceProvider > locProvider;
NS_NewProfileDirServiceProvider( PR_TRUE, getter_AddRefs( locProvider ) );
if ( ! locProvider )
@@ -191,6 +178,7 @@ bool LLEmbeddedBrowser::init( std::string applicationDir,
XRE_TermEmbedding();
return PR_FALSE;
};
result = locProvider->Register();
if ( NS_FAILED( result ) )
{
@@ -206,7 +194,6 @@ bool LLEmbeddedBrowser::init( std::string applicationDir,
XRE_TermEmbedding();
return PR_FALSE;
};
#endif
nsCOMPtr<nsIPref> pref = do_CreateInstance( NS_PREF_CONTRACTID );
if ( pref )
@@ -242,8 +229,6 @@ bool LLEmbeddedBrowser::init( std::string applicationDir,
clearLastError();
std::cout<<"LLEmbeddedBrowser::init() succeeded"<<std::endl;
return true;
}
@@ -381,8 +366,7 @@ LLEmbeddedBrowserWindow* LLEmbeddedBrowser::createBrowserWindow( int browserWidt
LLEmbeddedBrowserWindow* newWin = new LLEmbeddedBrowserWindow();
if ( ! newWin )
{
std::cout<<"createBrowserWindow !newNew"<<std::endl;
return 0;
return 0;
};
nsIWebBrowserChrome** aNewWindow = getter_AddRefs( chrome );
@@ -398,7 +382,6 @@ LLEmbeddedBrowserWindow* LLEmbeddedBrowser::createBrowserWindow( int browserWidt
newWin->createBrowser( mNativeWindowHandle, browserWidthIn, browserHeightIn, getter_AddRefs( newBrowser ) );
if ( ! newBrowser )
{
std::cout<<"createBrowserWindow !newBrowser"<<std::endl;
return 0;
};

View File

@@ -47,32 +47,32 @@ class LLEmbeddedBrowserWindowObserver;
class LLEmbeddedBrowser
{
public:
LLEmbeddedBrowser();
virtual ~LLEmbeddedBrowser();
public:
LLEmbeddedBrowser();
virtual ~LLEmbeddedBrowser();
static LLEmbeddedBrowser* getInstance();
static LLEmbeddedBrowser* getInstance();
bool init( std::string applicationDir, std::string componentDir, std::string profileDir, void* nativeWindowHandleIn );
bool reset();
bool clearCache();
bool enableProxy( bool proxyEnabledIn, std::string proxyHostNameIn, int proxyPortIn );
bool enableCookies( bool enabledIn );
bool clearAllCookies();
bool enablePlugins( bool enabledIn );
std::string getGREVersion();
void setBrowserAgentId( std::string idIn );
LLEmbeddedBrowserWindow* createBrowserWindow( int browserWidthIn, int browserHeightIn );
bool destroyBrowserWindow( LLEmbeddedBrowserWindow* browserWindowIn );
void setLastError( int errorNumIn );
void clearLastError();
int getLastError();
bool init( std::string applicationDir, std::string componentDir, std::string profileDir, void* nativeWindowHandleIn );
bool reset();
bool clearCache();
bool enableProxy( bool proxyEnabledIn, std::string proxyHostNameIn, int proxyPortIn );
bool enableCookies( bool enabledIn );
bool clearAllCookies();
bool enablePlugins( bool enabledIn );
std::string getGREVersion();
void setBrowserAgentId( std::string idIn );
LLEmbeddedBrowserWindow* createBrowserWindow( int browserWidthIn, int browserHeightIn );
bool destroyBrowserWindow( LLEmbeddedBrowserWindow* browserWindowIn );
void setLastError( int errorNumIn );
void clearLastError();
int getLastError();
private:
static LLEmbeddedBrowser* sInstance;
void* mNativeWindowHandle;
int mErrorNum;
private:
static LLEmbeddedBrowser* sInstance;
void* mNativeWindowHandle;
int mErrorNum;
};
#endif // LLEMBEDDEDBROWSER_H
#endif // LLEMBEDDEDBROWSER_H

File diff suppressed because it is too large Load Diff

View File

@@ -75,57 +75,57 @@
template< class T >
class LLEmbeddedBrowserWindowEmitter
{
public:
LLEmbeddedBrowserWindowEmitter() { };
~LLEmbeddedBrowserWindowEmitter() { };
public:
LLEmbeddedBrowserWindowEmitter() { };
~LLEmbeddedBrowserWindowEmitter() { };
typedef typename T::EventType EventType;
typedef std::list< T* > ObserverContainer;
typedef void( T::*observerMethod )( const EventType& );
typedef typename T::EventType EventType;
typedef std::list< T* > ObserverContainer;
typedef void( T::*observerMethod )( const EventType& );
///////////////////////////////////////////////////////////////////////////////
//
bool addObserver( T* observerIn )
{
if ( ! observerIn )
return false;
///////////////////////////////////////////////////////////////////////////////
//
bool addObserver( T* observerIn )
{
if ( ! observerIn )
return false;
if ( std::find( observers.begin(), observers.end(), observerIn ) != observers.end() )
return false;
if ( std::find( observers.begin(), observers.end(), observerIn ) != observers.end() )
return false;
observers.push_back( observerIn );
observers.push_back( observerIn );
return true;
};
return true;
};
///////////////////////////////////////////////////////////////////////////////
//
bool remObserver( T* observerIn )
{
if ( ! observerIn )
return false;
///////////////////////////////////////////////////////////////////////////////
//
bool remObserver( T* observerIn )
{
if ( ! observerIn )
return false;
observers.remove( observerIn );
observers.remove( observerIn );
return true;
};
return true;
};
///////////////////////////////////////////////////////////////////////////////
//
void update( observerMethod method, const EventType& msgIn )
{
typename std::list< T* >::iterator iter = observers.begin();
///////////////////////////////////////////////////////////////////////////////
//
void update( observerMethod method, const EventType& msgIn )
{
typename std::list< T* >::iterator iter = observers.begin();
while( iter != observers.end() )
{
( ( *iter )->*method )( msgIn );
while( iter != observers.end() )
{
( ( *iter )->*method )( msgIn );
++iter;
};
};
++iter;
};
};
protected:
ObserverContainer observers;
protected:
ObserverContainer observers;
};
class LLEmbeddedBrowser;
@@ -133,131 +133,132 @@ class LLEmbeddedBrowser;
////////////////////////////////////////////////////////////////////////////////
// class for a "window" that holds a browser - there can be lots of these
class LLEmbeddedBrowserWindow :
public nsIInterfaceRequestor,
public nsIWebBrowserChrome,
public nsIWebProgressListener,
public nsIURIContentListener,
public nsIInterfaceRequestor,
public nsIWebBrowserChrome,
public nsIWebProgressListener,
public nsIURIContentListener,
#ifdef SUPPORTS_WEAK_REFENCE
public nsSupportsWeakReference,
public nsSupportsWeakReference,
#endif
public nsIDOMEventListener
#ifdef NS_DECL_NSITOOLKITOBSERVER
,public nsIToolkitObserver
public nsIToolkitObserver,
#endif
public nsIDOMEventListener
{
public:
LLEmbeddedBrowserWindow();
virtual ~LLEmbeddedBrowserWindow();
public:
LLEmbeddedBrowserWindow();
virtual ~LLEmbeddedBrowserWindow();
NS_DECL_ISUPPORTS
NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSIWEBBROWSERCHROME
NS_DECL_NSIWEBPROGRESSLISTENER
NS_DECL_NSIURICONTENTLISTENER
NS_DECL_NSIDOMEVENTLISTENER
NS_DECL_ISUPPORTS
NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSIWEBBROWSERCHROME
NS_DECL_NSIWEBPROGRESSLISTENER
NS_DECL_NSIURICONTENTLISTENER
NS_DECL_NSIDOMEVENTLISTENER
#ifdef NS_DECL_NSITOOLKITOBSERVER
NS_DECL_NSITOOLKITOBSERVER
NS_DECL_NSITOOLKITOBSERVER
#endif
// housekeeping
nsresult createBrowser( void* nativeWindowHandleIn, PRInt32 widthIn, PRInt32 heightIn, nsIWebBrowser** aBrowser );
void setParent( LLEmbeddedBrowser* parentIn ) { mParent = parentIn; };
PRBool setSize( PRInt16 widthIn, PRInt16 heightIn );
void focusBrowser( PRBool focusBrowserIn );
void scrollByLines( PRInt16 linesIn );
void setWindowId( int windowIdIn );
int getWindowId();
// housekeeping
nsresult createBrowser( void* nativeWindowHandleIn, PRInt32 widthIn, PRInt32 heightIn, nsIWebBrowser** aBrowser );
void setParent( LLEmbeddedBrowser* parentIn ) { mParent = parentIn; };
PRBool setSize( PRInt16 widthIn, PRInt16 heightIn );
void focusBrowser( PRBool focusBrowserIn );
void scrollByLines( PRInt16 linesIn );
void setWindowId( int windowIdIn );
int getWindowId();
NS_METHOD NotifyInvalidated(nsIWidget*, PRInt32, PRInt32, PRInt32, PRInt32);
// random accessors
const PRInt16 getPercentComplete();
const std::string& getStatusMsg();
const std::string& getCurrentUri();
const std::string& getClickLinkHref();
const std::string& getClickLinkTarget();
// random accessors
const PRInt16 getPercentComplete();
const std::string& getStatusMsg();
const std::string& getCurrentUri();
const std::string& getClickLinkHref();
const std::string& getClickLinkTarget();
// memory buffer management
unsigned char* grabWindow( int xIn, int yIn, int widthIn, int heightIn );
PRBool flipWindow( PRBool flip );
unsigned char* getPageBuffer();
PRInt16 getBrowserWidth();
PRInt16 getBrowserHeight();
PRInt16 getBrowserDepth();
PRInt32 getBrowserRowSpan();
// memory buffer management
unsigned char* grabWindow( int xIn, int yIn, int widthIn, int heightIn );
PRBool flipWindow( PRBool flip );
unsigned char* getPageBuffer();
PRInt16 getBrowserWidth();
PRInt16 getBrowserHeight();
PRInt16 getBrowserDepth();
PRInt32 getBrowserRowSpan();
// set background color that you see in between pages - default is white but sometimes useful to change
void setBackgroundColor( const PRUint8 redIn, const PRUint8 greenIn, const PRUint8 blueIn );
// set background color that you see in between pages - default is white but sometimes useful to change
void setBackgroundColor( const PRUint8 redIn, const PRUint8 greenIn, const PRUint8 blueIn );
// change the caret color (we have different backgrounds to edit fields - black caret on black background == bad)
void setCaretColor( const PRUint8 redIn, const PRUint8 greenIn, const PRUint8 blueIn );
// change the caret color (we have different backgrounds to edit fields - black caret on black background == bad)
void setCaretColor( const PRUint8 redIn, const PRUint8 greenIn, const PRUint8 blueIn );
// can turn off updates to a page - e.g. when it's hidden by your windowing system
void setEnabled( PRBool enabledIn );
// can turn off updates to a page - e.g. when it's hidden by your windowing system
void setEnabled( PRBool enabledIn );
// navigation
void navigateStop();
PRBool navigateTo( const std::string uriIn );
PRBool canNavigateBack();
void navigateBack();
PRBool canNavigateForward();
void navigateForward();
void navigateReload();
// navigation
void navigateStop();
PRBool navigateTo( const std::string uriIn );
PRBool canNavigateBack();
void navigateBack();
PRBool canNavigateForward();
void navigateForward();
void navigateReload();
// javascript access/control
std::string evaluateJavascript( std::string scriptIn );
// javascript access/control
std::string evaluateJavascript( std::string scriptIn );
// redirection when you hit a missing page
bool set404RedirectUrl( std::string redirect_url );
bool clr404RedirectUrl();
// redirection when you hit a missing page
bool set404RedirectUrl( std::string redirect_url );
bool clr404RedirectUrl();
// mouse & keyboard events
void mouseDown( PRInt16 xPosIn, PRInt16 yPosIn );
void mouseUp( PRInt16 xPosIn, PRInt16 yPosIn );
void mouseMove( PRInt16 xPosIn, PRInt16 yPosIn );
void mouseLeftDoubleClick( PRInt16 xPosIn, PRInt16 yPosIn );
void keyPress( PRInt16 keyCode );
void unicodeInput( PRUint32 uni_char );
// mouse & keyboard events
void mouseDown( PRInt16 xPosIn, PRInt16 yPosIn );
void mouseUp( PRInt16 xPosIn, PRInt16 yPosIn );
void mouseMove( PRInt16 xPosIn, PRInt16 yPosIn );
void mouseLeftDoubleClick( PRInt16 xPosIn, PRInt16 yPosIn );
void keyPress( PRInt16 keyCode );
void unicodeInput( PRUint32 uni_char );
// allow consumers of this class and to observe browser events
bool addObserver( LLEmbeddedBrowserWindowObserver* observerIn );
bool remObserver( LLEmbeddedBrowserWindowObserver* observerIn );
// allow consumers of this class and to observe browser events
bool addObserver( LLEmbeddedBrowserWindowObserver* observerIn );
bool remObserver( LLEmbeddedBrowserWindowObserver* observerIn );
// accessor/mutator for scheme that browser doesn't follow - e.g. secondlife.com://
void setNoFollowScheme( std::string schemeIn );
std::string getNoFollowScheme();
// accessor/mutator for scheme that browser doesn't follow - e.g. secondlife.com://
void setNoFollowScheme( std::string schemeIn );
std::string getNoFollowScheme();
private:
PRBool sendMozillaMouseEvent( PRInt16 eventIn, PRInt16 xPosIn, PRInt16 yPosIn, PRUint32 clickCountIn );
PRBool sendMozillaKeyboardEvent( PRUint32 keyIn, PRUint32 ns_vk_code );
PRBool renderCaret();
PRBool enableToolkitObserver( PRBool enableIn );
private:
PRBool sendMozillaMouseEvent( PRInt16 eventIn, PRInt16 xPosIn, PRInt16 yPosIn, PRUint32 clickCountIn );
PRBool sendMozillaKeyboardEvent( PRUint32 keyIn, PRUint32 ns_vk_code );
PRBool renderCaret();
PRBool enableToolkitObserver( PRBool enableIn );
LLEmbeddedBrowserWindowEmitter< LLEmbeddedBrowserWindowObserver > mEventEmitter;
LLEmbeddedBrowserWindowEmitter< LLEmbeddedBrowserWindowObserver > mEventEmitter;
LLEmbeddedBrowser* mParent;
PRInt16 mPercentComplete;
std::string mStatusText;
std::string mCurrentUri;
std::string mClickHref;
std::string mClickTarget;
std::string mNoFollowScheme;
nsCOMPtr< nsIWebBrowser > mWebBrowser;
nsCOMPtr< nsIBaseWindow > mBaseWindow;
nsCOMPtr< nsIWebNavigation > mWebNav;
int mWindowId;
unsigned char* mPageBuffer;
std::string m404RedirectUrl;
PRBool mEnabled;
PRBool mFlipBitmap;
PRInt32 mBrowserRowSpan;
PRInt16 mBrowserWidth;
PRInt16 mBrowserHeight;
PRInt16 mBrowserDepth;
PRUint8 mBkgRed;
PRUint8 mBkgGreen;
PRUint8 mBkgBlue;
PRUint8 mCaretRed;
PRUint8 mCaretGreen;
PRUint8 mCaretBlue;
LLEmbeddedBrowser* mParent;
PRInt16 mPercentComplete;
std::string mStatusText;
std::string mCurrentUri;
std::string mClickHref;
std::string mClickTarget;
std::string mNoFollowScheme;
nsCOMPtr< nsIWebBrowser > mWebBrowser;
nsCOMPtr< nsIBaseWindow > mBaseWindow;
nsCOMPtr< nsIWebNavigation > mWebNav;
int mWindowId;
unsigned char* mPageBuffer;
std::string m404RedirectUrl;
PRBool mEnabled;
PRBool mFlipBitmap;
PRInt32 mBrowserRowSpan;
PRInt16 mBrowserWidth;
PRInt16 mBrowserHeight;
PRInt16 mBrowserDepth;
PRUint8 mBkgRed;
PRUint8 mBkgGreen;
PRUint8 mBkgBlue;
PRUint8 mCaretRed;
PRUint8 mCaretGreen;
PRUint8 mCaretBlue;
};
#endif // LLEMBEDEDDBROWSERWINDOW_H

View File

@@ -51,7 +51,7 @@ LLMozLib* LLMozLib::sInstance = 0;
////////////////////////////////////////////////////////////////////////////////
//
LLMozLib::LLMozLib() :
mMaxBrowserWindows( 16 )
mMaxBrowserWindows( 16 )
{
}
@@ -59,12 +59,12 @@ LLMozLib::LLMozLib() :
//
LLMozLib* LLMozLib::getInstance()
{
if ( ! sInstance )
{
sInstance = new LLMozLib;
};
if ( ! sInstance )
{
sInstance = new LLMozLib;
};
return sInstance;
return sInstance;
}
////////////////////////////////////////////////////////////////////////////////
@@ -77,7 +77,7 @@ LLMozLib::~LLMozLib()
//
bool LLMozLib::init( std::string applicationDir, std::string componentDir, std::string profileDir, void* nativeWindowHandleIn )
{
return LLEmbeddedBrowser::getInstance()->init( applicationDir,
return LLEmbeddedBrowser::getInstance()->init( applicationDir,
componentDir,
profileDir,
nativeWindowHandleIn );
@@ -87,603 +87,600 @@ bool LLMozLib::init( std::string applicationDir, std::string componentDir, std::
//
int LLMozLib::getLastError()
{
return LLEmbeddedBrowser::getInstance()->getLastError();
return LLEmbeddedBrowser::getInstance()->getLastError();
}
////////////////////////////////////////////////////////////////////////////////
//
bool LLMozLib::reset()
{
return LLEmbeddedBrowser::getInstance()->reset();
return LLEmbeddedBrowser::getInstance()->reset();
}
////////////////////////////////////////////////////////////////////////////////
//
bool LLMozLib::clearCache()
{
return LLEmbeddedBrowser::getInstance()->clearCache();
return LLEmbeddedBrowser::getInstance()->clearCache();
}
////////////////////////////////////////////////////////////////////////////////
//
const std::string LLMozLib::getVersion()
{
const int majorVersion = 2;
const int minorVersion = 1;
const int majorVersion = 2;
const int minorVersion = 1;
// number of hours since "time began" for this library - used to identify builds of same version
const int magicNumber = static_cast< int >( ( time( NULL ) / 3600L ) - ( 321190L ) );
// number of hours since "time began" for this library - used to identify builds of same version
const int magicNumber = static_cast< int >( ( time( NULL ) / 3600L ) - ( 321190L ) );
// return as a string for now - don't think we need to expose actual version numbers
std::ostringstream codec;
codec << std::setw( 1 ) << std::setfill( '0' );
codec << majorVersion << ".";
codec << std::setw( 2 ) << std::setfill( '0' );
codec << minorVersion << ".";
codec << std::setw( 5 ) << std::setfill( '0' );
codec << magicNumber;
codec << " (Mozilla GRE version ";
codec << LLEmbeddedBrowser::getInstance()->getGREVersion();
codec << ")";
// return as a string for now - don't think we need to expose actual version numbers
std::ostringstream codec;
codec << std::setw( 1 ) << std::setfill( '0' );
codec << majorVersion << ".";
codec << std::setw( 2 ) << std::setfill( '0' );
codec << minorVersion << ".";
codec << std::setw( 5 ) << std::setfill( '0' );
codec << magicNumber;
codec << " (Mozilla GRE version ";
codec << LLEmbeddedBrowser::getInstance()->getGREVersion();
codec << ")";
return codec.str();
return codec.str();
}
////////////////////////////////////////////////////////////////////////////////
//
void LLMozLib::setBrowserAgentId( std::string idIn )
{
LLEmbeddedBrowser::getInstance()->setBrowserAgentId( idIn );
LLEmbeddedBrowser::getInstance()->setBrowserAgentId( idIn );
}
////////////////////////////////////////////////////////////////////////////////
//
bool LLMozLib::enableProxy( bool proxyEnabledIn, std::string proxyHostNameIn, int proxyPortIn )
{
return LLEmbeddedBrowser::getInstance()->enableProxy( proxyEnabledIn, proxyHostNameIn, proxyPortIn );
return LLEmbeddedBrowser::getInstance()->enableProxy( proxyEnabledIn, proxyHostNameIn, proxyPortIn );
}
////////////////////////////////////////////////////////////////////////////////
//
int LLMozLib::createBrowserWindow( int browserWindowWidthIn, int browserWindowHeightIn )
{
LLEmbeddedBrowserWindow* browserWindow = LLEmbeddedBrowser::getInstance()->createBrowserWindow( browserWindowWidthIn, browserWindowHeightIn );
LLEmbeddedBrowserWindow* browserWindow = LLEmbeddedBrowser::getInstance()->createBrowserWindow( browserWindowWidthIn, browserWindowHeightIn );
if ( browserWindow )
{
// arbitrary limit so we don't exhaust system resources
int id( 0 );
while ( ++id < mMaxBrowserWindows )
{
std::pair< BrowserWindowMapIter, bool > result = mBrowserWindowMap.insert( std::make_pair( id, browserWindow ) );
if ( browserWindow )
{
// arbitrary limit so we don't exhaust system resources
int id( 0 );
while ( ++id < mMaxBrowserWindows )
{
std::pair< BrowserWindowMapIter, bool > result = mBrowserWindowMap.insert( std::make_pair( id, browserWindow ) );
// find first place the insert succeeds and use that index as the id
if ( result.second )
{
browserWindow->setWindowId( id );
// find first place the insert succeeds and use that index as the id
if ( result.second )
{
browserWindow->setWindowId( id );
return id;
};
};
};
return id;
};
};
};
return 0;
return 0;
}
////////////////////////////////////////////////////////////////////////////////
//
bool LLMozLib::destroyBrowserWindow( int browserWindowIdIn )
{
// don't use the utility method here since we need the iterator to remove the entry from the map
BrowserWindowMapIter iter = mBrowserWindowMap.find( browserWindowIdIn );
LLEmbeddedBrowserWindow* browserWindow = (*iter).second;
// don't use the utility method here since we need the iterator to remove the entry from the map
BrowserWindowMapIter iter = mBrowserWindowMap.find( browserWindowIdIn );
LLEmbeddedBrowserWindow* browserWindow = (*iter).second;
if ( browserWindow )
{
LLEmbeddedBrowser::getInstance()->destroyBrowserWindow( browserWindow );
};
if ( browserWindow )
{
LLEmbeddedBrowser::getInstance()->destroyBrowserWindow( browserWindow );
};
mBrowserWindowMap.erase( iter );
mBrowserWindowMap.erase( iter );
return true;
return true;
}
////////////////////////////////////////////////////////////////////////////////
//
bool LLMozLib::setBackgroundColor( int browserWindowIdIn, const int redIn, const int greenIn, const int blueIn )
{
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->setBackgroundColor( redIn, greenIn, blueIn );
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->setBackgroundColor( redIn, greenIn, blueIn );
return true;
};
return true;
};
return false;
return false;
}
////////////////////////////////////////////////////////////////////////////////
//
bool LLMozLib::setCaretColor( int browserWindowIdIn, const int redIn, const int greenIn, const int blueIn )
{
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->setCaretColor( redIn, greenIn, blueIn );
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->setCaretColor( redIn, greenIn, blueIn );
return true;
};
return true;
};
return false;
return false;
}
////////////////////////////////////////////////////////////////////////////////
//
bool LLMozLib::setEnabled( int browserWindowIdIn, bool enabledIn )
{
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->setEnabled( enabledIn );
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->setEnabled( enabledIn );
return true;
};
return true;
};
return false;
return false;
}
////////////////////////////////////////////////////////////////////////////////
//
bool LLMozLib::setSize( int browserWindowIdIn, int widthIn, int heightIn )
{
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->setSize( widthIn, heightIn );
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->setSize( widthIn, heightIn );
return true;
};
return true;
};
return false;
return false;
}
////////////////////////////////////////////////////////////////////////////////
//
bool LLMozLib::scrollByLines( int browserWindowIdIn, int linesIn )
{
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->scrollByLines( linesIn );
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->scrollByLines( linesIn );
return true;
};
return true;
};
return false;
return false;
}
////////////////////////////////////////////////////////////////////////////////
//
bool LLMozLib::addObserver( int browserWindowIdIn, LLEmbeddedBrowserWindowObserver* subjectIn )
{
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->addObserver( subjectIn );
};
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->addObserver( subjectIn );
};
return true;
return true;
}
////////////////////////////////////////////////////////////////////////////////
//
bool LLMozLib::remObserver( int browserWindowIdIn, LLEmbeddedBrowserWindowObserver* subjectIn )
{
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->remObserver( subjectIn );
};
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->remObserver( subjectIn );
};
return true;
return true;
}
////////////////////////////////////////////////////////////////////////////////
//
bool LLMozLib::navigateTo( int browserWindowIdIn, const std::string uriIn )
{
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
return browserWindow->navigateTo( uriIn ) ? true : false;
};
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
return browserWindow->navigateTo( uriIn ) ? true : false;
};
return false;
return false;
}
////////////////////////////////////////////////////////////////////////////////
//
bool LLMozLib::navigateStop( int browserWindowIdIn )
{
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->navigateStop();
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->navigateStop();
return true;
};
return true;
};
return false;
return false;
}
////////////////////////////////////////////////////////////////////////////////
//
bool LLMozLib::canNavigateBack( int browserWindowIdIn )
{
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
return browserWindow->canNavigateBack() ? true : false;
};
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
return browserWindow->canNavigateBack() ? true : false;
};
return false;
return false;
}
////////////////////////////////////////////////////////////////////////////////
//
bool LLMozLib::navigateBack( int browserWindowIdIn )
{
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->navigateBack();
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->navigateBack();
return true;
};
return true;
};
return false;
return false;
}
////////////////////////////////////////////////////////////////////////////////
//
bool LLMozLib::canNavigateForward( int browserWindowIdIn )
{
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
return browserWindow->canNavigateForward() ? true : false;
};
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
return browserWindow->canNavigateForward() ? true : false;
};
return false;
return false;
}
////////////////////////////////////////////////////////////////////////////////
//
bool LLMozLib::navigateForward( int browserWindowIdIn )
{
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->navigateForward();
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->navigateForward();
return true;
};
return true;
};
return false;
return false;
}
////////////////////////////////////////////////////////////////////////////////
//
bool LLMozLib::navigateReload( int browserWindowIdIn )
{
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->navigateReload();
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->navigateReload();
return true;
};
return true;
};
return false;
return false;
}
///////////////////////////////////////////////////////////////////////////////
//
const unsigned char* LLMozLib::grabBrowserWindow( int browserWindowIdIn )
{
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
return browserWindow->grabWindow( 0, 0, getBrowserWidth( browserWindowIdIn ), getBrowserHeight( browserWindowIdIn ) );
};
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
return browserWindow->grabWindow( 0, 0, getBrowserWidth( browserWindowIdIn ), getBrowserHeight( browserWindowIdIn ) );
};
return 0;
return 0;
}
////////////////////////////////////////////////////////////////////////////////
//
const unsigned char* LLMozLib::getBrowserWindowPixels( int browserWindowIdIn )
{
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
std::cout<<"Returning browserWindow->getPageBuffer() "<<std::endl;
return browserWindow->getPageBuffer();
};
std::cout<<"No browserWindow"<<std::endl;
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
return browserWindow->getPageBuffer();
};
return 0;
return 0;
}
////////////////////////////////////////////////////////////////////////////////
//
const bool LLMozLib::flipWindow( int browserWindowIdIn, bool flipIn )
{
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->flipWindow( flipIn );
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->flipWindow( flipIn );
return true;
};
return true;
};
return false;
return false;
}
////////////////////////////////////////////////////////////////////////////////
//
const int LLMozLib::getBrowserWidth( int browserWindowIdIn )
{
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
return browserWindow->getBrowserWidth();
};
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
return browserWindow->getBrowserWidth();
};
return 0;
return 0;
}
////////////////////////////////////////////////////////////////////////////////
//
const int LLMozLib::getBrowserHeight( int browserWindowIdIn )
{
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
return browserWindow->getBrowserHeight();
};
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
return browserWindow->getBrowserHeight();
};
return 0;
return 0;
}
////////////////////////////////////////////////////////////////////////////////
//
const int LLMozLib::getBrowserDepth( int browserWindowIdIn )
{
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
return browserWindow->getBrowserDepth();
};
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
return browserWindow->getBrowserDepth();
};
return 0;
return 0;
}
////////////////////////////////////////////////////////////////////////////////
//
const int LLMozLib::getBrowserRowSpan( int browserWindowIdIn )
{
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
return browserWindow->getBrowserRowSpan();
};
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
return browserWindow->getBrowserRowSpan();
};
return 0;
return 0;
}
////////////////////////////////////////////////////////////////////////////////
//
bool LLMozLib::mouseDown( int browserWindowIdIn, int xPosIn, int yPosIn )
{
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->mouseDown( xPosIn, yPosIn );
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->mouseDown( xPosIn, yPosIn );
return true;
};
return true;
};
return false;
return false;
}
////////////////////////////////////////////////////////////////////////////////
//
bool LLMozLib::mouseUp( int browserWindowIdIn, int xPosIn, int yPosIn )
{
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->mouseUp( xPosIn, yPosIn );
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->mouseUp( xPosIn, yPosIn );
return true;
};
return true;
};
return false;
return false;
}
////////////////////////////////////////////////////////////////////////////////
//
bool LLMozLib::mouseMove( int browserWindowIdIn, int xPosIn, int yPosIn )
{
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->mouseMove( xPosIn, yPosIn );
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->mouseMove( xPosIn, yPosIn );
return true;
};
return true;
};
return false;
return false;
}
////////////////////////////////////////////////////////////////////////////////
//
bool LLMozLib::mouseLeftDoubleClick( int browserWindowIdIn, int xPosIn, int yPosIn )
{
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->mouseLeftDoubleClick( xPosIn, yPosIn );
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->mouseLeftDoubleClick( xPosIn, yPosIn );
return true;
};
return true;
};
return false;
return false;
}
////////////////////////////////////////////////////////////////////////////////
//
bool LLMozLib::keyPress( int browserWindowIdIn, int keyCodeIn )
{
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->keyPress( keyCodeIn );
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->keyPress( keyCodeIn );
return true;
};
return true;
};
return false;
return false;
}
bool LLMozLib::unicodeInput( int browserWindowIdIn, unsigned long uni_char )
{
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->unicodeInput( uni_char );
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->unicodeInput( uni_char );
return true;
};
return true;
};
return false;
return false;
}
////////////////////////////////////////////////////////////////////////////////
//
bool LLMozLib::focusBrowser( int browserWindowIdIn, bool focusBrowserIn )
{
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->focusBrowser( focusBrowserIn );
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->focusBrowser( focusBrowserIn );
return true;
};
return true;
};
return false;
return false;
}
////////////////////////////////////////////////////////////////////////////////
//
void LLMozLib::setNoFollowScheme( int browserWindowIdIn, std::string schemeIn )
{
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->setNoFollowScheme( schemeIn );
};
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
browserWindow->setNoFollowScheme( schemeIn );
};
}
////////////////////////////////////////////////////////////////////////////////
//
std::string LLMozLib::getNoFollowScheme( int browserWindowIdIn )
{
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
return browserWindow->getNoFollowScheme();
};
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
return browserWindow->getNoFollowScheme();
};
return ( "" );
return ( "" );
}
////////////////////////////////////////////////////////////////////////////////
//
bool LLMozLib::enableCookies( bool enabledIn )
{
return LLEmbeddedBrowser::getInstance()->enableCookies( enabledIn );
return LLEmbeddedBrowser::getInstance()->enableCookies( enabledIn );
}
////////////////////////////////////////////////////////////////////////////////
//
bool LLMozLib::clearAllCookies()
{
return LLEmbeddedBrowser::getInstance()->clearAllCookies();
return LLEmbeddedBrowser::getInstance()->clearAllCookies();
}
////////////////////////////////////////////////////////////////////////////////
//
bool LLMozLib::enablePlugins( bool enabledIn )
{
return LLEmbeddedBrowser::getInstance()->enablePlugins( enabledIn );
return LLEmbeddedBrowser::getInstance()->enablePlugins( enabledIn );
}
////////////////////////////////////////////////////////////////////////////////
//
std::string LLMozLib::evaluateJavascript( int browserWindowIdIn, const std::string scriptIn )
{
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
return browserWindow->evaluateJavascript( scriptIn );
};
LLEmbeddedBrowserWindow* browserWindow = getBrowserWindowFromWindowId( browserWindowIdIn );
if ( browserWindow )
{
return browserWindow->evaluateJavascript( scriptIn );
};
return "";
return "";
}
////////////////////////////////////////////////////////////////////////////////
//
bool LLMozLib::set404RedirectUrl( int browser_window_in, std::string redirect_url )
{
LLEmbeddedBrowserWindow* browser_window = getBrowserWindowFromWindowId( browser_window_in );
if ( browser_window )
{
browser_window->set404RedirectUrl( redirect_url );
LLEmbeddedBrowserWindow* browser_window = getBrowserWindowFromWindowId( browser_window_in );
if ( browser_window )
{
browser_window->set404RedirectUrl( redirect_url );
return true;
};
return true;
};
return false;
return false;
}
////////////////////////////////////////////////////////////////////////////////
//
bool LLMozLib::clr404RedirectUrl( int browser_window_in )
{
LLEmbeddedBrowserWindow* browser_window = getBrowserWindowFromWindowId( browser_window_in );
if ( browser_window )
{
browser_window->clr404RedirectUrl();
LLEmbeddedBrowserWindow* browser_window = getBrowserWindowFromWindowId( browser_window_in );
if ( browser_window )
{
browser_window->clr404RedirectUrl();
return true;
};
return true;
};
return false;
return false;
}
////////////////////////////////////////////////////////////////////////////////
// utility method to get an LLEmbeddedBrowserWindow* from a window id (int)
LLEmbeddedBrowserWindow* LLMozLib::getBrowserWindowFromWindowId( int browserWindowIdIn )
{
BrowserWindowMapIter iter = mBrowserWindowMap.find( browserWindowIdIn );
BrowserWindowMapIter iter = mBrowserWindowMap.find( browserWindowIdIn );
if ( iter != mBrowserWindowMap.end() )
return ( *iter ).second;
else
return 0;
if ( iter != mBrowserWindowMap.end() )
return ( *iter ).second;
else
return 0;
}

View File

@@ -49,206 +49,206 @@ class LLEmbeddedBrowserWindow;
// data class that is passed with an event
class LLEmbeddedBrowserWindowEvent
{
public:
LLEmbeddedBrowserWindowEvent( int eventWindowIdIn, std::string uriIn ) :
mEventWindowId( eventWindowIdIn ),
mEventUri( uriIn )
{
};
public:
LLEmbeddedBrowserWindowEvent( int eventWindowIdIn, std::string uriIn ) :
mEventWindowId( eventWindowIdIn ),
mEventUri( uriIn )
{
};
// single int passed with the event - e.g. progress
LLEmbeddedBrowserWindowEvent( int eventWindowIdIn, std::string uriIn, int intValIn ) :
mEventWindowId( eventWindowIdIn ),
mEventUri( uriIn ),
mIntVal( intValIn )
{
};
// single int passed with the event - e.g. progress
LLEmbeddedBrowserWindowEvent( int eventWindowIdIn, std::string uriIn, int intValIn ) :
mEventWindowId( eventWindowIdIn ),
mEventUri( uriIn ),
mIntVal( intValIn )
{
};
// string passed with the event
LLEmbeddedBrowserWindowEvent( int eventWindowIdIn, std::string uriIn, std::string stringValIn ) :
mEventWindowId( eventWindowIdIn ),
mEventUri( uriIn ),
mStringVal( stringValIn )
{
};
// string passed with the event
LLEmbeddedBrowserWindowEvent( int eventWindowIdIn, std::string uriIn, std::string stringValIn ) :
mEventWindowId( eventWindowIdIn ),
mEventUri( uriIn ),
mStringVal( stringValIn )
{
};
// 2 strings passed with the event
LLEmbeddedBrowserWindowEvent( int eventWindowIdIn, std::string uriIn, std::string stringValIn, std::string stringVal2In ) :
mEventWindowId( eventWindowIdIn ),
mEventUri( uriIn ),
mStringVal( stringValIn ),
mStringVal2( stringVal2In )
{
};
// 2 strings passed with the event
LLEmbeddedBrowserWindowEvent( int eventWindowIdIn, std::string uriIn, std::string stringValIn, std::string stringVal2In ) :
mEventWindowId( eventWindowIdIn ),
mEventUri( uriIn ),
mStringVal( stringValIn ),
mStringVal2( stringVal2In )
{
};
// string and an int passed with the event
LLEmbeddedBrowserWindowEvent( int eventWindowIdIn, std::string uriIn, std::string stringValIn, int intValIn ) :
mEventWindowId( eventWindowIdIn ),
mEventUri( uriIn ),
mStringVal( stringValIn ),
mIntVal( intValIn )
{
};
// string and an int passed with the event
LLEmbeddedBrowserWindowEvent( int eventWindowIdIn, std::string uriIn, std::string stringValIn, int intValIn ) :
mEventWindowId( eventWindowIdIn ),
mEventUri( uriIn ),
mStringVal( stringValIn ),
mIntVal( intValIn )
{
};
// 4 ints passed (semantically as a rectangle but could be anything - didn't want to make a RECT type structure)
LLEmbeddedBrowserWindowEvent( int eventWindowIdIn, std::string uriIn, int xIn, int yIn, int widthIn, int heightIn ) :
mEventWindowId( eventWindowIdIn ),
mEventUri( uriIn ),
mXVal( xIn ),
mYVal( yIn ),
mWidthVal( widthIn ),
mHeightVal( heightIn )
{
};
// 4 ints passed (semantically as a rectangle but could be anything - didn't want to make a RECT type structure)
LLEmbeddedBrowserWindowEvent( int eventWindowIdIn, std::string uriIn, int xIn, int yIn, int widthIn, int heightIn ) :
mEventWindowId( eventWindowIdIn ),
mEventUri( uriIn ),
mXVal( xIn ),
mYVal( yIn ),
mWidthVal( widthIn ),
mHeightVal( heightIn )
{
};
virtual ~LLEmbeddedBrowserWindowEvent()
{
};
virtual ~LLEmbeddedBrowserWindowEvent()
{
};
int getEventWindowId() const
{
return mEventWindowId;
};
int getEventWindowId() const
{
return mEventWindowId;
};
std::string getEventUri() const
{
return mEventUri;
};
std::string getEventUri() const
{
return mEventUri;
};
int getIntValue() const
{
return mIntVal;
};
int getIntValue() const
{
return mIntVal;
};
std::string getStringValue() const
{
return mStringVal;
};
std::string getStringValue() const
{
return mStringVal;
};
std::string getStringValue2() const
{
return mStringVal2;
};
std::string getStringValue2() const
{
return mStringVal2;
};
void getRectValue( int& xOut, int& yOut, int& widthOut, int& heightOut ) const
{
xOut = mXVal;
yOut = mYVal;
widthOut = mWidthVal;
heightOut = mHeightVal;
};
void getRectValue( int& xOut, int& yOut, int& widthOut, int& heightOut ) const
{
xOut = mXVal;
yOut = mYVal;
widthOut = mWidthVal;
heightOut = mHeightVal;
};
private:
int mEventWindowId;
std::string mEventUri;
int mIntVal;
std::string mStringVal;
std::string mStringVal2;
int mXVal;
int mYVal;
int mWidthVal;
int mHeightVal;
private:
int mEventWindowId;
std::string mEventUri;
int mIntVal;
std::string mStringVal;
std::string mStringVal2;
int mXVal;
int mYVal;
int mWidthVal;
int mHeightVal;
};
////////////////////////////////////////////////////////////////////////////////
// derrive from this class and override these methods to observe these events
class LLEmbeddedBrowserWindowObserver
{
public:
virtual ~LLEmbeddedBrowserWindowObserver() { };
typedef LLEmbeddedBrowserWindowEvent EventType;
public:
virtual ~LLEmbeddedBrowserWindowObserver() { };
typedef LLEmbeddedBrowserWindowEvent EventType;
virtual void onPageChanged( const EventType& eventIn ) { };
virtual void onNavigateBegin( const EventType& eventIn ) { };
virtual void onNavigateComplete( const EventType& eventIn ) { };
virtual void onUpdateProgress( const EventType& eventIn ) { };
virtual void onStatusTextChange( const EventType& eventIn ) { };
virtual void onLocationChange( const EventType& eventIn ) { };
virtual void onClickLinkHref( const EventType& eventIn ) { };
virtual void onClickLinkNoFollow( const EventType& eventIn ) { };
virtual void onPageChanged( const EventType& eventIn ) { };
virtual void onNavigateBegin( const EventType& eventIn ) { };
virtual void onNavigateComplete( const EventType& eventIn ) { };
virtual void onUpdateProgress( const EventType& eventIn ) { };
virtual void onStatusTextChange( const EventType& eventIn ) { };
virtual void onLocationChange( const EventType& eventIn ) { };
virtual void onClickLinkHref( const EventType& eventIn ) { };
virtual void onClickLinkNoFollow( const EventType& eventIn ) { };
};
////////////////////////////////////////////////////////////////////////////////
// main library class
class LLMozLib
{
public:
virtual ~LLMozLib();
public:
virtual ~LLMozLib();
// singleton access
static LLMozLib* getInstance();
// singleton access
static LLMozLib* getInstance();
// housekeeping
bool init( std::string applicationDir, std::string componentDir, std::string profileDir, void* nativeWindowHandleIn );
bool reset();
bool clearCache();
int getLastError();
const std::string getVersion();
void setBrowserAgentId( std::string idIn );
bool enableProxy( bool proxyEnabledIn, std::string proxyHostNameIn, int proxyPortIn );
bool enableCookies( bool enabledIn );
bool clearAllCookies();
bool enablePlugins( bool enabledIn );
// housekeeping
bool init( std::string applicationDir, std::string componentDir, std::string profileDir, void* nativeWindowHandleIn );
bool reset();
bool clearCache();
int getLastError();
const std::string getVersion();
void setBrowserAgentId( std::string idIn );
bool enableProxy( bool proxyEnabledIn, std::string proxyHostNameIn, int proxyPortIn );
bool enableCookies( bool enabledIn );
bool clearAllCookies();
bool enablePlugins( bool enabledIn );
// browser window - creation/deletion, mutation etc.
int createBrowserWindow( int browserWindowWidthIn, int browserWindowHeightIn );
bool destroyBrowserWindow( int browserWindowIdIn );
bool setSize( int browserWindowIdIn, int widthIn, int heightIn );
bool scrollByLines( int browserWindowIdIn, int linesIn );
bool setBackgroundColor( int browserWindowIdIn, const int redIn, const int greenIn, const int blueIn );
bool setCaretColor( int browserWindowIdIn, const int redIn, const int greenIn, const int blueIn );
bool setEnabled( int browserWindowIdIn, bool enabledIn );
// browser window - creation/deletion, mutation etc.
int createBrowserWindow( int browserWindowWidthIn, int browserWindowHeightIn );
bool destroyBrowserWindow( int browserWindowIdIn );
bool setSize( int browserWindowIdIn, int widthIn, int heightIn );
bool scrollByLines( int browserWindowIdIn, int linesIn );
bool setBackgroundColor( int browserWindowIdIn, const int redIn, const int greenIn, const int blueIn );
bool setCaretColor( int browserWindowIdIn, const int redIn, const int greenIn, const int blueIn );
bool setEnabled( int browserWindowIdIn, bool enabledIn );
// add/remove yourself as an observer on browser events - see LLEmbeddedBrowserWindowObserver declaration
bool addObserver( int browserWindowIdIn, LLEmbeddedBrowserWindowObserver* subjectIn );
bool remObserver( int browserWindowIdIn, LLEmbeddedBrowserWindowObserver* subjectIn );
// add/remove yourself as an observer on browser events - see LLEmbeddedBrowserWindowObserver declaration
bool addObserver( int browserWindowIdIn, LLEmbeddedBrowserWindowObserver* subjectIn );
bool remObserver( int browserWindowIdIn, LLEmbeddedBrowserWindowObserver* subjectIn );
// navigation - self explanatory
bool navigateTo( int browserWindowIdIn, const std::string uriIn );
bool navigateStop( int browserWindowIdIn );
bool canNavigateBack( int browserWindowIdIn );
bool navigateBack( int browserWindowIdIn );
bool canNavigateForward( int browserWindowIdIn );
bool navigateForward( int browserWindowIdIn );
bool navigateReload( int browserWindowIdIn );
// navigation - self explanatory
bool navigateTo( int browserWindowIdIn, const std::string uriIn );
bool navigateStop( int browserWindowIdIn );
bool canNavigateBack( int browserWindowIdIn );
bool navigateBack( int browserWindowIdIn );
bool canNavigateForward( int browserWindowIdIn );
bool navigateForward( int browserWindowIdIn );
bool navigateReload( int browserWindowIdIn );
// javascript access/control
std::string evaluateJavascript( int browserWindowIdIn, const std::string scriptIn );
// javascript access/control
std::string evaluateJavascript( int browserWindowIdIn, const std::string scriptIn );
// set/clear URL to redirect to when a 404 page is reached
bool set404RedirectUrl( int browser_window_in, std::string redirect_url );
bool clr404RedirectUrl( int browser_window_in );
// set/clear URL to redirect to when a 404 page is reached
bool set404RedirectUrl( int browser_window_in, std::string redirect_url );
bool clr404RedirectUrl( int browser_window_in );
// access to rendered bitmap data
const unsigned char* grabBrowserWindow( int browserWindowIdIn ); // renders page to memory and returns pixels
const unsigned char* getBrowserWindowPixels( int browserWindowIdIn ); // just returns pixels - no render
const bool flipWindow( int browserWindowIdIn, bool flipIn ); // optionally flip window (pixels) you get back
const int getBrowserWidth( int browserWindowIdIn ); // current browser width (can vary slightly after page is rendered)
const int getBrowserHeight( int browserWindowIdIn ); // current height
const int getBrowserDepth( int browserWindowIdIn ); // depth in bytes
const int getBrowserRowSpan( int browserWindowIdIn ); // width in pixels * depth in bytes
// access to rendered bitmap data
const unsigned char* grabBrowserWindow( int browserWindowIdIn ); // renders page to memory and returns pixels
const unsigned char* getBrowserWindowPixels( int browserWindowIdIn ); // just returns pixels - no render
const bool flipWindow( int browserWindowIdIn, bool flipIn ); // optionally flip window (pixels) you get back
const int getBrowserWidth( int browserWindowIdIn ); // current browser width (can vary slightly after page is rendered)
const int getBrowserHeight( int browserWindowIdIn ); // current height
const int getBrowserDepth( int browserWindowIdIn ); // depth in bytes
const int getBrowserRowSpan( int browserWindowIdIn ); // width in pixels * depth in bytes
// mouse/keyboard interaction
bool mouseDown( int browserWindowIdIn, int xPosIn, int yPosIn ); // send a mouse down event to a browser window at given XY in browser space
bool mouseUp( int browserWindowIdIn, int xPosIn, int yPosIn ); // send a mouse up event to a browser window at given XY in browser space
bool mouseMove( int browserWindowIdIn, int xPosIn, int yPosIn ); // send a mouse move event to a browser window at given XY in browser space
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
bool keyPress( int browserWindowIdIn, int keyCodeIn ); // send a key press event to a browser window
bool unicodeInput ( int browserWindowIdIn, unsigned long uni_char ); // send a unicode keypress event to a browser window
bool focusBrowser( int browserWindowIdIn, bool focusBrowserIn ); // set/remove focus to given browser window
// mouse/keyboard interaction
bool mouseDown( int browserWindowIdIn, int xPosIn, int yPosIn ); // send a mouse down event to a browser window at given XY in browser space
bool mouseUp( int browserWindowIdIn, int xPosIn, int yPosIn ); // send a mouse up event to a browser window at given XY in browser space
bool mouseMove( int browserWindowIdIn, int xPosIn, int yPosIn ); // send a mouse move event to a browser window at given XY in browser space
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
bool keyPress( int browserWindowIdIn, int keyCodeIn ); // send a key press event to a browser window
bool unicodeInput ( int browserWindowIdIn, unsigned long uni_char ); // send a unicode keypress event to a browser window
bool focusBrowser( int browserWindowIdIn, bool focusBrowserIn ); // set/remove focus to given browser window
// accessor/mutator for scheme that browser doesn't follow - e.g. secondlife.com://
void setNoFollowScheme( int browserWindowIdIn, std::string schemeIn );
std::string getNoFollowScheme( int browserWindowIdIn );
// accessor/mutator for scheme that browser doesn't follow - e.g. secondlife.com://
void setNoFollowScheme( int browserWindowIdIn, std::string schemeIn );
std::string getNoFollowScheme( int browserWindowIdIn );
private:
LLMozLib();
LLEmbeddedBrowserWindow* getBrowserWindowFromWindowId( int browserWindowIdIn );
static LLMozLib* sInstance;
const int mMaxBrowserWindows;
typedef std::map< int, LLEmbeddedBrowserWindow* > BrowserWindowMap;
typedef std::map< int, LLEmbeddedBrowserWindow* >::iterator BrowserWindowMapIter;
BrowserWindowMap mBrowserWindowMap;
private:
LLMozLib();
LLEmbeddedBrowserWindow* getBrowserWindowFromWindowId( int browserWindowIdIn );
static LLMozLib* sInstance;
const int mMaxBrowserWindows;
typedef std::map< int, LLEmbeddedBrowserWindow* > BrowserWindowMap;
typedef std::map< int, LLEmbeddedBrowserWindow* >::iterator BrowserWindowMapIter;
BrowserWindowMap mBrowserWindowMap;
};
// Mozilla virtual keycodes.

View File

@@ -0,0 +1,544 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Conrad Carlen <ccarlen@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsProfileDirServiceProvider.h"
#include "nsProfileStringTypes.h"
#include "nsProfileLock.h"
#include "nsILocalFile.h"
#include "nsDirectoryServiceDefs.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsISupportsUtils.h"
#include "nsISimpleEnumerator.h"
#include "nsIObserverService.h"
#ifdef MOZ_PROFILESHARING
#include "nsIProfileSharingSetup.h"
#include "ipcITransactionService.h"
#endif
// File Name Defines
#define PREFS_FILE_50_NAME NS_LITERAL_CSTRING("prefs.js")
#define USER_CHROME_DIR_50_NAME NS_LITERAL_CSTRING("chrome")
#define LOCAL_STORE_FILE_50_NAME NS_LITERAL_CSTRING("localstore.rdf")
#define HISTORY_FILE_50_NAME NS_LITERAL_CSTRING("history.dat")
#define PANELS_FILE_50_NAME NS_LITERAL_CSTRING("panels.rdf")
#define MIME_TYPES_FILE_50_NAME NS_LITERAL_CSTRING("mimeTypes.rdf")
#define BOOKMARKS_FILE_50_NAME NS_LITERAL_CSTRING("bookmarks.html")
#define DOWNLOADS_FILE_50_NAME NS_LITERAL_CSTRING("downloads.rdf")
#define SEARCH_FILE_50_NAME NS_LITERAL_CSTRING("search.rdf" )
#define MAIL_DIR_50_NAME NS_LITERAL_CSTRING("Mail")
#define IMAP_MAIL_DIR_50_NAME NS_LITERAL_CSTRING("ImapMail")
#define NEWS_DIR_50_NAME NS_LITERAL_CSTRING("News")
#define MSG_FOLDER_CACHE_DIR_50_NAME NS_LITERAL_CSTRING("panacea.dat")
#define STORAGE_FILE_50_NAME NS_LITERAL_CSTRING("storage.sdb")
//*****************************************************************************
// nsProfileDirServiceProvider::nsProfileDirServiceProvider
//*****************************************************************************
nsProfileDirServiceProvider::nsProfileDirServiceProvider(PRBool aNotifyObservers) :
#ifdef MOZ_PROFILELOCKING
mProfileDirLock(nsnull),
#endif
mNotifyObservers(aNotifyObservers),
mSharingEnabled(PR_FALSE)
{
}
nsProfileDirServiceProvider::~nsProfileDirServiceProvider()
{
#ifdef MOZ_PROFILELOCKING
delete mProfileDirLock;
#endif
}
nsresult
nsProfileDirServiceProvider::SetProfileDir(nsIFile* aProfileDir,
nsIFile* aLocalProfileDir)
{
if (!aLocalProfileDir)
aLocalProfileDir = aProfileDir;
if (mProfileDir) {
PRBool isEqual;
if (aProfileDir &&
NS_SUCCEEDED(aProfileDir->Equals(mProfileDir, &isEqual)) && isEqual) {
NS_WARNING("Setting profile dir to same as current");
return NS_OK;
}
#ifdef MOZ_PROFILELOCKING
mProfileDirLock->Unlock();
#endif
UndefineFileLocations();
}
mProfileDir = aProfileDir;
mLocalProfileDir = aLocalProfileDir;
if (!mProfileDir)
return NS_OK;
nsresult rv = InitProfileDir(mProfileDir);
if (NS_FAILED(rv))
return rv;
// Make sure that the local profile dir exists
// we just try to create it - if it exists already, that'll fail; ignore
// errors
mLocalProfileDir->Create(nsIFile::DIRECTORY_TYPE, 0700);
#ifdef MOZ_PROFILESHARING
if (mSharingEnabled) {
nsCOMPtr<ipcITransactionService> transServ =
do_GetService(IPC_TRANSACTIONSERVICE_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv)) {
nsCAutoString nativePath;
rv = mProfileDir->GetNativePath(nativePath);
if (NS_SUCCEEDED(rv))
rv = transServ->Init(nativePath);
}
if (NS_FAILED(rv)) {
NS_WARNING("Unable to initialize transaction service");
}
}
#endif
#ifdef MOZ_PROFILELOCKING
// Lock the non-shared sub-dir if we are sharing,
// the whole profile dir if we are not.
nsCOMPtr<nsILocalFile> dirToLock;
if (mSharingEnabled)
dirToLock = do_QueryInterface(mNonSharedProfileDir);
else
dirToLock = do_QueryInterface(mProfileDir);
rv = mProfileDirLock->Lock(dirToLock, nsnull);
if (NS_FAILED(rv))
return rv;
#endif
if (mNotifyObservers) {
nsCOMPtr<nsIObserverService> observerService =
do_GetService("@mozilla.org/observer-service;1");
if (!observerService)
return NS_ERROR_FAILURE;
NS_NAMED_LITERAL_STRING(context, "startup");
// Notify observers that the profile has changed - Here they respond to new profile
observerService->NotifyObservers(nsnull, "profile-do-change", context.get());
// Now observers can respond to something another observer did on "profile-do-change"
observerService->NotifyObservers(nsnull, "profile-after-change", context.get());
}
return NS_OK;
}
nsresult
nsProfileDirServiceProvider::Register()
{
nsCOMPtr<nsIDirectoryService> directoryService =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID);
if (!directoryService)
return NS_ERROR_FAILURE;
return directoryService->RegisterProvider(this);
}
nsresult
nsProfileDirServiceProvider::Shutdown()
{
if (!mNotifyObservers)
return NS_OK;
nsCOMPtr<nsIObserverService> observerService =
do_GetService("@mozilla.org/observer-service;1");
if (!observerService)
return NS_ERROR_FAILURE;
NS_NAMED_LITERAL_STRING(context, "shutdown-persist");
observerService->NotifyObservers(nsnull, "profile-before-change", context.get());
return NS_OK;
}
//*****************************************************************************
// nsProfileDirServiceProvider::nsISupports
//*****************************************************************************
NS_IMPL_THREADSAFE_ISUPPORTS1(nsProfileDirServiceProvider,
nsIDirectoryServiceProvider)
//*****************************************************************************
// nsProfileDirServiceProvider::nsIDirectoryServiceProvider
//*****************************************************************************
NS_IMETHODIMP
nsProfileDirServiceProvider::GetFile(const char *prop, PRBool *persistant, nsIFile **_retval)
{
NS_ENSURE_ARG(prop);
NS_ENSURE_ARG_POINTER(persistant);
NS_ENSURE_ARG_POINTER(_retval);
// Don't assert - we can be called many times before SetProfileDir() has been called.
if (!mProfileDir)
return NS_ERROR_FAILURE;
*persistant = PR_TRUE;
nsIFile* domainDir = mProfileDir;
#ifdef MOZ_PROFILESHARING
// If the prop is prefixed with NS_SHARED,
// the location is in the shared domain.
PRBool bUseShared = PR_FALSE;
if (strncmp(prop, NS_SHARED, sizeof(NS_SHARED)-1) == 0) {
prop += (sizeof(NS_SHARED)-1);
bUseShared = PR_TRUE;
}
if (!bUseShared && mNonSharedProfileDir)
domainDir = mNonSharedProfileDir;
#endif
nsCOMPtr<nsIFile> localFile;
nsresult rv = NS_ERROR_FAILURE;
if (strcmp(prop, NS_APP_PREFS_50_DIR) == 0) {
rv = domainDir->Clone(getter_AddRefs(localFile));
}
else if (strcmp(prop, NS_APP_PREFS_50_FILE) == 0) {
rv = domainDir->Clone(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendNative(PREFS_FILE_50_NAME);
}
else if (strcmp(prop, NS_APP_USER_PROFILE_50_DIR) == 0) {
rv = domainDir->Clone(getter_AddRefs(localFile));
}
else if (strcmp(prop, NS_APP_USER_PROFILE_LOCAL_50_DIR) == 0) {
rv = mLocalProfileDir->Clone(getter_AddRefs(localFile));
}
else if (strcmp(prop, NS_APP_USER_CHROME_DIR) == 0) {
rv = domainDir->Clone(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendNative(USER_CHROME_DIR_50_NAME);
}
else if (strcmp(prop, NS_APP_LOCALSTORE_50_FILE) == 0) {
rv = domainDir->Clone(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv)) {
rv = localFile->AppendNative(LOCAL_STORE_FILE_50_NAME);
if (NS_SUCCEEDED(rv)) {
// it's OK if we can't copy the file... it will be created
// by client code.
(void) EnsureProfileFileExists(localFile, domainDir);
}
}
}
else if (strcmp(prop, NS_APP_HISTORY_50_FILE) == 0) {
rv = domainDir->Clone(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendNative(HISTORY_FILE_50_NAME);
}
else if (strcmp(prop, NS_APP_USER_PANELS_50_FILE) == 0) {
rv = domainDir->Clone(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv)) {
rv = localFile->AppendNative(PANELS_FILE_50_NAME);
if (NS_SUCCEEDED(rv))
rv = EnsureProfileFileExists(localFile, domainDir);
}
}
else if (strcmp(prop, NS_APP_USER_MIMETYPES_50_FILE) == 0) {
rv = domainDir->Clone(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv)) {
rv = localFile->AppendNative(MIME_TYPES_FILE_50_NAME);
if (NS_SUCCEEDED(rv))
rv = EnsureProfileFileExists(localFile, domainDir);
}
}
else if (strcmp(prop, NS_APP_BOOKMARKS_50_FILE) == 0) {
rv = domainDir->Clone(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendNative(BOOKMARKS_FILE_50_NAME);
}
else if (strcmp(prop, NS_APP_DOWNLOADS_50_FILE) == 0) {
rv = domainDir->Clone(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendNative(DOWNLOADS_FILE_50_NAME);
}
else if (strcmp(prop, NS_APP_SEARCH_50_FILE) == 0) {
rv = domainDir->Clone(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv)) {
rv = localFile->AppendNative(SEARCH_FILE_50_NAME);
if (NS_SUCCEEDED(rv))
rv = EnsureProfileFileExists(localFile, domainDir);
}
}
else if (strcmp(prop, NS_APP_MAIL_50_DIR) == 0) {
rv = domainDir->Clone(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendNative(MAIL_DIR_50_NAME);
}
else if (strcmp(prop, NS_APP_IMAP_MAIL_50_DIR) == 0) {
rv = domainDir->Clone(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendNative(IMAP_MAIL_DIR_50_NAME);
}
else if (strcmp(prop, NS_APP_NEWS_50_DIR) == 0) {
rv = domainDir->Clone(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendNative(NEWS_DIR_50_NAME);
}
else if (strcmp(prop, NS_APP_MESSENGER_FOLDER_CACHE_50_DIR) == 0) {
rv = domainDir->Clone(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendNative(MSG_FOLDER_CACHE_DIR_50_NAME);
}
else if (strcmp(prop, NS_APP_STORAGE_50_FILE) == 0) {
rv = domainDir->Clone(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendNative(STORAGE_FILE_50_NAME);
}
if (localFile && NS_SUCCEEDED(rv))
return CallQueryInterface(localFile, _retval);
return rv;
}
//*****************************************************************************
// Protected methods
//*****************************************************************************
nsresult
nsProfileDirServiceProvider::Initialize()
{
#ifdef MOZ_PROFILELOCKING
mProfileDirLock = new nsProfileLock;
if (!mProfileDirLock)
return NS_ERROR_OUT_OF_MEMORY;
#endif
#ifdef MOZ_PROFILESHARING
nsCOMPtr<nsIProfileSharingSetup> sharingSetup =
do_GetService("@mozilla.org/embedcomp/profile-sharing-setup;1");
if (sharingSetup) {
PRBool tempBool;
if (NS_SUCCEEDED(sharingSetup->GetIsSharingEnabled(&tempBool)))
mSharingEnabled = tempBool;
if (mSharingEnabled)
sharingSetup->GetClientName(mNonSharedDirName);
}
#endif
return NS_OK;
}
nsresult
nsProfileDirServiceProvider::InitProfileDir(nsIFile *profileDir)
{
// Make sure our "Profile" folder exists.
// If it does not, copy the profile defaults to its location.
nsresult rv;
PRBool exists;
rv = profileDir->Exists(&exists);
if (NS_FAILED(rv))
return rv;
if (!exists) {
nsCOMPtr<nsIFile> profileDefaultsDir;
nsCOMPtr<nsIFile> profileDirParent;
nsCAutoString profileDirName;
(void)profileDir->GetParent(getter_AddRefs(profileDirParent));
if (!profileDirParent)
return NS_ERROR_FAILURE;
rv = profileDir->GetNativeLeafName(profileDirName);
if (NS_FAILED(rv))
return rv;
rv = NS_GetSpecialDirectory(NS_APP_PROFILE_DEFAULTS_50_DIR, getter_AddRefs(profileDefaultsDir));
if (NS_FAILED(rv)) {
rv = NS_GetSpecialDirectory(NS_APP_PROFILE_DEFAULTS_NLOC_50_DIR, getter_AddRefs(profileDefaultsDir));
if (NS_FAILED(rv))
return rv;
}
rv = profileDefaultsDir->CopyToNative(profileDirParent, profileDirName);
if (NS_FAILED(rv)) {
// if copying failed, lets just ensure that the profile directory exists.
profileDirParent->AppendNative(profileDirName);
rv = profileDirParent->Create(nsIFile::DIRECTORY_TYPE, 0700);
if (NS_FAILED(rv))
return rv;
}
#if !defined(XP_MAC) && !defined(WINCE)
rv = profileDir->SetPermissions(0700);
if (NS_FAILED(rv))
return rv;
#endif
}
else {
PRBool isDir;
rv = profileDir->IsDirectory(&isDir);
if (NS_FAILED(rv))
return rv;
if (!isDir)
return NS_ERROR_FILE_NOT_DIRECTORY;
}
if (mNonSharedDirName.Length())
rv = InitNonSharedProfileDir();
return rv;
}
nsresult
nsProfileDirServiceProvider::InitNonSharedProfileDir()
{
nsresult rv;
NS_ENSURE_STATE(mProfileDir);
NS_ENSURE_STATE(mNonSharedDirName.Length());
nsCOMPtr<nsIFile> localDir;
rv = mProfileDir->Clone(getter_AddRefs(localDir));
if (NS_SUCCEEDED(rv)) {
rv = localDir->Append(mNonSharedDirName);
if (NS_SUCCEEDED(rv)) {
PRBool exists;
rv = localDir->Exists(&exists);
if (NS_SUCCEEDED(rv)) {
if (!exists) {
rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0700);
}
else {
PRBool isDir;
rv = localDir->IsDirectory(&isDir);
if (NS_SUCCEEDED(rv)) {
if (!isDir)
rv = NS_ERROR_FILE_NOT_DIRECTORY;
}
}
if (NS_SUCCEEDED(rv))
mNonSharedProfileDir = localDir;
}
}
}
return rv;
}
nsresult
nsProfileDirServiceProvider::EnsureProfileFileExists(nsIFile *aFile, nsIFile *destDir)
{
nsresult rv;
PRBool exists;
rv = aFile->Exists(&exists);
if (NS_FAILED(rv))
return rv;
if (exists)
return NS_OK;
nsCOMPtr<nsIFile> defaultsFile;
// Attempt first to get the localized subdir of the defaults
rv = NS_GetSpecialDirectory(NS_APP_PROFILE_DEFAULTS_50_DIR, getter_AddRefs(defaultsFile));
if (NS_FAILED(rv)) {
// If that has not been defined, use the top level of the defaults
rv = NS_GetSpecialDirectory(NS_APP_PROFILE_DEFAULTS_NLOC_50_DIR, getter_AddRefs(defaultsFile));
if (NS_FAILED(rv))
return rv;
}
nsCAutoString leafName;
rv = aFile->GetNativeLeafName(leafName);
if (NS_FAILED(rv))
return rv;
rv = defaultsFile->AppendNative(leafName);
if (NS_FAILED(rv))
return rv;
return defaultsFile->CopyTo(destDir, EmptyString());
}
nsresult
nsProfileDirServiceProvider::UndefineFileLocations()
{
nsresult rv;
nsCOMPtr<nsIProperties> directoryService =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
NS_ENSURE_TRUE(directoryService, NS_ERROR_FAILURE);
(void) directoryService->Undefine(NS_APP_PREFS_50_DIR);
(void) directoryService->Undefine(NS_APP_PREFS_50_FILE);
(void) directoryService->Undefine(NS_APP_USER_PROFILE_50_DIR);
(void) directoryService->Undefine(NS_APP_USER_CHROME_DIR);
(void) directoryService->Undefine(NS_APP_LOCALSTORE_50_FILE);
(void) directoryService->Undefine(NS_APP_HISTORY_50_FILE);
(void) directoryService->Undefine(NS_APP_USER_PANELS_50_FILE);
(void) directoryService->Undefine(NS_APP_USER_MIMETYPES_50_FILE);
(void) directoryService->Undefine(NS_APP_BOOKMARKS_50_FILE);
(void) directoryService->Undefine(NS_APP_DOWNLOADS_50_FILE);
(void) directoryService->Undefine(NS_APP_SEARCH_50_FILE);
(void) directoryService->Undefine(NS_APP_MAIL_50_DIR);
(void) directoryService->Undefine(NS_APP_IMAP_MAIL_50_DIR);
(void) directoryService->Undefine(NS_APP_NEWS_50_DIR);
(void) directoryService->Undefine(NS_APP_MESSENGER_FOLDER_CACHE_50_DIR);
return NS_OK;
}
//*****************************************************************************
// Global creation function
//*****************************************************************************
nsresult NS_NewProfileDirServiceProvider(PRBool aNotifyObservers,
nsProfileDirServiceProvider** aProvider)
{
NS_ENSURE_ARG_POINTER(aProvider);
*aProvider = nsnull;
nsProfileDirServiceProvider *prov = new nsProfileDirServiceProvider(aNotifyObservers);
if (!prov)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv = prov->Initialize();
if (NS_FAILED(rv)) {
delete prov;
return rv;
}
NS_ADDREF(*aProvider = prov);
return NS_OK;
}

View File

@@ -0,0 +1,145 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Conrad Carlen <ccarlen@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// Interfaces Needed
#include "nsIDirectoryService.h"
#include "nsILocalFile.h"
#include "nsCOMPtr.h"
#include "nsDirectoryServiceUtils.h"
#include "nsComponentManagerUtils.h"
#include "nsServiceManagerUtils.h"
#ifdef MOZILLA_INTERNAL_API
#include "nsString.h"
#else
#include "nsEmbedString.h"
#endif
// Forward Declarations
class nsProfileLock;
// --------------------------------------------------------------------------------------
// nsProfileDirServiceProvider - The nsIDirectoryServiceProvider implementation used for
// profile-relative file locations.
// --------------------------------------------------------------------------------------
class nsProfileDirServiceProvider: public nsIDirectoryServiceProvider
{
NS_DECL_ISUPPORTS
NS_DECL_NSIDIRECTORYSERVICEPROVIDER
friend nsresult NS_NewProfileDirServiceProvider(PRBool, nsProfileDirServiceProvider**);
public:
/**
* SetProfileDir
*
* @param aProfileDir The directory containing the profile files.
* It does not need to exist before calling this
* method. If it does not, it will be created and
* defaults will be copied to it.
* @param aLocalProfileDir
* Directory for local profile data, e.g. Cache.
* If null, aProfileDir will be used for this purpose.
*/
virtual nsresult SetProfileDir(nsIFile* aProfileDir,
nsIFile* aLocalProfileDir = nsnull);
/**
* Register
*
* Convenience method to register the provider with directory service.
* The service holds strong references to registered providers so consumers
* don't need to hold a reference to this object after calling Register().
*/
virtual nsresult Register();
/**
* Shutdown
*
* This method must be called before shutting down XPCOM if this object
* was created with aNotifyObservers == PR_TRUE. If this object was
* created with aNotifyObservers == PR_FALSE, this method is a no-op.
*/
virtual nsresult Shutdown();
protected:
nsProfileDirServiceProvider(PRBool aNotifyObservers = PR_TRUE);
virtual ~nsProfileDirServiceProvider();
nsresult Initialize();
nsresult InitProfileDir(nsIFile* profileDir);
nsresult InitNonSharedProfileDir();
nsresult EnsureProfileFileExists(nsIFile *aFile, nsIFile *destDir);
nsresult UndefineFileLocations();
protected:
nsCOMPtr<nsIFile> mProfileDir;
nsCOMPtr<nsIFile> mLocalProfileDir;
nsProfileLock* mProfileDirLock;
PRPackedBool mNotifyObservers;
PRPackedBool mSharingEnabled;
#ifndef MOZILLA_INTERNAL_API
nsEmbedString mNonSharedDirName;
#else
nsString mNonSharedDirName;
#endif
nsCOMPtr<nsIFile> mNonSharedProfileDir;
};
// --------------------------------------------------------------------------------------
/**
* Global method to create an instance of nsProfileDirServiceProvider
*
* @param aNotifyObservers If true, will send out profile startup
* notifications when the profile directory is set.
* See nsIProfileChangeStatus.
*/
nsresult NS_NewProfileDirServiceProvider(PRBool aNotifyObservers,
nsProfileDirServiceProvider** aProvider);

View File

@@ -0,0 +1,112 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Conrad Carlen <ccarlen@netscape.com>
* Brendan Eich <brendan@mozilla.org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __nsProfileLock_h___
#define __nsProfileLock_h___
#include "nsILocalFile.h"
class nsIProfileUnlocker;
#if defined (XP_WIN)
#include <windows.h>
#endif
#if defined (XP_OS2)
#define INCL_DOSERRORS
#define INCL_DOSFILEMGR
#include <os2.h>
#endif
#if defined (XP_UNIX)
#include "prclist.h"
#endif
class nsProfileLock
#if defined (XP_UNIX)
: public PRCList
#endif
{
public:
nsProfileLock();
nsProfileLock(nsProfileLock& src);
~nsProfileLock();
nsProfileLock& operator=(nsProfileLock& rhs);
/**
* Attempt to lock a profile directory.
*
* @param aProfileDir [in] The profile directory to lock.
* @param aUnlocker [out] Optional. This is only returned when locking
* fails with NS_ERROR_FILE_ACCESS_DENIED, and may not
* be returned at all.
* @throws NS_ERROR_FILE_ACCESS_DENIED if the profile is locked.
*/
nsresult Lock(nsILocalFile* aProfileDir, nsIProfileUnlocker* *aUnlocker);
nsresult Unlock();
private:
PRPackedBool mHaveLock;
#if defined (XP_WIN)
HANDLE mLockFileHandle;
#elif defined (XP_OS2)
LHANDLE mLockFileHandle;
#elif defined (XP_UNIX)
static void RemovePidLockFiles();
static void FatalSignalHandler(int signo);
static PRCList mPidLockList;
nsresult LockWithFcntl(const nsACString& lockFilePath);
/**
* @param aHaveFcntlLock if true, we've already acquired an fcntl lock so this
* lock is merely an "obsolete" lock to keep out old Firefoxes
*/
nsresult LockWithSymlink(const nsACString& lockFilePath, PRBool aHaveFcntlLock);
char* mPidLockFileName;
int mLockFileDesc;
#endif
};
#endif /* __nsProfileLock_h___ */

View File

@@ -0,0 +1,64 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Marco Pesenti Gritti <marco@gnome.org>.
* Portions created by the Initial Developer are Copyright (C) 2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
* We support two builds of the directory service provider.
* One, linked into the profile component, uses the internal
* string API. The other can be used by standalone embedding
* clients, and uses embed strings.
* To keep the code clean, we are using typedefs to equate
* embed/internal string types. We are also defining some
* internal macros in terms of the embedding strings API.
*
* When modifying the profile directory service provider, be
* sure to use methods supported by both the internal and
* embed strings APIs.
*/
#ifndef MOZILLA_INTERNAL_API
#include "nsStringAPI.h"
typedef nsCString nsPromiseFlatCString;
typedef nsCString nsCAutoString;
#define PromiseFlatCString nsCString
#else
#include "nsString.h"
#include "nsPromiseFlatString.h"
#endif

View File

@@ -74,6 +74,7 @@ class testGL :
mNeedsUpdate( true ), // flag to indicate if browser texture needs an update
mBrowserWindowId( 0 ),
mAppWindowName( "testGL" ),
//mHomeUrl( "http://www.google.com" )
mHomeUrl( "http://www.google.com" )
{
std::cout << "LLMozLib version: " << LLMozLib::getInstance()->getVersion() << std::endl;
@@ -174,20 +175,7 @@ class testGL :
glutPostRedisplay();
};
////////////////////////////////////////////////////////////////////////////////
//
void idle()
{
//std::cout<<"idle()"<<std::endl;
// onPageChanged event sets this
// if ( mNeedsUpdate )
// grab a page but don't reset 'needs update' flag until we've written it to the texture in display()
LLMozLib::getInstance()->grabBrowserWindow( mBrowserWindowId );
// lots of updates for smooth motion
glutPostRedisplay();
};
void idle();
////////////////////////////////////////////////////////////////////////////////
//
@@ -206,17 +194,20 @@ class testGL :
// valid window ?
if ( mBrowserWindowId )
{
static int count = 0;
count++;
// needs to be updated?
if ( mNeedsUpdate )
if ( mNeedsUpdate && (count%1)==0)
{
// grab the page
std::cout<<"mNeedsUpdate = true"<<std::endl;
// std::cout<<"mNeedsUpdate = true"<<std::endl;
const unsigned char* pixels = LLMozLib::getInstance()->getBrowserWindowPixels( mBrowserWindowId );
if ( pixels )
{
std::cout<<"Texture subload "<<LLMozLib::getInstance()->getBrowserRowSpan( mBrowserWindowId ) / LLMozLib::getInstance()->getBrowserDepth( mBrowserWindowId )<<", "<<mBrowserWindowHeight<<std::endl;
//std::cout<<"Texture subload "<<LLMozLib::getInstance()->getBrowserRowSpan( mBrowserWindowId ) / LLMozLib::getInstance()->getBrowserDepth( mBrowserWindowId )<<", "<<mBrowserWindowHeight<<std::endl;
// write them into the texture
glTexSubImage2D( GL_TEXTURE_2D, 0,
@@ -234,7 +225,7 @@ class testGL :
}
// flag as already updated
// mNeedsUpdate = false;
//mNeedsUpdate = false;
};
};
@@ -251,16 +242,16 @@ class testGL :
glColor3f( 1.0f, 1.0f, 1.0f );
glBegin( GL_QUADS );
glTexCoord2f( 1.0f, 0.0f );
glVertex2d( mAppWindowWidth*0.8, 0 );
glVertex2d( mAppWindowWidth, 0 );
glTexCoord2f( 0.0f, 0.0f );
glVertex2d( 0, 0 );
glTexCoord2f( 0.0f, 1.0f );
glVertex2d( 0, mAppWindowHeight*0.8 );
glVertex2d( 0, mAppWindowHeight );
glTexCoord2f( 1.0f, 1.0f );
glVertex2d( mAppWindowWidth*0.8, mAppWindowHeight*0.8 );
glVertex2d( mAppWindowWidth, mAppWindowHeight );
glEnd();
glMatrixMode( GL_TEXTURE );
@@ -318,14 +309,6 @@ class testGL :
//
void keyboard( unsigned char keyIn, int xIn, int yIn )
{
if (keyIn=='a')
{
// go to the "home page"
LLMozLib::getInstance()->navigateTo( mBrowserWindowId, "http://www.linuxtoday.org" );
std::cout<<"new browse to"<<std::endl;
}
// ESC key exits
if ( keyIn == 27 )
{
@@ -335,7 +318,8 @@ class testGL :
};
// send event to LLMozLib
LLMozLib::getInstance()->keyPress( mBrowserWindowId, keyIn );
if (keyIn<32) LLMozLib::getInstance()->keyPress( mBrowserWindowId, keyIn );
else LLMozLib::getInstance()->unicodeInput( mBrowserWindowId, keyIn );
};
////////////////////////////////////////////////////////////////////////////////
@@ -432,6 +416,23 @@ testGL* theApp;
////////////////////////////////////////////////////////////////////////////////
//
#ifdef _WINDOWS
////////////////////////////////////////////////////////////////////////////////
//
void idle()
{
//std::cout<<"idle()"<<std::endl;
// onPageChanged event sets this
// if ( mNeedsUpdate )
// grab a page but don't reset 'needs update' flag until we've written it to the texture in display()
LLMozLib::getInstance()->grabBrowserWindow( mBrowserWindowId );
// lots of updates for smooth motion
glutPostRedisplay();
};
void* testGL::getNativeWindowHandle()
{
// My implementation of the embedded browser needs a native window handle
@@ -442,18 +443,49 @@ void* testGL::getNativeWindowHandle()
#include <gtk/gtk.h>
////////////////////////////////////////////////////////////////////////////////
//
void testGL::idle()
{
// pump the GTK+Gecko event queue for a (limited) while. this should
// be done so that the Gecko event queue doesn't starve, and done
// *here* so that mNeedsUpdate[] can be populated by callbacks
// from Gecko.
gtk_main_iteration_do(0);
for (int iter=0; iter<10; ++iter)
if (gtk_events_pending())
gtk_main_iteration();
//std::cout<<"idle()"<<std::endl;
// onPageChanged event sets this
// if ( mNeedsUpdate )
// grab a page but don't reset 'needs update' flag until we've written it to the texture in display()
LLMozLib::getInstance()->grabBrowserWindow( mBrowserWindowId );
// lots of updates for smooth motion
glutPostRedisplay();
};
void* testGL::getNativeWindowHandle()
{
gtk_disable_setlocale();
gtk_init(NULL, NULL);
gtk_disable_setlocale();
gtk_init(NULL, NULL);
GtkWidget *win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_realize(win);
gtk_window_set_title(GTK_WINDOW(win), "Raw gecko window");
GtkWidget *win = gtk_window_new(GTK_WINDOW_POPUP);
// Why a layout widget? A MozContainer would be ideal, but
// it involves exposing Mozilla headers to mozlib-using apps.
// A layout widget with a GtkWindow parent has the desired
// properties of being plain GTK, having a window, and being
// derived from a GtkContainer.
GtkWidget *rtnw = gtk_layout_new(NULL, NULL);
gtk_container_add(GTK_CONTAINER(win), rtnw);
gtk_widget_realize(rtnw);
GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(rtnw), GTK_NO_WINDOW);
GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(win), GTK_NO_WINDOW);
return win;
return rtnw;
};
#endif