summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtimer_alert/inc/log.h145
-rwxr-xr-xtimer_alert/inc/ring.h5
-rwxr-xr-xtimer_alert/src/ring.c117
-rwxr-xr-xtimer_alert/src/sound.c32
4 files changed, 244 insertions, 55 deletions
diff --git a/timer_alert/inc/log.h b/timer_alert/inc/log.h
new file mode 100755
index 0000000..df46ffc
--- /dev/null
+++ b/timer_alert/inc/log.h
@@ -0,0 +1,145 @@
+/*
+ * Samsung API
+ * Copyright (c) 2013 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 __SAMPLE_APP_LOG_H__
+#define __SAMPLE_APP_LOG_H__
+
+#include <unistd.h>
+#include <dlog.h>
+
+#define FONT_COLOR_RESET "\033[0m"
+#define FONT_COLOR_RED "\033[31m"
+#define FONT_COLOR_GREEN "\033[32m"
+#define FONT_COLOR_YELLOW "\033[33m"
+#define FONT_COLOR_BLUE "\033[34m"
+#define FONT_COLOR_PURPLE "\033[35m"
+#define FONT_COLOR_CYAN "\033[36m"
+#define FONT_COLOR_GRAY "\033[37m"
+
+#define WCOLOR_RED "\033[0;31m"
+#define WCOLOR_GREEN "\033[0;32m"
+#define WCOLOR_BROWN "\033[0;33m"
+#define WCOLOR_BLUE "\033[0;34m"
+#define WCOLOR_PURPLE "\033[0;35m"
+#define WCOLOR_CYAN "\033[0;36m"
+#define WCOLOR_LIGHTBLUE "\033[0;37m"
+#define WCOLOR_END "\033[0;m"
+#define MODULE_INFO (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
+#undef LOG_TAG
+#define LOG_TAG "TIMER_ALERT"
+
+#if !defined(_D)
+#define _D(fmt, arg...) dlog_print(DLOG_DEBUG, \
+ LOG_TAG, "%s: %s(%d) > " WCOLOR_GREEN fmt WCOLOR_END, MODULE_INFO, \
+ __func__, __LINE__, ##arg)
+#endif
+
+#if !defined(_W)
+#define _W(fmt, arg...) (dlog_print(DLOG_WARN, \
+ LOG_TAG, "%s: %s(%d) > " WCOLOR_GREEN fmt WCOLOR_END, MODULE_INFO, \
+ __func__, __LINE__, ##arg))
+#endif
+
+#if !defined(_E)
+#define _E(fmt,arg...) (dlog_print(DLOG_ERROR, \
+ LOG_TAG, "%s: %s(%d) > " WCOLOR_RED fmt WCOLOR_END, MODULE_INFO, \
+ __func__, __LINE__, ##arg))
+#endif
+
+#if !defined(TMR_INFO)
+#define TMR_INFO(fmt, arg...) (dlog_print(DLOG_DEBUG, \
+ LOG_TAG, "%s: %s(%d) > " WCOLOR_GREEN fmt WCOLOR_END, MODULE_INFO, \
+ __func__, __LINE__, ##arg))
+#endif
+
+#if !defined(TMR_SINFO)
+#define TMR_SINFO(fmt, arg...) (dlog_print(DLOG_DEBUG, \
+ LOG_TAG, "%s: %s(%d) > " WCOLOR_GREEN fmt WCOLOR_END, MODULE_INFO, \
+ __func__, __LINE__, ##arg))
+#endif
+
+#if !defined(TMR_ERR)
+#define TMR_ERR(fmt,arg...) (dlog_print(DLOG_ERROR, \
+ LOG_TAG, "%s: %s(%d) > " WCOLOR_RED fmt WCOLOR_END, MODULE_INFO, \
+ __func__, __LINE__, ##arg))
+#endif
+
+#if !defined(_TMR_ENTER_)
+#define _TMR_ENTER_ _D("%s - Entry", __func__)
+#endif
+
+#if !defined(DBG)
+#define DBG(fmt , args...) \
+ do { \
+ dlog_print(DLOG_DEBUG, \
+ LOG_TAG, "%s: %s(%d) > " WCOLOR_GREEN fmt WCOLOR_END, MODULE_INFO, \
+ __func__, __LINE__, ##arg)\
+ } while (0)
+#endif
+
+#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; \
+ } \
+}
+
+#endif /* __SAMPLE_APP_LOG_H__ */
diff --git a/timer_alert/inc/ring.h b/timer_alert/inc/ring.h
index 2598a63..84689e6 100755
--- a/timer_alert/inc/ring.h
+++ b/timer_alert/inc/ring.h
@@ -23,12 +23,7 @@
#include <Elementary.h>
#include <system_settings.h>
#include <efl_extension.h>
-#include <dlog.h>
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-#define LOG_TAG "ring"
#if !defined(PACKAGE)
#define PACKAGE "timer"
diff --git a/timer_alert/src/ring.c b/timer_alert/src/ring.c
index 81643ea..7994879 100755
--- a/timer_alert/src/ring.c
+++ b/timer_alert/src/ring.c
@@ -21,6 +21,10 @@
#include <device/power.h>
#include <sound_manager.h>
#include "timer_alert_string.h"
+#include "log.h"
+
+#define KEY_POWER "XF86PowerOff"
+#define KEY_BACK "XF86Back"
typedef struct appdata {
Evas_Object* win;
@@ -31,23 +35,26 @@ typedef struct appdata {
Ecore_Timer *timer = NULL;
int delay_count = 0;
+void close_alert_app();
static void _ring_pm_state_set(Eina_Bool isLock)
{
- dlog_print(DLOG_INFO, LOG_TAG, "_ring_pm_state_set");
+ _TMR_ENTER_;
+ _D("_ring_pm_state_set");
int ret = 0;
if (isLock == EINA_TRUE) {
ret = device_power_request_lock(POWER_LOCK_DISPLAY_DIM, 0);
- dlog_print(DLOG_INFO, LOG_TAG, "Lock display state :: ret = %d", ret);
+ _D("Lock display state :: ret = %d", ret);
} else {
ret = device_power_release_lock(POWER_LOCK_DISPLAY_DIM);
- dlog_print(DLOG_INFO, LOG_TAG, "Unlock display state :: ret = %d", ret);
+ _D("Unlock display state :: ret = %d", ret);
}
}
void data_get_resource_path(const char *file_in, char *file_path_out, int file_path_max)
{
+ _TMR_ENTER_;
char *res_path = app_get_resource_path();
if (res_path) {
snprintf(file_path_out, file_path_max, "%s%s", res_path, file_in);
@@ -58,13 +65,14 @@ void data_get_resource_path(const char *file_in, char *file_path_out, int file_p
static void
win_delete_request_cb(void *data, Evas_Object *obj, void *event_info)
{
- _ring_pm_state_set(EINA_FALSE);
- ui_app_exit();
+ _TMR_ENTER_;
+ close_alert_app();
}
static void
app_get_resource(const char *edj_file_in, char *edj_path_out, int edj_path_max)
{
+ _TMR_ENTER_;
char *res_path = app_get_resource_path();
if (res_path) {
snprintf(edj_path_out, edj_path_max, "%s%s", res_path, edj_file_in);
@@ -72,9 +80,26 @@ app_get_resource(const char *edj_file_in, char *edj_path_out, int edj_path_max)
}
}
+static Eina_Bool _key_pressed(void *data, Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info)
+{
+ _TMR_ENTER_;
+ _D("_key_pressed");
+ Evas_Event_Key_Down *ev = event_info;
+ _D("type:%d, key: %s ,powerkey:%s",type, ev->key, KEY_POWER);
+ if (type == EVAS_CALLBACK_KEY_DOWN && ( strncmp(KEY_POWER, ev->key, strlen(KEY_POWER)) == 0 || strncmp(KEY_BACK, ev->key, strlen(KEY_BACK)) == 0) ) {
+ _D("KEY PRESSED: %s", ev->key);
+
+ close_alert_app();
+
+ return EINA_TRUE;
+ } else {
+ return EINA_FALSE;
+ }
+}
static void
create_base_gui(appdata_s *ad)
{
+ _TMR_ENTER_;
char edj_path[PATH_MAX] = {0, };
/* Window */
@@ -100,6 +125,7 @@ create_base_gui(appdata_s *ad)
elm_win_indicator_opacity_set(ad->win, ELM_WIN_INDICATOR_OPAQUE);
evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(ad->win, ad->conform);
+ elm_object_event_callback_add(ad->win, _key_pressed, NULL);
evas_object_show(ad->conform);
app_get_resource(EDJ_FILE, edj_path, (int)PATH_MAX);
@@ -116,47 +142,53 @@ create_base_gui(appdata_s *ad)
evas_object_show(ad->win);
}
-
-static void _ring_main_dismiss_timer_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
+void close_alert_app()
{
- dlog_print(DLOG_INFO, LOG_TAG, "_ring_main_dismiss_timer_cb");
+ _ring_pm_state_set(EINA_FALSE);
ring_stop_player();
- elm_naviframe_item_pop((Evas_Object*)data);
delay_count = 0;
ECORE_TIMER_DELIF(timer);
ui_app_exit();
}
+static void _ring_main_dismiss_timer_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
+{
+ _TMR_ENTER_;
+ _D("_ring_main_dismiss_timer_cb");
+ close_alert_app();
+}
Evas_Object *view_create_layout(Evas_Object *parent, const char *file_path, const char *group_name, Eext_Event_Cb cb_function, void *user_data)
{
- dlog_print(DLOG_INFO, LOG_TAG, "view_create_layout >>");
+ _TMR_ENTER_;
+ _D("view_create_layout >>");
Evas_Object *layout = NULL;
if (parent == NULL) {
- dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
+ _E("parent is NULL.");
return NULL;
}
- dlog_print(DLOG_INFO, LOG_TAG, "view_create_layout 0");
+ _D("view_create_layout 0");
layout = elm_layout_add(parent);
//elm_layout_theme_set(layout, "layout", "nocontents", "default");
- dlog_print(DLOG_INFO, LOG_TAG, "view_create_layout file_path:%s, group_name:%s", file_path, group_name);
+ _D("view_create_layout file_path:%s, group_name:%s", file_path, group_name);
int ret = elm_layout_file_set(layout, file_path, group_name);
- dlog_print(DLOG_INFO, LOG_TAG, "view_create_layout ret : %d", ret);
+ _D("view_create_layout ret : %d", ret);
evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- dlog_print(DLOG_INFO, LOG_TAG, "view_create_layout 2");
+ _D("view_create_layout 2");
if (cb_function)
eext_object_event_callback_add(layout, EEXT_CALLBACK_BACK, cb_function, user_data);
- dlog_print(DLOG_INFO, LOG_TAG, "view_create_layout 3");
+ _D("view_create_layout 3");
evas_object_show(layout);
- dlog_print(DLOG_INFO, LOG_TAG, "view_create_layout <<");
+ _D("view_create_layout <<");
return layout;
}
void view_set_text(Evas_Object *parent, const char *part_name, const char *text)
{
- dlog_print(DLOG_ERROR, LOG_TAG, "view_set_text");
+ _TMR_ENTER_;
+ _E("view_set_text");
if (parent == NULL) {
- dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
+ _E("parent is NULL.");
return;
}
@@ -166,15 +198,16 @@ void view_set_text(Evas_Object *parent, const char *part_name, const char *text)
Elm_Object_Item* view_push_item_to_naviframe(Evas_Object *nf, Evas_Object *item, Elm_Naviframe_Item_Pop_Cb _pop_cb, void *cb_data)
{
+ _TMR_ENTER_;
Elm_Object_Item* nf_it = NULL;
if (nf == NULL) {
- dlog_print(DLOG_ERROR, LOG_TAG, "naviframe is NULL.");
+ _E("naviframe is NULL.");
return NULL;
}
if (item == NULL) {
- dlog_print(DLOG_ERROR, LOG_TAG, "item is NULL.");
+ _E("item is NULL.");
return NULL;
}
@@ -188,8 +221,9 @@ Elm_Object_Item* view_push_item_to_naviframe(Evas_Object *nf, Evas_Object *item,
static Eina_Bool _update_ring_view_by_timer_cb(void *data)
{
+ //_TMR_ENTER_;
if (!data) {
- dlog_print(DLOG_ERROR, LOG_TAG, "canceled timer");
+ _E("canceled timer");
return ECORE_CALLBACK_CANCEL;
}
Evas_Object *ly_main = (Evas_Object *)data;
@@ -207,12 +241,13 @@ static Eina_Bool _update_ring_view_by_timer_cb(void *data)
void ring_view_add_by_timer(Evas_Object *parent)
{
- dlog_print(DLOG_INFO, LOG_TAG, "ring_view_add_by_timer >>");
+ _TMR_ENTER_;
+ _D("ring_view_add_by_timer >>");
Evas_Object *ly_main = NULL;
char file_path[BUF_LEN] = {0, };
if (parent == NULL) {
- dlog_print(DLOG_ERROR, LOG_TAG, "failed to get parent.");
+ _E("failed to get parent.");
return;
}
@@ -220,10 +255,10 @@ void ring_view_add_by_timer(Evas_Object *parent)
* Create a layout that shows when the alarm sounds.
*/
data_get_resource_path("edje/ring.edj", file_path, sizeof(file_path));
- dlog_print(DLOG_ERROR, LOG_TAG, "file_path:%s", file_path);
+ _E("file_path:%s", file_path);
ly_main = view_create_layout(parent, file_path, "timer", NULL, NULL);
if (ly_main == NULL) {
- dlog_print(DLOG_ERROR, LOG_TAG, "failed to create a layout.");
+ _E("failed to create a layout.");
return;
}
char text[256] = { 0 };
@@ -249,6 +284,7 @@ void ring_view_add_by_timer(Evas_Object *parent)
static bool
app_create(void *data)
{
+ _TMR_ENTER_;
/* 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
@@ -259,53 +295,57 @@ app_create(void *data)
snprintf(locale_path,sizeof(locale_path),"%s/locale",respath);
bindtextdomain(PACKAGE,locale_path);
create_base_gui(ad);
-
+ _ring_pm_state_set(EINA_TRUE);
+ ring_view_add_by_timer(ad->nf);
return true;
}
static void
app_control(app_control_h app_control, void *data)
{
+ _TMR_ENTER_;
/* Handle the launch request. */
appdata_s *ad = data;
- _ring_pm_state_set(EINA_TRUE);
- dlog_print(DLOG_INFO, LOG_TAG, "app_control >>");
- ring_view_add_by_timer(ad->nf);
+ //_D("app_control >>");
+
+
}
static void
app_pause(void *data)
{
+ _TMR_ENTER_;
/* Take necessary actions when application becomes invisible. */
- _ring_pm_state_set(EINA_FALSE);
+
}
static void
app_resume(void *data)
{
+ _TMR_ENTER_;
/* Take necessary actions when application becomes visible. */
- _ring_pm_state_set(EINA_TRUE);
+
}
static void
app_terminate(void *data)
{
-
+ _TMR_ENTER_;
}
static void
ui_app_lang_changed(app_event_info_h event_info, void *user_data)
{
/*APP_EVENT_LANGUAGE_CHANGED*/
-
+ _TMR_ENTER_;
int ret;
char *language;
ret = app_event_get_language(event_info, &language);
if (ret != APP_ERROR_NONE) {
- dlog_print(DLOG_ERROR, LOG_TAG, "app_event_get_language() failed. Err = %d.", ret);
+ _E("app_event_get_language() failed. Err = %d.", ret);
return;
}
@@ -318,6 +358,7 @@ ui_app_lang_changed(app_event_info_h event_info, void *user_data)
static void
ui_app_orient_changed(app_event_info_h event_info, void *user_data)
{
+ _TMR_ENTER_;
/*APP_EVENT_DEVICE_ORIENTATION_CHANGED*/
return;
}
@@ -325,24 +366,28 @@ ui_app_orient_changed(app_event_info_h event_info, void *user_data)
static void
ui_app_region_changed(app_event_info_h event_info, void *user_data)
{
+ _TMR_ENTER_;
/*APP_EVENT_REGION_FORMAT_CHANGED*/
}
static void
ui_app_low_battery(app_event_info_h event_info, void *user_data)
{
+ _TMR_ENTER_;
/*APP_EVENT_LOW_BATTERY*/
}
static void
ui_app_low_memory(app_event_info_h event_info, void *user_data)
{
+ _TMR_ENTER_;
/*APP_EVENT_LOW_MEMORY*/
}
int
main(int argc, char *argv[])
{
+ _TMR_ENTER_;
appdata_s ad = {0,};
int ret = 0;
@@ -363,7 +408,7 @@ main(int argc, char *argv[])
ret = ui_app_main(argc, argv, &event_callback, &ad);
if (ret != APP_ERROR_NONE)
- dlog_print(DLOG_ERROR, LOG_TAG, "ui_app_main() is failed. err = %d", ret);
+ _E("ui_app_main() is failed. err = %d", ret);
return ret;
}
diff --git a/timer_alert/src/sound.c b/timer_alert/src/sound.c
index 1fa31ad..a5e8cba 100755
--- a/timer_alert/src/sound.c
+++ b/timer_alert/src/sound.c
@@ -18,7 +18,7 @@
#include <app.h>
#include <app_alarm.h>
#include <efl_extension.h>
-#include <dlog.h>
+#include "log.h"
#include <system_settings.h>
#include <app_preference.h>
#include <bundle.h>
@@ -28,11 +28,13 @@
static void _ring_player_error_cb(int error_code, void *data)
{
- dlog_print(DLOG_ERROR, LOG_TAG, "player error Code: %x", error_code);
+ _TMR_ENTER_;
+ _E("player error Code: %x", error_code);
}
static Eina_Bool _ring_player_start_cb(void *data)
{
+ _TMR_ENTER_;
int ret = SUCCESS;
player_state_e play_state;
@@ -41,17 +43,18 @@ static Eina_Bool _ring_player_start_cb(void *data)
if (play_state == PLAYER_STATE_PAUSED || play_state == PLAYER_STATE_READY) {
ret = player_start(*mm_player);
if (ret != PLAYER_ERROR_NONE)
- dlog_print(DLOG_ERROR, LOG_TAG, "player error Code: %x", ret);
+ _E("player error Code: %x", ret);
} else
- dlog_print(DLOG_ERROR, LOG_TAG, "Player state = %d. Do not start player", play_state);
+ _E("Player state = %d. Do not start player", play_state);
player_start_timer = NULL;
return ECORE_CALLBACK_CANCEL;
}
void ring_stop_player(void)
{
+ _TMR_ENTER_;
if (mm_player == NULL) {
- dlog_print(DLOG_ERROR, LOG_TAG, "mm_player = NULL. Returnr");
+ _E("mm_player = NULL. Returnr");
return;
}
@@ -61,7 +64,7 @@ void ring_stop_player(void)
ret = player_unprepare(*(mm_player));
player_state_e play_state;
player_get_state(*(mm_player), &play_state);
- dlog_print(DLOG_INFO, LOG_TAG, "After unprepare play_state: %d", play_state);
+ _D("After unprepare play_state: %d", play_state);
if (mm_player)
player_destroy(*(mm_player));
@@ -71,7 +74,8 @@ void ring_stop_player(void)
void ring_create_player(void)
{
- dlog_print(DLOG_INFO, LOG_TAG, "player create");
+ _TMR_ENTER_;
+ _D("player create");
int ret = SUCCESS;
/* Player create */
@@ -79,13 +83,13 @@ void ring_create_player(void)
player_h *player = (player_h *)calloc(1, sizeof(player_h));
ret = player_create(player);
if (PLAYER_ERROR_NONE != ret) {
- dlog_print(DLOG_ERROR, LOG_TAG, "Create player failed Error ID: %x", ret);
+ _E("Create player failed Error ID: %x", ret);
FREEIF(player);
return;
}
if (player_set_looping(*player, true) != PLAYER_ERROR_NONE) {
- dlog_print(DLOG_ERROR, LOG_TAG, "looping player failed Error ID: %x", ret);
+ _E("looping player failed Error ID: %x", ret);
FREEIF(player);
return;
}
@@ -98,7 +102,7 @@ void ring_create_player(void)
if (play_state == PLAYER_STATE_IDLE) {
ret = player_set_uri(*(mm_player), RING_DEFALT_TONE);
if (PLAYER_ERROR_NONE != ret) {
- dlog_print(DLOG_ERROR, LOG_TAG, "player_set_uri Error ID: %x", ret);
+ _E("player_set_uri Error ID: %x", ret);
player_destroy(*(mm_player));
FREEIF(mm_player);
return;
@@ -108,7 +112,7 @@ void ring_create_player(void)
/* Player set sound type */
ret = player_set_sound_type(*(mm_player), SOUND_TYPE_ALARM);
if (PLAYER_ERROR_NONE != ret) {
- dlog_print(DLOG_ERROR, LOG_TAG, "player_set_sound_type Error ID: %x", ret);
+ _E("player_set_sound_type Error ID: %x", ret);
player_destroy(*(mm_player));
FREEIF(mm_player);
return;
@@ -122,15 +126,15 @@ void ring_create_player(void)
if (play_state == PLAYER_STATE_IDLE) {
ret = player_prepare(*(mm_player));
if (PLAYER_ERROR_NONE != ret) {
- dlog_print(DLOG_ERROR, LOG_TAG, "player_prepare Error ID: %x", ret);
+ _E("player_prepare Error ID: %x", ret);
player_destroy(*(mm_player));
FREEIF(mm_player);
return;
}
if (mm_player != NULL) {
- dlog_print(DLOG_INFO, LOG_TAG, "player ring_paused = %d", ring_paused);
+ _D("player ring_paused = %d", ring_paused);
if (ring_paused) {
- dlog_print(DLOG_ERROR, LOG_TAG, "Player is not started because app already pause state");
+ _E("Player is not started because app already pause state");
return;
}
/* Add timer for player context separate */