Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* * Common class to get a file content by FTC
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Iuliana Ojog, SLSE, 2017-08-22
|
||||
*/
|
||||
|
||||
#include "flm_get_content.h"
|
||||
|
||||
|
||||
namespace FileManagement
|
||||
{
|
||||
//------------------------------------------------------------------------------------
|
||||
GetFileContent::GetFileContent(const std::shared_ptr<FileManagement::Interface::Ftc> &ftc,
|
||||
QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_ftc(ftc)
|
||||
, m_logger(getLogger("GetFileContent"))
|
||||
{
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
GetFileContent::~GetFileContent()
|
||||
{
|
||||
delete m_requestHelper;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
bool GetFileContent::getContent(int fileContentId, std::vector<uint8_t> &content)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "New Get Content";
|
||||
auto handleContent = [this, &content](const Core::FunctionReply & baseReply)
|
||||
{
|
||||
const GetFileContentDataReply &reply = static_cast<const GetFileContentDataReply &>(baseReply);
|
||||
content = reply.content();
|
||||
DEBUG_LOG(m_logger) << "Content size: " << content.size();
|
||||
};
|
||||
|
||||
auto sendReq = [this, fileContentId]()
|
||||
{
|
||||
GetFileContentDataRequest req;
|
||||
req.fileContentId(fileContentId);
|
||||
return m_ftc->getFileContentDataRequest(req, this);
|
||||
};
|
||||
|
||||
if (!m_requestHelper->startSingleRequest(sendReq, handleContent))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Cannot retrieve file content for id = " << fileContentId;
|
||||
return false;
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "Content size: " << content.size();
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace FileManagement;
|
||||
Reference in new issue
Block a user