2017-01-16 03:40:17 -05:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
|
|
|
* Copyright (C) 2016 Furrtek
|
|
|
|
*
|
|
|
|
* This file is part of PortaPack.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; see the file COPYING. If not, write to
|
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ui_sd_wipe.hpp"
|
|
|
|
|
|
|
|
namespace ui {
|
|
|
|
|
2023-05-18 16:16:05 -04:00
|
|
|
Thread* WipeSDView::thread{nullptr};
|
|
|
|
|
|
|
|
WipeSDView::WipeSDView(NavigationView& nav)
|
|
|
|
: nav_(nav) {
|
|
|
|
add_children({&text_info,
|
|
|
|
&progress,
|
|
|
|
&dummy});
|
2017-01-16 03:40:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
WipeSDView::~WipeSDView() {
|
2023-05-18 16:16:05 -04:00
|
|
|
if (thread)
|
|
|
|
chThdTerminate(thread);
|
2017-01-16 03:40:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void WipeSDView::focus() {
|
2023-05-18 16:16:05 -04:00
|
|
|
BlockDeviceInfo block_device_info;
|
|
|
|
|
|
|
|
dummy.focus();
|
|
|
|
|
|
|
|
if (!confirmed) {
|
2023-09-27 15:03:02 -04:00
|
|
|
nav_.push<ModalMessageView>(
|
|
|
|
"Warning !",
|
|
|
|
"Wipe FAT of SD card?",
|
|
|
|
YESNO,
|
|
|
|
[this](bool choice) {
|
|
|
|
if (choice)
|
|
|
|
confirmed = true;
|
|
|
|
else
|
|
|
|
nav_.pop(false); // Pop w/o update so the modal will pop off the app.
|
|
|
|
});
|
2023-05-18 16:16:05 -04:00
|
|
|
} else {
|
|
|
|
if (sdcGetInfo(&SDCD1, &block_device_info) == CH_SUCCESS) {
|
|
|
|
thread = chThdCreateFromHeap(NULL, 2048, NORMALPRIO, WipeSDView::static_fn, this);
|
|
|
|
} else {
|
2023-09-27 15:03:02 -04:00
|
|
|
nav_.pop(); // Just silently abort for now.
|
2023-05-18 16:16:05 -04:00
|
|
|
}
|
|
|
|
}
|
2017-01-16 03:40:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
} /* namespace ui */
|