update the latest source
[platform/core/connectivity/smartcard-service.git] / client / include / ClientChannel.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 CLIENTCHANNEL_H_
19 #define CLIENTCHANNEL_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 "Channel.h"
29 #include "Session.h"
30 #endif /* __cplusplus */
31
32 #ifdef __cplusplus
33 namespace smartcard_service_api
34 {
35         class ClientChannel: public Channel
36         {
37         private:
38                 void *context;
39                 void *handle;
40                 /* temporary data for sync function */
41                 int error;
42                 ByteArray response;
43
44                 ClientChannel(void *context, Session *session, int channelNum, ByteArray selectResponse, void *handle);
45
46                 static bool dispatcherCallback(void *message);
47
48                 void closeSync();
49                 int transmitSync(ByteArray command, ByteArray &result);
50
51         public:
52                 ~ClientChannel();
53
54                 int close(closeCallback callback, void *userParam);
55                 int transmit(ByteArray command, transmitCallback callback, void *userParam);
56
57                 friend class ClientDispatcher;
58                 friend class Session;
59         };
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 int channel_close(channel_h handle, channel_close_cb callback, void *userParam);
71 int channel_transmit(channel_h handle, unsigned char *command, unsigned int length, channel_transmit_cb callback, void *userParam);
72 bool channel_is_basic_channel(channel_h handle);
73 bool channel_is_closed(channel_h handle);
74
75 unsigned int channel_get_select_response_length(channel_h handle);
76 bool channel_get_select_response(channel_h handle, unsigned char *buffer, unsigned int length);
77 session_h channel_get_session(channel_h handle);
78 void channel_destroy_instance(channel_h handle);
79
80 #ifdef __cplusplus
81 }
82 #endif /* __cplusplus */
83
84 #endif /* CLIENTCHANNEL_H_ */