2008-09-28 17:02:36 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 by Dominik Riebeling
|
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef BOOTLOADERINSTALLBASE_H
|
|
|
|
#define BOOTLOADERINSTALLBASE_H
|
|
|
|
|
|
|
|
#include <QtCore>
|
2021-12-26 10:05:25 +00:00
|
|
|
#include "progressloglevels.h"
|
2008-09-28 17:02:36 +00:00
|
|
|
#include "httpget.h"
|
|
|
|
|
2009-05-09 18:17:05 +00:00
|
|
|
//! baseclass for all Bootloader installs
|
2008-09-28 17:02:36 +00:00
|
|
|
class BootloaderInstallBase : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
enum Capability
|
|
|
|
{ Install = 0x01, Uninstall = 0x02, Backup = 0x04,
|
2009-05-09 18:17:05 +00:00
|
|
|
IsFile = 0x08, IsRaw = 0x10, NeedsOf = 0x20,
|
2008-09-28 17:02:36 +00:00
|
|
|
CanCheckInstalled = 0x40, CanCheckVersion = 0x80 };
|
|
|
|
Q_DECLARE_FLAGS(Capabilities, Capability)
|
|
|
|
|
|
|
|
enum BootloaderType
|
|
|
|
{ BootloaderNone, BootloaderRockbox, BootloaderOther, BootloaderUnknown };
|
|
|
|
|
2009-05-09 18:17:05 +00:00
|
|
|
BootloaderInstallBase(QObject *parent) : QObject(parent)
|
2008-09-28 17:02:36 +00:00
|
|
|
{ }
|
|
|
|
|
2009-05-09 18:17:05 +00:00
|
|
|
//! install the bootloader, must be implemented
|
|
|
|
virtual bool install(void) = 0;
|
|
|
|
//! uninstall the bootloader, must be implemented
|
|
|
|
virtual bool uninstall(void) = 0;
|
|
|
|
//! returns the installed bootloader
|
|
|
|
virtual BootloaderType installed(void)=0;
|
|
|
|
//! returns the capabilities of the bootloader class
|
|
|
|
virtual Capabilities capabilities(void)=0;
|
2009-08-09 10:57:33 +00:00
|
|
|
//! returns a OF Firmware hint or empty if there is none
|
2009-05-09 18:17:05 +00:00
|
|
|
virtual QString ofHint() {return QString();}
|
2012-01-03 21:48:27 +00:00
|
|
|
|
2009-05-09 18:17:05 +00:00
|
|
|
//! backup a already installed bootloader
|
2008-09-28 17:02:36 +00:00
|
|
|
bool backup(QString to);
|
|
|
|
|
2009-08-09 10:57:39 +00:00
|
|
|
//! set the different filenames and paths
|
|
|
|
void setBlFile(QStringList f);
|
2008-09-28 17:02:36 +00:00
|
|
|
void setBlUrl(QUrl u)
|
|
|
|
{ m_blurl = u; }
|
|
|
|
void setLogfile(QString f)
|
|
|
|
{ m_logfile = f; }
|
2012-01-15 22:20:17 +00:00
|
|
|
bool setOfFile(QString of, QStringList blfile);
|
2012-01-03 21:48:27 +00:00
|
|
|
|
2009-08-09 10:57:33 +00:00
|
|
|
//! returns a port Install Hint or empty if there is none
|
|
|
|
//! static and in the base class, so the installer classes dont need to
|
|
|
|
// be modified for new targets
|
2008-09-28 17:02:36 +00:00
|
|
|
static QString postinstallHints(QString model);
|
2012-01-03 21:48:27 +00:00
|
|
|
|
2008-09-28 17:02:36 +00:00
|
|
|
protected slots:
|
|
|
|
void downloadReqFinished(int id, bool error);
|
|
|
|
void downloadBlFinish(bool error);
|
|
|
|
void installBlfile(void);
|
2016-01-08 22:56:27 +00:00
|
|
|
void progressAborted(void);
|
2009-11-22 22:13:25 +00:00
|
|
|
|
|
|
|
// NOTE: we need to keep this slot even on targets that don't need it
|
|
|
|
// -- using the preprocessor here confused moc.
|
|
|
|
void checkRemount(void);
|
2008-09-28 17:02:36 +00:00
|
|
|
protected:
|
|
|
|
enum LogMode
|
|
|
|
{ LogAdd, LogRemove };
|
|
|
|
|
|
|
|
void downloadBlStart(QUrl source);
|
|
|
|
int logInstall(LogMode mode);
|
|
|
|
|
|
|
|
HttpGet m_http; //! http download object
|
|
|
|
QString m_blfile; //! bootloader filename on player
|
|
|
|
QString m_logfile; //! file for installation log
|
|
|
|
QUrl m_blurl; //! bootloader download URL
|
|
|
|
QTemporaryFile m_tempfile; //! temporary file for download
|
2012-01-15 22:20:17 +00:00
|
|
|
QTemporaryFile m_tempof; //! temporary file for OF extracted from archive
|
2008-09-28 17:02:36 +00:00
|
|
|
QDateTime m_blversion; //! download timestamp used for version information
|
2009-05-09 18:17:05 +00:00
|
|
|
QString m_offile; //! path to the offile
|
2009-11-22 22:13:25 +00:00
|
|
|
#if defined(Q_OS_MACX)
|
|
|
|
void waitRemount(void);
|
|
|
|
|
|
|
|
int m_remountTries;
|
|
|
|
QString m_remountDevice;
|
|
|
|
#endif
|
|
|
|
|
2008-09-28 17:02:36 +00:00
|
|
|
signals:
|
|
|
|
void downloadDone(void); //! internal signal sent when download finished.
|
2016-01-08 22:56:27 +00:00
|
|
|
void installAborted(void); //! internal signal sent on abort button click.
|
2008-09-28 17:02:36 +00:00
|
|
|
void done(bool);
|
|
|
|
void logItem(QString, int); //! set logger item
|
|
|
|
void logProgress(int, int); //! set progress bar.
|
2009-11-22 22:13:25 +00:00
|
|
|
|
|
|
|
// NOTE: we need to keep this signal even on targets that don't need it
|
|
|
|
// -- using the preprocessor here confused moc.
|
|
|
|
void remounted(bool);
|
2008-09-28 17:02:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(BootloaderInstallBase::Capabilities)
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|