|
1 /* |
|
2 * Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Entry wrapper for client side components |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #ifndef MMSCLIENTENTRY_H |
|
22 #define MMSCLIENTENTRY_H |
|
23 |
|
24 // INCLUDES |
|
25 #include "mmsentrywrapper.h" |
|
26 |
|
27 // CONSTANTS |
|
28 |
|
29 // MACROS |
|
30 |
|
31 // DATA TYPES |
|
32 |
|
33 // FUNCTION PROTOTYPES |
|
34 |
|
35 // FORWARD DECLARATIONS |
|
36 |
|
37 // CLASS DECLARATION |
|
38 |
|
39 /** |
|
40 * Entry wrapper implementing MMmsEntry for client side. |
|
41 * Hides difference between CMscEntry and CMsvServerEntry |
|
42 * |
|
43 * @lib mmsutil.lib |
|
44 * @since 3.0 |
|
45 */ |
|
46 class CMmsClientEntry :public CBase, public MMmsEntryWrapper |
|
47 { |
|
48 public: // Constructors and destructor |
|
49 |
|
50 /** |
|
51 * Two-phased constructor. |
|
52 * @param aFs opened file system handle. |
|
53 * @param aEntry reference to a message entry (CMsvEntry), |
|
54 * originally refers to the entry to be handled. |
|
55 * @param aServiceId TMsvId of MMS service entry. |
|
56 * @param aUseDrm is DRM handling needed. Default on client side is "No" |
|
57 */ |
|
58 IMPORT_C static CMmsClientEntry* NewL( RFs& aFs, |
|
59 CMsvEntry& aEntry, |
|
60 TMsvId aServiceId); |
|
61 |
|
62 /** |
|
63 * Destructor. |
|
64 */ |
|
65 virtual ~CMmsClientEntry(); |
|
66 |
|
67 public: // New functions |
|
68 |
|
69 public: // Functions from base classes |
|
70 |
|
71 // From MMmsEntryWrapper: |
|
72 |
|
73 /** |
|
74 * Provide an edit store for editing messages |
|
75 * Ownership of the store is transferred. Caller must delete the store |
|
76 * @return CMsvStore* if successful, leaves if unsuccessful |
|
77 */ |
|
78 CMsvStore* EditStoreL(); |
|
79 |
|
80 /** |
|
81 * provide a read store for editing messages |
|
82 * Ownership of the store is transferred. Caller must delete the store |
|
83 * @return CMsvStore* if successful, leaves if unsuccessful |
|
84 */ |
|
85 CMsvStore* ReadStoreL(); |
|
86 |
|
87 /** |
|
88 * reads index entry contents from current entry |
|
89 * @param TMsvEntry reference to entry to be filled with data |
|
90 * @return error code, KErrNone if successful |
|
91 */ |
|
92 TInt GetIndexEntry( TMsvEntry& aTMsvEntry ); |
|
93 |
|
94 /** |
|
95 * stores index entry contents to current entry |
|
96 * @param TMsvEntry reference to entry to be written to disk |
|
97 * @return error code KErrNone, if successful |
|
98 */ |
|
99 TInt ChangeIndexEntry( TMsvEntry& aTMsvEntry ); |
|
100 |
|
101 /** |
|
102 * Sets context to specified message entry |
|
103 * @param aId ID of the new message entry. |
|
104 * @return error code, KErrNone if successful |
|
105 */ |
|
106 TInt SetCurrentEntry( TMsvId aEntryId ); |
|
107 |
|
108 /** |
|
109 * Returns total size of all attachments including mime headers |
|
110 * and binary attachment data. Linked attachments are included |
|
111 * This function is needed to allocate the encoding buffer. |
|
112 * @param aStore Read store for the message entry |
|
113 * @return combined size of all attachments, including linked attachments |
|
114 */ |
|
115 TInt AttachmentsSizeL( CMsvStore& aStore ); |
|
116 |
|
117 /** |
|
118 * Check if disk space is below critical level when storing data. |
|
119 * @param aDataSize amount of data to be added. If aDataSize == 0, |
|
120 * returns info if disk space is already below critical level. |
|
121 * @return error code KErrDiskFull if data does not fit, |
|
122 * KErrNone if data fits. |
|
123 * May return some other error code if appropriate. |
|
124 * KErrNone always means it is all right to save the data. |
|
125 */ |
|
126 TInt DiskSpaceBelowCriticalLevelL( TInt aDataSize ); |
|
127 |
|
128 /** |
|
129 * Store CMmsHeaders to message store for main message entry. |
|
130 * @param aMmsHeaders headers to store. |
|
131 * @param aStore store to be used. If not given, function gets and commits store |
|
132 * @return error code if not successful, KErrNone if successful. |
|
133 */ |
|
134 TInt StoreMmsHeadersL( CMmsHeaders& aMmsHeaders, CMsvStore* aStore ); |
|
135 |
|
136 /** |
|
137 * Restore CMmsHeaders from message store for main message entry. |
|
138 * @param aMmsHeaders headers to restore. |
|
139 * Leaves if cannot restore headers. |
|
140 */ |
|
141 void RestoreMmsHeadersL( CMmsHeaders& aMmsHeaders, CMsvStore* aStore ); |
|
142 |
|
143 /** |
|
144 * Create attachment, save data to file and save MIME headers. |
|
145 * Must check first if enough disk space. |
|
146 * DRM handling is done here if needed. |
|
147 * Return code tells if whole attachment was removed. |
|
148 * This is the one-shot function that does everything: |
|
149 * Creates attachent, opens file, writes data, flushes it, |
|
150 * closes file, saves MIME headers. |
|
151 * Caller must commit and close store |
|
152 * @param aStore edit store for current entry |
|
153 * @param aFileName Suggested filename. |
|
154 * @param aAttachmentData Pointer to the attachment binary data. |
|
155 * @param aMimeHeaders Mime header structure to be saved. |
|
156 * @param aAttachment id of the newly created attachment if successful |
|
157 * @param aAttachmentSize size of the attachment binary data + mime headers |
|
158 * @param aDRMFlags structure where DRM flags are collected. |
|
159 * These flags will ultimately be collected together for all |
|
160 * attachments and stored into iMtmData1 of the parent entry. |
|
161 * Therefore the function must only OR new flags into the structure |
|
162 * and must not change any other bits (the same value may be reused |
|
163 * for all attachments collecting the flags together). |
|
164 * @return Error code must indicate if attachment was removed (DRM) so that |
|
165 * the first attachment id may be adjusted. (Decode must keep track |
|
166 * of the first attachment in case root is not specified for |
|
167 * multipart/related structure. |
|
168 * KErrNone = All well. |
|
169 * KDRMRemoved = all well otherwise, but DRM attachment was removed, |
|
170 * and first attachment id must be adjusted accordingly. |
|
171 * Some other error code means a more serious error. |
|
172 */ |
|
173 TInt CreateFileAttachmentL( |
|
174 CMsvStore& aStore, |
|
175 const TDesC& aFileName, |
|
176 const TPtrC8& aAttachmentData, |
|
177 CMsvMimeHeaders& aMimeHeaders, |
|
178 TMsvAttachmentId& aAttachment, |
|
179 TInt& aAttachmentSize, |
|
180 TInt32& aDRMFlags); |
|
181 |
|
182 /** |
|
183 * Deletes a message store entry. |
|
184 * @param aEntryIndex is the index of the entry, which will be deleted. |
|
185 * If the Entry has children, all children are destroyed too. |
|
186 * @return error code if not successful, KErrNone if successful. |
|
187 */ |
|
188 TInt DeleteEntry( TMsvId aEntryIndex ); |
|
189 |
|
190 /** |
|
191 * From MMmsEntryWrapper: Check if aFileName would be a valid filename. |
|
192 * Cannot use path because absolute path is not known. Only filename is checked |
|
193 * @param aFileName suggestion of a filename. |
|
194 * @return ETrue if filename is valid, EFalse if not. |
|
195 */ |
|
196 TBool IsValidFilename( const TPtrC& aFileName ); |
|
197 |
|
198 /** |
|
199 * Read the decoding flag from the service entry. |
|
200 * (Info stored in MMS service entry) |
|
201 * @return ETrue = Log add details while decoding |
|
202 * EFalse = Don't log details. |
|
203 */ |
|
204 TBool GetDecodingFlag(); |
|
205 |
|
206 /** |
|
207 * Read the dump flag from the service entry. |
|
208 * The dump flag tells if all incoming messages are dumped to a file. |
|
209 * @return ETrue = dump binary message to file while decoding |
|
210 * EFalse = No binary dump wanted |
|
211 */ |
|
212 TBool GetDumpFlag(); |
|
213 |
|
214 /** |
|
215 * From MMmsEntryWrapper |
|
216 * Create Empty attachment file and save Mime headers. |
|
217 * DRM check is done here. |
|
218 * This function is the initialization function for chunked |
|
219 * attachment handling. |
|
220 * This function creates attachent, opens file, and saves MIME headers. |
|
221 * |
|
222 * @since v3.1 |
|
223 * @param aStore edit store for current message entry |
|
224 * Caller must keep store open until FinalizeAttachmentL has been called. |
|
225 * @param aFileName Suggested filename. |
|
226 * @param aMimeHeaders Mime header structure to be saved. |
|
227 * @param aAttachment id of the newly created attachment if successful |
|
228 * @param aAttachmentSize size of the attachment binary data + mime headers |
|
229 */ |
|
230 void CreateEmptyFileAttachmentL( |
|
231 CMsvStore& aStore, |
|
232 const TDesC& aFileName, |
|
233 CMsvMimeHeaders& aMimeHeaders, |
|
234 TMsvAttachmentId& aAttachment); |
|
235 |
|
236 /** |
|
237 * From MMmsEntryWrapper |
|
238 * Write attachment data into file. |
|
239 * Call DRM handler if needed. |
|
240 * |
|
241 * @since v3.1 |
|
242 * |
|
243 * @param aAttachmentData Pointer to the attachment binary data. |
|
244 * @param aDRMFlags structure where DRM flags are collected. |
|
245 * These flags will ultimately be collected together for all |
|
246 * attachments and stored into iMtmData1 of the parent entry. |
|
247 * Therefore the function must only OR new flags into the structure |
|
248 * and must not change any other bits (the same value may be reused |
|
249 * for all attachments collecting the flags together). |
|
250 * @return Error code must indicate if attachment was removed (DRM) so that |
|
251 * KErrNone = All well. |
|
252 * KDRMRemoved = all well otherwise, but DRM attachment was removed, |
|
253 * and first attachment id must be adjusted accordingly. |
|
254 * Some other error code means an error. |
|
255 * Leaves if memory runs out |
|
256 */ |
|
257 TInt ProcessAttachmentDataL( |
|
258 const TPtrC8& aAttachmentData, |
|
259 TInt32& aDRMFlags ); |
|
260 |
|
261 /** |
|
262 * From MMmsEntryWrapper |
|
263 * Finalize the attachment. |
|
264 * Flush buffers and close file, calculate total size. |
|
265 * Caller must commit the store after this |
|
266 * |
|
267 * @since v3.1 |
|
268 * |
|
269 * @param aStore edit store for current entry |
|
270 * @param aAttachmentSize size of the attachment binary data + mime headers |
|
271 * @param aDRMFlags structure where DRM flags are collected. |
|
272 * These flags will ultimately be collected together for all |
|
273 * attachments and stored into iMtmData1 of the parent entry. |
|
274 * Therefore the function must only OR new flags into the structure |
|
275 * and must not change any other bits (the same value may be reused |
|
276 * for all attachments collecting the flags together). |
|
277 * @return Error code must indicate if attachment was removed (DRM) so that |
|
278 * KErrNone = All well. |
|
279 * KDRMRemoved = all well otherwise, but DRM attachment was removed, |
|
280 * and first attachment id must be adjusted accordingly. |
|
281 * Some other error code means an error. |
|
282 * Leaves if memory runs out |
|
283 */ |
|
284 TInt FinalizeAttachmentL( |
|
285 CMsvStore& aStore, |
|
286 TInt& aAttachmentSize, |
|
287 TInt32& aDRMFlags ); |
|
288 |
|
289 |
|
290 protected: // New functions |
|
291 |
|
292 protected: // Functions from base classes |
|
293 |
|
294 private: |
|
295 |
|
296 /** |
|
297 * C++ constructor. |
|
298 * @param aFs opened file system handle. |
|
299 * @param aEntry reference to a CmsvEntry entry, |
|
300 * originally refers to the entry to be handled. |
|
301 * @param aUseDrm is DRM handling needed |
|
302 */ |
|
303 CMmsClientEntry( RFs& aFs, CMsvEntry& aEntry ); |
|
304 |
|
305 /** |
|
306 * @param aServiceId TMsvId of MMS service entry. |
|
307 */ |
|
308 void ConstructL( TMsvId aServiceId ); |
|
309 |
|
310 |
|
311 public: // Data |
|
312 |
|
313 protected: // Data |
|
314 |
|
315 private: // Data |
|
316 RFs& iFs; // file system handle |
|
317 CMsvEntry& iCMsvEntry; // message entry |
|
318 TMsvId iMessageEntry; // Id of the current message entry |
|
319 TMsvId iServiceId; // MMS service entry id |
|
320 TInt iMessageDrive; // messages are on C: drive by default, |
|
321 // may be moved to other drive |
|
322 TBool iDump; // dump flag |
|
323 TBool iLogAllDecoded; // detailed logging flag |
|
324 RFile iAttaFile; // file handle for writing the attachment |
|
325 TBool iFileOpen; // keep track if we have an open file and stream |
|
326 TMsvAttachmentId iAttaId; // current attachment |
|
327 |
|
328 public: // Friend classes |
|
329 protected: // Friend classes |
|
330 private: // Friend classes |
|
331 |
|
332 }; |
|
333 |
|
334 #endif // MMSCLIENTENTRY_H |
|
335 |
|
336 // End of File |