1 // Copyright (c) 2001-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.
14 // $Workfile: obexHeader.h $
17 // $Date: 25/03/02 10:57 $
21 #if !defined (__OBEXHEADER_H__)
22 #define __OBEXHEADER_H__
26 #include <e32base.h> //CBase
30 class RMsvWriteStream;
32 // Stream version -- increment by one each time the externalized data format changes
33 // for a significant release.
34 const TInt32 KObexMessageStreamVersion = 1;///<Stream version
35 const TInt KObexBadStreamVersion = 1;
38 class CObexMtmHeader : public CBase
40 Base class for OBEX object headers. Allows them to be stored and restored to and from the
50 * Destructor which deletes all of the HBufC members
53 IMPORT_C ~CObexMtmHeader();
56 * Creates a stream in aStore and externalises this object to it.
59 * @param aStore The store to which this object is to be stored. Note this must be open with write access or
60 * this function will leave.
61 * @leave KErrXXX Standard EPOC stream leave codes.
62 * @leave KErrAccessDenied aStore is not opened with write access.
65 IMPORT_C void StoreL(CMsvStore& aStore) const;
68 * Opens a stream in aStore and internalises this object from it.
69 * @param aStore The store from which this object is to be restored. Note this must be open with read or
70 * read/write access or this function will leave.
71 * @leave KErrXXX Standard EPOC stream leave codes.
72 * @leave KErrAccessDenied aStore is not opened with read access.
75 IMPORT_C void RestoreL(const CMsvStore& aStore);
80 * Returns the Name header value.
81 * @return The Name header value. This will be a zero-length descriptor if this Name has not been set.
84 IMPORT_C TPtrC Name() const;
87 * Sets the Name header value.
88 * @param aName The new Name header value
89 * @leave KErrXXX Standard EPOC error codes if allocation of a buffer to hold the Name header fails.
92 IMPORT_C void SetNameL(const TDesC& aSubject);
95 * Returns the Subject header value.
96 * @return The Subject header value. This will be a zero-length descriptor if this Subject has not been set.
99 IMPORT_C TPtrC Subject() const;
102 * Sets the Subject header value.
104 * @param aName The new Subject header value
105 * @leave KErrXXX Standard EPOC error codes if allocation of a buffer to hold the Subject header fails.
108 IMPORT_C void SetSubjectL(const TDesC& aSubject);
111 * Returns the Type header value.
112 * @return The Type header value. This will be a zero-length descriptor if this Type has not been set.
115 IMPORT_C TPtrC8 Type() const;
118 * Sets the Type header value.
120 * @param aType The new Type header value
121 * @leave KErrXXX Standard EPOC error codes if allocation of a buffer to hold the Type header fails.
124 IMPORT_C void SetTypeL(const TDesC8& aSubject);
127 * Returns the Target header value.
128 * @return The Target header value. This will be a zero-length descriptor if this Target has not been set.
131 IMPORT_C TPtrC8 Target() const;
134 * Sets the ConnectionID header value.
136 * @param ConnectionID The new Target header value
137 * @leave KErrXXX Standard EPOC error codes if allocation of a buffer to hold the Target header fails.
140 IMPORT_C void SetTargetL(const TDesC8& aSubject);
143 * Returns the ConnectionID header value.
144 * @return The ConnectionID header value. This will be a zero-length descriptor if this ConnectionID has not been set.
147 IMPORT_C TPtrC8 ConnectionID() const;
150 * Sets the ConnectionID header value.
152 * @param ConnectionID The new ConnectionID header value
153 * @leave KErrXXX Standard EPOC error codes if allocation of a buffer to hold the ConnectionID header fails.
156 IMPORT_C void SetConnectionIDL(const TDesC8& aSubject);
159 * Returns the Length header value
160 * @return Length header value
163 IMPORT_C TInt Length() const;
166 * Sets the Length header value
167 * @param aLength The new Length header value
170 IMPORT_C void SetLength(TInt aLength);
173 * Returns the Time header value
174 * @return Time header value
177 IMPORT_C const TTime& Time() const;
180 * Sets the Time header value
181 * @param aTime The new Time header value
184 IMPORT_C void SetTime(const TTime& aTime);
186 ///Transport specific address getter, therefore implemented in the derived classes
187 IMPORT_C virtual TPtrC8 Addr() const = 0;
188 ///Transport specific address setter, therefore implemented in the derived classes
189 IMPORT_C virtual void SetAddrL(const TDesC8& aSubject) = 0;
191 ///Called by Store/Restore -- must be implemented in the derived class and call BaseInternaliseL first
192 IMPORT_C virtual void InternalizeL(RMsvReadStream& aReadStream) = 0;
193 ///Called by Store/Restore -- must be implemented in the derived class and call BaseExternaliseL first
194 IMPORT_C virtual void ExternalizeL(RMsvWriteStream& aWriteStream) const = 0;
197 //Base class functions that MUST be called by the derived classes
200 * Internalizes the CObexMtmHeader object from a stream.Must be called by the derived class BEFORE
201 * that class internalizes
203 * @param aReadStream The stream to be read from
204 * @leave KErrXXX Standard EPOC stream leave codes
207 IMPORT_C void BaseInternalizeL(RMsvReadStream& aReadStream);
210 * Externalizes CObexMtmHeader object to a stream. Must be called by the derived class BEFORE
211 * that class externalizes
212 * @param aWriteStream The stream to be written to
213 * @leave KErrXXX Standard EPOC stream leave codes
216 IMPORT_C void BaseExternalizeL(RMsvWriteStream& aWriteStream) const;
219 * Leaving constructor, which must be called by the base classes to initialise the HBufC members
222 IMPORT_C void BaseConstructL();
227 * Default constructor, which assigns the TUid for the stream and stream version
229 * @param aStreamUid Uid of the header stream--specified in the derived class
230 * @param aStreamVersion Version number for the stream, must be specified in the derived classes
231 * and incremented each time a new version of the stream is implemented.
234 IMPORT_C CObexMtmHeader(TUid aStreamUid, TInt32 aStreamVersion);
237 HBufC* iName; ///< The name of the Obex object
238 HBufC* iSubject; ///< The subject of the Obex object
239 HBufC8* iType; ///< The type of the Obex object
240 TInt iLength; ///< The size of the Obex object
241 TTime iTime; ///< Date and time of last modification of Obex object
242 HBufC8* iTarget; ///< Byte sequence identifying intended target
243 HBufC8* iConnectionID; ///< The transport type
245 const TUid iStreamUid; ///< Uid of the header stream
246 const TInt32 iStreamVersion; ///< Version number for the streams
248 #endif //!defined (__OBEXHEADER_H__)