4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
6 * Contact: MyoungJune Park <mj2004.park@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
21 #include <setting-privacy-main.h>
22 //#include <package-manager.h>
23 #include <privacy_manager.h>
24 //#include <privacy_info.h>
26 static int setting_privacy_main_create(void *cb);
27 static int setting_privacy_main_destroy(void *cb);
28 static int setting_privacy_main_update(void *cb);
29 static int setting_privacy_main_cleanup(void *cb);
31 setting_view setting_view_privacy_main = {
32 .create = setting_privacy_main_create,
33 .destroy = setting_privacy_main_destroy,
34 .update = setting_privacy_main_update,
35 .cleanup = setting_privacy_main_cleanup,
38 typedef struct _PrivacyNode PrivacyNode;
41 char* pkgname; // ex) com.samsung.app
42 int state; // 0:OFF, 1:ON
46 static int get_privacy_app(const char *appid, bool* status)
49 //privacy_info_h handle;
53 static void __apps_list_cb(const pkgmgrinfo_pkginfo_h handler, void* data)
55 SettingPrivacyUG *ad = (SettingPrivacyUG *) data;
58 char *pkg_name = NULL;
59 char *icon_path = NULL;
60 char *main_appid = NULL;
61 char *pkg_label = NULL;
63 pkgmgrinfo_appinfo_h appinfo_h = NULL;
65 r = pkgmgrinfo_pkginfo_get_pkgid(handler, &pkg_name);
67 SETTING_TRACE_ERROR("pkgmgrinfo_pkginfo_get_pkgid is failed code[%d] ", r);
70 SETTING_TRACE("pkg_name: %s", pkg_name);
72 r = pkgmgrinfo_pkginfo_get_mainappid(handler, &main_appid);
74 SETTING_TRACE_ERROR("pkgmgrinfo_pkginfo_get_mainappid is failed code[%d]", r);
77 SETTING_TRACE("main_appid: %s", main_appid);
79 r = pkgmgrinfo_appinfo_get_appinfo(main_appid, &appinfo_h);
81 SETTING_TRACE_ERROR("pkgmgrinfo_appinfo_get_appinfo is failed code[%d]", r);
85 r = pkgmgrinfo_appinfo_is_nodisplay(appinfo_h, &nodisplay);
87 SETTING_TRACE_ERROR("pkgmgrinfo_appinfo_get_appinfo is failed code[%d]", r);
91 r = pkgmgrinfo_appinfo_get_label(appinfo_h, &pkg_label);
93 SETTING_TRACE_ERROR("pkgmgrinfo_appinfo_get_appinfo is failed code[%d]", r);
97 //PrivacyNode* node = (PrivacyNode*) malloc(sizeof(PrivacyNode));
98 //node->pkgname = strdup(pkg_name);
99 // TODO : free node->pkgname later
101 setting_create_Gendial_field_def(ad->genlist_privacy,
103 setting_privacy_main_list_Gendial_mouse_up_cb,
105 SWALLOW_Type_INVALID,
112 //ad->item_check_list = eina_list_append(ad->item_check_list, node);
116 pkgmgrinfo_appinfo_destroy_appinfo(appinfo_h);
124 static void __info_cb(const privacy_info_h handler, void* data)
127 SettingPrivacyUG *ad = (SettingPrivacyUG *) data;
128 bool enabled = false;
129 char *privacy_id = NULL;
131 char *description = NULL;
133 int r = privacy_info_is_enabled(handler, &enabled);
135 SETTING_TRACE_ERROR("privacy_info_is_enabled is failed code[%d] ", r);
138 SETTING_TRACE("check privacy_info_is_enabled 001");
142 r = privacy_info_get_privacy_id(handler, &privacy_id);
144 SETTING_TRACE_ERROR("privacy_info_get_privacy_id is failed code[%d] ", r);
148 r = privacy_info_get_privacy_display_name(handler, &name);
150 SETTING_TRACE_ERROR("privacy_info_get_privacy_display_name is failed code[%d] ", r);
154 r = privacy_info_get_privacy_description(handler, &description);
156 SETTING_TRACE_ERROR("privacy_info_get_privacy_description is failed code[%d] ", r);
159 setting_create_Gendial_field_def(ad->genlist_privacy,
161 setting_privacy_main_list_Gendial_mouse_up_cb,
163 SWALLOW_Type_INVALID,
173 static void __apps_list_cb(const pkgmgrinfo_pkginfo_h handler, void* data)
176 SettingPrivacyUG *ad = (SettingPrivacyUG *) data;
179 char *pkg_name = NULL;
180 r = pkgmgrinfo_pkginfo_get_pkgid(handler, &pkg_name);
182 SETTING_TRACE_ERROR("pkgmgrinfo_pkginfo_get_pkgid is failed code[%d] ", r);
185 SETTING_TRACE("pkg_name [%s]",pkg_name);
186 privacy_manager_foreach_privacy_info(pkg_name, __info_cb, ad);
191 static void __apps_list_cb(const char* package_id, void* data)
194 SettingPrivacyUG *ad = (SettingPrivacyUG *) data;
195 SETTING_TRACE("package_id : %s", package_id);
200 * get 3rd party applist from AIL & searching dir/file by the defined rule
202 * if data is NULL --> just get how many items are there
203 * if data is NOT NULL --> draw UI code
205 static void setting_privacy_get_app_list(void* data)
208 SettingPrivacyUG *ad = (SettingPrivacyUG *) data;
210 //int r = pkgmgrinfo_pkginfo_get_list(__apps_list_cb, ad);
211 int r = privacy_manager_foreach_privacy_packages(__apps_list_cb, ad);
213 SETTING_TRACE_ERROR("privacy_manager_foreach_privacy_packages failed. %d", r);
218 /* ***************************************************
222 ****************************************************/
223 static int setting_privacy_main_create(void *cb)
226 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
228 SettingPrivacyUG *ad = (SettingPrivacyUG *) cb;
229 Elm_Object_Item *item = NULL;
230 Evas_Object *scroller = NULL;
232 setting_create_layout_navi_bar_genlist(ad->win_main_layout,
235 _("IDS_COM_BODY_BACK"),
237 setting_privacy_main_click_softkey_back_cb,
244 item = elm_genlist_item_append(scroller , &itc_seperator, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
245 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
248 //ad->item_check_list = NULL;
250 ad->genlist_privacy = scroller;
252 setting_privacy_get_app_list(ad);
255 item = elm_genlist_item_append(scroller , &itc_bottom_seperator, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
256 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
259 setting_view_privacy_main.is_create = 1;
260 return SETTING_RETURN_SUCCESS;
263 static int setting_privacy_main_destroy(void *cb)
267 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
268 SettingPrivacyUG *ad = (SettingPrivacyUG *) cb;
270 elm_naviframe_item_pop(ad->navi_bar);
271 setting_view_privacy_main.is_create = 0;
272 return SETTING_RETURN_SUCCESS;
275 static int setting_privacy_main_update(void *cb)
279 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
280 SettingPrivacyUG *ad = (SettingPrivacyUG *) cb;
283 /* update genlist when list add or delete */
284 return SETTING_RETURN_SUCCESS;
287 static int setting_privacy_main_cleanup(void *cb)
291 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
293 SettingPrivacyUG *ad = (SettingPrivacyUG *) cb;
294 return setting_privacy_main_destroy(ad);
297 /* ***************************************************
301 ****************************************************/
302 static void setting_privacy_main_click_softkey_back_cb(void *data, Evas_Object *obj,
307 retm_if(data == NULL, "Data parameter is NULL");
308 SettingPrivacyUG *ad = (SettingPrivacyUG *) data;
310 /* Send destroy request */
311 ug_destroy_me(ad->ug);
315 static void setting_privacy_main_list_Gendial_mouse_up_cb(void *data, Evas_Object *obj,
319 retm_if(event_info == NULL, "Invalid argument: event info is NULL");
320 //Elm_Object_Item *item = (Elm_Object_Item *) event_info;
321 //elm_genlist_item_selected_set(item, 0);
322 //Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
323 //change view to privacy services