File: BEID_ReaderContext.cs

package info (click to toggle)
beid 3.5.2.dfsg-10
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 147,240 kB
  • ctags: 34,507
  • sloc: cpp: 149,944; ansic: 41,577; java: 8,927; cs: 6,528; sh: 2,426; perl: 1,866; xml: 805; python: 463; makefile: 263; lex: 92
file content (318 lines) | stat: -rw-r--r-- 12,667 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 1.3.35
 *
 * Do not make changes to this file unless you know what you are doing--modify
 * the SWIG interface file instead.
 * ----------------------------------------------------------------------------- */

namespace be.belgium.eid {

using System;
using System.Runtime.InteropServices;

/// <summary>
/// This class represent a reader.
/// You get reader object from the ReaderSet 
///     either by its index (getReaderByNum) or by its name (getReaderByName).
/// Once you have a reader object, you can check if a card is present (isCardPresent).
/// Then you can ask which type of card is in the reader with getCardType()
///		and then get a card object using one of this method :
///			getCard, getEIDCard, getKidsCard, getForeignerCard or getSISCard.
/// </summary>
public class BEID_ReaderContext : BEID_Object
    {
  private HandleRef swigCPtr;

  internal BEID_ReaderContext(IntPtr cPtr, bool cMemoryOwn) : base(beidlib_dotNetPINVOKE.BEID_ReaderContextUpcast(cPtr), cMemoryOwn) {
    swigCPtr = new HandleRef(this, cPtr);
  }

  internal static HandleRef getCPtr(BEID_ReaderContext obj) {
    return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
  }

  ~BEID_ReaderContext() {
    Dispose();
  }

  public override void Dispose() {
    lock(this) {
      if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) {
        swigCMemOwn = false;
        beidlib_dotNetPINVOKE.delete_BEID_ReaderContext(swigCPtr);
      }
      swigCPtr = new HandleRef(null, IntPtr.Zero);
      GC.SuppressFinalize(this);
      base.Dispose();
    }
  }

