diff options
author | Tino Rachui <tra@openoffice.org> | 2001-04-27 12:55:35 +0000 |
---|---|---|
committer | Tino Rachui <tra@openoffice.org> | 2001-04-27 12:55:35 +0000 |
commit | d36345edd9dc2b7f00933ac34b3e29ed002ddbcb (patch) | |
tree | 2cecc3ee5a5b605a27b3730f7b5f78239f1f154f | |
parent | 47c8fd5e04637e316a0553a98a2f6aa6330fc5db (diff) |
*** empty log message ***
-rw-r--r-- | shell/prj/build.lst | 3 | ||||
-rw-r--r-- | shell/prj/d.lst | 5 | ||||
-rw-r--r-- | shell/source/win32/SysShExec.cxx | 316 | ||||
-rw-r--r-- | shell/source/win32/SysShExec.hxx | 125 | ||||
-rw-r--r-- | shell/source/win32/SysShentry.cxx | 186 | ||||
-rw-r--r-- | shell/source/win32/exports.dxp | 3 | ||||
-rw-r--r-- | shell/source/win32/makefile.mk | 103 | ||||
-rw-r--r-- | shell/source/win32/syssh.xml | 34 | ||||
-rw-r--r-- | shell/source/win32/workbench/TestSysShExec.cxx | 214 | ||||
-rw-r--r-- | shell/source/win32/workbench/makefile.mk | 96 |
10 files changed, 1085 insertions, 0 deletions
diff --git a/shell/prj/build.lst b/shell/prj/build.lst new file mode 100644 index 000000000000..ff61d2710e8d --- /dev/null +++ b/shell/prj/build.lst @@ -0,0 +1,3 @@ +sh shell : offapi rdbmaker NULL +sh shell usr1 - all su_mkout NULL +sh shell\source\win32\ nmake - w sh_win32 NULL diff --git a/shell/prj/d.lst b/shell/prj/d.lst new file mode 100644 index 000000000000..1bbe5ea67ff8 --- /dev/null +++ b/shell/prj/d.lst @@ -0,0 +1,5 @@ +..\%__SRC%\lib\*.so %_DEST%\lib%_EXT%\*.so +..\%__SRC%\bin\*.dll %_DEST%\bin%_EXT%\*.dll +..\%__SRC%\lib\*.dylib %_DEST%\lib%_EXT%\*.dylib + +..\source\win32\syssh.xml %_DEST%\xml%_EXT%\syssh.xml diff --git a/shell/source/win32/SysShExec.cxx b/shell/source/win32/SysShExec.cxx new file mode 100644 index 000000000000..78c98279b0cd --- /dev/null +++ b/shell/source/win32/SysShExec.cxx @@ -0,0 +1,316 @@ +/************************************************************************* + * + * $RCSfile: SysShExec.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-04-27 13:54:12 $ + * + * 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 +//------------------------------------------------------------------------ + +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif + +#ifndef _SYSSHEXEC_HXX_ +#include "SysShExec.hxx" +#endif + +#include <osl/file.h> + +#ifndef _COM_SUN_STAR_SYS_SHELL_SYSTEMSHELLEXECUTEFLAGS_HPP_ +#include <com/sun/star/system/SystemShellExecuteFlags.hpp> +#endif + +#include <systools/win32/shell9x.h> + +//------------------------------------------------------------------------ +// namespace directives +//------------------------------------------------------------------------ + +using com::sun::star::uno::Reference; +using com::sun::star::uno::RuntimeException; +using com::sun::star::uno::Sequence; +using com::sun::star::uno::XInterface; +using com::sun::star::lang::EventObject; +using com::sun::star::lang::XServiceInfo; +using com::sun::star::lang::IllegalArgumentException; +using rtl::OUString; +using osl::Mutex; +using com::sun::star::system::XSystemShellExecute; +using com::sun::star::system::SystemShellExecuteException; + +using namespace ::com::sun::star::system::SystemShellExecuteFlags; +using namespace cppu; + +//------------------------------------------------------------------------ +// defines +//------------------------------------------------------------------------ + +#define SYSSHEXEC_IMPL_NAME "com.sun.star.sys.shell.SystemShellExecute" + +//------------------------------------------------------------------------ +// helper functions +//------------------------------------------------------------------------ + +namespace // private +{ + Sequence< OUString > SAL_CALL SysShExec_getSupportedServiceNames() + { + Sequence< OUString > aRet(1); + aRet[0] = OUString::createFromAscii("com.sun.star.sys.shell.SystemShellExecute"); + return aRet; + } + + /* This is the error table that defines the mapping between OS error + codes and errno values */ + + struct errentry { + unsigned long oscode; /* OS return value */ + int errnocode; /* System V error code */ + }; + + struct errentry errtable[] = { + { ERROR_SUCCESS, osl_File_E_None }, /* 0 */ + { ERROR_INVALID_FUNCTION, osl_File_E_INVAL }, /* 1 */ + { ERROR_FILE_NOT_FOUND, osl_File_E_NOENT }, /* 2 */ + { ERROR_PATH_NOT_FOUND, osl_File_E_NOENT }, /* 3 */ + { ERROR_TOO_MANY_OPEN_FILES, osl_File_E_MFILE }, /* 4 */ + { ERROR_ACCESS_DENIED, osl_File_E_ACCES }, /* 5 */ + { ERROR_INVALID_HANDLE, osl_File_E_BADF }, /* 6 */ + { ERROR_ARENA_TRASHED, osl_File_E_NOMEM }, /* 7 */ + { ERROR_NOT_ENOUGH_MEMORY, osl_File_E_NOMEM }, /* 8 */ + { ERROR_INVALID_BLOCK, osl_File_E_NOMEM }, /* 9 */ + { ERROR_BAD_ENVIRONMENT, osl_File_E_2BIG }, /* 10 */ + { ERROR_BAD_FORMAT, osl_File_E_NOEXEC }, /* 11 */ + { ERROR_INVALID_ACCESS, osl_File_E_INVAL }, /* 12 */ + { ERROR_INVALID_DATA, osl_File_E_INVAL }, /* 13 */ + { ERROR_INVALID_DRIVE, osl_File_E_NOENT }, /* 15 */ + { ERROR_CURRENT_DIRECTORY, osl_File_E_ACCES }, /* 16 */ + { ERROR_NOT_SAME_DEVICE, osl_File_E_XDEV }, /* 17 */ + { ERROR_NO_MORE_FILES, osl_File_E_NOENT }, /* 18 */ + { ERROR_LOCK_VIOLATION, osl_File_E_ACCES }, /* 33 */ + { ERROR_BAD_NETPATH, osl_File_E_NOENT }, /* 53 */ + { ERROR_NETWORK_ACCESS_DENIED, osl_File_E_ACCES }, /* 65 */ + { ERROR_BAD_NET_NAME, osl_File_E_NOENT }, /* 67 */ + { ERROR_FILE_EXISTS, osl_File_E_EXIST }, /* 80 */ + { ERROR_CANNOT_MAKE, osl_File_E_ACCES }, /* 82 */ + { ERROR_FAIL_I24, osl_File_E_ACCES }, /* 83 */ + { ERROR_INVALID_PARAMETER, osl_File_E_INVAL }, /* 87 */ + { ERROR_NO_PROC_SLOTS, osl_File_E_AGAIN }, /* 89 */ + { ERROR_DRIVE_LOCKED, osl_File_E_ACCES }, /* 108 */ + { ERROR_BROKEN_PIPE, osl_File_E_PIPE }, /* 109 */ + { ERROR_DISK_FULL, osl_File_E_NOSPC }, /* 112 */ + { ERROR_INVALID_TARGET_HANDLE, osl_File_E_BADF }, /* 114 */ + { ERROR_INVALID_HANDLE, osl_File_E_INVAL }, /* 124 */ + { ERROR_WAIT_NO_CHILDREN, osl_File_E_CHILD }, /* 128 */ + { ERROR_CHILD_NOT_COMPLETE, osl_File_E_CHILD }, /* 129 */ + { ERROR_DIRECT_ACCESS_HANDLE, osl_File_E_BADF }, /* 130 */ + { ERROR_NEGATIVE_SEEK, osl_File_E_INVAL }, /* 131 */ + { ERROR_SEEK_ON_DEVICE, osl_File_E_ACCES }, /* 132 */ + { ERROR_DIR_NOT_EMPTY, osl_File_E_NOTEMPTY }, /* 145 */ + { ERROR_NOT_LOCKED, osl_File_E_ACCES }, /* 158 */ + { ERROR_BAD_PATHNAME, osl_File_E_NOENT }, /* 161 */ + { ERROR_MAX_THRDS_REACHED, osl_File_E_AGAIN }, /* 164 */ + { ERROR_LOCK_FAILED, osl_File_E_ACCES }, /* 167 */ + { ERROR_ALREADY_EXISTS, osl_File_E_EXIST }, /* 183 */ + { ERROR_FILENAME_EXCED_RANGE, osl_File_E_NOENT }, /* 206 */ + { ERROR_NESTING_NOT_ALLOWED, osl_File_E_AGAIN }, /* 215 */ + { ERROR_NOT_ENOUGH_QUOTA, osl_File_E_NOMEM } /* 1816 */ + }; + + /* size of the table */ + #define ERRTABLESIZE (sizeof(errtable)/sizeof(errtable[0])) + + /* The following two constants must be the minimum and maximum + values in the (contiguous) range of osl_File_E_xec Failure errors. */ + #define MIN_EXEC_ERROR ERROR_INVALID_STARTING_CODESEG + #define MAX_EXEC_ERROR ERROR_INFLOOP_IN_RELOC_CHAIN + + /* These are the low and high value in the range of errors that are + access violations */ + #define MIN_EACCES_RANGE ERROR_WRITE_PROTECT + #define MAX_EACCES_RANGE ERROR_SHARING_BUFFER_EXCEEDED + + + /*******************************************************************************/ + + oslFileError _mapError( DWORD dwError ) + { + int i; + + /* check the table for the OS error code */ + for ( i = 0; i < ERRTABLESIZE; ++i ) + { + if ( dwError == errtable[i].oscode ) + return (oslFileError)errtable[i].errnocode; + } + + /* The error code wasn't in the table. We check for a range of */ + /* osl_File_E_ACCES errors or exec failure errors (ENOEXEC). Otherwise */ + /* osl_File_E_INVAL is returned. */ + + if ( dwError >= MIN_EACCES_RANGE && dwError <= MAX_EACCES_RANGE) + return osl_File_E_ACCES; + else if ( dwError >= MIN_EXEC_ERROR && dwError <= MAX_EXEC_ERROR) + return osl_File_E_NOEXEC; + else + return osl_File_E_INVAL; + } + + #define MapError( oserror ) _mapError( oserror ) + + #define E_UNKNOWN_EXEC_ERROR -1 + +} // end namespace + +//----------------------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------------------- + +CSysShExec::CSysShExec( ) : + WeakComponentImplHelper2< XSystemShellExecute, XServiceInfo >( m_aMutex ) +{ +} + +//------------------------------------------------- +// +//------------------------------------------------- + +void SAL_CALL CSysShExec::execute( const OUString& aCommand, const OUString& aParameter, sal_Int32 nFlags ) + throw (IllegalArgumentException, SystemShellExecuteException, RuntimeException) +{ + // parameter checking + if ( !aCommand.getLength( ) ) + throw IllegalArgumentException( + OUString::createFromAscii( "Empty command" ), + static_cast< XSystemShellExecute* >( this ), + 1 ); + + if ( !( nFlags >= SSEF_DEFAULTS && nFlags <= SSEF_NO_SYSTEM_ERROR_MESSAGE ) ) + throw IllegalArgumentException( + OUString::createFromAscii( "Invalid Flags specified" ), + static_cast< XSystemShellExecute* >( this ), + 3 ); + + SHELLEXECUTEINFOW sei; + ZeroMemory( &sei, sizeof( sei ) ); + + sei.cbSize = sizeof( sei ); + sei.lpFile = aCommand.getStr(); + sei.lpParameters = aParameter.getStr(); + sei.nShow = SW_SHOWNORMAL; + + if ( SSEF_NO_SYSTEM_ERROR_MESSAGE & nFlags ) + sei.fMask = SEE_MASK_FLAG_NO_UI; + + SetLastError( 0 ); + + if ( !ShellExecuteExW( &sei ) ) + { + // ShellExecuteEx fails to set an error code + // we return osl_File_E_INVAL + sal_Int32 psxErr = GetLastError( ); + if ( ERROR_SUCCESS == psxErr ) + psxErr = E_UNKNOWN_EXEC_ERROR; + else + psxErr = MapError( psxErr ); + + throw SystemShellExecuteException( + OUString::createFromAscii( "Error executing command" ), + static_cast< XSystemShellExecute* >( this ), + psxErr ); + } +} + +// ------------------------------------------------- +// XServiceInfo +// ------------------------------------------------- + +OUString SAL_CALL CSysShExec::getImplementationName( ) + throw( RuntimeException ) +{ + return OUString::createFromAscii( SYSSHEXEC_IMPL_NAME ); +} + +// ------------------------------------------------- +// XServiceInfo +// ------------------------------------------------- + +sal_Bool SAL_CALL CSysShExec::supportsService( const OUString& ServiceName ) + throw( RuntimeException ) +{ + Sequence < OUString > SupportedServicesNames = SysShExec_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 CSysShExec::getSupportedServiceNames( ) + throw( RuntimeException ) +{ + return SysShExec_getSupportedServiceNames(); +} + diff --git a/shell/source/win32/SysShExec.hxx b/shell/source/win32/SysShExec.hxx new file mode 100644 index 000000000000..f7787a55fbd1 --- /dev/null +++ b/shell/source/win32/SysShExec.hxx @@ -0,0 +1,125 @@ +/************************************************************************* + * + * $RCSfile: SysShExec.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-04-27 13:53:50 $ + * + * 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 _SYSSHEXEC_HXX_ +#define _SYSSHEXEC_HXX_ + +//_______________________________________________________________________________________________________________________ +// includes of other projects +//_______________________________________________________________________________________________________________________ + +#ifndef _CPPUHELPER_COMPBASE2_HXX_ +#include <cppuhelper/compbase2.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_SYS_SHELL_XSYSTEMSHELLEXECUTE_HPP_ +#include <com/sun/star/system/XSystemShellExecute.hpp> +#endif + +//---------------------------------------------------------- +// class declaration +//---------------------------------------------------------- + +class CSysShExecBase +{ +protected: + osl::Mutex m_aMutex; +}; + +class CSysShExec : + public CSysShExecBase, + public cppu::WeakComponentImplHelper2< + com::sun::star::system::XSystemShellExecute, + com::sun::star::lang::XServiceInfo > +{ +public: + CSysShExec( ); + + //------------------------------------------------ + // 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); + + //------------------------------------------------ + // 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/win32/SysShentry.cxx b/shell/source/win32/SysShentry.cxx new file mode 100644 index 000000000000..9a170c89610b --- /dev/null +++ b/shell/source/win32/SysShentry.cxx @@ -0,0 +1,186 @@ +/************************************************************************* + * + * $RCSfile: SysShentry.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-04-27 13:53:57 $ + * + * 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 _SYSSHEXEC_HXX_ +#include "SysShExec.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 SYSSHEXEC_SERVICE_NAME "com.sun.star.system.SystemShellExecute" +#define SYSSHEXEC_IMPL_NAME "com.sun.star.system.SystemShellExecute" +#define SYSSHEXEC_REGKEY_NAME "/com.sun.star.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 CSysShExec( ) ) ); + } +} + +//----------------------------------------------------------------------- +// 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( SYSSHEXEC_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, SYSSHEXEC_IMPL_NAME ) ) ) + { + Sequence< OUString > aSNS( 1 ); + aSNS.getArray( )[0] = OUString::createFromAscii( SYSSHEXEC_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/win32/exports.dxp b/shell/source/win32/exports.dxp new file mode 100644 index 000000000000..028ac4175990 --- /dev/null +++ b/shell/source/win32/exports.dxp @@ -0,0 +1,3 @@ +component_getImplementationEnvironment +component_writeInfo +component_getFactory diff --git a/shell/source/win32/makefile.mk b/shell/source/win32/makefile.mk new file mode 100644 index 000000000000..2862dbc3d8af --- /dev/null +++ b/shell/source/win32/makefile.mk @@ -0,0 +1,103 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: tra $ $Date: 2001-04-27 13:54:19 $ +# +# 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 -------------------------------------------------------- + +.INCLUDE : ..$/cppumaker.mk + +SLOFILES=$(SLO)$/SysShentry.obj\ + $(SLO)$/SysShExec.obj + +SHL1TARGET=$(TARGET) + +SHL1STDLIBS=$(CPPULIB)\ + $(CPPUHELPERLIB)\ + $(SALLIB)\ + shell32.lib + +SHL1LIBS=$(SOLARLIBDIR)\shell9x.lib + +SHL1DEPN= +SHL1IMPLIB=i$(SHL1TARGET) + +SHL1OBJS=$(SLOFILES) +SHL1DEF=$(MISC)$/$(SHL1TARGET).def + +DEF1NAME=$(SHL1TARGET) +DEF1EXPORTFILE= exports.dxp + + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk diff --git a/shell/source/win32/syssh.xml b/shell/source/win32/syssh.xml new file mode 100644 index 000000000000..b4f44fadfc8d --- /dev/null +++ b/shell/source/win32/syssh.xml @@ -0,0 +1,34 @@ +<?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> Tino Rachui </author> + <name>com.sun.star.comp.system.SystemShellExecute</name> + <description> + The win32 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.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> + </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> cppuhelper </runtime-module-dependency> + <runtime-module-dependency> cppu2 </runtime-module-dependency> + <runtime-module-dependency> sal2 </runtime-module-dependency> +</module-description> diff --git a/shell/source/win32/workbench/TestSysShExec.cxx b/shell/source/win32/workbench/TestSysShExec.cxx new file mode 100644 index 000000000000..ad7c343095e6 --- /dev/null +++ b/shell/source/win32/workbench/TestSysShExec.cxx @@ -0,0 +1,214 @@ +/************************************************************************* + * + * $RCSfile: TestSysShExec.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-04-27 13:55:35 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + + +//----------------------------------------------------------- +// interface includes +//----------------------------------------------------------- + +#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_ +#include <com/sun/star/lang/XComponent.hpp> +#endif + +#ifndef _COM_SUN_STAR_REGISTRY_XSIMPLEREGISTRY_HPP_ +#include <com/sun/star/registry/XSimpleRegistry.hpp> +#endif + +#ifndef _COM_SUN_STAR_SYS_SHELL_XSYSTEMSHELLEXECUTE_HPP_ +#include <com/sun/star/system/XSystemShellExecute.hpp> +#endif + +#ifndef _CPPUHELPER_SERVICEFACTORY_HXX_ +#include <cppuhelper/servicefactory.hxx> +#endif + + +#ifndef _OSL_FILE_HXX_ +#include <osl/file.hxx> +#endif + +//-------------------------------------------------------------- +// other includes +//-------------------------------------------------------------- + +#ifndef _CPPUHELPER_SERVICEFACTORY_HXX_ +#include <cppuhelper/servicefactory.hxx> +#endif + +#ifndef _RTL_USTRING_ +#include <rtl/ustring> +#endif + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif + +#include <stdio.h> + +#include <windows.h> + +//-------------------------------------------------------------- +// namesapces +//-------------------------------------------------------------- + +using namespace ::rtl ; +using namespace ::cppu ; +using namespace ::com::sun::star::uno ; +using namespace ::com::sun::star::lang ; +using namespace std ; +using namespace com::sun::star::system; + +//-------------------------------------------------------------- +// defines +//-------------------------------------------------------------- + +#define RDB_SYSPATH "D:\\Projects\\src630\\sysshell\\wntmsci7\\bin\\applicat.rdb" + +//-------------------------------------------------------------- +// global variables +//-------------------------------------------------------------- + +Reference< XMultiServiceFactory > g_xFactory; + + +//-------------------------------------------------------------- +// main +//-------------------------------------------------------------- + + +int SAL_CALL main(int nArgc, char* Argv[], char* Env[] ) +{ + //------------------------------------------------- + // get the global service-manager + //------------------------------------------------- + + if ( nArgc < 4 ) + return 0; + + // Get global factory for uno services. + OUString rdbName = OUString( RTL_CONSTASCII_USTRINGPARAM( RDB_SYSPATH ) ); + Reference< XMultiServiceFactory > g_xFactory( createRegistryServiceFactory( rdbName ) ); + + // Print a message if an error occured. + if ( g_xFactory.is() == sal_False ) + { + OSL_ENSURE(sal_False, "Can't create RegistryServiceFactory"); + return(-1); + } + + printf("Creating RegistryServiceFactory successful\n"); + + //------------------------------------------------- + // try to get an Interface to a XFilePicker Service + //------------------------------------------------- + + Reference< XSystemShellExecute > xSysShExec( + g_xFactory->createInstance( OUString::createFromAscii( "com.sun.star.system.SystemShellExecute" ) ), UNO_QUERY ); + + if ( !xSysShExec.is() ) + { + OSL_ENSURE( sal_False, "Error creating SystemShellExecute Service" ); + return(-1); + } + + //"c:\\winnt\\notepad.exe" + OUString cmd = OUString::createFromAscii( Argv[1] ); + OUString param = OUString::createFromAscii( Argv[2] ); //c:\\winnt\\iis5.log + + try + { + xSysShExec->execute( cmd, param, atoi( Argv[3] ) ); + } + catch( SystemShellExecuteException& ex ) + { + OSL_ENSURE( sal_False, "Error executing system command" ); + } + catch( IllegalArgumentException& ex) + { + OSL_ENSURE( sal_False, "Invalid parameter" ); + } + + //-------------------------------------------------- + // shutdown + //-------------------------------------------------- + + // Cast factory to XComponent + Reference< XComponent > xComponent( g_xFactory, UNO_QUERY ); + + // Print a message if an error occured. + if ( xComponent.is() == sal_False ) + { + OSL_ENSURE(sal_False, "Error shuting down"); + } + + // Dispose and clear factory + xComponent->dispose(); + g_xFactory.clear(); + g_xFactory = Reference< XMultiServiceFactory >(); + + printf("Test successful\n"); + + return 0; +} diff --git a/shell/source/win32/workbench/makefile.mk b/shell/source/win32/workbench/makefile.mk new file mode 100644 index 000000000000..b5e371d8dc21 --- /dev/null +++ b/shell/source/win32/workbench/makefile.mk @@ -0,0 +1,96 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: tra $ $Date: 2001-04-27 13:55:30 $ +# +# 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= sysshell +TARGET= testsyssh +LIBTARGET= NO +TARGETTYPE= CUI + + +# --- Settings ----------------------------------------------------- +#.INCLUDE : $(PRJ)$/util$/makefile.pmk + +.INCLUDE : settings.mk + +.INCLUDE : ..$/..$/cppumaker.mk + +# --- Files -------------------------------------------------------- + +CFLAGS+=/GX + +OBJFILES= $(OBJ)$/TestSysShExec.obj + +APP1TARGET=$(TARGET) +APP1OBJS= $(OBJFILES) + +APP1STDLIBS+= $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(SALLIB) \ + user32.lib + +APP1DEF= $(MISC)$/$(APP1TARGET).def + +# --- Targets ------------------------------------------------------ +.INCLUDE : target.mk +#.INCLUDE : $(PRJ)$/util$/target.pmk |