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