aboutsummaryrefslogtreecommitdiff
path: root/rwa/support/sessionservice/service.py
diff options
context:
space:
mode:
Diffstat (limited to 'rwa/support/sessionservice/service.py')
-rwxr-xr-xrwa/support/sessionservice/service.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/rwa/support/sessionservice/service.py b/rwa/support/sessionservice/service.py
index 0d7ade1..40e65cb 100755
--- a/rwa/support/sessionservice/service.py
+++ b/rwa/support/sessionservice/service.py
@@ -185,9 +185,9 @@ class RWASupportSessionService(dbus.service.Object):
return {"status": "success", "type": "valid_host"}
@dbus.service.method(
- "org.ArcticaProject.RWASupportSessionService", in_signature="s", out_signature="s"
+ "org.ArcticaProject.RWASupportSessionService", in_signature="ss", out_signature="s"
)
- def add_web_app_host(self, host_url: str) -> str:
+ def add_web_app_host(self, host_url: str, host_alias: str) -> str:
"""Add a RWA.Support.WebApp host.
:param host_url: Exact hostname of the RWA.Support.WebApp host (D-Bus string)
@@ -197,7 +197,7 @@ class RWASupportSessionService(dbus.service.Object):
::
- {"status": "success", "host": {"url": "https://example.org", "uuid": <host_uuid>}}
+ {"status": "success", "host": {"url": "https://example.org", "alias": "<host_alias>", "uuid": <host_uuid>}}
**Structure of returned JSON (error):**
@@ -214,12 +214,13 @@ class RWASupportSessionService(dbus.service.Object):
* ``duplicate``
"""
host_url = str(host_url).rstrip("/")
+ host_alias = str(host_alias)
- logging.info('D-Bus method call: %s("%s")', "add_web_app_host", host_url)
+ logging.info('D-Bus method call: %s("%s", "%s")', "add_web_app_host", host_url, host_alias)
if not self._is_url(host_url):
logging.warning("Given URL is not valid!")
- logging.debug('Did not add "%s" to "web_app_hosts" in user_settings', host_url)
+ logging.debug('Did not add "%s":"%s" to "web_app_hosts" in user_settings', host_alias, host_url)
response = json.dumps({"status": "error", "type": "invalid_url"})
logging.info('The response to D-Bus caller: "%s"', response)
@@ -229,7 +230,7 @@ class RWASupportSessionService(dbus.service.Object):
for uuid, host in self.settings.web_app_hosts.items():
if host_url == host['url']:
logging.warning("Given URL is already present!")
- logging.debug('Did not add "%s" to "web_app_hosts" in user_settings', host_url)
+ logging.debug('Did not add "%s":"%s" to "web_app_hosts" in user_settings', host_alias, host_url)
response = json.dumps({"status": "error", "type": "duplicate"})
logging.info('The response to D-Bus caller: "%s"', response)
@@ -242,19 +243,19 @@ class RWASupportSessionService(dbus.service.Object):
res = self._do_api_handshake(host_url)
if res["status"] == "error":
- logging.debug('Did not add "%s" to "web_app_hosts" in user_settings', host_url)
+ logging.debug('Did not add "%s":"%s" to "web_app_hosts" in user_settings', host_alias, host_url)
response = json.dumps(res)
logging.info('The response to D-Bus caller: "%s"', response)
return response
host_uuid = str(uuid4())
- host_object = {"url": host_url}
+ host_object = {"url": host_url, "alias": host_alias}
self.settings.web_app_hosts[host_uuid] = host_object
self.settings.save_settings()
- logging.info('Added "%s" to "web_app_hosts" in user_settings', host_url)
+ logging.info('Added "%s":"%s" to "web_app_hosts" in user_settings', host_alias, host_url)
response = {"status": "success", "host": self._build_host_dict(host_uuid, host_object)}
response = json.dumps(response)