epoc32/include/obexbaseobject.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
     1.1 --- a/epoc32/include/obexbaseobject.h	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/obexbaseobject.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,147 @@
     1.4 -obexbaseobject.h
     1.5 +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +// All rights reserved.
     1.7 +// This component and the accompanying materials are made available
     1.8 +// 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
     1.9 +// which accompanies this distribution, and is available
    1.10 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.11 +//
    1.12 +// Initial Contributors:
    1.13 +// Nokia Corporation - initial contribution.
    1.14 +//
    1.15 +// Contributors:
    1.16 +//
    1.17 +// Description:
    1.18 +//
    1.19 +
    1.20 +
    1.21 +
    1.22 +/**
    1.23 + @file
    1.24 + @publishedAll
    1.25 + @released
    1.26 +*/
    1.27 +
    1.28 +#ifndef __OBEXBASEOBJECT_H
    1.29 +#define __OBEXBASEOBJECT_H
    1.30 +
    1.31 +#include <obextypes.h>
    1.32 +#include <f32file.h>
    1.33 +
    1.34 +const TUint32 KConnIDInvalid = 0xffffffff;
    1.35 +
    1.36 +/**
    1.37 +Objects of this class are used to describe the objects to be transferred and
    1.38 +those received via Obex.
    1.39 +Consists of a number of attributes describing the object, along with
    1.40 +methods to set them. CObexBaseObject is an abstract base class, which defines
    1.41 +attribute setting and transferring functionality, but does not specify the
    1.42 +storage mechanism for the data part (called the object body) of the object.
    1.43 +This body part is defined in derived classes.
    1.44 +
    1.45 +Object description attributes are tracked for validity automatically, so
    1.46 +that only valid attributes are sent to the remote machine. Also has the
    1.47 +concept of "header masks". This selects which of the various attributes
    1.48 +will actually be sent out/read in when the object is used in an operation
    1.49 +with the remote machine. Objects default to transferring all valid
    1.50 +attributes, use the header mask if restriction is required on the headers
    1.51 +exchanged.
    1.52 +
    1.53 +See the various derived classes for description of object body
    1.54 +representation.
    1.55 +
    1.56 +The common attributes are defined to be as close to the underlying OBEX
    1.57 +headers as usefully possible, hence any OBEX header specified as a Unicode
    1.58 +string (e.g. Name) translate to TDes (variant) EPOC descriptors, "byte
    1.59 +sequences" (e.g. Type) are TDes8 (or ASCII invariant), and byte and 32 bit
    1.60 +integers (e.g. Length) are TUint32s.
    1.61 +
    1.62 +This class is not designed for user derivation (ie. outside of this dll).
    1.63 +
    1.64 +@see CObexHeader
    1.65 +@publishedAll
    1.66 +@released
    1.67 +*/
    1.68 +NONSHARABLE_CLASS(CObexBaseObject) : public CBase
    1.69 +	{
    1.70 +// required for access to iValidHeaders in CObexServer::CheckForConnectionID
    1.71 +friend class CObexServer;
    1.72 +
    1.73 +public:
    1.74 +	virtual ~CObexBaseObject();
    1.75 +	IMPORT_C void SetHeaderMask(const TObexHeaderMask aHeaderMask);
    1.76 +	IMPORT_C void SetNameL(const TDesC& aDesc);
    1.77 +	IMPORT_C void SetTypeL(const TDesC8& aDesc);
    1.78 +	IMPORT_C void SetLengthL(const TUint32 aLength);
    1.79 +	IMPORT_C void SetTimeL(const TTime aLocalTime);
    1.80 +	IMPORT_C void SetDescriptionL(const TDesC& aDesc);
    1.81 +	IMPORT_C void SetTargetL(const TDesC8& aDesc);
    1.82 +	IMPORT_C void AddHttpL(const TDesC8& aDesc);
    1.83 +	IMPORT_C void SetAppParamL(const TDesC8& aDesc);
    1.84 +	
    1.85 +	IMPORT_C void AddHeaderL(CObexHeader& aHeader);
    1.86 +	IMPORT_C TInt BytesSent();
    1.87 +	IMPORT_C TInt BytesReceived();
    1.88 +	IMPORT_C TObexHeaderMask HeaderMask();
    1.89 +	IMPORT_C TObexHeaderMask ValidHeaders();
    1.90 +	IMPORT_C const TDesC& Name();
    1.91 +	IMPORT_C const TDesC8& Type();
    1.92 +	IMPORT_C TUint32 Length();
    1.93 +	IMPORT_C const TTime Time();
    1.94 +	IMPORT_C const TDesC& Description();
    1.95 +	IMPORT_C const TDesC8& Target();
    1.96 +	IMPORT_C const RPointerArray<HBufC8>* Http() const;
    1.97 +	IMPORT_C const TDesC8& AppParam() const;
    1.98 +	IMPORT_C void Reset();
    1.99 +	IMPORT_C const CObexHeaderSet& HeaderSet() const;
   1.100 +	IMPORT_C CObexHeaderSet& HeaderSet();
   1.101 +
   1.102 +	// Public unexported functions used by CObexServer, CObexClient, etc
   1.103 +	enum TProgress { EContinue,EComplete,EError,ELastPacket };
   1.104 +	TInt InitSend(TObexOpcode aOpcode);
   1.105 +	TProgress PrepareNextSendPacket(CObexPacket& aPacket);
   1.106 +	TInt InitReceive();
   1.107 +	TProgress ParseNextReceivePacket(CObexPacket& aPacket);
   1.108 +	void PrepareConnectionHeader( CObexPacket& aPacket );
   1.109 +	void SetConnectionIdL(TUint32 aFourByte);
   1.110 +	TUint32 ConnectionID();
   1.111 +	TObexResponse GetLastError() const;
   1.112 +
   1.113 +protected:
   1.114 +	CObexBaseObject();
   1.115 +	void GuessTypeFromExtL(const TDesC& aExt);
   1.116 +	void ResetHeaders();
   1.117 +	// Pure virtuals that all derived objects must implement
   1.118 +	virtual void GetData(TInt aPos, TDes8& aDes) =0;
   1.119 +	virtual void NewData(TInt aPos, TDes8& aDes) =0;
   1.120 +	virtual TInt DataSize() =0;
   1.121 +	virtual void ResetData() =0;
   1.122 +	void CreateHeaderStorageDataL();
   1.123 +	void SetTimeHeaderL(const TDesC8& aTimeDes);
   1.124 +	void SetUtcTimeL(const TTime aUtcTime);
   1.125 +	
   1.126 +// Data
   1.127 +private:
   1.128 +	TObexHeaderMask iHeaderMask;
   1.129 +	TObexHeaderMask iValidHeaders;
   1.130 +
   1.131 +	mutable RPointerArray<HBufC8>* iHttp;
   1.132 +
   1.133 +	CObexHeaderSet* iHeaderSet;
   1.134 +	
   1.135 +	TProgress iSendProgress;
   1.136 +	TProgress iRecvProgress;
   1.137 +	TObexOpcode iSendOpcode;
   1.138 +
   1.139 +	// This data item is used to store a CObexHeader which is used as a temporary
   1.140 +	// store when finding headers
   1.141 +	CObexHeader* iObexHeader;
   1.142 +	
   1.143 +	TObexHeaderMask iSendHeaders; 
   1.144 +	TInt iSendBytes;
   1.145 +	TInt iRecvBytes;
   1.146 +	
   1.147 +	TObexResponse iLastError;
   1.148 +	
   1.149 +	};
   1.150 +
   1.151 +#endif // __OBEXBASEOBJECT_H