|
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: update the music library after the musics are recieved using direct file saving |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 //#include <mpxcollectionhelper.h> |
|
21 #include <mpxcollectionhelperfactory.h> |
|
22 |
|
23 #include "updatemusiccollection.h" |
|
24 #include "obexutilsdebug.h" |
|
25 |
|
26 //#include <mpxplaybackutility.h> |
|
27 #include <mpxmessagegeneraldefs.h> |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // CUpdateMusicCollection::CUpdateMusicCollection |
|
31 // Default constructor |
|
32 // ----------------------------------------------------------------------------- |
|
33 CUpdateMusicCollection::CUpdateMusicCollection() |
|
34 { |
|
35 } |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CUpdateMusicCollection::NewL |
|
39 // ----------------------------------------------------------------------------- |
|
40 |
|
41 CUpdateMusicCollection* CUpdateMusicCollection::NewL() |
|
42 { |
|
43 CUpdateMusicCollection* self = new( ELeave ) CUpdateMusicCollection(); |
|
44 CleanupStack::PushL( self ); |
|
45 self->ConstructL(); |
|
46 CleanupStack::Pop( self ); |
|
47 return self; |
|
48 } |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CUpdateMusicCollection::ConstructL |
|
51 // Symbian OS default constructor can leave. |
|
52 // ----------------------------------------------------------------------------- |
|
53 |
|
54 void CUpdateMusicCollection::ConstructL() |
|
55 { |
|
56 iCollectionHelper = |
|
57 CMPXCollectionHelperFactory::NewCollectionHelperL(); |
|
58 iPlaybackUtility = MMPXPlaybackUtility::NewL( KPbModeDefault, this ); |
|
59 |
|
60 } |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CUpdateMusicCollection::addToCollectionL |
|
63 // add the music to music library |
|
64 // ----------------------------------------------------------------------------- |
|
65 |
|
66 void CUpdateMusicCollection::addToCollectionL(const TDesC& aFileName) |
|
67 { |
|
68 iCollectionHelper->AddL(aFileName,this); |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CUpdateMusicCollection::isSupported |
|
73 // checks if the file is supported by music library |
|
74 // ----------------------------------------------------------------------------- |
|
75 TInt CUpdateMusicCollection::isSupported (const TDesC16& aPtr) |
|
76 { |
|
77 CDesCArray* SupportedMimeTypes = |
|
78 iPlaybackUtility->SupportedMimeTypes(); |
|
79 TInt pos = 0; |
|
80 return SupportedMimeTypes->Find(aPtr,pos); |
|
81 } |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // CUpdateMusicCollection::HandleAddFileCompleteL |
|
85 // callbackCalled back after a call to CCollectionHelper::AddL() to provide status |
|
86 // ----------------------------------------------------------------------------- |
|
87 void CUpdateMusicCollection::HandleAddFileCompleteL( TInt aErr ) |
|
88 { |
|
89 if(aErr == KErrNone) |
|
90 { |
|
91 FLOG(_L("[CUpdateMusicCollection]\t HandleAddFileCompleteL successful")); |
|
92 } |
|
93 else |
|
94 { |
|
95 FLOG(_L("[CUpdateMusicCollection]\t HandleAddFileCompleteL unsuccessful")); |
|
96 } |
|
97 |
|
98 } |
|
99 // ----------------------------------------------------------------------------- |
|
100 // CUpdateMusicCollection::HandlePlaybackMessage |
|
101 // ----------------------------------------------------------------------------- |
|
102 |
|
103 void CUpdateMusicCollection::HandlePlaybackMessage( CMPXMessage* aMessage,TInt aError ) |
|
104 { |
|
105 if ( aError == KErrNone && aMessage ) |
|
106 { |
|
107 FLOG(_L("[CUpdateMusicCollection]\t HandleAddFileCompleteL unsuccessful")); |
|
108 } |
|
109 } |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // CUpdateMusicCollection::~CUpdateMusicCollection |
|
113 // default destructor |
|
114 // ----------------------------------------------------------------------------- |
|
115 |
|
116 CUpdateMusicCollection::~CUpdateMusicCollection() |
|
117 { |
|
118 if ( iCollectionHelper ) |
|
119 { |
|
120 iCollectionHelper->Close(); |
|
121 } |
|
122 if (iPlaybackUtility) |
|
123 { |
|
124 iPlaybackUtility->Close(); |
|
125 } |
|
126 } |