Beta merge 2
[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 toAccountServiceArray(const JSValueRef jsValue);
57         AccountServicesPtr toService(JSValueRef jsValue);
58
59         AccountServiceFilterPropertyPtr toAccountServiceFilterProperty(const JSValueRef jsValue);
60
61         std::vector<std::string> toTags(const JSValueRef jsValue);
62
63         void setProvider(const JSValueRef jsValue);
64         std::string convertTostring(const JSValueRef jsValue);
65
66     JSValueRef toJSValueRefAccount(const EventAccountPtr& arg);
67     JSValueRef toJSValueRef(const std::vector<EventAccountPtr> &arg);
68 //    JSValueRef toJSValueRefAccountService(const IAccountServicePtr& arg);
69     JSValueRef toJSValueRefAccountServiceType(const AccountServiceTypePropertyPtr& arg);
70     JSValueRef toJSValueRefAccountServiceProvider(const AccountServiceProviderPropertyPtr& arg);
71 //    JSValueRef toJSValueRef(const std::vector<IAccountServicePtr> &arg);
72     JSValueRef toJSValueRef(const EventAccountListPtr &arg);
73
74     JSValueRef toJSONString(const std::string& arg);
75
76     /**
77      * @throw InvalidArgumentException If not a callback nor JS null.
78      */
79     JSValueRef toFunctionOrNull(const JSValueRef& arg);
80
81     /**
82      * @throw ConversionException If JS null.
83      * @throw InvalidArgumentException If not a callback nor JS null.
84      */
85     JSValueRef toFunction(const JSValueRef& arg);
86
87   private:
88         void toEventFilterConvertId(const AccountFilterPtr &result, const JSValueRef &filters);
89
90     static std::vector<std::string> m_allowedAttributes;
91     static std::vector<std::string> m_allowedCreateProperties;
92
93     std::string m_provider;
94
95 };
96
97 typedef ConverterFactory<AccountConverter> AccountConverterFactory;
98 }
99 }
100 }
101
102 #endif /* _JS_TIZEN_ACCOUNT_CONVERTER_H_ */