1 #include "updatenotification.h"
2 
3 #include <QNetworkAccessManager>
4 #include <QStatusBar>
5 
6 #include "mainwindow.h"
7 
8 UpdateNotification olive::update_notifier;
9 
UpdateNotification()10 UpdateNotification::UpdateNotification()
11 {
12 
13 }
14 
check()15 void UpdateNotification::check()
16 {
17 #if defined(GITHASH) && defined(UPDATEMSG)
18   QNetworkAccessManager* manager = new QNetworkAccessManager();
19 
20   connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(finished_slot(QNetworkReply *)));
21   connect(manager, SIGNAL(finished(QNetworkReply *)), manager, SLOT(deleteLater()));
22 
23   QString update_url = QString("http://olivevideoeditor.org/update.php?version=0&hash=%1");
24 
25   QNetworkRequest request(QUrl(update_url.arg(GITHASH)));
26   manager->get(request);
27 #endif
28 }
29 
finished_slot(QNetworkReply * reply)30 void UpdateNotification::finished_slot(QNetworkReply *reply)
31 {
32   QString response = QString::fromUtf8(reply->readAll());
33 
34   if (response == "1") {
35     olive::MainWindow->statusBar()->showMessage(tr("An update is available from the Olive website. "
36                                                    "Visit www.olivevideoeditor.org to download it."));
37   }
38 }
39