Fix error handling
[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
23 /* SLP library header */
24
25 /* local header */
26 #include "Synchronous.h"
27 #include "SessionHelper.h"
28
29 using namespace std;
30
31 namespace smartcard_service_api
32 {
33         class SEServiceHelper;
34
35         typedef void (*openSessionCallback)(SessionHelper *session, int error, void *userData);
36
37         class ReaderHelper : public Synchronous
38         {
39         protected:
40                 char name[30];
41                 vector<SessionHelper *> sessions;
42                 SEServiceHelper *seService;
43                 bool present;
44
45                 ReaderHelper();
46                 virtual ~ReaderHelper() {}
47
48         public:
49                 inline const char *getName() { return name; }
50                 inline SEServiceHelper *getSEService() { return seService; }
51                 inline bool isSecureElementPresent() { return present; }
52
53                 virtual void closeSessions()
54                         throw(ErrorIO &, ErrorIllegalState &) = 0;
55
56                 virtual int openSession(openSessionCallback callback, void *userData) = 0;
57                 virtual SessionHelper *openSessionSync()
58                         throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
59                                 ErrorIllegalParameter &, ErrorSecurity &)= 0;
60         };
61
62 } /* namespace smartcard_service_api */
63 #endif /* READERHELPER_H_ */