summaryrefslogtreecommitdiff
path: root/extensions/source/update/check
diff options
context:
space:
mode:
authorDirk Voelzke <dv@openoffice.org>2010-10-28 11:15:18 +0200
committerDirk Voelzke <dv@openoffice.org>2010-10-28 11:15:18 +0200
commit37e081573b530252985b45af8a00169c7c14c745 (patch)
tree8374c421c49a352a3d296bafb7eeaf13a247329e /extensions/source/update/check
parentfaea3cb5a9d96bfc897606130cfcb93e61db54bb (diff)
#dv22#i115288# Allow user to ignore updates for an extension
Diffstat (limited to 'extensions/source/update/check')
-rwxr-xr-x[-rw-r--r--]extensions/source/update/check/Jobs.xcu0
-rw-r--r--[-rwxr-xr-x]extensions/source/update/check/download.cxx0
-rwxr-xr-xextensions/source/update/check/updatecheckconfig.cxx103
-rwxr-xr-x[-rw-r--r--]extensions/source/update/check/updatecheckconfig.hxx10
-rwxr-xr-x[-rw-r--r--]extensions/source/update/check/updateprotocol.cxx10
5 files changed, 88 insertions, 35 deletions
diff --git a/extensions/source/update/check/Jobs.xcu b/extensions/source/update/check/Jobs.xcu
index ed324650c..ed324650c 100644..100755
--- a/extensions/source/update/check/Jobs.xcu
+++ b/extensions/source/update/check/Jobs.xcu
diff --git a/extensions/source/update/check/download.cxx b/extensions/source/update/check/download.cxx
index c4ff5dd4b..c4ff5dd4b 100755..100644
--- a/extensions/source/update/check/download.cxx
+++ b/extensions/source/update/check/download.cxx
diff --git a/extensions/source/update/check/updatecheckconfig.cxx b/extensions/source/update/check/updatecheckconfig.cxx
index 987e5fce6..163d46576 100755
--- a/extensions/source/update/check/updatecheckconfig.cxx
+++ b/extensions/source/update/check/updatecheckconfig.cxx
@@ -32,10 +32,8 @@
#include "updatecheckconfig.hxx"
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/beans/XPropertyState.hpp>
-
-#ifndef _COM_SUN_STAR_CONTAINER_CHANGESEVENT_HPP_
-#include <com/sun/star/beans/XPropertyState.hpp>
-#endif
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <osl/security.hxx>
#include <osl/time.h>
@@ -78,6 +76,8 @@ namespace uno = com::sun::star::uno ;
#define RELEASE_NOTE "ReleaseNote"
#define EXTENSION_PREFIX "Extension_"
+#define PROPERTY_VERSION UNISTRING("Version")
+
static const sal_Char * const aUpdateEntryProperties[] = {
UPDATE_VERSION,
UPDATE_BUILDID,
@@ -246,19 +246,19 @@ rtl::OUString UpdateCheckConfig::getAllUsersDirectory()
}
//------------------------------------------------------------------------------
-
-UpdateCheckConfig::UpdateCheckConfig(
- const uno::Reference<container::XNameContainer>& xContainer,
- const ::rtl::Reference< UpdateCheckConfigListener >& rListener
-) : m_xContainer(xContainer), m_rListener(rListener)
-{
-}
+UpdateCheckConfig::UpdateCheckConfig( const uno::Reference<container::XNameContainer>& xContainer,
+ const uno::Reference<container::XNameContainer>& xAvailableUpdates,
+ const uno::Reference<container::XNameContainer>& xIgnoredUpdates,
+ const ::rtl::Reference< UpdateCheckConfigListener >& rListener ) :
+ m_xContainer( xContainer ),
+ m_xAvailableUpdates( xAvailableUpdates ),
+ m_xIgnoredUpdates( xIgnoredUpdates ),
+ m_rListener( rListener )
+{}
//------------------------------------------------------------------------------
-
UpdateCheckConfig::~UpdateCheckConfig()
-{
-}
+{}
//------------------------------------------------------------------------------
@@ -295,7 +295,15 @@ UpdateCheckConfig::get(
UNISTRING("com.sun.star.configuration.ConfigurationUpdateAccess"), aArgumentList ),
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()
}
}
}
+
+ 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)
}
//------------------------------------------------------------------------------
-void UpdateCheckConfig::storeExtensionVersion( const rtl::OUString& rExtensionName,
+bool UpdateCheckConfig::storeExtensionVersion( const rtl::OUString& rExtensionName,
const rtl::OUString& rVersion )
{
- const rtl::OUString aExtName = UNISTRING( EXTENSION_PREFIX ) + rExtensionName;
- const uno::Any aValue = uno::makeAny( rVersion );
-
- if( m_xContainer->hasByName( aExtName ) )
- m_xContainer->replaceByName( aExtName, aValue );
+ bool bNotify = true;
+
+ if ( m_xAvailableUpdates->hasByName( rExtensionName ) )
+ uno::Reference< beans::XPropertySet >( m_xAvailableUpdates->getByName( rExtensionName ), uno::UNO_QUERY_THROW )->setPropertyValue( PROPERTY_VERSION, uno::Any( rVersion ) );
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();
+
+ return bNotify;
}
//------------------------------------------------------------------------------
bool UpdateCheckConfig::checkExtensionVersion( const rtl::OUString& rExtensionName,
const rtl::OUString& rVersion )
{
- const rtl::OUString aExtName = UNISTRING( EXTENSION_PREFIX ) + rExtensionName;
-
- if( m_xContainer->hasByName( aExtName ) )
+ if ( m_xAvailableUpdates->hasByName( rExtensionName ) )
{
- 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;
+ 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 ) )
return true;
else
{
- m_xContainer->removeByName( aExtName );
+ m_xAvailableUpdates->removeByName( rExtensionName );
commitChanges();
}
}
+
return false;
}
diff --git a/extensions/source/update/check/updatecheckconfig.hxx b/extensions/source/update/check/updatecheckconfig.hxx
index 1cf320711..7169ad44c 100644..100755
--- a/extensions/source/update/check/updatecheckconfig.hxx
+++ b/extensions/source/update/check/updatecheckconfig.hxx
@@ -93,8 +93,10 @@ class UpdateCheckConfig : public ::cppu::WeakImplHelper3<
::com::sun::star::util::XChangesBatch,
::com::sun::star::lang::XServiceInfo >
{
- UpdateCheckConfig(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& xContainer,
- const ::rtl::Reference< UpdateCheckConfigListener >& rListener );
+ 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 );
virtual ~UpdateCheckConfig();
@@ -154,7 +156,7 @@ public:
static rtl::OUString getAllUsersDirectory();
// store and retrieve information about extensions
- void storeExtensionVersion( const rtl::OUString& rExtensionName,
+ bool storeExtensionVersion( const rtl::OUString& rExtensionName,
const rtl::OUString& rVersion );
bool checkExtensionVersion( const rtl::OUString& rExtensionName,
const rtl::OUString& rVersion );
@@ -205,6 +207,8 @@ private:
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_xAvailableUpdates;
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > m_xIgnoredUpdates;
const ::rtl::Reference< UpdateCheckConfigListener > m_rListener;
};
diff --git a/extensions/source/update/check/updateprotocol.cxx b/extensions/source/update/check/updateprotocol.cxx
index 83d982986..98d17e520 100644..100755
--- a/extensions/source/update/check/updateprotocol.cxx
+++ b/extensions/source/update/check/updateprotocol.cxx
@@ -255,16 +255,18 @@ checkForUpdates(
bool storeExtensionUpdateInfos( const uno::Reference< uno::XComponentContext > & rxContext,
const uno::Sequence< uno::Sequence< rtl::OUString > > &rUpdateInfos )
{
+ bool bNotify = false;
+
if ( rUpdateInfos.hasElements() )
{
rtl::Reference< UpdateCheckConfig > aConfig = UpdateCheckConfig::get( rxContext );
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 > &
if ( !xInfoProvider.is() ) return false;
aUpdateList = xInfoProvider->isUpdateAvailable( ::rtl::OUString() );
- storeExtensionUpdateInfos( rxContext, aUpdateList );
+ bool bNotify = storeExtensionUpdateInfos( rxContext, aUpdateList );
- return aUpdateList.hasElements();
+ return bNotify;
}
//------------------------------------------------------------------------------