FS#10925 by myself: add touchscreen support for virtual keyboard.
[kugel-rb.git] / rbutil / rbutilqt / base / bootloaderinstallmpio.cpp
blob97e96678c991a16a47aa386055881599aca92e5f
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
9 * Copyright (C) 2008 by Dominik Wenger
10 * $Id: bootloaderinstallams.cpp 24778 2010-02-19 23:45:29Z funman $
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 "bootloaderinstallmpio.h"
24 #include "../mkmpioboot/mkmpioboot.h"
26 BootloaderInstallMpio::BootloaderInstallMpio(QObject *parent)
27 : BootloaderInstallBase(parent)
31 QString BootloaderInstallMpio::ofHint()
33 return tr("Bootloader installation requires you to provide "
34 "a firmware file of the original firmware (bin 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 "
38 "the <a href='http://www.rockbox.org/wiki/MPIOHD200Port'>MPIOHD200Port</a> "
39 "wiki page on how to obtain this file.<br/>"
40 "Press Ok to continue and browse your computer for the firmware "
41 "file.");
44 bool BootloaderInstallMpio::install(void)
46 if(m_offile.isEmpty())
47 return false;
49 qDebug() << "[BootloaderInstallMpio] installing bootloader";
51 // download firmware from server
52 emit logItem(tr("Downloading bootloader file"), LOGINFO);
54 connect(this, SIGNAL(downloadDone()), this, SLOT(installStage2()));
55 downloadBlStart(m_blurl);
57 return true;
60 void BootloaderInstallMpio::installStage2(void)
62 qDebug() << "[BootloaderInstallMpio] installStage2";
64 int origin = 0xe0000; /* MPIO HD200 bootloader address */
66 m_tempfile.open();
67 QString bootfile = m_tempfile.fileName();
68 m_tempfile.close();
70 int ret = mkmpioboot(m_offile.toLocal8Bit().data(),
71 bootfile.toLocal8Bit().data(), m_blfile.toLocal8Bit().data(), origin);
73 if(ret != 0)
75 QString error;
76 switch(ret)
78 case -1:
79 error = tr("Could not open the original firmware.");
80 break;
81 case -2:
82 error = tr("Could not read the original firmware.");
83 break;
84 case -3:
85 error = tr("Loaded firmware file does not look like MPIO original firmware file.");
86 break;
87 case -4:
88 error = tr("Could not open downloaded bootloader.");
89 break;
90 case -5:
91 error = tr("Place for bootloader in OF file not empty.");
92 break;
93 case -6:
94 error = tr("Could not read the downloaded bootloader.");
95 break;
96 case -7:
97 error = tr("Bootloader checksum error.");
98 break;
99 case -8:
100 error = tr("Could not open output file.");
101 break;
102 case -9:
103 error = tr("Could not write output file.");
104 break;
105 default:
106 error = tr("Unknown error number: %1").arg(ret);
107 break;
110 qDebug() << tr("Patching original firmware failed: %1").arg(error);
111 emit logItem(tr("Patching original firmware failed: %1").arg(error), LOGERROR);
112 emit done(true);
113 return;
116 //end of install
117 qDebug() << "[BootloaderInstallMpio] install successful";
118 emit logItem(tr("Success: modified firmware file created"), LOGINFO);
119 logInstall(LogAdd);
120 emit done(false);
121 return;
124 bool BootloaderInstallMpio::uninstall(void)
126 emit logItem(tr("To uninstall, perform a normal upgrade with an unmodified "
127 "original firmware"), LOGINFO);
128 logInstall(LogRemove);
129 return false;
132 BootloaderInstallBase::BootloaderType BootloaderInstallMpio::installed(void)
134 return BootloaderUnknown;
137 BootloaderInstallBase::Capabilities BootloaderInstallMpio::capabilities(void)
139 return (Install | NeedsOf);