tizen 2.3.1 release
[framework/connectivity/bluez.git] / gobex / gobex-packet.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_PACKET_H
24 #define __GOBEX_PACKET_H
25
26 #include <stdarg.h>
27 #include <glib.h>
28
29 #include "gobex/gobex-defs.h"
30 #include "gobex/gobex-header.h"
31
32 /* Request opcodes */
33 #define G_OBEX_OP_CONNECT                       0x00
34 #define G_OBEX_OP_DISCONNECT                    0x01
35 #define G_OBEX_OP_PUT                           0x02
36 #define G_OBEX_OP_GET                           0x03
37 #define G_OBEX_OP_SETPATH                       0x05
38 #define G_OBEX_OP_ACTION                        0x06
39 #define G_OBEX_OP_SESSION                       0x07
40 #define G_OBEX_OP_ABORT                         0x7f
41
42 /* Response codes */
43 #define G_OBEX_RSP_CONTINUE                     0x10
44 #define G_OBEX_RSP_SUCCESS                      0x20
45 #define G_OBEX_RSP_CREATED                      0x21
46 #define G_OBEX_RSP_ACCEPTED                     0x22
47 #define G_OBEX_RSP_NON_AUTHORITATIVE            0x23
48 #define G_OBEX_RSP_NO_CONTENT                   0x24
49 #define G_OBEX_RSP_RESET_CONTENT                0x25
50 #define G_OBEX_RSP_PARTIAL_CONTENT              0x26
51 #define G_OBEX_RSP_MULTIPLE_CHOICES             0x30
52 #define G_OBEX_RSP_MOVED_PERMANENTLY            0x31
53 #define G_OBEX_RSP_MOVED_TEMPORARILY            0x32
54 #define G_OBEX_RSP_SEE_OTHER                    0x33
55 #define G_OBEX_RSP_NOT_MODIFIED                 0x34
56 #define G_OBEX_RSP_USE_PROXY                    0x35
57 #define G_OBEX_RSP_BAD_REQUEST                  0x40
58 #define G_OBEX_RSP_UNAUTHORIZED                 0x41
59 #define G_OBEX_RSP_PAYMENT_REQUIRED             0x42
60 #define G_OBEX_RSP_FORBIDDEN                    0x43
61 #define G_OBEX_RSP_NOT_FOUND                    0x44
62 #define G_OBEX_RSP_METHOD_NOT_ALLOWED           0x45
63 #define G_OBEX_RSP_NOT_ACCEPTABLE               0x46
64 #define G_OBEX_RSP_PROXY_AUTH_REQUIRED          0x47
65 #define G_OBEX_RSP_REQUEST_TIME_OUT             0x48
66 #define G_OBEX_RSP_CONFLICT                     0x49
67 #define G_OBEX_RSP_GONE                         0x4a
68 #define G_OBEX_RSP_LENGTH_REQUIRED              0x4b
69 #define G_OBEX_RSP_PRECONDITION_FAILED          0x4c
70 #define G_OBEX_RSP_REQ_ENTITY_TOO_LARGE         0x4d
71 #define G_OBEX_RSP_REQ_URL_TOO_LARGE            0x4e
72 #define G_OBEX_RSP_UNSUPPORTED_MEDIA_TYPE       0x4f
73 #define G_OBEX_RSP_INTERNAL_SERVER_ERROR        0x50
74 #define G_OBEX_RSP_NOT_IMPLEMENTED              0x51
75 #define G_OBEX_RSP_BAD_GATEWAY                  0x52
76 #define G_OBEX_RSP_SERVICE_UNAVAILABLE          0x53
77 #define G_OBEX_RSP_GATEWAY_TIMEOUT              0x54
78 #define G_OBEX_RSP_VERSION_NOT_SUPPORTED        0x55
79 #define G_OBEX_RSP_DATABASE_FULL                0x60
80 #define G_OBEX_RSP_DATABASE_LOCKED              0x61
81
82 typedef struct _GObexPacket GObexPacket;
83
84 GObexHeader *g_obex_packet_get_header(GObexPacket *pkt, guint8 id);
85 GObexHeader *g_obex_packet_get_body(GObexPacket *pkt);
86 guint8 g_obex_packet_get_operation(GObexPacket *pkt, gboolean *final);
87 gboolean g_obex_packet_prepend_header(GObexPacket *pkt, GObexHeader *header);
88 gboolean g_obex_packet_add_header(GObexPacket *pkt, GObexHeader *header);
89 gboolean g_obex_packet_add_body(GObexPacket *pkt, GObexDataProducer func,
90                                                         gpointer user_data);
91 gboolean g_obex_packet_add_unicode(GObexPacket *pkt, guint8 id,
92                                                         const char *str);
93 gboolean g_obex_packet_add_bytes(GObexPacket *pkt, guint8 id,
94                                                 const void *data, gsize len);
95 gboolean g_obex_packet_add_uint8(GObexPacket *pkt, guint8 id, guint8 val);
96 gboolean g_obex_packet_add_uint32(GObexPacket *pkt, guint8 id, guint32 val);
97 gboolean g_obex_packet_set_data(GObexPacket *pkt, const void *data, gsize len,
98                                                 GObexDataPolicy data_policy);
99 const void *g_obex_packet_get_data(GObexPacket *pkt, gsize *len);
100 GObexPacket *g_obex_packet_new(guint8 opcode, gboolean final,
101                                                 guint8 first_hdr_id, ...);
102 GObexPacket *g_obex_packet_new_valist(guint8 opcode, gboolean final,
103                                         guint8 first_hdr_id, va_list args);
104 void g_obex_packet_free(GObexPacket *pkt);
105
106 GObexPacket *g_obex_packet_decode(const void *data, gsize len,
107                                                 gsize header_offset,
108                                                 GObexDataPolicy data_policy,
109                                                 GError **err);
110 gssize g_obex_packet_encode(GObexPacket *pkt, guint8 *buf, gsize len);
111
112 #endif /* __GOBEX_PACKET_H */