imagingandcamerafws/imagingfws/ImageTransform/src/ImageTransformMain.cpp
changeset 0 40261b775718
equal deleted inserted replaced
-1:000000000000 0:40261b775718
       
     1 // Copyright (c) 2008-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 
       
    17 #include "ImageTransformMain.h"
       
    18 //#include "ImageTransformPlugin.h"
       
    19 #include "ImageTransformFramework.h"
       
    20 
       
    21 // Literal for panics.
       
    22 _LIT(KIclPanicCategory, "ImageTransform");
       
    23 
       
    24 // Global panic fn.
       
    25 GLDEF_C void Panic(TImageTransformPanic aError)
       
    26 	{
       
    27 	User::Panic(KIclPanicCategory, aError);
       
    28 	}
       
    29 
       
    30 
       
    31 TImageParameterData::TImageParameterData()
       
    32 	{
       
    33 	Reset();
       
    34 	}
       
    35 
       
    36 void TImageParameterData::Reset()
       
    37 	{
       
    38 	iImageParameterDataFlag = ENull;
       
    39 	iFilename = NULL;
       
    40 	iData = NULL;
       
    41 	iDataPtr = NULL;
       
    42 	iMimeType = &KNullDesC8;
       
    43 	iImageType = KNullUid;
       
    44 	iImageSubType = KNullUid;
       
    45 	}
       
    46 
       
    47 void TImageParameterData::SetFilename(const TDesC& aFilename)
       
    48 	{
       
    49 	iImageParameterDataFlag = EFilename;
       
    50 	iFilename = &aFilename;
       
    51 	}
       
    52 
       
    53 void TImageParameterData::SetData(const TDesC8& aData)
       
    54 	{
       
    55 	iImageParameterDataFlag = EData;
       
    56 	iData = &aData;
       
    57 	}
       
    58 
       
    59 void TImageParameterData::SetDataPtr(HBufC8*& aDataPtr)
       
    60 	{
       
    61 	iImageParameterDataFlag = EDataPtr;
       
    62 	iDataPtr = &aDataPtr;
       
    63 	}
       
    64 
       
    65 void TImageParameterData::SetMimeType(const TDesC8& aMimeType)
       
    66 	{
       
    67 	iMimeType = &aMimeType;
       
    68 	}
       
    69 
       
    70 void TImageParameterData::SetImageType(TUid aImageType, TUid aImageSubType)
       
    71 	{
       
    72 	iImageType = aImageType;
       
    73 	iImageSubType = aImageSubType;
       
    74 	}
       
    75 
       
    76 /**
       
    77  *
       
    78  * Indicates whether the data source or destination desciptor contains a filename.
       
    79  *
       
    80  * @return	ETrue if the source or destination descriptor contains a filename, otherwise EFalse.
       
    81  * @panic   EUndefinedSourceType
       
    82  *          The source type has not been defined.
       
    83  */
       
    84 TBool TImageParameterData::IsFilename() const
       
    85 	{
       
    86 	if (iImageParameterDataFlag == ENull)
       
    87 		Panic(EUndefinedSourceType);
       
    88 	return iImageParameterDataFlag == EFilename;
       
    89 	}
       
    90 
       
    91 /**
       
    92  *
       
    93  * Indicates whether the data source desciptor contains data.
       
    94  *
       
    95  * @return	ETrue if the source or destination descriptor contains data, otherwise EFalse.
       
    96  * @panic   EUndefinedSourceType
       
    97  *          The source type has not been defined.
       
    98  */
       
    99 TBool TImageParameterData::IsData() const
       
   100 	{
       
   101 	if (iImageParameterDataFlag == ENull)
       
   102 		{
       
   103 		Panic(EUndefinedSourceType);
       
   104 		}
       
   105 	return ((iImageParameterDataFlag == EData) || (iImageParameterDataFlag == EDataPtr));
       
   106 	}
       
   107 
       
   108 /**
       
   109  *
       
   110  * Retrieves a pointer to the filename from the source descriptor.
       
   111  *
       
   112  * @return	A pointer to the filename source descriptor.
       
   113  * @panic   EUndefinedSourceType
       
   114  *          The source has not been defined as a file source.
       
   115  */
       
   116 const TDesC& TImageParameterData::Filename() const
       
   117 	{
       
   118 	if (iImageParameterDataFlag != EFilename)
       
   119 		Panic(EUndefinedSourceType);
       
   120 	return *iFilename;
       
   121 	}
       
   122 
       
   123 /**
       
   124  *
       
   125  * Retrieves a pointer to the data from the source descriptor.
       
   126  *
       
   127  * @return	A pointer to the data source descriptor.
       
   128  * @panic   EUndefinedSourceType
       
   129  *          The source has not been defined as a data source.
       
   130  */
       
   131 const TDesC8& TImageParameterData::Data() const
       
   132 	{
       
   133 	if (iImageParameterDataFlag != EData)
       
   134 		Panic(EUndefinedSourceType);
       
   135 	return *iData;
       
   136 	}
       
   137 
       
   138 HBufC8*& TImageParameterData::DataPtr() const
       
   139 	{
       
   140 	if (iImageParameterDataFlag != EDataPtr)
       
   141 		Panic(EUndefinedSourceType);
       
   142 	return *iDataPtr;
       
   143 	}
       
   144 
       
   145 const TDesC8& TImageParameterData::MimeType() const
       
   146 	{
       
   147 	return *iMimeType;
       
   148 	}
       
   149 
       
   150 const TUid TImageParameterData::ImageType() const
       
   151 	{
       
   152 	return iImageType;
       
   153 	}
       
   154 
       
   155 const TUid TImageParameterData::ImageSubType() const
       
   156 	{
       
   157 	return iImageSubType;
       
   158 	}
       
   159 
       
   160 TBool TImageParameterData::IsDataTypeDefined() const
       
   161 	{
       
   162 	return (iImageParameterDataFlag == ENull)?EFalse:ETrue;
       
   163 	}