williamr@2: // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@2: // 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 williamr@2: // which accompanies this distribution, and is available williamr@2: // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // williamr@2: williamr@2: #if !defined(__MSVSTORE_H__) williamr@2: #define __MSVSTORE_H__ williamr@2: williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: williamr@2: class CMsvCachedStore; williamr@2: class CMsvBodyText; williamr@2: class CMsvAttachment; williamr@2: williamr@2: //********************************** williamr@2: // MMsvStoreObserver williamr@2: //********************************** williamr@2: // williamr@2: // williamr@2: // williamr@2: williamr@2: class MMsvStoreObserver williamr@2: /** Observer interface to get events relating to a message store. williamr@2: williamr@2: This is used in the derivation of CMsvServerEntry and CMsvEntry. williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: /** williamr@2: Defines message store event types. williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: enum TMsvStoreEvent { /** A read-only message store was closed. */ williamr@2: EMsvReadStoreClosed, // read only CMsvStore closed williamr@2: /** An editable message store was closed. */ williamr@2: EMsvEditStoreClosed // edit only CMsvStore closed williamr@2: }; williamr@2: public: williamr@2: /** Receives a message store event. williamr@2: williamr@2: @param aEvent Event type williamr@2: @param aId ID of the message to which the event relates williamr@2: */ williamr@2: virtual void HandleStoreEvent(TMsvStoreEvent aEvent, TMsvId aId)=0; williamr@2: }; williamr@2: williamr@2: williamr@2: //********************************** williamr@2: // CMsvStore williamr@2: //********************************** williamr@2: // williamr@2: // The entry structure that the client uses williamr@2: // williamr@2: williamr@2: /* williamr@2: Uid which are not needed to be known outside CMsvStore williamr@2: @internalComponent williamr@2: @deprecated williamr@2: */ williamr@2: const TUid KMsvEntryRichTextBody={0x10000F70}; williamr@2: williamr@2: williamr@2: /** williamr@2: UId for the 16-bit chunk storage mechanism. williamr@2: @internalTechnology williamr@2: @prototype williamr@2: */ williamr@2: const TUid KMsvPlainBodyText16={0x10000F90}; williamr@2: williamr@2: /** williamr@2: UId for the 8-bit chunk storage mechanism. williamr@2: @internalTechnology williamr@2: @prototype williamr@2: */ williamr@2: const TUid KMsvPlainBodyText8={0x10000F80}; williamr@2: williamr@2: class MMsvAttachmentManager; williamr@2: class MMsvAttachmentManagerSync; williamr@2: class CMsvAttachmentManager; williamr@2: class MMsvStoreManager; williamr@2: class CMsvPlainBodyText; williamr@2: class CMsvStore : public CBase williamr@2: /** Provides an interface over the message store that is associated with a message williamr@2: entry. It is similar to the dictionary store in supporting the concept of williamr@2: streams referenced by UID. williamr@2: williamr@2: This class is intended for use by MTM implementations. Message client applications williamr@2: access the store through the higher-level functions provided by Client-side williamr@2: and User Interface MTMs. williamr@2: williamr@2: A CMsvStore object is created by a CMsvEntry object and passed to a client williamr@2: process. The client process then becomes responsible for deleting the CMsvStore williamr@2: object. The store can be opened in two modes, read or edit, and only one CMsvStore williamr@2: object can have edit access to a store. williamr@2: williamr@2: CMsvStore provides functions for general manipulation of the store, and for williamr@2: accessing the standard body text stream. RMsvReadStream and RMsvWriteStream williamr@2: must be used to access other streams. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C ~CMsvStore(); williamr@2: // williamr@2: IMPORT_C void StoreBodyTextL(const CRichText& aRichTextBody); williamr@2: williamr@2: IMPORT_C void RestoreBodyTextL(CRichText& aRichTextBody); williamr@2: IMPORT_C void RestoreBodyTextL(CRichText& aRichTextBody, TUint aCharsetOverride); williamr@2: williamr@2: IMPORT_C void DeleteBodyTextL(); williamr@2: IMPORT_C TBool HasBodyTextL() const; williamr@2: // williamr@2: IMPORT_C void DeleteL(); // deletes the message store williamr@2: IMPORT_C TInt SizeL(); // the size of the store williamr@2: // williamr@2: // The following give the Dictionary store interface williamr@2: IMPORT_C TBool IsNullL() const; williamr@2: IMPORT_C TBool IsPresentL(TUid aUid) const; williamr@2: IMPORT_C void Remove(TUid aUid); williamr@2: IMPORT_C void RemoveL(TUid aUid); williamr@2: IMPORT_C void Revert(); williamr@2: IMPORT_C void RevertL(); williamr@2: IMPORT_C TInt Commit(); williamr@2: IMPORT_C void CommitL(); williamr@2: williamr@2: // Attachment Management williamr@2: IMPORT_C MMsvAttachmentManager& AttachmentManagerL(); williamr@2: IMPORT_C MMsvAttachmentManagerSync& AttachmentManagerExtensionsL(); williamr@2: williamr@2: // APIs to get the CMsvPlainBodyText interface. williamr@2: IMPORT_C CMsvPlainBodyText* InitialisePlainBodyTextForWriteL(TBool aIs8Bit, TUint aCharsetId, TUint aDefaultCharsetId); williamr@2: IMPORT_C CMsvPlainBodyText* InitialisePlainBodyTextForReadL(TInt aChunkLength); williamr@2: williamr@2: /** williamr@2: @internalTechnology williamr@2: @released williamr@2: */ williamr@2: IMPORT_C void CreateShareProtectedAttachmentL(const TDesC& aFileName, RFile& aAttachmentFile, CMsvAttachment* aAttachmentInfo); williamr@2: void Restore8BitBodyTextL(RFileReadStream& aInputStream); williamr@2: williamr@2: protected: williamr@2: williamr@2: IMPORT_C CMsvStore(MMsvStoreObserver& aObserver, RFs& aFs, TMsvId aId, MMsvStoreManager& aStoreManager); williamr@2: IMPORT_C static CMsvStore* OpenForReadL(MMsvStoreObserver& aObserver, RFs& aFs, MMsvStoreManager& aStoreManager, TMsvId aId); williamr@2: IMPORT_C static CMsvStore* OpenForWriteL(MMsvStoreObserver& aObserver, RFs& aFs, MMsvStoreManager& aStoreManager, TMsvId aId); williamr@2: williamr@2: private: williamr@2: williamr@2: williamr@2: void ConstructL(TBool aReadOnly); williamr@2: williamr@2: //Methods to handle plain bodytext. williamr@2: void RestorePlainBodyTextL(CRichText& aRichText, TUint aCharsetOverride); williamr@2: void GetRichTextFrom8BitL(RFile& aBodyTextFile, CRichText& aRichText, TUint aCharSet, TUint aDefaultCharSet); williamr@2: void GetRichTextFrom16BitL(RFile& aBodyTextFile, CRichText& aRichText); williamr@2: void Convert8BitToRichTextL(RFile& aBodyTextFile, CRichText& aRichText, TUint aCharSet, TUint aDefaultCharSet); williamr@2: williamr@2: void Lock(); williamr@2: inline const CMsvCachedStore& Store() const; williamr@2: inline CMsvCachedStore& Store(); williamr@2: private: williamr@2: enum {EMsvStoreUnlocked, EMsvStoreLocked} iLockStatus; williamr@2: williamr@2: RFs& iFs; williamr@2: MMsvStoreObserver& iObserver; williamr@2: williamr@2: williamr@2: const TMsvId iId; williamr@2: CMsvCachedStore* iStore; williamr@2: TBool iConstructed; williamr@2: CMsvBodyText* iBodyText; williamr@2: williamr@2: MMsvStoreManager& iStoreManager; williamr@2: CMsvAttachmentManager* iAttachmentManager; williamr@2: williamr@2: friend class CMsvEntry; williamr@2: friend class CMsvServerEntry; williamr@2: friend class RMsvReadStream; williamr@2: friend class RMsvWriteStream; williamr@2: }; williamr@2: williamr@2: williamr@2: class RMsvReadStream : public RReadStream williamr@2: /** Accesses the streams in a message store with read access. williamr@2: williamr@2: Before it is used, williamr@2: a CMsvStore must have been opened on the message store with read or read/write williamr@2: access. williamr@2: williamr@2: This class is intended for use by MTM implementations to store MTM-specific williamr@2: information. Message client applications access the store through the higher-level williamr@2: functions provided by Client-side and User Interface MTMs. williamr@2: williamr@2: Most of its functionality is provided by the base class RReadStream. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C void OpenL(const CMsvStore& aMsvStore, TUid aUid); williamr@2: IMPORT_C void OpenLC(const CMsvStore& aMsvStore,TUid aUid); williamr@2: void OpenLC(CMsvCachedStore& aStore,TUid aUid); williamr@2: }; williamr@2: williamr@2: williamr@2: class RMsvWriteStream : public RWriteStream williamr@2: /** Accesses the streams in a message store with write access, or creates new streams. williamr@2: Before it is used, a CMsvStore must have been opened on the message store williamr@2: with write access. williamr@2: williamr@2: This class is intended for use by MTM implementations to store MTM-specific williamr@2: information. Message client applications access the store through the higher-level williamr@2: functions provided by Client-side and User Interface MTMs. williamr@2: williamr@2: Most of its functionality is provided by the base class RWriteStream. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C void AssignLC(CMsvStore &aMsvStore, TUid aUid); williamr@2: IMPORT_C void AssignL(CMsvStore &aMsvStore, TUid aUid); williamr@2: void AssignLC(CMsvCachedStore &aStore, TUid aUid); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: #endif