--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(ug-im-ui C)
+
+INCLUDE(FindPkgConfig)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(PKGNAME "lib${PROJECT_NAME}")
+SET(LIBDIR "${PREFIX}/lib")
+SET(RESDIR "${PREFIX}/res")
+SET(LOCALEDIR "${RESDIR}/locale")
+
+SET(CMAKE_C_FLAGS_RELEASE "-g -O2")
+SET(CMAKE_C_FLAGS_DEBUG "-g -O0 -ggdb")
+SET(CMAKE_C_CFLAS_CCOV "-g -O2 --coverage")
+
+# Set compiler warning flags
+ADD_DEFINITIONS("-Werror")
+ADD_DEFINITIONS("-Wall")
+ADD_DEFINITIONS("-Wextra")
+
+ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
+ADD_DEFINITIONS("-DPKGNAME=\"${PKGNAME}\"")
+ADD_DEFINITIONS("-DPACKAGE_NAME=\"${PKGNAME}\"")
+ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
+ADD_DEFINITIONS("-DRESDIR=\"${RESDIR}\"")
+ADD_DEFINITIONS("-DLOCALEDIR=\"${LOCALEDIR}\"")
+
+IF (CMAKE_BUILD_TYPE MATCHES "DEBUG")
+ ADD_DEFINITIONS("-DTIZEN_DEBUG_ENABLE")
+ ADD_DEFINITIONS("-DBUILD_TYPE_DEBUG")
+ENDIF (CMAKE_BUILD_TYPE MATCHES "DEBUG")
+
+SET(TARGET_IM_UIGADGET "ug-im-ui")
+
+#${CMAKE_SOURCE_DIR}/packaging/im-ui.spec
+INSTALL(FILES
+ ${CMAKE_SOURCE_DIR}/packaging/im-ui.manifest
+ DESTINATION
+ /usr/share
+)
+
+# i18n
+ADD_SUBDIRECTORY(po)
+
+ADD_SUBDIRECTORY(src)
\ No newline at end of file
--- /dev/null
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
--- /dev/null
+/**
+ * Copyright (c) 2014 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 im-check-file.h
+ * @author Janusz Kozerski (j.kozerski@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+#ifndef __IM_CHECK_FILE_H__
+#define __IM_CHECK_FILE_H__
+
+#include "im-common.h"
+#include "im-uigadget.h"
+
+void im_check_file_cb (void *data, Evas_Object *obj, void *event_info);
+int im_check_file (struct ug_data *ad, const char* const file_path);
+
+#endif /* __IM_CHECK_FILE_H__ */
--- /dev/null
+/**
+ * Copyright (c) 2014 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 im-common.h
+ * @author Janusz Kozerski (j.kozerski@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+#ifndef __IM_COMMON_H__
+#define __IM_COMMON_H__
+
+#include "im-uigadget.h"
+
+Eina_Bool quit_cb(void *data, Elm_Object_Item *it);
+
+void show_file_selector(struct ug_data *ad, const char* const window_title);
+void create_ok_popup (struct ug_data *ad);
+
+void on_done (void *data, Evas_Object *obj, void *event_info);
+void genlist_clicked_cb (void *data, Evas_Object *obj, void *event_info);
+
+#endif /* __IM_COMMON_H__ */
--- /dev/null
+/**
+ * Copyright (c) 2014 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 im-compromised.h
+ * @author Janusz Kozerski (j.kozerski@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+#ifndef __IM_COMPROMISED_LIST_H__
+#define __IM_COMPROMISED_LIST_H__
+
+#include "im-uigadget.h"
+
+void im_compromised_list_cb(void *data, Evas_Object *obj, void *event_info);
+
+#endif /* __IM_COMPROMISED_LIST_H__ */
--- /dev/null
+/**
+ * Copyright (c) 2014 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 im-get-policy.h
+ * @author Janusz Kozerski (j.kozerski@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+#ifndef __IM_GET_POLICY_H__
+#define __IM_GET_POLICY_H__
+
+#include "im-uigadget.h"
+
+void im_get_policy_cb(void *data, Evas_Object *obj, void *event_info);
+
+#endif /* __IM_GET_POLICY_H__ */
--- /dev/null
+/**
+ * Copyright (c) 2014 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 im-load-policy.h
+ * @author Janusz Kozerski (j.kozerski@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+#ifndef __IM_LOAD_POLICY_H__
+#define __IM_LOAD_POLICY_H__
+
+#include "im-uigadget.h"
+
+void im_load_policy_cb(void *data, Evas_Object *obj, void *event_info);
+int im_load_policy_wrapper (struct ug_data *ad, const char* const file_path);
+
+#endif /* __IM_LOAD_POLICY_H__ */
--- /dev/null
+/**
+ * Copyright (c) 2014 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 im-main-menu.h
+ * @author Janusz Kozerski (j.kozerski@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+#ifndef __IM_MAIN_MENU_H__
+#define __IM_MAIN_MENU_H__
+
+#include "im-common.h"
+#include "im-uigadget.h"
+
+void im_main_menu_cb(void *data, Evas_Object *obj, void *event_info);
+
+#endif /* __IM_MAIN_MENU_H__ */
--- /dev/null
+/**
+ * Copyright (c) 2014 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 im-uigadget.h
+ * @author Janusz Kozerski (j.kozerski@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+#ifndef __IM_UIGADGET_H__
+#define __IM_UIGADGET_H__
+
+#include <app.h>
+#include <dlog.h>
+#include <efl_assist.h>
+#include <Elementary.h>
+#include <ui-gadget.h>
+#include <ui-gadget-module.h>
+#include <glib.h>
+
+#ifndef PACKAGE
+#define PACKAGE "ug-im-ui"
+#endif
+
+#ifndef LOCALEDIR
+#define LOCALEDIR "/res/locale"
+#endif
+
+struct ug_data {
+ Evas_Object *win_main;
+ Evas_Object *bg;
+ Evas_Object *layout_main;
+ Evas_Object *navi_bar;
+ ui_gadget_h ug;
+ Evas_Object *popup;
+ char *popup_content;
+ Elm_Theme *theme;
+ int (*file_action)(struct ug_data *ad, const char* const file_path);
+ const char *fileselector_default_path;
+};
+
+#ifdef LOG_TAG
+ #undef LOG_TAG
+#endif
+
+#ifndef LOG_TAG
+ #define LOG_TAG "IM_UIGADGET"
+#endif
+
+#endif /* __IM_UIGADGET_H__ */
--- /dev/null
+<manifest>
+ <define>
+ <domain name="im-ui"/>
+ </define>
+ <assign>
+ <filesystem path="/usr/ug/lib/*" label="_" />
+ <filesystem path="/usr/ug/res/*" label="_" />
+ </assign>
+</manifest>
--- /dev/null
+Name: im-ui
+Summary: Integrity Management UI
+Version: 0.0.1
+Release: 1
+Group: System/Libraries
+License: Apache License, Version 2.0
+Source0: %{name}-%{version}.tar.gz
+Source1: %{name}.manifest
+
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+BuildRequires: cmake
+BuildRequires: gettext-tools
+BuildRequires: edje-tools
+BuildRequires: pkgconfig(ail)
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(appcore-efl)
+BuildRequires: pkgconfig(appsvc)
+BuildRequires: pkgconfig(capi-appfw-application)
+BuildRequires: pkgconfig(edje)
+BuildRequires: pkgconfig(efl-assist)
+BuildRequires: pkgconfig(eina)
+BuildRequires: pkgconfig(elementary)
+BuildRequires: pkgconfig(evas)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(ui-gadget-1)
+BuildRequires: ima-evm-utils
+BuildRequires: openssl-devel
+
+%description
+Tizen Integrity Management UI
+
+%prep
+%setup -q
+
+%define _ugdir /usr/ug
+
+%build
+%{!?build_type:%define build_type "Release"}
+%cmake . -DVERSION=%{version} \
+ -DCMAKE_INSTALL_PREFIX="%{_ugdir}" \
+ -DCMAKE_BUILD_TYPE=%{build_type}
+make
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}/usr/share/license
+cp LICENSE %{buildroot}/usr/share/license/%{name}
+%make_install
+
+%clean
+rm -rf %{buildroot}
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files
+%defattr(-,root,root,-)
+%manifest %{_datadir}/im-ui.manifest
+%{_datadir}/license/%{name}
+%{_ugdir}/res/locale/*/LC_MESSAGES/*
+%{_ugdir}/lib/*so*
+
--- /dev/null
+SET(POFILES
+ en.po en_US.po
+)
+
+SET(MSGFMT "/usr/bin/msgfmt")
+
+FOREACH(pofile ${POFILES})
+ SET(pofile ${CMAKE_CURRENT_SOURCE_DIR}/${pofile})
+ MESSAGE("PO: ${pofile}")
+ GET_FILENAME_COMPONENT(absPofile ${pofile} ABSOLUTE)
+ GET_FILENAME_COMPONENT(lang ${absPofile} NAME_WE)
+ SET(moFile ${CMAKE_CURRENT_BINARY_DIR}/${lang}.mo)
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${moFile}
+ COMMAND ${MSGFMT} -o ${moFile} ${absPofile}
+ DEPENDS ${absPofile}
+ )
+ INSTALL(FILES ${moFile}
+ DESTINATION ${LOCALEDIR}/${lang}/LC_MESSAGES RENAME ${PROJECT_NAME}.mo)
+ SET(moFiles ${moFiles} ${moFile})
+ENDFOREACH(pofile)
+
+MESSAGE(".mo files: ${moFiles}")
+ADD_CUSTOM_TARGET(po ALL DEPENDS ${moFiles})
--- /dev/null
+msgid "IDS_ST_CHECK_FILE_MSG_BEGIN"
+msgstr "File "
+
+msgid "IDS_ST_CHECK_FILE_MSG_END"
+msgstr " was tested: OK"
+
+msgid "IDS_ST_CHECK_FILE_TITLE"
+msgstr "Choose file to check"
+
+msgid "IDS_ST_POLICY_LOAD_MSG_BEGIN"
+msgstr "Policy from file "
+
+msgid "IDS_ST_POLICY_LOAD_MSG_END"
+msgstr " was loaded"
+
+msgid "IDS_ST_POLICY_LOAD_TITLE"
+msgstr "Load policy"
+
+msgid "IDS_ST_BUTTON_OK"
+msgstr "OK"
+
+msgid "IDS_ST_BUTTON_CANCEL"
+msgstr "Cancel"
+
+msgid "IDS_ST_COMPROMISED_LIST_TITLE"
+msgstr "Compromised files list"
+
+msgid "IDS_ST_COMPROMISED_TITLE_IGNORED"
+msgstr "Measure ignored"
+
+msgid "IDS_ST_COMPROMISED_TITLE_DENIED"
+msgstr "Access denied"
+
+msgid "IDS_ST_IMA_ENABLE_DISABLE_SWITCH"
+msgstr "Enable/Disable"
+
+msgid "IDS_ST_IMA_FIX_MODE_CHECKBOX"
+msgstr "Fix Mode"
+
+msgid "IDS_ST_COMPROMISED_FILES_LIST"
+msgstr "List of compromised files"
+
+msgid "IDS_ST_LOAD_NEW_POLICY"
+msgstr "Load new policy"
+
+msgid "IDS_ST_CURRENT_POLICY"
+msgstr "Currently loaded policy"
+
+msgid "IDS_ST_GET_POLICY"
+msgstr "Get policy from kernel"
+
+msgid "IDS_ST_CHECK_FILE_STATE"
+msgstr "Check file state"
+
+msgid "IDS_ST_IMA_EVM_SETUP_MAIN"
+msgstr "IMA/EVM Setup"
+
--- /dev/null
+msgid "IDS_ST_CHECK_FILE_MSG_BEGIN"
+msgstr "File "
+
+msgid "IDS_ST_CHECK_FILE_MSG_END"
+msgstr " was tested: OK"
+
+msgid "IDS_ST_CHECK_FILE_TITLE"
+msgstr "Choose file to check"
+
+msgid "IDS_ST_POLICY_LOAD_MSG_BEGIN"
+msgstr "Policy from file "
+
+msgid "IDS_ST_POLICY_LOAD_MSG_END"
+msgstr " was loaded"
+
+msgid "IDS_ST_POLICY_LOAD_TITLE"
+msgstr "Load policy"
+
+msgid "IDS_ST_BUTTON_OK"
+msgstr "OK"
+
+msgid "IDS_ST_BUTTON_CANCEL"
+msgstr "Cancel"
+
+msgid "IDS_ST_COMPROMISED_LIST_TITLE"
+msgstr "Compromised files list"
+
+msgid "IDS_ST_COMPROMISED_TITLE_IGNORED"
+msgstr "Measure ignored"
+
+msgid "IDS_ST_COMPROMISED_TITLE_DENIED"
+msgstr "Access denied"
+
+msgid "IDS_ST_IMA_ENABLE_DISABLE_SWITCH"
+msgstr "Enable/Disable"
+
+msgid "IDS_ST_IMA_FIX_MODE_CHECKBOX"
+msgstr "Fix Mode"
+
+msgid "IDS_ST_COMPROMISED_FILES_LIST"
+msgstr "List of compromised files"
+
+msgid "IDS_ST_LOAD_NEW_POLICY"
+msgstr "Load new policy"
+
+msgid "IDS_ST_CURRENT_POLICY"
+msgstr "Currently loaded policy"
+
+msgid "IDS_ST_GET_POLICY"
+msgstr "Get policy from kernel"
+
+msgid "IDS_ST_CHECK_FILE_STATE"
+msgstr "Check file state"
+
+msgid "IDS_ST_IMA_EVM_SETUP_MAIN"
+msgstr "IMA/EVM Setup"
+
--- /dev/null
+pkg_check_modules(im-uigadget_pkgs
+ REQUIRED
+ elementary
+ ui-gadget-1
+ evas
+ efl-assist
+ dlog
+ #libima
+)
+
+SET(SRCS
+ im-check-file.c
+ im-common.c
+ im-compromised-list.c
+ im-load-policy.c
+ im-get-policy.c
+ im-main-menu.c
+ im-uigadget.c
+)
+
+SET(CMAKE_INSTALL_RPATH "${PREFIX}/lib")
+
+INCLUDE_DIRECTORIES(
+ ${CMAKE_SOURCE_DIR}/include
+)
+
+INCLUDE_DIRECTORIES(SYSTEM
+ ${im-uigadget_pkgs_INCLUDE_DIRS}
+)
+
+ADD_LIBRARY(${TARGET_IM_UIGADGET} SHARED ${SRCS})
+
+TARGET_LINK_LIBRARIES(${TARGET_IM_UIGADGET}
+ ${im-uigadget_pkgs_LIBRARIES}
+ ${im-uigadget_pkgs_LDFLAGS}
+ imaevm
+)
+
+INSTALL(TARGETS
+ ${TARGET_IM_UIGADGET}
+ DESTINATION
+ ${LIBDIR}
+)
--- /dev/null
+/**
+ * Copyright (c) 2014 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 im-check-file.c
+ * @author Janusz Kozerski (j.kozerski@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+#include "im-common.h"
+#include "im-uigadget.h"
+#include "im-check-file.h"
+
+#define CHECK_FILE_DEFAULT_PATH "/"
+#define MESSAGE_BEGIN "IDS_ST_CHECK_FILE_MSG_BEGIN"
+#define MESSAGE_END "IDS_ST_CHECK_FILE_MSG_END"
+#define FILE_SELECTOR_TITLE "IDS_ST_CHECK_FILE_TITLE"
+
+void im_check_file_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ LOGD("Enter function: %s", __func__);
+ // Unused param warning
+ (void)obj;
+ (void)event_info;
+
+ struct ug_data *ad = (struct ug_data*) data;
+ ad->file_action = im_check_file;
+ ad->fileselector_default_path = CHECK_FILE_DEFAULT_PATH;
+
+ show_file_selector(ad, dgettext(PACKAGE, FILE_SELECTOR_TITLE));
+}
+
+int im_check_file (struct ug_data *ad, const char* const file_path)
+{
+ LOGD("Enter function: %s", __func__);
+ // TODO: This function should internally call
+ // policy loader from ima-evm-utils library
+
+ size_t size = strlen(dgettext(PACKAGE, MESSAGE_BEGIN)) +
+ strlen(dgettext(PACKAGE, MESSAGE_END)) +
+ strlen(file_path) + 1; // Use asprintf?
+ ad->popup_content = malloc(sizeof(char) * size); // One more char to add NULL at the end
+ snprintf(ad->popup_content, size, "%s%s%s", dgettext(PACKAGE, MESSAGE_BEGIN),
+ file_path, dgettext(PACKAGE, MESSAGE_END));
+ ad->popup_content[size-1] = '\0';
+
+ create_ok_popup(ad);
+ return 0;
+}
--- /dev/null
+/**
+ * Copyright (c) 2014 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 im-common.c
+ * @author Janusz Kozerski (j.kozerski@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+#include "im-common.h"
+#include "im-uigadget.h"
+#include "im-load-policy.h"
+
+static void _pop_response_ok_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ LOGD("Enter function: %s", __func__);
+ (void)obj;
+ (void)event_info;
+ if (NULL == data) {
+ return;
+ }
+
+ if (((struct ug_data*)data)->popup) {
+ evas_object_del(((struct ug_data*)data)->popup);
+ ((struct ug_data*)data)->popup = NULL;
+ }
+
+ free(((struct ug_data*)data)->popup_content);
+ ((struct ug_data*)data)->popup_content = NULL;
+}
+
+// Because of bug in fileselector, if no file was selected then the return string
+// will be "//" instead of NULL pointer. Also if the selected file (e.g. "example.file")
+// is in the root directory ("/") then the return string will be "//examlpe.file" instead
+// of "/example.file". This function will fix the path. You have to free the memory
+// allocated by this function using free().
+static char* _fix_file_path(const char* const path)
+{
+ LOGD("Enter function: %s", __func__);
+ const char* const BAD_PATH = "//";
+ char* fixed_path = NULL;
+
+ if (!path)
+ return NULL;
+
+ if (!strncmp(BAD_PATH, path, 3))
+ return NULL;
+
+ if (!strncmp(BAD_PATH, path, 2)) {
+ size_t size = strlen(path);
+ fixed_path = malloc(sizeof(char) * size);
+ strncpy(fixed_path, &(path[1]), size); // copy original string ignoring first char ("/")
+ fixed_path[size-1] = '\0';
+ return fixed_path;
+ }
+
+ return strdup(path);
+}
+
+static void _fs_done(void *data, Evas_Object *obj, void *event_info)
+{
+ LOGD("Enter function: %s", __func__);
+ (void)obj;
+ (void)event_info;
+
+ struct ug_data *ad = (struct ug_data*) data;
+
+ LOGD("Path returned by file selector: %s", event_info);
+ // event_info contains (char*) full path to the selected file or NULL if Cancel button was pushed
+ const char *path = _fix_file_path((const char* const) event_info);
+ LOGD("Fixed path : %s", path);
+ if (path) {
+ // Set and run proper action for the selected file
+ int (*file_action)(struct ug_data *ad, const char* const file_path) = ad->file_action;
+ file_action(ad, path);
+ free((void*)path);
+ }
+
+ on_done(data, NULL, NULL);
+}
+
+void on_done(void *data, Evas_Object *obj, void *event_info)
+{
+ LOGD("Enter function: %s", __func__);
+ (void)obj;
+ (void)event_info;
+
+ struct ug_data *ad = (struct ug_data*) data;
+ elm_naviframe_item_pop(ad->navi_bar);
+}
+
+Eina_Bool quit_cb(void *data, Elm_Object_Item *it)
+{
+ LOGD("Enter function: %s", __func__);
+ (void)it;
+
+ struct ug_data *ad = (struct ug_data*) data;
+
+ if (ad->ug) {
+ ug_destroy_me(ad->ug);
+ ad->ug = NULL;
+ }
+
+ return EINA_TRUE;
+}
+
+void genlist_clicked_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ (void)data;
+ (void)event_info;
+
+ Elm_Object_Item *it = (Elm_Object_Item *) elm_genlist_selected_item_get(obj);
+ if (it == NULL)
+ return;
+
+ elm_genlist_item_selected_set(it, EINA_FALSE);
+}
+
+void show_file_selector(struct ug_data *ad, const char* const window_title)
+{
+ LOGD("Enter function: %s", __func__);
+ if (!ad)
+ return;
+ Evas_Object *file_selector = NULL;
+ Elm_Object_Item *nf_it = NULL;
+
+ file_selector = elm_fileselector_add(ad->navi_bar);
+ elm_fileselector_mode_set(file_selector, ELM_FILESELECTOR_LIST);
+ elm_fileselector_expandable_set(file_selector, EINA_FALSE);
+ elm_fileselector_path_set(file_selector, ad->fileselector_default_path);
+ elm_fileselector_buttons_ok_cancel_set (file_selector, EINA_TRUE);
+
+ // "done" callback is called when user click OK/Cancel button
+ evas_object_smart_callback_add(file_selector, "done", _fs_done, ad);
+
+ nf_it = elm_naviframe_item_push(ad->navi_bar, window_title, NULL, NULL, file_selector, NULL);
+ //elm_object_item_domain_text_translatable_set(nf_it, PACKAGE, EINA_TRUE);
+
+ elm_naviframe_item_pop_cb_set(nf_it, NULL, NULL);
+
+ elm_naviframe_prev_btn_auto_pushed_set(ad->navi_bar, EINA_FALSE);
+ ea_object_event_callback_add(ad->navi_bar, EA_CALLBACK_BACK, ea_naviframe_back_cb, NULL);
+ ea_object_event_callback_add(ad->navi_bar, EA_CALLBACK_MORE, ea_naviframe_more_cb, NULL);
+}
+
+void create_ok_popup(struct ug_data *ad)
+{
+ LOGD("Enter function: %s", __func__);
+ if (NULL == ad) {
+ return;
+ }
+
+#ifdef FEATURE_MULTIWINDOW_ENABLE
+ ad->popup = ea_center_popup_add(ad->navi_bar);
+#else
+ ad->popup = elm_popup_add(ad->navi_bar);
+#endif
+ if (NULL == ad->popup) {
+ return;
+ }
+
+ evas_object_size_hint_weight_set(ad->popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+ //ok button
+ Evas_Object *btn_ok = elm_button_add(ad->popup);
+ elm_object_domain_translatable_text_set(btn_ok, PACKAGE, "IDS_ST_BUTTON_OK");
+ elm_object_style_set(btn_ok, "popup");
+ evas_object_smart_callback_add(btn_ok, "clicked", _pop_response_ok_cb, ad);
+
+ elm_object_text_set(ad->popup, ad->popup_content);
+
+ // Do we need it?
+ //evas_object_smart_callback_add(ad->popup, "language,changed", _popup_lang_changed, contentId);
+
+ elm_object_part_content_set(ad->popup, "button1", btn_ok);
+
+ ea_object_event_callback_add(ad->popup, EA_CALLBACK_BACK, _pop_response_ok_cb, ad);
+
+ evas_object_show(ad->popup);
+
+ return;
+}
--- /dev/null
+/**
+ * Copyright (c) 2014 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 im-compromised-list.c
+ * @author Janusz Kozerski (j.kozerski@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+//#include <imaevm.h>
+
+#include "im-common.h"
+#include "im-uigadget.h"
+#include "im-compromised-list.h"
+
+/************************ Genlist Item Class ************************/
+#define ITC_TYPE_TITLE (int)0
+#define ITC_TYPE_LIST 1
+#define ITC_TYPE_SEPARATOR 2
+#define ITC_TYPE_MAX 3
+
+static Elm_Genlist_Item_Class *_itc[ITC_TYPE_MAX] = {NULL, NULL, NULL};
+
+typedef struct ItemData_s {
+ const char* label;
+ const char* label2;
+ int elm_genlist_item_type;
+} ItemData_t;
+
+static void* _create_item_data(const char* const label, const char* const label2, const int item_type)
+{
+ LOGD("Enter function: %s", __func__);
+ ItemData_t *itemD = malloc(sizeof(ItemData_t));
+ if (!itemD)
+ return NULL;
+
+ itemD->elm_genlist_item_type = item_type;
+
+ if (label)
+ itemD->label = strdup(label);
+ else
+ itemD->label = NULL;
+
+ if (label2)
+ itemD->label2 = strdup(label2);
+ else
+ itemD->label2 = NULL;
+
+ return (void *) itemD;
+}
+
+static void _gl_del(void *data, Evas_Object *obj)
+{
+ (void)obj;
+
+ // Cleaning ItemData_t structure
+ if (!data)
+ return;
+
+ free((char*)((ItemData_t *)data)->label);
+ free((char*)((ItemData_t *)data)->label2);
+ free(data);
+
+}
+
+static char * _item_title_label_get(void *data, Evas_Object *obj, const char *part)
+{
+ (void)obj;
+ (void)part;
+
+ return strdup(((ItemData_t *)data)->label);
+}
+
+static char * _item_file_label_get(void *data, Evas_Object *obj, const char *part)
+{
+ (void)obj;
+
+ if (!strcmp(part, "elm.text.1")) {
+ return strdup(((ItemData_t *)data)->label);
+ }
+ else {
+ return strdup(((ItemData_t *)data)->label2);
+ }
+}
+
+static Evas_Object *_item_content_get(void *data, Evas_Object *obj, const char *part)
+{
+ (void)data;
+ (void)obj;
+ (void)part;
+ return NULL;
+}
+
+static void _create_itc(int itc_type)
+{
+ if (itc_type >= ITC_TYPE_MAX || itc_type < 0)
+ return; // Incorrect itc_type
+
+ if(_itc[itc_type])
+ return; // This type was already created
+
+ _itc[itc_type] = elm_genlist_item_class_new();
+
+ switch (itc_type) {
+ case ITC_TYPE_TITLE:
+ _itc[itc_type]->item_style = "dialogue/grouptitle";
+ _itc[itc_type]->func.text_get = _item_title_label_get;
+ break;
+ case ITC_TYPE_LIST:
+ //_itc[itc_type]->item_style = eina_stringshare_add(str); // ???
+ _itc[itc_type]->item_style = "dialogue/2text.2";
+
+ _itc[itc_type]->func.text_get = _item_file_label_get;
+ break;
+ case ITC_TYPE_SEPARATOR:
+ _itc[itc_type]->item_style = "dialogue/separator";
+ _itc[itc_type]->func.text_get = NULL;
+ break;
+ default:
+ break;
+ }
+ _itc[itc_type]->func.content_get = _item_content_get;
+ _itc[itc_type]->func.state_get = NULL;
+ _itc[itc_type]->func.del = _gl_del;
+}
+
+static void _free_itc()
+{
+ int i = 0;
+ for(; i<ITC_TYPE_MAX; ++i) {
+ elm_genlist_item_class_free(_itc[i]);
+ _itc[i] = NULL;
+ }
+}
+
+// elm_genlist_item_append wrapper
+static Elm_Object_Item * _add_genlist_item(
+ Evas_Object *genlist,
+ int itc_class,
+ const char* const file_name,
+ const char* const path,
+ Evas_Smart_Cb callback_func
+ )
+{
+ LOGD("Enter function: %s", __func__);
+ Elm_Object_Item *item;
+ void * data = _create_item_data(
+ file_name,
+ path,
+ (itc_class == ITC_TYPE_TITLE) ? ELM_GENLIST_ITEM_GROUP : ELM_GENLIST_ITEM_NONE);
+ if (!data)
+ return NULL; // Error while allocating memory
+
+ item = elm_genlist_item_append(
+ genlist, // Genlist object
+ _itc[itc_class], // Item class
+ data, // Item data
+ NULL, // Parrent
+ ((ItemData_t *)data)->elm_genlist_item_type, //ELM_GENLIST_ITEM_GROUP, //ELM_GENLIST_ITEM_NONE, // Item type
+ callback_func, // select callback
+ data); // callback data
+ elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+ return item;
+}
+/********************************************************************/
+
+/***** Stub functions - will be replaced with functions from ima-evm-utils library *****/
+static void _stub_get_list_compromised_files1(char ***files_list)
+{
+ const char* const file[] = {"/example.file", "/usr/file", "/usr/bin/bash", "not-real-file", "/usr/bin/dlogutil"};
+ int i;
+
+ // 5 example files;
+ (*files_list) = malloc(6 * sizeof(char*));
+ for(i=0; i<5; ++i) {
+ (*files_list)[i] = strdup(file[i]);
+ }
+ (*files_list)[i] = NULL;
+}
+/***************************************************************************************/
+
+static void _free_list(char **list)
+{
+ int i=0;
+ while (list[i]) {
+ free(list[i]);
+ ++i;
+ }
+ free(list);
+}
+
+// This function fill separate full file path (e.g. "/usr/bin/bash")
+// to the file name ("bash") and the location ("/usr/bin"), by putting '\0' in place
+// of last '/' character, and returning pointer to file_name.
+// Notice that if file is in root directory "/" then the '/' sign will be replaced by '\0'
+// so you have to put "/" as the path manually.
+// This function will no allocate any memory.
+static char* _speparate_file_name(char * file_path)
+{
+ LOGD("Enter function: %s", __func__);
+ char *file_name = NULL;
+
+ if (!file_path)
+ return NULL;
+ file_name = strrchr(file_path, '/');
+ if(file_name != NULL) {
+ *file_name = '\0';
+ LOGD("Dir: %s", file_path[0]=='\0' ? "/" : file_path);
+ LOGD("File name: %s", file_name);
+ return file_name + sizeof(char);
+ }
+ else // Character '/' wasn't found in file path. Something went wrong. Ignoring file.
+ return NULL;
+}
+
+void im_compromised_list_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ LOGD("Enter function: %s", __func__);
+ (void)obj;
+ (void)event_info;
+
+ struct ug_data *ad = (struct ug_data*) data;
+ char **files_list;
+ char *file_name;
+ int i;
+ Evas_Object *genlist = NULL;
+ Elm_Object_Item *nf_it = NULL;
+
+ for (i=0; i<ITC_TYPE_MAX; ++i) {
+ _create_itc(i); // Creating all item classes
+ }
+
+ genlist = elm_genlist_add(ad->navi_bar);
+ elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
+
+ evas_object_smart_callback_add(genlist, "selected", genlist_clicked_cb, NULL);
+
+ // -------------------------------
+ // Add list separator 1
+ nf_it = _add_genlist_item(genlist, ITC_TYPE_SEPARATOR, NULL, NULL, genlist_clicked_cb);
+
+ // Add title of list 1
+ nf_it = _add_genlist_item(genlist, ITC_TYPE_TITLE,
+ dgettext(PACKAGE, "IDS_ST_COMPROMISED_TITLE_IGNORED"), NULL, genlist_clicked_cb);
+ elm_object_item_domain_text_translatable_set(nf_it, PACKAGE, EINA_TRUE);
+
+ // Add compromised files list 1
+ _stub_get_list_compromised_files1(&files_list); // TODO: Replace it with function from ima-evm-utils library
+ i = 0;
+ while (files_list[i]) {
+ LOGD("Compromised file[%d]: %s", i, files_list[i]);
+ file_name = _speparate_file_name(files_list[i]);
+ if (!file_name) { // File name not found - ignoring the file
+ ++i;
+ continue;
+ }
+ nf_it = _add_genlist_item(genlist, ITC_TYPE_LIST, file_name,
+ (files_list[i][0] == '\0' ? "/" : files_list[i]), genlist_clicked_cb);
+ elm_object_item_domain_text_translatable_set(nf_it, PACKAGE, EINA_FALSE);
+ ++i;
+ }
+ _free_list(files_list);
+
+ // -----------------------------------
+ // Add list separator 2
+ nf_it = _add_genlist_item(genlist, ITC_TYPE_SEPARATOR, NULL, NULL, genlist_clicked_cb);
+
+ // Add title of list 2
+ nf_it = _add_genlist_item(genlist, ITC_TYPE_TITLE,
+ dgettext(PACKAGE, "IDS_ST_COMPROMISED_TITLE_DENIED"), NULL, genlist_clicked_cb);
+ elm_object_item_domain_text_translatable_set(nf_it, PACKAGE, EINA_TRUE);
+
+ // Add compromised files list 2
+ _stub_get_list_compromised_files1(&files_list); // TODO: Replace it with function from ima-evm-utils library
+ i = 0;
+ while (files_list[i]) {
+ LOGD("Compromised file[%d]: %s", i, files_list[i]);
+ file_name = _speparate_file_name(files_list[i]);
+ if (!file_name) { // File name not found - ignoring the file
+ ++i;
+ continue;
+ }
+ nf_it = _add_genlist_item(genlist, ITC_TYPE_LIST, file_name,
+ (files_list[i][0] == '\0' ? "/" : files_list[i]), genlist_clicked_cb);
+ elm_object_item_domain_text_translatable_set(nf_it, PACKAGE, EINA_FALSE);
+ ++i;
+ }
+ _free_list(files_list);
+
+ // -----------------------------------
+ // Add list separator 3
+ nf_it = _add_genlist_item(genlist, ITC_TYPE_SEPARATOR, NULL, NULL, genlist_clicked_cb);
+
+ nf_it = elm_naviframe_item_push(ad->navi_bar, dgettext(PACKAGE, "IDS_ST_COMPROMISED_LIST_TITLE"), NULL, NULL, genlist, NULL);
+ elm_object_item_domain_text_translatable_set(nf_it, PACKAGE, EINA_TRUE);
+
+ _free_itc();
+
+ elm_naviframe_item_pop_cb_set(nf_it, NULL, NULL);
+
+ elm_naviframe_prev_btn_auto_pushed_set(ad->navi_bar, EINA_FALSE);
+ ea_object_event_callback_add(ad->navi_bar, EA_CALLBACK_BACK, ea_naviframe_back_cb, NULL);
+ ea_object_event_callback_add(ad->navi_bar, EA_CALLBACK_MORE, ea_naviframe_more_cb, NULL);
+}
--- /dev/null
+/**
+ * Copyright (c) 2014 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 im-get-policy.c
+ * @author Janusz Kozerski (j.kozerski@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+#include "im-uigadget.h"
+#include "im-common.h"
+#include "im-get-policy.h"
+
+/************************ Genlist Item Class ************************/
+static void _gl_del(void *data, Evas_Object *obj)
+{
+ // Cleaning formated policy string
+ (void)obj;
+ if (data)
+ free(data);
+}
+
+static char * _item_label_get(void *data, Evas_Object *obj, const char *part)
+{
+ (void)obj;
+ (void)part;
+ return strdup(data);
+}
+
+// Needed because of GCC "missing initializer" error
+#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
+static Elm_Genlist_Item_Class _itc_policy_content = {
+ .item_style = "multiline/1text",
+ .func.text_get = _item_label_get,
+ .func.content_get = NULL,
+ .func.state_get = NULL,
+ .func.del = _gl_del
+};
+#pragma GCC diagnostic pop // Restoring GCC command line parameters
+/********************************************************************/
+
+// This function will format policy to EFL usable string ("<br>" as a new line
+// sign). You have to free() the memory that's allocated by this function.
+static char* _convert_policy (const char *const *const policy)
+{
+ LOGD("Enter function: %s", __func__);
+ char *new_policy = NULL;
+ char *tmp = NULL;
+ const char* const new_line_sign = "<br>";
+ size_t nls_size = strlen(new_line_sign);
+ size_t size = 0;
+ int i = 0;
+
+ // Counting size for policy rules
+ while (policy[i] != NULL) {
+ size += strlen(policy[i]);
+ ++i;
+ }
+ // Size of new line signs after every policy rule except the last one.
+ size += nls_size * (i - 1);
+
+ // NULL sign at the end
+ size += 1;
+
+ new_policy = malloc(size * sizeof(char));
+ if (!new_policy)
+ return NULL;
+
+ i = 0;
+ tmp = new_policy;
+ while (policy[i] != NULL) {
+ LOGD("Policy rule no. %d: %s", i, policy[i]);
+ strcpy(tmp, policy[i]);
+ tmp += strlen(policy[i]);
+ if (policy[i+1] != NULL) { //Appending new_line_sign only if it's not the last rule
+ strcpy(tmp, new_line_sign);
+ tmp += nls_size;
+ }
+ ++i;
+ }
+ new_policy[size] = '\0';
+
+ LOGD("Formated Policy: %s", new_policy);
+ return new_policy;
+}
+
+void im_get_policy_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ LOGD("Enter function: %s", __func__);
+ (void)obj;
+ (void)event_info;
+
+ struct ug_data *ad = (struct ug_data*) data;
+ int i;
+ Evas_Object *genlist = NULL;
+ Elm_Object_Item *nf_it = NULL;
+ char **policy = NULL;
+ char *formated_policy = NULL;
+
+ // TODO: Call function from libIMA to get currently loaded policy
+ // int res = ima_get_ima_policy(&policy);
+ // Check error code: if (res) {return;}
+ // Temporary allocation - will be removed when function from libIMA will be used
+ policy = calloc(4, sizeof(char*));
+ policy[0] = strdup("MEASURE something");
+ policy[1] = strdup("MEASUER something else");
+ policy[2] = strdup("DONT_MEASURE file");
+ // ------------
+
+ formated_policy = _convert_policy((const char *const *const) policy);
+ i = 0;
+ while (policy[i] != NULL) {
+ free(policy[i]);
+ policy[i] = NULL;
+ ++i;
+ }
+ free(policy);
+ policy = NULL;
+
+ if (!formated_policy)
+ return;
+
+ genlist = elm_genlist_add(ad->navi_bar);
+ if (!genlist)
+ return;
+
+ elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
+ evas_object_smart_callback_add(genlist, "selected", genlist_clicked_cb, NULL);
+
+ nf_it = elm_genlist_item_append(
+ genlist, // Genlist object
+ &_itc_policy_content, // Item class
+ formated_policy, // Item data
+ NULL, // Parrent
+ ELM_GENLIST_ITEM_NONE, // Item type
+ genlist_clicked_cb, // select callback
+ NULL); // callback data
+ elm_genlist_item_select_mode_set(nf_it, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+
+ nf_it = elm_naviframe_item_push(ad->navi_bar, dgettext(PACKAGE, "IDS_ST_CURRENT_POLICY"), NULL, NULL, genlist, NULL);
+ elm_object_item_domain_text_translatable_set(nf_it, PACKAGE, EINA_TRUE);
+
+ elm_naviframe_prev_btn_auto_pushed_set(ad->navi_bar, EINA_FALSE);
+ elm_naviframe_item_pop_cb_set(nf_it, NULL, NULL);
+
+ ea_object_event_callback_add(ad->navi_bar, EA_CALLBACK_BACK, ea_naviframe_back_cb, NULL);
+ ea_object_event_callback_add(ad->navi_bar, EA_CALLBACK_MORE, ea_naviframe_more_cb, NULL);
+}
--- /dev/null
+/**
+ * Copyright (c) 2014 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 im-load-policy.c
+ * @author Janusz Kozerski (j.kozerski@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+#include "im-common.h"
+#include "im-uigadget.h"
+#include "im-load-policy.h"
+
+#define LOAD_POLICY_DEFAULT_PATH "/"
+#define MESSAGE_BEGIN "IDS_ST_POLICY_LOAD_MSG_BEGIN"
+#define MESSAGE_END "IDS_ST_POLICY_LOAD_MSG_END"
+#define FILE_SELECTOR_TITLE "IDS_ST_POLICY_LOAD_TITLE"
+
+void im_load_policy_cb (void *data, Evas_Object *obj, void *event_info)
+{
+ LOGD("Enter function: %s", __func__);
+ // Unused param warning
+ (void)obj;
+ (void)event_info;
+
+ struct ug_data *ad = (struct ug_data*) data;
+ ad->file_action = im_load_policy_wrapper;
+ ad->fileselector_default_path = LOAD_POLICY_DEFAULT_PATH;
+
+ show_file_selector(ad, dgettext(PACKAGE, FILE_SELECTOR_TITLE));
+}
+
+int im_load_policy_wrapper (struct ug_data *ad, const char* const file_path)
+{
+ LOGD("Enter function: %s", __func__);
+ // TODO: This function should internally call
+ // policy loader from ima-evm-utils library
+
+ size_t size = strlen(dgettext(PACKAGE, MESSAGE_BEGIN)) +
+ strlen(dgettext(PACKAGE, MESSAGE_END)) +
+ strlen(file_path) + 1; // Use asprintf?
+ ad->popup_content = malloc(sizeof(char) * size); // One more char to add NULL at the end
+ snprintf(ad->popup_content, size, "%s%s%s", dgettext(PACKAGE, MESSAGE_BEGIN),
+ file_path, dgettext(PACKAGE, MESSAGE_END));
+ ad->popup_content[size-1] = '\0';
+
+ create_ok_popup(ad);
+ return 0;
+}
--- /dev/null
+/**
+ * Copyright (c) 2014 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 im-main-menu.c
+ * @author Janusz Kozerski (j.kozerski@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+#include <imaevm.h>
+
+#include "im-common.h"
+#include "im-uigadget.h"
+#include "im-check-file.h"
+#include "im-compromised-list.h"
+#include "im-load-policy.h"
+#include "im-get-policy.h"
+
+static int ima_state; // 0 for disabled, 1 for enabled
+static int ima_fix_state; // 0 for fix off (ima enabled), 1 for fix on
+
+/************************ Genlist Item Class ************************/
+#define ITC_TYPE_CHECK (int)0
+#define ITC_TYPE_LIST 1
+#define ITC_TYPE_MAX 2
+
+static Elm_Genlist_Item_Class *_itc[ITC_TYPE_MAX] = {NULL, NULL};
+
+typedef struct ItemData_s {
+ const char *label;
+ const char *style;
+ Evas_Object *object;
+ Eina_Bool check_status;
+} ItemData_t;
+
+static void* _create_item_data(const char* const label, const char* const style)
+{
+ LOGD("Enter function: %s", __func__);
+ ItemData_t *itemD = malloc(sizeof(ItemData_t));
+ if (!itemD)
+ return NULL;
+
+ itemD->label = label;
+ itemD->style = style;
+ itemD->object = NULL;
+ itemD->check_status = EINA_FALSE;
+ return (void *) itemD;
+}
+
+static void _gl_del(void *data, Evas_Object *obj)
+{
+ // Cleaning ItemData_t structure
+ (void)obj;
+ if (data)
+ free(data);
+}
+
+static char * _item_label_get(void *data, Evas_Object *obj, const char *part)
+{
+ (void)obj;
+ (void)part;
+ return strdup(((ItemData_t *)data)->label);
+}
+
+/*static*/ void _check_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ (void)obj;
+ (void)event_info;
+ ((ItemData_t *)data)->check_status = !(((ItemData_t *)data)->check_status);
+}
+
+static Evas_Object *_item_check_content_get(void *data, Evas_Object *obj, const char *part)
+{
+ Evas_Object *ic = elm_check_add(obj);
+
+ if (!strcmp(part, "elm.icon") || !strcmp(part, "elm.icon.2")) {
+ elm_object_style_set(ic, (void *)(((ItemData_t *)data)->style));
+ ((ItemData_t *)data)->object = ic;
+ elm_check_state_pointer_set(ic, &(((ItemData_t *)data)->check_status));
+ evas_object_smart_callback_add(ic, "changed", _check_cb, data);
+ }
+
+ evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
+ return ic;
+}
+
+static Evas_Object *_item_list_content_get(void *data, Evas_Object *obj, const char *part)
+{
+ (void)data;
+ (void)obj;
+ (void)part;
+ return NULL;
+}
+
+static Eina_Bool _gl_state_get(void *data, Evas_Object *obj, const char *part)
+{
+ (void)data;
+ (void)obj;
+ (void)part;
+ return EINA_FALSE;
+}
+
+// Will disable all(*) items on genlist if IMA is disabled
+// (*) Probably the FIX check box should also not be disabled
+static void _ima_disable_all_items (Elm_Object_Item *itm)
+{
+ LOGD("Enter function: %s", __func__);
+ if (!itm)
+ return;
+ // Bypassing FIX check box - FIX checkbox should be active all the time
+ itm = elm_genlist_item_next_get(itm);
+ if (!itm)
+ return;
+
+ while ((itm = elm_genlist_item_next_get(itm))) {
+ elm_object_item_disabled_set(itm, EINA_TRUE);
+ elm_genlist_item_update(itm);
+ }
+}
+
+static void _ima_enable_all_items (Elm_Object_Item *itm)
+{
+ LOGD("Enter function: %s", __func__);
+ if (!itm)
+ return;
+ // Bypassing FIX check box - FIX checkbox should be active all the time
+ itm = elm_genlist_item_next_get(itm);
+ if (!itm)
+ return;
+
+ while ((itm = elm_genlist_item_next_get(itm))) {
+ elm_object_item_disabled_set(itm, EINA_FALSE);
+ elm_genlist_item_update(itm);
+ }
+}
+
+static void genlist_ima_enable_disable_clicked_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ LOGD("Enter function: %s", __func__);
+ (void)event_info;
+ int ret;
+
+ Elm_Object_Item *it = (Elm_Object_Item *) elm_genlist_selected_item_get(obj);
+ if (it == NULL)
+ return;
+
+ if (ima_state == 0) { // Turning on the IMA
+ if (ima_fix_state == 1) {
+ ret = ima_set_state(IMA_STATE_FIX);
+ printf("result of ima_set_ima_state(IMA_STATE_FIX): %d\n", ret);
+ // FIXME: this code is commented for testing purpose
+ // if (ret) // Error
+ // goto out;
+ }
+ else {
+ ret = ima_set_state(IMA_STATE_ENABLED);
+ printf("result of ima_set_ima_state(IMA_STATE_ENABLED): %d\n", ret);
+ // FIXME: this code is commented for testing purpose
+ // if (ret) // Error
+ // goto out;
+ }
+ ima_state = 1;
+ ((ItemData_t *)data)->check_status = EINA_TRUE;
+ _ima_enable_all_items(it);
+ }
+ else { // Turning off the IMA
+ ret = ima_set_state(IMA_STATE_DISABLED);
+ printf("result of ima_set_ima_state(IMA_STATE_DISABLED): %d\n", ret);
+ // FIXME: this code is commented for testing purpose
+ // if (ret) // Error
+ // goto out;
+ ima_state = 0;
+ ((ItemData_t *)data)->check_status = EINA_FALSE;
+ _ima_disable_all_items(it);
+ }
+// out:
+ elm_genlist_item_update(it);
+ elm_genlist_item_selected_set(it, EINA_FALSE);
+}
+
+static void genlist_ima_fix_mode_enable_disable_clicked_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ LOGD("Enter function: %s", __func__);
+ (void)event_info;
+ int ret;
+
+ Elm_Object_Item *it = (Elm_Object_Item *) elm_genlist_selected_item_get(obj);
+ if (it == NULL)
+ return;
+
+ if (ima_fix_state == 0) { // Turning on IMA fix state
+ if (ima_state == 1) { // If IMA is enabled then turn on FIX mode
+ ret = ima_set_state(IMA_STATE_FIX);
+ printf("result of ima_set_ima_state(FIX): %d\n", ret);
+ // FIXME: this code is commented for testing purpose
+ // if (ret) // Error
+ // goto out;
+ }
+ // If IMA is disabled then just change the state in UI
+ ima_fix_state = 1;
+ ((ItemData_t *)data)->check_status = EINA_TRUE;
+ }
+ else { // Turning off IMA fix state
+ if (ima_state == 1) {
+ ret = ima_set_state(IMA_STATE_ENABLED);
+ printf("result of ima_set_ima_state(IMA_STATE_ENABLED): %d\n", ret);
+ // FIXME: this code is commented for testing purpose
+ // if (ret) // Error
+ // goto out;
+ }
+ // If IMA is disabled then just change the state in UI
+ ima_fix_state = 0;
+ ((ItemData_t *)data)->check_status = EINA_FALSE;
+ }
+//out:
+ elm_genlist_item_selected_set(it, EINA_FALSE);
+ elm_genlist_item_update(it);
+}
+
+static void _create_itc(int itc_type)
+{
+ if (itc_type >= ITC_TYPE_MAX || itc_type < 0)
+ return; // Incorrect itc_type
+
+ if(_itc[itc_type])
+ return; // This type was already created
+
+ _itc[itc_type] = elm_genlist_item_class_new();
+ switch (itc_type) {
+ case ITC_TYPE_CHECK:
+ _itc[itc_type]->item_style = "1text.1icon.6";
+ _itc[itc_type]->func.content_get = _item_check_content_get;
+ break;
+ case ITC_TYPE_LIST:
+ _itc[itc_type]->item_style = "1text";
+ _itc[itc_type]->func.content_get = _item_list_content_get;
+ break;
+ default:
+ break;
+ }
+ _itc[itc_type]->func.text_get = _item_label_get;
+ _itc[itc_type]->func.state_get = _gl_state_get;
+ _itc[itc_type]->func.del = _gl_del;
+}
+
+static void _free_itc()
+{
+ int i = 0;
+ for(; i<ITC_TYPE_MAX; ++i) {
+ elm_genlist_item_class_free(_itc[i]);
+ _itc[i] = NULL;
+ }
+}
+
+static void _setup(Elm_Object_Item *ima_enable_item, Elm_Object_Item *ima_fix_item)
+{
+ LOGD("Enter function: %s", __func__);
+
+ // FIXME: When libIMA implementation will be ready ima_get_ima_state() should returns SUCCESS or ERROR_CODE,
+ // and is should pass the IMA state via parameter.
+ int state = 0;
+ //TODO: check error code!
+ ima_get_state(&state);
+ LOGD("IMA state returns: %d", state);
+ if(IMA_STATE_DISABLED == state) {
+ ima_state = 0;
+ ima_fix_state = 0;
+ ((ItemData_t *)elm_object_item_data_get(ima_enable_item))->check_status = EINA_FALSE;
+ ((ItemData_t *)elm_object_item_data_get(ima_fix_item))->check_status = EINA_FALSE;
+ _ima_disable_all_items(ima_enable_item);
+ }
+ else if (IMA_STATE_ENABLED == state) {
+ ima_state = 1;
+ ima_fix_state = 0;
+ ((ItemData_t *)elm_object_item_data_get(ima_enable_item))->check_status = EINA_TRUE;
+ ((ItemData_t *)elm_object_item_data_get(ima_fix_item))->check_status = EINA_FALSE;
+ _ima_enable_all_items(ima_enable_item);
+ }
+ else if(IMA_STATE_FIX == state) {
+ ima_state = 1;
+ ima_fix_state = 1;
+ ((ItemData_t *)elm_object_item_data_get(ima_enable_item))->check_status = EINA_TRUE;
+ ((ItemData_t *)elm_object_item_data_get(ima_fix_item))->check_status = EINA_TRUE;
+ _ima_enable_all_items(ima_enable_item);
+ }
+ else { // Error while getting IMA state
+ LOGE("Unknown state of IMA: %d. Is IMA pressent in system?", state);
+ // How the switches should be set if there's no IMA? Now they are disabled
+ ima_state = 0;
+ ima_fix_state = 0;
+ ((ItemData_t *)elm_object_item_data_get(ima_enable_item))->check_status = EINA_FALSE;
+ ((ItemData_t *)elm_object_item_data_get(ima_fix_item))->check_status = EINA_FALSE;
+ _ima_disable_all_items(ima_enable_item);
+ }
+}
+
+// elm_genlist_item_append wrapper
+static Elm_Object_Item * _add_genlist_item(
+ Evas_Object *genlist,
+ int itc_class,
+ const char* const label,
+ const char* const style,
+ Evas_Smart_Cb callback_func,
+ void *ad
+ )
+{
+ LOGD("Enter function: %s", __func__);
+ void * data = _create_item_data(label, style);
+ if (!data)
+ return NULL; // Error while allocating memory
+ if(!ad) { // App data is NULL - use currently created data
+ ad = data;
+ }
+ return elm_genlist_item_append(
+ genlist, // Genlist object
+ _itc[itc_class], // Item class
+ data, // Item data
+ NULL, // Parrent
+ ELM_GENLIST_ITEM_FIELD_CONTENT, // Item type
+ callback_func, // select callback
+ ad); // callback data
+}
+/********************************************************************/
+
+void im_main_menu_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ LOGD("Enter function: %s", __func__);
+ (void)obj;
+ (void)event_info;
+
+ struct ug_data *ad = (struct ug_data*) data;
+ int i;
+ Evas_Object *genlist = NULL;
+ Elm_Object_Item *nf_it = NULL;
+
+ for (i=0; i<ITC_TYPE_MAX; ++i) {
+ _create_itc(i); // Creating all item classes
+ }
+
+ genlist = elm_genlist_add(ad->navi_bar);
+ elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
+
+ evas_object_smart_callback_add(genlist, "selected", genlist_clicked_cb, NULL);
+
+ Elm_Object_Item *ima_enable_item = _add_genlist_item(genlist, ITC_TYPE_CHECK,
+ dgettext(PACKAGE, "IDS_ST_IMA_ENABLE_DISABLE_SWITCH"), "on&off", genlist_ima_enable_disable_clicked_cb, NULL);
+ elm_object_item_domain_text_translatable_set(ima_enable_item, PACKAGE, EINA_TRUE);
+
+ Elm_Object_Item *ima_fix_item = _add_genlist_item(genlist, ITC_TYPE_CHECK, dgettext(PACKAGE, "IDS_ST_IMA_FIX_MODE_CHECKBOX"),
+ "check", genlist_ima_fix_mode_enable_disable_clicked_cb, NULL);
+ elm_object_item_domain_text_translatable_set(ima_fix_item, PACKAGE, EINA_TRUE);
+
+ nf_it = _add_genlist_item(genlist, ITC_TYPE_LIST, dgettext(PACKAGE, "IDS_ST_COMPROMISED_FILES_LIST"),
+ NULL, im_compromised_list_cb, ad);
+ elm_object_item_domain_text_translatable_set(nf_it, PACKAGE, EINA_TRUE);
+
+ nf_it = _add_genlist_item(genlist, ITC_TYPE_LIST, dgettext(PACKAGE, "IDS_ST_LOAD_NEW_POLICY"),
+ NULL, im_load_policy_cb, ad);
+ elm_object_item_domain_text_translatable_set(nf_it, PACKAGE, EINA_TRUE);
+
+ nf_it = _add_genlist_item(genlist, ITC_TYPE_LIST, dgettext(PACKAGE, "IDS_ST_GET_POLICY"),
+ NULL, im_get_policy_cb, ad);
+ elm_object_item_domain_text_translatable_set(nf_it, PACKAGE, EINA_TRUE);
+
+ nf_it = _add_genlist_item(genlist, ITC_TYPE_LIST, dgettext(PACKAGE, "IDS_ST_CHECK_FILE_STATE"),
+ NULL, im_check_file_cb, ad);
+ elm_object_item_domain_text_translatable_set(nf_it, PACKAGE, EINA_TRUE);
+
+ nf_it = elm_naviframe_item_push(ad->navi_bar, dgettext(PACKAGE, "IDS_ST_IMA_EVM_SETUP_MAIN"),
+ NULL, NULL, genlist, NULL);
+ elm_object_item_domain_text_translatable_set(nf_it, PACKAGE, EINA_TRUE);
+
+ _free_itc();
+
+ _setup(ima_enable_item, ima_fix_item);
+
+ elm_naviframe_item_pop_cb_set(nf_it, quit_cb, data);
+
+ elm_naviframe_prev_btn_auto_pushed_set(ad->navi_bar, EINA_FALSE);
+ ea_object_event_callback_add(ad->navi_bar, EA_CALLBACK_BACK, ea_naviframe_back_cb, NULL);
+ ea_object_event_callback_add(ad->navi_bar, EA_CALLBACK_MORE, ea_naviframe_more_cb, NULL);
+}
--- /dev/null
+/**
+ * Copyright (c) 2014 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 im-uigadget.c
+ * @author Janusz Kozerski (j.kozerski@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+#ifndef UG_MODULE_API
+#define UG_MODULE_API __attribute__ ((visibility("default")))
+#endif
+
+#include "im-uigadget.h"
+#include "im-main-menu.h"
+
+static void *on_create(ui_gadget_h ug, enum ug_mode mode, service_h service, void *priv)
+{
+ (void) mode;
+ (void) service;
+
+ int theme = 0;
+ if (NULL == ug)
+ return NULL ;
+ if (NULL == priv)
+ return NULL ;
+
+ bindtextdomain(PACKAGE, LOCALEDIR);
+
+ struct ug_data *ugd = priv;
+ ugd->ug = ug;
+
+ ugd->win_main = ug_get_parent_layout(ug);
+ if (NULL == ugd->win_main) {
+ return NULL ;
+ }
+
+ if (strncmp(elm_theme_get(NULL ), "tizen-HD-dark", strlen("tizen-HD-dark")) == 0) {
+ theme = 0;
+ } else if (strncmp(elm_theme_get(NULL ), "tizen-HD-light", strlen("tizen-HD-light")) == 0) {
+ theme = 1;
+ }
+
+ ugd->bg = elm_bg_add(ugd->win_main);
+ if (!ugd->bg) {
+ LOGD("ugd->bg is null");
+ free(ugd->win_main);
+ return NULL ;
+ }
+ evas_object_size_hint_weight_set(ugd->bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_show(ugd->bg);
+
+ ugd->layout_main = elm_layout_add(ugd->win_main);
+ if (!ugd->layout_main) {
+ LOGD("ugd->layout_main is null");
+ free(ugd->win_main);
+ free(ugd->bg);
+ return NULL;
+ }
+
+ ugd->theme = elm_theme_new();
+
+ if (theme == 1) {
+ elm_theme_set(ugd->theme, "tizen-HD-light");
+ } else {
+ elm_theme_set(ugd->theme, "tizen-HD-dark");
+ }
+ elm_object_theme_set(ugd->layout_main, ugd->theme);
+ elm_layout_theme_set(ugd->layout_main, "layout", "application", "default");
+ evas_object_size_hint_weight_set(ugd->layout_main, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_show(ugd->layout_main);
+
+ elm_object_part_content_set(ugd->layout_main, "elm.swallow.bg", ugd->bg);
+
+ ugd->navi_bar = elm_naviframe_add(ugd->layout_main);
+ if (!ugd->navi_bar) {
+ LOGD("ugd->navi_bar is null");
+ free(ugd->win_main);
+ free(ugd->bg);
+ free(ugd->layout_main);
+ return NULL;
+ }
+ elm_object_part_content_set(ugd->layout_main, "elm.swallow.content", ugd->navi_bar);
+ evas_object_show(ugd->navi_bar);
+
+ im_main_menu_cb((void*) ugd, NULL, NULL);
+
+ return ugd->layout_main;
+}
+
+static void on_start(ui_gadget_h ug, service_h service, void *priv)
+{
+ (void)ug;
+ (void)service;
+ (void)priv;
+}
+
+static void on_pause(ui_gadget_h ug, service_h service, void *priv)
+{
+ (void)ug;
+ (void)service;
+ (void)priv;
+}
+
+static void on_resume(ui_gadget_h ug, service_h service, void *priv)
+{
+ (void)ug;
+ (void)service;
+ (void)priv;
+}
+
+static void on_destroy(ui_gadget_h ug, service_h service, void *priv)
+{
+ (void)service;
+
+ if (NULL == ug) {
+ LOGD("NULL == ug; return");
+ return;
+ }
+ if (NULL == priv) {
+ LOGD("NULL == priv; return");
+ return;
+ }
+
+ struct ug_data *ugd = priv;
+
+ if (ugd->theme) {
+ elm_theme_free(ugd->theme);
+ ugd->theme = NULL;
+ }
+
+ evas_object_del(ugd->layout_main);
+ ugd->layout_main = NULL;
+}
+
+static void on_message(ui_gadget_h ug, service_h msg, service_h service, void *priv)
+{
+ (void)ug;
+ (void)msg;
+ (void)service;
+ (void)priv;
+}
+
+static void on_event(ui_gadget_h ug, enum ug_event event, service_h service, void *priv)
+{
+ (void)ug;
+ (void)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, service_h service, void *priv)
+{
+ (void)service;
+ (void)priv;
+
+ if (NULL == ug) {
+ //LOGD("NULL == ug; return");
+ return;
+ }
+
+ 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)
+{
+ if (NULL == ops) {
+ LOGD("NULL == ops; return");
+ return -1;
+ }
+
+ struct ug_data *ugd = calloc(1, sizeof(struct ug_data));
+
+ 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;
+
+ return 0;
+}
+
+UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
+{
+ if (NULL == ops) {
+ LOGD("NULL == ops; return");
+ return;
+ }
+
+ struct ug_data *ugd = ops->priv;
+ free(ugd);
+}
+
+UG_MODULE_API int setting_plugin_reset(service_h service, void *priv)
+{
+ (void)service;
+ (void)priv;
+ /* nothing to do for Setting>Reset */
+ return 0;
+}