Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
22 andreas 1
/*
179 andreas 2
 * Copyright (C) 2021, 2022 by Andreas Theofilu <andreas@theosys.at>
22 andreas 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>
122 andreas 22
#include <vector>
120 andreas 23
#include <functional>
22 andreas 24
 
137 andreas 25
#define MAX_TMP_LEN     10
26
 
231 andreas 27
#ifdef __MACH__
28
typedef off_t off64_t;
29
#endif
30
 
22 andreas 31
class TTPInit
32
{
33
    public:
34
        TTPInit(const std::string& path);
51 andreas 35
        TTPInit();
22 andreas 36
 
179 andreas 37
        typedef struct FILELIST_t
38
        {
39
            size_t size;
40
            std::string fname;
41
        }FILELIST_t;
42
 
258 andreas 43
        void setPath(const std::string& p);
51 andreas 44
        bool createDirectoryStructure();
115 andreas 45
        bool loadSurfaceFromController(bool force=false);
179 andreas 46
        std::vector<FILELIST_t>& getFileList(const std::string& filter);
122 andreas 47
        bool isSystemDefault();
48
        bool isVirgin();
159 andreas 49
        bool makeSystemFiles();
156 andreas 50
        bool reinitialize();
51 andreas 51
 
120 andreas 52
        int progressCallback(off64_t xfer);
179 andreas 53
        void setFileSize(off64_t fs) { mFileSize = fs; }
54
        off64_t getFileSize() { return mFileSize; }
208 andreas 55
        off64_t getFileSize(const std::string& file);
120 andreas 56
        void regCallbackProcessEvents(std::function<void ()> pe) { _processEvents = pe; }
179 andreas 57
        void regCallbackProgressBar(std::function<void (int percent)> pb) { _progressBar = pb; }
120 andreas 58
 
259 andreas 59
        static bool haveSystemMarker();
60
 
22 andreas 61
    private:
120 andreas 62
        std::function<void ()> _processEvents{nullptr};
179 andreas 63
        std::function<void (int percent)> _progressBar{nullptr};
120 andreas 64
 
22 andreas 65
        bool createPanelConfigs();
117 andreas 66
        bool createSystemConfigs();
258 andreas 67
        bool createDemoPage();
50 andreas 68
        bool _makeDir(const std::string& dir);
113 andreas 69
        bool copyFile(const std::string& fname);
137 andreas 70
        std::string getTmpFileName();
179 andreas 71
        void logging(int level, const std::string& msg);
43 andreas 72
#ifdef __ANDROID__
73
        bool askPermissions();
74
#endif
22 andreas 75
        std::string mPath;
179 andreas 76
        std::vector<FILELIST_t> mDirList;
77
        off64_t mFileSize{0};
258 andreas 78
        bool mDirStructureCreated{false};
79
        bool mPanelConfigsCreated{false};
80
        bool mSystemConfigsCreated{false};
81
        bool mDemoPageCreated{false};
22 andreas 82
};
83
 
84
#endif // TTPINIT_H