Subversion Repositories tpanel

Rev

Rev 479 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
446 andreas 1
/*
2
 * Copyright (C) 2021, 2022 by Andreas Theofilu <andreas@theosys.at>
3
 *
4
 * This program is free software; you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation; either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program; if not, write to the Free Software Foundation,
16
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
17
 */
18
#ifndef TTPINIT_H
19
#define TTPINIT_H
20
 
21
#include <string>
22
#include <vector>
23
#include <functional>
24
 
25
#define MAX_TMP_LEN     10
26
 
27
#ifdef __MACH__
28
typedef off_t off64_t;
29
#endif
30
 
31
class TTPInit
32
{
33
    public:
34
        TTPInit(const std::string& path);
35
        TTPInit();
36
 
37
        typedef struct FILELIST_t
38
        {
39
            size_t size;
40
            std::string fname;
41
        }FILELIST_t;
42
 
43
        void setPath(const std::string& p);
44
        bool createDirectoryStructure();
45
        bool loadSurfaceFromController(bool force=false);
46
        std::vector<FILELIST_t>& getFileList(const std::string& filter);
47
        bool isSystemDefault();
48
        bool isVirgin();
49
        bool makeSystemFiles();
50
        bool reinitialize();
51
 
52
        int progressCallback(off64_t xfer);
53
        void setFileSize(off64_t fs) { mFileSize = fs; }
54
        off64_t getFileSize() { return mFileSize; }
55
        off64_t getFileSize(const std::string& file);
56
        void regCallbackProcessEvents(std::function<void ()> pe) { _processEvents = pe; }
57
        void regCallbackProgressBar(std::function<void (int percent)> pb) { _progressBar = pb; }
479 andreas 58
        static void setTP5(bool tp) { mIsTP5 = tp; }
486 andreas 59
        static bool isTP5() { return mIsTP5; }
446 andreas 60
 
61
        static bool haveSystemMarker();
62
 
462 andreas 63
    protected:
64
        bool testForTp5();
65
 
446 andreas 66
    private:
67
        std::function<void ()> _processEvents{nullptr};
68
        std::function<void (int percent)> _progressBar{nullptr};
69
 
70
        bool createPanelConfigs();
71
        bool createSystemConfigs();
72
        bool createDemoPage();
73
        bool _makeDir(const std::string& dir);
74
        bool copyFile(const std::string& fname);
75
        std::string getTmpFileName();
76
        void logging(int level, const std::string& msg);
77
#ifdef __ANDROID__
78
        bool askPermissions();
79
#endif
80
        std::string mPath;
81
        std::vector<FILELIST_t> mDirList;
82
        off64_t mFileSize{0};
83
        bool mDirStructureCreated{false};
84
        bool mPanelConfigsCreated{false};
85
        bool mSystemConfigsCreated{false};
86
        bool mDemoPageCreated{false};
479 andreas 87
        static bool mIsTP5;
446 andreas 88
};
89
 
90
#endif // TTPINIT_H