|
1 /* |
|
2 * Copyright (c) 2002-2006 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 * CMmsViewerLaunchOperation, Storage for single attachment in presentation. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // ========== INCLUDE FILES ================================ |
|
22 |
|
23 #include <AknsConstants.h> |
|
24 #include <data_caging_path_literals.hrh> |
|
25 #include <MsgEditorView.h> // for CMsgEditorView |
|
26 #include <MsgBodyControl.h> |
|
27 #include <MuiuMsgEditorLauncher.h> |
|
28 |
|
29 #include <mmsconst.h> |
|
30 #include <mmsclient.h> |
|
31 #include <MmsViewer.rsg> |
|
32 |
|
33 #include <aknlayoutscalable_avkon.cdl.h> |
|
34 #include <aknlayoutscalable_apps.cdl.h> |
|
35 #include <AknUtils.h> |
|
36 #include <MsgEditorCommon.h> |
|
37 #include <MsgMediaInfo.h> |
|
38 #include <msgimagecontrol.h> |
|
39 #include <unislideloader.h> |
|
40 #include "UniMmsViewerDocument.h" |
|
41 |
|
42 #include <mmsui.mbg> |
|
43 #include "MmsMtmConst.h" // File logger |
|
44 |
|
45 #include "MmsMtmUi.h" |
|
46 #include "MmsViewerHeader.h" |
|
47 #include "MmsViewerLaunchOperation.h" |
|
48 |
|
49 _LIT( KMmsUiMbmFile, "mmsui.mbm" ); |
|
50 |
|
51 // ========== EXTERNAL DATA STRUCTURES ===================== |
|
52 |
|
53 // ========== EXTERNAL FUNCTION PROTOTYPES ================= |
|
54 |
|
55 // ========== CONSTANTS ==================================== |
|
56 |
|
57 // ========== MACROS ======================================= |
|
58 |
|
59 // ========== LOCAL CONSTANTS AND MACROS =================== |
|
60 |
|
61 // ========== MODULE DATA STRUCTURES ======================= |
|
62 |
|
63 // ========== LOCAL FUNCTION PROTOTYPES ==================== |
|
64 |
|
65 // ========== LOCAL FUNCTIONS ============================== |
|
66 |
|
67 // ========== MEMBER FUNCTIONS ============================= |
|
68 |
|
69 // --------------------------------------------------------- |
|
70 // CMmsViewerLaunchOperation::CMmsViewerLaunchOperation |
|
71 // |
|
72 // Constructor. |
|
73 // --------------------------------------------------------- |
|
74 // |
|
75 CMmsViewerLaunchOperation::CMmsViewerLaunchOperation( |
|
76 MUniObjectObserver* aUniObjectObserver, |
|
77 MMsgAsyncControlObserver& aControlObserver, |
|
78 MMmsViewerOperationObserver& aOperationObserver, |
|
79 CMmsViewerDocument& aDocument, |
|
80 CMsgEditorView& aView, |
|
81 RFs& aFs ) : |
|
82 CMmsViewerOperation( aOperationObserver, aDocument, aFs ), |
|
83 iControlObserver( aControlObserver ), |
|
84 iView( aView ), |
|
85 iUniObjectObserver( aUniObjectObserver ) |
|
86 { |
|
87 } |
|
88 |
|
89 |
|
90 // --------------------------------------------------------- |
|
91 // CMmsViewerLaunchOperation::CMmsViewerLaunchOperation |
|
92 // |
|
93 // Destructor. |
|
94 // --------------------------------------------------------- |
|
95 // |
|
96 CMmsViewerLaunchOperation::~CMmsViewerLaunchOperation() |
|
97 { |
|
98 #ifdef CANCEL_TEST_CODE |
|
99 CancelCancelTest( ); |
|
100 #endif |
|
101 Cancel(); |
|
102 delete iSlideLoader; |
|
103 delete iHeader; |
|
104 } |
|
105 |
|
106 // --------------------------------------------------------- |
|
107 // CMmsViewerLaunchOperation::Launch |
|
108 // |
|
109 // --------------------------------------------------------- |
|
110 // |
|
111 void CMmsViewerLaunchOperation::Launch() |
|
112 { |
|
113 iNextState = EMmsLaunchInitialize; |
|
114 CompleteSelf( KErrNone ); |
|
115 } |
|
116 |
|
117 // --------------------------------------------------------- |
|
118 // CMmsViewerLaunchOperation::Launch |
|
119 // |
|
120 // SaveL |
|
121 // --------------------------------------------------------- |
|
122 // |
|
123 void CMmsViewerLaunchOperation::DoLaunchStepL() |
|
124 { |
|
125 switch ( iNextState ) |
|
126 { |
|
127 case EMmsLaunchInitialize: |
|
128 { |
|
129 LOGTEXT(_L8("CMmsViewerLaunchOperation::DoLaunchStepL EMmsLaunchInitialize") ); |
|
130 DoInitializeL(); |
|
131 break; |
|
132 } |
|
133 case EMmsLaunchPrepareHeader: |
|
134 { |
|
135 LOGTEXT(_L8("CMmsViewerLaunchOperation::DoLaunchStepL EMmsLaunchPrepareHeader") ); |
|
136 DoPrepareHeaderL(); |
|
137 break; |
|
138 } |
|
139 case EMmsLaunchPrepareBody: |
|
140 { |
|
141 LOGTEXT(_L8("CMmsViewerLaunchOperation::DoLaunchStepL EMmsLaunchPrepareBody") ); |
|
142 DoPrepareBodyL(); |
|
143 break; |
|
144 } |
|
145 case EMmsLaunchEnd: |
|
146 { |
|
147 LOGTEXT(_L8("CMmsViewerLaunchOperation::DoLaunchStepL EMmsLaunchEnd") ); |
|
148 iObserver.ViewerOperationEvent( |
|
149 EMmsViewerOperationLaunch, |
|
150 EMmsViewerOperationComplete, |
|
151 KErrNone ); |
|
152 break; |
|
153 } |
|
154 default: |
|
155 iObserver.ViewerOperationEvent( |
|
156 EMmsViewerOperationLaunch, |
|
157 EMmsViewerOperationError, |
|
158 KErrUnknown ); |
|
159 break; |
|
160 } |
|
161 |
|
162 iNextState++; |
|
163 } |
|
164 |
|
165 // --------------------------------------------------------- |
|
166 // DoInitializeL |
|
167 // --------------------------------------------------------- |
|
168 void CMmsViewerLaunchOperation::DoInitializeL() |
|
169 { |
|
170 // For messages without SMIL iDocument.InitializeL() completes immediately even before |
|
171 // call of SetActiveNoCompleteSelf |
|
172 iDocument.InitializeL( *this ); |
|
173 if ( !iIsInitialised ) |
|
174 { |
|
175 SetActiveNoCompleteSelf(); |
|
176 } |
|
177 } |
|
178 |
|
179 |
|
180 // --------------------------------------------------------- |
|
181 // DoPrepareHeaderL |
|
182 // --------------------------------------------------------- |
|
183 void CMmsViewerLaunchOperation::DoPrepareHeaderL() |
|
184 { |
|
185 // Header is always drawn and populated |
|
186 iHeader = CMmsViewerHeader::NewL( |
|
187 iDocument.Mtm(), |
|
188 iDocument.DataModel().AttachmentList(), |
|
189 iView, |
|
190 iFs ); |
|
191 CompleteSelf( KErrNone ); |
|
192 } |
|
193 |
|
194 // --------------------------------------------------------- |
|
195 // DoPrepareBodyL |
|
196 // --------------------------------------------------------- |
|
197 void CMmsViewerLaunchOperation::DoPrepareBodyL() |
|
198 { |
|
199 // Determine whether body objects should be drawn |
|
200 // NOTE: Viewable if conformant even if forwarded. |
|
201 if ( iDocument.ErrorResponseMessage() ) |
|
202 { |
|
203 DoPrepareErrorResponseMessageL(); |
|
204 CompleteSelf( KErrNone ); |
|
205 } |
|
206 else if ( iDocument.SmilType() == EMmsSmil ) |
|
207 { |
|
208 if ( !iDocument.SmilModel()->SlideCount() ) |
|
209 { |
|
210 iDocument.SmilModel()->AddSlideL(); |
|
211 } |
|
212 |
|
213 iSlideLoader = CUniSlideLoader::NewL( |
|
214 iUniObjectObserver, |
|
215 iControlObserver, |
|
216 iDocument.DataModel(), |
|
217 iView, |
|
218 EUniControlViewerMode ); |
|
219 |
|
220 iSlideLoader->LoadSlideL( *this, 0 ); |
|
221 SetActiveNoCompleteSelf( ); |
|
222 } |
|
223 else |
|
224 { |
|
225 DoPrepare3GPPBodyL(); |
|
226 CompleteSelf( KErrNone ); |
|
227 } |
|
228 } |
|
229 |
|
230 // --------------------------------------------------------- |
|
231 // DoPrepareErrorResponseMessageL |
|
232 // --------------------------------------------------------- |
|
233 void CMmsViewerLaunchOperation::DoPrepareErrorResponseMessageL() |
|
234 { |
|
235 CMsgBodyControl* textControl = CMsgBodyControl::NewL( &iView ); |
|
236 CleanupStack::PushL( textControl ); |
|
237 textControl->SetControlId( EMsgComponentIdBody ); |
|
238 |
|
239 textControl->InsertTextL( |
|
240 static_cast<CMmsClientMtm&>( iDocument.Mtm() ).ResponseText() ); |
|
241 |
|
242 iView.AddControlL( textControl, EMsgComponentIdBody, EMsgFirstControl, EMsgBody ); |
|
243 CleanupStack::Pop( textControl ); |
|
244 } |
|
245 |
|
246 // --------------------------------------------------------- |
|
247 // DoPrepare3GPPBodyL |
|
248 // --------------------------------------------------------- |
|
249 void CMmsViewerLaunchOperation::DoPrepare3GPPBodyL() |
|
250 { |
|
251 CMsgImageControl* imageControl = CMsgImageControl::NewL( |
|
252 iView, |
|
253 &iControlObserver ); |
|
254 CleanupStack::PushL( imageControl ); |
|
255 |
|
256 TParse fileParse; |
|
257 |
|
258 fileParse.Set( KMmsUiMbmFile, &KDC_APP_BITMAP_DIR, NULL ); |
|
259 imageControl->LoadIconL( |
|
260 fileParse.FullName( ), |
|
261 KAknsIIDQgnGrafMmsPlay, |
|
262 EMbmMmsuiQgn_graf_mms_play, |
|
263 EMbmMmsuiQgn_graf_mms_play_mask ); |
|
264 |
|
265 TAknWindowLineLayout layOut( AknLayoutScalable_Apps::msg_data_pane_g7().LayoutLine() ); |
|
266 TAknLayoutRect iconLayout; |
|
267 iconLayout.LayoutRect( MsgEditorCommons::MsgDataPane(), |
|
268 layOut ); |
|
269 |
|
270 imageControl->SetIconSizeL( iconLayout.Rect().Size() ); |
|
271 imageControl->SetIconVisible( ETrue ); |
|
272 |
|
273 imageControl->SetControlId( EMsgComponentIdImage ); |
|
274 //The ownership of imageControl is transferred to iView |
|
275 iView.AddControlL( imageControl, EMsgComponentIdImage, EMsgFirstControl, EMsgBody ); |
|
276 CleanupStack::Pop( imageControl ); |
|
277 } |
|
278 |
|
279 // --------------------------------------------------------- |
|
280 // CMmsViewerLaunchOperation::DoCancel |
|
281 // |
|
282 // --------------------------------------------------------- |
|
283 // |
|
284 void CMmsViewerLaunchOperation::DoCancel() |
|
285 { |
|
286 LOGTEXT(_L8("CMmsViewerLaunchOperation::DoCancel") ); |
|
287 if ( iSlideLoader ) |
|
288 { |
|
289 iSlideLoader->Cancel(); |
|
290 } |
|
291 iObserver.ViewerOperationEvent( |
|
292 EMmsViewerOperationLaunch, |
|
293 EMmsViewerOperationCancel, |
|
294 KErrNone ); |
|
295 CompleteActiveSelf( KErrCancel ); |
|
296 } |
|
297 |
|
298 // --------------------------------------------------------- |
|
299 // CMmsViewerLaunchOperation::RunL |
|
300 // |
|
301 // --------------------------------------------------------- |
|
302 // |
|
303 void CMmsViewerLaunchOperation::RunL() |
|
304 { |
|
305 LOGTEXT2( _L("CMmsViewerLaunchOperation::RunL iStatus=%d"), iStatus.Int() ); |
|
306 if ( iStatus.Int() == KErrCancel ) |
|
307 { |
|
308 iObserver.ViewerOperationEvent( |
|
309 EMmsViewerOperationLaunch, |
|
310 EMmsViewerOperationCancel, |
|
311 iStatus.Int() ); |
|
312 return; |
|
313 } |
|
314 else if ( iStatus.Int() != KErrNone ) |
|
315 { |
|
316 User::Leave( iStatus.Int() ); |
|
317 } |
|
318 |
|
319 DoLaunchStepL(); |
|
320 } |
|
321 |
|
322 // --------------------------------------------------------- |
|
323 // CMmsViewerLaunchOperation::RunError |
|
324 // |
|
325 // --------------------------------------------------------- |
|
326 // |
|
327 TInt CMmsViewerLaunchOperation::RunError( TInt aError ) |
|
328 { |
|
329 LOGTEXT2(_L("CMmsViewerLaunchOperation::RunError aError %d"), aError ); |
|
330 if ( aError == KLeaveExit ) |
|
331 { |
|
332 return KLeaveExit; |
|
333 } |
|
334 iObserver.ViewerOperationEvent( |
|
335 EMmsViewerOperationLaunch, |
|
336 EMmsViewerOperationError, |
|
337 aError ); |
|
338 return KErrNone; |
|
339 } |
|
340 |
|
341 // --------------------------------------------------------- |
|
342 // InitializeReady |
|
343 // --------------------------------------------------------- |
|
344 // |
|
345 void CMmsViewerLaunchOperation::InitializeReady( TInt aParseResult, TInt aError ) |
|
346 { |
|
347 LOGTEXT2(_L("CMmsViewerLaunchOperation::InitializeReady aError %d"), aError ); |
|
348 iIsInitialised = ETrue; |
|
349 iParseResult = aParseResult; |
|
350 if ( !IsActive() ) |
|
351 { |
|
352 SetActiveNoCompleteSelf(); |
|
353 } |
|
354 CompleteActiveSelf( aError ); |
|
355 } |
|
356 |
|
357 // --------------------------------------------------------- |
|
358 // UiSlideEvent |
|
359 // --------------------------------------------------------- |
|
360 // |
|
361 void CMmsViewerLaunchOperation::SlideLoadReady( TInt aError ) |
|
362 { |
|
363 LOGTEXT2(_L("CMmsViewerLaunchOperation::SlideLoadReady aError %d"), aError ); |
|
364 CompleteActiveSelf( aError ); |
|
365 } |
|
366 |
|
367 // EOF |