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 */
22 /* SLP library header */
25 #include "Synchronous.h"
26 #include "ByteArray.h"
27 #include "Exception.h"
29 namespace smartcard_service_api
31 class SessionHelper; /* explicit declaration */
33 typedef void (*transmitCallback)(unsigned char *buffer, unsigned int length,
34 int error, void *userParam);
35 typedef void (*closeCallback)(int error, void *userParam);
37 class Channel : public Synchronous
40 ByteArray selectResponse;
41 SessionHelper *session;
44 Channel() : session(NULL), channelNum(-1) {}
45 Channel(SessionHelper *session) : session(session), channelNum(-1) {}
47 inline void setSelectResponse(ByteArray response) { selectResponse = response; }
50 virtual ~Channel() {};
52 inline bool isBasicChannel() const throw() { return (channelNum == 0); }
53 inline bool isClosed() const throw() { return (channelNum < 0); }
55 inline ByteArray getSelectResponse() const throw() { return selectResponse; }
56 inline SessionHelper *getSession() const throw() { return session; }
58 virtual int close(closeCallback callback, void *userParam) = 0;
59 virtual int transmit(ByteArray command, transmitCallback callback, void *userData) = 0;
61 virtual void closeSync()
62 throw(ExceptionBase &, ErrorIO &, ErrorSecurity &,
63 ErrorIllegalState &, ErrorIllegalParameter &) = 0;
65 virtual int transmitSync(ByteArray command, ByteArray &result)
66 throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
67 ErrorIllegalParameter &, ErrorSecurity &) = 0;
70 } /* namespace smartcard_service_api */
71 #endif /* CHANNEL_H_ */