Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions | Variables
nsPhRemoteService.cpp File Reference
#include <stdlib.h>
#include <nsIWidget.h>
#include <nsCOMPtr.h>
#include "nsIGenericFactory.h"
#include "nsPhRemoteService.h"
#include "nsIServiceManager.h"
#include "nsCRT.h"
#include "nsISuiteRemoteService.h"
#include <Pt.h>

Go to the source code of this file.

Defines

#define MOZ_REMOTE_MSG_TYPE   100
#define NS_REMOTESERVICE_CID   { 0xc0773e90, 0x5799, 0x4eff, { 0xad, 0x3, 0x3e, 0xbc, 0xd8, 0x56, 0x24, 0xac } }

Functions

 NS_IMPL_QUERY_INTERFACE2 (nsPhRemoteService, nsIRemoteService, nsIObserver) nsPhRemoteService
static void constRemoteMsgHandler (PtConnectionServer_t *connection, void *user_data, unsigned long type, void const *msg, unsigned len, unsigned *reply_len)
static void client_connect (PtConnector_t *cntr, PtConnectionServer_t *csrvr, void *data)

Variables

static const nsModuleComponentInfo components []

Define Documentation

Definition at line 100 of file nsPhRemoteService.cpp.

#define NS_REMOTESERVICE_CID   { 0xc0773e90, 0x5799, 0x4eff, { 0xad, 0x3, 0x3e, 0xbc, 0xd8, 0x56, 0x24, 0xac } }

Definition at line 179 of file nsPhRemoteService.cpp.


Function Documentation

static void client_connect ( PtConnector_t *  cntr,
PtConnectionServer_t *  csrvr,
void data 
) [static]

Definition at line 154 of file nsPhRemoteService.cpp.

{
       static PtConnectionMsgHandler_t handlers[] = { { 0, RemoteMsgHandler } };
       PtConnectionAddMsgHandlers( csrvr, handlers, sizeof(handlers)/sizeof(handlers[0]) );
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 40 of file nsPhRemoteService.cpp.

{
  return 1;
}
static void const* RemoteMsgHandler ( PtConnectionServer_t *  connection,
void user_data,
unsigned long  type,
void const msg,
unsigned  len,
unsigned *  reply_len 
) [static]

Definition at line 102 of file nsPhRemoteService.cpp.

{
    nsresult rv;

       if( type != MOZ_REMOTE_MSG_TYPE ) return NULL;

       /* we are given strings and we reply with strings */
       char *response = NULL;

       // parse the command
    nsCOMPtr<nsICommandLineRunner> cmdline
      (do_CreateInstance("@mozilla.org/toolkit/command-line;1", &rv));
    if (!NS_FAILED(rv)) {

      // 1) Make sure that it looks remotely valid with parens
      // 2) Treat ping() immediately and specially

      nsCAutoString command((char *)msg);
      PRInt32 p1, p2;
      p1 = command.FindChar('(');
      p2 = command.FindChar(')');

      if (p1 != kNotFound && p2 != kNotFound && p1 != 0 && p2 >= p1) {
        command.Truncate(p1);
        command.Trim(" ", PR_TRUE, PR_TRUE);
        ToLowerCase(command);

        //printf("Processing xremote command: %s\n", command.get());

        if (!command.EqualsLiteral("ping")) {
          char* argv[3] = {"dummyappname", "-remote", (char *)msg};
          rv = cmdline->Init(3, argv, nsnull, nsICommandLine::STATE_REMOTE_EXPLICIT);
          if (!NS_FAILED(rv)) {
            rv = cmdline->Run();
            if (NS_ERROR_ABORT == rv)
              response = "500 command not parseable";
            if (NS_FAILED(rv))
              response = "509 internal error";
             } else
            response = "509 internal error";
        }
      } else
        response = "500 command not parseable";
       } else
      response = "509 internal error";

       PtConnectionReply( connection, response ? strlen(response) : 0, response );

       return ( void * ) 1; /* return any non NULL value to indicate we handled the message */
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Initial value:
{
  { "Remote Service",
    NS_REMOTESERVICE_CID,
    "@mozilla.org/toolkit/remote-service;1",
    nsPhRemoteServiceConstructor
  }
}

Definition at line 184 of file nsPhRemoteService.cpp.