Tizen Native API  4.0

The Reader API provides functions to reader.

Required Header

#include <smartcard.h>

Related Features

This API is related with the following features:

You can check if a device supports the related features for this API by using System Information, thereby controlling the procedure of your application.

To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.

More details on featuring your application can be found from Feature Element.

Functions

int smartcard_reader_get_name (int reader, char **reader_name)
 Returns the name of the given reader.
int smartcard_reader_is_secure_element_present (int reader, bool *is_present)
 Checks if a Secure Element is present in the given reader.
int smartcard_reader_open_session (int reader, int *session)
 Connects to a Secure Element in the given reader.
int smartcard_reader_close_sessions (int reader)
 Closes all the sessions opened on the given reader.
int smartcard_reader_set_event_cb (smartcard_reader_event_cb cb, void *user_data)
 Sets a callback function for receiving reader event.
int smartcard_reader_unset_event_cb (void)
 Unsets the reader event callback function.

Typedefs

typedef void(* smartcard_reader_event_cb )(int reader, smartcard_reader_event_type_e event_type, void *user_data)
 Called when a smartcard reader event occurs.

Typedef Documentation

typedef void(* smartcard_reader_event_cb)(int reader, smartcard_reader_event_type_e event_type, void *user_data)

Called when a smartcard reader event occurs.

Since :
3.0
Parameters:
[in]readerThe reader handle
[in]event_typeThe reader event type
[in]user_dataThe user data passed from the callback registration function
See also:
smartcard_reader_set_event_cb()
smartcard_reader_unset_event_cb()

Enumeration Type Documentation

Enumerations for Smartcard reader event type.

Since :
3.0
Enumerator:
SMARTCARD_READER_EVENT_TYPE_IO_ERROR 

This event notifies the application that I/O error occurs on smartcard reader

SMARTCARD_READER_EVENT_TYPE_INSERTED 

This event notifies the application that smartcard reader is inserted

SMARTCARD_READER_EVENT_TYPE_REMOVED 

This event notifies the application that smartcard reader is removed


Function Documentation

int smartcard_reader_close_sessions ( int  reader)

Closes all the sessions opened on the given reader.

All the channels opened by all these sessions will be closed.

Since :
2.3.1
Privilege Level:
public
Privilege:
http://tizen.org/privilege/secureelement
Parameters:
[in]readerHandle to the reader
Returns:
0 on success, otherwise a negative error value.
Return values:
SMARTCARD_ERROR_NONESuccessful
SMARTCARD_ERROR_GENERALA general error occurred
SMARTCARD_ERROR_INVALID_PARAMETERInvalid function parameter
SMARTCARD_ERROR_IO_ERRORI/O error
SMARTCARD_ERROR_NOT_INITIALIZEDSmartcard service not initialized
SMARTCARD_ERROR_NOT_SUPPORTEDNot supported
SMARTCARD_ERROR_PERMISSION_DENIEDPermission denied
See also:
smartcard_get_readers()
int smartcard_reader_get_name ( int  reader,
char **  reader_name 
)

Returns the name of the given reader.

Since :
2.3.1
Remarks:
reader_name must be released using free().
If the reader is a SIM reader, then its name must be "SIM[Slot]"
If the reader is a SD or micro SD reader, then its name must be "SD[slot]"
If the reader is a embedded SE reader, then its name must be "eSE[slot]"
Parameters:
[in]readerHandle to the reader
[out]reader_nameThe name of reader
Returns:
0 on success, otherwise a negative error value.
Return values:
SMARTCARD_ERROR_NONESuccessful
SMARTCARD_ERROR_GENERALA general error occurred
SMARTCARD_ERROR_INVALID_PARAMETERInvalid function parameter
SMARTCARD_ERROR_NOT_INITIALIZEDSmartcard service not initialized
SMARTCARD_ERROR_NOT_SUPPORTEDNot supported
See also:
smartcard_get_readers()
int smartcard_reader_is_secure_element_present ( int  reader,
bool *  is_present 
)

Checks if a Secure Element is present in the given reader.

Since :
2.3.1
Parameters:
[in]readerHandle to the reader
[out]is_presentTrue or false depending whether a secure element is present in the reader - undefined when an error is returned
Returns:
0 on success, otherwise a negative error value.
Return values:
SMARTCARD_ERROR_NONESuccessful
SMARTCARD_ERROR_GENERALA general error occurred
SMARTCARD_ERROR_INVALID_PARAMETERInvalid function parameter
SMARTCARD_ERROR_NOT_INITIALIZEDSmartcard service not initialized
SMARTCARD_ERROR_NOT_SUPPORTEDNot supported
See also:
smartcard_get_readers()
int smartcard_reader_open_session ( int  reader,
int *  session 
)

Connects to a Secure Element in the given reader.

Since :
2.3.1
Privilege Level:
public
Privilege:
http://tizen.org/privilege/secureelement
Parameters:
[in]readerHandle to the reader
[out]sessionHandle to the session created for the given reader
Returns:
0 on success, otherwise a negative error value.
Return values:
SMARTCARD_ERROR_NONESuccessful
SMARTCARD_ERROR_GENERALA general error occurred
SMARTCARD_ERROR_INVALID_PARAMETERInvalid function parameter
SMARTCARD_ERROR_IO_ERRORI/O error
SMARTCARD_ERROR_NOT_INITIALIZEDSmartcard service not initialized
SMARTCARD_ERROR_NOT_SUPPORTEDNot supported
SMARTCARD_ERROR_PERMISSION_DENIEDPermission denied
See also:
smartcard_get_readers()
int smartcard_reader_set_event_cb ( smartcard_reader_event_cb  cb,
void *  user_data 
)

Sets a callback function for receiving reader event.

Since :
3.0
Parameters:
[in]cbThe reader event callback
[in]user_dataThe user data
Returns:
0 on success, otherwise a negative error value.
Return values:
SMARTCARD_ERROR_NONESuccessful
SMARTCARD_ERROR_INVALID_PARAMETERInvalid function parameter
SMARTCARD_ERROR_NOT_INITIALIZEDSmartcard service not initialized
SMARTCARD_ERROR_NOT_SUPPORTEDNot supported
See also:
smartcard_reader_unset_event_cb()

Unsets the reader event callback function.

Since :
3.0
Returns:
0 on success, otherwise a negative error value.
Return values:
SMARTCARD_ERROR_NONESuccessful
SMARTCARD_ERROR_NOT_INITIALIZEDSmartcard service not initialized
SMARTCARD_ERROR_NOT_SUPPORTEDNot supported
See also:
smartcard_reader_set_event_cb()