/*
- * app-core
- *
- * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
#ifndef __APPCORE_WATCH_H__
#define __APPCORE_WATCH_H__
-
#include <libintl.h>
#include <bundle.h>
#include "app_control.h"
-
#ifdef __cplusplus
extern "C" {
#endif
struct watchcore_ops {
- void *data;
- /**< Callback data */
+ void *data; /**< Callback data */
int (*create) (int w, int h, void *); /**< This callback function is called at the start of the application. */
int (*app_control) (app_control_h, void *); /**< This callback function is called when other application send the launch request to the application. */
- int (*pause) (void *); /**< Called when every window goes back */
- int (*resume) (void *); /**< Called when any window comes on top */
+ int (*pause) (void *); /**< Called when every window goes back */
+ int (*resume) (void *); /**< Called when any window comes on top */
int (*terminate) (void *); /**< This callback function is called once after the main loop of application exits. */
void (*time_tick) (void *, void *);
void (*ambient_tick) (void *, void *);
void (*ambient_changed) (int, void *);
-
- void *reserved[6];
- /**< Reserved */
+ void *reserved[6]; /**< Reserved */
};
enum watch_core_event {
- /**< Unknown event */
- WATCH_CORE_EVENT_UNKNOWN,
-
- /**< Low memory */
- WATCH_CORE_EVENT_LOW_MEMORY,
-
- /**< Low battery */
- WATCH_CORE_EVENT_LOW_BATTERY,
-
- /**< Language setting is changed */
- WATCH_CORE_EVENT_LANG_CHANGE,
-
- /**< Region setting is changed */
- WATCH_CORE_EVENT_REGION_CHANGE,
+ WATCH_CORE_EVENT_UNKNOWN, /**< Unknown event */
+ WATCH_CORE_EVENT_LOW_MEMORY, /**< Low memory */
+ WATCH_CORE_EVENT_LOW_BATTERY, /**< Low battery */
+ WATCH_CORE_EVENT_LANG_CHANGE, /**< Language setting is changed */
+ WATCH_CORE_EVENT_REGION_CHANGE, /**< Region setting is changed */
};
-struct watch_time_s
-{
+struct watch_time_s {
int year;
int month;
int day_of_week;
char *timezone;
};
-int watch_core_main(const char *appid, int argc, char **argv, struct watchcore_ops *ops);
-
+int watch_core_main(const char *appid, int argc, char **argv,
+ struct watchcore_ops *ops);
int watch_core_terminate();
-
int watch_core_set_event_callback(enum watch_core_event event,
- int (*cb)(void *, void *), void *data);
-
+ int (*cb) (void *, void *), void *data);
const char *watch_core_get_appid();
-
void watch_core_get_timeinfo(struct watch_time_s *timeinfo);
-
bool watch_core_get_24h_mode(void);
#ifdef __cplusplus
}
#endif
-#endif /* __APPCORE_WATCH_H__ */
+#endif /* __APPCORE_WATCH_H__ */
+
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* limitations under the License.
*/
-
#ifndef __TIZEN_APPFW_WATCH_APP_H__
#define __TIZEN_APPFW_WATCH_APP_H__
* @brief watch_time_h watch_time handle
* @since_tizen 2.3.1
*/
-typedef struct _watch_time_s* watch_time_h;
+typedef struct _watch_time_s *watch_time_h;
/**
* @brief Called when the application starts.
* @see watch_app_ambient_changed_cb()
* @see watch_app_terminate_cb()
*/
-typedef struct
-{
+typedef struct {
watch_app_create_cb create; /**< This callback function is called at the start of the application. */
watch_app_control_cb app_control; /**< This callback function is called when another application sends the launch request to the application. */
watch_app_pause_cb pause; /**< This callback function is called each time the application is completely obscured by another application and becomes invisible to the user. */
watch_app_time_tick_cb time_tick; /**< This callback function is called at each second. */
watch_app_ambient_tick_cb ambient_tick; /**< This callback function is called at each minute in ambient mode. */
watch_app_ambient_changed_cb ambient_changed; /**< This callback function is called when the device enters or exits ambient mode. */
-
} watch_app_lifecycle_callback_s;
* @retval #APP_ERROR_OUT_OF_MEMORY Out of Memory
* @retval #APP_ERROR_NONE Successful
*/
-int watch_time_get_current_time(watch_time_h* watch_time);
+int watch_time_get_current_time(watch_time_h *watch_time);
/**
* @brief Deletes the watch time handle and releases all its resources.
#endif
#endif /* __TIZEN_APPFW_WATCH_APP_H__ */
+
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
#endif
#endif
+
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
#include <errno.h>
#include <unistd.h>
#include <linux/limits.h>
+
#include <glib.h>
#include <tzplatform_config.h>
-
#include <aul.h>
#include <vconf.h>
void _update_lang(void)
{
+ char *r;
char *lang = vconf_get_str(VCONFKEY_LANGSET);
if (lang) {
setenv("LANG", lang, 1);
setenv("LC_MESSAGES", lang, 1);
- char *r = setlocale(LC_ALL, "");
+ r = setlocale(LC_ALL, "");
if (r == NULL) {
r = setlocale(LC_ALL, lang);
- if (r) {
+ if (r)
_D("*****appcore setlocale=%s\n", r);
- }
}
free(lang);
} else {
setenv("LC_MEASUREMENT", region, 1);
setenv("LC_IDENTIFICATION", region, 1);
r = setlocale(LC_ALL, "");
- if (r != NULL) {
+ if (r != NULL)
_D("*****appcore setlocale=%s\n", r);
- }
free(region);
} else {
_E("failed to get current region format for set region env");
r = snprintf(dirname, PATH_MAX, "%s/%s" PATH_RES PATH_LOCALE,
PATH_APP_ROOT, pkg_name);
-
if (r < 0)
return -1;
r = snprintf(dirname, PATH_MAX, "%s/%s" PATH_RES PATH_LOCALE,
PATH_SYS_RO_APP_ROOT, pkg_name);
-
if (r < 0)
return -1;
r = snprintf(dirname, PATH_MAX, "%s/%s" PATH_RES PATH_LOCALE,
PATH_SYS_RW_APP_ROOT, pkg_name);
-
if (r < 0)
return -1;
return 0;
}
-
static int __set_i18n(const char *domain)
{
char *r;
char dirname[PATH_MAX];
+ char *lang;
if (domain == NULL) {
errno = EINVAL;
r = setlocale(LC_ALL, "");
/* if locale is not set properly, try again to set as language base */
if (r == NULL) {
- char *lang = vconf_get_str(VCONFKEY_LANGSET);
+ lang = vconf_get_str(VCONFKEY_LANGSET);
r = setlocale(LC_ALL, lang);
- if (r) {
+ if (r)
_D("*****appcore setlocale=%s\n", r);
- }
- if (lang) {
+ if (lang)
free(lang);
- }
}
- if (r == NULL) {
+ if (r == NULL)
_E("appcore: setlocale() error");
- }
r = bindtextdomain(domain, dirname);
- if (r == NULL) {
+ if (r == NULL)
_E("appcore: bindtextdomain() error");
- }
r = textdomain(domain);
- if (r == NULL) {
+ if (r == NULL)
_E("appcore: textdomain() error");
- }
return 0;
}
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
void _update_region(void);
#endif /* __APPCORE_WATCH_INTERNAL_H__ */
+
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* limitations under the License.
*/
-
#ifndef __APPFW_WATCH_LOG_H__
#define __APPFW_WATCH_LOG_H__
} \
} while (0)
+#endif /*__APPFW_WATCH_LOG_H_ */
-#endif //__APPFW_WATCH_LOG_H_
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* limitations under the License.
*/
-
-
-
#define _GNU_SOURCE
#include <errno.h>
#include <malloc.h>
#include <dlog.h>
-
#include <dbus/dbus.h>
#include <dbus/dbus-glib-lowlevel.h>
#define LOG_TAG "WATCH_CORE"
-
#define MAX_BUFFER_SIZE 512
static DBusConnection *bus = NULL;
-
static int (*_deviced_signal_alpm_handler) (int ambient, void *data);
static void *_deviced_signal_alpm_data;
-static DBusHandlerResult
-__dbus_signal_filter(DBusConnection *conn, DBusMessage *message,
- void *user_data)
+static DBusHandlerResult __dbus_signal_filter(DBusConnection *conn,
+ DBusMessage *message, void *user_data)
{
const char *sender;
const char *interface;
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
- if (dbus_message_is_signal(message, interface, DEVICED_SIGNAL_HOME_SCREEN))
- {
- if (dbus_message_get_args(message, &error, DBUS_TYPE_STRING, &value, DBUS_TYPE_INVALID) == FALSE) {
+ if (dbus_message_is_signal(message, interface,
+ DEVICED_SIGNAL_HOME_SCREEN)) {
+ if (dbus_message_get_args(message, &error, DBUS_TYPE_STRING,
+ &value, DBUS_TYPE_INVALID) == FALSE) {
_E("Failed to get data: %s", error.message);
dbus_error_free(&error);
}
- if (_deviced_signal_alpm_handler)
- {
+ if (_deviced_signal_alpm_handler) {
if (strcmp(value, CLOCK_START) == 0)
- {
- _deviced_signal_alpm_handler(1, _deviced_signal_alpm_data);
- }
+ _deviced_signal_alpm_handler(1,
+ _deviced_signal_alpm_data);
else if (strcmp(value, CLOCK_STOP) == 0)
- {
- _deviced_signal_alpm_handler(0, _deviced_signal_alpm_data);
- }
+ _deviced_signal_alpm_handler(0,
+ _deviced_signal_alpm_data);
}
}
static int __dbus_init(void)
{
+ DBusError error;
+
if (bus)
return 0;
- DBusError error;
dbus_error_init(&error);
bus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error);
if (!bus) {
return 0;
}
-static int __dbus_signal_handler_init(const char* path, const char* interface)
+static int __dbus_signal_handler_init(const char *path, const char *interface)
{
char rule[MAX_BUFFER_SIZE] = {0,};
-
DBusError error;
+
dbus_error_init(&error);
snprintf(rule, MAX_BUFFER_SIZE,
- "path='%s',type='signal',interface='%s'", path, interface);
+ "path='%s',type='signal',interface='%s'", path,
+ interface);
dbus_bus_add_match(bus, rule, &error);
if (dbus_error_is_set(&error)) {
return -1;
}
- if (dbus_connection_add_filter(bus, __dbus_signal_filter, NULL, NULL) == FALSE) {
+ if (dbus_connection_add_filter(bus, __dbus_signal_filter, NULL,
+ NULL) == FALSE) {
_E("add filter fail");
return -1;
}
__dbus_init();
- if(__dbus_signal_handler_init(DEVICED_PATH, DEVICED_INTERFACE) < 0)
- {
+ if (__dbus_signal_handler_init(DEVICED_PATH, DEVICED_INTERFACE) < 0) {
_E("error app signal init");
return -1;
}
__dbus_init();
message = dbus_message_new_signal(ALPM_VIEWER_PATH,
- ALPM_VIEWER_INTERFACE,
- ALPM_VIEWER_SIGNAL_DRAW_DONE);
+ ALPM_VIEWER_INTERFACE, ALPM_VIEWER_SIGNAL_DRAW_DONE);
if (dbus_message_append_args(message,
DBUS_TYPE_INVALID) == FALSE) {
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* limitations under the License.
*/
-
#ifndef __APPCORE_WATCH_SIGNAL_H__
#define __APPCORE_WATCH_SIGNAL_H__
-
#include <dbus/dbus.h>
#ifdef __cplusplus
extern "C" {
#endif
-#define ALPM_VIEWER_PATH "/Org/Tizen/Coreapps/Alpmviewer/Clockdraw"
-#define ALPM_VIEWER_INTERFACE "org.tizen.coreapps.alpmviewer.clockdraw"
-#define ALPM_VIEWER_SIGNAL_DRAW_DONE "drawdone"
+#define ALPM_VIEWER_PATH "/Org/Tizen/Coreapps/Alpmviewer/Clockdraw"
+#define ALPM_VIEWER_INTERFACE "org.tizen.coreapps.alpmviewer.clockdraw"
+#define ALPM_VIEWER_SIGNAL_DRAW_DONE "drawdone"
-
-#define DEVICED_PATH "/Org/Tizen/System/DeviceD"
-#define DEVICED_INTERFACE "org.tizen.system.deviced"
-#define DEVICED_SIGNAL_HOME_SCREEN "HomeScreen"
-#define CLOCK_START "clockbegin"
-#define CLOCK_STOP "clockstop"
+#define DEVICED_PATH "/Org/Tizen/System/DeviceD"
+#define DEVICED_INTERFACE "org.tizen.system.deviced"
+#define DEVICED_SIGNAL_HOME_SCREEN "HomeScreen"
+#define CLOCK_START "clockbegin"
+#define CLOCK_STOP "clockstop"
int _watch_core_listen_alpm_handler(int (*func) (int, void *), void *data);
int _watch_core_send_alpm_update_done(void);
#endif
#endif /* __APPCORE_WATCH_SIGNAL_H__ */
+
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* limitations under the License.
*/
-
#define _GNU_SOURCE
#include <errno.h>
#include <assert.h>
#include <bundle_internal.h>
-
#include <Elementary.h>
-
#include <app_control.h>
#include <app_control_internal.h>
-
#include <aul.h>
#include <dlog.h>
#include <vconf.h>
#include <alarm.h>
#include <glib-object.h>
-
-
#include <widget_app.h>
#include "appcore-watch.h"
#include <unicode/udatpg.h>
#include <unicode/ustring.h>
-#define WATCH_ID "internal://WATCH_ID"
-
-#define AUL_K_CALLER_APPID "__AUL_CALLER_APPID__"
-#define APPID_BUFFER_MAX 255
-
-#define TIMEZONE_BUFFER_MAX 1024
-#define LOCAL_TIME_PATH "/opt/etc/localtime"
-
+#define WATCH_ID "internal://WATCH_ID"
+#define AUL_K_CALLER_APPID "__AUL_CALLER_APPID__"
+#define APPID_BUFFER_MAX 255
+#define TIMEZONE_BUFFER_MAX 1024
+#define LOCAL_TIME_PATH "/opt/etc/localtime"
#define ONE_SECOND 1000
#define ONE_MINUTE 60
#define ONE_HOUR 60
static Ecore_Timer *watch_tick = NULL;
-
static alarm_id_t alarm_id = 0;
/**
WE_MAX
};
-
static enum watch_core_event to_ae[SE_MAX] = {
WATCH_CORE_EVENT_UNKNOWN, /* SE_UNKNOWN */
WATCH_CORE_EVENT_LOW_MEMORY, /* SE_LOWMEM */
static int __watch_core_ambient_tick(alarm_id_t id, void *data);
-static int __widget_create(const char *id, const char *content, int w, int h, void *data);
+static int __widget_create(const char *id, const char *content, int w, int h,
+ void *data);
static int __widget_resize(const char *id, int w, int h, void *data);
-static int __widget_destroy(const char *id, widget_app_destroy_type_e reason, void *data);
+static int __widget_destroy(const char *id, widget_app_destroy_type_e reason,
+ void *data);
static int __widget_pause(const char *id, void *data);
static int __widget_resume(const char *id, void *data);
-extern int app_control_create_event(bundle *data, struct app_control_s **app_control);
+extern int app_control_create_event(bundle *data,
+ struct app_control_s **app_control);
static void __exit_loop(void *data)
{
{
struct watch_priv *watch_data = data;
app_control_h app_control = NULL;
+ int r;
_ret_if(watch_data == NULL);
- if (event == WE_TERMINATE)
- {
+ if (event == WE_TERMINATE) {
watch_data->state = WS_DYING;
- ecore_main_loop_thread_safe_call_sync((Ecore_Data_Cb)__exit_loop, NULL);
+ ecore_main_loop_thread_safe_call_sync(
+ (Ecore_Data_Cb)__exit_loop, NULL);
return;
}
_ret_if(watch_data->ops == NULL);
- switch (event)
- {
- case WE_APPCONTROL:
- _D("appcontrol request");
-
- if (app_control_create_event(b, &app_control) != 0)
- {
- _E("failed to get the app_control handle");
- return;
- }
-
- if (watch_data->ops->app_control)
- watch_data->ops->app_control(app_control, watch_data->ops->data);
-
- app_control_destroy(app_control);
-
- break;
-
- case WE_PAUSE:
- _D("WE_PAUSE");
-
- if (watch_data->state == WS_CREATED)
- {
- _E("Invalid state");
-
- return;
- }
-
- // Handling the ambient mode
- if (watch_data->ambient_mode)
- {
- watch_data->ambient_mode_skip_resume = 1;
- }
+ switch (event) {
+ case WE_APPCONTROL:
+ _D("appcontrol request");
+ if (app_control_create_event(b, &app_control) != 0) {
+ _E("failed to get the app_control handle");
+ return;
+ }
- // Cancel the time_tick callback
- __watch_core_time_tick_cancel();
+ if (watch_data->ops->app_control)
+ watch_data->ops->app_control(app_control,
+ watch_data->ops->data);
- if (watch_data->state == WS_RUNNING)
- {
+ app_control_destroy(app_control);
+ break;
+ case WE_PAUSE:
+ _D("WE_PAUSE");
+ if (watch_data->state == WS_CREATED) {
+ _E("Invalid state");
+ return;
+ }
- if (watch_data->ops->pause) {
- int r = priv.ops->pause(priv.ops->data);
- if (r < 0) {
- _E("pause() fails");
- }
- }
+ /* Handling the ambient mode */
+ if (watch_data->ambient_mode)
+ watch_data->ambient_mode_skip_resume = 1;
+
+ /* Cancel the time_tick callback */
+ __watch_core_time_tick_cancel();
+ if (watch_data->state == WS_RUNNING) {
+ if (watch_data->ops->pause) {
+ r = priv.ops->pause(priv.ops->data);
+ if (r < 0)
+ _E("pause() fails");
}
+ }
- watch_data->state = WS_PAUSED;
- break;
-
- case WE_RESUME:
- _D("WE_RESUME");
+ watch_data->state = WS_PAUSED;
+ break;
+ case WE_RESUME:
+ _D("WE_RESUME");
- // Handling the ambient mode
- if (watch_data->ambient_mode)
- {
- watch_data->ambient_mode_skip_resume = 0;
- return;
- }
+ /* Handling the ambient mode */
+ if (watch_data->ambient_mode) {
+ watch_data->ambient_mode_skip_resume = 0;
+ return;
+ }
- if (watch_data->state == WS_PAUSED || watch_data->state == WS_CREATED)
- {
- if (watch_data->ops->resume) {
- int r = priv.ops->resume(priv.ops->data);
- if (r < 0) {
- _E("resume() fails");
- }
- }
+ if (watch_data->state == WS_PAUSED ||
+ watch_data->state == WS_CREATED) {
+ if (watch_data->ops->resume) {
+ r = priv.ops->resume(priv.ops->data);
+ if (r < 0)
+ _E("resume() fails");
}
watch_data->state = WS_RUNNING;
- // Set the time tick callback
- if (!watch_tick)
- {
+ /* Set the time tick callback */
+ if (!watch_tick) {
__watch_core_time_tick(NULL);
- }
- else
- {
+ } else {
__watch_core_time_tick_cancel();
__watch_core_time_tick(NULL);
}
+ }
+ break;
+ case WE_AMBIENT:
+ _D("WE_AMBIENT");
+ if (priv.ops && priv.ops->ambient_changed)
+ priv.ops->ambient_changed(watch_data->ambient_mode,
+ priv.ops->data);
- break;
-
- case WE_AMBIENT:
- _D("WE_AMBIENT");
-
- if (priv.ops && priv.ops->ambient_changed) {
- priv.ops->ambient_changed(watch_data->ambient_mode, priv.ops->data);
- }
-
- break;
-
- default:
- break;
+ break;
+ default:
+ break;
}
-
}
static struct watch_ops w_ops = {
.cb_app = __do_app,
};
-char* __get_domain_name(const char *appid)
+static char *__get_domain_name(const char *appid)
{
char *name_token = NULL;
- if (appid == NULL)
- {
+ if (appid == NULL) {
_E("appid is NULL");
return NULL;
}
- // com.vendor.name -> name
+ /* com.vendor.name -> name */
name_token = strrchr(appid, '.');
-
- if (name_token == NULL)
- {
+ if (name_token == NULL) {
_E("appid is invalid");
return NULL;
}
return strdup(name_token);
}
-static int __set_data(struct watch_priv *watch, const char *appid, struct watchcore_ops *ops)
+static int __set_data(struct watch_priv *watch, const char *appid,
+ struct watchcore_ops *ops)
{
if (ops == NULL) {
errno = EINVAL;
}
watch->ops = ops;
-
watch->appid = strdup(appid);
watch->name = __get_domain_name(appid);
watch->pid = getpid();
return 0;
}
-static int __watch_appcontrol(void *data, bundle * k)
+static int __watch_appcontrol(void *data, bundle *k)
{
struct watch_core *wc = data;
_retv_if(wc == NULL || wc->ops == NULL, -1);
static int __sys_do_default(struct watch_core *wc, enum sys_event event)
{
- int r;
-
switch (event) {
case SE_LOWBAT:
/*r = __def_lowbatt(wc);*/
- r = 0;
break;
default:
- r = 0;
break;
- };
+ }
- return r;
+ return 0;
}
-static int __sys_do(struct watch_core *wc, void *event_info, enum sys_event event)
+static int __sys_do(struct watch_core *wc, void *event_info,
+ enum sys_event event)
{
struct sys_op *op;
{
int i;
const char *name;
+ struct watch_priv *watch_data = data;
+ struct evt_ops *eo;
name = vconf_keynode_get_name(key);
_ret_if(name == NULL);
_D("vconf changed: %s", name);
- // Check the time changed event
- if (!strcmp(name, VCONFKEY_SYSTEM_TIME_CHANGED))
- {
- struct watch_priv *watch_data = data;
-
+ /* Check the time changed event */
+ if (!strcmp(name, VCONFKEY_SYSTEM_TIME_CHANGED)) {
_D("ambient_mode: %d", watch_data->ambient_mode);
-
if (watch_data->ambient_mode)
- {
__watch_core_ambient_tick(0, NULL);
- }
return;
}
for (i = 0; i < sizeof(evtops) / sizeof(evtops[0]); i++) {
- struct evt_ops *eo = &evtops[i];
+ eo = &evtops[i];
switch (eo->type) {
case _CB_VCONF:
switch (se) {
case SE_LOWMEM:
- r = vconf_notify_key_changed(VCONFKEY_SYSMAN_LOW_MEMORY, __vconf_cb, wc);
+ r = vconf_notify_key_changed(VCONFKEY_SYSMAN_LOW_MEMORY,
+ __vconf_cb, wc);
break;
case SE_LOWBAT:
- r = vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, __vconf_cb, wc);
+ r = vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW,
+ __vconf_cb, wc);
break;
case SE_LANGCHG:
r = vconf_notify_key_changed(VCONFKEY_LANGSET, __vconf_cb, wc);
break;
case SE_REGIONCHG:
- r = vconf_notify_key_changed(VCONFKEY_REGIONFORMAT, __vconf_cb, wc);
+ r = vconf_notify_key_changed(VCONFKEY_REGIONFORMAT, __vconf_cb,
+ wc);
break;
case SE_TIMECHG:
- r = vconf_notify_key_changed(VCONFKEY_SYSTEM_TIME_CHANGED, __vconf_cb, &priv);
+ r = vconf_notify_key_changed(VCONFKEY_SYSTEM_TIME_CHANGED,
+ __vconf_cb, &priv);
break;
default:
r = -1;
switch (se) {
case SE_LOWMEM:
- r = vconf_ignore_key_changed(VCONFKEY_SYSMAN_LOW_MEMORY, __vconf_cb);
+ r = vconf_ignore_key_changed(VCONFKEY_SYSMAN_LOW_MEMORY,
+ __vconf_cb);
break;
case SE_LOWBAT:
- r = vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, __vconf_cb);
+ r = vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW,
+ __vconf_cb);
break;
case SE_LANGCHG:
r = vconf_ignore_key_changed(VCONFKEY_LANGSET, __vconf_cb);
r = vconf_ignore_key_changed(VCONFKEY_REGIONFORMAT, __vconf_cb);
break;
case SE_TIMECHG:
- r = vconf_ignore_key_changed(VCONFKEY_SYSTEM_TIME_CHANGED, __vconf_cb);
+ r = vconf_ignore_key_changed(VCONFKEY_SYSTEM_TIME_CHANGED,
+ __vconf_cb);
break;
default:
r = -1;
}
EXPORT_API int watch_core_set_event_callback(enum watch_core_event event,
- int (*cb) (void *, void *), void *data)
+ int (*cb) (void *, void *), void *data)
{
struct watch_core *wc = &core;
struct sys_op *op;
return 0;
}
-static char* __get_timezone(void)
+static char *__get_timezone(void)
{
char buf[TIMEZONE_BUFFER_MAX] = {0,};
-
- ssize_t len = readlink(LOCAL_TIME_PATH, buf, sizeof(buf)-1);
+ ssize_t len = readlink(LOCAL_TIME_PATH, buf, sizeof(buf) - 1);
if (len != -1)
- {
buf[len] = '\0';
- }
- else // handle error condition
- {
+ else /* handle error condition */
return vconf_get_str(VCONFKEY_SETAPPL_TIMEZONE_ID);
- }
- return strdup(buf+20);
+ return strdup(buf + 20);
}
static void __get_timeinfo(struct watch_time_s *timeinfo)
{
UErrorCode status = U_ZERO_ERROR;
-
- // UTC time
struct timeval current;
+ char *timezone;
+ UCalendar *cal;
+
+ /* UTC time */
gettimeofday(¤t, NULL);
timeinfo->timestamp = current.tv_sec;
- // Time zone
- char* timezone = __get_timezone();
+ /* Time zone */
+ timezone = __get_timezone();
UChar utf16_timezone[64] = {0};
u_uastrncpy(utf16_timezone, timezone, 64);
- // Local time
- UCalendar *cal = ucal_open(utf16_timezone, u_strlen(utf16_timezone), uloc_getDefault(), UCAL_TRADITIONAL, &status);
+ /* Local time */
+ cal = ucal_open(utf16_timezone, u_strlen(utf16_timezone),
+ uloc_getDefault(), UCAL_TRADITIONAL, &status);
if (cal == NULL)
return;
}
int watch_core_init(const char *name, const struct watch_ops *ops,
- int argc, char **argv)
+ int argc, char **argv)
{
int r;
return 0;
- err:
+err:
return -1;
}
int r = 0;
int pid = getpid();
char appid[APPID_BUFFER_MAX] = {0,};
+
r = aul_app_get_appid_bypid(pid, appid, APPID_BUFFER_MAX);
if (r < 0) {
_E("fail to get the appid from the pid : %d", pid);
r = alarmmgr_init(appid);
if (r < 0) {
- _E("fail to alarmmgr_init : error_code : %d",r);
+ _E("fail to alarmmgr_init : error_code : %d", r);
assert(0);
}
-
}
static void __watch_core_time_tick_cancel(void)
{
- if (watch_tick)
- {
+ if (watch_tick) {
ecore_timer_del(watch_tick);
watch_tick = NULL;
}
static Eina_Bool __watch_core_time_tick(void *data)
{
+ struct watch_time_s timeinfo;
+ double sec;
+
_D("state: %d", priv.state);
- if (priv.ops && priv.ops->time_tick && priv.state != WS_PAUSED)
- {
- struct watch_time_s timeinfo;
+ if (priv.ops && priv.ops->time_tick && priv.state != WS_PAUSED) {
__get_timeinfo(&timeinfo);
- // Set a next timer
- double sec = (ONE_SECOND - timeinfo.millisecond) / 1000.0;
+ /* Set a next timer */
+ sec = (ONE_SECOND - timeinfo.millisecond) / 1000.0;
watch_tick = ecore_timer_add(sec, __watch_core_time_tick, NULL);
_D("next time tick: %f", sec);
-
priv.ops->time_tick(&timeinfo, priv.ops->data);
}
static int __watch_core_ambient_tick(alarm_id_t id, void *data)
{
- _D("state: %d", priv.state);
+ struct watch_time_s timeinfo;
- if (priv.ops && priv.ops->ambient_tick && priv.state != WS_RUNNING)
- {
- struct watch_time_s timeinfo;
+ _D("state: %d", priv.state);
+ if (priv.ops && priv.ops->ambient_tick && priv.state != WS_RUNNING) {
__get_timeinfo(&timeinfo);
-
priv.ops->ambient_tick(&timeinfo, priv.ops->data);
}
return 0;
}
-static int __widget_create(const char *id, const char *content, int w, int h, void *data)
+static int __widget_create(const char *id, const char *content, int w, int h,
+ void *data)
{
+ int r;
_D("widget_create");
- if (priv.ops && priv.ops->create)
- {
- int r = priv.ops->create(w, h, priv.ops->data);
- if (r < 0)
- {
+ if (priv.ops && priv.ops->create) {
+ r = priv.ops->create(w, h, priv.ops->data);
+ if (r < 0) {
_E("Failed to initialize the application");
__exit_loop(NULL);
}
_D("widget_create done");
- // Alarm init
+ /* Alarm init */
__watch_core_alarm_init();
return WIDGET_ERROR_NONE;
return WIDGET_ERROR_NONE;
}
-static int __widget_destroy(const char *id, widget_app_destroy_type_e reason, void *data)
+static int __widget_destroy(const char *id, widget_app_destroy_type_e reason,
+ void *data)
{
_D("widget_destory");
static int __signal_alpm_handler(int ambient, void *data)
{
+ struct watch_time_s timeinfo;
+ int sec;
+ int r;
+
_D("_signal_alpm_handler: ambient: %d, state: %d", ambient, priv.state);
- if (priv.ambient_mode == ambient)
- {
+ if (priv.ambient_mode == ambient) {
_E("invalid state");
return 0;
}
- // Enter the ambient mode
- if (ambient)
- {
- if (priv.state != WS_PAUSED)
- {
+ /* Enter the ambient mode */
+ if (ambient) {
+ if (priv.state != WS_PAUSED) {
__do_app(WE_PAUSE, &priv, NULL);
priv.ambient_mode_skip_resume = 0;
- }
- else
- {
+ } else {
priv.ambient_mode_skip_resume = 1;
}
__do_app(WE_AMBIENT, &priv, NULL);
if (priv.ops && priv.ops->ambient_tick) {
- struct watch_time_s timeinfo;
__get_timeinfo(&timeinfo);
-
- int sec = ONE_MINUTE - timeinfo.second;
+ sec = ONE_MINUTE - timeinfo.second;
_D("next time tick: %d", sec);
- // Set a next alarm
- int r = alarmmgr_add_alarm_withcb(ALARM_TYPE_VOLATILE, sec, 60,
- __watch_core_ambient_tick, data, &alarm_id);
- if (r < 0) {
- _E("fail to alarmmgr_add_alarm_withcb : error_code : %d",r);
- }
+ /* Set a next alarm */
+ r = alarmmgr_add_alarm_withcb(ALARM_TYPE_VOLATILE, sec,
+ 60, __watch_core_ambient_tick, data,
+ &alarm_id);
+ if (r < 0)
+ _E("fail to alarmmgr_add_alarm_withcb : "
+ "error_code : %d", r);
priv.ops->ambient_tick(&timeinfo, priv.ops->data);
}
- // Send a update done signal
+ /* Send a update done signal */
_watch_core_send_alpm_update_done();
- }
- // Exit the ambient mode
- else
- {
+ } else { /* Exit the ambient mode */
priv.ambient_mode = 0;
__do_app(WE_AMBIENT, &priv, NULL);
_D("Resume check: %d", priv.ambient_mode_skip_resume);
- if (!priv.ambient_mode_skip_resume)
- {
+ if (!priv.ambient_mode_skip_resume) {
_D("Call the resume after ambient mode changed");
__do_app(WE_RESUME, &priv, NULL);
}
- // Disable alarm
- if (alarm_id)
- {
+ /* Disable alarm */
+ if (alarm_id) {
alarmmgr_remove_alarm(alarm_id);
alarm_id = 0;
}
static int __before_loop(struct watch_priv *watch, int argc, char **argv)
{
- int r = 0;
+ int r;
+ bundle *kb = NULL;
+ char *wayland_display = NULL;
+ char *xdg_runtime_dir = NULL;
+ char *width_str = NULL;
+ char *height_str = NULL;
+ int width = 360;
+ int height = 360;
+
if (argc <= 0 || argv == NULL) {
errno = EINVAL;
g_type_init();
#endif
- bundle *kb = NULL;
- char *wayland_display = NULL;
- char *xdg_runtime_dir = NULL;
- char *width_str = NULL;
- char *height_str = NULL;
- int width = 360;
- int height = 360;
kb = bundle_import_from_argv(argc, argv);
if (kb) {
bundle_get_str(kb, "XDG_RUNTIME_DIR", &xdg_runtime_dir);
if (xdg_runtime_dir) {
_E("senenv: %s", xdg_runtime_dir);
setenv("XDG_RUNTIME_DIR", xdg_runtime_dir, 1);
- } else
+ } else {
_E("failed to get xdgruntimedir");
+ }
if (wayland_display) {
_E("setenv: %s", wayland_display);
setenv("WAYLAND_DISPLAY", wayland_display, 1);
- } else
+ } else {
_E("failed to get waylanddisplay");
+ }
if (width_str)
width = atoi(width_str);
height = atoi(height_str);
bundle_free(kb);
- } else
+ } else {
_E("failed to get launch argv");
+ }
elm_init(argc, argv);
alarmmgr_fini();
}
-
EXPORT_API int watch_core_main(const char *appid, int argc, char **argv,
struct watchcore_ops *ops)
{
{
return priv.appid;
}
+
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* limitations under the License.
*/
-
#include <string.h>
#include <libintl.h>
#define LOG_TAG "CAPI_APPFW_APPLICATION"
-static const char* watch_app_error_to_string(app_error_e error)
+static const char *watch_app_error_to_string(app_error_e error)
{
- switch (error)
- {
+ switch (error) {
case APP_ERROR_NONE:
return "NONE";
-
case APP_ERROR_INVALID_PARAMETER:
return "INVALID_PARAMETER";
-
case APP_ERROR_OUT_OF_MEMORY:
return "OUT_OF_MEMORY";
-
case APP_ERROR_INVALID_CONTEXT:
return "INVALID_CONTEXT";
-
case APP_ERROR_NO_SUCH_FILE:
return "NO_SUCH_FILE";
-
case APP_ERROR_ALREADY_RUNNING:
return "ALREADY_RUNNING";
-
- default :
+ default:
return "UNKNOWN";
}
}
-int watch_app_error(app_error_e error, const char* function, const char *description)
+int watch_app_error(app_error_e error, const char *function,
+ const char *description)
{
if (description)
- {
- LOGE("[%s] %s(0x%08x) : %s", function, watch_app_error_to_string(error), error, description);
- }
+ LOGE("[%s] %s(0x%08x) : %s", function,
+ watch_app_error_to_string(error), error,
+ description);
else
- {
- LOGE("[%s] %s(0x%08x)", function, watch_app_error_to_string(error), error);
- }
+ LOGE("[%s] %s(0x%08x)", function,
+ watch_app_error_to_string(error), error);
return error;
}
+
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* limitations under the License.
*/
-
#include <stdlib.h>
#include <bundle.h>
#include <dlog.h>
#include <app_common.h>
#include <app_control.h>
-
#include <Eina.h>
#include <Evas.h>
#include <Elementary.h>
#define LOG_TAG "CAPI_WATCH_APPLICATION"
-#define WATCH_ID "internal://WATCH_ID"
+#define WATCH_ID "internal://WATCH_ID"
typedef enum {
- WATCH_APP_STATE_NOT_RUNNING, // The application has been launched or was running but was terminated
- WATCH_APP_STATE_CREATING, // The application is initializing the resources on watch_app_create_cb callback
- WATCH_APP_STATE_RUNNING, // The application is running in the foreground and background
+ WATCH_APP_STATE_NOT_RUNNING, /* The application has been launched or was running but was terminated */
+ WATCH_APP_STATE_CREATING, /* The application is initializing the resources on watch_app_create_cb callback */
+ WATCH_APP_STATE_RUNNING, /* The application is running in the foreground and background */
} watch_app_state_e;
typedef struct {
typedef watch_app_context_s *watch_app_context_h;
-struct _watch_time_s
-{
+struct _watch_time_s {
int year;
int month;
int day_of_week;
char *timezone;
};
-
#define WATCH_APP_EVENT_MAX 5
static Eina_List *handler_list[WATCH_APP_EVENT_MAX] = {NULL, };
static int _initialized = 0;
event.type = APP_EVENT_LANGUAGE_CHANGED;
event.value = event_info;
- EINA_LIST_FOREACH(handler_list[APP_EVENT_LANGUAGE_CHANGED], l, handler) {
+ EINA_LIST_FOREACH(handler_list[APP_EVENT_LANGUAGE_CHANGED], l,
+ handler) {
handler->cb(&event, handler->data);
}
event.type = APP_EVENT_REGION_FORMAT_CHANGED;
event.value = event_info;
- EINA_LIST_FOREACH(handler_list[APP_EVENT_REGION_FORMAT_CHANGED], l, handler) {
+ EINA_LIST_FOREACH(handler_list[APP_EVENT_REGION_FORMAT_CHANGED], l,
+ handler) {
handler->cb(&event, handler->data);
}
return APP_ERROR_NONE;
}
-static void _watch_core_set_appcore_event_cb(struct watch_app_context *app_context)
+static void _watch_core_set_appcore_event_cb(
+ struct watch_app_context *app_context)
{
- watch_core_set_event_callback(WATCH_CORE_EVENT_LOW_MEMORY, _watch_core_low_memory, app_context);
- watch_core_set_event_callback(WATCH_CORE_EVENT_LANG_CHANGE, _watch_core_lang_changed, app_context);
- watch_core_set_event_callback(WATCH_CORE_EVENT_REGION_CHANGE, _watch_core_region_changed, app_context);
+ watch_core_set_event_callback(WATCH_CORE_EVENT_LOW_MEMORY,
+ _watch_core_low_memory, app_context);
+ watch_core_set_event_callback(WATCH_CORE_EVENT_LANG_CHANGE,
+ _watch_core_lang_changed, app_context);
+ watch_core_set_event_callback(WATCH_CORE_EVENT_REGION_CHANGE,
+ _watch_core_region_changed, app_context);
if (eina_list_count(handler_list[APP_EVENT_LOW_BATTERY]) > 0)
- watch_core_set_event_callback(WATCH_CORE_EVENT_LOW_BATTERY, _watch_core_low_battery, app_context);
+ watch_core_set_event_callback(WATCH_CORE_EVENT_LOW_BATTERY,
+ _watch_core_low_battery, app_context);
}
static void _watch_core_unset_appcore_event_cb(void)
{
watch_core_set_event_callback(WATCH_CORE_EVENT_LOW_MEMORY, NULL, NULL);
watch_core_set_event_callback(WATCH_CORE_EVENT_LANG_CHANGE, NULL, NULL);
- watch_core_set_event_callback(WATCH_CORE_EVENT_REGION_CHANGE, NULL, NULL);
+ watch_core_set_event_callback(WATCH_CORE_EVENT_REGION_CHANGE, NULL,
+ NULL);
if (eina_list_count(handler_list[APP_EVENT_LOW_BATTERY]) > 0)
- watch_core_set_event_callback(WATCH_CORE_EVENT_LOW_BATTERY, NULL, NULL);
+ watch_core_set_event_callback(WATCH_CORE_EVENT_LOW_BATTERY,
+ NULL, NULL);
}
static int _watch_core_create(int w, int h, void *data)
{
- _W("_watch_core_create");
struct watch_app_context *app_context = data;
watch_app_create_cb create_cb;
- if (app_context == NULL) {
- return watch_app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, NULL);
- }
+ _W("_watch_core_create");
+
+ if (app_context == NULL)
+ return watch_app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__,
+ NULL);
watch_core_initialized = 1;
_watch_core_set_appcore_event_cb(app_context);
create_cb = app_context->callback->create;
- if (create_cb == NULL || create_cb(w, h, app_context->data) == false) {
- return watch_app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, "watch_app_create_cb() returns false");
- }
+ if (create_cb == NULL || create_cb(w, h, app_context->data) == false)
+ return watch_app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__,
+ "watch_app_create_cb() returns false");
app_context->state = WATCH_APP_STATE_RUNNING;
static int _watch_core_control(app_control_h app_control, void *data)
{
- _W("_watch_core_control");
struct watch_app_context *app_context = data;
watch_app_control_cb app_control_cb;
+ _W("_watch_core_control");
+
if (app_context == NULL)
- return watch_app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, NULL);
+ return watch_app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__,
+ NULL);
app_control_cb = app_context->callback->app_control;
static int _watch_core_pause(void *data)
{
- _W("_watch_core_pause");
struct watch_app_context *app_context = data;
watch_app_pause_cb pause_cb;
+ _W("_watch_core_pause");
+
if (app_context == NULL)
- return watch_app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, NULL);
+ return watch_app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__,
+ NULL);
pause_cb = app_context->callback->pause;
static int _watch_core_resume(void *data)
{
- _W("_watch_core_resume");
struct watch_app_context *app_context = data;
watch_app_resume_cb resume_cb;
+ _W("_watch_core_resume");
+
if (app_context == NULL)
- return watch_app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, NULL);
+ return watch_app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__,
+ NULL);
resume_cb = app_context->callback->resume;
static int _watch_core_terminate(void *data)
{
- _W("_watch_core_terminate");
struct watch_app_context *app_context = data;
watch_app_terminate_cb terminate_cb;
+ _W("_watch_core_terminate");
+
if (app_context == NULL)
- return watch_app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, NULL);
+ return watch_app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__,
+ NULL);
terminate_cb = app_context->callback->terminate;
static void _watch_core_time_tick(void *watchtime, void *data)
{
- _I("_watch_core_time_tick");
struct watch_app_context *app_context = data;
watch_app_time_tick_cb time_tick_cb;
+ _I("_watch_core_time_tick");
+
if (app_context == NULL)
return;
static void _watch_core_ambient_tick(void *watchtime, void *data)
{
- _W("_watch_core_ambient_tick");
struct watch_app_context *app_context = data;
watch_app_ambient_tick_cb ambient_tick_cb;
+ _W("_watch_core_ambient_tick");
+
if (app_context == NULL)
return;
static void _watch_core_ambient_changed(int ambient, void *data)
{
- _W("_watch_core_ambient_changed: %d", ambient);
struct watch_app_context *app_context = data;
watch_app_ambient_changed_cb ambient_changed_cb;
+ _W("_watch_core_ambient_changed: %d", ambient);
+
if (app_context == NULL)
return;
}
-EXPORT_API int watch_app_main(int argc, char **argv, watch_app_lifecycle_callback_s *callback, void *user_data)
+EXPORT_API int watch_app_main(int argc, char **argv,
+ watch_app_lifecycle_callback_s *callback, void *user_data)
{
struct watch_app_context app_context = {
.appid = NULL,
};
if (argc <= 0 || argv == NULL || callback == NULL)
- return watch_app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+ return watch_app_error(APP_ERROR_INVALID_PARAMETER,
+ __FUNCTION__, NULL);
if (callback->create == NULL)
- return watch_app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, "watch_app_create_cb() callback must be registered");
+ return watch_app_error(APP_ERROR_INVALID_PARAMETER,
+ __FUNCTION__,
+ "watch_app_create_cb() callback must be "
+ "registered");
if (app_context.state != WATCH_APP_STATE_NOT_RUNNING)
- return watch_app_error(APP_ERROR_ALREADY_RUNNING, __FUNCTION__, NULL);
+ return watch_app_error(APP_ERROR_ALREADY_RUNNING, __FUNCTION__,
+ NULL);
if (app_get_id(&(app_context.appid)) != APP_ERROR_NONE)
- return watch_app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, "failed to get the appid");
+ return watch_app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__,
+ "failed to get the appid");
app_context.state = WATCH_APP_STATE_CREATING;
watch_core_terminate();
}
-EXPORT_API int watch_app_add_event_handler(app_event_handler_h *event_handler, app_event_type_e event_type, app_event_cb callback, void *user_data)
+EXPORT_API int watch_app_add_event_handler(app_event_handler_h *event_handler,
+ app_event_type_e event_type, app_event_cb callback,
+ void *user_data)
{
app_event_handler_h handler;
Eina_List *l_itr;
}
if (event_handler == NULL || callback == NULL)
- return watch_app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+ return watch_app_error(APP_ERROR_INVALID_PARAMETER,
+ __FUNCTION__, NULL);
- if (event_type < APP_EVENT_LOW_MEMORY || event_type > APP_EVENT_REGION_FORMAT_CHANGED)
- return watch_app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+ if (event_type < APP_EVENT_LOW_MEMORY ||
+ event_type > APP_EVENT_REGION_FORMAT_CHANGED)
+ return watch_app_error(APP_ERROR_INVALID_PARAMETER,
+ __FUNCTION__, NULL);
EINA_LIST_FOREACH(handler_list[event_type], l_itr, handler) {
if (handler->cb == callback)
- return watch_app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+ return watch_app_error(APP_ERROR_INVALID_PARAMETER,
+ __FUNCTION__, NULL);
}
handler = calloc(1, sizeof(struct app_event_handler));
if (!handler)
- return watch_app_error(APP_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL);
+ return watch_app_error(APP_ERROR_OUT_OF_MEMORY, __FUNCTION__,
+ NULL);
handler->type = event_type;
handler->cb = callback;
if (watch_core_initialized
&& event_type == APP_EVENT_LOW_BATTERY
&& eina_list_count(handler_list[event_type]) == 0)
- watch_core_set_event_callback(WATCH_CORE_EVENT_LOW_BATTERY, _watch_core_low_battery, NULL);
+ watch_core_set_event_callback(WATCH_CORE_EVENT_LOW_BATTERY,
+ _watch_core_low_battery, NULL);
- handler_list[event_type] = eina_list_append(handler_list[event_type], handler);
+ handler_list[event_type] = eina_list_append(handler_list[event_type],
+ handler);
*event_handler = handler;
Eina_List *l_next;
if (event_handler == NULL)
- return watch_app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+ return watch_app_error(APP_ERROR_INVALID_PARAMETER,
+ __FUNCTION__, NULL);
if (!_initialized) {
_I("handler list is not initialized");
}
type = event_handler->type;
- if (type < APP_EVENT_LOW_MEMORY || type > APP_EVENT_REGION_FORMAT_CHANGED)
- return watch_app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+ if (type < APP_EVENT_LOW_MEMORY ||
+ type > APP_EVENT_REGION_FORMAT_CHANGED)
+ return watch_app_error(APP_ERROR_INVALID_PARAMETER,
+ __FUNCTION__, NULL);
EINA_LIST_FOREACH_SAFE(handler_list[type], l_itr, l_next, handler) {
if (handler == event_handler) {
free(handler);
- handler_list[type] = eina_list_remove_list(handler_list[type], l_itr);
+ handler_list[type] = eina_list_remove_list(
+ handler_list[type], l_itr);
if (watch_core_initialized
- && type == APP_EVENT_LOW_BATTERY
- && eina_list_count(handler_list[type]) == 0)
- watch_core_set_event_callback(WATCH_CORE_EVENT_LOW_BATTERY, NULL, NULL);
+ && type == APP_EVENT_LOW_BATTERY
+ && eina_list_count(handler_list[type]) == 0)
+ watch_core_set_event_callback(
+ WATCH_CORE_EVENT_LOW_BATTERY,
+ NULL, NULL);
return APP_ERROR_NONE;
}
}
- return watch_app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, "cannot find such handler");
+ return watch_app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__,
+ "cannot find such handler");
}
-EXPORT_API int watch_time_get_current_time(watch_time_h* watch_time)
+EXPORT_API int watch_time_get_current_time(watch_time_h *watch_time)
{
- if (watch_time == NULL)
- return watch_app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
-
struct watch_time_s *time_info;
+ if (watch_time == NULL)
+ return watch_app_error(APP_ERROR_INVALID_PARAMETER,
+ __FUNCTION__, NULL);
+
time_info = calloc(1, sizeof(struct watch_time_s));
if (time_info == NULL)
- return watch_app_error(APP_ERROR_OUT_OF_MEMORY, __FUNCTION__, "failed to create a handle");
+ return watch_app_error(APP_ERROR_OUT_OF_MEMORY, __FUNCTION__,
+ "failed to create a handle");
watch_core_get_timeinfo(time_info);
EXPORT_API int watch_time_delete(watch_time_h watch_time)
{
if (watch_time == NULL)
- return watch_app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+ return watch_app_error(APP_ERROR_INVALID_PARAMETER,
+ __FUNCTION__, NULL);
if (watch_time->timezone)
free(watch_time->timezone);
EXPORT_API int watch_time_get_year(watch_time_h watch_time, int *year)
{
if (watch_time == NULL)
- return watch_app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+ return watch_app_error(APP_ERROR_INVALID_PARAMETER,
+ __FUNCTION__, NULL);
*year = watch_time->year;
return APP_ERROR_NONE;
EXPORT_API int watch_time_get_month(watch_time_h watch_time, int *month)
{
if (watch_time == NULL)
- return watch_app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+ return watch_app_error(APP_ERROR_INVALID_PARAMETER,
+ __FUNCTION__, NULL);
*month = watch_time->month;
return APP_ERROR_NONE;
EXPORT_API int watch_time_get_day(watch_time_h watch_time, int *day)
{
if (watch_time == NULL)
- return watch_app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+ return watch_app_error(APP_ERROR_INVALID_PARAMETER,
+ __FUNCTION__, NULL);
*day = watch_time->day;
return APP_ERROR_NONE;
}
-EXPORT_API int watch_time_get_day_of_week(watch_time_h watch_time, int *day_of_week)
+EXPORT_API int watch_time_get_day_of_week(watch_time_h watch_time,
+ int *day_of_week)
{
if (watch_time == NULL)
- return watch_app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+ return watch_app_error(APP_ERROR_INVALID_PARAMETER,
+ __FUNCTION__, NULL);
*day_of_week = watch_time->day_of_week;
return APP_ERROR_NONE;
EXPORT_API int watch_time_get_hour(watch_time_h watch_time, int *hour)
{
if (watch_time == NULL)
- return watch_app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+ return watch_app_error(APP_ERROR_INVALID_PARAMETER,
+ __FUNCTION__, NULL);
*hour = watch_time->hour;
return APP_ERROR_NONE;
EXPORT_API int watch_time_get_hour24(watch_time_h watch_time, int *hour24)
{
if (watch_time == NULL)
- return watch_app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+ return watch_app_error(APP_ERROR_INVALID_PARAMETER,
+ __FUNCTION__, NULL);
*hour24 = watch_time->hour24;
return APP_ERROR_NONE;
EXPORT_API int watch_time_get_minute(watch_time_h watch_time, int *minute)
{
if (watch_time == NULL)
- return watch_app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+ return watch_app_error(APP_ERROR_INVALID_PARAMETER,
+ __FUNCTION__, NULL);
*minute = watch_time->minute;
return APP_ERROR_NONE;
EXPORT_API int watch_time_get_second(watch_time_h watch_time, int *second)
{
if (watch_time == NULL)
- return watch_app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+ return watch_app_error(APP_ERROR_INVALID_PARAMETER,
+ __FUNCTION__, NULL);
*second = watch_time->second;
return APP_ERROR_NONE;
}
-EXPORT_API int watch_time_get_millisecond(watch_time_h watch_time, int *millisecond)
+EXPORT_API int watch_time_get_millisecond(watch_time_h watch_time,
+ int *millisecond)
{
if (watch_time == NULL)
- return watch_app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+ return watch_app_error(APP_ERROR_INVALID_PARAMETER,
+ __FUNCTION__, NULL);
*millisecond = watch_time->millisecond;
return APP_ERROR_NONE;
}
-EXPORT_API int watch_time_get_utc_time(watch_time_h watch_time, struct tm *utc_time)
+EXPORT_API int watch_time_get_utc_time(watch_time_h watch_time,
+ struct tm *utc_time)
{
+ time_t timestamp;
+
if (watch_time == NULL || utc_time == NULL)
- return watch_app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+ return watch_app_error(APP_ERROR_INVALID_PARAMETER,
+ __FUNCTION__, NULL);
- time_t timestamp = watch_time->timestamp;
+ timestamp = watch_time->timestamp;
gmtime_r(×tamp, utc_time);
return APP_ERROR_NONE;
}
-EXPORT_API int watch_time_get_utc_timestamp(watch_time_h watch_time, time_t *utc_timestamp)
+EXPORT_API int watch_time_get_utc_timestamp(watch_time_h watch_time,
+ time_t *utc_timestamp)
{
if (watch_time == NULL)
- return watch_app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+ return watch_app_error(APP_ERROR_INVALID_PARAMETER,
+ __FUNCTION__, NULL);
*utc_timestamp = watch_time->timestamp;
return APP_ERROR_NONE;
}
-EXPORT_API int watch_time_get_time_zone(watch_time_h watch_time, char **time_zone_id)
+EXPORT_API int watch_time_get_time_zone(watch_time_h watch_time,
+ char **time_zone_id)
{
- if (watch_time == NULL || watch_time->timezone == NULL || time_zone_id == NULL)
- return watch_app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+ if (watch_time == NULL || watch_time->timezone == NULL
+ || time_zone_id == NULL)
+ return watch_app_error(APP_ERROR_INVALID_PARAMETER,
+ __FUNCTION__, NULL);
*time_zone_id = strdup(watch_time->timezone);
Evas_Object *ret_win;
if (win == NULL)
- return watch_app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+ return watch_app_error(APP_ERROR_INVALID_PARAMETER,
+ __FUNCTION__, NULL);
ret_win = elm_win_add(NULL, watch_core_get_appid(), ELM_WIN_BASIC);
if (ret_win == NULL)
- return watch_app_error(APP_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL);
+ return watch_app_error(APP_ERROR_OUT_OF_MEMORY, __FUNCTION__,
+ NULL);
*win = ret_win;
return APP_ERROR_NONE;
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
extern "C" {
#endif
-int watch_app_error(app_error_e error, const char* function, const char *description);
+int watch_app_error(app_error_e error, const char *function,
+ const char *description);
#ifdef __cplusplus
}
#endif
#endif /* __WATCH_APP_PRIVATE_H__ */
+