Commit 3ef0f121 authored by Dennis Rassmann's avatar Dennis Rassmann

update_notif: add timeout if server is unreachable & start hidden

Signed-off-by: Dennis Rassmann's avatarshowp1984 <showp1984@gmail.com>
parent 9396c55d
......@@ -67,6 +67,7 @@
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
<value key="QtVersionId" type="int">0</value>
<value key="ToolChain" type="int">0</value>
<value key="addQDumper" type=""></value>
<value key="buildConfiguration" type="int">0</value>
</valuemap>
......@@ -219,7 +220,7 @@
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
<valuelist key="abstractProcess.Environment" type="QVariantList">
<value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-daaW22EhEn,guid=ac9d1ad5f8bfb833a93e21cc4ff0530e</value>
<value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-AK3IOs6MW0,guid=59e227efb3c6b2dfb059065f4ff76076</value>
<value type="QString">DEFAULTS_PATH=/usr/share/gconf/gnome.default.path</value>
<value type="QString">DESKTOP_SESSION=gnome</value>
<value type="QString">DISPLAY=:0.0</value>
......@@ -227,7 +228,7 @@
<value type="QString">GDM_KEYBOARD_LAYOUT=de</value>
<value type="QString">GDM_LANG=en_US.utf8</value>
<value type="QString">GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
<value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-JbhyRt</value>
<value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-rpeLCg</value>
<value type="QString">GTK_MODULES=canberra-gtk-module</value>
<value type="QString">HOME=/home/showp1984</value>
<value type="QString">LANG=en_US.utf8</value>
......@@ -238,17 +239,17 @@
<value type="QString">PATH=/usr/bin:/home/showp1984/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
<value type="QString">PWD=/home/showp1984</value>
<value type="QString">QTDIR=/usr/share/qt4</value>
<value type="QString">SESSION_MANAGER=local/jarvis:@/tmp/.ICE-unix/1496,unix/jarvis:/tmp/.ICE-unix/1496</value>
<value type="QString">SESSION_MANAGER=local/jarvis:@/tmp/.ICE-unix/1721,unix/jarvis:/tmp/.ICE-unix/1721</value>
<value type="QString">SHELL=/bin/bash</value>
<value type="QString">SPEECHD_PORT=7560</value>
<value type="QString">SSH_AGENT_PID=1530</value>
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-JbhyRt/ssh</value>
<value type="QString">SSH_AGENT_PID=1755</value>
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-rpeLCg/ssh</value>
<value type="QString">USER=showp1984</value>
<value type="QString">USERNAME=showp1984</value>
<value type="QString">XAUTHORITY=/var/run/gdm/auth-for-showp1984-Rqzu0R/database</value>
<value type="QString">XAUTHORITY=/var/run/gdm/auth-for-showp1984-hWrKFh/database</value>
<value type="QString">XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg</value>
<value type="QString">XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
<value type="QString">XDG_SESSION_COOKIE=974fcb0734e21cc3b1c41ff34e9d5403-1341149966.587519-994636315</value>
<value type="QString">XDG_SESSION_COOKIE=974fcb0734e21cc3b1c41ff34e9d5403-1341612150.406627-53872009</value>
</valuelist>
<valuelist key="abstractProcess.arguments" type="QVariantList">
<value type="QString">/home/showp1984/_android/WORKDIRECTORY/Kernel_installer_Qt/Bricked-Installer/Bricked-Installer.pro</value>
......@@ -266,7 +267,7 @@
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
<valuelist key="abstractProcess.Environment" type="QVariantList">
<value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-daaW22EhEn,guid=ac9d1ad5f8bfb833a93e21cc4ff0530e</value>
<value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-AK3IOs6MW0,guid=59e227efb3c6b2dfb059065f4ff76076</value>
<value type="QString">DEFAULTS_PATH=/usr/share/gconf/gnome.default.path</value>
<value type="QString">DESKTOP_SESSION=gnome</value>
<value type="QString">DISPLAY=:0.0</value>
......@@ -274,7 +275,7 @@
<value type="QString">GDM_KEYBOARD_LAYOUT=de</value>
<value type="QString">GDM_LANG=en_US.utf8</value>
<value type="QString">GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
<value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-JbhyRt</value>
<value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-rpeLCg</value>
<value type="QString">GTK_MODULES=canberra-gtk-module</value>
<value type="QString">HOME=/home/showp1984</value>
<value type="QString">LANG=en_US.utf8</value>
......@@ -285,17 +286,17 @@
<value type="QString">PATH=/usr/bin:/home/showp1984/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
<value type="QString">PWD=/home/showp1984</value>
<value type="QString">QTDIR=/usr/share/qt4</value>
<value type="QString">SESSION_MANAGER=local/jarvis:@/tmp/.ICE-unix/1496,unix/jarvis:/tmp/.ICE-unix/1496</value>
<value type="QString">SESSION_MANAGER=local/jarvis:@/tmp/.ICE-unix/1721,unix/jarvis:/tmp/.ICE-unix/1721</value>
<value type="QString">SHELL=/bin/bash</value>
<value type="QString">SPEECHD_PORT=7560</value>
<value type="QString">SSH_AGENT_PID=1530</value>
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-JbhyRt/ssh</value>
<value type="QString">SSH_AGENT_PID=1755</value>
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-rpeLCg/ssh</value>
<value type="QString">USER=showp1984</value>
<value type="QString">USERNAME=showp1984</value>
<value type="QString">XAUTHORITY=/var/run/gdm/auth-for-showp1984-Rqzu0R/database</value>
<value type="QString">XAUTHORITY=/var/run/gdm/auth-for-showp1984-hWrKFh/database</value>
<value type="QString">XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg</value>
<value type="QString">XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
<value type="QString">XDG_SESSION_COOKIE=974fcb0734e21cc3b1c41ff34e9d5403-1341149966.587519-994636315</value>
<value type="QString">XDG_SESSION_COOKIE=974fcb0734e21cc3b1c41ff34e9d5403-1341612150.406627-53872009</value>
</valuelist>
<value key="abstractProcess.IgnoreReturnValue" type="bool">false</value>
<valuelist key="abstractProcess.arguments" type="QVariantList">
......
#############################################################################
# Makefile for building: Bricked-Installer
# Generated by qmake (2.01a) (Qt 4.6.2) on: Fri Jul 6 04:08:17 2012
# Generated by qmake (2.01a) (Qt 4.6.2) on: Sat Jul 7 02:59:37 2012
# Project: Bricked-Installer.pro
# Template: app
# Command: /usr/bin/qmake-qt4 -spec /usr/share/qt4/mkspecs/linux-g++ -unix -o Makefile Bricked-Installer.pro
......@@ -252,7 +252,13 @@ moc_openfile.cpp: info.h \
openfile.h
/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) openfile.h -o moc_openfile.cpp
moc_update_notif.cpp: update_notif.h
moc_update_notif.cpp: dragons.h \
mainwindow.h \
info.h \
detect.h \
openfile.h \
flasher.h \
update_notif.h
/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) update_notif.h -o moc_update_notif.cpp
moc_quazipfile.cpp: quazip/quazip_global.h \
......@@ -371,6 +377,12 @@ openfile.o: openfile.cpp openfile.h \
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o openfile.o openfile.cpp
update_notif.o: update_notif.cpp update_notif.h \
dragons.h \
mainwindow.h \
info.h \
detect.h \
openfile.h \
flasher.h \
ui_update_notif.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o update_notif.o update_notif.cpp
......
......@@ -14,6 +14,7 @@
* more details.
*/
#include <QApplication>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QDebug>
......@@ -30,7 +31,3 @@ QSqlDatabase connectDB(void) {
if (!db.open()) qDebug() << "Failed to connect to database";
return db;
}
void closeDB(QSqlDatabase db) {
db.close();
}
......@@ -30,6 +30,7 @@ int main(int argc, char *argv[])
a.setApplicationVersion(APP_VERSION);
un.show();
un.hide();
return a.exec();
}
......@@ -27,19 +27,27 @@ update_notif::update_notif(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::update_notif)
{
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(closeupdnot()));
timer_tout = new QTimer(this);
connect(timer_tout, SIGNAL(timeout()), this, SLOT(tout_close()));
getDBupd *dbupd = new getDBupd();
QObject::connect(dbupd,
SIGNAL(finished()),
this,
SLOT(closeupdnot()));
dbupd->start();
this->p_dbupd = dbupd;
ui->setupUi(this);
timer->setSingleShot(true);
timer->setInterval(0);
timer->start();
timer_tout->setSingleShot(true);
timer_tout->setInterval(1000);
timer_tout->start();
}
update_notif::~update_notif()
{
delete timer;
delete timer_tout;
delete ui;
}
......@@ -57,45 +65,30 @@ void update_notif::changeEvent(QEvent *e)
void update_notif::closeupdnot(void)
{
float version = 0;
QSqlDatabase db = connectDB();
QSqlQuery query;
QString branch;
QString changelog;
QString date;
QString url;
QString ver;
qDebug() << "Local: " << qApp->applicationVersion();
query.prepare("SELECT version, branch, changelog, date, url FROM versions WHERE version = (SELECT MAX(version) FROM versions) AND version > " + qApp->applicationVersion());
query.exec();
while (query.next()) {
version = query.value(0).toFloat();
branch = query.value(1).toString();
changelog = query.value(2).toString();
date = query.value(3).toString();
url = query.value(4).toString();
qDebug() << version << branch << date << url;// << changelog;
}
if (version > qApp->applicationVersion().toFloat()) {
timer_tout->stop();
show();
if (p_dbupd->version > qApp->applicationVersion().toFloat()) {
qDebug() << "Update found!";
ver = QString::number(version);
ver = QString::number(p_dbupd->version);
ui->lbl_edt_vers->setText(ver);
ui->lbl_edt_branch->setText(branch);
ui->lbl_edt_date->setText(date);
ui->txt_change->setText(changelog);
ui->lbl_edt_branch->setText(p_dbupd->branch);
ui->lbl_edt_date->setText(p_dbupd->date);
ui->txt_change->setText(p_dbupd->changelog);
url = url;
} else {
qDebug() << "No update found.";
closeDB(db);
this->close();
d = new dragons();
d->show();
}
}
closeDB(db);
void update_notif::tout_close(void)
{
this->close();
d = new dragons();
d->show();
}
void update_notif::on_btn_quit_clicked()
......@@ -109,3 +102,26 @@ void update_notif::on_btn_later_clicked()
d = new dragons();
d->show();
}
void getDBupd::run(void)
{
QSqlDatabase db = connectDB();
QSqlQuery query;
qDebug() << "Local: " << qApp->applicationVersion();
query.prepare("SELECT version, branch, changelog, date, url FROM versions WHERE version = (SELECT MAX(version) FROM versions) AND version > " + qApp->applicationVersion());
query.exec();
while (query.next()) {
version = query.value(0).toFloat();
branch = query.value(1).toString();
changelog = query.value(2).toString();
date = query.value(3).toString();
url = query.value(4).toString();
qDebug() << version << branch << date << url;// << changelog;
}
db.close();
db.removeDatabase("default");
this->finished();
this->quit();
}
......@@ -20,18 +20,20 @@
#include <QMainWindow>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QThread>
#include "dragons.h"
namespace Ui {
class update_notif;
}
class getDBupd;
class update_notif : public QMainWindow {
Q_OBJECT
public:
update_notif(QWidget *parent = 0);
~update_notif();
getDBupd *p_dbupd;
protected:
void changeEvent(QEvent *e);
......@@ -39,13 +41,29 @@ protected:
private:
Ui::update_notif *ui;
dragons *d;
QTimer *timer;
QTimer *timer_tout;
QString url;
private slots:
void on_btn_later_clicked();
void on_btn_quit_clicked();
void closeupdnot(void);
void tout_close(void);
};
class getDBupd : public QThread {
Q_OBJECT
public:
void run();
QString branch;
QString changelog;
QString date;
QString url;
float version;
signals:
void finished();
void error(QString err);
};
#endif // UPDATE_NOTIF_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment