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