diff options
author | Daniel Boelzle <dbo@openoffice.org> | 2001-05-07 14:07:01 +0000 |
---|---|---|
committer | Daniel Boelzle <dbo@openoffice.org> | 2001-05-07 14:07:01 +0000 |
commit | ca133d88841acd4680e6290556504e58c59703b3 (patch) | |
tree | 71042e8196ce242d9c9328b523020b4b710389ed /cppu/inc | |
parent | 5675e380b626619fc428c39e550dc746ddf1b478 (diff) |
revisited current context impl
Diffstat (limited to 'cppu/inc')
-rw-r--r-- | cppu/inc/uno/current_context.h | 23 | ||||
-rw-r--r-- | cppu/inc/uno/current_context.hxx | 59 |
2 files changed, 52 insertions, 30 deletions
diff --git a/cppu/inc/uno/current_context.h b/cppu/inc/uno/current_context.h index c540544d3378..f2edc275c0f6 100644 --- a/cppu/inc/uno/current_context.h +++ b/cppu/inc/uno/current_context.h @@ -2,9 +2,9 @@ * * $RCSfile: current_context.h,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: dbo $ $Date: 2001-03-28 10:46:06 $ + * last change: $Author: dbo $ $Date: 2001-05-07 15:06:56 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -70,17 +70,30 @@ extern "C" { #endif -/** Gets the current thread's context. +/** Gets the current task's context. - @param ppCompEnv out param current context of type com.sun.star.uno.XCurrentContext + @param ppCurrentContext inout param current context of type com.sun.star.uno.XCurrentContext @param pEnvTypeName type name of returned interface's environment @param pEnvContext context of returned interface's environment (commonly 0) + @return true, if context ref was transferred (even if null ref) */ -void SAL_CALL uno_getCurrentContext( +sal_Bool SAL_CALL uno_getCurrentContext( void ** ppCurrentContext, rtl_uString * pEnvTypeName, void * pEnvContext ) SAL_THROW_EXTERN_C(); +/** Sets the current task's context. + + @param pCurrentContext in param current context of type com.sun.star.uno.XCurrentContext + @param pEnvTypeName type name of interface's environment + @param pEnvContext context of interface's environment (commonly 0) + @return true, if context ref was transferred (even if null ref) +*/ +sal_Bool SAL_CALL uno_setCurrentContext( + void * pCurrentContext, + rtl_uString * pEnvTypeName, void * pEnvContext ) + SAL_THROW_EXTERN_C(); + #ifdef __cplusplus } #endif diff --git a/cppu/inc/uno/current_context.hxx b/cppu/inc/uno/current_context.hxx index 0859c2ca4b1f..ca0282b0ddb0 100644 --- a/cppu/inc/uno/current_context.hxx +++ b/cppu/inc/uno/current_context.hxx @@ -2,9 +2,9 @@ * * $RCSfile: current_context.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: dbo $ $Date: 2001-03-09 12:10:56 $ + * last change: $Author: dbo $ $Date: 2001-05-07 15:06:56 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -61,9 +61,7 @@ #ifndef _UNO_CURRENT_CONTEXT_HXX_ #define _UNO_CURRENT_CONTEXT_HXX_ -#include <osl/diagnose.h> #include <uno/current_context.h> - #include <cppu/macros.hxx> #include <com/sun/star/uno/XCurrentContext.hpp> @@ -82,38 +80,49 @@ namespace star namespace uno { -/** Current context. +/** Getting the current context. + + @return current context or null ref, if none is set */ -inline Reference< XCurrentContext > SAL_CALL getCurrentContext() SAL_THROW( () ) +inline Reference< XCurrentContext > SAL_CALL getCurrentContext() + SAL_THROW( () ) { - ::rtl::OUString aEnvTypeName( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) ); - Reference< XCurrentContext > xRet; + ::rtl::OUString aEnvTypeName( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) ); ::uno_getCurrentContext( (void **)&xRet, aEnvTypeName.pData, 0 ); - return xRet; } +/** Setting the current context. -/** Security support. + @param xContext current context to be set + @return true, if context has been successfully set */ -inline void SAL_CALL checkPermission( - const ::com::sun::star::security::Permission & rPerm ) - SAL_THROW( (::com::sun::star::security::AccessControlException) ) +inline bool SAL_CALL setCurrentContext( + Reference< XCurrentContext > const & xContext ) + SAL_THROW( () ) { - Reference< XCurrentContext > xContext( getCurrentContext() ); - OSL_ENSURE( xContext.is(), "### cannot get current thread's uno context!" ); - - if (xContext.is()) - { - Reference< ::com::sun::star::security::XAccessController > xAC( - xContext->getAccessController() ); - if (xAC.is()) // access controller installed? - { - xAC->checkPermission( rPerm ); - } - } + ::rtl::OUString aEnvTypeName( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) ); + return (::uno_setCurrentContext( xContext.get(), aEnvTypeName.pData, 0 ) != sal_False); } +// /** Permission check. +// */ +// inline void SAL_CALL checkPermission( +// ::com::sun::star::security::Permission const & rPerm ) +// SAL_THROW( (::com::sun::star::security::AccessControlException) ) +// { +// Reference< XCurrentContext > xContext( getCurrentContext() ); +// if (xContext.is()) +// { +// Reference< ::com::sun::star::security::XAccessController > xAC; +// if (xContext->getValueByName( OUString( +// RTL_CONSTASCII_USTRINGPARAM("com.sun.star.security.AccessController") ) ) >>= xAC) +// { +// xAC->checkPermission( rPerm ); +// } +// } +// } + } } } |