63ad820841ee2ba9afa4dae8e64bb37905f202cd
[AGL/meta-agl.git] / meta-agl-profile-graphical-html5 / recipes-wam / wam / files / trunc-webapp-roles.patch
1 From 870dd9c0e80d2f7ce843399f606299629ae7b570 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Jacobo=20Aragunde=20P=C3=A9rez?= <jaragunde@igalia.com>
3 Date: Thu, 23 Jan 2020 11:57:23 +0100
4 Subject: [PATCH] Set webapp roles that are max 12 characters long.
5
6 This is a workaround for SPEC-3127. To prevent repeated roles as much
7 as possible, I'm using the appid as a basis instead of "Webapp-" +
8 host + port, which has many chances to be redundant in the first 12
9 chars.
10
11 Bug-AGL: SPEC-3127
12 ---
13  src/agl/WebRuntimeAGL.cpp | 10 +++-------
14  1 file changed, 3 insertions(+), 7 deletions(-)
15
16 diff --git a/src/agl/WebRuntimeAGL.cpp b/src/agl/WebRuntimeAGL.cpp
17 index a919759..baa2708 100644
18 --- a/src/agl/WebRuntimeAGL.cpp
19 +++ b/src/agl/WebRuntimeAGL.cpp
20 @@ -162,7 +162,6 @@ int WebAppLauncherRuntime::run(int argc, const char** argv) {
21    bool isWaitHostService = isWaitForHostService(args);
22    m_id = getAppId(args);
23    m_url = getAppUrl(args);
24 -  m_role = "WebApp";
25  
26    if(isWaitHostService) {
27      while(!WebAppManagerServiceAGL::instance()->isHostServiceRunning()) {
28 @@ -220,15 +219,9 @@ bool WebAppLauncherRuntime::init() {
29        if (n != std::string::npos) {
30          std::string sport = authority.substr(n+1);
31          m_host = authority.substr(0, n);
32 -        m_role.push_back('-');
33 -        m_role.append(m_host);
34 -        m_role.push_back('-');
35 -        m_role.append(sport);
36          m_port = stringTo<int>(sport);
37        } else {
38          m_host = authority;
39 -        m_role.push_back('-');
40 -        m_role.append(m_host);
41        }
42      }
43  
44 @@ -265,6 +258,9 @@ bool WebAppLauncherRuntime::init() {
45        m_role = "homescreen";
46      else if (m_id.rfind("webapps-homescreen", 0) == 0)
47        m_role = "homescreen";
48 +    else {
49 +      m_role = m_id.substr(0,12);
50 +    }
51  
52      LOG_DEBUG("id=[%s], name=[%s], role=[%s], url=[%s], host=[%s], port=%d, token=[%s]",
53              m_id.c_str(), m_name.c_str(), m_role.c_str(), m_url.c_str(),