bump product version to 6.3.0.0.beta1
[LibreOffice.git] / extensions / source / update / check / updatecheck.hxx
blobe50fa3859b0cf18621bbe1b1dbbdedebac62510d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_EXTENSIONS_SOURCE_UPDATE_CHECK_UPDATECHECK_HXX
21 #define INCLUDED_EXTENSIONS_SOURCE_UPDATE_CHECK_UPDATECHECK_HXX
23 #include <com/sun/star/beans/NamedValue.hpp>
24 #include <com/sun/star/beans/XPropertySet.hpp>
25 #include <com/sun/star/task/XInteractionHandler.hpp>
26 #include <com/sun/star/uno/XComponentContext.hpp>
28 #include <osl/conditn.hxx>
29 #include <osl/thread.hxx>
30 #include <rtl/instance.hxx>
32 #include "updateinfo.hxx"
33 #include "updatecheckconfiglistener.hxx"
34 #include "actionlistener.hxx"
35 #include "updatehdl.hxx"
36 #include "download.hxx"
39 class UpdateCheck;
41 class UpdateCheckInitData {
43 public:
44 inline rtl::Reference< UpdateCheck > operator() () const;
47 class WorkerThread : public osl::Thread
49 public:
50 virtual void cancel() = 0;
53 class UpdateCheck :
54 public UpdateCheckConfigListener,
55 public IActionListener,
56 public DownloadInteractionHandler,
57 public rtl::StaticWithInit< rtl::Reference< UpdateCheck >, UpdateCheckInitData >
59 UpdateCheck();
61 virtual ~UpdateCheck() override;
63 public:
64 operator rtl::Reference< UpdateCheckConfigListener > ()
65 { return static_cast< UpdateCheckConfigListener * > (this); }
67 void initialize(const css::uno::Sequence<css::beans::NamedValue>& rValues,
68 const css::uno::Reference<css::uno::XComponentContext>& xContext);
70 // Update internal update info member
71 void setUpdateInfo(const UpdateInfo& aInfo);
73 /* This method turns on the menubar icon, triggers the bubble window or
74 * updates the dialog text when appropriate
76 void setUIState(UpdateState eState, bool suppressBubble = false);
78 // Returns the UI state that matches rInfo best
79 static UpdateState getUIState(const UpdateInfo& rInfo);
81 // Check for updates failed
82 void setCheckFailedState();
84 // Executes the update check dialog for manual checks and downloads interaction
85 void showDialog(bool forceCheck = false);
87 // Returns true if the update dialog is currently showing
88 bool isDialogShowing() const;
89 bool shouldShowExtUpdDlg() const { return ( m_bShowExtUpdDlg && m_bHasExtensionUpdate ); }
90 void showExtensionDialog();
91 void setHasExtensionUpdates( bool bHasUpdates ) { m_bHasExtensionUpdate = bHasUpdates; }
92 bool hasOfficeUpdate() const { return (m_aUpdateInfo.BuildId.getLength() > 0); }
94 // DownloadInteractionHandler
95 virtual bool downloadTargetExists(const OUString& rFileName) override;
96 virtual void downloadStalled(const OUString& rErrorMessage) override;
97 virtual void downloadProgressAt(sal_Int8 nProcent) override;
98 virtual void downloadStarted(const OUString& rLocalFileName, sal_Int64 nFileSize) override;
99 virtual void downloadFinished(const OUString& rLocalFileName) override;
100 // checks if the download target already exists and asks user what to do next
101 virtual bool checkDownloadDestination( const OUString& rFile ) override;
103 // Cancels the download action (and resumes checking if enabled)
104 void cancelDownload();
106 // Returns the XInteractionHandler of the UpdateHandler instance if present (and visible)
107 css::uno::Reference< css::task::XInteractionHandler > getInteractionHandler() const;
109 // UpdateCheckConfigListener
110 virtual void autoCheckStatusChanged(bool enabled) override;
111 virtual void autoCheckIntervalChanged() override;
113 // IActionListener
114 void cancel() override;
115 void download() override;
116 void install() override;
117 void pause() override;
118 void resume() override;
119 void closeAfterFailure() override;
121 private:
123 // Schedules or cancels next automatic check for updates
124 void enableAutoCheck(bool enable);
126 // Starts/resumes or stops a download
127 void enableDownload(bool enable, bool paused=false);
129 // Shuts down the currently running thread
130 void shutdownThread(bool join);
132 // Returns the update handler instance
133 rtl::Reference<UpdateHandler> getUpdateHandler();
135 // Open the given URL in a browser
136 void showReleaseNote(const OUString& rURL) const;
138 // stores the release note url on disk to be used by setup app
139 static bool storeReleaseNote(sal_Int8 nNum, const OUString &rURL);
141 /* This method turns on the menubar icon and triggers the bubble window
143 void handleMenuBarUI( const rtl::Reference< UpdateHandler >& rUpdateHandler,
144 UpdateState& eState, bool suppressBubble );
145 enum State {
146 NOT_INITIALIZED,
147 DISABLED,
148 CHECK_SCHEDULED,
149 DOWNLOADING,
150 DOWNLOAD_PAUSED
153 State m_eState;
154 UpdateState m_eUpdateState;
156 mutable osl::Mutex m_aMutex;
157 WorkerThread *m_pThread;
158 osl::Condition m_aCondition;
160 UpdateInfo m_aUpdateInfo;
161 OUString m_aImageName;
162 bool m_bHasExtensionUpdate;
163 bool m_bShowExtUpdDlg;
165 rtl::Reference<UpdateHandler> m_aUpdateHandler;
166 css::uno::Reference<css::beans::XPropertySet> m_xMenuBarUI;
167 css::uno::Reference<css::uno::XComponentContext> m_xContext;
169 friend class UpdateCheckInitData;
172 inline rtl::Reference< UpdateCheck >
173 UpdateCheckInitData::operator() () const
175 return rtl::Reference< UpdateCheck > (new UpdateCheck());
178 #endif // INCLUDED_EXTENSIONS_SOURCE_UPDATE_CHECK_UPDATECHECK_HXX
180 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */