Apply user space smack, step 1
[platform/core/connectivity/smartcard-service.git] / common / include / ReaderHelper.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 READERHELPER_H_
18 #define READERHELPER_H_
19
20 /* standard library header */
21 #include <vector>
22 #include <string>
23
24 /* SLP library header */
25
26 /* local header */
27 #include "Synchronous.h"
28 #include "SessionHelper.h"
29
30 using namespace std;
31
32 namespace smartcard_service_api
33 {
34         class SEServiceHelper;
35
36         typedef void (*openSessionCallback)(SessionHelper *session, int error,
37                 void *userData);
38
39         class ReaderHelper : public Synchronous
40         {
41         protected:
42                 SEServiceHelper *seService;
43                 string name;
44                 bool present;
45                 vector<SessionHelper *> sessions;
46
47                 ReaderHelper() : seService(NULL), present(false) {}
48                 ReaderHelper(const char *name) : seService(NULL), name(name),
49                         present(false) {}
50                 virtual ~ReaderHelper() {}
51
52         public:
53                 inline const char *getName() const { return name.c_str(); }
54                 inline SEServiceHelper *getSEService() const { return seService; }
55                 inline bool isSecureElementPresent() const { return present; }
56
57                 virtual void closeSessions()
58                         throw(ErrorIO &, ErrorIllegalState &) = 0;
59
60                 virtual int openSession(openSessionCallback callback, void *userData) = 0;
61                 virtual SessionHelper *openSessionSync()
62                         throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
63                                 ErrorIllegalParameter &, ErrorSecurity &)= 0;
64         };
65
66 } /* namespace smartcard_service_api */
67 #endif /* READERHELPER_H_ */