summaryrefslogtreecommitdiff
path: root/utils/rbutilqt/base/bootloaderinstallchinachip.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'utils/rbutilqt/base/bootloaderinstallchinachip.cpp')
-rw-r--r--utils/rbutilqt/base/bootloaderinstallchinachip.cpp133
1 files changed, 133 insertions, 0 deletions
diff --git a/utils/rbutilqt/base/bootloaderinstallchinachip.cpp b/utils/rbutilqt/base/bootloaderinstallchinachip.cpp
new file mode 100644
index 0000000000..f6af952b9a
--- /dev/null
+++ b/utils/rbutilqt/base/bootloaderinstallchinachip.cpp
@@ -0,0 +1,133 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2009 by Maurus Cuelenaere
10 *
11 * All files in this archive are subject to the GNU General Public License.
12 * See the file COPYING in the source tree root for full license agreement.
13 *
14 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
15 * KIND, either express or implied.
16 *
17 ****************************************************************************/
18
19#include <QtCore>
20#include "bootloaderinstallbase.h"
21#include "bootloaderinstallchinachip.h"
22
23#include "../chinachippatcher/chinachip.h"
24
25BootloaderInstallChinaChip::BootloaderInstallChinaChip(QObject *parent)
26 : BootloaderInstallBase(parent)
27{
28 (void)parent;
29}
30
31QString BootloaderInstallChinaChip::ofHint()
32{
33 return tr("Bootloader installation requires you to provide "
34 "a firmware file of the original firmware (HXF file). "
35 "You need to download this file yourself due to legal "
36 "reasons. Please refer to the "
37 "<a href='http://www.rockbox.org/manual.shtml'>manual</a> and the "
38 "<a href='http://www.rockbox.org/wiki/OndaVX747"
39 "#Download_and_extract_a_recent_ve'>OndaVX747</a> wiki page on "
40 "how to obtain this file.<br/>"
41 "Press Ok to continue and browse your computer for the firmware "
42 "file.");
43}
44
45bool BootloaderInstallChinaChip::install()
46{
47 if(m_offile.isEmpty())
48 return false;
49
50 emit logItem(tr("Downloading bootloader file"), LOGINFO);
51
52 connect(this, &BootloaderInstallBase::downloadDone, this, &BootloaderInstallChinaChip::installStage2);
53 downloadBlStart(m_blurl);
54
55 return true;
56}
57
58void BootloaderInstallChinaChip::installStage2()
59{
60 enum cc_error result;
61 bool error = true;
62 m_tempfile.open();
63 QString blfile = m_tempfile.fileName();
64 m_tempfile.close();
65
66 QString backupfile = QFileInfo(m_blfile).absoluteDir().absoluteFilePath("ccpmp.bin");
67
68 result = chinachip_patch(m_offile.toLocal8Bit(), blfile.toLocal8Bit(),
69 m_blfile.toLocal8Bit(), backupfile.toLocal8Bit());
70 switch(result) {
71 case E_OK:
72 error = false;
73 break;
74 case E_OPEN_FIRMWARE:
75 emit logItem(tr("Could not open firmware file"), LOGERROR);
76 break;
77 case E_OPEN_BOOTLOADER:
78 emit logItem(tr("Could not open bootloader file"), LOGERROR);
79 break;
80 case E_MEMALLOC:
81 emit logItem(tr("Could not allocate memory"), LOGERROR);
82 break;
83 case E_LOAD_FIRMWARE:
84 emit logItem(tr("Could not load firmware file"), LOGERROR);
85 break;
86 case E_INVALID_FILE:
87 emit logItem(tr("File is not a valid ChinaChip firmware"), LOGERROR);
88 break;
89 case E_NO_CCPMP:
90 emit logItem(tr("Could not find ccpmp.bin in input file"), LOGERROR);
91 break;
92 case E_OPEN_BACKUP:
93 emit logItem(tr("Could not open backup file for ccpmp.bin"), LOGERROR);
94 break;
95 case E_WRITE_BACKUP:
96 emit logItem(tr("Could not write backup file for ccpmp.bin"), LOGERROR);
97 break;
98 case E_LOAD_BOOTLOADER:
99 emit logItem(tr("Could not load bootloader file"), LOGERROR);
100 break;
101 case E_GET_TIME:
102 emit logItem(tr("Could not get current time"), LOGERROR);
103 break;
104 case E_OPEN_OUTFILE:
105 emit logItem(tr("Could not open output file"), LOGERROR);
106 break;
107 case E_WRITE_OUTFILE:
108 emit logItem(tr("Could not write output file"), LOGERROR);
109 break;
110 default:
111 emit logItem(tr("Unexpected error from chinachippatcher"), LOGERROR);
112 break;
113 }
114
115 emit done(error);
116}
117
118bool BootloaderInstallChinaChip::uninstall()
119{
120 /* TODO: only way is to restore the OF */
121 return false;
122}
123
124BootloaderInstallBase::BootloaderType BootloaderInstallChinaChip::installed()
125{
126 /* TODO: find a way to figure this out */
127 return BootloaderUnknown;
128}
129
130BootloaderInstallBase::Capabilities BootloaderInstallChinaChip::capabilities()
131{
132 return (Install | IsFile | NeedsOf);
133}