2010-10-14 01:30:07 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-19 11:56:50 -05:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2006-09-16 10:03:43 -05:00
|
|
|
|
2001-03-14 02:31:19 -06:00
|
|
|
#include <osl/time.h>
|
|
|
|
|
2000-09-18 09:29:57 -05:00
|
|
|
#include <osl/mutex.hxx>
|
2001-03-16 02:42:20 -06:00
|
|
|
#include <osl/thread.hxx>
|
2000-09-18 09:29:57 -05:00
|
|
|
|
|
|
|
#include <cppuhelper/servicefactory.hxx>
|
|
|
|
|
|
|
|
#include <com/sun/star/bridge/XBridgeFactory.hpp>
|
|
|
|
#include <com/sun/star/connection/XAcceptor.hpp>
|
|
|
|
#include <com/sun/star/connection/XConnector.hpp>
|
|
|
|
|
|
|
|
#include <com/sun/star/lang/XComponent.hpp>
|
|
|
|
|
|
|
|
#include <cppuhelper/weak.hxx>
|
|
|
|
|
|
|
|
#include <test/XTestFactory.hpp>
|
|
|
|
|
|
|
|
|
|
|
|
using namespace ::test;
|
|
|
|
using namespace ::rtl;
|
|
|
|
using namespace ::cppu;
|
2001-03-16 02:42:20 -06:00
|
|
|
using namespace ::osl;
|
2000-09-18 09:29:57 -05:00
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace ::com::sun::star::bridge;
|
|
|
|
using namespace ::com::sun::star::connection;
|
|
|
|
|
|
|
|
#ifdef SAL_W32
|
|
|
|
#include <conio.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "testcomp.h"
|
|
|
|
#include "osl/mutex.h"
|
|
|
|
|
|
|
|
/*********
|
|
|
|
*
|
|
|
|
********/
|
|
|
|
|
|
|
|
class MyThread :
|
2001-03-16 02:42:20 -06:00
|
|
|
public Thread
|
2000-09-18 09:29:57 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
MyThread( const Reference< XAcceptor > &r ,
|
|
|
|
const Reference< XBridgeFactory > &rFactory,
|
|
|
|
const OUString &sConnectionDescription) :
|
|
|
|
m_rAcceptor( r ),
|
|
|
|
m_rBridgeFactory ( rFactory ),
|
|
|
|
m_sConnectionDescription( sConnectionDescription )
|
|
|
|
{}
|
|
|
|
virtual void SAL_CALL run();
|
|
|
|
|
|
|
|
private:
|
|
|
|
Reference < XAcceptor > m_rAcceptor;
|
|
|
|
Reference < XBridgeFactory > m_rBridgeFactory;
|
|
|
|
OUString m_sConnectionDescription;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MyThread::run()
|
|
|
|
{
|
|
|
|
|
2013-03-04 08:11:48 -06:00
|
|
|
while ( true )
|
2000-09-18 09:29:57 -05:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference < XConnection > rConnection =
|
|
|
|
m_rAcceptor->accept( m_sConnectionDescription );
|
|
|
|
|
|
|
|
if( ! rConnection.is() )
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
Reference < XBridge > rBridge =
|
|
|
|
m_rBridgeFactory->createBridge(
|
|
|
|
OUString() ,
|
2013-03-19 03:22:44 -05:00
|
|
|
OUString("iiop") ,
|
2000-09-18 09:29:57 -05:00
|
|
|
rConnection ,
|
|
|
|
(XInstanceProvider * ) new OInstanceProvider );
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
catch ( ... )
|
|
|
|
{
|
|
|
|
printf( "Exception was thrown by acceptor thread\n" );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-04-18 04:09:22 -05:00
|
|
|
int main( int argc, char *argv[] )
|
2000-09-18 09:29:57 -05:00
|
|
|
{
|
|
|
|
if( argc < 2 )
|
|
|
|
{
|
|
|
|
printf( "usage : testsamprocess host:port\n" );
|
2003-03-18 12:07:19 -06:00
|
|
|
return 0;
|
2000-09-18 09:29:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
Reference< XMultiServiceFactory > rSMgr = createRegistryServiceFactory(
|
2013-03-19 03:22:44 -05:00
|
|
|
OUString( "client.rdb" ) );
|
2000-09-18 09:29:57 -05:00
|
|
|
|
|
|
|
Reference < XConnector > rConnector(
|
2013-03-19 03:22:44 -05:00
|
|
|
createComponent( OUString("com.sun.star.connection.Connector"),
|
2013-03-31 13:41:33 -05:00
|
|
|
OUString( "connector.uno" SAL_DLLEXTENSION),
|
2000-09-18 09:29:57 -05:00
|
|
|
rSMgr ),
|
|
|
|
UNO_QUERY );
|
|
|
|
|
|
|
|
Reference < XAcceptor > rAcceptor(
|
2013-03-19 03:22:44 -05:00
|
|
|
createComponent( OUString("com.sun.star.connection.Acceptor"),
|
2013-03-31 13:41:33 -05:00
|
|
|
OUString( "acceptor.uno" SAL_DLLEXTENSION),
|
2000-09-18 09:29:57 -05:00
|
|
|
rSMgr ),
|
|
|
|
UNO_QUERY );
|
|
|
|
|
|
|
|
// just ensure that it is registered
|
2013-03-19 03:22:44 -05:00
|
|
|
// createComponent( OUString("com.sun.star.bridge.Bridge.iiop"),
|
2013-03-31 13:41:33 -05:00
|
|
|
// OUString( "iiopbrdg" SAL_DLLEXTENSION),
|
2003-04-23 10:45:38 -05:00
|
|
|
// rSMgr );
|
2000-09-18 09:29:57 -05:00
|
|
|
|
|
|
|
Reference < XBridgeFactory > rFactory(
|
2013-03-19 03:22:44 -05:00
|
|
|
createComponent( OUString("com.sun.star.bridge.BridgeFactory"),
|
2013-03-31 13:41:33 -05:00
|
|
|
OUString( "bridgefac.uno" SAL_DLLEXTENSION),
|
2000-09-18 09:29:57 -05:00
|
|
|
rSMgr ),
|
|
|
|
UNO_QUERY );
|
|
|
|
|
|
|
|
|
|
|
|
MyThread threadAcceptor( rAcceptor , rFactory , OUString::createFromAscii( argv[1] ) );
|
|
|
|
|
|
|
|
threadAcceptor.create();
|
|
|
|
TimeValue value={2,0};
|
|
|
|
osl_waitThread( &value );
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference < XConnection > rConnection =
|
|
|
|
rConnector->connect( OUString::createFromAscii( argv[1] ) );
|
|
|
|
|
|
|
|
printf( "%s\n" , OUStringToOString( rConnection->getDescription(),
|
|
|
|
RTL_TEXTENCODING_ASCII_US ).pData->buffer );
|
|
|
|
|
|
|
|
if( rFactory.is() )
|
|
|
|
{
|
|
|
|
|
|
|
|
Reference < XBridge > rBridge = rFactory->createBridge(
|
2013-03-19 03:22:44 -05:00
|
|
|
OUString("bla blub"),
|
|
|
|
OUString("iiop"),
|
2000-09-18 09:29:57 -05:00
|
|
|
rConnection,
|
|
|
|
Reference < XInstanceProvider > () );
|
|
|
|
|
|
|
|
Reference < XInterface > rInitialObject
|
2013-03-19 03:22:44 -05:00
|
|
|
= rBridge->getInstance( OUString("bla") );
|
2000-09-18 09:29:57 -05:00
|
|
|
|
|
|
|
if( rInitialObject.is() )
|
|
|
|
{
|
|
|
|
printf( "got the remote object\n" );
|
|
|
|
testRemote( rInitialObject );
|
|
|
|
}
|
|
|
|
printf( "Closing...\n" );
|
2008-01-29 07:41:15 -06:00
|
|
|
TimeValue timeValue={2,0};
|
|
|
|
osl_waitThread( &timeValue );
|
2000-09-18 09:29:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
Reference < XBridge > rBridge = rFactory->getBridge(
|
2013-03-19 03:22:44 -05:00
|
|
|
OUString("bla blub") );
|
2009-07-10 07:03:42 -05:00
|
|
|
OSL_ASSERT( ! rBridge.is() );
|
2000-09-18 09:29:57 -05:00
|
|
|
|
|
|
|
}
|
|
|
|
catch( Exception & )
|
|
|
|
{
|
|
|
|
printf( "Login failed, got an Exception !\n" );
|
|
|
|
}
|
|
|
|
|
|
|
|
rAcceptor->stopAccepting();
|
|
|
|
threadAcceptor.join();
|
|
|
|
|
|
|
|
Reference < XComponent > rComp( rFactory , UNO_QUERY );
|
|
|
|
rComp->dispose();
|
|
|
|
|
|
|
|
|
|
|
|
rComp = Reference < XComponent > ( rSMgr , UNO_QUERY );
|
|
|
|
rComp->dispose();
|
|
|
|
}
|
2002-04-18 04:09:22 -05:00
|
|
|
return 0;
|
2000-09-18 09:29:57 -05:00
|
|
|
}
|
2010-10-14 01:30:07 -05:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|