Initial upload 72/94772/2
authorYounho Park <younho.park@samsung.com>
Tue, 1 Nov 2016 06:47:23 +0000 (15:47 +0900)
committerYounho Park <younho.park@samsung.com>
Tue, 1 Nov 2016 06:49:28 +0000 (15:49 +0900)
Change-Id: I41d7e380d87c2b9bbcd0fdf3aa084e79b0783a9c
Signed-off-by: Younho Park <younho.park@samsung.com>
CMakeLists.txt [new file with mode: 0644]
LICENSE.APLv2 [new file with mode: 0644]
inc/ad-id.h [new file with mode: 0644]
org.tizen.settings-adid.manifest [new file with mode: 0644]
org.tizen.settings-adid.xml [new file with mode: 0644]
packaging/adid.spec [new file with mode: 0644]
resources/data/sounds/Guidance.ogg [new file with mode: 0644]
resources/edc/CMakeLists.txt [new file with mode: 0644]
resources/edc/adid.edc [new file with mode: 0644]
src/CMakeLists.txt [new file with mode: 0644]
src/ad-id.c [new file with mode: 0644]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..e483e65
--- /dev/null
@@ -0,0 +1,69 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(adid C)
+SET(PROJECT_NAME org.tizen.settings-adid)
+
+# Version control
+SET(VERSION_MAJOR 0)
+SET(VERSION "${VERSION_MAJOR}.0.1")
+
+# Architecture
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+IF("${ARCH}" STREQUAL "arm")
+    ADD_DEFINITIONS("-D_SOUND_EQ_ARCH_ARM_")
+ENDIF()
+
+SET(COMMON_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(BINDIR "${PREFIX}/bin")
+SET(LIBDIR "${PREFIX}/lib")
+SET(RESDIR "${PREFIX}/res")
+SET(DATADIR "${PREFIX}/data")
+SET(ADID_MODE_LOCALE_DIR "${RESDIR}/locale")
+SET(AD_ID_EDJ_DIR "${RESDIR}/edje")
+
+SET(RW_PREFIX ${CMAKE_INSTALL_RW_PREFIX})
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+       SET(CMAKE_BUILD_TYPE "Release")
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+
+INCLUDE(FindPkgConfig)
+
+# Check external libraries
+INCLUDE(FindPkgConfig)
+MACRO(PKG_CONFIG E_NAME A_PKG)
+    SET(${E_NAME} ${A_PKG})
+    pkg_check_modules(${E_NAME} "REQUIRED" ${A_PKG} uuid)
+ENDMACRO(PKG_CONFIG)
+
+PKG_CONFIG(E_APPFW              "capi-appfw-application")
+PKG_CONFIG(E_CAIRO             "cairo")
+PKG_CONFIG(E_DLOG               "dlog")
+PKG_CONFIG(E_VCONF              "vconf")
+PKG_CONFIG(E_APPCORE_EFL        "appcore-efl")
+PKG_CONFIG(E_EFL       "elementary eina evas edje")
+PKG_CONFIG(E_EFLEXT     "efl-extension")
+PKG_CONFIG(E_SYSTEMSETTINGS            "capi-system-system-settings")
+
+SET(EXTRA_CFLAGS "")
+FOREACH(flag ${ui_pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${COMMON_C_FLAGS} -fpie ${EXTRA_CFLAGS}")
+
+ADD_DEFINITIONS("-DEDJ_DIR=\"${AD_ID_EDJ_DIR}\"")
+ADD_DEFINITIONS("-DPROJECT_NAME=\"${PROJECT_NAME}\"")
+
+# install application HOME directory
+INSTALL(DIRECTORY DESTINATION ${DATADIR})
+
+# install file
+INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/resources/data/xml/ DESTINATION /usr/apps/org.tizen.settings-adid/res FILES_MATCHING PATTERN "*.xml")
+
+ADD_SUBDIRECTORY(src)
+ADD_SUBDIRECTORY(resources/edc)
+
+
diff --git a/LICENSE.APLv2 b/LICENSE.APLv2
new file mode 100644 (file)
index 0000000..d645695
--- /dev/null
@@ -0,0 +1,202 @@
+
+                                 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.
diff --git a/inc/ad-id.h b/inc/ad-id.h
new file mode 100644 (file)
index 0000000..4c9d2c1
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ *  Copyright (c) 2000 - 2015 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 __UG_AD_ID_H__
+#define __UG_AD_ID_H__
+
+#include <app.h>
+#include <dlog.h>
+#include <Elementary.h>
+#include <stdio.h>
+#include <string.h>
+#include <vconf.h>
+#include <efl_extension.h>
+#include <app_preference.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct appdata {
+       Evas_Object* win;
+       Evas_Object* layout;
+       Evas_Object* conform;
+       Evas_Object* nf;
+} ad_id_app_data_s;
+
+#define TAG_ADID "AD_ID"
+#if !defined(AD_ID_PKG)
+#define AD_ID_PKG "org.tizen.settings-adid"
+#endif
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#define LOG_TAG TAG_ADID
+#endif
+#define AD_ID_EDJ "edje/adid.edj"
+
+#define AI_LOGD(fmt, args...)  LOGD(fmt, ##args)
+#define AI_LOGW(fmt, args...)  LOGW(fmt, ##args)
+#define AI_LOGI(fmt, args...)  LOGI(fmt, ##args)
+#define AI_LOGE(fmt, args...)  LOGE(fmt, ##args)
+
+#define AI_FUNC_ENTER  AI_LOGD("(%s) ENTER", __FUNCTION__);
+#define AI_FUNC_EXIT   AI_LOGD("(%s) EXIT", __FUNCTION__);
+#define AI_RETURN_IF_FAILED(point) do { \
+               if (point == NULL) { \
+                       AI_LOGE("critical error : AI_RETURN_IF_FAILED"); \
+                       return; \
+               } \
+       } while (0)
+
+#ifdef __cplusplus
+}
+#endif /*__cplusplus */
+
+#endif
diff --git a/org.tizen.settings-adid.manifest b/org.tizen.settings-adid.manifest
new file mode 100644 (file)
index 0000000..97e8c31
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+       <request>
+               <domain name="_"/>
+       </request>
+</manifest>
diff --git a/org.tizen.settings-adid.xml b/org.tizen.settings-adid.xml
new file mode 100644 (file)
index 0000000..d7ea27f
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns="http://tizen.org/ns/packages" package="org.tizen.settings-adid" version="0.0.1" install-location="internal-only" api-version="3.0">
+       <label>ADID</label>
+       <author email="sriram.k@samsung.com" href="www.samsung.com">Sriram</author>
+       <description>AD ID generating application</description>
+       <ui-application appid="org.tizen.settings-adid" exec="/usr/apps/org.tizen.settings-adid/bin/adid" launch_mode="caller" nodisplay="true" taskmanage="false" multiple="false" type="capp">
+       <label>Ad Id</label>
+       </ui-application>
+
+       <privileges>
+               <privilege>http://tizen.org/privilege/systemsettings.admin</privilege>
+       </privileges>
+</manifest>
diff --git a/packaging/adid.spec b/packaging/adid.spec
new file mode 100644 (file)
index 0000000..f29adc0
--- /dev/null
@@ -0,0 +1,83 @@
+Name:       org.tizen.settings-adid
+Summary:    Ad Id
+Version:    0.0.1
+Release:    1
+Group:      comm
+License:    Apache-2.0
+Source0:    %{name}-%{version}.tar.gz
+BuildRequires: pkgconfig(capi-appfw-application)
+BuildRequires: pkgconfig(efl-extension)
+BuildRequires: pkgconfig(cairo)
+BuildRequires: pkgconfig(elementary)
+BuildRequires: pkgconfig(eina)
+BuildRequires: pkgconfig(evas)
+BuildRequires: pkgconfig(edje)
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(appcore-efl)
+BuildRequires: pkgconfig(capi-system-system-settings)
+BuildRequires: edje-bin
+BuildRequires: cmake
+BuildRequires: gettext-tools
+Requires(post):   /sbin/ldconfig
+Requires(post):   /usr/bin/vconftool
+requires(postun): /sbin/ldconfig
+
+%define appdir /usr/apps/org.tizen.settings-adid
+
+%description
+Tizen Ad-Id Setting Application
+
+%prep
+%setup -q
+
+%build
+export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
+export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
+
+%define PREFIX    "/usr/apps/org.tizen.settings-adid"
+%define RW_PREFIX      "/opt/usr/apps/org.tizen.settings-adid"
+
+cmake . -DCMAKE_INSTALL_PREFIX=%{PREFIX} -DCMAKE_INSTALL_RW_PREFIX=%{RW_PREFIX}
+cmake . -DCMAKE_INSTALL_PREFIX=%{PREFIX} -DCMAKE_INSTALL_DATADIR=%{DATADIR}
+cmake . -DCMAKE_INSTALL_PREFIX=%{PREFIX} -DCMAKE_INSTALL_SHAREDDIR=%{SHAREDDIR}
+make %{?jobs:-j%jobs}
+
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}/usr/share/license
+cp %{_builddir}/%{name}-%{version}/LICENSE.APLv2 %{buildroot}/usr/share/license/%{name}
+
+%make_install
+
+###### for package signing step ######
+%define tizen_sign 1
+%define tizen_sign_base /usr/apps/org.tizen.settings-adid
+%define tizen_sign_level platform
+%define tizen_author_sign 1
+%define tizen_dist_sign 1
+
+%post
+/sbin/ldconfig
+mkdir -p /opt/usr/apps/org.tizen.settings-adid/data
+chown -R 5000:5000 /opt/usr/apps/org.tizen.settings-adid/data
+echo -e '\033[1m\033[36m ===== Import to package DB using tpk-backend ===== \033[0m'
+echo 'tpk-backend -y %{name} --preload'
+tpk-backend -y %{name} --preload
+echo -e '\033[1m\033[36m ===== done ===== \033[0m'
+
+%postun -p /sbin/ldconfig
+
+%files
+%manifest org.tizen.settings-adid.manifest
+%defattr(-,root,root,-)
+/usr/share/license/%{name}
+%attr(-,inhouse,inhouse)
+/usr/apps/org.tizen.settings-adid/*
+%defattr(-,root,root,-)
+%{appdir}/data/
+/usr/share/packages/org.tizen.settings-adid.xml
+%defattr(-,*,*,-)
+%dir
diff --git a/resources/data/sounds/Guidance.ogg b/resources/data/sounds/Guidance.ogg
new file mode 100644 (file)
index 0000000..97c5a6c
Binary files /dev/null and b/resources/data/sounds/Guidance.ogg differ
diff --git a/resources/edc/CMakeLists.txt b/resources/edc/CMakeLists.txt
new file mode 100644 (file)
index 0000000..cbdcd9c
--- /dev/null
@@ -0,0 +1,15 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(adid C CXX)
+
+ADD_CUSTOM_TARGET(adid.edj
+       COMMAND edje_cc -no-save -id ${CMAKE_CURRENT_SOURCE_DIR}/../data/images
+               ${CMAKE_CURRENT_SOURCE_DIR}/adid.edc ${CMAKE_CURRENT_SOURCE_DIR}/adid.edj
+               DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/adid.edc
+)
+ADD_DEPENDENCIES(${PROJECT_NAME} adid.edj)
+
+
+#install binary & edj files
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/adid.edj DESTINATION ${AD_ID_EDJ_DIR})
+
+
diff --git a/resources/edc/adid.edc b/resources/edc/adid.edc
new file mode 100644 (file)
index 0000000..2cc8c01
--- /dev/null
@@ -0,0 +1,17 @@
+collections {
+   group { name: "main";
+      parts {
+         part { name: "txt_title";
+            type: TEXT;
+            mouse_events: 0;
+            description { state: "default" 0.0;
+               align: 0.0 0.0;
+               rel1 { relative: 0.0 0.0; }
+               rel2 { relative: 0.0 0.0; }
+               text { font: "Tizen:style=regular"; size: 20; min: 1 1; }
+               color: 0 0 0 255;
+            }
+         }
+      }
+   }
+}
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644 (file)
index 0000000..58151b4
--- /dev/null
@@ -0,0 +1,63 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+PROJECT(adid C)
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+       SET(CMAKE_BUILD_TYPE "Release")
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+
+# Set ready to build
+SET(EXT_LIBS_DIRS "")
+SET(EXT_LIBS_DEFS "")
+SET(EXT_LIBS_LDFLAGS "")
+
+# Set external libraries
+SET(EXT_LIBS
+    E_APPFW
+       E_CAIRO
+       E_DLOG
+       E_VCONF
+       E_APPCORE_EFL
+       E_EFL
+       E_EFLEXT
+       E_SYSTEMSETTINGS
+)
+
+FOREACH(flag ${EXT_LIBS})
+    SET(EXT_LIBS_DIRS       ${EXT_LIBS_DIRS}    ${${flag}_INCLUDE_DIRS})
+    SET(EXT_LIBS_DEFS       ${EXT_LIBS_DEFS}    ${${flag}_CFLAGS_OTHER})
+    SET(EXT_LIBS_LDFLAGS    ${EXT_LIBS_LDFLAGS} ${${flag}_LDFLAGS})
+ENDFOREACH(flag)
+
+# Set ready to build
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../inc)
+INCLUDE_DIRECTORIES(${EXT_LIBS_DIRS})
+
+ADD_DEFINITIONS(
+    ${EXT_LIBS_DEFS}
+)
+
+SET(SRCS
+    ad-id.c
+)
+
+ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
+ADD_DEFINITIONS("-DRESDIR=\"${RESDIR}\"")
+ADD_DEFINITIONS("-DDATADIR=\"${DATADIR}\"")
+
+ADD_DEFINITIONS("-D_ADID_SIGNAL_HANDLER")
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} "-pie" "-ldl" ${EXT_LIBS_LDFLAGS})
+
+message(${EXT_LIBS_LDFLAGS})
+
+#install binary & edj files
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR})
+
+# install manifest file & icon
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/org.tizen.settings-adid.xml DESTINATION /usr/share/packages)
+
+# install application HOME directory
+INSTALL(DIRECTORY DESTINATION ${DATADIR})
diff --git a/src/ad-id.c b/src/ad-id.c
new file mode 100644 (file)
index 0000000..9fcc240
--- /dev/null
@@ -0,0 +1,514 @@
+/*
+ *  Copyright (c) 2000 - 2015 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
+ *
+ */
+
+#include <app.h>
+#include <glib.h>
+#include <vconf.h>
+#include <Elementary.h>
+#include <dlog.h>
+#include <vconf.h>
+#include <system_settings.h>
+#include "ad-id.h"
+#include "app_preference.h"
+#include "uuid/uuid.h"
+
+#define DEFAULT_ID "00000000-0000-0000-0000-000000000000"
+
+Elm_Object_Item *id_it = NULL;
+
+const char *get_res_path()
+{
+       static char res_folder_path[PATH_MAX] = {'\0'};
+       if (res_folder_path[0] == '\0') {
+               char *resource_path_buf = app_get_resource_path();
+               strncpy(res_folder_path, resource_path_buf, PATH_MAX-1);
+               free(resource_path_buf);
+       }
+       return res_folder_path;
+}
+
+static void
+win_delete_request_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       ui_app_exit();
+}
+
+static Eina_Bool
+naviframe_pop_cb(void *data, Elm_Object_Item *it)
+{
+       AI_FUNC_ENTER
+       ui_app_exit();
+       return EINA_FALSE;
+}
+
+void make_ad_id(void)
+{
+       int ret = 0;
+       AI_LOGD("make_ad_id");
+       uuid_t uuid_value;
+       char uuid_unparsed[50] = {0};
+       uuid_generate(uuid_value);
+       uuid_unparse_lower(uuid_value, uuid_unparsed);
+       AI_LOGD("ad_id %s", uuid_unparsed);
+       system_settings_set_value_string(SYSTEM_SETTINGS_KEY_ADS_ID, uuid_unparsed);
+       ret = vconf_set_str(VCONFKEY_SETAPPL_AD_ID, uuid_unparsed);
+       AI_LOGE("vconf_set_str ret = %d", ret);
+       elm_genlist_item_update(id_it);
+
+}
+
+/* Opt out popup */
+static void
+_opt_out_popup_ok_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       Evas_Object *popup = data;
+
+       Evas_Object *chk = (Evas_Object *)evas_object_data_get(popup, "checkobj");
+       evas_object_del(popup);
+       bool val = elm_check_state_get(chk);
+       val = !val;
+       elm_check_state_set(chk, val);
+       elm_object_item_disabled_set(id_it, val);
+       if (val)
+               vconf_set_int(VCONFKEY_SETAPPL_AD_ID_OPT_OUT, 1);
+       else
+               vconf_set_int(VCONFKEY_SETAPPL_AD_ID_OPT_OUT, 0);
+}
+
+static void
+_opt_out_popup_cancel_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       Evas_Object *popup = data;
+       evas_object_del(popup);
+}
+
+static void
+_create_opt_out_popup(ad_id_app_data_s *ad, Evas_Object *chk)
+{
+       Evas_Object *popup;
+       Evas_Object *btn;
+
+       /* popup */
+       popup = elm_popup_add(ad->win);
+       elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
+       eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, eext_popup_back_cb, NULL);
+       evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_data_set(popup, "checkobj", chk);
+       elm_object_text_set(popup,
+               "You may not see ads based on your interests as you are opting out interest-based ads. However, you will still see ads.");
+       elm_object_part_text_set(popup, "title,text", "Opt out?");
+
+       /* ok button */
+       btn = elm_button_add(popup);
+       elm_object_style_set(btn, "popup");
+       elm_object_text_set(btn, "OK");
+       elm_object_part_content_set(popup, "button2", btn);
+       evas_object_smart_callback_add(btn, "clicked",
+               _opt_out_popup_ok_btn_clicked_cb, popup);
+
+       /* cancel button */
+       btn = elm_button_add(popup);
+       elm_object_style_set(btn, "popup");
+       elm_object_text_set(btn, "CANCEL");
+       elm_object_part_content_set(popup, "button1", btn);
+       evas_object_smart_callback_add(btn, "clicked",
+               _opt_out_popup_cancel_btn_clicked_cb, popup);
+
+       evas_object_show(popup);
+}
+
+/* Reset ID popup */
+static void
+_reset_id_popup_ok_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       Evas_Object *popup = data;
+       evas_object_del(popup);
+
+       make_ad_id();
+}
+
+static void
+_reset_id_popup_cancel_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       Evas_Object *popup = data;
+       evas_object_del(popup);
+}
+
+static void
+_create_reset_id_popup(ad_id_app_data_s *ad)
+{
+       Evas_Object *popup;
+       Evas_Object *btn;
+
+       /* popup */
+       popup = elm_popup_add(ad->win);
+       elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
+       eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, eext_popup_back_cb, NULL);
+       evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_data_set(popup, "appdata", ad);
+       elm_object_text_set(popup,
+               "Your advertising ID will be replaced with a new random number");
+       elm_object_part_text_set(popup, "title,text", "Reset advertising ID?");
+
+       /* ok button */
+       btn = elm_button_add(popup);
+       elm_object_style_set(btn, "popup");
+       elm_object_text_set(btn, "OK");
+       elm_object_part_content_set(popup, "button2", btn);
+       evas_object_smart_callback_add(btn, "clicked",
+               _reset_id_popup_ok_btn_clicked_cb, popup);
+
+       /* cancel button */
+       btn = elm_button_add(popup);
+       elm_object_style_set(btn, "popup");
+       elm_object_text_set(btn, "CANCEL");
+       elm_object_part_content_set(popup, "button1", btn);
+       evas_object_smart_callback_add(btn, "clicked",
+               _reset_id_popup_cancel_btn_clicked_cb, popup);
+
+       evas_object_show(popup);
+}
+
+static char *
+_text_get_cb(void *data, Evas_Object *obj, const char *part)
+{
+       AI_FUNC_ENTER
+       AI_LOGD("part : %s", part);
+       int id = (int) data;
+       char *adid = NULL;
+       char buf[1024] = {0};
+       char *long_text = NULL;
+       if (!strcmp(part, "elm.text")) {
+               switch (id) {
+               case 2:
+                       return strdup("Your advertising ID :");
+               case 3:
+                       return strdup("Reset advertising ID");
+               case 4:
+                       return strdup("Opt out of interest-based ad");
+               default:
+                       break;
+               }
+       } else if (!strcmp(part, "elm.text.multiline")) {
+               switch (id) {
+               case 1:
+                       long_text = "Control the types of interest-based ads that you see on this device.";
+                       snprintf(buf, sizeof(buf), "<font_size=40><color=#000000>%s</color></font_size>", long_text);
+                       return strdup(buf);
+               case 2:
+                       adid = vconf_get_str(VCONFKEY_SETAPPL_AD_ID);
+                       AI_LOGD("adid: %s", adid);
+                       return strdup(adid);
+               case 3:
+                       return strdup("Recreate a new user profile by generating new user ID");
+               case 4:
+                       return strdup("Do not let apps use your advertising ID to build profiles to show you interest bases ads");
+               default:
+                       break;
+               }
+
+       }
+
+       return NULL;
+}
+
+static Evas_Object *
+_content_get_cb(void *data, Evas_Object *obj, const char *part)
+{
+       AI_FUNC_ENTER
+       /* int id = (int) data; */
+       int val = 0;
+       vconf_get_int(VCONFKEY_SETAPPL_AD_ID_OPT_OUT, &val);
+       /* ad_id_app_data_s *ad = evas_object_data_get(obj, "ad"); */
+
+       if (!strcmp("elm.icon", part)) {
+               Evas_Object *check;
+               check = elm_check_add(obj);
+               elm_object_style_set(check, "on&off");
+               if (val == 0)
+                       elm_check_state_set(check, EINA_FALSE);
+               else
+                       elm_check_state_set(check, EINA_TRUE);
+
+               elm_object_signal_emit(check, "elm,event,pass,enabled", "elm");
+               evas_object_propagate_events_set(check, EINA_TRUE);
+               return check;
+       }
+
+       return NULL;
+}
+
+void sel_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       AI_FUNC_ENTER
+       int id = (int) data;
+       ad_id_app_data_s *ad = evas_object_data_get(obj, "ad");
+       Elm_Object_Item *it = (Elm_Object_Item *) event_info;
+       elm_genlist_item_selected_set(it, EINA_FALSE);
+
+       if (id == 3) {
+               _create_reset_id_popup(ad);
+
+       } else if (id == 4) {
+               Evas_Object *chk = (Evas_Object *)elm_object_item_part_content_get(it, "elm.icon");
+               if (!elm_check_state_get(chk))
+                       _create_opt_out_popup(ad, chk);
+               else {
+                       elm_check_state_set(chk, false);
+                       elm_object_item_disabled_set(id_it, EINA_FALSE);
+                       vconf_set_int(VCONFKEY_SETAPPL_AD_ID_OPT_OUT, 0);
+               }
+       }
+}
+
+static void
+prev_btn_selected_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       AI_FUNC_ENTER
+       ad_id_app_data_s *ad = (ad_id_app_data_s*)data;
+       if (ad != NULL)
+               elm_naviframe_item_pop(ad->nf);
+}
+
+static void
+create_list_view(ad_id_app_data_s *ad)
+{
+       AI_FUNC_ENTER
+       AI_LOGD("Entered in to create list view");
+       Evas_Object *genlist;
+       Elm_Genlist_Item_Class *itc, *itc1, *itc2 = NULL;
+       Evas_Object *nf = ad->nf;
+       Elm_Object_Item *nf_it;
+
+       itc2 = elm_genlist_item_class_new();
+       itc2->item_style = "multiline";
+       itc2->func.content_get = NULL;
+       itc2->func.text_get = _text_get_cb;
+       itc2->func.del = NULL;
+
+       itc = elm_genlist_item_class_new();
+       itc->item_style = "multiline_sub.main.1icon";
+       itc->func.content_get = _content_get_cb;
+       itc->func.text_get = _text_get_cb;
+       itc->func.del = NULL;
+
+       itc1 = elm_genlist_item_class_new();
+       itc1->item_style = "multiline_sub.main";
+       itc1->func.content_get = NULL;
+       itc1->func.text_get = _text_get_cb;
+       itc1->func.del = NULL;
+
+
+       genlist = elm_genlist_add(nf);
+       elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
+       evas_object_data_set(genlist, "ad", ad);
+
+       Elm_Object_Item *item1 = elm_genlist_item_append(genlist,       /* genlist object */
+               itc2,   /* item class */
+               (void *)1,      /* item class user data */
+               NULL,
+               ELM_GENLIST_ITEM_NONE,  /* item type */
+               sel_cb, /* select smart callback */
+               NULL);  /* smart callback user data */
+       elm_genlist_item_select_mode_set(item1, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+
+       id_it = elm_genlist_item_append(genlist,        /* genlist object */
+               itc2,   /* item class */
+               (void *)2,      /* item class user data */
+               NULL,
+               ELM_GENLIST_ITEM_NONE,  /* item type */
+               NULL,   /* select smart callback */
+               NULL);  /* smart callback user data */
+       elm_genlist_item_select_mode_set(id_it, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+
+       elm_genlist_item_append(genlist,        /* genlist object */
+               itc2,           /* item class */
+               (void *)3,      /* item class user data */
+               NULL,
+               ELM_GENLIST_ITEM_NONE,  /* item type */
+               sel_cb,         /* select smart callback */
+               (void *)3);     /* smart callback user data */
+
+
+       elm_genlist_item_append(genlist,        /* genlist object */
+               itc2,           /* item class */
+               (void *)4,      /* item class user data */
+               NULL,
+               ELM_GENLIST_ITEM_NONE,  /* item type */
+               sel_cb,         /* select smart callback */
+               (void *)4);     /* smart callback user data */
+
+       Evas_Object *back_btn = elm_button_add(ad->nf);
+       elm_object_style_set(back_btn, "naviframe/back_btn/default");
+       evas_object_smart_callback_add(back_btn, "clicked", prev_btn_selected_cb, ad);
+       nf_it = elm_naviframe_item_push(nf, "Ads", back_btn, NULL, genlist, NULL);
+       elm_naviframe_item_pop_cb_set(nf_it, naviframe_pop_cb, ad->win);
+}
+
+static void
+create_base_gui(ad_id_app_data_s *ad)
+{
+       AI_FUNC_ENTER
+
+       /* Window */
+       ad->win = elm_win_util_standard_add(AD_ID_PKG, AD_ID_PKG);
+       elm_win_conformant_set(ad->win, EINA_TRUE);
+       elm_win_autodel_set(ad->win, EINA_TRUE);
+
+       if (elm_win_wm_rotation_supported_get(ad->win)) {
+               int rots[4] = { 0, 90, 180, 270 };
+               elm_win_wm_rotation_available_rotations_set(ad->win, (const int *)(&rots), 4);
+       }
+
+       evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL);
+
+       /* Conformant */
+       ad->conform = elm_conformant_add(ad->win);
+       elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW);
+       elm_win_indicator_opacity_set(ad->win, ELM_WIN_INDICATOR_OPAQUE);
+       evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       elm_win_resize_object_add(ad->win, ad->conform);
+       evas_object_show(ad->conform);
+
+
+       ad->nf = elm_naviframe_add(ad->conform);
+       AI_LOGD("Entered in to crease base");
+       create_list_view(ad);
+       elm_object_part_content_set(ad->conform, "elm.swallow.content", ad->nf);
+
+       eext_object_event_callback_add(ad->nf, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
+       eext_object_event_callback_add(ad->nf, EEXT_CALLBACK_MORE, eext_naviframe_more_cb, NULL);
+       /* Show window after base gui is set up */
+       int val = 0;
+       vconf_get_int(VCONFKEY_SETAPPL_AD_ID_OPT_OUT, &val);
+       if (val == 1)
+               elm_object_item_disabled_set(id_it, EINA_TRUE);
+
+       evas_object_show(ad->win);
+
+}
+
+static bool _app_create_cb(void *user_data)
+{
+       AI_FUNC_ENTER
+       elm_app_base_scale_set(2.6);
+
+       /* uxt_theme_set_changeable_ui_enabled(EINA_TRUE); */
+       AI_FUNC_EXIT
+       return true;
+}
+
+
+static void _app_terminate_cb(void *user_data)
+{
+       AI_FUNC_ENTER
+       ad_id_app_data_s *ad = (ad_id_app_data_s *) user_data;
+       AI_RETURN_IF_FAILED(ad);
+}
+
+static void _app_pause_cb(void *user_data)
+{
+       AI_FUNC_ENTER
+}
+
+static void _app_resume_cb(void *user_data)
+{
+       AI_FUNC_ENTER
+}
+
+static void _app_control_cb(app_control_h app_control, void *user_data)
+{
+       AI_FUNC_ENTER
+
+       ad_id_app_data_s *ad = (ad_id_app_data_s *) user_data;
+       AI_RETURN_IF_FAILED(ad);
+
+       char *value = NULL;
+       app_control_get_extra_data(app_control, "Operation", &value);
+
+       if (value != NULL && !strcmp(value, "GenerateAdId")) {
+               char *adid = vconf_get_str(VCONFKEY_SETAPPL_AD_ID);
+               if (!strcmp(adid, DEFAULT_ID)) {
+                       make_ad_id();
+                       vconf_set_int(VCONFKEY_SETAPPL_AD_ID_OPT_OUT, 0);
+               }
+       } else {
+               create_base_gui(ad);
+       }
+}
+
+/*
+static void _app_low_memory_cb(void *user_data)
+{
+       AI_FUNC_ENTER
+       //Nothing
+}
+
+static void _app_low_battery_cb(void *user_data)
+{
+       AI_FUNC_ENTER
+       //Nothing
+}
+
+static void _app_device_orientation_cb(app_device_orientation_e orientation, void *user_data)
+{
+       AI_FUNC_ENTER
+
+       //Nothing
+}
+*/
+
+static void _app_language_changed_cb(app_event_info_h event_info, void *user_data)
+{
+       AI_FUNC_ENTER
+}
+
+/*
+static void _app_region_format_changed_cb(void *user_data)
+{
+       AI_FUNC_ENTER
+       //Nothing
+}
+*/
+
+int main(int argc, char *argv[])
+{
+       AI_FUNC_ENTER
+
+       int ret = APP_ERROR_NONE;
+       ad_id_app_data_s ad = {0,};
+       ui_app_lifecycle_callback_s event_callback = {0,};
+       app_event_handler_h handler = NULL;
+
+       event_callback.create = _app_create_cb;
+       event_callback.terminate = _app_terminate_cb;
+       event_callback.app_control = _app_control_cb;
+       event_callback.pause = _app_pause_cb;
+       event_callback.resume = _app_resume_cb;
+
+       ret = ui_app_add_event_handler(&handler, APP_EVENT_LANGUAGE_CHANGED, _app_language_changed_cb, &ad);
+       if (ret != APP_ERROR_NONE)
+               AI_LOGE("ui_app_add_event_handler() is failed. err=%d", ret);
+
+       ret = ui_app_main(argc, argv, &event_callback, &ad);
+       if (ret != APP_ERROR_NONE)
+               AI_LOGE("ui_app_main() is failed. err=%d", ret);
+
+       return 0;
+       AI_FUNC_EXIT
+}
+