summaryrefslogtreecommitdiffstats
path: root/rbutil/rbutilqt/bootloaderinstallbase.h
blob: 4f0d279229aa9e0ca1c5289924c42f4a31768330 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/***************************************************************************
 *             __________               __   ___.
 *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
 *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
 *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
 *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
 *                     \/            \/     \/    \/            \/
 *
 *   Copyright (C) 2008 by Dominik Riebeling
 *   $Id:$
 *
 * 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>
#include "progressloggerinterface.h"
#include "httpget.h"


class BootloaderInstallBase : public QObject
{
    Q_OBJECT

    public:
        enum Capability
            { Install = 0x01, Uninstall = 0x02, Backup = 0x04,
              IsFile = 0x08, IsRaw = 0x10, NeedsFlashing = 0x20,
              CanCheckInstalled = 0x40, CanCheckVersion = 0x80 };
        Q_DECLARE_FLAGS(Capabilities, Capability)

        enum BootloaderType
            { BootloaderNone, BootloaderRockbox, BootloaderOther, BootloaderUnknown };

        BootloaderInstallBase(QObject *parent = 0) : QObject(parent)
            { }

        virtual bool install(void)
            { return false; }
        virtual bool uninstall(void)
            { return false; }
        virtual BootloaderType installed(void);
        virtual Capabilities capabilities(void);
        bool backup(QString to);

        void setBlFile(QString f)
            { m_blfile = f; }
        void setBlUrl(QUrl u)
            { m_blurl = u; }
        void setLogfile(QString f)
            { m_logfile = f; }

        static QString postinstallHints(QString model);

    protected slots:
        void downloadReqFinished(int id, bool error);
        void downloadBlFinish(bool error);
        void installBlfile(void);
    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
        QDateTime m_blversion; //! download timestamp used for version information

    signals:
        void downloadDone(void); //! internal signal sent when download finished.
        void done(bool);
        void logItem(QString, int); //! set logger item
        void logProgress(int, int); //! set progress bar.
};

Q_DECLARE_OPERATORS_FOR_FLAGS(BootloaderInstallBase::Capabilities)

#endif