tizen 2.3.1 release
[framework/web/wearable/wrt-plugins-tizen.git] / src / NFC / NFCUtil.h
1 //
2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18
19 #ifndef __TIZEN_NFC_NFCUTIL_H_
20 #define __TIZEN_NFC_NFCUTIL_H_
21
22 #include <vector>
23 #include <string>
24 #include <nfc.h>
25
26 namespace DeviceAPI {
27 namespace NFC {
28
29 namespace {
30 const std::string GENERIC_TARGET = "GENERIC_TARGET";
31 const std::string ISO14443_A = "ISO14443_A";
32 const std::string ISO14443_4A = "ISO14443_4A";
33 const std::string ISO14443_3A = "ISO14443_3A";
34 const std::string MIFARE_MINI = "MIFARE_MINI";
35 const std::string MIFARE_1K = "MIFARE_1K";
36 const std::string MIFARE_4K = "MIFARE_4K";
37 const std::string MIFARE_ULTRA = "MIFARE_ULTRA";
38 const std::string MIFARE_DESFIRE = "MIFARE_DESFIRE";
39 const std::string ISO14443_B = "ISO14443_B";
40 const std::string ISO14443_4B = "ISO14443_4B";
41 const std::string ISO14443_BPRIME  = "ISO14443_BPRIME";
42 const std::string FELICA  = "FELICA";
43 const std::string JEWEL  = "JEWEL";
44 const std::string ISO15693  = "ISO15693";
45 const std::string UNKNOWN_TARGET = "UNKNOWN_TARGET";
46
47 const std::string ALWAYS_ON = "ALWAYS_ON";
48 const std::string OFF = "OFF";
49
50 const std::string ESE = "ESE";
51 const std::string UICC = "UICC";
52 const std::string HCE= "HCE";
53
54 const std::string PAYMENT = "PAYMENT";
55 const std::string OTHER= "OTHER";
56
57 const std::string DEACTIVATED = "DEACTIVATED";
58 const std::string ACTIVATED= "ACTIVATED";
59 const std::string APDU_RECEIVED = "APDU_RECEIVED";
60 const std::string UNKNOWN_EVENT_RECEIVED = "UNKNOWN_EVENT_RECEIVED";
61 }
62
63 typedef std::vector<unsigned char> UCharVector;
64
65 class NFCUtil
66 {
67 public:
68     static UCharVector toVector(const unsigned char *ch, const int size);
69     static void throwNFCException(const int errorCode, const char * message);
70     static std::string getNFCErrorString(const int error_code);
71     static std::string getNFCErrorMessage(const int error_code);
72     static std::string toStringNFCTag(const nfc_tag_type_e tag_type);
73     static nfc_tag_type_e toNfcTagString(const std::string& type_string);
74     static std::string toStringCardEmulationMode(
75         const nfc_se_card_emulation_mode_type_e mode);
76     static nfc_se_card_emulation_mode_type_e toCardEmulationMode(
77         const std::string& mode_string);
78     static std::string toStringSecureElementType(const nfc_se_type_e type);
79     static nfc_se_type_e toSecureElementType(const std::string& type_string);
80     static void setDefaultFilterValues(std::vector<nfc_tag_type_e>& filter);
81     static std::string toStringHceEventType( const nfc_hce_event_type_e type);
82     static nfc_card_emulation_category_type_e toCardEmulationCategoryType(
83         const std::string& type_string);
84 };
85
86 } // NFC
87 } // DeviceApi
88
89 #endif // __TIZEN_NFC_NFCUTIL_H_