diff options
Diffstat (limited to 'rbutil/rbutilqt/base/bootloaderinstallchinachip.cpp')
-rw-r--r-- | rbutil/rbutilqt/base/bootloaderinstallchinachip.cpp | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/rbutil/rbutilqt/base/bootloaderinstallchinachip.cpp b/rbutil/rbutilqt/base/bootloaderinstallchinachip.cpp new file mode 100644 index 0000000000..dba2ec8c92 --- /dev/null +++ b/rbutil/rbutilqt/base/bootloaderinstallchinachip.cpp | |||
@@ -0,0 +1,117 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2009 by Maurus Cuelenaere | ||
10 | * $Id$ | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include <QtCore> | ||
21 | #include "bootloaderinstallbase.h" | ||
22 | #include "bootloaderinstallchinachip.h" | ||
23 | |||
24 | #include "../chinachippatcher/chinachip.h" | ||
25 | |||
26 | BootloaderInstallChinaChip::BootloaderInstallChinaChip(QObject *parent) | ||
27 | : BootloaderInstallBase(parent) | ||
28 | { | ||
29 | (void)parent; | ||
30 | } | ||
31 | |||
32 | QString BootloaderInstallChinaChip::ofHint() | ||
33 | { | ||
34 | return tr("Bootloader installation requires you to provide " | ||
35 | "a firmware file of the original firmware (HXF file). " | ||
36 | "You need to download this file yourself due to legal " | ||
37 | "reasons. Please refer to the " | ||
38 | "<a href='http://www.rockbox.org/manual.shtml'>manual</a> and the " | ||
39 | "<a href='http://www.rockbox.org/wiki/OndaVX747" | ||
40 | "#Download_and_extract_a_recent_ve'>OndaVX747</a> wiki page on " | ||
41 | "how to obtain this file.<br/>" | ||
42 | "Press Ok to continue and browse your computer for the firmware " | ||
43 | "file."); | ||
44 | } | ||
45 | |||
46 | void BootloaderInstallChinaChip::logString(char* format, va_list args, int type) | ||
47 | { | ||
48 | QString buffer; | ||
49 | |||
50 | emit logItem(buffer.vsprintf(format, args), type); | ||
51 | QCoreApplication::processEvents(); | ||
52 | } | ||
53 | |||
54 | static void info(void* userdata, char* format, ...) | ||
55 | { | ||
56 | BootloaderInstallChinaChip* pThis = (BootloaderInstallChinaChip*) userdata; | ||
57 | va_list args; | ||
58 | |||
59 | va_start(args, format); | ||
60 | pThis->logString(format, args, LOGINFO); | ||
61 | va_end(args); | ||
62 | } | ||
63 | |||
64 | static void err(void* userdata, char* format, ...) | ||
65 | { | ||
66 | BootloaderInstallChinaChip* pThis = (BootloaderInstallChinaChip*) userdata; | ||
67 | va_list args; | ||
68 | |||
69 | va_start(args, format); | ||
70 | pThis->logString(format, args, LOGERROR); | ||
71 | va_end(args); | ||
72 | } | ||
73 | |||
74 | bool BootloaderInstallChinaChip::install() | ||
75 | { | ||
76 | if(m_offile.isEmpty()) | ||
77 | return false; | ||
78 | |||
79 | emit logItem(tr("Downloading bootloader file"), LOGINFO); | ||
80 | |||
81 | connect(this, SIGNAL(downloadDone()), this, SLOT(installStage2())); | ||
82 | downloadBlStart(m_blurl); | ||
83 | |||
84 | return true; | ||
85 | } | ||
86 | |||
87 | void BootloaderInstallChinaChip::installStage2() | ||
88 | { | ||
89 | m_tempfile.open(); | ||
90 | QString blfile = m_tempfile.fileName(); | ||
91 | m_tempfile.close(); | ||
92 | |||
93 | QString backupfile = QFileInfo(m_blfile).absoluteDir().absoluteFilePath("ccpmp.bin"); | ||
94 | |||
95 | int ret = chinachip_patch(m_offile.toLocal8Bit(), blfile.toLocal8Bit(), m_blfile.toLocal8Bit(), | ||
96 | backupfile.toLocal8Bit(), &info, &err, (void*)this); | ||
97 | qDebug() << "chinachip_patch" << ret; | ||
98 | |||
99 | emit done(ret); | ||
100 | } | ||
101 | |||
102 | bool BootloaderInstallChinaChip::uninstall() | ||
103 | { | ||
104 | /* TODO: only way is to restore the OF */ | ||
105 | return false; | ||
106 | } | ||
107 | |||
108 | BootloaderInstallBase::BootloaderType BootloaderInstallChinaChip::installed() | ||
109 | { | ||
110 | /* TODO: find a way to figure this out */ | ||
111 | return BootloaderUnknown; | ||
112 | } | ||
113 | |||
114 | BootloaderInstallBase::Capabilities BootloaderInstallChinaChip::capabilities() | ||
115 | { | ||
116 | return (Install | IsFile | NeedsOf); | ||
117 | } | ||