From b6103ae98b92524b04d3fe261c445135002a65c2 Mon Sep 17 00:00:00 2001 From: Dirk Völzke Date: Mon, 24 Aug 2009 07:40:00 +0000 Subject: #i88957# Improved handling of already downloaded updates --- extensions/source/update/check/download.cxx | 48 ++++++++++++-- extensions/source/update/check/download.hxx | 2 + extensions/source/update/check/updatecheck.cxx | 69 +++++++++++++++++---- extensions/source/update/check/updatecheck.hxx | 2 + extensions/source/update/check/updatehdl.cxx | 86 ++++++++++++++++++++++++++ extensions/source/update/check/updatehdl.hrc | 3 + extensions/source/update/check/updatehdl.hxx | 5 ++ extensions/source/update/check/updatehdl.src | 15 +++++ 8 files changed, 213 insertions(+), 17 deletions(-) (limited to 'extensions') diff --git a/extensions/source/update/check/download.cxx b/extensions/source/update/check/download.cxx index eaa16a9f9368..8c64c037da7e 100644 --- a/extensions/source/update/check/download.cxx +++ b/extensions/source/update/check/download.cxx @@ -172,7 +172,9 @@ progress_callback( void *clientp, double dltotal, double dlnow, double ultotal, if( ! out->StopCondition.check() ) { - double fPercent = (dlnow + out->Offset) * 100 / (dltotal + out->Offset); + double fPercent = 0; + if ( dltotal + out->Offset ) + fPercent = (dlnow + out->Offset) * 100 / (dltotal + out->Offset); if( fPercent < 0 ) fPercent = 0; @@ -333,14 +335,52 @@ Download::start(const rtl::OUString& rURL, const rtl::OUString& rFile, const rtl OSL_ASSERT( m_aHandler.is() ); OutData out(m_aCondition); + rtl::OUString aFile( rFile ); - out.File = rFile; + // when rFile is empty, there is no remembered file name. If there is already a file with the + // same name ask the user if she wants to resume a download or restart the download + if ( !aFile.getLength() ) + { + // GetFileName() + rtl::OUString aURL( rURL ); + // ensure no trailing '/' + sal_Int32 nLen = aURL.getLength(); + while( (nLen > 0) && ('/' == aURL[ nLen-1 ]) ) + aURL = aURL.copy( 0, --nLen ); + + // extract file name last '/' + sal_Int32 nIndex = aURL.lastIndexOf('/'); + aFile = rDestinationDir + aURL.copy( nIndex ); + + // check for existing file + oslFileError rc = osl_openFile( aFile.pData, &out.FileHandle, osl_File_OpenFlag_Write | osl_File_OpenFlag_Create ); + osl_closeFile(out.FileHandle); + out.FileHandle = NULL; + + if( osl_File_E_EXIST == rc ) + { + if ( m_aHandler->checkDownloadDestination( aURL.copy( nIndex+1 ) ) ) + { + osl_removeFile( aFile.pData ); + aFile = rtl::OUString(); + } + else + m_aHandler->downloadStarted( aFile, 1 ); + } + else + { + osl_removeFile( aFile.pData ); + aFile = rtl::OUString(); + } + } + + out.File = aFile; out.DestinationDir = rDestinationDir; out.Handler = m_aHandler; - if( rFile.getLength() > 0 ) + if( aFile.getLength() > 0 ) { - oslFileError rc = osl_openFile(rFile.pData, &out.FileHandle, osl_File_OpenFlag_Write); + oslFileError rc = osl_openFile(aFile.pData, &out.FileHandle, osl_File_OpenFlag_Write); if( osl_File_E_None == rc ) { diff --git a/extensions/source/update/check/download.hxx b/extensions/source/update/check/download.hxx index 24c2842a709d..034f39dbe733 100644 --- a/extensions/source/update/check/download.hxx +++ b/extensions/source/update/check/download.hxx @@ -38,6 +38,8 @@ struct DownloadInteractionHandler : public rtl::IReference { + virtual bool checkDownloadDestination(const rtl::OUString& rFileName) = 0; + // called if the destination file already exists, but resume is false virtual bool downloadTargetExists(const rtl::OUString& rFileName) = 0; diff --git a/extensions/source/update/check/updatecheck.cxx b/extensions/source/update/check/updatecheck.cxx index 23d4da29a41f..09776f1fc1c4 100644 --- a/extensions/source/update/check/updatecheck.cxx +++ b/extensions/source/update/check/updatecheck.cxx @@ -785,6 +785,8 @@ UpdateCheck::initialize(const uno::Sequence< beans::NamedValue >& rValues, aModel.getUpdateEntry(m_aUpdateInfo); bool obsoleteUpdateInfo = isObsoleteUpdateInfo(aUpdateEntryVersion); + bool bContinueDownload = false; + bool bDownloadAvailable = false; m_bHasExtensionUpdate = checkForPendingUpdates( xContext ); m_bShowExtUpdDlg = false; @@ -793,10 +795,7 @@ UpdateCheck::initialize(const uno::Sequence< beans::NamedValue >& rValues, if( aLocalFileName.getLength() > 0 ) { - bool downloadPaused = aModel.isDownloadPaused(); - - enableDownload(true, downloadPaused); - setUIState(downloadPaused ? UPDATESTATE_DOWNLOAD_PAUSED : UPDATESTATE_DOWNLOADING); + bContinueDownload = true; // Try to get the number of bytes already on disk osl::DirectoryItem aDirectoryItem; @@ -805,16 +804,36 @@ UpdateCheck::initialize(const uno::Sequence< beans::NamedValue >& rValues, osl::FileStatus aFileStatus(FileStatusMask_FileSize); if( osl::DirectoryItem::E_None == aDirectoryItem.getFileStatus(aFileStatus) ) { - // Calculate initial percent value. - if( aModel.getDownloadSize() > 0 ) + sal_Int64 nDownloadSize = aModel.getDownloadSize(); + sal_Int64 nFileSize = aFileStatus.getFileSize(); + + if( nDownloadSize > 0 ) { - sal_Int32 nPercent = (sal_Int32) (100 * aFileStatus.getFileSize() / aModel.getDownloadSize()); - getUpdateHandler()->setProgress(nPercent); + if ( nDownloadSize == nFileSize ) // we have already downloaded everthing + { + bContinueDownload = false; + bDownloadAvailable = true; + m_aImageName = getImageFromFileName( aLocalFileName ); + } + else // Calculate initial percent value. + { + sal_Int32 nPercent = (sal_Int32) (100 * nFileSize / nDownloadSize); + getUpdateHandler()->setProgress( nPercent ); + } } } } + + if ( bContinueDownload ) + { + bool downloadPaused = aModel.isDownloadPaused(); + + enableDownload(true, downloadPaused); + setUIState(downloadPaused ? UPDATESTATE_DOWNLOAD_PAUSED : UPDATESTATE_DOWNLOADING); + } + } - else + if ( !bContinueDownload ) { // We do this intentionally only if no download is in progress .. if( obsoleteUpdateInfo ) @@ -827,13 +846,18 @@ UpdateCheck::initialize(const uno::Sequence< beans::NamedValue >& rValues, // Data is outdated, probably due to installed update rtl::Reference< UpdateCheckConfig > aConfig = UpdateCheckConfig::get( xContext, *this ); aConfig->clearUpdateFound(); + aConfig->clearLocalFileName(); + m_aUpdateInfo = UpdateInfo(); } else { enableAutoCheck(aModel.isAutoCheckEnabled()); - setUIState(getUIState(m_aUpdateInfo)); + if ( bDownloadAvailable ) + setUIState( UPDATESTATE_DOWNLOAD_AVAIL ); + else + setUIState(getUIState(m_aUpdateInfo)); } } } @@ -922,6 +946,10 @@ UpdateCheck::install() aParameter += UNISTRING(" &"); #endif + + rtl::Reference< UpdateCheckConfig > rModel = UpdateCheckConfig::get( m_xContext ); + rModel->clearLocalFileName(); + xShellExecute->execute(aInstallImage, aParameter, nFlags); ShutdownThread *pShutdownThread = new ShutdownThread( m_xContext ); (void) pShutdownThread; @@ -1086,6 +1114,23 @@ UpdateCheck::downloadTargetExists(const rtl::OUString& rFileName) return cont; } +//------------------------------------------------------------------------------ +bool UpdateCheck::checkDownloadDestination( const rtl::OUString& rFileName ) +{ + osl::ClearableMutexGuard aGuard(m_aMutex); + + rtl::Reference< UpdateHandler > aUpdateHandler( getUpdateHandler() ); + + bool bReload = false; + + if( aUpdateHandler->isVisible() ) + { + bReload = aUpdateHandler->showOverwriteWarning( rFileName ); + } + + return bReload; +} + //------------------------------------------------------------------------------ void @@ -1138,9 +1183,6 @@ UpdateCheck::downloadFinished(const rtl::OUString& rLocalFileName) // no more retries m_pThread->terminate(); - rtl::Reference< UpdateCheckConfig > rModel = UpdateCheckConfig::get(m_xContext); - rModel->clearLocalFileName(); - m_aImageName = getImageFromFileName(rLocalFileName); UpdateInfo aUpdateInfo(m_aUpdateInfo); @@ -1148,6 +1190,7 @@ UpdateCheck::downloadFinished(const rtl::OUString& rLocalFileName) setUIState(UPDATESTATE_DOWNLOAD_AVAIL); // Bring-up release note for position 2 .. + rtl::Reference< UpdateCheckConfig > rModel = UpdateCheckConfig::get( m_xContext ); const rtl::OUString aURL(getReleaseNote(aUpdateInfo, 2, rModel->isAutoDownloadEnabled())); if( aURL.getLength() > 0 ) showReleaseNote(aURL); diff --git a/extensions/source/update/check/updatecheck.hxx b/extensions/source/update/check/updatecheck.hxx index c3a088897860..ff16fc3ed95b 100644 --- a/extensions/source/update/check/updatecheck.hxx +++ b/extensions/source/update/check/updatecheck.hxx @@ -114,6 +114,8 @@ public: virtual void downloadProgressAt(sal_Int8 nProcent); virtual void downloadStarted(const rtl::OUString& rLocalFileName, sal_Int64 nFileSize); virtual void downloadFinished(const rtl::OUString& rLocalFileName); + // checks if the download target already exists and asks user what to do next + virtual bool checkDownloadDestination( const rtl::OUString& rFile ); // Cancels the download action (and resumes checking if enabled) void cancelDownload(); diff --git a/extensions/source/update/check/updatehdl.cxx b/extensions/source/update/check/updatehdl.cxx index 19ca5588c09c..e94b91c4126d 100644 --- a/extensions/source/update/check/updatehdl.cxx +++ b/extensions/source/update/check/updatehdl.cxx @@ -54,6 +54,7 @@ #include "com/sun/star/awt/XThrobber.hpp" #include "com/sun/star/awt/XTopWindow.hpp" #include "com/sun/star/awt/XVclWindowPeer.hpp" +#include "com/sun/star/awt/XVclContainer.hpp" #include "com/sun/star/awt/XWindow.hpp" #include "com/sun/star/awt/XWindow2.hpp" @@ -230,6 +231,11 @@ void UpdateHandler::setVisible( bool bVisible ) //-------------------------------------------------------------------- void UpdateHandler::setProgress( sal_Int32 nPercent ) { + if ( nPercent > 100 ) + nPercent = 100; + else if ( nPercent < 0 ) + nPercent = 0; + if ( nPercent != mnPercent ) { osl::MutexGuard aGuard( maMutex ); @@ -705,6 +711,9 @@ void UpdateHandler::loadStrings() msInstallError = loadString( xBundle, RID_UPDATE_STR_INSTALL_ERROR ); msOverwriteWarning = loadString( xBundle, RID_UPDATE_STR_OVERWRITE_WARNING ); msPercent = loadString( xBundle, RID_UPDATE_STR_PERCENT ); + msReloadWarning = loadString( xBundle, RID_UPDATE_STR_RELOAD_WARNING ); + msReloadReload = loadString( xBundle, RID_UPDATE_STR_RELOAD_RELOAD ); + msReloadContinue = loadString( xBundle, RID_UPDATE_STR_RELOAD_CONTINUE ); msStatusFL = loadString( xBundle, RID_UPDATE_FT_STATUS ); msDescription = loadString( xBundle, RID_UPDATE_FT_DESCRIPTION ); @@ -956,6 +965,83 @@ bool UpdateHandler::showWarning( const rtl::OUString &rWarningText ) const return bRet; } +//-------------------------------------------------------------------- +bool UpdateHandler::showWarning( const rtl::OUString &rWarningText, + const rtl::OUString &rBtnText_1, + const rtl::OUString &rBtnText_2 ) const +{ + bool bRet = false; + + uno::Reference< awt::XControl > xControl( mxUpdDlg, uno::UNO_QUERY ); + if ( !xControl.is() ) return bRet; + + uno::Reference< awt::XWindowPeer > xPeer = xControl->getPeer(); + if ( !xPeer.is() ) return bRet; + + uno::Reference< awt::XToolkit > xToolkit = xPeer->getToolkit(); + if ( !xToolkit.is() ) return bRet; + + awt::WindowDescriptor aDescriptor; + + sal_Int32 nWindowAttributes = awt::WindowAttribute::BORDER | awt::WindowAttribute::MOVEABLE | awt::WindowAttribute::CLOSEABLE; + nWindowAttributes |= awt::VclWindowPeerAttribute::YES_NO; + nWindowAttributes |= awt::VclWindowPeerAttribute::DEF_NO; + + aDescriptor.Type = awt::WindowClass_MODALTOP; + aDescriptor.WindowServiceName = UNISTRING( "warningbox" ); + aDescriptor.ParentIndex = -1; + aDescriptor.Parent = xPeer; + aDescriptor.Bounds = awt::Rectangle( 10, 10, 250, 150 ); + aDescriptor.WindowAttributes = nWindowAttributes; + + uno::Reference< awt::XMessageBox > xMsgBox( xToolkit->createWindow( aDescriptor ), uno::UNO_QUERY ); + if ( xMsgBox.is() ) + { + uno::Reference< awt::XVclContainer > xMsgBoxCtrls( xMsgBox, uno::UNO_QUERY ); + if ( xMsgBoxCtrls.is() ) + { + uno::Sequence< uno::Reference< awt::XWindow > > xChildren = xMsgBoxCtrls->getWindows(); + + for ( long i=0; i < xChildren.getLength(); i++ ) + { + uno::Reference< awt::XVclWindowPeer > xMsgBoxCtrl( xChildren[i], uno::UNO_QUERY ); + if ( xMsgBoxCtrl.is() ) + { + bool bIsDefault; + uno::Any aValue = xMsgBoxCtrl->getProperty( UNISTRING("DefaultButton") ); + aValue >>= bIsDefault; + if ( bIsDefault ) + xMsgBoxCtrl->setProperty( UNISTRING("Text"), uno::Any( rBtnText_1 ) ); + else + xMsgBoxCtrl->setProperty( UNISTRING("Text"), uno::Any( rBtnText_2 ) ); + } + } + } + + sal_Int16 nRet; + // xMsgBox->setCaptionText( msCancelTitle ); + xMsgBox->setMessageText( rWarningText ); + nRet = xMsgBox->execute(); + if ( nRet == 2 ) // RET_YES == 2 + bRet = true; + } + + uno::Reference< lang::XComponent > xComponent( xMsgBox, uno::UNO_QUERY ); + if ( xComponent.is() ) + xComponent->dispose(); + + return bRet; +} + +//-------------------------------------------------------------------- +bool UpdateHandler::showOverwriteWarning( const rtl::OUString& rFileName ) const +{ + rtl::OUString aMsg( msReloadWarning ); + searchAndReplaceAll( aMsg, UNISTRING( "%FILENAME" ), rFileName ); + searchAndReplaceAll( aMsg, UNISTRING( "%DOWNLOAD_PATH" ), msDownloadPath ); + return showWarning( aMsg, msReloadContinue, msReloadReload ); +} + //-------------------------------------------------------------------- bool UpdateHandler::showOverwriteWarning() const { diff --git a/extensions/source/update/check/updatehdl.hrc b/extensions/source/update/check/updatehdl.hrc index 906a2e2a5db7..567269f97e52 100644 --- a/extensions/source/update/check/updatehdl.hrc +++ b/extensions/source/update/check/updatehdl.hrc @@ -50,6 +50,9 @@ #define RID_UPDATE_STR_PERCENT RID_UPDATE_HDL_START + 18 #define RID_UPDATE_STR_DOWNLOAD_DESCR RID_UPDATE_HDL_START + 19 #define RID_UPDATE_STR_INSTALL_ERROR RID_UPDATE_HDL_START + 20 + #define RID_UPDATE_STR_RELOAD_WARNING RID_UPDATE_HDL_START + 21 + #define RID_UPDATE_STR_RELOAD_RELOAD RID_UPDATE_HDL_START + 22 + #define RID_UPDATE_STR_RELOAD_CONTINUE RID_UPDATE_HDL_START + 23 #define RID_UPDATE_FT_DESCRIPTION RID_UPDATE_HDL_START + 25 #define RID_UPDATE_FT_STATUS RID_UPDATE_HDL_START + 26 diff --git a/extensions/source/update/check/updatehdl.hxx b/extensions/source/update/check/updatehdl.hxx index 9b33098f30f1..f54eca5008b8 100644 --- a/extensions/source/update/check/updatehdl.hxx +++ b/extensions/source/update/check/updatehdl.hxx @@ -128,6 +128,9 @@ private: rtl::OUString msInstallError; // RID_UPDATE_STR_INSTALL_ERROR rtl::OUString msOverwriteWarning; // RID_UPDATE_STR_OVERWRITE_WARNING rtl::OUString msPercent; // RID_UPDATE_STR_PERCENT + rtl::OUString msReloadWarning; // RID_UPDATE_STR_OVERWRITE_WARNING + rtl::OUString msReloadReload; // RID_UPDATE_STR_OVERWRITE_WARNING + rtl::OUString msReloadContinue; // RID_UPDATE_STR_OVERWRITE_WARNING rtl::OUString msStatusFL; // RID_UPDATE_FT_STATUS rtl::OUString msDescription; // RID_UPDATE_FT_DESCRIPTION rtl::OUString msClose; // RID_UPDATE_BTN_CLOSE @@ -187,6 +190,8 @@ public: rtl::OUString getBubbleTitle( UpdateState eState ); rtl::OUString getDefaultInstErrMsg(); bool showWarning( const rtl::OUString &rWarning ) const; + bool showWarning( const rtl::OUString &rWarning, const rtl::OUString& rBtnText_1, const rtl::OUString& rBtnText_2 ) const; + bool showOverwriteWarning( const rtl::OUString &rFileName ) const; bool showOverwriteWarning() const; // Allows runtime exceptions to be thrown by const methods diff --git a/extensions/source/update/check/updatehdl.src b/extensions/source/update/check/updatehdl.src index 7e846d3d9185..99e4a6dcbf59 100644 --- a/extensions/source/update/check/updatehdl.src +++ b/extensions/source/update/check/updatehdl.src @@ -125,6 +125,21 @@ String RID_UPDATE_STR_OVERWRITE_WARNING Text [ en-US ] = "A file with that name already exists! Do you want to overwrite the existing file?"; }; +String RID_UPDATE_STR_RELOAD_WARNING +{ + Text [ en-US ] = "A file with the name '%FILENAME' already exists in '%DOWNLOAD_PATH'! Do you want to continue with the download or delete and reload the file?"; +}; + +String RID_UPDATE_STR_RELOAD_RELOAD +{ + Text [ en-US ] = "Reload File"; +}; + +String RID_UPDATE_STR_RELOAD_CONTINUE +{ + Text [ en-US ] = "Continue"; +}; + String RID_UPDATE_STR_PERCENT { Text [ en-US ] = "%PERCENT%"; -- cgit From 02e47dac20beb7d9d9d96942a77087c4215a944f Mon Sep 17 00:00:00 2001 From: Dirk Völzke Date: Tue, 25 Aug 2009 10:52:54 +0000 Subject: #i88957# Improved handling of already downloaded updates --- extensions/source/update/check/updatehdl.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'extensions') diff --git a/extensions/source/update/check/updatehdl.cxx b/extensions/source/update/check/updatehdl.cxx index e94b91c4126d..01a404465e12 100644 --- a/extensions/source/update/check/updatehdl.cxx +++ b/extensions/source/update/check/updatehdl.cxx @@ -1007,7 +1007,7 @@ bool UpdateHandler::showWarning( const rtl::OUString &rWarningText, uno::Reference< awt::XVclWindowPeer > xMsgBoxCtrl( xChildren[i], uno::UNO_QUERY ); if ( xMsgBoxCtrl.is() ) { - bool bIsDefault; + bool bIsDefault = true; uno::Any aValue = xMsgBoxCtrl->getProperty( UNISTRING("DefaultButton") ); aValue >>= bIsDefault; if ( bIsDefault ) -- cgit From 4496e7dc73caf6070ccf7d4a170cbdbbefa0d817 Mon Sep 17 00:00:00 2001 From: Dirk Völzke Date: Mon, 21 Sep 2009 11:58:50 +0000 Subject: #i105165# Don't allow quitting the application while modal dialog is shown --- extensions/source/update/check/updatehdl.cxx | 21 +++++++++++++++++++-- extensions/source/update/check/updatehdl.hxx | 1 + 2 files changed, 20 insertions(+), 2 deletions(-) (limited to 'extensions') diff --git a/extensions/source/update/check/updatehdl.cxx b/extensions/source/update/check/updatehdl.cxx index 01a404465e12..ca9da74d3525 100644 --- a/extensions/source/update/check/updatehdl.cxx +++ b/extensions/source/update/check/updatehdl.cxx @@ -104,7 +104,8 @@ UpdateHandler::UpdateHandler( const uno::Reference< uno::XComponentContext > & r mbVisible( false ), mbStringsLoaded( false ), mbMinimized( false ), - mbListenerAdded(false) + mbListenerAdded(false), + mbShowsMessageBox(false) { } @@ -482,7 +483,18 @@ void SAL_CALL UpdateHandler::handle( uno::Reference< task::XInteractionRequest > void SAL_CALL UpdateHandler::queryTermination( const lang::EventObject& ) throw ( frame::TerminationVetoException, uno::RuntimeException ) { - setVisible( false ); + if ( mbShowsMessageBox ) + { + uno::Reference< awt::XTopWindow > xTopWindow( mxUpdDlg, uno::UNO_QUERY ); + if ( xTopWindow.is() ) + xTopWindow->toFront(); + + throw frame::TerminationVetoException( + UNISTRING("The office cannot be closed while displaying a warning!"), + uno::Reference(static_cast(this), uno::UNO_QUERY)); + } + else + setVisible( false ); } //------------------------------------------------------------------------------ @@ -950,12 +962,14 @@ bool UpdateHandler::showWarning( const rtl::OUString &rWarningText ) const uno::Reference< awt::XMessageBox > xMsgBox( xToolkit->createWindow( aDescriptor ), uno::UNO_QUERY ); if ( xMsgBox.is() ) { + mbShowsMessageBox = true; sal_Int16 nRet; // xMsgBox->setCaptionText( msCancelTitle ); xMsgBox->setMessageText( rWarningText ); nRet = xMsgBox->execute(); if ( nRet == 2 ) // RET_YES == 2 bRet = true; + mbShowsMessageBox = false; } uno::Reference< lang::XComponent > xComponent( xMsgBox, uno::UNO_QUERY ); @@ -1020,10 +1034,13 @@ bool UpdateHandler::showWarning( const rtl::OUString &rWarningText, sal_Int16 nRet; // xMsgBox->setCaptionText( msCancelTitle ); + mbShowsMessageBox = true; xMsgBox->setMessageText( rWarningText ); nRet = xMsgBox->execute(); if ( nRet == 2 ) // RET_YES == 2 bRet = true; + + mbShowsMessageBox = false; } uno::Reference< lang::XComponent > xComponent( xMsgBox, uno::UNO_QUERY ); diff --git a/extensions/source/update/check/updatehdl.hxx b/extensions/source/update/check/updatehdl.hxx index f54eca5008b8..5a980228b9e2 100644 --- a/extensions/source/update/check/updatehdl.hxx +++ b/extensions/source/update/check/updatehdl.hxx @@ -101,6 +101,7 @@ private: bool mbStringsLoaded; bool mbMinimized; bool mbListenerAdded; + mutable bool mbShowsMessageBox; osl::Mutex maMutex; -- cgit From 9a57c3de06263eeaa28a4644d53248bdfca6df0f Mon Sep 17 00:00:00 2001 From: Dirk Völzke Date: Fri, 25 Sep 2009 11:13:49 +0000 Subject: #i88957# Handle some http errors --- extensions/source/update/check/download.cxx | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'extensions') diff --git a/extensions/source/update/check/download.cxx b/extensions/source/update/check/download.cxx index 8c64c037da7e..1d50ddad7305 100644 --- a/extensions/source/update/check/download.cxx +++ b/extensions/source/update/check/download.cxx @@ -267,6 +267,9 @@ bool curl_run(const rtl::OUString& rURL, OutData& out, const rtl::OString& aProx rtl::OString aURL(rtl::OUStringToOString(rURL, RTL_TEXTENCODING_UTF8)); curl_easy_setopt(pCURL, CURLOPT_URL, aURL.getStr()); + // abort on http errors + curl_easy_setopt(pCURL, CURLOPT_FAILONERROR, 1); + // enable redirection curl_easy_setopt(pCURL, CURLOPT_FOLLOWLOCATION, 1); @@ -318,7 +321,30 @@ bool curl_run(const rtl::OUString& rURL, OutData& out, const rtl::OString& aProx if( NULL != error_message ) aMessage = error_message; - out.Handler->downloadStalled( rtl::OStringToOUString(aMessage, RTL_TEXTENCODING_UTF8) ); + if ( CURLE_HTTP_RETURNED_ERROR == cc ) + { + long nError; + curl_easy_getinfo( pCURL, CURLINFO_RESPONSE_CODE, &nError ); + + if ( 403 == nError ) + aMessage += RTL_CONSTASCII_STRINGPARAM( " 403: Access denied!" ); + else if ( 404 == nError ) + aMessage += RTL_CONSTASCII_STRINGPARAM( " 404: File not found!" ); + else if ( 416 == nError ) + { + // we got this error probably, because we already downloaded the file + out.Handler->downloadFinished(out.File); + ret = true; + } + else + { + aMessage += RTL_CONSTASCII_STRINGPARAM( ":error code = " ); + aMessage += aMessage.valueOf( nError ); + aMessage += RTL_CONSTASCII_STRINGPARAM( " !" ); + } + } + if ( !ret ) + out.Handler->downloadStalled( rtl::OStringToOUString(aMessage, RTL_TEXTENCODING_UTF8) ); } curl_easy_cleanup(pCURL); -- cgit From ea69598127b41c0b87f1fc3359f7fa3887e91d54 Mon Sep 17 00:00:00 2001 From: Dirk Völzke Date: Fri, 25 Sep 2009 11:52:58 +0000 Subject: #i88957# Use UNISTRING macro --- extensions/source/update/check/download.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'extensions') diff --git a/extensions/source/update/check/download.cxx b/extensions/source/update/check/download.cxx index 1d50ddad7305..2936d6078d93 100644 --- a/extensions/source/update/check/download.cxx +++ b/extensions/source/update/check/download.cxx @@ -327,9 +327,9 @@ bool curl_run(const rtl::OUString& rURL, OutData& out, const rtl::OString& aProx curl_easy_getinfo( pCURL, CURLINFO_RESPONSE_CODE, &nError ); if ( 403 == nError ) - aMessage += RTL_CONSTASCII_STRINGPARAM( " 403: Access denied!" ); + aMessage += UNISTRING( " 403: Access denied!" ); else if ( 404 == nError ) - aMessage += RTL_CONSTASCII_STRINGPARAM( " 404: File not found!" ); + aMessage += UNISTRING( " 404: File not found!" ); else if ( 416 == nError ) { // we got this error probably, because we already downloaded the file @@ -338,9 +338,9 @@ bool curl_run(const rtl::OUString& rURL, OutData& out, const rtl::OString& aProx } else { - aMessage += RTL_CONSTASCII_STRINGPARAM( ":error code = " ); + aMessage += UNISTRING( ":error code = " ); aMessage += aMessage.valueOf( nError ); - aMessage += RTL_CONSTASCII_STRINGPARAM( " !" ); + aMessage += UNISTRING( " !" ); } } if ( !ret ) -- cgit From 7d22694d5186484a470947c395cb19a7b7ed079b Mon Sep 17 00:00:00 2001 From: Dirk Völzke Date: Fri, 25 Sep 2009 11:56:17 +0000 Subject: #i88957# second try to remove warnings --- extensions/source/update/check/download.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'extensions') diff --git a/extensions/source/update/check/download.cxx b/extensions/source/update/check/download.cxx index 2936d6078d93..76d4b373a329 100644 --- a/extensions/source/update/check/download.cxx +++ b/extensions/source/update/check/download.cxx @@ -327,9 +327,9 @@ bool curl_run(const rtl::OUString& rURL, OutData& out, const rtl::OString& aProx curl_easy_getinfo( pCURL, CURLINFO_RESPONSE_CODE, &nError ); if ( 403 == nError ) - aMessage += UNISTRING( " 403: Access denied!" ); + aMessage += rtl::OString( RTL_CONSTASCII_STRINGPARAM( " 403: Access denied!" ) ); else if ( 404 == nError ) - aMessage += UNISTRING( " 404: File not found!" ); + aMessage += rtl::OString( RTL_CONSTASCII_STRINGPARAM( " 404: File not found!" ) ); else if ( 416 == nError ) { // we got this error probably, because we already downloaded the file @@ -338,9 +338,9 @@ bool curl_run(const rtl::OUString& rURL, OutData& out, const rtl::OString& aProx } else { - aMessage += UNISTRING( ":error code = " ); + aMessage += rtl::OString( RTL_CONSTASCII_STRINGPARAM( ":error code = " ) ); aMessage += aMessage.valueOf( nError ); - aMessage += UNISTRING( " !" ); + aMessage += rtl::OString( RTL_CONSTASCII_STRINGPARAM( " !" ) ); } } if ( !ret ) -- cgit From 465099eb825f40ec15af1499444263cbb3d7df19 Mon Sep 17 00:00:00 2001 From: Dirk Voelzke Date: Thu, 6 May 2010 11:15:51 +0200 Subject: dv12#i88957# improved handling of downloading new versions --- extensions/source/update/check/download.cxx | 15 ++++++++++++++- extensions/source/update/check/updatecheck.cxx | 19 +++++++++++-------- extensions/source/update/check/updatecheckconfig.cxx | 2 +- 3 files changed, 26 insertions(+), 10 deletions(-) mode change 100644 => 100755 extensions/source/update/check/download.cxx mode change 100644 => 100755 extensions/source/update/check/updatecheck.cxx mode change 100644 => 100755 extensions/source/update/check/updatecheckconfig.cxx (limited to 'extensions') diff --git a/extensions/source/update/check/download.cxx b/extensions/source/update/check/download.cxx old mode 100644 new mode 100755 index 9e10abf27a0e..09d90f1eaa83 --- a/extensions/source/update/check/download.cxx +++ b/extensions/source/update/check/download.cxx @@ -305,6 +305,19 @@ bool curl_run(const rtl::OUString& rURL, OutData& out, const rtl::OString& aProx ret = true; } + if ( CURLE_PARTIAL_FILE == cc ) + { + // this sometimes happens, when a user throws away his user data, but has already + // completed the download of an update. + double fDownloadSize; + curl_easy_getinfo( pCURL, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &fDownloadSize ); + if ( -1 == fDownloadSize ) + { + out.Handler->downloadFinished(out.File); + ret = true; + } + } + // Avoid target file being removed else if( (CURLE_ABORTED_BY_CALLBACK == cc) || out.StopCondition.check() ) ret = true; @@ -388,7 +401,7 @@ Download::start(const rtl::OUString& rURL, const rtl::OUString& rFile, const rtl aFile = rtl::OUString(); } else - m_aHandler->downloadStarted( aFile, 1 ); + m_aHandler->downloadStarted( aFile, 0 ); } else { diff --git a/extensions/source/update/check/updatecheck.cxx b/extensions/source/update/check/updatecheck.cxx old mode 100644 new mode 100755 index d89233e88dc2..d65a97e49dc6 --- a/extensions/source/update/check/updatecheck.cxx +++ b/extensions/source/update/check/updatecheck.cxx @@ -824,7 +824,7 @@ UpdateCheck::initialize(const uno::Sequence< beans::NamedValue >& rValues, if( nDownloadSize > 0 ) { - if ( nDownloadSize == nFileSize ) // we have already downloaded everthing + if ( nDownloadSize <= nFileSize ) // we have already downloaded everthing { bContinueDownload = false; bDownloadAvailable = true; @@ -1177,15 +1177,18 @@ UpdateCheck::downloadProgressAt(sal_Int8 nPercent) void UpdateCheck::downloadStarted(const rtl::OUString& rLocalFileName, sal_Int64 nFileSize) { - osl::MutexGuard aGuard(m_aMutex); + if ( nFileSize > 0 ) + { + osl::MutexGuard aGuard(m_aMutex); - rtl::Reference< UpdateCheckConfig > aModel(UpdateCheckConfig::get(m_xContext)); - aModel->storeLocalFileName(rLocalFileName, nFileSize); + rtl::Reference< UpdateCheckConfig > aModel(UpdateCheckConfig::get(m_xContext)); + aModel->storeLocalFileName(rLocalFileName, nFileSize); - // Bring-up release note for position 1 .. - const rtl::OUString aURL(getReleaseNote(m_aUpdateInfo, 1, aModel->isAutoDownloadEnabled())); - if( aURL.getLength() > 0 ) - showReleaseNote(aURL); + // Bring-up release note for position 1 .. + const rtl::OUString aURL(getReleaseNote(m_aUpdateInfo, 1, aModel->isAutoDownloadEnabled())); + if( aURL.getLength() > 0 ) + showReleaseNote(aURL); + } } //------------------------------------------------------------------------------ diff --git a/extensions/source/update/check/updatecheckconfig.cxx b/extensions/source/update/check/updatecheckconfig.cxx old mode 100644 new mode 100755 index b3e559c5f136..9f78b33270c2 --- a/extensions/source/update/check/updatecheckconfig.cxx +++ b/extensions/source/update/check/updatecheckconfig.cxx @@ -398,7 +398,7 @@ UpdateCheckConfig::storeLocalFileName(const rtl::OUString& rLocalFileName, sal_I if( m_xContainer->hasByName(aNameList[i]) ) m_xContainer->replaceByName(aNameList[i], aValueList[i]); else - m_xContainer->insertByName(aNameList[i],aValueList[i]); + m_xContainer->insertByName(aNameList[i], aValueList[i]); } commitChanges(); -- cgit