|
1 /* |
|
2 * Copyright (c) 2002-2005 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 * CMsvOperation class for MMS message creation. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #ifndef CMMSMESSAGEOPERATION_H |
|
22 #define CMMSMESSAGEOPERATION_H |
|
23 |
|
24 // INCLUDES |
|
25 #include <mtclbase.h> // TMsvPartList |
|
26 #include <msvapi.h> // CMsvOperation etc |
|
27 |
|
28 // CONSTANTS |
|
29 |
|
30 // MACROS |
|
31 |
|
32 // DATA TYPES |
|
33 |
|
34 // FUNCTION PROTOTYPES |
|
35 |
|
36 // FORWARD DECLARATIONS |
|
37 class TRequestStatus; |
|
38 class CMmsHeaders; |
|
39 class CMmsSettings; |
|
40 |
|
41 // CLASS DECLARATION |
|
42 |
|
43 /** |
|
44 * CMsvOperation class for MMS message creation. |
|
45 * |
|
46 * Currently this supports creation of Reply, Forward and New message entry |
|
47 * to the desired destination folder. This class is used by MMS Client MTM, |
|
48 * but can be used by other client application modules too. |
|
49 * |
|
50 * CMmsMessageOperation is derived from CMsvOperation class and can therefore |
|
51 * supply progress information to a caller while the asynchronous operation is |
|
52 * being carried out. |
|
53 * |
|
54 * The progress information provides the id of the created message when the |
|
55 * message has been created in a 8-bit descriptor. While the operation is in |
|
56 * progress the package will contain a null id (KMsvNullIndexEntryId). |
|
57 * If there was an error while creating the message, then the message will be |
|
58 * deleted and the package will contain null id. |
|
59 * |
|
60 * The progress will be packaged into an 8-bit descriptor in the normal manner, |
|
61 * as described by the CMsvOperation API. |
|
62 */ |
|
63 class CMmsMessageOperation :public CMsvOperation |
|
64 { |
|
65 public: // Constructors and destructor |
|
66 |
|
67 /** |
|
68 * Destructor. |
|
69 */ |
|
70 IMPORT_C ~CMmsMessageOperation(); |
|
71 |
|
72 public: // New functions |
|
73 |
|
74 /** |
|
75 * Crete new message entry. |
|
76 * @param aObserverRequestStatus observer's request status. |
|
77 * @param aMsvSession message server session. |
|
78 * @param aDestination destination folder id. |
|
79 * @param aServiceId MMS service id. |
|
80 * @param aVisible if the new entry is visible. |
|
81 * @param aInPreparation if the new entry is left under construction. |
|
82 * @return this message operation object. |
|
83 */ |
|
84 IMPORT_C static CMmsMessageOperation* CreateNewL( |
|
85 TRequestStatus& aObserverRequestStatus, |
|
86 CMsvSession& aMsvSession, |
|
87 TMsvId aDestination, |
|
88 TMsvId aServiceId, |
|
89 TBool aVisible = EFalse, |
|
90 TBool aInPreparation = ETrue ); |
|
91 |
|
92 /** |
|
93 * Crete new reply message entry. |
|
94 * @param aObserverRequestStatus observer's request status. |
|
95 * @param aMsvSession message server session. |
|
96 * @param aMessageId original message id |
|
97 * @param aDestination destination folder id |
|
98 * @param aPartList message part list included in the new entry |
|
99 * @param aServiceId MMS service id |
|
100 * @param aVisible if the new entry is visible. |
|
101 * @param aInPreparation if the new entry is left under construction. |
|
102 * @return this message operation object. |
|
103 */ |
|
104 IMPORT_C static CMmsMessageOperation* CreateReplyL( |
|
105 TRequestStatus& aObserverRequestStatus, |
|
106 CMsvSession& aMsvSession, |
|
107 TMsvId aMessageId, |
|
108 TMsvId aDestination, |
|
109 TMsvPartList aPartList, |
|
110 TMsvId aServiceId, |
|
111 TBool aVisible = EFalse, |
|
112 TBool aInPreparation = ETrue ); |
|
113 |
|
114 /** |
|
115 * Crete new forward message entry. |
|
116 * @param aObserverRequestStatus observer's request status. |
|
117 * @param aMsvSession message server session. |
|
118 * @param aMessageId original message id |
|
119 * @param aDestination destination folder id |
|
120 * @param aPartList message part list included in the new entry |
|
121 * @param aServiceId MMS service id |
|
122 * @param aVisible if the new entry is visible. |
|
123 * @param aInPreparation if the new entry is left under construction. |
|
124 * @return this message operation object. |
|
125 */ |
|
126 IMPORT_C static CMmsMessageOperation* CreateForwardL( |
|
127 TRequestStatus& aObserverRequestStatus, |
|
128 CMsvSession& aMsvSession, |
|
129 TMsvId aMessageId, |
|
130 TMsvId aDestination, |
|
131 TMsvPartList aPartList, |
|
132 TMsvId aServiceId, |
|
133 TBool aVisible = EFalse, |
|
134 TBool aInPreparation = ETrue ); |
|
135 |
|
136 /** |
|
137 * Crete new forward without retrieval entry. |
|
138 * This function is used only for forwarding a message based on a received |
|
139 * notification without fetching the whole message into the terminal. |
|
140 * This is a static and synchronous function. |
|
141 * @param aMsvSession message server session. |
|
142 * @param aContentLocation of the related notification |
|
143 * @param aRelatedEntry entryId of the notification that this forward refers to |
|
144 * @param aDestination destination folder id |
|
145 * @param aServiceId MMS service id |
|
146 * @param aVisible if the new entry is visible. |
|
147 * @param aInPreparation if the new entry is left under construction. |
|
148 * @return entry id of the newly created entry |
|
149 */ |
|
150 IMPORT_C static TMsvId CreateForwardWithoutRetrievalL( |
|
151 CMsvSession& aMsvSession, |
|
152 const CMmsHeaders& aNotificationHeaders, |
|
153 const TMsvId aRelatedEntry, |
|
154 const TMsvId aDestination, |
|
155 TMsvId aServiceId, |
|
156 TBool aVisible = EFalse, |
|
157 TBool aInPreparation = ETrue ); |
|
158 |
|
159 /** |
|
160 * This returns the id of the created message if a message was created |
|
161 * packaged into an 8-bit descriptor. If there was an error while creating |
|
162 * the message, then the message will be deleted and the package will |
|
163 * contain a null id. |
|
164 * @return the id of the created message packaged into an 8-bit descriptor. |
|
165 */ |
|
166 IMPORT_C const TDesC8& FinalProgress(); |
|
167 |
|
168 public: // Functions from base classes |
|
169 |
|
170 /** |
|
171 * Active object completion |
|
172 */ |
|
173 void RunL(); |
|
174 |
|
175 /** |
|
176 * Active object cancellation |
|
177 */ |
|
178 void DoCancel(); |
|
179 |
|
180 /** |
|
181 * Use this function to get information on the progress of the operation. |
|
182 * @return descriptor holding progress information (message id). |
|
183 */ |
|
184 const TDesC8& ProgressL(); |
|
185 |
|
186 protected: // New functions |
|
187 |
|
188 protected: // Functions from base classes |
|
189 |
|
190 private: |
|
191 |
|
192 // Different operations that this class is able to perform |
|
193 // NOTE: Forward without retrieval operation is not in this list |
|
194 // because it is a static and syncronous operation. |
|
195 enum TMmsOperation |
|
196 { |
|
197 ENew, |
|
198 EReply, |
|
199 EForward |
|
200 }; |
|
201 |
|
202 // Possible states |
|
203 // NOTE: forward without retrieval operation is synchronous and |
|
204 // is not related to these |
|
205 enum TMmsOperationState |
|
206 { |
|
207 ECreateMmsHeaders, |
|
208 ECreateMessageEntry, |
|
209 EStoreMmsHeaders, |
|
210 ECopyAttachments, |
|
211 ECompleteMessage, |
|
212 EFinished |
|
213 }; |
|
214 |
|
215 /** |
|
216 * Symbian OS constructor is private. |
|
217 * @param aMessageId original message id |
|
218 * @param aOperation what to do. |
|
219 */ |
|
220 void ConstructL( |
|
221 TMsvId aMessageId, |
|
222 TMmsOperation aOperation ); |
|
223 |
|
224 /** |
|
225 * C-style constructor. |
|
226 * @param aObserverRequestStatus observer's request status |
|
227 * @param aMsvSession message server session |
|
228 * @param aDestination destination folder id |
|
229 * @param aPartList message part list included in the new entry |
|
230 * @param aServiceId MMS service id |
|
231 * @param aVisible if the new entry is visible. |
|
232 * @param aInPreparation if the new entry is left under construction. |
|
233 */ |
|
234 CMmsMessageOperation( |
|
235 TRequestStatus& aObserverRequestStatus, |
|
236 CMsvSession& aMsvSession, |
|
237 TMsvId aDestination, |
|
238 TMsvPartList aPartList, |
|
239 TMsvId aServiceId, |
|
240 TBool aVisible, |
|
241 TBool aInPreparation ); |
|
242 |
|
243 /** |
|
244 * Tidy up environment after error, and free memory. |
|
245 * @param aError error code to be returned |
|
246 */ |
|
247 void ErrorRecovery( TInt aError ); |
|
248 |
|
249 /** |
|
250 * Change the state of this operation. |
|
251 */ |
|
252 void ChangeStateL(); |
|
253 |
|
254 /** |
|
255 * Select the next state of this operation. |
|
256 */ |
|
257 void SelectNextStateL(); |
|
258 |
|
259 /** |
|
260 * Do the operations and change the state. |
|
261 */ |
|
262 void SelectAndChangeToNextStateL(); |
|
263 |
|
264 /** |
|
265 * Signal the completion of a request. ( one step ) |
|
266 */ |
|
267 void RequestComplete( TInt aError ); |
|
268 |
|
269 /** |
|
270 * Create MMS headers. Set default values from MMS service entry. |
|
271 */ |
|
272 void CreateNewMmsHeaderL(); |
|
273 |
|
274 /** |
|
275 * Create new message entry. |
|
276 */ |
|
277 void CreateMessageEntryL(); |
|
278 |
|
279 /** |
|
280 * Store MMS headers of the message |
|
281 */ |
|
282 void StoreMmsHeadersL(); |
|
283 |
|
284 /** |
|
285 * Copy attachments entries and binary files from original message entry. |
|
286 */ |
|
287 void CopyAttachmentsL(); |
|
288 |
|
289 /** |
|
290 * Complete the message. Count the message size and set flags. |
|
291 */ |
|
292 void CompleteMessageL(); |
|
293 |
|
294 /** |
|
295 * Count the total size of attachments |
|
296 */ |
|
297 void AttachmentsSizeL(); |
|
298 |
|
299 public: // Data |
|
300 |
|
301 protected: // Data |
|
302 |
|
303 private: // Data |
|
304 TInt iState; |
|
305 TPckgBuf<TMsvId> iDataMember; |
|
306 TMsvId iNewMessageId; |
|
307 CMsvOperation* iMsvOperation; |
|
308 TMsvId iDestinationId; |
|
309 TMsvPartList iPartList; |
|
310 TMsvId iOrigMessageId; |
|
311 TMmsOperation iOperation; |
|
312 TMsvId iServiceId; |
|
313 CMmsSettings* iSettings; |
|
314 CMmsHeaders* iNewMmsHeaders; |
|
315 TBool iVisible; |
|
316 TBool iInPreparation; |
|
317 TInt iAttachmentsSize; |
|
318 TInt iMmsHeaderSize; |
|
319 HBufC* iDescription; // message description |
|
320 TMsvAttachmentId iOriginalRoot; // to retain root when forwarding |
|
321 TInt iNewRoot; // index of root in new entry |
|
322 // Separate source and target entry and store are needed |
|
323 // for hanling attachments using the new attachment manager. |
|
324 CMsvStore* iSourceStore; // need to keep open to copy attachments |
|
325 CMsvStore* iTargetStore; // need to keep open to copy attachments |
|
326 CMsvEntry* iSourceEntry; |
|
327 CMsvEntry* iTargetEntry; |
|
328 TInt iAttachmentCount; //number of attachments to be handled |
|
329 TInt iCurrentAttachment; // index of attachmnet being handled |
|
330 |
|
331 public: // Friend classes |
|
332 |
|
333 protected: // Friend classes |
|
334 |
|
335 private: // Friend classes |
|
336 |
|
337 }; |
|
338 |
|
339 #endif // CMMSMESSAGEOPERATION_H |
|
340 |
|
341 // End of File |