apply new smartcard service(0.1.27)
[platform/core/connectivity/smartcard-plugin-uicc.git] / include / UICCTerminal.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 UICCTERMINAL_H_
18 #define UICCTERMINAL_H_
19
20 /* standard library header */
21 #include <vector>
22 #include <map>
23
24 /* SLP library header */
25 #include "tapi_common.h"
26 #include "ITapiSim.h"
27
28 /* local header */
29 #include "Lock.h"
30 #include "Terminal.h"
31
32 using namespace std;
33
34 namespace smartcard_service_api
35 {
36         class UICCTerminal: public Terminal
37         {
38         private:
39                 PMutex mutex;
40                 TapiHandle *handle;
41
42                 /* temporary data for sync function */
43                 ByteArray response;
44                 int error;
45                 bool complete;
46
47                 UICCTerminal();
48                 ~UICCTerminal();
49
50                 static void uiccTransmitAPDUCallback(TapiHandle *handle, int result, void *data, void *user_data);
51                 static void uiccGetAtrCallback(TapiHandle *handle, int result, void *data, void *user_data);
52                 static void uiccStatusNotiCallback(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
53
54         public:
55                 static UICCTerminal *getInstance();
56
57                 bool initialize();
58                 void finalize();
59
60                 bool isSecureElementPresence() const;
61
62                 int transmitSync(const ByteArray &command, ByteArray &response);
63                 int getATRSync(ByteArray &atr);
64
65                 int transmit(const ByteArray &command, terminalTransmitCallback callback, void *userParam);
66                 int getATR(terminalGetATRCallback callback, void *userParam);
67
68                 friend void uiccTransmitAPDUCallback(TapiHandle *handle, int result, void *data, void *user_data);
69                 friend void uiccGetAtrCallback(TapiHandle *handle, int result, void *data, void *user_data);
70                 friend void uiccStatusNotiCallback(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
71         };
72
73 } /* namespace smartcard_service_api */
74 #endif /* UICCTERMINAL_H_ */