INTEGRATION: CWS onlineupdate3 (1.1.2); FILE ADDED
2006/07/21 04:57:46 obr 1.1.2.1: #i66949# added config services to communicate with tools/options
This commit is contained in:
parent
d031d0b075
commit
27184a1123
2 changed files with 353 additions and 0 deletions
243
extensions/source/update/check/updatecheckconfig.cxx
Normal file
243
extensions/source/update/check/updatecheckconfig.cxx
Normal file
|
@ -0,0 +1,243 @@
|
|||
/*************************************************************************
|
||||
*
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* $RCSfile: updatecheckconfig.cxx,v $
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
* last change: $Author: ihi $ $Date: 2006-08-04 09:56:29 $
|
||||
*
|
||||
* The Contents of this file are made available subject to
|
||||
* the terms of GNU Lesser General Public License Version 2.1.
|
||||
*
|
||||
*
|
||||
* GNU Lesser General Public License Version 2.1
|
||||
* =============================================
|
||||
* Copyright 2005 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
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
|
||||
#include "updatecheckconfig.hxx"
|
||||
|
||||
#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
|
||||
#include <com/sun/star/beans/PropertyValue.hpp>
|
||||
#endif
|
||||
|
||||
#include <osl/security.hxx>
|
||||
|
||||
namespace container = com::sun::star::container ;
|
||||
namespace beans = com::sun::star::beans ;
|
||||
namespace lang = com::sun::star::lang ;
|
||||
namespace util = com::sun::star::util ;
|
||||
namespace uno = com::sun::star::uno ;
|
||||
|
||||
#define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
UpdateCheckConfig::UpdateCheckConfig(const uno::Reference<uno::XComponentContext>& xContext)
|
||||
{
|
||||
if( !xContext.is() )
|
||||
throw uno::RuntimeException(
|
||||
UNISTRING( "UpdateCheckConfig: empty component context" ), *this );
|
||||
|
||||
uno::Reference< lang::XMultiComponentFactory > xServiceManager(xContext->getServiceManager());
|
||||
|
||||
if( !xServiceManager.is() )
|
||||
throw uno::RuntimeException(
|
||||
UNISTRING( "UpdateCheckConfig: unable to obtain service manager from component context" ), *this );
|
||||
|
||||
uno::Reference< lang::XMultiServiceFactory > xConfigProvider(
|
||||
xServiceManager->createInstanceWithContext( UNISTRING( "com.sun.star.configuration.ConfigurationProvider" ), xContext ),
|
||||
uno::UNO_QUERY_THROW);
|
||||
|
||||
beans::PropertyValue aProperty;
|
||||
aProperty.Name = UNISTRING( "nodepath" );
|
||||
aProperty.Value = uno::makeAny( UNISTRING("org.openoffice.Office.Jobs/Jobs/UpdateCheck/Arguments") );
|
||||
|
||||
uno::Sequence< uno::Any > aArgumentList( 1 );
|
||||
aArgumentList[0] = uno::makeAny( aProperty );
|
||||
|
||||
m_xUpdateAccess = uno::Reference< container::XNameReplace > (
|
||||
xConfigProvider->createInstanceWithArguments(
|
||||
UNISTRING("com.sun.star.configuration.ConfigurationUpdateAccess"), aArgumentList ),
|
||||
uno::UNO_QUERY_THROW );
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
UpdateCheckConfig::~UpdateCheckConfig()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
uno::Sequence< rtl::OUString >
|
||||
UpdateCheckConfig::getServiceNames()
|
||||
{
|
||||
uno::Sequence< rtl::OUString > aServiceList(1);
|
||||
aServiceList[0] = UNISTRING( "com.sun.star.setup.UpdateCheckConfig");
|
||||
return aServiceList;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
rtl::OUString
|
||||
UpdateCheckConfig::getImplName()
|
||||
{
|
||||
return UNISTRING( "vnd.sun.UpdateCheckConfig");
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
uno::Type SAL_CALL
|
||||
UpdateCheckConfig::getElementType() throw (uno::RuntimeException)
|
||||
{
|
||||
return m_xUpdateAccess->getElementType();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
sal_Bool SAL_CALL
|
||||
UpdateCheckConfig::hasElements() throw (uno::RuntimeException)
|
||||
{
|
||||
return m_xUpdateAccess->hasElements();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
uno::Any SAL_CALL
|
||||
UpdateCheckConfig::getByName( const ::rtl::OUString& aName )
|
||||
throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
|
||||
{
|
||||
uno::Any aValue = m_xUpdateAccess->getByName( aName );
|
||||
|
||||
// Provide dynamic default value
|
||||
if( aName.equalsAscii("DownloadDestination") )
|
||||
{
|
||||
rtl::OUString aStr;
|
||||
aValue >>= aStr;
|
||||
|
||||
if( aStr.getLength() == 0 )
|
||||
{
|
||||
// This should become the desktop ..
|
||||
osl::Security().getHomeDir(aStr);
|
||||
aValue = uno::makeAny(aStr);
|
||||
}
|
||||
}
|
||||
|
||||
return aValue;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
uno::Sequence< ::rtl::OUString > SAL_CALL
|
||||
UpdateCheckConfig::getElementNames( ) throw (uno::RuntimeException)
|
||||
{
|
||||
return m_xUpdateAccess->getElementNames();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
sal_Bool SAL_CALL
|
||||
UpdateCheckConfig::hasByName( const ::rtl::OUString& aName ) throw (uno::RuntimeException)
|
||||
{
|
||||
return m_xUpdateAccess->hasByName( aName );
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void SAL_CALL
|
||||
UpdateCheckConfig::replaceByName( const ::rtl::OUString& aName, const uno::Any& aElement )
|
||||
throw (lang::IllegalArgumentException, container::NoSuchElementException,
|
||||
lang::WrappedTargetException, uno::RuntimeException)
|
||||
{
|
||||
return m_xUpdateAccess->replaceByName( aName, aElement );
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// XChangesBatch
|
||||
void SAL_CALL
|
||||
UpdateCheckConfig::commitChanges( )
|
||||
throw (lang::WrappedTargetException, uno::RuntimeException)
|
||||
{
|
||||
uno::Reference< util::XChangesBatch > xChangesBatch(m_xUpdateAccess, uno::UNO_QUERY);
|
||||
if( xChangesBatch.is() )
|
||||
xChangesBatch->commitChanges();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
sal_Bool SAL_CALL
|
||||
UpdateCheckConfig::hasPendingChanges( ) throw (uno::RuntimeException)
|
||||
{
|
||||
uno::Reference< util::XChangesBatch > xChangesBatch(m_xUpdateAccess, uno::UNO_QUERY);
|
||||
if( xChangesBatch.is() )
|
||||
return xChangesBatch->hasPendingChanges();
|
||||
|
||||
return sal_False;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
uno::Sequence< util::ElementChange > SAL_CALL
|
||||
UpdateCheckConfig::getPendingChanges( ) throw (uno::RuntimeException)
|
||||
{
|
||||
uno::Reference< util::XChangesBatch > xChangesBatch(m_xUpdateAccess, uno::UNO_QUERY);
|
||||
if( xChangesBatch.is() )
|
||||
return xChangesBatch->getPendingChanges();
|
||||
|
||||
return uno::Sequence< util::ElementChange >();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
rtl::OUString SAL_CALL
|
||||
UpdateCheckConfig::getImplementationName() throw (uno::RuntimeException)
|
||||
{
|
||||
return getImplName();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
sal_Bool SAL_CALL
|
||||
UpdateCheckConfig::supportsService(rtl::OUString const & serviceName)
|
||||
throw (uno::RuntimeException)
|
||||
{
|
||||
uno::Sequence< rtl::OUString > aServiceNameList = getServiceNames();
|
||||
|
||||
for( sal_Int32 n=0; n < aServiceNameList.getLength(); n++ )
|
||||
if( aServiceNameList[n].equals(serviceName) )
|
||||
return sal_True;
|
||||
|
||||
return sal_False;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
uno::Sequence< rtl::OUString > SAL_CALL
|
||||
UpdateCheckConfig::getSupportedServiceNames() throw (uno::RuntimeException)
|
||||
{
|
||||
return getServiceNames();
|
||||
}
|
||||
|
110
extensions/source/update/check/updatecheckconfig.hxx
Normal file
110
extensions/source/update/check/updatecheckconfig.hxx
Normal file
|
@ -0,0 +1,110 @@
|
|||
/*************************************************************************
|
||||
*
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* $RCSfile: updatecheckconfig.hxx,v $
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
* last change: $Author: ihi $ $Date: 2006-08-04 09:56:38 $
|
||||
*
|
||||
* The Contents of this file are made available subject to
|
||||
* the terms of GNU Lesser General Public License Version 2.1.
|
||||
*
|
||||
*
|
||||
* GNU Lesser General Public License Version 2.1
|
||||
* =============================================
|
||||
* Copyright 2005 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
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
#ifndef _CPPUHELPER_IMPLBASE3_HXX_
|
||||
#include <cppuhelper/implbase3.hxx>
|
||||
#endif
|
||||
|
||||
#ifndef _COM_SUN_STAR_CONTAINER_XNAMEREPLACE_HPP_
|
||||
#include <com/sun/star/container/XNameReplace.hpp>
|
||||
#endif
|
||||
|
||||
#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
|
||||
#include <com/sun/star/lang/XServiceInfo.hpp>
|
||||
#endif
|
||||
|
||||
#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_
|
||||
#include <com/sun/star/uno/XComponentContext.hpp>
|
||||
#endif
|
||||
|
||||
#ifndef _COM_SUN_STAR_UTIL_XCHANGESBATCH_HPP_
|
||||
#include <com/sun/star/util/XChangesBatch.hpp>
|
||||
#endif
|
||||
|
||||
class UpdateCheckConfig : public ::cppu::WeakImplHelper3<
|
||||
::com::sun::star::container::XNameReplace,
|
||||
::com::sun::star::util::XChangesBatch,
|
||||
::com::sun::star::lang::XServiceInfo >
|
||||
{
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > m_xUpdateAccess;
|
||||
|
||||
public:
|
||||
UpdateCheckConfig(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext);
|
||||
virtual ~UpdateCheckConfig();
|
||||
|
||||
static ::com::sun::star::uno::Sequence< rtl::OUString > getServiceNames();
|
||||
static rtl::OUString getImplName();
|
||||
|
||||
// XElementAccess
|
||||
virtual ::com::sun::star::uno::Type SAL_CALL getElementType( )
|
||||
throw (::com::sun::star::uno::RuntimeException);
|
||||
virtual sal_Bool SAL_CALL hasElements( )
|
||||
throw (::com::sun::star::uno::RuntimeException);
|
||||
|
||||
// XNameAccess
|
||||
virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
|
||||
throw (::com::sun::star::container::NoSuchElementException,
|
||||
::com::sun::star::lang::WrappedTargetException,
|
||||
::com::sun::star::uno::RuntimeException);
|
||||
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( )
|
||||
throw (::com::sun::star::uno::RuntimeException);
|
||||
virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
|
||||
throw (::com::sun::star::uno::RuntimeException);
|
||||
|
||||
// XNameReplace
|
||||
virtual void SAL_CALL replaceByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement )
|
||||
throw (::com::sun::star::lang::IllegalArgumentException,
|
||||
::com::sun::star::container::NoSuchElementException,
|
||||
::com::sun::star::lang::WrappedTargetException,
|
||||
::com::sun::star::uno::RuntimeException);
|
||||
|
||||
// XChangesBatch
|
||||
virtual void SAL_CALL commitChanges( )
|
||||
throw (::com::sun::star::lang::WrappedTargetException,
|
||||
::com::sun::star::uno::RuntimeException);
|
||||
virtual ::sal_Bool SAL_CALL hasPendingChanges( )
|
||||
throw (::com::sun::star::uno::RuntimeException);
|
||||
virtual ::com::sun::star::uno::Sequence< ::com::sun::star::util::ElementChange > SAL_CALL getPendingChanges( )
|
||||
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(rtl::OUString const & serviceName)
|
||||
throw (::com::sun::star::uno::RuntimeException);
|
||||
virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames()
|
||||
throw (::com::sun::star::uno::RuntimeException);
|
||||
};
|
||||
|
Loading…
Reference in a new issue