Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Static Public Member Functions
ipcCommandModule Struct Reference

List of all members.

Public Types

typedef void(* MsgHandler )(ipcClient *, const ipcMessage *)

Static Public Member Functions

static char ** BuildStringArray (const ipcStringNode *nodes)
static nsID ** BuildIDArray (const ipcIDNode *nodes)
static void OnPing (ipcClient *client, const ipcMessage *rawMsg)
static void OnClientHello (ipcClient *client, const ipcMessage *rawMsg)
static void OnClientAddName (ipcClient *client, const ipcMessage *rawMsg)
static void OnClientDelName (ipcClient *client, const ipcMessage *rawMsg)
static void OnClientAddTarget (ipcClient *client, const ipcMessage *rawMsg)
static void OnClientDelTarget (ipcClient *client, const ipcMessage *rawMsg)
static void OnQueryClientByName (ipcClient *client, const ipcMessage *rawMsg)
static void OnForward (ipcClient *client, const ipcMessage *rawMsg)

Detailed Description

Definition at line 50 of file ipcCommandModule.cpp.


Member Typedef Documentation

Definition at line 52 of file ipcCommandModule.cpp.


Member Function Documentation

static nsID** ipcCommandModule::BuildIDArray ( const ipcIDNode nodes) [inline, static]

Definition at line 81 of file ipcCommandModule.cpp.

    {
        size_t count = 0;

        const ipcIDNode *node;
        
        for (node = nodes; node; node = node->mNext)
            count++;

        nsID **ids = (nsID **) calloc(count + 1, sizeof(nsID *));
        if (!ids)
            return NULL;

        count = 0;
        for (node = nodes; node; node = node->mNext, ++count)
            ids[count] = (nsID *) &node->Value();

        return ids;
    }

Here is the call graph for this function:

static char** ipcCommandModule::BuildStringArray ( const ipcStringNode nodes) [inline, static]

Definition at line 59 of file ipcCommandModule.cpp.

    {
        size_t count = 0;

        const ipcStringNode *node;
        
        for (node = nodes; node; node = node->mNext)
            count++;

        char **strs = (char **) malloc((count + 1) * sizeof(char *));
        if (!strs)
            return NULL;

        count = 0;
        for (node = nodes; node; node = node->mNext, ++count)
            strs[count] = (char *) node->Value();
        strs[count] = 0;

        return strs;
    }

Here is the call graph for this function:

static void ipcCommandModule::OnClientAddName ( ipcClient client,
const ipcMessage rawMsg 
) [inline, static]

