gobex: Fix segfault caused by interrupted transfer
[platform/upstream/bluez.git] / gobex / gobex.h
1 /*
2  *
3  *  OBEX library with GLib integration
4  *
5  *  Copyright (C) 2011  Intel Corporation. All rights reserved.
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2 of the License, or
10  *  (at your option) any later version.
11  *
12  *  This program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with this program; if not, write to the Free Software
19  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  *
21  */
22
23 #ifndef __GOBEX_H
24 #define __GOBEX_H
25
26 #include <stdarg.h>
27 #include <glib.h>
28
29 #include "gobex/gobex-defs.h"
30 #include "gobex/gobex-packet.h"
31
32 typedef enum {
33         G_OBEX_TRANSPORT_STREAM,
34         G_OBEX_TRANSPORT_PACKET,
35 } GObexTransportType;
36
37 typedef struct _GObex GObex;
38
39 typedef void (*GObexFunc) (GObex *obex, GError *err, gpointer user_data);
40 typedef void (*GObexRequestFunc) (GObex *obex, GObexPacket *req,
41                                                         gpointer user_data);
42 typedef void (*GObexResponseFunc) (GObex *obex, GError *err, GObexPacket *rsp,
43                                                         gpointer user_data);
44
45 gboolean g_obex_send(GObex *obex, GObexPacket *pkt, GError **err);
46
47 guint g_obex_send_req(GObex *obex, GObexPacket *req, int timeout,
48                         GObexResponseFunc func, gpointer user_data,
49                         GError **err);
50 gboolean g_obex_cancel_req(GObex *obex, guint req_id,
51                                                 gboolean remove_callback);
52
53 gboolean g_obex_send_rsp(GObex *obex, guint8 rspcode, GError **err,
54                                                 guint first_hdr_type, ...);
55
56 void g_obex_set_disconnect_function(GObex *obex, GObexFunc func,
57                                                         gpointer user_data);
58 guint g_obex_add_request_function(GObex *obex, guint8 opcode,
59                                                 GObexRequestFunc func,
60                                                 gpointer user_data);
61 gboolean g_obex_remove_request_function(GObex *obex, guint id);
62
63 void g_obex_suspend(GObex *obex);
64 void g_obex_resume(GObex *obex);
65 gboolean g_obex_srm_active(GObex *obex);
66 void g_obex_drop_tx_queue(GObex *obex);
67
68 GObex *g_obex_new(GIOChannel *io, GObexTransportType transport_type,
69                                                 gssize rx_mtu, gssize tx_mtu);
70
71 GObex *g_obex_ref(GObex *obex);
72 void g_obex_unref(GObex *obex);
73
74 /* High level client functions */
75
76 guint g_obex_connect(GObex *obex, GObexResponseFunc func, gpointer user_data,
77                                 GError **err, guint first_hdr_id, ...);
78
79 guint g_obex_disconnect(GObex *obex, GObexResponseFunc func, gpointer user_data,
80                                                                 GError **err);
81
82 guint g_obex_setpath(GObex *obex, const char *path, GObexResponseFunc func,
83                                         gpointer user_data, GError **err);
84
85 guint g_obex_mkdir(GObex *obex, const char *path, GObexResponseFunc func,
86                                         gpointer user_data, GError **err);
87
88 guint g_obex_delete(GObex *obex, const char *name, GObexResponseFunc func,
89                                         gpointer user_data, GError **err);
90
91 guint g_obex_copy(GObex *obex, const char *name, const char *dest,
92                         GObexResponseFunc func, gpointer user_data,
93                         GError **err);
94
95 guint g_obex_move(GObex *obex, const char *name, const char *dest,
96                         GObexResponseFunc func, gpointer user_data,
97                         GError **err);
98
99 guint g_obex_abort(GObex *obex, GObexResponseFunc func, gpointer user_data,
100                                                                 GError **err);
101
102 /* Transfer related high-level functions */
103
104 guint g_obex_put_req(GObex *obex, GObexDataProducer data_func,
105                         GObexFunc complete_func, gpointer user_data,
106                         GError **err, guint first_hdr_id, ...);
107
108 guint g_obex_put_req_pkt(GObex *obex, GObexPacket *req,
109                         GObexDataProducer data_func, GObexFunc complete_func,
110                         gpointer user_data, GError **err);
111
112 guint g_obex_get_req(GObex *obex, GObexDataConsumer data_func,
113                         GObexFunc complete_func, gpointer user_data,
114                         GError **err, guint first_hdr_id, ...);
115
116 guint g_obex_get_req_pkt(GObex *obex, GObexPacket *req,
117                         GObexDataConsumer data_func, GObexFunc complete_func,
118                         gpointer user_data, GError **err);
119
120 guint g_obex_put_rsp(GObex *obex, GObexPacket *req,
121                         GObexDataConsumer data_func, GObexFunc complete_func,
122                         gpointer user_data, GError **err,
123                         guint first_hdr_id, ...);
124
125 guint g_obex_get_rsp(GObex *obex, GObexDataProducer data_func,
126                         GObexFunc complete_func, gpointer user_data,
127                         GError **err, guint first_hdr_id, ...);
128
129 guint g_obex_get_rsp_pkt(GObex *obex, GObexPacket *rsp,
130                         GObexDataProducer data_func, GObexFunc complete_func,
131                         gpointer user_data, GError **err);
132
133 gboolean g_obex_cancel_transfer(guint id, GObexFunc complete_func,
134                                                         gpointer user_data);
135
136 const char *g_obex_strerror(guint8 err_code);
137 guint8 g_obex_errno_to_rsp(int err);
138 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
139 void g_obex_io_shutdown(GObex *obex);
140 #endif
141
142 #endif /* __GOBEX_H */