tizen 2.3.1 release tizen_2.3.1 submit/tizen_2.3.1/20150915.073130 tizen_2.3.1_release
authorjk7744.park <jk7744.park@samsung.com>
Mon, 14 Sep 2015 12:55:43 +0000 (21:55 +0900)
committerjk7744.park <jk7744.park@samsung.com>
Mon, 14 Sep 2015 12:55:43 +0000 (21:55 +0900)
49 files changed:
CMakeLists.txt [new file with mode: 0644]
clock-viewer/CMakeLists.txt [new file with mode: 0644]
clock-viewer/LICENSE [new file with mode: 0644]
clock-viewer/data/CMakeLists.txt [new file with mode: 0644]
clock-viewer/data/clock-viewer.edc [new file with mode: 0644]
clock-viewer/data/default-clock-fallback.edc [new file with mode: 0644]
clock-viewer/include/clock-viewer-debug.h [new file with mode: 0644]
clock-viewer/include/clock-viewer-default-clock-fallback.h [new file with mode: 0644]
clock-viewer/include/clock-viewer-default-clock.h [new file with mode: 0644]
clock-viewer/include/clock-viewer-display.h [new file with mode: 0644]
clock-viewer/include/clock-viewer-feature.h [new file with mode: 0644]
clock-viewer/include/clock-viewer-minicontrol.h [new file with mode: 0644]
clock-viewer/include/clock-viewer-plugin.h [new file with mode: 0644]
clock-viewer/include/clock-viewer-util-alarm.h [new file with mode: 0644]
clock-viewer/include/clock-viewer-util-dbus.h [new file with mode: 0644]
clock-viewer/include/clock-viewer-util-pkginfo.h [new file with mode: 0644]
clock-viewer/include/clock-viewer-util-status.h [new file with mode: 0644]
clock-viewer/include/clock-viewer-util-winset.h [new file with mode: 0644]
clock-viewer/include/clock-viewer-widget.h [new file with mode: 0644]
clock-viewer/include/clock-viewer-window.h [new file with mode: 0644]
clock-viewer/include/clock-viewer.h [new file with mode: 0644]
clock-viewer/org.tizen.w-clock-viewer.manifest [new file with mode: 0644]
clock-viewer/org.tizen.w-clock-viewer.rule [new file with mode: 0644]
clock-viewer/org.tizen.w-clock-viewer.xml.in [new file with mode: 0644]
clock-viewer/src/clock-viewer-default-clock-fallback.c [new file with mode: 0644]
clock-viewer/src/clock-viewer-default-clock.c [new file with mode: 0644]
clock-viewer/src/clock-viewer-display.c [new file with mode: 0644]
clock-viewer/src/clock-viewer-main.c [new file with mode: 0644]
clock-viewer/src/clock-viewer-minicontrol.c [new file with mode: 0644]
clock-viewer/src/clock-viewer-plugin.c [new file with mode: 0644]
clock-viewer/src/clock-viewer-util-alarm.c [new file with mode: 0644]
clock-viewer/src/clock-viewer-util-dbus-emul.c [new file with mode: 0644]
clock-viewer/src/clock-viewer-util-dbus.c [new file with mode: 0644]
clock-viewer/src/clock-viewer-util-pkginfo.c [new file with mode: 0644]
clock-viewer/src/clock-viewer-util-status.c [new file with mode: 0644]
clock-viewer/src/clock-viewer-util-winset.c [new file with mode: 0644]
clock-viewer/src/clock-viewer-widget.c [new file with mode: 0644]
clock-viewer/src/clock-viewer-window.c [new file with mode: 0644]
clock-viewer/src/clock-viewer.c [new file with mode: 0644]
default-clock/CMakeLists.txt [new file with mode: 0644]
default-clock/data/CMakeLists.txt [new file with mode: 0644]
default-clock/data/alpm.edc [new file with mode: 0644]
default-clock/data/images/alpm_hands_hr.png [new file with mode: 0644]
default-clock/data/images/alpm_hands_min.png [new file with mode: 0644]
default-clock/include/alpm.h [new file with mode: 0644]
default-clock/include/clock-viewer-plugin.h [new file with mode: 0644]
default-clock/src/analog.c [new file with mode: 0644]
default-clock/src/digital.c [new file with mode: 0644]
packaging/org.tizen.w-clock-viewer.spec [new file with mode: 0644]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..13626f9
--- /dev/null
@@ -0,0 +1,4 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+ADD_SUBDIRECTORY(clock-viewer)
+ADD_SUBDIRECTORY(default-clock)
diff --git a/clock-viewer/CMakeLists.txt b/clock-viewer/CMakeLists.txt
new file mode 100644 (file)
index 0000000..b474ee3
--- /dev/null
@@ -0,0 +1,101 @@
+PROJECT(w-clock-viewer C)
+
+IF("${ARCH}" STREQUAL "arm")
+       OPTION(RUN_ON_DEVICE "Run on device" ON)
+       ADD_DEFINITIONS("-DRUN_ON_DEVICE")
+ELSE()
+       OPTION(RUN_ON_EMULATOR "Run on emulator" ON)
+       ADD_DEFINITIONS("-DRUN_ON_EMULATOR")
+ENDIF()
+MESSAGE("ARCH: ${ARCH}")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(PKGS REQUIRED
+       capi-appfw-application
+       capi-system-device
+       elementary
+       minicontrol-viewer
+       minicontrol-monitor
+       minicontrol-handler
+       widget_viewer_evas
+       widget_service
+       alarm-service
+       pkgmgr-info
+       vconf
+       dlog
+)
+
+SET(PACKAGE_NAME "org.tizen.${PROJECT_NAME}")
+SET(PREFIX "/usr/apps/${PACKAGE_NAME}")
+SET(BINDIR "${PREFIX}/bin")
+SET(RESDIR "${PREFIX}/res")
+SET(DATADIR "/opt${PREFIX}/data")
+SET(EDJEDIR "${RESDIR}/edje")
+
+REMOVE_DEFINITIONS("-DLOG_TAG")
+ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
+ADD_DEFINITIONS("-DPROJECT=\"${PROJECT_NAME}\"")
+ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE_NAME}\"")
+ADD_DEFINITIONS("-DVERSION=\"${VERSION}\"")
+ADD_DEFINITIONS("-DDATADIR=\"${DATADIR}\"")
+ADD_DEFINITIONS("-DRESDIR=\"${RESDIR}\"")
+ADD_DEFINITIONS("-DIMAGEDIR=\"${IMAGEDIR}\"")
+ADD_DEFINITIONS("-DEDJEDIR=\"${EDJEDIR}\"")
+ADD_DEFINITIONS("-DLOCALEDIR=\"${LOCALEDIR}\"")
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+       SET(CMAKE_BUILD_TYPE "Release")
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+
+FOREACH(flag ${PKGS_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+FOREACH(flag ${PKGS_ARM_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(PRIVATE_C_FLAGS "-I${CMAKE_CURRENT_SOURCE_DIR}/include")
+SET(CMAKE_C_FLAGS " ${PRIVATE_C_FLAGS} ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE ${ADD_VIEWER_CFLAGS}")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_C_FLAGS_RELEASE "-O2")
+
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+
+SET(EXTRA_LDFLAGS "-ldl")
+SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed")
+
+ADD_EXECUTABLE(${PROJECT_NAME}
+       src/clock-viewer-main.c
+       src/clock-viewer.c
+       src/clock-viewer-util-dbus.c
+       src/clock-viewer-util-pkginfo.c
+       src/clock-viewer-util-winset.c
+       src/clock-viewer-util-alarm.c
+       src/clock-viewer-display.c
+       src/clock-viewer-window.c
+       src/clock-viewer-minicontrol.c
+       src/clock-viewer-widget.c
+       src/clock-viewer-default-clock.c
+       src/clock-viewer-default-clock-fallback.c
+       src/clock-viewer-plugin.c
+)
+
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${PKGS_LDFLAGS} ${EXTRA_LDFLAGS} -lm  -Wl,--hash-style=both -Wl,--as-needed -pie )
+IF(RUN_ON_DEVICE)
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${PKGS_ARM_LDFLAGS} -lm)
+ENDIF()
+
+# Install
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR})
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE DESTINATION /usr/share/license RENAME ${PACKAGE_NAME})
+
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${PACKAGE_NAME}.xml.in ${CMAKE_BINARY_DIR}/${PACKAGE_NAME}.xml)
+INSTALL(FILES ${CMAKE_BINARY_DIR}/${PACKAGE_NAME}.xml DESTINATION /usr/share/packages)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PACKAGE_NAME}.rule DESTINATION /etc/smack/accesses.d)
+
+# data
+ADD_SUBDIRECTORY(data)
+
+# End of a file
diff --git a/clock-viewer/LICENSE b/clock-viewer/LICENSE
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/clock-viewer/data/CMakeLists.txt b/clock-viewer/data/CMakeLists.txt
new file mode 100644 (file)
index 0000000..5d417d2
--- /dev/null
@@ -0,0 +1,16 @@
+# install edj
+ADD_CUSTOM_TARGET(clock-viewer.edj
+               COMMAND edje_cc -id ${CMAKE_CURRENT_SOURCE_DIR}/images ${EDJE_CFLAGS}
+               ${CMAKE_CURRENT_SOURCE_DIR}/clock-viewer.edc clock-viewer.edj
+               DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/clock-viewer.edc
+)
+ADD_DEPENDENCIES(${PROJECT_NAME} clock-viewer.edj)
+ADD_CUSTOM_TARGET(default-clock-fallback.edj
+               COMMAND edje_cc -id ${CMAKE_CURRENT_SOURCE_DIR}/images ${EDJE_CFLAGS}
+               ${CMAKE_CURRENT_SOURCE_DIR}/default-clock-fallback.edc default-clock-fallback.edj
+               DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/default-clock-fallback.edc
+)
+ADD_DEPENDENCIES(${PROJECT_NAME} default-clock-fallback.edj)
+
+INSTALL(FILES clock-viewer.edj DESTINATION ${EDJEDIR})
+INSTALL(FILES default-clock-fallback.edj DESTINATION ${EDJEDIR})
diff --git a/clock-viewer/data/clock-viewer.edc b/clock-viewer/data/clock-viewer.edc
new file mode 100644 (file)
index 0000000..6654ff5
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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.
+ *
+ */
+
+#define IDLE_CLOCK_ALPM_STATE_CHANGE(title,state)\
+       program {\
+               signal: title.state;\
+               source: title;\
+               action: STATE_SET state 0.0;\
+               target: title;\
+       }
+
+collections {
+       group {
+               name: "layout_manual_clock_position";
+               parts {
+                       part {
+                               name: "bg";
+                               type: RECT;
+                               scale: 1;
+                               description {
+                                       state: "default" 0.0;
+                                       rel1 { relative: 0.0 0.0; }
+                                       rel2 { relative: 1.0 1.0; }
+                                       color: 0 0 0 255;
+                               }
+                       }
+                       part {
+                               name: "elm.swallow.body";
+                               type: SWALLOW;
+                               scale: 1;
+                               description {
+                                       state: "default" 0.0;
+                                       rel1 { relative: 0.0 0.0; to: "bg"; }
+                                       rel2 { relative: 1.0 1.0; to: "bg"; }
+                               }
+                               description {
+                                       state: "top" 0.0;
+                                       rel1 { relative: 0.0 -0.02; to: "bg"; }
+                                       rel2 { relative: 1.0 0.98; to: "bg"; }
+                               }
+                               description {
+                                       state: "right" 0.0;
+                                       rel1 { relative: 0.02 0.0; to: "bg"; }
+                                       rel2 { relative: 1.02 1.0; to: "bg"; }
+                               }
+                               description {
+                                       state: "bottom" 0.0;
+                                       rel1 { relative: 0.0 0.02; to: "bg"; }
+                                       rel2 { relative: 1.0 1.02; to: "bg"; }
+                               }
+                               description {
+                                       state: "left" 0.0;
+                                       rel1 { relative: -0.02 0.0; to: "bg"; }
+                                       rel2 { relative: 0.98 1.0; to: "bg"; }
+                               }
+                               description {
+                                       state: "topright" 0.0;
+                                       rel1 { relative: 0.02 -0.02; to: "bg"; }
+                                       rel2 { relative: 1.02 0.98; to: "bg"; }
+                               }
+                               description {
+                                       state: "bottomright" 0.0;
+                                       rel1 { relative: 0.02 0.02; to: "bg"; }
+                                       rel2 { relative: 1.02 1.02; to: "bg"; }
+                               }
+                               description {
+                                       state: "bottomleft" 0.0;
+                                       rel1 { relative: -0.02 0.02; to: "bg"; }
+                                       rel2 { relative: 0.98 1.02; to: "bg"; }
+                               }
+                               description {
+                                       state: "topleft" 0.0;
+                                       rel1 { relative: -0.02 -0.02; to: "bg"; }
+                                       rel2 { relative: 0.98 0.98; to: "bg"; }
+                               }
+                       }
+               }
+               programs {
+                       IDLE_CLOCK_ALPM_STATE_CHANGE(elm.swallow.body, default)
+                       IDLE_CLOCK_ALPM_STATE_CHANGE(elm.swallow.body, top)
+                       IDLE_CLOCK_ALPM_STATE_CHANGE(elm.swallow.body, right)
+                       IDLE_CLOCK_ALPM_STATE_CHANGE(elm.swallow.body, bottom)
+                       IDLE_CLOCK_ALPM_STATE_CHANGE(elm.swallow.body, left)
+                       IDLE_CLOCK_ALPM_STATE_CHANGE(elm.swallow.body, topright)
+                       IDLE_CLOCK_ALPM_STATE_CHANGE(elm.swallow.body, bottomright)
+                       IDLE_CLOCK_ALPM_STATE_CHANGE(elm.swallow.body, bottomleft)
+                       IDLE_CLOCK_ALPM_STATE_CHANGE(elm.swallow.body, topleft)
+               }
+       }
+}
+
diff --git a/clock-viewer/data/default-clock-fallback.edc b/clock-viewer/data/default-clock-fallback.edc
new file mode 100644 (file)
index 0000000..8a23ca2
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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.
+ *
+ */
+
+#define IDLE_CLOCK_ALPM_STATE_CHANGE(title,state)\
+       program {\
+               signal: title.state;\
+               source: title;\
+               action: STATE_SET state 0.0;\
+               target: title;\
+       }
+
+collections {
+       group {
+               name: "layout_clock_position";
+               parts {
+                       part {
+                               name: "bg";
+                               type: RECT;
+                               scale: 1;
+                               description {
+                                       state: "default" 0.0;
+                                       rel1 { relative: 0.0 0.0; }
+                                       rel2 { relative: 1.0 1.0; }
+                                       color: 0 0 0 255;
+                               }
+                       }
+                       part {
+                               name: "elm.swallow.body";
+                               type: SWALLOW;
+                               scale: 1;
+                               description {
+                                       state: "default" 0.0;
+                                       rel1 { relative: 0.0 15/480; to: "bg"; }
+                                       rel2 { relative: 1.0 121/480; to: "bg"; }
+                               }
+                               description {
+                                       state: "middle1" 0.0;
+                                       rel1 { relative: 0.0 58/480; to: "bg"; }
+                                       rel2 { relative: 1.0 164/480; to: "bg"; }
+                               }
+                               description {
+                                       state: "middle2" 0.0;
+                                       rel1 { relative: 0.0 101/480; to: "bg"; }
+                                       rel2 { relative: 1.0 207/480; to: "bg"; }
+                               }
+                               description {
+                                       state: "middle3" 0.0;
+                                       rel1 { relative: 0.0 144/480; to: "bg"; }
+                                       rel2 { relative: 1.0 250/480; to: "bg"; }
+                               }
+                               description {
+                                       state: "middle4" 0.0;
+                                       rel1 { relative: 0.0 187/480; to: "bg"; }
+                                       rel2 { relative: 1.0 293/480; to: "bg"; }
+                               }
+                               description {
+                                       state: "middle5" 0.0;
+                                       rel1 { relative: 0.0 230/480; to: "bg"; }
+                                       rel2 { relative: 1.0 336/480; to: "bg"; }
+                               }
+                               description {
+                                       state: "middle6" 0.0;
+                                       rel1 { relative: 0.0 273/480; to: "bg"; }
+                                       rel2 { relative: 1.0 379/480; to: "bg"; }
+                               }
+                               description {
+                                       state: "middle7" 0.0;
+                                       rel1 { relative: 0.0 316/480; to: "bg"; }
+                                       rel2 { relative: 1.0 422/480; to: "bg"; }
+                               }
+                               description {
+                                       state: "bottom" 0.0;
+                                       rel1 { relative: 0.0 359/480; to: "bg"; }
+                                       rel2 { relative: 1.0 465/480; to: "bg"; }
+                               }
+                       }
+               }
+               programs {
+                       IDLE_CLOCK_ALPM_STATE_CHANGE(elm.swallow.body, default)
+                       IDLE_CLOCK_ALPM_STATE_CHANGE(elm.swallow.body, middle1)
+                       IDLE_CLOCK_ALPM_STATE_CHANGE(elm.swallow.body, middle2)
+                       IDLE_CLOCK_ALPM_STATE_CHANGE(elm.swallow.body, middle3)
+                       IDLE_CLOCK_ALPM_STATE_CHANGE(elm.swallow.body, middle4)
+                       IDLE_CLOCK_ALPM_STATE_CHANGE(elm.swallow.body, middle5)
+                       IDLE_CLOCK_ALPM_STATE_CHANGE(elm.swallow.body, middle6)
+                       IDLE_CLOCK_ALPM_STATE_CHANGE(elm.swallow.body, middle7)
+                       IDLE_CLOCK_ALPM_STATE_CHANGE(elm.swallow.body, bottom)
+               }
+       }
+
+       group {
+               name: "layout_clock_tb";
+               styles {
+                       style {
+                               name: "textblock_digit_style2";
+                               base: "font=SamsungNeoNum-3T:style=Light font_size=78 color=#ffffff align=center style=shadow,bottom shadow_color=#00000088";
+                               tag:  "br" "\n";
+                               tag:  "hilight" "+ font_weight=Bold";
+                               tag:  "b" "+ font_weight=Bold";
+                               tag:  "tab" "\t";
+                       }
+               }
+
+               parts {
+                       part {
+                               name: "text.clock";
+                               type: TEXTBLOCK;
+                               scale: 1;
+                               description {
+                                       state: "default" 0.0;
+                                       rel1 { relative: 0.0 0.0; }
+                                       rel2 { relative: 1.0 1.0; }
+                                       fixed: 1 1;
+                                       visible: 1;
+                                       color: 255 255 255 255;
+                                       //align: 0.5 1.0;
+                                       text{
+                                               text: "";
+                                               style: "textblock_digit_style2";
+                                               align: 0.5 0.5;
+                                       }
+                               }
+                       }
+               }
+       }
+}
+
diff --git a/clock-viewer/include/clock-viewer-debug.h b/clock-viewer/include/clock-viewer-debug.h
new file mode 100644 (file)
index 0000000..335e01c
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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 __CLOCK_VIEWER_DEBUG_H__
+#define __CLOCK_VIEWER_DEBUG_H__
+
+#ifdef  LOG_TAG
+#undef  LOG_TAG
+#endif
+#define LOG_TAG "W_CLOCK_VIEWER"
+
+#include <dlog.h>
+
+#define _ERR(fmt, arg...)  LOGE(" "fmt, ##arg)
+#define _WARN(fmt, arg...) LOGW(" "fmt, ##arg)
+#define _DBG(fmt, arg...)  LOGD(" "fmt, ##arg)
+
+#define _SERR(fmt, arg...)  SECURE_LOGE(" "fmt, ##arg)
+#define _SWARN(fmt, arg...) SECURE_LOGW(" "fmt, ##arg)
+#define _SDBG(fmt, arg...)  SECURE_LOGD(" "fmt, ##arg)
+
+#endif /* __CLOCK_VIEWER_DEBUG_H__ */
diff --git a/clock-viewer/include/clock-viewer-default-clock-fallback.h b/clock-viewer/include/clock-viewer-default-clock-fallback.h
new file mode 100644 (file)
index 0000000..e3df50e
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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 __CLOCK_VIEWER_DEFAULT_CLOCK_FALLBACK_H__
+#define __CLOCK_VIEWER_DEFAULT_CLOCK_FALLBACK_H__
+
+#include <Elementary.h>
+
+#include "clock-viewer.h"
+
+/**
+ * @brief initialize fallback digital clock
+ *
+ * @param[in]  data    user data
+ * @param[in]  parent  it should be window evas object
+ * @return     CLOCK_VIEWER_SUCCESS if success, otherwise CLOCK_VIEWER_FAIL
+ */
+extern int clock_viewer_default_clock_fallback_init(void *data, Evas_Object *parent);
+
+/**
+ * @brief finalize fallback digital clock
+ *
+ * @param[in]  data    user data
+ * @return     CLOCK_VIEWER_SUCCESS if success, otherwise CLOCK_VIEWER_FAIL
+ */
+extern int clock_viewer_default_clock_fallback_fini(void *data);
+
+/**
+ * @brief update fallback digital clock
+ *
+ * @param[in]  data    user data
+ * @return     CLOCK_VIEWER_SUCCESS if success, otherwise CLOCK_VIEWER_FAIL
+ */
+extern int clock_viewer_default_clock_fallback_update(void *data);
+
+#endif /* __CLOCK_VIEWER_DEFAULT_CLOCK_FALLBACK_H__ */
diff --git a/clock-viewer/include/clock-viewer-default-clock.h b/clock-viewer/include/clock-viewer-default-clock.h
new file mode 100644 (file)
index 0000000..785af86
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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 __CLOCK_VIEWER_DEFAULT_CLOCK_H__
+#define __CLOCK_VIEWER_DEFAULT_CLOCK_H__
+
+#include <Elementary.h>
+
+#include "clock-viewer.h"
+
+/**
+ * @brief initialize default clock
+ *
+ * @param[in]  data    user data
+ * @param[in]  parent  it should be window evas object
+ * @param[in]  ambient_type    ambient clock type
+ * @return     CLOCK_VIEWER_SUCCESS if success, otherwise CLOCK_VIEWER_FAIL
+ */
+extern int clock_viewer_default_clock_init(void *data, Evas_Object *parent, clock_viewer_ambient_type ambient_type);
+
+/**
+ * @brief finalize default clock
+ *
+ * @param[in]  data    user data
+ * @return     CLOCK_VIEWER_SUCCESS if success, otherwise CLOCK_VIEWER_FAIL
+ */
+extern int clock_viewer_default_clock_fini(void *data);
+
+/**
+ * @brief pause default clock
+ *
+ * @param[in]  data    user data
+ * @return     CLOCK_VIEWER_SUCCESS if success, otherwise CLOCK_VIEWER_FAIL
+ */
+extern int clock_viewer_default_clock_pause(void *data);
+
+/**
+ * @brief resume default clock
+ *
+ * @param[in]  data    user data
+ * @return     CLOCK_VIEWER_SUCCESS if success, otherwise CLOCK_VIEWER_FAIL
+ */
+extern int clock_viewer_default_clock_resume(void *data);
+
+#endif /* __CLOCK_VIEWER_DEFAULT_CLOCK_H__ */
diff --git a/clock-viewer/include/clock-viewer-display.h b/clock-viewer/include/clock-viewer-display.h
new file mode 100644 (file)
index 0000000..2d90538
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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 __CLOCK_VIEWER_DISPLAY_H__
+#define __CLOCK_VIEWER_DISPLAY_H__
+
+enum
+{
+       CLOCK_VIEWER_DISPLAY_MODE_NONE = 0,
+       CLOCK_VIEWER_DISPLAY_MODE_RESUME,
+       CLOCK_VIEWER_DISPLAY_MODE_PAUSE,
+       CLOCK_VIEWER_DISPLAY_MODE_MAX,
+};
+
+extern void clock_viewer_display_set_dpms_mode(int mode);
+
+#endif /* __CLOCK_VIEWER_DISPLAY_H__ */
diff --git a/clock-viewer/include/clock-viewer-feature.h b/clock-viewer/include/clock-viewer-feature.h
new file mode 100644 (file)
index 0000000..5489d1e
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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 __CLOCK_VIEWER_FEATURE_H__
+#define __CLOCK_VIEWER_FEATURE_H__
+
+#ifndef PACKAGE
+#define PACKAGE "w-clock-viewer"
+#endif
+
+#ifndef EDJEDIR
+#define EDJEDIR        "/usr/apps/org.tizen.w-clock-viewer/res/edje"
+#endif
+
+/* for window */
+#define _CLOCK_VIEWER_FEATURE_ALPHA_WINDOW_    0
+
+/* for display */
+#define _CLOCK_VIEWER_FEATURE_DPMS_CALL_ENABLED_       0
+
+/* for preloaded watchface app */
+#define _CLOCK_VIEWER_FEATURE_VI_BY_HOMESCREEN_STATUS_ENABLED_ 1
+
+#endif /* __CLOCK_VIEWER_FEATURE_H__ */
diff --git a/clock-viewer/include/clock-viewer-minicontrol.h b/clock-viewer/include/clock-viewer-minicontrol.h
new file mode 100644 (file)
index 0000000..500035a
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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 __CLOCK_VIEWER_MINICONTROL_H__
+#define __CLOCK_VIEWER_MINICONTROL_H__
+
+#include "clock-viewer.h"
+
+extern void clock_viewer_minicontrol_init(void *data, Evas_Object *parent);
+extern void clock_viewer_minicontrol_fini(void *data);
+
+#endif /* __CLOCK_VIEWER_MINICONTROL_H__ */
diff --git a/clock-viewer/include/clock-viewer-plugin.h b/clock-viewer/include/clock-viewer-plugin.h
new file mode 100644 (file)
index 0000000..23b4319
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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 __CLOCK_VIEWER_PLUGIN_H__
+#define __CLOCK_VIEWER_PLUGIN_H__
+
+#include "clock-viewer.h"
+
+#ifndef ALPM_CLOCK_PLUGIN_MODULE_INIT_SYM
+#define ALPM_CLOCK_PLUGIN_MODULE_INIT_SYM "ALPM_CLOCK_PLUGIN_MODULE_INIT"
+#endif
+
+#ifndef ALPM_CLOCK_PLUGIN_MODULE_EXIT_SYM
+#define ALPM_CLOCK_PLUGIN_MODULE_EXIT_SYM "ALPM_CLOCK_PLUGIN_MODULE_EXIT"
+#endif
+
+#ifndef ALPM_CLOCK_PLUGIN_MODULE_LOCALE_UPDATE_SYM
+#define ALPM_CLOCK_PLUGIN_MODULE_LOCALE_UPDATE_SYM "ALPM_CLOCK_PLUGIN_MODULE_LOCALE_UPDATE"
+#endif
+
+#ifndef ALPM_CLOCK_PLUGIN_EXPORT_API
+#define ALPM_CLOCK_PLUGIN_EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+typedef struct _alpm_clock_plugin_module_ops
+{
+       /* struct modules is initialized by alpm-clock module. */
+       struct
+       {
+               int (*ui_runtime_plugin_init)(void *ops, void *data); /* data will be parent evas object */
+               int (*ui_runtime_plugin_deinit)(void *ops, void *data);
+               int (*ui_runtime_plugin_update_clock)(void *ops, void *data);
+               void *priv;
+       } modules;
+
+} alpm_clock_plugin_module_ops;
+
+/**
+ * @brief initialize plugin clock
+ *
+ * @param[in]  data    user data
+ * @param[in]  parent  it should be window evas object
+ * @param[in]  ambient_type    ambient clock type
+ * @return     CLOCK_VIEWER_SUCCESS if success, otherwise CLOCK_VIEWER_FAIL
+ */
+extern int clock_viewer_plugin_init(void *data, Evas_Object *parent, clock_viewer_ambient_type ambient_type);
+
+/**
+ * @brief finalize plugin clock
+ *
+ * @param[in]  data    user data
+ * @return     CLOCK_VIEWER_SUCCESS if success, otherwise CLOCK_VIEWER_FAIL
+ */
+extern int clock_viewer_plugin_fini(void *data);
+
+extern int clock_viewer_plugin_locale_update(void *data);
+
+/**
+ * @brief update plugin clock
+ *
+ * @param[in]  data    user data
+ * @return     CLOCK_VIEWER_SUCCESS if success, otherwise CLOCK_VIEWER_FAIL
+ */
+extern int clock_viewer_plugin_update(void *data);
+
+#endif /* __CLOCK_VIEWER_PLUGIN_H__ */
diff --git a/clock-viewer/include/clock-viewer-util-alarm.h b/clock-viewer/include/clock-viewer-util-alarm.h
new file mode 100644 (file)
index 0000000..af8a899
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * W Clock Viewer
+ *
+ * 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 __CLOCK_VIEWER_UTIL_ALARM_H__
+#define __CLOCK_VIEWER_UTIL_ALARM_H__
+
+#include <alarm.h>
+
+extern int clock_viewer_util_alarm_init(void);
+extern void clock_viewer_util_alarm_fini(void);
+
+extern alarm_id_t clock_viewer_util_alarm_add(time_t start, time_t interval, alarm_cb_t func, void *data);
+extern void clock_viewer_util_alarm_remove(alarm_id_t alarm_id);
+
+#endif /* __CLOCK_VIEWER_UTIL_ALARM_H__ */ 
diff --git a/clock-viewer/include/clock-viewer-util-dbus.h b/clock-viewer/include/clock-viewer-util-dbus.h
new file mode 100644 (file)
index 0000000..87310d4
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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 __CLOCK_VIEWER_UTIL_DBUS_H__
+#define __CLOCK_VIEWER_UTIL_DBUS_H__
+
+#include <E_DBus.h>
+
+#define DEVICED_PATH   "/Org/Tizen/System/DeviceD"
+#define DEVICED_INTERFACE      "org.tizen.system.deviced"
+
+#define DEVICED_DISPLAY_PATH   "/Org/Tizen/System/DeviceD/Display"
+#define DEVICED_DISPLAY_INTERFACE      "org.tizen.system.deviced.display"
+#define LCDON_SIGNAL_NAME      "LCDOn"
+#define LCDOFF_SIGNAL_NAME     "LCDOff"
+
+#define CLOCKDRAW_PATH "/Org/Tizen/Coreapps/Alpmviewer/Clockdraw"
+#define CLOCKDRAW_INTERFACE    "org.tizen.coreapps.alpmviewer.clockdraw"
+#define CLOCKDRAW_NAME "drawdone"
+
+extern void clock_viewer_util_dbus_broadcast_signal(void *data, char *path, char *interface, char *name, const char *type, char *signal[]);
+
+extern void clock_viewer_util_dbus_init_lcdoff_signal(void *data, E_DBus_Signal_Cb cb_signal);
+extern void clock_viewer_util_dbus_fini_lcdoff_signal(void *data);
+
+extern void clock_viewer_util_dbus_init_lcdon_signal(void *data, E_DBus_Signal_Cb cb_signal);
+extern void clock_viewer_util_dbus_fini_lcdon_signal(void *data);
+
+extern void clock_viewer_util_dbus_init_clockdraw_signal(void *data, E_DBus_Signal_Cb cb_signal);
+extern void clock_viewer_util_dbus_fini_clockdraw_signal(void *data);
+
+extern int clock_viewer_util_dbus_message_is_signal(DBusMessage *msg, const char *interface, const char *signal);
+
+#endif /* __CLOCK_VIEWER_UTIL_DBUS_H__ */
diff --git a/clock-viewer/include/clock-viewer-util-pkginfo.h b/clock-viewer/include/clock-viewer-util-pkginfo.h
new file mode 100644 (file)
index 0000000..31bfc3c
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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 __CLOCK_VIEWER_UTIL_PKGINFO_H__
+#define __CLOCK_VIEWER_UTIL_PKGINFO_H__
+
+#include <vconf.h>
+
+#include "clock-viewer.h"
+
+extern void clock_viewer_util_pkginfo_init_clock_package_event(void *data, vconf_callback_fn cb);
+extern void clock_viewer_util_pkginfo_fini_clock_package_event(vconf_callback_fn cb);
+
+extern char *clock_viewer_util_pkginfo_get_clock_package(void);
+
+extern clock_viewer_ambient_type clock_viewer_util_pkginfo_get_ambient_type(char *appid);
+
+extern int clock_viewer_util_pkginfo_is_widget(char *appid);
+
+#endif /* __CLOCK_VIEWER_UTIL_PKGINFO_H__ */
diff --git a/clock-viewer/include/clock-viewer-util-status.h b/clock-viewer/include/clock-viewer-util-status.h
new file mode 100644 (file)
index 0000000..9f76d20
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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 __CLOCK_VIEWER_UTIL_STATUS_H__
+#define __CLOCK_VIEWER_UTIL_STATUS_H__
+
+extern void clock_viewer_util_status_init(void);
+extern void clock_viewer_util_status_fini(void);
+
+extern int clock_viewer_util_status_get_reserved_apps_status(void);
+
+#endif /* __CLOCK_VIEWER_UTIL_STATUS_H__ */
diff --git a/clock-viewer/include/clock-viewer-util-winset.h b/clock-viewer/include/clock-viewer-util-winset.h
new file mode 100644 (file)
index 0000000..a773775
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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 __CLOCK_VIEWER_UTIL_WINSET_H__
+#define __CLOCK_VIEWER_UTIL_WINSET_H__
+
+#include <Elementary.h>
+
+#include "clock-viewer.h"
+
+/**
+ * @brief create background
+ *
+ * @param[in]  parent  parent evas object
+ * @return     bg if success, otherwise NULL
+ */
+
+extern Evas_Object *clock_viewer_util_winset_create_bg(Evas_Object *parent);
+
+/**
+ * @brief create layout
+ *
+ * @param[in]  parent  parent evas object
+ * @param[in]  file    edj file path
+ * @param[in]  group   group in edc
+ * @return     layout if success, otherwise NULL
+ */
+extern Evas_Object *clock_viewer_util_winset_create_layout(Evas_Object *parent, const char *file, const char *group);
+
+#endif /* __CLOCK_VIEWER_UTIL_WINSET_H__ */
diff --git a/clock-viewer/include/clock-viewer-widget.h b/clock-viewer/include/clock-viewer-widget.h
new file mode 100644 (file)
index 0000000..6c23053
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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 __CLOCK_VIEWER_WIDGET_H__
+#define __CLOCK_VIEWER_WIDGET_H__
+
+#include <Elementary.h>
+
+#include "clock-viewer.h"
+
+extern void clock_viewer_widget_init(void *data, Evas_Object *parent, char *pkgname);
+extern void clock_viewer_widget_fini(void *data);
+extern void clock_viewer_widget_pause(void);
+extern void clock_viewer_widget_resume(void);
+
+extern void clock_viewer_widget_update_position(void);
+
+extern void clock_viewer_widget_register_render_event(Evas_Smart_Cb func, void *data);
+extern void clock_viewer_widget_unregister_render_event(Evas_Smart_Cb func, void *data);
+
+#endif /* __CLOCK_VIEWER_WIDGET_H__ */
diff --git a/clock-viewer/include/clock-viewer-window.h b/clock-viewer/include/clock-viewer-window.h
new file mode 100644 (file)
index 0000000..c09ba2a
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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 __CLOCK_VIEWER_WINDOW_H__
+#define __CLOCK_VIEWER_WINDOW_H__
+
+#include "clock-viewer.h"
+
+extern Evas_Object *clock_viewer_window_create(void);
+extern void clock_viewer_window_destroy(Evas_Object *window);
+
+#endif /* __CLOCK_VIEWER_H__ */
diff --git a/clock-viewer/include/clock-viewer.h b/clock-viewer/include/clock-viewer.h
new file mode 100644 (file)
index 0000000..dee879d
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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 __CLOCK_VIEWER_H__
+#define __CLOCK_VIEWER_H__
+
+#include <Elementary.h>
+
+#include "clock-viewer-feature.h"
+#include "clock-viewer-debug.h"
+
+typedef enum _clock_viewer_type_e
+{
+       CLOCK_VIEWER_TYPE_NONE = 0,
+       CLOCK_VIEWER_TYPE_MINICTRL,
+       CLOCK_VIEWER_TYPE_WIDGET,
+       CLOCK_VIEWER_TYPE_DEFAULT_CLOCK,
+} clock_viewer_type_e;
+
+typedef enum _clock_viewer_ambient_type
+{
+       CLOCK_VIEWER_AMBIENT_TYPE_ANALOG = 1,
+       CLOCK_VIEWER_AMBIENT_TYPE_MANUAL,
+} clock_viewer_ambient_type;
+
+typedef enum _clock_viewer_pm_step_e
+{
+       CLOCK_VIEWER_PM_STEP_NONE = 0,
+       CLOCK_VIEWER_PM_STEP_CLOCKSTART,
+       CLOCK_VIEWER_PM_STEP_CLOCKEND,
+} clock_viewer_pm_step_e;
+
+typedef void (*clock_viewer_render_cb)(void *data, int type);
+
+typedef struct _clock_viewer_s
+{
+       Evas_Object *window;
+       Evas_Object *evas;
+
+       int win_width;
+       int win_height;
+
+       clock_viewer_type_e current_type;
+
+       // flag
+       clock_viewer_pm_step_e request_pm_status;
+       int is_lckoff;  // 0 : on 1 : off
+} clock_viewer_s;
+
+#define CLOCK_VIEWER_SUCCESS   1
+#define CLOCK_VIEWER_FAIL      0
+
+#define CLOCK_VIEWER_TIZEN_CLOCK_CATEGORY "http://tizen.org/category/wearable_clock"
+
+#define HAPI __attribute__((visibility("hidden")))
+
+extern void clock_viewer_create(clock_viewer_s *clock_viewer);
+extern void clock_viewer_destroy(clock_viewer_s *clock_viewer);
+
+extern void clock_viewer_resume(clock_viewer_s *clock_viewer);
+extern void clock_viewer_pause(clock_viewer_s *clock_viewer);
+
+extern void clock_viewer_show(clock_viewer_s *clock_viewer, int is_hide_launch);
+extern void clock_viewer_hide(clock_viewer_s *clock_viewer);
+
+#endif /* __CLOCK_VIEWER_H__ */
diff --git a/clock-viewer/org.tizen.w-clock-viewer.manifest b/clock-viewer/org.tizen.w-clock-viewer.manifest
new file mode 100644 (file)
index 0000000..98a54ac
--- /dev/null
@@ -0,0 +1,8 @@
+<manifest>
+    <define>
+        <domain name="org.tizen.w-clock-viewer"/>
+    </define>
+    <request>
+        <domain name="org.tizen.w-clock-viewer"/>
+    </request>
+</manifest>
diff --git a/clock-viewer/org.tizen.w-clock-viewer.rule b/clock-viewer/org.tizen.w-clock-viewer.rule
new file mode 100644 (file)
index 0000000..178521a
--- /dev/null
@@ -0,0 +1,59 @@
+org.tizen.w-clock-viewer system::use_internet r----- ------
+org.tizen.w-clock-viewer net-config r----- ------
+org.tizen.w-clock-viewer xorg rw---- ------
+org.tizen.w-clock-viewer isf rwx--- ------
+org.tizen.w-clock-viewer sound_server rw---- ------
+org.tizen.w-clock-viewer syspopup::db rw---- ------
+org.tizen.w-clock-viewer dbus rwx--- ------
+org.tizen.w-clock-viewer pulseaudio rwxat- ------
+org.tizen.w-clock-viewer ail::db rw---- ------
+org.tizen.w-clock-viewer connman r----- ------
+org.tizen.w-clock-viewer system rwx--- ------
+org.tizen.w-clock-viewer immvibed rw---- ------
+org.tizen.w-clock-viewer svi-data r-x--- ------
+org.tizen.w-clock-viewer e17 r-x--- ------
+org.tizen.w-clock-viewer deviced rwx--- ------
+org.tizen.w-clock-viewer deviced::display rw---- ------
+org.tizen.w-clock-viewer deviced::haptic rw---- ------
+org.tizen.w-clock-viewer data-provider-master::data --x--- ------
+org.tizen.w-clock-viewer data-provider-master::db rw---- ------
+org.tizen.w-clock-viewer data-provider-master::share rwxat- ------
+org.tizen.w-clock-viewer data-provider-master::client rw---- ------
+org.tizen.w-clock-viewer data-provider-master rw---- ------
+org.tizen.w-clock-viewer app-svc::db rw---- ------
+org.tizen.w-clock-viewer org.tizen.alarm rwx--- ------
+org.tizen.w-clock-viewer org.tizen.setting::system rwx--- ------
+org.tizen.w-clock-viewer org.tizen.wfmd rwx--- ------
+org.tizen.w-clock-viewer pkgmgr::db rwx--- ------
+org.tizen.w-clock-viewer pkgmgr-client r-x--- ------
+org.tizen.w-clock-viewer pkgmgr::svc r-x--- ------
+org.tizen.w-clock-viewer pkgmgr::info r----- ------
+org.tizen.w-clock-viewer efreet rwx--- ------
+org.tizen.w-clock-viewer org.tizen.clocksetting rwx--- ------
+org.tizen.w-clock-viewer org.tizen.clocksetting::default-resources r-x--- ------
+org.tizen.w-clock-viewer org.tizen.w-idle-clock-weather2 rwx--- ------
+org.tizen.w-clock-viewer org.tizen.idle-clock-pedometer rwx--- ------
+org.tizen.w-clock-viewer org.tizen.idle-clock-dual rwx--- ------
+org.tizen.w-clock-viewer org.tizen.idle-clock-digital rwx--- ------
+org.tizen.w-clock-viewer org.tizen.w-idle-clock-shortcut2 rwx--- ------
+org.tizen.w-clock-viewer org.tizen.idle-clock-style01 rwx--- ------
+org.tizen.w-clock-viewer org.tizen.idle-clock-style02 rwx--- ------
+org.tizen.w-clock-viewer org.tizen.idle-clock-style03 rwx--- ------
+org.tizen.w-clock-viewer org.tizen.idle-clock-style04 rwx--- ------
+org.tizen.w-clock-viewer org.tizen.idle-clock-style05 rwx--- ------
+org.tizen.w-clock-viewer org.tizen.idle-clock-style06 rwx--- ------
+org.tizen.w-clock-viewer org.tizen.idle-clock-style07 rwx--- ------
+org.tizen.w-clock-viewer org.tizen.idle-clock-style08 rwx--- ------
+org.tizen.w-clock-viewer org.tizen.idle-clock-style09 rwx--- ------
+org.tizen.w-clock-viewer org.tizen.idle-clock-style10 rwx--- ------
+org.tizen.w-clock-viewer org.tizen.alpm-clock-manager rwx--- ------
+org.tizen.w-clock-viewer tizen::vconf::setting::admin rw---- ------
+org.tizen.w-clock-viewer data-provider-master::badge rw---- ------
+org.tizen.w-clock-viewer data-provider-master::badge.client -w---- ------
+org.tizen.w-clock-viewer samsung::vconf::widget rw---- ------
+org.tizen.w-clock-viewer aul::launch --x--- ------
+org.tizen.w-clock-viewer aul::terminate --x--- ------
+org.tizen.w-clock-viewer alarm-server::alarm rw---l ------
+org.tizen.w-clock-viewer alarm-manager::alarm rw---l ------
+aul org.tizen.w-clock-viewer r-x--- ------
+dbus org.tizen.w-clock-viewer rwx--- ------
diff --git a/clock-viewer/org.tizen.w-clock-viewer.xml.in b/clock-viewer/org.tizen.w-clock-viewer.xml.in
new file mode 100644 (file)
index 0000000..cfd2c24
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns="http://tizen.org/ns/packages" package="@PACKAGE_NAME@" version="0.0.1" install-location="internal-only" support-mode="screen-reader">
+       <label>W-Clock-Viewer</label>
+       <description>W-Clock-Viewer Application</description>
+       <ui-application appid="@PACKAGE_NAME@" exec="@BINDIR@/@PROJECT_NAME@" nodisplay="true" multiple="false" type="capp" taskmanage="false" process-pool="false">
+               <label>w-clock-viewer</label>
+       </ui-application>
+       <privileges>
+               <privilege>http://tizen.org/privilege/setting</privilege>
+               <privilege>http://tizen.org/privilege/power</privilege>
+       </privileges>
+</manifest>
diff --git a/clock-viewer/src/clock-viewer-default-clock-fallback.c b/clock-viewer/src/clock-viewer-default-clock-fallback.c
new file mode 100644 (file)
index 0000000..b5186b6
--- /dev/null
@@ -0,0 +1,723 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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 <glib.h>
+#include <unicode/utypes.h>
+#include <unicode/putil.h>
+#include <unicode/uiter.h>
+#include <unicode/udat.h>
+#include <unicode/udatpg.h>
+#include <unicode/ustring.h>
+
+#include <vconf.h>
+
+#include "clock-viewer-util-winset.h"
+#include "clock-viewer-default-clock-fallback.h"
+
+#define EDJ_APP EDJEDIR"/default-clock-fallback.edj"
+#define MAX_VIEW_STATE 8
+
+static struct _default_clock_fallback_info
+{
+       Evas_Object *parent;    // window
+       Evas_Object *bg;
+       Evas_Object *position_layout;
+       Evas_Object *clock_layout;
+
+       Eina_Bool is_pre;
+
+       int timeformat;
+       char *timeregion_format;
+       char *timezone_id;
+
+       UDateTimePatternGenerator *generator;
+       UDateFormat *formatter_time;
+       UDateFormat *formatter_ampm;
+       UDateFormat *formatter_time_24;
+       UDateFormat *formatter_date;
+
+       int view_state;
+} s_default_clock_info = {
+       .parent = NULL,
+       .bg = NULL,
+       .position_layout = NULL,
+       .clock_layout = NULL,
+
+       .is_pre = 0,
+
+       .timeformat = 0,
+       .timeregion_format = NULL,
+       .timezone_id = NULL,
+
+       .generator = NULL,
+       .formatter_time = NULL,
+       .formatter_ampm = NULL,
+       .formatter_time_24 = NULL,
+       .formatter_date = NULL,
+
+       .view_state = -1,
+};
+
+static UChar *uastrcpy(const char *chars)
+{
+       int len = 0;
+       UChar *str = NULL;
+       len = strlen(chars);
+       str = (UChar *) malloc(sizeof(UChar) * (len + 1));
+       if (!str) {
+               return NULL;
+       }
+       u_uastrcpy(str, chars);
+       return str;
+}
+
+static char* _clock_viewer_default_clock_fallback_get_timezone(void)
+{
+       char buf[1024] = { 0, };
+       ssize_t len = readlink("/opt/etc/localtime", buf, sizeof(buf) - 1);
+
+       if (len != -1) {
+               buf[len] = '\0';
+       } else {
+               /* handle error condition */
+               _ERR("readlink() failed");
+               return vconf_get_str(VCONFKEY_SETAPPL_TIMEZONE_ID);
+       }
+
+       return strdup(buf + 20);
+}
+
+static char *_clock_viewer_default_clock_fallback_get_locale(void)
+{
+       char *locale = NULL;
+       char *str = NULL;
+       int count = 0;
+       gchar **ptr = NULL;
+       gchar **split_str = NULL;
+
+       locale = vconf_get_str(VCONFKEY_REGIONFORMAT);
+       if (!locale) {
+               _ERR("Failed to get region format");
+               return strdup("en_US");
+       }
+
+       split_str = g_strsplit(locale, ".", 0);
+
+       for (ptr = split_str; *ptr; ptr++) {
+               count++;
+       }
+
+       _DBG("count[%d] original locale[%s]", count, locale);
+
+       if (count == 2) {
+               if (!strcmp(split_str[1], "UTF-8")) {
+                       str = g_strdup_printf("%s", split_str[0]);
+                       free(locale);
+                       _DBG("dest locale[%s]", str);
+                       g_strfreev(split_str);
+                       return str;
+               } else {
+                       g_strfreev(split_str);
+                       return locale;
+               }
+       } else {
+               g_strfreev(split_str);
+               return locale;
+       }
+}
+
+static UDateTimePatternGenerator *_clock_viewer_default_clock_fallback_get_generator(void)
+{
+       UErrorCode status = U_ZERO_ERROR;
+       UDateTimePatternGenerator *generator = NULL;
+       UChar u_skeleton[64] = { 0, };
+
+       uloc_setDefault(getenv("LC_TIME"), &status);
+       if (U_FAILURE(status)) {
+               _ERR("Failed to set default");
+               return NULL;
+       }
+
+       u_uastrncpy(u_skeleton, "hhmm", strlen("hhmm"));
+
+       if (!s_default_clock_info.timeregion_format) {
+               s_default_clock_info.timeregion_format = _clock_viewer_default_clock_fallback_get_locale();
+       }
+
+       generator = udatpg_open(s_default_clock_info.timeregion_format, &status);
+       if (U_FAILURE(status)) {
+               _ERR("Failed to udatpg_open");
+               generator = NULL;
+               return NULL;
+       }
+
+       return generator;
+}
+
+static UDateFormat *_clock_viewer_default_clock_fallback_get_time_formatter(void)
+{
+       UErrorCode status = U_ZERO_ERROR;
+
+       UChar u_pattern[64] = { 0, };
+       UChar u_timezone[64] = { 0, };
+       UChar u_best_pattern[64] = { 0, };
+       int32_t u_best_pattern_capacity;
+       UDateFormat *formatter = NULL;
+
+       if (!s_default_clock_info.generator) {
+               s_default_clock_info.generator = _clock_viewer_default_clock_fallback_get_generator();
+       }
+
+       /* only 12 format */
+       if (u_uastrncpy(u_pattern, "h:mm", sizeof(u_pattern)) == NULL) {
+               _ERR("Failed to u_uastrncpy");
+               return NULL;
+       }
+
+       u_best_pattern_capacity = (int32_t) (sizeof(u_best_pattern) / sizeof((u_best_pattern)[0]));
+
+       udatpg_getBestPattern(s_default_clock_info.generator, u_pattern, u_strlen(u_pattern), u_best_pattern, u_best_pattern_capacity, &status);
+       if (U_FAILURE(status)) {
+               _ERR("Failed to udatpg_getBestPattern");
+               return NULL;
+       }
+
+       /* remove am/pm of best pattern */
+       char a_best_pattern[64] = { 0. };
+       char *buffer = NULL;
+       u_austrcpy(a_best_pattern, u_best_pattern);
+       char *a_best_pattern_fixed = strtok_r(a_best_pattern, "a", &buffer);
+       a_best_pattern_fixed = strtok_r(a_best_pattern_fixed, " ", &buffer);
+
+       _DBG("best pattern [%s] fixed [%s]", a_best_pattern, a_best_pattern_fixed);
+
+       if (a_best_pattern_fixed) {
+               /* exception - da_DK */
+               if (strncmp(s_default_clock_info.timeregion_format, "da_DK", 5) == 0 || strncmp(s_default_clock_info.timeregion_format, "mr_IN", 5) == 0) {
+                       char *a_best_pattern_changed = g_strndup("h:mm", 4);
+
+                       _DBG("best pattern is changed [%s]", a_best_pattern_changed);
+                       if (a_best_pattern_changed) {
+                               u_uastrcpy(u_best_pattern, a_best_pattern_changed);
+                               g_free(a_best_pattern_changed);
+                       }
+               } else {
+                       u_uastrcpy(u_best_pattern, a_best_pattern_fixed);
+               }
+       }
+
+       /* change char to UChar */
+       u_strncpy(u_pattern, u_best_pattern, sizeof(u_pattern));
+
+       /* get formatter */
+       u_uastrncpy(u_timezone, s_default_clock_info.timezone_id, sizeof(u_timezone));
+       formatter = udat_open(UDAT_IGNORE, UDAT_IGNORE, s_default_clock_info.timeregion_format, u_timezone, -1, u_pattern, -1, &status);
+       if (U_FAILURE(status)) {
+               _ERR("Failed to udat_open");
+               return NULL;
+       }
+
+       return formatter;
+}
+
+static UDateFormat *_clock_viewer_default_clock_fallback_get_time_formatter_24(void)
+{
+       UErrorCode status = U_ZERO_ERROR;
+
+       UChar u_pattern[64] = { 0, };
+       UChar u_timezone[64] = { 0, };
+       UChar u_best_pattern[64] = { 0, };
+       int32_t u_best_pattern_capacity;
+       UDateFormat *formatter = NULL;
+
+       if (!s_default_clock_info.generator) {
+               s_default_clock_info.generator = _clock_viewer_default_clock_fallback_get_generator();
+       }
+
+       /* only 12 format */
+       if (u_uastrncpy(u_pattern, "H:mm", sizeof(u_pattern)) == NULL) {
+               _ERR("Failed to u_uastrncpy");
+               return NULL;
+       }
+
+       u_best_pattern_capacity = (int32_t) (sizeof(u_best_pattern) / sizeof((u_best_pattern)[0]));
+
+       udatpg_getBestPattern(s_default_clock_info.generator, u_pattern, u_strlen(u_pattern), u_best_pattern, u_best_pattern_capacity, &status);
+       if (U_FAILURE(status)) {
+               _ERR("Failed to udatpg_getBestPattern");
+               return NULL;
+       }
+
+       /* remove am/pm of best pattern */
+       char a_best_pattern[64] = { 0. };
+       char *buffer = NULL;
+       u_austrcpy(a_best_pattern, u_best_pattern);
+       char *a_best_pattern_fixed = strtok_r(a_best_pattern, "a", &buffer);
+       a_best_pattern_fixed = strtok_r(a_best_pattern_fixed, " ", &buffer);
+
+       _DBG("best pattern [%s] fixed [%s]", a_best_pattern, a_best_pattern_fixed);
+
+       if (a_best_pattern_fixed) {
+               /* exception - pt_BR(HH'h'mm), id_ID, da_DK */
+               if (strncmp(a_best_pattern_fixed, "HH'h'mm", 7) == 0
+                               || strncmp(s_default_clock_info.timeregion_format, "id_ID", 5) == 0
+                               || strncmp(s_default_clock_info.timeregion_format, "da_DK", 5) == 0
+                               || strncmp(s_default_clock_info.timeregion_format, "mr_IN", 5) == 0)
+               {
+                       char *a_best_pattern_changed = g_strndup("HH:mm", 5);
+                       _DBG("best pattern is changed [%s]", a_best_pattern_changed);
+                       if (a_best_pattern_changed) {
+                               u_uastrcpy(u_best_pattern, a_best_pattern_changed);
+                               g_free(a_best_pattern_changed);
+                       }
+               } else {
+                       u_uastrcpy(u_best_pattern, a_best_pattern_fixed);
+               }
+       }
+
+       /* change char to UChar */
+       u_strncpy(u_pattern, u_best_pattern, sizeof(u_pattern));
+
+       /* get formatter */
+       u_uastrncpy(u_timezone, s_default_clock_info.timezone_id, sizeof(u_timezone));
+       formatter = udat_open(UDAT_IGNORE, UDAT_IGNORE, s_default_clock_info.timeregion_format, u_timezone, -1, u_pattern, -1, &status);
+       if (U_FAILURE(status)) {
+               _ERR("Failed to udat_open");
+               return NULL;
+       }
+
+       return formatter;
+}
+
+static UDateFormat *_clock_viewer_default_clock_fallback_get_date_formatter()
+{
+       UErrorCode status = U_ZERO_ERROR;
+       UChar u_timezone[64] = { 0, };
+       UChar u_skeleton[64] = { 0, };
+       int skeleton_len = 0;
+
+       UChar u_best_pattern[64] = { 0, };
+       int32_t u_best_pattern_capacity;
+       UDateFormat *formatter = NULL;
+
+       u_uastrncpy(u_skeleton, "MMMEd", strlen("MMMEd"));
+       skeleton_len = u_strlen(u_skeleton);
+
+       u_best_pattern_capacity = (int32_t) (sizeof(u_best_pattern) / sizeof((u_best_pattern)[0]));
+       udatpg_getBestPattern(s_default_clock_info.generator, u_skeleton, skeleton_len, u_best_pattern, u_best_pattern_capacity, &status);
+       if (U_FAILURE(status)) {
+               _ERR("Failed to udatpg_getBestPattern");
+               return NULL;
+       }
+
+       if (strncmp(s_default_clock_info.timeregion_format, "fi_FI", 5) == 0) {
+               char *a_best_pattern_changed = g_strndup("ccc, d. MMM", 11);
+               _DBG("date formatter best pattern is changed [%s]", a_best_pattern_changed);
+               if (a_best_pattern_changed) {
+                       u_uastrcpy(u_best_pattern, a_best_pattern_changed);
+                       g_free(a_best_pattern_changed);
+               }
+       }
+
+       /* get formatter */
+       u_uastrncpy(u_timezone, s_default_clock_info.timezone_id, sizeof(u_timezone));
+       formatter = udat_open(UDAT_IGNORE, UDAT_IGNORE, s_default_clock_info.timeregion_format, u_timezone, -1, u_best_pattern, -1, &status);
+       if (U_FAILURE(status)) {
+               _ERR("Failed to udat_open");
+               return NULL;
+       }
+
+       return formatter;
+}
+
+static UDateFormat *_clock_viewer_default_clock_fallback_get_ampm_formatter()
+{
+       UErrorCode status = U_ZERO_ERROR;
+
+       char a_best_pattern[64] = { 0. };
+
+       UChar u_timezone[64] = { 0, };
+       UChar u_skeleton[64] = { 0, };
+       int skeleton_len = 0;
+
+       UChar u_best_pattern[64] = { 0, };
+       int32_t u_best_pattern_capacity;
+       UDateFormat *formatter = NULL;
+
+       u_uastrncpy(u_skeleton, "hhmm", strlen("hhmm"));
+       skeleton_len = u_strlen(u_skeleton);
+
+       u_best_pattern_capacity = (int32_t) (sizeof(u_best_pattern) / sizeof((u_best_pattern)[0]));
+       udatpg_getBestPattern(s_default_clock_info.generator, u_skeleton, skeleton_len, u_best_pattern, u_best_pattern_capacity, &status);
+       if (U_FAILURE(status)) {
+               _ERR("Failed to udatpg_getBestPattern");
+               return NULL;
+       }
+
+       u_austrcpy(a_best_pattern, u_best_pattern);
+       u_uastrcpy(u_best_pattern, "a");
+
+       if (a_best_pattern[0] == 'a') {
+               s_default_clock_info.is_pre = EINA_TRUE;
+       } else {
+               s_default_clock_info.is_pre = EINA_FALSE;
+       }
+
+       /* get formatter */
+       u_uastrncpy(u_timezone, s_default_clock_info.timezone_id, sizeof(u_timezone));
+       formatter = udat_open(UDAT_IGNORE, UDAT_IGNORE, s_default_clock_info.timeregion_format, u_timezone, -1, u_best_pattern, -1, &status);
+       if (U_FAILURE(status)) {
+               _ERR("Failed to udat_open");
+               return NULL;
+       }
+
+       return formatter;
+}
+
+static void _clock_viewer_default_clock_fallback_set_icu_timezone(void)
+{
+       if (!s_default_clock_info.timezone_id) {
+               _ERR("Invalid timezone");
+               return;
+       }
+
+       UErrorCode ec = U_ZERO_ERROR;
+       UChar *str = uastrcpy(s_default_clock_info.timezone_id);
+       if (str) {
+               ucal_setDefaultTimeZone(str, &ec);
+               if (!U_SUCCESS(ec)) {
+                       _ERR("Failed set default timezone[%s]", u_errorName(ec));
+               }
+               free(str);
+       }
+}
+
+static void _clock_viewer_default_clock_fallback_set_formatters(void)
+{
+       s_default_clock_info.generator = _clock_viewer_default_clock_fallback_get_generator();
+       s_default_clock_info.formatter_time = _clock_viewer_default_clock_fallback_get_time_formatter();
+       s_default_clock_info.formatter_ampm = _clock_viewer_default_clock_fallback_get_ampm_formatter();
+       s_default_clock_info.formatter_time_24 = _clock_viewer_default_clock_fallback_get_time_formatter_24();
+       s_default_clock_info.formatter_date = _clock_viewer_default_clock_fallback_get_date_formatter();
+}
+
+static void _clock_viewer_default_clock_fallback_remove_formatters(void)
+{
+       if (s_default_clock_info.generator) {
+               udat_close(s_default_clock_info.generator);
+               s_default_clock_info.generator = NULL;
+       }
+
+       if (s_default_clock_info.formatter_time) {
+               udat_close(s_default_clock_info.formatter_time);
+               s_default_clock_info.formatter_time = NULL;
+       }
+
+       if (s_default_clock_info.formatter_ampm) {
+               udat_close(s_default_clock_info.formatter_ampm);
+               s_default_clock_info.formatter_ampm = NULL;
+       }
+
+       if (s_default_clock_info.formatter_time_24) {
+               udat_close(s_default_clock_info.formatter_time_24);
+               s_default_clock_info.formatter_time_24 = NULL;
+       }
+
+       if (s_default_clock_info.formatter_date) {
+               udat_close(s_default_clock_info.formatter_date);
+               s_default_clock_info.formatter_date = NULL;
+       }
+}
+
+static int _clock_viewer_default_clock_fallback_get_formatted_ampm_from_utc_time(void *data, time_t intime, char *buf, int buf_len, int *ampm_len)
+{
+       UDate u_time = (UDate) intime * 1000;
+       UChar u_formatted_str[64] = { 0, };
+       int32_t u_formatted_str_capacity;
+       int formatted_str_len = -1;
+       UErrorCode status = U_ZERO_ERROR;
+
+       /* calculate formatted string capacity */
+       u_formatted_str_capacity = (int32_t) (sizeof(u_formatted_str) / sizeof((u_formatted_str)[0]));
+
+       /* fomatting date using formatter */
+       formatted_str_len = udat_format(s_default_clock_info.formatter_ampm, u_time, u_formatted_str, u_formatted_str_capacity, NULL, &status);
+       if (U_FAILURE(status)) {
+               _ERR("Failed to udat_format");
+               return -1;
+       }
+
+       if (formatted_str_len <= 0) {
+               _ERR("formatted_str_len is less than 0");
+       }
+
+       (*ampm_len) = u_strlen(u_formatted_str);
+
+       buf = u_austrncpy(buf, u_formatted_str, buf_len);
+       _SDBG("ampm[%d][%s][%d]", formatted_str_len, buf, intime);
+
+       return 0;
+}
+
+static int _clock_viewer_default_clock_fallback_get_formatted_time_from_utc_time(void *data, time_t intime, char *buf, int buf_len, Eina_Bool is_time_24)
+{
+       UDate u_time = (UDate) intime * 1000;
+       UChar u_formatted_str[64] = { 0, };
+       int32_t u_formatted_str_capacity;
+       int formatted_str_len = -1;
+       UErrorCode status = U_ZERO_ERROR;
+
+       /* calculate formatted string capacity */
+       u_formatted_str_capacity = (int32_t) (sizeof(u_formatted_str) / sizeof((u_formatted_str)[0]));
+
+       /* fomatting date using formatter */
+       if (is_time_24) {
+               formatted_str_len = udat_format(s_default_clock_info.formatter_time_24, u_time, u_formatted_str, u_formatted_str_capacity, NULL, &status);
+       } else {
+               formatted_str_len = udat_format(s_default_clock_info.formatter_time, u_time, u_formatted_str, u_formatted_str_capacity, NULL, &status);
+       }
+
+       if (U_FAILURE(status)) {
+               _ERR("Failed to udat_format");
+               return -1;
+       }
+
+       if (formatted_str_len <= 0) {
+               _ERR("formatted_str_len is less than 0");
+       }
+
+       buf = u_austrncpy(buf, u_formatted_str, buf_len);
+       _SDBG("time[%d][%s][%d]", formatted_str_len, buf, intime);
+
+       return 0;
+}
+
+static void _clock_viewer_default_clock_fallback_set_view_state(void)
+{
+       if (++s_default_clock_info.view_state > MAX_VIEW_STATE) {
+               s_default_clock_info.view_state = 0;
+       }
+}
+
+static int _clock_viewer_default_clock_fallback_set_info_time()
+{
+       struct tm ts;
+       struct tm *ret_tm = NULL;
+       time_t tt;
+
+       tt = time(NULL);
+       ret_tm = localtime_r(&tt, &ts);
+
+       if (!ret_tm) {
+               _ERR("Failed to get the local time");
+               return CLOCK_VIEWER_FAIL;
+       }
+
+       // display position position
+       if (!s_default_clock_info.clock_layout) {
+               s_default_clock_info.clock_layout = clock_viewer_util_winset_create_layout(s_default_clock_info.position_layout, EDJ_APP, "layout_clock_tb");
+               if (!s_default_clock_info.clock_layout) {
+                       _ERR("Failed to create clock layout");
+                       return CLOCK_VIEWER_FAIL;
+               }
+
+               if (s_default_clock_info.position_layout) {
+                       elm_object_part_content_set(s_default_clock_info.position_layout, "elm.swallow.body", s_default_clock_info.clock_layout);
+               }
+       }
+
+       if (s_default_clock_info.view_state == 1) {
+               edje_object_signal_emit(elm_layout_edje_get(s_default_clock_info.position_layout), "elm.swallow.body.default", "elm.swallow.body");
+       } else if (s_default_clock_info.view_state == 2) {
+               edje_object_signal_emit(elm_layout_edje_get(s_default_clock_info.position_layout), "elm.swallow.body.middle1", "elm.swallow.body");
+       } else if (s_default_clock_info.view_state == 3) {
+               edje_object_signal_emit(elm_layout_edje_get(s_default_clock_info.position_layout), "elm.swallow.body.middle2", "elm.swallow.body");
+       } else if (s_default_clock_info.view_state == 4) {
+               edje_object_signal_emit(elm_layout_edje_get(s_default_clock_info.position_layout), "elm.swallow.body.middle3", "elm.swallow.body");
+       } else if (s_default_clock_info.view_state == 5) {
+               edje_object_signal_emit(elm_layout_edje_get(s_default_clock_info.position_layout), "elm.swallow.body.middle4", "elm.swallow.body");
+       } else if (s_default_clock_info.view_state == 6) {
+               edje_object_signal_emit(elm_layout_edje_get(s_default_clock_info.position_layout), "elm.swallow.body.middle5", "elm.swallow.body");
+       } else if (s_default_clock_info.view_state == 7) {
+               edje_object_signal_emit(elm_layout_edje_get(s_default_clock_info.position_layout), "elm.swallow.body.middle6", "elm.swallow.body");
+       } else if (s_default_clock_info.view_state == 8) {
+               edje_object_signal_emit(elm_layout_edje_get(s_default_clock_info.position_layout), "elm.swallow.body.middle7", "elm.swallow.body");
+       } else {
+               edje_object_signal_emit(elm_layout_edje_get(s_default_clock_info.position_layout), "elm.swallow.body.bottom", "elm.swallow.body");
+       }
+
+       edje_object_message_signal_process(elm_layout_edje_get(s_default_clock_info.position_layout));
+
+       char utc_time[256] = { 0 };
+       char utc_ampm[256] = { 0 };
+       int ampm_length = 0;
+       Eina_Bool is_24hour = EINA_FALSE;
+
+       if (s_default_clock_info.timeformat == VCONFKEY_TIME_FORMAT_12) {
+               _clock_viewer_default_clock_fallback_get_formatted_ampm_from_utc_time(NULL, tt, utc_ampm, sizeof(utc_ampm), &ampm_length);
+               _clock_viewer_default_clock_fallback_get_formatted_time_from_utc_time(NULL, tt, utc_time, sizeof(utc_time), EINA_FALSE);
+               is_24hour = EINA_FALSE;
+       } else {
+               _clock_viewer_default_clock_fallback_get_formatted_time_from_utc_time(NULL, tt, utc_time, sizeof(utc_time), EINA_TRUE);
+               is_24hour = EINA_TRUE;
+       }
+
+       _DBG("utc_time=%s, utc_ampm=[%d]%s", utc_time, ampm_length, utc_ampm);
+
+       if (ampm_length >= 3) {
+               _DBG("AM PM string is too long, changed to default AM/PM");
+
+               if (strncmp(s_default_clock_info.timeregion_format, "fa", 2) == 0) {
+                       _DBG("In Farsi, AM/PM text abbreviated.");
+
+                       if (ts.tm_hour >= 0 && ts.tm_hour < 12) {
+                               snprintf(utc_ampm, sizeof(utc_ampm), "%s", "ق.ظ");
+                       } else {
+                               snprintf(utc_ampm, sizeof(utc_ampm), "%s", "ب.ظ");
+                       }
+               } else {
+                       if (ts.tm_hour >= 0 && ts.tm_hour < 12)
+                               snprintf(utc_ampm, sizeof(utc_ampm), "%s", "AM");
+                       else
+                               snprintf(utc_ampm, sizeof(utc_ampm), "%s", "PM");
+               }
+       }
+
+       char *time_str = NULL;
+
+       if (is_24hour == EINA_TRUE) {
+               time_str = g_strdup_printf("%s", utc_time);
+       } else {
+               if (s_default_clock_info.is_pre == EINA_TRUE) {
+                       time_str = g_strdup_printf("<font_size=24><font=SamsungSans:style=Regular>%s</font></font_size>%s", utc_ampm, utc_time);
+               } else {
+                       time_str = g_strdup_printf("%s<font_size=24><font=SamsungSans:style=Regular> %s</font></font_size>", utc_time, utc_ampm);
+               }
+       }
+
+       _DBG("View state[%d] time[%s]", s_default_clock_info.view_state, time_str);
+
+       elm_object_part_text_set(s_default_clock_info.clock_layout, "text.clock", time_str);
+
+       g_free(time_str);
+
+       return CLOCK_VIEWER_SUCCESS;
+}
+
+HAPI int clock_viewer_default_clock_fallback_init(void *data, Evas_Object *parent)
+{
+       if (!parent) {
+               _ERR("invalid parent");
+               return CLOCK_VIEWER_FAIL;
+       }
+
+       s_default_clock_info.parent = parent;
+
+       // create bg
+       if (!s_default_clock_info.bg) {
+               s_default_clock_info.bg = clock_viewer_util_winset_create_bg(parent);
+               if (!s_default_clock_info.bg) {
+                       _ERR("Failed to create clock bg");
+                       return CLOCK_VIEWER_FAIL;
+               }
+
+               elm_win_resize_object_add(parent, s_default_clock_info.bg);
+       } else {
+               _DBG("default clock bg is already created");
+       }
+
+       // create position layout
+       if (!s_default_clock_info.position_layout) {
+               s_default_clock_info.position_layout = clock_viewer_util_winset_create_layout(s_default_clock_info.bg, EDJ_APP, "layout_clock_position");
+               if (!s_default_clock_info.position_layout) {
+                       _ERR("Failed to create clock position layout");
+                       return CLOCK_VIEWER_FAIL;
+               }
+
+               evas_object_size_hint_weight_set(s_default_clock_info.position_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+               elm_object_content_set(s_default_clock_info.bg, s_default_clock_info.position_layout);
+               evas_object_show(s_default_clock_info.position_layout);
+       } else {
+               _DBG("default clock layout is already created");
+       }
+
+       // TODO: need to notify these?
+       vconf_get_int(VCONFKEY_REGIONFORMAT_TIME1224, &s_default_clock_info.timeformat);
+       s_default_clock_info.timeregion_format = _clock_viewer_default_clock_fallback_get_locale();
+       s_default_clock_info.timezone_id = _clock_viewer_default_clock_fallback_get_timezone();
+
+       _DBG("[%d][%s][%s]", s_default_clock_info.timeformat, s_default_clock_info.timeregion_format, s_default_clock_info.timezone_id);
+
+       _clock_viewer_default_clock_fallback_set_icu_timezone();
+
+       _clock_viewer_default_clock_fallback_remove_formatters();
+       _clock_viewer_default_clock_fallback_set_formatters();
+
+       return CLOCK_VIEWER_SUCCESS;
+}
+
+HAPI int clock_viewer_default_clock_fallback_fini(void *data)
+{
+       if (s_default_clock_info.timeregion_format) {
+               free(s_default_clock_info.timeregion_format);
+       }
+
+       if (s_default_clock_info.timezone_id) {
+               free(s_default_clock_info.timezone_id);
+       }
+
+       _clock_viewer_default_clock_fallback_remove_formatters();
+
+       if (s_default_clock_info.clock_layout) {
+               evas_object_del(s_default_clock_info.clock_layout);
+               s_default_clock_info.clock_layout = NULL;
+       }
+
+       if (s_default_clock_info.position_layout) {
+               if (s_default_clock_info.bg) {
+                       Evas_Object *content = elm_object_content_get(s_default_clock_info.bg);
+                       if (content && content == s_default_clock_info.position_layout) {
+                               elm_object_content_unset(s_default_clock_info.bg);
+                       }
+               }
+
+               evas_object_del(s_default_clock_info.position_layout);
+               s_default_clock_info.position_layout = NULL;
+       }
+
+       if (s_default_clock_info.bg) {
+               if (s_default_clock_info.parent) {
+                       elm_win_resize_object_del(s_default_clock_info.parent, s_default_clock_info.bg);
+               }
+               evas_object_del(s_default_clock_info.bg);
+               s_default_clock_info.bg = NULL;
+       }
+
+       s_default_clock_info.parent = NULL;
+
+       return CLOCK_VIEWER_SUCCESS;
+}
+
+HAPI int clock_viewer_default_clock_fallback_update(void *data)
+{
+       _clock_viewer_default_clock_fallback_set_view_state();
+
+       return _clock_viewer_default_clock_fallback_set_info_time();
+}
diff --git a/clock-viewer/src/clock-viewer-default-clock.c b/clock-viewer/src/clock-viewer-default-clock.c
new file mode 100644 (file)
index 0000000..8966e38
--- /dev/null
@@ -0,0 +1,234 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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 <time.h>
+#include <vconf.h>
+
+#include "clock-viewer-default-clock.h"
+#include "clock-viewer-default-clock-fallback.h"
+#include "clock-viewer-plugin.h"
+#include "clock-viewer-util-alarm.h"
+
+static struct _default_clock_info {
+       Evas_Object *parent;
+
+       int is_fallback;
+       int is_alarm_init;
+       alarm_id_t alarm_id;
+
+       int is_event_registered;
+} s_default_clock_info = {
+       .parent = NULL,
+
+       .is_fallback = 0,
+       .is_alarm_init = 0,
+       .alarm_id = 0,
+
+       .is_event_registered = 0,
+};
+
+static int __clock_viewer_default_clock_alarm_cb(alarm_id_t alarm_id, void *user_param)
+{
+       int ret = 0;
+       _DBG("Alarm timer expired");
+
+       if (s_default_clock_info.is_fallback) {
+               ret = clock_viewer_default_clock_fallback_update(user_param);
+               if (!ret) {
+                       _ERR("Failed to update fallback");
+               }
+       } else {
+               ret = clock_viewer_plugin_update(user_param);
+               if (!ret) {
+                       _ERR("Failed to update plugin");
+               }
+       }
+
+       return 1;
+}
+
+static void __clock_viewer_default_clock_time_format_changed_cb(keynode_t *node, void *data)
+{
+       int ret = 0;
+       _DBG("time format changed");
+
+       if (!s_default_clock_info.is_fallback) {
+               ret = clock_viewer_plugin_locale_update(data);
+               if (!ret) {
+                       _ERR("Failed to locale update plugin");
+               }
+               ret = clock_viewer_plugin_update(data);
+               if (!ret) {
+                       _ERR("Failed to update plugin");
+               }
+       }
+}
+
+HAPI int clock_viewer_default_clock_init(void *data, Evas_Object *parent, clock_viewer_ambient_type ambient_type)
+{
+       int ret = 0;
+
+       // display default clock
+       ret = clock_viewer_plugin_init(data, parent, ambient_type);
+       if (ret) {
+               _DBG("Success to load plugin");
+               s_default_clock_info.is_fallback = 0;
+       } else {
+               _DBG("Failed to load plugin. Go fallback");
+               ret = clock_viewer_default_clock_fallback_init(data, parent);
+               if (ret) {
+                       s_default_clock_info.is_fallback = 1;
+               } else {
+                       _ERR("Failed to load fallback");
+                       return CLOCK_VIEWER_FAIL;
+               }
+       }
+
+       // init alarm manager
+       if (!s_default_clock_info.is_alarm_init) {
+               ret = clock_viewer_util_alarm_init();
+               if (ret != CLOCK_VIEWER_SUCCESS) {
+                       _ERR("Failed to init alarm[%d]", ret);
+                       s_default_clock_info.is_alarm_init = 0;
+               } else {
+                       s_default_clock_info.is_alarm_init = 1;
+               }
+       } else {
+               _DBG("Alarm is already initialized");
+       }
+
+       // register locale changed event
+       if (!s_default_clock_info.is_event_registered) {
+               ret = vconf_notify_key_changed(VCONFKEY_SYSTEM_TIME_CHANGED, __clock_viewer_default_clock_time_format_changed_cb, data);
+               if (ret != 0) {
+                       _ERR("Failed to notify system time changed event[%d]", ret);
+               }
+               ret = vconf_notify_key_changed(VCONFKEY_REGIONFORMAT_TIME1224, __clock_viewer_default_clock_time_format_changed_cb, data);
+               if (ret != 0) {
+                       _ERR("Failed to notify region format time1224 event[%d]", ret);
+               }
+               s_default_clock_info.is_event_registered = 1;
+       }
+
+       return CLOCK_VIEWER_SUCCESS;
+}
+
+HAPI int clock_viewer_default_clock_fini(void *data)
+{
+       int ret = 0;
+
+       if (s_default_clock_info.is_event_registered) {
+               ret = vconf_ignore_key_changed(VCONFKEY_SYSTEM_TIME_CHANGED, __clock_viewer_default_clock_time_format_changed_cb);
+               if (ret != 0) {
+                       _ERR("Failed to ignore system time changed event[%d]", ret);
+               }
+               ret = vconf_ignore_key_changed(VCONFKEY_REGIONFORMAT_TIME1224, __clock_viewer_default_clock_time_format_changed_cb);
+               if (ret != 0) {
+                       _ERR("Failed to ignore region format time1224 event[%d]", ret);
+               }
+               s_default_clock_info.is_event_registered = 0;
+       }
+
+       // delete default clock
+       if (s_default_clock_info.is_fallback) {
+               ret = clock_viewer_default_clock_fallback_fini(data);
+               if (!ret) {
+                       _ERR("Failed to finalize fallback");
+               }
+       } else {
+               ret = clock_viewer_plugin_fini(data);
+               if (!ret) {
+                       _ERR("Failed to finalize plugin");
+               }
+       }
+
+       s_default_clock_info.is_fallback = 0;
+
+       // remove remain alarm
+       if (s_default_clock_info.alarm_id) {
+               _DBG("Delete alarm id[%d] by terminate", s_default_clock_info.alarm_id);
+               clock_viewer_util_alarm_remove(s_default_clock_info.alarm_id);
+               s_default_clock_info.alarm_id = 0;
+       }
+
+       // fini alarm manager
+       if (s_default_clock_info.is_alarm_init) {
+               clock_viewer_util_alarm_fini();
+               s_default_clock_info.is_alarm_init = 0;
+       }
+
+       return CLOCK_VIEWER_SUCCESS;
+}
+
+HAPI int clock_viewer_default_clock_pause(void *data)
+{
+       if (s_default_clock_info.alarm_id) {
+               _DBG("Delete alarm id[%d] by pause", s_default_clock_info.alarm_id);
+               clock_viewer_util_alarm_remove(s_default_clock_info.alarm_id);
+               s_default_clock_info.alarm_id = 0;
+       }
+
+       return CLOCK_VIEWER_SUCCESS;
+}
+
+HAPI int clock_viewer_default_clock_resume(void *data)
+{
+       int ret = 0;
+       struct tm ts;
+       struct tm *ret_tm = NULL;
+       time_t tt;
+
+       tt = time(NULL);
+       ret_tm = localtime_r(&tt, &ts);
+
+       if (!ret_tm) {
+               _ERR("Failed to get the local time");
+               return CLOCK_VIEWER_FAIL;
+       }
+
+       time_t start = 60 - ts.tm_sec;
+       time_t interval = 60;
+
+       if (s_default_clock_info.alarm_id) {
+               _DBG("Delete alarm id[%d] by resume", s_default_clock_info.alarm_id);
+               clock_viewer_util_alarm_remove(s_default_clock_info.alarm_id);
+               s_default_clock_info.alarm_id = 0;
+       }
+
+       _DBG("Add alarm start[%d], interval[%d]", start, interval);
+
+       s_default_clock_info.alarm_id = clock_viewer_util_alarm_add(start, interval, __clock_viewer_default_clock_alarm_cb, data);
+       if (s_default_clock_info.alarm_id == 0) {
+               _ERR("Failed to add alarm[%d]", ret);
+       }
+
+       if (s_default_clock_info.is_fallback) {
+               ret = clock_viewer_default_clock_fallback_update(data);
+               if (!ret) {
+                       _ERR("Failed to update fallback");
+               }
+       } else {
+               ret = clock_viewer_plugin_update(data);
+               if (!ret) {
+                       _ERR("Failed to update plugin");
+               }
+       }
+
+       return CLOCK_VIEWER_SUCCESS;
+}
diff --git a/clock-viewer/src/clock-viewer-display.c b/clock-viewer/src/clock-viewer-display.c
new file mode 100644 (file)
index 0000000..fd04e4f
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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 "clock-viewer.h"
+#include "clock-viewer-display.h"
+
+static struct _display_info {
+       int mode;
+} s_display_info = {
+       .mode = CLOCK_VIEWER_DISPLAY_MODE_NONE,
+};
+
+static void _clock_viewer_display_resume_dpms_mode()
+{
+       /**
+        * @TODO Set DPMS Mode to Standby
+        */
+       LOGE("Change the DPMS Mode to Standby");
+}
+
+static void _clock_viewer_display_pause_dpms_mode()
+{
+       /**
+        * @TODO Set DEPMS Mode to Suspend
+        */
+       LOGE("Change the DPMS Mode to Suspend");
+}
+
+HAPI void clock_viewer_display_set_dpms_mode(int mode)
+{
+       _DBG("Change dpms mode [%d] -> [%d]", s_display_info.mode, mode);
+
+       switch (mode) {
+       case CLOCK_VIEWER_DISPLAY_MODE_NONE:
+               if (s_display_info.mode == CLOCK_VIEWER_DISPLAY_MODE_RESUME) {
+                       _clock_viewer_display_pause_dpms_mode();
+               }
+               s_display_info.mode = mode;
+               break;
+       case CLOCK_VIEWER_DISPLAY_MODE_RESUME:
+               if (s_display_info.mode == CLOCK_VIEWER_DISPLAY_MODE_NONE || s_display_info.mode == CLOCK_VIEWER_DISPLAY_MODE_PAUSE) {
+                       _clock_viewer_display_resume_dpms_mode();
+               }
+               s_display_info.mode = mode;
+               break;
+       case CLOCK_VIEWER_DISPLAY_MODE_PAUSE:
+               if (s_display_info.mode == CLOCK_VIEWER_DISPLAY_MODE_RESUME) {
+                       // it may need to lazy pause
+                       _clock_viewer_display_pause_dpms_mode();
+               }
+               s_display_info.mode = mode;
+               break;
+       default:
+               _ERR("invalid mode");
+               break;
+       }
+}
diff --git a/clock-viewer/src/clock-viewer-main.c b/clock-viewer/src/clock-viewer-main.c
new file mode 100644 (file)
index 0000000..5dc31a8
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ *  W Clock Viewer
+ *
+ * Copyright (c) 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 <stdio.h>
+
+#include <app.h>
+
+#include "clock-viewer.h"
+
+static bool _app_create(void *data)
+{
+       _DBG("");
+
+       clock_viewer_s *clock_viewer = (clock_viewer_s *) data;
+       if (!clock_viewer) {
+               _ERR("invalid app data");
+               return false;
+       }
+
+       clock_viewer_create(clock_viewer);
+
+       return true;
+}
+
+static void _app_terminate(void *data)
+{
+       _DBG("");
+
+       clock_viewer_s *clock_viewer = (clock_viewer_s *) data;
+       if (!clock_viewer) {
+               _ERR("invalid app data");
+               return;
+       }
+
+       clock_viewer_destroy(clock_viewer);
+       free(clock_viewer);
+}
+
+static void _app_pause(void *data)
+{
+       _DBG("");
+
+       clock_viewer_pause(data);
+}
+
+static void _app_resume(void *data)
+{
+       _DBG("");
+
+       clock_viewer_resume(data);
+}
+
+static void _app_control(app_control_h service, void *data)
+{
+       _DBG("");
+}
+
+int main(int argc, char *argv[])
+{
+       clock_viewer_s *clock_viewer = NULL;
+       clock_viewer = (clock_viewer_s *) malloc(sizeof(clock_viewer_s));
+       if (clock_viewer) {
+               memset(clock_viewer, 0x00, sizeof(clock_viewer_s));
+       } else {
+               _ERR("Failed to create app data");
+       }
+
+       app_event_callback_s event_callback;
+
+       event_callback.create = _app_create;
+       event_callback.terminate = _app_terminate;
+       event_callback.pause = _app_pause;
+       event_callback.resume = _app_resume;
+       event_callback.app_control = _app_control;
+       event_callback.language_changed = NULL;
+       event_callback.low_memory = NULL;
+       event_callback.low_battery = NULL;
+       event_callback.device_orientation = NULL;
+       event_callback.region_format_changed = NULL;
+
+       return app_efl_main(&argc, &argv, &event_callback, clock_viewer);
+}
diff --git a/clock-viewer/src/clock-viewer-minicontrol.c b/clock-viewer/src/clock-viewer-minicontrol.c
new file mode 100644 (file)
index 0000000..8008a53
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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 <minicontrol-viewer.h>
+#include <minicontrol-monitor.h>
+#include <minicontrol-handler.h>
+
+#include "clock-viewer-feature.h"
+#include "clock-viewer-debug.h"
+#include "clock-viewer-minicontrol.h"
+#include "clock-viewer-util-winset.h"
+
+static struct _minictrl_info {
+       Evas_Object *parent;
+       Evas_Object *bg;
+       Evas_Object *minictrl;
+
+       int is_monitor_start;
+} s_minictrl_info = {
+       .parent = NULL,
+       .bg = NULL,
+       .minictrl = NULL,
+
+       .is_monitor_start = 0,
+};
+
+static void __clock_viewer_minicontrol_monitor_with_handler_cb(minicontrol_action_e action, const char *name, unsigned int width, unsigned int height, minicontrol_priority_e priority, minicontrol_h handler, void *data)
+{
+       Evas_Object *minictrl = NULL;
+       _DBG("action[%d] name[%s], size[%dx%d], priority[%d], handler[%p]", action, name, width, height, priority, handler);
+
+       switch (action) {
+       case MINICONTROL_ACTION_START:
+               if (s_minictrl_info.bg) {
+                       s_minictrl_info.minictrl = minicontrol_viewer_add(s_minictrl_info.bg, name);
+
+                       minictrl = elm_object_content_unset(s_minictrl_info.bg);
+                       if (minictrl && minictrl != s_minictrl_info.bg) {
+                               evas_object_del(minictrl);
+                       }
+
+                       if (s_minictrl_info.minictrl) {
+                               elm_object_content_set(s_minictrl_info.bg, s_minictrl_info.minictrl);
+                               evas_object_show(s_minictrl_info.minictrl);
+                       }
+               }
+               break;
+       case MINICONTROL_ACTION_STOP:
+               break;
+       case MINICONTROL_ACTION_RESIZE:
+               break;
+       case MINICONTROL_ACTION_REQUEST:
+               break;
+       case MINICONTROL_ACTION_REALIZE:
+               break;
+       }
+}
+
+HAPI void clock_viewer_minicontrol_init(void *data, Evas_Object *parent)
+{
+       int ret = 0;
+
+       if (!parent) {
+               _ERR("invalid parent");
+               return;
+       }
+
+       if (s_minictrl_info.is_monitor_start) {
+               _DBG("minictrl clock already started");
+               return;
+       }
+
+       // create bg
+       if (!s_minictrl_info.bg) {
+               s_minictrl_info.bg = clock_viewer_util_winset_create_bg(parent);
+               if (!s_minictrl_info.bg) {
+                       _ERR("Failed to create clock bg");
+                       return;
+               }
+
+               elm_win_resize_object_add(parent, s_minictrl_info.bg);
+       } else {
+               _DBG("minictrl clock bg is already created");
+       }
+
+       ret = minicontrol_monitor_start_with_handler(__clock_viewer_minicontrol_monitor_with_handler_cb, data);
+       if (ret != MINICONTROL_ERROR_NONE) {
+               _ERR("Failed to start mini control monitor[%d]", ret);
+       }
+
+       s_minictrl_info.is_monitor_start = 1;
+       s_minictrl_info.parent = parent;
+}
+
+HAPI void clock_viewer_minicontrol_fini(void *data)
+{
+       int ret = 0;
+
+       if (s_minictrl_info.is_monitor_start) {
+               ret = minicontrol_monitor_stop();
+               if (ret != MINICONTROL_ERROR_NONE) {
+                       _ERR("Failed to stop mini control monitor[%d]", ret);
+               }
+               s_minictrl_info.is_monitor_start = 0;
+       }
+
+       if (s_minictrl_info.minictrl) {
+               evas_object_del(s_minictrl_info.minictrl);
+               s_minictrl_info.minictrl = NULL;
+       }
+
+       if (s_minictrl_info.bg) {
+               if (s_minictrl_info.parent) {
+                       elm_win_resize_object_del(s_minictrl_info.parent, s_minictrl_info.bg);
+               }
+               evas_object_del(s_minictrl_info.bg);
+               s_minictrl_info.bg = NULL;
+       }
+
+       s_minictrl_info.parent = NULL;
+}
diff --git a/clock-viewer/src/clock-viewer-plugin.c b/clock-viewer/src/clock-viewer-plugin.c
new file mode 100644 (file)
index 0000000..d0d7cc8
--- /dev/null
@@ -0,0 +1,162 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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 <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h> /* for open */
+
+#include <dlfcn.h> /* for dlopen, dlsym and dlclose */
+
+#include "clock-viewer-plugin.h"
+
+#define CLOCK_VIEWER_PLUGIN_DIGITAL_PATH       "/usr/apps/org.tizen.w-clock-viewer/shared/lib/libdigital.so"
+#define CLOCK_VIEWER_PLUGIN_ANALOG_PATH        "/usr/apps/org.tizen.w-clock-viewer/shared/lib/libalnalog.so"
+
+static struct _plugin_info {
+       Evas_Object *parent;
+
+       clock_viewer_ambient_type ambient_type;
+
+       void *module_data;
+       alpm_clock_plugin_module_ops ops;
+} s_plugin_info = {
+       .parent = NULL,
+
+       .ambient_type = CLOCK_VIEWER_AMBIENT_TYPE_ANALOG,
+
+       .module_data = NULL,
+       .ops.modules.ui_runtime_plugin_init = NULL,
+       .ops.modules.ui_runtime_plugin_deinit = NULL,
+       .ops.modules.ui_runtime_plugin_update_clock = NULL,
+       .ops.modules.priv = NULL,
+};
+
+HAPI int clock_viewer_plugin_init(void *data, Evas_Object *parent, clock_viewer_ambient_type ambient_type)
+{
+       int (*init)(alpm_clock_plugin_module_ops *ops);
+       int ret = 0;
+
+       if (s_plugin_info.module_data) {
+               _ERR("Previous module is not finalized");
+               ret = clock_viewer_plugin_fini(data);
+               if (!ret) {
+                       _ERR("Failed to finalize plugin");
+               }
+       }
+
+       if (ambient_type == CLOCK_VIEWER_AMBIENT_TYPE_MANUAL) {
+               _DBG("invalid ambient type[%d]", ambient_type);
+               return CLOCK_VIEWER_FAIL;
+       }
+
+       s_plugin_info.module_data = dlopen(CLOCK_VIEWER_PLUGIN_ANALOG_PATH, RTLD_LAZY);
+       if (!s_plugin_info.module_data) {
+               _DBG("Failed to load plugin clock[%s]", dlerror());
+               return CLOCK_VIEWER_FAIL;
+       }
+
+       init = dlsym(s_plugin_info.module_data, ALPM_CLOCK_PLUGIN_MODULE_INIT_SYM);
+       if (!init) {
+               _ERR("Failed to dlsym[%s]", dlerror());
+               if (s_plugin_info.module_data) {
+                       dlclose(s_plugin_info.module_data);
+                       s_plugin_info.module_data = NULL;
+               }
+               return CLOCK_VIEWER_FAIL;
+       }
+
+       if (init(&s_plugin_info.ops) == -1) {
+               _ERR("Failed to init");
+               if (s_plugin_info.module_data) {
+                       dlclose(s_plugin_info.module_data);
+                       s_plugin_info.module_data = NULL;
+               }
+               return CLOCK_VIEWER_FAIL;
+       }
+
+       if (s_plugin_info.ops.modules.ui_runtime_plugin_init) {
+               s_plugin_info.ops.modules.ui_runtime_plugin_init(&s_plugin_info.ops, parent);
+       }
+
+       s_plugin_info.parent = parent;
+       s_plugin_info.ambient_type = ambient_type;
+
+       return CLOCK_VIEWER_SUCCESS;
+}
+
+HAPI int clock_viewer_plugin_fini(void *data)
+{
+       int (*exit)(alpm_clock_plugin_module_ops *ops);
+
+       if (s_plugin_info.ops.modules.ui_runtime_plugin_deinit) {
+               s_plugin_info.ops.modules.ui_runtime_plugin_deinit(&s_plugin_info.ops, s_plugin_info.parent);
+       }
+
+       if (s_plugin_info.module_data) {
+               exit = dlsym(s_plugin_info.module_data, ALPM_CLOCK_PLUGIN_MODULE_EXIT_SYM);
+               if (!exit || (exit && exit(&s_plugin_info.ops) == -1)) {
+                       _ERR("Failed to plugin exit");
+               }
+
+               dlclose(s_plugin_info.module_data);
+               s_plugin_info.module_data = NULL;
+       }
+
+       s_plugin_info.ops.modules.ui_runtime_plugin_init = NULL;
+       s_plugin_info.ops.modules.ui_runtime_plugin_deinit = NULL;
+       s_plugin_info.ops.modules.ui_runtime_plugin_update_clock = NULL;
+       s_plugin_info.ops.modules.priv = NULL;
+
+       s_plugin_info.parent = NULL;
+       s_plugin_info.ambient_type = CLOCK_VIEWER_AMBIENT_TYPE_ANALOG;
+
+       return CLOCK_VIEWER_SUCCESS;
+}
+
+HAPI int clock_viewer_plugin_locale_update(void *data)
+{
+       int (*locale_update)(alpm_clock_plugin_module_ops *ops);
+
+       if (s_plugin_info.module_data) {
+               locale_update = dlsym(s_plugin_info.module_data, ALPM_CLOCK_PLUGIN_MODULE_LOCALE_UPDATE_SYM);
+               if (!locale_update) {
+                       _ERR("Failed to dlsym[%s]", dlerror());
+                       return CLOCK_VIEWER_FAIL;
+               }
+
+               if (locale_update(&s_plugin_info.ops) == -1) {
+                       _ERR("Failed to locale update");
+                       return CLOCK_VIEWER_FAIL;
+               }
+
+               return CLOCK_VIEWER_SUCCESS;
+       }
+
+       return CLOCK_VIEWER_FAIL;
+}
+
+HAPI int clock_viewer_plugin_update(void *data)
+{
+       if (s_plugin_info.ops.modules.ui_runtime_plugin_update_clock) {
+               s_plugin_info.ops.modules.ui_runtime_plugin_update_clock(&s_plugin_info.ops, s_plugin_info.parent);
+               return CLOCK_VIEWER_SUCCESS;
+       }
+
+       return CLOCK_VIEWER_FAIL;
+}
diff --git a/clock-viewer/src/clock-viewer-util-alarm.c b/clock-viewer/src/clock-viewer-util-alarm.c
new file mode 100644 (file)
index 0000000..e15afb4
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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 "clock-viewer.h"
+#include "clock-viewer-util-alarm.h"
+
+static struct _util_alarm_info
+{
+       int ref_count;
+} s_util_alarm_info = {
+       .ref_count = 0,
+};
+
+static int __clock_viewer_util_alarm_ids_cb(alarm_id_t alarm_id, void *user_param)
+{
+       _WARN("Delete alarm id[%d]", alarm_id);
+       clock_viewer_util_alarm_remove(alarm_id);
+
+       return 1;
+}
+
+HAPI int clock_viewer_util_alarm_init(void)
+{
+       int ret = 0;
+
+       if (s_util_alarm_info.ref_count == 0) {
+               ret = alarmmgr_init(PACKAGE);
+               if (ret != ALARMMGR_RESULT_SUCCESS) {
+                       _ERR("Failed to init alarm[%d]", ret);
+                       return CLOCK_VIEWER_FAIL;
+               } else {
+                       s_util_alarm_info.ref_count++;
+                       _DBG("Alarm initialized[%d]", s_util_alarm_info.ref_count);
+
+                       // when first initialized, remove previous alarms
+                       ret = alarmmgr_enum_alarm_ids(__clock_viewer_util_alarm_ids_cb, NULL);
+                       if (ret != ALARMMGR_RESULT_SUCCESS) {
+                               _ERR("Failed to enum alarm ids[%d]", ret);
+                       }
+               }
+       } else {
+               s_util_alarm_info.ref_count++;
+               _DBG("Add alarm reference count[%d]", s_util_alarm_info.ref_count);
+       }
+
+       return CLOCK_VIEWER_SUCCESS;
+}
+
+HAPI void clock_viewer_util_alarm_fini(void)
+{
+       if (s_util_alarm_info.ref_count == 0) {
+               _WARN("Already alarm finalized");
+       } else {
+               _DBG("Delete alarm reference count[%d]", s_util_alarm_info.ref_count);
+               s_util_alarm_info.ref_count--;
+               if (s_util_alarm_info.ref_count == 0) {
+                       _DBG("alarm finalized");
+                       alarmmgr_fini();
+               }
+       }
+}
+
+HAPI alarm_id_t clock_viewer_util_alarm_add(time_t start, time_t interval, alarm_cb_t func, void *data)
+{
+       alarm_id_t alarm_id = 0;
+       int ret = 0;
+
+       ret = alarmmgr_add_alarm_withcb(ALARM_TYPE_VOLATILE, start, interval, func, data, &alarm_id);
+       if (ret != ALARMMGR_RESULT_SUCCESS) {
+               _ERR("Failed to add alarm[%d]", ret);
+       }
+
+       return alarm_id;
+}
+
+HAPI void clock_viewer_util_alarm_remove(alarm_id_t alarm_id)
+{
+       int ret = 0;
+
+       ret = alarmmgr_remove_alarm(alarm_id);
+       if (ret != ALARMMGR_RESULT_SUCCESS) {
+               _ERR("Failed to remove alarm[%d]", ret);
+       }
+}
diff --git a/clock-viewer/src/clock-viewer-util-dbus-emul.c b/clock-viewer/src/clock-viewer-util-dbus-emul.c
new file mode 100644 (file)
index 0000000..849d339
--- /dev/null
@@ -0,0 +1,189 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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 "clock-viewer.h"
+#include "clock-viewer-util-dbus.h"
+#include <vconf.h>
+
+struct cb_item {
+       E_DBus_Signal_Cb cb;
+       void *data;
+};
+
+static struct info {
+       Eina_List *lcdoff_list;
+       Eina_List *lcdon_list;
+       Eina_List *clockdraw_list;
+} s_info = {
+       .lcdoff_list = NULL,
+       .lcdon_list = NULL,
+       .clockdraw_list = NULL,
+};
+
+static void lcdoff_cb(keynode_t *node, void *user_data)
+{
+       Eina_List *l;
+       struct cb_item *item;
+
+       EINA_LIST_FOREACH(s_info.lcdoff_list, l, item) {
+               LOGD("Invoke lcdoff vcon");
+               item->cb(item->data, NULL);
+       }
+}
+
+static void lcdon_cb(keynode_t *node, void *user_data)
+{
+       Eina_List *l;
+       struct cb_item *item;
+
+       EINA_LIST_FOREACH(s_info.lcdon_list, l, item) {
+               LOGD("Invoke lcdoff vcon");
+               item->cb(item->data, NULL);
+       }
+}
+
+static void clockdraw_cb(keynode_t *node, void *user_data)
+{
+       Eina_List *l;
+       struct cb_item *item;
+
+       EINA_LIST_FOREACH(s_info.clockdraw_list, l, item) {
+               LOGD("Invoke lcdoff vcon");
+               item->cb(item->data, NULL);
+       }
+}
+
+static inline int register_event_callback(Eina_List **list, void (*event_cb)(keynode_t *, void *), const char *key, void *data, E_DBus_Signal_Cb signal)
+{
+       struct cb_item *item;
+
+       item = malloc(sizeof(*item));
+       if (!item) {
+               LOGE("malloc: %s\n", strerror(errno));
+               return -1;
+       }
+
+       item->cb = signal;
+       item->data = data;
+
+       if (!*list) {
+               int ret;
+
+               ret = vconf_notify_key_changed(key, event_cb, NULL);
+               if (ret < 0) {
+                       LOGE("Failed to add vconf for lock state: %d\n", ret);
+               }
+       }
+
+       *list = eina_list_append(*list, item);
+       return 0;
+}
+
+static inline int unregister_event_callback(Eina_List **list, void (*event_cb)(keynode_t *, void *), const char *key, void *data)
+{
+       Eina_List *l;
+       Eina_List *n;
+       struct cb_item *item;
+
+       item = NULL;
+       EINA_LIST_FOREACH_SAFE(*list, l, n, item) {
+               if (item->data == data) {
+                       break;
+               }
+               item = NULL;
+       }
+
+       if (!item) {
+               /* not found */
+               return -1;
+       }
+
+       *list = eina_list_remove(*list, item);
+       free(item);
+
+       if (!*list) {
+               vconf_ignore_key_changed(key, event_cb);
+       }
+
+       return 0;
+}
+
+HAPI void clock_viewer_util_dbus_broadcast_signal(void *data, char *path, char *interface, char *name, const char *type, char *signal[])
+{
+       LOGD("Broadcast signal path[%s] interface[%s] name[%s] type[%s]\n", path, interface, name, type);
+}
+
+HAPI void clock_viewer_util_dbus_init_lcdoff_signal(void *data, E_DBus_Signal_Cb cb_signal)
+{
+       register_event_callback(&s_info.lcdoff_list, lcdoff_cb, "memory/clock_viewer/lcdoff", data, cb_signal);
+}
+
+HAPI void clock_viewer_util_dbus_fini_lcdoff_signal(void *data)
+{
+       unregister_event_callback(&s_info.lcdoff_list, lcdoff_cb, "memory/clock_viewer/lcdoff", data);
+}
+
+HAPI void clock_viewer_util_dbus_init_lcdon_signal(void *data, E_DBus_Signal_Cb cb_signal)
+{
+       register_event_callback(&s_info.lcdon_list, lcdon_cb, "memory/clock_viewer/lcdon", data, cb_signal);
+}
+
+HAPI void clock_viewer_util_dbus_fini_lcdon_signal(void *data)
+{
+       unregister_event_callback(&s_info.lcdon_list, lcdon_cb, "memory/clock_viewer/lcdon", data);
+}
+
+HAPI void clock_viewer_util_dbus_init_clockdraw_signal(void *data, E_DBus_Signal_Cb cb_signal)
+{
+       register_event_callback(&s_info.clockdraw_list, clockdraw_cb, "memory/clock_viewer/clockdraw", data, cb_signal);
+}
+
+HAPI void clock_viewer_util_dbus_fini_clockdraw_signal(void *data)
+{
+       unregister_event_callback(&s_info.clockdraw_list, clockdraw_cb, "memory/clock_viewer/clockdraw", data);
+}
+
+HAPI int clock_viewer_util_dbus_message_is_signal(DBusMessage *msg, const char *interface, const char *signal)
+{
+       if (!strcmp(interface, DEVICED_DISPLAY_INTERFACE)) {
+               if (!strcmp(signal, LCDON_SIGNAL_NAME)) {
+                       int lcdon;
+
+                       if (vconf_get_int("memory/clock_viewer/lcdon", &lcdon) < 0) {
+                               LOGE("Failed to get lcdon status");
+                               lcdon = 0;
+                       }
+
+                       return lcdon;
+               } else if (!strcmp(signal, LCDOFF_SIGNAL_NAME)) {
+                       int lcdoff;
+
+                       if (vconf_get_int("memory/clock_viewer/lcdoff", &lcdoff) < 0) {
+                               LOGE("Failed to get lcdoff status");
+                               lcdoff = 0;
+                       }
+
+                       return lcdoff;
+               }
+       }
+
+       return 0;
+}
+
+/* End of a file */
diff --git a/clock-viewer/src/clock-viewer-util-dbus.c b/clock-viewer/src/clock-viewer-util-dbus.c
new file mode 100644 (file)
index 0000000..b64cbff
--- /dev/null
@@ -0,0 +1,197 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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 "clock-viewer.h"
+#include "clock-viewer-util-dbus.h"
+
+static struct _dbus_info
+{
+       DBusConnection *dbus_conn;
+       E_DBus_Connection *e_dbus_conn;
+
+       E_DBus_Signal_Handler *dbus_lcdon_signal_handler;
+       E_DBus_Signal_Handler *dbus_lcdoff_signal_handler;
+       E_DBus_Signal_Handler *dbus_clockdraw_signal_handler;
+} s_dbus_info = {
+       .dbus_conn = NULL,
+       .e_dbus_conn = NULL,
+
+       .dbus_lcdon_signal_handler = NULL,
+       .dbus_lcdoff_signal_handler = NULL,
+       .dbus_clockdraw_signal_handler = NULL,
+};
+
+static int _clock_viewer_util_dbus_append_variant(DBusMessageIter *iter, const char *sig, char *param[])
+{
+       char *ch;
+       int i;
+       int int_type;
+       uint64_t int64_type;
+
+       if (!sig || !param) {
+               return 0;
+       }
+
+       for (ch = (char*) sig, i = 0; *ch != '\0'; ++i, ++ch) {
+               switch (*ch) {
+               case 'i':
+                       int_type = atoi(param[i]);
+                       dbus_message_iter_append_basic(iter, DBUS_TYPE_INT32, &int_type);
+                       break;
+               case 'u':
+                       int_type = strtoul(param[i], NULL, 10);
+                       dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT32, &int_type);
+                       break;
+               case 't':
+                       int64_type = atoll(param[i]);
+                       dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT64, &int64_type);
+                       break;
+               case 's':
+                       dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &param[i]);
+                       break;
+               default:
+                       return -EINVAL;
+
+               }
+       }
+
+       return 0;
+}
+
+HAPI void clock_viewer_util_dbus_broadcast_signal(void *data, char *path, char *interface, char *name, const char *type, char *signal[])
+{
+       DBusMessage *msg;
+       DBusMessageIter iter;
+       int r;
+
+       msg = dbus_message_new_signal(path, interface, name);
+       if (!msg) {
+               _ERR("Failed to new signal");
+               return;
+       }
+
+       dbus_message_iter_init_append(msg, &iter);
+       r = _clock_viewer_util_dbus_append_variant(&iter, type, signal);
+       if (r < 0) {
+               _ERR("Failed to append variant[%d]", r);
+               return;
+       }
+
+       if (s_dbus_info.dbus_conn == NULL) {
+               s_dbus_info.dbus_conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+               if (s_dbus_info.dbus_conn == NULL) {
+                       _ERR("Failed to get bus");
+                       return;
+               }
+       }
+
+       r = dbus_connection_send(s_dbus_info.dbus_conn, msg, NULL);
+       if (!r) {
+               _ERR("Failed to send message[%s][%s][%s]", path, interface, name);
+               return;
+       }
+
+       dbus_message_unref(msg);
+}
+
+HAPI void clock_viewer_util_dbus_init_lcdoff_signal(void *data, E_DBus_Signal_Cb cb_signal)
+{
+       if (s_dbus_info.e_dbus_conn == NULL) {
+               e_dbus_init();
+
+               s_dbus_info.e_dbus_conn = e_dbus_bus_get(DBUS_BUS_SYSTEM);
+               if (s_dbus_info.e_dbus_conn == NULL) {
+                       _ERR("Failed to get e dbus");
+                       return;
+               }
+       }
+
+       s_dbus_info.dbus_lcdoff_signal_handler = e_dbus_signal_handler_add(s_dbus_info.e_dbus_conn, NULL, DEVICED_DISPLAY_PATH, DEVICED_DISPLAY_INTERFACE, LCDOFF_SIGNAL_NAME, cb_signal, data);
+
+       if (s_dbus_info.dbus_lcdoff_signal_handler == NULL) {
+               _ERR("Failed to add lcd off signal");
+       }
+}
+
+HAPI void clock_viewer_util_dbus_fini_lcdoff_signal(void *data)
+{
+       if (s_dbus_info.e_dbus_conn && s_dbus_info.dbus_lcdoff_signal_handler) {
+               e_dbus_signal_handler_del(s_dbus_info.e_dbus_conn, s_dbus_info.dbus_lcdoff_signal_handler);
+               s_dbus_info.dbus_lcdoff_signal_handler = NULL;
+       }
+}
+
+HAPI void clock_viewer_util_dbus_init_lcdon_signal(void *data, E_DBus_Signal_Cb cb_signal)
+{
+       if (s_dbus_info.e_dbus_conn == NULL) {
+               e_dbus_init();
+
+               s_dbus_info.e_dbus_conn = e_dbus_bus_get(DBUS_BUS_SYSTEM);
+               if (s_dbus_info.e_dbus_conn == NULL) {
+                       _ERR("Failed to get e dbus");
+                       return;
+               }
+       }
+
+       s_dbus_info.dbus_lcdon_signal_handler = e_dbus_signal_handler_add(s_dbus_info.e_dbus_conn, NULL, DEVICED_DISPLAY_PATH, DEVICED_DISPLAY_INTERFACE, LCDON_SIGNAL_NAME, cb_signal, data);
+
+       if (s_dbus_info.dbus_lcdon_signal_handler == NULL) {
+               _ERR("Failed to add lcd on signal");
+       }
+}
+
+HAPI void clock_viewer_util_dbus_fini_lcdon_signal(void *data)
+{
+       if (s_dbus_info.e_dbus_conn && s_dbus_info.dbus_lcdon_signal_handler) {
+               e_dbus_signal_handler_del(s_dbus_info.e_dbus_conn, s_dbus_info.dbus_lcdon_signal_handler);
+               s_dbus_info.dbus_lcdon_signal_handler = NULL;
+       }
+}
+
+HAPI void clock_viewer_util_dbus_init_clockdraw_signal(void *data, E_DBus_Signal_Cb cb_signal)
+{
+       if (s_dbus_info.e_dbus_conn == NULL) {
+               e_dbus_init();
+
+               s_dbus_info.e_dbus_conn = e_dbus_bus_get(DBUS_BUS_SYSTEM);
+               if (s_dbus_info.e_dbus_conn == NULL) {
+                       _ERR("Failed to get e dbus");
+                       return;
+               }
+       }
+
+       s_dbus_info.dbus_clockdraw_signal_handler = e_dbus_signal_handler_add(s_dbus_info.e_dbus_conn, NULL, CLOCKDRAW_PATH, CLOCKDRAW_INTERFACE, CLOCKDRAW_NAME, cb_signal, data);
+
+       if (s_dbus_info.dbus_clockdraw_signal_handler == NULL) {
+               _ERR("Failed to add clockdraw signal");
+       }
+}
+
+HAPI void clock_viewer_util_dbus_fini_clockdraw_signal(void *data)
+{
+       if (s_dbus_info.e_dbus_conn && s_dbus_info.dbus_clockdraw_signal_handler) {
+               e_dbus_signal_handler_del(s_dbus_info.e_dbus_conn, s_dbus_info.dbus_clockdraw_signal_handler);
+               s_dbus_info.dbus_clockdraw_signal_handler = NULL;
+       }
+}
+
+HAPI int clock_viewer_util_dbus_message_is_signal(DBusMessage *msg, const char *interface, const char *signal)
+{
+       return dbus_message_is_signal(msg, interface, signal);
+}
diff --git a/clock-viewer/src/clock-viewer-util-pkginfo.c b/clock-viewer/src/clock-viewer-util-pkginfo.c
new file mode 100644 (file)
index 0000000..542e4e0
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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 <pkgmgr-info.h>
+#include <widget_service.h>
+#include <widget_service_internal.h>
+
+#include "clock-viewer-util-pkginfo.h"
+
+HAPI void clock_viewer_util_pkginfo_init_clock_package_event(void *data, vconf_callback_fn cb)
+{
+       int ret = 0;
+
+       ret = vconf_notify_key_changed(VCONFKEY_WMS_CLOCKS_SET_IDLE, cb, data);
+       if (ret != 0) {
+               _ERR("Failed to notify clock set");
+       }
+}
+
+HAPI void clock_viewer_util_pkginfo_fini_clock_package_event(vconf_callback_fn cb)
+{
+       int ret = 0;
+
+       ret = vconf_ignore_key_changed(VCONFKEY_WMS_CLOCKS_SET_IDLE, cb);
+       if (ret != 0) {
+               _ERR("Failed to ignore clock set");
+       }
+}
+
+HAPI char *clock_viewer_util_pkginfo_get_clock_package(void)
+{
+       return vconf_get_str(VCONFKEY_WMS_CLOCKS_SET_IDLE);
+}
+
+static inline char *pkgmgr_get_mainapp(const char *pkgid)
+{
+       pkgmgrinfo_pkginfo_h handle;
+       char *ret;
+
+       if (pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle) != PMINFO_R_OK) {
+               _ERR("Unable to get mainapp: %s\n", pkgid);
+               return NULL;
+       }
+
+       ret = NULL;
+       if (pkgmgrinfo_pkginfo_get_mainappid(handle, &ret) == PMINFO_R_OK) {
+               if (ret) {
+                       ret = strdup(ret);
+                       if (!ret) {
+                               _ERR("strdup: %d\n", errno);
+                       }
+               }
+       } else {
+               _ERR("Failed to get mainappid\n");
+               ret = NULL; /* I cannot believe the pkgmgrinfo_pkginfo_get_mainappid. it maybe able to touch my "ret" even though it fails */
+       }
+
+       pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+       return ret;
+}
+
+HAPI clock_viewer_ambient_type clock_viewer_util_pkginfo_get_ambient_type(char *pkgid)
+{
+       int ret;
+       pkgmgrinfo_appinfo_h handle = NULL;
+       bool ambient_mode = false;
+       char *appid;
+
+       appid = pkgmgr_get_mainapp(pkgid);
+       if (!appid) {
+               _ERR("Failed to get appid. try to use the pkgid again\n");
+               appid = strdup(pkgid);
+               if (!appid) {
+                       _ERR("strdup: %d\n", errno);
+                       return CLOCK_VIEWER_AMBIENT_TYPE_ANALOG;
+               }
+       }
+
+       _DBG("App: %s\n", appid);
+       ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
+       free(appid);
+       if (ret != PMINFO_R_OK || handle == NULL) {
+               return CLOCK_VIEWER_AMBIENT_TYPE_ANALOG;
+       }
+
+       ret = pkgmgrinfo_appinfo_get_ambient_support(handle, &ambient_mode);
+       pkgmgrinfo_appinfo_destroy_appinfo(handle);
+       if (ret != PMINFO_R_OK) {
+               return CLOCK_VIEWER_AMBIENT_TYPE_ANALOG;
+       }
+
+       _DBG("ambient mode[%s]", ambient_mode ? "manual" : "analog");
+
+       return ambient_mode ? CLOCK_VIEWER_AMBIENT_TYPE_MANUAL : CLOCK_VIEWER_AMBIENT_TYPE_ANALOG;
+}
+
+HAPI int clock_viewer_util_pkginfo_is_widget(char *appid)
+{
+       int is_widget = 0;
+       char *widget_id = NULL;
+
+       widget_id = widget_service_get_widget_id(appid);
+       if (widget_id != NULL) {
+               char *category = NULL;
+               category = widget_service_get_category(widget_id);
+
+               if (category != NULL) {
+                       if (!strcmp(category, CLOCK_VIEWER_TIZEN_CLOCK_CATEGORY)) {
+                               is_widget = 1;
+                       }
+                       free(category);
+               }
+               free(widget_id);
+       }
+
+       return is_widget;
+}
diff --git a/clock-viewer/src/clock-viewer-util-status.c b/clock-viewer/src/clock-viewer-util-status.c
new file mode 100644 (file)
index 0000000..bb3f869
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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 <vconf.h>
+
+#include "clock-viewer.h"
+#include "clock-viewer-util-status.h"
+
+#define CLOCK_VIEWER_UTIL_STATUS_VCONFKEY_RESERVED_APPS_STATUS "memory/starter/reserved_apps_status"
+
+static struct _util_status_info
+{
+       int reserved_apps_status;
+} s_util_status_info = {
+       .reserved_apps_status = 0,
+};
+
+static void __clock_viewer_util_status_reserved_apps_status_changed_cb(keynode_t *node, void *data)
+{
+       int ret = 0;
+       int value = 0;
+
+       ret = vconf_get_int(CLOCK_VIEWER_UTIL_STATUS_VCONFKEY_RESERVED_APPS_STATUS, &value);
+       if (ret != 0) {
+               _ERR("Failed to get reserved apps status[%d]", ret);
+               s_util_status_info.reserved_apps_status = 0;
+       } else {
+               _DBG("Reserved apps status[%d]", value);
+               s_util_status_info.reserved_apps_status = value;
+       }
+}
+
+HAPI void clock_viewer_util_status_init(void)
+{
+       int ret = 0;
+
+       // reserved apps status
+       ret = vconf_notify_key_changed(CLOCK_VIEWER_UTIL_STATUS_VCONFKEY_RESERVED_APPS_STATUS, __clock_viewer_util_status_reserved_apps_status_changed_cb, NULL);
+       if (ret != 0) {
+               _ERR("Failed to notify reserved apps status changed event[%d]", ret);
+       }
+       __clock_viewer_util_status_reserved_apps_status_changed_cb(NULL, NULL);
+}
+
+HAPI void clock_viewer_util_status_fini(void)
+{
+       int ret = 0;
+
+       // reserved apps status
+       ret = vconf_ignore_key_changed(CLOCK_VIEWER_UTIL_STATUS_VCONFKEY_RESERVED_APPS_STATUS, __clock_viewer_util_status_reserved_apps_status_changed_cb);
+       if (ret != 0) {
+               _ERR("Failed to ignore reserved apps status changed event[%d]", ret);
+       }
+}
+
+HAPI int clock_viewer_util_status_get_reserved_apps_status(void)
+{
+       return s_util_status_info.reserved_apps_status;
+}
diff --git a/clock-viewer/src/clock-viewer-util-winset.c b/clock-viewer/src/clock-viewer-util-winset.c
new file mode 100644 (file)
index 0000000..87b7e40
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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 "clock-viewer-util-winset.h"
+
+HAPI Evas_Object *clock_viewer_util_winset_create_bg(Evas_Object *parent)
+{
+       Evas_Object *bg = NULL;
+
+       if (!parent) {
+               _ERR("Invalid parent");
+               return NULL;
+       }
+
+       bg = elm_bg_add(parent);
+       if (!bg) {
+               _ERR("Failed to create bg");
+               return NULL;
+       }
+
+       elm_bg_color_set(bg, 0, 0, 0);
+
+       evas_object_show(bg);
+
+       return bg;
+}
+
+HAPI Evas_Object *clock_viewer_util_winset_create_layout(Evas_Object *parent, const char *file, const char *group)
+{
+       Evas_Object *layout = NULL;
+       int ret = 0;
+
+       if (!parent) {
+               _ERR("Invalid parent");
+               return NULL;
+       }
+
+       layout = elm_layout_add(parent);
+       if (!layout) {
+               _ERR("Failed to add layout");
+               return NULL;
+       }
+
+       ret = elm_layout_file_set(layout, file, group);
+       if (!ret) {
+               _ERR("Failed to set file[%s], group[%s]", file, group);
+               evas_object_del(layout);
+               return NULL;
+       }
+
+       evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_show(layout);
+
+       return layout;
+}
diff --git a/clock-viewer/src/clock-viewer-widget.c b/clock-viewer/src/clock-viewer-widget.c
new file mode 100644 (file)
index 0000000..fc7cb04
--- /dev/null
@@ -0,0 +1,308 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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 <Elementary.h>
+#include <widget_service.h>
+#include <widget_service_internal.h>
+#include <widget_viewer_evas.h>
+#include <widget_viewer_evas_internal.h>
+
+#include "clock-viewer-widget.h"
+#include "clock-viewer-util-winset.h"
+
+#define EDJ_APP EDJEDIR"/clock-viewer.edj"
+#define MAX_VIEW_STATE 8
+
+static struct _widget_info
+{
+       Evas_Object *parent;
+       Evas_Object *layout;
+       Evas_Object *widget;
+
+       int is_widget_init;
+       int is_widget_resumed;
+
+       char *pkgname;
+
+       int view_pos;
+       int view_pos_timestamp;
+} s_widget_info = {
+       .parent = NULL,
+       .layout = NULL,
+       .widget = NULL,
+
+       .is_widget_init = 0,
+       .is_widget_resumed = 0,
+
+       .pkgname = NULL,
+
+       .view_pos = 0,
+       .view_pos_timestamp = 0,
+};
+
+static void __clock_viewer_widget_raw_event_cb(struct widget_evas_raw_event_info *info, void *data)
+{
+       Evas_Object *widget = NULL;
+
+       if (info) {
+               if (info->type == WIDGET_VIEWER_EVAS_RAW_CREATE) {
+                       _DBG("Widget Created[%s] it should be [%s]", info->pkgname, s_widget_info.pkgname);
+
+                       if (s_widget_info.pkgname && info->pkgname) {
+                               if (strcmp(s_widget_info.pkgname, info->pkgname)) {
+                                       _ERR("invalid widget pkgname");
+                                       return;
+                               }
+                       }
+
+                       if (s_widget_info.layout) {
+                               widget = elm_object_content_unset(s_widget_info.layout);
+                               if (widget && widget != info->widget) {
+                                       // delete old widget
+                                       evas_object_del(widget);
+                               }
+
+                               elm_object_part_content_set(s_widget_info.layout, "elm.swallow.body", info->widget);
+                               evas_object_show(info->widget);
+
+                               s_widget_info.widget = info->widget;
+
+                               if (s_widget_info.is_widget_resumed) {
+                                       _DBG("resume when it created");
+                                       widget_viewer_evas_resume_widget(s_widget_info.widget);
+                               }
+                       }
+               } else if (info->type == WIDGET_VIEWER_EVAS_RAW_DELETE) {
+                       _DBG("Widget deleted[%s]", info->pkgname);
+                       // unset will be done when another evas object is set or fini
+               } else {
+                       _ERR("invalid type[%d]", info->type);
+               }
+       }
+}
+
+HAPI void clock_viewer_widget_init(void *data, Evas_Object *parent, char *pkgname)
+{
+       int ret = 0;
+
+       if (s_widget_info.is_widget_init) {
+               _DBG("widget already init");
+               return;
+       }
+
+       // create layouot
+       if (!s_widget_info.layout) {
+               s_widget_info.layout = clock_viewer_util_winset_create_layout(parent, EDJ_APP, "layout_manual_clock_position");
+               if (!s_widget_info.layout) {
+                       _ERR("Failed to create clock layout");
+                       return;
+               }
+
+               elm_win_resize_object_add(parent, s_widget_info.layout);
+       } else {
+               _DBG("widget clock bg is already created");
+       }
+
+       ret = widget_viewer_evas_init(s_widget_info.layout);
+       if (ret != 0) {
+               _ERR("Failed to init widget[%d]", ret);
+               return;
+       }
+       s_widget_info.is_widget_init = 1;
+
+       widget_viewer_evas_set_option(WIDGET_VIEWER_EVAS_MANUAL_PAUSE_RESUME, 1);
+
+       ret = widget_viewer_evas_set_raw_event_callback(WIDGET_VIEWER_EVAS_RAW_CREATE, __clock_viewer_widget_raw_event_cb, data);
+       if (ret != 0) {
+               _ERR("Failed to set widget create callback[%d]", ret);
+       }
+
+       ret = widget_viewer_evas_set_raw_event_callback(WIDGET_VIEWER_EVAS_RAW_DELETE, __clock_viewer_widget_raw_event_cb, data);
+       if (ret != 0) {
+               _ERR("Failed to set widget delete callback[%d]", ret);
+       }
+
+       ret = widget_viewer_evas_subscribe_category(CLOCK_VIEWER_TIZEN_CLOCK_CATEGORY);
+       if (ret != 0) {
+               _ERR("Failed to subscribe category[%d]", ret);
+       }
+
+       if (pkgname) {
+               s_widget_info.pkgname = strdup(pkgname);
+       }
+
+       s_widget_info.parent = parent;
+}
+
+HAPI void clock_viewer_widget_fini(void *data)
+{
+       int ret = 0;
+
+       if (s_widget_info.is_widget_init) {
+               ret = widget_viewer_evas_unset_raw_event_callback(WIDGET_VIEWER_EVAS_RAW_CREATE, __clock_viewer_widget_raw_event_cb, data);
+               if (ret != 0) {
+                       _ERR("Failed to unset widget create callback[%d]", ret);
+               }
+
+               ret = widget_viewer_evas_unset_raw_event_callback(WIDGET_VIEWER_EVAS_RAW_DELETE, __clock_viewer_widget_raw_event_cb, data);
+               if (ret != 0) {
+                       _ERR("Failed to unset widget delete callback[%d]", ret);
+               }
+
+               ret = widget_viewer_evas_unsubscribe_category(CLOCK_VIEWER_TIZEN_CLOCK_CATEGORY);
+               if (ret != 0) {
+                       _ERR("Failed to subscribe category[%d]", ret);
+               }
+
+               widget_viewer_evas_fini();
+               s_widget_info.is_widget_init = 0;
+       }
+
+       if (s_widget_info.widget) {
+               evas_object_del(s_widget_info.widget);
+               s_widget_info.widget = NULL;
+       }
+
+       if (s_widget_info.layout) {
+               if (s_widget_info.parent) {
+                       elm_win_resize_object_del(s_widget_info.parent, s_widget_info.layout);
+               }
+               evas_object_del(s_widget_info.layout);
+               s_widget_info.layout = NULL;
+       }
+
+       if (s_widget_info.pkgname) {
+               free(s_widget_info.pkgname);
+               s_widget_info.pkgname = NULL;
+       }
+
+       s_widget_info.parent = NULL;
+}
+
+HAPI void clock_viewer_widget_pause(void)
+{
+       _DBG("");
+       if (s_widget_info.widget) {
+               widget_viewer_evas_pause_widget(s_widget_info.widget);
+       }
+       s_widget_info.is_widget_resumed = 0;
+
+       // reset position
+       if (s_widget_info.layout) {
+               edje_object_signal_emit(elm_layout_edje_get(s_widget_info.layout), "elm.swallow.body.default", "elm.swallow.body");
+               edje_object_message_signal_process(elm_layout_edje_get(s_widget_info.layout));
+       }
+}
+
+HAPI void clock_viewer_widget_resume(void)
+{
+       _DBG("");
+       if (s_widget_info.widget) {
+               evas_object_show(s_widget_info.widget);
+               widget_viewer_evas_resume_widget(s_widget_info.widget);
+       }
+       s_widget_info.is_widget_resumed = 1;
+}
+
+HAPI void clock_viewer_widget_update_position(void)
+{
+       int timestamp = time(NULL);
+       static const struct signal_list {
+               char *emission;
+               char *source;
+       } signal_list[] = {
+               [0] = {
+                       .emission = NULL,
+                       .source = NULL
+               },
+               [1] = {
+                       .emission =  "elm.swallow.body.top",
+                       .source = "elm.swallow.body"
+               },
+               [2] = {
+                       .emission = "elm.swallow.body.right",
+                       .source = "elm.swallow.body"
+               },
+               [3] = {
+                       .emission = "elm.swallow.body.bottom",
+                       .source = "elm.swallow.body"
+               },
+               [4] = {
+                       .emission = "elm.swallow.body.left",
+                       .source = "elm.swallow.body"
+               },
+               [5] = {
+                       .emission = "elm.swallow.body.topright",
+                       .source = "elm.swallow.body"
+               },
+               [6] = {
+                       .emission = "elm.swallow.body.bottomright",
+                       .source = "elm.swallow.body"
+               },
+               [7] = {
+                       .emission = "elm.swallow.body.bottomleft",
+                       .source = "elm.swallow.body"
+               },
+               [8] = {
+                       .emission = "elm.swallow.body.topleft",
+                       .source = "elm.swallow.body"
+               },
+               [9] = {
+                       .emission = NULL,
+                       .source = NULL
+               }
+       };
+
+       if (timestamp - s_widget_info.view_pos_timestamp < 60) {
+               return;
+       }
+       s_widget_info.view_pos_timestamp = timestamp;
+
+       if (++s_widget_info.view_pos > MAX_VIEW_STATE) {
+               s_widget_info.view_pos = 0;
+       }
+
+       _DBG("moved pos[%d]", s_widget_info.view_pos);
+
+       if (s_widget_info.view_pos >= 1 && s_widget_info.view_pos <= 8) {
+               edje_object_signal_emit(elm_layout_edje_get(s_widget_info.layout), signal_list[s_widget_info.view_pos].emission, signal_list[s_widget_info.view_pos].source);
+       } else {
+               edje_object_signal_emit(elm_layout_edje_get(s_widget_info.layout), "elm.swallow.body.default", "elm.swallow.body");
+       }
+
+       edje_object_message_signal_process(elm_layout_edje_get(s_widget_info.layout));
+}
+
+HAPI void clock_viewer_widget_register_render_event(Evas_Smart_Cb func, void *data)
+{
+       if (!s_widget_info.widget) {
+               return;
+       }
+
+       evas_object_smart_callback_add(s_widget_info.widget, WIDGET_SMART_SIGNAL_UPDATED, func, data);
+}
+
+HAPI void clock_viewer_widget_unregister_render_event(Evas_Smart_Cb func, void *data)
+{
+       if (!s_widget_info.widget) {
+               return;
+       }
+
+       evas_object_smart_callback_del(s_widget_info.widget, WIDGET_SMART_SIGNAL_UPDATED, func);
+}
diff --git a/clock-viewer/src/clock-viewer-window.c b/clock-viewer/src/clock-viewer-window.c
new file mode 100644 (file)
index 0000000..9d7b8bc
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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 <Ecore_X.h>
+
+#include "clock-viewer-window.h"
+
+static Evas_Object *_clock_viewer_window_create_window()
+{
+       Evas_Object *win = NULL;
+
+       win = elm_win_add(NULL, PACKAGE, ELM_WIN_BASIC);
+       if (win) {
+               elm_win_title_set(win, PACKAGE);
+               elm_win_borderless_set(win, EINA_TRUE);
+               elm_win_alpha_set(win, EINA_FALSE);
+               elm_win_indicator_mode_set(win, ELM_WIN_INDICATOR_HIDE);
+               elm_win_indicator_opacity_set(win, ELM_WIN_INDICATOR_BG_TRANSPARENT);
+       } else {
+               _ERR("Failed to create window");
+       }
+
+       return win;
+}
+
+HAPI Evas_Object *clock_viewer_window_create(void)
+{
+       Evas_Object *window = NULL;
+       int w, h;
+
+       window = _clock_viewer_window_create_window();
+       if (!window) {
+               _ERR("Failed to create window");
+               return NULL;
+       }
+
+       /**
+        * @TODO
+        * Set window class name as "CLOCK_VIEWER"
+        * Disable launch effect
+        */
+       elm_win_screen_size_get(window, NULL, NULL, &w, &h);
+       evas_object_resize(window, w, h);
+       LOGD("Window is resized to %dx%d\n", w, h);
+
+       return window;
+}
+
+HAPI void clock_viewer_window_destroy(Evas_Object *window)
+{
+       if (window) {
+               evas_object_del(window);
+       }
+}
diff --git a/clock-viewer/src/clock-viewer.c b/clock-viewer/src/clock-viewer.c
new file mode 100644 (file)
index 0000000..42e427c
--- /dev/null
@@ -0,0 +1,590 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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 <Ecore.h>
+#include <Ecore_Evas.h>
+#include <device/power.h>
+
+#include "clock-viewer.h"
+#include "clock-viewer-window.h"
+#include "clock-viewer-util-dbus.h"
+#include "clock-viewer-util-pkginfo.h"
+#include "clock-viewer-display.h"
+#include "clock-viewer-minicontrol.h"
+#include "clock-viewer-widget.h"
+#include "clock-viewer-default-clock.h"
+
+#define CV_WINDOW_SHOW_POS_X   0
+#define CV_WINDOW_SHOW_POS_Y   0
+#define CV_WINDOW_HIDE_POS_X   10000
+#define CV_WINDOW_HIDE_POS_Y   10000
+
+#define CLOCK_VIEWER_TIMER_CLOCKEND    0.1
+#define CLOCK_VIEWER_TIMER_RENDER_CHECK        0.5
+
+#define CLOCK_VIEWER_VCONF_HOMESCREEN_CLOCK_VISIBILITY "memory/homescreen/clock_visibility"    /* Set by homescreen */
+#define CLOCK_VIEWER_VCONF_CLOCK_VIEWER_CLOCK_VISIBILITY       "memory/clock_viewer/clock_visibility"
+
+static struct _info {
+       Evas_Object *parent;
+       Evas_Object *widget;
+
+       int is_render_added;    // 0 : deleted, 1 : added
+       int is_clock_resumed;
+
+       int home_clock_visibitity;      // homescreen clock status
+       int clock_visibitity;   // clock status
+
+       clock_viewer_ambient_type ambient_type;
+       char *clock_pkgname;
+
+       /* clockend condition check list */
+       int is_drawdone;
+       int is_render_check_timer_expired;
+
+       Ecore_Timer *render_first_timer;
+       Ecore_Timer *render_check_timer;
+       Ecore_Timer *clockend_timer;
+} s_info = {
+       .parent = NULL,
+       .widget = NULL,
+
+       .is_render_added = 0,
+       .is_clock_resumed = 0,
+
+       .home_clock_visibitity = 0,
+       .clock_visibitity = 0,
+
+       .ambient_type = CLOCK_VIEWER_AMBIENT_TYPE_ANALOG,
+       .clock_pkgname = NULL,
+
+       .is_drawdone = 0,
+       .is_render_check_timer_expired = 0,
+
+       .render_first_timer = NULL,
+       .render_check_timer = NULL,
+       .clockend_timer = NULL,
+};
+
+static int _clock_viewer_try_clockend(clock_viewer_s *clock_viewer);
+static void _clock_viewer_set_current_clock(clock_viewer_s *clock_viewer);
+
+static Eina_Bool __clock_viewer_clockend_timer_cb(void *data)
+{
+       char *clock_signal[1] = { "clockend" };
+       _WARN("clock end <<");
+       clock_viewer_util_dbus_broadcast_signal(data, DEVICED_PATH, DEVICED_INTERFACE, "HomeScreen", "s", &clock_signal[0]);
+       device_power_release_lock(POWER_LOCK_CPU);
+
+       s_info.clockend_timer = NULL;
+
+       return EINA_FALSE;
+}
+
+static Eina_Bool __clock_viewer_render_check_timer_cb(void *data)
+{
+       clock_viewer_s *clock_viewer = (clock_viewer_s *) data;
+       _DBG("Render check timer expired");
+
+       s_info.is_render_check_timer_expired = 1;
+
+       if (!_clock_viewer_try_clockend(clock_viewer)) {
+               _DBG("clockend condition is unmet");
+       }
+
+       s_info.render_check_timer = NULL;
+
+       return EINA_FALSE;
+}
+
+static void __clock_viewer_render_pre_cb(void *data, Evas *e, void *event_info)
+{
+       clock_viewer_s *clock_viewer = (clock_viewer_s *) data;
+       if (!clock_viewer) {
+               _ERR("invalid data");
+               return;
+       }
+
+       _WARN("RENDER PRE [%d] timer[%d]", clock_viewer->request_pm_status, s_info.is_render_check_timer_expired);
+
+       if (!s_info.is_render_check_timer_expired) {
+               return;
+       }
+
+       if (clock_viewer->request_pm_status == CLOCK_VIEWER_PM_STEP_CLOCKSTART
+                       || clock_viewer->request_pm_status == CLOCK_VIEWER_PM_STEP_CLOCKEND)
+       {
+               clock_viewer_display_set_dpms_mode(CLOCK_VIEWER_DISPLAY_MODE_RESUME);
+
+               if (s_info.ambient_type == CLOCK_VIEWER_AMBIENT_TYPE_MANUAL) {
+                       clock_viewer_widget_update_position();
+               }
+       }
+}
+
+static void __clock_viewer_render_post_cb(void *data, Evas *e, void *event_info)
+{
+       clock_viewer_s *clock_viewer = (clock_viewer_s *) data;
+       if (!clock_viewer) {
+               _ERR("invalid data");
+               return;
+       }
+
+       _WARN("RENDER POST [%d] timer[%d]", clock_viewer->request_pm_status, s_info.is_render_check_timer_expired);
+
+       if (!s_info.is_render_check_timer_expired) {
+               if (s_info.render_check_timer) {
+                       ecore_timer_del(s_info.render_check_timer);
+               }
+               s_info.render_check_timer = ecore_timer_add(CLOCK_VIEWER_TIMER_RENDER_CHECK, __clock_viewer_render_check_timer_cb, clock_viewer);
+               return;
+       }
+
+       if (clock_viewer->request_pm_status == CLOCK_VIEWER_PM_STEP_CLOCKEND) {
+               clock_viewer_display_set_dpms_mode(CLOCK_VIEWER_DISPLAY_MODE_PAUSE);
+       }
+}
+
+static void __clock_viewer_widget_updated_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       __clock_viewer_render_pre_cb(data, NULL, NULL);
+       __clock_viewer_render_post_cb(data, NULL, NULL);
+}
+
+Eina_Bool __clock_viewer_render_first_timer_cb(void *data)
+{
+       _DBG("Render first done");
+
+       clock_viewer_s *clock_viewer = (clock_viewer_s *) data;
+       if (!clock_viewer) {
+               _ERR("invalid data");
+               return EINA_FALSE;
+       }
+
+       if (clock_viewer->request_pm_status == CLOCK_VIEWER_PM_STEP_CLOCKSTART) {
+               clock_viewer->request_pm_status = CLOCK_VIEWER_PM_STEP_CLOCKEND;
+
+               s_info.is_drawdone = 1;
+               if (!_clock_viewer_try_clockend(clock_viewer)) {
+                       _DBG("clockend condition is unmet");
+               }
+       }
+
+       s_info.render_first_timer = NULL;
+
+       return EINA_FALSE;
+}
+
+static void __clock_viewer_clockdraw_cb(void *data, DBusMessage *msg)
+{
+       _DBG("Clock draw done");
+
+       clock_viewer_s *clock_viewer = (clock_viewer_s *) data;
+       if (!clock_viewer) {
+               _ERR("invalid data");
+               return;
+       }
+
+       if (clock_viewer->request_pm_status == CLOCK_VIEWER_PM_STEP_CLOCKSTART) {
+               clock_viewer->request_pm_status = CLOCK_VIEWER_PM_STEP_CLOCKEND;
+
+               s_info.is_drawdone = 1;
+               if (!_clock_viewer_try_clockend(clock_viewer)) {
+                       _DBG("clockend condition is unmet");
+               }
+       }
+}
+
+static void __clock_viewer_lcdon_cb(void *data, DBusMessage *msg)
+{
+       clock_viewer_s *clock_viewer = (clock_viewer_s *) data;
+       if (!clock_viewer) {
+               _ERR("invalid data");
+               return;
+       }
+
+       int is_lcdon = clock_viewer_util_dbus_message_is_signal(msg, DEVICED_DISPLAY_INTERFACE, LCDON_SIGNAL_NAME);
+       _DBG("event lcdon[%d]", is_lcdon);
+
+       clock_viewer->is_lckoff = 0;
+       if (is_lcdon) {
+               clock_viewer_hide(clock_viewer);
+
+               clock_viewer->request_pm_status = CLOCK_VIEWER_PM_STEP_NONE;
+       }
+}
+
+static void __clock_viewer_lcdoff_cb(void *data, DBusMessage *msg)
+{
+       clock_viewer_s *clock_viewer = (clock_viewer_s *) data;
+       if (!clock_viewer) {
+               _ERR("invalid data");
+               return;
+       }
+
+       int ret = 0;
+       int is_lcdoff = clock_viewer_util_dbus_message_is_signal(msg, DEVICED_DISPLAY_INTERFACE, LCDOFF_SIGNAL_NAME);
+       _DBG("event pre lcdoff[%d]", is_lcdoff);
+
+       clock_viewer->is_lckoff = 1;
+       if (is_lcdoff) {
+#ifdef _CLOCK_VIEWER_FEATURE_VI_BY_HOMESCREEN_STATUS_ENABLED_
+               // set clock visibility first
+               s_info.clock_visibitity = s_info.home_clock_visibitity;
+#else
+               // default is 1
+               s_info.clock_visibitity = 1;
+#endif
+               ret = vconf_set_int(CLOCK_VIEWER_VCONF_CLOCK_VIEWER_CLOCK_VISIBILITY, s_info.home_clock_visibitity);
+               if (ret != 0) {
+                       _ERR("Failed to set clock visibility");
+               } else {
+                       _DBG("Clock visibility set to [%d]", s_info.home_clock_visibitity);
+               }
+
+               // init clockend condition
+               s_info.is_drawdone = 0;
+               s_info.is_render_check_timer_expired = 0;
+
+               clock_viewer->request_pm_status = CLOCK_VIEWER_PM_STEP_CLOCKSTART;
+
+               if (s_info.clock_visibitity) {
+                       clock_viewer_show(clock_viewer, 0);
+               }
+
+               char *clock_signal[1] = { "clockstart" };
+               _WARN("clock start >>");
+               device_power_request_lock(POWER_LOCK_CPU, 0);
+               clock_viewer_util_dbus_broadcast_signal(clock_viewer, DEVICED_PATH, DEVICED_INTERFACE, "HomeScreen", "s", &clock_signal[0]);
+
+               if (s_info.ambient_type == CLOCK_VIEWER_AMBIENT_TYPE_MANUAL) {
+                       char *clock_begin_signal[1] = { "clockbegin" };
+                       _WARN("clock begin >>");
+                       clock_viewer_util_dbus_broadcast_signal(clock_viewer, DEVICED_PATH, DEVICED_INTERFACE, "HomeScreen", "s", &clock_begin_signal[0]);
+               }
+
+               if (clock_viewer->current_type != CLOCK_VIEWER_TYPE_WIDGET) {
+                       // if dbox, wait draw done signal. others are not send draw done signal
+                       s_info.render_first_timer = ecore_timer_add(1.0, __clock_viewer_render_first_timer_cb, clock_viewer);
+               }
+
+               if (!s_info.clock_visibitity) {
+                       clock_viewer_show(clock_viewer, 0);
+               }
+       }
+}
+
+static void __clock_viewer_clock_package_event_cb(keynode_t *node, void *user_data)
+{
+       _DBG("clock package has been changed");
+
+       _clock_viewer_set_current_clock(user_data);
+}
+
+static int _clock_viewer_try_clockend(clock_viewer_s *clock_viewer)
+{
+       _DBG("drawdone[%d] render timer expired[%d]", s_info.is_drawdone, s_info.is_render_check_timer_expired);
+
+       if (s_info.is_drawdone && s_info.is_render_check_timer_expired) {
+               if (!s_info.clock_visibitity) {
+                       // [LCDOFF Flow 2] manual render
+                       int w, h;
+                       Evas *e;
+                       Ecore_Evas *ee;
+                       ee = ecore_evas_ecore_evas_get(evas_object_evas_get(clock_viewer->window));
+                       e = ecore_evas_get(ee);
+                       evas_output_viewport_get(e, NULL, NULL, &w, &h);
+                       evas_obscured_clear(e);
+                       evas_damage_rectangle_add(e, 0, 0, w, h);
+                       ecore_evas_manual_render(ee);
+
+                       // [LCDOFF Flow 3] move to view area
+                       evas_object_resize(clock_viewer->window, clock_viewer->win_width, clock_viewer->win_height);
+                       evas_object_move(clock_viewer->window, CV_WINDOW_SHOW_POS_X, CV_WINDOW_SHOW_POS_Y);
+                       evas_object_show(clock_viewer->window);
+               }
+
+               if (s_info.clockend_timer) {
+                       ecore_timer_del(s_info.clockend_timer);
+               }
+               s_info.clockend_timer = ecore_timer_add(CLOCK_VIEWER_TIMER_CLOCKEND, __clock_viewer_clockend_timer_cb, clock_viewer);
+
+               return CLOCK_VIEWER_SUCCESS;
+       }
+
+       return CLOCK_VIEWER_FAIL;
+}
+
+static void __clock_viewer_homescreen_clock_visibility_changed_cb(keynode_t *node, void *data)
+{
+       int ret = 0;
+       int value = 0;
+
+       ret = vconf_get_int(CLOCK_VIEWER_VCONF_HOMESCREEN_CLOCK_VISIBILITY, &value);
+       if (ret != 0) {
+               _ERR("Failed to get homescreen clock visibility[%d]", ret);
+       }
+
+       _DBG("homescreen clock visibility changed [%d]->[%d]", s_info.home_clock_visibitity, value);
+       s_info.home_clock_visibitity = value;
+}
+
+static void _clock_viewer_set_current_clock(clock_viewer_s *clock_viewer)
+{
+       clock_viewer_ambient_type ambient_type;
+       char *pkgname;
+
+       pkgname = clock_viewer_util_pkginfo_get_clock_package();
+       if (!pkgname) {
+               _ERR("pkgname is not valid\n");
+               return;
+       }
+
+       if (s_info.clock_pkgname) {
+               if (!strcmp(s_info.clock_pkgname, pkgname)) {
+                       _WARN("same pkgname(%s), skip!", pkgname);
+                       free(pkgname);
+                       return;
+               }
+       } else {
+               _DBG("First time\n");
+       }
+
+       ambient_type = clock_viewer_util_pkginfo_get_ambient_type(pkgname);
+       _WARN("package[%s] ambient type[%d]", pkgname, ambient_type);
+
+       // unload clock
+       clock_viewer_default_clock_fini(clock_viewer);
+       clock_viewer_minicontrol_fini(clock_viewer);
+       clock_viewer_widget_fini(clock_viewer);
+
+       // load clock
+       if (ambient_type == CLOCK_VIEWER_AMBIENT_TYPE_MANUAL) {
+               if (clock_viewer_util_pkginfo_is_widget(pkgname)) {
+                       clock_viewer_widget_init(clock_viewer, clock_viewer->window, pkgname);
+                       clock_viewer->current_type = CLOCK_VIEWER_TYPE_WIDGET;
+               } else {
+                       clock_viewer_minicontrol_init(clock_viewer, clock_viewer->window);
+                       clock_viewer->current_type = CLOCK_VIEWER_TYPE_MINICTRL;
+               }
+       } else {
+               clock_viewer_default_clock_init(clock_viewer, clock_viewer->window, ambient_type);
+               clock_viewer->current_type = CLOCK_VIEWER_TYPE_DEFAULT_CLOCK;
+       }
+
+       s_info.is_clock_resumed = 0;
+       s_info.ambient_type = ambient_type;
+
+       free(s_info.clock_pkgname);
+       s_info.clock_pkgname = pkgname;
+
+       _DBG("type changed to [%d](%s)", clock_viewer->current_type, s_info.clock_pkgname);
+}
+
+static void _clock_viewer_register_event(clock_viewer_s *clock_viewer)
+{
+       int ret = 0;
+
+       // dbus event
+       clock_viewer_util_dbus_init_lcdon_signal(clock_viewer, __clock_viewer_lcdon_cb);
+       clock_viewer_util_dbus_init_lcdoff_signal(clock_viewer, __clock_viewer_lcdoff_cb);
+       clock_viewer_util_dbus_init_clockdraw_signal(clock_viewer, __clock_viewer_clockdraw_cb);
+
+       // pkginfo event
+       clock_viewer_util_pkginfo_init_clock_package_event(clock_viewer, __clock_viewer_clock_package_event_cb);
+
+       // vconf event
+       ret = vconf_notify_key_changed(CLOCK_VIEWER_VCONF_HOMESCREEN_CLOCK_VISIBILITY, __clock_viewer_homescreen_clock_visibility_changed_cb, clock_viewer);
+       if (ret != 0) {
+               _ERR("Failed to notify homescreen clock visibility changed event[%d]", ret);
+       }
+       __clock_viewer_homescreen_clock_visibility_changed_cb(NULL, NULL);
+}
+
+static void _clock_viewer_unregister_event(clock_viewer_s *clock_viewer)
+{
+       // dbus event
+       clock_viewer_util_dbus_fini_lcdon_signal(clock_viewer);
+       clock_viewer_util_dbus_fini_lcdoff_signal(clock_viewer);
+       clock_viewer_util_dbus_fini_clockdraw_signal(clock_viewer);
+
+       // pkginfo event
+       clock_viewer_util_pkginfo_fini_clock_package_event(__clock_viewer_clock_package_event_cb);
+}
+
+HAPI void clock_viewer_create(clock_viewer_s *clock_viewer)
+{
+       if (!clock_viewer) {
+               _ERR("invalid data");
+               return;
+       }
+
+       _clock_viewer_register_event(clock_viewer);
+
+       // create base winset
+       clock_viewer->window = clock_viewer_window_create();
+
+       elm_win_screen_size_get(clock_viewer->window, NULL, NULL, &clock_viewer->win_width, &clock_viewer->win_height);
+       evas_object_move(clock_viewer->window, CV_WINDOW_HIDE_POS_X, CV_WINDOW_HIDE_POS_Y);
+       evas_object_show(clock_viewer->window);
+
+       _clock_viewer_set_current_clock(clock_viewer);
+}
+
+HAPI void clock_viewer_destroy(clock_viewer_s *clock_viewer)
+{
+       _clock_viewer_unregister_event(clock_viewer);
+}
+
+HAPI void clock_viewer_resume(clock_viewer_s *clock_viewer)
+{
+       _DBG("");
+}
+
+HAPI void clock_viewer_pause(clock_viewer_s *clock_viewer)
+{
+       _DBG("");
+}
+
+HAPI void clock_viewer_show(clock_viewer_s *clock_viewer, int is_hide_launch)
+{
+       _DBG("hide_launch[%d]", is_hide_launch);
+       Evas_Object *win = NULL;
+       Evas *evas = NULL;
+
+       if (!clock_viewer) {
+               _ERR("invalid data");
+               return;
+       }
+
+       win = clock_viewer->window;
+       if (win) {
+               if (!s_info.is_render_added) {
+                       if (clock_viewer->current_type == CLOCK_VIEWER_TYPE_WIDGET) {
+                               clock_viewer_widget_register_render_event(__clock_viewer_widget_updated_cb, clock_viewer);
+                       } else {
+                               evas = evas_object_evas_get(win);
+
+                               evas_event_callback_add(evas, EVAS_CALLBACK_RENDER_PRE, __clock_viewer_render_pre_cb, clock_viewer);
+                               evas_event_callback_add(evas, EVAS_CALLBACK_RENDER_POST, __clock_viewer_render_post_cb, clock_viewer);
+                       }
+
+                       s_info.is_render_added = 1;
+               }
+
+               // [LCDOFF Flow 1] widget or mc resume
+               if (!s_info.is_clock_resumed) {
+                       if (clock_viewer->current_type == CLOCK_VIEWER_TYPE_DEFAULT_CLOCK) {
+                               clock_viewer_default_clock_resume(clock_viewer);
+                       } else if (clock_viewer->current_type == CLOCK_VIEWER_TYPE_WIDGET) {
+                               clock_viewer_widget_resume();
+                       }
+
+                       s_info.is_clock_resumed = 1;
+               } else {
+                       // only widget is working with render event
+                       if (clock_viewer->current_type != CLOCK_VIEWER_TYPE_WIDGET) {
+                               // temporary move to set visible so we can receive render pre/post
+                               evas_object_move(win, clock_viewer->win_width - 1, clock_viewer->win_height - 1);
+                       }
+               }
+
+               // [LCDOFF Flow 2] manual render
+               int w, h;
+               Evas *e;
+               Ecore_Evas *ee;
+
+               ee = ecore_evas_ecore_evas_get(evas_object_evas_get(clock_viewer->window));
+               e = ecore_evas_get(ee);
+
+               evas_output_viewport_get(e, NULL, NULL, &w, &h);
+               evas_obscured_clear(e);
+               evas_damage_rectangle_add(e, 0, 0, w, h);
+               ecore_evas_manual_render(ee);
+
+               if (s_info.clock_visibitity) {
+                       // if homescreen is not clock, do move in drawdone
+                       // [LCDOFF Flow 3] move to view area
+                       evas_object_resize(win, clock_viewer->win_width, clock_viewer->win_height);
+                       evas_object_move(win, CV_WINDOW_SHOW_POS_X, CV_WINDOW_SHOW_POS_Y);
+                       evas_object_show(win);
+               } else {
+                       if (clock_viewer->current_type != CLOCK_VIEWER_TYPE_WIDGET) {
+                               // temporary move to set visible so we can receive render pre/post
+                               evas_object_move(win, clock_viewer->win_width - 1, clock_viewer->win_height - 1);
+                       }
+               }
+
+               // Raise up the Clock Viewer Window
+               _DBG("Raise up the window\n");
+               elm_win_raise(win);
+       } else {
+               _ERR("window is not created");
+       }
+}
+
+HAPI void clock_viewer_hide(clock_viewer_s *clock_viewer)
+{
+       _DBG("");
+       Evas_Object *win = NULL;
+       Evas *evas = NULL;
+
+       if (!clock_viewer) {
+               _ERR("invalid data");
+               return;
+       }
+
+       win = clock_viewer->window;
+       if (win) {
+               if (s_info.is_render_added) {
+                       if (clock_viewer->current_type == CLOCK_VIEWER_TYPE_WIDGET) {
+                               clock_viewer_widget_unregister_render_event(__clock_viewer_widget_updated_cb, clock_viewer);
+                       } else {
+                               evas = evas_object_evas_get(win);
+
+                               evas_event_callback_del(evas, EVAS_CALLBACK_RENDER_PRE, __clock_viewer_render_pre_cb);
+                               evas_event_callback_del(evas, EVAS_CALLBACK_RENDER_POST, __clock_viewer_render_post_cb);
+                       }
+
+                       s_info.is_render_added = 0;
+               }
+
+               // TODO: when it should be called?
+               clock_viewer_display_set_dpms_mode(CLOCK_VIEWER_DISPLAY_MODE_PAUSE);
+
+               if (s_info.is_clock_resumed) {
+                       if (clock_viewer->current_type == CLOCK_VIEWER_TYPE_DEFAULT_CLOCK) {
+                               clock_viewer_default_clock_pause(clock_viewer);
+                       } else if (clock_viewer->current_type == CLOCK_VIEWER_TYPE_WIDGET) {
+                               clock_viewer_widget_pause();
+                       }
+                       s_info.is_clock_resumed = 0;
+
+                       if (s_info.ambient_type == CLOCK_VIEWER_AMBIENT_TYPE_MANUAL) {
+                               char *clock_signal[1] = { "clockstop" };
+                               _WARN("clock stop <<");
+                               clock_viewer_util_dbus_broadcast_signal(clock_viewer, DEVICED_PATH, DEVICED_INTERFACE, "HomeScreen", "s", &clock_signal[0]);
+                       }
+               }
+
+               evas_object_move(win, CV_WINDOW_HIDE_POS_X, CV_WINDOW_HIDE_POS_Y);
+       } else {
+               _ERR("window is not created");
+       }
+}
diff --git a/default-clock/CMakeLists.txt b/default-clock/CMakeLists.txt
new file mode 100644 (file)
index 0000000..124ce5b
--- /dev/null
@@ -0,0 +1,48 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(idle-clock-alpm C)
+
+SET(ANALOG "alnalog")
+SET(DIGITAL "digital")
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(SHAREDDIR "${PREFIX}/shared")
+SET(LIBDIR "${SHAREDDIR}/lib")
+SET(RESDIR "${SHAREDDIR}/res")
+SET(CHGDIR "${SHAREDDIR}/res/tables")
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED
+       elementary
+       ecore-x
+       evas
+       dlog
+       vconf
+)
+
+FOREACH(flag ${pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS}")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_C_FLAGS_RELEASE "-O2")
+
+SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DCHGDIR=\"${CHGDIR}\"")
+
+ADD_LIBRARY(${ANALOG} SHARED src/analog.c)
+TARGET_LINK_LIBRARIES(${ANALOG} ${pkgs_LDFLAGS})
+INSTALL(TARGETS ${ANALOG} DESTINATION ${LIBDIR})
+
+ADD_LIBRARY(${DIGITAL} SHARED src/digital.c)
+TARGET_LINK_LIBRARIES(${DIGITAL} ${pkgs_LDFLAGS})
+INSTALL(TARGETS ${DIGITAL} DESTINATION ${LIBDIR})
+
+# data
+ADD_SUBDIRECTORY(data)
diff --git a/default-clock/data/CMakeLists.txt b/default-clock/data/CMakeLists.txt
new file mode 100644 (file)
index 0000000..41ef41f
--- /dev/null
@@ -0,0 +1,12 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+# install edj
+ADD_CUSTOM_TARGET(alpm.edj
+               COMMAND edje_cc -id ${CMAKE_CURRENT_SOURCE_DIR}/images ${EDJE_CFLAGS}
+               ${CMAKE_CURRENT_SOURCE_DIR}/alpm.edc alpm.edj
+               DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/alpm.edc
+)
+ADD_DEPENDENCIES(${DIGITAL} alpm.edj)
+ADD_DEPENDENCIES(${ANALOG} alpm.edj)
+
+INSTALL(FILES alpm.edj DESTINATION ${RESDIR})
diff --git a/default-clock/data/alpm.edc b/default-clock/data/alpm.edc
new file mode 100644 (file)
index 0000000..49d1e15
--- /dev/null
@@ -0,0 +1,157 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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.
+ *
+ */
+
+collections {
+       base_scale: 1.3;
+
+       group {
+               name: "layout_clock_position";
+               parts {
+                       part {
+                               name: "bg";
+                               type: RECT;
+                               scale: 1;
+                               description {
+                                       state: "default" 0.0;
+                                       color: 0 0 0 255;
+                               }
+                       }
+                       part {
+                               name: "elm.swallow.body";
+                               type: SWALLOW;
+                               scale: 1;
+                               description {
+                                       state: "default" 0.0;
+                               }
+                       }
+               }
+       }
+
+       group {
+               name: "layout_clock_tb";
+               styles {
+                       style {
+                               name: "textblock_digit_style2";
+                               base: "font=TIZEN:style=Regular font_size=104 color=#ffffff align=center style=shadow,bottom shadow_color=#00000088";
+                               tag:  "br" "\n";
+                               tag:  "hilight" "+ font_weight=Bold";
+                               tag:  "b" "+ font_weight=Bold";
+                               tag:  "tab" "\t";
+                       }
+               }
+
+               parts {
+                       part {
+                               name: "text.clock";
+                               type: TEXTBLOCK;
+                               scale: 1;
+                               description {
+                                       state: "default" 0.0;
+                                       fixed: 1 1;
+                                       visible: 1;
+                                       color: 255 255 255 255;
+                                       text{
+                                               text: "";
+                                               style: "textblock_digit_style2";
+                                               align: 0.5 0.5;
+                                       }
+                               }
+                       }
+               }
+       }
+
+       group {
+               name: "analog";
+               parts {
+                       part {
+                               name: "bg";
+                               type: RECT;
+                               description {
+                                       state: "default" 0.0;
+                                       //color_class: "AO011";
+                                       color: 100 100 100 255;
+                               }
+                       }
+               }
+       }
+
+       group {
+               name: "hour_hand";
+               images.image: "alpm_hands_hr.png" COMP;
+               parts {
+                       part {
+                               name: "bg";
+                               type: SPACER;
+                               scale: 1;
+                               description {
+                                       state: "default" 0.0;
+                                       min, 360 360;
+                                       max, 360 360;
+                                       fixed, 1 1;
+                               }
+                       }
+                       part {
+                               name: "image";
+                               type: IMAGE;
+                               scale: 1;
+                               description {
+                                       state: "default" 0.0;
+                                       min: 34 264;
+                                       max: 34 264;
+                                       fixed: 1 1;
+                                       image.normal: "alpm_hands_hr.png";
+                                       rel1.relative: 0.5 0.5;
+                                       rel2.relative: 0.5 0.5;
+                               }
+                       }
+               }
+       }
+
+       group {
+               name: "minute_hand";
+               images.image: "alpm_hands_min.png" COMP;
+               parts {
+                       part {
+                               name: "bg";
+                               type: SPACER;
+                               scale: 1;
+                               description {
+                                       state: "default" 0.0;
+                                       min, 360 360;
+                                       max, 360 360;
+                                       fixed, 1 1;
+                               }
+                       }
+                       part {
+                               name: "image";
+                               type: IMAGE;
+                               scale: 1;
+                               description {
+                                       state: "default" 0.0;
+                                       min: 34 324;
+                                       max: 34 324;
+                                       fixed: 1 1;
+                                       image.normal: "alpm_hands_min.png";
+                                       rel1.relative: 0.5 0.5;
+                                       rel2.relative: 0.5 0.5;
+                               }
+                       }
+               }
+       }
+}
diff --git a/default-clock/data/images/alpm_hands_hr.png b/default-clock/data/images/alpm_hands_hr.png
new file mode 100644 (file)
index 0000000..b4e8322
Binary files /dev/null and b/default-clock/data/images/alpm_hands_hr.png differ
diff --git a/default-clock/data/images/alpm_hands_min.png b/default-clock/data/images/alpm_hands_min.png
new file mode 100644 (file)
index 0000000..2c26039
Binary files /dev/null and b/default-clock/data/images/alpm_hands_min.png differ
diff --git a/default-clock/include/alpm.h b/default-clock/include/alpm.h
new file mode 100644 (file)
index 0000000..af67a5d
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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 __ALPM_H__
+#define __ALPM_H__
+
+#include <Elementary.h>
+#include <dlog.h>
+
+#include <unicode/utypes.h>
+#include <unicode/putil.h>
+#include <unicode/uiter.h>
+#include <unicode/udat.h>
+#include <unicode/udatpg.h>
+#include <unicode/ustring.h>
+
+
+#define FREEIF(p) ({if (p) {free(p); p = NULL; }})
+
+#define EDJ_APP "/usr/apps/org.tizen.w-clock-viewer/shared/res/alpm.edj"
+
+#undef LOG_TAG
+#define LOG_TAG "IDLE-CLOCK-ALPM"
+#define _E(fmt, arg...) LOGE("[%s:%d] "fmt,__FUNCTION__,__LINE__,##arg)
+#define _D(fmt, arg...) LOGD("[%s:%d] "fmt,__FUNCTION__,__LINE__,##arg)
+#define _SECURE_E(fmt, arg...) SECURE_LOGE("[%s:%d] "fmt,__FUNCTION__,__LINE__,##arg)
+#define _SECURE_D(fmt, arg...) SECURE_LOGD("[%s:%d] "fmt,__FUNCTION__,__LINE__,##arg)
+#define ENTER() LOGD(COLOR_GREEN"BEGIN >>>"COLOR_END);
+
+#define retvm_if_timer(timer, expr, val, fmt, arg...) do { \
+       if(expr) { \
+               _E(fmt, ##arg); \
+               _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+               timer = NULL; \
+               return (val); \
+       } \
+} while (0)
+
+#define retvm_if(expr, val, fmt, arg...) do { \
+       if(expr) { \
+               _E(fmt, ##arg); \
+               _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+               return (val); \
+       } \
+} while (0)
+
+#define retv_if(expr, val) do { \
+       if(expr) { \
+               _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+               return (val); \
+       } \
+} while (0)
+
+#define retm_if(expr, fmt, arg...) do { \
+       if(expr) { \
+               _E(fmt, ##arg); \
+               _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+               return; \
+       } \
+} while (0)
+
+#define ret_if(expr) do { \
+       if(expr) { \
+               _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+               return; \
+       } \
+} while (0)
+
+typedef struct _alpm_module_data
+{
+    Evas_Object *parent;
+    Evas_Object *bg;
+    Evas_Object *ly_main;
+    Evas_Object *ly_clock;
+
+    /* for time display */
+    Eina_Bool is_pre;
+    int timeformat;
+    char *timeregion_format;
+    char *timezone_id;
+    UDateFormat *formatter_time;
+    UDateFormat *formatter_ampm;
+    UDateFormat *formatter_time_24;
+    UDateFormat *formatter_date;
+    UDateTimePatternGenerator *generator;
+
+    /* private data. you can expand these data structure.*/
+}alpm_module_data;
+
+ALPM_CLOCK_PLUGIN_EXPORT_API int ALPM_CLOCK_PLUGIN_MODULE_INIT(alpm_clock_plugin_module_ops *ops);
+ALPM_CLOCK_PLUGIN_EXPORT_API int ALPM_CLOCK_PLUGIN_MODULE_EXIT(alpm_clock_plugin_module_ops *ops);
+ALPM_CLOCK_PLUGIN_EXPORT_API int ALPM_CLOCK_PLUGIN_MODULE_LOCALE_UPDATE(alpm_clock_plugin_module_ops *ops);
+#endif /* __ALPM_H__ */
diff --git a/default-clock/include/clock-viewer-plugin.h b/default-clock/include/clock-viewer-plugin.h
new file mode 100644 (file)
index 0000000..2ed4698
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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 __CLOCK_VIEWER_PLUGIN_H__
+#define __CLOCK_VIEWER_PLUGIN_H__
+
+#ifndef ALPM_CLOCK_PLUGIN_MODULE_INIT_SYM
+#define ALPM_CLOCK_PLUGIN_MODULE_INIT_SYM "ALPM_CLOCK_PLUGIN_MODULE_INIT"
+#endif
+
+#ifndef ALPM_CLOCK_PLUGIN_MODULE_EXIT_SYM
+#define ALPM_CLOCK_PLUGIN_MODULE_EXIT_SYM "ALPM_CLOCK_PLUGIN_MODULE_EXIT"
+#endif
+
+#ifndef ALPM_CLOCK_PLUGIN_EXPORT_API
+#define ALPM_CLOCK_PLUGIN_EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+typedef enum
+{
+    ALPM_ERROR=-1,
+    ALPM_NONE=0,
+    ALPM_SUCCESS=1,
+    ALPM_NEED_UPDATE=2
+}ALPM_RET_TYPE;
+
+typedef struct _alpm_clock_plugin_module_ops
+{
+    /* struct modules is initialized by alpm-clock module. */
+    struct {
+        int (*ui_runtime_plugin_init)(void *ops, void *data); /* data will be parent evas object */
+        int (*ui_runtime_plugin_deinit)(void *ops, void *data);
+        int (*ui_runtime_plugin_update_clock)(void *ops, void *data);
+        void *priv;
+    } modules;
+
+}alpm_clock_plugin_module_ops;
+
+#endif /* __CLOCK_VIEWER_PLUGIN_H__ */
diff --git a/default-clock/src/analog.c b/default-clock/src/analog.c
new file mode 100644 (file)
index 0000000..ecd76d7
--- /dev/null
@@ -0,0 +1,336 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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 <stdio.h>
+
+#include "clock-viewer-plugin.h"
+#include "alpm.h"
+
+static Evas_Object *_add_layout(Evas_Object *parent, const char *file, const char *group)
+{
+       _D("%s", __func__);
+       Evas_Object *eo = NULL;
+       int r = -1;
+
+       retvm_if(parent == NULL, NULL, "Invalid argument: parent is NULL\n");
+       retvm_if(file == NULL, NULL, "Invalid argument: file is NULL\n");
+       retvm_if(group == NULL, NULL, "Invalid argument: group is NULL\n");
+
+       eo = elm_layout_add(parent);
+       retvm_if(eo == NULL, NULL, "Failed to add layout\n");
+
+       r = elm_layout_file_set(eo, file, group);
+       if (!r) {
+               _E("Failed to set file[%s]\n", file);
+               evas_object_del(eo);
+               return NULL;
+       }
+
+       evas_object_size_hint_weight_set(eo, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_show(eo);
+       return eo;
+}
+
+/**
+ * @brief Initialize ALPM UI.
+ * @param[in] data : Evas Object pointer for elm_win.
+ * @return return -1 if an error occurred. Otherwise return 1.
+ */
+static int alpm_module_init(void *module_ops, void *data)
+{
+       alpm_module_data *alpm_md;
+       alpm_clock_plugin_module_ops *ops;
+
+       _E("module init!!");
+       ops = (alpm_clock_plugin_module_ops *)module_ops;
+       if (!ops) {
+               _E("ops is NULL!!");
+               return -1;
+       }
+
+       if(!data) {
+               _E("data is NULL!!");
+               return -1;
+       }
+
+       alpm_md = ops->modules.priv;
+       if(!alpm_md) {
+               _E("alpm_md is NULL!");
+               return -1;
+       }
+
+       alpm_md->parent = (Evas_Object *)data;
+
+       /* Implement main layout for ALPM clock */
+       //Add BG
+       if (!alpm_md->bg) {
+               alpm_md->bg = elm_bg_add(alpm_md->parent);
+               evas_object_size_hint_weight_set(alpm_md->bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+               elm_win_resize_object_add(alpm_md->parent, alpm_md->bg);
+               evas_object_show(alpm_md->bg);
+       }
+
+       //Create main layout
+       if (!alpm_md->ly_main) {
+               alpm_md->ly_main = _add_layout(alpm_md->parent, EDJ_APP, "layout_clock_position");
+               evas_object_size_hint_weight_set(alpm_md->ly_main, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+               elm_win_resize_object_add(alpm_md->parent, alpm_md->ly_main);
+       }
+
+       Evas_Coord x, y, w, h;
+       evas_object_geometry_get(alpm_md->ly_main, &x, &y, &w, &h);
+       _D("Layout %dx%d - %dx%d\n", x, y, w, h);
+       evas_object_geometry_get(alpm_md->parent, &x, &y, &w, &h);
+       _D("Window %dx%d - %dx%d\n", x, y, w, h);
+
+       return 1;
+}
+
+/**
+ * @brief clean up ALPM UI.
+ * @param[in] data : Evas Object pointer for elm_win.
+ * @return return -1 if an error occurred. Otherwise return 1.
+ */
+static int alpm_module_deinit(void *module_ops, void *data)
+{
+       alpm_module_data *alpm_md;
+       alpm_clock_plugin_module_ops *ops;
+
+       _E("module deinit!!");
+
+       ops = (alpm_clock_plugin_module_ops *)module_ops;
+       if (!ops) {
+               _E("ops is NULL!!");
+               return -1;
+       }
+
+       if (!data) {
+               _E("data is NULL!!");
+               return -1;
+       }
+
+       alpm_md = ops->modules.priv;
+       if(!alpm_md) {
+               _E("alpm_md is NULL!");
+               return -1;
+       }
+
+       /* destroy main layout for ALPM clock */
+
+       if (alpm_md->bg) {
+           evas_object_del(alpm_md->bg);
+       }
+       if (alpm_md->ly_main) {
+           evas_object_del(alpm_md->ly_main);
+       }
+
+       if (ops->modules.priv) {
+           free(ops->modules.priv);
+           ops->modules.priv = NULL;
+           alpm_md = NULL;
+       }
+
+    return 1;
+}
+
+static double __get_hour_degree()
+{
+       time_t now = time(NULL);
+       struct tm tm_now;
+       struct tm *tm_ret = localtime_r(&now, &tm_now);
+
+       if (!tm_ret) {
+               _E("Failed to get the localtime");
+               return 0.0f;
+       }
+
+       return tm_now.tm_hour * 360 / 12 + tm_now.tm_min * 360 / 60 / 12;
+}
+
+static double __get_minute_degree()
+{
+       time_t now = time(NULL);
+       struct tm tm_now;
+       struct tm *tm_ret = localtime_r(&now, &tm_now);
+
+       if (!tm_ret) {
+               _E("Failed to get the localtime");
+               return 0.0f;
+       }
+
+       return tm_now.tm_min * 360 / 60;
+}
+
+static Evas_Object* __create_hour_hand(Evas_Object* parent)
+{
+       Evas_Object* hand = NULL;
+
+       hand = _add_layout(parent, EDJ_APP, "hour_hand");
+       evas_object_resize(hand, 360, 360);
+       evas_object_move(hand, 0, 0);
+
+       return hand;
+}
+
+static Evas_Object* __create_minute_hand(Evas_Object* parent)
+{
+       Evas_Object* hand = NULL;
+
+       hand = _add_layout(parent, EDJ_APP, "minute_hand");
+       evas_object_resize(hand, 360, 360);
+       evas_object_move(hand, 0, 0);
+
+       return hand;
+}
+
+static void __rotate(Evas_Object* obj, double degree)
+{
+       Evas_Map* map = evas_map_new(4);
+       evas_map_util_points_populate_from_object(map, obj);
+
+       Evas_Coord_Rectangle r = {0};
+       evas_object_geometry_get(obj, &r.x, &r.y, &r.w, &r.h);
+
+       evas_map_util_rotate(map, degree, r.x + r.w/2, r.y + r.h/2);
+
+       evas_object_map_set(obj, map);
+       evas_object_map_enable_set(obj, EINA_TRUE);
+       evas_map_free(map);
+}
+
+static void _set_analog(void *data)
+{
+       alpm_module_data *alpm_md = (alpm_module_data *)data;
+
+       if (alpm_md->ly_clock != NULL)
+       {
+               evas_object_del(alpm_md->ly_clock);
+               alpm_md->ly_clock = NULL;
+       }
+
+       alpm_md->ly_clock = _add_layout(alpm_md->ly_main, EDJ_APP, "analog");
+       elm_object_part_content_set(alpm_md->ly_main, "elm.swallow.body", alpm_md->ly_clock);
+
+       __rotate(__create_minute_hand(alpm_md->ly_clock), __get_minute_degree());
+       __rotate(__create_hour_hand(alpm_md->ly_clock), __get_hour_degree());
+
+       evas_object_show(alpm_md->ly_clock);
+}
+
+/**
+ * @brief Update ALPM UI.
+ *        Evas Rendering will be done in alpm parent modules.
+ *        So in alpm_module_update_clock(), just update clock infomation and add damage in evas object.
+ * @param[in] data : Evas Object pointer for elm_win.
+ * @return return -1 if an error occurred. Otherwise return 1.
+ */
+static int alpm_module_update_clock(void *module_ops, void *data)
+{
+       alpm_module_data *alpm_md;
+       alpm_clock_plugin_module_ops *ops;
+
+       _E("update clock!");
+
+       ops = (alpm_clock_plugin_module_ops *)module_ops;
+       if (!ops) {
+               _E("ops is NULL!!");
+               return -1;
+       }
+
+       if (!data) {
+               _E("data is NULL!!");
+               return -1;
+       }
+
+       alpm_md = ops->modules.priv;
+       if (!alpm_md) {
+               _E("alpm_md is NULL!");
+               return -1;
+       }
+
+       /* update time and rendering for ALPM clock */
+       _set_analog(alpm_md);
+
+       return ALPM_NEED_UPDATE;
+}
+
+/**
+ * @brief Initialize ALPM clock plugin module.
+ * @param[in] ops : plugin module ops.
+ * @return return -1 if an error occurred. Otherwise return 1.
+ */
+ALPM_CLOCK_PLUGIN_EXPORT_API int ALPM_CLOCK_PLUGIN_MODULE_INIT(alpm_clock_plugin_module_ops *ops)
+{
+    alpm_module_data *alpm_md;
+
+    _D("ALPM_CLOCK_PLUGIN_MODULE INIT!!");
+    if( !ops )
+        return -1;
+
+    alpm_md = calloc(1, sizeof(alpm_module_data));
+    if( !alpm_md )
+        return -1;
+
+    ops->modules.ui_runtime_plugin_init = alpm_module_init;
+    ops->modules.ui_runtime_plugin_deinit = alpm_module_deinit;
+    ops->modules.ui_runtime_plugin_update_clock = alpm_module_update_clock;
+    ops->modules.priv = alpm_md;
+
+    return 1;
+}
+
+/**
+ * @brief Exit ALPM clock plugin module.
+ * @param[in] ops : plugin module ops.
+ * @return return -1 if an error occurred. Otherwise return 1.
+ */
+ALPM_CLOCK_PLUGIN_EXPORT_API int ALPM_CLOCK_PLUGIN_MODULE_EXIT(alpm_clock_plugin_module_ops *ops)
+{
+    alpm_module_data *alpm_md;
+
+    _D("ALPM_CLOCK_PLUGIN_MODULE EXIT!!");
+    if( !ops )
+        return -1;
+
+    alpm_md = ops->modules.priv;
+    if( alpm_md )
+        free(alpm_md);
+
+    return 1;
+}
+
+/**
+ * @brief Update Locale information for ALPM clock plugin module.
+ * @param[in] ops : plugin module ops.
+ * @return return -1 if an error occurred. Otherwise return 1.
+ */
+ALPM_CLOCK_PLUGIN_EXPORT_API int ALPM_CLOCK_PLUGIN_MODULE_LOCALE_UPDATE(alpm_clock_plugin_module_ops *ops)
+{
+    alpm_module_data *alpm_md;
+
+    _D("ALPM_CLOCK_PLUGIN_MODULE_LOCALE_UPDATE!!");
+    if( !ops )
+        return -1;
+
+    alpm_md = ops->modules.priv;
+    if( !alpm_md )
+        return -1;
+
+    return 1;
+}
diff --git a/default-clock/src/digital.c b/default-clock/src/digital.c
new file mode 100644 (file)
index 0000000..032f543
--- /dev/null
@@ -0,0 +1,936 @@
+/*
+ *  W Clock Viewer
+ *
+ * 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 <glib.h>
+#include <stdio.h>
+#include <vconf.h>
+#include <vconf-keys.h>
+#include <math.h>
+
+#include "clock-viewer-plugin.h"
+#include "alpm.h"
+
+static Evas_Object *_add_layout(Evas_Object *parent, const char *file, const char *group)
+{
+       _D("%s", __func__);
+       Evas_Object *eo = NULL;
+       int r = -1;
+
+       retvm_if(parent == NULL, NULL, "Invalid argument: parent is NULL\n");
+       retvm_if(file == NULL, NULL, "Invalid argument: file is NULL\n");
+       retvm_if(group == NULL, NULL, "Invalid argument: group is NULL\n");
+
+       eo = elm_layout_add(parent);
+       retvm_if(eo == NULL, NULL, "Failed to add layout\n");
+
+       r = elm_layout_file_set(eo, file, group);
+       if (!r) {
+               _E("Failed to set file[%s]\n", file);
+               evas_object_del(eo);
+               return NULL;
+       }
+
+       evas_object_size_hint_weight_set(eo, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_show(eo);
+       return eo;
+}
+
+static char* __get_timezone(void)
+{
+       char buf[1024];
+       ssize_t len = readlink("/opt/etc/localtime", buf, sizeof(buf)-1);
+
+       if (len != -1) {
+               buf[len] = '\0';
+       }
+       else {
+               /* handle error condition */
+               _E("readlink() failed");
+               return vconf_get_str(VCONFKEY_SETAPPL_TIMEZONE_ID);
+       }
+       return strdup(buf+20);
+}
+
+static char *__get_locale(void)
+{
+       char *locale = vconf_get_str(VCONFKEY_REGIONFORMAT);
+       if(locale == NULL) {
+               _E("vconf_get_str() failed : region format");
+               return strdup("en_US");
+       }
+
+       char *str = NULL;
+       int count = 0;
+       gchar **ptr = NULL;
+       gchar **split_str = NULL;
+
+       split_str = g_strsplit(locale, ".", 0);
+
+       for(ptr = split_str; *ptr; ptr++) {
+               count++;
+       }
+
+       _D("count:%d", count);
+       _D("orig_locale:%s", locale);
+
+       if(count == 2) {
+               if(!strcmp(split_str[1], "UTF-8")) {
+                       str = g_strdup_printf("%s", split_str[0]);
+                       free(locale);
+                       _D("dest_locale:%s", str);
+                       g_strfreev(split_str);
+                       return str;
+               } else {
+                       g_strfreev(split_str);
+                       return locale;
+               }
+       } else {
+               g_strfreev(split_str);
+               return locale;
+       }
+}
+
+static UDateTimePatternGenerator *__get_generator(void *data)
+{
+       _D("");
+
+       UErrorCode status = U_ZERO_ERROR;
+       UDateTimePatternGenerator *generator = NULL;
+
+       UChar u_skeleton[64] = {0,};
+
+       alpm_module_data *alpm_md = data;
+       retv_if(alpm_md == NULL, NULL);
+
+
+       uloc_setDefault(getenv("LC_TIME"), &status);
+       if (U_FAILURE(status)) {
+               _E("uloc_setDefault() is failed.");
+               return NULL;
+       }
+
+       u_uastrncpy(u_skeleton, "hhmm", strlen("hhmm"));
+
+       if(alpm_md->timeregion_format == NULL) {
+               alpm_md->timeregion_format = __get_locale();
+       }
+
+       generator = udatpg_open(alpm_md->timeregion_format, &status);
+       if(U_FAILURE(status)) {
+               _E("udatpg_open() failed");
+               generator = NULL;
+               return NULL;
+       }
+
+       _D("get_generator success");
+       return generator;
+}
+
+static UDateFormat *__get_time_formatter(void *data)
+{
+       _D("");
+
+       UErrorCode status = U_ZERO_ERROR;
+
+       UChar u_pattern[64] = {0,};
+       UChar u_timezone[64] = {0,};
+       UChar u_best_pattern[64] = {0,};
+       int32_t u_best_pattern_capacity;
+       UDateFormat *formatter = NULL;
+
+       alpm_module_data *alpm_md = data;
+       retv_if(alpm_md == NULL, NULL);
+
+       if(alpm_md->generator == NULL) {
+               alpm_md->generator = __get_generator(alpm_md);
+       }
+
+       /* only 12 format */
+       if(u_uastrncpy(u_pattern, "h:mm", sizeof(u_pattern)) == NULL) {
+               _E("u_uastrncpy() is failed.");
+               return NULL;
+       }
+
+       u_best_pattern_capacity =
+                       (int32_t) (sizeof(u_best_pattern) / sizeof((u_best_pattern)[0]));
+
+       udatpg_getBestPattern(alpm_md->generator, u_pattern, u_strlen(u_pattern),
+                                                               u_best_pattern, u_best_pattern_capacity, &status);
+       if(U_FAILURE(status)) {
+               _E("udatpg_getBestPattern() failed");
+               return NULL;
+       }
+
+       /* remove am/pm of best pattern */
+       char a_best_pattern[64] = {0.};
+       char *buffer = NULL;
+       u_austrcpy(a_best_pattern, u_best_pattern);
+       _D("best pattern [%s]", a_best_pattern);
+       char *a_best_pattern_fixed = strtok_r(a_best_pattern, "a", &buffer);
+       a_best_pattern_fixed = strtok_r(a_best_pattern_fixed, " ", &buffer);
+       _D("best pattern fixed [%s]", a_best_pattern_fixed);
+
+       if(a_best_pattern_fixed) {
+               /* exception - da_DK */
+               if(strncmp(alpm_md->timeregion_format, "da_DK", 5) == 0
+               || strncmp(alpm_md->timeregion_format, "mr_IN", 5) == 0){
+
+                       char *a_best_pattern_changed = g_strndup("h:mm", 4);
+                       _D("best pattern is changed [%s]", a_best_pattern_changed);
+                       if(a_best_pattern_changed) {
+                               u_uastrcpy(u_best_pattern, a_best_pattern_changed);
+                               g_free(a_best_pattern_changed);
+                       }
+               }
+               else {
+                       u_uastrcpy(u_best_pattern, a_best_pattern_fixed);
+               }
+       }
+
+       /* change char to UChar */
+       u_strncpy(u_pattern, u_best_pattern, sizeof(u_pattern));
+
+       /* get formatter */
+       u_uastrncpy(u_timezone, alpm_md->timezone_id, sizeof(u_timezone));
+       formatter = udat_open(UDAT_IGNORE, UDAT_IGNORE, alpm_md->timeregion_format, u_timezone, -1,
+                                                       u_pattern, -1, &status);
+       if (U_FAILURE(status)) {
+               _E("udat_open() is failed.");
+               return NULL;
+       }
+
+       _D("getting time formatter success");
+       return formatter;
+}
+
+static UDateFormat *__get_time_formatter_24(void *data)
+{
+       _D("");
+
+       UErrorCode status = U_ZERO_ERROR;
+
+       UChar u_pattern[64] = {0,};
+       UChar u_timezone[64] = {0,};
+       UChar u_best_pattern[64] = {0,};
+       int32_t u_best_pattern_capacity;
+       UDateFormat *formatter = NULL;
+
+       alpm_module_data *alpm_md = data;
+       retv_if(alpm_md == NULL, NULL);
+
+       if(alpm_md->generator == NULL) {
+               alpm_md->generator = __get_generator(alpm_md);
+       }
+
+       /* only 12 format */
+       if(u_uastrncpy(u_pattern, "H:mm", sizeof(u_pattern)) == NULL) {
+               _E("u_uastrncpy() is failed.");
+               return NULL;
+       }
+
+       u_best_pattern_capacity =
+                       (int32_t) (sizeof(u_best_pattern) / sizeof((u_best_pattern)[0]));
+
+       udatpg_getBestPattern(alpm_md->generator, u_pattern, u_strlen(u_pattern),
+                                                               u_best_pattern, u_best_pattern_capacity, &status);
+       if(U_FAILURE(status)) {
+               _E("udatpg_getBestPattern() failed");
+               return NULL;
+       }
+
+       /* remove am/pm of best pattern */
+       char a_best_pattern[64] = {0.};
+       char *buffer = NULL;
+       u_austrcpy(a_best_pattern, u_best_pattern);
+       _D("best pattern [%s]", a_best_pattern);
+       char *a_best_pattern_fixed = strtok_r(a_best_pattern, "a", &buffer);
+       a_best_pattern_fixed = strtok_r(a_best_pattern_fixed, " ", &buffer);
+       _D("best pattern fixed [%s]", a_best_pattern_fixed);
+
+       if(a_best_pattern_fixed) {
+               /* exception - pt_BR(HH'h'mm), id_ID, da_DK */
+               if(strncmp(a_best_pattern_fixed, "HH'h'mm", 7) == 0
+                       || strncmp(alpm_md->timeregion_format, "id_ID", 5) == 0
+                       || strncmp(alpm_md->timeregion_format, "da_DK", 5) == 0
+                       || strncmp(alpm_md->timeregion_format, "mr_IN", 5) == 0){
+
+                       char *a_best_pattern_changed = g_strndup("HH:mm", 5);
+                       _D("best pattern is changed [%s]", a_best_pattern_changed);
+                       if(a_best_pattern_changed) {
+                               u_uastrcpy(u_best_pattern, a_best_pattern_changed);
+                               g_free(a_best_pattern_changed);
+                       }
+               }
+               else {
+                       u_uastrcpy(u_best_pattern, a_best_pattern_fixed);
+               }
+       }
+
+       /* change char to UChar */
+       u_strncpy(u_pattern, u_best_pattern, sizeof(u_pattern));
+
+       /* get formatter */
+       u_uastrncpy(u_timezone, alpm_md->timezone_id, sizeof(u_timezone));
+       formatter = udat_open(UDAT_IGNORE, UDAT_IGNORE, alpm_md->timeregion_format, u_timezone, -1,
+                                                       u_pattern, -1, &status);
+       if (U_FAILURE(status)) {
+               _E("udat_open() is failed.");
+               return NULL;
+       }
+
+       _D("getting time formatter success");
+       return formatter;
+}
+
+static UDateFormat *__get_date_formatter(void *data)
+{
+       _D("");
+
+       UErrorCode status = U_ZERO_ERROR;
+       UChar u_timezone[64] = {0,};
+       UChar u_skeleton[64] = {0,};
+       int skeleton_len = 0;
+
+       UChar u_best_pattern[64] = {0,};
+       int32_t u_best_pattern_capacity;
+       UDateFormat *formatter = NULL;
+
+       alpm_module_data *alpm_md = data;
+       retv_if(alpm_md == NULL, NULL);
+
+       u_uastrncpy(u_skeleton, "MMMEd", strlen("MMMEd"));
+       skeleton_len = u_strlen(u_skeleton);
+
+       u_best_pattern_capacity =
+                                       (int32_t) (sizeof(u_best_pattern) / sizeof((u_best_pattern)[0]));
+       udatpg_getBestPattern(alpm_md->generator, u_skeleton, skeleton_len,
+                                                       u_best_pattern, u_best_pattern_capacity, &status);
+       if(U_FAILURE(status)) {
+               _E("udatpg_getBestPattern() failed");
+               return NULL;
+       }
+
+       if(strncmp(alpm_md->timeregion_format, "fi_FI", 5) == 0) {
+               char *a_best_pattern_changed = g_strndup("ccc, d. MMM", 11);
+               _D("date formatter best pattern is changed [%s]", a_best_pattern_changed);
+               if(a_best_pattern_changed) {
+                       u_uastrcpy(u_best_pattern, a_best_pattern_changed);
+                       g_free(a_best_pattern_changed);
+               }
+       }
+
+       /* get formatter */
+       u_uastrncpy(u_timezone, alpm_md->timezone_id, sizeof(u_timezone));
+       formatter = udat_open(UDAT_IGNORE, UDAT_IGNORE, alpm_md->timeregion_format, u_timezone, -1,
+                                                       u_best_pattern, -1, &status);
+       if (U_FAILURE(status)) {
+               _E("udat_open() is failed.");
+               return NULL;
+       }
+
+       _D("getting date formatter success");
+
+       return formatter;
+
+}
+
+
+static UDateFormat *__get_ampm_formatter(void *data)
+{
+       _D("");
+
+       UErrorCode status = U_ZERO_ERROR;
+
+       char a_best_pattern[64] = {0.};
+
+       UChar u_timezone[64] = {0,};
+       UChar u_skeleton[64] = {0,};
+       int skeleton_len = 0;
+
+       UChar u_best_pattern[64] = {0,};
+       int32_t u_best_pattern_capacity;
+       UDateFormat *formatter = NULL;
+
+       alpm_module_data *alpm_md = data;
+       retv_if(alpm_md == NULL, NULL);
+
+       u_uastrncpy(u_skeleton, "hhmm", strlen("hhmm"));
+       skeleton_len = u_strlen(u_skeleton);
+
+       u_best_pattern_capacity =
+                                       (int32_t) (sizeof(u_best_pattern) / sizeof((u_best_pattern)[0]));
+       udatpg_getBestPattern(alpm_md->generator, u_skeleton, skeleton_len,
+                                                       u_best_pattern, u_best_pattern_capacity, &status);
+       if(U_FAILURE(status)) {
+               _E("udatpg_getBestPattern() failed");
+               return NULL;
+       }
+
+       u_austrcpy(a_best_pattern, u_best_pattern);
+       u_uastrcpy(u_best_pattern, "a");
+
+       if(a_best_pattern[0] == 'a') {
+               alpm_md->is_pre = EINA_TRUE;
+       } else {
+               alpm_md->is_pre = EINA_FALSE;
+       }
+
+       /* get formatter */
+       u_uastrncpy(u_timezone, alpm_md->timezone_id, sizeof(u_timezone));
+       formatter = udat_open(UDAT_IGNORE, UDAT_IGNORE, alpm_md->timeregion_format, u_timezone, -1,
+                                                       u_best_pattern, -1, &status);
+       if (U_FAILURE(status)) {
+               _E("udat_open() is failed.");
+               return NULL;
+       }
+
+       _D("getting ampm formatter success");
+
+       return formatter;
+
+}
+
+static UChar *uastrcpy(const char *chars)
+{
+       int len = 0;
+       UChar *str = NULL;
+       len = strlen(chars);
+       str = (UChar *) malloc(sizeof(UChar) *(len + 1));
+       if (!str)
+               return NULL;
+       u_uastrcpy(str, chars);
+       return str;
+}
+
+static void __set_icu_timezone(const char *timezone)
+{
+       _D("%s", __func__);
+       if(timezone == NULL) {
+               _E("TIMEZONE is NULL");
+               return;
+       }
+
+       UErrorCode ec = U_ZERO_ERROR;
+       UChar *str = uastrcpy(timezone);
+
+       if (!str) {
+               _E("Failed to string about timezone");
+               return;
+       }
+
+       ucal_setDefaultTimeZone(str, &ec);
+       if (U_SUCCESS(ec)) {
+       } else {
+               _E("ucal_setDefaultTimeZone() FAILED : %s ",
+                             u_errorName(ec));
+       }
+       free(str);
+}
+
+static void __set_formatters(void *data)
+{
+       alpm_module_data *alpm_md = data;
+       ret_if(alpm_md == NULL);
+
+       /* generator */
+       alpm_md->generator = __get_generator(alpm_md);
+       /* time formatter */
+       alpm_md->formatter_time = __get_time_formatter(alpm_md);
+       /* ampm formatter */
+       alpm_md->formatter_ampm = __get_ampm_formatter(alpm_md);
+       /* 24 time formatter */
+       alpm_md->formatter_time_24 = __get_time_formatter_24(alpm_md);
+       /* date formatter */
+       alpm_md->formatter_date = __get_date_formatter(alpm_md);
+}
+
+static void __remove_formatters(void *data)
+{
+       alpm_module_data *alpm_md = data;
+       ret_if(alpm_md == NULL);
+
+       if(alpm_md->generator) {
+               udat_close(alpm_md->generator);
+               alpm_md->generator = NULL;
+       }
+       if(alpm_md->formatter_time) {
+               udat_close(alpm_md->formatter_time);
+               alpm_md->formatter_time = NULL;
+       }
+       if(alpm_md->formatter_ampm) {
+               udat_close(alpm_md->formatter_ampm);
+               alpm_md->formatter_ampm = NULL;
+       }
+       if(alpm_md->formatter_time_24) {
+               udat_close(alpm_md->formatter_time_24);
+               alpm_md->formatter_time_24 = NULL;
+       }
+       if(alpm_md->formatter_date) {
+               udat_close(alpm_md->formatter_date);
+               alpm_md->formatter_date = NULL;
+       }
+}
+/**
+ * @brief Initialize ALPM UI.
+ * @param[in] data : Evas Object pointer for elm_win.
+ * @return return -1 if an error occurred. Otherwise return 1.
+ */
+static int alpm_module_init(void *module_ops, void *data)
+{
+       alpm_module_data *alpm_md;
+       alpm_clock_plugin_module_ops *ops;
+
+       _E("module init!!");
+       ops = (alpm_clock_plugin_module_ops *)module_ops;
+       if (!ops) {
+               _E("ops is NULL!!");
+               return -1;
+       }
+
+       if(!data) {
+               _E("data is NULL!!");
+               return -1;
+       }
+
+       alpm_md = ops->modules.priv;
+       if(!alpm_md) {
+               _E("alpm_md is NULL!");
+               return -1;
+       }
+
+       alpm_md->parent = (Evas_Object *)data;
+
+       /* Implement main layout for ALPM clock */
+       //Add BG
+       if (!alpm_md->bg) {
+               alpm_md->bg = elm_bg_add(alpm_md->parent);
+               evas_object_size_hint_weight_set(alpm_md->bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+               elm_win_resize_object_add(alpm_md->parent, alpm_md->bg);
+               evas_object_show(alpm_md->bg);
+       }
+
+       //Create main layout
+       if (!alpm_md->ly_main) {
+               alpm_md->ly_main = _add_layout(alpm_md->parent, EDJ_APP, "layout_clock_position");
+               evas_object_size_hint_weight_set(alpm_md->ly_main, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+               elm_win_resize_object_add(alpm_md->parent, alpm_md->ly_main);
+       }
+
+       alpm_md->timezone_id = __get_timezone();
+       __set_icu_timezone(alpm_md->timezone_id);
+       alpm_md->timeregion_format = __get_locale();
+       vconf_get_int(VCONFKEY_REGIONFORMAT_TIME1224, &alpm_md->timeformat);
+
+       _D("[%d][%s][%s]", alpm_md->timeformat, alpm_md->timeregion_format, alpm_md->timezone_id);
+
+       __remove_formatters(alpm_md);
+       __set_formatters(alpm_md);
+
+       return 1;
+}
+
+/**
+ * @brief clean up ALPM UI.
+ * @param[in] data : Evas Object pointer for elm_win.
+ * @return return -1 if an error occurred. Otherwise return 1.
+ */
+static int alpm_module_deinit(void *module_ops, void *data)
+{
+       alpm_module_data *alpm_md;
+       alpm_clock_plugin_module_ops *ops;
+
+       _E("module deinit!!");
+
+       ops = (alpm_clock_plugin_module_ops *)module_ops;
+       if (!ops) {
+               _E("ops is NULL!!");
+               return -1;
+       }
+
+       if (!data) {
+               _E("data is NULL!!");
+               return -1;
+       }
+
+       alpm_md = ops->modules.priv;
+       if(!alpm_md) {
+               _E("alpm_md is NULL!");
+               return -1;
+       }
+
+       /* destroy main layout for ALPM clock */
+       FREEIF(alpm_md->timezone_id);
+       FREEIF(alpm_md->timeregion_format);
+       __remove_formatters(alpm_md);
+
+       if (alpm_md->bg) {
+           evas_object_del(alpm_md->bg);
+       }
+       if (alpm_md->ly_main) {
+           evas_object_del(alpm_md->ly_main);
+       }
+
+       if (ops->modules.priv) {
+           free(ops->modules.priv);
+           ops->modules.priv = NULL;
+           alpm_md = NULL;
+       }
+
+    return 1;
+}
+
+static int __get_formatted_ampm_from_utc_time(void *data, time_t intime, char *buf, int buf_len, int *ampm_len)
+{
+       alpm_module_data *alpm_md = (alpm_module_data *)data;
+       retv_if(alpm_md == NULL, -1);
+       retv_if(alpm_md->formatter_ampm == NULL, -1);
+
+       UDate u_time = (UDate)intime * 1000;
+       UChar u_formatted_str[64] = {0,};
+       int32_t u_formatted_str_capacity;
+       int formatted_str_len = -1;
+       UErrorCode status = U_ZERO_ERROR;
+
+       /* calculate formatted string capacity */
+       u_formatted_str_capacity =
+                       (int32_t)(sizeof(u_formatted_str) / sizeof((u_formatted_str)[0]));
+
+       /* fomatting date using formatter */
+       formatted_str_len = udat_format(alpm_md->formatter_ampm, u_time, u_formatted_str, u_formatted_str_capacity,
+                                                                       NULL, &status);
+       if(U_FAILURE(status)) {
+               _E("udat_format() failed");
+               return -1;
+       }
+
+       if(formatted_str_len <= 0)
+               _E("formatted_str_len is less than 0");
+
+       (*ampm_len) = u_strlen(u_formatted_str);
+
+       buf = u_austrncpy(buf, u_formatted_str, buf_len);
+       _SECURE_D("ampm:(%d)[%s][%d]", formatted_str_len, buf, intime);
+
+       return 0;
+}
+static int __get_formatted_time_from_utc_time(void *data, time_t intime, char *buf, int buf_len, Eina_Bool is_time_24)
+{
+       alpm_module_data *alpm_md = (alpm_module_data *)data;
+       retv_if(alpm_md == NULL, -1);
+
+       UDate u_time = (UDate)intime * 1000;
+       UChar u_formatted_str[64] = {0,};
+       int32_t u_formatted_str_capacity;
+       int formatted_str_len = -1;
+       UErrorCode status = U_ZERO_ERROR;
+
+       /* calculate formatted string capacity */
+       u_formatted_str_capacity =
+                       (int32_t)(sizeof(u_formatted_str) / sizeof((u_formatted_str)[0]));
+
+       /* fomatting date using formatter */
+       if(is_time_24) {
+               retv_if(alpm_md->formatter_time_24 == NULL, -1);
+               formatted_str_len = udat_format(alpm_md->formatter_time_24, u_time, u_formatted_str, u_formatted_str_capacity,
+                                                               NULL, &status);
+       } else {
+               retv_if(alpm_md->formatter_time == NULL, -1);
+               formatted_str_len = udat_format(alpm_md->formatter_time, u_time, u_formatted_str, u_formatted_str_capacity,
+                                                               NULL, &status);
+       }
+       if(U_FAILURE(status)) {
+               _E("udat_format() failed");
+               return -1;
+       }
+
+       if(formatted_str_len <= 0)
+               _E("formatted_str_len is less than 0");
+
+       buf = u_austrncpy(buf, u_formatted_str, buf_len);
+       _SECURE_D("time:(%d)[%s][%d]", formatted_str_len, buf, intime);
+
+       return 0;
+}
+
+static void _get_random_distance(int radius, int* dx, int* dy)
+{
+       srand(time(NULL));
+
+       unsigned int seed = time(NULL);
+       int random = rand_r(&seed);
+
+       *dx = (int)round(sin(random) * radius);
+       *dy = (int)round(cos(random) * radius);
+}
+
+static void _get_random_position(const int radius, const int width, const int height, int* position_x, int* position_y)
+{
+       if (!position_x || !position_y)
+               return;
+
+       int dx = 0;
+       int dy = 0;
+       _get_random_distance(radius, &dx, &dy);
+
+       const int center_x = 180 - width / 2;
+       const int center_y = 180 - height / 2;
+
+       *position_x = center_x + dx;
+       *position_y = center_y + dy;
+}
+
+static void _set_info_time(void *data)
+{
+    alpm_module_data *alpm_md = (alpm_module_data *)data;
+    if (alpm_md == NULL) {
+        _D("appdata is NULL");
+        return;
+    }
+
+    struct tm ts;
+       struct tm *ret_tm = NULL;
+    time_t tt;
+    char bf1[32] = { 0, };
+    int hour, minute;
+    int err_code = 0;
+    int regionformat_value = 0;
+
+    tt = time(NULL);
+    ret_tm = localtime_r(&tt, &ts);
+    if (!ret_tm) {
+               _E("Failed to get the local time");
+               return;
+    }
+
+    _D("TIME[%d]:[%d] DAY[%d]", ts.tm_hour, ts.tm_min, ts.tm_mday);
+
+    /* if %l is 1 ~9, it has blank space in front. Trim it using atoi function */
+    strftime(bf1, sizeof(bf1), "%H", &ts);
+    hour = atoi(bf1);
+    _D("hour %d", hour);
+    strftime(bf1, sizeof(bf1), "%M", &ts);
+    minute = atoi(bf1);
+    _D("minute %d", minute);
+
+    err_code = vconf_get_int(VCONFKEY_REGIONFORMAT_TIME1224, &regionformat_value);
+    if(err_code != 0) {
+        _E("vconf_get_int(VCONFKEY_REGIONFORMAT_TIME1224) error");
+    }
+
+    if (alpm_md->ly_clock) {
+        evas_object_del(alpm_md->ly_clock);
+        alpm_md->ly_clock = NULL;
+    }
+
+    alpm_md->ly_clock = _add_layout(alpm_md->ly_main, EDJ_APP, "layout_clock_tb");
+    edje_object_signal_emit(elm_layout_edje_get(alpm_md->ly_main), "elm.swallow.body.middle4", "elm.swallow.body");
+
+    char utc_time[256] = { 0 };
+    char utc_ampm[256] = { 0 };
+    int ampm_length = 0;
+    Eina_Bool is_pre = alpm_md->is_pre;
+    Eina_Bool is_24hour = EINA_FALSE;
+
+    if(alpm_md->timeformat == VCONFKEY_TIME_FORMAT_12) {
+        __get_formatted_ampm_from_utc_time(alpm_md, tt, utc_ampm, sizeof(utc_ampm), &ampm_length);
+        __get_formatted_time_from_utc_time(alpm_md, tt, utc_time, sizeof(utc_time), EINA_FALSE);
+        is_24hour = EINA_FALSE;
+    } else {
+        __get_formatted_time_from_utc_time(alpm_md, tt, utc_time, sizeof(utc_time), EINA_TRUE);
+        is_24hour = EINA_TRUE;
+    }
+
+    _D("utc_time=%s, utc_ampm=[%d]%s", utc_time, ampm_length, utc_ampm);
+
+    if(ampm_length >= 3) {
+        _D("AM PM string is too long, changed to default AM/PM");
+
+        if(strncmp(alpm_md->timeregion_format, "fa", 2) == 0)
+        {
+            _D("In Farsi, AM/PM text abbreviated.");
+
+            if (ts.tm_hour >= 0 && ts.tm_hour < 12)
+                snprintf(utc_ampm, sizeof(utc_ampm), "%s", "ق.ظ");
+            else
+                snprintf(utc_ampm, sizeof(utc_ampm), "%s", "ب.ظ");
+        }
+        else
+        {
+            if (ts.tm_hour >= 0 && ts.tm_hour < 12)
+                snprintf(utc_ampm, sizeof(utc_ampm), "%s", "AM");
+            else
+                snprintf(utc_ampm, sizeof(utc_ampm), "%s", "PM");
+        }
+    }
+
+    char *time_str = NULL;
+
+    if(is_24hour == EINA_TRUE){
+        time_str = g_strdup_printf("%s", utc_time);
+    }
+    else {
+        if(is_pre== EINA_TRUE)
+            time_str = g_strdup_printf("<font_size=32><font=SamsungSans:style=Regular>%s</font></font_size>%s", utc_ampm, utc_time);
+        else {
+            time_str = g_strdup_printf("%s<font_size=32><font=SamsungSans:style=Regular> %s</font></font_size>", utc_time, utc_ampm);
+        }
+    }
+    _D("time_str=%s", time_str);
+
+    elm_object_part_text_set(alpm_md->ly_clock, "text.clock", time_str);
+
+    g_free(time_str);
+
+    // radius can be modified if text is not clipped.
+    const int movable_radius = 40;
+    //TODO need to set as exact size
+    const int width = 280;
+    const int height = 100;
+    evas_object_resize(alpm_md->ly_clock, width, height);
+
+    int position_x = 0;
+    int position_y = 0;
+    _get_random_position(movable_radius, width, height, &position_x, &position_y);
+    evas_object_move(alpm_md->ly_clock, position_x, position_y);
+
+    evas_object_show(alpm_md->ly_clock);
+}
+
+/**
+ * @brief Update ALPM UI.
+ *        Evas Rendering will be done in alpm parent modules.
+ *        So in alpm_module_update_clock(), just update clock infomation and add damage in evas object.
+ * @param[in] data : Evas Object pointer for elm_win.
+ * @return return -1 if an error occurred. Otherwise return 1.
+ */
+static int alpm_module_update_clock(void *module_ops, void *data)
+{
+       alpm_module_data *alpm_md;
+       alpm_clock_plugin_module_ops *ops;
+
+       _E("update clock!");
+
+       ops = (alpm_clock_plugin_module_ops *)module_ops;
+       if (!ops) {
+               _E("ops is NULL!!");
+               return -1;
+       }
+
+       if (!data) {
+               _E("data is NULL!!");
+               return -1;
+       }
+
+       alpm_md = ops->modules.priv;
+       if (!alpm_md) {
+               _E("alpm_md is NULL!");
+               return -1;
+       }
+
+       /* update time and rendering for ALPM clock */
+       _set_info_time(alpm_md);
+
+       return ALPM_NEED_UPDATE;
+}
+
+/**
+ * @brief Initialize ALPM clock plugin module.
+ * @param[in] ops : plugin module ops.
+ * @return return -1 if an error occurred. Otherwise return 1.
+ */
+ALPM_CLOCK_PLUGIN_EXPORT_API int ALPM_CLOCK_PLUGIN_MODULE_INIT(alpm_clock_plugin_module_ops *ops)
+{
+    alpm_module_data *alpm_md;
+
+    _D("ALPM_CLOCK_PLUGIN_MODULE INIT!!");
+    if( !ops )
+        return -1;
+
+    alpm_md = calloc(1, sizeof(alpm_module_data));
+    if( !alpm_md )
+        return -1;
+
+    ops->modules.ui_runtime_plugin_init = alpm_module_init;
+    ops->modules.ui_runtime_plugin_deinit = alpm_module_deinit;
+    ops->modules.ui_runtime_plugin_update_clock = alpm_module_update_clock;
+    ops->modules.priv = alpm_md;
+
+    return 1;
+}
+
+/**
+ * @brief Exit ALPM clock plugin module.
+ * @param[in] ops : plugin module ops.
+ * @return return -1 if an error occurred. Otherwise return 1.
+ */
+ALPM_CLOCK_PLUGIN_EXPORT_API int ALPM_CLOCK_PLUGIN_MODULE_EXIT(alpm_clock_plugin_module_ops *ops)
+{
+    alpm_module_data *alpm_md;
+
+    _D("ALPM_CLOCK_PLUGIN_MODULE EXIT!!");
+    if( !ops )
+        return -1;
+
+    alpm_md = ops->modules.priv;
+    if( alpm_md )
+        free(alpm_md);
+
+    return 1;
+}
+
+/**
+ * @brief Update Locale information for ALPM clock plugin module.
+ * @param[in] ops : plugin module ops.
+ * @return return -1 if an error occurred. Otherwise return 1.
+ */
+ALPM_CLOCK_PLUGIN_EXPORT_API int ALPM_CLOCK_PLUGIN_MODULE_LOCALE_UPDATE(alpm_clock_plugin_module_ops *ops)
+{
+    alpm_module_data *alpm_md;
+
+    _D("ALPM_CLOCK_PLUGIN_MODULE_LOCALE_UPDATE!!");
+    if( !ops )
+        return -1;
+
+    alpm_md = ops->modules.priv;
+    if( !alpm_md )
+        return -1;
+
+    /* Update locale information. */
+    if( alpm_md->timezone_id ) {
+        free(alpm_md->timezone_id);
+        alpm_md->timezone_id = NULL;
+    }
+    if( alpm_md->timeregion_format ) {
+        free(alpm_md->timeregion_format);
+        alpm_md->timeregion_format = NULL;
+    }
+
+    alpm_md->timezone_id = __get_timezone();
+    __set_icu_timezone(alpm_md->timezone_id);
+    alpm_md->timeregion_format = __get_locale();
+    vconf_get_int(VCONFKEY_REGIONFORMAT_TIME1224, &alpm_md->timeformat);
+
+    _D("[%d][%s][%s]", alpm_md->timeformat, alpm_md->timeregion_format, alpm_md->timezone_id);
+
+    __remove_formatters(alpm_md);
+    __set_formatters(alpm_md);
+
+    return 1;
+}
+
diff --git a/packaging/org.tizen.w-clock-viewer.spec b/packaging/org.tizen.w-clock-viewer.spec
new file mode 100644 (file)
index 0000000..d20bb7d
--- /dev/null
@@ -0,0 +1,85 @@
+Name:  org.tizen.w-clock-viewer
+Summary:       Clock viewer for the wearable devices
+Version:       0.0.1
+Release:       1
+Group: Applications/System
+License:       Apache-2.0
+Source0:       %{name}-%{version}.tar.gz
+
+BuildRequires: pkgconfig(capi-appfw-application)
+BuildRequires: pkgconfig(capi-system-device)
+BuildRequires: pkgconfig(elementary)
+BuildRequires: pkgconfig(minicontrol-monitor)
+BuildRequires: pkgconfig(minicontrol-viewer)
+BuildRequires: pkgconfig(minicontrol-handler)
+BuildRequires: pkgconfig(widget_viewer_evas)
+BuildRequires: pkgconfig(widget_service)
+BuildRequires: pkgconfig(alarm-service)
+BuildRequires: pkgconfig(pkgmgr-info)
+BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(dlog)
+BuildRequires: edje-bin
+
+BuildRequires: cmake
+BuildRequires: model-build-features
+BuildRequires: hash-signer
+
+%description
+Clock viewer for wearable devices
+
+%prep
+%setup -q
+
+%define PREFIX /usr/apps/%{name}
+%define DATADIR /opt%{PREFIX}/data
+
+%build
+%if 0%{?tizen_build_binary_release_type_eng}
+export CFLAGS="$CFLAGS -DTIZEN_ENGINEER_MODE"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_ENGINEER_MODE"
+export FFLAGS="$FFLAGS -DTIZEN_ENGINEER_MODE"
+%endif
+
+%if 0%{?sec_build_binary_debug_enable}
+export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
+export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
+%endif
+
+RPM_OPT=`echo $CFLAGS|sed 's/-Wp,-D_FORTIFY_SOURCE=2//'`
+export CFLAGS=$RPM_OPT
+cmake  -DCMAKE_INSTALL_PREFIX="%{PREFIX}"
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+mkdir -p %{buildroot}/usr/share/license
+
+%define tizen_sign 1
+%define tizen_sign_base /usr/apps/%{name}
+%define tizen_sign_level platform
+%define tizen_author_sign 1
+%define tizen_dist_sign 1
+
+%post
+/usr/bin/signing-client/hash-signer-client.sh -a -d -p platform /usr/apps/%{name}
+
+INHOUSE_ID="5000"
+SETTING_LABEL="tizen::vconf::setting::admin"
+
+vconftool set -t int "memory/clock_viewer/clock_visibility" 0 -i -g $INHOUSE_ID -f -s $SETTING_LABEL
+vconftool set -t int "memory/clock_viewer/lcdon" 0 -i -g $INHOUSE_ID -f -s $SETTING_LABEL
+vconftool set -t int "memory/clock_viewer/lcdoff" 0 -i -g $INHOUSE_ID -f -s $SETTING_LABEL
+vconftool set -t int "memory/clock_viewer/clockdraw" 0 -i -g $INHOUSE_ID -f -s $SETTING_LABEL
+
+%files
+%manifest clock-viewer/%{name}.manifest
+%defattr(-,root,root,-)
+/usr/share/license/%{name}
+/usr/share/packages/%{name}.xml
+/etc/smack/accesses.d/%{name}.rule
+%{PREFIX}/*.xml
+%{PREFIX}/bin/*
+%{PREFIX}/res/*
+%{PREFIX}/shared/*