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 "ByteArray.h"
26 #include "Synchronous.h"
28 namespace smartcard_service_api
31 typedef void (*terminalNotificationCallback)(const void *terminal, int event, int error, void *user_param);
33 typedef void (*terminalTransmitCallback)(const unsigned char *buffer, unsigned int length, int error, void *userParam);
34 typedef void (*terminalGetATRCallback)(const unsigned char *buffer, unsigned int length, int error, void *userParam);
36 class Terminal : public Synchronous
39 terminalNotificationCallback statusCallback;
45 static const int NOTIFY_SE_AVAILABLE = 1;
46 static const int NOTIFY_SE_NOT_AVAILABLE = -1;
48 Terminal() : statusCallback(NULL), initialized(false),
49 closed(true), name(NULL) {}
51 virtual ~Terminal() {}
53 virtual bool initialize() = 0;
54 virtual void finalize() = 0;
55 inline bool isInitialized() const { return initialized; }
57 virtual bool open() = 0;
58 virtual void close() = 0;
59 inline bool isClosed() const { return closed; }
61 inline const char *getName() const { return name; }
62 inline void setStatusCallback(terminalNotificationCallback callback) { statusCallback = callback; }
64 virtual bool isSecureElementPresence() const = 0;
66 virtual int transmitSync(const ByteArray &command, ByteArray &result) = 0;
67 virtual int getATRSync(ByteArray &atr) = 0;
69 virtual int transmit(const ByteArray &command, terminalTransmitCallback callback, void *userData) = 0;
70 virtual int getATR(terminalGetATRCallback callback, void *userData) = 0;
74 } /* namespace smartcard_service_api */
75 #endif /* TERMINAL_H_ */