2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @file view_logic_usermedia_support.cpp
18 * @author Jihoon Chung (jihoon.chung@samsung.com)
21 #include "view_logic_usermedia_support.h"
24 #include <dpl/log/log.h>
25 #include <dpl/assert.h>
26 #include <Elementary.h>
29 namespace ViewModule {
31 const char* const USERMEDIA_USE_ASK_BODY =
32 "This application wants to use your media";
35 void askUserForUsermediaPermission(Evas_Object* window, void* data);
36 Evas_Object* getPopup(Evas_Object* button);
37 static void popupCallback(void* data, Evas_Object* obj, void* eventInfo);
39 void askUserForUsermediaPermission(Evas_Object* window, void* data)
41 LogDebug("askUserForUsermediaPermission called");
43 Evas_Object* popup = elm_popup_add(window);
44 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
45 elm_object_text_set(popup, USERMEDIA_USE_ASK_BODY);
47 Evas_Object* lButton = elm_button_add(popup);
48 elm_object_text_set(lButton, "Allow");
49 elm_object_part_content_set(popup, "button1", lButton);
50 evas_object_smart_callback_add(lButton, "clicked", popupCallback, data);
52 Evas_Object* rButton = elm_button_add(popup);
53 elm_object_text_set(rButton, "Deny");
54 elm_object_part_content_set(popup, "button2", rButton);
55 evas_object_smart_callback_add(rButton, "clicked", popupCallback, data);
56 evas_object_show(popup);
59 Evas_Object* getPopup(Evas_Object* button)
63 Evas_Object* popup = button;
64 while (strcmp(elm_object_widget_type_get(popup), "elm_popup")) {
65 popup = elm_object_parent_widget_get(popup);
73 void popupCallback(void* data, Evas_Object* obj, void* /*eventInfo*/)
75 LogDebug("popupCallback");
77 Ewk_User_Media_Permission* usermediaPermission =
78 static_cast<Ewk_User_Media_Permission*>(data);
81 Evas_Object* popup = getPopup(obj);
83 bool allow = !strcmp("Allow", elm_object_text_get(obj));
85 Eina_Bool ret = allow ? EINA_TRUE : EINA_FALSE;
86 ewk_user_media_permission_set(usermediaPermission, ret);
88 evas_object_hide(popup);
89 evas_object_del(popup);
93 void UsermediaSupport::usermediaPermissionRequest(Evas_Object* window,
96 LogDebug("usermediaPermissionRequest called");
100 askUserForUsermediaPermission(window, data);
103 } // namespace ViewModule