Tizen 2.0 Release
[framework/system/sync-agent.git] / src / framework / engine-controller / task_error.c
1 /*
2  * sync-agent
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
5  * Licensed under the Apache License, Version 2.0 (the License);
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #include "utility/sync_util.h"
19 #include "engine-controller/task_error.h"
20 #include "engine-controller/task_error_internal.h"
21
22 #ifndef SYNC_AGENT_LOG
23 #undef LOG_TAG
24 #define LOG_TAG "AF_EC"
25 #endif
26
27 typedef struct ec_task_error_map_s ec_task_error_map_t;
28 struct ec_task_error_map_s {
29         sync_agent_ec_task_error_e err;
30         sync_agent_ec_char *str;
31 };
32
33 static ec_task_error_map_t ec_task_error_string_tbl[5] = {
34         {SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN, "not yet run"},
35         {SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS, "success"},
36         {SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED, "failed"},
37         {SYNC_AGENT_EC_TASK_ERROR_CANCELED, "canceled"},
38         {SYNC_AGENT_EC_TASK_ERROR_INVALID_TASK, "invalid"}
39 };
40
41 sync_agent_ec_char *ec_task_error_string(sync_agent_ec_task_error_e error)
42 {
43         _EXTERN_FUNC_ENTER;
44         sync_agent_ec_char *str = ec_task_error_string_tbl[4].str;
45         sync_agent_ec_int i = 0;
46         for (i = 0; i < 5; i++) {
47                 if (error == ec_task_error_string_tbl[i].err) {
48                         str = ec_task_error_string_tbl[i].str;
49                         break;
50                 }
51         }
52
53         _EXTERN_FUNC_EXIT;
54         return str;
55 }