2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file FNetNfcTagConnection.h
19 * @brief This is the header file for the %TagConnection class.
21 * This header file contains the declarations of the %TagConnection class.
24 #ifndef _FNET_NFC_TAG_CONNECTION_H_
25 #define _FNET_NFC_TAG_CONNECTION_H_
27 #include <FBaseObject.h>
28 #include <FBaseResult.h>
30 namespace Tizen { namespace Base
35 namespace Tizen { namespace Net { namespace Nfc
39 class _TagConnectionImpl;
40 class ITagConnectionListener;
43 * @class TagConnection
44 * @brief This class represents the connection with an NFC tag. It provides the mechanism to communicate with the NFC
45 * tag through ISO14443 or a general Radio Frequency Identification (RFID) manner.
49 * The %TagConnection class represents the connection with an NFC tag. It provides the mechanism to communicate with
50 * the NFC tag through ISO14443 or a general Radio Frequency Identification (RFID) manner. @n
51 * The class has an NfcTag instance that represents the target tag. This class can be inherited by the
52 * NdefTagConnection class if the target tag supports the NFC Data Exchange Format (NDEF) operations.
54 * For more information on the class features, see
55 * <a href="../org.tizen.native.appprogramming/html/guide/net/nfc.htm">NFC Guide</a>.
57 * The following example demonstrates how to use the %TagConnection class.
64 * : public Tizen::Net::Nfc::INfcManagerEventListener
65 * , public Tizen::Net::Nfc::INfcTagDiscoveryEventListener
66 * , public Tizen::Net::Nfc::ITagConnectionListener
69 * // Method declarations are hidden for the sake of simplicity.
72 * Tizen::Net::Nfc::NfcManager* __pNfcManager;
73 * Tizen::Net::Nfc::TagConnection* __pConnection;
77 * #include "MyClass.h"
79 * using namespace Tizen::Net::Nfc;
81 * MyClass::MyClass(void)
82 * : __pNfcManager(null)
83 * , __pConnection(null)
85 * __pNfcManager = new NfcManager();
88 * MyClass::~MyClass(void)
90 * // Removes the tag discovery event listener for the ISO14443-4 tag type.
91 * __pNfcManager->RemoveTagDiscoveryEventListener(*this, NFC_TAG_TYPE_ISO14443_4);
93 * delete __pNfcManager;
97 * MyClass::SendApduCommandSample(void)
99 * // Creates an instance of NfcManager and registers the manager event listener
100 * __pNfcManager->Construct(*this);
102 * // Adds the tag discovery event listener for the ISO14443-4 tag type
103 * __pNfcManager->AddTagDiscoveryEventListener(*this, NFC_TAG_TYPE_ISO14443_4);
106 * // This method is invoked when a new ISO14443-4 tag like a Mifare DESFire is detected
108 * MyClass::OnNfcTagDetectedN(TagConnection* pConnection)
110 * // Checks whether the connection supports ISO14443-4,
111 * // but the evaluation result of the below code is always true in this example
112 * if (pConnection->GetTargetTag()->HasTagType(NFC_TAG_TYPE_ISO14443_4))
114 * __pConnection = pConnection;
116 * // Registers the tag connection listener
117 * __pConnection->SetTagConnectionListener(this);
119 * Tizen::Base::ByteBuffer command;
120 * // Makes an APDU(ISO7816-4) command here
122 * __pConnection->SendCommand(command);
126 * // This method is invoked when the target tag is lost
128 * MyClass::OnNfcTagLost(void)
130 * // The acquired TagConnection should be deallocated
131 * delete __pConnection;
134 * // This method is invoked when the response of the command is received
136 * MyClass::OnNfcResponseReceivedN(Tizen::Base::ByteBuffer* pResponse, result r)
138 * if (r == E_SUCCESS)
140 * // Uses the response data here
142 * // Deallocates the response data
148 class _OSP_EXPORT_ TagConnection
149 : public Tizen::Base::Object
153 * Checks whether the connection supports the NDEF message operations.
157 * @return @c true if the connection supports the NDEF message operations, @n
160 virtual bool IsNdefConnection(void) const;
163 * Gets the target tag object with which this connection is established.
167 * @return The tag object
169 const NfcTag* GetTargetTag(void) const;
172 * Sets a listener for receiving the response of the command sent on this tag connection.
176 * @return An error code
177 * @param[in] pListener The listener to add
178 * @exception E_SUCCESS The method is successful.
179 * @exception E_SYSTEM A system error has occurred.
180 * @remarks Only one event listener can be registered. If the input parameter is @c null, the listener that is
181 * already registered gets unregistered.
183 result SetTagConnectionListener(ITagConnectionListener* pListener);
186 * Sends the specified @c command to the target tag.
190 * @return An error code
191 * @param[in] command The command to send
192 * @exception E_SUCCESS The method is successful.
193 * @exception E_INVALID_ARG The input @c command is invalid.
194 * @exception E_IN_PROGRESS The previous send request is in progress.
195 * @exception E_CONNECTION_BUSY The connection is busy. Therefore, the method cannot process the send request.
196 * @exception E_CONNECTION_FAILED The connection to the tag is closed or it has failed.
197 * @exception E_SYSTEM A system error has occurred.
198 * @see ITagConnectionListener::OnNfcResponseReceivedN()
200 result SendCommand(const Tizen::Base::ByteBuffer& command);
203 * This destructor overrides Tizen::Base::Object::~Object().
207 virtual ~TagConnection(void);
211 // This method is for internal use only. Using this method can cause behavioral, security-related,
212 // and consistency-related issues in the application.
214 // This is the default constructor for this class.
221 // This method is for internal use only. Using this method can cause behavioral, security-related,
222 // and consistency-related issues in the application.
224 // This method is reserved and may change its name at any time without prior notice.
228 virtual void TagConnection_Reserved1(void) {}
231 // This method is for internal use only. Using this method can cause behavioral, security-related,
232 // and consistency-related issues in the application.
234 // This method is reserved and may change its name at any time without prior notice.
238 virtual void TagConnection_Reserved2(void) {}
241 // This method is for internal use only. Using this method can cause behavioral, security-related,
242 // and consistency-related issues in the application.
244 // This method is reserved and may change its name at any time without prior notice.
248 virtual void TagConnection_Reserved3(void) {}
252 // The implementation of this copy constructor is intentionally blank to prohibit copying of objects.
254 TagConnection(const TagConnection& value);
257 // The implementation of this copy assignment operator is intentionally blank to prohibit copying of objects.
259 TagConnection& operator =(const TagConnection& value);
263 // This variable is for internal use only. Using this variable can cause behavioral,
264 // security-related, and consistency-related issues in the application.
266 // The point for indicating the implementation object.
270 _TagConnectionImpl* _pImpl;
272 friend class _TagConnectionImpl;
276 } } } // Tizen::Net::Nfc
278 #endif // _FNET_NFC_TAG_CONNECTION_H_