Change some indent for Tizen 3.0 Coding rule
[platform/core/api/smartcard.git] / include / SEService.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 SESERVICE_H_
18 #define SESERVICE_H_
19
20 /* standard library header */
21 #include <glib.h>
22 #include <gio/gio.h>
23
24 /* SLP library header */
25
26 /* local header */
27 #include "smartcard-types.h"
28 #ifdef __cplusplus
29 #include "SEServiceListener.h"
30 #include "SEServiceHelper.h"
31 #endif /* __cplusplus */
32
33 #ifdef __cplusplus
34 using namespace std;
35
36 namespace smartcard_service_api
37 {
38         typedef void (*serviceConnected)(SEServiceHelper *service, void *context);
39
40         class SEService : public SEServiceHelper
41         {
42 private:
43                 unsigned int handle;
44                 void *context;
45                 serviceConnected handler;
46                 SEServiceListener *listener;
47
48                 se_service_event_cb event_handler;
49                 void *event_handler_context;
50
51                 void *proxy;
52                 const char *version;
53
54                 SEService();
55
56                 void addReader(unsigned int handle, const char *name);
57                 bool parseReaderInformation(unsigned int count, const ByteArray &data);
58                 bool parseReaderInformation(GVariant *variant);
59
60                 bool _initialize()
61                         throw(ErrorIO &);
62                 bool initialize(void *context, serviceConnected handler)
63                         throw(ErrorIO &, ErrorIllegalParameter &);
64                 bool initialize(void *context, SEServiceListener *listener)
65                         throw(ErrorIO &, ErrorIllegalParameter &);
66                 int _initialize_sync()
67                         throw(ErrorIO &, ExceptionBase &);
68                 int _initialize_sync_do_not_throw_exception();
69                 bool initializeSync(void *context)
70                         throw(ErrorIO &, ErrorIllegalParameter &, ExceptionBase &);
71
72                 static void reader_inserted(GObject *source_object,
73                         guint reader_id, gchar *reader_name,
74                         gpointer user_data);
75                 static void reader_removed(GObject *source_object,
76                         guint reader_id, gchar *reader_name,
77                         gpointer user_data);
78                 static void se_service_shutdown_cb(GObject *source_object,
79                         GAsyncResult *res, gpointer user_data);
80                 static void se_service_cb(GObject *source_object,
81                         GAsyncResult *res, gpointer user_data);
82
83 public:
84                 SEService(void *user_data, serviceConnected handler)
85                         throw(ErrorIO &, ErrorIllegalParameter &);
86                 SEService(void *user_data, SEServiceListener *listener)
87                         throw(ErrorIO &, ErrorIllegalParameter &);
88                 SEService(void *user_data)
89                         throw(ErrorIO &, ErrorIllegalParameter &, ExceptionBase &);
90                 ~SEService();
91
92                 static SEService *createInstance(void *user_data, SEServiceListener *listener)
93                         throw(ErrorIO &, ErrorIllegalParameter &);
94                 static SEService *createInstance(void *user_data, serviceConnected handler)
95                         throw(ErrorIO &, ErrorIllegalParameter &);
96
97                 void setEventHandler(se_service_event_cb cb, void *context);
98                 void shutdown();
99                 void shutdownSync();
100                 const char *getVersion() const { return version; }
101         };
102 } /* namespace smartcard_service_api */
103 #endif /* __cplusplus */
104
105 /* export C API */
106 #ifdef __cplusplus
107 extern "C"
108 {
109 #endif /* __cplusplus */
110
111 se_service_h se_service_create_instance(void *user_data,
112         se_service_connected_cb callback);
113 se_service_h se_service_create_instance_with_event_callback(void *user_data,
114         se_service_connected_cb connected, se_service_event_cb event,
115         se_sesrvice_error_cb error);
116
117 se_service_h se_service_create_instance_sync(void *user_data, int* result);
118 int se_service_get_version(se_service_h handle, char **version_str);
119 int se_service_get_readers_count(se_service_h handle);
120 int se_service_get_readers(se_service_h handle, int **readers, int *count);
121
122 bool se_service_is_connected(se_service_h handle);
123 void se_service_shutdown(se_service_h handle);
124
125 void se_service_set_event_handler(se_service_h handle, se_service_event_cb event_handler, void *user_data);
126 void se_service_unset_event_handler(se_service_h handle);
127
128 int se_service_destroy_instance(se_service_h handle);
129
130
131 #ifdef __cplusplus
132 }
133 #endif /* __cplusplus */
134
135 #endif /* SESERVICE_H_ */