Change some indent for Tizen 3.0 Coding rule
[platform/core/api/smartcard.git] / 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                 bool selectNext() { return false; }
56
57                 void closeSync()
58                         throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
59                                 ErrorSecurity &, ErrorIllegalParameter &);
60                 int transmitSync(const ByteArray &command, ByteArray &result)
61                         throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
62                                 ErrorIllegalParameter &, ErrorSecurity &);
63
64                 void *getHandle() { return handle; }
65
66                 friend class Session;
67         };
68 } /* namespace smartcard_service_api */
69 #endif /* __cplusplus */
70
71 /* export C API */
72 #ifdef __cplusplus
73 extern "C"
74 {
75 #endif /* __cplusplus */
76
77 int channel_is_basic_channel(channel_h handle, bool* is_basic_channel);
78 int channel_is_closed(channel_h handle, bool* is_closed);
79 int channel_get_session(channel_h handle, int *session_handle);
80 int channel_close_sync(channel_h handle);
81 int channel_transmit_sync(channel_h handle, unsigned char *command,
82         unsigned int cmd_len, unsigned char **response, unsigned int *resp_len);
83 int channel_get_select_response(channel_h handle,
84         unsigned char **buffer, size_t* length);
85 int channel_get_transmit_response(channel_h handle,
86         unsigned char **buffer, size_t* length);
87 int channel_select_next(channel_h hChannel, bool *pSuccess);
88 ////
89
90 int channel_close(channel_h handle, channel_close_cb callback, void *userParam);
91 int channel_transmit(channel_h handle, unsigned char *command,
92         unsigned int length, channel_transmit_cb callback, void *userParam);
93 unsigned int channel_get_select_response_length(channel_h handle);
94 void channel_destroy_instance(channel_h handle) __attribute__((deprecated));
95
96
97 #ifdef __cplusplus
98 }
99 #endif /* __cplusplus */
100
101 #endif /* CLIENTCHANNEL_H_ */