summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Dolzhenko <d.dolzhenko@samsung.com>2017-07-17 10:20:46 +0300
committerDenis Dolzhenko <d.dolzhenko@samsung.com>2017-07-17 10:25:46 +0300
commitfa2dd6c7993a40fbe4f07fd135a0bbb5e78e092e (patch)
tree66a058f31cadc3e1b1b50563ceac5ee5328d871b
parent6c77dc6fec66dd77537bd4a52775295bd7156561 (diff)
parent7a8bacdffabf88f07aaedeea85e5f845844f75bd (diff)
downloadidle-clock-digital-fa2dd6c7993a40fbe4f07fd135a0bbb5e78e092e.tar.gz
idle-clock-digital-fa2dd6c7993a40fbe4f07fd135a0bbb5e78e092e.tar.bz2
idle-clock-digital-fa2dd6c7993a40fbe4f07fd135a0bbb5e78e092e.zip
Merge remote-tracking branch 'origin/tizen_dev' into tizensubmit/tizen/20170802.125025submit/tizen/20170725.150321submit/tizen/20170717.124125
Change-Id: I52e7c9944bc71f1eb595b8811c985761beca4296
-rw-r--r--.cproject15
-rw-r--r--.gitignore14
-rw-r--r--Build/flags.mk12
-rw-r--r--Build/prepost.mk6
-rw-r--r--edje/images/default_digital_sec.pngbin0 -> 1735 bytes
-rw-r--r--[-rwxr-xr-x]inc/Config.h (renamed from inc/clock_view.h)29
-rw-r--r--inc/Resource.h26
-rwxr-xr-xinc/app_data.h56
-rwxr-xr-xinc/log.h124
-rwxr-xr-xinc/util.h56
-rw-r--r--project_def.prop12
-rwxr-xr-xres/edje/clock-digital.edc100
-rw-r--r--res/edje/defines.inl1
-rwxr-xr-xres/edje/idle-clock-digital.edc270
-rw-r--r--res/edje/main-layout.edc41
-rw-r--r--src/App/inc/DateTimeFormatter.h67
-rw-r--r--src/App/inc/DateTimeView.h34
-rw-r--r--src/App/inc/MainController.h56
-rw-r--r--src/App/inc/MainLayout.h33
-rw-r--r--src/App/inc/WatchApp.h74
-rw-r--r--src/App/src/DateTimeFormatter.cpp208
-rw-r--r--src/App/src/DateTimeView.cpp43
-rw-r--r--src/App/src/MainController.cpp135
-rw-r--r--src/App/src/MainLayout.cpp38
-rw-r--r--src/App/src/WatchApp.cpp214
-rw-r--r--src/Common/inc/Atspi.h154
-rw-r--r--src/Common/inc/BaseView.h82
-rw-r--r--src/Common/inc/Callback.h43
-rw-r--r--src/Common/inc/I18nString.h57
-rw-r--r--src/Common/inc/LangUtils.h149
-rw-r--r--src/Common/inc/Logger.h87
-rw-r--r--src/Common/inc/PathUtils.h73
-rw-r--r--src/Common/inc/View.h622
-rw-r--r--src/Common/inc/WatchWindow.h38
-rw-r--r--src/Common/src/I18nString.cpp137
-rw-r--r--src/Common/src/Logger.cpp45
-rw-r--r--src/Common/src/PathUtils.cpp142
-rw-r--r--src/Common/src/View.cpp163
-rw-r--r--src/Common/src/WatchWindow.cpp77
-rwxr-xr-xsrc/clock_view.c1288
-rwxr-xr-xsrc/debug.c53
-rwxr-xr-xsrc/main.c666
-rw-r--r--[-rwxr-xr-x]src/main.cpp (renamed from inc/window.h)17
-rwxr-xr-xsrc/window.c54
44 files changed, 2999 insertions, 2612 deletions
diff --git a/.cproject b/.cproject
index 50e107b..c0aeb2b 100644
--- a/.cproject
+++ b/.cproject
@@ -135,13 +135,15 @@
<listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
</option>
<option id="gnu.cpp.compiler.option.include.paths.471457378" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
- <listOptionValue builtIn="false" value="&quot;${workspace_loc:/DigitalWatch/DigitalWatch/inc}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/App/inc}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/Common/inc}&quot;"/>
</option>
<option id="sbi.gnu.cpp.compiler.option.frameworks.core.1948188719" name="Tizen-Frameworks" superClass="sbi.gnu.cpp.compiler.option.frameworks.core" valueType="userObjs">
<listOptionValue builtIn="false" value="Native_API"/>
</option>
- <option id="sbi.gnu.cpp.compiler.option.preprocessor.def.deprecation.1944366159" name="Defined symbols (-D)" superClass="sbi.gnu.cpp.compiler.option.preprocessor.def.deprecation" valueType="definedSymbols"/>
- <option id="gnu.cpp.compiler.option.dialect.std.1601782784" superClass="gnu.cpp.compiler.option.dialect.std" value="gnu.cpp.compiler.dialect.default" valueType="enumerated"/>
+ <option id="sbi.gnu.cpp.compiler.option.preprocessor.def.deprecation.1944366159" name="Defined symbols (-D)" superClass="sbi.gnu.cpp.compiler.option.preprocessor.def.deprecation"/>
+ <option id="gnu.cpp.compiler.option.dialect.std.1601782784" name="Language standard" superClass="gnu.cpp.compiler.option.dialect.std" value="gnu.cpp.compiler.dialect.c++11" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1156939550" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool command="clang" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.673472688" name="C Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.c.compiler">
@@ -257,7 +259,7 @@
<option id="sbi.gnu.c.compiler.option.frameworks.core.1120316379" name="Tizen-Frameworks" superClass="sbi.gnu.c.compiler.option.frameworks.core" valueType="userObjs">
<listOptionValue builtIn="false" value="Native_API"/>
</option>
- <option id="sbi.gnu.c.compiler.option.preprocessor.def.symbols.deprecation.47436355" name="Defined symbols (-D)" superClass="sbi.gnu.c.compiler.option.preprocessor.def.symbols.deprecation" valueType="definedSymbols"/>
+ <option id="sbi.gnu.c.compiler.option.preprocessor.def.symbols.deprecation.47436355" name="Defined symbols (-D)" superClass="sbi.gnu.c.compiler.option.preprocessor.def.symbols.deprecation"/>
<option id="gnu.c.compiler.option.dialect.std.1717910620" name="Language standard" superClass="gnu.c.compiler.option.dialect.std" value="gnu.c.compiler.dialect.default" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.712765063" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
@@ -516,11 +518,14 @@
<listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
</option>
<option id="gnu.cpp.compiler.option.include.paths.46682391" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
- <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/DigitalWatch/DigitalWatch/inc}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/App/inc}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/Common/inc}&quot;"/>
</option>
<option id="sbi.gnu.cpp.compiler.option.frameworks.core.1516031646" name="Tizen-Frameworks" superClass="sbi.gnu.cpp.compiler.option.frameworks.core" valueType="userObjs">
<listOptionValue builtIn="false" value="Native_API"/>
</option>
+ <option id="gnu.cpp.compiler.option.dialect.std.742288624" name="Language standard" superClass="gnu.cpp.compiler.option.dialect.std" value="gnu.cpp.compiler.dialect.c++11" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.209804161" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool command="clang" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.1890430938" name="C Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.c.compiler">
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..417846b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,14 @@
+Debug/
+Release/
+crash-info
+.sign
+.checkers
+*~
+/SA_Report
+.rds_delta
+.sdk_delta.info
+.settings/
+org.tizen.w-message-Test-result.xml
+.package-stamp
+.svace-dir
+*.edj
diff --git a/Build/flags.mk b/Build/flags.mk
index 0ee8efb..39e3e39 100644
--- a/Build/flags.mk
+++ b/Build/flags.mk
@@ -1,13 +1,13 @@
-DEBUG_OP = -g3
-CPP_DEBUG_OP =
+DEBUG_OP =
+CPP_DEBUG_OP = -g3
-OPTIMIZATION_OP = -O0
-CPP_OPTIMIZATION_OP =
+OPTIMIZATION_OP =
+CPP_OPTIMIZATION_OP = -O0
-COMPILE_FLAGS = $(DEBUG_OP) $(OPTIMIZATION_OP) -Wall -c -fmessage-length=0
+COMPILE_FLAGS = $(DEBUG_OP) $(OPTIMIZATION_OP)
-CPP_COMPILE_FLAGS = $(CPP_DEBUG_OP) $(CPP_OPTIMIZATION_OP)
+CPP_COMPILE_FLAGS = $(CPP_DEBUG_OP) $(CPP_OPTIMIZATION_OP) -std=c++0x -Wall -c -fmessage-length=0
LINK_FLAGS =
diff --git a/Build/prepost.mk b/Build/prepost.mk
deleted file mode 100644
index 6bb5e2f..0000000
--- a/Build/prepost.mk
+++ /dev/null
@@ -1,6 +0,0 @@
-
-# Add pre/post build process
-PREBUILD_DESC =
-PREBUILD_COMMAND =
-POSTBUILD_DESC =
-POSTBUILD_COMMAND =
diff --git a/edje/images/default_digital_sec.png b/edje/images/default_digital_sec.png
new file mode 100644
index 0000000..9ef7e3b
--- /dev/null
+++ b/edje/images/default_digital_sec.png
Binary files differ
diff --git a/inc/clock_view.h b/inc/Config.h
index b82cafe..ba1303a 100755..100644
--- a/inc/clock_view.h
+++ b/inc/Config.h
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org/license/
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,21 +14,22 @@
* limitations under the License.
*/
-#ifndef __CLOCK_VIEW_H__
-#define __CLOCK_VIEW_H__
+#ifndef Config_h_
+#define Config_h_
-#include <Elementary.h>
+#if !defined(PACKAGE_NAME)
+#define PACKAGE_NAME "org.tizen.idle-clock-proto"
+#endif
-bool clock_view_create_layout(void *data);
-int clock_view_parse_result_data(const char *result_data);
-void clock_view_set_result_data(void *data);
-void clock_view_update_view(void *data);
-int clock_view_get_display_state();
-Eina_Bool clock_view_set_info_time(void *data);
-void clock_view_destroy_view_main(void *data);
-void clock_view_show_clock(void *data);
-void clock_view_hide_clock(void *data);
+#if !defined(PROJECT_NAME)
+#define PROJECT_NAME "idle-clock-proto"
+#endif
+#ifdef LOGGER_TAG
+#undef LOGGER_TAG
+#endif
+#define LOGGER_TAG "idleclock"
+#define APP_DOMAIN PROJECT_NAME
-#endif /* __CLOCK_VIEW_H__ */
+#endif // Config_h_
diff --git a/inc/Resource.h b/inc/Resource.h
new file mode 100644
index 0000000..1b3c9d1
--- /dev/null
+++ b/inc/Resource.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 RESOURCE_H_
+#define RESOURCE_H_
+
+#define EDJ_PATH "edje"
+#define IMAGE_PATH "images"
+
+#define MAINT_LAYOUT_EDJ "main-layout.edj"
+#define CLOCK_DIGITAL_EDJ "clock-digital.edj"
+
+#endif /* RESOURCE_H_ */
diff --git a/inc/app_data.h b/inc/app_data.h
deleted file mode 100755
index 16e13c1..0000000
--- a/inc/app_data.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 __APP_DATA_H__
-#define __APP_DATA_H__
-
-#include <Elementary.h>
-#include <app.h>
-
-/* for time variables */
-#include <utils_i18n.h>
-#define MAX_PATH_LEN 1024
-
-typedef struct __appdata {
- Evas_Object *win;
- Evas_Object *ly_main;
- Evas_Object *ly_time;
- Evas_Object *bg;
-
- int win_w;
- int win_h;
-
- Ecore_Timer *timer;
- int win_type;
- Evas *e_offscreen;
- app_control_h app_control;
-
- /* for time display */
- Eina_Bool is_pre;
- int timeformat;
- char *timeregion_format;
- char *timezone_id;
- i18n_udate_format_h formatter_time;
- i18n_udate_format_h formatter_ampm;
- i18n_udate_format_h formatter_time_24;
- i18n_udate_format_h formatter_date;
- i18n_udatepg_h generator;
-
- Eina_Bool is_show;
-} appdata;
-
-#endif /* __APP_DATA_H__ */
-
diff --git a/inc/log.h b/inc/log.h
deleted file mode 100755
index de35fd0..0000000
--- a/inc/log.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 __LOG_H__
-#define __LOG_H__
-
-#include <unistd.h>
-#include <dlog.h>
-#include <dlog-internal.h>
-
-#undef LOG_TAG
-#define LOG_TAG "IDLE-CLOCK-DIGITAL"
-
-#if !defined(_D)
-#define _D(fmt, arg...) LOGD(fmt"\n", ##arg)
-#endif
-
-#if !defined(_W)
-#define _W(fmt, arg...) LOGW(fmt"\n", ##arg)
-#endif
-
-#if !defined(_E)
-#define _E(fmt, arg...) LOGE(fmt"\n", ##arg)
-#endif
-
-#if !defined(_SD)
-#define _SD(fmt, arg...) SECURE_LOGD(fmt"\n", ##arg)
-#endif
-
-#if !defined(_SW)
-#define _SW(fmt, arg...) SECURE_LOGW(fmt"\n", ##arg)
-#endif
-
-#if !defined(_SE)
-#define _SE(fmt, arg...) SECURE_LOGE(fmt"\n", ##arg)
-#endif
-
-#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)
-
-#define goto_if(expr, val) do { \
- if (expr) { \
- _E("(%s) -> goto", #expr); \
- goto val; \
- } \
-} while (0)
-
-#define break_if(expr) { \
- if (expr) { \
- _E("(%s) -> break", #expr); \
- break; \
- } \
-}
-
-#define continue_if(expr) { \
- if (expr) { \
- _E("(%s) -> continue", #expr); \
- continue; \
- } \
-}
-
-//assert
-#define ASSERT_SE(expr, args...) do { \
- if (expr) app_assert_screen(LOG_TAG, __FILE__, __LINE__, __func__, ##args); \
- } while (0)
-
-#define ASSERT_S(expr) do { \
- if (expr) assert_screen(LOG_TAG, __FILE__, __LINE__, __func__, #expr, NULL); \
- } while (0)
-
-void assert_screen(const char* tag_name, const char* file, int line, const char* func, const char *expr, const char *fmt, ...);
-
-
-
-#endif /* IDLE_CLOCK_DIGITAL_DEBUG_H */
diff --git a/inc/util.h b/inc/util.h
deleted file mode 100755
index 53d0c0f..0000000
--- a/inc/util.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 __UTIL_H__
-#define __UTIL_H__
-
-#include <Elementary.h>
-
-#if !defined(PACKAGE)
-# define PACKAGE "idle-clock-digital"
-#endif
-
-#if !defined(PKGNAME)
-# define PKGNAME "org.tizen.idle-clock-digital"
-#endif
-
-#define EDJ_APP "/edje/idle-clock-digital.edj"
-
-#define S_(str) dgettext("sys_string", str)
-#define T_(str) dgettext(PACKAGE, str)
-#undef _
-#define _(str) gettext(str)
-
-#define _EDJ(x) elm_layout_edje_get(x)
-#define _X(x) (x*elm_config_scale_get())
-
-#ifdef FEATURE_DIGITAL_OPERATOR_GEAR3
-#define WIN_SIZE_W 360
-#define WIN_SIZE_H 480
-#else
-#define WIN_SIZE_W 320
-#define WIN_SIZE_H 320
-#endif
-
-
-typedef enum _buffer_type {
- BUFFER_TYPE_MINICONTROL = 0,
- BUFFER_TYPE_OFFSCREEN,
- BUFFER_TYPE_WINDOW,
-} buffer_type_e;
-
-#endif /* __IDLE_CLOCK_DIGITAL_COMMON_H__ */
-
diff --git a/project_def.prop b/project_def.prop
index ce61f20..61ae8a3 100644
--- a/project_def.prop
+++ b/project_def.prop
@@ -9,17 +9,17 @@ type = app
profile = wearable-4.0
# C/CPP Sources
-USER_SRCS = src/debug.c src/main.c src/clock_view.c src/window.c
+USER_SRCS = src/App/src/DateTimeView.cpp src/Common/src/PathUtils.cpp src/App/src/WatchApp.cpp src/Common/src/I18nString.cpp src/App/src/MainLayout.cpp src/Common/src/View.cpp src/Common/src/Logger.cpp src/App/src/DateTimeFormatter.cpp src/App/src/MainController.cpp src/main.cpp src/Common/src/WatchWindow.cpp
# EDC Sources
USER_EDCS =
# PO Sources
-USER_POS = res/po/da.po res/po/en.po res/po/hi.po res/po/ms.po res/po/si.po res/po/es_US.po res/po/ja_JP.po res/po/or.po res/po/bn.po res/po/et.po res/po/my.po res/po/ne.po res/po/ga.po res/po/lv.po res/po/ar.po res/po/hu.po res/po/ta.po res/po/eu.po res/po/he.po res/po/kk.po res/po/es_ES.po res/po/kn.po res/po/fr.po res/po/sk.po res/po/uz.po res/po/hr.po res/po/km.po res/po/uk.po res/po/vi.po res/po/mn_MN.po res/po/zh_CN.po res/po/tl.po res/po/ro.po res/po/gu.po res/po/lt.po res/po/mk.po res/po/nb.po res/po/sl.po res/po/en_PH.po res/po/tr_TR.po res/po/zh_TW.po res/po/pt_PT.po res/po/az.po res/po/lo.po res/po/pa.po res/po/sr.po res/po/is.po res/po/ka.po res/po/sq.po res/po/th.po res/po/ko_KR.po res/po/de.po res/po/fi.po res/po/id.po res/po/ml.po res/po/it_IT.po res/po/zh_HK.po res/po/fa.po res/po/ru_RU.po res/po/bg.po res/po/el_GR.po res/po/mr.po res/po/as.po res/po/ca.po res/po/nl.po res/po/sv.po res/po/pt_BR.po res/po/cs.po res/po/fr_CA.po res/po/pl.po res/po/gl.po res/po/hy.po res/po/te.po res/po/ur.po res/po/en_US.po
+USER_POS = res/po/es_US.po res/po/or.po res/po/bn.po res/po/et.po res/po/my.po res/po/ne.po res/po/ga.po res/po/lv.po res/po/eu.po res/po/he.po res/po/kk.po res/po/es_ES.po res/po/vi.po res/po/zh_CN.po res/po/ro.po res/po/nb.po res/po/en_PH.po res/po/zh_TW.po res/po/az.po res/po/pa.po res/po/sr.po res/po/ka.po res/po/sq.po res/po/fi.po res/po/id.po res/po/it_IT.po res/po/zh_HK.po res/po/ru_RU.po res/po/as.po res/po/sv.po res/po/cs.po res/po/fr_CA.po res/po/gl.po res/po/ur.po res/po/da.po res/po/en.po res/po/hi.po res/po/ms.po res/po/si.po res/po/ja_JP.po res/po/ar.po res/po/hu.po res/po/ta.po res/po/kn.po res/po/fr.po res/po/sk.po res/po/uz.po res/po/hr.po res/po/km.po res/po/uk.po res/po/mn_MN.po res/po/tl.po res/po/gu.po res/po/lt.po res/po/mk.po res/po/sl.po res/po/tr_TR.po res/po/pt_PT.po res/po/lo.po res/po/is.po res/po/th.po res/po/ko_KR.po res/po/de.po res/po/ml.po res/po/fa.po res/po/bg.po res/po/el_GR.po res/po/mr.po res/po/ca.po res/po/nl.po res/po/pt_BR.po res/po/pl.po res/po/hy.po res/po/te.po res/po/en_US.po
# User Defines
USER_DEFS =
-USER_CPP_DEFS =
+USER_CPP_DEFS = TIZEN_DEPRECATION DEPRECATION_WARNING
# User Undefines
USER_UNDEFS =
@@ -33,10 +33,10 @@ USER_OBJS =
# User Includes
## C Compiler
-USER_C_INC_DIRS = inc
+USER_C_INC_DIRS =
USER_INC_FILES =
## C++ Compiler
-USER_CPP_INC_DIRS =
+USER_CPP_INC_DIRS = inc src/App/inc src/Common/inc
USER_CPP_INC_FILES =
USER_INC_DIRS = $(USER_C_INC_DIRS) $(USER_CPP_INC_DIRS)
@@ -52,7 +52,7 @@ USER_EDCS_FONT_DIRS = ${OUTPUT_DIR} edje/fonts
# EDC Flags
USER_EXT_EDC_KEYS = EDC0
-USER_EXT_EDC0_EDCS = res/edje/idle-clock-digital.edc
+USER_EXT_EDC0_EDCS = res/edje/main-layout.edc res/edje/clock-digital.edc
USER_EXT_EDC0_EDCS_IMAGE_DIRS = ${OUTPUT_DIR} edje/images
USER_EXT_EDC0_EDCS_SOUND_DIRS = ${OUTPUT_DIR} edje/sounds
USER_EXT_EDC0_EDCS_FONT_DIRS = ${OUTPUT_DIR} edje/fonts
diff --git a/res/edje/clock-digital.edc b/res/edje/clock-digital.edc
new file mode 100755
index 0000000..168be81
--- /dev/null
+++ b/res/edje/clock-digital.edc
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 "defines.inl"
+
+#define MAX_TEXT_WIDTH 340
+#define MAX_TIME_TEXT_HEIGHT 118
+#define MAX_SEC_WIDTH 23
+
+collections {
+ base_scale: BASE_SCALE;
+
+ images {
+ image: "default_digital_sec.png" RAW;
+ }
+
+ styles {
+ style { name: "textblock_digit_style";
+ base: "font=Tizen font_size=118 color=#ffffff align=center style=shadow,bottom shadow_color=#00000088";
+ tag: "ampm" "+ font_size=24";
+ }
+ }
+
+ group { name : "layout_clock_digital";
+ parts{
+ spacer { "main";
+ scale: 1;
+ desc { "default";
+ min: 0 0;
+ max: MAX_TEXT_WIDTH MAX_TIME_TEXT_HEIGHT;
+ }
+ }
+ textblock { "text_hour";
+ effect: SHADOW BOTTOM;
+ scale: 1;
+ desc { "default";
+ color: 255 255 255 255;
+ rel1.to: "main";
+ rel1.relative: 0 0;
+ rel2.to_y: "main";
+ rel2.relative: 0 1;
+ align: 0 0.5;
+ text {
+ text: "12";
+ style: "textblock_digit_style";
+ min: 1 1;
+ max: 0 1;
+ }
+ }
+ }
+ image { "digital_sec";
+ scale;
+ desc { "default";
+ image.normal: "default_digital_sec.png";
+ min: 23 MAX_TIME_TEXT_HEIGHT;
+ max: 23 MAX_TIME_TEXT_HEIGHT;
+ color: 255 52 41 255;
+ rel1.to_x: "text_hour";
+ rel1.to_y: "main";
+ rel1.relative: 1 0;
+ rel2.to_y: "main";
+ rel2.relative: 0 1;
+ align: 0 0.5;
+ }
+ }
+ textblock { "text_min";
+ effect: SHADOW BOTTOM;
+ scale: 1;
+ desc { "default";
+ color: 255 255 255 255;
+ rel1.to_x: "digital_sec";
+ rel1.to_y: "main";
+ rel1.relative: 1 0;
+ rel2.to: "main";
+ rel2.relative: 1 1;
+ align: 0 0.5;
+ text {
+ text: "55<ampm>AM</ampm>";
+ style: "textblock_digit_style";
+ min: 1 1;
+ max: 0 1;
+ }
+ }
+ }
+ }
+ } //group end
+}
diff --git a/res/edje/defines.inl b/res/edje/defines.inl
new file mode 100644
index 0000000..7b3ae30
--- /dev/null
+++ b/res/edje/defines.inl
@@ -0,0 +1 @@
+#define BASE_SCALE 1.3; \ No newline at end of file
diff --git a/res/edje/idle-clock-digital.edc b/res/edje/idle-clock-digital.edc
deleted file mode 100755
index b5f06a2..0000000
--- a/res/edje/idle-clock-digital.edc
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 WIN_HEIGHT 360
-#define WIN_WIDTH 360
-
-#define PROGRAM_SHOW_DATE( TYPE, NUM ) \
- program { \
- signal: "show,"TYPE"_text_date_"NUM; \
- source: "source_"TYPE"_text_date"; \
- action: STATE_SET "text_date_"NUM 0.0; \
- target: ""TYPE"_text_date"; \
- }
-
-collections {
-
- group { name: "main";
- parts {
- rect { "bg";
- scale: 1;
- desc { "default";
- rel1.relative: 0 0;
- rel2.relative: 1 1;
- color: 0 0 0 255;
- }
- }
- swallow { "time.part";
- scale: 1;
- desc { "default";
- rel.to: bg;
- rel1.relative: 0 0.5;
- rel2.relative: 1 0.5;
- }
- }
- }
- }
-
- group {
- name : "layout_clock_digital";
-
- styles {
- style {
- name: "textblock_digit_style";
- base: "font=Tizen:style=Bold font_size=80 color=#ffffff align=center style=shadow,bottom shadow_color=#00000088 text_class=idle_font";
- tag: "br" "\n";
- tag: "hilight" "+ font_weight=Bold";
- tag: "b" "+ font_weight=Bold";
- tag: "tab" "\t";
- }
- }
- parts{
- rect { "clipper";
- scale: 1;
- desc { "default";
- color: 255 255 255 255;
- }
- desc { "hide";
- color: 0 0 0 0 ;
- }
- }
-
- textblock { "textblock_time";
- effect: SHADOW BOTTOM;
- scale: 1;
- clip_to: "clipper";
- desc { "default";
- rel1.relative: 0 0;
- rel2.relative: 1 0;
- visible: 1;
- color: 255 255 255 255;
- align: 0 0;
- text{
- text: "";
- style: "textblock_digit_style";
- text_class: "idle_font";
- min: 0 1;
- align: 0.5 0.5;
- }
- }
- desc { "no_date";
- inherit: "default" 0.0;
- text{
- text: "";
- style: "textblock_digit_style";
- text_class: "idle_font";
- align: 0.5 0.5;
- min: 1 1;
- }
- }
- desc { "hide_time";
- inherit: "default" 0.0;
- visible: 0;
- }
- }
- part{
- name: "default_text_date";
- type: TEXT;
- effect: SHADOW BOTTOM;
- scale: 1;
- clip_to: "clipper";
- description{
- state: "default" 0.0;
- color: 255 255 255 255;
- color2: 255 128 0 255;
- rel1 { relative: 0.0 1.0; to: "textblock_time"; }
- rel2 { relative: 1.0 1.0; }
- align: 0 0;
- text{
- text: "";
- font: "Tizen:style=Bold";
- text_class: "tizen";
- min: 0 1;
- size: 34;
- align: 0.5 0;
- }
- visible: 0;
- }
- description{
- state: "text_date_1" 0.0;
- inherit: "default" 0.0;
- color: 0 0 0 255;
- visible: 1;
- }
- description{
- state: "text_date_2" 0.0;
- inherit: "default" 0.0;
- color: 206 255 0 255;
- visible: 1;
- }
- description{
- state: "text_date_3" 0.0;
- inherit: "default" 0.0;
- color: 255 101 25 255;
- visible: 1;
- }
- description{
- state: "text_date_4" 0.0;
- inherit: "default" 0.0;
- color: 188 255 251 255;
- visible: 1;
- }
- description{
- state: "text_date_5" 0.0;
- inherit: "default" 0.0;
- color: 240 56 128 255;
- visible: 1;
- }
- description{
- state: "text_date_6" 0.0;
- inherit: "default" 0.0;
- color: 255 234 0 255;
- visible: 1;
- }
- description{
- state: "text_date_7" 0.0;
- inherit: "default" 0.0;
- color: 103 62 39 255;
- visible: 1;
- }
- description{
- state: "text_date_8" 0.0;
- inherit: "default" 0.0;
- color: 255 255 255 255;
- visible: 1;
- }
- description{
- state: "text_date_9" 0.0;
- inherit: "default" 0.0;
- color: 4 40 96 255;
- visible: 1;
- }
- description{
- state: "text_date_10" 0.0;
- inherit: "default" 0.0;
- color: 242 220 197 255;
- visible: 1;
- }
- description{
- state: "text_date_11" 0.0;
- inherit: "default" 0.0;
- color: 246 46 0 255;
- visible: 1;
- }
- description{
- state: "text_date_12" 0.0;
- inherit: "default" 0.0;
- color: 89 89 89 255;
- visible: 1;
- }
- }
- } //parts end
- programs {
- program {
- name: "show_effect";
- signal: "show_effect";
- source: "";
- action: STATE_SET "default" 0.0;
- target: "clipper";
- }
- program {
- name: "hide_effect";
- signal: "hide_effect";
- source: "";
- action: STATE_SET "hide" 0.0;
- target: "clipper";
- }
- program {
- name: "change,no_date";
- signal: "change,no_date";
- source: "source_textblock_time";
- action: STATE_SET "no_date" 0.0;
- target: "textblock_time";
- }
- program {
- name: "change,default";
- signal: "change,default";
- source: "source_textblock_time";
- action: STATE_SET "default" 0.0;
- target: "textblock_time";
- }
- PROGRAM_SHOW_DATE(default, 1);
- PROGRAM_SHOW_DATE(default, 2);
- PROGRAM_SHOW_DATE(default, 3);
- PROGRAM_SHOW_DATE(default, 4);
- PROGRAM_SHOW_DATE(default, 5);
- PROGRAM_SHOW_DATE(default, 6);
- PROGRAM_SHOW_DATE(default, 7);
- PROGRAM_SHOW_DATE(default, 8);
- PROGRAM_SHOW_DATE(default, 9);
- PROGRAM_SHOW_DATE(default, 10);
- PROGRAM_SHOW_DATE(default, 11);
- PROGRAM_SHOW_DATE(default, 12);
-
- program {
- name: "change,yes_date";
- signal: "change,yes_date";
- source: "source_textblock_time";
- action: STATE_SET "default" 0.0;
- target: "textblock_time";
- }
- program {
- name: "hide,default_time";
- signal: "hide,default_time";
- source: "source_default_time";
- action: STATE_SET "hide_default_time" 0.0;
- target: "textblock_time";
- }
- program {
- name: "hide,text_date";
- signal: "hide,text_date";
- source: "source_text_date";
- action: STATE_SET "default" 0.0;
- target: "default_text_date";
- }
- } // programs end
- } //group end
-}
diff --git a/res/edje/main-layout.edc b/res/edje/main-layout.edc
new file mode 100644
index 0000000..ec5b21d
--- /dev/null
+++ b/res/edje/main-layout.edc
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 "defines.inl"
+
+collections {
+ base_scale: BASE_SCALE;
+ group { name: "main";
+ parts {
+ rect { "bg";
+ scale: 1;
+ desc { "default";
+ rel1.relative: 0 0;
+ rel2.relative: 1 1;
+ color: 0 0 0 255;
+ }
+ }
+ swallow { "time.part";
+ scale: 1;
+ desc { "default";
+ rel.to: bg;
+ rel1.relative: 0.5 0.5;
+ rel2.relative: 0.5 0.5;
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/src/App/inc/DateTimeFormatter.h b/src/App/inc/DateTimeFormatter.h
new file mode 100644
index 0000000..d38d4d6
--- /dev/null
+++ b/src/App/inc/DateTimeFormatter.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 DateTimeFormatter_h_
+#define DateTimeFormatter_h_
+
+#include <string>
+#include <watch_app.h>
+#include <utils_i18n.h>
+#include <time.h>
+
+#include "I18nString.h"
+
+namespace IdleClock {
+
+ class DateTimeFormatter {
+ public:
+ DateTimeFormatter();
+ ~DateTimeFormatter();
+
+ DateTimeFormatter(const DateTimeFormatter&) = delete;
+ DateTimeFormatter &operator=(const DateTimeFormatter&) = delete;
+
+ std::string getTime(time_t intime) const;
+ std::string getDate(time_t intime) const;
+
+ void set24hTimeFormat(bool value);
+ void setRegion(std::string region);
+ void setTimeZone(const std::string &timeZone);
+ void update();
+
+ private:
+ std::string getDateTime(time_t intime, const i18n_udate_format_h format) const;
+
+ void updateTime();
+ void updateDate();
+ void updateGen();
+
+ void destroy();
+ void destroyGen();
+ void destroyTime();
+ void destroyDate();
+
+ private:
+ bool m_IsTime24Format;
+ std::string m_Region;
+ I18nString m_TimeZoneId;
+ i18n_udate_format_h m_Time;
+ i18n_udate_format_h m_Date;
+ i18n_udatepg_h m_Gen;
+ };
+}
+
+#endif /* DateTimeFormatter_h_ */
diff --git a/src/App/inc/DateTimeView.h b/src/App/inc/DateTimeView.h
new file mode 100644
index 0000000..59c5510
--- /dev/null
+++ b/src/App/inc/DateTimeView.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 DateTimeView_h_
+#define DateTimeView_h_
+
+#include "View.h"
+
+namespace IdleClock {
+ class DateTimeView
+ : public View {
+ public:
+ DateTimeView(Evas_Object *parent);
+ virtual ~DateTimeView();
+
+ void setHours(const std::string &time);
+ void setMinutes(const std::string &time);
+ };
+}
+
+#endif /* DateTimeView_h_ */
diff --git a/src/App/inc/MainController.h b/src/App/inc/MainController.h
new file mode 100644
index 0000000..15a97e9
--- /dev/null
+++ b/src/App/inc/MainController.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 MainController_h_
+#define MainController_h_
+
+#include "MainLayout.h"
+#include "DateTimeFormatter.h"
+#include "DateTimeView.h"
+
+namespace IdleClock {
+ class MainController
+ : public MainLayout {
+
+ public:
+ MainController(Evas_Object *parent);
+ virtual ~MainController();
+
+ void onPause();
+ void onResume();
+ void onControl(app_control_h app_control);
+ void onTick(watch_time_h watch_time);
+ void onAmbientTick(watch_time_h watch_time);
+ void onAmbientChanged(bool ambient_mode);
+ void onLanguageChanged(app_event_info_h appEvent);
+ void onLowBattery(app_event_info_h appEvent);
+ void onRegionChanged(app_event_info_h appEvent);
+ void onTimeFormatChanged();
+ void onTimeChanged();
+
+ private:
+ void updateTime();
+ void dispTime(watch_time_h watch_time);
+ void dispTime(time_t tt);
+ void dispTime();
+
+ private:
+ DateTimeFormatter m_Formatter;
+ DateTimeView *m_pTimeView;
+ };
+}
+
+#endif /* MainController_h_ */
diff --git a/src/App/inc/MainLayout.h b/src/App/inc/MainLayout.h
new file mode 100644
index 0000000..1341731
--- /dev/null
+++ b/src/App/inc/MainLayout.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 MainLayout_h_
+#define MainLayout_h_
+
+#include "View.h"
+
+namespace IdleClock {
+ class MainLayout
+ : public View {
+ public:
+ MainLayout(Evas_Object *parent);
+ virtual ~MainLayout();
+
+ void setDateTime(Evas_Object *dateTime);
+ };
+}
+
+#endif /* MainLayout_h_ */
diff --git a/src/App/inc/WatchApp.h b/src/App/inc/WatchApp.h
new file mode 100644
index 0000000..bb30649
--- /dev/null
+++ b/src/App/inc/WatchApp.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 WatchApp_h_
+#define WatchApp_h_
+
+#include <app.h>
+#include <app_control.h>
+#include <Evas.h>
+#include <watch_app.h>
+#include <system_settings.h>
+#include <string>
+
+namespace IdleClock {
+ class WatchWindow;
+ class MainController;
+
+ class WatchApp {
+ public:
+ static WatchApp &getInst();
+ int start(int argc, char *argv[]);
+ void exit();
+ WatchWindow &getWindow();
+ const WatchWindow &getWindow() const;
+
+ std::string getLang() const;
+ std::string getTimeZone() const;
+ std::string getCountry() const;
+ bool is24TimeFormat() const;
+
+ private:
+ WatchApp();
+ ~WatchApp();
+ WatchApp(WatchApp &) = delete;
+ WatchApp &operator=(WatchApp &) = delete;
+
+ std::string getStr(system_settings_key_e key) const;
+
+ // App cbs:
+ bool onCreate(int width, int height);
+ void onTerminate();
+ void onPause();
+ void onResume();
+ void onControl(app_control_h app_control);
+ void onTick(watch_time_h watch_time);
+ void onAmbientTick(watch_time_h watch_time);
+ void onAmbientChanged(bool ambient_mode);
+ void onLanguageChanged(app_event_info_h appEvent);
+ void onLowBattery(app_event_info_h appEvent);
+ void onRegionChanged(app_event_info_h appEvent);
+ void onTimeFormatChanged(system_settings_key_e key);
+ void onTimeChanged(system_settings_key_e key);
+
+ private:
+ static WatchApp m_AppInst;
+ WatchWindow *m_pWindow;
+ MainController *m_pRootController;
+ };
+}
+
+#endif /* WatchApp_h_ */
diff --git a/src/App/src/DateTimeFormatter.cpp b/src/App/src/DateTimeFormatter.cpp
new file mode 100644
index 0000000..f2f400c
--- /dev/null
+++ b/src/App/src/DateTimeFormatter.cpp
@@ -0,0 +1,208 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 "DateTimeFormatter.h"
+#include "Logger.h"
+
+using namespace IdleClock;
+
+namespace {
+ const std::string defaultRegion = "en_US";
+
+ std::string highlightKeyword(const std::string &str, const std::string &searchWord,
+ const std::string &tagOpen, const std::string &tagClose)
+ {
+ if (str.empty() || searchWord.empty())
+ return str;
+
+ char *found = strcasestr((char*)str.c_str(), (char*)searchWord.c_str());
+ if (!found)
+ return str;
+
+ std::string res;
+ res.reserve(str.length() + tagOpen.length() + tagClose.length());
+
+ int diff = found - str.c_str();
+ std::string firstPart = std::string(str.begin(), str.begin() + diff);
+ std::string lastPart = std::string(str.begin() + diff + searchWord.length(), str.end());
+
+ res += firstPart;
+ res += tagOpen;
+ res += std::string(found, searchWord.length());
+ res += tagClose;
+ res += lastPart;
+
+ return res;
+ }
+
+ void cleanupPattern(std::string &s, const std::string &charSet)
+ {
+ size_t pos = 0;
+ do {
+ pos = s.find_first_of(charSet);
+ if (pos != std::string::npos)
+ s.erase(pos, 1);
+ } while (pos != std::string::npos);
+ }
+}
+
+DateTimeFormatter::DateTimeFormatter()
+ : m_IsTime24Format(false)
+ , m_Region(defaultRegion)
+ , m_TimeZoneId()
+ , m_Time()
+ , m_Date()
+ , m_Gen()
+{
+ update();
+}
+
+DateTimeFormatter::~DateTimeFormatter()
+{
+ destroy();
+}
+
+std::string DateTimeFormatter::getDateTime(time_t intime, const i18n_udate_format_h format) const
+{
+ static const int maxLen = 128;
+ I18nString res(maxLen);
+ i18n_udate uTime = (i18n_udate)intime * 1000;
+ int32_t formattedStrLen = 0;
+ i18n_udate_format_date(format, uTime, res.getUStr(), res.getCapacity(), nullptr, &formattedStrLen);
+ return res.toStr();
+}
+
+std::string DateTimeFormatter::getTime(time_t intime) const
+{
+ return getDateTime(intime, m_Time);
+}
+
+std::string DateTimeFormatter::getDate(time_t intime) const
+{
+ return getDateTime(intime, m_Date);
+}
+
+void DateTimeFormatter::set24hTimeFormat(bool value)
+{
+ m_IsTime24Format = value;
+ LOG("24Format: ", value);
+}
+
+void DateTimeFormatter::setRegion(std::string region)
+{
+ m_Region = std::move(region);
+ if (m_Region.empty())
+ m_Region = defaultRegion;
+
+ LOG("Region: ", m_Region);
+}
+
+void DateTimeFormatter::setTimeZone(const std::string &timeZone)
+{
+ m_TimeZoneId = timeZone;
+ LOG("TimeZone: ", m_TimeZoneId.toStr());
+}
+
+void DateTimeFormatter::update()
+{
+ i18n_ulocale_set_default(nullptr);
+ i18n_ucalendar_set_default_timezone(m_TimeZoneId);
+ updateGen();
+ updateTime();
+ updateDate();
+}
+
+void DateTimeFormatter::updateDate()
+{
+ destroyDate();
+
+ int32_t bestPatternLen = 0;
+
+ I18nString skeleton = "MMMEd";
+ I18nString uBestPattern(128);
+
+ i18n_udatepg_get_best_pattern(m_Gen, skeleton, skeleton.getLen(), uBestPattern, uBestPattern.getCapacity(), &bestPatternLen);
+ std::string aPattern = uBestPattern.toStr();
+ i18n_udate_create(I18N_UDATE_PATTERN, I18N_UDATE_PATTERN, m_Region.c_str(), m_TimeZoneId, -1, uBestPattern, -1, &m_Date);
+ LOG("BestPattern: ", uBestPattern.toStr());
+}
+
+void DateTimeFormatter::updateTime()
+{
+ int32_t bestPatternLen = 0;
+ I18nString uBestPattern(128);
+ static const std::string period = "a";
+ I18nString skeleton = m_IsTime24Format ? "HH:mm" : ("h:mm " + period);
+
+ destroyTime();
+ i18n_udatepg_get_best_pattern(m_Gen, skeleton, skeleton.getLen(), uBestPattern, uBestPattern.getCapacity(), &bestPatternLen);
+ std::string aPattern = uBestPattern.toStr();
+
+ if (m_IsTime24Format) {
+ // Remove am/pm:
+ cleanupPattern(aPattern, " a");
+ } else {
+ static const std::string searchWord = period;
+ static const std::string tagOpen = "'<ampm>'";
+ static const std::string tagClose = "'</ampm>'";
+ aPattern = highlightKeyword(aPattern, searchWord, tagOpen, tagClose);
+ cleanupPattern(aPattern, " ");
+ }
+
+ uBestPattern = aPattern;
+
+ i18n_udate_create(I18N_UDATE_PATTERN, I18N_UDATE_PATTERN, m_Region.c_str(), m_TimeZoneId, -1, uBestPattern, -1, &m_Time);
+ LOG("BestPattern: ", uBestPattern.toStr());
+}
+
+void DateTimeFormatter::destroyGen()
+{
+ if (m_Gen) {
+ i18n_udatepg_destroy(m_Gen);
+ m_Gen = nullptr;
+ }
+}
+
+void DateTimeFormatter::destroyTime()
+{
+ if (m_Time) {
+ i18n_udate_destroy(m_Time);
+ m_Time = nullptr;
+ }
+}
+
+void DateTimeFormatter::destroyDate()
+{
+ if (m_Date) {
+ i18n_udate_destroy(m_Date);
+ m_Date = nullptr;
+ }
+}
+
+void DateTimeFormatter::destroy()
+{
+ destroyTime();
+ destroyDate();
+ destroyGen();
+}
+
+void DateTimeFormatter::updateGen()
+{
+ destroyGen();
+ i18n_udatepg_create(m_Region.c_str(), &m_Gen);
+}
+
+
diff --git a/src/App/src/DateTimeView.cpp b/src/App/src/DateTimeView.cpp
new file mode 100644
index 0000000..44e1464
--- /dev/null
+++ b/src/App/src/DateTimeView.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 "DateTimeView.h"
+#include "Resource.h"
+#include "PathUtils.h"
+#include "Logger.h"
+#include "LangUtils.h"
+#include "Callback.h"
+
+using namespace IdleClock;
+
+DateTimeView::DateTimeView(Evas_Object *parent)
+{
+ setEo(View::addLayout(parent, CLOCK_DIGITAL_EDJ, "layout_clock_digital"));
+}
+
+DateTimeView::~DateTimeView()
+{
+}
+
+void DateTimeView::setHours(const std::string &time)
+{
+ setText(time, "text_hour");
+}
+
+void DateTimeView::setMinutes(const std::string &time)
+{
+ setText(time, "text_min");
+}
diff --git a/src/App/src/MainController.cpp b/src/App/src/MainController.cpp
new file mode 100644
index 0000000..0214295
--- /dev/null
+++ b/src/App/src/MainController.cpp
@@ -0,0 +1,135 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 "WatchApp.h"
+#include "MainController.h"
+#include "Logger.h"
+#include <vector>
+#include <iostream>
+#include <cstring>
+
+using namespace IdleClock;
+
+MainController::MainController(Evas_Object *parent)
+ : MainLayout(parent)
+ , m_pTimeView(nullptr)
+{
+ m_pTimeView = new DateTimeView(getEo());
+ MainLayout::setDateTime(*m_pTimeView);
+ updateTime();
+}
+
+MainController::~MainController()
+{
+}
+
+void MainController::onPause()
+{
+ LOG("");
+}
+
+void MainController::onResume()
+{
+ LOG("");
+ dispTime();
+}
+
+void MainController::onControl(app_control_h app_control)
+{
+ LOG("");
+}
+
+void MainController::onTick(watch_time_h watch_time)
+{
+ LOG("");
+ dispTime(watch_time);
+}
+
+void MainController::onAmbientTick(watch_time_h watch_time)
+{
+ LOG("");
+ dispTime(watch_time);
+}
+
+void MainController::onAmbientChanged(bool ambient_mode)
+{
+ LOG("");
+}
+
+void MainController::onLanguageChanged(app_event_info_h appEvent)
+{
+ LOG("");
+ updateTime();
+}
+
+void MainController::onLowBattery(app_event_info_h appEvent)
+{
+ LOG("");
+}
+
+void MainController::onRegionChanged(app_event_info_h appEvent)
+{
+ LOG("");
+ updateTime();
+}
+
+void MainController::onTimeFormatChanged()
+{
+ LOG("");
+ updateTime();
+}
+
+void MainController::onTimeChanged()
+{
+ LOG("");
+ updateTime();
+}
+
+void MainController::dispTime()
+{
+ dispTime(time(nullptr));
+}
+
+void MainController::dispTime(time_t tt)
+{
+ std::string timeStr = m_Formatter.getTime(tt);
+ LOG("Time: ", timeStr);
+
+ char *lexeme = strtok(const_cast<char*>(timeStr.c_str()), ":");
+ std::string hoursStr = lexeme;
+ lexeme = strtok(nullptr, ":");
+ std::string minutesStr = lexeme;
+
+ m_pTimeView->setHours(hoursStr);
+ m_pTimeView->setMinutes(minutesStr);
+}
+
+void MainController::dispTime(watch_time_h watch_time)
+{
+ time_t tt = {};
+ if (watch_time_get_utc_timestamp(watch_time, &tt) == 0)
+ dispTime(tt);
+}
+
+void MainController::updateTime()
+{
+ LOG("");
+ m_Formatter.set24hTimeFormat(WatchApp::getInst().is24TimeFormat());
+ m_Formatter.setTimeZone(WatchApp::getInst().getTimeZone());
+ m_Formatter.setRegion(WatchApp::getInst().getCountry());
+ m_Formatter.update();
+ dispTime();
+}
diff --git a/src/App/src/MainLayout.cpp b/src/App/src/MainLayout.cpp
new file mode 100644
index 0000000..9c779f6
--- /dev/null
+++ b/src/App/src/MainLayout.cpp
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 "MainLayout.h"
+#include "Resource.h"
+#include "PathUtils.h"
+#include "Logger.h"
+#include "LangUtils.h"
+#include "Callback.h"
+
+using namespace IdleClock;
+
+MainLayout::MainLayout(Evas_Object *parent)
+{
+ setEo(View::addLayout(parent, MAINT_LAYOUT_EDJ, "main"));
+}
+
+MainLayout::~MainLayout()
+{
+}
+
+void MainLayout::setDateTime(Evas_Object *dateTime)
+{
+ setContent(dateTime, "time.part");
+}
diff --git a/src/App/src/WatchApp.cpp b/src/App/src/WatchApp.cpp
new file mode 100644
index 0000000..dbc6a60
--- /dev/null
+++ b/src/App/src/WatchApp.cpp
@@ -0,0 +1,214 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 "WatchApp.h"
+
+#include "PathUtils.h"
+#include "Logger.h"
+#include "Callback.h"
+#include "MainController.h"
+#include "WatchWindow.h"
+
+#include <efl_extension.h>
+
+using namespace IdleClock;
+
+WatchApp WatchApp::m_AppInst;
+
+WatchApp::WatchApp()
+ : m_pWindow(nullptr)
+ , m_pRootController(nullptr)
+{
+}
+
+WatchApp::~WatchApp()
+{
+}
+
+WatchApp &WatchApp::getInst()
+{
+ return m_AppInst;
+}
+
+void WatchApp::exit()
+{
+ watch_app_exit();
+}
+
+WatchWindow &WatchApp::getWindow()
+{
+ ASSERT(m_pWindow, "Window is null");
+ return *m_pWindow;
+}
+
+const WatchWindow &WatchApp::getWindow() const
+{
+ return const_cast<WatchApp*>(this)->getWindow();
+}
+
+int WatchApp::start(int argc, char *argv[])
+{
+ watch_app_lifecycle_callback_s cbs = {};
+
+ cbs.create = makeCbLast(&WatchApp::onCreate);
+ cbs.terminate = makeCbLast(&WatchApp::onTerminate);
+ cbs.pause = makeCbLast(&WatchApp::onPause);
+ cbs.resume = makeCbLast(&WatchApp::onResume);
+ cbs.app_control = makeCbLast(&WatchApp::onControl);
+ cbs.time_tick = makeCbLast(&WatchApp::onTick);
+ cbs.ambient_tick = makeCbLast(&WatchApp::onAmbientTick);
+ cbs.ambient_changed = makeCbLast(&WatchApp::onAmbientChanged);
+
+ app_event_handler_h events[3] = {};
+
+ watch_app_add_event_handler(&events[0], APP_EVENT_LANGUAGE_CHANGED, makeCbLast(&WatchApp::onLanguageChanged), this);
+ watch_app_add_event_handler(&events[1], APP_EVENT_REGION_FORMAT_CHANGED, makeCbLast(&WatchApp::onRegionChanged), this);
+ watch_app_add_event_handler(&events[2], APP_EVENT_LOW_BATTERY, makeCbLast(&WatchApp::onLowBattery), this);
+
+ system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, makeCbLast(&WatchApp::onTimeFormatChanged), this);
+ system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_TIME_CHANGED, makeCbLast(&WatchApp::onTimeChanged), this);
+
+ return watch_app_main(argc, argv, &cbs, this);
+}
+
+std::string WatchApp::getStr(system_settings_key_e key) const
+{
+ std::string res;
+ char *value = nullptr;
+ system_settings_get_value_string(key, &value);
+ if (value) {
+ res = value;
+ free(value);
+ }
+ return res;
+}
+
+std::string WatchApp::getLang() const
+{
+ return getStr(SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE);
+}
+
+std::string WatchApp::getTimeZone() const
+{
+ return getStr(SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE);
+}
+
+std::string WatchApp::getCountry() const
+{
+ return getStr(SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY);
+}
+
+bool WatchApp::is24TimeFormat() const
+{
+ bool value = false;
+ system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, &value);
+ return value;
+}
+
+bool WatchApp::onCreate(int width, int height)
+{
+ TRACE;
+
+ std::string localePath(PathUtils::getLocalePath());
+ if (!localePath.empty())
+ bindtextdomain(PROJECT_NAME, localePath.c_str());
+
+ elm_app_base_scale_set(1.3);
+ elm_config_accel_preference_set("3d");
+ watch_app_set_time_tick_frequency(1, WATCH_APP_TIME_TICKS_PER_MINUTE);
+
+ m_pWindow = new WatchWindow;
+ m_pWindow->resize(width, height);
+ m_pWindow->show();
+
+ m_pRootController = new MainController(m_pWindow->getLayout());
+ m_pWindow->setContent(*m_pRootController);
+
+ return true;
+}
+
+void WatchApp::onTerminate()
+{
+ TRACE;
+ m_pWindow->destroy();
+}
+
+void WatchApp::onTimeFormatChanged(system_settings_key_e key)
+{
+ if (m_pRootController)
+ m_pRootController->onTimeFormatChanged();
+}
+
+void WatchApp::onTimeChanged(system_settings_key_e key)
+{
+ if (m_pRootController)
+ m_pRootController->onTimeChanged();
+}
+
+void WatchApp::onPause()
+{
+ if (m_pRootController)
+ m_pRootController->onPause();
+}
+
+void WatchApp::onResume()
+{
+ if (m_pRootController)
+ m_pRootController->onResume();
+}
+
+void WatchApp::onTick(watch_time_h watch_time)
+{
+ if (m_pRootController)
+ m_pRootController->onTick(watch_time);
+}
+
+void WatchApp::onAmbientTick(watch_time_h watch_time)
+{
+ if (m_pRootController)
+ m_pRootController->onAmbientTick(watch_time);
+}
+
+void WatchApp::onAmbientChanged(bool ambient_mode)
+{
+ if (m_pRootController)
+ m_pRootController->onAmbientChanged(ambient_mode);
+}
+
+void WatchApp::onControl(app_control_h app_control)
+{
+ if (m_pRootController)
+ m_pRootController->onControl(app_control);
+}
+
+void WatchApp::onLanguageChanged(app_event_info_h appEvent)
+{
+ if (m_pRootController)
+ m_pRootController->onLanguageChanged(appEvent);
+}
+
+void WatchApp::onLowBattery(app_event_info_h appEvent)
+{
+ if (m_pRootController)
+ m_pRootController->onLowBattery(appEvent);
+}
+
+void WatchApp::onRegionChanged(app_event_info_h appEvent)
+{
+ if (m_pRootController)
+ m_pRootController->onRegionChanged(appEvent);
+}
+
diff --git a/src/Common/inc/Atspi.h b/src/Common/inc/Atspi.h
new file mode 100644
index 0000000..b92bdc8
--- /dev/null
+++ b/src/Common/inc/Atspi.h
@@ -0,0 +1,154 @@
+/*
+ * Copyright 2016 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 Atspi_h_
+#define Atspi_h_
+
+#include "LangUtils.h"
+#include "Config.h"
+
+#include <Elementary.h>
+
+namespace IdleClock {
+ /**
+ * @brief Wrapper for Elm_Interface_Atspi_Accessible interface (Screen reader)
+ */
+ class Atspi {
+ public:
+ Atspi();
+ Atspi(Elm_Interface_Atspi_Accessible *obj);
+ void wrap(Elm_Interface_Atspi_Accessible *obj);
+ Elm_Interface_Atspi_Accessible *getEo() const;
+ operator Elm_Interface_Atspi_Accessible *() const;
+
+ void setDescription(const char *text);
+ void setDescription(const std::string &text);
+ void setName(const char *text);
+ void setName(const std::string &text);
+ void setRole(Elm_Atspi_Role role);
+ void setReadingInfo(Elm_Accessible_Reading_Info_Type type);
+ void appendRel(Elm_Atspi_Relation_Type type, const Elm_Interface_Atspi_Accessible *obj);
+ void removeRel(Elm_Atspi_Relation_Type type, const Elm_Interface_Atspi_Accessible *obj);
+ void canHighlight(bool canHighlight);
+ void setActionCb(const Elm_Access_Action_Type type, const Elm_Access_Action_Cb cb, const void *data);
+
+ void makeStartPosition(Elm_Interface_Atspi_Accessible *obj);
+ void appendFlowRel(Elm_Interface_Atspi_Accessible *obj);
+ void removeFlowRel(Elm_Interface_Atspi_Accessible *obj);
+
+ // TODO: impl. other methods if needed
+
+ private:
+ Elm_Interface_Atspi_Accessible *m_pEo;
+ };
+
+ inline Atspi::Atspi()
+ : m_pEo(nullptr)
+ {
+ }
+
+ inline Atspi::Atspi(Elm_Interface_Atspi_Accessible *obj)
+ : m_pEo(obj)
+ {
+ }
+
+ inline void Atspi::wrap(Elm_Interface_Atspi_Accessible *obj)
+ {
+ m_pEo = obj;
+ }
+
+ inline Elm_Interface_Atspi_Accessible *Atspi::getEo() const
+ {
+ return m_pEo;
+ }
+
+ inline Atspi::operator Elm_Interface_Atspi_Accessible *() const
+ {
+ return getEo();
+ }
+
+ inline void Atspi::setDescription(const char *text)
+ {
+ elm_atspi_accessible_description_set(m_pEo, text);
+ elm_atspi_accessible_translation_domain_set(m_pEo, PACKAGE_NAME);
+ }
+
+ inline void Atspi::setDescription(const std::string &text)
+ {
+ setDescription(text.c_str());
+ }
+
+ inline void Atspi::setName(const char *text)
+ {
+ elm_atspi_accessible_name_set(m_pEo, (char*)text);
+ }
+
+ inline void Atspi::setName(const std::string &text)
+ {
+ setName(text.c_str());
+ }
+
+ inline void Atspi::setRole(Elm_Atspi_Role role)
+ {
+ elm_atspi_accessible_role_set(m_pEo, role);
+ }
+
+ inline void Atspi::setReadingInfo(Elm_Accessible_Reading_Info_Type type)
+ {
+ elm_atspi_accessible_reading_info_type_set(m_pEo, type);
+ }
+
+ inline void Atspi::appendRel(Elm_Atspi_Relation_Type type, const Elm_Interface_Atspi_Accessible *obj)
+ {
+ elm_atspi_accessible_relationship_append(m_pEo, type, obj);
+ }
+
+ inline void Atspi::removeRel(Elm_Atspi_Relation_Type type, const Elm_Interface_Atspi_Accessible *obj)
+ {
+ elm_atspi_accessible_relationship_remove(m_pEo, type, obj);
+ }
+
+ inline void Atspi::canHighlight(bool canHighlight)
+ {
+ elm_atspi_accessible_can_highlight_set(m_pEo, canHighlight);
+ }
+
+ inline void Atspi::setActionCb(const Elm_Access_Action_Type type, const Elm_Access_Action_Cb cb, const void *data)
+ {
+ elm_access_action_cb_set(m_pEo, type, cb, data);
+ }
+
+ inline void Atspi::makeStartPosition(Elm_Interface_Atspi_Accessible *obj)
+ {
+ elm_atspi_accessible_relationship_append(m_pEo, ELM_ATSPI_RELATION_FLOWS_FROM, m_pEo);
+ elm_atspi_accessible_relationship_append(m_pEo, ELM_ATSPI_RELATION_FLOWS_TO, obj);
+ elm_atspi_accessible_relationship_append(obj, ELM_ATSPI_RELATION_FLOWS_FROM, m_pEo);
+ }
+
+ inline void Atspi::appendFlowRel(Elm_Interface_Atspi_Accessible *obj)
+ {
+ elm_atspi_accessible_relationship_append(m_pEo, ELM_ATSPI_RELATION_FLOWS_TO, obj);
+ elm_atspi_accessible_relationship_append(obj, ELM_ATSPI_RELATION_FLOWS_FROM, m_pEo);
+ }
+
+ inline void Atspi::removeFlowRel(Elm_Interface_Atspi_Accessible *obj)
+ {
+ elm_atspi_accessible_relationship_remove(m_pEo, ELM_ATSPI_RELATION_FLOWS_TO, obj);
+ elm_atspi_accessible_relationship_remove(obj, ELM_ATSPI_RELATION_FLOWS_FROM, m_pEo);
+ }
+}
+
+#endif /* Atspi_h_ */
diff --git a/src/Common/inc/BaseView.h b/src/Common/inc/BaseView.h
new file mode 100644
index 0000000..fbdd988
--- /dev/null
+++ b/src/Common/inc/BaseView.h
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2016 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 BaseView_h_
+#define BaseView_h_
+
+#include "Atspi.h"
+#include <Evas.h>
+#include "PathUtils.h"
+
+namespace IdleClock
+{
+ /**
+ * @brief Basic interface for all visual objects used across the whole application.
+ */
+ class BaseView
+ {
+ public:
+ BaseView();
+ virtual ~BaseView() {};
+
+ operator Evas_Object *() const;
+ Eo *getEo() const;
+
+ /**
+ * @brief Gets AtspiAccessibleInterface wrapper
+ * @return wrapper to AtspiAccessibleInterface
+ */
+ Atspi getAtspi() const;
+
+ protected:
+ void setEo(Eo *eo);
+
+ /**
+ * @brief Performs self-removing by request from children-classes.
+ */
+ virtual void onViewDestroyed() { delete this; };
+
+ protected:
+ Eo *m_pEo;
+ };
+
+ inline BaseView::BaseView()
+ : m_pEo(nullptr)
+ {
+ }
+
+ inline Atspi BaseView::getAtspi() const
+ {
+ return Atspi(m_pEo);
+ }
+
+ inline BaseView::operator Eo *() const
+ {
+ return m_pEo;
+ }
+
+ inline Eo *BaseView::getEo() const
+ {
+ return m_pEo;
+ }
+
+ inline void BaseView::setEo(Eo *eo)
+ {
+ m_pEo = eo;
+ }
+}
+
+#endif /* BaseView_h_ */
diff --git a/src/Common/inc/Callback.h b/src/Common/inc/Callback.h
new file mode 100644
index 0000000..f71259d
--- /dev/null
+++ b/src/Common/inc/Callback.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 Callback_h_
+#define Callback_h_
+
+template <class F>
+struct Callback;
+
+template <class R, class C, class... A>
+struct Callback<R(C::*)(A...)> {
+ using M = R(C::*)(A...);
+
+ template <M m>
+ static R stubFirst(void *obj, A... args)
+ {
+ return (static_cast<C*>(obj)->*m)(args...);
+ }
+
+ template <M m>
+ static R stubLast(A... args, void *obj)
+ {
+ return (static_cast<C*>(obj)->*m)(args...);
+ }
+};
+
+#define makeCbFirst(method) Callback<decltype(method)>::stubFirst<method>
+#define makeCbLast(method) Callback<decltype(method)>::stubLast<method>
+
+#endif // Callback_h_
diff --git a/src/Common/inc/I18nString.h b/src/Common/inc/I18nString.h
new file mode 100644
index 0000000..89f61b9
--- /dev/null
+++ b/src/Common/inc/I18nString.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 I18nString_h_
+#define I18nString_h_
+
+#include <string>
+#include <utils_i18n.h>
+
+namespace IdleClock {
+
+ class I18nString :
+ private std::basic_string<i18n_uchar> {
+
+ public:
+ I18nString();
+ I18nString(const I18nString &that);
+ I18nString(I18nString &&that);
+ I18nString(size_t count);
+ I18nString(const char *str);
+ I18nString(const i18n_uchar *uStr);
+ I18nString(const std::string &str);
+
+ I18nString &operator=(const I18nString &that);
+ i18n_uchar *getUStr() const;
+ operator i18n_uchar *() const;
+ int getLen() const;
+ std::string toStr() const;
+ size_t getCapacity() const;
+ void clear();
+ bool isEmpty() const;
+
+ private:
+ using Impl = std::basic_string<i18n_uchar>;
+
+ private:
+ void copyStr(const I18nString &that);
+ void copyStr(const i18n_uchar *uStr);
+ void copyStr(const std::string &str);
+ void copyStr(const char *str);
+ };
+}
+
+#endif /* I18nString_h_ */
diff --git a/src/Common/inc/LangUtils.h b/src/Common/inc/LangUtils.h
new file mode 100644
index 0000000..659793b
--- /dev/null
+++ b/src/Common/inc/LangUtils.h
@@ -0,0 +1,149 @@
+/*
+ * Copyright 2016 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 LangUtils_h_
+#define LangUtils_h_
+
+#include "Resource.h"
+#include "Config.h"
+
+#include <string>
+#include <libintl.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <cstddef>
+
+namespace IdleClock
+{
+ // Translatable Text
+ struct TText
+ {
+ // Constructor for nullptr;
+ TText(std::nullptr_t)
+ : m_pDomain(nullptr)
+ , m_IsTranslatable(false)
+ {
+ }
+
+ // Move Constructor;
+ TText(TText &&text)
+ : m_pDomain(text.m_pDomain)
+ , m_Str(std::move(text.m_Str))
+ , m_IsTranslatable(text.m_IsTranslatable)
+ {
+ }
+
+ // Constructor for C string
+ TText(const char *str, bool translatable = false, const char *domainName = APP_DOMAIN)
+ : m_pDomain(domainName)
+ , m_Str(str ? str : "")
+ , m_IsTranslatable(translatable)
+ {
+ }
+
+ // Constructor for C++ string
+ TText(std::string str, bool translatable = false, const char *domainName = APP_DOMAIN)
+ : m_pDomain(domainName)
+ , m_Str(std::move(str))
+ , m_IsTranslatable(translatable)
+ {
+ }
+
+ void clear()
+ {
+ m_Str.clear();
+ m_pDomain = nullptr;
+ m_IsTranslatable = false;
+ }
+
+ const char *getMsg() const
+ {
+ return m_Str.c_str();
+ }
+
+ const char *getDomain() const
+ {
+ if (m_pDomain && m_pDomain[0] == 0)
+ return nullptr;
+ return m_pDomain;
+ }
+
+ bool isTranslatable() const
+ {
+ return m_IsTranslatable;
+ }
+
+ private:
+ const char *m_pDomain;
+ std::string m_Str;
+ bool m_IsTranslatable;
+ };
+
+ // dgettext
+ struct DText
+ {
+ explicit DText(const char *stringId, const char *domainName)
+ {
+ m_pMsg = dgettext(domainName, stringId);
+ }
+
+ explicit DText(const std::string &stringId, const char *domainName)
+ {
+ m_pMsg = dgettext(domainName, stringId.c_str());
+ }
+
+ explicit DText(char dummyArg, const char *stringId, const char *domainName, ...)
+ : m_pMsg(m_Buf)
+ {
+ va_list args;
+ va_start(args, domainName);
+ vsnprintf(m_Buf, maxBufSize, dgettext(domainName, stringId), args);
+ va_end(args);
+ }
+
+ const char *get() const
+ {
+ return m_pMsg;
+ }
+
+ const char* cStr() const
+ {
+ return m_pMsg;
+ }
+
+ operator std::string() const
+ {
+ return m_pMsg;
+ }
+
+ private:
+ DText(DText&) = delete;
+ DText operator =(DText&) = delete;
+
+ static const int maxBufSize = 1024;
+ char m_Buf[maxBufSize];
+ const char *m_pMsg;
+ };
+
+ #define msgt(strId) TText(strId, true, MSG_DOMAIN)
+ #define msg(strId) DText(strId, MSG_DOMAIN)
+ #define msgArgs(strId, ...) DText(0, strId, MSG_DOMAIN, __VA_ARGS__)
+ #define sys(strId) DText(strId, SYS_DOMAIN)
+ #define syst(strId) TText(strId, true, SYS_DOMAIN)
+ #define sysArgs(strId, ...) DText(0, strId, SYS_DOMAIN, __VA_ARGS__)
+}
+
+#endif /* LangUtils_h_ */
diff --git a/src/Common/inc/Logger.h b/src/Common/inc/Logger.h
new file mode 100644
index 0000000..14b6bab
--- /dev/null
+++ b/src/Common/inc/Logger.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 LOGGER_H_
+#define LOGGER_H_
+
+#include "Config.h"
+#include <assert.h>
+#include <dlog.h>
+#include <string>
+#include <sstream>
+
+#ifndef LOGGER_TAG
+ #error "Please define LOGGER_TAG"
+#endif
+
+enum class LogPriority
+{
+ DEFAULT = DLOG_DEFAULT,
+ VERBOSE = DLOG_VERBOSE, /**< Verbose */
+ DEBUG = DLOG_DEBUG, /**< Debug */
+ INFO = DLOG_INFO, /**< Info */
+ WARN = DLOG_WARN, /**< Warning */
+ ERROR = DLOG_ERROR, /**< Error */
+ FATAL = DLOG_FATAL, /**< Fatal */
+ SILEN = DLOG_SILENT, /**< Silent */
+ MAX = DLOG_PRIO_MAX/**< Keep this always at the end. */
+};
+
+template<typename... Tail>
+void loggerImpl(LogPriority prior
+ , const char *tag
+ , const char *file, const char *function, int line
+ , Tail... msg)
+{
+ std::ostringstream messageStr;
+ (void)std::initializer_list<bool> { (messageStr << msg, true)... };
+ dlog_print(static_cast<log_priority>(prior)
+ , tag, "%s: %s(%d) -> %s", file, function, line
+ , messageStr.str().c_str());
+}
+
+class LoggerImpl
+{
+ public:
+ LoggerImpl(const char *tag, const char *file, const char *function, int line);
+ ~LoggerImpl();
+
+ private:
+ const std::string m_Tag;
+ const std::string m_File;
+ const std::string m_Function;
+};
+
+#define TRACE\
+ LoggerImpl __tmp_logger_unique(LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__);\
+
+#define LOG(...)\
+ loggerImpl(LogPriority::INFO, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__);
+
+#define LOG_INFO(...)\
+ loggerImpl(LogPriority::INFO, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__);
+
+#define LOG_ERROR(...)\
+ loggerImpl(LogPriority::ERROR, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__);
+
+#define LOG_WARN(...)\
+ loggerImpl(LogPriority::WARN, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__);
+
+#define ASSERT(expr, ...)\
+ if (!(expr)) { LOG_ERROR(__VA_ARGS__); } \
+ assert(expr)
+
+#endif /* LOGGER_H_ */
diff --git a/src/Common/inc/PathUtils.h b/src/Common/inc/PathUtils.h
new file mode 100644
index 0000000..177ac97
--- /dev/null
+++ b/src/Common/inc/PathUtils.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 PathUtils_h_
+#define PathUtils_h_
+
+#include <string>
+#include "Resource.h"
+
+namespace IdleClock {
+ namespace PathUtils {
+ /**
+ * @brief Gets the absolute path to file in the application resource directory.
+ * @param[in] path to file in res. dir (without slash at begin/end)
+ * @return absolute path to file
+ */
+ std::string getResourcePath(const std::string &filePath);
+
+ /**
+ * @brief Gets the absolute path to file in data directory which is used to store private data of the application.
+ * @param[in] path to file in data dir (without slash at begin/end)
+ * @return absolute path to file
+ */
+ std::string getDataPath(const std::string &filePath);
+
+ /**
+ * @brief Gets absolute path to application's resource-directory
+ * @return absolute path in case of success, or empty string otherwise
+ */
+ std::string getResourcePath();
+
+ /**
+ * @brief Gets absolute path to application's locale-directory
+ * @return absolute path in case of success, or empty string otherwise
+ */
+ std::string getLocalePath();
+
+ /**
+ * @brief Gets absolute path to Dowloads directory
+ * @return absolute path in case of success, or empty string otherwise
+ */
+ const std::string &getDownloadPath();
+
+ /**
+ * @brief Gets the absolute path to edje file
+ * @param[in] base edje file name
+ * @return absolute path to file
+ */
+ std::string getEdjePath(const std::string &fileName);
+
+ /**
+ * @brief Gets the absolute path to app. shared resource file
+ * @param[in] base file name
+ * @return absolute path to file
+ */
+ std::string getSharedResPath(const std::string &fileName);
+ };
+}
+
+#endif /* PathUtils_h_ */
diff --git a/src/Common/inc/View.h b/src/Common/inc/View.h
new file mode 100644
index 0000000..803ef0b
--- /dev/null
+++ b/src/Common/inc/View.h
@@ -0,0 +1,622 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 View_h_
+#define View_h_
+
+#include <Atspi.h>
+#include "BaseView.h"
+#include "LangUtils.h"
+#include <Elementary.h>
+#include <efl_extension.h>
+
+namespace IdleClock {
+ /**
+ * @brief Wraps all basic Evas_Object operations and manages automatic self-removal by EVAS_CALLBACK_FREE and EVAS_CALLBACK_DEL events.
+ */
+ class View
+ : public BaseView
+ {
+ public:
+ View();
+
+ /**
+ * @brief Destroys nested Evas_Object.
+ */
+ void destroy();
+ operator Evas_Object *() const;
+ Evas_Object *getEo() const;
+
+ /**
+ * @brief Checks whether view is visible or not.
+ * @return true if view is visible, otherwise false.
+ */
+ bool isVisible() const;
+
+ /**
+ * @brief Shows view.
+ * @param[in] value - true show, false - otherwise
+ */
+ void show(bool value = true);
+
+ /**
+ * @brief Moves view to specified Evas-coordinates.
+ * @param[in] x x-coordinate
+ * @param[in] y y-coordinate
+ */
+ void move(Evas_Coord x, Evas_Coord y);
+
+ /**
+ * @brief Sets size-weight hints.
+ * @param[in] x x-coordinate
+ * @param[in] y y-coordinate
+ */
+ void setSizeHintWeight(double x, double y);
+
+ /**
+ * @brief Sets size-align hints.
+ * @param[in] x x-coordinate
+ * @param[in] y y-coordinate
+ */
+ void setSizeHintAlign(double x, double y);
+
+ /**
+ * @brief Sets size-weight and size-align hints in order to make view expanded.
+ */
+ void expand();
+
+ /**
+ * @brief Sets specified Evas_object's size-weight and size-align hints in order to make it expanded.
+ * @param[in] obj an Evas_Object to be expanded.
+ */
+ static void expand(Evas_Object *obj);
+
+ /**
+ * @brief Sets min size hints.
+ * @param[in] w width hint.
+ * @param[in] h height hint.
+ */
+ void setSizeHintMin(Evas_Coord w, Evas_Coord h);
+
+ /**
+ * @brief Sets max size hints.
+ * @param[in] w width hint.
+ * @param[in] h height hint.
+ */
+ void setSizeHintMax(Evas_Coord w, Evas_Coord h);
+
+ /**
+ * @brief Gets min size hints.
+ * @param[out] w width hint.
+ * @param[out] h height hint.
+ */
+ void getSizeHintMin(Evas_Coord *w, Evas_Coord *h) const;
+
+ /**
+ * @brief Gets max size hints.
+ * @param[out] w width hint.
+ * @param[out] h height hint.
+ */
+ void getSizeHintMax(Evas_Coord *w, Evas_Coord *h) const;
+
+ /**
+ * @brief Sets specified content into specified part.
+ * @param[in] content a content to set into view.
+ * @param[in] part a part content should be placed to. If part is nullptr the default part is used.
+ * @param[in] saveOldContent a flag that checks whether old view's content should be returned or not.
+ * @return if saveOldContent is true returns old content set into view before, otherwise returns nullptr.
+ */
+ Evas_Object *setContent(Evas_Object *content, const char *part = nullptr, bool saveOldContent = false);
+ static Evas_Object *setContent(Evas_Object *obj, Evas_Object *content, const char *part = nullptr, bool saveOldContent = false);
+
+ /**
+ * @brief Unsets view's content.
+ * @param[in] part a part content should be removed from. If part is nullptr the default part is used.
+ * @return old view's content in case of success, nullptr in case of errors.
+ */
+ Evas_Object *unsetContent(const char *part = nullptr);
+
+ /**
+ * @brief Gets view's content.
+ * @param[in] part a content-part. If part is nullptr the default part is used.
+ * @return view's content in case of success, nullptr in case of errors.
+ */
+ Evas_Object* getContent(const char *part = nullptr) const;
+
+ /**
+ * @brief Set the ability for an view object to be focused.
+ * @param[in] enable if true view is enabled to be focused, otherwise it can not be focused.
+ */
+ void setFocusAllow(bool enable);
+
+ /**
+ * @brief Checks whether view can be focused or not.
+ * @return true if view is able to be focused, otherwise false.
+ */
+ bool getFocusAllow() const;
+
+ /**
+ * @brief Sets(unsets) focus to view.
+ * @param[in] focus if true sets focus to view, otherwise unfocuses it.
+ */
+ void setFocus(bool focus);
+
+ /**
+ * @brief Checks whether view is focused or not.
+ * @return true if view is focused, otherwise false.
+ */
+ bool getFocus() const;
+
+ /**
+ * @brief Mark the part text to be translatable or not.
+ * @param[in] translatable @c true, the part text will be translated internally. @c false, otherwise.
+ * @param[in] domain The translation domain to use.
+ * @param[in] part The part name of the translatable text, if part is nullptr the default part is used.
+ */
+ void setTranslatable(bool translatable, const char *domain, const char *part = nullptr);
+
+ /**
+ * @brief Sends a signal to edje-object.
+ * @param[in] emission The signal's name.
+ * @param[in] source The signal's source.
+ * @param[in] async true - process an object's message queue in job/timer, false - process immediately.
+ */
+ void emitSignal(const char *emission, const char *source = "", bool async = false);
+
+ /**
+ * @brief Sends a signal to edje-object.
+ * @param[in] obj Target object
+ * @param[in] emission The signal's name.
+ * @param[in] source The signal's source.
+ * @param[in] async true - process the signal postponed, false - process immediately.
+ */
+ static void emitSignal(Evas_Object *obj, const char *emission, const char *source = "", bool async = false);
+
+ /**
+ * @brief Process all edje signals for object
+ * @param[in] obj Target object
+ */
+ static void processSignal(Evas_Object *obj);
+
+ /**
+ * @brief Process edje signals for object
+ */
+ void processSignal();
+
+ /**
+ * @brief Process all edje signals
+ */
+ static void processSignals();
+
+ /**
+ * @brief Sets user-data associated with specified key-string.
+ * @param[in] key a string-key.
+ * @param[in] data to be stored.
+ */
+ void setData(const char *key, const void *data);
+
+ /**
+ * @brief Sets the view mirrored mode.
+ * @param[in] obj evas object
+ * @param[in] true to set mirrored mode, false othewise
+ */
+ static void setMirrored(Evas_Object *obj, bool mirrored);
+ void setMirrored(bool mirrored);
+
+ /**
+ * @brief Gets data associated with specified key-string.
+ * @param[in] key a string-key.
+ * @return user-data.
+ */
+ void *getData(const char *key) const;
+ void addEventCb(Evas_Callback_Type type, Evas_Object_Event_Cb func, const void *data);
+ void addSmartCb(const char *event, Evas_Smart_Cb func, const void *data);
+ void addSignalCb(const char *emission, const char *source, Edje_Signal_Cb func, void *data);
+ void addHwButtonEvent(Eext_Callback_Type cbType, Eext_Event_Cb cb, void *data);
+ void HwButtonEvent(Eext_Callback_Type cbType, Eext_Event_Cb cb, void *data);
+
+ static void addHwButtonEvent(Evas_Object *obj, Eext_Callback_Type cbType, Eext_Event_Cb cb, void *data);
+ static void addEventCb(Evas_Object *obj, Evas_Callback_Type type, Evas_Object_Event_Cb func, const void *data);
+ static void addSmartCb(Evas_Object *obj, const char *event, Evas_Smart_Cb func, const void *data);
+ static void addSignalCb(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func, void *data);
+
+ template<typename T>
+ static T staticCast(void *evasObj);
+ template<typename T>
+ static T reinterpretCast(void *evasObj);
+ template<typename T>
+ static T dynamicCast(void *evasObj);
+
+ /**
+ * @brief Gets text placed in specified part.
+ * @param[in] part a part to get text from. If part is nullptr the default part is used.
+ * @return a text part contains. If part contains no text returns empty string.
+ */
+ std::string getText(const char *part = nullptr) const;
+
+ /**
+ * @brief A C-style implementation of getText().
+ */
+ const char *getTextCStr(const char *part = nullptr) const;
+
+ /**
+ * @brief Sets IDS of translatable string into specified part.
+ * @param[in] text a translatable text to be set in specified part.
+ * @param[in] part a part to get text from. If part is nullptr the default part is used.
+ */
+ void setText(const TText &text, const char *part = nullptr);
+
+ /**
+ * @brief Set the style to used by a given widget
+ * @param[in] style The name of the style to use on it
+ */
+ void setStyle(const char *style);
+ static void setStyle(Evas_Object *obj, const char *style);
+
+ /**
+ * @brief Gets the edje object
+ * @return edje object
+ */
+ Evas_Object *getEdje() const;
+
+ /**
+ * @brief Gets evas
+ * @return pointer to evas
+ */
+ Evas *getEvas() const;
+
+ /**
+ * @brief Resize view
+ * @param[in] w width
+ * @param[in] h height
+ */
+ void resize(Evas_Coord w, Evas_Coord h);
+
+ Atspi registerAccessObj(const char *part);
+ static Atspi registerAccessObj(Evas_Object *obj, const char *part);
+ Atspi registerAccessObj(Evas_Object *parent);
+ void unregisterAccessObj();
+ static Atspi registerAccessObj(Evas_Object *obj, Evas_Object *parent);
+ static void unregisterAccessObj(Evas_Object *obj);
+ static Atspi getAccessObj(Evas_Object *obj);
+ Atspi getAccessObj() const;
+
+ static void setText(Evas_Object *obj, const TText &text, const char *part = nullptr);
+
+ static Evas_Object *addLayout(Evas_Object *parent, const std::string &edjePath, const std::string &group);
+
+ protected:
+ virtual ~View();
+
+ /**
+ * @brief Allows children-classes to perform some cleanup activities before their destroying.
+ */
+ virtual void onBeforeDelete() {};
+ void setEo(Evas_Object *eo);
+
+ private:
+ View(View&) = delete;
+ View& operator=(View&) = delete;
+ Evas_Object_Event_Cb getCb(Evas_Callback_Type);
+ void *getData() const;
+ static void *getData(Evas_Object *obj);
+ void setData(const void *data);
+ static void setData(Evas_Object *obj, const void *data);
+
+ private:
+ static void on_free_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
+ static void on_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
+ };
+
+ std::string markupToUtf8(const char *str);
+ std::string utf8ToMarkup(const char *str);
+ std::string markupToUtf8(const std::string &str);
+ std::string utf8ToMarkup(const std::string &str);
+
+ inline View::operator Evas_Object *() const
+ {
+ return m_pEo;
+ }
+
+ inline Evas_Object *View::getEo() const
+ {
+ return (Evas_Object*)BaseView::getEo();
+ }
+
+ inline void View::destroy()
+ {
+ evas_object_del(m_pEo);
+ }
+
+ inline bool View::isVisible() const
+ {
+ return evas_object_visible_get(m_pEo);
+ }
+
+ inline void View::show(bool value)
+ {
+ value ? evas_object_show(m_pEo) : evas_object_hide(m_pEo);
+ }
+
+ inline void View::setSizeHintWeight(double x, double y)
+ {
+ evas_object_size_hint_weight_set(m_pEo, x, y);
+ }
+
+ inline void View::setSizeHintAlign(double x, double y)
+ {
+ evas_object_size_hint_align_set(m_pEo, x, y);
+ }
+
+ inline void View::setSizeHintMin(Evas_Coord w, Evas_Coord h)
+ {
+ evas_object_size_hint_min_set(m_pEo, w, h);
+ }
+
+ inline void View::setSizeHintMax(Evas_Coord w, Evas_Coord h)
+ {
+ evas_object_size_hint_max_set(m_pEo, w, h);
+ }
+
+ inline void View::getSizeHintMin(Evas_Coord *w, Evas_Coord *h) const
+ {
+ evas_object_size_hint_min_get(m_pEo, w, h);
+ };
+
+ inline void View::getSizeHintMax(Evas_Coord *w, Evas_Coord *h) const
+ {
+ evas_object_size_hint_max_get(m_pEo, w, h);
+ }
+
+ inline void View::move(Evas_Coord x, Evas_Coord y)
+ {
+ evas_object_move(m_pEo, x, y);
+ }
+
+ inline Evas_Object* View::getContent(const char *part) const
+ {
+ return elm_object_part_content_get(m_pEo, part);
+ }
+
+ inline void View::setFocusAllow(bool enable)
+ {
+ elm_object_focus_allow_set(m_pEo, enable);
+ }
+
+ inline bool View::getFocusAllow() const
+ {
+ return elm_object_focus_allow_get(m_pEo);
+ }
+
+ inline void View::setFocus(bool focus)
+ {
+ return elm_object_focus_set(m_pEo, focus);
+ }
+
+ inline bool View::getFocus() const
+ {
+ return elm_object_focus_get(m_pEo);
+ }
+
+ inline void View::setTranslatable(bool translatable, const char *domain, const char *part)
+ {
+ elm_object_domain_part_text_translatable_set(m_pEo, part, domain, translatable);
+ }
+
+ inline void View::emitSignal(const char *emission, const char *source, bool async)
+ {
+ emitSignal(m_pEo, emission, source, async);
+ }
+
+ inline void View::processSignal()
+ {
+ processSignal(m_pEo);
+ }
+
+ inline void View::processSignals()
+ {
+ edje_message_signal_process();
+ }
+
+ inline void View::setText(const TText &text, const char *part)
+ {
+ setText(m_pEo, text, part);
+ }
+
+ inline void View::setStyle(const char *style)
+ {
+ setStyle(getEo(), style);
+ }
+
+ inline void View::setStyle(Evas_Object *obj, const char *style)
+ {
+ elm_object_style_set(obj, style);
+ }
+
+ inline void View::setText(Evas_Object *obj, const TText &text, const char *part)
+ {
+ if (text.isTranslatable())
+ elm_object_domain_translatable_part_text_set(obj, part, text.getDomain(), text.getMsg());
+ else {
+ elm_object_part_text_translatable_set(obj, part, false);
+ elm_object_part_text_set(obj, part, text.getMsg());
+ }
+ }
+
+ inline std::string View::getText(const char *part) const
+ {
+ const char *text = getTextCStr(part);
+ return text ? text : "";
+ }
+
+ inline const char *View::getTextCStr(const char *part) const
+ {
+ return elm_object_part_text_get(m_pEo, part);
+ }
+
+ inline void View::setData(const char *key, const void *data)
+ {
+ evas_object_data_set(m_pEo, key, data);
+ }
+
+ inline void *View::getData(const char *key) const
+ {
+ return evas_object_data_get(m_pEo, key);
+ }
+
+ inline void View::setData(const void *data)
+ {
+ setData(m_pEo, data);
+ }
+
+ inline void *View::getData() const
+ {
+ return getData(m_pEo);
+ }
+
+ inline void View::resize(Evas_Coord w, Evas_Coord h)
+ {
+ evas_object_resize(m_pEo, w, h);
+ }
+
+ template<typename T>
+ inline T View::staticCast(void *evasObj)
+ {
+ return static_cast<T>(getData((Evas_Object*)evasObj));
+ }
+
+ template<typename T>
+ inline T View::reinterpretCast(void *evasObj)
+ {
+ return reinterpret_cast<T>(getData((Evas_Object*)evasObj));
+ }
+
+ template<typename T>
+ inline T View::dynamicCast(void *evasObj)
+ {
+ return dynamic_cast<T>(staticCast<View*>(evasObj));
+ }
+
+ inline void View::addEventCb(Evas_Callback_Type type, Evas_Object_Event_Cb func, const void *data)
+ {
+ evas_object_event_callback_add(m_pEo, type, func, data);
+ }
+
+ inline void View::addSmartCb(const char *event, Evas_Smart_Cb func, const void *data)
+ {
+ evas_object_smart_callback_add(m_pEo, event, func, data);
+ }
+
+ inline void View::addSignalCb(const char *emission, const char *source, Edje_Signal_Cb func, void *data)
+ {
+ elm_object_signal_callback_add(m_pEo, emission, source, func, data);
+ }
+
+ inline void View::addHwButtonEvent(Evas_Object *obj, Eext_Callback_Type cbType, Eext_Event_Cb cb, void *data)
+ {
+ eext_object_event_callback_add(obj, cbType, cb, data);
+ }
+
+ inline void View::addEventCb(Evas_Object *obj, Evas_Callback_Type type, Evas_Object_Event_Cb func, const void *data)
+ {
+ evas_object_event_callback_add(obj, type, func, data);
+ }
+
+ inline void View::addSmartCb(Evas_Object *obj, const char *event, Evas_Smart_Cb func, const void *data)
+ {
+ evas_object_smart_callback_add(obj, event, func, data);
+ }
+
+ inline void View::addSignalCb(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func, void *data)
+ {
+ elm_object_signal_callback_add(obj, emission, source, func, data);
+ }
+
+ inline void View::addHwButtonEvent(Eext_Callback_Type cbType, Eext_Event_Cb cb, void *data)
+ {
+ addHwButtonEvent(m_pEo, cbType, cb, data);
+ }
+
+ inline Evas_Object *View::unsetContent(const char *part)
+ {
+ return elm_object_part_content_unset(m_pEo, part);
+ }
+
+ inline Evas_Object *View::getEdje() const
+ {
+ return elm_layout_edje_get(m_pEo);
+ }
+
+ inline Evas *View::getEvas() const
+ {
+ return evas_object_evas_get(m_pEo);
+ }
+
+ inline void View::setMirrored(Evas_Object *obj, bool mirrored)
+ {
+ elm_object_mirrored_automatic_set(obj, mirrored);
+ elm_object_mirrored_set(obj, mirrored);
+ }
+
+ inline void View::setMirrored(bool mirrored)
+ {
+ setMirrored(getEo(), mirrored);
+ }
+
+ inline Atspi View::registerAccessObj(const char *part)
+ {
+ return registerAccessObj(m_pEo, part);
+ }
+
+ inline Atspi View::registerAccessObj(Evas_Object *obj, const char *part)
+ {
+ Evas_Object *edje = elm_layout_edje_get(obj);
+ Evas_Object *partObj = (Evas_Object *)edje_object_part_object_get(edje, part);
+ return registerAccessObj(partObj, obj);
+ }
+
+ inline Atspi View::registerAccessObj(Evas_Object *parent)
+ {
+ return registerAccessObj(m_pEo, parent);
+ }
+
+ inline void View::unregisterAccessObj()
+ {
+ unregisterAccessObj(m_pEo);
+ }
+
+ inline Atspi View::registerAccessObj(Evas_Object *obj, Evas_Object *parent)
+ {
+ return elm_access_object_register(obj, parent);
+ }
+
+ inline void View::unregisterAccessObj(Evas_Object *obj)
+ {
+ elm_access_object_unregister(obj);
+ }
+
+ inline Atspi View::getAccessObj(Evas_Object *obj)
+ {
+ return elm_access_object_get(obj);
+ }
+
+ inline Atspi View::getAccessObj() const
+ {
+ return getAccessObj(m_pEo);
+ }
+}
+
+#endif /* View_h_ */
diff --git a/src/Common/inc/WatchWindow.h b/src/Common/inc/WatchWindow.h
new file mode 100644
index 0000000..7d98ff6
--- /dev/null
+++ b/src/Common/inc/WatchWindow.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 WatchWindow_h_
+#define WatchWindow_h_
+
+#include "View.h"
+
+namespace IdleClock {
+ class WatchWindow
+ : public View {
+ public:
+ WatchWindow();
+ virtual ~WatchWindow();
+
+ Evas_Object *getLayout() const;
+ void setContent(Evas_Object *content);
+ void getScreenSize(int *w, int *h) const;
+ int getRotation() const;
+ void lower();
+ void raise();
+ };
+}
+
+#endif /* WatchWindow_h_ */
diff --git a/src/Common/src/I18nString.cpp b/src/Common/src/I18nString.cpp
new file mode 100644
index 0000000..8ce901e
--- /dev/null
+++ b/src/Common/src/I18nString.cpp
@@ -0,0 +1,137 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 "I18nString.h"
+#include <string.h>
+
+using namespace IdleClock;
+
+I18nString::I18nString()
+{
+}
+
+I18nString::I18nString(const I18nString &that)
+{
+ copyStr(that);
+}
+
+I18nString::I18nString(I18nString &&that)
+ : Impl(std::move(that))
+{
+}
+
+I18nString::I18nString(size_t count)
+ : Impl(count, 0)
+{
+}
+
+I18nString::I18nString(const char *str)
+{
+ copyStr(str);
+}
+
+I18nString::I18nString(const i18n_uchar *uStr)
+{
+ copyStr(uStr);
+}
+
+I18nString::I18nString(const std::string &str)
+ : I18nString(str.c_str())
+{
+}
+
+i18n_uchar *I18nString::getUStr() const
+{
+ return (i18n_uchar*)&front();
+}
+
+I18nString::operator i18n_uchar *() const
+{
+ return getUStr();
+}
+
+I18nString &I18nString::operator=(const I18nString &that)
+{
+ copyStr(that);
+ return *this;
+}
+
+int I18nString::getLen() const
+{
+ return data() ? i18n_ustring_get_length(data()) : 0;
+}
+
+std::string I18nString::toStr() const
+{
+ std::string res;
+ int len = length() * sizeof(i18n_uchar);
+ if (len >= 0) {
+ res.resize(len);
+ i18n_ustring_copy_au(&res.front(), data());
+ }
+ return res;
+}
+
+size_t I18nString::getCapacity() const
+{
+ return capacity();
+}
+
+void I18nString::clear()
+{
+ std::basic_string<i18n_uchar>::clear();
+}
+
+bool I18nString::isEmpty() const
+{
+ return Impl::empty();
+}
+
+void I18nString::copyStr(const I18nString &that)
+{
+ copyStr(that.getUStr());
+}
+
+void I18nString::copyStr(const i18n_uchar *uStr)
+{
+ clear();
+ if (uStr) {
+ int len = uStr ? i18n_ustring_get_length(uStr) : 0;
+ resize(len);
+ i18n_ustring_mem_copy(getUStr(), uStr, len);
+ }
+}
+
+void I18nString::copyStr(const std::string &str)
+{
+ clear();
+ if (!str.empty()) {
+ size_t len = str.length();
+ resize(len);
+ i18n_ustring_copy_ua_n(getUStr(), str.c_str(), len);
+ }
+}
+
+void I18nString::copyStr(const char *str)
+{
+ clear();
+ if (str) {
+ size_t len = strlen(str);
+ resize(len);
+ i18n_ustring_copy_ua_n(getUStr(), str, len);
+ }
+}
+
diff --git a/src/Common/src/Logger.cpp b/src/Common/src/Logger.cpp
new file mode 100644
index 0000000..1ac27ff
--- /dev/null
+++ b/src/Common/src/Logger.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 "Logger.h"
+
+namespace {
+ const std::string enterFraseFormat = "%s: %s(%d) -> [ENTER]";
+ const std::string leaveFraseFormat = "%s: %s -> [LEAVE]";
+ const log_priority defaultPriority = DLOG_DEBUG;
+}
+
+LoggerImpl::LoggerImpl(const char *tag, const char *file, const char *function, int line)
+ : m_Tag(tag)
+ , m_File(file)
+ , m_Function(function)
+{
+ dlog_print(defaultPriority
+ , m_Tag.c_str()
+ , enterFraseFormat.c_str()
+ , m_File.c_str()
+ , m_Function.c_str()
+ , line);
+}
+
+LoggerImpl::~LoggerImpl()
+{
+ dlog_print(defaultPriority
+ , m_Tag.c_str()
+ , leaveFraseFormat.c_str()
+ , m_File.c_str()
+ , m_Function.c_str());
+}
diff --git a/src/Common/src/PathUtils.cpp b/src/Common/src/PathUtils.cpp
new file mode 100644
index 0000000..1750fc1
--- /dev/null
+++ b/src/Common/src/PathUtils.cpp
@@ -0,0 +1,142 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 "PathUtils.h"
+#include "Logger.h"
+#include "Resource.h"
+
+#include <storage-expand.h>
+#include <stdlib.h>
+#include <app.h>
+
+namespace IdleClock {
+namespace PathUtils {
+
+std::string getResourcePath(const std::string &filePath)
+{
+ std::string res;
+ static std::string basePath;
+ if (basePath.empty()) {
+ char *path = app_get_resource_path();
+ if (path) {
+ basePath = path;
+ free(path);
+ }
+ }
+
+ res += basePath;
+ res += filePath;
+
+ return res;
+}
+
+std::string getDataPath(const std::string &filePath)
+{
+ std::string res;
+ static std::string basePath;
+ if (basePath.empty()) {
+ char *path = app_get_data_path();
+ if (path) {
+ basePath = path;
+ free(path);
+ }
+ }
+
+ res += basePath;
+ res += filePath;
+
+ return res;
+}
+
+std::string getResourcePath()
+{
+ std::string res;
+ char* resPath = app_get_resource_path();
+ if (resPath) {
+ res = resPath;
+ free(resPath);
+ }
+
+ return res;
+}
+
+std::string getLocalePath()
+{
+ std::string resPath(getResourcePath());
+ if (!resPath.empty()) {
+ resPath.append("locale");
+ }
+
+ return resPath;
+}
+
+static bool storageCb(int storageId, storage_type_e type, storage_state_e state, const char *path, void *userData)
+{
+ if (type == STORAGE_TYPE_INTERNAL) {
+ int *internalStorage = (int *)userData;
+ *internalStorage = storageId;
+ return false;
+ }
+ return true;
+}
+
+const std::string &getDownloadPath()
+{
+ static std::string downloadPath;
+
+ if (!downloadPath.empty())
+ return downloadPath;
+
+ char *dirPath = nullptr;
+ int storageId = -1;
+
+ int error = storage_foreach_device_supported(storageCb, &storageId);
+ if (error == STORAGE_ERROR_NONE)
+ storage_get_directory(storageId, STORAGE_DIRECTORY_DOWNLOADS, &dirPath);
+
+ if (dirPath) {
+ downloadPath = dirPath;
+ free(dirPath);
+ }
+
+ return downloadPath;
+}
+
+std::string getEdjePath(const std::string &fileName)
+{
+ return getResourcePath(EDJ_PATH"/" + fileName);
+}
+
+std::string getSharedResPath(const std::string &fileName)
+{
+ std::string res;
+ static std::string basePath;
+ if (basePath.empty()) {
+ char *path = app_get_shared_resource_path();
+ if (path) {
+ basePath = path;
+ free(path);
+ }
+ }
+
+ res += basePath;
+ res += fileName;
+
+ return res;
+}
+
+} // PathUtils
+} // TaskMngr
diff --git a/src/Common/src/View.cpp b/src/Common/src/View.cpp
new file mode 100644
index 0000000..639f4c2
--- /dev/null
+++ b/src/Common/src/View.cpp
@@ -0,0 +1,163 @@
+/*
+ * Copyright 2016 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 "View.h"
+#include "Logger.h"
+#include "PathUtils.h"
+
+#include <cstddef>
+#include <cassert>
+#include <map>
+
+using namespace IdleClock;
+
+namespace
+{
+ const char *thisKey = "this";
+}
+
+View::View()
+{
+}
+
+View::~View()
+{
+}
+
+void View::setEo(Evas_Object *eo)
+{
+ if (m_pEo) {
+ LOG_ERROR("m_pEo not null");
+ assert(false);
+ return;
+ }
+
+ BaseView::setEo(eo);
+
+ if (eo) {
+ setData(this);
+ evas_object_event_callback_add(eo, EVAS_CALLBACK_FREE, on_free_cb, this);
+ evas_object_event_callback_add(eo, EVAS_CALLBACK_DEL, on_del_cb, this);
+ }
+}
+
+Evas_Object *View::setContent(Evas_Object *obj, Evas_Object *content, const char *part, bool saveOldContent)
+{
+ Evas_Object *oldContent = saveOldContent ? elm_object_part_content_unset(obj, part) : nullptr;
+ elm_object_part_content_set(obj, part, content);
+ return oldContent;
+}
+
+Evas_Object *View::setContent(Evas_Object *content, const char *part, bool saveOldContent)
+{
+ return setContent(m_pEo, content, part, saveOldContent);
+}
+
+void View::on_free_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ auto *view = static_cast<View*>(data);
+ if (view)
+ view->onViewDestroyed();
+}
+
+void View::on_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ auto *view = static_cast<View*>(data);
+ if (view)
+ view->onBeforeDelete();
+}
+
+void View::expand()
+{
+ expand(m_pEo);
+}
+
+void View::expand(Evas_Object *obj)
+{
+ evas_object_size_hint_weight_set(obj, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(obj, EVAS_HINT_FILL, EVAS_HINT_FILL);
+}
+
+void View::processSignal(Evas_Object *obj)
+{
+ Evas_Object *edj = elm_layout_edje_get(obj);
+ edje_object_message_signal_process(edj);
+}
+
+void View::emitSignal(Evas_Object *obj, const char *emission, const char *source, bool async)
+{
+ elm_object_signal_emit(obj, emission, source);
+ if (!async)
+ processSignal(obj);
+}
+
+Evas_Object *View::addLayout(Evas_Object *parent, const std::string &edjePath, const std::string &group)
+{
+ Evas_Object *layout = elm_layout_add(parent);
+ std::string edjAbsPath = PathUtils::getEdjePath(edjePath);
+ elm_layout_file_set(layout, edjAbsPath.c_str(), group.c_str());
+ return layout;
+}
+
+void View::setData(Evas_Object *obj, const void *data)
+{
+ evas_object_data_set(obj, thisKey, (void*)data);
+}
+
+void *View::getData(Evas_Object *obj)
+{
+ return evas_object_data_get(obj, thisKey);
+}
+
+std::string IdleClock::markupToUtf8(const char *str)
+{
+ if (!str)
+ return std::string();
+
+ std::string res;
+ char *markup = elm_entry_markup_to_utf8(str);
+ if (markup) {
+ res = markup;
+ free(markup);
+ }
+
+ return res;
+}
+
+std::string IdleClock::utf8ToMarkup(const char *str)
+{
+ if (!str)
+ return std::string();
+
+ std::string res;
+ char *markup = elm_entry_utf8_to_markup(str);
+ if (markup) {
+ res = markup;
+ free(markup);
+ }
+
+ return res;
+}
+
+std::string IdleClock::markupToUtf8(const std::string &str)
+{
+ return markupToUtf8(str.c_str());
+}
+
+std::string IdleClock::utf8ToMarkup(const std::string &str)
+{
+ return utf8ToMarkup(str.c_str());
+}
diff --git a/src/Common/src/WatchWindow.cpp b/src/Common/src/WatchWindow.cpp
new file mode 100644
index 0000000..627f21b
--- /dev/null
+++ b/src/Common/src/WatchWindow.cpp
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 "WatchWindow.h"
+#include "Config.h"
+
+#include <watch_app_efl.h>
+
+using namespace IdleClock;
+
+WatchWindow::WatchWindow()
+{
+ Evas_Object *win = nullptr;
+
+ watch_app_get_elm_win(&win);
+ if (!win)
+ return;
+
+ setEo(win);
+ elm_win_title_set(win, PROJECT_NAME);
+ elm_win_borderless_set(win, true);
+ elm_win_alpha_set(win, false);
+ elm_win_indicator_mode_set(win, ELM_WIN_INDICATOR_HIDE);
+ elm_win_indicator_opacity_set(win, ELM_WIN_INDICATOR_BG_TRANSPARENT);
+ elm_win_prop_focus_skip_set(win, true);
+ elm_win_role_set(win, "no-effect");
+}
+
+WatchWindow::~WatchWindow()
+{
+}
+
+void WatchWindow::lower()
+{
+ elm_win_lower(getEo());
+}
+
+void WatchWindow::raise()
+{
+ elm_win_raise(getEo());
+}
+
+Evas_Object *WatchWindow::getLayout() const
+{
+ return getEo();
+}
+
+void WatchWindow::setContent(Evas_Object *content)
+{
+ expand(content);
+ evas_object_show(content);
+ elm_win_resize_object_add(getEo(), content);
+}
+
+void WatchWindow::getScreenSize(int *w, int *h) const
+{
+ elm_win_screen_size_get(getEo(), nullptr, nullptr, w, h);
+}
+
+int WatchWindow::getRotation() const
+{
+ return elm_win_rotation_get(getEo());
+}
+
diff --git a/src/clock_view.c b/src/clock_view.c
deleted file mode 100755
index 6a0b7a5..0000000
--- a/src/clock_view.c
+++ /dev/null
@@ -1,1288 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <app.h>
-#include <app_preference.h>
-#include <unistd.h>
-#include <device/display.h>
-#include <device/callback.h>
-#include <errno.h>
-#include <glib.h>
-#include <system_settings.h>
-
-#include <utils_i18n.h>
-
-#include <libxml/parser.h>
-#include <libxml/xpath.h>
-#include <libxml/xpathInternals.h>
-#include <libxml/xmlmemory.h>
-#include <libxml/xmlreader.h>
-#include <string.h>
-#include <libxml/encoding.h>
-#include <libxml/xmlwriter.h>
-
-#include "app_data.h"
-#include "clock_view.h"
-#include "window.h"
-#include "log.h"
-#include "util.h"
-
-#define MAX_PATH_LENGTH 1024
-
-static struct {
- int show_date;
- int clock_font_color;
-} setting_items_s = {
- .show_date = 1,
- .clock_font_color = 8,
-};
-
-/*
-font_color : 1 - #000000
-font_color : 2 - #CEFF00
-font_color : 3 - #FF6519
-font_color : 4 - #BCFFFB
-font_color : 5 - #F03880
-font_color : 6 - #FFEA00
-font_color : 7 - #673E27
-font_color : 8 - #FFFFFF
-font_color : 9 - #042860
-font_color : 10 - #F2DCC5
-font_color : 11 - #F62E00
-font_color : 12 - #595959
-*/
-
-static char font_color_list[][7] = { "000000", "CEFF00", "FF6519", "BCFFFB", "F03880", "FFEA00",
- "673E27", "FFFFFF", "042860", "F2DCC5", "F62E00", "595959"};
-
-#define DIGITAL_PREFERENCE_SHOW_DATE "showdate"
-#define DIGITAL_PREFERENCE_CLOCK_FONT_COLOR "clock_font_color"
-
-#define FONT_DEFAULT_FAMILY_NAME "Tizen:style=Bold"
-#define FONT_DEFAULT_SIZE 80
-
-#define BUFFER_LENGTH 256
-
-
-
-static void _clock_font_changed_cb(int node, void *data);
-
-
-
-void clock_view_show_clock(void *data)
-{
- _D("");
- appdata *ad = data;
- ret_if(!ad);
-
- elm_object_signal_emit(ad->ly_time, "show_effect", "");
- ad->is_show = true;
-}
-
-
-
-void clock_view_hide_clock(void *data)
-{
- _D("");
- appdata *ad = data;
- ret_if(!ad);
-
- elm_object_signal_emit(ad->ly_time, "hide_effect", "");
- ad->is_show = false;
-}
-
-
-
-void clock_view_set_result_data(void *data)
-{
- _D("");
- appdata *ad = data;
- ret_if(!ad);
-
- int ret = 0;
- bool existing = false;
-
- ret = preference_is_existing(DIGITAL_PREFERENCE_SHOW_DATE, &existing);
- if (!ret) {
- if (!existing) ret = preference_set_int(DIGITAL_PREFERENCE_SHOW_DATE, setting_items_s.show_date);
- if (0 != ret) _E("cannot set the show date(%d)", ret);
- } else _E("cannot check the preference is existing(%d)");
-
- ret = preference_is_existing(DIGITAL_PREFERENCE_CLOCK_FONT_COLOR, &existing);
- if (!ret) {
- if (!existing) ret = preference_set_int(DIGITAL_PREFERENCE_CLOCK_FONT_COLOR, setting_items_s.clock_font_color);
- if (0 != ret) _E("cannot set the clock font color(%d)", ret);
- } else _E("cannot check the preference is existing(%d)");
-
- _clock_font_changed_cb(0, ad);
-}
-
-
-
-int clock_view_parse_result_data(const char *result_data)
-{
- _D("");
- retv_if(!result_data, -1);
-
- int i = 0;
- xmlDocPtr doc = NULL;
- xmlXPathContextPtr xpath_context = NULL;
- xmlXPathObjectPtr xpath_obj_organization = NULL;
- xmlChar *xpath_organization = (xmlChar*)"/Application/SettingsResult/Item";
-
- xmlInitParser();
-
- doc = xmlParseMemory(result_data, strlen(result_data));
- if (!doc) {
- _E("unable to xmlParseMemory");
- return -1;
- }
-
- /* Create xpath evaluation context */
- xpath_context = xmlXPathNewContext(doc);
- if (!xpath_context) {
- _E("unable to create new XPath context");
- xmlFreeDoc(doc);
- return -1;
- }
-
- xpath_obj_organization = xmlXPathEvalExpression(xpath_organization, xpath_context);
- if (!xpath_obj_organization) {
- _E("unable to xmlXPathEvalExpression!");
- xmlXPathFreeContext(xpath_context);
- xmlFreeDoc(doc);
- return -1;
- }
-
- if (xpath_obj_organization->nodesetval->nodeNr) {
- _D("node count [%d]", xpath_obj_organization->nodesetval->nodeNr);
- } else {
- _E("xmlXPathEvalExpression failed");
- xmlXPathFreeObject(xpath_obj_organization);
- xmlXPathFreeContext(xpath_context);
- xmlFreeDoc(doc);
- return -1;
- }
-
- for (i = 0; i < xpath_obj_organization->nodesetval->nodeNr; i++) {
- xmlNodePtr itemNode = xpath_obj_organization->nodesetval->nodeTab[i];
- if (itemNode) {
- char *id = NULL;
- id = (char *) xmlGetProp(itemNode, (const xmlChar *)"id");
- if (!id) {
- _E("xmlGetProp failed");
- goto FINISH_OFF;
- }
-
- if (strcmp(id, "showdate") == 0) {
- xmlNodePtr childNode = xmlFirstElementChild(itemNode);
- char *checked = NULL;
-
- while (childNode) {
- checked = (char *) xmlGetProp(childNode, (const xmlChar *)"checked");
- if (checked) {
- _D("checked:%s", checked);
- if (strcmp(checked, "yes") == 0)
- setting_items_s.show_date = 1;
- else if (strcmp(checked, "no") == 0)
- setting_items_s.show_date = 0;
-
- xmlFree(checked);
- }
- childNode = xmlNextElementSibling(childNode);
- }
- xmlFree(childNode);
- } else if (strcmp(id, "clock_font_color") == 0) {
- xmlNodePtr childNode = xmlFirstElementChild(itemNode);
- char *selected = NULL;
- int num = 0;
-
- while (childNode) {
- selected = (char *) xmlGetProp(childNode, (const xmlChar *)"selected");
- if (selected) {
- _D("clock_font_color: selected:%s", selected);
- num = atoi(selected);
- setting_items_s.clock_font_color = num;
- xmlFree(selected);
- }
- childNode = xmlNextElementSibling(childNode);
- }
- xmlFree(childNode);
- }
- xmlFree(id);
- }
- }
-
-FINISH_OFF:
- if (xpath_obj_organization)
- xmlXPathFreeObject(xpath_obj_organization);
-
- if (xpath_context)
- xmlXPathFreeContext(xpath_context);
-
- if (doc)
- xmlFreeDoc(doc);
-
- xmlCleanupParser();
-
- return 0;
-}
-
-
-
-static char *_get_locale(void)
-{
- _D("");
- char *locale = NULL;
-
- int ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, &locale);
- if (ret < 0) {
- _E("fail to get the locale country value(%d)", ret);
- return strdup("en_US");
- }
-
- if (!locale) {
- _E("system settings fail to get value: region format");
- return strdup("en_US");
- }
- _D("locale is %s", locale);
-
- return locale;
-}
-
-
-
-static i18n_udatepg_h _get_generator(void *data)
-{
- _D("");
-
- int status = I18N_ERROR_INVALID_PARAMETER;
- i18n_udatepg_h generator = NULL;
-
- //UChar u_skeleton[64] = {0,};
-
- appdata *ad = data;
- retv_if(!ad, NULL);
-
-
- status = i18n_ulocale_set_default(NULL);
- if (status != I18N_ERROR_NONE) {
- _E("uloc_setDefault() is failed.");
- return NULL;
- }
-
- //i18n_ustring_copy_ua_n(u_skeleton, "hhmm", strlen("hhmm"));
-
- if (!ad->timeregion_format)
- ad->timeregion_format = _get_locale();
-
- status = i18n_udatepg_create(ad->timeregion_format, &generator);
- if (status != I18N_ERROR_NONE) {
- _E("udatepg_creation is failed");
- generator = NULL;
- return NULL;
- }
-
- _D("get_generator success");
- return generator;
-}
-
-
-
-static i18n_udate_format_h _get_time_formatter(void *data)
-{
- _D("");
-
- char a_best_pattern[64] = {0.};
- char *a_best_pattern_fixed = NULL;
-
- char *saveptr1, *saveptr2;
- int status = I18N_ERROR_INVALID_PARAMETER;
-
- i18n_uchar u_pattern[64] = {0,};
- i18n_uchar u_timezone[64] = {0,};
- i18n_uchar u_best_pattern[64] = {0,};
- int32_t u_best_pattern_capacity;
- int32_t best_pattern_len;
- i18n_udate_format_h formatter = NULL;
-
- appdata *ad = data;
- retv_if(!ad, NULL);
-
- if (!ad->generator)
- ad->generator = _get_generator(ad);
-
- /* only 12 format */
-
- if (!i18n_ustring_copy_ua_n(u_pattern, "h:mm", sizeof(u_pattern))) {
- _E("ustring_copy() is failed.");
- return NULL;
- }
-
- u_best_pattern_capacity =
- (int32_t) (sizeof(u_best_pattern) / sizeof((u_best_pattern)[0]));
-
- status = i18n_udatepg_get_best_pattern(ad->generator, u_pattern, i18n_ustring_get_length(u_pattern),
- u_best_pattern, u_best_pattern_capacity, &best_pattern_len);
- if (status != I18N_ERROR_NONE) {
- _E("get best pattern() failed(%d)", status);
- return NULL;
- }
-
- /* remove am/pm of best pattern */
- retv_if(!i18n_ustring_copy_au(a_best_pattern, u_best_pattern), NULL);
- _D("best pattern [%s]", a_best_pattern);
- a_best_pattern_fixed = strtok_r(a_best_pattern, "a", &saveptr1);
- a_best_pattern_fixed = strtok_r(a_best_pattern_fixed, " ", &saveptr2);
- _D("best pattern fixed [%s]", a_best_pattern_fixed);
-
- if (a_best_pattern_fixed) {
- /* exception - da_DK */
- if (strncmp(ad->timeregion_format, "da_DK", 5) == 0
- || strncmp(ad->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) {
- i18n_ustring_copy_ua(u_best_pattern, a_best_pattern_changed);
- g_free(a_best_pattern_changed);
- }
- } else {
- retv_if(!i18n_ustring_copy_ua(u_best_pattern, a_best_pattern_fixed), NULL);
- }
- }
-
- /* change char to UChar */
- retv_if(!i18n_ustring_copy_n(u_pattern, u_best_pattern, sizeof(u_pattern)), NULL);
-
- /* get formatter */
- i18n_ustring_copy_ua_n(u_timezone, ad->timezone_id, sizeof(u_timezone));
- status = i18n_udate_create(I18N_UDATE_PATTERN, I18N_UDATE_PATTERN, ad->timeregion_format, u_timezone, -1,
- u_pattern, -1, &formatter);
- if (!formatter) {
- _E("time_create() is failed.%d", status);
-
- return NULL;
- }
-
- _D("getting time formatter success");
- return formatter;
-}
-
-
-
-static i18n_udate_format_h _get_time_formatter_24(void *data)
-{
- _D("");
-
- char a_best_pattern[64] = {0.};
- char *a_best_pattern_fixed = NULL;
- char *saveptr1 = NULL;
- char *saveptr2 = NULL;
- int status = I18N_ERROR_INVALID_PARAMETER;
-
- i18n_uchar u_pattern[64] = {0,};
- i18n_uchar u_timezone[64] = {0,};
- i18n_uchar u_best_pattern[64] = {0,};
- int32_t u_best_pattern_capacity;
- int32_t best_pattern_len;
- i18n_udate_format_h formatter = NULL;
-
- appdata *ad = data;
- retv_if(!ad, NULL);
-
- if (!ad->generator)
- ad->generator = _get_generator(ad);
-
- /* only 12 format */
- if (!i18n_ustring_copy_ua_n(u_pattern, "H:mm", sizeof(u_pattern))) {
- _E("ustring_copy() is failed.");
- return NULL;
- }
-
- u_best_pattern_capacity =
- (int32_t) (sizeof(u_best_pattern) / sizeof((u_best_pattern)[0]));
-
- status = i18n_udatepg_get_best_pattern(ad->generator, u_pattern, i18n_ustring_get_length(u_pattern),
- u_best_pattern, u_best_pattern_capacity, &best_pattern_len);
- if (status != I18N_ERROR_NONE) {
- _E("get best pattern() failed(%d)", status);
- return NULL;
- }
-
- /* remove am/pm of best pattern */
- retv_if(!i18n_ustring_copy_au(a_best_pattern, u_best_pattern), NULL);
- _D("best pattern [%s]", a_best_pattern);
- a_best_pattern_fixed = strtok_r(a_best_pattern, "a", &saveptr1);
- a_best_pattern_fixed = strtok_r(a_best_pattern_fixed, " ", &saveptr2);
- _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(ad->timeregion_format, "id_ID", 5) == 0
- || strncmp(ad->timeregion_format, "da_DK", 5) == 0
- || strncmp(ad->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) {
- i18n_ustring_copy_ua(u_best_pattern, a_best_pattern_changed);
- g_free(a_best_pattern_changed);
- }
- } else {
- retv_if(!i18n_ustring_copy_ua(u_best_pattern, a_best_pattern_fixed), NULL);
- }
- }
-
- /* change char to UChar */
-
- retv_if(!i18n_ustring_copy_n(u_pattern, u_best_pattern, sizeof(u_pattern)), NULL);
-
- /* get formatter */
- i18n_ustring_copy_ua_n(u_timezone, ad->timezone_id, sizeof(u_timezone));
- status = i18n_udate_create(I18N_UDATE_PATTERN, I18N_UDATE_PATTERN, ad->timeregion_format, u_timezone, -1,
- u_pattern, -1, &formatter);
- if (!formatter) {
- _E("time24_create() is failed.");
- return NULL;
- }
-
- _D("getting time formatter success");
- return formatter;
-}
-
-
-
-static i18n_udate_format_h _get_date_formatter(void *data)
-{
- _D("");
-
- i18n_uchar u_timezone[64] = {0,};
- i18n_uchar u_skeleton[64] = {0,};
- int32_t skeleton_len = 0;
- int status = I18N_ERROR_INVALID_PARAMETER;
-
- i18n_uchar u_best_pattern[64] = {0,};
- int32_t u_best_pattern_capacity;
- i18n_udate_format_h formatter = NULL;
-
- appdata *ad = data;
- retv_if(!ad, NULL);
-
- i18n_ustring_copy_ua_n(u_skeleton, "MMMEd", strlen("MMMEd"));
- skeleton_len = i18n_ustring_get_length(u_skeleton);
-
- u_best_pattern_capacity =
- (int32_t) (sizeof(u_best_pattern) / sizeof((u_best_pattern)[0]));
- status = i18n_udatepg_get_best_pattern(ad->generator, u_skeleton, skeleton_len,
- u_best_pattern, u_best_pattern_capacity, &status);
- if (status != I18N_ERROR_NONE) {
- _E("get best pattern() failed(%d)", status);
- return NULL;
- }
-
- if (strncmp(ad->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) {
- i18n_ustring_copy_ua(u_best_pattern, a_best_pattern_changed);
- g_free(a_best_pattern_changed);
- }
- }
-
- /* get formatter */
-
- i18n_ustring_copy_ua_n(u_timezone, ad->timezone_id, sizeof(u_timezone));
- status = i18n_udate_create(I18N_UDATE_PATTERN, I18N_UDATE_PATTERN, ad->timeregion_format, u_timezone, -1, u_best_pattern, -1, &formatter);
-
- if (!formatter) {
- _E("udate_create() is failed.");
- return NULL;
- }
-
- _D("getting date formatter success");
-
- return formatter;
-
-}
-
-
-
-static i18n_udate_format_h _get_ampm_formatter(void *data)
-{
- _D("");
-
- int status = I18N_ERROR_INVALID_PARAMETER;
-
- char a_best_pattern[64] = {0.};
-
- i18n_uchar u_timezone[64] = {0,};
- i18n_uchar u_skeleton[64] = {0,};
- int32_t skeleton_len = 0;
-
- i18n_uchar u_best_pattern[64] = {0,};
- int32_t u_best_pattern_capacity;
- i18n_udate_format_h formatter = NULL;
-
- appdata *ad = data;
- retv_if(!ad, NULL);
-
- i18n_ustring_copy_ua_n(u_skeleton, "hhmm", strlen("hhmm"));
- skeleton_len = i18n_ustring_get_length(u_skeleton);
-
- u_best_pattern_capacity =
- (int32_t) (sizeof(u_best_pattern) / sizeof((u_best_pattern)[0]));
- status = i18n_udatepg_get_best_pattern(ad->generator, u_skeleton, skeleton_len,
- u_best_pattern, u_best_pattern_capacity, &status);
- if (status != I18N_ERROR_NONE) {
- _E("get best pattern() failed(%d)", status);
- return NULL;
- }
-
- i18n_ustring_copy_au(a_best_pattern, u_best_pattern);
- i18n_ustring_copy_ua(u_best_pattern, "a");
-
- if (a_best_pattern[0] == 'a')
- ad->is_pre = EINA_TRUE;
- else
- ad->is_pre = EINA_FALSE;
-
- /* get formatter */
- i18n_ustring_copy_ua_n(u_timezone, ad->timezone_id, sizeof(u_timezone));
- status = i18n_udate_create(I18N_UDATE_PATTERN, I18N_UDATE_PATTERN, ad->timeregion_format, u_timezone, -1, u_best_pattern, -1, &formatter);
- if (!formatter) {
- _E("ampm_create() is failed.");
- return NULL;
- }
-
- _D("getting ampm formatter success");
-
- return formatter;
-}
-
-
-
-static void _set_formatters(void *data)
-{
- _D("");
-
- appdata *ad = data;
- ret_if(!ad);
-
- /* generator */
- ad->generator = _get_generator(ad);
- /* time formatter */
- ad->formatter_time = _get_time_formatter(ad);
- /* ampm formatter */
- ad->formatter_ampm = _get_ampm_formatter(ad);
- /* 24 time formatter */
- ad->formatter_time_24 = _get_time_formatter_24(ad);
- /* date formatter */
- ad->formatter_date = _get_date_formatter(ad);
-}
-
-
-
-static void _remove_formatters(void *data)
-{
- _D("");
-
- appdata *ad = data;
- ret_if(!ad);
-
- if (ad->generator) {
- i18n_udatepg_destroy(ad->generator);
- ad->generator = NULL;
- }
- if (ad->formatter_time) {
- i18n_udate_destroy(ad->formatter_time);
- ad->formatter_time = NULL;
- }
- if (ad->formatter_ampm) {
- i18n_udate_destroy(ad->formatter_ampm);
- ad->formatter_ampm = NULL;
- }
- if (ad->formatter_time_24) {
- i18n_udate_destroy(ad->formatter_time_24);
- ad->formatter_time_24 = NULL;
- }
- if (ad->formatter_date) {
- i18n_udate_destroy(ad->formatter_date);
- ad->formatter_date = NULL;
- }
-}
-
-
-
-static int _get_formatted_date_from_utc_time(void *data, time_t intime, char *buf, int buf_len)
-{
- appdata *ad = data;
- retv_if(!ad, -1);
- retv_if(!ad->formatter_date, -1);
-
- i18n_udate u_time = (i18n_udate)intime * 1000;
- i18n_uchar u_formatted_str[64] = {0,};
- int32_t u_formatted_str_capacity;
- int32_t formatted_str_len = -1;
- int status = I18N_ERROR_INVALID_PARAMETER;
-
- /* calculate formatted string capacity */
- u_formatted_str_capacity =
- (int32_t)(sizeof(u_formatted_str) / sizeof((u_formatted_str)[0]));
-
- /* fomatting date using formatter */
- status = i18n_udate_format_date(ad->formatter_date, u_time, u_formatted_str, u_formatted_str_capacity, NULL, &formatted_str_len);
- if (status != I18N_ERROR_NONE) {
- _E("udat_format() failed");
- return -1;
- }
-
- if (formatted_str_len <= 0)
- _E("formatted_str_len is less than 0");
-
- buf = i18n_ustring_copy_au_n(buf, u_formatted_str, (int32_t)buf_len);
- _SD("date:(%d)[%s][%d]", formatted_str_len, buf, intime);
-
- return 0;
-}
-
-
-
-static int _get_formatted_ampm_from_utc_time(void *data, time_t intime, char *buf, int buf_len, int *ampm_len)
-{
- appdata *ad = data;
- retv_if(!ad, -1);
- retv_if(!ad->formatter_ampm, -1);
-
- i18n_udate u_time = (i18n_udate)intime * 1000;
- i18n_uchar u_formatted_str[64] = {0,};
- int32_t u_formatted_str_capacity;
- int32_t formatted_str_len = -1;
- int status = I18N_ERROR_INVALID_PARAMETER;
-
- /* calculate formatted string capacity */
- u_formatted_str_capacity =
- (int32_t)(sizeof(u_formatted_str) / sizeof((u_formatted_str)[0]));
-
- /* fomatting date using formatter */
- status = i18n_udate_format_date(ad->formatter_ampm, u_time, u_formatted_str, u_formatted_str_capacity, NULL, &formatted_str_len);
- if (status != I18N_ERROR_NONE) {
- _E("udat_format() failed");
- return -1;
- }
-
- if (formatted_str_len <= 0)
- _E("formatted_str_len is less than 0");
-
-
- (*ampm_len) = i18n_ustring_get_length(u_formatted_str);
-
- buf = i18n_ustring_copy_au_n(buf, u_formatted_str, (int32_t)buf_len);
- _SD("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)
-{
- appdata *ad = data;
- retv_if(!ad, -1);
-
- i18n_udate u_time = (i18n_udate)intime * 1000;
- i18n_uchar u_formatted_str[64] = {0,};
- int32_t u_formatted_str_capacity;
- int32_t formatted_str_len = -1;
- int status = I18N_ERROR_INVALID_PARAMETER;
-
- /* 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(ad->formatter_time_24 == NULL, -1);
- status = i18n_udate_format_date(ad->formatter_time_24, u_time, u_formatted_str, u_formatted_str_capacity, NULL, &formatted_str_len);
- } else {
- retv_if(ad->formatter_time == NULL, -1);
- status = i18n_udate_format_date(ad->formatter_time, u_time, u_formatted_str, u_formatted_str_capacity, NULL, &formatted_str_len);
- }
- if (status != I18N_ERROR_NONE) {
- _E("udat_format() failed");
- return -1;
- }
-
- if (formatted_str_len <= 0)
- _E("formatted_str_len is less than 0");
-
- buf = i18n_ustring_copy_au_n(buf, u_formatted_str, (int32_t)buf_len);
- _SD("time:(%d)[%s][%d]", formatted_str_len, buf, intime);
-
- return 0;
-}
-
-
-
-#if 0
-static char *_replaceAll(char *s, const char *olds, const char *news)
-{
- char *result, *sr;
- size_t i, count = 0;
- size_t oldlen = strlen(olds); if (oldlen < 1) return s;
- size_t newlen = strlen(news);
-
-
- if (newlen != oldlen) {
- for (i = 0; s[i] != '\0';) {
- if (memcmp(&s[i], olds, oldlen) == 0) count++, i += oldlen;
- else i++;
- }
- } else i = strlen(s);
-
-
- result = (char *) malloc(i + 1 + count * (newlen - oldlen));
- if (!result) return NULL;
-
- sr = result;
- while (*s) {
- if (memcmp(s, olds, oldlen) == 0) {
- memcpy(sr, news, newlen);
- sr += newlen;
- s += oldlen;
- } else *sr++ = *s++;
- }
- *sr = '\0';
-
- return result;
-}
-#endif
-
-
-
-Eina_Bool clock_view_set_info_time(void *data)
-{
- _D("");
- appdata *ad = data;
- if (!ad) {
- _D("appdata is NULL");
- return ECORE_CALLBACK_RENEW;
- }
- struct tm tempts;
- struct tm *ts = NULL;
- time_t tt;
- int err_code = 0;
- int showdate = 1;
- int clock_font_color = 8;
- display_state_e val;
- int ampm_length = 0;
- char font_buf[512] = {0, };
- char utc_date[256] = { 0, }; //text_date
- char utc_time[BUFFER_LENGTH] = { 0 };
- char utc_ampm[BUFFER_LENGTH] = { 0 };
- char *time_str = NULL;
- tt = time(NULL);
- ts = localtime_r(&tt , &tempts);
- retv_if(!ts, ECORE_CALLBACK_RENEW);
-
- if (ad->timer != NULL) {
- ecore_timer_del(ad->timer);
- ad->timer = NULL;
- }
-
- device_display_get_state(&val);
- if (val != DISPLAY_STATE_SCREEN_OFF)
- ad->timer = ecore_timer_add(60 - ts->tm_sec, clock_view_set_info_time, ad);
-
- /* text_date */
- err_code = preference_get_int(DIGITAL_PREFERENCE_CLOCK_FONT_COLOR, &clock_font_color);
- if (0 != err_code) clock_font_color = setting_items_s.clock_font_color;
-
- if (clock_font_color < 1 || clock_font_color > 12) //Exception
- clock_font_color = 8;
-
- err_code = preference_get_int(DIGITAL_PREFERENCE_SHOW_DATE, &showdate);
- if (0 != err_code) showdate = setting_items_s.show_date;
-
- _D("show_date:%d", showdate);
-
- if (showdate) {
- _get_formatted_date_from_utc_time(ad, tt, utc_date, sizeof(utc_date));
- elm_object_part_text_set(ad->ly_time, "default_text_date", utc_date);
- snprintf(font_buf, sizeof(font_buf)-1, "%s_%d", "show,default_text_date", clock_font_color);
- elm_object_signal_emit(ad->ly_time, font_buf, "source_default_text_date");
- }
- _D("");
-
- Eina_Bool is_pre = ad->is_pre;
- Eina_Bool is_24hour = EINA_FALSE;
-
- if (!ad->timeformat) {
- _get_formatted_ampm_from_utc_time(ad, tt, utc_ampm, sizeof(utc_ampm), &ampm_length);
- _get_formatted_time_from_utc_time(ad, tt, utc_time, sizeof(utc_time), EINA_FALSE);
- is_24hour = EINA_FALSE;
- } else {
- _get_formatted_time_from_utc_time(ad, 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 (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");
- }
-
- if (is_24hour == EINA_TRUE) {
- time_str = g_strdup_printf("<color=#%sFF>%s</color>", font_color_list[clock_font_color-1], utc_time);
- } else {
- if (is_pre == EINA_TRUE)
- time_str = g_strdup_printf("<color=#%sFF><font_size=24><font=Tizen:style=Bold>%s</font></font_size>%s</color>", font_color_list[clock_font_color-1], utc_ampm, utc_time);
- else
- // Todo : Fix the gap between clock and ampm.
- time_str = g_strdup_printf("<color=#%sFF>%s<font_size=24><font=Tizen:style=Bold> %s</font></font_size></color>", font_color_list[clock_font_color-1], utc_time, utc_ampm);
- }
- _D("time_str=%s", time_str);
-
- elm_object_part_text_set(ad->ly_time, "textblock_time", time_str);
- elm_object_signal_emit(ad->ly_time, "change,default", "source_textblock_time");
-
- g_free(time_str);
-
- return ECORE_CALLBACK_RENEW;
-}
-
-
-
-void clock_view_update_view(void *data)
-{
- _D("");
- appdata *ad = data;
- if (!ad) {
- _E("appdata is NULL");
- return;
- }
-
- if (ad->win)
- clock_view_set_info_time(ad);
-}
-
-
-
-static i18n_uchar *_uastrcpy(const char *chars)
-{
- _D("");
- int len = 0;
- i18n_uchar *str = NULL;
- len = strlen(chars);
- str = (i18n_uchar *) malloc(sizeof(i18n_uchar) *(len + 1));
- if (!str)
- return NULL;
- i18n_ustring_copy_ua(str, chars);
- return str;
-}
-
-
-
-static void ICU_set_timezone(const char *timezone)
-{
- _D("%s", __func__);
- if (!timezone) {
- _E("TIMEZONE is NULL");
- return;
- }
-
- int ec = I18N_ERROR_NONE;
- i18n_uchar *str = _uastrcpy(timezone);
-
- ec = i18n_ucalendar_set_default_timezone(str);
- _D("ec:%d" , ec);
- free(str);
-}
-
-
-
-static char* _get_timezone()
-{
- _D("");
- char *timezone = NULL;
-
- int ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, &timezone);
- if (ret < 0)
- _E("fail to get the locale time zone value(%d)", ret);
-
- if (!timezone)
- _E("system settings fail to get value: time zone");
-
- _D("time zone : %s", timezone);
-
- return timezone;
-}
-
-
-
-static void _time_status_changed_cb(system_settings_key_e key, void *data)
-{
- _D("");
-
- appdata *ad = data;
- ret_if(!ad);
-
- if (ad->timezone_id) {
- free(ad->timezone_id);
- ad->timezone_id = NULL;
- }
- if (ad->timeregion_format) {
- free(ad->timeregion_format);
- ad->timeregion_format = NULL;
- }
-
- ad->timezone_id = _get_timezone();
- ICU_set_timezone(ad->timezone_id);
- ad->timeregion_format = _get_locale();
-
- _D("[%d][%s][%s]", ad->timeformat, ad->timeregion_format, ad->timezone_id);
- _D("system setting key : %d", key);
-
- _remove_formatters(ad);
- _set_formatters(ad);
-
- clock_view_set_info_time(ad);
-}
-
-
-#if 0
-static void _clear_time(void *data)
-{
- _D("");
- appdata *ad = data;
- ret_if(!ad);
-
- clock_view_hide_clock(ad);
-
- if (ad->timer) {
- ecore_timer_del(ad->timer);
- ad->timer = NULL;
- }
-}
-#endif
-
-
-static void _clock_font_changed_cb(int node, void *data)
-{
- _D("");
- appdata *ad = data;
- ret_if(!ad);
-
- char font_buf[512] = {0, };
-
- int show_date = 1;
- int clock_font_color = 8;
- int ret = 0;
-
- /* font */
- elm_config_font_overlay_set("idle_font", FONT_DEFAULT_FAMILY_NAME, FONT_DEFAULT_SIZE);
-
- elm_config_font_overlay_apply();
-
- ret = preference_get_int(DIGITAL_PREFERENCE_SHOW_DATE, &setting_items_s.show_date);
- if (!ret) show_date = setting_items_s.show_date;
- else _E("fail to get the show date (%d)", ret);
-
- ret = preference_get_int(DIGITAL_PREFERENCE_CLOCK_FONT_COLOR, &setting_items_s.clock_font_color);
- if (!ret) clock_font_color = setting_items_s.clock_font_color;
- else _E("fail to get the clock font color (%d)", ret);
-
- _D("show_date:%d, font color:%d", show_date, clock_font_color);
-
- if (show_date) {
- snprintf(font_buf, sizeof(font_buf)-1, "%s_%d", "show,default_text_date", clock_font_color);
- elm_object_signal_emit(ad->ly_time, font_buf, "source_default_text_date");
- elm_object_signal_emit(ad->ly_time, "change,default", "source_textblock_time");
- } else {
- elm_object_signal_emit(ad->ly_time, "hide,text_date", "source_text_date");
- elm_object_signal_emit(ad->ly_time, "change,no_data", "source_textblock_time");
- }
-
- if (node)
- clock_view_set_info_time(ad);
-}
-
-
-
-int clock_view_get_display_state()
-{
- _D("");
- display_state_e val;
- device_display_get_state(&val);
- _D("DISPLAY STATE [%d]", val);
- return val;
-}
-
-
-
-static void _device_state_changed_cb(device_callback_e type, void *value, void *data)
-{
- _D("");
- appdata *ad = data;
- struct tm *ts = NULL;
- time_t tt;
- struct tm tempts;
-
- if (!ad) {
- _E("ad is null. check!!");
- return;
- }
-
- if (type != DEVICE_CALLBACK_DISPLAY_STATE) {
- _E("Wrong callback was called. check!!!");
- return;
- }
- display_state_e val = (display_state_e)value;
- _D("DISPLAY STATE [%d] ", val);
-
- if (val == DISPLAY_STATE_NORMAL) {
- if (!ad->is_show) {
- clock_view_set_info_time(ad);
- clock_view_show_clock(ad);
- }
-
- tt = time(NULL);
- ret_if(tt == (time_t)-1);
- ts = localtime_r(&tt, &tempts);
- ret_if(!ts);
- if (ad->timer) {
- ecore_timer_del(ad->timer);
- ad->timer = NULL;
- }
- ad->timer = ecore_timer_add(60 - ts->tm_sec, clock_view_set_info_time, ad);
- } else if (val == DISPLAY_STATE_SCREEN_OFF) {
- //_clear_time(data); //Disable this code for transit to alpm clock
- _D("Display state is off");
- } else {
- _D("Not interested PM STATE");
- }
-}
-
-
-
-static void _language_changed_cb(system_settings_key_e key, void *data)
-{
- _D("%s", __func__);
- appdata *ad = data;
- ret_if(!ad);
-
- sleep(1);
- _time_status_changed_cb(key, ad);
-}
-
-
-
-static void _timeformat_changed_cb(system_settings_key_e key, void *data)
-{
- _D("");
- appdata *ad = data;
- ret_if(!ad);
-
- bool val = false;
-
- system_settings_get_value_bool(key, &val);
- ad->timeformat = (int) val;
- _time_status_changed_cb(key, ad);
-}
-
-
-
-static void _set_settings(void *data)
-{
- _D("");
- appdata *ad = data;
- ret_if(!ad);
- int ret = -1;
-
- /* register time changed cb */
- ret = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_TIME_CHANGED, _time_status_changed_cb, ad);
- if (ret < 0)
- _E("Failed to set time changed cb.(%d)", ret);
-
- /*Register changed cb(timezone) */
- ret = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, _time_status_changed_cb, ad);
- if (ret < 0)
- _E("Failed to set time zone change cb(%d)", ret);
-
- /* Register changed cb(pm mode) */
- ret = device_add_callback(DEVICE_CALLBACK_DISPLAY_STATE, _device_state_changed_cb, ad);
- if (DEVICE_ERROR_NONE != ret)
- _E("Failed to add device display state changed cb(%d)", ret);
-
- /*Register changed cb(language) */
- ret = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, _language_changed_cb, ad);
- if (ret < 0)
- _E("Failed to set language setting's changed cb.(%d)", ret);
-
- /*Register changed cb(regionformat 1224) */
- ret = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, _timeformat_changed_cb, ad);
- if (ret < 0)
- _E("Failed to set time format about 24 hour changed cb(%d).", ret);
-}
-
-
-#if 0
-static void _unset_settings()
-{
- _D("");
- int ret = -1;
-
- /* unset changed cb(time changed) */
- ret = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_TIME_CHANGED);
- if (ret < 0)
- _E("Failed to unset time changed(%d).", ret);
-
- /* unset changed cb(timezone) */
- ret = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE);
- if (ret < 0)
- _E("Failed to unset time zone changed cb(%d).", ret);
-
- /* unset changed cb(pm mode) */
- ret = device_remove_callback(DEVICE_CALLBACK_DISPLAY_STATE, _device_state_changed_cb);
- if (DEVICE_ERROR_NONE != ret)
- _E("Failed to remove device display state changed cb(%d)", ret);
-
- /* unset changed cb(language)*/
- ret = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE);
- if (ret < 0)
- _E("Failed to unset locale language(%d).", ret);
-
- /* unset changed cb(region format)*/
- ret = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR);
- if (ret < 0)
- _E("Failed to unset locale time format about 24 hour(%d).", ret);
-
- /* date showing */
- ret = preference_unset_changed_cb(DIGITAL_PREFERENCE_SHOW_DATE);
- if (ret < 0)
- _E("Failed to unset preference(show_date, %d).", ret);
-
- /* clock_font_color */
- ret = preference_unset_changed_cb(DIGITAL_PREFERENCE_CLOCK_FONT_COLOR);
- if (ret < 0)
- _E("Failed to unset preference(font color, %d).", ret);
-}
-#endif
-
-
-static void _set_info(void *data)
-{
- _D("");
-
- appdata *ad = data;
- ret_if(!ad);
-
- _set_settings(data);
-
- _time_status_changed_cb(-1, ad);
- _clock_font_changed_cb(0, ad);
-
- clock_view_set_info_time(ad);
-}
-
-
-
-static Evas_Object *_add_layout(Evas_Object *parent, const char *file, const char *group)
-{
- _D("%s", __func__);
- Evas_Object *eo = NULL;
- int r = -1;
-
- retv_if(!parent, NULL);
- retv_if(!file, NULL);
- retv_if(!group, NULL);
-
- eo = elm_layout_add(parent);
- retv_if(!eo, NULL);
-
- r = elm_layout_file_set(eo, file, group);
- if (!r) {
- _E("Failed to set file[%s]", 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;
-}
-
-
-
-void clock_view_destroy_view_main(void *data)
-{
- _D("");
- appdata *ad = data;
- ret_if(!ad);
-
- if (ad->timezone_id) {
- free(ad->timezone_id);
- ad->timezone_id = NULL;
- }
- if (ad->timeregion_format) {
- free(ad->timeregion_format);
- ad->timeregion_format = NULL;
- }
-
- _remove_formatters(ad);
-}
-
-
-
-bool clock_view_create_layout(void *data)
-{
- _D("");
- appdata *ad = data;
- retv_if(!ad, false);
-
- /* create main layout */
- char edj_path[MAX_PATH_LEN] = {0,};
- char *res_path = app_get_resource_path();
- snprintf(edj_path, MAX_PATH_LEN, "%s%s", res_path, EDJ_APP);
- free(res_path);
- _D("edj_path: %s", edj_path);
-
- Evas_Object *ly_main = NULL;
- ly_main = _add_layout(ad->win, edj_path, "main");
- retv_if(!ly_main, -1);
- evas_object_size_hint_weight_set(ly_main, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_win_resize_object_add(ad->win, ly_main);
- ad->ly_main = ly_main;
-
- Evas_Object *ly_time = NULL;
- ly_time = _add_layout(ly_main, edj_path, "layout_clock_digital");
- elm_object_part_content_set(ly_main, "time.part", ly_time);
- ad->ly_time = ly_time;
-
- evas_object_show(ad->win);
-
- evas_object_resize(ly_main, ad->win_w, ad->win_h);
- evas_object_show(ly_main);
-
- _set_info(ad);
-
- return true;
-}
diff --git a/src/debug.c b/src/debug.c
deleted file mode 100755
index defbc13..0000000
--- a/src/debug.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 <unistd.h>
-#include <errno.h>
-
-#include "log.h"
-
-void assert_screen(const char* tag_name, const char* file, int line, const char* func, const char *expr, const char *fmt, ...)
-{
- app_control_h app_control;
- va_list ap;
- char pid_buffer[16] = {0};
- char result_buffer[256] = {0};
- char line_buffer[16] = {0};
-
- app_control_create(&app_control);
- app_control_set_app_id(app_control, "com.samsung.assert-scr");
- snprintf(pid_buffer, sizeof(pid_buffer), "%d", getpid());
- app_control_add_extra_data(app_control, "pid", pid_buffer);
- app_control_add_extra_data(app_control, "appname", tag_name);
- if (fmt == NULL)
- snprintf(result_buffer, sizeof(result_buffer), "%s", expr);
- else {
- char arg_buffer[256] = {0};
- va_start(ap, fmt);
- vsnprintf(arg_buffer, sizeof(arg_buffer), fmt, ap);
- va_end(ap);
- snprintf(result_buffer, sizeof(result_buffer), "(%s) %s", expr, arg_buffer);
- }
- app_control_add_extra_data(app_control, "assert_str", result_buffer);
- app_control_add_extra_data(app_control, "filename", file);
- snprintf(line_buffer, sizeof(line_buffer), "%d", line);
- app_control_add_extra_data(app_control, "line", line_buffer);
- app_control_add_extra_data(app_control, "funcname", func);
- app_control_send_launch_request(app_control, NULL, NULL);
- app_control_destroy(app_control);
-}
diff --git a/src/main.c b/src/main.c
deleted file mode 100755
index db4296c..0000000
--- a/src/main.c
+++ /dev/null
@@ -1,666 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <app.h>
-#include <unistd.h>
-#include <errno.h>
-#include <glib.h>
-#include <device/display.h>
-#include <tizen.h>
-#include <watch_app.h>
-#include <watch_app_efl.h>
-
-
-#include "log.h"
-#include "window.h"
-#include "app_data.h"
-#include "clock_view.h"
-#include "util.h"
-
-#if !defined(PACKAGE_NAME)
-#define PACKAGE_NAME "org.tizen.idle-clock-digital"
-#endif
-
-#define DATA_PATH "/tmp"
-#define DUMP_FILE_PATH_OFFSCREEN DATA_PATH"/"PACKAGE_NAME"-dump_offscreen.png"
-#define DUMP_FILE_PATH_MINICONTROL DATA_PATH"/"PACKAGE_NAME"-dump_minicontrol.png"
-#define QUALITY_N_COMPRESS "quality=100 compress=1"
-
-static int drawing_state = 0; // 0: nothing, 1: offscreen capture ongoing, 2: onscreen capture ongoing
-static Ecore_Timer *sync_timer = NULL;
-static Ecore_Timer *drawing_timer = NULL;
-static Ecore_Timer *close_timer = NULL;
-
-static Evas *offscreen_e = NULL;
-static Evas_Object *offscreen_box = NULL;
-static Evas_Object *offscreen_bg = NULL;
-static Evas_Object *offscreen_img = NULL;
-static Evas *minicontrol_e = NULL;
-static Evas_Object *minicontrol_bg = NULL;
-static Evas_Object *minicontrol_img = NULL;
-static Evas_Object *minicontrol_img_box = NULL;
-
-static Evas* _live_create_virtual_canvas(int w, int h);
-static int live_flush_to_file(Evas *e, const char *filename, int w, int h);
-static int _flush_data_to_file(Evas *e, char *data, const char *filename, int w, int h);
-static void _update_clock_to_offscreen(void *data, int w, int h);
-
-EXPORT_API Evas_Object* elm_widget_top_get(const Evas_Object *obj);
-EXPORT_API Evas_Object* elm_widget_parent_widget_get(const Evas_Object *obj);
-
-
-
-static void _live_destroy_virtual_canvas(Evas *e)
-{
- ret_if(!e);
- Ecore_Evas *ee;
-
- ee = ecore_evas_ecore_evas_get(e);
- if (!ee) {
- _E("Failed to ecore evas object\n");
- return ;
- }
-
- ecore_evas_free(ee);
-}
-
-
-
-void _remove_preview_resource(void *data)
-{
- _D();
-
- appdata *ad = data;
- ret_if(!ad);
-
- if (offscreen_box) {
- evas_object_del(offscreen_box);
- offscreen_box = NULL;
- ad->win = NULL;
- _D("##### ad->win set to NULL");
- }
-
- if (offscreen_bg) {
- evas_object_del(offscreen_bg);
- offscreen_bg = NULL;
- }
-
- if (offscreen_img) {
- evas_object_del(offscreen_img);
- offscreen_img = NULL;
- }
-
- if (minicontrol_bg) {
- evas_object_del(minicontrol_bg);
- minicontrol_bg = NULL;
- }
-
- if (minicontrol_img) {
- evas_object_del(minicontrol_img);
- minicontrol_img = NULL;
- }
-
- if (minicontrol_img_box) {
- evas_object_del(minicontrol_img_box);
- minicontrol_img_box = NULL;
- }
-
- _live_destroy_virtual_canvas(offscreen_e);
- _live_destroy_virtual_canvas(minicontrol_e);
-
- ad->e_offscreen = NULL;
-}
-
-
-
-static void _update_clock_to_offscreen(void *data, int w, int h)
-{
- appdata *ad = data;
- ret_if(!ad);
-
- if (!offscreen_e) {
- offscreen_e = _live_create_virtual_canvas(w, h);
- ad->e_offscreen = offscreen_e;
- }
-
- offscreen_box = evas_object_rectangle_add(offscreen_e);
- evas_object_resize(offscreen_box, w, h);
- evas_object_color_set(offscreen_box, 0, 0, 0, 0);
- evas_object_show(offscreen_box);
-
- ad->win = offscreen_box;
-
- clock_view_create_layout(ad);
- _D("create offscreen window");
-
-}
-
-
-
-static Evas* _live_create_virtual_canvas(int w, int h)
-{
- Ecore_Evas *internal_ee;
- Evas *internal_e;
-
- internal_ee = ecore_evas_buffer_new(w, h);
- if (!internal_ee) {
- _E("Failed to create a new canvas buffer");
- return NULL;
- }
-
- ecore_evas_alpha_set(internal_ee, EINA_FALSE);
- ecore_evas_manual_render_set(internal_ee, EINA_TRUE);
-
- internal_e = ecore_evas_get(internal_ee);
- if (!internal_e) {
- ecore_evas_free(internal_ee);
- _E("Faield to get Evas object");
- return NULL;
- }
-
- return internal_e;
-}
-
-
-
-static int live_flush_to_file(Evas *e, const char *filename, int w, int h)
-{
- void *data;
- Ecore_Evas *internal_ee;
-
- internal_ee = ecore_evas_ecore_evas_get(e);
- if (!internal_ee) {
- _E("Failed to get ecore evas");
- return -1;
- }
-
- ecore_evas_manual_render(internal_ee);
- // Get a pointer of a buffer of the virtual canvas
- data = (void*)ecore_evas_buffer_pixels_get(internal_ee);
-
- if (!data) {
- _E("Failed to get pixel data");
- return -1;
- }
-
- return _flush_data_to_file(e, (char *) data, filename, w, h);
-}
-
-
-
-static int _flush_data_to_file(Evas *e, char *data, const char *filename, int w, int h)
-{
- Evas_Object *output = NULL;
-
- output = evas_object_image_add(e);
- if (!output) {
- _E("Failed to create an image object");
- return -1;
- }
-
- /* evas_object_image_data_get/set should be used as pair. */
- evas_object_image_colorspace_set(output, EVAS_COLORSPACE_ARGB8888);
- // evas_object_image_alpha_set(output, EINA_FALSE);
- evas_object_image_alpha_set(output, EINA_TRUE);
- evas_object_image_size_set(output, w, h);
- evas_object_image_smooth_scale_set(output, EINA_TRUE);
- evas_object_image_data_set(output, data);
- evas_object_image_data_update_add(output, 0, 0, w, h);
-
- if (evas_object_image_save(output, filename, NULL, QUALITY_N_COMPRESS) == EINA_FALSE) {
- evas_object_del(output);
- _E("Faield to save a captured image (%s)", filename);
- return -1;
- }
-
- evas_object_del(output);
-
- return 0;
-}
-
-
-
-static Eina_Bool _make_dump(void *data, int win_type, int width, int height, char *file)
-{
- appdata *ad = data;
- Evas_Object *obj = NULL;
-
- Evas *e = NULL;
- const void *pixel_data = NULL;
-
- retv_if(!ad, EINA_FALSE);
- retv_if(!win_type, EINA_FALSE);
-
- obj = ad->win;
-
- _D("obj: %x", obj);
-
- _flush_data_to_file(e, (char *)pixel_data, DUMP_FILE_PATH_MINICONTROL, 384, WIN_SIZE_H);
-
- return EINA_TRUE;
-}
-
-
-
-static bool _create_window(void *data, int mode)
-{
- Evas_Object *win = NULL;
- appdata *ad = data;
- retv_if(!ad, false);
-
- /* create main window */
- if (ad->win == NULL) {
- if (mode == BUFFER_TYPE_OFFSCREEN) {
- ad->win_type = BUFFER_TYPE_OFFSCREEN;
- _update_clock_to_offscreen(data, ad->win_w, ad->win_h);
-
- return true;
- }
- win = window_create(PACKAGE);
- retv_if(!win, -1);
- evas_object_resize(win, ad->win_w, ad->win_h);
- evas_object_move(win, 0, 0);
- ad->win = win;
- ad->win_type = BUFFER_TYPE_WINDOW;
- clock_view_create_layout(ad);
- _D("create window");
- }
- return true;
-}
-
-
-
-static bool _idle_clock_digital_create(int width, int height, void *data)
-{
- _D("%s", __func__);
-
- appdata *ad = data;
-
- app_event_handler_h handlers[5] = {NULL, };
-
- // Register callbacks for each system event
- if (watch_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, NULL, NULL) != APP_ERROR_NONE)
- _E("watch_app_add_event_handler () is failed");
-
- if (watch_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, NULL, NULL) != APP_ERROR_NONE)
- _E("watch_app_add_event_handler () is failed");
-
- if (watch_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, NULL, NULL) != APP_ERROR_NONE)
- _E("watch_app_add_event_handler () is failed");
-
- if (watch_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, NULL, NULL) != APP_ERROR_NONE)
- _E("watch_app_add_event_handler () is failed");
-
- if (watch_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, NULL, NULL) != APP_ERROR_NONE)
- _E("watch_app_add_event_handler () is failed");
-
- ad->win_w = width;
- ad->win_h = height;
-
- return true;
-}
-
-
-
-static void _idle_clock_digital_terminate(void *data)
-{
- _D();
- appdata *ad = data;
-
- if (ad->win) {
- evas_object_del(ad->win);
- ad->win = NULL;
- }
-
- if (ad->ly_time) {
- evas_object_del(ad->ly_time);
- ad->ly_time = NULL;
- }
-
- if (close_timer) {
- ecore_timer_del(close_timer);
- close_timer = NULL;
- }
-
- clock_view_destroy_view_main(ad);
-
-}
-
-
-
-static void _idle_clock_digital_pause(void *data)
-{
- _D("%s", __func__);
- appdata *ad = data;
- ret_if(!ad);
-}
-
-
-
-static void _idle_clock_digital_resume(void *data)
-{
- _D("%s", __func__);
- appdata *ad = data;
- ret_if(!ad);
-}
-
-
-
-static void _send_reply(void *data)
-{
- _D("%s", __func__);
-
- int ret;
-
- appdata *ad = data;
- ret_if(!ad);
-
- /* send reply */
- app_control_h reply;
- ret = app_control_create(&reply);
- _D("reply app_control created");
- if (ret == 0) {
- _D("reply caller");
- if (ad->win_type == BUFFER_TYPE_OFFSCREEN)
- ret = app_control_add_extra_data(reply, "result", DUMP_FILE_PATH_OFFSCREEN);
- else
- ret = app_control_add_extra_data(reply, "result", DUMP_FILE_PATH_MINICONTROL);
-
- if (ret)
- _E("app_control_add_extra_data failed");
-
- ret = app_control_reply_to_launch_request(reply, ad->app_control, APP_CONTROL_RESULT_SUCCEEDED);
-
- if (ret)
- _E("app_control_reply_to_launch_request failed");
-
- app_control_destroy(reply);
- } else {
- _E("app_control_create failed");
- }
-
-}
-
-
-
-static void _draw_onscreen(void *data)
-{
- _D("");
-
- appdata *ad = data;
- ret_if(!ad);
-
- _make_dump(data, ad->win_type, WIN_SIZE_W, WIN_SIZE_H, DUMP_FILE_PATH_MINICONTROL);
- _send_reply(data);
-
- if (clock_view_get_display_state() == DISPLAY_STATE_SCREEN_OFF)
- clock_view_hide_clock(ad);
-
- drawing_state = 0;
- drawing_timer = NULL;
-}
-
-
-
-static Eina_Bool _idler_drawing_onscreen_cb(void *data)
-{
- _D("");
-
- appdata *ad = data;
- retv_if(!ad, ECORE_CALLBACK_CANCEL);
-
- _draw_onscreen(ad);
-
- return ECORE_CALLBACK_CANCEL;
-}
-
-
-
-static Eina_Bool _drawing_timer_onscreen_cb(void *data)
-{
- appdata *ad = data;
- retv_if(!ad, ECORE_CALLBACK_CANCEL);
-
- if (!ad->is_show) {
- clock_view_show_clock(ad);
- ecore_idler_add(_idler_drawing_onscreen_cb, ad);
- return ECORE_CALLBACK_CANCEL;
- }
-
- _draw_onscreen(ad);
-
- return ECORE_CALLBACK_CANCEL;
-}
-
-
-
-static void _draw_offscreen(void *data)
-{
- _D();
-
- appdata *ad = data;
- ret_if(!ad);
-
- live_flush_to_file(ad->e_offscreen, DUMP_FILE_PATH_OFFSCREEN, WIN_SIZE_W, WIN_SIZE_H);
-
- _send_reply(data);
-
- if (clock_view_get_display_state() == DISPLAY_STATE_SCREEN_OFF)
- clock_view_hide_clock(ad);
-
- drawing_state = 0;
- drawing_timer = NULL;
-
- _D("win type = %d and window = %d", ad->win_type, ad->win);
- if (BUFFER_TYPE_OFFSCREEN == ad->win_type) {
- _D("offscreen capture completed. app will be closed");
- elm_exit();
- }
-}
-
-
-
-static Eina_Bool _idler_drawing_offscreen_cb(void *data)
-{
- _D();
-
- appdata *ad = data;
- retv_if(!ad, ECORE_CALLBACK_RENEW);
-
- _draw_offscreen(ad);
-
- return ECORE_CALLBACK_CANCEL;
-}
-
-
-
-static Eina_Bool _drawing_timer_cb(void *data)
-{
- _D();
-
- appdata *ad = data;
- retv_if(!ad, ECORE_CALLBACK_RENEW);
-
- if (!ad->is_show) {
- clock_view_show_clock(ad);
- ecore_idler_add(_idler_drawing_offscreen_cb, ad);
- return ECORE_CALLBACK_CANCEL;
- }
-
- _draw_offscreen(ad);
-
- return ECORE_CALLBACK_CANCEL;
-}
-
-
-
-static Eina_Bool _close_timer_cb(void *data)
-{
- _D();
-
- elm_exit();
- return ECORE_CALLBACK_CANCEL;
-}
-
-
-
-static Eina_Bool _sync_timer_cb(void *data)
-{
- _D();
-
- appdata *ad = data;
- retv_if(!ad, ECORE_CALLBACK_RENEW);
-
- if (drawing_state == 0) {
- _remove_preview_resource(data);
- _create_window(data, BUFFER_TYPE_WINDOW);
- sync_timer = NULL;
- return ECORE_CALLBACK_CANCEL;
- }
-
- return ECORE_CALLBACK_RENEW;
-}
-
-
-
-static void _idle_clock_digital_app_control(app_control_h app_control, void *data)
-{
- _D();
-
- appdata *ad = data;
- ret_if(!ad);
-
- char *op = NULL;
- char *result_data = NULL;
-
- app_control_get_operation(app_control, &op);
-
- if (op) {
- _D("operation:%s", op);
- if (strcmp(op, "http://tizen.org/appcontrol/operation/remote_settings") == 0) {
- app_control_get_extra_data(app_control, "http://tizen.org/appcontrol/data/result_xml", &result_data);
- if (result_data) {
- _D("Result:%s", result_data);
- clock_view_parse_result_data(result_data);
- clock_view_set_result_data(ad);
- clock_view_update_view(ad);
- free(result_data);
-
- if (BUFFER_TYPE_WINDOW == ad->win_type && ad->win) {
- device_display_change_state(DISPLAY_STATE_NORMAL);
- } else {
- _D("app will be closed");
- if (close_timer) {
- ecore_timer_del(close_timer);
- close_timer = NULL;
- }
- close_timer = ecore_timer_add(3.0, _close_timer_cb, NULL);
- }
- }
- } else if (strcmp(op, "http://tizen.org/appcontrol/operation/main") == 0) {
- if (close_timer) {
- ecore_timer_del(close_timer);
- close_timer = NULL;
- }
- if (drawing_state) {
- if (sync_timer) {
- ecore_timer_del(sync_timer);
- sync_timer = NULL;
- }
- sync_timer = ecore_timer_add(0.1, _sync_timer_cb, data);
- } else {
- /* New case: offscreen capture -> operation/main */
- _remove_preview_resource(data);
- _create_window(data, BUFFER_TYPE_WINDOW); /* create window if not mini app setting called */
- }
- } else if (strcmp(op, "http://tizen.org/appcontrol/operation/clock/capture") == 0) {
- app_control_clone(&ad->app_control, app_control);
-
- if (close_timer) {
- ecore_timer_del(close_timer);
- close_timer = NULL;
- }
-
- _create_window(data, BUFFER_TYPE_OFFSCREEN);
-
- if (BUFFER_TYPE_OFFSCREEN == ad->win_type) {
- _D("offscreen capture");
- drawing_state = 1;
-
- if (drawing_timer) {
- ecore_timer_del(drawing_timer);
- drawing_timer = NULL;
- }
- clock_view_set_info_time(data);
- if (clock_view_get_display_state() == DISPLAY_STATE_SCREEN_OFF)
- clock_view_show_clock(ad);
- drawing_timer = ecore_timer_add(0.15, _drawing_timer_cb, data);
- } else {
- _D("minicontrol capture");
- drawing_state = 2;
- if (drawing_timer) {
- ecore_timer_del(drawing_timer);
- drawing_timer = NULL;
- }
- clock_view_set_info_time(data);
- if (clock_view_get_display_state() == DISPLAY_STATE_SCREEN_OFF)
- clock_view_show_clock(ad);
- drawing_timer = ecore_timer_add(0.15, _drawing_timer_onscreen_cb, data);
- }
- } else
- _E("Unknown operation");
-
- free(op);
- }
-}
-
-
-
-void app_time_tick(watch_time_h watch_time, void* user_data)
-{
-
-}
-
-void app_ambient_tick(watch_time_h watch_time, void* user_data)
-{
-
-}
-
-void app_ambient_changed(bool ambient_mode, void* user_data)
-{
-
-}
-
-int main(int argc, char *argv[])
-{
- appdata ad;
-
- watch_app_lifecycle_callback_s lifecycle_callback = {0, };
-
- lifecycle_callback.create = _idle_clock_digital_create;
- lifecycle_callback.terminate = _idle_clock_digital_terminate;
- lifecycle_callback.pause = _idle_clock_digital_pause;
- lifecycle_callback.resume = _idle_clock_digital_resume;
- lifecycle_callback.app_control = _idle_clock_digital_app_control;
- lifecycle_callback.time_tick = app_time_tick;
- lifecycle_callback.ambient_tick = app_ambient_tick;
- lifecycle_callback.ambient_changed = app_ambient_changed;
-
-
- memset(&ad, 0x0, sizeof(appdata));
-
- return watch_app_main(argc, argv, &lifecycle_callback, &ad);
-}
diff --git a/inc/window.h b/src/main.cpp
index bc6dbee..5d4be0a 100755..100644
--- a/inc/window.h
+++ b/src/main.cpp
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://floralicense.org/license/
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,11 +14,12 @@
* limitations under the License.
*/
-#ifndef __WINDOW_H__
-#define __WINDOW_H__
+#include <tizen.h>
+#include "WatchApp.h"
+#include "Logger.h"
-#include <Elementary.h>
-
-Evas_Object *window_create(const char *name);
-
-#endif /* __WINDOW_H__ */
+EXPORT_API int main(int argc, char *argv[])
+{
+ TRACE;
+ return IdleClock::WatchApp::getInst().start(argc, argv);
+}
diff --git a/src/window.c b/src/window.c
deleted file mode 100755
index 8a16595..0000000
--- a/src/window.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 <Elementary.h>
-#include <watch_app.h>
-#include <watch_app_efl.h>
-
-
-#include "app_data.h"
-#include "log.h"
-#include "util.h"
-
-
-Evas_Object *window_create(const char *name)
-{
- Evas_Object *win = NULL;
- int ret = 0;
-
- /* Window */
-
- _D("WATCH APP CREATE");
- ret = watch_app_get_elm_win(&win);
- if (ret != APP_ERROR_NONE) {
- _E("failed to get window(%d)", ret);
- return NULL;
- }
-
- elm_win_title_set(win, "idle-clock_digital");
- elm_win_borderless_set(win, EINA_TRUE);
- elm_win_alpha_set(win, EINA_FALSE);
- elm_win_indicator_opacity_set(win, ELM_WIN_INDICATOR_TRANSPARENT);
- elm_win_role_set(win, "no-effect");
-
- /* Show window after base gui is set up */
- evas_object_show(win);
-
- return win;
-
-}
-