60
|
1 |
/*
|
|
2 |
* Copyright (c) 2006,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: CUniEditorSendUiOperation, operation for opening messages created by SendUI
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// ========== INCLUDE FILES ================================
|
|
21 |
|
|
22 |
#include <mmsconst.h>
|
|
23 |
|
|
24 |
#include <unidatautils.h>
|
|
25 |
#include <MsgMimeTypes.h>
|
|
26 |
#include <unismilmodel.h>
|
|
27 |
#include <MsgMediaInfo.h>
|
|
28 |
#include <MsgTextInfo.h>
|
|
29 |
#include <MsgImageInfo.h>
|
|
30 |
#include <MsgVideoInfo.h>
|
|
31 |
|
|
32 |
#include <MmsConformance.h>
|
|
33 |
|
|
34 |
#include "UniEditorSendUiOperation.h"
|
|
35 |
#include "UniEditorProcessTextOperation.h"
|
|
36 |
|
|
37 |
// ========== EXTERNAL DATA STRUCTURES =====================
|
|
38 |
|
|
39 |
// ========== EXTERNAL FUNCTION PROTOTYPES =================
|
|
40 |
|
|
41 |
// ========== CONSTANTS ====================================
|
|
42 |
|
|
43 |
const TUint KSendAsDeleteAllPercentage = 80;
|
|
44 |
|
|
45 |
// ========== MACROS =======================================
|
|
46 |
|
|
47 |
// ========== LOCAL CONSTANTS AND MACROS ===================
|
|
48 |
|
|
49 |
// ========== MODULE DATA STRUCTURES =======================
|
|
50 |
|
|
51 |
// ========== LOCAL FUNCTION PROTOTYPES ====================
|
|
52 |
|
|
53 |
// ========== LOCAL FUNCTIONS ==============================
|
|
54 |
|
|
55 |
// ========== MEMBER FUNCTIONS =============================
|
|
56 |
|
|
57 |
// ---------------------------------------------------------
|
|
58 |
// CUniEditorSendUiOperation::NewL
|
|
59 |
//
|
|
60 |
// Factory method.
|
|
61 |
// ---------------------------------------------------------
|
|
62 |
//
|
|
63 |
CUniEditorSendUiOperation* CUniEditorSendUiOperation::NewL(
|
|
64 |
MUniEditorOperationObserver& aObserver,
|
|
65 |
CUniEditorDocument& aDocument,
|
|
66 |
RFs& aFs )
|
|
67 |
{
|
|
68 |
CUniEditorSendUiOperation* self =
|
|
69 |
new ( ELeave ) CUniEditorSendUiOperation( aObserver, aDocument, aFs );
|
|
70 |
|
|
71 |
CleanupStack::PushL( self );
|
|
72 |
self->ConstructL();
|
|
73 |
CleanupStack::Pop( self );
|
|
74 |
|
|
75 |
return self;
|
|
76 |
}
|
|
77 |
|
|
78 |
// ---------------------------------------------------------
|
|
79 |
// CUniEditorSendUiOperation::CUniEditorSendUiOperation
|
|
80 |
//
|
|
81 |
// Constructor.
|
|
82 |
// ---------------------------------------------------------
|
|
83 |
//
|
|
84 |
CUniEditorSendUiOperation::CUniEditorSendUiOperation(
|
|
85 |
MUniEditorOperationObserver& aObserver,
|
|
86 |
CUniEditorDocument& aDocument,
|
|
87 |
RFs& aFs ) :
|
|
88 |
CUniEditorOperation( aObserver, aDocument, aFs, EUniEditorOperationSendUi )
|
|
89 |
{
|
|
90 |
}
|
|
91 |
|
|
92 |
|
|
93 |
// ---------------------------------------------------------
|
|
94 |
// CUniEditorSendUiOperation::CUniEditorSendUiOperation
|
|
95 |
//
|
|
96 |
// Destructor.
|
|
97 |
// ---------------------------------------------------------
|
|
98 |
//
|
|
99 |
CUniEditorSendUiOperation::~CUniEditorSendUiOperation()
|
|
100 |
{
|
|
101 |
Cancel();
|
|
102 |
delete iImageOperation;
|
|
103 |
delete iVideoOperation;
|
|
104 |
#ifdef RD_MSG_XHTML_SUPPORT
|
|
105 |
delete iTextOperation;
|
|
106 |
#endif
|
|
107 |
}
|
|
108 |
|
|
109 |
// ---------------------------------------------------------
|
|
110 |
// CUniEditorSendUiOperation::Start
|
|
111 |
// ---------------------------------------------------------
|
|
112 |
//
|
|
113 |
void CUniEditorSendUiOperation::Start()
|
|
114 |
{
|
|
115 |
ResetErrors();
|
|
116 |
|
|
117 |
iOperationState = EUniEditorSendUiCheck;
|
|
118 |
iObjectsSize = 0;
|
|
119 |
iObjectNum = 0;
|
|
120 |
iSlideNum = 0;
|
|
121 |
iDeleteAll = EFalse;
|
|
122 |
|
|
123 |
CompleteSelf( KErrNone );
|
|
124 |
}
|
|
125 |
|
|
126 |
// ---------------------------------------------------------
|
|
127 |
// CUniEditorSendUiOperation::ConstructL
|
|
128 |
//
|
|
129 |
// 2nd phase constructor.
|
|
130 |
// ---------------------------------------------------------
|
|
131 |
//
|
|
132 |
void CUniEditorSendUiOperation::ConstructL()
|
|
133 |
{
|
|
134 |
BaseConstructL();
|
|
135 |
|
|
136 |
iDeleteAllLimit = ( iDocument.MaxMessageSize() * KSendAsDeleteAllPercentage ) / 100;
|
|
137 |
iOptimizedFlow = EFalse;
|
|
138 |
}
|
|
139 |
|
|
140 |
// ---------------------------------------------------------
|
|
141 |
// CUniEditorSendUiOperation::DoCancelCleanup
|
|
142 |
//
|
|
143 |
// ---------------------------------------------------------
|
|
144 |
//
|
|
145 |
void CUniEditorSendUiOperation::DoCancelCleanup()
|
|
146 |
{
|
|
147 |
if ( iImageOperation )
|
|
148 |
{
|
|
149 |
iImageOperation->Cancel();
|
|
150 |
}
|
|
151 |
|
|
152 |
if ( iVideoOperation )
|
|
153 |
{
|
|
154 |
iVideoOperation->Cancel();
|
|
155 |
}
|
|
156 |
#ifdef RD_MSG_XHTML_SUPPORT
|
|
157 |
if ( iTextOperation )
|
|
158 |
{
|
|
159 |
iTextOperation->Cancel();
|
|
160 |
}
|
|
161 |
#endif
|
|
162 |
}
|
|
163 |
|
|
164 |
// ---------------------------------------------------------
|
|
165 |
// CUniEditorSendUiOperation::RunL
|
|
166 |
//
|
|
167 |
// ---------------------------------------------------------
|
|
168 |
//
|
|
169 |
void CUniEditorSendUiOperation::RunL()
|
|
170 |
{
|
|
171 |
PrintOperationAndState();
|
|
172 |
|
|
173 |
if ( !SetErrorAndReport( iStatus.Int() ) )
|
|
174 |
{
|
|
175 |
DoSendUiStepL();
|
|
176 |
}
|
|
177 |
}
|
|
178 |
|
|
179 |
// ---------------------------------------------------------
|
|
180 |
// CUniEditorSendUiOperation::DoSendUiStepL
|
|
181 |
//
|
|
182 |
// ---------------------------------------------------------
|
|
183 |
//
|
|
184 |
void CUniEditorSendUiOperation::DoSendUiStepL()
|
|
185 |
{
|
|
186 |
switch ( iOperationState )
|
|
187 |
{
|
|
188 |
case EUniEditorSendUiCheck:
|
|
189 |
{
|
|
190 |
DoSendUiCheckL();
|
|
191 |
break;
|
|
192 |
}
|
|
193 |
case EUniEditorSendUiPrepareObject:
|
|
194 |
{
|
|
195 |
DoSendUiPrepareObjectL();
|
|
196 |
break;
|
|
197 |
}
|
|
198 |
case EUniEditorSendUiPrepareAttachments:
|
|
199 |
{
|
|
200 |
DoSendUiPrepareAttachmentsL();
|
|
201 |
break;
|
|
202 |
}
|
|
203 |
case EUniEditorSendUiEnd:
|
|
204 |
{
|
|
205 |
iObserver.EditorOperationEvent( EUniEditorOperationSendUi,
|
|
206 |
EUniEditorOperationComplete );
|
|
207 |
break;
|
|
208 |
}
|
|
209 |
default:
|
|
210 |
{
|
|
211 |
iObserver.EditorOperationEvent( EUniEditorOperationSendUi,
|
|
212 |
EUniEditorOperationError );
|
|
213 |
break;
|
|
214 |
}
|
|
215 |
}
|
|
216 |
}
|
|
217 |
|
|
218 |
// ---------------------------------------------------------
|
|
219 |
// CUniEditorSendUiOperation::DoSendUiCheckL
|
|
220 |
//
|
|
221 |
// Check message content when message created by SendAs
|
|
222 |
// ---------------------------------------------------------
|
|
223 |
//
|
|
224 |
void CUniEditorSendUiOperation::DoSendUiCheckL()
|
|
225 |
{
|
|
226 |
// check is it, one embedded object with jpeg image
|
|
227 |
// captured from camera\ seleted from photo\ filemanager
|
|
228 |
TInt objectCount =iDocument.DataModel()->ObjectList().Count() ;
|
|
229 |
TInt slideCount =iDocument.DataModel()->SmilModel().SlideCount() ;
|
|
230 |
if ( (objectCount == 1)&&(slideCount == 1)&&
|
|
231 |
(iDocument.DataModel()->AttachmentList().Count()== 0))
|
|
232 |
{
|
|
233 |
CUniObject* obj =
|
|
234 |
iDocument.DataModel()->SmilModel().GetObjectByIndex( slideCount-1, objectCount-1 );
|
|
235 |
if(obj->MediaInfo()->MimeType().CompareF( KMsgMimeImageJpeg )== 0)
|
|
236 |
{
|
|
237 |
iOptimizedFlow = ETrue;
|
|
238 |
}
|
|
239 |
}
|
|
240 |
|
|
241 |
if ( iDocument.DataModel()->ObjectList().Count() ||
|
|
242 |
iDocument.DataModel()->AttachmentList().Count() )
|
|
243 |
{
|
|
244 |
DoCheckFilesL();
|
|
245 |
}
|
|
246 |
|
|
247 |
if ( iDocument.DataModel()->ObjectList().Count() )
|
|
248 |
{
|
|
249 |
iDocument.DataModel()->SmilModel().SortSlidesL();
|
|
250 |
}
|
|
251 |
|
|
252 |
iOperationState = EUniEditorSendUiPrepareObject;
|
|
253 |
CompleteSelf( KErrNone );
|
|
254 |
}
|
|
255 |
|
|
256 |
// ---------------------------------------------------------
|
|
257 |
// CUniEditorSendUiOperation::DoCheckFilesL
|
|
258 |
// ---------------------------------------------------------
|
|
259 |
//
|
|
260 |
void CUniEditorSendUiOperation::DoCheckFilesL()
|
|
261 |
{
|
|
262 |
TInt slideCount = iDocument.DataModel()->SmilModel().SlideCount();
|
|
263 |
|
|
264 |
//It's important to go from end to beginning
|
|
265 |
//because slides may be removed
|
|
266 |
for ( TInt i = slideCount; --i >= 0 ; )
|
|
267 |
{
|
|
268 |
//It's important to go from end to beginning
|
|
269 |
//because objects may be removed
|
|
270 |
for ( TInt ii = iDocument.DataModel()->SmilModel().SlideObjectCount(i); --ii >= 0 ;)
|
|
271 |
{
|
|
272 |
CUniObject* obj = iDocument.DataModel()->SmilModel().GetObjectByIndex( i, ii );
|
|
273 |
|
|
274 |
TMmsConformance conformance =
|
|
275 |
iDocument.DataModel()->MmsConformance().MediaConformance( *obj->MediaInfo() );
|
|
276 |
|
|
277 |
TUint32 confStatus = conformance.iConfStatus;
|
|
278 |
|
|
279 |
TBool remove = EFalse;
|
|
280 |
if ( confStatus & EMmsConfNokDRM )
|
|
281 |
{
|
|
282 |
remove = ETrue;
|
|
283 |
SetError( EUniSendUiForbidden );
|
|
284 |
}
|
|
285 |
else if ( confStatus & EMmsConfNokCorrupt )
|
|
286 |
{
|
|
287 |
SetError( EUniSendUiCorrupted );
|
|
288 |
}
|
|
289 |
else if ( confStatus & ( EMmsConfNokNotEnoughInfo | EMmsConfNokNotSupported ) ||
|
|
290 |
( iDocument.CreationMode() == EMmsCreationModeRestricted &&
|
|
291 |
confStatus & EMmsConfNokFreeModeOnly ) )
|
|
292 |
{
|
|
293 |
remove = ETrue;
|
|
294 |
SetError( EUniSendUiUnsupported );
|
|
295 |
}
|
|
296 |
else if ( !conformance.iCanAdapt &&
|
|
297 |
confStatus & EMmsConfNokTooBig )
|
|
298 |
{
|
|
299 |
remove = ETrue;
|
|
300 |
SetError( EUniSendUiTooBig );
|
|
301 |
}
|
|
302 |
|
|
303 |
if ( remove )
|
|
304 |
{
|
|
305 |
iDocument.DataModel()->SmilModel().RemoveObjectByIndexL( i, ii );
|
|
306 |
remove = EFalse;
|
|
307 |
}
|
|
308 |
}
|
|
309 |
|
|
310 |
if ( !iDocument.DataModel()->SmilModel().SlideObjectCount( i ) )
|
|
311 |
{
|
|
312 |
iDocument.DataModel()->SmilModel().RemoveSlide( i );
|
|
313 |
}
|
|
314 |
}
|
|
315 |
|
|
316 |
CUniObjectList& attachments = iDocument.DataModel()->AttachmentList();
|
|
317 |
//It's important to go from end to beginning
|
|
318 |
//because attachments may be removed
|
|
319 |
for ( TInt j = attachments.Count(); --j >= 0 ; )
|
|
320 |
{
|
|
321 |
CUniObject* obj = attachments.GetByIndex( j );
|
|
322 |
|
|
323 |
TMmsConformance conformance =
|
|
324 |
iDocument.DataModel()->MmsConformance().MediaConformance( *obj->MediaInfo() );
|
|
325 |
|
|
326 |
TUint32 confStatus = conformance.iConfStatus;
|
|
327 |
|
|
328 |
if ( iDocument.CreationMode() != EMmsCreationModeRestricted )
|
|
329 |
{
|
|
330 |
// Mask "FreeModeOnly" away in free mode
|
|
331 |
confStatus &= ~EMmsConfNokFreeModeOnly;
|
|
332 |
// Mask "Scaling needed" away in free mode
|
|
333 |
confStatus &= ~EMmsConfNokScalingNeeded;
|
|
334 |
}
|
|
335 |
|
|
336 |
if ( confStatus & EMmsConfNokDRM )
|
|
337 |
{
|
|
338 |
attachments.RemoveObjectL( obj );
|
|
339 |
SetError( EUniSendUiForbidden );
|
|
340 |
delete obj;
|
|
341 |
}
|
|
342 |
else if ( confStatus & EMmsConfNokCorrupt )
|
|
343 |
{
|
|
344 |
SetError( EUniSendUiCorrupted );
|
|
345 |
}
|
|
346 |
else if ( confStatus != EMmsConfOk )
|
|
347 |
{
|
|
348 |
attachments.RemoveObjectL( obj );
|
|
349 |
SetError( EUniSendUiUnsupported );
|
|
350 |
delete obj;
|
|
351 |
}
|
|
352 |
}
|
|
353 |
}
|
|
354 |
|
|
355 |
// ---------------------------------------------------------
|
|
356 |
// CUniEditorSendUiOperation::DoSendUiPrepareObjectL
|
|
357 |
//
|
|
358 |
// Processes images and checks whether message size is below
|
|
359 |
// max size. If not removes as many objects as needed.
|
|
360 |
// ---------------------------------------------------------
|
|
361 |
//
|
|
362 |
void CUniEditorSendUiOperation::DoSendUiPrepareObjectL()
|
|
363 |
{
|
|
364 |
VerifyPreparedObjectL();
|
|
365 |
|
|
366 |
CUniObject* obj = iDocument.DataModel()->SmilModel().GetObjectByIndex( iSlideNum, iObjectNum );
|
|
367 |
|
|
368 |
if ( obj )
|
|
369 |
{
|
|
370 |
DoPrepareObjectL( obj );
|
|
371 |
}
|
|
372 |
else
|
|
373 |
{
|
|
374 |
iOperationState = EUniEditorSendUiPrepareAttachments;
|
|
375 |
CompleteSelf( KErrNone );
|
|
376 |
}
|
|
377 |
}
|
|
378 |
|
|
379 |
// ---------------------------------------------------------
|
|
380 |
// CUniEditorSendUiOperation::VerifyPreparedObjectL
|
|
381 |
// ---------------------------------------------------------
|
|
382 |
//
|
|
383 |
void CUniEditorSendUiOperation::VerifyPreparedObjectL()
|
|
384 |
{
|
|
385 |
if ( iPreparedObject )
|
|
386 |
{
|
|
387 |
TBool remove = EFalse;
|
|
388 |
|
|
389 |
// Conformance status check!
|
|
390 |
TMmsConformance conformance =
|
|
391 |
iDocument.DataModel()->MmsConformance().MediaConformance( *iPreparedObject->MediaInfo() );
|
|
392 |
|
|
393 |
TUint32 confStatus = conformance.iConfStatus;
|
|
394 |
if ( iPreparedObject->MediaType() == EMsgMediaText )
|
|
395 |
{
|
|
396 |
// Mask "ConversionNeeded" away for text objects
|
|
397 |
// -> Will be always converted to UTF-8 anyway
|
|
398 |
confStatus &= ~EMmsConfNokConversionNeeded;
|
|
399 |
}
|
|
400 |
|
|
401 |
if ( iDocument.CreationMode() != EMmsCreationModeRestricted )
|
|
402 |
{
|
|
403 |
// Mask "FreeModeOnly" away in free mode
|
|
404 |
confStatus &= ~EMmsConfNokFreeModeOnly;
|
|
405 |
// Mask "Scaling needed" away in free mode
|
|
406 |
confStatus &= ~EMmsConfNokScalingNeeded;
|
|
407 |
//Mask "Corrupted" away in free mode
|
|
408 |
confStatus &= ~EMmsConfNokCorrupt;
|
|
409 |
}
|
|
410 |
|
|
411 |
// Mask "Too big" away as there is a separate check for that
|
|
412 |
confStatus &= ~EMmsConfNokTooBig;
|
|
413 |
|
|
414 |
if ( confStatus != EMmsConfOk )
|
|
415 |
{
|
|
416 |
SetError( EUniSendUiUnsupported );
|
|
417 |
remove = ETrue;
|
|
418 |
}
|
|
419 |
|
|
420 |
TInt currentSize = iObjectsSize +
|
|
421 |
iPreparedObject->Size() +
|
|
422 |
iDocument.DataModel()->SmilModel().SmilComposeSize( iSlideNum + 1, iObjectNum + 1 );
|
|
423 |
|
|
424 |
if ( !remove &&
|
|
425 |
TUint( currentSize ) > iDocument.MaxMessageSize() )
|
|
426 |
{
|
|
427 |
// Remove if above max size
|
|
428 |
if ( TUint( iPreviousSize ) > iDeleteAllLimit )
|
|
429 |
{
|
|
430 |
//Once above "delete all limit" delete all the rest.
|
|
431 |
iDeleteAll = ETrue;
|
|
432 |
}
|
|
433 |
remove = ETrue;
|
|
434 |
SetError( EUniSendUiTooBig );
|
|
435 |
}
|
|
436 |
else
|
|
437 |
{
|
|
438 |
// Don't remove. Update previous size.
|
|
439 |
iPreviousSize = currentSize;
|
|
440 |
}
|
|
441 |
|
|
442 |
if ( remove )
|
|
443 |
{
|
|
444 |
iDocument.DataModel()->SmilModel().RemoveObjectByIndexL( iSlideNum, iObjectNum );
|
|
445 |
|
|
446 |
if ( !iDocument.DataModel()->SmilModel().SlideObjectCount( iSlideNum ) )
|
|
447 |
{
|
|
448 |
iDocument.DataModel()->SmilModel().RemoveSlide( iSlideNum );
|
|
449 |
}
|
|
450 |
}
|
|
451 |
else
|
|
452 |
{
|
|
453 |
iObjectsSize += iPreparedObject->Size();
|
|
454 |
iObjectNum++;
|
|
455 |
|
|
456 |
if ( iObjectNum >= iDocument.DataModel()->SmilModel().SlideObjectCount( iSlideNum ) )
|
|
457 |
{
|
|
458 |
iSlideNum++;
|
|
459 |
iObjectNum = 0;
|
|
460 |
}
|
|
461 |
}
|
|
462 |
}
|
|
463 |
}
|
|
464 |
|
|
465 |
// ---------------------------------------------------------
|
|
466 |
// CUniEditorSendUiOperation::DoPrepareObjectL
|
|
467 |
// ---------------------------------------------------------
|
|
468 |
//
|
|
469 |
void CUniEditorSendUiOperation::DoPrepareObjectL( CUniObject* aObject )
|
|
470 |
{
|
|
471 |
switch ( aObject->MediaType() )
|
|
472 |
{
|
|
473 |
case EMsgMediaImage:
|
|
474 |
{
|
|
475 |
if ( !iImageOperation )
|
|
476 |
{
|
|
477 |
iImageOperation = CUniEditorProcessImageOperation::NewL( *this, iDocument, iFs );
|
|
478 |
}
|
|
479 |
|
|
480 |
iImageOperation->SetOptimizedFlow(iOptimizedFlow);
|
|
481 |
// Processes if needed:
|
|
482 |
iImageOperation->Process( static_cast<CMsgImageInfo*>( aObject->MediaInfo() ),
|
|
483 |
aObject->AttachmentId(),
|
|
484 |
iPreviousSize );
|
|
485 |
iPreparedObject = aObject;
|
|
486 |
|
|
487 |
SetPending();
|
|
488 |
return;
|
|
489 |
}
|
|
490 |
case EMsgMediaVideo:
|
|
491 |
{
|
|
492 |
//We need video conversion only for mp4 videos
|
|
493 |
if ( aObject->MimeType().Compare( KMsgMimeVideoMp4 ) == 0 )
|
|
494 |
{
|
|
495 |
if ( CUniEditorConvertVideoOperation::IsImplementedL() )
|
|
496 |
{
|
|
497 |
if ( !iVideoOperation )
|
|
498 |
{
|
|
499 |
iVideoOperation = CUniEditorConvertVideoOperation::NewL( *this, iDocument, iFs );
|
|
500 |
}
|
|
501 |
|
|
502 |
// Processes if needed:
|
|
503 |
iVideoOperation->Process( static_cast<CMsgVideoInfo*>( aObject->MediaInfo() ),
|
|
504 |
aObject->AttachmentId(),
|
|
505 |
iDocument.MaxMessageSize() );
|
|
506 |
iPreparedObject = aObject;
|
|
507 |
|
|
508 |
SetPending();
|
|
509 |
return;
|
|
510 |
}
|
|
511 |
}
|
|
512 |
break;
|
|
513 |
}
|
|
514 |
case EMsgMediaXhtml:
|
|
515 |
{
|
|
516 |
#ifdef RD_MSG_XHTML_SUPPORT
|
|
517 |
// Processes all XHTML objects and converts them into plain text.
|
|
518 |
iTextOperation = CUniEditorProcessTextOperation::NewL( *this, iDocument, iFs );
|
|
519 |
iTextOperation->Start();
|
|
520 |
|
|
521 |
SetPending();
|
|
522 |
return;
|
|
523 |
#else
|
|
524 |
break;
|
|
525 |
#endif
|
|
526 |
}
|
|
527 |
case EMsgMediaText:
|
|
528 |
case EMsgMediaAudio:
|
|
529 |
default:
|
|
530 |
{
|
|
531 |
// nothing
|
|
532 |
break;
|
|
533 |
}
|
|
534 |
}
|
|
535 |
|
|
536 |
iPreparedObject = aObject;
|
|
537 |
CompleteSelf( KErrNone );
|
|
538 |
}
|
|
539 |
|
|
540 |
// ---------------------------------------------------------
|
|
541 |
// CUniEditorSendUiOperation::DoSendUiPrepareAttachmentsL
|
|
542 |
// ---------------------------------------------------------
|
|
543 |
//
|
|
544 |
void CUniEditorSendUiOperation::DoSendUiPrepareAttachmentsL()
|
|
545 |
{
|
|
546 |
TInt smilSize = iObjectsSize + iDocument.DataModel()->SmilModel().SmilComposeSize();
|
|
547 |
|
|
548 |
TInt attaSize = 0;
|
|
549 |
TInt j = 0;
|
|
550 |
|
|
551 |
CUniObjectList& attachments = iDocument.DataModel()->AttachmentList();
|
|
552 |
|
|
553 |
if ( attachments.Count() )
|
|
554 |
{
|
|
555 |
while ( TUint( smilSize + attaSize ) < iDocument.MaxMessageSize() )
|
|
556 |
{
|
|
557 |
attaSize += attachments.GetByIndex( j )->Size();
|
|
558 |
j++;
|
|
559 |
if ( j >= attachments.Count() &&
|
|
560 |
TUint( smilSize + attaSize ) < iDocument.MaxMessageSize() )
|
|
561 |
{
|
|
562 |
j++;
|
|
563 |
break;
|
|
564 |
}
|
|
565 |
}
|
|
566 |
j--;
|
|
567 |
while ( j < attachments.Count() )
|
|
568 |
{
|
|
569 |
CUniObject* obj = attachments.GetByIndex( j );
|
|
570 |
attachments.RemoveObjectL( obj );
|
|
571 |
SetError( EUniSendUiTooBig );
|
|
572 |
delete obj;
|
|
573 |
}
|
|
574 |
}
|
|
575 |
iOperationState = EUniEditorSendUiEnd;
|
|
576 |
CompleteSelf( KErrNone );
|
|
577 |
}
|
|
578 |
|
|
579 |
// ---------------------------------------------------------
|
|
580 |
// CUniEditorSendUiOperation::HandleOperationEvent
|
|
581 |
// ---------------------------------------------------------
|
|
582 |
//
|
|
583 |
void CUniEditorSendUiOperation::HandleOperationEvent( TUniEditorOperationType aOperation,
|
|
584 |
TUniEditorOperationEvent aEvent )
|
|
585 |
{
|
|
586 |
TBool remove( EFalse );
|
|
587 |
|
|
588 |
TMsvAttachmentId attaId( KMsvNullIndexEntryId );
|
|
589 |
CMsgMediaInfo* info = NULL;
|
|
590 |
|
|
591 |
if ( aOperation == EUniEditorOperationProcessImage )
|
|
592 |
{
|
|
593 |
if( aEvent == EUniEditorOperationPartialComplete)
|
|
594 |
{
|
|
595 |
if(iOptimizedFlow)
|
|
596 |
{
|
|
597 |
iObserver.EditorOperationEvent( EUniEditorOperationSendUi,
|
|
598 |
EUniEditorOperationPartialComplete );
|
|
599 |
iOptimizedFlow = EFalse;
|
|
600 |
}
|
|
601 |
return;
|
|
602 |
}
|
|
603 |
iOptimizedFlow = EFalse;
|
|
604 |
// Process image error handling
|
|
605 |
CArrayFixFlat<TInt>* errors = iImageOperation->GetErrors();
|
|
606 |
for ( TInt i = 0; i < errors->Count(); i++ )
|
|
607 |
{
|
|
608 |
if ( errors->At( i ) == EUniProcessImgUserAbort )
|
|
609 |
{
|
|
610 |
iOperationState = EUniEditorSendUiEnd;
|
|
611 |
}
|
|
612 |
else if ( ( errors->At( i ) == EUniProcessImgCouldNotScale &&
|
|
613 |
iDocument.CreationMode() == EMmsCreationModeRestricted ) ||
|
|
614 |
errors->At( i ) == EUniProcessImgNotFound )
|
|
615 |
{
|
|
616 |
remove = ETrue;
|
|
617 |
}
|
|
618 |
|
|
619 |
SetError( errors->At( i ) );
|
|
620 |
}
|
|
621 |
|
|
622 |
info = iImageOperation->DetachImageInfo();
|
|
623 |
iImageOperation->DetachAttachmentId( attaId );
|
|
624 |
}
|
|
625 |
else if ( aOperation == EUniEditorOperationConvertVideo )
|
|
626 |
{
|
|
627 |
// Convert video error handling
|
|
628 |
CArrayFixFlat<TInt>* errors = iVideoOperation->GetErrors();
|
|
629 |
for ( TInt i = 0; i < errors->Count(); i++ )
|
|
630 |
{
|
|
631 |
if ( errors->At( i ) == EUniConvertVidUserAbort )
|
|
632 |
{
|
|
633 |
iOperationState = EUniEditorSendUiEnd;
|
|
634 |
}
|
|
635 |
else if ( ( errors->At( i ) == EUniConvertVidFailed &&
|
|
636 |
iDocument.CreationMode() == EMmsCreationModeRestricted ) ||
|
|
637 |
errors->At( i ) == EUniConvertVidNotFound )
|
|
638 |
{
|
|
639 |
remove = ETrue;
|
|
640 |
}
|
|
641 |
|
|
642 |
SetError( errors->At( i ) );
|
|
643 |
}
|
|
644 |
|
|
645 |
info = iVideoOperation->DetachVideoInfo();
|
|
646 |
iVideoOperation->DetachAttachmentId( attaId );
|
|
647 |
}
|
|
648 |
#ifdef RD_MSG_XHTML_SUPPORT
|
|
649 |
else if ( aOperation == EUniEditorOperationProcessText )
|
|
650 |
{
|
|
651 |
CArrayFixFlat<TInt>* errors = iTextOperation->GetErrors();
|
|
652 |
for ( TInt i = 0; i < errors->Count(); i++ )
|
|
653 |
{
|
|
654 |
SetError( errors->At( i ) );
|
|
655 |
}
|
|
656 |
}
|
|
657 |
#endif
|
|
658 |
|
|
659 |
if ( info )
|
|
660 |
{
|
|
661 |
TRAPD( error,
|
|
662 |
iDocument.DataModel()->SmilModel().RemoveObjectL( iSlideNum, iPreparedObject ) );
|
|
663 |
|
|
664 |
if ( !error )
|
|
665 |
{
|
|
666 |
iPreparedObject = NULL;
|
|
667 |
TRAP_IGNORE( iPreparedObject = iDocument.DataModel()->SmilModel().AddStoredObjectL( iSlideNum, attaId, info ) );
|
|
668 |
}
|
|
669 |
else // --> original object remains...
|
|
670 |
{
|
|
671 |
delete info;
|
|
672 |
}
|
|
673 |
}
|
|
674 |
|
|
675 |
if ( remove && iPreparedObject )
|
|
676 |
{
|
|
677 |
TRAPD( err, iDocument.DataModel()->SmilModel().RemoveObjectByIndexL( iSlideNum, iObjectNum ) );
|
|
678 |
|
|
679 |
if ( !err &&
|
|
680 |
!iDocument.DataModel()->SmilModel().SlideObjectCount( iSlideNum ) )
|
|
681 |
{
|
|
682 |
iDocument.DataModel()->SmilModel().RemoveSlide( iSlideNum );
|
|
683 |
}
|
|
684 |
|
|
685 |
iPreparedObject = NULL;
|
|
686 |
}
|
|
687 |
|
|
688 |
//else --> original object remains...
|
|
689 |
CompleteOperation( KErrNone );
|
|
690 |
}
|
|
691 |
// ---------------------------------------------------------
|
|
692 |
// CUniEditorSendUiOperation::IsOptimizedFlagSet
|
|
693 |
// ---------------------------------------------------------
|
|
694 |
//
|
|
695 |
TBool CUniEditorSendUiOperation::IsOptimizedFlagSet()
|
|
696 |
{
|
|
697 |
return iOptimizedFlow;
|
|
698 |
}
|
|
699 |
// EOF
|