Tizen 2.1 base
[platform/core/system/sync-agent.git] / include / account / service.h
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 #ifndef ACCOUNT_SERVICE_H_
19 #define ACCOUNT_SERVICE_H_
20
21 #include "manager.h"
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif                          /* __cplusplus */
26
27 /**
28  * @file        service.h
29  * @brief       Support to use framework Account module
30  */
31
32 /** @addtogroup account
33  *      @{
34  */
35
36 /**
37  * @brief       Enumerations of account type
38  */
39         typedef enum {
40                 SYNC_AGENT_ACC_TYPE_LOCAL = 0,
41                                         /**< local account type */
42                 SYNC_AGENT_ACC_TYPE_EAS,        /**< eas account type */
43                 SYNC_AGENT_ACC_TYPE_GOOGLE,     /**< google account type */
44                 SYNC_AGENT_ACC_TYPE_NONE        /**< no account type */
45         } sync_agent_service_account_type_e;
46
47 /**
48  * @brief       Structure of Service Account instance
49  */
50         typedef struct {
51                 char *email;    /**< e-mail address */
52                 sync_agent_service_account_type_e type; /**< type of service account */
53         } sync_agent_service_account_info_s;
54
55 /**
56  * @brief       Mapping service's all account to F/W account
57  * @par Usage:
58  * @code
59
60  sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
61  
62  account_err = sync_agent_construct_account_tbl_from_service();
63  if (account_err != SYNC_AGENT_ACC_SUCCESS) {
64         ...
65  }
66  
67  * @endcode
68  * @remarks     Services which are provided as a DataConnector plug-in.
69  * @return      SYNC_AGENT_ACC_SUCCESS on success, otherwise a error value.
70  * @retval      SYNC_AGENT_ACC_SUCCESS          Successful
71  * @retval      SYNC_AGENT_ACC_FAIL                     Parsing the initialization config file failed
72  * @retval      SYNC_AGENT_ACC_CHANGED  Service account repository changed
73  * @post                Mapped service's all existed account id with F/W account id
74  */
75
76         sync_agent_acc_error_e sync_agent_construct_account_tbl_from_service(void);
77
78 /**
79  * @brief       Create sync_agent_service_account_info_s structure
80  * @par Usage:
81  * @code
82  
83  sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
84  sync_agent_service_account_info_s *account_info = NULL;
85  
86  account_err = sync_agent_create_service_account_info(&account_info);
87  if (account_err != SYNC_AGENT_ACC_SUCCESS) {
88         ...
89  }
90  
91  * @endcode
92  * @param[out] account_info instance of service account info
93  * @return      SYNC_AGENT_ACC_SUCCESS  on success, otherwise a error value.
94  * @retval      SYNC_AGENT_ACC_SUCCESS          Successful
95  * @retval      SYNC_AGENT_ACC_FAIL                     When memory allocation is failed
96  */
97         sync_agent_acc_error_e sync_agent_create_service_account_info(sync_agent_service_account_info_s ** account_info);
98
99 /**
100  * @brief       Get Account Information
101  * @par Usage:
102  * @code
103  
104  sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
105  sync_agent_service_account_info_s *account_info = NULL;
106  
107  account_err = sync_agent_get_service_account(fw_account_id, 1, &account_info);
108  if (account_err != SYNC_AGENT_ACC_SUCCESS) {
109         ...
110  }
111  
112  * @endcode
113  * @remarks     Account Information type is defined in account plugIn.
114  * @param[in]   fw_account_id   account id
115  * @param[in]   service_type    service type
116  * @param[out] account_info instance of service account info
117  * @return      SYNC_AGENT_ACC_SUCCESS  on success, otherwise an error value.
118  * @retval      SYNC_AGENT_ACC_SUCCESS          Successful
119  * @retval      SYNC_AGENT_ACC_FAIL                     Parsing the initialization config file failed
120  * @retval      SYNC_AGENT_ACC_CHANGED  Service account repository changed
121  * @pre account plugIn loaded
122  */
123         sync_agent_acc_error_e sync_agent_get_service_account(int fw_account_id, int service_type, sync_agent_service_account_info_s ** account_info);
124
125 /**
126  * @brief       Free sync_agent_service_account_info_s structure
127  * @par Usage:
128  * @code
129  
130  sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
131  sync_agent_service_account_info_s *account_info = NULL;
132  
133  account_err = sync_agent_get_service_account(fw_account_id, 1, &account_info);
134  ...
135  sync_agent_free_service_account_info(account_info);
136  * @endcode
137  * @param[in] account_info instance of service account info
138  */
139         void sync_agent_free_service_account_info(sync_agent_service_account_info_s * account_info);
140
141 /**
142  * @}
143  */
144
145 #ifdef __cplusplus
146 }
147 #endif                          /* __cplusplus */
148 #endif                          /* ACCOUNT_SERVICE_H_ */