From 74bbda465777abc62aa1c594ae20dd98b7936ccf Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 19 Oct 2017 11:13:15 -0400 Subject: [PATCH] add support for opening uris from sandboxed gadgets --- e-gadget.xml | 3 +++ loader/loader.c | 11 +++++++++++ src/runner.c | 16 +++++++++++++++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/e-gadget.xml b/e-gadget.xml index f01463e..837c260 100644 --- a/e-gadget.xml +++ b/e-gadget.xml @@ -30,6 +30,9 @@ + + + diff --git a/loader/loader.c b/loader/loader.c index ff8738e..8658423 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -187,6 +187,16 @@ static const struct action_route_bind_listener _ar_bind_interface = _ar_bind_end }; +static void +uriopen_request(void *data, Evas_Object *obj EINA_UNUSED, void *event_info) +{ + Ecore_Wl2_Display *d = data; + const char *uri = event_info; + struct e_gadget *gadget_global = eina_hash_find(gadget_globals, &d); + + e_gadget_open_uri(gadget_global, uri); +} + static void action_request(void *data, Evas_Object *obj, void *event_info) { @@ -259,6 +269,7 @@ win_add(Evas_Object *win) wins = eina_hash_pointer_new(NULL); eina_hash_list_append(wins, &d, win); evas_object_smart_callback_add(win, "gadget_action_request", action_request, d); + evas_object_smart_callback_add(win, "gadget_open_uri", uriopen_request, d); evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, win_del, NULL); elm_win_borderless_set(win, 1); return win; diff --git a/src/runner.c b/src/runner.c index 49daabf..ee14166 100644 --- a/src/runner.c +++ b/src/runner.c @@ -387,6 +387,20 @@ gadget_unbind(struct wl_resource *resource) inst->gadget_resource = NULL; } +static void +gadget_open_uri(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, const char *uri) +{ + Instance *inst = wl_resource_get_user_data(resource); + + /* FIXME: rate limit? */ + e_util_open(uri, NULL); +} + +static const struct e_gadget_interface _gadget_interface = +{ + .open_uri = gadget_open_uri, +}; + static void gadget_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id) { @@ -403,7 +417,7 @@ gadget_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id) } res = wl_resource_create(client, &e_gadget_interface, version, id); - wl_resource_set_implementation(res, NULL, data, gadget_unbind); + wl_resource_set_implementation(res, &_gadget_interface, data, gadget_unbind); inst->gadget_resource = res; site = e_gadget_site_get(inst->box); e_gadget_send_gadget_orient(res, e_gadget_site_orient_get(site));