API Documentation
Loading...
Searching...
No Matches
UpdateChecker.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Widgets
28File: UpdateChecker
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include <NDEVR/SoftwareService.h>
34#include <NDEVR/ItemDownloader.h>
35#include <NDEVR/File.h>
36#include <NDEVR/String.h>
37#include <NDEVR/Time.h>
38#include <NDEVR/TimeSpan.h>
39#include <NDEVR/INIFactory.h>
40#include <QObject>
41namespace NDEVR
42{
43 /**--------------------------------------------------------------------------------------------------
44 \brief Provides logic for checking a source, typically online, for an update to the software
45 **/
46 class NDEVR_WIDGETS_API UpdateChecker : public QObject, public SoftwareService
47 {
48 Q_OBJECT
49 public:
51 {
52 e_need_to_check
53 , e_no_new_updates
54 , e_update_available_to_download
55 , e_update_available_to_install
56 , e_could_not_connect
57 };
59 {
60 e_alpha = 0
61 , e_beta = 1
62 , e_release = 2
63 , e_lts_release = 3
64 };
66 UpdateChecker(String update_version);
67 virtual void requestCheckForUpdate(const String& current_version = "") = 0;
68 virtual bool requstDownloadUpdate();
69 virtual bool requestInstallUpdate(bool wait_for_completion = false);
70 virtual bool updateSupported() const;
71 virtual String updateName() const { return m_update_file_name; };
72 virtual String updateVersion() const { return m_update_version; };
73 virtual String updateURLPage() const = 0;
74 virtual String updateURLDownload() const { return m_update_url; };
75 virtual bool updateRequiresApplicationClose() const;
78 virtual INIFactory getINI();
79 virtual void createUpdateFile(const String& installer_url, File output_location);
80 virtual void processUpdateString(const String& s);
88 void setMaxNoUpdateTime(const TimeSpan& max_no_update_check_time);
89 virtual String defaultURLPathName() const;
90 signals:
92 void updateDownloadCompletedSignal(const File& location);
95 protected slots:
98 protected:
99 virtual void onCheckForUpdateComplete(){};
100 protected:
109 private:
110 void init();
111 UpdateStatus m_status = UpdateStatus::e_need_to_check;
112 };
113 /**--------------------------------------------------------------------------------------------------
114 \brief Provides place to set an update checker for checking for software updates.
115 **/
117 {
118 public:
122 private:
123 static UpdateChecker* s_app_update_checker;
124 };
125}
126
#define NDEVR_WIDGETS_API
Definition DLLInfo.h:59
Logic for reading or writing to a file as well as navigating filesystems.
Definition File.h:48
Contains methods for easily reading and writing to an INI file including efficient casting,...
Definition INIReader.h:68
Used for Downloading resources from a network.
Definition ItemDownloader.h:120
Software Services provide an interface for adding to or changing the software behavior via functional...
Definition SoftwareService.h:9
Software Service Managers take a Software service to modify the behavior of the software.
Definition SoftwareService.h:15
The core String class for the NDEVR API.
Definition String.h:69
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:54
Stores a time span, or difference between two times, with an optional start time.
Definition TimeSpan.h:46
Provides place to set an update checker for checking for software updates.
Definition UpdateChecker.h:117
static void SetApplicationUpdateChecker(UpdateChecker *checker)
static UpdateChecker * ApplicationUpdateChecker()
Provides logic for checking a source, typically online, for an update to the software.
Definition UpdateChecker.h:47
virtual void onCheckForUpdateComplete()
Definition UpdateChecker.h:99
virtual String updateVersion() const
Definition UpdateChecker.h:72
UpdateStatus
Definition UpdateChecker.h:51
String m_update_file_name
Definition UpdateChecker.h:106
virtual bool requestInstallUpdate(bool wait_for_completion=false)
ItemDownloader * m_downloader
Definition UpdateChecker.h:102
void showUpdateDialogIfNeeded()
Time m_last_application_update_check
Definition UpdateChecker.h:107
virtual String updateURLDownload() const
Definition UpdateChecker.h:74
virtual void requestCheckForUpdate(const String &current_version="")=0
virtual void createUpdateFile(const String &installer_url, File output_location)
File m_download_location
Definition UpdateChecker.h:101
void updateDownloadCompletedSignal(const File &location)
void onUpdateDownloadCompleteSlot()
fltp08 downloadPercent() const
virtual bool updateRequiresApplicationClose() const
ReleaseChannel
Definition UpdateChecker.h:59
void checkForUpdateCompletedSignal(UpdateStatus update)
void setUpdateStatus(UpdateStatus status)
void setMaxNoUpdateTime(const TimeSpan &max_no_update_check_time)
virtual INIFactory getINI()
String m_update_version
Definition UpdateChecker.h:103
virtual String updateName() const
Definition UpdateChecker.h:71
String m_current_version
Definition UpdateChecker.h:105
virtual bool updateSupported() const
TimeSpan m_max_no_update_time
Definition UpdateChecker.h:108
uint08 currentDownloadSize() const
void checkForUpdateCompleteSlot()
String m_update_url
Definition UpdateChecker.h:104
UpdateStatus updateStatus() const
File updateFile() const
Time lastUpdateCheckTime() const
virtual String defaultURLPathName() const
virtual void processUpdateString(const String &s)
UpdateChecker(String update_version)
uint08 totalDownloadSize() const
virtual String updateURLPage() const =0
virtual bool requstDownloadUpdate()
Definition ACIColor.h:37
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer
Definition BaseValues.hpp:106
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:149