2 * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
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.
17 #ifndef SESSIONHELPER_H_
18 #define SESSIONHELPER_H_
20 /* standard library header */
23 /* SLP library header */
26 #include "Synchronous.h"
27 #include "ByteArray.h"
32 namespace smartcard_service_api
37 typedef void (*openChannelCallback)(Channel *channel, int error, void *userData);
38 typedef void (*getATRCallback)(unsigned char *atr, unsigned int length, int error, void *userData);
39 typedef void (*closeSessionCallback)(int error, void *userData);
40 typedef void (*getChannelCountCallback)(unsigned count, int error, void *userData);
42 class SessionHelper : public Synchronous
46 vector<Channel *> channels;
51 SessionHelper(ReaderHelper *reader) :
52 reader(reader), closed(true) {}
53 virtual ~SessionHelper() {}
55 ReaderHelper *getReader() const throw() { return reader; }
56 bool isClosed() const throw() { return closed; }
58 virtual void closeChannels() = 0;
60 virtual int getATR(getATRCallback callback, void *userData) = 0;
61 virtual int close(closeSessionCallback callback, void *userData) = 0;
63 virtual int openBasicChannel(const ByteArray &aid, openChannelCallback callback, void *userData) = 0;
64 virtual int openBasicChannel(const unsigned char *aid, unsigned int length, openChannelCallback callback, void *userData) = 0;
65 virtual int openLogicalChannel(const ByteArray &aid, openChannelCallback callback, void *userData) = 0;
66 virtual int openLogicalChannel(const unsigned char *aid, unsigned int length, openChannelCallback callback, void *userData) = 0;
68 virtual const ByteArray getATRSync() = 0;
70 virtual void closeSync() = 0;
72 virtual Channel *openBasicChannelSync(const ByteArray &aid) = 0;
74 virtual Channel *openBasicChannelSync(const unsigned char *aid, unsigned int length) = 0;
76 virtual Channel *openLogicalChannelSync(const ByteArray &aid) = 0;
78 virtual Channel *openLogicalChannelSync(const unsigned char *aid, unsigned int length) = 0;
80 virtual Channel *openBasicChannelSync(const ByteArray &aid, unsigned char P2) = 0;
82 virtual Channel *openBasicChannelSync(const unsigned char *aid, unsigned int length, unsigned char P2) = 0;
84 virtual Channel *openLogicalChannelSync(const ByteArray &aid, unsigned char P2) = 0;
86 virtual Channel *openLogicalChannelSync(const unsigned char *aid, unsigned int length, unsigned char P2) = 0;
90 } /* namespace smartcard_service_api */
91 #endif /* SESSIONHELPER_H_ */