[DEV] set work on android

This commit is contained in:
Edouard DUPIN 2017-04-25 22:16:15 +02:00
parent 2738f7d0e2
commit 3fd99a2f5a
10 changed files with 90 additions and 63 deletions

View File

@ -27,78 +27,78 @@
#include <ejson/ejson.hpp> #include <ejson/ejson.hpp>
appl::ClientProperty::ClientProperty() { appl::ClientProperty::ClientProperty() {
address = "127.0.0.1"; m_address = "127.0.0.1";
port = 1983; m_port = 1983;
} }
ejson::Object appl::ClientProperty::toJson() { ejson::Object appl::ClientProperty::toJson() {
ejson::Object out; ejson::Object out;
out.add("user", ejson::String(fromUser)); out.add("user", ejson::String(m_fromUser));
out.add("pass", ejson::String(pass)); out.add("pass", ejson::String(m_pass));
out.add("address", ejson::String(address)); out.add("address", ejson::String(m_address));
out.add("port", ejson::Number(port)); out.add("port", ejson::Number(m_port));
return out; return out;
} }
void appl::ClientProperty::fromJson(ejson::Object _obj) { void appl::ClientProperty::fromJson(ejson::Object _obj) {
fromUser = _obj["user"].toString().get(); m_fromUser = _obj["user"].toString().get();
toUser = fromUser; m_toUser = m_fromUser;
pass = _obj["pass"].toString().get(); m_pass = _obj["pass"].toString().get();
address = _obj["address"].toString().get(); m_address = _obj["address"].toString().get();
port = _obj["port"].toNumber().getU64(); m_port = _obj["port"].toNumber().getU64();
} }
void appl::ClientProperty::connect() { void appl::ClientProperty::connect() {
if (connection.isAlive() == true) { if (m_connection.isAlive() == true) {
connection.pingIsAlive(); m_connection.pingIsAlive();
if (connection.isAlive() == true) { if (m_connection.isAlive() == true) {
return; return;
} }
} }
// Generate IP and Port in the client interface // Generate IP and Port in the client interface
if (address == "") { if (m_address == "") {
connection.propertyIp.set("127.0.0.1"); m_connection.propertyIp.set("127.0.0.1");
} else { } else {
connection.propertyIp.set(address); m_connection.propertyIp.set(m_address);
} }
if (port == 0) { if (m_port == 0) {
connection.propertyPort.set(1983); m_connection.propertyPort.set(1983);
} else { } else {
connection.propertyPort.set(port); m_connection.propertyPort.set(m_port);
} }
// Connection depending on the mode requested // Connection depending on the mode requested
if (fromUser == toUser) { if (m_fromUser == m_toUser) {
bool ret = connection.connect(fromUser, pass); bool ret = m_connection.connect(m_fromUser, m_pass);
if (ret == false) { if (ret == false) {
APPL_ERROR(" ==> NOT Authentify with '" << toUser << "'"); APPL_ERROR(" ==> NOT Authentify with '" << m_toUser << "'");
return; return;
} else { } else {
APPL_INFO(" ==> Authentify with '" << toUser << "'"); APPL_INFO(" ==> Authentify with '" << m_toUser << "'");
} }
} else if (fromUser != "") { } else if (m_fromUser != "") {
bool ret = connection.connect(fromUser, toUser, pass); bool ret = m_connection.connect(m_fromUser, m_toUser, m_pass);
if (ret == false) { if (ret == false) {
APPL_ERROR(" ==> NOT Connected to '" << toUser << "' with '" << fromUser << "'"); APPL_ERROR(" ==> NOT Connected to '" << m_toUser << "' with '" << m_fromUser << "'");
return; return;
} else { } else {
APPL_INFO(" ==> Connected with '" << toUser << "' with '" << fromUser << "'"); APPL_INFO(" ==> Connected with '" << m_toUser << "' with '" << m_fromUser << "'");
} }
} else { } else {
bool ret = connection.connect(toUser); bool ret = m_connection.connect(m_toUser);
if (ret == false) { if (ret == false) {
APPL_ERROR(" ==> NOT Connected with 'anonymous' to '" << toUser << "'"); APPL_ERROR(" ==> NOT Connected with 'anonymous' to '" << m_toUser << "'");
return; return;
} else { } else {
APPL_INFO(" ==> Connected with 'anonymous' to '" << toUser << "'"); APPL_INFO(" ==> Connected with 'anonymous' to '" << m_toUser << "'");
} }
} }
} }
void appl::ClientProperty::setLogin(std::string _login) { void appl::ClientProperty::setLogin(std::string _login) {
fromUser = ""; m_fromUser = "";
toUser = ""; m_toUser = "";
address = ""; m_address = "";
port = 0; m_port = 0;
// separate loggin and IP adress ... // separate loggin and IP adress ...
std::string login; std::string login;
std::vector<std::string> listElem = etk::split(_login, '~'); std::vector<std::string> listElem = etk::split(_login, '~');
@ -106,48 +106,48 @@ void appl::ClientProperty::setLogin(std::string _login) {
APPL_ERROR("Not enouth element in the login ..."); APPL_ERROR("Not enouth element in the login ...");
return; return;
} }
fromUser = listElem[0]; m_fromUser = listElem[0];
toUser = listElem[0]; m_toUser = m_fromUser;
if (listElem.size() == 1) { if (listElem.size() == 1) {
// connnect on local host ... nothing to do // connnect on local host ... nothing to do
} else { } else {
std::vector<std::string> listElem2 = etk::split(listElem[1], ':'); std::vector<std::string> listElem2 = etk::split(listElem[1], ':');
if (listElem2.size() >= 1) { if (listElem2.size() >= 1) {
address = listElem2[0]; m_address = listElem2[0];
} }
if (listElem2.size() >= 2) { if (listElem2.size() >= 2) {
port = etk::string_to_uint32_t(listElem2[1]); m_port = etk::string_to_uint32_t(listElem2[1]);
} }
} }
} }
std::string appl::ClientProperty::getLogin() { std::string appl::ClientProperty::getLogin() {
std::string out = fromUser; std::string out = m_fromUser;
bool hasTild = false; bool hasTild = false;
if (address != "") { if (m_address != "") {
if (hasTild == false) { if (hasTild == false) {
out += "~" ; out += "~" ;
hasTild = true; hasTild = true;
} }
out += address; out += m_address;
} }
if ( port != 1983 if ( m_port != 1983
&& port != 0) { && m_port != 0) {
if (hasTild == false) { if (hasTild == false) {
out += "~" ; out += "~" ;
hasTild = true; hasTild = true;
} }
out += ":" + etk::to_string(port); out += ":" + etk::to_string(m_port);
} }
return out; return out;
} }
void appl::ClientProperty::setPassword(std::string _password) { void appl::ClientProperty::setPassword(std::string _password) {
pass = _password; m_pass = _password;
} }
std::string appl::ClientProperty::getPassword() { std::string appl::ClientProperty::getPassword() {
return pass; return m_pass;
} }
#include <esignal/details/Signal.hxx> #include <esignal/details/Signal.hxx>

