obex/obexprotocol/obex/public/obexbaseobject.h
changeset 0 d0791faffa3f
equal deleted inserted replaced
-1:000000000000 0:d0791faffa3f
       
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @publishedAll
       
    19  @released
       
    20 */
       
    21 
       
    22 #ifndef __OBEXBASEOBJECT_H
       
    23 #define __OBEXBASEOBJECT_H
       
    24 
       
    25 #include <obextypes.h>
       
    26 #include <f32file.h>
       
    27 
       
    28 const TUint32 KConnIDInvalid = 0xffffffff;
       
    29 
       
    30 /**
       
    31 Objects of this class are used to describe the objects to be transferred and
       
    32 those received via Obex.
       
    33 Consists of a number of attributes describing the object, along with
       
    34 methods to set them. CObexBaseObject is an abstract base class, which defines
       
    35 attribute setting and transferring functionality, but does not specify the
       
    36 storage mechanism for the data part (called the object body) of the object.
       
    37 This body part is defined in derived classes.
       
    38 
       
    39 Object description attributes are tracked for validity automatically, so
       
    40 that only valid attributes are sent to the remote machine. Also has the
       
    41 concept of "header masks". This selects which of the various attributes
       
    42 will actually be sent out/read in when the object is used in an operation
       
    43 with the remote machine. Objects default to transferring all valid
       
    44 attributes, use the header mask if restriction is required on the headers
       
    45 exchanged.
       
    46 
       
    47 See the various derived classes for description of object body
       
    48 representation.
       
    49 
       
    50 The common attributes are defined to be as close to the underlying OBEX
       
    51 headers as usefully possible, hence any OBEX header specified as a Unicode
       
    52 string (e.g. Name) translate to TDes (variant) EPOC descriptors, "byte
       
    53 sequences" (e.g. Type) are TDes8 (or ASCII invariant), and byte and 32 bit
       
    54 integers (e.g. Length) are TUint32s.
       
    55 
       
    56 This class is not designed for user derivation (ie. outside of this dll).
       
    57 
       
    58 @see CObexHeader
       
    59 @publishedAll
       
    60 @released
       
    61 */
       
    62 NONSHARABLE_CLASS(CObexBaseObject) : public CBase
       
    63 	{
       
    64 // required for access to iValidHeaders in CObexServer::CheckForConnectionID
       
    65 friend class CObexServer;
       
    66 
       
    67 public:
       
    68 	virtual ~CObexBaseObject();
       
    69 	IMPORT_C void SetHeaderMask(const TObexHeaderMask aHeaderMask);
       
    70 	IMPORT_C void SetNameL(const TDesC& aDesc);
       
    71 	IMPORT_C void SetTypeL(const TDesC8& aDesc);
       
    72 	IMPORT_C void SetLengthL(const TUint32 aLength);
       
    73 	IMPORT_C void SetTimeL(const TTime aLocalTime);
       
    74 	IMPORT_C void SetDescriptionL(const TDesC& aDesc);
       
    75 	IMPORT_C void SetTargetL(const TDesC8& aDesc);
       
    76 	IMPORT_C void AddHttpL(const TDesC8& aDesc);
       
    77 	IMPORT_C void SetAppParamL(const TDesC8& aDesc);
       
    78 	
       
    79 	IMPORT_C void AddHeaderL(CObexHeader& aHeader);
       
    80 	IMPORT_C TInt BytesSent();
       
    81 	IMPORT_C TInt BytesReceived();
       
    82 	IMPORT_C TObexHeaderMask HeaderMask();
       
    83 	IMPORT_C TObexHeaderMask ValidHeaders();
       
    84 	IMPORT_C const TDesC& Name();
       
    85 	IMPORT_C const TDesC8& Type();
       
    86 	IMPORT_C TUint32 Length();
       
    87 	IMPORT_C const TTime Time();
       
    88 	IMPORT_C const TDesC& Description();
       
    89 	IMPORT_C const TDesC8& Target();
       
    90 	IMPORT_C const RPointerArray<HBufC8>* Http() const;
       
    91 	IMPORT_C const TDesC8& AppParam() const;
       
    92 	IMPORT_C void Reset();
       
    93 	IMPORT_C const CObexHeaderSet& HeaderSet() const;
       
    94 	IMPORT_C CObexHeaderSet& HeaderSet();
       
    95 
       
    96 	// Public unexported functions used by CObexServer, CObexClient, etc
       
    97 	enum TProgress { EContinue,EComplete,EError,ELastPacket };
       
    98 	TInt InitSend(TObexOpcode aOpcode);
       
    99 	TProgress PrepareNextSendPacket(CObexPacket& aPacket);
       
   100 	TInt InitReceive();
       
   101 	TProgress ParseNextReceivePacket(CObexPacket& aPacket);
       
   102 	void PrepareConnectionHeader( CObexPacket& aPacket );
       
   103 	void SetConnectionIdL(TUint32 aFourByte);
       
   104 	TUint32 ConnectionID();
       
   105 	TObexResponse GetLastError() const;
       
   106 
       
   107 protected:
       
   108 	CObexBaseObject();
       
   109 	void GuessTypeFromExtL(const TDesC& aExt);
       
   110 	void ResetHeaders();
       
   111 	// Pure virtuals that all derived objects must implement
       
   112 	virtual void GetData(TInt aPos, TDes8& aDes) =0;
       
   113 	virtual void NewData(TInt aPos, TDes8& aDes) =0;
       
   114 	virtual TInt DataSize() =0;
       
   115 	virtual void ResetData() =0;
       
   116 	void CreateHeaderStorageDataL();
       
   117 	void SetTimeHeaderL(const TDesC8& aTimeDes);
       
   118 	void SetUtcTimeL(const TTime aUtcTime);
       
   119 	
       
   120 // Data
       
   121 private:
       
   122 	TObexHeaderMask iHeaderMask;
       
   123 	TObexHeaderMask iValidHeaders;
       
   124 
       
   125 	mutable RPointerArray<HBufC8>* iHttp;
       
   126 
       
   127 	CObexHeaderSet* iHeaderSet;
       
   128 	
       
   129 	TProgress iSendProgress;
       
   130 	TProgress iRecvProgress;
       
   131 	TObexOpcode iSendOpcode;
       
   132 
       
   133 	// This data item is used to store a CObexHeader which is used as a temporary
       
   134 	// store when finding headers
       
   135 	CObexHeader* iObexHeader;
       
   136 	
       
   137 	TObexHeaderMask iSendHeaders; 
       
   138 	TInt iSendBytes;
       
   139 	TInt iRecvBytes;
       
   140 	
       
   141 	TObexResponse iLastError;
       
   142 	
       
   143 	};
       
   144 
       
   145 #endif // __OBEXBASEOBJECT_H