1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
9 * Copyright (C) 2009 by Maurus Cuelenaere
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.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
21 #include "bootloaderinstallbase.h"
22 #include "bootloaderinstallchinachip.h"
24 #include "../chinachippatcher/chinachip.h"
26 BootloaderInstallChinaChip::BootloaderInstallChinaChip(QObject
*parent
)
27 : BootloaderInstallBase(parent
)
32 QString
BootloaderInstallChinaChip::ofHint()
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 "
46 void BootloaderInstallChinaChip::logString(char* format
, va_list args
, int type
)
48 QString translation
= QCoreApplication::translate("", format
, NULL
, QCoreApplication::UnicodeUTF8
);
50 emit
logItem(QString().vsprintf(translation
.toLocal8Bit(), args
), type
);
51 QCoreApplication::processEvents();
54 static void info(void* userdata
, char* format
, ...)
56 BootloaderInstallChinaChip
* pThis
= (BootloaderInstallChinaChip
*) userdata
;
59 va_start(args
, format
);
60 pThis
->logString(format
, args
, LOGINFO
);
64 static void err(void* userdata
, char* format
, ...)
66 BootloaderInstallChinaChip
* pThis
= (BootloaderInstallChinaChip
*) userdata
;
69 va_start(args
, format
);
70 pThis
->logString(format
, args
, LOGERROR
);
74 bool BootloaderInstallChinaChip::install()
76 if(m_offile
.isEmpty())
79 emit
logItem(tr("Downloading bootloader file"), LOGINFO
);
81 connect(this, SIGNAL(downloadDone()), this, SLOT(installStage2()));
82 downloadBlStart(m_blurl
);
87 void BootloaderInstallChinaChip::installStage2()
90 QString blfile
= m_tempfile
.fileName();
93 QString backupfile
= QFileInfo(m_blfile
).absoluteDir().absoluteFilePath("ccpmp.bin");
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
;
102 bool BootloaderInstallChinaChip::uninstall()
104 /* TODO: only way is to restore the OF */
108 BootloaderInstallBase::BootloaderType
BootloaderInstallChinaChip::installed()
110 /* TODO: find a way to figure this out */
111 return BootloaderUnknown
;
114 BootloaderInstallBase::Capabilities
BootloaderInstallChinaChip::capabilities()
116 return (Install
| IsFile
| NeedsOf
);