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