зеркало из https://github.com/mozilla/gecko-dev.git
Родитель
b4e6745c60
Коммит
0ccc81ad71
|
@ -34,7 +34,7 @@ include $(DEPTH)/config/autoconf.mk
|
|||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
DIRS = transport test loader
|
||||
DIRS = transport test loader connect
|
||||
|
||||
CXXFLAGS += -I$(CONNECT_SRC)/public -I$(topsrcdir)/java/xpcom/xpcom -Itransport
|
||||
CPPSRCS = \
|
||||
|
|
|
@ -34,7 +34,7 @@ include $(DEPTH)/config/autoconf.mk
|
|||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
DIRS = transport test loader
|
||||
DIRS = transport test loader connect
|
||||
|
||||
CXXFLAGS += -I$(CONNECT_SRC)/public -I$(topsrcdir)/java/xpcom/xpcom -Itransport
|
||||
CPPSRCS = \
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
#!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
|
|
@ -0,0 +1,104 @@
|
|||
/* -*- 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;
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
/* -*- 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>
|
||||
*/
|
||||
|
||||
#ifndef _urpCONNECTCOMPONENT_h
|
||||
#define _urpCONNECTCOMPONENT_h
|
||||
#include "urpIConnectComponent.h"
|
||||
#include "urpConnectComponentCID.h"
|
||||
|
||||
#include "../urpManager.h"
|
||||
#include "../urpStub.h"
|
||||
|
||||
class urpConnectComponent : public urpIConnectComponent {
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_IMETHOD GetCompMan(char* cntStr, nsISupports** ret);
|
||||
NS_IMETHODIMP GetTransport(char* cntStr, urpTransport** trans);
|
||||
urpConnectComponent();
|
||||
virtual ~urpConnectComponent();
|
||||
private:
|
||||
urpConnection* connection;
|
||||
urpTransport* transport;
|
||||
urpManager* man;
|
||||
urpStub* stub;
|
||||
nsISupports* compM;
|
||||
bcIORB* orb;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
/* -*- 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>
|
||||
*/
|
||||
|
||||
#ifndef __urpConnectComponentCID_h__
|
||||
#define __urpConnectComponentCID_h__
|
||||
|
||||
#define URP_CONNECTCOMPONENT_ContractID "@mozilla.org/blackwood/urpconnect/connectcomponent;1"
|
||||
|
||||
/*66c1700d-b509-4c2f-aba2-8c18a6aac4cc*/
|
||||
#define URP_CONNECTCOMPONENT_CID \
|
||||
{ 0x66c1700d, 0xb509, 0x4c2f, \
|
||||
{0xab, 0xa2, 0x8c, 0x18, 0xa6, 0xaa, 0xc4, 0xcc }}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
/* -*- 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>
|
||||
*/
|
||||
|
||||
#ifndef __urpIConnectComponent_h__
|
||||
#define __urpIConnectComponent_h_
|
||||
#include "nsISupports.h"
|
||||
#include "urpTransport.h"
|
||||
|
||||
/*b7f595cb-dd93-4d70-868b-9f9ae35e6181*/
|
||||
#define URP_CONNECTCOMPONENT_IID \
|
||||
{ 0xb7f595cb, 0xdd93, 0x4d70, \
|
||||
{0x86, 0x8b, 0x9f, 0x9a, 0xe3, 0x5e, 0x61, 0x81}}
|
||||
|
||||
class urpIConnectComponent : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(URP_CONNECTCOMPONENT_IID)
|
||||
NS_IMETHOD GetCompMan(char* cntStr, nsISupports** man) = 0;
|
||||
NS_IMETHOD GetTransport(char* cntStr, urpTransport** trans) = 0;
|
||||
};
|
||||
#endif
|
|
@ -17,27 +17,28 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
* 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 nsISupports* compM = nsnull;
|
||||
//nsCOMPtr<nsIComponentManager> compM = nsnull;
|
||||
static NS_DEFINE_CID(kConnectComponent,URP_CONNECTCOMPONENT_CID);
|
||||
|
||||
urpComponentFactory::urpComponentFactory(const char *_location, const nsCID &aCID, nsISupports* m) {
|
||||
|
||||
urpComponentFactory::urpComponentFactory(const char *_location, const nsCID &aCID) {
|
||||
NS_INIT_ISUPPORTS();
|
||||
location = nsCRT::strdup(_location);
|
||||
aClass = aCID;
|
||||
compM = (nsIComponentManager*)m;
|
||||
}
|
||||
|
||||
urpComponentFactory::~urpComponentFactory() {
|
||||
printf("destructor or urpComponentFactory\n");
|
||||
NS_RELEASE(compM);
|
||||
nsCRT::free((char*)location);
|
||||
}
|
||||
|
||||
|
@ -47,7 +48,14 @@ NS_IMETHODIMP urpComponentFactory::CreateInstance(nsISupports *aOuter, const nsI
|
|||
printf("--urpComponentFactory::CreateInstance\n");
|
||||
nsresult r;
|
||||
nsIFactory* factory;
|
||||
((nsIComponentManager*)(compM))->FindFactory(aClass, &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");
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
* Sergey Lunegov <lsv@sparc.spb.su>
|
||||
*/
|
||||
#ifndef __urpComponentFactory_h
|
||||
#define __urpComponentFactory_h
|
||||
|
@ -27,13 +27,11 @@ class urpComponentFactory : public nsIFactory {
|
|||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIFACTORY
|
||||
urpComponentFactory(const char *location, const nsCID &aCID,
|
||||
nsISupports* m);
|
||||
urpComponentFactory(const char *location, const nsCID &aCID);
|
||||
virtual ~urpComponentFactory();
|
||||
private:
|
||||
char *location;
|
||||
nsCID aClass;
|
||||
nsIComponentManager* compM;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
* Sergey Lunegov <lsv@sparc.spb.su>
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -33,16 +33,6 @@
|
|||
#include "nsXPIDLString.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
#include "bcIXPCOMStubsAndProxies.h"
|
||||
#include "bcXPCOMStubsAndProxiesCID.h"
|
||||
#include "bcIORBComponent.h"
|
||||
#include "bcORBComponentCID.h"
|
||||
|
||||
#include "urpStub.h"
|
||||
#include "urpManager.h"
|
||||
|
||||
static NS_DEFINE_CID(kXPCOMStubsAndProxies,BC_XPCOMSTUBSANDPROXIES_CID);
|
||||
static NS_DEFINE_CID(kORBComponent,BC_ORBCOMPONENT_CID);
|
||||
|
||||
const char urpComponentTypeName[] = URPCOMPONENTTYPENAME;
|
||||
|
||||
|
@ -59,13 +49,6 @@ const char xpcomKeyName[] = "software/mozilla/XPCOM/components";
|
|||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS(urpComponentLoader,NS_GET_IID(nsIComponentLoader));
|
||||
|
||||
//nsCOMPtr<nsIComponentManager> compM = nsnull;
|
||||
static bcIORB* orb = nsnull;
|
||||
static urpTransport* transport;
|
||||
static urpManager* man;
|
||||
static bcIStub* stub;
|
||||
static nsISupports* proxy = nsnull;
|
||||
|
||||
urpComponentLoader::urpComponentLoader()
|
||||
: mCompMgr(NULL),
|
||||
|
||||
|
@ -73,40 +56,9 @@ urpComponentLoader::urpComponentLoader()
|
|||
{
|
||||
NS_INIT_REFCNT();
|
||||
printf("--urpComponentLoader::urpComponentLoader \n");
|
||||
nsresult r;
|
||||
NS_WITH_SERVICE(bcIXPCOMStubsAndProxies, xpcomStubsAndProxies, kXPCOMStubsAndProxies, &r);
|
||||
if (NS_FAILED(r)) {
|
||||
printf("--urpComponentFactory::CreateInstance xpcomStubsAndProxies failed \n");
|
||||
return;
|
||||
}
|
||||
NS_WITH_SERVICE(bcIORBComponent, _orb, kORBComponent, &r);
|
||||
if (NS_FAILED(r)) {
|
||||
printf("--urpComponentFactory::CreateInstance bcORB failed \n");
|
||||
return;
|
||||
}
|
||||
_orb->GetORB(&orb);
|
||||
// bcOID oid;
|
||||
bcOID oid = 1601175553;
|
||||
transport = new urpConnector();
|
||||
PRStatus status = transport->Open("socket,host=indra,port=20009");
|
||||
if(status != PR_SUCCESS) {
|
||||
printf("Error during opening connection\n");
|
||||
exit(-1);
|
||||
}
|
||||
urpConnection* conn = transport->GetConnection();
|
||||
man = new urpManager(PR_TRUE, nsnull, conn);
|
||||
stub = new urpStub(man, conn);
|
||||
// oid = orb->RegisterStub(stub);
|
||||
orb->RegisterStubWithOID(stub, &oid);
|
||||
xpcomStubsAndProxies->GetProxy(oid, NS_GET_IID(nsIComponentManager), orb, (nsISupports**)&proxy);
|
||||
// compM = (nsIComponentManager*)proxy;
|
||||
}
|
||||
|
||||
urpComponentLoader::~urpComponentLoader() { //nb
|
||||
delete stub;
|
||||
delete man;
|
||||
delete transport;
|
||||
// NS_RELEASE(proxy);
|
||||
printf("--urpComponentLoader::~urpComponentLoader \n");
|
||||
}
|
||||
|
||||
|
@ -124,7 +76,8 @@ NS_IMETHODIMP urpComponentLoader::GetFactory(const nsIID & aCID, const char *aLo
|
|||
fprintf(stderr, "--urpComponentLoader::GetFactory(%s,%s,%s)\n", cidString, aLocation, aType);
|
||||
delete [] cidString;
|
||||
#endif
|
||||
nsIFactory *f = new urpComponentFactory(aLocation, aCID, proxy);
|
||||
// nsIFactory *f = new urpComponentFactory(aLocation, aCID, proxy);
|
||||
nsIFactory *f = new urpComponentFactory(aLocation, aCID);
|
||||
NS_ADDREF(f);
|
||||
*_retval = f;
|
||||
return NS_OK;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
* Sergey Lunegov <lsv@sparc.spb.su>
|
||||
*/
|
||||
#ifndef _urpComponentLoader_h
|
||||
#define _urpComponentLoader_h
|
||||
|
|
|
@ -27,7 +27,8 @@
|
|||
#include "nsIInterfaceInfo.h"
|
||||
#include "nsIInterfaceInfoManager.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "bcIJavaSample.h"
|
||||
#include "urpITest.h"
|
||||
#include "urpTestImpl.h"
|
||||
|
||||
static char * className = "initImpl";
|
||||
|
||||
|
@ -37,11 +38,11 @@ initImpl::initImpl() {
|
|||
NS_INIT_REFCNT();
|
||||
printf("Constructor of initImpl\n");
|
||||
nsresult rv;
|
||||
bcIJavaSample * serverComponent;
|
||||
// urpITest* anComp;
|
||||
rv = nsComponentManager::CreateInstance("bcJavaSample",
|
||||
urpITest * serverComponent;
|
||||
urpITest* anComp;
|
||||
rv = nsComponentManager::CreateInstance("urpTest",
|
||||
nsnull,
|
||||
NS_GET_IID(bcIJavaSample),
|
||||
NS_GET_IID(urpITest),
|
||||
(void**)&serverComponent);
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("Create instance failed in initImpl!!!");
|
||||
|
@ -58,27 +59,23 @@ initImpl::initImpl() {
|
|||
}
|
||||
*/
|
||||
int l = 2000;
|
||||
serverComponent->Test1(100);
|
||||
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";
|
||||
*/
|
||||
int intArray[] = {1,2,3};
|
||||
serverComponent->Test3(3, intArray);
|
||||
// printf("--urpTestImpl after Test3 s2=%s\n",s2);
|
||||
serverComponent->Test3(s1,&s2);
|
||||
printf("--urpTestImpl after Test3 s2=%s\n",s2);
|
||||
/*******************************************/
|
||||
|
||||
char ** valueArray = (char **)malloc(sizeof(char*)*4);
|
||||
|
@ -87,28 +84,9 @@ initImpl::initImpl() {
|
|||
valueArray[2] = "a";
|
||||
valueArray[3] = "b";
|
||||
|
||||
char *** valueArray2 = &valueArray;
|
||||
serverComponent->Test4(4,valueArray2);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
char *str = (*valueArray2)[i];
|
||||
printf("--[c++] valueArray2[%d]=%s\n",i,(str == NULL) ? "null" : str);
|
||||
}
|
||||
{
|
||||
|
||||
nsIComponentManager* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
||||
printf("--[c++] bcJavaSample before test->Test5(cm)\n");
|
||||
serverComponent->Test5(cm);
|
||||
|
||||
nsIEnumerator *enumerator;
|
||||
rv = cm->EnumerateCLSIDs(&enumerator);
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("--[c++] can get enumerator\n");
|
||||
}
|
||||
printf("--[c++] bcJavaSample after test->Test5(cm)\n");
|
||||
}
|
||||
serverComponent->Test4(4,(const char **)valueArray);
|
||||
/*******************************************/
|
||||
/*
|
||||
|
||||
char ***valueArray2 = &valueArray;
|
||||
|
||||
printf("call object\n");
|
||||
|
@ -126,6 +104,10 @@ initImpl::initImpl() {
|
|||
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);
|
||||
|
@ -146,8 +128,7 @@ initImpl::initImpl() {
|
|||
|
||||
|
||||
}
|
||||
*/
|
||||
// delete serverComponent;
|
||||
delete serverComponent;
|
||||
}
|
||||
|
||||
initImpl::~initImpl() {
|
||||
|
|
|
@ -93,8 +93,11 @@ struct sendThreadArg {
|
|||
};
|
||||
|
||||
struct monitCall {
|
||||
PRCList* stack;
|
||||
/*
|
||||
PRMonitor *mon;
|
||||
bcICall* call;
|
||||
*/
|
||||
urpPacket* mess;
|
||||
char header;
|
||||
bcIID iid;
|
||||
|
@ -102,9 +105,8 @@ struct monitCall {
|
|||
bcTID tid;
|
||||
bcMID mid;
|
||||
int request;
|
||||
monitCall(PRMonitor *m, bcICall* c, urpPacket* mes, char h) {
|
||||
this->mon = m;
|
||||
this->call = c;
|
||||
monitCall(PRCList* stack, urpPacket* mes, char h) {
|
||||
this->stack = stack;
|
||||
this->mess = mes;
|
||||
this->header = h;
|
||||
this->request = 0;
|
||||
|
@ -248,9 +250,11 @@ urpManager::ReadReply(urpPacket* message, char header,
|
|||
urpConnection* conn) {
|
||||
nsresult rv = NS_OK;
|
||||
printf("this is method readReply\n");
|
||||
urpMarshalToolkit* mt = new urpMarshalToolkit(PR_TRUE);
|
||||
rv = mt->ReadParams(paramCount, info, message, interfaceInfo, methodIndex, call, broker, this, conn);
|
||||
delete mt;
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -296,9 +300,10 @@ urpManager::ReadMessage(urpConnection* conn, PRBool isClient) {
|
|||
mc->tid = tid;
|
||||
mc->mid = methodId;
|
||||
mc->request = 1;
|
||||
PR_EnterMonitor(mc->mon);
|
||||
PR_Notify(mc->mon);
|
||||
PR_ExitMonitor(mc->mon);
|
||||
PRMonitor* mon = (PRMonitor*)PR_LIST_HEAD(mc->stack);
|
||||
PR_EnterMonitor(mon);
|
||||
PR_Notify(mon);
|
||||
PR_ExitMonitor(mon);
|
||||
} else {
|
||||
arg->man = this;
|
||||
arg->header = header;
|
||||
|
@ -358,9 +363,10 @@ urpManager::ReadMessage(urpConnection* conn, PRBool isClient) {
|
|||
ReadReply(message, header, mc->call, paramCount,
|
||||
info, interfaceInfo, mid, conn);
|
||||
*/
|
||||
PR_EnterMonitor(mc->mon);
|
||||
PR_Notify(mc->mon);
|
||||
PR_ExitMonitor(mc->mon);
|
||||
PRMonitor* mon = (PRMonitor*)PR_LIST_HEAD(mc->stack);
|
||||
PR_EnterMonitor(mon);
|
||||
PR_Notify(mon);
|
||||
PR_ExitMonitor(mon);
|
||||
}
|
||||
}
|
||||
else { // only a short request header
|
||||
|
@ -392,8 +398,8 @@ urpManager::SendReply(bcTID tid, bcICall* call, PRUint32 paramCount,
|
|||
message->WriteByte(header);
|
||||
urpMarshalToolkit* mt = new urpMarshalToolkit(PR_FALSE);
|
||||
mt->WriteThreadID(tid, message);
|
||||
rv = mt->WriteParams(call, paramCount, info, interfaceInfo, message,
|
||||
methodIndex);
|
||||
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);
|
||||
|
@ -465,16 +471,23 @@ char* name;
|
|||
rv = SendReply(tid, call, paramCount, info, interfaceInfo,
|
||||
methodId, conn);
|
||||
// delete call;
|
||||
NS_RELEASE(interfaceInfo);
|
||||
// NS_RELEASE(interfaceInfo);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
urpManager::SetCall(bcICall* call, PRMonitor *m, bcTID thrID) {
|
||||
monitCall* mc = new monitCall(m, call, nsnull, 0);
|
||||
monitCall* mc;
|
||||
// = new monitCall(m, call, nsnull, 0);
|
||||
printf("method SetCall %p %p %p %ld\n",call, m, this, thrID);
|
||||
threadHashKey thrHK(thrID);
|
||||
monitTable->Put(&thrHK, mc);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -486,8 +499,14 @@ printf("method RemoveCall\n");
|
|||
fR->mess= mc->mess;
|
||||
fR->header = mc->header;
|
||||
if(!mc->request) {
|
||||
mc = (monitCall*)monitTable->Remove(&thrHK);
|
||||
delete mc;
|
||||
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;
|
||||
|
|
|
@ -1,5 +1,27 @@
|
|||
#ifndef URP_MANGER
|
||||
#define URP_MANGER
|
||||
/* -*- 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>
|
||||
*/
|
||||
|
||||
#ifndef URP_MANAGER
|
||||
#define URP_MANAGER
|
||||
|
||||
#include "nsIInterfaceInfo.h"
|
||||
#include "xptinfo.h"
|
||||
|
|
|
@ -227,10 +227,13 @@ urpMarshalToolkit::WriteParams(bcICall *call, PRUint32 paramCount, const nsXPTMe
|
|||
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;
|
||||
}
|
||||
message->WriteInt(result);
|
||||
}
|
||||
for(i=0;i<paramCount;i++) {
|
||||
short cache_index;
|
||||
|
@ -404,6 +407,9 @@ urpMarshalToolkit::ReadParams(PRUint32 paramCount, const nsXPTMethodInfo *info,
|
|||
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++) {
|
||||
|
|
|
@ -1,3 +1,25 @@
|
|||
/* -*- 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>
|
||||
*/
|
||||
|
||||
#ifndef URP_MARSHALTOOLKIT
|
||||
#define URP_MARSHALTOOLKIT
|
||||
|
||||
|
|
|
@ -44,10 +44,6 @@ printf("destructor of urpStub\n");
|
|||
}
|
||||
|
||||
void urpStub::Dispatch(bcICall *call) {
|
||||
if (_mOwningThread == PR_CurrentThread())
|
||||
printf("RavnYYYYYYYYY\n");
|
||||
else
|
||||
printf("NEEEEE RAAAAVVVNNNYYY\n");
|
||||
|
||||
printf("this is method Dispatch of urpStub\n");
|
||||
bcIID iid; bcOID oid; bcMID mid;
|
||||
|
|
Загрузка…
Ссылка в новой задаче