Beta merge 2
[profile/ivi/wrt-plugins-tizen.git] / src / standards / Tizen / NFC / NFCConverter.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 #ifndef _JS_TIZEN10_NFC_CONVERTER_H_
20 #define _JS_TIZEN10_NFC_CONVERTER_H_
21
22 #include <vector>
23 #include <string>
24 #include <JavaScriptCore/JavaScript.h>
25 #include <CommonsJavaScript/Converter.h>
26 #include <API/NFC/TagFilter.h>
27 #include <API/NFC/NdefRecordProperties.h>
28 #include <API/NFC/NFCTagProperties.h>
29 #include <API/NFC/INdefRecord.h>
30 #include "NFCChangedCallback.h"
31
32 using namespace TizenApis::Api::NFC;
33
34 namespace TizenApis {
35 namespace Tizen1_0 {
36
37
38 class NFCConverter : public WrtDeviceApis::CommonsJavaScript::Converter
39 {
40     public:
41         using WrtDeviceApis::CommonsJavaScript::Converter::toJSValueRef;
42     public:
43         explicit NFCConverter(JSContextRef context);
44         virtual  ~NFCConverter();
45         TagFilterPtr toNFCTagFilter(JSValueRef jsValue);
46         nfcTagType toNfcTagType(std::string typeString);
47         std::string toNfcTagTypeString(nfcTagType type);
48         nfcTextEncodeUTF toNfcTextEncodeUTF(std::string encodeString);
49         std::string toNfcTextEncodeUTFString(nfcTextEncodeUTF encode);
50         JSValueRef toJSValueRef(const std::vector<unsigned char>& arg);
51         JSValueRef toJSValueRef(std::vector<NFCTagProperties> props);
52         JSValueRef toJSValueRef(NdefRecordData arg);
53         bool isNdefRecord(const JSValueRef& arg);
54         std::vector<void *> toVectorOfRecordHandles(const JSValueRef& arg);
55         std::string toRecordClassName(NdefRecordData arg);
56         void *getRecordHandle(const JSValueRef& arg);
57         void *getMessageHandle(const JSValueRef& arg);
58         NFCChangedCallback toNFCChangedCallback(const JSValueRef& arg);
59
60   private:
61     bool initializeAllowedProperties();
62     static std::vector<std::string> m_allowedTagFilterProperties;
63 };
64
65 typedef WrtDeviceApis::CommonsJavaScript::ConverterFactory<NFCConverter> NFCConverterFactory;
66
67 }
68 }
69
70 #endif /* _JS_TIZEN10_NFC_CONVERTER_H_ */