df62570bc6b983f5b2c36c5d18fe9560221b7ebf
[framework/web/wrt-plugins-tizen.git] / src / NFC / NFCDefaultAdapter.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
20 #ifndef _NFCDEFAULTADAPTER_H_
21 #define _NFCDEFAULTADAPTER_H_
22
23 #include <vector>
24 #include <dpl/shared_ptr.h>
25 #include <dpl/singleton.h>
26 #include <Commons/Emitters.h>
27
28 #include "EventNFCChanged.h"
29 #include "NFCAdapter.h"
30
31
32 namespace DeviceAPI {
33 namespace NFC {
34 class NFCDefaultAdapter
35 {
36     public:
37                 NFCDefaultAdapter();
38         virtual  ~NFCDefaultAdapter();
39
40 public:
41      /**
42      * watchNFCTag
43      */
44         int setTagListener(NFCAdapter* adapter);
45         int setPeerListener(NFCAdapter * adapter);
46         /**
47      * clearWatch
48      */
49         void unsetTagListener(NFCAdapter * adapter);
50         void unsetPeerListener(NFCAdapter * adapter);
51
52         void NFCTagHasDetected(void *props);
53         void NFCTargetHasDetected(void *props);
54
55         void *getCachedMessage();
56         void getCurrentNFC();
57
58         bool getPowerState();
59         void setPowered(const bool state, NFCAdapter * adapter);
60         void setPoweredManualAnswer(int error);
61
62         EventNFCSEType getSEType();
63         void setCardEmulation(const EventNFCSEType seType, NFCAdapter * adapter);
64         void setCardEmulationManualAnswer(int error, void *adapter);
65
66         void setCardEmulationChangeListener(NFCAdapter *adapter);
67         void seChanged();
68         void unsetCardEmulationChangeListener(NFCAdapter * adapter);
69
70         bool isSupported();
71         void deinitialze();
72 private:
73         /**
74      * Initialize NFC.
75      */
76         int initialize();
77
78         std::vector<NFCAdapter *> m_NFCTagListeners;
79         std::vector<NFCAdapter *> m_NFCTargetListeners;
80         std::vector<NFCAdapter *> m_NFCChangedSETypes;
81          
82         NFCAdapter * m_poweredAdapter;
83         bool m_initialized;
84         EventNFCSEType m_seType;
85
86         friend class DPL::Singleton<NFCDefaultAdapter>;
87
88 };
89 typedef DPL::Singleton<NFCDefaultAdapter> NFCDefaultAdapterSingleton;
90
91 }
92 }
93
94 #endif /* _NFCDEFAULTADAPTER_H_ */