/* * email-service * * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: Kyuho Jo , Sunghyun Kwon * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * 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 #include #include #include #include #include #include #include #include #include #include "email-core-timer.h" #include "email-debug-log.h" #include typedef struct { EMAIL_TIMER_CALLBACK user_callback_function; void *callback_user_data; int time_id; }em_timer_callback_data; INTERNAL_FUNC int emcore_timer_ex_callback(void *a_pData) { EM_DEBUG_LOG("[emcore_timer_ex_callback] enter\n"); void *pUserData = NULL; g_thread_init(NULL); dbus_g_thread_init (); em_timer_callback_data *pTimerData = (em_timer_callback_data *)a_pData; if (pTimerData != NULL) { EMAIL_TIMER_CALLBACK pfn_UserCB = pTimerData->user_callback_function; pUserData = pTimerData->callback_user_data; if (pUserData) EM_DEBUG_LOG("emcore_timer_ex_callback >>> data : %s", (char *)pTimerData->callback_user_data); EM_SAFE_FREE(pTimerData); pfn_UserCB(pUserData); } g_thread_init(NULL); dbus_g_thread_init (); EM_DEBUG_LOG("[emcore_timer_ex_callback] leave\n"); if (pUserData) return 0; else return 1; } INTERNAL_FUNC int emcore_set_timer_ex(long a_nSetTimeValue, EMAIL_TIMER_CALLBACK a_pCallBack, void *a_pData) { EM_DEBUG_LOG("emcore_set_timer_ex %d", a_nSetTimeValue); em_timer_callback_data *pTimerData = NULL; pTimerData = malloc(sizeof(em_timer_callback_data)); char *data = NULL; if (!pTimerData) return -1; memset(pTimerData, 0x00, sizeof(em_timer_callback_data)); if (a_pData) EM_DEBUG_LOG("emcore_set_timer_ex >>> data : %s", (char *)a_pData); pTimerData->user_callback_function = a_pCallBack; if (a_pData) { data = (char *) a_pData; pTimerData->callback_user_data = EM_SAFE_STRDUP(data); } pTimerData->time_id = g_timeout_add(a_nSetTimeValue, emcore_timer_ex_callback, pTimerData); return pTimerData->time_id; } INTERNAL_FUNC void emcore_kill_timer_ex(int a_nTimerID) { EM_DEBUG_LOG("[emcore_kill_timer_ex] a_nTimerID %d", a_nTimerID); g_source_remove(a_nTimerID); }