5568f3046e1e7aea586cad209be5ee36b8383971
[profile/ivi/wrt-plugins-tizen.git] / src / standards / Tizen / Account / plugin_config.cpp
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include <Commons/FunctionDefinition.h>
18 #include <Commons/FunctionDeclaration.h>
19 #include <iostream>
20 #include <Commons/Exception.h>
21 #include <dpl/exception.h>
22 #include <map>
23
24 #include "plugin_config.h"
25
26 #define ACCOUNT_FEATURE_API "http://tizen.org/api/account"
27 #define ACCOUNT_FEATURE_API_READ  "http://tizen.org/api/account.read"
28 #define ACCOUNT_FEATURE_API_WRITE "http://tizen.org/api/account.write"
29
30 #define ACCOUNT_DEVICE_CAP_READ "account.read"
31 #define ACCOUNT_DEVICE_CAP_WRITE "account.write"
32
33 //using namespace TizenApis::Api::Account;
34 using namespace WrtDeviceApis::Commons;
35 //using namespace WrtDeviceApis::CommonsJavaScript;
36
37 namespace TizenApis {
38 namespace Tizen1_0 {
39 namespace Account{
40
41 static FunctionMapping createAccountFunctions();
42
43 static FunctionMapping AccountFunctions =
44     createAccountFunctions();
45
46 DEFINE_FUNCTION_GETTER(Account, AccountFunctions);
47
48 static FunctionMapping createAccountFunctions()
49 {
50
51     /**
52      * Device capabilities
53      */
54     ACE_CREATE_DEVICE_CAP(DEVICE_CAP_ACCOUNT_READ, ACCOUNT_DEVICE_CAP_READ);
55     ACE_CREATE_DEVICE_CAP(DEVICE_CAP_ACCOUNT_WRITE, ACCOUNT_DEVICE_CAP_WRITE);
56
57     ACE_CREATE_DEVICE_CAPS_LIST(EMPTY_DEVICE_LIST);
58
59     ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_ACCOUNT_READ);
60     ACE_ADD_DEVICE_CAP(DEVICE_LIST_ACCOUNT_READ, DEVICE_CAP_ACCOUNT_READ);
61
62     ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_ACCOUNT_WRITE);
63     ACE_ADD_DEVICE_CAP(DEVICE_LIST_ACCOUNT_WRITE, DEVICE_CAP_ACCOUNT_WRITE);
64
65     /**
66      * Api Features
67      */
68     ACE_CREATE_FEATURE(FEATURE_ACCOUNT, ACCOUNT_FEATURE_API);
69     ACE_CREATE_FEATURE(FEATURE_ACCOUNT_READ, ACCOUNT_FEATURE_API_READ);
70     ACE_CREATE_FEATURE(FEATURE_ACCOUNT_WRITE, ACCOUNT_FEATURE_API_WRITE);
71
72     ACE_CREATE_FEATURE_LIST(ACCOUNT_FEATURES_ACCOUNT_READ_WRITE);
73     ACE_ADD_API_FEATURE(ACCOUNT_FEATURES_ACCOUNT_READ_WRITE, FEATURE_ACCOUNT);
74     ACE_ADD_API_FEATURE(ACCOUNT_FEATURES_ACCOUNT_READ_WRITE, FEATURE_ACCOUNT_READ);
75     ACE_ADD_API_FEATURE(ACCOUNT_FEATURES_ACCOUNT_READ_WRITE, FEATURE_ACCOUNT_WRITE);
76
77     ACE_CREATE_FEATURE_LIST(ACCOUNT_FEATURES_ACCOUNT_READ);
78     ACE_ADD_API_FEATURE(ACCOUNT_FEATURES_ACCOUNT_READ, FEATURE_ACCOUNT);
79     ACE_ADD_API_FEATURE(ACCOUNT_FEATURES_ACCOUNT_READ, FEATURE_ACCOUNT_READ);
80
81     ACE_CREATE_FEATURE_LIST(ACCOUNT_FEATURES_ACCOUNT_WRITE);
82     ACE_ADD_API_FEATURE(ACCOUNT_FEATURES_ACCOUNT_WRITE, FEATURE_ACCOUNT);
83     ACE_ADD_API_FEATURE(ACCOUNT_FEATURES_ACCOUNT_WRITE, FEATURE_ACCOUNT_WRITE);
84
85     ACE_CREATE_FEATURE_LIST(ACCOUNT_FEATURES_ACCOUNT);
86     ACE_ADD_API_FEATURE(ACCOUNT_FEATURES_ACCOUNT, FEATURE_ACCOUNT);
87
88     ACE_CREATE_FEATURE_LIST(ACCOUNT_FEATURES_READ);
89     ACE_ADD_API_FEATURE(ACCOUNT_FEATURES_ACCOUNT_READ,FEATURE_ACCOUNT_READ);
90
91     ACE_CREATE_FEATURE_LIST(ACCOUNT_FEATURES_WRITE);
92     ACE_ADD_API_FEATURE(ACCOUNT_FEATURES_WRITE,FEATURE_ACCOUNT_WRITE);
93
94     /**
95      * Functions
96      */
97
98     FunctionMapping accountMapping;
99
100     //addAccount
101     AceFunction addAccountFunc = ACE_CREATE_FUNCTION(
102             FUNCTION_CREATE_ACCOUNT,
103             ACCOUNT_FUNCTION_API_ADD_ACCOUNT,
104             ACCOUNT_FEATURES_ACCOUNT_READ_WRITE,
105             EMPTY_DEVICE_LIST);
106
107     accountMapping.insert(std::make_pair(
108                                ACCOUNT_FUNCTION_API_ADD_ACCOUNT,
109                                addAccountFunc));
110
111     //Add listener
112     AceFunction listenerAccountsFunc = ACE_CREATE_FUNCTION(
113             FUNCTION_ADD_LISTENER_ACCOUNTS,
114             ACCOUNT_FUNCTION_API_ADD_LISTENER_ACCOUNTS,
115             ACCOUNT_FEATURES_ACCOUNT_READ,
116             DEVICE_LIST_ACCOUNT_READ);
117
118     accountMapping.insert(std::make_pair(
119                                ACCOUNT_FUNCTION_API_ADD_LISTENER_ACCOUNTS,
120                                listenerAccountsFunc));
121
122     //Remove listener
123     AceFunction removelistenerAccountsFunc = ACE_CREATE_FUNCTION(
124             FUNCTION_REMOVE_LISTENER_ACCOUNTS,
125             ACCOUNT_FUNCTION_API_REMOVE_LISTENER_ACCOUNTS,
126             ACCOUNT_FEATURES_ACCOUNT_READ,
127             DEVICE_LIST_ACCOUNT_READ);
128
129     accountMapping.insert(std::make_pair(
130                                ACCOUNT_FUNCTION_API_REMOVE_LISTENER_ACCOUNTS,
131                                removelistenerAccountsFunc));
132
133     //Get Account by ID
134     AceFunction getAccountbyId = ACE_CREATE_FUNCTION(
135             FUNCTION_GET_ACCOUNT_BY_ID,
136             ACCOUNT_FUNCTION_API_GET_ACCOUNT_BY_ID,
137             ACCOUNT_FEATURES_ACCOUNT_READ,
138             DEVICE_LIST_ACCOUNT_READ);
139
140     accountMapping.insert(std::make_pair(
141                                ACCOUNT_FUNCTION_API_GET_ACCOUNT_BY_ID,
142                                getAccountbyId));
143
144     //Get ServiceTypes by ID
145     AceFunction getServicetypesbyId = ACE_CREATE_FUNCTION(
146             FUNCTION_GET_SERVICETYPE_BY_ID,
147             ACCOUNT_FUNCTION_API_GET_SERVICETYPE_BY_ID,
148             ACCOUNT_FEATURES_ACCOUNT_READ,
149             DEVICE_LIST_ACCOUNT_READ);
150
151     accountMapping.insert(std::make_pair(
152                                ACCOUNT_FUNCTION_API_GET_SERVICETYPE_BY_ID,
153                                getServicetypesbyId));
154
155     //Get Provider by ID
156     AceFunction getProviderbyId = ACE_CREATE_FUNCTION(
157             FUNCTION_GET_PROVIDER_BY_ID,
158             ACCOUNT_FUNCTION_API_GET_PROVIDER_BY_ID,
159             ACCOUNT_FEATURES_ACCOUNT_READ,
160             DEVICE_LIST_ACCOUNT_READ);
161
162     accountMapping.insert(std::make_pair(
163                                ACCOUNT_FUNCTION_API_GET_PROVIDER_BY_ID,
164                                getProviderbyId));
165
166     //Find Accounts by ServiceType
167     AceFunction findAccountsbyServicetype = ACE_CREATE_FUNCTION(
168             FUNCTION_FIND_ACCOUNTS_BY_SERVICETYPE,
169             ACCOUNT_FUNCTION_API_FIND_ACCOUNTS_BY_SERVICETYPE,
170             ACCOUNT_FEATURES_ACCOUNT_READ,
171             DEVICE_LIST_ACCOUNT_READ);
172
173     accountMapping.insert(std::make_pair(
174                                ACCOUNT_FUNCTION_API_FIND_ACCOUNTS_BY_SERVICETYPE,
175                                findAccountsbyServicetype));
176
177     //Find Accounts by Tags
178     AceFunction findAccountsbyTags = ACE_CREATE_FUNCTION(
179             FUNCTION_FIND_ACCOUNTS_BY_TAGS,
180             ACCOUNT_FUNCTION_API_FIND_ACCOUNTS_BY_TAGS,
181             ACCOUNT_FEATURES_ACCOUNT_READ,
182             DEVICE_LIST_ACCOUNT_READ);
183
184     accountMapping.insert(std::make_pair(
185                                ACCOUNT_FUNCTION_API_FIND_ACCOUNTS_BY_TAGS,
186                                findAccountsbyTags));
187
188     //Find Services by Tags
189     AceFunction findServicesbyTags = ACE_CREATE_FUNCTION(
190             FUNCTION_FIND_SERVICES_BY_TAGS,
191             ACCOUNT_FUNCTION_API_FIND_SERVICES_BY_TAGS,
192             ACCOUNT_FEATURES_ACCOUNT_READ,
193             DEVICE_LIST_ACCOUNT_READ);
194
195     accountMapping.insert(std::make_pair(
196                                ACCOUNT_FUNCTION_API_FIND_SERVICES_BY_TAGS,
197                                findServicesbyTags));
198
199     //Find Providers
200     AceFunction findProviders = ACE_CREATE_FUNCTION(
201             FUNCTION_FIND_PROVIDERS,
202             ACCOUNT_FUNCTION_API_FIND_PROVIDERS,
203             ACCOUNT_FEATURES_ACCOUNT_READ,
204             DEVICE_LIST_ACCOUNT_READ);
205
206     accountMapping.insert(std::make_pair(
207                                ACCOUNT_FUNCTION_API_FIND_PROVIDERS,
208                                findProviders));
209
210     //Find ServiceTypes
211     AceFunction findServicetypes = ACE_CREATE_FUNCTION(
212             FUNCTION_FIND_SERVICETYPES,
213             ACCOUNT_FUNCTION_API_FIND_SERVICETYPES,
214             ACCOUNT_FEATURES_ACCOUNT_READ,
215             DEVICE_LIST_ACCOUNT_READ);
216
217     accountMapping.insert(std::make_pair(
218                                ACCOUNT_FUNCTION_API_FIND_SERVICETYPES,
219                                findServicetypes));
220
221     //getServiceByName
222         AceFunction getServiceByName = ACE_CREATE_FUNCTION(
223                                         FUNCTION_GET_SERVICE_BY_NAME,
224                                         ACCOUNT_FUNCTION_API_GET_SERVICE_BY_NAME,
225                                         ACCOUNT_FEATURES_ACCOUNT_READ,
226                                         DEVICE_LIST_ACCOUNT_READ);
227         accountMapping.insert(std::make_pair(
228                                         ACCOUNT_FUNCTION_API_GET_SERVICE_BY_NAME,
229                                         getServiceByName));
230
231         //getServiceById
232                 AceFunction getServiceById = ACE_CREATE_FUNCTION(
233                                                 FUNCTION_GET_SERVICE_BY_ID,
234                                                 ACCOUNT_FUNCTION_API_GET_SERVICE_BY_ID,
235                                                 ACCOUNT_FEATURES_ACCOUNT_READ,
236                                                 DEVICE_LIST_ACCOUNT_READ);
237                 accountMapping.insert(std::make_pair(
238                                                 ACCOUNT_FUNCTION_API_GET_SERVICE_BY_ID,
239                                                 getServiceById));
240
241     return accountMapping;
242 }
243 }
244 }
245 }