Compare commits

...

5 Commits

56 changed files with 413 additions and 332 deletions

View File

@ -68,7 +68,13 @@ Start the service:
systemctl start zeus-router.service
Run some command tools:
=======================
Access to the video backend:
```
lutin -cclang -mdebug zeus-package-base?run%zeus-cli-video:--login=HeeroYui:--pass=plop:list
```
License (MPL v2.0)

View File

@ -1,5 +1,5 @@
#!/usr/bin/python
import lutin.debug as debug
import realog.debug as debug
import lutin.tools as tools
import os
import copy
@ -8,6 +8,8 @@ list_of_known_type = [
["void", "void"],
["bool", "bool"],
["string", "etk::String"],
["uri", "etk::Uri"],
["path", "etk::Path"],
["int8", "int8_t"],
["int16", "int16_t"],
["int32", "int32_t"],
@ -439,6 +441,7 @@ class ServiceDefinition:
out += "#include <etk/types.hpp>\n"
out += "#include <eproperty/Value.hpp>\n"
out += "#include <zeus/Raw.hpp>\n"
out += "#include <etk/uri/uri.hpp>\n"
out += "#include <etk/String.hpp>\n"
out += "#include <etk/Vector.hpp>\n"
out += "#include <ememory/memory.hpp>\n"
@ -520,7 +523,7 @@ class ServiceDefinition:
out += "#include <etk/stdTools.hpp>\n"
out += "#include <zeus/AbstractFunction.hpp>\n"
out += "#include <climits>\n"
out += "#include <etk/os/FSNode.hpp>\n"
out += "#include <etk/path/fileSystem.hpp>\n"
out += "#include <zeus/WebServer.hpp>\n"
out += "#include <zeus/Object.hpp>\n"
out += "\n"

View File

@ -1,5 +1,5 @@
#!/usr/bin/python
import lutin.debug as debug
import realog.debug as debug
import lutin.tools as tools
import lutin.macro as macro

View File

@ -10,7 +10,7 @@
#include <zeus/mineType.hpp>
#include <etk/etk.hpp>
#include <zeus/zeus.hpp>
#include <etk/os/FSNode.hpp>
#include <etk/uri/uri.hpp>
#include <elog/elog.hpp>
@ -23,7 +23,6 @@
int main(int _argc, const char *_argv[]) {
etk::init(_argc, _argv);
elog::init(_argc, _argv);
zeus::init(_argc, _argv);
zeus::Client client1;
etk::String fromUser = "test1";

View File

@ -1,5 +1,5 @@
#!/usr/bin/python
import lutin.debug as debug
import realog.debug as debug
import lutin.tools as tools

View File

@ -13,7 +13,6 @@
#include <ethread/Mutex.hpp>
#include <ejson/ejson.hpp>
#include <etk/os/FSNode.hpp>
#include <sstream>
#include <etk/stdTools.hpp>
@ -25,7 +24,7 @@
#include <zeus/zeus-Media.impl.hpp>
static ethread::Mutex g_mutex;
static etk::String g_basePath;
static etk::Uri g_basePath;
static etk::String g_baseDBName = etk::String(SERVICE_NAME) + "-database.json";
static etk::Vector<ememory::SharedPtr<zeus::MediaImpl>> m_listFile;
@ -80,21 +79,21 @@ static void store_db() {
ejson::Document database;
ejson::Array listFilesArray;
database.add("baseValue", ejson::String("plop"));
bool retGenerate = database.storeSafe(g_basePath + g_baseDBName);
APPL_INFO("Store database [STOP] : " << (g_basePath + g_baseDBName) << " ret = " << retGenerate);
bool retGenerate = database.storeSafe(g_basePath / g_baseDBName);
APPL_INFO("Store database [STOP] : " << (g_basePath / g_baseDBName) << " ret = " << retGenerate);
g_needToStore = false;
}
static void load_db() {
ejson::Document database;
bool ret = database.load(g_basePath + g_baseDBName);
bool ret = database.load(g_basePath / g_baseDBName);
if (ret == false) {
APPL_WARNING(" ==> LOAD error");
}
g_needToStore = false;
}
ETK_EXPORT_API bool SERVICE_IO_init(int _argc, const char *_argv[], etk::String _basePath) {
ETK_EXPORT_API bool SERVICE_IO_init(int _argc, const char *_argv[], etk::Uri _basePath) {
g_basePath = _basePath;
ethread::UniqueLock lock(g_mutex);
APPL_INFO("Load USER: " << g_basePath);

View File

@ -1,5 +1,5 @@
#!/usr/bin/python
import lutin.debug as debug
import realog.debug as debug
import lutin.tools as tools

View File

@ -1,5 +1,5 @@
#!/usr/bin/python
import lutin.debug as debug
import realog.debug as debug
import lutin.tools as tools
import lutin.macro as macro

View File

@ -1,5 +1,5 @@
#!/usr/bin/python
import lutin.debug as debug
import realog.debug as debug
import lutin.tools as tools

View File

@ -10,7 +10,9 @@
#include <zeus/mineType.hpp>
#include <etk/etk.hpp>
#include <zeus/zeus.hpp>
#include <etk/os/FSNode.hpp>
#include <etk/path/fileSystem.hpp>
#include <etk/io/File.hpp>
#include <elog/elog.hpp>
#include <algorithm>
@ -52,13 +54,9 @@ bool progressCall(const etk::String& _value) {
void progressCallback(const etk::String& _value) {
APPL_PRINT("plop " << _value);
}
bool pushVideoFile(zeus::service::ProxyVideo& _srv, etk::String _path, etk::Map<etk::String,etk::String> _basicKey = etk::Map<etk::String,etk::String>()) {
etk::String extention;
if ( _path.rfind('.') != etk::String::npos
&& _path.rfind('.') != 0) {
extention = etk::toLower(etk::String(_path.begin()+_path.rfind('.')+1, _path.end()));
}
etk::String fileName = etk::split(_path, '/').back();
bool pushVideoFile(zeus::service::ProxyVideo& _srv, etk::Path _path, etk::Map<etk::String,etk::String> _basicKey = etk::Map<etk::String,etk::String>()) {
etk::String extention = _path.getExtention().toLower();
etk::String fileName = _path.getFileName();
// internal extention ...
if (extention == "sha512") {
return true;
@ -92,19 +90,26 @@ bool pushVideoFile(zeus::service::ProxyVideo& _srv, etk::String _path, etk::Map<
if (_basicKey["saison"] != "") {
groupName += ":" + _basicKey["saison"];
}
auto sending = _srv.setGroupCover(zeus::File::create(_path, ""), groupName);
auto sending = _srv.setGroupCover(zeus::File::create(_path.getString(), ""), groupName);
sending.onSignal(progressCallback);
sending.waitFor(echrono::seconds(20000));
return true;
}
etk::String storedSha512;
if (etk::FSNodeExist(_path + ".sha512") == true) {
uint64_t time_sha512 = etk::FSNodeGetTimeModified(_path + ".sha512");
uint64_t time_elem = etk::FSNodeGetTimeModified(_path);
etk::String storedSha512_file = etk::FSNodeReadAllData(_path + ".sha512");
if (etk::path::exist(_path + ".sha512") == true) {
APPL_VERBOSE("file sha exist ==> read it");
uint64_t time_sha512 = etk::path::getModifyTime(_path + ".sha512");
uint64_t time_elem = etk::path::getModifyTime(_path);
etk::io::File file(_path + ".sha512");
file.open(etk::io::OpenMode::Read);
etk::String storedSha512_file = file.readAllString();
file.close();
APPL_VERBOSE("file sha == " << storedSha512_file);
if (time_elem > time_sha512) {
APPL_VERBOSE("file time > sha time ==> regenerate new one ...");
// check the current sha512
storedSha512 = algue::stringConvert(algue::sha512::encodeFromFile(_path));
APPL_VERBOSE("calculated new sha'" << storedSha512 << "'");
if (storedSha512_file != storedSha512) {
//need to remove the old sha file
auto idFileToRemove_fut = _srv.getId(storedSha512_file).waitFor(echrono::seconds(2));
@ -117,15 +122,29 @@ bool pushVideoFile(zeus::service::ProxyVideo& _srv, etk::String _path, etk::Map<
}
}
// store new sha512 ==> this update tile too ...
etk::FSNodeWriteAllData(_path + ".sha512", storedSha512);
file.open(etk::io::OpenMode::Write);
file.writeAll(storedSha512);
file.close();
} else {
// store new sha512
storedSha512 = etk::FSNodeReadAllData(_path + ".sha512");
/*
storedSha512 = file.readAllString();
file.open(etk::io::OpenMode::Read);
file.writeAll(storedSha512);
file.close();
*/
storedSha512 = storedSha512_file;
APPL_VERBOSE("read all sha from the file'" << storedSha512 << "'");
}
} else {
storedSha512 = algue::stringConvert(algue::sha512::encodeFromFile(_path));
etk::FSNodeWriteAllData(_path + ".sha512", storedSha512);
etk::io::File file(_path + ".sha512");
file.open(etk::io::OpenMode::Write);
file.writeAll(storedSha512);
file.close();
APPL_VERBOSE("calculate and store sha '" << storedSha512 << "'");
}
APPL_VERBOSE("check file existance: sha='" << storedSha512 << "'");
// push only if the file exist
// TODO : Check the metadata updating ...
auto idFile_fut = _srv.getId(storedSha512).waitFor(echrono::seconds(2));
@ -134,9 +153,12 @@ bool pushVideoFile(zeus::service::ProxyVideo& _srv, etk::String _path, etk::Map<
return true;
}
// TODO: Do it better ==> add the calback to know the push progression ...
APPL_VERBOSE("Add File : " << _path << " sha='" << storedSha512 << "'");
auto sending = _srv.add(zeus::File::create(_path, storedSha512));
sending.onSignal(progressCallback);
APPL_VERBOSE("Add done ... now waiting ... ");
uint32_t mediaId = sending.waitFor(echrono::seconds(20000)).get();
APPL_VERBOSE("END WAITING ... ");
if (mediaId == 0) {
APPL_ERROR("Get media ID = 0 With no error");
return false;
@ -309,14 +331,13 @@ bool pushVideoFile(zeus::service::ProxyVideo& _srv, etk::String _path, etk::Map<
return true;
}
void installVideoPath(zeus::service::ProxyVideo& _srv, etk::String _path, etk::Map<etk::String,etk::String> _basicKey = etk::Map<etk::String,etk::String>()) {
etk::FSNode node(_path);
void installVideoPath(zeus::service::ProxyVideo& _srv, etk::Path _path, etk::Map<etk::String,etk::String> _basicKey = etk::Map<etk::String,etk::String>()) {
APPL_INFO("Parse : '" << _path << "'");
etk::Vector<etk::String> listSubPath = node.folderGetSub(true, false, "*");
etk::Vector<etk::Path> listSubPath = etk::path::list(_path, etk::path::LIST_FOLDER);
for (auto &itPath : listSubPath) {
etk::Map<etk::String,etk::String> basicKeyTmp = _basicKey;
APPL_INFO("Add Sub path: '" << itPath << "'");
etk::String lastPathName = etk::split(itPath, '/').back();
etk::String lastPathName = itPath.getFileName();
if (basicKeyTmp.size() == 0) {
APPL_INFO("find A '" << lastPathName << "' " << basicKeyTmp.size());
if (lastPathName == "film") {
@ -406,9 +427,8 @@ void installVideoPath(zeus::service::ProxyVideo& _srv, etk::String _path, etk::M
installVideoPath(_srv, itPath, basicKeyTmp);
}
// Add files :
etk::Vector<etk::String> listSubFile = node.folderGetSub(false, true, "*");
etk::Vector<etk::Path> listSubFile = etk::path::list(_path, etk::path::LIST_FILE);
for (auto &itFile : listSubFile) {
etk::Map<etk::String,etk::String> basicKeyTmp = _basicKey;
pushVideoFile(_srv, itFile, _basicKey);
@ -417,7 +437,6 @@ void installVideoPath(zeus::service::ProxyVideo& _srv, etk::String _path, etk::M
int main(int _argc, const char *_argv[]) {
etk::init(_argc, _argv);
elog::init(_argc, _argv);
zeus::init(_argc, _argv);
zeus::Client client1;
etk::String login = "test1";

View File

@ -1,5 +1,5 @@
#!/usr/bin/python
import lutin.debug as debug
import realog.debug as debug
import lutin.tools as tools

View File

@ -10,7 +10,6 @@
#include <zeus/mineType.hpp>
#include <etk/etk.hpp>
#include <zeus/zeus.hpp>
#include <etk/os/FSNode.hpp>
#include <elog/elog.hpp>
#include <etk/stdTools.hpp>
@ -394,7 +393,6 @@ void installVideoPath(zeus::service::ProxyVideo& _srv, etk::String _path, etk::M
int main(int _argc, const char *_argv[]) {
etk::init(_argc, _argv);
elog::init(_argc, _argv);
zeus::init(_argc, _argv);
zeus::Client client1;
etk::String login = "test1";

View File

@ -1,5 +1,5 @@
#!/usr/bin/python
import lutin.debug as debug
import realog.debug as debug
import lutin.tools as tools

View File

@ -127,6 +127,7 @@ uint16_t appl::GateWay::getId() {
}
void appl::GateWay::start() {
APPL_WARNING("start [START]");
if (*propertyRouterNo == false) {
m_routerClient = ememory::makeShared<appl::RouterInterface>(propertyRouterIp.get(), propertyRouterPort.get(), propertyUserName.get(), this, propertyDirectPort.get());
if (m_routerClient->isAlive() == false) {
@ -141,13 +142,14 @@ void appl::GateWay::start() {
APPL_WARNING("#################################");
m_interfaceNewService->start(*propertyServiceIp, *propertyServicePort);
}
// Ebale access of direct Client
// Enable access of direct Client
if (propertyDirectPort.get() != 0) {
APPL_WARNING("#################################");
APPL_WARNING("## Open interface for Direct client : " << *propertyDirectIp << ":" << *propertyDirectPort);
APPL_WARNING("#################################");
m_interfaceNewClient->start(*propertyDirectIp, *propertyDirectPort);
}
APPL_WARNING("start [ END ]");
}
void appl::GateWay::stop() {

View File

@ -7,8 +7,10 @@
#include <appl/debug.hpp>
#include <appl/GateWay.hpp>
#include <etk/etk.hpp>
#include <etk/path/fileSystem.hpp>
#include <zeus/zeus.hpp>
#include <etk/Allocator.hpp>
#include <etk/uri/uri.hpp>
#include <etk/stdTools.hpp>
@ -17,7 +19,6 @@
#ifdef GATEWAY_ENABLE_LAUNCHER
#include <ethread/Mutex.hpp>
#include <etk/os/FSNode.hpp>
#include <sstream>
#include <stdlib.h>
#include <stdio.h>
@ -28,7 +29,7 @@
#include <zeus/Client.hpp>
#include <zeus/zeus.hpp>
typedef bool (*SERVICE_IO_init_t)(int _argc, const char *_argv[], etk::String _basePath);
typedef bool (*SERVICE_IO_init_t)(int _argc, const char *_argv[], etk::Uri _basePath);
typedef bool (*SERVICE_IO_uninit_t)();
typedef void (*SERVICE_IO_peridic_call_t)();
typedef zeus::Object* (*SERVICE_IO_instanciate_t)(uint32_t, ememory::SharedPtr<zeus::WebServer>&, uint32_t);
@ -50,13 +51,13 @@ class PlugginAccess {
m_SERVICE_IO_init(null),
m_SERVICE_IO_uninit(null),
m_SERVICE_IO_instanciate(null) {
etk::String srv = etk::FSNodeGetApplicationPath() + "/../lib/lib" + m_fullName + "-impl.so";
etk::Path srv = etk::path::getBinaryDirectory() / ".." / "lib" / "lib" + m_fullName + "-impl.so";
APPL_PRINT("++++++++++++++++++++++++++++++++");
APPL_PRINT("++ srv: '" << m_name << "' ");
APPL_PRINT("++++++++++++++++++++++++++++++++");
APPL_PRINT("At position: '" << srv << "'");
APPL_PRINT("with full name=" << m_fullName);
m_handle = dlopen(srv.c_str(), RTLD_LAZY);
m_handle = dlopen(srv.getNative().c_str(), RTLD_LAZY);
if (!m_handle) {
APPL_ERROR("Can not load Lbrary:" << dlerror());
return;
@ -90,16 +91,15 @@ class PlugginAccess {
~PlugginAccess() {
}
bool init(int _argc, const char *_argv[], etk::String _basePath) {
bool init(int _argc, const char *_argv[], etk::Uri _basePath) {
if (m_SERVICE_IO_init == null) {
return false;
}
if (_basePath.size() == 0) {
_basePath = "USERDATA:" + m_name + "/";
if (_basePath.isEmpty() == true) {
_basePath = "USER_DATA:///" + m_name;
APPL_PRINT("Use base path: " << _basePath);
} else {
_basePath += m_name + "/";
_basePath /= m_name;
}
return (*m_SERVICE_IO_init)(_argc, _argv, _basePath);
}
@ -128,6 +128,9 @@ class PlugginAccess {
}
(*m_SERVICE_IO_peridic_call)();
}
const etk::String getName() const {
return m_name;
}
};
#endif
@ -137,7 +140,7 @@ int main(int _argc, const char *_argv[]) {
zeus::init(_argc, _argv);
appl::GateWay basicGateway;
#ifdef GATEWAY_ENABLE_LAUNCHER
etk::String basePath;
etk::Uri basePath;
etk::Vector<etk::String> services;
zeus::Client m_client;
// The default service port is 1985
@ -147,6 +150,7 @@ int main(int _argc, const char *_argv[]) {
uint32_t routerDisconnectionDelay = 30;
for (int32_t iii=0; iii<_argc ; ++iii) {
etk::String data = _argv[iii];
APPL_PRINT("parameter: [" << iii << "] '" << data << "'");
if (etk::start_with(data, "--user=") == true) {
basicGateway.propertyUserName.set(etk::String(&data[7]));
} else if (data == "--no-router") {
@ -188,11 +192,7 @@ int main(int _argc, const char *_argv[]) {
basicGateway.propertyServiceMax.set(etk::string_to_uint16_t(etk::String(&data[14])));
#ifdef GATEWAY_ENABLE_LAUNCHER
} else if (etk::start_with(data, "--base-path=") == true) {
basePath = etk::String(&data[12]);
if ( basePath.size() != 0
&& basePath[basePath.size()-1] != '/') {
basePath += '/';
}
basePath = etk::Path(etk::String(&data[12]));
} else if (etk::start_with(data, "--srv=") == true) {
services.pushBack(etk::String(&data[6]));
#endif
@ -223,16 +223,19 @@ int main(int _argc, const char *_argv[]) {
etk::Vector<etk::Pair<etk::String,etk::String>> listAvaillableServices;
if (services.size() != 0) {
// find all services:
etk::FSNode dataPath(etk::FSNodeGetApplicationPath() + "/../share");
etk::Vector<etk::String> listSubPath = dataPath.folderGetSub(true, false, ".*");
APPL_DEBUG(" Base data path: " << dataPath.getName());
etk::Path dataPath(etk::path::getBinaryDirectory() / ".." / "share");
etk::Vector<etk::Path> listSubPath = etk::path::list(dataPath, etk::path::LIST_FOLDER);
APPL_DEBUG(" Base data path: " << dataPath);
APPL_DEBUG(" SubPath: " << listSubPath);
for (auto &it: listSubPath) {
if (etk::FSNodeExist(it + "/zeus/") == true) {
etk::FSNode dataPath(it + "/zeus/");
etk::Vector<etk::String> listServices = dataPath.folderGetSub(false, true, ".*\\.srv");
if (etk::path::exist(it / "zeus") == true) {
etk::Path dataPath(it / "zeus");
etk::Vector<etk::Path> listServices = etk::path::list(dataPath, etk::path::LIST_FILE);
for (auto &it2: listServices) {
etk::String nameFileSrv = etk::FSNode(it2).getNameFile();
if (it2.getExtention() != "srv") {
continue;
}
etk::String nameFileSrv = it2.getFileName();
etk::Vector<etk::String> spl = etk::String(nameFileSrv.begin(), nameFileSrv.end()-4).split("-service-");
if (spl.size() != 2) {
APPL_ERROR("reject service, wrong format ... '" << it2 << "' missing XXX-service-SERVICE-NAME.srv");
@ -295,13 +298,25 @@ int main(int _argc, const char *_argv[]) {
}
}
}
APPL_WARNING("=================================================");
APPL_WARNING("== INIT All service");
APPL_WARNING("=================================================");
for (auto &it: listElements) {
APPL_WARNING(" init: " << it->getName());
it->init(_argc, _argv, basePath);
}
APPL_WARNING("=================================================");
APPL_WARNING("== check client connected:");
APPL_WARNING("=================================================");
if (m_client.connect() == false) {
APPL_WARNING(" ==> not connected");
return -1;
}
APPL_WARNING("=================================================");
APPL_WARNING("== Publish all service");
APPL_WARNING("=================================================");
for (auto &it: listElements) {
APPL_WARNING(" publish: " << it->getName());
it->publish(m_client);
}
uint32_t iii = 0;

View File

@ -1,5 +1,5 @@
#!/usr/bin/python
import lutin.debug as debug
import realog.debug as debug
import lutin.tools as tools

View File

@ -9,7 +9,6 @@
#include <etk/etk.hpp>
#include <ethread/Mutex.hpp>
#include <etk/os/FSNode.hpp>
#include <sstream>
#include <stdlib.h>
#include <stdio.h>
@ -19,8 +18,10 @@
#include <zeus/Object.hpp>
#include <zeus/Client.hpp>
#include <zeus/zeus.hpp>
#include <etk/uri/uri.hpp>
#include <etk/path/fileSystem.hpp>
typedef bool (*SERVICE_IO_init_t)(int _argc, const char *_argv[], etk::String _basePath);
typedef bool (*SERVICE_IO_init_t)(int _argc, const char *_argv[], etk::Uri _basePath);
typedef bool (*SERVICE_IO_uninit_t)();
typedef void (*SERVICE_IO_peridic_call_t)();
typedef zeus::Object* (*SERVICE_IO_instanciate_t)(uint32_t, ememory::SharedPtr<zeus::WebServer>&, uint32_t);
@ -41,9 +42,9 @@ class PlugginAccess {
m_SERVICE_IO_uninit(null),
m_SERVICE_IO_peridic_call(null),
m_SERVICE_IO_instanciate(null) {
etk::String srv = etk::FSNodeGetApplicationPath() + "/../lib/libzeus-service-" + m_name + "-impl.so";
etk::Path srv = etk::path::getBinaryPath() / ".." / "lib" / "libzeus-service-" + m_name + "-impl.so";
APPL_PRINT("Try to open service with name: '" << m_name << "' at position: '" << srv << "'");
m_handle = dlopen(srv.c_str(), RTLD_LAZY);
m_handle = dlopen(srv.getNative().c_str(), RTLD_LAZY);
if (!m_handle) {
APPL_ERROR("Can not load Lbrary:" << dlerror());
return;
@ -77,16 +78,16 @@ class PlugginAccess {
~PlugginAccess() {
}
bool init(int _argc, const char *_argv[], etk::String _basePath) {
bool init(int _argc, const char *_argv[], etk::Uri _basePath) {
if (m_SERVICE_IO_init == null) {
return false;
}
if (_basePath.size() == 0) {
_basePath = "USERDATA:" + m_name + "/";
if (_basePath.isEmpty() == true) {
_basePath = "USER_DATA:///" + m_name + "/";
APPL_PRINT("Use base path: " << _basePath);
} else {
_basePath += m_name + "/";
_basePath.setPath(_basePath.getPath() / m_name);
}
return (*m_SERVICE_IO_init)(_argc, _argv, _basePath);
}

View File

@ -1,5 +1,5 @@
#!/usr/bin/python
import lutin.debug as debug
import realog.debug as debug
import lutin.tools as tools

View File

@ -1,5 +1,5 @@
#!/usr/bin/python
import lutin.debug as debug
import realog.debug as debug
import lutin.tools as tools

View File

@ -60,7 +60,7 @@ namespace appl {
class StreamBuffering : public ememory::EnableSharedFromThis<StreamBuffering> {
public:
StreamBuffering();
ethread::Mutex m_mutex; //!< local Lock Data protection
ethread::Mutex m_mutex; //!< local Lock Data protection
ememory::SharedPtr<appl::ClientProperty> m_property; //!< Remote interface that must get data
uint32_t m_mediaId; //!< remote media ID that need to get data
zeus::ProxyFile m_fileHandle; //!< Reference on the remote file

View File

@ -29,7 +29,7 @@
#include <appl/widget/Player.hpp>
static etk::String g_baseDBName = "USERDATA:config.json";
static etk::Uri g_baseDBName = "CONFIG:///config.json";
void appl::Windows::store_db() {
APPL_DEBUG("Store database [START]");
@ -76,7 +76,7 @@ void appl::Windows::init() {
APPL_CRITICAL(" An error occured ... in the windows creatrion ...");
return;
}
m_composer->loadFromFile("DATA:gui.xml");
m_composer->loadFromFile("DATA:///gui.xml");
setSubWidget(m_composer);
drawWidgetTree();

View File

@ -32,7 +32,7 @@ appl::widget::Connection::Connection() :
void appl::widget::Connection::init() {
ewol::widget::Composer::init();
loadFromFile("DATA:gui-connection.xml", getId());
loadFromFile("DATA:///gui-connection.xml", getId());
subBind(ewol::widget::Entry, "[" + etk::toString(getId()) + "]connect-login", signalModify, sharedFromThis(), &appl::widget::Connection::onCallbackEntryLoginChangeValue);
subBind(ewol::widget::Entry, "[" + etk::toString(getId()) + "]connect-password", signalModify, sharedFromThis(), &appl::widget::Connection::onCallbackEntryPasswordChangeValue);
subBind(ewol::widget::Button, "[" + etk::toString(getId()) + "]connect-bt", signalPressed, sharedFromThis(), &appl::widget::Connection::onCallbackButtonValidate);

View File

@ -37,8 +37,8 @@ appl::widget::ListViewer::ListViewer() :
void appl::widget::ListViewer::init() {
ewol::Widget::init();
markToRedraw();
//m_compImageVideo.setSource("DATA:Video.svg", 128);
//m_compImageAudio.setSource("DATA:MusicNote.svg", 128);
//m_compImageVideo.setSource("DATA:///Video.svg", 128);
//m_compImageAudio.setSource("DATA:///MusicNote.svg", 128);
}
appl::widget::ListViewer::~ListViewer() {
@ -310,10 +310,10 @@ void appl::ElementProperty::loadData() {
tmpProperty->m_mineType = _value;
if (etk::start_with(tmpProperty->m_mineType, "video") == true) {
// 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));
} else if (etk::start_with(tmpProperty->m_mineType, "audio") == true) {
// TODO : Optimise this ...
tmpProperty->m_thumb = egami::load("DATA:MusicNote.svg", ivec2(128,128));
tmpProperty->m_thumb = egami::load("DATA:///MusicNote.svg", ivec2(128,128));
}
}
m_widget->markToRedraw();
@ -819,7 +819,7 @@ void appl::ElementDisplayed::generateDisplay(vec2 _startPos, vec2 _size) {
bool haveThumb = false;
if (m_property->LoadDataEnded() == false) {
haveThumb = false;
m_image.setSource("DATA:Home.svg", 128);
m_image.setSource("DATA:///Home.svg", 128);
} else {
ethread::UniqueLock lock(m_property->m_mutex);
if (m_property->m_thumbPresent == true) {
@ -829,12 +829,12 @@ void appl::ElementDisplayed::generateDisplay(vec2 _startPos, vec2 _size) {
m_image.print(vec2(_size.y(), _size.y()));
} else {
if (etk::start_with(m_property->m_mineType, "video") == true) {
m_image.setSource("DATA:Video.svg", 128);
m_image.setSource("DATA:///Video.svg", 128);
} else if (etk::start_with(m_property->m_mineType, "audio") == true) {
m_image.setSource("DATA:MusicNote.svg", 128);
m_image.setSource("DATA:///MusicNote.svg", 128);
} else {
APPL_DEBUG("Set image: Unknow type '" << m_property->m_mineType << "'");
m_image.setSource("DATA:Home.svg", 128);
m_image.setSource("DATA:///Home.svg", 128);
}
}
}
@ -856,7 +856,7 @@ void appl::ElementDisplayed::generateDisplay(vec2 _startPos, vec2 _size) {
}
}
if (haveThumb == false) {
m_image.setSource("DATA:Home.svg", 128);
m_image.setSource("DATA:///Home.svg", 128);
m_image.setPos(_startPos+vec2(10,10));
m_image.print(vec2(_size.y(), _size.y())-vec2(20,20));
}

View File

@ -35,7 +35,7 @@ appl::widget::Player::Player() :
void appl::widget::Player::init() {
ewol::widget::Composer::init();
if (*propertySubFile == "") {
propertySubFile.set("DATA:gui-player.xml");
propertySubFile.set("DATA:///gui-player.xml");
}
subBind(ewol::widget::Button, "[" + etk::toString(getId()) + "]appl-player-bt-previous", signalPressed, sharedFromThis(), &appl::widget::Player::onCallbackButtonPrevious);
subBind(ewol::widget::Button, "[" + etk::toString(getId()) + "]appl-player-bt-play", signalValue, sharedFromThis(), &appl::widget::Player::onCallbackButtonPlay);

View File

@ -42,9 +42,9 @@ void appl::widget::UpBar::init() {
ewol::widget::Composer::init();
if (*propertySubFile == "") {
if (*propertyType == "volume") {
propertySubFile.set("DATA:gui-volume.xml");
propertySubFile.set("DATA:///gui-volume.xml");
} else if (*propertyType == "light") {
propertySubFile.set("DATA:gui-light.xml");
propertySubFile.set("DATA:///gui-light.xml");
} else {
APPL_ERROR("can not set the mode of upBar");
}

View File

@ -71,7 +71,7 @@ void appl::widget::VideoDisplay::loadProgram() {
// get the shader resource:
m_GLPosition = 0;
m_GLprogram.reset();
m_GLprogram = gale::resource::Program::create("{ewol}DATA:textured3D.prog");
m_GLprogram = gale::resource::Program::create("DATA:///textured3D.prog?lib=ewol");
if (m_GLprogram != null) {
m_GLPosition = m_GLprogram->getAttribute("EW_coord3d");
m_GLColor = m_GLprogram->getAttribute("EW_color");
@ -80,6 +80,7 @@ void appl::widget::VideoDisplay::loadProgram() {
m_GLtexID = m_GLprogram->getUniform("EW_texID");
}
}
void appl::widget::VideoDisplay::setFile(const etk::String& _filename) {
/*
// Stop playing in all case...
@ -357,7 +358,7 @@ void appl::widget::VideoDisplay::periodicEvent(const ewol::event::Time& _event)
// check the slot is valid and check display time of the element:
if ( idSlot != -1
&& m_currentTime > m_decoder->m_videoPool[idSlot].m_time) {
APPL_WARNING("Get Slot VIDEO " << m_currentTime << " > " << m_decoder->m_audioPool[idSlot].m_time);
APPL_WARNING("Get Slot VIDEO " << m_currentTime << " > " << m_decoder->m_videoPool[idSlot].m_time);
m_resource[m_useElement]->get().swap(m_decoder->m_videoPool[idSlot].m_image);
m_resource[m_useElement]->flush();
m_useElement++;

View File

@ -1,5 +1,5 @@
<sizer mode="vert" fill="true" expand="false,true" gravity="left">
<image name="[{ID}]appl-upbar-image" src="DATA:Light.svg" size="8,8mm"/>
<image name="[{ID}]appl-upbar-image" src="DATA:///Light.svg" size="8,8mm"/>
<appl_VolumeBar name="[{ID}]appl-upbar-range" expand="false,true" fill="true" step="5" min="0" max="200" danger="101" value="100" mode="vert"/>
<label name="[{ID}]appl-upbar-label">100%</label>
</sizer>

View File

@ -6,19 +6,19 @@
<spacer expand="true,false" fill="true"/>
<button name="[{ID}]appl-player-bt-previous" shape="">
<!--<label>_T{Previous}</label>-->
<image src="DATA:Previous.svg" size="8,8mm"/>
<image src="DATA:///Previous.svg" size="8,8mm"/>
</button>
<spacer expand="true,false" fill="true"/>
<button name="[{ID}]appl-player-bt-play" toggle="true" shape="">
<!--<label>_T{Play}</label>-->
<image src="DATA:Play.svg" size="8,8mm"/>
<image src="DATA:///Play.svg" size="8,8mm"/>
<!--<label>_T{Pause}</label>-->
<image src="DATA:Suspend.svg" size="8,8mm"/>
<image src="DATA:///Suspend.svg" size="8,8mm"/>
</button>
<spacer expand="true,false" fill="true"/>
<button name="[{ID}]appl-player-bt-next" shape="">
<!--<label>_T{Next}</label>-->
<image src="DATA:Next.svg" size="8,8mm" />
<image src="DATA:///Next.svg" size="8,8mm" />
</button>
<spacer expand="true,false" fill="true"/>
<spacer expand="true,false" fill="true"/>

View File

@ -1,5 +1,5 @@
<sizer mode="vert" fill="true" expand="false,true" gravity="right">
<image name="[{ID}]appl-upbar-image" src="DATA:Volume.svg" size="8,8mm" fill="true" expand="true,false"/>
<image name="[{ID}]appl-upbar-image" src="DATA:///Volume.svg" size="8,8mm" fill="true" expand="true,false"/>
<appl_VolumeBar name="[{ID}]appl-upbar-range" expand="false,true" fill="true" step="0.3" value="0" min="-40" danger="0.2" max="6" mode="vert"/>
<label name="[{ID}]appl-upbar-label">0dB</label>
</sizer>

View File

@ -15,10 +15,10 @@
</wslider>
<sizer mode="hori" fill="true,false" expand="true,false" lock="true">
<menu name="menu-bar">
<elem title="" image="DATA:List.svg" event="">
<elem title="_T{Connect}" image="DATA:Connect.svg" event="menu:connect"/>
<elem title="_T{Home}" image="DATA:Home.svg" event="menu:home"/>
<elem title="_T{Group}" image="DATA:Group.svg" event="menu:group">
<elem title="" image="DATA:///List.svg" event="">
<elem title="_T{Connect}" image="DATA:///Connect.svg" event="menu:connect"/>
<elem title="_T{Home}" image="DATA:///Home.svg" event="menu:home"/>
<elem title="_T{Group}" image="DATA:///Group.svg" event="menu:group">
<elem title="_T{Films}" image="" event="menu:films"/>
<elem title="_T{Annimated films}" image="" event="menu:animation-films"/>
<elem title="_T{TV Show}" image="" event="menu:tv-show"/>
@ -27,48 +27,48 @@
<elem title="_T{One-man show}" image="" event="menu:one-man-show"/>
<elem title="_T{Courses}" image="" event="menu:courses"/>
</elem>
<elem title="_T{TV}" image="DATA:Tv.svg" event="menu:tv">
<elem title="_T{TV}" image="DATA:///Tv.svg" event="menu:tv">
<elem title="_T{Child TV}" image="" event="menu:TV-child"/>
<elem title="_T{Adult TV}" image="" event="menu:TV-adult"/>
</elem>
<!--
<separator/>
<elem title="_T{Child Adult Switch}" image="DATA:ChildAdult.svg" event="menu:child-adult-switch"/>
<elem title="_T{Child Adult Switch}" image="DATA:///ChildAdult.svg" event="menu:child-adult-switch"/>
-->
<separator/>
<elem title="_T{Full screen}" image="DATA:FullScreen.svg" event="menu:full-screen"/>
<elem title="_T{Full screen}" image="DATA:///FullScreen.svg" event="menu:full-screen"/>
<separator/>
<elem title="_T{Exit}" image="DATA:Exit.svg" event="menu:exit"/>
<elem title="_T{Exit}" image="DATA:///Exit.svg" event="menu:exit"/>
</elem>
</menu>
<spacer expand="true,false"/>
<button name="access-fast-back" shape="">
<image src="DATA:Back.svg" size="8,8mm" />
<image src="DATA:///Back.svg" size="8,8mm" />
</button>
<spacer expand="true,false"/>
<button name="access-fast-home" shape="">
<image src="DATA:Home.svg" size="8,8mm" />
<image src="DATA:///Home.svg" size="8,8mm" />
</button>
<spacer expand="true,false"/>
<button name="access-fast-group" shape="">
<image src="DATA:Group.svg" size="8,8mm" />
<image src="DATA:///Group.svg" size="8,8mm" />
</button>
<spacer expand="true,false"/>
<!--
<button name="access-fast-tv">
<image src="DATA:Tv.svg" size="8,8mm" />
<image src="DATA:///Tv.svg" size="8,8mm" />
</button>
<spacer expand="true,false"/>
<button name="access-fast-page-previous">
<image src="DATA:Previous.svg" size="8,8mm" />
<image src="DATA:///Previous.svg" size="8,8mm" />
</button>
<spacer expand="true,false"/>
<button name="access-fast-page-next">
<image src="DATA:Next.svg" size="8,8mm" />
<image src="DATA:///Next.svg" size="8,8mm" />
</button>
<spacer expand="true,false"/>
<button name="search-bt" shape="">
<image src="DATA:Search.svg" size='8,8mm' />
<image src="DATA:///Search.svg" size='8,8mm' />
</button>
-->
</sizer>

View File

@ -1,6 +1,6 @@
#!/usr/bin/python
import lutin.tools as tools
import lutin.debug as debug
import realog.debug as debug
import os
import lutinLib_ffmpegCommon

View File

@ -6,10 +6,10 @@
#include <appl/Router.hpp>
#include <appl/debug.hpp>
#include <etk/path/fileSystem.hpp>
#include <enet/TcpServer.hpp>
#include <etk/os/FSNode.hpp>
static etk::String g_pathDBName = "USERDATA:router-database.json";
static etk::Uri g_pathDBName = "USER_DATA:///router-database.json";
class UserAvaillable {
public:
@ -186,6 +186,7 @@ extern "C" {
ememory::SharedPtr<appl::GateWayInterface> appl::Router::get(const etk::String& _userName) {
// TODO : Start USer only when needed, not get it all time started...
APPL_ERROR("Get user : " << _userName);
for (auto &it : m_GateWayList) {
if (it == null) {
continue;
@ -193,91 +194,100 @@ ememory::SharedPtr<appl::GateWayInterface> appl::Router::get(const etk::String&
if (it->getName() != _userName) {
continue;
}
APPL_ERROR(" ==> find IT ... already started...");
return it;
}
APPL_ERROR(" ==> Not found ==> start it ...");
// we not find the user ==> check if it is availlable ...
for (auto &it : g_listUserAvaillable) {
if (it.m_name == _userName) {
#if 0
// start interface:
etk::String cmd = "~/dev/perso/out/Linux_x86_64/debug/staging/clang/zeus-package-base/zeus-package-base.app/bin/zeus-gateway";
cmd += " --user=" + it.m_name + " ";
cmd += " --srv=user";
cmd += " --srv=picture";
cmd += " --srv=video";
cmd += " --base-path=" + it.m_basePath;
cmd += " --elog-file=\"/tmp/zeus.gateway." + it.m_name + ".log\"";
cmd += "&";
APPL_ERROR("Start " << cmd);
it.m_subProcess = popen(cmd.c_str(), "r");
if (it.m_subProcess == null) {
perror("popen");
return null;
}
// just trash IO ...
//pclose(it.m_subProcess);
#else
if (fork()) {
// We're in the parent here.
// nothing to do ...
APPL_ERROR("Parent Execution ...");
} else {
// We're in the child here.
APPL_ERROR("Child Execution ...");
etk::String binary = etk::FSNodeGetApplicationPath() + "/zeus-gateway";
etk::String userConf = "--user=" + it.m_name;
etk::String basePath = "--base-path=" + it.m_basePath;
etk::String logFile;
if (*propertyStdOut == false) {
logFile = it.m_basePath + "/log/gateway.log";
if ( logFile.size() != 0
&& logFile[0] == '~') {
logFile = etk::FSNodeGetHomePath() + &logFile[1];
}
logFile = "--elog-file=" + logFile;
//etk::String logFile = "--elog-file=/home/heero/.local/share/zeus-DATA/SDFGHTHBSDFGSQDHZSRDFGSDFGSDFGSDFG/log/gateway.log";
//etk::String logFile = " ";
APPL_INFO("New Child log in = " << logFile);
}
etk::String directAccess;
if (it.m_enableDirectAccess == true) {
directAccess = "--direct-ip=" + *propertyClientIp;
directAccess += " --direct-port=" + etk::toString(*propertyGateWayDirectPortMin);
}
etk::String delay = "--router-delay=" + etk::toString(*propertyDelayToStop);
//etk::String delay = "--router-delay=-1";
APPL_INFO("execute: " << binary << " " << userConf << " --srv=all " << delay << " " << basePath << " " << logFile << " " << directAccess);
int ret = execlp( binary.c_str(),
binary.c_str(), // must repeate the binary name to have the name as first argument ...
userConf.c_str(),
"--srv=all",
"--service-extern=false",
delay.c_str(),
basePath.c_str(),
logFile.c_str(),
directAccess.c_str(),
NULL);
APPL_ERROR("Child Execution ret = " << ret);
exit (-1);
APPL_ERROR("Must never appear ... child of fork killed ...");
}
#endif
int32_t nbCheckDelayMax = 24;
while (nbCheckDelayMax-- > 0) {
ethread::sleepMilliSeconds((25));
for (auto &it : m_GateWayList) {
if (it == null) {
continue;
}
if (it->getName() != _userName) {
continue;
}
return it;
}
}
APPL_ERROR("must be connected ==> and it is not ...");
break;
APPL_ERROR(" Check: " << it.m_name << " != " << _userName);
if (it.m_name != _userName) {
continue;
}
APPL_ERROR(" ==> find ...");
#if 0
// start interface:
etk::String cmd = "~/dev/perso/out/Linux_x86_64/debug/staging/clang/zeus-package-base/zeus-package-base.app/bin/zeus-gateway";
cmd += " --user=" + it.m_name + " ";
cmd += " --srv=user";
cmd += " --srv=picture";
cmd += " --srv=video";
cmd += " --base-path=" + it.m_basePath;
cmd += " --elog-file=\"/tmp/zeus.gateway." + it.m_name + ".log\"";
cmd += "&";
APPL_ERROR("Start " << cmd);
it.m_subProcess = popen(cmd.c_str(), "r");
if (it.m_subProcess == null) {
perror("popen");
return null;
}
// just trash IO ...
//pclose(it.m_subProcess);
#else
pid_t pid = fork();
if (pid > 0) {
// We're in the parent here.
// nothing to do ...
APPL_ERROR("Parent Execution ...");
} else if (pid == 0) {
// We're in the child here.
APPL_ERROR("Child Execution ...");
etk::Path binary = etk::path::getBinaryDirectory() / "zeus-gateway";
etk::String userConf = "--user=" + it.m_name;
etk::String basePath = "--base-path=" + it.m_basePath;
etk::String logFile;
if (*propertyStdOut == false) {
etk::Path tmp = etk::Path(it.m_basePath) / "log" / "gateway.log";
if ( tmp.isEmpty() == false
&& tmp.getString()[0] == '~') {
tmp = etk::path::getHomePath() / &logFile[1];
}
logFile = "--elog-file=" + tmp.getString();
//etk::String logFile = "--elog-file=/home/heero/.local/share/zeus-DATA/SDFGHTHBSDFGSQDHZSRDFGSDFGSDFGSDFG/log/gateway.log";
//etk::String logFile = " ";
APPL_INFO("New Child log in = " << logFile);
}
etk::String directAccess;
if (it.m_enableDirectAccess == true) {
directAccess = "--direct-ip=" + *propertyClientIp;
directAccess += " --direct-port=" + etk::toString(*propertyGateWayDirectPortMin);
}
etk::String delay = "--router-delay=" + etk::toString(*propertyDelayToStop);
//etk::String delay = "--router-delay=-1";
APPL_INFO("execute: " << binary << " " << userConf << " --srv=all " << delay << " " << basePath << " " << logFile << " " << directAccess);
int ret = execlp( binary.getNative().c_str(),
binary.getNative().c_str(), // must repeate the binary name to have the name as first argument ...
userConf.c_str(),
"--srv=all",
/*"--service-extern=false",*/
delay.c_str(),
basePath.c_str(),
logFile.c_str(),
directAccess.c_str(),
NULL);
APPL_ERROR("Child Execution ret = " << ret);
exit (-1);
APPL_ERROR("Must never appear ... child of fork killed ...");
} else {
// fork failed
APPL_ERROR("fork() failed!\n");
}
#endif
int32_t nbCheckDelayMax = 24;
while (nbCheckDelayMax-- > 0) {
ethread::sleepMilliSeconds((25));
for (auto &it : m_GateWayList) {
if (it == null) {
continue;
}
if (it->getName() != _userName) {
continue;
}
return it;
}
}
APPL_ERROR("must be connected ==> and it is not ...");
break;
}
return null;
}

View File

@ -1,5 +1,5 @@
#!/usr/bin/python
import lutin.debug as debug
import realog.debug as debug
import lutin.tools as tools

View File

@ -73,7 +73,7 @@ void appl::Windows::init() {
APPL_CRITICAL(" An error occured ... in the windows creatrion ...");
return;
}
m_composer->loadFromFile("DATA:gui.xml");
m_composer->loadFromFile("DATA:///gui.xml");
setSubWidget(m_composer);
subBind(ewol::widget::Button, "appl-shutdown", signalPressed, sharedFromThis(), &appl::Windows::onCallbackShutdown);

View File

@ -32,7 +32,7 @@ appl::widget::Connection::Connection() :
void appl::widget::Connection::init() {
ewol::widget::Composer::init();
loadFromFile("DATA:gui-connection.xml", getId());
loadFromFile("DATA:///gui-connection.xml", getId());
subBind(ewol::widget::Entry, "[" + etk::toString(getId()) + "]connect-login", signalModify, sharedFromThis(), &appl::widget::Connection::onCallbackEntryLoginChangeValue);
subBind(ewol::widget::Entry, "[" + etk::toString(getId()) + "]connect-password", signalModify, sharedFromThis(), &appl::widget::Connection::onCallbackEntryPasswordChangeValue);
subBind(ewol::widget::Button, "[" + etk::toString(getId()) + "]connect-bt", signalPressed, sharedFromThis(), &appl::widget::Connection::onCallbackButtonValidate);

View File

@ -1,6 +1,6 @@
#!/usr/bin/python
import lutin.tools as tools
import lutin.debug as debug
import realog.debug as debug
import os
import lutinLib_ffmpegCommon

View File

@ -8,12 +8,13 @@
#include <zeus/Object.hpp>
#include <zeus/File.hpp>
#include <etk/etk.hpp>
#include <etk/uri/uri.hpp>
#include <zeus/zeus.hpp>
#include <echrono/Time.hpp>
#include <ethread/Mutex.hpp>
#include <ejson/ejson.hpp>
#include <etk/os/FSNode.hpp>
#include <etk/path/fileSystem.hpp>
#include <etk/stdTools.hpp>
@ -24,7 +25,7 @@
#include <zeus/ProxyFile.hpp>
static ethread::Mutex g_mutex;
static etk::String g_basePath;
static etk::Uri g_basePath;
static etk::String g_baseDBName = etk::String(SERVICE_NAME) + "-database.json";
class FileProperty {
public:
@ -108,7 +109,9 @@ namespace appl {
if (find == false) {
throw etk::exception::InvalidArgument("Wrong file name ...");
}
return zeus::File::create(g_basePath + property.m_fileName + "." + zeus::getExtention(property.m_mineType), "", property.m_mineType);
etk::Uri tmpp = g_basePath;
tmpp.setPath(g_basePath.getPath() / property.m_fileName + "." + zeus::getExtention(property.m_mineType));
return zeus::File::create(tmpp.getString(), property.m_mineType);
}
uint32_t mediaAdd(zeus::ProxyFile _dataFile) override {
ethread::UniqueLock lock(g_mutex);
@ -117,8 +120,9 @@ namespace appl {
auto futType = _dataFile.getMineType();
auto futName = _dataFile.getName();
etk::String tmpFileName = g_basePath + "tmpImport_" + etk::toString(id);
etk::String sha512String = zeus::storeInFile(_dataFile, tmpFileName);
etk::Uri tmpFileName = g_basePath;
tmpFileName.setPath(g_basePath.getPath() / "tmpImport_" + etk::toString(id));
etk::String sha512String = zeus::storeInFile(_dataFile, tmpFileName.getString());
futType.wait();
futName.wait();
// TODO : Get internal data of the file and remove all the meta-data ==> proper files ...
@ -127,17 +131,19 @@ namespace appl {
APPL_INFO("File already registered at " << it.m_creationData);
// TODO : Check if data is identical ...
// remove temporary file
etk::FSNodeRemove(tmpFileName);
etk::uri::remove(tmpFileName);
return it.m_id;
}
}
// move the file at the good position:
APPL_DEBUG("move temporay file in : " << g_basePath << sha512String);
if (etk::FSNodeGetSize(tmpFileName) == 0) {
if (etk::uri::fileSize(tmpFileName) == 0) {
APPL_ERROR("try to store an empty file");
throw etk::exception::RuntimeError("file size == 0");
}
etk::FSNodeMove(tmpFileName, g_basePath + sha512String + "." + zeus::getExtention(futType.get()));
etk::Uri tmpFileNameDest = g_basePath;
tmpFileNameDest.setPath(g_basePath.getPath() / sha512String + "." + zeus::getExtention(futType.get()));
etk::uri::move(tmpFileName, tmpFileNameDest);
FileProperty property;
property.m_id = id;
property.m_fileName = sha512String;
@ -183,7 +189,10 @@ namespace appl {
}
// Real Remove definitly the file
// TODO : Set it in a trash ... For a while ...
if (etk::FSNodeRemove(g_basePath + property.m_fileName + "." + zeus::getExtention(property.m_mineType)) == false) {
etk::Uri tmpFileName = g_basePath;
tmpFileName.setPath(g_basePath.getPath() / property.m_fileName + "." + zeus::getExtention(property.m_mineType));
if (etk::uri::remove(tmpFileName) == false) {
throw etk::exception::RuntimeError("Can not remove file ...");
}
}
@ -429,14 +438,18 @@ static void store_db() {
listMediaArray.add(ejson::Number(it2));
}
}
bool retGenerate = database.storeSafe(g_basePath + g_baseDBName);
APPL_ERROR("Store database [STOP] : " << (g_basePath + g_baseDBName) << " ret = " << retGenerate);
etk::Uri dbFileName = g_basePath;
dbFileName.setPath(g_basePath.getPath() / g_baseDBName);
bool retGenerate = database.storeSafe(dbFileName);
APPL_ERROR("Store database [STOP] : " << dbFileName << " ret = " << retGenerate);
g_needToStore = false;
}
static void load_db() {
ejson::Document database;
bool ret = database.load(g_basePath + g_baseDBName);
etk::Uri dbFileName = g_basePath;
dbFileName.setPath(g_basePath.getPath() / g_baseDBName);
bool ret = database.load(dbFileName);
if (ret == false) {
APPL_WARNING(" ==> LOAD error");
}
@ -485,7 +498,7 @@ static void load_db() {
g_needToStore = false;
}
ETK_EXPORT_API bool SERVICE_IO_init(int _argc, const char *_argv[], etk::String _basePath) {
ETK_EXPORT_API bool SERVICE_IO_init(int _argc, const char *_argv[], etk::Uri _basePath) {
g_basePath = _basePath;
ethread::UniqueLock lock(g_mutex);
APPL_WARNING("Load USER: " << g_basePath);

View File

@ -1,5 +1,5 @@
#!/usr/bin/python
import lutin.debug as debug
import realog.debug as debug
import lutin.tools as tools

View File

@ -1,5 +1,5 @@
#!/usr/bin/python
import lutin.debug as debug
import realog.debug as debug
import lutin.tools as tools
import lutin.macro as macro

View File

@ -1,5 +1,5 @@
#!/usr/bin/python
import lutin.debug as debug
import realog.debug as debug
import lutin.tools as tools
import os
import copy

View File

@ -1,5 +1,5 @@
#!/usr/bin/python
import lutin.debug as debug
import realog.debug as debug
import lutin.tools as tools
import lutin.macro as macro

View File

@ -19,7 +19,7 @@
#include <zeus/ProxyClientProperty.hpp>
static ethread::Mutex g_mutex;
static etk::String g_basePath;
static etk::Uri g_basePath;
static etk::String g_baseDBName = etk::String(SERVICE_NAME) + "-database.json";
static ejson::Document g_database;
@ -135,11 +135,13 @@ namespace appl {
};
}
ETK_EXPORT_API bool SERVICE_IO_init(int _argc, const char *_argv[], etk::String _basePath) {
ETK_EXPORT_API bool SERVICE_IO_init(int _argc, const char *_argv[], etk::Uri _basePath) {
g_basePath = _basePath;
ethread::UniqueLock lock(g_mutex);
APPL_WARNING("Load USER: " << g_basePath);
bool ret = g_database.load(g_basePath + g_baseDBName);
etk::Uri db = g_basePath;
db.setPath(g_basePath.getPath() / g_baseDBName);
bool ret = g_database.load(db);
if (ret == false) {
APPL_WARNING(" ==> LOAD error");
}
@ -149,7 +151,9 @@ ETK_EXPORT_API bool SERVICE_IO_init(int _argc, const char *_argv[], etk::String
ETK_EXPORT_API bool SERVICE_IO_uninit() {
ethread::UniqueLock lock(g_mutex);
APPL_DEBUG("Store User Info:");
bool ret = g_database.storeSafe(g_basePath + g_baseDBName);
etk::Uri db = g_basePath;
db.setPath(g_basePath.getPath() / g_baseDBName);
bool ret = g_database.storeSafe(db);
if (ret == false) {
APPL_WARNING(" ==> Store error");
return false;

View File

@ -1,5 +1,5 @@
#!/usr/bin/python
import lutin.debug as debug
import realog.debug as debug
import lutin.tools as tools
import os
import copy

View File

@ -1,5 +1,5 @@
#!/usr/bin/python
import lutin.debug as debug
import realog.debug as debug
import lutin.tools as tools
import lutin.macro as macro

View File

@ -13,7 +13,6 @@
#include <ethread/Mutex.hpp>
#include <ejson/ejson.hpp>
#include <etk/os/FSNode.hpp>
#include <sstream>
#include <etk/stdTools.hpp>
@ -26,9 +25,10 @@
#include <zeus/zeus-Media.impl.hpp>
static ethread::Mutex g_mutex;
static etk::String g_basePath;
static etk::String g_basePathCover;
static etk::String g_basePathCoverGroup;
static etk::Uri g_basePath;
static etk::Uri g_basePathCover;
static etk::Uri g_basePathCoverGroup;
static etk::Uri g_basePathBDD;
static etk::String g_baseDBName = etk::String(SERVICE_NAME) + "-database.json";
static etk::Vector<ememory::SharedPtr<zeus::MediaImpl>> m_listFile;
@ -210,20 +210,20 @@ namespace appl {
}
}
}
etk::String tmpFileName = g_basePath + "tmpImport_" + etk::toString(importId);
etk::Uri tmpFileName = g_basePath / ("tmpImport_" + etk::toString(importId));
etk::String sha512String = zeus::storeInFile(_dataFile, tmpFileName);
futType.wait();
futName.wait();
// move the file at the good position:
APPL_DEBUG("move temporay file in : " << g_basePath << sha512String);
if (etk::FSNodeGetSize(tmpFileName) == 0) {
if (etk::uri::fileSize(tmpFileName) == 0) {
APPL_ERROR("try to store an empty file");
throw etk::exception::RuntimeError("file size == 0");
}
if (zeus::getExtention(futType.get()) != "") {
ethread::UniqueLock lock(g_mutex);
etk::FSNodeMove(tmpFileName, g_basePath + sha512String + "." + zeus::getExtention(futType.get()));
ememory::SharedPtr<zeus::MediaImpl> property = ememory::makeShared<zeus::MediaImpl>(id, sha512String + "." + zeus::getExtention(futType.get()), g_basePath);
etk::uri::move(tmpFileName, g_basePath / (sha512String + "." + zeus::getExtention(futType.get())));
ememory::SharedPtr<zeus::MediaImpl> property = ememory::makeShared<zeus::MediaImpl>(id, g_basePath / (sha512String + "." + zeus::getExtention(futType.get())));
property->setMetadata("sha512", sha512String);
property->setMetadata("mime-type", futType.get());
property->setCallbackMetadataChange(&metadataChange);
@ -231,8 +231,8 @@ namespace appl {
g_needToStore = true;
} else {
ethread::UniqueLock lock(g_mutex);
etk::FSNodeMove(tmpFileName, g_basePath + sha512String);
ememory::SharedPtr<zeus::MediaImpl> property = ememory::makeShared<zeus::MediaImpl>(id, sha512String, g_basePath);
etk::uri::move(tmpFileName, g_basePath / sha512String);
ememory::SharedPtr<zeus::MediaImpl> property = ememory::makeShared<zeus::MediaImpl>(id, g_basePath / sha512String);
property->setMetadata("sha512", sha512String);
property->setCallbackMetadataChange(&metadataChange);
m_listFile.pushBack(property);
@ -403,42 +403,42 @@ namespace appl {
return out;
}
ememory::SharedPtr<zeus::File> internalGetCover(const etk::String& _baseName, const etk::String& _mediaString, uint32_t _maxSize) {
if (etk::FSNodeExist(_baseName + _mediaString + ".jpg") == true) {
return zeus::File::create(_baseName + _mediaString + ".jpg");
ememory::SharedPtr<zeus::File> internalGetCover(const etk::Uri& _baseName, const etk::String& _mediaString, uint32_t _maxSize) {
if (etk::uri::exist(_baseName / (_mediaString + ".jpg")) == true) {
return zeus::File::create(_baseName / (_mediaString + ".jpg"));
}
if (etk::FSNodeExist(_baseName + _mediaString + ".png") == true) {
return zeus::File::create(_baseName + _mediaString + ".png");
if (etk::uri::exist(_baseName / (_mediaString + ".png")) == true) {
return zeus::File::create(_baseName / (_mediaString + ".png"));
}
throw etk::exception::RuntimeError("No cover availlable");
}
void internalSetCover(const etk::String& _baseName, zeus::ActionNotification<etk::String>& _notifs, zeus::ProxyFile _cover, etk::String _mediaString) {
void internalSetCover(const etk::Uri& _baseName, zeus::ActionNotification<etk::String>& _notifs, zeus::ProxyFile _cover, etk::String _mediaString) {
uint64_t importId = 0;
{
ethread::UniqueLock lock(g_mutex);
importId = createUniqueImportID();
}
auto futType = _cover.getMineType();
etk::String tmpFileName = g_basePath + "tmpImport_" + etk::toString(importId);
etk::Uri tmpFileName = g_basePath / ("tmpImport_" + etk::toString(importId));
etk::String sha512String = zeus::storeInFile(_cover, tmpFileName);
futType.wait();
if (etk::FSNodeGetSize(tmpFileName) == 0) {
if (etk::uri::fileSize(tmpFileName) == 0) {
APPL_ERROR("try to store an empty file");
throw etk::exception::RuntimeError("file size == 0");
}
if (etk::FSNodeGetSize(tmpFileName) > 1024*1024) {
if (etk::uri::fileSize(tmpFileName) > 1024*1024) {
APPL_ERROR("try to store a Bigger file");
throw etk::exception::RuntimeError("file size > 1Mo");
}
if (futType.get() == "image/png") {
ethread::UniqueLock lock(g_mutex);
etk::FSNodeRemove(_baseName + _mediaString + ".jpg");
etk::FSNodeMove(tmpFileName, _baseName + _mediaString + ".png");
etk::uri::remove(_baseName / (_mediaString + ".jpg"));
etk::uri::move(tmpFileName, _baseName / (_mediaString + ".png"));
} else if (futType.get() == "image/jpeg") {
ethread::UniqueLock lock(g_mutex);
etk::FSNodeRemove(_baseName + _mediaString + ".png");
etk::FSNodeMove(tmpFileName, _baseName + _mediaString + ".jpg");
etk::uri::remove(_baseName / (_mediaString + ".png"));
etk::uri::move(tmpFileName, _baseName / (_mediaString + ".jpg"));
} else {
APPL_ERROR("try to store a file with the wrong format");
throw etk::exception::RuntimeError("wrong foramt :" + futType.get() + " support only image/jpeg, image/png");
@ -475,14 +475,14 @@ static void store_db() {
listFilesArray.add(it->getJson());
}
}
bool retGenerate = database.storeSafe(g_basePath + g_baseDBName);
APPL_ERROR("Store database [STOP] : " << (g_basePath + g_baseDBName) << " ret = " << retGenerate);
bool retGenerate = database.storeSafe(g_basePathBDD);
APPL_ERROR("Store database [STOP] : " << g_basePathBDD << " ret = " << retGenerate);
g_needToStore = false;
}
static void load_db() {
ejson::Document database;
bool ret = database.load(g_basePath + g_baseDBName);
bool ret = database.load(g_basePathBDD);
if (ret == false) {
APPL_WARNING(" ==> LOAD error");
}
@ -506,10 +506,11 @@ static void load_db() {
g_needToStore = false;
}
ETK_EXPORT_API bool SERVICE_IO_init(int _argc, const char *_argv[], etk::String _basePath) {
ETK_EXPORT_API bool SERVICE_IO_init(int _argc, const char *_argv[], etk::Uri _basePath) {
g_basePath = _basePath;
g_basePathCover = _basePath + "/AAAASDGDFGQN4352SCVdfgBSXDFGFCVQDSGFQSfd_cover/";
g_basePathCoverGroup = _basePath + "/AAAASDGDFGQN4352SCVdfgBSXDFGFCVQDSGFQSfd_cover_group/";
g_basePathCover = g_basePath / "AAAASDGDFGQN4352SCVdfgBSXDFGFCVQDSGFQSfd_cover";
g_basePathCoverGroup = g_basePath / "AAAASDGDFGQN4352SCVdfgBSXDFGFCVQDSGFQSfd_cover_group";
g_basePathBDD = g_basePath / g_baseDBName;
ethread::UniqueLock lock(g_mutex);
APPL_WARNING("Load USER: " << g_basePath);
load_db();

View File

@ -1,5 +1,5 @@
#!/usr/bin/python
import lutin.debug as debug
import realog.debug as debug
import lutin.tools as tools

View File

@ -1,5 +1,5 @@
#!/usr/bin/python
import lutin.debug as debug
import realog.debug as debug
import lutin.tools as tools
import lutin.macro as macro

View File

@ -5,7 +5,6 @@
*/
#include <zeus/AbstractFunction.hpp>
#include <zeus/debug.hpp>
#include <etk/os/FSNode.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(zeus::AbstractFunction);

View File

@ -674,7 +674,7 @@ void zeus::WebServer::threadAsyncCallback() {
if (m_threadAsyncList2.size() != 0) {
ethread::UniqueLock lock(m_threadAsyncMutex);
for (auto &it : m_threadAsyncList2) {
ZEUS_INFO("Add async");
ZEUS_DEBUG("Add async");
m_threadAsyncList.pushBack(it);
}
m_threadAsyncList2.clear();
@ -689,7 +689,7 @@ void zeus::WebServer::threadAsyncCallback() {
bool ret = (*it)(this);
if (ret == true) {
// Remove it ...
ZEUS_INFO("Remove async");
ZEUS_DEBUG("Remove async");
it = m_threadAsyncList.erase(it);
} else {
++it;

View File

@ -11,7 +11,6 @@
#include <etk/stdTools.hpp>
#include <zeus/AbstractFunction.hpp>
#include <climits>
#include <etk/os/FSNode.hpp>
#include <zeus/mineType.hpp>
#include <zeus/WebServer.hpp>

View File

@ -8,7 +8,7 @@
#include <zeus/ProxyFile.hpp>
#include <zeus/mineType.hpp>
#include <algue/sha512.hpp>
#include <etk/os/FSNode.hpp>
#include <etk/path/fileSystem.hpp>
#include <etk/Exception.hpp>
#include "debug.hpp"
@ -17,18 +17,18 @@
ETK_DECLARE_TYPE(zeus::FileImpl);
ememory::SharedPtr<zeus::File> zeus::File::create(etk::String _fileNameReal) {
ememory::SharedPtr<zeus::File> zeus::File::create(etk::Uri _fileNameReal) {
return ememory::makeShared<zeus::FileImpl>(_fileNameReal);
}
ememory::SharedPtr<zeus::File> zeus::File::create(etk::String _fileNameReal, etk::String _sha512) {
ememory::SharedPtr<zeus::File> zeus::File::create(etk::Uri _fileNameReal, etk::String _sha512) {
return ememory::makeShared<zeus::FileImpl>(_fileNameReal, _sha512);
}
ememory::SharedPtr<zeus::File> zeus::File::create(etk::String _fileNameReal, etk::String _fileNameShow, etk::String _mineType) {
ememory::SharedPtr<zeus::File> zeus::File::create(etk::Uri _fileNameReal, etk::String _fileNameShow, etk::String _mineType) {
return ememory::makeShared<zeus::FileImpl>(_fileNameReal, _fileNameShow, _mineType);
}
ememory::SharedPtr<zeus::File> zeus::File::create(etk::String _fileNameReal, etk::String _fileNameShow, etk::String _mineType, etk::String _sha512) {
ememory::SharedPtr<zeus::File> zeus::File::create(etk::Uri _fileNameReal, etk::String _fileNameShow, etk::String _mineType, etk::String _sha512) {
return ememory::makeShared<zeus::FileImpl>(_fileNameReal, _fileNameShow, _mineType, _sha512);
}
@ -42,23 +42,19 @@ zeus::FileImpl::FileImpl(etk::Vector<uint8_t> _value, etk::String _virtualName,
m_gettedData(0),
m_mineType(_mineType),
m_sha512("") {
ZEUS_ERROR(" ==============>>>>>>>>>>>>>> CREATE FILE");
ZEUS_ERROR(" ==============>>>>>>>>>>>>>> CREATE FILE 1 " << _virtualName);
m_dataRaw = true;
m_data = _value;
m_size = m_data.size();
}
zeus::FileImpl::FileImpl(etk::String _fileNameReal, etk::String _sha512) :
m_filename(_fileNameReal),
m_node(_fileNameReal),
zeus::FileImpl::FileImpl(etk::Uri _fileNameReal, etk::String _sha512) :
m_filename(_fileNameReal.getPath().getFileName()),
m_file(etk::uri::get(_fileNameReal)),
m_gettedData(0),
m_sha512(_sha512) {
ZEUS_ERROR(" ==============>>>>>>>>>>>>>> CREATE FILE");
m_size = m_node.fileSize();
etk::String extention;
if ( _fileNameReal.rfind('.') != etk::String::npos
&& _fileNameReal.rfind('.') != 0) {
extention = etk::String(_fileNameReal.begin()+_fileNameReal.rfind('.')+1, _fileNameReal.end());
}
ZEUS_ERROR(" ==============>>>>>>>>>>>>>> CREATE FILE 3 " << _fileNameReal << " '" << _sha512 << "' size=" << m_file->size());
m_size = m_file->size();
etk::String extention = _fileNameReal.getPath().getExtention();
m_mineType = zeus::getMineType(extention);
if ( _sha512.size() > 0
&& _sha512.size() != 128) {
@ -69,14 +65,14 @@ zeus::FileImpl::FileImpl(etk::String _fileNameReal, etk::String _sha512) :
// sha 512 example: 6134b4a4b5b116cf1b1b757c5aa48bd8b3482b86c6d3fee389a0a3232f74e7331e5f8af6ad516d2ca92eda0a475f44e1291618562ce6f9e54634ba052650dcd7
// 000000000100000000020000000003000000000400000000050000000006000000000700000000080000000009000000000A000000000B000000000C00000000
zeus::FileImpl::FileImpl(etk::String _fileNameReal, etk::String _fileNameShow, etk::String _mineType, etk::String _sha512) :
zeus::FileImpl::FileImpl(etk::Uri _fileNameReal, etk::String _fileNameShow, etk::String _mineType, etk::String _sha512) :
m_filename(_fileNameShow),
m_node(_fileNameReal),
m_file(etk::uri::get(_fileNameReal)),
m_gettedData(0),
m_mineType(_mineType),
m_sha512(_sha512) {
ZEUS_ERROR(" ==============>>>>>>>>>>>>>> CREATE FILE");
m_size = m_node.fileSize();
ZEUS_ERROR(" ==============>>>>>>>>>>>>>> CREATE FILE 2 " << _fileNameReal);
m_size = m_file->size();
if ( _sha512.size() > 0
&& _sha512.size() != 128) {
ZEUS_ERROR("Set a wrong sha512 file type");
@ -86,8 +82,8 @@ zeus::FileImpl::FileImpl(etk::String _fileNameReal, etk::String _fileNameShow, e
zeus::FileImpl::~FileImpl() {
ZEUS_ERROR(" <<<<<<<<<<<<<<============== DESTROY FILE");
if (m_node.fileIsOpen() == true) {
m_node.fileClose();
if (m_file->isOpen() == true) {
m_file->close();
}
}
@ -100,15 +96,17 @@ etk::String zeus::FileImpl::getName() {
}
etk::String zeus::FileImpl::getSha512() {
ZEUS_VERBOSE("Get SHA 512 ... " << m_sha512.size() << " '" << m_sha512 << "'");
if (m_sha512 == "") {
ZEUS_INFO("calculation of sha 512 (start)");
if (m_dataRaw == false) {
m_sha512 = algue::stringConvert(algue::sha512::encodeFromFile(m_node.getFileSystemName()));
m_sha512 = algue::stringConvert(algue::sha512::encodeFromFile(m_file));
} else {
m_sha512 = algue::stringConvert(algue::sha512::encode(m_data));
}
ZEUS_INFO("calculation of sha 512 (stop)");
}
ZEUS_VERBOSE("return sha512 : '" << m_sha512 << "'");
return m_sha512;
}
@ -117,6 +115,7 @@ etk::String zeus::FileImpl::getMineType() {
}
zeus::Raw zeus::FileImpl::getPart(uint64_t _start, uint64_t _stop) {
ZEUS_VERBOSE("REQUEST Get part ... " << _start << " " << _stop);
if ((_stop - _start) > 25*1024*1024) {
ZEUS_ERROR("REQUEST more that 25 Mo in a part file ...");
throw etk::exception::InvalidArgument("REQUEST more that 25 Mo in a part file ..." + etk::toString(_stop - _start) + " Bytes");
@ -126,21 +125,21 @@ zeus::Raw zeus::FileImpl::getPart(uint64_t _start, uint64_t _stop) {
throw etk::exception::InvalidArgument("REQUEST start position out of file size" + etk::toString(_start) + " > " + etk::toString(m_size));
}
if (m_dataRaw == false) {
if (m_node.fileIsOpen() == false) {
m_node.fileOpenRead();
if (m_file->isOpen() == false) {
m_file->open(etk::io::OpenMode::Read);
}
m_gettedData += (_stop - _start);
//ZEUS_PRINT("Reading file : " << m_gettedData << "/" << m_size << " ==> " << float(m_gettedData)/float(m_size)*100.0f << "%");
printf("Reading file : %d/%d ==> %f \r", int(m_gettedData), int(m_size), float(m_gettedData)/float(m_size)*100.0f);
zeus::Raw tmp(_stop - _start);
if (m_node.fileSeek(_start, etk::seekNode_start) == false) {
if (m_file->seek(_start, etk::io::SeekMode::Start) == false) {
ZEUS_ERROR("REQUEST seek error ...");
throw etk::exception::RuntimeError("Seek in the file error");
return zeus::Raw();
}
int64_t sizeCopy = m_node.fileRead(tmp.writeData(), 1, _stop-_start);
int64_t sizeCopy = m_file->read(tmp.writeData(), 1, _stop-_start);
if (m_size <= _stop) {
m_node.fileClose();
m_file->close();
}
// TODO : Check if copy is correct ...
return etk::move(tmp);
@ -154,12 +153,12 @@ zeus::Raw zeus::FileImpl::getPart(uint64_t _start, uint64_t _stop) {
}
}
etk::String zeus::storeInFile(zeus::ProxyFile _file, etk::String _filename) {
etk::String zeus::storeInFile(zeus::ProxyFile _file, etk::Uri _uri) {
zeus::ActionNotification<etk::String> tmp;
return zeus::storeInFileNotify(_file, _filename, tmp);
return zeus::storeInFileNotify(_file, _uri, tmp);
}
etk::String zeus::storeInFileNotify(zeus::ProxyFile _file, etk::String _filename, zeus::ActionNotification<etk::String> _notification) {
etk::String zeus::storeInFileNotify(zeus::ProxyFile _file, etk::Uri _uri, zeus::ActionNotification<etk::String> _notification) {
auto futSize = _file.getSize();
auto futSha = _file.getSha512();
futSize.wait();
@ -167,8 +166,8 @@ etk::String zeus::storeInFileNotify(zeus::ProxyFile _file, etk::String _filename
int64_t offset = 0;
algue::Sha512 shaCtx;
etk::FSNode nodeFile(_filename);
nodeFile.fileOpenWrite();
ememory::SharedPtr<etk::io::Interface> file = etk::uri::get(_uri);
file->open(etk::io::OpenMode::Write);
while (retSize > 0) {
// get by batch of 1 MB
int32_t nbElement = 1*1024*1024;
@ -176,19 +175,21 @@ etk::String zeus::storeInFileNotify(zeus::ProxyFile _file, etk::String _filename
nbElement = retSize;
}
auto futData = _file.getPart(offset, offset + nbElement);
// TODO: set a timeout
futData.wait();
if (futData.hasError() == true) {
ZEUS_DEBUG("read: ==> exception when read data ...");
throw etk::exception::RuntimeError("Error when loading data");
}
zeus::Raw buffer = futData.get();
shaCtx.update(buffer.data(), buffer.size());
nodeFile.fileWrite(buffer.data(), 1, buffer.size());
file->write(buffer.data(), 1, buffer.size());
offset += nbElement;
retSize -= nbElement;
ZEUS_VERBOSE("read: " << offset << "/" << futSize.get() << " " << buffer.size());
_notification.notify("{\"pourcent\":" + etk::toString(float(offset)/float(buffer.size())) + ", \"comment\":\"download\"");
}
nodeFile.fileClose();
file->close();
// get the final sha512 of the file:
etk::String sha512String = algue::stringConvert(shaCtx.finalize());
futSha.wait();
@ -238,4 +239,4 @@ etk::Vector<uint8_t> zeus::storeInMemory(zeus::ProxyFile _file) {
ZEUS_ERROR("get wrong Sha512 remote: '" << futSha.get() << "'");
}
return out;
}
}

View File

@ -6,13 +6,14 @@
#pragma once
#include <zeus/File.hpp>
#include <etk/os/FSNode.hpp>
#include <etk/path/fileSystem.hpp>
#include <etk/io/File.hpp>
namespace zeus {
class FileImpl : public zeus::File {
private:
etk::String m_filename; //!< Name of the file
etk::FSNode m_node; //!< File node access
ememory::SharedPtr<etk::io::Interface> m_file; //!< File node access
etk::Vector<uint8_t> m_data; //!< data of the file to transfer;
bool m_dataRaw = false;
size_t m_size; //!< Size of the file
@ -20,8 +21,8 @@ namespace zeus {
etk::String m_mineType; //!< Mine Type of the file
etk::String m_sha512; //!< Global file sha-512
public:
FileImpl(etk::String _fileNameReal, etk::String _fileNameShow, etk::String _mineType, etk::String _sha512="");
FileImpl(etk::String _fileNameReal, etk::String _sha512="");
FileImpl(etk::Uri _fileNameReal, etk::String _fileNameShow, etk::String _mineType, etk::String _sha512="");
FileImpl(etk::Uri _fileNameReal, etk::String _sha512="");
FileImpl(etk::Vector<uint8_t> _value, etk::String _virtualName, etk::String _mineType);
~FileImpl();
uint64_t getSize() override;

View File

@ -9,24 +9,24 @@
#brief:Factory to create a local object.
#param:fileName:Name of the local file to instanciate.
[factory] create(string)
[factory] create(uri)
#brief:Factory to create a local object.
#param:fileName:Name of the local file to instanciate.
#param:sha512: Sha-512 string if the file
[factory] create(string, string)
[factory] create(uri, string)
#brief:Factory to create a local object.
#param:fileNameReal:Name of the local file to instanciate.
#param:fileNameShow:Name of the file like the remote user will se it.
#param:mineType:Mine-type of the file.
[factory] create(string, string, string)
[factory] create(uri, string, string)
#brief:Factory to create a local object.
#param:fileNameReal:Name of the local file to instanciate.
#param:fileNameShow:Name of the file like the remote user will se it.
#param:mineType:Mine-type of the file.
#param:sha512: Sha-512 string if the file
[factory] create(string, string, string, string)
[factory] create(uri, string, string, string)
#brief:Factory to create a local object with a buffer with data like a file.
#param:buffer:Data bueffer of the data.
#param:buffer:Data buffer of the data.
#param:virtualName:Virtual name of the file.
#param:mineType:Mine-type of the file.
[factory] create(vector:uint8, string, string)
@ -65,7 +65,7 @@ raw getPart(uint64, uint64)
#param:file:Handle on the file.
#param:filename:Local filename.
#return:the sha512 of the file (calculated with the input stream.
[tool-remote] string storeInFile(obj:zeus-File, string)
[tool-remote] string storeInFile(obj:zeus-File, uri)
#brief:Store all the data in a specific vector of data.
#param:file:Handle on the file.
@ -77,5 +77,5 @@ raw getPart(uint64, uint64)
#param:filename:Local filename.
#param:notif:Local filename.
#return:the sha512 of the file (calculated with the input stream.
[tool-remote] string storeInFileNotify(obj:zeus-File, string, ActionNotif)
[tool-remote] string storeInFileNotify(obj:zeus-File, uri, ActionNotif)

View File

@ -8,17 +8,24 @@
#include <zeus/ProxyFile.hpp>
#include <zeus/mineType.hpp>
#include <algue/sha512.hpp>
#include <etk/os/FSNode.hpp>
#include <etk/path/fileSystem.hpp>
#include "debug.hpp"
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(zeus::MediaImpl);
ememory::SharedPtr<zeus::Media> zeus::Media::create(etk::String _fileNameReal) {
return ememory::makeShared<zeus::MediaImpl>(0, _fileNameReal);
ememory::SharedPtr<zeus::Media> zeus::Media::create(etk::String _fileName) {
return zeus::Media::create(etk::Uri("file:///" + _fileName));
}
ememory::SharedPtr<zeus::Media> zeus::Media::create(etk::Path _path) {
return zeus::Media::create(etk::Uri("file:///" + _path.getString()));
}
ememory::SharedPtr<zeus::Media> zeus::Media::create(etk::Uri _uri) {
return ememory::makeShared<zeus::MediaImpl>(0, _uri);
}
ejson::Object zeus::MediaImpl::getJson() {
ejson::Object out;
out.add("id", ejson::Number(m_id));
@ -33,7 +40,7 @@ ejson::Object zeus::MediaImpl::getJson() {
return out;
}
zeus::MediaImpl::MediaImpl(const etk::String& _basePath, ejson::Object _property) :
zeus::MediaImpl::MediaImpl(const etk::Uri& _basePath, ejson::Object _property) :
m_basePath(_basePath) {
ZEUS_ERROR(" ==============>>>>>>>>>>>>>> CREATE MEDIA");
m_id = _property["id"].toNumber().getU64();
@ -54,17 +61,13 @@ uint64_t zeus::MediaImpl::getUniqueId() {
return m_id;
}
zeus::MediaImpl::MediaImpl(uint64_t _id, const etk::String& _fileNameReal, const etk::String& _basePath):
zeus::MediaImpl::MediaImpl(uint64_t _id, const etk::Uri& _basePath, const etk::String& _fileNameReal):
m_id(_id),
m_basePath(_basePath),
m_fileName(_fileNameReal) {
ZEUS_ERROR(" ==============>>>>>>>>>>>>>> CREATE MEDIA");
etk::String extention;
if ( m_fileName.rfind('.') != etk::String::npos
&& m_fileName.rfind('.') != 0) {
extention = etk::toLower(etk::String(m_fileName.begin()+m_fileName.rfind('.')+1, m_fileName.end()));
m_fileName = etk::String(m_fileName.begin(), m_fileName.begin()+m_fileName.rfind('.'));
}
etk::String extention = etk::toLower(m_basePath.getPath().getExtention());
m_fileName = m_basePath.getPath().getFileName();
if (extention != "") {
setMetadata("mime-type", zeus::getMineType(extention));
//m_creationData = echrono::Time::now();
@ -73,7 +76,7 @@ zeus::MediaImpl::MediaImpl(uint64_t _id, const etk::String& _fileNameReal, const
zeus::MediaImpl::~MediaImpl() {
ZEUS_ERROR(" <<<<<<<<<<<<<<============== DESTROY MEDIA");
}
etk::String zeus::MediaImpl::getMineType() {
@ -90,9 +93,9 @@ etk::String zeus::MediaImpl::getSha512() {
etk::String sha512;
auto it = m_metadata.find("mime-type");
if (it != m_metadata.end()) {
sha512 = algue::stringConvert(algue::sha512::encodeFromFile(m_basePath + m_fileName + "." + zeus::getExtention(it->second)));
sha512 = algue::stringConvert(algue::sha512::encodeFromFile(m_basePath / (m_fileName + "." + zeus::getExtention(it->second))));
} else {
sha512 = algue::stringConvert(algue::sha512::encodeFromFile(m_basePath + m_fileName));
sha512 = algue::stringConvert(algue::sha512::encodeFromFile(m_basePath / m_fileName));
}
setMetadata("sha512", sha512);
return sha512;
@ -123,10 +126,10 @@ etk::String zeus::MediaImpl::getDecoratedName() {
ememory::SharedPtr<zeus::File> zeus::MediaImpl::getFile() {
auto it = m_metadata.find("mime-type");
if (it != m_metadata.end()) {
return zeus::File::create(m_basePath + m_fileName + "." + zeus::getExtention(it->second), "", it->second, getSha512());
return zeus::File::create(m_basePath / (m_fileName + "." + zeus::getExtention(it->second)), "", it->second, getSha512());
}
// no mimetype specify ... ==> theoric impossible case ...
return zeus::File::create(m_basePath + m_fileName, "", "");
return zeus::File::create(m_basePath / m_fileName, "", "");
}
etk::Vector<etk::String> zeus::MediaImpl::getMetadataKeys() {
@ -170,26 +173,26 @@ void zeus::MediaImpl::setMetadata(etk::String _key, etk::String _value) {
bool zeus::MediaImpl::erase() {
auto it = m_metadata.find("mime-type");
if (it != m_metadata.end()) {
return etk::FSNodeRemove(m_basePath + m_fileName + "." + zeus::getExtention(it->second));
return etk::uri::remove(m_basePath / (m_fileName + "." + zeus::getExtention(it->second)));
}
return etk::FSNodeRemove(m_basePath + m_fileName);
return etk::uri::remove(m_basePath / m_fileName);
}
bool zeus::MediaImpl::move(const etk::String& _newOffsetFile) {
ZEUS_INFO("move file : '" << m_basePath + m_fileName << "' ==> " << m_basePath + _newOffsetFile << "'");
ZEUS_INFO("move file : '" << m_basePath / m_fileName << "' ==> " << m_basePath / _newOffsetFile << "'");
if (_newOffsetFile == m_fileName) {
// nothing to do ...
return true;
}
auto it = m_metadata.find("mime-type");
if (it != m_metadata.end()) {
bool ret = etk::FSNodeMove(m_basePath + m_fileName + "." + zeus::getExtention(it->second), m_basePath + _newOffsetFile + "." + zeus::getExtention(it->second));
bool ret = etk::uri::move(m_basePath / m_fileName + "." + zeus::getExtention(it->second), m_basePath / (_newOffsetFile + "." + zeus::getExtention(it->second)));
if (ret == true) {
m_fileName = _newOffsetFile;
}
return ret;
}
bool ret = etk::FSNodeMove(m_basePath + m_fileName, m_basePath + _newOffsetFile);
bool ret = etk::uri::move(m_basePath / m_fileName, m_basePath / _newOffsetFile);
if (ret == true) {
m_fileName = _newOffsetFile;
}

View File

@ -6,7 +6,6 @@
#pragma once
#include <zeus/Media.hpp>
#include <etk/os/FSNode.hpp>
#include <echrono/Time.hpp>
#include <ejson/ejson.hpp>
@ -14,7 +13,7 @@ namespace zeus {
class MediaImpl : public zeus::Media {
private:
uint64_t m_id; //!< use local reference ID to have faster access on the file ...
etk::String m_basePath; //!< basic global path
etk::Uri m_basePath; //!< basic global path
etk::String m_fileName; //!< Name of the file
etk::Map<etk::String, etk::String> m_metadata; //!< all extra property
etk::Function<void(zeus::MediaImpl*, const etk::String& )> m_callback;
@ -26,11 +25,11 @@ namespace zeus {
/**
* @brief Generic json constructor
*/
MediaImpl(const etk::String& _basePath, ejson::Object _property);
MediaImpl(const etk::Uri& _basePath, ejson::Object _property);
/**
* @brief Generic file constructor
*/
MediaImpl(uint64_t _id, const etk::String& _fileNameReal, const etk::String& _basePath="");
MediaImpl(uint64_t _id, const etk::Uri& _basePath, const etk::String& _fileNameReal = "");
/**
* @brief Generic destructor
*/

View File

@ -13,6 +13,14 @@ import zeus-File
#param:fileName:Name of the local file to instanciate.
[factory] create(string)
#brief:Factory to create a local object.
#param:path:Name of the file path to instanciate.
[factory] create(path)
#brief:Factory to create a local object.
#param:uri:Name of the file uri to instanciate.
[factory] create(uri)
#brief:Get the book unique Id of the server+user
#return:The UID requested
uint64 getUniqueId()