/*******************************************************************

Copyright (c) 2004 Open Mobile Alliance, Ltd.  All Rights Reserved.

This software is made available under the usage and distribution terms 
covered by the Common Public License 1.0 and by using this software you
are bound by the terms and conditions of the same.

EXCEPT AS EXPRESSLY SET FORTH IN THE COMMON PUBLIC LICENSE,
THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, 
ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, 
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
   
Each recipient is solely responsible for determining the 
appropriateness of using and distributing this program and assumes 
all risks associated with its exercise of rights under the Common 
Public License, including but not limited to the risks and 
costs of program errors, compliance with applicable laws, 
damage to or loss of data, programs or equipment, and 
unavailability or interruption of operations.

********************************************************************/
#ifndef OBEXOBJECT_H
#define OBEXOBJECT_H

#include <iConstants.h>

#include <handle.h>
#include <header.h>

#define OBJECT_FSM_CHECK_PRECONDITONS    1
#define OBJECT_FSM_DETERMINE_LENGTHS     2
#define OBJECT_FSM_CHECK_FOR_FINAL       3
#define OBJECT_FSM_SEND_OPCODE           4
#define OBJECT_FSM_SEND_LENGTH           5
#define OBJECT_FSM_SEND_META             6
#define OBJECT_FSM_SEND_NONBODY          7
#define OBJECT_FSM_SEND_BODY             8
#define OBJECT_FSM_FINISH                9

#ifdef __cplusplus
extern "C" {
#endif

/*
** The current object is sent using the transport associated with the passed ObxHandle.
** This method will send any leading information, then iterate through the headers sending
** each of them.
** Note, this function will send what it can, it's up to the caller to deal with partial
** sends (by re invoking).
*/
ObxRc       iobxObjectSendObject( ObxObject *object, ObxHandle *handle );

/*
** The passed object is populated by reading from the transport layer associated with the
** passed ObxHandle object.
*/
ObxRc       iobxObjectRecvObject( ObxObject *object, ObxHandle *handle );


/*
** Creates and initializes a new ObxObject structure.
*/
ObxObject   *iobxObjectNew();

/*
** Destroys the passed ObxObject structure.  All internal structures and
** the ObxObject structure itself is free()'ed.
*/
void        iobxObjectFree( ObxObject *object );

/*
** The passed ObxObject is cleared to an initial state.  Allows users to
** reuse objects.
*/
ObxRc       iobxObjectReset( ObxObject *object );

/*
** Adds a header to the list of headers associated with the object.
*/
ObxRc       iobxObjectAddHeader( ObxObject *object, ObxHeader *header, ObxHandle *handle );

/*
** What's the prefix size of this object
*/
int         iobxObjectPrefixSize( ObxObject *object, ObxHandle *handle );

/*
** Requests the current list of headers be returned.  From this object users
** can get an iterator and manipulate the header list.
*/
ObxList     *iobxObjectGetHeaderList( ObxObject *object );

ObxRc iobxObjectSetConnectMeta( ObxObject *object, unsigned char version, unsigned char flags, unsigned short hbo_mtu );
ObxRc iobxObjectSetSetPathMeta( ObxObject *object, unsigned char flags, unsigned char constants );

#ifdef __cplusplus
}
#endif

#endif
