1 // Copyright (c) 1998-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
21 #if !defined(__MSVSTORE_H__)
22 #define __MSVSTORE_H__
28 class CMsvCachedStore;
32 //**********************************
34 //**********************************
39 class MMsvStoreObserver
40 /** Observer interface to get events relating to a message store.
42 This is used in the derivation of CMsvServerEntry and CMsvEntry.
50 Defines message store event types.
55 enum TMsvStoreEvent { /** A read-only message store was closed. */
56 EMsvReadStoreClosed, // read only CMsvStore closed
57 /** An editable message store was closed. */
58 EMsvEditStoreClosed // edit only CMsvStore closed
61 /** Receives a message store event.
63 @param aEvent Event type
64 @param aId ID of the message to which the event relates
66 virtual void HandleStoreEvent(TMsvStoreEvent aEvent, TMsvId aId)=0;
70 //**********************************
72 //**********************************
74 // The entry structure that the client uses
78 Uid which are not needed to be known outside CMsvStore
82 const TUid KMsvEntryRichTextBody={0x10000F70};
84 class MMsvAttachmentManager;
85 class MMsvAttachmentManagerSync;
86 class CMsvAttachmentManager;
87 class MMsvStoreManager;
88 class CMsvPlainBodyText;
91 class CMsvStore : public CBase
92 /** Provides an interface over the message store that is associated with a message
93 entry. It is similar to the dictionary store in supporting the concept of
94 streams referenced by UID.
96 This class is intended for use by MTM implementations. Message client applications
97 access the store through the higher-level functions provided by Client-side
98 and User Interface MTMs.
100 A CMsvStore object is created by a CMsvEntry object and passed to a client
101 process. The client process then becomes responsible for deleting the CMsvStore
102 object. The store can be opened in two modes, read or edit, and only one CMsvStore
103 object can have edit access to a store.
105 CMsvStore provides functions for general manipulation of the store, and for
106 accessing the standard body text stream. RMsvReadStream and RMsvWriteStream
107 must be used to access other streams.
113 IMPORT_C ~CMsvStore();
115 IMPORT_C void StoreBodyTextL(const CRichText& aRichTextBody);
117 IMPORT_C void RestoreBodyTextL(CRichText& aRichTextBody);
118 IMPORT_C void RestoreBodyTextL(CRichText& aRichTextBody, TUint aCharsetOverride);
120 IMPORT_C void DeleteBodyTextL();
121 IMPORT_C TBool HasBodyTextL() const;
123 IMPORT_C void DeleteL(); // deletes the message store
124 IMPORT_C TInt SizeL(); // the size of the store
126 // The following give the Dictionary store interface
127 IMPORT_C TBool IsNullL() const;
128 IMPORT_C TBool IsPresentL(TUid aUid) const;
129 IMPORT_C void Remove(TUid aUid);
130 IMPORT_C void RemoveL(TUid aUid);
131 IMPORT_C void Revert();
132 IMPORT_C void RevertL();
133 IMPORT_C TInt Commit();
134 IMPORT_C void CommitL();
136 #if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)
137 IMPORT_C TBool IsDbStore();
138 void CommitHeaderL();
141 // Attachment Management
142 IMPORT_C MMsvAttachmentManager& AttachmentManagerL();
143 IMPORT_C MMsvAttachmentManagerSync& AttachmentManagerExtensionsL();
145 // APIs to get the CMsvPlainBodyText interface.
146 IMPORT_C CMsvPlainBodyText* InitialisePlainBodyTextForWriteL(TBool aIs8Bit, TUint aCharsetId, TUint aDefaultCharsetId);
147 IMPORT_C CMsvPlainBodyText* InitialisePlainBodyTextForReadL(TInt aChunkLength);
149 IMPORT_C void CreateShareProtectedAttachmentL(const TDesC& aFileName, RFile& aAttachmentFile, CMsvAttachment* aAttachmentInfo);
150 void Restore8BitBodyTextL(RFileReadStream& aInputStream);
152 #if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)
153 IMPORT_C static CMsvStore* OpenForReadL(MMsvStoreObserver& aObserver, RFs& aFs, MMsvStoreManager& aStoreManager, TMsvId aId, TUid aMtmId);
154 IMPORT_C static CMsvStore* OpenForWriteL(MMsvStoreObserver& aObserver, RFs& aFs, MMsvStoreManager& aStoreManager, TMsvId aId, TUid aMtmId);
156 IMPORT_C CMsvStore(MMsvStoreObserver& aObserver, RFs& aFs, TMsvId aId, MMsvStoreManager& aStoreManager);
157 IMPORT_C static CMsvStore* OpenForReadL(MMsvStoreObserver& aObserver, RFs& aFs, MMsvStoreManager& aStoreManager, TMsvId aId);
158 IMPORT_C static CMsvStore* OpenForWriteL(MMsvStoreObserver& aObserver, RFs& aFs, MMsvStoreManager& aStoreManager, TMsvId aId);
162 void ConstructL(TBool aReadOnly);
163 #if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)
164 void ConstructDbL(TUid aMtmId,TBool aReadOnly);
166 void LoadHeaderEntryL(const TUid aMtmId, TBool aUid);
169 //Methods to handle plain bodytext.
170 void RestorePlainBodyTextL(CRichText& aRichText, TUint aCharsetOverride);
171 void GetRichTextFrom8BitL(RFile& aBodyTextFile, CRichText& aRichText, TUint aCharSet, TUint aDefaultCharSet);
172 void GetRichTextFrom16BitL(RFile& aBodyTextFile, CRichText& aRichText);
173 void Convert8BitToRichTextL(RFile& aBodyTextFile, CRichText& aRichText, TUint aCharSet, TUint aDefaultCharSet);
176 inline const CMsvCachedStore& Store() const;
177 inline CMsvCachedStore& Store();
179 enum {EMsvStoreUnlocked, EMsvStoreLocked} iLockStatus;
182 MMsvStoreObserver& iObserver;
186 CMsvCachedStore* iStore;
188 CMsvBodyText* iBodyText;
190 MMsvStoreManager& iStoreManager;
191 CMsvAttachmentManager* iAttachmentManager;
193 friend class CMsvEntry;
194 friend class CMsvServerEntry;
195 friend class RMsvReadStream;
196 friend class RMsvWriteStream;
197 #if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)
198 friend class TMsvWriteStore;
199 friend class TMsvReadStore;
204 class RMsvReadStream : public RReadStream
205 /** Accesses the streams in a message store with read access.
208 a CMsvStore must have been opened on the message store with read or read/write
211 This class is intended for use by MTM implementations to store MTM-specific
212 information. Message client applications access the store through the higher-level
213 functions provided by Client-side and User Interface MTMs.
215 Most of its functionality is provided by the base class RReadStream.
221 IMPORT_C void OpenL(const CMsvStore& aMsvStore, TUid aUid);
222 IMPORT_C void OpenLC(const CMsvStore& aMsvStore,TUid aUid);
223 void OpenLC(CMsvCachedStore& aStore,TUid aUid);
227 class RMsvWriteStream : public RWriteStream
228 /** Accesses the streams in a message store with write access, or creates new streams.
229 Before it is used, a CMsvStore must have been opened on the message store
232 This class is intended for use by MTM implementations to store MTM-specific
233 information. Message client applications access the store through the higher-level
234 functions provided by Client-side and User Interface MTMs.
236 Most of its functionality is provided by the base class RWriteStream.
242 IMPORT_C void AssignLC(CMsvStore &aMsvStore, TUid aUid);
243 IMPORT_C void AssignL(CMsvStore &aMsvStore, TUid aUid);
244 void AssignLC(CMsvCachedStore &aStore, TUid aUid);
249 #if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)
251 /** Accesses the message store with write access, or creates new header entry.
252 Before it is used, a CMsvStore must have been opened on the message store
255 This class is intended for use by MTM implementations to store MTM-specific
256 information. Message client applications access the store through the higher-level
257 functions provided by Client-side and User Interface MTMs.
265 IMPORT_C TMsvWriteStore(CMsvStore& aMsvStore);
266 IMPORT_C void AssignL(CHeaderFields* aHeaderFields);
267 IMPORT_C void CommitL();
269 CMsvStore& iMsvStore;
272 /** Accesses the a message store with read access.
275 a CMsvStore must have been opened on the message store with read or read/write
278 This class is intended for use by MTM implementations to store MTM-specific
279 information. Message client applications access the store through the higher-level
280 functions provided by Client-side and User Interface MTMs.
289 IMPORT_C TMsvReadStore(CMsvStore& aMsvStore, TUid aUid);
290 IMPORT_C void LoadL(CHeaderFields*& aHeaderFields);
291 IMPORT_C void ReadL(CHeaderFields*& aHeaderFields);
293 CMsvStore& iMsvStore;