Browse Source

add support for opening uris from sandboxed gadgets

devs/discomfitor/wip
Mike Blumenkrantz 5 years ago
parent
commit
74bbda4657
  1. 3
      e-gadget.xml
  2. 11
      loader/loader.c
  3. 16
      src/runner.c

3
e-gadget.xml

@ -30,6 +30,9 @@
<event name="gadget_gravity">
<arg name="gravity" type="uint" enum="gravity"/>
</event>
<request name="open_uri">
<arg name="uri" type="string"/>
</request>
</interface>
</protocol>

11
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;

16
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));

Loading…
Cancel
Save