LibreOffice Module extensions (master) 1
updatecheck.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#pragma once
21
22#include <sal/config.h>
23
24#include <condition_variable>
25#include <mutex>
26
27#include <com/sun/star/beans/NamedValue.hpp>
28#include <com/sun/star/beans/XPropertySet.hpp>
29#include <com/sun/star/task/XInteractionHandler.hpp>
30#include <com/sun/star/uno/XComponentContext.hpp>
31
32#include <osl/conditn.hxx>
33#include <osl/thread.hxx>
34#include <rtl/instance.hxx>
35
36#include "updateinfo.hxx"
38#include "actionlistener.hxx"
39#include "updatehdl.hxx"
40#include "download.hxx"
41
42
43class UpdateCheck;
44
46
47public:
49};
50
51class WorkerThread : public osl::Thread
52{
53public:
54 virtual void cancel() = 0;
55};
56
59 public IActionListener,
61 public rtl::StaticWithInit< rtl::Reference< UpdateCheck >, UpdateCheckInitData >
62{
64
65 virtual ~UpdateCheck() override;
66
67public:
69 { return static_cast< UpdateCheckConfigListener * > (this); }
70
71 void initialize(const css::uno::Sequence<css::beans::NamedValue>& rValues,
72 const css::uno::Reference<css::uno::XComponentContext>& xContext);
73
74 // Update internal update info member
75 void setUpdateInfo(const UpdateInfo& aInfo);
76
77 /* This method turns on the menubar icon, triggers the bubble window or
78 * updates the dialog text when appropriate
79 */
80 void setUIState(UpdateState eState, bool suppressBubble = false);
81
82 // Returns the UI state that matches rInfo best
83 static UpdateState getUIState(const UpdateInfo& rInfo);
84
85 // Check for updates failed
87
88 // Executes the update check dialog for manual checks and downloads interaction
89 void showDialog(bool forceCheck = false);
90
91 // Returns true if the update dialog is currently showing
92 bool isDialogShowing() const;
95 void setHasExtensionUpdates( bool bHasUpdates ) { m_bHasExtensionUpdate = bHasUpdates; }
96 bool hasOfficeUpdate() const { return (m_aUpdateInfo.BuildId.getLength() > 0); }
97
98 // DownloadInteractionHandler
99 virtual bool downloadTargetExists(const OUString& rFileName) override;
100 virtual void downloadStalled(const OUString& rErrorMessage) override;
101 virtual void downloadProgressAt(sal_Int8 nProcent) override;
102 virtual void downloadStarted(const OUString& rLocalFileName, sal_Int64 nFileSize) override;
103 virtual void downloadFinished(const OUString& rLocalFileName) override;
104 // checks if the download target already exists and asks user what to do next
105 virtual bool checkDownloadDestination( const OUString& rFile ) override;
106
107 // Cancels the download action (and resumes checking if enabled)
108 void cancelDownload();
109
110 // Returns the XInteractionHandler of the UpdateHandler instance if present (and visible)
111 css::uno::Reference< css::task::XInteractionHandler > getInteractionHandler() const;
112
113 // UpdateCheckConfigListener
114 virtual void autoCheckStatusChanged(bool enabled) override;
115 virtual void autoCheckIntervalChanged() override;
116
117 // IActionListener
118 void cancel() override;
119 void download() override;
120 void pause() override;
121 void resume() override;
122 void closeAfterFailure() override;
123
125
127
128private:
129
130 // Schedules or cancels next automatic check for updates
131 void enableAutoCheck(bool enable);
132
133 // Starts/resumes or stops a download
134 void enableDownload(bool enable, bool paused=false);
135
136 // Shuts down the currently running thread
137 void shutdownThread(bool join);
138
139 // Returns the update handler instance
141
142 // Open the given URL in a browser
143 void showReleaseNote(const OUString& rURL) const;
144
145 // stores the release note url on disk to be used by setup app
146 static bool storeReleaseNote(sal_Int8 nNum, const OUString &rURL);
147
148 /* This method turns on the menubar icon and triggers the bubble window
149 */
150 void handleMenuBarUI( const rtl::Reference< UpdateHandler >& rUpdateHandler,
151 UpdateState& eState, bool suppressBubble );
152 enum State {
158 };
159
162
163 mutable std::recursive_mutex m_aMutex;
165 osl::Condition m_aCondition;
166
168 OUString m_aImageName;
171
173 css::uno::Reference<css::beans::XPropertySet> m_xMenuBarUI;
174 css::uno::Reference<css::uno::XComponentContext> m_xContext;
175
177 std::condition_variable_any m_updateCheckFinished;
178
180};
181
184{
186}
187
188/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
rtl::Reference< UpdateCheck > operator()() const
void enableDownload(bool enable, bool paused=false)
rtl::Reference< UpdateHandler > getUpdateHandler()
void showDialog(bool forceCheck=false)
WorkerThread * m_pThread
css::uno::Reference< css::beans::XPropertySet > m_xMenuBarUI
void enableAutoCheck(bool enable)
void download() override
virtual ~UpdateCheck() override
virtual bool downloadTargetExists(const OUString &rFileName) override
bool shouldShowExtUpdDlg() const
Definition: updatecheck.hxx:93
bool m_bHasExtensionUpdate
virtual void downloadFinished(const OUString &rLocalFileName) override
virtual void downloadStarted(const OUString &rLocalFileName, sal_Int64 nFileSize) override
css::uno::Reference< css::task::XInteractionHandler > getInteractionHandler() const
void showReleaseNote(const OUString &rURL) const
bool isDialogShowing() const
OUString m_aImageName
void waitForUpdateCheckFinished()
bool hasOfficeUpdate() const
Definition: updatecheck.hxx:96
UpdateInfo m_aUpdateInfo
void notifyUpdateCheckFinished()
void initialize(const css::uno::Sequence< css::beans::NamedValue > &rValues, const css::uno::Reference< css::uno::XComponentContext > &xContext)
void cancel() override
std::recursive_mutex m_aMutex
void handleMenuBarUI(const rtl::Reference< UpdateHandler > &rUpdateHandler, UpdateState &eState, bool suppressBubble)
void cancelDownload()
void setCheckFailedState()
static UpdateState getUIState(const UpdateInfo &rInfo)
virtual void downloadProgressAt(sal_Int8 nProcent) override
osl::Condition m_aCondition
virtual bool checkDownloadDestination(const OUString &rFile) override
std::condition_variable_any m_updateCheckFinished
void setUpdateInfo(const UpdateInfo &aInfo)
static bool storeReleaseNote(sal_Int8 nNum, const OUString &rURL)
void closeAfterFailure() override
rtl::Reference< UpdateHandler > m_aUpdateHandler
void setHasExtensionUpdates(bool bHasUpdates)
Definition: updatecheck.hxx:95
css::uno::Reference< css::uno::XComponentContext > m_xContext
UpdateState m_eUpdateState
virtual void autoCheckIntervalChanged() override
void shutdownThread(bool join)
virtual void autoCheckStatusChanged(bool enabled) override
void showExtensionDialog()
bool m_updateCheckRunning
void setUIState(UpdateState eState, bool suppressBubble=false)
void pause() override
bool m_bShowExtUpdDlg
void resume() override
virtual void downloadStalled(const OUString &rErrorMessage) override
virtual void cancel()=0
OUString BuildId
Definition: updateinfo.hxx:51
signed char sal_Int8
UpdateState
Definition: updatehdl.hxx:57