2006-08-04 08:56:09 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
|
|
|
*
|
|
|
|
* $RCSfile: updatecheck.cxx,v $
|
|
|
|
*
|
2007-11-26 12:28:42 +00:00
|
|
|
* $Revision: 1.17 $
|
2006-08-04 08:56:09 +00:00
|
|
|
*
|
2007-11-26 12:28:42 +00:00
|
|
|
* last change: $Author: ihi $ $Date: 2007-11-26 13:28:42 $
|
2006-08-04 08:56:09 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 12:30:50 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_extensions.hxx"
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
#include "updatecheck.hxx"
|
|
|
|
|
|
|
|
#include <cppuhelper/implbase1.hxx>
|
|
|
|
|
|
|
|
#ifndef _COM_SUN_STAR_BEANS_XFASTPROPERTYSET_HPP_
|
|
|
|
#include <com/sun/star/beans/XFastPropertySet.hpp>
|
|
|
|
#endif
|
2006-08-04 08:56:09 +00:00
|
|
|
|
|
|
|
#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
|
|
|
|
#include <com/sun/star/lang/XComponent.hpp>
|
|
|
|
#endif
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
#ifndef _COM_SUN_STAR_FRAME_XDESKTOP_HPP_
|
|
|
|
#include <com/sun/star/frame/XDesktop.hpp>
|
2006-10-06 09:37:03 +00:00
|
|
|
#endif
|
2006-08-04 08:56:09 +00:00
|
|
|
|
|
|
|
#ifndef _COM_SUN_STAR_FRAME_XFRAME_HPP_
|
|
|
|
#include <com/sun/star/frame/XFrame.hpp>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _COM_SUN_STAR_FRAME_DISPATCHRESULTEVENT_HPP_
|
|
|
|
#include <com/sun/star/frame/DispatchResultEvent.hpp>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _COM_SUN_STAR_FRAME_DISPATCHRESULTSTATE_HPP_
|
|
|
|
#include <com/sun/star/frame/DispatchResultState.hpp>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _COM_SUN_STAR_SYSTEM_XSYSTEMSHELLEXECUTE_HPP_
|
|
|
|
#include <com/sun/star/system/XSystemShellExecute.hpp>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _COM_SUN_STAR_SYSTEM_SYSTEMSHELLEXECUTEFLAGS_HPP_
|
|
|
|
#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _COM_SUN_STAR_TASK_XJOB_HPP_
|
|
|
|
#include <com/sun/star/task/XJob.hpp>
|
|
|
|
#endif
|
2007-11-19 15:47:59 +00:00
|
|
|
#ifndef _COM_SUN_STAR_TASK_XJOBEXECUTOR_HPP_
|
|
|
|
#include <com/sun/star/task/XJobExecutor.hpp>
|
|
|
|
#endif
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
// #include <comphelper/processfactory.hxx>
|
2006-11-01 09:12:28 +00:00
|
|
|
|
2006-08-04 08:56:09 +00:00
|
|
|
#include <rtl/ustrbuf.hxx>
|
|
|
|
|
|
|
|
#include <rtl/bootstrap.hxx>
|
|
|
|
#include <osl/process.h>
|
2007-07-06 13:36:35 +00:00
|
|
|
#include <osl/module.hxx>
|
|
|
|
#include <osl/file.hxx>
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-31 14:56:29 +00:00
|
|
|
#ifdef WNT
|
2007-09-06 12:38:05 +00:00
|
|
|
#ifdef _MSC_VER
|
2007-07-31 14:56:29 +00:00
|
|
|
#pragma warning(push,1) // disable warnings within system headers
|
|
|
|
//#pragma warning(disable: 4917)
|
2007-09-06 12:38:05 +00:00
|
|
|
#endif
|
2007-07-31 14:56:29 +00:00
|
|
|
#include <objbase.h>
|
2007-09-06 12:38:05 +00:00
|
|
|
#ifdef _MSC_VER
|
2007-07-31 14:56:29 +00:00
|
|
|
#pragma warning(pop)
|
|
|
|
#endif
|
2007-09-06 12:38:05 +00:00
|
|
|
#endif
|
2007-07-31 14:56:29 +00:00
|
|
|
|
2006-08-04 08:56:09 +00:00
|
|
|
#include "updateprotocol.hxx"
|
|
|
|
#include "updatecheckconfig.hxx"
|
|
|
|
|
|
|
|
namespace awt = com::sun::star::awt ;
|
|
|
|
namespace beans = com::sun::star::beans ;
|
|
|
|
namespace container = com::sun::star::container ;
|
2007-01-29 15:00:00 +00:00
|
|
|
namespace deployment = com::sun::star::deployment ;
|
2006-08-04 08:56:09 +00:00
|
|
|
namespace frame = com::sun::star::frame ;
|
|
|
|
namespace lang = com::sun::star::lang ;
|
|
|
|
namespace c3s = com::sun::star::system ;
|
|
|
|
namespace task = com::sun::star::task ;
|
|
|
|
namespace util = com::sun::star::util ;
|
|
|
|
namespace uno = com::sun::star::uno ;
|
|
|
|
|
|
|
|
#define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
|
|
|
|
|
2006-10-06 09:37:03 +00:00
|
|
|
#define PROPERTY_TITLE UNISTRING("BubbleHeading")
|
|
|
|
#define PROPERTY_TEXT UNISTRING("BubbleText")
|
|
|
|
#define PROPERTY_IMAGE UNISTRING("BubbleImageURL")
|
|
|
|
#define PROPERTY_SHOW_BUBBLE UNISTRING("BubbleVisible")
|
|
|
|
#define PROPERTY_CLICK_HDL UNISTRING("MenuClickHDL")
|
|
|
|
#define PROPERTY_DEFAULT_TITLE UNISTRING("DefaultHeading")
|
|
|
|
#define PROPERTY_DEFAULT_TEXT UNISTRING("DefaultText")
|
2006-11-01 09:12:28 +00:00
|
|
|
#define PROPERTY_SHOW_MENUICON UNISTRING("MenuIconVisible")
|
2006-08-04 08:56:09 +00:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
// Returns the URL of the release note for the given position
|
|
|
|
rtl::OUString getReleaseNote(const UpdateInfo& rInfo, sal_uInt8 pos, bool autoDownloadEnabled)
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
std::vector< ReleaseNote >::const_iterator iter = rInfo.ReleaseNotes.begin();
|
|
|
|
while( iter != rInfo.ReleaseNotes.end() )
|
2006-09-25 08:33:36 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
if( pos == iter->Pos )
|
2006-09-25 08:33:36 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
if( (pos > 2) || !autoDownloadEnabled || ! (iter->URL2.getLength() > 0) )
|
|
|
|
return iter->URL;
|
2006-09-25 08:33:36 +00:00
|
|
|
}
|
2007-07-06 13:36:35 +00:00
|
|
|
else if( (pos == iter->Pos2) && ((1 == iter->Pos) || (2 == iter->Pos)) && autoDownloadEnabled )
|
|
|
|
return iter->URL2;
|
|
|
|
|
2007-07-31 14:56:29 +00:00
|
|
|
++iter;
|
2006-09-25 08:33:36 +00:00
|
|
|
}
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
return rtl::OUString();
|
2006-08-04 08:56:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
|
2007-11-26 12:28:42 +00:00
|
|
|
static rtl::OUString getBootstrapValue(const rtl::OUString& aFile, const rtl::OUString& aValue)
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
rtl::OUString aPath, aRet;
|
|
|
|
if( osl_getExecutableFile(&aPath.pData) == osl_Process_E_None )
|
|
|
|
{
|
|
|
|
sal_uInt32 lastIndex = aPath.lastIndexOf('/');
|
|
|
|
if ( lastIndex > 0 )
|
|
|
|
{
|
|
|
|
aPath = aPath.copy( 0, lastIndex+1 );
|
2007-11-26 12:28:42 +00:00
|
|
|
aPath += aFile;
|
2007-07-06 13:36:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
rtl::Bootstrap aVersionFile(aPath);
|
2007-11-26 12:28:42 +00:00
|
|
|
aVersionFile.getFrom(aValue, aRet, rtl::OUString());
|
2007-07-06 13:36:35 +00:00
|
|
|
}
|
|
|
|
return aRet;
|
2006-08-04 08:56:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2007-11-26 12:28:42 +00:00
|
|
|
static inline rtl::OUString getBuildId()
|
|
|
|
{
|
|
|
|
return getBootstrapValue(UNISTRING( SAL_CONFIGFILE( "version" ) ), UNISTRING("buildid") );
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
static inline rtl::OUString getBaseInstallation()
|
|
|
|
{
|
|
|
|
return getBootstrapValue(UNISTRING( SAL_CONFIGFILE( "bootstrap" ) ), UNISTRING("BaseInstallation") );
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
inline bool isObsoleteUpdateInfo(const rtl::OUString& rBuildId)
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
return sal_True != rBuildId.equals(getBuildId()) && rBuildId.getLength() > 0;
|
|
|
|
}
|
2006-08-04 08:56:09 +00:00
|
|
|
|
|
|
|
|
2007-11-26 12:28:42 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
rtl::OUString getImageFromFileName(const rtl::OUString& aFile)
|
|
|
|
{
|
|
|
|
#ifndef WNT
|
|
|
|
rtl::OUString aUnpackPath;
|
|
|
|
if( osl_getExecutableFile(&aUnpackPath.pData) == osl_Process_E_None )
|
|
|
|
{
|
|
|
|
sal_uInt32 lastIndex = aUnpackPath.lastIndexOf('/');
|
|
|
|
if ( lastIndex > 0 )
|
|
|
|
{
|
|
|
|
aUnpackPath = aUnpackPath.copy( 0, lastIndex+1 );
|
|
|
|
aUnpackPath += UNISTRING( "unpack_update" );
|
|
|
|
}
|
|
|
|
|
|
|
|
oslFileHandle hOut = NULL;
|
|
|
|
oslProcess hProcess = NULL;
|
|
|
|
|
|
|
|
rtl::OUString aSystemPath;
|
|
|
|
osl::File::getSystemPathFromFileURL(aFile, aSystemPath);
|
|
|
|
|
|
|
|
oslProcessError rc = osl_executeProcess_WithRedirectedIO(
|
|
|
|
aUnpackPath.pData, // [in] Image name
|
|
|
|
&aSystemPath.pData, 1, // [in] Arguments
|
|
|
|
osl_Process_WAIT || osl_Process_NORMAL, // [in] Options
|
|
|
|
NULL, // [in] Security
|
|
|
|
NULL, // [in] Working directory
|
|
|
|
NULL, 0, // [in] Environment variables
|
|
|
|
&hProcess, // [out] Process handle
|
|
|
|
NULL, &hOut, NULL // [out] File handles for redirected I/O
|
|
|
|
);
|
|
|
|
|
|
|
|
if( osl_Process_E_None == rc )
|
|
|
|
{
|
|
|
|
oslProcessInfo aInfo;
|
|
|
|
aInfo.Size = sizeof(oslProcessInfo);
|
|
|
|
|
|
|
|
if( osl_Process_E_None == osl_getProcessInfo(hProcess, osl_Process_EXITCODE, &aInfo) )
|
|
|
|
{
|
|
|
|
if( 0 == aInfo.Code )
|
|
|
|
{
|
|
|
|
sal_Char szBuffer[4096];
|
|
|
|
sal_uInt64 nBytesRead = 0;
|
|
|
|
const sal_uInt64 nBytesToRead = sizeof(szBuffer) - 1;
|
|
|
|
|
|
|
|
rtl::OUString aImageName;
|
|
|
|
while( osl_File_E_None == osl_readFile(hOut, szBuffer, nBytesToRead, &nBytesRead) )
|
|
|
|
{
|
|
|
|
sal_Char *pc = szBuffer + nBytesRead;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
*pc = '\0'; --pc;
|
|
|
|
}
|
|
|
|
while( ('\n' == *pc) || ('\r' == *pc) );
|
|
|
|
|
|
|
|
aImageName += rtl::OUString(szBuffer, pc - szBuffer + 1, osl_getThreadTextEncoding());
|
|
|
|
|
|
|
|
if( nBytesRead < nBytesToRead )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( osl::FileBase::E_None == osl::FileBase::getFileURLFromSystemPath(aImageName, aImageName) )
|
|
|
|
return aImageName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
osl_closeFile(hOut);
|
|
|
|
osl_freeProcessHandle(hProcess);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return aFile;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
static uno::Reference< beans::XPropertySet > createMenuBarUI(
|
|
|
|
const uno::Reference< uno::XComponentContext >& xContext,
|
|
|
|
const uno::Reference< task::XJob >& xJob)
|
|
|
|
{
|
|
|
|
if( !xContext.is() )
|
|
|
|
throw uno::RuntimeException(
|
|
|
|
UNISTRING( "UpdateCheckJob: empty component context" ), uno::Reference< uno::XInterface > () );
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
uno::Reference< lang::XMultiComponentFactory > xServiceManager(xContext->getServiceManager());
|
|
|
|
if( !xServiceManager.is() )
|
|
|
|
throw uno::RuntimeException(
|
|
|
|
UNISTRING( "UpdateCheckJob: unable to obtain service manager from component context" ), uno::Reference< uno::XInterface > () );
|
2006-11-01 09:12:28 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
uno::Reference< beans::XPropertySet > xMenuBarUI =
|
|
|
|
uno::Reference< beans::XPropertySet > (
|
|
|
|
xServiceManager->createInstanceWithContext( UNISTRING( "com.sun.star.setup.UpdateCheckUI" ), xContext ),
|
|
|
|
uno::UNO_QUERY_THROW);
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
xMenuBarUI->setPropertyValue( PROPERTY_CLICK_HDL, uno::makeAny( xJob ) );
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
return xMenuBarUI;
|
|
|
|
}
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
//------------------------------------------------------------------------------
|
2006-08-04 08:56:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
typedef sal_Bool (* OnlineCheckFunc) ();
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
class UpdateCheckThread : public WorkerThread
|
|
|
|
{
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
public:
|
|
|
|
UpdateCheckThread( osl::Condition& rCondition,
|
|
|
|
const uno::Reference<uno::XComponentContext>& xContext );
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
virtual void SAL_CALL join();
|
|
|
|
virtual void SAL_CALL terminate();
|
|
|
|
virtual void SAL_CALL cancel();
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
protected:
|
|
|
|
virtual ~UpdateCheckThread();
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
virtual void SAL_CALL run();
|
|
|
|
virtual void SAL_CALL onTerminated();
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
/* Wrapper around checkForUpdates */
|
|
|
|
bool runCheck();
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
private:
|
2006-08-04 08:56:09 +00:00
|
|
|
|
|
|
|
/* Used to avoid dialup login windows (on platforms we know how to double this) */
|
|
|
|
inline bool hasInternetConnection() const
|
|
|
|
{
|
|
|
|
if(m_pHasInternetConnection != NULL )
|
|
|
|
return (sal_True == m_pHasInternetConnection());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
/* Creates a new instance of UpdateInformationProvider and returns this instance */
|
|
|
|
inline uno::Reference<deployment::XUpdateInformationProvider> createProvider()
|
|
|
|
{
|
|
|
|
osl::MutexGuard aGuard(m_aMutex);
|
|
|
|
m_xProvider = deployment::UpdateInformationProvider::create(m_xContext);
|
|
|
|
return m_xProvider;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Returns the remembered instance of UpdateInformationProvider if any */
|
|
|
|
inline uno::Reference<deployment::XUpdateInformationProvider> getProvider()
|
|
|
|
{ osl::MutexGuard aGuard(m_aMutex); return m_xProvider; };
|
|
|
|
|
|
|
|
/* Releases the remembered instance of UpdateInformationProvider if any */
|
|
|
|
inline void clearProvider()
|
|
|
|
{ osl::MutexGuard aGuard(m_aMutex); m_xProvider.clear(); };
|
|
|
|
|
|
|
|
osl::Mutex m_aMutex;
|
|
|
|
osl::Module m_aModule;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
osl::Condition& m_aCondition;
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
// const
|
|
|
|
OnlineCheckFunc m_pHasInternetConnection;
|
|
|
|
|
|
|
|
const uno::Reference<uno::XComponentContext> m_xContext;
|
|
|
|
uno::Reference<deployment::XUpdateInformationProvider> m_xProvider;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class ManualUpdateCheckThread : public UpdateCheckThread
|
|
|
|
{
|
2006-08-04 08:56:09 +00:00
|
|
|
public:
|
2007-07-06 13:36:35 +00:00
|
|
|
ManualUpdateCheckThread( osl::Condition& rCondition, const uno::Reference<uno::XComponentContext>& xContext ) :
|
|
|
|
UpdateCheckThread(rCondition, xContext) {};
|
|
|
|
|
|
|
|
virtual void SAL_CALL run();
|
|
|
|
};
|
2006-08-04 08:56:09 +00:00
|
|
|
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
class MenuBarButtonJob : public ::cppu::WeakImplHelper1< task::XJob >
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MenuBarButtonJob(const rtl::Reference< UpdateCheck >& rUpdateCheck);
|
2006-08-04 08:56:09 +00:00
|
|
|
|
|
|
|
// XJob
|
|
|
|
virtual uno::Any SAL_CALL execute(const uno::Sequence<beans::NamedValue>&)
|
|
|
|
throw (lang::IllegalArgumentException, uno::Exception);
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
private:
|
|
|
|
rtl::Reference< UpdateCheck > m_aUpdateCheck;
|
2006-08-04 08:56:09 +00:00
|
|
|
};
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
class DownloadThread : public WorkerThread
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DownloadThread(
|
|
|
|
osl::Condition& rCondition,
|
|
|
|
const uno::Reference<uno::XComponentContext>& xContext,
|
|
|
|
const rtl::Reference< DownloadInteractionHandler >& rHandler,
|
|
|
|
const rtl::OUString& rURL );
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
virtual void SAL_CALL run();
|
|
|
|
virtual void SAL_CALL cancel();
|
|
|
|
virtual void SAL_CALL suspend();
|
|
|
|
virtual void SAL_CALL onTerminated();
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
protected:
|
|
|
|
~DownloadThread();
|
|
|
|
|
|
|
|
private:
|
|
|
|
osl::Condition& m_aCondition;
|
|
|
|
const uno::Reference<uno::XComponentContext> m_xContext;
|
|
|
|
const rtl::OUString m_aURL;
|
|
|
|
Download m_aDownload;
|
|
|
|
};
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-31 14:56:29 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
class ShutdownThread : public osl::Thread
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ShutdownThread( const uno::Reference<uno::XComponentContext>& xContext );
|
|
|
|
|
|
|
|
virtual void SAL_CALL run();
|
|
|
|
virtual void SAL_CALL onTerminated();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
~ShutdownThread();
|
|
|
|
|
|
|
|
private:
|
|
|
|
osl::Condition m_aCondition;
|
|
|
|
const uno::Reference<uno::XComponentContext> m_xContext;
|
|
|
|
};
|
|
|
|
|
2006-08-04 08:56:09 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
UpdateCheckThread::UpdateCheckThread( osl::Condition& rCondition,
|
|
|
|
const uno::Reference<uno::XComponentContext>& xContext ) :
|
|
|
|
m_aCondition(rCondition),
|
|
|
|
m_pHasInternetConnection(NULL),
|
|
|
|
m_xContext(xContext)
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
|
|
|
|
#ifdef WNT
|
|
|
|
rtl::OUString aPath;
|
|
|
|
if( osl_getExecutableFile(&aPath.pData) == osl_Process_E_None )
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
sal_uInt32 lastIndex = aPath.lastIndexOf('/');
|
|
|
|
if ( lastIndex > 0 )
|
|
|
|
{
|
|
|
|
aPath = aPath.copy( 0, lastIndex+1 );
|
|
|
|
aPath += UNISTRING( "onlinecheck" );
|
|
|
|
}
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
if ( m_aModule.load(aPath) )
|
2007-01-29 15:00:00 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
m_pHasInternetConnection =
|
|
|
|
reinterpret_cast < OnlineCheckFunc > (
|
|
|
|
m_aModule.getFunctionSymbol( UNISTRING("hasInternetConnection")));
|
2007-01-29 15:00:00 +00:00
|
|
|
}
|
2006-08-04 08:56:09 +00:00
|
|
|
}
|
2007-07-06 13:36:35 +00:00
|
|
|
#endif
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
createSuspended();
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
// actually run the thread
|
|
|
|
resume();
|
2006-08-04 08:56:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
UpdateCheckThread::~UpdateCheckThread()
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
}
|
2006-08-04 08:56:09 +00:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
|
|
|
|
void SAL_CALL
|
|
|
|
UpdateCheckThread::terminate()
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
// Cancel potentially hanging http request ..
|
|
|
|
cancel();
|
|
|
|
// .. before terminating
|
|
|
|
osl::Thread::terminate();
|
2006-08-04 08:56:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
void SAL_CALL
|
|
|
|
UpdateCheckThread::join()
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
uno::Reference< deployment::XUpdateInformationProvider > xProvider(getProvider());
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
// do not join during an update check until #i73893# is fixed
|
|
|
|
if( ! xProvider.is() )
|
|
|
|
{
|
|
|
|
osl::Thread::join();
|
|
|
|
}
|
|
|
|
}
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
//------------------------------------------------------------------------------
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
void SAL_CALL
|
|
|
|
UpdateCheckThread::cancel()
|
|
|
|
{
|
|
|
|
uno::Reference< deployment::XUpdateInformationProvider > xProvider(getProvider());
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
if( xProvider.is() )
|
|
|
|
xProvider->cancel();
|
2006-08-04 08:56:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
bool
|
|
|
|
UpdateCheckThread::runCheck()
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
bool ret = false;
|
2007-11-19 15:47:59 +00:00
|
|
|
UpdateState eUIState = UPDATESTATE_NO_UPDATE_AVAIL;
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
UpdateInfo aInfo;
|
|
|
|
rtl::Reference< UpdateCheck > aController(UpdateCheck::get());
|
|
|
|
|
|
|
|
if( checkForUpdates(aInfo, m_xContext, aController->getInteractionHandler(), createProvider()) )
|
|
|
|
{
|
|
|
|
aController->setUpdateInfo(aInfo);
|
2007-11-19 15:47:59 +00:00
|
|
|
eUIState = aController->getUIState(aInfo);
|
2007-07-06 13:36:35 +00:00
|
|
|
ret = true;
|
|
|
|
}
|
2007-07-31 14:56:29 +00:00
|
|
|
else
|
|
|
|
aController->setCheckFailedState();
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-11-19 15:47:59 +00:00
|
|
|
// We will only look for extension updates, when there is no 'check for office updates' dialog open
|
|
|
|
// and when there was no office update found
|
|
|
|
if ( ( eUIState != UPDATESTATE_UPDATE_AVAIL ) &&
|
|
|
|
( eUIState != UPDATESTATE_UPDATE_NO_DOWNLOAD ) &&
|
|
|
|
!aController->isDialogShowing() )
|
|
|
|
{
|
|
|
|
bool bHasExtensionUpdates = checkForExtensionUpdates( m_xContext );
|
|
|
|
aController->setHasExtensionUpdates( bHasExtensionUpdates );
|
|
|
|
if ( bHasExtensionUpdates )
|
|
|
|
aController->setUIState( UPDATESTATE_EXT_UPD_AVAIL );
|
|
|
|
}
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
// joining with this thread is safe again
|
|
|
|
clearProvider();
|
|
|
|
return ret;
|
2006-08-04 08:56:09 +00:00
|
|
|
}
|
|
|
|
|
2006-11-01 09:12:28 +00:00
|
|
|
//------------------------------------------------------------------------------
|
2007-07-06 13:36:35 +00:00
|
|
|
|
|
|
|
void SAL_CALL
|
|
|
|
UpdateCheckThread::onTerminated()
|
2006-11-01 09:12:28 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
delete this;
|
|
|
|
}
|
2006-11-01 09:12:28 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
//------------------------------------------------------------------------------
|
2006-11-01 09:12:28 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
void SAL_CALL
|
|
|
|
UpdateCheckThread::run()
|
|
|
|
{
|
|
|
|
osl::Condition::Result aResult = osl::Condition::result_timeout;
|
|
|
|
TimeValue tv = { 10, 0 };
|
2006-11-01 09:12:28 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
// Initial wait to avoid doing further time consuming tasks during start-up
|
|
|
|
aResult = m_aCondition.wait(&tv);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
while( sal_True == schedule() )
|
|
|
|
{
|
|
|
|
/* Use cases:
|
|
|
|
* a) manual check requested from auto check thread - "last check" should not be checked (one time)
|
|
|
|
* a1) manual check was requested in the middle of a running auto check,
|
|
|
|
* condition is set
|
|
|
|
* a2) manual check was requested while waiting for a retry,
|
|
|
|
* condition is set
|
|
|
|
* a3) manual check was requested while waiting for time to next
|
|
|
|
* scheduled check elapsing, condition is set
|
|
|
|
* a4) manual check was requested during initial wait, condition is set
|
|
|
|
* b) check interval got changed, condition may be set - same sub-cases as a),
|
|
|
|
* but "last check" should be honored
|
|
|
|
* c) normal auto check mode, condition not set - "last check" should be honored
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Accessing const members without synchronization
|
|
|
|
rtl::Reference< UpdateCheck > aController(UpdateCheck::get());
|
|
|
|
rtl::Reference< UpdateCheckConfig > rModel = UpdateCheckConfig::get(m_xContext, *aController);
|
|
|
|
|
|
|
|
// FIXME: remember last & offset ?
|
|
|
|
sal_Int64 last = rModel->getLastChecked();
|
|
|
|
sal_Int64 offset = rModel->getCheckInterval();
|
|
|
|
|
|
|
|
rModel.clear();
|
|
|
|
|
|
|
|
// last == 0 means check immediately
|
|
|
|
bool checkNow = ! (last > 0);
|
|
|
|
|
|
|
|
// Reset the condition to avoid busy loops
|
|
|
|
if( osl::Condition::result_ok == aResult )
|
|
|
|
{
|
|
|
|
m_aCondition.reset();
|
|
|
|
aResult = osl::Condition::result_timeout;
|
|
|
|
checkNow = aController->isDialogShowing();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( ! checkNow )
|
|
|
|
{
|
|
|
|
TimeValue systime;
|
|
|
|
osl_getSystemTime(&systime);
|
2006-11-01 09:12:28 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
// Go back to sleep until time has elapsed
|
|
|
|
sal_Int64 next = last + offset;
|
|
|
|
if( last + offset > systime.Seconds )
|
|
|
|
{
|
|
|
|
// This can not be > 32 Bit for now ..
|
|
|
|
tv.Seconds = static_cast< sal_Int32 > (next - systime.Seconds);
|
|
|
|
aResult = m_aCondition.wait(&tv);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static sal_uInt8 n = 0;
|
|
|
|
|
|
|
|
if( ! hasInternetConnection() || ! runCheck() )
|
|
|
|
{
|
|
|
|
// Increase next by 1, 5, 15, 60, .. minutes
|
|
|
|
static const sal_Int16 nRetryInterval[] = { 60, 300, 900, 3600 };
|
|
|
|
|
|
|
|
if( n < sizeof(nRetryInterval) / sizeof(sal_Int16) )
|
|
|
|
++n;
|
|
|
|
|
|
|
|
tv.Seconds = nRetryInterval[n-1];
|
|
|
|
aResult = m_aCondition.wait(&tv);
|
|
|
|
}
|
|
|
|
else // reset retry counter
|
|
|
|
n = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
catch(const uno::Exception& e) {
|
|
|
|
// Silently catch all errors
|
|
|
|
OSL_TRACE( "Caught exception: %s\n thread terminated.\n",
|
|
|
|
rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2006-11-01 09:12:28 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
void SAL_CALL
|
|
|
|
ManualUpdateCheckThread::run()
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
runCheck();
|
|
|
|
m_aCondition.reset();
|
|
|
|
}
|
|
|
|
catch(const uno::Exception& e) {
|
|
|
|
// Silently catch all errors
|
|
|
|
OSL_TRACE( "Caught exception: %s\n thread terminated.\n",
|
|
|
|
rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr() );
|
|
|
|
}
|
2006-11-01 09:12:28 +00:00
|
|
|
}
|
|
|
|
|
2006-08-04 08:56:09 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
MenuBarButtonJob::MenuBarButtonJob(const rtl::Reference< UpdateCheck >& rUpdateCheck) :
|
|
|
|
m_aUpdateCheck(rUpdateCheck)
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
uno::Any SAL_CALL
|
|
|
|
MenuBarButtonJob::execute(const uno::Sequence<beans::NamedValue>& )
|
|
|
|
throw (lang::IllegalArgumentException, uno::Exception)
|
|
|
|
{
|
2007-11-19 15:47:59 +00:00
|
|
|
if ( m_aUpdateCheck->shouldShowExtUpdDlg() )
|
|
|
|
m_aUpdateCheck->showExtensionDialog();
|
|
|
|
else
|
|
|
|
m_aUpdateCheck->showDialog();
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
return uno::Any();
|
2006-08-04 08:56:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
DownloadThread::DownloadThread(osl::Condition& rCondition,
|
|
|
|
const uno::Reference<uno::XComponentContext>& xContext,
|
|
|
|
const rtl::Reference< DownloadInteractionHandler >& rHandler,
|
|
|
|
const rtl::OUString& rURL) :
|
|
|
|
m_aCondition(rCondition),
|
|
|
|
m_xContext(xContext),
|
|
|
|
m_aURL(rURL),
|
|
|
|
m_aDownload(xContext, rHandler)
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
createSuspended();
|
2006-08-04 08:56:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
DownloadThread::~DownloadThread()
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
void SAL_CALL
|
|
|
|
DownloadThread::run()
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-31 14:56:29 +00:00
|
|
|
#ifdef WNT
|
|
|
|
CoUninitialize();
|
|
|
|
CoInitialize( NULL );
|
|
|
|
#endif
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
while( schedule() )
|
|
|
|
{
|
|
|
|
rtl::Reference< UpdateCheckConfig > rModel = UpdateCheckConfig::get(m_xContext);
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
rtl::OUString aLocalFile = rModel->getLocalFileName();
|
2007-07-31 14:56:29 +00:00
|
|
|
rtl::OUString aDownloadDest = rModel->getDownloadDestination();
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
// release config class for now
|
|
|
|
rModel.clear();
|
|
|
|
|
2007-07-31 14:56:29 +00:00
|
|
|
if( ! m_aDownload.start(m_aURL, aLocalFile, aDownloadDest ) )
|
2007-07-06 13:36:35 +00:00
|
|
|
{
|
|
|
|
static sal_uInt8 n = 0;
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
// retry every 15s unless the dialog is not visible
|
|
|
|
TimeValue tv;
|
|
|
|
tv.Seconds = 15;
|
|
|
|
|
|
|
|
if( ! UpdateCheck::get()->isDialogShowing() )
|
|
|
|
{
|
|
|
|
// Increase next by 1, 5, 15, 60, .. minutes
|
|
|
|
static const sal_Int16 nRetryInterval[] = { 60, 300, 900, 3600 };
|
|
|
|
|
|
|
|
if( n < sizeof(nRetryInterval) / sizeof(sal_Int16) )
|
|
|
|
++n;
|
|
|
|
|
|
|
|
tv.Seconds = nRetryInterval[n-1];
|
|
|
|
}
|
|
|
|
m_aCondition.wait(&tv);
|
|
|
|
}
|
|
|
|
}
|
2006-08-04 08:56:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
void SAL_CALL DownloadThread::cancel()
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
m_aDownload.stop();
|
|
|
|
resume();
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
rtl::Reference< UpdateCheck > aController(UpdateCheck::get());
|
|
|
|
aController->cancelDownload();
|
|
|
|
}
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
//------------------------------------------------------------------------------
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
void SAL_CALL DownloadThread::suspend()
|
|
|
|
{
|
|
|
|
osl::Thread::suspend();
|
|
|
|
m_aDownload.stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
void SAL_CALL DownloadThread::onTerminated()
|
|
|
|
{
|
|
|
|
delete this;
|
2006-08-04 08:56:09 +00:00
|
|
|
}
|
|
|
|
|
2007-07-31 14:56:29 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
ShutdownThread::ShutdownThread( const uno::Reference<uno::XComponentContext>& xContext) :
|
|
|
|
m_xContext( xContext )
|
|
|
|
{
|
|
|
|
create();
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
ShutdownThread::~ShutdownThread()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL
|
|
|
|
ShutdownThread::run()
|
|
|
|
{
|
|
|
|
TimeValue tv = { 0, 250 };
|
|
|
|
|
|
|
|
m_aCondition.wait(&tv);
|
|
|
|
|
|
|
|
// Tell QuickStarter not to veto ..
|
|
|
|
uno::Reference< beans::XFastPropertySet > xQuickStarter(
|
|
|
|
UpdateCheck::createService(UNISTRING("com.sun.star.office.Quickstart"), m_xContext),
|
|
|
|
uno::UNO_QUERY
|
|
|
|
);
|
|
|
|
|
|
|
|
if (xQuickStarter.is())
|
|
|
|
xQuickStarter->setFastPropertyValue(0, uno::makeAny(false));
|
|
|
|
|
|
|
|
// Shutdown the office
|
|
|
|
uno::Reference< frame::XDesktop > xDesktop(
|
|
|
|
UpdateCheck::createService(UNISTRING("com.sun.star.frame.Desktop"), m_xContext),
|
|
|
|
uno::UNO_QUERY);
|
|
|
|
|
|
|
|
if( xDesktop.is() )
|
|
|
|
xDesktop->terminate();
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL ShutdownThread::onTerminated()
|
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
2006-08-04 08:56:09 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
} // anonymous namespace
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
UpdateCheck::initialize(const uno::Sequence< beans::NamedValue >& rValues,
|
|
|
|
const uno::Reference<uno::XComponentContext>& xContext)
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
osl::MutexGuard aGuard(m_aMutex);
|
|
|
|
|
|
|
|
if( NOT_INITIALIZED == m_eState )
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
NamedValueByNameAccess aNameAccess(rValues);
|
|
|
|
UpdateCheckROModel aModel( aNameAccess );
|
|
|
|
m_xContext = xContext;
|
|
|
|
|
|
|
|
rtl::OUString aUpdateEntryVersion = aModel.getUpdateEntryVersion();
|
|
|
|
|
|
|
|
aModel.getUpdateEntry(m_aUpdateInfo);
|
|
|
|
|
|
|
|
bool obsoleteUpdateInfo = isObsoleteUpdateInfo(aUpdateEntryVersion);
|
2007-11-19 15:47:59 +00:00
|
|
|
|
|
|
|
m_bHasExtensionUpdate = checkForPendingUpdates( xContext );
|
|
|
|
m_bShowExtUpdDlg = false;
|
|
|
|
|
2007-07-31 14:56:29 +00:00
|
|
|
rtl::OUString aLocalFileName = aModel.getLocalFileName();
|
2007-07-06 13:36:35 +00:00
|
|
|
|
2007-07-31 14:56:29 +00:00
|
|
|
if( aLocalFileName.getLength() > 0 )
|
2007-07-06 13:36:35 +00:00
|
|
|
{
|
|
|
|
bool downloadPaused = aModel.isDownloadPaused();
|
|
|
|
|
|
|
|
enableDownload(true, downloadPaused);
|
|
|
|
setUIState(downloadPaused ? UPDATESTATE_DOWNLOAD_PAUSED : UPDATESTATE_DOWNLOADING);
|
2007-07-31 14:56:29 +00:00
|
|
|
|
|
|
|
// Try to get the number of bytes already on disk
|
|
|
|
osl::DirectoryItem aDirectoryItem;
|
|
|
|
if( osl::DirectoryItem::E_None == osl::DirectoryItem::get(aLocalFileName, aDirectoryItem) )
|
|
|
|
{
|
|
|
|
osl::FileStatus aFileStatus(FileStatusMask_FileSize);
|
|
|
|
if( osl::DirectoryItem::E_None == aDirectoryItem.getFileStatus(aFileStatus) )
|
|
|
|
{
|
|
|
|
// Calculate initial percent value.
|
|
|
|
sal_Int32 nPercent = (sal_Int32) (100 * aFileStatus.getFileSize() / aModel.getDownloadSize());
|
|
|
|
getUpdateHandler()->setProgress(nPercent);
|
|
|
|
}
|
|
|
|
}
|
2007-07-06 13:36:35 +00:00
|
|
|
}
|
|
|
|
else
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
// We do this intentionally only if no download is in progress ..
|
|
|
|
if( obsoleteUpdateInfo )
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
// Bring-up release note for position 5 ..
|
|
|
|
const rtl::OUString aURL(getReleaseNote(m_aUpdateInfo, 5));
|
|
|
|
if( aURL.getLength() > 0 )
|
|
|
|
showReleaseNote(aURL);
|
|
|
|
|
|
|
|
// Data is outdated, probably due to installed update
|
|
|
|
rtl::Reference< UpdateCheckConfig > aConfig = UpdateCheckConfig::get( xContext, *this );
|
|
|
|
aConfig->clearUpdateFound();
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
m_aUpdateInfo = UpdateInfo();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
enableAutoCheck(aModel.isAutoCheckEnabled());
|
2007-07-31 14:56:29 +00:00
|
|
|
setUIState(getUIState(m_aUpdateInfo));
|
2007-07-06 13:36:35 +00:00
|
|
|
}
|
2006-08-04 08:56:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
void
|
|
|
|
UpdateCheck::dispose()
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
shutdownThread(true);
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
osl::MutexGuard aGuard(m_aMutex);
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
m_eState = NOT_INITIALIZED;
|
|
|
|
m_xContext.clear();
|
|
|
|
m_xMenuBarUI.clear();
|
|
|
|
m_aUpdateHandler.clear();
|
2006-08-04 08:56:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2007-07-06 13:36:35 +00:00
|
|
|
void
|
|
|
|
UpdateCheck::cancel()
|
2006-09-13 10:26:00 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
osl::ClearableMutexGuard aGuard(m_aMutex);
|
2006-09-13 10:26:00 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
WorkerThread *pThread = m_pThread;
|
2007-07-31 14:56:29 +00:00
|
|
|
UpdateState eUIState = getUIState(m_aUpdateInfo);
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
aGuard.clear();
|
2006-09-13 10:26:00 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
if( NULL != pThread )
|
|
|
|
pThread->cancel();
|
|
|
|
|
2007-07-31 14:56:29 +00:00
|
|
|
setUIState(eUIState);
|
2006-09-13 10:26:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2006-08-04 08:56:09 +00:00
|
|
|
void
|
2007-07-06 13:36:35 +00:00
|
|
|
UpdateCheck::download()
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
osl::ClearableMutexGuard aGuard(m_aMutex);
|
|
|
|
UpdateInfo aInfo(m_aUpdateInfo);
|
|
|
|
State eState = m_eState;
|
|
|
|
aGuard.clear();
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
if( aInfo.Sources[0].IsDirect )
|
|
|
|
{
|
|
|
|
// Ignore second click of a double click
|
|
|
|
if( DOWNLOADING != eState )
|
|
|
|
{
|
|
|
|
shutdownThread(true);
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-31 14:56:29 +00:00
|
|
|
osl::ClearableMutexGuard aGuard2(m_aMutex);
|
2007-07-06 13:36:35 +00:00
|
|
|
enableDownload(true);
|
2007-07-31 14:56:29 +00:00
|
|
|
aGuard2.clear();
|
2007-07-06 13:36:35 +00:00
|
|
|
setUIState(UPDATESTATE_DOWNLOADING);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
showReleaseNote(aInfo.Sources[0].URL); // Display in browser
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void
|
|
|
|
UpdateCheck::install()
|
|
|
|
{
|
|
|
|
osl::MutexGuard aGuard(m_aMutex);
|
|
|
|
|
|
|
|
const uno::Reference< c3s::XSystemShellExecute > xShellExecute(
|
|
|
|
createService( UNISTRING( "com.sun.star.system.SystemShellExecute" ), m_xContext ),
|
|
|
|
uno::UNO_QUERY );
|
2006-08-04 08:56:09 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
// Construct install command ??
|
2006-08-04 08:56:09 +00:00
|
|
|
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
// Store release note for position 3 and 4
|
|
|
|
rtl::OUString aURL(getReleaseNote(m_aUpdateInfo, 3));
|
|
|
|
if( aURL.getLength() > 0 )
|
|
|
|
storeReleaseNote(1, aURL);
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
aURL = getReleaseNote(m_aUpdateInfo, 4);
|
|
|
|
if( aURL.getLength() > 0 )
|
|
|
|
storeReleaseNote(2, aURL);
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
if( xShellExecute.is() )
|
|
|
|
{
|
|
|
|
rtl::OUString aInstallImage(m_aImageName);
|
|
|
|
osl::FileBase::getSystemPathFromFileURL(aInstallImage, aInstallImage);
|
2007-11-26 12:28:42 +00:00
|
|
|
|
|
|
|
rtl::OUString aParameter;
|
|
|
|
sal_Int32 nFlags = c3s::SystemShellExecuteFlags::DEFAULTS;
|
|
|
|
#if ( defined LINUX || defined SOLARIS )
|
|
|
|
nFlags = 42;
|
|
|
|
aParameter = getBaseInstallation();
|
|
|
|
if( aParameter.getLength() > 0 )
|
|
|
|
osl::FileBase::getSystemPathFromFileURL(aParameter, aParameter);
|
|
|
|
|
|
|
|
aParameter += UNISTRING(" &");
|
|
|
|
OSL_TRACE(" Length: %d", aParameter.getLength());
|
|
|
|
#endif
|
|
|
|
xShellExecute->execute(aInstallImage, aParameter, nFlags);
|
|
|
|
ShutdownThread *pShutdownThread = new ShutdownThread( m_xContext );
|
|
|
|
(void) pShutdownThread;
|
2007-07-06 13:36:35 +00:00
|
|
|
}
|
|
|
|
} catch(c3s::SystemShellExecuteException&) {
|
|
|
|
m_aUpdateHandler->setErrorMessage( m_aUpdateHandler->getDefaultInstErrMsg() );
|
|
|
|
}
|
|
|
|
}
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
//------------------------------------------------------------------------------
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
void
|
|
|
|
UpdateCheck::pause()
|
|
|
|
{
|
2007-07-31 14:56:29 +00:00
|
|
|
osl::ClearableMutexGuard aGuard(m_aMutex);
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
if( NULL != m_pThread )
|
|
|
|
m_pThread->suspend();
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
rtl::Reference< UpdateCheckConfig > rModel = UpdateCheckConfig::get(m_xContext);
|
2007-07-31 14:56:29 +00:00
|
|
|
aGuard.clear();
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-31 14:56:29 +00:00
|
|
|
rModel->storeDownloadPaused(true);
|
2007-07-06 13:36:35 +00:00
|
|
|
setUIState(UPDATESTATE_DOWNLOAD_PAUSED);
|
|
|
|
}
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
//------------------------------------------------------------------------------
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
void
|
|
|
|
UpdateCheck::resume()
|
|
|
|
{
|
2007-07-31 14:56:29 +00:00
|
|
|
osl::ClearableMutexGuard aGuard(m_aMutex);
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
if( NULL != m_pThread )
|
|
|
|
m_pThread->resume();
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
rtl::Reference< UpdateCheckConfig > rModel = UpdateCheckConfig::get(m_xContext);
|
2007-07-31 14:56:29 +00:00
|
|
|
aGuard.clear();
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-31 14:56:29 +00:00
|
|
|
rModel->storeDownloadPaused(false);
|
2007-07-06 13:36:35 +00:00
|
|
|
setUIState(UPDATESTATE_DOWNLOADING);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2007-01-29 15:00:00 +00:00
|
|
|
|
2007-07-31 14:56:29 +00:00
|
|
|
void
|
|
|
|
UpdateCheck::closeAfterFailure()
|
|
|
|
{
|
|
|
|
osl::ClearableMutexGuard aGuard(m_aMutex);
|
|
|
|
|
|
|
|
if ( ( m_eState == DISABLED ) || ( m_eState == CHECK_SCHEDULED ) )
|
|
|
|
{
|
|
|
|
const UpdateState eUIState = getUIState( m_aUpdateInfo );
|
|
|
|
aGuard.clear();
|
|
|
|
setUIState( eUIState, true );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
void
|
|
|
|
UpdateCheck::shutdownThread(bool join)
|
|
|
|
{
|
|
|
|
osl::ClearableMutexGuard aGuard(m_aMutex);
|
|
|
|
|
|
|
|
// copy thread object pointer to stack
|
|
|
|
osl::Thread *pThread = m_pThread;
|
|
|
|
m_pThread = NULL;
|
|
|
|
aGuard.clear();
|
|
|
|
|
|
|
|
if( NULL != pThread )
|
|
|
|
{
|
|
|
|
pThread->terminate();
|
|
|
|
if( join )
|
|
|
|
{
|
|
|
|
m_aCondition.set();
|
|
|
|
pThread->join();
|
|
|
|
m_aCondition.reset();
|
2006-08-04 08:56:09 +00:00
|
|
|
}
|
|
|
|
}
|
2007-07-06 13:36:35 +00:00
|
|
|
}
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void
|
|
|
|
UpdateCheck::enableAutoCheck(bool enable)
|
|
|
|
{
|
|
|
|
if( enable )
|
|
|
|
m_pThread = new UpdateCheckThread(m_aCondition, m_xContext);
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
m_eState = enable ? CHECK_SCHEDULED : DISABLED;
|
2006-08-04 08:56:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void
|
2007-07-06 13:36:35 +00:00
|
|
|
UpdateCheck::enableDownload(bool enable, bool paused)
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
OSL_ASSERT(NULL == m_pThread);
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
State eState = DISABLED;
|
|
|
|
if( enable )
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
m_pThread = new DownloadThread(m_aCondition, m_xContext, this, m_aUpdateInfo.Sources[0].URL );
|
|
|
|
if( !paused )
|
|
|
|
{
|
|
|
|
eState = DOWNLOADING;
|
|
|
|
m_pThread->resume();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
eState = DOWNLOAD_PAUSED;
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
m_eState = eState;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
enableAutoCheck(UpdateCheckConfig::get(m_xContext)->isAutoCheckEnabled());
|
|
|
|
}
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
}
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
//------------------------------------------------------------------------------
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
bool
|
|
|
|
UpdateCheck::downloadTargetExists(const rtl::OUString& rFileName)
|
|
|
|
{
|
2007-07-31 14:56:29 +00:00
|
|
|
osl::ClearableMutexGuard aGuard(m_aMutex);
|
2007-07-06 13:36:35 +00:00
|
|
|
|
|
|
|
rtl::Reference< UpdateHandler > aUpdateHandler(getUpdateHandler());
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
bool cont = false;
|
|
|
|
|
|
|
|
if( aUpdateHandler->isVisible() )
|
|
|
|
{
|
|
|
|
cont = aUpdateHandler->showOverwriteWarning();
|
|
|
|
if( cont )
|
|
|
|
{
|
|
|
|
if( osl_File_E_None != osl_removeFile(rFileName.pData) )
|
|
|
|
{
|
|
|
|
// FIXME: error message
|
|
|
|
cont = false;
|
|
|
|
}
|
|
|
|
}
|
2007-07-31 14:56:29 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
UpdateState eUIState = getUIState(m_aUpdateInfo);
|
|
|
|
aGuard.clear();
|
|
|
|
setUIState(eUIState);
|
|
|
|
}
|
2007-07-06 13:36:35 +00:00
|
|
|
}
|
2007-07-31 14:56:29 +00:00
|
|
|
|
|
|
|
if( !cont )
|
2006-11-01 09:12:28 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
shutdownThread(false);
|
|
|
|
enableDownload(false);
|
2006-11-01 09:12:28 +00:00
|
|
|
}
|
2007-07-06 13:36:35 +00:00
|
|
|
|
|
|
|
return cont;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void
|
|
|
|
UpdateCheck::downloadStalled(const rtl::OUString& rErrorMessage)
|
|
|
|
{
|
2007-07-31 14:56:29 +00:00
|
|
|
osl::ClearableMutexGuard aGuard(m_aMutex);
|
|
|
|
rtl::Reference< UpdateHandler > aUpdateHandler(getUpdateHandler());
|
|
|
|
aGuard.clear();
|
|
|
|
|
|
|
|
aUpdateHandler->setErrorMessage(rErrorMessage);
|
2007-07-06 13:36:35 +00:00
|
|
|
setUIState(UPDATESTATE_ERROR_DOWNLOADING);
|
2006-11-01 09:12:28 +00:00
|
|
|
}
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2006-11-01 09:12:28 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void
|
2007-07-06 13:36:35 +00:00
|
|
|
UpdateCheck::downloadProgressAt(sal_Int8 nPercent)
|
2006-11-01 09:12:28 +00:00
|
|
|
{
|
2007-07-31 14:56:29 +00:00
|
|
|
osl::ClearableMutexGuard aGuard(m_aMutex);
|
|
|
|
rtl::Reference< UpdateHandler > aUpdateHandler(getUpdateHandler());
|
|
|
|
aGuard.clear();
|
|
|
|
|
|
|
|
aUpdateHandler->setProgress(nPercent);
|
2007-07-06 13:36:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void
|
2007-07-31 14:56:29 +00:00
|
|
|
UpdateCheck::downloadStarted(const rtl::OUString& rLocalFileName, sal_Int64 nFileSize)
|
2007-07-06 13:36:35 +00:00
|
|
|
{
|
|
|
|
osl::MutexGuard aGuard(m_aMutex);
|
|
|
|
|
|
|
|
rtl::Reference< UpdateCheckConfig > aModel(UpdateCheckConfig::get(m_xContext));
|
2007-07-31 14:56:29 +00:00
|
|
|
aModel->storeLocalFileName(rLocalFileName, nFileSize);
|
2007-07-06 13:36:35 +00:00
|
|
|
|
|
|
|
// Bring-up release note for position 1 ..
|
|
|
|
const rtl::OUString aURL(getReleaseNote(m_aUpdateInfo, 1, aModel->isAutoDownloadEnabled()));
|
|
|
|
if( aURL.getLength() > 0 )
|
|
|
|
showReleaseNote(aURL);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void
|
|
|
|
UpdateCheck::downloadFinished(const rtl::OUString& rLocalFileName)
|
|
|
|
{
|
2007-07-31 14:56:29 +00:00
|
|
|
osl::ClearableMutexGuard aGuard(m_aMutex);
|
2007-07-06 13:36:35 +00:00
|
|
|
|
|
|
|
// no more retries
|
|
|
|
m_pThread->terminate();
|
|
|
|
|
|
|
|
rtl::Reference< UpdateCheckConfig > rModel = UpdateCheckConfig::get(m_xContext);
|
|
|
|
rModel->clearLocalFileName();
|
|
|
|
|
2007-11-26 12:28:42 +00:00
|
|
|
m_aImageName = getImageFromFileName(rLocalFileName);
|
2007-07-31 14:56:29 +00:00
|
|
|
UpdateInfo aUpdateInfo(m_aUpdateInfo);
|
|
|
|
|
|
|
|
aGuard.clear();
|
2007-07-06 13:36:35 +00:00
|
|
|
setUIState(UPDATESTATE_DOWNLOAD_AVAIL);
|
|
|
|
|
|
|
|
// Bring-up release note for position 2 ..
|
2007-07-31 14:56:29 +00:00
|
|
|
const rtl::OUString aURL(getReleaseNote(aUpdateInfo, 2, rModel->isAutoDownloadEnabled()));
|
2007-07-06 13:36:35 +00:00
|
|
|
if( aURL.getLength() > 0 )
|
|
|
|
showReleaseNote(aURL);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void
|
|
|
|
UpdateCheck::cancelDownload()
|
|
|
|
{
|
|
|
|
shutdownThread(true);
|
|
|
|
|
|
|
|
osl::MutexGuard aGuard(m_aMutex);
|
|
|
|
enableDownload(false);
|
|
|
|
|
|
|
|
rtl::Reference< UpdateCheckConfig > rModel = UpdateCheckConfig::get(m_xContext);
|
|
|
|
|
|
|
|
rtl::OUString aLocalFile(rModel->getLocalFileName());
|
|
|
|
rModel->clearLocalFileName();
|
|
|
|
rModel->storeDownloadPaused(false);
|
|
|
|
|
|
|
|
if( isObsoleteUpdateInfo(rModel->getUpdateEntryVersion()) )
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
rModel->clearUpdateFound(); // This wasn't done during init yet ..
|
|
|
|
m_aUpdateInfo = UpdateInfo();
|
2006-08-04 08:56:09 +00:00
|
|
|
}
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
/*oslFileError rc =*/ osl_removeFile(aLocalFile.pData);
|
|
|
|
// FIXME: error handling ..
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
}
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
//------------------------------------------------------------------------------
|
2006-11-01 09:12:28 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
void
|
|
|
|
UpdateCheck::showDialog(bool forceCheck)
|
|
|
|
{
|
2007-07-31 14:56:29 +00:00
|
|
|
osl::ResettableMutexGuard aGuard(m_aMutex);
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
bool update_found = m_aUpdateInfo.BuildId.getLength() > 0;
|
|
|
|
bool bSetUIState = ! m_aUpdateHandler.is();
|
|
|
|
|
|
|
|
UpdateState eDialogState = UPDATESTATES_COUNT;
|
|
|
|
|
|
|
|
switch( m_eState )
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
case DISABLED:
|
|
|
|
case CHECK_SCHEDULED:
|
|
|
|
if( forceCheck || ! update_found ) // Run check when forced or if we did not find an update yet
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
eDialogState = UPDATESTATE_CHECKING;
|
|
|
|
bSetUIState = true;
|
2006-08-04 08:56:09 +00:00
|
|
|
}
|
2007-07-06 13:36:35 +00:00
|
|
|
else if(m_aUpdateInfo.Sources[0].IsDirect)
|
|
|
|
eDialogState = UPDATESTATE_UPDATE_AVAIL;
|
|
|
|
else
|
|
|
|
eDialogState = UPDATESTATE_UPDATE_NO_DOWNLOAD;
|
|
|
|
break;
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
case DOWNLOADING:
|
|
|
|
eDialogState = UPDATESTATE_DOWNLOADING;
|
|
|
|
break;
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
case DOWNLOAD_PAUSED:
|
|
|
|
eDialogState = UPDATESTATE_DOWNLOAD_PAUSED;
|
|
|
|
break;
|
|
|
|
|
2007-07-31 14:56:29 +00:00
|
|
|
case NOT_INITIALIZED:
|
2007-07-06 13:36:35 +00:00
|
|
|
OSL_ASSERT( false );
|
2007-07-31 14:56:29 +00:00
|
|
|
break;
|
2006-08-04 08:56:09 +00:00
|
|
|
}
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
if( bSetUIState )
|
2007-07-31 14:56:29 +00:00
|
|
|
{
|
|
|
|
aGuard.clear();
|
2007-07-06 13:36:35 +00:00
|
|
|
setUIState(eDialogState, true); // suppress bubble as Dialog will be visible soon
|
2007-07-31 14:56:29 +00:00
|
|
|
aGuard.reset();
|
|
|
|
}
|
2007-07-06 13:36:35 +00:00
|
|
|
|
|
|
|
getUpdateHandler()->setVisible(true);
|
|
|
|
|
|
|
|
// Run check in separate thread ..
|
|
|
|
if( UPDATESTATE_CHECKING == eDialogState )
|
|
|
|
{
|
|
|
|
if( DISABLED == m_eState )
|
|
|
|
{
|
|
|
|
// destructs itself when done, not cancellable for now ..
|
|
|
|
new ManualUpdateCheckThread(m_aCondition, m_xContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_aCondition.set();
|
|
|
|
}
|
2006-08-04 08:56:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
void
|
|
|
|
UpdateCheck::setUpdateInfo(const UpdateInfo& aInfo)
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-31 14:56:29 +00:00
|
|
|
osl::ClearableMutexGuard aGuard(m_aMutex);
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
bool bSuppressBubble = (sal_True == aInfo.BuildId.equals(m_aUpdateInfo.BuildId));
|
|
|
|
m_aUpdateInfo = aInfo;
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
OSL_ASSERT(DISABLED == m_eState || CHECK_SCHEDULED == m_eState);
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
// Ignore leading non direct download if we get direct ones
|
|
|
|
std::vector< DownloadSource >::iterator iter = m_aUpdateInfo.Sources.begin();
|
|
|
|
while( iter != m_aUpdateInfo.Sources.end() )
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
if( iter->IsDirect )
|
|
|
|
break;
|
2006-11-01 09:12:28 +00:00
|
|
|
|
2007-07-31 14:56:29 +00:00
|
|
|
++iter;
|
2007-07-06 13:36:35 +00:00
|
|
|
}
|
2006-11-01 09:12:28 +00:00
|
|
|
|
2007-07-13 10:15:08 +00:00
|
|
|
if( (iter != m_aUpdateInfo.Sources.begin()) &&
|
|
|
|
(iter != m_aUpdateInfo.Sources.end()) &&
|
|
|
|
iter->IsDirect )
|
2007-07-06 13:36:35 +00:00
|
|
|
{
|
2007-07-31 14:56:29 +00:00
|
|
|
m_aUpdateInfo.Sources.erase(m_aUpdateInfo.Sources.begin(), --iter);
|
2006-08-04 08:56:09 +00:00
|
|
|
}
|
2007-07-06 13:36:35 +00:00
|
|
|
|
|
|
|
rtl::Reference< UpdateCheckConfig > rModel = UpdateCheckConfig::get(m_xContext, *this);
|
|
|
|
OSL_ASSERT( rModel.is() );
|
|
|
|
|
|
|
|
// Decide whether to use alternate release note pos ..
|
|
|
|
bool autoDownloadEnabled = rModel->isAutoDownloadEnabled();
|
|
|
|
|
|
|
|
std::vector< ReleaseNote >::iterator iter2 = m_aUpdateInfo.ReleaseNotes.begin();
|
|
|
|
while( iter2 != m_aUpdateInfo.ReleaseNotes.end() )
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
if( ((1 == iter2->Pos) || (2 == iter2->Pos)) && autoDownloadEnabled && (iter2->URL2.getLength() > 0))
|
|
|
|
{
|
|
|
|
iter2->URL = iter2->URL2;
|
|
|
|
iter2->URL2 = rtl::OUString();
|
|
|
|
iter2->Pos = iter2->Pos2;
|
|
|
|
iter2->Pos2 = 0;
|
|
|
|
}
|
|
|
|
|
2007-07-31 14:56:29 +00:00
|
|
|
++iter2;
|
2007-07-06 13:36:35 +00:00
|
|
|
}
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
// do not move below store/clear ..
|
|
|
|
rModel->updateLastChecked();
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
UpdateState eUIState;
|
|
|
|
if( m_aUpdateInfo.Sources.size() > 0 )
|
|
|
|
{
|
|
|
|
rModel->storeUpdateFound(aInfo, getBuildId());
|
|
|
|
|
|
|
|
if( m_aUpdateInfo.Sources[0].IsDirect )
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
eUIState = UPDATESTATE_UPDATE_AVAIL;
|
|
|
|
|
|
|
|
if( rModel->isAutoDownloadEnabled() )
|
2006-11-01 09:12:28 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
shutdownThread(false);
|
|
|
|
eUIState = UPDATESTATE_DOWNLOADING;
|
|
|
|
enableDownload(true);
|
2006-11-01 09:12:28 +00:00
|
|
|
}
|
2007-07-06 13:36:35 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
eUIState = UPDATESTATE_UPDATE_NO_DOWNLOAD;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
eUIState = UPDATESTATE_NO_UPDATE_AVAIL;
|
|
|
|
rModel->clearUpdateFound();
|
|
|
|
}
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-31 14:56:29 +00:00
|
|
|
aGuard.clear();
|
2007-07-06 13:36:35 +00:00
|
|
|
setUIState(eUIState, bSuppressBubble);
|
|
|
|
}
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
//------------------------------------------------------------------------------
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-31 14:56:29 +00:00
|
|
|
void
|
|
|
|
UpdateCheck::setCheckFailedState()
|
|
|
|
{
|
|
|
|
setUIState(UPDATESTATE_ERROR_CHECKING);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2007-11-19 15:47:59 +00:00
|
|
|
void UpdateCheck::handleMenuBarUI( rtl::Reference< UpdateHandler > rUpdateHandler,
|
|
|
|
UpdateState& eState,
|
|
|
|
bool suppressBubble )
|
|
|
|
{
|
|
|
|
uno::Reference<beans::XPropertySet> xMenuBarUI( m_xMenuBarUI );
|
2007-07-31 14:56:29 +00:00
|
|
|
|
2007-11-19 15:47:59 +00:00
|
|
|
if ( ( UPDATESTATE_NO_UPDATE_AVAIL == eState ) && m_bHasExtensionUpdate )
|
|
|
|
eState = UPDATESTATE_EXT_UPD_AVAIL;
|
|
|
|
|
|
|
|
if ( UPDATESTATE_EXT_UPD_AVAIL == eState )
|
|
|
|
m_bShowExtUpdDlg = true;
|
|
|
|
else
|
|
|
|
m_bShowExtUpdDlg = false;
|
|
|
|
|
|
|
|
if( xMenuBarUI.is() )
|
|
|
|
{
|
|
|
|
if( UPDATESTATE_NO_UPDATE_AVAIL == eState )
|
|
|
|
{
|
|
|
|
xMenuBarUI->setPropertyValue( PROPERTY_SHOW_MENUICON, uno::makeAny(sal_False) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xMenuBarUI->setPropertyValue( PROPERTY_TITLE, uno::makeAny(rUpdateHandler->getBubbleTitle(eState)) );
|
|
|
|
xMenuBarUI->setPropertyValue( PROPERTY_TEXT, uno::makeAny(rUpdateHandler->getBubbleText(eState)) );
|
|
|
|
|
|
|
|
if( ! suppressBubble && ( ! rUpdateHandler->isVisible() || rUpdateHandler->isMinimized() ) )
|
|
|
|
xMenuBarUI->setPropertyValue( PROPERTY_SHOW_BUBBLE, uno::makeAny( sal_True ) );
|
|
|
|
|
|
|
|
if( UPDATESTATE_CHECKING != eState )
|
|
|
|
xMenuBarUI->setPropertyValue( PROPERTY_SHOW_MENUICON, uno::makeAny(sal_True) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2007-07-06 13:36:35 +00:00
|
|
|
void UpdateCheck::setUIState(UpdateState eState, bool suppressBubble)
|
|
|
|
{
|
2007-07-31 14:56:29 +00:00
|
|
|
osl::ClearableMutexGuard aGuard(m_aMutex);
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
if( ! m_xMenuBarUI.is() &&
|
|
|
|
(DISABLED != m_eState) &&
|
2007-11-19 15:47:59 +00:00
|
|
|
( m_bHasExtensionUpdate || (UPDATESTATE_NO_UPDATE_AVAIL != eState)) &&
|
2007-07-31 14:56:29 +00:00
|
|
|
(UPDATESTATE_CHECKING != eState) &&
|
|
|
|
(UPDATESTATE_ERROR_CHECKING != eState)
|
2007-07-06 13:36:35 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
m_xMenuBarUI = createMenuBarUI(m_xContext, new MenuBarButtonJob(this));
|
|
|
|
}
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-31 14:56:29 +00:00
|
|
|
rtl::Reference<UpdateHandler> aUpdateHandler(getUpdateHandler());
|
2007-07-06 13:36:35 +00:00
|
|
|
OSL_ASSERT( aUpdateHandler.is() );
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-31 14:56:29 +00:00
|
|
|
UpdateInfo aUpdateInfo(m_aUpdateInfo);
|
|
|
|
rtl::OUString aImageName(m_aImageName);
|
2007-07-06 13:36:35 +00:00
|
|
|
|
2007-07-31 14:56:29 +00:00
|
|
|
aGuard.clear();
|
2007-07-06 13:36:35 +00:00
|
|
|
|
2007-11-19 15:47:59 +00:00
|
|
|
handleMenuBarUI( aUpdateHandler, eState, suppressBubble );
|
2007-07-06 13:36:35 +00:00
|
|
|
|
|
|
|
if( UPDATESTATE_UPDATE_AVAIL == eState )
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-11-19 15:47:59 +00:00
|
|
|
uno::Reference< uno::XComponentContext > xContext(m_xContext);
|
2007-07-31 14:56:29 +00:00
|
|
|
aUpdateHandler->setNextVersion(aUpdateInfo.Version);
|
2007-07-06 13:36:35 +00:00
|
|
|
|
2007-07-31 14:56:29 +00:00
|
|
|
rtl::OUString aDownloadDestination =
|
|
|
|
UpdateCheckConfig::get(xContext, this)->getDownloadDestination();
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-31 14:56:29 +00:00
|
|
|
osl_getSystemPathFromFileURL(aDownloadDestination.pData, &aDownloadDestination.pData);
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-31 14:56:29 +00:00
|
|
|
aUpdateHandler->setDownloadPath(aDownloadDestination);
|
2007-07-06 13:36:35 +00:00
|
|
|
}
|
|
|
|
else if( UPDATESTATE_DOWNLOAD_AVAIL == eState )
|
|
|
|
{
|
2007-07-31 14:56:29 +00:00
|
|
|
aUpdateHandler->setDownloadFile(aImageName);
|
2006-08-04 08:56:09 +00:00
|
|
|
}
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
if( (UPDATESTATE_UPDATE_AVAIL == eState) || (UPDATESTATE_UPDATE_NO_DOWNLOAD == eState) )
|
|
|
|
{
|
2007-07-31 14:56:29 +00:00
|
|
|
aUpdateHandler->setDescription(aUpdateInfo.Description);
|
2007-07-06 13:36:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
aUpdateHandler->setState(eState);
|
2006-08-04 08:56:09 +00:00
|
|
|
}
|
|
|
|
|
2006-11-01 09:12:28 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2007-07-31 14:56:29 +00:00
|
|
|
UpdateState
|
|
|
|
UpdateCheck::getUIState(const UpdateInfo& rInfo)
|
2006-11-01 09:12:28 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
UpdateState eUIState = UPDATESTATE_NO_UPDATE_AVAIL;
|
2006-11-01 09:12:28 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
if( rInfo.BuildId.getLength() > 0 )
|
2006-11-01 09:12:28 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
if( rInfo.Sources[0].IsDirect )
|
|
|
|
eUIState = UPDATESTATE_UPDATE_AVAIL;
|
|
|
|
else
|
|
|
|
eUIState = UPDATESTATE_UPDATE_NO_DOWNLOAD;
|
|
|
|
}
|
2006-11-01 09:12:28 +00:00
|
|
|
|
2007-07-31 14:56:29 +00:00
|
|
|
return eUIState;
|
2007-07-06 13:36:35 +00:00
|
|
|
}
|
2006-11-01 09:12:28 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
//------------------------------------------------------------------------------
|
2006-11-01 09:12:28 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
void
|
|
|
|
UpdateCheck::showReleaseNote(const rtl::OUString& rURL) const
|
|
|
|
{
|
|
|
|
const uno::Reference< c3s::XSystemShellExecute > xShellExecute(
|
|
|
|
createService( UNISTRING( "com.sun.star.system.SystemShellExecute" ), m_xContext ),
|
|
|
|
uno::UNO_QUERY );
|
2006-11-01 09:12:28 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
try {
|
2006-11-01 09:12:28 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
if( xShellExecute.is() )
|
|
|
|
xShellExecute->execute(rURL, rtl::OUString(), c3s::SystemShellExecuteFlags::DEFAULTS);
|
|
|
|
} catch(c3s::SystemShellExecuteException&) {
|
2006-11-01 09:12:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-04 08:56:09 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
bool
|
|
|
|
UpdateCheck::storeReleaseNote(sal_Int8 nNum, const rtl::OUString &rURL)
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
osl::FileBase::RC rc;
|
|
|
|
rtl::OUString aTargetDir( UpdateCheckConfig::getAllUsersDirectory() + UNISTRING( "/sun" ) );
|
|
|
|
|
|
|
|
rc = osl::Directory::createPath( aTargetDir );
|
|
|
|
|
|
|
|
rtl::OUString aFileName = UNISTRING("releasenote") +
|
|
|
|
rtl::OUString::valueOf( (sal_Int32) nNum ) +
|
|
|
|
UNISTRING(".url");
|
|
|
|
|
|
|
|
rtl::OUString aFilePath;
|
|
|
|
rc = osl::FileBase::getAbsoluteFileURL( aTargetDir, aFileName, aFilePath );
|
|
|
|
if ( rc != osl::FileBase::E_None ) return false;
|
|
|
|
|
|
|
|
rc = osl::File::remove( aFilePath );
|
|
|
|
|
|
|
|
osl::File aFile( aFilePath );
|
|
|
|
rc = aFile.open( OpenFlag_Write | OpenFlag_Create );
|
|
|
|
|
|
|
|
if ( rc != osl::FileBase::E_None ) return false;
|
|
|
|
|
|
|
|
rtl::OString aLineBuf("[InternetShortcut]\r\n");
|
|
|
|
sal_uInt64 nWritten = 0;
|
|
|
|
|
|
|
|
rtl::OUString aURL( rURL );
|
|
|
|
#ifdef WNT
|
|
|
|
rc = aFile.write( aLineBuf.getStr(), aLineBuf.getLength(), nWritten );
|
|
|
|
if ( rc != osl::FileBase::E_None ) return false;
|
|
|
|
aURL = UNISTRING("URL=") + rURL;
|
|
|
|
#endif
|
|
|
|
aLineBuf = rtl::OUStringToOString( aURL, RTL_TEXTENCODING_UTF8 );
|
|
|
|
rc = aFile.write( aLineBuf.getStr(), aLineBuf.getLength(), nWritten );
|
|
|
|
if ( rc != osl::FileBase::E_None ) return false;
|
|
|
|
|
|
|
|
aFile.close();
|
|
|
|
return true;
|
2006-08-04 08:56:09 +00:00
|
|
|
}
|
|
|
|
|
2007-11-19 15:47:59 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void UpdateCheck::showExtensionDialog()
|
|
|
|
{
|
|
|
|
rtl::OUString sServiceName = UNISTRING("com.sun.star.deployment.ui.PackageManagerDialog");
|
|
|
|
rtl::OUString sArguments = UNISTRING("SHOW_UPDATE_DIALOG");
|
|
|
|
uno::Reference< uno::XInterface > xService;
|
|
|
|
|
|
|
|
if( ! m_xContext.is() )
|
|
|
|
throw uno::RuntimeException(
|
|
|
|
UNISTRING( "UpdateCheck::showExtensionDialog(): empty component context" ), uno::Reference< uno::XInterface > () );
|
|
|
|
|
|
|
|
uno::Reference< lang::XMultiComponentFactory > xServiceManager( m_xContext->getServiceManager() );
|
|
|
|
if( !xServiceManager.is() )
|
|
|
|
throw uno::RuntimeException(
|
|
|
|
UNISTRING( "UpdateCheck::showExtensionDialog(): unable to obtain service manager from component context" ), uno::Reference< uno::XInterface > () );
|
|
|
|
|
|
|
|
xService = xServiceManager->createInstanceWithContext( sServiceName, m_xContext );
|
|
|
|
uno::Reference< task::XJobExecutor > xExecuteable( xService, uno::UNO_QUERY );
|
|
|
|
if ( xExecuteable.is() )
|
|
|
|
xExecuteable->trigger( sArguments );
|
|
|
|
}
|
|
|
|
|
2006-08-04 08:56:09 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
rtl::Reference<UpdateHandler>
|
|
|
|
UpdateCheck::getUpdateHandler()
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
if( ! m_aUpdateHandler.is() )
|
|
|
|
m_aUpdateHandler = new UpdateHandler(m_xContext, this);
|
|
|
|
|
|
|
|
return m_aUpdateHandler;
|
2006-08-04 08:56:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
uno::Reference< task::XInteractionHandler >
|
|
|
|
UpdateCheck::getInteractionHandler() const
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
osl::MutexGuard aGuard(m_aMutex);
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
uno::Reference< task::XInteractionHandler > xHandler;
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
if( m_aUpdateHandler.is() && m_aUpdateHandler->isVisible() )
|
|
|
|
xHandler = m_aUpdateHandler.get();
|
|
|
|
|
|
|
|
return xHandler;
|
2006-08-04 08:56:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
uno::Reference< uno::XInterface >
|
|
|
|
UpdateCheck::createService(const rtl::OUString& rServiceName,
|
|
|
|
const uno::Reference<uno::XComponentContext>& xContext)
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
if( !xContext.is() )
|
|
|
|
throw uno::RuntimeException(
|
|
|
|
UNISTRING( "UpdateCheckConfig: empty component context" ),
|
|
|
|
uno::Reference< uno::XInterface >() );
|
2007-01-29 15:00:00 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
const uno::Reference< lang::XMultiComponentFactory > xServiceManager(xContext->getServiceManager());
|
2007-01-29 15:00:00 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
if( !xServiceManager.is() )
|
|
|
|
throw uno::RuntimeException(
|
|
|
|
UNISTRING( "UpdateCheckConfig: unable to obtain service manager from component context" ),
|
|
|
|
uno::Reference< uno::XInterface >() );
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
return xServiceManager->createInstanceWithContext(rServiceName, xContext);
|
|
|
|
}
|
2006-08-04 08:56:09 +00:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
uno::Reference< uno::XInterface >
|
|
|
|
UpdateCheck::createService(const rtl::OUString& rServiceName) const
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
osl::MutexGuard aGuard(m_aMutex);
|
|
|
|
const uno::Reference<uno::XComponentContext>& xContext(m_xContext);
|
|
|
|
return createService(rServiceName, xContext);
|
2006-08-04 08:56:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
bool
|
|
|
|
UpdateCheck::isDialogShowing() const
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
osl::MutexGuard aGuard(m_aMutex);
|
|
|
|
return sal_True == m_aUpdateHandler.is() && m_aUpdateHandler->isVisible();
|
|
|
|
};
|
2006-08-04 08:56:09 +00:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
void
|
|
|
|
UpdateCheck::autoCheckStatusChanged(bool enabled)
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-31 14:56:29 +00:00
|
|
|
osl::ClearableMutexGuard aGuard(m_aMutex);
|
2006-11-01 09:12:28 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
if( (CHECK_SCHEDULED == m_eState) && !enabled )
|
|
|
|
shutdownThread(false);
|
2006-08-04 08:56:09 +00:00
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
if( (DISABLED == m_eState) || (CHECK_SCHEDULED == m_eState) )
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
enableAutoCheck(enabled);
|
2007-07-31 14:56:29 +00:00
|
|
|
UpdateState eState = getUIState(m_aUpdateInfo);
|
|
|
|
aGuard.clear();
|
|
|
|
setUIState(eState);
|
2007-07-06 13:36:35 +00:00
|
|
|
}
|
|
|
|
};
|
2006-08-04 08:56:09 +00:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
void
|
|
|
|
UpdateCheck::autoCheckIntervalChanged()
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
// just wake-up
|
|
|
|
m_aCondition.set();
|
|
|
|
};
|
2006-08-04 08:56:09 +00:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
oslInterlockedCount SAL_CALL
|
|
|
|
UpdateCheck::acquire() SAL_THROW(())
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
return ReferenceObject::acquire();
|
2006-08-04 08:56:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2007-07-06 13:36:35 +00:00
|
|
|
oslInterlockedCount SAL_CALL
|
|
|
|
UpdateCheck::release() SAL_THROW(())
|
2006-08-04 08:56:09 +00:00
|
|
|
{
|
2007-07-06 13:36:35 +00:00
|
|
|
return ReferenceObject::release();
|
2006-08-04 08:56:09 +00:00
|
|
|
}
|