CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(ug-setting-privacy-efl C)
+PROJECT(privacy-setting C)
INCLUDE(FindPkgConfig)
ADD_DEFINITIONS("-Wall") # Generate all warnings
ADD_DEFINITIONS("-Wextra") # Generate even more extra warnings
ADD_DEFINITIONS("-Wno-unused-parameter") # Ignore unused parameter
+ADD_DEFINITIONS("-Wno-unused-function")
+ADD_DEFINITIONS("-Wno-unused-variable")
# Set linker flags
SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed")
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
-
+SET(BINDIR "${PREFIX}/bin")
SET(LIBDIR "${PREFIX}/lib")
SET(RESDIR "${PREFIX}/res")
-
SET(LOCALEDIR "${RESDIR}/locale")
-SET(TARGET_PRIVACY_MANAGER_UG ${PROJECT_NAME})
-
IF (CMAKE_BUILD_TYPE MATCHES "DEBUG")
ADD_DEFINITIONS("-DTIZEN_DEBUG_ENABLE")
ADD_DEFINITIONS("-DBUILD_TYPE_DEBUG")
ADD_DEFINITIONS("-DRESDIR=\"${RESDIR}\"")
ADD_DEFINITIONS("-DLOCALEDIR=\"${LOCALEDIR}\"")
-SET(CMAKE_INSTALL_RPATH "${LIBDIR}")
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
-ADD_DEFINITIONS("-DUG_WAYLAND")
+#ADD_DEFINITIONS("-DUG_WAYLAND")
-ADD_SUBDIRECTORY(ug)
+ADD_SUBDIRECTORY(ui)
#ADD_SUBDIRECTORY(po)
-INSTALL(FILES packaging/ug-setting-privacy-efl.xml DESTINATION ${TZ_SYS_RO_PACKAGES}/)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/packaging/org.tizen.privacy-setting.xml DESTINATION ${TZ_SYS_RO_PACKAGES}/)
+
* @brief
*/
-#ifndef __UG_SETTING_PRIVACY_COMMON_UTILS_H_
-#define __UG_SETTING_PRIVACY_COMMON_UTILS_H_
+#ifndef __UI_PRIVACY_SETTING_COMMON_UTILS_H_
+#define __UI_PRIVACY_SETTING_COMMON_UTILS_H_
#include <Elementary.h>
#include <dlog.h>
-#include "privacy_setting_ug.h"
+#include "privacy_setting.h"
#ifdef LOG_TAG
#undef LOG_TAG
#endif
-#define LOG_TAG "UG_PRIVACY_SETTING"
+#define LOG_TAG "UI_PRIVACY_SETTING"
#ifdef _cplusplus
extern "C" {
Evas_Object *common_genlist_add(Evas_Object *parent);
-Evas_Object *common_back_btn_add(struct ug_data_s *ugd);
+Evas_Object *common_back_btn_add(struct app_data_s *ad);
#ifdef _cplusplus
}
#endif
-#endif /* __UG_SETTING_PRIVACY_COMMON_UTILS_H_ */
+#endif /* __UI_PRIVACY_SETTING_COMMON_UTILS_H_ */
static void back_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
{
- struct ug_data_s *ugd = (struct ug_data_s *)data;
- return_if(!ugd, , , "ugd is null");
- elm_naviframe_item_pop(ugd->nf);
+ struct app_data_s *ad = (struct app_data_s *)data;
+ return_if(!ad, , , "ad is null");
+ elm_naviframe_item_pop(ad->nf);
}
-Evas_Object *common_back_btn_add(struct ug_data_s *ad)
+Evas_Object *common_back_btn_add(struct app_data_s *ad)
{
Evas_Object *btn = elm_button_add(ad->nf);
elm_object_style_set(btn, "naviframe/back_btn/default");
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_" />
+ </request>
+</manifest>
--- /dev/null
+%define PREFIX %{TZ_SYS_RO_APP}/%{name}
+
+Name: org.tizen.privacy-setting
+Summary: Privacy setting ui application
+Version: 1.0.0
+Release: 1
+Group: System/???
+License: Apache-2.0
+Source0: %{name}-%{version}.tar.gz
+Source1001: %{name}.manifest
+%if "%{?tizen_profile_name}" == "tv"
+ExcludeArch: %{arm} %ix86 x86_64
+%endif
+BuildRequires: cmake
+BuildRequires: gettext-tools
+BuildRequires: edje-tools
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(edje)
+BuildRequires: pkgconfig(eina)
+BuildRequires: pkgconfig(elementary)
+BuildRequires: pkgconfig(evas)
+BuildRequires: pkgconfig(efl-extension)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(ui-gadget-1)
+BuildRequires: pkgconfig(icu-i18n)
+BuildRequires: pkgconfig(libtzplatform-config)
+BuildRequires: pkgconfig(security-privilege-manager)
+BuildRequires: pkgconfig(security-manager)
+BuildRequires: pkgconfig(pkgmgr-info)
+
+%description
+Privacy setting ui gadget
+
+%prep
+%setup -q
+cp -a %SOURCE1001 .
+
+%build
+export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
+export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
+
+export CFLAGS="$CFLAGS -DTIZEN_ENGINEER_MODE"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_ENGINEER_MODE"
+export FFLAGS="$FFLAGS -DTIZEN_ENGINEER_MODE"
+
+%ifarch %{ix86}
+export CFLAGS="$CFLAGS -DTIZEN_EMULATOR_MODE"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_EMULATOR_MODE"
+export FFLAGS="$FFLAGS -DTIZEN_EMULATOR_MODE"
+%endif
+
+%{!?build_type:%define build_type "Release"}
+%cmake . -DCMAKE_INSTALL_PREFIX=%PREFIX \
+ -DTZ_SYS_RO_PACKAGES=%TZ_SYS_RO_PACKAGES \
+ -DTZ_SYS_RO_APP=%TZ_SYS_RO_APP \
+ -DCMAKE_BUILD_TYPE=%{build_type} \
+ -DVERSION=%version
+
+make %{?_smp_mflags}
+
+%install
+%make_install
+
+%post
+/sbin/ldconfig
+# Only for testing -> Fllowing single line must be removed
+cyad -s -k MANIFESTS -c User::App::org.tizen.privacy-setting -u 5001 -p http://tizen.org/privilege/notexist -t ALLOW
+echo "cyad done"
+
+%postun -p /sbin/ldconfig
+
+%files
+%defattr(-,root,root,-)
+%manifest %name.manifest
+%license LICENSE
+%{TZ_SYS_RO_PACKAGES}/%name.xml
+%{TZ_SYS_RO_APP}/%{name}/bin/
+#%{PREFIX}/*
+#%TZ_SYS_RO_UG/res/locale/*
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns="http://tizen.org/ns/packages" package="org.tizen.privacy-setting" api-version="3.0" version="0.1">
+ <ui-application appid="org.tizen.privacy-setting" exec="/usr/apps/org.tizen.privacy-setting/bin/org.tizen.privacy-setting" multiple="false" nodisplay="true" taskmanager="false" type="capp">
+ <label>Setting privacy</label>
+ </ui-application>
+ <privileges>
+ <privilege>http://tizen.org/privilege/systemsettings.admin</privilege>
+ </privileges>
+</manifest>
+++ /dev/null
-<manifest>
- <request>
- <domain name="_" />
- </request>
-</manifest>
+++ /dev/null
-Name: ug-setting-privacy-efl
-Summary: Privacy setting ui gadget
-Version: 1.0.0
-Release: 1
-Group: System/Libraries
-License: Apache-2.0
-Source0: %{name}-%{version}.tar.gz
-Source1001: %{name}.manifest
-%if "%{?tizen_profile_name}" == "tv"
-ExcludeArch: %{arm} %ix86 x86_64
-%endif
-BuildRequires: cmake
-BuildRequires: gettext-tools
-BuildRequires: edje-tools
-BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(edje)
-BuildRequires: pkgconfig(eina)
-BuildRequires: pkgconfig(elementary)
-BuildRequires: pkgconfig(evas)
-BuildRequires: pkgconfig(efl-extension)
-BuildRequires: pkgconfig(glib-2.0)
-BuildRequires: pkgconfig(ui-gadget-1)
-BuildRequires: pkgconfig(icu-i18n)
-BuildRequires: pkgconfig(libtzplatform-config)
-BuildRequires: pkgconfig(security-privilege-manager)
-
-%description
-Privacy setting ui gadget
-
-%prep
-%setup -q
-cp -a %SOURCE1001 .
-
-%build
-export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
-export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
-export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
-
-export CFLAGS="$CFLAGS -DTIZEN_ENGINEER_MODE"
-export CXXFLAGS="$CXXFLAGS -DTIZEN_ENGINEER_MODE"
-export FFLAGS="$FFLAGS -DTIZEN_ENGINEER_MODE"
-
-%ifarch %{ix86}
-export CFLAGS="$CFLAGS -DTIZEN_EMULATOR_MODE"
-export CXXFLAGS="$CXXFLAGS -DTIZEN_EMULATOR_MODE"
-export FFLAGS="$FFLAGS -DTIZEN_EMULATOR_MODE"
-%endif
-
-%{!?build_type:%define build_type "Release"}
-%cmake . -DCMAKE_INSTALL_PREFIX=%TZ_SYS_RO_UG \
- -DTZ_SYS_RO_PACKAGES=%TZ_SYS_RO_PACKAGES \
- -DCMAKE_BUILD_TYPE=%{build_type} \
- -DVERSION=%version
-
-make %{?_smp_mflags}
-
-%install
-%make_install
-
-%post -p /sbin/ldconfig
-
-%postun -p /sbin/ldconfig
-
-%files
-%defattr(-,root,root,-)
-%manifest %name.manifest
-%license LICENSE
-%TZ_SYS_RO_PACKAGES/%name.xml
-%TZ_SYS_RO_UG/lib/libug-setting-privacy-efl.so*
-#%TZ_SYS_RO_UG/res/locale/*
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns="http://tizen.org/ns/packages" package="ug-setting-privacy-efl" api-version="3.0" version="0.1" install-location="internal-only">
- <label>ug-setting-privacy-efl ug</label>
- <description>Privacy Setting UI</description>
- <ui-application appid="setting-privacy-efl" exec="/usr/apps/ug-setting-privacy-efl/bin/setting-privacy-efl" nodisplay="true" ui-gadget="true" hw-acceleration="use-GL" multiple="false" type="capp" taskmanage="false">
- <label>Setting privacy</label>
- </ui-application>
-</manifest>
+++ /dev/null
-SET(pkg_name "ug-setting-privacy-efl")
-
-pkg_check_modules(${pkg_name} REQUIRED glib-2.0 ui-gadget-1 evas elementary edje eina efl-extension security-privilege-manager icu-i18n dlog)
-
-SET(SRCS
- ${CMAKE_SOURCE_DIR}/common/src/common_utils.c
- src/main_privacy_setting_ug.c
- src/privacy_list_view.c
- src/privacy_package_list_view.c
-)
-
-FOREACH(flag ${${pkg_name}_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-SET(INC_DIR include)
-INCLUDE_DIRECTORIES(
- ${CMAKE_SOURCE_DIR}/common/include
- "${INC_DIR}"
-)
-
-ADD_LIBRARY(${pkg_name} SHARED ${SRCS})
-SET_TARGET_PROPERTIES(
- ${pkg_name}
- PROPERTIES
- COMPILE_FLAGS "-D_GNU_SOURCE -fPIC -fvisibility=default"
- SOVERSION ${SO_VERSION}
- VERSION ${VERSION}
-)
-
-TARGET_LINK_LIBRARIES(${pkg_name}
- ${${pkg_name}_LIBRARIES}
- ${${pkg_name}_LDFLAGS}
-)
-
-INSTALL(TARGETS
- ${pkg_name}
- DESTINATION
- ${LIBDIR}
-)
+++ /dev/null
-/**
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/*
- * @file privacy_setting_ug.h
- * @author Yunjin Lee <yunjin-.lee@samsung.com>
- * @version 1.0
- * @brief
- */
-
-#ifndef __UG_SETTING_MANAGE_PRIVACY_EFL_H__
-#define __UG_SETTING_MANAGE_PRIVACY_EFL_H__
-
-#include <Elementary.h>
-#include <ui-gadget.h>
-#include <ui-gadget-module.h>
-#include <glib.h>
-#include <app.h>
-
-struct ug_data_s {
- Evas_Object *parent_layout;
- Evas_Object *bg;
- Evas_Object *layout;
- Evas_Object *nf;
- ui_gadget_h ug;
- void *data;
- Elm_Theme *theme;
-
- GList *privacy_list;
-};
-
-struct ug_data_s *get_ug_data();
-
-#endif /* __UG_SETTING_MANAGE_PRIVACY_EFL_H__ */
+++ /dev/null
-/**
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/*
- * @file privacy_view.h
- * @author Yunjin Lee <yunjin-.lee@samsung.com>
- * @version 1.0
- * @brief
- */
-
-
-#include <Elementary.h>
-#include <ui-gadget.h>
-#include <ui-gadget-module.h>
-#include <glib.h>
-#include <app.h>
-
-#include "privacy_setting_ug.h"
-
-typedef struct item_data {
- int index;
- char *title;
- bool status;
-} item_data_s;
-
-void create_privacy_package_list_view(struct ug_data_s *ugd, item_data_s *selected_id);
-
-void create_privacy_list_view(struct ug_data_s *ugd);
+++ /dev/null
-/**
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/*
- * @file main_privacy_setting_ug.c
- * @author Yunjin Lee (yunjin-.lee@samsung.com)
- * @version 1.0
- * @brief
- */
-
-#ifndef UG_MODULE_API
-#define UG_MODULE_API __attribute__ ((visibility("default")))
-#endif
-
-#include <libintl.h>
-#include <efl_extension.h>
-
-#include "common_utils.h"
-
-#include "privacy_setting_ug.h"
-#include "privacy_view.h"
-
-#include <privilege_info.h>
-
-static struct ug_data_s *g_ugd;
-
-struct ug_data_s *get_ug_data()
-{
- return g_ugd;
-}
-
-static void *on_create(ui_gadget_h ug, enum ug_mode mode, app_control_h service, void *priv)
-{
- struct ug_data_s *ugd = (struct ug_data_s *)priv;
- log_if(!ug || !ugd, 1, "!ug || !ugd");
-
- bindtextdomain(PACKAGE, LOCALEDIR);
-
- ugd->ug = ug;
-
- /* Get privacy list */
- log_if(privilege_info_get_privacy_list(&(ugd->privacy_list)) != PRVMGR_ERR_NONE, 1, "Failed to get privacy_list");
-
- /* Get parent layout */
- ugd->parent_layout = ug_get_parent_layout(ug);
- log_if(!ugd->parent_layout, 1, "ugd->parent_layout is null");
-
- /* Add bg */
- ugd->bg = elm_bg_add(ugd->parent_layout);
- log_if(!ugd->bg, 1, "ugd->bg is null");
-
- evas_object_size_hint_weight_set(ugd->bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_show(ugd->bg);
-
- /* Add layout */
- ugd->layout = elm_layout_add(ugd->parent_layout);
- log_if(!ugd->layout, 1, "ugd->layout is null");
-
- elm_layout_theme_set(ugd->layout, "layout", "application", "default");
- evas_object_size_hint_weight_set(ugd->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_show(ugd->layout);
-
- elm_object_part_content_set(ugd->layout, "elm.swallow.bg", ugd->bg);
-
- /* Add naviframe */
- ugd->nf = elm_naviframe_add(ugd->layout);
- log_if(!ugd->nf, 1, "ugd->nf is null");
-
- /* Create privacy list view */
- create_privacy_list_view(ugd);
-
- elm_object_part_content_set(ugd->layout, "elm.swallow.content", ugd->nf);
- eext_object_event_callback_add(ugd->nf, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
- eext_object_event_callback_add(ugd->nf, EEXT_CALLBACK_MORE, eext_naviframe_more_cb, NULL);
- evas_object_show(ugd->nf);
-
- return ugd->layout;
-}
-
-static void on_start(ui_gadget_h ug, app_control_h service, void *priv)
-{
-}
-
-static void on_pause(ui_gadget_h ug, app_control_h service, void *priv)
-{
-}
-
-static void on_resume(ui_gadget_h ug, app_control_h service, void *priv)
-{
-}
-
-static void on_destroy(ui_gadget_h ug, app_control_h service, void *priv)
-{
- LOGD("on_destroy");
-
- log_if(ug == NULL, 1, "ug is NULL");
- log_if(priv == NULL, 1, "priv is NULL");
-
- struct ug_data_s *ugd = (struct ug_data_s *)priv;
-
- if (ugd->theme) {
- elm_theme_free(ugd->theme);
- ugd->theme = NULL;
- }
-
- evas_object_hide(ugd->layout);
- evas_object_del(ugd->layout);
- ugd->layout = NULL;
-}
-
-static void on_message(ui_gadget_h ug, app_control_h msg, app_control_h service, void *priv)
-{
-}
-
-static void on_event(ui_gadget_h ug, enum ug_event event, app_control_h service, void *priv)
-{
- switch (event) {
- case UG_EVENT_LOW_MEMORY:
- break;
- case UG_EVENT_LOW_BATTERY:
- break;
- case UG_EVENT_LANG_CHANGE:
- break;
- case UG_EVENT_ROTATE_PORTRAIT:
- break;
- case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
- break;
- case UG_EVENT_ROTATE_LANDSCAPE:
- break;
- case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
- break;
- default:
- break;
- }
-}
-
-static void on_key_event(ui_gadget_h ug, enum ug_key_event event, app_control_h service, void *priv)
-{
- log_if(ug == NULL, 1, "ug is NULL");
-
- switch (event) {
- case UG_KEY_EVENT_END:
- ug_destroy_me(ug);
- break;
- default:
- break;
- }
-}
-
-UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
-{
- return_if(ops == NULL, , -1, "ops is NULL.");
-
- struct ug_data_s *ugd = (struct ug_data_s *)malloc(sizeof(struct ug_data_s));
- return_if(ugd == NULL, , -1, "Fail to malloc ugd.");
-
- ops->create = on_create;
- ops->start = on_start;
- ops->pause = on_pause;
- ops->resume = on_resume;
- ops->destroy = on_destroy;
- ops->message = on_message;
- ops->event = on_event;
- ops->key_event = on_key_event;
- ops->priv = ugd;
- ops->opt = UG_OPT_INDICATOR_ENABLE;
-
- g_ugd = ugd;
-
- return 0;
-}
-
-UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
-{
- log_if(ops == NULL, 1, "ops is NULL.");
-
- free(ops->priv);
-}
-
-UG_MODULE_API int setting_plugin_reset(app_control_h service, void *priv)
-{
- /* nothing to do for Setting>Reset */
- return 0;
-}
+++ /dev/null
-/**
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/*
- * @file privacy_list_view.c
- * @author Yunjin Lee (yunjin-.lee@samsung.com)
- * @version 1.0
- * @brief
- */
-
-#include <efl_extension.h>
-
-#include "common_utils.h"
-#include "privacy_setting_ug.h"
-#include "privacy_view.h"
-
-Eina_Bool quit_cb(void *data, Elm_Object_Item *it)
-{
- struct ug_data_s* ugd = (struct ug_data_s*)data;
- log_if(!ugd, 1, "ugd is null");
-
- ug_destroy_me(ugd->ug);
- ugd->ug = NULL;
- return EINA_FALSE;
-}
-
-static char* gl_text_get_cb(void *data, Evas_Object *obj, const char *part)
-{
- item_data_s *id = data;
- lreturn_if(!strcmp(part, "elm.text"), , strdup(id->title), "privacy = %s", id->title);
- return "FAIL";
-}
-static void gl_del_cb(void *data, Evas_Object *obj)
-{
- /* Unrealized callback can be called after this. */
- /* Accessing item_data_s can be dangerous on unrealized callback. */
- item_data_s *id = data;
- free(id);
-}
-
-static void privacy_selected_cb(void *data, Evas_Object *obj, void *event_info)
-{
- /* Get selected privacy */
- Elm_Object_Item *ei = event_info;
- item_data_s *selected_id = elm_object_item_data_get(ei);
- LOGD("%s is selected, index = %d", selected_id->title, selected_id->index);
-
- /* Unhighlight selected item */
- elm_genlist_item_selected_set(ei, EINA_FALSE);
-
- struct ug_data_s *ugd = (struct ug_data_s *)data;
- return_if(ugd == NULL, , , "ugd is null");
-
- create_privacy_package_list_view(ugd, selected_id);
-}
-
-/*Privacy List*/
-void create_privacy_list_view(struct ug_data_s *ugd)
-{
- Evas_Object *genlist = common_genlist_add(ugd->nf);
-
- evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
-
- Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
- itc->item_style = "default";
- itc->func.text_get = gl_text_get_cb;
- itc->func.del = gl_del_cb;
- Elm_Object_Item *it = NULL;
- int i = 0;
- for (i = 0; i < (int)g_list_length(ugd->privacy_list); ++i) {
- item_data_s *id = calloc(sizeof(item_data_s), 1);
- id->index = i;
- id->title = (char*)g_list_nth_data(ugd->privacy_list, i);
- it = elm_genlist_item_append(genlist, itc, id, NULL, ELM_GENLIST_ITEM_NONE, privacy_selected_cb, ugd);
- log_if(it == NULL, 1, "Error in elm_genlist_item_append");
- }
- elm_genlist_item_class_free(itc);
- evas_object_show(genlist);
-
- /* Change "Privacy Setting" to proper DID : use dgettext() */
- Elm_Object_Item *nf_it = elm_naviframe_item_push(ugd->nf, "Privacy Setting", common_back_btn_add(ugd), NULL, genlist, NULL);
- elm_object_item_domain_text_translatable_set(nf_it, PACKAGE, EINA_TRUE);
- elm_naviframe_item_pop_cb_set(nf_it, quit_cb, ugd);
-}
-
+++ /dev/null
-/**
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/*
- * @file privacy_package_list_view.c
- * @author Yunjin Lee (yunjin-.lee@samsung.com)
- * @version 1.0
- * @brief
- */
-
-#include <efl_extension.h>
-
-#include "common_utils.h"
-#include "privacy_setting_ug.h"
-#include "privacy_view.h"
-
-static void gl_del_cb(void *data, Evas_Object *obj)
-{
- /* Unrealized callback can be called after this. */
- /* Accessing item_data_s can be dangerous on unrealized callback. */
- item_data_s *id = data;
- free(id);
-}
-
-static void privacy_package_selected_cb(void *data, Evas_Object *obj, void *event_info)
-{
- Elm_Object_Item *ei = event_info;
- /* Unhighlight selected item */
- elm_genlist_item_selected_set(ei, EINA_FALSE);
- /* TBD? Add package's privacy info.
- For example, package's selected privacy related privilege list.
- Or remove. */
-}
-static char* gl_text_get_cb(void *data, Evas_Object *obj, const char *part)
-{
- item_data_s *id = data;
- lreturn_if(!strcmp(part, "elm.text"), , strdup(id->title), "privacy-package item = %s", id->title);
- return "FAIL";
-}
-static void privacy_package_check_changed_cb(void *data, Evas_Object *obj, void *event_info)
-{
- /* TBD: Add privacy on&off function */
- item_data_s *id = (item_data_s*)data;
- if (id->status)
- id->status = false;
- else
- id->status = true;
- Eina_Bool status = id->status;
- char* selected = (char*)id->title;
- if (status)
- LOGD("%s is on", selected);
- else if (!status)
- LOGD("%s is off", selected);
-}
-
-static Evas_Object* gl_content_get_cb(void *data, Evas_Object *obj, const char *part)
-{
- Evas_Object *check;
- item_data_s *id = (item_data_s*)data;
- Eina_Bool status = id->status;
-
- if (strcmp(part, "elm.swallow.end"))
- return NULL;
-
- check = elm_check_add(obj);
-
- elm_object_style_set(check, "on&off");
- elm_check_state_set(check, status);
- evas_object_repeat_events_set(check, EINA_FALSE);
- evas_object_propagate_events_set(check, EINA_FALSE);
- evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_smart_callback_add(check, "changed", privacy_package_check_changed_cb, data);
- evas_object_show(check);
-
- return check;
-}
-
-void create_privacy_package_list_view(struct ug_data_s* ugd, item_data_s *selected_id)
-{
- /* Add genlist */
- Evas_Object *genlist = common_genlist_add(ugd->nf);
-
- evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
-
- /* Set itc */
- Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
- itc->item_style = "default";
- itc->func.content_get = gl_content_get_cb;
- itc->func.text_get = gl_text_get_cb;
- itc->func.del = gl_del_cb;
-
- /* Append privacy related package as genlist item */
- /* TBD : Data should be replaced by privacy related package list */
- const char* items[] = {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven"};
- int i = 0;
- Elm_Object_Item *it = NULL;
- for (i = 0; i < 10; ++i) {
- item_data_s *id = calloc(sizeof(item_data_s), 1);
- id->index = i;
- char temp[256];
- snprintf(temp, sizeof(temp), "%s%s", selected_id->title, items[i]);
- id->title = strdup(temp);
- /* id->status = ; */
- it = elm_genlist_item_append(genlist, itc, id, NULL, ELM_GENLIST_ITEM_NONE, privacy_package_selected_cb, id);
- log_if(it == NULL, 1, "Error in elm_genlist_item_append");
- }
- elm_genlist_item_class_free(itc);
- evas_object_show(genlist);
-
- /* Push naviframe item */
- /* Change "Package List" to proper DID : use dgettext() */
- Elm_Object_Item *nf_it = elm_naviframe_item_push(ugd->nf, "Package List", common_back_btn_add(ugd), NULL, genlist, NULL);
- elm_object_item_domain_text_translatable_set(nf_it, PACKAGE, EINA_TRUE);
-}
--- /dev/null
+INCLUDE(FindPkgConfig)
+SET(pkg_name "org.tizen.privacy-setting")
+
+pkg_check_modules(${pkg_name} REQUIRED glib-2.0 ui-gadget-1 evas elementary edje eina efl-extension security-privilege-manager icu-i18n dlog security-manager pkgmgr-info)
+
+SET(SRCS
+ ${CMAKE_SOURCE_DIR}/common/src/common_utils.c
+ src/main_privacy_setting.c
+ src/privacy_menu_view.c
+ src/privacy_list_view.c
+ src/privacy_package_list_view.c
+)
+
+FOREACH(flag ${${pkg_name}_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE -Werror-implicit-function-declaration")
+INCLUDE_DIRECTORIES(
+ ${CMAKE_SOURCE_DIR}/common/include
+ ${CMAKE_SOURCE_DIR}/ui/include
+)
+
+ADD_EXECUTABLE(${pkg_name} ${SRCS})
+
+TARGET_LINK_LIBRARIES(${pkg_name}
+ ${${pkg_name}_LDFLAGS}
+)
+
+INSTALL(TARGETS ${pkg_name} DESTINATION ${BINDIR})
--- /dev/null
+/**
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * @file privacy_setting.h
+ * @author Yunjin Lee <yunjin-.lee@samsung.com>
+ * @version 1.0
+ * @brief
+ */
+
+#ifndef __UI_PRIVACY_SETTING_H__
+#define __UI_PRIVACY_SETTING_H__
+#include <Elementary.h>
+#include <ui-gadget.h>
+#include <ui-gadget-module.h>
+#include <glib.h>
+#include <app.h>
+
+#define PRIVACY_MENU_SETTING "Privacy Setting"
+#define PRIVACY_MENU_GUARD "Privacy Guard"
+
+struct app_data_s {
+ Evas_Object *parent_layout;
+ Evas_Object *win;
+ Evas_Object *conform;
+ Evas_Object *bg;
+ Evas_Object *layout;
+ Evas_Object *nf;
+ void *data;
+ Elm_Theme *theme;
+
+ GList *privacy_list;
+ char* privacy;
+};
+
+struct app_data_s *get_app_data();
+
+#endif /* __UI_PRIVACY_SETTING_H__ */
--- /dev/null
+/**
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * @file privacy_view.h
+ * @author Yunjin Lee <yunjin-.lee@samsung.com>
+ * @version 1.0
+ * @brief
+ */
+
+
+#include <Elementary.h>
+#include <ui-gadget.h>
+#include <ui-gadget-module.h>
+#include <glib.h>
+#include <app.h>
+
+#include "privacy_setting.h"
+
+typedef struct {
+ char* pkgid;
+ GList* applist;
+ GList* privlist;
+ bool change; /* toggle */
+ bool status; /* original status */
+} pkg_data_s;
+
+typedef struct item_data {
+ int index;
+ char *title;
+ char *pkgid;
+ bool status;
+} item_data_s;
+
+void create_privacy_package_list_view(struct app_data_s *ad, item_data_s *selected_id);
+
+void create_privacy_list_view(struct app_data_s *ad);
+
+void create_privacy_menu_view(struct app_data_s *ad);
--- /dev/null
+/**
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * @file main_privacy_setting.c
+ * @author Yunjin Lee (yunjin-.lee@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+#include <bundle.h>
+
+#include <libintl.h>
+#include <efl_extension.h>
+
+#include "common_utils.h"
+
+#include "privacy_setting.h"
+#include "privacy_view.h"
+
+static void win_delete_request_cb(void *data, Evas_Object * obj, void *event_info)
+{
+ ui_app_exit();
+}
+
+static void app_start(void* data)
+{
+ struct app_data_s* ad = (struct app_data_s*)data;
+
+ /* Add conformant to window */
+ ad->conform = elm_conformant_add(ad->win);
+ evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(ad->win, ad->conform);
+ evas_object_show(ad->conform);
+
+ /* Add layout to conformant */
+ ad->layout = elm_layout_add(ad->conform);
+ evas_object_size_hint_weight_set(ad->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_layout_theme_set(ad->layout, "layout", "application", "default");
+ elm_object_content_set(ad->conform, ad->layout);
+ evas_object_show(ad->layout);
+
+ /* Add naviframe to layout */
+ ad->nf = elm_naviframe_add(ad->layout);
+ log_if(!ad->nf, 1, "ad->nf is null");
+
+ /* Create privacy menu view */
+ create_privacy_menu_view(ad);
+
+ elm_object_part_content_set(ad->layout, "elm.swallow.content", ad->nf);
+ eext_object_event_callback_add(ad->nf, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
+ eext_object_event_callback_add(ad->nf, EEXT_CALLBACK_MORE, eext_naviframe_more_cb, NULL);
+ evas_object_show(ad->nf);
+
+ return ;
+}
+
+static bool app_create(void * data)
+{
+ struct app_data_s *ad = (struct app_data_s*)data;
+
+ elm_app_base_scale_set(1.8);
+
+ ad->win = elm_win_add(NULL, "setting-privacy", ELM_WIN_BASIC);
+ elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW);
+ elm_win_indicator_opacity_set(ad->win, ELM_WIN_INDICATOR_OPAQUE);
+
+ if (elm_win_wm_rotation_supported_get(ad->win)) {
+ int rots[4] = { 0, 90, 180, 270 };
+ elm_win_wm_rotation_available_rotations_set(ad->win, (const int *)(&rots), 4);
+ }
+ evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL);
+ evas_object_show(ad->win);
+
+ app_start(ad);
+
+ return true;
+}
+
+static void
+app_control(app_control_h app_control, void *data)
+{
+ /* Handle the launch request. */
+}
+
+static void
+app_pause(void *data)
+{
+ /* Take necessary actions when application becomes invisible. */
+}
+
+static void
+app_resume(void *data)
+{
+ /* Take necessary actions when application becomes visible. */
+}
+static void app_terminate(void *data)
+{
+}
+
+static void ui_app_lang_changed(app_event_info_h event_info, void *user_data)
+{
+ /*APP_EVENT_LANGUAGE_CHANGED*/
+}
+
+
+int main(int argc, char *argv[])
+{
+ struct app_data_s ad = {0, };
+ int ret = 0;
+
+ ui_app_lifecycle_callback_s event_callback = {0, };
+ app_event_handler_h handlers[2] = {NULL, };
+
+ ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, ui_app_lang_changed, &ad);
+
+ event_callback.create = app_create;
+ event_callback.terminate = app_terminate;
+ event_callback.pause = app_pause;
+ event_callback.resume = app_resume;
+ event_callback.app_control = app_control;
+
+ ret = ui_app_main(argc, argv, &event_callback, &ad);
+ if (ret != APP_ERROR_NONE)
+ dlog_print(DLOG_ERROR, LOG_TAG, "ui_app_main() is failed. err = %d", ret);
+
+ return 0;
+}
+
--- /dev/null
+/**
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * @file privacy_list_view.c
+ * @author Yunjin Lee (yunjin-.lee@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+#include <efl_extension.h>
+
+#include "common_utils.h"
+#include "privacy_setting.h"
+#include "privacy_view.h"
+
+static char* gl_text_get_cb(void *data, Evas_Object *obj, const char *part)
+{
+ item_data_s *id = data;
+ lreturn_if(!strcmp(part, "elm.text"), , strdup(id->title), "privacy = %s", id->title);
+ return "FAIL";
+}
+static void gl_del_cb(void *data, Evas_Object *obj)
+{
+ /* Unrealized callback can be called after this. */
+ /* Accessing item_data_s can be dangerous on unrealized callback. */
+ item_data_s *id = data;
+ free(id);
+}
+
+static void privacy_selected_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ /* Get selected privacy */
+ Elm_Object_Item *ei = event_info;
+ item_data_s *selected_id = elm_object_item_data_get(ei);
+ LOGD("%s is selected, index = %d", selected_id->title, selected_id->index);
+
+ /* Unhighlight selected item */
+ elm_genlist_item_selected_set(ei, EINA_FALSE);
+
+ struct app_data_s *ad = (struct app_data_s *)data;
+ return_if(ad == NULL, , , "ad is null");
+
+ ad->privacy = (char*)selected_id->title;
+
+ create_privacy_package_list_view(ad, selected_id);
+}
+
+/*Privacy List*/
+void create_privacy_list_view(struct app_data_s *ad)
+{
+ Evas_Object *genlist = common_genlist_add(ad->nf);
+
+ evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+ Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
+ itc->item_style = "default";
+ itc->func.text_get = gl_text_get_cb;
+ itc->func.del = gl_del_cb;
+ Elm_Object_Item *it = NULL;
+ int i = 0;
+ for (i = 0; i < (int)g_list_length(ad->privacy_list); ++i) {
+ item_data_s *id = calloc(sizeof(item_data_s), 1);
+ id->index = i;
+ id->title = (char*)g_list_nth_data(ad->privacy_list, i);
+ it = elm_genlist_item_append(genlist, itc, id, NULL, ELM_GENLIST_ITEM_NONE, privacy_selected_cb, ad);
+ log_if(it == NULL, 1, "Error in elm_genlist_item_append");
+ }
+ elm_genlist_item_class_free(itc);
+ evas_object_show(genlist);
+
+ /* Change "Privacy Setting" to proper DID : use dgettext() */
+ Elm_Object_Item *nf_it = elm_naviframe_item_push(ad->nf, "Privacy Setting", common_back_btn_add(ad), NULL, genlist, NULL);
+
+ elm_object_item_domain_text_translatable_set(nf_it, PACKAGE, EINA_TRUE);
+}
+
--- /dev/null
+/**
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * @file privacy_menu_view.c
+ * @author Yunjin Lee (yunjin-.lee@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+#include <efl_extension.h>
+#include <privilege_info.h>
+#include <glib.h>
+
+#include "common_utils.h"
+#include "privacy_setting.h"
+#include "privacy_view.h"
+
+GList *privacy_menu_list;
+
+static Eina_Bool quit_cb(void *data, Elm_Object_Item *it)
+{
+ struct app_data_s* ad = (struct app_data_s*)data;
+ return_if(!ad, , EINA_FALSE, "ad is null");
+ ui_app_exit();
+
+ return EINA_FALSE;
+}
+
+static char* gl_text_get_cb(void *data, Evas_Object *obj, const char *part)
+{
+ item_data_s *id = data;
+ /* TBD: Use dgettext when menu string is replaced by DID */
+ lreturn_if(!strcmp(part, "elm.text"), , strdup(id->title), "selected menu = %s", id->title);
+ return "FAIL";
+}
+static void gl_del_cb(void *data, Evas_Object *obj)
+{
+ /* Unrealized callback can be called after this. */
+ /* Accessing item_data_s can be dangerous on unrealized callback. */
+ item_data_s *id = data;
+ free(id);
+}
+
+static void menu_selected_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ /* Get selected privacy */
+ Elm_Object_Item *ei = event_info;
+ item_data_s *selected_id = elm_object_item_data_get(ei);
+ LOGD("%s is selected, index = %d", selected_id->title, selected_id->index);
+
+ /* Unhighlight selected item */
+ elm_genlist_item_selected_set(ei, EINA_FALSE);
+
+ struct app_data_s *ad = (struct app_data_s *)data;
+ return_if(ad == NULL, , , "ad is null");
+
+ if (strstr(selected_id->title, PRIVACY_MENU_SETTING) != NULL) {
+ int ret = privilege_info_get_privacy_list(&(ad->privacy_list));
+ log_if(ret != PRVMGR_ERR_NONE, 1, "Failed to get privacy_list");
+ create_privacy_list_view(ad);
+ } else if (strstr(selected_id->title, PRIVACY_MENU_GUARD) != NULL) {/* privacy guard */
+ /* TBD: Call privacy guard view */
+ } else {
+ LOGE("selected_id->title = %s, no matching menu", selected_id->title);
+ }
+}
+
+/*Privacy Menu List*/
+void create_privacy_menu_view(struct app_data_s *ad)
+{
+ Evas_Object *genlist = common_genlist_add(ad->nf);
+
+ evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+ /* Set privacy menu list */
+ privacy_menu_list = NULL;
+ privacy_menu_list = g_list_append(privacy_menu_list, PRIVACY_MENU_SETTING);
+ privacy_menu_list = g_list_append(privacy_menu_list, PRIVACY_MENU_GUARD);
+
+ Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
+ itc->item_style = "default";
+ itc->func.text_get = gl_text_get_cb;
+ itc->func.del = gl_del_cb;
+ Elm_Object_Item *it = NULL;
+ int i = 0;
+ for (i = 0; i < (int)g_list_length(privacy_menu_list); ++i) {
+ item_data_s *id = calloc(sizeof(item_data_s), 1);
+ id->index = i;
+ id->title = (char*)g_list_nth_data(privacy_menu_list, i);
+ it = elm_genlist_item_append(genlist, itc, id, NULL, ELM_GENLIST_ITEM_NONE, menu_selected_cb, ad);
+ log_if(it == NULL, 1, "Error in elm_genlist_item_append");
+ }
+ elm_genlist_item_class_free(itc);
+ evas_object_show(genlist);
+
+ /* Change "Privacy & Safety" to proper DID : use dgettext() */
+ Elm_Object_Item *nf_it = elm_naviframe_item_push(ad->nf, "Privacy & Safety", common_back_btn_add(ad), NULL, genlist, NULL);
+ elm_object_item_domain_text_translatable_set(nf_it, PACKAGE, EINA_TRUE);
+
+ elm_naviframe_item_pop_cb_set(nf_it, quit_cb, ad);
+}
+
--- /dev/null
+/**
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * @file privacy_package_list_view.c
+ * @author Yunjin Lee (yunjin-.lee@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+#include <efl_extension.h>
+#include <policy-manager.h>
+#include <privilege_info.h>
+#include <glib.h>
+#include <pkgmgr-info.h>
+
+#include "common_utils.h"
+#include "privacy_setting.h"
+#include "privacy_view.h"
+
+static GList* pkg_list;
+static GList* privilege_list;
+static GList* pkg_data_list;
+
+int change_cnt;
+Evas_Object *save_btn;
+bool first;
+
+#define UIDMAXLEN 10
+
+static void gl_del_cb(void *data, Evas_Object *obj)
+{
+ /* Unrealized callback can be called after this. */
+ /* Accessing item_data_s can be dangerous on unrealized callback. */
+ item_data_s *id = data;
+ free(id);
+}
+
+static void privacy_package_selected_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ Elm_Object_Item *ei = event_info;
+ /* Unhighlight selected item */
+ elm_genlist_item_selected_set(ei, EINA_FALSE);
+ /* TBD? Add package's privacy info.
+ For example, package's selected privacy related privilege list.
+ Or remove. */
+}
+static char* gl_text_get_cb(void *data, Evas_Object *obj, const char *part)
+{
+ item_data_s *id = data;
+ lreturn_if(!strcmp(part, "elm.text"), , strdup(id->title), "privacy-package item = %s", id->title);
+ return "FAIL";
+}
+
+static void privacy_package_check_changed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ struct app_data_s* ad = (struct app_data_s*)data;
+ item_data_s *id = (item_data_s*)data;
+ if (id->status)
+ id->status = EINA_FALSE;
+ else
+ id->status = EINA_TRUE;
+
+ char* selected = (char*)id->pkgid;
+ GList* l;
+
+ for (l = pkg_data_list; l != NULL; l = l->next) {
+ pkg_data_s* pkg_data = (pkg_data_s*)l->data;
+ char* pkgid = (char*)pkg_data->pkgid;
+ if (strcmp(selected, pkgid) == 0) {
+ if (pkg_data->change) {/* toggle */
+ --change_cnt;
+ pkg_data->change = false;
+ } else {
+ ++change_cnt;
+ pkg_data->change = true;
+ }
+ log_if(change_cnt < 0, 1, "change_cnt < 0");
+ }
+ }
+ if (change_cnt > 0) {
+ if (first) {
+ elm_object_text_set(save_btn, "SAVE");
+ elm_object_disabled_set(save_btn, EINA_FALSE);
+ }
+ evas_object_show(save_btn);
+ LOGD("save_btn enabled");
+ } else {
+ evas_object_hide(save_btn);
+ LOGD("save_btn diabled");
+ }
+}
+static void __get_package_privacy_status(pkg_data_s* pkg_data, char* privilege_name)
+{
+ GList* l;
+ char uid[UIDMAXLEN];
+ snprintf(uid, UIDMAXLEN, "%d", getuid());
+ for (l = pkg_data->applist; l != NULL; l = l->next) {
+ char* appid = (char*)l->data;
+
+ /* Make policy filter to get specific uid, appid and privilege's status */
+ policy_entry* p_filter;
+ int ret = 0;
+ ret = security_manager_policy_entry_new(&p_filter);
+ log_if(ret != SECURITY_MANAGER_SUCCESS, 1, "security_manager_policy_entry_new failed. ret = %s", ret);
+ log_if(p_filter == NULL, 1, "security_manager_policy_entry_new failed failed. creation of new policy entry did not allocate memory");
+ ret = security_manager_policy_entry_set_application(p_filter, appid);
+ log_if(ret != SECURITY_MANAGER_SUCCESS, 1, "security_manager_policy_entry_set_application failed. ret = %d", ret);
+ ret = security_manager_policy_entry_set_user(p_filter, uid);
+ log_if(ret != SECURITY_MANAGER_SUCCESS, 1, "security_manager_policy_entry_set_user failed. ret = %d", ret);
+ security_manager_policy_entry_set_privilege(p_filter, privilege_name);
+ log_if(ret != SECURITY_MANAGER_SUCCESS, 1, "security_manager_policy_entry_set_privilege failed. ret = %d", ret);
+
+ /* Get policy filtered by p_filter */
+ policy_entry **pp_policy = NULL;
+ size_t pp_policy_size = 0;
+ ret = security_manager_get_policy(p_filter, &pp_policy, &pp_policy_size);
+ log_if(ret != SECURITY_MANAGER_SUCCESS, 1, "security_manager_get_policy failed. ret = %d", ret);
+
+ /* Get level from policy */
+ unsigned int i = 0;
+ for (i = 0; i < pp_policy_size; ++i) {
+ char* result = (char*)security_manager_policy_entry_get_level(pp_policy[i]);
+ log_if(result == NULL, 1, "security_manager_policy_entry_get_level failed. No policy is declared for pkgid: %s, uid: %s, appid: %s, privilege: %s", pkg_data->pkgid, uid, appid, privilege_name);
+ if (strncmp("Allow", result, strlen("Allow")) == 0) {
+ pkg_data->status = EINA_TRUE;
+ break;
+ }
+ }
+
+ /* Free policy entries */
+ security_manager_policy_entry_free(p_filter);
+ for (i = 0; i < pp_policy_size ; ++i)
+ security_manager_policy_entry_free(pp_policy[i]);
+
+ if (pkg_data->status == EINA_TRUE)
+ break;
+ }
+}
+static Eina_Bool get_package_privacy_status(char* package)
+{
+ Eina_Bool status = EINA_FALSE;
+
+ GList* l;
+ for (l = pkg_data_list; l != NULL; l = l->next) {
+ pkg_data_s* pkg_data = (pkg_data_s*)l->data;
+ if (strcmp(pkg_data->pkgid, package) == 0) {
+ status = pkg_data->status;
+ break;
+ }
+ }
+
+ return status;
+}
+
+static Evas_Object* gl_content_get_cb(void *data, Evas_Object *obj, const char *part)
+{
+ Evas_Object *check;
+ item_data_s *id = (item_data_s*)data;
+ Eina_Bool status = id->status;
+
+ if (strcmp(part, "elm.swallow.end"))
+ return NULL;
+
+ check = elm_check_add(obj);
+
+ elm_object_style_set(check, "on&off");
+ elm_check_state_set(check, status);
+ evas_object_repeat_events_set(check, EINA_FALSE);
+ evas_object_propagate_events_set(check, EINA_FALSE);
+ evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_smart_callback_add(check, "changed", privacy_package_check_changed_cb, data);
+ evas_object_show(check);
+
+ return check;
+}
+
+static void _save_btn_clicked_cb(void *user_data, Evas_Object *obj, void *event_info)
+{
+
+ char uid[UIDMAXLEN];
+ snprintf(uid, UIDMAXLEN, "%d", getuid());
+
+ /* Send policy change request to security-manager */
+ GList* l;
+ GList* ll;
+ GList* lll;
+ int ret = 0;
+ for (l = pkg_data_list; l != NULL; l = l->next) {
+ pkg_data_s* pkg_data = (pkg_data_s*)l->data;
+ char* pkgid = (char*)pkg_data->pkgid;
+ if (pkg_data->change) {
+ char* level;
+ if (pkg_data->status) {
+ level = "Deny";
+ pkg_data->status = false;
+ } else {
+ level = "Allow";
+ pkg_data->status = true;
+ }
+
+ LOGD("%s will be changed to %s", pkgid, level);
+
+ int priv_num = g_list_length(pkg_data->privlist);
+ int app_num = g_list_length(pkg_data->applist);
+ int entry_num = priv_num*app_num;
+ LOGD("priv_num = %d, app_num = %d, entry_num = %d", priv_num, app_num, entry_num);
+
+ /* Make policy update request */
+ policy_update_req *policy_update_request;
+ ret = security_manager_policy_update_req_new(&policy_update_request);
+ log_if(ret != SECURITY_MANAGER_SUCCESS, 1, "security_manager_policy_update_req_new failed. ret = %d", ret);
+ log_if(policy_update_request == NULL, 1, "security_manager_policy_entry_new failed failed. creation of new policy request did not allocate memory");
+ /* Make policy entries to update according to the number of privilege and appid of package */
+ policy_entry *entry[entry_num];
+ int entry_index = 0;
+ for (ll = pkg_data->applist; ll != NULL; ll = ll->next) {
+ char* appid = (char*)ll->data;
+ for (lll = pkg_data->privlist; lll != NULL; lll = lll->next) {
+ char* privilege_name = (char*)lll->data;
+ LOGD("%d: Change to %s => uid: %s, appid: %s, privilege_name: %s", entry_index, level, uid, appid, privilege_name);
+ /* Make entries by each uid, appid, and privilege_name */
+ ret = security_manager_policy_entry_new(&entry[entry_index]);
+ log_if(ret != SECURITY_MANAGER_SUCCESS, 1, "security_manager_policy_entry_new failed. ret = %d", ret);
+ log_if(entry[entry_index] == NULL, 1, "security_manager_policy_entry_new failed failed. creation of new policy entry did not allocate memory");
+ ret = security_manager_policy_entry_set_application(entry[entry_index], appid);
+ log_if(ret != SECURITY_MANAGER_SUCCESS, 1, "security_manager_policy_entry_set_application failed. ret = %d", ret);
+ ret = security_manager_policy_entry_set_privilege(entry[entry_index], privilege_name);
+ log_if(ret != SECURITY_MANAGER_SUCCESS, 1, "security_manager_policy_entry_set_privilege failed. ret = %d", ret);
+ ret = security_manager_policy_entry_set_user(entry[entry_index], uid);
+ log_if(ret != SECURITY_MANAGER_SUCCESS, 1, "security_manager_policy_entry_set_user failed. ret = %d", ret);
+ ret = security_manager_policy_entry_set_level(entry[entry_index], level);
+ log_if(ret != SECURITY_MANAGER_SUCCESS, 1, "security_manager_policy_entry_set_level failed. ret = %d", ret);
+
+ /* Add entry to policy update request */
+ ret = security_manager_policy_update_req_add_entry(policy_update_request, entry[entry_index]);
+ log_if(ret != SECURITY_MANAGER_SUCCESS, 1, "security_manager_policy_update_req_add_entry failed. ret = %d", ret);
+ entry_index++;
+ }
+ }
+ /* Send policy update request */
+ ret = security_manager_policy_update_send(policy_update_request);
+ log_if(ret != SECURITY_MANAGER_SUCCESS, 1, "security-manager update req failed. ret = %d", ret);
+
+ /* Free policy entries */
+ for (--entry_index; entry_index >= 0; --entry_index)
+ security_manager_policy_entry_free(entry[entry_index]);
+
+ security_manager_policy_update_req_free(policy_update_request);
+ pkg_data->change = false;
+ }
+ }
+ change_cnt = 0;
+ evas_object_hide(save_btn);
+}
+
+static int pkg_app_list_cb(pkgmgrinfo_appinfo_h pkg_handle, void* user_data)
+{
+ char* appid = NULL;
+ pkg_data_s* pkg_data = (pkg_data_s*)user_data;
+ int ret = pkgmgrinfo_appinfo_get_appid(pkg_handle, &appid);
+ return_if(ret != PMINFO_R_OK, , -1, "pkgmgrinfo_appinfo_get_appid failed");
+ char* appidd = strdup(appid);
+ return_if(appid == NULL, , -1, "appid strdup failed");
+ pkg_data->applist = g_list_append(pkg_data->applist, appidd);
+ return ret;
+}
+
+static int pkg_list_cb(pkgmgrinfo_pkginfo_h filter_handle, void *user_data)
+{
+ char* privilege_name = strdup((char*)user_data);
+ char *pkgid = NULL;
+ int ret = pkgmgrinfo_pkginfo_get_pkgid(filter_handle, &pkgid);
+ char *pkgidd = strdup(pkgid);
+ return_if(ret != PMINFO_R_OK, , -1, "pkgmgrinfo_pkginfo_get_pkgname failed");
+ GList* find = g_list_find_custom(pkg_list, pkgid, (GCompareFunc)strcmp);
+ if (find != NULL) {
+ /* Add privilege info to package data list */
+ GList* l;
+ for (l = pkg_data_list; l != NULL; l = l->next) {
+ pkg_data_s* temp = (pkg_data_s*)l->data;
+ char* temp_pkgid = (char*)temp->pkgid;
+ if (strcmp(temp_pkgid, pkgid) == 0) {
+ temp->privlist = g_list_append(temp->privlist, privilege_name);
+ if (!temp->status)
+ __get_package_privacy_status(temp, privilege_name);
+ break;
+ }
+ }
+ return ret;
+ }
+
+ pkg_list = g_list_append(pkg_list, pkgidd);
+
+ /* Make package data item */
+ pkg_data_s *pkg_data = (pkg_data_s *)malloc(sizeof(pkg_data_s));
+
+ /* Add pkg id to package data item */
+ pkg_data->pkgid = strdup(pkgid);
+
+ /* Add privilege info to package data item */
+ pkg_data->privlist = NULL;
+ pkg_data->privlist = g_list_append(pkg_data->privlist, privilege_name);
+
+ /* Add app list to package data item */
+ pkg_data->applist = NULL;
+ pkgmgrinfo_pkginfo_h pkg_handle;
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &pkg_handle);
+ return_if(ret != PMINFO_R_OK, , -1, "pkgmgrinfo_pkginfo_get_pkginfo failed");
+ ret = pkgmgrinfo_appinfo_get_list(pkg_handle, PMINFO_ALL_APP, pkg_app_list_cb, pkg_data);
+ return_if(ret != PMINFO_R_OK, pkgmgrinfo_pkginfo_destroy_pkginfo(pkg_handle), -1, "pkgmgrinfo_appinfo_get_list failed");
+ pkgmgrinfo_pkginfo_destroy_pkginfo(pkg_handle);
+
+ /* Get package privacy status */
+ pkg_data->status = false;
+ pkg_data->change = false;
+ __get_package_privacy_status(pkg_data, privilege_name);
+
+ /* Append package data item to package_data_list */
+ pkg_data_list = g_list_append(pkg_data_list, pkg_data);
+ return ret;
+}
+static int get_uniq_pkg_list_by_privacy(const char* privacy)
+{
+ int ret = 0;
+ /* For privilege list loop -> Get pkg_list by privilege */
+ if (pkg_list != NULL) {
+ g_list_free(pkg_list);
+ pkg_list = NULL;
+ }
+ if (pkg_data_list != NULL) {
+ g_list_free(pkg_data_list);
+ pkg_data_list = NULL;
+ }
+ GList* l;
+ int uid = getuid();
+ for (l = privilege_list; l != NULL; l = l->next) {
+ char* privilege_name = (char*)l->data;
+ /* For each privilege */
+ pkgmgrinfo_pkginfo_filter_h filter_handle;
+ ret = pkgmgrinfo_pkginfo_filter_create(&filter_handle);
+ return_if(ret != PMINFO_R_OK, , -1, "pkgmgrinfo_pkginfo_filter_create failed");
+ ret = pkgmgrinfo_pkginfo_filter_add_string(filter_handle, PMINFO_PKGINFO_PROP_PACKAGE_PRIVILEGE, privilege_name);
+ LOGD("uid: %d, privacy: %s, privilege: %s", uid, privacy, privilege_name);
+ return_if(ret != PMINFO_R_OK, pkgmgrinfo_pkginfo_filter_destroy(filter_handle), -1, "pkgmgrinfo_pkginfo_filter_add_string failed");
+ /* Get uniq pkg list */
+ ret = pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo(filter_handle, pkg_list_cb, privilege_name, uid);
+ return_if(ret != PMINFO_R_OK, pkgmgrinfo_pkginfo_filter_destroy(filter_handle), -1, "pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo failed");
+ }
+
+ /* To check : each privacy related package's app, privilege info
+ for (l = pkg_data_list; l != NULL; l = l->next) {
+ pkg_data_s* temp = (pkg_data_s*)l->data;
+ LOGD(" * PACKAGE ID : %s", temp->pkgid);
+ GList* ll;
+ LOGD(" * APP ID");
+ for (ll = temp->applist; ll != NULL; ll = ll->next) {
+ char* temp_appid = (char*)ll->data;
+ LOGD(" - %s", temp_appid);
+ }
+ LOGD(" * PRIVILEGE");
+ for (ll = temp->privlist; ll != NULL; ll = ll->next) {
+ char* temp_privname = (char*)ll->data;
+ LOGD(" - %s", temp_privname);
+ }
+ }*/
+
+ return ret;
+}
+void create_privacy_package_list_view(struct app_data_s* ad, item_data_s *selected_id)
+{
+ /* Add genlist */
+ Evas_Object *genlist = common_genlist_add(ad->nf);
+
+ evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+ /* Set itc */
+ Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
+ itc->item_style = "default";
+ itc->func.content_get = gl_content_get_cb;
+ itc->func.text_get = gl_text_get_cb;
+ itc->func.del = gl_del_cb;
+
+ /* Get privilege list by privacy */
+ if (privilege_list != NULL) {
+ g_list_free(privilege_list);
+ privilege_list = NULL;
+ }
+ int ret = privilege_info_get_privilege_list_by_privacy(ad->privacy, &privilege_list);
+ log_if(ret != PRVMGR_ERR_NONE, 1, "Couldn't get privilege list of privacy: %s", ad->privacy);
+
+ /* Get unique package list filtered by given privacy related privileges */
+ ret = get_uniq_pkg_list_by_privacy(ad->privacy);
+ log_if(ret != 0, 1, "get_unique_pkg_list_by_privacy failed");
+ pkg_list = g_list_sort(pkg_list, (GCompareFunc)strcmp);
+
+ /* Append privacy related package as genlist item */
+ change_cnt = 0;
+ first = true;
+ GList* l;
+ int i = 0;
+ Elm_Object_Item *it = NULL;
+ for (l = pkg_list; l != NULL; l = l->next) {
+ item_data_s *id = calloc(sizeof(item_data_s), 1);
+ id->index = i++;
+ char temp[256];
+ char* pkg_name = (char*)l->data;
+ id->pkgid = strdup(pkg_name);
+ snprintf(temp, sizeof(temp), "%d : %s", i, pkg_name);
+ id->title = strdup(temp);
+ /* Get privacy status of given package */
+ id->status = get_package_privacy_status(pkg_name);
+ it = elm_genlist_item_append(genlist, itc, id, NULL, ELM_GENLIST_ITEM_NONE, privacy_package_selected_cb, id);
+ log_if(it == NULL, 1, "Error in elm_genlist_item_append");
+ }
+ elm_genlist_item_class_free(itc);
+ evas_object_show(genlist);
+
+ /* TBD: change nf_it_title to proper DID : use dgettext() */
+ char nf_it_title[256];
+ snprintf(nf_it_title, sizeof(nf_it_title), "%s Packages", ad->privacy);
+
+ /* Push naviframe item */
+ Elm_Object_Item *nf_it = elm_naviframe_item_push(ad->nf, nf_it_title, common_back_btn_add(ad), NULL, genlist, NULL);
+
+ /* Add button to save privacy package policy changes */
+ save_btn = elm_button_add(ad->nf);
+ evas_object_smart_callback_add(save_btn, "clicked", _save_btn_clicked_cb, ad);
+ elm_object_style_set(save_btn, "naviframe/title_right");
+ elm_object_disabled_set(save_btn, EINA_TRUE);
+ elm_object_item_part_content_set(nf_it, "title_right_btn", save_btn);
+
+ elm_object_item_domain_text_translatable_set(nf_it, PACKAGE, EINA_TRUE);
+}