major overhaul of daemon plug-in module story. modules now talk to the

daemon through a table of function pointers.  this greatly simplifies the
linker magic required to allow the modules to talk with the daemon.
This commit is contained in:
darin@netscape.com
2002-11-07 04:56:06 +00:00
parent 90f94b98d4
commit 52479d7d97
19 changed files with 332 additions and 278 deletions

View File

@@ -1,9 +1,8 @@
#include <stdio.h>
#include "ipcModule.h"
#include "ipcMessage.h"
#include "ipcd.h"
IPC_EXPORT ipcModule **IPC_GetModuleList();
IPC_EXPORT int IPC_GetModules(ipcDaemonMethods *, ipcModuleEntry **);
static const nsID TestModuleID =
{ /* e628fc6e-a6a7-48c7-adba-f241d1128fb8 */
@@ -13,38 +12,44 @@ static const nsID TestModuleID =
{0xad, 0xba, 0xf2, 0x41, 0xd1, 0x12, 0x8f, 0xb8}
};
class TestModule : public ipcModule
static ipcDaemonMethods *gDaemonMethods;
struct TestModule
{
public:
void Shutdown()
static void Shutdown()
{
printf("*** TestModule::Shutdown\n");
}
const nsID &ID()
{
printf("*** TestModule::ID\n");
return TestModuleID;
}
void HandleMsg(ipcClient *client, const ipcMessage *msg)
static void HandleMsg(ipcClientHandle client, const ipcMessage *msg)
{
printf("*** TestModule::HandleMsg [%s]\n", msg->Data());
ipcMessage *outMsg = new ipcMessage();
ipcMessage outMsg;
static const char buf[] = "pong";
outMsg->Init(TestModuleID, buf, sizeof(buf));
IPC_SendMsg(client, outMsg);
outMsg.Init(TestModuleID, buf, sizeof(buf));
gDaemonMethods->sendMsg(client, &outMsg);
}
};
ipcModule **
IPC_GetModuleList()
int
IPC_GetModules(ipcDaemonMethods *daemonMeths, ipcModuleEntry **entries)
{
static TestModule testMod;
static ipcModule *modules[2];
printf("*** testmodule: IPC_GetModules\n");
modules[0] = &testMod;
modules[1] = NULL;
static ipcModuleMethods methods =
{
IPC_MODULE_METHODS_VERSION,
TestModule::Shutdown,
TestModule::HandleMsg
};
static ipcModuleEntry moduleEntry =
{
TestModuleID,
&methods
};
return modules;
gDaemonMethods = daemonMeths;
*entries = &moduleEntry;
return 1;
}