Change the function type of 'getChannelCount'
authorWonkyu Kwon <wonkyu.kwon@samsung.com>
Tue, 23 Jul 2013 11:20:06 +0000 (20:20 +0900)
committerWonkyu Kwon <wonkyu.kwon@samsung.com>
Wed, 24 Jul 2013 08:56:39 +0000 (17:56 +0900)
Change-Id: I7a94042f71570ccc153857736d9b2097471c6588

client/Session.cpp
client/include/Session.h

index 61aa5a2..63a57d0 100644 (file)
@@ -506,52 +506,13 @@ namespace smartcard_service_api
                return result;
        }
 
-       unsigned int Session::getChannelCountSync()
+       size_t Session::getChannelCount() const
        {
-               unsigned int count = 0;
+               size_t count = 0;
 
                if (getReader()->isSecureElementPresent() == true)
                {
-#ifdef USE_GDBUS
                        count = channels.size();
-#else
-                       Message msg;
-                       int rv;
-
-                       channelCount = -1;
-#ifdef CLIENT_IPC_THREAD
-                       /* request channel handle from server */
-                       msg.message = Message::MSG_REQUEST_GET_CHANNEL_COUNT;
-                       msg.param1 = (unsigned long)handle;
-                       msg.error = (unsigned long)context; /* using error to context */
-                       msg.caller = (void *)this;
-                       msg.callback = (void *)this; /* if callback is class instance, it means synchronized call */
-
-                       syncLock();
-                       if (ClientIPC::getInstance().sendMessage(msg) == true)
-                       {
-                               rv = waitTimedCondition(0);
-                               if (rv != 0)
-                               {
-                                       _ERR("time over");
-                                       this->error = SCARD_ERROR_OPERATION_TIMEOUT;
-                               }
-
-                               count = channelCount;
-                       }
-                       else
-                       {
-                               _ERR("sendMessage failed");
-                               this->error = SCARD_ERROR_IPC_FAILED;
-                       }
-                       syncUnlock();
-
-                       if (this->error != SCARD_ERROR_OK)
-                       {
-                               ThrowError::throwError(this->error);
-                       }
-#endif
-#endif
                }
                else
                {
@@ -562,43 +523,6 @@ namespace smartcard_service_api
                return count;
        }
 
-       int Session::getChannelCount(getChannelCountCallback callback, void *userData)
-       {
-               int result;
-
-               if (getReader()->isSecureElementPresent() == true)
-               {
-#ifdef USE_GDBUS
-#else
-                       Message msg;
-
-                       msg.message = Message::MSG_REQUEST_GET_CHANNEL_COUNT;
-                       msg.param1 = (unsigned long)handle;
-                       msg.error = (unsigned long)context; /* using error to context */
-                       msg.caller = (void *)this;
-                       msg.callback = (void *)callback;
-                       msg.userParam = userData;
-
-                       if (ClientIPC::getInstance().sendMessage(msg) == true)
-                       {
-                               result = SCARD_ERROR_OK;
-                       }
-                       else
-                       {
-                               _ERR("sendMessage failed");
-                               result = SCARD_ERROR_IPC_FAILED;
-                       }
-#endif
-               }
-               else
-               {
-                       _ERR("unavailable session");
-                       result = SCARD_ERROR_ILLEGAL_STATE;
-               }
-
-               return result;
-       }
-
        Channel *Session::openChannelSync(int id, const ByteArray &aid)
                throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
                        ErrorIllegalParameter &, ErrorSecurity &)
@@ -1052,17 +976,6 @@ EXTERN_API int session_open_logical_channel(session_h handle, unsigned char *aid
        return result;
 }
 
-EXTERN_API int session_get_channel_count(session_h handle, session_get_channel_count_cb callback, void * userData)
-{
-       int result = -1;
-
-       SESSION_EXTERN_BEGIN;
-               result = session->getChannelCount((getChannelCountCallback)callback, userData);
-       SESSION_EXTERN_END;
-
-       return result;
-}
-
 EXTERN_API void session_destroy_instance(session_h handle)
 {
 }
@@ -1127,13 +1040,13 @@ EXTERN_API channel_h session_open_logical_channel_sync(session_h handle, unsigne
        return result;
 }
 
-EXTERN_API unsigned int session_get_channel_count_sync(session_h handle)
+EXTERN_API size_t session_get_channel_count(session_h handle)
 {
-       unsigned int result = 0;
+       size_t result = 0;
 
 #ifdef CLIENT_IPC_THREAD
        SESSION_EXTERN_BEGIN;
-               result = session->getChannelCountSync();
+               result = session->getChannelCount();
        SESSION_EXTERN_END;
 #endif
 
index 3635191..fdff4fc 100644 (file)
@@ -35,7 +35,7 @@ namespace smartcard_service_api
 {
        class Reader;
 
-       class Session: public SessionHelper
+       class Session : public SessionHelper
        {
        private:
                void *context;
@@ -77,7 +77,6 @@ namespace smartcard_service_api
                int openBasicChannel(const unsigned char *aid, unsigned int length, openChannelCallback callback, void *userData);
                int openLogicalChannel(const ByteArray &aid, openChannelCallback callback, void *userData);
                int openLogicalChannel(const unsigned char *aid, unsigned int length, openChannelCallback callback, void *userData);
-               int getChannelCount(getChannelCountCallback callback, void * userData);
 
                const ByteArray getATRSync()
                        throw(ExceptionBase &, ErrorIO &, ErrorSecurity &,
@@ -103,7 +102,7 @@ namespace smartcard_service_api
                        throw(ErrorIO &, ErrorIllegalState &,
                                ErrorIllegalParameter &, ErrorSecurity &);
 
-               unsigned int getChannelCountSync();
+               size_t getChannelCount() const;
 
 #ifndef USE_GDBUS
                friend class ClientDispatcher;
@@ -131,14 +130,14 @@ int session_open_basic_channel(session_h handle, unsigned char *aid,
        unsigned int length, session_open_channel_cb callback, void *userData);
 int session_open_logical_channel(session_h handle, unsigned char *aid,
        unsigned int length, session_open_channel_cb callback, void *userData);
-int session_get_channel_count(session_h handle, session_get_channel_count_cb callback, void * userData);
 
 int session_get_atr_sync(session_h handle, unsigned char **buffer, unsigned int *length);
 void session_close_sync(session_h handle);
 
 channel_h session_open_basic_channel_sync(session_h handle, unsigned char *aid, unsigned int length);
 channel_h session_open_logical_channel_sync(session_h handle, unsigned char *aid, unsigned int length);
-unsigned int session_get_channel_count_sync(session_h handle);
+
+size_t session_get_channel_count(session_h handle);
 
 #ifdef __cplusplus
 }