f913446088e5fa72131da333f526a67e2b2fd4cb
[platform/core/connectivity/smartcard-service.git] / client / include / Reader.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 READER_H_
18 #define READER_H_
19
20 #ifdef USE_AUTOSTART
21 #include <glib.h>
22 #include <gio/gio.h>
23 #endif
24
25 #include "smartcard-types.h"
26 #ifdef __cplusplus
27 #include "ReaderHelper.h"
28 #include "Session.h"
29 #endif /* __cplusplus */
30
31 #ifdef __cplusplus
32 namespace smartcard_service_api
33 {
34         class EXPORT Reader: public ReaderHelper
35         {
36         private:
37                 void *context;
38                 void *handle;
39                 void *proxy;
40
41                 Reader(void *context, const char *name, void *handle);
42                 ~Reader();
43
44                 inline void unavailable() { present = false; }
45 #ifdef USE_AUTOSTART
46                 static void reader_open_session_cb(GObject *source_object,
47                         GAsyncResult *res, gpointer user_data);
48 #endif
49
50         public:
51                 void closeSessions()
52                         throw(ErrorIO &, ErrorIllegalState &);
53
54                 int openSession(openSessionCallback callback, void *userData);
55                 SessionHelper *openSessionSync()
56                         throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
57                                 ErrorIllegalParameter &, ErrorSecurity &);
58
59                 friend class SEService;
60         };
61 } /* namespace smartcard_service_api */
62 #endif /* __cplusplus */
63
64 /* export C API */
65 #ifdef __cplusplus
66 extern "C"
67 {
68 #endif /* __cplusplus */
69
70 const char *reader_get_name(reader_h handle);
71 se_service_h reader_get_se_service(reader_h handle);
72 bool reader_is_secure_element_present(reader_h handle);
73 int reader_open_session(reader_h handle, reader_open_session_cb callback,
74         void *userData);
75 session_h reader_open_session_sync(reader_h handle);
76 void reader_close_sessions(reader_h handle);
77 __attribute__((deprecated)) void reader_destroy_instance(reader_h handle);
78
79 #ifdef __cplusplus
80 }
81 #endif /* __cplusplus */
82
83 #endif /* READER_H_ */