2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #ifndef WRTPLUGINS_API_NFC_EVENT_TAG_ACTION_H_
19 #define WRTPLUGINS_API_NFC_EVENT_TAG_ACTION_H_
23 #include <dpl/shared_ptr.h>
29 template <class templateClass>
30 class EventTagAction : public EventNFCTemplate<templateClass>
34 void setNdefMessageHandle(void *handle) { messageHandle = handle; }
35 void *getNdefMessageHandle() { return messageHandle; }
40 class EventTagActionRead : public EventNFCTemplate<EventTagActionRead>
43 void setReadNdefResult(std::vector<unsigned char> result) {rawData = result;}
44 std::vector<unsigned char> getReadNdefResult() {return rawData;}
45 EventTagActionRead(){ }
47 std::vector<unsigned char> rawData;
51 class EventTagActionWrite : public EventTagAction<EventTagActionWrite>
54 void writeNdef(void *handle) {setNdefMessageHandle(handle);}
55 void *getNdefForWriting() {return getNdefMessageHandle();}
56 EventTagActionWrite(){ }
59 class EventTagActionTransceive : public EventNFCTemplate<EventTagActionTransceive>
62 std::vector<unsigned char> transceiveBuffer;
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() { }
71 class EventTagActionFormat : public EventNFCTemplate<EventTagActionFormat>
74 std::vector<unsigned char> m_key;
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() { }
83 typedef DPL::SharedPtr<EventTagActionRead> EventTagActionReadPtr;
84 typedef DPL::SharedPtr<EventTagActionWrite> EventTagActionWritePtr;
85 typedef DPL::SharedPtr<EventTagActionTransceive> EventTagActionTransceivePtr;
86 typedef DPL::SharedPtr<EventTagActionFormat> EventTagActionFormatPtr;
91 #endif //WRTPLUGINS_API_NFC_EVENT_TAG_ACTION_H_