diff -r 3ec52facab4d -r 8192e5b5c935 mpengine/tsrc/unittest_mpmpxdetailsframeworkwrapper/stub/src/mpsongdata.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mpengine/tsrc/unittest_mpmpxdetailsframeworkwrapper/stub/src/mpsongdata.cpp Thu May 27 12:49:57 2010 +0300 @@ -0,0 +1,477 @@ +/* +* 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: Playback Data provider for playback view. +* +*/ + + +#include +#include +#include +#include +#include +#include "stub/inc/mpsongdata.h" +#include "mptrace.h" + +const int KUndefined = -1; + + +MpSongData::MpSongData( QObject *parent ) + : QObject( parent ), + mTitle( NULL ), + mAlbum( NULL ), + mArtist( NULL ), + mComposer( NULL), + mGenre( NULL ), + mYear( NULL ), + mAlbumTrack( NULL ), + mAlbumArt(), + mReqId( KUndefined ) +{ + TX_ENTRY_ARGS("Stub") + TX_EXIT_ARGS("Stub") +} + +MpSongData::~MpSongData() +{ + TX_ENTRY_ARGS("Stub") + TX_EXIT_ARGS("Stub") +} + +void MpSongData::albumArt( HbIcon& icon ) const +{ + TX_ENTRY_ARGS("Stub") + TX_EXIT_ARGS("Stub") +} + + +QString MpSongData::title() const +{ + TX_ENTRY_ARGS("Stub") + return mTitle; +} + +QString MpSongData::album() const +{ + TX_ENTRY_ARGS("Stub") + return mAlbum; +} + +QString MpSongData::artist() const +{ + TX_ENTRY_ARGS("Stub") + return mArtist; +} + +QString MpSongData::comment() const +{ + TX_ENTRY_ARGS("Stub") + return mComment; +} + +QString MpSongData::composer() const +{ + TX_ENTRY_ARGS("Stub") + return mComposer; +} + + +QString MpSongData::genre() const +{ + TX_ENTRY_ARGS("Stub") + return mGenre; +} + + +QString MpSongData::albumTrack() const +{ + TX_ENTRY_ARGS("Stub") + return mAlbumTrack; +} + +QString MpSongData::link() const +{ + TX_ENTRY_ARGS("Stub") + return mLink; +} + +QString MpSongData::year() const +{ + TX_ENTRY_ARGS("Stub") + return mYear; +} + +QString MpSongData::fileName() const +{ + TX_ENTRY_ARGS("Stub") + return mFileName; +} + +QString MpSongData::mimeType() const +{ + TX_ENTRY_ARGS("Stub") + return mMimeType; +} + +QString MpSongData::duration() const +{ + TX_ENTRY_ARGS("Stub") + return mDuration; +} + +QString MpSongData::bitRate() const +{ + TX_ENTRY_ARGS("Stub") + return mBitRate; +} + +QString MpSongData::sampleRate() const +{ + TX_ENTRY_ARGS("Stub") + return mSampleRate; +} + +QString MpSongData::size() const +{ + TX_ENTRY_ARGS("Stub") + return mSize; +} + +QString MpSongData::modified() const +{ + TX_ENTRY_ARGS("Stub") + return mModified; +} + +QString MpSongData::copyright() const +{ + TX_ENTRY_ARGS("Stub") + return mCopyright; +} + +QString MpSongData::musicURL() const +{ + TX_ENTRY_ARGS("Stub") + return mMusicURL; +} + +bool MpSongData::isDrmProtected() const +{ + TX_ENTRY_ARGS("Stub") + return mDrmProtected; +} +bool MpSongData::setTitle( const QString &title ) +{ + TX_ENTRY_ARGS("Stub title =" << title ) + bool change = false; + if ( title != mTitle ) { + change = true; + mTitle = title; + } + TX_EXIT_ARGS("Stub") + return change; +} + +bool MpSongData::setAlbum( const QString &album ) +{ + TX_ENTRY_ARGS( "Stub album =" << album ) + bool change = false; + if ( album != mAlbum ) { + change = true; + mAlbum = album; + } + + return change; +} + +bool MpSongData::setArtist( const QString &artist ) +{ + TX_ENTRY_ARGS("Stub artist =" << artist ) + bool change = false; + if ( artist != mArtist ) { + change = true; + mArtist = artist; + } + TX_EXIT_ARGS("Stub") + return change; +} + +bool MpSongData::setComment( const QString &comment) +{ + TX_ENTRY_ARGS("Stub comment =" << comment ) + bool change = false; + if ( comment != mComment ) { + change = true; + mComment = comment; + } + TX_EXIT_ARGS("Stub") + return change; +} + +bool MpSongData::setComposer( const QString &composer ) +{ + TX_ENTRY_ARGS("Stub composer =" << composer ) + bool change = false; + if ( composer != mComposer ) { + change = true; + mComposer = composer; + } + TX_EXIT_ARGS("Stub") + return change; +} + +bool MpSongData::setGenre( const QString &genre ) +{ + TX_ENTRY_ARGS("Stub genre =" << genre ) + bool change = false; + if ( genre != mGenre ) { + change = true; + mGenre = genre; + } + TX_EXIT_ARGS("Stub") + return change; +} + + +bool MpSongData::setYear( int year ) +{ + TX_ENTRY_ARGS("Stub year =" << year ) + bool change = false; + if ( QString::number(year) != mYear ) { + change = true; + if ( year >= 0 && year < 9999 ) { + mYear = QString::number(year); + } + } + TX_EXIT_ARGS("Stub") + return change; +} + +bool MpSongData::setAlbumTrack( const QString &track ) +{ + TX_ENTRY_ARGS("Stub track =" << track ) + bool change = false; + if ( track != mAlbumTrack ) { + change = true; + mAlbumTrack = track; + } + TX_EXIT_ARGS("Stub") + return change; +} + +void MpSongData::setLink( const QString &link ) +{ + TX_ENTRY_ARGS("Stub Link =" << link ) + mLink = link; + TX_EXIT_ARGS("Stub") +} + +void MpSongData::setAlbumArtUri( const QString &albumArtUri) +{ + TX_ENTRY_ARGS("Stub albumArtUri = " << albumArtUri ) + // Set default album art. + mAlbumArt = mDefaultAlbumArt; + emit albumArtReady(); + TX_EXIT +} + +bool MpSongData::setFileName( const QString &fileName ) +{ + TX_ENTRY_ARGS( "File name =" << fileName ) + bool change = false; + if ( fileName != mFileName ) { + change = true; + mFileName = fileName; + } + TX_EXIT + return change; +} + +bool MpSongData::setMimeType( const QString &mimeType ) +{ + TX_ENTRY_ARGS( "Mime =" << mimeType ) + bool change = false; + if ( mimeType != mMimeType ) { + change = true; + mMimeType = mimeType; + } + TX_EXIT + return change; +} + +bool MpSongData::setDuration( int duration ) +{ + TX_ENTRY_ARGS( "Duration =" << duration ) + bool change = false; + QString timeFormatOne("%1:%2:%3"); + QString timeFormatTwo("%1:%2"); + if ( QString::number( duration ) != mDuration ) { + change = true; + if ( duration >= 3600 ) { + // more than one hours + QString hourStr, minStr, secStr; + int hour = duration / 3600; + int min = duration % 3600 / 60; + int sec = duration % 3600 % 60; + + hourStr = hour >= 10 ? QString::number( hour ) : QString::number( hour ).prepend( "0" ); + minStr = min >= 10 ? QString::number( min ) : QString::number( min ).prepend( "0" ); + secStr = sec >= 10 ? QString::number( sec ) : QString::number( sec ).prepend( "0" ); + mDuration = timeFormatOne.arg( hourStr ).arg( minStr ).arg( secStr ); + } else if ( duration >= 60 && duration < 3600 ) { + // more than one min && less than one hour + QString minStr, secStr; + int min = duration / 60; + int sec = duration % 60; + + minStr = min >= 10 ? QString::number( min ) : QString::number( min ).prepend( "0" ); + secStr = sec >= 10 ? QString::number( sec ) : QString::number( sec ).prepend( "0" ); + mDuration = timeFormatTwo.arg( minStr ).arg( secStr ); + } else if ( duration > 0 && duration < 60 ) { + QString secStr; + secStr = duration >= 10 ? QString::number( duration ) : QString::number( duration ).prepend( "0" ); + mDuration = secStr; + } else { + mDuration = QString(); + } + } + TX_EXIT + return change; +} + +bool MpSongData::setBitRate( int bitRate) +{ + TX_ENTRY_ARGS( "Bit rate =" << bitRate ) + bool change = false; + if ( QString::number( bitRate ) != mBitRate ) { + change = true; + if ( bitRate > 0 ) { + mBitRate = QString::number( bitRate / 1000 ); + } else { + mBitRate = QString(); + } + } + TX_EXIT + return change; +} + +bool MpSongData::setSampleRate( int sampleRate ) +{ + TX_ENTRY_ARGS( "Sample rate =" << sampleRate ) + bool change = false; + if ( QString::number( sampleRate ) != mSampleRate ) { + change = true; + if ( sampleRate > 0 ) { + mSampleRate = QString::number( sampleRate ); + } else { + mSampleRate = QString(); + } + } + TX_EXIT + return change; +} + +bool MpSongData::setSize( int size ) +{ + TX_ENTRY_ARGS( "Size =" << size ) + bool change = false; + if ( QString::number( size ) != mSize ) { + change = true; + mSize = QString::number( size / 1000 ).append( " MB" ); + } + TX_EXIT + return change; +} + +bool MpSongData::setModified( const QString &modified ) +{ + TX_ENTRY_ARGS( "Modified =" << modified ) + bool change = false; + if ( modified != mModified ) { + change = true; + mModified = modified; + } + TX_EXIT + return change; +} + +bool MpSongData::setCopyright( const QString ©right ) +{ + TX_ENTRY_ARGS( "Copyright =" << copyright ) + bool change = false; + if ( copyright != mCopyright ) { + change = true; + mCopyright = copyright; + } + TX_EXIT + return change; +} + +bool MpSongData::setMusicURL( const QString &musicURL ) +{ + TX_ENTRY_ARGS( "Music URL =" << musicURL ) + bool change = false; + if ( musicURL != mMusicURL ) { + change = true; + mMusicURL = musicURL; + } + TX_EXIT + return change; +} + +/*! + Set whether the song is DRM protected +*/ +bool MpSongData::setDrmProtected( bool drmProtected ) +{ + TX_ENTRY_ARGS( "STUB DRM protected =" << drmProtected ) + bool change = false; + if ( drmProtected != mDrmProtected ) { + change = true; + mDrmProtected = drmProtected; + } + TX_EXIT + return change; +} + +void MpSongData::thumbnailReady( + const QPixmap& pixmap, + void *data, + int id, + int error ) +{ + TX_ENTRY_ARGS("Stub") + Q_UNUSED( data ); + TX_EXIT_ARGS("Stub") +} + +void MpSongData::commitPlaybackInfo() +{ + TX_ENTRY_ARGS("Stub") + emit playbackInfoChanged(); + TX_EXIT_ARGS("Stub") +} + +void MpSongData::commitSongDetailInfo() +{ + TX_ENTRY_ARGS("Stub") + emit songDetailInfoChanged(); + TX_EXIT_ARGS("Stub") +} + +QString MpSongData::albumArtBase64() const +{ + TX_ENTRY_ARGS("Stub") + return QString(); +}