BuildmLearn Toolkit  2.0.4
BuildmLearn Toolkit is an easy-to-use program that helps users make mobile apps without any knowledge of application development.
 All Classes Functions Enumerations Groups Pages
formupdate.h
1 /*
2  Copyright (c) 2012, BuildmLearn Contributors listed at http://buildmlearn.org/people/
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without
6  modification, are permitted provided that the following conditions are met:
7 
8  * Redistributions of source code must retain the above copyright notice, this
9  list of conditions and the following disclaimer.
10 
11  * Redistributions in binary form must reproduce the above copyright notice,
12  this list of conditions and the following disclaimer in the documentation
13  and/or other materials provided with the distribution.
14 
15  * Neither the name of the BuildmLearn nor the names of its
16  contributors may be used to endorse or promote products derived from
17  this software without specific prior written permission.
18 
19  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30 
31 #ifndef FORMUPDATE_H
32 #define FORMUPDATE_H
33 
34 #include "ui_formupdate.h"
35 
36 #include "miscellaneous/systemfactory.h"
37 
38 #include <QDialog>
39 #include <QPushButton>
40 #include <QNetworkReply>
41 
42 
43 namespace Ui {
44  class FormUpdate;
45 }
46 
47 class Downloader;
48 
49 /// \brief Dialog for showing update details.
50 /// \see UpdateInfo, UpdateUrl, SystemFactory::checkForUpdates()
51 class FormUpdate : public QDialog {
52  Q_OBJECT
53 
54  public:
55  // Constructors and destructors.
56  explicit FormUpdate(QWidget *parent = 0);
57  virtual ~FormUpdate();
58 
59  /// \brief Indication of update/platform suitability.
60  /// \return Returns true if current update provides
61  /// installation file for current platform.
62  bool isUpdateForThisSystem() const;
63 
64  /// \brief Indication of presence of self-update feature.
65  /// \return Returns true if application can self-update
66  /// on current platform.
67  /// \note This returns false for all platforms.
68  bool isSelfUpdateSupported() const;
69 
70  protected slots:
71  /// \brief Check for updates and interprets the results.
72  void checkForUpdates();
73 
74  void startUpdate();
75 
76  void updateProgress(qint64 bytes_received, qint64 bytes_total);
77  void updateCompleted(QNetworkReply::NetworkError status, QByteArray contents);
78  void saveUpdateFile(const QByteArray &file_contents);
79 
80  private:
81  Downloader *m_downloader;
82  bool m_readyToInstall;
83  QString m_updateFilePath;
84  Ui::FormUpdate *m_ui;
85  UpdateInfo m_updateInfo;
86  QPushButton *m_btnUpdate;
87 };
88 
89 #endif // FORMUPDATE_H
Dialog for showing update details.
Definition: formupdate.h:51
void checkForUpdates()
Check for updates and interprets the results.
Definition: formupdate.cpp:82
Simple file downloader with progress reporting.
Definition: downloader.h:47
Information about available update.
Definition: systemfactory.h:49
bool isSelfUpdateSupported() const
Indication of presence of self-update feature.
Definition: formupdate.cpp:73
bool isUpdateForThisSystem() const
Indication of update/platform suitability.
Definition: formupdate.cpp:69