From f4a41e57e92777e56ec74e90be8dc73a301cd71e Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Tue, 11 Apr 2017 22:05:13 +0200 Subject: [PATCH] [DEV] add a remote to stop or restart a personal server --- lutinParseSubFolders.txt | 1 + tools/package-base/lutin_zeus-package-base.py | 1 + tools/server-remote/appl/ClientProperty.cpp | 153 +++++++++++++ tools/server-remote/appl/ClientProperty.hpp | 32 +++ tools/server-remote/appl/Main.cpp | 61 ++++++ tools/server-remote/appl/Main.hpp | 7 + tools/server-remote/appl/Windows.cpp | 206 ++++++++++++++++++ tools/server-remote/appl/Windows.hpp | 35 +++ tools/server-remote/appl/debug.cpp | 13 ++ tools/server-remote/appl/debug.hpp | 37 ++++ .../server-remote/appl/widget/Connection.cpp | 98 +++++++++ .../server-remote/appl/widget/Connection.hpp | 88 ++++++++ tools/server-remote/authors.txt | 1 + tools/server-remote/data/gui-connection.xml | 14 ++ tools/server-remote/data/gui.xml | 10 + .../server-remote/lutin_zeus-server-remote.py | 51 +++++ tools/server-remote/version.txt | 1 + tools/service-server/appl/debug.cpp | 12 + tools/service-server/appl/debug.hpp | 40 ++++ .../appl/main-service-server.cpp | 0 .../appl/zeus-service-server.srv.zeus.idl | 11 + .../lutin_zeus-service-server-impl.py | 46 ++++ .../lutin_zeus-service-server.py | 39 ++++ 23 files changed, 957 insertions(+) create mode 100644 tools/server-remote/appl/ClientProperty.cpp create mode 100644 tools/server-remote/appl/ClientProperty.hpp create mode 100644 tools/server-remote/appl/Main.cpp create mode 100644 tools/server-remote/appl/Main.hpp create mode 100644 tools/server-remote/appl/Windows.cpp create mode 100644 tools/server-remote/appl/Windows.hpp create mode 100644 tools/server-remote/appl/debug.cpp create mode 100644 tools/server-remote/appl/debug.hpp create mode 100644 tools/server-remote/appl/widget/Connection.cpp create mode 100644 tools/server-remote/appl/widget/Connection.hpp create mode 100644 tools/server-remote/authors.txt create mode 100644 tools/server-remote/data/gui-connection.xml create mode 100644 tools/server-remote/data/gui.xml create mode 100644 tools/server-remote/lutin_zeus-server-remote.py create mode 100644 tools/server-remote/version.txt create mode 100644 tools/service-server/appl/debug.cpp create mode 100644 tools/service-server/appl/debug.hpp create mode 100644 tools/service-server/appl/main-service-server.cpp create mode 100644 tools/service-server/appl/zeus-service-server.srv.zeus.idl create mode 100644 tools/service-server/lutin_zeus-service-server-impl.py create mode 100644 tools/service-server/lutin_zeus-service-server.py diff --git a/lutinParseSubFolders.txt b/lutinParseSubFolders.txt index 71a8ea0..aba48bd 100644 --- a/lutinParseSubFolders.txt +++ b/lutinParseSubFolders.txt @@ -3,6 +3,7 @@ tools/router tools/service-user tools/service-picture tools/service-video +tools/service-server tools/player-video tools/package-base tools/launcher diff --git a/tools/package-base/lutin_zeus-package-base.py b/tools/package-base/lutin_zeus-package-base.py index 67f2ad5..3aa21e1 100644 --- a/tools/package-base/lutin_zeus-package-base.py +++ b/tools/package-base/lutin_zeus-package-base.py @@ -28,6 +28,7 @@ def configure(target, my_module): 'zeus-service-user-impl', 'zeus-service-picture-impl', 'zeus-service-video-impl', + 'zeus-service-server-impl', 'zeus-launcher', ]) return True diff --git a/tools/server-remote/appl/ClientProperty.cpp b/tools/server-remote/appl/ClientProperty.cpp new file mode 100644 index 0000000..d1c36e6 --- /dev/null +++ b/tools/server-remote/appl/ClientProperty.cpp @@ -0,0 +1,153 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2016, Edouard DUPIN, all right reserved + * @license GPL v3 (see license file) + */ + +#include +#include + + + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +appl::ClientProperty::ClientProperty() { + address = "127.0.0.1"; + 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)); + 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(); +} + +void appl::ClientProperty::connect() { + if (connection.isAlive() == true) { + connection.pingIsAlive(); + if (connection.isAlive() == true) { + return; + } + } + // Generate IP and Port in the client interface + if (address == "") { + connection.propertyIp.set("127.0.0.1"); + } else { + connection.propertyIp.set(address); + } + if (port == 0) { + connection.propertyPort.set(1983); + } else { + connection.propertyPort.set(port); + } + // Connection depending on the mode requested + if (fromUser == toUser) { + bool ret = connection.connect(fromUser, pass); + if (ret == false) { + APPL_ERROR(" ==> NOT Authentify with '" << toUser << "'"); + return; + } else { + APPL_INFO(" ==> Authentify with '" << toUser << "'"); + } + } else if (fromUser != "") { + bool ret = connection.connect(fromUser, toUser, pass); + if (ret == false) { + APPL_ERROR(" ==> NOT Connected to '" << toUser << "' with '" << fromUser << "'"); + return; + } else { + APPL_INFO(" ==> Connected with '" << toUser << "' with '" << fromUser << "'"); + } + } else { + bool ret = connection.connect(toUser); + if (ret == false) { + APPL_ERROR(" ==> NOT Connected with 'anonymous' to '" << toUser << "'"); + return; + } else { + APPL_INFO(" ==> Connected with 'anonymous' to '" << toUser << "'"); + } + } +} + +void appl::ClientProperty::setLogin(std::string _login) { + fromUser = ""; + toUser = ""; + // separate loggin and IP adress ... + std::string login; + std::vector listElem = etk::split(_login, '~'); + if (listElem.size() == 0) { + APPL_ERROR("Not enouth element in the login ..."); + return; + } + fromUser = listElem[0]; + toUser = listElem[0]; + 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]; + } + if (listElem2.size() >= 2) { + port = etk::string_to_uint32_t(listElem2[1]); + } + } +} + +std::string appl::ClientProperty::getLogin() { + std::string out = fromUser; + bool hasTild = false; + if (address != "") { + if (hasTild == false) { + out += "~" ; + hasTild = true; + } + out += address; + } + if ( port != 1983 + && port != 0) { + if (hasTild == false) { + out += "~" ; + hasTild = true; + } + out += ":" + etk::to_string(port); + } + return out; +} + +void appl::ClientProperty::setPassword(std::string _password) { + pass = _password; +} + +std::string appl::ClientProperty::getPassword() { + return pass; +} + +#include +ESIGNAL_DECLARE_SIGNAL(ememory::SharedPtr); + diff --git a/tools/server-remote/appl/ClientProperty.hpp b/tools/server-remote/appl/ClientProperty.hpp new file mode 100644 index 0000000..56757f5 --- /dev/null +++ b/tools/server-remote/appl/ClientProperty.hpp @@ -0,0 +1,32 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2016, Edouard DUPIN, all right reserved + * @license GPL v3 (see license file) + */ + +#pragma once + +#include +#include + +namespace appl { + class ClientProperty { + public: + std::string fromUser; + std::string toUser; + std::string pass; + std::string address; + uint16_t port; + zeus::Client connection; + ClientProperty(); + void connect(); + void disconnect(); + ejson::Object toJson(); + void fromJson(ejson::Object _obj); + void setLogin(std::string _login); + std::string getLogin(); + void setPassword(std::string _password); + std::string getPassword(); + }; +} + diff --git a/tools/server-remote/appl/Main.cpp b/tools/server-remote/appl/Main.cpp new file mode 100644 index 0000000..52ef39e --- /dev/null +++ b/tools/server-remote/appl/Main.cpp @@ -0,0 +1,61 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2016, Edouard DUPIN, all right reserved + * @license GPL v3 (see license file) + */ + +#include +#include +#include + + +#include +#include +#include +#include +#include +#include + +namespace appl { + class MainApplication : public ewol::context::Application { + public: + void onCreate(ewol::Context& _context) override { + APPL_INFO("==> CREATE ... " PROJECT_NAME " (BEGIN)"); + localCreate(_context); + APPL_INFO("==> CREATE ... " PROJECT_NAME " (END)"); + } + void localCreate(ewol::Context& _context) { + // parse all the argument of the application + for (int32_t iii=0 ; iii<_context.getCmd().size(); iii++) { + std::string tmpppp = _context.getCmd().get(iii); + if ( tmpppp == "-h" + || tmpppp == "--help") { + APPL_INFO(" -h/--help display this help" ); + exit(0); + } + } + // TODO : Remove this: Move if in the windows properties + _context.setSize(vec2(800, 600)); + // 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", 19); + // Create the windows + ememory::SharedPtr basicWindows = appl::Windows::create(); + // configure the ewol context to use the new windows + _context.setWindows(basicWindows); + } + }; +} + +/** + * @brief Main of the program (This can be set in every case, but it is not used in Andoid...). + * @param std IO + * @return std IO + */ +int main(int _argc, const char *_argv[]) { + audio::river::init(); + zeus::init(_argc, _argv); + return ewol::run(new appl::MainApplication(), _argc, _argv); +} + diff --git a/tools/server-remote/appl/Main.hpp b/tools/server-remote/appl/Main.hpp new file mode 100644 index 0000000..18cf43c --- /dev/null +++ b/tools/server-remote/appl/Main.hpp @@ -0,0 +1,7 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2016, Edouard DUPIN, all right reserved + * @license GPL v3 (see license file) + */ +#pragma once + diff --git a/tools/server-remote/appl/Windows.cpp b/tools/server-remote/appl/Windows.cpp new file mode 100644 index 0000000..1632f56 --- /dev/null +++ b/tools/server-remote/appl/Windows.cpp @@ -0,0 +1,206 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2016, Edouard DUPIN, all right reserved + * @license GPL v3 (see license file) + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +static std::string g_baseDBName = "USERDATA:config.json"; + +void appl::Windows::store_db() { + APPL_DEBUG("Store database [START]"); + ejson::Document database; + if (m_clientProp != nullptr) { + database.add("access", m_clientProp->toJson()); + } + bool retGenerate = database.storeSafe(g_baseDBName); + APPL_ERROR("Store database [STOP] : " << (g_baseDBName) << " ret = " << retGenerate); +} + +void appl::Windows::load_db() { + ejson::Document database; + bool ret = database.load(g_baseDBName); + if (ret == false) { + APPL_WARNING(" ==> LOAD error"); + } + if (m_clientProp == nullptr) { + m_clientProp = ememory::makeShared(); + if (m_clientProp == nullptr) { + APPL_ERROR(" can not allocate the pointer of data ==> must auto kill"); + autoDestroy(); + return; + } + } + if (m_clientProp != nullptr) { + m_clientProp->fromJson(database["access"].toObject()); + } +} + + +appl::Windows::Windows() { + addObjectType("appl::Windows"); + propertyTitle.setDirectCheck(PROJECT_NAME); +} + +void appl::Windows::init() { + ewol::widget::Windows::init(); + load_db(); + m_composer = ewol::widget::Composer::create(); + if (m_composer == nullptr) { + APPL_CRITICAL(" An error occured ... in the windows creatrion ..."); + return; + } + m_composer->loadFromFile("DATA:gui.xml"); + setSubWidget(m_composer); + + subBind(ewol::widget::Button, "appl-shutdown", signalPressed, sharedFromThis(), &appl::Windows::onCallbackShutdown); + subBind(ewol::widget::Button, "appl-reboot", signalPressed, sharedFromThis(), &appl::Windows::onCallbackReboot); + + // Direct display list: + ewol::propertySetOnObjectNamed("view-selection", "select", "ws-name-list-viewer"); + subBind(ewol::widget::Menu, "menu-bar", signalSelect, sharedFromThis(), &appl::Windows::onCallbackMenuEvent); + shortCutAdd("alt+F4", "menu:exit"); + shortCutAdd("F12", "menu:reload-shader"); + shortCutAdd("F11", "menu:connect"); + signalShortcut.connect(sharedFromThis(), &appl::Windows::onCallbackShortCut); + // TODO: try to connect the last connection availlable ... + if (m_clientProp == nullptr) { + onCallbackMenuEvent("menu:connect"); + } else { + m_clientProp->connect(); + if (m_clientProp->connection.isAlive() == false) { + onCallbackMenuEvent("menu:connect"); + } + } +} + + +void appl::Windows::onCallbackShortCut(const std::string& _value) { + APPL_WARNING("Event from ShortCut : " << _value); + onCallbackMenuEvent(_value); +} + +void appl::Windows::onCallbackMenuEvent(const std::string& _value) { + APPL_WARNING("Event from Menu : " << _value); + if (_value == "menu:connect") { + appl::widget::ConnectionShared tmpWidget = appl::widget::Connection::create(); + if (tmpWidget == nullptr) { + APPL_ERROR("Can not open File chooser !!! "); + return; + } + tmpWidget->setProperty(m_clientProp); + // register on the Validate event: + tmpWidget->signalValidate.connect(sharedFromThis(), &appl::Windows::onCallbackConnectionValidate); + // no need of this event watching ... + tmpWidget->signalCancel.connect(sharedFromThis(), &appl::Windows::onCallbackConnectionCancel); + // add the widget as windows pop-up ... + popUpWidgetPush(tmpWidget); + } else if (_value == "menu:exit") { + gale::getContext().stop(); + } else if (_value == "menu:reload-shader") { + ewol::getContext().getResourcesManager().reLoadResources(); + ewol::getContext().forceRedrawAll(); + } else { + APPL_ERROR("Event from Menu UNKNOW : '" << _value << "'"); + } +} + +void appl::Windows::onCallbackConnectionValidate(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 ... + +} + +void appl::Windows::onCallbackReboot() { + if (m_clientProp == nullptr) { + onCallbackMenuEvent("menu:connect"); + return; + } + m_clientProp->connect(); + if (m_clientProp->connection.isAlive() == false) { + onCallbackMenuEvent("menu:connect"); + return; + } + + bool retSrv = m_clientProp->connection.waitForService("server"); + if (retSrv == false) { + APPL_ERROR(" ==> SERVICE not availlable or not started"); + return; + } + // get all the data: + zeus::service::ProxyServer remoteService = m_clientProp->connection.getService("server"); + // remove all media (for test) + if (remoteService.exist() == false) { + APPL_ERROR(" ==> Service does not exist : 'server'"); + return; + } + zeus::Future listElem = remoteService.reboot().wait(); + if (listElem.hasError() == true) { + popUpWidgetPush(ewol::widget::StdPopUp::create("title", std::string("Error occured"), + "comment", std::string("Reboot can not be done"))); + } +} + +void appl::Windows::onCallbackShutdown() { + if (m_clientProp == nullptr) { + onCallbackMenuEvent("menu:connect"); + return; + } + m_clientProp->connect(); + if (m_clientProp->connection.isAlive() == false) { + onCallbackMenuEvent("menu:connect"); + return; + } + + bool retSrv = m_clientProp->connection.waitForService("server"); + if (retSrv == false) { + APPL_ERROR(" ==> SERVICE not availlable or not started"); + return; + } + // get all the data: + zeus::service::ProxyServer remoteService = m_clientProp->connection.getService("server"); + // remove all media (for test) + if (remoteService.exist() == false) { + APPL_ERROR(" ==> Service does not exist : 'server'"); + return; + } + zeus::Future listElem = remoteService.shutdown().wait(); + if (listElem.hasError() == true) { + popUpWidgetPush(ewol::widget::StdPopUp::create("title", std::string("Error occured"), + "comment", std::string("Reboot can not be done"))); + } +} + + + diff --git a/tools/server-remote/appl/Windows.hpp b/tools/server-remote/appl/Windows.hpp new file mode 100644 index 0000000..4f05706 --- /dev/null +++ b/tools/server-remote/appl/Windows.hpp @@ -0,0 +1,35 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2016, Edouard DUPIN, all right reserved + * @license GPL v3 (see license file) + */ +#pragma once + +#include +#include + +namespace appl { + class Windows; + using WindowsShared = ememory::SharedPtr; + using WindowsWeak = ememory::WeakPtr; + class Windows : public ewol::widget::Windows { + protected: + Windows(); + void init(); + ewol::widget::ComposerShared m_composer; + ememory::SharedPtr m_clientProp; + public: + DECLARE_FACTORY(Windows); + public: // callback functions + void onCallbackReboot(); + void onCallbackShutdown(); + void load_db(); + void store_db(); + + void onCallbackConnectionValidate(const ememory::SharedPtr& _prop); + void onCallbackConnectionCancel(); + void onCallbackShortCut(const std::string& _value); + void onCallbackMenuEvent(const std::string& _value); + }; +} + diff --git a/tools/server-remote/appl/debug.cpp b/tools/server-remote/appl/debug.cpp new file mode 100644 index 0000000..685fb92 --- /dev/null +++ b/tools/server-remote/appl/debug.cpp @@ -0,0 +1,13 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2016, Edouard DUPIN, all right reserved + * @license GPL v3 (see license file) + */ + + +#include + +int32_t appl::getLogId() { + static int32_t g_val = elog::registerInstance("zeus-server-remote"); + return g_val; +} diff --git a/tools/server-remote/appl/debug.hpp b/tools/server-remote/appl/debug.hpp new file mode 100644 index 0000000..1eff520 --- /dev/null +++ b/tools/server-remote/appl/debug.hpp @@ -0,0 +1,37 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2016, Edouard DUPIN, all right reserved + * @license GPL v3 (see license file) + */ +#pragma once + +#include + +namespace appl { + int32_t getLogId(); +}; +#define APPL_BASE(info,data) ELOG_BASE(appl::getLogId(),info,data) + +#define APPL_PRINT(data) APPL_BASE(-1, data) +#define APPL_CRITICAL(data) APPL_BASE(1, data) +#define APPL_ERROR(data) APPL_BASE(2, data) +#define APPL_WARNING(data) APPL_BASE(3, data) +#ifdef DEBUG + #define APPL_INFO(data) APPL_BASE(4, data) + #define APPL_DEBUG(data) APPL_BASE(5, data) + #define APPL_VERBOSE(data) APPL_BASE(6, data) + #define APPL_TODO(data) APPL_BASE(4, "TODO : " << data) +#else + #define APPL_INFO(data) do { } while(false) + #define APPL_DEBUG(data) do { } while(false) + #define APPL_VERBOSE(data) do { } while(false) + #define APPL_TODO(data) do { } while(false) +#endif + +#define APPL_ASSERT(cond,data) \ + do { \ + if (!(cond)) { \ + APPL_CRITICAL(data); \ + assert(!#cond); \ + } \ + } while (0) diff --git a/tools/server-remote/appl/widget/Connection.cpp b/tools/server-remote/appl/widget/Connection.cpp new file mode 100644 index 0000000..d6f2150 --- /dev/null +++ b/tools/server-remote/appl/widget/Connection.cpp @@ -0,0 +1,98 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2011, Edouard DUPIN, all right reserved + * @license MPL v2.0 (see license file) + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//#include +#include +#include +#include + +#include +#include + +appl::widget::Connection::Connection() : + signalCancel(this, "cancel", ""), + signalValidate(this, "validate", "") { + addObjectType("appl::widget::Connection"); +} + +void appl::widget::Connection::init() { + ewol::widget::Composer::init(); + loadFromFile("DATA:gui-connection.xml", getId()); + subBind(ewol::widget::Entry, "[" + etk::to_string(getId()) + "]connect-login", signalModify, sharedFromThis(), &appl::widget::Connection::onCallbackEntryLoginChangeValue); + subBind(ewol::widget::Entry, "[" + etk::to_string(getId()) + "]connect-password", signalModify, sharedFromThis(), &appl::widget::Connection::onCallbackEntryPasswordChangeValue); + subBind(ewol::widget::Button, "[" + etk::to_string(getId()) + "]connect-bt", signalPressed, sharedFromThis(), &appl::widget::Connection::onCallbackButtonValidate); + subBind(ewol::widget::Button, "[" + etk::to_string(getId()) + "]cancel-bt", signalPressed, sharedFromThis(), &appl::widget::Connection::onCallbackButtonCancel); + setProperty(nullptr); + propertyCanFocus.set(true); +} + + +void appl::widget::Connection::setProperty(ememory::SharedPtr _baseProperty) { + m_baseProperty = _baseProperty; + if (m_baseProperty == nullptr) { + m_baseProperty = ememory::makeShared(); + if (m_baseProperty == nullptr) { + APPL_ERROR(" can not allocate the pointer of data ==> must auto kill"); + autoDestroy(); + return; + } + } + m_login = m_baseProperty->getLogin(); + m_password = m_baseProperty->getPassword(); + propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]connect-login", "value", m_login); + propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]connect-password", "value", m_password); +} + +void appl::widget::Connection::onGetFocus() { + // transfert focus on a specific widget... + propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]connect-login", "focus", "true"); +} + +appl::widget::Connection::~Connection() { + +} + +void appl::widget::Connection::onCallbackEntryLoginChangeValue(const std::string& _value) { + m_login = _value; +} + +void appl::widget::Connection::onCallbackEntryPasswordChangeValue(const std::string& _value) { + m_password = _value; +} + +void appl::widget::Connection::onCallbackButtonValidate() { + // ckeck if connection is valid ... + APPL_INFO("Connect with : '" << m_login << "' ... '" << m_password << "'"); + m_baseProperty->setLogin(m_login); + m_baseProperty->setPassword(m_password); + m_baseProperty->connect(); + if (m_baseProperty->connection.isAlive() == false) { + APPL_ERROR(" ==> NOT Authentify to '" << m_baseProperty->getLogin() << "'"); + ewol::tools::message::displayError("Can not connect the server with
'" + m_baseProperty->getLogin() + "'"); + } else { + APPL_INFO(" ==> Authentify with '" << m_baseProperty->getLogin() << "'"); + signalValidate.emit(m_baseProperty); + autoDestroy(); + } +} + +void appl::widget::Connection::onCallbackButtonCancel() { + signalCancel.emit(); + autoDestroy(); +} + diff --git a/tools/server-remote/appl/widget/Connection.hpp b/tools/server-remote/appl/widget/Connection.hpp new file mode 100644 index 0000000..7458237 --- /dev/null +++ b/tools/server-remote/appl/widget/Connection.hpp @@ -0,0 +1,88 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2011, Edouard DUPIN, all right reserved + * @license MPL v2.0 (see license file) + */ +#pragma once + +#include +#include +#include +#include +#include + +namespace appl { + namespace widget { + class Connection; + using ConnectionShared = ememory::SharedPtr; + using ConnectionWeak = ememory::WeakPtr; + /** + * @brief File Chooser is a simple selector of file for opening, saving, and what you want ... + * + * As all other pop-up methode ( wost case we can have) the creating is simple , but event back is not all the time simple: + * + * Fist global static declaration and inclusion: + * [code style=c++] + * #include + * [/code] + * + * The first step is to create the file chooser pop-up : (never in the constructor!!!) + * [code style=c++] + * appl::widget::ConnectionShared tmpWidget = appl::widget::Connection::create(); + * if (tmpWidget == nullptr) { + * APPL_ERROR("Can not open File chooser !!! "); + * return -1; + * } + * // register on the Validate event: + * tmpWidget->signalValidate.connect(sharedFromThis(), &****::onCallbackConnectionValidate); + * // no need of this event watching ... + * tmpWidget->signalCancel.connect(sharedFromThis(), &****::onCallbackConnectionCancel); + * // add the widget as windows pop-up ... + * ewol::widget::WindowsShared tmpWindows = getWindows(); + * if (tmpWindows == nullptr) { + * APPL_ERROR("Can not get the current windows !!! "); + * return -1; + * } + * tmpWindows->popUpWidgetPush(tmpWidget); + * [/code] + * + * Now we just need to wait the the open event message. + * + * [code style=c++] + * void ****::onCallbackConnectionValidate(const ememory::SharedPtr& _prop) { + * APPL_INFO("New connection : '" << _value << "'"); + * } + * void ****::onCallbackConnectionCancel() { + * APPL_INFO("cancel connection"); + * } + * [/code] + * This is the best example of a Meta-widget. + */ + 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) + protected: + ememory::SharedPtr m_baseProperty; + std::string m_login; + std::string m_password; + Connection(); + void init() override; + public: + DECLARE_WIDGET_FACTORY(Connection, "Connection"); + virtual ~Connection(); + void setProperty(ememory::SharedPtr _baseProperty=nullptr); + private: + std::string getCompleateFileName(); + void updateCurrentFolder(); + public: + void onGetFocus() override; + private: + // callback functions: + void onCallbackButtonValidate(); + void onCallbackButtonCancel(); + void onCallbackEntryLoginChangeValue(const std::string& _value); + void onCallbackEntryPasswordChangeValue(const std::string& _value); + }; + }; +}; diff --git a/tools/server-remote/authors.txt b/tools/server-remote/authors.txt new file mode 100644 index 0000000..07b1ab7 --- /dev/null +++ b/tools/server-remote/authors.txt @@ -0,0 +1 @@ +Edouard DUPIN \ No newline at end of file diff --git a/tools/server-remote/data/gui-connection.xml b/tools/server-remote/data/gui-connection.xml new file mode 100644 index 0000000..48ed91a --- /dev/null +++ b/tools/server-remote/data/gui-connection.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/tools/server-remote/data/gui.xml b/tools/server-remote/data/gui.xml new file mode 100644 index 0000000..0caf2ef --- /dev/null +++ b/tools/server-remote/data/gui.xml @@ -0,0 +1,10 @@ + + + + + + diff --git a/tools/server-remote/lutin_zeus-server-remote.py b/tools/server-remote/lutin_zeus-server-remote.py new file mode 100644 index 0000000..0e19a0e --- /dev/null +++ b/tools/server-remote/lutin_zeus-server-remote.py @@ -0,0 +1,51 @@ +#!/usr/bin/python +import lutin.tools as tools +import lutin.debug as debug +import os +import lutinLib_ffmpegCommon + +def get_type(): + #return "BINARY_SHARED" + return "BINARY" + +def get_desc(): + return "zeus server remote" + +def get_licence(): + return "GPL-3" + +def get_compagny_type(): + return "org" + +def get_compagny_name(): + return "atria-soft" + +def get_maintainer(): + return "authors.txt" + +def get_version(): + return "version.txt" + +def configure(target, my_module): + # add the file to compile: + my_module.add_src_file([ + 'appl/debug.cpp', + 'appl/Main.cpp', + 'appl/Windows.cpp', + 'appl/ClientProperty.cpp', + 'appl/widget/Connection.cpp', + ]) + my_module.add_depend([ + 'ewol', + 'zeus', + 'zeus-service-server', + ]) + my_module.add_flag('c++', [ + "-DPROJECT_NAME=\"\\\""+my_module.get_name()+"\\\"\"", + "-DAPPL_VERSION=\"\\\"" + tools.version_to_string(get_version()) + "\\\"\"", + ]) + my_module.copy_path('data/*') + my_module.add_path(".") + return True + + diff --git a/tools/server-remote/version.txt b/tools/server-remote/version.txt new file mode 100644 index 0000000..6c6aa7c --- /dev/null +++ b/tools/server-remote/version.txt @@ -0,0 +1 @@ +0.1.0 \ No newline at end of file diff --git a/tools/service-server/appl/debug.cpp b/tools/service-server/appl/debug.cpp new file mode 100644 index 0000000..74b5ce1 --- /dev/null +++ b/tools/service-server/appl/debug.cpp @@ -0,0 +1,12 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2016, Edouard DUPIN, all right reserved + * @license MPL v2.0 (see license file) + */ + +#include + +int32_t appl::getLogId() { + static int32_t g_val = elog::registerInstance("zeus-system-server"); + return g_val; +} diff --git a/tools/service-server/appl/debug.hpp b/tools/service-server/appl/debug.hpp new file mode 100644 index 0000000..70b9c0b --- /dev/null +++ b/tools/service-server/appl/debug.hpp @@ -0,0 +1,40 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2016, Edouard DUPIN, all right reserved + * @license MPL v2.0 (see license file) + */ +#pragma once + +#include + +namespace appl { + int32_t getLogId(); +}; + +#define APPL_BASE(info,data) ELOG_BASE(appl::getLogId(),info,data) + +#define APPL_PRINT(data) APPL_BASE(-1, data) +#define APPL_CRITICAL(data) APPL_BASE(1, data) +#define APPL_ERROR(data) APPL_BASE(2, data) +#define APPL_WARNING(data) APPL_BASE(3, data) +#ifdef DEBUG + #define APPL_INFO(data) APPL_BASE(4, data) + #define APPL_DEBUG(data) APPL_BASE(5, data) + #define APPL_VERBOSE(data) APPL_BASE(6, data) + #define APPL_TODO(data) APPL_BASE(4, "TODO : " << data) +#else + #define APPL_INFO(data) do { } while(false) + #define APPL_DEBUG(data) do { } while(false) + #define APPL_VERBOSE(data) do { } while(false) + #define APPL_TODO(data) do { } while(false) +#endif + +#define APPL_ASSERT(cond,data) \ + do { \ + if (!(cond)) { \ + APPL_CRITICAL(data); \ + assert(!#cond); \ + } \ + } while (0) + + diff --git a/tools/service-server/appl/main-service-server.cpp b/tools/service-server/appl/main-service-server.cpp new file mode 100644 index 0000000..e69de29 diff --git a/tools/service-server/appl/zeus-service-server.srv.zeus.idl b/tools/service-server/appl/zeus-service-server.srv.zeus.idl new file mode 100644 index 0000000..b0a1148 --- /dev/null +++ b/tools/service-server/appl/zeus-service-server.srv.zeus.idl @@ -0,0 +1,11 @@ +#elem-brief: server interface management +#elem-version: 0.1 +#elem-type:SERVER +#elem-author:Heero Yui + +#brief:Shutdown the server +void shutdown() + +#brief:Reboot the server +void reboot() + diff --git a/tools/service-server/lutin_zeus-service-server-impl.py b/tools/service-server/lutin_zeus-service-server-impl.py new file mode 100644 index 0000000..b7b099f --- /dev/null +++ b/tools/service-server/lutin_zeus-service-server-impl.py @@ -0,0 +1,46 @@ +#!/usr/bin/python +import lutin.debug as debug +import lutin.tools as tools +import os +import copy + + +def get_type(): + return "LIBRARY_DYNAMIC" + +def get_sub_type(): + return "TOOLS" + +def get_desc(): + return "ZEUS service server" + +def get_licence(): + return "MPL-2" + +def get_compagny_type(): + return "com" + +def get_compagny_name(): + return "atria-soft" + +def get_maintainer(): + return ["Mr DUPIN Edouard "] + +def configure(target, my_module): + my_module.add_path(".") + my_module.add_depend([ + 'zeus', + 'ejson', + 'zeus-service-server' + ]) + my_module.add_src_file([ + 'appl/debug.cpp', + 'appl/main-service-server.cpp' + ]) + + my_module.add_flag('c++', "-DSERVICE_NAME=\"\\\"server\\\"\"") + + return True + + + diff --git a/tools/service-server/lutin_zeus-service-server.py b/tools/service-server/lutin_zeus-service-server.py new file mode 100644 index 0000000..821af0c --- /dev/null +++ b/tools/service-server/lutin_zeus-service-server.py @@ -0,0 +1,39 @@ +#!/usr/bin/python +import lutin.debug as debug +import lutin.tools as tools +import lutin.macro as macro + + +def get_type(): + return "LIBRARY" + +def get_sub_type(): + return "TOOLS" + +def get_desc(): + return "ZEUS service server" + +def get_license(): + return "MPL-2" + +def get_compagny_type(): + return "com" + +def get_compagny_name(): + return "atria-soft" + +def get_maintainer(): + return ["Mr DUPIN Edouard "] + +def configure(target, my_module): + my_module.add_path(".") + my_module.add_depend([ + 'zeus' + ]) + zeus_macro = macro.load_macro('zeus') + zeus_macro.parse_object_idl(my_module, 'appl/zeus-service-server.srv.zeus.idl') + my_module.add_flag('c++', "-DSERVICE_NAME=\"\\\"server\\\"\"") + return True + + +