summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c145
1 files changed, 145 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..8cb4633
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,145 @@
+/*
+ * 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 "comp-manager.h"
+#include "analog-watch.h"
+#include "app-log.h"
+#include "view.h"
+
+static bool
+app_create(int width, int height, void* user_data)
+{
+ /* Hook to take necessary actions before main event loop starts
+ Initialize UI resources and application's data
+ If this function returns true, the main loop of application starts
+ If this function returns false, the application is terminated */
+ __I("%s", __func__);
+ view_init();
+ comp_init();
+ return true;
+}
+
+static void
+app_control(app_control_h app_control, void *data)
+{
+ /* Handle the launch request. */
+ __I("%s", __func__);
+}
+
+static void
+app_pause(void *data)
+{
+ /* Take necessary actions when application becomes invisible. */
+ __I("%s", __func__);
+}
+
+static void
+app_resume(void *data)
+{
+ /* Take necessary actions when application becomes visible. */
+ __I("%s", __func__);
+}
+
+static void
+app_terminate(void *data)
+{
+ /* Release all resources. */
+ comp_destroy();
+ view_destroy();
+}
+
+static void
+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);
+ return;
+}
+
+static void
+app_orient_changed(app_event_info_h event_info, void *user_data)
+{
+ /*APP_EVENT_DEVICE_ORIENTATION_CHANGED*/
+ return;
+}
+
+static void
+app_region_changed(app_event_info_h event_info, void *user_data)
+{
+ /*APP_EVENT_REGION_FORMAT_CHANGED*/
+}
+
+static void
+low_battery(app_event_info_h event_info, void *user_data)
+{
+ /*APP_EVENT_LOW_BATTERY*/
+}
+
+static void
+low_memory(app_event_info_h event_info, void *user_data)
+{
+ /*APP_EVENT_LOW_MEMORY*/
+ watch_app_exit();
+}
+
+void app_time_tick(watch_time_h watch_time, void* user_data)
+{
+ int hour = 0;
+ int min = 0;
+ int sec = 0;
+ int month = 0;
+ int day = 0;
+
+ watch_time_get_hour(watch_time, &hour);
+ watch_time_get_minute(watch_time, &min);
+ watch_time_get_second(watch_time, &sec);
+ watch_time_get_day(watch_time, &day);
+ watch_time_get_month(watch_time, &month);
+
+ view_set_time(hour, min, sec);
+}
+
+int
+main(int argc, char *argv[])
+{
+ int ret = 0;
+
+ watch_app_lifecycle_callback_s event_callback = { 0, };
+ app_event_handler_h handlers[5] = {NULL, };
+
+ event_callback.create = app_create;
+ event_callback.terminate = app_terminate;
+ event_callback.pause = app_pause;
+ event_callback.resume = app_resume;
+ event_callback.app_control = app_control;
+ event_callback.time_tick = app_time_tick;
+
+ watch_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, low_battery, NULL);
+ watch_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, low_memory, NULL);
+ watch_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, app_orient_changed, NULL);
+ watch_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, app_lang_changed, NULL);
+ watch_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, app_region_changed, NULL);
+
+ ret = watch_app_main(argc, argv, &event_callback, NULL);
+ if (ret != APP_ERROR_NONE) {
+ __E("app_main() is failed. err = %d", ret);
+ }
+
+ return ret;
+}