Function
obex_t *
OBEX_Init
(gint transport,
obex_event_t eventcb,
guint flags)
Arguments
- transport
- Which transport to use. The following transports are available :
- eventcb
- Function pointer to your event callback.
See obex.h for prototype of this callback.
- flags
- Bitmask of flags. The following flags are available :
Function
gint
OBEX_RegisterCTransport
(obex_t * self,
obex_ctrans_t * ctrans)
Arguments
- self
- OBEX handle
- ctrans
- Structure with callbacks to transport operations
(see obex_const.h for details)
Description
Call this function directly after OBEX_Init if you are using
a custom transport.
Function
void
OBEX_Cleanup
(obex_t * self)
Arguments
- self
- OBEX handle
Description
Close down an OBEX instance.
Function
void
OBEX_SetUserData
(obex_t * self,
gpointer data)
Arguments
- self
- OBEX handle
- data
- It's all up to you!
Function
gpointer
OBEX_GetUserData
(obex_t * self)
Arguments
- self
- OBEX handle
Description
Returns userdata
Function
void
OBEX_SetUserCallBack
(obex_t * self,
obex_event_t eventcb,
gpointer data)
Arguments
- self
- OBEX handle
- eventcb
- Function pointer to your new event callback.
- data
- Pointer to the new user data to pass to the new callback (optional)
Function
gint
OBEX_ServerRegister
(obex_t * self,
const char * service)
Arguments
- self
- OBEX handle
- service
- Service to bind to. Only used then using IrDA transport.
Description
Returns -1 on error.
Function
obex_t *
OBEX_ServerAccept
(obex_t * server,
obex_event_t eventcb,
gpointer data)
Arguments
- server
- OBEX handle
- eventcb
- Event callback for client (use NULL for same as server)
- data
- Userdata for client (use NULL for same as server)
Description
Create a new OBEX instance to handle the incomming connection.
The old OBEX instance will continue to listen for new connections.
The two OBEX instances become totally independant from each other.
This function should be called after the library generates
an OBEX_EV_ACCEPTHINT event to the user, but before the user
start to pull data out of the incomming connection.
Using this function also requires that the OBEX handle was created
with the OBEX_FL_KEEPSERVER flag set while calling OBEX_Init.
Returns the client instance or NULL for error.
Function
gint
OBEX_HandleInput
(obex_t * self,
gint timeout)
Arguments
- self
- OBEX handle
- timeout
- Maximum time to wait in seconds
Description
Let the OBEX parser read and process incoming data. If no data
is available this call will block.
When a request has been sent or you are waiting for an incoming server-
request you should call this function until the request has finished.
Like select this function returns -1 on error, 0 on timeout or
positive on success.
Function
gint
OBEX_CustomDataFeed
(obex_t * self,
guint8 * inputbuf,
gint actual)
Arguments
- self
- OBEX handle
- inputbuf
- Pointer to custom data
- actual
- Length of buffer
Function
gint
OBEX_TransportConnect
(obex_t * self,
struct sockaddr * saddr,
int addrlen)
Arguments
- self
- OBEX handle
- saddr
- Address to connect to
- addrlen
- Length of address
Description
Returns -1 on error.
Function
gint
OBEX_TransportDisconnect
(obex_t * self)
Arguments
- self
- OBEX handle
Function
gint
OBEX_GetFD
(obex_t * self)
Arguments
- self
- OBEX handle
Description
Returns the filedescriptor of the transport. Returns -1 on error.
Note that if you for example have a custom transport, no fd
is available.
The returned filehandle can be used to do select on, before
calling OBEX_HandleInput
There is one subtelty about this function. When the OBEX connection is
established, it returns the connection filedescriptor, while for
an unconnected server it will return the listening filedescriptor.
This mean that after receiving an incomming connection, you need to
call this function again.
Function
gint
OBEX_Request
(obex_t * self,
obex_object_t * object)
Arguments
- self
- OBEX handle
- object
- Object containing request
Description
Returns negative on error.
Function
gint
OBEX_CancelRequest
(obex_t * self,
gboolean nice)
Arguments
- self
- OBEX handle
- nice
- If true an OBEX Abort will be sent if beeing client
or OBEX_RSP_UNAUTHORIZED as reponse if beeing server.
Description
Function
obex_object_t *
OBEX_ObjectNew
(obex_t * self,
guint8 cmd)
Arguments
- self
- OBEX handle
- cmd
- command of object
Description
Returns a pointer to a new OBEX Object or NULL on error.
Function
gint
OBEX_ObjectDelete
(obex_t * self,
obex_object_t * object)
Arguments
- self
- OBEX handle
- object
- object to delete.
Description
Note that as soon as you have passed an object to the lib using
OBEX_Request, you shall not delete it yourself.
Function
gint
OBEX_ObjectAddHeader
(obex_t * self,
obex_object_t * object,
guint8 hi,
obex_headerdata_t hv,
guint32 hv_size,
guint flags)
Arguments
- self
- OBEX handle
- object
- OBEX object
- hi
- Header identifier
- hv
- Header value
- hv_size
- Header size
- flags
- See obex.h for possible values
Description
Add a new header to an object.
If you want all headers to fit in one packet, use the flag
OBEX_FL_FIT_ONE_PACKET on all headers you add to an object.
To stream a body add a body header with hv.bs = NULL and set the flag
OBEX_FL_STREAM_START. You will now get OBEX_EV_STREAMEMPTY events as
soon as the the parser wants you to feed it with more data.
When you get an OBEX_EV_STREAMEMPTY event give the parser some data by
adding a body-header and set the flag OBEX_EV_STREAM_DATA. When you
have no more data to send set the flag OBEX_EV_STREAM_DATAEND instead.
After adding a header you are free to do whatever you want with the buffer
if you are NOT streaming. If you are streaming you may not touch the
buffer until you get another OBEX_EV_STREAMEMTPY or until the request
finishes.
The headers will be sent in the order you add them.
Function
gint
OBEX_ObjectGetNextHeader
(obex_t * self,
obex_object_t * object,
guint8 * hi,
obex_headerdata_t * hv,
guint32 * hv_size)
Arguments
- self
- OBEX handle
- object
- OBEX object
- hi
- Pointer to header identifier
- hv
- Pointer to hv
- hv_size
- Pointer to hv_size
Description
Returns 0 when no more headers are available.
All headers are read-only.
You will get the headers in the received order.
Function
gint
OBEX_ObjectReParseHeaders
(obex_t * self,
obex_object_t * object)
Arguments
- self
- OBEX handle
- object
- OBEX object
Description
The user must have extracted all headers from the object before
calling this function (until OBEX_ObjectGetNextHeader() returns 0).
Next call to OBEX_ObjectGetNextHeader() will return the first received
header.
Returns 1 on success
Returns 0 if failed due previous parsing not completed.
Function
gint
OBEX_ObjectReadStream
(obex_t * self,
obex_object_t * object,
const guint8 ** buf)
Arguments
- self
- OBEX handle
- object
- OBEX object
- buf
- A pointer to a pointer which this function will set to a buffer which
shall be read (and ONLY read) after this function returns.
Description
To recieve the body as a stream call this function with buf = NULL as soon
as you get an OBEX_EV_REQHINT event.
You will now recieve OBEX_EV_STREAMAVAIL events when data is available
for you. Call this function to get the data.
Note! When receiving a stream data is not buffered so if you don't call this
function when you get an OBEX_EV_STREAMAVAIL event data will be lost.
Returns the number of bytes in buffer, or 0 for end-of-stream.
Function
gint
OBEX_ObjectSetRsp
(obex_object_t * object,
guint8 rsp,
guint8 lastrsp)
Arguments
- object
- OBEX object
- rsp
- Respose code in non-last packets
- lastrsp
- Response code in last packet
Description
Returns -1 on error.
Function
gint
OBEX_ObjectGetNonHdrData
(obex_object_t * object,
guint8 ** buffer)
Arguments
- object
- OBEX object
- buffer
- Pointer to a pointer which will point to a read-only buffer
Description
Returns the size of the buffer or -1 for error.
Function
gint
OBEX_ObjectSetNonHdrData
(obex_object_t * object,
const guint8 * buffer,
guint len)
Arguments
- object
- OBEX object
- buffer
- Data to send
- len
- Length to data
Description
Some commands (notably SetPath) send data before headers. Use this
function to set this data.
Function
gint
OBEX_ObjectSetHdrOffset
(obex_object_t * object,
guint offset)
Arguments
- object
- OBEX object
- offset
- Desired offset
Description
Call this function when you get a OBEX_EV_REQHINT and you know that the
command has data before the headers comes. You do NOT need to use this
function on Connect and SetPath, they are handled automatically.
Function
gint
OBEX_UnicodeToChar
(guint8 * c,
const guint8 * uc,
gint size)
Arguments
- c
- Destination (char)
- uc
- Source (unicode)
- size
- Length of destination buffer
Description
Buffers may overlap. Returns -1 on error.
Function
gint
OBEX_CharToUnicode
(guint8 * uc,
const guint8 * c,
gint size)
Arguments
- uc
- Destination (unicode)
- c
- Source (char)
- size
- Length of destination buffer
Description
Buffers may overlap. Returns -1 on error.
Function
GString*
OBEX_GetResponseMessage
(obex_t * self,
gint rsp)
Arguments
- self
- OBEX handle
- rsp
- Response code.
Description
The returned GString shall be freed by you. Returns NULL on error.