4 * Copyright (c) 2000 - 2011 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"
35 #include <dbus/dbus-glib.h>
40 EMAIL_TIMER_CALLBACK user_callback_function;
41 void *callback_user_data;
43 }em_timer_callback_data;
46 INTERNAL_FUNC int emcore_timer_ex_callback(void *a_pData)
48 EM_DEBUG_LOG("[emcore_timer_ex_callback] enter\n");
49 void *pUserData = NULL;
53 dbus_g_thread_init ();
55 em_timer_callback_data *pTimerData = (em_timer_callback_data *)a_pData;
56 if (pTimerData != NULL)
58 EMAIL_TIMER_CALLBACK pfn_UserCB = pTimerData->user_callback_function;
59 pUserData = pTimerData->callback_user_data;
61 EM_DEBUG_LOG("emcore_timer_ex_callback >>> data : %s", (char *)pTimerData->callback_user_data);
62 EM_SAFE_FREE(pTimerData);
63 pfn_UserCB(pUserData);
68 dbus_g_thread_init ();
70 EM_DEBUG_LOG("[emcore_timer_ex_callback] leave\n");
78 INTERNAL_FUNC int emcore_set_timer_ex(long a_nSetTimeValue, EMAIL_TIMER_CALLBACK a_pCallBack, void *a_pData)
80 EM_DEBUG_LOG("emcore_set_timer_ex %d", a_nSetTimeValue);
81 em_timer_callback_data *pTimerData = NULL;
82 pTimerData = malloc(sizeof(em_timer_callback_data));
86 memset(pTimerData, 0x00, sizeof(em_timer_callback_data));
88 EM_DEBUG_LOG("emcore_set_timer_ex >>> data : %s", (char *)a_pData);
90 pTimerData->user_callback_function = a_pCallBack;
92 data = (char *) a_pData;
93 pTimerData->callback_user_data = EM_SAFE_STRDUP(data);
95 pTimerData->time_id = g_timeout_add(a_nSetTimeValue, emcore_timer_ex_callback, pTimerData);
96 return pTimerData->time_id;
99 INTERNAL_FUNC void emcore_kill_timer_ex(int a_nTimerID)
101 EM_DEBUG_LOG("[emcore_kill_timer_ex] a_nTimerID %d", a_nTimerID);
102 g_source_remove(a_nTimerID);