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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
24 #ifndef __OBEXBASEOBJECT_H
25 #define __OBEXBASEOBJECT_H
27 #include <obextypes.h>
30 const TUint32 KConnIDInvalid = 0xffffffff;
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.
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
49 See the various derived classes for description of object body
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.
58 This class is not designed for user derivation (ie. outside of this dll).
64 NONSHARABLE_CLASS(CObexBaseObject) : public CBase
66 // required for access to iValidHeaders in CObexServer::CheckForConnectionID
67 friend class CObexServer;
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);
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();
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);
103 TProgress ParseNextReceivePacket(CObexPacket& aPacket);
104 void PrepareConnectionHeader( CObexPacket& aPacket );
105 void SetConnectionIdL(TUint32 aFourByte);
106 TUint32 ConnectionID();
107 TObexResponse GetLastError() const;
111 void GuessTypeFromExtL(const TDesC& aExt);
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);
124 TObexHeaderMask iHeaderMask;
125 TObexHeaderMask iValidHeaders;
127 mutable RPointerArray<HBufC8>* iHttp;
129 CObexHeaderSet* iHeaderSet;
131 TProgress iSendProgress;
132 TProgress iRecvProgress;
133 TObexOpcode iSendOpcode;
135 // This data item is used to store a CObexHeader which is used as a temporary
136 // store when finding headers
137 CObexHeader* iObexHeader;
139 TObexHeaderMask iSendHeaders;
143 TObexResponse iLastError;
147 #endif // __OBEXBASEOBJECT_H