Ethan Yonker | 472f506 | 2016-02-25 13:47:30 -0600 | [diff] [blame] | 1 | /* |
| 2 | Copyright 2016 bigbiff/Dees_Troy TeamWin |
| 3 | This file is part of TWRP/TeamWin Recovery Project. |
| 4 | |
| 5 | TWRP is free software: you can redistribute it and/or modify |
| 6 | it under the terms of the GNU General Public License as published by |
| 7 | the Free Software Foundation, either version 3 of the License, or |
| 8 | (at your option) any later version. |
| 9 | |
| 10 | TWRP is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | GNU General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU General Public License |
| 16 | along with TWRP. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | #ifndef __PROGRESSTRACKING_HPP |
| 20 | #define __PROGRESSTRACKING_HPP |
| 21 | |
| 22 | #include <time.h> |
| 23 | |
| 24 | // Progress tracking class for tracking backup progess and updating the progress bar as appropriate |
| 25 | class ProgressTracking |
| 26 | { |
| 27 | public: |
| 28 | ProgressTracking(const unsigned long long backup_size); |
| 29 | |
| 30 | void SetPartitionSize(const unsigned long long part_size); |
| 31 | void SetSizeCount(const unsigned long long part_size, unsigned long long f_count); |
| 32 | |
| 33 | void UpdateSize(const unsigned long long size); |
| 34 | void UpdateSizeCount(const unsigned long long size, const unsigned long long count); |
| 35 | |
| 36 | void DisplayFileCount(const bool display); |
| 37 | void UpdateDisplayDetails(const bool force); |
| 38 | |
| 39 | private: |
| 40 | unsigned long long total_backup_size; // Overall size (for the progress bar) |
| 41 | |
| 42 | unsigned long long partition_size; // Size of the current partition |
| 43 | unsigned long long file_count; // Count of files for the current partition (tar backup only, not restore) |
| 44 | |
| 45 | unsigned long long current_size; // Size of the current partition's already backed up data |
| 46 | unsigned long long current_count; // Count of files that have already been backed up for the current partition |
| 47 | |
| 48 | unsigned long long previous_partitions_size; // Total data already backed up from previous partitions (for the progress bar) |
| 49 | |
| 50 | bool display_file_count; // Inidicates if we will display the file count text |
| 51 | timespec last_update; // Tracks last update of the displayed progress (frequent updates tax the CPU and slow us down) |
| 52 | }; |
| 53 | |
| 54 | #endif //__PROGRESSTRACKING_HPP |