4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: JuHak Park <juhaki.park@samsung.com>,
7 * JuneHyuk Lee <junhyuk7.lee@samsung.com>,
8 * SunBong Ha <sunbong.ha@samsung.com>
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
28 * For any sort of issue you concern as to this software,
29 * you may use following point of contact.
30 * All resources contributed on this software
31 * are orinigally written by S-Core Inc., a member of Samsung Group.
33 * SeongWon Shim <seongwon.shim@samsung.com>
37 * @OMA_DS_Platform_Event_Handler.c
39 * @brief This file is the source file of implementation of event callback function(from platform)
42 #include "agent-framework/DACI/DACI_Agent_Handler_Manager.h"
43 #include "Framework/Event/OMA_DS_Platform_Event_Handler.h"
44 #include "Framework/Task/OMA_DS_Engine_Controller_Task.h"
45 #include "Framework/SAN_parser/PM_SanParser.h"
46 #include "agent-framework/Utility/fw_log.h"
47 #include "Common/Common_Define_Internal.h"
48 #include "Common/Common_Util.h"
50 #define LOG_TAG "OMA_DS_COMMON"
52 static void __request_periodic_sync_task_finish_callback(task_error_t task_error,
53 unsigned int out_param_cnt, param_t **out_param_spec_array, void *usr_data);
55 static void __request_san_sync_task_finish_callback(task_error_t task_error,
56 unsigned int out_param_cnt, param_t **out_param_spec_array, void *usr_data);
58 static void __request_periodic_sync_task_finish_callback(task_error_t task_error,
59 unsigned int out_param_cnt,
60 param_t **out_param_spec_array,
63 unsigned int request_msg_id_to_cancel = 0;
64 get_periodic_sync_request_id(&request_msg_id_to_cancel);
68 static void __request_san_sync_task_finish_callback(task_error_t task_error,
69 unsigned int out_param_cnt,
70 param_t **out_param_spec_array,
73 unsigned int request_msg_id_to_cancel = 0;
74 get_san_sync_request_id(&request_msg_id_to_cancel);
77 int SAN_callback_parse(const char *msgBody, unsigned int msgSize, int version)
80 SanPackage *pSanPackage = NULL;
82 char *sync_mode = NULL;
83 char *server_id = NULL;
84 int *account_list = 0;
89 pSanPackage = sanPackage11Parser(msgBody, msgSize) ;
94 pSanPackage = sanPackage12Parser(msgBody, msgSize) ;
101 DACI_RETURN da_err = DACI_Open_Agent();
102 if (da_err != DACI_SUCCESS)
109 int account_list_count = 0;
110 account_list = DACI_Get_Account_Account_Id_List(&account_list_count);
114 for (i = 0 ; i < account_list_count ; i++) {
115 result = get_config(account_list[i], DEFINE_CONFIG_KEY_PROFILE_SYNC_MODE, &sync_mode);
116 if (result == true) {
117 /*One device MUST NOT register multi account at same server...*/
118 if (strcmp(sync_mode, DEFINE_SYNC_MODE_PUSH) == 0) {
119 result = get_config(account_list[i], DEFINE_CONFIG_KEY_PROFILE_SERVER_ID, &server_id);
120 if (result == true) {
121 /*One device MUST NOT register multi account at same server...*/
122 if (strcmp(pSanPackage->serverID, server_id) == 0) {
123 accountID = account_list[i];
127 FW_LOGE("failed in get_Config");
132 FW_LOGE("failed in get_Config");
141 char *syncMode = strdup(DEFINE_SYNC_MODE_PUSH) ;
143 void *in_param_value_array[3] = {&accountID, &syncMode, &pSanPackage};
144 int in_param_index_array[3] = {0, 1, 2};
145 ECValueType in_param_type[3] = {EC_VALUE_TYPE_INT, EC_VALUE_TYPE_STRUCT, EC_VALUE_TYPE_STRUCT};
146 unsigned int request_msg_id = 0;
147 engine_controller_async_request_task(EC_MSG_TYPE_SYNC_TASK_REQUEST, 0,
148 3, in_param_index_array, in_param_type, in_param_value_array,
149 __request_san_sync_task_finish_callback, NULL,
150 (int *)&request_msg_id);
152 insert_request_msg_info(SYNC_MODE_SAN, request_msg_id);
158 if (account_list_count > 0)
173 void send_periodic_sync_msg(int schedulerId, void *data)
175 FW_LOGV("#######Scheduler Send Msg Success!!!!!##########");
176 FW_LOGV("schedulerId = %d", schedulerId);
178 int *account_list = 0;
179 int account_list_count = 0;
182 char *alarmId_str = NULL;
185 DACI_RETURN da_err = DACI_Open_Agent();
186 if (da_err != DACI_SUCCESS) {
187 FW_LOGE("failed in DACI_Open_Agent");
191 account_list = DACI_Get_Account_Account_Id_List(&account_list_count);
193 FW_LOGV("account_list_count = %d", account_list_count);
196 for (i = 0; i < account_list_count; i++) {
197 if (alarmId_str != NULL)
200 result = get_config(account_list[i], DEFINE_CONFIG_KEY_PROFILE_ALARM_ID, &alarmId_str);
201 if (result == false) {
202 FW_LOGE("failed in get_Config");
205 alarmId = atoi(alarmId_str);
206 FW_LOGV("alarm id = %d", alarmId);
207 if (alarmId == schedulerId) {
208 FW_LOGV("account_list[i] = %d", account_list[i]);
209 accountId = account_list[i];
214 if (accountId != -1) {
215 int in_param_index_array[3] = {0, 1, 2};
216 ECValueType in_param_value_type_array[3] = {EC_VALUE_TYPE_INT,
217 EC_VALUE_TYPE_STRUCT, EC_VALUE_TYPE_STRUCT};
218 char *syncMode = strdup(DEFINE_SYNC_MODE_PERIODIC);
220 void *in_param_value_array[3] = {&accountId, &syncMode, NULL};
222 unsigned int request_msg_id = 0;
223 engine_controller_async_request_task(EC_MSG_TYPE_SYNC_TASK_REQUEST, 0,
224 3, in_param_index_array, in_param_value_type_array, in_param_value_array,
225 __request_periodic_sync_task_finish_callback, NULL,
226 (int *)&request_msg_id);
228 insert_request_msg_info(SYNC_MODE_PERIODIC, request_msg_id);
233 if (account_list_count > 0)
236 if (alarmId_str != NULL)