imageeditor/EditorProvider/src/ImageRotaterProvider.cpp
changeset 1 edfc90759b9f
equal deleted inserted replaced
0:57d4cdd99204 1:edfc90759b9f
       
     1 /*
       
     2 * Copyright (c) 2010 Ixonos Plc.
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the "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 * Ixonos Plc
       
    14 *
       
    15 * Description:  
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDES
       
    22 #include <eikmenup.h>
       
    23 #include <eikenv.h>
       
    24 #include <eikproc.h>
       
    25 #include <bautils.h>
       
    26 #include <e32property.h>
       
    27 
       
    28 #include <ImageEditorProviderInternal.rsg>
       
    29 #include <aiwmenu.h>
       
    30 #include <ImplementationProxy.h>
       
    31 #include <aknutils.h>
       
    32 #include <ImageConversion.h>
       
    33 #include <AknOpenFileService.h>
       
    34 
       
    35 #include "ImageEditorProvider.hrh"
       
    36 #include "JpegRotatorHelper.h"
       
    37 #include "ImageRotaterProvider.h"
       
    38 #include "ImageEditorUids.hrh"
       
    39 #include "ImageEditorUtils.h"
       
    40 #include "commondefs.h"
       
    41 
       
    42 #include <AiwCommon.hrh>
       
    43 #include <AiwCommon.h>
       
    44 #include <eikstart.h>
       
    45 #include <PathInfo.h>
       
    46 #include <apgcli.h>
       
    47 
       
    48 
       
    49 #include <ErrorUI.h>
       
    50 
       
    51 // LOCAL CONSTANTS AND MACROS
       
    52 #ifdef DRM_SUPPORT
       
    53 #include <DRMCommon.h>
       
    54 #define DRM_FILE_ARG(x) x
       
    55 #else
       
    56 #define DRM_FILE_ARG(x)
       
    57 #endif
       
    58 
       
    59 #ifdef JPEG_ROTATOR_AIW_PROVIDER_SUPPORT
       
    60 #define JPEG_ROTATOR_AIW_PROVIDER_SUPPORT_ARG(x) x
       
    61 #else
       
    62 #define JPEG_ROTATOR_AIW_PROVIDER_SUPPORT_ARG(x)
       
    63 #endif
       
    64 
       
    65 #ifdef AIW_MULTIPLE_FILE_SUPPORT
       
    66 const TBool KMultipleFileSupport = ETrue;
       
    67 #else
       
    68 const TBool KMultipleFileSupport = EFalse;
       
    69 #endif
       
    70 
       
    71 // debug log
       
    72 #include "imageeditordebugutils.h"
       
    73 _LIT(KEditorServiceProviderLogFile,"EditorServiceProvider.log");
       
    74 
       
    75 // resource file
       
    76 _LIT (KResourceFile, "\\resource\\imageeditorproviderinternal.rsc");
       
    77 
       
    78 // application
       
    79 
       
    80 
       
    81 //=============================================================================
       
    82 CRotateProvider * CRotateProvider::NewL()
       
    83 {
       
    84     LOG(KEditorServiceProviderLogFile, "CRotateProvider::NewL");
       
    85 
       
    86 	return new (ELeave) CRotateProvider;
       
    87 }
       
    88 
       
    89 //=============================================================================
       
    90 CRotateProvider::CRotateProvider()
       
    91 : iResLoader(*CEikonEnv::Static()),
       
    92   iResLoaderOpen(EFalse),
       
    93   iFileServerConnected(EFalse)
       
    94 {
       
    95 
       
    96 }
       
    97 
       
    98 //=============================================================================
       
    99 CRotateProvider::~CRotateProvider()
       
   100 {
       
   101 	LOG(KEditorServiceProviderLogFile, "CRotateProvider::~CRotateProvider");
       
   102 
       
   103 	iCallback = NULL;
       
   104 
       
   105 	if (iInParamList)
       
   106 		{
       
   107 		iInParamList->Reset();
       
   108 		delete iInParamList;
       
   109 		}
       
   110 	if (iOutParamList)
       
   111 		{
       
   112 		iOutParamList->Reset();
       
   113 		delete iOutParamList;
       
   114 		}
       
   115 
       
   116 	iFileHandle.Close();
       
   117 
       
   118 #ifdef VERBOSE  	
       
   119     TInt count = iSharableFS.ResourceCount();   
       
   120     LOGFMT(KEditorServiceProviderLogFile, "Resource count: %d", count);
       
   121 	iSharableFS.ResourceCountMarkEnd();
       
   122 #endif
       
   123 
       
   124 	delete iInputFileList;
       
   125 	delete iTargetFileList;
       
   126 
       
   127 	delete iJpegRotatorHelper;	
       
   128 
       
   129     iSharableFS.Close();
       
   130     iResLoader.Close();
       
   131 }
       
   132 
       
   133 //=============================================================================
       
   134 void CRotateProvider::InitialiseL (
       
   135 	MAiwNotifyCallback &			/*aFrameworkCallback*/,
       
   136 	const RCriteriaArray &			/*aInterest*/
       
   137     )
       
   138 {
       
   139     LOG(KEditorServiceProviderLogFile, "CRotateProvider::InitialiseL");
       
   140 
       
   141     if (!iInParamList)
       
   142     {
       
   143         iInParamList = CAiwGenericParamList::NewL();    
       
   144     }
       
   145 
       
   146     if (!iOutParamList)
       
   147     {
       
   148         iOutParamList = CAiwGenericParamList::NewL();    
       
   149     }
       
   150     
       
   151     if (!iResLoaderOpen)
       
   152         {
       
   153         //	Load AIW edit provider internal resource file
       
   154         TFileName fileName;
       
   155         TParse p;    
       
   156 
       
   157         Dll::FileName(fileName);
       
   158         p.Set(KResourceFile, &fileName, NULL);
       
   159         iResourceFile = p.FullName();
       
   160         BaflUtils::NearestLanguageFile( CEikonEnv::Static()->FsSession(), iResourceFile );
       
   161 
       
   162         LOGFMT(KEditorServiceProviderLogFile, "\tLoading resource file: %S", &iResourceFile);
       
   163 
       
   164 		iResLoader.OpenL ( iResourceFile );
       
   165         iResLoaderOpen = ETrue;
       
   166 
       
   167         LOG(KEditorServiceProviderLogFile, "\tResources loaded succesfully");
       
   168         }
       
   169 
       
   170     // Connect to file server     
       
   171     if (!iFileServerConnected)
       
   172     {
       
   173         User::LeaveIfError(iSharableFS.Connect());    
       
   174         iFileServerConnected = ETrue;
       
   175 
       
   176 #ifdef VERBOSE        
       
   177         iSharableFS.ResourceCountMarkStart();
       
   178 #endif
       
   179 
       
   180         // Share file server sessions with other processes. Needed for Open File service.
       
   181         User::LeaveIfError(iSharableFS.ShareProtected());
       
   182     }   
       
   183     
       
   184     LOG(KEditorServiceProviderLogFile, "\tInitialized.");
       
   185 }
       
   186 
       
   187 //=============================================================================
       
   188 void CRotateProvider::InitializeMenuPaneL (
       
   189     CAiwMenuPane &                  aMenuPane,
       
   190     TInt                            aIndex,
       
   191     TInt                            /*aCascadeId*/,
       
   192     const CAiwGenericParamList &    aInParamList
       
   193     )
       
   194     {
       
   195 	LOG(KEditorServiceProviderLogFile, "CRotateProvider::InitializeMenuPaneL: In");
       
   196 
       
   197 	if (BaflUtils::FileExists(iSharableFS, iResourceFile))
       
   198 		{
       
   199 		// Check how many input files & examine the MIME types
       
   200 		CDesCArray* fileList = CheckInputFilesLC( aInParamList );
       
   201 		RArray<TDataType> mimeTypeList;
       
   202 		CleanupClosePushL(mimeTypeList);
       
   203 
       
   204 		if( fileList && fileList->Count())
       
   205 			{
       
   206 			// If we support multiple selection, all the files are opened here.
       
   207 			// This migh be very slow.
       
   208 			TInt inputFileCount = fileList->MdcaCount();
       
   209 
       
   210 			LOGFMT(KEditorServiceProviderLogFile, "CRotateProvider::InitializeMenuPaneL: inputFileCount: %d", inputFileCount);
       
   211 
       
   212 			// Get the MIME type(s) of the file(s)
       
   213 			RApaLsSession lsSession;
       
   214 			TInt err = lsSession.Connect();
       
   215 			CleanupClosePushL (lsSession);
       
   216 			for( TInt i = 0; i < inputFileCount; i++ )
       
   217 				{
       
   218 				TDataRecognitionResult dataType;
       
   219 				RFile file;
       
   220 				err = file.Open (iSharableFS, fileList->MdcaPoint(i), EFileShareReadersOnly);
       
   221 				if (KErrNone != err)
       
   222 					{
       
   223 					// second try...
       
   224 					err = file.Open (iSharableFS, fileList->MdcaPoint(i), EFileShareAny);
       
   225 					}
       
   226 				if (KErrNone == err)
       
   227 					{
       
   228 					CleanupClosePushL( file );
       
   229 					User::LeaveIfError( lsSession.RecognizeData(file, dataType) );
       
   230 					mimeTypeList.AppendL( dataType.iDataType );
       
   231 					CleanupStack::PopAndDestroy(); // file
       
   232 					}
       
   233 				else
       
   234 					{
       
   235 					mimeTypeList.AppendL( TDataType() );
       
   236 					}
       
   237 				}
       
   238 			CleanupStack::PopAndDestroy(); // lsSession
       
   239 
       
   240 			LOG(KEditorServiceProviderLogFile, "CRotateProvider::InitializeMenuPaneL: AIW parameter list content analyzed");
       
   241 			TBool displayJpegRotatorMenu = EFalse;
       
   242 			TInt count = fileList->MdcaCount();
       
   243 			if( (KMultipleFileSupport && count > 0) || count == 1 )
       
   244 				{
       
   245 				LOGFMT(KEditorServiceProviderLogFile, "CRotateProvider::InitializeMenuPaneL: count %d ", count);
       
   246 				for (TInt index = 0; index < count; ++index)
       
   247 					{
       
   248 					// Check if file is DRM protected
       
   249 					displayJpegRotatorMenu = !CheckDRMProtectionL( fileList->MdcaPoint(index) );
       
   250 					if (displayJpegRotatorMenu)
       
   251 						{
       
   252 						// Check that it is JPEG
       
   253 						displayJpegRotatorMenu = IsJpeg( mimeTypeList[0] );
       
   254 						}
       
   255 					if (!displayJpegRotatorMenu)
       
   256 						{
       
   257 						break;
       
   258 						}
       
   259 					}
       
   260 				}
       
   261 			// Show the menu if all selected files were of supported type
       
   262 			if (displayJpegRotatorMenu)
       
   263 				{
       
   264 			    	aMenuPane.AddMenuItemsL (iResourceFile,	R_JPEG_ROTATOR_MENU,KAiwCmdRotate,aIndex);
       
   265 				}
       
   266 			}
       
   267 		CleanupStack::PopAndDestroy(2); // fileList, mimeTypeList
       
   268 		}
       
   269 
       
   270 	LOG(KEditorServiceProviderLogFile, "CRotateProvider::InitializeMenuPaneL: Out");
       
   271 	}
       
   272 
       
   273 //=============================================================================
       
   274 void CRotateProvider::HandleServiceCmdL (
       
   275     const TInt &                    aCmdId,
       
   276     const CAiwGenericParamList &    aInParamList,
       
   277     CAiwGenericParamList &          aOutParamList,
       
   278     TUint                           aCmdOptions,
       
   279     const MAiwNotifyCallback *		aCallback
       
   280     )
       
   281 {
       
   282     LOGFMT(KEditorServiceProviderLogFile, "CRotateProvider::HandleServiceCmdL (%d)", aCmdId);
       
   283     HandleCmdsL(aCmdId, aInParamList, aOutParamList, aCmdOptions, aCallback);
       
   284 }
       
   285 
       
   286 //=============================================================================
       
   287 void CRotateProvider::HandleMenuCmdL (
       
   288     TInt                            aMenuCmdId,
       
   289     const CAiwGenericParamList &	aInParamList,
       
   290     CAiwGenericParamList &          aOutParamList,
       
   291     TUint                           aCmdOptions,
       
   292     const MAiwNotifyCallback *      aCallback
       
   293     )
       
   294 {
       
   295     LOGFMT(KEditorServiceProviderLogFile, "CRotateProvider::HandleMenuCmdL (%d)", aMenuCmdId);
       
   296 
       
   297     HandleCmdsL(aMenuCmdId, aInParamList, aOutParamList, aCmdOptions, aCallback);
       
   298 }
       
   299 
       
   300 //=============================================================================
       
   301 void CRotateProvider::HandleCmdsL (
       
   302     TInt                            aCmdId,
       
   303     const CAiwGenericParamList &	aInParamList,
       
   304     CAiwGenericParamList &          aOutParamList,
       
   305     TUint                           /*aCmdOptions*/,
       
   306     const MAiwNotifyCallback *      aCallback
       
   307     )
       
   308 {
       
   309 	switch (aCmdId)
       
   310 			{
       
   311 	 	  case EEditorProviderCmdIdRotateLeft:
       
   312 			case EEditorProviderCmdIdRotateRight:
       
   313 				{
       
   314 				delete iInputFileList;
       
   315 				iInputFileList = NULL;
       
   316 				iInputFileList = CheckInputFilesLC( aInParamList );
       
   317 				CleanupStack::Pop(iInputFileList);
       
   318 				CheckAiwCallBackL( aOutParamList, aCallback );
       
   319 
       
   320 				// Check that there is enough disk space and launch the rotator
       
   321 				if( iInputFileList )
       
   322 					{
       
   323              if( CheckDiskSpaceL(iSharableFS, iInputFileList) )
       
   324                 {
       
   325                    LaunchJpegRotatorL( iInputFileList, aCmdId );
       
   326                 }
       
   327                 else
       
   328                 {
       
   329                   LOG(KEditorServiceProviderLogFile, "CRotateProvider::HandleCmdsL: not enough disk space to start editing");
       
   330                   delete iInputFileList;
       
   331                   iInputFileList = NULL;
       
   332                   User::Leave (KErrDiskFull);
       
   333                 }
       
   334 					}
       
   335 
       
   336 				break; 
       
   337 				}
       
   338 			case EEditorProviderCmdIdScale:
       
   339 				{
       
   340 				User::Leave(KErrNotSupported);
       
   341 				break;
       
   342 				}
       
   343 			case EEditorProviderCmdIdNoiseReduction:
       
   344 				{
       
   345 				User::Leave(KErrNotSupported);
       
   346 				break;
       
   347 				}
       
   348 			case EEditorProviderCmdIdAutoFix:
       
   349 				{
       
   350 				User::Leave(KErrNotSupported);
       
   351 				break;
       
   352 				}
       
   353 				default:
       
   354 				{
       
   355 					break;
       
   356 				}
       
   357 		}
       
   358 }
       
   359 
       
   360 //=============================================================================
       
   361 void CRotateProvider::CheckAiwCallBackL ( 
       
   362     CAiwGenericParamList &          aOutParamList,
       
   363     const MAiwNotifyCallback *      aCallback
       
   364 	)
       
   365 {
       
   366     LOG(KEditorServiceProviderLogFile, "CRotateProvider::CheckAiwCallBackL: In");
       
   367 
       
   368     if (aCallback)
       
   369     {
       
   370         LOG(KEditorServiceProviderLogFile, "CRotateProvider::CheckAiwCallBackL: Callback used");
       
   371         iCallback = aCallback;
       
   372 		iOutParamList->Reset();
       
   373 		iOutParamList->AppendL(aOutParamList);
       
   374 		LOG(KEditorServiceProviderLogFile, "CRotateProvider::CheckAiwCallBackL: Using AIW call back");
       
   375 		iUseCallBack = ETrue;
       
   376 	}
       
   377 	else
       
   378 	{
       
   379 		iCallback = NULL;
       
   380 		iUseCallBack = EFalse;
       
   381 	}
       
   382     LOG(KEditorServiceProviderLogFile, "CRotateProvider::CheckAiwCallBackL: Out");
       
   383 }
       
   384 
       
   385 //=============================================================================
       
   386 CDesCArray* CRotateProvider::CheckInputFilesLC ( 
       
   387     const CAiwGenericParamList &    aInParamList
       
   388 	)
       
   389 {
       
   390 	LOG(KEditorServiceProviderLogFile, "CRotateProvider::CheckInputFilesLC: in");
       
   391 
       
   392 	iInParamList->Reset();
       
   393 	iInParamList->AppendL(aInParamList);
       
   394 
       
   395 	// Create array for input files.
       
   396 	CDesCArray* inputFileList = new (ELeave) CDesCArraySeg(4);
       
   397 	CleanupStack::PushL( inputFileList );
       
   398 
       
   399 	// Count number of files in param list and store the file names.
       
   400 	// Assuming that the files were already checked in
       
   401 	// InitializeMenuPaneL; no need to check them here.
       
   402 	TInt count = aInParamList.Count();
       
   403 	TInt index = 0;
       
   404 	TInt fileCount = 0;
       
   405 	for (index = 0; index < count; ++index)
       
   406 	{
       
   407 		const TAiwGenericParam& param = aInParamList[index];
       
   408 		if (param.SemanticId() == EGenericParamFile)
       
   409 		{
       
   410 #ifndef AIW_MULTIPLE_FILE_SUPPORT		
       
   411 			if (fileCount)
       
   412 			{
       
   413 				inputFileList->Reset();
       
   414 				break;	
       
   415 			}
       
   416 #endif				
       
   417 		
       
   418 			// Get file name
       
   419 			TPtrC fileName = param.Value().AsDes();
       
   420 			inputFileList->AppendL( fileName );
       
   421 			fileCount++;
       
   422 			LOGFMT(KEditorServiceProviderLogFile, "\tfile: %S", &fileName);
       
   423 		}
       
   424 	}
       
   425 
       
   426 	// Check that the files exist
       
   427 	TBool filesExist = ETrue;
       
   428 	for( TInt i = 0; i < inputFileList->MdcaCount(); i++ )
       
   429 		{
       
   430 		filesExist = BaflUtils::FileExists( iSharableFS, inputFileList->MdcaPoint(i) );
       
   431 		if( !filesExist )
       
   432 		{
       
   433 			inputFileList->Reset();
       
   434 			LOG(KEditorServiceProviderLogFile, "CRotateProvider::CheckInputFilesLC: file list deleted");
       
   435 			break;
       
   436 		}
       
   437 	}
       
   438 
       
   439 	LOG(KEditorServiceProviderLogFile, "CRotateProvider::CheckInputFilesLC: out");
       
   440 	return inputFileList;
       
   441 }
       
   442 
       
   443 
       
   444 //=============================================================================
       
   445 void CRotateProvider::LaunchJpegRotatorL ( 
       
   446 	const CDesCArray*   aInputFileList,
       
   447     TInt                aCmdId
       
   448 	)
       
   449 {
       
   450     LOGFMT(KEditorServiceProviderLogFile, "CRotateProvider::LaunchJpegRotatorL: number of files: %d", aInputFileList->MdcaCount());
       
   451     
       
   452     ASSERT( EEditorProviderCmdIdRotateLeft == aCmdId || EEditorProviderCmdIdRotateRight == aCmdId);
       
   453 
       
   454     // Notify that the rotating has been started
       
   455 	if (iCallback)
       
   456 	{
       
   457 	    LOG(KEditorServiceProviderLogFile, "CRotateProvider: Calling HandleNotifyL");
       
   458 	    ((MAiwNotifyCallback*)iCallback)->HandleNotifyL(KAiwCmdEdit, KAiwEventStarted, *iOutParamList, *iInParamList);
       
   459 	}
       
   460 
       
   461 	// Set the rotation mode
       
   462 	CJpegRotator::TRotationMode mode = CJpegRotator::ERotModeCounterClockwise;
       
   463 	if (EEditorProviderCmdIdRotateRight == aCmdId)
       
   464 	{
       
   465 		mode = CJpegRotator::ERotModeClockwise;
       
   466 	}
       
   467 
       
   468 	// Start the asyncronous rotate operation
       
   469     delete iTargetFileList;
       
   470     iTargetFileList = NULL;
       
   471     iTargetFileList = new (ELeave) CDesCArraySeg(4);
       
   472 	delete iJpegRotatorHelper;
       
   473 	iJpegRotatorHelper = NULL;
       
   474 	iJpegRotatorHelper = new (ELeave) CJpegRotatorHelper( iSharableFS, *this );
       
   475 
       
   476 	// Start rotate, replacing original file(s)	
       
   477 	TRAPD( err, iJpegRotatorHelper->StartRotateL( aInputFileList, iTargetFileList, mode, EFalse ) ); // replace original files
       
   478 	if (KErrNone != err)
       
   479 	{
       
   480 		iJpegRotatorHelper->Cancel();
       
   481 	}
       
   482 
       
   483 #ifdef VERBOSE        
       
   484     count = iSharableFS.ResourceCount();   
       
   485     LOGFMT(KEditorServiceProviderLogFile, "Resource count: %d", count);
       
   486 #endif
       
   487 
       
   488 }
       
   489 
       
   490 //=============================================================================
       
   491 TBool CRotateProvider::CheckDRMProtectionL(const TDesC& DRM_FILE_ARG(aFileName)) const
       
   492 {
       
   493     LOG(KEditorServiceProviderLogFile, "CRotateProvider::CheckDRMProtectionL: In");
       
   494 
       
   495     TBool isDRMProtected = EFalse;
       
   496 
       
   497 #ifdef DRM_SUPPORT
       
   498 
       
   499 	DRMCommon* drm = DRMCommon::NewL();
       
   500 	CleanupStack::PushL (drm);
       
   501 	drm->IsProtectedFile( aFileName, isDRMProtected );
       
   502 	CleanupStack::PopAndDestroy (drm);
       
   503 
       
   504 #endif
       
   505 
       
   506 	LOGFMT(KEditorServiceProviderLogFile, "CRotateProvider::CheckDRMProtectionL: Out (result: %d)", isDRMProtected);
       
   507 
       
   508     return isDRMProtected;
       
   509 }
       
   510 
       
   511 
       
   512 //=============================================================================
       
   513 TBool CRotateProvider::IsJpeg (const TDataType& aDataType) const
       
   514 {
       
   515 	_LIT(KMimeJpeg, "image/jpeg");
       
   516 
       
   517 	// CompareC return 0 if equal
       
   518 	return 0 == ( aDataType.Des().Left(10).CompareF( KMimeJpeg ) );
       
   519 }
       
   520 
       
   521 //=============================================================================
       
   522 TBool CRotateProvider::CheckDiskSpaceL(RFs& aFsSession, const TDesC& aFileName) const
       
   523 {
       
   524     LOG(KEditorServiceProviderLogFile, "CRotateProvider::CheckDiskSpaceL");
       
   525 
       
   526     TBool enoughFreeSpace = ETrue;
       
   527 
       
   528     TFileName targetDrive = PathInfo::MemoryCardRootPath();
       
   529 
       
   530     if (!ImageEditorUtils::ImageFitsToDriveL (aFsSession, aFileName, targetDrive))
       
   531     {
       
   532         targetDrive = PathInfo::PhoneMemoryRootPath();
       
   533 
       
   534         if (!ImageEditorUtils::ImageFitsToDriveL (aFsSession, aFileName, targetDrive))
       
   535         {
       
   536             enoughFreeSpace = EFalse;
       
   537         }
       
   538     }
       
   539 
       
   540     return enoughFreeSpace;
       
   541 }
       
   542 
       
   543 //=============================================================================
       
   544 TBool CRotateProvider::CheckDiskSpaceL(RFs& aFsSession, const CDesCArray* aFileList) const
       
   545 {
       
   546     LOG(KEditorServiceProviderLogFile, "CRotateProvider::CheckDiskSpaceL");
       
   547 
       
   548     // Check if the files fit onto the drive. Do this initial check assuming
       
   549     // that each rotated file is saved to the same drive than the original file
       
   550 	return ImageEditorUtils::ImagesFitToDriveL (aFsSession, *aFileList, *aFileList);
       
   551 }
       
   552 
       
   553 //=============================================================================
       
   554 void CRotateProvider::RotateOperationReadyL( TInt JPEG_ROTATOR_AIW_PROVIDER_SUPPORT_ARG(aError) )
       
   555 {
       
   556   LOGFMT(KEditorServiceProviderLogFile, "CRotateProvider::OperationReadyL: %d", aError);
       
   557 
       
   558 	if (iCallback)
       
   559 	{
       
   560 	    LOG(KEditorServiceProviderLogFile, "CRotateProvider: Calling MAiwNotifyCallback::HandleNotifyL");
       
   561 
       
   562 		iOutParamList->Reset();
       
   563 		if( KErrNone == aError )
       
   564 		{
       
   565 			// Pass the new file names to the AIW consumer.
       
   566 			// In error cases pass empty list.
       
   567 			for( TInt i = 0; i < iTargetFileList->MdcaCount(); i++ )
       
   568 			{
       
   569 				TAiwVariant variant( iTargetFileList->MdcaPoint(i) );
       
   570 				TAiwGenericParam param( EGenericParamFile, variant );
       
   571 				iOutParamList->AppendL( param );
       
   572 			}
       
   573 		    // Non-leaving function shall use TRAP
       
   574     	    TRAP_IGNORE ( 
       
   575     	        ((MAiwNotifyCallback*)iCallback)->HandleNotifyL(KAiwCmdRotate, KAiwEventCompleted, *iOutParamList, *iInParamList);    	    	    
       
   576     	    );
       
   577 
       
   578 		}
       
   579         else
       
   580         {
       
   581         
       
   582             // Show error            
       
   583             CErrorUI* errorUi = CErrorUI::NewLC(*CEikonEnv::Static());
       
   584             TBool errorShown = errorUi->ShowGlobalErrorNoteL(aError);
       
   585             if (errorShown == EFalse)
       
   586             {
       
   587                 User::Leave(aError);
       
   588             }
       
   589         
       
   590             CleanupStack::PopAndDestroy();
       
   591         
       
   592             TRAP_IGNORE (    
       
   593                 ((MAiwNotifyCallback*)iCallback)->HandleNotifyL(KAiwCmdRotate, KAiwEventError, *iOutParamList, *iInParamList);    
       
   594             );
       
   595         }
       
   596         	
       
   597         TRAP_IGNORE ( 	   
       
   598 	        ((MAiwNotifyCallback*)iCallback)->HandleNotifyL(KAiwCmdRotate, KAiwEventStopped, *iOutParamList, *iInParamList);    
       
   599 	    );
       
   600 	}
       
   601 	
       
   602 	delete iJpegRotatorHelper;
       
   603 	iJpegRotatorHelper = NULL;
       
   604 
       
   605 
       
   606 }
       
   607 
       
   608 
       
   609 
       
   610 // End of File