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.
27 * For any sort of issue you concern as to this software,
28 * you may use following point of contact.
29 * All resources contributed on this software
30 * are orinigally written by S-Core Inc., a member of Samsung Group.
32 * SeongWon Shim <seongwon.shim@samsung.com>
38 * @brief This file is the source file of implementation of main function
44 #include "agent-framework/Initialization/initialize.h"
45 #include "agent-framework/Utility/fw_log.h"
46 #include "agent-framework/PlatformMonitor/EXT_PMCI_Struct.h"
47 #include "agent-framework/PlatformMonitor/EXT_PMCI.h"
48 #include "agent-framework/FSAPI/FSAPI_operation.h"
49 #include "Framework/Event/OMA_DS_Platform_Event_Handler.h"
50 #include "Framework/Event/OMA_DS_Event_Handler.h"
51 #include "Framework/Task/OMA_DS_Engine_Controller_Task.h"
52 #include "Common/CscKeys.h"
53 #include "Common/Common_Define_Internal.h"
54 #include "Common/Common_Vconf.h"
55 #include "ServiceEngine/SE_Account.h"
57 #define LOG_TAG "OMA_DS_MAIN"
59 static void __request_reset_synchronizing_profiles();
60 static void __check_csc();
61 static void __update_csc();
67 EVENT_ERROR error = EVENT_SUCCESS;
69 INIT_ERROR init_error = Init_Framework("/opt/data/oma-ds/omads_fw_config.xml");
70 if (init_error != INIT_SUCCESS) {
71 FW_LOGE("Failed to Init_Framework() : %d", init_error);
73 FW_LOGV("done init_Framework");
76 /*TODO have to be removed after removing vconf*/
77 task_spec_t *pAddAccountTaskSpec = make_add_account_task();
78 task_spec_t *pEditAccountTaskSpec = make_edit_account_task();
79 /*task_spec_t *pDeleteAccountTaskSpec = make_delete_account_task();*/
80 task_spec_t *pAutoConfTaskSpec = make_autoconfigure_task();
83 task_spec_t *pSyncTaskSpec = make_synchronize_task();
84 /*task_spec_t *pAddProfileTaskSpec = make_add_profile_task();*/
85 /*task_spec_t *pEditProfileTaskSpec = make_edit_profile_task();*/
86 task_spec_t *pDeleteProfileTaskSpec = make_delete_profile_task();
87 /*task_spec_t *pAutoConfTaskSpec = make_auto_configure_task();*/
88 task_spec_t *pSyncStatusTaskSpec = make_sync_status_task();
89 task_spec_t *pGetProfileNameTaskSpec = make_get_profile_name_task();
90 task_spec_t *pGetProfileServerInfoTaskSpec = make_get_profile_server_info_task();
91 task_spec_t *pGetProfileSyncModeTaskSpec = make_get_profile_sync_mode_task();
92 task_spec_t *pGetProfileSyncCategoryTaskSpec = make_get_profile_sync_category_task();
93 task_spec_t *pGetProfileLastSessionTaskSpec = make_get_profile_last_session_task();
94 task_spec_t *pGetProfileStatisticsTaskSpec = make_get_profile_statistics_task();
95 task_spec_t *pResetSynchronizingProfilesTaskSpec = make_reset_synchronizing_profiles_task();
96 task_spec_t *pAddProfileCPTaskSpec = make_add_profile_cp_task();
97 task_spec_t *pRefreshFromServiceTaskSpec = make_refresh_from_service_task();
99 /*FIXME cancel request to NA */
100 /*task_spec_t *pCancelSyncRequestTaskSpec = make_cancel_sync_request();*/
104 /*TODO have to be removed after removing vconf*/
105 engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_ADD_ACCOUNT,
106 EC_MSG_TYPE_NAME_SYNC_TASK_ADD_ACCOUNT,
107 pAddAccountTaskSpec, NULL);
109 engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_EDIT_ACCOUNT,
110 EC_MSG_TYPE_NAME_SYNC_TASK_EDIT_ACCOUNT,
111 pEditAccountTaskSpec, NULL);
113 engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_AUTOCONFIGURE,
114 EC_MSG_TYPE_NAME_SYNC_TASK_AUTOCONFIGURE,
115 pAutoConfTaskSpec, NULL);
116 /*******************************************************/
119 engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_REQUEST,
120 EC_MSG_TYPE_NAME_SYNC_TASK_REQUEST,
121 pSyncTaskSpec, NULL);
123 /*engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_ADD_PROFILE,
124 EC_MSG_TYPE_NAME_SYNC_TASK_ADD_PROFILE,
125 pAddProfileTaskSpec, NULL);*/
127 /*engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_EDIT_PROFILE,
128 EC_MSG_TYPE_NAME_SYNC_TASK_EDIT_PROFILE,
129 pEditProfileTaskSpec, NULL);*/
131 engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_DELETE_PROFILE,
132 EC_MSG_TYPE_NAME_SYNC_TASK_DELETE_PROFILE,
133 pDeleteProfileTaskSpec, NULL);
136 /*engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_AUTO_CONFIGURE,
137 EC_MSG_TYPE_NAME_SYNC_TASK_AUTO_CONFIGURE,
138 pAutoConfTaskSpec, NULL);*/
140 engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_SYNCSTATUS,
141 EC_MSG_TYPE_NAME_SYNC_TASK_SYNCSTATUS,
142 pSyncStatusTaskSpec, NULL);
144 engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_GET_PROFILE_NAME,
145 EC_MSG_TYPE_NAME_SYNC_TASK_GET_PROFILE_NAME,
146 pGetProfileNameTaskSpec, NULL);
148 engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_GET_PROFILE_SERVER_INFO,
149 EC_MSG_TYPE_NAME_SYNC_TASK_GET_PROFILE_SERVER_INFO,
150 pGetProfileServerInfoTaskSpec, NULL);
152 engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_GET_PROFILE_SYNC_MODE,
153 EC_MSG_TYPE_NAME_SYNC_TASK_GET_PROFILE_SYNC_MODE,
154 pGetProfileSyncModeTaskSpec, NULL);
156 engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_GET_PROFILE_SYNC_CATEGORY,
157 EC_MSG_TYPE_NAME_SYNC_TASK_GET_PROFILE_SYNC_CATEGORY,
158 pGetProfileSyncCategoryTaskSpec, NULL);
160 engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_GET_PROFILE_LAST_SESSION,
161 EC_MSG_TYPE_NAME_SYNC_TASK_GET_PROFILE_LAST_SESSION,
162 pGetProfileLastSessionTaskSpec, NULL);
164 engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_GET_PROFILE_STATISTICS,
165 EC_MSG_TYPE_NAME_SYNC_TASK_GET_PROFILE_STATISTICS,
166 pGetProfileStatisticsTaskSpec, NULL);
168 engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_RESET_SYNCHRONIZING_PROFILES,
169 EC_MSG_TYPE_NAME_SYNC_TASK_RESET_SYNCHRONIZING_PROFILES,
170 pResetSynchronizingProfilesTaskSpec, NULL);
172 engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_ADD_PROFILE_CP,
173 EC_MSG_TYPE_NAME_SYNC_TASK_ADD_PROFILE_CP,
174 pAddProfileCPTaskSpec, NULL);
176 engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_REFRESH_FROM_SERVICE,
177 EC_MSG_TYPE_NAME_SYNC_TASK_REFRESH_FROM_SERVICE,
178 pRefreshFromServiceTaskSpec, NULL);
180 /*FIXME cancel request to NA */
181 /*engine_controller_register_task_spec(EC_MSG_TYPE_SYNC_TASK_CANCEL_SYNC_REQUEST,
182 EC_MSG_TYPE_NAME_SYNC_TASK_CANCEL_SYNC_REQUEST,
183 pCancelSyncRequestTaskSpec, NULL);*/
185 queuing_rule_spec_t *pQueuing_rule = queuing_rule_spec_create_queuing_rule_spec_outline("sync_queueing_rule");
187 queuing_rule_spec_add_progress_blocking_element(pQueuing_rule, EC_MSG_TYPE_SYNC_TASK_REFRESH_FROM_SERVICE,
190 queuing_rule_spec_add_progress_blocking_element(pQueuing_rule, EC_MSG_TYPE_SYNC_TASK_REQUEST,
193 engine_controller_async_register_queuing_rule_spec(pQueuing_rule, NULL, NULL);
195 queuing_rule_spec_unref(pQueuing_rule);
197 __request_reset_synchronizing_profiles(); /*reset synchronizing flag 0 every account & construct item tbl*/
199 /*TODO have to be removed after removing vconf*/
200 error = set_EventCallback(1, event_callback_add_account);
201 if (error != EVENT_SUCCESS)
202 FW_LOGE("failed set_EventCallback()");
204 error = set_EventCallback(3, event_callback_edit_account);
205 if (error != EVENT_SUCCESS)
206 FW_LOGE("failed set_EventCallback()");
208 error = set_EventCallback(5, event_callback_auto_configure);
209 if (error != EVENT_SUCCESS)
210 FW_LOGE("failed set_EventCallback()");
211 /************************************************/
215 /*error = set_EventCallback(1, event_callback_add_profile_sync);
216 if (error != EVENT_SUCCESS)
217 FW_LOGE("failed set_EventCallback()");*/
219 error = set_EventCallback(2, event_callback_request_sync_async);
220 if (error != EVENT_SUCCESS)
221 FW_LOGE("failed set_EventCallback()");
223 /*error = set_EventCallback(3, event_callback_edit_profile_sync);
224 if (error != EVENT_SUCCESS)
225 FW_LOGE("failed set_EventCallback()");*/
227 error = set_EventCallback(4, event_callback_delete_profile_sync);
228 if (error != EVENT_SUCCESS)
229 FW_LOGE("failed set_EventCallback()");
231 /*error = set_EventCallback(5, event_callback_auto_configure_async);
232 if (error != EVENT_SUCCESS)
233 FW_LOGE("failed set_EventCallback()");*/
235 error = set_EventCallback(6, event_callback_cancel_sync_async);
236 if (error != EVENT_SUCCESS)
237 FW_LOGE("failed set_EventCallback()");
239 error = set_EventCallback(7, event_callback_query_sync_status_async);
240 if (error != EVENT_SUCCESS)
241 FW_LOGE("failed set_EventCallback()");
243 error = set_EventCallback(8, event_callback_get_profile_name_sync);
244 if (error != EVENT_SUCCESS)
245 FW_LOGE("failed set_EventCallback()");
247 error = set_EventCallback(9, event_callback_get_profile_server_info_sync);
248 if (error != EVENT_SUCCESS)
249 FW_LOGE("failed set_EventCallback()");
251 error = set_EventCallback(10, event_callback_get_profile_sync_mode_sync);
252 if (error != EVENT_SUCCESS)
253 FW_LOGE("failed set_EventCallback()");
255 error = set_EventCallback(11, event_callback_get_profile_sync_category_sync);
256 if (error != EVENT_SUCCESS)
257 FW_LOGE("failed set_EventCallback()");
259 error = set_EventCallback(12, event_callback_get_profile_last_session_sync);
260 if (error != EVENT_SUCCESS)
261 FW_LOGE("failed set_EventCallback()");
263 error = set_EventCallback(13, event_callback_get_profile_last_statistics_sync);
264 if (error != EVENT_SUCCESS)
265 FW_LOGE("failed set_EventCallback()");
267 error = set_EventCallback(14, event_callback_add_profile_cp_sync);
268 if (error != EVENT_SUCCESS)
269 FW_LOGE("failed set_EventCallback()");
271 PMCI_RETURN san_err = PMCI_Init_Specific_Type(DEFINE_PLATFORM, SAN, PKG_NAME, NULL, 1, SAN_callback_parse);
272 if (san_err != PMCI_SUCCESS)
273 FW_LOGE("failed in PMCI_Init_Specific_Type");
275 PMCI_RETURN scheduler_err = PMCI_Init_Specific_Type(DEFINE_PLATFORM, ALARM, PKG_NAME, NULL, 1, send_periodic_sync_msg);
276 if (scheduler_err != PMCI_SUCCESS)
277 FW_LOGE("failed in PMCI_Init_Specific_Type");
279 /*register profiles from csc*/
288 static void __request_reset_synchronizing_profiles()
291 unsigned int request_msg_id = 0;
292 engine_controller_async_request_task(EC_MSG_TYPE_SYNC_TASK_RESET_SYNCHRONIZING_PROFILES, 0,
293 0, NULL, NULL, NULL, NULL, NULL, (int *)&request_msg_id);
296 static void __check_csc()
302 /*FIXME(temporary do not process csc for ui reason)
303 check csc_check file is existed
304 if false do csc update
305 if true check csc xml file has been changed*/
307 /*exist = FSAPI_isExisting(OMA_DS_CSC_CHECK_PATH);*/
309 FW_LOGV("update = %d", exist);
317 static void __update_csc()
322 int numberOfProfiles = 0;
323 char *contents = "check";
325 bool result = get_vconf_Int_key(CSC_VCONF_KEY_SYNCMLDS_NBDATASYNC, &numberOfProfiles);
326 if (result == false) {
327 FW_LOGE("failed in get_vconf_Int_key");
332 for (i = 1; i <= numberOfProfiles; i++) {
333 sprintf(profile, "Sync%d", i);
337 FSAPI_fileWriteWhole(OMA_DS_CSC_CHECK_PATH, contents, sizeof(contents), false);