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.
20 * @author Jihwa Park (jh7979.park@samsung.com)
25 #ifndef _JS_TIZEN_ACCOUNT_CONVERTER_H_
26 #define _JS_TIZEN_ACCOUNT_CONVERTER_H_
30 #include <API/Account/AccountFilter.h>
31 #include <API/Account/IAccountService.h>
32 #include <API/Account/AccountServices.h>
34 #include <CommonsJavaScript/Converter.h>
35 #include <CommonsJavaScript/ScopedJSStringRef.h>
37 using namespace TizenApis::Api::Account;
38 using namespace WrtDeviceApis::Commons;
39 using namespace WrtDeviceApis::CommonsJavaScript;
44 class AccountConverter : public Converter
47 using Converter::toJSValueRef;
49 explicit AccountConverter(JSContextRef context);
50 virtual ~AccountConverter();
51 AccountFilterPtr toAccountFilter(const JSValueRef &filters);
52 EventAccountPtr toAccount(const JSValueRef account);
53 EventAccountPtr toAccount(const std::string& accountServiceProviderId);
54 EventAccountListPtr toVectorOfAccounts(JSValueRef accounts);
56 AccountServicesArrayPtr toAccountService(const JSValueRef jsValue);
57 AccountServicesPtr toService(JSValueRef jsValue);
59 void setProvider(const JSValueRef jsValue);
60 std::string convertTostring(const JSValueRef jsValue);
62 JSValueRef toJSValueRefAccount(const EventAccountPtr& arg);
63 JSValueRef toJSValueRef(const std::vector<EventAccountPtr> &arg);
64 JSValueRef toJSValueRefAccountService(const IAccountServicePtr& arg);
65 JSValueRef toJSValueRefAccountServiceType(const AccountServiceTypePropertyPtr& arg);
66 JSValueRef toJSValueRefAccountServiceProvider(const AccountServiceProviderPropertyPtr& arg);
67 JSValueRef toJSValueRef(const std::vector<IAccountServicePtr> &arg);
70 * @throw InvalidArgumentException If not a callback nor JS null.
72 JSValueRef toFunctionOrNull(const JSValueRef& arg);
75 * @throw ConversionException If JS null.
76 * @throw InvalidArgumentException If not a callback nor JS null.
78 JSValueRef toFunction(const JSValueRef& arg);
81 void toEventFilterConvertId(const AccountFilterPtr &result, const JSValueRef &filters);
83 static std::vector<std::string> m_allowedAttributes;
84 static std::vector<std::string> m_allowedCreateProperties;
86 std::string m_provider;
90 typedef ConverterFactory<AccountConverter> AccountConverterFactory;
95 #endif /* _JS_TIZEN_ACCOUNT_CONVERTER_H_ */