22#include <com/sun/star/beans/PropertyValue.hpp>
23#include <com/sun/star/beans/XPropertySet.hpp>
24#include <com/sun/star/configuration/theDefaultProvider.hpp>
25#include <com/sun/star/lang/XSingleServiceFactory.hpp>
27#include <osl/security.hxx>
29#include <osl/file.hxx>
44#define LAST_CHECK "LastCheck"
45#define UPDATE_VERSION "UpdateVersion"
46#define UPDATE_BUILDID "UpdateBuildId"
47#define UPDATE_DESCRIPTION "UpdateDescription"
48#define DOWNLOAD_URL "DownloadURL"
49#define IS_DIRECT_DOWNLOAD "IsDirectDownload"
50#define OLD_VERSION "UpdateFoundFor"
51#define AUTOCHECK_ENABLED "AutoCheckEnabled"
52#define AUTODOWNLOAD_ENABLED "AutoDownloadEnabled"
53#define CHECK_INTERVAL "CheckInterval"
54#define LOCAL_FILE "LocalFile"
55#define DOWNLOAD_SIZE "DownloadSize"
56#define DOWNLOAD_PAUSED "DownloadPaused"
57#define DOWNLOAD_DESTINATION "DownloadDestination"
58#define RELEASE_NOTE "ReleaseNote"
60#define PROPERTY_VERSION "Version"
80 const sal_Int32 nLen =
m_rValues.getLength();
81 for( sal_Int32
n=0;
n < nLen; ++
n )
86 return css::uno::Any();
139 bool isDirectDownload =
false;
144 for(sal_Int32
n=1;
n < 6; ++
n )
147 OString(OString::Concat(
RELEASE_NOTE) + OString::number(
n)).getStr());
148 if( !aUStr.isEmpty() )
160 if (SHGetKnownFolderPath(FOLDERID_Downloads, 0,
nullptr, &szPath) == S_OK)
162 aRet = o3tl::toU(szPath);
163 CoTaskMemFree(szPath);
164 osl::FileBase::getFileURLFromSystemPath( aRet, aRet );
169 osl::Security().getHomeDir( aHomeDir );
170 aRet = aHomeDir +
"/Desktop";
173 osl::Directory aDocumentsDir( aRet );
174 if( osl::FileBase::E_None != aDocumentsDir.open() )
188 if (
TRUE == SHGetSpecialFolderPathW(
nullptr, szPath, CSIDL_COMMON_DOCUMENTS,
true))
190 aRet = o3tl::toU(szPath);
191 osl::FileBase::getFileURLFromSystemPath( aRet, aRet );
194 osl::FileBase::getTempDirURL(aRet);
201 const uno::Reference<container::XNameContainer>& xAvailableUpdates,
202 const uno::Reference<container::XNameContainer>& xIgnoredUpdates,
203 const ::rtl::Reference< UpdateCheckConfigListener >& rListener ) :
205 m_xAvailableUpdates( xAvailableUpdates ),
206 m_xIgnoredUpdates( xIgnoredUpdates ),
207 m_rListener( rListener )
215 const uno::Reference<uno::XComponentContext>& xContext,
216 const ::rtl::Reference< UpdateCheckConfigListener >& rListener)
218 uno::Reference< lang::XMultiServiceFactory > xConfigProvider(
219 css::configuration::theDefaultProvider::get( xContext ) );
221 beans::PropertyValue aProperty;
222 aProperty.Name =
"nodepath";
223 aProperty.Value <<= OUString(
"org.openoffice.Office.Jobs/Jobs/UpdateCheck/Arguments");
225 uno::Sequence< uno::Any > aArgumentList{
uno::Any(aProperty) };
227 uno::Reference< container::XNameContainer > xContainer(
228 xConfigProvider->createInstanceWithArguments(
229 "com.sun.star.configuration.ConfigurationUpdateAccess", aArgumentList ),
230 uno::UNO_QUERY_THROW );
232 aProperty.Value <<= OUString(
"/org.openoffice.Office.ExtensionManager/ExtensionUpdateData/IgnoredUpdates");
233 aArgumentList = {
uno::Any(aProperty) };
234 uno::Reference< container::XNameContainer > xIgnoredExt( xConfigProvider->createInstanceWithArguments(
"com.sun.star.configuration.ConfigurationUpdateAccess", aArgumentList ), uno::UNO_QUERY_THROW );
236 aProperty.Value <<= OUString(
"/org.openoffice.Office.ExtensionManager/ExtensionUpdateData/AvailableUpdates");
237 aArgumentList = {
uno::Any(aProperty) };
238 uno::Reference< container::XNameContainer > xUpdateAvail( xConfigProvider->createInstanceWithArguments(
"com.sun.star.configuration.ConfigurationUpdateAccess", aArgumentList ), uno::UNO_QUERY_THROW );
240 return new UpdateCheckConfig( xContainer, xUpdateAvail, xIgnoredExt, rListener );
338 for(
const auto &
i : aNameList)
358 osl_getSystemTime(&systime);
360 sal_Int64 lastCheck = systime.Seconds;
407 aName = OUString::createFromAscii(aUpdateEntryProperty);
412 }
catch(
const lang::WrappedTargetException& ) {
456uno::Sequence< OUString > SAL_CALL
479 uno::Reference< util::XChangesBatch > xChangesBatch(
m_xContainer, uno::UNO_QUERY);
480 if( xChangesBatch.is() && xChangesBatch->hasPendingChanges() )
482 util::ChangesSet aChangesSet = xChangesBatch->getPendingChanges();
483 xChangesBatch->commitChanges();
487 const sal_Int32 nChanges = aChangesSet.getLength();
490 for( sal_Int32
i=0;
i<nChanges; ++
i )
492 aChangesSet[
i].Accessor >>= aString;
495 bool bEnabled =
false;
496 aChangesSet[
i].Element >>= bEnabled;
508 if( xChangesBatch.is() && xChangesBatch->hasPendingChanges() )
510 xChangesBatch->commitChanges();
513 if( xChangesBatch.is() && xChangesBatch->hasPendingChanges() )
515 xChangesBatch->commitChanges();
522 uno::Reference< util::XChangesBatch > xChangesBatch(
m_xContainer, uno::UNO_QUERY);
523 if( xChangesBatch.is() )
524 return xChangesBatch->hasPendingChanges();
529uno::Sequence< util::ElementChange > SAL_CALL
532 uno::Reference< util::XChangesBatch > xChangesBatch(
m_xContainer, uno::UNO_QUERY);
533 if( xChangesBatch.is() )
534 return xChangesBatch->getPendingChanges();
536 return uno::Sequence< util::ElementChange >();
540 const OUString& rVersion )
548 uno::Reference< beans::XPropertySet > elem( uno::Reference< lang::XSingleServiceFactory >(
m_xAvailableUpdates, uno::UNO_QUERY_THROW )->
createInstance(), uno::UNO_QUERY_THROW );
555 OUString aIgnoredVersion;
557 aValue >>= aIgnoredVersion;
558 if ( aIgnoredVersion.isEmpty() )
560 else if ( aIgnoredVersion == rVersion )
570 const OUString& rVersion )
574 OUString aStoredVersion;
576 aValue >>= aStoredVersion;
580 OUString aIgnoredVersion;
582 aValue2 >>= aIgnoredVersion;
583 if ( aIgnoredVersion.isEmpty() )
585 else if ( aIgnoredVersion == aStoredVersion )
604 while ( *
nIndex < rVersion.getLength() && rVersion[*
nIndex] ==
'0')
609 return rVersion.getToken( 0,
'.', *
nIndex );
614 const OUString& rVersion2 )
616 for ( sal_Int32 i1 = 0, i2 = 0; i1 >= 0 || i2 >= 0; )
621 if ( sSub1.getLength() < sSub2.getLength() ) {
623 }
else if ( sSub1.getLength() > sSub2.getLength() ) {
625 }
else if ( sSub1 < sSub2 ) {
627 }
else if ( sSub1 > sSub2 ) {
637 return "vnd.sun.UpdateCheckConfig";
646uno::Sequence< OUString > SAL_CALL
649 return {
"com.sun.star.setup.UpdateCheckConfig" };
652extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
654 css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any>
const&)
HRESULT createInstance(REFIID iid, Ifc **ppIfc)
const css::uno::Sequence< css::beans::NamedValue > & m_rValues
css::uno::Any getValue(const char *pName)
const css::uno::Reference< css::container::XNameContainer > m_xIgnoredUpdates
virtual ~UpdateCheckConfig() override
void storeDownloadPaused(bool paused)
sal_Int64 getLastChecked() const
void storeLocalFileName(const OUString &rFileName, sal_Int64 nFileSize)
sal_Int64 getCheckInterval() const
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
static OUString getSubVersion(const OUString &rVersion, sal_Int32 *nIndex)
virtual sal_Bool SAL_CALL hasElements() override
static OUString getAllUsersDirectory()
static OUString getDownloadsDirectory()
bool storeExtensionVersion(const OUString &rExtensionName, const OUString &rVersion)
static bool isVersionGreater(const OUString &rVersion1, const OUString &rVersion2)
checks if the second version string is greater than the first one
OUString getUpdateEntryVersion() const
static ::rtl::Reference< UpdateCheckConfig > get(const css::uno::Reference< css::uno::XComponentContext > &xContext, const ::rtl::Reference< UpdateCheckConfigListener > &rListener=::rtl::Reference< UpdateCheckConfigListener >())
void clearLocalFileName()
virtual void SAL_CALL replaceByName(const OUString &aName, const css::uno::Any &aElement) override
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
virtual css::uno::Sequence< css::util::ElementChange > SAL_CALL getPendingChanges() override
UpdateCheckConfig(const css::uno::Reference< css::container::XNameContainer > &xContainer, const css::uno::Reference< css::container::XNameContainer > &xAvailableUpdates, const css::uno::Reference< css::container::XNameContainer > &xIgnoredUpdates, const ::rtl::Reference< UpdateCheckConfigListener > &rListener)
virtual sal_Bool SAL_CALL supportsService(OUString const &serviceName) override
bool isAutoCheckEnabled() const
OUString getLocalFileName() const
OUString getDownloadDestination() const
virtual OUString SAL_CALL getImplementationName() override
const ::rtl::Reference< UpdateCheckConfigListener > m_rListener
virtual sal_Bool SAL_CALL hasPendingChanges() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
bool isAutoDownloadEnabled() const
virtual void SAL_CALL commitChanges() override
bool checkExtensionVersion(const OUString &rExtensionName, const OUString &rVersion)
void storeUpdateFound(const UpdateInfo &rInfo, const OUString &aCurrentBuild)
const css::uno::Reference< css::container::XNameContainer > m_xContainer
const css::uno::Reference< css::container::XNameContainer > m_xAvailableUpdates
virtual css::uno::Type SAL_CALL getElementType() override
OUString getStringValue(const char *) const
void getUpdateEntry(UpdateInfo &rInfo) const
OUString getUpdateEntryVersion() const
sal_Int64 getDownloadSize() const
OUString getLocalFileName() const
bool isDownloadPaused() const
bool isAutoCheckEnabled() const
NamedValueByNameAccess & m_aNameAccess
#define SAL_N_ELEMENTS(arr)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
Reference< XNameAccess > m_xContainer
std::vector< DownloadSource > Sources
std::vector< ReleaseNote > ReleaseNotes
OUString getReleaseNote(const UpdateInfo &rInfo, sal_uInt8 pos, bool autoDownloadEnabled)
#define DOWNLOAD_DESTINATION
#define AUTOCHECK_ENABLED
#define IS_DIRECT_DOWNLOAD
#define UPDATE_DESCRIPTION
#define AUTODOWNLOAD_ENABLED
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * extensions_update_UpdateCheckConfig_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
const sal_uInt32 nUpdateEntryProperties
const char *const aUpdateEntryProperties[]