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

View File

@ -18,14 +18,19 @@
namespace appl {
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:
std::string fromUser;
std::string toUser;
std::string pass;
std::string address;
uint16_t port;
zeus::Client connection;
ClientProperty();
zeus::Client& getConnection() {
return m_connection;
};
void connect();
void disconnect();
ejson::Object toJson();

View File

@ -70,7 +70,12 @@ namespace appl {
// eneble the search of the font in the system font path
_context.getFontDefault().setUseExternal(true);
// 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:
appl::widget::VideoDisplay::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");
return;
}
if (_property->connection.isAlive() == false) {
if (_property->getConnection().isAlive() == false) {
APPL_ERROR("Request play of not connected handle ==> 'not alive'");
return;
}
bool retSrv = _property->connection.waitForService("video");
bool retSrv = _property->getConnection().waitForService("video");
if (retSrv == false) {
APPL_ERROR(" ==> SERVICE not availlable or not started");
return;
}
zeus::service::ProxyVideo remoteServiceVideo = _property->connection.getService("video");
zeus::service::ProxyVideo remoteServiceVideo = _property->getConnection().getService("video");
// remove all media (for test)
if (remoteServiceVideo.exist() == false) {
APPL_ERROR("Video service is ==> 'not alive'");

View File

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

View File

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

View File

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

View File

@ -61,7 +61,8 @@ namespace appl {
class Connection : public ewol::widget::Composer {
public: // signals
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:
ememory::SharedPtr<appl::ClientProperty> m_baseProperty;
std::string m_login;

View File

@ -80,18 +80,18 @@ void appl::widget::ListViewer::searchElementsInternal(const std::string& _filter
m_currentGroup = _group;
markToRedraw();
m_clientProp->connect();
if (m_clientProp->connection.isAlive() == false) {
if (m_clientProp->getConnection().isAlive() == false) {
APPL_ERROR("Conection is not alive anymore ...");
return;
}
bool retSrv = m_clientProp->connection.waitForService("video");
bool retSrv = m_clientProp->getConnection().waitForService("video");
if (retSrv == false) {
APPL_ERROR(" ==> SERVICE not availlable or not started");
return;
}
// 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)
if (remoteServiceVideo.exist() == false) {
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.add_path(".")
myModule.pkg_add("RIGHT", "SET_ORIENTATION")
myModule.pkg_add("RIGHT", "VIBRATE")
myModule.pkg_add("RIGHT", "INTERNET")
return True