HDD6330: add missing button for test_codec.
[kugel-rb.git] / rbutil / rbutilqt / base / bootloaderinstallchinachip.cpp
blobbbb5649259604fb268dd61ad6233ba86a0b49df0
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
9 * Copyright (C) 2009 by Maurus Cuelenaere
10 * $Id$
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 ****************************************************************************/
20 #include <QtCore>
21 #include "bootloaderinstallbase.h"
22 #include "bootloaderinstallchinachip.h"
24 #include "../chinachippatcher/chinachip.h"
26 BootloaderInstallChinaChip::BootloaderInstallChinaChip(QObject *parent)
27 : BootloaderInstallBase(parent)
29 (void)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 "
43 "file.");
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;
57 va_list args;
59 va_start(args, format);
60 pThis->logString(format, args, LOGINFO);
61 va_end(args);
64 static void err(void* userdata, char* format, ...)
66 BootloaderInstallChinaChip* pThis = (BootloaderInstallChinaChip*) userdata;
67 va_list args;
69 va_start(args, format);
70 pThis->logString(format, args, LOGERROR);
71 va_end(args);
74 bool BootloaderInstallChinaChip::install()
76 if(m_offile.isEmpty())
77 return false;
79 emit logItem(tr("Downloading bootloader file"), LOGINFO);
81 connect(this, SIGNAL(downloadDone()), this, SLOT(installStage2()));
82 downloadBlStart(m_blurl);
84 return true;
87 void BootloaderInstallChinaChip::installStage2()
89 m_tempfile.open();
90 QString blfile = m_tempfile.fileName();
91 m_tempfile.close();
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;
99 emit done(ret);
102 bool BootloaderInstallChinaChip::uninstall()
104 /* TODO: only way is to restore the OF */
105 return false;
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);