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