summaryrefslogtreecommitdiff
path: root/extensions/source/update/check/updatecheckconfig.cxx
diff options
context:
space:
mode:
authorIvo Hinkelmann <ihi@openoffice.org>2006-08-04 08:56:38 +0000
committerIvo Hinkelmann <ihi@openoffice.org>2006-08-04 08:56:38 +0000
commit27184a1123144bf41fde65cc2bc6bef83f0dd57c (patch)
tree0e0627e90401a79ff4b1c5fb104b1fe6df8e70b8 /extensions/source/update/check/updatecheckconfig.cxx
parentd031d0b075f9216c64112148628ade6a3d3f99d5 (diff)
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
Diffstat (limited to 'extensions/source/update/check/updatecheckconfig.cxx')
-rw-r--r--extensions/source/update/check/updatecheckconfig.cxx243
1 files changed, 243 insertions, 0 deletions
diff --git a/extensions/source/update/check/updatecheckconfig.cxx b/extensions/source/update/check/updatecheckconfig.cxx
new file mode 100644
index 000000000000..eb5b0dfa12a7
--- /dev/null
+++ b/extensions/source/update/check/updatecheckconfig.cxx
@@ -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();
+}
+