Updater stuff.

This commit is contained in:
Martin Rotter 2014-04-10 14:06:29 +02:00
parent 2643feaaa9
commit 163ec6f0f8
4 changed files with 68 additions and 1 deletions

View File

@ -0,0 +1,29 @@
7-Zip Command line version
~~~~~~~~~~~~~~~~~~~~~~~~~~
License for use and distribution
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7-Zip Copyright (C) 1999-2010 Igor Pavlov.
7za.exe is distributed under the GNU LGPL license
Notes:
You can use 7-Zip on any computer, including a computer in a commercial
organization. You don't need to register or pay for 7-Zip.
GNU LGPL information
--------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You can receive a copy of the GNU Lesser General Public License from
http://www.gnu.org/

View File

@ -29,6 +29,9 @@
#include <QDesktopServices>
#include <QProcess>
#if defined(Q_OS_WIN32)
#include "qt_windows.h"
#endif
FormUpdate::FormUpdate(QWidget *parent)
: QDialog(parent), m_ui(new Ui::FormUpdate) {
@ -136,6 +139,23 @@ void FormUpdate::startUpdate() {
// TODO: spustit updater
// pouzit qprocess, nebo neco multiplatformniho
// nebo z quiterss shellexecuter
// program obcas pada, to je mozna zpusobeny tim
// ze je otevreny modalni okno.
close();
#if defined(Q_OS_WIN32)
ShellExecute(0,
0,
(wchar_t *)QString("updater.exe").utf16(),
(wchar_t *) QString("\"%1\" \"%2\"").arg(qApp->applicationFilePath(),
output_file.fileName()).utf16(),
0,
SW_SHOWNORMAL);
#elif defined(Q_OS_OS2)
#endif
// TODO: vetev pro osn
}
else {
// TODO: chyba - nelze zapisovat do souboru

View File

@ -8,4 +8,7 @@ void Detector::handleMessage(const QString &message) {
if (message == "app_is_running") {
qDebug("Detected another instance of RSS Guard/Updater was starting...");
}
else if (message == "app_quit") {
// zprava na vypnuti, tu ignorujeme.
}
}

View File

@ -21,13 +21,23 @@
#include <QTranslator>
#include <QDebug>
#include <QThread>
#include <QProcess>
int main(int argc, char *argv[]) {
int main(int argc, char *argv[]) {
// Instantiate base application object.
QtSingleCoreApplication application("rssguard", argc, argv);
qDebug("Instantiated QtSingleApplication class.");
if (argc != 3) {
qDebug("Insufficient arguments passed. Quitting updater...");
}
else {
// Print input data.
qDebug("RSS Guard application executable: %s", argv[1]);
qDebug("File with update to be installed: %s", argv[2]);
}
// Check if main RSS Guard instance is running.
if (application.sendMessage("app_quit")) {
qDebug("RSS Guard application is running. Quitting it...");
@ -42,6 +52,11 @@ int main(int argc, char *argv[]) {
QObject::connect(&application, SIGNAL(messageReceived(QString)),
&detector, SLOT(handleMessage(QString)));
// Everything is set up, file is downloaded, RSS Guard is not running.
// TODO: nahradit spravne "/" > "\\" v argumentech pro 7za
// https://code.google.com/p/quite-rss/source/browse/src/mainwindow.cpp?repo=updater#393
QProcess::startDetached("7za", QStringList() << "e" << argv[2]);
// Enter global event loop.
return QtSingleCoreApplication::exec();
}