diff options
author | Oliver Braun <obr@openoffice.org> | 2001-06-20 12:55:05 +0000 |
---|---|---|
committer | Oliver Braun <obr@openoffice.org> | 2001-06-20 12:55:05 +0000 |
commit | 5f10dc06ce45432a1faa1ebe1f94d094a79e60cd (patch) | |
tree | fefedee655e63eec8e13c400c22492da23a0dfff /shell | |
parent | 11b73d7639651acbd675fb8774faaab5d911628d (diff) |
#88296# initial release
Diffstat (limited to 'shell')
-rw-r--r-- | shell/source/unix/exec/makefile.mk | 101 | ||||
-rw-r--r-- | shell/source/unix/exec/shellexec.cxx | 398 | ||||
-rw-r--r-- | shell/source/unix/exec/shellexec.hxx | 138 | ||||
-rw-r--r-- | shell/source/unix/exec/shellexecentry.cxx | 186 | ||||
-rw-r--r-- | shell/source/unix/exec/syssh.xml | 38 |
5 files changed, 861 insertions, 0 deletions
diff --git a/shell/source/unix/exec/makefile.mk b/shell/source/unix/exec/makefile.mk new file mode 100644 index 000000000000..db943c99f3c6 --- /dev/null +++ b/shell/source/unix/exec/makefile.mk @@ -0,0 +1,101 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: obr $ $Date: 2001-06-20 13:55:05 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library 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 for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source 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.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/..$/.. +PRJNAME=shell +TARGET=syssh +LIBTARGET=NO +ENABLE_EXCEPTIONS=TRUE +COMP1TYPELIST=$(TARGET) +COMPRDB=$(SOLARBINDIR)$/applicat.rdb + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +# --- Files -------------------------------------------------------- + +SLOFILES=$(SLO)$/shellexec.obj\ + $(SLO)$/shellexecentry.obj + +SHL1TARGET=$(TARGET) + +SHL1STDLIBS=$(CPPULIB)\ + $(CPPUHELPERLIB)\ + $(SALLIB) + +SHL1LIBS= + +SHL1DEPN= +SHL1IMPLIB=i$(SHL1TARGET) + +SHL1OBJS=$(SLOFILES) +#SHL1DEF=$(MISC)$/$(SHL1TARGET).def + +#DEF1NAME=$(SHL1TARGET) +#DEF1EXPORTFILE= exports.dxp + + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + diff --git a/shell/source/unix/exec/shellexec.cxx b/shell/source/unix/exec/shellexec.cxx new file mode 100644 index 000000000000..357f2720da84 --- /dev/null +++ b/shell/source/unix/exec/shellexec.cxx @@ -0,0 +1,398 @@ +/************************************************************************* + * + * $RCSfile: shellexec.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: obr $ $Date: 2001-06-20 13:55:05 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source 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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif + +#ifndef _OSL_THREAD_H_ +#include <osl/thread.h> +#endif + +#ifndef _OSL_FILE_HXX_ +#include <osl/file.hxx> +#endif + +#ifndef _RTL_STRBUF_HXX_ +#include <rtl/strbuf.hxx> +#endif + +#ifndef _RTL_USTRBUF_HXX_ +#include <rtl/ustrbuf.hxx> +#endif + +#ifndef _SHELLEXEC_HXX_ +#include "shellexec.hxx" +#endif + +#ifndef _COM_SUN_STAR_SYSTEM_SYSTEMSHELLEXECUTEFLAGS_HPP_ +#include <com/sun/star/system/SystemShellExecuteFlags.hpp> +#endif + +#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ +#include <com/sun/star/container/XNameAccess.hpp> +#endif + +#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ +#include <com/sun/star/beans/PropertyValue.hpp> +#endif + +#include <errno.h> +#include <unistd.h> + +//------------------------------------------------------------------------ +// namespace directives +//------------------------------------------------------------------------ + +using com::sun::star::system::XSystemShellExecute; +using com::sun::star::system::SystemShellExecuteException; +using com::sun::star::beans::PropertyValue; +using com::sun::star::container::NoSuchElementException; +using com::sun::star::container::XNameAccess; + +using rtl::OString; +using rtl::OUString; +using rtl::OStringBuffer; +using rtl::OUStringBuffer; +using osl::FileBase; +using osl::MutexGuard; +using osl::Mutex; + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::system::SystemShellExecuteFlags; +using namespace cppu; + +//------------------------------------------------------------------------ +// defines +//------------------------------------------------------------------------ + +#define SHELLEXEC_IMPL_NAME "com.sun.star.comp.system.SystemShellExecute" + +//------------------------------------------------------------------------ +// helper functions +//------------------------------------------------------------------------ + +namespace // private +{ + Sequence< OUString > SAL_CALL ShellExec_getSupportedServiceNames() + { + Sequence< OUString > aRet(1); + aRet[0] = OUString::createFromAscii("com.sun.star.sys.shell.SystemShellExecute"); + return aRet; + } +} + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +ShellExec::ShellExec( const Reference< XMultiServiceFactory >& xServiceManager ) : + WeakComponentImplHelper3< XSystemShellExecute, XEventListener, XServiceInfo >( m_aMutex ), + m_xServiceManager( xServiceManager ) +{ + try { + Reference< XComponent > xComponent = Reference< XComponent >( xServiceManager, UNO_QUERY ); + + if( xComponent.is() ) + xComponent->addEventListener( static_cast < XEventListener * > (this) ); + } + + catch( ... ) + { + m_xServiceManager.clear(); + OSL_TRACE( "ShellExec: corrupted service manager given." ); + } +} + +//------------------------------------------------- +// +//------------------------------------------------- + +void SAL_CALL ShellExec::execute( const OUString& aCommand, const OUString& aParameter, sal_Int32 nFlags ) + throw (IllegalArgumentException, SystemShellExecuteException, RuntimeException) +{ + OString aCommandLine = OUStringToOString( aCommand, osl_getThreadTextEncoding() ); + + // check if file exists and is executable - + // if not, it is either an url or a document +// if( 0 != access( aCommandLine.getStr(), X_OK ) ) + + // for now, only execute urls + if( 1 ) + { + OUString aURL( aCommand ); + OUString aProtocol, aHandler; + + // save this value here +// int nerr = errno; + // default error value here + int nerr = ENOEXEC; + + // find protocol specifier + sal_Int32 nIndex = aCommand.indexOf( (sal_Unicode) ':' ); + + if( nIndex > 0 ) + { + // FIXME: check for valid protocols here - proposed API for rtl + + // protocol keys are stored in lower case + aProtocol = aCommand.copy( 0, nIndex ).toAsciiLowerCase(); + } + + if( ( 0 == aProtocol.getLength() ) && + ( osl_File_E_None == FileBase::getFileURLFromSystemPath( aCommand, aURL ) ) ) + { + // seems to be a document + aProtocol = OUString::createFromAscii( "file" ); + } + + // if aCommand contains a url with a known protocol, + // retrieve the registered handler from configuration + if( aProtocol.getLength() ) + { + MutexGuard aGuard( m_aMutex ); + + // create config manager if not already done so + if( m_xServiceManager.is() && !m_xConfigurationProvider.is() ) + { + try + { + m_xConfigurationProvider = Reference< XMultiServiceFactory > ( + m_xServiceManager->createInstance( + OUString::createFromAscii( "com.sun.star.configuration.ConfigurationProvider" ) ), + UNO_QUERY ); + + Reference< XComponent > xComponent = + Reference< XComponent >( m_xConfigurationProvider, UNO_QUERY ); + + if( xComponent.is() ) + xComponent->addEventListener( static_cast < XEventListener * > (this) ); + } + + // release service manager instance on runtime exceptions + catch ( RuntimeException e ) + { + m_xServiceManager.clear(); + OSL_TRACE( "ShellExec: can not instanciate configuration provider." ); + throw e; + } + } + + if( m_xConfigurationProvider.is() ) + { + try + { + Sequence< Any > aArgumentList( 1 ); + + PropertyValue aProperty; + aProperty.Name = OUString::createFromAscii( "nodepath" ); + aProperty.Value = makeAny( OUString::createFromAscii( "org.openoffice.Office.Common/ExternalApps" ) ); + + aArgumentList[0] = makeAny( aProperty ); + + // query the configured handle for this protocol + Reference< XNameAccess > xNameAccess = + Reference< XNameAccess > ( + m_xConfigurationProvider->createInstanceWithArguments( + OUString::createFromAscii( "com.sun.star.configuration.ConfigurationAccess" ), + aArgumentList ), + UNO_QUERY ); + + if( xNameAccess.is() ) + { + // save the registered handler + xNameAccess->getByName( aProtocol ) >>= aHandler; + } + } + + catch( NoSuchElementException e ) + { + OSL_TRACE( "ShellExec: unknown protocol.\n" ); + OSL_TRACE( OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).getStr() ); + } + + catch( WrappedTargetException e ) + { + OSL_TRACE( "ShellExec: unexspected exception.\n" ); + OSL_TRACE( OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).getStr() ); + } + + catch( RuntimeException e ) + { + m_xConfigurationProvider.clear(); + OSL_TRACE( "ShellExec: configuration provider." ); + OSL_TRACE( OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).getStr() ); + throw e; + } + + catch( Exception e ) + { + OSL_TRACE( "ShellExec: unexspected exception.\n" ); + OSL_TRACE( OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).getStr() ); + } + } + } + + sal_Int32 nLength = aHandler.getLength(); + if( nLength ) + { + // due to a possible convertion to file url, + // rebuild command line from scratch + OUStringBuffer aBuffer( nLength + aURL.getLength() + 1 ); + + aBuffer.append( aHandler ); + aBuffer.append( (sal_Unicode) ' ' ); + aBuffer.append( aURL ); + + aCommandLine = OUStringToOString( aBuffer.makeStringAndClear(), osl_getThreadTextEncoding() ); + } + else + { + // no handler installed + throw SystemShellExecuteException( + OUString::createFromAscii( strerror( nerr ) ), + static_cast < XSystemShellExecute * > (this), + nerr ); + } + } + + // append parameter if any + if( aParameter.getLength() ) + { + OString aTmp = OUStringToOString( aParameter, osl_getThreadTextEncoding() ); + + OStringBuffer aBuffer( aCommandLine.getLength() + aTmp.getLength() + 1 ); + + aBuffer.append( aCommandLine ); + aBuffer.append( ' ' ); + aBuffer.append( aTmp ); + + aCommandLine = aBuffer.makeStringAndClear(); + } + + if( 0 != system( aCommandLine.getStr() ) ) + { + int nerr = errno; + + throw SystemShellExecuteException( + OUString::createFromAscii( strerror( nerr ) ), + static_cast < XSystemShellExecute * > (this), + nerr ); + } +} + +//------------------------------------------------ +// XEventListener +//------------------------------------------------ + +void SAL_CALL ShellExec::disposing( const ::com::sun::star::lang::EventObject& aEvent ) + throw(::com::sun::star::uno::RuntimeException) +{ + MutexGuard aGuard( m_aMutex ); + + if( m_xServiceManager == aEvent.Source ) + { + m_xServiceManager.clear(); + } + + else if( m_xConfigurationProvider == aEvent.Source ) + { + m_xConfigurationProvider.clear(); + } +} + +// ------------------------------------------------- +// XServiceInfo +// ------------------------------------------------- + +OUString SAL_CALL ShellExec::getImplementationName( ) + throw( RuntimeException ) +{ + return OUString::createFromAscii( SHELLEXEC_IMPL_NAME ); +} + +// ------------------------------------------------- +// XServiceInfo +// ------------------------------------------------- + +sal_Bool SAL_CALL ShellExec::supportsService( const OUString& ServiceName ) + throw( RuntimeException ) +{ + Sequence < OUString > SupportedServicesNames = ShellExec_getSupportedServiceNames(); + + for ( sal_Int32 n = SupportedServicesNames.getLength(); n--; ) + if (SupportedServicesNames[n].compareTo(ServiceName) == 0) + return sal_True; + + return sal_False; +} + +// ------------------------------------------------- +// XServiceInfo +// ------------------------------------------------- + +Sequence< OUString > SAL_CALL ShellExec::getSupportedServiceNames( ) + throw( RuntimeException ) +{ + return ShellExec_getSupportedServiceNames(); +} + diff --git a/shell/source/unix/exec/shellexec.hxx b/shell/source/unix/exec/shellexec.hxx new file mode 100644 index 000000000000..228c289fe2c2 --- /dev/null +++ b/shell/source/unix/exec/shellexec.hxx @@ -0,0 +1,138 @@ +/************************************************************************* + * + * $RCSfile: shellexec.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: obr $ $Date: 2001-06-20 13:55:05 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source 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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SHELLEXEC_HXX_ +#define _SHELLEXEC_HXX_ + +#ifndef _CPPUHELPER_COMPBASE3_HXX_ +#include <cppuhelper/compbase3.hxx> +#endif + +#ifndef _OSL_MUTEX_HXX_ +#include <osl/mutex.hxx> +#endif + +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif + +#ifndef _COM_SUN_STAR_LANG_XEVENTLISTENER_HPP_ +#include <com/sun/star/lang/XEventListener.hpp> +#endif + +#ifndef _COM_SUN_STAR_SYS_SHELL_XSYSTEMSHELLEXECUTE_HPP_ +#include <com/sun/star/system/XSystemShellExecute.hpp> +#endif + +//---------------------------------------------------------- +// class declaration +//---------------------------------------------------------- + +class ShellExecBase +{ +protected: + osl::Mutex m_aMutex; +}; + +class ShellExec : + public ShellExecBase, + public cppu::WeakComponentImplHelper3< + com::sun::star::system::XSystemShellExecute, + com::sun::star::lang::XEventListener, + com::sun::star::lang::XServiceInfo > +{ + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager; + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xConfigurationProvider; + + ::osl::Mutex m_aMutex; + +public: + ShellExec( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ); + + //------------------------------------------------ + // XSystemShellExecute + //------------------------------------------------ + + virtual void SAL_CALL execute( const ::rtl::OUString& aCommand, const ::rtl::OUString& aParameter, sal_Int32 nFlags ) + throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::system::SystemShellExecuteException, ::com::sun::star::uno::RuntimeException); + + //------------------------------------------------ + // XEventListener + //------------------------------------------------ + + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& aEvent ) + throw(::com::sun::star::uno::RuntimeException); + + //------------------------------------------------ + // XServiceInfo + //------------------------------------------------ + + virtual ::rtl::OUString SAL_CALL getImplementationName( ) + throw(::com::sun::star::uno::RuntimeException); + + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) + throw(::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) + throw(::com::sun::star::uno::RuntimeException); +}; + +#endif diff --git a/shell/source/unix/exec/shellexecentry.cxx b/shell/source/unix/exec/shellexecentry.cxx new file mode 100644 index 000000000000..48c1c9c93e00 --- /dev/null +++ b/shell/source/unix/exec/shellexecentry.cxx @@ -0,0 +1,186 @@ +/************************************************************************* + * + * $RCSfile: shellexecentry.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: obr $ $Date: 2001-06-20 13:55:05 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source 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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +//----------------------------------------------------------------------- +// includes of other projects +//----------------------------------------------------------------------- + +#ifndef _CPPUHELPER_FACTORY_HXX_ +#include <cppuhelper/factory.hxx> +#endif + +#ifndef _COM_SUN_STAR_CONTAINER_XSET_HPP_ +#include <com/sun/star/container/XSet.hpp> +#endif + +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif + +#ifndef _SHELLEXEC_HXX_ +#include "shellexec.hxx" +#endif + +//----------------------------------------------------------------------- +// namespace directives +//----------------------------------------------------------------------- + +using namespace ::rtl; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::registry; +using namespace ::cppu; +using com::sun::star::system::XSystemShellExecute; + +//----------------------------------------------------------------------- +// defines +//----------------------------------------------------------------------- + +#define SHELLEXEC_SERVICE_NAME "com.sun.star.system.SystemShellExecute" +#define SHELLEXEC_IMPL_NAME "com.sun.star.comp.system.SystemShellExecute" +#define SHELLEXEC_REGKEY_NAME "/com.sun.star.comp.system.SystemShellExecute/UNO/SERVICES/com.sun.star.system.SystemShellExecute" + +//----------------------------------------------------------------------- +// +//----------------------------------------------------------------------- + +namespace +{ + Reference< XInterface > SAL_CALL createInstance( const Reference< XMultiServiceFactory >& rServiceManager ) + { + return Reference< XInterface >( static_cast< XSystemShellExecute* >( new ShellExec( rServiceManager ) ) ); + } +} + +//----------------------------------------------------------------------- +// the 3 important functions which will be exported +//----------------------------------------------------------------------- + +extern "C" +{ + +//---------------------------------------------------------------------- +// component_getImplementationEnvironment +//---------------------------------------------------------------------- + +void SAL_CALL component_getImplementationEnvironment( + const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv ) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + +//----------------------------------------------------------------------- +// +//----------------------------------------------------------------------- + +sal_Bool SAL_CALL component_writeInfo( void* pServiceManager, void* pRegistryKey ) +{ + sal_Bool bRetVal = sal_True; + + if ( pRegistryKey ) + { + try + { + Reference< XRegistryKey > pXNewKey( static_cast< XRegistryKey* >( pRegistryKey ) ); + pXNewKey->createKey( + OUString::createFromAscii( SHELLEXEC_REGKEY_NAME ) ); + } + catch( InvalidRegistryException& ) + { + OSL_ENSURE(sal_False, "InvalidRegistryException caught"); + bRetVal = sal_False; + } + } + + return bRetVal; +} + +//---------------------------------------------------------------------- +// component_getFactory +// returns a factory to create XFilePicker-Services +//---------------------------------------------------------------------- + +void* SAL_CALL component_getFactory( const sal_Char* pImplName, uno_Interface* pSrvManager, uno_Interface* pRegistryKey ) +{ + void* pRet = 0; + + if ( pSrvManager && ( 0 == rtl_str_compare( pImplName, SHELLEXEC_IMPL_NAME ) ) ) + { + Sequence< OUString > aSNS( 1 ); + aSNS.getArray( )[0] = OUString::createFromAscii( SHELLEXEC_SERVICE_NAME ); + + Reference< XSingleServiceFactory > xFactory ( createOneInstanceFactory( + reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ), + OUString::createFromAscii( pImplName ), + createInstance, + aSNS ) ); + if ( xFactory.is() ) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + } + + return pRet; +} + +} // extern "C" diff --git a/shell/source/unix/exec/syssh.xml b/shell/source/unix/exec/syssh.xml new file mode 100644 index 000000000000..af9691e4d2f9 --- /dev/null +++ b/shell/source/unix/exec/syssh.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd"> +<module-description xmlns:xlink="http://www.w3.org/1999/xlink"> + <module-name> syssh </module-name> + <component-description> + <author> Oliver Braun </author> + <name>com.sun.star.comp.system.SystemShellExecute</name> + <description> The unix implementation of a SystemShellExecute service. </description> + <loader-name>com.sun.star.loader.SharedLibrary</loader-name> + <language> c++ </language> + <status value="beta"/> + <supported-service> com.sun.star.system.SystemShellExecute </supported-service> + <service-dependency>...</service-dependency> + <type> com.sun.star.system.XSystemShellExecute </type> + <type> com.sun.star.system.SystemShellExecuteException </type> + <type> com.sun.star.system.SystemShellExecuteFlags </type> + <type> com.sun.star.beans.PropertyValue </type> + <type> com.sun.star.lang.XComponent </type> + <type> com.sun.star.lang.XEventListener </type> + <type> com.sun.star.lang.XMultiServiceFactory </type> + <type> com.sun.star.lang.XSingleServiceFactory </type> + <type> com.sun.star.lang.XServiceInfo </type> + <type> com.sun.star.lang.XTypeProvider </type> + <type> com.sun.star.lang.IllegalArgumentException </type> + <type> com.sun.star.uno.TypeClass </type> + <type> com.sun.star.uno.XWeak </type> + <type> com.sun.star.uno.XAggregation </type> + <type> com.sun.star.registry.XRegistryKey </type> + <type> com.sun.star.container.XSet </type> + <type> com.sun.star.container.XNameAccess </type> + </component-description> + <project-build-dependency> cppuhelper </project-build-dependency> + <project-build-dependency> cppu </project-build-dependency> + <project-build-dependency> sal </project-build-dependency> + <runtime-module-dependency> cppuhelper3$(COM) </runtime-module-dependency> + <runtime-module-dependency> cppu3 </runtime-module-dependency> + <runtime-module-dependency> sal3 </runtime-module-dependency> +</module-description> |