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 auto configure in Service Engine
42 #include "agent-framework/Utility/fw_log.h"
43 #include "ServiceEngine/SE_AutoConfig.h"
44 #include "ServiceEngine/SE_Common.h"
45 #include "ServiceEngine/SE_Error.h"
46 #include "ServiceEngine/SE_Sync.h"
47 #include "ServiceEngine/SE_Notification.h"
48 #include "Common/Common_Vconf.h"
49 #include "Common/Common_Define.h"
50 #include "ServiceAdapter/SA_Common_Interface.h"
52 #define LOG_TAG "OMA_DS_SE"
54 bool autoconfigure_from_vconf(char *profile)
58 SE_ErrorType err = SE_INTERNAL_OK;
60 char profilePath[128];
62 char *password = NULL;
63 char *serverIP = NULL;
65 SyncProgress process = PROGRESS_NONE;
66 SyncError error = ERROR_NONE ;
69 FW_LOGE("Not Defined profile");
70 err = SE_INTERNAL_NOT_DEFINED;
74 sprintf(profilePath, "%s/%s", DS_SETTINGS_PATH, profile);
76 email = get_vconf_str(profilePath, DS_SETTING_CLIENT_AUTHNAME);
78 FW_LOGE("email is NULL");
79 err = SE_INTERNAL_DA_ERROR;
83 password = get_vconf_str(profilePath, DS_SETTING_CLIENT_AUTHPWD);
84 if (password == NULL) {
85 FW_LOGE("password is NULL");
86 err = SE_INTERNAL_DA_ERROR;
90 serverIP = get_vconf_str(profilePath, DS_SETTING_ADDR);
91 if (serverIP == NULL) {
92 FW_LOGE("serverIP is NULL");
93 err = SE_INTERNAL_DA_ERROR;
97 GList *configure = NULL;
98 Common_ErrorType common_err = auto_configure_from_vconf(email, password, serverIP, profilePath, &configure);
100 if (common_err != COMMON_CANCEL) {
102 convert_common_errorcode(common_err, &process, &error);
104 if (common_err == COMMON_OK) {
105 err = send_noti_auto_configure(profile, configure);
106 if (err != SE_INTERNAL_OK) {
107 FW_LOGE("failed in send_noti_auto_configure");
111 err = SE_INTERNAL_SA_ERROR;
113 err = session_process(profile, process, error);
114 if (err != SE_INTERNAL_OK) {
115 FW_LOGE("failed in send_noti_auto_configure");
119 err = SE_INTERNAL_CANCEL;
127 convert_engine_errorcode(err, &process, &error);
128 session_process(profile, process, error);
140 GList *inIter = NULL;
141 for (iter = configure; iter != NULL; iter = g_list_next(iter)) {
144 for (inIter = iter->data; inIter != NULL; inIter = g_list_next(inIter))
149 g_list_free(configure);
151 if (err != SE_INTERNAL_OK)
157 bool autoconfigure(char *profildDirName, char *addr, char *id, char *password)
161 SE_ErrorType err = SE_INTERNAL_OK;
163 SyncProgress process = PROGRESS_NONE;
164 SyncError error = ERROR_NONE ;
166 GList *configure = NULL;
168 GList *inIter = NULL;
170 Common_ErrorType common_err = auto_configure(addr, id, password, &configure);
172 if (common_err != COMMON_CANCEL) {
174 convert_common_errorcode(common_err, &process, &error);
176 if (common_err == COMMON_OK) {
177 err = send_noti_auto_configure(profildDirName, configure);
178 if (err != SE_INTERNAL_OK) {
179 FW_LOGE("failed in send_noti_auto_configure");
183 err = SE_INTERNAL_SA_ERROR;
185 err = session_process(profildDirName, process, error);
186 if (err != SE_INTERNAL_OK) {
187 FW_LOGE("failed in send_noti_auto_configure");
191 err = SE_INTERNAL_CANCEL;
199 convert_engine_errorcode(err, &process, &error);
200 session_process(profildDirName, process, error);
204 for (iter = configure; iter != NULL; iter = g_list_next(iter)) {
207 for (inIter = iter->data; inIter != NULL; inIter = g_list_next(inIter))
212 g_list_free(configure);
214 if (err != SE_INTERNAL_OK)