#include <klay/filesystem.h>
#include <klay/audit/logger.h>
-#include "rmi/secure-erase.h"
-#include "progress-bar.h"
-#include "progress-vconf-backend.h"
-#include "block-device.h"
#include "ext4-tool.h"
+#include "block-device.h"
+#include "progress-bar.h"
+#include "rmi/secure-erase.h"
+
+#define PRIVILEGE_PLATFORM "http://tizen.org/privilege/internal/default/platform"
namespace ode {
namespace {
-VConfBackend vconfBackend(VCONFKEY_ODE_ERASE_PROGRESS);
-ProgressBar progressBar(std::bind(&VConfBackend::update, &vconfBackend, std::placeholders::_1));
+
+std::unique_ptr<ProgressBar> progressBar;
static int totalFileCount = 0;
static int erasedFileCount = 0;
SecureErase::SecureErase(ODEControlContext &ctx) :
context(ctx), devicePath("")
{
- context.registerParametricMethod(this, "", (int)(SecureErase::erase)(std::string));
- context.registerParametricMethod(this, "", (int)(SecureErase::clean)(std::string));
+ context.expose(this, PRIVILEGE_PLATFORM, (int)(SecureErase::erase)(std::string));
+ context.expose(this, PRIVILEGE_PLATFORM, (int)(SecureErase::clean)(std::string));
+
+ progressBar.reset(new ProgressBar([](int v) {
+ ::vconf_set_str(VCONFKEY_ODE_ERASE_PROGRESS, std::to_string(v).c_str());
+ }));
}
SecureErase::~SecureErase()
for (unsigned int i = 0; i < totalBlock; i++) {
Block block(i * blockSize, blockSize);
blockDevice.discard(block);
- progressBar.update(i, totalBlock, 1);
+ progressBar->update(i, totalBlock, 1);
}
}
dropCachePage();
- progressBar.done();
+ progressBar->done();
} catch (runtime::Exception &e) {}
};
blockDevice.discard(block);
}
- progressBar.update(i, totalBlock, 1);
+ progressBar->update(i, totalBlock, 1);
}
dropCachePage();
- progressBar.done();
+ progressBar->done();
} catch (runtime::Exception &e) {}
};
}
if (totalFileCount == 1) {
- progressBar.update(i, extentBlockCount, 1);
+ progressBar->update(i, extentBlockCount, 1);
}
}
fileErase(next);
::remove(next.c_str());
erasedFileCount++;
- progressBar.update(erasedFileCount, totalFileCount, 1);
+ progressBar->update(erasedFileCount, totalFileCount, 1);
} else if (file.isDirectory()) {
directoryErase(next);
}