Beta merge 2
[profile/ivi/wrt-plugins-tizen.git] / src / platform / API / NFC / EventTagAction.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 #ifndef WRTPLUGINS_API_NFC_EVENT_TAG_ACTION_H_
19 #define WRTPLUGINS_API_NFC_EVENT_TAG_ACTION_H_
20
21 #include <vector>
22 #include "EventNFC.h"
23 #include <dpl/shared_ptr.h>
24
25 namespace TizenApis {
26 namespace Api {
27 namespace NFC {
28
29 template <class templateClass>
30 class EventTagAction : public EventNFCTemplate<templateClass>
31 {
32 protected:
33         void *messageHandle;
34         void setNdefMessageHandle(void *handle) { messageHandle = handle; }
35         void *getNdefMessageHandle()  { return messageHandle; }
36 public:
37         EventTagAction() { }
38 };
39
40 class EventTagActionRead : public EventNFCTemplate<EventTagActionRead>
41 {
42 public:
43         void setReadNdefResult(std::vector<unsigned char> result) {rawData = result;}
44         std::vector<unsigned char> getReadNdefResult()  {return rawData;}
45         EventTagActionRead(){ }
46 private:
47         std::vector<unsigned char> rawData;
48         
49 };
50
51 class EventTagActionWrite : public EventTagAction<EventTagActionWrite>
52 {
53 public:
54         void writeNdef(void *handle) {setNdefMessageHandle(handle);}
55         void *getNdefForWriting()  {return getNdefMessageHandle();}
56         EventTagActionWrite(){ }
57 };
58
59 class EventTagActionTransceive : public EventNFCTemplate<EventTagActionTransceive>
60 {
61 private:
62         std::vector<unsigned char> transceiveBuffer;
63 public:
64         void setTransceiveBuffer(const std::vector<unsigned char> data) {transceiveBuffer = data;}
65         std::vector<unsigned char> getTransceiveBuffer() const {return transceiveBuffer;}
66         int getTransceiveBufferSize() const {return transceiveBuffer.size();}
67         void transceive(const std::vector<unsigned char> data) {setTransceiveBuffer(data);}
68         EventTagActionTransceive()  { }
69 };
70
71 class EventTagActionFormat : public EventNFCTemplate<EventTagActionFormat>
72 {
73 private:
74         std::vector<unsigned char> m_key;
75
76 public:
77         void format(const std::vector<unsigned char> key) {m_key = key;}
78         std::vector<unsigned char> getKey() {return m_key;}
79         int getKeySize() const {return m_key.size();}
80         EventTagActionFormat()  { }
81 };
82
83 typedef DPL::SharedPtr<EventTagActionRead> EventTagActionReadPtr;
84 typedef DPL::SharedPtr<EventTagActionWrite> EventTagActionWritePtr;
85 typedef DPL::SharedPtr<EventTagActionTransceive> EventTagActionTransceivePtr;
86 typedef DPL::SharedPtr<EventTagActionFormat> EventTagActionFormatPtr;
87 } // NFC
88 } // Api
89 } // TizenApis
90
91 #endif //WRTPLUGINS_API_NFC_EVENT_TAG_ACTION_H_