Родитель
d4438a374a
Коммит
62409a5f3d
|
@ -1,62 +0,0 @@
|
|||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Serge Pikalev <sep@sparc.spb.su>
|
||||
#
|
||||
#
|
||||
DEPTH = ../../../../
|
||||
topsrcdir = $(DEPTH)
|
||||
srcdir = .
|
||||
VPATH = .
|
||||
|
||||
LIBRARY_NAME = urpstubs
|
||||
MODULE = urpstubs
|
||||
#IS_COMPONENT = 1
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
DIRS = transport test loader connect
|
||||
|
||||
CXXFLAGS += -I$(CONNECT_SRC)/public -I$(topsrcdir)/java/xpcom/xpcom -Itransport
|
||||
CPPSRCS = \
|
||||
urpMarshalToolkit.cpp \
|
||||
urpManager.cpp \
|
||||
urpStub.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
urpMarshalToolkit.h \
|
||||
urpStub.h \
|
||||
urpManager.h \
|
||||
|
||||
LIBS = \
|
||||
-lxpcom \
|
||||
-lxptinfo \
|
||||
$(NSPR_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Serge Pikalev <sep@sparc.spb.su>
|
||||
#
|
||||
#
|
||||
DEPTH = ../../../../
|
||||
topsrcdir = $(DEPTH)
|
||||
srcdir = .
|
||||
VPATH = .
|
||||
|
||||
LIBRARY_NAME = urpstubs
|
||||
MODULE = urpstubs
|
||||
#IS_COMPONENT = 1
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
DIRS = transport test loader connect
|
||||
|
||||
CXXFLAGS += -I$(CONNECT_SRC)/public -I$(topsrcdir)/java/xpcom/xpcom -Itransport
|
||||
CPPSRCS = \
|
||||
urpMarshalToolkit.cpp \
|
||||
urpManager.cpp \
|
||||
urpStub.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
urpMarshalToolkit.h \
|
||||
urpStub.h \
|
||||
urpManager.h \
|
||||
|
||||
LIBS = \
|
||||
-lxpcom \
|
||||
-lxptinfo \
|
||||
$(NSPR_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Sun Microsystems,
|
||||
# Inc. Portions created by Sun are
|
||||
# Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Sergey Lunegov <lsv@sparc.spb.su>
|
||||
#
|
||||
|
||||
DEPTH = ../../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
MODULE = urpconnect
|
||||
LIBRARY_NAME = urpconnect
|
||||
IS_COMPONENT = 1
|
||||
|
||||
CPPSRCS = \
|
||||
urpConnectComponent.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
urpIConnectComponent.h \
|
||||
urpConnectComponentCID.h \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_DSO_LDOPTS += \
|
||||
../transport/llTransport.o ../transport/urpPacket.o \
|
||||
../transport/urpTransport.o \
|
||||
../urpStub.o \
|
||||
../urpMarshalToolkit.o \
|
||||
../urpManager.o
|
||||
|
||||
CXXFLAGS += -I../transport/ $(MOZ_TOOLKIT_REGISTRY_CFLAGS) -D_REENTRANT -DOJI_DISABLE -I$(CONNECT_SRC)/public
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
|
@ -1,104 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Sergey Lunegov <lsv@sparc.spb.su>
|
||||
*/
|
||||
#include "urpConnectComponent.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIModule.h"
|
||||
|
||||
#include "bcIXPCOMStubsAndProxies.h"
|
||||
#include "bcXPCOMStubsAndProxiesCID.h"
|
||||
#include "bcIORBComponent.h"
|
||||
#include "bcORBComponentCID.h"
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(urpConnectComponent);
|
||||
|
||||
static NS_DEFINE_CID(kXPCOMStubsAndProxies,BC_XPCOMSTUBSANDPROXIES_CID);
|
||||
static NS_DEFINE_CID(kORBComponent,BC_ORBCOMPONENT_CID);
|
||||
|
||||
static nsModuleComponentInfo components[] =
|
||||
{
|
||||
{
|
||||
"URP Connect Component",
|
||||
URP_CONNECTCOMPONENT_CID,
|
||||
URP_CONNECTCOMPONENT_ContractID,
|
||||
urpConnectComponentConstructor
|
||||
}
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE("URPConnect component",components);
|
||||
|
||||
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS(urpConnectComponent,NS_GET_IID(urpConnectComponent));
|
||||
|
||||
urpConnectComponent::urpConnectComponent() :
|
||||
transport(0), connection(0), compM(0), man(0), stub(0), orb(0)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
urpConnectComponent::~urpConnectComponent() {
|
||||
}
|
||||
|
||||
NS_IMETHODIMP urpConnectComponent::GetCompMan(char* cntStr,
|
||||
nsISupports** cm) {
|
||||
if (!cm) {
|
||||
printf("--urpConnectComponent::GetCompMan\n");
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (!compM) {
|
||||
transport = new urpConnector();
|
||||
transport->Open(cntStr);
|
||||
connection = transport->GetConnection();
|
||||
man = new urpManager(PR_TRUE, nsnull, connection);
|
||||
stub = new urpStub(man, connection);
|
||||
nsresult r;
|
||||
NS_WITH_SERVICE(bcIXPCOMStubsAndProxies, xpcomStubsAndProxies, kXPCOMStubsAndProxies, &r);
|
||||
if (NS_FAILED(r)) {
|
||||
printf("--urpConnectComponent::GetCompMan xpcomStubsAndProxies failed \n");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_WITH_SERVICE(bcIORBComponent, _orb, kORBComponent, &r);
|
||||
if (NS_FAILED(r)) {
|
||||
printf("--urpConnectComponent::GetCompMan bcORB failed \n");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
_orb->GetORB(&orb);
|
||||
bcOID oid = 441450497;
|
||||
orb->RegisterStubWithOID(stub, &oid);
|
||||
xpcomStubsAndProxies->GetProxy(oid, NS_GET_IID(nsIComponentManager), orb, (nsISupports**)&compM);
|
||||
}
|
||||
*cm = compM;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP urpConnectComponent::GetTransport(char* cntStr, urpTransport** trans) {
|
||||
if(!trans) {
|
||||
printf("--urpConnectComponent::GetTransport\n");
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if(!transport) {
|
||||
transport = new urpAcceptor();
|
||||
transport->Open(cntStr);
|
||||
}
|
||||
*trans = transport;
|
||||
return NS_OK;
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Sun Microsystems,
|
||||
# Inc. Portions created by Sun are
|
||||
# Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Igor Kushnirskiy <idk@eng.sun.com>
|
||||
#
|
||||
|
||||
DEPTH = ../../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
MODULE = urploader
|
||||
LIBRARY_NAME = urploader
|
||||
IS_COMPONENT = 1
|
||||
|
||||
CPPSRCS = \
|
||||
urpComponentLoader.cpp \
|
||||
urpComponentFactory.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_DSO_LDOPTS += \
|
||||
../transport/llTransport.o ../transport/urpPacket.o \
|
||||
../transport/urpTransport.o \
|
||||
../urpStub.o \
|
||||
../urpMarshalToolkit.o \
|
||||
../urpManager.o
|
||||
|
||||
CXXFLAGS += -I../transport/ $(MOZ_TOOLKIT_REGISTRY_CFLAGS) -D_REENTRANT -DOJI_DISABLE -I$(CONNECT_SRC)/public
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
|
@ -1,77 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Sergey Lunegov <lsv@sparc.spb.su>
|
||||
*/
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsCRT.h"
|
||||
#include "urpComponentFactory.h"
|
||||
|
||||
#include "urpIConnectComponent.h"
|
||||
#include "urpConnectComponentCID.h"
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(urpComponentFactory, nsIFactory)
|
||||
|
||||
static NS_DEFINE_CID(kConnectComponent,URP_CONNECTCOMPONENT_CID);
|
||||
|
||||
|
||||
urpComponentFactory::urpComponentFactory(const char *_location, const nsCID &aCID) {
|
||||
NS_INIT_ISUPPORTS();
|
||||
location = nsCRT::strdup(_location);
|
||||
aClass = aCID;
|
||||
}
|
||||
|
||||
urpComponentFactory::~urpComponentFactory() {
|
||||
printf("destructor or urpComponentFactory\n");
|
||||
nsCRT::free((char*)location);
|
||||
}
|
||||
|
||||
/* void CreateInstance (in nsISupports aOuter, in nsIIDRef iid, [iid_is (iid), retval] out nsQIResult result);
|
||||
*/
|
||||
NS_IMETHODIMP urpComponentFactory::CreateInstance(nsISupports *aOuter, const nsIID & iid, void * *result) {
|
||||
printf("--urpComponentFactory::CreateInstance\n");
|
||||
nsresult r;
|
||||
nsIFactory* factory;
|
||||
NS_WITH_SERVICE(urpIConnectComponent, conn, kConnectComponent, &r);
|
||||
if(NS_FAILED(r)) {
|
||||
printf("Error in loading urpIConnectComponent\n");
|
||||
exit(-1);
|
||||
}
|
||||
nsIComponentManager* compM;
|
||||
conn->GetCompMan("socket,host=indra,port=20009", (nsISupports**)&compM);
|
||||
compM->FindFactory(aClass, &factory);
|
||||
factory->CreateInstance(aOuter, iid, result);
|
||||
NS_RELEASE(factory);
|
||||
printf("--urpComponentFactory::CreateInstance end\n");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void LockFactory (in PRBool lock); */
|
||||
NS_IMETHODIMP urpComponentFactory::LockFactory(PRBool lock)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -33,6 +33,8 @@
|
|||
#include "nsXPIDLString.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
#include "../urpLog.h"
|
||||
|
||||
|
||||
const char urpComponentTypeName[] = URPCOMPONENTTYPENAME;
|
||||
|
||||
|
@ -55,11 +57,13 @@ urpComponentLoader::urpComponentLoader()
|
|||
mXPCOMKey(0)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
printf("--urpComponentLoader::urpComponentLoader \n");
|
||||
PRLogModuleInfo *log = urpLog::GetLog();
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("--urpComponentLoader::urpComponentLoader \n"));
|
||||
}
|
||||
|
||||
urpComponentLoader::~urpComponentLoader() { //nb
|
||||
printf("--urpComponentLoader::~urpComponentLoader \n");
|
||||
PRLogModuleInfo *log = urpLog::GetLog();
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("--urpComponentLoader::~urpComponentLoader \n"));
|
||||
}
|
||||
|
||||
|
||||
|
@ -68,7 +72,8 @@ urpComponentLoader::~urpComponentLoader() { //nb
|
|||
*/
|
||||
/* nsIFactory getFactory (in nsIIDRef aCID, in string aLocation, in string aType); */
|
||||
NS_IMETHODIMP urpComponentLoader::GetFactory(const nsIID & aCID, const char *aLocation, const char *aType, nsIFactory **_retval) {
|
||||
printf("--urpComponentLoader::GetFactory \n");
|
||||
PRLogModuleInfo *log = urpLog::GetLog();
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("--urpComponentLoader::GetFactory \n"));
|
||||
if (!_retval)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
#ifdef DEBUG
|
||||
|
@ -90,7 +95,8 @@ NS_IMETHODIMP urpComponentLoader::GetFactory(const nsIID & aCID, const char *aLo
|
|||
*/
|
||||
/* void init (in nsIComponentManager aCompMgr, in nsISupports aRegistry); */
|
||||
NS_IMETHODIMP urpComponentLoader::Init(nsIComponentManager *aCompMgr, nsISupports *aReg) {
|
||||
printf("--urpComponentLoader::Init \n");
|
||||
PRLogModuleInfo *log = urpLog::GetLog();
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("--urpComponentLoader::Init \n"));
|
||||
nsresult rv;
|
||||
mCompMgr = aCompMgr;
|
||||
mRegistry = do_QueryInterface(aReg, &rv);
|
||||
|
@ -111,7 +117,8 @@ NS_IMETHODIMP urpComponentLoader::Init(nsIComponentManager *aCompMgr, nsISupport
|
|||
*/
|
||||
/* void onRegister (in nsIIDRef aCID, in string aType, in string aClassName, in string aContractID, in string aLocation, in boolean aReplace, in boolean aPersist); */
|
||||
NS_IMETHODIMP urpComponentLoader::OnRegister(const nsIID & aCID, const char *aType, const char *aClassName, const char *aContractID, const char *aLocation, PRBool aReplace, PRBool aPersist) { //nb
|
||||
printf("--urpComponentLoader::OnRegister \n");
|
||||
PRLogModuleInfo *log = urpLog::GetLog();
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("--urpComponentLoader::OnRegister \n"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -119,7 +126,8 @@ NS_IMETHODIMP urpComponentLoader::OnRegister(const nsIID & aCID, const char *aTy
|
|||
* AutoRegister components in the given directory.
|
||||
*/
|
||||
NS_IMETHODIMP urpComponentLoader::AutoRegisterComponents(PRInt32 aWhen, nsIFile *aDirectory) {
|
||||
printf("--urpComponentLoader::AutoRegisterComponents \n");
|
||||
PRLogModuleInfo *log = urpLog::GetLog();
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("--urpComponentLoader::AutoRegisterComponents \n"));
|
||||
return RegisterComponentsInDir(aWhen,aDirectory);
|
||||
}
|
||||
|
||||
|
@ -218,14 +226,15 @@ NS_IMETHODIMP urpComponentLoader::AutoRegisterComponent(PRInt32 when, nsIFile *c
|
|||
PL_strcasecmp(leafName + len - javaExtensionLen, javaExtension))
|
||||
return NS_OK;
|
||||
|
||||
printf("--urpComponentLoader: registering urpComponent component %s\n",(const char *)leafName);
|
||||
PRLogModuleInfo *log = urpLog::GetLog();
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("--urpComponentLoader: registering urpComponent component %s\n",(const char *)leafName));
|
||||
rv = AttemptRegistration(component, PR_FALSE);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
printf("registered module %s\n", (const char *)leafName);
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("registered module %s\n", (const char *)leafName));
|
||||
else if (rv == NS_ERROR_FACTORY_REGISTER_AGAIN)
|
||||
printf("deferred module %s\n", (const char *)leafName);
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("deferred module %s\n", (const char *)leafName));
|
||||
else
|
||||
printf("failed to register %s\n", (const char *)leafName);
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("failed to register %s\n", (const char *)leafName));
|
||||
*registered = (PRBool) NS_SUCCEEDED(rv);
|
||||
return NS_OK;
|
||||
|
||||
|
@ -248,7 +257,8 @@ nsresult urpComponentLoader::AttemptRegistration(nsIFile *component,
|
|||
in.getline(cidStr,1000);
|
||||
in.getline(contractid,1000);
|
||||
in.getline(desc,1000);
|
||||
printf("%s %s %s", cidStr, contractid, desc);
|
||||
PRLogModuleInfo *log = urpLog::GetLog();
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("%s %s %s", cidStr, contractid, desc));
|
||||
nsCID cid;
|
||||
cid.Parse((const char *)cidStr);
|
||||
mCompMgr->RegisterComponentWithType(cid, desc, contractid, component, registryLocation, PR_TRUE, PR_TRUE, urpComponentTypeName);
|
||||
|
@ -283,8 +293,9 @@ nsresult urpComponentLoader::SetRegistryInfo(const char *registryLocation,
|
|||
if (NS_FAILED(rv = component->GetFileSize(&fileSize)) ||
|
||||
NS_FAILED(rv = mRegistry->SetLongLong(key, fileSizeValueName, &fileSize)))
|
||||
return rv;
|
||||
printf("SetRegistryInfo(%s) => (%d,%d)\n", registryLocation,
|
||||
(int)modDate, (int)fileSize);
|
||||
PRLogModuleInfo *log = urpLog::GetLog();
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("SetRegistryInfo(%s) => (%d,%d)\n", registryLocation,
|
||||
(int)modDate, (int)fileSize));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -323,7 +334,8 @@ PRBool urpComponentLoader::HasChanged(const char *registryLocation, nsIFile *com
|
|||
*/
|
||||
/* boolean registerDeferredComponents (in long aWhen); */
|
||||
NS_IMETHODIMP urpComponentLoader::RegisterDeferredComponents(PRInt32 aWhen, PRBool *aRegistered) {
|
||||
printf("--urpComponentLoader::RegisterDeferredComponents \n");
|
||||
PRLogModuleInfo *log = urpLog::GetLog();
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("--urpComponentLoader::RegisterDeferredComponents \n"));
|
||||
nsresult rv;
|
||||
*aRegistered = PR_FALSE;
|
||||
PRUint32 count;
|
||||
|
@ -368,7 +380,8 @@ NS_IMETHODIMP urpComponentLoader::RegisterDeferredComponents(PRInt32 aWhen, PRBo
|
|||
*/
|
||||
/* void unloadAll (in long aWhen); */
|
||||
NS_IMETHODIMP urpComponentLoader::UnloadAll(PRInt32 aWhen) { //nb
|
||||
printf("--urpComponentLoader::UnloadAll \n");
|
||||
PRLogModuleInfo *log = urpLog::GetLog();
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("--urpComponentLoader::UnloadAll \n"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -381,26 +394,27 @@ static NS_METHOD
|
|||
RegisterRemoteLoader(nsIComponentManager *aCompMgr, nsIFile *aPath,
|
||||
const char *registryLocation, const char *componentType, const nsModuleComponentInfo *info)
|
||||
{
|
||||
PRLogModuleInfo *log = urpLog::GetLog();
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICategoryManager> catman =
|
||||
do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
|
||||
printf("--URPLoader got registered\n");
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("--URPLoader got registered\n"));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsXPIDLCString previous;
|
||||
rv = catman->AddCategoryEntry("component-loader", urpComponentTypeName,
|
||||
URP_COMPONENTLOADER_ContractID,
|
||||
PR_TRUE, PR_TRUE, getter_Copies(previous));
|
||||
if(NS_FAILED(rv))
|
||||
printf("Adding of remote-comp-loader is failed\n");
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("Adding of remote-comp-loader is failed\n"));
|
||||
else
|
||||
printf("Adding of remote-comp-loader is succeseded\n");
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("Adding of remote-comp-loader is succeseded\n"));
|
||||
nsXPIDLCString urpLoader;
|
||||
rv = catman->GetCategoryEntry("component-loader", urpComponentTypeName,
|
||||
getter_Copies(urpLoader));
|
||||
if (NS_FAILED(rv))
|
||||
printf("didn't got category entry\n");
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("didn't got category entry\n"));
|
||||
else
|
||||
printf("got category entry\n");
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("got category entry\n"));
|
||||
|
||||
return rv;
|
||||
|
||||
|
@ -415,7 +429,8 @@ UnregisterRemoteLoader(nsIComponentManager *aCompMgr, nsIFile *aPath,
|
|||
do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsXPIDLCString urpLoader;
|
||||
printf("URP component loader is being unregistered\n");
|
||||
PRLogModuleInfo *log = urpLog::GetLog();
|
||||
PR_LOG(log, PR_LOG_DEBUG, ("URP component loader is being unregistered\n"));
|
||||
rv = catman->GetCategoryEntry("component-loader", urpComponentTypeName,
|
||||
getter_Copies(urpLoader));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
|
|
@ -1,136 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Leila.Garin@eng.sun.com
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "initImpl.h"
|
||||
#include "nsIInterfaceInfo.h"
|
||||
#include "nsIInterfaceInfoManager.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "urpITest.h"
|
||||
#include "urpTestImpl.h"
|
||||
|
||||
static char * className = "initImpl";
|
||||
|
||||
NS_IMPL_ISUPPORTS1(initImpl, urpInit);
|
||||
|
||||
initImpl::initImpl() {
|
||||
NS_INIT_REFCNT();
|
||||
printf("Constructor of initImpl\n");
|
||||
nsresult rv;
|
||||
urpITest * serverComponent;
|
||||
urpITest* anComp;
|
||||
rv = nsComponentManager::CreateInstance("urpTest",
|
||||
nsnull,
|
||||
NS_GET_IID(urpITest),
|
||||
(void**)&serverComponent);
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("Create instance failed in initImpl!!!");
|
||||
exit(-1);
|
||||
}
|
||||
/*
|
||||
rv = nsComponentManager::CreateInstance("urpTest",
|
||||
nsnull,
|
||||
NS_GET_IID(urpITest),
|
||||
(void**)&anComp);
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("Create instance failed in initImpl sec!!!");
|
||||
exit(-1);
|
||||
}
|
||||
*/
|
||||
int l = 2000;
|
||||
serverComponent->Test1(&l);
|
||||
printf("in initImpl after Test1 %d\n",l);
|
||||
/*
|
||||
anComp->Test1(&l);
|
||||
printf("in initImpl after Test1 %d\n",l);
|
||||
*/
|
||||
/*******************************************/
|
||||
PRInt32 l2 = 2000;
|
||||
l = 1999;
|
||||
serverComponent->Test2(l,&l2);
|
||||
printf("--urpTestImpl after Test2 l2=%d\n",l2);
|
||||
|
||||
/*******************************************/
|
||||
const char * s1 = "s1";
|
||||
char * s2 = "s2";
|
||||
serverComponent->Test3(s1,&s2);
|
||||
printf("--urpTestImpl after Test3 s2=%s\n",s2);
|
||||
/*******************************************/
|
||||
|
||||
char ** valueArray = (char **)malloc(sizeof(char*)*4);
|
||||
valueArray[0] = "hi";
|
||||
valueArray[1] = "there";
|
||||
valueArray[2] = "a";
|
||||
valueArray[3] = "b";
|
||||
|
||||
serverComponent->Test4(4,(const char **)valueArray);
|
||||
/*******************************************/
|
||||
|
||||
char ***valueArray2 = &valueArray;
|
||||
|
||||
printf("call object\n");
|
||||
for (unsigned int i = 0; i < 4; i++) {
|
||||
printf("valueArray[%d]=%s\n",i,(*valueArray2)[i]);
|
||||
}
|
||||
printf("after calling object\n");
|
||||
for (unsigned int i = 0; i < 4; i++) {
|
||||
printf("valueArray[%d]=%s\n",i,(*valueArray2)[i]);
|
||||
}
|
||||
|
||||
|
||||
valueArray2 = (char ***)&valueArray;
|
||||
serverComponent->Test5(4,valueArray2);
|
||||
for (unsigned int i = 0; i < 4; i++) {
|
||||
printf("valueArray[%d]=%s\n",i,(*valueArray2)[i]);
|
||||
}
|
||||
|
||||
urpITest *object = new urpTestImpl();
|
||||
object->AddRef();
|
||||
serverComponent->Test6(object);
|
||||
{
|
||||
urpITest *p1;
|
||||
serverComponent->Test7(&p1);
|
||||
printf("p1=%p",p1);
|
||||
PRInt32 l = 1234;
|
||||
PRInt32 r;
|
||||
p1->Test1(&l);
|
||||
urpITest *p3;
|
||||
printf("--before QueryInterface calling \n");
|
||||
if (NS_SUCCEEDED(p1->QueryInterface(NS_GET_IID(urpITest),(void**)&p3)))
|
||||
{
|
||||
l=2000;
|
||||
p3->Test1(&l);
|
||||
printf("l in client after test1 %ld\n",l);
|
||||
}
|
||||
delete p1;
|
||||
delete p3;
|
||||
|
||||
|
||||
}
|
||||
delete serverComponent;
|
||||
}
|
||||
|
||||
initImpl::~initImpl() {
|
||||
}
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Sergey Lunegov <lsv@sparc.spb.su>
|
||||
|
||||
DEPTH = ../../../../../
|
||||
topsrcdir = ../../../../../
|
||||
srcdir = .
|
||||
VPATH = .
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
DIRS = client Init
|
||||
|
||||
LIBRARY_NAME = urpTest
|
||||
MODULE = urpTest
|
||||
IS_COMPONENT = 1
|
||||
XPIDLSRCS = urpITest.idl
|
||||
|
||||
PROGRAM = server
|
||||
|
||||
CXXFLAGS += -I$(topsrcdir)/java/xpcom/xpcom -I../transport -I$(JDKHOME)/include -I$(topsrcdir)/java/xpcom/java/src -I$(topsrcdir)/java/xpcom/connect/xpcom
|
||||
|
||||
CPPSRCS = \
|
||||
urpTestImpl.cpp \
|
||||
urpTestImplFactory.cpp \
|
||||
server.cpp \
|
||||
$(NULL)
|
||||
|
||||
LIBS = -L./ -L$(DIST)/bin/components/ $(XPCOM_LIBS) $(NSPR_LIBS) $(EXTRA_DSO_LIBS) \
|
||||
../urpStub.o \
|
||||
../urpMarshalToolkit.o \
|
||||
../urpManager.o \
|
||||
../transport/llTransport.o ../transport/urpPacket.o \
|
||||
../transport/urpTransport.o \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_DSO_LDOPTS += \
|
||||
../transport/llTransport.o ../transport/urpPacket.o \
|
||||
../transport/urpTransport.o \
|
||||
../urpStub.o \
|
||||
../urpMarshalToolkit.o \
|
||||
../urpManager.o \
|
||||
$(NULL)
|
||||
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Sergey Lunegov <lsv@sparc.spb.su>
|
||||
|
||||
DEPTH = ../../../../../../
|
||||
topsrcdir = ../../../../../../
|
||||
srcdir = .
|
||||
VPATH = .
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
|
||||
#XPIDLSRCS = urpITest.idl
|
||||
|
||||
PROGRAM = client
|
||||
|
||||
CXXFLAGS += -I$(topsrcdir)/java/xpcom/xpcom -I$(JDKHOME)/include -I$(topsrcdir)/java/xpcom/java/src -I$(topsrcdir)/java/xpcom/connect/xpcom -I../../transport -I../
|
||||
|
||||
CPPSRCS = \
|
||||
client.cpp \
|
||||
$(NULL)
|
||||
|
||||
|
||||
LIBS = -L./ -L$(DIST)/bin/components/ $(XPCOM_LIBS) $(NSPR_LIBS) $(EXTRA_DSO_LIBS) \
|
||||
../../urpStub.o \
|
||||
../../urpMarshalToolkit.o \
|
||||
../../urpManager.o \
|
||||
../../transport/llTransport.o ../../transport/urpPacket.o \
|
||||
../../transport/urpTransport.o \
|
||||
../urpTestImpl.o
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,176 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Sergey Lunegov <lsv@sparc.spb.su>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "urpManager.h"
|
||||
#include "nsIInterfaceInfo.h"
|
||||
#include "nsIInterfaceInfoManager.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/****************************************************/
|
||||
|
||||
#include "nsIModule.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "bcIXPCOMStubsAndProxies.h"
|
||||
#include "bcXPCOMStubsAndProxiesCID.h"
|
||||
#include "bcIORBComponent.h"
|
||||
#include "bcORBComponentCID.h"
|
||||
#include "bcIStub.h"
|
||||
#include "urpStub.h"
|
||||
#include "urpITest.h"
|
||||
|
||||
#include "urpTestImpl.h"
|
||||
|
||||
static NS_DEFINE_CID(kORBCIID,BC_ORBCOMPONENT_CID);
|
||||
static NS_DEFINE_CID(kXPCOMStubsAndProxies,BC_XPCOMSTUBSANDPROXIES_CID);
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
nsIInterfaceInfo *interfaceInfo;
|
||||
nsIInterfaceInfoManager* iimgr;
|
||||
char *connectString = argv[1];
|
||||
nsresult rv = NS_InitXPCOM(NULL, NULL);
|
||||
bcIID iid = NS_GET_IID(urpITest);
|
||||
if( (iimgr = XPTI_GetInterfaceInfoManager()) ) {
|
||||
if (NS_FAILED(iimgr->GetInfoForIID(&iid, &interfaceInfo))) {
|
||||
return NS_ERROR_FAILURE; //nb exception handling
|
||||
}
|
||||
NS_RELEASE(iimgr);
|
||||
} else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsresult r;
|
||||
NS_WITH_SERVICE(bcIORBComponent, _orb, kORBCIID, &r);
|
||||
if (NS_FAILED(r)) {
|
||||
printf("--urpTestImpl test failed\n");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_WITH_SERVICE(bcIXPCOMStubsAndProxies, xpcomStubsAndProxies, kXPCOMStubsAndProxies, &r);
|
||||
if (NS_FAILED(r)) {
|
||||
printf("--urpTestImpl test failed\n");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
bcIORB *orb;
|
||||
_orb->GetORB(&orb);
|
||||
bcIStub *stub = NULL;
|
||||
urpITest *object = new urpTestImpl();
|
||||
object->AddRef();
|
||||
urpITest *proxy = NULL;
|
||||
urpTransport* transport = new urpConnector();
|
||||
PRStatus status = transport->Open(connectString);
|
||||
if(status != PR_SUCCESS) {
|
||||
printf("Error during opening connection\n");
|
||||
exit(-1);
|
||||
}
|
||||
urpConnection* conn = transport->GetConnection();
|
||||
urpManager* man = new urpManager(PR_TRUE, nsnull, conn);
|
||||
stub = new urpStub(man, conn);
|
||||
bcOID oid = 1221591041;
|
||||
// bcOID oid = orb->RegisterStub(stub);
|
||||
orb->RegisterStubWithOID(stub, &oid);
|
||||
printf("---urpTestImpl oid=%ld iid=%s\n",oid, NS_GET_IID(urpITest).ToString());
|
||||
r = xpcomStubsAndProxies->GetProxy(oid,NS_GET_IID(urpITest),orb,(nsISupports**)&proxy);
|
||||
if (NS_FAILED(r)) {
|
||||
printf("--urpTestImpl test failed\n");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
/*******************************************/
|
||||
char ** valueArray = (char **)malloc(sizeof(char*)*4);
|
||||
valueArray[0] = "hi";
|
||||
valueArray[1] = "there";
|
||||
valueArray[2] = "a";
|
||||
valueArray[3] = "b";
|
||||
|
||||
PRInt32 l1 = 99;
|
||||
PRInt32 ret;
|
||||
PRInt32 rt;
|
||||
// object->Test1(&l1);
|
||||
l1 = 1999;
|
||||
proxy->Test1(&l1);
|
||||
printf("--urpTestImpl after Test1 l=%d %d\n",l1,ret);
|
||||
/*******************************************/
|
||||
PRInt32 l2 = 2020;
|
||||
l1 = 1999;
|
||||
proxy->Test2(l1,&l2);
|
||||
printf("--urpTestImpl after Test2 l2=%d\n",l2);
|
||||
|
||||
/*******************************************/
|
||||
const char * s1 = "s111";
|
||||
char * s2 = "s2222";
|
||||
proxy->Test3(s1,&s2);
|
||||
printf("--urpTestImpl after Test3 s2=%s\n",s2);
|
||||
/*******************************************/
|
||||
|
||||
|
||||
proxy->Test4(4,(const char **)valueArray);
|
||||
/*******************************************/
|
||||
|
||||
char ***valueArray2 = &valueArray;
|
||||
|
||||
printf("call object\n");
|
||||
for (unsigned int i = 0; i < 4; i++) {
|
||||
printf("valueArray[%d]=%s\n",i,(*valueArray2)[i]);
|
||||
}
|
||||
// object->Test5(4,valueArray2);
|
||||
printf("after calling object\n");
|
||||
for (unsigned int i = 0; i < 4; i++) {
|
||||
printf("valueArray[%d]=%s\n",i,(*valueArray2)[i]);
|
||||
}
|
||||
|
||||
|
||||
valueArray2 = (char ***)&valueArray;
|
||||
proxy->Test5(4,valueArray2);
|
||||
for (unsigned int i = 0; i < 4; i++) {
|
||||
printf("valueArray[%d]=%s\n",i,(*valueArray2)[i]);
|
||||
}
|
||||
|
||||
/*********************************************/
|
||||
proxy->Test6(object);
|
||||
/*********************************************/
|
||||
{
|
||||
urpITest *p1;
|
||||
proxy->Test7(&p1);
|
||||
printf("p1=%p",p1);
|
||||
PRInt32 l = 1234;
|
||||
PRInt32 r;
|
||||
p1->Test1(&l);
|
||||
urpITest *p3;
|
||||
printf("--before QueryInterface calling \n");
|
||||
if (NS_SUCCEEDED(p1->QueryInterface(NS_GET_IID(urpITest),(void**)&p3))) {
|
||||
l=2000;
|
||||
p3->Test1(&l);
|
||||
printf("l in client after test1 %ld\n",l);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
delete conn;
|
||||
transport->Close();
|
||||
}
|
||||
|
|
@ -1,537 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Sergey Lunegov <lsv@sparc.spb.su>
|
||||
*/
|
||||
|
||||
#include "prmem.h"
|
||||
#include "nsIInterfaceInfo.h"
|
||||
#include "nsIInterfaceInfoManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "xptcall.h"
|
||||
#include "nsCRT.h"
|
||||
#include "urpManager.h"
|
||||
#include <unistd.h>
|
||||
#include "urpStub.h"
|
||||
#include "urpMarshalToolkit.h"
|
||||
|
||||
|
||||
#include "nsIModule.h"
|
||||
|
||||
|
||||
class threadHashKey : public nsHashKey {
|
||||
public:
|
||||
threadHashKey(bcTID thrdID) : threadID(thrdID) {}
|
||||
|
||||
virtual PRUint32 HashCode(void) const
|
||||
{
|
||||
return PRUint32(threadID);
|
||||
}
|
||||
|
||||
virtual PRBool Equals(const nsHashKey *aKey) const
|
||||
{
|
||||
return ((threadHashKey*)aKey)->threadID == threadID;
|
||||
}
|
||||
|
||||
virtual nsHashKey *Clone(void) const
|
||||
{
|
||||
return new threadHashKey(threadID);
|
||||
}
|
||||
|
||||
private:
|
||||
bcTID threadID;
|
||||
};
|
||||
|
||||
struct localThreadArg {
|
||||
urpManager *mgr;
|
||||
urpConnection *conn;
|
||||
PRBool isClnt;
|
||||
localThreadArg( urpManager *mgr, urpConnection *conn, PRBool ic ) {
|
||||
this->mgr = mgr;
|
||||
this->conn = conn;
|
||||
this->isClnt = ic;
|
||||
}
|
||||
};
|
||||
|
||||
struct sendThreadArg {
|
||||
urpManager* man;
|
||||
char header;
|
||||
urpPacket* message;
|
||||
bcIID iid;
|
||||
bcOID oid;
|
||||
bcTID tid;
|
||||
PRUint16 methodId;
|
||||
urpConnection* connection;
|
||||
sendThreadArg(urpManager* m, char header, urpPacket* message, bcIID iid,
|
||||
bcOID oid, bcTID tid, PRUint16 methodId,
|
||||
urpConnection* conn) {
|
||||
this->man = m;
|
||||
this->header = header;
|
||||
this->message = message;
|
||||
this->iid = iid;
|
||||
this->oid = oid;
|
||||
this->tid = tid;
|
||||
this->methodId = methodId;
|
||||
this->connection = conn;
|
||||
}
|
||||
};
|
||||
|
||||
struct monitCall {
|
||||
PRCList* stack;
|
||||
/*
|
||||
PRMonitor *mon;
|
||||
bcICall* call;
|
||||
*/
|
||||
urpPacket* mess;
|
||||
char header;
|
||||
bcIID iid;
|
||||
bcOID oid;
|
||||
bcTID tid;
|
||||
bcMID mid;
|
||||
int request;
|
||||
monitCall(PRCList* stack, urpPacket* mes, char h) {
|
||||
this->stack = stack;
|
||||
this->mess = mes;
|
||||
this->header = h;
|
||||
this->request = 0;
|
||||
}
|
||||
};
|
||||
|
||||
void thread_start( void *arg )
|
||||
{
|
||||
urpManager *manager = ((localThreadArg *)arg)->mgr;
|
||||
urpConnection *connection = ((localThreadArg *)arg)->conn;
|
||||
PRBool ic = ((localThreadArg *)arg)->isClnt;
|
||||
nsresult rv = manager->ReadMessage( connection, ic );
|
||||
}
|
||||
|
||||
void send_thread_start (void * arg) {
|
||||
urpManager *manager = ((sendThreadArg *)arg)->man;
|
||||
char header = ((sendThreadArg *)arg)->header;
|
||||
urpPacket* mes = ((sendThreadArg *)arg)->message;
|
||||
bcIID iid = ((sendThreadArg *)arg)->iid;
|
||||
bcOID oid = ((sendThreadArg *)arg)->oid;
|
||||
bcTID tid = ((sendThreadArg *)arg)->tid;
|
||||
PRUint16 methodId = ((sendThreadArg *)arg)->methodId;
|
||||
urpConnection* conn = ((sendThreadArg *)arg)->connection;
|
||||
nsresult rv = manager->ReadLongRequest(header, mes, iid, oid,
|
||||
tid, methodId, conn);
|
||||
//printf("just run test\n");
|
||||
}
|
||||
|
||||
urpManager::urpManager(PRBool IsClient, bcIORB *orb, urpConnection* conn) {
|
||||
broker = orb;
|
||||
monitTable = new nsHashtable(20);
|
||||
if(IsClient) {
|
||||
threadTable = nsnull;
|
||||
localThreadArg *arg = new localThreadArg( this, conn, PR_TRUE );
|
||||
PRThread *thr = PR_CreateThread( PR_USER_THREAD,
|
||||
thread_start,
|
||||
arg,
|
||||
PR_PRIORITY_NORMAL,
|
||||
PR_LOCAL_THREAD,
|
||||
PR_UNJOINABLE_THREAD,
|
||||
0);
|
||||
if(thr == nsnull) {
|
||||
printf("Error couldn't run listener\n");
|
||||
exit(-1);
|
||||
}
|
||||
} else
|
||||
threadTable = new nsHashtable(20);
|
||||
}
|
||||
|
||||
|
||||
urpManager::~urpManager() {
|
||||
if(monitTable)
|
||||
delete monitTable;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void urpManager::SendUrpRequest(bcOID oid, bcIID iid,
|
||||
PRUint16 methodIndex,
|
||||
nsIInterfaceInfo* interfaceInfo,
|
||||
bcICall *call,
|
||||
PRUint32 paramCount, const nsXPTMethodInfo* info,
|
||||
urpConnection* connection) {
|
||||
printf("this is method sendUrpRequest and mid is %x\n",methodIndex);
|
||||
long size = 0;
|
||||
long messagesCount = 0;
|
||||
urpPacket* message = new urpPacket();
|
||||
|
||||
char header = 0x0;
|
||||
char bigHeader = 0x0;
|
||||
char synchron = 0x1;
|
||||
char mustReply = 0x1;
|
||||
|
||||
if(1) { //there should be checking on whether oid is the new one
|
||||
header |= NEWOID;
|
||||
bigHeader = 0x1;
|
||||
}
|
||||
|
||||
if(1) { //there should be checking on whether type is the new one
|
||||
header |= NEWTYPE;
|
||||
bigHeader = 0x1;
|
||||
}
|
||||
|
||||
if(1) { //there should be checking on whether threadid is the new one
|
||||
header |= NEWTID;
|
||||
bigHeader = 0x1;
|
||||
}
|
||||
|
||||
if(bigHeader) {
|
||||
header |= BIG_HEADER;
|
||||
header |= 0x80;
|
||||
header |= REQUEST;
|
||||
header |= 0;
|
||||
|
||||
if(methodIndex > 255)
|
||||
header |= LONGMETHODID;
|
||||
|
||||
message->WriteByte(header);
|
||||
|
||||
if(methodIndex > 255)
|
||||
message->WriteShort(methodIndex);
|
||||
else
|
||||
message->WriteByte((char)methodIndex);
|
||||
}
|
||||
|
||||
urpMarshalToolkit* mt = new urpMarshalToolkit(PR_TRUE);
|
||||
mt->WriteType(iid, message);
|
||||
mt->WriteOid(oid, message);
|
||||
bcTID thrID;
|
||||
bcTID* thr;
|
||||
if(threadTable) {
|
||||
thrID = (bcTID)PR_GetCurrentThread();
|
||||
threadHashKey thrHK(thrID);
|
||||
thr = (bcTID*)threadTable->Get(&thrHK);
|
||||
if(thr)
|
||||
thrID = *(bcTID*)thr;
|
||||
else {
|
||||
printf("Error with threads in SendUrpRequest\n");
|
||||
exit(-1);
|
||||
}
|
||||
} else
|
||||
thrID = (bcTID)PR_GetCurrentThread();
|
||||
printf("OID is written %ld %ld\n", oid, thrID);
|
||||
mt->WriteThreadID(thrID, message);
|
||||
broker = call->GetORB();
|
||||
mt->WriteParams(call, paramCount, info, interfaceInfo, message, methodIndex);
|
||||
delete mt;
|
||||
connection->Write(message);
|
||||
delete message;
|
||||
}
|
||||
|
||||
void urpManager::TransformMethodIDAndIID() {
|
||||
printf("this is method transformMethodIDAndIID\n");
|
||||
}
|
||||
|
||||
nsresult
|
||||
urpManager::ReadReply(urpPacket* message, char header,
|
||||
bcICall* call, PRUint32 paramCount,
|
||||
const nsXPTMethodInfo *info,
|
||||
nsIInterfaceInfo *interfaceInfo, PRUint16 methodIndex,
|
||||
urpConnection* conn) {
|
||||
nsresult rv = NS_OK;
|
||||
printf("this is method readReply\n");
|
||||
if(methodIndex != 1 && methodIndex != 2) {
|
||||
urpMarshalToolkit* mt = new urpMarshalToolkit(PR_TRUE);
|
||||
rv = mt->ReadParams(paramCount, info, message, interfaceInfo, methodIndex, call, broker, this, conn);
|
||||
delete mt;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
urpManager::ReadMessage(urpConnection* conn, PRBool isClient) {
|
||||
nsresult rv = NS_OK;
|
||||
PRBool inserted = PR_FALSE;
|
||||
bcTID tid;
|
||||
PRThread *thr;
|
||||
sendThreadArg *arg = (sendThreadArg *)PR_Malloc(sizeof(sendThreadArg));
|
||||
while(conn->GetStatus() == urpSuccess) {
|
||||
urpPacket* message = conn->Read();
|
||||
char header = message->ReadByte();
|
||||
if((header & BIG_HEADER) != 0) { // full header?
|
||||
if((header & REQUEST) != 0) { // a request ?
|
||||
bcIID iid;
|
||||
bcOID oid;
|
||||
PRUint16 methodId;
|
||||
if((header & LONGMETHODID) != 0) // usigned short ?
|
||||
methodId = message->ReadShort();
|
||||
else
|
||||
methodId = message->ReadByte();
|
||||
|
||||
urpMarshalToolkit* mt = new urpMarshalToolkit(PR_FALSE);
|
||||
if((header & NEWTYPE) != 0)
|
||||
iid = mt->ReadType(message);
|
||||
|
||||
if((header & NEWOID) != 0) // new oid?
|
||||
oid = mt->ReadOid(message);
|
||||
|
||||
if((header & NEWTID) != 0) // new thread id ?
|
||||
tid = mt->ReadThreadID(message);
|
||||
|
||||
delete mt;
|
||||
|
||||
threadHashKey thrHK(tid);
|
||||
monitCall* mc = (monitCall*)monitTable->Get(&thrHK);
|
||||
if(mc != nsnull) {
|
||||
mc->mess = message;
|
||||
mc->header = header;
|
||||
mc->iid = iid;
|
||||
mc->oid = oid;
|
||||
mc->tid = tid;
|
||||
mc->mid = methodId;
|
||||
mc->request = 1;
|
||||
PRMonitor* mon = (PRMonitor*)PR_LIST_HEAD(mc->stack);
|
||||
PR_EnterMonitor(mon);
|
||||
PR_Notify(mon);
|
||||
PR_ExitMonitor(mon);
|
||||
} else {
|
||||
arg->man = this;
|
||||
arg->header = header;
|
||||
arg->message = message;
|
||||
arg->iid = iid;
|
||||
arg->oid = oid;
|
||||
arg->tid = tid;
|
||||
arg->methodId = methodId;
|
||||
arg->connection = conn;
|
||||
/*
|
||||
sendThreadArg *arg = new sendThreadArg( this, header,
|
||||
message, iid, oid, tid, methodId, conn);
|
||||
*/
|
||||
thr = PR_CreateThread( PR_USER_THREAD,
|
||||
send_thread_start,
|
||||
arg,
|
||||
PR_PRIORITY_NORMAL,
|
||||
PR_LOCAL_THREAD,
|
||||
PR_UNJOINABLE_THREAD,
|
||||
0);
|
||||
//ReadLongRequest(header, message, iid, oid, tid, methodId, conn);
|
||||
}
|
||||
} else { // a reply
|
||||
bcIID iid; bcOID oid; bcMID mid;
|
||||
|
||||
urpMarshalToolkit* mt = new urpMarshalToolkit(PR_TRUE);
|
||||
if((header & NEWTID) != 0) { // new thread id ?
|
||||
printf("new threadID\n");
|
||||
tid = mt->ReadThreadID(message);
|
||||
}
|
||||
else
|
||||
printf("old threadID\n");
|
||||
delete mt;
|
||||
threadHashKey thrHK(tid);
|
||||
monitCall* mc = (monitCall*)monitTable->Get(&thrHK);
|
||||
mc->mess = message;
|
||||
mc->header = header;
|
||||
mc->request = 0;
|
||||
/*
|
||||
mc->call->GetParams(&iid, &oid, &mid);
|
||||
nsIInterfaceInfo *interfaceInfo;
|
||||
nsIInterfaceInfoManager* iimgr;
|
||||
if( (iimgr = XPTI_GetInterfaceInfoManager()) ) {
|
||||
if (NS_FAILED(iimgr->GetInfoForIID(&iid, &interfaceInfo))) {
|
||||
printf("Error in ReadMessage\n");
|
||||
return NS_ERROR_FAILURE; //nb exception handling
|
||||
}
|
||||
NS_RELEASE(iimgr);
|
||||
} else {
|
||||
printf("Error in ReadMessage in second place\n");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsXPTMethodInfo* info;
|
||||
interfaceInfo->GetMethodInfo(mid, (const nsXPTMethodInfo **)&info);
|
||||
PRUint32 paramCount = info->GetParamCount();
|
||||
ReadReply(message, header, mc->call, paramCount,
|
||||
info, interfaceInfo, mid, conn);
|
||||
*/
|
||||
PRMonitor* mon = (PRMonitor*)PR_LIST_HEAD(mc->stack);
|
||||
PR_EnterMonitor(mon);
|
||||
PR_Notify(mon);
|
||||
PR_ExitMonitor(mon);
|
||||
}
|
||||
}
|
||||
else { // only a short request header
|
||||
// rv = ReadShortRequest(header, message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
PR_Free(arg);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
urpManager::ReadShortRequest(char header, urpPacket* message) {
|
||||
nsresult rv = NS_OK;
|
||||
bcTID tid = 0;
|
||||
printf("null implementation of readShortRequest\n");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
urpManager::SendReply(bcTID tid, bcICall* call, PRUint32 paramCount,
|
||||
const nsXPTMethodInfo* info,
|
||||
nsIInterfaceInfo *interfaceInfo, PRUint16 methodIndex,
|
||||
urpConnection* connection) {
|
||||
nsresult rv = NS_OK;
|
||||
char header = (char)BIG_HEADER;
|
||||
header |= NEWTID;
|
||||
urpPacket* message = new urpPacket();
|
||||
message->WriteByte(header);
|
||||
urpMarshalToolkit* mt = new urpMarshalToolkit(PR_FALSE);
|
||||
mt->WriteThreadID(tid, message);
|
||||
if(methodIndex != 1 && methodIndex != 2)
|
||||
rv = mt->WriteParams(call, paramCount, info, interfaceInfo, message, methodIndex);
|
||||
delete mt;
|
||||
if(NS_FAILED(rv)) return rv;
|
||||
connection->Write(message);
|
||||
delete message;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
urpManager::ReadLongRequest(char header, urpPacket* message,
|
||||
bcIID iid, bcOID oid, bcTID tid,
|
||||
PRUint16 methodId, urpConnection* conn) {
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if(threadTable != nsnull) {
|
||||
bcTID thrID = (bcTID)PR_GetCurrentThread();
|
||||
threadHashKey thrHK(thrID);
|
||||
bcTID* clientTID = (bcTID*)threadTable->Get(&thrHK);
|
||||
if(clientTID) thrID = *clientTID;
|
||||
if(clientTID) {
|
||||
if(thrID != tid) {
|
||||
printf("Error: threadIDs are not equal in ReadLongRequest\n");
|
||||
exit(-1);
|
||||
}
|
||||
} else
|
||||
threadTable->Put(&thrHK, &tid);
|
||||
}
|
||||
|
||||
urpMarshalToolkit* mt = new urpMarshalToolkit(PR_FALSE);
|
||||
|
||||
printf("method readLongRequest: tid %ld %ld\n",tid,oid);
|
||||
char ignore_cache = ((header & IGNORECACHE) != 0); // do not use cache for this request?
|
||||
|
||||
char mustReply;
|
||||
|
||||
if((header & MOREFLAGS) != 0) {// is there an extended flags byte?
|
||||
char exFlags = message->ReadByte();
|
||||
|
||||
mustReply = (exFlags & MUSTREPLY) != 0;
|
||||
}
|
||||
else {
|
||||
mustReply = 0x1;
|
||||
}
|
||||
|
||||
nsIInterfaceInfo *interfaceInfo;
|
||||
nsIInterfaceInfoManager* iimgr;
|
||||
if( (iimgr = XPTI_GetInterfaceInfoManager()) ) {
|
||||
if (NS_FAILED(iimgr->GetInfoForIID(&iid, &interfaceInfo))) {
|
||||
delete mt;
|
||||
return NS_ERROR_FAILURE; //nb exception handling
|
||||
}
|
||||
NS_RELEASE(iimgr);
|
||||
} else {
|
||||
delete mt;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
char* name;
|
||||
interfaceInfo->GetName(&name);
|
||||
printf("in handleRequest interface name is %s\n",name);
|
||||
nsXPTMethodInfo* info;
|
||||
interfaceInfo->GetMethodInfo(methodId,(const nsXPTMethodInfo **)&info);
|
||||
PRUint32 paramCount = info->GetParamCount();
|
||||
bcICall *call = broker->CreateCall(&iid, &oid, methodId);
|
||||
mt->ReadParams(paramCount, info, message, interfaceInfo, methodId, call, broker, this, conn);
|
||||
delete mt;
|
||||
delete message;
|
||||
//nb return value; excepion handling
|
||||
broker->SendReceive(call);
|
||||
rv = SendReply(tid, call, paramCount, info, interfaceInfo,
|
||||
methodId, conn);
|
||||
// delete call;
|
||||
// NS_RELEASE(interfaceInfo);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
urpManager::SetCall(bcICall* call, PRMonitor *m, bcTID thrID) {
|
||||
monitCall* mc;
|
||||
// = new monitCall(m, call, nsnull, 0);
|
||||
printf("method SetCall %p %p %p %ld\n",call, m, this, thrID);
|
||||
threadHashKey thrHK(thrID);
|
||||
if(!(mc = (monitCall*)monitTable->Get(&thrHK))) {
|
||||
PR_INIT_CLIST((PRCList*)m);
|
||||
mc = new monitCall((PRCList*)m, nsnull, 0);
|
||||
monitTable->Put(&thrHK, mc);
|
||||
} else {
|
||||
PR_INSERT_LINK((PRCList*)m, mc->stack);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
urpManager::RemoveCall(forReply* fR, bcTID thrID) {
|
||||
printf("method RemoveCall\n");
|
||||
threadHashKey thrHK(thrID);
|
||||
monitCall* mc = (monitCall*)monitTable->Get(&thrHK);
|
||||
fR->mess= mc->mess;
|
||||
fR->header = mc->header;
|
||||
if(!mc->request) {
|
||||
mc = (monitCall*)monitTable->Get(&thrHK);
|
||||
PR_REMOVE_LINK(mc->stack);
|
||||
if(PR_CLIST_IS_EMPTY(mc->stack)) {
|
||||
mc = (monitCall*)monitTable->Remove(&thrHK);
|
||||
delete mc;
|
||||
} else {
|
||||
printf("It is not error\n");
|
||||
}
|
||||
} else {
|
||||
fR->iid = mc->iid;
|
||||
fR->oid = mc->oid;
|
||||
fR->tid = mc->tid;
|
||||
fR->methodId = mc->mid;
|
||||
fR->request = mc->request;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bcTID
|
||||
urpManager::GetThread() {
|
||||
bcTID thrID;
|
||||
bcTID* thr;
|
||||
if(threadTable) {
|
||||
thrID = (bcTID)PR_GetCurrentThread();
|
||||
threadHashKey thrHK(thrID);
|
||||
thr = (bcTID*)threadTable->Get(&thrHK);
|
||||
if(thr)
|
||||
thrID = *(bcTID*)thr;
|
||||
else {
|
||||
printf("Error with threads in SendUrpRequest\n");
|
||||
exit(-1);
|
||||
}
|
||||
} else
|
||||
thrID = (bcTID)PR_GetCurrentThread();
|
||||
return thrID;
|
||||
}
|
|
@ -1,636 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Sergey Lunegov <lsv@sparc.spb.su>
|
||||
*/
|
||||
|
||||
#include "prmem.h"
|
||||
#include "nsIInterfaceInfo.h"
|
||||
#include "nsIInterfaceInfoManager.h"
|
||||
#include "nsIAllocator.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "xptcall.h"
|
||||
#include "nsCRT.h"
|
||||
#include "urpMarshalToolkit.h"
|
||||
#include <unistd.h>
|
||||
#include "urpStub.h"
|
||||
|
||||
|
||||
#include "nsIModule.h"
|
||||
|
||||
|
||||
class urpAllocator : public bcIAllocator { //nb make is smarter. It should deallocate allocated memory.
|
||||
public:
|
||||
urpAllocator(nsIAllocator *_allocator) {
|
||||
allocator = _allocator;
|
||||
}
|
||||
virtual ~urpAllocator() {}
|
||||
virtual void * Alloc(size_t size) {
|
||||
return allocator->Alloc(size);
|
||||
}
|
||||
virtual void Free(void *ptr) {
|
||||
allocator->Free(ptr);
|
||||
}
|
||||
virtual void * Realloc(void* ptr, size_t size) {
|
||||
return allocator->Realloc(ptr,size);
|
||||
}
|
||||
private:
|
||||
nsCOMPtr<nsIAllocator> allocator;
|
||||
};
|
||||
|
||||
|
||||
urpMarshalToolkit::urpMarshalToolkit(PRBool isclnt) {
|
||||
isClient = isclnt;
|
||||
}
|
||||
|
||||
|
||||
urpMarshalToolkit::~urpMarshalToolkit() {
|
||||
}
|
||||
|
||||
nsresult
|
||||
urpMarshalToolkit::WriteElement(bcIUnMarshaler *um, nsXPTParamInfo * param, uint8 type, uint8 ind,
|
||||
nsIInterfaceInfo* interfaceInfo, urpPacket* message,
|
||||
PRUint16 methodIndex, const nsXPTMethodInfo *info,
|
||||
bcIAllocator * allocator) {
|
||||
void* data = allocator->Alloc(sizeof(void*));
|
||||
nsID *id;
|
||||
char* help;
|
||||
nsresult r = NS_OK;
|
||||
switch(type) {
|
||||
case nsXPTType::T_IID :
|
||||
id = new nsID();
|
||||
um->ReadSimple(id,XPTType2bcXPType(type));
|
||||
help = ((nsID)(*id)).ToString();
|
||||
printf("nsIID %s\n", help);
|
||||
message->WriteString(help, strlen(help));
|
||||
delete id;
|
||||
PR_Free(help);
|
||||
break;
|
||||
case nsXPTType::T_I8 :
|
||||
um->ReadSimple(data,XPTType2bcXPType(type));
|
||||
message->WriteByte(*(char*)data);
|
||||
break;
|
||||
case nsXPTType::T_I16 :
|
||||
um->ReadSimple(data,XPTType2bcXPType(type));
|
||||
message->WriteShort(*(short*)data);
|
||||
break;
|
||||
case nsXPTType::T_I32 :
|
||||
um->ReadSimple(data,XPTType2bcXPType(type));
|
||||
message->WriteInt(*(int*)data);
|
||||
break;
|
||||
case nsXPTType::T_I64 :
|
||||
um->ReadSimple(data,XPTType2bcXPType(type));
|
||||
message->WriteLong(*(long*)data);
|
||||
break;
|
||||
case nsXPTType::T_U8 :
|
||||
um->ReadSimple(data,XPTType2bcXPType(type));
|
||||
message->WriteByte(*(char*)data);
|
||||
break;
|
||||
case nsXPTType::T_U16 :
|
||||
um->ReadSimple(data,XPTType2bcXPType(type));
|
||||
message->WriteShort(*(short*)data);
|
||||
break;
|
||||
case nsXPTType::T_U32 :
|
||||
um->ReadSimple(data,XPTType2bcXPType(type));
|
||||
message->WriteInt(*(int*)data);
|
||||
break;
|
||||
case nsXPTType::T_U64 :
|
||||
um->ReadSimple(data,XPTType2bcXPType(type));
|
||||
message->WriteLong(*(long*)data);
|
||||
break;
|
||||
case nsXPTType::T_FLOAT :
|
||||
um->ReadSimple(data,XPTType2bcXPType(type));
|
||||
message->WriteFloat(*(float*)data);
|
||||
break;
|
||||
case nsXPTType::T_DOUBLE :
|
||||
um->ReadSimple(data,XPTType2bcXPType(type));
|
||||
message->WriteDouble(*(double*)data);
|
||||
break;
|
||||
case nsXPTType::T_CHAR :
|
||||
case nsXPTType::T_WCHAR :
|
||||
um->ReadSimple(data,XPTType2bcXPType(type));
|
||||
message->WriteByte(*(char*)data);
|
||||
break;
|
||||
case nsXPTType::T_CHAR_STR :
|
||||
case nsXPTType::T_WCHAR_STR :
|
||||
{
|
||||
size_t size;
|
||||
um->ReadString(data,&size,allocator);
|
||||
{
|
||||
char *str = *(char**)data;
|
||||
for (int i = 0; i < size && type == nsXPTType::T_WCHAR_STR; i++) {
|
||||
char c = str[i];
|
||||
}
|
||||
}
|
||||
data = *(char **)data;
|
||||
size_t length = 0;
|
||||
if(data != nsnull) {
|
||||
if (type == nsXPTType::T_WCHAR_STR) {
|
||||
length = nsCRT::strlen((const PRUnichar*)data);
|
||||
length *= 2;
|
||||
length +=2;
|
||||
for (int i = 0; i < length && type == nsXPTType::T_WCHAR_STR; i++) {
|
||||
char c = ((char*)data)[i];
|
||||
}
|
||||
} else {
|
||||
length = nsCRT::strlen((const char*)data);
|
||||
length+=1;
|
||||
}
|
||||
}
|
||||
message->WriteString((char*)data,length);
|
||||
break;
|
||||
}
|
||||
case nsXPTType::T_INTERFACE :
|
||||
case nsXPTType::T_INTERFACE_IS :
|
||||
{
|
||||
nsIID iid;
|
||||
bcOID oid;
|
||||
um->ReadSimple(&oid,XPTType2bcXPType(type));
|
||||
um->ReadSimple(&iid,bc_T_IID);
|
||||
WriteOid(oid, message);
|
||||
WriteType(iid, message);
|
||||
break;
|
||||
}
|
||||
case nsXPTType::T_PSTRING_SIZE_IS:
|
||||
case nsXPTType::T_PWSTRING_SIZE_IS:
|
||||
case nsXPTType::T_ARRAY: //nb array of interfaces [to do]
|
||||
{
|
||||
size_t size;
|
||||
nsXPTType datumType;
|
||||
if(type != nsXPTType::T_ARRAY) {
|
||||
um->ReadString(data,&size,allocator);
|
||||
{
|
||||
char *str = *(char**)data;
|
||||
for (int i = 0; i < size && type == nsXPTType::T_WCHAR_STR; i++) {
|
||||
char c = str[i];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(NS_FAILED(interfaceInfo->GetTypeForParam(methodIndex, param, 1,&datumType))) {
|
||||
allocator->Free(data);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
PRUint32 arraySize;
|
||||
PRInt16 elemSize = GetSimpleSize(datumType);
|
||||
um->ReadSimple(&arraySize,bc_T_U32);
|
||||
message->WriteInt(arraySize);
|
||||
for (unsigned int i = 0; i < arraySize; i++) {
|
||||
r = WriteElement(um,param,datumType.TagPart(),0,
|
||||
interfaceInfo, message, methodIndex, info, allocator);
|
||||
if(NS_FAILED(r)) {
|
||||
allocator->Free(data);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (type != nsXPTType::T_ARRAY) {
|
||||
size_t length = 0;
|
||||
if (type == nsXPTType::T_PWSTRING_SIZE_IS) {
|
||||
length = size * sizeof(PRUnichar);
|
||||
} else {
|
||||
length = size;
|
||||
}
|
||||
message->WriteString((char*)data, length);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
allocator->Free(data);
|
||||
return r;
|
||||
}
|
||||
allocator->Free(data);
|
||||
return r;
|
||||
}
|
||||
|
||||
nsresult
|
||||
urpMarshalToolkit::WriteParams(bcICall *call, PRUint32 paramCount, const nsXPTMethodInfo *info, nsIInterfaceInfo* interfaceInfo, urpPacket* message, PRUint16 methodIndex) {
|
||||
int i;
|
||||
nsresult rv = NS_OK;
|
||||
bcIAllocator * allocator = new urpAllocator(nsAllocator::GetGlobalAllocator());
|
||||
bcIUnMarshaler *um = call->GetUnMarshaler();
|
||||
if(!isClient) {
|
||||
nsresult result;
|
||||
um->ReadSimple(&result, bc_T_U32);
|
||||
message->WriteInt(result);
|
||||
if(!NS_SUCCEEDED(result)) {
|
||||
printf("Returned result is error on server side\n");
|
||||
delete allocator;
|
||||
delete um;
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
for(i=0;i<paramCount;i++) {
|
||||
short cache_index;
|
||||
nsXPTParamInfo param = info->GetParam(i);
|
||||
PRBool isOut = param.IsOut();
|
||||
if ((isClient && !param.IsIn()) ||
|
||||
(!isClient && !param.IsOut())) {
|
||||
continue;
|
||||
}
|
||||
rv = WriteElement(um, ¶m,param.GetType().TagPart(), i, interfaceInfo, message, methodIndex, info, allocator);
|
||||
if(NS_FAILED(rv)) {
|
||||
delete allocator;
|
||||
delete um;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
delete allocator;
|
||||
delete um;
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
urpMarshalToolkit::ReadElement(nsXPTParamInfo * param, uint8 type,
|
||||
nsIInterfaceInfo* interfaceInfo, urpPacket* message,
|
||||
PRUint16 methodIndex, bcIAllocator* allocator,
|
||||
bcIMarshaler* m, bcIORB *broker, urpManager* man,
|
||||
urpConnection* conn) {
|
||||
void* data = allocator->Alloc(sizeof(void*));
|
||||
nsresult r = NS_OK;
|
||||
char* str;
|
||||
nsID id;
|
||||
switch(type) {
|
||||
case nsXPTType::T_IID :
|
||||
{
|
||||
int size;
|
||||
str = message->ReadString(size);
|
||||
id.Parse((char*)str);
|
||||
m->WriteSimple((char*)&id, XPTType2bcXPType(type));
|
||||
PR_Free(str);
|
||||
break;
|
||||
}
|
||||
case nsXPTType::T_I8 :
|
||||
*(char*)data = message->ReadByte();
|
||||
m->WriteSimple(data, XPTType2bcXPType(type));
|
||||
break;
|
||||
case nsXPTType::T_I16 :
|
||||
*(short*)data = message->ReadShort();
|
||||
m->WriteSimple(data, XPTType2bcXPType(type));
|
||||
break;
|
||||
case nsXPTType::T_I32 :
|
||||
*(int*)data = message->ReadInt();
|
||||
m->WriteSimple(data, XPTType2bcXPType(type));
|
||||
break;
|
||||
case nsXPTType::T_I64 :
|
||||
*(long*)data = message->ReadLong();
|
||||
m->WriteSimple(data, XPTType2bcXPType(type));
|
||||
break;
|
||||
case nsXPTType::T_U8 :
|
||||
*(char*)data = message->ReadByte();
|
||||
m->WriteSimple(data, XPTType2bcXPType(type));
|
||||
break;
|
||||
case nsXPTType::T_U16 :
|
||||
*(short*)data = message->ReadShort();
|
||||
m->WriteSimple(data, XPTType2bcXPType(type));
|
||||
break;
|
||||
case nsXPTType::T_U32 :
|
||||
*(int*)data = message->ReadInt();
|
||||
m->WriteSimple(data, XPTType2bcXPType(type));
|
||||
break;
|
||||
case nsXPTType::T_U64 :
|
||||
*(long*)data = message->ReadLong();
|
||||
m->WriteSimple(data, XPTType2bcXPType(type));
|
||||
break;
|
||||
case nsXPTType::T_FLOAT :
|
||||
*(float*)data = message->ReadFloat();
|
||||
m->WriteSimple(data, XPTType2bcXPType(type));
|
||||
break;
|
||||
case nsXPTType::T_DOUBLE :
|
||||
*(double*)data = message->ReadDouble();
|
||||
m->WriteSimple(data, XPTType2bcXPType(type));
|
||||
break;
|
||||
case nsXPTType::T_CHAR_STR :
|
||||
case nsXPTType::T_WCHAR_STR :
|
||||
{
|
||||
int size;
|
||||
/*
|
||||
*(char**)data = message->ReadString(size);
|
||||
data = *(char **)data;
|
||||
*/
|
||||
str = message->ReadString(size);
|
||||
data = str;
|
||||
size_t length = 0;
|
||||
if (type == nsXPTType::T_WCHAR_STR) {
|
||||
length = nsCRT::strlen((const PRUnichar*)data);
|
||||
length *= 2;
|
||||
length +=2;
|
||||
for (int i = 0; i < length && type == nsXPTType::T_WCHAR_STR; i++) {
|
||||
char c = ((char*)data)[i];
|
||||
}
|
||||
} else {
|
||||
length = nsCRT::strlen((const char*)data);
|
||||
length+=1;
|
||||
}
|
||||
m->WriteString(data,length);
|
||||
PR_Free(str);
|
||||
break;
|
||||
}
|
||||
case nsXPTType::T_INTERFACE :
|
||||
case nsXPTType::T_INTERFACE_IS :
|
||||
{
|
||||
bcOID oid = ReadOid(message);
|
||||
nsIID iid = ReadType(message);
|
||||
nsISupports *proxy = NULL;
|
||||
if (oid != 0) {
|
||||
urpStub* stub = new urpStub(man, conn);
|
||||
broker->RegisterStubWithOID(stub, &oid);
|
||||
}
|
||||
m->WriteSimple(&oid, XPTType2bcXPType(type));
|
||||
m->WriteSimple(&iid,bc_T_IID);
|
||||
break;
|
||||
}
|
||||
case nsXPTType::T_PSTRING_SIZE_IS:
|
||||
case nsXPTType::T_PWSTRING_SIZE_IS:
|
||||
case nsXPTType::T_ARRAY:
|
||||
{
|
||||
nsXPTType datumType;
|
||||
if(NS_FAILED(interfaceInfo->GetTypeForParam(methodIndex, param, 1,&datumType))) {
|
||||
allocator->Free(data);
|
||||
return r;
|
||||
}
|
||||
PRUint32 arraySize;
|
||||
PRInt16 elemSize = GetSimpleSize(datumType);
|
||||
arraySize = message->ReadInt();
|
||||
|
||||
if(type == nsXPTType::T_ARRAY) {
|
||||
m->WriteSimple(&arraySize,bc_T_U32);
|
||||
char *current = *(char**)data;
|
||||
for (int i = 0; i < arraySize; i++) {
|
||||
ReadElement(param,datumType.TagPart(),interfaceInfo, message, methodIndex, allocator, m, broker, man, conn);
|
||||
}
|
||||
} else {
|
||||
size_t length = 0;
|
||||
if (type == nsXPTType::T_PWSTRING_SIZE_IS) {
|
||||
length = arraySize * sizeof(PRUnichar);
|
||||
} else {
|
||||
length = arraySize;
|
||||
}
|
||||
m->WriteString(data, length);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
allocator->Free(data);
|
||||
return r;
|
||||
}
|
||||
allocator->Free(data);
|
||||
return r;
|
||||
}
|
||||
|
||||
nsresult
|
||||
urpMarshalToolkit::ReadParams(PRUint32 paramCount, const nsXPTMethodInfo *info, urpPacket* message, nsIInterfaceInfo *interfaceInfo, PRUint16 methodIndex, bcICall* call, bcIORB *orb, urpManager* man, urpConnection* conn) {
|
||||
bcIAllocator * allocator = new urpAllocator(nsAllocator::GetGlobalAllocator());
|
||||
bcIMarshaler* m = call->GetMarshaler();
|
||||
int i;
|
||||
nsresult rv = NS_OK;
|
||||
if(isClient) {
|
||||
nsresult result = message->ReadInt();
|
||||
m->WriteSimple(&result, bc_T_U32);
|
||||
if (!NS_SUCCEEDED(result)) {
|
||||
printf("Returned result is error on client side\n");
|
||||
delete allocator;
|
||||
delete m;
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
for(i=0;i<paramCount;i++) {
|
||||
short cache_index;
|
||||
nsXPTParamInfo param = info->GetParam(i);
|
||||
PRBool isOut = param.IsOut();
|
||||
|
||||
if ((!isClient && !param.IsIn()) ||
|
||||
(isClient && !param.IsOut())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
rv = ReadElement(¶m, param.GetType().TagPart(), interfaceInfo,
|
||||
message, methodIndex, allocator, m, orb, man, conn);
|
||||
if(NS_FAILED(rv)) {
|
||||
delete allocator;
|
||||
delete m;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
delete allocator;
|
||||
delete m;
|
||||
return rv;
|
||||
}
|
||||
|
||||
PRInt16 urpMarshalToolkit::GetSimpleSize(uint8 type) {
|
||||
PRInt16 size = -1;
|
||||
switch(type) {
|
||||
case nsXPTType::T_I8:
|
||||
case nsXPTType::T_U8:
|
||||
size = sizeof(PRInt8);
|
||||
break;
|
||||
case nsXPTType::T_I16:
|
||||
case nsXPTType::T_U16:
|
||||
size = sizeof(PRInt16);
|
||||
break;
|
||||
case nsXPTType::T_I32:
|
||||
case nsXPTType::T_U32:
|
||||
size = sizeof(PRInt32);
|
||||
break;
|
||||
case nsXPTType::T_I64:
|
||||
case nsXPTType::T_U64:
|
||||
size = sizeof(PRInt64);
|
||||
break;
|
||||
case nsXPTType::T_FLOAT:
|
||||
size = sizeof(float);
|
||||
break;
|
||||
case nsXPTType::T_DOUBLE:
|
||||
size = sizeof(double);
|
||||
break;
|
||||
case nsXPTType::T_BOOL:
|
||||
size = sizeof(PRBool);
|
||||
break;
|
||||
case nsXPTType::T_CHAR:
|
||||
size = sizeof(char);
|
||||
break;
|
||||
case nsXPTType::T_WCHAR:
|
||||
size = sizeof(PRUnichar);
|
||||
break;
|
||||
default:
|
||||
size = sizeof(void*);
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
bcXPType urpMarshalToolkit::XPTType2bcXPType(uint8 type) {
|
||||
switch(type) {
|
||||
case nsXPTType::T_I8 :
|
||||
return bc_T_I8;
|
||||
case nsXPTType::T_U8 :
|
||||
return bc_T_U8;
|
||||
case nsXPTType::T_I16 :
|
||||
return bc_T_I16;
|
||||
case nsXPTType::T_U16 :
|
||||
return bc_T_U16;
|
||||
case nsXPTType::T_I32 :
|
||||
return bc_T_I32;
|
||||
case nsXPTType::T_U32 :
|
||||
return bc_T_U32;
|
||||
case nsXPTType::T_I64 :
|
||||
return bc_T_I64;
|
||||
case nsXPTType::T_U64 :
|
||||
return bc_T_U64;
|
||||
case nsXPTType::T_FLOAT :
|
||||
return bc_T_FLOAT;
|
||||
case nsXPTType::T_DOUBLE :
|
||||
return bc_T_DOUBLE;
|
||||
case nsXPTType::T_BOOL :
|
||||
return bc_T_BOOL;
|
||||
case nsXPTType::T_CHAR :
|
||||
return bc_T_CHAR;
|
||||
case nsXPTType::T_WCHAR :
|
||||
return bc_T_WCHAR;
|
||||
case nsXPTType::T_IID :
|
||||
return bc_T_IID;
|
||||
case nsXPTType::T_CHAR_STR :
|
||||
case nsXPTType::T_PSTRING_SIZE_IS:
|
||||
return bc_T_CHAR_STR;
|
||||
case nsXPTType::T_WCHAR_STR :
|
||||
case nsXPTType::T_PWSTRING_SIZE_IS:
|
||||
return bc_T_WCHAR_STR;
|
||||
case nsXPTType::T_INTERFACE :
|
||||
case nsXPTType::T_INTERFACE_IS :
|
||||
return bc_T_INTERFACE;
|
||||
case nsXPTType::T_ARRAY:
|
||||
return bc_T_ARRAY;
|
||||
default:
|
||||
return bc_T_UNDEFINED;
|
||||
|
||||
}
|
||||
}
|
||||
void
|
||||
urpMarshalToolkit::WriteType(bcIID iid, urpPacket* message) {
|
||||
|
||||
short cache_index;
|
||||
|
||||
char typeClass = INTERFACE;
|
||||
int found = 0;
|
||||
|
||||
if(0) //here should be checking on whether class is simple or not
|
||||
printf("class is simple\n");
|
||||
else {
|
||||
if(0) { // here should be checking on whether cache is used
|
||||
printf("cache is used\n");
|
||||
cache_index = 0x0;
|
||||
}
|
||||
else
|
||||
cache_index = (short)0xffff;
|
||||
|
||||
message->WriteByte((char)typeClass | (found ? 0x0 : 0x80));
|
||||
printf("write type is %x\n",(char)typeClass | (found ? 0x0 : 0x80));
|
||||
message->WriteShort(cache_index);
|
||||
printf("write type is %x\n",cache_index);
|
||||
|
||||
if(!found) {
|
||||
char* iidStr = iid.ToString();
|
||||
message->WriteString(iidStr, strlen(iidStr));
|
||||
PR_Free(iidStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bcIID
|
||||
urpMarshalToolkit::ReadType(urpPacket* message) {
|
||||
|
||||
char byte = (char)message->ReadByte();
|
||||
char typeClassValue = byte & 0xff;
|
||||
|
||||
short cache_index = message->ReadShort();
|
||||
|
||||
int size;
|
||||
nsIID iid;
|
||||
char* name = message->ReadString(size);
|
||||
iid.Parse(name);
|
||||
PR_Free(name);
|
||||
return iid;
|
||||
}
|
||||
|
||||
void
|
||||
urpMarshalToolkit::WriteOid(bcOID oid, urpPacket* message) {
|
||||
short cache_index;
|
||||
int found = 0;
|
||||
|
||||
if(0) { // here should be checking on whether cache is used
|
||||
printf("cache is used\n");
|
||||
cache_index = 0x0;
|
||||
}
|
||||
else
|
||||
cache_index = (short)0xffff;
|
||||
|
||||
char* str = (char*)calloc(100, sizeof(char));
|
||||
sprintf(str,"%ld",oid);
|
||||
message->WriteString(str, strlen(str));
|
||||
free(str);
|
||||
message->WriteShort(cache_index);
|
||||
}
|
||||
|
||||
bcOID
|
||||
urpMarshalToolkit::ReadOid(urpPacket* message) {
|
||||
int size;
|
||||
bcOID result;
|
||||
|
||||
char* str = message->ReadString(size);
|
||||
short cache_index = message->ReadShort();
|
||||
result = (bcOID)atol(str);
|
||||
PR_Free(str);
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
urpMarshalToolkit::WriteThreadID(bcTID tid, urpPacket* message) {
|
||||
short cache_index;
|
||||
int found = 0;
|
||||
|
||||
char realTID[4]; /* this is hack: I know that bcTID is PRUint32
|
||||
so it is represented by four bytes */
|
||||
realTID[0] = tid>>24 & 0xff;
|
||||
realTID[1] = (tid>>16) & 0xff;
|
||||
realTID[2] = (tid>>8) & 0xff;
|
||||
realTID[3] = tid & 0xff;
|
||||
|
||||
if(0) { // here should be checking on whether cache is used
|
||||
printf("cache is used\n");
|
||||
cache_index = 0x0;
|
||||
}
|
||||
else
|
||||
cache_index = (short)0xffff;
|
||||
|
||||
message->WriteOctetStream(realTID, 4);
|
||||
message->WriteShort(cache_index);
|
||||
}
|
||||
|
||||
bcTID
|
||||
urpMarshalToolkit::ReadThreadID(urpPacket* message) {
|
||||
int size = 0;
|
||||
bcTID result;
|
||||
char* array = message->ReadOctetStream(size);
|
||||
short cache_index = message->ReadShort();
|
||||
result = ((unsigned char)array[0]<<24) + ((unsigned char)array[1]<<16) + ((unsigned char)array[2]<<8) + ((unsigned char)array[3]&0xff);
|
||||
PR_Free(array);
|
||||
return result;
|
||||
}
|
|
@ -1,108 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Sergey Lunegov <lsv@sparc.spb.su>
|
||||
*/
|
||||
|
||||
#include "prmem.h"
|
||||
#include "nsIInterfaceInfo.h"
|
||||
#include "nsIInterfaceInfoManager.h"
|
||||
#include "xptcall.h"
|
||||
#include "nsCRT.h"
|
||||
#include "urpStub.h"
|
||||
|
||||
#include "urpManager.h"
|
||||
|
||||
|
||||
urpStub::urpStub(urpManager* man, urpConnection* conn) {
|
||||
manager = man;
|
||||
connection = conn;
|
||||
_mOwningThread = PR_CurrentThread();
|
||||
}
|
||||
|
||||
|
||||
urpStub::~urpStub() {
|
||||
printf("destructor of urpStub\n");
|
||||
if(manager)
|
||||
delete manager;
|
||||
}
|
||||
|
||||
void urpStub::Dispatch(bcICall *call) {
|
||||
|
||||
printf("this is method Dispatch of urpStub\n");
|
||||
bcIID iid; bcOID oid; bcMID mid;
|
||||
call->GetParams(&iid, &oid, &mid);
|
||||
nsIInterfaceInfo *interfaceInfo;
|
||||
nsIInterfaceInfoManager* iimgr;
|
||||
if( (iimgr = XPTI_GetInterfaceInfoManager()) ) {
|
||||
if (NS_FAILED(iimgr->GetInfoForIID(&iid, &interfaceInfo))) {
|
||||
return; //nb exception handling
|
||||
}
|
||||
NS_RELEASE(iimgr);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
char* name;
|
||||
interfaceInfo->GetName(&name);
|
||||
printf("real interface name is %s\n",name);
|
||||
|
||||
nsXPTMethodInfo* info;
|
||||
interfaceInfo->GetMethodInfo(mid, (const nsXPTMethodInfo **)&info);
|
||||
PRUint32 paramCount = info->GetParamCount();
|
||||
PRMonitor* mon = PR_NewMonitor();
|
||||
PR_EnterMonitor(mon);
|
||||
printf("ThreadID is written %d %p %p %p %p\n",paramCount, call, mon, manager, this);
|
||||
bcTID tid = manager->GetThread();
|
||||
nsresult rv = manager->SetCall(call, mon, tid);
|
||||
if(NS_FAILED(rv)) {
|
||||
printf("Error of SetCall in method Dispatch\n");
|
||||
exit(-1);
|
||||
}
|
||||
manager->SendUrpRequest(oid, iid, mid, interfaceInfo, call, paramCount,
|
||||
info, connection);
|
||||
forReply* fR = (forReply*)PR_Malloc(sizeof(forReply));
|
||||
while(1) {
|
||||
fR->request = 0;
|
||||
if(NS_FAILED(PR_Wait(mon, PR_INTERVAL_NO_TIMEOUT))) {
|
||||
printf("Can't wait on cond var\n");
|
||||
exit(-1);
|
||||
}
|
||||
rv = manager->RemoveCall(fR, tid);
|
||||
if(fR->request)
|
||||
manager->ReadLongRequest(fR->header, fR->mess, fR->iid,
|
||||
fR->oid, fR->tid, fR->methodId, connection);
|
||||
else
|
||||
break;
|
||||
}
|
||||
manager->ReadReply(fR->mess, fR->header, call, paramCount,
|
||||
info, interfaceInfo, mid, connection);
|
||||
NS_RELEASE(interfaceInfo);
|
||||
PR_ExitMonitor(mon);
|
||||
PR_DestroyMonitor(mon);
|
||||
delete fR->mess;
|
||||
PR_Free(fR);
|
||||
}
|
||||
|
||||
|
||||
void urpStub::SetORB(bcIORB *orb){
|
||||
//nb to be implemented
|
||||
}
|
||||
void urpStub::SetOID(bcOID oid) {
|
||||
//nb to be implemented
|
||||
}
|
Загрузка…
Ссылка в новой задаче