From ea7f3bc72a50cb641c19a4fbf5913f0195629cf7 Mon Sep 17 00:00:00 2001 From: Strider <127.0.0.1@404.com> Date: Sun, 17 May 2020 15:03:49 +0200 Subject: [PATCH] update// implemented reader for addressbook --- src/FileSystem/FileSystem.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/FileSystem/FileSystem.cpp b/src/FileSystem/FileSystem.cpp index 49c8178..d560d98 100644 --- a/src/FileSystem/FileSystem.cpp +++ b/src/FileSystem/FileSystem.cpp @@ -22,6 +22,23 @@ FileSystem* FileSystem::getInstance() QList FileSystem::readContacts(QString file) { return this->readContactsOldFormat(file); //will be called if addresses are in the old dat-format + + QFile _file(file); + if (_file.exists()) + { + std::ifstream f(file.toStdString().c_str(), std::ios::binary); + if(f.is_open()) + { + std::vector buffer(std::istreambuf_iterator(f), {}); + //todo covert to string to use is as json to feed the data store in addressbook + } + + f.close(); + } + else + { + qInfo() << file << "not exist"; + } } void FileSystem::writeContacts(QString file, QString data) @@ -33,6 +50,8 @@ void FileSystem::writeContacts(QString file, QString data) std::ofstream f(file.toStdString().c_str()); if(f.is_open()) { + //ENCRYPT HERE + f << data.toStdString(); }