# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1264511885 -7200 # Node ID 2014ca87e772b5ac9e299503b72dcf86af5dd325 Revision: 201004 diff -r 000000000000 -r 2014ca87e772 group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/group/bld.inf Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include + +#include "../imagehandling_plat/group/bld.inf" + +#include "../imagehandlinglib/Group/bld.inf" +#include "../imagehandlingutilities/group/bld.inf" + +PRJ_EXPORTS + +// End of File + + diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/3gp_library_api/3gp_library_api.metaxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/3gp_library_api/3gp_library_api.metaxml Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,18 @@ + + + 3GP Library API + Interface to 3GP file composing and parsing library. + c++ + 3gplibrary + + + + + + + + + no + no + + diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/3gp_library_api/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/3gp_library_api/group/bld.inf Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: File that exports the files belonging to +: 3GP Library API +* +*/ + + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS + +../inc/mp4lib.h MW_LAYER_PLATFORM_EXPORT_PATH(mp4lib.h) +../inc/mp4config.h MW_LAYER_PLATFORM_EXPORT_PATH(mp4config.h) +../inc/3GPMP4Lib.iby CORE_MW_LAYER_IBY_EXPORT_PATH(3GPMP4Lib.iby) diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/3gp_library_api/inc/3GPMP4Lib.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/3gp_library_api/inc/3GPMP4Lib.iby Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Iby file for 3GPMP4Lib. +* +*/ + + +#ifndef __3GPMP4LIB_IBY__ +#define __3GPMP4LIB_IBY__ + +// 3GP/MP4 File Format Library + +// Utilizing constants from data_caging_paths_for_iby.hrh, included in higher level +file=ABI_DIR\BUILD_DIR\3GPMP4LIB.DLL SHARED_LIB_DIR\3GPMP4LIB.DLL + +//data=ZSYSTEM\install\3GPMP4LibStub.sis system\install\3GPMP4LibStub.sis + +#endif //__3GPMP4LIB_IBY__ diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/3gp_library_api/inc/mp4config.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/3gp_library_api/inc/mp4config.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,21 @@ +/* +* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: The operating system specific variables have been collected in this file +* +*/ + +// transition header for 3GPMP4Lib clients, new location: +#include <3gplibrary/mp4config.h> + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/3gp_library_api/inc/mp4lib.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/3gp_library_api/inc/mp4lib.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,21 @@ +/* +* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file is included by the library user. +* +*/ + +// transition header for 3GPMP4Lib clients, new location: +#include <3gplibrary/mp4lib.h> + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/group/bld.inf Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Includes all the Domain API specific bld.inf files, which +* export files. +* +*/ + + +#include "../image_handling_library_api/group/bld.inf" +#include "../3gp_library_api/group/bld.inf" +#include "../thumbnailmanager_api/group/bld.inf" + + +// End of File + + diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/image_handling_library_api/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/image_handling_library_api/group/bld.inf Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: File that exports the files belonging to +: Image Handling Library API +* +*/ + + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS + +../inc/IHLProcessorFactory.h MW_LAYER_PLATFORM_EXPORT_PATH(IHLProcessorFactory.h) +../inc/IHLBitmapUtil.h MW_LAYER_PLATFORM_EXPORT_PATH(IHLBitmapUtil.h) +../inc/MIHLBitmap.h MW_LAYER_PLATFORM_EXPORT_PATH(MIHLBitmap.h) +../inc/MIHLImage.h MW_LAYER_PLATFORM_EXPORT_PATH(MIHLImage.h) +../inc/MIHLProcessor.h MW_LAYER_PLATFORM_EXPORT_PATH(MIHLProcessor.h) +../inc/IHLViewerFactory.h MW_LAYER_PLATFORM_EXPORT_PATH(IHLViewerFactory.h) +../inc/MIHLScaler.h MW_LAYER_PLATFORM_EXPORT_PATH(MIHLScaler.h) +../inc/IHLImageFactory.h MW_LAYER_PLATFORM_EXPORT_PATH(IHLImageFactory.h) +../inc/MIHLBitmapProcessor.h MW_LAYER_PLATFORM_EXPORT_PATH(MIHLBitmapProcessor.h) +../inc/MIHLViewer.h MW_LAYER_PLATFORM_EXPORT_PATH(MIHLViewer.h) +../inc/MIHLViewerObserver.h MW_LAYER_PLATFORM_EXPORT_PATH(MIHLViewerObserver.h) +../inc/MIHLFileImage.h MW_LAYER_PLATFORM_EXPORT_PATH(MIHLFileImage.h) +../inc/TIHLInterfaceType.h MW_LAYER_PLATFORM_EXPORT_PATH(TIHLInterfaceType.h) +../inc/IHLInterfaceIds.h MW_LAYER_PLATFORM_EXPORT_PATH(IHLInterfaceIds.h) +../inc/MIHLImageViewer.h MW_LAYER_PLATFORM_EXPORT_PATH(MIHLImageViewer.h) diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/image_handling_library_api/image_handling_library_api.metaxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/image_handling_library_api/image_handling_library_api.metaxml Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,18 @@ + + + Image Handling Library API + An interface for viewing images + c++ + imagehandlinglib + + + + + + + + + no + no + + diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/image_handling_library_api/inc/IHLBitmapUtil.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/image_handling_library_api/inc/IHLBitmapUtil.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,157 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Static utility class for synchronous CFbsBitmap operations. +* +*/ + + +#ifndef IHLBITMAPUTIL_H +#define IHLBITMAPUTIL_H + +// INCLUDES +#include + +// FORWARD DECLARATION +class CFbsBitmap; + +// CLASS DECLARATION +/** +* IHLBitmapUtil +* +* Static utility class for synchronous CFbsBitmap operations. +* @lib IHL.lib +* @since 3.0 +*/ +class IHLBitmapUtil + { + public: + + /** + * Create new bitmap instance using + * same server handle as in given bitmap. + * Note that modifying bitmap content will also change + * all other bitmap content that has same server handle. + * @since 3.0 + * @param aBitmap Duplicated bitmap reference. + * @return Duplicated CFbsBitmap instance. + */ + IMPORT_C static CFbsBitmap* DuplicateBitmapL( const CFbsBitmap& aBitmap ); + + /** + * Create new bitmap instance using + * same server handle as in given bitmap. + * Note that modifying bitmap content will also change + * all other bitmap content that has same server handle. + * New instance is pushed into CleanupStack. + * @since 3.0 + * @param aBitmap Duplicated bitmap reference. + * @return Duplicated CFbsBitmap instance. + */ + IMPORT_C static CFbsBitmap* DuplicateBitmapLC( const CFbsBitmap& aBitmap ); + + /** + * Copy bitmap into new same sized bitmap. + * New bitmap has unique server handle and it can be + * modified without risk of changes in given source bitmap. + * @since 3.0 + * @param aBitmap Copied bitmap reference. + * @return Copied CFbsBitmap instance. + */ + IMPORT_C static CFbsBitmap* CopyBitmapL( const CFbsBitmap& aBitmap ); + + /** + * Copy bitmap into new same sized bitmap. + * New bitmap has unique server handle and it can be + * modified without risk of changes in given source bitmap. + * New instance is pushed into CleanupStack. + * @since 3.0 + * @param aBitmap Copied bitmap reference. + * @return Copied CFbsBitmap instance. + */ + IMPORT_C static CFbsBitmap* CopyBitmapLC( const CFbsBitmap& aBitmap ); + + /** + * Copy user defined area from source bitmap into new bitmap. + * New bitmap has unique server handle and it can be + * modified without risk of changes in given source bitmap. + * @since 3.0 + * @param aBitmap Source bitmap reference. + * @param aRect Copied rectangle from source bitmap. + * @return Copied CFbsBitmap instance, size of given rect. + */ + IMPORT_C static CFbsBitmap* CopyBitmapL( const CFbsBitmap& aBitmap, const TRect& aRect ); + + /** + * Copy user defined area from source bitmap into new bitmap. + * New bitmap has unique server handle and it can be + * modified without risk of changes in given source bitmap. + * New instance is pushed into CleanupStack. + * @since 3.0 + * @param aBitmap Source bitmap reference. + * @param aRect Copied rectangle from source bitmap. + * @return Copied CFbsBitmap instance, size of given rect. + */ + IMPORT_C static CFbsBitmap* CopyBitmapLC( const CFbsBitmap& aBitmap, const TRect& aRect ); + + /** + * Synchronous bitmap scaler. Use only with small bitmaps! + * Prefer asynchronous MIHLScaler instead. + * + * Scale source bitmap into destination bitmap. + * @since 3.0 + * @param aSrcBitmap Source bitmap reference. + * @param aDstBitmap Destination bitmap reference. + * If destination bitmap has null handle, + * processor will create new bitmap using size of + * destination rectangle. + * @param aOptions Reserved for future use. + * @return Return system wide error codes: + * KerrArgument - source bitmap is empty (handle is null). + * - destination bitmap displaymode differs + * from source bitmap displaymode. + */ + IMPORT_C static TInt ScaleBitmap( const CFbsBitmap& aSrcBitmap, CFbsBitmap& aDstBitmap, + TUint32 aOptions = 0 ); + + /** + * Synchronous bitmap scaler. Use only with small bitmaps! + * Prefer asynchronous MIHLScaler instead. + * + * Scale rectangle from source bitmap to a rectangle + * in destination bitmap. Scaled area can be also + * rotated and/or mirrored during process. + * See full usage description from MIHLScaler header. + * @since 3.0 + * @param aSrcBitmap Source bitmap reference. + * @param aSrcRect Rectangle that is processed from source bitmap. + * @param aDstBitmap Destination bitmap reference. + * If destination bitmap has null handle, + * processor will create new bitmap using size of + * destination rectangle. + * @param aDstRect Rectangle that is filled in destination bitmap. + * @param aOptions Reserved for future use. + * @return Return system wide error codes: + * KerrArgument - rectangles are outside of bitmap area. + * - source bitmap is empty (handle is null). + * - destination bitmap displaymode differs + * from source bitmap displaymode. + */ + IMPORT_C static TInt ScaleBitmap( const CFbsBitmap& aSrcBitmap, const TRect& aSrcRect, + CFbsBitmap& aDstBitmap, const TRect& aDstRect, + TUint32 aOptions = 0 ); + }; + +#endif // IHLBITMAPUTIL_H + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/image_handling_library_api/inc/IHLImageFactory.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/image_handling_library_api/inc/IHLImageFactory.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,176 @@ +/* +* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Static factory class for creating image instances. +* +*/ + + +#ifndef IHLIMAGEFACTORY_H +#define IHLIMAGEFACTORY_H + +// INCLUDES +#include + +// FORWARD DECLARATION +class RFs; +class RFile; +class MIHLFileImage; + +// CLASS DECLARATION +/** +* IHLImageFactory +* +* Static factory class for creating file instances. +* @lib IHL.lib +* @since 3.0 +*/ +class IHLImageFactory + { + public: + + /** + * Open file and create new image instance. + * Default filemode is EFileShareReadersOnly and if opening fails, EFileShareAny is used. + * Method leaves with appropriate error code if file could not be opened. + * If file is multi-image, new image contains handle to the first image. + * + * Note! Method may leave with KErrBadHandle if RFs::ShareProtected() method is not called! + * + * @since 3.0 + * @param aFs Fileserver reference. + * @param aFilename Full path of image file. + * @return New image instance. + */ + IMPORT_C static MIHLFileImage* OpenFileImageL( RFs& aFs, const TDesC& aFilename ); + + /** + * Open file and create new image instance. + * Default filemode is EFileShareReadersOnly and if opening fails, EFileShareAny is used. + * Method leaves with appropriate error code if + * file could not be opened or index is out of bounds. + * + * Note! Method may leave with KErrBadHandle if RFs::ShareProtected() method is not called! + * + * @since 3.0 + * @param aFs Fileserver reference. + * @param aFilename Full path of image file. + * @param aImageIndex Image index. This is used in multi-image + * file to determine which image is opened. + * @return New image instance. + */ + IMPORT_C static MIHLFileImage* OpenFileImageL( RFs& aFs, const TDesC& aFilename, + TInt aImageIndex ); + + /** + * Open file and create new image instance. + * Default filemode is EFileShareReadersOnly and if opening fails, EFileShareAny is used. + * Method leaves with appropriate error code if + * file could not be opened or index is out of bounds. + * + * Note! Method may leave with KErrBadHandle if RFs::ShareProtected() method is not called! + * + * @since 3.0 + * @param aFs Fileserver reference. + * @param aFilename Full path of image file. + * @param aImageIndex Image index. This is used in multi-image + * file to determine which image is opened. + * @param aOptions Special opening options. Refer to MIHLFileImage header. + * @return New image instance. + */ + IMPORT_C static MIHLFileImage* OpenFileImageL( RFs& aFs, const TDesC& aFilename, + TInt aImageIndex, const TUint32 aOptions ); + + /** + * Create new image instance. + * Method leaves with appropriate error code if file type is unknown. + * @since 3.0 + * @param aFile Open file handle. + * @return New image instance. + */ + IMPORT_C static MIHLFileImage* OpenFileImageL( RFile& aFile ); + + /** + * Create new image instance. + * Method leaves with appropriate error code if + * file type is unknown or index is out of bounds. + * @since 3.0 + * @param aFile Open file handle. + * @param aImageIndex Image index. This is used in multi-image + * file to determine which image is opened. + * @return New image instance. + */ + IMPORT_C static MIHLFileImage* OpenFileImageL( RFile& aFile, TInt aImageIndex ); + + /** + * Create new image instance. + * Method leaves with appropriate error code if + * file type is unknown or index is out of bounds. + * @since 3.0 + * @param aFile Open file handle. + * @param aImageIndex Image index. This is used in multi-image + * file to determine which image is opened. + * @param aOptions Special opening options. Refer to MIHLFileImage header. + * @return New image instance. + */ + IMPORT_C static MIHLFileImage* OpenFileImageL( RFile& aFile, TInt aImageIndex, + const TUint32 aOptions ); + + /** + * Create new image instance from buffered image data. + * Method leaves with appropriate error code if buffer data could not be used. + * If buffer contains multi-image, created image instance contains handle to + * the first image. + * @since 3.0 + * @param aFs Fileserver reference. + * @param aDataBuf Buffer reference. + * @return New image instance. + */ + IMPORT_C static MIHLFileImage* OpenBufferedFileImageL( RFs& aFs, const TDesC8& aDataBuf ); + + /** + * Create new image instance from buffered image data. + * Method leaves with appropriate error code if buffer data could not be used + * or image index is out of bounds. If buffer contains multi-image, created + * image instance contains handle to the first image. + * @since 3.0 + * @param aFs Fileserver reference. + * @param aDataBuf Buffer reference. + * @param aImageIndex Image index. This is used in multi-image + * file to determine which image is opened. + * @return New image instance. + */ + IMPORT_C static MIHLFileImage* OpenBufferedFileImageL( RFs& aFs, const TDesC8& aDataBuf, + TInt aImageIndex ); + + /** + * Create new image instance from buffered image data. + * Method leaves with appropriate error code if buffer data could not be used + * or image index is out of bounds. If buffer contains multi-image, created + * image instance contains handle to the first image. + * @since 3.0 + * @param aFs Fileserver reference. + * @param aDataBuf Buffer reference. + * @param aImageIndex Image index. This is used in multi-image + * file to determine which image is opened. + * @param aOptions Special opening options. Refer to MIHLFileImage header. + * @return New image instance. + */ + IMPORT_C static MIHLFileImage* OpenBufferedFileImageL( RFs& aFs, const TDesC8& aDataBuf, + TInt aImageIndex, const TUint32 aOptions ); + + }; + +#endif // IHLIMAGEFACTORY_H + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/image_handling_library_api/inc/IHLInterfaceIds.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/image_handling_library_api/inc/IHLInterfaceIds.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Interface id's used in IHL interfaces. +* +*/ + + +#ifndef IHLINTERFACEIDS_H +#define IHLINTERFACEIDS_H + +// INCLUDES +#include + +// ----------------------------------------------------------------------------- +// INTERFACE IDs +// ----------------------------------------------------------------------------- +// +// Images +const TInt KIHLInterfaceIdFileImage = 0x0100; + +// Processors +const TInt KIHLInterfaceIdBitmapProcessor = 0x0200; + +// Viewers +const TInt KIHLInterfaceIdImageViewer = 0x0300; + +// Filters (reserved) +// const TInt KIHLInterfaceIdFilter = 0x0400; // CSI: 13 # + +#endif // IHLINTERFACEIDS_H + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/image_handling_library_api/inc/IHLProcessorFactory.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/image_handling_library_api/inc/IHLProcessorFactory.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Static factory class for creating processors. +* +*/ + + +#ifndef IHLPROCESSORFACTORY_H +#define IHLPROCESSORFACTORY_H + +// INCLUDES +#include + +// FORWARD DECLARATION +class MIHLBitmapProcessor; + +// CLASS DECLARATION +/** +* IHLProcessorFactory +* +* Static factory class for creating processors. +* @lib IHL.lib +* @since 3.0 +*/ +class IHLProcessorFactory + { + public: + + /** + * Create new MIHLBitmapProcessor instance. + * @since 3.0 + * @param aOptions Special options for bitmap processing. Refer to MIHLBitmapProcessor header. + * @return New MIHLBitmapProcessor instance. + */ + IMPORT_C static MIHLBitmapProcessor* CreateBitmapProcessorL( const TUint32 aOptions = 0 ); + }; + +#endif // IHLPROCESSORFACTORY_H + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/image_handling_library_api/inc/IHLViewerFactory.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/image_handling_library_api/inc/IHLViewerFactory.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Static factory class for creating viewers. +* +*/ + + +#ifndef IHLVIEWERFACTORY_H +#define IHLVIEWERFACTORY_H + +// INCLUDES +#include + +// FORWARD DECLARATION +class MIHLImageViewer; +class MIHLViewerObserver; +class MIHLImage; +class MIHLBitmap; + +// CLASS DECLARATION +/** +* IHLViewerFactory +* +* Static factory class for creating viewers. +* @lib IHL.lib +* @since 3.0 +*/ +class IHLViewerFactory + { + public: + + /** + * Create new MIHLImageViewer instance. + * References to image, bitmap and observer must remain valid + * through viewer lifespan. Note that viewer start processing + * immediately after it's created. + * @since 3.0 + * @param aViewerSize Size of viewer. This is also maximum + * size of destination bitmap. + * @param aSource Source image reference. + * @param aDestination Destination bitmap reference. + * @param aObserver Viewer observer reference. + * @param aOptions Viewer options. Refer to MIHLImageViewer header. + * @return New MIHLImageViewer instance. + */ + IMPORT_C static MIHLImageViewer* CreateImageViewerL( const TSize& aViewerSize, + MIHLImage& aSource, + MIHLBitmap& aDestination, + MIHLViewerObserver& aObserver, + const TUint32 aOptions = 0 ); + }; + +#endif // IHLVIEWERFACTORY_H + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/image_handling_library_api/inc/MIHLBitmap.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/image_handling_library_api/inc/MIHLBitmap.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,196 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Pure virtual interface to bitmap and mask container. +* +*/ + + +#ifndef MIHLBITMAP_H +#define MIHLBITMAP_H + +// INCLUDES +#include + +// FORWARD DECLARATION +class MIHLBitmap; +class CBitmapContext; +class CFbsBitmap; + + +// FACTORY DECLARATION +class IHLBitmap + { + public: + + /** + * Create new MIHLBitmap instance. + * @since 3.0 + * @return New default MIHLBitmap instance. + */ + IMPORT_C static MIHLBitmap* CreateL(); + + }; + +// CLASS DECLARATION +/** +* MIHLBitmap +* +* Pure virtual interface to bitmap and mask container. +* +* If interface needs to be pushed into CleanupStack, +* remember to use CleanupStackDeletePushL() function! +* DO NOT USE CleanupStack::PushL()!! +* +* @lib IHL.lib +* @since 3.0 +*/ +class MIHLBitmap + { + public: + + /** + * Virtual destructor. + */ + virtual ~MIHLBitmap() {} + + public: + + /** + * Create new bitmap. + * @since 3.0 + * @param aSize Bitmap size. + * @param aDisplayMode Bitmap displaymode. + * @return KErrArgument if size is negative or displaymode is not supported. + * Otherwise system wide error codes. + */ + virtual TInt Create( const TSize& aSize, TDisplayMode aDisplayMode ) = 0; + + /** + * Create new bitmap and mask. + * @since 3.0 + * @param aSize Bitmap and mask size. + * @param aBitmapDisplayMode Bitmap displaymode. + * @param aMaskDisplayMode Mask displaymode (EGray2 or EGray256) + * @return KErrArgument if size is negative or displaymode is not supported. + * Otherwise system wide error codes. + */ + virtual TInt Create( const TSize& aSize, TDisplayMode aBitmapDisplayMode, + TDisplayMode aMaskDisplayMode ) = 0; + + /** + * Copy or duplicate bitmap. + * Copied bitmap has unique server handle and it can be + * modified without risk of changes in given source bitmap. + * Duplicated bitmap has same server handle than source bitmap + * and modifying duplicated bitmap will also modify source bitmap. + * @since 3.0 + * @param aBitmap Source bitmap that is copied or duplicated. + * @param aDuplicate ETrue to duplicate, EFalse to copy. + * @return System wide error codes. + */ + virtual TInt Copy( const CFbsBitmap& aBitmap, TBool aDuplicate ) = 0; + + /** + * Copy or duplicate bitmap and mask. + * Copied bitmaps has unique server handles and they can be + * modified without risk of changes in given source bitmaps. + * Duplicated bitmaps has same server handles than source bitmaps + * and modifying duplicated bitmaps will also modify source bitmaps. + * @since 3.0 + * @param aBitmap Source bitmap that is copied or duplicated. + * @param aBitmap Source aMask that is copied or duplicated. + * @param aDuplicate ETrue to duplicate, EFalse to copy. + * @return System wide error codes. + */ + virtual TInt Copy( const CFbsBitmap& aBitmap, const CFbsBitmap& aMask, TBool aDuplicate ) = 0; + + /** + * Copy or duplicate MIHLBitmap. + * Copied bitmaps has unique server handles and they can be + * modified without risk of changes in given source bitmaps. + * Duplicated bitmaps has same server handles than source bitmaps + * and modifying duplicated bitmaps will also modify source bitmaps. + * @since 3.0 + * @param aBitmap Source MIHLBitmap that is copied or duplicated. + * @param aDuplicate ETrue to duplicate, EFalse to copy. + * @return System wide error codes. + */ + virtual TInt Copy( const MIHLBitmap& aBitmap, TBool aDuplicate ) = 0; + + /** + * Release bitmap and mask server handles. + * Create() and Copy() methods will call this + * automatically if any old bitmaps exist. + * @since 3.0 + */ + virtual void Reset() = 0; + + /** + * Check if bitmap is created or copied. + * This checks that bitmap handle is valid and exist. + * @since 3.0 + * @return ETrue if bitmap exist, EFalse if bitmap handle is zero. + */ + virtual TBool IsCreated() const = 0; + + /** + * Return bitmap reference. + * Use MIHLBitmap::IsCreated() method + * to check if bitmap actually exist. + * @since 3.0 + * @return Reference to bitmap. + */ + virtual const CFbsBitmap& Bitmap() const = 0; + + /** + * Check if mask bitmap handle is valid and exist. + * @since 3.0 + * @return ETrue if mask exist, EFalse if mask handle is zero. + */ + virtual TBool HasMask() const = 0; + + /** + * Return mask reference. + * Use MIHLBitmap::HasMask() method + * to check if mask actually exist. + * @since 3.0 + * @return Reference to mask. + */ + virtual const CFbsBitmap& Mask() const = 0; + + /** + * Draw bitmap to bitmap context. + * If bitmaps are not created, method does nothing. + * @param aContext Bitmap context where bitmap is drawn. + * @param aPoint Draw position. + * @since 3.0 + */ + virtual void Draw( CBitmapContext& aContext, const TPoint& aPoint ) const = 0; + + /** + * Draw bitmap to bitmap context. + * If bitmaps are not created, method does nothing. + * @param aContext Bitmap context where bitmap is drawn. + * @param aPoint Draw position. + * @param aSourceRect Source rectangle that is drawn. + * @since 3.0 + */ + virtual void Draw( CBitmapContext& aContext, const TPoint& aPoint, + const TRect& aSourceRect ) const = 0; + + }; + +#endif // MIHLBITMAP_H + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/image_handling_library_api/inc/MIHLBitmapProcessor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/image_handling_library_api/inc/MIHLBitmapProcessor.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,115 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Pure virtual interface to scaling processor +* : using MIHLBitmaps. +* +*/ + + +#ifndef MIHLBITMAPPROCESSOR_H +#define MIHLBITMAPPROCESSOR_H + +// INCLUDES +#include + +// FORWARD DECLARATION +class MIHLBitmap; +class MIHFilter; + +// CLASS DECLARATION +/** +* MIHLBitmapProcessor +* +* Pure virtual interface to scaling processor using MIHLBitmaps. +* +* If interface needs to be pushed into CleanupStack, +* remember to use CleanupStackDeletePushL() function! +* DO NOT USE CleanupStack::PushL()!! +* +* @lib IHL.lib +* @since 3.0 +*/ +class MIHLBitmapProcessor : public MIHLProcessor + { + public: + + /** + * Virtual destructor. + */ + virtual ~MIHLBitmapProcessor() {} + + public: + + /** + * Flags to control scaler functionality. + * These can be combined using an OR operation. + * @since 3.0 + */ + enum TOptions + { + EOptionUseBilinearInterpolation = 0x01, + }; + + public: + + /** + * Process rectangle from source bitmap to a rectangle + * in destination bitmap. Scaled area can be also + * rotated and/or mirrored during process. + * See full description from MIHLScaler header. + * @since 3.0 + * @param aStatus Process request status reference. + * @param aSrcBitmap Source bitmap reference. + * @param aSrcRect Rectangle that is processed from source bitmap. + * @param aDstBitmap Destination bitmap reference. + * @param aDstRect Rectangle that is filled in destination bitmap. + * @return Return system wide error codes: + * KErrArgument - rectangles are outside of bitmap area. + * - source bitmap is empty (handle is null). + * - destination bitmap is empty (handle is null). + * - destination bitmap displaymode differs + * from source bitmap displaymode. + * KErrBusy - processor has request pending already. + */ + virtual TInt Process( TRequestStatus& aStatus, + const MIHLBitmap& aSrcBitmap, + const TRect& aSrcRect, + MIHLBitmap& aDstBitmap, + const TRect& aDstRect ) = 0; + + /** + * Check if processor has request pending. + * @since 3.0 + * @return ETrue if request is pending, EFalse if not. + */ + virtual TBool IsBusy() const = 0; + + /** + * Cancel pending request. + * If not active, method does nothing. + * @since 3.0 + */ + virtual void CancelProcess() = 0; + + /** + * Set filter. + * For future use, not used currently! + * @since 3.0 + */ + virtual void SetFilter( MIHFilter* aFilter ) = 0; + }; + +#endif // MIHLBITMAPPROCESSOR_H + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/image_handling_library_api/inc/MIHLFileImage.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/image_handling_library_api/inc/MIHLFileImage.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,238 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Pure virtual interface for file based image class. +* : This class acts as a window into single image or animation +* : in one physical file. Note that file will be locked as long +* : as instance of this class is present. +* +*/ + + +#ifndef MIHLFILEIMAGE_H +#define MIHLFILEIMAGE_H + +// INCLUDES +#include +#include + +// FORWARD DECLARATION +class MIHLBitmap; +class MIHLFilter; + +// CLASS DECLARATION +/** +* MIHLFileImage +* +* Pure virtual interface for file based image class. +* This class acts as a window into single image or animation +* in one physical file. Note that file will be locked as long +* as instance of this class is present. +* +* If interface needs to be pushed into CleanupStack, +* remember to use CleanupDeletePushL() function! +* DO NOT USE CleanupStack::PushL()!! +* +* @lib IHL.lib +* @since 3.0 +*/ +class MIHLFileImage : public MIHLImage + { + public: + + /** + * Virtual destructor. + */ + virtual ~MIHLFileImage() {} + + public: + + /** + * Flags to control file image functionality. + * These can be combined using an OR operation. + * @since 3.0 + */ + enum TOptions + { + EOptionNoDRMConsume = 0x01, + }; + + public: + + /** + * Return image type's unique identifier. + * @since 3.0 + * @return Image type Uid. + */ + virtual const TUid& ImageType() const = 0; + + /** + * Return image subtype's unique identifier. + * @since 3.0 + * @return Image subtype Uid. + */ + virtual const TUid& ImageSubType() const = 0; + + /** + * Return image index of this instance from source file. + * Note that animation is counted as an single image. + * @since 3.0 + * @return Index of this instance. + */ + virtual TInt ImageIndex() const = 0; + + /** + * Return count of images in source file. + * Note that animation is counted as an single image. + * @since 3.0 + * @return Count of images in source file. + */ + virtual TInt ImageCount() const = 0; + + + /** + * Return image size. + * @since 3.0 + * @return Image size in pixels. + */ + virtual TSize Size() const = 0; + + /** + * Return preferred display mode for image. + * Note that this display mode may differ from images original + * display mode. Image processing may + * need more colors than image has originally. + * @since 3.0 + * @return Preferred image display mode. + */ + virtual TDisplayMode DisplayMode() const = 0; + + /** + * Return display mode of mask bitmap. + * If image doesn't support transparency, ENone is returned. + * @since 3.0 + * @return ENone if image is not transparent. + * Mask display mode if image has transparency. + */ + virtual TDisplayMode MaskDisplayMode() const = 0; + + /** + * Return image background color. + * @since 3.0 + * @return Image background color. + */ + virtual TRgb BackgroundColor() const = 0; + + /** + * Return array of fixed load sizes which can + * be used in bitmap loading operation. + * Array contain only sizes that differs from image original size. + * If image can be loaded only to original size or it's fully + * scaleable, array is empty. + * Sizes starts from smallest and ends at largest. + * @since 3.0 + * @return Array of supported image load sizes. + */ + virtual const RArray& CustomLoadSizeArray() const = 0; + + /** + * Check if image can be loaded directly into any given load size. + * @since 3.0 + * @return Array of supported image load sizes. + */ + virtual TBool IsFullyScaleable() const = 0; + + /** + * Check if image is animated. + * @since 3.0 + * @return ETrue if image is animated, EFalse if not. + */ + virtual TBool IsAnimation() const = 0; + + /** + * Return animation frame count. + * If image is not animated, it has no animation frames either. + * @since 3.0 + * @return Animation frame count. + */ + virtual TInt AnimationFrameCount() const = 0; + + /** + * Return animation frame delay. + * If image is not animated, it has no animation frames either. + * @since 3.0 + * @param aAnimationFrameIndex Animation frame index. + * @return Animation frame delay. + */ + virtual TTimeIntervalMicroSeconds32 AnimationFrameDelay( TInt aAnimationFrameIndex ) const = 0; + + /** + * Load image into bitmap. + * If using scale support, given bitmap must be created with wanted size + * from CustomLoadSizeArray(). Displaymode can be get from Displaymode() method. + * Mask bitmap is always reseted. It's recreated if image is transparent by using + * size of given bitmap and displaymode from MaskDisplayMode() method. + * If image is animated, first animation frame is loaded. + * @since 3.0 + * @param aStatus Load request status reference. + * @param aDestination Destination bitmap reference. + * @param aFrameIndex for loading single frame from image + * @return Return system wide error codes: + * KerrArgument if given bitmap is not created or it's size is incorrect. + * KErrBusy image has load request pending already. + */ + virtual TInt Load( TRequestStatus& aStatus, MIHLBitmap& aDestination, TInt aFrameIndex = 0 ) = 0; + + /** + * Load animation frame into bitmap. + * If using scale support, given bitmap must be created with wanted size + * from CustomLoadSizeArray(). Displaymode can be get from Displaymode() method. + * Because some animations are build on top of previous frames, passing already loaded previous + * frame as a destination bitmap will increase load speed of next frames. + * Method will panic if given animation frame index is out of bounds. + * @since 3.0 + * @param aStatus Load request status reference. + * @param aDestination Destination bitmap reference. + * @param aAnimationFrameIndex Animation frame index. + * @return Return system wide error codes: + * KErrArgument if given bitmap is not created or it's size is incorrect. + * KErrBusy image has load request pending already. + */ + virtual TInt LoadAnimation( TRequestStatus& aStatus, MIHLBitmap& aDestination, + TInt aAnimationFrameIndex ) = 0; + + /** + * Check if image has load request pending. + * @since 3.0 + * @return ETrue if request is pending, EFalse if not. + */ + virtual TBool IsBusy() const = 0; + + /** + * Cancel pending load request. + * If not active, method does nothing. + * @since 3.0 + */ + virtual void CancelLoad() = 0; + + /** + * Set filter. + * For future use, not used currently! + * @since 3.0 + */ + virtual void SetFilter( MIHLFilter* aFilter ) = 0; + }; + +#endif // MIHLFILEIMAGE_H + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/image_handling_library_api/inc/MIHLImage.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/image_handling_library_api/inc/MIHLImage.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Pure virtual base class for all Image type interfaces. +* : Class contains method to identify underlaying interface and +* : implementation. +* +*/ + + +#ifndef MIHLIMAGE_H +#define MIHLIMAGE_H + +// INCLUDES +#include + +// CLASS DECLARATION +/** +* MIHLImage +* +* This is pure virtual base class for all Image type interfaces. +* Class contains method to identify underlaying interface and +* implementation. +* +* @lib IHL.lib +* @since 3.0 +*/ +class MIHLImage + { + public: + + /** + * Return identifier for underlaying interface + * and implementation. + * @since 3.0 + * @return Identifier for underlaying + * interface and implementation. + */ + virtual TIHLInterfaceType Type() const = 0; + + protected: + // Derived class cannot be destructed through this interface + ~MIHLImage() {} + }; + +#endif // MIHLIMAGE_H + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/image_handling_library_api/inc/MIHLImageViewer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/image_handling_library_api/inc/MIHLImageViewer.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,298 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Pure virtual interface for Image Viewer class. +* : Class can be used to view, process and play animation +* : from source image. +* +*/ + + +#ifndef MIHLIMAGEVIEWER_H +#define MIHLIMAGEVIEWER_H + +// INCLUDES +#include +#include + +// FORWARD DECLARATION +class MIHLFilter; + +// CLASS DECLARATION +/** +* MIHLImageViewer +* +* Pure virtual interface for Image Viewer class. +* Class can be used to view, process and play animation +* from source image. +* +* If interface needs to be pushed into CleanupStack, +* remember to use CleanupStackDeletePushL() function! +* DO NOT USE CleanupStack::PushL()!! +* +* @lib IHL.lib +* @since 3.0 +*/ +class MIHLImageViewer : public MIHLViewer + { + public: + + /** + * Virtual destructor. + */ + virtual ~MIHLImageViewer() {} + + public: + + /** + * Flags to control viewer functionality. + * These can be combined using an OR operation. + * @since 3.0 + */ + enum TOptions + { + EOptionIgnoreAspectRatio = 0x01, + EOptionUseBilinearInterpolation = 0x02 + }; + + /** + * Rotation angle of source image. + * @since 3.0 + */ + enum TRotationAngle + { + ERotationAngle0 = 0, + ERotationAngle90 = 90, + ERotationAngle180 = 180, + ERotationAngle270 = 270, + }; + + public: + + /** + * Check if source image is animated. + * @since 3.0 + * @return ETrue if source image is animated. EFalse if not. + */ + virtual TBool IsAnimation() const = 0; + + /** + * Start animation playback. + * If source image is not animated, method does nothing. + * @since 3.0 + */ + virtual void Play() = 0; + + /** + * Stop animation playback. + * If source image is not animated or animation is + * not played currently, method does nothing. + * @since 3.0 + */ + virtual void Stop() = 0; + + /** + * Check if animation playback is currently running. + * @since 3.0 + * @return ETrue if animation is running. EFalse if not. + */ + virtual TBool IsPlaying() const = 0; + + /** + * Count of frames in animated image. + * If not animated, return zero. + * @since 3.0 + * @return Frames count of animation. + */ + virtual TInt AnimationFrameCount() const = 0; + + /** + * Current animation frame in display. + * @since 3.0 + * @return Current animation frame index. + */ + virtual TInt AnimationFrame() const = 0; + + /** + * Change current animation frame. + * @since 3.0 + * @param aFrameIndex New animation frame. + * @return System wide error code. + */ + virtual TInt SetAnimationFrame( TInt aFrameIndex ) = 0; + + /** + * Change viewer size. + * This is also the maximum size of destination bitmap. + * @since 3.0 + * @param aViewerSize New viewer size. + * @return System wide error code. + */ + virtual TInt SetViewerSize( const TSize& aViewerSize, TInt srcBitmapScaleFactor = 1 ) = 0; + + /** + * Viewer size. + * This is also the maximum size of destination bitmap. + * @since 3.0 + * @return Viewer size. + */ + virtual TSize ViewerSize() const = 0; + + /** + * Move source clip rectangle. + * This is the area that is used from source image + * and processed to destination bitmap. + * Check valid move area with SourceRect() + * and SourceSize() methods. + * @since 3.0 + * @param aDx Movement in X-axis. + * @param aDy Movement in Y-axis. + * @return System wide error code. + */ + virtual TInt MoveSourceRect( TInt aDx, TInt aDy ) = 0; + + /** + * Set source clip rectangle position. + * This is the area that is used from source image + * and processed to destination bitmap. + * Check valid move area with SourceRect() + * and SourceSize() methods. + * @since 3.0 + * @param aPosition Topleft posion of rectangle. + * @return System wide error code. + */ + virtual TInt SetSourceRectPosition( const TPoint& aPosition ) = 0; + + /** + * This is the area that is used from source image + * and processed to destination bitmap. + * @since 3.0 + * @return Source clip rectangle. + */ + virtual TRect SourceRect() const = 0; + + /** + * Source image size. + * Note that this will change if image is rotated. + * @since 3.0 + * @return Source image size. + */ + virtual TSize SourceSize() const = 0; + + /** + * Set new zoom ratio. + * Zoom ratio is multiplier for scaling, + * 0,5 is 50%, 1.0 is 100%, 2,0 is 200% and so on. + * Value cannot be zero or negative. + * @since 3.0 + * @param aZoomRatio New zoom ratio. + * @return System wide error code. + */ + virtual TInt SetZoomRatio( TReal aZoomRatio ) = 0; + + /** + * Current zoom ratio. + * @since 3.0 + * @return Current zoom ratio. + */ + virtual TReal ZoomRatio() const = 0; + + /** + * Zoom to fit ratio. + * Using this zoom ratio, image will fit + * exactly to viewer. + * @since 3.0 + * @return Zoom to fit ratio. + */ + virtual TReal ZoomToFitRatio() const = 0; + + /** + * Rotate source image 90 degree clockwise. + * Source rect is also moved to remain in same position + * where it was according to source image data. + * @since 3.0 + * @return System wide error code. + */ + virtual TInt RotateClockwise() = 0; + + /** + * Rotate source image 90 degree counterclockwise. + * Source rect is also moved to remain in same position + * where it was according to source image data. + * @since 3.0 + * @return System wide error code. + */ + virtual TInt RotateCounterClockwise() = 0; + + /** + * Set rotation angle. Use values from TRotationAngle enumeration. + * Source rect is also moved to remain in same position + * where it was according to source image data. + * @since 3.0 + * @param aRotationAngle New rotation angle. + * @return System wide error code. + */ + virtual TInt SetRotationAngle( TInt aRotationAngle ) = 0; + + /** + * Current rotation angle. + * @since 3.0 + * @return Current rotation angle. + */ + virtual TInt RotationAngle() const = 0; + + /** + * Set vertical mirroring for source image. + * Source rect is also moved to remain in same position + * where it was according to source image data. + * @since 3.0 + * @param aValue Mirroring flag. + * @return System wide error code. + */ + virtual TInt SetVerticalMirroring( TBool aValue ) = 0; + + /** + * Check if source is vertically mirrored. + * @since 3.0 + * @return ETrue if mirrored, EFalse if not. + */ + virtual TBool VerticalMirroring() const = 0; + + /** + * Set horizontal mirroring for source image. + * Source rect is also moved to remain in same position + * where it was according to source image data. + * @since 3.0 + * @param aValue Mirroring flag. + * @return System wide error code. + */ + virtual TInt SetHorizontalMirroring( TBool aValue ) = 0; + + /** + * Check if source is horizontally mirrored. + * @since 3.0 + * @return ETrue if mirrored, EFalse if not. + */ + virtual TBool HorizontalMirroring() const = 0; + + /** + * Set filter. + * For future use, not used currently! + * @since 3.0 + */ + virtual void SetFilter( MIHLFilter* aFilter ) = 0; + }; + +#endif // MIHLIMAGEVIEWER_H + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/image_handling_library_api/inc/MIHLProcessor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/image_handling_library_api/inc/MIHLProcessor.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Pure virtual base class for all Processor type interfaces. +* : Class contains method to identify underlaying interface and +* : implementation. +* +*/ + + +#ifndef MIHLPROCESSOR_H +#define MIHLPROCESSOR_H + +// INCLUDES +#include + +// CLASS DECLARATION +/** +* MIHLProcessor +* +* This is pure virtual base class for all Processor type interfaces. +* Class contains method to identify underlaying interface and +* implementation. +* +* @lib IHL.lib +* @since 3.0 +*/ +class MIHLProcessor + { + public: + + /** + * Return identifier for underlaying interface + * and implementation. + * @since 3.0 + * @return Identifier for underlaying + * interface and implementation. + */ + virtual TIHLInterfaceType Type() const = 0; + + protected: + // Derived class cannot be destructed through this interface + ~MIHLProcessor() {} + }; + +#endif // MIHLPROCESSOR_H + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/image_handling_library_api/inc/MIHLScaler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/image_handling_library_api/inc/MIHLScaler.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,169 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Pure virtual interface to bitmap scaler +* : using Font and Bitmap Server bitmaps. +* +*/ + + +#ifndef MIHLSCALER_H +#define MIHLSCALER_H + +// INCLUDES +#include + +// FORWARD DECLARATION +class MIHLScaler; +class MIHFilter; +class CFbsBitmap; + +// FACTORY DECLARATION +class IHLScaler + { + public: + + /** + * Create new MIHLScaler instance. + * @since 3.0 + * @param aOptions Special options for bitmap scaling. Use MIHLScaler::TOptions values. + * @return New scaler instance. + */ + IMPORT_C static MIHLScaler* CreateL( const TUint32 aOptions = 0 ); + }; + +// CLASS DECLARATION +/** +* MIHLScaler +* +* Pure virtual interface to bitmap scaler +* using Font and Bitmap Server bitmaps. +* +* If interface needs to be pushed into CleanupStack, +* remember to use CleanupStackDeletePushL() function! +* DO NOT USE CleanupStack::PushL()!! +* +* @lib IHL.lib +* @since 3.0 +*/ +class MIHLScaler + { + public: + + /** + * Virtual destructor. + */ + virtual ~MIHLScaler() {} + + public: + + /** + * Flags to control scaler functionality. + * These can be combined using an OR operation. + * @since 3.0 + */ + enum TOptions + { + EOptionUseBilinearInterpolation = 0x01, + }; + + public: + + /** + * Scale rectangle from source bitmap to a rectangle + * in destination bitmap. Scaled area can be also + * rotated and/or mirrored during process. + * + * Rotating is done by defining SOURCE rectangle + * topleft and bottomright corners in following way: + * + * No rotate: tl----- 90 degree: -----tl + * | | | | + * | | | | + * -----br br----- + * + * 180 degree: br----- 270 degree: -----br + * | | | | + * | | | | + * -----tl tl----- + * + * Mirroring is done by defining DESTINATION rectangle + * topleft and bottomright corners in following way: + * + * No mirroring: tl----- + * | | + * | | + * -----br + * + * X-axis mirroring: -----tl + * | | + * | | + * br----- + * + * Y-axis mirroring: -----br + * | | + * | | + * tl----- + * + * X and Y-axis br----- + * mirroring: | | + * | | + * -----tl + * + * @since 3.0 + * @param aStatus Process request status reference. + * @param aSrcBitmap Source bitmap reference. + * @param aSrcRect Rectangle that is processed from source bitmap. + * @param aDstBitmap Destination bitmap reference. + * If destination bitmap has null handle, + * processor will create new bitmap using size of + * destination rectangle. + * @param aDstRect Rectangle that is filled in destination bitmap. + * @return Return system wide error codes: + * KerrArgument - rectangles are outside of bitmap area. + * - source bitmap is empty (handle is null). + * - destination bitmap displaymode differs + * from source bitmap displaymode. + * KErrBusy - processor has request pending already. + */ + virtual TInt Scale( TRequestStatus& aStatus, + const CFbsBitmap& aSrcBitmap, + const TRect& aSrcRect, + CFbsBitmap& aDstBitmap, + const TRect& aDstRect ) = 0; + + /** + * Check if processor has request pending. + * @since 3.0 + * @return ETrue if request is pending, EFalse if not. + */ + virtual TBool IsBusy() const = 0; + + /** + * Cancel pending request. + * If not active, method does nothing. + * @since 3.0 + */ + virtual void CancelProcess() = 0; + + /** + * Set filter. + * For future use, not used currently! + * @since 3.0 + */ + virtual void SetFilter( MIHFilter* aFilter ) = 0; + }; + +#endif // MIHLSCALER_H + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/image_handling_library_api/inc/MIHLViewer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/image_handling_library_api/inc/MIHLViewer.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Pure virtual base class for all Viewer type interfaces. +* : Class contains method to identify underlaying interface and +* : implementation. +* +*/ + + +#ifndef MIHLVIEWER_H +#define MIHLVIEWER_H + +// INCLUDES +#include + +// CLASS DECLARATION +/** +* MIHLViewer +* +* This is pure virtual base class for all Viewer type interfaces. +* Class contains method to identify underlaying interface and +* implementation. +* +* @lib IHL.lib +* @since 3.0 +*/ +class MIHLViewer + { + public: + + /** + * Return identifier for underlaying interface + * and implementation. + * @since 3.0 + * @return Identifier for underlaying + * interface and implementation. + */ + virtual TIHLInterfaceType Type() const = 0; + + protected: + // Derived class cannot be destructed through this interface + ~MIHLViewer() {} + }; + +#endif // MIHLVIEWER_H + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/image_handling_library_api/inc/MIHLViewerObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/image_handling_library_api/inc/MIHLViewerObserver.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Pure virtual base class for viewer observer. +* +*/ + + +#ifndef IHLVIEWEROBSERVER_H +#define IHLVIEWEROBSERVER_H + +// INCLUDES +#include + +// CLASS DECLARATION +/** +* MIHLViewerObserver +* +* Pure virtual base class for viewer observer. +* @lib IHL.lib +* @since 3.0 +*/ +class MIHLViewerObserver + { + public: + + /** + * This callback is currently not supported! + * + * Notifies client of viewer events. + * Event codes are defined in viewer header. + * Leave situation is handled in ViewerError() callback. + * @since 3.0 + * @param aEvent Type of event. + * @param aEventCode1 Event specific code 1. + * @param aEventCode2 Event specific code 2. + */ + virtual void ViewerEventL( TInt /*aEvent*/, TInt /*aEventCode1*/, TInt /*aEventCode2*/ ) {} + + /** + * Notifies client when viewer bitmap content is changed. + * Leave situation is handled in ViewerError() callback. + * @since 3.0 + */ + virtual void ViewerBitmapChangedL() = 0; + + /** + * Notifies client if error occurs in viewer. + * @since 3.0 + * @param aError System wide error code. + */ + virtual void ViewerError( TInt aError ) = 0; + + }; + +#endif // IHLIMAGEVIEWEROBSERVER_H + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/image_handling_library_api/inc/TIHLInterfaceType.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/image_handling_library_api/inc/TIHLInterfaceType.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This struct contain interface and +* : implementation ids for IHL classes. +* +*/ + + +#ifndef TIHLINTERFACETYPE_H +#define TIHLINTERFACETYPE_H + +// INCLUDES +#include + +// CLASS DECLARATION +/** +* TIHLInterfaceType +* +* This struct contain interface and +* implementation ids for IHL classes. +* +* Used id values are defined in IHLInterfaceIds.h header. +* +* @lib IHL.lib +* @since 3.0 +*/ +class TIHLInterfaceType + { + public: // Constructor and destructor + + inline TIHLInterfaceType( TInt aInterfaceId, TInt aImplementationId ); + virtual ~TIHLInterfaceType() {}; + + public: // Public data + + /** + * Class interface id. + * Used to identify interface type currently in use. + */ + TInt iInterfaceId; + + /** + * Class implementation id. + * Used to identify implementation class behind interface. + * For internal use. + */ + TInt iImplementationId; + + }; + +inline TIHLInterfaceType::TIHLInterfaceType( TInt aInterfaceId, TInt aImplementationId ) +:iInterfaceId( aInterfaceId ), iImplementationId( aImplementationId ) {} + +#endif // TIHLINTERFACETYPE_H + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/thumbnailmanager_api/group/bld.inf Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: File that exports the files belonging to +* : Thumbnailmanager API +* +*/ + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS + +#ifdef RD_THUMBNAILMANAGER + +../inc/thumbnaildata.h MW_LAYER_PLATFORM_EXPORT_PATH(thumbnaildata.h) +../inc/thumbnailmanager.h MW_LAYER_PLATFORM_EXPORT_PATH(thumbnailmanager.h) +../inc/thumbnailmanagerobserver.h MW_LAYER_PLATFORM_EXPORT_PATH(thumbnailmanagerobserver.h) +../inc/thumbnailobjectsource.h MW_LAYER_PLATFORM_EXPORT_PATH(thumbnailobjectsource.h) + +#endif // RD_THUMBNAILMANAGER + +// End of File + + diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/inc/thumbnaildata.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/thumbnailmanager_api/inc/thumbnaildata.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Thumbnail object + * +*/ + + +#ifndef THUMBNAILDATA_H +#define THUMBNAILDATA_H + +#include + +class CFbsBitmap; + +/** + * Thumbnail object. + * + * @since S60 S60 v5.0 + */ +NONSHARABLE_CLASS( MThumbnailData ) + { +public: + + /** + * Get a pointer to a CFbsBitmap containing the thumbnail image. Ownership + * of the object is not transferred (i.e. client must not delete the + * pointer). + * + * @since S60 v5.0 + * @return Pointer to a bitmap representing the thumbnail or NULL if + * thumbnail pointer is not available or it has been detached. + */ + virtual CFbsBitmap* Bitmap() = 0; + + /** + * Get a pointer to a CFbsBitmap containing the thumbnail image. Ownership + * of the object is transferred to the caller. Client must delete the + * bitmap after it is done processing it. + * + * @since S60 v5.0 + * @return Pointer to a bitmap representing the thumbnail or NULL if + * thumbnail pointer is not available or it has been detached. + * Caller assumes ownership of the bitmap. + */ + virtual CFbsBitmap* DetachBitmap() = 0; + + /** + * Get client data structure. + * + * @since S60 v5.0 + * @return A pointer for client data specified as a parameter for + * GetThumbnailL() or NULL if not specified. + */ + virtual TAny* ClientData() = 0; +}; + +#endif // THUMBNAILDATA_H diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/inc/thumbnailmanager.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/thumbnailmanager_api/inc/thumbnailmanager.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,554 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Main interface class to Thumbnail Manager + * +*/ + + +#ifndef THUMBNAILMANAGER_H +#define THUMBNAILMANAGER_H + +#include +#include +#include + +#include + +class MThumbnailManagerObserver; + +typedef TInt TThumbnailRequestId; + +typedef TUint32 TThumbnailId; +typedef enum +{ +EUnknownThumbnailSize, +ECustomThumbnailSize, +EImageGridThumbnailSize, +EImageListThumbnailSize, +EImageFullScreenThumbnailSize, +EVideoGridThumbnailSize, +EVideoListThumbnailSize, +EVideoFullScreenThumbnailSize, +EAudioGridThumbnailSize, +EAudioListThumbnailSize, +EAudioFullScreenThumbnailSize, +EGridThumbnailSize, +EListThumbnailSize, +EFullScreenThumbnailSize +} TThumbnailSize; +/** + * Thumbnail engine. + * + * This is the main interface class to thumbnail engine. Thumbnail engine + * can be used to request thumbnails for different kinds of media objects. + * + * The client using thumbnail engine must implement the + * MThumbnailManagerObserver. The observer interface is used to provide + * thumbnail data when it is available. + * + * Typical use of thumbnail engine consists of 4 parts: + * - creating an engine instance using NewL + * - setting thumbnail parameters using SetThumbnailSizeL(), SetFlags(), + * and so on + * - creating an object source (CThumbnailObjectSource) and using it to + * request thumbnails + * - handling MThumbnailManagerObserver callbacks when the thumbnail request + * is complete + * + * Here is an example of how thumbnail engine could be used by a typical + * application: + * + * @code + * + * #include + * #include + * + * class CMyThumbnailControl: public CCoeControl, + * public MThumbnailManagerObserver + * { + * public: + * CMyThumbnailControl(); + * ~CMyThumbnailControl(); + * ... + * + * // Callbacks from MThumbnailManagerObserver for getting thumbnails + * void ThumbnailPreviewReady( + * MThumbnailData& aThumbnail, + * TThumbnailRequestId aId ); + * void ThumbnailReady( + * TInt aError, + * MThumbnailData& aThumbnail, + * TThumbnailRequestId aId ); + * + * private: + * void ConstructL(); + * CThumbnailManager* iManager; + * CFbsBitmap* iBitmap; + * } + * + * _LIT( KTestFilePath, "e:\\TestImage.jpg" ); + * _LIT( KTestFileType, "image/jpeg" ); + * + * void CMyThumbnailControl::ConstructL() + * { + * // Create Thumbnail Manager instance. This object is the observer. + * iManager = CThumbnailManager::NewL( *this ); + * + * // Set flags: If the aspect ratio of the media object does not match + * // 4:3 then we would like it to be cropped. We don’t mind getting + * // smaller images than requested. + * iManager->SetFlagsL( CThumbnailManager::ECropToAspectRatio | + * CThumbnailManager::EAllowAnySize ); + * + * // Preferred size is 160x120 (or less) + * iManager->SetSizeL( TSize( 160, 120 ) ); + * + * // Get a preview thumbnail first, if available. + * // The preview thumbnail is delivered via a ThumbnailPreviewReady() + * // callback. + * iManager->SetQualityPreferenceL( + * CThumbnailManager::EOptimizeForQualityWithPreview ); + * + * // Create an object source representing a path to a file on local + * // file system. + * CThumbnailObjectSource* source = CThumbnailObjectSource::NewLC( + * KTestFilePath, // File path + * KTestFileType ); // Let Thumbnail Manager know it’s a JPEG, so + * // it doesn’t need to recognize the file format + * + * // Issue the request using default priority + * iManager->GetThumbnailL( *source ); + * + * // If GetThumbnailL() did not leave, the ThumbnailReady() callback is + * // now guaranteed to be called, unless the request is cancelled or + * // CThumbnailManager instance is deleted. + * + * // The source can be deleted immediately after issuing the request + * CleanupStack::PopAndDestroy( source ); + * } + * + * CMyThumbnailControl::~CMyThumbnailControl() + * { + * // Bitmap should be destroyed before Thumbnail Manager + * delete iBitmap; + * delete iManager; + * } + * + * void CMyThumbnailControl::ThumbnailReady( + * TInt aError, + * MThumbnailData& aThumbnail, + * TThumbnailRequestId aId ) + * { + * // This function must not leave. + * + * delete iBitmap; iBitmap = NULL; + * if ( !aError ) + * { + * // Claim ownership of the bitmap instance for later use + * iBitmap = aThumbnail.DetachBitmap(); + * + * // We can now use iBitmap in our Draw() method + * DrawDeferred(); + * } + * else + * { + * // An error occurred while getting the thumbnail. + * // Perhaps we should show a broken image icon to the user. + * } + * } + * + * @endcode + * + * @lib thumbnailmanager.lib + * @since S60 v5.0 + */ +NONSHARABLE_CLASS( CThumbnailManager ): public CBase + { +public: + /** + * Flags for thumbnail creation. + * These can be combined using bitwise or. + */ + enum TThumbnailFlags + { + /** + * Default flags. This means that: + * - Thumbnail must be as large as requested (unless the actual + * object is smaller). + * - Smaller thumbnails may be up scaled to desired resolution. + * - Aspect ratio is maintained and thumbnails are not cropped. The + * resulting thumbnail may smaller in either width or height if + * the aspect ratio of the object does not match the aspect ratio + * of the requested size. + */ + EDefaultFlags = 0, + + /** + * Allow thumbnails which are smaller than requested are. Thumbnail + * bitmaps are never up scaled if this flag is set. + */ + EAllowAnySize = 1, + + /** + * New thumbnail images are not created if this flag is set. Only + * existing thumbnails may be returned. If a requested thumbnail does + * not exist, KErrNotFound error is returned in ThumbnailReady() + * callback. + */ + EDoNotCreate = 2, + + /** + * Thumbnail images are cropped to match requested aspect ratio. If + * this flag is set, the size of the resulting thumbnail always + * matches the requested size. + */ + ECropToAspectRatio = 4 + }; + + /** Quality versus speed preference setting */ + enum TThumbnailQualityPreference + { + /** + * Prefer thumbnails in the highest quality possible disregarding + * any negative impact on performance. + */ + EOptimizeForQuality, + + /** + * Get thumbnails as fast as possible, even if + * it means lower quality. + */ + EOptimizeForPerformance, + + /** + * Get lower quality preview thumbnail as fast as possible first and + * then a higher quality thumbnail later. The preview thumbnail is + * provided in the ThumbnailPreviewReady() callback and the high + * quality thumbnail in ThumbnailReady(). ThumbnailPreviewReady() + * is not get called at all if a suitable existing thumbnail is not + * found or if a high quality version is already available. + */ + EOptimizeForQualityWithPreview + }; + + /** + * Two-phased constructor. + * + * @since S60 v5.0 + * @param aObserver Observer to receive notifications about completed + * operations. + * @return New CThumbnailManager instance. + */ + IMPORT_C static CThumbnailManager* NewL( MThumbnailManagerObserver& + aObserver ); + + /** + * Two-phased constructor. + * + * @since S60 v5.0 + * @param aObserver Observer to receive notifications about completed + * operations. + * @return New CThumbnailManager instance (on cleanup stack). + */ + IMPORT_C static CThumbnailManager* NewLC( MThumbnailManagerObserver& + aObserver ); + + /** + * Destructor + * + * @since S60 v5.0 + */ + virtual ~CThumbnailManager(); + + /** + * Get the current display mode for thumbnail bitmaps. + * + * @since S60 v5.0 + * @return Current display mode for the thumbnail bitmaps. + */ + virtual TDisplayMode DisplayMode()const = 0; + + /** + * Set the current display mode for thumbnail bitmaps. + * + * @since S60 v5.0 + * @param aDisplayMode New display mode value for the thumbnail bitmaps. + */ + virtual void SetDisplayModeL( TDisplayMode aDisplayMode ) = 0; + + /** + * Get the current quality versus performance preference. + * + * @since S60 v5.0 + * @return Current quality versus performance preference. + */ + virtual TThumbnailQualityPreference QualityPreference()const = 0; + + /** + * Set quality versus performance preference. + * + * @since S60 v5.0 + * @param aQualityPreference New quality versus performance preference + * value. + */ + virtual void SetQualityPreferenceL( TThumbnailQualityPreference + aQualityPreference ) = 0; + + /** + * Get the current desired size for thumbnail bitmaps. + * + * @since S60 v5.0 + * @return Current desired size for thumbnail bitmaps (in pixels). + */ + virtual const TSize& ThumbnailSize()const = 0; + + /** + * Set desired size for thumbnail bitmaps. + * + * @since S60 v5.0 + * @param aThumbnailSize New quality for the desired thumbnail size. + */ + virtual void SetThumbnailSizeL( const TSize& aThumbnailSize ) = 0; + + + /** + * Get current flags for thumbnail generation. + * + * @since S60 v5.0 + * @return Current flags. + */ + virtual TThumbnailFlags Flags()const = 0; + + /** + * Set flags for thumbnail generation. Several flags may be enabled + * by combining the values using bitwise or. + * + * @since S60 v5.0 + * @param aFlags New flags. + */ + virtual void SetFlagsL( TThumbnailFlags aFlags ) = 0; + + /** + * Get a thumbnail for an object file. If a thumbnail already exists, it + * is loaded and if a thumbnail does not exist, it is created + * transparently. ThumbnailReady() callback will be called when the + * operation is complete. In addition, ThumbnailPreviewReady() + * callback may be called if EOptimizeForQualityWithPreview mode was + * defined. + * + * Current values for display mode, thumbnail size, flags and performance + * preference are used. + * + * @since S60 v5.0 + * @param aObjectSource Source object or file + * @param aClientData Pointer to arbitrary client data. + * This pointer is not used by the API for + * anything other than returning it in the + * ThumbnailReady callback. + * @param aPriority Priority for this operation + * @return Thumbnail request ID. This can be used to + * cancel the request or change priority. + * The ID is specific to this CThumbnailManager + * instance and may not be shared with other + * instances. + */ + virtual TThumbnailRequestId GetThumbnailL( CThumbnailObjectSource& + aObjectSource, TAny* aClientData = NULL, TInt aPriority = CActive + ::EPriorityStandard ) = 0; + + /** + * Delete all thumbnails for a given object. This is an asynchronous + * operation, which always returns immediately. + * + * @since S60 v5.0 + * @param aObjectSource Source object or file + */ + virtual void DeleteThumbnails( CThumbnailObjectSource& aObjectSource ) = 0; + + /** + * Create thumbnail for a given object. This is an asynchronous + * operation, which always returns immediately. No callbacks are + * emitted. + * + * @since S60 v5.0 + * @param aObjectSource Source object or file + * @param aPriority Priority for this operation + * @return Thumbnail request ID. This can be used to + * cancel the request or change priority. + * The ID is specific to this CThumbnailManager + * instance and may not be shared with other + * instances. + */ + virtual TThumbnailRequestId CreateThumbnails( CThumbnailObjectSource& + aObjectSource, TInt aPriority = CActive::EPriorityIdle ) = 0; + + /** + * Cancel a thumbnail operation. + * + * @since S60 v5.0 + * @param aId Request ID for the operation to be cancelled. + * @return Symbian OS error code or KErrNone if cancelling was + * successful. + */ + virtual TInt CancelRequest( TThumbnailRequestId aId ) = 0; + + /** + * Change the priority of a queued thumbnail operation. + * + * @since S60 v5.0 + * @param aId Request ID for the request which to assign a new + * priority. + * @param aNewPriority New priority value + * @return Symbian OS error code or KErrNone if change was + * successful. + */ + virtual TInt ChangePriority( TThumbnailRequestId aId, TInt aNewPriority ) = + 0; + + /** + * Get a list of supported file formats for object files. + * + * The return value is a reference to a list that contains each + * supported MIME type. There may also be wildcards, such as "image/*". + * + * The returned reference is valid until CThumbnailManager is + * destroyed or GetSupportedMimeTypesL() is called again. + * + * @since S60 v5.0 + * @return A list of supported MIME types. May contain wildcards. + * Ownership not transferred. + */ + virtual const CDesCArray& GetSupportedMimeTypesL() = 0; + + /** + * Delete thumbnails by TThumbnailId. This is an asynchronous + * operation, which always returns immediately. + * + * @since S60 v5.0 + * @param aItemId TThumbnailId + */ + virtual void DeleteThumbnails( const TThumbnailId aItemId ) = 0; + +/** + * Set desired size for thumbnail bitmaps. + * + * @since S60 v5.0 + * @param aThumbnailSize Desired thumbnail size. + */ + virtual void SetThumbnailSizeL( const TThumbnailSize aThumbnailSize ) = 0; + + /** + * Get a persistent thumbnail for an object file. If a thumbnail already + * exists, it is loaded and if a thumbnail does not exist, it is created + * transparently. ThumbnailReady() callback will be called when the + * operation is complete. In addition, ThumbnailPreviewReady() + * callback may be called if EOptimizeForQualityWithPreview mode was + * defined. + * + * Current values for display mode, thumbnail size, flags and performance + * preference are used. + * + * @since S60 v5.0 + * @param aThumbnailId Thumbnail ID + * @param aThumbnailSizeType Thumbnail size enumeration + * @param aClientData Pointer to arbitrary client data. + * This pointer is not used by the API for + * anything other than returning it in the + * ThumbnailReady callback. + * @param aPriority Priority for this operation + * @return Thumbnail request ID. This can be used to + * cancel the request or change priority. + * The ID is specific to this CThumbnailManager + * instance and may not be shared with other + * instances. + */ + virtual TThumbnailRequestId GetThumbnailL( const TThumbnailId aThumbnailId, + TAny* aClientData = NULL, + TInt aPriority = CActive::EPriorityStandard ) = 0; + + + /** + * Set a thumbnail for an object file generated from buffer delivered in source + * object. ThumbnailReady() callback will be called when the + * operation is complete. In addition, ThumbnailPreviewReady() + * callback may be called if EOptimizeForQualityWithPreview mode was + * defined. + * + * Current values for display mode, thumbnail size, flags and performance + * preference are used. + * + * @since S60 v5.0 + * @param aThumbnailId Thumbnail ID + * @param aThumbnailSizeType Thumbnail size enumeration + * @param aClientData Pointer to arbitrary client data. + * This pointer is not used by the API for + * anything other than returning it in the + * ThumbnailReady callback. + * @param aPriority Priority for this operation + * @return Thumbnail request ID. This can be used to + * cancel the request or change priority. + * The ID is specific to this CThumbnailManager + * instance and may not be shared with other + * instances. + */ + virtual TThumbnailRequestId SetThumbnailL( CThumbnailObjectSource& aObjectSource, + TAny* = NULL, + TInt aPriority = CActive::EPriorityIdle ) = 0; + + + /** + * Import an image to be used as thumbnail for an object. If a + * thumbnail already exists, it is loaded and if a thumbnail does not + * exist, it is created transparently. ThumbnailReady() callback will be + * called when the operation is complete. In addition, ThumbnailPreviewReady() + * callback may be called if EOptimizeForQualityWithPreview mode was + * defined. + * + * Current values for display mode, thumbnail size, flags and performance + * preference are used. + * + * @since S60 v5.0 + * @param aObjectSource Source object or file + * @param aTargetUri Target URI to which the imported thumbnail is linked. + * @param aClientData Pointer to arbitrary client data. + * This pointer is not used by the API for + * anything other than returning it in the + * ThumbnailReady callback. + * @param aPriority Priority for this operation + * @return Thumbnail request ID. This can be used to + * cancel the request or change priority. + * The ID is specific to this CThumbnailManager + * instance and may not be shared with other + * instances. + */ + virtual TThumbnailRequestId ImportThumbnailL( CThumbnailObjectSource& aObjectSource, + const TDesC& aTargetUri, TAny* aClientData = NULL, + TInt aPriority = CActive::EPriorityIdle ) = 0; + + /** + * Update Thumbnails by TThumbnailId. This is an asynchronous + * operation, which always returns immediately. + * + * @since S60 v5.0 + * @param aItemId TThumbnailId + * @param aPath (New) path for the Thumbnail + * @param aOrientation Thumbnail orientation + * @param aModified Last modified + */ + virtual void UpdateThumbnailsL( const TThumbnailId aItemId, const TDesC& aPath, + const TInt aOrientation, const TInt64 aModified, const TInt aPriority ) = 0; + +}; + +#endif // THUMBNAILMANAGER_H diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/inc/thumbnailmanagerobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/thumbnailmanager_api/inc/thumbnailmanagerobserver.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,104 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Thumbnail Manager observer. + * +*/ + + +#ifndef THUMBNAILMANAGEROBSERVER_H +#define THUMBNAILMANAGEROBSERVER_H + +#include "thumbnailobjectsource.h" + +class MThumbnailData; + +/** + * Thumbnail observer. + * + * Callback interface for getting information about completed thumbnail + * operations. This should be implemented by the client using the API. + * + * Example of how the client may implement the ThumbnailReady() + * method: + * @code + * void CMyThumbnailControl::ThumbnailReady( + * TInt aError, + * MThumbnailData& aThumbnail, + * TThumbnailRequestId aId ) + * { + * // This function must not leave. + * delete iBitmap; + * iBitmap = NULL; + * + * if ( !aError ) + * { + * // Claim ownership of the bitmap instance for later use + * iBitmap = aThumbnail.DetachBitmap(); + * // We can now use iBitmap in our Draw() method + * DrawDeferred(); + * } + * else + * { + * // An error occurred while getting the thumbnail. + * // Perhaps we should show a broken image icon to the user. + * } + * } + * @endcode + * @since S60 v5.0 + */ +class MThumbnailManagerObserver + { +public: + + /** + * Preview thumbnail generation or loading is complete. + * + * This callback is not called unless EOptimizeForQualityWithPreview flag + * was specified. + * + * This callback is not called if any of the following is true: + * - an error occurred while processing the preview thumbnail + * - a suitable existing thumbnail was not found + * - a high quality thumbnail is already available + * + * The MThumbnailData instance is only valid for the duration of + * this call. It may not be stored for later use. If the client should + * want to use the bitmap data later, it can claim ownership of the + * CFbsBitmap object by calling DetachBitmap(). + * + * @since S60 v5.0 + * @param aThumbnail An object representing the resulting thumbnail. + * @param aId Request ID for the operation + */ + virtual void ThumbnailPreviewReady( MThumbnailData& aThumbnail, + TThumbnailRequestId aId ) = 0; + + /** + * Final thumbnail bitmap generation or loading is complete. + * + * The MThumbnailData instance is only valid for the duration of + * this call. It may not be stored for later use. If the client should + * want to use the bitmap data later, it can claim ownership of the + * CFbsBitmap object by calling DetachBitmap(). + * + * @since S60 v5.0 + * @param aError Error code. + * @param aThumbnail An object representing the resulting thumbnail. + * @param aId Request ID for the operation. + */ + virtual void ThumbnailReady( TInt aError, MThumbnailData& aThumbnail, + TThumbnailRequestId aId ) = 0; +}; + +#endif // THUMBNAILMANAGEROBSERVER_H diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/inc/thumbnailobjectsource.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/thumbnailmanager_api/inc/thumbnailobjectsource.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,322 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class for encapsulating the data source for objects. + * +*/ + + +#ifndef THUMBNAILOBJECTSOURCE_H +#define THUMBNAILOBJECTSOURCE_H + +#include +#include + +typedef TUint32 TThumbnailId; + +class CFbsBitmap; + +/** + * Object source for thumbnails. + * + * Class for encapsulating the data source for objects. + * + * @since S60 v5.0 + */ +NONSHARABLE_CLASS( CThumbnailObjectSource ): public CBase + { +public: + /** + * Construct a new CThumbnailObjectSource referring to an URI. + * @param aUri Object URI or a full path to a file in the file system. + * @param aMimeType MIME type. Optional, but should be specified if known. + * @since S60 v5.0 + * @return New CThumbnailObjectSource instance. + */ + IMPORT_C static CThumbnailObjectSource* NewL( const TDesC& aUri, const + TDesC& aMimeType = KNullDesC ); + + /** + * Construct a new CThumbnailObjectSource referring to an URI. + * @param aUri Object URI or a full path to a file in the file system. + * @param aMimeType MIME type. Optional, but should be specified if known. + * @since S60 v5.0 + * @return New CThumbnailObjectSource instance. + */ + IMPORT_C static CThumbnailObjectSource* NewLC( const TDesC& aUri, const + TDesC& aMimeType = KNullDesC ); + + /** + * Construct a new CThumbnailObjectSource referring to a file handle. + * The file handle must refer to an open file and it must remain + * valid until this object source is deleted. + * + * @param aFile File handle. + * @param aMimeType MIME type. Optional, but should be specified if known. + * @since S60 v5.0 + * @return New CThumbnailObjectSource instance. + */ + IMPORT_C static CThumbnailObjectSource* NewL( const RFile64& aFile, const + TDesC& aMimeType = KNullDesC ); + + /** + * Construct a new CThumbnailObjectSource referring to a file handle. + * The file handle must refer to an open file and it must remain + * valid until this object source is deleted. + * + * @param aFile File handle. + * @param aMimeType MIME type. Optional, but should be specified if known. + * @since S60 v5.0 + * @return New CThumbnailObjectSource instance. + */ + IMPORT_C static CThumbnailObjectSource* NewLC( const RFile64& aFile, const + TDesC& aMimeType = KNullDesC ); + + /** + * Destructor + * + * @since S60 v5.0 + */ + virtual ~CThumbnailObjectSource(); + +public: + + /** + * Returns file handle. + * + * @since S60 v5.0 + * @return reference to file handle + */ + IMPORT_C RFile64& FileHandle(); + + /** + * Returns source uri. + * + * @since S60 v5.0 + * @return uri + */ + IMPORT_C const TDesC& Uri(); + +private: + + /** + * C++ default constructor + * + * @since S60 v5.0 + */ + CThumbnailObjectSource(); + + /** + * Symbian 2nd phase constructor can leave. + * + * @since S60 v5.0 + * @param aUri Object URI or a full path to a file in the file system. + * @param aMimeType MIME type. Optional, but should be specified if known. + */ + void ConstructL( const TDesC& aUri, const TDesC& aMimeType ); + + /** + * Symbian 2nd phase constructor can leave. + * + * @since S60 v5.0 + * @param aFile File handle. + * @param aMimeType MIME type. Optional, but should be specified if known. + */ + void ConstructL( const RFile64& aFile, const TDesC& aMimeType ); + +private: + // data + + /** + * File + */ + RFile64 iFile; + + /** + * Uri + */ + HBufC* iUri; // own + + /** + * Mime type + */ + HBufC8* iMimeType; // own + + /** + * Buffer + */ + TDesC8* iBuffer; // own + + /** + * Bitmap + */ + + CFbsBitmap* iBitmap; // own + + /** + * ThumbnailId + */ + + TThumbnailId iThumbnailId; //own + +public: + /** + * Symbian 2nd phase constructor can leave. + * + * @since S60 v5.0 + * @param aURI URI. + * @param aMimeType MimeType. + * @param aThumbnailId ThumbnailId + */ + void ConstructL( const TDesC& aUri, const TDesC& aMimeType, TThumbnailId aThumbnailId ); + + /** + * Construct a new CThumbnailObjectSource referring to a buffer + * containing an image. + * + * @param aBuffer Buffer. + * @param aUri Object URI or a full path to a file in the file system. + * @since S60 v5.0 + * @return New CThumbnailObjectSource instance. + */ + IMPORT_C static CThumbnailObjectSource* NewL( CFbsBitmap* aBitmap, const TDesC& aUri ); + + /** + * Construct a new CThumbnailObjectSource referring to a buffer + * containing an image. + * + * @param aFile File handle. + * @param aUri Object URI or a full path to a file in the file system. + * @since S60 v5.0 + * @return New CThumbnailObjectSource instance. + */ + IMPORT_C static CThumbnailObjectSource* NewLC( CFbsBitmap* aBitmap, const TDesC& aUri ); + + /** + * Construct a new CThumbnailObjectSource referring to a buffer + * containing an image. + * + * @param aBuffer Buffer. + * @param aUri Object URI or a full path to a file in the file system. + * @since S60 v5.0 + * @return New CThumbnailObjectSource instance. + */ + IMPORT_C static CThumbnailObjectSource* NewL( TDesC8* aBuffer, TDesC& aMimeType, const TDesC& aUri ); + + /** + * Construct a new CThumbnailObjectSource referring to a buffer + * containing an image. + * + * @param aBuffer Buffer. + * @param aMimeType MIME type. Optional, but should be specified if known. + * @param aUri Object URI or a full path to a file in the file system. + * @since S60 v5.0 + * @return New CThumbnailObjectSource instance. + */ + IMPORT_C static CThumbnailObjectSource* NewLC( TDesC8* aBuffer, TDesC& aMimeType, const TDesC& aUri); + + /** + * Construct a new CThumbnailObjectSource referring to an URI. + * @param aUri Object URI or a full path to a file in the file system. + * @param aMimeType MIME type. Optional, but should be specified if known. + * @since S60 v5.0 + * @return New CThumbnailObjectSource instance. + */ + IMPORT_C static CThumbnailObjectSource* NewL( const TDesC& aUri, + TThumbnailId aThumbnailId = 0, const TDesC& aMimeType = KNullDesC ); + + /** + * Construct a new CThumbnailObjectSource referring to an URI. + * @param aUri Object URI or a full path to a file in the file system. + * @param aMimeType MIME type. Optional, but should be specified if known. + * @since S60 v5.0 + * @return New CThumbnailObjectSource instance. + */ + IMPORT_C static CThumbnailObjectSource* NewLC( const TDesC& aUri, + TThumbnailId aThumbnailId = 0, const TDesC& aMimeType = KNullDesC ); + + + /** + * Returns source buffer. + * + * @since S60 v5.0 + * @return buffer + */ + IMPORT_C TDesC8* Buffer(); + + /** + * Gets ownership of buffer from source object. + * After that Buffer() returns NULL. + * + * @since S60 v5.0 + * @return buffer + */ + IMPORT_C TDesC8* GetBufferOwnership(); + + /** + * Gets MIME type. + * + * @since S60 v5.0 + * @return MIME type + */ + IMPORT_C const TDesC8& MimeType(); + + /** + * Gets ThumbnailId. + * + * @since S60 v5.0 + * @return ThumbnailId + */ + + IMPORT_C TThumbnailId Id(); + + /** + * Symbian 2nd phase constructor can leave. + * + * @since S60 v5.0 + * @param aBitmap Bitmap. + * @param aURI URI. + */ + void ConstructL( CFbsBitmap* aBitmap, const TDesC& + aUri ); + + /** + * Symbian 2nd phase constructor can leave. + * + * @since S60 v5.0 + * @param aBuffer Buffer. + * @param aMimeType MIME type. Optional, but should be specified if known. + * @param aURI URI. + */ + void ConstructL( TDesC8* aBuffer, const TDesC& + aMimeType, const TDesC& aUri ); + + /** + * Returns source bitmap. + * + * @since S60 v5.0 + * @return bitmap + */ + IMPORT_C CFbsBitmap* Bitmap(); + + /** + * Gets ownership of bitmap from source object. + * After that Bitmap() returns NULL. + * + * @since S60 v5.0 + * @return bitmap + */ + IMPORT_C CFbsBitmap* GetBitmapOwnership(); +}; + +#endif // THUMBNAILOBJECTSOURCE_H diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/thumbnailmanager_api.metaxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/thumbnailmanager_api/thumbnailmanager_api.metaxml Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,14 @@ + + +thumbnailmanager_api +Thumbnail engine can be used to request thumbnails for different kinds of media objects. +c++ +imagehandlingutilities + + + + +no +no + + diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/tsrc/Bmarm/ThumbnailManagerTestU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/thumbnailmanager_api/tsrc/Bmarm/ThumbnailManagerTestU.DEF Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,3 @@ +EXPORTS + LibEntryL__FR13CTestModuleIf @ 1 NONAME R3UNUSED ; LibEntryL(CTestModuleIf &) + diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/tsrc/Bwins/ThumbnailManagerTestU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/thumbnailmanager_api/tsrc/Bwins/ThumbnailManagerTestU.DEF Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,3 @@ +EXPORTS + ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * __cdecl LibEntryL(class CTestModuleIf &) + diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/tsrc/EABI/ThumbnailManagerTestU.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/thumbnailmanager_api/tsrc/EABI/ThumbnailManagerTestU.def Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,5 @@ +EXPORTS + _Z9LibEntryLR13CTestModuleIf @ 1 NONAME + _ZTI16CThumbnailCenRep @ 2 NONAME ; ## + _ZTV16CThumbnailCenRep @ 3 NONAME ; ## + diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/tsrc/conf/ThumbnailManagerTest.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/thumbnailmanager_api/tsrc/conf/ThumbnailManagerTest.cfg Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,2139 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Thumbnail Manager API tests +* +*/ + + +[StifSettings] +TestThreadStackSize= 32768 +TestThreadMinHeap= 4096 +TestThreadMaxHeap= 67108860 +[EndStifSettings] + + +// --------------------------------------------------------------------------- +// Thumbnail Manager API test cases +// --------------------------------------------------------------------------- + +// These should be run in sequential mode if several cases are run at the same +// time! Running multiple cases in parallel will not work, because the test +// cases assume they can delete the database file between tests. + + +// --------------------------------------------------------------------------- +// Define constants +// --------------------------------------------------------------------------- +[Define] + +KErrNotFound -1 +KErrNotSupported -5 +KErrArgument -6 + +KMaxTInt 2147483647 + +// Delay between test cases (milliseconds) +KTestDelay 1000 + +KOneSecondDelay 1000 +KFiveSecondDelay 5000 +KTenSecondDelay 5000 + +// A delay to make sure the client-server request to generate a thumbnail +// reaches the server, but doesn't have enough time to complete yet +// (milliseconds) +KClientServerDelay 150 +KClientServerDelay2 25 +KClientServerDelay3 10 + +// From TDisplayMode: value for 24-bit display mode +EColor16M 8 +EColor64K 7 +KDefaultDisplayMode 7 + +// From CThumbnailManager::TThumbeFlags +EDefaultFlags 0 +EAllowAnySize 1 +EDoNotCreate 2 +ECropToAspectRatio 4 + +// From CThumbnailManager::TThumbeQualityPreference +EOptimizeForQuality 0 +EOptimizeForPerformance 1 +EOptimizeForQualityWithPreview 2 + +EUnknownThumbnailSize 0 +ECustomThumbnailSize 1 +EImageGridThumbnailSize 2 +EImageListThumbnailSize 3 +EImageFullScreenThumbnailSize 4 +EVideoGridThumbnailSize 5 +EVideoListThumbnailSize 6 +EVideoFullScreenThumbnailSize 7 +EAudioGridThumbnailSize 8 +EAudioListThumbnailSize 9 +EAudioFullScreenThumbnailSize 10 + +// Custom sizes +KCustomSizeX 111 +KCustomSizeY 222 +KCustomSize2X 222 +KCustomSize2Y 111 +KCustomSize3X 10 +KCustomSize3Y 100 +KCustomSize4X 100 +KCustomSize4Y 10 +KCustomSize5X 1000 +KCustomSize5Y 1000 +KCustomSize6X 1000 +KCustomSize6Y 2000 +KCustomSize7X 2000 +KCustomSize7Y 1000 +KCustomSize8X 1 +KCustomSize8Y 1 +KCustomSize9X 555 +KCustomSize9Y 556 +KCustomSize10X 556 +KCustomSize10Y 555 + +[Enddefine] + + +// --------------------------------------------------------------------------- +// Create and delete CThumbnailManager +// --------------------------------------------------------------------------- +[Test] +title Create and delete CThumbnailManager +create ThumbnailManagerTest tn +tn CreateInstanceL +pause KOneSecondDelay +tn DeleteInstance +delete tn +pause KTestDelay +[Endtest] + +// --------------------------------------------------------------------------- +// Set and check parameters +// --------------------------------------------------------------------------- +[Test] +title Set and check parameters +create ThumbnailManagerTest tn +tn CreateInstanceL + +tn SetThumbnailSizeL 0 0 +tn CheckThumbnailSizeL 0 0 +tn SetThumbnailSizeL 1 1 +tn CheckThumbnailSizeL 1 1 +tn SetThumbnailSizeL KMaxTInt KMaxTInt +tn CheckThumbnailSizeL KMaxTInt KMaxTInt +tn SetThumbnailEnumSizeL EUnknownThumbnailSize +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailEnumSizeL EImageGridThumbnailSize +tn SetThumbnailEnumSizeL EVideoFullScreenThumbnailSize +tn SetThumbnailEnumSizeL KMaxTInt + +tn SetFlagsL EDefaultFlags +tn CheckFlags EDefaultFlags +tn SetFlagsL EAllowAnySize +tn CheckFlags EAllowAnySize +tn SetFlagsL KMaxTInt +tn CheckFlags KMaxTInt + +tn SetQualityPreferenceL EOptimizeForQuality +tn CheckQualityPreference EOptimizeForQuality +tn SetQualityPreferenceL EOptimizeForPerformance +tn CheckQualityPreference EOptimizeForPerformance +tn SetQualityPreferenceL KMaxTInt +tn CheckQualityPreference KMaxTInt + +tn SetDisplayModeL EColor16M +tn CheckDisplayModeL EColor16M +tn SetDisplayModeL EColor64K +tn CheckDisplayModeL EColor64K +tn SetDisplayModeL 0 +tn CheckDisplayModeL 0 +tn SetDisplayModeL KMaxTInt +tn CheckDisplayModeL KMaxTInt + +tn DeleteInstance +delete tn +pause KTestDelay +[Endtest] + +// --------------------------------------------------------------------------- +// Create object sources +// --------------------------------------------------------------------------- +[Test] +title Create object sources +create ThumbnailManagerTest tn +tn CreateInstanceL + +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\RGB_VGA.jpg +tn DeleteSourceInstance +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\Tiny_1x1.jpg +tn DeleteSourceInstance +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\video.3gp +tn DeleteSourceInstance +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\empty_file.bmp +tn DeleteSourceInstance + +tn CreateSourceInstanceHandleL \data\ThumbnailManagerTest\RGB_VGA.jpg +tn DeleteSourceInstance +tn CreateSourceInstanceHandleL \data\ThumbnailManagerTest\Tiny_1x1.jpg +tn DeleteSourceInstance +tn CreateSourceInstanceHandleL \data\ThumbnailManagerTest\video.3gp +tn DeleteSourceInstance +tn CreateSourceInstanceHandleL \data\ThumbnailManagerTest\empty_file.bmp +tn DeleteSourceInstance + +tn CreateSourceInstanceBufferL \data\ThumbnailManagerTest\RGB_VGA.jpg image/jpeg +tn DeleteSourceInstance +tn CreateSourceInstanceBufferL \data\ThumbnailManagerTest\Tiny_1x1.jpg image/jpeg +tn DeleteSourceInstance +tn CreateSourceInstanceBufferL \data\ThumbnailManagerTest\empty_file.bmp image/bmp +tn DeleteSourceInstance + +tn DeleteInstance +delete tn +pause KTestDelay +[Endtest] + + +// --------------------------------------------------------------------------- +// Create JPEG thumbnail +// --------------------------------------------------------------------------- +[Test] +title Create JPEG thumbnail +create ThumbnailManagerTest tn +tn CreateInstanceL +tn SetDisplayModeL EColor16M + +// using path +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\RGB_VGA.jpg +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageFullScreenThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +// using handle +tn CreateSourceInstanceHandleL \data\ThumbnailManagerTest\RGB_VGA.jpg +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageFullScreenThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn DeleteInstance +delete tn +pause KTestDelay +[Endtest] + +// --------------------------------------------------------------------------- +// Create GIF thumbnail +// --------------------------------------------------------------------------- +[Test] +title Create GIF thumbnail +create ThumbnailManagerTest tn +tn CreateInstanceL +tn SetDisplayModeL EColor16M + +// using path +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\WIDE_800x400.gif +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageFullScreenThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +// using handle +tn CreateSourceInstanceHandleL \data\ThumbnailManagerTest\WIDE_800x400.gif +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageFullScreenThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn DeleteInstance +delete tn +pause KTestDelay +[Endtest] + +// --------------------------------------------------------------------------- +// Create SVG thumbnail +// --------------------------------------------------------------------------- +[Test] +title Create SVG thumbnail +create ThumbnailManagerTest tn +tn CreateInstanceL +tn SetDisplayModeL EColor16M + +// using path +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\SVG_640x480.svg +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageFullScreenThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +// using handle +tn CreateSourceInstanceHandleL \data\ThumbnailManagerTest\SVG_640x480.svg +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageFullScreenThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn DeleteInstance +delete tn +pause KTestDelay +[Endtest] + +// --------------------------------------------------------------------------- +// Create BMP thumbnail +// --------------------------------------------------------------------------- +[Test] +title Create BMP thumbnail +create ThumbnailManagerTest tn +tn CreateInstanceL +tn SetDisplayModeL EColor16M + +// using path +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\RGB_400x300.bmp +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageFullScreenThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +// using handle +tn CreateSourceInstanceHandleL \data\ThumbnailManagerTest\RGB_400x300.bmp +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageFullScreenThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn DeleteInstance +delete tn +pause KTestDelay +[Endtest] + +// --------------------------------------------------------------------------- +// Create 3GP thumbnail +// --------------------------------------------------------------------------- +[Test] +title Create 3GP thumbnail +create ThumbnailManagerTest tn +tn CreateInstanceL +tn SetDisplayModeL EColor16M + +// using path +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\video.3gp +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EVideoGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EVideoGridThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EVideoFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EVideoFullScreenThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +// using handle +tn CreateSourceInstanceHandleL \data\ThumbnailManagerTest\video.3gp +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EVideoGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EVideoGridThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EVideoFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EVideoFullScreenThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn DeleteInstance +delete tn +pause KTestDelay +[Endtest] + +// --------------------------------------------------------------------------- +// Create MPEG4 thumbnail +// --------------------------------------------------------------------------- +[Test] +title Create MPEG4 thumbnail +create ThumbnailManagerTest tn +tn CreateInstanceL +tn SetDisplayModeL EColor16M + +// using path +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\Videoclip.mp4 +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EVideoGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EVideoGridThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EVideoFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EVideoFullScreenThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +// using handle +tn CreateSourceInstanceHandleL \data\ThumbnailManagerTest\Videoclip.mp4 +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EVideoGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EVideoGridThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EVideoFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EVideoFullScreenThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn DeleteInstance +delete tn +pause KTestDelay +[Endtest] + +// --------------------------------------------------------------------------- +// Create MP3 thumbnail +// --------------------------------------------------------------------------- +[Test] +title Create MP3 thumbnail +create ThumbnailManagerTest tn +tn CreateInstanceL +tn SetDisplayModeL EColor16M + +// using path +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\mp3.mp3 +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EAudioGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EAudioGridThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EAudioFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EAudioFullScreenThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +// using handle +tn CreateSourceInstanceHandleL \data\ThumbnailManagerTest\mp3.mp3 +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EAudioGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EAudioGridThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EAudioFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EAudioFullScreenThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn DeleteInstance +delete tn +pause KTestDelay +[Endtest] + + +// --------------------------------------------------------------------------- +// Thumbs from buffer +// --------------------------------------------------------------------------- +[Test] +title Thumbs from buffer +create ThumbnailManagerTest tn +tn CreateInstanceL +tn SetDisplayModeL EColor16M + +tn CreateSourceInstanceBufferL \data\ThumbnailManagerTest\RGB_VGA.jpg image/jpeg +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageFullScreenThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn CreateSourceInstanceBufferL \data\ThumbnailManagerTest\RGB_400x300.bmp image/bmp +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageFullScreenThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn CreateSourceInstanceBufferL \data\ThumbnailManagerTest\8bit_PNG.png image/png +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageFullScreenThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn CreateSourceInstanceBufferL \data\ThumbnailManagerTest\SVG_640x480.svg image/svg+xml +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageFullScreenThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn DeleteInstance +delete tn +pause KTestDelay +[Endtest] + +// --------------------------------------------------------------------------- +// Create thumbnails for each persistent size +// --------------------------------------------------------------------------- +[Test] +title Create thumbnails for each persistent size +create ThumbnailManagerTest tn +tn CreateInstanceL +tn SetDisplayModeL EColor16M + +tn SetFlagsL EDefaultFlags +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\RGB_VGA.jpg +tn DeleteThumbnails +tn CreateThumbnails +waittestclass tn + +pause KTenSecondDelay + +tn SetFlagsL EDoNotCreate +tn SetThumbnailEnumSizeL EImageGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor16M +tn SetThumbnailEnumSizeL EImageListThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageListThumbnailSize EColor16M +tn SetThumbnailEnumSizeL EImageFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageFullScreenThumbnailSize EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn SetFlagsL EDefaultFlags +tn CreateSourceInstanceBufferL \data\ThumbnailManagerTest\RGB_VGA.jpg image/jpeg +tn DeleteThumbnails +tn CreateThumbnails +waittestclass tn + +pause KTenSecondDelay + +tn SetFlagsL EDoNotCreate +tn SetThumbnailEnumSizeL EImageGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor16M +tn SetThumbnailEnumSizeL EImageListThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageListThumbnailSize EColor16M +tn SetThumbnailEnumSizeL EImageFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageFullScreenThumbnailSize EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn SetFlagsL EDefaultFlags +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\RGB_400x300.bmp +tn DeleteThumbnails +tn CreateThumbnails +waittestclass tn + +pause KTenSecondDelay + +tn SetFlagsL EDoNotCreate +tn SetThumbnailEnumSizeL EImageGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor16M +tn SetThumbnailEnumSizeL EImageListThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageListThumbnailSize EColor16M +tn SetThumbnailEnumSizeL EImageFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageFullScreenThumbnailSize EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn SetFlagsL EDefaultFlags +tn CreateSourceInstanceBufferL \data\ThumbnailManagerTest\RGB_400x300.bmp image/bmp +tn DeleteThumbnails +tn CreateThumbnails +waittestclass tn + +pause KTenSecondDelay + +tn SetFlagsL EDoNotCreate +tn SetThumbnailEnumSizeL EImageGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor16M +tn SetThumbnailEnumSizeL EImageListThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageListThumbnailSize EColor16M +tn SetThumbnailEnumSizeL EImageFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageFullScreenThumbnailSize EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn SetFlagsL EDefaultFlags +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\video.3gp +tn DeleteThumbnails +tn CreateThumbnails +waittestclass tn + +pause KTenSecondDelay + +tn SetFlagsL EDoNotCreate +tn SetThumbnailEnumSizeL EVideoGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EVideoGridThumbnailSize EColor16M +tn SetThumbnailEnumSizeL EVideoListThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EVideoListThumbnailSize EColor16M +tn SetThumbnailEnumSizeL EVideoFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EVideoFullScreenThumbnailSize EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn DeleteInstance +delete tn +pause KTestDelay +[Endtest] + + +// --------------------------------------------------------------------------- +// Thumbnail from missing or unsupported file +// --------------------------------------------------------------------------- +[Test] +title Thumbnail from missing or unsupported file +create ThumbnailManagerTest tn +tn CreateInstanceL +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY + +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\does_not_exist.jpg +tn GetThumbnailL +allownextresult KErrNotFound +waittestclass tn +tn DeleteSourceInstance + +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\Unsupported.txt +tn GetThumbnailL +allownextresult KErrNotSupported +waittestclass tn +tn DeleteSourceInstance + +tn CreateSourceInstanceHandleL \data\ThumbnailManagerTest\Unsupported.txt +tn GetThumbnailL +allownextresult KErrNotSupported +waittestclass tn +tn DeleteSourceInstance + +tn CreateSourceInstanceBufferL \data\ThumbnailManagerTest\Unsupported.txt plain/text +tn GetThumbnailL +allownextresult KErrNotSupported +waittestclass tn +tn DeleteSourceInstance + +tn DeleteInstance +delete tn +pause KTestDelay +[Endtest] + +// --------------------------------------------------------------------------- +// Thumbnail from corrupt file +// --------------------------------------------------------------------------- +[Test] +title Thumbnail from corrupt file +create ThumbnailManagerTest tn +tn CreateInstanceL +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY + +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\not_jpg.jpg +tn GetThumbnailL +allownextresult KErrNotFound +waittestclass tn +tn DeleteSourceInstance + +tn CreateSourceInstanceBufferL \data\ThumbnailManagerTest\not_jpg.jpg image/jpeg +tn GetThumbnailL +allownextresult KErrNotFound +waittestclass tn +tn DeleteSourceInstance + +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\not_3gp.3gp +tn GetThumbnailL +allownextresult KErrNotSupported +waittestclass tn +tn DeleteSourceInstance + +tn DeleteInstance +delete tn +pause KTestDelay +[Endtest] + + +// --------------------------------------------------------------------------- +// Custom size thumbs +// --------------------------------------------------------------------------- +[Test] +title Custom size thumbs +create ThumbnailManagerTest tn +tn CreateInstanceL +tn SetDisplayModeL EColor16M +tn SetThumbnailEnumSizeL ECustomThumbnailSize + +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\RGB_VGA.jpg +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize2X KCustomSize2Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize2X KCustomSize2Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize3X KCustomSize3Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize3X KCustomSize3Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize4X KCustomSize4Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize4X KCustomSize4Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize5X KCustomSize5Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize5X KCustomSize5Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize6X KCustomSize6Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize6X KCustomSize6Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize7X KCustomSize7Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize7X KCustomSize7Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize8X KCustomSize8Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize8X KCustomSize8Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize9X KCustomSize9Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize9X KCustomSize9Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize10X KCustomSize10Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize10X KCustomSize10Y EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\TALL_400x800.bmp +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize2X KCustomSize2Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize2X KCustomSize2Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize3X KCustomSize3Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize3X KCustomSize3Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize4X KCustomSize4Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize4X KCustomSize4Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize5X KCustomSize5Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize5X KCustomSize5Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize6X KCustomSize6Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize6X KCustomSize6Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize7X KCustomSize7Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize7X KCustomSize7Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize8X KCustomSize8Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize8X KCustomSize8Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize9X KCustomSize9Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize9X KCustomSize9Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize10X KCustomSize10Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize10X KCustomSize10Y EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\WIDE_800x400.gif +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize2X KCustomSize2Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize2X KCustomSize2Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize3X KCustomSize3Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize3X KCustomSize3Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize4X KCustomSize4Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize4X KCustomSize4Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize5X KCustomSize5Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize5X KCustomSize5Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize6X KCustomSize6Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize6X KCustomSize6Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize7X KCustomSize7Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize7X KCustomSize7Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize8X KCustomSize8Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize8X KCustomSize8Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize9X KCustomSize9Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize9X KCustomSize9Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize10X KCustomSize10Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize10X KCustomSize10Y EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn DeleteInstance +delete tn +pause KTestDelay +[Endtest] + +// --------------------------------------------------------------------------- +// Custom size thumbs with cropping +// --------------------------------------------------------------------------- +[Test] +title Custom size thumbs with cropping +create ThumbnailManagerTest tn +tn CreateInstanceL +tn SetDisplayModeL EColor16M +tn SetThumbnailEnumSizeL ECustomThumbnailSize + +tn SetFlagsL ECropToAspectRatio + +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\RGB_VGA.jpg +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize2X KCustomSize2Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize2X KCustomSize2Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize3X KCustomSize3Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize3X KCustomSize3Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize4X KCustomSize4Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize4X KCustomSize4Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize5X KCustomSize5Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize5X KCustomSize5Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize6X KCustomSize6Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize6X KCustomSize6Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize7X KCustomSize7Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize7X KCustomSize7Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize8X KCustomSize8Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize8X KCustomSize8Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize9X KCustomSize9Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize9X KCustomSize9Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize10X KCustomSize10Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize10X KCustomSize10Y EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\TALL_400x800.bmp +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize2X KCustomSize2Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize2X KCustomSize2Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize3X KCustomSize3Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize3X KCustomSize3Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize4X KCustomSize4Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize4X KCustomSize4Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize5X KCustomSize5Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize5X KCustomSize5Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize6X KCustomSize6Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize6X KCustomSize6Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize7X KCustomSize7Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize7X KCustomSize7Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize8X KCustomSize8Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize8X KCustomSize8Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize9X KCustomSize9Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize9X KCustomSize9Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize10X KCustomSize10Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize10X KCustomSize10Y EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\WIDE_800x400.gif +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize2X KCustomSize2Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize2X KCustomSize2Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize3X KCustomSize3Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize3X KCustomSize3Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize4X KCustomSize4Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize4X KCustomSize4Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize5X KCustomSize5Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize5X KCustomSize5Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize6X KCustomSize6Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize6X KCustomSize6Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize7X KCustomSize7Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize7X KCustomSize7Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize8X KCustomSize8Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize8X KCustomSize8Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize9X KCustomSize9Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize9X KCustomSize9Y EColor16M +tn DeleteThumbnails +tn SetThumbnailSizeL KCustomSize10X KCustomSize10Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize10X KCustomSize10Y EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn DeleteInstance +delete tn +pause KTestDelay +[Endtest] + +// --------------------------------------------------------------------------- +// Different display modes +// --------------------------------------------------------------------------- +[Test] +title Different display modes +create ThumbnailManagerTest tn +tn CreateInstanceL + +// 24-bit +tn SetDisplayModeL EColor16M + +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\RGB_VGA.jpg +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageFullScreenThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSize5X KCustomSize5Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize5X KCustomSize5Y EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn CreateSourceInstanceBufferL \data\ThumbnailManagerTest\RGB_VGA.jpg image/jpeg +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageFullScreenThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSize5X KCustomSize5Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize5X KCustomSize5Y EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\RGB_400x300.bmp +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageFullScreenThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSize5X KCustomSize5Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize5X KCustomSize5Y EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn CreateSourceInstanceBufferL \data\ThumbnailManagerTest\RGB_400x300.bmp image/bmp +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageFullScreenThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSize5X KCustomSize5Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize5X KCustomSize5Y EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\video.3gp +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EVideoGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EVideoGridThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EVideoFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EVideoFullScreenThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSize5X KCustomSize5Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize5X KCustomSize5Y EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\Videoclip.mp4 +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EVideoGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EVideoGridThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EVideoFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EVideoFullScreenThumbnailSize EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor16M +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSize5X KCustomSize5Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize5X KCustomSize5Y EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +// 16-bit +tn SetDisplayModeL EColor64K + +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\RGB_VGA.jpg +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor64K +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageFullScreenThumbnailSize EColor64K +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor64K +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSize5X KCustomSize5Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize5X KCustomSize5Y EColor64K +tn DeleteThumbnails +tn DeleteSourceInstance + +tn CreateSourceInstanceBufferL \data\ThumbnailManagerTest\RGB_VGA.jpg image/jpeg +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor64K +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageFullScreenThumbnailSize EColor64K +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor64K +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSize5X KCustomSize5Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize5X KCustomSize5Y EColor64K +tn DeleteThumbnails +tn DeleteSourceInstance + +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\RGB_400x300.bmp +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor64K +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageFullScreenThumbnailSize EColor64K +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor64K +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSize5X KCustomSize5Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize5X KCustomSize5Y EColor64K +tn DeleteThumbnails +tn DeleteSourceInstance + +tn CreateSourceInstanceBufferL \data\ThumbnailManagerTest\RGB_400x300.bmp image/bmp +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor64K +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EImageFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageFullScreenThumbnailSize EColor64K +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor64K +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSize5X KCustomSize5Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize5X KCustomSize5Y EColor64K +tn DeleteThumbnails +tn DeleteSourceInstance + +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\video.3gp +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EVideoGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EVideoGridThumbnailSize EColor64K +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EVideoFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EVideoFullScreenThumbnailSize EColor64K +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor64K +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSize5X KCustomSize5Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize5X KCustomSize5Y EColor64K +tn DeleteThumbnails +tn DeleteSourceInstance + +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\Videoclip.mp4 +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EVideoGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EVideoGridThumbnailSize EColor64K +tn DeleteThumbnails +tn SetThumbnailEnumSizeL EVideoFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EVideoFullScreenThumbnailSize EColor64K +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSizeX KCustomSizeY +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSizeX KCustomSizeY EColor64K +tn DeleteThumbnails +tn SetThumbnailEnumSizeL ECustomThumbnailSize +tn SetThumbnailSizeL KCustomSize5X KCustomSize5Y +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailL KCustomSize5X KCustomSize5Y EColor64K +tn DeleteThumbnails +tn DeleteSourceInstance + +tn DeleteInstance +delete tn +pause KTestDelay +[Endtest] + + +// --------------------------------------------------------------------------- +// Get thumbnail by id +// --------------------------------------------------------------------------- +[Test] +title Get thumbnail by id +create ThumbnailManagerTest tn +tn CreateInstanceL +tn SetDisplayModeL EColor16M + +tn SetThumbnailEnumSizeL EImageGridThumbnailSize +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\RGB_VGA.jpg 99999 +tn DeleteThumbnails +tn CreateThumbnails +waittestclass tn + +pause KTenSecondDelay + +tn SetFlagsL EDoNotCreate +tn GetThumbnailByIdL 99999 +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor16M +tn DeleteThumbnails + +tn DeleteSourceInstance +tn DeleteInstance +delete tn +pause KTestDelay +[Endtest] + +// --------------------------------------------------------------------------- +// Set thumbnail from buffer +// --------------------------------------------------------------------------- +[Test] +title Set thumbnail from buffer +create ThumbnailManagerTest tn +tn CreateInstanceL +tn SetDisplayModeL EColor16M + +tn SetFlagsL EDefaultFlags +tn SetThumbnailEnumSizeL EImageGridThumbnailSize +tn CreateSourceInstanceBufferL \data\ThumbnailManagerTest\RGB_VGA.jpg image/jpeg +tn DeleteThumbnails +tn SetThumbnailL + +waittestclass tn + +tn SetFlagsL EDoNotCreate +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn SetFlagsL EDefaultFlags +tn CreateSourceInstanceBufferL \data\ThumbnailManagerTest\RGB_400x300.bmp image/bmp +tn DeleteThumbnails +tn SetThumbnailL + +waittestclass tn + +tn SetFlagsL EDoNotCreate +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn SetFlagsL EDefaultFlags +tn CreateSourceInstanceBufferL \data\ThumbnailManagerTest\WIDE_800x400.gif image/gif +tn DeleteThumbnails +tn SetThumbnailL + +waittestclass tn + +tn SetFlagsL EDoNotCreate +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn DeleteInstance +delete tn +pause KTestDelay +[Endtest] + +// --------------------------------------------------------------------------- +// Import thumbnail +// --------------------------------------------------------------------------- +[Test] +title Import thumbnail +create ThumbnailManagerTest tn +tn CreateInstanceL +tn SetDisplayModeL EColor16M + +tn SetFlagsL EDefaultFlags +tn SetThumbnailEnumSizeL EImageGridThumbnailSize +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\RGB_VGA.jpg +tn DeleteThumbnails +tn ImportThumbnailL \data\ThumbnailManagerTest\imported.jpg +waittestclass tn +tn DeleteSourceInstance + +tn SetFlagsL EDoNotCreate +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\imported.jpg +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn SetFlagsL EDefaultFlags +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\RGB_400x300.bmp +tn DeleteThumbnails +tn ImportThumbnailL \data\ThumbnailManagerTest\imported.bmp +waittestclass tn +tn DeleteSourceInstance + +tn SetFlagsL EDoNotCreate +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\imported.bmp +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn SetFlagsL EDefaultFlags +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\WIDE_800x400.gif +tn DeleteThumbnails +tn ImportThumbnailL \data\ThumbnailManagerTest\imported.gif +waittestclass tn +tn DeleteSourceInstance + +tn SetFlagsL EDoNotCreate +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\imported.gif +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn SetFlagsL EDefaultFlags +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\video.3gp +tn DeleteThumbnails +tn ImportThumbnailL \data\ThumbnailManagerTest\imported.3gp +waittestclass tn +tn DeleteSourceInstance + +tn SetFlagsL EDoNotCreate +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\imported.3gp +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn DeleteInstance +delete tn +pause KTestDelay +[Endtest] + + +// --------------------------------------------------------------------------- +// Delete thumbnails +// --------------------------------------------------------------------------- +[Test] +title Delete thumbnails +create ThumbnailManagerTest tn +tn CreateInstanceL +tn SetDisplayModeL EColor16M + +tn SetThumbnailEnumSizeL EImageGridThumbnailSize + +// one thumbnail +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\RGB_VGA.jpg +tn DeleteThumbnails +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor16M + +tn DeleteThumbnails +pause KTenSecondDelay + +tn SetFlagsL EDoNotCreate +tn GetThumbnailL +allownextresult KErrNotFound +waittestclass tn + +// all persistent thumbnails created +tn SetFlagsL EDefaultFlags +tn CreateThumbnails +waittestclass tn +pause KTenSecondDelay + +tn DeleteThumbnails +pause KTenSecondDelay + +tn SetFlagsL EDoNotCreate +tn GetThumbnailL +allownextresult KErrNotFound +waittestclass tn + +tn DeleteThumbnails +tn DeleteSourceInstance + +tn DeleteInstance +delete tn +pause KTestDelay +[Endtest] + +// --------------------------------------------------------------------------- +// Delete thumbnails by id +// --------------------------------------------------------------------------- +[Test] +title Delete thumbnails by id +create ThumbnailManagerTest tn +tn CreateInstanceL +tn SetDisplayModeL EColor16M + +tn SetThumbnailEnumSizeL EImageGridThumbnailSize +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\RGB_VGA.jpg 99999 +tn DeleteThumbnails +tn CreateThumbnails +waittestclass tn + +pause KTenSecondDelay + +tn SetFlagsL EDoNotCreate +tn GetThumbnailByIdL 99999 +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor16M + +tn DeleteThumbnailsByIdL 99999 +pause KOneSecondDelay + +tn GetThumbnailByIdL 99999 +allownextresult KErrNotFound +waittestclass tn + +tn DeleteSourceInstance +tn DeleteInstance +delete tn +pause KTestDelay +[Endtest] + + +// --------------------------------------------------------------------------- +// Update path +// --------------------------------------------------------------------------- +[Test] +title Update path +create ThumbnailManagerTest tn +tn CreateInstanceL +tn SetDisplayModeL EColor16M + +tn SetThumbnailEnumSizeL EImageGridThumbnailSize +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\RGB_VGA.jpg 99999 +tn DeleteThumbnails +tn CreateThumbnails +waittestclass tn +tn DeleteSourceInstance + +pause KTenSecondDelay + +tn UpdatePathL 99999 \data\ThumbnailManagerTest\updated_path.bmp +waittestclass tn + +pause KTenSecondDelay + +tn SetFlagsL EDoNotCreate +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\RGB_VGA.jpg +tn GetThumbnailL +allownextresult KErrNotFound +waittestclass tn +tn DeleteSourceInstance + +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\updated_path.bmp 99999 +tn GetThumbnailByIdL 99999 +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor16M +tn DeleteSourceInstance +tn DeleteThumbnailsByIdL 99999 + +tn DeleteInstance +delete tn +pause KTestDelay +[Endtest] + + +// --------------------------------------------------------------------------- +// Delete engine when requests are pending +// --------------------------------------------------------------------------- +[Test] +title Delete engine when requests are pending +create ThumbnailManagerTest tn +tn CreateInstanceL + +tn SetThumbnailEnumSizeL EImageFullScreenThumbnailSize + +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\Videoclip.mp4 +tn DeleteThumbnails +tn DeleteSourceInstance +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\TALL_400x800.bmp +tn DeleteThumbnails +tn DeleteSourceInstance + +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\Videoclip.mp4 +tn GetThumbnailL +tn DeleteSourceInstance + +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\TALL_400x800.bmp +tn GetThumbnailL +tn DeleteSourceInstance + +tn DeleteInstance +delete tn +pause KTestDelay +[Endtest] + +// --------------------------------------------------------------------------- +// Cancel request +// --------------------------------------------------------------------------- +[Test] +title Cancel request +create ThumbnailManagerTest tn +tn CreateInstanceL +tn SetDisplayModeL EColor16M + +tn SetThumbnailEnumSizeL EImageFullScreenThumbnailSize + +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\Videoclip.mp4 +tn DeleteThumbnails +tn DeleteSourceInstance +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\TALL_400x800.bmp +tn DeleteThumbnails +tn DeleteSourceInstance + +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\Videoclip.mp4 +tn GetThumbnailL +tn DeleteSourceInstance + +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\TALL_400x800.bmp +tn GetThumbnailL +tn DeleteSourceInstance + +pause KClientServerDelay2 + +// The server should have the two thumbnail requests queued by now. +// This should cancel the second one while letting the first one finish. +tn CancelPrevious + +waittestclass tn +tn CheckThumbnailCenrepL EImageFullScreenThumbnailSize EColor16M + +tn DeleteInstance +delete tn +pause KTestDelay +[Endtest] + +// --------------------------------------------------------------------------- +// Priority handling +// --------------------------------------------------------------------------- +[Test] +title Priority handling +create ThumbnailManagerTest tn +tn CreateInstanceL +tn SetDisplayModeL EColor16M +tn SetThumbnailEnumSizeL ECustomThumbnailSize + +tn CreateSourceInstanceHandleL \data\ThumbnailManagerTest\WIDE_800x400.gif +tn DeleteThumbnails +tn DeleteSourceInstance +tn CreateSourceInstanceHandleL \data\ThumbnailManagerTest\TALL_400x800.bmp +tn DeleteThumbnails +tn DeleteSourceInstance +tn CreateSourceInstanceHandleL \data\ThumbnailManagerTest\SVG_640x480.svg +tn DeleteThumbnails +tn DeleteSourceInstance + +// First request with 100 priority +tn SetThumbnailSizeL 80 40 +tn CreateSourceInstanceHandleL \data\ThumbnailManagerTest\WIDE_800x400.gif +tn GetThumbnailL 0 100 +tn DeleteSourceInstance + +// Second request with negative priority +tn SetThumbnailSizeL 1 1 +tn CreateSourceInstanceHandleL \data\ThumbnailManagerTest\TALL_400x800.bmp +tn GetThumbnailL 0 -50 +tn DeleteSourceInstance + +// Third request with positive priority +tn SetThumbnailSizeL 40 30 +tn CreateSourceInstanceHandleL \data\ThumbnailManagerTest\SVG_640x480.svg +tn GetThumbnailL 0 50 +tn DeleteSourceInstance + +// First request should complete first, since the server started processing +// it before the other requests were done +waittestclass tn +tn CheckThumbnailL 80 40 EColor16M + +// The third request should finish next +waittestclass tn +tn CheckThumbnailL 40 30 EColor16M + +// The second request should finish last, since it had the lowest priority +waittestclass tn +tn CheckThumbnailL 1 1 EColor16M + +tn CreateSourceInstanceHandleL \data\ThumbnailManagerTest\WIDE_800x400.gif +tn DeleteThumbnails +tn DeleteSourceInstance +tn CreateSourceInstanceHandleL \data\ThumbnailManagerTest\TALL_400x800.bmp +tn DeleteThumbnails +tn DeleteSourceInstance +tn CreateSourceInstanceHandleL \data\ThumbnailManagerTest\SVG_640x480.svg +tn DeleteThumbnails +tn DeleteSourceInstance + +tn DeleteInstance +delete tn +pause KTestDelay +[Endtest] + +// --------------------------------------------------------------------------- +// Change priority +// --------------------------------------------------------------------------- +[Test] +title Change priority +create ThumbnailManagerTest tn +tn CreateInstanceL +tn SetDisplayModeL EColor16M +tn SetThumbnailEnumSizeL ECustomThumbnailSize + +tn CreateSourceInstanceHandleL \data\ThumbnailManagerTest\WIDE_800x400.gif +tn DeleteThumbnails +tn DeleteSourceInstance +tn CreateSourceInstanceHandleL \data\ThumbnailManagerTest\TALL_400x800.bmp +tn DeleteThumbnails +tn DeleteSourceInstance +tn CreateSourceInstanceHandleL \data\ThumbnailManagerTest\SVG_640x480.svg +tn DeleteThumbnails +tn DeleteSourceInstance + +// First request with 0 priority +tn SetThumbnailSizeL 80 40 +tn CreateSourceInstanceHandleL \data\ThumbnailManagerTest\WIDE_800x400.gif +tn GetThumbnailL 0 0 +tn DeleteSourceInstance + +// Second request with negative priority +tn SetThumbnailSizeL 1 1 +tn CreateSourceInstanceHandleL \data\ThumbnailManagerTest\TALL_400x800.bmp +tn GetThumbnailL 0 -50 +tn DeleteSourceInstance + +// Third request with positive priority +tn SetThumbnailSizeL 40 30 +tn CreateSourceInstanceHandleL \data\ThumbnailManagerTest\SVG_640x480.svg +tn GetThumbnailL 0 50 +tn DeleteSourceInstance + +// Change the priority of the third request to a low value +tn ChangePreviousPriority -100 + +// First request should complete first, since the server started processing +// it before the other requests were done +waittestclass tn +tn CheckThumbnailL 80 40 EColor16M + +// The second request should finish next +waittestclass tn +tn CheckThumbnailL 1 1 EColor16M + +// The third request should finish last, since the priority was changed to the +// lowest value. +waittestclass tn +tn CheckThumbnailL 40 30 EColor16M + +tn CreateSourceInstanceHandleL \data\ThumbnailManagerTest\WIDE_800x400.gif +tn DeleteThumbnails +tn DeleteSourceInstance +tn CreateSourceInstanceHandleL \data\ThumbnailManagerTest\TALL_400x800.bmp +tn DeleteThumbnails +tn DeleteSourceInstance +tn CreateSourceInstanceHandleL \data\ThumbnailManagerTest\SVG_640x480.svg +tn DeleteThumbnails +tn DeleteSourceInstance + +tn DeleteInstance +delete tn +pause KTestDelay +[Endtest] + +// --------------------------------------------------------------------------- +// Get supported mime types +// --------------------------------------------------------------------------- +[Test] +title Get supported mime types +create ThumbnailManagerTest tn +tn CreateInstanceL +tn GetSupportedMimeTypesL +tn DeleteInstance +delete tn +pause KTestDelay +[Endtest] + +// --------------------------------------------------------------------------- +// Create thumbnails using CFbsBitmap +// --------------------------------------------------------------------------- +[Test] +title Create thumbnails using CFbsBitmap +create ThumbnailManagerTest tn +tn CreateInstanceL +tn SetDisplayModeL EColor16M + +tn SetFlagsL EDefaultFlags +tn CreateSourceInstanceBitmapL \data\ThumbnailManagerTest\TestMBM.mbm \data\ThumbnailManagerTest\camera.jpg +tn DeleteThumbnails +tn CreateThumbnails +waittestclass tn + +pause KTenSecondDelay + +tn DeleteSourceInstance + +tn CreateSourceInstancePathL \data\ThumbnailManagerTest\camera.jpg +tn SetFlagsL EDoNotCreate +tn SetThumbnailEnumSizeL EImageGridThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageGridThumbnailSize EColor16M +tn SetThumbnailEnumSizeL EImageFullScreenThumbnailSize +tn GetThumbnailL +waittestclass tn +tn CheckThumbnailCenrepL EImageFullScreenThumbnailSize EColor16M +tn DeleteThumbnails +tn DeleteSourceInstance + +tn DeleteInstance +delete tn +pause KTestDelay +[Endtest] diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/8bit_PNG.png Binary file imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/8bit_PNG.png has changed diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/RGB_400x300.bmp Binary file imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/RGB_400x300.bmp has changed diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/RGB_VGA.jpg Binary file imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/RGB_VGA.jpg has changed diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/SVG_640x480.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/SVG_640x480.svg Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,93 @@ + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/TALL_400x800.bmp Binary file imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/TALL_400x800.bmp has changed diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/TestMBM.mbm Binary file imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/TestMBM.mbm has changed diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/Tiny_1x1.jpg Binary file imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/Tiny_1x1.jpg has changed diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/Unsupported.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/Unsupported.txt Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,1 @@ +Text file for testing purposes diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/Videoclip.mp4 Binary file imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/Videoclip.mp4 has changed diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/WIDE_800x400.gif Binary file imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/WIDE_800x400.gif has changed diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/camera.jpg Binary file imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/camera.jpg has changed diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/empty_file.bmp diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/mp3.mp3 Binary file imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/mp3.mp3 has changed diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/not_3gp.3gp Binary file imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/not_3gp.3gp has changed diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/not_jpg.jpg Binary file imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/not_jpg.jpg has changed diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/video.3gp Binary file imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/video.3gp has changed diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/tsrc/group/ThumbnailManagerTest.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/thumbnailmanager_api/tsrc/group/ThumbnailManagerTest.mmp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Thumbnail Manager API tests +* +*/ + +#include +#include + +TARGET ThumbnailManagerTest.dll +TARGETTYPE dll +UID 0x1000008D 0x101FB3E3 + +CAPABILITY ALL -TCB +VENDORID VID_DEFAULT +EPOCSTACKSIZE 0x8192 + +DEFFILE ThumbnailManagerTest.def + +SOURCEPATH ../src +SOURCE ThumbnailManagerTest.cpp +SOURCE ThumbnailManagerTestBlocks.cpp +SOURCE thumbnailcenrep.cpp + +// Default system include paths for middleware layer modules. +MW_LAYER_SYSTEMINCLUDE + +USERINCLUDE ../inc + +LIBRARY euser.lib +LIBRARY PlatformEnv.lib +LIBRARY stiftestinterface.lib +LIBRARY stiftestengine.lib +LIBRARY efsrv.lib +LIBRARY sqldb.lib +LIBRARY fbscli.lib +LIBRARY imageconversion.lib +LIBRARY centralrepository.lib +LIBRARY thumbnailmanager.lib + +PAGED +BYTEPAIRCOMPRESSTARGET + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/tsrc/group/ThumbnailManagerTest.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/thumbnailmanager_api/tsrc/group/ThumbnailManagerTest.pkg Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,49 @@ +; +; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: Thumbnail Manager API tests +; + +; Languages +&EN + +; Header +#{"ThumbnailManagerTest"},(0x101FB3E3),1,0,0,TYPE=SA + +; Localised Vendor name +%{"Nokia"} + +; Unique Vendor name +:"Nokia" + +; Install files +"\epoc32\release\armv5\udeb\ThumbnailManagerTest.dll" - "c:\sys\bin\ThumbnailManagerTest.dll" +"..\conf\ThumbnailManagerTest.cfg" - "c:\TestFramework\ThumbnailManagerTest.cfg" +"..\init\ThumbnailManagerTest.ini" - "c:\TestFramework\ThumbnailManagerTest.ini" +"..\data\mmc\ThumbnailManagerTest\8bit_PNG.png" - "e:\testing\data\ThumbnailManagerTest\8bit_PNG.png" +"..\data\mmc\ThumbnailManagerTest\empty_file.bmp" - "e:\testing\data\ThumbnailManagerTest\empty_file.bmp" +"..\data\mmc\ThumbnailManagerTest\not_3gp.3gp" - "e:\testing\data\ThumbnailManagerTest\not_3gp.3gp" +"..\data\mmc\ThumbnailManagerTest\not_jpg.jpg" - "e:\testing\data\ThumbnailManagerTest\not_jpg.jpg" +"..\data\mmc\ThumbnailManagerTest\RGB_400x300.bmp" - "e:\testing\data\ThumbnailManagerTest\RGB_400x300.bmp" +"..\data\mmc\ThumbnailManagerTest\RGB_VGA.jpg" - "e:\testing\data\ThumbnailManagerTest\RGB_VGA.jpg" +"..\data\mmc\ThumbnailManagerTest\SVG_640x480.svg" - "e:\testing\data\ThumbnailManagerTest\SVG_640x480.svg" +"..\data\mmc\ThumbnailManagerTest\TALL_400x800.bmp" - "e:\testing\data\ThumbnailManagerTest\TALL_400x800.bmp" +"..\data\mmc\ThumbnailManagerTest\Tiny_1x1.jpg" - "e:\testing\data\ThumbnailManagerTest\Tiny_1x1.jpg" +"..\data\mmc\ThumbnailManagerTest\Unsupported.txt" - "e:\testing\data\ThumbnailManagerTest\Unsupported.txt" +"..\data\mmc\ThumbnailManagerTest\video.3gp" - "e:\testing\data\ThumbnailManagerTest\video.3gp" +"..\data\mmc\ThumbnailManagerTest\Videoclip.mp4" - "e:\testing\data\ThumbnailManagerTest\Videoclip.mp4" +"..\data\mmc\ThumbnailManagerTest\WIDE_800x400.gif" - "e:\testing\data\ThumbnailManagerTest\WIDE_800x400.gif" +"..\data\mmc\ThumbnailManagerTest\TestMBM.mbm" - "e:\testing\data\ThumbnailManagerTest\TestMBM.mbm" +"..\data\mmc\ThumbnailManagerTest\mp3.mp3" - "e:\testing\data\ThumbnailManagerTest\mp3.mp3" +"..\data\mmc\ThumbnailManagerTest\camera.jpg" - "e:\testing\data\ThumbnailManagerTest\camera.jpg" + diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/tsrc/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/thumbnailmanager_api/tsrc/group/bld.inf Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Thumbnail Manager API tests +* +*/ + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS + +PRJ_MMPFILES + +PRJ_TESTMMPFILES +ThumbnailManagerTest.mmp + +PRJ_TESTEXPORTS +../conf/ThumbnailManagerTest.cfg /epoc32/winscw/c/TestFramework/ThumbnailManagerTest.cfg +../init/ThumbnailManagerTest.ini /epoc32/winscw/c/TestFramework/ThumbnailManagerTest.ini +../data/mmc/ThumbnailManagerTest/8bit_PNG.png /epoc32/winscw/c/data/ThumbnailManagerTest/8bit_PNG.png +../data/mmc/ThumbnailManagerTest/empty_file.bmp /epoc32/winscw/c/data/ThumbnailManagerTest/empty_file.bmp +../data/mmc/ThumbnailManagerTest/not_3gp.3gp /epoc32/winscw/c/data/ThumbnailManagerTest/not_3gp.3gp +../data/mmc/ThumbnailManagerTest/not_jpg.jpg /epoc32/winscw/c/data/ThumbnailManagerTest/not_jpg.jpg +../data/mmc/ThumbnailManagerTest/RGB_400x300.bmp /epoc32/winscw/c/data/ThumbnailManagerTest/RGB_400x300.bmp +../data/mmc/ThumbnailManagerTest/RGB_VGA.jpg /epoc32/winscw/c/data/ThumbnailManagerTest/RGB_VGA.jpg +../data/mmc/ThumbnailManagerTest/SVG_640x480.svg /epoc32/winscw/c/data/ThumbnailManagerTest/SVG_640x480.svg +../data/mmc/ThumbnailManagerTest/TALL_400x800.bmp /epoc32/winscw/c/data/ThumbnailManagerTest/TALL_400x800.bmp +../data/mmc/ThumbnailManagerTest/Tiny_1x1.jpg /epoc32/winscw/c/data/ThumbnailManagerTest/Tiny_1x1.jpg +../data/mmc/ThumbnailManagerTest/Unsupported.txt /epoc32/winscw/c/data/ThumbnailManagerTest/Unsupported.txt +../data/mmc/ThumbnailManagerTest/video.3gp /epoc32/winscw/c/data/ThumbnailManagerTest/video.3gp +../data/mmc/ThumbnailManagerTest/Videoclip.mp4 /epoc32/winscw/c/data/ThumbnailManagerTest/Videoclip.mp4 +../data/mmc/ThumbnailManagerTest/WIDE_800x400.gif /epoc32/winscw/c/data/ThumbnailManagerTest/WIDE_800x400.gif +../data/mmc/ThumbnailManagerTest/TestMBM.mbm /epoc32/winscw/c/data/ThumbnailManagerTest/TestMBM.mbm +../data/mmc/ThumbnailManagerTest/mp3.mp3 /epoc32/winscw/c/data/ThumbnailManagerTest/mp3.mp3 +../data/mmc/ThumbnailManagerTest/camera.jpg /epoc32/winscw/c/data/ThumbnailManagerTest/camera.jpg + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/tsrc/inc/ThumbnailManagerTest.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/thumbnailmanager_api/tsrc/inc/ThumbnailManagerTest.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,213 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Thumbnail Manager API tests +* +*/ + +#ifndef THUMBNAILMANAGERTEST_H +#define THUMBNAILMANAGERTEST_H + +// INCLUDES +#include +#include +#include + +#include +#include +#include +#include + +#include "thumbnailcenrep.h" + +const TInt KPathPrefixLength( 2 ); + +// MACROS +#if ( defined (__WINS__) || defined (__WINSCW__) ) +_LIT( KTMTestDataPath, "" ); +#else +_LIT( KTMTestDataPath, "\\testing" ); +#endif + +// Logging path +_LIT( KThumbnailManagerTestLogPath, "\\logs\\testframework\\ThumbnailManagerTest\\" ); +// Log file +_LIT( KThumbnailManagerTestLogFile, "ThumbnailManagerTest.txt" ); +_LIT( KThumbnailManagerTestLogFileWithTitle, "ThumbnailManagerTest_[%S].txt" ); + +// FORWARD DECLARATIONS +class CThumbnailManagerTest; + +// CLASS DECLARATION + +/** +* CThumbnailManagerTest test class for STIF Test Framework TestScripter. +* ?other_description_lines +* +* @lib ?library +* @since ?Series60_version +*/ +NONSHARABLE_CLASS(CThumbnailManagerTest): public CScriptBase, + public MThumbnailManagerObserver + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CThumbnailManagerTest* NewL( CTestModuleIf& aTestModuleIf ); + + /** + * Destructor. + */ + virtual ~CThumbnailManagerTest(); + + public: // Functions from base classes + + /** + * From CScriptBase Runs a script line. + * @since ?Series60_version + * @param aItem Script line containing method name and parameters + * @return Symbian OS error code + */ + virtual TInt RunMethodL( CStifItemParser& aItem ); + + protected: // Functions from base classes + + /** + * From MThumbnailManagerObserver + */ + void ThumbnailPreviewReady( MThumbnailData& aThumbnail, TThumbnailRequestId aId ); + + void ThumbnailReady( TInt aError, MThumbnailData& aThumbnail, TThumbnailRequestId aId ); + + private: + + /** + * C++ default constructor. + */ + CThumbnailManagerTest( CTestModuleIf& aTestModuleIf ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + /** + * Frees all resources allocated from test methods. + * @since ?Series60_version + */ + void Delete(); + + /** + * Test methods are listed below. + */ + + virtual TInt CreateInstanceL( CStifItemParser& aItem ); + virtual TInt DeleteInstance( CStifItemParser& aItem ); + + virtual TInt CreateSourceInstancePathL( CStifItemParser& aItem ); + virtual TInt CreateSourceInstanceHandleL( CStifItemParser& aItem ); + virtual TInt CreateSourceInstanceBufferL( CStifItemParser& aItem ); + virtual TInt CreateSourceInstanceBitmapL( CStifItemParser& aItem ); + virtual TInt DeleteSourceInstance( CStifItemParser& aItem ); + + virtual TInt GetThumbnailL( CStifItemParser& aItem ); + virtual TInt GetThumbnailByIdL( CStifItemParser& aItem ); + + virtual TInt SetThumbnailL( CStifItemParser& aItem ); + virtual TInt ImportThumbnailL( CStifItemParser& aItem ); + + virtual TInt CheckPreviewThumbnailL( CStifItemParser& aItem ); + virtual TInt CheckThumbnailL( CStifItemParser& aItem ); + virtual TInt CheckThumbnailCenrepL( CStifItemParser& aItem ); + + virtual TInt CancelPrevious( CStifItemParser& aItem ); + virtual TInt ChangePreviousPriority( CStifItemParser& aItem ); + + virtual TInt SetThumbnailSizeL( CStifItemParser& aItem ); + virtual TInt CheckThumbnailSizeL( CStifItemParser& aItem ); + virtual TInt SetThumbnailEnumSizeL( CStifItemParser& aItem ); + virtual TInt SetFlagsL( CStifItemParser& aItem ); + virtual TInt CheckFlags( CStifItemParser& aItem ); + virtual TInt SetQualityPreferenceL( CStifItemParser& aItem ); + virtual TInt CheckQualityPreference( CStifItemParser& aItem ); + virtual TInt SetDisplayModeL( CStifItemParser& aItem ); + virtual TInt CheckDisplayModeL( CStifItemParser& aItem ); + + virtual TInt DeleteThumbnails( CStifItemParser& aItem ); + virtual TInt DeleteThumbnailsByIdL( CStifItemParser& aItem ); + + virtual TInt CreateThumbnails( CStifItemParser& aItem ); + virtual TInt UpdatePathL( CStifItemParser& aItem ); + + virtual TInt GetSupportedMimeTypesL( CStifItemParser& aItem ); + + /** + * Method used to log version of test class + */ + void SendTestClassVersion(); + + private: // Data + + // Own. Thumbnail engine + CThumbnailManager* iEngine; + + // Own. Thumbnail object source + CThumbnailObjectSource* iObjectSource; + + // Own. File server session + RFs iFs; + + // Own. + RFile64 iFile; + + // Own. Bitmap from previous ThumbnailPreviewReady() callback + CFbsBitmap* iPreviewThumbnail; + + // Own. Bitmap from previous ThumbnailReady() callback + CFbsBitmap* iThumbnail; + + // Value for aId for previous ThumbnailPreviewReady() callback + TThumbnailRequestId iPreviewThumbnailCbId; + + // Value for aId for previous ThumbnailReady() callback + TThumbnailRequestId iThumbnailCbId; + + // Request ID of the previous request + TThumbnailRequestId iPreviousRequestId; + + // Test data path + TFileName iDataPath; + + // Temp buffer + HBufC8* iBuffer; + + // Temp bitmap + CFbsBitmap* iBitmap; + + // Own. Central repository data handler + CThumbnailCenRep* iCenrep; + + // persistent sizes + RArray < TThumbnailPersistentSize > iPersistentSizes; + + TThumbnailSize iCurrentThumbnailSize; + + TBool iDoNotCreate; + TBool iCreateThumbnails; + }; + +#endif // THUMBNAILMANAGERTEST_H + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/tsrc/inc/thumbnailcenrep.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/thumbnailmanager_api/tsrc/inc/thumbnailcenrep.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,211 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class for handling central repositoty data + * +*/ + + +#ifndef THUMBNAILCENREP_H +#define THUMBNAILCENREP_H + +#include + +#include // TThumbnailSize + +class CRepository; +class TThumbnailPersistentSize; +class TThumbnailAutoCreate; + +/** + * Class for handling central repositoty data. + * + * @since S60 v5.0 + */ +class CThumbnailCenRep: public CBase + { + +public: + + /** + * Destructor + * + * @since S60 v5.0 + */ + virtual ~CThumbnailCenRep(); + + /** + * Two-phased constructor + * + * @since S60 v5.0 + * @return New CThumbnailCenRep instance. + */ + static CThumbnailCenRep* NewL(); + + /** + * GetPersistentSizes + * + * @since S60 v5.0 + * @return Reference to array of central repository settings + */ + RArray < TThumbnailPersistentSize > & GetPersistentSizes(); + + /** + * GetAutoCreateParams + * + * @since S60 v5.0 + * @return Reference to auto creation settings + */ + TThumbnailAutoCreate & GetAutoCreateParams(); + + /** + * Get concrete persistent size associated to relative size + * + * @since S60 v5.0 + * @param aThumbnailSize Relative size + * @return Persistent size object + */ + TThumbnailPersistentSize & PersistentSizeL( TThumbnailSize + aThumbnailSize ); + +private: + + /** + * C++ default constructor + * + * @since S60 v5.0 + * @return New CThumbnailCenRep instance. + */ + CThumbnailCenRep(); + + /** + * ConstructL + * + * @since S60 v5.0 + */ + void ConstructL(); + +private: + // data + + /** + * Central Repository + * Own. + */ + CRepository* iRepository; + + /** + * Persistent sizes. + */ + RArray < TThumbnailPersistentSize > iPersistentSizes; + + /** + * Auto creation parameters. + */ + TThumbnailAutoCreate * iAutoCreate; + +}; + +/** + * Class for representing persistent thumbnail sizes and related + * parameters. + * + * @since S60 v5.0 + */ +class TThumbnailPersistentSize + { + /** + * Format used for storing bitmaps. + * @since S60 v5.0 + */ + enum TThumbnailImageFormat + { + /** + * Use JPEG compression for stored bitmaps. + */ + EJpeg, + + /** + * Use native Symbian bitmap format for stored bitmaps. + */ + EBmp + }; + +public: + enum { EUnknownSourceType, EImage, EVideo, EAudio }; + enum { EUnknownSizeType, EGrid, EList, EFullscreen }; + +public: + + /** + * C++ constructor. + * + * @since S60 v5.0 + * @param aSize Thumbnail size (in pixels) which will be stored. + * @param aCrop If true, stored thumbnails are cropped to aspect ratio. + * @param aMode Display mode used for stored bitmaps + * @param aFormat Format used when storing thumbnails + */ + TThumbnailPersistentSize( const TSize& aSize, TBool aCrop, TDisplayMode + aMode, TInt aFormat ); + + TThumbnailPersistentSize( TThumbnailSize aType, const TSize& aSize, TBool aCrop, TDisplayMode + aMode, TInt aFormat, TBool aAutoCreate ); + +public: + + // data + TThumbnailSize iType; + TInt iSourceType; + TInt iSizeType; + + TSize iSize; + TBool iCrop; + TDisplayMode iMode; + TInt iFormat; + + TBool iAutoCreate; +}; + +/** + * Class for representing thumbnail auto creation parameters. + * + * @since S60 v5.0 + */ +class TThumbnailAutoCreate + { + +public: + + /** + * C++ constructor. + * + * @since S60 v5.0 + */ + TThumbnailAutoCreate(); + +public: + + // data + TBool iImageGrid; + TBool iImageList; + TBool iImageFullscreen; + TBool iVideoGrid; + TBool iVideoList; + TBool iVideoFullscreen; + TBool iAudioGrid; + TBool iAudioList; + TBool iAudioFullscreen; +}; + +#endif // THUMBNAILCENREP_H diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/tsrc/init/ThumbnailManagerTest.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/thumbnailmanager_api/tsrc/init/ThumbnailManagerTest.ini Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,219 @@ +# +# This is STIF initialization file +# Comment lines start with '#'-character. +# See STIF TestFramework users guide.doc for instructions + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set following test engine settings: +# - Set Test Reporting mode. TestReportMode's possible values are: +# + 'Summary': Summary of the tested test cases. +# + 'Environment': Hardware and software info. +# + 'TestCases': Test case report. +# + 'FullReport': Set of all above ones. +# + Example 'TestReportMode= Summary TestCases' +# +# - CreateTestReport setting controls report creation mode +# + YES, Test report will created. +# + NO, No Test report. +# +# - File path indicates the base path of the test report. +# - File name indicates the name of the test report. +# +# - File format indicates the type of the test report. +# + TXT, Test report file will be txt type, for example 'TestReport.txt'. +# + HTML, Test report will be html type, for example 'TestReport.html'. +# + XML, Test report will be xml type, for example 'TestReport.xml'. +# Note, that xml format is available only when output is set to FILE. +# +# - File output indicates output source of the test report. +# + FILE, Test report logging to file. +# + RDEBUG, Test report logging to using rdebug. +# +# - File Creation Mode indicates test report overwriting if file exist. +# + OVERWRITE, Overwrites if the Test report file exist. +# + APPEND, Continue logging after the old Test report information if +# report exist. +# - Sets a device reset module's dll name(Reboot). +# + If Nokia specific reset module is not available or it is not correct one +# StifHWResetStub module may use as a template for user specific reset +# module. +# - Sets STIF test measurement disable options. e.g. pluging1 and pluging2 disablation +# DisableMeasurement= stifmeasurementplugin01 stifmeasurementplugin02 +# + +[Engine_Defaults] + +TestReportMode= FullReport # Possible values are: 'Empty', 'Summary', 'Environment', + # 'TestCases' or 'FullReport' + +CreateTestReport= YES # Possible values: YES or NO + +TestReportFilePath= C:\LOGS\TestFramework\ +TestReportFileName= TestReport + +TestReportFormat= TXT # Possible values: TXT, HTML or XML +TestReportOutput= FILE # Possible values: FILE or RDEBUG +TestReportFileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +DeviceResetDllName= StifResetForNokia.dll # e.g. 'StifHWResetStub.dll' for user specific reseting + +DisableMeasurement= stifmeasurementdisablenone # Possible values are: + # 'stifmeasurementdisablenone', 'stifmeasurementdisableall' + # 'stifmeasurementplugin01', 'stifmeasurementplugin02', + # 'stifmeasurementplugin03', 'stifmeasurementplugin04', + # 'stifmeasurementplugin05' or 'stifbappeaprofiler' + +Timeout= 180000 # Default timeout value for each test case. In milliseconds +#UITestingSupport= YES # Possible values: YES or NO +#SeparateProcesses= YES # Possible values: YES or NO (default: NO) +[End_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Module configurations start +# Modules are added between module tags +# tags. Module name is specified after ModuleName= tag, like +# ModuleName= XXXXXXXXX +# Modules might have initialisation file, specified as +# IniFile= c:\testframework\YYYYYY +# Modules might have several configuration files, like +# TestCaseFile= c:\testframework\NormalCases.txt +# TestCaseFile= c:\testframework\SmokeCases.txt +# TestCaseFile= c:\testframework\ManualCases.txt + +# (TestCaseFile is synonym for old term ConfigFile) + +# Following case specifies demo module settings. Demo module +# does not read any settings from file, so tags +# IniFile and TestCaseFile are not used. +# In the simplest case it is enough to specify only the +# name of the test module when adding new test module + + +[New_Module] +ModuleName= TestScripter +TestCaseFile= c:\testframework\ThumbnailManagerTest.cfg +[End_Module] + + +# Load testmoduleXXX, optionally with initialization file and/or test case files +#[New_Module] +#ModuleName= testmodulexxx + +#TestModuleXXX used initialization file +#IniFile= c:\testframework\init.txt + +#TestModuleXXX used configuration file(s) +#TestCaseFile= c:\testframework\testcases1.cfg +#TestCaseFile= c:\testframework\testcases2.cfg +#TestCaseFile= c:\testframework\manualtestcases.cfg + +#[End_Module] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set STIF logging overwrite parameters for Logger. +# Hardware and emulator environment logging path and styles can +# be configured from here to overwrite the Logger's implemented values. +# +# Settings description: +# - Indicates option for creation log directory/directories. If log directory/directories +# is/are not created by user they will make by software. +# + YES, Create log directory/directories if not allready exist. +# + NO, Log directory/directories not created. Only created one is used. +# +# - Overwrite emulator path setting. +# + Example: If 'EmulatorBasePath= C:\LOGS\TestFramework\' and in code is defined +# Logger's path 'D:\\LOGS\\Module\\' with those definition the path +# will be 'C:\LOGS\TestFramework\LOGS\Module\' +# +# - Overwrite emulator's logging format. +# + TXT, Log file(s) will be txt type(s), for example 'Module.txt'. +# + HTML, Log file(s) will be html type(s), for example 'Module.html'. +# +# - Overwrited emulator logging output source. +# + FILE, Logging to file(s). +# + RDEBUG, Logging to using rdebug(s). +# +# - Overwrite hardware path setting (Same description as above in emulator path). +# - Overwrite hardware's logging format(Same description as above in emulator format). +# - Overwrite hardware's logging output source(Same description as above in emulator output). +# +# - File Creation Mode indicates file overwriting if file exist. +# + OVERWRITE, Overwrites if file(s) exist. +# + APPEND, Continue logging after the old logging information if file(s) exist. +# +# - Will thread id include to the log filename. +# + YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'. +# + NO, No thread id to log file(s), Example filename 'Module.txt'. +# +# - Will time stamps include the to log file. +# + YES, Time stamp added to each line in log file(s). Time stamp is +# for example'12.Nov.2003 115958 LOGGING INFO' +# + NO, No time stamp(s). +# +# - Will line breaks include to the log file. +# + YES, Each logging event includes line break and next log event is in own line. +# + NO, No line break(s). +# +# - Will event ranking include to the log file. +# + YES, Event ranking number added to each line in log file(s). Ranking number +# depends on environment's tics, for example(includes time stamp also) +# '012 12.Nov.2003 115958 LOGGING INFO' +# + NO, No event ranking. +# +# - Will write log file in unicode format. +# + YES, Log file will be written in unicode format +# + NO, Log will be written as normal, not unicode, file. +# + +[Logger_Defaults] + +#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#' +#NOTE: TestEngine and TestServer logging settings cannot change here + +CreateLogDirectories= YES # Possible values: YES or NO + +#EmulatorBasePath= C:\LOGS\TestFramework\ +#EmulatorFormat= HTML # Possible values: TXT or HTML +#EmulatorOutput= FILE # Possible values: FILE or RDEBUG + +HardwareBasePath= C:\ +#HardwareFormat= HTML # Possible values: TXT or HTML +#HardwareOutput= FILE # Possible values: FILE or RDEBUG + +#FileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +#ThreadIdToLogFile= YES # Possible values: YES or NO +#WithTimeStamp= YES # Possible values: YES or NO +#WithLineBreak= YES # Possible values: YES or NO +#WithEventRanking= YES # Possible values: YES or NO + +#FileUnicode= YES # Possible values: YES or NO +#AddTestCaseTitle= YES # Possible values: YES or NO +[End_Logger_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set filters to be used by ConsoleUI. +# If you want to use filter with ConsoleUI, simply remove comments +# from section below and provide valid filter entries. +# Each filter line has to start with "filter= " keyword. +# Filter can contain special wildcard characters: +# * which stands for none or any literal; +# ? which stands for single character. +# Filters are not case-sensitive. + +#[Filters] +#filter= *math* +#filter= *radio* +#[End_Filters] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + +# End of file diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/tsrc/src/ThumbnailManagerTest.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/thumbnailmanager_api/tsrc/src/ThumbnailManagerTest.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,108 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Thumbnail Manager API tests +* +*/ + +// INCLUDE FILES +#include +#include + +#include + +#include "ThumbnailManagerTest.h" + +// ============================= LOCAL FUNCTIONS =============================== + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CThumbnailManagerTest::CThumbnailManagerTest +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CThumbnailManagerTest::CThumbnailManagerTest( CTestModuleIf& aTestModuleIf ): + CScriptBase( aTestModuleIf ) + { + } + +// ----------------------------------------------------------------------------- +// CThumbnailManagerTest::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CThumbnailManagerTest::ConstructL() + { + iLog = CStifLogger::NewL( KThumbnailManagerTestLogPath, + KThumbnailManagerTestLogFile, + CStifLogger::ETxt, + CStifLogger::EFile, + EFalse ); + + User::LeaveIfError( iFs.Connect()); + User::LeaveIfError( iFs.ShareProtected()); + + // set test data path according to env +#if ( defined (__WINS__) || defined (__WINSCW__) ) + iDataPath.Copy( PathInfo::PhoneMemoryRootPath().Left( KPathPrefixLength )); +#else + iDataPath.Copy( PathInfo::MemoryCardRootPath ().Left( KPathPrefixLength )); +#endif + iDataPath.Append( KTMTestDataPath ); + iDataPath.ZeroTerminate(); + } + +// ----------------------------------------------------------------------------- +// CThumbnailManagerTest::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CThumbnailManagerTest* CThumbnailManagerTest::NewL( CTestModuleIf& aTestModuleIf ) + { + CThumbnailManagerTest* self = new (ELeave) CThumbnailManagerTest( aTestModuleIf ); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + + return self; + } + +// Destructor +CThumbnailManagerTest::~CThumbnailManagerTest() + { + // Delete resources allocated from test methods + Delete(); + + // Delete logger + delete iLog; + + iFs.Close(); + } + +// ========================== OTHER EXPORTED FUNCTIONS ========================= + +// ----------------------------------------------------------------------------- +// LibEntryL is a polymorphic Dll entry point. +// Returns: CScriptBase: New CScriptBase derived object +// ----------------------------------------------------------------------------- +// +EXPORT_C CScriptBase* LibEntryL( CTestModuleIf& aTestModuleIf ) // Backpointer to STIF + { + return ( CScriptBase* ) CThumbnailManagerTest::NewL( aTestModuleIf ); + } + + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/tsrc/src/ThumbnailManagerTestBlocks.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/thumbnailmanager_api/tsrc/src/ThumbnailManagerTestBlocks.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,811 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Thumbnail Manager API tests +* +*/ + +// [INCLUDE FILES] - do not remove +#include +#include +#include + +#include +#include +#include +#include + +#include "ThumbnailManagerTest.h" + + +// ============================= LOCAL FUNCTIONS =============================== + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CThumbnailManagerTest::Delete +// Delete here all resources allocated and opened from test methods. +// Called from destructor. +// ----------------------------------------------------------------------------- +// +void CThumbnailManagerTest::Delete() + { + delete iPreviewThumbnail; + iPreviewThumbnail = NULL; + delete iThumbnail; + iThumbnail = NULL; + delete iEngine; + iEngine = NULL; + delete iObjectSource; + iObjectSource = NULL; + delete iCenrep; + iCenrep = NULL; + } + +// ----------------------------------------------------------------------------- +// CThumbnailManagerTest::RunMethodL +// Run specified method. Contains also table of test mothods and their names. +// ----------------------------------------------------------------------------- +// +TInt CThumbnailManagerTest::RunMethodL( CStifItemParser& aItem ) + { + static TStifFunctionInfo const KFunctions[] = + { + ENTRY( "CreateInstanceL", CThumbnailManagerTest::CreateInstanceL ), + ENTRY( "DeleteInstance", CThumbnailManagerTest::DeleteInstance ), + ENTRY( "SetThumbnailSizeL", CThumbnailManagerTest::SetThumbnailSizeL ), + ENTRY( "CheckThumbnailSizeL", CThumbnailManagerTest::CheckThumbnailSizeL ), + ENTRY( "SetThumbnailEnumSizeL", CThumbnailManagerTest::SetThumbnailEnumSizeL ), + ENTRY( "CreateSourceInstancePathL", CThumbnailManagerTest::CreateSourceInstancePathL ), + ENTRY( "CreateSourceInstanceHandleL", CThumbnailManagerTest::CreateSourceInstanceHandleL ), + ENTRY( "CreateSourceInstanceBufferL", CThumbnailManagerTest::CreateSourceInstanceBufferL ), + ENTRY( "CreateSourceInstanceBitmapL", CThumbnailManagerTest::CreateSourceInstanceBitmapL ), + ENTRY( "DeleteSourceInstance", CThumbnailManagerTest::DeleteSourceInstance ), + ENTRY( "GetThumbnailL", CThumbnailManagerTest::GetThumbnailL ), + ENTRY( "GetThumbnailByIdL", CThumbnailManagerTest::GetThumbnailByIdL ), + ENTRY( "SetThumbnailL", CThumbnailManagerTest::SetThumbnailL ), + ENTRY( "ImportThumbnailL", CThumbnailManagerTest::ImportThumbnailL ), + ENTRY( "CheckPreviewThumbnailL", CThumbnailManagerTest::CheckPreviewThumbnailL ), + ENTRY( "CheckThumbnailL", CThumbnailManagerTest::CheckThumbnailL ), + ENTRY( "CheckThumbnailCenrepL", CThumbnailManagerTest::CheckThumbnailCenrepL ), + ENTRY( "CancelPrevious", CThumbnailManagerTest::CancelPrevious ), + ENTRY( "ChangePreviousPriority", CThumbnailManagerTest::ChangePreviousPriority ), + ENTRY( "SetFlagsL", CThumbnailManagerTest::SetFlagsL ), + ENTRY( "CheckFlags", CThumbnailManagerTest::CheckFlags ), + ENTRY( "SetQualityPreferenceL", CThumbnailManagerTest::SetQualityPreferenceL ), + ENTRY( "CheckQualityPreference", CThumbnailManagerTest::CheckQualityPreference ), + ENTRY( "SetDisplayModeL", CThumbnailManagerTest::SetDisplayModeL ), + ENTRY( "CheckDisplayModeL", CThumbnailManagerTest::CheckDisplayModeL ), + ENTRY( "DeleteThumbnails", CThumbnailManagerTest::DeleteThumbnails ), + ENTRY( "DeleteThumbnailsByIdL", CThumbnailManagerTest::DeleteThumbnailsByIdL ), + ENTRY( "CreateThumbnails", CThumbnailManagerTest::CreateThumbnails ), + ENTRY( "UpdatePathL", CThumbnailManagerTest::UpdatePathL ), + ENTRY( "GetSupportedMimeTypesL", CThumbnailManagerTest::GetSupportedMimeTypesL ) + }; + + const TInt count = sizeof( KFunctions ) / sizeof( TStifFunctionInfo ); + + return RunInternalL( KFunctions, count, aItem ); + } + +TInt CThumbnailManagerTest::CreateInstanceL( CStifItemParser& /*aItem*/ ) + { + _LIT( KPanicTxt, "CreateInstanceL" ); + __ASSERT_ALWAYS( !iEngine, User::Panic( KPanicTxt, 0 )); + + iEngine = CThumbnailManager::NewL( *this ); + + iCenrep = CThumbnailCenRep::NewL(); + iPersistentSizes = iCenrep->GetPersistentSizes(); + + iCurrentThumbnailSize = EUnknownThumbnailSize; + iDoNotCreate = EFalse; + iCreateThumbnails = EFalse; + + return KErrNone; + } + +TInt CThumbnailManagerTest::DeleteInstance( CStifItemParser& /*aItem*/ ) + { + // Bitmaps must be deleted before CThumbnailManager, since + // CThumbnailManager will close the FBS session + delete iPreviewThumbnail; + iPreviewThumbnail = NULL; + delete iThumbnail; + iThumbnail = NULL; + delete iEngine; + iEngine = NULL; + delete iObjectSource; + iObjectSource = NULL; + delete iCenrep; + iCenrep = NULL; + + return KErrNone; + } + +TInt CThumbnailManagerTest::SetThumbnailSizeL( CStifItemParser& aItem ) + { + _LIT( KPanicTxt, "SetThumbnailSizeL" ); + __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 0 )); + + TInt width = 0; + TInt height = 0; + User::LeaveIfError( aItem.GetNextInt( width )); + User::LeaveIfError( aItem.GetNextInt( height )); + iEngine->SetThumbnailSizeL( TSize( width, height )); + return KErrNone; + } + +TInt CThumbnailManagerTest::CheckThumbnailSizeL( CStifItemParser& aItem ) + { + _LIT( KPanicTxt, "CheckThumbnailSize" ); + __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 0 )); + + TInt width = 0; + TInt height = 0; + User::LeaveIfError( aItem.GetNextInt( width )); + User::LeaveIfError( aItem.GetNextInt( height )); + TInt ret = KErrArgument; + TSize size = iEngine->ThumbnailSize(); + + if ( size == TSize( width, height )) + { + ret = KErrNone; + } + + return ret; + } + +TInt CThumbnailManagerTest::SetThumbnailEnumSizeL( CStifItemParser& aItem ) + { + _LIT( KPanicTxt, "SetThumbnailEnumSizeL" ); + __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 0 )); + + TInt enumSize = 0; + User::LeaveIfError( aItem.GetNextInt( enumSize )); + + iEngine->SetThumbnailSizeL( (TThumbnailSize)enumSize ); + iCurrentThumbnailSize = (TThumbnailSize)enumSize; + + return KErrNone; + } + +TInt CThumbnailManagerTest::SetFlagsL( CStifItemParser& aItem ) + { + _LIT( KPanicTxt, "SetFlagsL" ); + __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 0 )); + + TInt flags = 0; + User::LeaveIfError( aItem.GetNextInt( flags )); + + iEngine->SetFlagsL(( CThumbnailManager::TThumbnailFlags )flags ); + + if (flags == CThumbnailManager::EDoNotCreate) + { + iDoNotCreate = ETrue; + } + else + { + iDoNotCreate = EFalse; + } + + return KErrNone; + } + +TInt CThumbnailManagerTest::CheckFlags( CStifItemParser& aItem ) + { + _LIT( KPanicTxt, "CheckFlags" ); + __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 0 )); + + TInt flags = 0; + aItem.GetNextInt( flags ); + + if ( iEngine->Flags() != flags ) + { + return KErrArgument; + } + + return KErrNone; + } + +TInt CThumbnailManagerTest::SetQualityPreferenceL( CStifItemParser& aItem + ) + { + _LIT( KPanicTxt, "SetQualityPreferenceL" ); + __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 0 )); + + TInt qp = 0; + User::LeaveIfError( aItem.GetNextInt( qp )); + + iEngine->SetQualityPreferenceL( (CThumbnailManager::TThumbnailQualityPreference)qp ); + return KErrNone; + } + +TInt CThumbnailManagerTest::CheckQualityPreference( CStifItemParser& + aItem ) + { + _LIT( KPanicTxt, "CheckQualityPreference" ); + __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 0 )); + + TInt qp = 0; + aItem.GetNextInt( qp ); + + if ( iEngine->QualityPreference() != qp ) + { + return KErrArgument; + } + + return KErrNone; + } + +TInt CThumbnailManagerTest::SetDisplayModeL( CStifItemParser& aItem ) + { + _LIT( KPanicTxt, "SetDisplayModeL" ); + __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 0 )); + + TInt displaymode = 0; + User::LeaveIfError( aItem.GetNextInt( displaymode )); + + iEngine->SetDisplayModeL( (TDisplayMode)displaymode ); + return KErrNone; + } + +TInt CThumbnailManagerTest::CheckDisplayModeL( CStifItemParser& aItem ) + { + _LIT( KPanicTxt, "CheckDisplayModeL" ); + __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 0 )); + + TInt displaymode = 0; + User::LeaveIfError( aItem.GetNextInt( displaymode )); + + if ( iEngine->DisplayMode() != displaymode ) + { + return KErrArgument; + } + + return KErrNone; + } + +TInt CThumbnailManagerTest::CreateSourceInstancePathL( CStifItemParser& aItem ) + { + _LIT( KPanicTxt, "CreateSrcPath" ); + __ASSERT_ALWAYS( !iObjectSource, User::Panic( KPanicTxt, 0 )); + + TPtrC path; + User::LeaveIfError( aItem.GetNextString( path )); + + TInt id = 0; + aItem.GetNextInt( id ); + + TFileName filePath( iDataPath ); + filePath.Append( path ); + filePath.ZeroTerminate(); + + iLog->Log( _L( "CreateSourceInstancePathL - path = %S" ), &filePath ); + + delete iObjectSource; + iObjectSource = NULL; + + iObjectSource = CThumbnailObjectSource::NewL( filePath, id ); + return KErrNone; + } + +TInt CThumbnailManagerTest::CreateSourceInstanceHandleL( CStifItemParser& aItem ) + { + _LIT( KPanicTxt, "CreateSrcHandle" ); + __ASSERT_ALWAYS( !iObjectSource, User::Panic( KPanicTxt, 0 )); + + TPtrC path; + User::LeaveIfError( aItem.GetNextString( path )); + + TFileName filePath( iDataPath ); + filePath.Append( path ); + filePath.ZeroTerminate(); + + User::LeaveIfError( iFile.Open( iFs, filePath, EFileShareReadersOrWriters )); + iLog->Log( _L( "CreateSourceInstanceHandleL - path = %S" ), &filePath ); + + delete iObjectSource; + iObjectSource = NULL; + iObjectSource = CThumbnailObjectSource::NewL( iFile ); + return KErrNone; + } + +TInt CThumbnailManagerTest::CreateSourceInstanceBufferL( CStifItemParser& aItem ) + { + _LIT( KPanicTxt, "CreateSrcBuffer" ); + __ASSERT_ALWAYS( !iObjectSource, User::Panic( KPanicTxt, 0 )); + + TPtrC path; + User::LeaveIfError( aItem.GetNextString( path )); + + TPtrC mimeType; + User::LeaveIfError( aItem.GetNextString( mimeType )); + + TFileName filePath( iDataPath ); + filePath.Append( path ); + filePath.ZeroTerminate(); + + User::LeaveIfError( iFile.Open( iFs, filePath, EFileShareReadersOrWriters )); + iLog->Log( _L( "CreateSourceInstanceBufferL - path = %S" ), &filePath ); + + TInt64 size; + User::LeaveIfError( iFile.Size( size ) ); + iBuffer = HBufC8::NewL( size ); + TPtr8 ptr = iBuffer->Des(); + iFile.Read( ptr ); + iFile.Close(); + + delete iObjectSource; + iObjectSource = NULL; + iObjectSource = CThumbnailObjectSource::NewL( iBuffer, mimeType, filePath ); + + iBuffer = NULL; + return KErrNone; + } + +TInt CThumbnailManagerTest::CreateSourceInstanceBitmapL( CStifItemParser& aItem ) + { + _LIT( KPanicTxt, "CreateSrcBuffer" ); + __ASSERT_ALWAYS( !iObjectSource, User::Panic( KPanicTxt, 0 )); + + TPtrC path; + User::LeaveIfError( aItem.GetNextString( path )); + + TFileName filePath( iDataPath ); + filePath.Append( path ); + filePath.ZeroTerminate(); + + TPtrC target; + User::LeaveIfError( aItem.GetNextString( target )); + + TFileName targetPath( iDataPath ); + targetPath.Append( target ); + targetPath.ZeroTerminate(); + + iLog->Log( _L( "CreateSourceInstanceBitmapL - bitmap = %S" ), &filePath ); + iLog->Log( _L( "CreateSourceInstanceBitmapL - target = %S" ), &targetPath ); + + iBitmap = new (ELeave) CFbsBitmap(); + User::LeaveIfError(iBitmap->Load(filePath, 0)); + + delete iObjectSource; + iObjectSource = NULL; + iObjectSource = CThumbnailObjectSource::NewL( iBitmap, targetPath ); + + return KErrNone; + } + +TInt CThumbnailManagerTest::DeleteSourceInstance( CStifItemParser& /*aItem*/ ) + { + delete iObjectSource; + iObjectSource = NULL; + return KErrNone; + } + +TInt CThumbnailManagerTest::GetThumbnailL( CStifItemParser& aItem ) + { + _LIT( KPanicTxt, "GetThumbnailL" ); + __ASSERT_ALWAYS( iObjectSource, User::Panic( KPanicTxt, 0 )); + __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 1 )); + + TInt clientData = NULL; + TInt priority = 0; + + TInt err = aItem.GetNextInt( clientData ); + if ( !err ) + { + aItem.GetNextInt( priority ); + } + + iPreviousRequestId = iEngine->GetThumbnailL( *iObjectSource, ( TAny* ) + clientData, priority ); + iLog->Log( _L( "GetThumbnailL - request id %d" ), iPreviousRequestId ); + + if (!iDoNotCreate) + { + iCreateThumbnails = EFalse; + } + + return KErrNone; + } + +TInt CThumbnailManagerTest::GetThumbnailByIdL( CStifItemParser& aItem ) + { + _LIT( KPanicTxt, "GetThumbnailByIdL" ); + __ASSERT_ALWAYS( iObjectSource, User::Panic( KPanicTxt, 0 )); + __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 1 )); + + TInt id = 0; + TInt clientData = NULL; + TInt priority = 0; + + User::LeaveIfError( aItem.GetNextInt( id )); + TInt err = aItem.GetNextInt( clientData ); + if ( !err ) + { + aItem.GetNextInt( priority ); + } + + iPreviousRequestId = iEngine->GetThumbnailL( id, (TAny*)clientData, priority ); + iLog->Log( _L( "GetThumbnailByIdL - request id %d" ), iPreviousRequestId ); + + if (!iDoNotCreate) + { + iCreateThumbnails = EFalse; + } + + return KErrNone; + } + +TInt CThumbnailManagerTest::SetThumbnailL( CStifItemParser& aItem ) + { + _LIT( KPanicTxt, "SetThumbnailL" ); + __ASSERT_ALWAYS( iObjectSource, User::Panic( KPanicTxt, 0 )); + __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 1 )); + + TInt clientData = NULL; + TInt priority = 0; + + TInt err = aItem.GetNextInt( clientData ); + if ( !err ) + { + aItem.GetNextInt( priority ); + } + + iPreviousRequestId = iEngine->SetThumbnailL( *iObjectSource, ( TAny* ) + clientData, priority ); + iLog->Log( _L( "SetThumbnailL - request id %d" ), iPreviousRequestId ); + + if (!iDoNotCreate) + { + iCreateThumbnails = EFalse; + } + + return KErrNone; + } + +TInt CThumbnailManagerTest::ImportThumbnailL( CStifItemParser& aItem ) + { + _LIT( KPanicTxt, "ImportThumbnailL" ); + __ASSERT_ALWAYS( iObjectSource, User::Panic( KPanicTxt, 0 )); + __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 1 )); + + TInt clientData = NULL; + TInt priority = 0; + TPtrC path; + + User::LeaveIfError( aItem.GetNextString( path )); + + TFileName filePath( iDataPath ); + filePath.Append( path ); + filePath.ZeroTerminate(); + + TInt err = aItem.GetNextInt( clientData ); + if ( !err ) + { + aItem.GetNextInt( priority ); + } + + iPreviousRequestId = iEngine->ImportThumbnailL( *iObjectSource, filePath, + (TAny*)clientData, priority ); + iLog->Log( _L( "ImportThumbnailL - request id %d" ), iPreviousRequestId ); + + if (!iDoNotCreate) + { + iCreateThumbnails = EFalse; + } + + return KErrNone; + } + +void CThumbnailManagerTest::ThumbnailPreviewReady( MThumbnailData& + aThumbnail, TThumbnailRequestId aId ) + { + iLog->Log( _L( "ThumbnailPreviewReady aId=%d" ), aId ); + delete iPreviewThumbnail; + iPreviewThumbnail = aThumbnail.DetachBitmap(); + iPreviewThumbnailCbId = aId; + Signal( KErrNone ); + } + +void CThumbnailManagerTest::ThumbnailReady( TInt aError, MThumbnailData& + aThumbnail, TThumbnailRequestId aId ) + { + iLog->Log( _L( "ThumbnailReady aError=%d aId=%d" ), aError, aId ); + delete iThumbnail; + iThumbnail = aThumbnail.DetachBitmap(); + iThumbnailCbId = aId; + + // ignore KErrNotFound, if auto create disabled (CreateThumbnails used) + if (aError == KErrNotFound && iCreateThumbnails) + { + for ( TInt i = 0 ; i < iPersistentSizes.Count(); i++ ) + { + if ( iPersistentSizes[i].iType == iCurrentThumbnailSize && + !iPersistentSizes[i].iAutoCreate ) + { + aError = KErrNone; + break; + } + } + } + + Signal( aError ); + } + +TInt CThumbnailManagerTest::CheckPreviewThumbnailL( CStifItemParser& aItem ) + { + if ( iPreviewThumbnail ) + { + TInt width = 0; + TInt height = 0; + TInt displaymode = 0; + User::LeaveIfError( aItem.GetNextInt( width )); + User::LeaveIfError( aItem.GetNextInt( height )); + User::LeaveIfError( aItem.GetNextInt( displaymode )); + TSize size = iPreviewThumbnail->SizeInPixels(); + iLog->Log( _L( + "CheckPreviewThumbnailL - bitmap size %dx%d (expecting %dx%d)" ), + size.iWidth, size.iHeight, width, height ); + iLog->Log( _L( "CheckPreviewThumbnailL - bitmap mode %d (expecting %d)" + ), iPreviewThumbnail->DisplayMode(), displaymode ); + if ( size != TSize( width, height )) + { + iLog->Log( _L( "CheckPreviewThumbnailL - size mismatch" )); + User::Leave( KErrArgument ); + } + else if ( displaymode != iPreviewThumbnail->DisplayMode()) + { + iLog->Log( _L( "CheckPreviewThumbnailL - displaymode mismatch" )); + User::Leave( KErrArgument ); + } + else + { + iLog->Log( _L( "CheckPreviewThumbnailL - ok" )); + } + } + else + { + // Bitmap missing + iLog->Log( _L( "CheckPreviewThumbnailL - preview bitmap NULL" )); + User::Leave( KErrUnknown ); + } + return KErrNone; + } + +TInt CThumbnailManagerTest::CheckThumbnailL( CStifItemParser& aItem ) + { + if ( iThumbnail ) + { + TInt width = 0; + TInt height = 0; + TInt displaymode = 0; + User::LeaveIfError( aItem.GetNextInt( width )); + User::LeaveIfError( aItem.GetNextInt( height )); + User::LeaveIfError( aItem.GetNextInt( displaymode )); + TSize size = iThumbnail->SizeInPixels(); + iLog->Log( _L( "CheckThumbnailL - bitmap size %dx%d (expecting %dx%d)" ) + , size.iWidth, size.iHeight, width, height ); + iLog->Log( _L( "CheckThumbnailL - bitmap mode %d (expecting %d)" ), + iThumbnail->DisplayMode(), displaymode ); + + // one needs to match, aspect ratio scaling makes this difficult... + if ( size.iWidth != width && size.iHeight != height ) + { + iLog->Log( _L( "CheckThumbnailL - size mismatch" )); + User::Leave( KErrArgument ); + } + else if ( displaymode != iThumbnail->DisplayMode()) + { + iLog->Log( _L( "CheckThumbnailL - displaymode mismatch" )); + } + else + { + iLog->Log( _L( "CheckThumbnailL - ok" )); + } + } + else + { + // Bitmap missing + iLog->Log( _L( "CheckThumbnailL - bitmap NULL" )); + User::Leave( KErrNotFound ); + } + return KErrNone; + } + +TInt CThumbnailManagerTest::CheckThumbnailCenrepL( CStifItemParser& aItem ) + { + TInt err = KErrNone; + TBool full = EFalse; + + TInt sizeType; + TInt displaymode = 0; + User::LeaveIfError( aItem.GetNextInt( sizeType )); + User::LeaveIfError( aItem.GetNextInt( displaymode )); + + TThumbnailSize size = (TThumbnailSize)sizeType; + if (size == EImageFullScreenThumbnailSize || + size == EVideoFullScreenThumbnailSize || + size == EAudioFullScreenThumbnailSize) + { + full = ETrue; + } + + if ( iThumbnail ) + { + TInt width = 0; + TInt height = 0; + + for ( TInt i = 0 ; i < iPersistentSizes.Count(); i++ ) + { + if ( iPersistentSizes[i].iType == size ) + { + width = iPersistentSizes[i].iSize.iWidth; + height = iPersistentSizes[i].iSize.iHeight; + break; + } + } + + TSize thumbSize = iThumbnail->SizeInPixels(); + + iLog->Log( _L( "CheckThumbnailCenrepL - bitmap size %dx%d (expecting %dx%d)" ) + , thumbSize.iWidth, thumbSize.iHeight, width, height ); + iLog->Log( _L( "CheckThumbnailCenrepL - bitmap mode %d (expecting %d)" ), + iThumbnail->DisplayMode(), displaymode ); + + // one needs to match, and both need to be smaller than cenrep value + if ( (thumbSize.iWidth == width || thumbSize.iHeight == height) && + thumbSize.iWidth <= width && thumbSize.iHeight <= height) + { + iLog->Log( _L( "CheckThumbnailCenrepL - ok" )); + } + else if (full && (thumbSize.iWidth <= width && thumbSize.iHeight <= height)) + { + iLog->Log( _L( "CheckThumbnailCenrepL - fullscreen ok, not upscaled" )); + } + else + { + iLog->Log( _L( "CheckThumbnailCenrepL - size mismatch" )); + err = KErrArgument; + } + + // check display mode + if ( displaymode != iThumbnail->DisplayMode()) + { + iLog->Log( _L( "CheckThumbnailCenrepL - displaymode mismatch" )); + err = KErrArgument; + } + } + else + { + for ( TInt i = 0 ; i < iPersistentSizes.Count(); i++ ) + { + if ( iPersistentSizes[i].iType == size && iPersistentSizes[i].iAutoCreate) + { + // Bitmap missing + iLog->Log( _L( "CheckThumbnailCenrepL - bitmap NULL" )); + err = KErrNotFound; + break; + } + } + } + + return err; + } + +TInt CThumbnailManagerTest::CancelPrevious( CStifItemParser& /*aItem*/ ) + { + _LIT( KPanicTxt, "CancelPrevious" ); + __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 0 )); + + TInt err = iEngine->CancelRequest( iPreviousRequestId ); + iLog->Log( _L( "CancelPrevious() returned %d" ), err ); + return err; + } + +TInt CThumbnailManagerTest::ChangePreviousPriority( CStifItemParser& + aItem ) + { + _LIT( KPanicTxt, "ChangePreviousPriority" ); + __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 0 )); + + TInt priority = 0; + aItem.GetNextInt( priority ); + + TInt err = iEngine->ChangePriority( iPreviousRequestId, priority ); + iLog->Log( _L( "ChangePriority() returned %d" ), err ); + return err; + } + + +TInt CThumbnailManagerTest::DeleteThumbnails( CStifItemParser& /*aItem*/ ) + { + iEngine->DeleteThumbnails( *iObjectSource ); + return KErrNone; + } + +TInt CThumbnailManagerTest::DeleteThumbnailsByIdL( CStifItemParser& aItem ) + { + TInt id = 0; + User::LeaveIfError( aItem.GetNextInt( id )); + + iEngine->DeleteThumbnails( id ); + return KErrNone; + } + + +TInt CThumbnailManagerTest::CreateThumbnails( CStifItemParser& aItem ) + { + _LIT( KPanicTxt, "CreateThumbnails" ); + __ASSERT_ALWAYS( iObjectSource, User::Panic( KPanicTxt, 0 )); + __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 1 )); + + TInt priority = 0; + + aItem.GetNextInt( priority ); + + TInt id; + id = iEngine->CreateThumbnails( *iObjectSource, priority ); + if (id < 0) + { + iLog->Log( _L( "CreateThumbnails - error %d" ), id ); + return id; + } + else + { + iPreviousRequestId = id; + iLog->Log( _L( "CreateThumbnails - request id %d" ), iPreviousRequestId ); + } + + iCreateThumbnails = ETrue; + + return KErrNone; + } + +TInt CThumbnailManagerTest::UpdatePathL( CStifItemParser& aItem ) + { + _LIT( KPanicTxt, "UpdatePath" ); + __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 0 )); + + TInt id = 0; + TPtrC path; + User::LeaveIfError( aItem.GetNextInt( id )); + User::LeaveIfError( aItem.GetNextString( path )); + + TFileName filePath( iDataPath ); + filePath.Append( path ); + filePath.ZeroTerminate(); + + iLog->Log( _L( "UpdatePath - path = %S" ), &filePath ); + + iEngine->UpdateThumbnailsL(id, filePath, 0, 1000, CActive::EPriorityIdle); + + return KErrNone; + } + +TInt CThumbnailManagerTest::GetSupportedMimeTypesL( CStifItemParser& /*aItem*/ ) + { + _LIT( KPanicTxt, "GetSupportedMimeTypesL" ); + __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 0 )); + + iEngine->GetSupportedMimeTypesL(); + + return KErrNone; + } + + +// ========================== OTHER EXPORTED FUNCTIONS ========================= +// None + +// [End of File] - Do not remove diff -r 000000000000 -r 2014ca87e772 imagehandling_plat/thumbnailmanager_api/tsrc/src/thumbnailcenrep.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandling_plat/thumbnailmanager_api/tsrc/src/thumbnailcenrep.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,286 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class for handling central repositoty data + * +*/ + + +#include +#include + +#include "thumbnailcenrep.h" + + +#define THUMBNAIL_CENREP_UID 0x102830B0 + +const TUint32 KSizeImageGridWidth = 0x0; +const TUint32 KSizeImageGridHeight = 0x1; +const TUint32 KSizeImageListWidth = 0x2; +const TUint32 KSizeImageListHeight = 0x3; +const TUint32 KSizeImageFullscreenWidth = 0x4; +const TUint32 KSizeImageFullscreenHeight = 0x5; +const TUint32 KSizeVideoGridWidth = 0x6; +const TUint32 KSizeVideoGridHeight = 0x7; +const TUint32 KSizeVideoListWidth = 0x8; +const TUint32 KSizeVideoListHeight = 0x9; +const TUint32 KSizeVideoFullscreenWidth = 0x10; +const TUint32 KSizeVideoFullscreenHeight = 0x11; +const TUint32 KSizeAudioGridWidth = 0x12; +const TUint32 KSizeAudioGridHeight = 0x13; +const TUint32 KSizeAudioListWidth = 0x14; +const TUint32 KSizeAudioListHeight = 0x15; +const TUint32 KSizeAudioFullscreenWidth = 0x16; +const TUint32 KSizeAudioFullscreenHeight = 0x17; + +const TUint32 KAutoCreateImageGrid = 0x100; +const TUint32 KAutoCreateImageList = 0x101; +const TUint32 KAutoCreateImageFullscreen = 0x102; +const TUint32 KAutoCreateVideoGrid = 0x103; +const TUint32 KAutoCreateVideoList = 0x104; +const TUint32 KAutoCreateVideoFullscreen = 0x105; +const TUint32 KAutoCreateAudioGrid = 0x106; +const TUint32 KAutoCreateAudioList = 0x107; +const TUint32 KAutoCreateAudioFullscreen = 0x108; + + +// --------------------------------------------------------------------------- +// TThumbnailPersistentSize::TThumbnailPersistentSize +// --------------------------------------------------------------------------- +// +TThumbnailPersistentSize::TThumbnailPersistentSize( const TSize& aSize, TBool + aCrop, TDisplayMode aMode, TInt aFormat ): iSize( aSize ), iCrop( aCrop ), + iMode( aMode ), iFormat( aFormat ) + { + iType = EUnknownThumbnailSize; + iSourceType = EUnknownSourceType; + iAutoCreate = ETrue; + } + +// --------------------------------------------------------------------------- +// TThumbnailPersistentSize::TThumbnailPersistentSize +// --------------------------------------------------------------------------- +// +TThumbnailPersistentSize::TThumbnailPersistentSize( TThumbnailSize aType, + const TSize& aSize, TBool aCrop, TDisplayMode aMode, TInt aFormat, + TBool aAutoCreate ) + : iType( aType ), iSize( aSize ), iCrop( aCrop ), iMode( aMode ), + iFormat( aFormat ), iAutoCreate( aAutoCreate ) + { + switch ( aType ) + { + case EImageGridThumbnailSize: + case EImageListThumbnailSize: + case EImageFullScreenThumbnailSize: + iSourceType = EImage; + break; + case EVideoGridThumbnailSize: + case EVideoListThumbnailSize: + case EVideoFullScreenThumbnailSize: + iSourceType = EVideo; + break; + case EAudioGridThumbnailSize: + case EAudioListThumbnailSize: + case EAudioFullScreenThumbnailSize: + iSourceType = EAudio; + break; + default: + iSourceType = EUnknownSourceType; + } + + } + +// --------------------------------------------------------------------------- +// TThumbnailAutoCreate::TThumbnailAutoCreate +// --------------------------------------------------------------------------- +// +TThumbnailAutoCreate::TThumbnailAutoCreate() + : iImageGrid(EFalse), iImageList(EFalse), iImageFullscreen(EFalse), + iVideoGrid(EFalse), iVideoList(EFalse), iVideoFullscreen(EFalse), + iAudioGrid(EFalse), iAudioList(EFalse), iAudioFullscreen(EFalse) + { + // No implementation required + } + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CThumbnailCenRep::CThumbnailCenRep() +// C++ default constructor can NOT contain any code, that might leave. +// --------------------------------------------------------------------------- +// +CThumbnailCenRep::CThumbnailCenRep() + { + // No implementation required + } + + +// --------------------------------------------------------------------------- +// CThumbnailCenRep::~CThumbnailCenRep() +// Destructor. +// --------------------------------------------------------------------------- +// +CThumbnailCenRep::~CThumbnailCenRep() + { + iPersistentSizes.Close(); + delete iAutoCreate; + delete iRepository; + } + +// --------------------------------------------------------------------------- +// CThumbnailCenRep::NewL() +// Two-phased constructor. +// --------------------------------------------------------------------------- +// +CThumbnailCenRep* CThumbnailCenRep::NewL() + { + CThumbnailCenRep* self = new( ELeave )CThumbnailCenRep(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------------------------- +// CThumbnailCenRep::ConstructL() +// Returns id of specific task. +// --------------------------------------------------------------------------- +// +void CThumbnailCenRep::ConstructL() + { + iRepository = CRepository::NewL( TUid::Uid( THUMBNAIL_CENREP_UID )); + + TInt xSize( 0 ); + TInt ySize( 0 ); + TBool flags( EFalse ); + const TBool KGridAndListThumbnailCropped = ETrue; + TInt raw_mode( EColor16M ); // always 16-bit + TInt format( 0 ); + TBool autoCreate( EFalse ); + + User::LeaveIfError( iRepository->Get( KSizeImageGridWidth, xSize )); + User::LeaveIfError( iRepository->Get( KSizeImageGridHeight, ySize )); + User::LeaveIfError( iRepository->Get( KAutoCreateImageGrid, autoCreate )); + + iPersistentSizes.AppendL( TThumbnailPersistentSize( EImageGridThumbnailSize, TSize( xSize, ySize ), + KGridAndListThumbnailCropped, static_cast (raw_mode), format, autoCreate )); + + User::LeaveIfError( iRepository->Get( KSizeImageListWidth, xSize )); + User::LeaveIfError( iRepository->Get( KSizeImageListHeight, ySize )); + User::LeaveIfError( iRepository->Get( KAutoCreateImageList, autoCreate )); + + iPersistentSizes.AppendL( TThumbnailPersistentSize( EImageListThumbnailSize, TSize( xSize, ySize ), + KGridAndListThumbnailCropped, static_cast (raw_mode), format, autoCreate )); + + User::LeaveIfError( iRepository->Get( KSizeImageFullscreenWidth, xSize )); + User::LeaveIfError( iRepository->Get( KSizeImageFullscreenHeight, ySize )); + User::LeaveIfError( iRepository->Get( KAutoCreateImageFullscreen, autoCreate )); + + iPersistentSizes.AppendL( TThumbnailPersistentSize( EImageFullScreenThumbnailSize, TSize( xSize, ySize ), + flags, static_cast (raw_mode), format, autoCreate )); + + User::LeaveIfError( iRepository->Get( KSizeVideoGridWidth, xSize )); + User::LeaveIfError( iRepository->Get( KSizeVideoGridHeight, ySize )); + User::LeaveIfError( iRepository->Get( KAutoCreateVideoGrid, autoCreate )); + + iPersistentSizes.AppendL( TThumbnailPersistentSize( EVideoGridThumbnailSize, TSize( xSize, ySize ), + KGridAndListThumbnailCropped, static_cast (raw_mode), format, autoCreate )); + + User::LeaveIfError( iRepository->Get( KSizeVideoListWidth, xSize )); + User::LeaveIfError( iRepository->Get( KSizeVideoListHeight, ySize )); + User::LeaveIfError( iRepository->Get( KAutoCreateVideoList, autoCreate )); + + iPersistentSizes.AppendL( TThumbnailPersistentSize( EVideoListThumbnailSize, TSize( xSize, ySize ), + KGridAndListThumbnailCropped, static_cast (raw_mode), format, autoCreate )); + + User::LeaveIfError( iRepository->Get( KSizeVideoFullscreenWidth, xSize )); + User::LeaveIfError( iRepository->Get( KSizeVideoFullscreenHeight, ySize )); + User::LeaveIfError( iRepository->Get( KAutoCreateVideoFullscreen, autoCreate )); + + iPersistentSizes.AppendL( TThumbnailPersistentSize( EVideoFullScreenThumbnailSize, TSize( xSize, ySize ), + flags, static_cast (raw_mode), format, autoCreate )); + + User::LeaveIfError( iRepository->Get( KSizeAudioGridWidth, xSize )); + User::LeaveIfError( iRepository->Get( KSizeAudioGridHeight, ySize )); + User::LeaveIfError( iRepository->Get( KAutoCreateAudioGrid, autoCreate )); + + iPersistentSizes.AppendL( TThumbnailPersistentSize( EAudioGridThumbnailSize, TSize( xSize, ySize ), + KGridAndListThumbnailCropped, static_cast (raw_mode), format, autoCreate )); + + User::LeaveIfError( iRepository->Get( KSizeAudioListWidth, xSize )); + User::LeaveIfError( iRepository->Get( KSizeAudioListHeight, ySize )); + User::LeaveIfError( iRepository->Get( KAutoCreateAudioList, autoCreate )); + + iPersistentSizes.AppendL( TThumbnailPersistentSize( EAudioListThumbnailSize, TSize( xSize, ySize ), + KGridAndListThumbnailCropped, static_cast (raw_mode), format, autoCreate )); + + User::LeaveIfError( iRepository->Get( KSizeAudioFullscreenWidth, xSize )); + User::LeaveIfError( iRepository->Get( KSizeAudioFullscreenHeight, ySize )); + User::LeaveIfError( iRepository->Get( KAutoCreateAudioFullscreen, autoCreate )); + + iPersistentSizes.AppendL( TThumbnailPersistentSize( EAudioFullScreenThumbnailSize, TSize( xSize, ySize ), + flags, static_cast (raw_mode), format, autoCreate )); + + iAutoCreate = new (ELeave) TThumbnailAutoCreate(); + + User::LeaveIfError( iRepository->Get( KAutoCreateImageGrid, iAutoCreate->iImageGrid )); + User::LeaveIfError( iRepository->Get( KAutoCreateImageList, iAutoCreate->iImageList )); + User::LeaveIfError( iRepository->Get( KAutoCreateImageFullscreen, iAutoCreate->iImageFullscreen )); + User::LeaveIfError( iRepository->Get( KAutoCreateVideoGrid, iAutoCreate->iVideoGrid )); + User::LeaveIfError( iRepository->Get( KAutoCreateVideoList, iAutoCreate->iVideoList )); + User::LeaveIfError( iRepository->Get( KAutoCreateVideoFullscreen, iAutoCreate->iVideoFullscreen )); + User::LeaveIfError( iRepository->Get( KAutoCreateAudioGrid, iAutoCreate->iAudioGrid )); + User::LeaveIfError( iRepository->Get( KAutoCreateAudioList, iAutoCreate->iAudioList )); + User::LeaveIfError( iRepository->Get( KAutoCreateAudioFullscreen, iAutoCreate->iAudioFullscreen )); + } + +// --------------------------------------------------------------------------- +// CThumbnailCenRep::GetPersistentSizes() +// --------------------------------------------------------------------------- +// +RArray < TThumbnailPersistentSize > & CThumbnailCenRep::GetPersistentSizes() + { + return iPersistentSizes; + } + +// --------------------------------------------------------------------------- +// CThumbnailCenRep::GetAutoCreateParams() +// --------------------------------------------------------------------------- +// +TThumbnailAutoCreate & CThumbnailCenRep::GetAutoCreateParams() + { + return *iAutoCreate; + } + +TThumbnailPersistentSize & CThumbnailCenRep::PersistentSizeL( TThumbnailSize + aThumbnailSize ) + { + TThumbnailPersistentSize* persistentSize = NULL; + TInt i = iPersistentSizes.Count(); + for ( ; --i >= 0; ) + { + persistentSize = &iPersistentSizes[i]; + if ( persistentSize->iType == aThumbnailSize ) + { + break; + } + } + if ( i < 0 ) + { // size not found + User::Leave( KErrNotFound ); + } + + return *persistentSize; + } + +// End of file diff -r 000000000000 -r 2014ca87e772 imagehandlinglib/BWINS/IHLU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlinglib/BWINS/IHLU.DEF Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,23 @@ +EXPORTS + ?CopyBitmapL@IHLBitmapUtil@@SAPAVCFbsBitmap@@ABV2@@Z @ 1 NONAME ; class CFbsBitmap * IHLBitmapUtil::CopyBitmapL(class CFbsBitmap const &) + ?CopyBitmapL@IHLBitmapUtil@@SAPAVCFbsBitmap@@ABV2@ABVTRect@@@Z @ 2 NONAME ; class CFbsBitmap * IHLBitmapUtil::CopyBitmapL(class CFbsBitmap const &, class TRect const &) + ?CopyBitmapLC@IHLBitmapUtil@@SAPAVCFbsBitmap@@ABV2@@Z @ 3 NONAME ; class CFbsBitmap * IHLBitmapUtil::CopyBitmapLC(class CFbsBitmap const &) + ?CopyBitmapLC@IHLBitmapUtil@@SAPAVCFbsBitmap@@ABV2@ABVTRect@@@Z @ 4 NONAME ; class CFbsBitmap * IHLBitmapUtil::CopyBitmapLC(class CFbsBitmap const &, class TRect const &) + ?CreateBitmapProcessorL@IHLProcessorFactory@@SAPAVMIHLBitmapProcessor@@K@Z @ 5 NONAME ; class MIHLBitmapProcessor * IHLProcessorFactory::CreateBitmapProcessorL(unsigned long) + ?CreateImageViewerL@IHLViewerFactory@@SAPAVMIHLImageViewer@@ABVTSize@@AAVMIHLImage@@AAVMIHLBitmap@@AAVMIHLViewerObserver@@K@Z @ 6 NONAME ; class MIHLImageViewer * IHLViewerFactory::CreateImageViewerL(class TSize const &, class MIHLImage &, class MIHLBitmap &, class MIHLViewerObserver &, unsigned long) + ?CreateL@IHLBitmap@@SAPAVMIHLBitmap@@XZ @ 7 NONAME ; class MIHLBitmap * IHLBitmap::CreateL(void) + ?CreateL@IHLScaler@@SAPAVMIHLScaler@@K@Z @ 8 NONAME ; class MIHLScaler * IHLScaler::CreateL(unsigned long) + ?DuplicateBitmapL@IHLBitmapUtil@@SAPAVCFbsBitmap@@ABV2@@Z @ 9 NONAME ; class CFbsBitmap * IHLBitmapUtil::DuplicateBitmapL(class CFbsBitmap const &) + ?DuplicateBitmapLC@IHLBitmapUtil@@SAPAVCFbsBitmap@@ABV2@@Z @ 10 NONAME ; class CFbsBitmap * IHLBitmapUtil::DuplicateBitmapLC(class CFbsBitmap const &) + ?OpenFileImageL@IHLImageFactory@@SAPAVMIHLFileImage@@AAVRFile@@@Z @ 11 NONAME ; class MIHLFileImage * IHLImageFactory::OpenFileImageL(class RFile &) + ?OpenFileImageL@IHLImageFactory@@SAPAVMIHLFileImage@@AAVRFile@@H@Z @ 12 NONAME ; class MIHLFileImage * IHLImageFactory::OpenFileImageL(class RFile &, int) + ?OpenFileImageL@IHLImageFactory@@SAPAVMIHLFileImage@@AAVRFs@@ABVTDesC16@@@Z @ 13 NONAME ; class MIHLFileImage * IHLImageFactory::OpenFileImageL(class RFs &, class TDesC16 const &) + ?OpenFileImageL@IHLImageFactory@@SAPAVMIHLFileImage@@AAVRFs@@ABVTDesC16@@H@Z @ 14 NONAME ; class MIHLFileImage * IHLImageFactory::OpenFileImageL(class RFs &, class TDesC16 const &, int) + ?ScaleBitmap@IHLBitmapUtil@@SAHABVCFbsBitmap@@AAV2@K@Z @ 15 NONAME ; int IHLBitmapUtil::ScaleBitmap(class CFbsBitmap const &, class CFbsBitmap &, unsigned long) + ?ScaleBitmap@IHLBitmapUtil@@SAHABVCFbsBitmap@@ABVTRect@@AAV2@1K@Z @ 16 NONAME ; int IHLBitmapUtil::ScaleBitmap(class CFbsBitmap const &, class TRect const &, class CFbsBitmap &, class TRect const &, unsigned long) + ?OpenFileImageL@IHLImageFactory@@SAPAVMIHLFileImage@@AAVRFile@@HK@Z @ 17 NONAME ; class MIHLFileImage * IHLImageFactory::OpenFileImageL(class RFile &, int, unsigned long) + ?OpenFileImageL@IHLImageFactory@@SAPAVMIHLFileImage@@AAVRFs@@ABVTDesC16@@HK@Z @ 18 NONAME ; class MIHLFileImage * IHLImageFactory::OpenFileImageL(class RFs &, class TDesC16 const &, int, unsigned long) + ?OpenBufferedFileImageL@IHLImageFactory@@SAPAVMIHLFileImage@@AAVRFs@@ABVTDesC8@@@Z @ 19 NONAME ; class MIHLFileImage * IHLImageFactory::OpenBufferedFileImageL(class RFs &, class TDesC8 const &) + ?OpenBufferedFileImageL@IHLImageFactory@@SAPAVMIHLFileImage@@AAVRFs@@ABVTDesC8@@H@Z @ 20 NONAME ; class MIHLFileImage * IHLImageFactory::OpenBufferedFileImageL(class RFs &, class TDesC8 const &, int) + ?OpenBufferedFileImageL@IHLImageFactory@@SAPAVMIHLFileImage@@AAVRFs@@ABVTDesC8@@HK@Z @ 21 NONAME ; class MIHLFileImage * IHLImageFactory::OpenBufferedFileImageL(class RFs &, class TDesC8 const &, int, unsigned long) + diff -r 000000000000 -r 2014ca87e772 imagehandlinglib/EABI/IHLU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlinglib/EABI/IHLU.DEF Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,23 @@ +EXPORTS + _ZN13IHLBitmapUtil11CopyBitmapLERK10CFbsBitmap @ 1 NONAME + _ZN13IHLBitmapUtil11CopyBitmapLERK10CFbsBitmapRK5TRect @ 2 NONAME + _ZN13IHLBitmapUtil11ScaleBitmapERK10CFbsBitmapRK5TRectRS0_S5_m @ 3 NONAME + _ZN13IHLBitmapUtil11ScaleBitmapERK10CFbsBitmapRS0_m @ 4 NONAME + _ZN13IHLBitmapUtil12CopyBitmapLCERK10CFbsBitmap @ 5 NONAME + _ZN13IHLBitmapUtil12CopyBitmapLCERK10CFbsBitmapRK5TRect @ 6 NONAME + _ZN13IHLBitmapUtil16DuplicateBitmapLERK10CFbsBitmap @ 7 NONAME + _ZN13IHLBitmapUtil17DuplicateBitmapLCERK10CFbsBitmap @ 8 NONAME + _ZN15IHLImageFactory14OpenFileImageLER3RFsRK7TDesC16 @ 9 NONAME + _ZN15IHLImageFactory14OpenFileImageLER3RFsRK7TDesC16i @ 10 NONAME + _ZN15IHLImageFactory14OpenFileImageLER5RFile @ 11 NONAME + _ZN15IHLImageFactory14OpenFileImageLER5RFilei @ 12 NONAME + _ZN16IHLViewerFactory18CreateImageViewerLERK5TSizeR9MIHLImageR10MIHLBitmapR18MIHLViewerObserverm @ 13 NONAME + _ZN19IHLProcessorFactory22CreateBitmapProcessorLEm @ 14 NONAME + _ZN9IHLBitmap7CreateLEv @ 15 NONAME + _ZN9IHLScaler7CreateLEm @ 16 NONAME + _ZN15IHLImageFactory14OpenFileImageLER3RFsRK7TDesC16im @ 17 NONAME + _ZN15IHLImageFactory14OpenFileImageLER5RFileim @ 18 NONAME + _ZN15IHLImageFactory22OpenBufferedFileImageLER3RFsRK6TDesC8 @ 19 NONAME + _ZN15IHLImageFactory22OpenBufferedFileImageLER3RFsRK6TDesC8i @ 20 NONAME + _ZN15IHLImageFactory22OpenBufferedFileImageLER3RFsRK6TDesC8im @ 21 NONAME + diff -r 000000000000 -r 2014ca87e772 imagehandlinglib/Group/IHL.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlinglib/Group/IHL.mmp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Image Handling Library project file.* +*/ + + +#include + +TARGET IHL.dll +TARGETTYPE dll +UID 0x1000008D 0x101f4d90 // Image Viewer uid +CAPABILITY CAP_GENERAL_DLL +VENDORID VID_DEFAULT + +OPTION ARMCC --cpu 6 + +SOURCEPATH ../Src + +SOURCE IHLBitmapUtil.cpp +SOURCE CIHLScaler.cpp +SOURCE CIHLBitmap.cpp + +SOURCE IHLImageFactory.cpp +SOURCE CIHLFileImage.cpp +SOURCE CIHLFileImageExtJpg.cpp + +SOURCE IHLProcessorFactory.cpp +SOURCE CIHLBitmapProcessor.cpp + +SOURCE IHLViewerFactory.cpp +SOURCE CIHLImageViewer.cpp +SOURCE CIHLImageViewerExtJpg.cpp + +USERINCLUDE . +USERINCLUDE ../Src +USERINCLUDE ../Inc // subsystem level inc dir +USERINCLUDE ../../inc // ADo level inc dir + +// Default system include paths for middleware layer modules. +MW_LAYER_SYSTEMINCLUDE +SYSTEMINCLUDE /epoc32/include/icl // Needs to be removed after ICL has made SF structural changes. + + +LIBRARY euser.lib +LIBRARY fbscli.lib +LIBRARY bitgdi.lib +LIBRARY ImageConversion.lib +LIBRARY efsrv.lib +LIBRARY CAF.lib +LIBRARY IclExtJpegApi.lib +LIBRARY hal.lib + +//Remove comment to enable debug print +//MACRO IHL_ENABLE_DEBUG_PRINT diff -r 000000000000 -r 2014ca87e772 imagehandlinglib/Group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlinglib/Group/bld.inf Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This file provides the information required for building.* +*/ + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS +// export iby file +../Rom/Ihl.iby CORE_MW_LAYER_IBY_EXPORT_PATH( Ihl.iby ) + +PRJ_MMPFILES + +IHL.mmp + +PRJ_TESTMMPFILES +// specify the .mmp files required for building any test programs here +// +// You can specify "manual" to denote that a test should be listed in a +// generated batch file for running a group of tests +// which require user input during testing. +// You can specify "support" to denote that a file is a test support file +// and shouldn't be listed in a batch file for running a group of tests +// By default, each test will be listed in a batch file for running a group +// of tests which can be left to run without requiring watching over +// by the person running the tests, i.e. tests where no user +// input is required. The default will apply if neither "manual" +// or "support" is specified. +// Example: + +// ../tsrc/IHLValidation.mmp + diff -r 000000000000 -r 2014ca87e772 imagehandlinglib/Rom/Ihl.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlinglib/Rom/Ihl.iby Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: IBY file for Image Handling Library +* +*/ + + +#ifndef IMAGEHANDLINGLIBRARY_IBY +#define IMAGEHANDLINGLIBRARY_IBY + +file=ABI_DIR\BUILD_DIR\Ihl.dll SHARED_LIB_DIR\Ihl.dll + +#endif // IMAGEHANDLINGLIBRARY_IBY + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandlinglib/Src/CIHLBitmap.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlinglib/Src/CIHLBitmap.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,371 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Default implementation of bitmap class. +* +*/ + + +// INCLUDE FILES +#include "CIHLBitmap.h" +#include + +// ======================== STATIC FACTORY FUNCTIONS =========================== +// ----------------------------------------------------------------------------- +// IHLBitmap::CreateL +// ----------------------------------------------------------------------------- +// +EXPORT_C MIHLBitmap* IHLBitmap::CreateL() + { + return CIHLBitmap::NewL(); + } + +// ============================ MEMBER FUNCTIONS =============================== +// ----------------------------------------------------------------------------- +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +CIHLBitmap::CIHLBitmap() + { + } + +// ----------------------------------------------------------------------------- +// +// Second phase constructors. Can leave. +// ----------------------------------------------------------------------------- +void CIHLBitmap::ConstructL() + { + iBitmap = new (ELeave) CFbsBitmap; + iMask = new (ELeave) CFbsBitmap; + } + +// ----------------------------------------------------------------------------- +// +// Two-phased constructors. +// ----------------------------------------------------------------------------- +CIHLBitmap* CIHLBitmap::NewL() + { + CIHLBitmap* self = new( ELeave ) CIHLBitmap; + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); // self + return self; + } + +// ----------------------------------------------------------------------------- +// Destructor +// ----------------------------------------------------------------------------- +CIHLBitmap::~CIHLBitmap() + { + delete iBitmap; + delete iMask; + } + +// ----------------------------------------------------------------------------- +// CIHLBitmap::Create +// ----------------------------------------------------------------------------- +TInt CIHLBitmap::Create( const TSize& aSize, TDisplayMode aDisplayMode ) + { + Reset(); + return iBitmap->Create( aSize, aDisplayMode ); + } + +// ----------------------------------------------------------------------------- +// CIHLBitmap::Create +// ----------------------------------------------------------------------------- +TInt CIHLBitmap::Create( const TSize& aSize, TDisplayMode aBitmapDisplayMode, + TDisplayMode aMaskDisplayMode ) + { + Reset(); + TInt err( KErrArgument ); + if( aMaskDisplayMode == EGray2 || aMaskDisplayMode == EGray256 ) + { + err = iBitmap->Create( aSize, aBitmapDisplayMode ); + if( err ) + { + return err; + } + err = iMask->Create( aSize, aMaskDisplayMode ); + if( err ) + { + iBitmap->Reset(); + } + } + return err; + } + +// ----------------------------------------------------------------------------- +// CIHLBitmap::Copy +// ----------------------------------------------------------------------------- +TInt CIHLBitmap::Copy( const CFbsBitmap& aBitmap, TBool aDuplicate ) + { + Reset(); + TInt err( KErrNone ); + TInt bitmapHandle( aBitmap.Handle() ); + if( bitmapHandle ) + { + if( aDuplicate ) + { + err = iBitmap->Duplicate( bitmapHandle ); + } + else + { + err = CopyBitmap( aBitmap, *iBitmap ); + } + } + return err; + } + +// ----------------------------------------------------------------------------- +// CIHLBitmap::Copy +// ----------------------------------------------------------------------------- +TInt CIHLBitmap::Copy( const CFbsBitmap& aBitmap, const CFbsBitmap& aMask, TBool aDuplicate ) + { + Reset(); + TInt bitmapHandle( aBitmap.Handle() ); + TInt maskHandle( aMask.Handle() ); + if( bitmapHandle && maskHandle && + aBitmap.SizeInPixels() != aMask.SizeInPixels() ) + { + return KErrArgument; + } + + if( maskHandle ) + { + switch( aMask.DisplayMode() ) + { + case EGray2: + case EGray256: + { + break; + } + default: + { + return KErrArgument; + } + } + } + + TInt err( KErrNone ); + if( bitmapHandle ) + { + if( aDuplicate ) + { + err = iBitmap->Duplicate( bitmapHandle ); + } + else + { + err = CopyBitmap( aBitmap, *iBitmap ); + } + } + + if( !err && maskHandle ) + { + if( aDuplicate ) + { + err = iMask->Duplicate( maskHandle ); + } + else + { + err = CopyBitmap( aMask, *iMask ); + } + if( err ) + { + iBitmap->Reset(); + } + } + return err; + } + +// ----------------------------------------------------------------------------- +// CIHLBitmap::Copy +// ----------------------------------------------------------------------------- +TInt CIHLBitmap::Copy( const MIHLBitmap& aBitmap, TBool aDuplicate ) + { + return Copy( aBitmap.Bitmap(), aBitmap.Mask(), aDuplicate ); + } + +// ----------------------------------------------------------------------------- +// CIHLBitmap::Reset +// ----------------------------------------------------------------------------- +void CIHLBitmap::Reset() + { + iBitmap->Reset(); + iMask->Reset(); + iEditorPtr = NULL; + iEditorValue = 0; + } + + +// ----------------------------------------------------------------------------- +// CIHLBitmap::IsCreated +// ----------------------------------------------------------------------------- +TBool CIHLBitmap::IsCreated() const + { + return ( iBitmap->Handle() != 0 ); + } + +// ----------------------------------------------------------------------------- +// CIHLBitmap::Bitmap +// ----------------------------------------------------------------------------- +const CFbsBitmap& CIHLBitmap::Bitmap() const + { + return *iBitmap; + } + +// ----------------------------------------------------------------------------- +// CIHLBitmap::HasMask +// ----------------------------------------------------------------------------- +TBool CIHLBitmap::HasMask() const + { + return ( iMask->Handle() != 0 ); + } + +// ----------------------------------------------------------------------------- +// CIHLBitmap::Mask +// ----------------------------------------------------------------------------- +const CFbsBitmap& CIHLBitmap::Mask() const + { + return *iMask; + } + +// ----------------------------------------------------------------------------- +// CIHLBitmap::Draw +// ----------------------------------------------------------------------------- +void CIHLBitmap::Draw( CBitmapContext& aContext, const TPoint& aPoint ) const + { + if( iBitmap->Handle() ) + { + if( iMask->Handle() ) + { + aContext.BitBltMasked( aPoint, iBitmap, iBitmap->SizeInPixels(), iMask, EFalse ); + } + else + { + aContext.BitBlt( aPoint, iBitmap, iBitmap->SizeInPixels() ); + } + } + } + +// ----------------------------------------------------------------------------- +// CIHLBitmap::Draw +// ----------------------------------------------------------------------------- +void CIHLBitmap::Draw( CBitmapContext& aContext, const TPoint& aPoint, + const TRect& aSourceRect ) const + { + if( iBitmap->Handle() ) + { + if( iMask->Handle() ) + { + aContext.BitBltMasked( aPoint, iBitmap, aSourceRect, iMask, EFalse ); + } + else + { + aContext.BitBlt( aPoint, iBitmap, aSourceRect ); + } + } + } + +// Internal interface +// ----------------------------------------------------------------------------- +// CIHLBitmap::SetFilename +// ----------------------------------------------------------------------------- +CFbsBitmap& CIHLBitmap::BitmapModifyable() + { + return *iBitmap; + } + +// ----------------------------------------------------------------------------- +// CIHLBitmap::SetFilename +// ----------------------------------------------------------------------------- +CFbsBitmap& CIHLBitmap::MaskModifyable() + { + return *iMask; + } + +// ----------------------------------------------------------------------------- +// CIHLBitmap::SetEditorPtr +// ----------------------------------------------------------------------------- +void CIHLBitmap::SetEditorPtr( const TAny* aEditorPtr ) + { + iEditorPtr = aEditorPtr; + } + +// ----------------------------------------------------------------------------- +// CIHLBitmap::SetEditorValue +// ----------------------------------------------------------------------------- +void CIHLBitmap::SetEditorValue( TInt aEditorValue ) + { + iEditorValue = aEditorValue; + } + +// ----------------------------------------------------------------------------- +// CIHLBitmap::EditorPtr +// ----------------------------------------------------------------------------- +const TAny* CIHLBitmap::EditorPtr() const + { + return iEditorPtr; + } + +// ----------------------------------------------------------------------------- +// CIHLBitmap::FrameIndex +// ----------------------------------------------------------------------------- +TInt CIHLBitmap::EditorValue() const + { + return iEditorValue; + } + +// Private methods +// ----------------------------------------------------------------------------- +// CIHLBitmap::CopyBitmap +// ----------------------------------------------------------------------------- +TInt CIHLBitmap::CopyBitmap( const CFbsBitmap& aSource, CFbsBitmap& aDestination ) + { + TSize size( aSource.SizeInPixels() ); + TDisplayMode displayMode( aSource.DisplayMode() ); + TInt err( aDestination.Create( size, displayMode ) ); + if( !err ) + { + err = CopyBitmapData( aSource, aDestination, size, displayMode ); + if( err ) + { + aDestination.Reset(); + } + } + return err; + } + +// ----------------------------------------------------------------------------- +// CIHLBitmap::CopyBitmapData +// ----------------------------------------------------------------------------- +TInt CIHLBitmap::CopyBitmapData( const CFbsBitmap& aSource, CFbsBitmap& aDestination, + const TSize& aSize, const TDisplayMode& aDisplayMode ) + { + HBufC8* scanLine = HBufC8::New( aSource.ScanLineLength( aSize.iWidth, aDisplayMode ) ); + if( scanLine ) + { + TPtr8 scanPtr( scanLine->Des() ); + TPoint pp; + for( pp.iY = 0; pp.iY < aSize.iHeight; ++pp.iY ) + { + aSource.GetScanLine( scanPtr, pp, aSize.iWidth, aDisplayMode ); + aDestination.SetScanLine( scanPtr, pp.iY ); + } + + delete scanLine; + return KErrNone; + } + return KErrNoMemory; // scanLine alloc failed + } + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandlinglib/Src/CIHLBitmap.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlinglib/Src/CIHLBitmap.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,184 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Default implementation of bitmap class. +* +*/ + + +#ifndef CIHLBITMAP_H +#define CIHLBITMAP_H + +// INCLUDES +#include +#include + +// CLASS DECLARATION +/** +* CIHLBitmap +* +* Default implementation of bitmap class. +* @lib IHL.lib +* @since 3.0 +*/ +NONSHARABLE_CLASS( CIHLBitmap ) : public CBase, public MIHLBitmap + { + public: // Constructors and destructor + + /** + * Two-phased constructors + */ + static CIHLBitmap* NewL(); + + /** + * Virtual destructor. + */ + virtual ~CIHLBitmap(); + + public: // From base class MIHLBitmap + + /** + * From MIHLBitmap, see base class header. + */ + TInt Create( const TSize& aSize, TDisplayMode aDisplayMode ); + + /** + * From MIHLBitmap, see base class header. + */ + TInt Create( const TSize& aSize, TDisplayMode aBitmapDisplayMode, + TDisplayMode aMaskDisplayMode ); + + /** + * From MIHLBitmap, see base class header. + */ + TInt Copy( const CFbsBitmap& aBitmap, TBool aDuplicate ); + + /** + * From MIHLBitmap, see base class header. + */ + TInt Copy( const CFbsBitmap& aBitmap, const CFbsBitmap& aMask, TBool aDuplicate ); + + /** + * From MIHLBitmap, see base class header. + */ + TInt Copy( const MIHLBitmap& aBitmap, TBool aDuplicate ); + + /** + * From MIHLBitmap, see base class header. + */ + void Reset(); + + /** + * From MIHLBitmap, see base class header. + */ + TBool IsCreated() const; + + /** + * From MIHLBitmap, see base class header. + */ + const CFbsBitmap& Bitmap() const; + + /** + * From MIHLBitmap, see base class header. + */ + TBool HasMask() const; + + /** + * From MIHLBitmap, see base class header. + */ + const CFbsBitmap& Mask() const; + + /** + * From MIHLBitmap, see base class header. + */ + void Draw( CBitmapContext& aContext, const TPoint& aPoint ) const; + + /** + * From MIHLBitmap, see base class header. + */ + void Draw( CBitmapContext& aContext, const TPoint& aPoint, const TRect& aSourceRect ) const; + + public: // Internal interface + + /** + * Non-const bitmap reference. + * @since 3.0 + * @return Non-const bitmap reference. + */ + CFbsBitmap& BitmapModifyable(); + + /** + * Non-const bitmap reference. + * @since 3.0 + * @return Non-const bitmap reference. + */ + CFbsBitmap& MaskModifyable(); + + /** + * Set editor pointer. This information is used + * internally to detect what class has made changes to bitmap data. + * @since 3.0 + * @param aEditorPtr Editor pointer + */ + void SetEditorPtr( const TAny* aEditorPtr ); + + /** + * Set editor value. Meaning of this value may vary depending + * on type of editor class. + * @since 3.0 + * @param aEditorValue Editor custom value + */ + void SetEditorValue( TInt aEditorValue ); + + /** + * Return Editor pointer. NULL if just created or reseted. + * @return Editor pointer. + */ + const TAny* EditorPtr() const; + + /** + * Return editor value. + * @since 3.0 + * @return Editor custom value. + */ + TInt EditorValue() const; + + public: // Private methods + + TInt CopyBitmap( const CFbsBitmap& aSource, CFbsBitmap& aDestination ); + + TInt CopyBitmapData( const CFbsBitmap& aSource, CFbsBitmap& aDestination, + const TSize& aSize, const TDisplayMode& aDisplayMode ); + + private: // Private constructors + + CIHLBitmap(); + void ConstructL(); + + private: // Data + + // Own: Bitmap pointers + CFbsBitmap* iBitmap; + CFbsBitmap* iMask; + + // Ref: Editor ptr + const TAny* iEditorPtr; + + // Editor value + TInt iEditorValue; + + }; + +#endif // CIHLBITMAP_H + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandlinglib/Src/CIHLBitmapProcessor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlinglib/Src/CIHLBitmapProcessor.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,293 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of scaling processor +* : using MIHLBitmap type bitmaps. +* +*/ + + + +// INCLUDE FILES +#include "CIHLBitmapProcessor.h" + +#include "CIHLScaler.h" +#include "CIHLBitmap.h" +#include "IHLImplementationIds.h" +#include "IHLDebugPrint.h" // Debug print + +#include +#include // CFbsBitmap +#include // CFbsBitmapDevice, CFbsBitGc + +// Private namespace for constants and functions +namespace + { + // Panic function + _LIT( KIHLPanicString, "IHLBitmapProcessor" ); + void Panic( TInt aPanicCode ) { User::Panic( KIHLPanicString, aPanicCode ); } + } + +// ============================ MEMBER FUNCTIONS =============================== +// ----------------------------------------------------------------------------- +// +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +CIHLBitmapProcessor::CIHLBitmapProcessor() +:CActive( CActive::EPriorityStandard ) + { + CActiveScheduler::Add( this ); + } + +// ----------------------------------------------------------------------------- +// +// Two-phased constructor. +// ----------------------------------------------------------------------------- +CIHLBitmapProcessor* CIHLBitmapProcessor::NewL( const TUint32 aOptions ) + { + CIHLBitmapProcessor* self = new( ELeave ) CIHLBitmapProcessor(); + CleanupStack::PushL( self ); + self->ConstructL( aOptions ); + CleanupStack::Pop(); // self + return self; + } + +// ----------------------------------------------------------------------------- +// +// Symbian constructor can leave. +// ----------------------------------------------------------------------------- +void CIHLBitmapProcessor::ConstructL( const TUint32 aOptions ) + { + iScaler = CIHLScaler::NewL( aOptions ); + } + +// ----------------------------------------------------------------------------- +// Destructor +// ----------------------------------------------------------------------------- +CIHLBitmapProcessor::~CIHLBitmapProcessor() + { + Cancel(); + delete iScaler; + } + +// ----------------------------------------------------------------------------- +// CIHLBitmapProcessor::Type +// ----------------------------------------------------------------------------- +TIHLInterfaceType CIHLBitmapProcessor::Type() const + { + return TIHLInterfaceType( KIHLInterfaceIdBitmapProcessor, KIHLImplementationIdBitmapProcessor ); + } + +// ----------------------------------------------------------------------------- +// CIHLBitmapProcessor::Process +// ----------------------------------------------------------------------------- +TInt CIHLBitmapProcessor::Process( TRequestStatus& aStatus, + const MIHLBitmap& aSrcBitmap, + const TRect& aSrcRect, + MIHLBitmap& aDstBitmap, + const TRect& aDstRect ) + { + if( IsBusy() ) + { + return KErrNotReady; + } + + // Check bitmaps (no checking of masks is needed) + const CFbsBitmap& srcBitmap = aSrcBitmap.Bitmap(); + const CFbsBitmap& dstBitmap = aDstBitmap.Bitmap(); + if( !srcBitmap.Handle() || + !iScaler->IsValidRect( srcBitmap.SizeInPixels(), aSrcRect ) || + !dstBitmap.Handle() || + !iScaler->IsValidRect( dstBitmap.SizeInPixels(), aDstRect ) ) + { + return KErrArgument; + } + + IHL_DEBUG1( KIHLDebug, "IHL - CIHLBitmapProcessor - Start asynchronous bitmap processing" ); + + // Set references to member data + iSrcBitmap = &aSrcBitmap; + iSrcRect = aSrcRect; + iDstBitmap = static_cast( &aDstBitmap ); //lint !e826 + iDstRect = aDstRect; + + // Start processing + iProcessorStatus = &aStatus; + *iProcessorStatus = KRequestPending; + + iProcessorState = EProcessBitmap; + SelfComplete(); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CIHLBitmapProcessor::IsBusy +// ----------------------------------------------------------------------------- +TBool CIHLBitmapProcessor::IsBusy() const + { + return ( iProcessorState != EInactive ); + } + +// ----------------------------------------------------------------------------- +// CIHLBitmapProcessor::CancelProcess +// ----------------------------------------------------------------------------- +void CIHLBitmapProcessor::CancelProcess() + { + IHL_DEBUG1( KIHLDebug, "IHL - CIHLBitmapProcessor - Process cancelled" ); + + Cancel(); + } + +// ----------------------------------------------------------------------------- +// CIHLBitmapProcessor::SetFilter +// ----------------------------------------------------------------------------- +void CIHLBitmapProcessor::SetFilter( MIHFilter* /*aFilter*/ ) + { + // Not in use + } + +// ----------------------------------------------------------------------------- +// CIHLBitmapProcessor::DoCancel +// ----------------------------------------------------------------------------- +void CIHLBitmapProcessor::DoCancel() + { + iScaler->CancelProcess(); + iProcessorState = EInactive; + RequestComplete( KErrCancel ); + } + +// ----------------------------------------------------------------------------- +// CIHLBitmapProcessor::RunL +// ----------------------------------------------------------------------------- +void CIHLBitmapProcessor::RunL() + { + User::LeaveIfError( iStatus.Int() ); + + switch( iProcessorState ) + { + case EProcessBitmap: + { + ProcessBitmapL(); + if( iDstBitmap->Mask().Handle() ) + { + iProcessorState = EProcessMask; + } + else + { + // Destination has no mask -> finish process + iProcessorState = EFinish; + } + break; + } + case EProcessMask: + { + ProcessMaskL(); + iProcessorState = EFinish; + break; + } + case EFinish: + { + IHL_DEBUG1( KIHLDebug, "IHL - CIHLBitmapProcessor - Process complete!" ); + + iProcessorState = EInactive; + RequestComplete( KErrNone ); + break; + } + default: + { + Panic( KErrTotalLossOfPrecision ); + } + } + } + +// ----------------------------------------------------------------------------- +// CIHLBitmapProcessor::RunError +// ----------------------------------------------------------------------------- +TInt CIHLBitmapProcessor::RunError( TInt aError ) + { + IHL_DEBUG2( KIHLDebug, "IHL - CIHLBitmapProcessor - Processing error: %d", aError ); + + iProcessorState = EInactive; + RequestComplete( aError ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CIHLBitmapProcessor::ProcessBitmapL +// ----------------------------------------------------------------------------- +void CIHLBitmapProcessor::ProcessBitmapL() + { + User::LeaveIfError( iScaler->Scale( iStatus, + iSrcBitmap->Bitmap(), + iSrcRect, + iDstBitmap->BitmapModifyable(), + iDstRect ) ); + SetActive(); + } + +// ----------------------------------------------------------------------------- +// CIHLBitmapProcessor::ProcessMaskL +// ----------------------------------------------------------------------------- +void CIHLBitmapProcessor::ProcessMaskL() + { + if( iSrcBitmap->Mask().Handle() ) + { + User::LeaveIfError( iScaler->Scale( iStatus, + iSrcBitmap->Mask(), + iSrcRect, + iDstBitmap->MaskModifyable(), + iDstRect ) ); + SetActive(); + } + else + { + // No source bitmap where mask can be copied + // -> clear destination mask at given rectangle + CFbsBitGc* bitGc; + CFbsBitmapDevice* bitDev = CFbsBitmapDevice::NewL( + &(iDstBitmap->BitmapModifyable()) ); + CleanupStack::PushL( bitDev ); + User::LeaveIfError( bitDev->CreateContext( bitGc ) ); + CleanupStack::PushL( bitGc ); + + bitGc->SetPenColor( KRgbWhite ); // white is non-transparent + bitGc->SetBrushColor( KRgbWhite ); + bitGc->SetBrushStyle( CGraphicsContext::ESolidBrush ); + bitGc->DrawRect( iDstRect ); + + CleanupStack::PopAndDestroy( 2 ); // bitGc, bitDev + } + } + +// ----------------------------------------------------------------------------- +// CIHLBitmapProcessor::SelfComplete +// ----------------------------------------------------------------------------- +void CIHLBitmapProcessor::SelfComplete() + { + SetActive(); + iStatus = KRequestPending; + TRequestStatus* status = &iStatus; + User::RequestComplete( status, KErrNone ); + } + +// ----------------------------------------------------------------------------- +// CIHLBitmapProcessor::RequestComplete +// ----------------------------------------------------------------------------- +void CIHLBitmapProcessor::RequestComplete( TInt aReason ) + { + ASSERT( iProcessorStatus ); + User::RequestComplete( iProcessorStatus, aReason ); + } + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandlinglib/Src/CIHLBitmapProcessor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlinglib/Src/CIHLBitmapProcessor.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,167 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of scaling processor +* : using MIHLBitmap type bitmaps. +* +*/ + + +#ifndef CIHLBITMAPPROCESSOR_H +#define CIHLBITMAPPROCESSOR_H + +// INCLUDES +#include +#include + +// FORWARD DECLARATIONS +class CIHLScaler; +class CIHLBitmap; + +// CLASS DECLARATION +/** +* CIHLBitmapProcessor +* +* Implementation of scaling processor +* using MIHLBitmap type bitmaps. +* @lib IHL.lib +* @since 3.0 +*/ +NONSHARABLE_CLASS( CIHLBitmapProcessor ) : public CActive, + public MIHLBitmapProcessor + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CIHLBitmapProcessor* NewL( const TUint32 aOptions = 0 ); + + /* + * Virtual destructor. + */ + virtual ~CIHLBitmapProcessor(); + + public: // From base class MIHLProcessor + + /* + * From MIHLProcessor, see base class header. + */ + TIHLInterfaceType Type() const; + + public: // From base class MIHLBitmapProcessor + + /* + * From MIHLBitmapProcessor, see base class header. + */ + TInt Process( TRequestStatus& aStatus, + const MIHLBitmap& aSrcBitmap, + const TRect& aSrcRect, + MIHLBitmap& aDstBitmap, + const TRect& aDstRect ); + + /* + * From MIHLBitmapProcessor, see base class header. + */ + TBool IsBusy() const; + + /* + * From MIHLBitmapProcessor, see base class header. + */ + void CancelProcess(); + + /* + * From MIHLBitmapProcessor, see base class header. + */ + void SetFilter( MIHFilter* aFilter ); + + private: // From base class CActive + + /* + * From CActive, see base class header. + */ + void DoCancel(); + + /* + * From CActive, see base class header. + */ + void RunL(); + + /* + * From CActive, see base class header. + */ + TInt RunError( TInt aError ); + + + private: // Private methods + + /* + * Process bitmap part of source image + */ + void ProcessBitmapL(); + + /* + * Process mask part of source image + */ + void ProcessMaskL(); + + /* + * Set this active object to completed state + * -> one process step (RunL) will be executed. + */ + void SelfComplete(); + + /* + * Set client request to completed state + * -> process complete. + * @param aReason Request complete reason + */ + void RequestComplete( TInt aReason ); + + private: // Private constructors + + CIHLBitmapProcessor(); + void ConstructL( const TUint32 aOptions ); + + private: // Private data types + + enum TProcessorState + { + EInactive, + EProcessBitmap, + EProcessMask, + EFinish, + }; + + private: // Data + + // Ref: Process status & state + TRequestStatus* iProcessorStatus; + TProcessorState iProcessorState; + + // Ref: Source bitmap & rect + const MIHLBitmap* iSrcBitmap; + TRect iSrcRect; + + // Ref: Destination bitmap & rect + CIHLBitmap* iDstBitmap; + TRect iDstRect; + + // Own: Scaler + CIHLScaler* iScaler; + + }; + +#endif // CIHLBITMAPPROCESSOR_H + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandlinglib/Src/CIHLFileImage.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlinglib/Src/CIHLFileImage.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,992 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of Image class. +* +*/ + + +// INCLUDE FILES +#include "CIHLFileImage.h" + +#include "CIHLBitmap.h" +#include "IHLImplementationIds.h" +#include "IHLDebugPrint.h" // Debug print +#include + +// Private namespace for constants and functions +namespace + { + // Fixed scale factors + enum TScaleFactors + { + EFull = 1, + EHalf = 2, + EQuarter = 4, + EEighth = 8, + }; + + // Panic function + _LIT( KIHLPanicString, "IHLImage" ); + void Panic( TInt aPanicCode ) { User::Panic( KIHLPanicString, aPanicCode ); } + } + +// ============================ MEMBER FUNCTIONS =============================== +// ----------------------------------------------------------------------------- +// +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +CIHLFileImage::CIHLFileImage( TInt aImageIndex ) +:CActive( CActive::EPriorityStandard ), +iImageIndex( aImageIndex ) + { + CActiveScheduler::Add( this ); + } + +// ----------------------------------------------------------------------------- +// +// Two-phased constructor. +// ----------------------------------------------------------------------------- +CIHLFileImage* CIHLFileImage::NewL( RFile& aFile, TInt aImageIndex, const TUint32 aOptions ) + { + CIHLFileImage* self = new (ELeave) CIHLFileImage( aImageIndex ); + CleanupStack::PushL( self ); + self->ConstructL( aFile, aOptions ); + CleanupStack::Pop(); // self + return self; + } + +CIHLFileImage* CIHLFileImage::NewL( RFs& aFs, const TDesC8& aDataBuf, + TInt aImageIndex, const TUint32 aOptions ) + { + CIHLFileImage* self = new (ELeave) CIHLFileImage( aImageIndex ); + CleanupStack::PushL( self ); + self->ConstructL( aFs, aDataBuf, aOptions ); + CleanupStack::Pop(); // self + return self; + } + +// ----------------------------------------------------------------------------- +// +// Symbian constructor can leave. +// ----------------------------------------------------------------------------- +void CIHLFileImage::ConstructL( RFile& aFile, const TUint32 aOptions ) + { + TInt decoderOptions( CImageDecoder::EOptionNoDither | CImageDecoder::EOptionUseFrameSizeInPixels ); + + // Open decoder + IHL_DEBUG1( KIHLDebug1, "IHL - CIHLFileImage - Start create ICL image decoder" ); + if( aOptions & MIHLFileImage::EOptionNoDRMConsume ) + { + iDecoder = CImageDecoder::FileNewL( aFile, ContentAccess::EPeek, + (CImageDecoder::TOptions)decoderOptions ); + } + else + { + iDecoder = CImageDecoder::FileNewL( aFile, ContentAccess::EView, + (CImageDecoder::TOptions)decoderOptions ); + } + ConstructCommonL(); + IHL_DEBUG1( KIHLDebug2, "IHL - CIHLFileImage - ICL image decoder ready!" ); + } + +void CIHLFileImage::ConstructL( RFs& aFs, const TDesC8& aDataBuf, const TUint32 /*aOptions*/ ) + { + TInt decoderOptions( CImageDecoder::EOptionNoDither | CImageDecoder::EOptionUseFrameSizeInPixels ); + + IHL_DEBUG1( KIHLDebug1, "IHL - CIHLFileImage - Start create buffered ICL image decoder" ); + + iDecoder = CImageDecoder::DataNewL( aFs, aDataBuf, (CImageDecoder::TOptions)decoderOptions ); + ConstructCommonL(); + + IHL_DEBUG1( KIHLDebug2, "IHL - CIHLFileImage - Buffered ICL image decoder ready!" ); + } + + +// ----------------------------------------------------------------------------- +// CIHLFileImage::ConstructCommonL +// ----------------------------------------------------------------------------- + +void CIHLFileImage::ConstructCommonL() + { + // Check frame count and image index + iImageCount = iDecoder->FrameCount(); + __ASSERT_ALWAYS( iImageCount > 0, User::Leave( KErrCorrupt ) ); + + // Get image types + iDecoder->ImageType( iImageIndex, iImageType, iImageSubType ); + + if( KImageTypeGIFUid == iImageType ) + { + iGif = ETrue; + if( iImageCount > 1 ) + { + iAnimation = ETrue; + iAnimationFrameCount = iImageCount; + iImageCount = 1; // Handled as one animated image + } + } + __ASSERT_ALWAYS( iImageIndex >= 0 && iImageIndex < iImageCount, User::Leave( KErrArgument ) ); + + // cache frame info and set scale sizes + iFrameInfo = iDecoder->FrameInfo( iImageIndex ); + if( !iAnimation ) + { + // Animation must always be loaded 1:1 + if( !iGif && + iFrameInfo.iFlags & TFrameInfo::EFullyScaleable ) + { + // Gif cannot be fully scaleable + iFullyScaleable = ETrue; + } + else + { + TSize size( iFrameInfo.iOverallSizeInPixels ); + iLoadSizeArray.AppendL( ScaledLoadSize( size, EEighth ) ); + iLoadSizeArray.AppendL( ScaledLoadSize( size, EQuarter ) ); + iLoadSizeArray.AppendL( ScaledLoadSize( size, EHalf ) ); + } + } + } + +// ----------------------------------------------------------------------------- +// Destructor +// ----------------------------------------------------------------------------- +CIHLFileImage::~CIHLFileImage() + { + Cancel(); + delete iPrevAnimationFrame; + delete iSubFrameBitmap; + delete iDecoder; + iLoadSizeArray.Reset(); + } + +// ----------------------------------------------------------------------------- +// CIHLFileImage::Type +// ----------------------------------------------------------------------------- +TIHLInterfaceType CIHLFileImage::Type() const + { + return TIHLInterfaceType( KIHLInterfaceIdFileImage, + KIHLImplementationIdFileImage ); + } + +// ----------------------------------------------------------------------------- +// CIHLFileImage::ImageType +// ----------------------------------------------------------------------------- +const TUid& CIHLFileImage::ImageType() const + { + return iImageType; + } + +// ----------------------------------------------------------------------------- +// CIHLFileImage::ImageSubType +// ----------------------------------------------------------------------------- +const TUid& CIHLFileImage::ImageSubType() const + { + return iImageSubType; + } + +// ----------------------------------------------------------------------------- +// CIHLFileImage::ImageIndex +// ----------------------------------------------------------------------------- +TInt CIHLFileImage::ImageIndex() const + { + return iImageIndex; + } + +// ----------------------------------------------------------------------------- +// CIHLFileImage::ImageCount +// ----------------------------------------------------------------------------- +TInt CIHLFileImage::ImageCount() const + { + return iImageCount; + } + +// ----------------------------------------------------------------------------- +// CIHLFileImage::Size +// ----------------------------------------------------------------------------- +TSize CIHLFileImage::Size() const + { + return iFrameInfo.iOverallSizeInPixels; + } + +// ----------------------------------------------------------------------------- +// CIHLFileImage::DisplayMode +// ----------------------------------------------------------------------------- +TDisplayMode CIHLFileImage::DisplayMode() const + { + if( iGif ) + { + // We cannot trust iFrameDisplayMode for GIF images. It always return EColor256. + // This is error because palette sure holds only 256 colors but these colors can + // be still any RGB values and so for cannot be directly put to 8 bit bitmap (EColor256). + // To decrypt image correctly and without color dithering, we must use 24 bit (EColor16M) + // destination bitmap. Note that CFbsBitmap has palette methods but they are + // not supported currently. + // Return maximum color mode to ensure best image quality. + return EColor16MU; + } + else if( iFrameInfo.iFrameDisplayMode < EColor16MU || + iFrameInfo.iFrameDisplayMode == EColor4K ) + { + return EColor64K; + } + return EColor16MU; + } + +// ----------------------------------------------------------------------------- +// CIHLFileImage::MaskDisplayMode +// ----------------------------------------------------------------------------- +TDisplayMode CIHLFileImage::MaskDisplayMode() const + { + if( iFrameInfo.iFlags & TFrameInfo::ETransparencyPossible ) + { + if( iFrameInfo.iFlags & TFrameInfo::EAlphaChannel ) + { + return EGray256; + } + return EGray2; + } + return ENone; + } + +// ----------------------------------------------------------------------------- +// CIHLFileImage::BackgroundColor +// ----------------------------------------------------------------------------- +TRgb CIHLFileImage::BackgroundColor() const + { + return iFrameInfo.iBackgroundColor; + } + +// ----------------------------------------------------------------------------- +// CIHLFileImage::CustomLoadSizeArray +// ----------------------------------------------------------------------------- +const RArray& CIHLFileImage::CustomLoadSizeArray() const + { + return iLoadSizeArray; + } + +// ----------------------------------------------------------------------------- +// CIHLFileImage::CustomLoadSizeArray +// ----------------------------------------------------------------------------- +TBool CIHLFileImage::IsFullyScaleable() const + { + return iFullyScaleable; + } + +// ----------------------------------------------------------------------------- +// CIHLFileImage::IsAnimation +// ----------------------------------------------------------------------------- +TBool CIHLFileImage::IsAnimation() const + { + return iAnimation; + } + +// ----------------------------------------------------------------------------- +// CIHLFileImage::AnimationFrameCount +// ----------------------------------------------------------------------------- +TInt CIHLFileImage::AnimationFrameCount() const + { + return iAnimationFrameCount; + } + +// ----------------------------------------------------------------------------- +// CIHLFileImage::AnimationFrameDelay +// ----------------------------------------------------------------------------- +TTimeIntervalMicroSeconds32 CIHLFileImage::AnimationFrameDelay( TInt aAnimationFrameIndex ) const + { + __ASSERT_ALWAYS( aAnimationFrameIndex >= 0 && + aAnimationFrameIndex < iAnimationFrameCount, Panic( KErrArgument ) ); + + return I64INT( iDecoder->FrameInfo( aAnimationFrameIndex ).iDelay.Int64() ); + } + +// ------------------------------------------------------------------------------ +// CIHLFileImage::Load +// ------------------------------------------------------------------------------ + +TInt CIHLFileImage::Load( TRequestStatus& aStatus, MIHLBitmap& aDestination, TInt aFrameIndex ) + { + iImageIndex = aFrameIndex; + return LoadRequest( aStatus, aDestination, iImageIndex ); + } + +// ----------------------------------------------------------------------------- +// CIHLFileImage::LoadAnimation +// ----------------------------------------------------------------------------- +TInt CIHLFileImage::LoadAnimation( TRequestStatus& aStatus, MIHLBitmap& aDestination, + TInt aAnimationFrameIndex ) + { + __ASSERT_ALWAYS( aAnimationFrameIndex >= 0 && + aAnimationFrameIndex < iAnimationFrameCount, Panic( KErrArgument ) ); + + return LoadRequest( aStatus, aDestination, aAnimationFrameIndex ); + } + +// ----------------------------------------------------------------------------- +// CIHLFileImage::IsBusy +// ----------------------------------------------------------------------------- +TBool CIHLFileImage::IsBusy() const + { + return ( iImageState != EInactive ); + } + +// ----------------------------------------------------------------------------- +// CIHLFileImage::CancelLoad +// ----------------------------------------------------------------------------- +void CIHLFileImage::CancelLoad() + { + Cancel(); + } + +// ----------------------------------------------------------------------------- +// CIHLFileImage::SetFilter +// ----------------------------------------------------------------------------- +void CIHLFileImage::SetFilter( MIHLFilter* /*aFilter*/ ) + { + // Not in use + } + + +// ----------------------------------------------------------------------------- +// CIHLFileImage::Decoder +// ----------------------------------------------------------------------------- +const CImageDecoder& CIHLFileImage::Decoder() const + { + return *iDecoder; + } + +// ----------------------------------------------------------------------------- +// CIHLFileImage::DoCancel +// ----------------------------------------------------------------------------- +void CIHLFileImage::DoCancel() + { + iDecoder->Cancel(); + + // Delete all processed bitmaps + ErrorCleanup(); + + // Complete with cancel + iImageState = EInactive; + RequestComplete( KErrCancel ); + } + +// ----------------------------------------------------------------------------- +// CIHLFileImage::RunL +// ----------------------------------------------------------------------------- +void CIHLFileImage::RunL() + { + __ASSERT_DEBUG( iDestination, Panic( KErrGeneral ) ); + User::LeaveIfError( iStatus.Int() ); + + switch( iImageState ) + { + case EStartLoad: + { + // start loading the bitmaps + StartLoadL(); + break; + } + case ECompleteLoad: + { + // complete loading the bitmaps + CompleteLoadL(); + break; + } + default: + { + Panic( KErrTotalLossOfPrecision ); + } + } + } + +// ----------------------------------------------------------------------------- +// CIHLFileImage::RunError +// ----------------------------------------------------------------------------- +TInt CIHLFileImage::RunError( TInt aError ) + { + IHL_DEBUG2( KIHLDebug, "IHL - CIHLFileImage - Loading error: %d", aError ); + + // Delete all processed bitmaps + ErrorCleanup(); + + // Complete with error + iImageState = EInactive; + RequestComplete( aError ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CIHLFileImage::LoadRequest +// ----------------------------------------------------------------------------- +TInt CIHLFileImage::LoadRequest( TRequestStatus& aStatus, + MIHLBitmap& aDestination, + TInt aFrameIndex ) + { + if( IsBusy() ) + { + return KErrNotReady; + } + + if( aFrameIndex < 0 || aFrameIndex >= iDecoder->FrameCount() ) + { + return KErrArgument; + } + + const CFbsBitmap& dstBitmap = aDestination.Bitmap(); + if( !dstBitmap.Handle() ) + { + return KErrArgument; + } + + TSize dstSize( dstBitmap.SizeInPixels() ); + if( dstSize != Size() && + !iFullyScaleable ) + { + TBool sizeFound( EFalse ); + const TInt count( iLoadSizeArray.Count() ); + for( TInt i( 0 ); i < count; ++i ) + { + if( dstSize == iLoadSizeArray[ i ] ) + { + sizeFound = ETrue; + } + } + if( !sizeFound ) + { + return KErrArgument; + } + } + + IHL_DEBUG1( KIHLDebug, "IHL - CIHLFileImage - Frame loading requested" ); + + iImageStatus = &aStatus; + *iImageStatus = KRequestPending; + + iDestination = static_cast( &aDestination ); //lint !e826 + iFrameIndex = aFrameIndex; + + // Start the active object + iImageState = EStartLoad; + SelfComplete(); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CIHLFileImage::StartLoadL +// ----------------------------------------------------------------------------- +void CIHLFileImage::StartLoadL() + { + __ASSERT_DEBUG( !iSubFrameBitmap, Panic( KErrGeneral ) ); + + IHL_DEBUG1( KIHLDebug, "IHL - CIHLFileImage - Start ICL convert" ); + + if( iAnimation ) + { + // Start animation from first frame by default + iSubFrameIndex = 0; + + // Check is animation can be continued on top of destination bitmap + if( iDestination->IsCreated() && + iDestination->EditorPtr() == this && + iDestination->EditorValue() < iFrameIndex ) + { + // Editor value means frame index + iSubFrameIndex = iDestination->EditorValue() + 1; + } + + StartLoadSubFrameL( iSubFrameIndex, ETrue ); + } + else if( iGif ) + { + StartLoadSubFrameL( iFrameIndex, EFalse ); + } + else + { + // Frame fills the whole image -> normal load + StartLoadNormalFrame( iFrameIndex ); + } + + iImageState = ECompleteLoad; + SetActive(); + } + +// ----------------------------------------------------------------------------- +// CIHLFileImage::StartLoadNormalFrame +// ----------------------------------------------------------------------------- +void CIHLFileImage::StartLoadNormalFrame( TInt aFrameIndex ) + { + CFbsBitmap& dstBitmap = iDestination->BitmapModifyable(); + CFbsBitmap& dstMask = iDestination->MaskModifyable(); + + if( MaskDisplayMode() && dstMask.Handle() ) + { + iDecoder->Convert( &iStatus, dstBitmap, dstMask, aFrameIndex ); + } + else + { + dstMask.Reset(); + iDecoder->Convert( &iStatus, dstBitmap, aFrameIndex ); + } + } + +// ----------------------------------------------------------------------------- +// CIHLFileImage::StartLoadSubFrameL +// ----------------------------------------------------------------------------- +void CIHLFileImage::StartLoadSubFrameL( TInt aFrameIndex, TBool aAnimation ) + { + __ASSERT_DEBUG( !iSubFrameBitmap, Panic( KErrGeneral ) ); + + // Create animation bitmap + iSubFrameBitmap = CIHLBitmap::NewL(); + CFbsBitmap& subBitmap = iSubFrameBitmap->BitmapModifyable(); + CFbsBitmap& subMask = iSubFrameBitmap->MaskModifyable(); + + TSize dstSize( iDestination->Bitmap().SizeInPixels() ); + TFrameInfo subFrameInfo( iDecoder->FrameInfo( aFrameIndex ) ); + + // Check is client uses downscaling (not used in animations) + TSize loadSize( subFrameInfo.iFrameSizeInPixels ); + iSubFrameScaleFactor = EFull; + if( !aAnimation && + dstSize != iFrameInfo.iOverallSizeInPixels ) + { + if( dstSize == ScaledLoadSize( iFrameInfo.iOverallSizeInPixels, EHalf ) ) + { + iSubFrameScaleFactor = EHalf; + loadSize = ScaledLoadSize( loadSize, EHalf ); + } + else if( dstSize == ScaledLoadSize( iFrameInfo.iOverallSizeInPixels, EQuarter ) ) + { + iSubFrameScaleFactor = EQuarter; + loadSize = ScaledLoadSize( loadSize, EQuarter ); + } + else if( dstSize == ScaledLoadSize( iFrameInfo.iOverallSizeInPixels, EEighth ) ) + { + iSubFrameScaleFactor = EEighth; + loadSize = ScaledLoadSize( loadSize, EEighth ); + } + } + User::LeaveIfError( subBitmap.Create( loadSize, EColor16M ) ); + + if( subFrameInfo.iFlags & TFrameInfo::ETransparencyPossible ) + { + User::LeaveIfError( subMask.Create( loadSize, + subFrameInfo.iFlags & TFrameInfo::EAlphaChannel ? EGray256 : EGray2 ) ); + iDecoder->Convert( &iStatus, subBitmap, subMask, aFrameIndex ); + } + else + { + iDecoder->Convert( &iStatus, subBitmap, aFrameIndex ); + } + } + +// ----------------------------------------------------------------------------- +// CIHLFileImage::CompleteLoadL +// ----------------------------------------------------------------------------- +void CIHLFileImage::CompleteLoadL() + { + IHL_DEBUG1( KIHLDebug1, "IHL - CIHLFileImage - ICL convert complete!" ); + + if( iSubFrameBitmap ) + { + IHL_DEBUG1( KIHLDebug2, "IHL - CIHLFileImage - Start build animation frame" ); + + // Copy animation bitmap to destination + BuildSubFrameL(); + delete iSubFrameBitmap; + iSubFrameBitmap = NULL; + + IHL_DEBUG1( KIHLDebug3, "IHL - CIHLFileImage - Animation frame complete!" ); + + // Save source info destination + iDestination->SetEditorPtr( this ); + iDestination->SetEditorValue( iSubFrameIndex ); + + if( iSubFrameIndex < iFrameIndex ) + { + // re-start the active object and load next subframe + iSubFrameIndex++; + iImageState = EStartLoad; + SelfComplete(); + } + else + { + // Animation/subframe image ready + iDestination = NULL; + iImageState = EInactive; + RequestComplete( KErrNone ); + } + } + else + { + // Save source info destination + iDestination->SetEditorPtr( this ); + iDestination->SetEditorValue( iFrameIndex ); + + // Normal image ready + iDestination = NULL; + iImageState = EInactive; + RequestComplete( KErrNone ); + } + + IHL_DEBUG1( KIHLDebug4, "IHL - CIHLFileImage - Frame loading request complete!" ); + } + +// ----------------------------------------------------------------------------- +// CIHLFileImage::BuildSubFrameL +// ----------------------------------------------------------------------------- +void CIHLFileImage::BuildSubFrameL() + { + __ASSERT_DEBUG( iSubFrameBitmap, Panic( KErrGeneral ) ); + const CFbsBitmap& subBitmap = iSubFrameBitmap->Bitmap(); + const CFbsBitmap& subMask = iSubFrameBitmap->Mask(); + __ASSERT_DEBUG( subBitmap.Handle(), Panic( KErrGeneral ) ); + + if( !iAnimation || + ( iAnimation && iSubFrameIndex == 0 ) ) + { + TFrameInfo frameInfo( iDecoder->FrameInfo( iSubFrameIndex ) ); + if( iDestination->Bitmap().SizeInPixels() == subBitmap.SizeInPixels() && + frameInfo.iFrameCoordsInPixels.iTl == TPoint(0,0) ) + { + // Sub frame is same size as destination image and has no offset + // -> put directly into destination + User::LeaveIfError( iDestination->Copy( subBitmap, subMask, ETrue ) ); + } + else + { + // Sub frame size differs from destination image size + CFbsBitmap& desBitmap = iDestination->BitmapModifyable(); + CFbsBitmap& desMask = iDestination->MaskModifyable(); + + // Other frames must be build on top of previous frames + __ASSERT_DEBUG( desBitmap.Handle(), Panic( KErrGeneral ) ); + + // Fill destination using background color + FillL( desBitmap, frameInfo.iBackgroundColor ); + + // Copy loaded frame on top of background + CFbsBitGc* bitGc; + CFbsBitmapDevice* bitDevice = CFbsBitmapDevice::NewL( &desBitmap ); + CleanupStack::PushL( bitDevice ); + User::LeaveIfError( bitDevice->CreateContext( bitGc ) ); + CleanupStack::PushL( bitGc ); + + TPoint framePos( ScaledFramePosition( + frameInfo.iFrameCoordsInPixels.iTl, iSubFrameScaleFactor ) ); + if( subMask.Handle() ) + { + bitGc->BitBltMasked( framePos, &subBitmap, + subBitmap.SizeInPixels(), &subMask, EFalse ); + } + else + { + bitGc->BitBlt( framePos, &subBitmap, subBitmap.SizeInPixels() ); + } + CleanupStack::PopAndDestroy( 2, bitDevice ); // bitGc, bitDevice + + if( desMask.Handle() ) + { + // Fill mask to transparent + FillL( desMask, KRgbBlack ); + + // Fill bg mask with transparency (=black) + CFbsBitmapDevice* maskDev = CFbsBitmapDevice::NewL( &desMask ); + CleanupStack::PushL( maskDev ); + CFbsBitGc* maskGc; + User::LeaveIfError( maskDev->CreateContext( maskGc ) ); + CleanupStack::PushL( maskGc ); + + // Combine bg mask with first frame mask + maskGc->BitBlt( framePos, &subMask, subMask.SizeInPixels() ); + + CleanupStack::PopAndDestroy( 2, maskDev ); // maskGc, maskDev + } + } + + // Create "previous frame" if animation + if( iAnimation ) + { + if( !iPrevAnimationFrame ) + { + iPrevAnimationFrame = CIHLBitmap::NewL(); + } + CFbsBitmap& desBitmap = iDestination->BitmapModifyable(); + CFbsBitmap& desMask = iDestination->MaskModifyable(); + if( iSubFrameBitmap->HasMask() ) + { + User::LeaveIfError( + iPrevAnimationFrame->Create( desBitmap.SizeInPixels(), + desBitmap.DisplayMode(), desMask.DisplayMode() ) ); + FillL( iPrevAnimationFrame->BitmapModifyable(), frameInfo.iBackgroundColor ); + FillL( iPrevAnimationFrame->MaskModifyable(), KRgbBlack ); + } + else + { + User::LeaveIfError( + iPrevAnimationFrame->Create( desBitmap.SizeInPixels(), + desBitmap.DisplayMode() ) ); + FillL( iPrevAnimationFrame->BitmapModifyable(), frameInfo.iBackgroundColor ); + } + } + } + else // same as iAnimation && iSubFrameIndex > 0 + { + TFrameInfo prevFrameInfo( iDecoder->FrameInfo( iSubFrameIndex - 1 ) ); + if ( prevFrameInfo.iFlags & TFrameInfo::ERestoreToPrevious ) + { + // Restore destination to "previous frame" + User::LeaveIfError( iDestination->Copy( *iPrevAnimationFrame, EFalse ) ); + } + + CFbsBitmap& prevBitmap = iDestination->BitmapModifyable(); + CFbsBitmap& prevMask = iDestination->MaskModifyable(); + + // Other frames must be build on top of previous frames + __ASSERT_DEBUG( prevBitmap.Handle(), Panic( KErrGeneral ) ); + + // Restore area in destination bitmap if needed + TRect restoreRect; + TBool restoreToBackground( EFalse ); + if( prevFrameInfo.iFlags & TFrameInfo::ERestoreToBackground ) + { + restoreToBackground = ETrue; + restoreRect = prevFrameInfo.iFrameCoordsInPixels; + FillRectL( prevBitmap, restoreRect, prevFrameInfo.iBackgroundColor ); + + // Cache new "previous frame" + User::LeaveIfError( iPrevAnimationFrame->Copy( *iDestination, EFalse ) ); + } + else if( prevFrameInfo.iFlags & TFrameInfo::ELeaveInPlace ) + { + // Cache new "previous frame" + User::LeaveIfError( iPrevAnimationFrame->Copy( *iDestination, EFalse ) ); + } + + // Copy animation frame to destination bitmap + TFrameInfo frameInfo( iDecoder->FrameInfo( iSubFrameIndex ) ); + CFbsBitGc* bitGc; + CFbsBitmapDevice* bitDevice = CFbsBitmapDevice::NewL( &prevBitmap ); + CleanupStack::PushL( bitDevice ); + User::LeaveIfError( bitDevice->CreateContext( bitGc ) ); + CleanupStack::PushL( bitGc ); + if( subMask.Handle() ) + { + bitGc->BitBltMasked( frameInfo.iFrameCoordsInPixels.iTl, &subBitmap, + subBitmap.SizeInPixels(), &subMask, EFalse ); + } + else + { + bitGc->BitBlt( frameInfo.iFrameCoordsInPixels.iTl, &subBitmap, + subBitmap.SizeInPixels() ); + } + CleanupStack::PopAndDestroy( 2 ); // bitGc, bitDevice + + // Combine masks if any + if( prevMask.Handle() && subMask.Handle() ) + { + ////////////////////////////////////////////////////////////////////////// + // ALTERNATIVE WAY TO COMBINE MASKS! + // Current solution doesn't combine soft masks. + // Following code could be used if soft masks are enabled in animations. + // Do not delete! + ////////////////////////////////////////////////////////////////////////// + /* + if( restoreToBackground ) + { + bitDevice = CFbsBitmapDevice::NewL( &prevMask ); + CleanupStack::PushL( bitDevice ); + User::LeaveIfError( bitDevice->CreateContext( bitGc ) ); + CleanupStack::PushL( bitGc ); + + bitGc->SetBrushColor( KRgbBlack ); + bitGc->SetBrushStyle( CGraphicsContext::ESolidBrush ); + bitGc->DrawRect( restoreRect ); + bitGc->SetBrushStyle( CGraphicsContext::ENullBrush ); + + CleanupStack::PopAndDestroy( 2 ); // bitDevice, bitGc + } + + prevMask.LockHeap(); + + TUint8* srcAddress = reinterpret_cast( animMask.DataAddress() ); + TSize srcSize( animMask.SizeInPixels() ); + TPoint srcPos( 0,0 ); + TInt srcScanLen8 = CFbsBitmap::ScanLineLength( srcSize.iWidth, EGray256 ); + + TUint8* dstAddress = reinterpret_cast( prevMask.DataAddress() ); + TSize dstSize( prevMask.SizeInPixels() ); + TPoint dstPos( frameInfo.iFrameCoordsInPixels.iTl ); + TPoint dstEndPos( frameInfo.iFrameCoordsInPixels.iBr ); + TInt dstScanLen8 = CFbsBitmap::ScanLineLength( dstSize.iWidth, EGray256 ); + + while( dstPos.iY < dstEndPos.iY ) + { + TUint8* srcAddressCur = srcAddress + ( srcPos.iY * srcScanLen8 ); + TUint8* dstAddressCur = dstAddress + ( dstPos.iY * dstScanLen8 ); + while( dstPos.iX < dstEndPos.iX ) + { + TUint8& srcPixel = srcAddressCur[ srcPos.iX++ ]; + TUint8& dstPixel = dstAddressCur[ dstPos.iX++ ]; + if( srcPixel > dstPixel ) + { + dstPixel = srcPixel; + } + } + + srcPos.iX = 0; + srcPos.iY++; + dstPos.iX = frameInfo.iFrameCoordsInPixels.iTl.iX; + dstPos.iY++; + } + + animMask.UnlockHeap(); + */ + + if( restoreToBackground ) + { + FillRectL( prevMask, restoreRect, KRgbBlack ); + } + + bitDevice = CFbsBitmapDevice::NewL( &prevMask ); + CleanupStack::PushL( bitDevice ); + User::LeaveIfError( bitDevice->CreateContext( bitGc ) ); + CleanupStack::PushL( bitGc ); + + CFbsBitmap* tmpMask = new(ELeave) CFbsBitmap; + CleanupStack::PushL( tmpMask ); + User::LeaveIfError( tmpMask->Create( prevMask.SizeInPixels(), prevMask.DisplayMode() ) ); + CFbsBitmapDevice* tmpMaskDev = CFbsBitmapDevice::NewL( tmpMask ); + CleanupStack::PushL( tmpMaskDev ); + CFbsBitGc* tmpMaskGc; + User::LeaveIfError( tmpMaskDev->CreateContext( tmpMaskGc ) ); + CleanupStack::PushL( tmpMaskGc ); + + tmpMaskGc->BitBlt( TPoint( 0, 0 ), &prevMask, frameInfo.iFrameCoordsInPixels ); + + bitGc->BitBltMasked( frameInfo.iFrameCoordsInPixels.iTl, &subMask, + subMask.SizeInPixels(), tmpMask, ETrue ); + + CleanupStack::PopAndDestroy( 5 ); // tmpMaskGc,tmpMaskDev,tmpMask,bitGc,bitDevice + } + else + { + prevMask.Reset(); // Mask not valid anymore -> reset + } + } + } + +// ----------------------------------------------------------------------------- +// CIHLFileImage::FillL +// ----------------------------------------------------------------------------- +void CIHLFileImage::FillL( CFbsBitmap& aBitmap, const TRgb& aColor ) + { + CFbsBitGc* bitGc; + CFbsBitmapDevice* bitDevice = CFbsBitmapDevice::NewL( &aBitmap ); + CleanupStack::PushL( bitDevice ); + User::LeaveIfError( bitDevice->CreateContext( bitGc ) ); + CleanupStack::PushL( bitGc ); + + bitGc->SetBrushColor( aColor ); + bitGc->SetPenColor( aColor ); + bitGc->SetBrushStyle( CGraphicsContext::ESolidBrush ); + bitGc->Clear(); + bitGc->SetBrushStyle( CGraphicsContext::ENullBrush ); + + CleanupStack::PopAndDestroy( 2 ); // bitGc, bitDevice + } + +// ----------------------------------------------------------------------------- +// CIHLFileImage::FillRectL +// ----------------------------------------------------------------------------- +void CIHLFileImage::FillRectL( CFbsBitmap& aBitmap, const TRect& aRect, + const TRgb& aColor ) + { + CFbsBitGc* bitGc; + CFbsBitmapDevice* bitDevice = CFbsBitmapDevice::NewL( &aBitmap ); + CleanupStack::PushL( bitDevice ); + User::LeaveIfError( bitDevice->CreateContext( bitGc ) ); + CleanupStack::PushL( bitGc ); + + bitGc->SetBrushColor( aColor ); + bitGc->SetPenColor( aColor ); + bitGc->SetBrushStyle( CGraphicsContext::ESolidBrush ); + bitGc->DrawRect( aRect ); + bitGc->SetBrushStyle( CGraphicsContext::ENullBrush ); + + CleanupStack::PopAndDestroy( 2 ); // bitGc, bitDevice + } + +// ----------------------------------------------------------------------------- +// CIHLFileImage::ErrorCleanup +// ----------------------------------------------------------------------------- +void CIHLFileImage::ErrorCleanup() + { + if( iSubFrameBitmap ) + { + delete iSubFrameBitmap; + iSubFrameBitmap = NULL; + } + + if( iDestination ) + { + iDestination = NULL; + } + } + +// ----------------------------------------------------------------------------- +// CIHLFileImage::SelfComplete +// ----------------------------------------------------------------------------- +void CIHLFileImage::SelfComplete() + { + SetActive(); + iStatus = KRequestPending; + TRequestStatus* status = &iStatus; + User::RequestComplete( status, KErrNone ); + } + +// ----------------------------------------------------------------------------- +// CIHLFileImage::RequestComplete +// ----------------------------------------------------------------------------- +void CIHLFileImage::RequestComplete( TInt aReason ) + { + ASSERT( iImageStatus ); + User::RequestComplete( iImageStatus, aReason ); + } + +// ----------------------------------------------------------------------------- +// CIHLFileImage::ScaledLoadSize +// ----------------------------------------------------------------------------- +TSize CIHLFileImage::ScaledLoadSize( const TSize& aOriginalSize, TInt aScaleFactor ) + { + // Divide original size with scalefactor + // Round always up if result is not integer + return ( aScaleFactor == EFull ) ? aOriginalSize : + TSize( aOriginalSize.iWidth / aScaleFactor + ( aOriginalSize.iWidth % aScaleFactor ? 1 : 0 ), + aOriginalSize.iHeight / aScaleFactor + ( aOriginalSize.iHeight % aScaleFactor ? 1 : 0 ) ); + } + +// ----------------------------------------------------------------------------- +// CIHLFileImage::ScaledLoadSize +// ----------------------------------------------------------------------------- +TPoint CIHLFileImage::ScaledFramePosition( const TPoint& aOriginalPos, TInt aScaleFactor ) + { + // Divide original position with scalefactor + // Round always up if result is not integer + return ( aScaleFactor == EFull ) ? aOriginalPos : + TPoint( aOriginalPos.iX / aScaleFactor + ( aOriginalPos.iX % aScaleFactor ? 1 : 0 ), + aOriginalPos.iY / aScaleFactor + ( aOriginalPos.iY % aScaleFactor ? 1 : 0 ) ); + } +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandlinglib/Src/CIHLFileImage.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlinglib/Src/CIHLFileImage.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,314 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of ImageFile class. +* +*/ + + +#ifndef CIHLFILEIMAGE_H +#define CIHLFILEIMAGE_H + +// INCLUDES +#include +#include +#include // TFrameInfo +#include // TDisplayMode +#include + +// FORWARD DECLARATIONS +class MIHLBitmap; +class CIHLBitmap; +class CImageDecoder; +class TRequestStatus; + +// CLASS DECLARATION +/** +* CIHLImage +* +* Implementation of file based image class. +* @lib IHL.lib +* @since 3.0 +*/ +NONSHARABLE_CLASS( CIHLFileImage ) : public CActive, public MIHLFileImage + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CIHLFileImage* NewL( RFile& aFile, TInt aImageIndex, const TUint32 aOptions ); + static CIHLFileImage* NewL( RFs& aFs, const TDesC8& aDataBuf, + TInt aImageIndex, const TUint32 aOptions ); + + /* + * Virtual destructor. + */ + virtual ~CIHLFileImage(); + + public: // From base class MIHLImage + + /* + * From MIHLImage, see base class header. + */ + TIHLInterfaceType Type() const; + + public: // From base class MIHLFileImage + + /* + * From MIHLFileImage, see base class header. + */ + const TUid& ImageType() const; + + /* + * From MIHLFileImage, see base class header. + */ + const TUid& ImageSubType() const; + + /* + * From MIHLFileImage, see base class header. + */ + TInt ImageIndex() const; + + /* + * From MIHLFileImage, see base class header. + */ + TInt ImageCount() const; + + /* + * From MIHLFileImage, see base class header. + */ + TSize Size() const; + + /* + * From MIHLFileImage, see base class header. + */ + TDisplayMode DisplayMode() const; + + /* + * From MIHLFileImage, see base class header. + */ + TDisplayMode MaskDisplayMode() const; + + /* + * From MIHLFileImage, see base class header. + */ + TRgb BackgroundColor() const; + + /* + * From MIHLFileImage, see base class header. + */ + const RArray& CustomLoadSizeArray() const; + + /* + * From MIHLFileImage, see base class header. + */ + TBool IsFullyScaleable() const; + + /* + * From MIHLFileImage, see base class header. + */ + TBool IsAnimation() const; + + /* + * From MIHLFileImage, see base class header. + */ + TInt AnimationFrameCount() const; + + /* + * From MIHLFileImage, see base class header. + */ + TTimeIntervalMicroSeconds32 AnimationFrameDelay( TInt aAnimationFrameIndex ) const; + + /* + * From MIHLFileImage, see base class header. + */ + TInt Load( TRequestStatus& aStatus, MIHLBitmap& aDestination, TInt aFrameIndex = 0 ); + + /* + * From MIHLFileImage, see base class header. + */ + TInt LoadAnimation( TRequestStatus& aStatus, MIHLBitmap& aDestination, + TInt aAnimationFrameIndex ); + + /* + * From MIHLFileImage, see base class header. + */ + TBool IsBusy() const; + + /* + * From MIHLFileImage, see base class header. + */ + void CancelLoad(); + + /* + * From MIHLFileImage, see base class header. + */ + void SetFilter( MIHLFilter* aFilter ); + + private: // From base class CActive + + /* + * From CActive, see base class header. + */ + void DoCancel(); + + /* + * From CActive, see base class header. + */ + void RunL(); + + /* + * From CActive, see base class header. + */ + TInt RunError( TInt aError ); + + public: // Internal interface + + /** + * Return reference to used CImageDecoder instance. + * For internal use. + * @since 3.0 + * @return Reference to used CImageDecoder instance. + */ + const CImageDecoder& Decoder() const; + + private: // Private methods + + /* + * Request load and start ActiveScheduler. + * Called from Load() and LoadAnimation() methods. + */ + TInt LoadRequest( TRequestStatus& aStatus, MIHLBitmap& aDestination, TInt aFrameIndex ); + + /* + * Start loading from file. Checks if image is still or animation. + * Called by ActiveSheduler when state is EStartLoad. + */ + void StartLoadL(); + + /* + * Start loading normal frame. Called by StartLoadL() method. + */ + void StartLoadNormalFrame( TInt aFrameIndex ); + + /* + * Start loading sub frame. Called by StartLoadL() method. + */ + void StartLoadSubFrameL( TInt aFrameIndex, TBool aAnimation ); + + /* + * Loading complete. Build possible animation and notify client. + * Called by ActiveSheduler when state is ECompleteLoad. + */ + void CompleteLoadL(); + + /* + * Build sub frame. Called by CompleteLoadL() method. + */ + void BuildSubFrameL(); + + /* + * Fill whole bitmap using given color. + * Used by BuildAnimationFrameL(). + */ + void FillL( CFbsBitmap& aBitmap, const TRgb& aColor ); + + /* + * Fill bitmap rect using given color. + * Used by BuildAnimationFrameL(). + */ + void FillRectL( CFbsBitmap& aBitmap, const TRect& aRect, const TRgb& aColor ); + + /* + * Error cleanup. Called if error occurs during load. + */ + void ErrorCleanup(); + + /* + * Complete dummy request. This causes RunL() method to be called. + * Needed by state machine. + */ + void SelfComplete(); + + /* + * Complete client load request. + * This causes client RunL() method to be called. + */ + void RequestComplete( TInt aReason ); + + /* + * Calculate scaled size. + * Original size is divided by scale factor and result is rounded up + * to next integer. + */ + TSize ScaledLoadSize( const TSize& aOriginalSize, TInt aScaleFactor ); + + /* + * Calculate scaled frame position. + * Original position is divided by scale factor and result is rounded up + * to next integer. + */ + TPoint ScaledFramePosition( const TPoint& aOriginalPos, TInt aScaleFactor ); + + private: // Private constructors + + CIHLFileImage( TInt aImageIndex ); + void ConstructL( RFile& aFile, const TUint32 aOptions ); + void ConstructL( RFs& aFs, const TDesC8& aDataBuf, const TUint32 aOptions ); + void ConstructCommonL(); + + private: // Private data types + + enum TImageState + { + EInactive, + EStartLoad, + ECompleteLoad, + }; + + private: // Data + + // Ref: Image status & state + TRequestStatus* iImageStatus; + TImageState iImageState; + + // Own: Image decoder + CImageDecoder* iDecoder; + + // Image information + TUid iImageType; + TUid iImageSubType; + TInt iImageIndex; + TInt iImageCount; + RArray iLoadSizeArray; + TBool iFullyScaleable; + TFrameInfo iFrameInfo; + TBool iGif; + TBool iAnimation; + TInt iAnimationFrameCount; + + // Ref: Destination bitmap + CIHLBitmap* iDestination; + TInt iFrameIndex; + + // Own: Temporary animation bitmap + CIHLBitmap* iSubFrameBitmap; + TInt iSubFrameIndex; + CIHLBitmap* iPrevAnimationFrame; + TInt iSubFrameScaleFactor; + }; + +#endif // CIHLFILEIMAGE_H + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandlinglib/Src/CIHLFileImageExtJpg.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlinglib/Src/CIHLFileImageExtJpg.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,610 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of FileImageExtJpg class. +* +*/ + + +// INCLUDE FILES +#include "CIHLFileImageExtJpg.h" + +#include "CIHLBitmap.h" +#include "IHLImplementationIds.h" +#include +#include + +// Private namespace for constants and functions +namespace + { + // Fixed scale factors + enum TScaleFactors + { + EHalf = 2, + EQuarter = 4, + EEighth = 8, + }; + + // Panic function + _LIT( KIHLExtJpgPanic, "IHLImageExtJpg" ); + void Panic( TInt aPanicCode ) { User::Panic( KIHLExtJpgPanic, aPanicCode ); } + } + +// ============================ MEMBER FUNCTIONS =============================== +// ----------------------------------------------------------------------------- +// +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +CIHLFileImageExtJpg::CIHLFileImageExtJpg( TInt aImageIndex ) +:CActive( CActive::EPriorityStandard ), +iImageIndex( aImageIndex ) + { + CActiveScheduler::Add( this ); + } + +// ----------------------------------------------------------------------------- +// +// Two-phased constructor. +// ----------------------------------------------------------------------------- + +CIHLFileImageExtJpg* CIHLFileImageExtJpg::NewL( RFs& aFs, const TDesC8& aDataBuf, + TInt aImageIndex, const TUint32 aOptions ) + { + CIHLFileImageExtJpg* self = new (ELeave) CIHLFileImageExtJpg( aImageIndex ); + CleanupStack::PushL( self ); + self->ConstructL( aFs, aDataBuf, aOptions ); + CleanupStack::Pop(); // self + return self; + } + +CIHLFileImageExtJpg* CIHLFileImageExtJpg::NewL( RFs& aFs, const TDesC& aFilename, + TInt aImageIndex, const TUint32 aOptions ) + { + CIHLFileImageExtJpg* self = new (ELeave) CIHLFileImageExtJpg( aImageIndex ); + CleanupStack::PushL( self ); + self->ConstructL( aFs, aFilename, aOptions ); + CleanupStack::Pop(); // self + return self; + } + +// ----------------------------------------------------------------------------- +// +// Symbian constructor can leave. +// ----------------------------------------------------------------------------- + + +void CIHLFileImageExtJpg::ConstructL( RFs& aFs, const TDesC& aFilename, const TUint32 /*aOptions*/ ) + { + TRAPD( err, iDecoder = CExtJpegDecoder::FileNewL( CExtJpegDecoder::EHwImplementation, aFs, aFilename ) ); + + if ( err != KErrNone ) + { + iDecoder = CExtJpegDecoder::FileNewL( CExtJpegDecoder::ESwImplementation, aFs, aFilename ); + } + + ConstructCommonL(); + } + +void CIHLFileImageExtJpg::ConstructL( RFs& aFs, const TDesC8& aDataBuf, const TUint32 /*aOptions*/ ) + { + TRAPD( err, iDecoder = CExtJpegDecoder::DataNewL( CExtJpegDecoder::EHwImplementation, aFs, aDataBuf ) ); + + if ( err != KErrNone ) + { + iDecoder = CExtJpegDecoder::DataNewL( CExtJpegDecoder::ESwImplementation, aFs, aDataBuf ); + } + + ConstructCommonL(); + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::ConstructCommonL +// ----------------------------------------------------------------------------- +void CIHLFileImageExtJpg::ConstructCommonL() + { + // Check frame count and image index + iImageCount = iDecoder->FrameCount(); + __ASSERT_ALWAYS( iImageCount > 0, User::Leave( KErrCorrupt ) ); + + // Get image types + iDecoder->ImageType( iImageIndex, iImageType, iImageSubType ); + + __ASSERT_ALWAYS( iImageIndex >= 0 && iImageIndex < iImageCount, User::Leave( KErrArgument ) ); + + // cache frame info and set scale sizes + iFrameInfo = iDecoder->FrameInfo( iImageIndex ); + if( iFrameInfo.iFlags & TFrameInfo::EFullyScaleable ) + { + iFullyScaleable = ETrue; + } + } + +// ----------------------------------------------------------------------------- +// Destructor +// ----------------------------------------------------------------------------- +CIHLFileImageExtJpg::~CIHLFileImageExtJpg() + { + Cancel(); + delete iDecoder; + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::Type +// ----------------------------------------------------------------------------- +TIHLInterfaceType CIHLFileImageExtJpg::Type() const + { + return TIHLInterfaceType( KIHLInterfaceIdFileImage, + KIHLImplementationIdFileImageExtJpg ); + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::ImageType +// ----------------------------------------------------------------------------- +const TUid& CIHLFileImageExtJpg::ImageType() const + { + return iImageType; + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::ImageSubType +// ----------------------------------------------------------------------------- +const TUid& CIHLFileImageExtJpg::ImageSubType() const + { + return iImageSubType; + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::ImageIndex +// ----------------------------------------------------------------------------- +TInt CIHLFileImageExtJpg::ImageIndex() const + { + return iImageIndex; + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::ImageCount +// ----------------------------------------------------------------------------- +TInt CIHLFileImageExtJpg::ImageCount() const + { + return iImageCount; + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::Size +// ----------------------------------------------------------------------------- +TSize CIHLFileImageExtJpg::Size() const + { + return iFrameInfo.iOverallSizeInPixels; + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::DisplayMode +// ----------------------------------------------------------------------------- +TDisplayMode CIHLFileImageExtJpg::DisplayMode() const + { + TDisplayMode displayMode( iFrameInfo.iFrameDisplayMode ); + if( iFrameInfo.iFrameDisplayMode <= EGray256 ) + { + displayMode = EGray256; + } + else if( iFrameInfo.iFrameDisplayMode <= EColor256 ) + { + displayMode = EColor256; + } + + return displayMode; + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::MaskDisplayMode +// ----------------------------------------------------------------------------- +TDisplayMode CIHLFileImageExtJpg::MaskDisplayMode() const + { + if( iFrameInfo.iFlags & TFrameInfo::ETransparencyPossible ) + { + if( iFrameInfo.iFlags & TFrameInfo::EAlphaChannel ) + { + return EGray256; + } + return EGray2; + } + return ENone; + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::BackgroundColor +// ----------------------------------------------------------------------------- +TRgb CIHLFileImageExtJpg::BackgroundColor() const + { + return iFrameInfo.iBackgroundColor; + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::CustomLoadSizeArray +// ----------------------------------------------------------------------------- +const RArray& CIHLFileImageExtJpg::CustomLoadSizeArray() const + { + return iLoadSizeArray; + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::IsFullyScaleable +// ----------------------------------------------------------------------------- +TBool CIHLFileImageExtJpg::IsFullyScaleable() const + { + return iFullyScaleable; + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::IsAnimation +// ----------------------------------------------------------------------------- +TBool CIHLFileImageExtJpg::IsAnimation() const + { + return iAnimation; + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::AnimationFrameCount +// ----------------------------------------------------------------------------- +TInt CIHLFileImageExtJpg::AnimationFrameCount() const + { + return iAnimationFrameCount; + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::AnimationFrameDelay +// ----------------------------------------------------------------------------- +TTimeIntervalMicroSeconds32 CIHLFileImageExtJpg::AnimationFrameDelay( TInt aAnimationFrameIndex ) const + { + //Animation is not supported + ( void ) aAnimationFrameIndex; + Panic( KErrNotSupported ); + return 0; + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::Load +// ----------------------------------------------------------------------------- +TInt CIHLFileImageExtJpg::Load( TRequestStatus& aStatus, MIHLBitmap& aDestination, TInt aFrameIndex ) + { + iImageIndex = aFrameIndex; + return LoadRequest( aStatus, aDestination, iImageIndex ); + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::Load +// ----------------------------------------------------------------------------- +TInt CIHLFileImageExtJpg::Load( TRect aSrcRect, TRequestStatus& aStatus, MIHLBitmap& aDestination, TInt aFrameIndex ) + { + TRAPD( err, SetCroppingL( aSrcRect ) ); + if( err ) + { + return err; + } + iImageIndex = aFrameIndex; + return LoadRequest( aStatus, aDestination, iImageIndex ); + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::LoadAnimation +// ----------------------------------------------------------------------------- +TInt CIHLFileImageExtJpg::LoadAnimation( TRequestStatus& aStatus, MIHLBitmap& aDestination, + TInt aAnimationFrameIndex ) + { + //Animation is not supported + ( void ) aStatus; + ( void ) aDestination; + ( void ) aAnimationFrameIndex; + Panic( KErrNotSupported ); + return 0; + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::IsBusy +// ----------------------------------------------------------------------------- +TBool CIHLFileImageExtJpg::IsBusy() const + { + return ( iImageState != EInactive ); + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::CancelLoad +// ----------------------------------------------------------------------------- +void CIHLFileImageExtJpg::CancelLoad() + { + Cancel(); + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::SetFilter +// ----------------------------------------------------------------------------- +void CIHLFileImageExtJpg::SetFilter( MIHLFilter* /*aFilter*/ ) + { + // Not in use + } + + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::Decoder +// ----------------------------------------------------------------------------- +const CExtJpegDecoder& CIHLFileImageExtJpg::Decoder() const + { + return *iDecoder; + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::DoCancel +// ----------------------------------------------------------------------------- +void CIHLFileImageExtJpg::DoCancel() + { + iDecoder->Cancel(); + + // Delete all processed bitmaps + ErrorCleanup(); + + // Complete with cancel + iImageState = EInactive; + RequestComplete( KErrCancel ); + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::RunL +// ----------------------------------------------------------------------------- +void CIHLFileImageExtJpg::RunL() + { + __ASSERT_DEBUG( iDestination, Panic( KErrGeneral ) ); + User::LeaveIfError( iStatus.Int() ); + + switch( iImageState ) + { + case EStartLoad: + { + // start loading the bitmaps + StartLoadL(); + break; + } + case ECompleteLoad: + { + // complete loading the bitmaps + CompleteLoadL(); + break; + } + default: + { + Panic( KErrTotalLossOfPrecision ); + } + } + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::RunError +// ----------------------------------------------------------------------------- +TInt CIHLFileImageExtJpg::RunError( TInt aError ) + { + // Delete all processed bitmaps + ErrorCleanup(); + + // Complete with error + iImageState = EInactive; + RequestComplete( aError ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::LoadRequest +// ----------------------------------------------------------------------------- +TInt CIHLFileImageExtJpg::LoadRequest( TRequestStatus& aStatus, MIHLBitmap& aDestination, TInt aFrameIndex ) + { + if( IsBusy() ) + { + return KErrNotReady; + } + + if( aFrameIndex < 0 || aFrameIndex >= iDecoder->FrameCount() ) + { + return KErrArgument; + } + + const CFbsBitmap& dstBitmap = aDestination.Bitmap(); + if( !dstBitmap.Handle() ) + { + return KErrArgument; + } + + iImageStatus = &aStatus; + *iImageStatus = KRequestPending; + + iDestination = static_cast( &aDestination ); //lint !e826 + iFrameIndex = aFrameIndex; + + // Start the active object + iImageState = EStartLoad; + SelfComplete(); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::StartLoadL +// ----------------------------------------------------------------------------- +void CIHLFileImageExtJpg::StartLoadL() + { + CFbsBitmap& dstBitmap = iDestination->BitmapModifyable(); + CFbsBitmap& dstMask = iDestination->MaskModifyable(); + + if( MaskDisplayMode() && dstMask.Handle() ) + { + iDecoder->Convert( &iStatus, dstBitmap, dstMask, iFrameIndex ); + } + else + { + dstMask.Reset(); + iDecoder->Convert( &iStatus, dstBitmap, iFrameIndex ); + } + iImageState = ECompleteLoad; + SetActive(); + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::CompleteLoadL +// ----------------------------------------------------------------------------- +void CIHLFileImageExtJpg::CompleteLoadL() + { + // Save source info destination + iDestination->SetEditorPtr( this ); + iDestination->SetEditorValue( iFrameIndex ); + + // Normal image ready + iDestination = NULL; + iImageState = EInactive; + RequestComplete( KErrNone ); + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::ErrorCleanup +// ----------------------------------------------------------------------------- +void CIHLFileImageExtJpg::ErrorCleanup() + { + if( iDestination ) + { + iDestination = NULL; + } + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::SelfComplete +// ----------------------------------------------------------------------------- +void CIHLFileImageExtJpg::SelfComplete() + { + SetActive(); + iStatus = KRequestPending; + TRequestStatus* status = &iStatus; + User::RequestComplete( status, KErrNone ); + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::RequestComplete +// ----------------------------------------------------------------------------- +void CIHLFileImageExtJpg::RequestComplete( TInt aReason ) + { + ASSERT( iImageStatus ); + User::RequestComplete( iImageStatus, aReason ); + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::SetCroppingL +// ----------------------------------------------------------------------------- + +void CIHLFileImageExtJpg::SetCroppingL( TRect aCropRect ) + { + iDecoder->SetCroppingL( aCropRect ); + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::SetStreamingL +// ----------------------------------------------------------------------------- + +void CIHLFileImageExtJpg::SetStreamingL( TSize& aMacroBlockSize ) + { + iDecoder->SetStreamingL( aMacroBlockSize ); + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::SetRotationL +// ----------------------------------------------------------------------------- + +void CIHLFileImageExtJpg::SetRotationL( TInt aDegree ) + { + iDecoder->SetRotationL( aDegree ); + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::SetFlippingL +// ----------------------------------------------------------------------------- + +void CIHLFileImageExtJpg::SetFlippingL() + { + iDecoder->SetFlippingL(); + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::SetMirroringL +// ----------------------------------------------------------------------------- + +void CIHLFileImageExtJpg::SetMirroringL() + { + iDecoder->SetMirroringL(); + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::SetDctDecodingL +// ----------------------------------------------------------------------------- + +void CIHLFileImageExtJpg::SetDctDecodingL() + { + iDecoder->SetDctDecodingL(); + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::ConvertL +// ----------------------------------------------------------------------------- + +void CIHLFileImageExtJpg::ConvertL( + TRequestStatus* aRequestStatus, + const CVisualFrame* aDestinationFrame, + TInt& aNoOfDecodedMBlocks, + TInt aFrameNumber ) + { + iDecoder->ConvertL( + aRequestStatus, + aDestinationFrame, + aNoOfDecodedMBlocks, + aFrameNumber ); + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::ContinueConvertL +// ----------------------------------------------------------------------------- + +void CIHLFileImageExtJpg::ContinueConvertL( + TRequestStatus* aRequestStatus, + const CVisualFrame* aDestinationFrame, + TInt& aNoOfDecodedMBlocks, + TInt aFrameNumber ) + { + iDecoder->ContinueConvertL( + aRequestStatus, + aDestinationFrame, + aNoOfDecodedMBlocks, + aFrameNumber ); + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::SupportedFormatsL +// ----------------------------------------------------------------------------- + +TInt CIHLFileImageExtJpg::SupportedFormatsL() + { + return iDecoder->SupportedFormatsL(); + } + +// ----------------------------------------------------------------------------- +// CIHLFileImageExtJpg::CapabilitiesL +// ----------------------------------------------------------------------------- + +TInt CIHLFileImageExtJpg::CapabilitiesL() + { + return iDecoder->CapabilitiesL(); + } + +//End of file diff -r 000000000000 -r 2014ca87e772 imagehandlinglib/Src/CIHLFileImageExtJpg.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlinglib/Src/CIHLFileImageExtJpg.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,330 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of ImageFile class. +* +*/ + + +#ifndef CIHLFILEIMAGEEXTJPG_H +#define CIHLFILEIMAGEEXTJPG_H + +// INCLUDES +#include +#include // TFrameInfo +#include // TDisplayMode +#include "MIHLFileImageExtJpg.h" + +// FORWARD DECLARATIONS +class MIHLBitmap; +class CIHLBitmap; +class CExtJpegDecoder; +class CVisualFrame; + +// CLASS DECLARATION +/** +* CIHLFileImageExtJpg +* +* Implementation of file based ext jpg image class. +* @lib IHL.lib +* @since 3.0 +*/ + +NONSHARABLE_CLASS( CIHLFileImageExtJpg ) : public CActive, public MIHLFileImageExtJpg + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CIHLFileImageExtJpg* NewL( RFs& aFs, const TDesC8& aDataBuf, + TInt aImageIndex, const TUint32 aOptions ); + static CIHLFileImageExtJpg* NewL( RFs& aFs, const TDesC& aFilename, + TInt aImageIndex, const TUint32 aOptions ); + /* + * Virtual destructor. + */ + virtual ~CIHLFileImageExtJpg(); + + public: // From base class MIHLImage + + TIHLInterfaceType Type() const; + + public: // From base class MIHLFileImage + + /* + * From MIHLFileImage, see base class header. + */ + const TUid& ImageType() const; + + /* + * From MIHLFileImage, see base class header. + */ + const TUid& ImageSubType() const; + + /* + * From MIHLFileImage, see base class header. + */ + TInt ImageIndex() const; + + /* + * From MIHLFileImage, see base class header. + */ + TInt ImageCount() const; + + /* + * From MIHLFileImage, see base class header. + */ + TSize Size() const; + + /* + * From MIHLFileImage, see base class header. + */ + TDisplayMode DisplayMode() const; + + /* + * From MIHLFileImage, see base class header. + */ + TDisplayMode MaskDisplayMode() const; + + /* + * From MIHLFileImage, see base class header. + */ + TRgb BackgroundColor() const; + + /* + * From MIHLFileImage, see base class header. + */ + const RArray& CustomLoadSizeArray() const; + + /* + * From MIHLFileImage, see base class header. + */ + TBool IsFullyScaleable() const; + + /* + * From MIHLFileImage, see base class header. + */ + TBool IsAnimation() const; + + /* + * From MIHLFileImage, see base class header. + */ + TInt AnimationFrameCount() const; + + /* + * From MIHLFileImage, see base class header. + */ + TTimeIntervalMicroSeconds32 AnimationFrameDelay( TInt aAnimationFrameIndex ) const; + + /* + * From MIHLFileImage, see base class header. + */ + TInt Load( TRequestStatus& aStatus, MIHLBitmap& aDestination, TInt aFrameIndex = 0 ); + + /* + * From MIHLFileImage, see base class header. + */ + TInt LoadAnimation( TRequestStatus& aStatus, MIHLBitmap& aDestination, TInt aAnimationFrameIndex ); + + /* + * From MIHLFileImage, see base class header. + */ + TBool IsBusy() const; + + /* + * From MIHLFileImage, see base class header. + */ + void CancelLoad(); + + /* + * From MIHLFileImage, see base class header. + */ + void SetFilter( MIHLFilter* aFilter ); + + public: // From MIHLFileImageExtJpg + + /* + * From MIHLFileImageExtJpg, see base class header. + */ + TInt Load( TRect aSrcRect, TRequestStatus& aStatus, MIHLBitmap& aDestination, TInt aFrameIndex = 0 ); + + /* + * From MIHLFileImageExtJpg, see base class header. + */ + void SetCroppingL( TRect aCropRect ); + + /* + * From MIHLFileImageExtJpg, see base class header. + */ + void SetStreamingL( TSize& aMacroBlockSize ); + + /* + * From MIHLFileImageExtJpg, see base class header. + */ + void SetRotationL( TInt aDegree ); + + /* + * From MIHLFileImageExtJpg, see base class header. + */ + void SetFlippingL(); + + /* + * From MIHLFileImageExtJpg, see base class header. + */ + void SetMirroringL(); + + /* + * From MIHLFileImageExtJpg, see base class header. + */ + void SetDctDecodingL(); + + /* + * From MIHLFileImageExtJpg, see base class header. + */ + void ConvertL( + TRequestStatus* aRequestStatus, + const CVisualFrame* aDestinationFrame, + TInt& aNoOfDecodedMBlocks, + TInt aFrameNumber = 0 ); + + /* + * From MIHLFileImageExtJpg, see base class header. + */ + void ContinueConvertL( + TRequestStatus* aRequestStatus, + const CVisualFrame* aDestinationFrame, + TInt& aNoOfDecodedMBlocks, + TInt aFrameNumber = 0 ); + + /* + * From MIHLFileImageExtJpg, see base class header. + */ + TInt SupportedFormatsL(); + + /* + * From MIHLFileImageExtJpg, see base class header. + */ + TInt CapabilitiesL(); + + private: // From base class CActive + + /* + * From CActive, see base class header. + */ + void DoCancel(); + + /* + * From CActive, see base class header. + */ + void RunL(); + + /* + * From CActive, see base class header. + */ + TInt RunError( TInt aError ); + + public: // Internal interface + + /** + * Return reference to used CExtJpegDecoder instance. + * For internal use. + * @since 3.0 + * @return Reference to used CExtJpegDecoder instance. + */ + const CExtJpegDecoder& Decoder() const; + + private: // Private methods + + /* + * Request load and start ActiveScheduler. + * Called from Load() and LoadAnimation() methods. + */ + TInt LoadRequest( TRequestStatus& aStatus, MIHLBitmap& aDestination, TInt aFrameIndex ); + + /* + * Start loading from file. Checks if image is still or animation. + * Called by ActiveSheduler when state is EStartLoad. + */ + void StartLoadL(); + + /* + * Loading complete. Build possible animation and notify client. + * Called by ActiveSheduler when state is ECompleteLoad. + */ + void CompleteLoadL(); + + /* + * Error cleanup. Called if error occurs during load. + */ + void ErrorCleanup(); + + /* + * Complete dummy request. This causes RunL() method to be called. + * Needed by state machine. + */ + void SelfComplete(); + + /* + * Complete client load request. + * This causes client RunL() method to be called. + */ + void RequestComplete( TInt aReason ); + + private: // Private constructors + + CIHLFileImageExtJpg( TInt aImageIndex ); + + void ConstructL( RFs& aFs, const TDesC& aFilename, const TUint32 aOptions ); + void ConstructL( RFs& aFs, const TDesC8& aDataBuf, const TUint32 aOptions ); + void ConstructCommonL(); + + private: // Private data types + + enum TImageState + { + EInactive, + EStartLoad, + ECompleteLoad, + }; + + private: // Data + + // Ref: Image status & state + TRequestStatus* iImageStatus; + TImageState iImageState; + + // Own: Image decoder + CExtJpegDecoder* iDecoder; + + // Image information + TUid iImageType; + TUid iImageSubType; + TInt iImageIndex; + TInt iImageCount; + + TBool iFullyScaleable; + TFrameInfo iFrameInfo; + TBool iAnimation; + TInt iAnimationFrameCount; + + // Ref: Destination bitmap + CIHLBitmap* iDestination; + TInt iFrameIndex; + + RArray iLoadSizeArray; + }; + +#endif // CIHLFILEIMAGEEXTJPG_H + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandlinglib/Src/CIHLImageViewer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlinglib/Src/CIHLImageViewer.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,1369 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of Image Viewer class. +* +*/ + + +// INCLUDE FILES +#include "CIHLImageViewer.h" + +#include "CIHLBitmap.h" +#include "CIHLBitmapProcessor.h" +#include "IHLImplementationIds.h" +#include "IHLDebugPrint.h" // Debug print +#include +#include +#include +#include +#include + +// Private namespace for constants and functions +namespace + { + // Panic function + _LIT( KIHLPanicString, "IHLImageViewer" ); + void Panic( TInt aPanicCode ) { User::Panic( KIHLPanicString, aPanicCode ); } + } + +// ============================ MEMBER FUNCTIONS =============================== +// ----------------------------------------------------------------------------- +// +// C++ constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +CIHLImageViewer::CIHLImageViewer( const TSize& aViewerSize, + MIHLFileImage& aSource, + MIHLBitmap& aDestination, + MIHLViewerObserver& aObserver, + const TUint32 aOptions ) +:CTimer( EPriorityNormal ), iObserver( aObserver ), +iSource( aSource ), iDestination( aDestination ), +iOptions( aOptions ), iViewerSize( aViewerSize ), iSrcBitmapScaleFactor(1) + { + CActiveScheduler::Add( this ); + iAnimDelay = 0; + iAnimLastFrameDrawTime = 0; + iAnimDrawStartFastTime = 0; + } + +// ----------------------------------------------------------------------------- +// +// Two-phased constructor. +// ----------------------------------------------------------------------------- +CIHLImageViewer* CIHLImageViewer::NewL( const TSize& aViewerSize, + MIHLFileImage& aSource, + MIHLBitmap& aDestination, + MIHLViewerObserver& aObserver, + const TUint32 aOptions ) + { + CIHLImageViewer* self = new( ELeave ) CIHLImageViewer( + aViewerSize, aSource, aDestination, aObserver, aOptions ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); // self + return self; + } + +// ----------------------------------------------------------------------------- +// +// Symbian constructor can leave. +// ----------------------------------------------------------------------------- +void CIHLImageViewer::ConstructL() + { + CTimer::ConstructL(); + + HAL::Get(HALData::EFastCounterFrequency, iTickPeriod); + + iCacheSource = CIHLBitmap::NewL(); + iCacheDestination = CIHLBitmap::NewL(); + iProcessor = CIHLBitmapProcessor::NewL( iOptions ); + + // Initialize settings and start load (default is zoom to fit) + iSourceSize = iSource.Size(); + CalculateZoomToFitRatio(); + User::LeaveIfError( SetZoomRatio( iZoomToFitRatio ) ); + } + +// ----------------------------------------------------------------------------- +// Destructor +// ----------------------------------------------------------------------------- +CIHLImageViewer::~CIHLImageViewer() + { + Cancel(); + delete iProcessor; + delete iCacheDestination; + delete iCacheSource; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::Id +// ----------------------------------------------------------------------------- +TIHLInterfaceType CIHLImageViewer::Type() const + { + return TIHLInterfaceType( KIHLInterfaceIdImageViewer, KIHLImplementationIdImageViewer ); + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::IsAnimation +// ----------------------------------------------------------------------------- +TBool CIHLImageViewer::IsAnimation() const + { + return iSource.IsAnimation(); + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::SheduleNextFrame +// ----------------------------------------------------------------------------- +void CIHLImageViewer::SheduleNextFrame(TTimeIntervalMicroSeconds32 aDelay) + { + TInt delay=aDelay.Int(); + + if (delay == 0) // 0 second deleay set in GIF file + { + iAnimDelay = TTimeIntervalMicroSeconds32(100000-iAnimLastFrameDrawTime); + } + else + { + iAnimDelay = delay - iAnimLastFrameDrawTime; + } + + if (iAnimDelay.Int() <=0) //last frame drawn longer than animation frame interval. + { + iAnimDelay = KMinimumInterval; + } + iAnimInitFastTime=User::FastCounter(); //store the start time + HighRes(iAnimDelay); + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::Play +// ----------------------------------------------------------------------------- +void CIHLImageViewer::Play() + { + if( iSource.IsAnimation() ) + { + iIsPlaying = ETrue; + if( iViewerState == EInactive) + { + iViewerState = EAnimation; + SheduleNextFrame( iSource.AnimationFrameDelay( iAnimationIndex ) ); + } + } + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::Stop +// ----------------------------------------------------------------------------- +void CIHLImageViewer::Stop() + { + iIsPlaying = EFalse; + if( iViewerState == EAnimation ) + { + Cancel(); + } + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::IsPlaying +// ----------------------------------------------------------------------------- +TBool CIHLImageViewer::IsPlaying() const + { + return iIsPlaying; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::AnimationFrameCount +// ----------------------------------------------------------------------------- +TInt CIHLImageViewer::AnimationFrameCount() const + { + return iSource.AnimationFrameCount(); + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::AnimationFrame +// ----------------------------------------------------------------------------- +TInt CIHLImageViewer::AnimationFrame() const + { + return iAnimationIndex; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::SetAnimationFrame +// ----------------------------------------------------------------------------- +TInt CIHLImageViewer::SetAnimationFrame( TInt aFrameIndex ) + { + // Public API, boundary check -> panic also on hardware + __ASSERT_ALWAYS( aFrameIndex >= 0 && + aFrameIndex < iSource.AnimationFrameCount(), Panic( KErrArgument ) ); + + // Save new index and clear old source cache to force load new frame + iAnimationIndex = aFrameIndex; + iCacheSource->Reset(); + + // Start load + return ApplySettings(); + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::SetViewerSize +// ----------------------------------------------------------------------------- +TInt CIHLImageViewer::SetViewerSize( const TSize& aViewerSize, int aSrcBitmapScaleFactor ) + { + // Public API, negative value check -> panic also on hardware + __ASSERT_ALWAYS( aViewerSize.iWidth >= 0 && + aViewerSize.iHeight >= 0, Panic( KErrArgument ) ); + + iSrcBitmapScaleFactor = aSrcBitmapScaleFactor; + + // Save new viewer size + iViewerSize = aViewerSize; + + // Recalculate source rect and destination size + CalculateSourceRectAndDestinationSize(); + + // Recalculate zoom to fit ratio + CalculateZoomToFitRatio(); + + // Start load + return ApplySettings(); + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::ViewerSize +// ----------------------------------------------------------------------------- +TSize CIHLImageViewer::ViewerSize() const + { + return iViewerSize; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::MoveSourceRect +// ----------------------------------------------------------------------------- +TInt CIHLImageViewer::MoveSourceRect( TInt aDx, TInt aDy ) + { + TInt dx( aDx ); + TInt dy( aDy ); + switch( iRotationAngle ) + { + case ERotationAngle0: + { + break; + } + case ERotationAngle90: + { + dx = aDy; + dy = -aDx; + break; + } + case ERotationAngle180: + { + dx = -aDx; + dy = -aDy; + break; + } + case ERotationAngle270: + { + dx = -aDy; + dy = aDx; + break; + } + default: + { + // Internal state error, debug panic only + #ifdef _DEBUG + Panic( KErrGeneral ); + #endif + } + } + if( iHorizontalMirroring ) + { + dx = -dx; + } + if( iVerticalMirroring ) + { + dy = -dy; + } + + if( iSourceRect.iTl.iX + dx < 0 || + iSourceRect.iBr.iX + dx > iSourceSize.iWidth || + iSourceRect.iTl.iY + dy < 0 || + iSourceRect.iBr.iY + dy > iSourceSize.iHeight ) + { + return KErrArgument; + } + + iSourceRect.Move( dx, dy ); + + // Start load + return ApplySettings(); + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::SetSourceRectPosition +// ----------------------------------------------------------------------------- +TInt CIHLImageViewer::SetSourceRectPosition( const TPoint& aPosition ) + { + TPoint newPosition( aPosition ); + TSize sourceRectSize( iSourceRect.Size() ); + switch( iRotationAngle ) + { + case ERotationAngle0: + { + break; + } + case ERotationAngle90: + { + newPosition.iX = aPosition.iY; + newPosition.iY = iSourceSize.iHeight - sourceRectSize.iHeight - aPosition.iX; + break; + } + case ERotationAngle180: + { + newPosition.iX = iSourceSize.iWidth - sourceRectSize.iWidth - aPosition.iX; + newPosition.iY = iSourceSize.iHeight - sourceRectSize.iHeight - aPosition.iY; + break; + } + case ERotationAngle270: + { + newPosition.iX = iSourceSize.iWidth - sourceRectSize.iWidth - aPosition.iY; + newPosition.iY = aPosition.iX; + break; + } + default: + { + // Internal state error, debug panic only + #ifdef _DEBUG + Panic( KErrGeneral ); + #endif + } + } + if( iHorizontalMirroring ) + { + newPosition.iX = iSourceSize.iWidth - sourceRectSize.iWidth - newPosition.iX; + } + if( iVerticalMirroring ) + { + newPosition.iY = iSourceSize.iHeight - sourceRectSize.iHeight - newPosition.iY; + } + + if( newPosition.iX < 0 || + newPosition.iX > ( iSourceSize.iWidth - sourceRectSize.iWidth ) || + newPosition.iY < 0 || + newPosition.iY > ( iSourceSize.iHeight - sourceRectSize.iHeight ) ) + { + return KErrArgument; + } + + iSourceRect = TRect( newPosition, sourceRectSize ); + + // Start load + return ApplySettings(); + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::SourceRect +// ----------------------------------------------------------------------------- +TRect CIHLImageViewer::SourceRect() const + { + TRect mirroredSourceRect( iSourceRect ); + if( iHorizontalMirroring ) + { + mirroredSourceRect.iTl.iX = iSourceSize.iWidth - iSourceRect.iBr.iX; + mirroredSourceRect.iBr.iX = iSourceSize.iWidth - iSourceRect.iTl.iX; + } + if( iVerticalMirroring ) + { + mirroredSourceRect.iTl.iY = iSourceSize.iHeight - iSourceRect.iBr.iY; + mirroredSourceRect.iBr.iY = iSourceSize.iHeight - iSourceRect.iTl.iY; + } + + TRect rotatedSourceRect( mirroredSourceRect ); + switch( iRotationAngle ) + { + case ERotationAngle0: + { + break; + } + case ERotationAngle90: + { + rotatedSourceRect.iTl.iX = iSourceSize.iHeight - mirroredSourceRect.iBr.iY; + rotatedSourceRect.iTl.iY = mirroredSourceRect.iTl.iX; + rotatedSourceRect.iBr.iX = iSourceSize.iHeight - mirroredSourceRect.iTl.iY; + rotatedSourceRect.iBr.iY = mirroredSourceRect.iBr.iX; + break; + } + case ERotationAngle180: + { + rotatedSourceRect.iTl.iX = iSourceSize.iWidth - mirroredSourceRect.iBr.iX; + rotatedSourceRect.iTl.iY = iSourceSize.iHeight - mirroredSourceRect.iBr.iY; + rotatedSourceRect.iBr.iX = iSourceSize.iWidth - mirroredSourceRect.iTl.iX; + rotatedSourceRect.iBr.iY = iSourceSize.iHeight - mirroredSourceRect.iTl.iY; + break; + } + case ERotationAngle270: + { + rotatedSourceRect.iTl.iX = mirroredSourceRect.iTl.iY; + rotatedSourceRect.iTl.iY = iSourceSize.iWidth - mirroredSourceRect.iBr.iX; + rotatedSourceRect.iBr.iX = mirroredSourceRect.iBr.iY; + rotatedSourceRect.iBr.iY = iSourceSize.iWidth - mirroredSourceRect.iTl.iX; + break; + } + default: + { + // Internal state error, debug panic only + #ifdef _DEBUG + Panic( KErrGeneral ); + #endif + } + } + + return rotatedSourceRect; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::SourceSize +// ----------------------------------------------------------------------------- +TSize CIHLImageViewer::SourceSize() const + { + if( iRotationAngle == ERotationAngle90 || + iRotationAngle == ERotationAngle270 ) + { + return TSize( iSourceSize.iHeight, iSourceSize.iWidth ); + } + else + { + return iSourceSize; + } + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::SetZoomRatio +// ----------------------------------------------------------------------------- +TInt CIHLImageViewer::SetZoomRatio( TReal aZoomRatio ) + { + if( aZoomRatio <= 0 || Math::IsInfinite( aZoomRatio ) ) + { + return KErrArgument; + } + + iZoomRatio = aZoomRatio; + + // Recalculate source rect and destination size + CalculateSourceRectAndDestinationSize(); + + // Start load + return ApplySettings(); + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::ZoomRatio +// ----------------------------------------------------------------------------- +TReal CIHLImageViewer::ZoomRatio() const + { + return iZoomRatio; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::ZoomToFitRatio +// ----------------------------------------------------------------------------- +TReal CIHLImageViewer::ZoomToFitRatio() const + { + return iZoomToFitRatio; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::RotateClockwise +// ----------------------------------------------------------------------------- +TInt CIHLImageViewer::RotateClockwise() + { + TInt rotationAngle( iRotationAngle + ERotationAngle90 ); + if( rotationAngle > ERotationAngle270 ) + { + rotationAngle = ERotationAngle0; + } + + return SetRotationAngle( rotationAngle ); + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::RotateCounterClockwise +// ----------------------------------------------------------------------------- +TInt CIHLImageViewer::RotateCounterClockwise() + { + TInt rotationAngle( iRotationAngle - ERotationAngle90 ); + if( rotationAngle < ERotationAngle0 ) + { + rotationAngle = ERotationAngle270; + } + + return SetRotationAngle( rotationAngle ); + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::SetRotationAngle +// ----------------------------------------------------------------------------- +TInt CIHLImageViewer::SetRotationAngle( TInt aRotationAngle ) + { + if( aRotationAngle != ERotationAngle0 && + aRotationAngle != ERotationAngle90 && + aRotationAngle != ERotationAngle180 && + aRotationAngle != ERotationAngle270 ) + { + return KErrArgument; + } + + iRotationAngle = aRotationAngle; + + // Recalculate source rect and destination size + CalculateSourceRectAndDestinationSize(); + + // Recalculate zoom to fit ratio + CalculateZoomToFitRatio(); + + // Start load + return ApplySettings(); + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::RotationAngle +// ----------------------------------------------------------------------------- +TInt CIHLImageViewer::RotationAngle() const + { + return iRotationAngle; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::SetVerticalMirroring +// ----------------------------------------------------------------------------- +TInt CIHLImageViewer::SetVerticalMirroring( TBool aValue ) + { + if( iVerticalMirroring != aValue ) + { + iVerticalMirroring = aValue; + + // Start load + return ApplySettings(); + } + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::VerticalMirroring +// ----------------------------------------------------------------------------- +TBool CIHLImageViewer::VerticalMirroring() const + { + return iVerticalMirroring; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::SetHorizontalMirroring +// ----------------------------------------------------------------------------- +TInt CIHLImageViewer::SetHorizontalMirroring( TBool aValue ) + { + if( iHorizontalMirroring != aValue ) + { + iHorizontalMirroring = aValue; + return ApplySettings(); + } + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::HorizontalMirroring +// ----------------------------------------------------------------------------- +TBool CIHLImageViewer::HorizontalMirroring() const + { + return iHorizontalMirroring; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::SetFilter +// ----------------------------------------------------------------------------- +void CIHLImageViewer::SetFilter( MIHLFilter* /*aFilter*/ ) + { + // Not in use + } + + + +// Private methods +// ----------------------------------------------------------------------------- +// CIHLImageViewer::DoCancel +// ----------------------------------------------------------------------------- +void CIHLImageViewer::DoCancel() + { + CTimer::DoCancel(); + switch( iViewerState ) + { + case ELoad: + { + // Cancel asynchronous source loading + iSource.CancelLoad(); + iCacheSource->Reset(); + break; + } + case EProcess: + { + // Cancel asynchronous processing + iProcessor->CancelProcess(); + iCacheDestination->Reset(); + break; + } + default: + { + break; + } + } + + // Set state to inactive + iViewerState = EInactive; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::RunL +// ----------------------------------------------------------------------------- +void CIHLImageViewer::RunL() + { + User::LeaveIfError( iStatus.Int() ); + + + TInt err( KErrNone ); + switch( iViewerState ) + { + case ELoad: + { + // Async load successful; start async processing if needed + if( NeedAsyncProcess() ) + { + err = AsyncProcess(); + if( !err ) + { + iViewerState = EProcess; + SetActive(); + } + break; + } + else + { + iViewerState=EInactive; + // Flowtrough to EProcess if no error + err = SyncProcess(); + if( err ) + { + break; + } + } + } + case EProcess: + { + // Process successful; finish and check if animation is needed + err = Finish(); + if( !err ) + { + TInt64 currentTime = User::FastCounter(); + if(iAnimDrawStartFastTime > 0) + { + iAnimLastFrameDrawTime=(currentTime-iAnimDrawStartFastTime)*1000000/iTickPeriod; + } + + if( iIsPlaying ) + { + iViewerState = EAnimation; + SheduleNextFrame(iSource.AnimationFrameDelay( iAnimationIndex )); + } + else + { + iViewerState = EInactive; + } + // Notify client + // NOTE! client may call any API method in this point! + iObserver.ViewerBitmapChangedL(); + } + break; + } + case EAnimation: + { + // Check if still playing.. + iAnimDrawStartFastTime = User::FastCounter(); + if( iIsPlaying ) + { + // Change animation frame + 1 + UpdateAnimationIndex(); + err = AsyncLoad(); + if( !err ) + { + iViewerState = ELoad; + SetActive(); + } + else + { + iViewerState = EInactive; + } + } + else + { + iViewerState = EInactive; + } + break; + } + default: + { + // Internal state error, debug panic only + #ifdef _DEBUG + Panic( KErrGeneral ); + #endif + } + } + + + User::LeaveIfError( err ); + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::RunError +// ----------------------------------------------------------------------------- +TInt CIHLImageViewer::RunError( TInt aError ) + { + switch( iViewerState ) + { + case ELoad: + { + // Cleanup cached source if load has been failed + iCacheSource->Reset(); + break; + } + case EProcess: + { + // Cleanup cached destination if process has been failed + iCacheDestination->Reset(); + break; + } + default: + { + break; + } + } + + iViewerState = EInactive; + iObserver.ViewerError( aError ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::Set +// ----------------------------------------------------------------------------- +TInt CIHLImageViewer::ApplySettings() + { + // Assert source rect and destination, debug build only +#ifdef _DEBUG + AssertSourceRectAndDestinationSize(); +#endif + + // Cancel current process if any + Cancel(); + + // Check if cached source bitmap is already valid for processing.. + TBool validSourceCache( EFalse ); + const CFbsBitmap& cacheSource = iCacheSource->Bitmap(); + if( cacheSource.Handle() ) + { + const TSize cacheSize( cacheSource.SizeInPixels() ); + const TSize minLoadSize( MinimumSourceLoadSize() ); + if( cacheSize.iWidth >= minLoadSize.iWidth && + cacheSize.iHeight >= minLoadSize.iHeight ) + { + validSourceCache = ETrue; + } + } + + // Start async load/process.. + TInt err( KErrNone ); + if( validSourceCache ) + { + if( NeedAsyncProcess() ) + { + err = AsyncProcess(); + if( !err ) + { + iViewerState = EProcess; + SetActive(); + } + } + else + { + err = SyncProcess(); + if( !err ) + { + iViewerState = EProcess; + SelfComplete(); + } + } + } + else + { + err = AsyncLoad(); + if( !err ) + { + iViewerState = ELoad; + SetActive(); + } + } + + return err; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::AsyncLoad +// ----------------------------------------------------------------------------- +TInt CIHLImageViewer::AsyncLoad() + { + // Internal state check, debug panic only + __ASSERT_DEBUG( !iCacheDestination->Bitmap().Handle(), Panic( KErrGeneral ) ); + + TInt err( KErrNone ); + if( !iSource.IsAnimation() ) + { + // Do not reset animation frame because loading + // might be faster if previous frame can be utilized + iCacheSource->Reset(); + } + if( !iCacheSource->Bitmap().Handle() ) + { + TDisplayMode transparency( iSource.MaskDisplayMode() ); + if( transparency ) + { + err = iCacheSource->Create( MinimumSourceLoadSize(), + iSource.DisplayMode(), + transparency ); + } + else + { + err = iCacheSource->Create( MinimumSourceLoadSize(), + iSource.DisplayMode() ); + } + } + + // Load source bitmap + if( !err ) + { + if( iSource.IsAnimation() ) + { + err = iSource.LoadAnimation( iStatus, *iCacheSource, iAnimationIndex ); + } + else + { + err = iSource.Load( iStatus, *iCacheSource, iSource.ImageIndex() ); + } + + } + + // Error cleanup if needed + if( err ) + { + iCacheSource->Reset(); + } + return err; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::NeedAsyncProcess +// ----------------------------------------------------------------------------- +TBool CIHLImageViewer::NeedAsyncProcess() + { + // Internal state check, debug panic only + __ASSERT_DEBUG( iCacheSource->Bitmap().Handle(), Panic( KErrGeneral ) ); + __ASSERT_DEBUG( !iCacheDestination->Bitmap().Handle(), Panic( KErrGeneral ) ); + + // First check if destination size differs from source size + // (=scaling needed) + TSize scaledSrcSize( iCacheSource->Bitmap().SizeInPixels() ); + if( scaledSrcSize.iWidth != iDestinationSize.iWidth || + scaledSrcSize.iHeight != iDestinationSize.iHeight ) + { + return ETrue; + } + + // Then check if source rect and source size differs + // (=clipping needed) + if( iSourceRect.iTl != TPoint( 0,0 ) || + iSourceRect.iBr != iSource.Size().AsPoint() ) + { + return ETrue; + } + + // Finally check rotation and mirroring + if( iRotationAngle == ERotationAngle0 && + !iHorizontalMirroring && + !iVerticalMirroring ) + { + return EFalse; + } + else if( iRotationAngle == ERotationAngle180 && + iHorizontalMirroring && + iVerticalMirroring ) + { + return EFalse; + } + else + { + return ETrue; + } + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::AsyncProcess +// ----------------------------------------------------------------------------- +TInt CIHLImageViewer::AsyncProcess() + { + IHL_DEBUG1( KIHLDebug, "IHL - CIHLImageViewer - AsyncProcess" ); + + // Internal state check, debug panic only + __ASSERT_DEBUG( iCacheSource->Bitmap().Handle(), Panic( KErrGeneral ) ); + __ASSERT_DEBUG( !iCacheDestination->Bitmap().Handle(), Panic( KErrGeneral ) ); + + const CFbsBitmap& srcBitmap = iCacheSource->Bitmap(); + const CFbsBitmap& srcMask = iCacheSource->Mask(); + TInt err( KErrNone ); + + // Create new cached destination + if( srcMask.Handle() ) + { + err = iCacheDestination->Create( iDestinationSize, + srcBitmap.DisplayMode(), srcMask.DisplayMode() ); + } + else + { + err = iCacheDestination->Create( iDestinationSize, srcBitmap.DisplayMode() ); + } + + // Scale and clip bitmap from cached source to new cached destination + if( !err ) + { + TRect scaledSourceRect( + CalculateProcessSourceRect( srcBitmap.SizeInPixels() ) ); + + TRect destinationRect( CalculateProcessDestinationRect() ); + + err = iProcessor->Process( iStatus, *iCacheSource, scaledSourceRect, + *iCacheDestination, destinationRect ); + } + + // Error cleanup if needed + if( err ) + { + iCacheDestination->Reset(); + } + + return err; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::SyncProcess +// ----------------------------------------------------------------------------- +TInt CIHLImageViewer::SyncProcess() + { + IHL_DEBUG1( KIHLDebug, "IHL - CIHLImageViewer - SyncProcess" ); + + // Internal state check, debug panic only + __ASSERT_DEBUG( iCacheSource->Bitmap().Handle(), Panic( KErrGeneral ) ); + __ASSERT_DEBUG( !iCacheDestination->Bitmap().Handle(), Panic( KErrGeneral ) ); + + // Duplicate destination cache to destination bitmap + TInt err( iCacheDestination->Copy( *iCacheSource, EFalse ) ); + return err; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::Finish +// ----------------------------------------------------------------------------- +TInt CIHLImageViewer::Finish() + { + // Internal state check, debug panic only + __ASSERT_DEBUG( iCacheDestination->Bitmap().Handle(), Panic( KErrGeneral ) ); + + // Duplicate destination cache to destination bitmap + TInt err( iDestination.Copy( *iCacheDestination, ETrue ) ); + iCacheDestination->Reset(); + + // Error cleanup if needed + if( err ) + { + iDestination.Reset(); + } + return err; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::UpdateAnimationIndex +// ----------------------------------------------------------------------------- +void CIHLImageViewer::UpdateAnimationIndex() + { + // Internal state check, debug panic only + __ASSERT_DEBUG( iIsPlaying, Panic( KErrGeneral ) ); + + // Check if animation is in last frame + if( iAnimationIndex == iSource.AnimationFrameCount() - 1 ) + { + iAnimationIndex = 0; + } + else + { + // Not in last frame; move to next frame + iAnimationIndex++; + } + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::SelfComplete +// ----------------------------------------------------------------------------- +void CIHLImageViewer::SelfComplete() + { + SetActive(); + iStatus = KRequestPending; + TRequestStatus* status = &iStatus; + User::RequestComplete( status, KErrNone ); + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::MinimumSourceLoadSize +// ----------------------------------------------------------------------------- +TSize CIHLImageViewer::MinimumSourceLoadSize() + { + TSize minumumLoadSize( iSource.Size() ); + + if( iSource.IsFullyScaleable() ) + { + const TSize originalSize( iSource.Size() ); + switch( iRotationAngle ) + { + case ERotationAngle0: + case ERotationAngle180: + { + minumumLoadSize.iWidth = originalSize.iWidth * iDestinationSize.iWidth / Abs( iSourceRect.Width() ); + minumumLoadSize.iHeight = originalSize.iHeight * iDestinationSize.iHeight / Abs( iSourceRect.Height() ); + break; + } + case ERotationAngle90: + case ERotationAngle270: + { + minumumLoadSize.iWidth = originalSize.iWidth * iDestinationSize.iWidth / Abs( iSourceRect.Height() ); + minumumLoadSize.iHeight = originalSize.iHeight * iDestinationSize.iHeight / Abs( iSourceRect.Width() ); + break; + } + default: + { + // Internal state error, debug panic only + #ifdef _DEBUG + Panic( KErrGeneral ); + #endif + } + } + + // Limit fully scaleable loadsize to original size + if( minumumLoadSize.iWidth > originalSize.iWidth || + minumumLoadSize.iHeight > originalSize.iHeight ) + { + minumumLoadSize = originalSize; + } + } + else + { + const RArray& loadSizeArray = iSource.CustomLoadSizeArray(); + const TInt count( loadSizeArray.Count() ); + + if( count ) + { + TRect loadRect; + TSize loadRectSize; + TBool indexFound( EFalse ); + for( TInt i( 0 ); ( i < count ) && !indexFound; ++i ) + { + loadRect = CalculateProcessSourceRect( loadSizeArray[ i ] ); + loadRectSize = loadRect.Size(); + loadRectSize.iWidth = Abs( loadRectSize.iWidth ); + loadRectSize.iHeight = Abs( loadRectSize.iHeight ); + + if( iDestinationSize.iWidth <= loadRectSize.iWidth && + iDestinationSize.iHeight <= loadRectSize.iHeight ) + { + minumumLoadSize = loadSizeArray[ i ]; + indexFound = ETrue; + } + } + } + } + + return minumumLoadSize; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::CalculateProcessSourceRect +// ----------------------------------------------------------------------------- +TRect CIHLImageViewer::CalculateProcessSourceRect( const TSize& aLoadSize ) + { + const TSize originalSize( iSource.Size() ); + TRect loadRect; + if ( aLoadSize.iWidth > KErrNone && aLoadSize.iHeight > KErrNone ) + { + loadRect.iTl.iX = iSourceRect.iTl.iX * aLoadSize.iWidth / originalSize.iWidth; + loadRect.iTl.iY = iSourceRect.iTl.iY * aLoadSize.iHeight / originalSize.iHeight; + loadRect.iBr.iX = iSourceRect.iBr.iX * aLoadSize.iWidth / originalSize.iWidth; + loadRect.iBr.iY = iSourceRect.iBr.iY * aLoadSize.iHeight / originalSize.iHeight; + } + else + { + loadRect.SetRect(0,0,0,0); + return loadRect; + } + + switch( iRotationAngle ) + { + case ERotationAngle0: + { + break; + } + case ERotationAngle90: + { + TInt tmp( loadRect.iTl.iY ); + loadRect.iTl.iY = loadRect.iBr.iY; + loadRect.iBr.iY = tmp; + break; + } + case ERotationAngle180: + { + TPoint tmp( loadRect.iTl ); + loadRect.iTl = loadRect.iBr; + loadRect.iBr = tmp; + break; + } + case ERotationAngle270: + { + TInt tmp( loadRect.iTl.iX ); + loadRect.iTl.iX = loadRect.iBr.iX; + loadRect.iBr.iX = tmp; + break; + } + default: + { + // Internal state error, debug panic only + #ifdef _DEBUG + Panic( KErrGeneral ); + #endif + } + } + + return loadRect; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::CalculateProcessDestinationRect +// ----------------------------------------------------------------------------- +TRect CIHLImageViewer::CalculateProcessDestinationRect() + { + TRect dstRect( iDestinationSize ); + switch( iRotationAngle ) + { + case ERotationAngle0: + case ERotationAngle180: + { + if( iHorizontalMirroring ) + { + TInt tmp( dstRect.iTl.iX ); + dstRect.iTl.iX = dstRect.iBr.iX; + dstRect.iBr.iX = tmp; + } + if( iVerticalMirroring ) + { + TInt tmp( dstRect.iTl.iY ); + dstRect.iTl.iY = dstRect.iBr.iY; + dstRect.iBr.iY = tmp; + } + break; + } + case ERotationAngle90: + case ERotationAngle270: + { + if( iHorizontalMirroring ) + { + TInt tmp( dstRect.iTl.iY ); + dstRect.iTl.iY = dstRect.iBr.iY; + dstRect.iBr.iY = tmp; + } + if( iVerticalMirroring ) + { + TInt tmp( dstRect.iTl.iX ); + dstRect.iTl.iX = dstRect.iBr.iX; + dstRect.iBr.iX = tmp; + } + break; + } + default: + { + // Internal state error, debug panic only + #ifdef _DEBUG + Panic( KErrGeneral ); + #endif + } + } + return dstRect; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::CalculateZoomToFitRatio +// ----------------------------------------------------------------------------- +void CIHLImageViewer::CalculateZoomToFitRatio() + { + TSize sourceSize( SourceSize() ); + TReal widthRatio( TReal( iViewerSize.iWidth ) / TReal( sourceSize.iWidth ) ); + TReal heightRatio( TReal( iViewerSize.iHeight ) / TReal( sourceSize.iHeight ) ); + + if( iOptions & MIHLImageViewer::EOptionIgnoreAspectRatio ) + { + iZoomToFitRatio = ( widthRatio > heightRatio ) ? widthRatio : heightRatio; + } + else + { + iZoomToFitRatio = ( widthRatio < heightRatio ) ? widthRatio : heightRatio; + } + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::CalculateSourceRectAndDestinationSize +// ----------------------------------------------------------------------------- +void CIHLImageViewer::CalculateSourceRectAndDestinationSize() + { + // Calculate new source rect + TSize oldSourceRectSize( iSourceRect.Size() ); + + TReal newSourceRectWidth; + TReal newSourceRectHeight; + TReal widthZoomRatio( iZoomRatio ); + TReal heightZoomRatio( iZoomRatio ); + + if( iOptions & MIHLImageViewer::EOptionIgnoreAspectRatio ) + { + TReal widthRatio( TReal( iViewerSize.iWidth ) / TReal( iSourceSize.iWidth ) ); + TReal heightRatio( TReal( iViewerSize.iHeight ) / TReal( iSourceSize.iHeight ) ); + if( widthRatio < heightRatio ) + { + widthZoomRatio = widthZoomRatio * widthRatio / heightRatio; + } + else + { + heightZoomRatio = heightZoomRatio * heightRatio / widthRatio; + } + } + + if( iRotationAngle == ERotationAngle90 || + iRotationAngle == ERotationAngle270 ) + { + newSourceRectWidth = iSrcBitmapScaleFactor * iViewerSize.iHeight / heightZoomRatio; //widthZoomRatio + newSourceRectHeight = iSrcBitmapScaleFactor * iViewerSize.iWidth / widthZoomRatio; //heightZoomRatio + } + else + { + newSourceRectWidth = iSrcBitmapScaleFactor * iViewerSize.iWidth / widthZoomRatio; + newSourceRectHeight = iSrcBitmapScaleFactor * iViewerSize.iHeight / heightZoomRatio; + } + + // Check if source rect is not larger than source area + if( newSourceRectWidth > iSourceSize.iWidth ) + { + newSourceRectWidth = iSourceSize.iWidth; + } + if( newSourceRectHeight > iSourceSize.iHeight ) + { + newSourceRectHeight = iSourceSize.iHeight; + } + + // Rounding the results + TReal roundedWidth; + Math::Round( roundedWidth, newSourceRectWidth, 0 ); + TReal roundedHeight; + Math::Round( roundedHeight, newSourceRectHeight, 0 ); + + iSourceRect.SetWidth( (TInt)roundedWidth ); + iSourceRect.SetHeight( (TInt)roundedHeight ); + + // Calculate actual destination size (always same or smaller than iViewerSize !) + if( iRotationAngle == ERotationAngle90 || + iRotationAngle == ERotationAngle270 ) + { + iDestinationSize.iWidth = (TInt)( newSourceRectHeight * widthZoomRatio ); //heightZoomRatio + iDestinationSize.iHeight = (TInt)( newSourceRectWidth * heightZoomRatio ); //widthZoomRatio + } + else + { + iDestinationSize.iWidth = (TInt)( newSourceRectWidth * widthZoomRatio ); + iDestinationSize.iHeight = (TInt)( newSourceRectHeight * heightZoomRatio ); + } + // Check that destination size is not rounded to zero + if( iDestinationSize.iWidth == 0 ) + { + iDestinationSize.iWidth = 1; + } + if( iDestinationSize.iHeight == 0 ) + { + iDestinationSize.iHeight = 1; + } + + // Move source rect keeping center point in same location + iSourceRect.Move( ( oldSourceRectSize.iWidth - (TInt)newSourceRectWidth ) / 2, + ( oldSourceRectSize.iHeight - (TInt)newSourceRectHeight ) / 2 ); + + // Move rect if partially out of source area + TPoint moveOffset( 0, 0 ); + if( iSourceRect.iTl.iX < 0 ) + { + moveOffset.iX = -iSourceRect.iTl.iX; + } + else if( iSourceRect.iBr.iX > iSourceSize.iWidth ) + { + moveOffset.iX = iSourceSize.iWidth - iSourceRect.iBr.iX; + } + if( iSourceRect.iTl.iY < 0 ) //lint !e961 + { + moveOffset.iY = -iSourceRect.iTl.iY; + } + else if( iSourceRect.iBr.iY > iSourceSize.iHeight ) + { + moveOffset.iY = iSourceSize.iHeight - iSourceRect.iBr.iY; + } + iSourceRect.Move( moveOffset ); //lint !e961 + + // Assert that rectangle is valid, debug build only +#ifdef _DEBUG + AssertSourceRectAndDestinationSize(); +#endif + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewer::AssertSourceRectAndDestinationSize +// Used in debug build only +// ----------------------------------------------------------------------------- +#ifdef _DEBUG +void CIHLImageViewer::AssertSourceRectAndDestinationSize() + { + if( iSourceRect.iTl.iX < 0 || + iSourceRect.iBr.iX > iSourceSize.iWidth || + iSourceRect.iTl.iY < 0 || + iSourceRect.iBr.iY > iSourceSize.iHeight || + iDestinationSize.iWidth <= 0 || iDestinationSize.iHeight <= 0 ) + { + Panic( KErrGeneral ); + } + } +#endif + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandlinglib/Src/CIHLImageViewer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlinglib/Src/CIHLImageViewer.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,374 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of Image Viewer class. +* +*/ + + +#ifndef CIHLIMAGEVIEWER_H +#define CIHLIMAGEVIEWER_H + +// INCLUDES +#include +#include +#include + +//FORWARD DECLARATIONS +class MIHLFileImage; +class MIHLBitmap; +class MIHLViewerObserver; +class CIHLBitmap; +class CIHLBitmapProcessor; + +#define KMinimumInterval 10000 + +// CLASS DECLARATION +/** +* CIHLImageViewer +* +* Image Viewer implementation class. +* @lib IHL.lib +* @since 3.0 +*/ +NONSHARABLE_CLASS( CIHLImageViewer ) : public CTimer, public MIHLImageViewer + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CIHLImageViewer* NewL( const TSize& aViewerSize, + MIHLFileImage& aSource, + MIHLBitmap& aDestination, + MIHLViewerObserver& aObserver, + const TUint32 aOptions ); + + /* + * Virtual destructor. + */ + virtual ~CIHLImageViewer(); + + public: // From base class MIHLViewer + + /* + * From MIHLViewer, see base class header. + */ + TIHLInterfaceType Type() const; + + public: // From base class MIHLImageViewer + + /* + * From MIHLImageViewer, see base class header. + */ + TBool IsAnimation() const; + + /* + * From MIHLImageViewer, see base class header. + */ + void Play(); + + /* + * From MIHLImageViewer, see base class header. + */ + void Stop(); + + /* + * From MIHLImageViewer, see base class header. + */ + TBool IsPlaying() const; + + /* + * From MIHLImageViewer, see base class header. + */ + TInt AnimationFrameCount() const; + + /* + * From MIHLImageViewer, see base class header. + */ + TInt AnimationFrame() const; + + /* + * From MIHLImageViewer, see base class header. + */ + TInt SetAnimationFrame( TInt aFrameIndex ); + + /* + * From MIHLImageViewer, see base class header. + */ + TInt SetViewerSize( const TSize& aViewerSize, TInt srcBitmapScaleFactor = 1 ); + + /* + * From MIHLImageViewer, see base class header. + */ + TSize ViewerSize() const; + + /* + * From MIHLImageViewer, see base class header. + */ + TInt MoveSourceRect( TInt aDx, TInt aDy ); + + /* + * From MIHLImageViewer, see base class header. + */ + TInt SetSourceRectPosition( const TPoint& aPosition ); + + /* + * From MIHLImageViewer, see base class header. + */ + TRect SourceRect() const; + + /* + * From MIHLImageViewer, see base class header. + */ + TSize SourceSize() const; + + /* + * From MIHLImageViewer, see base class header. + */ + TInt SetZoomRatio( TReal aZoomRatio ); + + /* + * From MIHLImageViewer, see base class header. + */ + TReal ZoomRatio() const; + + /* + * From MIHLImageViewer, see base class header. + */ + TReal ZoomToFitRatio() const; + + /* + * From MIHLImageViewer, see base class header. + */ + TInt RotateClockwise(); + + /* + * From MIHLImageViewer, see base class header. + */ + TInt RotateCounterClockwise(); + + /* + * From MIHLImageViewer, see base class header. + */ + TInt SetRotationAngle( TInt aRotationAngle ); + + /* + * From MIHLImageViewer, see base class header. + */ + TInt RotationAngle() const; + + /* + * From MIHLImageViewer, see base class header. + */ + TInt SetVerticalMirroring( TBool aValue ); + + /* + * From MIHLImageViewer, see base class header. + */ + TBool VerticalMirroring() const; + + /* + * From MIHLImageViewer, see base class header. + */ + TInt SetHorizontalMirroring( TBool aValue ); + + /* + * From MIHLImageViewer, see base class header. + */ + TBool HorizontalMirroring() const; + + /* + * From MIHLImageViewer, see base class header. + */ + void SetFilter( MIHLFilter* aFilter ); + + public: // From base class CTimer + + /* + * From CTimer, see base class header. + */ + void DoCancel(); + + /* + * From CTimer, see base class header. + */ + void RunL(); + + /* + * From CTimer, see base class header. + */ + TInt RunError( TInt aError ); + + private: // Private methods + + /* + * Start asynchronous processing with new settings. + * This is needed always when settings are changed. + */ + TInt ApplySettings(); + + /* + * Start load process source bitmap. + */ + TInt AsyncLoad(); + + /* + * Check if process is needed. + */ + TBool NeedAsyncProcess(); + + /* + * Start processing with new settings. + */ + TInt AsyncProcess(); + + /* + * No external processing. + * Just duplicates source to destination. + */ + TInt SyncProcess(); + + /* + * Finish processing and notify client. + */ + TInt Finish(); + + /* + * Update frame index when playing animation. + */ + void UpdateAnimationIndex(); + + /* + * Complete dummy request. This causes RunL() method to be called. + * Needed by state machine. + */ + void SelfComplete(); + + /* + * Calculate minimum source bitmap size (using fixed loadsizes) + * needed by processing and destination bitmap. + */ + TSize MinimumSourceLoadSize(); + + /* + * Calculate source bitmap rectangle needed by processor. + * Rectangle is affected by rotating and mirroring settings etc. + */ + TRect CalculateProcessSourceRect( const TSize& aLoadSize ); + + /* + * Calculate destination bitmap rectangle needed by processor. + * Rectangle is affected by rotating and mirroring settings etc. + */ + TRect CalculateProcessDestinationRect(); + + /* + * Calculate needed zoomratio for "fit-to-screen" zooming. + */ + void CalculateZoomToFitRatio(); + + /* + * Calculate source bitmap rectangle and destination bitmap size. + * These values needs to be recalculated when rectangle setting is changed. + */ + void CalculateSourceRectAndDestinationSize( ); + + /* + * Shedules next frame of animation in using aDelay CTimer::Hires(). + * If this is not the first frame the shedule time is decreased by + * previous frame draw time. + */ + void SheduleNextFrame(TTimeIntervalMicroSeconds32 aDelay); + + /* + * Assert if source bitmap rectangle and destination bitmpa size are valid. + * This method is called by CalculateSourceRectAndDestinationSize() + */ +#ifdef _DEBUG + void AssertSourceRectAndDestinationSize(); +#endif + + private: // Private constructors + + void ConstructL(); + CIHLImageViewer( const TSize& aViewerSize, + MIHLFileImage& aSource, + MIHLBitmap& aDestination, + MIHLViewerObserver& aObserver, + const TUint32 aOptions ); + + private: // Private data types + + enum TViewerState + { + EInactive, + ELoad, + EProcess, + EAnimation, + }; + + private: // Data + + // Viewer state + TViewerState iViewerState; + + // Ref: Observers + MIHLViewerObserver& iObserver; + + // Ref: Viewer source image + MIHLFileImage& iSource; + TSize iSourceSize; + TRect iSourceRect; + + // Ref: Viewer destination bitmap + MIHLBitmap& iDestination; + TSize iDestinationSize; + + // Viewing settings + const TUint32 iOptions; + TSize iViewerSize; + TReal iZoomRatio; + TReal iZoomToFitRatio; + TInt iRotationAngle; + TBool iVerticalMirroring; + TBool iHorizontalMirroring; + + // Own: Bitmap caches + CIHLBitmap* iCacheSource; + CIHLBitmap* iCacheDestination; + + // Own: Bitmap processor + CIHLBitmapProcessor* iProcessor; + + // Animation info + TBool iIsPlaying; + TInt iAnimationIndex; + + // src bitmap scale factor + TInt iSrcBitmapScaleFactor; + + // Animation time tweaking + TInt64 iAnimInitFastTime; //clock ticks + TInt64 iAnimDrawStartFastTime; //clock tics + TInt iAnimLastFrameDrawTime; //micro seconds + TInt iTickPeriod; //clock tick period + TTimeIntervalMicroSeconds32 iAnimDelay; + + + + }; + +#endif // CIHLIMAGEVIEWER_H + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandlinglib/Src/CIHLImageViewerExtJpg.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlinglib/Src/CIHLImageViewerExtJpg.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,1037 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of Image Viewer class. +* +*/ + + +// INCLUDE FILES +#include "CIHLImageViewerExtJpg.h" + +#include "CIHLBitmap.h" +#include "CIHLBitmapProcessor.h" +#include "IHLImplementationIds.h" +#include +#include +#include +#include +#include "MIHLFileImageExtJpg.h" +#include + +// Private namespace for constants and functions +namespace + { + // Panic function + _LIT( KIHLImageViewerExtJpgPanic, "IHLImageViewerExtJpg" ); + void Panic( TInt aPanicCode ) { User::Panic( KIHLImageViewerExtJpgPanic, aPanicCode ); } + } + +// ============================ MEMBER FUNCTIONS =============================== +// ----------------------------------------------------------------------------- +// +// C++ constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +CIHLImageViewerExtJpg::CIHLImageViewerExtJpg( const TSize& aViewerSize, + MIHLFileImageExtJpg& aSource, + MIHLBitmap& aDestination, + MIHLViewerObserver& aObserver, + const TUint32 aOptions ) +: CTimer( EPriorityNormal ), iObserver( aObserver ), +iSource( aSource ), iDestination( aDestination ), +iOptions( aOptions ), iViewerSize( aViewerSize ), iSrcBitmapScaleFactor(1) + { + + CActiveScheduler::Add( this ); + } + +// ----------------------------------------------------------------------------- +// +// Two-phased constructor. +// ----------------------------------------------------------------------------- +CIHLImageViewerExtJpg* CIHLImageViewerExtJpg::NewL( const TSize& aViewerSize, + MIHLFileImageExtJpg& aSource, + MIHLBitmap& aDestination, + MIHLViewerObserver& aObserver, + const TUint32 aOptions ) + { + CIHLImageViewerExtJpg* self = new( ELeave ) CIHLImageViewerExtJpg( + aViewerSize, aSource, aDestination, aObserver, aOptions ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); // self + return self; + } + +// ----------------------------------------------------------------------------- +// +// Symbian constructor can leave. +// ----------------------------------------------------------------------------- +void CIHLImageViewerExtJpg::ConstructL() + { + CTimer::ConstructL(); + + iCacheSource = CIHLBitmap::NewL(); + iCacheDestination = CIHLBitmap::NewL(); + + // Check codec capabilities + iCapabilities = iSource.CapabilitiesL(); + if( !( iCapabilities & ( CExtJpegDecoder::ECapRotation + + CExtJpegDecoder::ECapMirroring + + CExtJpegDecoder::ECapFlipping ) ) ) + { + iInternalProcessingNeeded = ETrue; + iProcessor = CIHLBitmapProcessor::NewL( iOptions ); + } + + // Initialize settings and start load (default is zoom to fit) + iSourceSize = iSource.Size(); + CalculateZoomToFitRatio(); + User::LeaveIfError( SetZoomRatio( iZoomToFitRatio ) ); + } + +// ----------------------------------------------------------------------------- +// Destructor +// ----------------------------------------------------------------------------- +CIHLImageViewerExtJpg::~CIHLImageViewerExtJpg() + { + Cancel(); + if( iProcessor ) + { + delete iProcessor; + } + delete iCacheSource; + delete iCacheDestination; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::Id +// ----------------------------------------------------------------------------- +TIHLInterfaceType CIHLImageViewerExtJpg::Type() const + { + return TIHLInterfaceType( KIHLInterfaceIdImageViewer, KIHLImplementationIdImageViewerExtJpg ); + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::IsAnimation +// ----------------------------------------------------------------------------- +TBool CIHLImageViewerExtJpg::IsAnimation() const + { + return EFalse; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::Play +// ----------------------------------------------------------------------------- +void CIHLImageViewerExtJpg::Play() + { + + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::Stop +// ----------------------------------------------------------------------------- +void CIHLImageViewerExtJpg::Stop() + { + + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::IsPlaying +// ----------------------------------------------------------------------------- +TBool CIHLImageViewerExtJpg::IsPlaying() const + { + return EFalse; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::AnimationFrameCount +// ----------------------------------------------------------------------------- +TInt CIHLImageViewerExtJpg::AnimationFrameCount() const + { + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::AnimationFrame +// ----------------------------------------------------------------------------- +TInt CIHLImageViewerExtJpg::AnimationFrame() const + { + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::SetAnimationFrame +// ----------------------------------------------------------------------------- +TInt CIHLImageViewerExtJpg::SetAnimationFrame( TInt /*aFrameIndex*/ ) + { + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::SetViewerSize +// ----------------------------------------------------------------------------- +TInt CIHLImageViewerExtJpg::SetViewerSize( const TSize& aViewerSize, int aSrcBitmapScaleFactor ) + { + // Public API, negative value check -> panic also on hardware + __ASSERT_ALWAYS( aViewerSize.iWidth >= 0 && + aViewerSize.iHeight >= 0, Panic( KErrArgument ) ); + + iSrcBitmapScaleFactor = aSrcBitmapScaleFactor; + + // Save new viewer size + iViewerSize = aViewerSize; + + // Recalculate source rect and destination size + CalculateSourceRectAndDestinationSize(); + + // Recalculate zoom to fit ratio + CalculateZoomToFitRatio(); + + // Start load + return ApplySettings(); + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::ViewerSize +// ----------------------------------------------------------------------------- +TSize CIHLImageViewerExtJpg::ViewerSize() const + { + return iViewerSize; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::MoveSourceRect +// ----------------------------------------------------------------------------- +TInt CIHLImageViewerExtJpg::MoveSourceRect( TInt aDx, TInt aDy ) + { + TInt dx( aDx ); + TInt dy( aDy ); + switch( iRotationAngle ) + { + case ERotationAngle0: + { + break; + } + case ERotationAngle90: + { + dx = aDy; + dy = -aDx; + break; + } + case ERotationAngle180: + { + dx = -aDx; + dy = -aDy; + break; + } + case ERotationAngle270: + { + dx = -aDy; + dy = aDx; + break; + } + default: + { + // Internal state error, debug panic only + #ifdef _DEBUG + Panic( KErrGeneral ); + #endif + } + } + if( iHorizontalMirroring ) + { + dx = -dx; + } + if( iVerticalMirroring ) + { + dy = -dy; + } + + if( iSourceRect.iTl.iX + dx < 0 || + iSourceRect.iBr.iX + dx > iSourceSize.iWidth || + iSourceRect.iTl.iY + dy < 0 || + iSourceRect.iBr.iY + dy > iSourceSize.iHeight ) + { + return KErrArgument; + } + + iSourceRect.Move( dx, dy ); + + // Start load + return ApplySettings(); + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::SetSourceRectPosition +// ----------------------------------------------------------------------------- +TInt CIHLImageViewerExtJpg::SetSourceRectPosition( const TPoint& aPosition ) + { + TPoint newPosition( aPosition ); + TSize sourceRectSize( iSourceRect.Size() ); + switch( iRotationAngle ) + { + case ERotationAngle0: + { + break; + } + case ERotationAngle90: + { + newPosition.iX = aPosition.iY; + newPosition.iY = iSourceSize.iHeight - sourceRectSize.iHeight - aPosition.iX; + break; + } + case ERotationAngle180: + { + newPosition.iX = iSourceSize.iWidth - sourceRectSize.iWidth - aPosition.iX; + newPosition.iY = iSourceSize.iHeight - sourceRectSize.iHeight - aPosition.iY; + break; + } + case ERotationAngle270: + { + newPosition.iX = iSourceSize.iWidth - sourceRectSize.iWidth - aPosition.iY; + newPosition.iY = aPosition.iX; + break; + } + default: + { + // Internal state error, debug panic only + #ifdef _DEBUG + Panic( KErrGeneral ); + #endif + } + } + if( iHorizontalMirroring ) + { + newPosition.iX = iSourceSize.iWidth - sourceRectSize.iWidth - newPosition.iX; + } + if( iVerticalMirroring ) + { + newPosition.iY = iSourceSize.iHeight - sourceRectSize.iHeight - newPosition.iY; + } + + if( newPosition.iX < 0 || + newPosition.iX > ( iSourceSize.iWidth - sourceRectSize.iWidth ) || + newPosition.iY < 0 || + newPosition.iY > ( iSourceSize.iHeight - sourceRectSize.iHeight ) ) + { + return KErrArgument; + } + + iSourceRect = TRect( newPosition, sourceRectSize ); + + // Start load + return ApplySettings(); + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::SourceRect +// ----------------------------------------------------------------------------- +TRect CIHLImageViewerExtJpg::SourceRect() const + { + TRect mirroredSourceRect( iSourceRect ); + if( iHorizontalMirroring ) + { + mirroredSourceRect.iTl.iX = iSourceSize.iWidth - iSourceRect.iBr.iX; + mirroredSourceRect.iBr.iX = iSourceSize.iWidth - iSourceRect.iTl.iX; + } + if( iVerticalMirroring ) + { + mirroredSourceRect.iTl.iY = iSourceSize.iHeight - iSourceRect.iBr.iY; + mirroredSourceRect.iBr.iY = iSourceSize.iHeight - iSourceRect.iTl.iY; + } + + TRect rotatedSourceRect( mirroredSourceRect ); + switch( iRotationAngle ) + { + case ERotationAngle0: + { + break; + } + case ERotationAngle90: + { + rotatedSourceRect.iTl.iX = iSourceSize.iHeight - mirroredSourceRect.iBr.iY; + rotatedSourceRect.iTl.iY = mirroredSourceRect.iTl.iX; + rotatedSourceRect.iBr.iX = iSourceSize.iHeight - mirroredSourceRect.iTl.iY; + rotatedSourceRect.iBr.iY = mirroredSourceRect.iBr.iX; + break; + } + case ERotationAngle180: + { + rotatedSourceRect.iTl.iX = iSourceSize.iWidth - mirroredSourceRect.iBr.iX; + rotatedSourceRect.iTl.iY = iSourceSize.iHeight - mirroredSourceRect.iBr.iY; + rotatedSourceRect.iBr.iX = iSourceSize.iWidth - mirroredSourceRect.iTl.iX; + rotatedSourceRect.iBr.iY = iSourceSize.iHeight - mirroredSourceRect.iTl.iY; + break; + } + case ERotationAngle270: + { + rotatedSourceRect.iTl.iX = mirroredSourceRect.iTl.iY; + rotatedSourceRect.iTl.iY = iSourceSize.iWidth - mirroredSourceRect.iBr.iX; + rotatedSourceRect.iBr.iX = mirroredSourceRect.iBr.iY; + rotatedSourceRect.iBr.iY = iSourceSize.iWidth - mirroredSourceRect.iTl.iX; + break; + } + default: + { + // Internal state error, debug panic only + #ifdef _DEBUG + Panic( KErrGeneral ); + #endif + } + } + + return rotatedSourceRect; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::SourceSize +// ----------------------------------------------------------------------------- +TSize CIHLImageViewerExtJpg::SourceSize() const + { + if( iRotationAngle == ERotationAngle90 || + iRotationAngle == ERotationAngle270 ) + { + return TSize( iSourceSize.iHeight, iSourceSize.iWidth ); + } + else + { + return iSourceSize; + } + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::SetZoomRatio +// ----------------------------------------------------------------------------- +TInt CIHLImageViewerExtJpg::SetZoomRatio( TReal aZoomRatio ) + { + if( aZoomRatio <= 0 ) + { + return KErrArgument; + } + + iZoomRatio = aZoomRatio; + + // Recalculate source rect and destination size + CalculateSourceRectAndDestinationSize(); + + // Start load + return ApplySettings(); + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::ZoomRatio +// ----------------------------------------------------------------------------- +TReal CIHLImageViewerExtJpg::ZoomRatio() const + { + return iZoomRatio; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::ZoomToFitRatio +// ----------------------------------------------------------------------------- +TReal CIHLImageViewerExtJpg::ZoomToFitRatio() const + { + return iZoomToFitRatio; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::RotateClockwise +// ----------------------------------------------------------------------------- +TInt CIHLImageViewerExtJpg::RotateClockwise() + { + TInt rotationAngle( iRotationAngle + ERotationAngle90 ); + if( rotationAngle > ERotationAngle270 ) + { + rotationAngle = ERotationAngle0; + } + + return SetRotationAngle( rotationAngle ); + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::RotateCounterClockwise +// ----------------------------------------------------------------------------- +TInt CIHLImageViewerExtJpg::RotateCounterClockwise() + { + TInt rotationAngle( iRotationAngle - ERotationAngle90 ); + if( rotationAngle < ERotationAngle0 ) + { + rotationAngle = ERotationAngle270; + } + + return SetRotationAngle( rotationAngle ); + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::SetRotationAngle +// ----------------------------------------------------------------------------- +TInt CIHLImageViewerExtJpg::SetRotationAngle( TInt aRotationAngle ) + { + if( aRotationAngle != ERotationAngle0 && + aRotationAngle != ERotationAngle90 && + aRotationAngle != ERotationAngle180 && + aRotationAngle != ERotationAngle270 ) + { + return KErrArgument; + } + + iRotationAngle = aRotationAngle; + + // Recalculate source rect and destination size + CalculateSourceRectAndDestinationSize(); + + // Recalculate zoom to fit ratio + CalculateZoomToFitRatio(); + + // Start load + return ApplySettings(); + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::RotationAngle +// ----------------------------------------------------------------------------- +TInt CIHLImageViewerExtJpg::RotationAngle() const + { + return iRotationAngle; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::SetVerticalMirroring +// ----------------------------------------------------------------------------- +TInt CIHLImageViewerExtJpg::SetVerticalMirroring( TBool aValue ) + { + if( iVerticalMirroring != aValue ) + { + iVerticalMirroring = aValue; + + // Start load + return ApplySettings(); + } + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::VerticalMirroring +// ----------------------------------------------------------------------------- +TBool CIHLImageViewerExtJpg::VerticalMirroring() const + { + return iVerticalMirroring; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::SetHorizontalMirroring +// ----------------------------------------------------------------------------- +TInt CIHLImageViewerExtJpg::SetHorizontalMirroring( TBool aValue ) + { + if( iHorizontalMirroring != aValue ) + { + iHorizontalMirroring = aValue; + return ApplySettings(); + } + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::HorizontalMirroring +// ----------------------------------------------------------------------------- +TBool CIHLImageViewerExtJpg::HorizontalMirroring() const + { + return iHorizontalMirroring; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::SetFilter +// ----------------------------------------------------------------------------- +void CIHLImageViewerExtJpg::SetFilter( MIHLFilter* /*aFilter*/ ) + { + // Not in use + } + + + +// Private methods +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::DoCancel +// ----------------------------------------------------------------------------- +void CIHLImageViewerExtJpg::DoCancel() + { + CTimer::DoCancel(); + // Set state to inactive + switch( iViewerState ) + { + case ELoad: + { + // Cancel asynchronous source loading + iSource.CancelLoad(); + iCacheSource->Reset(); + break; + } + case EProcess: + { + // Cancel asynchronous processing + iProcessor->CancelProcess(); + iCacheDestination->Reset(); + break; + } + default: + { + break; + } + } + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::RunL +// ----------------------------------------------------------------------------- +void CIHLImageViewerExtJpg::RunL() + { + User::LeaveIfError( iStatus.Int() ); + + // Save previous state and set current state immediately + // to inactive to keep state up-to-date + TViewerState prevState( iViewerState ); + iViewerState = EInactive; + + switch( prevState ) + { + case ELoad: + { + //Use the internal processor if the codec is lacking some processing capability + if( iInternalProcessingNeeded ) + { + const CFbsBitmap& srcBitmap = iCacheSource->Bitmap(); + User::LeaveIfError( iCacheDestination->Create( iDestinationSize, srcBitmap.DisplayMode() ) ); + TRect processSourceRect( CalculateProcessSourceRect( iCacheSource->Bitmap().SizeInPixels() ) ); + TRect destinationRect( CalculateProcessDestinationRect() ); + + User::LeaveIfError( iProcessor->Process( iStatus, *iCacheSource, processSourceRect, + *iCacheDestination, destinationRect ) ); + + iViewerState = EProcess; + SetActive(); + } + else + { + User::LeaveIfError( Finish() ); + iObserver.ViewerBitmapChangedL(); + } + break; + } + case EProcess: + { + User::LeaveIfError( Finish() ); + iObserver.ViewerBitmapChangedL(); + break; + } + default: + { + // Internal state error, debug panic only + #ifdef _DEBUG + Panic( KErrGeneral ); + #endif + } + } + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::RunError +// ----------------------------------------------------------------------------- +TInt CIHLImageViewerExtJpg::RunError( TInt aError ) + { + switch( iViewerState ) + { + case ELoad: + { + // Cleanup cached source if load has been failed + iCacheSource->Reset(); + break; + } + case EProcess: + { + // Cleanup cached destination if process has been failed + iCacheDestination->Reset(); + break; + } + default: + { + break; + } + } + + iViewerState = EInactive; + iObserver.ViewerError( aError ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::ApplySettings +// ----------------------------------------------------------------------------- +TInt CIHLImageViewerExtJpg::ApplySettings() + { + // Assert source rect and destination, debug build only +#ifdef _DEBUG + AssertSourceRectAndDestinationSize(); +#endif + + // Cancel current process if any + Cancel(); + + // Perform processing if supported by codec + if( !iInternalProcessingNeeded ) + { + TRAPD( err, iSource.SetRotationL( iRotationAngle ) ); + if( !err && iHorizontalMirroring ) + { + TRAP( err, iSource.SetFlippingL() ); + } + if( !err && iVerticalMirroring ) + { + TRAP( err, iSource.SetMirroringL() ); + } + if( err ) + { + return err; + } + } + + // Start async load/process. + TInt err( KErrNone ); + + err = AsyncLoad(); + if( !err ) + { + iViewerState = ELoad; + SetActive(); + } + + return err; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::AsyncLoad +// ----------------------------------------------------------------------------- +TInt CIHLImageViewerExtJpg::AsyncLoad() + { + // Internal state check, debug panic only + __ASSERT_DEBUG( !iCacheDestination->Bitmap().Handle(), Panic( KErrGeneral ) ); + + TInt err( KErrNone ); + + // Load source bitmap + + iCacheSource->Reset(); + + err = iCacheSource->Create( iDestinationSize, iSource.DisplayMode() ); + + if( !err ) + { + err = iSource.Load( iSourceRect, iStatus, *iCacheSource ); + } + + // Error cleanup if needed + if( err ) + { + iCacheSource->Reset(); + } + return err; + } + + + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::Finish +// ----------------------------------------------------------------------------- +TInt CIHLImageViewerExtJpg::Finish() + { + // Internal state check, debug panic only + __ASSERT_DEBUG( iCacheSource->Bitmap().Handle(), Panic( KErrGeneral ) ); + + TInt err( KErrNone ); + + // Check if internal processor was used + if( iInternalProcessingNeeded ) + { + err = iDestination.Copy( *iCacheDestination, ETrue ); + iCacheDestination->Reset(); + } + else + { + err = iDestination.Copy( *iCacheSource, ETrue ); + iCacheSource->Reset(); + } + + // Error cleanup if needed + if( err ) + { + iDestination.Reset(); + } + + return err; + } + + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::SelfComplete +// ----------------------------------------------------------------------------- +void CIHLImageViewerExtJpg::SelfComplete() + { + SetActive(); + iStatus = KRequestPending; + TRequestStatus* status = &iStatus; + User::RequestComplete( status, KErrNone ); + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::CalculateProcessSourceRect +// ----------------------------------------------------------------------------- +TRect CIHLImageViewerExtJpg::CalculateProcessSourceRect( const TSize& aSourceCacheSize ) + { + + TRect loadRect( aSourceCacheSize ); + + switch( iRotationAngle ) + { + case ERotationAngle0: + { + break; + } + case ERotationAngle90: + { + TInt tmp( loadRect.iTl.iY ); + loadRect.iTl.iY = loadRect.iBr.iY; + loadRect.iBr.iY = tmp; + break; + } + case ERotationAngle180: + { + TPoint tmp( loadRect.iTl ); + loadRect.iTl = loadRect.iBr; + loadRect.iBr = tmp; + break; + } + case ERotationAngle270: + { + TInt tmp( loadRect.iTl.iX ); + loadRect.iTl.iX = loadRect.iBr.iX; + loadRect.iBr.iX = tmp; + break; + } + default: + { + // Internal state error, debug panic only + #ifdef _DEBUG + Panic( KErrGeneral ); + #endif + } + } + + return loadRect; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::CalculateProcessDestinationRect +// ----------------------------------------------------------------------------- +TRect CIHLImageViewerExtJpg::CalculateProcessDestinationRect() + { + TRect dstRect( iDestinationSize ); + switch( iRotationAngle ) + { + case ERotationAngle0: + case ERotationAngle180: + { + if( iHorizontalMirroring ) + { + TInt tmp( dstRect.iTl.iX ); + dstRect.iTl.iX = dstRect.iBr.iX; + dstRect.iBr.iX = tmp; + } + if( iVerticalMirroring ) + { + TInt tmp( dstRect.iTl.iY ); + dstRect.iTl.iY = dstRect.iBr.iY; + dstRect.iBr.iY = tmp; + } + break; + } + case ERotationAngle90: + case ERotationAngle270: + { + if( iHorizontalMirroring ) + { + TInt tmp( dstRect.iTl.iY ); + dstRect.iTl.iY = dstRect.iBr.iY; + dstRect.iBr.iY = tmp; + } + if( iVerticalMirroring ) + { + TInt tmp( dstRect.iTl.iX ); + dstRect.iTl.iX = dstRect.iBr.iX; + dstRect.iBr.iX = tmp; + } + break; + } + default: + { + // Internal state error, debug panic only + #ifdef _DEBUG + Panic( KErrGeneral ); + #endif + } + } + return dstRect; + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::CalculateZoomToFitRatio +// ----------------------------------------------------------------------------- +void CIHLImageViewerExtJpg::CalculateZoomToFitRatio() + { + TSize sourceSize( SourceSize() ); + TReal widthRatio( TReal( iViewerSize.iWidth ) / TReal( sourceSize.iWidth ) ); + TReal heightRatio( TReal( iViewerSize.iHeight ) / TReal( sourceSize.iHeight ) ); + + if( iOptions & MIHLImageViewer::EOptionIgnoreAspectRatio ) + { + iZoomToFitRatio = ( widthRatio > heightRatio ) ? widthRatio : heightRatio; + } + else + { + iZoomToFitRatio = ( widthRatio < heightRatio ) ? widthRatio : heightRatio; + } + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::CalculateSourceRectAndDestinationSize +// ----------------------------------------------------------------------------- +void CIHLImageViewerExtJpg::CalculateSourceRectAndDestinationSize() + { + // Calculate new source rect + TSize oldSourceRectSize( iSourceRect.Size() ); + + TReal newSourceRectWidth; + TReal newSourceRectHeight; + TReal widthZoomRatio( iZoomRatio ); + TReal heightZoomRatio( iZoomRatio ); + + if( iOptions & MIHLImageViewer::EOptionIgnoreAspectRatio ) + { + TReal widthRatio( TReal( iViewerSize.iWidth ) / TReal( iSourceSize.iWidth ) ); + TReal heightRatio( TReal( iViewerSize.iHeight ) / TReal( iSourceSize.iHeight ) ); + if( widthRatio < heightRatio ) + { + widthZoomRatio = widthZoomRatio * widthRatio / heightRatio; + } + else + { + heightZoomRatio = heightZoomRatio * heightRatio / widthRatio; + } + } + + if( iRotationAngle == ERotationAngle90 || + iRotationAngle == ERotationAngle270 ) + { + newSourceRectWidth = iSrcBitmapScaleFactor * iViewerSize.iHeight / heightZoomRatio; //widthZoomRatio + newSourceRectHeight = iSrcBitmapScaleFactor * iViewerSize.iWidth / widthZoomRatio; //heightZoomRatio + } + else + { + newSourceRectWidth = iSrcBitmapScaleFactor * iViewerSize.iWidth / widthZoomRatio; + newSourceRectHeight = iSrcBitmapScaleFactor * iViewerSize.iHeight / heightZoomRatio; + } + + // Check if source rect is not larger than source area + if( newSourceRectWidth > iSourceSize.iWidth ) + { + newSourceRectWidth = iSourceSize.iWidth; + } + if( newSourceRectHeight > iSourceSize.iHeight ) + { + newSourceRectHeight = iSourceSize.iHeight; + } + iSourceRect.SetWidth( (TInt)newSourceRectWidth ); + iSourceRect.SetHeight( (TInt)newSourceRectHeight ); + + // Calculate actual destination size (always same or smaller than iViewerSize !) + if( iRotationAngle == ERotationAngle90 || + iRotationAngle == ERotationAngle270 ) + { + iDestinationSize.iWidth = (TInt)( newSourceRectHeight * widthZoomRatio ); //heightZoomRatio + iDestinationSize.iHeight = (TInt)( newSourceRectWidth * heightZoomRatio ); //widthZoomRatio + } + else + { + iDestinationSize.iWidth = (TInt)( newSourceRectWidth * widthZoomRatio ); + iDestinationSize.iHeight = (TInt)( newSourceRectHeight * heightZoomRatio ); + } + // Check that destination size is not rounded to zero + if( iDestinationSize.iWidth == 0 ) + { + iDestinationSize.iWidth = 1; + } + if( iDestinationSize.iHeight == 0 ) + { + iDestinationSize.iHeight = 1; + } + + // Move source rect keeping center point in same location + iSourceRect.Move( ( oldSourceRectSize.iWidth - (TInt)newSourceRectWidth ) / 2, + ( oldSourceRectSize.iHeight - (TInt)newSourceRectHeight ) / 2 ); + + // Move rect if partially out of source area + TPoint moveOffset( 0, 0 ); + if( iSourceRect.iTl.iX < 0 ) + { + moveOffset.iX = -iSourceRect.iTl.iX; + } + else if( iSourceRect.iBr.iX > iSourceSize.iWidth ) + { + moveOffset.iX = iSourceSize.iWidth - iSourceRect.iBr.iX; + } + if( iSourceRect.iTl.iY < 0 ) //lint !e961 + { + moveOffset.iY = -iSourceRect.iTl.iY; + } + else if( iSourceRect.iBr.iY > iSourceSize.iHeight ) + { + moveOffset.iY = iSourceSize.iHeight - iSourceRect.iBr.iY; + } + iSourceRect.Move( moveOffset ); //lint !e961 + + // Assert that rectangle is valid, debug build only +#ifdef _DEBUG + AssertSourceRectAndDestinationSize(); +#endif + } + +// ----------------------------------------------------------------------------- +// CIHLImageViewerExtJpg::AssertSourceRectAndDestinationSize +// Used in debug build only +// ----------------------------------------------------------------------------- +#ifdef _DEBUG +void CIHLImageViewerExtJpg::AssertSourceRectAndDestinationSize() + { + if( iSourceRect.iTl.iX < 0 || + iSourceRect.iBr.iX > iSourceSize.iWidth || + iSourceRect.iTl.iY < 0 || + iSourceRect.iBr.iY > iSourceSize.iHeight || + iDestinationSize.iWidth <= 0 || iDestinationSize.iHeight <= 0 ) + { + Panic( KErrGeneral ); + } + } +#endif + +// End of File + + diff -r 000000000000 -r 2014ca87e772 imagehandlinglib/Src/CIHLImageViewerExtJpg.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlinglib/Src/CIHLImageViewerExtJpg.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,332 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of Image Viewer class. +* +*/ + + +#ifndef CIHLIMAGEVIEWEREXTJPG_H +#define CIHLIMAGEVIEWEREXTJPG_H + +// INCLUDES +#include "MIHLImageViewer.h" +#include + +//FORWARD DECLARATIONS +class MIHLFileImageExtJpg; +class MIHLBitmap; +class MIHLViewerObserver; +class CIHLBitmap; +class CIHLBitmapProcessor; + +// CLASS DECLARATION +/** +* CIHLImageViewer +* +* Image Viewer implementation class. +* @lib IHL.lib +* @since 3.0 +*/ +NONSHARABLE_CLASS( CIHLImageViewerExtJpg ) : public CTimer, public MIHLImageViewer + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CIHLImageViewerExtJpg* NewL( const TSize& aViewerSize, + MIHLFileImageExtJpg& aSource, + MIHLBitmap& aDestination, + MIHLViewerObserver& aObserver, + const TUint32 aOptions ); + + /* + * Virtual destructor. + */ + virtual ~CIHLImageViewerExtJpg(); + + public: // From base class MIHLViewer + + /* + * From MIHLViewer, see base class header. + */ + TIHLInterfaceType Type() const; + + public: + + /* + * From MIHLImageViewer, see base class header. + */ + TBool IsAnimation() const; + + /* + * From MIHLImageViewer, see base class header. + */ + void Play(); + + /* + * From MIHLImageViewer, see base class header. + */ + void Stop(); + + /* + * From MIHLImageViewer, see base class header. + */ + TBool IsPlaying() const; + + /* + * From MIHLImageViewer, see base class header. + */ + TInt AnimationFrameCount() const; + + /* + * From MIHLImageViewer, see base class header. + */ + TInt AnimationFrame() const; + + /* + * From MIHLImageViewer, see base class header. + */ + TInt SetAnimationFrame( TInt aFrameIndex ); + + /* + * From MIHLImageViewer, see base class header. + */ + TInt SetViewerSize( const TSize& aViewerSize, TInt srcBitmapScaleFactor = 1 ); + + /* + * From MIHLImageViewer, see base class header. + */ + TSize ViewerSize() const; + + /* + * From MIHLImageViewer, see base class header. + */ + TInt MoveSourceRect( TInt aDx, TInt aDy ); + + /* + * From MIHLImageViewer, see base class header. + */ + TInt SetSourceRectPosition( const TPoint& aPosition ); + + /* + * From MIHLImageViewer, see base class header. + */ + TRect SourceRect() const; + + /* + * From MIHLImageViewer, see base class header. + */ + TSize SourceSize() const; + + /* + * From MIHLImageViewer, see base class header. + */ + TInt SetZoomRatio( TReal aZoomRatio ); + + /* + * From MIHLImageViewer, see base class header. + */ + TReal ZoomRatio() const; + + /* + * From MIHLImageViewer, see base class header. + */ + TReal ZoomToFitRatio() const; + + /* + * From MIHLImageViewer, see base class header. + */ + TInt RotateClockwise(); + + /* + * From MIHLImageViewer, see base class header. + */ + TInt RotateCounterClockwise(); + + /* + * From MIHLImageViewer, see base class header. + */ + TInt SetRotationAngle( TInt aRotationAngle ); + + /* + * From MIHLImageViewer, see base class header. + */ + TInt RotationAngle() const; + + /* + * From MIHLImageViewer, see base class header. + */ + TInt SetVerticalMirroring( TBool aValue ); + + /* + * From MIHLImageViewer, see base class header. + */ + TBool VerticalMirroring() const; + + /* + * From MIHLImageViewer, see base class header. + */ + TInt SetHorizontalMirroring( TBool aValue ); + + /* + * From MIHLImageViewer, see base class header. + */ + TBool HorizontalMirroring() const; + + /* + * From MIHLImageViewer, see base class header. + */ + void SetFilter( MIHLFilter* aFilter ); + + public: + + + + public: // From base class CTimer + + /* + * From CTimer, see base class header. + */ + void DoCancel(); + + /* + * From CTimer, see base class header. + */ + void RunL(); + + /* + * From CTimer, see base class header. + */ + TInt RunError( TInt aError ); + + + private: // Private methods + + /* + * Start asynchronous processing with new settings. + * This is needed always when settings are changed. + */ + TInt ApplySettings(); + + /* + * Start load process source bitmap. + */ + TInt AsyncLoad(); + + /* + * Finish processing and notify client. + */ + TInt Finish(); + + /* + * Complete dummy request. This causes RunL() method to be called. + * Needed by state machine. + */ + void SelfComplete(); + + /* + * Calculate source bitmap rectangle needed by processor. + * Rectangle is affected by rotating and mirroring settings etc. + */ + TRect CalculateProcessSourceRect( const TSize& aSourceCacheSize ); + + /* + * Calculate destination bitmap rectangle needed by processor. + * Rectangle is affected by rotating and mirroring settings etc. + */ + TRect CalculateProcessDestinationRect(); + + /* + * Calculate needed zoomratio for "fit-to-screen" zooming. + */ + void CalculateZoomToFitRatio(); + + /* + * Calculate source bitmap rectangle and destination bitmap size. + * These values needs to be recalculated when rectangle setting is changed. + */ + void CalculateSourceRectAndDestinationSize(); + + /* + * Assert if source bitmap rectangle and destination bitmpa size are valid. + * This method is called by CalculateSourceRectAndDestinationSize() + */ +#ifdef _DEBUG + void AssertSourceRectAndDestinationSize(); +#endif + + private: // Private constructors + + void ConstructL(); + CIHLImageViewerExtJpg( const TSize& aViewerSize, + MIHLFileImageExtJpg& aSource, + MIHLBitmap& aDestination, + MIHLViewerObserver& aObserver, + const TUint32 aOptions ); + + private: // Private data types + + enum TViewerState + { + EInactive, + ELoad, + EProcess + }; + + private: // Data + + // Viewer state + TViewerState iViewerState; + + // Ref: Observers + MIHLViewerObserver& iObserver; + + // Ref: Viewer source image + MIHLFileImageExtJpg& iSource; + TSize iSourceSize; + TRect iSourceRect; + + // Ref: Viewer destination bitmap + MIHLBitmap& iDestination; + TSize iDestinationSize; + + // Viewing settings + const TUint32 iOptions; + TSize iViewerSize; + TReal iZoomRatio; + TReal iZoomToFitRatio; + TInt iRotationAngle; + TBool iVerticalMirroring; + TBool iHorizontalMirroring; + + // Decoder capabilities + TInt iCapabilities; + + // Internal processor flag + TBool iInternalProcessingNeeded; + + // Own: Bitmap caches + CIHLBitmap* iCacheSource; + CIHLBitmap* iCacheDestination; + // Own: Bitmap processor + CIHLBitmapProcessor* iProcessor; + // src bitmap scale factor + TInt iSrcBitmapScaleFactor; + + }; + +#endif // CIHLIMAGEVIEWEREXTJPG_H + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandlinglib/Src/CIHLScaler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlinglib/Src/CIHLScaler.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,1315 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of Scaling processor +* : using Font and Bitmap Server bitmaps. +* +*/ + +// INCLUDE FILES +#include "CIHLScaler.h" +#include "IHLDebugPrint.h" // Debug print +#include // MIHLImageViewer +#include +#include + +// Private namespace for constants and functions +namespace + { + // Processed pixels per one activesheduler step + const TInt KProcessPixelsPerStep = 16384; + + // These make the fast path scalings step out about every 5-10ms + // no reason to cut more aggressively since it just slows down everything + const TInt KBytesPerStepFastPath = 640*480; + const TInt KBytesPerStepFastPathScaleOnly = 640*480*2; + + const TInt KStepPrecision = 16; // 16 bit = 65k subpixels + const TInt KMaxProcessSize = KMaxTInt / 2; + } + +//functions and typedefs used inside ProcessBilinear scaling +namespace + { + // using our own RGB instead of TRGB as we need TInt32 for each value + typedef struct + { + TInt32 r, g, b, a; + } TColorRGB; + + // structure for handling data of 4 pixels + typedef struct + { + TColorRGB colXY00, colXY01, colXY10, colXY11; + TColorRGB col0, col1, col; + } TPixelData; + + // functions to handle conversion between TColorRGB and colr value stored in TInt32 + inline void IntToRgb(TInt32 aIntRGB_val, TColorRGB &col) + { + col.r = (aIntRGB_val >> 16) & 0x00ff; + col.g = (aIntRGB_val >> 8) & 0x00ff; + col.b = aIntRGB_val & 0x00ff; + col.a = (aIntRGB_val >> 24) & 0x00ff; + } + inline TUint32 RgbToInt(TColorRGB &col) + { + return 0x00000000 | ( ( col.r & 0xff) << 16 ) | ( ( col.g & 0xff) << 8 ) + | ( col.b & 0xff) | ( ( col.a & 0xff) << 24 ); + } + + // function which interpolates color using gathered data + inline void ProcessColorData( TPixelData &dat, TPoint aSrcPos ) + { + TInt32 pixel_width = 1 << KStepPrecision; + + //first pass (Y axis) + dat.col0.r = (dat.colXY01.r - dat.colXY00.r)*(aSrcPos.iY % pixel_width) / pixel_width + dat.colXY00.r; + dat.col0.g = (dat.colXY01.g - dat.colXY00.g)*(aSrcPos.iY % pixel_width) / pixel_width + dat.colXY00.g; + dat.col0.b = (dat.colXY01.b - dat.colXY00.b)*(aSrcPos.iY % pixel_width) / pixel_width + dat.colXY00.b; + dat.col0.a = (dat.colXY01.a - dat.colXY00.a)*(aSrcPos.iY % pixel_width) / pixel_width + dat.colXY00.a; + + dat.col1.r = (dat.colXY11.r - dat.colXY10.r)*(aSrcPos.iY % pixel_width) / pixel_width + dat.colXY10.r; + dat.col1.g = (dat.colXY11.g - dat.colXY10.g)*(aSrcPos.iY % pixel_width) / pixel_width + dat.colXY10.g; + dat.col1.b = (dat.colXY11.b - dat.colXY10.b)*(aSrcPos.iY % pixel_width) / pixel_width + dat.colXY10.b; + dat.col1.a = (dat.colXY11.a - dat.colXY10.a)*(aSrcPos.iY % pixel_width) / pixel_width + dat.colXY10.a; + + //second pass (X axis) + dat.col.r = (dat.col1.r - dat.col0.r)*(aSrcPos.iX % pixel_width) / pixel_width + dat.col0.r; + dat.col.g = (dat.col1.g - dat.col0.g)*(aSrcPos.iX % pixel_width) / pixel_width + dat.col0.g; + dat.col.b = (dat.col1.b - dat.col0.b)*(aSrcPos.iX % pixel_width) / pixel_width + dat.col0.b; + dat.col.a = (dat.col1.a - dat.col0.a)*(aSrcPos.iX % pixel_width) / pixel_width + dat.col0.a; + } + } + +// ======================== STATIC FACTORY FUNCTION ============================ +// ----------------------------------------------------------------------------- +// IHLScaler::CreateL +// ----------------------------------------------------------------------------- +// +EXPORT_C MIHLScaler* IHLScaler::CreateL( const TUint32 aOptions ) + { + return CIHLScaler::NewL( aOptions ); + } + +// ============================ MEMBER FUNCTIONS =============================== +// ----------------------------------------------------------------------------- +// +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +CIHLScaler::CIHLScaler( const TUint32 aOptions ) +:CActive( CActive::EPriorityStandard ), iOptions( aOptions ) + { + CActiveScheduler::Add( this ); + } + +// ----------------------------------------------------------------------------- +// +// Two-phased constructor. +// ----------------------------------------------------------------------------- +CIHLScaler* CIHLScaler::NewL( const TUint32 aOptions ) + { + CIHLScaler* self = new( ELeave ) CIHLScaler( aOptions ); + return self; + } + +// ----------------------------------------------------------------------------- +// Destructor +// ----------------------------------------------------------------------------- +CIHLScaler::~CIHLScaler() + { + Cancel(); + } + +// ----------------------------------------------------------------------------- +// CIHLScaler::Scale +// ----------------------------------------------------------------------------- +TInt CIHLScaler::Scale( TRequestStatus& aStatus, + const CFbsBitmap& aSrcBitmap, const TRect& aSrcRect, + CFbsBitmap& aDstBitmap, const TRect& aDstRect ) + { + if( IsBusy() ) + { + return KErrNotReady; + } + + TSize srcRectSize( aSrcRect.Size() ); + TSize dstRectSize( aDstRect.Size() ); + if( Abs( srcRectSize.iWidth ) > KMaxProcessSize || + Abs( srcRectSize.iHeight ) > KMaxProcessSize || + Abs( dstRectSize.iWidth ) > KMaxProcessSize || + Abs( dstRectSize.iHeight ) > KMaxProcessSize ) + { + return KErrTooBig; + } + + if( !aSrcBitmap.Handle() || + !IsValidRect( aSrcBitmap.SizeInPixels(), aSrcRect ) ) + { + return KErrArgument; + } + + if( aDstBitmap.Handle() ) + { + if( !IsValidRect( aDstBitmap.SizeInPixels(), aDstRect ) ) + { + return KErrArgument; + } + } + else + { + // Create destination bitmap + TSize dstSize( Abs( dstRectSize.iWidth ), Abs( dstRectSize.iHeight ) ); + TInt err = aDstBitmap.Create( dstSize, aSrcBitmap.DisplayMode() ); + if( err ) + { + return err; + } + } + +#ifdef RD_MEASURE_THROUGHPUT + iStartTime = User::FastCounter(); // For measuring scaler throughput +#endif + + TSize srcSize( aSrcBitmap.SizeInPixels() ); + TSize dstSize( aDstBitmap.SizeInPixels() ); + + if( srcSize.iWidth == 0 || srcSize.iHeight == 0 || + dstSize.iWidth == 0 || dstSize.iHeight == 0 || + aSrcRect.iTl.iX == aSrcRect.iBr.iX || + aSrcRect.iTl.iY == aSrcRect.iBr.iY || + aDstRect.iTl.iX == aDstRect.iBr.iX || + aDstRect.iTl.iY == aDstRect.iBr.iY ) + { + // Bitmap or rect width or height is zero so there is nothing to do. + // Complete process without error. + iNeedProcess = EFalse; + } + else + { + iNeedProcess = ETrue; + + // Set parameters to member data references + iSrcBitmap = &aSrcBitmap; + iSrcRect = aSrcRect; + iDstBitmap = &aDstBitmap; + iDstRect = aDstRect; + + TDisplayMode srcMode(iSrcBitmap->DisplayMode()); + TDisplayMode dstMode(iDstBitmap->DisplayMode()); + + IHL_DEBUG3( KIHLDebug1, "CIHLScaler: src bitmap size %dx%d", srcSize.iWidth, srcSize.iHeight); + IHL_DEBUG3( KIHLDebug2, "CIHLScaler: dst bitmap size %dx%d", dstSize.iWidth, dstSize.iHeight); + IHL_DEBUG5( KIHLDebug3, "CIHLScaler: src bitmap rect %d.%d -> %d.%d", iSrcRect.iTl.iX, iSrcRect.iTl.iY, iSrcRect.iBr.iX, iSrcRect.iBr.iY); + IHL_DEBUG5( KIHLDebug4, "CIHLScaler: dst bitmap rect %d.%d -> %d.%d", iDstRect.iTl.iX, iDstRect.iTl.iY, iDstRect.iBr.iX, iDstRect.iBr.iY); + IHL_DEBUG2( KIHLDebug5, "CIHLScaler: src bitmap mode %d", srcMode); + IHL_DEBUG2( KIHLDebug6, "CIHLScaler: dst bitmap mode %d", dstMode); + IHL_DEBUG2( KIHLDebug7, "CIHLScaler: src compressed %d", iSrcBitmap->IsCompressedInRAM()); + IHL_DEBUG2( KIHLDebug8, "CIHLScaler: dst compressed %d", iSrcBitmap->IsCompressedInRAM()); + + // Init stepper values + TBool onlyScaling = InitStepperValues(); + + // Select correct code path + InitCodePath(srcSize, srcMode, dstSize, dstMode, onlyScaling); + } + + IHL_DEBUG1( KIHLDebug, "IHL - CIHLScaler - Start bitmap scaling" ); + + // Start processing + iScalerStatus = &aStatus; + *iScalerStatus = KRequestPending; + + SelfComplete(); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CIHLScaler::IsBusy +// ----------------------------------------------------------------------------- +TBool CIHLScaler::IsBusy() const + { + return IsActive(); + } + +// ----------------------------------------------------------------------------- +// CIHLScaler::CancelProcess +// ----------------------------------------------------------------------------- +void CIHLScaler::CancelProcess() + { + Cancel(); + } + +// ----------------------------------------------------------------------------- +// CIHLScaler::SetFilter +// ----------------------------------------------------------------------------- +void CIHLScaler::SetFilter( MIHFilter* /*aFilter*/ ) + { + // Not in use + } + +// ----------------------------------------------------------------------------- +// CIHLScaler::DoCancel +// ----------------------------------------------------------------------------- +void CIHLScaler::DoCancel() + { + RequestComplete( KErrCancel ); + } + +// ----------------------------------------------------------------------------- +// CIHLScaler::RunL +// ----------------------------------------------------------------------------- +void CIHLScaler::RunL() + { + User::LeaveIfError( iStatus.Int() ); + + // Process bitmap (this if-else may look weird but it removes one extra triggering of the AS + if( iNeedProcess ) + { + // Call the selected code path directly via a function pointer + iNeedProcess = (this->*ProcessingFunc)(); + } + + if(!iNeedProcess) + { +#ifdef RD_MEASURE_THROUGHPUT + // Calculate throughput + TUint32 end = User::FastCounter(); + + TInt tickPeriod; + HAL::Get(HALData::EFastCounterFrequency, tickPeriod); + TReal time = TReal(end-iStartTime) / TReal(tickPeriod); + TReal bytes = iProcessSize.iWidth*iProcessSize.iHeight*2; + + IHL_DEBUG3("IHL - CIHLScaler - Scaling complete, %.3f ms, %.3f MB/s", time*1000.0, (bytes/time)/1024.0/1024.0); +#else + IHL_DEBUG1( KIHLDebug, "IHL - CIHLScaler - Scaling complete!" ); +#endif + // Process complete + RequestComplete( KErrNone ); + } + else + { + // Another round + SelfComplete(); + } + } + +// ----------------------------------------------------------------------------- +// CIHLScaler::RunError +// ----------------------------------------------------------------------------- +TInt CIHLScaler::RunError( TInt aError ) + { + IHL_DEBUG2( KIHLDebug, "IHL - CIHLScaler - Scaling error: %d", aError ); + + RequestComplete( aError ); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CIHLScaler::IsValidRect +// ----------------------------------------------------------------------------- +TBool CIHLScaler::IsValidRect( const TSize& aSize, const TRect& aRect ) + { + if( aRect.iTl.iX >= 0 && + aRect.iTl.iX <= aSize.iWidth && + aRect.iTl.iY >= 0 && + aRect.iTl.iY <= aSize.iHeight && + aRect.iBr.iX >= 0 && + aRect.iBr.iX <= aSize.iWidth && + aRect.iBr.iY >= 0 && + aRect.iBr.iY <= aSize.iHeight ) + { + return ETrue; + } + return EFalse; + } + +// ----------------------------------------------------------------------------- +// CIHLScaler::InitStepperValues +// ----------------------------------------------------------------------------- +TBool CIHLScaler::InitStepperValues() + { + TBool onlyScaling = EFalse; + + TSize srcRectSize( Abs( iSrcRect.Width() ), Abs( iSrcRect.Height() ) ); + TSize dstRectSize( Abs( iDstRect.Width() ), Abs( iDstRect.Height() ) ); + + TReal srcW = srcRectSize.iWidth << KStepPrecision; + TReal srcH = srcRectSize.iHeight << KStepPrecision; + + // ----------------------------------------- + // Set source start point and increment + // ----------------------------------------- + if( iSrcRect.iTl.iX > iSrcRect.iBr.iX && + iSrcRect.iTl.iY < iSrcRect.iBr.iY ) + { + TReal incrementInner( srcH / TReal(dstRectSize.iWidth) ); + TReal incrementOuter( srcW / TReal(dstRectSize.iHeight) ); + + iSrcIncrementInner.iX = 0; + iSrcIncrementInner.iY = incrementInner; + iSrcIncrementOuter.iX = -incrementOuter; + iSrcIncrementOuter.iY = 0; + + iSrcPos.SetXY( (iSrcRect.iTl.iX << KStepPrecision) - (incrementOuter / 2.0), + (iSrcRect.iTl.iY << KStepPrecision) + (incrementInner / 2.0) ); + } + else if ( iSrcRect.iTl.iX > iSrcRect.iBr.iX && + iSrcRect.iTl.iY > iSrcRect.iBr.iY ) + { + TReal incrementInner( srcW / TReal(dstRectSize.iWidth) ); + TReal incrementOuter( srcH / TReal(dstRectSize.iHeight) ); + + iSrcIncrementInner.iX = -incrementInner; + iSrcIncrementInner.iY = 0; + iSrcIncrementOuter.iX = 0; + iSrcIncrementOuter.iY = -incrementOuter; + + iSrcPos.SetXY( (iSrcRect.iTl.iX << KStepPrecision) - (incrementInner / 2.0), + (iSrcRect.iTl.iY << KStepPrecision) - (incrementOuter / 2.0) ); + } + else if ( iSrcRect.iTl.iX < iSrcRect.iBr.iX && + iSrcRect.iTl.iY > iSrcRect.iBr.iY ) + { + TReal incrementInner( srcH / TReal(dstRectSize.iWidth) ); + TReal incrementOuter( srcW / TReal(dstRectSize.iHeight) ); + + iSrcIncrementInner.iX = 0; + iSrcIncrementInner.iY = -incrementInner; + iSrcIncrementOuter.iX = incrementOuter; + iSrcIncrementOuter.iY = 0; + + iSrcPos.SetXY( (iSrcRect.iTl.iX << KStepPrecision) + (incrementOuter / 2.0), + (iSrcRect.iTl.iY << KStepPrecision) - (incrementInner / 2.0) ); + } + else + { + TReal incrementInner( srcW / TReal(dstRectSize.iWidth) ); + TReal incrementOuter( srcH / TReal(dstRectSize.iHeight) ); + + IHL_DEBUG3(KIHLDebug, "incrementInner: %f, incrementOuter: %f", incrementInner, incrementOuter); + + iSrcIncrementInner.iX = incrementInner; + iSrcIncrementInner.iY = 0; + iSrcIncrementOuter.iX = 0; + iSrcIncrementOuter.iY = incrementOuter; + + iSrcPos.SetXY( (iSrcRect.iTl.iX << KStepPrecision) + (incrementInner / 2.0), + (iSrcRect.iTl.iY << KStepPrecision) + (incrementOuter / 2.0) ); + + onlyScaling = ETrue; + } + + // ----------------------------------------- + // Set destination start point and increment + // ----------------------------------------- + + iDstPos.iX = iDstRect.iTl.iX; + iDstIncrementInner = 1; + iDstPos.iY = iDstRect.iTl.iY; + iDstIncrementOuter = 1; + + if( iDstRect.iTl.iX > iDstRect.iBr.iX ) + { + // From right to left + iDstPos.iX--; + iDstIncrementInner = -1; + onlyScaling = EFalse; + } + + if( iDstRect.iTl.iY > iDstRect.iBr.iY ) + { + // From bottom to up + iDstPos.iY--; + iDstIncrementOuter = -1; + onlyScaling = EFalse; + } + + // ----------------------------------------- + // Reset process counters + // ----------------------------------------- + iProcessInner = 0; + iProcessOuter = 0; + iProcessSize = dstRectSize; + + // These are for fast code path + + // Init how many scanlines to process + iScanlinesLeft = iProcessSize.iHeight; + + return onlyScaling; + } + + +// Optimize the fast code paths properly for ARM +#ifdef __ARMCC__ +#pragma push +#pragma O3 +#pragma Otime +#pragma arm +#endif + +// ----------------------------------------------------------------------------- +// CIHLScaler::ProcessNearestNeighbour64K +// Description: Scales & rotates 64K color bitmaps +// ----------------------------------------------------------------------------- +TBool CIHLScaler::ProcessNearestNeighbour64K() + { + // Lock bitmap heaps + iSrcBitmap->LockHeap(); + iDstBitmap->LockHeap(); + + // Pointers to start of bitmap data + TUint16 *srcBitmapPtr = (TUint16*)iSrcBitmap->DataAddress(); + TUint16 *dstBitmapPtr = (TUint16*)iDstBitmap->DataAddress(); + + // Get pointer to correct destination pixel (offset is updated after every round) + register TUint16* dst = dstBitmapPtr + iDstStartOffset; + + TUint32 width = iProcessSize.iWidth; + + // Check how many scanlines we can process this round + register TUint32 scanlinesLeft = iScanlinesLeft; + if(scanlinesLeft>iScanlinesPerRound) + { + scanlinesLeft = iScanlinesPerRound; + } + + // How many scanlines left for the next round + iScanlinesLeft-=scanlinesLeft; + + // Faster access to variables (it's slow to use member variables) + register TInt srcPosX(iSrcPos.iX); + register TInt srcPosY(iSrcPos.iY); + register TInt srcPitch = iSrcPitchInPixels; + + TInt incOuterSrcX = (-iSrcIncrementInner.iX * width) + iSrcIncrementOuter.iX; + TInt incOuterSrcY = (-iSrcIncrementInner.iY * width) + iSrcIncrementOuter.iY; + + while(scanlinesLeft!=0) + { + for(register TUint32 x = width; x!=0; x--) + { + register TUint16* src = srcBitmapPtr + ((srcPosY >> KStepPrecision) * srcPitch) + (srcPosX>>KStepPrecision); + *dst = *src; + + // Add inner counters + srcPosX+=iSrcIncrementInner.iX; + srcPosY+=iSrcIncrementInner.iY; + + dst+=iDstIncrementInner; + } + + // Reset inner counters and add outer counters + srcPosX += incOuterSrcX; + srcPosY += incOuterSrcY; + + // Move destination pointer to next pixel + dst += iDstResidualPixels; + + // One scanline done, n to go + scanlinesLeft--; + } + // Unlock bitmap heaps + iDstBitmap->UnlockHeap(); + iSrcBitmap->UnlockHeap(); + + if(iScanlinesLeft) + { + // Not all scanlines were processed yet + + // Save the necessary offsets for next round + iSrcPos.iX = srcPosX; + iSrcPos.iY = srcPosY; + iDstStartOffset = dst - dstBitmapPtr; + + return ETrue; + } + + // Processing done + return EFalse; + } + +// ----------------------------------------------------------------------------- +// CIHLScaler::ProcessNearestNeighbour64KScaleOnly +// ----------------------------------------------------------------------------- +TBool CIHLScaler::ProcessNearestNeighbour64KScaleOnly() + { + // Lock bitmap heaps + iSrcBitmap->LockHeap(); + iDstBitmap->LockHeap(); + + // Get bitmap data start addresses + TUint16 *srcBitmapPtr = (TUint16*)iSrcBitmap->DataAddress(); + TUint16 *dstBitmapPtr = (TUint16*)iDstBitmap->DataAddress(); + + // Target height and width + TInt width = iProcessSize.iWidth; + + // fixed point source coordinates + TInt startX = iSrcPos.iX; + TInt srcY = iSrcPos.iY; + + // How much to increase src position (in fixed point) + TInt srcYIncrement = iSrcIncrementOuter.iY; + register TInt srcXIncrement = iSrcIncrementInner.iX; + + // Set pointers to correct location (src = start of scanline, dst = start pixel) + register TUint16* dst = dstBitmapPtr + iDstStartOffset; + + // Calculate how many scanlines we can process this round + register TInt scanlinesLeft = iScanlinesLeft; + if(scanlinesLeft>iScanlinesPerRound) + { + scanlinesLeft = iScanlinesPerRound; + } + + iScanlinesLeft-=scanlinesLeft; + + while(scanlinesLeft--) + { + // Outer loop + + // Reset src X and scanline pointer + register TInt srcX = startX; + register TUint16* src = srcBitmapPtr + (srcY >> KStepPrecision) * iSrcPitchInPixels; + + // Init pixel counter + register TUint32 pixels = width; + + // Unaligned pixels to the left of 8B-aligned section + while((TUint32(dst)&0x7) && pixels) + { + *dst++ = (*(src + (srcX >> KStepPrecision))); + + srcX += srcXIncrement; + + pixels--; + } + + // Aligned middle section + register TUint32 middle = pixels&0xFFFFFFFC; + pixels &= 0x3; + + while(middle) + { + // Read four pixels + register TUint16 p1 = (*(src + (srcX >> KStepPrecision))); + srcX += srcXIncrement; + register TUint16 p2 = (*(src + (srcX >> KStepPrecision))); + srcX += srcXIncrement; + register TUint16 p3 = (*(src + (srcX >> KStepPrecision))); + srcX += srcXIncrement; + register TUint16 p4 = (*(src + (srcX >> KStepPrecision))); + srcX += srcXIncrement; + + // Write four pixels + *(dst++) = p1; + *(dst++) = p2; + *(dst++) = p3; + *(dst++) = p4; + + middle-=4; + } + + // Unaligned residual pixels to the right of 8-aligned section + while(pixels) + { + *dst++ = (*(src + (srcX >> KStepPrecision))); + + srcX += srcXIncrement; + + pixels--; + } + + // Move to next correct src scanline + srcY += srcYIncrement; + + // Advance dst to start of correct pixel in the next row + dst += iDstResidualPixels; + } + + iDstBitmap->UnlockHeap(); + iSrcBitmap->UnlockHeap(); + + if(iScanlinesLeft) + { + // Not all scanlines were processed yet + + // Save the necessary offsets for next round + iSrcPos.iY = srcY; + iDstStartOffset = dst - dstBitmapPtr; + + return ETrue; + } + + return EFalse; + + } + +// ----------------------------------------------------------------------------- +// CIHLScaler::ProcessNearestNeighbour16MX +// Description: Scales & rotates 16MU/MA color bitmaps +// ----------------------------------------------------------------------------- +TBool CIHLScaler::ProcessNearestNeighbour16MX() + { + // Lock bitmap heaps + iSrcBitmap->LockHeap(); + iDstBitmap->LockHeap(); + + // Pointers to start of bitmap data + TUint32 *srcBitmapPtr = (TUint32*)iSrcBitmap->DataAddress(); + TUint32 *dstBitmapPtr = (TUint32*)iDstBitmap->DataAddress(); + + // Get pointer to correct destination pixel (offset is updated after every round) + register TUint32* dst = dstBitmapPtr + iDstStartOffset; + + TUint32 width = iProcessSize.iWidth; + + // Check how many scanlines we can process this round + register TUint32 scanlinesLeft = iScanlinesLeft; + if(scanlinesLeft>iScanlinesPerRound) + { + scanlinesLeft = iScanlinesPerRound; + } + + // How many scanlines left for the next round + iScanlinesLeft-=scanlinesLeft; + + // Faster access to variables (it's slow to use member variables) + register TInt srcPosX(iSrcPos.iX); + register TInt srcPosY(iSrcPos.iY); + register TInt srcPitch = iSrcPitchInPixels; + + TInt incOuterSrcX = (-iSrcIncrementInner.iX * width) + iSrcIncrementOuter.iX; + TInt incOuterSrcY = (-iSrcIncrementInner.iY * width) + iSrcIncrementOuter.iY; + + while(scanlinesLeft!=0) + { + for(register TUint32 x = width; x!=0; x--) + { + register TUint32* src = srcBitmapPtr + ((srcPosY >> KStepPrecision) * srcPitch) + (srcPosX>>KStepPrecision); + *dst = *src; + + // Add inner counters + srcPosX+=iSrcIncrementInner.iX; + srcPosY+=iSrcIncrementInner.iY; + + dst+=iDstIncrementInner; + } + + // Reset inner counters and add outer counters + srcPosX += incOuterSrcX; + srcPosY += incOuterSrcY; + + // Move destination pointer to next pixel + dst += iDstResidualPixels; + + // One scanline done, n to go + scanlinesLeft--; + } + // Unlock bitmap heaps + iDstBitmap->UnlockHeap(); + iSrcBitmap->UnlockHeap(); + + if(iScanlinesLeft) + { + // Not all scanlines were processed yet + + // Save the necessary offsets for next round + iSrcPos.iX = srcPosX; + iSrcPos.iY = srcPosY; + iDstStartOffset = dst - dstBitmapPtr; + + return ETrue; + } + + // Processing done + return EFalse; + } + +// ----------------------------------------------------------------------------- +// CIHLScaler::ProcessNearestNeighbour64KScaleOnly +// ----------------------------------------------------------------------------- +TBool CIHLScaler::ProcessNearestNeighbour16MXScaleOnly() + { + // Lock bitmap heaps + iSrcBitmap->LockHeap(); + iDstBitmap->LockHeap(); + + // Get bitmap data start addresses + TUint32 *srcBitmapPtr = (TUint32*)iSrcBitmap->DataAddress(); + TUint32 *dstBitmapPtr = (TUint32*)iDstBitmap->DataAddress(); + + // Target height and width + TInt width = iProcessSize.iWidth; + + // fixed point source coordinates + TInt startX = iSrcPos.iX; + TInt srcY = iSrcPos.iY; + + // How much to increase src position (in fixed point) + TInt srcYIncrement = iSrcIncrementOuter.iY; + register TInt srcXIncrement = iSrcIncrementInner.iX; + + // Set pointers to correct location (src = start of scanline, dst = start pixel) + register TUint32* dst = dstBitmapPtr + iDstStartOffset; + + // Calculate how many scanlines we can process this round + register TInt scanlinesLeft = iScanlinesLeft; + if(scanlinesLeft>iScanlinesPerRound) + { + scanlinesLeft = iScanlinesPerRound; + } + + iScanlinesLeft-=scanlinesLeft; + + while(scanlinesLeft--) + { + // Outer loop + + // Reset src X and scanline pointer + register TInt srcX = startX; + register TUint32* src = srcBitmapPtr + (srcY >> KStepPrecision) * iSrcPitchInPixels; + + // Init pixel counter + register TUint32 pixels = width; + + // Unaligned pixels to the left of 16B-aligned section + while((TUint32(dst)&0xF) && pixels) + { + *dst++ = (*(src + (srcX >> KStepPrecision))); + + srcX += srcXIncrement; + + pixels--; + } + + // Aligned middle section + register TUint32 middle = pixels&0xFFFFFFFC; + pixels &= 0x3; + + while(middle) + { + // Read four pixels + register TUint32 p1 = (*(src + (srcX >> KStepPrecision))); + srcX += srcXIncrement; + register TUint32 p2 = (*(src + (srcX >> KStepPrecision))); + srcX += srcXIncrement; + register TUint32 p3 = (*(src + (srcX >> KStepPrecision))); + srcX += srcXIncrement; + register TUint32 p4 = (*(src + (srcX >> KStepPrecision))); + srcX += srcXIncrement; + + // Write four pixels + *(dst+0) = p1; + *(dst+1) = p2; + *(dst+2) = p3; + *(dst+3) = p4; + + middle-=4; + dst+=4; + } + + // Unaligned residual pixels to the right of 8-aligned section + while(pixels) + { + *dst++ = (*(src + (srcX >> KStepPrecision))); + + srcX += srcXIncrement; + + pixels--; + } + + // Move to next correct src scanline + srcY += srcYIncrement; + + // Advance dst to start of correct pixel in the next row + dst += iDstResidualPixels; + } + + iDstBitmap->UnlockHeap(); + iSrcBitmap->UnlockHeap(); + + if(iScanlinesLeft) + { + // Not all scanlines were processed yet + + // Save the necessary offsets for next round + iSrcPos.iY = srcY; + iDstStartOffset = dst - dstBitmapPtr; + + return ETrue; + } + + return EFalse; + + } + +// Restore previous pragma state +#ifdef __ARMCC__ +#pragma pop +#endif + +// ----------------------------------------------------------------------------- +// CIHLScaler::ProcessNearestNeighbour +// ----------------------------------------------------------------------------- +TBool CIHLScaler::ProcessNearestNeighbour() + { + // Util needs non-const pointers even if it's only used for reading pixels + TBitmapUtil srcBitmap( const_cast( iSrcBitmap ) ); + TBitmapUtil dstBitmap( iDstBitmap ); + srcBitmap.Begin( TPoint( iSrcPos.iX >> KStepPrecision, iSrcPos.iY >> KStepPrecision ) ); + dstBitmap.Begin( iDstPos ); // heap already locked by srcBitmap + TInt pixelCounter( KProcessPixelsPerStep ); + + // Start outer and inner process loops + while( iProcessOuter < iProcessSize.iHeight && pixelCounter ) + { + while( iProcessInner < iProcessSize.iWidth && pixelCounter ) + { + srcBitmap.SetPos( TPoint( iSrcPos.iX >> KStepPrecision, iSrcPos.iY >> KStepPrecision ) ); + dstBitmap.SetPos( iDstPos ); + dstBitmap.SetPixel( srcBitmap ); + + // Add inner counters + iSrcPos += iSrcIncrementInner; + iDstPos.iX += iDstIncrementInner; + ++iProcessInner; + --pixelCounter; + } + // Check if inner loop is finished (not just pixel counter) + if( iProcessInner == iProcessSize.iWidth ) + { + // Reset inner counters + iSrcPos.iX -= iSrcIncrementInner.iX * iProcessInner; + iSrcPos.iY -= iSrcIncrementInner.iY * iProcessInner; + + iDstPos.iX -= iDstIncrementInner * iProcessInner; + iProcessInner = 0; + + // Add outer counters + iSrcPos += iSrcIncrementOuter; + iDstPos.iY += iDstIncrementOuter; + ++iProcessOuter; + } + } + + // Release heap lock + dstBitmap.End(); + srcBitmap.End(); + + // ETrue if more processing is still needed + return ( iProcessOuter < iProcessSize.iHeight ); + } + +// ----------------------------------------------------------------------------- +// CIHLScaler::ProcessBilinear +// ----------------------------------------------------------------------------- +TBool CIHLScaler::ProcessBilinear() + { + // Util needs non-const pointers + //even if it's only used for reading pixels + TBitmapUtil srcBitmap( const_cast( iSrcBitmap ) ); + TBitmapUtil dstBitmap( iDstBitmap ); + + srcBitmap.Begin( TPoint( iSrcPos.iX >> KStepPrecision, iSrcPos.iY >> KStepPrecision ) ); + dstBitmap.Begin( iDstPos ); // heap already locked by srcBitmap + TInt pixelCounter( KProcessPixelsPerStep ); + + TInt incSrcX = iSrcIncrementInner.iX + iSrcIncrementOuter.iX; + TInt incSrcY = iSrcIncrementInner.iY + iSrcIncrementOuter.iY; + + TPixelData pixelData; + TUint32 color; + + TInt32 pixel_width = 1 << KStepPrecision; + + //if there is no scaling then process through loop using NearestNeighbour alghoritm + if ( incSrcX == pixel_width || -incSrcX == pixel_width ) + { + while( iProcessOuter < iProcessSize.iHeight && pixelCounter ) + { + while( iProcessInner < iProcessSize.iWidth && pixelCounter ) + { + srcBitmap.SetPos( TPoint( iSrcPos.iX >> KStepPrecision, iSrcPos.iY >> KStepPrecision ) ); + dstBitmap.SetPos( iDstPos ); + dstBitmap.SetPixel( srcBitmap ); + + // Add inner counters + iSrcPos += iSrcIncrementInner; + iDstPos.iX += iDstIncrementInner; + ++iProcessInner; + --pixelCounter; + } + + // Check if inner loop is finished (not just pixel counter) + if( iProcessInner == iProcessSize.iWidth ) + { + // Reset inner counters + iSrcPos.iX -= iSrcIncrementInner.iX * iProcessInner; + iSrcPos.iY -= iSrcIncrementInner.iY * iProcessInner; + + iDstPos.iX -= iDstIncrementInner * iProcessInner; + iProcessInner = 0; + + // Add outer counters + iSrcPos += iSrcIncrementOuter; + iDstPos.iY += iDstIncrementOuter; + ++iProcessOuter; + } + } + } + // Process using bilinear method according to + // orientation between source and destination bitmap + // + // There are 4 possibilities of orientation and can be + // determined by this if we're increasing or decreasing + // position on source bitmap. + else if ( ( incSrcY >= 0) && (incSrcX >= 0 ) ) + { + while( iProcessOuter < iProcessSize.iHeight && pixelCounter ) + { + while( iProcessInner < iProcessSize.iWidth && pixelCounter ) + { + srcBitmap.SetPos( TPoint( iSrcPos.iX >> KStepPrecision, iSrcPos.iY >> KStepPrecision ) ); + dstBitmap.SetPos( iDstPos ); + + // gather pixel data with step: + // 00 > 10 + // V + // 01 < 11 + IntToRgb(srcBitmap.GetPixel(),pixelData.colXY00); + srcBitmap.IncXPos(); + IntToRgb(srcBitmap.GetPixel(),pixelData.colXY10); + srcBitmap.IncYPos(); + IntToRgb(srcBitmap.GetPixel(),pixelData.colXY11); + srcBitmap.DecXPos(); + IntToRgb(srcBitmap.GetPixel(),pixelData.colXY01); + //return to starting position + srcBitmap.DecYPos(); + + // interpolate color using gathered pixel-data + ProcessColorData(pixelData, iSrcPos); + + // put color in destination package + color = RgbToInt(pixelData.col); + dstBitmap.SetPixel(color); + + // Add inner counters + iSrcPos += iSrcIncrementInner; + iDstPos.iX += iDstIncrementInner; + ++iProcessInner; + --pixelCounter; + } + + // Check if inner loop is finished (not just pixel counter) + if( iProcessInner == iProcessSize.iWidth ) + { + // Reset inner counters + iSrcPos.iX -= iSrcIncrementInner.iX * iProcessInner; + iSrcPos.iY -= iSrcIncrementInner.iY * iProcessInner; + + iDstPos.iX -= iDstIncrementInner * iProcessInner; + iProcessInner = 0; + + // Add outer counters + iSrcPos += iSrcIncrementOuter; + iDstPos.iY += iDstIncrementOuter; + ++iProcessOuter; + } + } + } + else if ( ( incSrcY >= 0) && (incSrcX < 0 ) ) + { + while( iProcessOuter < iProcessSize.iHeight && pixelCounter ) + { + while( iProcessInner < iProcessSize.iWidth && pixelCounter ) + { + srcBitmap.SetPos( TPoint( iSrcPos.iX >> KStepPrecision, iSrcPos.iY >> KStepPrecision ) ); + dstBitmap.SetPos( iDstPos ); + + // gather pixel data with step: + // 00 10 + // /\ V + // 01 < 11 + IntToRgb(srcBitmap.GetPixel(),pixelData.colXY10); + srcBitmap.IncYPos(); + IntToRgb(srcBitmap.GetPixel(),pixelData.colXY11); + srcBitmap.DecXPos(); + IntToRgb(srcBitmap.GetPixel(),pixelData.colXY01); + srcBitmap.DecYPos(); + IntToRgb(srcBitmap.GetPixel(),pixelData.colXY00); + //return to starting position + srcBitmap.IncXPos(); + + // interpolate color using gathered pixel-data + ProcessColorData(pixelData, iSrcPos); + + // put color in destination package + color = RgbToInt(pixelData.col); + dstBitmap.SetPixel(color); + + // Add inner counters + iSrcPos += iSrcIncrementInner; + iDstPos.iX += iDstIncrementInner; + ++iProcessInner; + --pixelCounter; + } + + // Check if inner loop is finished (not just pixel counter) + if( iProcessInner == iProcessSize.iWidth ) + { + // Reset inner counters + iSrcPos.iX -= iSrcIncrementInner.iX * iProcessInner; + iSrcPos.iY -= iSrcIncrementInner.iY * iProcessInner; + + iDstPos.iX -= iDstIncrementInner * iProcessInner; + iProcessInner = 0; + + // Add outer counters + iSrcPos += iSrcIncrementOuter; + iDstPos.iY += iDstIncrementOuter; + ++iProcessOuter; + } + + } + } + else if ( ( incSrcY < 0) && (incSrcX >= 0 ) ) + { + while( iProcessOuter < iProcessSize.iHeight && pixelCounter ) + { + while( iProcessInner < iProcessSize.iWidth && pixelCounter ) + { + srcBitmap.SetPos( TPoint( iSrcPos.iX >> KStepPrecision, iSrcPos.iY >> KStepPrecision ) ); + dstBitmap.SetPos( iDstPos ); + + // gather pixel data with step: + // 00 > 10 + // /\ V + // 01 11 + IntToRgb(srcBitmap.GetPixel(),pixelData.colXY01); + srcBitmap.DecYPos(); + IntToRgb(srcBitmap.GetPixel(),pixelData.colXY00); + srcBitmap.IncXPos(); + IntToRgb(srcBitmap.GetPixel(),pixelData.colXY10); + srcBitmap.IncYPos(); + IntToRgb(srcBitmap.GetPixel(),pixelData.colXY11); + //return to starting position + srcBitmap.DecXPos(); + + // interpolate color using gathered pixel-data + ProcessColorData(pixelData, iSrcPos); + + // put color in destination package + color = RgbToInt(pixelData.col); + dstBitmap.SetPixel(color); + + // Add inner counters + iSrcPos += iSrcIncrementInner; + iDstPos.iX += iDstIncrementInner; + ++iProcessInner; + --pixelCounter; + } + + // Check if inner loop is finished (not just pixel counter) + if( iProcessInner == iProcessSize.iWidth ) + { + // Reset inner counters + iSrcPos.iX -= iSrcIncrementInner.iX * iProcessInner; + iSrcPos.iY -= iSrcIncrementInner.iY * iProcessInner; + + iDstPos.iX -= iDstIncrementInner * iProcessInner; + iProcessInner = 0; + + // Add outer counters + iSrcPos += iSrcIncrementOuter; + iDstPos.iY += iDstIncrementOuter; + ++iProcessOuter; + } + } + } + else + { + while( iProcessOuter < iProcessSize.iHeight && pixelCounter ) + { + while( iProcessInner < iProcessSize.iWidth && pixelCounter ) + { + srcBitmap.SetPos( TPoint( iSrcPos.iX >> KStepPrecision, iSrcPos.iY >> KStepPrecision ) ); + dstBitmap.SetPos( iDstPos ); + + // gather pixel data with step: + // 00 > 10 + // /\ + // 01 < 11 + IntToRgb(srcBitmap.GetPixel(),pixelData.colXY11); + srcBitmap.DecXPos(); + IntToRgb(srcBitmap.GetPixel(),pixelData.colXY01); + srcBitmap.DecYPos(); + IntToRgb(srcBitmap.GetPixel(),pixelData.colXY00); + srcBitmap.IncXPos(); + IntToRgb(srcBitmap.GetPixel(),pixelData.colXY10); + //return to starting position + srcBitmap.IncYPos(); + + // interpolate color using gathered pixel-data + ProcessColorData(pixelData, iSrcPos); + + // put color in destination package + color = RgbToInt(pixelData.col); + dstBitmap.SetPixel(color); + + // Add inner counters + iSrcPos += iSrcIncrementInner; + iDstPos.iX += iDstIncrementInner; + ++iProcessInner; + --pixelCounter; + } + + // Check if inner loop is finished (not just pixel counter) + if( iProcessInner == iProcessSize.iWidth ) + { + // Reset inner counters + iSrcPos.iX -= iSrcIncrementInner.iX * iProcessInner; + iSrcPos.iY -= iSrcIncrementInner.iY * iProcessInner; + + iDstPos.iX -= iDstIncrementInner * iProcessInner; + iProcessInner = 0; + + // Add outer counters + iSrcPos += iSrcIncrementOuter; + iDstPos.iY += iDstIncrementOuter; + ++iProcessOuter; + } + + } + } + + // Release heap lock + dstBitmap.End(); + srcBitmap.End(); + + // ETrue if more processing is still needed + return ( iProcessOuter < iProcessSize.iHeight ); + } + +// ----------------------------------------------------------------------------- +// CIHLScaler::SelfComplete +// ----------------------------------------------------------------------------- +void CIHLScaler::SelfComplete() + { + SetActive(); + iStatus = KRequestPending; + TRequestStatus* status = &iStatus; + User::RequestComplete( status, KErrNone ); + } + +// ----------------------------------------------------------------------------- +// CIHLScaler::RequestComplete +// ----------------------------------------------------------------------------- +void CIHLScaler::RequestComplete( TInt aReason ) + { + ASSERT( iScalerStatus ); + User::RequestComplete( iScalerStatus, aReason ); + } + +// ----------------------------------------------------------------------------- +// CIHLScaler::InitCodePath +// ----------------------------------------------------------------------------- +void CIHLScaler::InitCodePath(const TSize& aSrcSize, const TDisplayMode &aSrcMode, const TSize& aDstSize, const TDisplayMode &aDstMode, TBool aOnlyScaling) + { + // Choose the correct processing code path + ProcessingFunc = &CIHLScaler::ProcessNearestNeighbour; + + if( iOptions & MIHLImageViewer::EOptionUseBilinearInterpolation ) + { + // TODO: optimize bilinear scaling + IHL_DEBUG("CIHLScaler::InitCodePath: slow bilinear"); + ProcessingFunc = CIHLScaler::ProcessBilinear; + iScanlinesPerRound = KProcessPixelsPerStep / iProcessSize.iWidth; + } + else if(aSrcMode == EColor64K && aSrcMode==aDstMode && !iSrcBitmap->IsCompressedInRAM() && !iDstBitmap->IsCompressedInRAM()) + { + // 16 bit non-compressed bitmaps + + // Calculate how many pixels the scanline is actually wide in the memory + iSrcPitchInPixels = CFbsBitmap::ScanLineLength( aSrcSize.iWidth, aSrcMode ) >> 1; + iDstPitchInPixels = CFbsBitmap::ScanLineLength( aDstSize.iWidth, aDstMode ) >> 1; + + // How many pixels to move destination pointer at the end of each scanline to get to next pixel + iDstResidualPixels = iDstIncrementOuter*iDstPitchInPixels - iDstIncrementInner*iProcessSize.iWidth; + + // Buffer offset to the first destination pixel + iDstStartOffset = iDstPos.iY * iDstPitchInPixels + iDstPos.iX; + + if(!aOnlyScaling) + { + IHL_DEBUG("CIHLScaler::InitCodePath: fast 64K scale&rotate"); + ProcessingFunc = &CIHLScaler::ProcessNearestNeighbour64K; + + // Calculate how often the process should allow AS to run + iScanlinesPerRound = KBytesPerStepFastPath / (iProcessSize.iWidth<<1); + } + else + { + IHL_DEBUG("CIHLScaler::InitCodePath: fast 64K scale only"); + ProcessingFunc = &CIHLScaler::ProcessNearestNeighbour64KScaleOnly; + + // Calculate how often the process should allow AS to run + iScanlinesPerRound = KBytesPerStepFastPathScaleOnly / (iProcessSize.iWidth<<1); + } + } + + else if((aSrcMode == EColor16MU || aSrcMode == EColor16MA) && aSrcMode==aDstMode && !iSrcBitmap->IsCompressedInRAM() && !iDstBitmap->IsCompressedInRAM()) + { + // 32 bit non-compressed bitmaps + + // Calculate how many pixels the scanline is actually wide in the memory + iSrcPitchInPixels = CFbsBitmap::ScanLineLength( aSrcSize.iWidth, aSrcMode ) >> 2; + iDstPitchInPixels = CFbsBitmap::ScanLineLength( aDstSize.iWidth, aDstMode ) >> 2; + + // How many pixels to move destination pointer at the end of each scanline to get to next pixel + iDstResidualPixels = iDstIncrementOuter*iDstPitchInPixels - iDstIncrementInner*iProcessSize.iWidth; + + // Buffer offset to the first destination pixel + iDstStartOffset = iDstPos.iY * iDstPitchInPixels + iDstPos.iX; + + if(!aOnlyScaling) + { + IHL_DEBUG("CIHLScaler::InitCodePath: fast 16MX scale&rotate"); + ProcessingFunc = &CIHLScaler::ProcessNearestNeighbour16MX; + + // Calculate how often the process should allow AS to run + iScanlinesPerRound = KBytesPerStepFastPath / (iProcessSize.iWidth<<2); + } + else + { + IHL_DEBUG("CIHLScaler::InitCodePath: fast 16MX scale only"); + ProcessingFunc = &CIHLScaler::ProcessNearestNeighbour16MXScaleOnly; + + // Calculate how often the process should allow AS to run + iScanlinesPerRound = KBytesPerStepFastPathScaleOnly / (iProcessSize.iWidth<<2); + } + } + else + { + IHL_DEBUG("CIHLScaler::InitCodePath: slow nearest neighbor"); + iScanlinesPerRound = KProcessPixelsPerStep / iProcessSize.iWidth; + } + + IHL_DEBUG2(KIHLDebug, "CIHLScaler::InitCodePath: scanlines per round = %d", iScanlinesPerRound); + } + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandlinglib/Src/CIHLScaler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlinglib/Src/CIHLScaler.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,204 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of bitmap scaler class +* : using Font and Bitmap Server bitmaps. +* +*/ + +#ifndef CIHLSCALER_H +#define CIHLSCALER_H + +// INCLUDES +#include +#include +#include + +// Define this to show throughput measurements +//#define RD_MEASURE_THROUGHPUT + +// FORWARD DECLARATIONS +class CFbsBitmap; + +// CLASS DECLARATION +/** +* CIHLScaler +* +* Implementation of Scaling processor +* using Font and Bitmap Server bitmaps. +* @lib IHL.lib +* @since 3.0 +*/ +NONSHARABLE_CLASS( CIHLScaler ) : public CActive, public MIHLScaler + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CIHLScaler* NewL( const TUint32 aOptions = 0 ); + + /* + * Virtual destructor. + */ + virtual ~CIHLScaler(); + + public: // From base class MIHLScaler + + /* + * From MIHLScaler, see base class header. + */ + TInt Scale( TRequestStatus& aStatus, + const CFbsBitmap& aSrcBitmap, + const TRect& aSrcRect, + CFbsBitmap& aDstBitmap, + const TRect& aDstRect ); + + /* + * From MIHLScaler, see base class header. + */ + TBool IsBusy() const; + + /* + * From MIHLScaler, see base class header. + */ + void CancelProcess(); + + /* + * From MIHLScaler, see base class header. + */ + void SetFilter( MIHFilter* aFilter ); + + private: // From base class CActive + + /* + * From CActive, see base class header. + */ + void DoCancel(); + + /* + * From CActive, see base class header. + */ + void RunL(); + + /* + * From CActive, see base class header. + */ + TInt RunError( TInt aError ); + + public: // Internal interface + + /** + * Check if rectangle is inside size. + * @since 3.0 + * @return ETrue if rectangle is fully inside given area, EFalse if not. + */ + TBool IsValidRect( const TSize& aSize, const TRect& aRect ); + + private: // Private methods + + /* + * Initialize process parameters and stepper values. + * @return ETrue if only doing scaling (and not rotating) + */ + TBool InitStepperValues(); + + /* + * Select and initialize fastest possible code path + */ + + void InitCodePath(const TSize& aSrcSize, const TDisplayMode &aSrcMode, const TSize& aDstSize, const TDisplayMode &aDstMode, TBool aOnlyScaling); + + /* + * Process step using nearest neighbour method. + */ + TBool ProcessNearestNeighbour(); + TBool ProcessNearestNeighbour64K(); // For 16-bit non-compressed bitmaps + TBool ProcessNearestNeighbour64KScaleOnly(); // For 16-bit non-compressed bitmaps (only scaling) + TBool ProcessNearestNeighbour16MX(); // For 32-bit non-compressed bitmaps + TBool ProcessNearestNeighbour16MXScaleOnly(); // For 32-bit non-compressed bitmaps (only scaling) + + /* + * Process step using bilinear interpolation method. + */ + TBool ProcessBilinear(); + + /* + * Complete dummy request. This causes RunL() method to be called. + * Needed by state machine. + */ + void SelfComplete(); + + /* + * Complete client process request. + * This causes client RunL() method to be called. + */ + void RequestComplete( TInt aReason ); + + private: // Private constructors + + CIHLScaler( const TUint32 aOptions ); + + private: // Data + + // Ref: Process status + TRequestStatus* iScalerStatus; + TBool iNeedProcess; + + // Process options + const TUint32 iOptions; + + // Ref: Source bitmap + const CFbsBitmap* iSrcBitmap; + TRect iSrcRect; + + // Ref: Destination bitmaps + CFbsBitmap* iDstBitmap; + TRect iDstRect; + + // Process position and stepping + TPoint iSrcIncrementInner; + TPoint iSrcIncrementOuter; + TPoint iSrcPos; + + TInt iDstIncrementInner; + TInt iDstIncrementOuter; + TPoint iDstPos; + + TInt iProcessInner; + TInt iProcessOuter; + TSize iProcessSize; + + // For fast code path + TInt iSrcPitchInPixels; + TInt iDstPitchInPixels; + TUint32 iScanlinesLeft; + TUint32 iScanlinesPerRound; + TInt iDstStartOffset; + TInt iDstResidualPixels; + + // Only for measuring scaler throughput +#ifdef RD_MEASURE_THROUGHPUT + TUint32 iStartTime; +#endif + + /* + * Forward process step event to selected processing code path + * Called by RunL() method. + */ + TBool (CIHLScaler::*ProcessingFunc)(); + }; + +#endif // CIHLSCALER_H + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandlinglib/Src/IHLBitmapUtil.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlinglib/Src/IHLBitmapUtil.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,163 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Static utility class for synchronous CFbsBitmap operations. +* +*/ + + +// INCLUDE FILES +#include +#include + +// ============================ STATIC FUNCTIONS =============================== +// ----------------------------------------------------------------------------- +// IHLBitmapUtil::DuplicateBitmapL +// ----------------------------------------------------------------------------- +EXPORT_C CFbsBitmap* IHLBitmapUtil::DuplicateBitmapL( const CFbsBitmap& aBitmap ) + { + CFbsBitmap* bitmap = DuplicateBitmapLC( aBitmap ); + CleanupStack::Pop(); // bitmap + return bitmap; + } + +// ----------------------------------------------------------------------------- +// IHLBitmapUtil::DuplicateBitmapLC +// ----------------------------------------------------------------------------- +EXPORT_C CFbsBitmap* IHLBitmapUtil::DuplicateBitmapLC( const CFbsBitmap& aBitmap ) + { + CFbsBitmap* bitmap = new(ELeave) CFbsBitmap; + CleanupStack::PushL( bitmap ); + User::LeaveIfError( bitmap->Duplicate( aBitmap.Handle() ) ); + return bitmap; + } + +// ----------------------------------------------------------------------------- +// IHLBitmapUtil::CopyBitmapL +// ----------------------------------------------------------------------------- +EXPORT_C CFbsBitmap* IHLBitmapUtil::CopyBitmapL( const CFbsBitmap& aBitmap ) + { + CFbsBitmap* bitmap = CopyBitmapLC( aBitmap ); + CleanupStack::Pop(); // bitmap + return bitmap; + } + +// ----------------------------------------------------------------------------- +// IHLBitmapUtil::CopyBitmapLC +// ----------------------------------------------------------------------------- +EXPORT_C CFbsBitmap* IHLBitmapUtil::CopyBitmapLC( const CFbsBitmap& aBitmap ) + { + CFbsBitmap* bitmap = new (ELeave) CFbsBitmap(); + CleanupStack::PushL( bitmap ); + if( !aBitmap.Handle() ) + { + return bitmap; + } + + TSize size( aBitmap.SizeInPixels() ); + TDisplayMode displayMode( aBitmap.DisplayMode() ); + + User::LeaveIfError( bitmap->Create( size, displayMode ) ); + + HBufC8* scanLine = HBufC8::NewLC( + aBitmap.ScanLineLength( size.iWidth, displayMode ) ); + TPtr8 scanPtr( scanLine->Des() ); + + TPoint pp; + for ( TInt y( 0 ); y < size.iHeight; ++y ) + { + pp.iY = y; + aBitmap.GetScanLine( scanPtr, pp, size.iWidth, displayMode ); + bitmap->SetScanLine( scanPtr, y ); + } + + CleanupStack::PopAndDestroy(); // scanLine + + return bitmap; + } + +// ----------------------------------------------------------------------------- +// IHLBitmapUtil::CopyBitmapL +// ----------------------------------------------------------------------------- +EXPORT_C CFbsBitmap* IHLBitmapUtil::CopyBitmapL( const CFbsBitmap& aBitmap, const TRect& aRect ) + { + CFbsBitmap* bitmap = CopyBitmapLC( aBitmap, aRect ); + CleanupStack::Pop(); // bitmap + return bitmap; + } + +// ----------------------------------------------------------------------------- +// IHLBitmapUtil::CopyBitmapLC +// ----------------------------------------------------------------------------- +EXPORT_C CFbsBitmap* IHLBitmapUtil::CopyBitmapLC( const CFbsBitmap& aBitmap, const TRect& aRect ) + { + CFbsBitmap* bitmap = new (ELeave) CFbsBitmap(); + CleanupStack::PushL( bitmap ); + if( !aBitmap.Handle() ) + { + return bitmap; + } + + TSize clipSize( aRect.Size() ); + TSize sourceSize( aBitmap.SizeInPixels() ); + if( aRect.iTl.iX == aRect.iBr.iX || + aRect.iTl.iY == aRect.iBr.iY || + aRect.iTl.iX < 0 || + aRect.iTl.iX > sourceSize.iWidth || + aRect.iTl.iY < 0 || + aRect.iTl.iY > sourceSize.iHeight ) + { + User::Leave( KErrArgument ); + } + + TDisplayMode dispMode( aBitmap.DisplayMode() ); + User::LeaveIfError( bitmap->Create( clipSize, dispMode ) ); + + HBufC8* scanLine = HBufC8::NewLC( + aBitmap.ScanLineLength( clipSize.iWidth, dispMode ) ); + TPtr8 scanPtr( scanLine->Des() ); + + TPoint pp( aRect.iTl ); + for ( TInt y( 0 ); y < clipSize.iHeight; ++y, ++pp.iY ) + { + aBitmap.GetScanLine( scanPtr, pp, clipSize.iWidth, dispMode ); + bitmap->SetScanLine( scanPtr, y ); + } + + CleanupStack::PopAndDestroy(); // scanLine + return bitmap; + } + +// ----------------------------------------------------------------------------- +// IHLBitmapUtil::ScaleBitmap +// ----------------------------------------------------------------------------- +EXPORT_C TInt IHLBitmapUtil::ScaleBitmap( const CFbsBitmap& /*aSrcBitmap*/, + CFbsBitmap& /*aDstBitmap*/, + TUint32 /*aOptions*/ ) + { + return KErrNotSupported; + } + +// ----------------------------------------------------------------------------- +// IHLBitmapUtil::ScaleBitmap +// ----------------------------------------------------------------------------- +EXPORT_C TInt IHLBitmapUtil::ScaleBitmap( const CFbsBitmap& /*aSrcBitmap*/, + const TRect& /*aSrcRect*/, + CFbsBitmap& /*aDstBitmap*/, + const TRect& /*aDstRect*/, + TUint32 /*aOptions*/ ) + { + return KErrNotSupported; + } + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandlinglib/Src/IHLDebugPrint.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlinglib/Src/IHLDebugPrint.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,150 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: IHL debug macros +* +*/ + + +#ifndef IHLDEBUGPRINT_H +#define IHLDEBUGPRINT_H + +// Debug logging is enabled, you may enable debug printing in release builds also +#ifdef IHL_ENABLE_DEBUG_PRINT + + // warn if this is a release build!! + #ifndef __WINSCW__ + #ifndef _DEBUG + #if defined(__VC32__) + #pragma message( "Warning: IHL debug printing is on in release build!" ) // CSI: 68 # + #else // __GCC32__ + #warning "IHL debug printing is on in release build!" + #endif // __VC32__ + #endif + #endif // __WINSCW__ + +// no include files if no debug printing --> faster compile time +// INCLUDES +#include +#include + + /** + * Helper macro for defining debug strings with just the debug text. + */ + #define IHL_DEBUG_STRING(name,s) _LIT(name,s) + + /** + * Output to debugger output + */ + #define IHL_DEBUG_PRINT RDebug::Print + +#else // IHL_ENABLE_DEBUG_PRINT + + /** + * Dummy struct for checking that all IHL_DEBUG_PRINT's define string + * literals using space-saving IHL_DEBUG_STRING. + */ + struct TIHLEmptyDebugString { }; // CSI: 80 # + + /** + * Macro for defining debug-only literal strings (empty release version) + */ + #define IHL_DEBUG_STRING(name, s) const TIHLEmptyDebugString name + + /** + * Output to debugger output (empty) + */ + #define IHL_DEBUG_PRINT IHL_EmptyPrint + + namespace { + + /// Empty debug print function for release builds. + inline void IHL_EmptyPrint(TIHLEmptyDebugString) + { + } + + /// Empty debug print function for release builds. + template + inline void IHL_EmptyPrint(TIHLEmptyDebugString,T1) + { + } + + /// Empty debug print function for release builds. + template + inline void IHL_EmptyPrint(TIHLEmptyDebugString,T1,T2) + { + } + + /// Empty debug print function for release builds. + template + inline void IHL_EmptyPrint(TIHLEmptyDebugString,T1,T2,T3) + { + } + + /// Empty debug print function for release builds. + template + inline void IHL_EmptyPrint(TIHLEmptyDebugString,T1,T2,T3,T4) + { + } + + /// Empty debug print function for release builds. + template + inline void IHL_EmptyPrint(TIHLEmptyDebugString,T1,T2,T3,T4,T5) + { + } + + /// Empty debug print function for release builds. + template + inline void IHL_EmptyPrint(TIHLEmptyDebugString,T1,T2,T3,T4,T5,T6) + { + } + + /// Empty debug print function for release builds. + template + inline void IHL_EmptyPrint(TIHLEmptyDebugString,T1,T2,T3,T4,T5,T6,T7) + { + } + + /// Empty debug print function for release builds. + template + inline void IHL_EmptyPrint(TIHLEmptyDebugString,T1,T2,T3,T4,T5,T6,T7,T8) + { + } + + } // unnamed namespace + + +#endif // IHL_ENABLE_DEBUG_PRINT + +/** + * Short variant for easier basic usage. + */ +#define IHL_DEBUG1( name, s ) IHL_DEBUG_STRING( name, s ); IHL_DEBUG_PRINT( name ); + +#ifdef IHL_ENABLE_DEBUG_PRINT +#define IHL_DEBUG( s ) RDebug::Print( _L( s ) ) +#define IHL_DEBUG2( name, s, i ) IHL_DEBUG_STRING( name, s ); IHL_DEBUG_PRINT( name, i ); +#define IHL_DEBUG3( name, s, i, j ) IHL_DEBUG_STRING( name, s ); IHL_DEBUG_PRINT( name, i, j ); +#define IHL_DEBUG4( name, s, i, j, k ) IHL_DEBUG_STRING( name, s ); IHL_DEBUG_PRINT( name, i, j, k ); +#define IHL_DEBUG5( name, s, i, j, k, l ) IHL_DEBUG_STRING( name, s ); IHL_DEBUG_PRINT( name, i, j, k, l ); +#else +// If debug printing is not enabled, strip other parameters than the string +// away to prevent unwanted function calls in release build. +#define IHL_DEBUG( s ) +#define IHL_DEBUG2( name, s, i ) IHL_DEBUG1( name, s ) +#define IHL_DEBUG3( name, s, i, j ) IHL_DEBUG1( name, s ) +#define IHL_DEBUG4( name, s, i, j, k ) IHL_DEBUG1( name, s ) +#define IHL_DEBUG5( name, s, i, j, k, l ) IHL_DEBUG1( name, s ) +#endif + +#endif // __IHLDEBUGPRINT_H__ diff -r 000000000000 -r 2014ca87e772 imagehandlinglib/Src/IHLImageFactory.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlinglib/Src/IHLImageFactory.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,249 @@ +/* +* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Static factory class for creating file instances. +* +*/ + + +// INCLUDE FILES +#include + +#include "CIHLFileImage.h" +#include "CIHLFileImageExtJpg.h" +#include + +// Private namespace for constants and functions +namespace + { + // First image index + const TInt KIHLFirstImage = 0; + const TInt KIHLNullOptions = 0; + + const TInt KMimeTypeStringLength = 255; + _LIT( KJpgType, "image/jpeg" ); + + + // Helper functions + // ----------------------------------------------------------------------------- + // OpenExtendedFileImageL + // ----------------------------------------------------------------------------- + // + CIHLFileImageExtJpg* OpenExtendedFileImageL( RFs& aFs, const TDesC& aFilename, + TInt aImageIndex, const TUint32 aOptions ) + { + CIHLFileImageExtJpg* fileImageExtJpg = NULL; + TRAPD( err, fileImageExtJpg = CIHLFileImageExtJpg::NewL( aFs, aFilename, + aImageIndex, aOptions ) ); + if( !err ) + { + // Hw or Sw extended decoder found; check for cropping capability + CleanupStack::PushL( fileImageExtJpg ); + if( !( fileImageExtJpg->CapabilitiesL() & CExtJpegDecoder::ECapCropping ) ) + { + //Decoder does not support cropping, use the old implementation + CleanupStack::PopAndDestroy( fileImageExtJpg ); + fileImageExtJpg = NULL; + } + else + { + CleanupStack::Pop( fileImageExtJpg ); + } + } + + return fileImageExtJpg; + } + + // ----------------------------------------------------------------------------- + // MimeTypeIsJpgL + // ----------------------------------------------------------------------------- + // + TBool MimeTypeIsJpgL( RFile& aFile ) + { + using namespace ContentAccess; + + TBuf mime; + CContent* content = CContent::NewL( aFile ); + CleanupStack::PushL( content ); + CData* data = content->OpenContentL( EPeek ); + CleanupStack::PushL( data ); + User::LeaveIfError( data->GetStringAttribute( EMimeType, mime ) ); + CleanupStack::PopAndDestroy( 2 ); //data, content + if( mime.Compare( KJpgType ) == 0 ) return ETrue; + return EFalse; + } + } + +// ============================ STATIC FUNCTIONS =============================== +// ----------------------------------------------------------------------------- +// IHLImageFactory::OpenFileImageL +// ----------------------------------------------------------------------------- +// +EXPORT_C MIHLFileImage* IHLImageFactory::OpenFileImageL( RFs& aFs, const TDesC& aFilename ) + { + RFile fileHandle; + TInt err( fileHandle.Open( aFs, aFilename, EFileShareReadersOnly ) ); + if( err ) + { + User::LeaveIfError( fileHandle.Open( aFs, aFilename, EFileShareAny ) ); + } + CleanupClosePushL( fileHandle ); + + if ( MimeTypeIsJpgL( fileHandle ) ) + { + CIHLFileImageExtJpg* fileImageExtJpg = OpenExtendedFileImageL( aFs, + aFilename, + KIHLFirstImage, + KIHLNullOptions ); + if ( fileImageExtJpg ) + { + CleanupStack::PopAndDestroy(); // fileHandle.Close() + return fileImageExtJpg; + } + } + + CIHLFileImage* fileImage = CIHLFileImage::NewL( fileHandle, KIHLFirstImage, KIHLNullOptions ); + + CleanupStack::PopAndDestroy(); // fileHandle.Close() + + return fileImage; + } + +// ----------------------------------------------------------------------------- +// IHLImageFactory::OpenFileImageL +// ----------------------------------------------------------------------------- +// +EXPORT_C MIHLFileImage* IHLImageFactory::OpenFileImageL( RFs& aFs, const TDesC& aFilename, + TInt aImageIndex ) + { + RFile fileHandle; + TInt err( fileHandle.Open( aFs, aFilename, EFileShareReadersOnly ) ); + if( err ) + { + User::LeaveIfError( fileHandle.Open( aFs, aFilename, EFileShareAny ) ); + } + CleanupClosePushL( fileHandle ); + + if ( MimeTypeIsJpgL( fileHandle ) ) + { + CIHLFileImageExtJpg* fileImageExtJpg = OpenExtendedFileImageL( aFs, + aFilename, + aImageIndex, + KIHLNullOptions ); + if ( fileImageExtJpg ) + { + CleanupStack::PopAndDestroy(); // fileHandle.Close() + return fileImageExtJpg; + } + } + + CIHLFileImage* fileImage = CIHLFileImage::NewL( fileHandle, aImageIndex, KIHLNullOptions ); + + CleanupStack::PopAndDestroy(); // fileHandle.Close() + + return fileImage; + } + +// ----------------------------------------------------------------------------- +// IHLImageFactory::OpenFileImageL +// ----------------------------------------------------------------------------- +// +EXPORT_C MIHLFileImage* IHLImageFactory::OpenFileImageL( RFs& aFs, const TDesC& aFilename, + TInt aImageIndex, const TUint32 aOptions ) + { + RFile fileHandle; + TInt err( fileHandle.Open( aFs, aFilename, EFileShareReadersOnly ) ); + if( err ) + { + User::LeaveIfError( fileHandle.Open( aFs, aFilename, EFileShareAny ) ); + } + CleanupClosePushL( fileHandle ); + + if ( MimeTypeIsJpgL( fileHandle ) ) + { + CIHLFileImageExtJpg* fileImageExtJpg = OpenExtendedFileImageL( aFs, + aFilename, + aImageIndex, + aOptions ); + if ( fileImageExtJpg ) + { + CleanupStack::PopAndDestroy(); // fileHandle.Close() + return fileImageExtJpg; + } + } + + CIHLFileImage* fileImage = CIHLFileImage::NewL( fileHandle, aImageIndex, aOptions ); + + CleanupStack::PopAndDestroy(); // fileHandle.Close() + + return fileImage; + } + +// ----------------------------------------------------------------------------- +// IHLImageFactory::OpenFileImageL +// ----------------------------------------------------------------------------- +// +EXPORT_C MIHLFileImage* IHLImageFactory::OpenFileImageL( RFile& aFile ) + { + return CIHLFileImage::NewL( aFile, KIHLFirstImage, KIHLNullOptions ); + } + +// ----------------------------------------------------------------------------- +// IHLImageFactory::OpenFileImageL +// ----------------------------------------------------------------------------- +// +EXPORT_C MIHLFileImage* IHLImageFactory::OpenFileImageL( RFile& aFile, TInt aImageIndex ) + { + return CIHLFileImage::NewL( aFile, aImageIndex, KIHLNullOptions ); + } + +// ----------------------------------------------------------------------------- +// IHLImageFactory::OpenFileImageL +// ----------------------------------------------------------------------------- +// +EXPORT_C MIHLFileImage* IHLImageFactory::OpenFileImageL( RFile& aFile, TInt aImageIndex, + const TUint32 aOptions ) + { + return CIHLFileImage::NewL( aFile, aImageIndex, aOptions ); + } + +// ----------------------------------------------------------------------------- +// IHLImageFactory::OpenBufferedFileImageL +// ----------------------------------------------------------------------------- +// +EXPORT_C MIHLFileImage* IHLImageFactory::OpenBufferedFileImageL( RFs& aFs, const TDesC8& aDataBuf ) + { + return CIHLFileImage::NewL( aFs, aDataBuf, KIHLFirstImage, KIHLNullOptions ); + } + +// ----------------------------------------------------------------------------- +// IHLImageFactory::OpenBufferedFileImageL +// ----------------------------------------------------------------------------- +// +EXPORT_C MIHLFileImage* IHLImageFactory::OpenBufferedFileImageL( RFs& aFs, + const TDesC8& aDataBuf, TInt aImageIndex ) + { + return CIHLFileImage::NewL( aFs, aDataBuf, aImageIndex, KIHLNullOptions ); + } + +// ----------------------------------------------------------------------------- +// IHLImageFactory::OpenBufferedFileImageL +// ----------------------------------------------------------------------------- +// +EXPORT_C MIHLFileImage* IHLImageFactory::OpenBufferedFileImageL( RFs& aFs, + const TDesC8& aDataBuf, TInt aImageIndex, const TUint32 aOptions ) + { + return CIHLFileImage::NewL( aFs, aDataBuf, aImageIndex, aOptions ); + } + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandlinglib/Src/IHLImplementationIds.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlinglib/Src/IHLImplementationIds.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation id's used in internal classes. +* +*/ + + +#ifndef IHLIMPLEMENTATIONIDS_H +#define IHLIMPLEMENTATIONIDS_H + +// INCLUDES +#include + +// ----------------------------------------------------------------------------- +// IMPLEMENTATION IDs +// ----------------------------------------------------------------------------- +// +// Images +const TInt KIHLImplementationIdFileImage = 0x0101; +const TInt KIHLImplementationIdFileImageExtJpg = 0x0102; + +// Processors +const TInt KIHLImplementationIdBitmapProcessor = 0x0201; + +// Viewers +const TInt KIHLImplementationIdImageViewer = 0x0301; +const TInt KIHLImplementationIdImageViewerExtJpg = 0x0302; + +// Filters (reserved) +// const TInt KIHLImplementationIdFilter = 0x0401; // CSI: 13 # + +#endif // IHLIMPLEMENTATIONIDS_H + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandlinglib/Src/IHLProcessorFactory.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlinglib/Src/IHLProcessorFactory.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Static factory class for creating processors. +* +*/ + + + +// INCLUDE FILES +#include +#include "CIHLScaler.h" +#include "CIHLBitmapProcessor.h" + +// ============================ STATIC FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// IHLProcessorFactory::CreateBitmapProcessorL +// ----------------------------------------------------------------------------- +// +EXPORT_C MIHLBitmapProcessor* IHLProcessorFactory::CreateBitmapProcessorL( const TUint32 aOptions ) + { + return CIHLBitmapProcessor::NewL( aOptions ); + } + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandlinglib/Src/IHLViewerFactory.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlinglib/Src/IHLViewerFactory.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Static factory class for creating viewers. +* +*/ + + +// INCLUDE FILES +#include + +#include "CIHLImageViewerExtJpg.h" +#include "MIHLFileImageExtJpg.h" +#include "IHLImplementationIds.h" + +#include "CIHLImageViewer.h" +#include +#include +#include + + +// ============================ STATIC FUNCTIONS =============================== +// ----------------------------------------------------------------------------- +// IHLViewerFactory::CreateImageViewerL +// ----------------------------------------------------------------------------- +// +EXPORT_C MIHLImageViewer* IHLViewerFactory::CreateImageViewerL( + const TSize& aViewerSize, + MIHLImage& aSource, + MIHLBitmap& aDestination, + MIHLViewerObserver& aObserver, + const TUint32 aOptions ) + { + MIHLImageViewer* viewer = NULL; + if( aSource.Type().iInterfaceId == KIHLInterfaceIdFileImage ) + { + if( aSource.Type().iImplementationId == KIHLImplementationIdFileImageExtJpg ) + { + viewer = CIHLImageViewerExtJpg::NewL( aViewerSize, static_cast< MIHLFileImageExtJpg& >( aSource ), // CSI: 35 # + aDestination, aObserver, aOptions ); + } + else + { + viewer = CIHLImageViewer::NewL( aViewerSize, static_cast< MIHLFileImage& >( aSource ), // CSI: 35 # + aDestination, aObserver, aOptions ); + } + } + else + { + User::Leave( KErrArgument ); + } + return viewer; + } + +// End of File diff -r 000000000000 -r 2014ca87e772 imagehandlinglib/Src/MIHLFileImageExtJpg.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlinglib/Src/MIHLFileImageExtJpg.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,105 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Pure virtual interface for file based external jpg image class. +* : This class acts as a window into single image or animation +* : in one physical file. Note that file will be locked as long +* : as instance of this class is present. +* +*/ + + +#ifndef MIHLFILEIMAGEEXTJPG_H +#define MIHLFILEIMAGEEXTJPG_H + +// INCLUDES +#include +#include + +// FORWARD DECLARATION +class MIHLBitmap; +class MIHLFilter; +class CVisualFrame; + +// CLASS DECLARATION +/** +* MIHLFileImageExtJpg +* +* Pure virtual interface for file based image class that uses IclExtJpegApi. +* This class acts as a window into single image or animation +* in one physical file. Note that file will be locked as long +* as instance of this class is present. +* +* If interface needs to be pushed into CleanupStack, +* remember to use CleanupDeletePushL() function! +* DO NOT USE CleanupStack::PushL()!! +* +* @lib IHL.lib +* @since 3.0 +*/ +class MIHLFileImageExtJpg : public MIHLFileImage + { + public: + + /** + * Virtual destructor. + */ + virtual ~MIHLFileImageExtJpg() {} + + public: + /** + * Load part of the image into bitmap. + * @since 3.0 + * @param aSrcRect Part of the picture to be loaded + * @param aStatus Load request status reference. + * @param aDestination Destination bitmap reference. + * @param aFrameIndex frame index for loading single frame from image + * @return Return system wide error codes: + * KerrArgument if given bitmap is not created or it's size is incorrect. + * KErrBusy image has load request pending already. + */ + virtual TInt Load( TRect aSrcRect, TRequestStatus& aStatus, MIHLBitmap& aDestination, TInt aFrameIndex = 0 ) = 0; + + public: //CExtJpegDecoder wrapper, see IclExtJpegApi.h + + virtual void SetCroppingL( TRect aCropRect ) = 0; + + virtual void SetStreamingL( TSize& aMacroBlockSize ) = 0; + + virtual void SetRotationL( TInt aDegree ) = 0; + + virtual void SetFlippingL() = 0; + + virtual void SetMirroringL() = 0; + + virtual void SetDctDecodingL() = 0; + + virtual void ConvertL( + TRequestStatus* aRequestStatus, + const CVisualFrame* aDestinationFrame, + TInt& aNoOfDecodedMBlocks, + TInt aFrameNumber = 0 ) = 0; + + virtual void ContinueConvertL( + TRequestStatus* aRequestStatus, + const CVisualFrame* aDestinationFrame, + TInt& aNoOfDecodedMBlocks, + TInt aFrameNumber = 0 ) = 0; + + virtual TInt SupportedFormatsL() = 0; + + virtual TInt CapabilitiesL() = 0; + + + }; +#endif diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/group/bld.inf Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,24 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include "../thumbnailmanager/group/bld.inf" + + +// End of File + + diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/conf/102830B0.txt Binary file imagehandlingutilities/thumbnailmanager/conf/102830B0.txt has changed diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/conf/thumbnailmanager.confml Binary file imagehandlingutilities/thumbnailmanager/conf/thumbnailmanager.confml has changed diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/conf/thumbnailmanager_102830B0.crml Binary file imagehandlingutilities/thumbnailmanager/conf/thumbnailmanager_102830B0.crml has changed diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/group/bld.inf Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Build information file for project ?myapp +* +*/ + +#include + +#ifdef RD_THUMBNAILMANAGER + +#include "../thumbnailclient/group/bld.inf" +#include "../thumbnailserver/group/bld.inf" +#include "../plugins/image/group/bld.inf" +#include "../plugins/video/group/bld.inf" +#include "../plugins/audio/group/bld.inf" +#include "../tmiadrestart/group/bld.inf" +#ifdef RD_MDS_2_5 +#include "../thumbagdaemon/group/bld.inf" +#endif + +PRJ_PLATFORMS +WINSCW ARMV5 + +PRJ_EXPORTS +../sis/thumbnailmanager/thumbnailmanager_stub.sis /epoc32/data/z/system/install/thumbnailmanager_stub.sis +../conf/thumbnailmanager.confml MW_LAYER_CONFML(thumbnailmanager.confml) +../conf/thumbnailmanager_102830B0.crml MW_LAYER_CRML(thumbnailmanager_102830b0.crml) +../rom/thumbnailmanager.iby CORE_MW_LAYER_IBY_EXPORT_PATH(thumbnailmanager.iby) +#ifdef RD_MDS_2_5 +../rom/thumbagdaemon.iby CORE_MW_LAYER_IBY_EXPORT_PATH(thumbagdaemon.iby) +#endif + +PRJ_TESTMMPFILES + +PRJ_TESTEXPORTS +../conf/102830B0.txt /epoc32/release/winscw/udeb/z/private/10202be9/102830b0.txt +../conf/102830B0.txt /epoc32/release/winscw/urel/z/private/10202be9/102830b0.txt + +#endif // RD_THUMBNAILMANAGER + +// End of File + + diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/inc/thumbnaillog.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/inc/thumbnaillog.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,105 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Logging functions + * +*/ + + +#ifndef THUMBNAILLOG_H +#define THUMBNAILLOG_H + +#include +#include + +//log to file instead of RDebug +//#define LOG_TO_FILE + +#ifdef _DEBUG +#ifdef LOG_TO_FILE +// +// Log to file +// +#include +_LIT( KThumbnailLogDir, "thumbnail" ); +_LIT( KThumbnailLogFile, "thumbnail.txt" ); + +#define TN_DEBUG1( s ) \ +RFileLogger::Write( \ +KThumbnailLogDir, \ +KThumbnailLogFile, \ +EFileLoggingModeAppend, \ +_L( s ) ); + +#define TN_DEBUG2( s, a ) \ +RFileLogger::WriteFormat( \ +KThumbnailLogDir, \ +KThumbnailLogFile, \ +EFileLoggingModeAppend, \ +_L( s ), a ); + +#define TN_DEBUG3( s, a, b ) \ +RFileLogger::WriteFormat( \ +KThumbnailLogDir, \ +KThumbnailLogFile, \ +EFileLoggingModeAppend, \ +_L( s ), a, b ); + +#define TN_DEBUG4( s, a, b, c ) \ +RFileLogger::WriteFormat( \ +KThumbnailLogDir, \ +KThumbnailLogFile, \ +EFileLoggingModeAppend, \ +_L( s ), a, b, c ); + +#define TN_DEBUG5( s, a, b, c, d ) \ +RFileLogger::WriteFormat( \ +KThumbnailLogDir, \ +KThumbnailLogFile, \ +EFileLoggingModeAppend, \ +_L( s ), a, b, c, d ); + +#define TN_DEBUG6( s, a, b, c, d, e ) \ +RFileLogger::WriteFormat( \ +KThumbnailLogDir, \ +KThumbnailLogFile, \ +EFileLoggingModeAppend, \ +_L( s ), a, b, c, d, e ); + +#else // LOG_TO_FILE +// +// Log to RDebug +// +#define TN_DEBUG1( s ) RDebug::Print( _L( s ) ) +#define TN_DEBUG2( s, a ) RDebug::Print( _L( s ), a ) +#define TN_DEBUG3( s, a, b ) RDebug::Print( _L( s ), a, b ) +#define TN_DEBUG4( s, a, b, c ) RDebug::Print( _L( s ), a, b, c ) +#define TN_DEBUG5( s, a, b, c, d ) RDebug::Print( _L( s ), a, b, c, d ) +#define TN_DEBUG6( s, a, b, c, d, e ) RDebug::Print( _L( s ), a, b, c, d, e ) + +#endif // LOG_TO_FILE + +#else // _DEBUG +// +// No logging +// +#define TN_DEBUG1( s ) +#define TN_DEBUG2( s, a ) +#define TN_DEBUG3( s, a, b ) +#define TN_DEBUG4( s, a, b, c ) +#define TN_DEBUG5( s, a, b, c, d ) +#define TN_DEBUG6( s, a, b, c, d, e ) + +#endif // _DEBUG + +#endif // THUMBNAILLOG_H diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/inc/thumbnailmanagerconstants.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/inc/thumbnailmanagerconstants.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,526 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Thumbnail manager constants + * +*/ + + +#ifndef THUMBNAILMANAGERCONSTANTS_H +#define THUMBNAILMANAGERCONSTANTS_H + +#include +#include +#include + +#include + +#include "thumbnailmanager.h" // TThumbnailFlags + +class CThumbnailServerSession; + +// P&S stuff +static _LIT_SECURITY_POLICY_PASS(KAllowAllPolicy); +static _LIT_SECURITY_POLICY_C1(KPowerMgmtPolicy,ECapabilityPowerMgmt); + +const TUid KTMPSNotification = { 0x102830AB }; +const TUid KTAGDPSNotification = { 0x2001FD51 }; +const TUid KMdSPSShutdown = { 0x20022E94 }; +const TUid KServerIdle = { 0x102830AB }; +const TUid KDaemonUid = { 0x2001FD51 }; + +const TInt KShutdown = 0x00000001; +const TInt KMdSShutdown = 0x00000002; +//used to signal from server side when it's idle +const TInt KIdle = 0x00000004; + +//insert to temp table first wo indexing and move data to main table as batch +const TUint KMaxBatchItems = 18; + +const TUint KMaxQueryItems = 1; + +// maximum number of active client queue requests +const TUint KMaxClientRequests = 2; + +// maximum number of active daemon requests +const TUint KMaxDaemonRequests = 3; + +const TUint KClientRequestTimeout = 60000000; //60 sec + +const TUint KThumbnailServerMajorVersionNumber = 0; +const TUint KThumbnailServerMinorVersionNumber = 1; +const TUint KThumbnailServerBuildVersionNumber = 1; + +const TInt KThumbnailErrThumbnailNotFound = -62000; + +//give MDS 1000 msec time to settle before starting generating TNs +const TInt KHarvestingCompleteTimeout = 10000000; //10 sec + +const TInt KPSKeyTimeout = 10000000; //10 sec +//Store's auto flush timeout +const TInt KAutoFlushTimeout = 30000000; //30 sec + +// video decoder timeout +const TInt KVideoDecoderTimeout = 5000000; // 5 seconds + +const TDisplayMode KThumbnailDefaultDisplayMode = EColor64K; + +//default displaymode (bpp - bits per pixel) for TNs in DB +//this makes possible to provide all colour depths up to 16M aka 24 -bit full colour +const TDisplayMode KStoreDisplayMode = EColor16M; + +//required amount of memory to keep bitmaps on RAM in bits +const TInt KMemoryNeed = 5000000; + +_LIT( KThumbnailServerName, "ThumbnailServer" ); +_LIT( KThumbnailServerProcess, "*ThumbnailServer*" ); +_LIT( KThumbnailServerExe, "thumbnailserver.exe" ); +_LIT( KThumbnailServerShutdown, "Thumbnailserver_Shutdown" ); + +_LIT( KTAGDaemonName, "ThumbAGDaemon" ); +_LIT( KTAGDaemonProcess, "*ThumbAGDaemon*" ); +_LIT( KTAGDaemonExe, "thumbagdaemon.exe" ); + +// server message slots, -1 doesn't reserve fixed amount from global but uses free available amount instead +const TInt KMessageSlots = -1; + +const TInt KMinPriority = KMinTInt; +const TInt KMinPlaceholderPriority = (KMinTInt +1000); +const TInt KLowPriority = -1000; +const TInt KNormalPriority = 0; +const TInt KHighPriority = 1000; +const TInt KMaxGeneratePriority = (KMaxTInt -1000); +const TInt KMaxPriority = KMaxTInt; // For scaling tasks +const TInt KImeiBufferSize = CTelephony::KPhoneSerialNumberSize; +const TInt KCheckValue = 123456; + +_LIT8( KJpegMime, "image/jpeg" ); _LIT( KJpegExt, ".jpeg" ); +_LIT8( KJpeg2000Mime, "image/jp2" ); _LIT( KJpeg2000Ext, ".jp2" ); +_LIT8( KJpgMime, "image/jpeg" ); _LIT( KJpgExt, ".jpg" ); +_LIT8( KGifMime, "image/gif" ); _LIT( KGifExt, ".gif" ); +_LIT8( KPngMime, "image/png" ); _LIT( KPngExt, ".png" ); +_LIT8( KSvgMime, "image/svg+xml" ); _LIT( KSvgExt, ".svg" ); +_LIT8( KMpgMime1, "video/mpeg"); _LIT( KMpgExt1, ".mpg" ); +_LIT8( KMpeg4Mime, "video/mpeg4" ); _LIT( KMpeg4Ext,".mpeg4" ); +_LIT8( KMp4Mime, "video/mp4" ); _LIT( KMp4Ext, ".mp4" ); +_LIT8( KAviMime, "video/x-msvideo" ); _LIT( KAviExt, ".avi" ); +_LIT8( KMp3Mime, "audio/mpeg" ); _LIT( KMp3Ext, ".mp3" ); +_LIT8( KNonEmbeddArtMime, "audio/mpeg" ); _LIT( KNonEmbeddArtExt, ".alb" ); +_LIT8( KM4aMime, "audio/mp4" ); _LIT( KM4aExt, ".m4a" ); +_LIT8( KAacMime, "audio/aac" ); _LIT( KAacExt, ".aac" ); +_LIT8( KWmaMime, "audio/x-ms-wma" ); _LIT( KWmaExt, ".wma" ); +_LIT8( KBmpMime, "image/bmp" ); _LIT( KBmpExt, ".bmp" ); +_LIT8( KAudio3gppMime, "audio/3gpp" ); +_LIT8( KVideo3gppMime, "video/3gpp" ); _LIT( K3gpExt, ".3gp" ); +_LIT8( KAudioAmrMime, "audio/AMR" ); _LIT( KAmrExt, ".amr" ); +_LIT8( KVideoWmvMime, "video/x-ms-wmv" ); _LIT( KWmvExt, ".wmv" ); +_LIT8( KRealAudioMime, "audio/vnd.rn-realaudio" ); _LIT( KRealAudioExt, ".ra" ); +_LIT8( KPmRealAudioPluginMime, "audio/x-pn-realaudio-plugin" ); _LIT( KPmRealAudioPluginExt, ".rpm" ); +_LIT8( KPmRealVideoPluginMime, "video/x-pn-realvideo" ); _LIT( KPmRealVideoPluginExt, ".rm" ); +_LIT8( KPmRealVbVideoPluginMime, "video/x-pn-realvideo" ); _LIT( KPmRealVbVideoPluginExt, ".rmvb" ); +_LIT8( KPmRealAudioMime, "audio/x-pn-realaudio" ); _LIT( KPmRealAudioExt, ".ra" ); +_LIT8( KRealVideoMime, "video/vnd.rn-realvideo" ); _LIT( KRealVideoExt, ".rv" ); +_LIT8( KFlashVideoMime, "video/x-flv" ); _LIT( KFlashVideoExt, ".flv" ); +_LIT8( KMatroskaVideoMime, "video/x-matroska" ); _LIT( KMatroskaVideoExt, ".mkv" ); +_LIT( KImageMime, "image/*" ); +_LIT( KVideoMime, "video/*" ); +_LIT( KAudioMime, "audio/*" ); +_LIT( KM4vExt, ".m4v" ); +_LIT( KNonEmbeddedArtExt, ".alb" ); + +/** + * Control flags set by the server for handling specific situations + * (for example for distinguishing between preview thumbnails and + * final thumbnails). + * + * @since S60 v5.0 + */ +enum TThumbnailControlFlags + { + /** + * Default value. No flags set. + */ + EThumbnailNoControlFlags = 0, + + /** + * Set by the server when the request is completed and it is only the + * first part of a two-phase request + */ + EThumbnailPreviewThumbnail = 1, + + /** + * Set by the client to inform server to create only missing persistent sizes thumbnails + */ + EThumbnailGeneratePersistentSizesOnly = 2 +}; + + +/** + * Thumbnail request parameters used for client-server communication. + * + * @since S60 v5.0 + */ +struct TThumbnailRequestParams + { +public: + /** + * Bitmap handle for completed requests + */ + TInt iBitmapHandle; + + /** + * Flags for new requests. + */ + CThumbnailManager::TThumbnailFlags iFlags; + + /** + * Quality-preference value for new requests. + */ + CThumbnailManager::TThumbnailQualityPreference iQualityPreference; + + /** + * Priority for new requests. + */ + TInt iPriority; + + /** + * Requested thumbnail size new requests. + */ + TSize iSize; + + /** + * Requested display mode new requests. + */ + TDisplayMode iDisplayMode; + + /** + * Full path to object file for new requests. Should be set even + * when file handles are used. + */ + TFileName iFileName; + + /** + * Full path to object to which the imported thumb is to be linked. + */ + TFileName iTargetUri; + + /** + * Thumbnail ID + */ + TThumbnailId iThumbnailId; + + /** + * Relative thumbnail size + */ + TThumbnailSize iThumbnailSize; + + /** + * MIME type + */ + TDataType iMimeType; + + /** + * Image buffer used to create & set the thumbnail + */ + TDesC8* iBuffer; + + /** + * Session specific request ID allocated by the client. + */ + TThumbnailRequestId iRequestId; + + /** + * Control flags set by the server for handling specific situations + * (for example for distinguishing between preview thumbnails and + * final thumbnails). + */ + TThumbnailControlFlags iControlFlags; + + /** + * Thumbnail's modify timestamp + */ + TInt64 iModified; + + /** + * Thumbnail's orientation + */ + TInt iOrientation; + }; + + +typedef TPckg < TThumbnailRequestParams > TThumbnailRequestParamsPckg; +typedef TPckgBuf < TThumbnailRequestParams > TThumbnailRequestParamsPckgBuf; + + +/** + * Request ID class used on the server side. Consists of a pointer to a + * session and a session specific ID. + * + * @since S60 v5.0 + */ +struct TThumbnailServerRequestId + { + /** + * Default C++ constructor + * + * @since S60 v5.0 + */ + inline TThumbnailServerRequestId(): iSession( NULL ), iRequestId( 0 ){} + + /** + * C++ constructor + * + * @since S60 v5.0 + * @param aSession Pointer to the server-side session object, which + * created the request. + * @param aRequestId Session specific request ID as allocated by the + * client. + */ + inline TThumbnailServerRequestId( CThumbnailServerSession* aSession, + TThumbnailRequestId aRequestId ): iSession( aSession ), iRequestId( + aRequestId ){} + + /** + * Compare request IDs. Both session and client-side request ID must + * match. + * + * @param aRequestId Another TThumbnailServerRequestId to compare to + * @since S60 v5.0 + */ + inline TBool operator == ( const TThumbnailServerRequestId& aRequestId ) + const + { + return aRequestId.iSession == iSession && aRequestId.iRequestId == + iRequestId; + } + +public: + /** + * Pointer to the server-side session object, which created the request. + * Not own. + */ + CThumbnailServerSession* iSession; + + /** + * Session specific request ID as allocated by the client. + */ + TThumbnailRequestId iRequestId; +}; + +/** + * Client-server message IDs + * + * @since S60 v5.0 + * Start from 0 so that TPolicy range matches to function count. + */ +enum TThumbnailServerRequest + { + /** + * Thumbnail request using file path. A TThumbnailRequestParams + * struct is passed as a parameter. + * @see TThumbnailRequestParams + */ + ERequestThumbByPathAsync = 0, + + /** + * Thumbnail request using file path. A TThumbnailRequestParams + * struct is passed as a parameter as well as the file handle using + * TransferToServer()/AdoptFromClient(). + * @see TThumbnailRequestParams + */ + ERequestThumbByFileHandleAsync, + + /** + * Release a bitmap after the client callback has returned. Bitmap + * handle is passed as a parameter. + */ + EReleaseBitmap, + + /** + * Cancel a thumbnail request. Session specific request ID is passed + * as a parameter. + */ + ECancelRequest, + + /** + * Change the priority of a thumbnail request. Session specific request + * ID and new priority value are passed as parameters. + */ + EChangePriority, + + /** + * Create thumbnails for a file. File path is passed as a + * parameter. + */ + ECreateThumbnails, + + /** + * Delete existing thumbnails for a file. File path is passed as a + * parameter. + */ + EDeleteThumbnails, + + /** + * Get the required size (in characters) for a buffer that contains the + * list of supported MIME types. Size in integers is returned in the + * first parameter. + */ + EGetMimeTypeBufferSize, + + /** + * Get the list of supported MIME types and store them as the first + * parameter. The first parameter should be allocated by the client + * to be large enough (using EGetMimeTypeBufferSize). + */ + EGetMimeTypeList, + + /** + * Thumbnail request using ID. + */ + ERequestThumbByIdAsync, + + ERequestThumbByBufferAsync, + + /** + * Request to set thumbnail created from buffered image + */ + ERequestSetThumbnailByBuffer, + + /** + * Delete existing thumbnails. Id as parameter. + */ + EDeleteThumbnailsById, + + EReserved1, + + /** + * Update thumbnails by given Id. + */ + EUpdateThumbnails, + + /** + * Request to set thumbnail created from given bitmap + */ + ERequestSetThumbnailByBitmap, + + /** + * Do not remove and keep as last item! Holds count of functions supported. + */ + EThumbnailServerRequestCount + }; + +/** + * Thumbnail format in storage + * + * @since S60 v5.0 + */ +enum TThumbnailFormat + { + /** + * Symbian internal bitmap format, usually as extranlized BLOB in the db. + */ + EThumbnailFormatFbsBitmap, + /** + * Stantard JPEG + */ + EThumbnailFormatJpeg + }; + +struct TThumbnailDatabaseData + { +public: + /** + * Full path to object to which the imported thumb is to be linked. + */ + TPath iPath; + /** + * Thumbnail ID + */ + TInt iTnId; + /** + * Requested thumbnail size new requests. + */ + TInt iSize; + /** + * type of data + */ + TInt iFormat; + /** + * Path for the thumbnails + */ + TPath iTnPath; + /** + * Data if bitmap + */ + CFbsBitmap* iBlob; + /** + * Data if jpeg + */ + TDesC8* iData; + /** + * Width of thumbnail + */ + TInt iWidth; + /** + * Height of thumbnail + */ + TInt iHeight; + /** + * Original width of thumbnail + */ + TInt iOrigWidth; + /** + * Original height of thumbnail + */ + TInt iOrigHeight; + /** + * flags + */ + TInt iFlags; + /** + * videoposition + */ + TInt iVideoPosition; + /** + * thumb oritentation + */ + TInt iOrientation; + /** + * Thumb created from associated path + */ + TInt iThumbFromPath; + /** + * last modified + */ + TInt64 iModified; + + }; + +/** + * MDS query modes used during thumbnail generation + * + * @since S60 v5.0 + */ +enum TMDSQueryType + { + /** + * Query Id by Path + */ + EId, + /** + * Query Path by Id + */ + EURI + }; + +#endif // THUMBNAILMANAGERCONSTANTS_H diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/inc/thumbnailmanagerprivatecrkeys.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/inc/thumbnailmanagerprivatecrkeys.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Central Repository keys for Thumbnail Manager + * +*/ + + +#ifndef THUMBNAILMANAGERPRIVATECRKEYS_H +#define THUMBNAILMANAGERPRIVATECRKEYS_H + +#include "thumbnailmanageruids.hrh" + +const TUid KThumbnailSettingsUid = + { + THUMBNAIL_CENREP_UID + }; + +const TUint32 KSizeImageGridWidth = 0x0; +const TUint32 KSizeImageGridHeight = 0x1; +const TUint32 KSizeImageListWidth = 0x2; +const TUint32 KSizeImageListHeight = 0x3; +const TUint32 KSizeImageFullscreenWidth = 0x4; +const TUint32 KSizeImageFullscreenHeight = 0x5; +const TUint32 KSizeVideoGridWidth = 0x6; +const TUint32 KSizeVideoGridHeight = 0x7; +const TUint32 KSizeVideoListWidth = 0x8; +const TUint32 KSizeVideoListHeight = 0x9; +const TUint32 KSizeVideoFullscreenWidth = 0x10; +const TUint32 KSizeVideoFullscreenHeight = 0x11; +const TUint32 KSizeAudioGridWidth = 0x12; +const TUint32 KSizeAudioGridHeight = 0x13; +const TUint32 KSizeAudioListWidth = 0x14; +const TUint32 KSizeAudioListHeight = 0x15; +const TUint32 KSizeAudioFullscreenWidth = 0x16; +const TUint32 KSizeAudioFullscreenHeight = 0x17; + +const TUint32 KAutoCreateImageGrid = 0x100; +const TUint32 KAutoCreateImageList = 0x101; +const TUint32 KAutoCreateImageFullscreen = 0x102; +const TUint32 KAutoCreateVideoGrid = 0x103; +const TUint32 KAutoCreateVideoList = 0x104; +const TUint32 KAutoCreateVideoFullscreen = 0x105; +const TUint32 KAutoCreateAudioGrid = 0x106; +const TUint32 KAutoCreateAudioList = 0x107; +const TUint32 KAutoCreateAudioFullscreen = 0x108; + +const TUint32 KColorDepthGrid = 0x200; +const TUint32 KColorDepthList = 0x201; +const TUint32 KColorDepthFullscreen = 0x202; + +const TUint32 KEnableDaemon = 0x300; + +#endif // THUMBNAILMANAGERPRIVATECRKEYS_H diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/inc/thumbnailmanageruids.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/inc/thumbnailmanageruids.hrh Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: UID values for Thumbnail Manager components +* +*/ + + +#ifndef THUMBNAILMANAGERUIDS_HRH +#define THUMBNAILMANAGERUIDS_HRH + +#define THUMBNAIL_PROVIDER_IF_UID 0x102830A9 +#define THUMBNAIL_MANAGER_CLIENT_DLL_UID 0x102830AA +#define THUMBNAIL_MANAGER_SERVER_UID 0x102830AB +#define THUMBNAIL_IMAGE_PROVIDER_DLL_UID 0x102830AC +#define THUMBNAIL_IMAGE_PROVIDER_IMP_UID 0x102830AD +#define THUMBNAIL_VIDEO_PROVIDER_DLL_UID 0x102830AE +#define THUMBNAIL_VIDEO_PROVIDER_IMP_UID 0x102830AF +#define THUMBNAIL_CENREP_UID 0x102830B0 +#define THUMBNAIL_AUDIO_PROVIDER_DLL_UID 0x20022D5D +#define THUMBNAIL_AUDIO_PROVIDER_IMP_UID 0x20022D5E + +#define THUMBAGDAEMON_UID 0x2001FD51 +#define THUMBAGDAEMON_SIS 0x102830A9 + +#endif // THUMBNAILMANAGERUIDS_HRH diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/inc/thumbnailpanic.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/inc/thumbnailpanic.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Panic codes for Thumbnail Manager + * +*/ + + +#ifndef THUMBNAILPANIC_H +#define THUMBNAILPANIC_H + +#include + +_LIT( KThumbnailPanicCategory, "ThumbnailManager" ); + +enum TThumbnailPanicCode + { + // Numerical values used to help finding the reason based on + // panic code. + EThumbnailNullPointer = 0, EThumbnailBadSize = 1, EThumbnailBadBitmapHandle + = 2, EThumbnailBadPath = 3, EThumbnailUnknownMessage = 4, + EThumbnailMessageNotCompleted = 5, EThumbnailBitmapNotReleased = 6, + EThumbnailEmptyDescriptor = 7, EThumbnailWrongId = 8, EAlreadyRunning = + 10 + }; + +/** + * Call User::Panic() with Thumbnail Manager panic category using + * one of the panic codes above + * @param aCode Panic code + */ +inline void ThumbnailPanic( TThumbnailPanicCode aCode ); + +/** + * Panic if a pointer is NULL + */ +#define TN_ASSERT_NOT_NULL( ptr ) \ +__ASSERT_ALWAYS( ptr, ThumbnailPanic( EThumbnailNullPointer ) ); + +#include "thumbnailpanic.inl" + + +#endif // THUMBNAILPANIC_H diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/inc/thumbnailpanic.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/inc/thumbnailpanic.inl Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Panic codes for Thumbnail Manager +* +*/ + + +// ----------------------------------------------------------------------------- +// Panic using numeric code +// ----------------------------------------------------------------------------- +// +inline void ThumbnailPanic( TThumbnailPanicCode aCode ) + { + User::Panic( KThumbnailPanicCategory, static_cast( aCode ) ); + } diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/inc/thumbnailprovider.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/inc/thumbnailprovider.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,232 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Base class for thumbnail provider plug-ins + * +*/ + + +#ifndef THUMBNAILPROVIDER_H +#define THUMBNAILPROVIDER_H + +#include +#include + +#include "thumbnailmanager.h" // TThumbnailFlags +#include "thumbnaillog.h" + +/** + * Thumbnail provider observer class + * + * @since S60 v5.0 + */ +class MThumbnailProviderObserver + { +public: + /** + * Thumbnail provider observer callback to notify the server when + * thumbnail has been generated. + * + * @since S60 5.0 + * @param aError Error code + * @param aBitmap Thumbnail bitmap. The observer implementation will + * assume ownership of the bitmap. + * @param aOriginalSize Original size of the object in pixels. + * @param aEXIF ETrue if thumbnail origin is EXIF. + */ + virtual void ThumbnailProviderReady( TInt aError, CFbsBitmap* aBitmap, + const TSize& aOriginalSize, const TBool aEXIF, const TBool aPortrait ) = 0; +}; + + +/** + * Base class for thumbnail provider plug-ins. + * + * @since S60 v5.0 + */ +class CThumbnailProvider: public CBase + { +public: + /** + * Create a provider instance. The instance is identified + * by the implementation UID. + */ + static CThumbnailProvider* NewL( TUid aUid ); + + /** + * Get the UID of this provider. + * + * @since S60 5.0 + * @return Provider implementation UID + */ + TUid Uid(); + + /** + * Set the observer to receive notification + * about thumbnail generation completion. + * + * @since S60 5.0 + * @param aObserver Reference to the observing object. Ownership not + * transferred. + */ + void SetObserver( MThumbnailProviderObserver& aObserver ); + + /** + * Set the target size for uncropped thumbnails. The actual thumbnail + * at least this wide or high, depending on which is the limiting + * factor. + * + * @since S60 5.0 + * @param aSize Target size in pixels for uncropped thumbnails. + */ + void SetTargetSize( const TSize& aSize ); + + /** + * Set the target size for cropped thumbnails. The actual thumbnail + * at least this large and it will include the whole thumbnail, + * not just the cropped portion. + * + * @since S60 5.0 + * @param aCroppedSize Target size in pixels for cropped thumbnails. + */ + void SetCroppedTargetSize( const TSize& aCroppedSize ); + + /** + * Reset thumbnail parameters to defaults. + */ + void Reset(); + + /** + * Get thumbnail bitmap. Must be implemented by provider plug-ins. + * + * @since S60 5.0 + * @param aFs File server session that can be used + * @param aFile File handle to the object file + * @param aMimeType MIME-type of the object file. + * @param aFlags Thumbnail generation flags + * @param aDisplayMode Display mode + */ + virtual void GetThumbnailL( RFs& aFs, RFile64& aFile, const TDataType& + aMimeType, const CThumbnailManager::TThumbnailFlags aFlags, const + TDisplayMode aDisplayMode, const CThumbnailManager::TThumbnailQualityPreference aQualityPreference ) = 0; + + /** + * Get thumbnail bitmap. Must be implemented by provider plug-ins. + * + * @since S60 5.0 + * @param aFs File server session that can be used + * @param aBuffer object buffer + * @param aMimeType MIME-type of the object file. + * @param aFlags Thumbnail generation flags + * @param aDisplayMode Display mode + */ + virtual void GetThumbnailL( RFs& aFs, TDesC8* aBuffer, const + TDataType& aMimeType, const CThumbnailManager::TThumbnailFlags aFlags, + const TDisplayMode aDisplayMode, const CThumbnailManager::TThumbnailQualityPreference aQualityPreference ) = 0; + + /** + * Get thumbnail bitmap. Must be implemented by provider plug-ins. + * + * @since S60 5.0 + * @param aFs File server session that can be used + * @param aBuffer object buffer + */ + + virtual void GetThumbnailL( RFs& aFs, TDesC8& aBuffer) = 0; + + /** + * Cancel a previous thumbnail request, if any. + * + * @since S60 5.0 + */ + virtual void CancelGetThumbnail() = 0; + + virtual ~CThumbnailProvider(){} + +protected: + /** + * Get the actual target size for the thumbnail. + * This is the maximum of the non-cropped and cropped + * target sizes. + * + * @since S60 5.0 + */ + inline void ResolveSize(); + + /** + * Calculate the scaled down size for the thumbnail. + * Aspect ratio is always preserved. If cropping is disabled + * the resulting size at most as wide or tall as requested. + * If cropping is enabled, the result is at least as wide + * and as tall as requested (unless original size is smaller + * than requested). + * + * @since S60 5.0 + * @param aOriginalSize Original size in pixels + * @param aTargetSize Target size in pixels + * @param aCrop Enable cropping + * @return Result size + */ + inline TSize FitToSize( const TSize& aOriginalSize, const TSize& + aTargetSize, TBool aCrop ); + +protected: + /** + * Provider observer. Implemented by thumbnail generation task. + * Not own. + */ + MThumbnailProviderObserver* iObserver; + + /** + * Thumbnail generation flags. + */ + CThumbnailManager::TThumbnailFlags iFlags; + + /** + * Thumbnail generation flags. + */ + CThumbnailManager::TThumbnailQualityPreference iQualityPreference; + + /** + * Size of the original object. + */ + TSize iOriginalSize; + + /** + * Target size for uncropped thumbnails. + */ + TSize iTargetSize; + + /** + * Target size for cropped thumbnails. + */ + TSize iCroppedTargetSize; + + /** + * Display mode for thumbnail bitmap + */ + TDisplayMode iDisplayMode; + + /** + * ECOM plug-in destructor key. + */ + TUid iDtor_ID_Key; + + /** + * UID of this implementation. + */ + TUid iUid; +}; + + +#endif // THUMBNAILPROVIDER_H diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/inc/thumbnailprovider.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/inc/thumbnailprovider.inl Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,92 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Thumbnail provider class inline functions +* +*/ + + +#include + + +inline TSize CThumbnailProvider::FitToSize( const TSize& aOrigSize, + const TSize& aTargetSize, + TBool aCrop ) + { + TSize res; + TReal32 srcAspect = + static_cast( aOrigSize.iWidth ) / aOrigSize.iHeight; + TReal32 reqAspect = + static_cast( aTargetSize.iWidth ) / aTargetSize.iHeight; + + res = aTargetSize; + + // Check whether the width or the height is the limiting factor for + // the size + TBool widthLimited = srcAspect > reqAspect; + if ( aCrop ) + { + // When cropping, this works exactly the opposite way + widthLimited = srcAspect < reqAspect; + } + + if ( res.iWidth >= aOrigSize.iWidth && + res.iHeight >= aOrigSize.iHeight ) + { + // Original is smaller than requested. No scaling needed. + res = aOrigSize; + } + else if ( widthLimited ) + { + // Width is the limiting factor, ie. the thumbnail is + // wide compared to requested size. + TReal trg; + TReal src( aTargetSize.iWidth / srcAspect ); + Math::Round( trg, src, 1 ); + res.SetSize( + aTargetSize.iWidth, + trg ); + } + else + { + // Height is the limiting factor, ie. the thumbnail is + // taller compared to requested size. + TReal trg; + TReal src( aTargetSize.iHeight * srcAspect ); + Math::Round( trg, src, 1 ); + res.SetSize( + trg, + aTargetSize.iHeight ); + } + return res; + } + + +inline void CThumbnailProvider::ResolveSize() + { + // Get the actual target size for the thumbnail. + // This is the maximum of the non-cropped and cropped + // target sizes. + + TSize scaledSize = FitToSize( iOriginalSize, iTargetSize, EFalse ); + if ( iCroppedTargetSize.iHeight && iCroppedTargetSize.iWidth ) + { + TSize croppedSize = FitToSize( + iOriginalSize, iCroppedTargetSize, ETrue ); + scaledSize.iWidth = Max( scaledSize.iWidth, croppedSize.iWidth ); + scaledSize.iHeight = Max( scaledSize.iHeight, croppedSize.iHeight ); + } + iTargetSize = scaledSize; + TN_DEBUG3("CThumbnailProvider::ResolveSize() - iTargetSize=(%d, %d)", + iTargetSize.iWidth, iTargetSize.iHeight); + } diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/plugins/audio/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/plugins/audio/group/bld.inf Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Build information file for project ?myapp +* +*/ + + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_MMPFILES +thumbnailaudioprovider.mmp + diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/plugins/audio/group/thumbnailaudioprovider.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/plugins/audio/group/thumbnailaudioprovider.mmp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Thumbnail image provider plugin definition file +* +*/ + + +// To get the MW_LAYER_SYSTEMINCLUDE-definition +#include + +#include "../../../inc/thumbnailmanageruids.hrh" + +TARGET thumbnailaudioprovider.dll +CAPABILITY CAP_ECOM_PLUGIN +TARGETTYPE PLUGIN + +UID 0x10009D8D THUMBNAIL_AUDIO_PROVIDER_DLL_UID +VENDORID VID_DEFAULT + +SOURCEPATH ../src +SOURCE thumbnailaudioprovider.cpp +SOURCE thumbnailimagedecoderv3.cpp + +// Default system include paths for middleware layer modules. +MW_LAYER_SYSTEMINCLUDE + +USERINCLUDE ../inc +USERINCLUDE ../../../inc + +SYSTEMINCLUDE /epoc32/include/ecom +SYSTEMINCLUDE /epoc32/include/icl + +START RESOURCE thumbnailaudioprovider.rss +END + +LIBRARY euser.lib +LIBRARY ecom.lib +LIBRARY efsrv.lib +LIBRARY imageconversion.lib +LIBRARY fbscli.lib +LIBRARY exiflib.lib +LIBRARY iclextjpegapi.lib +LIBRARY apmime.lib +LIBRARY metadatautility.lib + + +DEBUGLIBRARY flogger.lib + +PAGED +BYTEPAIRCOMPRESSTARGET diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/plugins/audio/inc/thumbnailaudioprovider.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/plugins/audio/inc/thumbnailaudioprovider.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,127 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Image thumbnail provider plugin. + * +*/ + + +#ifndef THUMBNAILAUDIOPROVIDER_H +#define THUMBNAILAUDIOPROVIDER_H + +#include "thumbnailprovider.h" + +class CThumbnailImageDecoderv3; + +/** + * Image thumbnail provider plugin. + * + * @since S60 v5.0 + */ +class CThumbnailAudioProvider: public CThumbnailProvider + { + +public: + + /** + * Two-phased constructor. + * + * @since S60 v5.0 + * @return New image thumbnail provider instance. + */ + static CThumbnailAudioProvider* NewL(); + + /** + * Destructor + * + * @since S60 v5.0 + */ + virtual ~CThumbnailAudioProvider(); + + /** + * Function that will provide thumbnail from given parameters. + * + * @since S60 v5.0 + * @param aFs File server session + * @param aFile Source image file. + * @param aMimeType MIME-type of the image file. + * @param aFlags Flags for thumbnail creation. + * @param aDisplayMode Used display mode. + */ + void GetThumbnailL( RFs& aFs, RFile64& aFile, const TDataType& aMimeType, + const CThumbnailManager::TThumbnailFlags aFlags, const TDisplayMode + aDisplayMode, const CThumbnailManager::TThumbnailQualityPreference aQualityPreference ); + + /** + * Function that will provide thumbnail from given parameters. + * + * @since S60 v5.0 + * @param aFs File server session + * @param aBuffer Source image buffer. + * @param aMimeType MIME-type of the image file. + * @param aFlags Flags for thumbnail creation. + * @param aDisplayMode Used display mode. + */ + void GetThumbnailL( RFs& aFs, TDesC8* aBuffer, const + TDataType& aMimeType, const CThumbnailManager::TThumbnailFlags aFlags, + const TDisplayMode aDisplayMode, const CThumbnailManager::TThumbnailQualityPreference aQualityPreference ); + + /** + * Function that will provide thumbnail from given parameters. + * + * @since S60 v5.0 + * @param aFs File server session + * @param aBuffer Source image buffer. + */ + void GetThumbnailL( RFs& aFs, TDesC8& aBuffer); + + /** + * Cancel a previous thumbnail request, if any. + * + * @since S60 5.0 + */ + void CancelGetThumbnail(); + +private: + + /** + * C++ default constructor + * + * @since S60 v5.0 + * @return New image thumbnail provider instance. + */ + CThumbnailAudioProvider(); + +private: + + /** + * Thumbnail decoder. + */ + CThumbnailImageDecoderv3* iImageDecoderv3; + + + /** + * File server session. + * Not own. + */ + RFs iFs; + + /** + * Mime-type of image + */ + TDataType iMimeType; +}; + +#include "thumbnailprovider.inl" + +#endif // THUMBNAILIMAGEPROVIDER_H diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/plugins/audio/inc/thumbnailimagedecoderv3.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/plugins/audio/inc/thumbnailimagedecoderv3.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,173 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Image thumbnail decoder. + * +*/ + + +#ifndef THUMBNAILIMAGEDECODERV3_H +#define THUMBNAILIMAGEDECODERV3_H + +#include "thumbnailprovider.h" + +class CImageDecoder; +class CFbsBitmap; + +// Size of buffer to load from file start to get EXIF thumbnail +const TInt KJpegLoadBufferSize = 64 * 1024; + + +/** + * Image thumbnail decoder. + * + * @since S60 v5.0 + */ +class CThumbnailImageDecoderv3: public CActive + { +public: + + /** + * C++ default constructor + * + * @since S60 v5.0 + * @param aFs File server session + * @return New image thumbnail decoder instance. + */ + CThumbnailImageDecoderv3( RFs& aFs ); + + /** + * Destructor + * + * @since S60 v5.0 + */ + virtual ~CThumbnailImageDecoderv3(); + + + /** + * Creates a decoder from the given image buffer and gets image + * information + * + * @since S60 v5.0 + * @param aBuffer Source image buffer. + * @param aObserver Observer to relay notifications about completed + * operations. + * @param aFlags Decoding option flags. + * @param aMimeType Mime-type of image to be decoded. + * @param aSize desired size of thumbnail. + */ + void CreateL( const TDesC8* aBuffer, MThumbnailProviderObserver& + aObserver, const CThumbnailManager::TThumbnailFlags aFlags, const + TDataType& aMimeType, const TSize& aSize ); + + /** + * Decode image. + * + * @since S60 v5.0 + * @param aDisplayMode Preferred display mode. + */ + void DecodeL( const TDisplayMode aDisplayMode ); + + /** + * Returns the size of original image. + * + * @since S60 v5.0 + * @return Size of original image. + */ + const TSize& OriginalSize()const; + +private: + /** + * Used to release reserved resources. + * + * @since S60 v5.0 + */ + void Release(); + + /** + * Implements cancellation of an outstanding request. + * + * @since S60 v5.0 + */ + void DoCancel(); + + /** + * Handles an active object's request completion event. + * + * @since S60 v5.0 + */ + void RunL(); + + + /** + * Creates image decoder to be used. + * + * @since S60 v5.0 + */ + void CreateDecoderL(); + + + +private: + // data + + /** + * Requested size. + */ + TSize iSize; + + /** + * Image decoder. + * Own. + */ + CImageDecoder* iDecoder; + + /** + * Decoded bitmap. + * Own. + */ + CFbsBitmap* iBitmap; + + /** + * Image info flags (from TFrameInfo) + */ + TUint32 iFrameInfoFlags; + + /** + * Original size of the image in pixels. + */ + TSize iOriginalSize; + + /** + * Used fileserver. + */ + RFs& iFs; + + + /** + * Buffer from which thumbnail is to be created. + */ + const TDesC8* iBuffer; + + /** + * Observer. + */ + MThumbnailProviderObserver* iObserver; // not own + + /** + * Mime-type. + */ + TDataType iMimeType; +}; + +#endif // THUMBNAILIMAGEDECODERV3_H diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/plugins/audio/src/thumbnailaudioprovider.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/plugins/audio/src/thumbnailaudioprovider.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,184 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Audio thumbnail provider plugin + * +*/ + + +#include +#include + +#include "thumbnailaudioprovider.h" +#include "thumbnailimagedecoderv3.h" +#include "thumbnailmanageruids.hrh" +#include "thumbnaillog.h" +#include +#include +#include "thumbnailmanagerconstants.h" + + +#ifndef IMPLEMENTATION_PROXY_ENTRY +typedef TAny* TProxyNewLPtr; +#define IMPLEMENTATION_PROXY_ENTRY(aUid, aFuncPtr) \ +{ {aUid}, static_cast(aFuncPtr) } +#endif + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CThumbnailImageProvider::NewL() +// Two-phased constructor. +// --------------------------------------------------------------------------- +// +CThumbnailAudioProvider* CThumbnailAudioProvider::NewL() + { + CThumbnailAudioProvider* self = new( ELeave )CThumbnailAudioProvider(); + return self; + } + + +// --------------------------------------------------------------------------- +// CThumbnailAudioProvider::CThumbnailAudioProvider() +// C++ default constructor can NOT contain any code, that might leave. +// --------------------------------------------------------------------------- +// +CThumbnailAudioProvider::CThumbnailAudioProvider() + { + TN_DEBUG1( "CThumbnailAudioProvider::CThumbnailAudioProvider()" ); + } + + +// --------------------------------------------------------------------------- +// CThumbnailAudioProvider::~CThumbnailAudioProvider() +// Destructor. +// --------------------------------------------------------------------------- +// +CThumbnailAudioProvider::~CThumbnailAudioProvider() + { + TN_DEBUG1( "CThumbnailAudioProvider::~CThumbnailAudioProvider()" ); + delete iImageDecoderv3; + REComSession::DestroyedImplementation( iDtor_ID_Key ); + } + + +// --------------------------------------------------------------------------- +// CThumbnailAudioProvider::GetThumbnailL() +// Provides the thumbnail image +// --------------------------------------------------------------------------- +// +void CThumbnailAudioProvider::GetThumbnailL( RFs& aFs, RFile64& aFile, const + TDataType& aMimeType , const CThumbnailManager::TThumbnailFlags aFlags, + const TDisplayMode /*aDisplayMode*/, const CThumbnailManager::TThumbnailQualityPreference /*aQualityPreference*/ ) + { + CMetaDataUtility* metaDataUtil = CMetaDataUtility::NewL(); + CleanupStack::PushL( metaDataUtil ); + + RArray wantedFields; + CleanupClosePushL(wantedFields); + wantedFields.AppendL(EMetaDataJpeg); + + metaDataUtil->OpenFileL(aFile, wantedFields, aMimeType.Des8()); + const CMetaDataFieldContainer& metaCont = metaDataUtil->MetaDataFieldsL(); + TPtrC8 ptr = metaCont.Field8( EMetaDataJpeg ); + HBufC8* data = ptr.AllocL(); + + CleanupStack::PushL( data ); + + if(data->Length() == 0) + { + User::Leave( KErrNotFound ); + } + + CleanupStack::Pop( data ); + CleanupStack::PopAndDestroy(&wantedFields); + CleanupStack::PopAndDestroy(metaDataUtil); + + if ( !iImageDecoderv3 ) + { + iImageDecoderv3 = new( ELeave )CThumbnailImageDecoderv3( aFs ); + } + + iMimeType = TDataType(KJpegMime); + iFlags = aFlags; + //set default mode displaymode from global constants + iDisplayMode = KStoreDisplayMode; + + iImageDecoderv3->CreateL( data, *iObserver, iFlags, iMimeType, iTargetSize ); + iOriginalSize = iImageDecoderv3->OriginalSize(); + iImageDecoderv3->DecodeL( iDisplayMode ); + } + +// --------------------------------------------------------------------------- +// CThumbnailAudioProvider::GetThumbnailL() +// Provides the thumbnail image +// --------------------------------------------------------------------------- +// +void CThumbnailAudioProvider::GetThumbnailL( RFs& /* aFs */, TDesC8* /* aBuffer */, const + TDataType& /*aMimeType */, const CThumbnailManager::TThumbnailFlags /* aFlags */, + const TDisplayMode /* aDisplayMode */, const CThumbnailManager::TThumbnailQualityPreference /*aQualityPreference*/ ) + { + + } + +// --------------------------------------------------------------------------- +// CThumbnailAudioProvider::GetThumbnailL() +// Provides the thumbnail image +// --------------------------------------------------------------------------- +// +void CThumbnailAudioProvider::GetThumbnailL( RFs& /* aFs */, TDesC8& /*aBuffer */) + { + + } + +// --------------------------------------------------------------------------- +// Cancel thumbnail request +// --------------------------------------------------------------------------- +// +void CThumbnailAudioProvider::CancelGetThumbnail() + { + if ( iImageDecoderv3) + { + iImageDecoderv3->Cancel(); + } + + } + +// ======== GLOBAL FUNCTIONS ======== + +// ----------------------------------------------------------------------------- +// ImplementationTable +// Define the interface UIDs +// ----------------------------------------------------------------------------- +// +const TImplementationProxy ImplementationTable[] = + { + IMPLEMENTATION_PROXY_ENTRY( THUMBNAIL_AUDIO_PROVIDER_IMP_UID, + CThumbnailAudioProvider::NewL ) +}; + + +// ----------------------------------------------------------------------------- +// ImplementationGroupProxy +// The one and only exported function that is the ECom entry point +// ----------------------------------------------------------------------------- +// +EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& + aTableCount ) + { + aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy ); + return ImplementationTable; + } + +//End of file diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/plugins/audio/src/thumbnailaudioprovider.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/plugins/audio/src/thumbnailaudioprovider.rss Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Image thumbnail provider plugin resource file +* +*/ + + +#include "registryinfov2.rh" +#include "thumbnailmanageruids.hrh" + +RESOURCE REGISTRY_INFO theInfo +{ +// resource_format_version must always be set as follows +resource_format_version = RESOURCE_FORMAT_VERSION_2; + +// Normal plug-in parameters +dll_uid = THUMBNAIL_AUDIO_PROVIDER_DLL_UID; +interfaces = + { + INTERFACE_INFO + { + interface_uid = THUMBNAIL_PROVIDER_IF_UID; + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = THUMBNAIL_AUDIO_PROVIDER_IMP_UID; + version_no = 1; + display_name = ""; + default_data = ""; + opaque_data = "audio/*"; + rom_only = 0; + } + }; + } + }; +} diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/plugins/audio/src/thumbnailimagedecoderv3.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/plugins/audio/src/thumbnailimagedecoderv3.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,249 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Image thumbnail decoder + * +*/ + + +//INCLUDE FILES +#include +#include +#include + +#include +#include "thumbnailimagedecoderv3.h" +#include "thumbnaillog.h" +#include "thumbnailpanic.h" + + +// CImageDecoder supports up to 1/8 size reduction if EFullyScaleable is +// not set. +const TInt KMaximumReductionFactor = 8; + + +// ============================ MEMBER FUNCTIONS =============================== + +// --------------------------------------------------------------------------- +// CThumbnailImageDecoder::CThumbnailImageDecoder() +// C++ default constructor can NOT contain any code, that might leave. +// --------------------------------------------------------------------------- +// +CThumbnailImageDecoderv3::CThumbnailImageDecoderv3( RFs& aFs ): CActive( + EPriorityStandard ), iFs( aFs ) + { + CActiveScheduler::Add( this ); + } + + +// --------------------------------------------------------------------------- +// CThumbnailImageDecoderv3::~CThumbnailImageDecoderv3() +// Destructor. +// --------------------------------------------------------------------------- +// +CThumbnailImageDecoderv3::~CThumbnailImageDecoderv3() + { + Release(); + } + + +// ----------------------------------------------------------------------------- +// CThumbnailImageDecoderv3::CreateL() +// Creates thumbnail of image +// ----------------------------------------------------------------------------- +// +void CThumbnailImageDecoderv3::CreateL( const TDesC8* aBuffer, MThumbnailProviderObserver& + aObserver, const CThumbnailManager::TThumbnailFlags /*aFlags*/, const + TDataType& aMimeType, const TSize& aSize ) + { + + TN_DEBUG1( "CCThumbnailImageDecoderv3::CreateL() called" ); + + iSize = aSize; + iMimeType = aMimeType; + iObserver = &aObserver; + iBuffer = aBuffer; + + CreateDecoderL(); + + const TFrameInfo info( iDecoder->FrameInfo()); + if (( info.iOverallSizeInPixels.iWidth < 1 ) || ( + info.iOverallSizeInPixels.iHeight < 1 )) + { + User::Leave( KErrCorrupt ); + } + iFrameInfoFlags = info.iFlags; + iOriginalSize = info.iOverallSizeInPixels; + } + +// ----------------------------------------------------------------------------- +// CThumbnailImageDecoderv3::DecodeL() +// Decode the thumbnail image +// ----------------------------------------------------------------------------- +// +void CThumbnailImageDecoderv3::DecodeL( const TDisplayMode aDisplayMode ) + { + // Create the bitmap + if ( !iBitmap ) + { + iBitmap = new( ELeave )CFbsBitmap(); + } + + //Size in both x and y dimension must be non-zero, positive value + TSize loadSize( iOriginalSize) ; + + // If EFullyScaleable flag is not set, we need to figure out a size + // reduction factor. 1/1, 1/2, 1/4, and 1/8 are possible values for all + // plug-ins. SVG graphics can be rendered at any size even though + // EFullyScaleable is not set. + if ( !( iFrameInfoFlags& TFrameInfo::EFullyScaleable ) ) + { + loadSize = iOriginalSize; + TInt reductionFactor = 1; + while ( reductionFactor < KMaximumReductionFactor && ( iSize.iWidth < + loadSize.iWidth / 2 ) && ( iSize.iHeight < loadSize.iHeight / 2 )) + { + // magic: use loadSize that is half of previous size + loadSize.iWidth /= 2; + loadSize.iHeight /= 2; + reductionFactor *= 2; + } + // If original size is not an exact multiple of reduction factor, + // we need to round loadSize up + if ( reductionFactor && iOriginalSize.iWidth % reductionFactor ) + { + loadSize.iWidth++; + } + if ( reductionFactor && iOriginalSize.iHeight % reductionFactor ) + { + loadSize.iHeight++; + } + TN_DEBUG4( + "EFullyScaleable not set for image - loadSize=(%d,%d) reduction=1/%d ", loadSize.iWidth, loadSize.iHeight, reductionFactor ); + } + + User::LeaveIfError( iBitmap->Create( loadSize, aDisplayMode )); + + iDecoder->Convert( &iStatus, * iBitmap ); + while ( iStatus == KErrUnderflow ) + { + iDecoder->ContinueConvert( &iStatus ); + } + SetActive(); + } + + +// ----------------------------------------------------------------------------- +// CThumbnailImageDecoderv3::Release() +// Releases resources +// ----------------------------------------------------------------------------- +// +void CThumbnailImageDecoderv3::Release() + { + Cancel(); + delete iDecoder; + iDecoder = NULL; + } + + +// ----------------------------------------------------------------------------- +// CThumbnailImageDecoderv3::DoCancel() +// ----------------------------------------------------------------------------- +// +void CThumbnailImageDecoderv3::DoCancel() + { + if ( iDecoder ) + { + iDecoder->Cancel(); + delete iDecoder; + iDecoder = NULL; + } + } + + +// ----------------------------------------------------------------------------- +// CThumbnailImageDecoderv3::RunL() +// ----------------------------------------------------------------------------- +// +void CThumbnailImageDecoderv3::RunL() + { + // This call takes ownership of iBitmap + iObserver->ThumbnailProviderReady( iStatus.Int(), iBitmap, iOriginalSize, EFalse, EFalse ); + + iBitmap = NULL; // owned by server now + delete iBuffer; + iBuffer = NULL; + Release(); + } + + +// ----------------------------------------------------------------------------- +// CThumbnailImageDecoderv3::CreateDecoderL +// Creates image decoder +// ----------------------------------------------------------------------------- +// +void CThumbnailImageDecoderv3::CreateDecoderL() + { + delete iDecoder; + iDecoder = NULL; + + CImageDecoder::TOptions options = ( CImageDecoder::TOptions )( + CImageDecoder::EOptionNoDither | CImageDecoder::EPreferFastDecode ); + + TRAPD( decErr, iDecoder = CExtJpegDecoder::DataNewL( + CExtJpegDecoder::EHwImplementation, iFs, *iBuffer, options )); + + if ( decErr != KErrNone ) + { + TRAP( decErr, iDecoder = CExtJpegDecoder::DataNewL( + CExtJpegDecoder::ESwImplementation, iFs, *iBuffer, options )); + + if ( decErr != KErrNone ) + { + // don't force any mime type + TRAPD( decErr, iDecoder = CImageDecoder::DataNewL( iFs, *iBuffer, options ) ); + if ( decErr != KErrNone ) + { + delete iBuffer; + iBuffer = NULL; + + TN_DEBUG1( "CThumbnailImageDecoderv3::CreateDecoderL() - error" ); + + User::Leave( decErr ); + } + + TN_DEBUG1( "CThumbnailImageDecoderv3::CreateDecoderL() - CImageDecoder created" ); + } + else + { + TN_DEBUG1( "CThumbnailImageDecoderv3::CreateDecoderL() - SW CExtJpegDecoder created" ); + } + } + else + { + TN_DEBUG1( "CThumbnailImageDecoderv3::CreateDecoderL() - HW CExtJpegDecoder created" ); + } + } + + +// ----------------------------------------------------------------------------- +// CThumbnailImageDecoderv3::CreateExifDecoderL() +// Returns size of original image +// ----------------------------------------------------------------------------- +// +const TSize& CThumbnailImageDecoderv3::OriginalSize()const + { + return iOriginalSize; + } + +//End of file diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/plugins/image/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/plugins/image/group/bld.inf Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Build information file for project ?myapp +* +*/ + + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_MMPFILES +thumbnailimageprovider.mmp + diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/plugins/image/group/thumbnailimageprovider.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/plugins/image/group/thumbnailimageprovider.mmp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Thumbnail image provider plugin definition file +* +*/ + + +// To get the MW_LAYER_SYSTEMINCLUDE-definition +#include + +#include "../../../inc/thumbnailmanageruids.hrh" + +TARGET thumbnailimageprovider.dll +CAPABILITY CAP_ECOM_PLUGIN +TARGETTYPE PLUGIN + +UID 0x10009D8D THUMBNAIL_IMAGE_PROVIDER_DLL_UID +VENDORID VID_DEFAULT + +SOURCEPATH ../src +SOURCE thumbnailimageprovider.cpp +SOURCE thumbnailimagedecoder.cpp +SOURCE thumbnailimagedecoderv2.cpp + +// Default system include paths for middleware layer modules. +MW_LAYER_SYSTEMINCLUDE + +USERINCLUDE ../inc +USERINCLUDE ../../../inc + +SYSTEMINCLUDE /epoc32/include/ecom +SYSTEMINCLUDE /epoc32/include/icl + +START RESOURCE ../src/thumbnailimageprovider.rss +END + +LIBRARY euser.lib +LIBRARY ecom.lib +LIBRARY efsrv.lib +LIBRARY imageconversion.lib +LIBRARY fbscli.lib +LIBRARY exiflib.lib +LIBRARY iclextjpegapi.lib +LIBRARY apmime.lib + +DEBUGLIBRARY flogger.lib + +PAGED +BYTEPAIRCOMPRESSTARGET diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/plugins/image/inc/thumbnailimagedecoder.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/plugins/image/inc/thumbnailimagedecoder.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,235 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Image thumbnail decoder. + * +*/ + + +#ifndef THUMBNAILIMAGEDECODER_H +#define THUMBNAILIMAGEDECODER_H + +#include "thumbnailprovider.h" + +class CImageDecoder; +class CFbsBitmap; + +// Size of buffer to load from file start to get EXIF thumbnail +const TInt KJpegLoadBufferSize = 64 * 1024; + + +/** + * Image thumbnail decoder. + * + * @since S60 v5.0 + */ +class CThumbnailImageDecoder: public CActive + { +public: + + /** + * C++ default constructor + * + * @since S60 v5.0 + * @param aFs File server session + * @return New image thumbnail decoder instance. + */ + CThumbnailImageDecoder( RFs& aFs ); + + /** + * Destructor + * + * @since S60 v5.0 + */ + virtual ~CThumbnailImageDecoder(); + + /** + * Creates a decoder from the given image file and gets image + * information + * + * @since S60 v5.0 + * @param aFile Source image file. + * @param aObserver Observer to relay notifications about completed + * operations. + * @param aFlags Decoding option flags. + * @param aMimeType Mime-type of image to be decoded. + * @param aSize desired size of thumbnail. + * @param aRotateIfNeeded If ETrue rectangle is rotated to maximize the decoded size (full screen images only) + */ + void CreateL( RFile64& aFile, MThumbnailProviderObserver& aObserver, const + CThumbnailManager::TThumbnailQualityPreference aFlags, const TDataType& aMimeType, + const TSize& aSize ); + + /** + * Creates a decoder from the given image buffer and gets image + * information + * + * @since S60 v5.0 + * @param aBuffer Source image buffer. + * @param aObserver Observer to relay notifications about completed + * operations. + * @param aFlags Decoding option flags. + * @param aMimeType Mime-type of image to be decoded. + * @param aSize desired size of thumbnail. + * @param aRotateIfNeeded If ETrue rectangle is rotated to maximize the decoded size (full screen images only) + */ + void CreateL( const TDesC8* aBuffer, MThumbnailProviderObserver& + aObserver, const CThumbnailManager::TThumbnailQualityPreference aFlags, const + TDataType& aMimeType, const TSize& aSize); + + /** + * Decode image. + * + * @since S60 v5.0 + * @param aDisplayMode Preferred display mode. + */ + void DecodeL( const TDisplayMode aDisplayMode, const CThumbnailManager::TThumbnailFlags aFlags ); + + /** + * Returns the size of original image. + * + * @since S60 v5.0 + * @return Size of original image. + */ + const TSize& OriginalSize()const; + +private: + /** + * Used to release reserved resources. + * + * @since S60 v5.0 + */ + void Release(); + + /** + * Implements cancellation of an outstanding request. + * + * @since S60 v5.0 + */ + void DoCancel(); + + /** + * Handles an active object's request completion event. + * + * @since S60 v5.0 + */ + void RunL(); + + /** + * Used to check if source is jpg/jpeg image. + * + * @since S60 v5.0 + * @return ETrue if image was jpg/jpeg format, otherwise EFalse + */ + TBool IsJpeg(); + + /** + * Used to check if source is svg image. + * + * @since S60 v5.0 + * @return ETrue if image was in svg format, otherwise EFalse + */ + TBool IsSvg(); + + /** + * Creates image decoder to be used. + * + * @since S60 v5.0 + */ + void CreateDecoderL( CThumbnailManager::TThumbnailQualityPreference aFlags ); + + /** + * Creates ExifDecoder. + * + * @since S60 v5.0 + */ + void CreateExifDecoderL( CThumbnailManager::TThumbnailQualityPreference aFlags ); + +private: + // data + + /** + * Requested size. + */ + TSize iSize; + + /** + * Image decoder. + * Own. + */ + CImageDecoder* iDecoder; + + /** + * Decoded bitmap. + * Own. + */ + CFbsBitmap* iBitmap; + + /** + * Image info flags (from TFrameInfo) + */ + TUint32 iFrameInfoFlags; + + /** + * Original size of the image in pixels. + */ + TSize iOriginalSize; + + /** + * Buffer for reading the beginning of a JPEG file to get the + * EXIF thumbnail data. + */ + HBufC8* iJpegReadBuffer; + + /** + * EXIF thumbnail image compressed as JPEG + */ + HBufC8* iExifThumbImage; + + /** + * Used fileserver. + */ + RFs& iFs; + + /** + * File from which thumbnail is to be created. + */ + RFile64 iFile; + + /** + * Buffer from which thumbnail is to be created. + */ + const TDesC8* iBuffer; + + /** + * Observer. + */ + MThumbnailProviderObserver* iObserver; // not own + + /** + * Mime-type. + */ + TDataType iMimeType; + + /** + * Is origin EXIF + */ + TBool iEXIF; + + /** + * Portrait image + */ + TBool iPortrait; +}; + +#endif // THUMBNAILIMAGEDECODER_H diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/plugins/image/inc/thumbnailimagedecoderv2.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/plugins/image/inc/thumbnailimagedecoderv2.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,136 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Image thumbnail decoderv2. + * +*/ + + +#ifndef THUMBNAILIMAGEDECODERV2_H +#define THUMBNAILIMAGEDECODERV2_H + +#include "thumbnailprovider.h" + +class CImageDecoder; +class CFbsBitmap; + +/** + * Image thumbnail decoder. + * + * @since S60 v5.0 + */ +class CThumbnailImageDecoderv2: public CActive + { +public: + + /** + * C++ default constructor + * + * @since S60 v5.0 + * @param aFs File server session + * @return New image thumbnail decoder instance. + */ + CThumbnailImageDecoderv2( RFs& aFs); + + /** + * Destructor + * + * @since S60 v5.0 + */ + virtual ~CThumbnailImageDecoderv2(); + + /** + * Creates a decoder from the given image buffer and gets image + * information + * + * @since S60 v5.0 + * @param aBuffer Source image buffer. + * @param aObserver Observer to relay notifications about completed + * operations. + */ + void CreateL(TDesC8& aBuffer, MThumbnailProviderObserver& aObserver); + + /** + * Decode image. + * + * @since S60 v5.0 + * @param aDisplayMode Preferred display mode. + */ + void DecodeL(); + +private: + /** + * Used to release reserved resources. + * + * @since S60 v5.0 + */ + void Release(); + + /** + * Implements cancellation of an outstanding request. + * + * @since S60 v5.0 + */ + void DoCancel(); + + /** + * Handles an active object's request completion event. + * + * @since S60 v5.0 + */ + void RunL(); + + /** + * Creates image decoder to be used. + * + * @since S60 v5.0 + */ + void CreateDecoderL(); + +private: + // data + + /** + * Image decoder. + * Own. + */ + CImageDecoder* iDecoder; + + /** + * Original size of the image in pixels. + */ + TSize iOriginalSize; + + /** + * Decoded bitmap. + * Own. + */ + CFbsBitmap* iBitmap; + + /** + * Used fileserver. + */ + RFs& iFs; + + /** + * Buffer from which thumbnail is to be created. + */ + TDesC8* iBuffer; + + /** + * Observer. + */ + MThumbnailProviderObserver* iObserver; // not own +}; + +#endif // THUMBNAILIMAGEDECODERV2_H diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/plugins/image/inc/thumbnailimageprovider.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/plugins/image/inc/thumbnailimageprovider.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,132 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Image thumbnail provider plugin. + * +*/ + + +#ifndef THUMBNAILIMAGEPROVIDER_H +#define THUMBNAILIMAGEPROVIDER_H + +#include "thumbnailprovider.h" + +class CThumbnailImageDecoder; +class CThumbnailImageDecoderv2; + +/** + * Image thumbnail provider plugin. + * + * @since S60 v5.0 + */ +class CThumbnailImageProvider: public CThumbnailProvider + { + +public: + + /** + * Two-phased constructor. + * + * @since S60 v5.0 + * @return New image thumbnail provider instance. + */ + static CThumbnailImageProvider* NewL(); + + /** + * Destructor + * + * @since S60 v5.0 + */ + virtual ~CThumbnailImageProvider(); + + /** + * Function that will provide thumbnail from given parameters. + * + * @since S60 v5.0 + * @param aFs File server session + * @param aFile Source image file. + * @param aMimeType MIME-type of the image file. + * @param aFlags Flags for thumbnail creation. + * @param aDisplayMode Used display mode. + */ + void GetThumbnailL( RFs& aFs, RFile64& aFile, const TDataType& aMimeType, + const CThumbnailManager::TThumbnailFlags aFlags, const TDisplayMode + aDisplayMode, const CThumbnailManager::TThumbnailQualityPreference aQualityPreference ); + + /** + * Function that will provide thumbnail from given parameters. + * + * @since S60 v5.0 + * @param aFs File server session + * @param aBuffer Source image buffer. + * @param aMimeType MIME-type of the image file. + * @param aFlags Flags for thumbnail creation. + * @param aDisplayMode Used display mode. + */ + void GetThumbnailL( RFs& aFs, TDesC8* aBuffer, const + TDataType& aMimeType, const CThumbnailManager::TThumbnailFlags aFlags, + const TDisplayMode aDisplayMode, const CThumbnailManager::TThumbnailQualityPreference aQualityPreference ); + + /** + * Function that will provide thumbnail from given parameters. + * + * @since S60 v5.0 + * @param aFs File server session + * @param aBuffer Source image buffer. + */ + void GetThumbnailL( RFs& aFs, TDesC8& aBuffer); + + /** + * Cancel a previous thumbnail request, if any. + * + * @since S60 5.0 + */ + void CancelGetThumbnail(); + +private: + + /** + * C++ default constructor + * + * @since S60 v5.0 + * @return New image thumbnail provider instance. + */ + CThumbnailImageProvider(); + +private: + + /** + * Thumbnail decoder. + */ + CThumbnailImageDecoder* iImageDecoder; + + /** + * Thumbnail decoderv2. + */ + CThumbnailImageDecoderv2* iImageDecoderv2; + + /** + * File server session. + * Not own. + */ + RFs iFs; + + /** + * Mime-type of image + */ + TDataType iMimeType; +}; + +#include "thumbnailprovider.inl" + +#endif // THUMBNAILIMAGEPROVIDER_H diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/plugins/image/src/thumbnailimagedecoder.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/plugins/image/src/thumbnailimagedecoder.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,591 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Image thumbnail decoder + * +*/ + + + +//INCLUDE FILES +#include +#include +#include +#include + +#include +#include "thumbnailimagedecoder.h" +#include "thumbnaillog.h" +#include "thumbnailpanic.h" + +const TUid KImageTypeSVGUid = + { + 0x102073E7 +}; + +// CImageDecoder supports up to 1/8 size reduction if EFullyScaleable is +// not set. +const TInt KMaximumReductionFactor = 8; + +// Matchers for recognizing JPEG files +_LIT( KJpegMime, "image/jpeg" ); + +// Matcher for recognizing SVG files +_LIT( KSvgMime, "image/svg+xml" ); + + + +// ============================ MEMBER FUNCTIONS =============================== + +// --------------------------------------------------------------------------- +// CThumbnailImageDecoder::CThumbnailImageDecoder() +// C++ default constructor can NOT contain any code, that might leave. +// --------------------------------------------------------------------------- +// +CThumbnailImageDecoder::CThumbnailImageDecoder( RFs& aFs ): CActive( + EPriorityStandard ), iFs( aFs ) + { + CActiveScheduler::Add( this ); + } + + +// --------------------------------------------------------------------------- +// CThumbnailImageDecoder::~CThumbnailImageDecoder() +// Destructor. +// --------------------------------------------------------------------------- +// +CThumbnailImageDecoder::~CThumbnailImageDecoder() + { + Release(); + } + + +// ----------------------------------------------------------------------------- +// CThumbnailImageDecoder::CreateL() +// Creates thumbnail of image +// ----------------------------------------------------------------------------- +// +void CThumbnailImageDecoder::CreateL( RFile64& aFile, MThumbnailProviderObserver& + aObserver, const CThumbnailManager::TThumbnailQualityPreference aQualityPreference, const + TDataType& aMimeType, const TSize& aSize) + { + TN_DEBUG1( "CThumbnailImageDecoder::CreateL() start" ); + + iBuffer = NULL; + iSize = aSize; + iMimeType = aMimeType; + iObserver = &aObserver; + iFile = aFile; + + CreateDecoderL( aQualityPreference ); + + const TFrameInfo info( iDecoder->FrameInfo()); + if (( info.iOverallSizeInPixels.iWidth < 1 ) || ( + info.iOverallSizeInPixels.iHeight < 1 )) + { + User::Leave( KErrCorrupt ); + } + iFrameInfoFlags = info.iFlags; + iOriginalSize = info.iOverallSizeInPixels; + + TN_DEBUG1( "CThumbnailImageDecoder::CreateL() end" ); + } + + +// ----------------------------------------------------------------------------- +// CThumbnailImageDecoder::CreateL() +// Creates thumbnail of image +// ----------------------------------------------------------------------------- +// +void CThumbnailImageDecoder::CreateL( const TDesC8* aBuffer, MThumbnailProviderObserver& + aObserver, const CThumbnailManager::TThumbnailQualityPreference aQualityPreference, const + TDataType& aMimeType, const TSize& aSize) + { + TN_DEBUG1( "CThumbnailImageDecoder::CreateL() start" ); + + iSize = aSize; + iMimeType = aMimeType; + iObserver = &aObserver; + iBuffer = aBuffer; + + CreateDecoderL( aQualityPreference ); + + const TFrameInfo info( iDecoder->FrameInfo()); + if (( info.iOverallSizeInPixels.iWidth < 1 ) || ( + info.iOverallSizeInPixels.iHeight < 1 )) + { + User::Leave( KErrCorrupt ); + } + iFrameInfoFlags = info.iFlags; + iOriginalSize = info.iOverallSizeInPixels; + + TN_DEBUG1( "CThumbnailImageDecoder::CreateL() end" ); + } + +// ----------------------------------------------------------------------------- +// CThumbnailImageDecoder::DecodeL() +// Decode the thumbnail image +// ----------------------------------------------------------------------------- +// +void CThumbnailImageDecoder::DecodeL( const TDisplayMode aDisplayMode, const CThumbnailManager::TThumbnailFlags aFlags) + { + TN_DEBUG1( "CThumbnailImageDecoder::DecodeL() start" ); + + // Create the bitmap + if ( !iBitmap ) + { + iBitmap = new( ELeave )CFbsBitmap(); + } + + TN_DEBUG3( "CThumbnailImageDecoder::DecodeL() %d x %d", iSize.iWidth, iSize.iHeight ); + if( iOriginalSize.iWidth < iOriginalSize.iHeight ) + { + TInt height = iSize.iHeight; + iSize.iHeight = iSize.iWidth; + iSize.iWidth = height; + iPortrait = ETrue; + TN_DEBUG3( "CThumbnailImageDecoder::DecodeL() %d x %d", iSize.iWidth, iSize.iHeight ); + } + else + { + iPortrait = EFalse; + } + + TN_DEBUG3( "CThumbnailImageDecoder::DecodeL() iOriginalSize = %d x %d", iOriginalSize.iWidth, iOriginalSize.iHeight ); + + //Size in both x and y dimension must be non-zero, positive value + TSize loadSize( iOriginalSize) ; + + + if(iOriginalSize.iHeight < iSize.iHeight || iOriginalSize.iWidth < iSize.iWidth ) + { + loadSize = iOriginalSize; + TN_DEBUG1( "CThumbnailImageDecoder::DecodeL() LoadSize is OriginalSize" ); + } + else if((iFrameInfoFlags& TFrameInfo::EFullyScaleable || IsSvg()) && aFlags == !CThumbnailManager::ECropToAspectRatio) + { + loadSize = iSize; + TN_DEBUG1( "CThumbnailImageDecoder::DecodeL() EFullyScaleable start" ); + const TReal32 srcAspect = static_cast < TReal32 > ( + iOriginalSize.iWidth ) / iOriginalSize.iHeight; + + // set loadsize to maximum size within target size + if ( (loadSize.iHeight * srcAspect) <= loadSize.iWidth ) + { + TReal trg = 0; + TReal src( loadSize.iHeight * srcAspect ); + Math::Round( trg, src, 0 ); + loadSize.SetSize( trg, loadSize.iHeight ); + } + else + { + TReal trg; + TReal src( loadSize.iWidth / srcAspect ); + Math::Round( trg, src, 0 ); + loadSize.SetSize( loadSize.iWidth, trg ); + } + + TN_DEBUG3( "CThumbnailImageDecoder::DecodeL() EFullyScaleable loadSize = %d x %d", loadSize.iWidth, loadSize.iHeight ); + } + else + { + + // Size reduction factor. 1/1, 1/2, 1/4, and 1/8 are possible values for all + // plug-ins. SVG graphics can be rendered at any size. + TInt reductionFactor = 1; + while ( reductionFactor < KMaximumReductionFactor && ( iSize.iWidth < + loadSize.iWidth / 2 ) && ( iSize.iHeight < loadSize.iHeight / 2 )) + { + // magic: use loadSize that is half of previous size + loadSize.iWidth /= 2; + loadSize.iHeight /= 2; + reductionFactor *= 2; + } + // If original size is not an exact multiple of reduction factor, + // we need to round loadSize up + if ( reductionFactor && iOriginalSize.iWidth % reductionFactor ) + { + loadSize.iWidth++; + } + if ( reductionFactor && iOriginalSize.iHeight % reductionFactor ) + { + loadSize.iHeight++; + } + TN_DEBUG4( + "CThumbnailImageDecoder::DecodeL() - loadSize = (%d,%d) reduction = 1/%d ", loadSize.iWidth, loadSize.iHeight, reductionFactor ); + } + + User::LeaveIfError( iBitmap->Create( loadSize, aDisplayMode )); + + iDecoder->Convert( &iStatus, * iBitmap ); + while ( iStatus == KErrUnderflow ) + { + iDecoder->ContinueConvert( &iStatus ); + } + + SetActive(); + + TN_DEBUG1( "CThumbnailImageDecoder::DecodeL() end" ); + } + + +// ----------------------------------------------------------------------------- +// CThumbnailImageDecoder::Release() +// Releases resources +// ----------------------------------------------------------------------------- +// +void CThumbnailImageDecoder::Release() + { + Cancel(); + delete iJpegReadBuffer; + iJpegReadBuffer = NULL; + delete iExifThumbImage; + iExifThumbImage = NULL; + delete iDecoder; + iDecoder = NULL; + } + + +// ----------------------------------------------------------------------------- +// CThumbnailImageDecoder::DoCancel() +// ----------------------------------------------------------------------------- +// +void CThumbnailImageDecoder::DoCancel() + { + if ( iDecoder ) + { + iDecoder->Cancel(); + delete iJpegReadBuffer; + iJpegReadBuffer = NULL; + delete iExifThumbImage; + iExifThumbImage = NULL; + delete iDecoder; + iDecoder = NULL; + } + } + + +// ----------------------------------------------------------------------------- +// CThumbnailImageDecoder::RunL() +// ----------------------------------------------------------------------------- +// +void CThumbnailImageDecoder::RunL() + { + // This call takes ownership of iBitmap + iObserver->ThumbnailProviderReady( iStatus.Int(), iBitmap, iOriginalSize, iEXIF, iPortrait ); + + iBitmap = NULL; // owned by server now + Release(); + } + + +// ----------------------------------------------------------------------------- +// CThumbnailImageDecoder::IsJpeg() +// ----------------------------------------------------------------------------- +// +TBool CThumbnailImageDecoder::IsJpeg() + { + __ASSERT_DEBUG(( iMimeType.Des() != KNullDesC ), ThumbnailPanic( + EThumbnailEmptyDescriptor )); + + if ( KJpegMime() == iMimeType.Des()) + { + return ETrue; + } + return EFalse; + } + + +// ----------------------------------------------------------------------------- +// CThumbnailImageDecoder::IsSvg() +// ----------------------------------------------------------------------------- +// +TBool CThumbnailImageDecoder::IsSvg() + { + __ASSERT_DEBUG(( iMimeType.Des() != KNullDesC ), ThumbnailPanic( + EThumbnailEmptyDescriptor )); + + if ( KSvgMime() == iMimeType.Des()) + { + return ETrue; + } + return EFalse; + } + + +// ----------------------------------------------------------------------------- +// CThumbnailImageDecoder::CreateDecoderL +// Creates image decoder +// ----------------------------------------------------------------------------- +// +void CThumbnailImageDecoder::CreateDecoderL( CThumbnailManager::TThumbnailQualityPreference + aFlags ) + { + TN_DEBUG1( "CThumbnailImageDecoder::CreateDecoderL() start" ); + + TBool thumbFound( EFalse ); + + // If the image is in jpeg format, try to get thumbnail from EXIF data (if EOptimizeForQuality not set) + if ( IsJpeg() && !( aFlags == CThumbnailManager::EOptimizeForQuality )) + { + TN_DEBUG1( "CThumbnailImageDecoder::CreateDecoderL() crete exif decoder" ); + TRAPD( err, CreateExifDecoderL( aFlags )); + thumbFound = ( err == KErrNone ); + iEXIF = ETrue; + } + + if ( !thumbFound ) + { + iEXIF = EFalse; + TN_DEBUG1( "CThumbnailImageDecoder::CreateDecoderL() crete normal decoder" ); + + delete iDecoder; + iDecoder = NULL; + + TFileName fullName; + if ( !iBuffer ) + { + iFile.FullName( fullName ); + } + + CImageDecoder::TOptions options; + if ( aFlags == CThumbnailManager::EOptimizeForQuality ) + { + options = ( CImageDecoder::TOptions )( CImageDecoder + ::EOptionNoDither ); + } + else + { + options = ( CImageDecoder::TOptions )( CImageDecoder + ::EOptionNoDither | CImageDecoder::EPreferFastDecode ); + } + + if ( IsSvg()) + { + if ( !iBuffer ) + { + iDecoder = CImageDecoder::FileNewL( iFile, ContentAccess::EPeek, + options, KImageTypeSVGUid, KNullUid, KNullUid ); + + TN_DEBUG1( "CThumbnailImageDecoder::CreateDecoderL() - CImageDecoder created" ); + } + else + { + TRAPD( decErr, iDecoder = CImageDecoder::DataNewL( iFs, *iBuffer, options, KImageTypeSVGUid ) ); + + if ( decErr != KErrNone ) + { + TN_DEBUG1( "CThumbnailImageDecoder::CreateDecoderL() - error 1" ); + + User::Leave( decErr ); + } + + TN_DEBUG1( "CThumbnailImageDecoder::CreateDecoderL() - CImageDecoder created" ); + } + } + else if ( !IsJpeg()) + { + if ( !iBuffer ) + { + iDecoder = CImageDecoder::FileNewL( iFile, ContentAccess::EPeek, options ); + + TN_DEBUG1( "CThumbnailImageDecoder::CreateDecoderL() - CImageDecoder created" ); + } + else + { + TRAPD( decErr, iDecoder = CImageDecoder::DataNewL( iFs, *iBuffer, iMimeType.Des8(), options) ); + + if ( decErr != KErrNone ) + { + // don't force any mime type + TRAPD( decErr, iDecoder = CImageDecoder::DataNewL( iFs, *iBuffer, options ) ); + if ( decErr != KErrNone ) + { + TN_DEBUG1( "CThumbnailImageDecoder::CreateDecoderL() - error 2" ); + + User::Leave( decErr ); + } + } + + TN_DEBUG1( "CThumbnailImageDecoder::CreateDecoderL() - CImageDecoder created" ); + } + } + else + { + + if ( !iBuffer ) + { + TRAPD( decErr, iDecoder = CExtJpegDecoder::FileNewL( + CExtJpegDecoder::EHwImplementation, iFs, fullName, options) ); + + if ( decErr != KErrNone ) + { + TRAP( decErr, iDecoder = CExtJpegDecoder::FileNewL( + CExtJpegDecoder::ESwImplementation, iFs, fullName, options) ); + + if ( decErr != KErrNone ) + { + iDecoder = CImageDecoder::FileNewL( iFile, ContentAccess::EPeek, options ); + + TN_DEBUG1( "CThumbnailImageDecoder::CreateDecoderL() - CImageDecoder created" ); + } + else + { + TN_DEBUG1( "CThumbnailImageDecoder::CreateDecoderL() - SW CExtJpegDecoder created" ); + } + } + else + { + TN_DEBUG1( "CThumbnailImageDecoder::CreateDecoderL() - HW CExtJpegDecoder created" ); + } + } + else + { + TRAPD( decErr, iDecoder = CExtJpegDecoder::DataNewL( + CExtJpegDecoder::EHwImplementation, iFs, *iBuffer, options )); + + if ( decErr != KErrNone ) + { + TRAP( decErr, iDecoder = CExtJpegDecoder::DataNewL( + CExtJpegDecoder::ESwImplementation, iFs, *iBuffer, options )); + + if ( decErr != KErrNone ) + { + TRAPD( decErr, iDecoder = CImageDecoder::DataNewL( iFs, *iBuffer, iMimeType.Des8(), options) ); + + if ( decErr != KErrNone ) + { + // don't force any mime type + TRAPD( decErr, iDecoder = CImageDecoder::DataNewL( iFs, *iBuffer, options ) ); + if ( decErr != KErrNone ) + { + TN_DEBUG1( "CThumbnailImageDecoder::CreateDecoderL() - error 3" ); + + User::Leave( decErr ); + } + } + + TN_DEBUG1( "CThumbnailImageDecoder::CreateDecoderL() - CImageDecoder created" ); + } + else + { + TN_DEBUG1( "CThumbnailImageDecoder::CreateDecoderL() - SW CExtJpegDecoder created" ); + } + } + else + { + TN_DEBUG1( "CThumbnailImageDecoder::CreateDecoderL() - HW CExtJpegDecoder created" ); + } + } + } + } + + TN_DEBUG1( "CThumbnailImageDecoder::CreateDecoderL() end" ); + } + + +// ----------------------------------------------------------------------------- +// CThumbnailImageDecoder::CreateExifDecoderL() +// ----------------------------------------------------------------------------- +// +void CThumbnailImageDecoder::CreateExifDecoderL( CThumbnailManager + ::TThumbnailQualityPreference aFlags ) + { + TN_DEBUG1( "CThumbnailImageDecoder::CreateExifDecoderL() start" ); + + // If the image is in jpeg format, try to get thumbnail from EXIF data. + CExifRead* reader = NULL; + + if ( !iBuffer ) + { + TInt64 size( 0 ); + User::LeaveIfError( iFile.Size( size )); + + TInt readSize = Min( size, KJpegLoadBufferSize ); + + delete iJpegReadBuffer; + iJpegReadBuffer = NULL; + iJpegReadBuffer = HBufC8::NewL( readSize ); + TPtr8 localBuffer = iJpegReadBuffer->Des(); + + User::LeaveIfError( iFile.Read( localBuffer, readSize )); + reader = CExifRead::NewL( localBuffer, CExifRead::ENoJpeg ); + } + else + { + reader = CExifRead::NewL( *iBuffer, CExifRead::ENoJpeg ); + } + + + CleanupStack::PushL( reader ); + + iExifThumbImage = reader->GetThumbnailL(); + CleanupStack::PopAndDestroy( reader ); + + User::LeaveIfNull( iExifThumbImage ); + + delete iDecoder; + iDecoder = NULL; + + CImageDecoder::TOptions options; + if ( aFlags == CThumbnailManager::EOptimizeForQuality ) + { + options = ( CImageDecoder::TOptions )( CImageDecoder::EOptionNoDither ); + } + else + { + options = ( CImageDecoder::TOptions )( CImageDecoder::EOptionNoDither | + CImageDecoder::EPreferFastDecode ); + } + + TRAPD( err, iDecoder = CExtJpegDecoder::DataNewL( iFs, * iExifThumbImage, + options )); + + if ( err == KErrNotFound || err == KErrNotSupported ) + { + delete iDecoder; + iDecoder = NULL; + + iDecoder = CImageDecoder::DataNewL( iFs, * iExifThumbImage, options ); + } + else + { + TN_DEBUG2( "CThumbnailImageDecoder::CreateExifDecoderL() - CExtJpegDecoder err == %d", err ); + User::LeaveIfError( err ); + } + +/* + // If the Exif thumbnail is smaller than requested it will not be used + TFrameInfo frame = iDecoder->FrameInfo( 0 ); + + if ( frame.iOverallSizeInPixels.iWidth < iSize.iWidth || + frame.iOverallSizeInPixels.iHeight < iSize.iHeight ) + { + User::Leave( KErrGeneral ); + } + */ + TN_DEBUG1( "CThumbnailImageDecoder::CreateExifDecoderL() end" ); + } + + +// ----------------------------------------------------------------------------- +// CThumbnailImageDecoder::CreateExifDecoderL() +// Returns size of original image +// ----------------------------------------------------------------------------- +// +const TSize& CThumbnailImageDecoder::OriginalSize()const + { + return iOriginalSize; + } + +//End of file diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/plugins/image/src/thumbnailimagedecoderv2.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/plugins/image/src/thumbnailimagedecoderv2.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,199 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Image thumbnail decoder + * +*/ + + +//INCLUDE FILES +#include +#include +#include + +#include +#include "thumbnailimagedecoderv2.h" +#include "thumbnaillog.h" +#include "thumbnailpanic.h" +#include "thumbnailmanagerconstants.h" + +// ============================ MEMBER FUNCTIONS =============================== +//------------------------------------------------------------------------ +// CThumbnailImageDecoder::CThumbnailImageDecoder() +// C++ default constructor can NOT contain any code, that might leave. +// --------------------------------------------------------------------------- +// +CThumbnailImageDecoderv2::CThumbnailImageDecoderv2( RFs& aFs): CActive( + EPriorityStandard ), iFs( aFs ) + { + CActiveScheduler::Add( this ); + } + + +// --------------------------------------------------------------------------- +// CThumbnailImageDecoder::~CThumbnailImageDecoder() +// Destructor. +// --------------------------------------------------------------------------- +// +CThumbnailImageDecoderv2::~CThumbnailImageDecoderv2() + { + Release(); + } + + +// ----------------------------------------------------------------------------- +// CThumbnailImageDecoder::CreateL() +// Creates thumbnail of image +// ----------------------------------------------------------------------------- +// +void CThumbnailImageDecoderv2::CreateL(TDesC8& aBuffer, MThumbnailProviderObserver& aObserver) + { + TN_DEBUG1( "CThumbnailImageDecoderv2::CreateL() start" ); + + iBuffer = &aBuffer; + iObserver = &aObserver; + + CreateDecoderL(); + + TN_DEBUG1( "CThumbnailImageDecoderv2::CreateL() end" ); + } + +// ----------------------------------------------------------------------------- +// CThumbnailImageDecoder::DecodeL() +// Decode the thumbnail image +// ----------------------------------------------------------------------------- +// +void CThumbnailImageDecoderv2::DecodeL( ) + { + TN_DEBUG1( "CThumbnailImageDecoderv2::DecodeL() start" ); + + // Create the bitmap + if ( !iBitmap ) + { + iBitmap = new( ELeave )CFbsBitmap(); + } + + //set displaymode from global constants + User::LeaveIfError( iBitmap->Create( iDecoder->FrameInfo().iOverallSizeInPixels, iDecoder->FrameInfo().iFrameDisplayMode) ); + + iDecoder->Convert( &iStatus, * iBitmap ); + while ( iStatus == KErrUnderflow ) + { + iDecoder->ContinueConvert( &iStatus ); + } + SetActive(); + + TN_DEBUG1( "CThumbnailImageDecoderv2::DecodeL() end" ); + } + + +// ----------------------------------------------------------------------------- +// CThumbnailImageDecoder::Release() +// Releases resources +// ----------------------------------------------------------------------------- +// +void CThumbnailImageDecoderv2::Release() + { + Cancel(); + delete iDecoder; + iDecoder = NULL; + } + + +// ----------------------------------------------------------------------------- +// CThumbnailImageDecoder::DoCancel() +// ----------------------------------------------------------------------------- +// +void CThumbnailImageDecoderv2::DoCancel() + { + if ( iDecoder ) + { + iDecoder->Cancel(); + delete iDecoder; + iDecoder = NULL; + } + } + + +// ----------------------------------------------------------------------------- +// CThumbnailImageDecoder::RunL() +// ----------------------------------------------------------------------------- +// +void CThumbnailImageDecoderv2::RunL() + { + // This call takes ownership of iBitmap + // EXIF always false + // Rotated always false + iObserver->ThumbnailProviderReady( iStatus.Int(), iBitmap, iOriginalSize, EFalse, EFalse); + + iBitmap = NULL; // owned by server now + iBuffer = NULL; + Release(); + } + + +// ----------------------------------------------------------------------------- +// CThumbnailImageDecoder::CreateDecoderL +// Creates image decoder +// ----------------------------------------------------------------------------- +// +void CThumbnailImageDecoderv2::CreateDecoderL() + { + TN_DEBUG1( "CThumbnailImageDecoderv2::CreateDecoderL() start" ); + + delete iDecoder; + iDecoder = NULL; + + CImageDecoder::TOptions options = ( CImageDecoder::TOptions )( + CImageDecoder::EOptionNoDither | CImageDecoder::EPreferFastDecode ); + + TRAPD( decErr, iDecoder = CExtJpegDecoder::DataNewL( + CExtJpegDecoder::EHwImplementation, iFs, *iBuffer, options )); + + if ( decErr != KErrNone ) + { + TRAP( decErr, iDecoder = CExtJpegDecoder::DataNewL( + CExtJpegDecoder::ESwImplementation, iFs, *iBuffer, options )); + + if ( decErr != KErrNone ) + { + TRAP( decErr, iDecoder = CImageDecoder::DataNewL( iFs, *iBuffer, KJpegMime(), options ) ); + + if ( decErr != KErrNone ) + { + // don't force any mime type + TRAPD( decErr, iDecoder = CImageDecoder::DataNewL( iFs, *iBuffer, options ) ); + if ( decErr != KErrNone ) + { + TN_DEBUG1( "CThumbnailImageDecoderv2::CreateDecoderL() - error" ); + + User::Leave( decErr ); + } + } + + TN_DEBUG1( "CThumbnailImageDecoderv2::CreateDecoderL() - CImageDecoder created" ); + } + else + { + TN_DEBUG1( "CThumbnailImageDecoderv2:CreateDecoderL() - SW CExtJpegDecoder created" ); + } + } + else + { + TN_DEBUG1( "CThumbnailImageDecoderv2::CreateDecoderL() - HW CExtJpegDecoder created" ); + } + + TN_DEBUG1( "CThumbnailImageDecoderv2::CreateDecoderL() end" ); + } + +//End of file diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/plugins/image/src/thumbnailimageprovider.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/plugins/image/src/thumbnailimageprovider.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,196 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Image thumbnail provider plugin + * +*/ + + +#include +#include + +#include "thumbnailimageprovider.h" +#include "thumbnailimagedecoder.h" +#include "thumbnailimagedecoderv2.h" +#include "thumbnailmanageruids.hrh" +#include "thumbnaillog.h" +#include "thumbnailmanagerconstants.h" + +#ifndef IMPLEMENTATION_PROXY_ENTRY +typedef TAny* TProxyNewLPtr; +#define IMPLEMENTATION_PROXY_ENTRY(aUid, aFuncPtr) \ +{ {aUid}, static_cast(aFuncPtr) } +#endif + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CThumbnailImageProvider::NewL() +// Two-phased constructor. +// --------------------------------------------------------------------------- +// +CThumbnailImageProvider* CThumbnailImageProvider::NewL() + { + CThumbnailImageProvider* self = new( ELeave )CThumbnailImageProvider(); + return self; + } + + +// --------------------------------------------------------------------------- +// CThumbnailImageProvider::CThumbnailImageProvider() +// C++ default constructor can NOT contain any code, that might leave. +// --------------------------------------------------------------------------- +// +CThumbnailImageProvider::CThumbnailImageProvider() + { + TN_DEBUG1( "CThumbnailImageProvider::CThumbnailImageProvider()" ); + } + + +// --------------------------------------------------------------------------- +// CThumbnailImageProvider::~CThumbnailImageProvider() +// Destructor. +// --------------------------------------------------------------------------- +// +CThumbnailImageProvider::~CThumbnailImageProvider() + { + TN_DEBUG1( "CThumbnailImageProvider::~CThumbnailImageProvider()" ); + delete iImageDecoder; + delete iImageDecoderv2; + REComSession::DestroyedImplementation( iDtor_ID_Key ); + } + + +// --------------------------------------------------------------------------- +// CThumbnailImageProvider::GetThumbnailL() +// Provides the thumbnail image +// --------------------------------------------------------------------------- +// +void CThumbnailImageProvider::GetThumbnailL( RFs& aFs, RFile64& aFile, const + TDataType& aMimeType, const CThumbnailManager::TThumbnailFlags aFlags, + const TDisplayMode /*aDisplayMode*/, const CThumbnailManager::TThumbnailQualityPreference aQualityPreference ) + { + TN_DEBUG1( "CThumbnailImageProvider::GetThumbnailL() start" ); + + if ( !iImageDecoder ) + { + iImageDecoder = new( ELeave )CThumbnailImageDecoder( aFs ); + } + + iMimeType = aMimeType; + iFlags = aFlags; + iQualityPreference = aQualityPreference; + //set default mode displaymode from global constants + iDisplayMode = KStoreDisplayMode; + + iImageDecoder->CreateL( aFile, *iObserver, iQualityPreference, iMimeType, iTargetSize ); + iOriginalSize = iImageDecoder->OriginalSize(); + iImageDecoder->DecodeL( iDisplayMode, iFlags ); + + TN_DEBUG1( "CThumbnailImageProvider::GetThumbnailL() end" ); + } + +// --------------------------------------------------------------------------- +// CThumbnailImageProvider::GetThumbnailL() +// Provides the thumbnail image +// --------------------------------------------------------------------------- +// +void CThumbnailImageProvider::GetThumbnailL( RFs& aFs, TDesC8* aBuffer, const + TDataType& aMimeType, const CThumbnailManager::TThumbnailFlags aFlags, + const TDisplayMode /*aDisplayMode*/, const CThumbnailManager::TThumbnailQualityPreference aQualityPreference ) + { + TN_DEBUG1( "CThumbnailImageProvider::GetThumbnailL() start" ); + + if ( !iImageDecoder ) + { + iImageDecoder = new( ELeave )CThumbnailImageDecoder( aFs ); + } + + iMimeType = aMimeType; + iFlags = aFlags; + iQualityPreference = aQualityPreference; + //set default mode displaymode from global constants + iDisplayMode = KStoreDisplayMode; + + iImageDecoder->CreateL( aBuffer, *iObserver, iQualityPreference, iMimeType, iTargetSize ); + iOriginalSize = iImageDecoder->OriginalSize(); + iImageDecoder->DecodeL( iDisplayMode, iFlags ); + + TN_DEBUG1( "CThumbnailImageProvider::GetThumbnailL() end" ); + } + +// --------------------------------------------------------------------------- +// CThumbnailImageProvider::GetThumbnailL() +// Provides the thumbnail image +// --------------------------------------------------------------------------- +// +void CThumbnailImageProvider::GetThumbnailL( RFs& aFs, TDesC8& aBuffer) + { + TN_DEBUG1( "CThumbnailImageProvider::GetThumbnailL() start" ); + + if ( !iImageDecoderv2 ) + { + iImageDecoderv2 = new( ELeave )CThumbnailImageDecoderv2( aFs); + } + + iImageDecoderv2->CreateL(aBuffer, *iObserver); + + iImageDecoderv2->DecodeL(); + + TN_DEBUG1( "CThumbnailImageProvider::GetThumbnailL() end" ); + } + +// --------------------------------------------------------------------------- +// Cancel thumbnail request +// --------------------------------------------------------------------------- +// +void CThumbnailImageProvider::CancelGetThumbnail() + { + if ( iImageDecoder ) + { + iImageDecoder->Cancel(); + } + if ( iImageDecoderv2) + { + iImageDecoderv2->Cancel(); + } + } + +// ======== GLOBAL FUNCTIONS ======== + +// ----------------------------------------------------------------------------- +// ImplementationTable +// Define the interface UIDs +// ----------------------------------------------------------------------------- +// +const TImplementationProxy ImplementationTable[] = + { + IMPLEMENTATION_PROXY_ENTRY( THUMBNAIL_IMAGE_PROVIDER_IMP_UID, + CThumbnailImageProvider::NewL ) +}; + + +// ----------------------------------------------------------------------------- +// ImplementationGroupProxy +// The one and only exported function that is the ECom entry point +// ----------------------------------------------------------------------------- +// +EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& + aTableCount ) + { + aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy ); + return ImplementationTable; + } + +//End of file diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/plugins/image/src/thumbnailimageprovider.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/plugins/image/src/thumbnailimageprovider.rss Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Image thumbnail provider plugin resource file +* +*/ + + +#include "registryinfov2.rh" +#include "thumbnailmanageruids.hrh" + +RESOURCE REGISTRY_INFO theInfo +{ +// resource_format_version must always be set as follows +resource_format_version = RESOURCE_FORMAT_VERSION_2; + +// Normal plug-in parameters +dll_uid = THUMBNAIL_IMAGE_PROVIDER_DLL_UID; +interfaces = + { + INTERFACE_INFO + { + interface_uid = THUMBNAIL_PROVIDER_IF_UID; + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = THUMBNAIL_IMAGE_PROVIDER_IMP_UID; + version_no = 1; + display_name = ""; + default_data = ""; + opaque_data = "image/*"; + rom_only = 0; + } + }; + } + }; +} + diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/plugins/video/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/plugins/video/group/bld.inf Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Build information file for project ?myapp +* +*/ + + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_MMPFILES +thumbnailvideoprovider.mmp + diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/plugins/video/group/thumbnailvideoprovider.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/plugins/video/group/thumbnailvideoprovider.mmp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Video thumbnail provider plugin +* +*/ + + +// To get the MW_LAYER_SYSTEMINCLUDE-definition +#include + +#include "../../../inc/thumbnailmanageruids.hrh" + +TARGET thumbnailvideoprovider.dll +CAPABILITY CAP_ECOM_PLUGIN +TARGETTYPE PLUGIN + +UID 0x10009D8D THUMBNAIL_VIDEO_PROVIDER_DLL_UID +VENDORID VID_DEFAULT + +SOURCEPATH ../src +SOURCE thumbnailvideoprovider.cpp + +// Default system include paths for middleware layer modules. +MW_LAYER_SYSTEMINCLUDE + +USERINCLUDE ../inc +USERINCLUDE ../../../inc + +SYSTEMINCLUDE /epoc32/include/ecom + +START RESOURCE ../src/thumbnailvideoprovider.rss +END + +LIBRARY euser.lib +LIBRARY ecom.lib +LIBRARY tneengine.lib +LIBRARY efsrv.lib +LIBRARY fbscli.lib + +DEBUGLIBRARY flogger.lib + +PAGED +BYTEPAIRCOMPRESSTARGET + +// End of File + + diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/plugins/video/inc/thumbnailvideoprovider.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/plugins/video/inc/thumbnailvideoprovider.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,155 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Video thumbnail provider. + * +*/ + + +#ifndef THUMBNAILVIDEOPROVIDER_H +#define THUMBNAILVIDEOPROVIDER_H + +#include +#include + +#include "thumbnailprovider.h" + +/** + * Video thumbnail provider plugin. + * + * @since S60 v5.0 + */ +class CThumbnailVideoProvider: public CThumbnailProvider, public CActive, + public MTNEVideoClipThumbObserver, public MTNEVideoClipInfoObserver + { +public: + + /** + * Two-phased constructor. + * + * @since S60 v5.0 + * @return New video thumbnail provider instance. + */ + static CThumbnailVideoProvider* NewL(); + + /** + * Destructor + * + * @since S60 v5.0 + */ + virtual ~CThumbnailVideoProvider(); + + /** + * Function that will provide thumbnail from given parameters. + * + * @since S60 v5.0 + * @param aFs File server session + * @param aFile Source image file. + * @param aMimeType Mime-type of the clip to be processed. + * @param aFlags Flags for thumbnail creation. + * @param aDisplayMode Used display mode. + */ + void GetThumbnailL( RFs& aFs, RFile64& aFile, const TDataType& aMimeType, + const CThumbnailManager::TThumbnailFlags aFlags, const TDisplayMode + aDisplayMode, const CThumbnailManager::TThumbnailQualityPreference aQualityPreference ); + + /** + * Function that will provide thumbnail from given parameters. + * + * @since S60 v5.0 + * @param aFs File server session + * @param aBuffer Source image buffer. + * @param aMimeType Mime-type of the clip to be processed. + * @param aFlags Flags for thumbnail creation. + * @param aDisplayMode Used display mode. + */ + void GetThumbnailL( RFs& aFs, TDesC8* aBuffer, const + TDataType& aMimeType, const CThumbnailManager::TThumbnailFlags aFlags, + const TDisplayMode aDisplayMode, const CThumbnailManager::TThumbnailQualityPreference aQualityPreference ); + + /** + * Function that will provide thumbnail from given parameters. + * + * @since S60 v5.0 + * @param aFs File server session + * @param aBuffer Source image buffer. + */ + + void GetThumbnailL( RFs& aFs, TDesC8& aBuffer); + /** + * Cancel a previous thumbnail request, if any. + * + * @since S60 5.0 + */ + void CancelGetThumbnail(); + +protected: + + /** + * Notifies when video clip thumbnail is ready. + * + * @since S60 v5.0 + * @param aInfo Video clip info. + * @param aError Error code. + * @param aThumb Thumbnail image. + */ + void NotifyVideoClipThumbCompleted( CTNEVideoClipInfo& aInfo, TInt aError, + CFbsBitmap* aThumb ); + + /** + * Notifies when info about video clip is ready. + * + * @since S60 v5.0 + * @param aInfo Video clip info. + * @param aError Error code. + */ + void NotifyVideoClipInfoReady( CTNEVideoClipInfo& aInfo, TInt aError ); + +private: + + /** + * C++ default constructor + * + * @since S60 v5.0 + * @return New video thumbnail provider instance. + */ + CThumbnailVideoProvider(); + + /** + * Implements cancellation of an outstanding request. + * + * @since S60 v5.0 + */ + void DoCancel(); + + /** + * Handles an active object's request completion event. + * + * @since S60 v5.0 + */ + void RunL(); + +private: + // data + + /** + * Video clip info. + */ + CTNEVideoClipInfo* iVideoClipInfo; + + RTimer iTimer; + TBool iTimeout; + +}; + +#endif // THUMBNAILVIDEOPROVIDER_H diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/plugins/video/src/thumbnailvideoprovider.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/plugins/video/src/thumbnailvideoprovider.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,286 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Video thumbnail provider + * +*/ + + +#include +#include +#include +#include + +#include "thumbnailvideoprovider.h" +#include "thumbnailmanageruids.hrh" +#include "thumbnailmanagerconstants.h" +#include "thumbnaillog.h" + +#ifndef IMPLEMENTATION_PROXY_ENTRY +typedef TAny* TProxyNewLPtr; +#define IMPLEMENTATION_PROXY_ENTRY(aUid, aFuncPtr) \ +{ {aUid}, static_cast(aFuncPtr) } +#endif + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CThumbnailVideoProvider::NewL() +// Two-phased constructor. +// --------------------------------------------------------------------------- +// +CThumbnailVideoProvider* CThumbnailVideoProvider::NewL() + { + CThumbnailVideoProvider* self = new( ELeave )CThumbnailVideoProvider(); + return self; + } + + +// --------------------------------------------------------------------------- +// CThumbnailImageProvider::CThumbnailImageProvider() +// C++ default constructor can NOT contain any code, that might leave. +// --------------------------------------------------------------------------- +// +CThumbnailVideoProvider::CThumbnailVideoProvider():CActive( EPriorityStandard ) + { + CActiveScheduler::Add( this ); + + iTimer.CreateLocal(); + iTimeout = EFalse; + + TN_DEBUG1( "CThumbnailVideoProvider::CThumbnailVideoProvider()" ); + } + + +// --------------------------------------------------------------------------- +// CThumbnailVideoProvider::~CThumbnailVideoProvider() +// Destructor. +// --------------------------------------------------------------------------- +// +CThumbnailVideoProvider::~CThumbnailVideoProvider() + { + // run DoCancel even if not active + if ( IsActive() ) + { + Cancel(); + } + else + { + DoCancel(); + } + + iTimer.Close(); + + TN_DEBUG1( "CThumbnailVideoProvider::~CThumbnailVideoProvider()" ); + REComSession::DestroyedImplementation( iDtor_ID_Key ); + } +// ----------------------------------------------------------------------------- +// CThumbnailVideoProvider::DoCancel() +// ----------------------------------------------------------------------------- +// +void CThumbnailVideoProvider::DoCancel() + { + iTimer.Cancel(); + + if ( iVideoClipInfo ) + { + iVideoClipInfo->CancelThumb(); + + delete iVideoClipInfo; + iVideoClipInfo = NULL; + } + } + + +// ----------------------------------------------------------------------------- +// CThumbnailImageDecoder::RunL() +// ----------------------------------------------------------------------------- +// +void CThumbnailVideoProvider::RunL() + { + DoCancel(); + + // video thumbnail engine doesn't respond + if (iTimeout) + { + iObserver->ThumbnailProviderReady( KErrNotSupported, NULL, TSize(), EFalse, EFalse); + iTimeout = EFalse; + + TN_DEBUG1( "CThumbnailVideoProvider::RunL() - timeout" ); + } + } + +// --------------------------------------------------------------------------- +// CThumbnailVideoProvider::GetThumbnailL() +// Provides the thumbnail image of video clip +// --------------------------------------------------------------------------- +// +void CThumbnailVideoProvider::GetThumbnailL( RFs& /*aFs*/, RFile64& aFile, const + TDataType& /*aMimeType*/, const CThumbnailManager::TThumbnailFlags aFlags, + const TDisplayMode /*aDisplayMode*/, const CThumbnailManager::TThumbnailQualityPreference /*aQualityPreference */) + { + TN_DEBUG1( "CThumbnailVideoProvider::GetThumbnailL() start" ); + + iFlags = aFlags; + //set default mode displaymode from global constants + iDisplayMode = KStoreDisplayMode; + + TFileName filename; + User::LeaveIfError( aFile.FullName( filename )); + + TRAPD( err, iVideoClipInfo = CTNEVideoClipInfo::NewL( filename, * this )); + + if ( err != KErrNone ) + { + User::Leave( KErrCorrupt ); + } + + TN_DEBUG1( "CThumbnailVideoProvider::GetThumbnailL() end" ); + } + +// --------------------------------------------------------------------------- +// CThumbnailVideoProvider::GetThumbnailL() +// --------------------------------------------------------------------------- +// +void CThumbnailVideoProvider::GetThumbnailL( RFs& /*aFs*/, + TDesC8* /* aBuffer */, + const TDataType& /* aMimeType */, + const CThumbnailManager::TThumbnailFlags /*aFlags*/, + const TDisplayMode /* aDisplayMode */, + const CThumbnailManager::TThumbnailQualityPreference /*aQualityPreference */) + { + TN_DEBUG1( "CThumbnailVideoProvider::GetThumbnailL() - nothing to do" ); + } + +// --------------------------------------------------------------------------- +// CThumbnailVideoProvider::GetThumbnailL() +// --------------------------------------------------------------------------- +// +void CThumbnailVideoProvider::GetThumbnailL( RFs& /*aFs*/, TDesC8& /*aBuffer*/) + { + TN_DEBUG1( "CThumbnailVideoProvider::GetThumbnailL() - nothing to do" ); + } + +// --------------------------------------------------------------------------- +// Cancel thumbnail request +// --------------------------------------------------------------------------- +// +void CThumbnailVideoProvider::CancelGetThumbnail() + { + // run DoCancel even if not active + if ( IsActive() ) + { + Cancel(); + } + else + { + DoCancel(); + } + } + +// --------------------------------------------------------------------------- +// CThumbnailVideoProvider::NotifyVideoClipThumbCompleted() +// Used to notify when thumbnail image of video clip is ready +// --------------------------------------------------------------------------- +// +void CThumbnailVideoProvider::NotifyVideoClipThumbCompleted( CTNEVideoClipInfo& + /*aInfo*/, TInt aError, CFbsBitmap* aThumb ) + { + TN_DEBUG2( "CThumbnailVideoProvider::NotifyVideoClipThumbCompleted(aError=%d)", aError ); + + iTimer.Cancel(); + iTimeout = EFalse; + + if (( aError == KErrNone ) && aThumb ) + { + iOriginalSize = aThumb->SizeInPixels(); + } + + iObserver->ThumbnailProviderReady( aError, aThumb, iOriginalSize, EFalse, EFalse); + } + + +// --------------------------------------------------------------------------- +// CThumbnailVideoProvider::NotifyVideoClipInfoReady() +// Used to notify when information of video clip is available +// --------------------------------------------------------------------------- +// +void CThumbnailVideoProvider::NotifyVideoClipInfoReady( CTNEVideoClipInfo& + aInfo, TInt aError ) + { + TN_DEBUG2( "CThumbnailVideoProvider::NotifyVideoClipInfoReady(aError=%d)", aError ); + + if ( aError == KErrNone ) + { + TInt err( KErrNone ); + + // cannot determine target size, aspect ratio scaling fails + TRAP( err, aInfo.GetThumbL( *this, KBestThumbIndex, NULL, iDisplayMode, ETrue )); + + if ( err != KErrNone ) + { + TN_DEBUG2( "CThumbnailVideoProvider::NotifyVideoClipInfoReady() -- GetThumbL() left with %d", err ); + + iObserver->ThumbnailProviderReady( err, NULL, TSize(), EFalse, EFalse); + + SetActive(); + TRequestStatus* statusPtr = &iStatus; + User::RequestComplete( statusPtr, KErrNone ); + } + else + { + // request timeout + iTimeout = ETrue; + iTimer.After(iStatus, KVideoDecoderTimeout); + SetActive(); + } + } + else + { + iObserver->ThumbnailProviderReady( aError, NULL, TSize(), EFalse, EFalse); + + SetActive(); + TRequestStatus* statusPtr = &iStatus; + User::RequestComplete( statusPtr, KErrNone ); + } + } + + +// ======== GLOBAL FUNCTIONS ======== + +// ----------------------------------------------------------------------------- +// ImplementationTable +// Define the interface UIDs +// ----------------------------------------------------------------------------- +// +const TImplementationProxy ImplementationTable[] = + { + IMPLEMENTATION_PROXY_ENTRY( THUMBNAIL_VIDEO_PROVIDER_IMP_UID, + CThumbnailVideoProvider::NewL ) +}; + + +// ----------------------------------------------------------------------------- +// ImplementationGroupProxy +// The one and only exported function that is the ECom entry point +// ----------------------------------------------------------------------------- +// +EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& + aTableCount ) + { + aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy ); + + return ImplementationTable; + } + +// End of file diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/plugins/video/src/thumbnailvideoprovider.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/plugins/video/src/thumbnailvideoprovider.rss Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Video thumbnail provider plugin resource file +* +*/ + + +#include "registryinfov2.rh" +#include "thumbnailmanageruids.hrh" + +RESOURCE REGISTRY_INFO theInfo +{ +// resource_format_version must always be set as follows +resource_format_version = RESOURCE_FORMAT_VERSION_2; + +// Normal plug-in parameters +dll_uid = THUMBNAIL_VIDEO_PROVIDER_DLL_UID; +interfaces = + { + INTERFACE_INFO + { + interface_uid = THUMBNAIL_PROVIDER_IF_UID; + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = THUMBNAIL_VIDEO_PROVIDER_IMP_UID; + version_no = 1; + display_name = ""; + default_data = ""; + opaque_data = "video/*"; + rom_only = 0; + } + }; + } + }; +} diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/rom/thumbagdaemon.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/rom/thumbagdaemon.iby Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Iby file +* +*/ + + +#ifdef RD_THUMBNAILMANAGER + +#ifndef THUMBAGDAEMON_IBY +#define THUMBAGDAEMON_IBY + +file=ABI_DIR\BUILD_DIR\thumbagdaemon.exe PROGRAMS_DIR\thumbagdaemon.exe + +#endif // THUMBNAILMANAGER_IBY + +#endif // RD_THUMBNAILMANAGER diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/rom/thumbnailmanager.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/rom/thumbnailmanager.iby Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Iby file +* +*/ + + +#ifdef RD_THUMBNAILMANAGER + +#ifndef THUMBNAILMANAGER_IBY +#define THUMBNAILMANAGER_IBY + +file=ABI_DIR\BUILD_DIR\thumbnailmanager.dll SHARED_LIB_DIR\thumbnailmanager.dll +file=ABI_DIR\BUILD_DIR\thumbnailserver.exe PROGRAMS_DIR\thumbnailserver.exe + +ECOM_PLUGIN(thumbnailvideoprovider.dll, thumbnailvideoprovider.rsc) +ECOM_PLUGIN(thumbnailimageprovider.dll, thumbnailimageprovider.rsc) +ECOM_PLUGIN(thumbnailaudioprovider.dll, thumbnailaudioprovider.rsc) + +data=ZSYSTEM\install\thumbnailmanager_stub.sis system\install\thumbnailmanager_stub.sis + +#endif // THUMBNAILMANAGER_IBY + +#endif // RD_THUMBNAILMANAGER diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/ThumbnailManager_0x102830AB_v9.20.2_SA_S60.50_Euro1.sis Binary file imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/ThumbnailManager_0x102830AB_v9.20.2_SA_S60.50_Euro1.sis has changed diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/depends.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/depends.xml Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,25 @@ + + + + + 1 + Thumbnail Manager + Upgrade package for Thumbnail Manager + + + + S60 + + 5 + 0 + + 2009 + 1 + + + + + + + \ No newline at end of file diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/package.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/package.pkg Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,39 @@ +; +; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +; Languages +&EN + +; Header +#{"Thumbnail Manager"},(0x102830AB), 9, 20, 2, TYPE=SA, RU + +; Localised Vendor name +%{"Nokia"} + +; Unique Vendor name +:"Nokia" + +;Files +@"..\thumbnailmanagercenrep\thumbnailmanagercenrep.sisx",(0x10202BE9) +"\epoc32\release\armv5\urel\thumbnailserver.exe"-"c:\sys\bin\thumbnailserver.exe" +"\epoc32\release\armv5\urel\thumbagdaemon.exe"-"c:\sys\bin\thumbagdaemon.exe" +"\epoc32\release\armv5\urel\thumbnailmanager.dll"-"c:\sys\bin\thumbnailmanager.dll" +"\epoc32\release\armv5\urel\thumbnailimageprovider.dll"-"c:\sys\bin\thumbnailimageprovider.dll" +"\epoc32\release\armv5\urel\thumbnailvideoprovider.dll"-"c:\sys\bin\thumbnailvideoprovider.dll" +"\epoc32\release\armv5\urel\thumbnailaudioprovider.dll"-"c:\sys\bin\thumbnailaudioprovider.dll" +"\epoc32\data\z\resource\plugins\thumbnailimageprovider.rsc"-"c:\resource\plugins\thumbnailimageprovider.rsc" +"\epoc32\data\z\resource\plugins\thumbnailvideoprovider.rsc"-"c:\resource\plugins\thumbnailvideoprovider.rsc" +"\epoc32\data\z\resource\plugins\thumbnailaudioprovider.rsc"-"c:\resource\plugins\thumbnailaudioprovider.rsc" +"\epoc32\release\armv5\urel\tmiadrestart.exe"-"c:\sys\bin\tmiadrestart.exe",FILERUN,RB \ No newline at end of file diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/stub.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/stub.pkg Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,28 @@ +; +; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +; Languages +&EN + +; Header +#{"ThumbnailManager"},(0x102830AB), 9, 20, 1, TYPE=SA + +; Localised Vendor name +%{"Nokia"} + +; Unique Vendor name +:"Nokia" + +;Files diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/thumbnailmanager_stub.sis Binary file imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/thumbnailmanager_stub.sis has changed diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/sis/thumbnailmanagercenrep/package.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/sis/thumbnailmanagercenrep/package.pkg Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,29 @@ +; +; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +; Languages +&EN + +; Header +#{"Thumbnail Manager Cenrep"},(0x10202BE9), 9, 20, 2, TYPE=SP + +; Localised Vendor name +%{"Symbian Software Ltd."} + +; Unique Vendor name +:"Symbian Software Ltd." + +;Files +"..\..\conf\102830B0.txt"-"c:\private\10202be9\102830B0.txt" diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbagdaemon/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbagdaemon/group/bld.inf Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Build information file +* +*/ + + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_MMPFILES +thumbagdaemon.mmp + + +// End of File + + diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbagdaemon/group/thumbagdaemon.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbagdaemon/group/thumbagdaemon.mmp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Project definition file +* +*/ + + +#include +#include +#include "../../inc/thumbnailmanageruids.hrh" + +VERSION 10.0 +TARGET thumbagdaemon.exe +TARGETTYPE EXE +UID 0x0 THUMBAGDAEMON_UID + +#ifdef WINSCW +EPOCHEAPSIZE 4096 0x200000 // heap 2MB +#else +EPOCHEAPSIZE 4096 0x800000 // max heap 8MB +#endif + +CAPABILITY ALL -AllFiles -DRM -TCB +VENDORID VID_DEFAULT + +EPOCPROCESSPRIORITY background + +SOURCEPATH ../src +SOURCE thumbagdaemon.cpp +SOURCE thumbagprocessor.cpp +SOURCE ../../thumbnailserver/src/tmshutdownobserver.cpp +SOURCE thumbagformatobserver.cpp + +// Default system include paths for middleware layer modules. +MW_LAYER_SYSTEMINCLUDE + +USERINCLUDE ../inc +USERINCLUDE ../../inc +USERINCLUDE ../../thumbnailserver/inc + +LIBRARY euser.lib +LIBRARY mdeclient.lib +LIBRARY thumbnailmanager.lib +LIBRARY centralrepository.lib +LIBRARY harvesterclient.lib +LIBRARY bafl.lib +LIBRARY mpxcollectionhelper.lib mpxcollectionutility.lib mpxcommon.lib + +DEBUGLIBRARY flogger.lib + +PAGED +BYTEPAIRCOMPRESSTARGET + +// End of File + + diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbagdaemon/inc/thumbagdaemon.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbagdaemon/inc/thumbagdaemon.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,156 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Thumbnail Auto Generate Daemon + * +*/ + + +#ifndef THUMBAGDAEMON_H +#define THUMBAGDAEMON_H + +#include +#include + +#include + +#include "thumbagprocessor.h" +#include "tmshutdownobserver.h" +#include "thumbnaillog.h" + + +/** + * ThumbAG daemon. + * + * @since S60 v5.0 + */ +NONSHARABLE_CLASS( CThumbAGDaemon ): public CServer2, + public MMdESessionObserver, + public MMdEObjectObserver, + public MTMShutdownObserver, + public MMdEObjectPresentObserver + + { +public: + + /** + * Two-phased constructor + * + * @since S60 v5.0 + * @return New CThumbAGDaemon server. + */ + static CThumbAGDaemon* NewLC(); + + /** + * Two-phased constructor + * + * @since S60 v5.0 + * @return New CThumbAGDaemon server. + */ + static CThumbAGDaemon* NewL(); + + /** + * Destructor + * + * @since S60 v5.0 + */ + virtual ~CThumbAGDaemon(); + +public: + + /** + * Creates new server session. + * + * @since S60 v5.0 + * @param aVersion Version info. + * @param aMessage Message to be passed. + * @return New session. + */ + CSession2* NewSessionL( const TVersion& aVersion, + const RMessage2& aMessage ) const; + + /** + * ThreadFunctionL + * + * @since S60 v5.0 + */ + static void ThreadFunctionL(); + +public: + + // from MMdESessionObserver + void HandleSessionOpened( CMdESession& aSession, TInt aError ); + void HandleSessionError( CMdESession& aSession, TInt aError ); + + // from MMdEObjectObserver + void HandleObjectNotification(CMdESession& aSession, + TObserverNotificationType aType, + const RArray& aObjectIdArray); + + void HandleObjectPresentNotification(CMdESession& aSession, + TBool aPresent, const RArray& aObjectIdArray); + + // from MTMShutdownObserver + void ShutdownNotification(); + +protected: + + /** + * AddObserversL + * + * @since S60 v5.0 + */ + void AddObserversL(); + + /** + * Check if daemon needs to run + * + * @since S60 v5.0 + */ + TBool DaemonEnabledL(); + +private: + + /** + * C++ default constructor + * + * @since S60 v5.0 + * @return New CThumbAGDaemon instance. + */ + CThumbAGDaemon(); + + /** + * Symbian 2nd phase constructor can leave. + * + * @since S60 v5.0 + */ + void ConstructL(); + +private: + + // own + CTMShutdownObserver* iShutdownObserver; + CTMShutdownObserver* iMDSShutdownObserver; + CMdESession* iMdESession; + CThumbAGProcessor* iProcessor; + + TBool iShutdown; + +#ifdef _DEBUG + TUint32 iAddCounter; + TUint32 iModCounter; + TUint32 iDelCounter; +#endif +}; + +#endif // THUMBAGDAEMON_H diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbagdaemon/inc/thumbagformatobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbagdaemon/inc/thumbagformatobserver.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,94 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Monitors File system for Format events +* +*/ + + +#ifndef CTHUMBAGFORMATOBSERVER_H +#define CTHUMBAGFORMATOBSERVER_H + +#include +#include "f32file.h" +#include "thumbagprocessor.h" + +/** + * File System monitor class to monitor for format events + * + * @lib thumbnailsserver.exe + * @since S60 3.0 + */ +NONSHARABLE_CLASS( CThumbAGFormatObserver ) : public CBase, + public MBackupOperationObserver + { + +public: + + /** + * Two-phase constructor + * @param aObserver observer to the monitor + */ + static CThumbAGFormatObserver* NewL( CThumbAGProcessor* aProcessor ); + + /** + * Two-phase constructor + * @param aObserver observer to the monitor + */ + static CThumbAGFormatObserver* NewLC( CThumbAGProcessor* aProcessor ); + + /** + * Destructor + */ + virtual ~CThumbAGFormatObserver(); + +public: // New functions + + /** + * Polls for the current monitor status + * If an event is happening, it will callback the observer of the event + */ + void PollStatus(); + +protected: // Base Class + + /* + * From MBackupOperationObserver + * Notifies this class of the backup event. + * MMC App will signal a start / end. + */ + void HandleBackupOperationEventL(const TBackupOperationAttributes& aBackupOperationAttributes); + +private: + + /** + * C++ constructor + * aObserver observer to this event + */ + CThumbAGFormatObserver ( CThumbAGProcessor* aProcessor ); + + /* + * Second phased constructor + */ + void ConstructL(); + +private: // data + + CThumbAGProcessor* iProcessor; + + CBaBackupSessionWrapper* iBackupSession; + + + }; + +#endif // CTHUMBAGFORMATOBSERVER_H diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbagdaemon/inc/thumbagprocessor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbagdaemon/inc/thumbagprocessor.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,296 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Processor + * +*/ + + +#ifndef THUMBAGPROCESSOR_H +#define THUMBAGPROCESSOR_H + +#include +#include +#include +#include +#include +#include +#include "thumbnaillog.h" +#include +#include +#include + +//FORWARD DECLARATIONS +class CThumbAGFormatObserver; +class MMPXCollectionUtility; + +/** + * Processor object for handling thumb generation + * + * @since S60 v5.0 + */ +class CThumbAGProcessor: public CActive, + public MThumbnailManagerObserver, + public MMdEQueryObserver, + public MHarvesterEventObserver, + public MMPXCollectionObserver + { +public: + + /** + * Two-phased constructor. + * + * @since S60 v5.0 + * @return Instance of CThumbAGProcessor. + */ + static CThumbAGProcessor* NewL(); + + /** + * Destructor + * + * @since S60 v5.0 + */ + virtual ~CThumbAGProcessor(); + +public: + + // From MMdEQueryObserver + void HandleQueryNewResults( CMdEQuery& aQuery, + TInt aFirstNewItemIndex, + TInt aNewItemCount ); + void HandleQueryCompleted( CMdEQuery& aQuery, TInt aError ); + + // from MThumbnailManagerObserver + void ThumbnailPreviewReady( MThumbnailData& aThumbnail, TThumbnailRequestId aId ); + void ThumbnailReady( TInt aError, MThumbnailData& aThumbnail, TThumbnailRequestId aId ); + + // from MHarvesterEventObserver + void HarvestingUpdated( + HarvesterEventObserverType aHEObserverType, + HarvesterEventState aHarvesterEventState, + TInt aItemsLeft ); + +private: // From MMPXCollectionObserver + /// See @ref MMPXCollectionObserver::HandleCollectionMessageL + void HandleCollectionMessage( CMPXMessage* aMessage, TInt aError ); + + /// See @ref MMPXCollectionObserver::HandleOpenL + void HandleOpenL(const CMPXMedia& aEntries, TInt aIndex, TBool aComplete, TInt aError); + + /// See @ref MMPXCollectionObserver::HandleOpenL + void HandleOpenL(const CMPXCollectionPlaylist& aPlaylist, TInt aError); + + /// See @ref MMPXCollectionObserver::HandleCollectionMediaL + void HandleCollectionMediaL( const CMPXMedia& aMedia, TInt aError ); + +public: + + /** + * Sets MdE Session + * + * @since S60 v5.0 + * @param aMdESession MdE Session + */ + void SetMdESession( CMdESession* aMdESession ); + + /** + * Adds new IDs to queue + * + * @since S60 v5.0 + * @param aType TObserverNotificationType + * @param aIDArray IDs for thumbnail creation + * @param aForce pass ETrue if processor is forced to run without waiting harvesting complete + */ + void AddToQueueL( TObserverNotificationType aType, const RArray& aIDArray, TBool aPresent ); + + /** + * Calls Thumbnail Manager to create thumbnails + * + * @since S60 v5.0 + * @param aObject MdEObject + */ + void CreateThumbnailsL( const CMdEObject* aObject ); + + /** + * Remove IDs from queue + * + * @since S60 v5.0 + * @param aIDArray IDs for thumbnail creation + */ + void RemoveFromQueues( const RArray& aIDArray, const TBool aRemoveFromDelete = EFalse); + + void SetForceRun( const TBool aForceRun ); + + void SetFormat(TBool aStatus); + + void QueryForPlaceholdersL(); + +protected: + + /** + * QueryL + * + * @since S60 v5.0 + * @param aIDArray Item IDs to query + */ + void QueryL( RArray& aIDArray ); + +protected: + + /** + * Handles an active object's request completion event. + * + * @since S60 v5.0 + */ + void RunL(); + + /** + * Implements cancellation of an outstanding request. + * + * @since S60 v5.0 + */ + void DoCancel(); + + /** + * Implements RunL error handling. + * + * @since S60 v5.0 + */ + TInt RunError(TInt aError); + +private: + + /** + * C++ default constructor + * + * @since S60 v5.0 + * @return Instance of CThumbAGProcessor. + */ + CThumbAGProcessor(); + + /** + * Symbian 2nd phase constructor can leave. + * + * @since S60 v5.0 + */ + void ConstructL(); + + /** + * Activate AO + * + * @since S60 v5.0 + */ + void ActivateAO(); + + /** + * Callback for harvesting complete timer + * + * @since S60 v5.0 + */ + static TInt PeriodicTimerCallBack(TAny* aAny); + + /** + * Check auto creation values from cenrep + * + * @since S60 v5.0 + */ + void CheckAutoCreateValuesL(); + + /** + * Start timeout timer + * + * @since S60 v5.0 + */ + void StartTimeout(); + + /** + * Cancel timeout timer + * + * @since S60 v5.0 + */ + void CancelTimeout(); + +private: + + // not own + CMdESession* iMdESession; + CMdENamespaceDef* iDefNamespace; + + // own + CThumbnailManager* iTMSession; + CMdEObjectQuery* iQuery; + CMdEObjectQuery* iQueryForPlaceholders; + + RArray iAddQueue; + RArray iModifyQueue; + RArray iRemoveQueue; + RArray iPresentQueue; + RArray iQueryQueue; + + RArray iTempModifyQueue; + RArray iTempAddQueue; + + RArray iPlaceholderIDs; + + TBool iQueryActive; + TBool iQueryReady; + + TBool iQueryForPlaceholdersActive; + + TBool iModify; + TInt iProcessingCount; + + //Flag is MDS Harvester harevsting + TBool iHarvesting; + TBool iHarvestingTemp; + + CPeriodic* iPeriodicTimer; + TBool iTimerActive; + + //MDS Harvester client + RHarvesterClient iHarvesterClient; + + //Set when running RunL() first time + TBool iInit; + + // auto create + TBool iAutoImage; + TBool iAutoVideo; + TBool iAutoAudio; + +#ifdef _DEBUG + TUint32 iAddCounter; + TUint32 iModCounter; + TUint32 iDelCounter; +#endif + + TBool iForceRun; + //request pending in TNM side + TBool iActive; + //PS key to get info server's idle status + RProperty iProperty; + + CThumbAGFormatObserver* iFormatObserver; + + TBool iFormatting; + TBool iSessionDied; + + TInt iActiveCount; + + MMPXCollectionUtility* iCollectionUtility; // own + + //Flag is MPX harvesting or MTP synchronisation in progress + TBool iMPXHarvesting; +}; + +#endif // THUMBAGPROCESSOR_H diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbagdaemon/inc/thumblog.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbagdaemon/inc/thumblog.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Log commands +* +*/ + + +#ifndef THUMBLOG_H +#define THUMBLOG_H + +#include +#include + +#ifdef _DEBUG + +#define WLOG(a) RDebug::Print(_L(a)) +#define WLOG1(a,b) RDebug::Print(_L(a),(b)) +#define WLOG2(a,b,c) RDebug::Print(_L(a),(b),(c)) +#define WLOG3(a,b,c,d) RDebug::Print(_L(a),(b),(c),(d)) + +#define HLOG(a) RDebug::Print((a)) +#define HLOG1(a, b) RDebug::Print((a), (b)) +#define HLOG2(a, b, c) RDebug::Print((a), (b), (c)) +#define HLOG3(a, b, c, d) RDebug::Print((a), (b), (c), (d)) +#define HLOG4(a, b, c, d, e) RDebug::Print((a), (b), (c), (d), (e)) +#define HLOG5(a, b, c, d, e, f) RDebug::Print((a), (b), (c), (d), (e), (f)) + +#else + +#define WLOG(a) +#define WLOG1(a,b) +#define WLOG2(a,b,c) +#define WLOG3(a,b,c,d) + +#define HLOG(a) +#define HLOG1(a, b) +#define HLOG2(a, b, c) +#define HLOG3(a, b, c, d) +#define HLOG4(a, b, c, d, e) +#define HLOG5(a, b, c, d, e, f) + +#endif + +#endif // THUMBLOG_H diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbagdaemon/src/thumbagdaemon.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbagdaemon/src/thumbagdaemon.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,472 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Thumbnail Auto Generate Daemon +* +*/ + + +#include +#include + +#include +#include +#include +#include + +#include "thumbagdaemon.h" +#include "thumbnaillog.h" +#include "thumbnailmanagerconstants.h" +#include "thumbnailmanagerprivatecrkeys.h" + + +// --------------------------------------------------------------------------- +// NewLC +// --------------------------------------------------------------------------- +// +CThumbAGDaemon* CThumbAGDaemon::NewLC() + { + TN_DEBUG1( "CThumbAGDaemon::NewLC() - begin" ); + + CThumbAGDaemon* self = new (ELeave) CThumbAGDaemon(); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + +// --------------------------------------------------------------------------- +// NewL +// --------------------------------------------------------------------------- +// +CThumbAGDaemon* CThumbAGDaemon::NewL() + { + TN_DEBUG1( "CThumbAGDaemon::NewL() - begin" ); + + CThumbAGDaemon* self = CThumbAGDaemon::NewLC(); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------------------------- +// CThumbAGDaemon +// --------------------------------------------------------------------------- +// +CThumbAGDaemon::CThumbAGDaemon() + : CServer2( CActive::EPriorityStandard, CServer2::EUnsharableSessions ) + { + // No implementation required + } + +// --------------------------------------------------------------------------- +// ConstructL +// --------------------------------------------------------------------------- +// +void CThumbAGDaemon::ConstructL() + { + TN_DEBUG1( "CThumbAGDaemon::ConstructL() - begin" ); + + StartL( KTAGDaemonName ); + +#ifdef _DEBUG + iAddCounter = 0; + iModCounter = 0; + iDelCounter = 0; +#endif + + if (DaemonEnabledL()) + { + TN_DEBUG1( "CThumbAGDaemon::ConstructL() - create observers" ); + + // create shutdown observer + iMDSShutdownObserver = CTMShutdownObserver::NewL( *this, KMdSPSShutdown, KMdSShutdown, EFalse ); + iShutdownObserver = CTMShutdownObserver::NewL( *this, KTAGDPSNotification, KShutdown, ETrue ); + iShutdown = EFalse; + + // create processor + iProcessor = NULL; + iProcessor = CThumbAGProcessor::NewL(); + + TN_DEBUG1( "CThumbAGDaemon::ConstructL() - connect to MDS" ); + + // connect to MDS + iMdESession = NULL; + iMdESession = CMdESession::NewL( *this ); + } + else + { + // no error here, but need to shutdown daemon neatly + User::Leave(KErrNone); + } + + TN_DEBUG1( "CThumbAGDaemon::ConstructL() - end" ); + } + +// --------------------------------------------------------------------------- +// ~CThumbAGDaemon +// --------------------------------------------------------------------------- +// +CThumbAGDaemon::~CThumbAGDaemon() + { + TN_DEBUG1( "CThumbAGDaemon::~CThumbAGDaemon() - begin" ); + + iShutdown = ETrue; + + delete iMDSShutdownObserver; + delete iShutdownObserver; + + if (iProcessor) + { + delete iProcessor; + iProcessor = NULL; + } + + if (iMdESession) + { + // 3 observers + TRAP_IGNORE( iMdESession->RemoveObjectObserverL( *this ) ); + TRAP_IGNORE( iMdESession->RemoveObjectObserverL( *this ) ); + TRAP_IGNORE( iMdESession->RemoveObjectObserverL( *this ) ); + TRAP_IGNORE(iMdESession->RemoveObjectPresentObserverL( * this )); + + delete iMdESession; + iMdESession = NULL; + } + + TN_DEBUG1( "CThumbAGDaemon::~CThumbAGDaemon() - end" ); + } + +// ----------------------------------------------------------------------------- +// CThumbnailServer::NewSessionL() +// ----------------------------------------------------------------------------- +// +CSession2* CThumbAGDaemon::NewSessionL( const TVersion& /*aVersion*/, + const RMessage2& /*aMessage*/ )const + { + // no services, no clients, no sessions + User::Leave(KErrNotSupported); + + //just for getting rid of compiler warning about missing return value + return NULL; + } + +// --------------------------------------------------------------------------- +// CThumbAGDaemon::ThreadFunctionL +// --------------------------------------------------------------------------- +// +void CThumbAGDaemon::ThreadFunctionL() + { + TN_DEBUG1( "CThumbAGDaemon::ThreadFunctionL() - begin" ); + + User::LeaveIfError( User::RenameThread( KTAGDaemonName ) ); + + CThumbAGDaemon* server = NULL; + CActiveScheduler* scheduler = new( ELeave )CActiveScheduler(); + + if ( scheduler ) + { + CActiveScheduler::Install( scheduler ); + + CleanupStack::PushL( scheduler ); + server = CThumbAGDaemon::NewL(); // Adds server in scheduler + + RProcess::Rendezvous( KErrNone ); + + CActiveScheduler::Start(); + + // comes here if server gets shut down + delete server; + + CleanupStack::PopAndDestroy( scheduler ); + } + + TN_DEBUG1( "CThumbAGDaemon::ThreadFunctionL() - end" ); + } + +// ----------------------------------------------------------------------------- +// CThumbAGDaemon::HandleSessionOpened +// ----------------------------------------------------------------------------- +// +void CThumbAGDaemon::HandleSessionOpened( CMdESession& /* aSession */, TInt aError ) + { + TN_DEBUG1( "CThumbAGDaemon::HandleSessionOpened"); + + if (aError == KErrNone) + { + iProcessor->SetMdESession(iMdESession); + TRAP_IGNORE(iProcessor->QueryForPlaceholdersL()); + + TRAPD( err, AddObserversL() ); + if (err != KErrNone) + { + TN_DEBUG2( "CThumbAGDaemon::HandleSessionOpened, AddObserversL error == %d", err ); + } + } + else + { + TN_DEBUG2( "CThumbAGDaemon::HandleSessionOpened error == %d", aError ); + } + } + +// ----------------------------------------------------------------------------- +// CThumbAGDaemon::HandleSessionError +// ----------------------------------------------------------------------------- +// +void CThumbAGDaemon::HandleSessionError( CMdESession& /*aSession*/, TInt aError ) + { + if (aError != KErrNone) + { + TN_DEBUG2( "CThumbAGDaemon::HandleSessionError == %d", aError ); + } + } + +// ----------------------------------------------------------------------------- +// CThumbAGDaemon::HandleObjectNotification +// ----------------------------------------------------------------------------- +// +void CThumbAGDaemon::HandleObjectNotification( CMdESession& /*aSession*/, + TObserverNotificationType aType, + const RArray& aObjectIdArray ) + { + TN_DEBUG1( "CThumbAGDaemon::HandleObjectNotification() - begin" ); + + // no processor or shutting down + if (!iProcessor || iShutdown) + { + return; + } + +#ifdef _DEBUG + if (aType == ENotifyAdd) + { + TN_DEBUG2( "CThumbAGDaemon::HandleObjectNotification() - ENotifyAdd %d", aObjectIdArray.Count() ); + iAddCounter = iAddCounter + aObjectIdArray.Count(); + } + else if (aType == ENotifyModify) + { + TN_DEBUG2( "CThumbAGDaemon::HandleObjectNotification() - ENotifyModify %d", aObjectIdArray.Count() ); + iModCounter = iModCounter + aObjectIdArray.Count(); + } + else if (aType == ENotifyRemove) + { + TN_DEBUG2( "CThumbAGDaemon::HandleObjectNotification() - ENotifyRemove %d", aObjectIdArray.Count() ); + iDelCounter = iDelCounter + aObjectIdArray.Count(); + } +#endif + + if ( (aType == ENotifyAdd || aType == ENotifyModify || aType == ENotifyRemove) && + (aObjectIdArray.Count() > 0) ) + { + TN_DEBUG1( "CThumbAGDaemon::HandleObjectNotification() - AddToQueueL" ); + + // If delete event, remove IDs from Modify and Add queues + if ( aType == ENotifyRemove ) + { + iProcessor->RemoveFromQueues( aObjectIdArray ); + } + + // Add event to processing queue by type and enable force run + TRAPD(err, iProcessor->AddToQueueL(aType, aObjectIdArray, EFalse)); + if (err != KErrNone) + { + TN_DEBUG1( "CThumbAGDaemon::HandleObjectNotification() - error adding to queue" ); + } + } + else + { + TN_DEBUG1( "CThumbAGDaemon::HandleObjectNotification() - bad notification" ); + } + +#ifdef _DEBUG + TN_DEBUG6( "CThumbAGDaemon::IN-COUNTERS---------- Type: %d Amount: %d, Add = %d Modify = %d Delete = %d", + aType, aObjectIdArray.Count(), iAddCounter, iModCounter, iDelCounter ); +#endif + + TN_DEBUG1( "CThumbAGDaemon::HandleObjectNotification() - end" ); + } + +// ----------------------------------------------------------------------------- +// CThumbAGDaemon::HandleObjectPresentNotification +// ----------------------------------------------------------------------------- +// +void CThumbAGDaemon::HandleObjectPresentNotification(CMdESession& /*aSession*/, + TBool aPresent, const RArray& aObjectIdArray) + { + TN_DEBUG3( "CThumbAGDaemon::HandleObjectPresentNotification() - aPresent == %d count == %d", aPresent, aObjectIdArray.Count() ); + + // no processor or shutting down + if (!iProcessor || iShutdown) + { + return; + } + + TInt err = 0; + + //tread present objects as added + if(aPresent) + { + TRAP_IGNORE( iProcessor->QueryForPlaceholdersL()); + if ( aObjectIdArray.Count() > 0) + { + // do not force run of these items + TRAP(err, iProcessor->AddToQueueL(ENotifyModify, aObjectIdArray, ETrue)); + + TN_DEBUG2( "CThumbAGDaemon::HandleObjectPresentNotification() - ENotifyAdd %d", aObjectIdArray.Count() ); + + +#ifdef _DEBUG + iAddCounter = iAddCounter + aObjectIdArray.Count(); + if (err != KErrNone) + { + TN_DEBUG1( "CThumbAGDaemon::HandleObjectPresentNotification() - error adding to queue" ); + } +#endif + } + } + else + { + TN_DEBUG1( "CThumbAGDaemon::HandleObjectPresentNotification() - handle not present" ); + TRAP_IGNORE( iProcessor->QueryForPlaceholdersL() ); +#ifdef _DEBUG + if( iModCounter < aObjectIdArray.Count() ) + { + iModCounter = 0; + } + else + { + iModCounter = iModCounter - aObjectIdArray.Count(); + } +#endif + + if ( aObjectIdArray.Count() > 0) + { + iProcessor->RemoveFromQueues( aObjectIdArray, ETrue ); + } + } + + #ifdef _DEBUG + TN_DEBUG5( "CThumbAGDaemon::IN-COUNTERS---------- Amount: %d, Add = %d Modify = %d Delete = %d", + aObjectIdArray.Count(), iAddCounter, iModCounter, iDelCounter ); + #endif + + TN_DEBUG1( "CThumbAGDaemon::HandleObjectPresentNotification() - end" ); + } + +// ----------------------------------------------------------------------------- +// CThumbAGDaemon::ShutdownNotification +// ----------------------------------------------------------------------------- +// +void CThumbAGDaemon::ShutdownNotification() + { + TN_DEBUG1( "CThumbAGDaemon::ShutdownNotification()" ); + + if (!iShutdown) + { + CActiveScheduler::Stop(); + iShutdown = ETrue; + } + } + +// --------------------------------------------------------------------------- +// CThumbAGDaemon::AddObserversL +// --------------------------------------------------------------------------- +// +void CThumbAGDaemon::AddObserversL() + { + TN_DEBUG1( "CThumbAGDaemon::AddObserversL() - begin" ); + + CMdENamespaceDef& defaultNamespace = iMdESession->GetDefaultNamespaceDefL(); + CMdEObjectDef& imageDef = defaultNamespace.GetObjectDefL( MdeConstants::Image::KImageObject ); + CMdEObjectDef& videoDef = defaultNamespace.GetObjectDefL( MdeConstants::Video::KVideoObject ); + CMdEObjectDef& audioDef = defaultNamespace.GetObjectDefL( MdeConstants::Audio::KAudioObject ); + + // set observing conditions + CMdELogicCondition* addCondition = CMdELogicCondition::NewLC( ELogicConditionOperatorOr ); + addCondition->AddObjectConditionL( imageDef ); + addCondition->AddObjectConditionL( videoDef ); + addCondition->AddObjectConditionL( audioDef ); + CleanupStack::Pop( addCondition ); + + CMdELogicCondition* modifyCondition = CMdELogicCondition::NewLC( ELogicConditionOperatorOr ); + modifyCondition->AddObjectConditionL( imageDef ); + modifyCondition->AddObjectConditionL( videoDef ); + modifyCondition->AddObjectConditionL( audioDef ); + CleanupStack::Pop( modifyCondition ); + + // add observer + iMdESession->AddObjectObserverL( *this, addCondition, ENotifyAdd ); + + // modify observer + iMdESession->AddObjectObserverL( *this, modifyCondition, ENotifyModify ); + + // remove observer + iMdESession->AddObjectObserverL( *this, NULL, ENotifyRemove ); + + // object present observer + iMdESession->AddObjectPresentObserverL( *this ); + + TN_DEBUG1( "CThumbAGDaemon::AddObserversL() - end" ); + } + +// --------------------------------------------------------------------------- +// CThumbAGDaemon::DaemonEnabledL +// --------------------------------------------------------------------------- +// +TBool CThumbAGDaemon::DaemonEnabledL() + { + TN_DEBUG1( "CThumbAGDaemon::DaemonEnabledL() - begin" ); + CRepository* rep = CRepository::NewL( TUid::Uid( THUMBNAIL_CENREP_UID )); + + // get value + TBool val( EFalse ); + TInt ret = rep->Get( KEnableDaemon, val ); + + delete rep; + TN_DEBUG3( "CThumbAGDaemon::DaemonEnabledL() - val == %d, ret == %d", val, ret ); + return val; + } + +// --------------------------------------------------------------------------- +// E32Main +// --------------------------------------------------------------------------- +// +TInt E32Main() + { + TN_DEBUG1( "CThumbAGDaemon::E32Main() - begin" ); + + __UHEAP_MARK; + + CTrapCleanup* cleanup = CTrapCleanup::New(); + TInt result = KErrNoMemory; + + if ( cleanup ) + { + TRAP( result, CThumbAGDaemon::ThreadFunctionL()); + delete cleanup; + } + + if ( result != KErrNone ) + { + TN_DEBUG1( "CThumbAGDaemon::E32Main() - error" ); + + // Signal the client that server creation failed + RProcess::Rendezvous( result ); + } + + __UHEAP_MARKEND; + + TN_DEBUG1( "CThumbAGDaemon::E32Main() - end" ); + + return result; + } + +// End of file diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbagdaemon/src/thumbagformatobserver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbagdaemon/src/thumbagformatobserver.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,129 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: File System format monitor +* +*/ + +#include "thumbagformatobserver.h" +#include "thumbnaillog.h" + +#include +#include + + +// ======== MEMBER FUNCTIONS ======== + +CThumbAGFormatObserver::CThumbAGFormatObserver ( CThumbAGProcessor* aProcessor): + iProcessor( aProcessor ) + { + TN_DEBUG1( "CThumbAGFormatObserver::CThumbAGFormatObserver()"); + + } + + +// --------------------------------------------------------------------------- +// Second Phase Constructor +// --------------------------------------------------------------------------- +// +void CThumbAGFormatObserver::ConstructL() + { + TN_DEBUG1("CThumbAGFormatObserver::ConstructL in"); + + iBackupSession = CBaBackupSessionWrapper::NewL(); + iBackupSession->RegisterBackupOperationObserverL( *this ); + + + TN_DEBUG1("CThumbAGFormatObserver::ConstructL out"); + } + + +// --------------------------------------------------------------------------- +// Two-Phased Constructor +// --------------------------------------------------------------------------- +// +CThumbAGFormatObserver* CThumbAGFormatObserver::NewL(CThumbAGProcessor* aProcessor ) + { + CThumbAGFormatObserver* self = CThumbAGFormatObserver::NewLC( aProcessor ); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// Two-Phased Constructor +// --------------------------------------------------------------------------- +// +CThumbAGFormatObserver* CThumbAGFormatObserver::NewLC( CThumbAGProcessor* aProcessor ) + { + CThumbAGFormatObserver* self = new( ELeave ) CThumbAGFormatObserver( aProcessor ); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + + +// --------------------------------------------------------------------------- +// destructor +// --------------------------------------------------------------------------- +// +CThumbAGFormatObserver::~CThumbAGFormatObserver() + { + + if( iBackupSession ) + { + iBackupSession->DeRegisterBackupOperationObserver( *this ); + } + delete iBackupSession; + } + +// --------------------------------------------------------------------------- +// Checks the current status +// --------------------------------------------------------------------------- +// +void CThumbAGFormatObserver::PollStatus() + { + + TN_DEBUG1("CThumbAGFormatObserver::PollStatus()"); + + TBool formatting = iBackupSession->IsBackupOperationRunning(); + + if( formatting ) + { + iProcessor->SetFormat(ETrue); + } + } + +// --------------------------------------------------------------------------- +// CThumbnailFormatObserver::HandleBackupOperationEventL +// Handles a format operation +// --------------------------------------------------------------------------- +// +void CThumbAGFormatObserver::HandleBackupOperationEventL( + const TBackupOperationAttributes& aBackupOperationAttributes) + { + TN_DEBUG1("CThumbAGFormatObserver::HandleBackupOperationEventL in"); + + if( aBackupOperationAttributes.iOperation == EStart ) + { + iProcessor->SetFormat(ETrue); + } + else // TOperationType::EEnd or TOperationType::EAbort + { + iProcessor->SetFormat(EFalse); + } + + TN_DEBUG1("CThumbAGObserver::HandleBackupOperationEventL out"); + } + + diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbagdaemon/src/thumbagprocessor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbagdaemon/src/thumbagprocessor.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,1334 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Processor +* +*/ + + +#include + +#include +#include + +#include "thumbagprocessor.h" +#include "thumbnaillog.h" +#include "thumbnailmanagerconstants.h" +#include "thumbnailmanagerprivatecrkeys.h" +#include "thumbagformatobserver.h" +#include +#include +#include + +// --------------------------------------------------------------------------- +// CThumbAGProcessor::NewL() +// --------------------------------------------------------------------------- +// +CThumbAGProcessor* CThumbAGProcessor::NewL() + { + TN_DEBUG1( "CThumbAGProcessor::NewL() - begin" ); + + CThumbAGProcessor* self = new( ELeave )CThumbAGProcessor(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------------------------- +// CThumbAGProcessor::CThumbAGProcessor() +// --------------------------------------------------------------------------- +// +CThumbAGProcessor::CThumbAGProcessor(): CActive( CActive::EPriorityStandard ) + { + TN_DEBUG1( "CThumbAGProcessor::CThumbAGProcessor() - begin" ); + + CActiveScheduler::Add( this ); + } + +// --------------------------------------------------------------------------- +// CThumbAGProcessor::ConstructL() +// --------------------------------------------------------------------------- +// +void CThumbAGProcessor::ConstructL() + { + TN_DEBUG1( "CThumbAGProcessor::ConstructL() - begin" ); + +#ifdef _DEBUG + iAddCounter = 0; + iModCounter = 0; + iDelCounter = 0; +#endif + + iTMSession = CThumbnailManager::NewL( *this ); + + iQuery = NULL; + iQueryActive = EFalse; + iModify = EFalse; + iProcessingCount = 0; + + iActiveCount = 0; + + // set auto create values from cenrep + CheckAutoCreateValuesL(); + + iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityIdle); + + //do some initializing async in RunL() + iInit = ETrue; + iForceRun = EFalse; + iActive = EFalse; + + iFormatObserver = CThumbAGFormatObserver::NewL( this ); + + iFormatting = EFalse; + iSessionDied = EFalse; + + iCollectionUtility = NULL; + + TN_DEBUG1( "CThumbAGProcessor::ConstructL() - end" ); + } + +// --------------------------------------------------------------------------- +// CThumbAGProcessor::~CThumbAGProcessor() +// --------------------------------------------------------------------------- +// +CThumbAGProcessor::~CThumbAGProcessor() + { + TN_DEBUG1( "CThumbAGProcessor::~CThumbAGProcessor() - begin" ); + + if(iPeriodicTimer) + { + iPeriodicTimer->Cancel(); + delete iPeriodicTimer; + } + + if (!iInit) + { + iHarvesterClient.RemoveHarvesterEventObserver(*this); + iHarvesterClient.Close(); + } + + if ( iCollectionUtility ) + { + iCollectionUtility->Close(); + iCollectionUtility = NULL; + } + + Cancel(); + + if (iQuery) + { + iQuery->Cancel(); + delete iQuery; + iQuery = NULL; + } + + if (iQueryForPlaceholders) + { + iQueryForPlaceholders->Cancel(); + delete iQueryForPlaceholders; + iQueryForPlaceholders = NULL; + } + + iAddQueue.Close(); + iModifyQueue.Close(); + iRemoveQueue.Close(); + iQueryQueue.Close(); + iPresentQueue.Close(); + iTempModifyQueue.Close(); + iTempAddQueue.Close(); + iPlaceholderIDs.Close(); + + if (iTMSession) + { + delete iTMSession; + iTMSession = NULL; + } + + delete iFormatObserver; + + TN_DEBUG1( "CThumbAGProcessor::~CThumbAGProcessor() - end" ); + } + +// ----------------------------------------------------------------------------- +// CThumbAGProcessor::HandleQueryNewResults() +// ----------------------------------------------------------------------------- +// +void CThumbAGProcessor::HandleQueryNewResults( CMdEQuery& /*aQuery*/, + const TInt /*aFirstNewItemIndex*/, + const TInt /*aNewItemCount*/ ) + { + // No implementation required + } + +// ----------------------------------------------------------------------------- +// CThumbAGProcessor::HandleQueryCompleted() +// ----------------------------------------------------------------------------- +// +void CThumbAGProcessor::HandleQueryCompleted( CMdEQuery& /*aQuery*/, const TInt aError ) + { + + if( iQueryForPlaceholdersActive && iQueryForPlaceholders) + { + TN_DEBUG3( "CThumbAGProcessor::HandleQueryCompletedv2, aError == %d Count== %d", aError, iQueryForPlaceholders->Count()); + + // if no errors in query + if (aError == KErrNone ) + { + + for(TInt i = 0; i < iQueryForPlaceholders->Count(); i++) + { + const CMdEObject* object = &iQueryForPlaceholders->Result(i); + + if(!object) + continue; + + if(!object->Placeholder()) + { + TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompletedv2 %d not placeholder",object->Id()); + continue; + } + + if (iPlaceholderIDs.Find( object->Id() ) == KErrNotFound) + { + TRAP_IGNORE( iPlaceholderIDs.AppendL( object->Id() )); + } + } + + } + else + { + TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted() FAILED!"); + } + + iQueryForPlaceholdersActive = EFalse; + } + + else if(iQueryActive) + { + TN_DEBUG3( "CThumbAGProcessor::HandleQueryCompleted, aError == %d Count== %d", aError, iQuery->Count()); + iQueryReady = ETrue; + iQueryActive = EFalse; + + // if no errors in query + if (aError == KErrNone && iQuery) + { + iProcessingCount = iQuery->Count(); + } + else + { + iProcessingCount = 0; + TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted() FAILED!"); + } + } + else + { + TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted() - NO QUERY ACTIVE"); + } + + ActivateAO(); + } + +// ----------------------------------------------------------------------------- +// CThumbAGProcessor::ThumbnailPreviewReady() +// ----------------------------------------------------------------------------- +// +void CThumbAGProcessor::ThumbnailPreviewReady( MThumbnailData& /*aThumbnail*/, + TThumbnailRequestId /*aId*/) + { + // No implementation required + } + +// ----------------------------------------------------------------------------- +// CThumbAGProcessor::ThumbnailReady() +// ----------------------------------------------------------------------------- +// +void CThumbAGProcessor::ThumbnailReady( TInt aError, MThumbnailData& /*aThumbnail*/, + TThumbnailRequestId /*aId*/ ) + { + TN_DEBUG2( "CThumbAGProcessor::ThumbnailReady() aError == %d", aError ); + + iActive = EFalse; + + // TNM server died, delete session + if( aError == KErrServerTerminated ) + { + TN_DEBUG1( "CThumbAGProcessor::ThumbnailReady() - **** THUMBNAIL SERVER DIED ****" ); + + iSessionDied = ETrue; + + if( !iTimerActive) + { + StartTimeout(); + } + + //reset PS idle so that RunL() can startup reopen TNM session and proceed + TInt ret = RProperty::Set(KServerIdle, KIdle, ETrue); + TN_DEBUG2( "CThumbAGProcessor::ThumbnailReady() set Idle ret = %d", ret ); + + return; + } + + ActivateAO(); + TN_DEBUG1( "CThumbAGProcessor::ThumbnailReady() - end" ); + } + +// --------------------------------------------------------------------------- +// CThumbAGProcessor::SetMdESession() +// --------------------------------------------------------------------------- +// +void CThumbAGProcessor::SetMdESession( CMdESession* aMdESession ) + { + TN_DEBUG1( "CThumbAGProcessor::SetMdESession() - begin" ); + + iMdESession = aMdESession; + + TRAPD( err, iDefNamespace = &iMdESession->GetDefaultNamespaceDefL() ); + if (err != KErrNone) + { + TN_DEBUG1( "CThumbAGProcessor::SetMdESession - Error: GetDefaultNamespaceDefL leave" ); + } + ActivateAO(); + } + +// --------------------------------------------------------------------------- +// CThumbAGProcessor::AddToQueue() +// --------------------------------------------------------------------------- +// +void CThumbAGProcessor::AddToQueueL( TObserverNotificationType aType, + const RArray& aIDArray, TBool aPresent ) + { + TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - begin" ); + + if(aPresent) + { + TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - Add to SetPresentQueue" ); + for (int i=0; i= 0 ) + { + TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - harvesting now ended for this placeholder - not Real ENotifyModify" ); + iPlaceholderIDs.Remove(itemIndex); + TN_DEBUG2( "CThumbAGProcessor::AddToQueueL() - placeholders left %d", iPlaceholderIDs.Count() ); + if (iAddQueue.Find( aIDArray[i] ) == KErrNotFound) + { + iAddQueue.AppendL(aIDArray[i]); + } + if (iTempModifyQueue.Find( aIDArray[i] ) == KErrNotFound) + { + iTempModifyQueue.AppendL( aIDArray[i] ); + } + } + else if ( iTempAddQueue.Find( aIDArray[i] ) == KErrNotFound) + { + TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - Real ENotifyModify, force run" ); + iModifyQueue.InsertL( aIDArray[i], 0 ); + + TInt itemIndex = iAddQueue.Find( aIDArray[i] ); + if(itemIndex >= 0) + { + iAddQueue.Remove(itemIndex); + } + itemIndex = iPresentQueue.Find( aIDArray[i] ); + if(itemIndex >= 0) + { + iPresentQueue.Remove(itemIndex); + } + SetForceRun( ETrue ); + } + else + { + if (iTempModifyQueue.Find( aIDArray[i] ) == KErrNotFound) + { + TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - harvesting now ended for this file - not Real ENotifyModify" ); + iTempModifyQueue.AppendL( aIDArray[i] ); + } + else + { + TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - harvesting ended allready for this file - Real ENotifyModify, force run" ); + iModifyQueue.InsertL( aIDArray[i], 0 ); + TInt itemIndex = iAddQueue.Find( aIDArray[i] ); + if(itemIndex >= 0) + { + iAddQueue.Remove(itemIndex); + } + itemIndex = iPresentQueue.Find( aIDArray[i] ); + if(itemIndex >= 0) + { + iPresentQueue.Remove(itemIndex); + } + SetForceRun( ETrue ); + } + } + } + } + else if (aType == ENotifyRemove) + { + TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyRemove" ); + + for (int i=0; i= 0) + { + iAddQueue.Remove(itemIndex); + } + // ..and Present Queue + itemIndex = iPresentQueue.Find( aIDArray[i] ); + if(itemIndex >= 0) + { + iPresentQueue.Remove(itemIndex); + } + // ..and Modify Queue + itemIndex = iModifyQueue.Find( aIDArray[i] ); + if(itemIndex >= 0) + { + iModifyQueue.Remove(itemIndex); + } + } + } + else + { + // should not come here + TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - should not come here" ); + return; + } + + ActivateAO(); + + TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - end" ); + } + +// --------------------------------------------------------------------------- +// CThumbAGProcessor::CreateThumbnailsL() +// --------------------------------------------------------------------------- +// +void CThumbAGProcessor::CreateThumbnailsL( const CMdEObject* aObject ) + { + TN_DEBUG1( "CThumbAGProcessor::CreateThumbnailsL() - begin" ); + + if( iModify ) + { + TInt orientationVal = 0; + TInt64 modifiedVal = 0; + + CMdEProperty* orientation = NULL; + CMdEObjectDef& objDef = iDefNamespace->GetObjectDefL( MdeConstants::Image::KImageObject ); + TInt orientErr = aObject->Property( objDef.GetPropertyDefL( MdeConstants::Image::KOrientationProperty ), orientation, 0 ); + + if (orientErr == KErrNone) + { + orientationVal = orientation->Uint16ValueL(); + } + + CMdEProperty* modified = NULL; + CMdEObjectDef& objDef2 = iDefNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject ); + TInt modifyErr = aObject->Property( objDef2.GetPropertyDefL( MdeConstants::Object::KLastModifiedDateProperty ), modified, 0 ); + + if (modifyErr >= 0) + { + modifiedVal = modified->TimeValueL().Int64(); + } + + // modify existing thumbs + if (iTMSession) + { + // run as lower priority than getting but higher that creating thumbnails + TRAPD(err, iTMSession->UpdateThumbnailsL(aObject->Id(), aObject->Uri(), orientationVal, modifiedVal, CActive::EPriorityIdle )); + + if ( err != KErrNone ) + { + TN_DEBUG2( "CThumbAGProcessor::UpdateThumbnailsL, iTMSession error == %d", err ); + + iSessionDied = ETrue; + iActive = EFalse; + ActivateAO(); + } + else + { + iActive = ETrue; + } + } + else + { + ActivateAO(); + } + +#ifdef _DEBUG + iModCounter++; +#endif + } + else + { + CThumbnailObjectSource* source = NULL; + CMdEProperty* mimeType = NULL; + CMdEObjectDef& objDef = iDefNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject ); + TInt mime = aObject->Property( objDef.GetPropertyDefL( MdeConstants::Object::KItemTypeProperty ), mimeType, 0 ); + + // create new thumbs + if (mime != KErrNotFound) + { + source = CThumbnailObjectSource::NewLC(aObject->Uri(), aObject->Id(), mimeType->TextValueL()); + } + else + { + source = CThumbnailObjectSource::NewLC(aObject->Uri(), aObject->Id()); + } + + if (iTMSession) + { + // run as very low priority task + TInt id = iTMSession->CreateThumbnails(*source, CActive::EPriorityIdle ); + if ( id < 0 ) + { + TN_DEBUG2( "CThumbAGProcessor::CreateThumbnailsL, iTMSession error == %d", id ); + + iSessionDied = ETrue; + iActive = EFalse; + CleanupStack::PopAndDestroy( source ); + ActivateAO(); + } + else + { + iActive = ETrue; + CleanupStack::PopAndDestroy( source ); + } + + } + else + { + ActivateAO(); + } + +#ifdef _DEBUG + iAddCounter++; +#endif + } + +#ifdef _DEBUG + TN_DEBUG3( "CThumbAGProcessor::OUT-COUNTERS----------, Add = %d Modify = %d", + iAddCounter, iModCounter ); +#endif + + TN_DEBUG1( "CThumbAGProcessor::CreateThumbnailsL() - end" ); + } + +// --------------------------------------------------------------------------- +// CThumbAGProcessor::QueryL() +// --------------------------------------------------------------------------- +// +void CThumbAGProcessor::QueryL( RArray& aIDArray ) + { + TN_DEBUG1( "CThumbAGProcessor::QueryL() - begin" ); + + iQueryReady = EFalse; + + // delete old query + if (iQuery) + { + delete iQuery; + iQuery = NULL; + } + + //move ID from source queue to Query queue + TInt maxCount = aIDArray.Count(); + + TN_DEBUG3( "CThumbAGProcessor::QueryL() - fill begin aIDArray == %d, iQueryQueue == %d", aIDArray.Count(), iQueryQueue.Count() ); + + for(TInt i=0;i < KMaxQueryItems && i < maxCount; i++) + { + TN_DEBUG2( "CThumbAGProcessor::QueryL() - fill %d", aIDArray[0] ); + iQueryQueue.Append( aIDArray[0] ); + aIDArray.Remove( 0 ); + } + + TN_DEBUG3( "CThumbAGProcessor::QueryL() - fill end aIDArray == %d, iQueryQueue == %d", aIDArray.Count(), iQueryQueue.Count() ); + + CMdEObjectDef& objDef = iDefNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject ); + iQuery = iMdESession->NewObjectQueryL( *iDefNamespace, objDef, this ); + iQuery->SetResultMode( EQueryResultModeItem ); + + CMdELogicCondition& rootCondition = iQuery->Conditions(); + rootCondition.SetOperator( ELogicConditionOperatorAnd ); + + // add IDs + CleanupClosePushL( iQueryQueue ); + rootCondition.AddObjectConditionL( iQueryQueue ); + CleanupStack::Pop( &iQueryQueue ); + + // add object type conditions + if (!iModify) + { + CMdELogicCondition& objDefCondition = rootCondition.AddLogicConditionL( ELogicConditionOperatorOr ); + + if (iAutoImage) + { + CMdEObjectDef& imageDef = iDefNamespace->GetObjectDefL( MdeConstants::Image::KImageObject ); + objDefCondition.AddObjectConditionL( imageDef ); + } + if (iAutoVideo) + { + CMdEObjectDef& videoDef = iDefNamespace->GetObjectDefL( MdeConstants::Video::KVideoObject ); + objDefCondition.AddObjectConditionL( videoDef ); + } + if (iAutoAudio) + { + CMdEObjectDef& audioDef = iDefNamespace->GetObjectDefL( MdeConstants::Audio::KAudioObject ); + objDefCondition.AddObjectConditionL( audioDef ); + } + } + + iQuery->FindL(); + + iQueryQueue.Reset(); + + TN_DEBUG1( "CThumbAGProcessor::QueryL() - end" ); + } + +// --------------------------------------------------------------------------- +// CThumbAGProcessor::RunL() +// --------------------------------------------------------------------------- +// +void CThumbAGProcessor::RunL() + { + TN_DEBUG1( "CThumbAGProcessor::RunL() - begin" ); + + if (iSessionDied) + { + delete iTMSession; + iTMSession = NULL; + } + + if (iInit) + { + TN_DEBUG1( "CThumbAGProcessor::RunL() - Do Initialisation" ); + iInit = EFalse; + TN_DEBUG1( "iHarvesterClient"); + if( iHarvesterClient.Connect() == KErrNone ) + { + TN_DEBUG1( "iHarvesterClient connected"); + iHarvesterClient.AddHarvesterEventObserver( *this, EHEObserverTypeOverall, KMaxTInt ); + iHarvesterClient.AddHarvesterEventObserver( *this, EHEObserverTypePlaceholder, KMaxTInt ); + TN_DEBUG1( "iHarvesterClient AddHarvesterEventObserver added"); + } + + TN_DEBUG1( "create MMPXCollectionUtility"); + iCollectionUtility = MMPXCollectionUtility::NewL( this, KMcModeIsolated ); + TN_DEBUG1( "CThumbAGProcessor::RunL() - Initialisation done" ); + return; + } + + // restart session if died + if (!iTMSession) + { + TN_DEBUG1( "CThumbAGProcessor::RunL() - open TNM session"); + iActive = EFalse; + TRAPD( err, iTMSession = CThumbnailManager::NewL( *this ) ); + + if (err != KErrNone) + { + iTMSession = NULL; + TN_DEBUG2( "CThumbAGProcessor::RunL() - Session restart failed, error == %d", err ); + } + else { + iSessionDied = EFalse; + } + } + + // do not run if request is already issued to TNM server even if forced + if( iActive) + { + if(iActiveCount <= KMaxDaemonRequests) + { + iActiveCount++; + TN_DEBUG1( "CThumbAGProcessor::RunL() - waiting for previous to complete, abort..." ); + return; + } + else + { + TN_DEBUG1( "CThumbAGProcessor::RunL() - iActive jammed - resetted" ); + iActive = EFalse; + iActiveCount = 0; + } + } + else + { + iActiveCount = 0; + } + + //Iforce run can proceed from this point + if( !iForceRun ) + { + //check if harvesting or waiting timeout + if( iHarvesting || iTimerActive || iMPXHarvesting ) + { + TN_DEBUG1( "void CThumbAGProcessor::RunL() Harvester or timer active, abort"); + return; + } + else + { + //check is server idle + TInt idle(-1); + + TInt ret = RProperty::Get(KServerIdle, KIdle, idle); + + if(ret == KErrNone ) + { + if(!idle) + { + //start wait timer and retry on after callback + TN_DEBUG1( "CThumbAGProcessor::RunL() server not idle, wait... " ); + if( !iTimerActive) + { + StartTimeout(); + } + return; + } + } + else + { + TN_DEBUG2( "CThumbAGProcessor::RunL() get KServerIdle failed %d, continue...", ret ); + } + } + } + else + { + TN_DEBUG1( "void CThumbAGProcessor::RunL() forced run"); + } + + + //Handle completed MDS Query + if( iQueryReady && iProcessingCount) + { + TInt err(KErrNone); + if((iForceRun && iModify) || (!iForceRun && !iModify)) + { + TN_DEBUG1( "CThumbAGProcessor::RunL() - iQueryReady START" ); + + + const CMdEObject* object = &iQuery->Result( iProcessingCount-1 ); + iProcessingCount--; + + // process one item at once + if ( object ) + { + TRAP( err, CreateThumbnailsL(object) ); + + if ( err != KErrNone ) + { + TN_DEBUG2( "CThumbAGProcessor::RunL(), CreateThumbnailsL error == %d", err ); + } + } + } + else + { + TN_DEBUG1( "CThumbAGProcessor::RunL() - deleting query" ); + delete iQuery; + iQuery = NULL; + iQueryReady = EFalse; + iProcessingCount = 0; + ActivateAO(); + return; + } + + //is last query item + if( iProcessingCount <= 0 ) + { + TN_DEBUG1( "CThumbAGProcessor::RunL() - iQueryReady FINISH" ); + iQueryReady = EFalse; + iQueryActive = EFalse; + iModify = EFalse; + + //check if forced run needs to continue + if (iModifyQueue.Count()) + { + iForceRun = ETrue; + } + else + { + iForceRun = EFalse; + } + + } + //keep going if processing Remove items or if Add item fails + else if( iModify || err ) + { + ActivateAO(); + } + } + //waiting for MDS query to complete + else if( iQueryActive || iQueryForPlaceholdersActive ) + { + if(iForceRun && !iModify && iQueryActive) + { + iQuery->Cancel(); + delete iQuery; + iQuery = NULL; + TN_DEBUG1( "CThumbAGProcessor::RunL() - canceling query..." ); + iQueryReady = EFalse; + iQueryActive = EFalse; + ActivateAO(); + } + else + { + TN_DEBUG1( "CThumbAGProcessor::RunL() - waiting for query to complete, abort..." ); + } + } + + // select queue to process, priority by type. Process modify events before new images + else if ( iModifyQueue.Count() > 0 ) + { + TN_DEBUG1( "void CThumbAGProcessor::RunL() update thumbnails"); + + // query for object info + iQueryActive = ETrue; + iModify = ETrue; + QueryL( iModifyQueue ); + } + else if ( iRemoveQueue.Count() > 0 ) + { + TN_DEBUG1( "void CThumbAGProcessor::RunL() delete thumbnails"); + + // delete thumbs by ID + if (iTMSession) + { + iTMSession->DeleteThumbnails( iRemoveQueue[0] ); + } + iRemoveQueue.Remove( 0 ); + +#ifdef _DEBUG + iDelCounter++; + TN_DEBUG2( "CThumbAGProcessor::OUT-COUNTERS----------, Delete = %d", iDelCounter ); +#endif + ActivateAO(); + } + else if ( iAddQueue.Count() > 0 ) + { + TN_DEBUG1( "void CThumbAGProcessor::RunL() add thumbnails"); + + // query for object info + iQueryActive = ETrue; + + QueryL( iAddQueue ); + } + else if ( iPresentQueue.Count() > 0 ) + { + TN_DEBUG1( "void CThumbAGProcessor::RunL() add thumbnails for present thumbnails" ); + + // query for object info + iQueryActive = ETrue; + + QueryL( iPresentQueue ); + } + + TN_DEBUG1( "CThumbAGProcessor::RunL() - end" ); + } + +// --------------------------------------------------------------------------- +// CThumbAGProcessor::DoCancel() +// --------------------------------------------------------------------------- +// +void CThumbAGProcessor::DoCancel() + { + // No implementation required + } + +void CThumbAGProcessor::HarvestingUpdated( + HarvesterEventObserverType aHEObserverType, + HarvesterEventState aHarvesterEventState, + TInt /*aItemsLeft*/ ) + { + TN_DEBUG3( "CThumbAGProcessor::HarvestingUpdated -- start() aHEObserverType = %d, aHarvesterEventState = %d", aHEObserverType, aHarvesterEventState ); + + if( aHEObserverType == EHEObserverTypePlaceholder) + { + TRAP_IGNORE( QueryForPlaceholdersL() ); + return; + } + + if( aHEObserverType != EHEObserverTypeOverall) + { + return; + } + + switch(aHarvesterEventState) + { + case EHEStateStarted: + case EHEStateHarvesting: + case EHEStatePaused: + case EHEStateResumed: + { + iHarvestingTemp = ETrue; + break; + } + case EHEStateFinished: + case EHEStateUninitialized: + { + iHarvestingTemp = EFalse; + break; + } + }; + + if(iHarvestingTemp == iHarvesting) + { + TN_DEBUG2( "CThumbAGProcessor::HarvestingUpdated -- no change %d", iHarvesting); + } + else + { + iHarvesting = iHarvestingTemp; + + if( iHarvesting ) + { + TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- MDS harvesterin started"); + CancelTimeout(); + } + else + { + TN_DEBUG1( "CThumbAGProcessor::HarvestingUpdated -- MDS harvesting finished "); + // continue processing if needed + StartTimeout(); + + iTempModifyQueue.Reset(); + iTempAddQueue.Reset(); + iPlaceholderIDs.Reset(); + } + } + + TN_DEBUG3( "CThumbAGProcessor::HarvestingUpdated -- end() iHarvesting == %d, iMPXHarvesting == %d", iHarvesting, iMPXHarvesting); + } + +// --------------------------------------------------------------------------- +// CThumbAGProcessor::StartTimeout() +// --------------------------------------------------------------------------- +// +void CThumbAGProcessor::StartTimeout() + { + CancelTimeout(); + + if(!iHarvesting && !iMPXHarvesting && !iPeriodicTimer->IsActive()) + { + iPeriodicTimer->Start( KHarvestingCompleteTimeout, KHarvestingCompleteTimeout, + TCallBack(PeriodicTimerCallBack, this)); + iTimerActive = ETrue; + } + else + { + iTimerActive = EFalse; + } + } + +// --------------------------------------------------------------------------- +// CThumbAGProcessor::StopTimeout() +// --------------------------------------------------------------------------- +// +void CThumbAGProcessor::CancelTimeout() + { + if(iTimerActive) + { + iPeriodicTimer->Cancel(); + } + iTimerActive = EFalse; + } + +// --------------------------------------------------------------------------- +// CThumbAGProcessor::RunError() +// --------------------------------------------------------------------------- +// +TInt CThumbAGProcessor::RunError(TInt aError) + { + if (aError != KErrNone) + { + TN_DEBUG2( "CThumbAGProcessor::RunError = %d", aError ); + } + + iActive = EFalse; + + // nothing to do + return KErrNone; + } + +// --------------------------------------------------------------------------- +// CThumbAGProcessor::ActivateAO() +// --------------------------------------------------------------------------- +// +void CThumbAGProcessor::ActivateAO() + { + if(iFormatting) + { + TN_DEBUG1( "CThumbAGProcessor::ActivateAO() - FORMATTING - DAEMON ON PAUSE"); + return; + } + + if( !IsActive() && (!iHarvesting || iForceRun )) + { +#ifdef _DEBUG + if( iForceRun ) + { + TN_DEBUG1( "CThumbAGProcessor::ActivateAO() - *** FORCED RUN ***"); + } +#endif + SetActive(); + TRequestStatus* statusPtr = &iStatus; + User::RequestComplete( statusPtr, KErrNone ); + } + } + +// --------------------------------------------------------------------------- +// CThumbAGProcessor::PeriodicTimerCallBack() +// --------------------------------------------------------------------------- +// +TInt CThumbAGProcessor::PeriodicTimerCallBack(TAny* aAny) + { + TN_DEBUG1( "CThumbAGProcessor::PeriodicTimerCallBack()"); + CThumbAGProcessor* self = static_cast( aAny ); + + self->CancelTimeout(); + self->ActivateAO(); + + return KErrNone; // Return value ignored by CPeriodic + } + +// --------------------------------------------------------------------------- +// CThumbAGProcessor::CheckAutoCreateValuesL() +// --------------------------------------------------------------------------- +// +void CThumbAGProcessor::CheckAutoCreateValuesL() + { + CRepository* rep = CRepository::NewL( TUid::Uid( THUMBNAIL_CENREP_UID )); + + TBool imageGrid( EFalse ); + TBool imageList( EFalse ); + TBool imageFull( EFalse ); + TBool videoGrid( EFalse ); + TBool videoList( EFalse ); + TBool videoFull( EFalse ); + TBool audioGrid( EFalse ); + TBool audioList( EFalse ); + TBool audioFull( EFalse ); + + // get cenrep values + rep->Get( KAutoCreateImageGrid, imageGrid ); + rep->Get( KAutoCreateImageList, imageList ); + rep->Get( KAutoCreateImageFullscreen, imageFull ); + rep->Get( KAutoCreateVideoGrid, videoGrid ); + rep->Get( KAutoCreateVideoList, videoList ); + rep->Get( KAutoCreateVideoFullscreen, videoFull ); + rep->Get( KAutoCreateAudioGrid, audioGrid ); + rep->Get( KAutoCreateAudioList, audioList ); + rep->Get( KAutoCreateAudioFullscreen, audioFull ); + + iAutoImage = EFalse; + iAutoVideo = EFalse; + iAutoAudio = EFalse; + + // set processing values + if (imageGrid || imageList || imageFull) + { + iAutoImage = ETrue; + } + if (videoGrid || videoList || videoFull) + { + iAutoVideo = ETrue; + } + if (audioGrid || audioList || audioFull) + { + iAutoAudio = ETrue; + } + + delete rep; + } + +// --------------------------------------------------------------------------- +// CThumbAGProcessor::RemoveFromQueues() +// --------------------------------------------------------------------------- +// +void CThumbAGProcessor::RemoveFromQueues( const RArray& aIDArray, const TBool aRemoveFromDelete ) + { + TN_DEBUG2( "CThumbAGProcessor::RemoveFromQueues() aRemoveFromDelete == %d - begin", aRemoveFromDelete ); + + TInt itemIndex = KErrNotFound; + + for (int i=0; i< aIDArray.Count(); i++) + { + TN_DEBUG2( "CThumbAGProcessor::RemoveFromQueues() - %d", aIDArray[i]); + + itemIndex = iAddQueue.Find( aIDArray[i] ); + + if(itemIndex >= 0) + { + iAddQueue.Remove(itemIndex); + TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iAddQueue" ); + continue; + } + + itemIndex = iPresentQueue.Find( aIDArray[i] ); + + if(itemIndex >= 0) + { + iPresentQueue.Remove(itemIndex); + TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iPresentQueue" ); + continue; + } + + itemIndex = iModifyQueue.Find( aIDArray[i] ); + + if(itemIndex >= 0) + { + iModifyQueue.Remove(itemIndex); + TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iModifyQueue" ); + + if( iModifyQueue.Count() == 0) + { + iForceRun = EFalse; + } + + continue; + } + + if( aRemoveFromDelete ) + { + itemIndex = iRemoveQueue.Find( aIDArray[i] ); + + if(itemIndex >= 0) + { + iRemoveQueue.Remove(itemIndex); + TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iRemoveQueue" ); + continue; + } + } + } + + TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - end" ); + } + +// --------------------------------------------------------------------------- +// CThumbAGProcessor::SetForceRun() +// --------------------------------------------------------------------------- +// +void CThumbAGProcessor::SetForceRun( const TBool aForceRun) + { + TN_DEBUG2( "CThumbAGProcessor::SetForceRun(%d) - end", aForceRun ); + + // enable forced run + if (aForceRun) + { + iForceRun = aForceRun; + } + } + +// --------------------------------------------------------------------------- +// CThumbAGProcessor::SetFormat() +// --------------------------------------------------------------------------- +// + +void CThumbAGProcessor::SetFormat(TBool aStatus) + { + TN_DEBUG2( "CThumbAGProcessor::SetFormat(%d) - end", aStatus ); + + iFormatting = aStatus; + if(!aStatus) + { + ActivateAO(); + } + } + +// --------------------------------------------------------------------------- +// CThumbAGProcessor::QueryForPlaceholders() +// --------------------------------------------------------------------------- +// + +void CThumbAGProcessor::QueryForPlaceholdersL() + { + TN_DEBUG1( "CThumbAGProcessor::QueryForPlaceholders" ); + if(iQueryForPlaceholdersActive) + { + TN_DEBUG1( "CThumbAGProcessor::QueryForPlaceholders - skip" ); + return; + } + + TN_DEBUG1( "CThumbAGProcessor::QueryForPlaceholders - start" ); + + // delete old query + if (iQueryForPlaceholders) + { + iQueryForPlaceholdersActive = EFalse; + iQueryForPlaceholders->Cancel(); + delete iQueryForPlaceholders; + iQueryForPlaceholders = NULL; + } + + CMdEObjectDef& imageObjDef = iDefNamespace->GetObjectDefL( MdeConstants::Image::KImageObject ); + CMdEObjectDef& videoObjDef = iDefNamespace->GetObjectDefL( MdeConstants::Video::KVideoObject ); + CMdEObjectDef& audioObjDef = iDefNamespace->GetObjectDefL( MdeConstants::Audio::KAudioObject ); + + CMdEObjectDef& objDef = iDefNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject); + iQueryForPlaceholders = iMdESession->NewObjectQueryL( *iDefNamespace, objDef, this ); + + iQueryForPlaceholders->SetResultMode( EQueryResultModeItem ); + + CMdELogicCondition& rootCondition = iQueryForPlaceholders->Conditions(); + rootCondition.SetOperator( ELogicConditionOperatorOr ); + + CMdEObjectCondition& imagePHObjectCondition = rootCondition.AddObjectConditionL(imageObjDef); + imagePHObjectCondition.SetPlaceholderOnly( ETrue ); + imagePHObjectCondition.SetNotPresent( ETrue ); + + CMdEObjectCondition& videoPHObjectCondition = rootCondition.AddObjectConditionL(videoObjDef); + videoPHObjectCondition.SetPlaceholderOnly( ETrue ); + videoPHObjectCondition.SetNotPresent( ETrue ); + + CMdEObjectCondition& audioPHObjectCondition = rootCondition.AddObjectConditionL(audioObjDef); + audioPHObjectCondition.SetPlaceholderOnly( ETrue ); + audioPHObjectCondition.SetNotPresent( ETrue ); + + iQueryForPlaceholders->FindL(); + + iQueryForPlaceholdersActive = ETrue; + + TN_DEBUG1( "CThumbAGProcessor::QueryForPlaceholders - end" ); + } + +// ----------------------------------------------------------------------------- +// CThumbAGProcessor::HandleCollectionMessage +// From MMPXCollectionObserver +// Handle collection message. +// ----------------------------------------------------------------------------- +// + +void CThumbAGProcessor::HandleCollectionMessage( CMPXMessage* aMessage, + TInt aError ) + { + if ( aError != KErrNone || !aMessage ) + { + return; + } + + TN_DEBUG1( "CThumbAGProcessor::HandleCollectionMessage" ); + + TMPXMessageId generalId( *aMessage->Value( KMPXMessageGeneralId ) ); + + //we are interestead of only general system events + if ( generalId == KMPXMessageGeneral ) + { + TInt event( *aMessage->Value( KMPXMessageGeneralEvent ) ); + if ( event == TMPXCollectionMessage::EBroadcastEvent ) + { + TInt op( *aMessage->Value( KMPXMessageGeneralType ) ); + + switch( op ) + { + //when MTP sync or music collection is started then pause processing + case EMcMsgRefreshStart: + case EMcMsgUSBMTPStart: + TN_DEBUG1("CThumbAGProcessor::HandleCollectionMessage MPX refresh started" ); + iMPXHarvesting = ETrue; + CancelTimeout(); + break; + //when MTP sync or music collection refresh is complete then resume processing + case EMcMsgRefreshEnd: + case EMcMsgUSBMTPEnd: + case EMcMsgUSBMTPNotActive: + TN_DEBUG1("CThumbAGProcessor::HandleCollectionMessage MPX refresh finished/not active" ); + iMPXHarvesting = EFalse; + StartTimeout(); + break; + default: + break; + } + TN_DEBUG3( "CThumbAGProcessor::HandleCollectionMessage -- end() iHarvesting == %d, iMPXHarvesting == %d", iHarvesting, iMPXHarvesting); + } + } + } +// ----------------------------------------------------------------------------- +// CThumbAGProcessor::HandleOpenL +// From MMPXCollectionObserver +// Handles the collection entries being opened. +// ----------------------------------------------------------------------------- +// +void CThumbAGProcessor::HandleOpenL( const CMPXMedia& /*aEntries*/, + TInt /*aIndex*/, + TBool /*aComplete*/, + TInt /*aError*/ ) + { + // not needed here + } + +// ----------------------------------------------------------------------------- +// CThumbAGProcessor::HandleOpenL +// From MMPXCollectionObserver +// Handles an item being opened. +// ----------------------------------------------------------------------------- +void CThumbAGProcessor::HandleOpenL( const CMPXCollectionPlaylist& /*aPlaylist*/, TInt /*aError*/ ) + { + // not needed here + } + +// ----------------------------------------------------------------------------- +// CThumbAGProcessor::HandleCollectionMediaL +// From MMPXCollectionObserver +// Handle media properties. +// ----------------------------------------------------------------------------- +// +void CThumbAGProcessor::HandleCollectionMediaL( const CMPXMedia& /*aMedia*/, + TInt /*aError*/ ) + { + // not needed here + } + +// End of file diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailclient/bwins/thumbnailmanageru.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailclient/bwins/thumbnailmanageru.def Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,22 @@ +EXPORTS + ?NewLC@CThumbnailObjectSource@@SAPAV1@ABVTDesC16@@0@Z @ 1 NONAME ; class CThumbnailObjectSource * CThumbnailObjectSource::NewLC(class TDesC16 const &, class TDesC16 const &) + ?NewL@CThumbnailObjectSource@@SAPAV1@ABVRFile64@@ABVTDesC16@@@Z @ 2 NONAME ; class CThumbnailObjectSource * CThumbnailObjectSource::NewL(class RFile64 const &, class TDesC16 const &) + ?NewL@CThumbnailManager@@SAPAV1@AAVMThumbnailManagerObserver@@@Z @ 3 NONAME ; class CThumbnailManager * CThumbnailManager::NewL(class MThumbnailManagerObserver &) + ?NewLC@CThumbnailObjectSource@@SAPAV1@ABVTDesC16@@K0@Z @ 4 NONAME ; class CThumbnailObjectSource * CThumbnailObjectSource::NewLC(class TDesC16 const &, unsigned long, class TDesC16 const &) + ?NewLC@CThumbnailObjectSource@@SAPAV1@ABVRFile64@@ABVTDesC16@@@Z @ 5 NONAME ; class CThumbnailObjectSource * CThumbnailObjectSource::NewLC(class RFile64 const &, class TDesC16 const &) + ?NewL@CThumbnailObjectSource@@SAPAV1@PAVTDesC8@@AAVTDesC16@@ABV3@@Z @ 6 NONAME ; class CThumbnailObjectSource * CThumbnailObjectSource::NewL(class TDesC8 *, class TDesC16 &, class TDesC16 const &) + ?NewL@CThumbnailObjectSource@@SAPAV1@PAVCFbsBitmap@@ABVTDesC16@@@Z @ 7 NONAME ; class CThumbnailObjectSource * CThumbnailObjectSource::NewL(class CFbsBitmap *, class TDesC16 const &) + ?NewLC@CThumbnailObjectSource@@SAPAV1@PAVCFbsBitmap@@ABVTDesC16@@@Z @ 8 NONAME ; class CThumbnailObjectSource * CThumbnailObjectSource::NewLC(class CFbsBitmap *, class TDesC16 const &) + ?NewL@CThumbnailObjectSource@@SAPAV1@ABVTDesC16@@0@Z @ 9 NONAME ; class CThumbnailObjectSource * CThumbnailObjectSource::NewL(class TDesC16 const &, class TDesC16 const &) + ?NewLC@CThumbnailObjectSource@@SAPAV1@PAVTDesC8@@AAVTDesC16@@ABV3@@Z @ 10 NONAME ; class CThumbnailObjectSource * CThumbnailObjectSource::NewLC(class TDesC8 *, class TDesC16 &, class TDesC16 const &) + ?NewL@CThumbnailObjectSource@@SAPAV1@ABVTDesC16@@K0@Z @ 11 NONAME ; class CThumbnailObjectSource * CThumbnailObjectSource::NewL(class TDesC16 const &, unsigned long, class TDesC16 const &) + ?NewLC@CThumbnailManager@@SAPAV1@AAVMThumbnailManagerObserver@@@Z @ 12 NONAME ; class CThumbnailManager * CThumbnailManager::NewLC(class MThumbnailManagerObserver &) + ?Buffer@CThumbnailObjectSource@@QAEPAVTDesC8@@XZ @ 13 NONAME ; class TDesC8 * CThumbnailObjectSource::Buffer(void) + ?FileHandle@CThumbnailObjectSource@@QAEAAVRFile64@@XZ @ 14 NONAME ; class RFile64 & CThumbnailObjectSource::FileHandle(void) + ?GetBufferOwnership@CThumbnailObjectSource@@QAEPAVTDesC8@@XZ @ 15 NONAME ; class TDesC8 * CThumbnailObjectSource::GetBufferOwnership(void) + ?Id@CThumbnailObjectSource@@QAEKXZ @ 16 NONAME ; unsigned long CThumbnailObjectSource::Id(void) + ?MimeType@CThumbnailObjectSource@@QAEABVTDesC8@@XZ @ 17 NONAME ; class TDesC8 const & CThumbnailObjectSource::MimeType(void) + ?Uri@CThumbnailObjectSource@@QAEABVTDesC16@@XZ @ 18 NONAME ; class TDesC16 const & CThumbnailObjectSource::Uri(void) + ?Bitmap@CThumbnailObjectSource@@QAEPAVCFbsBitmap@@XZ @ 19 NONAME ; class CFbsBitmap * CThumbnailObjectSource::Bitmap(void) + ?GetBitmapOwnership@CThumbnailObjectSource@@QAEPAVCFbsBitmap@@XZ @ 20 NONAME ; class CFbsBitmap * CThumbnailObjectSource::GetBitmapOwnership(void) + diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailclient/eabi/thumbnailmanageru.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailclient/eabi/thumbnailmanageru.def Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,24 @@ +EXPORTS + _ZN17CThumbnailManager4NewLER25MThumbnailManagerObserver @ 1 NONAME + _ZN17CThumbnailManager5NewLCER25MThumbnailManagerObserver @ 2 NONAME + _ZN22CThumbnailObjectSource4NewLERK7RFile64RK7TDesC16 @ 3 NONAME + _ZN22CThumbnailObjectSource4NewLERK7TDesC16S2_ @ 4 NONAME + _ZN22CThumbnailObjectSource5NewLCERK7RFile64RK7TDesC16 @ 5 NONAME + _ZN22CThumbnailObjectSource5NewLCERK7TDesC16S2_ @ 6 NONAME + _ZN22CThumbnailObjectSource10FileHandleEv @ 7 NONAME + _ZN22CThumbnailObjectSource3UriEv @ 8 NONAME + _ZN22CThumbnailObjectSource4NewLEP10CFbsBitmapRK7TDesC16 @ 9 NONAME + _ZN22CThumbnailObjectSource4NewLEP6TDesC8R7TDesC16RKS2_ @ 10 NONAME + _ZN22CThumbnailObjectSource5NewLCEP10CFbsBitmapRK7TDesC16 @ 11 NONAME + _ZN22CThumbnailObjectSource5NewLCEP6TDesC8R7TDesC16RKS2_ @ 12 NONAME + _ZN22CThumbnailObjectSource6BufferEv @ 13 NONAME + _ZN22CThumbnailObjectSource8MimeTypeEv @ 14 NONAME + _ZN22CThumbnailObjectSource18GetBufferOwnershipEv @ 15 NONAME + _ZN22CThumbnailObjectSource5NewLCERK7TDesC16mS2_ @ 16 NONAME + _ZN22CThumbnailObjectSource2IdEv @ 17 NONAME + _ZN22CThumbnailObjectSource4NewLERK7TDesC16mS2_ @ 18 NONAME + _ZN22CThumbnailObjectSource18GetBitmapOwnershipEv @ 19 NONAME + _ZN22CThumbnailObjectSource6BitmapEv @ 20 NONAME + _ZTI22CThumbnailRequestQueue @ 21 NONAME + _ZTV22CThumbnailRequestQueue @ 22 NONAME + diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailclient/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailclient/group/bld.inf Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Build information file for project ?myapp +* +*/ + + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_MMPFILES +thumbnailmanager.mmp + diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailclient/group/thumbnailmanager.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailclient/group/thumbnailmanager.mmp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Thumbnail manager client project definition file +* +*/ + + +// To get the MW_LAYER_SYSTEMINCLUDE-definition +#include + +#include +#include "../../inc/thumbnailmanageruids.hrh" + +VERSION 10.0 +TARGET thumbnailmanager.dll +TARGETTYPE DLL +UID 0x0 THUMBNAIL_MANAGER_CLIENT_DLL_UID + +CAPABILITY CAP_CLIENT_DLL +VENDORID VID_DEFAULT + +SOURCEPATH ../src +SOURCE thumbnailmanager.cpp +SOURCE thumbnailmanagerimpl.cpp +SOURCE thumbnailobjectsource.cpp +SOURCE thumbnailrequestactive.cpp +SOURCE thumbnailsession.cpp +SOURCE thumbnaildataimpl.cpp thumbnailrequestqueue.cpp + +// Default system include paths for middleware layer modules. +MW_LAYER_SYSTEMINCLUDE + +USERINCLUDE ../inc +USERINCLUDE ../../inc + +LIBRARY fbscli.lib +LIBRARY euser.lib +LIBRARY ecom.lib +LIBRARY efsrv.lib +LIBRARY bafl.lib +LIBRARY centralrepository.lib apmime.lib +LIBRARY hal.lib + +DEBUGLIBRARY flogger.lib + +PAGED +BYTEPAIRCOMPRESSTARGET diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailclient/inc/thumbnaildataimpl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailclient/inc/thumbnaildataimpl.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,106 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Thumbnail object implementation. + * +*/ + + +#ifndef THUMBNAILDATAIMPL_H +#define THUMBNAILDATAIMPL_H + +#include "thumbnaildata.h" + +/** + * Thumbnail object implementation. + * + * @since S60 v5.0 + */ +NONSHARABLE_CLASS( CThumbnailDataImpl ): public CBase, public MThumbnailData + { +public: + + /** + * C++ default constructor + * + * @since S60 v5.0 + * @return New thumbnail instance. + */ + CThumbnailDataImpl(); + + /** + * Destructor + * + * @since S60 v5.0 + */ + virtual ~CThumbnailDataImpl(); + +public: + + /** + * Get a pointer to a CFbsBitmap containing the thumbnail image. Ownership + * of the object is not transferred (i.e. client must not delete the + * pointer). + * @since S60 v5.0 + * @return Pointer to a bitmap representing the thumbnail or NULL if + * thumbnail pointer is not available or it has been detached. + */ + CFbsBitmap* Bitmap(); + + /** + * Get a pointer to a CFbsBitmap containing the thumbnail image. Ownership + * of the object is transferred to the caller. Client must delete the + * bitmap after it is done processing it. + * @since S60 v5.0 + * @return Pointer to a bitmap representing the thumbnail or NULL if + * thumbnail pointer is not available or it has been detached. + * Caller assumes ownership of the bitmap. + */ + CFbsBitmap* DetachBitmap(); + + /** + * Get client data structure. + * + * @since S60 v5.0 + * @return A pointer for client data specified as a parameter for + * GetThumbnailL() or NULL if not specified. + */ + TAny* ClientData(); + + /** + * Sets the thumbnail object data. + * + * @since S60 v5.0 + * @param aBitmap Bitmab for the object. + * @param aClientData Pointer to arbitrary client data. + * This pointer is not used by the API for + * anything other than returning it in the + * ThumbnailReady callback. + */ + void Set( CFbsBitmap* aBitmap, TAny* aClientData ); + +private: + // data + + /** + * Bitmap. + */ + CFbsBitmap* iBitmap; + + /** + * Arbitrary client data. + */ + TAny* iClientData; +}; + +#endif // THUMBNAILDATAIMPL_H diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailclient/inc/thumbnailmanagerimpl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailclient/inc/thumbnailmanagerimpl.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,440 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation class of Thumbnail Manager + * +*/ + + +#ifndef THUMBNAILMANAGERIMPL_H +#define THUMBNAILMANAGERIMPL_H + +#include + +#include "thumbnailmanager.h" +#include "thumbnailsession.h" +#include "thumbnailrequestqueue.h" +#include "thumbnaildata.h" + + +class CThumbnailRequestActive; + +/** + * Implementation class of thumbnail engine. + * + * @since S60 v5.0 + */ +NONSHARABLE_CLASS( CThumbnailManagerImpl ): public CThumbnailManager + { +public: + + /** + * Destructor + * + * @since S60 v5.0 + */ + virtual ~CThumbnailManagerImpl(); + + /** + * Two-phased constructor + * + * @since S60 v5.0 + * @param aObserver Observer to receive notifications about completed + * operations. + * @return New CThumbnailManagerImpl instance. + */ + static CThumbnailManagerImpl* NewLC( MThumbnailManagerObserver& aObserver ); + + /** + * Get a thumbnail for an object file. If a thumbnail already exists, it + * is loaded and if a thumbnail does not exist, it is created + * transparently. ThumbnailReady() callback will be called when the + * operation is complete. In addition, ThumbnailPreviewReady() + * callback may be called if EOptimizeForQualityWithPreview mode was + * defined. + * + * Current values for display mode, thumbnail size, flags and performance + * preference are used. + * + * @since S60 v5.0 + * @param aObjectSource Source object or file + * @param aClientData Pointer to arbitrary client data. + * This pointer is not used by the API for + * anything other than returning it in the + * ThumbnailReady callback. + * @param aPriority Priority for this operation + * @return Thumbnail request ID + */ + TThumbnailRequestId GetThumbnailL( CThumbnailObjectSource& aObjectSource, + TAny* aClientData = NULL, const TInt aPriority = CActive::EPriorityIdle + ); + + /** + * Get a thumbnail for an object file. If a thumbnail already exists, it + * is loaded and if a thumbnail does not exist, it is created + * transparently. ThumbnailReady() callback will be called when the + * operation is complete. In addition, ThumbnailPreviewReady() + * callback may be called if EOptimizeForQualityWithPreview mode was + * defined. + * + * Current values for display mode, thumbnail size, flags and performance + * preference are used. + * + * @since S60 v5.0 + * @param aObjectSource Source object or file + * @param aClientData Pointer to arbitrary client data. + * This pointer is not used by the API for + * anything other than returning it in the + * ThumbnailReady callback. + * @param aPriority Priority for this operation + * @param aGeneratePersistentSizesOnly Only persitent sizes generated + * @return Thumbnail request ID + */ + TThumbnailRequestId GetThumbnailL( CThumbnailObjectSource& aObjectSource, + TAny* aClientData, const TInt aPriority, TBool aGeneratePersistentSizesOnly); + + /** + * Get a persistent thumbnail for an object file. If a thumbnail already + * exists, it is loaded and if a thumbnail does not exist, it is created + * transparently. ThumbnailReady() callback will be called when the + * operation is complete. In addition, ThumbnailPreviewReady() + * callback may be called if EOptimizeForQualityWithPreview mode was + * defined. + * + * Current values for display mode, thumbnail size, flags and performance + * preference are used. + * + * @since S60 v5.0 + * @param aThumbnailId Thumbnail ID + * @param aThumbnailSizeType Thumbnail size enumeration + * @param aClientData Pointer to arbitrary client data. + * This pointer is not used by the API for + * anything other than returning it in the + * ThumbnailReady callback. + * @param aPriority Priority for this operation + * @return Thumbnail request ID. This can be used to + * cancel the request or change priority. + * The ID is specific to this CThumbnailManager + * instance and may not be shared with other + * instances. + */ + TThumbnailRequestId GetThumbnailL( const TThumbnailId, + TAny* aClientData = NULL, TInt aPriority = CActive::EPriorityIdle ); + + /** + * Import an image to be used as thumbnail for an object. If a + * thumbnail already exists, it is loaded and if a thumbnail does not + * exist, it is created transparently. ThumbnailReady() callback will be + * called when the operation is complete. In addition, ThumbnailPreviewReady() + * callback may be called if EOptimizeForQualityWithPreview mode was + * defined. + * + * Current values for display mode, thumbnail size, flags and performance + * preference are used. + * + * @since S60 v5.0 + * @param aObjectSource Source object or file + * @param aTargetUri Target URI to which the imported thumbnail is linked. + * @param aClientData Pointer to arbitrary client data. + * This pointer is not used by the API for + * anything other than returning it in the + * ThumbnailReady callback. + * @param aPriority Priority for this operation + * @return Thumbnail request ID + */ + TThumbnailRequestId ImportThumbnailL( CThumbnailObjectSource& aObjectSource, + const TDesC& aTargetUri, TAny* aClientData = NULL, + const TInt aPriority = CActive::EPriorityIdle ); + + /** + * Set persistent size scaled thumbnails for an object. If a + * thumbnail already exists, it is replaced and if a thumbnail does not + * exist, it is created transparently. + * + * Current values for display mode, thumbnail size, flags and performance + * preference are used. + * + * @since S60 v5.0 + * @param aObjectSource Source object or file + * @param aClientData Pointer to arbitrary client data. + * This pointer is not used by the API for + * anything other than returning it in the + * ThumbnailReady callback. + * @param aPriority Priority for this operation + * @return Thumbnail request ID. This can be used to + * cancel the request or change priority. + * The ID is specific to this CThumbnailManager + * instance and may not be shared with other + * instances. + */ + TThumbnailRequestId SetThumbnailL( CThumbnailObjectSource& source, + TAny* aClientData = NULL, + TInt aPriority = CActive::EPriorityIdle); + + /** + * Get the current display mode for thumbnail bitmaps. + * + * @since S60 v5.0 + * @return Default display mode for the thumbnail bitmaps. + */ + TDisplayMode DisplayMode()const; + + /** + * Set the current display mode for thumbnail bitmaps. + * + * @since S60 v5.0 + * @param aDisplayMode New display mode value for the thumbnail bitmaps. + */ + void SetDisplayModeL( const TDisplayMode aDisplayMode ); + + /** + * Get the current quality versus performance preference. + * + * @since S60 v5.0 + * @return Current quality versus performance preference. + */ + TThumbnailQualityPreference QualityPreference()const; + + /** + * Set quality versus performance preference. + * + * @since S60 v5.0 + * @param aQualityPreference New quality versus performance preference + * value. + */ + void SetQualityPreferenceL( const TThumbnailQualityPreference + aQualityPreference ); + + /** + * Get the current desired size for thumbnail bitmaps. + * + * @since S60 v5.0 + * @return Current desired size for thumbnail bitmaps (in pixels). + */ + const TSize& ThumbnailSize()const; + + /** + * Set desired size for thumbnail bitmaps. + * + * @since S60 v5.0 + * @param aThumbnailSize New quality for the desired thumbnail size. + */ + void SetThumbnailSizeL( const TSize& aThumbnailSize ); + + /** + * Set desired size for thumbnail bitmaps. + * + * @since S60 v5.0 + * @param aThumbnailSize New quality for the desired thumbnail size. + */ + void SetThumbnailSizeL( const TThumbnailSize aThumbnailSize ); + + /** + * Get current flags for thumbnail generation. + * + * @since S60 v5.0 + * @return Current flags. + */ + TThumbnailFlags Flags()const; + + /** + * Set flags for thumbnail generation. Several flags may be enabled + * by combining the values using bitwise or. + * + * @since S60 v5.0 + * @param aFlags New flags. + */ + void SetFlagsL( const TThumbnailFlags aFlags ); + + /** + * Delete all thumbnails for a given object. This is an asynchronous + * operation, which always returns immediately. + * + * @since S60 v5.0 + * @param aObjectSource Source object or file + */ + void DeleteThumbnails( CThumbnailObjectSource& aObjectSource ); + + /** + * Delete thumbnails by TThumbnailId. This is an asynchronous + * operation, which always returns immediately. + * + * @since S60 v5.0 + * @param aItemId TThumbnailId + */ + void DeleteThumbnails( const TThumbnailId aItemId ); + + /** + * Create thumbnail for a given object. This is an asynchronous + * operation, which always returns immediately. No callbacks are + * emitted. + * + * @since S60 v5.0 + * @param aObjectSource Source object or file + * @param aPriority Priority for this operation + * @return Thumbnail creation request ID + */ + TThumbnailRequestId CreateThumbnails( CThumbnailObjectSource& aObjectSource, + TInt aPriority = CActive::EPriorityIdle ); + + /** + * Cancel a thumbnail operation. + * + * @since S60 v5.0 + * @param aId Request ID for the operation to be cancelled. + * @return Symbian OS error code or KErrNone if cancelling was + * successful. + */ + TInt CancelRequest( const TThumbnailRequestId aId ); + + /** + * Change the priority of a queued thumbnail operation. + * + * @since S60 v5.0 + * @param aId Request ID for the request which to assign a new + * priority. + * @param aNewPriority New priority value + * @return Symbian OS error code or KErrNone if change was + * successful. + */ + TInt ChangePriority( const TThumbnailRequestId aId, const TInt aNewPriority + ); + + /** + * Get a list of supported file formats for object files. + * + * The return value is a reference to a list that contains each + * supported MIME type. There may also be wildcards, such as "image/ *". + * + * The returned reference is valid until CThumbnailManager is + * destroyed or GetSupportedMimeTypesL() is called again. + * + * @since S60 v5.0 + * @return A list of supported MIME types. May contain wildcards. + * Ownership not transferred. + */ + const CDesCArray& GetSupportedMimeTypesL(); + + /** + * Update Thumbnails by TThumbnailId. This is an asynchronous + * operation, which always returns immediately. + * + * @since S60 v5.0 + * @param aItemId TThumbnailId + * @param aPath (New) path for the Thumbnail + * @param aOrientation Thumbnail orientation + * @param aModified Last modified + * @param aPriority Priority for this operation + */ + void UpdateThumbnailsL( const TThumbnailId aItemId, const TDesC& aPath, + const TInt aOrientation, const TInt64 aModified, TInt aPriority ); + +private: + + /** + * C++ default constructor + * + * @since S60 v5.0 + * @param aObserver Observer to receive notifications about completed + * operations. + * @return New CThumbnailManagerImpl instance. + */ + CThumbnailManagerImpl( MThumbnailManagerObserver& aObserver ); + + /** + * Symbian 2nd phase constructor can leave. + * + * @since S60 v5.0 + */ + void ConstructL(); + + +private: + // data + + /** + * Default width of thumbnail. + */ + TInt iDefaultWidth; + + /** + * Default height of thumbnail + */ + TInt iDefaultHeight; + + /** + * Observer to receive notifications about completed operations. + */ + MThumbnailManagerObserver& iObserver; + + /** + * Session. + */ + RThumbnailSession iSession; + + /** + * Fileserver. + */ + RFs iFs; + + /** + * Request queue processor. + */ + CThumbnailRequestQueue* iRequestQueue; + + /** + * Display mode. + */ + TDisplayMode iDisplayMode; + + /** + * Flags. + */ + TThumbnailFlags iFlags; + + /** + * Quality preference. + */ + TThumbnailQualityPreference iQualityPreference; + + /** + * Requested size of thumbnail. + */ + TSize iSize; + + TThumbnailSize iThumbnailSize; + + /** + * Request ID for this thumbnail request, session specific. + */ + TThumbnailRequestId iRequestId; + + /** + * Font and Bitmap Server session. Only used unless the client + * does not already have an open session. + */ + RFbsSession iFbsSession; + + /** + * Temporary buffer for filename handling + */ + TFileName iFileNameBuf; + + /** + * List of supported MIME-types. + * Own. + */ + CDesCArraySeg* iMimeTypeList; +}; + +#endif diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailclient/inc/thumbnailrequestactive.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailclient/inc/thumbnailrequestactive.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,466 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Active object for an asynchronous thumbnail request + * +*/ + + +#ifndef THUMBNAILREQUESTACTIVE_H +#define THUMBNAILREQUESTACTIVE_H + +#include + +#include "thumbnailpanic.h" +#include "thumbnailmanager.h" +#include "thumbnailmanagerconstants.h" +#include "thumbnaillog.h" + +class RFs; +class CFbsBitmap; +class RThumbnailSession; +class CThumbnailDataImpl; +class CThumbnailRequestQueue; + +enum TThumbnailRequestType + { + EReqGetThumbnailHandle = 0, + EReqGetThumbnailPath = 1, + EReqSetThumbnailBuffer = 2, + EReqSetThumbnailBitmap = 3, + EReqUpdateThumbnails = 4, + EReqGetThumbnailHandleLater = 5, + EReqDeleteThumbnails = 6 +}; + +/** + * Active object for an asynchronous thumbnail request. + * + * @since S60 v5.0 + */ +NONSHARABLE_CLASS( CThumbnailRequestActive ): public CActive + { +public: + + /** + * Destructor + * + * @since S60 v5.0 + */ + virtual ~CThumbnailRequestActive(); + + /** + * Two-phased constructor + * + * @since S60 v5.0 + * @param aFs Fileserver used. + * @param aThumbnailSession Session used. + * @param aObserver Observer to receive notifications about completed + * operations. + * @param aId Assigned ID of the request, session specific. + * @param aPriority assigned processing priority + * @param aQueue request processor + * @return New CThumbnailRequestActive object. + */ + static CThumbnailRequestActive* NewL( RFs& aFs, RThumbnailSession& + aThumbnailSession, MThumbnailManagerObserver& aObserver, + TThumbnailRequestId aId, TInt aPriority, CThumbnailRequestQueue* aQueue ); + + /** + * Get a thumbnail created from file object. + * + * @since S60 v5.0 + * @param aFile File from which the thumbnail is to be created. + * @param aFlags Flags that control the creation of thumbnail. + * @param aQualityPreference Quality preference value + * @param aSize Requested size of the thumbnail. + * @param aDisplayMode Display mode. + * @param aPriority Priority of the request. + * @param aClientData Pointer to arbitrary client data. + * This pointer is not used by the API for + * anything other than returning it in the + * ThumbnailReady callback. + * @param aTargetUri Target URI to which the imported thumbnail is linked. + */ + void GetThumbnailL( const RFile64& aFile, TThumbnailId aThumbnailId, + CThumbnailManager::TThumbnailFlags aFlags, CThumbnailManager::TThumbnailQualityPreference + aQualityPreference, const TSize& aSize, const TDisplayMode aDisplayMode, + const TInt aPriority, TAny* aClientData, TBool aGeneratePersistentSizesOnly, const TDesC& aTargetUri = KNullDesC, + TThumbnailSize aThumbnailSize = EUnknownThumbnailSize ); + + /** + * Get a thumbnail opening file object later. + * + * @since S60 v5.0 + * @param aPath Path to file from which the thumbnail is to be created. + * @param aFlags Flags that control the creation of thumbnail. + * @param aQualityPreference Quality preference value + * @param aSize Requested size of the thumbnail. + * @param aDisplayMode Display mode. + * @param aPriority Priority of the request. + * @param aClientData Pointer to arbitrary client data. + * This pointer is not used by the API for + * anything other than returning it in the + * ThumbnailReady callback. + * @param aTargetUri Target URI to which the imported thumbnail is linked. + */ + void GetThumbnailL( TThumbnailId aThumbnailId, const TDesC& aPath, + CThumbnailManager::TThumbnailFlags aFlags, CThumbnailManager::TThumbnailQualityPreference + aQualityPreference, const TSize& aSize, const TDisplayMode aDisplayMode, + const TInt aPriority, TAny* aClientData, TBool aGeneratePersistentSizesOnly, const TDesC& aTargetUri = KNullDesC, + TThumbnailSize aThumbnailSize = EUnknownThumbnailSize ); + + /** + * Get a thumbnail created from file path. + * + * @since S60 v5.0 + * @param aPath Path to file from which the thumbnail is to be created. + * @param aFlags Flags that control the creation of thumbnail. + * @param aQualityPreference Quality preference value + * @param aSize Requested size of the thumbnail. + * @param aDisplayMode Display mode. + * @param aPriority Priority of the request. + * @param aClientData Pointer to arbitrary client data. + * This pointer is not used by the API for + * anything other than returning it in the + * ThumbnailReady callback. + * @param aGeneratePersistentSizesOnly + * @param aTargetUri Target URI to which the imported thumbnail is linked. + * @param aThumbnailSize Relative thumbnail size + */ + void GetThumbnailL( const TDesC& aPath, TThumbnailId aThumbnailId, + CThumbnailManager::TThumbnailFlags aFlags, + CThumbnailManager::TThumbnailQualityPreference aQualityPreference, + const TSize& aSize, const TDisplayMode aDisplayMode, const TInt aPriority, + TAny* aClientData, TBool aGeneratePersistentSizesOnly, + const TDesC& aTargetUri = KNullDesC, TThumbnailSize aThumbnailSize = EUnknownThumbnailSize ); + + /** + * Set a thumbnail + * + * @since S60 v5.0 + * @param aBuffer Buffer containing image where the thumbnail is to be created. + * @param aFlags Flags that control the creation of thumbnail. + * @param aQualityPreference Quality preference value + * @param aSize Requested size of the thumbnail. + * @param aDisplayMode Display mode. + * @param aPriority Priority of the request. + * @param aClientData Pointer to arbitrary client data. + * This pointer is not used by the API for + * anything other than returning it in the + * ThumbnailReady callback. + * @param aGeneratePersistentSizesOnly + * @param aTargetUri Target URI to which the imported thumbnail is linked. + * @param aThumbnailSize Requested thumbnail size + */ + void SetThumbnailL( TDesC8* aBuffer, TThumbnailId aThumbnailId, const TDesC8& aMimeType, + CThumbnailManager::TThumbnailFlags aFlags, CThumbnailManager + ::TThumbnailQualityPreference aQualityPreference, const TSize& aSize, const + TDisplayMode aDisplayMode, const TInt aPriority, TAny* aClientData, TBool aGeneratePersistentSizesOnly, + const TDesC& aTargetUri, TThumbnailSize aThumbnailSize ); + + /** + * Set a thumbnail + * + * @since S60 v5.0 + * @param aBitmap Bitmap + * @param aFlags Flags that control the creation of thumbnail. + * @param aQualityPreference Quality preference value + * @param aSize Requested size of the thumbnail. + * @param aDisplayMode Display mode. + * @param aPriority Priority of the request. + * @param aClientData Pointer to arbitrary client data. + * This pointer is not used by the API for + * anything other than returning it in the + * ThumbnailReady callback. + * @param aGeneratePersistentSizesOnly + * @param aTargetUri Target URI to which the imported thumbnail is linked. + * @param aThumbnailSize Requested thumbnail size + */ + void SetThumbnailL( CFbsBitmap* aBitmap, TThumbnailId aThumbnailId, const TDesC8& aMimeType, + CThumbnailManager::TThumbnailFlags aFlags, CThumbnailManager + ::TThumbnailQualityPreference aQualityPreference, const TSize& aSize, const + TDisplayMode aDisplayMode, const TInt aPriority, TAny* aClientData, TBool aGeneratePersistentSizesOnly, + const TDesC& aTargetUri, TThumbnailSize aThumbnailSize ); + + /** + * Update thumbnails by Id. + * + * @since S60 v5.0 + * @param aPath Path to file from which the thumbnail is to be created. + * @param aFlags Flags that control the creation of thumbnail. + * @param aQualityPreference Quality preference value + * @param aSize Requested size of the thumbnail. + * @param aDisplayMode Display mode. + * @param aPriority Priority of the request. + * @param aOrientation Thumbnail orientation + * @param aModified Last modified + */ + void UpdateThumbnailsL( const TDesC& aPath, const TThumbnailId aThumbnailId, + CThumbnailManager::TThumbnailFlags aFlags, + CThumbnailManager::TThumbnailQualityPreference aQualityPreference, + const TDisplayMode aDisplayMode, const TInt aPriority, const TInt aOrientation, + const TInt64 aModified ); + + /** + * Delete thumbnails. + * + * @since S60 v5.0 + * @param aPath Path to file from which the thumbnail is to be created. + * @param aPriority Priority of the request. + */ + void DeleteThumbnails( const TDesC& aPath, const TThumbnailId aThumbnailId, + const TInt aPriority ); + + /** + * Start active request. + * + * @since S60 v5.0 + */ + void StartL(); + + /** + * Change priority of a request. + * + * @since S60 v5.0 + * @param aNewPriority New priority. + * @return Error code. + */ + void ChangePriority( const TInt aNewPriority ); + + /** + * Returns ID of thumbnail request. + * + * @since S60 v5.0 + * @return Request ID + */ + TThumbnailRequestId RequestId()const; + + /** + * Is thumbnail request completed + * + * @since S60 v5.0 + */ + TBool RequestCompleted()const; + + /** + * Is thumbnail request active + * + * @since S60 v5.0 + */ + TBool IsRequestActive()const; + +private: + + /** + * C++ default constructor + * + * @since S60 v5.0 + * @param aFs Fileserver used. + * @param aThumbnailSession Session used. + * @param aObserver Observer to receive notifications about completed + * operations. + * @param aId Assigned ID of the request, session specific. + * @param aPriority assigned processing priority + * @param aQueue request processor + * @return New CThumbnailRequestActive object. + */ + CThumbnailRequestActive( RFs& aFs, RThumbnailSession& aThumbnailSession, + MThumbnailManagerObserver& aObserver, TThumbnailRequestId aId, TInt aPriority, + CThumbnailRequestQueue* aQueue); + + /** + * Symbian 2nd phase constructor can leave. + * + * @since S60 v5.0 + */ + void ConstructL(); + + /** + * Handles an active object's request completion event. + * + * @since S60 v5.0 + */ + void RunL(); + + /** + * Handles a leave occurring in the request completion event handler + * RunL(). + * + * @since S60 v5.0 + * @param aError The leave code. + * @return Error code. + */ + TInt RunError( TInt aError ); + + /** + * Implements cancellation of an outstanding request. + * + * @since S60 v5.0 + */ + void DoCancel(); + + /** + * Release bitmap instance kept by server process. + * + * @since S60 v5.0 + */ + void ReleaseServerBitmap(); + + /** + * Error handling function. + * + * @since S60 v5.0 + */ + void HandleError(); + + /** + * Request 2nd phase thumbnail + * + * @since S60 v5.0 + */ + void Get2ndPhaseThumbnailL(); + + /** + * Callback for timeout timer + * + * @since S60 v5.0 + */ + static TInt TimerCallBack(TAny* aAny); + +private: + // data + + /** + * Session. + */ + RThumbnailSession& iSession; + + /** + * Request parameters. + */ + TThumbnailRequestParams iParams; + + /** + * Package for request parameters. + */ + TThumbnailRequestParamsPckg iParamsPckg; + + /** + * Observer to receive notifications about completed operations. + */ + MThumbnailManagerObserver& iObserver; + + /** + * Fileserver, not own + */ + RFs& iFs; + + /** + * Client data. + */ + TAny* iClientData; + + /** + * Callback, own. + */ + CThumbnailDataImpl* iCallbackThumbnail; + + /** + * Handle to bitmap, own. + */ + TInt iBitmapHandle; + + /** + * Error code. + */ + TInt iError; + + /** + * Request id of thumbnail request, session specific. + */ + TThumbnailRequestId iRequestId; + + /** + * Duplicated file handle for two phase operation + */ + RFile64 iMyFileHandle; + + /** + * If set, we are currently processing the preview thumbnail + * of a two phase operation. If an error occurs, we can skip + * directly to 2nd phase. + */ + TBool iProcessingPreview; + + /** + * If set, this request object can be deleted. + */ + TBool iRequestCompleted; + + /** + * If set, this request object is under processing + */ + TBool iRequestActive; + + /** + * Bitmap that is passed to server + */ + CFbsBitmap* iBitmap; + + // for activating requests + RFile64 iFile; + TFileName iPath; + TFileName iTargetUri; + TInt iOrientation; + TInt64 iModified; + + // not own + CThumbnailRequestQueue* iRequestQueue; + + TThumbnailRequestType iRequestType; + + // request timeout timer + CPeriodic* iTimer; + +#ifdef _DEBUG + TTime iStartExecTime; +#endif +}; + +#endif // THUMBNAILREQUESTACTIVE_H + + + +// INLINE FUNCTIONS + +inline TBool CThumbnailRequestActive::RequestCompleted()const + { + return iRequestCompleted; + } + +inline TBool CThumbnailRequestActive::IsRequestActive()const + { + if(IsActive()) + { + return ETrue; + } + return iRequestActive; + } + +inline TThumbnailRequestId CThumbnailRequestActive::RequestId()const + { + __ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId )); + + return iRequestId; + } diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailclient/inc/thumbnailrequestqueue.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailclient/inc/thumbnailrequestqueue.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,129 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Processor object for running thumbnail requests +* +*/ + + +#ifndef THUMBNAILREQUESTQUEUE_H +#define THUMBNAILREQUESTQUEUE_H + +#include + +#include "thumbnailmanager.h" + +class CThumbnailRequestActive; + +/** + * Processor object for running queued tasks. + * + * @since S60 v5.0 + */ +class CThumbnailRequestQueue: public CBase + { +public: + + /** + * Two-phased constructor. + * + * @since S60 v5.0 + * @return Instance of CThumbnailRequestQueue. + */ + static CThumbnailRequestQueue* NewL(); + + /** + * Destructor + * + * @since S60 v5.0 + */ + virtual ~CThumbnailRequestQueue(); + + /** + * Activates next request if possible. + * + * @since S60 v5.0 + */ + void Process(); + + /** + * Adds new request to the queue. + * + * @since S60 v5.0 + * @param aRequest Request to be added to the queue. + */ + void AddRequestL( CThumbnailRequestActive* aRequest ); + + /** + * Cancels request in the queue. + * + * @since S60 v5.0 + * @param aId Request to be canceled. + * @return Error code. + */ + TInt CancelRequest( const TThumbnailRequestId aId ); + + /** + * Change priority of a request. + * + * @since S60 v5.0 + * @param aId Request to be canceled. + * @param aNewPriority New priority. + * @return Error code. + */ + TInt ChangePriority( const TThumbnailRequestId aId, const TInt aNewPriority ); + + /** + * Marks request complete. + * + * @since S60 v5.0 + */ + void RequestComplete(CThumbnailRequestActive* aRequestAO = NULL); + + /** + * Removes completed requests. + * + * @since S60 v5.0 + */ + void RemoveCompleted(CThumbnailRequestActive* aRequestAO); + +private: + + /** + * C++ default constructor + * + * @since S60 v5.0 + * @return Instance of CThumbnailRequestQueue. + */ + CThumbnailRequestQueue(); + + /** + * Symbian 2nd phase constructor can leave. + * + * @since S60 v5.0 + */ + void ConstructL(); + +private: + + /** + * Array of active objects for each pending thumbnail request. + */ + RPointerArray iRequests; + + // number of currently active requests + TInt iActiveRequests; + +}; + +#endif // THUMBNAILREQUESTQUEUE_H diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailclient/inc/thumbnailsession.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailclient/inc/thumbnailsession.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,216 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Thumbnail server client-side session + * +*/ + + +#ifndef THUMBNAILSESSION_H +#define THUMBNAILSESSION_H + +#include + +#include "thumbnailmanagerconstants.h" + +/** + * Thumbnail server client-side session + * + * @since S60 v5.0 + */ +NONSHARABLE_CLASS( RThumbnailSession ): public RSessionBase + { +public: + + /** + * C++ default constructor. + * + * @since S60 v5.0 + * @return New RThumbnailSession session. + */ + RThumbnailSession(); + + /** + * Connect to server process. + * + * @since S60 v5.0 + * @return Error code. + */ + TInt Connect(); + + /** + * Close session. + * + * @since S60 v5.0 + */ + void Close(); + + /** + * Version info. + * + * @since S60 v5.0 + * @return Version of client. + */ + TVersion Version(); + + /** + * Request a thumbnail for an object file. + * + * @since S60 v5.0 + * @param aFile File from which the thumbnail is to be created. + * @param aTargetUri Target URI to which the imported thumbnail is linked. + * @param aParams Package for request parameters. + * @param aStatus Status of the request. + */ + void RequestThumbnailL( const RFile64& aFile, const TDesC& aTargetUri, TThumbnailRequestParamsPckg& + aParams, TRequestStatus& aStatus ); + + /** + * Request a thumbnail for an object file. + * + * @since S60 v5.0 + * @param aPath Path of image from which the thumbnail is to be created. + * @param aTargetUri Target URI to which the imported thumbnail is linked. + * @param aParams Package for request parameters. + * @param aStatus Status of the request. + */ + void RequestThumbnailL( const TDesC& aPath, const TDesC& aTargetUri, const TThumbnailId aThumbnailId, TThumbnailRequestParamsPckg& + aParams, TRequestStatus& aStatus ); + + /** + * Request a thumbnail for an object file. + * + * @since S60 v5.0 + * @param aThumbnailId Thumbnail ID + * @param aTargetUri Target URI to which the imported thumbnail is linked. + * @param aParams Package for request parameters. + * @param aStatus Status of the request. + */ + void RequestThumbnailL( const TThumbnailId aThumbnailId, const TDesC& aTargetUri, + TThumbnailRequestParamsPckg& aParams, TRequestStatus& aStatus ); + + /** + * Request set thumbnail for an object file. + * + * @since S60 v5.0 + * @param aBuffer buffer from which the thumbnail is to be created. + * @param aTargetUri Target URI to which the imported thumbnail is linked. + * @param aParams Package for request parameters. + * @param aStatus Status of the request. + */ + void RequestSetThumbnailL( + TDesC8* aBuffer, const TDesC& aTargetUri, + TThumbnailRequestParamsPckg& aParams, + TRequestStatus& aStatus ); + + /** + * Request set thumbnail for an object file. + * + * @since S60 v5.0 + * @param aBitmapHandle Bitmap handle + * @param aTargetUri Target URI to which the imported thumbnail is linked. + * @param aParams Package for request parameters. + * @param aStatus Status of the request. + */ + void RequestSetThumbnailL( + TInt aBitmapHandle, const TDesC& aTargetUri, + TThumbnailRequestParamsPckg& aParams, + TRequestStatus& aStatus ); + + /** + * Release bitmap instance kept by server process. + * + * @since S60 v5.0 + * @param aBitmapHandle Handle to bitmap. + */ + void ReleaseBitmap( TInt aBitmapHandle ); + + /** + * Cancel pending thumbnail request. + * + * @since S60 v5.0 + * @param aRequestId Session specific thumbnail request ID. + * @return Error code. + */ + TInt CancelRequest( TThumbnailRequestId aRequestId ); + + /** + * Change priority of pending thumbnail request. + * + * @since S60 v5.0 + * @param aRequestId Session specific thumbnail request ID. + * @param aNewPriority New priority to be set for the request. + * @return Error code. + */ + TInt ChangePriority( TThumbnailRequestId aRequestId, TInt aNewPriority ); + + /** + * Create thumbnails. + * + * @since S60 v5.0 + * @param aPath Path to media object whose thumbnails should be created. + * @return Error code. + */ + TInt CreateThumbnails( const RFile64& aFile, TDisplayMode aDisplayMode ); + + /** + * Delete thumbnails. + * + * @since S60 v5.0 + * @param aPath Path to media object whose thumbnails should be deleted. + */ + void DeleteThumbnails( const TDesC& aPath, TThumbnailRequestParamsPckg& aParams, + TRequestStatus& aStatus ); + + /** + * Delete thumbnails. + * + * @since S60 v5.0 + * @param aItemId Id of item whose thumbnails should be deleted. + */ + void DeleteThumbnails( const TThumbnailId aItemId, TThumbnailRequestParamsPckg& aParams, + TRequestStatus& aStatus ); + + /** + * Get a list of supported MIME types in a HBufC. The list is space + * delimited. + * + * @since S60 v5.0 + * @return MIME type list. Ownership transferred to called. + */ + HBufC* GetMimeTypeListL(); + + /** + * Update thumbnails. + * + * @since S60 v5.0 + * @param aPath (New) path for the Thumbnail + * @param aOrientation Thumbnail orientation + * @param aModified Last modified + */ + void UpdateThumbnails( const TDesC& aPath, const TInt aOrientation, const TInt64 aModified, + TThumbnailRequestParamsPckg& aParams, TRequestStatus& aStatus); + +private: + + /** + * Launch server process. + * + * @since S60 v5.0 + * @return Error code. + */ + TInt StartServer(); + +}; + +#endif // THUMBNAILSESSION_H diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnaildataimpl.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnaildataimpl.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,95 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Thumbnail object implementation. + * +*/ + + +#include + +#include "thumbnaildataimpl.h" + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CThumbnailDataImpl::CThumbnailDataImpl() +// C++ default constructor can NOT contain any code, that might leave. +// --------------------------------------------------------------------------- +// +CThumbnailDataImpl::CThumbnailDataImpl() + { + // No implementation required + } + + +// --------------------------------------------------------------------------- +// CThumbnailDataImpl::~CThumbnailDataImpl() +// Destructor. +// --------------------------------------------------------------------------- +// +CThumbnailDataImpl::~CThumbnailDataImpl() + { + delete iBitmap; + iClientData = NULL; + } + + +// --------------------------------------------------------------------------- +// CThumbnailDataImpl::Bitmap() +// Get a pointer to a CFbsBitmap containing the thumbnail image. +// --------------------------------------------------------------------------- +// +CFbsBitmap* CThumbnailDataImpl::Bitmap() + { + return iBitmap; + } + + +// --------------------------------------------------------------------------- +// CThumbnailDataImpl::DetachBitmap() +// Get a pointer to a CFbsBitmap containing the thumbnail image. +// --------------------------------------------------------------------------- +// +CFbsBitmap* CThumbnailDataImpl::DetachBitmap() + { + CFbsBitmap* ret = iBitmap; + iBitmap = NULL; // client owns it now + return ret; + } + + +// --------------------------------------------------------------------------- +// CThumbnailDataImpl::ClientData() +// Get client data structure. +// --------------------------------------------------------------------------- +// +TAny* CThumbnailDataImpl::ClientData() + { + return iClientData; + } + + +// --------------------------------------------------------------------------- +// CThumbnailDataImpl::Set +// Sets the thumbnail object. +// --------------------------------------------------------------------------- +// +void CThumbnailDataImpl::Set( CFbsBitmap* aBitmap, TAny* aClientData ) + { + delete iBitmap; + iBitmap = aBitmap; + iClientData = aClientData; + } + +// End of file diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailmanager.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailmanager.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Main interface class to Thumbnail Manager. + * +*/ + + +#include "thumbnailmanagerimpl.h" + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CThumbnailManager* CThumbnailManager::NewL() +// Two-phased constructor. +// --------------------------------------------------------------------------- +// +EXPORT_C CThumbnailManager* CThumbnailManager::NewL( MThumbnailManagerObserver& + aObserver ) + { + CThumbnailManager* self = CThumbnailManagerImpl::NewLC( aObserver ); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------------------------- +// CThumbnailManager* CThumbnailManager::NewLC() +// Two-phased constructor. +// --------------------------------------------------------------------------- +// +EXPORT_C CThumbnailManager* CThumbnailManager::NewLC( + MThumbnailManagerObserver& aObserver ) + { + return CThumbnailManagerImpl::NewLC( aObserver ); + } + +// --------------------------------------------------------------------------- +// CThumbnailManager::~CThumbnailManager() +// C++ default constructor can NOT contain any code, that might leave. +// --------------------------------------------------------------------------- +// +CThumbnailManager::~CThumbnailManager() + { + // No implementation required + } + +// End of file diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailmanagerimpl.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailmanagerimpl.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,621 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation class of Thumbnail Manager. + * +*/ + + +#include +#include +#include +#include +#include + +#include + +#include "thumbnailmanagerimpl.h" +#include "thumbnailrequestactive.h" +#include "thumbnailprovider.h" +#include "thumbnailsession.h" +#include "thumbnailmanageruids.hrh" +#include "thumbnailmanagerprivatecrkeys.h" +#include "thumbnailpanic.h" + +#include "thumbnaildata.h" + + +const TInt KThumbnailMimeTypeListGranularity = 8; + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CThumbnailManagerImpl::~CThumbnailManagerImpl() +// Destructor. +// --------------------------------------------------------------------------- +// +CThumbnailManagerImpl::~CThumbnailManagerImpl() + { + delete iRequestQueue; + iSession.Close(); + iFs.Close(); + + // Check if we need to disconnect Fbs + TInt sessionCount = (TInt)Dll::Tls(); + if ( sessionCount > 0) + { + if( --sessionCount == 0 ) + { + TN_DEBUG1( "CThumbnailManagerImpl::~CThumbnailManagerImpl() - Disconnect FBS" ); + iFbsSession.Disconnect(); + } + TN_DEBUG2( "CThumbnailManagerImpl::~CThumbnailManagerImpl() - update sessionCount == %d to TLS", sessionCount ); + Dll::SetTls( (TAny*)sessionCount ); + } + + delete iMimeTypeList; + } + + +// --------------------------------------------------------------------------- +// CThumbnailManagerImpl::NewLC() +// Two-phased constructor. +// --------------------------------------------------------------------------- +// +CThumbnailManagerImpl* CThumbnailManagerImpl::NewLC( MThumbnailManagerObserver& + aObserver ) + { + CThumbnailManagerImpl* self = new( ELeave )CThumbnailManagerImpl( aObserver ); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + + +// --------------------------------------------------------------------------- +// CThumbnailManagerImpl::CThumbnailManagerImpl() +// C++ default constructor can NOT contain any code, that might leave. +// --------------------------------------------------------------------------- +// +CThumbnailManagerImpl::CThumbnailManagerImpl( MThumbnailManagerObserver& + aObserver ): iObserver( aObserver ), iDisplayMode( + KThumbnailDefaultDisplayMode ), iFlags( EDefaultFlags ), iQualityPreference + ( EOptimizeForQuality ), iRequestId( 0 ) + { + // No implementation required + } + + +// --------------------------------------------------------------------------- +// CThumbnailManagerImpl::ConstructL() +// Symbian 2nd phase constructor can leave. +// --------------------------------------------------------------------------- +// +void CThumbnailManagerImpl::ConstructL() + { + User::LeaveIfError( iSession.Connect()); + User::LeaveIfError( iFs.Connect()); + User::LeaveIfError( iFs.ShareProtected()); + + if ( !RFbsSession::GetSession() ) + { + // We need to connect to Fbs (first user in this thread) + // Maintain a reference count in TLS + User::LeaveIfError( iFbsSession.Connect()); + Dll::SetTls( (TAny*)1 ); + TN_DEBUG2( "CThumbnailManagerImpl::ConstructL() - update sessionCount == %d to TLS", 1 ); + } + else + { + TInt sessionCount = (TInt)Dll::Tls(); + if( sessionCount++ > 0 ) + { + // Increase the reference count in TLS + Dll::SetTls( (TAny*)sessionCount ); + TN_DEBUG2( "CThumbnailManagerImpl::ConstructL() - update sessionCount == %d to TLS", sessionCount ); + } + else + { + // Fbs connection was available in the beginning, no need to + // increase the reference count + } + } + + // request processor + iRequestQueue = CThumbnailRequestQueue::NewL(); + } + + +// --------------------------------------------------------------------------- +// CThumbnailManagerImpl::GetThumbnailL +// Get a thumbnail for an object file. +// --------------------------------------------------------------------------- +// +TThumbnailRequestId CThumbnailManagerImpl::GetThumbnailL( + CThumbnailObjectSource& aObjectSource, TAny* aClientData /*= NULL*/, const + TInt aPriority, TBool aGeneratePersistentSizesOnly) + { + iRequestId++; + TN_DEBUG4( "CThumbnailManagerImpl::GetThumbnailL() URI==%S, iThumbnailSize==%d %d", &aObjectSource.Uri(), iThumbnailSize, iRequestId ); + + __ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId )); + + CThumbnailRequestActive* getThumbnailActive = CThumbnailRequestActive::NewL + ( iFs, iSession, iObserver, iRequestId, aPriority, iRequestQueue ); + CleanupStack::PushL( getThumbnailActive ); + + if(aObjectSource.Id() > 0) + { + getThumbnailActive->GetThumbnailL( aObjectSource.Uri(), aObjectSource.Id(), iFlags, + iQualityPreference, iSize, iDisplayMode, aPriority, aClientData, aGeneratePersistentSizesOnly, + KNullDesC, iThumbnailSize); + } + else if ( aObjectSource.Uri().Length()) + { + getThumbnailActive->GetThumbnailL( aObjectSource.Uri(), aObjectSource.Id(), iFlags, + iQualityPreference, iSize, iDisplayMode, aPriority, aClientData, aGeneratePersistentSizesOnly, + KNullDesC, iThumbnailSize ); + } + else + { + getThumbnailActive->GetThumbnailL( aObjectSource.FileHandle(), aObjectSource.Id(), iFlags, + iQualityPreference, iSize, iDisplayMode, aPriority, aClientData, aGeneratePersistentSizesOnly, + KNullDesC, iThumbnailSize ); + } + + iRequestQueue->AddRequestL( getThumbnailActive ); + CleanupStack::Pop( getThumbnailActive ); + + iRequestQueue->Process(); + + TN_DEBUG2( "CThumbnailManagerImpl::GetThumbnailL() - request ID: %d", iRequestId ); + + return iRequestId; + } + +// --------------------------------------------------------------------------- +// CThumbnailManagerImpl::GetThumbnailL +// Get a thumbnail for an object file. +// --------------------------------------------------------------------------- +// +TThumbnailRequestId CThumbnailManagerImpl::GetThumbnailL( + CThumbnailObjectSource& aObjectSource, TAny* aClientData /*= NULL*/, const + TInt aPriority ) + { + return GetThumbnailL( aObjectSource, aClientData, aPriority, EFalse ); + } + + +// --------------------------------------------------------------------------- +// CThumbnailManagerImpl::GetThumbnailL +// Get a thumbnail for an object file. +// --------------------------------------------------------------------------- +// +TThumbnailRequestId CThumbnailManagerImpl::GetThumbnailL( const TThumbnailId + aThumbnailId, TAny* aClientData /*= NULL*/, TInt aPriority) + { + iRequestId++; + TN_DEBUG5( "CThumbnailManagerImpl::GetThumbnailL() reqid==%d, aThumbnailId==%d, iThumbnailSize==%d %d", iRequestId, aThumbnailId, iThumbnailSize, iRequestId ); + + __ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId )); + + CThumbnailRequestActive* getThumbnailActive = CThumbnailRequestActive::NewL + ( iFs, iSession, iObserver, iRequestId, aPriority, iRequestQueue ); + CleanupStack::PushL( getThumbnailActive ); + + getThumbnailActive->GetThumbnailL( KNullDesC, aThumbnailId, iFlags, + iQualityPreference, iSize, iDisplayMode, aPriority, aClientData, + EFalse, KNullDesC, iThumbnailSize ); + + iRequestQueue->AddRequestL( getThumbnailActive ); + CleanupStack::Pop( getThumbnailActive ); + + iRequestQueue->Process(); + + TN_DEBUG2( "CThumbnailManagerImpl::GetThumbnailL() - request ID: %d", iRequestId ); + + return iRequestId; + } + + +// --------------------------------------------------------------------------- +// CThumbnailManagerImpl::ImportThumbnailL +// Import an image to be used as thumbnail for an object. +// --------------------------------------------------------------------------- +// +TThumbnailRequestId CThumbnailManagerImpl::ImportThumbnailL( + CThumbnailObjectSource& aObjectSource, const TDesC& aTargetUri, + TAny* aClientData /*= NULL*/, const TInt aPriority) + { + iRequestId++; + + __ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId )); + + CThumbnailRequestActive* getThumbnailActive = CThumbnailRequestActive::NewL + ( iFs, iSession, iObserver, iRequestId, aPriority, iRequestQueue ); + CleanupStack::PushL( getThumbnailActive ); + + if ( aObjectSource.Uri().Length()) + { + getThumbnailActive->GetThumbnailL( aObjectSource.Uri(), aObjectSource.Id(), iFlags, + iQualityPreference, iSize, iDisplayMode, aPriority, aClientData, + EFalse, aTargetUri, iThumbnailSize ); + } + else + { + getThumbnailActive->GetThumbnailL( aObjectSource.FileHandle(), aObjectSource.Id(), + iFlags, iQualityPreference, iSize, iDisplayMode, aPriority, aClientData, + EFalse, aTargetUri, iThumbnailSize ); + } + + iRequestQueue->AddRequestL( getThumbnailActive ); + CleanupStack::Pop( getThumbnailActive ); + + iRequestQueue->Process(); + + TN_DEBUG2( "CThumbnailManagerImpl::ImportThumbnailL() - request ID: %d", iRequestId ); + + return iRequestId; + } + +// --------------------------------------------------------------------------- +// CThumbnailManagerImpl::SetThumbnailL +// Import an image to be used as thumbnail for an object. +// --------------------------------------------------------------------------- +// +TThumbnailRequestId CThumbnailManagerImpl::SetThumbnailL( CThumbnailObjectSource& aObjectSource, + TAny* aClientData, TInt aPriority ) + { + iRequestId++; + + __ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId )); + + CThumbnailRequestActive* getThumbnailActive = CThumbnailRequestActive::NewL + ( iFs, iSession, iObserver, iRequestId, aPriority, iRequestQueue ); + CleanupStack::PushL( getThumbnailActive ); + + if ( aObjectSource.Uri().Length() && + aObjectSource.Buffer() != NULL && + aObjectSource.MimeType() != KNullDesC8) + { + getThumbnailActive->SetThumbnailL( aObjectSource.GetBufferOwnership(), aObjectSource.Id(), + aObjectSource.MimeType(), iFlags, iQualityPreference, iSize, iDisplayMode, + aPriority, aClientData, EFalse, aObjectSource.Uri(), iThumbnailSize); + } + + iRequestQueue->AddRequestL( getThumbnailActive ); + CleanupStack::Pop( getThumbnailActive ); + + iRequestQueue->Process(); + + TN_DEBUG2( "CThumbnailManagerImpl::SetThumbnailL() - request ID: %d", iRequestId ); + + return iRequestId; + } + +// --------------------------------------------------------------------------- +// CThumbnailManagerImpl::CreateThumbnails +// Create persistent size thumbnails for an object. +// --------------------------------------------------------------------------- +// +TThumbnailRequestId CThumbnailManagerImpl::CreateThumbnails( + CThumbnailObjectSource& aObjectSource, TInt aPriority ) + { + TRAPD(err, + TN_DEBUG2( "CThumbnailManagerImpl::CreateThumbnails() aObjectSource==%S ", &aObjectSource.Uri() ); + iRequestId++; + + __ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId )); + + CThumbnailRequestActive* getThumbnailActive = CThumbnailRequestActive::NewL + ( iFs, iSession, iObserver, iRequestId, aPriority, iRequestQueue ); + + CleanupStack::PushL( getThumbnailActive ); + + if (aObjectSource.Bitmap()) + { + // from bitmap + getThumbnailActive->SetThumbnailL( aObjectSource.GetBitmapOwnership(), + aObjectSource.Id(), KBmpMime, iFlags, iQualityPreference, + iSize, iDisplayMode, aPriority, NULL, ETrue, + aObjectSource.Uri(), EUnknownThumbnailSize); + } + else if( !aObjectSource.Buffer() ) + { + getThumbnailActive->GetThumbnailL( aObjectSource.Id(), + aObjectSource.Uri(), iFlags, iQualityPreference, iSize, + iDisplayMode, aPriority, NULL, ETrue, aObjectSource.Uri(), + EUnknownThumbnailSize); + } + else + { + // from buffer + getThumbnailActive->SetThumbnailL( aObjectSource.GetBufferOwnership(), + aObjectSource.Id(), aObjectSource.MimeType(), iFlags, + iQualityPreference, iSize, iDisplayMode, aPriority, NULL, + ETrue, aObjectSource.Uri(), EUnknownThumbnailSize); + } + + iRequestQueue->AddRequestL( getThumbnailActive ); + + CleanupStack::Pop( getThumbnailActive ); + + iRequestQueue->Process(); + + TN_DEBUG2( "CThumbnailManagerImpl::CreateThumbnails() - request ID: %d", iRequestId ); + ); + + if( err != KErrNone) + { + return err; + } + + return iRequestId; + } + + +// --------------------------------------------------------------------------- +// CThumbnailManagerImpl::DisplayMode() +// Get the current display mode for thumbnail bitmaps. +// --------------------------------------------------------------------------- +// +TDisplayMode CThumbnailManagerImpl::DisplayMode()const + { + return iDisplayMode; + } + + +// --------------------------------------------------------------------------- +// CThumbnailManagerImpl::SetDisplayModeL() +// Set the current display mode for thumbnail bitmaps. +// --------------------------------------------------------------------------- +// +void CThumbnailManagerImpl::SetDisplayModeL( const TDisplayMode aDisplayMode ) + { + iDisplayMode = aDisplayMode; + } + + +// --------------------------------------------------------------------------- +// CThumbnailManagerImpl::QualityPreference() +// Get the current quality versus performance preference. +// --------------------------------------------------------------------------- +// +CThumbnailManager::TThumbnailQualityPreference CThumbnailManagerImpl + ::QualityPreference()const + { + return iQualityPreference; + } + + +// --------------------------------------------------------------------------- +// CThumbnailManagerImpl::SetQualityPreferenceL() +// Set quality versus performance preference. +// --------------------------------------------------------------------------- +// +void CThumbnailManagerImpl::SetQualityPreferenceL( const + TThumbnailQualityPreference aQualityPreference ) + { + iQualityPreference = aQualityPreference; + } + + +// --------------------------------------------------------------------------- +// CThumbnailManagerImpl::ThumbnailSize() +// Get the current desired size for thumbnail bitmaps. +// --------------------------------------------------------------------------- +// +const TSize& CThumbnailManagerImpl::ThumbnailSize()const + { + return iSize; + } + + +// --------------------------------------------------------------------------- +// CThumbnailManagerImpl::SetThumbnailSizeL() +// Set desired size for thumbnail bitmaps. +// --------------------------------------------------------------------------- +// +void CThumbnailManagerImpl::SetThumbnailSizeL( const TSize& aThumbnailSize ) + { + iSize = aThumbnailSize; + iThumbnailSize = ECustomThumbnailSize; + } + +// --------------------------------------------------------------------------- +// CThumbnailManagerImpl::SetThumbnailSizeL() +// Set desired size for thumbnail bitmaps. +// --------------------------------------------------------------------------- +// +void CThumbnailManagerImpl::SetThumbnailSizeL( const TThumbnailSize aThumbnailSize ) + { + iThumbnailSize = aThumbnailSize; + } + +// --------------------------------------------------------------------------- +// CThumbnailManagerImpl::Flags() +// Get current flags for thumbnail generation. +// --------------------------------------------------------------------------- +// +CThumbnailManager::TThumbnailFlags CThumbnailManagerImpl::Flags()const + { + return iFlags; + } + + +// --------------------------------------------------------------------------- +// CThumbnailManagerImpl::SetFlagsL() +// Set flags for thumbnail generation. Several flags may be enabled +// by combining the values using bitwise or. +// --------------------------------------------------------------------------- +// +void CThumbnailManagerImpl::SetFlagsL( const TThumbnailFlags aFlags ) + { + iFlags = aFlags; + } + + +// --------------------------------------------------------------------------- +// CThumbnailManagerImpl::DeleteThumbnails() +// Delete all thumbnails for a given object. +// --------------------------------------------------------------------------- +// +void CThumbnailManagerImpl::DeleteThumbnails( CThumbnailObjectSource& + aObjectSource ) + { + TRAP_IGNORE( + iRequestId++; + TN_DEBUG2( "CThumbnailManagerImpl::DeleteThumbnails() URI==%S ", &aObjectSource.Uri() ); + + __ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId )); + + CThumbnailRequestActive* getThumbnailActive = CThumbnailRequestActive::NewL + ( iFs, iSession, iObserver, iRequestId, CActive::EPriorityIdle, iRequestQueue ); + + CleanupStack::PushL( getThumbnailActive ); + + const TDesC& uri = aObjectSource.Uri(); + + if ( uri.Length()) + { + getThumbnailActive->DeleteThumbnails( uri, 0, CActive::EPriorityIdle ); + } + else + { + TInt err = aObjectSource.FileHandle().FullName( iFileNameBuf ); + if ( !err ) + { + getThumbnailActive->DeleteThumbnails( iFileNameBuf, 0, CActive::EPriorityIdle ); + } + } + + iRequestQueue->AddRequestL( getThumbnailActive ); + + CleanupStack::Pop( getThumbnailActive ); + + iRequestQueue->Process(); + ); + } + + +// --------------------------------------------------------------------------- +// CThumbnailManagerImpl::DeleteThumbnailsL() +// Delete thumbnails by TThumbnailId. +// --------------------------------------------------------------------------- +// +void CThumbnailManagerImpl::DeleteThumbnails( const TThumbnailId aItemId ) + { + TRAP_IGNORE( + iRequestId++; + TN_DEBUG2( "CThumbnailManagerImpl::DeleteThumbnails() aItemId==%d ", aItemId ); + + __ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId )); + + CThumbnailRequestActive* getThumbnailActive = CThumbnailRequestActive::NewL + ( iFs, iSession, iObserver, iRequestId, CActive::EPriorityIdle, iRequestQueue ); + + CleanupStack::PushL( getThumbnailActive ); + + getThumbnailActive->DeleteThumbnails( KNullDesC, aItemId, CActive::EPriorityIdle ); + + iRequestQueue->AddRequestL( getThumbnailActive ); + + CleanupStack::Pop( getThumbnailActive ); + + iRequestQueue->Process(); + ); + } + + +// --------------------------------------------------------------------------- +// CThumbnailManagerImpl::CancelRequest() +// Cancel a thumbnail operation. +// --------------------------------------------------------------------------- +// +TInt CThumbnailManagerImpl::CancelRequest( const TThumbnailRequestId aId ) + { + __ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId )); + + TN_DEBUG2( "CThumbnailManagerImpl::CancelRequest() - request ID: %d", aId ); + + return iRequestQueue->CancelRequest(aId); + } + + +// --------------------------------------------------------------------------- +// CThumbnailManagerImpl::ChangePriority() +// Change the priority of a queued thumbnail operation. +// --------------------------------------------------------------------------- +// +TInt CThumbnailManagerImpl::ChangePriority( const TThumbnailRequestId aId, + const TInt aNewPriority ) + { + __ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId )); + + TN_DEBUG2( "CThumbnailManagerImpl::ChangePriority() - request ID: %d", aId ); + + return iRequestQueue->ChangePriority(aId, aNewPriority); + } + +// --------------------------------------------------------------------------- +// Get the list of supported file systems from server +// --------------------------------------------------------------------------- +// +const CDesCArray& CThumbnailManagerImpl::GetSupportedMimeTypesL() + { + if ( !iMimeTypeList ) + { + iMimeTypeList = new( ELeave )CDesCArraySeg( + KThumbnailMimeTypeListGranularity ); + HBufC* buf = iSession.GetMimeTypeListL(); + CleanupStack::PushL( buf ); + TLex lex( *buf ); + while ( !lex.Eos()) + { + iMimeTypeList->AppendL( lex.NextToken()); + } + CleanupStack::PopAndDestroy( buf ); + } + return * iMimeTypeList; + } + + +// --------------------------------------------------------------------------- +// CThumbnailManagerImpl::UpdateThumbnails() +// Update thumbnails by given ID +// --------------------------------------------------------------------------- +// +void CThumbnailManagerImpl::UpdateThumbnailsL( const TThumbnailId aItemId, const TDesC& aPath, + const TInt aOrientation, const TInt64 aModified, + TInt aPriority ) + { + iRequestId++; + TN_DEBUG4( "CThumbnailManagerImpl::UpdateThumbnailsL() URI==%S, aItemId==%d %d", &aPath, aItemId, iRequestId); + + __ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId )); + + CThumbnailRequestActive* getThumbnailActive = CThumbnailRequestActive::NewL + ( iFs, iSession, iObserver, iRequestId, aPriority, iRequestQueue ); + CleanupStack::PushL( getThumbnailActive ); + + getThumbnailActive->UpdateThumbnailsL( aPath, aItemId, iFlags, iQualityPreference, + iDisplayMode, aPriority, aOrientation, aModified ); + + iRequestQueue->AddRequestL( getThumbnailActive ); + CleanupStack::Pop( getThumbnailActive ); + + iRequestQueue->Process(); + } + +// End of file diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailobjectsource.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailobjectsource.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,316 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class for encapsulating the data source for objects. + * +*/ + +#include + +#include "thumbnailobjectsource.h" + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CThumbnailObjectSource::NewL() +// Two-phased constructor. +// --------------------------------------------------------------------------- +// +EXPORT_C CThumbnailObjectSource* CThumbnailObjectSource::NewL( const TDesC& + aUri, const TDesC& aMimeType ) + { + CThumbnailObjectSource* self = CThumbnailObjectSource::NewLC( aUri, + aMimeType ); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// CThumbnailObjectSource::NewLC() +// Two-phased constructor. +// --------------------------------------------------------------------------- +// +EXPORT_C CThumbnailObjectSource* CThumbnailObjectSource::NewLC( const TDesC& + aUri, const TDesC& aMimeType ) + { + CThumbnailObjectSource* self = new( ELeave )CThumbnailObjectSource(); + CleanupStack::PushL( self ); + self->ConstructL( aUri, aMimeType ); + return self; + } + +// --------------------------------------------------------------------------- +// CThumbnailObjectSource::NewL() +// Two-phased constructor. +// --------------------------------------------------------------------------- +// +EXPORT_C CThumbnailObjectSource* CThumbnailObjectSource::NewL( const RFile64& + aFile, const TDesC& aMimeType ) + { + CThumbnailObjectSource* self = CThumbnailObjectSource::NewLC( aFile, + aMimeType ); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// CThumbnailObjectSource::NewLC() +// Two-phased constructor. +// --------------------------------------------------------------------------- +// +EXPORT_C CThumbnailObjectSource* CThumbnailObjectSource::NewLC( const RFile64& + aFile, const TDesC& aMimeType ) + { + CThumbnailObjectSource* self = new( ELeave )CThumbnailObjectSource(); + CleanupStack::PushL( self ); + self->ConstructL( aFile, aMimeType ); + return self; + } + + +EXPORT_C CThumbnailObjectSource* CThumbnailObjectSource::NewL( CFbsBitmap* aBitmap, const TDesC& aUri ) + { + CThumbnailObjectSource* self = CThumbnailObjectSource::NewLC( aBitmap, aUri ); + CleanupStack::Pop( self ); + return self; + } + +EXPORT_C CThumbnailObjectSource* CThumbnailObjectSource::NewLC( CFbsBitmap* aBitmap, const TDesC& aUri ) + { + CThumbnailObjectSource* self = new( ELeave )CThumbnailObjectSource(); + CleanupStack::PushL( self ); + self->ConstructL( aBitmap, aUri ); + return self; + } + +EXPORT_C CThumbnailObjectSource* CThumbnailObjectSource::NewL( TDesC8* aBuffer, TDesC& aMimeType, const TDesC& aUri) + { + CThumbnailObjectSource* self = CThumbnailObjectSource::NewLC( aBuffer, aMimeType, aUri ); + CleanupStack::Pop( self ); + return self; + } + +EXPORT_C CThumbnailObjectSource* CThumbnailObjectSource::NewLC( TDesC8* aBuffer, TDesC& aMimeType, const TDesC& aUri) + { + CThumbnailObjectSource* self = new( ELeave )CThumbnailObjectSource(); + CleanupStack::PushL( self ); + self->ConstructL( aBuffer, aMimeType, aUri ); + return self; + } + + +// --------------------------------------------------------------------------- +// CThumbnailObjectSource::CThumbnailObjectSource() +// C++ default constructor can NOT contain any code, that might leave. +// --------------------------------------------------------------------------- +// +CThumbnailObjectSource::CThumbnailObjectSource() + { + // No implementation required + } + + +// --------------------------------------------------------------------------- +// CThumbnailObjectSource::ConstructL() +// Symbian 2nd phase constructor can leave. +// --------------------------------------------------------------------------- +// +void CThumbnailObjectSource::ConstructL( const TDesC& aUri, const TDesC& + aMimeType) + { + iUri = aUri.AllocL(); + iMimeType = HBufC8::NewL( aMimeType.Length() ); + iMimeType->Des().Copy( aMimeType ); + } + + +// --------------------------------------------------------------------------- +// CThumbnailObjectSource::ConstructL() +// Symbian 2nd phase constructor can leave. +// --------------------------------------------------------------------------- +// +void CThumbnailObjectSource::ConstructL( const RFile64& aFile, const TDesC& + aMimeType ) + { + iFile = aFile; + iMimeType = HBufC8::NewL( aMimeType.Length() ); + iMimeType->Des().Copy( aMimeType ); + iThumbnailId = 0; + } + +// --------------------------------------------------------------------------- +// CThumbnailObjectSource::ConstructL() +// Symbian 2nd phase constructor can leave. +// --------------------------------------------------------------------------- +// +void CThumbnailObjectSource::ConstructL( CFbsBitmap* aBitmap, const TDesC& + aUri ) + { + iBitmap = aBitmap; + iUri = aUri.AllocL(); + iThumbnailId = 0; + } + +// --------------------------------------------------------------------------- +// CThumbnailObjectSource::ConstructL() +// Symbian 2nd phase constructor can leave. +// --------------------------------------------------------------------------- +// +void CThumbnailObjectSource::ConstructL( TDesC8* aBuffer, const TDesC& + aMimeType, const TDesC& aUri ) + { + iBuffer = aBuffer; + iMimeType = HBufC8::NewL( aMimeType.Length() ); + iMimeType->Des().Copy( aMimeType ); + iUri = aUri.AllocL(); + iThumbnailId = 0; + } + +// --------------------------------------------------------------------------- +// CThumbnailObjectSource::ConstructL() +// Symbian 2nd phase constructor can leave. +// --------------------------------------------------------------------------- +// +void CThumbnailObjectSource::ConstructL( const TDesC& aUri, const TDesC& + aMimeType, TThumbnailId aThumbnailId ) + { + iUri = aUri.AllocL(); + iMimeType = HBufC8::NewL( aMimeType.Length() ); + iMimeType->Des().Copy( aMimeType ); + iThumbnailId = aThumbnailId; + } + + +// --------------------------------------------------------------------------- +// CThumbnailObjectSource::~CThumbnailObjectSource()() +// Destructor. +// --------------------------------------------------------------------------- +// +CThumbnailObjectSource::~CThumbnailObjectSource() + { + delete iUri; + delete iMimeType; + delete iBuffer; + delete iBitmap; + } + + +// --------------------------------------------------------------------------- +// CThumbnailObjectSourceImpl::FileHandle() +// --------------------------------------------------------------------------- +// +EXPORT_C RFile64& CThumbnailObjectSource::FileHandle() + { + return iFile; + } + + +// --------------------------------------------------------------------------- +// CThumbnailObjectSourceImpl::Uri() +// --------------------------------------------------------------------------- +// +EXPORT_C const TDesC& CThumbnailObjectSource::Uri() + { + if ( iUri ) + { + return * iUri; + } + return KNullDesC; + } + +// --------------------------------------------------------------------------- +// CThumbnailObjectSourceImpl::Buffer() +// --------------------------------------------------------------------------- +// +EXPORT_C TDesC8* CThumbnailObjectSource::Buffer() + { + return iBuffer; + } + +// --------------------------------------------------------------------------- +// CThumbnailObjectSourceImpl::GetBufferOwnership() +// --------------------------------------------------------------------------- +// +EXPORT_C TDesC8* CThumbnailObjectSource::GetBufferOwnership() + { + TDesC8* temp = iBuffer; + iBuffer = NULL; + return temp; + } + +// --------------------------------------------------------------------------- +// CThumbnailObjectSourceImpl::aMimeType() +// --------------------------------------------------------------------------- +// +EXPORT_C const TDesC8& CThumbnailObjectSource::MimeType() + { + if ( iMimeType ) + { + return *iMimeType; + } + return KNullDesC8; + } + +EXPORT_C TThumbnailId CThumbnailObjectSource::Id() + { + return iThumbnailId; + } + +EXPORT_C CThumbnailObjectSource* CThumbnailObjectSource::NewL( const TDesC& +aUri, const TThumbnailId aThumbnailId, const TDesC& aMimeType ) +{ +CThumbnailObjectSource* self = CThumbnailObjectSource::NewLC( aUri, + aThumbnailId, aMimeType ); +CleanupStack::Pop( self ); +return self; + } + + +// --------------------------------------------------------------------------- +// CThumbnailObjectSource::NewLC() +// Two-phased constructor. +// --------------------------------------------------------------------------- +// +EXPORT_C CThumbnailObjectSource* CThumbnailObjectSource::NewLC( const TDesC& aUri, + const TThumbnailId aThumbnailId, const TDesC& aMimeType ) + { + CThumbnailObjectSource* self = new( ELeave )CThumbnailObjectSource(); + CleanupStack::PushL( self ); + self->ConstructL( aUri, aMimeType, aThumbnailId ); + return self; + } + +// --------------------------------------------------------------------------- +// CThumbnailObjectSourceImpl::Bitmap() +// --------------------------------------------------------------------------- +// +EXPORT_C CFbsBitmap* CThumbnailObjectSource::Bitmap() + { + return iBitmap; + } + +// --------------------------------------------------------------------------- +// CThumbnailObjectSourceImpl::GetBitmapOwnership() +// --------------------------------------------------------------------------- +// +EXPORT_C CFbsBitmap* CThumbnailObjectSource::GetBitmapOwnership() + { + CFbsBitmap* temp = iBitmap; + iBitmap = NULL; + return temp; + } + +// End of file diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailrequestactive.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailrequestactive.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,729 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Active object for an asynchronous thumbnail request + * +*/ + + +#include +#include +#include +#include + +#include "thumbnailrequestactive.h" +#include "thumbnailrequestqueue.h" +#include "thumbnailsession.h" +#include "thumbnailmanagerobserver.h" +#include "thumbnailmanagerconstants.h" +#include "thumbnaildataimpl.h" +#include "thumbnailpanic.h" +#include "thumbnaillog.h" + +#include "thumbnailmanagerimpl.h" + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CThumbnailRequestActive::~CThumbnailRequestActive() +// Destructor. +// --------------------------------------------------------------------------- +// +CThumbnailRequestActive::~CThumbnailRequestActive() + { + Cancel(); + + if(iTimer) + { + iTimer->Cancel(); + } + delete iTimer; + + ReleaseServerBitmap(); + delete iCallbackThumbnail; + delete iParams.iBuffer; + delete iBitmap; + iFile.Close(); + iMyFileHandle.Close(); + } + + +// --------------------------------------------------------------------------- +// CThumbnailRequestActive::NewL +// Two-phased constructor. +// --------------------------------------------------------------------------- +// +CThumbnailRequestActive* CThumbnailRequestActive::NewL( RFs& aFs, + RThumbnailSession& aThumbnailSession, MThumbnailManagerObserver& aObserver, + TThumbnailRequestId aId, TInt aPriority, CThumbnailRequestQueue* aQueue ) + { + CThumbnailRequestActive* self = new( ELeave )CThumbnailRequestActive( aFs, + aThumbnailSession, aObserver, aId, aPriority, aQueue ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// CThumbnailRequestActive::CThumbnailRequestActive() +// C++ default constructor can NOT contain any code, that might leave. +// --------------------------------------------------------------------------- +// +CThumbnailRequestActive::CThumbnailRequestActive( RFs& aFs, RThumbnailSession& + aThumbnailSession, MThumbnailManagerObserver& aObserver, + TThumbnailRequestId aId, TInt aPriority, CThumbnailRequestQueue* aQueue ): + CActive( aPriority ), iSession( aThumbnailSession ), iParamsPckg( iParams ), + iObserver( aObserver ), iFs( aFs ), iBitmapHandle( 0 ), iRequestId( aId ), + iRequestQueue( aQueue ) + { + CActiveScheduler::Add( this ); + TN_DEBUG2( "CThumbnaiRequestActive::CThumbnailRequestActive() AO's priority = %d", Priority()); + + iBitmap = NULL; + iRequestCompleted = EFalse; + } + + +// --------------------------------------------------------------------------- +// CThumbnailRequestActive::ConstructL() +// Symbian 2nd phase constructor can leave. +// --------------------------------------------------------------------------- +// +void CThumbnailRequestActive::ConstructL() + { + iCallbackThumbnail = new( ELeave )CThumbnailDataImpl(); + + iTimer = CPeriodic::NewL(CActive::EPriorityIdle); + +#ifdef _DEBUG + iStartExecTime.UniversalTime(); +#endif + } + + +// --------------------------------------------------------------------------- +// CThumbnailRequestActive::StartL() +// Start active request. +// --------------------------------------------------------------------------- +// +void CThumbnailRequestActive::StartL() + { + TN_DEBUG3( "CThumbnailRequestActive::StartL(0x%08x) reqid = %d", this, iRequestId ); + + iRequestActive = ETrue; + +#ifdef _DEBUG + TTime stop; + stop.UniversalTime(); + TN_DEBUG3( "CThumbnailRequestActive::StartL() req id = %d, queuing time %d ms", + iParams.iRequestId, (TInt)stop.MicroSecondsFrom(iStartExecTime).Int64()/1000 ); +#endif + + switch (iRequestType) + { + case EReqGetThumbnailHandle: + { + iSession.RequestThumbnailL( iFile, iTargetUri, iParamsPckg, iStatus ); + break; + } + case EReqGetThumbnailPath: + { + iSession.RequestThumbnailL( iPath, iTargetUri, iParams.iThumbnailId, + iParamsPckg, iStatus ); + break; + } + case EReqSetThumbnailBuffer: + { + iSession.RequestSetThumbnailL( iParams.iBuffer, iTargetUri, iParamsPckg, iStatus ); + break; + } + case EReqSetThumbnailBitmap: + { + iSession.RequestSetThumbnailL( iBitmap->Handle(), iTargetUri, iParamsPckg, iStatus ); + break; + } + case EReqUpdateThumbnails: + { + iSession.UpdateThumbnails( iPath, iOrientation, iModified, iParamsPckg, iStatus ); + break; + } + case EReqGetThumbnailHandleLater: + { + // open file handle + User::LeaveIfError( iFile.Open( iFs, iTargetUri, EFileShareReadersOrWriters ) ); + + TN_DEBUG2( "CThumbnailRequestActive::StartL() - file handle opened for %S", &iTargetUri ); + + CleanupClosePushL( iFile ); + iSession.RequestThumbnailL( iFile, iTargetUri, iParamsPckg, iStatus ); + CleanupStack::PopAndDestroy( &iFile ); + break; + } + case EReqDeleteThumbnails: + { + // by path + if (iPath != KNullDesC) + { + iSession.DeleteThumbnails( iPath, iParamsPckg, iStatus ); + } + // by id + else + { + iSession.DeleteThumbnails( iParams.iThumbnailId, iParamsPckg, iStatus ); + } + break; + } + default: + { + break; + } + } + + iTimer->Start( KClientRequestTimeout, KClientRequestTimeout, + TCallBack(TimerCallBack, this)); + SetActive(); + } + + +// --------------------------------------------------------------------------- +// CThumbnailRequestActive::RunL() +// --------------------------------------------------------------------------- +// +void CThumbnailRequestActive::RunL() + { + TN_DEBUG1( "CThumbnaiRequestActive::RunL()" ); + + if ( iParams.iControlFlags == EThumbnailPreviewThumbnail ) + { + iRequestCompleted = EFalse; + iProcessingPreview = ETrue; + } + else + { + iRequestCompleted = ETrue; + } + + iTimer->Cancel(); + + if (iRequestType == EReqDeleteThumbnails) + { + // no action for delete + iRequestQueue->RequestComplete(this); + +#ifdef _DEBUG + TTime stop; + stop.UniversalTime(); + TN_DEBUG3( "CThumbnailRequestActive::RunL() total execution time of req %d is %d ms", + iParams.iRequestId, (TInt)stop.MicroSecondsFrom(iStartExecTime).Int64()/1000 ); +#endif + } + else if ( iStatus.Int() == KThumbnailErrThumbnailNotFound && iParams.iFileName.Length() && + !( iParams.iFlags& CThumbnailManager::EDoNotCreate )) + { + TN_DEBUG1( "CThumbnaiRequestActive::RunL() - no thumbnail found - lets try with file handle" ); + iRequestCompleted = EFalse; + + // We tried to get thumbnail using file path, but it was not found in + // the database. We need to open the file now (on the client side) and + // use file handle. + User::LeaveIfError( iFile.Open( iFs, iParams.iFileName, EFileShareReadersOrWriters )); + CleanupClosePushL( iFile ); + + TN_DEBUG2( "CThumbnaiRequestActive::RunL() - file handle opened for %S", &iParams.iFileName ); + + iSession.RequestThumbnailL( iFile, iParams.iTargetUri, iParamsPckg, iStatus ); + CleanupStack::PopAndDestroy( &iFile ); + + iTimer->Start( KClientRequestTimeout, KClientRequestTimeout, + TCallBack(TimerCallBack, this)); + SetActive(); + } + else if ( iStatus.Int()) + { + TN_DEBUG2( "CThumbnaiRequestActive::RunL() - error (%d) occured", iStatus.Int() ); + // An error occurred + iError = iStatus.Int(); + HandleError(); + } + else if (iParams.iControlFlags == EThumbnailGeneratePersistentSizesOnly) + { + TN_DEBUG1( "CThumbnaiRequestActive::RunL()- generate persistent sizes" ); + iBitmapHandle = iParams.iBitmapHandle; + + TN_DEBUG2( "CThumbnaiRequestActive::RunL() - iObserver.ThumbnailReady %d", iParams.iRequestId ); + iObserver.ThumbnailReady( iStatus.Int(), *iCallbackThumbnail, iParams.iRequestId ); + + ReleaseServerBitmap(); + iRequestQueue->RequestComplete(this); + +#ifdef _DEBUG + TTime stop; + stop.UniversalTime(); + TN_DEBUG3( "CThumbnailRequestActive::RunL() total execution time %d, %d ms", + iParams.iRequestId, (TInt)stop.MicroSecondsFrom(iStartExecTime).Int64()/1000 ); +#endif + } + else + { + TN_DEBUG1( "CThumbnaiRequestActive::RunL() - succesful" ); + + // Success + iBitmapHandle = iParams.iBitmapHandle; + CFbsBitmap* bitmap = new( ELeave )CFbsBitmap(); + CleanupStack::PushL( bitmap ); + User::LeaveIfError( bitmap->Duplicate( iBitmapHandle )); + CleanupStack::Pop( bitmap ); + + // reduce bpp value (displaymode to match reqested bits per pixel) + #ifdef _DEBUG + TN_DEBUG2( "CThumbnaiRequestActive::RunL() - displaymode is %d", bitmap->DisplayMode()); + #endif + + if( bitmap->DisplayMode() > iParams.iDisplayMode ) + { + bitmap->SetDisplayMode( iParams.iDisplayMode ); + #ifdef _DEBUG + TN_DEBUG2( "CThumbnaiRequestActive::RunL() - displaymode is now %d", bitmap->DisplayMode()); + #endif + } + + iCallbackThumbnail->Set( bitmap, iClientData ); + bitmap = NULL; // Owned by iCallbackThumbnail or client now + + if ( iProcessingPreview ) + { + TN_DEBUG2( "CThumbnaiRequestActive::RunL() - iObserver.ThumbnailPreviewReady %d", iParams.iRequestId ); + iObserver.ThumbnailPreviewReady( *iCallbackThumbnail, iParams.iRequestId ); + iProcessingPreview = EFalse; + ReleaseServerBitmap(); + Get2ndPhaseThumbnailL(); + } + else + { + TN_DEBUG2( "CThumbnaiRequestActive::RunL() - iObserver.ThumbnailReady %d", iParams.iRequestId ); + + iObserver.ThumbnailReady( iStatus.Int(), * iCallbackThumbnail, iParams.iRequestId ); + ReleaseServerBitmap(); + + iRequestQueue->RequestComplete(this); + +#ifdef _DEBUG + TTime stop; + stop.UniversalTime(); + TN_DEBUG4( "CThumbnailRequestActive::RunL(0x%08x) total execution time of req %d is %d ms", + this, iParams.iRequestId, (TInt)stop.MicroSecondsFrom(iStartExecTime).Int64()/1000 ); +#endif + } + } + + delete iBitmap; + iBitmap = NULL; + + //if request is complete set it also not active -> really finished + if(iRequestCompleted) + { + iRequestActive = EFalse; + } + } + + +// --------------------------------------------------------------------------- +// CThumbnailRequestActive::RunError() +// --------------------------------------------------------------------------- +// +TInt CThumbnailRequestActive::RunError( TInt aError ) + { + TN_DEBUG1( "CThumbnailRequestActive::RunError"); + + iTimer->Cancel(); + + // If RunL() left, the client did not get any callbacks yet. + // We need to notify it of the error now. + iError = aError; + HandleError(); + + return KErrNone; + } + + +// --------------------------------------------------------------------------- +// CThumbnailRequestActive::DoCancel() +// --------------------------------------------------------------------------- +// +void CThumbnailRequestActive::DoCancel() + { + TN_DEBUG1( "CThumbnailRequestActive::DoCancel"); + iTimer->Cancel(); + + __ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId )); + + iSession.CancelRequest( iRequestId ); + ReleaseServerBitmap(); + } + + +// --------------------------------------------------------------------------- +// CThumbnailRequestActive::ReleaseServerBitmap() +// Releases reserved bitmap. +// --------------------------------------------------------------------------- +// +void CThumbnailRequestActive::ReleaseServerBitmap() + { + TN_DEBUG1( "CThumbnailRequestActive::ReleaseServerBitmap"); + + if ( iBitmapHandle && iSession.Handle()) + { + iSession.ReleaseBitmap( iBitmapHandle ); + iBitmapHandle = 0; + } + } + + +// --------------------------------------------------------------------------- +// CThumbnailRequestActive::HandleError() +// Error handling function. +// --------------------------------------------------------------------------- +// +void CThumbnailRequestActive::HandleError() + { + TN_DEBUG1( "CThumbnailRequestActive::HandleError"); + + if ( iError ) + { + if( iError == KErrServerTerminated) + { + iSession.Close(); + iSession.Connect(); + } + iCallbackThumbnail->Set( NULL, iClientData ); + + // don't leak internal TNM codes + if (iError == KThumbnailErrThumbnailNotFound) + { + iError = KErrNotFound; + } + + TN_DEBUG2( "CThumbnaiRequestActive::RunL() - iObserver.ThumbnailReady %d", iParams.iRequestId ); + iObserver.ThumbnailReady( iError, *iCallbackThumbnail, iParams.iRequestId ); + + iError = KErrNone; + } + + ReleaseServerBitmap(); + + iRequestCompleted = ETrue; + iRequestQueue->RequestComplete(this); + iRequestActive = EFalse; + } + + +// --------------------------------------------------------------------------- +// CThumbnailRequestActive::GetThumbnailL() +// Get a thumbnail for an object file. +// --------------------------------------------------------------------------- +// +void CThumbnailRequestActive::GetThumbnailL( const RFile64& aFile, TThumbnailId aThumbnailId, + CThumbnailManager::TThumbnailFlags aFlags, CThumbnailManager + ::TThumbnailQualityPreference aQualityPreference, const TSize& aSize, const + TDisplayMode aDisplayMode, const TInt aPriority, TAny* aClientData, TBool aGeneratePersistentSizesOnly, + const TDesC& aTargetUri, TThumbnailSize aThumbnailSize) + { + iRequestType = EReqGetThumbnailHandle; + + if ( aQualityPreference == CThumbnailManager + ::EOptimizeForQualityWithPreview ) + { + // We may need the file handle later for the 2nd phase + // thumbnail + iMyFileHandle.Close(); + User::LeaveIfError( iMyFileHandle.Duplicate( aFile )); + } + + iClientData = aClientData; + iParams.iControlFlags = (aGeneratePersistentSizesOnly ? + EThumbnailGeneratePersistentSizesOnly : + EThumbnailNoControlFlags); + iParams.iBitmapHandle = 0; + iParams.iSize = aSize; + iParams.iDisplayMode = aDisplayMode; + User::LeaveIfError( aFile.FullName( iParams.iFileName )); + iParams.iRequestId = iRequestId; + iParams.iPriority = aPriority; + iParams.iFlags = aFlags; + iParams.iQualityPreference = aQualityPreference; + iParams.iThumbnailSize = aThumbnailSize; + iParams.iThumbnailId = aThumbnailId; + + User::LeaveIfError( iFile.Duplicate( aFile )); + + iTargetUri = aTargetUri; + } + + +// --------------------------------------------------------------------------- +// CThumbnailRequestActive::GetThumbnailL() +// Get a thumbnail opening an object file later. +// --------------------------------------------------------------------------- +// +void CThumbnailRequestActive::GetThumbnailL( TThumbnailId aThumbnailId, + const TDesC& aPath, CThumbnailManager::TThumbnailFlags aFlags, CThumbnailManager + ::TThumbnailQualityPreference aQualityPreference, const TSize& aSize, const + TDisplayMode aDisplayMode, const TInt aPriority, TAny* aClientData, TBool aGeneratePersistentSizesOnly, + const TDesC& aTargetUri, TThumbnailSize aThumbnailSize) + { + iRequestType = EReqGetThumbnailHandleLater; + + iClientData = aClientData; + iParams.iControlFlags = (aGeneratePersistentSizesOnly ? + EThumbnailGeneratePersistentSizesOnly : + EThumbnailNoControlFlags); + iParams.iBitmapHandle = 0; + iParams.iSize = aSize; + iParams.iDisplayMode = aDisplayMode; + iParams.iFileName = aPath; + iParams.iRequestId = iRequestId; + iParams.iPriority = aPriority; + iParams.iFlags = aFlags; + iParams.iQualityPreference = aQualityPreference; + iParams.iThumbnailSize = aThumbnailSize; + iParams.iThumbnailId = aThumbnailId; + + iTargetUri = aTargetUri; + } + + +// --------------------------------------------------------------------------- +// CThumbnailRequestActive::GetThumbnailL() +// Get a thumbnail for an object file. +// --------------------------------------------------------------------------- +// +void CThumbnailRequestActive::GetThumbnailL( const TDesC& aPath, TThumbnailId aThumbnailId, + CThumbnailManager::TThumbnailFlags aFlags, CThumbnailManager + ::TThumbnailQualityPreference aQualityPreference, const TSize& aSize, const + TDisplayMode aDisplayMode, const TInt aPriority, TAny* aClientData, TBool aGeneratePersistentSizesOnly, + const TDesC& aTargetUri, TThumbnailSize aThumbnailSize) + { + iRequestType = EReqGetThumbnailPath; + + iClientData = aClientData; + iParams.iControlFlags = (aGeneratePersistentSizesOnly ? + EThumbnailGeneratePersistentSizesOnly : + EThumbnailNoControlFlags); + + iParams.iBitmapHandle = 0; + iParams.iSize = aSize; + iParams.iDisplayMode = aDisplayMode; + iParams.iRequestId = iRequestId; + iParams.iPriority = aPriority; + iParams.iFlags = aFlags; + iParams.iQualityPreference = aQualityPreference; + iParams.iThumbnailSize = aThumbnailSize; + iParams.iThumbnailId = aThumbnailId; + + iPath = aPath; + iTargetUri = aTargetUri; + } + +// --------------------------------------------------------------------------- +// CThumbnailRequestActive::SetThumbnailL() +// Get a thumbnail for an object file. +// --------------------------------------------------------------------------- +// +void CThumbnailRequestActive::SetThumbnailL( TDesC8* aBuffer, TThumbnailId aThumbnailId, + const TDesC8& aMimeType, CThumbnailManager::TThumbnailFlags aFlags, + CThumbnailManager::TThumbnailQualityPreference aQualityPreference, const TSize& aSize, + const TDisplayMode aDisplayMode, const TInt aPriority, TAny* aClientData, + TBool aGeneratePersistentSizesOnly, const TDesC& aTargetUri, TThumbnailSize aThumbnailSize ) + { + iRequestType = EReqSetThumbnailBuffer; + + iClientData = aClientData; + iParams.iControlFlags = (aGeneratePersistentSizesOnly ? + EThumbnailGeneratePersistentSizesOnly : + EThumbnailNoControlFlags); + + iParams.iMimeType = TDataType( aMimeType ); + iParams.iBitmapHandle = 0; + iParams.iSize = aSize; + iParams.iBuffer = aBuffer; // save pointer for deletion (~CThumbnailRequestActive()) + iParams.iThumbnailSize = aThumbnailSize; + iParams.iDisplayMode = aDisplayMode; + iParams.iRequestId = iRequestId; + iParams.iPriority = aPriority; + iParams.iFlags = aFlags; + iParams.iQualityPreference = aQualityPreference; + iParams.iThumbnailId = aThumbnailId; + + iTargetUri = aTargetUri; + } + +// --------------------------------------------------------------------------- +// CThumbnailRequestActive::SetThumbnailL() +// Get a thumbnail for an object file. +// --------------------------------------------------------------------------- +// +void CThumbnailRequestActive::SetThumbnailL( CFbsBitmap* aBitmap, TThumbnailId aThumbnailId, + const TDesC8& aMimeType, CThumbnailManager::TThumbnailFlags aFlags, + CThumbnailManager::TThumbnailQualityPreference aQualityPreference, const TSize& aSize, + const TDisplayMode aDisplayMode, const TInt aPriority, TAny* aClientData, + TBool aGeneratePersistentSizesOnly, const TDesC& aTargetUri, TThumbnailSize aThumbnailSize ) + { + iClientData = aClientData; + iParams.iControlFlags = (aGeneratePersistentSizesOnly ? + EThumbnailGeneratePersistentSizesOnly : + EThumbnailNoControlFlags); + + iParams.iBitmapHandle = 0; + iParams.iSize = aSize; + iParams.iThumbnailSize = aThumbnailSize; + iParams.iDisplayMode = aDisplayMode; + iParams.iRequestId = iRequestId; + iParams.iPriority = aPriority; + iParams.iFlags = aFlags; + iParams.iQualityPreference = aQualityPreference; + iParams.iThumbnailId = aThumbnailId; + iParams.iFileName = aTargetUri; + + iTargetUri = aTargetUri; + + TInt memoryFree( 0 ); + HAL::Get( HALData::EMemoryRAMFree, memoryFree ); + + TN_DEBUG2( "CThumbnaiRequestActive::SetThumbnailbyBitmap() - memoryFree %d", memoryFree ); + + if(memoryFree > KMemoryNeed) + { + // save parameter bitmap, it will be deleted when request is complete + iBitmap = aBitmap; + iParams.iMimeType = TDataType( aMimeType ); + iRequestType = EReqSetThumbnailBitmap; + } + else + { + // memory low, create thumbs using filehandle + TN_DEBUG1( "CThumbnaiRequestActive::SetThumbnailbyBitmap() - memory low, create thumbs using filehandle!" ); + delete aBitmap; + aBitmap = NULL; + iParams.iPriority = aPriority - 1; + iRequestType = EReqGetThumbnailHandleLater; + } + } + +// --------------------------------------------------------------------------- +// CThumbnailRequestActive::UpdateThumbnailsL() +// Update thumbnails by Id. +// --------------------------------------------------------------------------- +// +void CThumbnailRequestActive::UpdateThumbnailsL( const TDesC& aPath, + const TThumbnailId aThumbnailId, CThumbnailManager::TThumbnailFlags aFlags, + CThumbnailManager::TThumbnailQualityPreference aQualityPreference, + const TDisplayMode aDisplayMode, const TInt aPriority, const TInt aOrientation, + const TInt64 aModified ) + { + iRequestType = EReqUpdateThumbnails; + + iParams.iControlFlags = EThumbnailGeneratePersistentSizesOnly; + iParams.iBitmapHandle = 0; + iParams.iDisplayMode = aDisplayMode; + iParams.iRequestId = iRequestId; + iParams.iPriority = aPriority; + iParams.iFlags = aFlags; + iParams.iQualityPreference = aQualityPreference; + iParams.iThumbnailId = aThumbnailId; + + iPath = aPath; + iOrientation = aOrientation; + iModified = aModified; + } + +// --------------------------------------------------------------------------- +// CThumbnailRequestActive::DeleteThumbnails() +// Delete thumbnails. +// --------------------------------------------------------------------------- +// +void CThumbnailRequestActive::DeleteThumbnails( const TDesC& aPath, + const TThumbnailId aThumbnailId, const TInt aPriority ) + { + iRequestType = EReqDeleteThumbnails; + + iParams.iRequestId = iRequestId; + iParams.iPriority = aPriority; + iParams.iThumbnailId = aThumbnailId; + + iPath = aPath; + } + +// --------------------------------------------------------------------------- +// Request 2nd phase thumbnail +// --------------------------------------------------------------------------- +// +void CThumbnailRequestActive::Get2ndPhaseThumbnailL() + { + TN_DEBUG2( "CThumbnailRequestActive::Get2ndPhaseThumbnailL() %d", iParams.iRequestId ); + + iParams.iQualityPreference = CThumbnailManager::EOptimizeForQuality; + iParams.iControlFlags = EThumbnailNoControlFlags; + + if ( iMyFileHandle.SubSessionHandle()) + { + User::LeaveIfError( iMyFileHandle.FullName( iParams.iFileName )); + iSession.RequestThumbnailL( iMyFileHandle, iParams.iTargetUri, iParamsPckg, iStatus ); + SetActive(); + } + else + { + iSession.RequestThumbnailL( iParams.iFileName, iParams.iTargetUri, iParams.iThumbnailId, iParamsPckg, iStatus ); + SetActive(); + } + } + +// --------------------------------------------------------------------------- +// CThumbnailRequestActive::ChangePriority() +// --------------------------------------------------------------------------- +// +void CThumbnailRequestActive::ChangePriority( const TInt aNewPriority ) + { + TN_DEBUG1( "CThumbnailRequestActive::ChangePriority"); + + iParams.iPriority = aNewPriority; + + if (!IsActive()) + { + this->SetPriority(aNewPriority); + } + else + { + iSession.ChangePriority(iRequestId, aNewPriority); + } + } + +// --------------------------------------------------------------------------- +// CThumbnailRequestActive::TimerCallBack() +// --------------------------------------------------------------------------- +// +TInt CThumbnailRequestActive::TimerCallBack(TAny* aAny) + { + TN_DEBUG1( "CThumbnailRequestActive::TimerCallBack() - request timeout"); + + CThumbnailRequestActive* self = static_cast( aAny ); + + self->Cancel(); + self->iError = KErrTimedOut; + self->HandleError(); + + return KErrNone; + } + +// End of file diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailrequestqueue.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailrequestqueue.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,278 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Processor object for running thumbnail requests +* +*/ + + +#include "thumbnailrequestqueue.h" +#include "thumbnailrequestactive.h" +#include "thumbnaillog.h" + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CThumbnailRequestQueue::NewL() +// Two-phased constructor. +// --------------------------------------------------------------------------- +// +CThumbnailRequestQueue* CThumbnailRequestQueue::NewL() + { + CThumbnailRequestQueue* self = new( ELeave )CThumbnailRequestQueue(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// CThumbnailRequestQueue::CThumbnailRequestQueue() +// C++ default constructor can NOT contain any code, that might leave. +// --------------------------------------------------------------------------- +// +CThumbnailRequestQueue::CThumbnailRequestQueue() + { + } + + +// --------------------------------------------------------------------------- +// CThumbnailRequestQueue::ConstructL() +// Symbian 2nd phase constructor can leave. +// --------------------------------------------------------------------------- +// +void CThumbnailRequestQueue::ConstructL() + { + iActiveRequests = 0; + } + + +// --------------------------------------------------------------------------- +// CThumbnailRequestQueue::~CThumbnailRequestQueue() +// Destructor. +// --------------------------------------------------------------------------- +// +CThumbnailRequestQueue::~CThumbnailRequestQueue() + { + TN_DEBUG1( "CThumbnailRequestQueue::~CThumbnailRequestQueue()"); + + iRequests.ResetAndDestroy(); + + TN_DEBUG1( "CThumbnailRequestQueue::~CThumbnailRequestQueue() - All requests deleted"); + } + + +// --------------------------------------------------------------------------- +// CThumbnailRequestQueue::Process() +// Activates next request if possible. +// --------------------------------------------------------------------------- +// +void CThumbnailRequestQueue::Process() + { + TN_DEBUG1( "CThumbnailRequestQueue::Process()"); + + while ( (iActiveRequests < KMaxClientRequests) && + (iRequests.Count() > iActiveRequests) ) + { + CThumbnailRequestActive* selectedRequest = NULL; + TInt priority( KMinTInt ); + TInt reqPriority; + CThumbnailRequestActive* request = NULL; + + for ( TInt i = 0; i < iRequests.Count(); i++ ) + { + request = iRequests[i]; + + // this task is not yet activated or processed + if( request && !request->RequestCompleted() && !request->IsRequestActive() ) + { + TN_DEBUG4( "CThumbnailRequestQueue::Process() - candidate at %d, id = %d, (0x%08x)", i, + request->RequestId(), + request); + reqPriority = request->Priority(); + if ( reqPriority > priority ) + { + priority = reqPriority; + selectedRequest = request; + } + } + } + + // activate selected + if ( selectedRequest ) + { + TN_DEBUG1( "CThumbnailRequestQueue::Process() - starting next request"); + + TRAPD(err, selectedRequest->StartL()); + if (err != KErrNone) + { + iActiveRequests++; + } + } + else + { + break; + } + } + + TN_DEBUG3( "CThumbnailRequestQueue::Process() end - requests: %d, active requests: %d", + iRequests.Count(), iActiveRequests ); + } + + +// --------------------------------------------------------------------------- +// CThumbnailRequestQueue::AddRequestL() +// Adds new request to the queue. +// --------------------------------------------------------------------------- +// +void CThumbnailRequestQueue::AddRequestL( CThumbnailRequestActive* aRequest ) + { + TN_DEBUG3( "CThumbnailRequestQueue::AddRequestL() - requests: %d, active requests: %d", + iRequests.Count(), iActiveRequests ); + + RemoveCompleted(NULL); + iRequests.AppendL( aRequest ); + } + +void CThumbnailRequestQueue::RemoveCompleted( CThumbnailRequestActive* aRequestAO) + { + TN_DEBUG3( "CThumbnailRequestQueue::RemoveCompleted() - begin - requests: %d, active requests: %d", + iRequests.Count(), iActiveRequests ); + + //process completed queue and remove finished tasks + for ( TInt i = iRequests.Count() -1; i >= 0 && iRequests.Count(); i-- ) + { + CThumbnailRequestActive* request = iRequests[i]; + + // remove completed task if it's not active anymore and not this + if ( request->RequestCompleted() && !request->IsRequestActive() && aRequestAO != request) + { + // delete completed task + TN_DEBUG3( "CThumbnailRequestQueue::RemoveCompleted() - deleted id = %d (0x%08x)", request->RequestId(), request); + delete request; + iRequests.Remove( i ); + } + } + + TN_DEBUG3( "CThumbnailRequestQueue::RemoveCompleted() end - requests: %d, active requests: %d", + iRequests.Count(), iActiveRequests ); + } + + +// --------------------------------------------------------------------------- +// CThumbnailRequestQueue::CancelRequest() +// Removes specific request from the queue. +// --------------------------------------------------------------------------- +// +TInt CThumbnailRequestQueue::CancelRequest( const TThumbnailRequestId aRequestId ) + { + TN_DEBUG2( "CThumbnailRequestQueue::CancelRequest() - request ID: %d", aRequestId); + + TInt res = KErrNotFound; + + for ( TInt i = iRequests.Count(); --i >= 0; ) + { + CThumbnailRequestActive* request = iRequests[i]; + if ( request->RequestId() == aRequestId ) + { + // Cancel and remove from queue + if (iRequests[i]->IsActive()) + { + iRequests[i]->Cancel(); + + iActiveRequests--; + if(iActiveRequests <= -1) + { + iActiveRequests = 0; + } + + delete request; + iRequests.Remove( i ); + + TN_DEBUG2( "CThumbnailRequestQueue::CancelRequest() - canceled request ID: %d", aRequestId); + } + else + { + delete request; + iRequests.Remove( i ); + + TN_DEBUG2( "CThumbnailRequestQueue::CancelRequest() - removed request ID: %d", aRequestId); + } + + res = KErrNone; + break; + } + } + + RemoveCompleted(NULL); + + Process(); + + return res; + } + + +// --------------------------------------------------------------------------- +// CThumbnailRequestQueue::ChangeReqPriority() +// Changes priority of a request. +// --------------------------------------------------------------------------- +// +TInt CThumbnailRequestQueue::ChangePriority( const TThumbnailRequestId aRequestId, + const TInt aNewPriority ) + { + TN_DEBUG1( "CThumbnailRequestQueue::ChangePriority()"); + + TInt err = KErrNotFound; + const TInt count = iRequests.Count(); + + for ( TInt i( 0 ); i < count; i++ ) + { + if ( iRequests[i]->RequestId() == aRequestId ) + { + iRequests[i]->ChangePriority( aNewPriority ); + + err = KErrNone; + break; + } + } + + return err; + } + + +// --------------------------------------------------------------------------- +// CThumbnailRequestQueue::RequestComplete() +// Completes the request +// --------------------------------------------------------------------------- +// +void CThumbnailRequestQueue::RequestComplete(CThumbnailRequestActive* aRequestAO) + { + TN_DEBUG2( "CThumbnailRequestQueue::RequestComplete(0x%08x)", aRequestAO); + + iActiveRequests--; + if(iActiveRequests <= -1) + { + iActiveRequests = 0; + } + + RemoveCompleted( aRequestAO ); + + Process(); + + TN_DEBUG2( "CThumbnailRequestQueue::RequestComplete() end - active requests: %d", iActiveRequests ); + } + + +// End of file diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailsession.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailsession.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,351 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Thumbnail server client-side session + * +*/ + + +// INCLUDE FILES +#include "thumbnailsession.h" +#include "thumbnailmanagerconstants.h" + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// RThumbnailSession::RThumbnailSession() +// C++ default constructor can NOT contain any code, that might leave. +// --------------------------------------------------------------------------- +// +RThumbnailSession::RThumbnailSession(): RSessionBase() + { + // No implementation required + } + + +// --------------------------------------------------------------------------- +// RThumbnailSession::Connect() +// --------------------------------------------------------------------------- +// +TInt RThumbnailSession::Connect() + { + StartServer(); + + // special case + // wait possibly needed here to give an old server process + // time to enter shutdown state + User::After(1000); + + TInt err = CreateSession( KThumbnailServerName, Version(), KMessageSlots ); + TInt retry = 1; + + // special case + // old server still alive, wait and try again + while (retry <= 10 && err != KErrNone) + { + User::After(retry * 50000); + StartServer(); + err = CreateSession( KThumbnailServerName, Version(), KMessageSlots ); + retry++; + } + + return err; + } + + +// --------------------------------------------------------------------------- +// RThumbnailSession::Close() +// Closes session +// --------------------------------------------------------------------------- +// +void RThumbnailSession::Close() + { + RSessionBase::Close(); + } + + +// --------------------------------------------------------------------------- +// RThumbnailSession::Version() +// Closes session +// --------------------------------------------------------------------------- +// +TVersion RThumbnailSession::Version() + { + return TVersion( KThumbnailServerMajorVersionNumber, + KThumbnailServerMinorVersionNumber, KThumbnailServerBuildVersionNumber ) + ; + } + + +// --------------------------------------------------------------------------- +// RThumbnailSession::StartServer() +// --------------------------------------------------------------------------- +// +TInt RThumbnailSession::StartServer() + { + TInt res( KErrNone ); + // create server - if one of this name does not already exist + + TFindServer findServer( KThumbnailServerName ); + TFullName name; + if ( findServer.Next( name ) != KErrNone ) + // we don't exist already + { + RProcess server; + // Create the server process + // KNullDesC param causes server's E32Main() to be run + res = server.Create( KThumbnailServerExe, KNullDesC ); + if ( res != KErrNone ) + // thread created ok - now start it going + { + return res; + } + + // Process created successfully + TRequestStatus status; + server.Rendezvous( status ); + server.Resume(); // start it going + + // Wait until the completion of the server creation + User::WaitForRequest( status ); + + if ( status != KErrNone ) + { + server.Close(); + return status.Int(); + } + // Server created successfully + server.Close(); // we're no longer interested in the other process + + } + return res; + } + + +// --------------------------------------------------------------------------- +// Request a thumbnail for an object file using file handle +// --------------------------------------------------------------------------- +// +void RThumbnailSession::RequestThumbnailL( const RFile64& aFile, const TDesC& aTargetUri, + TThumbnailRequestParamsPckg& aParams, TRequestStatus& aStatus ) + { + TIpcArgs args( &aParams, KCheckValue ); // 1st and 2nd argument + User::LeaveIfError( aFile.TransferToServer( args, 2, 3 )); // 3th and 4th argument + aParams().iTargetUri = aTargetUri; + SendReceive( ERequestThumbByFileHandleAsync, args, aStatus ); + } + + +// --------------------------------------------------------------------------- +// Request a thumbnail for an object file using file path +// --------------------------------------------------------------------------- +// +void RThumbnailSession::RequestThumbnailL( const TDesC& aPath, const TDesC& aTargetUri, const TThumbnailId /*aThumbnailId*/, + TThumbnailRequestParamsPckg& aParams, TRequestStatus& aStatus ) + { + TIpcArgs args( &aParams, KCheckValue); + aParams().iFileName = aPath; + aParams().iTargetUri = aTargetUri; + + if(aPath.Length()== 0) + { + SendReceive( ERequestThumbByIdAsync, args, aStatus ); + } + else + { + SendReceive( ERequestThumbByPathAsync, args, aStatus ); + } + } + +// --------------------------------------------------------------------------- +// Request a thumbnail for an object file using file path +// --------------------------------------------------------------------------- +// +void RThumbnailSession::RequestThumbnailL( const TThumbnailId aThumbnailId, + const TDesC& /*aTargetUri*/, + TThumbnailRequestParamsPckg& aParams, + TRequestStatus& aStatus ) + { + TIpcArgs args( &aParams, KCheckValue ); + aParams().iThumbnailId = aThumbnailId; + SendReceive( ERequestThumbByIdAsync, args, aStatus ); + } + +#if 0 +// --------------------------------------------------------------------------- +// Request a thumbnail for an object file using file path +// --------------------------------------------------------------------------- +// +void RThumbnailSession::RequestThumbnailL( const TDesC& aPath, const TDesC& aTargetUri, + TThumbnailRequestParamsPckg& aParams, TRequestStatus& aStatus ) + { + TIpcArgs args( &aParams ); + aParams().iFileName = aPath; + aParams().iTargetUri = aTargetUri; + SendReceive( ERequestThumbByPathAsync, args, aStatus ); + } +#endif + +void RThumbnailSession::RequestSetThumbnailL( + TDesC8* aBuffer, const TDesC& aTargetUri, + TThumbnailRequestParamsPckg& aParams, + TRequestStatus& aStatus ) + { + if( !aBuffer ) + { + User::Leave( KErrArgument ); + } + + TIpcArgs args( &aParams, aBuffer, aBuffer->Length(), KCheckValue ); + aParams().iTargetUri = aTargetUri; + SendReceive( ERequestSetThumbnailByBuffer, args, aStatus ); + } + +void RThumbnailSession::RequestSetThumbnailL( + TInt aBitmapHandle, const TDesC& aTargetUri, + TThumbnailRequestParamsPckg& aParams, + TRequestStatus& aStatus ) + { + if( !aBitmapHandle ) + { + User::Leave( KErrArgument ); + } + + TIpcArgs args( &aParams, aBitmapHandle, KCheckValue ); + aParams().iTargetUri = aTargetUri; + SendReceive( ERequestSetThumbnailByBitmap, args, aStatus ); + } + +// --------------------------------------------------------------------------- +// Release bitmap instance kept by server process +// --------------------------------------------------------------------------- +// +void RThumbnailSession::ReleaseBitmap( TInt aBitmapHandle ) + { + TInt err = Send( EReleaseBitmap, TIpcArgs( aBitmapHandle )); + while ( err == KErrServerBusy ) + { + err = Send( EReleaseBitmap, TIpcArgs( aBitmapHandle )); + } + } + + +// --------------------------------------------------------------------------- +// Cancel pending thumbnail request +// --------------------------------------------------------------------------- +// +TInt RThumbnailSession::CancelRequest( TThumbnailRequestId aRequestId ) + { + TInt err = SendReceive( ECancelRequest, TIpcArgs( aRequestId )); + while ( err == KErrServerBusy ) + { + err = SendReceive( ECancelRequest, TIpcArgs( aRequestId )); + } + return err; + } + + +// --------------------------------------------------------------------------- +// Change priority of pending thumbnail request +// --------------------------------------------------------------------------- +// +TInt RThumbnailSession::ChangePriority( TThumbnailRequestId aRequestId, TInt + aNewPriority ) + { + TInt err = SendReceive( EChangePriority, TIpcArgs( aRequestId, aNewPriority )); + while ( err == KErrServerBusy ) + { + err = SendReceive( EChangePriority, TIpcArgs( aRequestId, aNewPriority )); + } + return err; + } + +// --------------------------------------------------------------------------- +// Delete thumbnails for given object file +// --------------------------------------------------------------------------- +// +TInt RThumbnailSession::CreateThumbnails( const RFile64& aFile, TDisplayMode aDisplayMode ) + { + TIpcArgs args( aDisplayMode ); // 1st argument + TInt err = aFile.TransferToServer( args, 1, 2 ); // 2.&3. argument + err = Send( ECreateThumbnails, args ); + while ( err == KErrServerBusy ) + { + err = Send( ECreateThumbnails, args ); + } + return err; + } + + +// --------------------------------------------------------------------------- +// Delete thumbnails for given object file +// --------------------------------------------------------------------------- +// +void RThumbnailSession::DeleteThumbnails( const TDesC& aPath, + TThumbnailRequestParamsPckg& aParams, TRequestStatus& aStatus ) + { + TIpcArgs args( &aParams, &aPath, KCheckValue); + + SendReceive( EDeleteThumbnails, args, aStatus ); + } + + +// --------------------------------------------------------------------------- +// Delete thumbnails by TThumbnailId. +// --------------------------------------------------------------------------- +// +void RThumbnailSession::DeleteThumbnails( const TThumbnailId aItemId, + TThumbnailRequestParamsPckg& aParams, TRequestStatus& aStatus ) + { + TIpcArgs args( &aParams, aItemId, KCheckValue); + + SendReceive( EDeleteThumbnailsById, args, aStatus ); + } + + +// --------------------------------------------------------------------------- +// Get a list of supported MIME types in a HBufC +// --------------------------------------------------------------------------- +// +HBufC* RThumbnailSession::GetMimeTypeListL() + { + TInt size = 0; + TPckg < TInt > pckg( size ); + User::LeaveIfError( SendReceive( EGetMimeTypeBufferSize, TIpcArgs( &pckg ))); + HBufC* res = HBufC::NewLC( size ); + TPtr ptr = res->Des(); + User::LeaveIfError( SendReceive( EGetMimeTypeList, TIpcArgs( &ptr ))); + CleanupStack::Pop( res ); + return res; + } + + +// --------------------------------------------------------------------------- +// Update thumbnails. +// --------------------------------------------------------------------------- +// +void RThumbnailSession::UpdateThumbnails( const TDesC& aPath, const TInt aOrientation, + const TInt64 aModified, TThumbnailRequestParamsPckg& aParams, TRequestStatus& aStatus ) + { + aParams().iFileName = aPath; + aParams().iTargetUri = KNullDesC; + aParams().iOrientation = aOrientation; + aParams().iModified = aModified; + + TIpcArgs args( &aParams, KCheckValue); + + SendReceive( EUpdateThumbnails, args, aStatus ); + } + + +// End of file diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailserver/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/group/bld.inf Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Build information file for project ?myapp +* +*/ + + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_MMPFILES +thumbnailserver.mmp + diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailserver/group/thumbnailserver.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/group/thumbnailserver.mmp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,89 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Project definition file for project ?myapp +* +*/ + + +// To get the MW_LAYER_SYSTEMINCLUDE-definition +#include + +#include +#include "../../inc/thumbnailmanageruids.hrh" + +VERSION 10.0 +TARGET thumbnailserver.exe +TARGETTYPE EXE +UID 0x0 THUMBNAIL_MANAGER_SERVER_UID + +#ifdef WINSCW +EPOCHEAPSIZE 4096 0x800000 // heap 8MB +#else +EPOCHEAPSIZE 4096 0x3000000 // max heap 48MB +#endif + + +CAPABILITY ALL -TCB -DRM +VENDORID VID_DEFAULT + +SOURCEPATH ../src +SOURCE thumbnailserver.cpp +SOURCE thumbnailserversession.cpp +SOURCE thumbnailtaskprocessor.cpp +SOURCE thumbnailtask.cpp +SOURCE thumbnailgeneratetask.cpp +SOURCE thumbnailscaletask.cpp +SOURCE thumbnailstore.cpp +SOURCE thumbnailprovider.cpp +SOURCE thumbnaildiskunmountobserver.cpp +SOURCE thumbnailcenrep.cpp +SOURCE thumbnailmemorycardobserver.cpp +SOURCE tmshutdownobserver.cpp +SOURCE thumbnaildecodetask.cpp +#ifdef RD_MDS_2_5 +SOURCE thumbnailmdsquerytask.cpp +#endif // RD_MDS_2_5 +SOURCE tnmgetimei.cc +SOURCE thumbnailformatobserver.cpp + +// Default system include paths for middleware layer modules. +MW_LAYER_SYSTEMINCLUDE + +USERINCLUDE ../inc +USERINCLUDE ../../inc + +LIBRARY fbscli.lib +LIBRARY euser.lib +LIBRARY ecom.lib +LIBRARY efsrv.lib +LIBRARY apmime.lib +LIBRARY sqldb.lib +LIBRARY apgrfx.lib +LIBRARY estor.lib +LIBRARY ihl.lib +LIBRARY centralrepository.lib +LIBRARY platformenv.lib +LIBRARY imageconversion.lib +LIBRARY caf.lib +LIBRARY cafutils.lib +LIBRARY mdeclient.lib +LIBRARY etel3rdparty.lib +LIBRARY bafl.lib +LIBRARY bitgdi.lib + +DEBUGLIBRARY flogger.lib + +PAGED +BYTEPAIRCOMPRESSTARGET +EPOCPROCESSPRIORITY foreground diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailcenrep.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailcenrep.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,211 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class for handling central repositoty data + * +*/ + + +#ifndef THUMBNAILCENREP_H +#define THUMBNAILCENREP_H + +#include + +#include // TThumbnailSize + +class CRepository; +class TThumbnailPersistentSize; +class TThumbnailAutoCreate; + +/** + * Class for handling central repositoty data. + * + * @since S60 v5.0 + */ +class CThumbnailCenRep: public CBase + { + +public: + + /** + * Destructor + * + * @since S60 v5.0 + */ + virtual ~CThumbnailCenRep(); + + /** + * Two-phased constructor + * + * @since S60 v5.0 + * @return New CThumbnailCenRep instance. + */ + static CThumbnailCenRep* NewL(); + + /** + * GetPersistentSizes + * + * @since S60 v5.0 + * @return Reference to array of central repository settings + */ + RArray < TThumbnailPersistentSize > & GetPersistentSizes(); + + /** + * GetAutoCreateParams + * + * @since S60 v5.0 + * @return Reference to auto creation settings + */ + TThumbnailAutoCreate & GetAutoCreateParams(); + + /** + * Get concrete persistent size associated to relative size + * + * @since S60 v5.0 + * @param aThumbnailSize Relative size + * @return Persistent size object + */ + TThumbnailPersistentSize & PersistentSizeL( TThumbnailSize + aThumbnailSize ); + +private: + + /** + * C++ default constructor + * + * @since S60 v5.0 + * @return New CThumbnailCenRep instance. + */ + CThumbnailCenRep(); + + /** + * ConstructL + * + * @since S60 v5.0 + */ + void ConstructL(); + +private: + // data + + /** + * Central Repository + * Own. + */ + CRepository* iRepository; + + /** + * Persistent sizes. + */ + RArray < TThumbnailPersistentSize > iPersistentSizes; + + /** + * Auto creation parameters. + */ + TThumbnailAutoCreate * iAutoCreate; + +}; + +/** + * Class for representing persistent thumbnail sizes and related + * parameters. + * + * @since S60 v5.0 + */ +class TThumbnailPersistentSize + { + /** + * Format used for storing bitmaps. + * @since S60 v5.0 + */ + enum TThumbnailImageFormat + { + /** + * Use JPEG compression for stored bitmaps. + */ + EJpeg, + + /** + * Use native Symbian bitmap format for stored bitmaps. + */ + EBmp + }; + +public: + enum { EUnknownSourceType, EImage, EVideo, EAudio }; + enum { EUnknownSizeType, EGrid, EList, EFullscreen }; + +public: + + /** + * C++ constructor. + * + * @since S60 v5.0 + * @param aSize Thumbnail size (in pixels) which will be stored. + * @param aCrop If true, stored thumbnails are cropped to aspect ratio. + * @param aMode Display mode used for stored bitmaps + * @param aFormat Format used when storing thumbnails + */ + TThumbnailPersistentSize( const TSize& aSize, TBool aCrop, TDisplayMode + aMode, TInt aFormat ); + + TThumbnailPersistentSize( TThumbnailSize aType, const TSize& aSize, TBool aCrop, TDisplayMode + aMode, TInt aFormat, TBool aAutoCreate ); + +public: + + // data + TThumbnailSize iType; + TInt iSourceType; + TInt iSizeType; + + TSize iSize; + TBool iCrop; + TDisplayMode iMode; + TInt iFormat; + + TBool iAutoCreate; +}; + +/** + * Class for representing thumbnail auto creation parameters. + * + * @since S60 v5.0 + */ +class TThumbnailAutoCreate + { + +public: + + /** + * C++ constructor. + * + * @since S60 v5.0 + */ + TThumbnailAutoCreate(); + +public: + + // data + TBool iImageGrid; + TBool iImageList; + TBool iImageFullscreen; + TBool iVideoGrid; + TBool iVideoList; + TBool iVideoFullscreen; + TBool iAudioGrid; + TBool iAudioList; + TBool iAudioFullscreen; +}; + +#endif // THUMBNAILCENREP_H diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnaildecodetask.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnaildecodetask.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,136 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Task for decoding a thumbnail + * +*/ + + +#ifndef THUMBNAILDECODETASK_H +#define THUMBNAILDECODETASK_H + +#include + +#include "thumbnailtask.h" +#include "thumbnailprovider.h" + + +class CThumbnailServer; + +/** + * Task for decoding a thumbnail. + * + * @since S60 v5.0 + */ +class CThumbnailDecodeTask: public CThumbnailTask, + public MThumbnailProviderObserver + { +public: + + /** + * C++ default constructor + * + * @since S60 v5.0 + * @param aProcessor Processor object for running tasks. + * @param aServer Thumbnail server in use. + * @param aBuffer Image in JPEG mode. + * @param aPriority Priority of the request. + * @return New CThumbnailDecodeTask object. + */ + CThumbnailDecodeTask( CThumbnailTaskProcessor& aProcessor, CThumbnailServer& aServer, TDesC8* aBuffer, + TInt aPriority, TDisplayMode aDisplayMode); + + /** + * Destructor. + * + * @since S60 v5.0 + */ + virtual ~CThumbnailDecodeTask(); + + /** + * StartL + * + * @since S60 v5.0 + */ + void StartL(); + + /** + * Handles an active object's request completion event. + * + * @since S60 v5.0 + */ + void RunL(); + + /** + * Implements cancellation of an outstanding request. + * + * @since S60 v5.0 + */ + void DoCancel(); + +private: + + /** + * For notifying when task has been finished. + * + * @since S60 v5.0 + * @param aError Error code. + * @param aBitmap Thumbnail image. + * @param aOriginalSize Original image size. + */ + void ThumbnailProviderReady( const TInt aError, CFbsBitmap* aBitmap, const + TSize& aOriginalSize, const TBool aEXIF, const TBool aPortait ); + + +private: + // Data + + /** + * Server. + */ + CThumbnailServer& iServer; + + /** + * Image buffer + */ + TDesC8* iBuffer; + + /** + * Size of the original image. + */ + TSize iOriginalSize; + + /** + * Thumbnail provider implementation. + * Not own. + */ + CThumbnailProvider* iProvider; + + /** + * If set, scaled bitmap must be released from pool. + */ + TInt iBitmapHandle; + + /** + * Temporary buffer for client/server parameters + */ + TThumbnailRequestParamsPckgBuf iParamsBuf; + + /* + * Displaymode of requested TN + */ + TDisplayMode iDisplayMode; + +}; + +#endif // THUMBNAILGENERATETASK_H diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnaildiskunmountobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnaildiskunmountobserver.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class to monitor when volumes are unmounted + * +*/ + + +#ifndef THUMBNAILDISKUNMOUNTOBSERVER_H +#define THUMBNAILDISKUNMOUNTOBSERVER_H + +#include "f32file.h" + +class CThumbnailServer; + +/** + * Class to monitor when volumes are unmounted + * + * @since S60 v5.0 + */ +class CThumbnailDiskUnmountObserver: public CActive + { +public: + + /** + * Two-phased constructor + * + * @since S60 v5.0 + * @return New CThumbnailDiskUnmountObserver object. + */ + static CThumbnailDiskUnmountObserver* NewL( RFs& aFs, TInt aDrive, CThumbnailServer* aServer ); + /** + * Destructor + * + * @since S60 v5.0 + */ + virtual ~CThumbnailDiskUnmountObserver(); + + void StartNotify(); + +private: + void RunL(); + void DoCancel(); + + + /** + * C++ default constructor + * + * @since S60 v5.0 + * @return New CThumbnailDiskUnmountObserver object. + */ + CThumbnailDiskUnmountObserver( RFs& aFs, TInt aDrive, CThumbnailServer* aServer ); + + /** + * Symbian 2nd phase constructor can leave. + * + * @since S60 v5.0 + */ + void ConstructL(); + +private: + // Data + RFs& iFs; + TInt iDrive; + CThumbnailServer* iServer; +}; + +#endif // THUMBNAILDISKUNMOUNTOBSERVER_H diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailformatobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailformatobserver.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,94 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Monitors File system for Format events +* +*/ + + +#ifndef CTHUMBNAILFORMATOBSERVER_H +#define CTHUMBNAILFORMATOBSERVER_H + +#include +#include "f32file.h" +#include "thumbnailserver.h" + +/** + * File System monitor class to monitor for format events + * + * @lib thumbnailsserver.exe + * @since S60 3.0 + */ +NONSHARABLE_CLASS( CThumbnailFormatObserver ) : public CBase, + public MBackupOperationObserver + { + +public: + + /** + * Two-phase constructor + * @param aObserver observer to the monitor + */ + static CThumbnailFormatObserver* NewL( CThumbnailServer* aServer ); + + /** + * Two-phase constructor + * @param aObserver observer to the monitor + */ + static CThumbnailFormatObserver* NewLC( CThumbnailServer* aServer ); + + /** + * Destructor + */ + virtual ~CThumbnailFormatObserver(); + +public: // New functions + + /** + * Polls for the current monitor status + * If an event is happening, it will callback the observer of the event + */ + void PollStatus(); + +protected: // Base Class + + /* + * From MBackupOperationObserver + * Notifies this class of the backup event. + * MMC App will signal a start / end. + */ + void HandleBackupOperationEventL(const TBackupOperationAttributes& aBackupOperationAttributes); + +private: + + /** + * C++ constructor + * aObserver observer to this event + */ + CThumbnailFormatObserver ( CThumbnailServer* aServer ); + + /* + * Second phased constructor + */ + void ConstructL(); + +private: // data + + CThumbnailServer* iServer; + + CBaBackupSessionWrapper* iBackupSession; + + + }; + +#endif // CTHUMBNAILFORMATOBSERVER_H diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailgeneratetask.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailgeneratetask.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,233 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Task for generating new thumbnails +* +*/ + + +#ifndef THUMBNAILGENERATETASK_H +#define THUMBNAILGENERATETASK_H + +#include + +#include "thumbnailtask.h" +#include "thumbnailprovider.h" +#include "thumbnailstore.h" // TThumbnailPersistentSize + +class CThumbnailServer; + +/** + * Task for generating new thumbnails. + * + * @since S60 v5.0 + */ +class CThumbnailGenerateTask: public CThumbnailTask, + public MThumbnailProviderObserver + { +public: + + /** + * C++ default constructor + * + * @since S60 v5.0 + * @param aProcessor Processor object for running tasks. + * @param aServer Thumbnail server in use. + * @param aFile File from which the thumbnail is to be created. + * @param aFlags Flags that control the creation of thumbnail. + * @param aSize Requested size of thumbnail. + * @param aDisplayMode Display mode. + * @param aPriority Priority of the request. + * @return New CThumbnailGenerateTask object. + */ + CThumbnailGenerateTask( CThumbnailTaskProcessor& aProcessor, CThumbnailServer& aServer, + RFile64* aFile, TDesC8* aBuffer, const TDataType* aMimeType, + CThumbnailManager::TThumbnailFlags aFlags, const TSize& aSize, + TDisplayMode aDisplayMode, TInt aPriority, + RArray < TThumbnailPersistentSize >* aMissingSizes, const TDesC& aTargetUri, + TThumbnailSize aThumbnailSize, const TThumbnailId aThumbnailId, + const CThumbnailManager::TThumbnailQualityPreference aQualityPreference ); + + /** + * Destructor. + * + * @since S60 v5.0 + */ + virtual ~CThumbnailGenerateTask(); + + /** + * StartL + * + * @since S60 v5.0 + */ + void StartL(); + + /** + * Handles an active object's request completion event. + * + * @since S60 v5.0 + */ + void RunL(); + + /** + * Implements cancellation of an outstanding request. + * + * @since S60 v5.0 + */ + void DoCancel(); + + /** + * Defines if scaled bitmaps needs to be added to pool. + * + * @since S60 v5.0 + * @param aBool boolean + */ + void ScaledBitmapToPool(TBool aBool); + +private: + + /** + * Calculate the largest non-cropped size and largest cropped size and + * let the provider know. + * + * @since S60 v5.0 + * @param aEffectiveTargetSize Effective target size. + * @param aCroppedTargetSize Cropped target size. + */ + void CalculateTargetSizesL( TSize& aEffectiveTargetSize, TSize& + aCroppedTargetSize ); + + /** + * For notifying when task has been finished. + * + * @since S60 v5.0 + * @param aError Error code. + * @param aBitmap Thumbnail image. + * @param aOriginalSize Original image size. + * @param aEXIF is origin EXIF. + */ + void ThumbnailProviderReady( const TInt aError, CFbsBitmap* aBitmap, const + TSize& aOriginalSize, const TBool aEXIF, const TBool aPortrait ); + + /** + * For creating scaling task. + * + * @since S60 v5.0 + * @param aBitmap Bitmap image. + * @param aEXIF is origin EXIF. + */ + void CreateScaleTasksL( CFbsBitmap* aBitmap ); + + /** + * For creating blacklisted thumbnail. + * + * @param aOriginalSize Original size of bitmap. + */ + void CreateBlackListedL( const TSize& aOriginalSize ); + +private: + // Data + + /** + * Server. + */ + CThumbnailServer& iServer; + + /** + * Imagefile from which the thumbnail is to be created. + */ + RFile64 iFile; + + /** + * Image buffer + */ + TDesC8* iBuffer; + + /** + * Mime type of the original image. + */ + TDataType iMimeType; + + /** + * Filename of the image from which the thumbnail is to be created. + */ + TFileName iFilename; + + /** + * Flags + */ + CThumbnailManager::TThumbnailFlags iFlags; + /** + * Requested size of thumbnail. + */ + TSize iSize; + + /** + * Display mode. + */ + TDisplayMode iDisplayMode; + + /** + * Only missing persistent sized thumbnails will be created + */ + RArray < TThumbnailPersistentSize >* iMissingSizes; + + /** + * Uri of the target object + */ + TFileName iTargetUri; + + /** + * Relative thumbnail size + */ + TThumbnailSize iThumbnailSize; + + + /** + * Size of the original image. + */ + TSize iOriginalSize; + + /** + * Refers to a bitmap in the bitmap pool owned by server. Must be deleted + * using CThumbnailServer::DeleteBitmapFromPool() to make reference + * counting work. + * Not own. + */ + CFbsBitmap* iBitmap; + + /** + * Thumbnail provider implementation. + * Not own. + */ + CThumbnailProvider* iProvider; + + TThumbnailId iThumbnailId; + + TBool iScaledBitmapToPool; + +#ifdef _DEBUG + TTime aStart, aStop; +#endif + + CThumbnailManager::TThumbnailQualityPreference iQualityPreference; + + TBool iEXIF; + + /** + * Target rect rotated (portrait image) + */ + TBool iPortrait; +}; + +#endif // THUMBNAILGENERATETASK_H diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailmdsquerytask.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailmdsquerytask.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,141 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Task for making MDS querys +* +*/ + + +#ifndef THUMBNAILMDSQUERYTASK_H +#define THUMBNAILMDSQUERYTASK_H + +#include +#include +#include + +#include "thumbnailtask.h" + +class CThumbnailServer; + +/** + * Task for making MDS querys + * + * @since S60 v5.0 + */ +class CThumbnailMDSQueryTask: public CThumbnailTask, + public MMdEQueryObserver + { +public: + + /** + * C++ default constructor + * + * @since S60 v5.0 + * @param aProcessor Processor object for running tasks. + * @param aPriority Priority of the request. + * @return New CThumbnailMDSQueryTask object. + */ + CThumbnailMDSQueryTask( CThumbnailTaskProcessor& aProcessor, TInt aPriority, + CMdESession* aMdESession, CThumbnailServer& aServer); + + /** + * Destructor. + * + * @since S60 v5.0 + */ + virtual ~CThumbnailMDSQueryTask(); + + /** + * StartL + * + * @since S60 v5.0 + */ + void StartL(); + + /** + * Handles an active object's request completion event. + * + * @since S60 v5.0 + */ + void RunL(); + + /** + * Implements cancellation of an outstanding request. + * + * @since S60 v5.0 + */ + void DoCancel(); + + /** + * Query path by id + * + * @since S60 v5.0 + * @param aId ID + */ + void QueryPathByIdL(TThumbnailId aId); + + /** + * Query Id by path + * + * @since S60 v5.0 + * @param aUri the Path + */ + void QueryIdByPathL(const TDesC& aUri); + + /** + * Sets are values updated to db automatically + * + * @since S60 v5.0 + * @param aComplete message, default is ETrue + */ + void SetUpdateToDb(const TBool& aUpdateToDb ); + +public: + + // From MMdEQueryObserver + void HandleQueryNewResults( CMdEQuery& aQuery, TInt aFirstNewItemIndex, TInt aNewItemCount ); + void HandleQueryCompleted( CMdEQuery& aQuery, TInt aError ); + +protected: + + void ReturnPath(const TDesC& aUri); + +private: + + // not own + CMdESession* iMdESession; + + // own + CMdEObjectQuery* iQuery; + + TThumbnailRequestParamsPckgBuf iRequestParams; + + /** + * Server. + */ + CThumbnailServer& iServer; + + /** + * Query type used when filling missing information from MDS + */ + TMDSQueryType iQueryType; + + /** + * Does task update db + */ + TBool iUpdateToDb; + + TFileName iUri; +}; + +#endif // THUMBNAILMDSQUERYTASK_H diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailmemorycardobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailmemorycardobserver.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,75 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class to monitor when volumes are unmounted + * +*/ + + +#ifndef THUMBNAILMEMORYCARDOBSERVER_H +#define THUMBNAILMEMORYCARDOBSERVER_H + +#include "f32file.h" +#include "thumbnailserver.h" + +/** + * Class to monitor when memory card status changes + * + * @since S60 v5.0 + */ +class CThumbnailMemoryCardObserver: public CActive + { +public: + + /** + * Two-phased constructor + * + * @since S60 v5.0 + * @return New CThumbnailMemoryCardObserver object. + */ + static CThumbnailMemoryCardObserver* NewL( CThumbnailServer* aServer, RFs& aFs ); + /** + * Destructor + * + * @since S60 v5.0 + */ + virtual ~CThumbnailMemoryCardObserver(); + +private: + void RunL(); + void DoCancel(); + + void StartNotify(); + + /** + * C++ default constructor + * + * @since S60 v5.0 + * @return New CThumbnailMemoryCardObserver object. + */ + CThumbnailMemoryCardObserver( CThumbnailServer* aServer, RFs& aFs ); + + /** + * Symbian 2nd phase constructor can leave. + * + * @since S60 v5.0 + */ + void ConstructL(); + +private: + // Data + CThumbnailServer* iServer; + RFs& iFs; +}; + +#endif // THUMBNAILMEMORYCARDOBSERVER_H diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailscaletask.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailscaletask.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,274 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Task for scaling thumbnails + * +*/ + + +#ifndef THUMBNAILSCALETASK_H +#define THUMBNAILSCALETASK_H + +#include "thumbnailtask.h" +#include "thumbnailprovider.h" +#include "thumbnailstore.h" // TThumbnailPersistentSize + +class CThumbnailServer; + +/** + * Task for scaling thumbnails. + * + * @since S60 v5.0 + */ +class CThumbnailScaleTask: public CThumbnailTask + { +public: + + /** + * Two-phased constructor + * + * @since S60 v5.0 + * @param aProcessor Processor object for running tasks. + * @param aServer Server to use. + * @param aFilename Filename of file from which the thumbnail is to be + * created. + * @param aBitmap Bitmap image. Scale task assumes ownership. + * @param aOriginalSize Original size of the image. + * @param aTargetSize Target size of thumbnail image. + * @param aCrop Enable or disable cropping. + * @param aDisplayMode Display mode. + * @param aPriority Priority of the request. + * @param aThumbnailSize Prededined size of thumbnail. + * @return New CThumbnailScaleTask object. + * @param aEXIF is origin EXIF. + */ + static CThumbnailScaleTask* NewL( CThumbnailTaskProcessor& aProcessor, + CThumbnailServer& aServer, const TDesC& aFilename, CFbsBitmap* aBitmap, + const TSize& aOriginalSize, const TSize& aTargetSize, TBool aCrop, + TDisplayMode aDisplayMode, TInt aPriority, const TDesC& aTargetUri, + const TThumbnailSize aThumbnailSize, const TThumbnailId aThumbnailId, + const TBool aBitmapToPool, const TBool aEXIF); + + /** + * Destructor + * + * @since S60 v5.0 + */ + virtual ~CThumbnailScaleTask(); + + /** + * StartL + * + * @since S60 v5.0 + */ + void StartL(); + + /** + * Handles an active object's request completion event. + * + * @since S60 v5.0 + */ + void RunL(); + + /** + * Implements cancellation of an outstanding request. + * + * @since S60 v5.0 + */ + void DoCancel(); + + /** + * Changes priority of the task. + * + * @since S60 v5.0 + */ + void ChangeTaskPriority( TInt aNewPriority ); + + /** + * Set whether the scaled image is to be stored or not. + * + * @since S60 v5.0 + * @param aDoStore Boolean value stating should the image be stored. + */ + void SetDoStore( TBool aDoStore ); + +private: + + /** + * C++ default constructor + * + * @since S60 v5.0 + * @param aProcessor Processor object for running tasks. + * @param aServer Server to use. + * @param aFilename Filename of file from which the thumbnail is to be + * created. + * @param aBitmap Bitmap image. Scale task assumes ownership. + * @param aOriginalSize Original size of the image. + * @param aTargetSize Target size of thumbnail image. + * @param aCrop Enable or disable cropping. + * @param aDisplayMode Display mode. + * @param aPriority Priority of the request. + * @param aThumbnailSize Prededined size of thumbnail. + * @return New CThumbnailScaleTask object. + * @param aEXIF is origin EXIF. + */ + CThumbnailScaleTask( CThumbnailTaskProcessor& aProcessor, CThumbnailServer& + aServer, const TDesC& aFilename, CFbsBitmap* aBitmap, const TSize& + aOriginalSize, const TSize& aTargetSize, TBool aCrop, TDisplayMode + aDisplayMode, TInt aPriority, const TDesC& aTargetUri, + const TThumbnailSize aThumbnailSize, const TThumbnailId aThumbnailId, + const TBool aBitmapToPool, const TBool aEXIF); + + /** + * Symbian 2nd phase constructor can leave. + * + * @since S60 v5.0 + */ + void ConstructL(); + + /** + * Calculates target size to be used for the thumbnail when cropping is + * disabled. The target size may be smaller than requested if aspect + * ratios do not match. Updates iTargetSize. + * + * @since S60 v5.0 + */ + void CalculateTargetSize(); + + /** + * Calculates cropping rectangle to be used for the thumbnail when + * cropping is enabled. Target size will always be the same as requested + * size and the cropping rectangle defines which area of the image will + * be visible. Updates iCropRectangle. + * + * @since S60 v5.0 + */ + void CalculateCropRectangle(); + + /** + * StoreAndCompleteL + * + * @since S60 v5.0 + */ + void StoreAndCompleteL(); + +private: + // Data + + /** + * Server. + */ + CThumbnailServer& iServer; + + /** + * Resides in bitmap pool. + * Not own. But we do are responsible for decreasing the reference count + * if iBitmapInPool is set. + */ + CFbsBitmap* iBitmap; + + /** + * Temporary place to store the original bitmap. This is set to NULL + * after the bitmap has been successfully added to the bitmap pool. + * Own. + */ + CFbsBitmap* iOwnBitmap; + + /** + * Bitmap pool. + */ + TBool iBitmapInPool; + + /** + * Original size of media object. + */ + TSize iOriginalSize; + + /** + * Target size of the thumbnail. + */ + TSize iTargetSize; + + /** + * Incidates if cropping is enabled. + */ + TBool iCrop; + + /** + * Defines the visible area of iBitmap which is to be included + * in the thumbnail if cropping is enabled. Not used if cropping + * is disabled. + */ + TRect iCropRectangle; + + /** + * Display mode. + */ + TDisplayMode iDisplayMode; + + /** + * Filename of the image to be used. + */ + TFileName iFilename; + + /** + * Uri of the target object + */ + TFileName iTargetUri; + + /** + * Scaled image. + */ + CFbsBitmap* iScaledBitmap; // own + + /** + * If set, scaled bitmap must be released from pool. + */ + TInt iScaledBitmapHandle; + + /** + * If set, thumbnail will be stored for later use. + */ + TBool iDoStore; + + /** + * Temporary buffer for client/server parameters + */ + TThumbnailRequestParamsPckgBuf iParamsBuf; + + /** + * Size of requested Thumbnail + */ + TThumbnailSize iThumbnailSize; + + /** + * MDS ID of requested Thumbnail + */ + TThumbnailId iThumbnailId; + + /** + * Add bitmap to server's pool. + */ + TBool iBitmapToPool; + +#ifdef _DEBUG + TTime aStart, aStop; +#endif + + /** + * Is origin EXIF. + */ + TBool iEXIF; +}; + +#endif // THUMBNAILSCALETASK_H diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailserver.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,680 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Thumbnail server + * +*/ + + +#ifndef THUMBNAILSERVER_H +#define THUMBNAILSERVER_H + +#include +#include +#include +#include +#include +#include + +#include + +#include "thumbnailmanager.h" +#include "thumbnailmanagerconstants.h" // TThumbnailServerRequestId +#include "thumbnailstore.h" // TThumbnailPersistentSize +#include "tmshutdownobserver.h" + +// Needed for creating server thread. +const TUint KDefaultHeapSize = 160 * 1024; + +class CThumbnailTaskProcessor; +class CThumbnailProvider; +class CThumbnailTask; +class CThumbnailStore; +class MIHLScaler; +class CThumbnailServerSession; +class CThumbnailDiskUnmountObserver; +class CThumbnailMemoryCardObserver; +class CThumbnailFormatObserver; + +/** + * Helper function to destroy all objects which are referred to + * by pointers in a hash table. + * @since S60 v5.0 + * @param aHashMap Reference to hash map + */ +template void ResetAndDestroyHashMap( RHashMap & + aHashMap ) + { + THashMapIter iter( aHashMap ); + + // const pointer to a non-const object + V* const * item = iter.NextValue(); + + while ( item ) + { + delete * item; + item = iter.NextValue(); + } + aHashMap.Close(); + } + +/** + * Thumbnail server. + * + * @since S60 v5.0 + */ +NONSHARABLE_CLASS( CThumbnailServer ): public CPolicyServer, + public MMdESessionObserver, + public MTMShutdownObserver + { +public: + + /** + * Two-phased constructor + * + * @since S60 v5.0 + * @return New CThumbnailServer server. + */ + static CThumbnailServer* NewL(); + + /** + * Destructor + * + * @since S60 v5.0 + */ + virtual ~CThumbnailServer(); + +public: + + /** + * Creates new server session. + * + * @since S60 v5.0 + * @param aVersion Version info. + * @param aMessage Message to be passed. + * @return New session. + */ + CSession2* NewSessionL( const TVersion& aVersion, const RMessage2& aMessage + )const; + + /** + * ThreadFunctionL + * + * @since S60 v5.0 + */ + static void ThreadFunctionL(); + + /** + * AddSession + * + * @since S60 v5.0 + */ + void AddSession(); + + /** + * DropSession + * + * @since S60 v5.0 + */ + void DropSession(CThumbnailServerSession* aSession); + + // from MMdESessionObserver + void HandleSessionOpened( CMdESession& aSession, TInt aError ); + void HandleSessionError( CMdESession& aSession, TInt aError ); + + // from MTMShutdownObserver + void ShutdownNotification(); + + /** + * Adds bitmap to bitmap pool. Server assumes ownership of the bitmap and + * implements reference counting to know when it is safe to delete + * the object. Reference count is increased if the bitmap already + * exists in the pool. + * + * @since S60 v5.0 + * @param aSession Server side session which owns the bitmap. + * @param aBitmap Bitmap to be added to pool. + */ + void AddBitmapToPoolL( CThumbnailServerSession* aSession, CFbsBitmap* + aBitmap ); + + /** + * Store thumbnail. + * + * @since S60 v5.0 + * @param aPath Image path. + * @param aBitmap Thumbnail image. + * @param aOriginalSize Original size of image. + * @param aCropped Enabled if the thumbnail was cropped. + * @param aThumbnailSize Prededined size of requested thumbnail. + * @param aThumbFromPath Thumbnail created from associated path. + * @param aThumbFromPath Check first if source uri exists. + */ + void StoreThumbnailL( const TDesC& aPath, CFbsBitmap* aBitmap, const TSize& + aOriginalSize, const TBool aCropped, const TThumbnailSize aThumbnailSize, + const TThumbnailId aThumbnailId, const TBool aThumbFromPath = ETrue, + const TBool aCheckExist = ETrue); + + /** + * Fetch thumbnail image. + * + * @since S60 v5.0 + * @param aPath Path of the media object whose thumbnail is to be + * retrieved. + * @param aThumbnail Pointer to get the fetched thumbnail bitmap. + * Caller assumes ownership. + * @param aMinimumSize Minimum size of the thumbnail. + * @param aOriginalSize Original size of the object file in pixels + * @param aCropped If true, match cropped images only. + * @param aAllowUpscaling If enabled, allow fetching thumbnails that + * are smaller than requested. + * @param aThumbnailSize Prededined size of requested thumbnail. + */ + void FetchThumbnailL( const TDesC& aPath, CFbsBitmap* & aThumbnail, + TDesC8* & aData, const TThumbnailSize aThumbnailSize, TSize &aOriginalSize ); + + /** + * Fetch thumbnail image. + * + * @since S60 v5.0 + * @param aThumbnailId ID of the media object whose thumbnail is to be + * retrieved. + * @param aThumbnail Pointer to get the fetched thumbnail bitmap. + * Caller assumes ownership. + */ + void FetchThumbnailL( TThumbnailId aThumbnailId, CFbsBitmap* & + aThumbnail, TDesC8* & aData, TThumbnailSize aThumbnailSize, TSize &aOriginalSize ); + + /** + * Delete thumbnails. + * + * @since S60 v5.0 + * @param aPath Path of the media object whose thumbnail is + * to be deleted. + */ + void DeleteThumbnailsL( const TDesC& aPath ); + + /** + * Delete thumbnails by Id. + * + * @since S60 v5.0 + * @param aItemId Id of item whose thumbnails are to be deleted. + */ + void DeleteThumbnailsByIdL( TThumbnailId aItemId ); + + /** + * Resolve the MIME-type of given file using recognizer framework. + * + * @since S60 v5.0 + * @param aFile File to be recognized. + * @return MIME-type + */ + TDataType ResolveMimeTypeL( RFile& aFile ); + + /** + * Removes bitmap from bitmap pool. Reference count is decremented + * and if it reaches zero, the bitmap object is deleted. + * + * @since S60 v5.0 + * @param aHandle Bitmap handle. + */ + void DeleteBitmapFromPool( TInt aHandle ); + + /** + * Resolve plugin to be used in thumbnail creation by mime type. + * + * @since S60 v5.0 + * @param aMimeType Mime type of the file from which a thumbnail is to be + * created. + * @return Thumbnail provider. + */ + CThumbnailProvider* ResolveProviderL( const TDesC8& aMimeType ); + + /** + * Add thumbnailtask to processor queue. + * + * @since S60 v5.0 + * @param aTask Task to be added to queue. + */ + void QueueTaskL( CThumbnailTask* aTask ); + + /** + * Remove thumbnailtask from processor queue. + * + * @since S60 v5.0 + * @param aRequestId ID of the task to be removed from queue. + * @return Error code. + */ + TInt DequeTask( const TThumbnailServerRequestId& aRequestId ); + + /** + * Change priority of specific task. + * + * @since S60 v5.0 + * @param aRequestId ID of the task to be assigned new priority. + * @param aNewPriority New priority for the task. + * @return Error code. + */ + TInt ChangeTaskPriority( const TThumbnailServerRequestId& aRequestId, TInt + aNewPriority ); + + /** + * Scale bitmap + * + * @since S60 v5.0 + * @param aStatus Request status. + * @param aSource Source bitmap. + * @param aDest Destination bitmap. + * @param aSourceRect Source rectangle for cropping. + */ + void ScaleBitmapL( TRequestStatus& aStatus, const CFbsBitmap& aSource, + CFbsBitmap& aDest, const TRect& aSourceRect ); + + /** + * Cancel scaling operation + * + * @since S60 v5.0 + */ + void CancelScale(); + + /** + * Returns processor. + * + * @since S60 v5.0 + * @return Reference to processor instance. + */ + CThumbnailTaskProcessor& Processor(); + + /** + * Get persistent size. + * + * @since S60 v5.0 + * @param aThumbnailSize Relative thumbnail size + * @return Persistent size object + */ + TThumbnailPersistentSize & PersistentSizeL( TThumbnailSize + aThumbnailSize ); + + /** + * Persistent sizes. + * + * @since S60 v5.0 + * @return List of thumbnail sizes (including othe parameters) which + * are stored for later access. + */ + RArray < TThumbnailPersistentSize > PersistentSizesL(); + + /** + * Get missing thumbnail sizes. + * + * @since S60 v5.0 + * @param aPath Path associated to missing thumbnails + * @param aMissingSizes Returns a list of thumbnail sizes not yet create related to the path + */ + void GetMissingSizesAndIDsL( const TDesC& aPath, TInt aSourceType, RArray < + TThumbnailPersistentSize > & aMissingSizes, TBool& aMissingIDs); + + /** + * Fileserver + * + * @since S60 v5.0 + * @return File server + */ + RFs& Fs(); + + /** + * Get the required size (in characters) for a buffer that contains the + * list of supported MIME types + * + * @since S60 v5.0 + */ + TInt GetMimeTypeBufferSize()const; + + /** + * Get the list of supported MIME types and store them in the buffer. + * + * @since S60 v5.0 + * @param aBuffer A buffer to receive the space delimited list of MIME + * types. Must be as least as large as the size returned + * by GetMimeTypeBufferSizeL() + */ + void GetMimeTypeList( TDes& aBuffer )const; + + /** + * Close store instance for given drive. + * + * @since S60 v5.0 + * @param aDrive Drive for which the store is used, such as EDriveC, + * EDriveE, etc. + */ + void CloseStoreForDriveL( const TInt aDrive ); + + /** + * React to change in memory card status. + * + * @since S60 v5.0 + */ + void MemoryCardStatusChangedL(); + + /** + * Update thumbnails in database + * + * @since S60 v5.0 + * @param aItemId TThumbnailId + * @param aPath (New) path for the Thumbnail + * @param aOrientation Thumbnail orientation + * @param aModified Last modified + * @param TBool EFalse, if new thumbs need to be created + */ + TBool UpdateThumbnailsL( const TThumbnailId aItemId, const TDesC& aPath, + const TInt aOrientation, const TInt64 aModified ); + + /** + * Resolve mime type from file extension + * + * @since S60 v5.0 + * @param aFileName Image file + * @param aMimeType Mime type + * @return TInt KErrNone/KErrNotFound + */ + TInt MimeTypeFromFileExt( const TDesC& aFileName, TDataType& aMimeType ); + + /** + * Resolve source type from mime type + * + * @since S60 v5.0 + * @param aMimeType Mime type + * @return TInt TThumbnailPersistentSize enum + */ + TInt SourceTypeFromMimeType( const TDataType& aMimeType ); + + /** + * Resolve source type from size type + * + * @since S60 v5.0 + * @param aSizeType size type enum + * @return TInt TThumbnailPersistentSize enum + */ + TInt SourceTypeFromSizeType( const TInt aSizeType ); + + /** + * Is mime type supported + * + * @since S60 v5.0 + * @param aMimeType Mime type + * @return TBool supported + */ + TBool SupportedMimeType( const TDataType& aMimeType ); + + /** + * Get MDS session + * + * @since S60 v5.0 + * @return CMdESession + */ + CMdESession* GetMdESession(); + + /** + * Get store instance for given path. + * + * @since S60 v5.0 + * @param aPath Path to a file + * @return CThumbnailStore object + */ + CThumbnailStore* StoreForPathL( const TDesC& aPath ); + + /** + * Update ID in database + * + * @since S60 v5.0 + * @param aItemId Id of item whose thumbnails are to be updated. + * @param aNewPath Path property of the object to be updated. + */ + void UpdateIDL( const TDesC& aPath, const TThumbnailId aNewId ); + + /** + * Close Removable Stores + * + * @since S60 v5.0 + */ + + void CloseRemovableDrivesL(); + + /** + * Open Removable Stores + * + * @since S60 v5.o + */ + + void OpenRemovableDrivesL(); + + /** + * Checks if formatting is ongoing + * + * @since S60 v5.o + */ + + TBool IsFormatting(); + +protected: // Functions from base classes + + /** + * From CPolicyServer. + * Handles capability checking for certain server requests. + * @param aMsg Message which was received from the client side + * @param aAction + * @param aMissing + * @result return one of TCustomResult set {EPass, EFail, EAsync}. + */ + CPolicyServer::TCustomResult CustomSecurityCheckL( + const RMessage2 &aMsg, TInt &aAction, TSecurityInfo &aMissing ); + + /** + * From CPolicyServer. + * Handles failure + * @param aMsg Message which was received from the client side + * @param aAction + * @param aMissing + * @result return one of TCustomResult set {EPass, EFail, EAsync}. + */ + CPolicyServer::TCustomResult CustomFailureActionL( + const RMessage2 &aMsg, TInt aAction, const TSecurityInfo &aMissing ); + +private: + + /** + * Get a provider plug-in by the given UID + * + * @since S60 v5.0 + * @param aImplUid UID of the provider plug-in. + * @return Provider instance. + */ + CThumbnailProvider* GetProviderL( const TUid& aImplUid ); + + /** + * Get store instance for given drive. + * + * @since S60 v5.0 + * @param aDrive Drive for which the store is used, such as EDriveC, + * EDriveE, etc. + * @return CThumbnailStore object + */ + CThumbnailStore* StoreForDriveL( const TInt aDrive ); + + + /** + * Add unmount observer for each unmountable drive. + * + * @since S60 v5.0 + */ + void AddUnmountObserversL(); + + /** + * Open store for each mounted drive. + * + * @since S60 v5.0 + */ + void OpenStoresL(); + + + +private: + + /** + * C++ default constructor + * + * @since S60 v5.0 + * @return New CThumbnailServer instance. + */ + CThumbnailServer(); + + /** + * Symbian 2nd phase constructor can leave. + * + * @since S60 v5.0 + */ + void ConstructL(); + +private: + /** + * Reference counted pointer to a CFbsBitmap object used for the bitmap + * pool. + */ + struct TThumbnailBitmapRef + { +public: + /** + * CThumbnailServerSession can be used to identify which client + * session is responsible for calling ReleaseBitmap() for this + * bitmap. Not own. + */ + CThumbnailServerSession* iSession; + + /** + * Reference count for this bitmap. If reference count reaches zero, + * the bitmap is deleted by the server. + */ + TInt iRefCount; + + /** + * Bitmap object. Not owned directly by TThumbnailBitmapRef, but by + * the server. + * Not own. + */ + CFbsBitmap* iBitmap; + }; + +private: + // data + + TBool iShutdown; + CTMShutdownObserver* iShutdownObserver; + + /** + * Fileserver, own. + */ + RFs iFs; + + /** + * Sessioncount. + */ + TInt iSessionCount; + + /** + * FbsSession. + */ + RFbsSession iFbsSession; + + /** + * Bitmap pool. Reference counted pointers to CFbsBitmaps stored + * in a hash table with bitmap handle as the key. + * Own. + */ + RHashMap < TInt, TThumbnailBitmapRef > iBitmapPool; + + /** + * Processor for running tasks. + * Own. + */ + CThumbnailTaskProcessor* iProcessor; + + /** + * Central repository data handler + * Own. + */ + CThumbnailCenRep* iCenrep; + + /** + * Recognizer. + * Own. + */ + RApaLsSession iRecognizer; + + /** + * Result of recognition. + */ + TDataRecognitionResult iResult; + + /** + * Plug-in info. + */ + RImplInfoPtrArray iPluginInfoArray; + + /** + * Thumbnail providers. Stored in a hash table with the implementation + * UID as the key. + * Own. + */ + RHashMap < TInt32, CThumbnailProvider* > iProviders; + + /** + * Scaler. + * Own. + */ + MIHLScaler* iScaler; + + /** + * Array of unmount observers. + */ + RPointerArray iUnmountObservers; + + CThumbnailMemoryCardObserver* iMMCObserver; + + CThumbnailFormatObserver* iFormatObserver; + + /** + * Databases for each drive, identified by drive (EDriveC, etc). + * New databases and created on-the-fly as new requests are received. + * Databases are closed when drives are dismounted. + * Own. + */ + RHashMap < TInt, CThumbnailStore* > iStores; + + // own + CMdESession* iMdESession; + + TBuf iImei; + + /** + * Persistent sizes. + */ + RArray < TThumbnailPersistentSize > iPersistentSizes; + + TBool iFormatting; + +#ifdef _DEBUG + TUint32 iPlaceholderCounter; +#endif +}; + +#endif // THUMBNAILSERVER_H diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailserversession.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailserversession.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,301 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Server side session for thumbnail engine + * +*/ + + +#ifndef THUMBNAILSERVERSESSION_H +#define THUMBNAILSERVERSESSION_H + +#include +#include + +#include "thumbnailmanagerconstants.h" + +// FORWARD DECLARATIONS +class CThumbnailServer; + +/** + * Server side session for thumbnail engine. + * + * @since S60 v5.0 + */ +NONSHARABLE_CLASS( CThumbnailServerSession ): public CSession2 + { +public: + + /** + * Constructor. + * + * @since S60 v5.0 + * @return New CThumbnailServerSession session. + */ + CThumbnailServerSession(); + + /** + * Destructor + * + * @since S60 v5.0 + */ + virtual ~CThumbnailServerSession(); + +public: + + /** + * Message dispatcher. + * + * @since S60 v5.0 + * @param aMessage Message to be passed. + * @return Error code. + */ + TInt DispatchMessageL( const RMessage2& aMessage ); + +public: + // Functions from base classes + + /** + * CreateL + * + * @since S60 v5.0 + */ + void CreateL(); + + /** + * From CSharableSession (pure virtual). + * Handles service request messages from clients. + * + * @since S60 v5.0 + * @param aMessage message from client. + */ + void ServiceL( const RMessage2& aMessage ); + +public: + // New functions + + /** + * Returns the server pointer. + * + * @since S60 v5.0 + * @return Server pointer. + */ + CThumbnailServer* Server(); + + /** + * Cancellation method. + * + * @since S60 v5.0 + */ + void Cancel(); + + /** + * Converts SQL error to E32 error. + * + * @since S60 v5.0 + * @param aReason Request message complete value which may be SQL error + * @return Request message complete value but not SQL error + */ + static TInt ConvertSqlErrToE32Err( TInt aReason ); + + void ResolveMimeTypeL( RFile64* aFile ); + + void ModifyThumbnailSize( TInt aSourceType ); + +private: + + /** + * RequestThumbByFileHandleAsyncL + * + * @since S60 v5.0 + * @param aMessage Message. + */ + void RequestThumbByFileHandleAsyncL( const RMessage2& aMessage ); + + /** + * RequestThumbByPathAsyncL + * + * @since S60 v5.0 + * @param aMessage Message. + */ + void RequestThumbByPathAsyncL( const RMessage2& aMessage ); + + /** + * RequestThumbByIdAsyncL + * + * @since S60 v5.0 + * @param aMessage Message. + */ + void RequestThumbByIdAsyncL( const RMessage2& aMessage ); + + /** + * RequestSetThumbnailByBufferL + * + * @since S60 v5.0 + * @param aMessage Message. + */ + void RequestSetThumbnailByBufferL( const RMessage2& aMessage ); + + /** + * RequestSetThumbnailByBitmapL + * + * @since S60 v5.0 + * @param aMessage Message. + */ + void RequestSetThumbnailByBitmapL( const RMessage2& aMessage ); + + /** + * Fetch thumbnail data from database. + * + * @since S60 v5.0 + */ + void FetchThumbnailL(); + + /** + * Create a task to generate a new thumbnail + * + * @since S60 v5.0 + * @param aFile File handle + */ + void CreateGenerateTaskFromFileHandleL( RFile64* aFile); + + /** + * Create a task to generate a new thumbnail + * + * @since S60 v5.0 + * @param aBuffer Source image buffer to be set + */ + void CreateGenerateTaskFromBufferL( TDesC8* aBuffer ); + + /** + * Process a fetched bitmap by creating scale tasks + * or by returning the bitmap as such. + * + * @since S60 v5.0 + */ + void ProcessBitmapL(); + + /** + * ReleaseBitmap() + * + * @since S60 v5.0 + * @param aMessage Message. + */ + void ReleaseBitmap( const RMessage2& aMessage ); + + /** + * Cancels pending request. + * + * @since S60 v5.0 + * @param aMessage Message. + * @return Error code. + */ + TInt CancelRequest( const RMessage2& aMessage ); + + /** + * Changes priority of pending request. + * + * @since S60 v5.0 + * @param aMessage Message. + * @return Error code. + */ + TInt ChangePriority( const RMessage2& aMessage ); + + /** + * Create thumbnails. + * + * @since S60 v5.0 + * @param aMessage Message. + */ + void CreateThumbnailsL( const RMessage2& aMessage ); + + /** + * Delete thumbnails. + * + * @since S60 v5.0 + * @param aMessage Message. + */ + void DeleteThumbnailsL( const RMessage2& aMessage ); + + /** + * Delete thumbnails by Id. + * + * @since S60 v5.0 + * @param aMessage Message. + */ + void DeleteThumbnailsByIdL( const RMessage2& aMessage ); + + /** + * Get the required size (in characters) for a buffer that contains the + * list of supported MIME types + * + * @since S60 v5.0 + * @param aMessage Message. + */ + void GetMimeTypeBufferSizeL( const RMessage2& aMessage ); + + /** + * Get the list of supported MIME types and store them in the buffer + * allocated by the client. + * + * @since S60 v5.0 + * @param aMessage Message. + */ + void GetMimeTypeListL( const RMessage2& aMessage ); + + /** + * Update thumbnails by Thumbnail ID. + * + * + * @since S60 v5.0 + * @param aMessage Message. + */ + void UpdateThumbnailsL( const RMessage2& aMessage ); + +private: + // data + /** + * Temporary store for any bitmaps fetched from the store. + * Own. + */ + CFbsBitmap* iBitmap; + + /** + * Temporary store for thumbnail request parameters as received + * from the client. + */ + TThumbnailRequestParamsPckgBuf iRequestParams; + + /** + * Message from client. This is kept in a member variable to make + * sure the message is completed if a leave occurs while handling + * the request. + */ + RMessage2 iMessage; + + /** + * Size of the original object. Only valid if a stored thumbnail + * was found when processing a request. + */ + TSize iOriginalSize; + + /** + * Temporary store for any jpegs fetched from the store. + * Own. + */ + TDesC8* iBuffer; + + TInt iBitmapHandle; +}; + +#endif // THUMBNAILSERVERSESSION_H diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailsql.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailsql.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,256 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: SQL statements + * +*/ + + +#ifndef THUMBNAILSQL_H +#define THUMBNAILSQL_H + +//main table +_LIT8( KThumbnailCreateInfoTable, "CREATE TABLE ThumbnailInfo (" + // Assosiacted object in file system + "Path TEXT COLLATE NOCASE," + // Associated (MDS) Id + "TNId INTEGER," + // Combined (enumerated) size and classification + "Size INTEGER," + // Format of thumbnail (CFBsbitmap, JPeg...) + "Format INTEGER," + // If thumbnail is in the filesystem then this is NOT NULL and points to such file + "TNPath TEXT COLLATE NOCASE," + // Width of thumbnail + "Width INTEGER," + // Height of thumbnail + "Height INTEGER," + // Width of source + "OrigWidth INTEGER," + // Height of source + "OrigHeight INTEGER," + // Control flags, cropped etc. + "Flags INTEGER," + // Frame number of video TN when user defined + "VideoPosition INTEGER," + // Thumbnail orientation + "Orientation INTEGER," + // Set if thumbnail is actually created from the associated object path + "ThumbFromPath INTEGER," + // Last modified timestamp + "Modified LARGEINT);"); + +_LIT8( KThumbnailCreateInfoDataTable, "CREATE TABLE ThumbnailInfoData (" + // If Thumbnail is stored in SQL then Data is NOT NULL + "Data BLOB);"); + +//Create index for speedup DB searches +_LIT8( KThumbnailCreateInfoTableIndex1, "CREATE INDEX idx1 ON ThumbnailInfo(Path, Size);"); +_LIT8( KThumbnailCreateInfoTableIndex2, "CREATE INDEX idx2 ON ThumbnailInfo(TNId, Size);"); + +//temp table is identical to actual main table except it's not persistent +_LIT8( KThumbnailCreateTempInfoTable, "CREATE TEMP TABLE TempThumbnailInfo (" + "Path TEXT COLLATE NOCASE," + "TNId INTEGER," + "Size INTEGER," + "Format INTEGER," + "TNPath TEXT COLLATE NOCASE," + "Width INTEGER," + "Height INTEGER," + "OrigWidth INTEGER," + "OrigHeight INTEGER," + "Flags INTEGER," + "VideoPosition INTEGER," + "Orientation INTEGER," + "ThumbFromPath INTEGER," + "Modified LARGEINT);"); + +_LIT8( KThumbnailCreateTempInfoDataTable, "CREATE TEMP TABLE TempThumbnailInfoData (" + // If Thumbnail is stored in SQL then Data is NOT NULL + "Data BLOB);"); + +//version table +_LIT8( KThumbnailVersionTable, "CREATE TABLE ThumbnailVersion (" + "Major INTEGER," + "Minor INTEGER," + "IMEI TEXT COLLATE NOCASE);"); + +_LIT8( KThumbnailMoveFromTempInfoToMainTable, "INSERT INTO ThumbnailInfo SELECT * FROM TempThumbnailInfo;"); +_LIT8( KThumbnailMoveFromTempDataToMainTable, "INSERT INTO ThumbnailInfoData SELECT * FROM TempThumbnailInfoData;"); + +_LIT8( KThumbnailDeleteFromTempInfoTable, "DELETE FROM TempThumbnailInfo;"); +_LIT8( KThumbnailDeleteFromTempDataTable, "DELETE FROM TempThumbnailInfoData;"); + +_LIT8( KThumbnailCreateSettingsTable, "CREATE TABLE ThumbnailSettings (" + "Version INTEGER);" ); + +_LIT8( KThumbnailDropInfoTable, "DROP TABLE ThumbnailInfo;" ); +_LIT8( KThumbnailDropTempInfoTable, "DROP TABLE TempThumbnailInfo;" ); + +_LIT8( KThumbnailDropSettingsTable, "DROP TABLE ThumbnailSettings;" ); + +_LIT8( KThumbnailBeginTransaction, "BEGIN TRANSACTION;" ); +_LIT8( KThumbnailCommitTransaction, "COMMIT;" ); +_LIT8( KThumbnailRollbackTransaction, "ROLLBACK;" ); + +_LIT8( KThumbnailInsertThumbnailInfoByPathAndId, "INSERT INTO TempThumbnailInfo " + "(Path,TNId,Size,Format,Width,Height,OrigWidth,OrigHeight,Flags,Orientation,ThumbFromPath,Modified) ""VALUES " + "(:Path,:TNId,:Size,:Format,:Width,:Height,:OrigWidth,:OrigHeight,:Flags,:Orient,:ThumbFromPath,:Modified);" ); + +_LIT8( KThumbnailInsertTempThumbnailInfoData, "INSERT INTO TempThumbnailInfoData (Data) VALUES (:Data);" ); + +_LIT8( KThumbnailSelectSizeByPath, "SELECT Size, TNId FROM ThumbnailInfo WHERE Path = :Path ORDER BY Size DESC;" ); + +_LIT8( KThumbnailSelectTempSizeByPath, "SELECT Size, TNId FROM TempThumbnailInfo WHERE Path = :Path ORDER BY Size DESC;" ); + +_LIT8( KThumbnailSelectById, "SELECT * " + "FROM ThumbnailInfo " + "JOIN ThumbnailInfoData " + "ON ThumbnailInfo.RowID = ThumbnailInfoData.RowID " + "WHERE TNId = :TNId" ); + +_LIT8( KThumbnailSelectTempById, "SELECT * " + "FROM TempThumbnailInfo " + "JOIN TempThumbnailInfoData " + "ON TempThumbnailInfo.RowID = TempThumbnailInfoData.RowID " + "WHERE TNId = :TNId" ); + +//query by Path +_LIT8( KThumbnailSelectInfoByPath, "SELECT ThumbnailInfo.Format, ThumbnailInfoData.Data, ThumbnailInfo.Width, ThumbnailInfo.Height, ThumbnailInfo.Flags " + "FROM ThumbnailInfo " + "JOIN ThumbnailInfoData " + "ON ThumbnailInfo.RowID = ThumbnailInfoData.RowID " + "WHERE ThumbnailInfo.Path = :Path AND ThumbnailInfo.Size = :Size;"); + +_LIT8( KThumbnailSelectTempInfoByPath, "SELECT TempThumbnailInfo.Format, TempThumbnailInfoData.Data, TempThumbnailInfo.Width, TempThumbnailInfo.Height, TempThumbnailInfo.Flags " + "FROM TempThumbnailInfo " + "JOIN TempThumbnailInfoData " + "ON TempThumbnailInfo.RowID = TempThumbnailInfoData.RowID " + "WHERE TempThumbnailInfo.Path = :Path AND TempThumbnailInfo.Size = :Size;"); + +//query by Id +_LIT8( KThumbnailSelectInfoById, "SELECT ThumbnailInfo.Format, ThumbnailInfoData.Data, ThumbnailInfo.Width, ThumbnailInfo.Height, ThumbnailInfo.Flags " + "FROM ThumbnailInfo " + "JOIN ThumbnailInfoData " + "ON ThumbnailInfo.RowID = ThumbnailInfoData.RowID " + "WHERE TNId = :TNId AND Size = :Size;" ); + +_LIT8( KThumbnailSelectTempInfoById, "SELECT TempThumbnailInfo.Format, TempThumbnailInfoData.Data, TempThumbnailInfo.Width, TempThumbnailInfo.Height, TempThumbnailInfo.Flags " + "FROM TempThumbnailInfo " + "JOIN TempThumbnailInfoData " + "ON TempThumbnailInfo.RowID = TempThumbnailInfoData.RowID " + "WHERE TNId = :TNId AND Size = :Size;" ); + +//query by Idv2 +_LIT8( KThumbnailSelectInfoByIdv2, "SELECT ThumbnailInfo.Format, ThumbnailInfoData.Data, ThumbnailInfo.Width, ThumbnailInfo.Height, ThumbnailInfo.Flags " + "FROM ThumbnailInfo " + "JOIN ThumbnailInfoData " + "ON ThumbnailInfo.RowID = ThumbnailInfoData.RowID " + "WHERE TNId = :TNId AND (Size = :SizeImage OR Size = :SizeVideo OR Size = :SizeAudio);" ); + +_LIT8( KThumbnailSelectTempInfoByIdv2, "SELECT TempThumbnailInfo.Format, TempThumbnailInfoData.Data, TempThumbnailInfo.Width, TempThumbnailInfo.Height, TempThumbnailInfo.Flags " + "FROM TempThumbnailInfo " + "JOIN TempThumbnailInfoData " + "ON TempThumbnailInfo.RowID = TempThumbnailInfoData.RowID " + "WHERE TNId = :TNId AND (Size = :SizeImage OR Size = :SizeVideo OR Size = :SizeAudio);" ); + +_LIT8( KThumbnailSelectSettings, "SELECT Version FROM ThumbnailSettings;" ); + +//qyery Path by ID +_LIT8( KThumbnailSelectPathByID, "SELECT Path FROM ThumbnailInfo WHERE TNId = :TNId;" ); +_LIT8( KThumbnailSelectTempPathByID, "SELECT Path FROM TempThumbnailInfo WHERE TNId = :TNId;"); + +//query Path and Modified by ID +_LIT8( KThumbnailSelectPathModifiedByID, "SELECT Path, Modified FROM ThumbnailInfo WHERE TNId = :TNId;" ); +_LIT8( KThumbnailSelectTempPathModifiedByID, "SELECT Path, Modified FROM TempThumbnailInfo WHERE TNId = :TNId;"); + +_LIT( KThumbnailSqlParamData, ":Data" ); +_LIT( KThumbnailSqlParamFlags, ":Flags" ); +_LIT( KThumbnailSqlParamPath, ":Path" ); +_LIT( KThumbnailSqlParamWidth, ":Width" ); +_LIT( KThumbnailSqlParamHeight, ":Height" ); +_LIT( KThumbnailSqlParamOriginalWidth, ":OrigWidth" ); +_LIT( KThumbnailSqlParamOriginalHeight, ":OrigHeight" ); +_LIT( KThumbnailSqlParamFormat, ":Format" ); +_LIT( KThumbnailSqlParamId, ":TNId" ); +_LIT( KThumbnailSqlParamSize, ":Size" ); +_LIT( KThumbnailSqlParamTNPath, ":TNPath" ); +_LIT( KThumbnailSqlParamMajor, ":Major" ); +_LIT( KThumbnailSqlParamMinor, ":Minor" ); +_LIT( KThumbnailSqlParamImei, ":IMEI" ); +_LIT( KThumbnailSqlParamSizeImage, ":SizeImage" ); +_LIT( KThumbnailSqlParamSizeVideo, ":SizeVideo" ); +_LIT( KThumbnailSqlParamSizeAudio, ":SizeAudio" ); +_LIT( KThumbnailSqlParamRowID, ":RowID" ); +_LIT( KThumbnailSqlParamOrientation, ":Orient" ); +_LIT( KThumbnailSqlParamThumbFromPath, ":ThumbFromPath" ); +_LIT( KThumbnailSqlParamModified, ":Modified" ); +_LIT( KThumbnailSqlParamFlag, ":Flag" ); + +//Delete by path +_LIT8( KThumbnailSqlSelectRowIDInfoByPath, "SELECT ThumbnailInfo.RowID FROM ThumbnailInfo WHERE Path = :Path;" ); +_LIT8( KThumbnailSqlDeleteInfoByPath, "DELETE FROM ThumbnailInfo WHERE ThumbnailInfo.RowID = :RowID;" ); +_LIT8( KThumbnailSqlDeleteInfoDataByPath, "DELETE FROM ThumbnailInfoData WHERE ThumbnailInfoData.RowID = :RowID;" ); +_LIT8( KTempThumbnailSqlSelectRowIDInfoByPath, "SELECT TempThumbnailInfo.RowID FROM TempThumbnailInfo WHERE Path = :Path LIMIT 1;" ); +_LIT8( KTempThumbnailSqlDeleteInfoByPath, "DELETE FROM TempThumbnailInfo WHERE TempThumbnailInfo.RowID = :RowID;" ); +_LIT8( KTempThumbnailSqlDeleteInfoDataByPath, "DELETE FROM TempThumbnailInfoData WHERE TempThumbnailInfoData.RowID = :RowID;" ); + + +//Delete by ID +_LIT8( KThumbnailSqlSelectRowIDInfoByID, "SELECT ThumbnailInfo.RowID FROM ThumbnailInfo WHERE TNId = :TNId;" ); +_LIT8( KThumbnailSqlDeleteInfoByID, "DELETE FROM ThumbnailInfo WHERE ThumbnailInfo.RowID = :RowID;" ); +_LIT8( KThumbnailSqlDeleteInfoDataByID, "DELETE FROM ThumbnailInfoData WHERE ThumbnailInfoData.RowID = :RowID;" ); +_LIT8( KTempThumbnailSqlSelectRowIDInfoByID, "SELECT TempThumbnailInfo.RowID FROM TempThumbnailInfo WHERE TNId = :TNId LIMIT 1;" ); +_LIT8( KTempThumbnailSqlDeleteInfoByID, "DELETE FROM TempThumbnailInfo WHERE TempThumbnailInfo.RowID = :RowID;" ); +_LIT8( KTempThumbnailSqlDeleteInfoDataByID, "DELETE FROM TempThumbnailInfoData WHERE TempThumbnailInfoData.RowID = :RowID;" ); + + +//Update path by Id +_LIT8( KTempThumbnailSqlUpdateById, "UPDATE TempThumbnailInfo SET Path = :Path WHERE TNId = :TNId" ); +_LIT8( KThumbnailSqlUpdateById, "UPDATE ThumbnailInfo SET Path = :Path WHERE TNId = :TNId" ); + +//version commands +_LIT8( KThumbnailInsertToVersion, "INSERT INTO ThumbnailVersion (IMEI, Minor, Major) VALUES (:IMEI, :Minor,:Major);" ); +_LIT8( KThumbnailSelectFromVersion, "SELECT * FROM ThumbnailVersion LIMIT 1" ); + +//reset IDs +_LIT8( KTempThumbnailResetIDs, "UPDATE TempThumbnailInfo SET TNId = NULL WHERE TNId NOT NULL" ); +_LIT8( KThumbnailResetIDs, "UPDATE ThumbnailInfo SET TNId = NULL WHERE TNId NOT NULL" ); + +//update IMEI +_LIT8( KThumbnailUpdateIMEI, "UPDATE ThumbnailVersion SET IMEI = :IMEI" ); + +//update ID by Path +_LIT8( KTempThumbnailUpdateIdByPath, "UPDATE TempThumbnailInfo SET TNId = :TNId WHERE Path = :Path" ); +_LIT8( KThumbnailUpdateIdByPath, "UPDATE ThumbnailInfo SET TNId = :TNId WHERE Path = :Path" ); + +//qyery Modification timestamp by ID +_LIT8( KThumbnailSelectModifiedByID, "SELECT Modified FROM ThumbnailInfo WHERE TNId = :TNId AND ThumbFromPath = 1 LIMIT 1" ); +_LIT8( KThumbnailSelectTempModifiedByID, "SELECT Modified FROM TempThumbnailInfo WHERE TNId = :TNId AND ThumbFromPath = 1 LIMIT 1"); + +//query Modification timestamp by path +_LIT8( KThumbnailSelectModifiedByPath, "SELECT Modified FROM ThumbnailInfo WHERE Path = :Path" ); +_LIT8( KThumbnailSelectTempModifiedByPath, "SELECT Modified FROM TempThumbnailInfo WHERE Path = :Path"); + +// query possible duplicates +_LIT8 ( KTempFindDuplicate, "SELECT Path FROM TempThumbnailInfo WHERE Size = :Size AND (TNId = :TNId OR Path = :Path);" ); +_LIT8 ( KFindDuplicate, "SELECT Path FROM ThumbnailInfo WHERE Size = :Size AND (TNId = :TNId OR Path = :Path);" ); + +// check rowIDs +_LIT8 ( KGetInfoRowID, "SELECT MAX (ThumbnailInfo.rowID) FROM ThumbnailInfo" ); +_LIT8 ( KGetDataRowID, "SELECT MAX (ThumbnailInfoData.rowID) FROM ThumbnailInfoData" ); + +//remove KThumbnailDbFlagBlacklisted flag +_LIT8( KThumbnailRemoveBlacklistedFlag, "UPDATE ThumbnailInfo SET Flags = Flags & ~:Flag WHERE Flags & :Flag" ); + +#endif // THUMBNAILSQL_H diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailstore.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailstore.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,477 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Store for thumbnails. + * +*/ + + +#ifndef THUMBNAILSTORE_H +#define THUMBNAILSTORE_H + +#include +#include "thumbnailcenrep.h" +#include "thumbnailmanagerconstants.h" +#include "thumbnaillog.h" +#include "thumbnailserver.h" + +class RFs; +class CFbsBitmap; +class CThumbnailServer; + +/** + * Database transaction + * + * @since S60 v5.0 + */ +class RThumbnailTransaction + { + enum TState + { + EOpen, EError, EClosed + }; +public: + RThumbnailTransaction( RSqlDatabase& aDatabase ); + + void BeginL(); + void Close(); + void CommitL(); + TInt Rollback(); + +private: + RSqlDatabase& iDatabase; + TState iState; +}; + + +/** + * Store for thumbnails. + * + * @since S60 v5.0 + */ +class CThumbnailStore: public CBase + { + // Bitmasked Flags + typedef enum + { + KThumbnailDbFlagCropped = 1, + KThumbnailDbFlagBlacklisted = 2, + KThumbnailDbFlagDeleted = 4 + }TThumbnailDbFlags; + +public: + + /** + * Two-phased constructor. + * + * @since S60 v5.0 + * @param aFs File server. + * @param aDrive Drive the store used for + * @param aCenter Pointer to cenrep data handler + * @return New CThumbnailStore instance. + */ + static CThumbnailStore* NewL( RFs& aFs, TInt aDrive, TDesC& aImei, CThumbnailServer* aServer ); + + /** + * Destructor + * + * @since S60 v5.0 + */ + virtual ~CThumbnailStore(); + + /** + * Stores thumbnail image. + * + * @since S60 v5.0 + * @param aPath Path of the image from which thumbnail was created. + * @param aThumbnail Thumbnail bitmap. + * @param aOriginalSize Original size of image. + * @param aCropped Enabled if image is cropped. + * @param aThumbnailSize Prededined size of requested thumbnail. + * @param aThumbFromPath Thumbnail created from associated path. + */ + void StoreThumbnailL( const TDesC& aPath, CFbsBitmap* aThumbnail, const + TSize& aOriginalSize, TBool aCropped, const TThumbnailSize aThumbnailSize, + const TThumbnailId aThumbnailId = 0, const TBool aThumbFromPath = ETrue, + TBool aBlackListed = EFalse ); + + /** + * Fetches thumbnail image. + * + * @since S60 v5.0 + * @param aPath Path of the media object whose thumbnail is + * to be retrieved. + * @param aThumbnail Pointer to get the fetched thumbnail bitmap. + * Caller assumes ownership. + * @param aData Pointer to get the fetched thumbnail JPEG. + * Caller assumes ownership. + + * @param aAllowUpscaling If enabled, allow fetching thumbnails that + * are smaller than requested. + * @param aThumbnailSize Prededined size of requested thumbnail. + * + * @param aThumbnailSize Reference to real size of TN. + */ + void FetchThumbnailL( const TDesC& aPath, + CFbsBitmap* & aThumbnail, + TDesC8* & aData, + const TThumbnailSize aThumbnailSize, + TSize &aThumbnailRealSize + ); + + /** + * Fetches thumbnail image. + * + * @since S60 v5.0 + * @param aThumbnailId Path of the media object whose thumbnail is + * to be retrieved. + * @param aThumbnail Pointer to get the fetched thumbnail bitmap. + * Caller assumes ownership. + * @param aData Pointer to get the fetched thumbnail JPEG. + * Caller assumes ownership. + * @param aThumbnailSize Minimum size of the thumbnail + * . + * @param aThumbnailSize Reference to real size of TN. + * + * @return KErrNone, otherwise KErrNotFound if thumbnail not found from DB + */ + TInt FetchThumbnailL( TThumbnailId aThumbnailId, + CFbsBitmap*& aThumbnail, + TDesC8* & aData, + TThumbnailSize aThumbnailSize, + TSize &aThumbnailRealSize + ); + + + /** + * Delete thumbnails. + * + * @since S60 v5.0 + * @param aPath Path of the media object whose thumbnail is + * to be deleted. + */ + void DeleteThumbnailsL( const TDesC& aPath ); + + /** + * Delete thumbnails. + * + * @since S60 TB9.1 + * @param aTNId Id of the media object whose thumbnail is + * to be deleted. + */ + void DeleteThumbnailsL( const TThumbnailId& aTNId ); + + /** + * Persistent sizes. + * + * @since S60 v5.0 + * @return List of thumbnail sizes (including othe parameters) which + * are stored for later access. + */ + void SetPersistentSizes(const RArray < TThumbnailPersistentSize > &aSizes); + + /** + * Get persistent sizes not yet in database + * + * @since S60 v5.0 + * @param aPath Path where missing sizes are associated + * @param aMissingSizes List of missing thumbnail sizes + */ + void GetMissingSizesAndIDsL( const TDesC& aPath, TInt aSourceType, RArray < + TThumbnailPersistentSize > & aMissingSizes, TBool& aMissingIDs ); + + /** + * Get persistent sizes not yet in database + * + * @since S60 TB9.1 + * @param aId Id of TN where missing sizes are associated + * @param aMissingSizes List of missing thumbnail sizes + */ + void GetMissingSizesL( const TThumbnailId aId, RArray < + TThumbnailPersistentSize > & aMissingSizes ); + + /** + * Find store for thumbnails. + * + * @since S60 TB9.1 + * @param aThumbnailId Id of thumbnails to be updated. + */ + void FindStoreL(TThumbnailId aThumbnailId); + + /** + * Updates path for thumbnails in current store. + * + * @since S60 v5.0 + * @param aItemId Id for thumbnails to be updated. + * @param aNewPath New path for thumbnails. + * @return ETrue, if path was updated + */ + TBool UpdateStoreL( TThumbnailId aItemId, const TDesC& aNewPath ); + + /** + * Updates path for thumbnails in current store. + * + * @since S60 v5.0 + * @param aItemId Id for thumbnails to be updated. + * @param aNewPath New path for thumbnails. + */ + void UpdateStoreL( const TDesC& aPath, TThumbnailId aNewId ); + + /** + * Check modification timestamp + * + * @since S60 v5.0 + * @param aItemId Id for thumbnails to be updated. + * @param aModified new MDS timestamp + * @return ETrue, if given timestamp was newer than in DB + */ + TBool CheckModifiedL( const TThumbnailId aItemId, const TInt64 aModified ); + + /** + * Fetches thumbnails from store to be moved. + * + * @since S60 v5.0 + * @param aItemId Id for thumbnails to be updated. + * @param aThumbnails Array for thumbnails to be moved. + */ + void FetchThumbnailsL(TThumbnailId aItemId, RArray < TThumbnailDatabaseData* >& aThumbnails); + + /** + * Stores thumbnails in to new store. + * + * @since S60 v5.0 + * @param aNewPath New path for thumbnails. + * @param aThumbnails Array for thumbnails to be moved. + */ + void StoreThumbnailsL(const TDesC& aNewPath, RArray < TThumbnailDatabaseData* >& aThumbnails); + + /** + * Stores thumbnails in to new store. + * + * @since S60 v5.0 + * @param aNewPath New path for thumbnails. + * @param aThumbnails Array for thumbnails to be moved. + */ + TInt CheckImeiL(); + + /** + * Stores thumbnails in to new store. + * + * @since S60 v5.0 + * @param aNewPath New path for thumbnails. + * @param aThumbnails Array for thumbnails to be moved. + */ + TInt CheckVersionL(); + + /** + * Stores thumbnails in to new store. + * + * @since S60 v5.0 + * @param aNewPath New path for thumbnails. + * @param aThumbnails Array for thumbnails to be moved. + */ + TInt CheckMediaIDL(); + + /** + * Stores thumbnails in to new store. + * + * @since S60 v5.0 + * @param aNewPath New path for thumbnails. + * @param aThumbnails Array for thumbnails to be moved. + */ + void AddVersionAndImeiL(); + + /** + * Stores thumbnails in to new store. + * + * @since S60 v5.0 + * @param aNewPath New path for thumbnails. + * @param aThumbnails Array for thumbnails to be moved. + */ + void ResetThumbnailIDs(); + + /** + * Stores thumbnails in to new store. + * + * @since S60 v5.0 + * @param aNewPath New path for thumbnails. + * @param aThumbnails Array for thumbnails to be moved. + */ + void UpdateImeiL(); + + /** + * Checks that database rowids match. + * + * @since S60 v5.0 + */ + + TInt CheckRowIDsL(); + +private: + /** + * C++ default constructor + * + * @since S60 v5.0 + * @param aFs File server. + * @param aDrive Drive the store used for + * @return New CThumbnailStore instance. + */ + CThumbnailStore( RFs& aFs, TInt aDrive, TDesC& aImei, CThumbnailServer* aServer); + + /** + * Symbian 2nd phase constructor can leave. + * + * @since S60 v5.0 + */ + void ConstructL(); + + /** + * Create database tables. + * + * @since S60 v5.0 + */ + void CreateTablesL(); + + /** + * Stores thumbnail image. + * + * @since S60 v5.0 + * @param aPath Path of the image from which thumbnail was created. + * @param aData Data. + * @param aSize Size of thumbnail. + * @param aOriginalSize Original size of image. + * @param aFormat Format of the image. + * @param aFlags Flags. + * @param aThumbnailSize Associated size of the thumbnail to be deleted + * @param aThumbFromPath Thumbnail created from associated path. + */ + void StoreThumbnailL( const TDesC& aPath, const TDes8& aData, const TSize& + aSize, const TSize& aOriginalSize, const TThumbnailFormat& aFormat, TInt aFlags, + const TThumbnailSize& aThumbnailSize, const TThumbnailId aThumbnailId = 0, + const TBool aThumbFromPath = ETrue); + + /** + * Finds possible existing duplicate thumbnail. + * + * @since S60 v5.0 + * @param aPath Path of the image from which thumbnail was created. + * @param aThumbnailId ID of the thumbnail + * @param aThumbnailSize Associated size of the thumbnail to be deleted + */ + TBool FindDuplicateL( const TDesC& aPath, const TThumbnailId aThumbnailId, + const TThumbnailSize& aThumbnailSize ); + + /** + * Flush RAM cache containing generated TNs to persistent storage. + * + * @since S60 TB9.1 + * @param aForce which forces logic to flush cache table. + */ + void FlushCacheTable( TBool aForce = EFalse ); + + /** + * Start db auto flush timer + * + * @since S60 TB9.1 + */ + void StartAutoFlush(); + + /** + * Stop db auto flush timer + * + * @since S60 TB9.1 + */ + void StopAutoFlush(); + + /** + * Callback for harvesting complete timer + * + * @since S60 v5.0 + */ + static TInt AutoFlushTimerCallBack(TAny* aAny); + + /** + * Checks timestamp of blacklisted entry to timestamp of file, from + * which thumbnail entry was created, in filesystem + * + * @param aPath Path from which thumbnail created + * @param aTempTable Indication whether data in temp table + * @param aModified On return contains indication whether file modified + */ + void CheckModifiedByPathL( const TDesC& aPath, TBool aTempTable, TBool& aModified ); + + /** + * Checks timestamp of blacklisted entry to timestamp of file, from + * which thumbnail entry was created, in filesystem + * + * @param aId Thumbnail id + * @param aTempTable Indication whether data in temp table + * @param aModified On return contains indication whether file modified + */ + void CheckModifiedByIdL( TUint32 aId, TBool aTempTable, TBool& aModified ); + + /** + * Removes blacklisted flag from all entrys + * + */ + void RemoveDbFlagL(TThumbnailDbFlags aFlag); + +private: + // data + + /** + * Fileserver. + */ + RFs& iFs; + + /** + * Drive number + */ + TInt iDrive; + + /** + * Thumbnail database. + */ + RSqlDatabase iDatabase; + + /** + * Persistent sizes. + */ + RArray < TThumbnailPersistentSize > iPersistentSizes; + + /** + * Count of cached TNs not yet committed to db + */ + TInt iBatchItemCount; + + /** + * Phones IMEI code + */ + TDesC& iImei; + + /** + * ThumbnailServer + */ + + CThumbnailServer* iServer; + +#ifdef _DEBUG + TUint32 iThumbCounter; +#endif + /** + * Periodic timer handling automatic flushing of db cache + */ + CPeriodic* iAutoFlushTimer; +}; + +#endif // THUMBNAILSTORE_H diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailtask.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailtask.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,210 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Base class for thumbnail server tasks + * +*/ + + +#ifndef THUMBNAILTASK_H +#define THUMBNAILTASK_H + +#include "thumbnailmanager.h" // TThumbnailRequestId +#include "thumbnailmanagerconstants.h" // TThumbnailServerRequestId + + +class CThumbnailTaskProcessor; +class CThumbnailServerSession; + +/** + * Base class for thumbnail server tasks. + * + * @since S60 v5.0 + */ +class CThumbnailTask: public CActive + { +public: + /** + * Task state. + * @since S60 v5.0 + */ + enum TTaskState + { + /** + * This task is waiting to be run. + */ + EIdle, + + /** + * This task is currently running. + */ + ERunning, + + /** + * This task has completed and can be destroyed. + */ + EComplete + }; + +public: + + /** + * C++ default constructor + * + * @since S60 v5.0 + * @param aProcessor Processor object for running tasks. + * @param aPriority Priority of the task. + * @return New CThumbnailTask instance. + */ + CThumbnailTask( CThumbnailTaskProcessor& aProcessor, TInt aPriority ); + + /** + * Destructor + * + * @since S60 v5.0 + */ + virtual ~CThumbnailTask(); + +public: + + /** + * Returns priority of task. + * + * @since S60 v5.0 + * @return Priority of the task. + */ + TInt Priority()const; + + /** + * Returns state of task. + * + * @since S60 v5.0 + * @return State. + */ + TTaskState State()const; + + /** + * SetMessageData + * + * @since S60 v5.0 + * @param aRequestId Request ID. + * @param aMessage Message. + */ + virtual void SetMessageData( const TThumbnailServerRequestId& aRequestId, + const RMessage2& aMessage ); + + /** + * SetMessageData if message is not needed to complete + * + * @since S60 v5.0 + * @param aRequestId Request ID. + */ + virtual void SetMessageData( const TThumbnailServerRequestId& aRequestId ); + + /** + * Resets message data. + * + * @since S60 v5.0 + */ + virtual void ResetMessageData(); + + /** + * Cancels message. + * + * @since S60 v5.0 + */ + virtual void CancelMessage(); + + /** + * Returns ID of specific task. + * + * @since S60 v5.0 + * @return Request ID. + */ + virtual TThumbnailServerRequestId RequestId()const; + + /** + * Changes priority of the task. + * + * @since S60 v5.0 + * @param aNewPriority New priority. + */ + virtual void ChangeTaskPriority( TInt aNewPriority ); + + /** + * StartL + * + * @since S60 v5.0 + */ + virtual void StartL(); + + /** + * Implements cancellation of an outstanding request. + * + * @since S60 v5.0 + */ + virtual void DoCancel(); + + /** + * StartError + * + * @since S60 v5.0 + * @param aError Error code. + */ + virtual void StartError( TInt aError ); + + /** + * Complete + * + * @since S60 v5.0 + * @param aReason Status code. + */ + virtual void Complete( TInt aReason ); + + /** + * Continue without deleting task + * + * @since S60 v5.0 + */ + virtual void Continue(); + +protected: + // data + + /** + * Processor. + */ + CThumbnailTaskProcessor& iProcessor; + + /** + * Priority of the task. + */ + TInt iPriority; + + /** + * State of the task. + */ + TTaskState iState; + + /** + * Id of the request. + */ + TThumbnailServerRequestId iRequestId; + + /** + * Message. + */ + RMessage2 iMessage; +}; + +#endif // THUMBNAILTASK_H diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailtaskprocessor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailtaskprocessor.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,186 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Processor object for running queued tasks + * +*/ + + +#ifndef THUMBNAILTASKPROCESSOR_H +#define THUMBNAILTASKPROCESSOR_H + +#include "thumbnailmanager.h" // TThumbnailFlags +#include "thumbnailmanagerconstants.h" // TThumbnailServerRequestId +#include "thumbnailprovider.h" +#include + + +class CThumbnailTask; + +/** + * Processor object for running queued tasks. + * + * @since S60 v5.0 + */ +class CThumbnailTaskProcessor: public CActive + { +public: + + /** + * Two-phased constructor. + * + * @since S60 v5.0 + * @return Instance of CThumbnailTaskProcessor. + */ + static CThumbnailTaskProcessor* NewL(); + + /** + * Destructor + * + * @since S60 v5.0 + */ + virtual ~CThumbnailTaskProcessor(); + + /** + * Adds new task to the task queue. + * + * @since S60 v5.0 + * @param aTask Task to be added to the queue. + */ + void AddTaskL( CThumbnailTask* aTask ); + + /** + * Removes specific task from the queue. + * + * @since S60 v5.0 + * @param aRequestId ID of the task to be removed. + */ + TInt RemoveTask( const TThumbnailServerRequestId& aRequestId ); + + /** + * Removes specific task from the queue. + * + * @since S60 v5.0 + * @param aSession Identifier for task to be removed. + */ + void RemoveTasks( CThumbnailServerSession* aSession ); + + /** + * Removes all tasks from the queue. + * + * @since S60 v5.0 + */ + + void RemoveAllTasks(); + + /** + * Changes priority of a task. + * + * @since S60 v5.0 + * @param aRequestId ID of the task. + * @param aNewPriority New priority to be assigned to the task. + */ + TInt ChangeTaskPriority( const TThumbnailServerRequestId& aRequestId, const + TInt aNewPriority ); + + /** + * Marks task to completed. + * + * @since S60 v5.0 + * @param aTask Completed task. + */ + void TaskComplete( CThumbnailTask* aTask ); + + void SetDaemonAsProcess(TBool aValue); + +protected: + // from base class CActive + + /** + * Handles an active object's request completion event. + * + * @since S60 v5.0 + */ + void RunL(); + + /** + * Implements cancellation of an outstanding request. + * + * @since S60 v5.0 + */ + void DoCancel(); + + /** + * Handles a leave occurring in the request completion event handler + * RunL(). + * + * @since S60 v5.0 + * @return Error code. + */ + TInt RunError( TInt aError ); + +private: + + /** + * C++ default constructor + * + * @since S60 v5.0 + * @return Instance of CThumbnailTaskProcessor. + */ + CThumbnailTaskProcessor(); + + /** + * Symbian 2nd phase constructor can leave. + * + * @since S60 v5.0 + */ + void ConstructL(); + + /** + * Callback for harvesting complete timer + * + * @since S60 v5.0 + */ + static TInt PeriodicTimerCallBack(TAny* aAny); + +private: + // data + + /** + * Task queue. Task objects are own by this class. + * Own. + */ + RPointerArray < CThumbnailTask > iTasks; + + /** + * Current active task. Not own. + */ + CThumbnailTask* iActiveTask; + + /** + * PS used to notify Daemon when server is idle + */ + RProperty iProperty; + /** + * Holds current idle value + */ + TBool iIdle; + + CPeriodic* iPeriodicTimer; + + TBool iTimerActive; + + TBool iIsDaemonAsProcess; +}; + +#endif // THUMBNAILTASKPROCESSOR_H diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/tmshutdownobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/tmshutdownobserver.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,108 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: TM Shutdown Observer + * +*/ + + +#ifndef TMSHUTDOWNOBSERVER_H +#define TMSHUTDOWNOBSERVER_H + +#include +#include +#include + + +/** + * Observer interface for signaling the need for shutdown + */ +class MTMShutdownObserver + { +public: + + virtual void ShutdownNotification() = 0; + }; + +/** + * Active object for observing P&S keys + * + * @since S60 v5.0 + */ +class CTMShutdownObserver: public CActive + { +public: + + /** + * Two-phased constructor. + * + * @since S60 v5.0 + * @return Instance of CTMShutdownObserver. + */ + static CTMShutdownObserver* NewL( MTMShutdownObserver& aObserver, const TUid& aKeyCategory, + const TInt aPropertyKey, TBool aDefineKey); + + /** + * Destructor + * + * @since S60 v5.0 + */ + virtual ~CTMShutdownObserver(); + +protected: + + /** + * Handles an active object's request completion event. + * + * @since S60 v5.0 + */ + void RunL(); + + /** + * Implements cancellation of an outstanding request. + * + * @since S60 v5.0 + */ + void DoCancel(); + +private: + + /** + * C++ default constructor + * + * @since S60 v5.0 + * @return Instance of CTMShutdownObserver. + */ + CTMShutdownObserver( MTMShutdownObserver& aObserver, const TUid& aKeyCategory, + const TInt iPropertyKey, TBool aDefineKey); + + /** + * Symbian 2nd phase constructor can leave. + * + * @since S60 v5.0 + */ + void ConstructL(); + +private: + + // not own + MTMShutdownObserver& iObserver; + + const TUid& iKeyCategory; + RProperty iProperty; + TInt iPropertyKey; + + TBool iDefineKey; +}; + +#endif // TMSHUTDOWNOBSERVER_H diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/tnmgetimei.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/tnmgetimei.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Helper class to get IMEI number. +* +*/ + +#ifndef _TNMGETIMEI_H_ +#define _TNMGETIMEI_H_ + +#include +#include + +#include "thumbnailmanagerconstants.h" + +class CTnmgetimei: public CActive + { + private: + CTelephony *iTelephony; + CTelephony::TPhoneIdV1 iV1; + TBuf iImei; + CActiveSchedulerWait iAsw; + public: + virtual ~CTnmgetimei(); + static CTnmgetimei* NewL(); + static CTnmgetimei* NewLC(); + TBuf GetIMEI(); + + void DoCancel(); + + void RunL(); + + private: + CTnmgetimei(): CActive(EPriorityStandard), iTelephony(NULL) + {} + void ConstructL(); + + }; + +#endif //_TNMGETIMEI_H_ + diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailcenrep.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailcenrep.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,258 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class for handling central repositoty data + * +*/ + + +#include + +#include + +#include "thumbnailcenrep.h" +#include "thumbnailmanageruids.hrh" +#include "thumbnailstore.h" +#include "thumbnailmanagerconstants.h" +#include "thumbnailmanagerprivatecrkeys.h" + +// --------------------------------------------------------------------------- +// TThumbnailPersistentSize::TThumbnailPersistentSize +// --------------------------------------------------------------------------- +// +TThumbnailPersistentSize::TThumbnailPersistentSize( const TSize& aSize, TBool + aCrop, TDisplayMode aMode, TInt aFormat ): iSize( aSize ), iCrop( aCrop ), + iMode( aMode ), iFormat( aFormat ) + { + iType = EUnknownThumbnailSize; + iSourceType = EUnknownSourceType; + iAutoCreate = ETrue; + } + +// --------------------------------------------------------------------------- +// TThumbnailPersistentSize::TThumbnailPersistentSize +// --------------------------------------------------------------------------- +// +TThumbnailPersistentSize::TThumbnailPersistentSize( TThumbnailSize aType, + const TSize& aSize, TBool aCrop, TDisplayMode aMode, TInt aFormat, + TBool aAutoCreate ) + : iType( aType ), iSize( aSize ), iCrop( aCrop ), iMode( aMode ), + iFormat( aFormat ), iAutoCreate( aAutoCreate ) + { + switch ( aType ) + { + case EImageGridThumbnailSize: + case EImageListThumbnailSize: + case EImageFullScreenThumbnailSize: + iSourceType = EImage; + break; + case EVideoGridThumbnailSize: + case EVideoListThumbnailSize: + case EVideoFullScreenThumbnailSize: + iSourceType = EVideo; + break; + case EAudioGridThumbnailSize: + case EAudioListThumbnailSize: + case EAudioFullScreenThumbnailSize: + iSourceType = EAudio; + break; + default: + iSourceType = EUnknownSourceType; + } + + } + +// --------------------------------------------------------------------------- +// TThumbnailAutoCreate::TThumbnailAutoCreate +// --------------------------------------------------------------------------- +// +TThumbnailAutoCreate::TThumbnailAutoCreate() + : iImageGrid(EFalse), iImageList(EFalse), iImageFullscreen(EFalse), + iVideoGrid(EFalse), iVideoList(EFalse), iVideoFullscreen(EFalse), + iAudioGrid(EFalse), iAudioList(EFalse), iAudioFullscreen(EFalse) + { + // No implementation required + } + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CThumbnailCenRep::CThumbnailCenRep() +// C++ default constructor can NOT contain any code, that might leave. +// --------------------------------------------------------------------------- +// +CThumbnailCenRep::CThumbnailCenRep() + { + // No implementation required + } + + +// --------------------------------------------------------------------------- +// CThumbnailCenRep::~CThumbnailCenRep() +// Destructor. +// --------------------------------------------------------------------------- +// +CThumbnailCenRep::~CThumbnailCenRep() + { + iPersistentSizes.Close(); + delete iAutoCreate; + delete iRepository; + } + +// --------------------------------------------------------------------------- +// CThumbnailCenRep::NewL() +// Two-phased constructor. +// --------------------------------------------------------------------------- +// +CThumbnailCenRep* CThumbnailCenRep::NewL() + { + CThumbnailCenRep* self = new( ELeave )CThumbnailCenRep(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------------------------- +// CThumbnailCenRep::ConstructL() +// Returns id of specific task. +// --------------------------------------------------------------------------- +// +void CThumbnailCenRep::ConstructL() + { + iRepository = CRepository::NewL( TUid::Uid( THUMBNAIL_CENREP_UID )); + + TInt xSize( 0 ); + TInt ySize( 0 ); + TBool flags( EFalse ); + const TBool KGridAndListThumbnailCropped = ETrue; + TInt raw_mode( KThumbnailDefaultDisplayMode ); + TInt format( 0 ); + TBool autoCreate( EFalse ); + + User::LeaveIfError( iRepository->Get( KSizeImageGridWidth, xSize )); + User::LeaveIfError( iRepository->Get( KSizeImageGridHeight, ySize )); + User::LeaveIfError( iRepository->Get( KAutoCreateImageGrid, autoCreate )); + + iPersistentSizes.AppendL( TThumbnailPersistentSize( EImageGridThumbnailSize, TSize( xSize, ySize ), + KGridAndListThumbnailCropped, static_cast (raw_mode), format, autoCreate )); + + User::LeaveIfError( iRepository->Get( KSizeImageListWidth, xSize )); + User::LeaveIfError( iRepository->Get( KSizeImageListHeight, ySize )); + User::LeaveIfError( iRepository->Get( KAutoCreateImageList, autoCreate )); + + iPersistentSizes.AppendL( TThumbnailPersistentSize( EImageListThumbnailSize, TSize( xSize, ySize ), + KGridAndListThumbnailCropped, static_cast (raw_mode), format, autoCreate )); + + User::LeaveIfError( iRepository->Get( KSizeImageFullscreenWidth, xSize )); + User::LeaveIfError( iRepository->Get( KSizeImageFullscreenHeight, ySize )); + User::LeaveIfError( iRepository->Get( KAutoCreateImageFullscreen, autoCreate )); + + iPersistentSizes.AppendL( TThumbnailPersistentSize( EImageFullScreenThumbnailSize, TSize( xSize, ySize ), + flags, static_cast (raw_mode), format, autoCreate )); + + User::LeaveIfError( iRepository->Get( KSizeVideoGridWidth, xSize )); + User::LeaveIfError( iRepository->Get( KSizeVideoGridHeight, ySize )); + User::LeaveIfError( iRepository->Get( KAutoCreateVideoGrid, autoCreate )); + + iPersistentSizes.AppendL( TThumbnailPersistentSize( EVideoGridThumbnailSize, TSize( xSize, ySize ), + KGridAndListThumbnailCropped, static_cast (raw_mode), format, autoCreate )); + + User::LeaveIfError( iRepository->Get( KSizeVideoListWidth, xSize )); + User::LeaveIfError( iRepository->Get( KSizeVideoListHeight, ySize )); + User::LeaveIfError( iRepository->Get( KAutoCreateVideoList, autoCreate )); + + iPersistentSizes.AppendL( TThumbnailPersistentSize( EVideoListThumbnailSize, TSize( xSize, ySize ), + KGridAndListThumbnailCropped, static_cast (raw_mode), format, autoCreate )); + + User::LeaveIfError( iRepository->Get( KSizeVideoFullscreenWidth, xSize )); + User::LeaveIfError( iRepository->Get( KSizeVideoFullscreenHeight, ySize )); + User::LeaveIfError( iRepository->Get( KAutoCreateVideoFullscreen, autoCreate )); + + iPersistentSizes.AppendL( TThumbnailPersistentSize( EVideoFullScreenThumbnailSize, TSize( xSize, ySize ), + flags, static_cast (raw_mode), format, autoCreate )); + + User::LeaveIfError( iRepository->Get( KSizeAudioGridWidth, xSize )); + User::LeaveIfError( iRepository->Get( KSizeAudioGridHeight, ySize )); + User::LeaveIfError( iRepository->Get( KAutoCreateAudioGrid, autoCreate )); + + iPersistentSizes.AppendL( TThumbnailPersistentSize( EAudioGridThumbnailSize, TSize( xSize, ySize ), + KGridAndListThumbnailCropped, static_cast (raw_mode), format, autoCreate )); + + User::LeaveIfError( iRepository->Get( KSizeAudioListWidth, xSize )); + User::LeaveIfError( iRepository->Get( KSizeAudioListHeight, ySize )); + User::LeaveIfError( iRepository->Get( KAutoCreateAudioList, autoCreate )); + + iPersistentSizes.AppendL( TThumbnailPersistentSize( EAudioListThumbnailSize, TSize( xSize, ySize ), + KGridAndListThumbnailCropped, static_cast (raw_mode), format, autoCreate )); + + User::LeaveIfError( iRepository->Get( KSizeAudioFullscreenWidth, xSize )); + User::LeaveIfError( iRepository->Get( KSizeAudioFullscreenHeight, ySize )); + User::LeaveIfError( iRepository->Get( KAutoCreateAudioFullscreen, autoCreate )); + + iPersistentSizes.AppendL( TThumbnailPersistentSize( EAudioFullScreenThumbnailSize, TSize( xSize, ySize ), + flags, static_cast (raw_mode), format, autoCreate )); + + iAutoCreate = new (ELeave) TThumbnailAutoCreate(); + + User::LeaveIfError( iRepository->Get( KAutoCreateImageGrid, iAutoCreate->iImageGrid )); + User::LeaveIfError( iRepository->Get( KAutoCreateImageList, iAutoCreate->iImageList )); + User::LeaveIfError( iRepository->Get( KAutoCreateImageFullscreen, iAutoCreate->iImageFullscreen )); + User::LeaveIfError( iRepository->Get( KAutoCreateVideoGrid, iAutoCreate->iVideoGrid )); + User::LeaveIfError( iRepository->Get( KAutoCreateVideoList, iAutoCreate->iVideoList )); + User::LeaveIfError( iRepository->Get( KAutoCreateVideoFullscreen, iAutoCreate->iVideoFullscreen )); + User::LeaveIfError( iRepository->Get( KAutoCreateAudioGrid, iAutoCreate->iAudioGrid )); + User::LeaveIfError( iRepository->Get( KAutoCreateAudioList, iAutoCreate->iAudioList )); + User::LeaveIfError( iRepository->Get( KAutoCreateAudioFullscreen, iAutoCreate->iAudioFullscreen )); + } + +// --------------------------------------------------------------------------- +// CThumbnailCenRep::GetPersistentSizes() +// --------------------------------------------------------------------------- +// +RArray < TThumbnailPersistentSize > & CThumbnailCenRep::GetPersistentSizes() + { + return iPersistentSizes; + } + +// --------------------------------------------------------------------------- +// CThumbnailCenRep::GetAutoCreateParams() +// --------------------------------------------------------------------------- +// +TThumbnailAutoCreate & CThumbnailCenRep::GetAutoCreateParams() + { + return *iAutoCreate; + } + +TThumbnailPersistentSize & CThumbnailCenRep::PersistentSizeL( TThumbnailSize + aThumbnailSize ) + { + TThumbnailPersistentSize* persistentSize = NULL; + TInt i = iPersistentSizes.Count(); + for ( ; --i >= 0; ) + { + persistentSize = &iPersistentSizes[i]; + if ( persistentSize->iType == aThumbnailSize ) + { + break; + } + } + if ( i < 0 ) + { // size not found + User::Leave( KErrNotFound ); + } + + return *persistentSize; + } + +// End of file diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnaildecodetask.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnaildecodetask.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,175 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Task for generating new thumbnails + * +*/ + + +#include +#include + +#include + +#include "thumbnaildecodetask.h" +#include "thumbnailprovider.h" +#include "thumbnailserver.h" +#include "thumbnaillog.h" +#include "thumbnailpanic.h" + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CThumbnailDecodeTask::CThumbnailDecodeTask() +// C++ default constructor can NOT contain any code, that might leave. +// --------------------------------------------------------------------------- +// +CThumbnailDecodeTask::CThumbnailDecodeTask( CThumbnailTaskProcessor& aProcessor, + CThumbnailServer& aServer, TDesC8* aBuffer, TInt aPriority, TDisplayMode aDisplayMode): CThumbnailTask( aProcessor, + aPriority ), iServer( aServer ), iBuffer(aBuffer), iDisplayMode(aDisplayMode) + { + TN_DEBUG3( "CThumbnailDecodeTask(0x%08x)::CThumbnailDecodeTask() aDisplayMode = %d", this + , iDisplayMode); + } + + +// --------------------------------------------------------------------------- +// CThumbnailDecodeTask::~CThumbnailDecodeTask() +// Destructor. +// --------------------------------------------------------------------------- +// +CThumbnailDecodeTask::~CThumbnailDecodeTask() + { + if ( iProvider ) + { + iProvider->CancelGetThumbnail(); + } + + iProvider = NULL; + delete iBuffer; + iBuffer = NULL; + } + + +// --------------------------------------------------------------------------- +// CThumbnailDecodeTask::StartL() +// --------------------------------------------------------------------------- +// +void CThumbnailDecodeTask::StartL() + { + TN_DEBUG2( "CThumbnailDecodeTask(0x%08x)::StartL()", this ); + + CThumbnailTask::StartL(); + + const TPtrC8 mimeType = KJpegMime(); + + iProvider = iServer.ResolveProviderL( mimeType ); + TN_DEBUG3( "CThumbnailDecodeTask(0x%08x) -- provider UID 0x%08x", this, + iProvider->Uid()); + + __ASSERT_DEBUG(( iProvider ), ThumbnailPanic( EThumbnailNullPointer )); + + iProvider->CancelGetThumbnail(); + iProvider->Reset(); + iProvider->SetObserver( *this ); + + iProvider->GetThumbnailL( iServer.Fs(), *iBuffer ); + } + + +// --------------------------------------------------------------------------- +// CThumbnailDecodeTask::RunL() +// --------------------------------------------------------------------------- +// +void CThumbnailDecodeTask::RunL() + { + // No implementation required + TN_DEBUG2( "CThumbnailDecodeTask(0x%08x)::RunL()", this ); + } + + +// --------------------------------------------------------------------------- +// CThumbnailDecodeTask::DoCancel() +// --------------------------------------------------------------------------- +// +void CThumbnailDecodeTask::DoCancel() + { + TN_DEBUG2( "CThumbnailDecodeTask(0x%08x)::DoCancel()", this ); + if ( iProvider ) + { + iProvider->CancelGetThumbnail(); + } + } + + +// +// --------------------------------------------------------------------------- +// Thumbnail provider observer callback to notify the server when +// thumbnail has been generated. +// --------------------------------------------------------------------------- +// +void CThumbnailDecodeTask::ThumbnailProviderReady( const TInt aError, + CFbsBitmap* aBitmap, const TSize& aOriginalSize, const TBool /*aEXIF*/, const TBool /*aPortrait*/ ) + { + TN_DEBUG4( "CThumbnailDecodeTask(0x%08x)::ThumbnailProviderReady(aError=%d, aBitmap=0x%08x)", + this, aError, aBitmap ); + + iOriginalSize = aOriginalSize; + + if ( aError ) + { + delete aBitmap; + aBitmap = NULL; + Complete( aError ); + return; + } + + if( !aBitmap ) + { + Complete( KErrGeneral ); + return; + } + + if ( iMessage.Handle()) + { + TRAP_IGNORE(iServer.AddBitmapToPoolL( iRequestId.iSession, aBitmap )); + const TSize bitmapSize = aBitmap->SizeInPixels(); + iBitmapHandle = aBitmap->Handle(); + aBitmap = NULL; + + // Complete message and pass bitmap handle to client + TThumbnailRequestParams& params = iParamsBuf(); + TInt ret = iMessage.Read( 0, iParamsBuf ); + + if(ret == KErrNone ) + { + params.iBitmapHandle = iBitmapHandle; + ret = iMessage.Write( 0, iParamsBuf ); + } + + Complete( ret ); + ResetMessageData(); + + // Successfully completed the message. The client will send + // EReleaseBitmap message later to delete the bitmap from pool. + // CThumbnailScaleTask is no longer responsible for that. + iBitmapHandle = 0; + } + else + { + delete aBitmap; + aBitmap = NULL; + } + } + diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnaildiskunmountobserver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnaildiskunmountobserver.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,127 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class to monitor when volumes are unmounted + * +*/ + + +#include "thumbnaildiskunmountobserver.h" +#include "thumbnaillog.h" +#include "thumbnailserver.h" + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CThumbnailTaskProcessor::NewL() +// Two-phased constructor. +// --------------------------------------------------------------------------- +// +CThumbnailDiskUnmountObserver* CThumbnailDiskUnmountObserver::NewL( RFs& aFs, + TInt aDrive, CThumbnailServer* aServer ) + { + CThumbnailDiskUnmountObserver* self = new( ELeave ) + CThumbnailDiskUnmountObserver( aFs, aDrive, aServer ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// CThumbnailTaskProcessor::CThumbnailTaskProcessor() +// C++ default constructor can NOT contain any code, that might leave. +// --------------------------------------------------------------------------- +// +CThumbnailDiskUnmountObserver::CThumbnailDiskUnmountObserver( RFs& aFs, + TInt aDrive, CThumbnailServer* aServer ) + : CActive( CActive::EPriorityStandard ), iFs( aFs ), iDrive( aDrive), iServer( aServer ) + { + TN_DEBUG1( "CThumbnailDiskUnmountObserver::CThumbnailDiskUnmountObserver()" + ); + CActiveScheduler::Add( this ); + StartNotify(); + } + + +// --------------------------------------------------------------------------- +// CThumbnailTaskProcessor::ConstructL() +// Symbian 2nd phase constructor can leave. +// --------------------------------------------------------------------------- +// +void CThumbnailDiskUnmountObserver::ConstructL() + { + // No implementation required + } + + +// --------------------------------------------------------------------------- +// CThumbnailTaskProcessor::~CThumbnailTaskProcessor() +// Destructor. +// --------------------------------------------------------------------------- +// +CThumbnailDiskUnmountObserver::~CThumbnailDiskUnmountObserver() + { + TN_DEBUG1( + "CThumbnailDiskUnmountObserver::~CThumbnailDiskUnmountObserver()" ); + Cancel(); + } + + +// --------------------------------------------------------------------------- +// CThumbnailTaskProcessor::RunL() +// --------------------------------------------------------------------------- +// +void CThumbnailDiskUnmountObserver::RunL() + { + TN_DEBUG2( "CThumbnailDiskUnmountObserver::RunL() iStatus = %d", + iStatus.Int()); + + if( !iStatus.Int() ) + { + // close store before allowing unmount + // trap because nothing could be done in RunError anyway + TRAP_IGNORE( iServer->CloseStoreForDriveL( iDrive ) ); + iFs.AllowDismount( iDrive ); + } + if ( iStatus.Int() != KErrNotReady) + { + StartNotify(); + } + } + +// --------------------------------------------------------------------------- +// CThumbnailDiskUnmountObserver::DoCancel() +// --------------------------------------------------------------------------- +// +void CThumbnailDiskUnmountObserver::DoCancel() + { + iFs.NotifyDismountCancel( iStatus ); + } + +// --------------------------------------------------------------------------- +// CThumbnailDiskUnmountObserver::StartNotify() +// --------------------------------------------------------------------------- +// +void CThumbnailDiskUnmountObserver::StartNotify() + { + TN_DEBUG1( "CThumbnailDiskUnmountObserver::StartNotify()" ); + if(!IsActive()) + { + iFs.NotifyDismount( iDrive, iStatus, EFsDismountRegisterClient ); + SetActive(); + } + } + +// End of file diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailformatobserver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailformatobserver.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,127 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: File System format monitor +* +*/ + +#include "thumbnailformatobserver.h" +#include "thumbnaillog.h" + +#include +#include + + +// ======== MEMBER FUNCTIONS ======== + +CThumbnailFormatObserver::CThumbnailFormatObserver ( CThumbnailServer* aServer): + iServer( aServer ) + { + TN_DEBUG1( "CThumbnailFormatObserver::CThumbnailFormatObserver()"); + + } + + +// --------------------------------------------------------------------------- +// Second Phase Constructor +// --------------------------------------------------------------------------- +// +void CThumbnailFormatObserver::ConstructL() + { + TN_DEBUG1("CThumbnailFormatObserver::ConstructL in"); + + iBackupSession = CBaBackupSessionWrapper::NewL(); + iBackupSession->RegisterBackupOperationObserverL( *this ); + + + TN_DEBUG1("CThumbnailFormatObserver::ConstructL out"); + } + + +// --------------------------------------------------------------------------- +// Two-Phased Constructor +// --------------------------------------------------------------------------- +// +CThumbnailFormatObserver* CThumbnailFormatObserver::NewL(CThumbnailServer* aServer ) + { + CThumbnailFormatObserver* self = CThumbnailFormatObserver::NewLC( aServer ); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// Two-Phased Constructor +// --------------------------------------------------------------------------- +// +CThumbnailFormatObserver* CThumbnailFormatObserver::NewLC( CThumbnailServer* aServer ) + { + CThumbnailFormatObserver* self = new( ELeave ) CThumbnailFormatObserver( aServer ); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + + +// --------------------------------------------------------------------------- +// destructor +// --------------------------------------------------------------------------- +// +CThumbnailFormatObserver::~CThumbnailFormatObserver() + { + + if( iBackupSession ) + { + iBackupSession->DeRegisterBackupOperationObserver( *this ); + } + delete iBackupSession; + } + +// --------------------------------------------------------------------------- +// Checks the current status +// --------------------------------------------------------------------------- +// +void CThumbnailFormatObserver::PollStatus() + { + + TN_DEBUG1("CThumbnailFormatObserver::PollStatus()"); + + TBool aFormatting = iBackupSession->IsBackupOperationRunning(); + + if( aFormatting ) + { + TRAP_IGNORE(iServer->CloseRemovableDrivesL()); + } + } + +// --------------------------------------------------------------------------- +// CThumbnailFormatObserver::HandleBackupOperationEventL +// Handles a format operation +// --------------------------------------------------------------------------- +// +void CThumbnailFormatObserver::HandleBackupOperationEventL( + const TBackupOperationAttributes& aBackupOperationAttributes) + { + TN_DEBUG1("CThumbnailFormatObserver::HandleBackupOperationEventL in"); + + if( aBackupOperationAttributes.iOperation == EStart ) + { + TRAP_IGNORE(iServer->CloseRemovableDrivesL()); + } + else // TOperationType::EEnd or TOperationType::EAbort + { + TRAP_IGNORE(iServer->OpenRemovableDrivesL()); + } + + TN_DEBUG1("CThumbnailFormatObserver::HandleBackupOperationEventL out"); + } diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailgeneratetask.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailgeneratetask.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,497 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Task for generating new thumbnails + * +*/ + + +#include +#include + +#include + +#include "thumbnailgeneratetask.h" +#include "thumbnailscaletask.h" +#include "thumbnailprovider.h" +#include "thumbnailserver.h" +#include "thumbnailtaskprocessor.h" +#include "thumbnailmanagerconstants.h" +#include "thumbnaillog.h" +#include "thumbnailpanic.h" + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CThumbnailGenerateTask::CThumbnailGenerateTask() +// C++ default constructor can NOT contain any code, that might leave. +// --------------------------------------------------------------------------- +// +CThumbnailGenerateTask::CThumbnailGenerateTask( CThumbnailTaskProcessor& + aProcessor, CThumbnailServer& aServer, RFile64* aFile, TDesC8* aBuffer, + const TDataType* aMimeType, CThumbnailManager::TThumbnailFlags aFlags, + const TSize& aSize, TDisplayMode aDisplayMode, TInt aPriority, + RArray < TThumbnailPersistentSize >* aMissingSizes, const TDesC& aTargetUri, + TThumbnailSize aThumbnailSize, const TThumbnailId aThumbnailId, + const CThumbnailManager::TThumbnailQualityPreference aQualityPreference ): + CThumbnailTask( aProcessor, aPriority ), iServer( aServer ), + iFlags( aFlags ), iSize( aSize ), iDisplayMode( aDisplayMode ), + iMissingSizes( aMissingSizes ), iTargetUri( aTargetUri ), + iThumbnailSize( aThumbnailSize ), iThumbnailId(aThumbnailId), + iQualityPreference( aQualityPreference ) + { + TN_DEBUG2( "CThumbnailGenerateTask(0x%08x)::CThumbnailGenerateTask()", this); + + if ( !aBuffer && aFile) + { + iFile = *aFile; + iFile.FullName( iFilename ); + } + else if( aBuffer ) + { + iBuffer = aBuffer; + } + if ( aMimeType ) + { + iMimeType = *aMimeType; + } + else + { + iMimeType = TDataType(KNullDesC8); + } + + // scaled bitmaps to pool by default + iScaledBitmapToPool = ETrue; + } + + +// --------------------------------------------------------------------------- +// CThumbnailGenerateTask::~CThumbnailGenerateTask() +// Destructor. +// --------------------------------------------------------------------------- +// +CThumbnailGenerateTask::~CThumbnailGenerateTask() + { + TN_DEBUG2("CThumbnailGenerateTask(0x%08x)::~CThumbnailGenerateTask()", this); + + if ( iProvider ) + { + iProvider->CancelGetThumbnail(); + } + + if ( iMissingSizes ) + { + iMissingSizes->Reset(); + delete iMissingSizes; + } + + if ( iBitmap ) + { + iServer.DeleteBitmapFromPool( iBitmap->Handle()); + iBitmap = NULL; + } + + iProvider = NULL; + delete iBuffer; + iBuffer = NULL; + + iFile.Close(); + TN_DEBUG1("CThumbnailGenerateTask::~CThumbnailGenerateTask() - file handle closed"); + } + + +// --------------------------------------------------------------------------- +// CThumbnailGenerateTask::StartL() +// --------------------------------------------------------------------------- +// +void CThumbnailGenerateTask::StartL() + { + TN_DEBUG2( "CThumbnailGenerateTask(0x%08x)::StartL()", this ); + + CThumbnailTask::StartL(); + +#ifdef _DEBUG + aStart.UniversalTime(); +#endif + + + TParsePtrC parse(iFilename); + TPtrC ext(parse.Ext()); + TBuf8< KMaxDataTypeLength > mimeType; + if (ext.CompareF(KNonEmbeddedArtExt)== 0) + { + mimeType.Copy( KImageMime ); + } + else + { + mimeType = iMimeType.Des8(); + } + iProvider = iServer.ResolveProviderL(mimeType); + + TN_DEBUG3( "CThumbnailGenerateTask(0x%08x) -- provider UID 0x%08x", this, + iProvider->Uid()); + + __ASSERT_DEBUG(( iProvider ), ThumbnailPanic( EThumbnailNullPointer )); + + iProvider->CancelGetThumbnail(); + iProvider->Reset(); + iProvider->SetObserver( *this ); + + TSize effectiveTargetSize; + TSize croppedTargetSize; + + CalculateTargetSizesL( effectiveTargetSize, croppedTargetSize ); + + iProvider->SetTargetSize( effectiveTargetSize ); + + if(effectiveTargetSize == TSize()) + { + iProvider->SetTargetSize( croppedTargetSize ); + } + + if ( !iBuffer ) + { + iProvider->GetThumbnailL( iServer.Fs(), iFile, iMimeType, iFlags, + iDisplayMode, iQualityPreference ); + } + else + { + iProvider->GetThumbnailL( iServer.Fs(), iBuffer, iMimeType, iFlags, + iDisplayMode, iQualityPreference ); + } + } + + +// --------------------------------------------------------------------------- +// CThumbnailGenerateTask::RunL() +// --------------------------------------------------------------------------- +// +void CThumbnailGenerateTask::RunL() + { + // No implementation required + } + + +// --------------------------------------------------------------------------- +// CThumbnailGenerateTask::DoCancel() +// --------------------------------------------------------------------------- +// +void CThumbnailGenerateTask::DoCancel() + { + TN_DEBUG2( "CThumbnailGenerateTask(0x%08x)::DoCancel()", this ); + if ( iProvider ) + { + iProvider->CancelGetThumbnail(); + } + } + + +// --------------------------------------------------------------------------- +// Calculate the largest non-cropped size and largest cropped size and +// let the provider plug-in know the values +// --------------------------------------------------------------------------- +// +void CThumbnailGenerateTask::CalculateTargetSizesL( TSize& aEffectiveTargetSize, + TSize& aCroppedTargetSize ) + { + if ( iThumbnailSize == ECustomThumbnailSize ) + { + if ( iFlags& CThumbnailManager::ECropToAspectRatio ) + { + aCroppedTargetSize = iSize; + } + else + { + aEffectiveTargetSize = iSize; + } + } + + if ( iThumbnailSize != ECustomThumbnailSize ) + { + RArray < TThumbnailPersistentSize > sizes = iServer.PersistentSizesL(); + const TInt count = sizes.Count(); + for ( TInt i = 0; i < count; i++ ) + { + TThumbnailPersistentSize size( sizes[i] ); + + iSize = size.iSize; + if ( size.iCrop ) + { + aCroppedTargetSize.iWidth = Max( aCroppedTargetSize.iWidth, + size.iSize.iWidth ); + aCroppedTargetSize.iHeight = Max( aCroppedTargetSize.iHeight, + size.iSize.iHeight ); + if(iBuffer) + { + iFlags = ( CThumbnailManager::TThumbnailFlags ) (iFlags | CThumbnailManager::ECropToAspectRatio); + aEffectiveTargetSize = aCroppedTargetSize; + } + } + else + { + aEffectiveTargetSize.iWidth = Max( aEffectiveTargetSize.iWidth, + size.iSize.iWidth ); + aEffectiveTargetSize.iHeight = Max( aEffectiveTargetSize.iHeight, + size.iSize.iHeight ); + } + + if(size.iType == iThumbnailSize) + { + break; + } + } + } + } + +// --------------------------------------------------------------------------- +// Thumbnail provider observer callback to notify the server when +// thumbnail has been generated. +// --------------------------------------------------------------------------- +// +void CThumbnailGenerateTask::ThumbnailProviderReady( const TInt aError, + CFbsBitmap* aBitmap, const TSize& aOriginalSize, const TBool aEXIF, const TBool aPortrait ) + { + TN_DEBUG4( + "CThumbnailGenerateTask(0x%08x)::ThumbnailProviderReady(aError=%d, aBitmap=0x%08x)", this, aError, aBitmap ); + + #ifdef _DEBUG + aStop.UniversalTime(); + TN_DEBUG2( "CThumbnailGenerateTask::ThumbnailProviderReady() generate took %d ms", (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000); + #endif + + iPortrait = aPortrait; + iEXIF = aEXIF; + iOriginalSize = aOriginalSize; + + if ( aError ) + { + delete aBitmap; + aBitmap = NULL; + // Create a temporary bitmap of size 1 for storing blacklisted thumbnail + // Because no actual bitmap data is generated, there is no reason to + // add bitmap to server bitmap pool. Completion of client request with + // error code just results in applications showing their default bitmap. + if( iFilename != KNullDesC || iTargetUri != KNullDesC ) + { + if ( aError == KErrNotSupported || + aError == KErrCorrupt || + aError == KErrCompletion) + { + TRAPD( err, CreateBlackListedL( aOriginalSize ) ); + if (err != KErrNone) + { + TN_DEBUG2( "CThumbnailGenerateTask::ThumbnailProviderReady() - blacklisting failed with code %d", err ); + } + } + } + Complete( aError ); + } + else + { + // CreateScaleTasksL will take ownership of bitmap + +#ifdef _DEBUG + TN_DEBUG2( "CThumbnailGenerateTask::ThumbnailProviderReady() - displaymode is %d", aBitmap->DisplayMode()); +#endif + + TRAPD( err, CreateScaleTasksL( aBitmap )); + aBitmap = NULL; + // If CreateScaleTasksL left, we are responsible for completing + // the RMessage. If there was no leave, then this call will not + // complete actual the message, just the mark the task as completed. + Complete( err ); + } + } + + +// --------------------------------------------------------------------------- +// Create tasks to scale the thumbnail to each persistent thumbnail size +// and also to the size the client requested +// --------------------------------------------------------------------------- +// +void CThumbnailGenerateTask::CreateScaleTasksL( CFbsBitmap* aBitmap ) + { + __ASSERT_DEBUG(( aBitmap ), ThumbnailPanic( EThumbnailNullPointer )); + + CleanupStack::PushL( aBitmap ); + iServer.AddBitmapToPoolL( iRequestId.iSession, aBitmap ); + + // Keep pointer so we can delete bitmap from pool + iBitmap = aBitmap; + CleanupStack::Pop( aBitmap ); + + // compTask is the scale task which returns the bitmap to the client + CThumbnailScaleTask* complTask = NULL; + + if ( iMissingSizes ) + { + const TInt count = iMissingSizes->Count(); + + for ( TInt i( 0 ); i < count; i++ ) + { + TThumbnailSize size = (*iMissingSizes)[ i ].iType; +#ifdef _DEBUG + TN_DEBUG3( "CThumbnailGenerateTask(0x%08x)::CreateScaleTasksL() *iMissingSizes)[ i ].iType == %d", this, size ); +#endif + + if ( iPortrait ) + { + if ( size == EFullScreenThumbnailSize || + size == EVideoFullScreenThumbnailSize || + size == EAudioFullScreenThumbnailSize || + size == EImageFullScreenThumbnailSize ) + { + TN_DEBUG2( "*iMissingSizes)[ i ].iWidth == %d", (*iMissingSizes)[ i ].iSize.iWidth ); + TN_DEBUG2( "*iMissingSizes)[ i ].iHeight == %d", (*iMissingSizes)[ i ].iSize.iHeight ); + TInt width = (*iMissingSizes)[ i ].iSize.iWidth; + (*iMissingSizes)[ i ].iSize.iWidth = (*iMissingSizes)[ i ].iSize.iHeight; + (*iMissingSizes)[ i ].iSize.iHeight = width; + TN_DEBUG2( "*iMissingSizes)[ i ].iWidth == %d", (*iMissingSizes)[ i ].iSize.iWidth ); + TN_DEBUG2( "*iMissingSizes)[ i ].iHeight == %d", (*iMissingSizes)[ i ].iSize.iHeight ); + } + } + + CThumbnailScaleTask* scaleTask = CThumbnailScaleTask::NewL( iProcessor, iServer, iFilename, + iBitmap, iOriginalSize, (*iMissingSizes)[ i ].iSize, (*iMissingSizes)[ i ].iCrop, iDisplayMode, + KMaxPriority, iTargetUri, (*iMissingSizes)[ i ].iType, iThumbnailId, iScaledBitmapToPool, iEXIF ); + CleanupStack::PushL( scaleTask ); + + TInt err1 = KErrNone; + TInt err2 = KErrNone; + if(iFilename != KNullDesC) + { + TRAP(err1, iServer.StoreForPathL(iFilename)); + } + if(iTargetUri != KNullDesC) + { + TRAP(err2, iServer.StoreForPathL(iTargetUri)); + } + // if trying to access Z drive, don't try to store + // don't want to store custom sizes + if( err1 == KErrAccessDenied || err2 == KErrAccessDenied || + (*iMissingSizes)[ i ].iType == ECustomThumbnailSize ) + { + scaleTask->SetDoStore( EFalse ); + } + else + { + scaleTask->SetDoStore( ETrue ); + } + + iProcessor.AddTaskL( scaleTask ); + CleanupStack::Pop( scaleTask ); + + // completion to first task, because task processor works like stack + if( i == 0 ) + { + // compTask is now responsible for completing the RMessage + scaleTask->SetMessageData( iRequestId, iMessage ); + ResetMessageData(); + } + } + } + else + { + if( iPortrait ) + { + if ( iThumbnailSize == EFullScreenThumbnailSize || + iThumbnailSize == EVideoFullScreenThumbnailSize || + iThumbnailSize == EAudioFullScreenThumbnailSize || + iThumbnailSize == EImageFullScreenThumbnailSize ) + { + TInt width = iSize.iWidth; + iSize.iWidth = iSize.iHeight; + iSize.iHeight = width; + } + } + + complTask = CThumbnailScaleTask::NewL( iProcessor, iServer, iFilename, + iBitmap, iOriginalSize, iSize, iFlags& CThumbnailManager + ::ECropToAspectRatio, iDisplayMode, KMaxPriority, iTargetUri, + iThumbnailSize, iThumbnailId, iScaledBitmapToPool, iEXIF ); + CleanupStack::PushL( complTask ); + + TInt err1 = KErrNone; + TInt err2 = KErrNone; + if(iFilename != KNullDesC) + { + TRAP(err1, iServer.StoreForPathL(iFilename)); + } + if(iTargetUri != KNullDesC) + { + TRAP(err2, iServer.StoreForPathL(iTargetUri)); + } + // if trying to access Z drive, don't try to store + // don't want to store custom sizes + if( err1 == KErrAccessDenied || err2 == KErrAccessDenied || + iThumbnailSize == ECustomThumbnailSize ) + { + complTask->SetDoStore( EFalse ); + } + else + { + complTask->SetDoStore( ETrue ); + } + + iProcessor.AddTaskL( complTask ); + CleanupStack::Pop( complTask ); + + // compTask is now responsible for completing the RMessage and + // returning the bitmap to the client + complTask->SetMessageData( iRequestId, iMessage ); + ResetMessageData(); + } + + // Scale tasks now reference the bitmap in the pool + iServer.DeleteBitmapFromPool( iBitmap->Handle()); + iBitmap = NULL; + } + +// --------------------------------------------------------------------------- +// Defines if scaled bitmaps need to be added to pool +// --------------------------------------------------------------------------- +// +void CThumbnailGenerateTask::ScaledBitmapToPool( TBool aBool ) + { + iScaledBitmapToPool = aBool; + } + +// --------------------------------------------------------------------------- +// Stores a blacklisted thumbnail +// --------------------------------------------------------------------------- +// +void CThumbnailGenerateTask::CreateBlackListedL( const TSize& aOriginalSize ) + { + CFbsBitmap* tempBitmap = 0; + tempBitmap = new (ELeave) CFbsBitmap(); + CleanupStack::PushL( tempBitmap ); + TSize tempSize( 1, 1 ); + User::LeaveIfError( tempBitmap->Create( tempSize, iDisplayMode ) ); + + // Instead of creating a blacklisted entry of requested size (iThumbnailSize) in thumbnail db, + // consider blacklisting all sizes (hence the changes are needed in thumbnail fetching logic too). + // However, decoding of source to thumnail could succeed in other sizes, which makes blacklisting + // of requested size only meaningful. + if(iFilename != KNullDesC) + { + iServer.StoreForPathL( iFilename )->StoreThumbnailL( + iFilename, tempBitmap, aOriginalSize, EFalse, iThumbnailSize, iThumbnailId, EFalse, ETrue ); + } + else if(iTargetUri != KNullDesC) + { + iServer.StoreForPathL( iTargetUri )->StoreThumbnailL( + iTargetUri, tempBitmap, aOriginalSize, EFalse, iThumbnailSize, iThumbnailId, EFalse, ETrue ); + } + + CleanupStack::PopAndDestroy( tempBitmap ); + } diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailmdsquerytask.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailmdsquerytask.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,285 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Task for making MDS querys +* +*/ + + +#include + +#include +#include + +#include "thumbnailmdsquerytask.h" +#include "thumbnailmanagerconstants.h" +#include "thumbnaillog.h" +#include "thumbnailserver.h" + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CThumbnailMDSQueryTask::CThumbnailMDSQueryTask() +// C++ default constructor can NOT contain any code, that might leave. +// --------------------------------------------------------------------------- +// +CThumbnailMDSQueryTask::CThumbnailMDSQueryTask( + CThumbnailTaskProcessor& aProcessor, TInt aPriority, CMdESession* aMdESession, CThumbnailServer& aServer): + CThumbnailTask( aProcessor, aPriority ), iMdESession( aMdESession ), iServer(aServer), iUpdateToDb(ETrue) + { + TN_DEBUG2( "CThumbnailMDSQueryTask(0x%08x)::CThumbnailMDSQueryTask()", this ); + } + + +// --------------------------------------------------------------------------- +// CThumbnailMDSQueryTask::~CThumbnailMDSQueryTask() +// Destructor. +// --------------------------------------------------------------------------- +// +CThumbnailMDSQueryTask::~CThumbnailMDSQueryTask() + { + TN_DEBUG2( "CThumbnailMDSQueryTask(0x%08x)::~CThumbnailMDSQueryTask()", this); + + if (iQuery) + { + iQuery->Cancel(); + delete iQuery; + } + } + + +// ----------------------------------------------------------------------------- +// CThumbnailMDSQueryTask::HandleQueryNewResults() +// ----------------------------------------------------------------------------- +// +void CThumbnailMDSQueryTask::HandleQueryNewResults( CMdEQuery& /*aQuery*/, + const TInt /*aFirstNewItemIndex*/, + const TInt /*aNewItemCount*/ ) + { + // No implementation required + } + +// ----------------------------------------------------------------------------- +// CThumbnailMDSQueryTask::HandleQueryCompleted() +// ----------------------------------------------------------------------------- +// +void CThumbnailMDSQueryTask::HandleQueryCompleted( CMdEQuery& /*aQuery*/, const TInt aError ) + { + TN_DEBUG3( "CThumbnailMDSQueryTask::HandleQueryCompleted(0x%08x), aError == %d", this, aError ); + + // if no errors in query + if (aError == KErrNone && iQuery && iQuery->Count() > 0) + { + if( iQueryType == EURI ) + { + const CMdEObject* object = &iQuery->Result(0); + + TN_DEBUG2( "CThumbnailMDSQueryTask::HandleQueryCompleted() - URI = %S", &object->Uri() ); + + if( iUpdateToDb) + { + //update IDs to database by Path + if (iMessage.Handle()) + { + TInt err = iMessage.Read( 0, iRequestParams ); + if( err == KErrNone) + { + TThumbnailRequestParams& params = iRequestParams(); + TRAP_IGNORE(iServer.UpdateIDL(object->Uri(), params.iThumbnailId)); + } + } + } + + // return path to client side + ReturnPath(object->Uri()); + } + else if (iQueryType == EId ) + { + const CMdEObject* object = &iQuery->Result(0); + + TN_DEBUG2( "CThumbnailMDSQueryTask::HandleQueryCompleted() - Id = %d", object->Id()); + + if( object->Id() != KNoId) + { + if( iUpdateToDb) + { + TRAP_IGNORE(iServer.UpdateIDL(object->Uri(), object->Id() )); + } + else + { + // add Id to message + if (iMessage.Handle()) + { + TInt ret = iMessage.Read( 0, iRequestParams ); + if( ret == KErrNone) + { + TThumbnailRequestParams& params = iRequestParams(); + params.iThumbnailId = object->Id(); + ret = iMessage.Write( 0, iRequestParams ); + } + } + } + } + + // complete the message with a code from which client side + // knows to make a new request using the path + Complete( KThumbnailErrThumbnailNotFound ); + ResetMessageData(); + } + else + { + TN_DEBUG1( "CThumbnailMDSQueryTask::HandleQueryCompleted() - Don't ever come here" ); + Complete( KErrNotFound ); + ResetMessageData(); + } + } + else + { + TN_DEBUG1( "CThumbnailMDSQueryTask::HandleQueryCompleted() - No results." ); + + if( iQueryType == EId ) + { + if( iUpdateToDb) + { + TN_DEBUG2( "CThumbnailMDSQueryTask::HandleQueryCompleted() delete %S", &iUri ); + TRAP_IGNORE( iServer.DeleteThumbnailsL( iUri ) ); + } + + Complete( KThumbnailErrThumbnailNotFound ); + ResetMessageData(); + } + else + { + Complete( KErrNotFound ); + ResetMessageData(); + } + } + } + + +// --------------------------------------------------------------------------- +// CThumbnailMDSQueryTask::StartL() +// --------------------------------------------------------------------------- +// +void CThumbnailMDSQueryTask::StartL() + { + TN_DEBUG2( "CThumbnailMDSQueryTask(0x%08x)::StartL()", this ); + + CThumbnailTask::StartL(); + + // start query + iQuery->FindL(); + } + + +// --------------------------------------------------------------------------- +// CThumbnailMDSQueryTask::RunL() +// --------------------------------------------------------------------------- +// +void CThumbnailMDSQueryTask::RunL() + { + // No implementation required + TN_DEBUG2( "CThumbnailMDSQueryTask(0x%08x)::RunL()", this ); + } + + +// --------------------------------------------------------------------------- +// CThumbnailMDSQueryTask::DoCancel() +// --------------------------------------------------------------------------- +// +void CThumbnailMDSQueryTask::DoCancel() + { + TN_DEBUG2( "CThumbnailMDSQueryTask(0x%08x)::DoCancel()", this ); + + iQuery->Cancel(); + } + +// --------------------------------------------------------------------------- +// CThumbnailMDSQueryTask::QueryPathByIdL() +// --------------------------------------------------------------------------- +// +void CThumbnailMDSQueryTask::QueryPathByIdL(TThumbnailId aId) + { + TN_DEBUG1( "CThumbnailMDSQueryTask()::QueryPathByIdL()"); + iQueryType = EURI; + CMdENamespaceDef* defNamespace = &iMdESession->GetDefaultNamespaceDefL(); + CMdEObjectDef& objDef = defNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject ); + + iQuery = iMdESession->NewObjectQueryL( *defNamespace, objDef, this ); + iQuery->SetResultMode( EQueryResultModeItem ); + + CMdELogicCondition& rootCondition = iQuery->Conditions(); + rootCondition.SetOperator( ELogicConditionOperatorOr ); + + // add ID condition + rootCondition.AddObjectConditionL( aId ); + } + +// --------------------------------------------------------------------------- +// CThumbnailMDSQueryTask::ReturnPath() +// --------------------------------------------------------------------------- +// +void CThumbnailMDSQueryTask::ReturnPath(const TDesC& aUri) + { + if ( iMessage.Handle()) + { + // add path to message + if (iMessage.Handle()) + { + TInt ret = iMessage.Read( 0, iRequestParams ); + if(ret == KErrNone) + { + TThumbnailRequestParams& params = iRequestParams(); + params.iFileName = aUri; + ret = iMessage.Write( 0, iRequestParams ); + } + } + + // complete the message with a code from which client side + // knows to make a new request using the path + Complete( KThumbnailErrThumbnailNotFound ); + ResetMessageData(); + } + } + +// --------------------------------------------------------------------------- +// CThumbnailMDSQueryTask::QueryIdByPathL() +// --------------------------------------------------------------------------- +// +void CThumbnailMDSQueryTask::QueryIdByPathL(const TDesC& aUri) + { + TN_DEBUG1( "CThumbnailMDSQueryTask()::QueryIdByPathL()"); + iQueryType = EId; + iUri = aUri; + CMdENamespaceDef* defNamespace = &iMdESession->GetDefaultNamespaceDefL(); + CMdEObjectDef& objDef = defNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject ); + + iQuery = iMdESession->NewObjectQueryL( *defNamespace, objDef, this ); + iQuery->SetResultMode( EQueryResultModeItem ); + + CMdELogicCondition& rootCondition = iQuery->Conditions(); + rootCondition.SetOperator( ELogicConditionOperatorOr ); + + rootCondition.AddObjectConditionL(EObjectConditionCompareUri, aUri); + } + +// --------------------------------------------------------------------------- +// CThumbnailMDSQueryTask::SetUpdateToDb() +// --------------------------------------------------------------------------- +// +void CThumbnailMDSQueryTask::SetUpdateToDb(const TBool& aUpdateToDb ) + { + TN_DEBUG2( "CThumbnailMDSQueryTask()::SetCompleteTask() aUpdateToDb == %d", aUpdateToDb); + iUpdateToDb = aUpdateToDb; + } diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailmemorycardobserver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailmemorycardobserver.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,120 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class to monitor when memory card status is changed + * +*/ + + +#include "thumbnailmemorycardobserver.h" +#include "thumbnaillog.h" + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CThumbnailMemoryCardObserver::NewL() +// Two-phased constructor. +// --------------------------------------------------------------------------- +// +CThumbnailMemoryCardObserver* CThumbnailMemoryCardObserver::NewL( CThumbnailServer* aServer, RFs& aFs ) + { + CThumbnailMemoryCardObserver* self = new( ELeave ) + CThumbnailMemoryCardObserver( aServer, aFs ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// CThumbnailMemoryCardObserver::CThumbnailMemoryCardObserver() +// C++ default constructor can NOT contain any code, that might leave. +// --------------------------------------------------------------------------- +// +CThumbnailMemoryCardObserver::CThumbnailMemoryCardObserver( CThumbnailServer* aServer, RFs& aFs ): + CActive( CActive::EPriorityStandard ), iServer( aServer ), iFs( aFs ) + { + TN_DEBUG1( "CThumbnailMemoryCardObserver::CThumbnailMemoryCardObserver()" + ); + CActiveScheduler::Add( this ); + StartNotify(); + } + + +// --------------------------------------------------------------------------- +// CThumbnailMemoryCardObserver::ConstructL() +// Symbian 2nd phase constructor can leave. +// --------------------------------------------------------------------------- +// +void CThumbnailMemoryCardObserver::ConstructL() + { + // No implementation required + } + + +// --------------------------------------------------------------------------- +// CThumbnailTaskProcessor::~CThumbnailTaskProcessor() +// Destructor. +// --------------------------------------------------------------------------- +// +CThumbnailMemoryCardObserver::~CThumbnailMemoryCardObserver() + { + TN_DEBUG1( + "CThumbnailMemoryCardObserver::~CThumbnailMemoryCardObserver()" ); + Cancel(); + } + + +// --------------------------------------------------------------------------- +// CThumbnailMemoryCardObserver::RunL() +// --------------------------------------------------------------------------- +// +void CThumbnailMemoryCardObserver::RunL() + { + TN_DEBUG2( "CThumbnailMemoryCardObserver::RunL() iStatus = %d", iStatus.Int()); + if ( !iStatus.Int() ) + { + // trap because nothing could be done in RunError + TRAP_IGNORE( iServer->MemoryCardStatusChangedL() ); + StartNotify(); + } + } + +// --------------------------------------------------------------------------- +// CThumbnailMemoryCardObserver::DoCancel() +// --------------------------------------------------------------------------- +// +void CThumbnailMemoryCardObserver::DoCancel() + { + iFs.NotifyChangeCancel(); + } + +// --------------------------------------------------------------------------- +// CThumbnailMemoryCardObserver::StartNotify() +// --------------------------------------------------------------------------- +// +void CThumbnailMemoryCardObserver::StartNotify() + { + TN_DEBUG1( "CThumbnailMemoryCardObserver::StartNotify()" ); + + if (IsActive()) + { + Cancel(); + } + + iFs.NotifyChange(ENotifyDisk, iStatus); + SetActive(); + } + +// End of file diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailprovider.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailprovider.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,89 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Base class for thumbnail provider plug-ins + * +*/ + + +#include "thumbnailprovider.h" +#include "thumbnaillog.h" + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// Construct new CThumbnailProvider implementation instance via ECom +// --------------------------------------------------------------------------- +// +CThumbnailProvider* CThumbnailProvider::NewL( TUid aUid ) + { + TAny* interface = REComSession::CreateImplementationL( aUid, _FOFF( + CThumbnailProvider, iDtor_ID_Key )); + CThumbnailProvider* ret = reinterpret_cast < CThumbnailProvider* > ( + interface ); + ret->iUid = aUid; + return ret; + } + + +// --------------------------------------------------------------------------- +// Get the UID of the provider +// --------------------------------------------------------------------------- +// +TUid CThumbnailProvider::Uid() + { + return iUid; + } + + +// --------------------------------------------------------------------------- +// CThumbnailProvider::SetObserver() +// --------------------------------------------------------------------------- +// +void CThumbnailProvider::SetObserver( MThumbnailProviderObserver& aObserver ) + { + iObserver = &aObserver; + } + + +// --------------------------------------------------------------------------- +// CThumbnailProvider::Reset() +// --------------------------------------------------------------------------- +// +void CThumbnailProvider::Reset() + { + iTargetSize = TSize(); + iCroppedTargetSize = TSize(); + } + + +// --------------------------------------------------------------------------- +// CThumbnailProvider::SetTargetSize() +// --------------------------------------------------------------------------- +// +void CThumbnailProvider::SetTargetSize( const TSize& aSize ) + { + iTargetSize = aSize; + } + + +// --------------------------------------------------------------------------- +// CThumbnailProvider::SetCroppedTargetSize() +// --------------------------------------------------------------------------- +// +void CThumbnailProvider::SetCroppedTargetSize( const TSize& aCroppedSize ) + { + iCroppedTargetSize = aCroppedSize; + } + +// End of file diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailscaletask.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailscaletask.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,430 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Task for scaling thumbnails. + * +*/ + + +#include +#include +#include +#include +#include + +#include "thumbnailscaletask.h" +#include "thumbnailprovider.h" +#include "thumbnailserver.h" +#include "thumbnailmanagerconstants.h" +#include "thumbnaillog.h" +#include "thumbnailpanic.h" + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CThumbnailScaleTask::NewL() +// Two-phased constructor. +// --------------------------------------------------------------------------- +// +CThumbnailScaleTask* CThumbnailScaleTask::NewL( CThumbnailTaskProcessor& + aProcessor, CThumbnailServer& aServer, const TDesC& aFilename, CFbsBitmap* + aBitmap, const TSize& aOriginalSize, const TSize& aTargetSize, TBool aCrop, + TDisplayMode aDisplayMode, TInt aPriority, const TDesC& aTargetUri, + const TThumbnailSize aThumbnailSize, const TThumbnailId aThumbnailId, + TBool aBitmapToPool, const TBool aEXIF) + { + // We take ownership of aBitmap + CleanupStack::PushL( aBitmap ); + CThumbnailScaleTask* self = new( ELeave )CThumbnailScaleTask( aProcessor, + aServer, aFilename, aBitmap, aOriginalSize, aTargetSize, aCrop, + aDisplayMode, aPriority, aTargetUri, aThumbnailSize, aThumbnailId, + aBitmapToPool, aEXIF); + CleanupStack::Pop( aBitmap ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// CThumbnailScaleTask::CThumbnailScaleTask() +// C++ default constructor can NOT contain any code, that might leave. +// --------------------------------------------------------------------------- +// +CThumbnailScaleTask::CThumbnailScaleTask( CThumbnailTaskProcessor& aProcessor, + CThumbnailServer& aServer, const TDesC& aFilename, CFbsBitmap* aBitmap, + const TSize& aOriginalSize, const TSize& aTargetSize, TBool aCrop, + TDisplayMode aDisplayMode, TInt aPriority, const TDesC& aTargetUri, + const TThumbnailSize aThumbnailSize, const TThumbnailId aThumbnailId, + TBool aBitmapToPool, const TBool aEXIF): + CThumbnailTask( aProcessor, aPriority ), iServer( aServer ), iOwnBitmap( aBitmap ), + iOriginalSize( aOriginalSize ), iTargetSize( aTargetSize ), iCrop( aCrop ), + iDisplayMode( aDisplayMode ), iFilename( aFilename ), iTargetUri( aTargetUri ), + iThumbnailSize(aThumbnailSize), iThumbnailId(aThumbnailId), + iBitmapToPool(aBitmapToPool), iEXIF(aEXIF) + { + TN_DEBUG2( "CThumbnailScaleTask(0x%08x)::CThumbnailScaleTask()", this ); + } + + +// --------------------------------------------------------------------------- +// CThumbnailScaleTask::ConstructL() +// Symbian 2nd phase constructor can leave. +// --------------------------------------------------------------------------- +// +void CThumbnailScaleTask::ConstructL() + { + iServer.AddBitmapToPoolL( NULL, iOwnBitmap ); + + // Successfully added bitmap to pool, we are no longer responsible for + // deleting it directly. + iBitmap = iOwnBitmap; + iOwnBitmap = NULL; + iBitmapInPool = ETrue; + + iScaledBitmap = NULL; + iScaledBitmapHandle = 0; + } + + +// --------------------------------------------------------------------------- +// CThumbnailScaleTask::~CThumbnailScaleTask() +// Destructor. +// --------------------------------------------------------------------------- +// +CThumbnailScaleTask::~CThumbnailScaleTask() + { + iServer.CancelScale(); + + if ( iBitmapInPool && iBitmap ) + { + TN_DEBUG1("CThumbnailScaleTask()::~CThumbnailScaleTask() delete original bitmap from pool"); + + // Original bitmap is owned by server, decrease reference count + iServer.DeleteBitmapFromPool( iBitmap->Handle()); + } + + if ( iScaledBitmapHandle ) + { + TN_DEBUG1("CThumbnailScaleTask()::~CThumbnailScaleTask() delete scaled bitmap from pool"); + + // Scaled bitmap is owned by server, decrease reference count + iServer.DeleteBitmapFromPool( iScaledBitmapHandle ); + } + + // Scaled bitmap is owned by us, delete now + delete iScaledBitmap; + } + + +// --------------------------------------------------------------------------- +// CThumbnailScaleTask::StartL() +// --------------------------------------------------------------------------- +// +void CThumbnailScaleTask::StartL() + { + TN_DEBUG2( "CThumbnailScaleTask(0x%08x)::StartL()", this ); + + CThumbnailTask::StartL(); + + if ( !iCrop ) + { + // target size at max, keep aspect ratio + CalculateTargetSize(); + } + else + { + // exact target size, crop excess + CalculateCropRectangle(); + } + +#ifdef _DEBUG + aStart.UniversalTime(); +#endif + + delete iScaledBitmap; + iScaledBitmap = NULL; + iScaledBitmap = new( ELeave )CFbsBitmap(); + + TSize bitmapSize = iBitmap->SizeInPixels(); + + if(bitmapSize.iHeight == iTargetSize.iHeight && bitmapSize.iWidth == iTargetSize.iWidth) + { + // copy bitmap 1:1 + User::LeaveIfError( iScaledBitmap->Create( bitmapSize, iBitmap->DisplayMode() )); + CFbsBitmapDevice* device = CFbsBitmapDevice::NewL(iScaledBitmap); + CleanupStack::PushL(device); + CFbsBitGc* gc = NULL; + User::LeaveIfError(device->CreateContext(gc)); + CleanupStack::PushL(gc); + gc->BitBlt(TPoint(0, 0), iBitmap); + CleanupStack::PopAndDestroy(2, device); // gc + + TN_DEBUG2( "CThumbnailScaleTask(0x%08x)::StartL() - no need for scaling", this); + TRAPD( err, StoreAndCompleteL()); + Complete( err ); + ResetMessageData(); + } + else + { + TN_DEBUG2( "CThumbnailScaleTask(0x%08x)::StartL() - scaling", this); + User::LeaveIfError( iScaledBitmap->Create( iTargetSize, iBitmap->DisplayMode() )); + iServer.ScaleBitmapL( iStatus, * iBitmap, * iScaledBitmap, iCropRectangle ); + SetActive(); + } + + } + + +// --------------------------------------------------------------------------- +// CThumbnailScaleTask::RunL() +// --------------------------------------------------------------------------- +// +void CThumbnailScaleTask::RunL() + { + TInt err = iStatus.Int(); + + TN_DEBUG3( "CThumbnailScaleTask(0x%08x)::RunL() err=%d)", this, err ); + + #ifdef _DEBUG + aStop.UniversalTime(); + TN_DEBUG2( "CThumbnailScaleTask::RunL() scale took %d ms", (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000); + #endif + + if ( !err ) + { + TRAP( err, StoreAndCompleteL()); + } + + Complete( err ); + ResetMessageData(); + } + + +// --------------------------------------------------------------------------- +// CThumbnailScaleTask::DoCancel() +// --------------------------------------------------------------------------- +// +void CThumbnailScaleTask::DoCancel() + { + TN_DEBUG2( "CThumbnailScaleTask(0x%08x)::DoCancel()", this ); + iServer.CancelScale(); + } + + +// --------------------------------------------------------------------------- +// Calculates target size to be used for the thumbnail +// --------------------------------------------------------------------------- +// +void CThumbnailScaleTask::CalculateTargetSize() + { + __ASSERT_DEBUG( iOriginalSize.iHeight && iTargetSize.iHeight, + ThumbnailPanic( EThumbnailBadSize )); + + if ( (iThumbnailSize == EFullScreenThumbnailSize || + iThumbnailSize == EImageFullScreenThumbnailSize || + iThumbnailSize == EVideoFullScreenThumbnailSize || + iThumbnailSize == EAudioFullScreenThumbnailSize) && + iOriginalSize.iHeight < iTargetSize.iHeight && + iOriginalSize.iWidth < iTargetSize.iWidth ) + { + // do not upscale fullscreen thumbs + iTargetSize = iOriginalSize; + } + else if ( iOriginalSize.iHeight && iTargetSize.iHeight ) + { + const TReal32 srcAspect = static_cast < TReal32 > ( + iOriginalSize.iWidth ) / iOriginalSize.iHeight; + + // scale to maximum size within target size + if ( (iTargetSize.iHeight * srcAspect) <= iTargetSize.iWidth ) + { + TReal trg = 0; + TReal src( iTargetSize.iHeight * srcAspect ); + Math::Round( trg, src, 0 ); + iTargetSize.SetSize( trg, iTargetSize.iHeight ); + } + else + { + TReal trg; + TReal src( iTargetSize.iWidth / srcAspect ); + Math::Round( trg, src, 0 ); + iTargetSize.SetSize( iTargetSize.iWidth, trg ); + } + } + else + { + iTargetSize.SetSize( 0, 0 ); + } + iCropRectangle.SetRect( TPoint(), iBitmap->SizeInPixels()); + } + + +// --------------------------------------------------------------------------- +// Calculates target size to be used for the thumbnail +// --------------------------------------------------------------------------- +// +void CThumbnailScaleTask::CalculateCropRectangle() + { + const TSize srcSize = iBitmap->SizeInPixels(); + + __ASSERT_DEBUG( srcSize.iHeight && iTargetSize.iHeight, ThumbnailPanic( + EThumbnailBadSize )); + + if ( srcSize.iHeight && iTargetSize.iHeight ) + { + const TReal32 srcAspect = static_cast < TReal32 > ( srcSize.iWidth ) / + srcSize.iHeight; + const TReal32 reqAspect = static_cast < TReal32 > ( iTargetSize.iWidth ) + / iTargetSize.iHeight; + + if ( (iTargetSize.iHeight * srcAspect) > iTargetSize.iWidth ) + { + // Thumbnail is wider than requested and we crop + // some of the right and left parts. + TReal trg; + TReal src( srcSize.iHeight* reqAspect ); + Math::Round( trg, src, 0 ); + const TSize cropSize( trg, srcSize.iHeight ); + iCropRectangle.iTl.SetXY(( srcSize.iWidth - cropSize.iWidth ) / 2, 0 ); + iCropRectangle.SetSize( cropSize ); + } + else + { + // Thumbnail is taller than requested and we crop + // some of the top and bottom parts. + TReal trg; + TReal src( srcSize.iWidth / reqAspect ); + Math::Round( trg, src, 0 ); + const TSize cropSize( srcSize.iWidth, trg ); + iCropRectangle.iTl.SetXY(0, ( srcSize.iHeight - cropSize.iHeight ) / 2 ); + iCropRectangle.SetSize( cropSize ); + } + + } + else + { + iTargetSize.SetSize( 0, 0 ); + } + } + +// --------------------------------------------------------------------------- +// CThumbnailScaleTask::StoreAndCompleteL() +// --------------------------------------------------------------------------- +// +void CThumbnailScaleTask::StoreAndCompleteL() + { + TN_DEBUG5( "CThumbnailScaleTask(0x%08x)::StoreAndCompleteL() iFilename=%S, iBitmap=0x%08x, iScaledBitmap=0x%08x)", + this, &iFilename, iBitmap, iScaledBitmap ); + + // do not store TN if quality is too low eg. orignal size of image is smaller than requested size + // (do not store upscaled images) + if ( iTargetSize.iWidth >= iOriginalSize.iWidth && + iTargetSize.iHeight >= iOriginalSize.iHeight && iEXIF) + { + TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() too low quality"); + //don't store preview image + iDoStore = EFalse; + } + + TN_DEBUG3("CThumbnailScaleTask(0x%08x)::StoreAndCompleteL() iDoStore = %d", this, iDoStore); + + if ( iDoStore ) + { + if (iTargetUri != KNullDesC) + { + if (iFilename != KNullDesC && iFilename.CompareF(iTargetUri) == 0) + { + // filename and target URI match, so thumb created from associated path + iServer.StoreThumbnailL( iTargetUri, iScaledBitmap, iOriginalSize, iCrop, iThumbnailSize, iThumbnailId, ETrue ); + } + else + { + // thumb not created from associated path + iServer.StoreThumbnailL( iTargetUri, iScaledBitmap, iOriginalSize, iCrop, iThumbnailSize, iThumbnailId, EFalse, EFalse ); + } + } + else if (iFilename != KNullDesC) + { + iServer.StoreThumbnailL( iFilename, iScaledBitmap, iOriginalSize, iCrop, iThumbnailSize, iThumbnailId, ETrue ); + } + } + + if ( iMessage.Handle() ) + { + TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() scaled bitmap handle to params"); + + TThumbnailRequestParams& params = iParamsBuf(); + iMessage.ReadL( 0, iParamsBuf ); + params.iBitmapHandle = iScaledBitmap->Handle(); + + // if need to add scaled bitmap to pool + if (iBitmapToPool) + { + TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() scaled bitmap to pool"); + + iServer.AddBitmapToPoolL( iRequestId.iSession, iScaledBitmap ); + iScaledBitmapHandle = params.iBitmapHandle; + } + + if( params.iQualityPreference == CThumbnailManager::EOptimizeForQualityWithPreview + && iEXIF && !iDoStore) + { + // this is upscaled preview image + params.iControlFlags = EThumbnailPreviewThumbnail; + TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() EThumbnailPreviewThumbnail"); + } + + // Server owns the bitmap now. If the code below leaves, we will + // release the bitmap reference in destructor using iScaledBitmapHandle. + if (iBitmapToPool) + { + iScaledBitmap = NULL; + } + + TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() write params to message"); + + // pass bitmap handle to client + iMessage.WriteL( 0, iParamsBuf ); + + // Successfully completed the message. The client will send + // EReleaseBitmap message later to delete the bitmap from pool. + // CThumbnailScaleTask is no longer responsible for that. + iScaledBitmapHandle = 0; + } + + TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() - end"); + } + + +// --------------------------------------------------------------------------- +// CThumbnailScaleTask::StoreAndCompleteL() +// Changes priority of the task. +// --------------------------------------------------------------------------- +// +void CThumbnailScaleTask::ChangeTaskPriority( TInt /*aNewPriority*/ ) + { + // The priority of scale tasks is fixed. Do nothing. + } + +// --------------------------------------------------------------------------- +// CThumbnailScaleTask::SetDoStore() +// Changes the store flag +// --------------------------------------------------------------------------- +// +void CThumbnailScaleTask::SetDoStore( TBool aDoStore ) + { + iDoStore = aDoStore; + } diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserver.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,1604 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Thumbnail server + * +*/ + + +#include +#include +#include +#include +#include +#include +#include + +#include "thumbnailserver.h" +#include "thumbnailtaskprocessor.h" +#include "thumbnailserversession.h" +#include "thumbnailmanagerconstants.h" +#include "thumbnailmanageruids.hrh" +#include "thumbnaillog.h" +#include "thumbnailstore.h" +#include "thumbnaildiskunmountobserver.h" +#include "thumbnailpanic.h" +#include "thumbnailcenrep.h" +#include "thumbnailmemorycardobserver.h" +#include "tnmgetimei.h" +#include "thumbnailformatobserver.h" + + +_LIT8( KThumbnailMimeWildCard, "*" ); +_LIT8( KThumbnailMimeImage, "image" ); +_LIT8( KThumbnailMimeVideo, "video" ); +_LIT8( KThumbnailMimeAudio, "audio" ); + +const TChar KThumbnailMimeSeparatorChar = '/'; +const TChar KThumbnailMimeWildCardChar = '*'; +const TChar KThumbnailMimeTypeSeparatorChar = ' '; + +// ---------------------------------------------------------------------------------------- +// Server's policy here +// ---------------------------------------------------------------------------------------- + +// ---------------------------------------------------------------------------------------- +// Total number of ranges +// ---------------------------------------------------------------------------------------- +const TUint KThumbnailServerRangeCount = 17; + +// ---------------------------------------------------------------------------------------- +// Definition of the ranges +// ---------------------------------------------------------------------------------------- +const TInt KThumbnailServerRanges[KThumbnailServerRangeCount] = +{ + ERequestThumbByPathAsync, + ERequestThumbByFileHandleAsync, + EReleaseBitmap, + ECancelRequest, + EChangePriority, + ECreateThumbnails, + EDeleteThumbnails, + EGetMimeTypeBufferSize, + EGetMimeTypeList, + ERequestThumbByIdAsync, + ERequestThumbByBufferAsync, + ERequestSetThumbnailByBuffer, + EDeleteThumbnailsById, + EReserved1, + EUpdateThumbnails, + ERequestSetThumbnailByBitmap, + EThumbnailServerRequestCount, +}; + +// ---------------------------------------------------------------------------------------- +// Policy to implement for each of the above ranges +// ---------------------------------------------------------------------------------------- +const TUint8 KThumbnailServerElementsIndex[KThumbnailServerRangeCount] = + { + CPolicyServer::ECustomCheck, // ERequestThumbByPathAsync + CPolicyServer::ECustomCheck, // ERequestThumbByFileHandleAsync + CPolicyServer::ECustomCheck, // EReleaseBitmap + CPolicyServer::ECustomCheck, // ECancelRequest + CPolicyServer::ECustomCheck, // EChangePriority + CPolicyServer::ECustomCheck, // ECreateThumbnails + CPolicyServer::ECustomCheck, // EDeleteThumbnails + CPolicyServer::ECustomCheck, // EGetMimeTypeBufferSize + CPolicyServer::ECustomCheck, // EGetMimeTypeList + CPolicyServer::ECustomCheck, // ERequestThumbByIdAsync + CPolicyServer::ECustomCheck, // ERequestThumbByBufferAsync + CPolicyServer::ECustomCheck, // ERequestSetThumbnailByBuffer + CPolicyServer::ECustomCheck, // EDeleteThumbnailsById + CPolicyServer::ECustomCheck, + CPolicyServer::ECustomCheck, // EUpdateThumbnails + CPolicyServer::ECustomCheck, // ERequestSetThumbnailByBitmap + CPolicyServer::ECustomCheck, // EThumbnailServerRequestCount + }; + +// ---------------------------------------------------------------------------------------- +// Package all the above together into a policy +// ---------------------------------------------------------------------------------------- +const CPolicyServer::TPolicy KThumbnailServerPolicy = + { + CPolicyServer::EAlwaysPass, + KThumbnailServerRangeCount, // number of ranges + KThumbnailServerRanges, // ranges array + KThumbnailServerElementsIndex, // elements<->ranges index + NULL + // array of elements + }; + +// --------------------------------------------------------------------------- +// CustomSecurityCheckL +// --------------------------------------------------------------------------- +// +CPolicyServer::TCustomResult CThumbnailServer::CustomSecurityCheckL( + const RMessage2& aMsg, TInt& /*aAction*/, TSecurityInfo& /*aMissing*/ ) + { + CPolicyServer::TCustomResult securityCheckResult = EFail; + + switch ( aMsg.Function() ) + { + case ERequestThumbByPathAsync: + case ERequestThumbByFileHandleAsync: + case ERequestThumbByIdAsync: + case ERequestThumbByBufferAsync: + { + securityCheckResult = EPass; + break; + } + case EReleaseBitmap: + case ECancelRequest: + case EChangePriority: + case ECreateThumbnails: + case EDeleteThumbnails: + case EGetMimeTypeBufferSize: + case EGetMimeTypeList: + case ERequestSetThumbnailByBuffer: + case EDeleteThumbnailsById: + case EUpdateThumbnails: + case ERequestSetThumbnailByBitmap: + { + if( aMsg.HasCapability( ECapabilityReadDeviceData ) && + aMsg.HasCapability( ECapabilityWriteDeviceData ) ) + { + securityCheckResult = EPass; + } + break; + } + + case EReserved1: + case EThumbnailServerRequestCount: + default: + { + securityCheckResult = EFail; + } + } + + return securityCheckResult; + } +// --------------------------------------------------------------------------- +// CustomFailureActionL +// --------------------------------------------------------------------------- +// +CPolicyServer::TCustomResult CThumbnailServer::CustomFailureActionL( + const RMessage2& /*aMsg*/, TInt /*aAction*/, const TSecurityInfo& /*aMissing*/ ) + { + // Not used + return EFail; + } + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CThumbnailServer::CThumbnailServer() +// C++ default constructor can NOT contain any code, that might leave. +// --------------------------------------------------------------------------- +// +CThumbnailServer::CThumbnailServer(): CPolicyServer( CActive::EPriorityStandard, + KThumbnailServerPolicy, EUnsharableSessions ) + { + // No implementation required + } + +// --------------------------------------------------------------------------- +// CThumbnailServer::NewL() +// Two-phased constructor. +// --------------------------------------------------------------------------- +// +CThumbnailServer* CThumbnailServer::NewL() + { + CThumbnailServer* self = new( ELeave )CThumbnailServer(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// CThumbnailServer::ConstructL() +// Symbian 2nd phase constructor can leave. +// --------------------------------------------------------------------------- +// +void CThumbnailServer::ConstructL() + { + TN_DEBUG1( "CThumbnailServer::ConstructL()" ); + +#ifdef _DEBUG + iPlaceholderCounter = 0; +#endif + + // create shutdown observer + iShutdownObserver = CTMShutdownObserver::NewL( *this, KTMPSNotification, KShutdown, ETrue ); + iShutdown = EFalse; + + // connect to MDS + iMdESession = CMdESession::NewL( *this ); + + User::LeaveIfError( iFbsSession.Connect()); + User::LeaveIfError( Start( KThumbnailServerName )); + User::LeaveIfError( iFs.Connect()); + iProcessor = CThumbnailTaskProcessor::NewL(); + REComSession::FinalClose(); + REComSession::ListImplementationsL( TUid::Uid( THUMBNAIL_PROVIDER_IF_UID ), + iPluginInfoArray ); + + CTnmgetimei * imeigetter = CTnmgetimei::NewLC(); + + iImei = imeigetter->GetIMEI(); + CleanupStack::PopAndDestroy(imeigetter); + + iFs.CreatePrivatePath(EDriveC); + iFs.SetSessionToPrivate(EDriveC); + + iCenrep = CThumbnailCenRep::NewL(); + + iPersistentSizes = iCenrep->GetPersistentSizes(); + + iMMCObserver = CThumbnailMemoryCardObserver::NewL( this, iFs ); + + iFormatObserver = CThumbnailFormatObserver::NewL( this ); + + iFormatting = EFalse; + + OpenStoresL(); + + AddUnmountObserversL(); + } + + +// --------------------------------------------------------------------------- +// Destructor. +// --------------------------------------------------------------------------- +// +CThumbnailServer::~CThumbnailServer() + { + TN_DEBUG1( "CThumbnailServer::~CThumbnailServer()" ); + + iShutdown = ETrue; + + delete iShutdownObserver; + delete iProcessor; + + if (iMdESession) + { + delete iMdESession; + } + + ResetAndDestroyHashMap < TInt, CThumbnailStore > ( iStores ); + ResetAndDestroyHashMap < TInt32, CThumbnailProvider > ( iProviders ); + + iUnmountObservers.ResetAndDestroy(); + delete iMMCObserver; + delete iFormatObserver; + + THashMapIter < TInt, TThumbnailBitmapRef > bpiter( iBitmapPool ); + + // const pointer to a non-const object + const TThumbnailBitmapRef* ref = bpiter.NextValue(); + + while ( ref ) + { + delete ref->iBitmap; + ref = bpiter.NextValue(); + } + + delete iScaler; + iBitmapPool.Close(); + iFbsSession.Disconnect(); + iRecognizer.Close(); + iPluginInfoArray.ResetAndDestroy(); + delete iCenrep; + iFs.Close(); + REComSession::FinalClose(); + } + +// ----------------------------------------------------------------------------- +// CThumbnailServer::HandleSessionOpened +// ----------------------------------------------------------------------------- +// +void CThumbnailServer::HandleSessionOpened( CMdESession& /* aSession */, TInt /*aError*/ ) + { + TN_DEBUG1( "CThumbnailServer::HandleSessionOpened"); + } + +// ----------------------------------------------------------------------------- +// CThumbnailServer::HandleSessionError +// ----------------------------------------------------------------------------- +// +void CThumbnailServer::HandleSessionError( CMdESession& /*aSession*/, TInt aError ) + { + if (aError != KErrNone) + { + TN_DEBUG2( "CThumbnailServer::HandleSessionError == %d", aError ); + } + } + +// ----------------------------------------------------------------------------- +// CThumbnailServer::NewSessionL() +// Creates new server session. +// ----------------------------------------------------------------------------- +// +CSession2* CThumbnailServer::NewSessionL( const TVersion& aVersion, const + RMessage2& /*aMessage*/ )const + { + const TVersion v( KThumbnailServerMajorVersionNumber, + KThumbnailServerMinorVersionNumber, KThumbnailServerBuildVersionNumber ) + ; + if ( !User::QueryVersionSupported( v, aVersion )) + { + User::Leave( KErrNotSupported ); + } + return new( ELeave )CThumbnailServerSession(); + } + + +// ----------------------------------------------------------------------------- +// CThumbnailServer::ThreadFunctionL() +// ----------------------------------------------------------------------------- +// +void CThumbnailServer::ThreadFunctionL() + { + // Rename own thread + User::LeaveIfError( User::RenameThread( KThumbnailServerName )); + + CThumbnailServer* server = NULL; + CActiveScheduler* scheduler = new( ELeave )CActiveScheduler(); + + if ( scheduler ) + { + CActiveScheduler::Install( scheduler ); + CleanupStack::PushL( scheduler ); + server = CThumbnailServer::NewL(); // Adds server in scheduler + // No need to CleanupStack::PushL(server) since no leaves can happen + RProcess::Rendezvous( KErrNone ); + TN_DEBUG1( + "CThumbnailServer::ThreadFunctionL() -- CActiveScheduler::Start() in" ); + CActiveScheduler::Start(); + TN_DEBUG1( + "CThumbnailServer::ThreadFunctionL() -- CActiveScheduler::Start() out" ); + // Comes here if server gets shut down + delete server; + CleanupStack::PopAndDestroy( scheduler ); + } + } + + +// ----------------------------------------------------------------------------- +// CThumbnailServer::AddSession() +// ----------------------------------------------------------------------------- +// +void CThumbnailServer::AddSession() + { + TN_DEBUG2( "CThumbnailServer::AddSession() iSessionCount was %d", + iSessionCount ); + iSessionCount++; + } + + +// ----------------------------------------------------------------------------- +// CThumbnailServer::DropSession() +// ----------------------------------------------------------------------------- +// +void CThumbnailServer::DropSession(CThumbnailServerSession* aSession) + { + TN_DEBUG2( "CThumbnailServer::DropSession() iSessionCount was %d", + iSessionCount ); + iSessionCount--; + + iProcessor->RemoveTasks(aSession); + if ( iSessionCount <= 0 ) + { + // rename thread + User::RenameThread( KThumbnailServerShutdown ); + + // server shutdown + if (!iShutdown) + { + CActiveScheduler::Stop(); + iShutdown = ETrue; + } + } + } + +// ----------------------------------------------------------------------------- +// CThumbnailServer::ShutdownNotification +// ----------------------------------------------------------------------------- +// +void CThumbnailServer::ShutdownNotification() + { + if (!iShutdown) + { + CActiveScheduler::Stop(); + iShutdown = ETrue; + } + } + + +// ----------------------------------------------------------------------------- +// CThumbnailServer::AddBitmapToPoolL() +// Add bitmap to bitmap pool. +// ----------------------------------------------------------------------------- +// +void CThumbnailServer::AddBitmapToPoolL( CThumbnailServerSession* aSession, + CFbsBitmap* aBitmap ) + { + if( !aBitmap ) + { + User::Leave( KErrArgument ); + } + TN_DEBUG4( + "CThumbnailServer::AddBitmapToPoolL(aSession=0x%08x, aBitmap=0x%08x), handle=%d", aSession, aBitmap, aBitmap->Handle()); + + TThumbnailBitmapRef* ptr = iBitmapPool.Find( aBitmap->Handle()); + + if ( ptr ) + { + ptr->iRefCount++; + } + else + { + TThumbnailBitmapRef ref; + ref.iBitmap = aBitmap; + ref.iSession = aSession; + ref.iRefCount = 1; // magic: first reference + iBitmapPool.InsertL( aBitmap->Handle(), ref ); + } + +#ifdef _DEBUG + TN_DEBUG2( "CThumbnailServer::BITMAP-POOL-COUNTER----------, Bitmaps = %d", iBitmapPool.Count() ); +#endif + } + + +// ----------------------------------------------------------------------------- +// CThumbnailServer::StoreThumbnailL() +// ----------------------------------------------------------------------------- +// +void CThumbnailServer::StoreThumbnailL( const TDesC& aPath, CFbsBitmap* aBitmap, + const TSize& aOriginalSize, const TBool aCropped, const TThumbnailSize aThumbnailSize, + const TThumbnailId aThumbnailId, const TBool aThumbFromPath, const TBool aCheckExist ) + { + TN_DEBUG6( + "CThumbnailServer::StoreBitmapL(aPath=%S, aBitmap=0x%08x, aOriginalSize=%dx%d, aCropped=%d)", &aPath, aBitmap, aOriginalSize.iWidth, aOriginalSize.iHeight, aCropped ); +#ifdef _DEBUG + TN_DEBUG2( "CThumbnailServer::StoreThumbnailL() - iScaledBitmap displaymode is %d", aBitmap->DisplayMode()); +#endif + + if (!aCheckExist) + { + StoreForPathL( aPath )->StoreThumbnailL( aPath, aBitmap, aOriginalSize, + aCropped, aThumbnailSize, aThumbnailId, aThumbFromPath ); + } + else if(BaflUtils::FileExists( iFs, aPath)) + { + StoreForPathL( aPath )->StoreThumbnailL( aPath, aBitmap, aOriginalSize, + aCropped, aThumbnailSize, aThumbnailId, aThumbFromPath ); + } + else + { + TN_DEBUG1( "CThumbnailServer::StoreThumbnailL() - file doesn't exists anymore, skip store!"); + } + } + + +// ----------------------------------------------------------------------------- +// CThumbnailServer::FetchThumbnailL() +// ----------------------------------------------------------------------------- +// +void CThumbnailServer::FetchThumbnailL( const TDesC& aPath, CFbsBitmap* & + aThumbnail, TDesC8* & aData, const TThumbnailSize aThumbnailSize, TSize &aOriginalSize ) + { + TN_DEBUG3( "CThumbnailServer::FetchThumbnailL(aPath=%S aThumbnailSize=%d)", &aPath, aThumbnailSize ); + + StoreForPathL( aPath )->FetchThumbnailL( aPath, aThumbnail, aData, aThumbnailSize, aOriginalSize); + } + + + +// ----------------------------------------------------------------------------- +// CThumbnailServer::DeleteBitmapFromPool() +// Removes bitmap from bitmap pool +// ----------------------------------------------------------------------------- +// +void CThumbnailServer::DeleteBitmapFromPool( TInt aHandle ) + { + TN_DEBUG2( "CThumbnailServer::DeleteBitmapFromPool(%d)", aHandle ); + + TThumbnailBitmapRef* ptr = iBitmapPool.Find( aHandle ); + if ( ptr ) + { + ptr->iRefCount--; + if ( !ptr->iRefCount ) + { + TN_DEBUG3( + "CThumbnailServer::DeleteBitmapFromPool(%d) -- deleting 0x%08x)", aHandle, ptr ); + delete ptr->iBitmap; + ptr->iBitmap = NULL; + iBitmapPool.Remove( aHandle ); + } + else + { + TN_DEBUG3( + "CThumbnailServer::DeleteBitmapFromPool(%d) -- refcount now %d", + aHandle, ptr->iRefCount ); + } + } + else + { + TN_DEBUG2( "CThumbnailServer::DeleteBitmapFromPool(%d) -- not found!", + aHandle ); + } + } + + +// ----------------------------------------------------------------------------- +// Delete thumbnails for given object file +// ----------------------------------------------------------------------------- +// +void CThumbnailServer::DeleteThumbnailsL( const TDesC& aPath ) + { + TN_DEBUG2( "CThumbnailServer::DeleteThumbnailsL(%S)", &aPath); + + StoreForPathL( aPath )->DeleteThumbnailsL( aPath ); + } + + +// ----------------------------------------------------------------------------- +// Delete thumbnails by Id +// ----------------------------------------------------------------------------- +// +void CThumbnailServer::DeleteThumbnailsByIdL( const TThumbnailId aItemId ) + { + TN_DEBUG2( "CThumbnailServer::DeleteThumbnailsByIdL(%d)", aItemId); + +#ifdef _DEBUG + TTime aStart, aStop; + aStart.UniversalTime(); +#endif + + // no path available, can be any store + THashMapIter iter( iStores ); + CThumbnailStore* const *store = iter.NextValue(); + + while ( store ) + { + TInt err = KErrNone; + TRAP(err, ((CThumbnailStore*)(*store))->DeleteThumbnailsL(aItemId) ); + if (err == KErrNone) + { +#ifdef _DEBUG + aStop.UniversalTime(); + TN_DEBUG2( "CThumbnailStore::DeleteThumbnailsByIdL() took %d ms", (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000); +#endif + return; + } + store = iter.NextValue(); + } + } + + +// ----------------------------------------------------------------------------- +// CThumbnailServer::ResolveMimeTypeL() +// ----------------------------------------------------------------------------- +// +TDataType CThumbnailServer::ResolveMimeTypeL( RFile& aFile ) + { + TN_DEBUG1( "CThumbnailStore::ResolveMimeTypeL()"); + RFile tmp = aFile; + + // check if DRM + ContentAccess::CData* data = ContentAccess::CData::NewLC( + tmp, ContentAccess::KDefaultContentObject, ContentAccess::EPeek ); + + TInt filetype( 0 ); + TInt drm( 0 ); + User::LeaveIfError( data->GetAttribute( ContentAccess::EIsProtected, drm ) ); + data->GetAttribute( ContentAccess::EFileType, filetype ); + CleanupStack::PopAndDestroy(); + + //close aFile on leave + CleanupClosePushL( aFile ); + + if ( drm && filetype != ContentAccess::EOma1Dcf ) + { + // cannot handle other than Oma DRM 1.x files + TN_DEBUG1( "CThumbnailStore::ResolveMimeTypeL()- only OMA DRM 1.0 supported"); + User::Leave(KErrNotSupported); + } + + TDataRecognitionResult res; + if ( iRecognizer.Handle() == KNullHandle ) + { + // error using recognizer, (re)connect + User::LeaveIfError( iRecognizer.Connect()); + } + + User::LeaveIfError( iRecognizer.RecognizeData( aFile, res )); + + if ( res.iConfidence == CApaDataRecognizerType::ENotRecognized ) + { + // file type not supported + User::Leave( KErrNotSupported ); + } + + CleanupStack::Pop( &aFile ); + return res.iDataType; + } + +// ----------------------------------------------------------------------------- +// CThumbnailServer::ResolveProviderL() +// Resolves plugin to be used in thumbnail creation. +// ----------------------------------------------------------------------------- +// +CThumbnailProvider* CThumbnailServer::ResolveProviderL( const TDesC8& aMimeType + ) + { +#ifdef _DEBUG + TBuf < KMaxDataTypeLength > buf; // 16-bit descriptor for debug prints + buf.Copy( aMimeType ); + TN_DEBUG2( "CThumbnailServer::ResolveProviderL(%S)", &buf ); +#endif + + CThumbnailProvider* ret = NULL; + + TInt separatorPos = aMimeType.Locate( KThumbnailMimeSeparatorChar ); + TPtrC8 mediaType( aMimeType.Left( separatorPos )); + TPtrC8 subType( aMimeType.Mid( separatorPos + 1 )); // skip slash + + const TInt count = iPluginInfoArray.Count(); + for ( TInt i( 0 ); i < count && !ret; i++ ) + { + const TDesC8& opaqueData = iPluginInfoArray[i]->OpaqueData(); + TInt pSeparatorPos = opaqueData.Locate( KThumbnailMimeSeparatorChar ); + TPtrC8 pMediaType( opaqueData.Left( pSeparatorPos )); + TPtrC8 pSubType( opaqueData.Mid( pSeparatorPos + 1 )); // skip slash + + if ( !pMediaType.CompareF( mediaType )) + { + if ( !pSubType.CompareF( KThumbnailMimeWildCard ) || + !pSubType.CompareF( subType )) + { +#ifdef _DEBUG + TN_DEBUG3( + "CThumbnailServer::ResolveProviderL(%S) -- using provider 0x%08x", &buf, iPluginInfoArray[i]->ImplementationUid().iUid ); +#endif + ret = GetProviderL( iPluginInfoArray[i]->ImplementationUid()); + } + } + } + if ( !ret ) + { +#ifdef _DEBUG + TN_DEBUG2( + "CThumbnailServer::ResolveProviderL(%S) -- provider not found", + &buf ); +#endif + User::Leave( KErrNotSupported ); + } + return ret; + } + + +// ----------------------------------------------------------------------------- +// CThumbnailServer::GetProviderL() +// ----------------------------------------------------------------------------- +// +CThumbnailProvider* CThumbnailServer::GetProviderL( const TUid& aImplUid ) + { + CThumbnailProvider** resPtr = iProviders.Find( aImplUid.iUid ); + CThumbnailProvider* res = NULL; + if ( resPtr ) + { + // Use existing instance + res = * resPtr; + } + else + { + // Plug-in needs to be loaded + TN_DEBUG2( + "CThumbnailServer::GetProviderL() -- loading plug-in, UID 0x%08x", + aImplUid ); + res = CThumbnailProvider::NewL( aImplUid ); + TN_DEBUG1( "CThumbnailServer::GetProviderL() -- loading complete" ); + CleanupStack::PushL( res ); + iProviders.InsertL( aImplUid.iUid, res ); + CleanupStack::Pop( res ); + } + + return res; + } + + +// ----------------------------------------------------------------------------- +// CThumbnailServer::QueueTaskL() +// Adds thumbnailtask to processor queue. +// ----------------------------------------------------------------------------- +// +void CThumbnailServer::QueueTaskL( CThumbnailTask* aTask ) + { + __ASSERT_DEBUG(( aTask ), ThumbnailPanic( EThumbnailNullPointer )); + iProcessor->AddTaskL( aTask ); + } + + +// ----------------------------------------------------------------------------- +// CThumbnailServer::DequeTask() +// Removes thumbnailtask from processor queue. +// ----------------------------------------------------------------------------- +// +TInt CThumbnailServer::DequeTask( const TThumbnailServerRequestId& aRequestId ) + { + return iProcessor->RemoveTask( aRequestId ); + } + + +// ----------------------------------------------------------------------------- +// CThumbnailServer::ChangeTaskPriority() +// Changes priority of specific task. +// ----------------------------------------------------------------------------- +// +TInt CThumbnailServer::ChangeTaskPriority( const TThumbnailServerRequestId& + aRequestId, TInt aNewPriority ) + { + return iProcessor->ChangeTaskPriority( aRequestId, aNewPriority ); + } + + +// ----------------------------------------------------------------------------- +// CThumbnailServer::ScaleBitmapL() +// Used to scale image. +// ----------------------------------------------------------------------------- +// +void CThumbnailServer::ScaleBitmapL( TRequestStatus& aStatus, const CFbsBitmap& + aSource, CFbsBitmap& aDest, const TRect& aSourceRect ) + { + if ( !iScaler ) + { + iScaler = IHLScaler::CreateL(); + } + TRect destRect( TPoint(), aDest.SizeInPixels()); + User::LeaveIfError( iScaler->Scale( aStatus, aSource, aSourceRect, aDest, + destRect )); + } + + +// ----------------------------------------------------------------------------- +// CThumbnailServer::CancelScale() +// Cancels scaling task. +// ----------------------------------------------------------------------------- +// +void CThumbnailServer::CancelScale() + { + if ( iScaler ) + { + iScaler->CancelProcess(); + } + } + + +// ----------------------------------------------------------------------------- +// CThumbnailServer::Processor() +// Returns processor. +// ----------------------------------------------------------------------------- +// +CThumbnailTaskProcessor& CThumbnailServer::Processor() + { + __ASSERT_DEBUG(( iProcessor ), ThumbnailPanic( EThumbnailNullPointer )); + return * iProcessor; + } + +// ----------------------------------------------------------------------------- +// Get the thumbnail store instance, which is responsible for this drive +// ----------------------------------------------------------------------------- +// +CThumbnailStore* CThumbnailServer::StoreForDriveL( const TInt aDrive ) + { + TN_DEBUG2( "CThumbnailServer::StoreForDriveL() drive=%d", aDrive ); + CThumbnailStore** resPtr = iStores.Find( aDrive ); + CThumbnailStore* res = NULL; + + + if ( resPtr ) + { + res = * resPtr; + } + else + { + if(iFormatting) + { + TN_DEBUG1( "CThumbnailServer::StoreForDriveL() - FORMATTING! - ABORT"); + User::Leave( KErrNotSupported ); + } + TVolumeInfo volumeInfo; + TInt err = iFs.Volume( volumeInfo, aDrive ); + if ( err || volumeInfo.iDrive.iDriveAtt& KDriveAttRom || + volumeInfo.iDrive.iDriveAtt& KDriveAttRemote || + volumeInfo.iDrive.iMediaAtt& KMediaAttWriteProtected || + volumeInfo.iDrive.iMediaAtt& KMediaAttLocked ) + { + // We don't support ROM disks or remote mounts. Media + // must be read-write and not locked. + User::Leave( KErrAccessDenied); + } + + res = CThumbnailStore::NewL( iFs, aDrive, iImei, this ); + CleanupStack::PushL( res ); + iStores.InsertL( aDrive, res ); + res->SetPersistentSizes(iPersistentSizes); + CleanupStack::Pop( res ); + + for(TInt i = 0; iStartNotify(); + } + } + + return res; + } + + +// ----------------------------------------------------------------------------- +// CThumbnailServer::FetchThumbnailL() +// ----------------------------------------------------------------------------- +// +void CThumbnailServer::FetchThumbnailL( TThumbnailId aThumbnailId, CFbsBitmap* & + aThumbnail, TDesC8* & aData, TThumbnailSize aThumbnailSize, TSize &aOriginalSize ) + { + TN_DEBUG3( "CThumbnailServer::FetchThumbnailL(aThumbnailId=%d aThumbnailSize=%d)", aThumbnailId, aThumbnailSize ); + +#ifdef _DEBUG + TTime aStart, aStop; + aStart.UniversalTime(); + TInt roundCount = 1; +#endif + + THashMapIter storeIter(iStores); + + TN_DEBUG1( "CThumbnailServer::FetchThumbnailL() store iteration - begin"); + for (CThumbnailStore* const* pStore = storeIter.NextValue(); + pStore && aThumbnail == NULL ; + pStore = storeIter.NextValue()) + { + TN_DEBUG2( "CThumbnailServer::FetchThumbnailL() store iteration - round == %d ", roundCount++); + CThumbnailStore* const store = (CThumbnailStore*)(*pStore); + + TRAP_IGNORE( store->FetchThumbnailL( aThumbnailId, aThumbnail, aData, aThumbnailSize, aOriginalSize )); + + if ( aThumbnail || aData) + { // thumbnail found from DB + TN_DEBUG1( "CThumbnailServer::FetchThumbnailL() found" ); + break; + } +/* +#ifdef _DEBUG + aStop.UniversalTime(); + TN_DEBUG3( "CThumbnailServer::FetchThumbnailL() iteration round %d took %d ms", roundCount, (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000); +#endif +*/ + } + +#ifdef _DEBUG + aStop.UniversalTime(); + TN_DEBUG2( "CThumbnailServer::FetchThumbnailL() took %d ms", (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000); +#endif + + if ( !aThumbnail && !aData) + { // thumbnail not found from DB + TN_DEBUG1( "CThumbnailServer::FetchThumbnailL() not found" ); + User::Leave( KErrNotFound ); + } + } + + +// ----------------------------------------------------------------------------- +// Get the thumbnail store instance, which is responsible for the drive +// identified by given path +// ----------------------------------------------------------------------------- +// +CThumbnailStore* CThumbnailServer::StoreForPathL( const TDesC& aPath ) + { + if(aPath.Length() < 3 || aPath.Length() > KMaxPath) + { + User::Leave(KErrArgument); + } + TInt drive = 0; + User::LeaveIfError( RFs::CharToDrive( aPath[0], drive )); + return StoreForDriveL( drive ); + } + + +// --------------------------------------------------------------------------- +// CThumbnailStore::PersistentSizeL() +// --------------------------------------------------------------------------- +// +TThumbnailPersistentSize & CThumbnailServer::PersistentSizeL( TThumbnailSize + aThumbnailSize ) + { + if ( !iCenrep ) + { + iCenrep = CThumbnailCenRep::NewL(); + } + + return iCenrep->PersistentSizeL( aThumbnailSize ); + + } + +// ----------------------------------------------------------------------------- +// Open store for each mounted drive +// ----------------------------------------------------------------------------- +// +void CThumbnailServer::OpenStoresL() + { + // get list of mounted drives and open stores + TDriveList driveListInt; + TInt driveCountInt(0); + User::LeaveIfError(DriveInfo::GetUserVisibleDrives( + iFs, driveListInt, driveCountInt, KDriveAttInternal | KDriveAttRemovable )); + + for( TInt i = EDriveA; i <= EDriveZ && driveCountInt; i++ ) + { + if (driveListInt[i]) + { + TVolumeInfo volumeInfo; + TInt err = iFs.Volume( volumeInfo, i ); + + if (!err) + { + TN_DEBUG2( "CThumbnailServer::OpenStoresL() StoreForDriveL %d", i); + + // ignore errors + TRAP_IGNORE( StoreForDriveL( i )); + + // start also placeholder task + //AddPlaceholderTaskL(i); + + driveCountInt--; + } + } + } + + } + +// ----------------------------------------------------------------------------- +// Close the thumbnail store instance, which is responsible for this drive +// ----------------------------------------------------------------------------- +// +void CThumbnailServer::CloseStoreForDriveL( const TInt aDrive ) + { + TN_DEBUG2( "CThumbnailServer::CloseStoreForDriveL drive=%d", aDrive); + CThumbnailStore** store = iStores.Find( aDrive ); + + if (store) + { + delete *store; + iStores.Remove( aDrive ); + } + } + + +// --------------------------------------------------------------------------- +// CThumbnailStore::PersistentSizes() +// --------------------------------------------------------------------------- +// +RArray < TThumbnailPersistentSize > CThumbnailServer::PersistentSizesL() + { + return iPersistentSizes; + } + +void CThumbnailServer::GetMissingSizesAndIDsL( const TDesC& aPath, TInt aSourceType, RArray < + TThumbnailPersistentSize > & aMissingSizes, TBool& aMissingIDs ) + { + StoreForPathL( aPath )->GetMissingSizesAndIDsL( aPath, aSourceType, aMissingSizes, aMissingIDs ); + } + +// --------------------------------------------------------------------------- +// CThumbnailServer::Fs() +// --------------------------------------------------------------------------- +// +RFs& CThumbnailServer::Fs() + { + return iFs; + } + +// --------------------------------------------------------------------------- +// CThumbnailServer::AddUnmountObserversL() +// --------------------------------------------------------------------------- +// +void CThumbnailServer::AddUnmountObserversL() + { + TDriveList driveList; + TInt drive; + TDriveInfo driveInfo; + + iUnmountObservers.ResetAndDestroy(); + + User::LeaveIfError( iFs.DriveList(driveList) ); + + // search all drives + for( drive = EDriveA; drive <= EDriveZ; drive++ ) + { + if( !driveList[drive] ) + { + // If drive-list entry is zero, drive is not available + continue; + } + + TInt err = iFs.Drive(driveInfo, drive); + + // if removable drive, add observer + if (!err && driveInfo.iDriveAtt& KDriveAttRemovable) + { + TN_DEBUG2( "CThumbnailServer::AddOnMountObserver drive=%d", drive); + CThumbnailDiskUnmountObserver* obs = CThumbnailDiskUnmountObserver::NewL( iFs, drive, this ); + CleanupStack::PushL( obs ); + iUnmountObservers.AppendL( obs ); + CleanupStack::Pop( obs ); + } + } + } + +// --------------------------------------------------------------------------- +// CThumbnailServer::MemoryCardStatusChangedL() +// --------------------------------------------------------------------------- +// +void CThumbnailServer::MemoryCardStatusChangedL() + { + TN_DEBUG1( "CThumbnailServer::MemoryCardStatusChangedL in()" ); + TDriveList driveList; + TInt drive; + TVolumeInfo volumeInfo; + TDriveInfo driveInfo; + + User::LeaveIfError( iFs.DriveList(driveList) ); + + // search all drives + for( drive = EDriveA; drive <= EDriveZ; drive++ ) + { + if( !driveList[drive] ) + { + // If drive-list entry is zero, drive is not available + continue; + } + + TInt err = iFs.Volume(volumeInfo, drive); + TInt err_drive = iFs.Drive(driveInfo, drive); + + // mount -- if removable drive, add new store + if (!err && !err_drive && driveInfo.iDriveAtt& KDriveAttRemovable) + { + // ignore errors + TRAP_IGNORE( StoreForDriveL( drive )); + + } + + //dismount -- if removable drive, close store + else if(err && !err_drive && driveInfo.iDriveAtt& KDriveAttRemovable) + { + CloseStoreForDriveL( drive); + } + } + + TN_DEBUG1( "CThumbnailServer::MemoryCardStatusChangedL out()" ); + } + + +// ----------------------------------------------------------------------------- +// Get the required size (in characters) for a buffer that contains the +// list of supported MIME types +// ----------------------------------------------------------------------------- +// +TInt CThumbnailServer::GetMimeTypeBufferSize()const + { + TInt size = 0; + for ( TInt i = iPluginInfoArray.Count(); --i >= 0; ) + { + const TDesC8& opaqueData = iPluginInfoArray[i]->OpaqueData(); + size += opaqueData.Length(); + size++; // space for separator character + } + if ( size ) + { + size--; // no need for a separator character at the end + } + + return size; + } + +// ----------------------------------------------------------------------------- +// Get the list of supported MIME types and store them in the buffer +// allocated by the client. +// ----------------------------------------------------------------------------- +// +void CThumbnailServer::GetMimeTypeList( TDes& aBuffer )const + { + TBuf < KMaxDataTypeLength > buf; // needed for convert from TBuf8 to TBuf + aBuffer.Zero(); + const TInt count = iPluginInfoArray.Count(); + for ( TInt i = 0; i < count; i++ ) + { + const TDesC8& opaqueData = iPluginInfoArray[i]->OpaqueData(); + buf.Copy( opaqueData ); + aBuffer.Append( buf ); + aBuffer.Append( KThumbnailMimeTypeSeparatorChar ); + } + if ( count ) + { + // remove last separator char + aBuffer.SetLength( aBuffer.Length() - 1 ); + } + } + + +// ----------------------------------------------------------------------------- +// Updates thumbnails by given Id. +// ----------------------------------------------------------------------------- +// +TBool CThumbnailServer::UpdateThumbnailsL( const TThumbnailId aItemId, const TDesC& aPath, + const TInt /*aOrientation*/, const TInt64 aModified ) + { + TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL()"); + + // 1. check path change + // 2. check orientation change + // 3. check timestamp change + TBool pathChanged = EFalse; + TBool orientationChanged = EFalse; + TBool modifiedChanged = EFalse; + + CThumbnailStore* newstore = StoreForPathL( aPath ); + TInt err(KErrNone); + + // no path available, can be any store + THashMapIter iter( iStores ); + CThumbnailStore* const *store = iter.NextValue(); + + while ( store ) + { + err = KErrNone; + + TRAP(err, ((CThumbnailStore*)(*store))->FindStoreL( aItemId ) ); + + // no need to move thumbs to different store + if (err == KErrNone && *store == newstore) + { + pathChanged = ((CThumbnailStore*)(*store))->UpdateStoreL(aItemId, aPath); + + if (pathChanged) + { + TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - path updated"); + + // path updated, no need to check further + return ETrue; + } + else + { + // placeholder for orientation check + orientationChanged = EFalse; + + if (orientationChanged) + { + TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - orientation updated"); + + // orientation updated, no need to check further + return ETrue; + } + else + { + TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified ?"); + modifiedChanged = ((CThumbnailStore*)(*store))->CheckModifiedL(aItemId, aModified); + + if (modifiedChanged) + { + TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified YES"); + + // delete old thumbs + ((CThumbnailStore*)(*store))->DeleteThumbnailsL(aItemId); + + // need to create new thumbs + return EFalse; + } + else + { + TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified NO"); + + // not modified + return ETrue; + } + } + } + + } + // move to new store + else if (err == KErrNone && *store != newstore) + { + RArray < TThumbnailDatabaseData* >* thumbnails = NULL; + thumbnails = new (ELeave) RArray < TThumbnailDatabaseData* >; + CleanupClosePushL( *thumbnails ); + ((CThumbnailStore*)(*store))->FetchThumbnailsL(aItemId, *thumbnails); + newstore->StoreThumbnailsL(aPath, *thumbnails); + ((CThumbnailStore*)(*store))->DeleteThumbnailsL(aItemId); + CleanupStack::PopAndDestroy( thumbnails); + delete thumbnails; + thumbnails = NULL; + + TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - moved to different store"); + + // no need to check further + return ETrue; + } + + store = iter.NextValue(); + } + + TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - no thumbs found, create new"); + + return EFalse; + } + +// ----------------------------------------------------------------------------- +// CThumbnailServer::MimeTypeFromFileExt() +// ----------------------------------------------------------------------------- +// +TInt CThumbnailServer::MimeTypeFromFileExt( const TDesC& aFileName, TDataType& aMimeType ) + { + TBool found = ETrue; + TParsePtrC parse( aFileName ); + TPtrC ext( parse.Ext() ); + + if ( ext.CompareF( KJpegExt ) == 0 || ext.CompareF( KJpgExt ) == 0) + { + aMimeType = TDataType( KJpegMime ); + } + else if ( ext.CompareF( KJpeg2000Ext ) == 0 ) + { + aMimeType = TDataType( KJpeg2000Mime ); + } + else if ( ext.CompareF( KSvgExt ) == 0 ) + { + aMimeType = TDataType( KSvgMime ); + } + else if ( ext.CompareF( KGifExt ) == 0 ) + { + aMimeType = TDataType( KGifMime ); + } + else if ( ext.CompareF( KPngExt ) == 0 ) + { + aMimeType = TDataType( KPngMime ); + } + else if ( ext.CompareF( KMpgExt1 ) == 0 ) + { + aMimeType = TDataType( KMpgMime1 ); + } + else if ( ext.CompareF( KMpeg4Ext ) == 0 ) + { + aMimeType = TDataType( KMpeg4Mime ); + } + else if ( ext.CompareF( KMp4Ext ) == 0 ) + { + aMimeType = TDataType( KMp4Mime ); + } + else if ( ext.CompareF( KAviExt ) == 0 ) + { + aMimeType = TDataType( KAviMime ); + } + else if ( ext.CompareF( KMp3Ext ) == 0 ) + { + aMimeType = TDataType( KMp3Mime ); + } + else if ( ext.CompareF( KNonEmbeddArtExt ) == 0 ) + { + aMimeType = TDataType( KNonEmbeddArtMime ); + } + else if ( ext.CompareF( KAacExt ) == 0 ) + { + aMimeType = TDataType( KAacMime ); + } + else if ( ext.CompareF( KWmaExt ) == 0 ) + { + aMimeType = TDataType( KWmaMime ); + } + else if ( ext.CompareF( KBmpExt ) == 0 ) + { + aMimeType = TDataType( KBmpMime ); + } + else if ( ext.CompareF( K3gpExt ) == 0 ) + { + aMimeType = TDataType( KVideo3gppMime ); + } + else if ( ext.CompareF( KAmrExt ) == 0 ) + { + aMimeType = TDataType( KAudioAmrMime ); + } + else if ( ext.CompareF( KWmvExt ) == 0 ) + { + aMimeType = TDataType( KVideoWmvMime ); + } + else if ( ext.CompareF( KRealAudioExt ) == 0 ) + { + aMimeType = TDataType( KRealAudioMime ); + } + else if ( ext.CompareF( KPmRealAudioPluginExt ) == 0 ) + { + aMimeType = TDataType( KPmRealAudioPluginMime ); + } + else if ( ext.CompareF( KRealVideoExt ) == 0 ) + { + aMimeType = TDataType( KRealVideoMime ); + } + else if ( ext.CompareF( KM4aExt ) == 0 ) + { + aMimeType = TDataType( KM4aMime); + } + else if ( ext.CompareF( KM4vExt ) == 0 ) + { + aMimeType = TDataType( KMp4Mime); + } + else if ( ext.CompareF( KPmRealVideoPluginExt ) == 0 ) + { + aMimeType = TDataType( KPmRealVideoPluginMime ); + } + else if ( ext.CompareF( KPmRealVbVideoPluginExt ) == 0 ) + { + aMimeType = TDataType( KPmRealVbVideoPluginMime ); + } + else if ( ext.CompareF( KFlashVideoExt ) == 0 ) + { + aMimeType = TDataType( KFlashVideoMime ); + } + else if ( ext.CompareF( KMatroskaVideoExt ) == 0 ) + { + aMimeType = TDataType( KMatroskaVideoMime ); + } + else + { + aMimeType = TDataType( KNullDesC8 ); + found = EFalse; + } + + if (found) + { + return KErrNone; + } + + return KErrNotFound; + } + +// ----------------------------------------------------------------------------- +// CThumbnailServer::SourceTypeFromMimeType() +// ----------------------------------------------------------------------------- +// +TInt CThumbnailServer::SourceTypeFromMimeType( const TDataType& aMimeType ) + { + const TPtrC8 mimeType = aMimeType.Des8(); + + TInt separatorPos = mimeType.Locate( KThumbnailMimeSeparatorChar ); + TPtrC8 mediaType( mimeType.Left( separatorPos )); + + if (mediaType.Compare(KThumbnailMimeImage) == 0) + { + return TThumbnailPersistentSize::EImage; + } + else if (mediaType.Compare(KThumbnailMimeVideo) == 0) + { + return TThumbnailPersistentSize::EVideo; + } + else if (mediaType.Compare(KThumbnailMimeAudio) == 0) + { + return TThumbnailPersistentSize::EAudio; + } + + return TThumbnailPersistentSize::EUnknownSourceType; + } + +// ----------------------------------------------------------------------------- +// CThumbnailServer::SourceTypeFromSizeType() +// ----------------------------------------------------------------------------- +// +TInt CThumbnailServer::SourceTypeFromSizeType( const TInt aSizeType ) + { + TInt sourceType = 0; + + switch (aSizeType) + { + case EImageGridThumbnailSize: + case EImageListThumbnailSize: + case EImageFullScreenThumbnailSize: + sourceType = TThumbnailPersistentSize::EImage; + break; + case EVideoGridThumbnailSize: + case EVideoListThumbnailSize: + case EVideoFullScreenThumbnailSize: + sourceType = TThumbnailPersistentSize::EVideo; + break; + case EAudioGridThumbnailSize: + case EAudioListThumbnailSize: + case EAudioFullScreenThumbnailSize: + sourceType = TThumbnailPersistentSize::EAudio; + break; + default: + sourceType = TThumbnailPersistentSize::EUnknownSourceType; + } + + return sourceType; + } + +// ----------------------------------------------------------------------------- +// CThumbnailServer::SupportedMimeType() +// ----------------------------------------------------------------------------- +// +TBool CThumbnailServer::SupportedMimeType( const TDataType& aMimeType ) + { + const TPtrC8 mimeType = aMimeType.Des8(); + + if ( mimeType.CompareF( KJpegMime ) == 0 || + mimeType.CompareF( KJpeg2000Mime ) == 0 || + mimeType.CompareF( KGifMime ) == 0 || + mimeType.CompareF( KPngMime ) == 0 || + mimeType.CompareF( KBmpMime ) == 0 || + mimeType.CompareF( KMpgMime1 ) == 0 || + mimeType.CompareF( KMpeg4Mime ) == 0 || + mimeType.CompareF( KMp4Mime ) == 0 || + mimeType.CompareF( KAviMime ) == 0 || + mimeType.CompareF( KVideo3gppMime ) == 0 || + mimeType.CompareF( KVideoWmvMime ) == 0 || + mimeType.CompareF( KRealVideoMime ) == 0 || + mimeType.CompareF( KMp3Mime ) == 0 || + mimeType.CompareF( KAacMime ) == 0 || + mimeType.CompareF( KWmaMime ) == 0 || + mimeType.CompareF( KAudioAmrMime ) == 0 || + mimeType.CompareF( KRealAudioMime ) == 0 || + mimeType.CompareF( KM4aMime ) == 0 || + mimeType.CompareF( KFlashVideoMime ) == 0 || + mimeType.CompareF( KPmRealVideoPluginMime ) == 0 || + mimeType.CompareF( KPmRealVbVideoPluginMime ) == 0 || + mimeType.CompareF( KPmRealAudioPluginMime ) == 0 ) + { + return ETrue; + } + + return EFalse; + } + +// ----------------------------------------------------------------------------- +// CThumbnailServer::GetMdESession() +// ----------------------------------------------------------------------------- +// +CMdESession* CThumbnailServer::GetMdESession() + { + return iMdESession; + } + + +// ----------------------------------------------------------------------------- +// E32Main() +// ----------------------------------------------------------------------------- +// +TInt E32Main() + { + __UHEAP_MARK; + CTrapCleanup* cleanup = CTrapCleanup::New(); + TInt result = KErrNoMemory; + if ( cleanup ) + { + TRAP( result, CThumbnailServer::ThreadFunctionL()); + TN_DEBUG2( + "CThumbnailServer::E32Main() -- thread function out, result=%d", + result ); + delete cleanup; + } + if ( result != KErrNone ) + { + // Signal the client that server creation failed + TN_DEBUG1( "CThumbnailServer::E32Main() -- Rendezvous() in" ); + RProcess::Rendezvous( result ); + TN_DEBUG1( "CThumbnailServer::E32Main() -- Rendezvous() out" ); + } + + __UHEAP_MARKEND; + return result; + } + +// ----------------------------------------------------------------------------- +// Updates ID for thumbnails with given Path +// ----------------------------------------------------------------------------- +// +void CThumbnailServer::UpdateIDL( const TDesC& aPath, const TThumbnailId aNewId ) + { + TN_DEBUG3( "CThumbnailServer::UpdateIDL() aPath = %S aId = %d", &aPath, aNewId); + + CThumbnailStore* store = StoreForPathL( aPath ); + User::LeaveIfNull( store ); + store->UpdateStoreL( aPath, aNewId ); + } + +// ----------------------------------------------------------------------------- +// Closes stores for removable drives +// ----------------------------------------------------------------------------- +// + +void CThumbnailServer::CloseRemovableDrivesL() + { + TDriveList driveList; + TInt drive; + TDriveInfo driveInfo; + iFormatting = ETrue; + + User::LeaveIfError( iFs.DriveList(driveList) ); + + // search all drives + for( drive = EDriveA; drive <= EDriveZ; drive++ ) + { + if( !driveList[drive] ) + { + // If drive-list entry is zero, drive is not available + continue; + } + + TInt err = iFs.Drive(driveInfo, drive); + + // if removable drive, close store + if (!err && driveInfo.iDriveAtt& KDriveAttRemovable) + { + TN_DEBUG2( "CThumbnailServer::CloseRemovableDrive drive=%d", drive); + CloseStoreForDriveL(drive); + } + } + iProcessor->RemoveAllTasks(); + } + +// ----------------------------------------------------------------------------- +// Open Stores for removable drives +// ----------------------------------------------------------------------------- +// + +void CThumbnailServer::OpenRemovableDrivesL() + { + TDriveList driveList; + TInt drive; + TDriveInfo driveInfo; + iFormatting = EFalse; + + User::LeaveIfError( iFs.DriveList(driveList) ); + + // search all drives + for( drive = EDriveA; drive <= EDriveZ; drive++ ) + { + if( !driveList[drive] ) + { + // If drive-list entry is zero, drive is not available + continue; + } + + TInt err = iFs.Drive(driveInfo, drive); + + // if removable drive, open store + if (!err && driveInfo.iDriveAtt& KDriveAttRemovable) + { + TN_DEBUG2( "CThumbnailServer::OpenRemovableDrive drive=%d", drive); + StoreForDriveL(drive); + } + } + } + +// ----------------------------------------------------------------------------- +// Is formatting ongoing +// ----------------------------------------------------------------------------- +// + +TBool CThumbnailServer::IsFormatting() + { + return iFormatting; + } + diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserversession.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserversession.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,1327 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Server side session for Thumbnail Manager Server + * +*/ + +#include + +#include "thumbnailserversession.h" +#include "thumbnailserver.h" +#include "thumbnailtaskprocessor.h" +#include "thumbnailmanagerconstants.h" +#include "thumbnailgeneratetask.h" +#include "thumbnailscaletask.h" +#include "thumbnaildecodetask.h" +#ifdef RD_MDS_2_5 +#include "thumbnailmdsquerytask.h" +#endif // RD_MDS_2_5 +#include "thumbnaillog.h" +#include "thumbnailpanic.h" + +#include "thumbnailcenrep.h" + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CThumbnailServerSession::CThumbnailServerSession() +// C++ default constructor can NOT contain any code, that might leave. +// --------------------------------------------------------------------------- +// +CThumbnailServerSession::CThumbnailServerSession(): CSession2() + { + iBitmapHandle = 0; + } + + +// --------------------------------------------------------------------------- +// CThumbnailServerSession::~CThumbnailServerSession() +// Destructor. +// --------------------------------------------------------------------------- +// +CThumbnailServerSession::~CThumbnailServerSession() + { + Server()->DropSession(this); + } + + +// ----------------------------------------------------------------------------- +// CThumbnailServerSession::DispatchMessageL() +// Message dispatcher. +// ----------------------------------------------------------------------------- +// +TInt CThumbnailServerSession::DispatchMessageL( const RMessage2& aMessage ) + { + TInt err( KErrNone ); + + switch ( aMessage.Function()) + { + case ERequestThumbByFileHandleAsync: + { + RequestThumbByFileHandleAsyncL( aMessage ); + break; + } + case ERequestThumbByPathAsync: + { + RequestThumbByPathAsyncL( aMessage ); + break; + } + case ERequestSetThumbnailByBuffer: + { + RequestSetThumbnailByBufferL( aMessage ); + break; + } + case ERequestSetThumbnailByBitmap: + { + RequestSetThumbnailByBitmapL( aMessage ); + break; + } + case EReleaseBitmap: + { + ReleaseBitmap( aMessage ); + break; + } + case ECancelRequest: + { + err = CancelRequest( aMessage ); + break; + } + case EChangePriority: + { + err = ChangePriority( aMessage ); + break; + } + case ECreateThumbnails: + { + CreateThumbnailsL( aMessage ); + break; + } + case EDeleteThumbnails: + { + DeleteThumbnailsL( aMessage ); + break; + } + case EDeleteThumbnailsById: + { + DeleteThumbnailsByIdL( aMessage ); + break; + } + case EGetMimeTypeBufferSize: + { + GetMimeTypeBufferSizeL( aMessage ); + break; + } + case EGetMimeTypeList: + { + GetMimeTypeListL( aMessage ); + break; + } + case ERequestThumbByIdAsync: + { + RequestThumbByIdAsyncL( aMessage ); + break; + } + case EUpdateThumbnails: + { + UpdateThumbnailsL( aMessage ); + break; + } + default: + { + err = KErrUnknown; + break; + } + } + + return err; + } + + +// --------------------------------------------------------------------------- +// CThumbnailServerSession::CreateL() +// --------------------------------------------------------------------------- +// +void CThumbnailServerSession::CreateL() + { + Server()->AddSession(); + } + + +// ----------------------------------------------------------------------------- +// CThumbnailServerSession::ServiceL() +// Handles service request messages from clients. +// ----------------------------------------------------------------------------- +// +void CThumbnailServerSession::ServiceL( const RMessage2& aMessage ) + { + __ASSERT_DEBUG( !iMessage.Handle(), ThumbnailPanic( + EThumbnailMessageNotCompleted )); + if ( iMessage.Handle()) + { + iMessage.Complete( KErrUnknown ); + iMessage = RMessage2(); + } + iMessage = aMessage; + + // clean up possible trash + if (iBitmapHandle) + { + Server()->DeleteBitmapFromPool( iBitmapHandle ); + iBitmapHandle = 0; + } + delete iBitmap; + iBitmap = NULL; + delete iBuffer; + iBuffer = NULL; + iOriginalSize = TSize(); + + TInt ret = KErrNone; + + TRAPD( err, + { + ret = DispatchMessageL( aMessage ); + } + ); + if ( iMessage.Handle()) + { + iMessage.Complete( ConvertSqlErrToE32Err( err != KErrNone ? err : ret )); + iMessage = RMessage2(); + } + else + { + return; + } + } + + +// ----------------------------------------------------------------------------- +// CThumbnailServerSession::Server() +// Returns the server pointer. +// ----------------------------------------------------------------------------- +// +CThumbnailServer* CThumbnailServerSession::Server() + { + return ( CThumbnailServer* )( CSession2::Server()); + } + + +// ----------------------------------------------------------------------------- +// CThumbnailServerSession::Cancel() +// ----------------------------------------------------------------------------- +// +void CThumbnailServerSession::Cancel() + { + } + + +// ----------------------------------------------------------------------------- +// CThumbnailServerSession::UpdateThumbnailsL() +// ----------------------------------------------------------------------------- +// +void CThumbnailServerSession::UpdateThumbnailsL( const RMessage2& aMessage ) + { + TN_DEBUG1( "CThumbnailServerSession::UpdateThumbnailsL()" ); + + if(aMessage.Int1() != KCheckValue) + { + TN_DEBUG1( "CThumbnailServerSession::UpdateThumbnailsL() - error in aMessage - leaving" ); + User::Leave(KErrArgument); + } + + // read message params + aMessage.ReadL( 0, iRequestParams ); + const TThumbnailRequestParams& params = iRequestParams(); + + TBool finished = Server()->UpdateThumbnailsL( params.iThumbnailId, params.iFileName, params.iOrientation, params.iModified ); + + if (finished) + { + TN_DEBUG1( "CThumbnailServerSession::UpdateThumbnailsL() - finished" ); + + aMessage.Complete( KErrNone ); + } + else + { + TN_DEBUG1( "CThumbnailServerSession::UpdateThumbnailsL() - need to recreate thumbs" ); + + // need to create new thumbs + aMessage.Complete( KThumbnailErrThumbnailNotFound ); + } + + iMessage = RMessage2(); + } + +// ----------------------------------------------------------------------------- +// CThumbnailServerSession::RequestThumbByIdAsyncL() +// ----------------------------------------------------------------------------- +// +void CThumbnailServerSession::RequestThumbByIdAsyncL( const RMessage2& + aMessage ) + { +#ifdef _DEBUG + TTime aStart, aStop; + aStart.UniversalTime(); +#endif + + TN_DEBUG1( "CThumbnailServerSession::RequestThumbByIdAsyncL() - begin" ); + + if(aMessage.Int1() != KCheckValue) + { + TN_DEBUG1( "CThumbnailServerSession::RequestThumbByIdAsync() - error in aMessage - leaving" ); + User::Leave(KErrArgument); + } + + aMessage.ReadL( 0, iRequestParams ); + const TThumbnailRequestParams& params = iRequestParams(); + TRAPD( err, Server()->FetchThumbnailL( params.iThumbnailId, iBitmap, iBuffer, + params.iThumbnailSize, iOriginalSize )); + if ( !err && iBitmap ) + { + TN_DEBUG1( + "CThumbnailServerSession::RequestThumbByIdAsyncL() - found existing thumbnail- bitmap" ); + + ProcessBitmapL(); + } + else if ( !err && iBuffer) + { + TN_DEBUG1( + "CThumbnailServerSession::RequestThumbByIdAsyncL() - found existing thumbnail- jpeg" ); + + CThumbnailDecodeTask* task = new( ELeave )CThumbnailDecodeTask( Server() + ->Processor(), * Server(), iBuffer, params.iPriority, params.iDisplayMode ); + + CleanupStack::PushL( task ); + task->SetMessageData( TThumbnailServerRequestId( this, params.iRequestId ), iMessage ); + Server()->QueueTaskL( task ); + CleanupStack::Pop( task ); // owned by processor now + + // Decode task is now responsible for completing the message + iMessage = RMessage2(); + + //CThumbnailDecodeTask is responsible freeing + iBuffer = NULL; + } + else if( err == KErrCompletion ) + { + // If thumbnail of requested size is blacklisted, fetching is left with KErrCompletion + TN_DEBUG1( + "CThumbnailServerSession::RequestThumbByIdAsyncL() - thumbnail blacklisted" ); + aMessage.Complete( err ); + iMessage = RMessage2(); + } + else + { + TN_DEBUG2( + "CThumbnailServerSession::RequestThumbByIdAsyncL() - thumbnail not found ( query path from MDS ), err=%d ", err ); + +#ifdef RD_MDS_2_5 + // try to query path from MDS + CThumbnailMDSQueryTask* task = new( ELeave )CThumbnailMDSQueryTask( + Server()->Processor(), params.iPriority + 1, Server()->GetMdESession(), *Server()); + + CleanupStack::PushL( task ); + task->QueryPathByIdL(params.iThumbnailId); + task->SetMessageData( TThumbnailServerRequestId( this, params.iRequestId ), iMessage ); + Server()->QueueTaskL( task ); + CleanupStack::Pop( task ); // owned by processor now + + // query task is now responsible for completing the message + iMessage = RMessage2(); +#else + User::Leave(KThumbnailErrThumbnailNotFound); +#endif // RD_MDS_2_5 + + } + +#ifdef _DEBUG + aStop.UniversalTime(); + TN_DEBUG2( "CThumbnailStore::RequestThumbByIdAsyncL() request took %d ms", (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000 ); +#endif + + TN_DEBUG1("CThumbnailServerSession::RequestThumbByIdAsyncL() - end" ); + } + +// ----------------------------------------------------------------------------- +// CThumbnailServerSession::RequestThumbByFileHandleAsync() +// ----------------------------------------------------------------------------- +// +void CThumbnailServerSession::RequestThumbByFileHandleAsyncL( const RMessage2& + aMessage ) + { + TN_DEBUG1( "CThumbnailServerSession::RequestThumbByFileHandleAsyncL()" ); + + if(aMessage.Int1() != KCheckValue) + { + TN_DEBUG1( "CThumbnailServerSession::RequestThumbByFileHandleAsync() - error in aMessage - leaving" ); + User::Leave(KErrArgument); + } + + aMessage.ReadL( 0, iRequestParams ); + const TThumbnailRequestParams& params = iRequestParams(); + + RFile64 file; + User::LeaveIfError( file.AdoptFromClient( aMessage, 2, 3 )); + + ResolveMimeTypeL(&file); + + if(params.iThumbnailSize == EFullScreenThumbnailSize || + params.iThumbnailSize == EGridThumbnailSize || + params.iThumbnailSize == EListThumbnailSize ) + { + TInt sourceType = TThumbnailPersistentSize::EUnknownSourceType; + sourceType = Server()->SourceTypeFromMimeType( params.iMimeType ); + ModifyThumbnailSize(sourceType); + } + + // CreateThumbnails + if (params.iControlFlags == EThumbnailGeneratePersistentSizesOnly) + { + CleanupClosePushL( file ); + CreateGenerateTaskFromFileHandleL( &file ); + CleanupStack::Pop( &file ); + } + // single thumbnail request + else + { + TRAPD( err, FetchThumbnailL()); + + if ( !err && iBitmap ) + { + TN_DEBUG1( "CThumbnailServerSession::RequestThumbByFileHandleAsyncL() - found existing thumbnail - bitmap " ); + + // Thumbnail already stored + file.Close(); + TN_DEBUG1("CThumbnailServerSession::RequestThumbByFileHandleAsyncL - file handle closed"); + + ProcessBitmapL(); + } + else if ( (err == KErrNotFound || err == KErrAccessDenied) && + !(params.iFlags& CThumbnailManager::EDoNotCreate) ) + { + CreateGenerateTaskFromFileHandleL( &file); + } + else if (!err && iBuffer) + { + TN_DEBUG1( + "CThumbnailServerSession::RequestThumbByFileHandleAsyncL() - found existing thumbnail - jpeg " ); + + CThumbnailDecodeTask* task = new( ELeave )CThumbnailDecodeTask( Server() + ->Processor(), * Server(), iBuffer, params.iPriority, params.iDisplayMode ); + + CleanupStack::PushL( task ); + task->SetMessageData( TThumbnailServerRequestId( this, params.iRequestId ), iMessage ); + Server()->QueueTaskL( task ); + CleanupStack::Pop( task ); // owned by processor now + + // Decode task is now responsible for completing the message + iMessage = RMessage2(); + + //CThumbnailDecodeTask is responsible freeing + iBuffer = NULL; + file.Close(); + TN_DEBUG1("CThumbnailServerSession::RequestThumbByFileHandleAsyncL - file handle closed"); + } + else + { + TN_DEBUG2( + "CThumbnailServerSession::RequestThumbByFileHandleAsyncL() - thumbnail not found, err=%d", err ); + aMessage.Complete( ConvertSqlErrToE32Err( err )); + iMessage = RMessage2(); + } + } + } + +// ----------------------------------------------------------------------------- +// CThumbnailServerSession::RequestThumbByPathAsync() +// ----------------------------------------------------------------------------- +// +void CThumbnailServerSession::RequestThumbByPathAsyncL( const RMessage2& + aMessage ) + { + TN_DEBUG1( "CThumbnailServerSession::RequestThumbByPathAsyncL()" ); + +#ifdef _DEBUG + TTime aStart, aStop; + aStart.UniversalTime(); +#endif + + if(aMessage.Int1() != KCheckValue) + { + TN_DEBUG1( "CThumbnailServerSession::RequestThumbByPathAsync() - error in aMessage - leaving" ); + User::Leave(KErrArgument); + } + + aMessage.ReadL( 0, iRequestParams ); + const TThumbnailRequestParams& params = iRequestParams(); + + ResolveMimeTypeL(NULL); + + if(params.iThumbnailSize == EFullScreenThumbnailSize || + params.iThumbnailSize == EGridThumbnailSize || + params.iThumbnailSize == EListThumbnailSize ) + { + TInt sourceType = TThumbnailPersistentSize::EUnknownSourceType; + sourceType = Server()->SourceTypeFromMimeType( params.iMimeType ); + ModifyThumbnailSize(sourceType); + } + + // should always be true + if (params.iControlFlags != EThumbnailGeneratePersistentSizesOnly) + { + TRAPD( err, FetchThumbnailL()); + + if ( !err && iBitmap ) + { + TN_DEBUG1( + "CThumbnailServerSession::RequestThumbByPathAsyncL() - found existing thumbnail- bitmap" ); + + ProcessBitmapL(); + } + else if ( !err && iBuffer) + { + TN_DEBUG1( + "CThumbnailServerSession::RequestThumbByPathAsyncL() - found existing thumbnail- jpeg" ); + + CThumbnailDecodeTask* task = new( ELeave )CThumbnailDecodeTask( Server() + ->Processor(), * Server(), iBuffer, params.iPriority, params.iDisplayMode ); + + CleanupStack::PushL( task ); + task->SetMessageData( TThumbnailServerRequestId( this, params.iRequestId ), iMessage ); + Server()->QueueTaskL( task ); + CleanupStack::Pop( task ); // owned by processor now + + // Decode task is now responsible for completing the message + iMessage = RMessage2(); + + //CThumbnailDecodeTask is responsible freeing + iBuffer = NULL; + } + else if( err == KErrCompletion ) + { + // If thumbnail of requested size is blacklisted, fetching is left with KErrCompletion + TN_DEBUG1( + "CThumbnailServerSession::RequestThumbByIdAsyncL() - thumbnail blacklisted" ); + aMessage.Complete( err ); + iMessage = RMessage2(); + } + else + { + TN_DEBUG2( + "CThumbnailServerSession::RequestThumbByPathAsyncL() - thumbnail not found, err = %d", err ); + + if ( (err == KErrNotFound || err == KErrAccessDenied) && + !(params.iFlags& CThumbnailManager::EDoNotCreate) ) + { + // Special error code so that the client side can open the file + // and retry the request using file handle + err = KThumbnailErrThumbnailNotFound; + } + else + { + User::Leave(err); + } + +#ifdef RD_MDS_2_5 + // try to query ID from MDS + CThumbnailMDSQueryTask* task = new( ELeave )CThumbnailMDSQueryTask( + Server()->Processor(), params.iPriority + 1, Server()->GetMdESession(), *Server()); + + CleanupStack::PushL( task ); + task->SetUpdateToDb( EFalse ); + task->QueryIdByPathL( params.iFileName ); + task->SetMessageData( TThumbnailServerRequestId( this, params.iRequestId ), iMessage ); + Server()->QueueTaskL( task ); + CleanupStack::Pop( task ); // owned by processor now + + // query task is now responsible for completing the message + iMessage = RMessage2(); +#else + User::Leave(err); +#endif // RD_MDS_2_5 + + } + } + +#ifdef _DEBUG + aStop.UniversalTime(); + TN_DEBUG2( "CThumbnailStore::RequestThumbByPathAsyncL() request took %d ms", (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000 ); +#endif + } + +void CThumbnailServerSession::RequestSetThumbnailByBufferL( const RMessage2& aMessage ) + { + TN_DEBUG1( "CThumbnailServerSession::RequestSetThumbnailByBufferL()" ); + + if(aMessage.Int3() != KCheckValue) + { + TN_DEBUG1( "CThumbnailServerSession::RequestSetThumbnailByBufferL() - error in aMessage - leaving" ); + User::Leave(KErrArgument); + } + + aMessage.ReadL( 0, iRequestParams ); + const TThumbnailRequestParams& params = iRequestParams(); + + if(params.iThumbnailSize != EUnknownThumbnailSize) + { + Server()->DeleteThumbnailsL( params.iTargetUri); + } + + if(params.iThumbnailSize == EFullScreenThumbnailSize || + params.iThumbnailSize == EGridThumbnailSize || + params.iThumbnailSize == EListThumbnailSize ) + { + TInt sourceType = TThumbnailPersistentSize::EUnknownSourceType; + TDataType mimetype; + Server()->MimeTypeFromFileExt( params.iTargetUri, mimetype ); + sourceType = Server()->SourceTypeFromMimeType( mimetype ); + ModifyThumbnailSize(sourceType); + } + + TInt bufferSize = aMessage.Int2(); + HBufC8* buffer = HBufC8::NewMaxLC( bufferSize ); + TPtr8 ptr = buffer->Des(); + aMessage.ReadL( 1 /* buffer pointer */, ptr ); + + CreateGenerateTaskFromBufferL( buffer ); + CleanupStack::Pop( buffer ); + } + +void CThumbnailServerSession::RequestSetThumbnailByBitmapL( const RMessage2& aMessage ) + { + TN_DEBUG1( "CThumbnailServerSession::RequestSetThumbnailByBitmapL()" ); + + if(aMessage.Int2() != KCheckValue) + { + TN_DEBUG1( "CThumbnailServerSession::RequestSetThumbnailByBitmapL() - error in aMessage - leaving" ); + User::Leave(KErrArgument); + } + + aMessage.ReadL( 0, iRequestParams ); + const TThumbnailRequestParams& params = iRequestParams(); + + TInt bitmapHandle = aMessage.Int1(); + TThumbnailServerRequestId &reqId = (TThumbnailServerRequestId&)params.iRequestId; + + // get bitmap + CFbsBitmap* bitmap = new( ELeave )CFbsBitmap(); + CleanupStack::PushL( bitmap ); + User::LeaveIfError( bitmap->Duplicate( bitmapHandle ) ); + Server()->AddBitmapToPoolL( reqId.iSession, bitmap ); + CleanupStack::Pop( bitmap ); + iBitmapHandle = bitmap->Handle(); + + RArray < TThumbnailPersistentSize >* missingSizes = NULL; + + // source type + TDataType mimeType; + TInt sourceType = 0; + TInt err = Server()->MimeTypeFromFileExt( params.iTargetUri, mimeType ); + TBool missingIDs(EFalse); + + // get missing sizes + if ( err == KErrNone && ( params.iControlFlags & EThumbnailGeneratePersistentSizesOnly ) != 0 ) + { + sourceType = Server()->SourceTypeFromMimeType( mimeType ); + + missingSizes = new (ELeave) RArray < TThumbnailPersistentSize >; + CleanupClosePushL( *missingSizes ); + + Server()->GetMissingSizesAndIDsL( params.iTargetUri, sourceType, *missingSizes, missingIDs); + + if ( missingSizes->Count() == 0) + { + // all thumbs already exist + CleanupStack::PopAndDestroy( missingSizes ); + delete missingSizes; + missingSizes = NULL; + } + } + + // if missing sizes, create scale tasks + if ( missingSizes ) + { + const TInt count = missingSizes->Count(); + + TSize bitmapSize = bitmap->SizeInPixels(); + + for ( TInt i( 0 ); i < count; i++ ) + { + if( bitmapSize.iWidth < bitmapSize.iHeight ) + { + TInt height = (*missingSizes)[i].iSize.iHeight; + (*missingSizes)[i].iSize.iHeight = (*missingSizes)[i].iSize.iWidth; + (*missingSizes)[i].iSize.iWidth = height; + TN_DEBUG1( "CThumbnailServerSession::RequestSetThumbnailByBitmapL() - portrait"); + } + + CThumbnailScaleTask* scaleTask = CThumbnailScaleTask::NewL( Server()->Processor(), + *Server(), params.iTargetUri, bitmap, bitmapSize, + (*missingSizes)[i].iSize, (*missingSizes)[i].iCrop, params.iDisplayMode, + KMaxPriority, KNullDesC, (*missingSizes)[i].iType, params.iThumbnailId, EFalse, EFalse ); + CleanupStack::PushL( scaleTask ); + scaleTask->SetDoStore( ETrue ); + //increase priority, scale needs to run before ID update below + scaleTask->SetPriority( params.iPriority + 1 ); + Server()->Processor().AddTaskL( scaleTask ); + CleanupStack::Pop( scaleTask ); + + if( i == count-1 ) + { + // scaleTask is now responsible for completing the RMessage + scaleTask->SetMessageData( reqId, iMessage ); + iMessage = RMessage2(); + } + } + + TN_DEBUG3("CThumbnailServerSession::RequestSetThumbnailByBitmapL() ID = %d, missingIDs = %d", params.iThumbnailId, missingIDs); + } + else + { + // complete message + aMessage.Complete( KErrNone ); + iMessage = RMessage2(); + } + + if ( missingSizes ) + { + CleanupStack::PopAndDestroy( missingSizes ); + delete missingSizes; + missingSizes = NULL; + } + + Server()->DeleteBitmapFromPool( iBitmapHandle ); + iBitmapHandle = 0; + bitmap = NULL; + } + +// ----------------------------------------------------------------------------- +// CThumbnailServerSession::CreateThumbnailsL() +// Create thumbnails for given object file +// ----------------------------------------------------------------------------- +// +void CThumbnailServerSession::CreateThumbnailsL( const RMessage2& aMessage ) + { + RFile64 file; + CleanupClosePushL( file ); + User::LeaveIfError( file.AdoptFromClient( aMessage, 1, 2 )); + + CreateGenerateTaskFromFileHandleL( &file); + + CleanupStack::Pop( &file ); + } + + +// ----------------------------------------------------------------------------- +// CThumbnailServerSession::CreateGenerateTaskL() +// Create a task to generate a new thumbnail +// ----------------------------------------------------------------------------- +// +void CThumbnailServerSession::CreateGenerateTaskFromFileHandleL( RFile64* aFile) + { + const TThumbnailRequestParams& params = iRequestParams(); + + TN_DEBUG2( + "CThumbnailServerSession::CreateGenerateTaskFromFileHandleL() -- create thumbnail generation task for %S", ¶ms.iFileName ); + + TBool missingIDs = EFalse; + + RArray < TThumbnailPersistentSize >* missingSizes = NULL; + + // get missing sizes + if ( ( params.iControlFlags & EThumbnailGeneratePersistentSizesOnly ) != 0 ) + { + TInt sourceType = TThumbnailPersistentSize::EUnknownSourceType; + sourceType = Server()->SourceTypeFromMimeType( params.iMimeType ); + missingSizes = new (ELeave) RArray < TThumbnailPersistentSize >; + CleanupClosePushL( *missingSizes ); + + Server()->GetMissingSizesAndIDsL( params.iFileName, sourceType, *missingSizes, missingIDs ); +#ifdef RD_MDS_2_5 + if( missingIDs ) + { + TN_DEBUG1("CThumbnailServerSession::CreateGenerateTaskFromFileHandleL() some IDs missing"); + + if( params.iThumbnailId == KNoId) + { + TN_DEBUG1("CThumbnailServerSession::CreateGenerateTaskFromFileHandleL() query fro MDS"); + // try to query ID from MDS + CThumbnailMDSQueryTask* task = new( ELeave )CThumbnailMDSQueryTask( + Server()->Processor(), params.iPriority + 1, Server()->GetMdESession(), *Server()); + + CleanupStack::PushL( task ); + task->QueryIdByPathL( params.iFileName ); + + task->SetMessageData( TThumbnailServerRequestId( this, params.iRequestId ) ); + Server()->QueueTaskL( task ); + CleanupStack::Pop( task ); // owned by processor now + TN_DEBUG1("CThumbnailServerSession::CreateGenerateTaskFromFileHandleL() query from MDS queued" ); + } + else + { + TN_DEBUG2("CThumbnailServerSession::CreateGenerateTaskFromFileHandleL() got ID %d from params", params.iThumbnailId); + TRAP_IGNORE( Server()->UpdateIDL(params.iFileName, params.iThumbnailId ) ); + } + } +#endif // RD_MDS_2_5 + + if ( missingSizes->Count() == 0) + { + // all thumbs already exist + CleanupStack::PopAndDestroy( missingSizes ); + delete missingSizes; + if( aFile ) + { + aFile->Close(); + } + return; + } + } + + // priority + TInt priority = params.iPriority; + if ( priority > KMaxGeneratePriority ) + { + priority = KMaxGeneratePriority; + } + + // create new task + if( !aFile) + { + User::Leave( KErrArgument ); + } + CleanupClosePushL( *aFile ); + CThumbnailGenerateTask* task = new( ELeave )CThumbnailGenerateTask( Server() + ->Processor(), * Server(), aFile, NULL, ¶ms.iMimeType, params.iFlags, + params.iSize, params.iDisplayMode, priority, missingSizes, params.iTargetUri, + params.iThumbnailSize, params.iThumbnailId, params.iQualityPreference ); + + // do not store bitmaps to server pool when generating only + if( params.iControlFlags & EThumbnailGeneratePersistentSizesOnly ) + { + task->ScaledBitmapToPool( EFalse ); + } + + CleanupStack::Pop( aFile ); + + CleanupStack::PushL( task ); + task->SetMessageData( TThumbnailServerRequestId( this, params.iRequestId ), + iMessage ); + Server()->QueueTaskL( task ); + CleanupStack::Pop( task ); // owned by processor now + + if ( missingSizes ) + { + CleanupStack::Pop( missingSizes ); + } + + // Generate task is now responsible for completing the message + iMessage = RMessage2(); + } +// ----------------------------------------------------------------------------- +// CThumbnailServerSession::CreateGenerateTaskL() +// Create a task to generate a new thumbnail +// ----------------------------------------------------------------------------- +// +void CThumbnailServerSession::CreateGenerateTaskFromBufferL( TDesC8* aBuffer ) + { + const TThumbnailRequestParams& params = iRequestParams(); + + TN_DEBUG2( + "CThumbnailServerSession::CreateGenerateTaskFromBufferL() -- create thumbnail generation task for %S", ¶ms.iTargetUri ); + + if(aBuffer && params.iMimeType.Des().Match( KVideoMime ) == 0 ) + { + User::Leave( KErrNotSupported ); + } + + TInt sourceType = TThumbnailPersistentSize::EUnknownSourceType; + + TDataType mimetype; + TInt ret = Server()->MimeTypeFromFileExt( params.iTargetUri, mimetype ); + if(ret == KErrNotFound) + { + Server()->Fs().ShareProtected(); + RFile64 file; + CleanupClosePushL( file ); + + User::LeaveIfError( file.Open( Server()->Fs(), params.iTargetUri, EFileShareReadersOrWriters )); + TN_DEBUG2( "CThumbnailServerSession::CreateGenerateTaskFromBufferL - file handle opened for %S", ¶ms.iFileName ); + + mimetype = Server()->ResolveMimeTypeL(file); + + file.Close(); + TN_DEBUG1("CThumbnailServerSession::CreateGenerateTaskFromBufferL - file handle closed"); + + CleanupStack::Pop( &file ); + } + + sourceType = Server()->SourceTypeFromMimeType( mimetype ); + + RArray < TThumbnailPersistentSize >* missingSizes = NULL; + + // get missing sizes + if ( ( params.iControlFlags & EThumbnailGeneratePersistentSizesOnly ) != 0 ) + { + missingSizes = new (ELeave) RArray < TThumbnailPersistentSize >; + CleanupClosePushL( *missingSizes ); + + TBool missingIDs; + Server()->GetMissingSizesAndIDsL( params.iTargetUri, sourceType, *missingSizes, missingIDs ); + + if ( missingSizes->Count() == 0) + { + // all thumbs already exist + CleanupStack::PopAndDestroy( missingSizes ); + delete missingSizes; + if ( aBuffer) + { + delete aBuffer; + aBuffer = NULL; + } + return; + } + } + + // priority + TInt priority = params.iPriority; + if ( priority > KMaxGeneratePriority ) + { + priority = KMaxGeneratePriority; + } + + // create new task + if( !aBuffer) + { + User::Leave( KErrArgument ); + } + + CThumbnailGenerateTask* task = new( ELeave )CThumbnailGenerateTask( Server() + ->Processor(), * Server(), NULL, aBuffer, ¶ms.iMimeType, params.iFlags, + params.iSize, params.iDisplayMode, priority, missingSizes, params.iTargetUri, + params.iThumbnailSize, params.iThumbnailId, params.iQualityPreference ); + + // do not store bitmaps to server pool when generating only + if( params.iControlFlags & EThumbnailGeneratePersistentSizesOnly ) + { + task->ScaledBitmapToPool( EFalse ); + } + + CleanupStack::PushL( task ); + task->SetMessageData( TThumbnailServerRequestId( this, params.iRequestId ), + iMessage ); + Server()->QueueTaskL( task ); + CleanupStack::Pop( task ); // owned by processor now + + if ( missingSizes ) + { + CleanupStack::Pop( missingSizes ); + } + + // Generate task is now responsible for completing the message + iMessage = RMessage2(); + } +// ----------------------------------------------------------------------------- +// CThumbnailServerSession::FetchThumbnailL() +// Fetch thumbnail data from database +// ----------------------------------------------------------------------------- +// +void CThumbnailServerSession::FetchThumbnailL() + { + TN_DEBUG1("CThumbnailServerSession::FetchThumbnailL()"); + __ASSERT_DEBUG( !iBitmap, ThumbnailPanic( EThumbnailBitmapNotReleased )); + + delete iBitmap; + iBitmap = NULL; + + TThumbnailRequestParams& params = iRequestParams(); + + if ( params.iThumbnailSize != EUnknownThumbnailSize && + params.iThumbnailSize != ECustomThumbnailSize ) + { + TThumbnailPersistentSize & persistentSize = Server()->PersistentSizeL( params.iThumbnailSize ); + params.iSize = persistentSize.iSize; + } + + if( params.iFileName != KNullDesC ) + { + TN_DEBUG4( "CThumbnailServerSession::FetchThumbnailL( TNId==%d ThumbnailSize=%d ( Path=%S ))", + params.iThumbnailId, params.iThumbnailSize, ¶ms.iFileName ); + Server()->FetchThumbnailL( params.iFileName, iBitmap, iBuffer, params.iThumbnailSize, iOriginalSize); + } + else + { + TN_DEBUG3( "CThumbnailServerSession::FetchThumbnailL(Path=%S ThumbnailSize=%d)", + ¶ms.iFileName, params.iThumbnailSize ); + Server()->FetchThumbnailL( params.iThumbnailId, iBitmap, iBuffer, params.iThumbnailSize, iOriginalSize ); + } +#ifdef _DEBUG + if( iBitmap) + { + TN_DEBUG4( "CThumbnailServerSession::FetchThumbnailL() size %d x %d displaymode %d", iBitmap->SizeInPixels().iWidth, iBitmap->SizeInPixels().iHeight, iBitmap->DisplayMode()); + } +#endif + } + +// ----------------------------------------------------------------------------- +// CThumbnailServerSession::ProcessBitmapL() +// Process a fetched bitmap by creating scale tasks or by returning the +// bitmap as such. +// ----------------------------------------------------------------------------- +// +void CThumbnailServerSession::ProcessBitmapL() + { + TThumbnailRequestParams& params = iRequestParams(); + + // in import case store bitmap + if (params.iTargetUri != KNullDesC) + { + Server()->StoreThumbnailL( params.iTargetUri, iBitmap, iOriginalSize, + params.iFlags& CThumbnailManager::ECropToAspectRatio, params.iThumbnailSize, params.iThumbnailId ); + } + + // No need to scale, return iBitmap directly + Server()->AddBitmapToPoolL( this, iBitmap ); + CFbsBitmap* bitmap = iBitmap; + iBitmap = NULL; // owned by server now + + params.iBitmapHandle = bitmap->Handle(); + const TSize bitmapSize = bitmap->SizeInPixels(); + + if ( params.iQualityPreference == CThumbnailManager + ::EOptimizeForQualityWithPreview && bitmapSize.iWidth < + params.iSize.iWidth && bitmapSize.iHeight < params.iSize.iHeight && + bitmapSize.iWidth < iOriginalSize.iWidth && bitmapSize.iHeight < + iOriginalSize.iHeight ) + { + // This is a non-scaled preview bitmap + params.iControlFlags = EThumbnailPreviewThumbnail; + } + + if ( iMessage.Handle() ) + { + iMessage.WriteL( 0, iRequestParams ); + iMessage.Complete( KErrNone ); + iMessage = RMessage2(); + } + } + +// ----------------------------------------------------------------------------- +// CThumbnailServerSession::ReleaseBitmap() +// Release bitmap from bitmap pool +// ----------------------------------------------------------------------------- +// +void CThumbnailServerSession::ReleaseBitmap( const RMessage2& aMessage ) + { + TN_DEBUG2( "CThumbnailServerSession::ReleaseBitmap(%d)", aMessage.Int0()); + Server()->DeleteBitmapFromPool( aMessage.Int0()); + } + + +// ----------------------------------------------------------------------------- +// CThumbnailServerSession::CancelRequest() +// Cancel pending request. +// ----------------------------------------------------------------------------- +// +TInt CThumbnailServerSession::CancelRequest( const RMessage2& aMessage ) + { + const TThumbnailServerRequestId requestId( this, aMessage.Int0()); + const TInt err = Server()->DequeTask( requestId ); + TN_DEBUG4( + "CThumbnailServerSession::CancelRequest(0x%08x/%d) - returning %d", + requestId.iSession, requestId.iRequestId, err ); + return err; + } + +// ----------------------------------------------------------------------------- +// CThumbnailServerSession::ChangePriority() +// Change priority of pending request. +// ----------------------------------------------------------------------------- +// +TInt CThumbnailServerSession::ChangePriority( const RMessage2& aMessage ) + { + const TThumbnailServerRequestId requestId( this, aMessage.Int0()); + const TInt newPriority = aMessage.Int1(); + + const TInt err = Server()->ChangeTaskPriority( requestId, newPriority ); + TN_DEBUG5( + "CThumbnailServerSession::ChangePriority(0x%08x/%d, %d) - returning %d", + requestId.iSession, requestId.iRequestId, newPriority, err ); + return err; + } + +// ----------------------------------------------------------------------------- +// CThumbnailServerSession::DeleteThumbnailsL() +// Delete thumbnails for given object file +// ----------------------------------------------------------------------------- +// +void CThumbnailServerSession::DeleteThumbnailsL( const RMessage2& aMessage ) + { + if(aMessage.Int2() != KCheckValue) + { + TN_DEBUG1( "CThumbnailServerSession::DeleteThumbnailsL() - error in aMessage - leaving" ); + User::Leave(KErrArgument); + } + + HBufC* fileName = HBufC::NewLC( KMaxFileName ); + TPtr ptr = fileName->Des(); + aMessage.ReadL( 1, ptr ); + Server()->DeleteThumbnailsL( ptr ); + CleanupStack::PopAndDestroy( fileName ); + + aMessage.Complete( KErrNone ); + iMessage = RMessage2(); + } + +// ----------------------------------------------------------------------------- +// CThumbnailServerSession::DeleteThumbnailsByIdL() +// Delete thumbnails by TThumbnailId. +// ----------------------------------------------------------------------------- +// +void CThumbnailServerSession::DeleteThumbnailsByIdL( const RMessage2& aMessage ) + { + if(aMessage.Int2() != KCheckValue) + { + TN_DEBUG1( "CThumbnailServerSession::DeleteThumbnailsByIdL() - error in aMessage - leaving" ); + User::Leave(KErrArgument); + } + + // read message params + aMessage.ReadL( 0, iRequestParams ); + const TThumbnailRequestParams& params = iRequestParams(); + + TThumbnailId id = params.iThumbnailId; + Server()->DeleteThumbnailsByIdL( id ); + + aMessage.Complete( KErrNone ); + iMessage = RMessage2(); + } + +// ----------------------------------------------------------------------------- +// Get the required size (in characters) for a buffer that contains the +// list of supported MIME types +// ----------------------------------------------------------------------------- +// +void CThumbnailServerSession::GetMimeTypeBufferSizeL( const RMessage2& aMessage + ) + { + TPckgBuf < TInt > buf; + buf() = Server()->GetMimeTypeBufferSize(); + aMessage.WriteL( 0, buf ); + } + +// ----------------------------------------------------------------------------- +// Get the list of supported MIME types and store them in the buffer +// allocated by the client. +// ----------------------------------------------------------------------------- +// +void CThumbnailServerSession::GetMimeTypeListL( const RMessage2& aMessage ) + { + TInt len = aMessage.GetDesMaxLengthL( 0 ); + HBufC* buf = HBufC::NewLC( len ); + TPtr ptr = buf->Des(); + Server()->GetMimeTypeList( ptr ); + aMessage.WriteL( 0, * buf ); + CleanupStack::PopAndDestroy( buf ); + } + +// --------------------------------------------------------------------------- +// CThumbnailServerSession::ModifyThumbnailSize +// --------------------------------------------------------------------------- +// +void CThumbnailServerSession::ModifyThumbnailSize( TInt aSourceType ) + { + TThumbnailRequestParams& params = iRequestParams(); + if(aSourceType == TThumbnailPersistentSize::EImage) + { + if(params.iThumbnailSize == EFullScreenThumbnailSize) + { + params.iThumbnailSize = EImageFullScreenThumbnailSize; + } + else if(params.iThumbnailSize == EGridThumbnailSize) + { + params.iThumbnailSize = EImageGridThumbnailSize; + } + else if(params.iThumbnailSize == EListThumbnailSize) + { + params.iThumbnailSize = EImageListThumbnailSize; + } + } + else if(aSourceType == TThumbnailPersistentSize::EVideo) + { + if(params.iThumbnailSize == EFullScreenThumbnailSize) + { + params.iThumbnailSize = EVideoFullScreenThumbnailSize; + } + else if(params.iThumbnailSize == EGridThumbnailSize) + { + params.iThumbnailSize = EVideoGridThumbnailSize; + } + else if(params.iThumbnailSize == EListThumbnailSize) + { + params.iThumbnailSize = EVideoListThumbnailSize; + } + } + else if(aSourceType == TThumbnailPersistentSize::EAudio) + { + if(params.iThumbnailSize == EFullScreenThumbnailSize) + { + params.iThumbnailSize = EAudioFullScreenThumbnailSize; + } + else if(params.iThumbnailSize == EGridThumbnailSize) + { + params.iThumbnailSize = EAudioGridThumbnailSize; + } + else if(params.iThumbnailSize == EListThumbnailSize) + { + params.iThumbnailSize = EAudioListThumbnailSize; + } + } + } + +//------------------------------------------------------------------------ +// CThumbnailServerSession::ModifyThumbnailSize +// --------------------------------------------------------------------------- +// +void CThumbnailServerSession::ResolveMimeTypeL( RFile64* aFile ) + { + TThumbnailRequestParams& params = iRequestParams(); + TInt res = 0; + + // mime type + if ( params.iMimeType.Des8() == KNullDesC8 && !Server()->SupportedMimeType(params.iMimeType) ) + { + // try parsing from file extension + res = Server()->MimeTypeFromFileExt( params.iFileName, params.iMimeType ); + if ( res == KErrNotFound ) + { + if( aFile ) + { + // parsed type not in the list, resolve from file + params.iMimeType = Server()->ResolveMimeTypeL(*aFile); + } + else + { + Server()->Fs().ShareProtected(); + RFile64 file; + CleanupClosePushL( file ); + + User::LeaveIfError( file.Open( Server()->Fs(), params.iFileName, EFileShareReadersOrWriters )); + TN_DEBUG2( "CThumbnailServerSession::ResolveMimeType - file handle opened for %S", ¶ms.iFileName ); + + params.iMimeType = Server()->ResolveMimeTypeL(file); + + file.Close(); + TN_DEBUG1("CThumbnailServerSession::ResolveMimeType - file handle closed"); + + CleanupStack::Pop( &file ); + } + } + } + } + + +// --------------------------------------------------------------------------- +// RThumbnailMessage::FilterSqlErr +// --------------------------------------------------------------------------- +// +TInt CThumbnailServerSession::ConvertSqlErrToE32Err( TInt aReason ) + { + TInt e32Err; + if ( aReason >= - 144 ) + // magic: [-1..-144] is E32 error range + { + // E32 error value or non-negative value + e32Err = aReason; + } + else + { + switch ( aReason ) + { + case KSqlErrGeneral: + e32Err = KErrGeneral; + break; + case KSqlErrInternal: + e32Err = KErrGeneral; + break; + case KSqlErrPermission: + e32Err = KErrPermissionDenied; + break; + case KSqlErrAbort: + e32Err = KErrAbort; + break; + case KSqlErrBusy: + e32Err = KErrServerBusy; + break; + case KSqlErrLocked: + e32Err = KErrLocked; + break; + case KSqlErrReadOnly: + e32Err = KErrAccessDenied; + break; + case KSqlErrInterrupt: + e32Err = KErrAbort; + break; + case KSqlErrIO: + e32Err = KErrGeneral; + break; + case KSqlErrCorrupt: + e32Err = KErrCorrupt; + break; + case KSqlErrNotFound: + e32Err = KErrNotFound; + break; + case KSqlErrFull: + e32Err = KErrOverflow; + break; + case KSqlErrCantOpen: + e32Err = KErrCouldNotConnect; + break; + case KSqlErrProtocol: + e32Err = KErrLocked; + break; + case KSqlErrEmpty: + e32Err = KErrNotFound; + break; + case KSqlErrSchema: + e32Err = KErrAbort; + break; + case KSqlErrTooBig: + e32Err = KErrTooBig; + break; + case KSqlErrConstraint: + e32Err = KErrGeneral; + break; + case KSqlErrMismatch: + e32Err = KErrGeneral; + break; + case KSqlErrMisuse: + e32Err = KErrGeneral; + break; + case KSqlErrRange: + e32Err = KErrOverflow; + break; + case KSqlErrNotDb: + e32Err = KErrCorrupt; + break; + case KSqlErrStmtExpired: + e32Err = KErrAbort; + break; + default: + e32Err = aReason; + } + } + return e32Err; + } + +// End of file diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailstore.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailstore.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,2370 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Store for thumbnails. + * +*/ + + +#include +#include +#include +#include +#include +#include + +#include +#include "thumbnailstore.h" +#include "thumbnailsql.h" +#include "thumbnaillog.h" +#include "thumbnailmanageruids.hrh" +#include "thumbnailcenrep.h" +#include "thumbnailpanic.h" +#include "thumbnailmanagerconstants.h" +#include "thumbnailserver.h" + + + +_LIT8( KThumbnailSqlConfig, "page_size=16384; cache_size=32;" ); + +const TInt KStreamBufferSize = 1024 * 8; +const TInt KMajor = 3; +const TInt KMinor = 2; + +// Database path without drive letter +_LIT( KThumbnailDatabaseName, ":[102830AB]thumbnail_v2.db" ); + +// Allow access to database only for the server process +const TSecurityPolicy KThumbnailDatabaseSecurityPolicy( TSecureId( + THUMBNAIL_MANAGER_SERVER_UID )); + + +// --------------------------------------------------------------------------- +// RThumbnailTransaction::RThumbnailTransaction::TThumbnailPersistentSize +// --------------------------------------------------------------------------- +// +RThumbnailTransaction::RThumbnailTransaction( RSqlDatabase& aDatabase ): + iDatabase( aDatabase ), iState( EClosed ) + { + // No implementation required + } + + +// --------------------------------------------------------------------------- +// RThumbnailTransaction::BeginL() +// --------------------------------------------------------------------------- +// +void RThumbnailTransaction::BeginL() + { + const TInt err = iDatabase.Exec( KThumbnailBeginTransaction ); + if ( err >= 0 ) + { + iState = EOpen; + } + else + { + iState = EError; + User::Leave( err ); + } + } + + +// --------------------------------------------------------------------------- +// RThumbnailTransaction::Close() +// --------------------------------------------------------------------------- +// +void RThumbnailTransaction::Close() + { + if ( iState != EClosed ) + { + Rollback(); + } + } + + +// --------------------------------------------------------------------------- +// RThumbnailTransaction::CommitL() +// --------------------------------------------------------------------------- +// +void RThumbnailTransaction::CommitL() + { + User::LeaveIfError( iDatabase.Exec( KThumbnailCommitTransaction )); + iState = EClosed; + } + + +// --------------------------------------------------------------------------- +// RThumbnailTransaction::Rollback() +// --------------------------------------------------------------------------- +// +TInt RThumbnailTransaction::Rollback() + { + const TInt err = iDatabase.Exec( KThumbnailRollbackTransaction ); + if ( err >= 0 ) + { + iState = EClosed; + } + return err; + } + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CThumbnailStore::NewL() +// Two-phased constructor. +// --------------------------------------------------------------------------- +// +CThumbnailStore* CThumbnailStore::NewL( RFs& aFs, TInt aDrive, TDesC& aImei, CThumbnailServer* aServer ) + { + CThumbnailStore* self = new( ELeave )CThumbnailStore( aFs, aDrive, aImei, aServer ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// CThumbnailStore::~CThumbnailStore() +// Destructor. +// --------------------------------------------------------------------------- +// +CThumbnailStore::~CThumbnailStore() + { + TN_DEBUG1( "CThumbnailStore::~CThumbnailStore()" ); + + if(!iServer->IsFormatting()) + { + FlushCacheTable( ETrue ); + } + if( iAutoFlushTimer ) + { + iAutoFlushTimer->Cancel(); + delete iAutoFlushTimer; + iAutoFlushTimer = NULL; + } + + iDatabase.Close(); + TN_DEBUG1( "CThumbnailStore::~CThumbnailStore() - database closed" ); + } + + +// --------------------------------------------------------------------------- +// CThumbnailStore::CThumbnailStore() +// C++ default constructor can NOT contain any code, that might leave. +// --------------------------------------------------------------------------- +// +CThumbnailStore::CThumbnailStore( RFs& aFs, TInt aDrive, TDesC& aImei, CThumbnailServer* aServer ): + iFs( aFs ), iDrive( aDrive ), iBatchItemCount(0), iImei(aImei), iServer(aServer) + { + // no implementation required + } + + +// --------------------------------------------------------------------------- +// CThumbnailStore::ConstructL() +// Symbian 2nd phase constructor can leave. +// --------------------------------------------------------------------------- +// +void CThumbnailStore::ConstructL() + { + TN_DEBUG1( "CThumbnailStore::ConstructL()" ); + +#ifdef _DEBUG + iThumbCounter = 0; +#endif + + HBufC* databasePath = HBufC::NewLC( KMaxFileName ); + TPtr pathPtr = databasePath->Des(); + TChar driveChar = 0; + User::LeaveIfError( RFs::DriveToChar( iDrive, driveChar )); + pathPtr.Append( driveChar ); + pathPtr.Append( KThumbnailDatabaseName ); + + TVolumeInfo volumeinfo; + iFs.Volume(volumeinfo, iDrive); + TUint id = volumeinfo.iUniqueID; + TBuf<50> mediaid; + mediaid.Num(id); + TBool newDatabase(EFalse); + + TInt error = KErrNone; + + TInt err = iDatabase.Open( pathPtr ); + if ( err == KErrNotFound ) + { + // db not found, create new + TN_DEBUG1( "CThumbnailStore::ConstructL() -- 1 creating database" ); + const TDesC8& config = KThumbnailSqlConfig; + + RSqlSecurityPolicy securityPolicy; + CleanupClosePushL( securityPolicy ); + securityPolicy.Create( KThumbnailDatabaseSecurityPolicy ); + + iDatabase.CreateL( pathPtr, securityPolicy, &config ); + CleanupStack::PopAndDestroy( &securityPolicy ); + + TN_DEBUG1( "CThumbnailStore::ConstructL() -- 1 database created ok" ); + + RFile64 file; + file.Create(iFs, mediaid, EFileShareReadersOrWriters ); + file.Close(); + newDatabase = ETrue; + } + else if ( err == KErrNone) + { + // db found, check version and rowids + error = CheckVersionL(); + if(error == KErrNone) + { + error = CheckRowIDsL(); + } + + } + + // if wrong version, corrupted database or other error opening db + if ( error == KErrNotSupported || (err != KErrNone && err != KErrNotFound) ) + { + TN_DEBUG1( "CThumbnailStore::ConstructL() -- delete databases" ); + + // delete db and create new + iDatabase.Close(); + iDatabase.Delete(pathPtr); + + TN_DEBUG1( "CThumbnailStore::ConstructL() -- 2 creating database" ); + + const TDesC8& config = KThumbnailSqlConfig; + + RSqlSecurityPolicy securityPolicy; + CleanupClosePushL( securityPolicy ); + securityPolicy.Create( KThumbnailDatabaseSecurityPolicy ); + + iDatabase.CreateL( pathPtr, securityPolicy, &config ); + CleanupStack::PopAndDestroy( &securityPolicy ); + + TN_DEBUG1( "CThumbnailStore::ConstructL() -- 2 database created ok" ); + + RFile64 file; + file.Create(iFs, mediaid, EFileShareReadersOrWriters ); + file.Close(); + } + else if(!newDatabase) + { + //check ownership + if(CheckImeiL() != KErrNone) + { + ResetThumbnailIDs(); + + //take ownership + UpdateImeiL(); + + //Remove blacklist markings + TRAP_IGNORE( RemoveDbFlagL( KThumbnailDbFlagBlacklisted ) ); + } + + //check is MMC known + if(CheckMediaIDL() != KErrNone ) + { + ResetThumbnailIDs(); + + //Remove blacklist markings + TRAP_IGNORE( RemoveDbFlagL( KThumbnailDbFlagBlacklisted ) ); + } + } + + CleanupStack::PopAndDestroy( databasePath ); + + // add tables + TRAPD(tableError, CreateTablesL() ); + + if(!tableError) + { + AddVersionAndImeiL(); + } + + err = iDatabase.Exec( KThumbnailCreateTempInfoTable ); + TN_DEBUG2("CThumbnailStore::CreateTablesL() KThumbnailCreateTempInfoTable %d", err); + User::LeaveIfError( err ); + err = iDatabase.Exec( KThumbnailCreateTempInfoDataTable ); + TN_DEBUG2("CThumbnailStore::CreateTablesL() KThumbnailCreateTempInfoDataTable %d", err); + User::LeaveIfError( err ); + } + + +// --------------------------------------------------------------------------- +// CThumbnailStore::StoreThumbnailL() +// Stores thumbnail image. +// --------------------------------------------------------------------------- +// +void CThumbnailStore::StoreThumbnailL( const TDesC& aPath, const TDes8& aData, + const TSize& aSize, const TSize& aOriginalSize, const TThumbnailFormat& aFormat, TInt aFlags, + const TThumbnailSize& aThumbnailSize, TThumbnailId aThumbnailId, const TBool aThumbFromPath ) + { + TN_DEBUG1( "CThumbnailStore::StoreThumbnailL( const TDes8& ) in" ); + +#ifdef _DEBUG + TTime aStart, aStop; + aStart.UniversalTime(); +#endif + + //Encapsulate insert to Transaction + RThumbnailTransaction transaction( iDatabase ); + CleanupClosePushL( transaction ); + transaction.BeginL(); + + RSqlStatement stmt; + CleanupClosePushL( stmt ); + // Insert into ThumbnailInfo + User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailInsertThumbnailInfoByPathAndId )); + + TInt paramIndex = stmt.ParameterIndex( KThumbnailSqlParamPath ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindText( paramIndex, aPath )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamWidth ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aSize.iWidth )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamHeight ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aSize.iHeight )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamOriginalWidth ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aOriginalSize.iWidth )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamOriginalHeight ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aOriginalSize.iHeight )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamFormat ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aFormat )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamFlags ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aFlags )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamSize ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aThumbnailSize )); + + if( aThumbnailId > 0 ) + { + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamId ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aThumbnailId )); + } + else + { + TN_DEBUG1( "CThumbnailStore::StoreThumbnailL( ) aThumbnailId == 0" ); + } + + // orientation temporarily to 0 + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamOrientation ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, 0 )); + + // thumb from associated path + TInt fromPath = aThumbFromPath; + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamThumbFromPath ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, fromPath )); + + // try getting modification time from file + TTime timeStamp; + + if (aPath.Length()) + { + iFs.Modified(aPath, timeStamp); + } + else + { + // otherwise current time + timeStamp.UniversalTime(); + } + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamModified ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt64( paramIndex, timeStamp.Int64() )); + + User::LeaveIfError( stmt.Exec()); + CleanupStack::PopAndDestroy( &stmt ); + + RSqlStatement stmtData; + CleanupClosePushL( stmtData ); + // Insert into ThumbnailInfoData + TInt err = stmtData.Prepare( iDatabase, KThumbnailInsertTempThumbnailInfoData ); + +#ifdef _DEBUG + TPtrC errorMsg = iDatabase.LastErrorMessage(); + TN_DEBUG2( "CThumbnailStore::FetchThumbnailL() KThumbnailInsertTempThumbnailInfoData %S" , &errorMsg); +#endif + User::LeaveIfError( err ); + + paramIndex = stmtData.ParameterIndex( KThumbnailSqlParamData ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmtData.BindBinary( paramIndex, aData )); + + User::LeaveIfError( stmtData.Exec()); + CleanupStack::PopAndDestroy( &stmtData ); + + // Commit transaction + transaction.CommitL(); + CleanupStack::PopAndDestroy( &transaction ); + + iBatchItemCount++; + + FlushCacheTable(); + +#ifdef _DEBUG + iThumbCounter++; + TN_DEBUG2( "CThumbnailStore::THUMBSTORE-COUNTER----------, Thumbs = %d", iThumbCounter ); + + aStop.UniversalTime(); + TN_DEBUG2( "CThumbnailStore::StoreThumbnailL() insert to table %d ms", (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000); +#endif + TN_DEBUG1( "CThumbnailStore::StoreThumbnailL( const TDes8& ) out" ); + } + + +// --------------------------------------------------------------------------- +// CThumbnailStore::StoreThumbnailL() +// Stores thumbnail image. +// --------------------------------------------------------------------------- +// +void CThumbnailStore::StoreThumbnailL( const TDesC& aPath, CFbsBitmap* + aThumbnail, const TSize& aOriginalSize, TBool /*aCropped*/, const TThumbnailSize aThumbnailSize, + const TThumbnailId aThumbnailId, const TBool aThumbFromPath, TBool aBlackListed ) + { + TN_DEBUG1( "CThumbnailStore::StoreThumbnailL( CFbsBitmap* ) in" ); + + __ASSERT_DEBUG(( aThumbnail ), ThumbnailPanic( EThumbnailNullPointer )); + + // check for duplicates + TBool exists = FindDuplicateL(aPath, aThumbnailId, aThumbnailSize); + + TSize thumbSize = aThumbnail->SizeInPixels(); + for ( TInt i = iPersistentSizes.Count(); --i >= 0; ) + { + TThumbnailPersistentSize & persistentSize = iPersistentSizes[i]; + + // don't store duplicates or custom sizes + if ( !exists && (aThumbnailSize != ECustomThumbnailSize && + thumbSize.iWidth > 0 && thumbSize.iHeight > 0 )) + { + TInt flags = 0; + if ( persistentSize.iCrop ) + { + flags |= KThumbnailDbFlagCropped; + } + + if( aBlackListed ) + { + flags |= KThumbnailDbFlagBlacklisted; + } + + if( (aThumbnailSize == EImageFullScreenThumbnailSize || aThumbnailSize == EVideoFullScreenThumbnailSize || + aThumbnailSize == EAudioFullScreenThumbnailSize) && !aBlackListed ) + { + HBufC8* data = NULL; + CImageEncoder* iEncoder = CImageEncoder::DataNewL( data, KJpegMime(), CImageEncoder::EOptionAlwaysThread ); + TJpegImageData* imageData = new (ELeave) TJpegImageData(); + + // Set some format specific data + imageData->iSampleScheme = TJpegImageData::EColor444; + imageData->iQualityFactor = 75; //? + + CFrameImageData* iFrameImageData = CFrameImageData::NewL(); + + // frameData - ownership passed to iFrameImageData after AppendImageData + User::LeaveIfError(iFrameImageData->AppendImageData(imageData)); + +#ifdef _DEBUG + TN_DEBUG4( "CThumbnailStore::StoreThumbnailL() size %d x %d displaymode %d ", + aThumbnail->SizeInPixels().iWidth, + aThumbnail->SizeInPixels().iHeight, + aThumbnail->DisplayMode()); +#endif + + TRequestStatus request; + iEncoder->Convert( &request, *aThumbnail, iFrameImageData); + User::WaitForRequest( request); + + if(request== KErrNone) + { + TPtr8 ptr = data->Des(); + StoreThumbnailL( aPath, ptr, aThumbnail->SizeInPixels(), aOriginalSize, + EThumbnailFormatJpeg, flags, aThumbnailSize, aThumbnailId, aThumbFromPath ); + } + + delete iFrameImageData; + iFrameImageData = NULL; + + delete iEncoder; + iEncoder = NULL; + delete data; + data = NULL; + } + else + { + CBufFlat* buf = CBufFlat::NewL( KStreamBufferSize ); + CleanupStack::PushL( buf ); + RBufWriteStream stream; + stream.Open( *buf ); + aThumbnail->ExternalizeL( stream ); + + StoreThumbnailL( aPath, buf->Ptr( 0 ), aThumbnail->SizeInPixels(), + aOriginalSize, EThumbnailFormatFbsBitmap, flags, aThumbnailSize, aThumbnailId ); + + CleanupStack::PopAndDestroy( buf ); + } + + break; + } + } + + TN_DEBUG1( "CThumbnailStore::StoreThumbnailL( CFbsBitmap* ) out" ); + } + + +// --------------------------------------------------------------------------- +// Finds possible existing duplicate thumbnail. +// --------------------------------------------------------------------------- +// +TBool CThumbnailStore::FindDuplicateL( const TDesC& aPath, const TThumbnailId aThumbnailId, + const TThumbnailSize& aThumbnailSize ) + { + TN_DEBUG1( "CThumbnailStore::FindDuplicateL()" ); + + TInt rowStatus = 0; + TInt paramIndex = 0; + TInt found = EFalse; + + RSqlStatement stmt; + CleanupClosePushL( stmt ); + + User::LeaveIfError( stmt.Prepare( iDatabase, KTempFindDuplicate )); + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamPath ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindText( paramIndex, aPath )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamId ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aThumbnailId )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamSize ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aThumbnailSize )); + + rowStatus = stmt.Next(); + + //if not found from temp table, look from real table + if(rowStatus != KSqlAtRow) + { + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt ); + CleanupClosePushL( stmt ); + + User::LeaveIfError( stmt.Prepare( iDatabase, KFindDuplicate )); + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamPath ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindText( paramIndex, aPath )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamId ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aThumbnailId )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamSize ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aThumbnailSize )); + + rowStatus = stmt.Next(); + + if(rowStatus == KSqlAtRow) + { + TN_DEBUG1( "CThumbnailStore::FindDuplicateL() - duplicate in main table" ); + + found = ETrue; + } + else + { + TN_DEBUG1( "CThumbnailStore::FindDuplicateL() - no duplicate" ); + } + } + else + { + TN_DEBUG1( "CThumbnailStore::FindDuplicateL() - duplicate in temp table" ); + + found = ETrue; + } + + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt ); + + return found; + } + + +// --------------------------------------------------------------------------- +// Create database tables +// --------------------------------------------------------------------------- +// +void CThumbnailStore::CreateTablesL() + { + TN_DEBUG1( "CThumbnailStore::CreateTablesL()" ); + TInt err = 0; + err = iDatabase.Exec( KThumbnailCreateInfoTable ); + TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailCreateInfoTable err=%d", err ); + err = iDatabase.Exec( KThumbnailCreateInfoDataTable ); + TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailCreateInfoDataTable err=%d", err ); + err = iDatabase.Exec( KThumbnailCreateInfoTableIndex1 ); + TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailCreateInfoTableIndex1 err=%d", err ); + err = iDatabase.Exec( KThumbnailCreateInfoTableIndex2 ); + TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailCreateInfoTableIndex2 err=%d", err ); + err = iDatabase.Exec(KThumbnailVersionTable); + TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailVersionTable err=%d", err ); + User::LeaveIfError( err ); + } + + +// --------------------------------------------------------------------------- +// Get missing sizes by Path +// --------------------------------------------------------------------------- +// +void CThumbnailStore::GetMissingSizesAndIDsL( const TDesC& aPath, TInt aSourceType, RArray < + TThumbnailPersistentSize > & aMissingSizes, TBool& aMissingIDs ) + { + TN_DEBUG2( "CThumbnailStore::GetMissingSizesAndIDsL() aSourceType == %d", aSourceType ); + // define sizes to be checked + const TInt count = iPersistentSizes.Count(); + + for ( TInt i = 0 ; i < count; i++ ) + { + if ( iPersistentSizes[ i ].iSourceType == aSourceType && iPersistentSizes[ i ].iAutoCreate) + { + aMissingSizes.Append( iPersistentSizes[ i ] ); + } + } + + TInt missingSizeCount = aMissingSizes.Count(); + aMissingIDs = EFalse; + + TN_DEBUG3( "CThumbnailStore::GetMissingSizesAndIDsL() missingSizeCount == %d, missingIDs == %d", missingSizeCount, aMissingIDs ); + + // check temp table first + RSqlStatement stmt; + CleanupClosePushL( stmt ); + User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailSelectTempSizeByPath )); + TInt paramIndex = stmt.ParameterIndex( KThumbnailSqlParamPath ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindText( paramIndex, aPath )); + + TInt rowStatus = stmt.Next(); + + TInt round = 1; + TInt size = 0; + TInt id = 0; + + while (round <= 2) + { + while ( rowStatus == KSqlAtRow && missingSizeCount > 0 ) + { + size = stmt.ColumnInt( 0 ); + id = stmt.ColumnInt( 1 ); + + TN_DEBUG2( "CThumbnailStore::GetMissingSizesAndIDsL() id == %d", id ); + + //if TNId is not valid mark that some are missing so that UpdateDb is run later + if ( id <= 0) + { + TN_DEBUG1( "CThumbnailStore::GetMissingSizesAndIDsL() missing ID"); + aMissingIDs = ETrue; + } + + missingSizeCount = aMissingSizes.Count(); + for ( TInt i = 0; i < missingSizeCount; i++ ) + { + if ( aMissingSizes[ i ].iType == size ) + { + TN_DEBUG1( "CThumbnailStore::GetMissingSizesL() -- thumbnail found" ); + aMissingSizes.Remove( i ); + missingSizeCount--; + break; + } + } + + rowStatus = stmt.Next(); + } + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt ); + + // all found + if (missingSizeCount == 0) + { + return; + } + else if (round == 1) + { + // change to real table + CleanupClosePushL( stmt ); + User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailSelectSizeByPath )); + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamPath ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindText( paramIndex, aPath )); + rowStatus = stmt.Next(); + } + + round++; + } + } + + +// --------------------------------------------------------------------------- +// CThumbnailStore::FetchThumbnailL() +// Fetches thumbnail image. +// --------------------------------------------------------------------------- +// +TInt CThumbnailStore::FetchThumbnailL( TThumbnailId aThumbnailId, + CFbsBitmap*& aThumbnail, TDesC8* & aData, TThumbnailSize aThumbnailSize, TSize &aThumbnailRealSize ) + { + TN_DEBUG3( "CThumbnailStore::FetchThumbnailL(%d) aThumbnailSize == %d", aThumbnailId, aThumbnailSize ); + delete aThumbnail; + aThumbnail = NULL; + + RSqlStatement stmt; + CleanupClosePushL( stmt ); + + TInt paramIndex = 0; + TInt found = KErrNotFound; + TInt rowStatus = 0; + TInt column = 0; + TInt count = 0; + TThumbnailSize thumbnailImage = EUnknownThumbnailSize; + TThumbnailSize thumbnailVideo = EUnknownThumbnailSize; + TThumbnailSize thumbnailAudio = EUnknownThumbnailSize; + TBool inTempTable( ETrue ); + + if(aThumbnailSize == EFullScreenThumbnailSize) + { + thumbnailImage = EImageFullScreenThumbnailSize; + thumbnailVideo = EVideoFullScreenThumbnailSize; + thumbnailAudio = EAudioFullScreenThumbnailSize; + } + else if(aThumbnailSize == EGridThumbnailSize) + { + thumbnailImage = EImageGridThumbnailSize; + thumbnailVideo = EVideoGridThumbnailSize; + thumbnailAudio = EAudioGridThumbnailSize; + } + else if(aThumbnailSize == EListThumbnailSize) + { + thumbnailImage = EImageListThumbnailSize; + thumbnailVideo = EVideoListThumbnailSize; + thumbnailAudio = EAudioListThumbnailSize; + } + + if(aThumbnailSize == EFullScreenThumbnailSize || + aThumbnailSize == EGridThumbnailSize || + aThumbnailSize == EListThumbnailSize ) + { + TN_DEBUG1( "CThumbnailStore::FetchThumbnailL() -- No DataType -- TEMP TABLE lookup" ); + User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailSelectTempInfoByIdv2 )); + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamId ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aThumbnailId )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamSizeImage ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, thumbnailImage )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamSizeVideo ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, thumbnailVideo )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamSizeAudio ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, thumbnailAudio )); + + rowStatus = stmt.Next(); + //if not found from temp table, look from real table + if(rowStatus != KSqlAtRow) + { + TN_DEBUG1( "CThumbnailStore::FetchThumbnailL() -- No DataType -- MAIN TABLE lookup" ); + inTempTable = EFalse; + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt ); + CleanupClosePushL( stmt ); + + User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailSelectInfoByIdv2 )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamId ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aThumbnailId )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamSizeImage ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, thumbnailImage )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamSizeVideo ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, thumbnailVideo )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamSizeAudio ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, thumbnailAudio )); + + rowStatus = stmt.Next(); + } + } + else + { + TN_DEBUG1( "CThumbnailStore::FetchThumbnailL() -- TEMP TABLE lookup" ); + User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailSelectTempInfoById )); + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamId ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aThumbnailId )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamSize ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aThumbnailSize )); + + rowStatus = stmt.Next(); + + //if not found from temp table, look from real table + if(rowStatus != KSqlAtRow) + { + TN_DEBUG1( "CThumbnailStore::FetchThumbnailL() -- MAIN TABLE lookup" ); + inTempTable = EFalse; + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt ); + CleanupClosePushL( stmt ); + + User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailSelectInfoById )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamId ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aThumbnailId )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamSize ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aThumbnailSize )); + + rowStatus = stmt.Next(); + } + } + if(rowStatus == KSqlAtRow) + { + TN_DEBUG1( "CThumbnailStore::FetchThumbnailL() -- thumbnail found" ); + // Check whether blacklisted thumbnail entry modified. + // If thumbnail is marked as blacklisted and timestamp has + // changed, delete thumbnails from tables and leave with + // KErrNotFound to get thumbnail regenerated. + column = 4; + TInt flags = stmt.ColumnInt( column ); + if( flags & KThumbnailDbFlagBlacklisted ) + { + TBool modified = EFalse; + CheckModifiedByIdL( aThumbnailId, inTempTable, modified ); + if( modified ) + { + // Close db to get deletion of thumbnails executed. + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt ); + DeleteThumbnailsL( aThumbnailId ); + User::Leave( KErrNotFound ); + } + else + { + User::Leave( KErrCompletion ); + } + } + + found = KErrNone; + count = 0; + count++; + column = 0; + TInt format = stmt.ColumnInt( column++ ); + if(format == 1 /*TThumbnailFormat::EThumbnailFormatJpeg */ ) + { + TPtrC8 ptr = stmt.ColumnBinaryL( column++ ); + HBufC8* data = ptr.AllocL() ; + aThumbnail = NULL; + aData = data; + + } else { + TPtrC8 ptr = stmt.ColumnBinaryL( column ); + RDesReadStream stream( ptr ); + aThumbnail = new( ELeave )CFbsBitmap(); + aThumbnail->InternalizeL( stream ); + aData = NULL; + } + + //fetch real size of TN + column = 2; + aThumbnailRealSize.iWidth = stmt.ColumnInt( column++ ); + aThumbnailRealSize.iHeight = stmt.ColumnInt( column ); + } + else + { + TN_DEBUG1( "CThumbnailStore::FetchThumbnailL() -- thumbnail NOT found" ); + } + + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt ); + + User::LeaveIfError( found ); + return found; + } + + +// --------------------------------------------------------------------------- +// CThumbnailStore::FetchThumbnailL() +// Fetches thumbnail image. +// --------------------------------------------------------------------------- +// +void CThumbnailStore::FetchThumbnailL( const TDesC& aPath, CFbsBitmap* & + aThumbnail, TDesC8* & aData, const TThumbnailSize aThumbnailSize, TSize &aThumbnailRealSize ) + { + TN_DEBUG3( "CThumbnailStore::FetchThumbnailL(%S) aThumbnailSize==%d", &aPath, aThumbnailSize ); + delete aThumbnail; + aThumbnail = NULL; + + RSqlStatement stmt; + CleanupClosePushL( stmt ); + + TInt paramIndex = 0; + TInt found = KErrNotFound; + TInt rowStatus = 0; + TInt column = 0; + TBool inTempTable = ETrue; + + TN_DEBUG1( "CThumbnailStore::FetchThumbnailL() -- TEMP TABLE lookup" ); + TInt err = stmt.Prepare( iDatabase, KThumbnailSelectTempInfoByPath ); + +#ifdef _DEBUG + TPtrC errorMsg = iDatabase.LastErrorMessage(); + TN_DEBUG2( "CThumbnailStore::FetchThumbnailL() %S" , &errorMsg); +#endif + User::LeaveIfError( err ); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamPath ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindText( paramIndex, aPath )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamSize ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aThumbnailSize )); + + rowStatus = stmt.Next(); + + //if not found from temp table, look from real table + if(rowStatus != KSqlAtRow) + { + TN_DEBUG1( "CThumbnailStore::FetchThumbnailL() -- MAIN TABLE lookup" ); + inTempTable = EFalse; + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt ); + CleanupClosePushL( stmt ); + + User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailSelectInfoByPath )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamPath ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindText( paramIndex, aPath )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamSize ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aThumbnailSize )); + + rowStatus = stmt.Next(); + } + + if(rowStatus == KSqlAtRow) + { + TN_DEBUG1( "CThumbnailStore::FetchThumbnailL() -- thumbnail found" ); + // Check whether blacklisted thumbnail entry modified. + // If thumbnail is marked as blacklisted and timestamp has + // changed, delete thumbnails from tables and leave with + // KErrNotFound to get thumbnail regenerated. + column = 4; + TInt flags = stmt.ColumnInt( column ); + if( flags & KThumbnailDbFlagBlacklisted && aPath.Length() ) + { + TBool modified = EFalse; + CheckModifiedByPathL( aPath, inTempTable, modified ); + if( modified ) + { + // Close db to get deletion of thumbnails executed. + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt ); + DeleteThumbnailsL( aPath ); + User::Leave( KErrNotFound ); + } + else + { + User::Leave( KErrCompletion ); + } + } + else if( !(flags & KThumbnailDbFlagBlacklisted) ) + { + found = KErrNone; + column = 0; + TInt format = stmt.ColumnInt( column++ ); + if(format == 1 /*TThumbnailFormat::EThumbnailFormatJpeg */ ) + { + TPtrC8 ptr = stmt.ColumnBinaryL( column++ ); + HBufC8* data = ptr.AllocL() ; + aThumbnail = NULL; + aData = data; + + } else { + + TPtrC8 ptr = stmt.ColumnBinaryL( column++ ); + RDesReadStream stream( ptr ); + aThumbnail = new( ELeave )CFbsBitmap(); + aThumbnail->InternalizeL( stream ); + aData = NULL; + } + + //fetch real size of TN + column = 2; + aThumbnailRealSize.iWidth = stmt.ColumnInt( column++ ); + aThumbnailRealSize.iHeight = stmt.ColumnInt( column ); + } + } + else + { + TN_DEBUG1( "CThumbnailStore::FetchThumbnailL() -- thumbnail NOT found" ); + } + + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt ); + + User::LeaveIfError( found ); + } + +// ----------------------------------------------------------------------------- +// Delete thumbnails for given object file by Path +// ----------------------------------------------------------------------------- +// +void CThumbnailStore::DeleteThumbnailsL( const TDesC& aPath ) + { + RThumbnailTransaction transaction( iDatabase ); + CleanupClosePushL( transaction ); + transaction.BeginL(); + RSqlStatement stmt; + CleanupClosePushL( stmt ); + + TInt paramIndex = 0; + TInt paramIndex1 = 0; + TInt paramIndex2 = 0; + TInt rowStatus = 0; + TInt column = 0; + TInt rowid = 0; + TInt deleteCount = 0; + + TN_DEBUG1( "CThumbnailStore::DeleteThumbnailsByPathL() -- TEMP TABLE lookup" ); + TInt err = stmt.Prepare( iDatabase, KTempThumbnailSqlSelectRowIDInfoByPath); + User::LeaveIfError( err ); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamPath ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindText( paramIndex, aPath )); + + rowStatus = stmt.Next(); + RSqlStatement stmt_info; + CleanupClosePushL( stmt_info ); + err = stmt_info.Prepare( iDatabase, KTempThumbnailSqlDeleteInfoByPath); + RSqlStatement stmt_infodata; + CleanupClosePushL( stmt_infodata ); + err = stmt_infodata.Prepare( iDatabase, KTempThumbnailSqlDeleteInfoDataByPath); + + + while(rowStatus == KSqlAtRow) + { + rowid = stmt.ColumnInt( column ); + paramIndex1 = stmt_info.ParameterIndex( KThumbnailSqlParamRowID ); + User::LeaveIfError( paramIndex1 ); + User::LeaveIfError( stmt_info.BindInt( paramIndex1, rowid )); + + deleteCount = stmt_info.Exec(); + stmt_info.Reset(); + User::LeaveIfError( deleteCount ); + + paramIndex2 = stmt_infodata.ParameterIndex( KThumbnailSqlParamRowID ); + User::LeaveIfError( paramIndex2 ); + User::LeaveIfError( stmt_infodata.BindInt( paramIndex2, rowid )); + + deleteCount = stmt_infodata.Exec(); + stmt_infodata.Reset(); + User::LeaveIfError( deleteCount ); + + TN_DEBUG1( "CThumbnailStore::DeleteThumbnailsByPathL() -- TEMP TABLE lookup - thumbnail deleted" ); + + // fetch another row (temp table rowIDs are updated immediately) + stmt.Reset(); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamPath ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindText( paramIndex, aPath )); + + rowStatus = stmt.Next(); + } + stmt_infodata.Close(); + stmt_info.Close(); + CleanupStack::PopAndDestroy( &stmt_infodata ); + CleanupStack::PopAndDestroy( &stmt_info ); + + + //look from real table + TN_DEBUG1( "CThumbnailStore::DeleteThumbnailByPathL() -- MAIN TABLE lookup" ); + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt ); + CleanupClosePushL( stmt ); + User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailSqlSelectRowIDInfoByPath )); + + User::LeaveIfError( err ); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamPath ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindText( paramIndex, aPath )); + + rowStatus = stmt.Next(); + CleanupClosePushL( stmt_info ); + err = stmt_info.Prepare( iDatabase, KThumbnailSqlDeleteInfoByPath); + CleanupClosePushL( stmt_infodata ); + err = stmt_infodata.Prepare( iDatabase, KThumbnailSqlDeleteInfoDataByPath); + + + while(rowStatus == KSqlAtRow) + { + rowid = stmt.ColumnInt( column ); + paramIndex1 = stmt_info.ParameterIndex( KThumbnailSqlParamRowID ); + User::LeaveIfError( paramIndex1 ); + User::LeaveIfError( stmt_info.BindInt( paramIndex1, rowid )); + + deleteCount = stmt_info.Exec(); + stmt_info.Reset(); + User::LeaveIfError( deleteCount ); + + paramIndex2 = stmt_infodata.ParameterIndex( KThumbnailSqlParamRowID ); + User::LeaveIfError( paramIndex2 ); + User::LeaveIfError( stmt_infodata.BindInt( paramIndex2, rowid )); + + deleteCount = stmt_infodata.Exec(); + stmt_infodata.Reset(); + User::LeaveIfError( deleteCount ); + + TN_DEBUG1( "CThumbnailStore::DeleteThumbnailByPathL() -- MAIN TABLE lookup - thumbnail deleted" ); + + rowStatus = stmt.Next(); + } + + stmt_infodata.Close(); + stmt_info.Close(); + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt_infodata ); + CleanupStack::PopAndDestroy( &stmt_info ); + CleanupStack::PopAndDestroy( &stmt ); + transaction.CommitL(); + CleanupStack::PopAndDestroy( &transaction ); + } + +// ----------------------------------------------------------------------------- +// Delete thumbnails for given object file by Id +// ----------------------------------------------------------------------------- +// +void CThumbnailStore::DeleteThumbnailsL( const TThumbnailId& aTNId ) + { +#ifdef _DEBUG + TTime aStart, aStop; + aStart.UniversalTime(); +#endif + + TInt paramIndex = 0; + TInt paramIndex1 = 0; + TInt paramIndex2 = 0; + TInt rowStatus = 0; + TInt column = 0; + TInt rowid = 0; + TInt deleteCount = 0; + + RThumbnailTransaction transaction( iDatabase ); + CleanupClosePushL( transaction ); + transaction.BeginL(); + RSqlStatement stmt; + CleanupClosePushL( stmt ); + + TN_DEBUG1( "CThumbnailStore::DeleteThumbnailsByIdL() -- TEMP TABLE lookup" ); + TInt err = stmt.Prepare( iDatabase, KTempThumbnailSqlSelectRowIDInfoByID); + User::LeaveIfError( err ); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamId ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aTNId )); + + rowStatus = stmt.Next(); + RSqlStatement stmt_info; + CleanupClosePushL( stmt_info ); + err = stmt_info.Prepare( iDatabase, KTempThumbnailSqlDeleteInfoByID); + RSqlStatement stmt_infodata; + CleanupClosePushL( stmt_infodata ); + err = stmt_infodata.Prepare( iDatabase, KTempThumbnailSqlDeleteInfoDataByID); + + + while(rowStatus == KSqlAtRow) + { + rowid = stmt.ColumnInt( column ); + paramIndex1 = stmt_info.ParameterIndex( KThumbnailSqlParamRowID ); + User::LeaveIfError( paramIndex1 ); + User::LeaveIfError( stmt_info.BindInt( paramIndex1, rowid )); + + err = stmt_info.Exec(); + stmt_info.Reset(); + User::LeaveIfError( err ); + + paramIndex2 = stmt_infodata.ParameterIndex( KThumbnailSqlParamRowID ); + User::LeaveIfError( paramIndex2 ); + User::LeaveIfError( stmt_infodata.BindInt( paramIndex2, rowid )); + + err = stmt_infodata.Exec(); + stmt_infodata.Reset(); + User::LeaveIfError( err ); + deleteCount++; + + TN_DEBUG1( "CThumbnailStore::DeleteThumbnailsByIdL() -- TEMP TABLE lookup - thumbnail deleted" ); + + // fetch another row (temp table rowIDs are updated immediately) + stmt.Reset(); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamId ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aTNId )); + + rowStatus = stmt.Next(); + } + + stmt_infodata.Close(); + stmt_info.Close(); + CleanupStack::PopAndDestroy( &stmt_infodata ); + CleanupStack::PopAndDestroy( &stmt_info ); + + + //look from real table + TN_DEBUG1( "CThumbnailStore::DeleteThumbnailByIdL() -- MAIN TABLE lookup" ); + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt ); + CleanupClosePushL( stmt ); + User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailSqlSelectRowIDInfoByID )); + + User::LeaveIfError( err ); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamId ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aTNId )); + + rowStatus = stmt.Next(); + CleanupClosePushL( stmt_info ); + err = stmt_info.Prepare( iDatabase, KThumbnailSqlDeleteInfoByID); + CleanupClosePushL( stmt_infodata ); + err = stmt_infodata.Prepare( iDatabase, KThumbnailSqlDeleteInfoDataByID); + + + while(rowStatus == KSqlAtRow) + { + rowid = stmt.ColumnInt( column ); + paramIndex1 = stmt_info.ParameterIndex( KThumbnailSqlParamRowID ); + User::LeaveIfError( paramIndex1 ); + User::LeaveIfError( stmt_info.BindInt( paramIndex1, rowid )); + + err = stmt_info.Exec(); + stmt_info.Reset(); + User::LeaveIfError( err ); + + paramIndex2 = stmt_infodata.ParameterIndex( KThumbnailSqlParamRowID ); + User::LeaveIfError( paramIndex2 ); + User::LeaveIfError( stmt_infodata.BindInt( paramIndex2, rowid )); + + err = stmt_infodata.Exec(); + stmt_infodata.Reset(); + User::LeaveIfError( err ); + deleteCount++; + + TN_DEBUG1( "CThumbnailStore::DeleteThumbnailByIdL() -- MAIN TABLE lookup - thumbnail deleted" ); + + rowStatus = stmt.Next(); + } + + stmt_infodata.Close(); + stmt_info.Close(); + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt_infodata ); + CleanupStack::PopAndDestroy( &stmt_info ); + CleanupStack::PopAndDestroy( &stmt ); + transaction.CommitL(); + CleanupStack::PopAndDestroy( &transaction ); + +#ifdef _DEBUG + aStop.UniversalTime(); + TN_DEBUG2( "CThumbnailStore::DeleteThumbnailsByIdL() took %d ms", (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000); +#endif + + if(!deleteCount) + { + User::Leave(KErrNotFound); + } + } + + +// --------------------------------------------------------------------------- +// CThumbnailStore::PersistentSizes() +// --------------------------------------------------------------------------- +// +void CThumbnailStore::SetPersistentSizes(const RArray < TThumbnailPersistentSize > &aSizes) + { + iPersistentSizes = aSizes; + } + +// --------------------------------------------------------------------------- +// CThumbnailStore::FlushCacheTable() +// --------------------------------------------------------------------------- +// +void CThumbnailStore::FlushCacheTable( TBool aForce ) + { + TN_DEBUG1("CThumbnailStore::FlushCacheTable() in"); + + StopAutoFlush(); + + if(iBatchItemCount <= 0) + { + // cache empty + return; + } + + if(iBatchItemCount < KMaxBatchItems && !aForce) + { + //some items in cache + StartAutoFlush(); + return; + } + + //cache full, flush now + iBatchItemCount = 0; + +#ifdef _DEBUG + TTime aStart, aStop; + aStart.UniversalTime(); +#endif + + // Move data from temp table to main.... + TInt err_begin = iDatabase.Exec( KThumbnailBeginTransaction ); + TN_DEBUG2("CThumbnailStore::FlushCacheTable() KThumbnailBeginTransaction %d", err_begin); + + TInt err_tempinfo = iDatabase.Exec( KThumbnailMoveFromTempInfoToMainTable ); + TN_DEBUG2("CThumbnailStore::FlushCacheTable() KThumbnailMoveFromTempInfoToMainTable %d", err_tempinfo); + + TInt err_tempdata = iDatabase.Exec( KThumbnailMoveFromTempDataToMainTable ); + TN_DEBUG2("CThumbnailStore::FlushCacheTable() KThumbnailMoveFromTempDataToMainTable %d", err_tempdata); + + TInt err_delinfo = iDatabase.Exec( KThumbnailDeleteFromTempInfoTable ); + TN_DEBUG2("CThumbnailStore::FlushCacheTable() KThumbnailDeleteFromTempInfoTable %d", err_delinfo); + + TInt err_deldata = iDatabase.Exec( KThumbnailDeleteFromTempDataTable ); + TN_DEBUG2("CThumbnailStore::FlushCacheTable() KThumbnailDeleteFromTempDataTable %d", err_deldata); + + + if( err_tempinfo < 0 || err_tempdata < 0 || err_delinfo < 0 || err_deldata < 0 ) + { + TInt err = iDatabase.Exec( KThumbnailRollbackTransaction ); + TN_DEBUG2("CThumbnailStore::FlushCacheTable() KThumbnailRollbackTransaction %d", err); + } + else + { + TInt err_commit = iDatabase.Exec( KThumbnailCommitTransaction ); + TN_DEBUG2("CThumbnailStore::FlushCacheTable() KThumbnailCommitTransaction %d", err_commit); + } + +#ifdef _DEBUG + aStop.UniversalTime(); + TN_DEBUG2( "CThumbnailStore::FlushCacheTable() took %d ms", (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000); +#endif + + TN_DEBUG1("CThumbnailStore::FlushCacheTable() out"); + } + + +// ----------------------------------------------------------------------------- +// Find store for thumbnails by Id +// ----------------------------------------------------------------------------- +// +void CThumbnailStore::FindStoreL(TThumbnailId aThumbnailId) + { + TN_DEBUG2( "CThumbnailStore::FindStore( %d )", aThumbnailId ); + RSqlStatement stmt; + CleanupClosePushL( stmt ); + + TInt paramIndex = 0; + TInt found = KErrNotFound; + TInt rowStatus = 0; + + TN_DEBUG1( "CThumbnailStore::FindStore() -- TEMP TABLE lookup" ); + User::LeaveIfError( stmt.Prepare( iDatabase, KTempThumbnailSqlSelectRowIDInfoByID )); + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamId ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aThumbnailId )); + + rowStatus = stmt.Next(); + + //if not found from temp table, look from real table + if(rowStatus != KSqlAtRow) + { + TN_DEBUG1( "CThumbnailStore::FindStore() -- MAIN TABLE lookup" ); + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt ); + CleanupClosePushL( stmt ); + + User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailSqlSelectRowIDInfoByID )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamId ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aThumbnailId )); + + rowStatus = stmt.Next(); + } + + if( rowStatus == KSqlAtRow ) + { + TN_DEBUG1( "CThumbnailStore::FindStore() -- thumbnail found" ); + found = KErrNone; + } + else + { + TN_DEBUG1( "CThumbnailStore::FindStore() -- thumbnail NOT found" ); + } + + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt ); + + User::LeaveIfError( found ); + } + +// ----------------------------------------------------------------------------- +// Updates path in current store by Id +// ----------------------------------------------------------------------------- +// +TBool CThumbnailStore::UpdateStoreL( TThumbnailId aItemId, const TDesC& aNewPath ) + { + TN_DEBUG3( "CThumbnailStore::UpdateStore( %d, %S) by ID", aItemId, &aNewPath); + + TBool doUpdate(EFalse); + TPath oldPath; + TInt column = 0; + + RSqlStatement stmt; + CleanupClosePushL( stmt ); + + //check if path needs updating in temp table + User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailSelectTempPathByID )); + + TInt paramIndex = stmt.ParameterIndex( KThumbnailSqlParamId ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aItemId )); + + TInt rowStatus = stmt.Next(); + + //if not found from temp table, look from real table + if(rowStatus != KSqlAtRow) + { + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt ); + CleanupClosePushL( stmt ); + + //check if path needs updating in main table + User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailSelectPathByID )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamId ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aItemId )); + + rowStatus = stmt.Next(); + } + + if(rowStatus == KSqlAtRow) + { + TN_DEBUG1( "CThumbnailStore::UpdateStore() -- matching TN ID found" ); + oldPath = stmt.ColumnTextL(column); + + if(oldPath.CompareF(aNewPath) != 0) + { + TN_DEBUG1( "CThumbnailStore::UpdateStore() -- path no match" ); + doUpdate = ETrue; + } + else + { + TN_DEBUG1( "CThumbnailStore::UpdateStore() -- path match, skip..." ); + } + } + + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt ); + + if(!doUpdate) + { + TN_DEBUG2( "CThumbnailStore::UpdateStore() -- no need to update old path=%S", &oldPath ); + return EFalse; + } + + //Encapsulate update to Transaction + RThumbnailTransaction transaction( iDatabase ); + CleanupClosePushL( transaction ); + transaction.BeginL(); + + CleanupClosePushL( stmt ); + + TN_DEBUG1( "CThumbnailStore::UpdateStore() -- do temp path update" ); + + User::LeaveIfError( stmt.Prepare( iDatabase, KTempThumbnailSqlUpdateById )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamPath ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindText( paramIndex, aNewPath )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamId ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aItemId )); + User::LeaveIfError( stmt.Exec()); + + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt ); + CleanupClosePushL( stmt ); + + TN_DEBUG1( "CThumbnailStore::UpdateStore() -- do main table path update" ); + + User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailSqlUpdateById )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamPath ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindText( paramIndex, aNewPath )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamId ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aItemId )); + + User::LeaveIfError( stmt.Exec()); + CleanupStack::PopAndDestroy( &stmt ); + + // Commit transaction + transaction.CommitL(); + CleanupStack::PopAndDestroy( &transaction ); + + return ETrue; + } + +// ----------------------------------------------------------------------------- +// Update IDs by Path +// ----------------------------------------------------------------------------- +// +void CThumbnailStore::UpdateStoreL( const TDesC& aPath, TThumbnailId aNewId ) + { + TN_DEBUG3( "CThumbnailStore::UpdateStore( %S, %d ) by Path", &aPath, aNewId); + +#ifdef _DEBUG + TTime aStart, aStop; + aStart.UniversalTime(); +#endif + + //Encapsulate update to Transaction + RThumbnailTransaction transaction( iDatabase ); + CleanupClosePushL( transaction ); + transaction.BeginL(); + + RSqlStatement stmt; + CleanupClosePushL( stmt ); + + TN_DEBUG1( "CThumbnailStore::UpdateStoreL() -- do temp ID update" ); + + TInt err = stmt.Prepare( iDatabase, KTempThumbnailUpdateIdByPath ); + +#ifdef _DEBUG + TPtrC errorMsg = iDatabase.LastErrorMessage(); + TN_DEBUG2( "CThumbnailStore::UpdateStoreL() KTempThumbnailUpdateIdByPath %S" , &errorMsg); +#endif + + User::LeaveIfError( err ); + + TInt paramIndex = stmt.ParameterIndex( KThumbnailSqlParamId ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aNewId )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamPath ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindText( paramIndex, aPath )); + + err = stmt.Exec(); + + TN_DEBUG2( "CThumbnailStore::UpdateStoreL() err==%d", err ); + + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt ); + CleanupClosePushL( stmt ); + + TN_DEBUG1( "CThumbnailStore::UpdateStoreL() -- do main table ID update" ); + + err = stmt.Prepare( iDatabase, KThumbnailUpdateIdByPath ); + +#ifdef _DEBUG + TPtrC errorMsg2 = iDatabase.LastErrorMessage(); + TN_DEBUG2( "CThumbnailStore::UpdateStoreL() KThumbnailUpdateIdByPath %S" , &errorMsg2); +#endif + + User::LeaveIfError( err ); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamId ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aNewId )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamPath ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindText( paramIndex, aPath )); + + err = stmt.Exec(); + + TN_DEBUG2( "CThumbnailStore::UpdateStoreL() err==%d", err ); + + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt ); + + // Commit transaction + transaction.CommitL(); + CleanupStack::PopAndDestroy( &transaction ); + +#ifdef _DEBUG + aStop.UniversalTime(); + TN_DEBUG2( "CThumbnailStore::UpdateStoreL() took %d ms", (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000); +#endif + } + +// ----------------------------------------------------------------------------- +// Checks if given modification timestamp is newer than in DB +// ----------------------------------------------------------------------------- +// +TBool CThumbnailStore::CheckModifiedL( const TThumbnailId aItemId, const TInt64 aModified ) + { + TN_DEBUG2( "CThumbnailStore::CheckModifiedL( %d )", aItemId); + + TInt column = 0; + + RSqlStatement stmt; + CleanupClosePushL( stmt ); + + User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailSelectTempModifiedByID )); + + TInt paramIndex = stmt.ParameterIndex( KThumbnailSqlParamId ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aItemId )); + + TInt rowStatus = stmt.Next(); + + //if not found from temp table, look from real table + if(rowStatus != KSqlAtRow) + { + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt ); + CleanupClosePushL( stmt ); + + User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailSelectModifiedByID )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamId ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aItemId )); + + rowStatus = stmt.Next(); + } + + TBool modified = EFalse; + + if(rowStatus == KSqlAtRow) + { + TInt64 oldModified = stmt.ColumnInt64( column ); + + if (oldModified < aModified) + { + TN_DEBUG1( "CThumbnailStore::CheckModifiedL() -- timestamp is newer than original" ); + modified = ETrue; + } + else if (oldModified > aModified) + { + TN_DEBUG1( "CThumbnailStore::CheckModifiedL() -- timestamp is older than original" ); + } + else if (oldModified == aModified) + { + TN_DEBUG1( "CThumbnailStore::CheckModifiedL() -- timestamp is the same as original" ); + } + } + + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt ); + + return modified; + } + +// ----------------------------------------------------------------------------- +// Fetches thumbnails from store by Id +// ----------------------------------------------------------------------------- +// +void CThumbnailStore::FetchThumbnailsL(TThumbnailId aItemId, RArray < TThumbnailDatabaseData* >& aThumbnails) + { + TN_DEBUG1( "CThumbnailStore::FetchThumbnails()" ); + RSqlStatement stmt; + CleanupClosePushL( stmt ); + + // first temp table + User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailSelectTempById )); + + TInt paramIndex = stmt.ParameterIndex( KThumbnailSqlParamId ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aItemId )); + + TInt rowStatus = stmt.Next(); + + TPath path; + TPath tnPath; + while ( rowStatus == KSqlAtRow) + { + TN_DEBUG1( "CThumbnailStore::FetchThumbnails() -- thumbnail found from temp table" ); + + TInt column = 0; + + TThumbnailDatabaseData* newRow = new(ELeave) TThumbnailDatabaseData; + + TInt err = stmt.ColumnText( column++, newRow->iPath ); + newRow->iTnId = stmt.ColumnInt( column++ ); + newRow->iSize = stmt.ColumnInt( column++ ); + newRow->iFormat = stmt.ColumnInt( column++ ); + err = stmt.ColumnText( column++, newRow->iTnPath); + newRow->iWidth = stmt.ColumnInt( column++ ); + newRow->iHeight = stmt.ColumnInt( column++ ); + newRow->iOrigWidth = stmt.ColumnInt( column++ ); + newRow->iOrigHeight = stmt.ColumnInt( column++ ); + newRow->iFlags = stmt.ColumnInt( column++ ); + newRow->iVideoPosition = stmt.ColumnInt( column++ ); + newRow->iOrientation = stmt.ColumnInt( column++ ); + newRow->iThumbFromPath = stmt.ColumnInt( column++ ); + newRow->iModified = stmt.ColumnInt64( column++ ); + + if(newRow->iFormat == 0) + { + TPtrC8 ptr = stmt.ColumnBinaryL( column++ ); + RDesReadStream stream( ptr ); + newRow->iBlob = new( ELeave )CFbsBitmap(); + newRow->iBlob->InternalizeL( stream ); + } + else if(newRow->iFormat == 1) + { + TPtrC8 ptr = stmt.ColumnBinaryL( column++ ); + HBufC8* data = ptr.AllocL() ; + newRow->iBlob = NULL; + newRow->iData = data; + } + + aThumbnails.Append( newRow ); + + rowStatus = stmt.Next(); + } + + // then real table + stmt.Close(); + CleanupStack::PopAndDestroy(&stmt); + CleanupClosePushL( stmt ); + User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailSelectById )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamId ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aItemId )); + + rowStatus = stmt.Next(); + while ( rowStatus == KSqlAtRow) + { + TN_DEBUG1( "CThumbnailStore::FetchThumbnails() -- thumbnail found from real table" ); + + TInt column = 0; + + TThumbnailDatabaseData* newRow = new(ELeave) TThumbnailDatabaseData; + + TInt err = stmt.ColumnText( column++, newRow->iPath ); + newRow->iTnId = stmt.ColumnInt( column++ ); + newRow->iSize = stmt.ColumnInt( column++ ); + newRow->iFormat = stmt.ColumnInt( column++ ); + err = stmt.ColumnText( column++, newRow->iTnPath); + newRow->iWidth = stmt.ColumnInt( column++ ); + newRow->iHeight = stmt.ColumnInt( column++ ); + newRow->iOrigWidth = stmt.ColumnInt( column++ ); + newRow->iOrigHeight = stmt.ColumnInt( column++ ); + newRow->iFlags = stmt.ColumnInt( column++ ); + newRow->iVideoPosition = stmt.ColumnInt( column++ ); + newRow->iOrientation = stmt.ColumnInt( column++ ); + newRow->iThumbFromPath = stmt.ColumnInt( column++ ); + newRow->iModified = stmt.ColumnInt64( column++ ); + + if(newRow->iFormat == 0) + { + TPtrC8 ptr = stmt.ColumnBinaryL( column++ ); + RDesReadStream stream( ptr ); + newRow->iBlob = new( ELeave )CFbsBitmap(); + newRow->iBlob->InternalizeL( stream ); + } + else if(newRow->iFormat == 1) + { + TPtrC8 ptr = stmt.ColumnBinaryL( column++ ); + HBufC8* data = ptr.AllocL() ; + newRow->iBlob = NULL; + newRow->iData = data; + } + + aThumbnails.Append( newRow ); + + rowStatus = stmt.Next(); + } + + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt ); + } + +// ----------------------------------------------------------------------------- +// Stores thumbnails to store +// ----------------------------------------------------------------------------- +// + +void CThumbnailStore::StoreThumbnailsL(const TDesC& aNewPath, RArray < TThumbnailDatabaseData* >& aThumbnails) + { + TN_DEBUG1( "CThumbnailStore::StoreThumbnails()" ); + + TInt ThumbnailCount = aThumbnails.Count(); + RSqlStatement stmt; + for ( TInt i = 0; i < ThumbnailCount; i++ ) + { + RThumbnailTransaction transaction( iDatabase ); + CleanupClosePushL( transaction ); + transaction.BeginL(); + + CleanupClosePushL( stmt ); + + User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailInsertThumbnailInfoByPathAndId )); + + TInt paramIndex = stmt.ParameterIndex( KThumbnailSqlParamPath ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindText( paramIndex, aNewPath )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamWidth ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aThumbnails[ i ]->iWidth )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamHeight ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aThumbnails[ i ]->iHeight )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamOriginalWidth ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aThumbnails[ i ]->iOrigWidth )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamOriginalHeight ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aThumbnails[ i ]->iOrigHeight )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamFormat ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aThumbnails[ i ]->iFormat )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamFlags ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aThumbnails[ i ]->iFlags )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamSize ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aThumbnails[ i ]->iSize )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamId ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aThumbnails[ i ]->iTnId )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamOrientation ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aThumbnails[ i ]->iOrientation )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamThumbFromPath ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aThumbnails[ i ]->iThumbFromPath )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamModified ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt64( paramIndex, aThumbnails[ i ]->iModified )); + + User::LeaveIfError( stmt.Exec()); + CleanupStack::PopAndDestroy( &stmt ); + + RSqlStatement stmtData; + CleanupClosePushL( stmtData ); + TInt err = stmtData.Prepare( iDatabase, KThumbnailInsertTempThumbnailInfoData ); + + if(aThumbnails[ i ]->iFormat == 0) + { + CBufFlat* buf = CBufFlat::NewL( KStreamBufferSize ); + CleanupStack::PushL( buf ); + RBufWriteStream stream; + stream.Open( *buf ); + aThumbnails[ i ]->iBlob->ExternalizeL( stream ); + paramIndex = stmtData.ParameterIndex( KThumbnailSqlParamData ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmtData.BindBinary( paramIndex, buf->Ptr( 0 ) )); + CleanupStack::PopAndDestroy( buf ); + delete aThumbnails[i]->iBlob; + aThumbnails[i]->iBlob = NULL; + } + else if(aThumbnails[ i ]->iFormat == 1) + { + paramIndex = stmtData.ParameterIndex( KThumbnailSqlParamData ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmtData.BindBinary( paramIndex, *aThumbnails[ i ]->iData )); + delete aThumbnails[i]->iData; + aThumbnails[i]->iData = NULL; + } + + User::LeaveIfError( stmtData.Exec()); + CleanupStack::PopAndDestroy( &stmtData ); + + // Commit transaction + transaction.CommitL(); + CleanupStack::PopAndDestroy( &transaction ); + + delete aThumbnails[i]; + aThumbnails[i] = NULL; + iBatchItemCount++; + } + + FlushCacheTable(); + } + +// ----------------------------------------------------------------------------- +// CheckVersionAndImeiL() +// ----------------------------------------------------------------------------- +// +TInt CThumbnailStore::CheckImeiL() + { + TN_DEBUG1( "CThumbnailStore::CheckImeiL()" ); + RSqlStatement stmt; + CleanupClosePushL( stmt ); + + TInt rowStatus = 0; + TInt column = 0; + TBuf imei; + + TInt ret = stmt.Prepare( iDatabase, KThumbnailSelectFromVersion ); + if(ret < 0 ) + { + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt ); + return KErrNotSupported; + } + + rowStatus = stmt.Next(); + + if ( rowStatus == KSqlAtRow) + { + column=2; + stmt.ColumnText( column++, imei); + } + + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt ); + + if( imei == iImei ) + { + return KErrNone; + } + else + { + return KErrNotSupported; + } + } + +// ----------------------------------------------------------------------------- +// CheckVersionAndImeiL() +// ----------------------------------------------------------------------------- +// +TInt CThumbnailStore::CheckVersionL() + { + TN_DEBUG1( "CThumbnailStore::CheckVersionL()" ); + RSqlStatement stmt; + CleanupClosePushL( stmt ); + + TInt rowStatus = 0; + TInt column = 0; + TInt minor = 0; + TInt major = 0; + + + TInt ret = stmt.Prepare( iDatabase, KThumbnailSelectFromVersion ); + if(ret < 0 ) + { + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt ); + return KErrNotSupported; + } + + rowStatus = stmt.Next(); + + if ( rowStatus == KSqlAtRow) + { + major = stmt.ColumnInt( column++); + minor = stmt.ColumnInt( column++); + } + + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt ); + + if(major == KMajor && minor == KMinor ) + { + return KErrNone; + } + else + { + return KErrNotSupported; + } + } + + +// ----------------------------------------------------------------------------- +// CheckVersionAndImeiL() +// ----------------------------------------------------------------------------- +// +TInt CThumbnailStore::CheckMediaIDL() + { + + TN_DEBUG1( "CThumbnailStore::CheckMediaIDL()" ); + TInt err = 0; + + TVolumeInfo volumeinfo; + err = iFs.Volume(volumeinfo, iDrive); + TUint id = volumeinfo.iUniqueID; + TBuf<50> mediaid; + mediaid.Num(id); + + RFile64 file; + err = file.Open(iFs, mediaid, EFileShareReadersOrWriters); + if(err) + { + file.Create(iFs, mediaid, EFileShareReadersOrWriters ); + file.Close(); + return KErrNotSupported; + } + file.Close(); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// AddVersionAndImeiL() +// ----------------------------------------------------------------------------- +// +void CThumbnailStore::AddVersionAndImeiL() + { + + TN_DEBUG1( "CThumbnailStore::AddVersionAndImei()" ); + RSqlStatement stmt; + CleanupClosePushL( stmt ); + + TInt paramIndex = 0; + + User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailInsertToVersion )); + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamImei ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindText( paramIndex, iImei )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamMinor ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, KMinor )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamMajor ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, KMajor )); + + User::LeaveIfError( stmt.Exec()); + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt ); + + } + +// ----------------------------------------------------------------------------- +// ResetThumbnailIDs() +// ----------------------------------------------------------------------------- +// +void CThumbnailStore::ResetThumbnailIDs() + { + TN_DEBUG1( "CThumbnailStore::ResetThumbnailIDs()" ); + + TInt err = iDatabase.Exec( KTempThumbnailResetIDs ); + TN_DEBUG2( "CThumbnailStore::ResetThumbnailIDs() KThumbnailResetIDs - temp table, err=%d", err ); + + err = iDatabase.Exec( KThumbnailResetIDs ); + TN_DEBUG2( "CThumbnailStore::ResetThumbnailIDs() KThumbnailResetIDs - main table, err=%d", err ); + } + + +// ----------------------------------------------------------------------------- +// UpdateImeiL() +// ----------------------------------------------------------------------------- +// +void CThumbnailStore::UpdateImeiL() + { + TN_DEBUG1( "CThumbnailStore::UpdateImeiL()" ); + RSqlStatement stmt; + CleanupClosePushL( stmt ); + + + TInt ret = stmt.Prepare( iDatabase, KThumbnailUpdateIMEI ); + + TInt paramIndex = stmt.ParameterIndex( KThumbnailSqlParamImei ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindText( paramIndex, iImei )); + + TInt err = stmt.Exec(); + + TN_DEBUG2( "CThumbnailStore::UpdateImeiL() err==%d", err ); + + User::LeaveIfError( err ); + + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt ); + } + +// ----------------------------------------------------------------------------- +// StartAutoFlush() +// ----------------------------------------------------------------------------- +// +void CThumbnailStore::StartAutoFlush() + { + TN_DEBUG1( "CThumbnailStore::StartAutoFlush()" ); + + TInt err = KErrNone; + + if( iAutoFlushTimer ) + { + iAutoFlushTimer->Cancel(); + } + else + { + TRAP(err, iAutoFlushTimer = CPeriodic::NewL(CActive::EPriorityIdle) ); + } + + if (err != KErrNone) + { + TN_DEBUG2( "CThumbnailStore::StartAutoFlush() - Error creating timer (%d)", err ); + } + else + { + iAutoFlushTimer->Start( KAutoFlushTimeout, KAutoFlushTimeout, + TCallBack(AutoFlushTimerCallBack, this)); + } + } + +// ----------------------------------------------------------------------------- +// StopAutoFlush() +// ----------------------------------------------------------------------------- +// +void CThumbnailStore::StopAutoFlush() + { + TN_DEBUG1( "CThumbnailStore::StopAutoFlush()" ); + if( iAutoFlushTimer ) + { + iAutoFlushTimer->Cancel(); + } + } + +// --------------------------------------------------------------------------- +// CThumbnailStore::AutoFlushTimerCallBack() +// --------------------------------------------------------------------------- +// +TInt CThumbnailStore::AutoFlushTimerCallBack(TAny* aAny) + { + TN_DEBUG1( "CThumbnailStore::AutoFlushTimerCallBack()"); + CThumbnailStore* self = static_cast( aAny ); + + self->FlushCacheTable(ETrue); + + return KErrNone; // Return value ignored by CPeriodic + } + +TInt CThumbnailStore::CheckRowIDsL() + { + TN_DEBUG1( "CThumbnailStore::CheckRowIDs()"); + + RSqlStatement stmt; + CleanupClosePushL( stmt ); + TInt column = 0; + TInt rowStatus = 0; + TInt64 inforows = 0; + TInt64 datarows = 0; + + TInt ret = stmt.Prepare( iDatabase, KGetInfoRowID ); + if(ret < 0) + { + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt ); + return KErrNotSupported; + } + rowStatus = stmt.Next(); + + if ( rowStatus == KSqlAtRow) + { + inforows = stmt.ColumnInt64( column ); + } + + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt ); + + CleanupClosePushL( stmt ); + ret = stmt.Prepare( iDatabase, KGetDataRowID ); + if(ret < 0) + { + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt ); + return KErrNotSupported; + } + rowStatus = stmt.Next(); + + if ( rowStatus == KSqlAtRow) + { + datarows = stmt.ColumnInt64( column ); + } + + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt ); + + if( inforows != datarows) + { + return KErrNotSupported; + } + else + { + return KErrNone; + } + } + +void CThumbnailStore::CheckModifiedByIdL( TUint32 aId, TBool aTempTable, + TBool& aModified ) + { + TN_DEBUG1( "CThumbnailStore::CheckModifiedByIdL()"); + + RSqlStatement stmt; + CleanupClosePushL( stmt ); + TInt column( 0 ); + + if( aTempTable ) + { + User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailSelectTempPathModifiedByID ) ); + } + else + { + User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailSelectPathModifiedByID ) ); + } + TInt paramIndex = stmt.ParameterIndex( KThumbnailSqlParamId ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aId )); + + TInt rowStatus = stmt.Next(); + + if(rowStatus == KSqlAtRow) + { + TPath path = stmt.ColumnTextL(column++); + + if (path.Length()) + { + TInt64 modified = stmt.ColumnInt64( column ); + TTime timeStamp; + iFs.Modified( path, timeStamp ); + + if( modified != timeStamp.Int64() ) + { + aModified = ETrue; + } + } + } + + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt ); + } + +void CThumbnailStore::CheckModifiedByPathL( const TDesC& aPath, TBool aTempTable, + TBool& aModified ) + { + TN_DEBUG1( "CThumbnailStore::CheckModifiedByPathL()"); + + RSqlStatement stmt; + CleanupClosePushL( stmt ); + TInt column( 0 ); + + if( aTempTable ) + { + User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailSelectTempModifiedByPath ) ); + } + else + { + User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailSelectModifiedByPath ) ); + } + TInt paramIndex = stmt.ParameterIndex( KThumbnailSqlParamPath ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindText( paramIndex, aPath )); + + TInt rowStatus = stmt.Next(); + + if(rowStatus == KSqlAtRow) + { + TInt64 modified = stmt.ColumnInt64( column ); + TTime timeStamp; + iFs.Modified( aPath, timeStamp ); + + if( modified != timeStamp.Int64() ) + { + aModified = ETrue; + } + } + + stmt.Close(); + CleanupStack::PopAndDestroy( &stmt ); + } + +// ----------------------------------------------------------------------------- +// RemoveDbFlagL() +// ----------------------------------------------------------------------------- +// +void CThumbnailStore::RemoveDbFlagL(TThumbnailDbFlags aFlag) + { + TN_DEBUG1( "CThumbnailStore::RemoveBlacklistedFlag()" ); + + RSqlStatement stmt; + CleanupClosePushL( stmt ); + + User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailRemoveBlacklistedFlag )); + + TInt paramIndex = stmt.ParameterIndex( KThumbnailSqlParamFlag ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, aFlag )); + + TInt err = stmt.Exec(); + + TN_DEBUG2( "CThumbnailStore::RemoveBlacklistedFlag() - main table, err=%d", err ); + + CleanupStack::PopAndDestroy( &stmt ); + } + +// End of file diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailtask.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailtask.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,228 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Base class for thumbnail server tasks + * +*/ + + +#include +#include +#include "thumbnailtask.h" +#include "thumbnailtaskprocessor.h" +#include "thumbnailprovider.h" +#include "thumbnaillog.h" +#include "thumbnailpanic.h" +#include "thumbnailserversession.h" // ConvertSqlErrToE32Err() +#include "thumbnailmanagerconstants.h" + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CThumbnailTask::CThumbnailTask() +// C++ default constructor can NOT contain any code, that might leave. +// --------------------------------------------------------------------------- +// +CThumbnailTask::CThumbnailTask( CThumbnailTaskProcessor& aProcessor, TInt + aPriority ): CActive( EPriorityStandard ), iProcessor( aProcessor ), + iPriority( aPriority ), iState( EIdle ) + { + TN_DEBUG2( "CThumbnailTask(0x%08x)::CThumbnailTask()", this); + CActiveScheduler::Add( this ); + } + + +// --------------------------------------------------------------------------- +// CThumbnailTask::~CThumbnailTask() +// Destructor. +// --------------------------------------------------------------------------- +// +CThumbnailTask::~CThumbnailTask() + { + Cancel(); + CancelMessage(); + } + + +// --------------------------------------------------------------------------- +// CThumbnailTask::Priority() +// Returns priority of task. +// --------------------------------------------------------------------------- +// +TInt CThumbnailTask::Priority()const + { + return iPriority; + } + + +// --------------------------------------------------------------------------- +// CThumbnailTask::State() +// Returns state of task. +// --------------------------------------------------------------------------- +// +CThumbnailTask::TTaskState CThumbnailTask::State()const + { + return iState; + } + + +// --------------------------------------------------------------------------- +// CThumbnailTask::StartL() +// --------------------------------------------------------------------------- +// +void CThumbnailTask::StartL() + { + TN_DEBUG3( "CThumbnailTask(0x%08x)::StartL() iState == %d ", this, iState ); + __ASSERT_DEBUG(( iState != ERunning ), ThumbnailPanic( EAlreadyRunning )); + iState = ERunning; + } + + +// --------------------------------------------------------------------------- +// CThumbnailTask::DoCancel() +// --------------------------------------------------------------------------- +// +void CThumbnailTask::DoCancel() + { + // No implementation required + } + + +// --------------------------------------------------------------------------- +// CThumbnailTask::Complete() +// --------------------------------------------------------------------------- +// +void CThumbnailTask::Complete( TInt aReason ) + { + TN_DEBUG4( "CThumbnailTask(0x%08x)::Complete(aReason=%d) iState was %d", + this, aReason, iState ); + + if ( iState != EComplete ) + { + iState = EComplete; + + if ( iMessage.Handle()) + { + if(iMessage.Identity() == KDaemonUid ) + { + iProcessor.SetDaemonAsProcess(ETrue); + } + else + { + iProcessor.SetDaemonAsProcess(EFalse); + } + iMessage.Complete( CThumbnailServerSession::ConvertSqlErrToE32Err( aReason )); + ResetMessageData(); + } + + iProcessor.TaskComplete( this ); + } + } + +// --------------------------------------------------------------------------- +// CThumbnailTask::Continue() +// --------------------------------------------------------------------------- +// +void CThumbnailTask::Continue() + { + if ( iState != EComplete ) + { + iState = EIdle; + } + + iProcessor.TaskComplete( this ); + } + +// --------------------------------------------------------------------------- +// CThumbnailTask::StartError() +// --------------------------------------------------------------------------- +// +void CThumbnailTask::StartError( TInt aError ) + { + // This is called if StartL() left. Complete this task with an error and + // continue processing. + TN_DEBUG3( "CThumbnailTask(0x%08x)::StartError(aError=%d)", this, aError ); + Complete( aError ); + } + + +// --------------------------------------------------------------------------- +// CThumbnailTask::ChangeTaskPriority() +// Changes priority of the task. +// --------------------------------------------------------------------------- +// +void CThumbnailTask::ChangeTaskPriority( TInt aNewPriority ) + { + iPriority = aNewPriority; + } + + +// --------------------------------------------------------------------------- +// CThumbnailTask::SetMessageData() +// --------------------------------------------------------------------------- +// +void CThumbnailTask::SetMessageData( const TThumbnailServerRequestId& + aRequestId, const RMessage2& aMessage ) + { + iMessage = aMessage; + iRequestId = aRequestId; + } + +// --------------------------------------------------------------------------- +// CThumbnailTask::SetMessageData() +// --------------------------------------------------------------------------- +// +void CThumbnailTask::SetMessageData( const TThumbnailServerRequestId& + aRequestId ) + { + iMessage = RMessage2(); + iRequestId = aRequestId; + } + + +// --------------------------------------------------------------------------- +// CThumbnailTask::ResetMessageData() +// --------------------------------------------------------------------------- +// +void CThumbnailTask::ResetMessageData() + { + iMessage = RMessage2(); + iRequestId = TThumbnailServerRequestId(); + } + + +// --------------------------------------------------------------------------- +// CThumbnailTask::ResetMessageData() +// Returns id of specific task. +// --------------------------------------------------------------------------- +// +TThumbnailServerRequestId CThumbnailTask::RequestId()const + { + return iRequestId; + } + + +// --------------------------------------------------------------------------- +// CThumbnailTask::CancelMessage() +// --------------------------------------------------------------------------- +// +void CThumbnailTask::CancelMessage() + { + if ( iMessage.Handle()) + { + iMessage.Complete( KErrCancel ); + ResetMessageData(); + } + } + +// End of file diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailtaskprocessor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailtaskprocessor.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,527 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Processor object for running queued tasks + * +*/ + + +#include +#include +#include "thumbnailtaskprocessor.h" +#include "thumbnailtask.h" +#include "thumbnailprovider.h" +#include "thumbnailmanageruids.hrh" +#include "thumbnailmanagerconstants.h" +#include "thumbnailgeneratetask.h" +#include "thumbnailpanic.h" + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CThumbnailTaskProcessor::NewL() +// Two-phased constructor. +// --------------------------------------------------------------------------- +// +CThumbnailTaskProcessor* CThumbnailTaskProcessor::NewL() + { + CThumbnailTaskProcessor* self = new( ELeave )CThumbnailTaskProcessor(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// CThumbnailTaskProcessor::CThumbnailTaskProcessor() +// C++ default constructor can NOT contain any code, that might leave. +// --------------------------------------------------------------------------- +// +CThumbnailTaskProcessor::CThumbnailTaskProcessor(): CActive( CActive + ::EPriorityStandard ) + { + CActiveScheduler::Add( this ); + } + + +// --------------------------------------------------------------------------- +// CThumbnailTaskProcessor::ConstructL() +// Symbian 2nd phase constructor can leave. +// --------------------------------------------------------------------------- +// +void CThumbnailTaskProcessor::ConstructL() + { + // define PS property + TInt ret = RProperty::Delete(KServerIdle, KIdle); + TN_DEBUG2( "CThumbnailTaskProcessor::CThumbnailTaskProcessor() Delete KServerIdle %d", ret); + + ret=RProperty::Define(KServerIdle, KIdle, RProperty::EInt); + TN_DEBUG2( "CThumbnailTaskProcessor::ConstructL() Define KServerIdle %d", ret); + + // attach to the property + ret = iProperty.Attach(KServerIdle, KIdle, EOwnerThread); + TN_DEBUG2( "CThumbnailTaskProcessor::ConstructL()Attach %d", ret); + + // set initial PS value + ret = iProperty.Set( ETrue ); + TN_DEBUG2( "CThumbnailTaskProcessor::ConstructL() Set IDLE ETrue %d", ret ); + iIdle = ETrue; + + iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityIdle); + + iTimerActive = EFalse; + + iIsDaemonAsProcess = EFalse; + } + + +// --------------------------------------------------------------------------- +// CThumbnailTaskProcessor::~CThumbnailTaskProcessor() +// Destructor. +// --------------------------------------------------------------------------- +// +CThumbnailTaskProcessor::~CThumbnailTaskProcessor() + { + Cancel(); + iTasks.ResetAndDestroy(); + iProperty.Close(); + TInt ret = RProperty::Delete(KServerIdle, KIdle); + TN_DEBUG2( "CThumbnailTaskProcessor::CThumbnailTaskProcessor() Delete KServerIdle %d", ret); + + if(iPeriodicTimer) + { + iPeriodicTimer->Cancel(); + } + delete iPeriodicTimer; + + } + + +// --------------------------------------------------------------------------- +// CThumbnailTaskProcessor::AddTaskL() +// Adds new task to the task queue. +// --------------------------------------------------------------------------- +// +void CThumbnailTaskProcessor::AddTaskL( CThumbnailTask* aTask ) + { + TN_DEBUG1( "CThumbnailTaskProcessor::AddTaskL()"); + __ASSERT_DEBUG(( aTask ), ThumbnailPanic( EThumbnailNullPointer )); + const TInt taskCount = iTasks.Count(); + iTasks.AppendL( aTask ); + + if ( !IsActive() && !taskCount ) + { + // this is the first task in queue, go active now + iActiveTask = aTask; + + SetActive(); + TRequestStatus* statusPtr = &iStatus; + User::RequestComplete( statusPtr, KErrNone ); + } + } + + +// --------------------------------------------------------------------------- +// CThumbnailTaskProcessor::RemoveTask() +// Removes specific tasks from the queue. +// --------------------------------------------------------------------------- +// +TInt CThumbnailTaskProcessor::RemoveTask( const TThumbnailServerRequestId& + aRequestId ) + { + TN_DEBUG2( "CThumbnailTaskProcessor::RemoveTask() - request ID: %d", aRequestId.iRequestId); + + TBool cancel = EFalse; + TInt res = KErrNotFound; + + for ( TInt i = iTasks.Count(); --i >= 0; ) + { + CThumbnailTask* task = iTasks[i]; + if ( task->RequestId() == aRequestId ) + { + if ( task->State() != CThumbnailTask::ERunning ) + { + // Remove task from queue + delete task; + iTasks.Remove( i ); + + TN_DEBUG2( "CThumbnailTaskProcessor::RemoveTask() - removed request ID: %d", aRequestId.iRequestId); + } + else + { + // Task is already running, canceled first + task->Cancel(); + delete task; + iTasks.Remove( i ); + cancel = ETrue; + + TN_DEBUG2( "CThumbnailTaskProcessor::RemoveTask() - canceled & removed request ID: %d", aRequestId.iRequestId); + } + + res = KErrNone; + + // don't break, because there could be many tasks related to the same request ID + } + } + + // no tasks active anymore + if ( cancel ) + { + Cancel(); + TaskComplete(NULL); + } + + TN_DEBUG2( "CThumbnailTaskProcessor::RemoveTask() - remaining task count: %d", iTasks.Count()); + + return res; + } + +// --------------------------------------------------------------------------- +// CThumbnailTaskProcessor::RemoveTasks() +// Removes specific task from the queue. +// --------------------------------------------------------------------------- +// +void CThumbnailTaskProcessor::RemoveTasks( CThumbnailServerSession* aSession ) + { + TN_DEBUG1( "CThumbnailTaskProcessor::RemoveTasks()"); + + TBool cancel = EFalse; + + for ( TInt i = iTasks.Count(); --i >= 0; ) + { + CThumbnailTask* task = iTasks[i]; + if ( task->RequestId().iSession == aSession) + { + if ( task->State() != CThumbnailTask::ERunning ) + { + TThumbnailRequestId id = task->RequestId().iRequestId; + + // Remove task from queue + delete task; + iTasks.Remove( i ); + + TN_DEBUG2( "CThumbnailTaskProcessor::RemoveTasks() - removed request ID: %d", id); + } + else + { + TN_DEBUG1( "CThumbnailTaskProcessor::RemoveTasks() - task still running"); + + TThumbnailRequestId id = task->RequestId().iRequestId; + + // Task is already running, canceled first + task->ResetMessageData(); + task->Cancel(); + delete task; + iTasks.Remove( i ); + cancel = ETrue; + + TN_DEBUG2( "CThumbnailTaskProcessor::RemoveTasks() - canceled & removed request ID: %d", id); + } + } + } + + // no tasks active anymore + if ( cancel ) + { + Cancel(); + TaskComplete(NULL); + } + + TN_DEBUG2( "CThumbnailTaskProcessor::RemoveTasks() - remaining task count: %d", iTasks.Count()); + } + +// --------------------------------------------------------------------------- +// CThumbnailTaskProcessor::RemoveAllTasks() +// Removes specific task from the queue. +// --------------------------------------------------------------------------- +// +void CThumbnailTaskProcessor::RemoveAllTasks() + { + TN_DEBUG1( "CThumbnailTaskProcessor::RemoveAllTasks()"); + + TBool cancel = EFalse; + + for ( TInt i = iTasks.Count(); --i >= 0; ) + { + CThumbnailTask* task = iTasks[i]; + if ( task->State() != CThumbnailTask::ERunning ) + { + TThumbnailRequestId id = task->RequestId().iRequestId; + + // Remove task from queue + delete task; + iTasks.Remove( i ); + + TN_DEBUG2( "CThumbnailTaskProcessor::RemoveTasks() - removed request ID: %d", id); + } + else + { + TN_DEBUG1( "CThumbnailTaskProcessor::RemoveTasks() - task still running"); + + TThumbnailRequestId id = task->RequestId().iRequestId; + + // Task is already running, canceled first + task->ResetMessageData(); + task->Cancel(); + delete task; + iTasks.Remove( i ); + cancel = ETrue; + + TN_DEBUG2( "CThumbnailTaskProcessor::RemoveTasks() - canceled & removed request ID: %d", id); + } + } + + // no tasks active anymore + if ( cancel ) + { + Cancel(); + TaskComplete(NULL); + } + + TN_DEBUG1( "CThumbnailTaskProcessor::RemoveAllTasks() - Task removed because of starting format" ); + } + +// --------------------------------------------------------------------------- +// CThumbnailTaskProcessor::ChangeTaskPriority() +// Changes priority of a task. +// --------------------------------------------------------------------------- +// +TInt CThumbnailTaskProcessor::ChangeTaskPriority( const + TThumbnailServerRequestId& aRequestId, const TInt aNewPriority ) + { + TInt err = KErrNotFound; + const TInt count = iTasks.Count(); + for ( TInt i( 0 ); i < count; i++ ) + { + if ( iTasks[i]->RequestId() == aRequestId ) + { + iTasks[i]->ChangeTaskPriority( aNewPriority ); + err = KErrNone; + break; + } + } + return err; + } + + +// --------------------------------------------------------------------------- +// CThumbnailTaskProcessor::RunL() +// --------------------------------------------------------------------------- +// +void CThumbnailTaskProcessor::RunL() + { + iActiveTask = NULL; + TInt priority( KMinTInt ); + TInt taskPriority; + +#ifdef _DEBUG + TN_DEBUG2( "CThumbnailTaskProcessor::TASKPROCESSOR-COUNTER---------- in, Tasks = %d", iTasks.Count() ); +#endif + + /* + // remove completed tasks and run priorised task + for ( TInt i = 0; i < iTasks.Count(); i++ ) + { + CThumbnailTask* task = iTasks[i]; + if ( task->State() == CThumbnailTask::EComplete ) + { + // delete completed task + delete task; + iTasks.Remove( i ); + + // correct the index so that no tasks are skipped + i--; + if(i <= -1) + { + i = -1; + } + }*/ + + // remove completed tasks and run priorised task + for ( TInt i = iTasks.Count(); --i >= 0; ) + { + CThumbnailTask* task = iTasks[i]; + if ( task->State() == CThumbnailTask::EComplete ) + { + // Delete completed task + delete task; + iTasks.Remove( i ); + } + else + { + if( task->State() == CThumbnailTask::EIdle ) + { + taskPriority = task->Priority(); + if ( taskPriority > priority ) + { + priority = taskPriority; + iActiveTask = task; + } + } + } + } + + if ( iActiveTask ) + { + iActiveTask->StartL(); + } + +#ifdef _DEBUG + TN_DEBUG2( "CThumbnailTaskProcessor::TASKPROCESSOR-COUNTER---------- out, Tasks = %d", iTasks.Count() ); +#endif + + //update PS value for Daemon + if( iTasks.Count() > 0 && iIdle) + { + //set not idle + if(iTimerActive) + { + iPeriodicTimer->Cancel(); + iTimerActive = EFalse; + } + TInt ret = iProperty.Set( EFalse ); + TN_DEBUG2( "CThumbnailTaskProcessor::RunL() iProperty Set EFalse %d", ret ); + iIdle = EFalse; + } + else + { + if(!iIdle) + { + //set idle + if(iIsDaemonAsProcess) + { + if(iTimerActive) + { + iPeriodicTimer->Cancel(); + iTimerActive = EFalse; + } + TN_DEBUG1( "CThumbnailTaskProcessor::RunL() - daemon is the process"); + TInt ret = iProperty.Set( ETrue ); + TN_DEBUG2( "CThumbnailTaskProcessor::RunL() iProperty Set ETrue %d", ret ); + iIdle = ETrue; + } + else + { + TN_DEBUG1( "CThumbnailTaskProcessor::RunL() - daemon is not the process - start timer"); + if(iTimerActive) + { + iPeriodicTimer->Cancel(); + iTimerActive = EFalse; + } + iPeriodicTimer->Start( KHarvestingCompleteTimeout, KHarvestingCompleteTimeout, + TCallBack(PeriodicTimerCallBack, this)); + iTimerActive = ETrue; + } + } + } + } + +// --------------------------------------------------------------------------- +// Handle any error from RunL +// --------------------------------------------------------------------------- +// +TInt CThumbnailTaskProcessor::RunError( TInt aError ) + { + TN_DEBUG1( "CThumbnailTaskProcessor::RunError()"); + if ( iActiveTask ) + { + // This will complete the task and continue processing from the + // next task + iActiveTask->StartError( aError ); + } + return KErrNone; + } + +// --------------------------------------------------------------------------- +// CThumbnailTaskProcessor::DoCancel() +// --------------------------------------------------------------------------- +// +void CThumbnailTaskProcessor::DoCancel() + { + // No implementation required + } + + +// --------------------------------------------------------------------------- +// CThumbnailTaskProcessor::TaskComplete() +// Marks task to completed +// --------------------------------------------------------------------------- +// +void CThumbnailTaskProcessor::TaskComplete( CThumbnailTask* /*aTask*/ ) + { + TN_DEBUG1( "CThumbnailTaskProcessor::TaskComplete()"); + + if ( iTasks.Count() && !IsActive()) + { + // More tasks yet to be run + SetActive(); + TRequestStatus* statusPtr = &iStatus; + User::RequestComplete( statusPtr, KErrNone ); + } + else if( iTasks.Count() == 0 && !iIdle) + { + if(iIsDaemonAsProcess) + { + if(iTimerActive) + { + iPeriodicTimer->Cancel(); + iTimerActive = EFalse; + } + TN_DEBUG1( "CThumbnailTaskProcessor::TaskComplete() - daemon is the process"); + TInt ret = iProperty.Set( ETrue ); + TN_DEBUG2( "CThumbnailTaskProcessor::TaskComplete() iProperty Set ETrue %d", ret ); + iIdle = ETrue; + } + else + { + if(iTimerActive) + { + iPeriodicTimer->Cancel(); + iTimerActive = EFalse; + } + iPeriodicTimer->Start( KPSKeyTimeout, KPSKeyTimeout, + TCallBack(PeriodicTimerCallBack, this)); + iTimerActive = ETrue; + } + } + } + +// --------------------------------------------------------------------------- +// CThumbnailTaskProcessor::PeriodicTimerCallBack() +// --------------------------------------------------------------------------- +// +TInt CThumbnailTaskProcessor::PeriodicTimerCallBack(TAny* aAny) + { + TN_DEBUG1( "CThumbnailTaskProcessor::PeriodicTimerCallBack()"); + + CThumbnailTaskProcessor* self = static_cast( aAny ); + + self->iTimerActive = EFalse; + self->iPeriodicTimer->Cancel(); + TInt ret = self->iProperty.Set( ETrue ); + TN_DEBUG2( "CThumbnailTaskProcessor::PeriodicTimerCallBack() iProperty Set ETrue %d", ret ); + self->iIdle = ETrue; + + return KErrNone; // Return value ignored by CPeriodic + } + +void CThumbnailTaskProcessor::SetDaemonAsProcess(TBool aValue) + { + TN_DEBUG2( "CThumbnailTaskProcessor::SetDaemonAsProcess() Daemon set %d", aValue ); + iIsDaemonAsProcess = aValue; + } + + +// End of file diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailserver/src/tmshutdownobserver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/tmshutdownobserver.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,119 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Processor +* +*/ + + +#include + +#include "tmshutdownobserver.h" +#include "thumbnailmanagerconstants.h" + +// --------------------------------------------------------------------------- +// CTMShutdownObserver::NewL() +// --------------------------------------------------------------------------- +// +CTMShutdownObserver* CTMShutdownObserver::NewL( MTMShutdownObserver& aObserver, + const TUid& aKeyCategory, + const TInt aPropertyKey, + TBool aDefineKey) + { + CTMShutdownObserver* self = new( ELeave )CTMShutdownObserver( aObserver, + aKeyCategory, + aPropertyKey, + aDefineKey); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------------------------- +// CTMShutdownObserver::CTMShutdownObserver() +// --------------------------------------------------------------------------- +// +CTMShutdownObserver::CTMShutdownObserver( MTMShutdownObserver& aObserver, + const TUid& aKeyCategory, + const TInt aPropertyKey, + TBool aDefineKey) + : CActive( CActive::EPriorityStandard ), iObserver( aObserver ), + iKeyCategory( aKeyCategory ), iPropertyKey(aPropertyKey), iDefineKey( aDefineKey ) + { + CActiveScheduler::Add( this ); + } + +// --------------------------------------------------------------------------- +// CTMShutdownObserver::ConstructL() +// --------------------------------------------------------------------------- +// +void CTMShutdownObserver::ConstructL() + { + // define P&S property types + if (iDefineKey) + { + RProperty::Define(iKeyCategory,iPropertyKey, + RProperty::EInt,KAllowAllPolicy,KPowerMgmtPolicy); + } + + // attach to the property + TInt err = iProperty.Attach(iKeyCategory,iPropertyKey,EOwnerThread); + User::LeaveIfError(err); + + // wait for the previously attached property to be updated + iProperty.Subscribe(iStatus); + SetActive(); + } + +// --------------------------------------------------------------------------- +// CTMShutdownObserver::~CTMShutdownObserver() +// --------------------------------------------------------------------------- +// +CTMShutdownObserver::~CTMShutdownObserver() + { + Cancel(); + iProperty.Close(); + } + +// --------------------------------------------------------------------------- +// CTMShutdownObserver::RunL() +// --------------------------------------------------------------------------- +// +void CTMShutdownObserver::RunL() + { + // resubscribe before processing new value to prevent missing updates + iProperty.Subscribe(iStatus); + SetActive(); + + // retrieve the value + TInt value = 0; + iProperty.Get(value); + + // observer callback + if (value) + { + iObserver.ShutdownNotification(); + } + } + +// --------------------------------------------------------------------------- +// CTMShutdownObserver::DoCancel() +// --------------------------------------------------------------------------- +// +void CTMShutdownObserver::DoCancel() + { + iProperty.Cancel(); + } + +// End of file diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/thumbnailserver/src/tnmgetimei.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/tnmgetimei.cc Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,75 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Helper class to get IMEI number. +* +*/ + + +#include "tnmgetimei.h" +#include "thumbnailmanagerconstants.h" + +CTnmgetimei* CTnmgetimei::NewL() + { + CTnmgetimei *self = CTnmgetimei::NewLC(); + CleanupStack::Pop(); + return self; + } + +CTnmgetimei* CTnmgetimei::NewLC() + { + CTnmgetimei *self = new (ELeave) CTnmgetimei(); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +void CTnmgetimei::ConstructL() + { + iTelephony = CTelephony::NewL(); + CActiveScheduler::Add(this); + } + +CTnmgetimei::~CTnmgetimei() + { + Cancel(); + + delete iTelephony; + } + +TBuf CTnmgetimei::GetIMEI() + { + + CTelephony::TPhoneIdV1Pckg phoneIdPckg( iV1 ); + + iTelephony->GetPhoneId( iStatus, phoneIdPckg ); + SetActive(); + iAsw.Start(); + Deque(); + return iImei; + + } + +void CTnmgetimei::DoCancel() + { + iTelephony->CancelAsync(CTelephony::EGetPhoneIdCancel); + } + +void CTnmgetimei::RunL() + { + if(iStatus == KErrNone) + { + iImei = iV1.iSerialNumber; + } + iAsw.AsyncStop(); + } diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/tmiadrestart/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/tmiadrestart/group/bld.inf Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Build information file +* +*/ + + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_MMPFILES +tmiadrestart.mmp + +// End of File + + diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/tmiadrestart/group/tmiadrestart.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/tmiadrestart/group/tmiadrestart.mmp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Project definition file +* +*/ + + +#include +#include + +VERSION 10.0 +TARGET tmiadrestart.exe +TARGETTYPE EXE +UID 0x0 0x2001FD52 + +CAPABILITY ALL -TCB +VENDORID VID_DEFAULT + +SOURCEPATH ../src +SOURCE tmiadrestart.cpp + +// Default system include paths for middleware layer modules. +MW_LAYER_SYSTEMINCLUDE + +USERINCLUDE ../inc +USERINCLUDE ../../inc +USERINCLUDE ../../thumbagdaemon/inc + +LIBRARY euser.lib + +PAGED +BYTEPAIRCOMPRESSTARGET + +// End of File + + diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/tmiadrestart/inc/tmiadrestart.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/tmiadrestart/inc/tmiadrestart.h Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Thumbnail Manager IAD Restart + * +*/ + + +#ifndef TMIADRESTART_H +#define TMIADRESTART_H + +#include +#include + +GLDEF_C TInt E32Main(); + +#endif // TMIADRESTART_H diff -r 000000000000 -r 2014ca87e772 imagehandlingutilities/thumbnailmanager/tmiadrestart/src/tmiadrestart.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imagehandlingutilities/thumbnailmanager/tmiadrestart/src/tmiadrestart.cpp Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,130 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Thumbnail Manager IAD Restart +* +*/ + + +#include +#include +#include + +#include "thumbnailmanagerconstants.h" + +LOCAL_C void MainL() + { + // delay so that cenrep has time to read new config + User::After(5000000); + + TInt res( KErrNone ); + RProcess process; + TFullName name; + + // find and terminate Thumb AG Daemon + TFindProcess findProcess( KTAGDaemonProcess ); + if ( findProcess.Next(name) == KErrNone ) + { + res = process.Open(name); + + // logon to get termination signal + TRequestStatus status; + process.Logon(status); + + // shutdown using P&S key + RProperty::Set(KTAGDPSNotification,KShutdown,1); + + // blocks here until thread is terminated + User::WaitForRequest(status); + + // reset key + RProperty::Set(KTAGDPSNotification,KShutdown,0); + + process.Close(); + } + + // find and terminate Thumbnail Server + TFindProcess findProcess2( KThumbnailServerProcess ); + if ( findProcess2.Next(name) == KErrNone ) + { + res = process.Open(name); + + // logon to get termination signal + TRequestStatus status; + process.Logon(status); + + // shutdown using P&S key + RProperty::Set(KTMPSNotification,KShutdown,1); + + // blocks here until thread is terminated + User::WaitForRequest(status); + + // reset key + RProperty::Set(KTMPSNotification,KShutdown,0); + + process.Close(); + } + + // delay just in case old daemon hasn't died yet + User::After(2500000); + + // start new ThumbAGDaemon + RProcess server; + TInt retryCount = 0; + + // Create the server process + // KNullDesC param causes server's E32Main() to be run + res = server.Create( KTAGDaemonExe, KNullDesC ); + + // try again 3 times if fails + while ( res != KErrNone) + { + if (retryCount > 2) + { + return; + } + + User::After(2500000); + res = server.Create( KTAGDaemonExe, KNullDesC ); + + retryCount++; + } + + // Process created successfully + TRequestStatus status; + server.Rendezvous( status ); + server.Resume(); // start it going + + // Wait until the completion of the server creation + User::WaitForRequest( status ); + + // Server created successfully + server.Close(); // we're no longer interested in the other process + } + +GLDEF_C TInt E32Main() + { + // Create cleanup stack + __UHEAP_MARK; + CTrapCleanup* cleanup = CTrapCleanup::New(); + + // Run application code inside TRAP harness + TInt err = KErrNone; + TRAP(err, MainL()); + + delete cleanup; + __UHEAP_MARKEND; + return err; + } + +// End of file diff -r 000000000000 -r 2014ca87e772 layers.sysdef.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/layers.sysdef.xml Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,27 @@ + + +]> + + + + + + + + + + + + + + + + + + + + + + + diff -r 000000000000 -r 2014ca87e772 package_definition.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/package_definition.xml Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 000000000000 -r 2014ca87e772 sysdef_1_4_0.dtd --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysdef_1_4_0.dtd Tue Jan 26 15:18:05 2010 +0200 @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +