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