1 /************************************************************************
\r
3 ** Copyright (C) 2010 Strahinja Markovic
\r
5 ** This file is part of FlightCrew.
\r
7 ** FlightCrew is free software: you can redistribute it and/or modify
\r
8 ** it under the terms of the GNU Lesser General Public License as published
\r
9 ** by the Free Software Foundation, either version 3 of the License, or
\r
10 ** (at your option) any later version.
\r
12 ** FlightCrew is distributed in the hope that it will be useful,
\r
13 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
15 ** GNU Lesser General Public License for more details.
\r
17 ** You should have received a copy of the GNU Lesser General Public License
\r
18 ** along with FlightCrew. If not, see <http://www.gnu.org/licenses/>.
\r
20 *************************************************************************/
\r
23 #ifndef UPDATECHECKER_H
\r
24 #define UPDATECHECKER_H
\r
28 class QNetworkAccessManager;
\r
29 class QNetworkReply;
\r
32 * Responsible for checking the current online version of
\r
33 * FlightCrew against the running one. If a newer version
\r
34 * exists, then a dialog is displayed informing the user
\r
37 * Objects of this class should ALWAYS be created on the heap
\r
38 * and never explicitly deleted. The reason is that these objects
\r
39 * receive replies asynchronously from the web and need to persist.
\r
40 * Upon receiving and processing the network reply, the object
\r
41 * schedules its own deletion.
\r
43 class UpdateChecker : QObject
\r
52 * @param parent The object's parent.
\r
54 UpdateChecker( QObject *parent );
\r
57 * Sends a request for the online version
\r
58 * if the last check was performed
\r
59 * a SECONDS_BETWEEN_CHECKS amount of time ago.
\r
61 void CheckForUpdate();
\r
66 * Gets called when the request posted by CheckForUpdate()
\r
67 * gets a reply from the server.
\r
69 * @param reply The network reply.
\r
71 void ReplyRecieved( QNetworkReply* reply );
\r
76 * Extracts the full text present in the network reply.
\r
78 * @param reply The reply from which text should be extracted.
\r
79 * @return The full text content.
\r
81 QString TextInReply( QNetworkReply* reply ) const;
\r
84 * Returns the version string present
\r
85 * in the specified XML file, or an empty QString
\r
86 * if the required element is not present.
\r
88 * @param online_version_xml The xml content from the reply.
\r
89 * @return The version string.
\r
91 QString ReadOnlineVersion( const QString &online_version_xml ) const;
\r
94 * Compares the two provided version strings.
\r
96 * @param current_version_string The version of the running program.
\r
97 * @param online_version_string The newest version.
\r
98 * @return \c true if the online string specifies
\r
99 * that the online version is newer.
\r
101 bool IsOnlineVersionNewer( const QString ¤t_version_string,
\r
102 const QString &online_version_string ) const;
\r
105 ///////////////////////////////
\r
106 // PRIVATE MEMBER VARIABLES
\r
107 ///////////////////////////////
\r
110 * The network manager used to post
\r
111 * network requests and receive replies.
\r
113 QNetworkAccessManager *m_NetworkManager;
\r
117 #endif // UPDATECHECKER_H
\r