1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
/*
* Qt UI
*
* Copyright (C) 2016 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
* Munkyu Im <munkyu.im@samsung.com>
* seokYeon Hwang <syeon.hwang@samsung.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
* Contributors:
* - S-Core Co., Ltd
*
*/
#include "sdbhelperthread.h"
#include "sdbhelper.h"
#include "displaybase.h"
#include "resource/ui_strings.h"
extern "C" {
#include "emul_state.h"
}
SdbHelperThread::SdbHelperThread(SdbHelper *parent)
{
this->parent = parent;
connect(this, SIGNAL(errorOccured(QString, int)), this, SLOT(handleErrorOccured(QString, int)));
}
void SdbHelperThread::setArguments(int command, QString &program, QList<QStringList> &args)
{
this->command = command;
this->program = program;
this->arguments = args;
}
void SdbHelperThread::run()
{
if (program.isEmpty() || arguments.isEmpty())
return;
for (int i = 0; i < arguments.size(); ++i) {
qDebug() << "program: " << program << arguments.at(i);
process = new QProcess();
process->deleteLater();
process->start(program, arguments.at(i));
process->waitForFinished();
outMsg = QString::fromLocal8Bit(process->readAllStandardOutput());
//FIXME: (sdb) general pushing log may redirect to stderr
errorMsg = QString::fromLocal8Bit(process->readAllStandardError());
qDebug() << "errorMsg" << errorMsg;
qDebug() << "outMsg" << outMsg;
//FIXME: (sdb) general sdb installation failure message is printed with stdout */
if (command == SDB_INSTALL_COMMAND && outMsg.contains(SDB_INSTALL_FAILURE)) {
emit errorOccured(outMsg, process->exitCode());
return;
}
if (process->exitCode() || process->exitStatus()) {
emit errorOccured(errorMsg, process->exitCode());
return;
}
}
}
void SdbHelperThread::handleErrorOccured(QString errString, int exitCode)
{
qDebug() << "exitcode: " << exitCode;
//FIXME: (sdb) cannot returns exit code like "no space left"
showMsgBox(QMessageBox::Warning, MSG_SDB_FAILED_PROCESSING + errString);
}
QMessageBox *SdbHelperThread::showMsgBox(
QMessageBox::Icon iconType, const QString &text,
QMessageBox::StandardButtons buttons,
QMessageBox::StandardButton defaultButton)
{
qWarning() << text;
QMessageBox *msgBox = new QMessageBox(iconType,
EMULATOR_TITLE, text, buttons, (QWidget *)parent->getMainWindow());
if (defaultButton != QMessageBox::NoButton) {
msgBox->setDefaultButton(defaultButton);
}
msgBox->setAttribute(Qt::WA_DeleteOnClose);
msgBox->setModal(false);
msgBox->show(); /* non-blocking */
return msgBox;
}
|