summaryrefslogtreecommitdiffstats
path: root/src/sdk/installerbase_p.cpp
diff options
context:
space:
mode:
authorkh1 <karsten.heimrich@digia.com>2014-01-07 14:19:44 +0100
committerKai Koehne <kai.koehne@digia.com>2014-01-08 08:29:30 +0100
commitd27ea0c55847dc8206d43ea2062cd568a049bf54 (patch)
tree0bd8846f9422fb86839c5520a14092138db26b18 /src/sdk/installerbase_p.cpp
parenteba0757fb0376728ece170b4c7a23d0359b4a8ed (diff)
Fix --checkupdates shows error dialog if network is down.
Task-number: QTIFW-431 We need to add a separate console window in case we run on windows, though we can't use a gui application as the lib might popup message boxes. (MessageBoxHandler checks against a running core application) Change-Id: Idad8dff44c6c0bfb0bb45e8a0fb408b3db832c3c Reviewed-by: Niels Weber <niels.weber@digia.com> Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'src/sdk/installerbase_p.cpp')
-rw-r--r--src/sdk/installerbase_p.cpp138
1 files changed, 3 insertions, 135 deletions
diff --git a/src/sdk/installerbase_p.cpp b/src/sdk/installerbase_p.cpp
index 4fcbe7b6e..2c79e0dde 100644
--- a/src/sdk/installerbase_p.cpp
+++ b/src/sdk/installerbase_p.cpp
@@ -39,6 +39,7 @@
**
**************************************************************************/
#include "installerbase_p.h"
+#include "console.h"
#include <binaryformat.h>
#include <errors.h>
@@ -58,147 +59,14 @@
#include <QMessageBox>
-#include <fstream>
#include <iomanip>
#include <iostream>
-#ifdef Q_OS_WIN
-# include <windows.h>
-# include <wincon.h>
-
-# ifndef ENABLE_INSERT_MODE
-# define ENABLE_INSERT_MODE 0x0020
-# endif
-
-# ifndef ENABLE_QUICK_EDIT_MODE
-# define ENABLE_QUICK_EDIT_MODE 0x0040
-# endif
-
-# ifndef ENABLE_EXTENDED_FLAGS
-# define ENABLE_EXTENDED_FLAGS 0x0080
-# endif
-#endif
-
using namespace KDUpdater;
using namespace QInstaller;
using namespace QInstallerCreator;
-// -- MyCoreApplication
-
-MyCoreApplication::MyCoreApplication(int &argc, char **argv)
- : QCoreApplication(argc, argv)
-{
-}
-
-// re-implemented from QCoreApplication so we can throw exceptions in scripts and slots
-bool MyCoreApplication::notify(QObject *receiver, QEvent *event)
-{
- try {
- return QCoreApplication::notify(receiver, event);
- } catch(std::exception &e) {
- qFatal("Exception thrown: %s", e.what());
- }
- return false;
-}
-
-
-// -- MyApplicationConsole
-
-class MyApplicationConsole
-{
-public:
- MyApplicationConsole()
- {
-#ifdef Q_OS_WIN
- AllocConsole();
-
- HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
- if (handle != INVALID_HANDLE_VALUE) {
- COORD largestConsoleWindowSize = GetLargestConsoleWindowSize(handle);
- largestConsoleWindowSize.X -= 3;
- largestConsoleWindowSize.Y = 5000;
- SetConsoleScreenBufferSize(handle, largestConsoleWindowSize);
- }
-
- handle = GetStdHandle(STD_INPUT_HANDLE);
- if (handle != INVALID_HANDLE_VALUE)
- SetConsoleMode(handle, ENABLE_INSERT_MODE | ENABLE_QUICK_EDIT_MODE | ENABLE_EXTENDED_FLAGS);
-
- m_oldCin = std::cin.rdbuf();
- m_newCin.open("CONIN$");
- std::cin.rdbuf(m_newCin.rdbuf());
-
- m_oldCout = std::cout.rdbuf();
- m_newCout.open("CONOUT$");
- std::cout.rdbuf(m_newCout.rdbuf());
-
- m_oldCerr = std::cerr.rdbuf();
- m_newCerr.open("CONOUT$");
- std::cerr.rdbuf(m_newCerr.rdbuf());
-# ifndef Q_CC_MINGW
- HMENU systemMenu = GetSystemMenu(GetConsoleWindow(), FALSE);
- if (systemMenu != NULL)
- RemoveMenu(systemMenu, SC_CLOSE, MF_BYCOMMAND);
- DrawMenuBar(GetConsoleWindow());
-# endif
-#endif
- }
- ~MyApplicationConsole()
- {
-#ifdef Q_OS_WIN
- system("PAUSE");
-
- std::cin.rdbuf(m_oldCin);
- std::cerr.rdbuf(m_oldCerr);
- std::cout.rdbuf(m_oldCout);
-
- FreeConsole();
-#endif
- }
-
-private:
- std::ifstream m_newCin;
- std::ofstream m_newCout;
- std::ofstream m_newCerr;
-
- std::streambuf* m_oldCin;
- std::streambuf* m_oldCout;
- std::streambuf* m_oldCerr;
-};
-
-
-// -- MyApplication
-
-MyApplication::MyApplication(int &argc, char **argv)
- : QApplication(argc, argv)
- , m_console(0)
-{
-}
-
-MyApplication::~MyApplication()
-{
- delete m_console;
-}
-
-void MyApplication::setVerbose()
-{
- if (!m_console)
- m_console = new MyApplicationConsole;
-}
-
-// re-implemented from QApplication so we can throw exceptions in scripts and slots
-bool MyApplication::notify(QObject *receiver, QEvent *event)
-{
- try {
- return QApplication::notify(receiver, event);
- } catch(std::exception &e) {
- qFatal("Exception thrown: %s", e.what());
- }
- return false;
-}
-
-
// -- InstallerBase
InstallerBase::InstallerBase(QObject *parent)
@@ -307,7 +175,7 @@ void InstallerBase::showUsage()
{
#define WIDTH1 46
#define WIDTH2 40
- MyApplicationConsole c;
+ Console c;
std::cout << "Usage: SDKMaintenanceTool [OPTIONS]" << std::endl << std::endl;
std::cout << "User:"<<std::endl;
@@ -373,7 +241,7 @@ void InstallerBase::showUsage()
/* static*/
void InstallerBase::showVersion(const QString &version)
{
- MyApplicationConsole c;
+ Console c;
std::cout << qPrintable(version) << std::endl;
}