|
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 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
76 case EMPXAbstractAlbum: |
|
77 ptr.Set(KMCAbstractAlbumTable); |
|
78 break; |
|
79 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
80 default: |
|
81 User::Leave(KErrNotSupported); |
|
82 } |
|
83 |
|
84 return ptr; |
|
85 } |
|
86 |
|
87 // ---------------------------------------------------------------------------- |
|
88 // MPXDbUtil::MusicFieldNameForCategoryL |
|
89 // ---------------------------------------------------------------------------- |
|
90 // |
|
91 TPtrC MPXDbUtil::MusicFieldNameForCategoryL( |
|
92 TMPXGeneralCategory aCategory) |
|
93 { |
|
94 MPX_FUNC("MPXDbUtil::MusicFieldNameForCategoryL"); |
|
95 |
|
96 TPtrC ptr; |
|
97 switch (aCategory) |
|
98 { |
|
99 case EMPXArtist: |
|
100 ptr.Set(KMCMusicArtist); |
|
101 break; |
|
102 case EMPXAlbum: |
|
103 ptr.Set(KMCMusicAlbum); |
|
104 break; |
|
105 case EMPXGenre: |
|
106 ptr.Set(KMCMusicGenre); |
|
107 break; |
|
108 case EMPXComposer: |
|
109 ptr.Set(KMCMusicComposer); |
|
110 break; |
|
111 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
112 case EMPXAbstractAlbum: |
|
113 ptr.Set(KMCMusicAbstractAlbum); |
|
114 break; |
|
115 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
116 default: |
|
117 User::Leave(KErrNotSupported); |
|
118 } |
|
119 |
|
120 return ptr; |
|
121 } |
|
122 |
|
123 // End of File |