|
1 /* |
|
2 * Copyright (c) 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 * CPostcardOperationSave, asynchronous operation for postcard saving |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #ifndef __POSTCARDOPERATIONSAVE_H |
|
22 #define __POSTCARDOPERATIONSAVE_H |
|
23 |
|
24 // INCLUDES |
|
25 |
|
26 #include <e32base.h> |
|
27 #include <e32std.h> |
|
28 |
|
29 #include "PostcardOperation.h" |
|
30 |
|
31 // CONSTANTS |
|
32 |
|
33 // MACROS |
|
34 |
|
35 // FORWARD DECLARATIONS |
|
36 class CMsvAttachment; |
|
37 class CPlainText; |
|
38 class CContactCard; |
|
39 class CCnvCharacterSetConverter; |
|
40 class CContactItemFieldSet; |
|
41 |
|
42 // DATA TYPES |
|
43 |
|
44 // FUNCTION PROTOTYPES |
|
45 |
|
46 // CLASS DECLARATION |
|
47 |
|
48 /** |
|
49 * CPostcardOperationSave |
|
50 * @lib postcardeditor.exe |
|
51 * @since 3.0 |
|
52 */ |
|
53 class CPostcardOperationSave : public CPostcardOperation |
|
54 { |
|
55 public: // New methods |
|
56 |
|
57 /** |
|
58 * Factory method that creates this object. |
|
59 * @since 3.0 |
|
60 * @return Pointer to instance |
|
61 */ |
|
62 static CPostcardOperationSave* NewL( |
|
63 MPostcardOperationObserver& aObserver, |
|
64 CPostcardDocument& aDocument, |
|
65 CPostcardAppUi& aAppUi, |
|
66 RFs& aFs, |
|
67 CContactCard& aContactItem, |
|
68 CPlainText& aPlainText ); |
|
69 |
|
70 /** |
|
71 * Destructor |
|
72 */ |
|
73 virtual ~CPostcardOperationSave( ); |
|
74 |
|
75 /** |
|
76 * Checks the argument to determine if the operation is save or send |
|
77 * Initializes iLaunchState and completes itself. |
|
78 * param aArgument If 0 - this is Save, otherwise Send |
|
79 */ |
|
80 void Start( TInt aArgument ); |
|
81 |
|
82 private: |
|
83 |
|
84 /** |
|
85 * Called by RunL. |
|
86 * Calls different functions according to iLaunchStep |
|
87 */ |
|
88 void DoLaunchStepL( ); |
|
89 |
|
90 /** |
|
91 * Removes the old text and recipient attachments. |
|
92 */ |
|
93 void RemoveOldAttasL( ); |
|
94 |
|
95 /** |
|
96 * Calls StartCreatingEmptyAttachmentL with greeting text file name |
|
97 */ |
|
98 void CreateNewTextAttaL( ); |
|
99 |
|
100 /** |
|
101 * Creates CharConverter. |
|
102 * Create new mime headers. |
|
103 * Sets mime types and possible OMA X header for text file. |
|
104 * If special format is used, handles the adding of the recipient address here |
|
105 * Converts user added separator characters to replacement characters. |
|
106 * Then writes the whole text into message store buffer by buffer. |
|
107 */ |
|
108 void HandleTextL( ); |
|
109 |
|
110 /** |
|
111 * Creates a special format text from postcard greeting and address |
|
112 */ |
|
113 HBufC* MakeSpecialFormatTextL( ); |
|
114 |
|
115 /** |
|
116 * Stores the mime headers. |
|
117 * In case special format was used -> skips the following recipient handling. |
|
118 * and smil adding and moves directly to finalizing the message |
|
119 */ |
|
120 void FinalizeTextL( ); |
|
121 |
|
122 /** |
|
123 * Calls StartCreatingEmptyAttachmentL with recipient VCard file name |
|
124 */ |
|
125 void CreateNewRecipientAttaL( ); |
|
126 |
|
127 /** |
|
128 * Creates CharConverter. |
|
129 * Create new mime headers. |
|
130 * Sets mime types VCard file. |
|
131 * Creates an instance of CParserVCard. |
|
132 * Adds the recipient address fields into the parser. |
|
133 * Parser externalizes itself into the message store. |
|
134 */ |
|
135 void HandleRecipientL( ); |
|
136 |
|
137 /** |
|
138 * Stores the mime headers. |
|
139 */ |
|
140 void FinalizeRecipientL( ); |
|
141 |
|
142 /** |
|
143 * In case Postcard app supports OMA 1.3 Postcard format a SMIL file is created. |
|
144 * Calls StartCreatingEmptyAttachmentL with smil file name |
|
145 */ |
|
146 void CreateNewSmilAttaL( ); |
|
147 |
|
148 /** |
|
149 * Creates and sets mime headers. |
|
150 * Reads the SMIL from resource file (R_POSTCARD_OMA_SMIL) |
|
151 * Writes the smil into the file. |
|
152 */ |
|
153 void HandleSmilL( ); |
|
154 |
|
155 /** |
|
156 * Stores the mime headers. |
|
157 */ |
|
158 void FinalizeSmilL( ); |
|
159 |
|
160 /** |
|
161 * In case no recipient is set, reads the address of the service provider |
|
162 * from the resource file and sets it as a recipient (of the Postcard MMS itself, not the postcard) |
|
163 * Updates the TMsvEntry (details, description, visibility, editor-orientation, biotype) |
|
164 */ |
|
165 void FinalizeMessageL( ); |
|
166 |
|
167 /** |
|
168 * Call ClientMtm's Send function. Called if this operation was started as "Send" |
|
169 */ |
|
170 void StartSendingL( ); |
|
171 |
|
172 /** |
|
173 * From CActive |
|
174 */ |
|
175 void DoCancel( ); |
|
176 |
|
177 /** |
|
178 * From CActive |
|
179 * Calls DoLaunchStepL |
|
180 */ |
|
181 void RunL( ); |
|
182 |
|
183 /** |
|
184 * From CActive |
|
185 */ |
|
186 TInt RunError( TInt aError ); |
|
187 |
|
188 protected: |
|
189 |
|
190 /** |
|
191 * Constructor. |
|
192 */ |
|
193 CPostcardOperationSave( |
|
194 MPostcardOperationObserver& aObserver, |
|
195 CPostcardDocument& aDocument, |
|
196 CPostcardAppUi& aAppUi, |
|
197 RFs& aFs, |
|
198 CContactCard& aContactItem, |
|
199 CPlainText& aPlainText ); |
|
200 |
|
201 /** |
|
202 * 2nd phase constructor. |
|
203 */ |
|
204 void ConstructL( ); |
|
205 |
|
206 private: |
|
207 |
|
208 /** |
|
209 * Creates a new empty attachment and asks AttachmentManager |
|
210 * to add it into message store. |
|
211 */ |
|
212 void StartCreatingEmptyAttachmentL( const TFileName& aFileName ); |
|
213 |
|
214 /** |
|
215 * Returns ETrue if any of the address fields has at least one character |
|
216 */ |
|
217 TBool HasContact( ); |
|
218 |
|
219 /** |
|
220 * Reads the address fields from aSet and adds them into an array. |
|
221 * The order is so that the strings match to the indexes used in |
|
222 * special format string. If operation is in "Send" mode and |
|
223 * special format is used -> looks for separator characters in |
|
224 * the field values and calls ReplaceWithL to replace them with |
|
225 * replace characters. |
|
226 * Returns the array to the caller. |
|
227 */ |
|
228 CDesCArrayFlat* AddressArrayLC( CContactItemFieldSet& aSet ); |
|
229 |
|
230 /** |
|
231 * Reads the address fields from aSet and adds them into an array. |
|
232 * The order is so that the strings match the order used in VCard address field |
|
233 * If operation is in "Send" mode and special format is used -> |
|
234 * looks for separator characters in the field values and calls |
|
235 * ReplaceWithL to replace them with replace characters. |
|
236 * Returns the array to the caller. |
|
237 */ |
|
238 CDesCArrayFlat* VCardAddressArrayL( CContactItemFieldSet& aSet ); |
|
239 |
|
240 /** |
|
241 * Looks for aWhat's in descriptor aOrig. Replaces aWhat's with aWiths. |
|
242 * param aOrig IN/OUT Function modifies this descriptor so that aWhat is replaced with aWith |
|
243 * param aWhat IN Replace this string |
|
244 * param aWith IN Replace with this string |
|
245 */ |
|
246 void ReplaceWith( TDes& aOrig, const TDesC& aWhat, const TDesC& aWith ); |
|
247 |
|
248 /** |
|
249 * Finds the image attachment and gets its name. |
|
250 * returns the the image file name buffer |
|
251 */ |
|
252 HBufC* GetImageFileNameL( ); |
|
253 |
|
254 protected: // data |
|
255 |
|
256 enum TPostcardSaveState |
|
257 { |
|
258 EPostcardSaveInitializing = 0, |
|
259 EPostcardSaveCheckAttas, |
|
260 EPostcardSaveRemoveOldAttas, |
|
261 EPostcardSaveCreateTextAtta, |
|
262 EPostcardSaveSaveTextAtta, |
|
263 EPostcardSaveFinalizeTextAtta, |
|
264 EPostcardSaveCreateRecipientAtta, |
|
265 EPostcardSaveSaveRecipientAtta, |
|
266 EPostcardSaveFinalizeRecipientAtta, |
|
267 EPostcardSaveCreateSmilAtta, |
|
268 EPostcardSaveSaveSmilAtta, |
|
269 EPostcardFinalizeSmilAtta, |
|
270 EPostcardSaveUninit, |
|
271 EPostcardSaveFinalizeMessage, |
|
272 EPostcardSaveStartSend, |
|
273 EPostcardSaveFinished, |
|
274 EPostcardSaveError |
|
275 }; |
|
276 |
|
277 enum TPostcardSaveFlags |
|
278 { |
|
279 EPostcardSaveSend = 1, |
|
280 EPostcardSaveSpecialFormat = 2, |
|
281 EPostcardSaveHasContact = 4, |
|
282 EPostcardSaveRequestActive = 8 |
|
283 }; |
|
284 |
|
285 private: |
|
286 CMsvAttachment* iTempAtta; |
|
287 RFile* iTempFile; |
|
288 CContactCard& iContact; |
|
289 CCnvCharacterSetConverter* iCharConv; |
|
290 |
|
291 CPlainText& iPlainText; |
|
292 CMsvOperation* iSendOperation; |
|
293 HBufC* iRecipientName; |
|
294 TInt iFlags; |
|
295 }; |
|
296 |
|
297 #endif // __PostcardOperationSave_H |