initial upload
authorJisung Ahn <jcastle.ahn@samsung.com>
Tue, 21 Aug 2012 08:51:52 +0000 (17:51 +0900)
committerJisung Ahn <jcastle.ahn@samsung.com>
Tue, 21 Aug 2012 13:05:18 +0000 (22:05 +0900)
Change-Id: I19875e2aace7daa8a3b676ea8313e8a49f5d99be

15 files changed:
CMakeLists.txt
debian/changelog [deleted file]
debian/compat [deleted file]
debian/control [deleted file]
debian/org.tizen.image-viewer.install.in [deleted file]
debian/org.tizen.image-viewer.postinst [deleted file]
debian/rules [deleted file]
include/image-viewer.h
org.tizen.image-viewer.desktop.in [deleted file]
org.tizen.image-viewer.png [deleted file]
packaging/changelog [new file with mode: 0755]
packaging/org.tizen.image-viewer.spec
res/manifest/org.tizen.image-viewer.png [new file with mode: 0755]
res/manifest/org.tizen.image-viewer.xml [new file with mode: 0755]
src/image-viewer.c

index 1a7abcc..0585aba 100755 (executable)
@@ -12,8 +12,18 @@ ${CMAKE_CURRENT_SOURCE_DIR}/include/
 )
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED appcore-efl appcore-common utilX elementary ui-gadget
-evas ecore-x ecore ecore-input appsvc)
+pkg_check_modules(pkgs REQUIRED
+       utilX
+       elementary
+       ui-gadget-1
+       evas
+       ecore-x
+       ecore
+       ecore-input
+       vconf
+       capi-appfw-application
+       dlog
+)
 
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
@@ -22,26 +32,26 @@ ENDFOREACH(flag)
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
 
 ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DSLP_DEBUG")
 
 #SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
 
 # install desktop file & icon
 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
-CONFIGURE_FILE(${DEBFILE_NAME}.desktop.in ${CMAKE_SOURCE_DIR}/${DEBFILE_NAME}.desktop)
 
 SET(BINDIR "${PREFIX}/bin")
 SET(RESDIR "${PREFIX}/res")
 SET(DATADIR "${PREFIX}/data")
 SET(LOCALEDIR "${RESDIR}/locale")
-SET(ICONDIR "${RESDIR}/icons/default/small")
+SET(ICONDIR "/opt/share/icons/default/small")
 SET(EDJDIR "${RESDIR}/edje")
 
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/${DEBFILE_NAME}.desktop DESTINATION /opt/share/applications)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/res/manifest/${DEBFILE_NAME}.xml DESTINATION /opt/share/packages)
 INSTALL(DIRECTORY DESTINATION ${DATADIR})
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/${DEBFILE_NAME}.png DESTINATION ${ICONDIR})
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/res/manifest/${DEBFILE_NAME}.png DESTINATION ${ICONDIR})
 
 ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} )
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
 
 INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
 
diff --git a/debian/changelog b/debian/changelog
deleted file mode 100755 (executable)
index 8838543..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-image-viewer (1.0-58) unstable; urgency=low
-
-   * Initial version
-   * Git: pkgs/i/image-viewer
-   * Tag: image-viewer_1.0-58 
-
- -- Jisung Ahn <jcastle.ahn@samsung.com>  Fri, 17 Feb 2012 12:44:50 +0900
-
diff --git a/debian/compat b/debian/compat
deleted file mode 100755 (executable)
index 7ed6ff8..0000000
+++ /dev/null
@@ -1 +0,0 @@
-5
diff --git a/debian/control b/debian/control
deleted file mode 100755 (executable)
index d431800..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-Source: image-viewer
-Section: misc
-Priority: extra
-Maintainer:  Li Suxia <suxia.li@samsung.com>, Tang Feng <feng.tang@samsung.com>, Hyunwoo Kim <hw4444.kim@samsung.com>, Jisung Ahn <jcastle.ahn@samsung.com>, Sangjin Han <sjhan.han@samsung.com>
-Uploaders: Tang Feng <feng.tang@samsung.com>, Hyunwoo Kim <hw4444.kim@samsung.com>
-Build-Depends: debhelper (>= 5), 
-       autotools-dev,
-       libappcore-efl-dev, 
-       libelm-dev, 
-       libedje-dev, 
-       libevas-dev, 
-       libecore-dev, 
-       libui-gadget-dev, 
-       libaul-1-dev,
-       libappsvc-dev,
-       libslp-setting-dev,
-       libslp-utilx-dev
-Standards-Version: 0.1.0
-
-Package: org.tizen.image-viewer
-Section: misc
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, 
-       libappcore-efl-0, 
-       libelm, 
-       libedje, 
-       libevas,
-       libecore, 
-       libui-gadget-0,
-       libslp-utilx-0,
-       libappsvc-0,
-       libslp-setting-0,
-       libug-image-viewer-efl
-Description: Image Viewer Application v1.0
-
-Package: org.tizen.image-viewer-dbg
-Section: debug
-Architecture: any
-Depends: ${misc:Depends}, org.tizen.image-viewer (= ${Source-Version})
-Description: Image Viewer Application (unstripped)
-
-
diff --git a/debian/org.tizen.image-viewer.install.in b/debian/org.tizen.image-viewer.install.in
deleted file mode 100755 (executable)
index 789a139..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-@PREFIX@/bin/*
-@PREFIX@/res/icons/*
-@PREFIX@/data
-/opt/share/applications/*
-
-
diff --git a/debian/org.tizen.image-viewer.postinst b/debian/org.tizen.image-viewer.postinst
deleted file mode 100755 (executable)
index 7ea27e6..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-if [ ${USER} == "root" ]
-then
-       # 5000 is inhouse user id
-       # do not use relative path
-       chown -R 5000:5000 /opt/apps/org.tizen.image-viewer/data
-fi
diff --git a/debian/rules b/debian/rules
deleted file mode 100755 (executable)
index 702fa63..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-#!/usr/bin/make -f
-# -*- makefile -*-
-# Sample debian/rules that uses debhelper.
-# This file was originally written by Joey Hess and Craig Small.
-# As a special exception, when this file is copied by dh-make into a
-# dh-make output file, you may use that output file without restriction.
-# This special exception was added by Craig Small in version 0.37 of dh-make.
-
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
-
-CFLAGS ?= -Wall -g
-CXXFLAGS ?=  -Wall -g
-LDFLAGS ?=
-PREFIX ?= /opt/apps/org.tizen.image-viewer
-RESDIR ?= /opt/apps/org.tizen.image-viewer/res
-DATADIR ?= /opt/apps/org.tizen.image-viewer/data
-
-CFLAGS += -fpic
-CXXFLAGS += -fpic
-
-ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
-       CFLAGS += -O0
-       CXXFLAGS += -O0
-else
-       CFLAGS += -O2
-       CXXFLAGS += -O2
-endif
-
-LDFLAGS += -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed -pie
-
-configure: configure-stamp
-configure-stamp:
-       dh_testdir
-       # Add here commands to configure the package.
-       CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" cmake . -DCMAKE_INSTALL_PREFIX=$(PREFIX)
-
-       touch configure-stamp
-
-build: build-stamp
-
-build-stamp: configure-stamp 
-       dh_testdir
-
-       # Add here commands to compile the package.
-       $(MAKE)
-       #docbook-to-man debian/wavplayer.sgml > wavplayer.1
-
-       for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
-               cat $$f > $${f%.in}; \
-               sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \
-               sed -i -e "s#@RESDIR@#$(RESDIR)#g" $${f%.in}; \
-               sed -i -e "s#@DATADIR@#$(DATADIR)#g" $${f%.in}; \
-       done
-
-
-       touch $@
-
-clean:
-       dh_testdir
-       dh_testroot
-       rm -f build-stamp configure-stamp
-
-       # Add here commands to clean up after the build process.
-       -$(MAKE) clean
-       rm -rf CMakeCache.txt
-       rm -rf CMakeFiles
-       rm -rf cmake_install.cmake
-       rm -rf Makefile
-       rm -rf install_manifest.txt
-       rm -rf *.so
-       rm -rf *.desktop
-       find -name CMakeFiles | xargs rm -rf
-       find -name cmake_install.cmake | xargs rm -rf
-       find -name Makefile | xargs rm -rf
-       find -name "*.cmake" | xargs rm -rf
-       find -name "*.edj" | xargs rm -rf
-
-       for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
-               rm -f $${f%.in}; \
-       done
-
-       dh_clean 
-
-
-install: build
-       dh_testdir
-       dh_testroot
-       dh_clean -k 
-       dh_installdirs
-
-       # Add here commands to install the package into debian/wavplayer.
-       $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
-
-
-# Build architecture-independent files here.
-binary-indep: build install
-# We have nothing to do by default.
-
-# Build architecture-dependent files here.
-binary-arch: build install
-       dh_testdir
-       dh_testroot
-#      dh_installchangelogs 
-#      dh_installdocs
-       dh_installexamples
-       dh_install --sourcedir=debian/tmp
-#      dh_installmenu
-#      dh_installdebconf       
-#      dh_installlogrotate
-#      dh_installemacsen
-#      dh_installpam
-#      dh_installmime
-#      dh_python
-#      dh_installinit
-#      dh_installcron
-#      dh_installinfo
-       dh_installman
-       dh_link
-       dh_strip --dbg-package=org.tizen.image-viewer-dbg
-       dh_compress
-       dh_fixperms
-#      dh_perl
-       dh_makeshlibs
-       dh_installdeb
-       dh_shlibdeps
-       dh_gencontrol
-       dh_md5sums
-       dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install configure
index 5e55a79..e1f5bf9 100755 (executable)
  * limitations under the License.
  */
 
