20#include <osl/security.hxx>
22#include <com/sun/star/connection/XConnection.hpp>
23#include <com/sun/star/connection/ConnectionSetupException.hpp>
24#include <com/sun/star/io/IOException.hpp>
26#include <osl/diagnose.h>
32using namespace ::
cppu;
43 class PipeConnection :
44 public WeakImplHelper< XConnection >
47 explicit PipeConnection( OUString sConnectionDescription);
49 virtual sal_Int32 SAL_CALL read(
Sequence< sal_Int8 >& aReadBytes, sal_Int32 nBytesToRead )
override;
51 virtual void SAL_CALL flush( )
override;
52 virtual void SAL_CALL
close( )
override;
53 virtual OUString SAL_CALL getDescription( )
override;
62 PipeConnection::PipeConnection( OUString sConnectionDescription) :
69 sal::static_int_cast<sal_Int64 >(
70 reinterpret_cast< sal_IntPtr
>(&
m_pipe)) );
79 if( aReadBytes.getLength() < nBytesToRead )
81 aReadBytes.realloc( nBytesToRead );
83 sal_Int32
n =
m_pipe.read( aReadBytes.getArray(), nBytesToRead );
84 OSL_ASSERT(
n >= 0 &&
n <= aReadBytes.getLength() );
85 if(
n < aReadBytes.getLength() )
87 aReadBytes.realloc(
n );
99 if(
m_pipe.write( seq.getConstArray() , seq.getLength() ) != seq.getLength() )
111 if( 1 == osl_atomic_increment( (&
m_nStatus) ) )
125 PipeAcceptor::PipeAcceptor( OUString sPipeName , OUString sConnectionDescription) :
126 m_sPipeName(
std::move( sPipeName )),
127 m_sConnectionDescription(
std::move( sConnectionDescription )),
138 OUString error =
"io.acceptor: Couldn't setup pipe " +
m_sPipeName;
139 throw ConnectionSetupException( error );
147 std::unique_lock guard(
m_mutex );
152 OUString error =
"io.acceptor: pipe already closed" +
m_sPipeName;
153 throw ConnectionSetupException( error );
157 oslPipeError status = pipe.accept( pConn->m_pipe );
162 return Reference < XConnection >();
164 else if( osl_Pipe_E_None == status )
170 OUString error =
"io.acceptor: Couldn't setup pipe " +
m_sPipeName;
171 throw ConnectionSetupException( error );
180 std::unique_lock guard(
m_mutex );
oslInterlockedCount m_nStatus
css::uno::Reference< css::connection::XConnection > accept()
OUString m_sConnectionDescription
virtual void SAL_CALL close() override
virtual OUString SAL_CALL getDescription() override
virtual void SAL_CALL flush() override
virtual sal_Int32 SAL_CALL read(css::uno::Sequence< sal_Int8 > &aReadBytes, sal_Int32 nBytesToRead) override
oslInterlockedCount m_nStatus
virtual void SAL_CALL write(const css::uno::Sequence< sal_Int8 > &aData) override
constexpr OUStringLiteral aData