imaging/imagingplugins/codecs/JPEGCodec/Exif/ExifJpegTransform.cpp
changeset 0 5752a19fdefe
equal deleted inserted replaced
-1:000000000000 0:5752a19fdefe
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "ExifJpegTransform.h"
       
    17 #include "icl/ExifJpegTransformExtension.h"
       
    18 
       
    19 #include "exiftransformdataaccessorimpl.h"
       
    20 #include "ExifEditUtility.h"
       
    21 #include <icl/icl_uids.hrh>
       
    22 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    23 #include <icl/icl_uids_const.hrh>
       
    24 #include <icl/icl_uids_def.hrh>
       
    25 #endif
       
    26 
       
    27 
       
    28 
       
    29 CExifJpegTransform* CExifJpegTransform::NewL()
       
    30 	{
       
    31 	CExifJpegTransform* self = new (ELeave) CExifJpegTransform;
       
    32 	CleanupStack::PushL(self);
       
    33 	self->ConstructL();
       
    34 	CleanupStack::Pop(self);
       
    35 	
       
    36 	return self;
       
    37 	}
       
    38 
       
    39 CExifJpegTransform::~CExifJpegTransform()
       
    40 	{
       
    41 	delete iExtension;
       
    42 	delete iExifEdit;
       
    43 	
       
    44 	//Can not simply delete iDest/iSource since all we have are M-class pointers.
       
    45 	if (iDest)
       
    46 		{
       
    47 		iDest->Destroy();
       
    48 		iDest = NULL;
       
    49 		}
       
    50 
       
    51 	if (iSource)
       
    52 		{
       
    53 		iSource->Destroy();
       
    54 		iSource = NULL;
       
    55 		}
       
    56 				
       
    57 	iFs.Close();
       
    58 	}
       
    59 
       
    60 
       
    61 CExifJpegTransform::CExifJpegTransform()
       
    62 	{
       
    63 	
       
    64 	}
       
    65 	
       
    66 void CExifJpegTransform::ConstructL()
       
    67 	{
       
    68 	User::LeaveIfError(iFs.Connect());
       
    69 	}
       
    70 
       
    71 MExifMetadata* CExifJpegTransform::ExifMetadata() const
       
    72 	{
       
    73 	if(iExifEdit)
       
    74 		{
       
    75 		return iExifEdit->ExifMetadata();	
       
    76 		}
       
    77 	return NULL;
       
    78 	}
       
    79 
       
    80 
       
    81 void CExifJpegTransform::Transform(TRequestStatus& aStatus)
       
    82 	{
       
    83 	TBool encodeThumbnail=EFalse;
       
    84 	if((Options()&CImageTransform::EThumbnail)==CImageTransform::EThumbnail)
       
    85 		{
       
    86 		encodeThumbnail=ETrue;		
       
    87 		}
       
    88 	
       
    89 	TRAPD(err, iExifEdit->WriteDestL(encodeThumbnail, DestinationSizeInPixels(), PreserveImageData(), MaintainAspectRatio(), &aStatus));
       
    90 	if(err!=KErrNone)
       
    91 		{
       
    92 		aStatus=KRequestPending;
       
    93 		TRequestStatus* status=&aStatus;
       
    94 		User::RequestComplete(status, err);
       
    95 		}
       
    96 	}
       
    97 
       
    98 
       
    99 void CExifJpegTransform::OpenL()
       
   100 	{		
       
   101 	if (SourceIsFilename())
       
   102 		{
       
   103 		iSource = new (ELeave) CExifFileSource(SourceFilename(), iFs);
       
   104 		}
       
   105 	else if (SourceIsData())
       
   106 		{
       
   107 		iSource = new (ELeave) CExifDescSource(SourceData(), iFs);
       
   108 		}
       
   109 	else
       
   110 		{
       
   111 		User::Leave(KErrNotSupported);
       
   112 		}
       
   113 		
       
   114 	if (DestIsFilename())
       
   115 		{
       
   116 		iDest = new (ELeave) CExifFileDest(DestFilename(), iFs);
       
   117 		}
       
   118 	else if (DestIsData())
       
   119 		{
       
   120 		iDest = new (ELeave) CExifDescDest(DestData());
       
   121 		}
       
   122 	else
       
   123 		{
       
   124 		User::Leave(KErrNotSupported);
       
   125 		}
       
   126 	iExifEdit=CExifEditUtility::NewL(iSource, iDest, Options() & CImageTransform::EIgnoreExifMetadataProcessing);	
       
   127 	iExifEdit->ReadSourceL();
       
   128 	iExtension=(CImageTransformPluginExtension*)CJpegTransformExtension::NewL(this);	
       
   129 	}
       
   130 
       
   131 	
       
   132 void CExifJpegTransform::CancelTransform()
       
   133 	{
       
   134 	iExifEdit->Cancel();
       
   135 	}
       
   136 
       
   137 CImageTransformPluginExtension* CExifJpegTransform::Extension() const
       
   138 	{
       
   139 	return iExtension;
       
   140 	}