diff -r dec420019252 -r 4f111d64a341 videocollection/videocollectionwrapper/inc/videocollectionutils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/inc/videocollectionutils.h Thu Apr 01 22:38:49 2010 +0300 @@ -0,0 +1,155 @@ +/* +* 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: VideoCollectionUtils class definition* +*/ + +#ifndef __VIDEOCOLLECTIONUTILS_H__ +#define __VIDEOCOLLECTIONUTILS_H__ + + +// INCLUDES +#include +#include +#include + +class VideoCollectionUtils +{ + + /** + * disable copy-constructor and assignment operator + */ + Q_DISABLE_COPY(VideoCollectionUtils) + +public: + + + /** + * Returns singleton instance for this class. + * + * @return The singleton instance. + */ + static VideoCollectionUtils& instance(); + + /** + * Gets QString value from provided media -object based on attribute provided + * + * @param CMPXMedia* pointer to media object from where to get data + * @param TMPXAttributeData& attribute to look for + * @param QString& wanted value + * + * @return bool true data value gotten ok + */ + template + bool mediaValue(const CMPXMedia *media, const TMPXAttributeData& attribute, QString& result) + { + bool status = false; + if( media && media->IsSupported(attribute)) + { + HBufC* valueText = NULL; + valueText = media->ValueText( attribute ).Alloc(); + if (valueText && valueText->Length() > 0) + { + // temp QString needed to make sure string is initialized correctly (Error #424) + QString text((QChar*)valueText->Des().Ptr(),valueText->Length()); + result = text; + status = true; + } + delete valueText; + } + return status; + } + + /** + * Gets typed value from provided media -object based on attribute provided + * + * @param CMPXMedia* pointer to media object from where to get data + * @param TMPXAttributeData& attribute to look for + * @param T& wanted value + * + * @return bool true data value gotten ok + */ + template + bool mediaValue(const CMPXMedia *media, const TMPXAttributeData& attribute, T& result) + { + bool status = false; + if(media && media->IsSupported(attribute)) + { + T *pointer = 0; + pointer = media->Value(attribute); + if(pointer) + { + result = *pointer; + status = true; + } + } + return status; + } + + /** + * Gets typed pointer from provided media -object based on attribute provided + * + * @param CMPXMedia* pointer to media object from where to get data + * @param TMPXAttributeData& attribute to look for + * + * @return T* pointer to wanted data (NULL if does not succeed) + */ + template + T* mediaValuePtr(const CMPXMedia *media, const TMPXAttributeData& attribute) + { + T *pointer = 0; + if(media && media->IsSupported(attribute)) + { + pointer = media->Value(attribute); + } + return pointer; + } + + /** + * Prepares length string from given value. + * + * @param length Length value in seconds. + * @return Length as string (for example "1min 45sec"). + */ + QString prepareLengthString(quint32 length); + + /** + * Prepares size string from the given value. + * + * @param size Size value in bytes + * @return Size as string (for example "450 kB"). + */ + QString prepareSizeString(quint32 size); + + +private: + + /** + * Default constructor + */ + VideoCollectionUtils(); + + /** + * Destructor + */ + ~VideoCollectionUtils(); + + + +}; +#endif // __VIDEOCOLLECTIONUTILS_H__ + +// End of file + + +