mpviewplugins/mpdetailsviewplugin/src/mpsharedata.cpp
author hgs
Fri, 11 Jun 2010 19:36:32 -0500
changeset 37 eb79a7c355bf
parent 36 a0afa279b8fe
permissions -rw-r--r--
201023
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36
hgs
parents: 35
diff changeset
     1
/*
hgs
parents: 35
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents: 35
diff changeset
     3
* All rights reserved.
hgs
parents: 35
diff changeset
     4
* This component and the accompanying materials are made available 
hgs
parents: 35
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
hgs
parents: 35
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents: 35
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents: 35
diff changeset
     8
*
hgs
parents: 35
diff changeset
     9
* Initial Contributors:
hgs
parents: 35
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents: 35
diff changeset
    11
*
hgs
parents: 35
diff changeset
    12
* Contributors:
hgs
parents: 35
diff changeset
    13
*
hgs
parents: 35
diff changeset
    14
* Description: 
hgs
parents: 35
diff changeset
    15
*
hgs
parents: 35
diff changeset
    16
*/
hgs
parents: 35
diff changeset
    17
35
hgs
parents:
diff changeset
    18
#ifdef SHARE_FUNC_ENABLED
hgs
parents:
diff changeset
    19
hgs
parents:
diff changeset
    20
#include "mpsharedata.h"
hgs
parents:
diff changeset
    21
#include "mpsongdata.h"
hgs
parents:
diff changeset
    22
36
hgs
parents: 35
diff changeset
    23
35
hgs
parents:
diff changeset
    24
// TODO OVI_URL needs to come from cenrep
hgs
parents:
diff changeset
    25
const QString OVI_URL = "http://music.ovi.com";
hgs
parents:
diff changeset
    26
hgs
parents:
diff changeset
    27
// The music note symbol that we post if we do not have music store URL.
36
hgs
parents: 35
diff changeset
    28
const QString MUSIC_NOTE_SYMBOL = "♫";
hgs
parents: 35
diff changeset
    29
35
hgs
parents:
diff changeset
    30
hgs
parents:
diff changeset
    31
MpShareData::MpShareData()
hgs
parents:
diff changeset
    32
    : mOwner( 0 ),
hgs
parents:
diff changeset
    33
      mSongData( 0 )
hgs
parents:
diff changeset
    34
{
hgs
parents:
diff changeset
    35
}
hgs
parents:
diff changeset
    36
hgs
parents:
diff changeset
    37
MpShareData::~MpShareData()
hgs
parents:
diff changeset
    38
{
36
hgs
parents: 35
diff changeset
    39
    // Intentionally empty.
35
hgs
parents:
diff changeset
    40
}
hgs
parents:
diff changeset
    41
hgs
parents:
diff changeset
    42
void MpShareData::setOwner( QObject* aOwner )
hgs
parents:
diff changeset
    43
{
hgs
parents:
diff changeset
    44
    mOwner = aOwner;
hgs
parents:
diff changeset
    45
}
hgs
parents:
diff changeset
    46
hgs
parents:
diff changeset
    47
QObject* MpShareData::owner() const
hgs
parents:
diff changeset
    48
{
hgs
parents:
diff changeset
    49
    return mOwner;
hgs
parents:
diff changeset
    50
}
hgs
parents:
diff changeset
    51
hgs
parents:
diff changeset
    52
void MpShareData::setSongData( MpSongData* aSongData )
hgs
parents:
diff changeset
    53
{
hgs
parents:
diff changeset
    54
    mSongData = aSongData;
hgs
parents:
diff changeset
    55
}
hgs
parents:
diff changeset
    56
hgs
parents:
diff changeset
    57
MpSongData* MpShareData::songData() const
hgs
parents:
diff changeset
    58
{
hgs
parents:
diff changeset
    59
    return mSongData;
hgs
parents:
diff changeset
    60
}
hgs
parents:
diff changeset
    61
hgs
parents:
diff changeset
    62
void MpShareData::setErrorMessage( const QString& s )
hgs
parents:
diff changeset
    63
{
hgs
parents:
diff changeset
    64
    mErrorMessage = s;
hgs
parents:
diff changeset
    65
}
hgs
parents:
diff changeset
    66
hgs
parents:
diff changeset
    67
QString MpShareData::errorMessage() const
hgs
parents:
diff changeset
    68
{
hgs
parents:
diff changeset
    69
    return mErrorMessage;
hgs
parents:
diff changeset
    70
}
hgs
parents:
diff changeset
    71
hgs
parents:
diff changeset
    72
void MpShareData::setUsername( const QString& s )
hgs
parents:
diff changeset
    73
{
hgs
parents:
diff changeset
    74
    mUsername = s;
hgs
parents:
diff changeset
    75
}
hgs
parents:
diff changeset
    76
hgs
parents:
diff changeset
    77
QString MpShareData::username() const
hgs
parents:
diff changeset
    78
{
hgs
parents:
diff changeset
    79
    return mUsername;
hgs
parents:
diff changeset
    80
}
hgs
parents:
diff changeset
    81
