Update source
[platform/core/connectivity/smartcard-service.git] / client / include / SEService.h
1 /*
2 * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
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
18 #ifndef SESERVICE_H_
19 #define SESERVICE_H_
20
21 /* standard library header */
22
23 /* SLP library header */
24
25 /* local header */
26 #include "smartcard-types.h"
27 #ifdef __cplusplus
28 #include "SEServiceListener.h"
29 #include "SEServiceHelper.h"
30 #endif /* __cplusplus */
31
32 #ifdef __cplusplus
33 using namespace std;
34
35 namespace smartcard_service_api
36 {
37         typedef void (*serviceConnected)(SEServiceHelper *service, void *context);
38
39         class SEService: public SEServiceHelper
40         {
41         private:
42                 int pid;
43                 void *context;
44                 serviceConnected handler;
45                 SEServiceListener *listener;
46
47                 SEService();
48
49                 static bool dispatcherCallback(void *message);
50                 bool parseReaderInformation(unsigned int count, ByteArray data);
51
52                 bool _initialize();
53
54                 bool initialize(void *context, serviceConnected handler);
55                 bool initialize(void *context, SEServiceListener *listener);
56                 SEService *initializeSync(void *context, serviceConnected handler);
57
58         public:
59                 SEService(void *user_data, serviceConnected handler);
60                 SEService(void *user_data, SEServiceListener *listener);
61                 ~SEService();
62
63                 void shutdown();
64                 void shutdownSync();
65
66                 friend class ClientDispatcher;
67         };
68
69 } /* namespace smartcard_service_api */
70 #endif /* __cplusplus */
71
72 /* export C API */
73 #ifdef __cplusplus
74 extern "C"
75 {
76 #endif /* __cplusplus */
77
78 se_service_h se_service_create_instance(void *user_data, se_service_connected_cb callback);
79 se_service_h se_service_create_instance_with_event_callback(void *user_data, se_service_connected_cb connected, se_service_event_cb event, se_sesrvice_error_cb error);
80 int se_service_get_readers_count(se_service_h handle);
81 bool se_service_get_readers(se_service_h handle, reader_h *readers, int *count);
82 bool se_service_is_connected(se_service_h handle);
83 void se_service_shutdown(se_service_h handle);
84 void se_service_destroy_instance(se_service_h handle);
85
86 #ifdef __cplusplus
87 }
88 #endif /* __cplusplus */
89
90 #endif /* SESERVICE_H_ */