|
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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #if !defined(__MSVSTORE_H__) |
|
17 #define __MSVSTORE_H__ |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <s32file.h> |
|
21 #include <msvstd.h> |
|
22 |
|
23 class CMsvCachedStore; |
|
24 class CMsvBodyText; |
|
25 class CMsvAttachment; |
|
26 |
|
27 //********************************** |
|
28 // MMsvStoreObserver |
|
29 //********************************** |
|
30 // |
|
31 // |
|
32 // |
|
33 |
|
34 class MMsvStoreObserver |
|
35 /** Observer interface to get events relating to a message store. |
|
36 |
|
37 This is used in the derivation of CMsvServerEntry and CMsvEntry. |
|
38 |
|
39 @publishedAll |
|
40 @released |
|
41 */ |
|
42 { |
|
43 public: |
|
44 /** |
|
45 Defines message store event types. |
|
46 |
|
47 @publishedAll |
|
48 @released |
|
49 */ |
|
50 enum TMsvStoreEvent { /** A read-only message store was closed. */ |
|
51 EMsvReadStoreClosed, // read only CMsvStore closed |
|
52 /** An editable message store was closed. */ |
|
53 EMsvEditStoreClosed // edit only CMsvStore closed |
|
54 }; |
|
55 public: |
|
56 /** Receives a message store event. |
|
57 |
|
58 @param aEvent Event type |
|
59 @param aId ID of the message to which the event relates |
|
60 */ |
|
61 virtual void HandleStoreEvent(TMsvStoreEvent aEvent, TMsvId aId)=0; |
|
62 }; |
|
63 |
|
64 |
|
65 //********************************** |
|
66 // CMsvStore |
|
67 //********************************** |
|
68 // |
|
69 // The entry structure that the client uses |
|
70 // |
|
71 |
|
72 /* |
|
73 Uid which are not needed to be known outside CMsvStore |
|
74 @internalComponent |
|
75 @deprecated |
|
76 */ |
|
77 const TUid KMsvEntryRichTextBody={0x10000F70}; |
|
78 |
|
79 |
|
80 /** |
|
81 UId for the 16-bit chunk storage mechanism. |
|
82 @internalTechnology |
|
83 @prototype |
|
84 */ |
|
85 const TUid KMsvPlainBodyText16={0x10000F90}; |
|
86 |
|
87 /** |
|
88 UId for the 8-bit chunk storage mechanism. |
|
89 @internalTechnology |
|
90 @prototype |
|
91 */ |
|
92 const TUid KMsvPlainBodyText8={0x10000F80}; |
|
93 |
|
94 class MMsvAttachmentManager; |
|
95 class MMsvAttachmentManagerSync; |
|
96 class CMsvAttachmentManager; |
|
97 class MMsvStoreManager; |
|
98 class CMsvPlainBodyText; |
|
99 class CMsvStore : public CBase |
|
100 /** Provides an interface over the message store that is associated with a message |
|
101 entry. It is similar to the dictionary store in supporting the concept of |
|
102 streams referenced by UID. |
|
103 |
|
104 This class is intended for use by MTM implementations. Message client applications |
|
105 access the store through the higher-level functions provided by Client-side |
|
106 and User Interface MTMs. |
|
107 |
|
108 A CMsvStore object is created by a CMsvEntry object and passed to a client |
|
109 process. The client process then becomes responsible for deleting the CMsvStore |
|
110 object. The store can be opened in two modes, read or edit, and only one CMsvStore |
|
111 object can have edit access to a store. |
|
112 |
|
113 CMsvStore provides functions for general manipulation of the store, and for |
|
114 accessing the standard body text stream. RMsvReadStream and RMsvWriteStream |
|
115 must be used to access other streams. |
|
116 @publishedAll |
|
117 @released |
|
118 */ |
|
119 { |
|
120 public: |
|
121 IMPORT_C ~CMsvStore(); |
|
122 // |
|
123 IMPORT_C void StoreBodyTextL(const CRichText& aRichTextBody); |
|
124 |
|
125 IMPORT_C void RestoreBodyTextL(CRichText& aRichTextBody); |
|
126 IMPORT_C void RestoreBodyTextL(CRichText& aRichTextBody, TUint aCharsetOverride); |
|
127 |
|
128 IMPORT_C void DeleteBodyTextL(); |
|
129 IMPORT_C TBool HasBodyTextL() const; |
|
130 // |
|
131 IMPORT_C void DeleteL(); // deletes the message store |
|
132 IMPORT_C TInt SizeL(); // the size of the store |
|
133 // |
|
134 // The following give the Dictionary store interface |
|
135 IMPORT_C TBool IsNullL() const; |
|
136 IMPORT_C TBool IsPresentL(TUid aUid) const; |
|
137 IMPORT_C void Remove(TUid aUid); |
|
138 IMPORT_C void RemoveL(TUid aUid); |
|
139 IMPORT_C void Revert(); |
|
140 IMPORT_C void RevertL(); |
|
141 IMPORT_C TInt Commit(); |
|
142 IMPORT_C void CommitL(); |
|
143 |
|
144 // Attachment Management |
|
145 IMPORT_C MMsvAttachmentManager& AttachmentManagerL(); |
|
146 IMPORT_C MMsvAttachmentManagerSync& AttachmentManagerExtensionsL(); |
|
147 |
|
148 // APIs to get the CMsvPlainBodyText interface. |
|
149 IMPORT_C CMsvPlainBodyText* InitialisePlainBodyTextForWriteL(TBool aIs8Bit, TUint aCharsetId, TUint aDefaultCharsetId); |
|
150 IMPORT_C CMsvPlainBodyText* InitialisePlainBodyTextForReadL(TInt aChunkLength); |
|
151 |
|
152 /** |
|
153 @internalTechnology |
|
154 @released |
|
155 */ |
|
156 IMPORT_C void CreateShareProtectedAttachmentL(const TDesC& aFileName, RFile& aAttachmentFile, CMsvAttachment* aAttachmentInfo); |
|
157 void Restore8BitBodyTextL(RFileReadStream& aInputStream); |
|
158 |
|
159 protected: |
|
160 |
|
161 IMPORT_C CMsvStore(MMsvStoreObserver& aObserver, RFs& aFs, TMsvId aId, MMsvStoreManager& aStoreManager); |
|
162 IMPORT_C static CMsvStore* OpenForReadL(MMsvStoreObserver& aObserver, RFs& aFs, MMsvStoreManager& aStoreManager, TMsvId aId); |
|
163 IMPORT_C static CMsvStore* OpenForWriteL(MMsvStoreObserver& aObserver, RFs& aFs, MMsvStoreManager& aStoreManager, TMsvId aId); |
|
164 |
|
165 private: |
|
166 |
|
167 |
|
168 void ConstructL(TBool aReadOnly); |
|
169 |
|
170 //Methods to handle plain bodytext. |
|
171 void RestorePlainBodyTextL(CRichText& aRichText, TUint aCharsetOverride); |
|
172 void GetRichTextFrom8BitL(RFile& aBodyTextFile, CRichText& aRichText, TUint aCharSet, TUint aDefaultCharSet); |
|
173 void GetRichTextFrom16BitL(RFile& aBodyTextFile, CRichText& aRichText); |
|
174 void Convert8BitToRichTextL(RFile& aBodyTextFile, CRichText& aRichText, TUint aCharSet, TUint aDefaultCharSet); |
|
175 |
|
176 void Lock(); |
|
177 inline const CMsvCachedStore& Store() const; |
|
178 inline CMsvCachedStore& Store(); |
|
179 private: |
|
180 enum {EMsvStoreUnlocked, EMsvStoreLocked} iLockStatus; |
|
181 |
|
182 RFs& iFs; |
|
183 MMsvStoreObserver& iObserver; |
|
184 |
|
185 |
|
186 const TMsvId iId; |
|
187 CMsvCachedStore* iStore; |
|
188 TBool iConstructed; |
|
189 CMsvBodyText* iBodyText; |
|
190 |
|
191 MMsvStoreManager& iStoreManager; |
|
192 CMsvAttachmentManager* iAttachmentManager; |
|
193 |
|
194 friend class CMsvEntry; |
|
195 friend class CMsvServerEntry; |
|
196 friend class RMsvReadStream; |
|
197 friend class RMsvWriteStream; |
|
198 }; |
|
199 |
|
200 |
|
201 class RMsvReadStream : public RReadStream |
|
202 /** Accesses the streams in a message store with read access. |
|
203 |
|
204 Before it is used, |
|
205 a CMsvStore must have been opened on the message store with read or read/write |
|
206 access. |
|
207 |
|
208 This class is intended for use by MTM implementations to store MTM-specific |
|
209 information. Message client applications access the store through the higher-level |
|
210 functions provided by Client-side and User Interface MTMs. |
|
211 |
|
212 Most of its functionality is provided by the base class RReadStream. |
|
213 @publishedAll |
|
214 @released |
|
215 */ |
|
216 { |
|
217 public: |
|
218 IMPORT_C void OpenL(const CMsvStore& aMsvStore, TUid aUid); |
|
219 IMPORT_C void OpenLC(const CMsvStore& aMsvStore,TUid aUid); |
|
220 void OpenLC(CMsvCachedStore& aStore,TUid aUid); |
|
221 }; |
|
222 |
|
223 |
|
224 class RMsvWriteStream : public RWriteStream |
|
225 /** Accesses the streams in a message store with write access, or creates new streams. |
|
226 Before it is used, a CMsvStore must have been opened on the message store |
|
227 with write access. |
|
228 |
|
229 This class is intended for use by MTM implementations to store MTM-specific |
|
230 information. Message client applications access the store through the higher-level |
|
231 functions provided by Client-side and User Interface MTMs. |
|
232 |
|
233 Most of its functionality is provided by the base class RWriteStream. |
|
234 @publishedAll |
|
235 @released |
|
236 */ |
|
237 { |
|
238 public: |
|
239 IMPORT_C void AssignLC(CMsvStore &aMsvStore, TUid aUid); |
|
240 IMPORT_C void AssignL(CMsvStore &aMsvStore, TUid aUid); |
|
241 void AssignLC(CMsvCachedStore &aStore, TUid aUid); |
|
242 }; |
|
243 |
|
244 |
|
245 |
|
246 #endif |