mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbutil.cpp
changeset 0 ff3acec5bc43
child 17 c8156a91d13c
equal deleted inserted replaced
-1:000000000000 0:ff3acec5bc43
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Contains utility functions for the DB plugin
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <mpxlog.h>
       
    21 
       
    22 #include "mpxcollectiondbdef.h"
       
    23 #include "mpxdbutil.h"
       
    24 
       
    25 // ============================ MEMBER FUNCTIONS ==============================
       
    26 
       
    27 // ----------------------------------------------------------------------------
       
    28 // Filter out duplicated Ids
       
    29 // ----------------------------------------------------------------------------
       
    30 //
       
    31 void MPXDbUtil::FilterDuplicatedIdsL(
       
    32     const TArray<TUint32>& aIds,
       
    33     RArray<TUint32>& aFilteredIds)
       
    34     {
       
    35     MPX_FUNC("MPXDbUtil::FilterDuplicatedIdsL");
       
    36 
       
    37     TInt count(aIds.Count());
       
    38     for (TInt i = 0; i < count; ++i)
       
    39         {
       
    40         MPX_TRAPD(error, aFilteredIds.InsertInUnsignedKeyOrderL(aIds[i]));
       
    41         if ((error != KErrNone) && (error != KErrAlreadyExists))
       
    42             {
       
    43             User::Leave(error);
       
    44             }
       
    45         }
       
    46     }
       
    47 
       
    48 // ----------------------------------------------------------------------------
       
    49 // MPXDbUtil::TableNameForCategoryL
       
    50 // ----------------------------------------------------------------------------
       
    51 //
       
    52 TPtrC MPXDbUtil::TableNameForCategoryL(
       
    53     TMPXGeneralCategory aCategory)
       
    54     {
       
    55     MPX_FUNC("MPXDbUtil::TableNameForCategoryL");
       
    56 
       
    57     TPtrC ptr;
       
    58     switch (aCategory)
       
    59         {
       
    60         case EMPXPlaylist:
       
    61             ptr.Set(KMCPlaylistTable);
       
    62             break;
       
    63         case EMPXArtist:
       
    64             ptr.Set(KMCArtistTable);
       
    65             break;
       
    66         case EMPXAlbum:
       
    67             ptr.Set(KMCAlbumTable);
       
    68             break;
       
    69         case EMPXGenre:
       
    70             ptr.Set(KMCGenreTable);
       
    71             break;
       
    72         case EMPXComposer:
       
    73             ptr.Set(KMCComposerTable);
       
    74             break;
       
    75         default:
       
    76             User::Leave(KErrNotSupported);
       
    77         }
       
    78 
       
    79     return ptr;
       
    80     }
       
    81 
       
    82 // ----------------------------------------------------------------------------
       
    83 // MPXDbUtil::MusicFieldNameForCategoryL
       
    84 // ----------------------------------------------------------------------------
       
    85 //
       
    86 TPtrC MPXDbUtil::MusicFieldNameForCategoryL(
       
    87     TMPXGeneralCategory aCategory)
       
    88     {
       
    89     MPX_FUNC("MPXDbUtil::MusicFieldNameForCategoryL");
       
    90 
       
    91     TPtrC ptr;
       
    92     switch (aCategory)
       
    93         {
       
    94         case EMPXArtist:
       
    95             ptr.Set(KMCMusicArtist);
       
    96             break;
       
    97         case EMPXAlbum:
       
    98             ptr.Set(KMCMusicAlbum);
       
    99             break;
       
   100         case EMPXGenre:
       
   101             ptr.Set(KMCMusicGenre);
       
   102             break;
       
   103         case EMPXComposer:
       
   104             ptr.Set(KMCMusicComposer);
       
   105             break;
       
   106         default:
       
   107             User::Leave(KErrNotSupported);
       
   108         }
       
   109 
       
   110     return ptr;
       
   111     }
       
   112 
       
   113 // End of File