|
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: |
|
15 * |
|
16 */ |
|
17 #include <mpxcommandgeneraldefs.h> |
|
18 #include <mpxcollectionpath.h> |
|
19 #include <mpxmessagegeneraldefs.h> |
|
20 #include <mpxmessageprogressdefs.h> |
|
21 |
|
22 #include <glxfilterfactory.h> |
|
23 #include <glxcollectionpluginall.hrh> |
|
24 #include <mglxmedialist.h> |
|
25 #include <glxcommandfactory.h> |
|
26 #include <glxmpxcommandhandler.h> |
|
27 #include <QDebug> |
|
28 |
|
29 GlxMpxCommandHandler::GlxMpxCommandHandler() |
|
30 { |
|
31 iMediaList = NULL; |
|
32 } |
|
33 |
|
34 GlxMpxCommandHandler::~GlxMpxCommandHandler() |
|
35 { |
|
36 //close the existing instance of Media List |
|
37 if ( iMediaList ) { |
|
38 iMediaList->Close(); |
|
39 iMediaList = NULL; |
|
40 } |
|
41 } |
|
42 |
|
43 void GlxMpxCommandHandler::executeCommand(int commandId,int collectionId) |
|
44 { |
|
45 qDebug("GlxMpxCommandHandler::executeCommand "); |
|
46 int aHierarchyId = 0; |
|
47 TGlxFilterItemType aFilterType = EGlxFilterImage; |
|
48 |
|
49 //CreateMediaListL(aCollectionId, aHierarchyId,aFilterType); |
|
50 if(collectionId != KGlxAlbumsMediaId) |
|
51 { |
|
52 qDebug("GlxMpxCommandHandler::executeCommand ::CreateMediaListL"); |
|
53 CreateMediaListL(collectionId, aHierarchyId,aFilterType); |
|
54 } |
|
55 else |
|
56 { |
|
57 qDebug("GlxMpxCommandHandler::executeCommand ::CreateMediaListAlbumItemL"); |
|
58 //for creating Medial List for Albums Media path Items |
|
59 CreateMediaListAlbumItemL(collectionId, aHierarchyId,aFilterType); |
|
60 } |
|
61 |
|
62 TBool consume = ETrue; |
|
63 //Execute Command |
|
64 DoExecuteCommandL(commandId,*iMediaList,consume); |
|
65 //Create MPX command if any |
|
66 CMPXCommand* command = CreateCommandL(commandId,*iMediaList,consume); |
|
67 if(command){ |
|
68 command->SetTObjectValueL<TAny*>(KMPXCommandGeneralSessionId, static_cast<TAny*>(this)); |
|
69 iMediaList->AddMediaListObserverL(this); |
|
70 iMediaList->CommandL(*command); |
|
71 } |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 // CreateMediaListL() |
|
76 // Creates a collection path |
|
77 // Create a filter as requested filtertype |
|
78 // Creates the medialist |
|
79 // --------------------------------------------------------------------------- |
|
80 void GlxMpxCommandHandler::CreateMediaListL(int aCollectionId, int aHierarchyId, TGlxFilterItemType aFilterType) |
|
81 { |
|
82 Q_UNUSED(aHierarchyId); |
|
83 Q_UNUSED(aFilterType); |
|
84 |
|
85 //close the existing instance of Media List |
|
86 if ( iMediaList ) { |
|
87 iMediaList->Close(); |
|
88 iMediaList = NULL; |
|
89 } |
|
90 |
|
91 // Create path to the list of images and videos |
|
92 CMPXCollectionPath* path = CMPXCollectionPath::NewL(); |
|
93 CleanupStack::PushL( path ); |
|
94 path->AppendL(aCollectionId); |
|
95 // Create filter to filter out either images or videos |
|
96 CMPXFilter* filter = TGlxFilterFactory::CreateItemTypeFilterL(EGlxFilterImage); //todo take actual filter type |
|
97 CleanupStack::PushL(filter); |
|
98 |
|
99 // Create the media list |
|
100 iMediaList = MGlxMediaList::InstanceL( *path, |
|
101 TGlxHierarchyId(0), filter ); //todo take actual hierarchy |
|
102 CleanupStack::PopAndDestroy( filter ); |
|
103 |
|
104 CleanupStack::PopAndDestroy(path); |
|
105 } |
|
106 |
|
107 // --------------------------------------------------------------------------- |
|
108 // CreateMediaListAlbumItemL() |
|
109 // Creates the media list for the album Item |
|
110 // --------------------------------------------------------------------------- |
|
111 void GlxMpxCommandHandler::CreateMediaListAlbumItemL(int aCollectionId, int aHierarchyId, TGlxFilterItemType aFilterType) |
|
112 { |
|
113 Q_UNUSED(aCollectionId); |
|
114 Q_UNUSED(aHierarchyId); |
|
115 //retrieve the instance of Media list for ALBUMS LIST which will be saved in iMediaList |
|
116 CreateMediaListL(KGlxCollectionPluginAlbumsImplementationUid,0,EGlxFilterAlbum); |
|
117 //retrieve the path of the focussed item of the MediaList |
|
118 CMPXCollectionPath* path = iMediaList->PathLC(NGlxListDefs:: EPathFocusOrSelection); |
|
119 //close the existing instance of Media List |
|
120 iMediaList->Close(); |
|
121 iMediaList = NULL; |
|
122 //create new media list with the derived path |
|
123 CMPXFilter* filter = TGlxFilterFactory::CreateItemTypeFilterL(aFilterType); //todo take actual filter type |
|
124 CleanupStack::PushL(filter); |
|
125 iMediaList = MGlxMediaList::InstanceL( *path, |
|
126 TGlxHierarchyId(0), filter ); //todo take actual hierarchy |
|
127 CleanupStack::PopAndDestroy( filter ); |
|
128 |
|
129 CleanupStack::PopAndDestroy(path); |
|
130 } |
|
131 // ----------------------------------------------------------------------------- |
|
132 // HandleItemAddedL |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 void GlxMpxCommandHandler::HandleItemAddedL(TInt /*aStartIndex*/, TInt /*aEndIndex*/, MGlxMediaList* /*aList*/) |
|
136 { |
|
137 // Do nothing |
|
138 qDebug("New item added "); |
|
139 } |
|
140 |
|
141 // ----------------------------------------------------------------------------- |
|
142 // HandleMediaL |
|
143 // ----------------------------------------------------------------------------- |
|
144 // |
|
145 void GlxMpxCommandHandler::HandleMediaL(TInt /*aListIndex*/, MGlxMediaList* /*aList*/) |
|
146 { |
|
147 // Do nothing |
|
148 } |
|
149 |
|
150 // ----------------------------------------------------------------------------- |
|
151 // HandleItemRemovedL |
|
152 // ----------------------------------------------------------------------------- |
|
153 // |
|
154 void GlxMpxCommandHandler::HandleItemRemovedL(TInt /*aStartIndex*/, TInt /*aEndIndex*/, MGlxMediaList* /*aList*/) |
|
155 { |
|
156 // Do nothing |
|
157 } |
|
158 |
|
159 // ----------------------------------------------------------------------------- |
|
160 // HandleItemModifiedL |
|
161 // ----------------------------------------------------------------------------- |
|
162 // |
|
163 void GlxMpxCommandHandler::HandleItemModifiedL(const RArray<TInt>& /*aItemIndexes*/, |
|
164 MGlxMediaList* /*aList*/) |
|
165 { |
|
166 // Do nothing |
|
167 } |
|
168 |
|
169 // ----------------------------------------------------------------------------- |
|
170 // HandleAttributesAvailableL |
|
171 // ----------------------------------------------------------------------------- |
|
172 // |
|
173 void GlxMpxCommandHandler::HandleAttributesAvailableL(TInt /*aItemIndex*/, |
|
174 const RArray<TMPXAttribute>& /*aAttributes*/, MGlxMediaList* /*aList*/) |
|
175 { |
|
176 // Do nothing |
|
177 } |
|
178 |
|
179 // ----------------------------------------------------------------------------- |
|
180 // HandleFocusChangedL |
|
181 // ----------------------------------------------------------------------------- |
|
182 // |
|
183 void GlxMpxCommandHandler::HandleFocusChangedL(NGlxListDefs::TFocusChangeType /*aType*/, |
|
184 TInt /*aNewIndex*/, TInt /*aOldIndex*/, MGlxMediaList* /*aList*/) |
|
185 { |
|
186 // Do nothing |
|
187 } |
|
188 |
|
189 // ----------------------------------------------------------------------------- |
|
190 // HandleItemSelectedL |
|
191 // ----------------------------------------------------------------------------- |
|
192 // |
|
193 void GlxMpxCommandHandler::HandleItemSelectedL(TInt /*aIndex*/, |
|
194 TBool /*aSelected*/, MGlxMediaList* /*aList*/) |
|
195 { |
|
196 // Do nothing |
|
197 } |
|
198 |
|
199 // ----------------------------------------------------------------------------- |
|
200 // HandleMessageL |
|
201 // ----------------------------------------------------------------------------- |
|
202 // |
|
203 void GlxMpxCommandHandler::HandleMessageL(const CMPXMessage& aMessage, |
|
204 MGlxMediaList* aList) |
|
205 { |
|
206 if ((aMessage.IsSupported(KMPXMessageGeneralId) && (aMessage.IsSupported(KMPXCommandGeneralSessionId)))) |
|
207 { |
|
208 TInt msgId = aMessage.ValueTObjectL<TInt>(KMPXMessageGeneralId); |
|
209 TAny* sessionId = aMessage.ValueTObjectL<TAny*>(KMPXCommandGeneralSessionId); |
|
210 |
|
211 // Check if this is a progress message and intended for this object |
|
212 } |
|
213 } |
|
214 |
|
215 // ----------------------------------------------------------------------------- |
|
216 // HandleCommandCompleteL |
|
217 // ----------------------------------------------------------------------------- |
|
218 // |
|
219 void GlxMpxCommandHandler::HandleCommandCompleteL(TAny* aSessionId, CMPXCommand* aCommandResult, TInt aError, MGlxMediaList* aList) |
|
220 { |
|
221 |
|
222 MGlxMediaList::UnmarkAllL(*iMediaList); |
|
223 |
|
224 DoHandleCommandCompleteL(aSessionId, aCommandResult, aError, aList); |
|
225 |
|
226 iMediaList->RemoveMediaListObserver(this); |
|
227 } |
|
228 |
|
229 // ----------------------------------------------------------------------------- |
|
230 // Default implementation of advanced command handling does nothing |
|
231 // ----------------------------------------------------------------------------- |
|
232 // |
|
233 void GlxMpxCommandHandler::DoHandleCommandCompleteL(TAny* /*aSessionId*/, |
|
234 CMPXCommand* /*aCommandResult*/, TInt /*aError*/, MGlxMediaList* /*aList*/) |
|
235 { |
|
236 } |
|
237 |
|
238 // ----------------------------------------------------------------------------- |
|
239 // Default implementation of advanced command handling does nothing |
|
240 // ----------------------------------------------------------------------------- |
|
241 // |
|
242 |
|
243 void GlxMpxCommandHandler::DoExecuteCommandL(TInt /*aCommandId*/, MGlxMediaList& /*aMediaList*/, TBool& /*aConsume*/) |
|
244 { |
|
245 |
|
246 } |