Sync to latest code 46/40246/1 accepted/tizen/tv/20150605.024059 submit/tizen/20150604.030419 submit/tizen_tv/20150603.015311
authorYunjin Lee <yunjin-.lee@samsung.com>
Mon, 1 Jun 2015 12:19:44 +0000 (21:19 +0900)
committerYunjin Lee <yunjin-.lee@samsung.com>
Mon, 1 Jun 2015 12:19:44 +0000 (21:19 +0900)
Change-Id: Ib399ed69d21f43c2d646053a80118b4395517aea
Signed-off-by: Yunjin Lee <yunjin-.lee@samsung.com>
CMakeLists.txt [new file with mode: 0755]
LICENSE.Apache-2.0 [new file with mode: 0755]
doc/privilege-info_doc.h [new file with mode: 0755]
packaging/privilege-info.manifest [new file with mode: 0755]
packaging/privilege-info.spec [new file with mode: 0755]
privilege-info.pc.in [new file with mode: 0755]
src/CMakeLists.txt [new file with mode: 0755]
src/include/privilege_information.h [new file with mode: 0755]
src/privilege_info.c [new file with mode: 0755]
test/CMakeLists.txt [new file with mode: 0755]
test/tc_privilege_info.c [new file with mode: 0755]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..8f99ca8
--- /dev/null
@@ -0,0 +1,20 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+SET(CMAKE_VERBOSE_MAKEFILE OFF)
+
+IF("${USE_AUTOSTART}" STREQUAL "1")
+    ADD_DEFINITIONS("-DUSE_AUTOSTART")
+ENDIF()
+
+ADD_DEFINITIONS("-DCLIENT_IPC_THREAD")
+ADD_DEFINITIONS("-DUSE_IPC_EPOLL")
+
+STRING(REGEX MATCH "([^.]*)" API_VERSION "${VERSION}")
+ADD_DEFINITIONS("-DAPI_VERSION=\"$(API_VERSION)\"")
+
+CONFIGURE_FILE(privilege-info.pc.in privilege-info.pc @ONLY)
+
+MESSAGE("build privilege-info")
+ADD_SUBDIRECTORY(src)
+MESSAGE("build tc-privilege-info")
+ADD_SUBDIRECTORY(test)
diff --git a/LICENSE.Apache-2.0 b/LICENSE.Apache-2.0
new file mode 100755 (executable)
index 0000000..a795f06
--- /dev/null
@@ -0,0 +1,204 @@
+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 (c) 2011 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.
+
diff --git a/doc/privilege-info_doc.h b/doc/privilege-info_doc.h
new file mode 100755 (executable)
index 0000000..190c9a1
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+#ifndef PRIVILEGE_INFO_DOC_H_
+#define PRIVILEGE_INFO_DOC_H_
+
+/**
+ * @ingroup CAPI_SECURITY_FRAMEWORK
+ * @defgroup CAPI_SECURITY_FRAMEWORK_PRIVILEGE_INFO_MODULE Privilege Info
+ * 
+ *
+ * @section CAPI_SECURITY_FRAMEWORK_PRIVILEGE_INFO_MODULE_HEADER Requires Header
+ *      \#include <privilege_information.h>
+ *
+ * @section CAPI_SECURITY_FRAMEWORK_PRIVILEGE_INFO_MODULE_OVERVIEW Overview
+ * A library for reading privilege information of the given privilege and API issue version. 
+ * It provides the display name or description of privileges. 
+ * If there's no matching privilege then it shows last token of given privilege or description string for undefined privileges.
+ */
+
+#endif /* PRIVILEEGE_INFO_DOC_H_ */
diff --git a/packaging/privilege-info.manifest b/packaging/privilege-info.manifest
new file mode 100755 (executable)
index 0000000..9031485
--- /dev/null
@@ -0,0 +1,8 @@
+<manifest>
+       <define>
+               <domain name="privilege-info" />
+       </defind>
+       <request>
+               <domain name="_" />
+       </request>
+</manifest>
diff --git a/packaging/privilege-info.spec b/packaging/privilege-info.spec
new file mode 100755 (executable)
index 0000000..01284ce
--- /dev/null
@@ -0,0 +1,91 @@
+Name:    privilege-info
+Summary: Privilege Management
+Version: 0.0.1
+Release: 1
+Group:   System/Libraries
+License: Apache-2.0
+Source0: %{name}-%{version}.tar.gz
+
+Requires(post):   /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+BuildRequires: cmake
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(capi-base-common)
+BuildRequires: pkgconfig(capi-security-privilege-manager)
+
+%description
+Privilege Information
+
+%package -n privilege-info-devel
+Summary: Privilege Info API (Development)
+Group: TO_BE/FILLED_IN
+Requires: %{name} = %{version}-%{release}
+
+%description -n privilege-info-devel
+The Privilege Info API provides functions to get privilege information (DEV)
+
+%package -n tc-privilege-info
+Summary: tc-privilege-info
+Group: TO_BE/FILLED_IN
+Requires: %{name} = %{version}-%{release}
+
+%description -n tc-privilege-info
+tc-privilege-info
+
+%prep
+%setup -q
+
+%build
+
+%if "%{?tizen_profile_name}" == "wearable"
+    __PROFILE_TYPE="WEARABLE"
+%else
+    __PROFILE_TYPE="MOBILE"
+%endif
+
+export CFLAGS="$CFLAGS -DTIZEN_ENGINEER_MODE"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_ENGINEER_MODE"
+export FFLAGS="$FFLAGS -DTIZEN_ENGINEER_MODE"
+
+echo cmake . -DPREFIX=%{_prefix} \
+        -DEXEC_PREFIX=%{_exec_prefix} \
+        -DLIBDIR=%{_libdir} \
+        -DINCLUDEDIR=%{_includedir} \
+        -DCMAKE_BUILD_TYPE=%{build_type} \
+        -DVERSION=%{version} \
+        -DDPL_LOG="ON" \
+        -DPROFILE_TYPE="${__PROFILE_TYPE}"
+
+cmake . -DPREFIX=%{_prefix} \
+        -DEXEC_PREFIX=%{_exec_prefix} \
+        -DLIBDIR=%{_libdir} \
+        -DINCLUDEDIR=%{_includedir} \
+        -DCMAKE_BUILD_TYPE=%{build_type} \
+        -DVERSION=%{version} \
+        -DDPL_LOG="ON" \
+        -DPROFILE_TYPE="${__PROFILE_TYPE}"
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}/usr/share/license
+cp LICENSE.Apache-2.0 %{buildroot}/usr/share/license/privilege-info
+
+%make_install
+
+%files -n privilege-info
+%{_libdir}/libprivilege-info.so.*
+/usr/share/license/privilege-info
+
+%files -n privilege-info-devel
+%{_libdir}/libprivilege-info.so
+%{_includedir}/*.h
+%{_libdir}/pkgconfig/privilege-info.pc
+
+%files -n tc-privilege-info
+%{_bindir}/tc-privilege-info
+
+%clean
+rm -rf %{buildroot}
+
diff --git a/privilege-info.pc.in b/privilege-info.pc.in
new file mode 100755 (executable)
index 0000000..a771af9
--- /dev/null
@@ -0,0 +1,14 @@
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=/usr
+libdir=/usr/lib
+includedir=/usr/include
+
+Name: @PC_NAME@
+Description: @PACKAGE_DESCRIPTION@
+Version: @VERSION@
+Requires: @PC_REQUIRED@ 
+Libs: -L${libdir} @PC_LDFLAGS@
+Cflags: -I${includedir} @PC_CFLAGS@
+
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..b5b05ab
--- /dev/null
@@ -0,0 +1,43 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+SET(PACKAGE_NAME privilege-info)
+PROJECT(${PACKAGE_NAME})
+
+SET(PRIV_INFO_SOURCES
+    ${PROJECT_SOURCE_DIR}/privilege_info.c
+)
+
+INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include)
+
+SET(requires glib-2.0 dlog capi-security-privilege-manager)
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${PACKAGE_NAME} REQUIRED ${requires})
+FOREACH(flag ${${PACKAGE_NAME}_CFLAGS})
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+# Compiler flags
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC -Wall -fvisibility=hidden -D_WITH_SYSTEMD_")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${PACKAGE_NAME_CFLAGS}")
+
+########################################################
+# For libprivilege-info libraries(.so)
+########################################################
+
+SET(TARGET_PRIV_INFO_LIB "privilege-info")
+SET(SO_VERSION 1)
+SET(VERSION "${SO_VERSION}.0.0")
+
+ADD_LIBRARY(${TARGET_PRIV_INFO_LIB} SHARED ${PRIV_INFO_SOURCES})
+
+SET_TARGET_PROPERTIES(${TARGET_PRIV_INFO_LIB} PROPERTIES
+    SOVERSION ${SO_VERSION}
+    VERSION ${VERSION}
+)
+
+TARGET_LINK_LIBRARIES(${TARGET_PRIV_INFO_LIB} ${${PACKAGE_NAME}_LDFLAGS})
+
+#######################################################
+
+INSTALL(TARGETS ${PACKAGE_NAME} DESTINATION /usr/lib)
+INSTALL(FILES ${PROJECT_SOURCE_DIR}/include/privilege_information.h DESTINATION /usr/include)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/privilege-info.pc DESTINATION /usr/lib/pkgconfig)
diff --git a/src/include/privilege_information.h b/src/include/privilege_information.h
new file mode 100755 (executable)
index 0000000..923be74
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2013 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.
+ */
+
+#ifndef __TIZEN_SECURITY_PRIVILEGE_INFO_H
+#define __TIZEN_SECURITY_PRIVILEGE_INFO_H
+
+#include <tizen.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup CAPI_SECURITY_FRAMEWORK_PRIVILEGE_INFO_MODULE
+ * @{
+ */
+
+/**
+ * @brief Enumerations of error code for Privilege Information.
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+    PRVINFO_ERROR_NONE                         = TIZEN_ERROR_NONE, /**< Successful */
+    PRVINFO_ERROR_INVALID_PARAMETER            = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid function parameter */
+    PRVINFO_ERROR_OUT_OF_MEMORY                = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+    PRVINFO_ERROR_INTERNAL_ERROR               = TIZEN_ERROR_UNKNOWN, /**< Unknown error */
+} privilege_info_error_e;
+
+
+/**
+ * @brief Gets the display name of the given privilege.
+ * @since_tizen 2.3
+ * @remarks @a display_name must be released with free() by you.
+ * @param [in] api_version The version of API
+ * @param [in] privilege The privilege
+ * @param [out] display_name The display name of the privilege
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #PRVINFO_ERROR_NONE Successful
+ * @retval #PRVINFO_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter
+ * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error
+ */
+int privilege_info_get_display_name(const char* api_version, const char* privilege, char **display_name);
+
+/**
+ * @brief Gets the display name of the given privilege.
+ * @since_tizen 2.3
+ * @remarks @a display_name must be released with free() by you.
+ * @remarks package_type must be one of followings: PRVINFO_PACKAGE_TYPE_NATIVE, PRVINFO_PACKAGE_TYPE_WEB
+ * @param [in] package_type The type of application package
+ * @param [in] api_version The version of API
+ * @param [in] privilege The privilege
+ * @param [out] display_name The display name of the privilege
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #PRVINFO_ERROR_NONE Successful
+ * @retval #PRVINFO_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter
+ * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error
+ */
+int privilege_info_get_display_name_by_pkgtype(const char* package_type, const char* api_version, const char* privilege, char **display_name);
+
+/**
+ * @brief Gets the description of the given privilege.
+ * @since_tizen 2.3
+ * @remarks @a description must be released with free() by you.
+ * @param [in] api_version The version of API
+ * @param [in]  privilege The privilege
+ * @param [out] description The description of the privilege
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #PRVINFO_ERROR_NONE Successful
+ * @retval #PRVINFO_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter
+ * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error
+ */
+int privilege_info_get_description(const char* api_version, const char *privilege, char **description);
+
+/**
+ * @brief Gets the description of the given privilege.
+ * @since_tizen 2.3
+ * @remarks @a description must be released with free() by you.
+ * @remarks package_type must be one of followings: PRVINFO_PACKAGE_TYPE_NATIVE, PRVINFO_PACKAGE_TYPE_WEB 
+ * @param [in] package_type The type of application package
+ * @param [in] api_version The version of API
+ * @param [in]  privilege The privilege
+ * @param [out] description The description of the privilege
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #PRVINFO_ERROR_NONE Successful                                                                                                                                            
+ * @retval #PRVINFO_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter
+ * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error
+ */
+int privilege_info_get_description_by_pkgtype(const char* package_type, const char* api_version, const char *privilege, char **description);
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __TIZEN_SECURITY_PRIVILEGE_INFO_H
diff --git a/src/privilege_info.c b/src/privilege_info.c
new file mode 100755 (executable)
index 0000000..5336bd7
--- /dev/null
@@ -0,0 +1,562 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <libintl.h>
+#include <dlog.h>
+#include <privilege_db_manager.h>
+#include "privilege_information.h"
+#ifdef LOG_TAG
+#undef LOG_TAG
+#define LOG_TAG "PRIVILEGE_INFO"
+#endif
+
+#define TryReturn(condition, returnValue, ...)  \
+    if (!(condition)) { \
+        LOGE(__VA_ARGS__); \
+        return returnValue; \
+    } \
+    else {;}
+
+#ifndef PI_API
+#define PI_API __attribute__((visibility("default")))
+#endif
+
+typedef enum
+{
+    PRVINFO_ERROR_NO_MATCHING_PRIVILEGE        = TIZEN_ERROR_PRIVILEGE_INFORMATION | 0x01
+}privilege_info_internal_error_e;
+
+int privilege_info_get_display_name_string_id(const char* api_version, const char *privilege, char **display_name_string_id)
+{
+    TryReturn(api_version != NULL, PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL");
+    TryReturn(privilege != NULL, PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL");
+
+    char* temp = NULL;
+
+    // Check NATIVE
+    int ret = privilege_db_manager_get_privilege_display(PRIVILEGE_DB_MANAGER_PACKAGE_TYPE_CORE, privilege, api_version, &temp);
+
+    if(ret == PRIVILEGE_DB_MANAGER_ERR_NONE)
+    {
+        if(temp == NULL)
+        {
+            *display_name_string_id = NULL;
+        }
+        else if(strcmp(temp,"") == 0)
+        {
+            *display_name_string_id = NULL;
+        }
+        else
+        {
+            goto err_none;
+        }
+    }
+    else if(ret != PRIVILEGE_DB_NO_EXIST_RESULT)
+    {
+        goto err_internal_error;
+    }
+
+    if(temp != NULL)
+    {
+        free(temp);
+        temp = NULL;
+    }
+
+    // Check WEB
+    ret = privilege_db_manager_get_privilege_display(PRIVILEGE_DB_MANAGER_PACKAGE_TYPE_WRT, privilege, api_version, &temp);
+
+    if(ret == PRIVILEGE_DB_MANAGER_ERR_NONE)
+    {
+        if(temp == NULL)
+        {
+            goto err_no_matching_privilege;
+        }
+        else if(strcmp(temp,"") == 0)
+        {
+            goto err_no_matching_privilege;
+        }
+        else
+        {
+            goto err_none;
+        }
+    }
+    else if(ret == PRIVILEGE_DB_NO_EXIST_RESULT)
+    {
+        goto err_no_matching_privilege;
+    }
+    else
+    {
+        goto err_internal_error;
+    }
+
+err_none:
+    *display_name_string_id = (char*)calloc(strlen(temp) + 1, sizeof(char));
+    TryReturn(*display_name_string_id != NULL, PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation is failed.");
+    memcpy(*display_name_string_id, temp, strlen(temp));
+    LOGD("display_name_string_id = %s", *display_name_string_id);
+    free(temp);
+    return PRVINFO_ERROR_NONE;
+
+err_no_matching_privilege:
+    *display_name_string_id = NULL;
+    free(temp);
+    return PRVINFO_ERROR_NO_MATCHING_PRIVILEGE;
+
+err_internal_error:
+    free(temp);
+    return PRVINFO_ERROR_INTERNAL_ERROR;
+}
+
+
+int privilege_info_get_display_name_by_string_id(const char *string_id, char **display_name)
+{
+    char *temp = NULL;
+    TryReturn(string_id != NULL, PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] string_id is NULL");
+
+    temp = dgettext("privilege", string_id);
+
+    *display_name = (char*)calloc(strlen(temp) + 1, sizeof(char));
+    TryReturn(*display_name != NULL, PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed.");
+
+    memcpy(*display_name, temp, strlen(temp));
+
+    return PRVINFO_ERROR_NONE;
+}
+
+PI_API
+int privilege_info_get_display_name(const char* api_version, const char* privilege, char** display_name)
+{
+    int ret = 0;
+    char* display_name_string_id = NULL;
+
+    TryReturn(api_version != NULL, PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL");
+    TryReturn(privilege != NULL, PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL");
+
+    ret = privilege_info_get_display_name_string_id(api_version, privilege, &display_name_string_id);
+    
+    if(ret == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE)
+    {
+        char tempPrivilege[256] = {0,};
+        char* token = NULL;
+        char* temp = NULL;
+        memcpy(tempPrivilege, privilege, strlen(privilege));
+        
+        token = strtok(tempPrivilege, "/");
+        while(token)
+        {
+            temp = token;
+            token = strtok(NULL, "/");
+        }
+        *display_name = (char*)calloc(strlen(temp) + 1, sizeof(char));
+        TryReturn(*display_name != NULL, PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed.");
+        memcpy(*display_name, temp, strlen(temp));
+    }
+    else if(ret == PRVINFO_ERROR_NONE)
+    {
+        ret = privilege_info_get_display_name_by_string_id(display_name_string_id, display_name);
+        free(display_name_string_id);
+        TryReturn(ret == PRVINFO_ERROR_NONE, PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed.");
+    }
+    else
+    {
+        return PRVINFO_ERROR_INTERNAL_ERROR;
+    }
+    return PRVINFO_ERROR_NONE;
+}
+
+
+int privilege_info_get_description_string_id(const char* api_version, const char *privilege, char **description_string_id)
+{
+    TryReturn(api_version != NULL, PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL");
+    TryReturn(privilege != NULL, PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL");
+
+    char* temp = NULL;
+
+    // Check NATIVE
+    int ret = privilege_db_manager_get_privilege_description(PRIVILEGE_DB_MANAGER_PACKAGE_TYPE_CORE, privilege, api_version, &temp);
+
+    if(ret == PRIVILEGE_DB_MANAGER_ERR_NONE)
+    {
+        if(temp == NULL)
+        {
+            *description_string_id = NULL;
+        }
+        else if(strcmp(temp, "") == 0)
+        {
+            *description_string_id = NULL;
+        }
+        else
+        {
+            goto err_none;
+        }
+    }
+    else if(ret != PRIVILEGE_DB_NO_EXIST_RESULT)
+    {
+        goto err_internal_error;
+    }
+
+    if(temp != NULL)
+    {
+        free(temp);
+        temp = NULL;
+    }
+    // Check WEB
+    ret = privilege_db_manager_get_privilege_description(PRIVILEGE_DB_MANAGER_PACKAGE_TYPE_WRT, privilege, api_version, &temp);
+
+    if(ret == PRIVILEGE_DB_MANAGER_ERR_NONE)
+    {
+        if(temp == NULL)
+        {
+            goto err_no_matching_privilege;
+        }
+        else if(strcmp(temp,"") == 0)
+        {
+            goto err_no_matching_privilege;
+        }
+        else
+        {
+            goto err_none;
+        }
+    }
+    else if(ret == PRIVILEGE_DB_NO_EXIST_RESULT)
+    {
+        goto err_no_matching_privilege;
+    }
+    else
+    {
+        goto err_internal_error;
+    }
+
+err_none:
+    *description_string_id = (char*)calloc(strlen(temp) + 1, sizeof(char));
+    TryReturn(*description_string_id != NULL, PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation is failed.");
+    memcpy(*description_string_id, temp, strlen(temp));
+    LOGD("description_string_id = %s", *description_string_id);
+    free(temp);
+    return PRVINFO_ERROR_NONE;
+
+err_no_matching_privilege:
+    *description_string_id = NULL;
+    free(temp);
+    return PRVINFO_ERROR_NO_MATCHING_PRIVILEGE;
+
+err_internal_error:
+    free(temp);
+    return PRVINFO_ERROR_INTERNAL_ERROR;
+}
+
+int privilege_info_get_description_by_string_id(const char *string_id, char **description)
+{
+    char *temp = NULL;
+    TryReturn(string_id != NULL, PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] string_id is NULL");
+
+    temp = dgettext("privilege", string_id);
+
+    *description = (char*)calloc(strlen(temp) + 1, sizeof(char));
+    TryReturn(*description != NULL, PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed.");
+
+    memcpy(*description, temp, strlen(temp));
+
+    return PRVINFO_ERROR_NONE;
+}
+
+PI_API
+int privilege_info_get_description(const char* api_version, const char* privilege, char** description)
+{
+    int ret = 0;
+    char* description_string_id = NULL;
+
+    TryReturn(api_version != NULL, PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL");
+    TryReturn(privilege != NULL, PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL");
+
+    ret = privilege_info_get_description_string_id(api_version, privilege, &description_string_id);
+
+    if(ret == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE)
+    {
+        char* temp = NULL;
+        temp = dgettext("privilege", "IDS_TPLATFORM_BODY_THIS_PRIVILEGE_IS_NOT_DEFINED");
+        *description = (char*)calloc(strlen(temp) + 1, sizeof(char));
+        TryReturn(*description != NULL, PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed.");
+
+        memcpy(*description, temp, strlen(temp));
+    }
+    else if(ret == PRVINFO_ERROR_NONE)
+    {
+        ret = privilege_info_get_description_by_string_id(description_string_id, description);
+        free(description_string_id);
+        TryReturn(ret == PRVINFO_ERROR_NONE, PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed.");
+    }
+    else
+    {
+        return PRVINFO_ERROR_INTERNAL_ERROR;
+    }
+    return PRVINFO_ERROR_NONE;
+}
+
+int privilege_info_get_display_name_string_id_by_pkgtype(const char* package_type, const char* api_version, const char *privilege, char **display_name_string_id)
+{
+    TryReturn(package_type != NULL, PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] package_type is NULL");
+    TryReturn(api_version != NULL, PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL");
+    TryReturn(privilege != NULL, PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL");
+
+    char* temp = NULL;
+
+    // Check package_type
+    int ret = 0;
+    if(strcmp(package_type,"PRVINFO_PACKAGE_TYPE_NATIVE") == 0)
+    {
+        LOGD("package_type = %s", package_type);
+    }
+    else if(strcmp(package_type,"PRVINFO_PACKAGE_TYPE_WEB") == 0)
+    {
+        LOGD("package_type = %s", package_type);
+        ret = privilege_db_manager_get_privilege_display(PRIVILEGE_DB_MANAGER_PACKAGE_TYPE_WRT, privilege, api_version, &temp);
+        if(ret == PRIVILEGE_DB_MANAGER_ERR_NONE)
+        {
+            if(temp == NULL)
+            {
+                *display_name_string_id = NULL;
+            }
+            else if(strcmp(temp,"") == 0)
+            {
+                *display_name_string_id = NULL;
+            }
+            else
+            {
+                goto err_none;
+            }
+        }
+        else if(ret != PRIVILEGE_DB_NO_EXIST_RESULT)
+        {
+            goto err_internal_error;
+        }
+
+        if(temp != NULL)
+        {
+            free(temp);
+            temp = NULL;
+        }
+    }
+    else
+    {
+        LOGD("package_type = %s", package_type);
+        free(temp);
+        return PRVINFO_ERROR_INVALID_PARAMETER;
+    }
+
+    ret = privilege_db_manager_get_privilege_display(PRIVILEGE_DB_MANAGER_PACKAGE_TYPE_CORE, privilege, api_version, &temp);
+
+    if(ret == PRIVILEGE_DB_MANAGER_ERR_NONE)
+    {
+        if(temp == NULL)
+        {
+            goto err_no_matching_privilege;
+        }
+        else if(strcmp(temp, "") == 0)
+        {
+            goto err_no_matching_privilege;
+        }
+        else
+        {
+            goto err_none;
+        }
+    }
+    else if(ret == PRIVILEGE_DB_NO_EXIST_RESULT)
+    {
+        goto err_no_matching_privilege;
+    }
+    else
+    {
+        goto err_internal_error;
+    }
+
+err_none:
+    *display_name_string_id = (char*)calloc(strlen(temp) + 1, sizeof(char));
+    TryReturn(*display_name_string_id != NULL, PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation is failed.");
+    memcpy(*display_name_string_id, temp, strlen(temp));
+    LOGD("display_name_string_id = %s", *display_name_string_id);
+    free(temp);
+    return PRVINFO_ERROR_NONE;
+
+err_no_matching_privilege:
+    *display_name_string_id = NULL;
+    free(temp);
+    return PRVINFO_ERROR_NO_MATCHING_PRIVILEGE;
+
+err_internal_error:
+    free(temp);
+    return PRVINFO_ERROR_INTERNAL_ERROR;
+}
+
+PI_API
+int privilege_info_get_display_name_by_pkgtype(const const char* package_type, const char* api_version, const char* privilege, char** display_name)
+{
+    int ret = 0;
+    char* display_name_string_id = NULL;
+
+    TryReturn(package_type != NULL, PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] package_type is NULL");
+    TryReturn(api_version != NULL, PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL");
+    TryReturn(privilege != NULL, PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL");
+
+    ret = privilege_info_get_display_name_string_id_by_pkgtype(package_type, api_version, privilege, &display_name_string_id);
+
+    if(ret == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE)
+    {
+        char tempPrivilege[256] = {0,};
+        char* token = NULL;
+        char* temp = NULL;
+        memcpy(tempPrivilege, privilege, strlen(privilege));
+        token = strtok(tempPrivilege, "/");
+        while(token)
+        {
+            temp = token;
+            token = strtok(NULL, "/");
+        }
+        *display_name = (char*)calloc(strlen(temp) + 1, sizeof(char));
+        TryReturn(*display_name != NULL, PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed.");
+        memcpy(*display_name, temp, strlen(temp));
+    }
+    else if(ret == PRVINFO_ERROR_NONE)
+    {
+        ret = privilege_info_get_display_name_by_string_id(display_name_string_id, display_name);
+        free(display_name_string_id);
+        TryReturn(ret == PRVINFO_ERROR_NONE, PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed.");
+    }
+    else
+    {
+        return PRVINFO_ERROR_INTERNAL_ERROR;
+    }
+    return PRVINFO_ERROR_NONE;
+}
+
+
+int privilege_info_get_description_string_id_by_pkgtype(const char* package_type, const char* api_version, const char *privilege, char **description_string_id)
+{
+    TryReturn(package_type != NULL, PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] package_type is NULL");
+    TryReturn(api_version != NULL, PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL");
+    TryReturn(privilege != NULL, PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL");
+
+    char* temp = NULL;
+
+    // Check package_type
+    int ret = 0;
+
+    if(strcmp(package_type,"PRVINFO_PACKAGE_TYPE_WEB") == 0)
+    {
+        LOGD("package_type = %s", package_type);
+        ret = privilege_db_manager_get_privilege_description(PRIVILEGE_DB_MANAGER_PACKAGE_TYPE_WRT, privilege, api_version, &temp);
+        if(ret == PRIVILEGE_DB_MANAGER_ERR_NONE)
+        {
+            if(temp == NULL)
+            {
+                *description_string_id = NULL;
+            }
+            else if(strcmp(temp,"") == 0)
+            {
+                *description_string_id = NULL;
+            }
+            else
+            {
+                goto err_none;
+            }
+        }
+        else if(ret != PRIVILEGE_DB_NO_EXIST_RESULT)
+        {
+            goto err_internal_error;
+        }
+
+        if(temp != NULL)
+        {
+            free(temp);
+            temp = NULL;
+        }
+    }
+    else if(strcmp(package_type,"PRVINFO_PACKAGE_TYPE_NATIVE") == 0)
+    {
+        LOGD("package_type = %s", package_type);
+    }
+    else
+    {
+        LOGD("package_type = %s", package_type);
+        free(temp);
+        return PRVINFO_ERROR_INVALID_PARAMETER;
+    }
+
+    ret = privilege_db_manager_get_privilege_description(PRIVILEGE_DB_MANAGER_PACKAGE_TYPE_CORE, privilege, api_version, &temp);
+
+    if(ret == PRIVILEGE_DB_MANAGER_ERR_NONE)
+    {
+        if(temp == NULL)
+        {
+            goto err_no_matching_privilege;
+        }
+        else if(strcmp(temp,"") == 0)
+        {
+            goto err_no_matching_privilege;
+        }
+        else
+        {
+            goto err_none;
+        }
+    }
+    else if(ret == PRIVILEGE_DB_NO_EXIST_RESULT)
+    {
+        goto err_no_matching_privilege;
+    }
+    else
+    {
+        goto err_internal_error;
+    }
+
+
+err_none:
+    *description_string_id = (char*)calloc(strlen(temp) + 1, sizeof(char));
+    TryReturn(*description_string_id != NULL, PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation is failed.");
+    memcpy(*description_string_id, temp, strlen(temp));
+    LOGD("description_string_id = %s", *description_string_id);
+    free(temp);
+    return PRVINFO_ERROR_NONE;
+
+err_no_matching_privilege:
+    *description_string_id = NULL;
+    free(temp);
+    return PRVINFO_ERROR_NO_MATCHING_PRIVILEGE;
+
+err_internal_error:
+    free(temp);
+    return PRVINFO_ERROR_INTERNAL_ERROR;
+}
+
+PI_API
+int privilege_info_get_description_by_pkgtype(const char* package_type, const char* api_version, const char* privilege, char** description)
+{
+    int ret = 0;
+    char* description_string_id = NULL;
+
+    TryReturn(package_type != NULL, PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] package_type is NULL");
+    TryReturn(api_version != NULL, PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] api_version is NULL");
+    TryReturn(privilege != NULL, PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL");
+
+    ret = privilege_info_get_description_string_id_by_pkgtype(package_type, api_version, privilege, &description_string_id);
+
+    if(ret == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE)
+    {
+        char* temp = NULL;
+        temp = dgettext("privilege", "IDS_TPLATFORM_BODY_THIS_PRIVILEGE_IS_NOT_DEFINED");
+        *description = (char*)calloc(strlen(temp) + 1, sizeof(char));
+        TryReturn(*description != NULL, PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed.");
+        memcpy(*description, temp, strlen(temp));
+        //return PRVINFO_ERROR_NO_MATCHING_PRIVILEGE;
+    }
+    else if(ret == PRVINFO_ERROR_NONE)
+    {
+        ret = privilege_info_get_description_by_string_id(description_string_id, description);
+        free(description_string_id);
+        TryReturn(ret == PRVINFO_ERROR_NONE, PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed.");
+    }
+    else
+    {
+        return PRVINFO_ERROR_INTERNAL_ERROR;
+    }
+    return PRVINFO_ERROR_NONE;
+}
+
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..9972e42
--- /dev/null
@@ -0,0 +1,24 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+SET(PACKAGE_NAME tc-privilege-info)
+PROJECT(${PACKAGE_NAME})
+
+SET(TC1_NAME tc-privilege-info)
+SET(TC1_SRCS ${PROJECT_SOURCE_DIR}/tc_privilege_info.c)
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/include)
+
+SET(requires glib-2.0 dlog)
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${PACKAGE_NAME} REQUIRED ${requires})
+FOREACH(flag ${${PACKAGE_NAME}_CFLAGS})
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC -Wall -fvisibility=hidden -D_WITH_SYSTEMD_")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${PACKAGE_NAME_CFLAGS}")
+                                                                                                                                                
+ADD_EXECUTABLE(${TC1_NAME} ${TC1_SRCS})
+TARGET_LINK_LIBRARIES(${TC1_NAME} "privilege-info")
+
+INSTALL(TARGETS ${TC1_NAME} DESTINATION /usr/bin)
\ No newline at end of file
diff --git a/test/tc_privilege_info.c b/test/tc_privilege_info.c
new file mode 100755 (executable)
index 0000000..10525e7
--- /dev/null
@@ -0,0 +1,406 @@
+#include <stdio.h>
+#include <privilege_information.h>
+
+#define BRIGHTNESS 0
+#define RED 31
+#define GREEN 32
+#define YELLOW 33
+#define BG_BLACK 40
+
+static int fail_cnt=0;
+static int success_cnt=0;
+
+static void __change_color_to_red(){
+    printf("%c[%d;%dm", 0x1B, BRIGHTNESS, RED);
+}
+
+static void __change_color_to_green(){
+    printf("%c[%d;%dm", 0x1B, BRIGHTNESS, GREEN);
+}
+
+static void __change_color_to_yellow(){
+    printf("%c[%d;%dm", 0x1B, BRIGHTNESS, YELLOW);
+}
+
+static void __change_color_to_origin(){
+    printf("%c[%dm", 0x1B, 0);
+}
+
+static const char* __get_result_string(privilege_info_error_e ret){
+    if(ret == PRVINFO_ERROR_NONE){
+        return "PRVINFO_ERROR_NONE";
+    }
+    else if(ret == PRVINFO_ERROR_INVALID_PARAMETER){
+        return "PRVINFO_ERROR_INVALID_PARAMETER";
+    }
+    else if(ret == PRVINFO_ERROR_OUT_OF_MEMORY)
+    {
+        return "PRVINFO_ERROR_OUT_OF_MEMORY";
+    }
+    else if(ret == PRVINFO_ERROR_INTERNAL_ERROR){
+        return "PRVINFO_ERROR_INTERNAL_ERROR";
+    }
+}
+
+static void __check_get_privilege_display_name_result(privilege_info_error_e expected_result, privilege_info_error_e result, const char* display_name)
+{
+    printf("expected result = %s, result = %s\n", __get_result_string(expected_result), __get_result_string(result));
+
+    if(expected_result != result)
+    {
+        printf("not matched\n");
+        __change_color_to_red();
+        printf("test fail\n");
+        fail_cnt++;
+    }else{
+        printf("matched\n");
+        if(result == PRVINFO_ERROR_NONE)
+        {
+            if(display_name == NULL)
+            {
+                printf("display_name must not be NULL\n");
+                __change_color_to_red();
+                printf("test fail\n");
+                fail_cnt++;
+                __change_color_to_origin();
+                return;
+            }else{
+                printf("display_name = %s\n", display_name);
+            }
+        }else{
+            if(display_name != NULL)
+            {
+                printf("display_name = %s\n", display_name);
+                printf("display_name must be NULL\n");
+                __change_color_to_red();
+                printf("test fail\n");
+                fail_cnt++;
+                __change_color_to_origin();
+                return;
+            }
+        }
+        __change_color_to_green();
+        printf("test success\n");
+        success_cnt++;
+    }
+    __change_color_to_origin();
+}
+
+
+static void __check_get_privilege_description_result(privilege_info_error_e expected_result, privilege_info_error_e result, const char* description)
+{
+    printf("expected result = %s, result = %s\n", __get_result_string(expected_result), __get_result_string(result));
+
+    if(expected_result != result)
+    {
+        printf("not matched\n");
+        __change_color_to_red();
+        printf("test fail\n");
+        fail_cnt++;
+    }else{
+       printf("matched\n");
+       if(result == PRVINFO_ERROR_NONE)
+        {
+            if(description == NULL)
+            {
+                printf("description must not be NULL\n");
+                __change_color_to_red();
+                printf("test fail\n");
+                fail_cnt++;
+                __change_color_to_origin();
+                return;
+            }else{
+                printf("description = %s\n", description);
+            }
+        }else{
+            if(description != NULL)
+            {
+                printf("description = %s\n", description);
+                printf("description must be NULL\n");
+                __change_color_to_red();
+                printf("test fail\n");
+                fail_cnt++;
+                __change_color_to_origin();
+                return;
+            }
+        }
+
+        __change_color_to_green();
+        printf("test success\n");
+        success_cnt++;
+    }
+    __change_color_to_origin();
+}
+
+static void __test_privilege_info_get_display_name()
+{
+    int ret;
+    char* display_name = NULL;
+
+    printf("-----------------------------------------------------------\n");
+    printf("api_version : 2.3\n");
+    printf("privilege : http://tizen.org/privilege/window.priority.set\n");
+    printf("expected result : PRVINFO_ERROR_NONE\n");
+    ret = privilege_info_get_display_name("2.3", "http://tizen.org/privilege/window.priority.set", &display_name);
+    __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name);
+
+    printf("-----------------------------------------------------------\n");
+    printf("api_version : 2.3\n");
+    printf("privilege : http://tizen.org/privilege/mediacapture\n");
+    printf("expected result : PRVINFO_ERROR_NONE\n");
+    if(display_name != NULL)
+    {
+        free(display_name);
+        display_name = NULL;
+    }
+    ret = privilege_info_get_display_name("2.3", "http://tizen.org/privilege/mediacapture", &display_name);
+    __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name);
+
+    printf("-----------------------------------------------------------\n");
+    printf("Not existing privilege\n");
+    printf("api_version : 2.3\n");
+    printf("privilege : http://tizen.org/privilege/RRRRRRRRRR\n");
+    printf("expected result : PRVINFO_ERROR_NONE\n");
+    if(display_name != NULL)
+    {
+        free(display_name);
+        display_name = NULL;
+    }
+    ret = privilege_info_get_display_name("2.3", "http://tizen.org/privilege/RRRRRRRRRR", &display_name);
+    __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name);
+
+    printf("-----------------------------------------------------------\n");
+    printf("Invalid parameter\n");
+    printf("api_version : NULL\n");
+    printf("privilege : http://tizen.org/privilege/window.priority.set\n");
+    printf("expected result : PRVINFO_ERROR_NONE\n");
+    if(display_name != NULL)
+    {
+        free(display_name);
+        display_name = NULL;
+    }
+    ret = privilege_info_get_display_name(NULL, "http://tizen.org/privilege/window,priority.set", &display_name);
+    __check_get_privilege_display_name_result(PRVINFO_ERROR_INVALID_PARAMETER, ret, display_name);
+
+    free(display_name);
+}
+static void __test_privilege_info_get_display_name_by_pkgtype()
+{
+    int ret;
+    char* display_name = NULL;
+
+    printf("-----------------------------------------------------------\n");
+    printf("pkgtype : PRVINFO_PACKAGE_TYPE_NATIVE\n");
+    printf("api_version : 2.3\n");
+    printf("privilege : http://tizen.org/privilege/window.priority.set\n");
+    printf("expected result : PRVINFO_ERROR_NONE\n");
+    ret = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/window.priority.set", &display_name);
+    __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name);
+
+    printf("-----------------------------------------------------------\n");
+    printf("pkgtype : PRVINFO_PACKAGE_TYPE_WEB\n");
+    printf("api_version : 2.3\n");
+    printf("privilege : http://tizen.org/privilege/mediacapture\n");
+    printf("expected result : PRVINFO_ERROR_NONE\n");
+    if(display_name != NULL)
+    {
+        free(display_name);
+        display_name = NULL;
+    }
+    ret = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_WEB", "2.3", "http://tizen.org/privilege/mediacapture", &display_name);
+    __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name);
+
+    printf("-----------------------------------------------------------\n");
+    printf("Mismatched package type: write WEB as NATIVE\n");
+    printf("pkgtype : PRVINFO_PACKAGE_TYPE_NATIVE\n");
+    printf("api_version : 2.3\n");
+    printf("privilege : http://tizen.org/privilege/mediacapture\n");
+    printf("expected result : PRVINFO_ERROR_NONE\n");
+    if(display_name != NULL)
+    {
+        free(display_name);
+        display_name = NULL;
+    }
+    ret = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/mediacapture", &display_name);
+    __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name);
+
+
+    printf("-----------------------------------------------------------\n");
+    printf("Not existing privilege\n");
+    printf("api_version : 2.3\n");
+    printf("privilege : http://tizen.org/privilege/RRRRRRRRRR\n");
+    printf("expected result : PRVINFO_ERROR_NONE\n");
+    if(display_name != NULL)
+    {
+        free(display_name);
+        display_name = NULL;
+    }
+    ret = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_WEB", "2.3", "http://tizen.org/privilege/RRRRRRRRRR", &display_name);
+    __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name);
+
+    printf("-----------------------------------------------------------\n");
+    printf("Invalid parameter\n");
+    printf("api_version : 2.3\n");
+    printf("privilege : http://tizen.org/privilege/mediacapture\n");
+    printf("expected result : PRVINFO_ERROR_NONE\n");
+    if(display_name != NULL)
+    {
+        free(display_name);
+        display_name = NULL;
+    }
+    ret = privilege_info_get_display_name_by_pkgtype(NULL, "2.3", "http://tizen.org/privilege/mediacapture", &display_name);
+    __check_get_privilege_display_name_result(PRVINFO_ERROR_INVALID_PARAMETER, ret, display_name);
+
+    free(display_name);
+}
+
+static void __test_privilege_info_get_description()
+{
+    int ret;
+    char* description = NULL;
+
+    printf("-----------------------------------------------------------\n");
+    printf("api_version : 2.3\n");
+    printf("privilege : http://tizen.org/privilege/window.priority.set\n");
+    printf("expected result : PRVINFO_ERROR_NONE\n");
+    ret = privilege_info_get_description("2.3", "http://tizen.org/privilege/window.priority.set", &description);
+    __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description);
+
+    printf("-----------------------------------------------------------\n");
+    printf("api_version : 2.3\n");
+    printf("privilege : http://tizen.org/privilege/mediacapture\n");
+    printf("expected result : PRVINFO_ERROR_NONE\n");
+    if(description != NULL)
+    {
+        free(description);
+        description = NULL;
+    }
+    ret = privilege_info_get_description("2.3", "http://tizen.org/privilege/mediacapture", &description);
+    __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description);
+
+    printf("-----------------------------------------------------------\n");
+    printf("Not existing privilege\n");
+    printf("api_version : 2.3\n");
+    printf("privilege : http://tizen.org/privilege/RRRRRRRRRR\n");
+    printf("expected result : PRVINFO_ERROR_NONE\n");
+    if(description != NULL)
+    {
+        free(description);
+        description = NULL;
+    }
+    ret = privilege_info_get_description("2.3", "http://tizen.org/privilege/RRRRRRRRRR", &description);
+    __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description);
+
+    printf("-----------------------------------------------------------\n");                                                                           
+    printf("Invalid parameter\n");
+    printf("api_version : 2.3\n");
+    printf("privilege : http://tizen.org/privilege/mediacapture\n");
+    printf("expected result : PRVINFO_ERROR_NONE\n");
+    if(description != NULL)
+    {
+        free(description);
+        description = NULL;
+    }
+    ret = privilege_info_get_description(NULL, "http://tizen.org/privilege/mediacapture", &description);
+    __check_get_privilege_description_result(PRVINFO_ERROR_INVALID_PARAMETER, ret, description);
+
+    free(description);
+}
+
+static void __test_privilege_info_get_description_by_pkgtype()
+{
+    int ret;
+    char* description = NULL;
+
+    printf("-----------------------------------------------------------\n");
+    printf("api_version : 2.3\n");
+    printf("privilege : http://tizen.org/privilege/window.priority.set\n");
+    printf("expected result : PRVINFO_ERROR_NONE\n");                                                                                                  
+    ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/window.priority.set", &description);
+    __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description);
+
+    printf("-----------------------------------------------------------\n");
+    printf("api_version : 2.3\n");
+    printf("privilege : http://tizen.org/privilege/mediacapture\n");
+    printf("expected result : PRVINFO_ERROR_NONE\n");
+    if(description != NULL)
+    {
+        free(description);
+        description = NULL;
+    }
+    ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_WEB", "2.3", "http://tizen.org/privilege/mediacapture", &description);
+    __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description);
+
+    printf("-----------------------------------------------------------\n");
+    printf("Mismatched package type: write WEB as NATIVE\n");
+    printf("pkgtype : PRVINFO_PACKAGE_TYPE_NATIVE\n");
+    printf("api_version : 2.3\n");
+    printf("privilege : http://tizen.org/privilege/mediacapture\n");
+    printf("expected result : PRVINFO_ERROR_NONE\n");
+    if(description != NULL)
+    {
+        free(description);
+        description = NULL;
+    }
+    ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/mediacapture", &description);
+    __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description);
+
+    printf("-----------------------------------------------------------\n");
+    printf("Not existing privilege\n");
+    printf("api_version : 2.3\n");
+    printf("privilege : http://tizen.org/privilege/RRRRRRRRRR\n");
+    printf("expected result : PRVINFO_ERROR_NONE\n");
+    if(description != NULL)
+    {
+        free(description);
+        description = NULL;
+    }
+    ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/RRRRRRRRRR", &description);
+    __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description);
+
+    printf("-----------------------------------------------------------\n");
+    printf("Invalid parameter\n");
+    printf("api_version : 2.3\n");
+    printf("privilege : NULL\n");
+    printf("expected result : PRVINFO_ERROR_INVALID_PARAMETER\n");
+    if(description != NULL)
+    {
+        free(description);
+        description = NULL;
+    }
+    ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE","2.3", NULL, &description);
+    __check_get_privilege_description_result(PRVINFO_ERROR_INVALID_PARAMETER, ret, description);
+
+    free(description);
+}
+
+int main()
+{
+    __change_color_to_yellow();
+    printf("Test function : privilege_info_get_display_name\n");
+    __change_color_to_origin();
+    __test_privilege_info_get_display_name();
+
+    __change_color_to_yellow();
+    printf("Test function : privilege_info_get_display_name_by_pkgtype\n");
+    __change_color_to_origin();
+    __test_privilege_info_get_display_name_by_pkgtype();
+
+    __change_color_to_yellow();
+    printf("Test function : privilege_info_get_description\n");
+    __change_color_to_origin();
+    __test_privilege_info_get_description();
+
+    __change_color_to_yellow();
+    printf("Test function : privilege_info_get_description_by_pkgtype\n");
+    __change_color_to_origin();
+    __test_privilege_info_get_description_by_pkgtype();
+
+    __change_color_to_green();
+    printf("Test Complete\n");
+    printf("success : %d, ", success_cnt);
+    __change_color_to_red();
+    printf("fail : %d\n", fail_cnt);
+    __change_color_to_origin();
+
+}