From 3fd99a2f5a406fb8a52507814111d57fca1c6b5f Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Tue, 25 Apr 2017 22:16:15 +0200 Subject: [PATCH] [DEV] set work on android --- tools/player-video/appl/ClientProperty.cpp | 94 +++++++++---------- tools/player-video/appl/ClientProperty.hpp | 17 ++-- tools/player-video/appl/Main.cpp | 7 +- tools/player-video/appl/MediaDecoder.cpp | 6 +- tools/player-video/appl/Windows.cpp | 11 ++- tools/player-video/appl/Windows.hpp | 1 + tools/player-video/appl/widget/Connection.cpp | 3 +- tools/player-video/appl/widget/Connection.hpp | 3 +- tools/player-video/appl/widget/ListViewer.cpp | 6 +- tools/player-video/lutin_zeus-player-video.py | 5 + 10 files changed, 90 insertions(+), 63 deletions(-) diff --git a/tools/player-video/appl/ClientProperty.cpp b/tools/player-video/appl/ClientProperty.cpp index 80f5fa0..c8dcb43 100644 --- a/tools/player-video/appl/ClientProperty.cpp +++ b/tools/player-video/appl/ClientProperty.cpp @@ -27,78 +27,78 @@ #include 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 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 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 diff --git a/tools/player-video/appl/ClientProperty.hpp b/tools/player-video/appl/ClientProperty.hpp index 15eff13..a1ec320 100644 --- a/tools/player-video/appl/ClientProperty.hpp +++ b/tools/player-video/appl/ClientProperty.hpp @@ -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(); diff --git a/tools/player-video/appl/Main.cpp b/tools/player-video/appl/Main.cpp index 6bafaae..b430da5 100644 --- a/tools/player-video/appl/Main.cpp +++ b/tools/player-video/appl/Main.cpp @@ -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()); diff --git a/tools/player-video/appl/MediaDecoder.cpp b/tools/player-video/appl/MediaDecoder.cpp index 4efab01..b06ee46 100644 --- a/tools/player-video/appl/MediaDecoder.cpp +++ b/tools/player-video/appl/MediaDecoder.cpp @@ -362,16 +362,16 @@ void appl::MediaDecoder::init(ememory::SharedPtr _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'"); diff --git a/tools/player-video/appl/Windows.cpp b/tools/player-video/appl/Windows.cpp index 197a9a7..2d42251 100644 --- a/tools/player-video/appl/Windows.cpp +++ b/tools/player-video/appl/Windows.cpp @@ -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::SharedPtrsearchElements(); } } +void appl::Windows::onCallbackConnectionError(const ememory::SharedPtr& _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 ... diff --git a/tools/player-video/appl/Windows.hpp b/tools/player-video/appl/Windows.hpp index 24448d2..2517935 100644 --- a/tools/player-video/appl/Windows.hpp +++ b/tools/player-video/appl/Windows.hpp @@ -37,6 +37,7 @@ namespace appl { void onCallbackConnectionValidate(const ememory::SharedPtr& _prop); + void onCallbackConnectionError(const ememory::SharedPtr& _prop); void onCallbackConnectionCancel(); void onCallbackShortCut(const std::string& _value); diff --git a/tools/player-video/appl/widget/Connection.cpp b/tools/player-video/appl/widget/Connection.cpp index d6f2150..a8471e8 100644 --- a/tools/player-video/appl/widget/Connection.cpp +++ b/tools/player-video/appl/widget/Connection.cpp @@ -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
'" + m_baseProperty->getLogin() + "'"); + signalConnectionError.emit(m_baseProperty); } else { APPL_INFO(" ==> Authentify with '" << m_baseProperty->getLogin() << "'"); signalValidate.emit(m_baseProperty); diff --git a/tools/player-video/appl/widget/Connection.hpp b/tools/player-video/appl/widget/Connection.hpp index 7458237..3955487 100644 --- a/tools/player-video/appl/widget/Connection.hpp +++ b/tools/player-video/appl/widget/Connection.hpp @@ -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> signalValidate; //!< select file(s) + esignal::Signal> signalValidate; //!< select a connection valid + esignal::Signal> signalConnectionError; //!< Error on connection protected: ememory::SharedPtr m_baseProperty; std::string m_login; diff --git a/tools/player-video/appl/widget/ListViewer.cpp b/tools/player-video/appl/widget/ListViewer.cpp index 4d58e76..70a6829 100644 --- a/tools/player-video/appl/widget/ListViewer.cpp +++ b/tools/player-video/appl/widget/ListViewer.cpp @@ -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'"); diff --git a/tools/player-video/lutin_zeus-player-video.py b/tools/player-video/lutin_zeus-player-video.py index 61c66fe..eb05594 100644 --- a/tools/player-video/lutin_zeus-player-video.py +++ b/tools/player-video/lutin_zeus-player-video.py @@ -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