|
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: Handles commands passed in by other appilcations |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CMPXCOMMANDHANDLER_H |
|
20 #define CMPXCOMMANDHANDLER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <mpxcollectionobserver.h> |
|
25 #include <mpxplaybackobserver.h> |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class CMPXCollectionPath; |
|
29 class MMPXCollectionUtility; |
|
30 class MMPXPlaybackUtility; |
|
31 class MMPXViewUtility; |
|
32 class CMPXParameter; |
|
33 |
|
34 // CLASS DECLARATION |
|
35 /** |
|
36 * Process commands passed in by other applications. |
|
37 * |
|
38 * @lib mpx.exe |
|
39 * @since 3.1 |
|
40 */ |
|
41 class CMPXCommandHandler : public CBase, |
|
42 public MMPXCollectionObserver, |
|
43 public MMPXPlaybackObserver |
|
44 { |
|
45 public: // Constructors and destructor |
|
46 |
|
47 /** |
|
48 * Two-phased constructor. |
|
49 * |
|
50 * @since 3.1 |
|
51 * @param aPlaybackUtility Playback utility to use. |
|
52 * @param aCollectionMode The collection mode for current music player |
|
53 * @param aParameter The command to process. |
|
54 * @return Pointer to newly created object. |
|
55 */ |
|
56 static CMPXCommandHandler * NewL( |
|
57 MMPXPlaybackUtility* aPlaybackUtility, |
|
58 TUid aCollectionMode, |
|
59 const TDesC8& aParameter ); |
|
60 |
|
61 /** |
|
62 * Two-phased constructor. |
|
63 * |
|
64 * @since 3.1 |
|
65 * @param aPlaybackUtility Playback utility to use. |
|
66 * @param aCollectionMode The collection mode for current music player |
|
67 * @param aParameter The command to process. |
|
68 * @return Pointer to newly created object. |
|
69 */ |
|
70 static CMPXCommandHandler * NewLC( |
|
71 MMPXPlaybackUtility* aPlaybackUtility, |
|
72 TUid aCollectionMode, |
|
73 const TDesC8& aParameter ); |
|
74 |
|
75 /** |
|
76 * Destructor. |
|
77 */ |
|
78 virtual ~CMPXCommandHandler(); |
|
79 |
|
80 /** |
|
81 * Start processing the command |
|
82 * |
|
83 * @param aIsUsbInUse Current USB state, ETrue if it's in use, |
|
84 * EFalse otherwise |
|
85 * @param aRefreshing Current refresh state, ETrue if refresh ongoing, |
|
86 * EFalse otherwise |
|
87 */ |
|
88 void ProcessMessageL( TBool aIsUsbInUse, TBool aRefreshing, TBool aFormattingOnGoing ); |
|
89 |
|
90 /** |
|
91 * Returns if a path has been inited in playback engine |
|
92 * |
|
93 * @return ETrue if a path has been inited, EFalse otherwise. |
|
94 */ |
|
95 TBool IsPathInited(); |
|
96 |
|
97 /** |
|
98 * Set current USB state |
|
99 * |
|
100 * @param aIsUsbInUse Current USB state, ETrue if it's in use, |
|
101 * EFalse otherwise |
|
102 */ |
|
103 void SetUsbInUse( TBool aIsUsbInUse ); |
|
104 |
|
105 /** |
|
106 * Set current refresh state |
|
107 * |
|
108 * @param aRefreshing Current refresh state, ETrue if refresh ongoing, |
|
109 * EFalse otherwise |
|
110 */ |
|
111 void SetRefreshState( TBool aRefreshing ); |
|
112 |
|
113 /** |
|
114 * Determines if the command should be handled by standalone mode. |
|
115 * This does not forward the command, it just returns if it should |
|
116 * |
|
117 * @return ETrue if the command should be forwarded, EFalse otherwise |
|
118 */ |
|
119 TBool ForwardCmdToStandAloneMode(); |
|
120 |
|
121 /** |
|
122 * Determines if the command should be handled by now playing instance |
|
123 * This does not forward the command, it just returns if it should |
|
124 * |
|
125 * @return ETrue if the command should be forwarded, EFalse otherwise |
|
126 */ |
|
127 TBool ForwardCmdToNowPlaying(); |
|
128 |
|
129 /** |
|
130 * Checks if initialize playback engine is needed for current command |
|
131 * |
|
132 * @return ETrue if init is needed, EFalse otherwise |
|
133 */ |
|
134 TBool IsInitPlaybackEngineNeeded(); |
|
135 |
|
136 /** |
|
137 * Extracts the activated view type from the command |
|
138 * |
|
139 * @return Activated view type ID |
|
140 */ |
|
141 TInt ActivatedViewTypeId(); |
|
142 |
|
143 private: |
|
144 |
|
145 /** |
|
146 * C++ Constructor |
|
147 * |
|
148 * @param aPlaybackUtility Playback utility to use. |
|
149 */ |
|
150 CMPXCommandHandler( |
|
151 MMPXPlaybackUtility* aPlaybackUtility ); |
|
152 |
|
153 /** |
|
154 * By default Symbian 2nd phase constructor is private. |
|
155 * |
|
156 * @param aCollectionMode The collection mode for current music player |
|
157 * @param aParameter The command to process. |
|
158 */ |
|
159 void ConstructL( |
|
160 TUid aCollectionMode, |
|
161 const TDesC8& aParameter ); |
|
162 |
|
163 // from base class MMPXCollectionObserver |
|
164 |
|
165 /** |
|
166 * From MMPXCollectionObserver |
|
167 * Handle media properties. |
|
168 * |
|
169 * @since 3.1 |
|
170 * @param aMedia media properties. |
|
171 * @param aError Error code. |
|
172 */ |
|
173 void HandleCollectionMediaL( |
|
174 const CMPXMedia& aMedia, |
|
175 TInt aError ); |
|
176 |
|
177 /** |
|
178 * From MMPXCollectionObserver |
|
179 * Handle collection message. |
|
180 * |
|
181 * @since 3.1 |
|
182 * @param aMessage Collection message |
|
183 * @param aErr system error code. |
|
184 */ |
|
185 void HandleCollectionMessage( |
|
186 CMPXMessage* aMessage, TInt aError ); |
|
187 |
|
188 /** |
|
189 * From MMPXCollectionObserver |
|
190 * Handles the collection entries being opened. |
|
191 * |
|
192 * @since 3.1 |
|
193 * @param aEntries Collection entries opened. |
|
194 * @param aIndex Focused entry. |
|
195 * @param aComplete ETrue no more entries. EFalse more entries |
|
196 * expected. |
|
197 * @param aError Error code. |
|
198 */ |
|
199 void HandleOpenL( |
|
200 const CMPXMedia& aEntries, |
|
201 TInt aIndex, |
|
202 TBool aComplete, |
|
203 TInt aError ); |
|
204 |
|
205 /** |
|
206 * From MMPXCollectionObserver |
|
207 * Handles the item being opened. |
|
208 * |
|
209 * @since 3.1 |
|
210 * @param aPlaylist Collection playlist, owner ship is transfered. |
|
211 * @param aError Error code. |
|
212 */ |
|
213 void HandleOpenL( |
|
214 const CMPXCollectionPlaylist& aPlaylist, |
|
215 TInt aError ); |
|
216 |
|
217 /** |
|
218 * From MMPXPlaybackObserver |
|
219 * Handle playback message |
|
220 * |
|
221 * @param aMessage playback message |
|
222 * @param aErr system error code. |
|
223 */ |
|
224 void HandlePlaybackMessage( CMPXMessage* aMessage, TInt aError ); |
|
225 |
|
226 private: // New functions |
|
227 |
|
228 /** |
|
229 * Initialize playback engine with the path provided |
|
230 * |
|
231 * @param aPath The collection path to initialize playback engine with. |
|
232 */ |
|
233 void InitPlaybackEngineL( CMPXCollectionPath& aPath ); |
|
234 |
|
235 /** |
|
236 * Start processing the message |
|
237 * |
|
238 */ |
|
239 void DoHandleMessageL(); |
|
240 |
|
241 /** |
|
242 * Extracts the message from the paramter provided. The message |
|
243 * is internalized to iParameter |
|
244 * |
|
245 * @param aParameter Parameter to extract the message from. |
|
246 */ |
|
247 void ExtractMessageL( const TDesC8& aParameter ); |
|
248 |
|
249 /** |
|
250 * Handle playback message |
|
251 * |
|
252 * @param aMessage playback message |
|
253 */ |
|
254 void DoHandlePlaybackMessageL( const CMPXMessage& aMessage ); |
|
255 |
|
256 /** |
|
257 * Handle collection message |
|
258 * |
|
259 * @param aMessage collection message |
|
260 */ |
|
261 void DoHandleCollectionMessageL( const CMPXMessage& aMessage ); |
|
262 |
|
263 private: // enums |
|
264 |
|
265 enum TMPXCollectionPlaylistSetupState |
|
266 { |
|
267 TMPXCollectionPlaylistSetupStateIdle, |
|
268 TMPXCollectionPlaylistSetupStateOpenPath, |
|
269 TMPXCollectionPlaylistSetupStateInitPlaybackEngine |
|
270 }; |
|
271 |
|
272 private: |
|
273 |
|
274 MMPXPlaybackUtility* iPlaybackUtility; // Not owned |
|
275 |
|
276 MMPXCollectionUtility* iMusicPlayerCollectionUtility; //owned |
|
277 |
|
278 MMPXViewUtility* iViewUtility; // owned |
|
279 |
|
280 CMPXCollectionOpenUtility* iIsolatedIncOpenUtil; // owned |
|
281 |
|
282 CMPXParameter* iParameter; //owned |
|
283 |
|
284 TBool iUnhandledMessage; |
|
285 |
|
286 TBool iPathInited; |
|
287 |
|
288 TBool iUsbInUse; |
|
289 |
|
290 TBool iRefreshOngoing; |
|
291 TBool iLastPlayedAutostart; |
|
292 |
|
293 TMPXCollectionPlaylistSetupState iCollectionPlaylistState; |
|
294 }; |
|
295 |
|
296 #endif // CMPXCOMMANDHANDLER_H |
|
297 |
|
298 // End of File |
|
299 |