4 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
31 #include <sys/signal.h>
32 #include <sys/timeb.h>
33 #include "email-core-timer.h"
34 #include "email-debug-log.h"
38 EMAIL_TIMER_CALLBACK user_callback_function;
39 void *callback_user_data;
41 } em_timer_callback_data;
44 INTERNAL_FUNC int emcore_timer_ex_callback(void *a_pData)
46 EM_DEBUG_LOG("[emcore_timer_ex_callback] enter\n");
47 void *pUserData = NULL;
49 #if !GLIB_CHECK_VERSION(2, 31, 0)
53 em_timer_callback_data *pTimerData = (em_timer_callback_data *)a_pData;
54 if (pTimerData != NULL) {
55 EMAIL_TIMER_CALLBACK pfn_UserCB = pTimerData->user_callback_function;
56 pUserData = pTimerData->callback_user_data;
58 EM_DEBUG_LOG("emcore_timer_ex_callback >>> data : %s", (char *)pTimerData->callback_user_data);
60 EM_SAFE_FREE(pTimerData);
61 pfn_UserCB(pUserData);
64 #if !GLIB_CHECK_VERSION(2, 31, 0)
68 EM_DEBUG_LOG("[emcore_timer_ex_callback] leave\n");
76 INTERNAL_FUNC int emcore_set_timer_ex(long a_nSetTimeValue, EMAIL_TIMER_CALLBACK a_pCallBack, void *a_pData)
78 EM_DEBUG_LOG("emcore_set_timer_ex %ld", a_nSetTimeValue);
79 em_timer_callback_data *pTimerData = NULL;
80 pTimerData = malloc(sizeof(em_timer_callback_data));
84 memset(pTimerData, 0x00, sizeof(em_timer_callback_data));
86 pTimerData->user_callback_function = a_pCallBack;
88 pTimerData->callback_user_data = a_pData;
90 pTimerData->time_id = g_timeout_add(a_nSetTimeValue, emcore_timer_ex_callback, pTimerData);
91 return pTimerData->time_id;
94 INTERNAL_FUNC void emcore_kill_timer_ex(int a_nTimerID)
96 EM_DEBUG_LOG("[emcore_kill_timer_ex] a_nTimerID %d", a_nTimerID);
97 g_source_remove(a_nTimerID);