1cc607e2101cc1d27db0e4821205d387528fd28b
[platform/core/connectivity/smartcard-service.git] / client / include / ClientChannel.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 CLIENTCHANNEL_H_
18 #define CLIENTCHANNEL_H_
19
20 /* standard library header */
21 #include <gio/gio.h>
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                 void *proxy;
41
42                 ClientChannel(void *context, Session *session, int channelNum,
43                         const ByteArray &selectResponse, void *handle);
44                 ~ClientChannel();
45
46                 static void channel_transmit_cb(GObject *source_object,
47                         GAsyncResult *res, gpointer user_data);
48                 static void channel_close_cb(GObject *source_object,
49                         GAsyncResult *res, gpointer user_data);
50
51         public:
52                 int close(closeChannelCallback callback, void *userParam);
53                 int transmit(const ByteArray &command,
54                         transmitCallback callback, void *userParam);
55
56                 void closeSync()
57                         throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
58                                 ErrorSecurity &, ErrorIllegalParameter &);
59                 int transmitSync(const ByteArray &command, ByteArray &result)
60                         throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
61                                 ErrorIllegalParameter &, ErrorSecurity &);
62
63                 friend class Session;
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 bool channel_is_basic_channel(channel_h handle);
75 bool channel_is_closed(channel_h handle);
76
77 unsigned int channel_get_select_response_length(channel_h handle);
78 bool channel_get_select_response(channel_h handle, unsigned char *buffer,
79         unsigned int length);
80 session_h channel_get_session(channel_h handle);
81 void channel_destroy_instance(channel_h handle) __attribute__((deprecated));
82
83 int channel_close(channel_h handle, channel_close_cb callback, void *userParam);
84 int channel_transmit(channel_h handle, unsigned char *command,
85         unsigned int length, channel_transmit_cb callback, void *userParam);
86 void channel_close_sync(channel_h handle);
87 int channel_transmit_sync(channel_h handle, unsigned char *command,
88         unsigned int cmd_len, unsigned char **response, unsigned int *resp_len);
89
90 #ifdef __cplusplus
91 }
92 #endif /* __cplusplus */
93
94 #endif /* CLIENTCHANNEL_H_ */