diff options
author | Norbert Thiebaud <nthiebaud@gmail.com> | 2010-10-21 15:34:02 -0500 |
---|---|---|
committer | Norbert Thiebaud <nthiebaud@gmail.com> | 2010-10-25 19:55:34 -0500 |
commit | 119873328acd70ca3569c21a0b1fe36277e8bf4c (patch) | |
tree | d4f07cf14521a880eb69a25208af8b817aa94b55 /basic | |
parent | 6cd025d44e9464716c8645f435966baca4caf921 (diff) |
convert vos/process.hxx and related API
Diffstat (limited to 'basic')
-rw-r--r-- | basic/inc/basic/process.hxx | 11 | ||||
-rw-r--r-- | basic/inc/pch/precompiled_basic.hxx | 5 | ||||
-rw-r--r-- | basic/source/app/process.cxx | 109 | ||||
-rw-r--r-- | basic/source/runtime/methods.cxx | 81 |
4 files changed, 114 insertions, 92 deletions
diff --git a/basic/inc/basic/process.hxx b/basic/inc/basic/process.hxx index 9a593322b896..df698096b2d8 100644 --- a/basic/inc/basic/process.hxx +++ b/basic/inc/basic/process.hxx @@ -29,7 +29,7 @@ #define _PROCESS_HXX #include <tools/string.hxx> -#include <vos/process.hxx> +#include <osl/process.h> #include <map> @@ -39,9 +39,12 @@ typedef Environment::value_type EnvironmentVariable; class Process { // Internal members and methods - vos::OArgumentList *pArgumentList; - vos::OEnvironment *pEnvList; - vos::OProcess *pProcess; + sal_uInt32 m_nArgumentCount; + rtl_uString **m_pArgumentList; + sal_uInt32 m_nEnvCount; + rtl_uString **m_pEnvList; + rtl::OUString m_aProcessName; + oslProcess m_pProcess; BOOL ImplIsRunning(); long ImplGetExitCode(); BOOL bWasGPF; diff --git a/basic/inc/pch/precompiled_basic.hxx b/basic/inc/pch/precompiled_basic.hxx index 502097724f9c..77ee37b7a470 100644 --- a/basic/inc/pch/precompiled_basic.hxx +++ b/basic/inc/pch/precompiled_basic.hxx @@ -148,6 +148,7 @@ #include "i18npool/lang.h" +#include "osl/diagnose.h" #include "osl/file.hxx" #include "osl/module.h" #include "osl/mutex.hxx" @@ -275,10 +276,6 @@ #include "vcl/wintypes.hxx" #include "vcl/wrkwin.hxx" -#include "osl/diagnose.h" -#include "osl/mutex.hxx" -#include "vos/process.hxx" - #include "xmlscript/xmldlg_imexp.hxx" #include "xmlscript/xmllib_imexp.hxx" #include "xmlscript/xmlmod_imexp.hxx" diff --git a/basic/source/app/process.cxx b/basic/source/app/process.cxx index 7054fc99ff12..837820eb1234 100644 --- a/basic/source/app/process.cxx +++ b/basic/source/app/process.cxx @@ -36,10 +36,10 @@ #include <tools/postwin.h> #endif #include <tools/errcode.hxx> -#include <vos/process.hxx> #include <basic/sbxcore.hxx> #include <tools/string.hxx> #include <osl/file.hxx> +#include <osl/process.h> #include <basic/ttstrhlp.hxx> @@ -51,29 +51,46 @@ #include <basic/process.hxx> Process::Process() -: pArgumentList( NULL ) -, pEnvList( NULL ) -, pProcess( NULL ) +: m_nArgumentCount( 0 ) +, m_pArgumentList( NULL ) +, m_nEnvCount( 0 ) +, m_pEnvList( NULL ) +, m_aProcessName() +, m_pProcess( NULL ) , bWasGPF( FALSE ) , bHasBeenStarted( FALSE ) { } +#define FREE_USTRING_LIST( count, list ) \ + if ( count && list ) \ + { \ + for ( unsigned int i = 0; i < count; ++i ) \ + { \ + rtl_uString_release( list[i] ); \ + list[i] = NULL; \ + } \ + delete[] list; \ + } \ + count = 0; \ + list = NULL; + Process::~Process() { -// delete pArgumentList; -// delete pEnvList; - delete pProcess; + FREE_USTRING_LIST( m_nArgumentCount, m_pArgumentList ); + FREE_USTRING_LIST( m_nEnvCount, m_pEnvList ); + if ( m_pProcess ) + osl_freeProcessHandle( m_pProcess ); } BOOL Process::ImplIsRunning() { - if ( pProcess && bHasBeenStarted ) + if ( m_pProcess && bHasBeenStarted ) { - vos::OProcess::TProcessInfo aProcessInfo; - pProcess->getInfo( vos::OProcess::TData_ExitCode, &aProcessInfo ); - if ( !(aProcessInfo.Fields & vos::OProcess::TData_ExitCode) ) + oslProcessInfo aProcessInfo; + osl_getProcessInfo(m_pProcess, osl_Process_EXITCODE, &aProcessInfo ); + if ( !(aProcessInfo.Fields & osl_Process_EXITCODE) ) return TRUE; else return FALSE; @@ -84,11 +101,11 @@ BOOL Process::ImplIsRunning() long Process::ImplGetExitCode() { - if ( pProcess ) + if ( m_pProcess ) { - vos::OProcess::TProcessInfo aProcessInfo; - pProcess->getInfo( vos::OProcess::TData_ExitCode, &aProcessInfo ); - if ( !(aProcessInfo.Fields & vos::OProcess::TData_ExitCode) ) + oslProcessInfo aProcessInfo; + osl_getProcessInfo(m_pProcess, osl_Process_EXITCODE, &aProcessInfo ); + if ( !(aProcessInfo.Fields & osl_Process_EXITCODE) ) SbxBase::SetError( SbxERR_NO_ACTIVE_OBJECT ); return aProcessInfo.Code; } @@ -102,13 +119,14 @@ long Process::ImplGetExitCode() void Process::SetImage( const String &aAppPath, const String &aAppParams, const Environment *pEnv ) { // Set image file of executable - if ( pProcess && ImplIsRunning() ) + if ( m_pProcess && ImplIsRunning() ) SbxBase::SetError( SbxERR_NO_ACTIVE_OBJECT ); else { - delete pArgumentList; pArgumentList = NULL; - delete pEnvList; pEnvList = NULL; - delete pProcess; pProcess = NULL; + FREE_USTRING_LIST( m_nArgumentCount, m_pArgumentList ); + FREE_USTRING_LIST( m_nEnvCount, m_pEnvList ); + osl_freeProcessHandle( m_pProcess ); + m_pProcess = NULL; xub_StrLen i, nCount = aAppParams.GetQuotedTokenCount( CUniString("\"\"" ), ' ' ); ::rtl::OUString *pParamList = new ::rtl::OUString[nCount]; @@ -123,42 +141,45 @@ void Process::SetImage( const String &aAppPath, const String &aAppParams, const nParamCount++; } } - pArgumentList = new vos::OArgumentList( pParamList, nCount ); - + m_nArgumentCount = nParamCount; + m_pArgumentList = new rtl_uString*[m_nArgumentCount]; + for ( i = 0 ; i < m_nArgumentCount ; i++ ) + { + m_pArgumentList[i] = NULL; + rtl_uString_assign( &(m_pArgumentList[i]), pParamList[i].pData ); + } + delete [] pParamList; - ::rtl::OUString *pEnvArray = NULL; if ( pEnv ) { - pEnvArray = new ::rtl::OUString[pEnv->size()]; + m_pEnvList = new rtl_uString*[pEnv->size()]; - xub_StrLen nEnvCount = 0; + m_nEnvCount = 0; Environment::const_iterator aIter = pEnv->begin(); while ( aIter != pEnv->end() ) { ::rtl::OUString aTemp = ::rtl::OUString( (*aIter).first ); aTemp += ::rtl::OUString::createFromAscii( "=" ); aTemp += ::rtl::OUString( (*aIter).second ); - pEnvArray[nEnvCount] = aTemp; - nEnvCount++; + m_pEnvList[m_nEnvCount] = NULL; + rtl_uString_assign( &(m_pEnvList[m_nEnvCount]), aTemp.pData ); + m_nEnvCount++; aIter++; } - pEnvList = new vos::OEnvironment( pEnvArray, nEnvCount ); } ::rtl::OUString aNormalizedAppPath; osl::FileBase::getFileURLFromSystemPath( ::rtl::OUString(aAppPath), aNormalizedAppPath ); - pProcess = new vos::OProcess( aNormalizedAppPath ); + m_aProcessName = aNormalizedAppPath;; bHasBeenStarted = FALSE; - delete [] pParamList; - delete [] pEnvArray; } } BOOL Process::Start() { // Start program BOOL bSuccess=FALSE; - if ( pProcess && !ImplIsRunning() ) + if ( m_pProcess && !ImplIsRunning() ) { bWasGPF = FALSE; #ifdef WNT @@ -167,17 +188,19 @@ BOOL Process::Start() try { #endif - if ( pEnvList ) - { - bSuccess = pProcess->execute( (vos::OProcess::TProcessOption)(vos::OProcess::TOption_SearchPath), - *pArgumentList, - *pEnvList ) == vos::OProcess::E_None; - } - else - { - bSuccess = pProcess->execute( (vos::OProcess::TProcessOption)(vos::OProcess::TOption_SearchPath), - *pArgumentList ) == vos::OProcess::E_None; - } + bSuccess = osl_executeProcess( + m_aProcessName.pData, + m_pArgumentList, + m_nArgumentCount, + osl_Process_SEARCHPATH + /*| osl_Process_DETACHED*/ + /*| osl_Process_WAIT*/, + NULL, + NULL, + m_pEnvList, + m_nEnvCount, + &m_pProcess ) == osl_Process_E_None; + #ifdef WNT } catch( ... ) @@ -216,7 +239,7 @@ BOOL Process::WasGPF() BOOL Process::Terminate() { if ( ImplIsRunning() ) - return pProcess->terminate() == vos::OProcess::E_None; + return osl_terminateProcess(m_pProcess) == osl_Process_E_None; return TRUE; } diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 475ea515d313..1e06e74d48ff 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -32,7 +32,7 @@ #include <tools/date.hxx> #include <basic/sbxvar.hxx> -#include <vos/process.hxx> +#include <osl/process.h> #include <vcl/svapp.hxx> #include <vcl/settings.hxx> #include <vcl/sound.hxx> @@ -3486,8 +3486,8 @@ RTLFUNC(Shell) } else { - USHORT nOptions = vos::OProcess::TOption_SearchPath| - vos::OProcess::TOption_Detached; + oslProcessOption nOptions = osl_Process_SEARCHPATH | osl_Process_DETACHED; + String aCmdLine = rPar.Get(1)->GetString(); // Zusaetzliche Parameter anhaengen, es muss eh alles geparsed werden if( nArgCount >= 4 ) @@ -3564,76 +3564,75 @@ RTLFUNC(Shell) nWinStyle = rPar.Get(2)->GetInteger(); switch( nWinStyle ) { - case 2: - nOptions |= vos::OProcess::TOption_Minimized; - break; - case 3: - nOptions |= vos::OProcess::TOption_Maximized; - break; - case 10: - nOptions |= vos::OProcess::TOption_FullScreen; - break; + case 2: + nOptions |= osl_Process_MINIMIZED; + break; + case 3: + nOptions |= osl_Process_MAXIMIZED; + break; + case 10: + nOptions |= osl_Process_FULLSCREEN; + break; } BOOL bSync = FALSE; if( nArgCount >= 5 ) bSync = rPar.Get(4)->GetBool(); if( bSync ) - nOptions |= vos::OProcess::TOption_Wait; + nOptions |= osl_Process_WAIT; } - vos::OProcess::TProcessOption eOptions = - (vos::OProcess::TProcessOption)nOptions; - // #72471 Parameter aufbereiten std::list<String>::const_iterator iter = aTokenList.begin(); const String& rStr = *iter; ::rtl::OUString aOUStrProg( rStr.GetBuffer(), rStr.Len() ); - String aOUStrProgUNC = getFullPathUNC( aOUStrProg ); + ::rtl::OUString aOUStrProgUNC = getFullPathUNC( aOUStrProg ); iter++; USHORT nParamCount = sal::static_int_cast< USHORT >( aTokenList.size() - 1 ); - ::rtl::OUString* pArgumentList = NULL; - //const char** pParamList = NULL; + rtl_uString** pParamList = NULL; if( nParamCount ) { - pArgumentList = new ::rtl::OUString[ nParamCount ]; - //pParamList = new const char*[ nParamCount ]; - USHORT iList = 0; - while( iter != aTokenList.end() ) + pParamList = new rtl_uString*[nParamCount]; + for(int iList = 0; iter != aTokenList.end(); ++iList, ++iter) { const String& rParamStr = (*iter); - pArgumentList[iList++] = ::rtl::OUString( rParamStr.GetBuffer(), rParamStr.Len() ); - //pParamList[iList++] = (*iter).GetStr(); - iter++; + const ::rtl::OUString aTempStr( rParamStr.GetBuffer(), rParamStr.Len()); + pParamList[iList] = NULL; + rtl_uString_assign(&(pParamList[iList]), aTempStr.pData); } } - //const char* pParams = aParams.Len() ? aParams.GetStr() : 0; - vos::OProcess* pApp; - pApp = new vos::OProcess( aOUStrProgUNC ); - BOOL bSucc; - if( nParamCount == 0 ) - { - bSucc = pApp->execute( eOptions ) == vos::OProcess::E_None; - } - else + oslProcess pApp; + BOOL bSucc = osl_executeProcess( + aOUStrProgUNC.pData, + pParamList, + nParamCount, + nOptions, + NULL, + NULL, + NULL, 0, + &pApp ) == osl_Process_E_None; + + osl_freeProcessHandle( pApp ); + + for(int j = 0; i < nParamCount; i++) { - vos::OArgumentList aArgList( pArgumentList, nParamCount ); - bSucc = pApp->execute( eOptions, aArgList ) == vos::OProcess::E_None; + rtl_uString_release(pParamList[j]); + pParamList[j] = NULL; } + long nResult = 0; - vos::OProcess::TProcessInfo aInfo; // We should return the identifier of the executing process when is running VBA, because method Shell(...) returns it in Excel. - if ( bSucc && SbiRuntime::isVBAEnabled() && pApp->getInfo( vos::OProcess::TData_Identifier, &aInfo ) == vos::OProcess::E_None ) + if ( bSucc && SbiRuntime::isVBAEnabled()) { + oslProcessInfo aInfo; + osl_getProcessInfo( pApp, osl_Process_IDENTIFIER, &aInfo ); nResult = aInfo.Ident; } - delete pApp; - delete[] pArgumentList; if( !bSucc ) StarBASIC::Error( SbERR_FILE_NOT_FOUND ); else |