summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2017-10-19 11:13:15 -0400
committerMike Blumenkrantz <zmike@osg.samsung.com>2017-10-19 11:13:15 -0400
commit74bbda465777abc62aa1c594ae20dd98b7936ccf (patch)
treea495a6f0bb2b36f7048dffe4ef748ea03809193f
parent2f74316f7d353390cc91b032f13f8a46c0d261eb (diff)
add support for opening uris from sandboxed gadgets
-rw-r--r--e-gadget.xml3
-rw-r--r--loader/loader.c11
-rw-r--r--src/runner.c16
3 files changed, 29 insertions, 1 deletions
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 @@
30 <event name="gadget_gravity"> 30 <event name="gadget_gravity">
31 <arg name="gravity" type="uint" enum="gravity"/> 31 <arg name="gravity" type="uint" enum="gravity"/>
32 </event> 32 </event>
33 <request name="open_uri">
34 <arg name="uri" type="string"/>
35 </request>
33 </interface> 36 </interface>
34 37
35</protocol> 38</protocol>
diff --git a/loader/loader.c b/loader/loader.c
index ff8738e..8658423 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -188,6 +188,16 @@ static const struct action_route_bind_listener _ar_bind_interface =
188}; 188};
189 189
190static void 190static void
191uriopen_request(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
192{
193 Ecore_Wl2_Display *d = data;
194 const char *uri = event_info;
195 struct e_gadget *gadget_global = eina_hash_find(gadget_globals, &d);
196
197 e_gadget_open_uri(gadget_global, uri);
198}
199
200static void
191action_request(void *data, Evas_Object *obj, void *event_info) 201action_request(void *data, Evas_Object *obj, void *event_info)
192{ 202{
193 Gadget_Action *ga; 203 Gadget_Action *ga;
@@ -259,6 +269,7 @@ win_add(Evas_Object *win)
259 wins = eina_hash_pointer_new(NULL); 269 wins = eina_hash_pointer_new(NULL);
260 eina_hash_list_append(wins, &d, win); 270 eina_hash_list_append(wins, &d, win);
261 evas_object_smart_callback_add(win, "gadget_action_request", action_request, d); 271 evas_object_smart_callback_add(win, "gadget_action_request", action_request, d);
272 evas_object_smart_callback_add(win, "gadget_open_uri", uriopen_request, d);
262 evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, win_del, NULL); 273 evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, win_del, NULL);
263 elm_win_borderless_set(win, 1); 274 elm_win_borderless_set(win, 1);
264 return win; 275 return win;
diff --git a/src/runner.c b/src/runner.c
index 49daabf..ee14166 100644
--- a/src/runner.c
+++ b/src/runner.c
@@ -388,6 +388,20 @@ gadget_unbind(struct wl_resource *resource)
388} 388}
389 389
390static void 390static void
391gadget_open_uri(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, const char *uri)
392{
393 Instance *inst = wl_resource_get_user_data(resource);
394
395 /* FIXME: rate limit? */
396 e_util_open(uri, NULL);
397}
398
399static const struct e_gadget_interface _gadget_interface =
400{
401 .open_uri = gadget_open_uri,
402};
403
404static void
391gadget_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id) 405gadget_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
392{ 406{
393 struct wl_resource *res; 407 struct wl_resource *res;
@@ -403,7 +417,7 @@ gadget_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
403 } 417 }
404 418
405 res = wl_resource_create(client, &e_gadget_interface, version, id); 419 res = wl_resource_create(client, &e_gadget_interface, version, id);
406 wl_resource_set_implementation(res, NULL, data, gadget_unbind); 420 wl_resource_set_implementation(res, &_gadget_interface, data, gadget_unbind);
407 inst->gadget_resource = res; 421 inst->gadget_resource = res;
408 site = e_gadget_site_get(inst->box); 422 site = e_gadget_site_get(inst->box);
409 e_gadget_send_gadget_orient(res, e_gadget_site_orient_get(site)); 423 e_gadget_send_gadget_orient(res, e_gadget_site_orient_get(site));