[DEV] better callback api but error on a mutable and const elements ...
This commit is contained in:
parent
cdfcede4c9
commit
4bfdd57093
@ -310,7 +310,7 @@ class FunctionDefinition:
|
|||||||
else:
|
else:
|
||||||
param_data += elem["name"]
|
param_data += elem["name"]
|
||||||
out += param_data
|
out += param_data
|
||||||
out += ");\n"
|
out += ") const;\n"
|
||||||
return out;
|
return out;
|
||||||
def generate_cpp_proxy(self, space, class_name):
|
def generate_cpp_proxy(self, space, class_name):
|
||||||
out = "";
|
out = "";
|
||||||
@ -327,7 +327,7 @@ class FunctionDefinition:
|
|||||||
else:
|
else:
|
||||||
param_data += elem["name"]
|
param_data += elem["name"]
|
||||||
out += param_data
|
out += param_data
|
||||||
out += ") {\n"
|
out += ") const {\n"
|
||||||
space += " "
|
space += " "
|
||||||
if self.is_action == True:
|
if self.is_action == True:
|
||||||
out += space + 'return m_obj.callAction("' + self.name + '"'
|
out += space + 'return m_obj.callAction("' + self.name + '"'
|
||||||
@ -703,6 +703,7 @@ class ServiceDefinition:
|
|||||||
out += "#include <zeus/RemoteProperty.hpp>\n"
|
out += "#include <zeus/RemoteProperty.hpp>\n"
|
||||||
out += "#include <string>\n"
|
out += "#include <string>\n"
|
||||||
out += "#include <vector>\n"
|
out += "#include <vector>\n"
|
||||||
|
out += "#include <" + self.prop["file_name_class_header"] + ">\n"
|
||||||
for elem in self.imports:
|
for elem in self.imports:
|
||||||
prop = zeus_object_to_dictionary(elem)
|
prop = zeus_object_to_dictionary(elem)
|
||||||
#out += "#include <" + prop["file_name_class_header"] + ">\n"
|
#out += "#include <" + prop["file_name_class_header"] + ">\n"
|
||||||
|
@ -392,14 +392,14 @@ void appl::MediaDecoder::init(ememory::SharedPtr<ClientProperty> _property, uint
|
|||||||
}
|
}
|
||||||
APPL_WARNING("Get File");
|
APPL_WARNING("Get File");
|
||||||
media.getFile().andThen(
|
media.getFile().andThen(
|
||||||
[=](zeus::Future<zeus::ProxyFile> _fut) mutable {
|
[=](const zeus::ProxyFile& _proxy) mutable {
|
||||||
APPL_WARNING("Receive ProxyFile");
|
APPL_WARNING("Receive ProxyFile");
|
||||||
m_remote->m_fileHandle = _fut.get();
|
m_remote->m_fileHandle = _proxy;
|
||||||
APPL_WARNING("We have handle");
|
APPL_WARNING("We have handle");
|
||||||
m_remote->m_fileHandle.getSize().andThen(
|
m_remote->m_fileHandle.getSize().andThen(
|
||||||
[=](zeus::Future<uint64_t> _fut) mutable {
|
[=](const uint64_t& _value) mutable {
|
||||||
APPL_WARNING("Receive FileSize to index property");
|
APPL_WARNING("Receive FileSize to index property");
|
||||||
uint64_t sizeOfBuffer = _fut.get();
|
uint64_t sizeOfBuffer = _value;
|
||||||
APPL_WARNING("pppllloooppp " << sizeOfBuffer);
|
APPL_WARNING("pppllloooppp " << sizeOfBuffer);
|
||||||
m_remote->m_buffer.resize(sizeOfBuffer, 0);
|
m_remote->m_buffer.resize(sizeOfBuffer, 0);
|
||||||
APPL_WARNING("pppllloooppp");
|
APPL_WARNING("pppllloooppp");
|
||||||
@ -501,7 +501,7 @@ int64_t appl::MediaDecoder::seekFunc(int64_t _offset, int _whence) {
|
|||||||
return m_remote->m_bufferReadPosition;
|
return m_remote->m_bufferReadPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool appl::StreamBuffering::addDataCallback(zeus::Future<zeus::Raw> _fut, int64_t _positionRequest) {
|
bool appl::StreamBuffering::addDataCallback(const zeus::Raw& _data, int64_t _positionRequest) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||||
#endif
|
#endif
|
||||||
@ -509,15 +509,10 @@ bool appl::StreamBuffering::addDataCallback(zeus::Future<zeus::Raw> _fut, int64_
|
|||||||
std::unique_lock<std::mutex> lock(m_mutex);
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
bool find = false;
|
bool find = false;
|
||||||
m_callInProgress = false;
|
m_callInProgress = false;
|
||||||
if (_fut.hasError() == true) {
|
|
||||||
APPL_ERROR("Error when loading data (1 MB)");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// TODO : Check buffer size ...
|
// TODO : Check buffer size ...
|
||||||
zeus::Raw buffer = _fut.get();
|
APPL_DEBUG(" ==> receive DATA : " << _positionRequest << " size=" << _data.size());
|
||||||
APPL_DEBUG(" ==> receive DATA : " << _positionRequest << " size=" << buffer.size());
|
|
||||||
// copy data
|
// copy data
|
||||||
memcpy(&m_buffer[_positionRequest], buffer.data(), buffer.size());
|
memcpy(&m_buffer[_positionRequest], _data.data(), _data.size());
|
||||||
// Update the buffer data and positionning
|
// Update the buffer data and positionning
|
||||||
// find if the position correspond at a last positioning:
|
// find if the position correspond at a last positioning:
|
||||||
|
|
||||||
@ -525,20 +520,20 @@ bool appl::StreamBuffering::addDataCallback(zeus::Future<zeus::Raw> _fut, int64_
|
|||||||
while (it != m_bufferFillSection.end()) {
|
while (it != m_bufferFillSection.end()) {
|
||||||
if ( _positionRequest >= it->first
|
if ( _positionRequest >= it->first
|
||||||
&& _positionRequest < it->second) {
|
&& _positionRequest < it->second) {
|
||||||
if (_positionRequest + buffer.size() > it->second){
|
if (_positionRequest + _data.size() > it->second){
|
||||||
it->second = _positionRequest + buffer.size();
|
it->second = _positionRequest + _data.size();
|
||||||
}
|
}
|
||||||
find = true;
|
find = true;
|
||||||
break;
|
break;
|
||||||
} else if (it->second == _positionRequest) {
|
} else if (it->second == _positionRequest) {
|
||||||
it->second += buffer.size();
|
it->second += _data.size();
|
||||||
find = true;
|
find = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
auto it2 = it;
|
auto it2 = it;
|
||||||
++it2;
|
++it2;
|
||||||
if ( it2 != m_bufferFillSection.end()
|
if ( it2 != m_bufferFillSection.end()
|
||||||
&& _positionRequest + buffer.size() >= it2->first) {
|
&& _positionRequest + _data.size() >= it2->first) {
|
||||||
it2->first = _positionRequest;
|
it2->first = _positionRequest;
|
||||||
find = true;
|
find = true;
|
||||||
break;
|
break;
|
||||||
@ -550,7 +545,7 @@ bool appl::StreamBuffering::addDataCallback(zeus::Future<zeus::Raw> _fut, int64_
|
|||||||
}
|
}
|
||||||
if (find == false) {
|
if (find == false) {
|
||||||
APPL_ERROR("insert new element in the list of values");
|
APPL_ERROR("insert new element in the list of values");
|
||||||
m_bufferFillSection.insert(it, std::pair<uint32_t,uint32_t>(_positionRequest, _positionRequest + buffer.size()));
|
m_bufferFillSection.insert(it, std::pair<uint32_t,uint32_t>(_positionRequest, _positionRequest + _data.size()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
checkIfWeNeedMoreDataFromNetwork();
|
checkIfWeNeedMoreDataFromNetwork();
|
||||||
@ -625,8 +620,8 @@ void appl::StreamBuffering::checkIfWeNeedMoreDataFromNetwork() {
|
|||||||
APPL_DEBUG("Request DATA: " << it->second << " size=" << sizeRequest);
|
APPL_DEBUG("Request DATA: " << it->second << " size=" << sizeRequest);
|
||||||
auto futData = m_fileHandle.getPart(it->second, it->second + sizeRequest);
|
auto futData = m_fileHandle.getPart(it->second, it->second + sizeRequest);
|
||||||
auto localShared = ememory::dynamicPointerCast<appl::StreamBuffering>(sharedFromThis());
|
auto localShared = ememory::dynamicPointerCast<appl::StreamBuffering>(sharedFromThis());
|
||||||
futData.andThen([=](zeus::Future<zeus::Raw> _fut) mutable {
|
futData.andThen([=](const zeus::Raw& _value) mutable {
|
||||||
return localShared->addDataCallback(_fut, it->second);
|
return localShared->addDataCallback(_value, it->second);
|
||||||
});
|
});
|
||||||
m_callInProgress = true;
|
m_callInProgress = true;
|
||||||
}
|
}
|
||||||
@ -643,8 +638,8 @@ void appl::StreamBuffering::checkIfWeNeedMoreDataFromNetwork() {
|
|||||||
APPL_DEBUG("Request DATA : " << m_bufferReadPosition << " size=" << sizeRequest);
|
APPL_DEBUG("Request DATA : " << m_bufferReadPosition << " size=" << sizeRequest);
|
||||||
auto futData = m_fileHandle.getPart(m_bufferReadPosition, m_bufferReadPosition+sizeRequest);
|
auto futData = m_fileHandle.getPart(m_bufferReadPosition, m_bufferReadPosition+sizeRequest);
|
||||||
auto localShared = ememory::dynamicPointerCast<appl::StreamBuffering>(sharedFromThis());
|
auto localShared = ememory::dynamicPointerCast<appl::StreamBuffering>(sharedFromThis());
|
||||||
futData.andThen([=](zeus::Future<zeus::Raw> _fut) mutable {
|
futData.andThen([=](const zeus::Raw& _value) mutable {
|
||||||
return localShared->addDataCallback(_fut, m_bufferReadPosition);
|
return localShared->addDataCallback(_value, m_bufferReadPosition);
|
||||||
});
|
});
|
||||||
m_callInProgress = true;
|
m_callInProgress = true;
|
||||||
// nothing more to do ...
|
// nothing more to do ...
|
||||||
@ -665,8 +660,8 @@ void appl::StreamBuffering::checkIfWeNeedMoreDataFromNetwork() {
|
|||||||
APPL_DEBUG("Request DATA : " << m_bufferReadPosition << " size=" << sizeRequest);
|
APPL_DEBUG("Request DATA : " << m_bufferReadPosition << " size=" << sizeRequest);
|
||||||
auto futData = m_fileHandle.getPart(m_bufferReadPosition, m_bufferReadPosition + sizeRequest);
|
auto futData = m_fileHandle.getPart(m_bufferReadPosition, m_bufferReadPosition + sizeRequest);
|
||||||
auto localShared = ememory::dynamicPointerCast<appl::StreamBuffering>(sharedFromThis());
|
auto localShared = ememory::dynamicPointerCast<appl::StreamBuffering>(sharedFromThis());
|
||||||
futData.andThen([=](zeus::Future<zeus::Raw> _fut) mutable {
|
futData.andThen([=](const zeus::Raw& _value) mutable {
|
||||||
return localShared->addDataCallback(_fut, m_bufferReadPosition);
|
return localShared->addDataCallback(_value, m_bufferReadPosition);
|
||||||
});
|
});
|
||||||
m_callInProgress = true;
|
m_callInProgress = true;
|
||||||
if (find == false) {
|
if (find == false) {
|
||||||
|
@ -69,7 +69,7 @@ namespace appl {
|
|||||||
bool m_callInProgress;
|
bool m_callInProgress;
|
||||||
bool m_stopRequested;
|
bool m_stopRequested;
|
||||||
public:
|
public:
|
||||||
bool addDataCallback(zeus::Future<zeus::Raw> _fut, int64_t _positionRequest);
|
bool addDataCallback(const zeus::Raw& _data, int64_t _positionRequest);
|
||||||
void checkIfWeNeedMoreDataFromNetwork();
|
void checkIfWeNeedMoreDataFromNetwork();
|
||||||
uint64_t getSize() {
|
uint64_t getSize() {
|
||||||
std::unique_lock<std::mutex> lock(m_mutex);
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
|
@ -79,32 +79,31 @@ void appl::ElementProperty::loadData() {
|
|||||||
auto tmpProperty = sharedFromThis();
|
auto tmpProperty = sharedFromThis();
|
||||||
// Get the media
|
// Get the media
|
||||||
zeus::Future<zeus::ProxyMedia> futMedia = m_remoteServiceVideo.get(m_id);
|
zeus::Future<zeus::ProxyMedia> futMedia = m_remoteServiceVideo.get(m_id);
|
||||||
futMedia.andElse([=](zeus::Future<zeus::ProxyMedia> _fut) mutable {
|
futMedia.andElse([=](const std::string& _error, const std::string& _help) mutable {
|
||||||
APPL_INFO(" [" << tmpProperty->m_id << "] get media error: " << tmpProperty->m_id);
|
APPL_INFO(" [" << tmpProperty->m_id << "] get media error: " << tmpProperty->m_id);
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
||||||
tmpProperty->m_title = "[ERROR] can not get media informations <br/>" + _fut.getErrorType() + ": " + _fut.getErrorHelp();
|
tmpProperty->m_title = "[ERROR] can not get media informations <br/>" + _error + ": " + _help;
|
||||||
tmpProperty->m_metadataUpdated = appl::statusLoadingData::done;
|
tmpProperty->m_metadataUpdated = appl::statusLoadingData::done;
|
||||||
}
|
}
|
||||||
m_widget->markToRedraw();
|
m_widget->markToRedraw();
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
futMedia.andThen([=](zeus::Future<zeus::ProxyMedia> _fut) mutable {
|
futMedia.andThen([=](const zeus::ProxyMedia& _media) mutable {
|
||||||
APPL_INFO(" [" << tmpProperty->m_id << "] get media: " << tmpProperty->m_id);
|
APPL_INFO(" [" << tmpProperty->m_id << "] get media: " << tmpProperty->m_id);
|
||||||
zeus::ProxyMedia media = _fut.get();
|
if (_media.exist() == false) {
|
||||||
if (media.exist() == false) {
|
|
||||||
APPL_ERROR("get media error");
|
APPL_ERROR("get media error");
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
||||||
tmpProperty->m_title = "[ERROR] can not get media informations (2)<br/>" + _fut.getErrorType() + ": " + _fut.getErrorHelp();
|
tmpProperty->m_title = "[ERROR] can not get media informations (2)";
|
||||||
tmpProperty->m_metadataUpdated = appl::statusLoadingData::done;
|
tmpProperty->m_metadataUpdated = appl::statusLoadingData::done;
|
||||||
}
|
}
|
||||||
m_widget->markToRedraw();
|
m_widget->markToRedraw();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
media.getMetadata("title")
|
_media.getMetadata("title")
|
||||||
.andElse([=](zeus::Future<std::string> _fut) mutable {
|
.andElse([=](const std::string& _error, const std::string& _help) mutable {
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
||||||
tmpProperty->m_nbElementLoaded++;
|
tmpProperty->m_nbElementLoaded++;
|
||||||
@ -114,11 +113,11 @@ void appl::ElementProperty::loadData() {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
.andThen([=](zeus::Future<std::string> _fut) mutable {
|
.andThen([=](const std::string& _value) mutable {
|
||||||
APPL_INFO(" [" << tmpProperty->m_id << "] get title: " << _fut.get());
|
APPL_INFO(" [" << tmpProperty->m_id << "] get title: " << _value);
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
||||||
tmpProperty->m_title = _fut.get();
|
tmpProperty->m_title = _value;
|
||||||
}
|
}
|
||||||
m_widget->markToRedraw();
|
m_widget->markToRedraw();
|
||||||
{
|
{
|
||||||
@ -130,8 +129,8 @@ void appl::ElementProperty::loadData() {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
media.getMetadata("series-name")
|
_media.getMetadata("series-name")
|
||||||
.andElse([=](zeus::Future<std::string> _fut) mutable {
|
.andElse([=](const std::string& _error, const std::string& _help) mutable {
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
||||||
tmpProperty->m_nbElementLoaded++;
|
tmpProperty->m_nbElementLoaded++;
|
||||||
@ -141,11 +140,11 @@ void appl::ElementProperty::loadData() {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
.andThen([=](zeus::Future<std::string> _fut) mutable {
|
.andThen([=](const std::string& _value) mutable {
|
||||||
APPL_ERROR(" [" << tmpProperty->m_id << "] get serie: " << _fut.get());
|
APPL_ERROR(" [" << tmpProperty->m_id << "] get serie: " << _value);
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
||||||
tmpProperty->m_serie = _fut.get();
|
tmpProperty->m_serie = _value;
|
||||||
}
|
}
|
||||||
m_widget->markToRedraw();
|
m_widget->markToRedraw();
|
||||||
{
|
{
|
||||||
@ -157,8 +156,8 @@ void appl::ElementProperty::loadData() {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
media.getMetadata("saison")
|
_media.getMetadata("saison")
|
||||||
.andElse([=](zeus::Future<std::string> _fut) mutable {
|
.andElse([=](const std::string& _error, const std::string& _help) mutable {
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
||||||
tmpProperty->m_nbElementLoaded++;
|
tmpProperty->m_nbElementLoaded++;
|
||||||
@ -168,11 +167,11 @@ void appl::ElementProperty::loadData() {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
.andThen([=](zeus::Future<std::string> _fut) mutable {
|
.andThen([=](const std::string& _value) mutable {
|
||||||
APPL_INFO(" [" << tmpProperty->m_id << "] get saison: " << _fut.get());
|
APPL_INFO(" [" << tmpProperty->m_id << "] get saison: " << _value);
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
||||||
tmpProperty->m_saison = _fut.get();
|
tmpProperty->m_saison = _value;
|
||||||
}
|
}
|
||||||
m_widget->markToRedraw();
|
m_widget->markToRedraw();
|
||||||
{
|
{
|
||||||
@ -184,8 +183,8 @@ void appl::ElementProperty::loadData() {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
media.getMetadata("episode")
|
_media.getMetadata("episode")
|
||||||
.andElse([=](zeus::Future<std::string> _fut) mutable {
|
.andElse([=](const std::string& _error, const std::string& _help) mutable {
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
||||||
tmpProperty->m_nbElementLoaded++;
|
tmpProperty->m_nbElementLoaded++;
|
||||||
@ -195,11 +194,11 @@ void appl::ElementProperty::loadData() {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
.andThen([=](zeus::Future<std::string> _fut) mutable {
|
.andThen([=](const std::string& _value) mutable {
|
||||||
APPL_INFO(" [" << tmpProperty->m_id << "] get episode: " << _fut.get());
|
APPL_INFO(" [" << tmpProperty->m_id << "] get episode: " << _value);
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
||||||
tmpProperty->m_episode = _fut.get();
|
tmpProperty->m_episode = _value;
|
||||||
}
|
}
|
||||||
m_widget->markToRedraw();
|
m_widget->markToRedraw();
|
||||||
{
|
{
|
||||||
@ -211,8 +210,8 @@ void appl::ElementProperty::loadData() {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
media.getMetadata("description")
|
_media.getMetadata("description")
|
||||||
.andElse([=](zeus::Future<std::string> _fut) mutable {
|
.andElse([=](const std::string& _error, const std::string& _help) mutable {
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
||||||
tmpProperty->m_nbElementLoaded++;
|
tmpProperty->m_nbElementLoaded++;
|
||||||
@ -222,11 +221,11 @@ void appl::ElementProperty::loadData() {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
.andThen([=](zeus::Future<std::string> _fut) mutable {
|
.andThen([=](const std::string& _value) mutable {
|
||||||
APPL_INFO(" [" << tmpProperty->m_id << "] get description: " << _fut.get());
|
APPL_INFO(" [" << tmpProperty->m_id << "] get description: " << _value);
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
||||||
tmpProperty->m_description = _fut.get();
|
tmpProperty->m_description = _value;
|
||||||
}
|
}
|
||||||
m_widget->markToRedraw();
|
m_widget->markToRedraw();
|
||||||
{
|
{
|
||||||
@ -238,8 +237,8 @@ void appl::ElementProperty::loadData() {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
media.getMetadata("production-methode")
|
_media.getMetadata("production-methode")
|
||||||
.andElse([=](zeus::Future<std::string> _fut) mutable {
|
.andElse([=](const std::string& _error, const std::string& _help) mutable {
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
||||||
tmpProperty->m_nbElementLoaded++;
|
tmpProperty->m_nbElementLoaded++;
|
||||||
@ -249,11 +248,11 @@ void appl::ElementProperty::loadData() {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
.andThen([=](zeus::Future<std::string> _fut) mutable {
|
.andThen([=](const std::string& _value) mutable {
|
||||||
APPL_INFO(" [" << tmpProperty->m_id << "] get production-methode: " << _fut.get());
|
APPL_INFO(" [" << tmpProperty->m_id << "] get production-methode: " << _value);
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
||||||
tmpProperty->m_productMethode = _fut.get();
|
tmpProperty->m_productMethode = _value;
|
||||||
}
|
}
|
||||||
m_widget->markToRedraw();
|
m_widget->markToRedraw();
|
||||||
{
|
{
|
||||||
@ -265,8 +264,8 @@ void appl::ElementProperty::loadData() {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
media.getMetadata("type")
|
_media.getMetadata("type")
|
||||||
.andElse([=](zeus::Future<std::string> _fut) mutable {
|
.andElse([=](const std::string& _error, const std::string& _help) mutable {
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
||||||
tmpProperty->m_nbElementLoaded++;
|
tmpProperty->m_nbElementLoaded++;
|
||||||
@ -276,11 +275,11 @@ void appl::ElementProperty::loadData() {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
.andThen([=](zeus::Future<std::string> _fut) mutable {
|
.andThen([=](const std::string& _value) mutable {
|
||||||
APPL_INFO(" [" << tmpProperty->m_id << "] get type: " << _fut.get());
|
APPL_INFO(" [" << tmpProperty->m_id << "] get type: " << _value);
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
||||||
tmpProperty->m_type = _fut.get();
|
tmpProperty->m_type = _value;
|
||||||
}
|
}
|
||||||
m_widget->markToRedraw();
|
m_widget->markToRedraw();
|
||||||
{
|
{
|
||||||
@ -292,8 +291,8 @@ void appl::ElementProperty::loadData() {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
media.getMineType()
|
_media.getMineType()
|
||||||
.andElse([=](zeus::Future<std::string> _fut) mutable {
|
.andElse([=](const std::string& _error, const std::string& _help) mutable {
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
||||||
tmpProperty->m_nbElementLoaded++;
|
tmpProperty->m_nbElementLoaded++;
|
||||||
@ -303,11 +302,11 @@ void appl::ElementProperty::loadData() {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
.andThen([=](zeus::Future<std::string> _fut) mutable {
|
.andThen([=](const std::string& _value) mutable {
|
||||||
APPL_INFO(" [" << tmpProperty->m_id << "] get mine-type: " << _fut.get());
|
APPL_INFO(" [" << tmpProperty->m_id << "] get mine-type: " << _value);
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
std::unique_lock<std::mutex> lock(tmpProperty->m_mutex);
|
||||||
tmpProperty->m_mineType = _fut.get();
|
tmpProperty->m_mineType = _value;
|
||||||
if (etk::start_with(tmpProperty->m_mineType, "video") == true) {
|
if (etk::start_with(tmpProperty->m_mineType, "video") == true) {
|
||||||
// TODO : Optimise this ...
|
// TODO : Optimise this ...
|
||||||
tmpProperty->m_thumb = egami::load("DATA:Video.svg", ivec2(128,128));
|
tmpProperty->m_thumb = egami::load("DATA:Video.svg", ivec2(128,128));
|
||||||
|
@ -6,9 +6,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <zeus/debug.hpp>
|
#include <zeus/debug.hpp>
|
||||||
#include <zeus/message/ParamType.hpp>
|
#include <zeus/message/ParamType.hpp>
|
||||||
#include <zeus/File.hpp>
|
|
||||||
#include <zeus/message/Message.hpp>
|
#include <zeus/message/Message.hpp>
|
||||||
#include <zeus/message/Call.hpp>
|
#include <zeus/message/Call.hpp>
|
||||||
|
#include <zeus/Raw.hpp>
|
||||||
#include <ememory/memory.hpp>
|
#include <ememory/memory.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ namespace zeus {
|
|||||||
|
|
||||||
void notify(const std::string& _value) {
|
void notify(const std::string& _value) {
|
||||||
if (m_interface != nullptr) {
|
if (m_interface != nullptr) {
|
||||||
m_interface->answerValue(m_transactionId, m_source, m_destination, _value);
|
m_interface->progressNotify(m_transactionId, m_source, m_destination, _value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -85,6 +85,14 @@ namespace zeus {
|
|||||||
});
|
});
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
Future<ZEUS_RETURN>& andThen(std::function<bool(const ZEUS_RETURN&)> _callback) {
|
||||||
|
zeus::FutureBase::andThen(
|
||||||
|
[=](zeus::FutureBase _fut) {
|
||||||
|
zeus::Future<ZEUS_RETURN> tmp(_fut);
|
||||||
|
return _callback(tmp.get());
|
||||||
|
});
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Attach callback on a specific return action (ERROR)
|
* @brief Attach callback on a specific return action (ERROR)
|
||||||
* @param[in] _callback Handle on the function to call in case of error on the call
|
* @param[in] _callback Handle on the function to call in case of error on the call
|
||||||
@ -96,6 +104,13 @@ namespace zeus {
|
|||||||
});
|
});
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
Future<ZEUS_RETURN>& andElse(std::function<bool(const std::string&, const std::string&)> _callback) {
|
||||||
|
zeus::FutureBase::andElse(
|
||||||
|
[=](zeus::FutureBase _fut) {
|
||||||
|
return _callback(_fut.getErrorType(), _fut.getErrorHelp());
|
||||||
|
});
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Attach callback on activity of the action if user set some return information
|
* @brief Attach callback on activity of the action if user set some return information
|
||||||
* @param[in] _callback Handle on the function to call in progress information
|
* @param[in] _callback Handle on the function to call in progress information
|
||||||
|
@ -85,7 +85,7 @@ namespace zeus {
|
|||||||
*/
|
*/
|
||||||
class ObjectRemote {
|
class ObjectRemote {
|
||||||
private:
|
private:
|
||||||
ememory::SharedPtr<zeus::ObjectRemoteBase> m_interface;
|
mutable ememory::SharedPtr<zeus::ObjectRemoteBase> m_interface;
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
@ -113,7 +113,7 @@ namespace zeus {
|
|||||||
* @return A generic future with all datas
|
* @return A generic future with all datas
|
||||||
*/
|
*/
|
||||||
template<class... _ARGS>
|
template<class... _ARGS>
|
||||||
zeus::FutureBase call(const std::string& _functionName, _ARGS&&... _args) {
|
zeus::FutureBase call(const std::string& _functionName, _ARGS&&... _args) const {
|
||||||
if ( m_interface == nullptr
|
if ( m_interface == nullptr
|
||||||
|| m_interface->m_interfaceWeb == nullptr) {
|
|| m_interface->m_interfaceWeb == nullptr) {
|
||||||
ememory::SharedPtr<zeus::message::Answer> ret = zeus::message::Answer::create(nullptr); // TODO : This is a real bad case ...
|
ememory::SharedPtr<zeus::message::Answer> ret = zeus::message::Answer::create(nullptr); // TODO : This is a real bad case ...
|
||||||
@ -133,7 +133,7 @@ namespace zeus {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
template<class... _ARGS>
|
template<class... _ARGS>
|
||||||
zeus::FutureBase callAction(const std::string& _functionName, _ARGS&&... _args) {
|
zeus::FutureBase callAction(const std::string& _functionName, _ARGS&&... _args) const {
|
||||||
zeus::FutureBase tmp = call(_functionName, _args...);
|
zeus::FutureBase tmp = call(_functionName, _args...);
|
||||||
tmp.setAction();
|
tmp.setAction();
|
||||||
return tmp;
|
return tmp;
|
||||||
|
@ -120,10 +120,10 @@ zeus::Raw zeus::FileImpl::getPart(uint64_t _start, uint64_t _stop) {
|
|||||||
|
|
||||||
std::string zeus::storeInFile(zeus::ProxyFile _file, std::string _filename) {
|
std::string zeus::storeInFile(zeus::ProxyFile _file, std::string _filename) {
|
||||||
zeus::ActionNotification tmp;
|
zeus::ActionNotification tmp;
|
||||||
return zeus::storeInFile(_file, _filename, tmp);
|
return zeus::storeInFileNotify(_file, _filename, tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string zeus::storeInFile(zeus::ProxyFile _file, std::string _filename, zeus::ActionNotification _notification) {
|
std::string zeus::storeInFileNotify(zeus::ProxyFile _file, std::string _filename, zeus::ActionNotification _notification) {
|
||||||
auto futSize = _file.getSize();
|
auto futSize = _file.getSize();
|
||||||
auto futSha = _file.getSha512();
|
auto futSha = _file.getSha512();
|
||||||
futSize.wait();
|
futSize.wait();
|
||||||
@ -150,7 +150,7 @@ std::string zeus::storeInFile(zeus::ProxyFile _file, std::string _filename, zeus
|
|||||||
offset += nbElement;
|
offset += nbElement;
|
||||||
retSize -= nbElement;
|
retSize -= nbElement;
|
||||||
ZEUS_VERBOSE("read: " << offset << "/" << futSize.get() << " " << buffer.size());
|
ZEUS_VERBOSE("read: " << offset << "/" << futSize.get() << " " << buffer.size());
|
||||||
"{\"pourcent\":" + etk::to_string(float(offset)/float(buffer.size())) + ", \"comment\":\"download\""
|
_notification.notify("{\"pourcent\":" + etk::to_string(float(offset)/float(buffer.size())) + ", \"comment\":\"download\"");
|
||||||
}
|
}
|
||||||
nodeFile.fileClose();
|
nodeFile.fileClose();
|
||||||
// get the final sha512 of the file:
|
// get the final sha512 of the file:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user