hgs
parents:
diff changeset
    82
void MpShareData::setPassword( const QString& s )
hgs
parents:
diff changeset
    83
{
hgs
parents:
diff changeset
    84
    mPassword = s;
hgs
parents:
diff changeset
    85
}
hgs
parents:
diff changeset
    86
hgs
parents:
diff changeset
    87
QString MpShareData::password() const
hgs
parents:
diff changeset
    88
{
hgs
parents:
diff changeset
    89
    return mPassword;
hgs
parents:
diff changeset
    90
}
hgs
parents:
diff changeset
    91
hgs
parents:
diff changeset
    92
void MpShareData::setLanguage( const QString& s )
hgs
parents:
diff changeset
    93
{
hgs
parents:
diff changeset
    94
	mLanguage = s;
hgs
parents:
diff changeset
    95
}
hgs
parents:
diff changeset
    96
hgs
parents:
diff changeset
    97
QString MpShareData::language() const
hgs
parents:
diff changeset
    98
{
hgs
parents:
diff changeset
    99
	return mLanguage;
hgs
parents:
diff changeset
   100
}
hgs
parents:
diff changeset
   101
36
hgs
parents: 35
diff changeset
   102
void MpShareData::setUnknownTr( const QString& s )
hgs
parents: 35
diff changeset
   103
{
hgs
parents: 35
diff changeset
   104
    mUnknownTr = s;
hgs
parents: 35
diff changeset
   105
}
hgs
parents: 35
diff changeset
   106
35
hgs
parents:
diff changeset
   107
QString MpShareData::objectType() const
hgs
parents:
diff changeset
   108
{
hgs
parents:
diff changeset
   109
    if ( !mSongData || mSongData->link().isEmpty() )
hgs
parents:
diff changeset
   110
    {
hgs
parents:
diff changeset
   111
        return "NOTE-APPEND";
hgs
parents:
diff changeset
   112
    }
36
hgs
parents: 35
diff changeset
   113
    // No link, append artist-song
hgs
parents: 35
diff changeset
   114
    return "URI";
35
hgs
parents:
diff changeset
   115
}
hgs
parents:
diff changeset
   116
hgs
parents:
diff changeset
   117
int MpShareData::objectReservedLength() const
hgs
parents:
diff changeset
   118
{
hgs
parents:
diff changeset
   119
    return objectContent().length();
hgs
parents:
diff changeset
   120
}
hgs
parents:
diff changeset
   121
hgs
parents:
diff changeset
   122
QString MpShareData::objectContent() const
hgs
parents:
diff changeset
   123
{
36
hgs
parents: 35
diff changeset
   124
    if ( mSongData && !mSongData->link().isEmpty() )
35
hgs
parents:
diff changeset
   125
    {
36
hgs
parents: 35
diff changeset
   126
        return mSongData->link();
35
hgs
parents:
diff changeset
   127
    }
36
hgs
parents: 35
diff changeset
   128
    // TODO: do we need to have right-to-left text direction here,
hgs
parents: 35
diff changeset
   129
    // i.e. putting the title before the artist in such a case?
hgs
parents: 35
diff changeset
   130
    return MUSIC_NOTE_SYMBOL + " " + artist() + ": " + title() + " " + OVI_URL;
35
hgs
parents:
diff changeset
   131
}
hgs
parents:
diff changeset
   132
hgs
parents:
diff changeset
   133
QString MpShareData::title() const
hgs
parents:
diff changeset
   134
{
36
hgs
parents: 35
diff changeset
   135
    if ( mSongData && !mSongData->title().isEmpty() )
hgs
parents: 35
diff changeset
   136
    {
hgs
parents: 35
diff changeset
   137
        return mSongData->title();
hgs
parents: 35
diff changeset
   138
    }
hgs
parents: 35
diff changeset
   139
    return mUnknownTr;
35
hgs
parents:
diff changeset
   140
}
hgs
parents:
diff changeset
   141
hgs
parents:
diff changeset
   142
QString MpShareData::artist() const
hgs
parents:
diff changeset
   143
{
36
hgs
parents: 35
diff changeset
   144
    if ( mSongData && !mSongData->artist().isEmpty() )
hgs
parents: 35
diff changeset
   145
    {
hgs
parents: 35
diff changeset
   146
        return mSongData->artist();
hgs
parents: 35
diff changeset
   147
    }
hgs
parents: 35
diff changeset
   148
    return mUnknownTr;
35
hgs
parents:
diff changeset
   149
}
hgs
parents:
diff changeset
   150
hgs
parents:
diff changeset
   151
QString MpShareData::albumArtBase64() const
hgs
parents:
diff changeset
   152
{
hgs
parents:
diff changeset
   153
    return mSongData ? mSongData->albumArtBase64() : "";
hgs
parents:
diff changeset
   154
}
hgs
parents:
diff changeset
   155
hgs
parents:
diff changeset
   156
#endif // SHARE_FUNC_ENABLED