Definition at line 131 of file ipcCommandModule.cpp.

    {
        LOG(("got CLIENT_ADD_NAME\n"));

        ipcMessageCast<ipcmMessageClientAddName> msg(rawMsg);
        const char *name = msg->Name();
        if (name)
            client->AddName(name);

        // TODO: send better status code (e.g., suppose name already defined for client)
        IPC_SendMsg(client, new ipcmMessageResult(IPCM_GetRequestIndex(rawMsg), IPCM_OK));
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static void ipcCommandModule::OnClientAddTarget ( ipcClient client,
const ipcMessage rawMsg 
) [inline, static]

Definition at line 159 of file ipcCommandModule.cpp.

    {
        LOG(("got CLIENT_ADD_TARGET\n"));

        ipcMessageCast<ipcmMessageClientAddTarget> msg(rawMsg);
        client->AddTarget(msg->Target());

        // TODO: send better status code (e.g., suppose target already defined for client)
        IPC_SendMsg(client, new ipcmMessageResult(IPCM_GetRequestIndex(rawMsg), IPCM_OK));
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static void ipcCommandModule::OnClientDelName ( ipcClient client,
const ipcMessage rawMsg 
) [inline, static]

Definition at line 145 of file ipcCommandModule.cpp.

    {
        LOG(("got CLIENT_DEL_NAME\n"));

        ipcMessageCast<ipcmMessageClientDelName> msg(rawMsg);
        const char *name = msg->Name();
        if (name)
            client->DelName(name);

        // TODO: send better status code (e.g., suppose name not defined for client)
        IPC_SendMsg(client, new ipcmMessageResult(IPCM_GetRequestIndex(rawMsg), IPCM_OK));
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static void ipcCommandModule::OnClientDelTarget ( ipcClient client,
const ipcMessage rawMsg 
) [inline, static]

Definition at line 171 of file ipcCommandModule.cpp.

    {
        LOG(("got CLIENT_DEL_TARGET\n"));

        ipcMessageCast<ipcmMessageClientDelTarget> msg(rawMsg);
        client->DelTarget(msg->Target());

        // TODO: send better status code (e.g., suppose target not defined for client)
        IPC_SendMsg(client, new ipcmMessageResult(IPCM_GetRequestIndex(rawMsg), IPCM_OK));
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static void ipcCommandModule::OnClientHello ( ipcClient client,
const ipcMessage rawMsg 
) [inline, static]

Definition at line 114 of file ipcCommandModule.cpp.

    {
        LOG(("got CLIENT_HELLO\n"));

        IPC_SendMsg(client, new ipcmMessageClientID(IPCM_GetRequestIndex(rawMsg), client->ID()));

        //
        // NOTE: it would almost make sense for this notification to live
        // in the transport layer code.  however, clients expect to receive
        // a CLIENT_ID as the first message following a CLIENT_HELLO, so we
        // must not allow modules to see a client until after we have sent
        // the CLIENT_ID message.
        //
        IPC_NotifyClientUp(client);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static void ipcCommandModule::OnForward ( ipcClient client,
const ipcMessage rawMsg 
) [inline, static]

Definition at line 230 of file ipcCommandModule.cpp.

    {
        LOG(("got FORWARD\n"));

        ipcMessageCast<ipcmMessageForward> msg(rawMsg);

        ipcClient *dest = IPC_GetClientByID(msg->ClientID());
        if (!dest) {
            LOG(("  destination client not found!\n"));
            IPC_SendMsg(client, new ipcmMessageResult(IPCM_GetRequestIndex(rawMsg), IPCM_ERROR_NO_CLIENT));
            return;
        }
        // inform client that its message will be forwarded
        IPC_SendMsg(client, new ipcmMessageResult(IPCM_GetRequestIndex(rawMsg), IPCM_OK));

        ipcMessage *newMsg = new ipcmMessageForward(IPCM_MSG_PSH_FORWARD,
                                                    client->ID(),
                                                    msg->InnerTarget(),
                                                    msg->InnerData(),
                                                    msg->InnerDataLen());
        IPC_SendMsg(dest, newMsg);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static void ipcCommandModule::OnPing ( ipcClient client,
const ipcMessage rawMsg 
) [inline, static]

Definition at line 106 of file ipcCommandModule.cpp.

    {
        LOG(("got PING\n"));

        IPC_SendMsg(client, new ipcmMessageResult(IPCM_GetRequestIndex(rawMsg), IPCM_OK));
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static void ipcCommandModule::OnQueryClientByName ( ipcClient client,
const ipcMessage rawMsg 
) [inline, static]

Definition at line 183 of file ipcCommandModule.cpp.

    {
        LOG(("got QUERY_CLIENT_BY_NAME\n"));

        PRUint32 requestIndex = IPCM_GetRequestIndex(rawMsg);

        ipcMessageCast<ipcmMessageQueryClientByName> msg(rawMsg);

        ipcClient *result = IPC_GetClientByName(msg->Name());
        if (result) {
            LOG(("  client exists w/ ID = %u\n", result->ID()));
            IPC_SendMsg(client, new ipcmMessageClientID(requestIndex, result->ID()));
        }
        else {
            LOG(("  client does not exist\n"));
            IPC_SendMsg(client, new ipcmMessageResult(requestIndex, IPCM_ERROR_NO_CLIENT));
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this struct was generated from the following file: