epoc32/include/pushentry.h
branchSymbian2
changeset 2 2fe1408b6811
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/pushentry.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,283 @@
     1.4 +// Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// 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
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +
    1.20 +
    1.21 +/**
    1.22 + @file
    1.23 + @publishedPartner
    1.24 + @released
    1.25 +*/
    1.26 +
    1.27 +#ifndef __PUSHENTRY_H__
    1.28 +#define __PUSHENTRY_H__
    1.29 +
    1.30 +#include <e32std.h>
    1.31 +#include <msvapi.h>
    1.32 +#include <msvstd.h>
    1.33 +
    1.34 +
    1.35 +/** UID for the WAP Push MTM. */
    1.36 +const TUid KUidMtmWapPush = {0x10009158};
    1.37 +/** UID for WAP Push SI messages. */
    1.38 +const TUid KUidWapPushMsgSI = {0x10009159};
    1.39 +/** UID for WAP Push SL messages. */
    1.40 +const TUid KUidWapPushMsgSL = {0x1000915A};
    1.41 +/** UID for WAP Push multipart messages. */
    1.42 +const TUid KUidWapPushMsgMultiPart = {0x1000915B};
    1.43 +/** UID for WAP Push unknown-type messages. */
    1.44 +const TUid KUidWapPushMsgUnknown = {0x1000915C};
    1.45 +
    1.46 +
    1.47 +// Defines for Masking values used to extract status information from iMtmData1
    1.48 +/** TMsvEntry::iMtmData1 mask to get Status value. */
    1.49 +const TInt32 KPushMaskOnlyStatus			= 0x0000000F;
    1.50 +/** TMsvEntry::iMtmData1 mask to all bits except those for the Status value. */
    1.51 +const TInt32 KPushMaskEverythingButStatus	= 0xFFFFFFF0;
    1.52 +/** TMsvEntry::iMtmData1 mask to get Action value. */
    1.53 +const TInt32 KPushMaskOnlyAction			= 0x000000F0;
    1.54 +/** TMsvEntry::iMtmData1 mask to all bits except those for the Action value. */
    1.55 +const TInt32 KPushMaskEverythingButAction	= 0xFFFFFF0F;
    1.56 +
    1.57 +
    1.58 +// Defines for Leave Codes
    1.59 +/** Base value for WAP Push-specific errors. */
    1.60 +const TInt KWPushBaseError		 =	-1100;
    1.61 +/** CPushMsgEntryBase::UpdateL() called without a message server entry being loaded 
    1.62 +error. */
    1.63 +const TInt KWPushNoMsgIndexEntry =   (KWPushBaseError-1);
    1.64 +/** Longest String Allowed. */
    1.65 +const TInt KLongestStringAllowed=KMaxTInt32;
    1.66 +
    1.67 +
    1.68 +/**
    1.69 +WAP Push Server MTM state information.
    1.70 +
    1.71 +This enum is used by TPushMTMProgress and CWapPushServerMtm.
    1.72 +
    1.73 +@publishedPartner
    1.74 +@released
    1.75 +@see TPushMTMProgress 
    1.76 +*/
    1.77 +enum TPushServerMTMState
    1.78 +	{
    1.79 +	/** Server is waiting for a command. */
    1.80 +	EWapPushServerMtmWaiting,
    1.81 +	/** Server is executing a Change command. */
    1.82 +	EWapPushServerMtmChange,
    1.83 +	/** Server is executing a Create command. */
    1.84 +	EWapPushServerMtmCreate,
    1.85 +	/** Server is executing a Delete command. */
    1.86 +	EWapPushServerMtmDelete,
    1.87 +	/** Unused. */
    1.88 +	EWapPushServerMtmComplete
    1.89 +	};
    1.90 +
    1.91 +
    1.92 +/** 
    1.93 +Encapsulates progress information returned for asynchronous operations with 
    1.94 +the WAP Push Server MTM. 
    1.95 +
    1.96 +This allows error status and ID of current entry to be returned to caller.
    1.97 +
    1.98 +@publishedPartner
    1.99 +@released
   1.100 +@see CMsvOperation::ProgressL() 
   1.101 +*/
   1.102 +class TPushMTMProgress
   1.103 +	{
   1.104 +public:
   1.105 +	/** Error code. */
   1.106 +	TInt				iError; // client side needs to be informed of an error
   1.107 +	/** The number of entries on which the operation was or will be attempted. */
   1.108 +	TInt				iTotalMsgs;
   1.109 +	/** The number of entries which have been processed. */
   1.110 +	TInt				iMsgsProcessed;
   1.111 +	/** ID of the (first) message being processed. */
   1.112 +	TMsvId				iMsgId;
   1.113 +	/** Server state information. */
   1.114 +	TPushServerMTMState iPushState;// Operation that is currently in progress
   1.115 +	};
   1.116 +
   1.117 +/** 
   1.118 +Packages a TPushMTMProgress object into a descriptor. 
   1.119 +
   1.120 +@publishedPartner
   1.121 +@released
   1.122 +*/
   1.123 +typedef TPckgBuf<TPushMTMProgress> TPushMTMProgressBuf;
   1.124 +
   1.125 +
   1.126 +/** Panic name and codes */
   1.127 +_LIT(KPushPanicMoniker, "PUSHENTRY");
   1.128 +
   1.129 +/**
   1.130 +@internalComponent
   1.131 +@released
   1.132 +*/
   1.133 +enum TPushEntryPanic	
   1.134 +	{
   1.135 +	/** Null Ids for entries not valid (Service, &Msg). */
   1.136 +	EPushEntryNullMsgId,
   1.137 +	/** Only save messages under the Service Entry. */
   1.138 +	EPushEntryServiceIdMismatch,
   1.139 +	/** Not a WAP Push  MTM. */
   1.140 +	EPushEntryWrongMTMtype,
   1.141 +	/** iBioType value in TMsvEntry don't match Uid for Push Entry class. */
   1.142 +	EPushEntryWrongMsgtype
   1.143 +	};
   1.144 +
   1.145 +
   1.146 +/** 
   1.147 +Abstract base class for classes that handle storage of WAP Push Messages in 
   1.148 +the message server.
   1.149 +
   1.150 +The class acts as a wrapper for TMsvEntry, and provides accessors and storage 
   1.151 +functionality. Key pieces of data are mapped onto certain TMsvEntry fields: 
   1.152 +this speeds up access by applications to this data. This base class has the 
   1.153 +generic mappings and storage behaviour. More specialised mappings and storage 
   1.154 +are defined in each derived class.
   1.155 +
   1.156 +The mappings of data to TMsvEntry fields standard to all classes are:
   1.157 +
   1.158 +Push Message Type UID: TMsvEntry::iBioType
   1.159 +
   1.160 +Status: sets bits 0-3 of TMsvEntry::iMtmData1
   1.161 +
   1.162 +Some derived classes need to store more data than there are available fields 
   1.163 +in TMsvEntry, and the Unknown type potentially requires large data capacity. 
   1.164 +This additional data is saved in the message store associated with the message 
   1.165 +entry. Derived classes provide this functionality by overriding ExternalizeL() 
   1.166 +and InternalizeL() implementations. The base class itself uses the message store
   1.167 +to store the WAP Push message's raw header and From information.
   1.168 +
   1.169 +@publishedPartner
   1.170 +@released
   1.171 +*/
   1.172 +class CPushMsgEntryBase: public CBase
   1.173 +	{
   1.174 +public:
   1.175 +	/** 
   1.176 +	WAP Push Message status values. 
   1.177 +	
   1.178 +	@internalTechnology
   1.179 +	@released
   1.180 +	*/
   1.181 +	enum TPushMsgStatus	
   1.182 +		{
   1.183 +		/** Message is valid. */
   1.184 +		EPushMsgStatusValid = 0,
   1.185 +		/** Message is expired. */
   1.186 +		EPushMsgStatusExpired,
   1.187 +		/** Message is deleted. */
   1.188 +		EPushMsgStatusDeleted,
   1.189 +		/** Message is corrupt. */
   1.190 +		EPushMsgStatusCorrupt
   1.191 +		};
   1.192 +
   1.193 +	IMPORT_C CPushMsgEntryBase();
   1.194 +
   1.195 +	IMPORT_C virtual ~CPushMsgEntryBase();
   1.196 +
   1.197 +	// Creates its own CMsvStore from the CMsvSession & calls StoreL()
   1.198 +	IMPORT_C virtual TMsvId SaveL(CMsvSession& aSession, TMsvId aParent);
   1.199 +	IMPORT_C virtual void UpdateL(CMsvSession& aSession);
   1.200 +
   1.201 +	// Creates its own CMsvStore from the CMsvSession & calls RestoreL()
   1.202 +	IMPORT_C virtual void RetrieveL(CMsvSession& aSession, TMsvId aMsgId);
   1.203 +	
   1.204 +	IMPORT_C void SetEntry(const TMsvEntry& aEntry);
   1.205 +	IMPORT_C void SetStatus(TInt aStatusFlags);
   1.206 +	IMPORT_C const TDesC8&  Header() const;
   1.207 +	IMPORT_C void SetHeaderL(const TDesC8& aHeader);
   1.208 +	IMPORT_C const TDesC8& From() const; 
   1.209 +	IMPORT_C void SetFromL(const TDesC8& aFrom);
   1.210 +
   1.211 +	/**
   1.212 +	Gets the push message content type.
   1.213 +	
   1.214 +	@return
   1.215 +	Content type 
   1.216 +	*/
   1.217 +	virtual const TDesC& ContentType() const =0;
   1.218 +	
   1.219 +	/** 
   1.220 +	Gets the push message type.
   1.221 +	
   1.222 +	Each derived class represents a different push message type, and implements 
   1.223 +	this to return the appropriate value.
   1.224 +	
   1.225 +	@return 
   1.226 +	Push message type
   1.227 +	*/
   1.228 +	virtual TInt32 PushMsgType() const =0;
   1.229 +	inline const TMsvEntry& Entry() const;
   1.230 +	inline TInt Status() const;
   1.231 +
   1.232 +	IMPORT_C const TDesC& MsgDescription() const;
   1.233 +	IMPORT_C void SetMsgDescriptionL(const TDesC& aDescription);
   1.234 +	IMPORT_C const TDesC& MsgDetails() const;
   1.235 +	IMPORT_C void SetMsgDetailsL(const TDesC& aDetails);
   1.236 +	IMPORT_C const TTime& ReceivedDate() const;
   1.237 +	IMPORT_C TInt AppID(TPtrC8& aAppURI, TInt& aAppID, TBool& aIsAnInt) const;
   1.238 +
   1.239 +protected:
   1.240 +	IMPORT_C virtual void ConstructL(const TPtrC8& aAppURI);
   1.241 +	IMPORT_C virtual void ConstructL(const TInt& aAppID);
   1.242 +	IMPORT_C virtual void ConstructL();
   1.243 +
   1.244 +	// No  matching StoreL due to different needs for saving & updating msg's
   1.245 +	IMPORT_C void RestoreL(CMsvStore& aStore );
   1.246 +	IMPORT_C virtual void ExternalizeL(RMsvWriteStream& aStream);
   1.247 +	IMPORT_C virtual void InternalizeL(RMsvReadStream& aStream);
   1.248 +	
   1.249 +	/** 	
   1.250 +	Sets the push message type.
   1.251 +	
   1.252 +	Each derived class represents a different push message type, and implements 
   1.253 +	this to set the appropriate value. 
   1.254 +	*/
   1.255 +	virtual void SetPushMsgType()=0;// Only the object can set it's push type - class dependent 
   1.256 +	void DoSaveL(CMsvEntry& aMsvEntry);
   1.257 +
   1.258 +protected:
   1.259 +
   1.260 +	/** Message server entry. */
   1.261 +	TMsvEntry iEntry;
   1.262 +
   1.263 +	/** Copy of the message server entry Details field. */
   1.264 +	HBufC* iMsgDetails;    
   1.265 +	/** Copy of the message server entry Description field. */
   1.266 +	HBufC* iMsgDescription;
   1.267 +							    
   1.268 +	/** WAP Push message raw header buffer. */
   1.269 +	HBufC8* iHeader;
   1.270 +	/** From field buffer. */
   1.271 +	HBufC8* iFrom;
   1.272 +	/** Set to true if the object has an associated entry in the message server index. */
   1.273 +	TBool iHasServerEntry;
   1.274 +
   1.275 +	/** Message AppID as a string. Only one of iAppIDString and iAppIdInt will be set.*/
   1.276 +	HBufC8* iAppIDString;
   1.277 +	/** Message AppID as a number. Only one of iAppIDString and iAppIdInt will be set.*/
   1.278 +	TInt iAppIdInt;
   1.279 +	};
   1.280 +
   1.281 +
   1.282 +
   1.283 +
   1.284 +#include <pushentry.inl>
   1.285 +
   1.286 +#endif