[DEV] add a remote to stop or restart a personal server
This commit is contained in:
parent
746c8ceac4
commit
f4a41e57e9
@ -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
|
||||
|
@ -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
|
||||
|
153
tools/server-remote/appl/ClientProperty.cpp
Normal file
153
tools/server-remote/appl/ClientProperty.cpp
Normal file
@ -0,0 +1,153 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
* @license GPL v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <appl/debug.hpp>
|
||||
#include <ewol/widget/Widget.hpp>
|
||||
|
||||
|
||||
|
||||
#include <appl/ClientProperty.hpp>
|
||||
#include <appl/debug.hpp>
|
||||
#include <appl/widget/ListViewer.hpp>
|
||||
#include <ewol/object/Manager.hpp>
|
||||
#include <etk/tool.hpp>
|
||||
|
||||
#include <egami/egami.hpp>
|
||||
#include <zeus/zeus.hpp>
|
||||
#include <zeus/Client.hpp>
|
||||
#include <zeus/service/ProxyVideo.hpp>
|
||||
#include <zeus/ProxyFile.hpp>
|
||||
#include <zeus/ObjectRemote.hpp>
|
||||
#include <echrono/Steady.hpp>
|
||||
#include <zeus/FutureGroup.hpp>
|
||||
#include <etk/stdTools.hpp>
|
||||
#include <ejson/ejson.hpp>
|
||||
|
||||
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<std::string> 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<std::string> 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/details/Signal.hxx>
|
||||
ESIGNAL_DECLARE_SIGNAL(ememory::SharedPtr<appl::ClientProperty>);
|
||||
|
32
tools/server-remote/appl/ClientProperty.hpp
Normal file
32
tools/server-remote/appl/ClientProperty.hpp
Normal file
@ -0,0 +1,32 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
* @license GPL v3 (see license file)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <zeus/Client.hpp>
|
||||
#include <ejson/ejson.hpp>
|
||||
|
||||
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();
|
||||
};
|
||||
}
|
||||
|
61
tools/server-remote/appl/Main.cpp
Normal file
61
tools/server-remote/appl/Main.cpp
Normal file
@ -0,0 +1,61 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
* @license GPL v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <ewol/ewol.hpp>
|
||||
#include <gale/context/commandLine.hpp>
|
||||
|
||||
|
||||
#include <appl/debug.hpp>
|
||||
#include <appl/Windows.hpp>
|
||||
#include <ewol/object/Object.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
#include <ewol/context/Context.hpp>
|
||||
#include <zeus/zeus.hpp>
|
||||
|
||||
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<appl::Windows> 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);
|
||||
}
|
||||
|
7
tools/server-remote/appl/Main.hpp
Normal file
7
tools/server-remote/appl/Main.hpp
Normal file
@ -0,0 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
* @license GPL v3 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
206
tools/server-remote/appl/Windows.cpp
Normal file
206
tools/server-remote/appl/Windows.cpp
Normal file
@ -0,0 +1,206 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
* @license GPL v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <ewol/ewol.hpp>
|
||||
#include <appl/debug.hpp>
|
||||
#include <appl/Windows.hpp>
|
||||
#include <ewol/widget/Label.hpp>
|
||||
#include <ewol/widget/Button.hpp>
|
||||
#include <ewol/widget/Entry.hpp>
|
||||
#include <ewol/widget/Slider.hpp>
|
||||
#include <ewol/widget/Menu.hpp>
|
||||
#include <ewol/tools/message.hpp>
|
||||
|
||||
#include <zeus/zeus.hpp>
|
||||
#include <zeus/Client.hpp>
|
||||
#include <zeus/service/ProxyServer.hpp>
|
||||
#include <zeus/ProxyFile.hpp>
|
||||
#include <zeus/ObjectRemote.hpp>
|
||||
#include <echrono/Steady.hpp>
|
||||
#include <zeus/FutureGroup.hpp>
|
||||
#include <etk/stdTools.hpp>
|
||||
#include <ejson/ejson.hpp>
|
||||
#include <appl/widget/Connection.hpp>
|
||||
#include <ewol/context/Context.hpp>
|
||||
#include <appl/widget/meta/StdPopUp.hpp>
|
||||
|
||||
|
||||
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<appl::ClientProperty>();
|
||||
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<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 ...
|
||||
|
||||
}
|
||||
|
||||
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<void> 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<void> 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")));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
35
tools/server-remote/appl/Windows.hpp
Normal file
35
tools/server-remote/appl/Windows.hpp
Normal file
@ -0,0 +1,35 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
* @license GPL v3 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <ewol/widget/Windows.hpp>
|
||||
#include <ewol/widget/Composer.hpp>
|
||||
|
||||
namespace appl {
|
||||
class Windows;
|
||||
using WindowsShared = ememory::SharedPtr<appl::Windows>;
|
||||
using WindowsWeak = ememory::WeakPtr<appl::Windows>;
|
||||
class Windows : public ewol::widget::Windows {
|
||||
protected:
|
||||
Windows();
|
||||
void init();
|
||||
ewol::widget::ComposerShared m_composer;
|
||||
ememory::SharedPtr<ClientProperty> m_clientProp;
|
||||
public:
|
||||
DECLARE_FACTORY(Windows);
|
||||
public: // callback functions
|
||||
void onCallbackReboot();
|
||||
void onCallbackShutdown();
|
||||
void load_db();
|
||||
void store_db();
|
||||
|
||||
void onCallbackConnectionValidate(const ememory::SharedPtr<ClientProperty>& _prop);
|
||||
void onCallbackConnectionCancel();
|
||||
void onCallbackShortCut(const std::string& _value);
|
||||
void onCallbackMenuEvent(const std::string& _value);
|
||||
};
|
||||
}
|
||||
|
13
tools/server-remote/appl/debug.cpp
Normal file
13
tools/server-remote/appl/debug.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
* @license GPL v3 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#include <appl/debug.hpp>
|
||||
|
||||
int32_t appl::getLogId() {
|
||||
static int32_t g_val = elog::registerInstance("zeus-server-remote");
|
||||
return g_val;
|
||||
}
|
37
tools/server-remote/appl/debug.hpp
Normal file
37
tools/server-remote/appl/debug.hpp
Normal file
@ -0,0 +1,37 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
* @license GPL v3 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <elog/log.hpp>
|
||||
|
||||
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)
|
98
tools/server-remote/appl/widget/Connection.cpp
Normal file
98
tools/server-remote/appl/widget/Connection.cpp
Normal file
@ -0,0 +1,98 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#include <appl/widget/Connection.hpp>
|
||||
#include <ewol/widget/Sizer.hpp>
|
||||
#include <ewol/widget/List.hpp>
|
||||
#include <ewol/widget/Button.hpp>
|
||||
#include <ewol/widget/CheckBox.hpp>
|
||||
#include <ewol/widget/ListFileSystem.hpp>
|
||||
#include <ewol/widget/Entry.hpp>
|
||||
#include <ewol/widget/Spacer.hpp>
|
||||
#include <ewol/widget/Image.hpp>
|
||||
#include <ewol/widget/Composer.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
//#include <vector>
|
||||
#include <vector>
|
||||
#include <etk/tool.hpp>
|
||||
#include <appl/debug.hpp>
|
||||
|
||||
#include <ewol/ewol.hpp>
|
||||
#include <ewol/tools/message.hpp>
|
||||
|
||||
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<appl::ClientProperty> _baseProperty) {
|
||||
m_baseProperty = _baseProperty;
|
||||
if (m_baseProperty == nullptr) {
|
||||
m_baseProperty = ememory::makeShared<appl::ClientProperty>();
|
||||
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 <br/>'" + m_baseProperty->getLogin() + "'");
|
||||
} else {
|
||||
APPL_INFO(" ==> Authentify with '" << m_baseProperty->getLogin() << "'");
|
||||
signalValidate.emit(m_baseProperty);
|
||||
autoDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
void appl::widget::Connection::onCallbackButtonCancel() {
|
||||
signalCancel.emit();
|
||||
autoDestroy();
|
||||
}
|
||||
|
88
tools/server-remote/appl/widget/Connection.hpp
Normal file
88
tools/server-remote/appl/widget/Connection.hpp
Normal file
@ -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 <etk/types.hpp>
|
||||
#include <ewol/debug.hpp>
|
||||
#include <ewol/widget/Composer.hpp>
|
||||
#include <esignal/Signal.hpp>
|
||||
#include <appl/ClientProperty.hpp>
|
||||
|
||||
namespace appl {
|
||||
namespace widget {
|
||||
class Connection;
|
||||
using ConnectionShared = ememory::SharedPtr<appl::widget::Connection>;
|
||||
using ConnectionWeak = ememory::WeakPtr<appl::widget::Connection>;
|
||||
/**
|
||||
* @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 <appl/widget/Connection.hpp>
|
||||
* [/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<appl::ClientProperty>& _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<ememory::SharedPtr<appl::ClientProperty>> signalValidate; //!< select file(s)
|
||||
protected:
|
||||
ememory::SharedPtr<appl::ClientProperty> 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<appl::ClientProperty> _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);
|
||||
};
|
||||
};
|
||||
};
|
1
tools/server-remote/authors.txt
Normal file
1
tools/server-remote/authors.txt
Normal file
@ -0,0 +1 @@
|
||||
Edouard DUPIN <yui.heero@gmail.com>
|
14
tools/server-remote/data/gui-connection.xml
Normal file
14
tools/server-remote/data/gui-connection.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<PopUp >
|
||||
<sizer mode="vert" fill="true" expand="false" lock="true" addmode="invert" min-size="45,10%">
|
||||
<label>_T{Login}</label>
|
||||
<entry name="[{ID}]connect-login" fill="true,false" expand="true,false"/>
|
||||
<label>_T{Password}</label>
|
||||
<entry name="[{ID}]connect-password" fill="true,false" expand="true,false"/>
|
||||
<button name="[{ID}]connect-bt" toggle="false" fill="false" expand="true,false" gravity="right">
|
||||
<label>_T{Connect}</label>
|
||||
</button>
|
||||
<button name="[{ID}]cancel-bt" toggle="false" fill="false" expand="true,false" gravity="right">
|
||||
<label>_T{Cancel}</label>
|
||||
</button>
|
||||
</sizer>
|
||||
</PopUp>
|
10
tools/server-remote/data/gui.xml
Normal file
10
tools/server-remote/data/gui.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<sizer mode="vert" fill="true" expand="true" addmode="invert">
|
||||
<button name="appl-shutdown" expand="true,false" fill="true">
|
||||
<label>_T{Shutdown}</label>
|
||||
</button>
|
||||
<button name="appl-reboot" expand="true,false" fill="true">
|
||||
<label>_T{Reboot}</label>
|
||||
</button>
|
||||
<spacer fill="true" expand="true"/>
|
||||
</sizer>
|
51
tools/server-remote/lutin_zeus-server-remote.py
Normal file
51
tools/server-remote/lutin_zeus-server-remote.py
Normal file
@ -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
|
||||
|
||||
|
1
tools/server-remote/version.txt
Normal file
1
tools/server-remote/version.txt
Normal file
@ -0,0 +1 @@
|
||||
0.1.0
|
12
tools/service-server/appl/debug.cpp
Normal file
12
tools/service-server/appl/debug.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <appl/debug.hpp>
|
||||
|
||||
int32_t appl::getLogId() {
|
||||
static int32_t g_val = elog::registerInstance("zeus-system-server");
|
||||
return g_val;
|
||||
}
|
40
tools/service-server/appl/debug.hpp
Normal file
40
tools/service-server/appl/debug.hpp
Normal file
@ -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 <elog/log.hpp>
|
||||
|
||||
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)
|
||||
|
||||
|
0
tools/service-server/appl/main-service-server.cpp
Normal file
0
tools/service-server/appl/main-service-server.cpp
Normal file
11
tools/service-server/appl/zeus-service-server.srv.zeus.idl
Normal file
11
tools/service-server/appl/zeus-service-server.srv.zeus.idl
Normal file
@ -0,0 +1,11 @@
|
||||
#elem-brief: server interface management
|
||||
#elem-version: 0.1
|
||||
#elem-type:SERVER
|
||||
#elem-author:Heero Yui<yui.heero@gmail.com>
|
||||
|
||||
#brief:Shutdown the server
|
||||
void shutdown()
|
||||
|
||||
#brief:Reboot the server
|
||||
void reboot()
|
||||
|
46
tools/service-server/lutin_zeus-service-server-impl.py
Normal file
46
tools/service-server/lutin_zeus-service-server-impl.py
Normal file
@ -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 <yui.heero@gmail.com>"]
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
39
tools/service-server/lutin_zeus-service-server.py
Normal file
39
tools/service-server/lutin_zeus-service-server.py
Normal file
@ -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 <yui.heero@gmail.com>"]
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user