9c4e52ef904a6fc1eb5b428e44e06c755322b505
[profile/ivi/wrt-plugins-tizen.git] / src / standards / Tizen / Account / AccountConverter.h
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
18 /*
19  * @file        Converter.h
20  * @author      Jihwa Park (jh7979.park@samsung.com)
21  * @author      Sangtai Kim
22  * @version     0.1
23  */
24
25 #ifndef _JS_TIZEN_ACCOUNT_CONVERTER_H_
26 #define _JS_TIZEN_ACCOUNT_CONVERTER_H_
27
28 #include <vector>
29 #include <string>
30 #include <API/Account/AccountFilter.h>
31 #include <API/Account/IAccountService.h>
32 #include <API/Account/AccountServices.h>
33
34 #include <CommonsJavaScript/Converter.h>
35 #include <CommonsJavaScript/ScopedJSStringRef.h>
36
37 using namespace TizenApis::Api::Account;
38 using namespace WrtDeviceApis::Commons;
39 using namespace WrtDeviceApis::CommonsJavaScript;
40
41 namespace TizenApis {
42 namespace Tizen1_0 {
43 namespace Account{
44 class AccountConverter : public Converter
45 {
46   public:
47     using Converter::toJSValueRef;
48   public:
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);
55
56         AccountServicesArrayPtr toAccountService(const JSValueRef jsValue);
57         AccountServicesPtr toService(JSValueRef jsValue);
58
59         void setProvider(const JSValueRef jsValue);
60         std::string convertTostring(const JSValueRef jsValue);
61
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);
68
69     /**
70      * @throw InvalidArgumentException If not a callback nor JS null.
71      */
72     JSValueRef toFunctionOrNull(const JSValueRef& arg);
73
74     /**
75      * @throw ConversionException If JS null.
76      * @throw InvalidArgumentException If not a callback nor JS null.
77      */
78     JSValueRef toFunction(const JSValueRef& arg);
79
80   private:
81         void toEventFilterConvertId(const AccountFilterPtr &result, const JSValueRef &filters);
82
83     static std::vector<std::string> m_allowedAttributes;
84     static std::vector<std::string> m_allowedCreateProperties;
85
86     std::string m_provider;
87
88 };
89
90 typedef ConverterFactory<AccountConverter> AccountConverterFactory;
91 }
92 }
93 }
94
95 #endif /* _JS_TIZEN_ACCOUNT_CONVERTER_H_ */