summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sb@openoffice.org>2002-10-04 08:41:05 +0000
committerStephan Bergmann <sb@openoffice.org>2002-10-04 08:41:05 +0000
commit762f2cf5d8c4c4db1938185a0fdff7989542db82 (patch)
tree490cf0bf7eaa08fa9ab822d6fe465341c11eda72
parent8f3c1275f5121bb469e7bef4dbe011341ec8755b (diff)
#99853# Adapted to new cppuhelper/unourl.hxx.
-rw-r--r--io/source/acceptor/acceptor.cxx239
-rw-r--r--io/source/connector/connector.cxx267
-rw-r--r--remotebridges/source/factory/bridgefactory.cxx23
-rw-r--r--remotebridges/source/unourl_resolver/unourl_resolver.cxx34
4 files changed, 188 insertions, 375 deletions
diff --git a/io/source/acceptor/acceptor.cxx b/io/source/acceptor/acceptor.cxx
index 8720a9192f2a..c67b8d9180bf 100644
--- a/io/source/acceptor/acceptor.cxx
+++ b/io/source/acceptor/acceptor.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: acceptor.cxx,v $
*
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
*
- * last change: $Author: vg $ $Date: 2002-09-05 16:08:53 $
+ * last change: $Author: sb $ $Date: 2002-10-04 09:39:17 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -65,6 +65,8 @@
#include <cppuhelper/factory.hxx>
#include <cppuhelper/implbase2.hxx>
#include <cppuhelper/implementationentry.hxx>
+#include "cppuhelper/unourl.hxx"
+#include "rtl/malformeduriexception.hxx"
#include <com/sun/star/connection/XAcceptor.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
@@ -147,74 +149,6 @@ namespace io_acceptor
g_moduleCount.modCnt.release( &g_moduleCount.modCnt );
}
- // helper class
- class TokenContainer
- {
- public:
- TokenContainer( const OUString &sString );
-
- ~TokenContainer()
- {
- delete [] m_aTokens;
- }
-
- inline OUString & getToken( sal_Int32 nElement )
- {
- return m_aTokens[nElement];
- }
-
- inline sal_Int32 getTokenCount()
- {
- return m_nTokenCount;
- }
-
- OUString *m_aTokens;
- sal_Int32 m_nTokenCount;
- };
-
- TokenContainer::TokenContainer( const OUString & sString ) :
- m_nTokenCount( 0 ),
- m_aTokens( 0 )
- {
- // split into separate tokens
- sal_Int32 i = 0,nMax;
-
- nMax = sString.getLength();
- for( i = 0 ; i < nMax ; i ++ )
- {
- if( ',' == sString.pData->buffer[i] )
- {
- m_nTokenCount ++;
- }
- }
-
- if( sString.getLength() )
- {
- m_nTokenCount ++;
- }
- if( m_nTokenCount )
- {
- m_aTokens = new OUString[m_nTokenCount];
- sal_Int32 nIndex = 0;
- for( i = 0 ; i < m_nTokenCount ; i ++ )
- {
- sal_Int32 nLastIndex = nIndex;
- nIndex = sString.indexOf( ( sal_Unicode ) ',' , nIndex );
- if( -1 == nIndex )
- {
- m_aTokens[i] = sString.copy( nLastIndex );
- break;
- }
- else
- {
- m_aTokens[i] = sString.copy( nLastIndex , nIndex-nLastIndex );
- }
- m_aTokens[i] = m_aTokens[i].trim();
- nIndex ++;
- }
- }
- }
-
struct BeingInAccept
{
BeingInAccept( sal_Bool *pFlag,const OUString & sConnectionDescription ) throw( AlreadyAcceptingException)
@@ -261,121 +195,98 @@ namespace io_acceptor
if( ! m_sLastDescription.getLength() )
{
// setup the acceptor
- TokenContainer container( sConnectionDescription );
- if( ! container.getTokenCount() )
+ try
{
- throw IllegalArgumentException(
- OUString( RTL_CONSTASCII_USTRINGPARAM( "empty connection string" ) ),
- Reference< XInterface > (),
- 0 );
- }
-
- if( 0 == container.getToken(0).compareToAscii("pipe") )
- {
- OUString sName;
- sal_Int32 i;
- for( i = 1 ; i < container.getTokenCount() ; i ++ )
+ cppu::UnoUrlDescriptor aDesc(sConnectionDescription);
+ if (aDesc.getName().equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("pipe")))
{
- sal_Int32 nIndex = container.getToken(i).indexOf( '=' );
- if( -1 != nIndex )
+ rtl::OUString aName(
+ aDesc.getParameter(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "name"))));
+
+ m_pPipe = new PipeAcceptor(aName, sConnectionDescription);
+
+ try
+ {
+ m_pPipe->init();
+ }
+ catch( ... )
{
- OUString aName = container.getToken(i).copy( 0 , nIndex ).trim().toAsciiLowerCase();
- if( nIndex < container.getToken(i).getLength() )
{
- OUString oValue = container.getToken(i).copy(
- nIndex+1 , container.getToken(i).getLength() - nIndex -1 ).trim();
- if ( 0 == aName.compareToAscii("name") )
- {
- sName = oValue;
- }
+ MutexGuard guard( m_mutex );
+ delete m_pPipe;
+ m_pPipe = 0;
}
+ throw;
}
}
- m_pPipe = new PipeAcceptor(sName , sConnectionDescription );
-
- try
- {
- m_pPipe->init();
- }
- catch( ... )
+ else if (aDesc.getName().equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("socket")))
{
+ rtl::OUString aHost;
+ if (aDesc.hasParameter(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("host"))))
+ aHost = aDesc.getParameter(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("host")));
+ else
+ aHost = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "localhost"));
+ sal_uInt16 nPort = static_cast< sal_uInt16 >(
+ aDesc.getParameter(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("port"))).
+ toInt32());
+ bool bTcpNoDelay
+ = aDesc.getParameter(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "tcpnodelay"))).toInt32() != 0;
+
+ m_pSocket = new SocketAcceptor(
+ aHost, nPort, bTcpNoDelay, sConnectionDescription);
+
+ try
{
- MutexGuard guard( m_mutex );
- delete m_pPipe;
- m_pPipe = 0;
+ m_pSocket->init();
}
- throw;
- }
- }
- else if ( 0 == container.getToken(0).compareToAscii("socket") )
- {
- OUString sHost = OUString( RTL_CONSTASCII_USTRINGPARAM("localhost"));
- sal_uInt16 nPort = 0;
- sal_Bool bTcpNoDelay = sal_False;
- sal_Int32 i;
-
- for( i = 1 ;i < container.getTokenCount() ; i ++ )
- {
- sal_Int32 nIndex = container.getToken(i).indexOf( '=' );
- if( -1 != nIndex )
+ catch( ... )
{
- OUString aName = container.getToken(i).copy( 0 , nIndex ).trim().toAsciiLowerCase();
- if( nIndex < container.getToken(i).getLength() )
{
- OUString oValue = container.getToken(i).copy( nIndex+1 , container.getToken(i).getLength() - nIndex -1 ).trim();
- if( aName.compareToAscii("host") == 0 )
- {
- sHost = oValue;
- }
- else if( aName.compareToAscii("port") == 0 )
- {
- nPort = (sal_uInt16) oValue.toInt32();
- }
- else if( aName.compareToAscii("tcpnodelay") == 0 )
- {
- bTcpNoDelay = oValue.toInt32() ? sal_True : sal_False;
- }
+ MutexGuard guard( m_mutex );
+ delete m_pSocket;
+ m_pSocket = 0;
}
+ throw;
}
}
-
- m_pSocket = new SocketAcceptor(
- sHost , nPort, bTcpNoDelay, sConnectionDescription );
-
- try
- {
- m_pSocket->init();
- }
- catch( ... )
+ else
{
- {
- MutexGuard guard( m_mutex );
- delete m_pSocket;
- m_pSocket = 0;
- }
- throw;
- }
- }
- else
- {
- OUString delegatee = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.connection.Acceptor."));
- delegatee += container.getToken(0);
+ OUString delegatee = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.connection.Acceptor."));
+ delegatee += aDesc.getName();
#ifdef DEBUG
- OString tmp = OUStringToOString(delegatee, RTL_TEXTENCODING_ASCII_US);
- OSL_TRACE("trying to get service %s\n", tmp.getStr());
+ OString tmp = OUStringToOString(delegatee, RTL_TEXTENCODING_ASCII_US);
+ OSL_TRACE("trying to get service %s\n", tmp.getStr());
#endif
- _xAcceptor = Reference<XAcceptor>(
- _xSMgr->createInstanceWithContext(delegatee, _xCtx), UNO_QUERY);
+ _xAcceptor = Reference<XAcceptor>(
+ _xSMgr->createInstanceWithContext(delegatee, _xCtx), UNO_QUERY);
- if(!_xAcceptor.is())
- {
- OUString message(RTL_CONSTASCII_USTRINGPARAM("Acceptor: unknown delegatee "));
- message += delegatee;
+ if(!_xAcceptor.is())
+ {
+ OUString message(RTL_CONSTASCII_USTRINGPARAM("Acceptor: unknown delegatee "));
+ message += delegatee;
- throw ConnectionSetupException(message, Reference<XInterface>());
+ throw ConnectionSetupException(message, Reference<XInterface>());
+ }
}
}
+ catch (rtl::MalformedUriException & rEx)
+ {
+ throw IllegalArgumentException(
+ rEx.getMessage(),
+ Reference< XInterface > (),
+ 0 );
+ }
m_sLastDescription = sConnectionDescription;
}
@@ -389,9 +300,7 @@ namespace io_acceptor
}
else
{
- sal_Int32 index = sConnectionDescription.indexOf((sal_Unicode) ',');
-
- r = _xAcceptor->accept(m_sLastDescription.copy(index + 1).trim());
+ r = _xAcceptor->accept(sConnectionDescription);
}
return r;
diff --git a/io/source/connector/connector.cxx b/io/source/connector/connector.cxx
index c3fc8c5ac7ae..9f04eff03379 100644
--- a/io/source/connector/connector.cxx
+++ b/io/source/connector/connector.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: connector.cxx,v $
*
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
*
- * last change: $Author: vg $ $Date: 2002-09-05 16:12:35 $
+ * last change: $Author: sb $ $Date: 2002-10-04 09:39:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -65,6 +65,8 @@
#include <cppuhelper/factory.hxx>
#include <cppuhelper/implbase2.hxx>
#include <cppuhelper/implementationentry.hxx>
+#include "cppuhelper/unourl.hxx"
+#include "rtl/malformeduriexception.hxx"
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/IllegalArgumentException.hpp>
@@ -123,74 +125,6 @@ namespace stoc_connector
g_moduleCount.modCnt.release( &g_moduleCount.modCnt );
}
- class TokenContainer
- {
- public:
- TokenContainer( const OUString &sString );
-
- ~TokenContainer()
- {
- delete [] m_aTokens;
- }
-
- inline OUString & getToken( sal_Int32 nElement )
- {
- return m_aTokens[nElement];
- }
-
- inline sal_Int32 getTokenCount()
- {
- return m_nTokenCount;
- }
-
- OUString *m_aTokens;
- sal_Int32 m_nTokenCount;
- };
-
- TokenContainer::TokenContainer( const OUString & sString ) :
- m_nTokenCount( 0 ),
- m_aTokens( 0 )
- {
- // split into separate tokens
- sal_Int32 i = 0,nMax;
-
- nMax = sString.getLength();
- for( i = 0 ; i < nMax ; i ++ )
- {
- if( ',' == sString.pData->buffer[i] )
- {
- m_nTokenCount ++;
- }
- }
-
- if( sString.getLength() )
- {
- m_nTokenCount ++;
- }
- if( m_nTokenCount )
- {
- m_aTokens = new OUString[m_nTokenCount];
- sal_Int32 nIndex = 0;
- for( i = 0 ; i < m_nTokenCount ; i ++ )
- {
- sal_Int32 nLastIndex = nIndex;
- nIndex = sString.indexOf( ( sal_Unicode ) ',' , nIndex );
- if( -1 == nIndex )
- {
- m_aTokens[i] = sString.copy( nLastIndex );
- break;
- }
- else
- {
- m_aTokens[i] = sString.copy( nLastIndex , nIndex-nLastIndex );
- }
- m_aTokens[i] = m_aTokens[i].trim();
- nIndex ++;
- }
- }
- }
-
-
Reference< XConnection > SAL_CALL OConnector::connect( const OUString& sConnectionDescription )
throw( NoConnectException, ConnectionSetupException, RuntimeException)
{
@@ -200,134 +134,109 @@ namespace stoc_connector
#endif
// split string into tokens
- TokenContainer container( sConnectionDescription );
-
- if( ! container.getTokenCount() )
+ try
{
- OUString message(RTL_CONSTASCII_USTRINGPARAM("Connector: empty connection string"));
- throw ConnectionSetupException( message , Reference< XInterface > () );
- }
+ cppu::UnoUrlDescriptor aDesc(sConnectionDescription);
- Reference< XConnection > r;
- if( 0 == container.getToken(0).compareToAscii( "pipe" ) )
- {
- OUString sName;
- sal_Int32 i;
- for( i = 1 ; i < container.getTokenCount() ; i ++ )
+ Reference< XConnection > r;
+ if (aDesc.getName().equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(
+ "pipe")))
{
- sal_Int32 nIndex = container.getToken(i).indexOf( '=' );
- if( -1 != nIndex )
- {
- OUString aName = container.getToken(i).copy( 0 , nIndex ).trim().toAsciiLowerCase();
- if( nIndex < container.getToken(i).getLength() )
- {
- OUString oValue = container.getToken(i).copy( nIndex+1 , container.getToken(i).getLength() - nIndex -1 ).trim();
- if ( aName.compareToAscii("name") == 0 )
- {
- sName = oValue;
- }
- }
- }
- }
+ rtl::OUString aName(
+ aDesc.getParameter(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("name"))));
- PipeConnection *pConn = new PipeConnection(sName , sConnectionDescription );
-
- ;
- if( pConn->m_pipe.create( sName.pData, osl_Pipe_OPEN ) )
- {
- r = Reference < XConnection > ( (XConnection * ) pConn );
- }
- else
- {
- OUString sMessage = OUString::createFromAscii( "Connector : couldn't connect to pipe " );
- sMessage += sName;
- sMessage += OUString::createFromAscii( "(" );
- sMessage += OUString::valueOf( (sal_Int32 ) pConn->m_pipe.getError() );
- sMessage += OUString::createFromAscii( ")" );
- delete pConn;
- throw NoConnectException( sMessage ,Reference< XInterface > () );
- }
- }
- else if( 0 == container.getToken(0).compareToAscii("socket") )
- {
- OUString sHost;
- sal_uInt16 nPort = 0;
- sal_Bool bTcpNoDelay = sal_False;
+ PipeConnection *pConn = new PipeConnection( aName, sConnectionDescription );
- int i;
- for( i = 1 ; i < container.getTokenCount() ; i ++ )
- {
- sal_Int32 nIndex = container.getToken(i).indexOf( '=' );
- if( -1 != nIndex )
+ if( pConn->m_pipe.create( aName.pData, osl_Pipe_OPEN ) )
{
- OUString aName = container.getToken(i).copy( 0 , nIndex ).trim().toAsciiLowerCase();
- if( nIndex < container.getToken(i).getLength() )
- {
- OUString oValue = container.getToken(i).copy( nIndex+1 , container.getToken(i).getLength() - nIndex -1 ).trim();
- if( 0 == aName.compareToAscii( "host") )
- {
- sHost = oValue;
- }
- else if( 0 == aName.compareToAscii("port") )
- {
- nPort = ( sal_uInt16 ) oValue.toInt32();
- }
- else if( aName.compareToAscii("tcpnodelay") == 0 )
- {
- bTcpNoDelay = oValue.toInt32() ? sal_True : sal_False;
- }
- }
+ r = Reference < XConnection > ( (XConnection * ) pConn );
+ }
+ else
+ {
+ OUString sMessage = OUString::createFromAscii( "Connector : couldn't connect to pipe " );
+ sMessage += aName;
+ sMessage += OUString::createFromAscii( "(" );
+ sMessage += OUString::valueOf( (sal_Int32 ) pConn->m_pipe.getError() );
+ sMessage += OUString::createFromAscii( ")" );
+ delete pConn;
+ throw NoConnectException( sMessage ,Reference< XInterface > () );
}
}
-
- SocketConnection *pConn = new SocketConnection( sHost,
- nPort,
- sConnectionDescription);
-
- SocketAddr AddrTarget( sHost.pData, nPort );
- if(pConn->m_socket.connect(AddrTarget) != osl_Socket_Ok)
+ else if (aDesc.getName().equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(
+ "socket")))
{
- OUString sMessage = OUString::createFromAscii( "Connector : couldn't connect to socket (" );
- OUString sError = pConn->m_socket.getErrorAsString();
- sMessage += sError;
- sMessage += OUString::createFromAscii( ")" );
- delete pConn;
- throw NoConnectException( sMessage, Reference < XInterface > () );
+ rtl::OUString aHost;
+ if (aDesc.hasParameter(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("host"))))
+ aHost = aDesc.getParameter(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("host")));
+ else
+ aHost = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "localhost"));
+ sal_uInt16 nPort = static_cast< sal_uInt16 >(
+ aDesc.getParameter(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("port"))).
+ toInt32());
+ bool bTcpNoDelay
+ = aDesc.getParameter(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "tcpnodelay"))).toInt32() != 0;
+
+ SocketConnection *pConn = new SocketConnection( aHost,
+ nPort,
+ sConnectionDescription);
+
+ SocketAddr AddrTarget( aHost.pData, nPort );
+ if(pConn->m_socket.connect(AddrTarget) != osl_Socket_Ok)
+ {
+ OUString sMessage = OUString::createFromAscii( "Connector : couldn't connect to socket (" );
+ OUString sError = pConn->m_socket.getErrorAsString();
+ sMessage += sError;
+ sMessage += OUString::createFromAscii( ")" );
+ delete pConn;
+ throw NoConnectException( sMessage, Reference < XInterface > () );
+ }
+ if( bTcpNoDelay )
+ {
+ sal_Int32 nTcpNoDelay = sal_True;
+ pConn->m_socket.setOption( osl_Socket_OptionTcpNoDelay , &nTcpNoDelay,
+ sizeof( nTcpNoDelay ) , osl_Socket_LevelTcp );
+ }
+ pConn->completeConnectionString();
+ r = Reference< XConnection > ( (XConnection * ) pConn );
}
- if( bTcpNoDelay )
+ else
{
- sal_Int32 nTcpNoDelay = sal_True;
- pConn->m_socket.setOption( osl_Socket_OptionTcpNoDelay , &nTcpNoDelay,
- sizeof( nTcpNoDelay ) , osl_Socket_LevelTcp );
- }
- pConn->completeConnectionString();
- r = Reference< XConnection > ( (XConnection * ) pConn );
- }
- else
- {
- OUString delegatee = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.connection.Connector."));
- delegatee += container.getToken(0);
+ OUString delegatee = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.connection.Connector."));
+ delegatee += aDesc.getName();
#ifdef DEBUG
- OString tmp = OUStringToOString(delegatee, RTL_TEXTENCODING_ASCII_US);
- OSL_TRACE("connector: trying to get service %s\n", tmp.getStr());
+ OString tmp = OUStringToOString(delegatee, RTL_TEXTENCODING_ASCII_US);
+ OSL_TRACE("connector: trying to get service %s\n", tmp.getStr());
#endif
- Reference<XConnector> xConnector(
- _xSMgr->createInstanceWithContext(delegatee, _xCtx), UNO_QUERY );
+ Reference<XConnector> xConnector(
+ _xSMgr->createInstanceWithContext(delegatee, _xCtx), UNO_QUERY );
- if(!xConnector.is())
- {
- OUString message(RTL_CONSTASCII_USTRINGPARAM("Connector: unknown delegatee "));
- message += delegatee;
+ if(!xConnector.is())
+ {
+ OUString message(RTL_CONSTASCII_USTRINGPARAM("Connector: unknown delegatee "));
+ message += delegatee;
- throw ConnectionSetupException(message, Reference<XInterface>());
- }
+ throw ConnectionSetupException(message, Reference<XInterface>());
+ }
- sal_Int32 index = sConnectionDescription.indexOf((sal_Unicode) ',');
+ sal_Int32 index = sConnectionDescription.indexOf((sal_Unicode) ',');
- r = xConnector->connect(sConnectionDescription.copy(index + 1).trim());
+ r = xConnector->connect(sConnectionDescription.copy(index + 1).trim());
+ }
+ return r;
+ }
+ catch (rtl::MalformedUriException & rEx)
+ {
+ throw ConnectionSetupException(rEx.getMessage(),
+ Reference< XInterface > ());
}
- return r;
}
Sequence< OUString > connector_getSupportedServiceNames()
diff --git a/remotebridges/source/factory/bridgefactory.cxx b/remotebridges/source/factory/bridgefactory.cxx
index e0659aa2da16..ac02c6c74f6a 100644
--- a/remotebridges/source/factory/bridgefactory.cxx
+++ b/remotebridges/source/factory/bridgefactory.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: bridgefactory.cxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: hr $ $Date: 2001-09-11 13:51:37 $
+ * last change: $Author: sb $ $Date: 2002-10-04 09:40:28 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -70,6 +70,8 @@
#include <cppuhelper/implementationentry.hxx>
#include <cppuhelper/component.hxx>
#include <cppuhelper/typeprovider.hxx>
+#include "cppuhelper/unourl.hxx"
+#include "rtl/malformeduriexception.hxx"
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
@@ -253,11 +255,14 @@ namespace remotebridges_factory
{
init();
OUString sService;
- OUString sProtocolName = sProtocol.toAsciiLowerCase();
- sal_Int32 nIndex = sProtocol.indexOf( (sal_Unicode)',' );
- if( nIndex > 0 )
+ OUString sProtocolName;
+ try
{
- sProtocolName = sProtocol.copy( 0 , nIndex );
+ sProtocolName = cppu::UnoUrlDescriptor(sProtocol).getName();
+ }
+ catch (rtl::MalformedUriException &)
+ {
+ OSL_ENSURE(false, "MalformedUriException");
}
ServiceHashMap::iterator ii = m_mapProtocolToService.find( sProtocolName );
if( ii != m_mapProtocolToService.end() )
@@ -268,12 +273,6 @@ namespace remotebridges_factory
{
// fallback to the old solution, deprecated, should be removed !
OUString sService = OUString::createFromAscii( "com.sun.star.bridge.Bridge." );
- OUString sProtocolName = sProtocol;
- sal_Int32 nIndex = sProtocol.indexOf( (sal_Unicode)',' );
- if( nIndex > 0 )
- {
- sProtocolName = sProtocol.copy( 0 , nIndex );
- }
sService += sProtocolName;
}
return sService;
diff --git a/remotebridges/source/unourl_resolver/unourl_resolver.cxx b/remotebridges/source/unourl_resolver/unourl_resolver.cxx
index 39f2c295b38c..96570bda0692 100644
--- a/remotebridges/source/unourl_resolver/unourl_resolver.cxx
+++ b/remotebridges/source/unourl_resolver/unourl_resolver.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: unourl_resolver.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: jbu $ $Date: 2001-06-22 16:39:16 $
+ * last change: $Author: sb $ $Date: 2002-10-04 09:41:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -67,6 +67,8 @@
#include <cppuhelper/factory.hxx>
#include <cppuhelper/implbase2.hxx>
#include <cppuhelper/implementationentry.hxx>
+#include "cppuhelper/unourl.hxx"
+#include "rtl/malformeduriexception.hxx"
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XComponent.hpp>
@@ -190,19 +192,19 @@ Sequence< OUString > ResolverImpl::getSupportedServiceNames()
Reference< XInterface > ResolverImpl::resolve( const OUString & rUnoUrl )
throw (NoConnectException, ConnectionSetupException, RuntimeException)
{
- sal_Int32 nTokenCount = 0;
- sal_Int32 nIndex = 0;
- do
+ OUString aProtocolDescr;
+ OUString aConnectDescr;
+ OUString aInstanceName;
+ try
{
- rUnoUrl.getToken( 0 , ';' , nIndex );
- nTokenCount++;
+ cppu::UnoUrl aUrl(rUnoUrl);
+ aProtocolDescr = aUrl.getProtocol().getDescriptor();
+ aConnectDescr = aUrl.getConnection().getDescriptor();
+ aInstanceName = aUrl.getObjectName();
}
- while ( nIndex >= 0 );
-
- if (nTokenCount != 3 || rUnoUrl.getLength() < 10 ||
- !rUnoUrl.copy( 0, 4 ).equalsIgnoreAsciiCase( OUString( RTL_CONSTASCII_USTRINGPARAM("uno:") ) ))
+ catch (rtl::MalformedUriException & rEx)
{
- throw ConnectionSetupException( OUString( RTL_CONSTASCII_USTRINGPARAM("illegal uno url given!" ) ), Reference< XInterface >() );
+ throw ConnectionSetupException(rEx.getMessage(), 0);
}
Reference< XConnector > xConnector(
@@ -214,11 +216,6 @@ Reference< XInterface > ResolverImpl::resolve( const OUString & rUnoUrl )
if (! xConnector.is())
throw RuntimeException( OUString( RTL_CONSTASCII_USTRINGPARAM("no connector!" ) ), Reference< XInterface >() );
- nIndex = 0;
- OUString aConnectDescr( rUnoUrl.getToken( 0, ';', nIndex ).copy( 4 ) ); // uno:CONNECTDESCR;iiop;InstanceName
- nIndex = 0;
- OUString aInstanceName( rUnoUrl.getToken( 2, ';', nIndex ) );
-
Reference< XConnection > xConnection( xConnector->connect( aConnectDescr ) );
// As soon as singletons are ready, switch to singleton !
@@ -232,9 +229,8 @@ Reference< XInterface > ResolverImpl::resolve( const OUString & rUnoUrl )
throw RuntimeException( OUString( RTL_CONSTASCII_USTRINGPARAM("no bridge factory!" ) ), Reference< XInterface >() );
// bridge
- nIndex = 0;
Reference< XBridge > xBridge( xBridgeFactory->createBridge(
- OUString(), rUnoUrl.getToken( 1, ';', nIndex ),
+ OUString(), aProtocolDescr,
xConnection, Reference< XInstanceProvider >() ) );
Reference< XInterface > xRet( xBridge->getInstance( aInstanceName ) );