dccc9bf78b27f4a84b58654bb5aac0aa55b71b85
[platform/core/connectivity/smartcard-service.git] / common / include / Terminal.h
1 /*
2  * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #ifndef TERMINAL_H_
18 #define TERMINAL_H_
19
20 /* standard library header */
21
22 /* SLP library header */
23
24 /* local header */
25 #include "ByteArray.h"
26 #include "Synchronous.h"
27
28 namespace smartcard_service_api
29 {
30         typedef void (*terminalNotificationCallback)(void *terminal, int event, int error, void *user_param);
31
32         typedef void (*terminalTransmitCallback)(unsigned char *buffer, unsigned int length, int error, void *userParam);
33         typedef void (*terminalGetATRCallback)(unsigned char *buffer, unsigned int length, int error, void *userParam);
34
35         class Terminal : public Synchronous
36         {
37         protected:
38                 terminalNotificationCallback statusCallback;
39                 bool initialized;
40                 char *name;
41
42         public:
43                 static const int NOTIFY_SE_AVAILABLE = 1;
44                 static const int NOTIFY_SE_NOT_AVAILABLE = -1;
45
46                 Terminal()
47                 {
48                         statusCallback = NULL;
49                         initialized = false;
50                         name = NULL;
51                 }
52                 virtual ~Terminal() {}
53
54                 virtual bool initialize() = 0;
55                 virtual void finalize() = 0;
56                 inline bool isInitialized() { return initialized; }
57
58                 inline char *getName() { return name; }
59                 inline void setStatusCallback(terminalNotificationCallback callback) { statusCallback = callback; }
60
61                 virtual bool isSecureElementPresence() = 0;
62
63                 virtual int transmitSync(ByteArray command, ByteArray &result) = 0;
64                 virtual int getATRSync(ByteArray &atr) = 0;
65
66                 virtual int transmit(ByteArray command, terminalTransmitCallback callback, void *userData) = 0;
67                 virtual int getATR(terminalGetATRCallback callback, void *userData) = 0;
68         };
69
70 } /* namespace smartcard_service_api */
71 #endif /* TERMINAL_H_ */