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