tizen 2.3.1 release
[framework/web/wearable/wrt-plugins-tizen.git] / src / NFC / NFCTag.h
1 //
2 // Tizen Web Device API
3 // Copyright (c) 2013 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 #ifndef __TIZEN_NFC_NFCTAG_H_
19 #define __TIZEN_NFC_NFCTAG_H_
20
21 #include <nfc.h>
22 #include <memory>
23 #include <vector>
24 #include "NdefRecord.h"
25 #include "NdefMessage.h"
26 #include "NFCCallbackData.h"
27 #include <Security.h>
28
29 namespace DeviceAPI {
30 namespace NFC {
31
32 class NFCTag;
33 typedef std::shared_ptr<NFCTag> NFCTagPtr;
34 typedef std::pair<std::string, UCharVector> PropertyPair;
35
36 class NFCTag : public Common::SecurityAccessor
37 {
38 public:
39     NFCTag(nfc_tag_h handle);
40     virtual ~NFCTag();
41
42     nfc_tag_type_e getType();
43     std::string getTypeString();
44     bool isSupportedNDEF();
45     long getNdefSize();
46     std::vector<PropertyPair> getProperties();
47     bool isConnected();
48     void writeNDEF(NdefMessageCallbackData* callback);
49     void readNDEF(NdefMessageCallbackData *callback);
50
51     void addTagProperty(const char *key, UCharVector &value);
52
53     void transceive(ByteArraySuccessCallback* callback);
54
55 protected:
56     nfc_tag_h m_handle;
57     std::vector<PropertyPair> m_properties;
58     // idle (i.e. not-busy) transceive flag
59     static bool transceive_idle;
60     static void transceiveCB(nfc_error_e result, unsigned char* buffer,
61         int buffer_size, void* user_data);
62 };
63
64
65 } // NFC
66 } // DeviceAPI
67
68 #endif // __TIZEN_NFC_NFCTAG_H_