summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c167
1 files changed, 167 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..c3af58c
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 2018 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-log.h>
+#include <defines.h>
+#include <view.h>
+#include <vconf.h>
+#include <watch-face-editor.h>
+
+static struct main_info {
+ app_event_handler_h handlers[5];
+} s_info = {
+ .handlers = {NULL, },
+};
+
+static void
+_notify_edit_ready(char *watch_appid)
+{
+ watchface_editor_notify_edit_ready(watch_appid);
+ __I("notify edit %s", watch_appid);
+}
+
+static bool
+app_create(void *data)
+{
+ __I("%s", __func__);
+ return true;
+}
+
+static void
+app_control(app_control_h app_control, void *data)
+{
+ //TODO
+ /* Handle the launch request. */
+ //for launching editor from watch
+ //char *watch_appid;
+ //app_control_get_extra_data(app_control, APP_CONTROL_DATA_SELECTED, &watch_appid);
+
+ char *home_watch = NULL;
+ _notify_edit_ready(HOME_WATCH_APPID);
+ home_watch = vconf_get_str(VCONFKEY_WMS_CLOCKS_SET_IDLE);
+ __I("Home watch: %s", home_watch);
+ view_create(home_watch);
+}
+
+static void
+app_pause(void *data)
+{
+ __I("%s", __func__);
+ ui_app_exit();
+ /* Take necessary actions when application becomes invisible. */
+}
+
+static void
+app_resume(void *data)
+{
+ __I("%s", __func__);
+ /* Take necessary actions when application becomes visible. */
+}
+
+static void
+app_terminate(void *data)
+{
+ /* Release all resources. */
+ __I("%s", __func__);
+ view_destroy();
+}
+
+static void
+ui_app_lang_changed(app_event_info_h event_info, void *user_data)
+{
+ /*APP_EVENT_LANGUAGE_CHANGED*/
+ char *locale = NULL;
+ system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
+ elm_language_set(locale);
+ free(locale);
+}
+
+static void
+ui_app_orient_changed(app_event_info_h event_info, void *user_data)
+{
+ /*APP_EVENT_DEVICE_ORIENTATION_CHANGED*/
+ __I("%s", __func__);
+}
+
+static void
+ui_app_region_changed(app_event_info_h event_info, void *user_data)
+{
+ /*APP_EVENT_REGION_FORMAT_CHANGED*/
+ __I("%s", __func__);
+}
+
+static void
+ui_app_low_battery(app_event_info_h event_info, void *user_data)
+{
+ /*APP_EVENT_LOW_BATTERY*/
+ __I("%s", __func__);
+}
+
+static void
+ui_app_low_memory(app_event_info_h event_info, void *user_data)
+{
+ /*APP_EVENT_LOW_MEMORY*/
+ __I("%s", __func__);
+}
+
+static void
+_add_event_handlers()
+{
+ ui_app_add_event_handler(&s_info.handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY,
+ ui_app_low_battery, NULL);
+ ui_app_add_event_handler(&s_info.handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY,
+ ui_app_low_memory, NULL);
+ ui_app_add_event_handler(&s_info.handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED,
+ ui_app_orient_changed, NULL);
+ ui_app_add_event_handler(&s_info.handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED,
+ ui_app_lang_changed, NULL);
+ ui_app_add_event_handler(&s_info.handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED,
+ ui_app_region_changed, NULL);
+}
+
+static void
+_remove_event_handlers()
+{
+ ui_app_remove_event_handler(s_info.handlers[APP_EVENT_LOW_BATTERY]);
+ ui_app_remove_event_handler(s_info.handlers[APP_EVENT_LOW_MEMORY]);
+ ui_app_remove_event_handler(s_info.handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED]);
+ ui_app_remove_event_handler(s_info.handlers[APP_EVENT_LANGUAGE_CHANGED]);
+ ui_app_remove_event_handler(s_info.handlers[APP_EVENT_REGION_FORMAT_CHANGED]);
+}
+
+int
+main(int argc, char *argv[])
+{
+ int ret = 0;
+
+ ui_app_lifecycle_callback_s event_callback = {0,};
+
+ event_callback.create = app_create;
+ event_callback.terminate = app_terminate;
+ event_callback.pause = app_pause;
+ event_callback.resume = app_resume;
+ event_callback.app_control = app_control;
+
+ _add_event_handlers();
+
+ ret = ui_app_main(argc, argv, &event_callback, NULL);
+ if (ret != APP_ERROR_NONE) {
+ __E("app_main() is failed. err = %d", ret);
+ }
+ _remove_event_handlers();
+
+ return ret;
+}