qtinternetradio/irqmediaplayer/inc/irqmetadata.inl
changeset 0 09774dfdd46b
equal deleted inserted replaced
-1:000000000000 0:09774dfdd46b
       
     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:  Meta data information wrapper
       
    15 *
       
    16 */
       
    17 /*
       
    18 * ============================================================================
       
    19 *  Name        : IRQMetaData.inl
       
    20 *  Part of     : Internet Radio / MediaPlayer
       
    21 *  Description : Meta data information wrapper
       
    22 *  Version     :
       
    23 */
       
    24 
       
    25 #include <QStringList>
       
    26 
       
    27 // ---------------------------------------------------------------------------
       
    28 // Constructor.
       
    29 // ---------------------------------------------------------------------------
       
    30 //
       
    31 inline IRQMetaData::IRQMetaData() :
       
    32     iBitrate(0)
       
    33 {
       
    34 }
       
    35 
       
    36 // ---------------------------------------------------------------------------
       
    37 // Constructor.
       
    38 // ---------------------------------------------------------------------------
       
    39 //
       
    40 inline IRQMetaData::IRQMetaData(const IRQMetaData& aMetaData)
       
    41 {
       
    42     setMetaData(aMetaData);
       
    43 }
       
    44 
       
    45 // ---------------------------------------------------------------------------
       
    46 // Destructor.
       
    47 // ---------------------------------------------------------------------------
       
    48 //
       
    49 inline IRQMetaData::~IRQMetaData()
       
    50 {
       
    51 }
       
    52 
       
    53 // ---------------------------------------------------------------------------
       
    54 // Copies values from the supplied meta data object.
       
    55 // ---------------------------------------------------------------------------
       
    56 //
       
    57 inline void IRQMetaData::setMetaData(const IRQMetaData& aMetaData)
       
    58 {
       
    59     setStreamUrl(aMetaData.iUrl);
       
    60     setArtistSongName(aMetaData.iArtistSongName);
       
    61     setBitrate(aMetaData.iBitrate);
       
    62 }
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 // Clears all the data in class.
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 inline void IRQMetaData::clear()
       
    69 {
       
    70     iUrl.clear();
       
    71     iArtistSongName.clear();
       
    72     iArtistName.clear();
       
    73     iSongName.clear();
       
    74     iBitrate = 0;
       
    75 }
       
    76 
       
    77 // ---------------------------------------------------------------------------
       
    78 // Sets the stream Url.
       
    79 // ---------------------------------------------------------------------------
       
    80 //
       
    81 inline void IRQMetaData::setStreamUrl(const QString& aUrl)
       
    82 {
       
    83     iUrl = aUrl;
       
    84 }
       
    85 
       
    86 // ---------------------------------------------------------------------------
       
    87 // Sets the artist and song name.
       
    88 // ---------------------------------------------------------------------------
       
    89 //
       
    90 inline void IRQMetaData::setArtistSongName(const QString& aArtistSongName)
       
    91 {
       
    92     iArtistSongName = aArtistSongName;
       
    93     QStringList nameList = iArtistSongName.split(" - ");
       
    94     
       
    95     if (nameList.count() == 1)
       
    96     {
       
    97         // if there's no " - " found, we think there's only a song name
       
    98         iSongName = aArtistSongName;
       
    99     }
       
   100     else  // either artist and song name exist, or they are all empty
       
   101     {
       
   102         if (false == nameList.isEmpty())
       
   103         {
       
   104             iArtistName = nameList.first();
       
   105             nameList.removeFirst();
       
   106         }
       
   107     
       
   108         if (false == nameList.isEmpty())
       
   109         {
       
   110             iSongName = nameList.join(" - ");
       
   111         }
       
   112     }
       
   113 }
       
   114 
       
   115 // ---------------------------------------------------------------------------
       
   116 // Sets the artist name.
       
   117 // ---------------------------------------------------------------------------
       
   118 //
       
   119 inline void IRQMetaData::setArtistName(const QString& aArtistName)
       
   120 {
       
   121     iArtistName = aArtistName;
       
   122 }
       
   123 
       
   124 // ---------------------------------------------------------------------------
       
   125 // Sets the song name.
       
   126 // ---------------------------------------------------------------------------
       
   127 //
       
   128 inline void IRQMetaData::setSongName(const QString& aSongName)
       
   129 {
       
   130     iSongName = aSongName;
       
   131 }
       
   132 
       
   133 // ---------------------------------------------------------------------------
       
   134 // Sets the audio bitrate.
       
   135 // ---------------------------------------------------------------------------
       
   136 //
       
   137 inline void IRQMetaData::setBitrate(const int& aBitrate)
       
   138 {
       
   139     iBitrate = aBitrate;
       
   140 }
       
   141 
       
   142 // ---------------------------------------------------------------------------
       
   143 // Returns the stream Url.
       
   144 // ---------------------------------------------------------------------------
       
   145 //
       
   146 inline const QString& IRQMetaData::getStreamUrl() const
       
   147 {
       
   148     return iUrl;
       
   149 }
       
   150 
       
   151 // ---------------------------------------------------------------------------
       
   152 // Returns the artist and song name.
       
   153 // ---------------------------------------------------------------------------
       
   154 //
       
   155 inline const QString& IRQMetaData::getArtistSongName() const
       
   156 {
       
   157     return iArtistSongName;
       
   158 }
       
   159 
       
   160 // ---------------------------------------------------------------------------
       
   161 // Returns the artist name.
       
   162 // ---------------------------------------------------------------------------
       
   163 //
       
   164 inline const QString& IRQMetaData::getArtistName() const
       
   165 {
       
   166     return iArtistName;
       
   167 }
       
   168 
       
   169 // ---------------------------------------------------------------------------
       
   170 // Returns the song name.
       
   171 // ---------------------------------------------------------------------------
       
   172 //
       
   173 inline const QString& IRQMetaData::getSongName() const
       
   174 {
       
   175     return iSongName;
       
   176 }
       
   177 
       
   178 // ---------------------------------------------------------------------------
       
   179 // Returns the audio bitrate.
       
   180 // ---------------------------------------------------------------------------
       
   181 //
       
   182 inline const int& IRQMetaData::getBitrate() const
       
   183 {
       
   184     return iBitrate;
       
   185 }
       
   186 
       
   187 // ---------------------------------------------------------------------------
       
   188 // Equality comparison operator.
       
   189 // ---------------------------------------------------------------------------
       
   190 //
       
   191 bool IRQMetaData::operator==(const IRQMetaData& aMetaData) const
       
   192 {
       
   193     bool ret = false;
       
   194 
       
   195     if (iUrl == aMetaData.iUrl
       
   196         && iArtistSongName == aMetaData.iArtistSongName
       
   197         && iArtistName == aMetaData.iArtistName
       
   198         && iSongName == aMetaData.iSongName
       
   199         && iBitrate == aMetaData.iBitrate)
       
   200     {
       
   201         ret = true;
       
   202     }
       
   203 
       
   204     return ret;
       
   205 }
       
   206 
       
   207 // ---------------------------------------------------------------------------
       
   208 // Inequality comparison operator.
       
   209 // ---------------------------------------------------------------------------
       
   210 //
       
   211 bool IRQMetaData::operator!=(const IRQMetaData& aMetaData) const
       
   212 {
       
   213     return !(*this == aMetaData);
       
   214 }