View File

@ -18,14 +18,19 @@
namespace appl { namespace appl {
class ClientProperty { class ClientProperty {
protected:
std::string m_fromUser;
std::string m_toUser;
std::string m_pass;
std::string m_address;
uint16_t m_port;
zeus::Client m_connection;
public: public:
std::string fromUser;
std::string toUser;
std::string pass;
std::string address;
uint16_t port;
zeus::Client connection;
ClientProperty(); ClientProperty();
zeus::Client& getConnection() {
return m_connection;
};
void connect(); void connect();
void disconnect(); void disconnect();
ejson::Object toJson(); ejson::Object toJson();

View File

@ -70,7 +70,12 @@ namespace appl {
// eneble the search of the font in the system font path // eneble the search of the font in the system font path
_context.getFontDefault().setUseExternal(true); _context.getFontDefault().setUseExternal(true);
// select font preference of der with a basic application size // select font preference of der with a basic application size
_context.getFontDefault().set("DejaVuSerif;FreeSerif;DejaVuSansMono", 12);
#ifdef __TARGET_OS__Android
_context.getFontDefault().set("FreeSerif;DroidSans", 20);
#else
_context.getFontDefault().set("FreeSerif;DejaVuSerif;FreeSerif;DejaVuSansMono;DroidSans",12);
#endif
// set application widget: // set application widget:
appl::widget::VideoDisplay::createManagerWidget(_context.getWidgetManager()); appl::widget::VideoDisplay::createManagerWidget(_context.getWidgetManager());
appl::widget::ListViewer::createManagerWidget(_context.getWidgetManager()); appl::widget::ListViewer::createManagerWidget(_context.getWidgetManager());

View File

@ -362,16 +362,16 @@ void appl::MediaDecoder::init(ememory::SharedPtr<ClientProperty> _property, uint
APPL_ERROR("Request play of not handle property ==> nullptr"); APPL_ERROR("Request play of not handle property ==> nullptr");
return; return;
} }
if (_property->connection.isAlive() == false) { if (_property->getConnection().isAlive() == false) {
APPL_ERROR("Request play of not connected handle ==> 'not alive'"); APPL_ERROR("Request play of not connected handle ==> 'not alive'");
return; return;
} }
bool retSrv = _property->connection.waitForService("video"); bool retSrv = _property->getConnection().waitForService("video");
if (retSrv == false) { if (retSrv == false) {
APPL_ERROR(" ==> SERVICE not availlable or not started"); APPL_ERROR(" ==> SERVICE not availlable or not started");
return; return;
} }
zeus::service::ProxyVideo remoteServiceVideo = _property->connection.getService("video"); zeus::service::ProxyVideo remoteServiceVideo = _property->getConnection().getService("video");
// remove all media (for test) // remove all media (for test)
if (remoteServiceVideo.exist() == false) { if (remoteServiceVideo.exist() == false) {
APPL_ERROR("Video service is ==> 'not alive'"); APPL_ERROR("Video service is ==> 'not alive'");

View File

@ -99,7 +99,7 @@ void appl::Windows::init() {
onCallbackMenuEvent("menu:connect"); onCallbackMenuEvent("menu:connect");
} else { } else {
m_clientProp->connect(); m_clientProp->connect();
if (m_clientProp->connection.isAlive() == false) { if (m_clientProp->getConnection().isAlive() == false) {
onCallbackMenuEvent("menu:connect"); onCallbackMenuEvent("menu:connect");
} else { } else {
if (m_listViewer != nullptr) { if (m_listViewer != nullptr) {
@ -136,6 +136,7 @@ void appl::Windows::onCallbackMenuEvent(const std::string& _value) {
tmpWidget->setProperty(m_clientProp); tmpWidget->setProperty(m_clientProp);
// register on the Validate event: // register on the Validate event:
tmpWidget->signalValidate.connect(sharedFromThis(), &appl::Windows::onCallbackConnectionValidate); tmpWidget->signalValidate.connect(sharedFromThis(), &appl::Windows::onCallbackConnectionValidate);
tmpWidget->signalConnectionError.connect(sharedFromThis(), &appl::Windows::onCallbackConnectionError);
// no need of this event watching ... // no need of this event watching ...
tmpWidget->signalCancel.connect(sharedFromThis(), &appl::Windows::onCallbackConnectionCancel); tmpWidget->signalCancel.connect(sharedFromThis(), &appl::Windows::onCallbackConnectionCancel);
// add the widget as windows pop-up ... // add the widget as windows pop-up ...
@ -201,6 +202,14 @@ void appl::Windows::onCallbackConnectionValidate(const ememory::SharedPtr<Client
m_listViewer->searchElements(); m_listViewer->searchElements();
} }
} }
void appl::Windows::onCallbackConnectionError(const ememory::SharedPtr<ClientProperty>& _prop) {
m_clientProp = _prop;
if (m_clientProp == nullptr) {
// TODO: set back in public mode ...
return;
}
store_db();
}
void appl::Windows::onCallbackConnectionCancel() { void appl::Windows::onCallbackConnectionCancel() {
// TODO: set back in public mode ... // TODO: set back in public mode ...

View File

@ -37,6 +37,7 @@ namespace appl {
void onCallbackConnectionValidate(const ememory::SharedPtr<ClientProperty>& _prop); void onCallbackConnectionValidate(const ememory::SharedPtr<ClientProperty>& _prop);
void onCallbackConnectionError(const ememory::SharedPtr<ClientProperty>& _prop);
void onCallbackConnectionCancel(); void onCallbackConnectionCancel();
void onCallbackShortCut(const std::string& _value); void onCallbackShortCut(const std::string& _value);

View File

@ -81,9 +81,10 @@ void appl::widget::Connection::onCallbackButtonValidate() {
m_baseProperty->setLogin(m_login); m_baseProperty->setLogin(m_login);
m_baseProperty->setPassword(m_password); m_baseProperty->setPassword(m_password);
m_baseProperty->connect(); m_baseProperty->connect();
if (m_baseProperty->connection.isAlive() == false) { if (m_baseProperty->getConnection().isAlive() == false) {
APPL_ERROR(" ==> NOT Authentify to '" << m_baseProperty->getLogin() << "'"); APPL_ERROR(" ==> NOT Authentify to '" << m_baseProperty->getLogin() << "'");
ewol::tools::message::displayError("Can not connect the server with <br/>'" + m_baseProperty->getLogin() + "'"); ewol::tools::message::displayError("Can not connect the server with <br/>'" + m_baseProperty->getLogin() + "'");
signalConnectionError.emit(m_baseProperty);
} else { } else {
APPL_INFO(" ==> Authentify with '" << m_baseProperty->getLogin() << "'"); APPL_INFO(" ==> Authentify with '" << m_baseProperty->getLogin() << "'");
signalValidate.emit(m_baseProperty); signalValidate.emit(m_baseProperty);

View File

@ -61,7 +61,8 @@ namespace appl {
class Connection : public ewol::widget::Composer { class Connection : public ewol::widget::Composer {
public: // signals public: // signals
esignal::Signal<> signalCancel; //!< abort the display of the pop-up or press cancel button esignal::Signal<> signalCancel; //!< abort the display of the pop-up or press cancel button
esignal::Signal<ememory::SharedPtr<appl::ClientProperty>> signalValidate; //!< select file(s) esignal::Signal<ememory::SharedPtr<appl::ClientProperty>> signalValidate; //!< select a connection valid
esignal::Signal<ememory::SharedPtr<appl::ClientProperty>> signalConnectionError; //!< Error on connection
protected: protected:
ememory::SharedPtr<appl::ClientProperty> m_baseProperty; ememory::SharedPtr<appl::ClientProperty> m_baseProperty;
std::string m_login; std::string m_login;

View File

@ -80,18 +80,18 @@ void appl::widget::ListViewer::searchElementsInternal(const std::string& _filter
m_currentGroup = _group; m_currentGroup = _group;
markToRedraw(); markToRedraw();
m_clientProp->connect(); m_clientProp->connect();
if (m_clientProp->connection.isAlive() == false) { if (m_clientProp->getConnection().isAlive() == false) {
APPL_ERROR("Conection is not alive anymore ..."); APPL_ERROR("Conection is not alive anymore ...");
return; return;
} }
bool retSrv = m_clientProp->connection.waitForService("video"); bool retSrv = m_clientProp->getConnection().waitForService("video");
if (retSrv == false) { if (retSrv == false) {
APPL_ERROR(" ==> SERVICE not availlable or not started"); APPL_ERROR(" ==> SERVICE not availlable or not started");
return; return;
} }
// get all the data: // get all the data:
zeus::service::ProxyVideo remoteServiceVideo = m_clientProp->connection.getService("video"); zeus::service::ProxyVideo remoteServiceVideo = m_clientProp->getConnection().getService("video");
// remove all media (for test) // remove all media (for test)
if (remoteServiceVideo.exist() == false) { if (remoteServiceVideo.exist() == false) {
APPL_ERROR(" ==> Service does not exist : 'video'"); APPL_ERROR(" ==> Service does not exist : 'video'");

View File

@ -57,6 +57,11 @@ def configure(target, my_module):
]) ])
my_module.copy_path('data/*') my_module.copy_path('data/*')
my_module.add_path(".") my_module.add_path(".")
myModule.pkg_add("RIGHT", "SET_ORIENTATION")
myModule.pkg_add("RIGHT", "VIBRATE")
myModule.pkg_add("RIGHT", "INTERNET")
return True return True