From 065b374d695f5208c6dcdad8ead3f1ff6223036f Mon Sep 17 00:00:00 2001 From: Vladimir Glazounov Date: Wed, 14 May 2008 13:49:20 +0000 Subject: INTEGRATION: CWS ucpgio1 (1.1.2); FILE ADDED 2008/04/30 16:35:19 cmc 1.1.2.1: #i88090# add gio content provider --- ucb/source/ucp/gio/gio_mount.hxx | 75 ++++++++++++++ ucb/source/ucp/gio/gio_outputstream.cxx | 95 +++++++++++++++++ ucb/source/ucp/gio/gio_outputstream.hxx | 85 +++++++++++++++ ucb/source/ucp/gio/gio_provider.cxx | 176 ++++++++++++++++++++++++++++++++ ucb/source/ucp/gio/gio_provider.hxx | 69 +++++++++++++ ucb/source/ucp/gio/gio_resultset.cxx | 62 +++++++++++ ucb/source/ucp/gio/gio_resultset.hxx | 59 +++++++++++ ucb/source/ucp/gio/gio_seekable.cxx | 132 ++++++++++++++++++++++++ ucb/source/ucp/gio/gio_seekable.hxx | 83 +++++++++++++++ ucb/source/ucp/gio/ucpgio-ucd.txt | 6 ++ 10 files changed, 842 insertions(+) create mode 100644 ucb/source/ucp/gio/gio_mount.hxx create mode 100644 ucb/source/ucp/gio/gio_outputstream.cxx create mode 100644 ucb/source/ucp/gio/gio_outputstream.hxx create mode 100644 ucb/source/ucp/gio/gio_provider.cxx create mode 100644 ucb/source/ucp/gio/gio_provider.hxx create mode 100644 ucb/source/ucp/gio/gio_resultset.cxx create mode 100644 ucb/source/ucp/gio/gio_resultset.hxx create mode 100644 ucb/source/ucp/gio/gio_seekable.cxx create mode 100644 ucb/source/ucp/gio/gio_seekable.hxx create mode 100644 ucb/source/ucp/gio/ucpgio-ucd.txt (limited to 'ucb/source') diff --git a/ucb/source/ucp/gio/gio_mount.hxx b/ucb/source/ucp/gio/gio_mount.hxx new file mode 100644 index 000000000000..d6e57e89fc60 --- /dev/null +++ b/ucb/source/ucp/gio/gio_mount.hxx @@ -0,0 +1,75 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: gio_mount.hxx,v $ + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef GIO_MOUNT_HXX +#define GIO_MOUNT_HXX + +#include +#include + +G_BEGIN_DECLS + +#define OOO_TYPE_MOUNT_OPERATION (ooo_mount_operation_get_type ()) +#define OOO_MOUNT_OPERATION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), OOO_TYPE_MOUNT_OPERATION, OOoMountOperation)) +#define OOO_MOUNT_OPERATION_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), OOO_TYPE_MOUNT_OPERATION, OOoMountOperationClass)) +#define OOO_IS_MOUNT_OPERATION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), OOO_TYPE_MOUNT_OPERATION)) +#define OOO_IS_MOUNT_OPERATION_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), OOO_TYPE_MOUNT_OPERATION)) +#define OOO_MOUNT_OPERATION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), OOO_TYPE_MOUNT_OPERATION, OOoMountOperationClass)) + +typedef struct OOoMountOperation OOoMountOperation; +typedef struct OOoMountOperationClass OOoMountOperationClass; +typedef struct OOoMountOperationPrivate OOoMountOperationPrivate; + +struct OOoMountOperation +{ + GMountOperation parent_instance; + + const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > *pEnv; + char *m_pPrevUsername; + char *m_pPrevPassword; +}; + +struct OOoMountOperationClass +{ + GMountOperationClass parent_class; + + /* Padding for future expansion */ + void (*_gtk_reserved1) (void); + void (*_gtk_reserved2) (void); + void (*_gtk_reserved3) (void); + void (*_gtk_reserved4) (void); +}; + + +GType ooo_mount_operation_get_type (void); +GMountOperation *ooo_mount_operation_new(const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& rEnv); + +G_END_DECLS +#endif diff --git a/ucb/source/ucp/gio/gio_outputstream.cxx b/ucb/source/ucp/gio/gio_outputstream.cxx new file mode 100644 index 000000000000..05f9bfbdb176 --- /dev/null +++ b/ucb/source/ucp/gio/gio_outputstream.cxx @@ -0,0 +1,95 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: gio_outputstream.cxx,v $ + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include +#include +#include +#include + +#include "gio_outputstream.hxx" +#include "gio_content.hxx" + +using namespace com::sun::star; + +namespace gio +{ + +OutputStream::OutputStream(GFileOutputStream *pStream) : Seekable(G_SEEKABLE(pStream)), mpStream(pStream) +{ + if (!mpStream) + throw io::NotConnectedException(); +} + +OutputStream::~OutputStream( void ) +{ + closeOutput(); +} + +void SAL_CALL OutputStream::writeBytes( const com::sun::star::uno::Sequence< sal_Int8 >& rData ) + throw( io::NotConnectedException, io::BufferSizeExceededException, + io::IOException, uno::RuntimeException) +{ + if (!mpStream) + throw io::NotConnectedException(); + + GError *pError=NULL; + if (!g_output_stream_write_all(G_OUTPUT_STREAM(mpStream), rData.getConstArray(), rData.getLength(), NULL, NULL, &pError)) + convertToException(pError, static_cast< cppu::OWeakObject * >(this)); +} + +void SAL_CALL OutputStream::flush( void ) + throw( io::NotConnectedException, io::BufferSizeExceededException, + io::IOException, uno::RuntimeException ) +{ + if (!mpStream) + throw io::NotConnectedException(); + + GError *pError=NULL; + if (!g_output_stream_flush(G_OUTPUT_STREAM(mpStream), NULL, &pError)) + convertToException(pError, static_cast< cppu::OWeakObject * >(this)); +} + +void SAL_CALL OutputStream::closeOutput( void ) + throw( io::NotConnectedException, io::IOException, + uno::RuntimeException ) +{ + if (mpStream) + g_output_stream_close(G_OUTPUT_STREAM(mpStream), NULL, NULL); +} + +uno::Any OutputStream::queryInterface( const uno::Type &type ) throw( uno::RuntimeException ) +{ + uno::Any aRet = ::cppu::queryInterface ( type, + static_cast< XOutputStream * >( this ) ); + + return aRet.hasValue() ? aRet : Seekable::queryInterface( type ); +} + +} diff --git a/ucb/source/ucp/gio/gio_outputstream.hxx b/ucb/source/ucp/gio/gio_outputstream.hxx new file mode 100644 index 000000000000..20a036249b36 --- /dev/null +++ b/ucb/source/ucp/gio/gio_outputstream.hxx @@ -0,0 +1,85 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: gio_outputstream.hxx,v $ + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef GIO_OUTPUTSTREAM_HXX +#define GIO_OUTPUTSTREAM_HXX + +#include +#include +#include + +#include +#include +#include + +#include "gio_seekable.hxx" + +namespace gio +{ + +class OutputStream : + public ::com::sun::star::io::XOutputStream, + public Seekable +{ +private: + GFileOutputStream *mpStream; + +public: + OutputStream ( GFileOutputStream *pStream ); + virtual ~OutputStream(); + + // XInterface + virtual com::sun::star::uno::Any SAL_CALL queryInterface(const ::com::sun::star::uno::Type & type ) + throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL acquire( void ) throw () { OWeakObject::acquire(); } + virtual void SAL_CALL release( void ) throw() { OWeakObject::release(); } + + // XOutputStream + virtual void SAL_CALL writeBytes( const com::sun::star::uno::Sequence< sal_Int8 >& aData ) + throw( com::sun::star::io::NotConnectedException, + com::sun::star::io::BufferSizeExceededException, + com::sun::star::io::IOException, + com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL flush( void ) + throw( com::sun::star::io::NotConnectedException, + com::sun::star::io::BufferSizeExceededException, + com::sun::star::io::IOException, + com::sun::star::uno::RuntimeException); + + + virtual void SAL_CALL closeOutput( void ) + throw( com::sun::star::io::NotConnectedException, + com::sun::star::io::IOException, + com::sun::star::uno::RuntimeException ); +}; + +} // namespace gio +#endif diff --git a/ucb/source/ucp/gio/gio_provider.cxx b/ucb/source/ucp/gio/gio_provider.cxx new file mode 100644 index 000000000000..77718a82da9b --- /dev/null +++ b/ucb/source/ucp/gio/gio_provider.cxx @@ -0,0 +1,176 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: gio_provider.cxx,v $ + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include +#include +#include +#include "gio_provider.hxx" +#include "gio_content.hxx" + +#include + +using namespace com::sun::star; + +namespace gio +{ +uno::Reference< com::sun::star::ucb::XContent > SAL_CALL +ContentProvider::queryContent( + const uno::Reference< + com::sun::star::ucb::XContentIdentifier >& Identifier ) + throw( com::sun::star::ucb::IllegalIdentifierException, + uno::RuntimeException ) +{ +#ifdef DEBUG + fprintf(stderr, "QueryContent: '%s'", + (const sal_Char *)rtl::OUStringToOString + (Identifier->getContentIdentifier(), RTL_TEXTENCODING_UTF8)); +#endif + + osl::MutexGuard aGuard( m_aMutex ); + + // Check, if a content with given id already exists... + uno::Reference< ucb::XContent > xContent = queryExistingContent( Identifier ).get(); + if ( xContent.is() ) + return xContent; + + try + { + xContent = new ::gio::Content(m_xSMgr, this, Identifier); + } + catch ( com::sun::star::ucb::ContentCreationException const & ) + { + throw com::sun::star::ucb::IllegalIdentifierException(); + } + + if ( !xContent->getIdentifier().is() ) + throw com::sun::star::ucb::IllegalIdentifierException(); + + return xContent; +} + +ContentProvider::ContentProvider( + const uno::Reference< lang::XMultiServiceFactory >& rSMgr ) +: ::ucbhelper::ContentProviderImplHelper( rSMgr ) +{ +} + +ContentProvider::~ContentProvider() +{ +} + +XINTERFACE_IMPL_3( ContentProvider, + lang::XTypeProvider, + lang::XServiceInfo, + com::sun::star::ucb::XContentProvider ); + +XTYPEPROVIDER_IMPL_3( ContentProvider, + lang::XTypeProvider, + lang::XServiceInfo, + com::sun::star::ucb::XContentProvider ); + +XSERVICEINFO_IMPL_1( ContentProvider, + rtl::OUString::createFromAscii( + "com.sun.star.comp.GIOContentProvider" ), + rtl::OUString::createFromAscii( + "com.sun.star.ucb.GIOContentProvider" ) ); + +ONE_INSTANCE_SERVICE_FACTORY_IMPL( ContentProvider ); + +} + +static sal_Bool writeInfo( void *pRegistryKey, + const rtl::OUString &rImplementationName, uno::Sequence< rtl::OUString > const &rServiceNames ) +{ + rtl::OUString aKeyName( rtl::OUString::createFromAscii( "/" ) ); + aKeyName += rImplementationName; + aKeyName += rtl::OUString::createFromAscii( "/UNO/SERVICES" ); + + uno::Reference< registry::XRegistryKey > xKey; + try + { + xKey = static_cast< registry::XRegistryKey * > (pRegistryKey )->createKey( aKeyName ); + } + catch ( registry::InvalidRegistryException const & ) + {} + + if ( !xKey.is() ) + return sal_False; + + sal_Bool bSuccess = sal_True; + + for ( sal_Int32 n = 0; n < rServiceNames.getLength(); ++n ) + { + try + { + xKey->createKey( rServiceNames[ n ] ); + } + catch ( registry::InvalidRegistryException const & ) + { + bSuccess = sal_False; + break; + } + } + return bSuccess; +} + +extern "C" void SAL_CALL component_getImplementationEnvironment( + const sal_Char **ppEnvTypeName, uno_Environment **) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + +extern "C" sal_Bool SAL_CALL component_writeInfo( void *, void *pRegistryKey ) +{ + return pRegistryKey && + writeInfo( pRegistryKey, + ::gio::ContentProvider::getImplementationName_Static(), + ::gio::ContentProvider::getSupportedServiceNames_Static() ); +} + +extern "C" void * SAL_CALL component_getFactory( const sal_Char *pImplName, + void *pServiceManager, void * ) +{ + void * pRet = 0; + + uno::Reference< lang::XMultiServiceFactory > xSMgr + (reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ) ); + uno::Reference< lang::XSingleServiceFactory > xFactory; + + if ( !::gio::ContentProvider::getImplementationName_Static().compareToAscii( pImplName ) ) + xFactory = ::gio::ContentProvider::createServiceFactory( xSMgr ); + + if ( xFactory.is() ) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + + return pRet; +} diff --git a/ucb/source/ucp/gio/gio_provider.hxx b/ucb/source/ucp/gio/gio_provider.hxx new file mode 100644 index 000000000000..95b928d9c100 --- /dev/null +++ b/ucb/source/ucp/gio/gio_provider.hxx @@ -0,0 +1,69 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: gio_provider.hxx,v $ + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef GIO_PROVIDER_HXX +#define GIO_PROVIDER_HXX + +#include +#include + +#define GIO_CONTENT_PROVIDER_SERVICE_NAME "com.sun.star.ucb.GIOContentProvider" + +namespace gio +{ + +class ContentProvider : public ::ucbhelper::ContentProviderImplHelper +{ +public: + ContentProvider( const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XMultiServiceFactory >& rSMgr ); + virtual ~ContentProvider(); + + // XInterface + XINTERFACE_DECL() + + // XTypeProvider + XTYPEPROVIDER_DECL() + + // XServiceInfo + XSERVICEINFO_DECL() + + // XContentProvider + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::ucb::XContent > SAL_CALL + queryContent( const ::com::sun::star::uno::Reference< + ::com::sun::star::ucb::XContentIdentifier >& Identifier ) + throw( ::com::sun::star::ucb::IllegalIdentifierException, + ::com::sun::star::uno::RuntimeException ); +}; + +} + +#endif diff --git a/ucb/source/ucp/gio/gio_resultset.cxx b/ucb/source/ucp/gio/gio_resultset.cxx new file mode 100644 index 000000000000..4934b6ee54a5 --- /dev/null +++ b/ucb/source/ucp/gio/gio_resultset.cxx @@ -0,0 +1,62 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: gio_resultset.cxx,v $ + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "gio_datasupplier.hxx" +#include "gio_resultset.hxx" + +using namespace com::sun::star::lang; +using namespace com::sun::star::ucb; +using namespace com::sun::star::uno; + +using namespace gio; + +DynamicResultSet::DynamicResultSet( + const Reference< XMultiServiceFactory >& rxSMgr, + const Reference< Content >& rxContent, + const OpenCommandArgument2& rCommand, + const Reference< XCommandEnvironment >& rxEnv ) + : ResultSetImplHelper( rxSMgr, rCommand ), + m_xContent( rxContent ), + m_xEnv( rxEnv ) +{ +} + +void DynamicResultSet::initStatic() +{ + m_xResultSet1 = new ::ucbhelper::ResultSet( + m_xSMgr, m_aCommand.Properties, + new DataSupplier( m_xSMgr, m_xContent, m_aCommand.Mode ), m_xEnv ); +} + +void DynamicResultSet::initDynamic() +{ + initStatic(); + m_xResultSet2 = m_xResultSet1; +} diff --git a/ucb/source/ucp/gio/gio_resultset.hxx b/ucb/source/ucp/gio/gio_resultset.hxx new file mode 100644 index 000000000000..d5a24e9b864f --- /dev/null +++ b/ucb/source/ucp/gio/gio_resultset.hxx @@ -0,0 +1,59 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: gio_resultset.hxx,v $ + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef GIO_RESULTSET_HXX +#define GIO_RESULTSET_HXX + +#include +#include "gio_content.hxx" + +namespace gio +{ + + class DynamicResultSet : public ::ucbhelper::ResultSetImplHelper + { + com::sun::star::uno::Reference< Content > m_xContent; + com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > m_xEnv; + + private: + virtual void initStatic(); + virtual void initDynamic(); + + public: + DynamicResultSet( + const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rxSMgr, + const com::sun::star::uno::Reference< Content >& rxContent, + const com::sun::star::ucb::OpenCommandArgument2& rCommand, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment >& rxEnv ); + }; +} + +#endif diff --git a/ucb/source/ucp/gio/gio_seekable.cxx b/ucb/source/ucp/gio/gio_seekable.cxx new file mode 100644 index 000000000000..ae5c6dd9121d --- /dev/null +++ b/ucb/source/ucp/gio/gio_seekable.cxx @@ -0,0 +1,132 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: gio_seekable.cxx,v $ + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include +#include +#include +#include + +#include "gio_seekable.hxx" +#include "gio_content.hxx" + +using namespace com::sun::star; + +namespace gio +{ + +Seekable::Seekable(GSeekable *pStream) : mpStream(pStream) +{ + if (!mpStream) + throw io::NotConnectedException(); +} + +Seekable::~Seekable( void ) +{ +} + +void SAL_CALL Seekable::truncate( void ) + throw( io::IOException, uno::RuntimeException ) +{ + if (!mpStream) + throw io::NotConnectedException(); + + if (!g_seekable_can_truncate(mpStream)) + throw io::IOException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Truncate unsupported")), + static_cast< cppu::OWeakObject * >(this)); + + GError *pError=NULL; + if (!g_seekable_truncate(mpStream, 0, NULL, &pError)) + convertToException(pError, static_cast< cppu::OWeakObject * >(this)); +} + +void SAL_CALL Seekable::seek( sal_Int64 location ) + throw( lang::IllegalArgumentException, io::IOException, uno::RuntimeException ) +{ + if (!mpStream) + throw io::NotConnectedException(); + + if (!g_seekable_can_seek(mpStream)) + throw io::IOException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Seek unsupported")), + static_cast< cppu::OWeakObject * >(this)); + + GError *pError=NULL; + if (!g_seekable_seek(mpStream, location, G_SEEK_SET, NULL, &pError)) + convertToException(pError, static_cast< cppu::OWeakObject * >(this)); +} + +sal_Int64 SAL_CALL Seekable::getPosition() throw( io::IOException, uno::RuntimeException ) +{ + if (!mpStream) + throw io::NotConnectedException(); + + return g_seekable_tell(mpStream); +} + +sal_Int64 SAL_CALL Seekable::getLength() throw( io::IOException, uno::RuntimeException ) +{ + if (!mpStream) + throw io::NotConnectedException(); + + GFileInfo* pInfo = G_IS_FILE_INPUT_STREAM(mpStream) + ? g_file_input_stream_query_info(G_FILE_INPUT_STREAM(mpStream), const_cast(G_FILE_ATTRIBUTE_STANDARD_SIZE), NULL, NULL) + : g_file_output_stream_query_info(G_FILE_OUTPUT_STREAM(mpStream), const_cast(G_FILE_ATTRIBUTE_STANDARD_SIZE), NULL, NULL); + + if (!pInfo) + throw io::IOException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Getting attributes unsupported")), + static_cast< cppu::OWeakObject * >(this)); + + bool bOk = true; + sal_uInt64 nSize = 0; + if (g_file_info_has_attribute(pInfo, G_FILE_ATTRIBUTE_STANDARD_SIZE)) + nSize = g_file_info_get_size(pInfo); + else + bOk = false; + + g_object_unref(pInfo); + + if (!bOk) + throw io::IOException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Getting size unsupported")), + static_cast< cppu::OWeakObject * >(this)); + + return nSize; +} + +uno::Any Seekable::queryInterface( const uno::Type &type ) throw( uno::RuntimeException ) +{ + uno::Any aRet = ::cppu::queryInterface ( type, + static_cast< XSeekable * >( this ) ); + + if (!aRet.hasValue() && g_seekable_can_truncate(mpStream)) + aRet = ::cppu::queryInterface ( type, static_cast< XTruncate * >( this ) ); + + return aRet.hasValue() ? aRet : OWeakObject::queryInterface( type ); +} + +} diff --git a/ucb/source/ucp/gio/gio_seekable.hxx b/ucb/source/ucp/gio/gio_seekable.hxx new file mode 100644 index 000000000000..e32ad844402e --- /dev/null +++ b/ucb/source/ucp/gio/gio_seekable.hxx @@ -0,0 +1,83 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: gio_seekable.hxx,v $ + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef GIO_SEEKABLE_HXX +#define GIO_SEEKABLE_HXX + +#include +#include +#include + +#include +#include + +#include + +namespace gio +{ + +class Seekable : public ::com::sun::star::io::XTruncate, + public ::com::sun::star::io::XSeekable, + public ::cppu::OWeakObject +{ +private: + GSeekable *mpStream; +public: + Seekable( GSeekable *pStream ); + virtual ~Seekable(); + + // XInterface + virtual com::sun::star::uno::Any SAL_CALL queryInterface(const ::com::sun::star::uno::Type & type ) + throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL acquire( void ) throw () { OWeakObject::acquire(); } + virtual void SAL_CALL release( void ) throw() { OWeakObject::release(); } + + // XSeekable + virtual void SAL_CALL seek( sal_Int64 location ) + throw( ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::io::IOException, + ::com::sun::star::uno::RuntimeException ); + + virtual sal_Int64 SAL_CALL getPosition() + throw( ::com::sun::star::io::IOException, + ::com::sun::star::uno::RuntimeException ); + + virtual sal_Int64 SAL_CALL getLength() + throw( ::com::sun::star::io::IOException, + ::com::sun::star::uno::RuntimeException ); + + // XTruncate + virtual void SAL_CALL truncate( void ) + throw( com::sun::star::io::IOException, + com::sun::star::uno::RuntimeException ); +}; + +} // namespace gio +#endif diff --git a/ucb/source/ucp/gio/ucpgio-ucd.txt b/ucb/source/ucp/gio/ucpgio-ucd.txt new file mode 100644 index 000000000000..ce7657fa73e3 --- /dev/null +++ b/ucb/source/ucp/gio/ucpgio-ucd.txt @@ -0,0 +1,6 @@ +[ComponentDescriptor] +ImplementationName=com.sun.star.comp.GIOContentProvider +ComponentName=ucpgio1.uno.so +LoaderName=com.sun.star.loader.SharedLibrary +[SupportedServices] +com.sun.star.ucb.GIOContentProvider -- cgit v1.2.3