|
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 #ifdef SHARE_FUNC_ENABLED |
|
18 |
|
19 #include "mpsharedata.h" |
|
20 #include "mpsongdata.h" |
|
21 |
|
22 // TODO OVI_URL needs to come from cenrep |
|
23 const QString OVI_URL = "http://music.ovi.com"; |
|
24 |
|
25 // The music note symbol that we post if we do not have music store URL. |
|
26 const QString MUSIC_NOTE_SYMBOL = "♫ "; |
|
27 |
|
28 MpShareData::MpShareData() |
|
29 : mOwner( 0 ), |
|
30 mSongData( 0 ) |
|
31 { |
|
32 } |
|
33 |
|
34 MpShareData::~MpShareData() |
|
35 { |
|
36 } |
|
37 |
|
38 void MpShareData::setOwner( QObject* aOwner ) |
|
39 { |
|
40 mOwner = aOwner; |
|
41 } |
|
42 |
|
43 QObject* MpShareData::owner() const |
|
44 { |
|
45 return mOwner; |
|
46 } |
|
47 |
|
48 void MpShareData::setSongData( MpSongData* aSongData ) |
|
49 { |
|
50 mSongData = aSongData; |
|
51 } |
|
52 |
|
53 MpSongData* MpShareData::songData() const |
|
54 { |
|
55 return mSongData; |
|
56 } |
|
57 |
|
58 void MpShareData::setErrorMessage( const QString& s ) |
|
59 { |
|
60 mErrorMessage = s; |
|
61 } |
|
62 |
|
63 QString MpShareData::errorMessage() const |
|
64 { |
|
65 return mErrorMessage; |
|
66 } |
|
67 |
|
68 void MpShareData::setUsername( const QString& s ) |
|
69 { |
|
70 mUsername = s; |
|
71 } |
|
72 |
|
73 QString MpShareData::username() const |
|
74 { |
|
75 return mUsername; |
|
76 } |
|
77 |
|
78 void MpShareData::setPassword( const QString& s ) |
|
79 { |
|
80 mPassword = s; |
|
81 } |
|
82 |
|
83 QString MpShareData::password() const |
|
84 { |
|
85 return mPassword; |
|
86 } |
|
87 |
|
88 void MpShareData::setLanguage( const QString& s ) |
|
89 { |
|
90 mLanguage = s; |
|
91 } |
|
92 |
|
93 QString MpShareData::language() const |
|
94 { |
|
95 return mLanguage; |
|
96 } |
|
97 |
|
98 QString MpShareData::objectType() const |
|
99 { |
|
100 if ( !mSongData || mSongData->link().isEmpty() ) |
|
101 { |
|
102 return "NOTE-APPEND"; |
|
103 } |
|
104 else |
|
105 { |
|
106 // No link, append artist-song |
|
107 return "URI"; |
|
108 } |
|
109 } |
|
110 |
|
111 int MpShareData::objectReservedLength() const |
|
112 { |
|
113 return objectContent().length(); |
|
114 } |
|
115 |
|
116 QString MpShareData::objectContent() const |
|
117 { |
|
118 QString result = ""; |
|
119 if ( mSongData ) |
|
120 { |
|
121 if ( !mSongData->link().isEmpty() ) |
|
122 { |
|
123 return mSongData->link(); |
|
124 } |
|
125 else if ( !mSongData->artist().isEmpty() && !mSongData->title().isEmpty() ) |
|
126 { |
|
127 // TODO: do we need to have right-to-left text direction here, |
|
128 // i.e. putting the title before the artist in such a case? |
|
129 result = MUSIC_NOTE_SYMBOL + mSongData->artist() + ": " + mSongData->title() + " " + OVI_URL; |
|
130 } |
|
131 else if ( !mSongData->artist().isEmpty() ) |
|
132 { |
|
133 result = MUSIC_NOTE_SYMBOL + mSongData->artist() + " " + OVI_URL; |
|
134 } |
|
135 else if ( !mSongData->title().isEmpty() ) |
|
136 { |
|
137 result = MUSIC_NOTE_SYMBOL + mSongData->title() + " " + OVI_URL; |
|
138 } |
|
139 else |
|
140 { |
|
141 result = MUSIC_NOTE_SYMBOL + OVI_URL; |
|
142 } |
|
143 } |
|
144 else |
|
145 { |
|
146 result = MUSIC_NOTE_SYMBOL + OVI_URL; |
|
147 } |
|
148 return result; |
|
149 } |
|
150 |
|
151 QString MpShareData::title() const |
|
152 { |
|
153 return mSongData ? mSongData->title() : ""; |
|
154 } |
|
155 |
|
156 QString MpShareData::album() const |
|
157 { |
|
158 return mSongData ? mSongData->album() : ""; |
|
159 } |
|
160 |
|
161 QString MpShareData::artist() const |
|
162 { |
|
163 return mSongData ? mSongData->artist() : ""; |
|
164 } |
|
165 |
|
166 QString MpShareData::albumArtBase64() const |
|
167 { |
|
168 return mSongData ? mSongData->albumArtBase64() : ""; |
|
169 } |
|
170 |
|
171 #endif // SHARE_FUNC_ENABLED |