Change to use handle instead of context parameter
[platform/core/connectivity/smartcard-service.git] / client / 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
22 /* SLP library header */
23
24 /* local header */
25 #include "smartcard-types.h"
26 #ifdef __cplusplus
27 #include "SEServiceListener.h"
28 #include "SEServiceHelper.h"
29 #endif /* __cplusplus */
30
31 #ifdef __cplusplus
32 using namespace std;
33
34 namespace smartcard_service_api
35 {
36         typedef void (*serviceConnected)(SEServiceHelper *service, void *context);
37
38         class SEService : public SEServiceHelper
39         {
40         private:
41                 unsigned int handle;
42                 void *context;
43                 serviceConnected handler;
44                 SEServiceListener *listener;
45
46                 SEService();
47
48                 static bool dispatcherCallback(void *message);
49                 bool parseReaderInformation(unsigned int count, ByteArray data);
50
51                 bool _initialize()
52                         throw(ErrorIO &);
53                 bool initialize(void *context, serviceConnected handler)
54                         throw(ErrorIO &, ErrorIllegalParameter &);
55                 bool initialize(void *context, SEServiceListener *listener)
56                         throw(ErrorIO &, ErrorIllegalParameter &);
57                 SEService *initializeSync(void *context, serviceConnected handler)
58                         throw(ErrorIO &, ErrorIllegalParameter &);
59
60         public:
61                 SEService(void *user_data, serviceConnected handler)
62                         throw(ErrorIO &, ErrorIllegalParameter &);
63                 SEService(void *user_data, SEServiceListener *listener)
64                         throw(ErrorIO &, ErrorIllegalParameter &);
65                 ~SEService();
66
67                 static SEService *createInstance(void *user_data, SEServiceListener *listener)
68                         throw(ErrorIO &, ErrorIllegalParameter &);
69                 static SEService *createInstance(void *user_data, serviceConnected handler)
70                         throw(ErrorIO &, ErrorIllegalParameter &);
71
72                 void shutdown();
73                 void shutdownSync();
74
75                 friend class ClientDispatcher;
76         };
77 } /* namespace smartcard_service_api */
78 #endif /* __cplusplus */
79
80 /* export C API */
81 #ifdef __cplusplus
82 extern "C"
83 {
84 #endif /* __cplusplus */
85
86 se_service_h se_service_create_instance(void *user_data, se_service_connected_cb callback);
87 se_service_h se_service_create_instance_with_event_callback(void *user_data,
88         se_service_connected_cb connected, se_service_event_cb event, se_sesrvice_error_cb error);
89 int se_service_get_readers_count(se_service_h handle);
90 bool se_service_get_readers(se_service_h handle, reader_h *readers, int *count);
91 bool se_service_is_connected(se_service_h handle);
92 void se_service_shutdown(se_service_h handle);
93 void se_service_destroy_instance(se_service_h handle);
94
95 #ifdef __cplusplus
96 }
97 #endif /* __cplusplus */
98
99 #endif /* SESERVICE_H_ */