Back to index

lightning-sunbird  0.9+nobinonly
Functions
ipcd.cpp File Reference
#include "prlog.h"
#include "prio.h"
#include "ipcConfig.h"
#include "ipcLog.h"
#include "ipcMessage.h"
#include "ipcClient.h"
#include "ipcModuleReg.h"
#include "ipcModule.h"
#include "ipcCommandModule.h"
#include "ipcdPrivate.h"
#include "ipcd.h"

Go to the source code of this file.

Functions

void IPC_NotifyParent ()
PRStatus IPC_DispatchMsg (ipcClient *client, const ipcMessage *msg)
PRStatus IPC_SendMsg (ipcClient *client, ipcMessage *msg)
void IPC_NotifyClientUp (ipcClient *client)
void IPC_NotifyClientDown (ipcClient *client)
PRStatus IPC_SendMsg (ipcClient *client, const nsID &target, const void *data, PRUint32 dataLen)
ipcClientIPC_GetClientByID (PRUint32 clientID)
ipcClientIPC_GetClientByName (const char *name)
void IPC_EnumClients (ipcClientEnumFunc func, void *closure)
PRUint32 IPC_GetClientID (ipcClient *client)
PRBool IPC_ClientHasName (ipcClient *client, const char *name)
PRBool IPC_ClientHasTarget (ipcClient *client, const nsID &target)
void IPC_EnumClientNames (ipcClient *client, ipcClientNameEnumFunc func, void *closure)
void IPC_EnumClientTargets (ipcClient *client, ipcClientTargetEnumFunc func, void *closure)

Function Documentation

PRBool IPC_ClientHasName ( ipcClient client,
const char *  name 
)

Definition at line 193 of file ipcd.cpp.

{
    PR_ASSERT(client);
    PR_ASSERT(name);
    return client->HasName(name);
}

Here is the call graph for this function:

PRBool IPC_ClientHasTarget ( ipcClient client,
const nsID target 
)

Definition at line 201 of file ipcd.cpp.

{
    PR_ASSERT(client);
    return client->HasTarget(target);
}

Here is the call graph for this function:

PRStatus IPC_DispatchMsg ( ipcClient client,
const ipcMessage msg 
)

Definition at line 67 of file ipcd.cpp.

{
    PR_ASSERT(client);
    PR_ASSERT(msg);

    // remember if client is expecting SYNC_REPLY.  we'll add that flag to the
    // next message sent to the client.
    if (msg->TestFlag(IPC_MSG_FLAG_SYNC_QUERY)) {
        PR_ASSERT(client->GetExpectsSyncReply() == PR_FALSE);
        // XXX shouldn't we remember the TargetID as well, and only set the
        //     SYNC_REPLY flag on the next message sent to the same TargetID?
        client->SetExpectsSyncReply(PR_TRUE);
    }

    if (msg->Target().Equals(IPCM_TARGET)) {
        IPCM_HandleMsg(client, msg);
        return PR_SUCCESS;
    }

    return IPC_DispatchMsg(client, msg->Target(), msg->Data(), msg->DataLen());
}

Here is the call graph for this function:

void IPC_EnumClientNames ( ipcClient client,
ipcClientNameEnumFunc  func,
void closure 
)

Definition at line 208 of file ipcd.cpp.

{
    PR_ASSERT(client);
    PR_ASSERT(func);
    const ipcStringNode *node = client->Names();
    while (node) {
        if (func(closure, client, node->Value()) == PR_FALSE)
            break;
        node = node->mNext;
    }
}

Here is the call graph for this function:

void IPC_EnumClients ( ipcClientEnumFunc  func,
void closure 
) [inline]

Definition at line 176 of file ipcd.cpp.

{
    PR_ASSERT(func);
    for (int i = 0; i < ipcClientCount; ++i) {
        if (func(closure, &ipcClients[i], ipcClients[i].ID()) == PR_FALSE)
            break;
    }
}
void IPC_EnumClientTargets ( ipcClient client,
ipcClientTargetEnumFunc  func,
void closure 
)

Definition at line 221 of file ipcd.cpp.

{
    PR_ASSERT(client);
    PR_ASSERT(func);
    const ipcIDNode *node = client->Targets();
    while (node) {
        if (func(closure, client, node->Value()) == PR_FALSE)
            break;
        node = node->mNext;
    }
}

Here is the call graph for this function:

ipcClient* IPC_GetClientByID ( PRUint32  clientID) [inline]

Definition at line 154 of file ipcd.cpp.

{
    // linear search OK since number of clients should be small
    for (int i = 0; i < ipcClientCount; ++i) {
        if (ipcClients[i].ID() == clientID)
            return &ipcClients[i];
    }
    return NULL;
}
ipcClient* IPC_GetClientByName ( const char *  name) [inline]

Definition at line 165 of file ipcd.cpp.

{
    // linear search OK since number of clients should be small
    for (int i = 0; i < ipcClientCount; ++i) {
        if (ipcClients[i].HasName(name))
            return &ipcClients[i];
    }
    return NULL;
}

Definition at line 186 of file ipcd.cpp.

{
    PR_ASSERT(client);
    return client->ID();
}

Here is the call graph for this function:

Definition at line 131 of file ipcd.cpp.

{
    // notify modules before other clients
    IPC_NotifyModulesClientDown(client);

    for (int i=0; i<ipcClientCount; ++i) {
        if (&ipcClients[i] != client)
            IPC_SendMsg(&ipcClients[i],
                new ipcmMessageClientState(client->ID(), IPCM_CLIENT_STATE_DOWN));
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 118 of file ipcd.cpp.

{
    // notify modules before other clients
    IPC_NotifyModulesClientUp(client);

    for (int i=0; i<ipcClientCount; ++i) {
        if (&ipcClients[i] != client)
            IPC_SendMsg(&ipcClients[i],
                new ipcmMessageClientState(client->ID(), IPCM_CLIENT_STATE_UP));
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 54 of file ipcd.cpp.

{
    PRFileDesc *fd = PR_GetInheritedFD(IPC_STARTUP_PIPE_NAME);
    if (fd) {
        char c = IPC_STARTUP_PIPE_MAGIC;
        PR_Write(fd, &c, 1);
        PR_Close(fd);
    }
}

Here is the caller graph for this function:

PRStatus IPC_SendMsg ( ipcClient client,
ipcMessage msg 
)

Definition at line 90 of file ipcd.cpp.

{
    PR_ASSERT(msg);

    if (client == NULL) {
        //
        // broadcast
        //
        for (int i=0; i<ipcClientCount; ++i)
            IPC_SendMsg(&ipcClients[i], msg->Clone());
        delete msg;
        return PR_SUCCESS;
    }

    // add SYNC_REPLY flag to message if client is expecting...
    if (client->GetExpectsSyncReply()) {
        msg->SetFlag(IPC_MSG_FLAG_SYNC_REPLY);
        client->SetExpectsSyncReply(PR_FALSE);
    }

    if (client->HasTarget(msg->Target()))
        return IPC_PlatformSendMsg(client, msg);

    LOG(("  no registered message handler\n"));
    return PR_FAILURE;
}

Here is the call graph for this function:

PRStatus IPC_SendMsg ( ipcClient client,
const nsID target,
const void data,
PRUint32  dataLen 
)

Definition at line 148 of file ipcd.cpp.

{
    return IPC_SendMsg(client, new ipcMessage(target, (const char *) data, dataLen));
}

Here is the call graph for this function: