epoc32/include/obexheader.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
permissions -rw-r--r--
Final list of Symbian^2 public API header files
     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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // $Workfile: obexHeader.h $
    15 // $Author: Stevep $
    16 // $Revision: 13 $
    17 // $Date: 25/03/02 10:57 $
    18 // 
    19 //
    20 
    21 #if !defined (__OBEXHEADER_H__)
    22 #define __OBEXHEADER_H__
    23 
    24 
    25 #include <e32std.h> 
    26 #include <e32base.h>    //CBase 
    27 
    28 class CMsvStore;
    29 class RMsvReadStream;
    30 class RMsvWriteStream;
    31 
    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;
    36 
    37 
    38 class CObexMtmHeader : public CBase
    39 /**
    40 Base class for OBEX object headers. Allows them to be stored and restored to and from the
    41 CMsvStore.
    42  
    43 @internalTechnology
    44 @released
    45 */
    46 	{
    47 public:
    48 
    49 	/**
    50 	* Destructor which deletes all of the HBufC members
    51 	*/
    52 
    53     IMPORT_C ~CObexMtmHeader();
    54 
    55 	/**
    56 	 * Creates a stream in aStore and externalises this object to it.
    57 	 *
    58 	 *
    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.
    63 	 */
    64     
    65 	IMPORT_C void StoreL(CMsvStore& aStore) const;
    66     
    67 	/**
    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.
    73 	 */
    74 
    75 	IMPORT_C void RestoreL(const CMsvStore& aStore);
    76 
    77 	//Setters/Getters
    78     
    79 	/**
    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.
    82 	 */
    83 	
    84 	IMPORT_C TPtrC Name() const;
    85 
    86 	/**
    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.
    90 	 */
    91 
    92     IMPORT_C void SetNameL(const TDesC& aSubject);
    93 
    94 	/**
    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.
    97 	 */
    98 
    99     IMPORT_C TPtrC Subject() const;
   100     
   101 	/**
   102 	 * Sets the Subject header value.
   103 	 *
   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.
   106 	 */
   107 
   108 	IMPORT_C void SetSubjectL(const TDesC& aSubject);
   109 
   110     /**
   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.
   113 	 */
   114 	
   115 	IMPORT_C TPtrC8 Type() const;
   116     
   117 	/**
   118 	 * Sets the Type header value.
   119 	 *
   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.
   122 	 */
   123 
   124 	IMPORT_C void SetTypeL(const TDesC8& aSubject);
   125 
   126     /**
   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.
   129 	 */
   130 
   131 	IMPORT_C TPtrC8 Target() const;
   132     
   133 	/**
   134 	 * Sets the ConnectionID header value.
   135 	 * 
   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.
   138 	 */
   139 	
   140 	IMPORT_C void SetTargetL(const TDesC8& aSubject);
   141 
   142     /**
   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.
   145 	 */
   146 	
   147 	IMPORT_C TPtrC8 ConnectionID() const;
   148     
   149 	/**
   150 	 * Sets the ConnectionID header value.
   151 	 * 
   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.
   154 	 */
   155 	
   156 	IMPORT_C void SetConnectionIDL(const TDesC8& aSubject);
   157 
   158 	/**
   159 	 * Returns the Length header value
   160 	 * @return Length header value
   161 	 */
   162 	
   163 	IMPORT_C TInt Length() const;
   164 	
   165 	/**
   166 	 * Sets the Length header value
   167 	 * @param aLength The new Length header value
   168 	 */
   169 
   170 	IMPORT_C void SetLength(TInt aLength);
   171 
   172 	/**
   173 	 * Returns the Time header value
   174 	 * @return Time header value
   175 	 */
   176 
   177 	IMPORT_C const TTime& Time() const;
   178 	
   179 	/**
   180 	 * Sets the Time header value
   181 	 * @param aTime The new Time header value
   182 	 */
   183 
   184 	IMPORT_C void SetTime(const TTime& aTime);
   185 
   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;
   190 
   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;
   195 
   196 protected:
   197 	//Base class functions that MUST be called by the derived classes
   198     
   199 	/**
   200 	 * Internalizes the CObexMtmHeader object from a stream.Must be called by the derived class BEFORE 
   201 	 * that class internalizes
   202 	 *
   203 	 * @param aReadStream The stream to be read from
   204 	 * @leave KErrXXX Standard EPOC stream leave codes
   205 	 */
   206 	
   207 	IMPORT_C void BaseInternalizeL(RMsvReadStream& aReadStream);
   208 
   209 	/**
   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
   214 	 */
   215 
   216     IMPORT_C void BaseExternalizeL(RMsvWriteStream& aWriteStream) const;
   217 	
   218 	/**
   219 	 * Leaving constructor, which must be called by the base classes to initialise the HBufC members
   220 	 */
   221 	
   222 	IMPORT_C void BaseConstructL();
   223 
   224 protected:
   225 	
   226 	/**
   227 	 * Default constructor, which assigns the TUid for the stream and stream version
   228 	 *
   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.
   232 	 */
   233 
   234 	IMPORT_C CObexMtmHeader(TUid aStreamUid, TInt32 aStreamVersion);
   235 
   236 protected:
   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
   244 
   245 	const TUid		iStreamUid; ///< Uid of the header stream
   246 	const TInt32	iStreamVersion; ///< Version number for the streams
   247 	};
   248 #endif	//!defined (__OBEXHEADER_H__)