[ion] Change Storage design (former kallax)

This commit is contained in:
Émilie Feral
2018-03-02 15:19:35 +01:00
committed by EmilieNumworks
parent 1f351ddbd6
commit b0ede47d55
19 changed files with 475 additions and 421 deletions

View File

@@ -5,13 +5,15 @@
#include <apps/code/app.h>
#include <escher/metric.h>
extern Ion::Storage storage;
namespace Code {
EditorController::EditorController(MenuController * menuController) :
ViewController(nullptr),
m_textArea(this),
m_areaBuffer(nullptr),
m_script(Ion::Record()),
m_script(Ion::Storage::Record()),
m_menuController(menuController)
{
m_textArea.setDelegate(this);
@@ -26,7 +28,7 @@ void EditorController::setScript(Script script) {
m_script = script;
const char * scriptBody = m_script.readContent();
size_t scriptBodySize = strlen(scriptBody)+1;
size_t availableScriptSize = scriptBodySize + Ion::Kallax::sharedKallax()->availableSize();
size_t availableScriptSize = scriptBodySize + storage.availableSize();
assert(m_areaBuffer == nullptr);
m_areaBuffer = new char[availableScriptSize];
strlcpy(m_areaBuffer, scriptBody, scriptBodySize);
@@ -37,7 +39,7 @@ void EditorController::setScript(Script script) {
bool EditorController::handleEvent(Ion::Events::Event event) {
if (event == Ion::Events::OK || event == Ion::Events::Back) {
Script::ErrorStatus err = m_script.writeContent(m_areaBuffer, strlen(m_areaBuffer)+1);
if (err == Script::ErrorStatus::NoEnoughSpaceAvailable) {
if (err == Script::ErrorStatus::NoEnoughSpaceAvailable || err == Script::ErrorStatus::RecordDoesNotExist) {
assert(false); // This should not happen as we set the text area according to the available space in the Kallax
} else {
stackController()->pop();