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