epoc32/include/mw/msvstore.h
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 2fe1408b6811
child 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/mw/msvstore.h	Wed Mar 31 12:27:01 2010 +0100
     1.3 @@ -0,0 +1,246 @@
     1.4 +// Copyright (c) 1998-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 +#if !defined(__MSVSTORE_H__)
    1.20 +#define __MSVSTORE_H__
    1.21 +
    1.22 +#include <e32base.h>
    1.23 +#include <s32file.h>
    1.24 +#include <msvstd.h>
    1.25 +
    1.26 +class CMsvCachedStore;
    1.27 +class CMsvBodyText;
    1.28 +class CMsvAttachment;
    1.29 +
    1.30 +//**********************************
    1.31 +// MMsvStoreObserver
    1.32 +//**********************************
    1.33 +//
    1.34 +// 
    1.35 +//
    1.36 +
    1.37 +class MMsvStoreObserver
    1.38 +/** Observer interface to get events relating to a message store.
    1.39 +
    1.40 +This is used in the derivation of CMsvServerEntry and CMsvEntry.
    1.41 +
    1.42 +@publishedAll
    1.43 +@released
    1.44 +*/
    1.45 +	{
    1.46 +public:
    1.47 +/**
    1.48 +Defines message store event types.
    1.49 +
    1.50 +@publishedAll
    1.51 +@released
    1.52 +*/
    1.53 +	enum TMsvStoreEvent {	/** A read-only message store was closed. */
    1.54 +							EMsvReadStoreClosed,	// read only CMsvStore closed
    1.55 +							/** An editable message store was closed. */
    1.56 +							EMsvEditStoreClosed		// edit only CMsvStore closed
    1.57 +							};	
    1.58 +public:
    1.59 +	/** Receives a message store event.
    1.60 +
    1.61 +	@param aEvent Event type
    1.62 +	@param aId ID of the message to which the event relates
    1.63 +	*/
    1.64 +	virtual void HandleStoreEvent(TMsvStoreEvent aEvent, TMsvId aId)=0;
    1.65 +	};
    1.66 +
    1.67 +
    1.68 +//**********************************
    1.69 +// CMsvStore
    1.70 +//**********************************
    1.71 +//
    1.72 +// The entry structure that the client uses
    1.73 +//
    1.74 +
    1.75 +/*
    1.76 +Uid which are not needed to be known outside CMsvStore
    1.77 +@internalComponent
    1.78 +@deprecated
    1.79 +*/
    1.80 +const TUid KMsvEntryRichTextBody={0x10000F70};
    1.81 +
    1.82 +
    1.83 +/**
    1.84 +UId for the 16-bit chunk storage mechanism.
    1.85 +@internalTechnology
    1.86 +@prototype
    1.87 +*/
    1.88 +const TUid KMsvPlainBodyText16={0x10000F90};
    1.89 +
    1.90 +/**
    1.91 +UId for the 8-bit chunk storage mechanism.
    1.92 +@internalTechnology
    1.93 +@prototype
    1.94 +*/
    1.95 +const TUid KMsvPlainBodyText8={0x10000F80};
    1.96 +
    1.97 +class MMsvAttachmentManager;
    1.98 +class MMsvAttachmentManagerSync;
    1.99 +class CMsvAttachmentManager;
   1.100 +class MMsvStoreManager;
   1.101 +class CMsvPlainBodyText;
   1.102 +class CMsvStore : public CBase
   1.103 +/** Provides an interface over the message store that is associated with a message 
   1.104 +entry. It is similar to the dictionary store in supporting the concept of 
   1.105 +streams referenced by UID. 
   1.106 +
   1.107 +This class is intended for use by MTM implementations. Message client applications 
   1.108 +access the store through the higher-level functions provided by Client-side 
   1.109 +and User Interface MTMs.
   1.110 +
   1.111 +A CMsvStore object is created by a CMsvEntry object and passed to a client 
   1.112 +process. The client process then becomes responsible for deleting the CMsvStore 
   1.113 +object. The store can be opened in two modes, read or edit, and only one CMsvStore 
   1.114 +object can have edit access to a store. 
   1.115 +
   1.116 +CMsvStore provides functions for general manipulation of the store, and for 
   1.117 +accessing the standard body text stream. RMsvReadStream and RMsvWriteStream 
   1.118 +must be used to access other streams. 
   1.119 +@publishedAll
   1.120 +@released
   1.121 +*/
   1.122 +	{
   1.123 +public:
   1.124 +	IMPORT_C ~CMsvStore();
   1.125 +	//
   1.126 +	IMPORT_C void StoreBodyTextL(const CRichText& aRichTextBody);
   1.127 +	
   1.128 +	IMPORT_C void RestoreBodyTextL(CRichText& aRichTextBody);
   1.129 +	IMPORT_C void RestoreBodyTextL(CRichText& aRichTextBody, TUint aCharsetOverride);
   1.130 +	
   1.131 +	IMPORT_C void DeleteBodyTextL();
   1.132 +	IMPORT_C TBool HasBodyTextL() const;
   1.133 +	//
   1.134 +	IMPORT_C void DeleteL(); // deletes the message store
   1.135 +	IMPORT_C TInt SizeL(); // the size of the store
   1.136 +	//
   1.137 +	// The following give the Dictionary store interface
   1.138 +	IMPORT_C TBool IsNullL() const;
   1.139 +	IMPORT_C TBool IsPresentL(TUid aUid) const;
   1.140 +	IMPORT_C void Remove(TUid aUid);
   1.141 +	IMPORT_C void RemoveL(TUid aUid);
   1.142 +	IMPORT_C void Revert();
   1.143 +	IMPORT_C void RevertL();
   1.144 +	IMPORT_C TInt Commit(); 
   1.145 +	IMPORT_C void CommitL();
   1.146 +	
   1.147 +	// Attachment Management
   1.148 +	IMPORT_C MMsvAttachmentManager& AttachmentManagerL();
   1.149 +	IMPORT_C MMsvAttachmentManagerSync& AttachmentManagerExtensionsL();
   1.150 +	
   1.151 +	// APIs to get the CMsvPlainBodyText interface.
   1.152 +	IMPORT_C CMsvPlainBodyText* InitialisePlainBodyTextForWriteL(TBool aIs8Bit, TUint aCharsetId, TUint aDefaultCharsetId);
   1.153 +	IMPORT_C CMsvPlainBodyText* InitialisePlainBodyTextForReadL(TInt aChunkLength);
   1.154 +
   1.155 +	/**
   1.156 +	@internalTechnology
   1.157 +	@released
   1.158 +	*/
   1.159 +	IMPORT_C void CreateShareProtectedAttachmentL(const TDesC& aFileName, RFile& aAttachmentFile, CMsvAttachment* aAttachmentInfo);
   1.160 +	void Restore8BitBodyTextL(RFileReadStream& aInputStream);
   1.161 +	
   1.162 +protected:
   1.163 +
   1.164 +	IMPORT_C CMsvStore(MMsvStoreObserver& aObserver, RFs& aFs, TMsvId aId, MMsvStoreManager& aStoreManager);
   1.165 +	IMPORT_C static CMsvStore* OpenForReadL(MMsvStoreObserver& aObserver, RFs& aFs, MMsvStoreManager& aStoreManager, TMsvId aId);
   1.166 +	IMPORT_C static CMsvStore* OpenForWriteL(MMsvStoreObserver& aObserver, RFs& aFs, MMsvStoreManager& aStoreManager, TMsvId aId);
   1.167 +
   1.168 +private:
   1.169 +	
   1.170 +	
   1.171 +	void ConstructL(TBool aReadOnly);
   1.172 +	
   1.173 +	//Methods to handle plain bodytext.
   1.174 +	void RestorePlainBodyTextL(CRichText& aRichText, TUint aCharsetOverride);
   1.175 +	void GetRichTextFrom8BitL(RFile& aBodyTextFile, CRichText& aRichText, TUint aCharSet, TUint aDefaultCharSet);
   1.176 +	void GetRichTextFrom16BitL(RFile& aBodyTextFile, CRichText& aRichText);
   1.177 +	void Convert8BitToRichTextL(RFile& aBodyTextFile, CRichText& aRichText, TUint aCharSet, TUint aDefaultCharSet);
   1.178 +
   1.179 +	void Lock();
   1.180 +	inline const CMsvCachedStore& Store() const;
   1.181 +	inline CMsvCachedStore& Store();
   1.182 +private:
   1.183 +	enum {EMsvStoreUnlocked, EMsvStoreLocked} iLockStatus;
   1.184 +
   1.185 +	RFs& iFs;
   1.186 +	MMsvStoreObserver& iObserver;
   1.187 +	
   1.188 +
   1.189 +	const TMsvId iId;
   1.190 +	CMsvCachedStore* iStore;
   1.191 +	TBool iConstructed;
   1.192 +	CMsvBodyText* iBodyText;
   1.193 +	
   1.194 +	MMsvStoreManager& iStoreManager;
   1.195 +	CMsvAttachmentManager* iAttachmentManager;
   1.196 +
   1.197 +friend class CMsvEntry;
   1.198 +friend class CMsvServerEntry;
   1.199 +friend class RMsvReadStream;
   1.200 +friend class RMsvWriteStream;
   1.201 +	};
   1.202 +
   1.203 +
   1.204 +class RMsvReadStream : public RReadStream
   1.205 +/** Accesses the streams in a message store with read access. 
   1.206 +
   1.207 +Before it is used, 
   1.208 +a CMsvStore must have been opened on the message store with read or read/write 
   1.209 +access.
   1.210 +
   1.211 +This class is intended for use by MTM implementations to store MTM-specific 
   1.212 +information. Message client applications access the store through the higher-level 
   1.213 +functions provided by Client-side and User Interface MTMs.
   1.214 +
   1.215 +Most of its functionality is provided by the base class RReadStream. 
   1.216 +@publishedAll
   1.217 +@released
   1.218 +*/
   1.219 +	{
   1.220 +public:
   1.221 +	IMPORT_C void OpenL(const CMsvStore& aMsvStore, TUid aUid);
   1.222 +	IMPORT_C void OpenLC(const CMsvStore& aMsvStore,TUid aUid);
   1.223 +	void OpenLC(CMsvCachedStore& aStore,TUid aUid);
   1.224 +	};
   1.225 +
   1.226 +
   1.227 +class RMsvWriteStream : public RWriteStream
   1.228 +/** Accesses the streams in a message store with write access, or creates new streams. 
   1.229 +Before it is used, a CMsvStore must have been opened on the message store 
   1.230 +with write access.
   1.231 +
   1.232 +This class is intended for use by MTM implementations to store MTM-specific 
   1.233 +information. Message client applications access the store through the higher-level 
   1.234 +functions provided by Client-side and User Interface MTMs.
   1.235 +
   1.236 +Most of its functionality is provided by the base class RWriteStream. 
   1.237 +@publishedAll
   1.238 +@released
   1.239 +*/
   1.240 +	{
   1.241 +public:
   1.242 +	IMPORT_C void AssignLC(CMsvStore &aMsvStore, TUid aUid);
   1.243 +	IMPORT_C void AssignL(CMsvStore &aMsvStore, TUid aUid);
   1.244 +	void AssignLC(CMsvCachedStore &aStore, TUid aUid);
   1.245 +	};
   1.246 +
   1.247 +
   1.248 +
   1.249 +#endif