messagingfw/wappushfw/PushMsgEntry/inc/PushEntry.h
changeset 0 8e480a14352b
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     1 // Copyright (c) 2000-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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @publishedPartner
       
    19  @released
       
    20 */
       
    21 
       
    22 #ifndef __PUSHENTRY_H__
       
    23 #define __PUSHENTRY_H__
       
    24 
       
    25 #include <e32std.h>
       
    26 #include <msvapi.h>
       
    27 #include <msvstd.h>
       
    28 
       
    29 
       
    30 /** UID for the WAP Push MTM. */
       
    31 const TUid KUidMtmWapPush = {0x10009158};
       
    32 /** UID for WAP Push SI messages. */
       
    33 const TUid KUidWapPushMsgSI = {0x10009159};
       
    34 /** UID for WAP Push SL messages. */
       
    35 const TUid KUidWapPushMsgSL = {0x1000915A};
       
    36 /** UID for WAP Push multipart messages. */
       
    37 const TUid KUidWapPushMsgMultiPart = {0x1000915B};
       
    38 /** UID for WAP Push unknown-type messages. */
       
    39 const TUid KUidWapPushMsgUnknown = {0x1000915C};
       
    40 
       
    41 
       
    42 // Defines for Masking values used to extract status information from iMtmData1
       
    43 /** TMsvEntry::iMtmData1 mask to get Status value. */
       
    44 const TInt32 KPushMaskOnlyStatus			= 0x0000000F;
       
    45 /** TMsvEntry::iMtmData1 mask to all bits except those for the Status value. */
       
    46 const TInt32 KPushMaskEverythingButStatus	= 0xFFFFFFF0;
       
    47 /** TMsvEntry::iMtmData1 mask to get Action value. */
       
    48 const TInt32 KPushMaskOnlyAction			= 0x000000F0;
       
    49 /** TMsvEntry::iMtmData1 mask to all bits except those for the Action value. */
       
    50 const TInt32 KPushMaskEverythingButAction	= 0xFFFFFF0F;
       
    51 
       
    52 
       
    53 // Defines for Leave Codes
       
    54 /** Base value for WAP Push-specific errors. */
       
    55 const TInt KWPushBaseError		 =	-1100;
       
    56 /** CPushMsgEntryBase::UpdateL() called without a message server entry being loaded 
       
    57 error. */
       
    58 const TInt KWPushNoMsgIndexEntry =   (KWPushBaseError-1);
       
    59 /** Longest String Allowed. */
       
    60 const TInt KLongestStringAllowed=KMaxTInt32;
       
    61 
       
    62 
       
    63 /**
       
    64 WAP Push Server MTM state information.
       
    65 
       
    66 This enum is used by TPushMTMProgress and CWapPushServerMtm.
       
    67 
       
    68 @publishedPartner
       
    69 @released
       
    70 @see TPushMTMProgress 
       
    71 */
       
    72 enum TPushServerMTMState
       
    73 	{
       
    74 	/** Server is waiting for a command. */
       
    75 	EWapPushServerMtmWaiting,
       
    76 	/** Server is executing a Change command. */
       
    77 	EWapPushServerMtmChange,
       
    78 	/** Server is executing a Create command. */
       
    79 	EWapPushServerMtmCreate,
       
    80 	/** Server is executing a Delete command. */
       
    81 	EWapPushServerMtmDelete,
       
    82 	/** Unused. */
       
    83 	EWapPushServerMtmComplete
       
    84 	};
       
    85 
       
    86 
       
    87 /** 
       
    88 Encapsulates progress information returned for asynchronous operations with 
       
    89 the WAP Push Server MTM. 
       
    90 
       
    91 This allows error status and ID of current entry to be returned to caller.
       
    92 
       
    93 @publishedPartner
       
    94 @released
       
    95 @see CMsvOperation::ProgressL() 
       
    96 */
       
    97 class TPushMTMProgress
       
    98 	{
       
    99 public:
       
   100 	/** Error code. */
       
   101 	TInt				iError; // client side needs to be informed of an error
       
   102 	/** The number of entries on which the operation was or will be attempted. */
       
   103 	TInt				iTotalMsgs;
       
   104 	/** The number of entries which have been processed. */
       
   105 	TInt				iMsgsProcessed;
       
   106 	/** ID of the (first) message being processed. */
       
   107 	TMsvId				iMsgId;
       
   108 	/** Server state information. */
       
   109 	TPushServerMTMState iPushState;// Operation that is currently in progress
       
   110 	};
       
   111 
       
   112 /** 
       
   113 Packages a TPushMTMProgress object into a descriptor. 
       
   114 
       
   115 @publishedPartner
       
   116 @released
       
   117 */
       
   118 typedef TPckgBuf<TPushMTMProgress> TPushMTMProgressBuf;
       
   119 
       
   120 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
       
   121 /** Panic name and codes */
       
   122 _LIT(KPushPanicMoniker, "PUSHENTRY");
       
   123 
       
   124 /**
       
   125 @internalComponent
       
   126 @released
       
   127 */
       
   128 enum TPushEntryPanic	
       
   129 	{
       
   130 	/** Null Ids for entries not valid (Service, &Msg). */
       
   131 	EPushEntryNullMsgId,
       
   132 	/** Only save messages under the Service Entry. */
       
   133 	EPushEntryServiceIdMismatch,
       
   134 	/** Not a WAP Push  MTM. */
       
   135 	EPushEntryWrongMTMtype,
       
   136 	/** iBioType value in TMsvEntry don't match Uid for Push Entry class. */
       
   137 	EPushEntryWrongMsgtype
       
   138 	};
       
   139 #endif//SYMBIAN_ENABLE_SPLIT_HEADERS
       
   140 
       
   141 /** 
       
   142 Abstract base class for classes that handle storage of WAP Push Messages in 
       
   143 the message server.
       
   144 
       
   145 The class acts as a wrapper for TMsvEntry, and provides accessors and storage 
       
   146 functionality. Key pieces of data are mapped onto certain TMsvEntry fields: 
       
   147 this speeds up access by applications to this data. This base class has the 
       
   148 generic mappings and storage behaviour. More specialised mappings and storage 
       
   149 are defined in each derived class.
       
   150 
       
   151 The mappings of data to TMsvEntry fields standard to all classes are:
       
   152 
       
   153 Push Message Type UID: TMsvEntry::iBioType
       
   154 
       
   155 Status: sets bits 0-3 of TMsvEntry::iMtmData1
       
   156 
       
   157 Some derived classes need to store more data than there are available fields 
       
   158 in TMsvEntry, and the Unknown type potentially requires large data capacity. 
       
   159 This additional data is saved in the message store associated with the message 
       
   160 entry. Derived classes provide this functionality by overriding ExternalizeL() 
       
   161 and InternalizeL() implementations. The base class itself uses the message store
       
   162 to store the WAP Push message's raw header and From information.
       
   163 
       
   164 @publishedPartner
       
   165 @released
       
   166 */
       
   167 class CPushMsgEntryBase: public CBase
       
   168    {
       
   169 
       
   170 public:
       
   171 	
       
   172 	IMPORT_C CPushMsgEntryBase();
       
   173 
       
   174 	IMPORT_C virtual ~CPushMsgEntryBase();
       
   175 
       
   176 	// Creates its own CMsvStore from the CMsvSession & calls StoreL()
       
   177 	IMPORT_C virtual TMsvId SaveL(CMsvSession& aSession, TMsvId aParent);
       
   178 	IMPORT_C virtual void UpdateL(CMsvSession& aSession);
       
   179 
       
   180 	// Creates its own CMsvStore from the CMsvSession & calls RestoreL()
       
   181 	IMPORT_C virtual void RetrieveL(CMsvSession& aSession, TMsvId aMsgId);
       
   182 	
       
   183 	IMPORT_C void SetEntry(const TMsvEntry& aEntry);
       
   184 	IMPORT_C void SetStatus(TInt aStatusFlags);
       
   185 	IMPORT_C const TDesC8&  Header() const;
       
   186 	IMPORT_C void SetHeaderL(const TDesC8& aHeader);
       
   187 	IMPORT_C const TDesC8& From() const; 
       
   188 	IMPORT_C void SetFromL(const TDesC8& aFrom);
       
   189 
       
   190 	/**
       
   191 	Gets the push message content type.
       
   192 	
       
   193 	@return
       
   194 	Content type 
       
   195 	*/
       
   196 	virtual const TDesC& ContentType() const =0;
       
   197 	
       
   198 	/** 
       
   199 	Gets the push message type.
       
   200 	
       
   201 	Each derived class represents a different push message type, and implements 
       
   202 	this to return the appropriate value.
       
   203 	
       
   204 	@return 
       
   205 	Push message type
       
   206 	*/
       
   207 	virtual TInt32 PushMsgType() const =0;
       
   208 	inline const TMsvEntry& Entry() const;
       
   209 	inline TInt Status() const;
       
   210 
       
   211 	IMPORT_C const TDesC& MsgDescription() const;
       
   212 	IMPORT_C void SetMsgDescriptionL(const TDesC& aDescription);
       
   213 	IMPORT_C const TDesC& MsgDetails() const;
       
   214 	IMPORT_C void SetMsgDetailsL(const TDesC& aDetails);
       
   215 	IMPORT_C const TTime& ReceivedDate() const;
       
   216 	IMPORT_C TInt AppID(TPtrC8& aAppURI, TInt& aAppID, TBool& aIsAnInt) const;
       
   217 
       
   218 protected:
       
   219 	IMPORT_C virtual void ConstructL(const TPtrC8& aAppURI);
       
   220 	IMPORT_C virtual void ConstructL(const TInt& aAppID);
       
   221 	IMPORT_C virtual void ConstructL();
       
   222 
       
   223 	// No  matching StoreL due to different needs for saving & updating msg's
       
   224 	IMPORT_C void RestoreL(CMsvStore& aStore );
       
   225 	IMPORT_C virtual void ExternalizeL(RMsvWriteStream& aStream);
       
   226 	IMPORT_C virtual void InternalizeL(RMsvReadStream& aStream);
       
   227 	
       
   228 	/** 	
       
   229 	Sets the push message type.
       
   230 	
       
   231 	Each derived class represents a different push message type, and implements 
       
   232 	this to set the appropriate value. 
       
   233 	*/
       
   234 	virtual void SetPushMsgType()=0;// Only the object can set it's push type - class dependent 
       
   235 	void DoSaveL(CMsvEntry& aMsvEntry);
       
   236 
       
   237 protected:
       
   238 
       
   239 	/** Message server entry. */
       
   240 	TMsvEntry iEntry;
       
   241 
       
   242 	/** Copy of the message server entry Details field. */
       
   243 	HBufC* iMsgDetails;    
       
   244 	/** Copy of the message server entry Description field. */
       
   245 	HBufC* iMsgDescription;
       
   246 							    
       
   247 	/** WAP Push message raw header buffer. */
       
   248 	HBufC8* iHeader;
       
   249 	/** From field buffer. */
       
   250 	HBufC8* iFrom;
       
   251 	/** Set to true if the object has an associated entry in the message server index. */
       
   252 	TBool iHasServerEntry;
       
   253 
       
   254 	/** Message AppID as a string. Only one of iAppIDString and iAppIdInt will be set.*/
       
   255 	HBufC8* iAppIDString;
       
   256 	/** Message AppID as a number. Only one of iAppIDString and iAppIdInt will be set.*/
       
   257 	TInt iAppIdInt;
       
   258 
       
   259 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
   260 private:
       
   261     /** 
       
   262 	WAP Push Message status values. 
       
   263 	*/
       
   264 	enum TPushMsgStatus	
       
   265 		{
       
   266 		/** Message is valid. */
       
   267 		EPushMsgStatusValid = 0,
       
   268 		/** Message is expired. */
       
   269 		EPushMsgStatusExpired,
       
   270 		/** Message is deleted. */
       
   271 		EPushMsgStatusDeleted,
       
   272 		/** Message is corrupt. */
       
   273 		EPushMsgStatusCorrupt
       
   274 		};
       
   275 private:
       
   276 	friend class CWapPushMsgUtils;
       
   277     friend class CMultiPartRelAndAltContentHandler;
       
   278 	friend class CSISLPushMsgUtils;
       
   279 #else
       
   280 public:
       
   281     /** 
       
   282 	WAP Push Message status values. 
       
   283 	*/
       
   284 	enum TPushMsgStatus	
       
   285 		{
       
   286 		/** Message is valid. */
       
   287 		EPushMsgStatusValid = 0,
       
   288 		/** Message is expired. */
       
   289 		EPushMsgStatusExpired,
       
   290 		/** Message is deleted. */
       
   291 		EPushMsgStatusDeleted,
       
   292 		/** Message is corrupt. */
       
   293 		EPushMsgStatusCorrupt
       
   294 		};
       
   295 #endif//SYMBIAN_ENABLE_SPLIT_HEADERS
       
   296 	};
       
   297 
       
   298 #include <pushentry.inl>
       
   299 
       
   300 #endif