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.
This commit is contained in:
amardare%qnx.com 2004-04-26 21:30:42 +00:00
Родитель 6860e94d83
Коммит 5da349dffb
2 изменённых файлов: 64 добавлений и 67 удалений

Просмотреть файл

@ -43,10 +43,6 @@
#include "nsIEventQueueService.h"
#include "nsICmdLineService.h"
#ifdef MOZ_ENABLE_XREMOTE
#include <nsIXRemoteService.h>
#endif
#include <stdlib.h>
#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<nsIXRemoteService> 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;

Просмотреть файл

@ -35,13 +35,67 @@
*
* ***** END LICENSE BLOCK ***** */
/* the XRemoteService.cpp insists on getting the "widget helper service" */
#include <stdlib.h>
#include <nsIWidget.h>
#include <nsIXRemoteService.h>
#include <nsCOMPtr.h>
#include "nsPhMozRemoteHelper.h"
#include "nsIServiceManager.h"
#include "nsCRT.h"
#include <Pt.h>
//-------------------------------------------------------------------------
//
// 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<nsIXRemoteService> 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()
{
@ -56,6 +110,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;
}