3 * OBEX library with GLib integration
5 * Copyright (C) 2011 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #ifndef __GOBEX_PACKET_H
23 #define __GOBEX_PACKET_H
28 #include <gobex/gobex-defs.h>
29 #include <gobex/gobex-header.h>
32 #define G_OBEX_OP_CONNECT 0x00
33 #define G_OBEX_OP_DISCONNECT 0x01
34 #define G_OBEX_OP_PUT 0x02
35 #define G_OBEX_OP_GET 0x03
36 #define G_OBEX_OP_SETPATH 0x05
37 #define G_OBEX_OP_ACTION 0x06
38 #define G_OBEX_OP_SESSION 0x07
39 #define G_OBEX_OP_ABORT 0x7f
42 #define G_OBEX_RSP_CONTINUE 0x10
43 #define G_OBEX_RSP_SUCCESS 0x20
44 #define G_OBEX_RSP_CREATED 0x21
45 #define G_OBEX_RSP_ACCEPTED 0x22
46 #define G_OBEX_RSP_NON_AUTHORITATIVE 0x23
47 #define G_OBEX_RSP_NO_CONTENT 0x24
48 #define G_OBEX_RSP_RESET_CONTENT 0x25
49 #define G_OBEX_RSP_PARTIAL_CONTENT 0x26
50 #define G_OBEX_RSP_MULTIPLE_CHOICES 0x30
51 #define G_OBEX_RSP_MOVED_PERMANENTLY 0x31
52 #define G_OBEX_RSP_MOVED_TEMPORARILY 0x32
53 #define G_OBEX_RSP_SEE_OTHER 0x33
54 #define G_OBEX_RSP_NOT_MODIFIED 0x34
55 #define G_OBEX_RSP_USE_PROXY 0x35
56 #define G_OBEX_RSP_BAD_REQUEST 0x40
57 #define G_OBEX_RSP_UNAUTHORIZED 0x41
58 #define G_OBEX_RSP_PAYMENT_REQUIRED 0x42
59 #define G_OBEX_RSP_FORBIDDEN 0x43
60 #define G_OBEX_RSP_NOT_FOUND 0x44
61 #define G_OBEX_RSP_METHOD_NOT_ALLOWED 0x45
62 #define G_OBEX_RSP_NOT_ACCEPTABLE 0x46
63 #define G_OBEX_RSP_PROXY_AUTH_REQUIRED 0x47
64 #define G_OBEX_RSP_REQUEST_TIME_OUT 0x48
65 #define G_OBEX_RSP_CONFLICT 0x49
66 #define G_OBEX_RSP_GONE 0x4a
67 #define G_OBEX_RSP_LENGTH_REQUIRED 0x4b
68 #define G_OBEX_RSP_PRECONDITION_FAILED 0x4c
69 #define G_OBEX_RSP_REQ_ENTITY_TOO_LARGE 0x4d
70 #define G_OBEX_RSP_REQ_URL_TOO_LARGE 0x4e
71 #define G_OBEX_RSP_UNSUPPORTED_MEDIA_TYPE 0x4f
72 #define G_OBEX_RSP_INTERNAL_SERVER_ERROR 0x50
73 #define G_OBEX_RSP_NOT_IMPLEMENTED 0x51
74 #define G_OBEX_RSP_BAD_GATEWAY 0x52
75 #define G_OBEX_RSP_SERVICE_UNAVAILABLE 0x53
76 #define G_OBEX_RSP_GATEWAY_TIMEOUT 0x54
77 #define G_OBEX_RSP_VERSION_NOT_SUPPORTED 0x55
78 #define G_OBEX_RSP_DATABASE_FULL 0x60
79 #define G_OBEX_RSP_DATABASE_LOCKED 0x61
81 typedef struct _GObexPacket GObexPacket;
83 GObexHeader *g_obex_packet_get_header(GObexPacket *pkt, guint8 id);
84 GObexHeader *g_obex_packet_get_body(GObexPacket *pkt);
85 guint8 g_obex_packet_get_operation(GObexPacket *pkt, gboolean *final);
86 gboolean g_obex_packet_prepend_header(GObexPacket *pkt, GObexHeader *header);
87 gboolean g_obex_packet_add_header(GObexPacket *pkt, GObexHeader *header);
88 gboolean g_obex_packet_add_body(GObexPacket *pkt, GObexDataProducer func,
90 gboolean g_obex_packet_add_unicode(GObexPacket *pkt, guint8 id,
92 gboolean g_obex_packet_add_bytes(GObexPacket *pkt, guint8 id,
93 const void *data, gsize len);
94 gboolean g_obex_packet_add_uint8(GObexPacket *pkt, guint8 id, guint8 val);
95 gboolean g_obex_packet_add_uint32(GObexPacket *pkt, guint8 id, guint32 val);
96 gboolean g_obex_packet_set_data(GObexPacket *pkt, const void *data, gsize len,
97 GObexDataPolicy data_policy);
98 const void *g_obex_packet_get_data(GObexPacket *pkt, gsize *len);
99 GObexPacket *g_obex_packet_new(guint8 opcode, gboolean final,
100 guint8 first_hdr_id, ...);
101 GObexPacket *g_obex_packet_new_valist(guint8 opcode, gboolean final,
102 guint8 first_hdr_id, va_list args);
103 void g_obex_packet_free(GObexPacket *pkt);
105 GObexPacket *g_obex_packet_decode(const void *data, gsize len,
107 GObexDataPolicy data_policy,
109 gssize g_obex_packet_encode(GObexPacket *pkt, guint8 *buf, gsize len);
111 #endif /* __GOBEX_PACKET_H */