From cb53eeea4c8f89efa7d1fe00059dad39504fe982 Mon Sep 17 00:00:00 2001 From: "darin%netscape.com" Date: Sun, 10 Nov 2002 09:57:05 +0000 Subject: [PATCH] ipcIService should be completely scriptable git-svn-id: svn://10.0.0.236/trunk@133534 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/modules/ipc/public/ipcIService.idl | 18 +++++++++------- mozilla/modules/ipc/src/ipcService.cpp | 8 +++---- mozilla/modules/ipc/test/TestIPC.cpp | 25 +++++++++++----------- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/mozilla/modules/ipc/public/ipcIService.idl b/mozilla/modules/ipc/public/ipcIService.idl index 41e50844707..8a379601455 100644 --- a/mozilla/modules/ipc/public/ipcIService.idl +++ b/mozilla/modules/ipc/public/ipcIService.idl @@ -152,10 +152,11 @@ interface ipcIService : nsISupports * @param aData the message data. * @param aDataLen the message length. */ - [noscript] void sendMessage(in unsigned long aClientID, - in nsIDRef aTarget, - in string aData, - in unsigned long aDataLen); + void sendMessage(in unsigned long aClientID, + in nsIDRef aTarget, + [array, const, size_is(aDataLen)] + in octet aData, + in unsigned long aDataLen); }; [scriptable, uuid(e40a4a3c-2dc1-470e-ab7f-5675fe1f1384)] @@ -169,9 +170,10 @@ interface ipcIMessageObserver : nsISupports * @param aData the data of the message. * @param aDataLen the data length of the message. */ - [noscript] void onMessageAvailable(in nsIDRef aTarget, - in string aData, - in unsigned long aDataLen); + void onMessageAvailable(in nsIDRef aTarget, + [array, const, size_is(aDataLen)] + in octet aData, + in unsigned long aDataLen); }; [scriptable, uuid(e858d450-62b2-482d-99bb-3b5425aa28cc)] @@ -200,7 +202,7 @@ interface ipcIClientObserver : nsISupports * @param aStatus client status (e.g. CLIENT_UP). */ void onClientStatus(in unsigned long aRequestToken, - in unsigned long aStatus, + in unsigned long aClientStatus, in unsigned long aClientID, in ipcIClientInfo aClientInfo); diff --git a/mozilla/modules/ipc/src/ipcService.cpp b/mozilla/modules/ipc/src/ipcService.cpp index bfc14400fad..67573ab28c6 100644 --- a/mozilla/modules/ipc/src/ipcService.cpp +++ b/mozilla/modules/ipc/src/ipcService.cpp @@ -320,7 +320,7 @@ ipcService::SetMessageObserver(const nsID &target, ipcIMessageObserver *observer NS_IMETHODIMP ipcService::SendMessage(PRUint32 clientID, const nsID &target, - const char *data, + const PRUint8 *data, PRUint32 dataLen) { NS_ENSURE_TRUE(mTransport, NS_ERROR_NOT_INITIALIZED); @@ -332,9 +332,9 @@ ipcService::SendMessage(PRUint32 clientID, ipcMessage *msg; if (clientID) - msg = new ipcmMessageForward(clientID, target, data, dataLen); + msg = new ipcmMessageForward(clientID, target, (const char *) data, dataLen); else - msg = new ipcMessage(target, data, dataLen); + msg = new ipcMessage(target, (const char *) data, dataLen); if (!msg) return NS_ERROR_OUT_OF_MEMORY; @@ -406,7 +406,7 @@ ipcService::OnMessageAvailable(const ipcMessage *msg) ipcIMessageObserver *observer = (ipcIMessageObserver *) mObserverDB.Get(&key); if (observer) observer->OnMessageAvailable(msg->Target(), - msg->Data(), + (const PRUint8 *) msg->Data(), msg->DataLen()); } } diff --git a/mozilla/modules/ipc/test/TestIPC.cpp b/mozilla/modules/ipc/test/TestIPC.cpp index e222649f842..d4266fb355e 100644 --- a/mozilla/modules/ipc/test/TestIPC.cpp +++ b/mozilla/modules/ipc/test/TestIPC.cpp @@ -65,6 +65,15 @@ static PRBool gKeepRunning = PR_TRUE; //static PRInt32 gMsgCount = 0; static ipcIService *gIpcServ = nsnull; +static void +SendMsg(ipcIService *ipc, PRUint32 cID, const nsID &target, const char *data, PRUint32 dataLen) +{ + printf("*** sending message: [to-client=%u dataLen=%u]\n", cID, dataLen); + + ipc->SendMessage(cID, target, (const PRUint8 *) data, dataLen); +// gMsgCount++; +} + //----------------------------------------------------------------------------- class myIpcMessageObserver : public ipcIMessageObserver @@ -79,9 +88,9 @@ public: NS_IMPL_ISUPPORTS1(myIpcMessageObserver, ipcIMessageObserver) NS_IMETHODIMP -myIpcMessageObserver::OnMessageAvailable(const nsID &target, const char *data, PRUint32 dataLen) +myIpcMessageObserver::OnMessageAvailable(const nsID &target, const PRUint8 *data, PRUint32 dataLen) { - printf("*** got message: [%s]\n", data); + printf("*** got message: [%s]\n", (const char *) data); // if (--gMsgCount == 0) // gKeepRunning = PR_FALSE; @@ -118,7 +127,7 @@ myIpcClientObserver::OnClientStatus(PRUint32 aReqToken, printf("*** name:%s --> ID:%u\n", cName.get(), aClientID); } const char hello[] = "hello friend!"; - gIpcServ->SendMessage(aClientID, kTestTargetID, hello, sizeof(hello)); + SendMsg(gIpcServ, aClientID, kTestTargetID, hello, sizeof(hello)); } return NS_OK; @@ -126,14 +135,6 @@ myIpcClientObserver::OnClientStatus(PRUint32 aReqToken, //----------------------------------------------------------------------------- -void SendMsg(ipcIService *ipc, const nsID &target, const char *data, PRUint32 dataLen) -{ - printf("*** sending message: [dataLen=%u]\n", dataLen); - - ipc->SendMessage(0, target, data, dataLen); -// gMsgCount++; -} - int main(int argc, char **argv) { nsresult rv; @@ -235,7 +236,7 @@ int main(int argc, char **argv) "58 this is a really long message.\n" "59 this is a really long message.\n" "60 this is a really long message.\n"; - SendMsg(ipcServ, kTestTargetID, data, strlen(data)+1); + SendMsg(ipcServ, 0, kTestTargetID, data, strlen(data)+1); PRUint32 reqToken; nsCOMPtr obs(new myIpcClientObserver());