update for beta universally
[profile/ivi/wrt-plugins-tizen.git] / src / platform / API / NFC / EventTagMifareClassicAction.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_TAGMIFARECLASSIC_ACTION_H_
19 #define WRTPLUGINS_API_NFC_EVENT_TAGMIFARECLASSIC_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 EventTagMifareClassicAuthenticate : public EventNFCTemplate<templateClass>
31 {
32 protected:
33         std::vector<unsigned char> key;
34         int sectorIndex;
35         void setKey(const std::vector<unsigned char> &keyValue) {key = keyValue;}
36         void setSectorIndex(const int index) {sectorIndex = index;}
37 public:
38         std::vector<unsigned char> getKey() const {return key;}
39         int getSectorIndex() const {return sectorIndex;}
40         EventTagMifareClassicAuthenticate() { }
41 };
42
43 class EventTagMifareClassicAuthenticateWithKeyA : public EventTagMifareClassicAuthenticate<EventTagMifareClassicAuthenticateWithKeyA>
44 {
45 public:
46         EventTagMifareClassicAuthenticateWithKeyA(const std::vector<unsigned char> &keyValue, const int index) {
47                 setKey(keyValue);
48                 setSectorIndex(index);
49         }
50 };
51
52 class EventTagMifareClassicAuthenticateWithKeyB : public EventTagMifareClassicAuthenticate<EventTagMifareClassicAuthenticateWithKeyB>
53 {
54 public:
55         EventTagMifareClassicAuthenticateWithKeyB(const std::vector<unsigned char> &keyValue, const int index) {
56                 setKey(keyValue);
57                 setSectorIndex(index);
58         }
59 };
60
61 template <class templateBlockActionClass>
62 class EventTagMifareClassicBlockAction : public EventNFCTemplate<templateBlockActionClass>
63 {
64         protected:
65                 int blockIndex;
66                 void setBlockIndex(const int index) {blockIndex = index;}
67         public:
68                 EventTagMifareClassicBlockAction() {}
69                 int getIndex() const {return blockIndex;}
70 };
71
72 class EventTagMifareClassicReadBlock : public EventTagMifareClassicBlockAction<EventTagMifareClassicReadBlock>
73 {
74         private:
75                 std::vector<unsigned char> blockData;
76         public:
77                 EventTagMifareClassicReadBlock(const int index) {setBlockIndex(index);}
78                 void setBlockData(const std::vector<unsigned char> data) {blockData = data;}
79                 std::vector<unsigned char> getBlockData() const {return blockData;}
80 };
81
82 class EventTagMifareClassicWriteBlock : public EventTagMifareClassicBlockAction<EventTagMifareClassicWriteBlock>
83 {
84         private:
85                 std::vector<unsigned char> blockData;
86         public:
87                 EventTagMifareClassicWriteBlock(const int index, const std::vector<unsigned char> data) : blockData(data) {setBlockIndex(index);}
88                 std::vector<unsigned char> getBlockData() const {return blockData;}
89 };
90
91 class EventTagMifareClassicIncrementBlockValue : public EventTagMifareClassicBlockAction<EventTagMifareClassicIncrementBlockValue>
92 {
93         private:
94                 int blockValue;
95         public:
96                 EventTagMifareClassicIncrementBlockValue(const int index, const int value) : blockValue(value) {setBlockIndex(index);}
97                 int getValue() const {return blockValue;}
98 };
99
100 class EventTagMifareClassicDecrementBlockValue : public EventTagMifareClassicBlockAction<EventTagMifareClassicDecrementBlockValue>
101 {
102         private:
103                 int blockValue;
104         public:
105                 EventTagMifareClassicDecrementBlockValue(const int index, const int value) : blockValue(value) {setBlockIndex(index);}
106                 int getValue() const {return blockValue;}
107 };
108
109 class EventTagMifareClassicTransfer : public EventTagMifareClassicBlockAction<EventTagMifareClassicTransfer>
110 {
111         public:
112                 EventTagMifareClassicTransfer(const int index) {setBlockIndex(index);}
113 };
114
115 class EventTagMifareClassicRestore : public EventTagMifareClassicBlockAction<EventTagMifareClassicRestore>
116 {
117         public:
118                 EventTagMifareClassicRestore(const int index) {setBlockIndex(index);}
119 };
120
121 typedef DPL::SharedPtr<EventTagMifareClassicAuthenticateWithKeyA> EventTagMifareClassicAuthenticateWithKeyAPtr;
122 typedef DPL::SharedPtr<EventTagMifareClassicAuthenticateWithKeyB> EventTagMifareClassicAuthenticateWithKeyBPtr;
123 typedef DPL::SharedPtr<EventTagMifareClassicReadBlock> EventTagMifareClassicReadBlockPtr;
124 typedef DPL::SharedPtr<EventTagMifareClassicWriteBlock> EventTagMifareClassicWriteBlockPtr;
125 typedef DPL::SharedPtr<EventTagMifareClassicIncrementBlockValue> EventTagMifareClassicIncrementBlockValuePtr;
126 typedef DPL::SharedPtr<EventTagMifareClassicDecrementBlockValue> EventTagMifareClassicDecrementBlockValuePtr;
127 typedef DPL::SharedPtr<EventTagMifareClassicTransfer> EventTagMifareClassicTransferPtr;
128 typedef DPL::SharedPtr<EventTagMifareClassicRestore> EventTagMifareClassicRestorePtr;
129
130 } // NFC
131 } // Api
132 } // TizenApis
133
134 #endif //WRTPLUGINS_API_NFC_EVENT_TAGMIFARECLASSIC_ACTION_H_