43 const TInt KGlxAiwShowMapCommandSpace = 0x00000400; |
43 const TInt KGlxAiwShowMapCommandSpace = 0x00000400; |
44 |
44 |
45 // ----------------------------------------------------------------------------- |
45 // ----------------------------------------------------------------------------- |
46 // NewL |
46 // NewL |
47 // ----------------------------------------------------------------------------- |
47 // ----------------------------------------------------------------------------- |
48 // |
48 // |
49 EXPORT_C CGlxCommandHandlerAiwShowMap* CGlxCommandHandlerAiwShowMap::NewL( |
49 EXPORT_C CGlxCommandHandlerAiwShowMap* CGlxCommandHandlerAiwShowMap::NewL( |
50 MGlxMediaListProvider* aMediaListProvider, TInt aMenuResource ) |
50 MGlxMediaListProvider* aMediaListProvider, TInt aMenuResource ) |
51 { |
51 { |
52 TRACER("CGlxCommandHandlerAiwShowMap::NewL"); |
52 TRACER("CGlxCommandHandlerAiwShowMap::NewL"); |
53 CGlxCommandHandlerAiwShowMap* self = new ( ELeave ) |
53 CGlxCommandHandlerAiwShowMap* self = new ( ELeave ) |
54 CGlxCommandHandlerAiwShowMap( aMediaListProvider, aMenuResource ); |
54 CGlxCommandHandlerAiwShowMap( aMediaListProvider, aMenuResource ); |
55 CleanupStack::PushL( self ); |
55 CleanupStack::PushL( self ); |
56 self->ConstructL(); |
56 self->ConstructL(); |
57 CleanupStack::Pop( self ); |
57 CleanupStack::Pop( self ); |
58 return self; |
58 return self; |
64 // |
64 // |
65 CGlxCommandHandlerAiwShowMap::~CGlxCommandHandlerAiwShowMap() |
65 CGlxCommandHandlerAiwShowMap::~CGlxCommandHandlerAiwShowMap() |
66 { |
66 { |
67 iBufferArray.ResetAndDestroy(); |
67 iBufferArray.ResetAndDestroy(); |
68 } |
68 } |
69 |
69 |
70 // ----------------------------------------------------------------------------- |
70 // ----------------------------------------------------------------------------- |
71 // Constructor |
71 // Constructor |
72 // ----------------------------------------------------------------------------- |
72 // ----------------------------------------------------------------------------- |
73 // |
73 // |
74 CGlxCommandHandlerAiwShowMap::CGlxCommandHandlerAiwShowMap( |
74 CGlxCommandHandlerAiwShowMap::CGlxCommandHandlerAiwShowMap( |
75 MGlxMediaListProvider* aMediaListProvider, TInt aMenuResource ) |
75 MGlxMediaListProvider* aMediaListProvider, TInt aMenuResource ) |
76 : CGlxCommandHandlerAiwBase( aMediaListProvider, aMenuResource ) |
76 : CGlxCommandHandlerAiwBase( aMediaListProvider, aMenuResource ) |
77 { |
77 { |
78 } |
78 } |
79 |
79 |
80 // ----------------------------------------------------------------------------- |
80 // ----------------------------------------------------------------------------- |
81 // CGlxCommandHandlerAiwShowMap::DoGetRequiredAttributesL |
81 // CGlxCommandHandlerAiwShowMap::DoGetRequiredAttributesL |
82 // ----------------------------------------------------------------------------- |
82 // ----------------------------------------------------------------------------- |
83 // |
83 // |
84 void CGlxCommandHandlerAiwShowMap::DoGetRequiredAttributesL |
84 void CGlxCommandHandlerAiwShowMap::DoGetRequiredAttributesL |
85 (RArray<TMPXAttribute>& aAttributes, TBool aFilterUsingSelection) const |
85 (RArray<TMPXAttribute>& aAttributes, TBool aFilterUsingSelection) const |
86 { |
86 { |
87 if (!aFilterUsingSelection || SelectionLength() <= MaxSelectedItems()) |
87 if (!aFilterUsingSelection || SelectionLength() <= MaxSelectedItems()) |
88 { |
88 { |
91 } |
91 } |
92 |
92 |
93 // ----------------------------------------------------------------------------- |
93 // ----------------------------------------------------------------------------- |
94 // AiwDoDynInitMenuPaneL |
94 // AiwDoDynInitMenuPaneL |
95 // ----------------------------------------------------------------------------- |
95 // ----------------------------------------------------------------------------- |
96 // |
96 // |
97 void CGlxCommandHandlerAiwShowMap::AiwDoDynInitMenuPaneL(TInt /*aResourceId*/, |
97 void CGlxCommandHandlerAiwShowMap::AiwDoDynInitMenuPaneL(TInt /*aResourceId*/, |
98 CEikMenuPane* aMenuPane) |
98 CEikMenuPane* aMenuPane) |
99 { |
99 { |
100 TInt num_items = aMenuPane->NumberOfItemsInPane(); |
100 TInt num_items = aMenuPane->NumberOfItemsInPane(); |
101 |
101 |
102 // Iterate through menu pane |
102 // Iterate through menu pane |
103 TInt i = 0; |
103 TInt i = 0; |
104 while (i < num_items) |
104 while (i < num_items) |
105 { |
105 { |
106 CEikMenuPaneItem::SData& item = aMenuPane->ItemDataByIndexL(i); |
106 CEikMenuPaneItem::SData& item = aMenuPane->ItemDataByIndexL(i); |
107 |
107 |
108 // "Show on map" cannot be dimmed as AIW resets the flags to not dimmed |
108 // "Show on map" cannot be dimmed as AIW resets the flags to not dimmed |
109 // Have to delete the menu item in this case. |
109 // Have to delete the menu item in this case. |
110 if (EGlxCmdAiwShowMap == item.iCommandId) |
110 if (EGlxCmdAiwShowMap == item.iCommandId) |
111 { |
111 { |
112 // Check visibility of the menu item |
112 //Check visibility of the menu item |
113 TBool isDisabled = IsItemWithLocationInfoSelected(MediaList()); |
113 //Fix for ESLM-7XFF9L:Must always be disabled in all cases. |
114 |
114 TBool isDisabled = ETrue; |
|
115 |
115 // Should it be disabled |
116 // Should it be disabled |
116 if ( (isDisabled) || |
117 if ( (isDisabled) || |
117 (MediaList().SelectionCount() != 1 && |
118 (MediaList().SelectionCount() != 1 && |
118 !IsInFullScreenViewingModeL()) ) |
119 !IsInFullScreenViewingModeL()) ) |
119 { |
120 { |
120 // if so delete it. |
121 // if so delete it. |
121 aMenuPane->DeleteMenuItem(EGlxCmdAiwShowMap); |
122 aMenuPane->DeleteMenuItem(EGlxCmdAiwShowMap); |
122 } |
123 } |
123 break; |
124 break; |
124 } |
125 } |
125 ++i; |
126 ++i; |
126 } |
127 } |
127 } |
128 } |
128 |
129 |
129 // ----------------------------------------------------------------------------- |
130 // ----------------------------------------------------------------------------- |
130 // CommandId |
131 // CommandId |
131 // ----------------------------------------------------------------------------- |
132 // ----------------------------------------------------------------------------- |
132 // |
133 // |
133 TInt CGlxCommandHandlerAiwShowMap::CommandId() const |
134 TInt CGlxCommandHandlerAiwShowMap::CommandId() const |
134 { |
135 { |
135 TRACER("CGlxCommandHandlerAiwShowMap::CommandId"); |
136 TRACER("CGlxCommandHandlerAiwShowMap::CommandId"); |
136 return EGlxCmdAiwShowMap; |
137 return EGlxCmdAiwShowMap; |
137 } |
138 } |
138 |
139 |
139 // ----------------------------------------------------------------------------- |
140 // ----------------------------------------------------------------------------- |
140 // AiwCommandId |
141 // AiwCommandId |
141 // ----------------------------------------------------------------------------- |
142 // ----------------------------------------------------------------------------- |
142 // |
143 // |
143 TInt CGlxCommandHandlerAiwShowMap::AiwCommandId() const |
144 TInt CGlxCommandHandlerAiwShowMap::AiwCommandId() const |
144 { |
145 { |
145 TRACER("CGlxCommandHandlerAiwShowMap::AiwCommandId"); |
146 TRACER("CGlxCommandHandlerAiwShowMap::AiwCommandId"); |
146 return KAiwCmdMnShowMap; |
147 return KAiwCmdMnShowMap; |
147 } |
148 } |
148 |
149 |
149 // ----------------------------------------------------------------------------- |
150 // ----------------------------------------------------------------------------- |
150 // AiwInterestResource |
151 // AiwInterestResource |
151 // ----------------------------------------------------------------------------- |
152 // ----------------------------------------------------------------------------- |
152 // |
153 // |
153 TInt CGlxCommandHandlerAiwShowMap::AiwInterestResource() const |
154 TInt CGlxCommandHandlerAiwShowMap::AiwInterestResource() const |
154 { |
155 { |
155 TRACER("CGlxCommandHandlerAiwShowMap::AiwInterestResource"); |
156 TRACER("CGlxCommandHandlerAiwShowMap::AiwInterestResource"); |
156 return R_GLX_AIW_SHOWMAP_INTEREST; |
157 return R_GLX_AIW_SHOWMAP_INTEREST; |
157 } |
158 } |
158 |
159 |
159 // ----------------------------------------------------------------------------- |
160 // ----------------------------------------------------------------------------- |
160 // AppendAiwParameterL |
161 // AppendAiwParameterL |
161 // ----------------------------------------------------------------------------- |
162 // ----------------------------------------------------------------------------- |
162 // |
163 // |
163 TBool CGlxCommandHandlerAiwShowMap::AppendAiwParameterL(const TGlxMedia& aItem, |
164 TBool CGlxCommandHandlerAiwShowMap::AppendAiwParameterL(const TGlxMedia& aItem, |
164 CGlxAiwServiceHandler& aAiwServiceHandler) |
165 CGlxAiwServiceHandler& aAiwServiceHandler) |
165 { |
166 { |
166 TRACER("CGlxCommandHandlerAiwShowMap::AppendAiwParameterL"); |
167 TRACER("CGlxCommandHandlerAiwShowMap::AppendAiwParameterL"); |
167 TBool success = EFalse; |
168 TBool success = EFalse; |
168 |
169 |
169 // Cleanup before execution |
170 // Cleanup before execution |
170 iBufferArray.ResetAndDestroy(); |
171 iBufferArray.ResetAndDestroy(); |
171 |
172 |
172 TCoordinate coordinate; |
173 TCoordinate coordinate; |
173 if (aItem.GetCoordinate(coordinate)) |
174 if (aItem.GetCoordinate(coordinate)) |
174 { |
175 { |
175 // Create a landmark from the coordinate |
176 // Create a landmark from the coordinate |
176 CPosLandmark* landmark = CPosLandmark::NewLC(); |
177 CPosLandmark* landmark = CPosLandmark::NewLC(); |
179 |
180 |
180 TLocality locality( coordinate, noNumber ); |
181 TLocality locality( coordinate, noNumber ); |
181 |
182 |
182 // locality must have valid (ie not NaN) values |
183 // locality must have valid (ie not NaN) values |
183 landmark->SetPositionL( locality ); |
184 landmark->SetPositionL( locality ); |
184 |
185 |
185 // Serialize buffer to landmark and append it to AIW parameter |
186 // Serialize buffer to landmark and append it to AIW parameter |
186 const HBufC8* landmarkBuf = |
187 const HBufC8* landmarkBuf = |
187 PosLandmarkSerialization::PackL( *landmark ); |
188 PosLandmarkSerialization::PackL( *landmark ); |
188 // we have ownership of landmarkBuf so add to array |
189 // we have ownership of landmarkBuf so add to array |
189 // for cleanup on our destruction |
190 // for cleanup on our destruction |
190 iBufferArray.AppendL( landmarkBuf ); |
191 iBufferArray.AppendL( landmarkBuf ); |
191 |
192 |
192 // Append location parameter to the AIW param list |
193 // Append location parameter to the AIW param list |
193 TAiwVariant landmarkVariant( *landmarkBuf ); |
194 TAiwVariant landmarkVariant( *landmarkBuf ); |
194 TAiwGenericParam landmarkParam( EGenericParamLandmark, landmarkVariant ); |
195 TAiwGenericParam landmarkParam( EGenericParamLandmark, landmarkVariant ); |
195 aAiwServiceHandler.AddParamL(aItem.Id(), landmarkParam ); |
196 aAiwServiceHandler.AddParamL(aItem.Id(), landmarkParam ); |
196 |
197 |
197 success = ETrue; |
198 success = ETrue; |
198 CleanupStack::PopAndDestroy( landmark ); |
199 CleanupStack::PopAndDestroy( landmark ); |
199 } |
200 } |
200 |
201 |
201 return success; |
202 return success; |
202 } |
203 } |
203 |
204 |
204 // ----------------------------------------------------------------------------- |
205 // ----------------------------------------------------------------------------- |
205 // CommandSpace |
206 // CommandSpace |
206 // ----------------------------------------------------------------------------- |
207 // ----------------------------------------------------------------------------- |
207 // |
208 // |
208 TInt CGlxCommandHandlerAiwShowMap::CommandSpace() const |
209 TInt CGlxCommandHandlerAiwShowMap::CommandSpace() const |
209 { |
210 { |
210 TRACER("CGlxCommandHandlerAiwShowMap::CommandSpace"); |
211 TRACER("CGlxCommandHandlerAiwShowMap::CommandSpace"); |
211 return KGlxAiwShowMapCommandSpace; |
212 return KGlxAiwShowMapCommandSpace; |
212 } |
213 } |
213 |
214 |
214 // ----------------------------------------------------------------------------- |
215 // ----------------------------------------------------------------------------- |
215 // DoIsDisabled |
216 // DoIsDisabled |
216 // ----------------------------------------------------------------------------- |
217 // ----------------------------------------------------------------------------- |
217 // |
218 // |
218 // |
219 // |
219 TBool CGlxCommandHandlerAiwShowMap::IsItemWithLocationInfoSelected(MGlxMediaList& aList ) |
220 TBool CGlxCommandHandlerAiwShowMap::IsItemWithLocationInfoSelected(MGlxMediaList& aList ) |
220 { |
221 { |
221 TRACER("CGlxCommandHandlerAiwShowMap::DoIsDisabled"); |
222 TRACER("CGlxCommandHandlerAiwShowMap::DoIsDisabled"); |
222 // Disable the "Show on map" menu item if the selection (marked list, |
223 // Disable the "Show on map" menu item if the selection (marked list, |
223 // or focused item if none marked) does not contain any items |
224 // or focused item if none marked) does not contain any items |
224 // that have location data |
225 // that have location data |
225 TBool isSupported = EFalse; |
226 TBool isSupported = EFalse; |
226 |
227 |
227 // Check through all, if any, selected items, otherwise the focused item |
228 // Check through all, if any, selected items, otherwise the focused item |
228 TGlxSelectionIterator iterator; |
229 TGlxSelectionIterator iterator; |
229 iterator.SetToFirst( &aList ); |
230 iterator.SetToFirst( &aList ); |
230 |
231 |
231 // Loop until a supported item is found or until there are no |
232 // Loop until a supported item is found or until there are no |
232 // more indexes to process |
233 // more indexes to process |
233 TInt index = KErrNotFound; |
234 TInt index = KErrNotFound; |
234 while ( KErrNotFound != (index = iterator++ ) && !isSupported ) |
235 while ( KErrNotFound != (index = iterator++ ) && !isSupported ) |
235 { |
236 { |
236 // get the media item |
237 // get the media item |
237 const TGlxMedia& media = aList.Item( index ); |
238 const TGlxMedia& media = aList.Item( index ); |
238 |
239 |
239 // Test to see if the coordinate is present |
240 // Test to see if the coordinate is present |
240 TCoordinate coordinate; |
241 TCoordinate coordinate; |
241 isSupported = media.GetCoordinate(coordinate); |
242 isSupported = media.GetCoordinate(coordinate); |
242 } |
243 } |
243 |
244 |
244 // Don't disable the menu item if the property's supported |
245 // Don't disable the menu item if the property's supported |
245 return !isSupported; |
246 return !isSupported; |
246 } |
247 } |
247 |
248 |
248 // ----------------------------------------------------------------------------- |
249 // ----------------------------------------------------------------------------- |
261 TBool CGlxCommandHandlerAiwShowMap::IsInFullScreenViewingModeL() |
262 TBool CGlxCommandHandlerAiwShowMap::IsInFullScreenViewingModeL() |
262 { |
263 { |
263 TBool fullscreenViewingMode = EFalse; |
264 TBool fullscreenViewingMode = EFalse; |
264 CGlxNavigationalState* aNavigationalState = CGlxNavigationalState::InstanceL(); |
265 CGlxNavigationalState* aNavigationalState = CGlxNavigationalState::InstanceL(); |
265 CMPXCollectionPath* naviState = aNavigationalState->StateLC(); |
266 CMPXCollectionPath* naviState = aNavigationalState->StateLC(); |
266 |
267 |
267 if ( naviState->Levels() >= 1) |
268 if ( naviState->Levels() >= 1) |
268 { |
269 { |
269 if (aNavigationalState->ViewingMode() == NGlxNavigationalState::EBrowse) |
270 if (aNavigationalState->ViewingMode() == NGlxNavigationalState::EBrowse) |
270 { |
271 { |
271 // For image viewer collection, goto view mode |
272 // For image viewer collection, goto view mode |
272 if (naviState->Id() == TMPXItemId(KGlxCollectionPluginImageViewerImplementationUid)) |
273 if (naviState->Id() == TMPXItemId(KGlxCollectionPluginImageViewerImplementationUid)) |
273 { |
274 { |
274 //it means we are in img viewer |
275 //it means we are in img viewer |
275 fullscreenViewingMode = ETrue; |
276 fullscreenViewingMode = ETrue; |
276 } |
277 } |
277 } |
278 } |
278 else |
279 else |
279 { |
280 { |
280 //it means we are in Fullscreen |
281 //it means we are in Fullscreen |
281 fullscreenViewingMode = ETrue; |
282 fullscreenViewingMode = ETrue; |
282 } |
283 } |
283 } |
284 } |
284 CleanupStack::PopAndDestroy( naviState ); |
285 CleanupStack::PopAndDestroy( naviState ); |
285 aNavigationalState->Close(); |
286 aNavigationalState->Close(); |
286 return fullscreenViewingMode; |
287 return fullscreenViewingMode; |
287 } |
288 } |