  /// <summary>
  /// Construct using a fileType and fileName.
  /// </summary>
  /// <remarks>
  /// No physical reader are connected.
  /// </remarks>
  public BEID_ReaderContext(BEID_FileType fileType, string fileName)
      : this(beidlib_dotNetPINVOKE.new_BEID_ReaderContext__SWIG_0((int)fileType, fileName), true)
  {
    if (beidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw beidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
  }

  /// <summary>
  /// Construct using a fileType and its content (for compatibility with SetRawFile).
  /// </summary>
  /// <remarks>
  /// No physical reader are connected.
  /// </remarks>
  public BEID_ReaderContext(BEID_FileType fileType, BEID_ByteArray data)
      : this(beidlib_dotNetPINVOKE.new_BEID_ReaderContext__SWIG_1((int)fileType, BEID_ByteArray.getCPtr(data)), true)
  {
    if (beidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw beidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
  }

  /// <summary>
  /// Construct using Raw data for Eid.
  /// </summary>
  /// <remarks>
  /// No physical reader are connected.
  /// </remarks>
  public BEID_ReaderContext(BEID_RawData_Eid data)
      : this(beidlib_dotNetPINVOKE.new_BEID_ReaderContext__SWIG_2(BEID_RawData_Eid.getCPtr(data)), true)
  {
    if (beidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw beidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
  }

  /// <summary>
  /// Construct using Raw data for Sis.
  /// </summary>
  /// <remarks>
  /// No physical reader are connected.
  /// </remarks>
  public BEID_ReaderContext(BEID_RawData_Sis data)
      : this(beidlib_dotNetPINVOKE.new_BEID_ReaderContext__SWIG_3(BEID_RawData_Sis.getCPtr(data)), true)
  {
    if (beidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw beidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
  }

  /// <summary>Return the name of the reader.</summary>
  public string getName() {
    string ret = beidlib_dotNetPINVOKE.BEID_ReaderContext_getName(swigCPtr);
    if (beidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw beidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>Return true if a card is present and false otherwise.</summary>
  public bool isCardPresent() {
    bool ret = beidlib_dotNetPINVOKE.BEID_ReaderContext_isCardPresent(swigCPtr);
    if (beidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw beidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>Release the card.</summary>
  /// <param name="bAllReference">
  /// If true all the invalid reference/pointer are destroyed.
  /// PUT THIS PARAMETER TO TRUE IS THREAD UNSAFE. 
  /// You have to be sure that you will not use any old reference/pointer after this release
  /// </param>
  public void releaseCard(bool bAllReference)
  {
    beidlib_dotNetPINVOKE.BEID_ReaderContext_releaseCard__SWIG_0(swigCPtr, bAllReference);
    if (beidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw beidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
  }

  /// <summary>Release the card.</summary>
  public void releaseCard()
  {
    beidlib_dotNetPINVOKE.BEID_ReaderContext_releaseCard__SWIG_1(swigCPtr);
    if (beidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw beidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
  }

  /// <summary>Return true if a card has changed since the last called (with the same ulOldId parameter).</summary>
  public bool isCardChanged(ref uint ulOldId) {
    bool ret = beidlib_dotNetPINVOKE.BEID_ReaderContext_isCardChanged(swigCPtr, ref ulOldId);
    if (beidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw beidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary> 
  /// Return the type of the card in the reader.
  /// Throw BEID_ExNoCardPresent exception if no card is present. 
  /// </summary>
  public BEID_CardType getCardType()
  {
    BEID_CardType ret = (BEID_CardType)beidlib_dotNetPINVOKE.BEID_ReaderContext_getCardType(swigCPtr);
    if (beidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw beidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary> 
  /// Get the card in the reader.
  /// Instantiation is made regarding the type of the card 
  ///			(BEID_EIDCard, BEID_KidsCard, BEID_ForeignerCard or BEID_SISCard).
  /// </summary>
  /// <remarks>
  /// If no card is present in the reader, exception BEID_ExNoCardPresent is thrown.
  /// If the card type is not supported, exception BEID_ExCardTypeUnknown is thrown.
  /// </remarks>
  public BEID_Card getCard()
  { 
	BEID_CardType cardType=getCardType();

	switch(cardType)
	{
	case BEID_CardType.BEID_CARDTYPE_EID:			
	case BEID_CardType.BEID_CARDTYPE_KIDS:
	case BEID_CardType.BEID_CARDTYPE_FOREIGNER:
		return getEIDCard();			

	case BEID_CardType.BEID_CARDTYPE_SIS:			
		return getSISCard();			

    default:										
		throw new BEID_ExCardTypeUnknown();
	}
}

	/// <summary> 
	/// Get the EIDcard in the reader. 
	///		Instantiation is made regarding the type of the card 
	///			(BEID_EIDCard, BEID_KidsCard, BEID_ForeignerCard).
	/// </summary>
    /// <remarks>
	/// If no card is present in the reader, exception BEID_ExNoCardPresent is thrown.
	/// If the card is not an EIDcard, exception BEID_ExCardBadType is thrown.
    /// </remarks>
  public BEID_EIDCard getEIDCard() { 
	BEID_CardType cardType=getCardType();

	switch(cardType)
	{
	case BEID_CardType.BEID_CARDTYPE_EID:			
		BEID_EIDCard ret = new BEID_EIDCard(beidlib_dotNetPINVOKE.BEID_ReaderContext_getEIDCard(swigCPtr), false);	
		if (beidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw beidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
		return ret;

	case BEID_CardType.BEID_CARDTYPE_KIDS:			
		return getKidsCard();		

	case BEID_CardType.BEID_CARDTYPE_FOREIGNER:		
		return getForeignerCard();	

    default:										
		throw new BEID_ExCardBadType();
	}
}

  /// <summary> 
  /// Get the KidsCard in the reader.
  /// </summary>
  /// <remarks>
  /// If no card is present in the reader, exception BEID_ExNoCardPresent is thrown.
  /// If the card is not a KidsCard, exception BEID_ExCardBadType is thrown.
  /// </remarks>
  public BEID_KidsCard getKidsCard() {
    BEID_KidsCard ret = new BEID_KidsCard(beidlib_dotNetPINVOKE.BEID_ReaderContext_getKidsCard(swigCPtr), false);
    if (beidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw beidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary> 
  /// Get the ForeignerCard in the reader.
  /// </summary>
  /// <remarks>
  /// If no card is present in the reader, exception BEID_ExNoCardPresent is thrown.
  /// If the card is not a ForeignerCard, exception BEID_ExCardBadType is thrown.
  /// </remarks>
  public BEID_ForeignerCard getForeignerCard()
  {
    BEID_ForeignerCard ret = new BEID_ForeignerCard(beidlib_dotNetPINVOKE.BEID_ReaderContext_getForeignerCard(swigCPtr), false);
    if (beidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw beidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary> 
  /// Get the SISCard in the reader.
  /// </summary>
  /// <remarks>
  /// If no card is present in the reader, exception BEID_ExNoCardPresent is thrown.
  /// If the card is not a SISCard, exception BEID_ExCardBadType is thrown.
  /// </remarks>
  public BEID_SISCard getSISCard()
  {
    BEID_SISCard ret = new BEID_SISCard(beidlib_dotNetPINVOKE.BEID_ReaderContext_getSISCard(swigCPtr), false);
    if (beidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw beidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary> 
  /// Specify a callback function to be called each time a card is inserted/remove in/from this reader.
  /// </summary>
  /// <returns>A handle can be used to stop the callbacks when they are no longer needed</returns>
  public uint SetEventCallback(BEID_SetEventDelegate callback, IntPtr pvRef)
  { 
	beidlib_dotNetPINVOKE.CUSTOM_SetEventHelper.countRef++;	
	IntPtr ptrCount = new IntPtr(beidlib_dotNetPINVOKE.CUSTOM_SetEventHelper.countRef);

	//We add the references to the hash table
	beidlib_dotNetPINVOKE.CUSTOM_SetEventHelper.delegateRef callbackRef =  new beidlib_dotNetPINVOKE.CUSTOM_SetEventHelper.delegateRef();
	callbackRef.functionRef = callback;
	callbackRef.ptrRef = pvRef;
	callbackRef.handleRef = 0;
	beidlib_dotNetPINVOKE.CUSTOM_SetEventHelper.delegateRefs.Add(beidlib_dotNetPINVOKE.CUSTOM_SetEventHelper.countRef,callbackRef);

	//We call the SetEvent with the internal reference (countRef)
	uint ulRslt = beidlib_dotNetPINVOKE.BEID_ReaderContext_SetEventCallback(swigCPtr, 0, ptrCount);
	if (beidlib_dotNetPINVOKE.SWIGPendingException.Pending) 
	{
		beidlib_dotNetPINVOKE.CUSTOM_SetEventHelper.delegateRefs.Remove(callbackRef);
		throw beidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
	}
	else
	{
		callbackRef.handleRef = ulRslt;
	}

	return ulRslt; 
  }

  /// <summary>To tell that the callbacks are not longer needed.</summary>
  /// <param name="ulHandle">is the handle return by SetEventCallback</param>
  public void StopEventCallback(uint ulHandle) { 
	beidlib_dotNetPINVOKE.BEID_ReaderContext_StopEventCallback(swigCPtr, ulHandle);
	if (beidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw beidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
	
	//Remove ulHandle from delegateRefs 
	foreach(beidlib_dotNetPINVOKE.CUSTOM_SetEventHelper.delegateRef callbackRef in beidlib_dotNetPINVOKE.CUSTOM_SetEventHelper.delegateRefs.Values )
    {
      if(callbackRef.handleRef==ulHandle)
      {
          beidlib_dotNetPINVOKE.CUSTOM_SetEventHelper.delegateRefs.Remove(callbackRef);
          break;
      }
    }	
  }

  /// <summary>Begin a transaction with the reader.</summary>
  public void BeginTransaction() {
    beidlib_dotNetPINVOKE.BEID_ReaderContext_BeginTransaction(swigCPtr);
    if (beidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw beidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
  }

  /// <summary>End the transaction.</summary>
  public void EndTransaction() {
    beidlib_dotNetPINVOKE.BEID_ReaderContext_EndTransaction(swigCPtr);
    if (beidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw beidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
  }

  /// <summary>Return true if this is a virtual reader (create from a file).</summary>
  public bool isVirtualReader() {
    bool ret = beidlib_dotNetPINVOKE.BEID_ReaderContext_isVirtualReader(swigCPtr);
    if (beidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw beidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

}

}