merge with master
[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
46                 UICCTerminal();
47                 ~UICCTerminal();
48
49                 static void uiccTransmitAPDUCallback(TapiHandle *handle, int result, void *data, void *user_data);
50                 static void uiccGetAtrCallback(TapiHandle *handle, int result, void *data, void *user_data);
51                 static void uiccStatusNotiCallback(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
52
53         public:
54                 static UICCTerminal *getInstance();
55
56                 bool initialize();
57                 void finalize();
58
59                 bool isSecureElementPresence();
60
61                 int transmitSync(ByteArray command, ByteArray &response);
62                 int getATRSync(ByteArray &atr);
63
64                 int transmit(ByteArray command, terminalTransmitCallback callback, void *userParam);
65                 int getATR(terminalGetATRCallback callback, void *userParam);
66
67                 friend void uiccTransmitAPDUCallback(TapiHandle *handle, int result, void *data, void *user_data);
68                 friend void uiccGetAtrCallback(TapiHandle *handle, int result, void *data, void *user_data);
69                 friend void uiccStatusNotiCallback(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
70         };
71
72 } /* namespace smartcard_service_api */
73 #endif /* UICCTERMINAL_H_ */