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 {
32 const char* const USERMEDIA_USE_ASK_BODY =
33 "This application wants to use your media";
36 void askUserForUsermediaPermission(Evas_Object* window, void* data);
37 Evas_Object* getPopup(Evas_Object* button);
38 static void popupCallback(void* data, Evas_Object* obj, void* eventInfo);
40 void askUserForUsermediaPermission(Evas_Object* window, void* data)
42 LogDebug("askUserForUsermediaPermission called");
44 Evas_Object* popup = elm_popup_add(window);
45 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
46 elm_object_text_set(popup, USERMEDIA_USE_ASK_BODY);
48 Evas_Object* lButton = elm_button_add(popup);
49 elm_object_text_set(lButton, "Allow");
50 elm_object_part_content_set(popup, "button1", lButton);
51 evas_object_smart_callback_add(lButton, "clicked", popupCallback, data);
53 Evas_Object* rButton = elm_button_add(popup);
54 elm_object_text_set(rButton, "Deny");
55 elm_object_part_content_set(popup, "button2", rButton);
56 evas_object_smart_callback_add(rButton, "clicked", popupCallback, data);
57 evas_object_show(popup);
60 Evas_Object* getPopup(Evas_Object* button)
64 Evas_Object* popup = button;
65 while (strcmp(elm_object_widget_type_get(popup), "elm_popup")) {
66 popup = elm_object_parent_widget_get(popup);
74 void popupCallback(void* data, Evas_Object* obj, void* /*eventInfo*/)
76 LogDebug("popupCallback");
78 Ewk_User_Media_Permission* usermediaPermission =
79 static_cast<Ewk_User_Media_Permission*>(data);
82 Evas_Object* popup = getPopup(obj);
84 bool allow = !strcmp("Allow", elm_object_text_get(obj));
86 Eina_Bool ret = allow ? EINA_TRUE : EINA_FALSE;
87 ewk_user_media_permission_set(usermediaPermission, ret);
89 evas_object_hide(popup);
90 evas_object_del(popup);
94 void UsermediaSupport::usermediaPermissionRequest(Evas_Object* window,
97 LogDebug("usermediaPermissionRequest called");
101 askUserForUsermediaPermission(window, data);
104 } // namespace ViewModule