#ifdef __cplusplus
namespace smartcard_service_api
{
- class ClientChannel: public Channel
+ class ClientChannel : public Channel
{
- private:
+private:
void *context;
void *handle;
void *proxy;
static void channel_close_cb(GObject *source_object,
GAsyncResult *res, gpointer user_data);
- public:
+public:
int close(closeChannelCallback callback, void *userParam);
int transmit(const ByteArray &command,
transmitCallback callback, void *userParam);
- bool selectNext(){ return false; }
+ bool selectNext() { return false; }
void closeSync()
throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
ErrorIllegalParameter &, ErrorSecurity &);
- void *getHandle(){ return handle; }
+ void *getHandle() { return handle; }
friend class Session;
};
#endif /* __cplusplus */
int channel_is_basic_channel(channel_h handle, bool* is_basic_channel);
-int channel_is_closed(channel_h handle, bool* is_closed );
+int channel_is_closed(channel_h handle, bool* is_closed);
int channel_get_session(channel_h handle, int *session_handle);
int channel_close_sync(channel_h handle);
int channel_transmit_sync(channel_h handle, unsigned char *command,
#ifdef __cplusplus
namespace smartcard_service_api
{
- class Reader: public ReaderHelper
+ class Reader : public ReaderHelper
{
- private:
+private:
void *context;
void *handle;
void *proxy;
static void reader_open_session_cb(GObject *source_object,
GAsyncResult *res, gpointer user_data);
- public:
+public:
void closeSessions()
throw(ErrorIO &, ErrorIllegalState &);
throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
ErrorIllegalParameter &, ErrorSecurity &);
- void *getHandle(){ return handle; }
+ void *getHandle() { return handle; }
friend class SEService;
};
class SEService : public SEServiceHelper
{
- private:
+private:
unsigned int handle;
void *context;
serviceConnected handler;
static void se_service_cb(GObject *source_object,
GAsyncResult *res, gpointer user_data);
- public:
+public:
SEService(void *user_data, serviceConnected handler)
throw(ErrorIO &, ErrorIllegalParameter &);
SEService(void *user_data, SEServiceListener *listener)
class SEServiceListener
{
- public:
+public:
virtual void serviceConnected(SEServiceHelper *service,
void *context) = 0;
virtual void eventHandler(SEServiceHelper *service,
{
class Reader;
- class Session : public SessionHelper
+ class Session:public SessionHelper
{
- private:
+private:
void *context;
void *handle;
void *proxy;
~Session();
int openChannel(int id, const ByteArray &aid, openChannelCallback callback, void *userData);
-
+
Channel *openChannelSync(int id, const ByteArray &aid)
throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
ErrorIllegalParameter &, ErrorSecurity &);
static void session_close_cb(GObject *source_object,
GAsyncResult *res, gpointer user_data);
- public:
+public:
void closeChannels()
throw(ErrorIO &, ErrorIllegalState &);
Channel *openLogicalChannelSync(const unsigned char *aid, unsigned int length)
throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
- ErrorIllegalParameter &, ErrorSecurity &);
+ ErrorIllegalParameter &, ErrorSecurity &);
Channel *openBasicChannelSync(const ByteArray &aid, unsigned char P2)
throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
ErrorIllegalParameter &, ErrorSecurity &);
size_t getChannelCount() const;
- void *getHandle(){ return handle; }
+ void *getHandle() { return handle; }
friend class Reader;
};
{
if (isClosed() == false)
{
- if (getSession()->getReader()->isSecureElementPresent() == true)
- {
+ if (getSession()->getReader()->isSecureElementPresent() == true) {
gint ret;
GError *error = NULL;
throw ErrorIO(SCARD_ERROR_IPC_FAILED);
}
- }
- else
- {
+ } else {
_INFO("unavailable channel");
}
}
{
int result = SCARD_ERROR_OK;
- if (isClosed() == false)
- {
- if (getSession()->getReader()->isSecureElementPresent() == true)
- {
+ if (isClosed() == false) {
+ if (getSession()->getReader()->isSecureElementPresent() == true) {
CallbackParam *param = new CallbackParam();
param->instance = this;
GPOINTER_TO_UINT(context),
GPOINTER_TO_UINT(handle), NULL,
&ClientChannel::channel_close_cb, param);
- }
- else
- {
+ } else {
_ERR("unavailable channel");
result = SCARD_ERROR_ILLEGAL_STATE;
}
{
int rv = SCARD_ERROR_OK;
- if (getSession()->getReader()->isSecureElementPresent() == true)
- {
+ if (getSession()->getReader()->isSecureElementPresent() == true) {
GVariant *var_command = NULL, *var_response = NULL;
GError *error = NULL;
GPOINTER_TO_UINT(handle),
var_command, &rv, &var_response,
NULL, &error) == true) {
-
if (rv == SCARD_ERROR_OK) {
GDBusHelper::convertVariantToByteArray(var_response, transmitResponse);
result = transmitResponse;
throw ErrorIO(SCARD_ERROR_IPC_FAILED);
}
- }
- else
- {
+ } else {
_ERR("unavailable channel");
throw ErrorIllegalState(SCARD_ERROR_UNAVAILABLE);
}
{
int result;
- if (getSession()->getReader()->isSecureElementPresent() == true)
- {
+ if (getSession()->getReader()->isSecureElementPresent() == true) {
GVariant *var_command;
CallbackParam *param = new CallbackParam();
&ClientChannel::channel_transmit_cb, param);
result = SCARD_ERROR_OK;
- }
- else
- {
+ } else {
_ERR("unavailable channel");
result = SCARD_ERROR_ILLEGAL_STATE;
}
using namespace std;
/* below functions will be called when dlopen or dlclose is called */
-void __attribute__ ((constructor)) lib_init()
+void __attribute__((constructor)) lib_init()
{
/* remove for deprecated-declarations build warning: glib ver > 2.36 */
#if !GLIB_CHECK_VERSION (2, 35, 0)
#endif
}
-void __attribute__ ((destructor)) lib_fini()
+void __attribute__((destructor)) lib_fini()
{
}
{
Session *session = NULL;
- if (isSecureElementPresent() == true)
- {
+ if (isSecureElementPresent() == true) {
gint result;
GError *error = NULL;
guint session_id;
THROW_ERROR(SCARD_ERROR_IPC_FAILED);
}
- }
- else
- {
+ } else {
_ERR("unavailable reader");
throw ErrorIllegalState(SCARD_ERROR_UNAVAILABLE);
}
_BEGIN();
- if (isSecureElementPresent() == true)
- {
+ if (isSecureElementPresent() == true) {
CallbackParam *param = new CallbackParam();
param->instance = this;
NULL, &Reader::reader_open_session_cb, param);
result = SCARD_ERROR_OK;
- }
- else
- {
+ } else {
_ERR("unavailable reader");
result = SCARD_ERROR_ILLEGAL_STATE;
}
/* add readers */
reader = new Reader(service->context,
reader_name, GUINT_TO_POINTER(reader_id));
- if (reader != NULL)
- {
+
+ if (reader != NULL) {
service->readers.push_back(reader);
- }
- else
- {
+ } else {
_ERR("alloc failed");
}
- if (service->listener != NULL)
- {
+ if (service->listener != NULL) {
service->listener->eventHandler(service,
reader_name, 1, service->context);
- }
- else if (service->event_handler != NULL)
- {
+ } else if (service->event_handler != NULL) {
service->event_handler(reader_id, 1, service->context);
- }
- else
- {
+ } else {
_DBG("listener is null");
}
}
}
}
- if (service->listener != NULL)
- {
+ if (service->listener != NULL) {
service->listener->eventHandler(service,
reader_name, 2, service->context);
- }
- else if (service->event_handler != NULL)
- {
+ } else if (service->event_handler != NULL) {
service->event_handler(reader_id, 2, service->context);
- }
- else
- {
+ } else {
_DBG("listener is null");
}
}
if(smartcard_service_se_service_call_se_service_sync(
(SmartcardServiceSeService *)proxy, &result, &handle, &readers, NULL, &error) == true)
{
- if (result == SCARD_ERROR_OK)
- {
+ if (result == SCARD_ERROR_OK) {
service->connected = true;
service->handle = handle;
service->parseReaderInformation(readers);
- }
- else
- {
+ } else {
_ERR("Initialize error : %d", result);
}
}
/* request reader */
if(smartcard_service_se_service_call_se_service_sync(
- (SmartcardServiceSeService *)proxy, &result, &handle, &readers, NULL, &error) == true)
- {
- if (result == SCARD_ERROR_OK)
- {
+ (SmartcardServiceSeService *)proxy, &result, &handle, &readers, NULL, &error) == true) {
+ if (result == SCARD_ERROR_OK) {
service->connected = true;
service->handle = handle;
service->parseReaderInformation(readers);
- }
- else
- {
+ } else {
throw ExceptionBase(result);
}
- }
- else
- {
+ } else {
_ERR("smartcard_service_se_service_call_se_service failed, [%s]", error->message);
g_error_free(error);
int temp = 0;
temp_readers = service->getReaders();
- if(temp_readers.size() > 0)
- {
+ if (temp_readers.size() > 0) {
*readers = (int *)calloc(temp_readers.size(), sizeof(int));
if(*readers == NULL)
for (i = 0; i < temp_readers.size(); i++)
{
- if (temp_readers[i]->isSecureElementPresent())
- {
+ if (temp_readers[i]->isSecureElementPresent()) {
(*readers)[i] = (long)temp_readers[i];
temp++;
}
}
*count = temp;
- }
- else
- {
+ } else {
*count = 0;
}
channels.clear();
}
- void Session::closeChannels() throw (ErrorIO &, ErrorIllegalState &)
+ void Session::closeChannels() throw(ErrorIO &, ErrorIllegalState &)
{
size_t i;
}
const ByteArray Session::getATRSync()
- throw (ExceptionBase &, ErrorIO &, ErrorSecurity &,
+ throw(ExceptionBase &, ErrorIO &, ErrorSecurity &,
ErrorIllegalState &, ErrorIllegalParameter &)
{
ByteArray result;
- if (getReader()->isSecureElementPresent() == true)
- {
+ if (getReader()->isSecureElementPresent() == true) {
if (atr.isEmpty() == true)
{
gint ret;
}
result = atr;
- }
- else
- {
+ } else {
_ERR("unavailable session");
throw ErrorIllegalState(SCARD_ERROR_UNAVAILABLE);
}
{
int result;
- if (getReader()->isSecureElementPresent() == true)
- {
- if (atr.isEmpty() == true)
- {
+ if (getReader()->isSecureElementPresent() == true) {
+ if (atr.isEmpty() == true) {
CallbackParam *param = new CallbackParam();
param->instance = this;
&Session::session_get_atr_cb, param);
result = SCARD_ERROR_OK;
- }
- else
- {
+ } else {
result = SCARD_ERROR_OK;
/* TODO : invoke callback directly */
callback(atr.getBuffer(),
atr.size(), 0, userData);
}
- }
- else
- {
+ } else {
_ERR("unavailable session");
result = SCARD_ERROR_ILLEGAL_STATE;
}
}
void Session::closeSync()
- throw (ExceptionBase &, ErrorIO &, ErrorSecurity &,
+ throw(ExceptionBase &, ErrorIO &, ErrorSecurity &,
ErrorIllegalState &, ErrorIllegalParameter &)
{
if (isClosed() == false)
{
size_t count = 0;
- if (getReader()->isSecureElementPresent() == true)
- {
+ if (getReader()->isSecureElementPresent() == true) {
count = channels.size();
- }
- else
- {
+ } else {
_ERR("unavailable session");
throw ErrorIllegalState(SCARD_ERROR_UNAVAILABLE);
}
return count;
}
Channel *Session::openChannelSync(int id, const ByteArray &aid)
- throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+ throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
ErrorIllegalParameter &, ErrorSecurity &)
{
return openChannelSync(id, aid, 0x00);
}
Channel *Session::openChannelSync(int id, const ByteArray &aid, unsigned char P2)
- throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+ throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
ErrorIllegalParameter &, ErrorSecurity &)
{
Channel *channel = NULL;
- if (getReader()->isSecureElementPresent() == true)
- {
+ if (getReader()->isSecureElementPresent() == true) {
gint ret;
GVariant *var_aid = NULL, *var_response = NULL;
guint channel_id;
channel = new ClientChannel(context,
this, channel_number,
response, GUINT_TO_POINTER(channel_id));
- if (channel != NULL)
- {
+ if (channel != NULL) {
channels.push_back(channel);
- }
- else
- {
+ } else {
_ERR("alloc failed");
THROW_ERROR(SCARD_ERROR_OUT_OF_MEMORY);
THROW_ERROR(SCARD_ERROR_IPC_FAILED);
}
- }
- else
- {
+ } else {
_ERR("unavailable session");
throw ErrorIllegalState(SCARD_ERROR_UNAVAILABLE);
{
int result;
- if (getReader()->isSecureElementPresent() == true)
- {
+ if (getReader()->isSecureElementPresent() == true) {
GVariant *var_aid;
CallbackParam *param = new CallbackParam();
&Session::session_open_channel_cb, param);
result = SCARD_ERROR_OK;
- }
- else
- {
+ } else {
_ERR("unavailable session");
result = SCARD_ERROR_ILLEGAL_STATE;
}
}
Channel *Session::openBasicChannelSync(const ByteArray &aid)
- throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+ throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
ErrorIllegalParameter &, ErrorSecurity &)
{
return openChannelSync(0, aid, 0x00);
}
Channel *Session::openBasicChannelSync(const ByteArray &aid, unsigned char P2)
- throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+ throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
ErrorIllegalParameter &, ErrorSecurity &)
{
return openChannelSync(0, aid, P2);
}
Channel *Session::openBasicChannelSync(const unsigned char *aid, unsigned int length)
- throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+ throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
ErrorIllegalParameter &, ErrorSecurity &)
{
ByteArray temp(aid, length);
}
Channel *Session::openBasicChannelSync(const unsigned char *aid, unsigned int length, unsigned char P2)
- throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+ throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
ErrorIllegalParameter &, ErrorSecurity &)
{
ByteArray temp(aid, length);
}
Channel *Session::openLogicalChannelSync(const ByteArray &aid)
- throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+ throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
ErrorIllegalParameter &, ErrorSecurity &)
{
return openChannelSync(1, aid, 0x00);
}
Channel *Session::openLogicalChannelSync(const ByteArray &aid, unsigned char P2)
- throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+ throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
ErrorIllegalParameter &, ErrorSecurity &)
{
return openChannelSync(1, aid, P2);
}
Channel *Session::openLogicalChannelSync(const unsigned char *aid, unsigned int length)
- throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+ throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
ErrorIllegalParameter &, ErrorSecurity &)
{
ByteArray temp(aid, length);
}
Channel *Session::openLogicalChannelSync(const unsigned char *aid, unsigned int length, unsigned char P2)
- throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+ throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
ErrorIllegalParameter &, ErrorSecurity &)
{
ByteArray temp(aid, length);