Subversion Repositories tpanel

Rev

Rev 462 | Go to most recent revision | Details | 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; }
58
 
59
        static bool haveSystemMarker();
60
 
61
    private:
62
        std::function<void ()> _processEvents{nullptr};
63
        std::function<void (int percent)> _progressBar{nullptr};
64
 
65
        bool createPanelConfigs();
66
        bool createSystemConfigs();
67
        bool createDemoPage();
68
        bool _makeDir(const std::string& dir);
69
        bool copyFile(const std::string& fname);
70
        std::string getTmpFileName();
71
        void logging(int level, const std::string& msg);
72
#ifdef __ANDROID__
73
        bool askPermissions();
74
#endif
75
        std::string mPath;
76
        std::vector<FILELIST_t> mDirList;
77
        off64_t mFileSize{0};
78
        bool mDirStructureCreated{false};
79
        bool mPanelConfigsCreated{false};
80
        bool mSystemConfigsCreated{false};
81
        bool mDemoPageCreated{false};
82
};
83
 
84
#endif // TTPINIT_H