summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2019-12-13 12:21:55 +0100
committerJosé Bollo <jose.bollo@iot.bzh>2019-12-13 12:21:55 +0100
commit949e8b8c90dfb37988b542df171c39941aee7bcb (patch)
tree4c72a5a794a6d81e8a754f561fe737cf224f2a5c
parent003cdfb640b595345b0d4d09471872c9295d0bc7 (diff)
In order to separate applications for cookies and private data the framework uses the component nss-localuser to forge specific hostnames. This commit takes it into account by allowing to specify the hostname to contact at init. Bug-AGL: SPEC-3014 Change-Id: Iabf4a5604dae2c5c5279bc0f45ccfbf3526164d5 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/libwindowmanager.cpp24
-rw-r--r--src/libwindowmanager.h1
2 files changed, 13 insertions, 12 deletions
diff --git a/src/libwindowmanager.cpp b/src/libwindowmanager.cpp
index 65684f1..8dae9c0 100644
--- a/src/libwindowmanager.cpp
+++ b/src/libwindowmanager.cpp
@@ -55,7 +55,7 @@ class LibWindowmanager::Impl {
~Impl();
// This is the LibWindowmanager interface impl
- int init(int port, char const *token);
+ int init(const char *hostname, int port, char const *token);
// WM API
int requestSurface(json_object *object);
@@ -186,7 +186,7 @@ LibWindowmanager::Impl::~Impl() {
sd_event_unref(loop);
}
-int LibWindowmanager::Impl::init(int port, char const *token) {
+int LibWindowmanager::Impl::init(const char *hostname, int port, char const *token) {
TRACE();
HMI_DEBUG("libwm", "called");
@@ -219,7 +219,9 @@ int LibWindowmanager::Impl::init(int port, char const *token) {
goto fail;
}
- asprintf(&uribuf, "ws://localhost:%d/api?token=%s", port, token);
+ if (hostname == nullptr)
+ hostname = "localhost";
+ asprintf(&uribuf, "ws://%s:%d/api?token=%s", hostname, port, token);
/* connect the websocket wsj1 to the uri given by the first argument */
this->wsj1 = afb_ws_client_connect_wsj1(
@@ -952,8 +954,8 @@ int LibWindowmanager::Impl::runEventLoop() {
/**
* @class LibWindowmanager
*/
-int LibWindowmanager::init(int port, char const *token) {
- int ret = this->d->init(port, token);
+int LibWindowmanager::init(char const *hostname, int port, char const *token) {
+ int ret = this->d->init(hostname, port, token);
if(ret == 0) {
json_object* j = json_object_new_object();
ret = this->getDisplayInfo(j); // return 0 if success
@@ -962,14 +964,12 @@ int LibWindowmanager::init(int port, char const *token) {
return ret;
}
+int LibWindowmanager::init(int port, char const *token) {
+ return init(nullptr, port, token);
+}
+
int LibWindowmanager::init(int port, const std::string &token) {
- int ret = this->d->init(port, token.c_str());
- if(ret == 0) {
- json_object* j = json_object_new_object();
- ret = this->getDisplayInfo(j); // return 0 if success
- json_object_put(j);
- }
- return ret;
+ return init(nullptr, port, token.c_str());
}
int LibWindowmanager::requestSurface(json_object *object) {
diff --git a/src/libwindowmanager.h b/src/libwindowmanager.h
index c9da4ca..01d889f 100644
--- a/src/libwindowmanager.h
+++ b/src/libwindowmanager.h
@@ -128,6 +128,7 @@ public:
Event_Val_Max = Event_Error
};
+ int init(char const *hostname, int port, char const *token);
int init(int port, char const *token);
int init(int port, const std::string &token);