Kaydet (Commit) 40544014 authored tarafından Hans-Joachim Lankenau's avatar Hans-Joachim Lankenau

CWS-TOOLING: integrate CWS dv22

...@@ -32,10 +32,8 @@ ...@@ -32,10 +32,8 @@
#include "updatecheckconfig.hxx" #include "updatecheckconfig.hxx"
#include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/beans/XPropertyState.hpp> #include <com/sun/star/beans/XPropertyState.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#ifndef _COM_SUN_STAR_CONTAINER_CHANGESEVENT_HPP_ #include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <com/sun/star/beans/XPropertyState.hpp>
#endif
#include <osl/security.hxx> #include <osl/security.hxx>
#include <osl/time.h> #include <osl/time.h>
...@@ -78,6 +76,8 @@ namespace uno = com::sun::star::uno ; ...@@ -78,6 +76,8 @@ namespace uno = com::sun::star::uno ;
#define RELEASE_NOTE "ReleaseNote" #define RELEASE_NOTE "ReleaseNote"
#define EXTENSION_PREFIX "Extension_" #define EXTENSION_PREFIX "Extension_"
#define PROPERTY_VERSION UNISTRING("Version")
static const sal_Char * const aUpdateEntryProperties[] = { static const sal_Char * const aUpdateEntryProperties[] = {
UPDATE_VERSION, UPDATE_VERSION,
UPDATE_BUILDID, UPDATE_BUILDID,
...@@ -246,19 +246,19 @@ rtl::OUString UpdateCheckConfig::getAllUsersDirectory() ...@@ -246,19 +246,19 @@ rtl::OUString UpdateCheckConfig::getAllUsersDirectory()
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
UpdateCheckConfig::UpdateCheckConfig( const uno::Reference<container::XNameContainer>& xContainer,
UpdateCheckConfig::UpdateCheckConfig( const uno::Reference<container::XNameContainer>& xAvailableUpdates,
const uno::Reference<container::XNameContainer>& xContainer, const uno::Reference<container::XNameContainer>& xIgnoredUpdates,
const ::rtl::Reference< UpdateCheckConfigListener >& rListener const ::rtl::Reference< UpdateCheckConfigListener >& rListener ) :
) : m_xContainer(xContainer), m_rListener(rListener) m_xContainer( xContainer ),
{ m_xAvailableUpdates( xAvailableUpdates ),
} m_xIgnoredUpdates( xIgnoredUpdates ),
m_rListener( rListener )
{}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
UpdateCheckConfig::~UpdateCheckConfig() UpdateCheckConfig::~UpdateCheckConfig()
{ {}
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -295,7 +295,15 @@ UpdateCheckConfig::get( ...@@ -295,7 +295,15 @@ UpdateCheckConfig::get(
UNISTRING("com.sun.star.configuration.ConfigurationUpdateAccess"), aArgumentList ), UNISTRING("com.sun.star.configuration.ConfigurationUpdateAccess"), aArgumentList ),
uno::UNO_QUERY_THROW ); uno::UNO_QUERY_THROW );
return new UpdateCheckConfig( xContainer, rListener ); aProperty.Value = uno::makeAny( UNISTRING("/org.openoffice.Office.ExtensionManager/ExtensionUpdateData/IgnoredUpdates") );
aArgumentList[0] = uno::makeAny( aProperty );
uno::Reference< container::XNameContainer > xIgnoredExt( xConfigProvider->createInstanceWithArguments( UNISTRING("com.sun.star.configuration.ConfigurationUpdateAccess"), aArgumentList ), uno::UNO_QUERY_THROW );
aProperty.Value = uno::makeAny( UNISTRING("/org.openoffice.Office.ExtensionManager/ExtensionUpdateData/AvailableUpdates") );
aArgumentList[0] = uno::makeAny( aProperty );
uno::Reference< container::XNameContainer > xUpdateAvail( xConfigProvider->createInstanceWithArguments( UNISTRING("com.sun.star.configuration.ConfigurationUpdateAccess"), aArgumentList ), uno::UNO_QUERY_THROW );
return new UpdateCheckConfig( xContainer, xUpdateAvail, xIgnoredExt, rListener );
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -627,6 +635,19 @@ UpdateCheckConfig::commitChanges() ...@@ -627,6 +635,19 @@ UpdateCheckConfig::commitChanges()
} }
} }
} }
xChangesBatch = uno::Reference< util::XChangesBatch > ( m_xAvailableUpdates, uno::UNO_QUERY );
if( xChangesBatch.is() && xChangesBatch->hasPendingChanges() )
{
util::ChangesSet aChangesSet = xChangesBatch->getPendingChanges();
xChangesBatch->commitChanges();
}
xChangesBatch = uno::Reference< util::XChangesBatch > ( m_xIgnoredUpdates, uno::UNO_QUERY );
if( xChangesBatch.is() && xChangesBatch->hasPendingChanges() )
{
util::ChangesSet aChangesSet = xChangesBatch->getPendingChanges();
xChangesBatch->commitChanges();
}
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -654,40 +675,66 @@ UpdateCheckConfig::getPendingChanges( ) throw (uno::RuntimeException) ...@@ -654,40 +675,66 @@ UpdateCheckConfig::getPendingChanges( ) throw (uno::RuntimeException)
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void UpdateCheckConfig::storeExtensionVersion( const rtl::OUString& rExtensionName, bool UpdateCheckConfig::storeExtensionVersion( const rtl::OUString& rExtensionName,
const rtl::OUString& rVersion ) const rtl::OUString& rVersion )
{ {
const rtl::OUString aExtName = UNISTRING( EXTENSION_PREFIX ) + rExtensionName; bool bNotify = true;
const uno::Any aValue = uno::makeAny( rVersion );
if( m_xContainer->hasByName( aExtName ) ) if ( m_xAvailableUpdates->hasByName( rExtensionName ) )
m_xContainer->replaceByName( aExtName, aValue ); uno::Reference< beans::XPropertySet >( m_xAvailableUpdates->getByName( rExtensionName ), uno::UNO_QUERY_THROW )->setPropertyValue( PROPERTY_VERSION, uno::Any( rVersion ) );
else else
m_xContainer->insertByName( aExtName, aValue ); {
uno::Reference< beans::XPropertySet > elem( uno::Reference< lang::XSingleServiceFactory >( m_xAvailableUpdates, uno::UNO_QUERY_THROW )->createInstance(), uno::UNO_QUERY_THROW );
elem->setPropertyValue( PROPERTY_VERSION, uno::Any( rVersion ) );
m_xAvailableUpdates->insertByName( rExtensionName, uno::Any( elem ) );
}
if ( m_xIgnoredUpdates->hasByName( rExtensionName ) )
{
::rtl::OUString aIgnoredVersion;
uno::Any aValue( uno::Reference< beans::XPropertySet >( m_xIgnoredUpdates->getByName( rExtensionName ), uno::UNO_QUERY_THROW )->getPropertyValue( PROPERTY_VERSION ) );
aValue >>= aIgnoredVersion;
if ( aIgnoredVersion.getLength() == 0 ) // no version means ignore all updates
bNotify = false;
else if ( aIgnoredVersion == rVersion ) // the user wanted to ignore this update
bNotify = false;
}
commitChanges(); commitChanges();
return bNotify;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool UpdateCheckConfig::checkExtensionVersion( const rtl::OUString& rExtensionName, bool UpdateCheckConfig::checkExtensionVersion( const rtl::OUString& rExtensionName,
const rtl::OUString& rVersion ) const rtl::OUString& rVersion )
{ {
const rtl::OUString aExtName = UNISTRING( EXTENSION_PREFIX ) + rExtensionName; if ( m_xAvailableUpdates->hasByName( rExtensionName ) )
if( m_xContainer->hasByName( aExtName ) )
{ {
uno::Any aValue = m_xContainer->getByName( aExtName ); ::rtl::OUString aStoredVersion;
rtl::OUString aStoredVersion; uno::Any aValue( uno::Reference< beans::XPropertySet >( m_xAvailableUpdates->getByName( rExtensionName ), uno::UNO_QUERY_THROW )->getPropertyValue( PROPERTY_VERSION ) );
aValue >>= aStoredVersion; aValue >>= aStoredVersion;
if ( m_xIgnoredUpdates->hasByName( rExtensionName ) )
{
::rtl::OUString aIgnoredVersion;
uno::Any aValue2( uno::Reference< beans::XPropertySet >( m_xIgnoredUpdates->getByName( rExtensionName ), uno::UNO_QUERY_THROW )->getPropertyValue( PROPERTY_VERSION ) );
aValue2 >>= aIgnoredVersion;
if ( aIgnoredVersion.getLength() == 0 ) // no version means ignore all updates
return false;
else if ( aIgnoredVersion == aStoredVersion ) // the user wanted to ignore this update
return false;
// TODO: else delete ignored entry?
}
if ( isVersionGreater( rVersion, aStoredVersion ) ) if ( isVersionGreater( rVersion, aStoredVersion ) )
return true; return true;
else else
{ {
m_xContainer->removeByName( aExtName ); m_xAvailableUpdates->removeByName( rExtensionName );
commitChanges(); commitChanges();
} }
} }
return false; return false;
} }
......
...@@ -93,7 +93,9 @@ class UpdateCheckConfig : public ::cppu::WeakImplHelper3< ...@@ -93,7 +93,9 @@ class UpdateCheckConfig : public ::cppu::WeakImplHelper3<
::com::sun::star::util::XChangesBatch, ::com::sun::star::util::XChangesBatch,
::com::sun::star::lang::XServiceInfo > ::com::sun::star::lang::XServiceInfo >
{ {
UpdateCheckConfig(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& xContainer, UpdateCheckConfig( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& xContainer,
const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& xAvailableUpdates,
const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& xIgnoredUpdates,
const ::rtl::Reference< UpdateCheckConfigListener >& rListener ); const ::rtl::Reference< UpdateCheckConfigListener >& rListener );
virtual ~UpdateCheckConfig(); virtual ~UpdateCheckConfig();
...@@ -154,7 +156,7 @@ public: ...@@ -154,7 +156,7 @@ public:
static rtl::OUString getAllUsersDirectory(); static rtl::OUString getAllUsersDirectory();
// store and retrieve information about extensions // store and retrieve information about extensions
void storeExtensionVersion( const rtl::OUString& rExtensionName, bool storeExtensionVersion( const rtl::OUString& rExtensionName,
const rtl::OUString& rVersion ); const rtl::OUString& rVersion );
bool checkExtensionVersion( const rtl::OUString& rExtensionName, bool checkExtensionVersion( const rtl::OUString& rExtensionName,
const rtl::OUString& rVersion ); const rtl::OUString& rVersion );
...@@ -205,6 +207,8 @@ private: ...@@ -205,6 +207,8 @@ private:
static bool isVersionGreater( const rtl::OUString& rVersion1, const rtl::OUString& rVersion2 ); static bool isVersionGreater( const rtl::OUString& rVersion1, const rtl::OUString& rVersion2 );
const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > m_xContainer; const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > m_xContainer;
const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > m_xAvailableUpdates;
const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > m_xIgnoredUpdates;
const ::rtl::Reference< UpdateCheckConfigListener > m_rListener; const ::rtl::Reference< UpdateCheckConfigListener > m_rListener;
}; };
......
...@@ -255,16 +255,18 @@ checkForUpdates( ...@@ -255,16 +255,18 @@ checkForUpdates(
bool storeExtensionUpdateInfos( const uno::Reference< uno::XComponentContext > & rxContext, bool storeExtensionUpdateInfos( const uno::Reference< uno::XComponentContext > & rxContext,
const uno::Sequence< uno::Sequence< rtl::OUString > > &rUpdateInfos ) const uno::Sequence< uno::Sequence< rtl::OUString > > &rUpdateInfos )
{ {
bool bNotify = false;
if ( rUpdateInfos.hasElements() ) if ( rUpdateInfos.hasElements() )
{ {
rtl::Reference< UpdateCheckConfig > aConfig = UpdateCheckConfig::get( rxContext ); rtl::Reference< UpdateCheckConfig > aConfig = UpdateCheckConfig::get( rxContext );
for ( sal_Int32 i = rUpdateInfos.getLength() - 1; i >= 0; i-- ) for ( sal_Int32 i = rUpdateInfos.getLength() - 1; i >= 0; i-- )
{ {
aConfig->storeExtensionVersion( rUpdateInfos[i][0], rUpdateInfos[i][1] ); bNotify |= aConfig->storeExtensionVersion( rUpdateInfos[i][0], rUpdateInfos[i][1] );
} }
} }
return rUpdateInfos.hasElements(); return bNotify;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -289,9 +291,9 @@ bool checkForExtensionUpdates( const uno::Reference< uno::XComponentContext > & ...@@ -289,9 +291,9 @@ bool checkForExtensionUpdates( const uno::Reference< uno::XComponentContext > &
if ( !xInfoProvider.is() ) return false; if ( !xInfoProvider.is() ) return false;
aUpdateList = xInfoProvider->isUpdateAvailable( ::rtl::OUString() ); aUpdateList = xInfoProvider->isUpdateAvailable( ::rtl::OUString() );
storeExtensionUpdateInfos( rxContext, aUpdateList ); bool bNotify = storeExtensionUpdateInfos( rxContext, aUpdateList );
return aUpdateList.hasElements(); return bNotify;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment