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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
22 #ifndef __OBEXBASEOBJECT_H
23 #define __OBEXBASEOBJECT_H
25 #include <obextypes.h>
28 const TUint32 KConnIDInvalid = 0xffffffff;
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.
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
47 See the various derived classes for description of object body
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.
56 This class is not designed for user derivation (ie. outside of this dll).
62 NONSHARABLE_CLASS(CObexBaseObject) : public CBase
64 // required for access to iValidHeaders in CObexServer::CheckForConnectionID
65 friend class CObexServer;
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);
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();
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);
101 TProgress ParseNextReceivePacket(CObexPacket& aPacket);
102 void PrepareConnectionHeader( CObexPacket& aPacket );
103 void SetConnectionIdL(TUint32 aFourByte);
104 TUint32 ConnectionID();
105 TObexResponse GetLastError() const;
109 void GuessTypeFromExtL(const TDesC& aExt);
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);
122 TObexHeaderMask iHeaderMask;
123 TObexHeaderMask iValidHeaders;
125 mutable RPointerArray<HBufC8>* iHttp;
127 CObexHeaderSet* iHeaderSet;
129 TProgress iSendProgress;
130 TProgress iRecvProgress;
131 TObexOpcode iSendOpcode;
133 // This data item is used to store a CObexHeader which is used as a temporary
134 // store when finding headers
135 CObexHeader* iObexHeader;
137 TObexHeaderMask iSendHeaders;
141 TObexResponse iLastError;
145 #endif // __OBEXBASEOBJECT_H