From bd8d03f151af110600f3e3bddb948ea9f17543db Mon Sep 17 00:00:00 2001 From: "amardare%qnx.com" Date: Mon, 26 Apr 2004 21:31:52 +0000 Subject: [PATCH] Changes for the qnx(photon) platform only. It should not affect building/runtime other platforms. Moved the xremote server setup ( PtConnector create ) to nsPhMozRemoteHelper.cpp where it belonged in the first place. The immediate reason was that the embedding stuff, if run first, would have set up the connector, making the subsequent xremote commands fail. git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_7_BRANCH@155547 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/widget/src/photon/nsAppShell.cpp | 64 ------------------ .../widget/src/photon/nsPhMozRemoteHelper.cpp | 65 ++++++++++++++++++- 2 files changed, 64 insertions(+), 65 deletions(-) diff --git a/mozilla/widget/src/photon/nsAppShell.cpp b/mozilla/widget/src/photon/nsAppShell.cpp index 0e7402cddf6..9f3719170d7 100644 --- a/mozilla/widget/src/photon/nsAppShell.cpp +++ b/mozilla/widget/src/photon/nsAppShell.cpp @@ -43,10 +43,6 @@ #include "nsIEventQueueService.h" #include "nsICmdLineService.h" -#ifdef MOZ_ENABLE_XREMOTE -#include -#endif - #include #include "nsIWidget.h" @@ -131,61 +127,6 @@ static int event_processor_callback(int fd, void *data, unsigned mode) } - -//------------------------------------------------------------------------- -// -// A client has connected and probably will want to xremote control us -// -//------------------------------------------------------------------------- - -#ifdef MOZ_ENABLE_XREMOTE - -/* the connector name that a client can use to remote control this instance of mozilla */ - -#if defined(MOZ_PHOENIX) -#define RemoteServerName "FirebirdRemoteServer" -#elif defined(MOZ_THUNDERBIRD) -#define RemoteServerName "ThunderbirdRemoteServer" -#else -#define RemoteServerName "MozillaRemoteServer" -#endif - -#define MOZ_REMOTE_MSG_TYPE 100 - -static void const * RemoteMsgHandler( PtConnectionServer_t *connection, void *user_data, - unsigned long type, void const *msg, unsigned len, unsigned *reply_len ) -{ - if( type != MOZ_REMOTE_MSG_TYPE ) return NULL; - - /* we are given strings and we reply with strings */ - char *command = ( char * ) msg, *response = NULL; - - // parse the command - nsCOMPtr remoteService; - remoteService = do_GetService(NS_IXREMOTESERVICE_CONTRACTID); - - if( remoteService ) { - command[len] = 0; - /* it seems we can pass any non-null value as the first argument - if this changes, pass a valid nsWidget* and move this code to nsWidget.cpp */ - remoteService->ParseCommand( (nsIWidget*)0x1, command, &response ); - } - - PtConnectionReply( connection, response ? strlen( response ) : 0, response ); - - if( response ) nsCRT::free( response ); - - return ( void * ) 1; /* return any non NULL value to indicate we handled the message */ -} - -static void client_connect( PtConnector_t *cntr, PtConnectionServer_t *csrvr, void *data ) -{ - static PtConnectionMsgHandler_t handlers[] = { { 0, RemoteMsgHandler } }; - PtConnectionAddMsgHandlers( csrvr, handlers, sizeof(handlers)/sizeof(handlers[0]) ); -} - -#endif - - //------------------------------------------------------------------------- // // Create the application shell @@ -222,11 +163,6 @@ NS_IMETHODIMP nsAppShell::Create(int *bac, char **bav) PtInit( NULL ); PtChannelCreate(); // Force use of pulses mPtInited = PR_TRUE; - -#ifdef MOZ_ENABLE_XREMOTE - /* create a connector for the xremote control */ - PtConnectorCreate( RemoteServerName, client_connect, NULL ); -#endif } return NS_OK; diff --git a/mozilla/widget/src/photon/nsPhMozRemoteHelper.cpp b/mozilla/widget/src/photon/nsPhMozRemoteHelper.cpp index 106b3f05078..a92ffef3f9a 100644 --- a/mozilla/widget/src/photon/nsPhMozRemoteHelper.cpp +++ b/mozilla/widget/src/photon/nsPhMozRemoteHelper.cpp @@ -26,6 +26,62 @@ #include #include #include "nsPhMozRemoteHelper.h" +#include "nsIServiceManager.h" +#include "nsCRT.h" + +#include + + +//------------------------------------------------------------------------- +// +// A client has connected and probably will want to xremote control us +// +//------------------------------------------------------------------------- + +/* the connector name that a client can use to remote control this instance of mozilla */ + +#if defined(MOZ_PHOENIX) +#define RemoteServerName "FirebirdRemoteServer" +#elif defined(MOZ_THUNDERBIRD) +#define RemoteServerName "ThunderbirdRemoteServer" +#else +#define RemoteServerName "MozillaRemoteServer" +#endif + +#define MOZ_REMOTE_MSG_TYPE 100 + +static void const * RemoteMsgHandler( PtConnectionServer_t *connection, void *user_data, + unsigned long type, void const *msg, unsigned len, unsigned *reply_len ) +{ + if( type != MOZ_REMOTE_MSG_TYPE ) return NULL; + + /* we are given strings and we reply with strings */ + char *command = ( char * ) msg, *response = NULL; + + // parse the command + nsCOMPtr remoteService; + remoteService = do_GetService(NS_IXREMOTESERVICE_CONTRACTID); + + if( remoteService ) { + command[len] = 0; + /* it seems we can pass any non-null value as the first argument - if this changes, pass a valid nsWidget* and move this code to nsWidget.cpp */ + remoteService->ParseCommand( (nsIWidget*)0x1, command, &response ); + } + + PtConnectionReply( connection, response ? strlen( response ) : 0, response ); + + if( response ) nsCRT::free( response ); + + return ( void * ) 1; /* return any non NULL value to indicate we handled the message */ +} + +static void client_connect( PtConnector_t *cntr, PtConnectionServer_t *csrvr, void *data ) +{ + static PtConnectionMsgHandler_t handlers[] = { { 0, RemoteMsgHandler } }; + PtConnectionAddMsgHandlers( csrvr, handlers, sizeof(handlers)/sizeof(handlers[0]) ); +} + + nsPhXRemoteWidgetHelper::nsPhXRemoteWidgetHelper() { @@ -40,6 +96,13 @@ NS_IMPL_ISUPPORTS1(nsPhXRemoteWidgetHelper, nsIXRemoteWidgetHelper) NS_IMETHODIMP nsPhXRemoteWidgetHelper::EnableXRemoteCommands( nsIWidget *aWidget, const char *aProfile, const char *aProgram ) { + static PRBool ConnectorCreated = PR_FALSE; + + if( !ConnectorCreated ) { + /* create a connector for the xremote control */ + PtConnectorCreate( RemoteServerName, client_connect, NULL ); + ConnectorCreated = PR_TRUE; + } + return NS_OK; } -