upload tizen1.0 source
[pkgs/o/oma-ds-service.git] / ServiceEngine / SE_Account.c
1 /*
2  * oma-ds-service
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: JuHak Park <juhaki.park@samsung.com>,
7  *          JuneHyuk Lee <junhyuk7.lee@samsung.com>,
8  *          SunBong Ha <sunbong.ha@samsung.com>
9  *
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
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
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.
21  *
22  */
23
24
25
26
27 /*
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.
32  *
33  * SeongWon Shim <seongwon.shim@samsung.com>
34  */
35
36 /**
37  *   @SE_Account.c
38  *   @version                                                                   0.1
39  *   @brief                                                                             This file is the source file of implementation of account in Service Engine
40  */
41
42 #include "Common/CscKeys.h"
43 #include "Common/Common_Vconf.h"
44 #include "Common/Common_Define.h"
45 #include "Common/Common_Util.h"
46 #include "ServiceEngine/SE_Account.h"
47 #include "ServiceEngine/SE_Error.h"
48 #include "ServiceEngine/SE_Common.h"
49 #include "agent-framework/Utility/fw_log.h"
50 #include "agent-framework/DACI/DACI_Agent_Handler_Manager.h"
51 #include "agent-framework/DACI/DACI_Luid.h"
52 #include "agent-framework/Account/Account_Mgr.h"
53 #include "agent-framework/PlatformMonitor/EXT_PMCI_Struct.h"
54 #include "agent-framework/PlatformMonitor/EXT_PMCI.h"
55 #include "agent-framework/Device/EXT_DCI_DevInfo.h"
56 #include "Framework/Event/OMA_DS_Platform_Event_Handler.h"
57
58 #define LOG_TAG "OMA_DS_SE"
59
60 #define MAX_DATASTORE_COUNT 3
61
62 typedef struct {
63         char *serverName;
64         int index;
65 } datastore_cp_info;
66
67
68 static char *predefinedDatastore[][MAX_DATASTORE_COUNT][2] = {
69                 { {"contacts", "text/x-vcard"}, {"calendar", "text/x-vcalendar"}, {"notes", "text/plain"} }
70 };
71
72 static datastore_cp_info predefinedServer[] = {
73                 {"O3SIS SyncML", 0}
74 };
75
76 /* TODO have to remove after removing vconf*/
77 static SE_ErrorType __set_datastore_config_from_vconf(int accountID, char *profilePath, int content_type);
78
79 static SE_ErrorType __set_datastore_config_from_csc(int accountID, int index, int content_type);
80 static SE_ErrorType __add_profile(char *addr,  char *id, char *password, char *access_name, int *accountID);
81 static SE_ErrorType __set_profile_info(int accountId, char *profileName, char *syncMode, char *syncType, char *interval);
82 static SE_ErrorType __set_profile_category(int accountId, int contentType, sync_category *category);
83 static SE_ErrorType __set_profile_category_cp(int accountId, int contentType, resource_cp *category);
84 static SE_ErrorType __set_periodic_sync_config(int account_id, char *syncMode, char *interval);
85 static SE_ErrorType __set_config_default_value(int accountID);
86 static SE_ErrorType __set_datastore_config_default_value(int accountID, int content_type);
87
88 /* TODO have to remove after removing vconf*/
89 static SE_ErrorType __set_datastore_config_from_vconf(int accountID, char *profilePath, int content_type)
90 {
91         FW_LOGV("start");
92
93         SE_ErrorType err = SE_INTERNAL_OK;
94
95         char *isEnabledPath = NULL;
96         char *targeturiPath = NULL;
97         char *sourceuriPath = NULL;
98         char *IDPath = NULL;
99         char *PWDPath = NULL;
100
101         char *datastore = NULL;
102         char datastore_target[128];
103         char datastore_source[128];
104         char datastore_id[128];
105         char datastore_pw[128];
106
107         int isEnabled = 0;
108         char *targeturi = NULL;
109         char *sourceuri = NULL;
110         char *ID = NULL;
111         char *PWD = NULL;
112
113         bool result;
114
115         if (content_type == TYPE_CONTACT) {
116                 datastore = DEFINE_CONFIG_KEY_PROFILE_CATEGORY_CONTACTS;
117                 isEnabledPath =  DS_SETTING_CONTACT_ENABLED;
118                 targeturiPath =  DS_SETTING_CONTACT_TGTURI;
119                 sourceuriPath = DS_SETTING_CONTACT_SRCURI;
120                 IDPath =   DS_SETTING_CONTACT_AUTHNAME;
121                 PWDPath =  DS_SETTING_CONTACT_AUTHPWD;
122         } else if (content_type == TYPE_CALENDAR) {
123                 datastore = DEFINE_CONFIG_KEY_PROFILE_CATEGORY_CALENDAR;
124                 isEnabledPath =  DS_SETTING_CALENDAR_ENABLED;
125                 targeturiPath =  DS_SETTING_CALENDAR_TGTURI;
126                 sourceuriPath =  DS_SETTING_CALENDAR_SRCURI;
127                 IDPath =   DS_SETTING_CALENDAR_AUTHNAME;
128                 PWDPath =   DS_SETTING_CALENDAR_AUTHPWD;
129         } else if (content_type == TYPE_MEMO) {
130                 datastore = DEFINE_CONFIG_KEY_PROFILE_CATEGORY_MEMO;
131                 isEnabledPath = DS_SETTING_MEMO_ENABLED;
132                 targeturiPath =  DS_SETTING_MEMO_TGTURI;
133                 sourceuriPath =  DS_SETTING_MEMO_SRCURI;
134                 IDPath =   DS_SETTING_MEMO_AUTHNAME;
135                 PWDPath =   DS_SETTING_MEMO_AUTHPWD;
136         }
137
138         result = get_vconf_int(profilePath, isEnabledPath, &isEnabled);
139         if (result == false) {
140                 FW_LOGE("failed in get_Vconf_int");
141                 err = SE_INTERNAL_DA_ERROR;
142                 goto error;
143          }
144
145         targeturi = get_vconf_str(profilePath, targeturiPath);
146         sourceuri = get_vconf_str(profilePath, sourceuriPath);
147         ID = get_vconf_str(profilePath, IDPath);
148         PWD = get_vconf_str(profilePath, PWDPath);
149
150         sprintf(datastore_target, "%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_CATEGORY_TARGET);
151         sprintf(datastore_source, "%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_CATEGORY_SOURCE);
152         sprintf(datastore_id, "%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_CATEGORY_ID);
153         sprintf(datastore_pw, "%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_CATEGORY_PASSWORD);
154
155         if (isEnabled) {
156                 result = set_config_str(accountID, datastore, "1", "string", "SE");
157                 if (result == false) {
158                         FW_LOGE("failed in set_config");
159                         err = SE_INTERNAL_DA_ERROR;
160                         goto error;
161                 }
162
163                 result = set_config_str(accountID, datastore_target, targeturi, "string", "SE");
164                 if (result == false) {
165                         FW_LOGE("failed in set_config");
166                         err = SE_INTERNAL_DA_ERROR;
167                         goto error;
168                 }
169
170                 result = set_config_str(accountID, datastore_id, ID, "string", "SE");
171                 if (result == false) {
172                         FW_LOGE("failed in set_config");
173                         err = SE_INTERNAL_DA_ERROR;
174                         goto error;
175                 }
176
177                 result = set_config_str(accountID, datastore_pw, PWD, "string", "SE");
178                 if (result == false) {
179                         FW_LOGE("failed in set_config");
180                         err = SE_INTERNAL_DA_ERROR;
181                         goto error;
182                 }
183
184         } else{
185                 result = set_config_str(accountID, datastore, "0", "string", "SE");
186                 if (result == false) {
187                         FW_LOGE("failed in set_config");
188                         err = SE_INTERNAL_DA_ERROR;
189                         goto error;
190                 }
191         }
192
193         result = set_config_str(accountID, datastore_source, sourceuri, "string", "SE");
194         if (result == false) {
195                 FW_LOGE("failed in set_config");
196                 err = SE_INTERNAL_DA_ERROR;
197                 goto error;
198         }
199
200         FW_LOGV("end");
201
202 error:
203
204         if (targeturi)
205                 free(targeturi);
206         if (sourceuri)
207                 free(sourceuri);
208         if (ID)
209                 free(ID);
210         if (PWD)
211                 free(PWD);
212
213         return err;
214 }
215
216
217 static SE_ErrorType __set_datastore_config_from_csc(int accountID, int index, int content_type)
218 {
219         FW_LOGV("start");
220
221         SE_ErrorType err = SE_INTERNAL_OK;
222
223         char *isEnabledPath = NULL;
224         char *targeturiPath = NULL;
225         char *IDPath = NULL;
226         char *PWDPath = NULL;
227
228         char *datastore = NULL;
229         char datastore_target[128];
230         char datastore_source[128];
231         char datastore_id[128];
232         char datastore_pw[128];
233
234         int isEnabled = 0;
235         char *targeturi = NULL;
236         char *ID = NULL;
237         char *PWD = NULL;
238         char profilePath[128];
239
240         char *sourceuri = NULL;
241
242         bool result;
243
244         if (content_type == TYPE_CONTACT) {
245                 datastore = DEFINE_CONFIG_KEY_PROFILE_CATEGORY_CONTACTS;
246                 sourceuri = DEFINE_SOURCE_CONTACT_URI;
247                 isEnabledPath =  CSC_VCONF_KEY_SYNCMLDS_CONTACTS_ENABLED;
248                 targeturiPath =  CSC_VCONF_KEY_SYNCMLDS_CONTACTS_TGTURI;
249                 IDPath =   CSC_VCONF_KEY_SYNCMLDS_CONTACTS_AUTHNAME;
250                 PWDPath =  CSC_VCONF_KEY_SYNCMLDS_CONTACTS_AUTHPWD;
251         } else if (content_type == TYPE_CALENDAR) {
252                 datastore = DEFINE_CONFIG_KEY_PROFILE_CATEGORY_CALENDAR;
253                 sourceuri = DEFINE_SOURCE_CALENDAR_URI;
254                 isEnabledPath =  CSC_VCONF_KEY_SYNCMLDS_CALENDAR_ENABLED;
255                 targeturiPath =  CSC_VCONF_KEY_SYNCMLDS_CALENDAR_TGTURI;
256                 IDPath =   CSC_VCONF_KEY_SYNCMLDS_CALENDAR_AUTHNAME;
257                 PWDPath =   CSC_VCONF_KEY_SYNCMLDS_CALENDAR_AUTHPWD;
258         } else if (content_type == TYPE_MEMO) {
259                 datastore = DEFINE_CONFIG_KEY_PROFILE_CATEGORY_MEMO;
260                 sourceuri = DEFINE_SOURCE_MEMO_URI;
261                 isEnabledPath = CSC_VCONF_KEY_SYNCMLDS_MEMO_ENABLED;
262                 targeturiPath =  CSC_VCONF_KEY_SYNCMLDS_MEMO_TGTURI;
263                 IDPath =   CSC_VCONF_KEY_SYNCMLDS_MEMO_AUTHNAME;
264                 PWDPath =   CSC_VCONF_KEY_SYNCMLDS_MEMO_AUTHPWD;
265         } else{
266                 err = SE_INTERNAL_ERROR;
267                 FW_LOGE("No content type");
268                 goto error;
269         }
270
271         sprintf(profilePath, isEnabledPath, index);
272         result = get_vconf_Int_key(profilePath, &isEnabled);
273         if (result == false) {
274                 FW_LOGE("No value in vconf key = %s", profilePath);
275                 goto error;
276         }
277
278         sprintf(profilePath, targeturiPath, index);
279         targeturi = get_vconf_str_key(profilePath);
280
281         sprintf(profilePath, IDPath, index);
282         ID = get_vconf_str_key(profilePath);
283
284         sprintf(profilePath, PWDPath, index);
285         PWD = get_vconf_str_key(profilePath);
286
287         sprintf(datastore_target, "%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_CATEGORY_TARGET);
288         sprintf(datastore_source, "%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_CATEGORY_SOURCE);
289         sprintf(datastore_id, "%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_CATEGORY_ID);
290         sprintf(datastore_pw, "%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_CATEGORY_PASSWORD);
291
292         if (isEnabled) {
293                 result = set_config_str(accountID, datastore, "1", "string", "SE");
294                 if (result == false) {
295                         FW_LOGE("failed in set_config");
296                         err = SE_INTERNAL_DA_ERROR;
297                         goto error;
298                 }
299                 result = set_config_str(accountID, datastore_target, targeturi, "string", "SE");
300                 if (result == false) {
301                         FW_LOGE("failed in set_config");
302                         err = SE_INTERNAL_DA_ERROR;
303                         goto error;
304                 }
305                 result = set_config_str(accountID, datastore_id, ID, "string", "SE");
306                 if (result == false) {
307                         FW_LOGE("failed in set_config");
308                         err = SE_INTERNAL_DA_ERROR;
309                         goto error;
310                 }
311                 result = set_config_str(accountID, datastore_pw, PWD, "string", "SE");
312                 if (result == false) {
313                         FW_LOGE("failed in set_config");
314                         err = SE_INTERNAL_DA_ERROR;
315                         goto error;
316                 }
317
318         } else{
319                 result = set_config_str(accountID, datastore, "0", "string", "SE");
320                 if (result == false) {
321                         FW_LOGE("failed in set_config");
322                         err = SE_INTERNAL_DA_ERROR;
323                         goto error;
324                 }
325         }
326         result = set_config_str(accountID, datastore_source, sourceuri, "string", "SE");
327         if (result == false) {
328                 FW_LOGE("failed in set_config");
329                 err = SE_INTERNAL_DA_ERROR;
330                 goto error;
331         }
332
333         FW_LOGV("end");
334
335 error:
336
337         if (targeturi)
338                 free(targeturi);
339         if (ID)
340                 free(ID);
341         if (PWD)
342                 free(PWD);
343
344         return err;
345 }
346
347 static SE_ErrorType __add_profile(char *addr,  char *id, char *password, char *access_name, int *accountID)
348 {
349         FW_LOGV("start");
350
351         SE_ErrorType err = SE_INTERNAL_OK;
352         int account = addAccount(id, password, addr, NULL, 0, 0, access_name);
353         char *folderID = NULL;
354
355         FW_LOGV("accountID = %d", account);
356
357         if (account < 0) {
358                 FW_LOGE("accountID = %d", account);
359                 err = SE_INTERNAL_ERROR;
360                 goto error;
361         }
362
363         folderID = DACI_Generate_Folder_Luid();
364         if (folderID == NULL) {
365                 FW_LOGE("failed in DACI_Generate_Folder_Luid");
366                 err = SE_INTERNAL_DA_ERROR;
367                 goto error;
368         }
369         daci_folder folder;
370         folder.account_id = account;
371         folder.folder_id = folderID;
372         folder.data_store_id = TYPE_CONTACT;
373         folder.folder_type_id = 0; /* Default contacts folder */
374         folder.parent_folder_id = 0;
375         folder.service_id = "0";
376         folder.access_name = "EventHandler";
377         DACI_RETURN ret = DACI_Add_Folder(&folder, 1);
378         if (ret != DACI_SUCCESS) {
379                 FW_LOGE("Agent Add_Folder Failed_In addAccount()!");
380                 FW_LOGE("[process_Event_Add_Account] Agent Add_Folder Failed_In addAccount()!");
381                 err = SE_INTERNAL_ERROR;
382                 goto error;
383         }
384
385         FW_LOGV("[process_Event_Add_Account] Successed Agent Add_Folder in addAccount(), added Folder ID : %s", folder.folder_id);
386
387         if (folderID != NULL) {
388                 free(folderID);
389                 folderID = NULL;
390         }
391
392         folderID = DACI_Generate_Folder_Luid();
393         if (folderID == NULL) {
394                 FW_LOGE("failed in DACI_Generate_Folder_Luid");
395                 err = SE_INTERNAL_DA_ERROR;
396                 goto error;
397         }
398         folder.account_id = account;
399         folder.folder_id = folderID;
400         folder.data_store_id = TYPE_CALENDAR;
401         folder.folder_type_id = 0; /* Default calendars folder */
402         folder.parent_folder_id = 0;
403         folder.service_id = "1";
404         folder.access_name = "EventHandler";
405         ret = DACI_Add_Folder(&folder, 1);
406         if (ret != DACI_SUCCESS) {
407                 FW_LOGE("Agent Add_Folder Failed_In addAccount()!");
408                 FW_LOGE("[process_Event_Add_Account] Agent Add_Folder Failed_In addAccount()!");
409                 err = SE_INTERNAL_ERROR;
410                 goto error;
411         }
412
413         FW_LOGV("[process_Event_Add_Account] Successed Agent Add_Folder in addAccount(), added Folder ID : %s", folder.folder_id);
414
415         if (folderID != NULL) {
416                 free(folderID);
417                 folderID = NULL;
418         }
419
420         /* TODO : add default memo folder (Hard cording) */
421         folderID = DACI_Generate_Folder_Luid();
422         if (folderID == NULL) {
423                 FW_LOGE("failed in DACI_Generate_Folder_Luid");
424                 err = SE_INTERNAL_DA_ERROR;
425                 goto error;
426         }
427         folder.account_id = account;
428         folder.folder_id = folderID;
429         folder.data_store_id = TYPE_MEMO;
430         folder.folder_type_id = 0; /* Default notes folder */
431         folder.parent_folder_id = 0;
432         folder.service_id = "0";
433         folder.access_name = "EventHandler";
434         ret = DACI_Add_Folder(&folder, 1);
435         if (ret != DACI_SUCCESS) {
436                 FW_LOGE("Agent Add_Folder Failed_In addAccount()!");
437                 FW_LOGE("[process_Event_Add_Account] Agent Add_Folder Failed_In addAccount()!");
438                 err = SE_INTERNAL_ERROR;
439                 goto error;
440         }
441
442         FW_LOGV("[process_Event_Add_Account] Successed Agent Add_Folder in addAccount(), added Folder ID : %s", folder.folder_id);
443
444         if (folderID != NULL) {
445                 free(folderID);
446                 folderID = NULL;
447         }
448
449         /* call log folder ID */
450         folderID = DACI_Generate_Folder_Luid();
451         if (folderID == NULL) {
452                 FW_LOGE("failed in DACI_Generate_Folder_Luid");
453                 err = SE_INTERNAL_DA_ERROR;
454                 goto error;
455         }
456
457         folder.account_id = account;
458         folder.folder_id = folderID;
459         folder.data_store_id = TYPE_CALLLOG;
460         folder.folder_type_id = 0; /* Default call log folder */
461         folder.parent_folder_id = 0;
462         folder.service_id = "0";
463         folder.access_name = "EventHandler";
464         ret = DACI_Add_Folder(&folder, 1);
465         if (ret != DACI_SUCCESS) {
466                 FW_LOGE("Agent Add_Folder Failed_In addAccount()!");
467                 FW_LOGE("[process_Event_Add_Account] Agent Add_Folder Failed_In addAccount()!");
468                 err = SE_INTERNAL_ERROR;
469                 goto error;
470         }
471
472         FW_LOGV("[process_Event_Add_Account] Successed Agent Add_Folder in addAccount(), added Folder ID : %s", folder.folder_id);
473
474         if (folderID != NULL) {
475                 free(folderID);
476                 folderID = NULL;
477         }
478
479         *accountID = account;
480
481         FW_LOGV("end");
482
483 error:
484
485         if (folderID != NULL)
486                 free(folderID);
487
488         return err;
489 }
490
491
492 static SE_ErrorType __set_profile_info(int accountId, char *profileName, char *syncMode, char *syncType, char *interval)
493 {
494         FW_LOGV("start");
495
496         SE_ErrorType err = SE_INTERNAL_OK;
497         bool result;
498
499         result = set_config_str(accountId, DEFINE_CONFIG_KEY_PROFILE_NAME, profileName, "string", "SE");
500         if (result == false) {
501                 FW_LOGE("failed in set_config");
502                 err = SE_INTERNAL_DA_ERROR;
503                 goto error;
504         }
505
506         result = set_config_str(accountId, DEFINE_CONFIG_KEY_PROFILE_SYNC_MODE, syncMode, "string", "SE");
507         if (result == false) {
508                 FW_LOGE("failed in set_config");
509                 err = SE_INTERNAL_DA_ERROR;
510                 goto error;
511         }
512
513         result = set_config_str(accountId, DEFINE_CONFIG_KEY_PROFILE_SYNC_TYPE , syncType, "string", "SE");
514         if (result == false) {
515                 FW_LOGE("failed in set_config");
516                 err = SE_INTERNAL_DA_ERROR;
517                 goto error;
518         }
519
520         result = set_config_str(accountId, DEFINE_CONFIG_KEY_PROFILE_SYNC_INTERVAL, interval, "string", "SE");
521         if (result == false) {
522                 FW_LOGE("failed in set_config");
523                 err = SE_INTERNAL_DA_ERROR;
524                 goto error;
525         }
526
527         FW_LOGV("end");
528
529 error:
530
531         return err;
532 }
533
534
535 static SE_ErrorType __set_profile_category(int accountId, int contentType, sync_category *category)
536 {
537         FW_LOGV("start");
538
539         FW_LOGV("category->enabled : %d", category->enabled);
540         FW_LOGV("category->srcURI : %s", category->srcURI);
541         FW_LOGV("category->tgtURI : %s", category->tgtURI);
542         FW_LOGV("category->id : %s", category->id);
543         FW_LOGV("category->password : %s", category->password);
544
545         SE_ErrorType err = SE_INTERNAL_OK;
546         bool result;
547
548         char *datastore = NULL;
549         char datastore_target[128];
550         char datastore_source[128];
551         char datastore_id[128];
552         char datastore_pw[128];
553
554         if (contentType == TYPE_CONTACT)
555                 datastore = DEFINE_CONFIG_KEY_PROFILE_CATEGORY_CONTACTS;
556         else if (contentType == TYPE_CALENDAR)
557                 datastore = DEFINE_CONFIG_KEY_PROFILE_CATEGORY_CALENDAR;
558         else if (contentType == TYPE_MEMO)
559                 datastore = DEFINE_CONFIG_KEY_PROFILE_CATEGORY_MEMO;
560         else if (contentType == TYPE_CALLLOG)
561                 datastore = DEFINE_CONFIG_KEY_PROFILE_CATEGORY_CALLLOG;
562
563         sprintf(datastore_target, "%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_CATEGORY_TARGET);
564         sprintf(datastore_source, "%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_CATEGORY_SOURCE);
565         sprintf(datastore_id, "%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_CATEGORY_ID);
566         sprintf(datastore_pw, "%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_CATEGORY_PASSWORD);
567
568
569         result = set_config_int(accountId, datastore, category->enabled, "int", "SE");
570         if (result == false) {
571                 FW_LOGE("failed in set_config");
572                 err = SE_INTERNAL_DA_ERROR;
573                 goto error;
574         }
575
576         result = set_config_str(accountId, datastore_source, category->srcURI, "string", "SE");
577         if (result == false) {
578                 FW_LOGE("failed in set_config");
579                 err = SE_INTERNAL_DA_ERROR;
580                 goto error;
581         }
582
583         result = set_config_str(accountId, datastore_target, category->tgtURI, "string", "SE");
584         if (result == false) {
585                 FW_LOGE("failed in set_config");
586                 err = SE_INTERNAL_DA_ERROR;
587                 goto error;
588         }
589
590         result = set_config_str(accountId, datastore_id, category->id, "string", "SE");
591         if (result == false) {
592                 FW_LOGE("failed in set_config");
593                 err = SE_INTERNAL_DA_ERROR;
594                 goto error;
595         }
596
597         result = set_config_str(accountId, datastore_pw, category->password, "string", "SE");
598         if (result == false) {
599                 FW_LOGE("failed in set_config");
600                 err = SE_INTERNAL_DA_ERROR;
601                 goto error;
602         }
603
604         FW_LOGV("end");
605
606 error:
607         return err;
608
609 }
610
611 static SE_ErrorType __set_profile_category_cp(int accountId, int contentType, resource_cp *category)
612 {
613         FW_LOGV("start");
614
615         FW_LOGV("category->srcURI : %s", category->name);
616         FW_LOGV("category->id : %s", category->id);
617         FW_LOGV("category->password : %s", category->password);
618         FW_LOGV("category->authType : %s", category->authType);
619         FW_LOGV("category->authData : %s", category->authData);
620         FW_LOGV("category->tgtURI : %s", category->accept);
621
622         SE_ErrorType err = SE_INTERNAL_OK;
623         bool result;
624
625         char *datastore = NULL;
626         char datastore_target[128];
627         char datastore_id[128];
628         char datastore_pw[128];
629
630         if (contentType == TYPE_CONTACT)
631                 datastore = DEFINE_CONFIG_KEY_PROFILE_CATEGORY_CONTACTS;
632         else if (contentType == TYPE_CALENDAR)
633                 datastore = DEFINE_CONFIG_KEY_PROFILE_CATEGORY_CALENDAR;
634         else if (contentType == TYPE_MEMO)
635                 datastore = DEFINE_CONFIG_KEY_PROFILE_CATEGORY_MEMO;
636
637         sprintf(datastore_target, "%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_CATEGORY_TARGET);
638         sprintf(datastore_id, "%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_CATEGORY_ID);
639         sprintf(datastore_pw, "%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_CATEGORY_PASSWORD);
640
641         result = set_config_str(accountId, datastore_target, category->name, "string", "SE");
642         if (result == false) {
643                 FW_LOGE("failed in set_config");
644                 err = SE_INTERNAL_DA_ERROR;
645                 goto error;
646         }
647
648         result = set_config_str(accountId, datastore_id, category->id, "string", "SE");
649         if (result == false) {
650                 FW_LOGE("failed in set_config");
651                 err = SE_INTERNAL_DA_ERROR;
652                 goto error;
653         }
654
655         result = set_config_str(accountId, datastore_pw, category->password, "string", "SE");
656         if (result == false) {
657                 FW_LOGE("failed in set_config");
658                 err = SE_INTERNAL_DA_ERROR;
659                 goto error;
660         }
661
662         FW_LOGV("end");
663
664 error:
665         return err;
666
667 }
668
669 static SE_ErrorType __set_periodic_sync_config(int account_id, char *syncMode, char *interval)
670 {
671         FW_LOGV("start");
672         FW_LOGV("syncMode = %s", syncMode);
673
674         SE_ErrorType err = SE_INTERNAL_OK;
675         PMCI_RETURN scheduler_err;
676         bool result;
677         char *value = NULL;
678         int alarm_id = 0;
679
680         pmci_alarm_t *alarm_info = (pmci_alarm_t *)calloc(1, sizeof(pmci_alarm_t));
681
682         result = get_config(account_id, DEFINE_CONFIG_KEY_PROFILE_ALARM_ID, &value);
683         if (result == false) {
684                 FW_LOGE("failed in set_config");
685                 err = SE_INTERNAL_DA_ERROR;
686                 goto error;
687         }
688
689         alarm_id = atoi(value);
690
691         if (alarm_id != 0) {
692                 scheduler_err = PMCI_Remove_Item_To_Specific_Type(DEFINE_PLATFORM, ALARM, alarm_id);
693                 if (scheduler_err != PMCI_SUCCESS) {
694                         FW_LOGE("failed in PMCI_Remove_Item_To_Specific_Type");
695                         err = SE_INTERNAL_SCHEDULER_ERROR;
696                         goto error;
697                 }
698         }
699
700         if (strcmp(syncMode , DEFINE_SYNC_MODE_PERIODIC) == 0 && interval != NULL) {
701
702                 result = set_config_str(account_id, DEFINE_CONFIG_KEY_PROFILE_SYNC_TYPE , DEFINE_ALERT_TWO_WAY_STR, "string", "SE");
703                 if (result == false) {
704                         FW_LOGE("failed in set_config");
705                         err = SE_INTERNAL_DA_ERROR;
706                         goto error;
707                 }
708
709                  int week[] = {DAY_SUN, DAY_MON, DAY_TUE, DAY_WED, DAY_THU, DAY_FRI, DAY_SAT};
710                  time_t current_time;
711                  struct tm *struct_time;
712                  time(&current_time);
713                  struct_time = localtime(&current_time);
714                  if (struct_time == NULL) {
715                          FW_LOGE("struct_time is NULL");
716                          err = SE_INTERNAL_ERROR;;
717                         goto error;
718                  }
719
720                  alarm_info->start_alarm_time = g_strdup_printf("%.2d-%.2d-%.2dT%.2d:%.2d:%.2dZ",
721                     struct_time->tm_year+1900,
722                     struct_time->tm_mon+1,
723                     struct_time->tm_mday,
724                     struct_time->tm_hour,
725                     struct_time->tm_min,
726                     struct_time->tm_sec);
727                  alarm_info->isDisposable = 0;
728
729                 if (strcmp(interval, "5 minutes") == 0) {
730                         FW_LOGV("5 minutes");
731                         alarm_info->repeat_type = REPEAT;
732                         alarm_info->repeat_value = 5*60;
733                 } else if (strcmp(interval, "15 minutes") == 0) {
734                         FW_LOGV("15 minutes");
735                         alarm_info->repeat_type = REPEAT;
736                         alarm_info->repeat_value = 15*60;
737                 } else if (strcmp(interval, "1 hour") == 0) {
738                         FW_LOGV("1 hour");
739                         alarm_info->repeat_type = REPEAT;
740                         alarm_info->repeat_value = ((1*60)*60);
741                 } else if (strcmp(interval, "4 hours") == 0) {
742                         FW_LOGV("4 hours");
743                         alarm_info->repeat_type = REPEAT;
744                         alarm_info->repeat_value = ((4*60)*60);
745                 } else if (strcmp(interval, "12 hours") == 0) {
746                         FW_LOGV("12 hours");
747                         alarm_info->repeat_type = REPEAT;
748                         alarm_info->repeat_value = ((12*60)*60);
749                 } else if (strcmp(interval, "1 day") == 0) {
750                         FW_LOGV("1 day");
751                         alarm_info->repeat_type = REPEAT;
752                         alarm_info->repeat_value = ((24*60)*60);
753                 } else if (strcmp(interval, "1 week") == 0) {
754                         FW_LOGV("1 week");
755                         alarm_info->repeat_type = REPEAT_WEEKLY;
756                         alarm_info->repeat_value = week[struct_time->tm_wday];
757                 }
758
759                 scheduler_err = PMCI_Add_Item_To_Specific_Type(DEFINE_PLATFORM, ALARM, alarm_info, &alarm_id);
760                 if (scheduler_err != PMCI_SUCCESS) {
761                         FW_LOGE("failed in PMCI_Add_Item_To_Specific_Type");
762                         err = SE_INTERNAL_SCHEDULER_ERROR;
763                         goto error;
764                 }
765                 FW_LOGV("alarm_id =%d", alarm_id);
766
767                 result = set_config_int(account_id, DEFINE_CONFIG_KEY_PROFILE_ALARM_ID, alarm_id, "int", "SE");
768                 if (result == false) {
769                         FW_LOGE("failed in set_config");
770                         err = SE_INTERNAL_DA_ERROR;
771                         goto error;
772                 }
773
774         } else{
775                 result = set_config_str(account_id, DEFINE_CONFIG_KEY_PROFILE_ALARM_ID, "0", "int", "SE");
776                 if (result == false) {
777                         FW_LOGE("failed in set_config");
778                         err = SE_INTERNAL_DA_ERROR;
779                         goto error;
780                 }
781         }
782
783         FW_LOGV("end");
784
785 error:
786
787         if (value != NULL)
788                 free(value);
789
790         if (alarm_info != NULL) {
791                 if (alarm_info->start_alarm_time != NULL)
792                         free(alarm_info->start_alarm_time);
793
794                 free(alarm_info);
795         }
796
797         return err;
798 }
799
800
801 static SE_ErrorType __set_config_default_value(int accountID)
802 {
803         FW_LOGV("start");
804         SE_ErrorType  err = SE_INTERNAL_OK;
805
806         bool result;
807
808         result = set_config_str(accountID, DEFINE_CONFIG_KEY_PROFILE_DIR_NAME, NULL, "string", "SE");
809         if (result == false) {
810                 FW_LOGE("failed in set_config");
811                 err = SE_INTERNAL_DA_ERROR;
812                 goto error;
813         }
814
815         result = set_config_str(accountID, DEFINE_CONFIG_KEY_PROFILE_NAME, NULL, "string", "SE");
816         if (result == false) {
817                 FW_LOGE("failed in set_config");
818                 err = SE_INTERNAL_DA_ERROR;
819                 goto error;
820         }
821
822         result = set_config_str(accountID, DEFINE_CONFIG_KEY_PROFILE_SERVER_IP, NULL, "string", "SE");
823         if (result == false) {
824                 FW_LOGE("failed in set_config");
825                 err = SE_INTERNAL_DA_ERROR;
826                 goto error;
827         }
828
829         result = set_config_str(accountID, DEFINE_CONFIG_KEY_PROFILE_SYNC_MODE, "Push", "string", "SE");
830         if (result == false) {
831                 FW_LOGE("failed in set_config");
832                 err = SE_INTERNAL_DA_ERROR;
833                 goto error;
834         }
835
836         result = set_config_str(accountID, DEFINE_CONFIG_KEY_PROFILE_SYNC_TYPE , "Full", "string", "SE");
837         if (result == false) {
838                 FW_LOGE("failed in set_config");
839                 err = SE_INTERNAL_DA_ERROR;
840                 goto error;
841         }
842
843         result = set_config_str(accountID, DEFINE_CONFIG_KEY_PROFILE_SYNC_INTERVAL, "5 minutes", "string", "SE");
844         if (result == false) {
845                 FW_LOGE("failed in set_config");
846                 err = SE_INTERNAL_DA_ERROR;
847                 goto error;
848         }
849
850         result = set_config_str(accountID, DEFINE_CONFIG_KEY_PROFILE_NEXT_NONCE, NULL, "string", "SE");
851         if (result == false) {
852                 FW_LOGE("failed in set_config");
853                 err = SE_INTERNAL_DA_ERROR;
854                 goto error;
855         }
856
857         result = set_config_str(accountID, DEFINE_CONFIG_KEY_PROFILE_SERVER_ID, NULL, "string", "SE");
858         if (result == false) {
859                 FW_LOGE("failed in set_config");
860                 err = SE_INTERNAL_DA_ERROR;
861                 goto error;
862         }
863
864         result = set_config_str(accountID, DEFINE_CONFIG_KEY_PROFILE_LAST_SESSION_STATUS, "-1", "int", "SE");
865         if (result == false) {
866                 FW_LOGE("failed in set_config");
867                 err = SE_INTERNAL_DA_ERROR;
868                 goto error;
869         }
870
871         result = set_config_str(accountID, DEFINE_CONFIG_KEY_PROFILE_LAST_SESSION_TIME, "-1", "int", "SE");
872         if (result == false) {
873                 FW_LOGE("failed in set_config");
874                 err = SE_INTERNAL_DA_ERROR;
875                 goto error;
876         }
877
878         result = set_config_str(accountID, DEFINE_CONFIG_KEY_PROFILE_ALARM_ID, "0", "int", "SE");
879         if (result == false) {
880                 FW_LOGE("failed in set_config");
881                 err = SE_INTERNAL_DA_ERROR;
882                 goto error;
883         }
884
885
886         int content_type;
887         for (content_type = 0; content_type < TYPE_CONTENT_COUNT; content_type++) {
888                 err = __set_datastore_config_default_value(accountID, content_type);
889                 if (err  != SE_INTERNAL_OK) {
890                         FW_LOGE("failed in set_DatastoreConfig");
891                         goto error;
892                 }
893         }
894
895         FW_LOGV("end");
896 error:
897
898         return err;
899 }
900
901 static SE_ErrorType __set_datastore_config_default_value(int accountID, int contentType)
902 {
903         FW_LOGV("start");
904         SE_ErrorType  err = SE_INTERNAL_OK;
905
906         bool result;
907
908         char *datastore = NULL;
909         char datastore_target[128];
910         char datastore_source[128];
911         char datastore_id[128];
912         char datastore_pw[128];
913
914         char datastore_dbSynced[128];
915         char datastore_lastSessionTime[128];
916         char datastore_s2c_Total[128];
917         char datastore_s2c_NrOfAdd[128];
918         char datastore_s2c_NrOfDelete[128];
919         char datastore_s2c_NrOfReplace[128];
920         char datastore_c2s_Total[128];
921         char datastore_c2s_NrOfAdd[128];
922         char datastore_c2s_NrOfDelete[128];
923         char datastore_c2s_NrOfReplace[128];
924
925         if (contentType == TYPE_CONTACT)
926                 datastore = DEFINE_CONFIG_KEY_PROFILE_CATEGORY_CONTACTS;
927         else if (contentType == TYPE_CALENDAR)
928                 datastore = DEFINE_CONFIG_KEY_PROFILE_CATEGORY_CALENDAR;
929         else if (contentType == TYPE_MEMO)
930                 datastore = DEFINE_CONFIG_KEY_PROFILE_CATEGORY_MEMO;
931         else if(contentType == TYPE_CALLLOG)
932                 datastore = DEFINE_CONFIG_KEY_PROFILE_CATEGORY_CALLLOG;
933
934         sprintf(datastore_target, "%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_CATEGORY_TARGET);
935         sprintf(datastore_source, "%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_CATEGORY_SOURCE);
936         sprintf(datastore_id, "%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_CATEGORY_ID);
937         sprintf(datastore_pw, "%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_CATEGORY_PASSWORD);
938
939         sprintf(datastore_dbSynced, "%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_DBSYNCED);
940         sprintf(datastore_lastSessionTime, "%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_LAST_TIME);
941
942         sprintf(datastore_s2c_Total, "%s_%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_SERVER, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_TOTAL);
943         sprintf(datastore_s2c_NrOfAdd, "%s_%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_SERVER, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_NROFADD);
944         sprintf(datastore_s2c_NrOfDelete, "%s_%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_SERVER, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_NROFDELETE);
945         sprintf(datastore_s2c_NrOfReplace, "%s_%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_SERVER, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_NROFREPLACE);
946
947         sprintf(datastore_c2s_Total, "%s_%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_CLIENT, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_TOTAL);
948         sprintf(datastore_c2s_NrOfAdd, "%s_%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_CLIENT, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_NROFADD);
949         sprintf(datastore_c2s_NrOfDelete, "%s_%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_CLIENT, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_NROFDELETE);
950         sprintf(datastore_c2s_NrOfReplace, "%s_%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_CLIENT, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_NROFREPLACE);
951
952
953         result = set_config_str(accountID, datastore, "0", "int", "SE");
954         if (result == false) {
955                 FW_LOGE("failed in set_config");
956                 err = SE_INTERNAL_DA_ERROR;
957                 goto error;
958         }
959
960         result = set_config_str(accountID, datastore_source, datastore, "string", "SE");
961         if (result == false) {
962                 FW_LOGE("failed in set_config");
963                 err = SE_INTERNAL_DA_ERROR;
964                 goto error;
965         }
966
967         result = set_config_str(accountID, datastore_target, NULL, "string", "SE");
968         if (result == false) {
969                 FW_LOGE("failed in set_config");
970                 err = SE_INTERNAL_DA_ERROR;
971                 goto error;
972         }
973
974         result = set_config_str(accountID, datastore_id, NULL, "string", "SE");
975         if (result == false) {
976                 FW_LOGE("failed in set_config");
977                 err = SE_INTERNAL_DA_ERROR;
978                 goto error;
979         }
980
981         result = set_config_str(accountID, datastore_pw, NULL, "string", "SE");
982         if (result == false) {
983                 FW_LOGE("failed in set_config");
984                 err = SE_INTERNAL_DA_ERROR;
985                 goto error;
986         }
987
988         result = set_config_str(accountID, datastore_dbSynced, DEFINE_DBSYNC_NO, "string", "SE");
989         if (result == false) {
990                 FW_LOGE("failed in set_config");
991                 err = SE_INTERNAL_DA_ERROR;
992                 goto error;
993         }
994
995         result = set_config_str(accountID, datastore_lastSessionTime, "-1", "int", "SE");
996         if (result == false) {
997                 FW_LOGE("failed in set_config");
998                 err = SE_INTERNAL_DA_ERROR;
999                 goto error;
1000         }
1001
1002         result = set_config_int(accountID, datastore_s2c_Total, 0, "int", "SE");
1003         if (result == false) {
1004                 FW_LOGE("failed in set_config");
1005                 err = SE_INTERNAL_DA_ERROR;
1006                 goto error;
1007         }
1008
1009         result = set_config_int(accountID, datastore_s2c_NrOfAdd, 0, "int", "SE");
1010         if (result == false) {
1011                 FW_LOGE("failed in set_config");
1012                 err = SE_INTERNAL_DA_ERROR;
1013                 goto error;
1014         }
1015
1016         result = set_config_int(accountID, datastore_s2c_NrOfDelete, 0, "int", "SE");
1017         if (result == false) {
1018                 FW_LOGE("failed in set_config");
1019                 err = SE_INTERNAL_DA_ERROR;
1020                 goto error;
1021         }
1022
1023         result = set_config_int(accountID, datastore_s2c_NrOfReplace, 0, "int", "SE");
1024         if (result == false) {
1025                 FW_LOGE("failed in set_config");
1026                 err = SE_INTERNAL_DA_ERROR;
1027                 goto error;
1028         }
1029
1030         result = set_config_int(accountID, datastore_c2s_Total, 0, "int", "SE");
1031         if (result == false) {
1032                 FW_LOGE("failed in set_config");
1033                 err = SE_INTERNAL_DA_ERROR;
1034                 goto error;
1035         }
1036
1037         result = set_config_int(accountID, datastore_c2s_NrOfAdd, 0, "int", "SE");
1038         if (result == false) {
1039                 FW_LOGE("failed in set_config");
1040                 err = SE_INTERNAL_DA_ERROR;
1041                 goto error;
1042         }
1043
1044         result = set_config_int(accountID, datastore_c2s_NrOfDelete, 0, "int", "SE");
1045         if (result == false) {
1046                 FW_LOGE("failed in set_config");
1047                 err = SE_INTERNAL_DA_ERROR;
1048                 goto error;
1049         }
1050
1051         result = set_config_int(accountID, datastore_c2s_NrOfReplace, 0, "int", "SE");
1052         if (result == false) {
1053                 FW_LOGE("failed in set_config");
1054                 err = SE_INTERNAL_DA_ERROR;
1055                 goto error;
1056         }
1057         FW_LOGV("end");
1058
1059 error:
1060         return err;
1061 }
1062
1063 /*TODO have to be removed after removing vconf*/
1064 int update_all_config(char *profile,  bool isAdd, int *accountId)
1065 {
1066         FW_LOGV("profile = %s", profile);
1067
1068         SE_ErrorType  err = SE_INTERNAL_OK;
1069         char profilePath[128];
1070         char *profileName = NULL;
1071         char *email = NULL;
1072         char *password = NULL;
1073         char *serverIP = NULL;
1074         char *syncMode = NULL;
1075         char *syncType = NULL;
1076         char *interval = NULL;
1077         bool result;
1078
1079         if (profile == NULL) {
1080                 FW_LOGE("profile is NULL");
1081                 err = SE_INTERNAL_NOT_DEFINED;
1082                 goto error;
1083         }
1084
1085         DACI_RETURN da_err = DACI_Open_Agent();
1086         if (da_err != DACI_SUCCESS) {
1087                 err = SE_INTERNAL_DA_ERROR;
1088                 goto error;
1089         }
1090
1091         sprintf(profilePath, "%s/%s", DS_SETTINGS_PATH, profile);
1092
1093         email = get_vconf_str(profilePath, DS_SETTING_CLIENT_AUTHNAME);
1094         password = get_vconf_str(profilePath, DS_SETTING_CLIENT_AUTHPWD);
1095         serverIP = get_vconf_str(profilePath, DS_SETTING_ADDR);
1096
1097         FW_LOGV("email = %s", email);
1098         FW_LOGV("password = %s", password);
1099         FW_LOGV("serverIP = %s", serverIP);
1100
1101         int accountID;
1102         if (isAdd == true) {
1103                 err = __add_profile(serverIP, email, password , "UI", &accountID);
1104                 if (err  != SE_INTERNAL_OK) {
1105                         FW_LOGE("failed in add_Account");
1106                         goto error;
1107                 }
1108
1109                 err = __set_config_default_value(accountID);
1110                 if (err  != SE_INTERNAL_OK) {
1111                         FW_LOGE("failed in add_Account");
1112                         goto error;
1113                 }
1114
1115                 result = set_config_str(accountID, DEFINE_CONFIG_KEY_PROFILE_DIR_NAME, profile, "string", "SE");
1116                 if (result == false) {
1117                         FW_LOGE("failed in set_config");
1118                         err = SE_INTERNAL_DA_ERROR;
1119                         goto error;
1120                 }
1121
1122         } else{
1123                 accountID = get_accountid(profile, true);
1124
1125                 FW_LOGV("accountID = %d", accountID);
1126
1127                 da_err = DACI_Set_Account_Email_Address(accountID, email, "SE");
1128                 if (da_err != DACI_SUCCESS) {
1129                         FW_LOGE("failed in DACI_Set_Account_Email_Address = %d", da_err);
1130                         err = SE_INTERNAL_ERROR;
1131                         goto error;
1132                 }
1133
1134                 da_err = DACI_Set_Account_Password(accountID, password, "SE");
1135                 if (da_err != DACI_SUCCESS) {
1136                         FW_LOGE("failed in DACI_Set_Account_Email_Address = %d", da_err);
1137                         err = SE_INTERNAL_ERROR;
1138                         goto error;
1139                 }
1140         }
1141
1142         profileName = get_vconf_str(profilePath, DS_SETTING_NAME);
1143         result = set_config_str(accountID, DEFINE_CONFIG_KEY_PROFILE_NAME, profileName, "string", "SE");
1144         if (result == false) {
1145                 FW_LOGE("failed in set_config");
1146                 err = SE_INTERNAL_DA_ERROR;
1147                 goto error;
1148         }
1149
1150         result = set_config_str(accountID, DEFINE_CONFIG_KEY_PROFILE_SERVER_IP, serverIP, "string", "SE");
1151         if (result == false) {
1152                 FW_LOGE("failed in set_config");
1153                 err = SE_INTERNAL_DA_ERROR;
1154                 goto error;
1155         }
1156
1157         syncMode = get_vconf_str(profilePath, DS_SETTING_SYNCMODE);
1158         result = set_config_str(accountID, DEFINE_CONFIG_KEY_PROFILE_SYNC_MODE, syncMode, "string", "SE");
1159         if (result == false) {
1160                 FW_LOGE("failed in set_config");
1161                 err = SE_INTERNAL_DA_ERROR;
1162                 goto error;
1163         }
1164
1165         syncType =  get_vconf_str(profilePath, DS_SETTING_SYNCTYPE);
1166         result = set_config_str(accountID, DEFINE_CONFIG_KEY_PROFILE_SYNC_TYPE, syncType, "string", "SE");
1167         if (result == false) {
1168                 FW_LOGE("failed in set_config");
1169                 err = SE_INTERNAL_DA_ERROR;
1170                 goto error;
1171         }
1172
1173         interval = get_vconf_str(profilePath, DS_SETTING_INTERVAL);
1174         FW_LOGV("interval %s ", interval);
1175
1176         err = __set_periodic_sync_config(accountID, syncMode, interval);
1177         if (err  != SE_INTERNAL_OK) {
1178                 FW_LOGE("failed in set_periodic_sync_config");
1179                 goto error;
1180         }
1181
1182         result = set_config_str(accountID, DEFINE_CONFIG_KEY_PROFILE_SYNC_INTERVAL, interval, "string", "SE");
1183         if (result == false) {
1184                 FW_LOGE("failed in set_config");
1185                 err = SE_INTERNAL_DA_ERROR;
1186                 goto error;
1187         }
1188
1189         int content_type;
1190         for (content_type = 0; content_type < TYPE_CONTENT_COUNT - 1; content_type++) {
1191                 err = __set_datastore_config_from_vconf(accountID, profilePath, content_type);
1192                 if (err  != SE_INTERNAL_OK) {
1193                         FW_LOGE("failed in set_DatastoreConfig");
1194                         goto error;
1195                 }
1196         }
1197
1198         *accountId = accountID;
1199
1200         FW_LOGV("end");
1201
1202 error:
1203
1204         if (profileName)
1205                 free(profileName);
1206         if (email)
1207                 free(email);
1208         if (password)
1209                 free(password);
1210         if (serverIP)
1211                 free(serverIP);
1212         if (syncMode)
1213                 free(syncMode);
1214         if (syncType)
1215                 free(syncType);
1216         if (interval)
1217                 free(interval);
1218
1219         DACI_Close_Agent();
1220
1221         if (err != SE_INTERNAL_OK)
1222                 return 0;
1223         else
1224                 return 1;
1225 }
1226
1227
1228 int add_profile_csc(int index)
1229 {
1230         SE_ErrorType  err = SE_INTERNAL_OK;
1231         char profilePath[128];
1232         char profileDirName[128];
1233         char *profileName = NULL;
1234         char *id = NULL;
1235         char *password = NULL;
1236         char *serverIP = NULL;
1237         char *syncMode = NULL;
1238         char *syncType = NULL;
1239         bool result;
1240
1241         DACI_RETURN da_err = DACI_Open_Agent();
1242         if (da_err != DACI_SUCCESS) {
1243                 err = SE_INTERNAL_DA_ERROR;
1244                 goto error;
1245         }
1246
1247         sprintf(profilePath, CSC_VCONF_KEY_SYNCMLDS_ADDR, index);
1248         serverIP =  get_vconf_str_key(profilePath);
1249
1250         sprintf(profilePath, CSC_VCONF_KEY_SYNCMLDS_AUTHNAME, index);
1251         id = get_vconf_str_key(profilePath);
1252
1253         sprintf(profilePath, CSC_VCONF_KEY_SYNCMLDS_AUTHPWD, index);
1254         password = get_vconf_str_key(profilePath);
1255
1256         FW_LOGV("email = %s", id);
1257         FW_LOGV("password = %s", password);
1258         FW_LOGV("serverIP = %s", serverIP);
1259
1260         int accountID;
1261         err = __add_profile(serverIP, id, password , "CSC", &accountID);
1262         if (err  != SE_INTERNAL_OK) {
1263                 FW_LOGE("failed in add_Account");
1264                 goto error;
1265         }
1266
1267         err = __set_config_default_value(accountID);
1268         if (err  != SE_INTERNAL_OK) {
1269                 FW_LOGE("failed in __set_config_default_value");
1270                 goto error;
1271         }
1272
1273         /*set profile dir name in config table*/
1274         sprintf(profileDirName, "Sync%d", index);
1275         result = set_config_str(accountID, DEFINE_CONFIG_KEY_PROFILE_DIR_NAME, profileDirName, "string", "SE");
1276         if (result == false) {
1277                 FW_LOGE("failed in set_config");
1278                 err = SE_INTERNAL_DA_ERROR;
1279                 goto error;
1280         }
1281
1282         result = set_config_str(accountID, DEFINE_CONFIG_KEY_PROFILE_SERVER_IP, serverIP, "string", "SE");
1283         if (result == false) {
1284                 FW_LOGE("failed in set_config");
1285                 err = SE_INTERNAL_DA_ERROR;
1286                 goto error;
1287         }
1288
1289         sprintf(profilePath, CSC_VCONF_KEY_SYNCMLDS_NAME, index);
1290         profileName = get_vconf_str_key(profilePath);
1291         result = set_config_str(accountID, DEFINE_CONFIG_KEY_PROFILE_NAME, profileName, "string", "SE");
1292         if (result == false) {
1293                 FW_LOGE("failed in set_config");
1294                 err = SE_INTERNAL_DA_ERROR;
1295                 goto error;
1296         }
1297
1298         sprintf(profilePath, CSC_VCONF_KEY_SYNCMLDS_SYNCMODE, index);
1299         syncMode = get_vconf_str_key(profilePath);
1300         result = set_config_str(accountID, DEFINE_CONFIG_KEY_PROFILE_SYNC_MODE, syncMode, "string", "SE");
1301         if (result == false) {
1302                 FW_LOGE("failed in set_config");
1303                 err = SE_INTERNAL_DA_ERROR;
1304                 goto error;
1305         }
1306
1307         sprintf(profilePath, CSC_VCONF_KEY_SYNCMLDS_SYNCTYPE, index);
1308         syncType =  get_vconf_str_key(profilePath);
1309         result = set_config_str(accountID, DEFINE_CONFIG_KEY_PROFILE_SYNC_TYPE, syncType, "string", "SE");
1310         if (result == false) {
1311                 FW_LOGE("failed in set_config");
1312                 err = SE_INTERNAL_DA_ERROR;
1313                 goto error;
1314         }
1315
1316         int content_type;
1317         for (content_type = 0; content_type < TYPE_CONTENT_COUNT - 1; content_type++) {
1318                 err = __set_datastore_config_from_csc(accountID, index, content_type);
1319                 if (err  != SE_INTERNAL_OK) {
1320                         FW_LOGE("failed in set_DatastoreConfig");
1321                         goto error;
1322                 }
1323         }
1324
1325         FW_LOGV("end");
1326
1327 error:
1328
1329         if (profileName)
1330                 free(profileName);
1331         if (id)
1332                 free(id);
1333         if (password)
1334                 free(password);
1335         if (serverIP)
1336                 free(serverIP);
1337         if (syncMode)
1338                 free(syncMode);
1339         if (syncType)
1340                 free(syncType);
1341
1342         DACI_Close_Agent();
1343
1344         if (err != SE_INTERNAL_OK)
1345                 return 0;
1346         else
1347                 return 1;
1348 }
1349
1350 bool add_profile_cp(char *profileName, char *addr, char *id, char *password, GList *categories, int *accountId)
1351 {
1352         FW_LOGV("start");
1353
1354         FW_LOGV("profileName = %s", profileName);
1355         FW_LOGV("addr = %s", addr);
1356         FW_LOGV("id = %s", id);
1357         FW_LOGV("password = %s", password);
1358
1359         SE_ErrorType err = SE_INTERNAL_OK;
1360         bool result;
1361
1362         int account = -1;
1363
1364         DACI_RETURN da_err = DACI_Open_Agent();
1365         if (da_err != DACI_SUCCESS) {
1366                 err = SE_INTERNAL_DA_ERROR;
1367                 goto error;
1368         }
1369
1370         err = __add_profile(addr, id, password, "CP", &account);
1371         if (err  != SE_INTERNAL_OK) {
1372                 FW_LOGE("failed in add_Account");
1373                 goto error;
1374         }
1375
1376         err = __set_config_default_value(account);
1377         if (err  != SE_INTERNAL_OK) {
1378                 FW_LOGE("failed in add_Account");
1379                 goto error;
1380         }
1381
1382         result = set_config_str(account, DEFINE_CONFIG_KEY_PROFILE_SERVER_IP, addr, "string", "SE");
1383         if (result == false) {
1384                 FW_LOGE("failed in set_config");
1385                 err = SE_INTERNAL_DA_ERROR;
1386                 goto error;
1387         }
1388
1389         result = set_config_str(account, DEFINE_CONFIG_KEY_PROFILE_NAME, profileName, "string", "SE");
1390         if (result == false) {
1391                 FW_LOGE("failed in set_config");
1392                 err = SE_INTERNAL_DA_ERROR;
1393                 goto error;
1394         }
1395
1396         int i;
1397         int cnt = (int) sizeof(predefinedServer) / sizeof(datastore_cp_info);
1398         FW_LOGV("cnt = %d", cnt);
1399         for (i = 0; i < cnt; i++) {
1400
1401                 FW_LOGV("predefinedServer[%d].serverName = %s", i, predefinedServer[i].serverName);
1402                 if (strcmp(predefinedServer[i].serverName, profileName) == 0) {
1403
1404                         int j;
1405                         for (j = 0; j < MAX_DATASTORE_COUNT; j++) {
1406                                 resource_cp *category = NULL;
1407                                 GList *iter = NULL;
1408                                 FW_LOGV("categories length = %d", g_list_length(categories));
1409                                 for (iter = categories; iter != NULL; iter = g_list_next(iter)) {
1410                                         category = (resource_cp *)iter->data;
1411                                         FW_LOGV("category->name = %s", category->name);
1412                                         FW_LOGV("category->accept = %s", category->accept);
1413
1414                                         FW_LOGV("predefinedDatastore[i][j][0] = %s", predefinedDatastore[i][j][0]);
1415                                         FW_LOGV("predefinedDatastore[i][j][1] = %s", predefinedDatastore[i][j][1]);
1416
1417                                         if (predefinedDatastore[i][j][0] != NULL && category->name != NULL &&
1418                                                         predefinedDatastore[i][j][1] != NULL && category->accept != NULL) {
1419
1420                                                 if (strcasecmp(predefinedDatastore[i][j][0] , category->name) == 0 &&
1421                                                         strcmp(predefinedDatastore[i][j][1], category->accept) == 0) {
1422
1423                                                         err = __set_profile_category_cp(account, j, category);
1424                                                         if (err  != SE_INTERNAL_OK) {
1425                                                                 FW_LOGE("failed in __set_profile_category");
1426                                                                 goto error;
1427                                                         }
1428                                                         break;
1429                                                 }
1430                                         }
1431                                 }
1432                         }
1433                 }
1434         }
1435
1436         *accountId = account;
1437
1438
1439         FW_LOGV("end");
1440
1441 error:
1442
1443         DACI_Close_Agent();
1444
1445         if (err != SE_INTERNAL_OK)
1446                 return false;
1447         else
1448                 return true;
1449 }
1450
1451 bool add_profile(char *profileDirName, char *profileName, char *addr, char *id, char *password, char *syncMode, char *syncType, char *interval, GList *categories, int *accountId)
1452 {
1453         FW_LOGV("start");
1454
1455         FW_LOGV("profileName = %s", profileName);
1456         FW_LOGV("addr = %s", addr);
1457         FW_LOGV("id = %s", id);
1458         FW_LOGV("password = %s", password);
1459         FW_LOGV("syncMode = %s", syncMode);
1460         FW_LOGV("syncType = %s", syncType);
1461         FW_LOGV("interval = %s", interval);
1462
1463         SE_ErrorType err = SE_INTERNAL_OK;
1464         bool result;
1465
1466         int account = -1;
1467
1468         DACI_RETURN da_err = DACI_Open_Agent();
1469         if (da_err != DACI_SUCCESS) {
1470                 err = SE_INTERNAL_DA_ERROR;
1471                 goto error;
1472         }
1473
1474         err = __add_profile(addr, id, password, "UI", &account);
1475         if (err  != SE_INTERNAL_OK) {
1476                 FW_LOGE("failed in add_Account");
1477                 goto error;
1478         }
1479
1480         err = __set_config_default_value(account);
1481         if (err  != SE_INTERNAL_OK) {
1482                 FW_LOGE("failed in add_Account");
1483                 goto error;
1484         }
1485
1486         result = set_config_str(account, DEFINE_CONFIG_KEY_PROFILE_DIR_NAME, profileDirName, "string", "SE");
1487         if (result == false) {
1488                 FW_LOGE("failed in set_config");
1489                 err = SE_INTERNAL_DA_ERROR;
1490                 goto error;
1491         }
1492
1493         result = set_config_str(account, DEFINE_CONFIG_KEY_PROFILE_SERVER_IP, addr, "string", "SE");
1494         if (result == false) {
1495                 FW_LOGE("failed in set_config");
1496                 err = SE_INTERNAL_DA_ERROR;
1497                 goto error;
1498         }
1499
1500         err = __set_profile_info(account, profileName, syncMode, syncType, interval);
1501         if (err  != SE_INTERNAL_OK) {
1502                 FW_LOGE("failed in __set_profile_info");
1503                 goto error;
1504         }
1505
1506         err = __set_periodic_sync_config(account, syncMode, interval);
1507         if (err  != SE_INTERNAL_OK) {
1508                 FW_LOGE("failed in __set_profile_info");
1509                 goto error;
1510         }
1511
1512         sync_category *category = NULL;
1513         GList *iter = NULL;
1514         int contentType = 0;
1515         for (iter = categories; iter != NULL; iter = g_list_next(iter)) {
1516                 category = iter->data;
1517                 err = __set_profile_category(account, contentType, category);
1518                 if (err  != SE_INTERNAL_OK) {
1519                         FW_LOGE("failed in __set_profile_category");
1520                         goto error;
1521                 }
1522                 contentType++;
1523         }
1524
1525         *accountId = account;
1526
1527
1528         FW_LOGV("end");
1529
1530 error:
1531
1532         DACI_Close_Agent();
1533
1534         if (err != SE_INTERNAL_OK)
1535                 return false;
1536         else
1537                 return true;
1538 }
1539
1540 bool edit_profile(int accountId, char *profileName, char *addr, char *id, char *password, char *syncMode, char *syncType, char *interval, GList *categories)
1541 {
1542         FW_LOGV("start");
1543         SE_ErrorType err = SE_INTERNAL_OK;
1544         bool result;
1545
1546         DACI_RETURN da_err = DACI_Open_Agent();
1547         if (da_err != DACI_SUCCESS) {
1548                 err = SE_INTERNAL_DA_ERROR;
1549                 goto error;
1550         }
1551
1552         da_err = DACI_Set_Account_Email_Address(accountId, id, "SE");
1553         if (da_err != DACI_SUCCESS) {
1554                 FW_LOGE("failed in DACI_Set_Account_Email_Address");
1555                 err = SE_INTERNAL_ERROR;
1556                 goto error;
1557         }
1558
1559
1560         da_err = DACI_Set_Account_Password(accountId, password, "SE");
1561         if (da_err != DACI_SUCCESS) {
1562                 FW_LOGE("failed in DACI_Set_Account_Email_Address");
1563                 err = SE_INTERNAL_ERROR;
1564                 goto error;
1565         }
1566
1567         result = set_config_str(accountId, DEFINE_CONFIG_KEY_PROFILE_SERVER_IP, addr, "string", "SE");
1568         if (result == false) {
1569                 FW_LOGE("failed in set_config");
1570                 err = SE_INTERNAL_DA_ERROR;
1571                 goto error;
1572         }
1573
1574         err = __set_profile_info(accountId, profileName, syncMode, syncType, interval);
1575         if (err  != SE_INTERNAL_OK) {
1576                 FW_LOGE("failed in __set_profile_info");
1577                 goto error;
1578         }
1579
1580         err = __set_periodic_sync_config(accountId, syncMode, interval);
1581         if (err  != SE_INTERNAL_OK) {
1582                 FW_LOGE("failed in __set_profile_info");
1583                 goto error;
1584         }
1585
1586         sync_category *category = NULL;
1587         GList *iter = NULL;
1588         int contentType = 0;
1589         for (iter = categories; iter != NULL; iter = g_list_next(iter)) {
1590                 category = iter->data;
1591                 err = __set_profile_category(accountId, contentType, category);
1592                 if (err  != SE_INTERNAL_OK) {
1593                         FW_LOGE("failed in __set_profile_category");
1594                         goto error;
1595                 }
1596                 contentType++;
1597         }
1598
1599         FW_LOGV("end");
1600
1601 error:
1602
1603         DACI_Close_Agent();
1604
1605         if (err != SE_INTERNAL_OK)
1606                 return false;
1607         else
1608                 return true;
1609 }
1610
1611 bool delete_profile(GList *profiles)
1612 {
1613         FW_LOGV("start");
1614         SE_ErrorType  err = SE_INTERNAL_OK;
1615         char *profileName = NULL;
1616         int *accountId = 0;
1617         char *value = NULL;
1618
1619         DACI_RETURN da_err = DACI_Open_Agent();
1620         if (da_err != DACI_SUCCESS) {
1621                 err = SE_INTERNAL_DA_ERROR;
1622                 goto error;
1623         }
1624
1625         GList *iter = NULL;
1626         int alarmId = 0;
1627
1628         bool result;
1629         for (iter = profiles; iter != NULL; iter = g_list_next(iter)) {
1630                 accountId = (int *)(iter->data);
1631
1632                 FW_LOGV("accountId = %d", *accountId);
1633                 /*if deleteing Account's sync mode is periodic sync it has to be deleted from schedule_tbl*/
1634                 result = get_config(*accountId, DEFINE_CONFIG_KEY_PROFILE_ALARM_ID, &value);
1635                 if (result == false) {
1636                         FW_LOGE("failed in get_config");
1637                         err = SE_INTERNAL_DA_ERROR;
1638                         goto error;
1639                 }
1640                 alarmId = atoi(value);
1641                 if (alarmId != 0) {
1642                         PMCI_RETURN scheduler_err = PMCI_Remove_Item_To_Specific_Type(DEFINE_PLATFORM, ALARM, alarmId);
1643                         if (scheduler_err != PMCI_SUCCESS) {
1644                                 FW_LOGE("failed in PMCI_Remove_Item_To_Specific_Type");
1645                                 err = SE_INTERNAL_SCHEDULER_ERROR;
1646                                 goto error;
1647                         }
1648                 }
1649                 deleteAccount(*accountId);
1650                 if(accountId != 0){
1651                         free(accountId);
1652                         accountId = 0;
1653                 }
1654         }
1655
1656         FW_LOGV("end");
1657
1658 error:
1659
1660         DACI_Close_Agent();
1661
1662         if (profileName)
1663                 free(profileName);
1664
1665         if (value)
1666                 free(value);
1667
1668         if(accountId != NULL)
1669                 free(accountId);
1670
1671         if (err != SE_INTERNAL_OK)
1672                 return false;
1673         else
1674                 return true;
1675 }
1676
1677 bool get_synchronising_profile(char **profileDirName)
1678 {
1679         FW_LOGV("start ");
1680
1681         SE_ErrorType err = SE_INTERNAL_OK;
1682
1683         bool result;
1684         char *value = NULL;
1685         int *account_list = 0;
1686         int account_list_count = 0;
1687
1688         DACI_RETURN da_err = DACI_Open_Agent();
1689         if (da_err != DACI_SUCCESS) {
1690                 err = SE_INTERNAL_DA_ERROR;
1691                 goto error;
1692         }
1693
1694         account_list = DACI_Get_Account_Account_Id_List(&account_list_count);
1695
1696         int i;
1697         for (i = 0; i < account_list_count; i++) {
1698                 result = get_config(account_list[i], DEFINE_CONFIG_KEY_PROFILE_SYNCHRONISING, &value);
1699                 if (result == false) {
1700                         FW_LOGE("failed in set_Config");
1701                         err = SE_INTERNAL_DA_ERROR;
1702                         goto error;
1703                 }
1704
1705                 if (strcmp(value, "1") == 0) {
1706                         result = get_config(account_list[i], DEFINE_CONFIG_KEY_PROFILE_DIR_NAME, profileDirName);
1707                         if (result == false) {
1708                                 FW_LOGE("failed in get_Config");
1709                                 err = SE_INTERNAL_DA_ERROR;
1710                                 goto error;
1711                         }
1712                         break;
1713                 }
1714
1715                 free(value);
1716                 value = NULL;
1717         }
1718
1719         FW_LOGV("end");
1720
1721 error:
1722
1723         if (account_list_count > 0)
1724                 free(account_list);
1725
1726         if (value != NULL)
1727                 free(value);
1728
1729         DACI_Close_Agent();
1730
1731         if (err != SE_INTERNAL_OK)
1732                 return false;
1733         else
1734                 return true;
1735 }
1736
1737
1738 bool add_profile_calllog(int *accountId)
1739 {
1740         FW_LOGV("start");
1741
1742         SE_ErrorType err = SE_INTERNAL_OK;
1743         DCI_RETURN dci_err = DCI_SUCCESS;
1744         bool result;
1745         sync_category *category = NULL;
1746         char *id = NULL;
1747         char *password  = NULL;
1748         int account = -1;
1749
1750
1751         DACI_RETURN da_err = DACI_Open_Agent();
1752         if (da_err != DACI_SUCCESS) {
1753                 err = SE_INTERNAL_DA_ERROR;
1754                 goto error;
1755         }
1756
1757         /* FIXME  get id from somewhere */
1758         /*get IMEI from Platform */
1759         id = "pcwds@samsung.com";
1760
1761         dci_err = DCI_Get_DevInfo(DEFINE_PLATFORM, "DevID", &password);
1762         if (dci_err != DCI_SUCCESS) {
1763                 FW_LOGE("failed to get devinfo");
1764                 goto error;
1765         }
1766
1767         err = __add_profile(DEFINE_CALLLOG_SERVER_URL_HTTPS, id, password, "CALLLOG", &account);
1768         if (err  != SE_INTERNAL_OK) {
1769                 FW_LOGE("failed in add_Account");
1770                 goto error;
1771         }
1772
1773         err = __set_config_default_value(account);
1774         if (err  != SE_INTERNAL_OK) {
1775                 FW_LOGE("failed in add_Account");
1776                 goto error;
1777         }
1778
1779         result = set_config_str(account, DEFINE_CONFIG_KEY_PROFILE_SERVER_IP, DEFINE_CALLLOG_SERVER_URL_HTTPS, "string", "SE");
1780         if (result == false) {
1781                 FW_LOGE("failed in set_config");
1782                 err = SE_INTERNAL_DA_ERROR;
1783                 goto error;
1784         }
1785
1786         result = set_config_str(account, DEFINE_CONFIG_KEY_PROFILE_SYNC_TYPE, DEFINE_ALERT_REFRESH_FROM_CLIENT_STR, "string", "SE");
1787         if (result == false) {
1788                 FW_LOGE("failed in set_config");
1789                 err = SE_INTERNAL_DA_ERROR;
1790                 goto error;
1791         }
1792
1793         result = set_config_str(account, DEFINE_CONFIG_KEY_PROFILE_NEXT_NONCE, DEFINE_CALLLOG_DEFAULT_NEXT_NONCE, "string", "SE");
1794         if (result == false) {
1795                 FW_LOGE("failed in set_config");
1796                 err = SE_INTERNAL_DA_ERROR;
1797                 goto error;
1798         }
1799
1800         category = (sync_category *)calloc(1, sizeof(sync_category));
1801
1802         category->enabled = 1;
1803         category->srcURI = DEFINE_SOURCE_CALLLOG_URI;
1804         category->tgtURI = "./CallLog";
1805
1806         err = __set_profile_category(account, TYPE_CALLLOG, category);
1807         if (err  != SE_INTERNAL_OK) {
1808                 FW_LOGE("failed in __set_profile_category");
1809                 goto error;
1810         }
1811
1812         *accountId = account;
1813
1814         FW_LOGV("end");
1815
1816 error:
1817
1818         if(category != NULL)
1819                 free(category);
1820
1821         if(password != NULL)
1822                 free(password);
1823
1824         DACI_Close_Agent();
1825
1826         if (err != SE_INTERNAL_OK)
1827                 return false;
1828         else
1829                 return true;
1830 }
1831
1832 bool delete_profile_calllog()
1833 {
1834         FW_LOGV("start");
1835
1836         SE_ErrorType err = SE_INTERNAL_OK;
1837
1838         /*delete account */
1839
1840
1841         FW_LOGV("end");
1842
1843         if (err != SE_INTERNAL_OK)
1844                 return false;
1845         else
1846                 return true;
1847 }