2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include <Commons/FunctionDefinition.h>
18 #include <Commons/FunctionDeclaration.h>
20 #include <Commons/Exception.h>
21 #include <dpl/exception.h>
24 #include "plugin_config.h"
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"
30 #define ACCOUNT_DEVICE_CAP_READ "account.read"
31 #define ACCOUNT_DEVICE_CAP_WRITE "account.write"
33 //using namespace TizenApis::Api::Account;
34 using namespace WrtDeviceApis::Commons;
35 //using namespace WrtDeviceApis::CommonsJavaScript;
41 static FunctionMapping createAccountFunctions();
43 static FunctionMapping AccountFunctions =
44 createAccountFunctions();
46 DEFINE_FUNCTION_GETTER(Account, AccountFunctions);
48 static FunctionMapping createAccountFunctions()
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);
57 ACE_CREATE_DEVICE_CAPS_LIST(EMPTY_DEVICE_LIST);
59 ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_ACCOUNT_READ);
60 ACE_ADD_DEVICE_CAP(DEVICE_LIST_ACCOUNT_READ, DEVICE_CAP_ACCOUNT_READ);
62 ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_ACCOUNT_WRITE);
63 ACE_ADD_DEVICE_CAP(DEVICE_LIST_ACCOUNT_WRITE, DEVICE_CAP_ACCOUNT_WRITE);
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);
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);
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);
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);
85 ACE_CREATE_FEATURE_LIST(ACCOUNT_FEATURES_ACCOUNT);
86 ACE_ADD_API_FEATURE(ACCOUNT_FEATURES_ACCOUNT, FEATURE_ACCOUNT);
88 ACE_CREATE_FEATURE_LIST(ACCOUNT_FEATURES_READ);
89 ACE_ADD_API_FEATURE(ACCOUNT_FEATURES_ACCOUNT_READ,FEATURE_ACCOUNT_READ);
91 ACE_CREATE_FEATURE_LIST(ACCOUNT_FEATURES_WRITE);
92 ACE_ADD_API_FEATURE(ACCOUNT_FEATURES_WRITE,FEATURE_ACCOUNT_WRITE);
98 FunctionMapping accountMapping;
101 AceFunction addAccountFunc = ACE_CREATE_FUNCTION(
102 FUNCTION_CREATE_ACCOUNT,
103 ACCOUNT_FUNCTION_API_ADD_ACCOUNT,
104 ACCOUNT_FEATURES_ACCOUNT_READ_WRITE,
107 accountMapping.insert(std::make_pair(
108 ACCOUNT_FUNCTION_API_ADD_ACCOUNT,
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);
118 accountMapping.insert(std::make_pair(
119 ACCOUNT_FUNCTION_API_ADD_LISTENER_ACCOUNTS,
120 listenerAccountsFunc));
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);
129 accountMapping.insert(std::make_pair(
130 ACCOUNT_FUNCTION_API_REMOVE_LISTENER_ACCOUNTS,
131 removelistenerAccountsFunc));
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);
140 accountMapping.insert(std::make_pair(
141 ACCOUNT_FUNCTION_API_GET_ACCOUNT_BY_ID,
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);
151 accountMapping.insert(std::make_pair(
152 ACCOUNT_FUNCTION_API_GET_SERVICETYPE_BY_ID,
153 getServicetypesbyId));
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);
162 accountMapping.insert(std::make_pair(
163 ACCOUNT_FUNCTION_API_GET_PROVIDER_BY_ID,
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);
173 accountMapping.insert(std::make_pair(
174 ACCOUNT_FUNCTION_API_FIND_ACCOUNTS_BY_SERVICETYPE,
175 findAccountsbyServicetype));
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);
184 accountMapping.insert(std::make_pair(
185 ACCOUNT_FUNCTION_API_FIND_ACCOUNTS_BY_TAGS,
186 findAccountsbyTags));
189 AceFunction findAccounts = ACE_CREATE_FUNCTION(
190 FUNCTION_FIND_ACCOUNTS,
191 ACCOUNT_FUNCTION_API_FIND_ACCOUNTS,
192 ACCOUNT_FEATURES_ACCOUNT_READ,
193 DEVICE_LIST_ACCOUNT_READ);
195 accountMapping.insert(std::make_pair(
196 ACCOUNT_FUNCTION_API_FIND_ACCOUNTS,
199 //Find Services by Tags
200 AceFunction findServicesbyTags = ACE_CREATE_FUNCTION(
201 FUNCTION_FIND_SERVICES_BY_TAGS,
202 ACCOUNT_FUNCTION_API_FIND_SERVICES_BY_TAGS,
203 ACCOUNT_FEATURES_ACCOUNT_READ,
204 DEVICE_LIST_ACCOUNT_READ);
206 accountMapping.insert(std::make_pair(
207 ACCOUNT_FUNCTION_API_FIND_SERVICES_BY_TAGS,
208 findServicesbyTags));
211 AceFunction findServices = ACE_CREATE_FUNCTION(
212 FUNCTION_FIND_SERVICES,
213 ACCOUNT_FUNCTION_API_FIND_SERVICES,
214 ACCOUNT_FEATURES_ACCOUNT_READ,
215 DEVICE_LIST_ACCOUNT_READ);
217 accountMapping.insert(std::make_pair(
218 ACCOUNT_FUNCTION_API_FIND_SERVICES,
222 AceFunction findProviders = ACE_CREATE_FUNCTION(
223 FUNCTION_FIND_PROVIDERS,
224 ACCOUNT_FUNCTION_API_FIND_PROVIDERS,
225 ACCOUNT_FEATURES_ACCOUNT_READ,
226 DEVICE_LIST_ACCOUNT_READ);
228 accountMapping.insert(std::make_pair(
229 ACCOUNT_FUNCTION_API_FIND_PROVIDERS,
233 AceFunction findServicetypes = ACE_CREATE_FUNCTION(
234 FUNCTION_FIND_SERVICETYPES,
235 ACCOUNT_FUNCTION_API_FIND_SERVICETYPES,
236 ACCOUNT_FEATURES_ACCOUNT_READ,
237 DEVICE_LIST_ACCOUNT_READ);
239 accountMapping.insert(std::make_pair(
240 ACCOUNT_FUNCTION_API_FIND_SERVICETYPES,
244 AceFunction getServiceByName = ACE_CREATE_FUNCTION(
245 FUNCTION_GET_SERVICE_BY_NAME,
246 ACCOUNT_FUNCTION_API_GET_SERVICE_BY_NAME,
247 ACCOUNT_FEATURES_ACCOUNT_READ,
248 DEVICE_LIST_ACCOUNT_READ);
249 accountMapping.insert(std::make_pair(
250 ACCOUNT_FUNCTION_API_GET_SERVICE_BY_NAME,
254 AceFunction getServiceById = ACE_CREATE_FUNCTION(
255 FUNCTION_GET_SERVICE_BY_ID,
256 ACCOUNT_FUNCTION_API_GET_SERVICE_BY_ID,
257 ACCOUNT_FEATURES_ACCOUNT_READ,
258 DEVICE_LIST_ACCOUNT_READ);
259 accountMapping.insert(std::make_pair(
260 ACCOUNT_FUNCTION_API_GET_SERVICE_BY_ID,
263 return accountMapping;