-
 #include <Elementary.h>
-
-#define IV_LOG_OUTPUT_DLOG
-
-#ifdef IV_LOG_OUTPUT_DLOG
-
 #include <dlog.h>
 
 #undef LOG_TAG
 #define LOG_TAG "IMAGE-VIEWER"
 
-#define iv_debug_msg(type, fmt, arg...)        LOGD("[%s : %05d]" fmt "\n", __func__, __LINE__, ##arg)
+#define IV_MSG_FATAL(fmt, arg...)      \
+       do { \
+               LOGE("[%s : %05d]" fmt "\n", __func__, __LINE__, ##arg); \
+       } while(0)
 
-#else /*IV_LOG_OUTPUT_DLOG*/
+#define IV_MSG_ERROR(fmt, arg...)      LOGE("[%s : %05d]" fmt "\n", __func__, __LINE__, ##arg)
+#define IV_MSG_HIGH(fmt, arg...)       LOGE("[%s : %05d]" fmt "\n", __func__, __LINE__, ##arg)
 
-#define iv_debug_msg(type, fmt,arg...) fprintf(stdout, "[%s: %d] [%s]" fmt "\n", __FILE__, __LINE__, __FUNCTION__, ##arg)
+#define IV_ASSERT(expr) \
+       do { \
+               if( !(expr) )                                   \
+               {                                                       \
+                       IV_MSG_FATAL("[%s] ASSERT : " #expr , __func__ );       \
+               } \
+       } while(0)
 
-#endif
 
 
-#  define iv_ret_if(expr) do { \
+#define iv_ret_if(expr) do { \
                 if(expr) { \
                         fprintf(stderr, "(%s) -> %s:%d() return\n", #expr, __func__, __LINE__); \
                         return; \
                 } \
         } while (0)
 
-#  define iv_retv_if(expr, val) do { \
+#define iv_retv_if(expr, val) do { \
                 if(expr) { \
                         fprintf(stderr, "(%s) -> %s():%d return\n", #expr, __func__, __LINE__); \
                         return (val); \
                 } \
         } while (0)
 
-typedef struct appdata_iv
-{
+typedef struct {
        int win_w;
        int win_h;
 
@@ -58,14 +60,14 @@ typedef struct appdata_iv
        Evas_Object* win_main;
        Evas_Object* ly_main;
 
-       struct ui_gadget *iv_ug;
+       Evas_Object* ug_layout;
+
+       ui_gadget_h iv_ug;
 
-       Evas_Object* iv_bg;
+       Evas_Object* bg;
        const char* iv_param_path;
-       const char* sort_type;
-       const char* view_mode;
-       const char* media_type;
-       const char* view_by;
+
+       service_h service_handle;
 
 } appdata_iv;
 
diff --git a/org.tizen.image-viewer.desktop.in b/org.tizen.image-viewer.desktop.in
deleted file mode 100755 (executable)
index e7ced77..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-Name=Image Viewer
-Type=Application
-Exec=${PREFIX}/bin/image-viewer
-Icon=org.tizen.image-viewer.png
-Nodisplay=True
-Version=0.1.0
-Comment=image viewer app 
-MimeType=image/jpeg;image/bmp;image/png;image/gif;image/vnd.wap.wbmp
-X-Tizen-TaskManage=True
-X-Tizen-Multiple=False
-X-Tizen-SVC=http://tizen.org/appsvc/operation/view|NULL|image/jpeg; http://tizen.org/appsvc/operation/view|NULL|image/bmp; http://tizen.org/appsvc/operation/view|NULL|image/png; http://tizen.org/appsvc/operation/view|NULL|image/gif; http://tizen.org/appsvc/operation/view|NULL|image/vnd.wap.wbmp; http://tizen.org/appsvc/operation/view|http|image/jpeg; http://tizen.org/appsvc/operation/view|http|image/bmp; http://tizen.org/appsvc/operation/view|http|image/png; http://tizen.org/appsvc/operation/view|http|image/gif; http://tizen.org/appsvc/operation/view|http|image/vnd.wap.wbmp;
-X-Tizen-Removable=False
diff --git a/org.tizen.image-viewer.png b/org.tizen.image-viewer.png
deleted file mode 100755 (executable)
index 1a0c715..0000000
Binary files a/org.tizen.image-viewer.png and /dev/null differ
diff --git a/packaging/changelog b/packaging/changelog
new file mode 100755 (executable)
index 0000000..6b303ee
--- /dev/null
@@ -0,0 +1,7 @@
+image-viewer (1.0.69) unstable; urgency=low
+
+  * update version
+  * Tag: image-viewer_1.0.69
+
+ -- root <jcastle.ahn@samsung.com>  Wed, 01 Aug 2012 19:58:39 +0900
+
index f13e1dc..c296518 100755 (executable)
@@ -1,21 +1,23 @@
 Name:       org.tizen.image-viewer
 Summary:    Image Viewer Application v1.0
-Version:    1.0
+Version:    1.0.69
 Release:    1
 Group:      misc
 License:    Flora Software License
+
 Source0:    %{name}-%{version}.tar.gz
-BuildRequires:  pkgconfig(appcore-efl)
 BuildRequires:  pkgconfig(elementary)
 BuildRequires:  pkgconfig(edje)
 BuildRequires:  pkgconfig(evas)
+BuildRequires:  pkgconfig(ecore)
+BuildRequires:  pkgconfig(ecore-x)
 BuildRequires:  pkgconfig(ecore-input)
-BuildRequires:  pkgconfig(ui-gadget)
-BuildRequires:  pkgconfig(aul)
+BuildRequires:  pkgconfig(sensor)
+BuildRequires:  pkgconfig(ui-gadget-1)
 BuildRequires:  pkgconfig(utilX)
-BuildRequires:  pkgconfig(appsvc)
 BuildRequires:  pkgconfig(vconf)
 BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(capi-appfw-application)
 
 BuildRequires:  cmake
 BuildRequires:  edje-bin
@@ -27,25 +29,24 @@ Image Viewer Application v1.0.
 
 
 %prep
-%setup -q
+%setup -q -n %{name}-%{version}
 
 
 %build
 
-cmake . -DCMAKE_INSTALL_PREFIX="/opt/apps/org.tizen.image-viewer" -DRESDIR="/opt/apps/org.tizen.image-viewer/res" -DDATADIR="/opt/apps/org.tizen.image-viewer/data"
+cmake . -DCMAKE_INSTALL_PREFIX="/opt/apps/org.tizen.image-viewer" -DRESDIR="/opt/apps/corg.tizen.image-viewer/res" -DDATADIR="/opt/apps/org.tizen.image-viewer/data"
 make %{?jobs:-j%jobs}
 
 %install
 rm -rf %{buildroot}
 %make_install
 
-mkdir -p %{buildroot}/opt/apps/org.tizen.image-viewer/data
 
-%post
-chown -R 5000:5000 /opt/apps/org.tizen.image-viewer/data
+
 
 %files
+%defattr(-,root,root,-)
 /opt/apps/org.tizen.image-viewer/bin/image-viewer
-/opt/apps/org.tizen.image-viewer/res/icons/default/small/org.tizen.image-viewer.png
-/opt/share/applications/org.tizen.image-viewer.desktop
-/opt/apps/org.tizen.image-viewer/data
+/opt/share/icons/default/small/org.tizen.image-viewer.png
+/opt/share/packages/org.tizen.image-viewer.xml
+
diff --git a/res/manifest/org.tizen.image-viewer.png b/res/manifest/org.tizen.image-viewer.png
new file mode 100755 (executable)
index 0000000..33d37ff
Binary files /dev/null and b/res/manifest/org.tizen.image-viewer.png differ
diff --git a/res/manifest/org.tizen.image-viewer.xml b/res/manifest/org.tizen.image-viewer.xml
new file mode 100755 (executable)
index 0000000..0864d33
--- /dev/null
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns="http://tizen.org/ns/packages" package="org.tizen.image-viewer" version="0.3.0-1" install-location="internal-only">
+       <label>org.tizen.image-viewer</label>
+       <author email="jcastle.ahn@samsung.com" href="www.samsung.com">Jisung Ahn</author>
+       <author email="hw4444.kim@samsung.com" href="www.samsung.com">Hyunwoo Kim</author>
+       <description>Image viewer Application</description>
+       <ui-application appid="org.tizen.image-viewer" exec="/opt/apps/org.tizen.image-viewer/bin/image-viewer" nodisplay="true" multiple="false" type="capp" taskmanage="true">
+               <icon>org.tizen.image-viewer.png</icon>
+               <label>Image viewer</label>
+               <label xml:lang="en-us">Image viewer</label>
+               <label xml:lang="nl-nl">Image viewer</label>
+               <label xml:lang="de-de">Image viewer</label>
+               <label xml:lang="zh-hk">Image viewer</label>
+               <label xml:lang="zh-cn">Image viewer</label>
+               <label xml:lang="ru-ru">Image viewer</label>
+               <label xml:lang="zh-tw">Image viewer</label>
+               <label xml:lang="ja-jp">画像​ビューア</label>
+               <label xml:lang="es-es">Image viewer</label>
+               <label xml:lang="el-gr">Image viewer</label>
+               <label xml:lang="it-it">Image viewer</label>
+               <label xml:lang="tr-tr">Image viewer</label>
+               <label xml:lang="pt-pt">Image viewer</label>
+               <label xml:lang="fr-fr">Image viewer</label>
+               <label xml:lang="ko-kr">이미지 뷰어</label>
+               <application-service>
+                       <operation name="http://tizen.org/appsvc/operation/view"/>
+                       <uri name="http"/>
+                       <uri name="https"/>
+                       <mime name="image/jpeg"/>
+                       <mime name="image/bmp"/>
+                       <mime name="image/png"/>
+                       <mime name="image/gif"/>
+                       <mime name="image/vnd.wap.wbmp"/>
+               </application-service>
+               <application-service>
+                       <operation name="http://tizen.org/appsvc/operation/view"/>
+                       <mime name="image/jpeg"/>
+                       <mime name="image/bmp"/>
+                       <mime name="image/png"/>
+                       <mime name="image/gif"/>
+                       <mime name="image/vnd.wap.wbmp"/>
+               </application-service>
+               <application-service>
+                       <operation name="http://tizen.org/appsvc/operation/crop"/>
+                       <mime name="image/jpeg"/>
+                       <mime name="image/bmp"/>
+                       <mime name="image/png"/>
+                       <mime name="image/gif"/>
+                       <mime name="image/vnd.wap.wbmp"/>
+               </application-service>
+       </ui-application>
+</manifest>
index b4c075e..e3681c1 100755 (executable)
  * limitations under the License.
  */
 
-
 #include <stdio.h>
+#include <stdbool.h>
+
 #include <Elementary.h>
-#include <appcore-efl.h>
-#include <appcore-common.h>
+#include <app.h>
+
 #include <utilX.h>
 #include <Evas.h>
 #include <Ecore_X.h>
 
 #include <ui-gadget-module.h>
 #include <ui-gadget.h>
-#include <aul.h>
-#include <appsvc.h>
-#include <stdbool.h>
+
 #include <vconf.h>
 #include <vconf-keys.h>
 
 #define PACKAGE "image-viewer"
 #define LOCALEDIR "/opt/apps/com.image-viewer/res/locale"
 
-#define UG_MODE_NORMAL "NORMAL"
 #define UG_MODE_SINGLE "SINGLE"
 #define UG_STANDALONE_VALUE "TRUE"
 
-void sample_cb(const char *k, const char *v, void *data)
-{
-       iv_debug_msg(MB_DEBUG_LOG,"%s -> %s", k, v);
-}
+#define UG_BUNDLE_KEY_VIEW_MODE                "View Mode"
+#define UG_BUNDLE_KEY_PATH                             "Path"
+#define UG_BUNDLE_KEY_SETAS_TYPE               "Setas type"
+#define UG_BUNDLE_KEY_STANDALONE               "Standalone"
 
+#define SERVICE_OPERATION_CROP "http://tizen.org/appsvc/operation/crop"
 
-static bool _parsing_bundle(bundle *b, void *data)
+static const char *_conver_error(int err)
 {
-       iv_retv_if(data == NULL, false);
-       iv_retv_if(b == NULL, false);
-
-       appdata_iv *ap = (appdata_iv *)data;
-
-       const char *uri = NULL;
-       const char *operation = appsvc_get_operation(b);
-       if(operation != NULL && strcmp(operation, APPSVC_OPERATION_VIEW) == 0)
+       switch(err)
        {
-               uri = appsvc_get_uri(b);
-               if(uri == NULL)
-               {
-                       iv_debug_msg(MB_DEBUG_LOG, "uri is NULL");
-                       return false;
-               }
-
-               ap->iv_param_path = uri;
-               ap->view_mode = appsvc_get_data(b, "View Mode");
-               ap->sort_type = appsvc_get_data(b, "Sort By");
-               ap->view_by = appsvc_get_data(b, "View By");
-               ap->media_type = appsvc_get_data(b, "Media type");
-
-               iv_debug_msg(MB_DEBUG_LOG,"*****************************");
-               iv_debug_msg(MB_DEBUG_LOG,"org.tizen.image-viewer : Case 1");
-               iv_debug_msg(MB_DEBUG_LOG,"  Operation : %s", operation);
-               iv_debug_msg(MB_DEBUG_LOG,"  URI path  : %s", ap->iv_param_path);
-               iv_debug_msg(MB_DEBUG_LOG,"  View Mode : %s", ap->view_mode);
-               iv_debug_msg(MB_DEBUG_LOG,"  Sort Type : %s", ap->sort_type);
-               iv_debug_msg(MB_DEBUG_LOG,"  View By   : %s", ap->view_by);
-               iv_debug_msg(MB_DEBUG_LOG,"  Media Type: %s", ap->media_type);
-               iv_debug_msg(MB_DEBUG_LOG,"*****************************");
-
-       }
-       else /* it is temp code, for backward compatability */
-       {
-               uri = bundle_get_val(b, AUL_K_MIME_CONTENT);
-               if(uri == NULL)
-               {
-                       iv_debug_msg(MB_DEBUG_LOG, "uri is NULL. %s", AUL_K_MIME_CONTENT);
-
-                       // iv_debug_msg(MB_DEBUG_LOG,"*****************************");
-
-                       // bundle_iterate(b, sample_cb, NULL);
-
-                       // iv_debug_msg(MB_DEBUG_LOG,"*****************************");
-
-                       if ( ap->iv_param_path == NULL )
-                       {
-                               iv_debug_msg(MB_DEBUG_LOG, "URI and Path is all empty. finish appl");
-                               return false;
-                       }
-               }
-               else
+               case SERVICE_ERROR_NONE:
+                       return "Successful";
+               case SERVICE_ERROR_INVALID_PARAMETER:
+                       return "Invalid parameter";
+               case SERVICE_ERROR_KEY_NOT_FOUND:
+                       return "Specified key not found";
+               case SERVICE_ERROR_OUT_OF_MEMORY:
+                       return "Out of memory";
+               case SERVICE_ERROR_INVALID_DATA_TYPE:
+                       return "Invalid data type";
+               default:
                {
-                       ap->iv_param_path = uri;
+                       static char error[128];
+                       sprintf(error, "Unknow Error : %d(0x%08x)", err, err);
+                       return error;
                }
-
-               ap->view_mode = bundle_get_val(b, "View Mode");
-               ap->sort_type = bundle_get_val(b, "Sort By");
-               ap->view_by = bundle_get_val(b, "View By");
-               ap->media_type = bundle_get_val(b, "Media type");
-
-               iv_debug_msg(MB_DEBUG_LOG,"*****************************");
-               iv_debug_msg(MB_DEBUG_LOG,"org.tizen.image-viewer : Case 2");
-               iv_debug_msg(MB_DEBUG_LOG,"  Operation : %s", operation);
-               iv_debug_msg(MB_DEBUG_LOG,"  URI path  : %s", ap->iv_param_path);
-               iv_debug_msg(MB_DEBUG_LOG,"  View Mode : %s", ap->view_mode);
-               iv_debug_msg(MB_DEBUG_LOG,"  Sort Type : %s", ap->sort_type);
-               iv_debug_msg(MB_DEBUG_LOG,"  View By   : %s", ap->view_by);
-               iv_debug_msg(MB_DEBUG_LOG,"  Media Type: %s", ap->media_type);
-               iv_debug_msg(MB_DEBUG_LOG,"*****************************");
-
        }
-       return true;
+       return NULL;
 }
 
-static void __back_cb(void *data);
+void _orient_changed(app_device_orientation_e orientation, void *user_data);
+
 
 /**
 * @brief       The win delete function
@@ -133,113 +79,20 @@ static void __back_cb(void *data);
 * @param obj
 * @param event_info
 */
-static void win_del(void *data, Evas_Object *obj, void *event_info)
+static void _win_del(void *data, Evas_Object *obj, void *event_info)
 {
        elm_exit();
 }
 
 
 /**
-* @brief       The hard key up exit callback
-*
-* @param data  The app data
-* @param type
-* @param event The event key
-*
-* @return      0
-*/
-static Eina_Bool _keydown_event(void *data, int type, void *event)
-{
-       iv_retv_if(data == NULL, ECORE_CALLBACK_CANCEL);
-
-       Ecore_Event_Key *ev = event;
-       appdata_iv *ad = (appdata_iv *)data;
-
-       if (!strcmp(ev->keyname, KEY_END))
-       {
-               iv_debug_msg(MB_DEBUG_LOG, "End Key DOWN");
-               if (ad->iv_ug)
-               {
-                       ug_destroy(ad->iv_ug);
-               }
-
-               elm_exit();
-       }
-
-       return ECORE_CALLBACK_RENEW;
-}
-
-/**
-* @brief       The hard key up exit callback
-*
-* @param data  The app data
-* @param type
-* @param event The event key
-*
-* @return      0
-*/
-static Eina_Bool _keyup_event(void *data, int type, void *event)
-{
-       Ecore_Event_Key *ev = event;
-
-       if (!strcmp(ev->keyname, KEY_END))
-       {
-               iv_debug_msg(MB_DEBUG_LOG, "End Key UP");
-       }
-
-       return ECORE_CALLBACK_RENEW;
-
-}
-
-
-/**
-* @brief The language change  callback
-*
-* @param data  The user data
-*
-* @return      0 on sucess
-*/
-static int lang_changed(void *data)
-{
-       ug_send_event( UG_EVENT_LANG_CHANGE );
-       return 0;
-}
-
-/**
-* @brief       The low batter callback
-*
-* @param data  The user data
-*
-* @return      0 on sucess
-*/
-static int low_battery_cb(void *data)
-{
-       ug_send_event( APPCORE_EVENT_LOW_BATTERY );
-       return 0;
-}
-
-/**
-* @brief       The low memory callback
-*
-* @param data  The user data
-*
-* @return      0 on sucess
-*/
-static int low_memory_cb(void *data)
-{
-       ug_send_event( APPCORE_EVENT_LOW_MEMORY );
-       return 0;
-}
-
-
-/**
 * @brief       Create the main window
 *
 * @param name  The title of the window
 *
 * @return  the win on sucess
 */
-static Evas_Object* create_win(const char *name)
+static Evas_Object* _create_win(const char *name)
 {
        iv_retv_if(name == NULL, NULL);
        Evas_Object *eo;
@@ -250,8 +103,7 @@ static Evas_Object* create_win(const char *name)
        {
                elm_win_title_set(eo, name);
                elm_win_borderless_set(eo, EINA_TRUE);
-               evas_object_smart_callback_add(eo, "delete,request",
-                               win_del, NULL);
+               evas_object_smart_callback_add(eo, "delete,request", _win_del, NULL);
                ecore_x_window_size_get(ecore_x_window_root_first_get(),
                                &w, &h);
                evas_object_resize(eo, w, h);
@@ -263,61 +115,21 @@ static Evas_Object* create_win(const char *name)
 /**
 * @brief Create the background
 *
-* @param ap    The app data
+* @param parent object
 */
-static void
-iv_ui_background_create(appdata_iv* ap)
-{
-       iv_ret_if(ap == NULL);
-       Evas_Object *black = NULL;
-       ap->iv_bg = black =  evas_object_rectangle_add(ap->evas);
-       evas_object_color_set(black, 0, 0, 0,255);
-       elm_win_resize_object_add(ap->win_main, ap->iv_bg);
-       evas_object_show(black);
-       evas_object_repeat_events_set(black, EINA_FALSE);
-}
-
-
-
-/**
-* @brief The back callback to destroy UG created
-*
-* @param data The app data
-*/
-static void __back_cb(void *data)
-{
-       iv_ret_if(data == NULL);
-       appdata_iv *ap = (appdata_iv *)data;
-
-       if(ap->iv_ug)
-       {
-               ug_destroy(ap->iv_ug);
-       }
-}
-
-static Evas_Object* load_edj(Evas_Object *parent, const char *file,
-               const char *group)
+static Evas_Object* _create_bgimg(Evas_Object* parent)
 {
-       Evas_Object *eo;
-       int r;
+       Evas_Object *bg = elm_bg_add(parent);
+       evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, EVAS_HINT_FILL);
 
-       eo = elm_layout_add(parent);
-       if (eo)
-       {
-               r = elm_layout_file_set(eo, file, group);
-               if (!r) {
-                       evas_object_del(eo);
-                       return NULL;
-               }
+       elm_win_resize_object_add(parent, bg);
 
-               evas_object_size_hint_weight_set(eo,
-                               EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-       }
+       evas_object_show(bg);
 
-       return eo;
+       return bg;
 }
 
-
 /**
 * @brief The layout callback after ug created
 *
@@ -325,33 +137,41 @@ static Evas_Object* load_edj(Evas_Object *parent, const char *file,
 * @param mode  The UG mode, FULLVIEW or FRAMEVIEW
 * @param priv  The privite data
 */
-void ug_layout_cb( struct ui_gadget *ug, enum ug_mode mode, void* priv)
+void _ug_layout_cb(ui_gadget_h ug, enum ug_mode mode, void* priv)
 {
+       IV_MSG_HIGH("ug Layout CB. UG=0x%08x Priv=0x%08x Mode=%d", ug, priv, mode);
+
        Evas_Object *base, *win;
 
        if (!ug || !priv)
        {
+               IV_MSG_ERROR("Abnormal value. UG=0x%08x Priv=0x%08x Mode=%d", ug, priv, mode);
                return;
        }
 
+       appdata_iv *ap = (appdata_iv *)priv;
+
        base = ug_get_layout(ug);
        if (!base)
        {
+               IV_MSG_HIGH( "ug_get_layout is fail");
                return;
        }
+       ap->ug_layout = base;
 
        win = ug_get_window();
 
-       switch (mode) {
-       case UG_MODE_FULLVIEW:
-               evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-               elm_win_resize_object_add(win, base);
-               ug_disable_effect(ug);
-               evas_object_show(base);
-               break;
-       default:
-               iv_debug_msg(MB_DEBUG_LOG, "Unknow UG mode : %d", mode);
-               break;
+       switch (mode)
+       {
+               case UG_MODE_FULLVIEW:
+                       evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+                       elm_win_resize_object_add(win, base);
+                       ug_disable_effect(ug);
+                       evas_object_show(base);
+                       break;
+               default:
+                       IV_MSG_HIGH("Unknow UG mode : %d", mode);
+                       break;
        }
 
 }
@@ -363,18 +183,23 @@ void ug_layout_cb( struct ui_gadget *ug, enum ug_mode mode, void* priv)
 * @param result        The result received from ug
 * @param priv  The privite data
 */
-void ug_return_cb( struct ui_gadget *ug, bundle *result, void *priv)
+void _ug_result_cb(ui_gadget_h ug, service_h reply, void *priv)
 {
-       appdata_iv *ap;
+       IV_MSG_HIGH("UG Result CB.");
 
        if (!ug || !priv)
        {
+               IV_MSG_ERROR("Abnormal value. UG=0x%08x Priv=0x%08x", ug, priv);
                return;
        }
-       ap = priv;
 
-       ug_destroy(ug);
-       ap->iv_ug = NULL;
+       appdata_iv *ap = (appdata_iv *)priv;
+
+       int ret = service_reply_to_launch_request(reply, ap->service_handle, SERVICE_RESULT_SUCCEEDED);
+       if (ret != SERVICE_ERROR_NONE)
+       {
+               IV_MSG_ERROR("service_reply_to_launch_request failed! [%s]", _conver_error(ret));
+       }
 }
 
 /**
@@ -383,14 +208,19 @@ void ug_return_cb( struct ui_gadget *ug, bundle *result, void *priv)
 * @param ug    The ug created
 * @param priv  The privite data
 */
-void ug_closed_cb( struct ui_gadget *ug, void *priv)
+void _ug_closed_cb(ui_gadget_h ug, void *priv)
 {
-       if(ug)
+       IV_MSG_HIGH("UG Destroyed..");
+
+       if (!ug || !priv)
        {
-               ug_destroy(ug);
+               IV_MSG_ERROR("Abnormal value. UG=0x%08x Priv=0x%08x", ug, priv);
+               return;
        }
 
-       elm_exit();
+       //appdata_iv *ap = (appdata_iv *)priv;
+
+       elm_exit();             // will tirgger app_terminated
 }
 
 /**
@@ -400,207 +230,406 @@ void ug_closed_cb( struct ui_gadget *ug, void *priv)
 *
 * @return  ug on sucess, NULL on fail
 */
-struct ui_gadget *create_ug(void* data)
+ui_gadget_h _create_ug(void* data)
 {
        iv_retv_if(data == NULL, NULL);
 
-       appdata_iv *ap = (struct appdata_iv *)data;
+       appdata_iv *ap = (appdata_iv *)data;
 
-       iv_debug_msg(MB_DEBUG_LOG, "");
-       if(!(ap->iv_param_path))
-       {
-               return NULL;
-       }
+       ui_gadget_h ug;
+       struct ug_cbs cbs = {0,};
 
-       struct ui_gadget *ug;
-       struct ug_cbs cbs;
-       memset(&cbs, 0x0, sizeof(struct ug_cbs));
+       cbs.layout_cb = _ug_layout_cb;
+       cbs.result_cb = _ug_result_cb;
+       cbs.destroy_cb = _ug_closed_cb;
+       cbs.priv = ap;
 
-       bundle *b;
+       ug = ug_create(NULL, "image-viewer-efl", UG_MODE_FULLVIEW, ap->service_handle, &cbs);
 
-       b = bundle_create();
-       if (!b)
+       IV_MSG_HIGH("UG Created!");
+       return ug;
+}
+
+static bool _is_rotation_lock(void)
+{
+       int lock = 0;
+       int ret = -1;
+
+       ret = vconf_get_bool(VCONFKEY_SETAPPL_ROTATE_LOCK_BOOL, &lock);
+
+       if ( ret != 0)  // Failed
        {
-               iv_debug_msg(MB_DEBUG_LOG, "Bundle create error!");
-               return NULL;
+               IV_MSG_HIGH( "Rotation locked state is [%d].", lock);
+               return false;
        }
 
-       if(ap->view_mode && strcmp(ap->view_mode, UG_MODE_NORMAL) == 0)
+       if ( lock == true)
        {
-               bundle_add(b, "View Mode", UG_MODE_NORMAL);
+               IV_MSG_HIGH("Rotation is locked");
+               return true;
        }
-       else
+
+       return false;
+}
+
+static void _on_portrait_lock_changed(keynode_t* node, void *user_data)
+{
+       IV_MSG_HIGH("State changed. %s=%d", vconf_keynode_get_name(node), vconf_keynode_get_bool(node));
+
+       if ( vconf_keynode_get_bool(node) == true )
        {
-               bundle_add(b, "View Mode", UG_MODE_SINGLE);
+               // When Set portrait lock, Set degree as 0.
+               _orient_changed(APP_DEVICE_ORIENTATION_0, user_data);
        }
+}
+
+static bool _app_create(void *user_data)
+{
+// Hook to take necessary actions before main event loop starts
+// Initialize UI resources and application's data
+// If this function returns true, the main loop of application starts
+// If this function returns false, the application is terminated
+       IV_ASSERT(user_data != NULL);
+
+       IV_MSG_HIGH("App Create");
+
+       elm_config_preferred_engine_set("opengl_x11");  //enabling the OpenGL as the backend of the EFL.
 
-       if(ap->sort_type)
+       appdata_iv *ap = (appdata_iv *) user_data;
+
+       Evas_Object *win = _create_win(PACKAGE);
+       if ( win == NULL )
        {
-               bundle_add(b, "Sort By", ap->sort_type);
+               IV_MSG_ERROR("Cannot create app. pkg=%s", PACKAGE);
+               return false;
        }
 
-       if(ap->view_by)
+       ap->win_main = win;
+
+       UG_INIT_EFL(ap->win_main, UG_OPT_INDICATOR_ENABLE);     // Init UG module
+
+       ap->bg = _create_bgimg(ap->win_main);
+       if ( ap->bg == NULL )
        {
-               bundle_add(b, "View By", ap->view_by);
+               IV_MSG_ERROR("Cannot create bg");
+               return false;
        }
 
-       if(ap->media_type)
+       int ret = -1;
+
+       ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_ROTATE_LOCK_BOOL, _on_portrait_lock_changed, user_data);
+       if ( ret == -1 )
        {
-               bundle_add(b, "Media type", ap->media_type);
+               IV_MSG_ERROR("Register %s is failed", VCONFKEY_SETAPPL_ROTATE_LOCK_BOOL);
+               return false;
        }
 
-       bundle_add(b, "Path", ap->iv_param_path);
+       _orient_changed(app_get_device_orientation(), user_data);               // Set initial degree
 
-       bundle_add(b, "Standalone", UG_STANDALONE_VALUE);
+       return true;
+}
 
-       cbs.layout_cb = ug_layout_cb;
-       cbs.result_cb = ug_return_cb;
-       cbs.destroy_cb = ug_closed_cb;
-       cbs.priv = ap;
+bool _iter_extra_data_cb(service_h service, const char *key, void *user_data)
+{
+       char *value = NULL;
 
-       ug = ug_create(NULL, "image-viewer-efl", UG_MODE_FULLVIEW, b, &cbs);
+       IV_MSG_HIGH("  Key=%s Value=%s", key, value);
 
-       bundle_free(b);
+       int ret = service_get_extra_data(service, key, &value);
+       if (ret != SERVICE_ERROR_NONE)
+       {
+               IV_MSG_ERROR("service_get_extra_data %s failed, [%s]", key, _conver_error(ret));
+               return false;
+       }
 
-       iv_debug_msg(MB_DEBUG_LOG, "");
-       return ug;
+       free(value);
+
+       return true;
 }
 
-/**
-* @brief Called before main loop
-*
-* @param data The user data
-*
-* @return      0 on sucess
-*/
-static int app_create(void *data)
+
+static void _app_service(service_h service, void *user_data)
 {
-       iv_retv_if(data == NULL, -1);
-       iv_debug_msg(MB_DEBUG_LOG, "");
-       appdata_iv *ap = (appdata_iv *) data;
+// How to get Alarm service????
+       appdata_iv *ap = (appdata_iv *)user_data;
 
-       Evas_Object *win = create_win(PACKAGE);
+       IV_MSG_HIGH("%s", __func__);
 
-       Evas_Object *ly;
-       iv_retv_if(win == NULL, -1);
+       char *operation = NULL;
+       char *uri = NULL;
 
-       ap->win_main = win;
+       int ret = service_get_operation(service, &operation);
+       if (ret != SERVICE_ERROR_NONE)
+       {
+               IV_MSG_ERROR("service_get_operation failed, [%s]", _conver_error(ret));
+               goto EXIT;
+       }
+
+       if ( operation == NULL )
+       {
+               IV_MSG_ERROR("Operation cannot be NULL.");
+               goto EXIT;
+       }
+
+       ret = service_foreach_extra_data(service, _iter_extra_data_cb, NULL);
+       if (ret != SERVICE_ERROR_NONE)
+       {
+               IV_MSG_ERROR("service_foreach_extra_data failed, [%s]", _conver_error(ret));
+               goto EXIT;
+       }
 
-       UG_INIT_EFL(ap->win_main, UG_OPT_INDICATOR_ENABLE);
+       ret = service_get_uri(service, &uri);
+       if (ret != SERVICE_ERROR_NONE)
+       {
+               IV_MSG_ERROR("service_get_uri failed, [%s]", _conver_error(ret));
+               goto EXIT;
+       }
 
-       lang_changed(ap);
+       IV_MSG_HIGH( "Operation=%s URI=%s", operation, uri);
 
-       /* add system event callback */
-       appcore_set_event_callback(APPCORE_EVENT_LANG_CHANGE, lang_changed, ap);
-       appcore_set_event_callback(APPCORE_EVENT_LOW_BATTERY, low_battery_cb, ap);
-       appcore_set_event_callback(APPCORE_EVENT_LOW_MEMORY, low_memory_cb, ap);
+       ret = service_clone(&ap->service_handle, service);
+       if (ret != SERVICE_ERROR_NONE)
+       {
+               IV_MSG_ERROR("service_clone failed, [%s]", _conver_error(ret));
+               goto EXIT;
+       }
 
-       ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, _keydown_event, ap);
-       ecore_event_handler_add(ECORE_EVENT_KEY_UP, _keyup_event, ap);
+       if( strcmp(operation, SERVICE_OPERATION_VIEW) == 0 || strcmp(operation, SERVICE_OPERATION_DEFAULT) == 0)
+       {
+               if(uri) // uri can entered through argv[1]
+               {
+                       ap->iv_param_path = uri;
+               }
+               if ( ap->iv_param_path == NULL )
+               {
+                       IV_MSG_ERROR("Entered path is NULL");
+                       goto EXIT;
+               }
 
-       return 0;
-}
+               IV_MSG_HIGH("*****************************");
+               IV_MSG_HIGH("com.samsung.image-viewer : Case View");
+               IV_MSG_HIGH("  URI path  : %s", ap->iv_param_path);
+               IV_MSG_HIGH("*****************************");
 
-/**
-* @brief Called after main loop, terminate the app
-*
-* @param data The user data
-*
-* @return      0 on sucess
-*/
-static int app_terminate(void *data)
-{
+               free(operation);
+       }
+       else if( strcmp(operation, SERVICE_OPERATION_CROP) == 0)
+       {
+               char *value = NULL;             // Will freed on terminate
+
+               if(uri) // uri can entered through argv[1]
+               {
+                       ap->iv_param_path = uri;
+               }
+               if ( ap->iv_param_path == NULL )
+               {
+                       IV_MSG_ERROR("Entered path is NULL");
+                       goto EXIT;
+               }
+
+               service_add_extra_data(ap->service_handle, UG_BUNDLE_KEY_VIEW_MODE, "SETAS");
+
+               service_get_extra_data(ap->service_handle, UG_BUNDLE_KEY_SETAS_TYPE, &value);
+               if(value == NULL)
+               {
+                       service_add_extra_data(ap->service_handle, UG_BUNDLE_KEY_SETAS_TYPE, "Crop");
+               }
+
+               IV_MSG_HIGH("*****************************");
+               IV_MSG_HIGH("com.samsung.image-viewer : Case Crop");
+               IV_MSG_HIGH("  URI path  : %s", ap->iv_param_path);
+               IV_MSG_HIGH("*****************************");
 
-       if(data)
+               free(operation);
+       }
+       else
        {
-               __back_cb(data);
+               IV_MSG_ERROR("Unknown operation. %s", operation);
+               free(operation);
+
+               if ( ap->iv_param_path == NULL )
+               {
+                       IV_MSG_ERROR("Entered path is NULL");
+                       goto EXIT;
+               }
        }
 
-       elm_exit();
+       if(ap->iv_param_path == NULL)
+       {
+               IV_MSG_ERROR("File path is NULL. cannot create UG");
+               goto EXIT;
+       }
+
+       elm_win_activate(ap->win_main);
+       evas_object_show(ap->win_main);
 
-       iv_debug_msg(MB_DEBUG_LOG, "exit");
+       if(ap->iv_ug != NULL)
+       {
+               // Create Previous UG if exist
+               IV_MSG_HIGH("Removing previous UG=0x%08x", ap->iv_ug);
+               ug_destroy(ap->iv_ug);
+               ap->iv_ug = NULL;
+       }
+
+       char *view_mode = NULL;
+       service_get_extra_data(ap->service_handle, UG_BUNDLE_KEY_VIEW_MODE, &view_mode);
+       if(view_mode == NULL)
+       {
+               service_add_extra_data(ap->service_handle, UG_BUNDLE_KEY_VIEW_MODE, UG_MODE_SINGLE);
+       }
+
+       service_add_extra_data(ap->service_handle, UG_BUNDLE_KEY_PATH, ap->iv_param_path);
+
+       service_add_extra_data(ap->service_handle, UG_BUNDLE_KEY_STANDALONE, UG_STANDALONE_VALUE);
+
+       ap->iv_ug = _create_ug(ap);
+       if(ap->iv_ug == NULL)
+       {
+               IV_MSG_HIGH("create_ug failed. Terminated");
+               elm_exit();
+               return;
+       }
+
+       return;
+
+EXIT:
+       if(ap->service_handle)
+               service_destroy(ap->service_handle);
+       ap->service_handle = NULL;
+       elm_exit();
+       return;
 
-       return 0;
 }
 
-/**
-* @brief Called when every window goes back
-*
-* @param data The user data
-*
-* @return      0 on sucess
-*/
-static int app_pause(void *data)
+
+void _app_pause(void *user_data)
 {
-       iv_debug_msg(MB_DEBUG_LOG, "");
+// Take necessary actions when application becomes invisible.
+       IV_MSG_HIGH("%s", __func__);
+
        ug_pause();
-       return -1;
 }
 
-/**
-* @brief Called when any window comes on top
-*
-* @param data  The user data
-*
-* @return      0 on sucess
-*/
-static int app_resume(void *data)
+void _app_resume(void *user_data)
 {
-       iv_debug_msg(MB_DEBUG_LOG, "");
+// Take necessary actions when application becomes visible.
+       IV_MSG_HIGH("%s", __func__);
 
        ug_resume();
-       return 0;
 }
 
-/**
-* @brief Called at the first idler and every relaunching
-*
-* @param b     The bundle param
-* @param data  The user data
-*
-* @return 0 on sucess
-*/
-static int app_reset(bundle *b, void *data)
+void _app_terminate(void *user_data)
 {
-       iv_retv_if(data == NULL, -1);
-       iv_debug_msg(MB_DEBUG_LOG, "");
+// Release all resources
+       IV_MSG_HIGH("%s", __func__);
 
-       appdata_iv *ap = (appdata_iv *)data;
+       appdata_iv *ap = (appdata_iv *)user_data;
 
-       if (ap->win_main)
-       {
-               elm_win_activate(ap->win_main);
-               evas_object_show(ap->win_main);
+       if(ap->service_handle) {
+               service_destroy(ap->service_handle);
+               ap->service_handle = NULL;
        }
 
-       bool ret = false;
+       if(ap->iv_ug)
+       {
+               ug_destroy(ap->iv_ug);
+               ap->iv_ug = NULL;
+       }
 
-       ret = _parsing_bundle(b, data);
-       if(ret == false)
+       if(ap->ug_layout)
        {
-               iv_debug_msg(MB_DEBUG_LOG, "Cannot lauch Image Viewer");
-               return 0;
+               evas_object_del(ap->ug_layout);
+               ap->ug_layout = NULL;
        }
 
-       if(ap->iv_ug != NULL)
+       IV_MSG_HIGH("%s terminated.", __func__);
+}
+
+void _region_changed(void *user_data)
+{
+       IV_MSG_HIGH("%s", __func__);
+       // Not used yet.
+}
+
+void _low_battery(void *user_data)
+{
+       IV_MSG_HIGH("%s", __func__);
+       ug_send_event( UG_EVENT_LOW_BATTERY );
+}
+
+void _low_memory(void *user_data)
+{
+       IV_MSG_HIGH("%s", __func__);
+       ug_send_event( UG_EVENT_LOW_MEMORY );
+
+}
+
+void _lang_changed(void *user_data)
+{
+       IV_MSG_HIGH("%s", __func__);
+       ug_send_event( UG_EVENT_LANG_CHANGE );
+
+}
+
+void _orient_changed(app_device_orientation_e orientation, void *user_data)
+{
+       IV_MSG_HIGH("%s. orientation=%d", __func__, orientation);
+
+/*
+       enum app_device_orientation_e
+
+       APP_DEVICE_ORIENTATION_0  The device is oriented in natural position
+
+       APP_DEVICE_ORIENTATION_90  The device's left side is at the top
+
+       APP_DEVICE_ORIENTATION_180      The device is upside down
+
+       APP_DEVICE_ORIENTATION_270      The device's right side is to the top
+
+*/
+       appdata_iv *ap = (appdata_iv *)user_data;
+
+       int degree = 0;
+       enum ug_event evt = UG_EVENT_NONE;
+
+       if ( _is_rotation_lock() == true )      // When rotatation lock is set, show application as portrate mode.
        {
-               // Create Previous UG if exist
-               iv_debug_msg(MB_DEBUG_LOG, "Removing previous UG=0x%08x", ap->iv_ug);
-               ug_destroy(ap->iv_ug);
-               ap->iv_ug = NULL;
+               orientation = APP_DEVICE_ORIENTATION_0;
        }
 
-       ap->iv_ug = create_ug(ap);
-       if(ap->iv_ug == NULL)
+       switch(orientation)
        {
-               iv_debug_msg(MB_DEBUG_LOG, "create_ug failed. Terminated");
-               elm_exit();
-               return ;
+       case APP_DEVICE_ORIENTATION_0:
+               degree = 0;
+               evt = UG_EVENT_ROTATE_PORTRAIT;
+               break;
+       case APP_DEVICE_ORIENTATION_90:
+               degree = 90;
+               evt = UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN;
+               break;
+
+       case APP_DEVICE_ORIENTATION_180:
+               degree = 180;
+               evt = UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN;
+               break;
+
+       case APP_DEVICE_ORIENTATION_270:
+               evt = UG_EVENT_ROTATE_LANDSCAPE;
+               degree = 270;
+               break;
        }
 
-       return 0;
+       ug_send_event( evt );
+
+//     IV_MSG_HIGH( "evt = %d, r = %d", evt, r);
+
+       if ( ap->win_main != NULL )
+       {
+               elm_win_rotation_with_resize_set(ap->win_main, degree);
+       }
 }
 
+
 /**
 * @brief The main function
 *
@@ -611,24 +640,41 @@ static int app_reset(bundle *b, void *data)
 */
 int main(int argc, char *argv[])
 {
-       struct appcore_ops ops = {
-               .create = app_create,
-               .terminate = app_terminate,
-               .pause = app_pause,
-               .resume = app_resume,
-               .reset = app_reset,
-       };
+       //setenv("ELM_ENGINE", "gl", 1); //changed to elm_config_preferred_engine_set("opengl_x11") at _app_create
+
+       appdata_iv ad = {0,};
+
+       app_event_callback_s event_callback = {0,};
 
-       appdata_iv ap;
+       event_callback.create = _app_create;
+       event_callback.terminate = _app_terminate;
+       event_callback.pause = _app_pause;
+       event_callback.resume = _app_resume;
+       event_callback.service = _app_service;
 
-       memset( &ap, 0x0, sizeof( appdata_iv ) );
-       ops.data = &ap;
+       event_callback.low_memory = _low_memory;
+       event_callback.low_battery = _low_battery;
+       event_callback.device_orientation = _orient_changed;    /* Rotate is not supported in FMRadio */
+       event_callback.language_changed = _lang_changed;                /* Currently, Application will terminated when change language */
+       event_callback.region_format_changed = NULL;
 
-       if ( argc == 2 )
+       if ( argc == 2 )                // For command line options.
        {
-               ap.iv_param_path = strdup(argv[1]);
+               IV_MSG_HIGH("Parsing from cmd line. file=%s", argv[1]);
+               ad.iv_param_path = strdup(argv[1]);
        }
 
-       return appcore_efl_main(PACKAGE, &argc, &argv, &ops);
+       int ret = APP_ERROR_NONE;
+
+       ret = app_efl_main(&argc, &argv, &event_callback, &ad);
+
+       if ( ret != APP_ERROR_NONE )
+       {
+               IV_MSG_ERROR("app_efl_main() is failed. err=%d", ret);
+               // Go through
+       }
+
+       return ret;
+
 }