Fix XML Doc Build Warning for Nfc
[platform/core/csapi/tizenfx.git] / src / Tizen.Network.Nfc / Tizen.Network.Nfc / NfcSecureElement.cs
1 /*
2  * Copyright (c) 2016 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 using System;
18 using System.Runtime.InteropServices;
19 using System.Collections.Generic;
20
21 namespace Tizen.Network.Nfc
22 {
23     /// <summary>
24     /// The class for managing the Secure Element information.
25     /// </summary>
26     /// <since_tizen> 3 </since_tizen>
27     public class NfcSecureElement : IDisposable
28     {
29         private IntPtr _secureElementHandle = IntPtr.Zero;
30         private bool disposed = false;
31
32         internal NfcSecureElement(IntPtr handle)
33         {
34             _secureElementHandle = handle;
35         }
36
37         /// <summary>
38         /// NfcSecureElement destructor.
39         /// </summary>
40         ~NfcSecureElement()
41         {
42             Dispose(false);
43         }
44
45         /// <summary>
46         /// Dispose
47         /// </summary>
48         public void Dispose()
49         {
50             Dispose(true);
51             GC.SuppressFinalize(this);
52         }
53
54         private void Dispose(bool disposing)
55         {
56             if (disposed)
57                 return;
58
59             if (disposing)
60             {
61                 // Free managed objects.
62             }
63             //Free unmanaged objects
64             disposed = true;
65         }
66
67         /// <summary>
68         /// Sends the APDU (Application Protocol Data Unit) response to the CLF (Contactless Front-end).
69         /// </summary>
70         /// <since_tizen> 3 </since_tizen>
71         /// <param name="response">The bytes array of the response data.</param>
72         /// <param name="responseLength">The size of the response bytes array.</param>
73         /// <privilege>http://tizen.org/privilege/nfc.cardemulation</privilege>
74         /// <exception cref="NotSupportedException">Thrown when the NFC is not supported.</exception>
75         /// <exception cref="ArgumentException">Thrown when the method fails due to an invalid parameter.</exception>
76         /// <exception cref="InvalidOperationException">Thrown when the method fails due to an invalid operation.</exception>
77         public void HceSendApduResponse(byte[] response, uint responseLength)
78         {
79             int ret = Interop.Nfc.CardEmulation.HceSendApduRespondse(_secureElementHandle, response, responseLength);
80             if (ret != (int)NfcError.None)
81             {
82                 Log.Error(Globals.LogTag, "Failed to hcd send apdu response, Error - " + (NfcError)ret);
83                 NfcErrorFactory.ThrowNfcException(ret);
84             }
85         }
86
87         internal IntPtr GetHandle()
88         {
89             return _secureElementHandle;
90         }
91     }
92 }