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: Provides CUniEditorProcessImageOperation methods.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// ========== INCLUDE FILES ================================
|
|
21 |
|
|
22 |
#include <apmstd.h>
|
|
23 |
|
|
24 |
#include <icl/imagedata.h>
|
|
25 |
|
|
26 |
#include <centralrepository.h>
|
|
27 |
|
|
28 |
#include <messagingvariant.hrh>
|
|
29 |
#include <messaginginternalcrkeys.h> // for Central Repository keys
|
|
30 |
|
|
31 |
#include <MsgMediaResolver.h>
|
|
32 |
#include <MsgImageInfo.h>
|
|
33 |
#include <MmsConformance.h>
|
|
34 |
#include <MsgMimeTypes.h>
|
|
35 |
|
|
36 |
#include <uniimageprocessor.h>
|
|
37 |
#include <unimsventry.h>
|
|
38 |
|
|
39 |
#include <mmsvattachmentmanager.h>
|
|
40 |
#include <mmsvattachmentmanagersync.h>
|
|
41 |
#include <cmsvattachment.h>
|
|
42 |
|
|
43 |
#include <msgtextutils.h>
|
|
44 |
|
|
45 |
#include <mmssettingsdefs.h>
|
|
46 |
|
|
47 |
#include <mmsversion.h>
|
|
48 |
|
|
49 |
#include "UniClientMtm.h"
|
|
50 |
#include "UniEditorEnum.h"
|
|
51 |
#include "UniEditorDocument.h"
|
|
52 |
#include "UniEditorProcessImageOperation.h"
|
|
53 |
|
|
54 |
// ========== CONSTANTS ====================================
|
|
55 |
|
|
56 |
// Leave some space after compression so that text can be inserted to the
|
|
57 |
// message.
|
|
58 |
const TInt KUniCompressionMargin = 10 * 1024; // 10 kB
|
|
59 |
|
|
60 |
const TInt KUniMmsUploadImageWidth = 1600;
|
|
61 |
const TInt KUniMmsUploadImageHeight = 1200;
|
|
62 |
|
|
63 |
|
|
64 |
_LIT8( KUniExtImageJpeg_8, ".jpg" );
|
|
65 |
_LIT8( KUniExtImageGif_8, ".gif" );
|
|
66 |
|
|
67 |
// ========== MEMBER FUNCTIONS =============================
|
|
68 |
|
|
69 |
// ---------------------------------------------------------
|
|
70 |
// CUniEditorProcessImageOperation::NewL
|
|
71 |
//
|
|
72 |
// Factory method.
|
|
73 |
// ---------------------------------------------------------
|
|
74 |
//
|
|
75 |
CUniEditorProcessImageOperation* CUniEditorProcessImageOperation::NewL(
|
|
76 |
MUniEditorOperationObserver& aObserver,
|
|
77 |
CUniEditorDocument& aDocument,
|
|
78 |
RFs& aFs )
|
|
79 |
{
|
|
80 |
CUniEditorProcessImageOperation* self = new ( ELeave ) CUniEditorProcessImageOperation(
|
|
81 |
aObserver,
|
|
82 |
aDocument,
|
|
83 |
aFs );
|
|
84 |
|
|
85 |
CleanupStack::PushL( self );
|
|
86 |
self->ConstructL();
|
|
87 |
CleanupStack::Pop( self );
|
|
88 |
|
|
89 |
return self;
|
|
90 |
}
|
|
91 |
|
|
92 |
// ---------------------------------------------------------
|
|
93 |
// CUniEditorProcessImageOperation::CUniEditorProcessImageOperation.
|
|
94 |
// ---------------------------------------------------------
|
|
95 |
//
|
|
96 |
CUniEditorProcessImageOperation::CUniEditorProcessImageOperation(
|
|
97 |
MUniEditorOperationObserver& aObserver,
|
|
98 |
CUniEditorDocument& aDocument,
|
|
99 |
RFs& aFs ) :
|
|
100 |
CUniEditorOperation( aObserver, aDocument, aFs, EUniEditorOperationProcessImage ),
|
|
101 |
iNewAttaId( KMsvNullIndexEntryId ),
|
|
102 |
iOptimizedFlow(EFalse)
|
|
103 |
{
|
|
104 |
}
|
|
105 |
|
|
106 |
// ---------------------------------------------------------
|
|
107 |
// CUniEditorProcessImageOperation::ConstructL
|
|
108 |
//
|
|
109 |
// 2nd phase constructor.
|
|
110 |
// ---------------------------------------------------------
|
|
111 |
//
|
|
112 |
void CUniEditorProcessImageOperation::ConstructL()
|
|
113 |
{
|
|
114 |
BaseConstructL();
|
|
115 |
|
|
116 |
TInt featureBitmask( 0 );
|
|
117 |
|
|
118 |
CRepository* repository = CRepository::NewL( KCRUidMuiuVariation );
|
|
119 |
repository->Get( KMuiuMmsFeatures, featureBitmask );
|
|
120 |
|
|
121 |
iExactImageScaling = ( featureBitmask & KMmsFeatureIdExactImageScaling );
|
|
122 |
|
|
123 |
delete repository;
|
|
124 |
}
|
|
125 |
|
|
126 |
// ---------------------------------------------------------
|
|
127 |
// CUniEditorProcessImageOperation::~CUniEditorProcessImageOperation
|
|
128 |
// ---------------------------------------------------------
|
|
129 |
//
|
|
130 |
CUniEditorProcessImageOperation::~CUniEditorProcessImageOperation()
|
|
131 |
{
|
|
132 |
Cancel();
|
|
133 |
|
|
134 |
delete iNewImageInfo;
|
|
135 |
iNewImageFile.Close();
|
|
136 |
delete iEditStore;
|
|
137 |
delete iImageProcessor;
|
|
138 |
}
|
|
139 |
|
|
140 |
// ---------------------------------------------------------
|
|
141 |
// CUniEditorProcessImageOperation::Process
|
|
142 |
// ---------------------------------------------------------
|
|
143 |
//
|
|
144 |
void CUniEditorProcessImageOperation::Process( CMsgImageInfo* aImageInfo,
|
|
145 |
TMsvAttachmentId aAttachmentId,
|
|
146 |
TInt aMessageSize )
|
|
147 |
{
|
|
148 |
ResetErrors();
|
|
149 |
|
|
150 |
iImageInfo = aImageInfo;
|
|
151 |
iAttachmentId = aAttachmentId;
|
|
152 |
iMessageSize = aMessageSize;
|
|
153 |
iOperationState = EUniProcessImgCheck;
|
|
154 |
|
|
155 |
CompleteSelf( KErrNone );
|
|
156 |
}
|
|
157 |
|
|
158 |
// ---------------------------------------------------------
|
|
159 |
// CUniEditorProcessImageOperation::DetachAttachmentId
|
|
160 |
// ---------------------------------------------------------
|
|
161 |
//
|
|
162 |
void CUniEditorProcessImageOperation::DetachAttachmentId( TMsvAttachmentId& aAttachmentId )
|
|
163 |
{
|
|
164 |
// iNewImageInfo may be already detached in DetachImageInfo
|
|
165 |
aAttachmentId = iNewAttaId;
|
|
166 |
iNewAttaId = KMsvNullIndexEntryId;
|
|
167 |
}
|
|
168 |
|
|
169 |
// ---------------------------------------------------------
|
|
170 |
// CUniEditorProcessImageOperation::RunL
|
|
171 |
// ---------------------------------------------------------
|
|
172 |
//
|
|
173 |
void CUniEditorProcessImageOperation::RunL()
|
|
174 |
{
|
|
175 |
PrintOperationAndState();
|
|
176 |
if ( iStatus.Int() != KErrNone )
|
|
177 |
{
|
|
178 |
SetError( iStatus.Int() );
|
|
179 |
iOperationState = EUniProcessImgError;
|
|
180 |
}
|
|
181 |
|
|
182 |
switch ( iOperationState )
|
|
183 |
{
|
|
184 |
case EUniProcessImgCheck:
|
|
185 |
{
|
|
186 |
DoStartCheck();
|
|
187 |
break;
|
|
188 |
}
|
|
189 |
case EUniProcessImgProcess:
|
|
190 |
{
|
|
191 |
DoStartProcessL();
|
|
192 |
break;
|
|
193 |
}
|
|
194 |
case EUniProcessImgResolve:
|
|
195 |
{
|
|
196 |
DoStartResolveL();
|
|
197 |
break;
|
|
198 |
}
|
|
199 |
case EUniProcessImgReady:
|
|
200 |
{
|
|
201 |
iObserver.EditorOperationEvent( EUniEditorOperationProcessImage,
|
|
202 |
EUniEditorOperationComplete );
|
|
203 |
break;
|
|
204 |
}
|
|
205 |
case EUniProcessImgError:
|
|
206 |
{
|
|
207 |
DoErrorWithoutStateChange();
|
|
208 |
iObserver.EditorOperationEvent( EUniEditorOperationProcessImage,
|
|
209 |
EUniEditorOperationError );
|
|
210 |
break;
|
|
211 |
}
|
|
212 |
default:
|
|
213 |
{
|
|
214 |
iObserver.EditorOperationEvent( EUniEditorOperationProcessImage,
|
|
215 |
EUniEditorOperationError );
|
|
216 |
break;
|
|
217 |
}
|
|
218 |
}
|
|
219 |
}
|
|
220 |
|
|
221 |
// ---------------------------------------------------------
|
|
222 |
// CUniEditorProcessImageOperation::DoCancelCleanup
|
|
223 |
// ---------------------------------------------------------
|
|
224 |
//
|
|
225 |
void CUniEditorProcessImageOperation::DoCancelCleanup()
|
|
226 |
{
|
|
227 |
if ( iImageProcessor )
|
|
228 |
{
|
|
229 |
iImageProcessor->Cancel();
|
|
230 |
}
|
|
231 |
|
|
232 |
DoErrorWithoutStateChange();
|
|
233 |
}
|
|
234 |
|
|
235 |
// ---------------------------------------------------------
|
|
236 |
// CUniEditorProcessImageOperation::DoStartCheck
|
|
237 |
// ---------------------------------------------------------
|
|
238 |
//
|
|
239 |
void CUniEditorProcessImageOperation::DoStartCheck()
|
|
240 |
{
|
|
241 |
if ( !CheckNeedToProcess() )
|
|
242 |
{
|
|
243 |
iOperationState = EUniProcessImgError;
|
|
244 |
}
|
|
245 |
else if ( iProcessMethod == EUniProcessImgMethodNone )
|
|
246 |
{
|
|
247 |
iOperationState = EUniProcessImgReady;
|
|
248 |
}
|
|
249 |
else
|
|
250 |
{
|
|
251 |
iOperationState = EUniProcessImgProcess;
|
|
252 |
}
|
|
253 |
CompleteSelf( KErrNone );
|
|
254 |
}
|
|
255 |
|
|
256 |
// ---------------------------------------------------------
|
|
257 |
// CUniEditorProcessImageOperation::DoStartProcessL
|
|
258 |
// ---------------------------------------------------------
|
|
259 |
//
|
|
260 |
void CUniEditorProcessImageOperation::DoStartProcessL()
|
|
261 |
{
|
|
262 |
|
|
263 |
if(iOptimizedFlow)
|
|
264 |
{
|
|
265 |
iObserver.EditorOperationEvent( EUniEditorOperationProcessImage,
|
|
266 |
EUniEditorOperationPartialComplete );
|
|
267 |
iOptimizedFlow = EFalse;
|
|
268 |
}
|
|
269 |
CreateEmptyAttachmentL();
|
|
270 |
|
|
271 |
if ( !iImageProcessor )
|
|
272 |
{
|
|
273 |
iImageProcessor = new( ELeave )CUniImageProcessor( this );
|
|
274 |
}
|
|
275 |
|
|
276 |
RFile sourceFile = OpenFileForReadingL();
|
|
277 |
|
|
278 |
CleanupClosePushL( sourceFile );
|
|
279 |
|
|
280 |
iImageProcessor->ProcessImageL( sourceFile,
|
|
281 |
iNewImageFile,
|
|
282 |
iScaleSize,
|
|
283 |
iTargetType.Des8(),
|
|
284 |
ETrue, // Always maintain aspect ratio
|
|
285 |
iDocument.MaxMessageSize() - KUniCompressionMargin );
|
|
286 |
SetPending();
|
|
287 |
|
|
288 |
CleanupStack::PopAndDestroy(); // sourceFile;
|
|
289 |
}
|
|
290 |
|
|
291 |
// ---------------------------------------------------------
|
|
292 |
// CUniEditorProcessImageOperation::DoStartResolveL
|
|
293 |
// ---------------------------------------------------------
|
|
294 |
//
|
|
295 |
void CUniEditorProcessImageOperation::DoStartResolveL()
|
|
296 |
{
|
|
297 |
iNewImageInfo = static_cast<CMsgImageInfo*>(iDocument.DataModel()->MediaResolver().CreateMediaInfoL( iNewImageFile ) );
|
|
298 |
iDocument.DataModel()->MediaResolver().ParseInfoDetailsL( iNewImageInfo, iNewImageFile );
|
|
299 |
|
|
300 |
iOperationState = EUniProcessImgReady;
|
|
301 |
|
|
302 |
iNewImageFile.Close();
|
|
303 |
|
|
304 |
__ASSERT_DEBUG( iEditStore, Panic( EUniNullPointer ) );
|
|
305 |
|
|
306 |
iEditStore->CommitL();
|
|
307 |
delete iEditStore;
|
|
308 |
iEditStore = NULL;
|
|
309 |
|
|
310 |
CompleteSelf( KErrNone );
|
|
311 |
}
|
|
312 |
|
|
313 |
// ---------------------------------------------------------
|
|
314 |
// CUniEditorProcessImageOperation::DoErrorWithoutStateChange
|
|
315 |
// ---------------------------------------------------------
|
|
316 |
//
|
|
317 |
void CUniEditorProcessImageOperation::DoErrorWithoutStateChange()
|
|
318 |
{
|
|
319 |
iNewImageFile.Close();
|
|
320 |
delete iNewImageInfo;
|
|
321 |
iNewImageInfo = NULL;
|
|
322 |
|
|
323 |
delete iEditStore;
|
|
324 |
iEditStore = NULL;
|
|
325 |
}
|
|
326 |
|
|
327 |
// ---------------------------------------------------------
|
|
328 |
// CUniEditorProcessImageOperation::ImageProcessingReady
|
|
329 |
//
|
|
330 |
// Image Compressor callback implementation.
|
|
331 |
// ---------------------------------------------------------
|
|
332 |
//
|
|
333 |
void CUniEditorProcessImageOperation::ImageProcessingReady( TSize aBitmapSize, TInt aFileSize, TBool aCompressed )
|
|
334 |
{
|
|
335 |
TInt err = iImageProcessor->Error();
|
|
336 |
|
|
337 |
if ( err == KErrNone &&
|
|
338 |
( aBitmapSize.iWidth == 0 || aBitmapSize.iHeight == 0 ||
|
|
339 |
( aCompressed &&
|
|
340 |
( aFileSize == 0 ||
|
|
341 |
aFileSize > ( iDocument.MaxMessageSize() - KUniCompressionMargin ) ) ) ) )
|
|
342 |
{
|
|
343 |
err = KErrGeneral;
|
|
344 |
}
|
|
345 |
|
|
346 |
switch ( err )
|
|
347 |
{
|
|
348 |
case KErrNone:
|
|
349 |
{
|
|
350 |
iOperationState = EUniProcessImgResolve;
|
|
351 |
if ( aCompressed )
|
|
352 |
{
|
|
353 |
SetError( EUniProcessImgCompressSuccessful );
|
|
354 |
}
|
|
355 |
break;
|
|
356 |
}
|
|
357 |
case KErrNoMemory:
|
|
358 |
{
|
|
359 |
iOperationState = EUniProcessImgError;
|
|
360 |
SetError( EUniProcessImgOutOfMemory );
|
|
361 |
break;
|
|
362 |
}
|
|
363 |
case KErrDiskFull:
|
|
364 |
{
|
|
365 |
iOperationState = EUniProcessImgError;
|
|
366 |
SetError( EUniProcessImgOutOfDisk );
|
|
367 |
break;
|
|
368 |
}
|
|
369 |
case KErrNotFound:
|
|
370 |
{
|
|
371 |
iOperationState = EUniProcessImgError;
|
|
372 |
SetError( EUniProcessImgNotFound );
|
|
373 |
break;
|
|
374 |
}
|
|
375 |
default:
|
|
376 |
{
|
|
377 |
iOperationState = EUniProcessImgError;
|
|
378 |
if ( aCompressed )
|
|
379 |
{
|
|
380 |
SetError( EUniProcessImgCompressFailed );
|
|
381 |
}
|
|
382 |
else
|
|
383 |
{
|
|
384 |
SetError( EUniProcessImgScalingFailed );
|
|
385 |
}
|
|
386 |
break;
|
|
387 |
}
|
|
388 |
}
|
|
389 |
|
|
390 |
if ( err == KErrCancel )
|
|
391 |
{
|
|
392 |
CompleteOperation( KErrCancel );
|
|
393 |
}
|
|
394 |
else
|
|
395 |
{
|
|
396 |
CompleteOperation( KErrNone );
|
|
397 |
}
|
|
398 |
}
|
|
399 |
|
|
400 |
// ---------------------------------------------------------
|
|
401 |
// CUniEditorProcessImageOperation::CheckNeedToProcess
|
|
402 |
//
|
|
403 |
// Checks if scaling/converting/compression is needed.
|
|
404 |
// ---------------------------------------------------------
|
|
405 |
//
|
|
406 |
TBool CUniEditorProcessImageOperation::CheckNeedToProcess()
|
|
407 |
{
|
|
408 |
iProcessMethod = EUniProcessImgMethodNone;
|
|
409 |
|
|
410 |
TMmsConformance conformance =
|
|
411 |
iDocument.DataModel()->MmsConformance().MediaConformance( *iImageInfo );
|
|
412 |
|
|
413 |
if ( conformance.iCanAdapt == EFalse )
|
|
414 |
{
|
|
415 |
return ETrue;
|
|
416 |
}
|
|
417 |
|
|
418 |
TSize origSize = iImageInfo->Dimensions();
|
|
419 |
|
|
420 |
if ( origSize.iWidth == 0 || origSize.iHeight == 0 )
|
|
421 |
{
|
|
422 |
// Cannot get size -> corrupted
|
|
423 |
SetError( EUniProcessImgCorrupted );
|
|
424 |
return ETrue;
|
|
425 |
}
|
|
426 |
|
|
427 |
TSize scaleSize = ImageSendSize();
|
|
428 |
TSize optimizedSize = origSize;
|
|
429 |
|
|
430 |
while ( optimizedSize.iWidth > scaleSize.iWidth ||
|
|
431 |
optimizedSize.iHeight > scaleSize.iHeight )
|
|
432 |
{
|
|
433 |
// Largest possible (1/2)^n size
|
|
434 |
optimizedSize.iWidth >>= 1;
|
|
435 |
optimizedSize.iHeight >>= 1;
|
|
436 |
}
|
|
437 |
|
|
438 |
if ( scaleSize.iWidth < origSize.iWidth ||
|
|
439 |
scaleSize.iHeight < origSize.iHeight )
|
|
440 |
{
|
|
441 |
if ( !iExactImageScaling &&
|
|
442 |
( scaleSize.iWidth > KMmsUniImageSmallWidth ||
|
|
443 |
scaleSize.iHeight > KMmsUniImageSmallHeight ) )
|
|
444 |
{
|
|
445 |
// Use optimized (1/2^n) size when scaling
|
|
446 |
// to larger than "Small"
|
|
447 |
scaleSize = optimizedSize;
|
|
448 |
}
|
|
449 |
// else -> scale to exact (non-optimized) size
|
|
450 |
|
|
451 |
iProcessMethod |= EUniProcessImgMethodScale;
|
|
452 |
}
|
|
453 |
else
|
|
454 |
{
|
|
455 |
// Scaling not needed. Check possible conversion need.
|
|
456 |
scaleSize = origSize;
|
|
457 |
|
|
458 |
if ( conformance.iConfStatus & EMmsConfNokConversionNeeded )
|
|
459 |
{
|
|
460 |
// Conversion needed.
|
|
461 |
iProcessMethod |= EUniProcessImgMethodConvert;
|
|
462 |
}
|
|
463 |
}
|
|
464 |
|
|
465 |
if ( !( iProcessMethod & EUniProcessImgMethodScale ) &&
|
|
466 |
( iImageInfo->FileSize() + iMessageSize ) > iDocument.MaxMessageSize() &&
|
|
467 |
iImageInfo->MimeType().CompareF( KMsgMimeImageJpeg ) == 0 &&
|
|
468 |
iMessageSize < KUniCompressionMargin )
|
|
469 |
{
|
|
470 |
// Only compression needed as image is JPEG that is larger than can be fitted
|
|
471 |
// into the message and scaling is not performed. Also current message size
|
|
472 |
// is under comression margin.
|
|
473 |
iProcessMethod |= EUniProcessImgMethodCompress;
|
|
474 |
}
|
|
475 |
|
|
476 |
TBool largeImageQuery = EFalse;
|
|
477 |
TInt conformanceWidth = KImageRichWidth;
|
|
478 |
TInt conformanceHeight = KImageRichHeight;
|
|
479 |
|
|
480 |
if (iDocument.DataModel()->MmsConformance().ConformanceVersion()> KMmsVersion12)
|
|
481 |
{
|
|
482 |
conformanceWidth = KImageMegapixelWidth;
|
|
483 |
conformanceHeight = KImageMegapixelHeight;
|
|
484 |
}
|
|
485 |
|
|
486 |
if ( iProcessMethod == EUniProcessImgMethodNone )
|
|
487 |
{
|
|
488 |
// Image won't be processed
|
|
489 |
if ( ( origSize.iWidth > conformanceWidth ||
|
|
490 |
origSize.iHeight > conformanceHeight ) &&
|
|
491 |
( iImageInfo->FileSize() + iMessageSize ) < iDocument.MaxMessageSize() )
|
|
492 |
{
|
|
493 |
// Original image width or height is "non-conformant" and original image would
|
|
494 |
// fit to into the message without any processing.
|
|
495 |
largeImageQuery = ETrue;
|
|
496 |
}
|
|
497 |
}
|
|
498 |
else
|
|
499 |
{
|
|
500 |
// Image will be processed
|
|
501 |
if ( scaleSize.iWidth > conformanceWidth ||
|
|
502 |
scaleSize.iHeight > conformanceHeight )
|
|
503 |
{
|
|
504 |
// Processed image is "non-conformant" after processing.
|
|
505 |
largeImageQuery = ETrue;
|
|
506 |
}
|
|
507 |
}
|
|
508 |
|
|
509 |
if ( largeImageQuery && iDocument.CreationMode() == EMmsCreationModeWarning )
|
|
510 |
{
|
|
511 |
// Observer will make the final decision whether it will show the query or not.
|
|
512 |
if ( !iObserver.EditorOperationQuery( EUniEditorOperationProcessImage,
|
|
513 |
EMEOQueryGuidedInsertLarge ) )
|
|
514 |
{
|
|
515 |
SetError( EUniProcessImgUserAbort );
|
|
516 |
return EFalse; // Abort
|
|
517 |
}
|
|
518 |
}
|
|
519 |
|
|
520 |
iScaleSize = scaleSize;
|
|
521 |
return ETrue;
|
|
522 |
}
|
|
523 |
|
|
524 |
// ---------------------------------------------------------
|
|
525 |
// CUniEditorProcessImageOperation::CreateEmptyAttachmentL
|
|
526 |
// ---------------------------------------------------------
|
|
527 |
//
|
|
528 |
void CUniEditorProcessImageOperation::CreateEmptyAttachmentL()
|
|
529 |
{
|
|
530 |
iNewAttaId = KMsvNullIndexEntryId;
|
|
531 |
|
|
532 |
// Get the file name from original full path name.
|
|
533 |
TParsePtrC parser( iImageInfo->FullFilePath() );
|
|
534 |
|
|
535 |
TFileName ext( parser.Ext() );
|
|
536 |
iTargetType = iImageInfo->MimeType();
|
|
537 |
|
|
538 |
if ( iTargetType.Des8().CompareF( KMsgMimeImagePng ) == 0 )
|
|
539 |
{
|
|
540 |
//png is non-conformant image type
|
|
541 |
//->convert to jpeg
|
|
542 |
iTargetType = TDataType( KMsgMimeImageJpeg );
|
|
543 |
ext.Zero();
|
|
544 |
ext.Copy( KUniExtImageJpeg_8 );
|
|
545 |
}
|
|
546 |
else if ( iTargetType.Des8().CompareF( KMsgMimeImageWbmp ) == 0 )
|
|
547 |
{
|
|
548 |
//no wbmp encoder
|
|
549 |
//->convert to gif if scaling is needed
|
|
550 |
iTargetType = TDataType( KMsgMimeImageGif );
|
|
551 |
ext.Zero();
|
|
552 |
ext.Copy( KUniExtImageGif_8 );
|
|
553 |
}
|
|
554 |
|
|
555 |
TFileName newFileName( parser.Name() );
|
|
556 |
newFileName.Append( ext );
|
|
557 |
|
|
558 |
iEditStore = iDocument.Mtm().Entry().EditStoreL();
|
|
559 |
MMsvAttachmentManagerSync& managerSync = iEditStore->AttachmentManagerExtensionsL();
|
|
560 |
CMsvAttachment* attachment = CMsvAttachment::NewL( CMsvAttachment::EMsvFile );
|
|
561 |
CleanupStack::PushL( attachment );
|
|
562 |
|
|
563 |
attachment->SetMimeTypeL( iTargetType.Des8() );
|
|
564 |
|
|
565 |
managerSync.CreateAttachmentL( newFileName, iNewImageFile, attachment );
|
|
566 |
CleanupStack::Pop( attachment ); // ownership transferred
|
|
567 |
|
|
568 |
iNewAttaId = attachment->Id();
|
|
569 |
}
|
|
570 |
|
|
571 |
// ---------------------------------------------------------
|
|
572 |
// CUniEditorProcessImageOperation::ImageSendSize
|
|
573 |
// ---------------------------------------------------------
|
|
574 |
//
|
|
575 |
TSize CUniEditorProcessImageOperation::ImageSendSize() const
|
|
576 |
{
|
|
577 |
TSize size;
|
|
578 |
if( TUniMsvEntry::IsMmsUpload( iDocument.Entry() ) )
|
|
579 |
{
|
|
580 |
size.iWidth = KUniMmsUploadImageWidth;
|
|
581 |
size.iHeight = KUniMmsUploadImageHeight;
|
|
582 |
}
|
|
583 |
else
|
|
584 |
{
|
|
585 |
size = iDocument.MaxImageSize();
|
|
586 |
}
|
|
587 |
return size;
|
|
588 |
}
|
|
589 |
|
|
590 |
// ---------------------------------------------------------
|
|
591 |
// CUniEditorProcessImageOperation::OpenFileForReadingL
|
|
592 |
// ---------------------------------------------------------
|
|
593 |
//
|
|
594 |
RFile CUniEditorProcessImageOperation::OpenFileForReadingL()
|
|
595 |
{
|
|
596 |
RFile sourceFile;
|
|
597 |
if ( iAttachmentId != KMsvNullIndexEntryId )
|
|
598 |
{
|
|
599 |
__ASSERT_DEBUG( iEditStore, Panic( EUniNullPointer ) );
|
|
600 |
sourceFile = iEditStore->AttachmentManagerL().GetAttachmentFileL( iAttachmentId );
|
|
601 |
}
|
|
602 |
else
|
|
603 |
{
|
|
604 |
TInt err = sourceFile.Open(
|
|
605 |
iFs, iImageInfo->FullFilePath(), EFileRead | EFileShareAny );
|
|
606 |
if ( err )
|
|
607 |
{
|
|
608 |
err = sourceFile.Open(
|
|
609 |
iFs, iImageInfo->FullFilePath(), EFileRead | EFileShareReadersOnly );
|
|
610 |
|
|
611 |
User::LeaveIfError( err );
|
|
612 |
}
|
|
613 |
}
|
|
614 |
return sourceFile;
|
|
615 |
}
|
|
616 |
|
|
617 |
// ---------------------------------------------------------
|
|
618 |
// CUniEditorProcessImageOperation::RunError
|
|
619 |
// ---------------------------------------------------------
|
|
620 |
//
|
|
621 |
TInt CUniEditorProcessImageOperation::RunError( TInt aError )
|
|
622 |
{
|
|
623 |
delete iImageProcessor;
|
|
624 |
iImageProcessor = NULL;
|
|
625 |
|
|
626 |
if ( aError == KErrNotFound )
|
|
627 |
{
|
|
628 |
aError = EUniProcessImgNotFound;
|
|
629 |
}
|
|
630 |
else if ( aError == KErrNoMemory )
|
|
631 |
{
|
|
632 |
aError = EUniProcessImgOutOfMemory;
|
|
633 |
}
|
|
634 |
else if ( aError == KErrDiskFull )
|
|
635 |
{
|
|
636 |
aError = EUniProcessImgOutOfDisk;
|
|
637 |
}
|
|
638 |
else if ( aError == KErrCorrupt )
|
|
639 |
{
|
|
640 |
aError = EUniProcessImgCorrupted;
|
|
641 |
}
|
|
642 |
|
|
643 |
return CUniEditorOperation::RunError( aError );
|
|
644 |
}
|
|
645 |
|
|
646 |
// ---------------------------------------------------------
|
|
647 |
// CUniEditorProcessImageOperation::DetachImageInfo
|
|
648 |
// ---------------------------------------------------------
|
|
649 |
//
|
|
650 |
CMsgImageInfo* CUniEditorProcessImageOperation::DetachImageInfo()
|
|
651 |
{
|
|
652 |
// ownership transferred
|
|
653 |
CMsgImageInfo* tempInfo = iNewImageInfo;
|
|
654 |
iNewImageInfo = NULL;
|
|
655 |
return tempInfo;
|
|
656 |
}
|
|
657 |
|
|
658 |
// ---------------------------------------------------------
|
|
659 |
// CUniEditorProcessImageOperation::SetOptimizedFlow
|
|
660 |
// ---------------------------------------------------------
|
|
661 |
//
|
|
662 |
void CUniEditorProcessImageOperation::SetOptimizedFlow(TBool aOptimizedFlow)
|
|
663 |
{
|
|
664 |
iOptimizedFlow = aOptimizedFlow;
|
|
665 |
}
|
|
666 |
// End of file
|