2 * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 /* standard library header */
23 /* SLP library header */
26 #include "smartcard-types.h"
28 #include "SessionHelper.h"
29 #endif /* __cplusplus */
32 namespace smartcard_service_api
36 class Session:public SessionHelper
43 Session(void *context, Reader *reader, void *handle);
46 int openChannel(int id, const ByteArray &aid, openChannelCallback callback, void *userData);
48 Channel *openChannelSync(int id, const ByteArray &aid)
49 throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
50 ErrorIllegalParameter &, ErrorSecurity &);
52 Channel *openChannelSync(int id, const ByteArray &aid, unsigned char P2)
53 throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
54 ErrorIllegalParameter &, ErrorSecurity &);
56 static void session_get_atr_cb(GObject *source_object,
57 GAsyncResult *res, gpointer user_data);
58 static void session_open_channel_cb(GObject *source_object,
59 GAsyncResult *res, gpointer user_data);
60 static void session_close_cb(GObject *source_object,
61 GAsyncResult *res, gpointer user_data);
65 throw(ErrorIO &, ErrorIllegalState &);
67 int getATR(getATRCallback callback, void *userData);
68 int close(closeSessionCallback callback, void *userData);
70 int openBasicChannel(const ByteArray &aid, openChannelCallback callback, void *userData);
71 int openBasicChannel(const unsigned char *aid, unsigned int length, openChannelCallback callback, void *userData);
72 int openLogicalChannel(const ByteArray &aid, openChannelCallback callback, void *userData);
73 int openLogicalChannel(const unsigned char *aid, unsigned int length, openChannelCallback callback, void *userData);
75 const ByteArray getATRSync()
76 throw(ExceptionBase &, ErrorIO &, ErrorSecurity &,
77 ErrorIllegalState &, ErrorIllegalParameter &);
80 throw(ExceptionBase &, ErrorIO &, ErrorSecurity &,
81 ErrorIllegalState &, ErrorIllegalParameter &);
83 Channel *openBasicChannelSync(const ByteArray &aid)
84 throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
85 ErrorIllegalParameter &, ErrorSecurity &);
87 Channel *openBasicChannelSync(const unsigned char *aid, unsigned int length)
88 throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
89 ErrorIllegalParameter &, ErrorSecurity &);
91 Channel *openLogicalChannelSync(const ByteArray &aid)
92 throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
93 ErrorIllegalParameter &, ErrorSecurity &);
95 Channel *openLogicalChannelSync(const unsigned char *aid, unsigned int length)
96 throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
97 ErrorIllegalParameter &, ErrorSecurity &);
99 Channel *openBasicChannelSync(const ByteArray &aid, unsigned char P2)
100 throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
101 ErrorIllegalParameter &, ErrorSecurity &);
103 Channel *openBasicChannelSync(const unsigned char *aid, unsigned int length, unsigned char P2)
104 throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
105 ErrorIllegalParameter &, ErrorSecurity &);
107 Channel *openLogicalChannelSync(const ByteArray &aid, unsigned char P2)
108 throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
109 ErrorIllegalParameter &, ErrorSecurity &);
111 Channel *openLogicalChannelSync(const unsigned char *aid, unsigned int length, unsigned char P2)
112 throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
113 ErrorIllegalParameter &, ErrorSecurity &);
115 size_t getChannelCount() const;
116 void *getHandle() { return handle; }
120 } /* namespace smartcard_service_api */
121 #endif /* __cplusplus */
127 #endif /* __cplusplus */
129 int session_get_reader(session_h handle, int* reader_handle);
130 int session_is_closed(session_h handle, bool* is_closed);
131 int session_close_channels(session_h handle);
132 int session_get_atr_sync(session_h handle, unsigned char **buffer, unsigned int *length);
133 int session_close_sync(session_h handle);
134 int session_open_basic_channel_sync(session_h handle, unsigned char *aid,
135 unsigned int length, unsigned char P2, int* channel_handle);
136 int session_open_logical_channel_sync(session_h handle, unsigned char *aid,
137 unsigned int length, unsigned char P2, int* channel_handle);
140 int session_get_atr(session_h handle, session_get_atr_cb callback,
142 int session_close(session_h handle, session_close_session_cb callback,
144 int session_open_basic_channel(session_h handle, unsigned char *aid,
145 unsigned int length, session_open_channel_cb callback, void *userData);
146 int session_open_logical_channel(session_h handle, unsigned char *aid,
147 unsigned int length, session_open_channel_cb callback, void *userData);
148 size_t session_get_channel_count(session_h handle);
149 __attribute__((deprecated)) void session_destroy_instance(session_h handle);
155 #endif /* __cplusplus */
157 #endif /* SESSION_H_ */