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>
39 * @brief This file is the source file of implementation of main function
45 #include "agent-framework/Initialization/initialize.h"
46 #include "agent-framework/Utility/fw_log.h"
47 #include "agent-framework/PlatformMonitor/EXT_PMCI_Struct.h"
48 #include "agent-framework/PlatformMonitor/EXT_PMCI.h"
49 #include "agent-framework/FSAPI/FSAPI_operation.h"
50 #include "Framework/Event/OMA_DS_Platform_Event_Handler.h"
51 #include "Framework/Event/OMA_DS_Event_Handler.h"
52 #include "Framework/Task/OMA_DS_Engine_Controller_Task.h"
53 #include "Common/CscKeys.h"
54 #include "Common/Common_Define_Internal.h"
55 #include "Common/Common_Vconf.h"
56 #include "ServiceEngine/SE_Account.h"
58 #define LOG_TAG "OMA_DS_MAIN"
60 static void __request_reset_synchronizing_profiles();
61 static void __check_csc();
62 static void __update_csc();
68 EVENT_ERROR error = EVENT_SUCCESS;
70 INIT_ERROR init_error = Init_Framework("/opt/data/oma-ds/omads_fw_config.xml");
71 if (init_error != INIT_SUCCESS) {
72 FW_LOGE("Failed to Init_Framework() : %d", init_error);
74 FW_LOGV("done init_Framework");
77 /*TODO have to be removed after removing vconf*/
78 task_spec_t *pAddAccountTaskSpec = make_add_account_task();
79 task_spec_t *pEditAccountTaskSpec = make_edit_account_task();
80 /*task_spec_t *pDeleteAccountTaskSpec = make_delete_account_task();*/
81 task_spec_t *pAutoConfTaskSpec = make_autoconfigure_task();
84 task_spec_t *pSyncTaskSpec = make_synchronize_task();
85 /*task_spec_t *pAddProfileTaskSpec = make_add_profile_task();*/
86 /*task_spec_t *pEditProfileTaskSpec = make_edit_profile_task();*/
87 task_spec_t *pDeleteProfileTaskSpec = make_delete_profile_task();
88 /*task_spec_t *pAutoConfTaskSpec = make_auto_configure_task();*/
89 task_spec_t *pSyncStatusTaskSpec = make_sync_status_task();
90 task_spec_t *pGetProfileNameTaskSpec = make_get_profile_name_task();
91 task_spec_t *pGetProfileServerInfoTaskSpec = make_get_profile_server_info_task();
92 task_spec_t *pGetProfileSyncModeTaskSpec = make_get_profile_sync_mode_task();
93 task_spec_t *pGetProfileSyncCategoryTaskSpec = make_get_profile_sync_category_task();
94 task_spec_t *pGetProfileLastSessionTaskSpec = make_get_profile_last_session_task();
95 task_spec_t *pGetProfileStatisticsTaskSpec = make_get_profile_statistics_task();
96 task_spec_t *pResetSynchronizingProfilesTaskSpec = make_reset_synchronizing_profiles_task();
97 task_spec_t *pAddProfileCPTaskSpec = make_add_profile_cp_task();
98 task_spec_t *pRefreshFromServiceTaskSpec = make_refresh_from_service_task();
100 /*FIXME cancel request to NA */
101 /*task_spec_t *pCancelSyncRequestTaskSpec = make_cancel_sync_request();*/
105 /*TODO have to be removed after removing vconf*/
106 engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_ADD_ACCOUNT,
107 EC_MSG_TYPE_NAME_SYNC_TASK_ADD_ACCOUNT,
108 pAddAccountTaskSpec, NULL);
110 engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_EDIT_ACCOUNT,
111 EC_MSG_TYPE_NAME_SYNC_TASK_EDIT_ACCOUNT,
112 pEditAccountTaskSpec, NULL);
114 engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_AUTOCONFIGURE,
115 EC_MSG_TYPE_NAME_SYNC_TASK_AUTOCONFIGURE,
116 pAutoConfTaskSpec, NULL);
117 /*******************************************************/
120 engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_REQUEST,
121 EC_MSG_TYPE_NAME_SYNC_TASK_REQUEST,
122 pSyncTaskSpec, NULL);
124 /*engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_ADD_PROFILE,
125 EC_MSG_TYPE_NAME_SYNC_TASK_ADD_PROFILE,
126 pAddProfileTaskSpec, NULL);*/
128 /*engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_EDIT_PROFILE,
129 EC_MSG_TYPE_NAME_SYNC_TASK_EDIT_PROFILE,
130 pEditProfileTaskSpec, NULL);*/
132 engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_DELETE_PROFILE,
133 EC_MSG_TYPE_NAME_SYNC_TASK_DELETE_PROFILE,
134 pDeleteProfileTaskSpec, NULL);
137 /*engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_AUTO_CONFIGURE,
138 EC_MSG_TYPE_NAME_SYNC_TASK_AUTO_CONFIGURE,
139 pAutoConfTaskSpec, NULL);*/
141 engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_SYNCSTATUS,
142 EC_MSG_TYPE_NAME_SYNC_TASK_SYNCSTATUS,
143 pSyncStatusTaskSpec, NULL);
145 engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_GET_PROFILE_NAME,
146 EC_MSG_TYPE_NAME_SYNC_TASK_GET_PROFILE_NAME,
147 pGetProfileNameTaskSpec, NULL);
149 engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_GET_PROFILE_SERVER_INFO,
150 EC_MSG_TYPE_NAME_SYNC_TASK_GET_PROFILE_SERVER_INFO,
151 pGetProfileServerInfoTaskSpec, NULL);
153 engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_GET_PROFILE_SYNC_MODE,
154 EC_MSG_TYPE_NAME_SYNC_TASK_GET_PROFILE_SYNC_MODE,
155 pGetProfileSyncModeTaskSpec, NULL);
157 engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_GET_PROFILE_SYNC_CATEGORY,
158 EC_MSG_TYPE_NAME_SYNC_TASK_GET_PROFILE_SYNC_CATEGORY,
159 pGetProfileSyncCategoryTaskSpec, NULL);
161 engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_GET_PROFILE_LAST_SESSION,
162 EC_MSG_TYPE_NAME_SYNC_TASK_GET_PROFILE_LAST_SESSION,
163 pGetProfileLastSessionTaskSpec, NULL);
165 engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_GET_PROFILE_STATISTICS,
166 EC_MSG_TYPE_NAME_SYNC_TASK_GET_PROFILE_STATISTICS,
167 pGetProfileStatisticsTaskSpec, NULL);
169 engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_RESET_SYNCHRONIZING_PROFILES,
170 EC_MSG_TYPE_NAME_SYNC_TASK_RESET_SYNCHRONIZING_PROFILES,
171 pResetSynchronizingProfilesTaskSpec, NULL);
173 engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_ADD_PROFILE_CP,
174 EC_MSG_TYPE_NAME_SYNC_TASK_ADD_PROFILE_CP,
175 pAddProfileCPTaskSpec, NULL);
177 engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_REFRESH_FROM_SERVICE,
178 EC_MSG_TYPE_NAME_SYNC_TASK_REFRESH_FROM_SERVICE,
179 pRefreshFromServiceTaskSpec, NULL);
181 /*FIXME cancel request to NA */
182 /*engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_CANCEL_SYNC_REQUEST,
183 EC_MSG_TYPE_NAME_SYNC_TASK_CANCEL_SYNC_REQUEST,
184 pCancelSyncRequestTaskSpec, NULL);*/
186 queuing_rule_spec_t *pQueuing_rule = queuing_rule_spec_create_queuing_rule_spec_outline("sync_queueing_rule");
188 queuing_rule_spec_add_progress_blocking_element(pQueuing_rule, EC_MSG_TYPE_SYNC_TASK_REFRESH_FROM_SERVICE,
191 queuing_rule_spec_add_progress_blocking_element(pQueuing_rule, EC_MSG_TYPE_SYNC_TASK_REQUEST,
194 engine_controller_async_register_queuing_rule_spec(pQueuing_rule, NULL, NULL);
196 queuing_rule_spec_unref(pQueuing_rule);
198 __request_reset_synchronizing_profiles(); /*reset synchronizing flag 0 every account & construct item tbl*/
200 /*TODO have to be removed after removing vconf*/
201 error = set_EventCallback(1, event_callback_add_account);
202 if (error != EVENT_SUCCESS)
203 FW_LOGE("failed set_EventCallback()");
205 error = set_EventCallback(3, event_callback_edit_account);
206 if (error != EVENT_SUCCESS)
207 FW_LOGE("failed set_EventCallback()");
209 error = set_EventCallback(5, event_callback_auto_configure);
210 if (error != EVENT_SUCCESS)
211 FW_LOGE("failed set_EventCallback()");
212 /************************************************/
216 /*error = set_EventCallback(1, event_callback_add_profile_sync);
217 if (error != EVENT_SUCCESS)
218 FW_LOGE("failed set_EventCallback()");*/
220 error = set_EventCallback(2, event_callback_request_sync_async);
221 if (error != EVENT_SUCCESS)
222 FW_LOGE("failed set_EventCallback()");
224 /*error = set_EventCallback(3, event_callback_edit_profile_sync);
225 if (error != EVENT_SUCCESS)
226 FW_LOGE("failed set_EventCallback()");*/
228 error = set_EventCallback(4, event_callback_delete_profile_sync);
229 if (error != EVENT_SUCCESS)
230 FW_LOGE("failed set_EventCallback()");
232 /*error = set_EventCallback(5, event_callback_auto_configure_async);
233 if (error != EVENT_SUCCESS)
234 FW_LOGE("failed set_EventCallback()");*/
236 error = set_EventCallback(6, event_callback_cancel_sync_async);
237 if (error != EVENT_SUCCESS)
238 FW_LOGE("failed set_EventCallback()");
240 error = set_EventCallback(7, event_callback_query_sync_status_async);
241 if (error != EVENT_SUCCESS)
242 FW_LOGE("failed set_EventCallback()");
244 error = set_EventCallback(8, event_callback_get_profile_name_sync);
245 if (error != EVENT_SUCCESS)
246 FW_LOGE("failed set_EventCallback()");
248 error = set_EventCallback(9, event_callback_get_profile_server_info_sync);
249 if (error != EVENT_SUCCESS)
250 FW_LOGE("failed set_EventCallback()");
252 error = set_EventCallback(10, event_callback_get_profile_sync_mode_sync);
253 if (error != EVENT_SUCCESS)
254 FW_LOGE("failed set_EventCallback()");
256 error = set_EventCallback(11, event_callback_get_profile_sync_category_sync);
257 if (error != EVENT_SUCCESS)
258 FW_LOGE("failed set_EventCallback()");
260 error = set_EventCallback(12, event_callback_get_profile_last_session_sync);
261 if (error != EVENT_SUCCESS)
262 FW_LOGE("failed set_EventCallback()");
264 error = set_EventCallback(13, event_callback_get_profile_last_statistics_sync);
265 if (error != EVENT_SUCCESS)
266 FW_LOGE("failed set_EventCallback()");
268 error = set_EventCallback(14, event_callback_add_profile_cp_sync);
269 if (error != EVENT_SUCCESS)
270 FW_LOGE("failed set_EventCallback()");
272 PMCI_RETURN san_err = PMCI_Init_Specific_Type(DEFINE_PLATFORM, SAN, PKG_NAME, NULL, 1, SAN_callback_parse);
273 if (san_err != PMCI_SUCCESS)
274 FW_LOGE("failed in PMCI_Init_Specific_Type");
276 PMCI_RETURN scheduler_err = PMCI_Init_Specific_Type(DEFINE_PLATFORM, ALARM, PKG_NAME, NULL, 1, send_periodic_sync_msg);
277 if (scheduler_err != PMCI_SUCCESS)
278 FW_LOGE("failed in PMCI_Init_Specific_Type");
280 /*register profiles from csc*/
289 static void __request_reset_synchronizing_profiles()
292 unsigned int request_msg_id = 0;
293 engine_controller_async_request_task(EC_MSG_TYPE_SYNC_TASK_RESET_SYNCHRONIZING_PROFILES, 0,
294 0, NULL, NULL, NULL, NULL, NULL, (int *)&request_msg_id);
297 static void __check_csc()
303 /*FIXME(temporary do not process csc for ui reason)
304 check csc_check file is existed
305 if false do csc update
306 if true check csc xml file has been changed*/
308 /*exist = FSAPI_isExisting(OMA_DS_CSC_CHECK_PATH);*/
310 FW_LOGV("update = %d", exist);
318 static void __update_csc()
323 int numberOfProfiles = 0;
324 char *contents = "check";
326 bool result = get_vconf_Int_key(CSC_VCONF_KEY_SYNCMLDS_NBDATASYNC, &numberOfProfiles);
327 if (result == false) {
328 FW_LOGE("failed in get_vconf_Int_key");
333 for (i = 1; i <= numberOfProfiles; i++) {
334 sprintf(profile, "Sync%d", i);
338 FSAPI_fileWriteWhole(OMA_DS_CSC_CHECK_PATH, contents, sizeof(contents), false);