134 iNotifier.Close(); |
153 iNotifier.Close(); |
135 iMenu.Close(); |
154 iMenu.Close(); |
136 //iWatcher->Cancel(); |
155 //iWatcher->Cancel(); |
137 delete iWatcher; |
156 delete iWatcher; |
138 delete iNotifyWatcher; |
157 delete iNotifyWatcher; |
|
158 |
139 CCoeEnv::Static()->DeleteResourceFile( iResourceOffset ); |
159 CCoeEnv::Static()->DeleteResourceFile( iResourceOffset ); |
140 } |
160 |
141 |
161 if ( iUndefinedItem ) |
142 |
162 { |
143 // --------------------------------------------------------------------------- |
163 delete iUndefinedItem; |
144 // |
164 iUndefinedItem = NULL; |
|
165 } |
|
166 } |
|
167 |
|
168 // --------------------------------------------------------------------------- |
|
169 // CMCSPluginEngine::InitL |
|
170 // |
145 // --------------------------------------------------------------------------- |
171 // --------------------------------------------------------------------------- |
146 // |
172 // |
147 void CMCSPluginEngine::InitL() |
173 void CMCSPluginEngine::InitL() |
148 { |
174 { |
149 iMenu.OpenL( KMyMenuData ); |
175 iMenu.OpenL( KMyMenuData ); |
150 iPluginData = CMCSPluginData::NewL( *this, iInstanceUid ); |
176 iPluginData = CMCSPluginData::NewL( *this, iInstanceUid ); |
151 iWatcher = CMCSPluginWatcher::NewL( CMCSPluginWatcher::EOperation ); |
177 iWatcher = CMCSPluginWatcher::NewL( CMCSPluginWatcher::EOperation ); |
152 TInt err = iNotifier.Open( iMenu ); |
178 |
|
179 TInt err( iNotifier.Open( iMenu ) ); |
|
180 |
153 if ( err == KErrNone ) |
181 if ( err == KErrNone ) |
154 { |
182 { |
155 iNotifyWatcher = CMCSPluginWatcher::NewL( CMCSPluginWatcher::ENotify ); |
183 iNotifyWatcher = CMCSPluginWatcher::NewL( CMCSPluginWatcher::ENotify ); |
|
184 |
156 iNotifier.Notify( 0, |
185 iNotifier.Notify( 0, |
157 RMenuNotifier::EItemsAddedRemoved | |
186 RMenuNotifier::EItemsAddedRemoved | |
158 RMenuNotifier::EItemsReordered | |
187 RMenuNotifier::EItemsReordered | |
159 RMenuNotifier::EItemAttributeChanged, |
188 RMenuNotifier::EItemAttributeChanged, |
160 iNotifyWatcher->iStatus ); |
189 iNotifyWatcher->iStatus ); |
|
190 |
161 iNotifyWatcher->WatchNotify( this ); |
191 iNotifyWatcher->WatchNotify( this ); |
162 } |
192 } |
163 } |
193 } |
164 |
194 |
165 // --------------------------------------------------------------------------- |
195 // --------------------------------------------------------------------------- |
166 // Tells the settings container to start observing for changes |
196 // CMCSPluginEngine::StartObservingL |
|
197 // |
167 // --------------------------------------------------------------------------- |
198 // --------------------------------------------------------------------------- |
168 // |
199 // |
169 void CMCSPluginEngine::StartObservingL() |
200 void CMCSPluginEngine::StartObservingL() |
170 { |
201 { |
171 // registering to bookmarks db. changes observing |
|
172 User::LeaveIfError( iBookmarkSession.Connect() ); |
|
173 User::LeaveIfError( iBookmarkDb.Open( iBookmarkSession, KBrowserBookmarks ) ); |
|
174 |
|
175 iBookmarkDbObserver = new (ELeave) CActiveFavouritesDbNotifier( |
|
176 iBookmarkDb, *this ); |
|
177 iBookmarkDbObserver->Start(); |
|
178 |
|
179 // registering to mailbox db. changes observing |
202 // registering to mailbox db. changes observing |
180 iMsvSession = CMsvSession::OpenAsObserverL( *this) ; |
203 iMsvSession = CMsvSession::OpenAsObserverL( *this ); |
181 } |
204 } |
182 |
205 |
183 // --------------------------------------------------------------------------- |
206 // --------------------------------------------------------------------------- |
184 // Tells the settings container to stop observing for changes |
207 // CMCSPluginEngine::StopObserving |
|
208 // |
185 // --------------------------------------------------------------------------- |
209 // --------------------------------------------------------------------------- |
186 // |
210 // |
187 void CMCSPluginEngine::StopObserving() |
211 void CMCSPluginEngine::StopObserving() |
188 { |
212 { |
189 if ( iBookmarkDbObserver ) |
213 delete iMsvSession; |
190 { |
214 iMsvSession = NULL; |
191 delete iBookmarkDbObserver; |
215 } |
192 iBookmarkDbObserver = NULL; |
216 |
193 } |
217 // --------------------------------------------------------------------------- |
194 iBookmarkDb.Close(); |
218 // CMCSPluginEngine::MenuDataL |
195 iBookmarkSession.Close(); |
219 // |
196 |
|
197 if ( iMsvSession ) |
|
198 { |
|
199 delete iMsvSession; |
|
200 iMsvSession = NULL; |
|
201 } |
|
202 } |
|
203 |
|
204 // --------------------------------------------------------------------------- |
|
205 // |
|
206 // --------------------------------------------------------------------------- |
220 // --------------------------------------------------------------------------- |
207 // |
221 // |
208 TMCSData& CMCSPluginEngine::MenuDataL( const TInt& aIndex ) |
222 TMCSData& CMCSPluginEngine::MenuDataL( const TInt& aIndex ) |
209 { |
223 { |
210 return iPluginData->DataItemL( aIndex ); |
224 return iPluginData->DataItemL( aIndex ); |
211 } |
225 } |
212 |
226 |
213 // --------------------------------------------------------------------------- |
227 // --------------------------------------------------------------------------- |
214 // |
228 // CMCSPluginEngine::MenuItemCount |
|
229 // |
215 // --------------------------------------------------------------------------- |
230 // --------------------------------------------------------------------------- |
216 // |
231 // |
217 TInt CMCSPluginEngine::MenuItemCount() |
232 TInt CMCSPluginEngine::MenuItemCount() |
218 { |
233 { |
219 return iPluginData->DataCount(); |
234 return iPluginData->DataCount(); |
220 } |
235 } |
221 |
236 |
222 // --------------------------------------------------------------------------- |
237 // --------------------------------------------------------------------------- |
|
238 // CMCSPluginEngine::FindMenuItemL |
223 // Returns the menu item header, which matches the given filter. |
239 // Returns the menu item header, which matches the given filter. |
224 // --------------------------------------------------------------------------- |
240 // --------------------------------------------------------------------------- |
225 // |
241 // |
226 TMenuItem CMCSPluginEngine::FindMenuItemL( CMenuFilter& aFilter ) |
242 TMenuItem CMCSPluginEngine::FindMenuItemL( CMenuFilter& aFilter ) |
227 { |
243 { |
228 TMenuItem item; |
244 TMenuItem item; |
229 const TInt root = iMenu.RootFolderL(); |
245 const TInt root( iMenu.RootFolderL() ); |
|
246 |
230 RArray<TMenuItem> items; |
247 RArray<TMenuItem> items; |
231 CleanupClosePushL( items ); |
248 CleanupClosePushL( items ); |
|
249 |
232 iMenu.GetItemsL( items, root, &aFilter, ETrue ); |
250 iMenu.GetItemsL( items, root, &aFilter, ETrue ); |
233 if( items.Count() > 0 ) |
251 |
234 { |
252 if ( items.Count() > 0 ) |
235 |
253 { |
236 item = items[0]; |
254 item = items[0]; |
237 } |
255 } |
238 |
256 |
239 CleanupStack::PopAndDestroy( &items ); |
257 CleanupStack::PopAndDestroy( &items ); |
|
258 |
240 return item; |
259 return item; |
241 } |
260 } |
242 |
261 |
243 // --------------------------------------------------------------------------- |
262 // --------------------------------------------------------------------------- |
|
263 // CMCSPluginEngine::FetchMenuItemL |
244 // Returns the actual menu item for the given header. |
264 // Returns the actual menu item for the given header. |
245 // --------------------------------------------------------------------------- |
265 // --------------------------------------------------------------------------- |
246 // |
266 // |
247 CMenuItem* CMCSPluginEngine::FetchMenuItemL( const TMenuItem& aMenuItem ) |
267 CMenuItem* CMCSPluginEngine::FetchMenuItemL( const TMenuItem& aMenuItem ) |
248 { |
268 { |
249 return CMenuItem::OpenL( iMenu, aMenuItem ); |
269 return CMenuItem::OpenL( iMenu, aMenuItem ); |
250 } |
270 } |
251 |
271 |
252 // --------------------------------------------------------------------------- |
272 // --------------------------------------------------------------------------- |
|
273 // CMCSPluginEngine::ItemIconL |
253 // Returns MCS default icon if attribute is 'icon' else parses the |
274 // Returns MCS default icon if attribute is 'icon' else parses the |
254 // skin definition from attribute and sets attributes to aMenuItem. |
275 // skin definition from attribute and sets attributes to aMenuItem. |
255 // --------------------------------------------------------------------------- |
276 // --------------------------------------------------------------------------- |
256 // |
277 // |
257 CGulIcon* CMCSPluginEngine::ItemIconL( CMenuItem& aMenuItem, const TDesC& aAttr ) |
278 CGulIcon* CMCSPluginEngine::ItemIconL( CMenuItem& aMenuItem, |
258 { |
279 const TDesC& aAttr ) |
|
280 { |
|
281 CMenuItem* menuItem; |
|
282 |
|
283 TInt id = aMenuItem.Id(); |
|
284 |
|
285 // because the flags might have changed, we have |
|
286 // to get a fresh copy of menu item from Menu Server |
|
287 CMenuItem* mi = CMenuItem::OpenL( iMenu, id ); |
|
288 TUint32 flags = mi->Flags(); |
|
289 delete mi; |
|
290 |
|
291 TUint32 isHidden = flags & TMenuItem::EHidden; |
|
292 TUint32 isMissing = flags & TMenuItem::EMissing; |
|
293 |
|
294 if ( iUndefinedItem && ( isHidden || isMissing ) ) |
|
295 { |
|
296 menuItem = iUndefinedItem; |
|
297 } |
|
298 else |
|
299 { |
|
300 menuItem = &aMenuItem; |
|
301 } |
|
302 |
259 CAknIcon* icon( NULL ); |
303 CAknIcon* icon( NULL ); |
260 CGulIcon* gIcon( NULL ); |
304 CGulIcon* gIcon( NULL ); |
261 TBool exists( ETrue ); |
305 TBool exists( ETrue ); |
262 if( aAttr != KIcon ) |
306 |
|
307 if ( aAttr != KIcon ) |
263 { |
308 { |
264 // Resolve secondary icon definition from attribute |
309 // Resolve secondary icon definition from attribute |
265 TPtrC iconDef = aMenuItem.GetAttributeL( aAttr, exists ); |
310 TPtrC iconDef( menuItem->GetAttributeL( aAttr, exists ) ); |
266 if( exists ) |
311 |
|
312 if ( exists ) |
267 { |
313 { |
268 exists = ConstructMenuItemForIconL( iconDef, aMenuItem ); |
314 exists = ConstructMenuItemForIconL( iconDef, *menuItem ); |
269 } |
315 } |
270 } |
316 } |
271 if( exists ) |
317 |
272 { |
318 if ( exists ) |
273 icon = MenuIconUtility::GetItemIconL( aMenuItem ); |
319 { |
274 if( icon ) |
320 icon = MenuIconUtility::GetItemIconL( *menuItem ); |
|
321 |
|
322 if ( icon ) |
275 { |
323 { |
276 CleanupStack::PushL( icon ); |
324 CleanupStack::PushL( icon ); |
277 gIcon = CGulIcon::NewL(icon->Bitmap(), icon->Mask()); |
325 |
|
326 gIcon = CGulIcon::NewL( icon->Bitmap(), icon->Mask() ); |
|
327 |
278 // Detach and delete |
328 // Detach and delete |
279 icon->SetBitmap( NULL ); |
329 icon->SetBitmap( NULL ); |
280 icon->SetMask( NULL ); |
330 icon->SetMask( NULL ); |
|
331 |
281 CleanupStack::PopAndDestroy( icon ); |
332 CleanupStack::PopAndDestroy( icon ); |
282 } |
333 } |
283 } |
334 } |
|
335 |
284 return gIcon; |
336 return gIcon; |
285 } |
337 } |
286 |
338 |
287 // --------------------------------------------------------------------------- |
339 // --------------------------------------------------------------------------- |
|
340 // CMCSPluginEngine::ItemTextL |
288 // Returns text string for the given attribute |
341 // Returns text string for the given attribute |
289 // --------------------------------------------------------------------------- |
342 // --------------------------------------------------------------------------- |
290 // |
343 // |
291 TPtrC CMCSPluginEngine::ItemTextL( CMenuItem& aMenuItem, const TDesC& aAttr ) |
344 TPtrC CMCSPluginEngine::ItemTextL( CMenuItem& aMenuItem, const TDesC& aAttr ) |
292 { |
345 { |
|
346 // if item is hidden or missing (mmc card removed) |
|
347 // use "Undefined" text instead |
|
348 CMenuItem* menuItem; |
|
349 |
|
350 TInt id = aMenuItem.Id(); |
|
351 |
|
352 // because the flags might have changed, we have |
|
353 // to get a fresh copy of the menu item from Menu Server |
|
354 CMenuItem* mi = CMenuItem::OpenL( iMenu, id ); |
|
355 TUint32 flags = mi->Flags(); |
|
356 delete mi; |
|
357 |
|
358 TUint32 isHidden = flags & TMenuItem::EHidden; |
|
359 TUint32 isMissing = flags & TMenuItem::EMissing; |
|
360 |
|
361 if ( iUndefinedItem && ( isHidden || isMissing ) ) |
|
362 { |
|
363 menuItem = iUndefinedItem; |
|
364 } |
|
365 else |
|
366 { |
|
367 menuItem = &aMenuItem; |
|
368 } |
|
369 |
293 TBool exists( KErrNotFound ); |
370 TBool exists( KErrNotFound ); |
294 TPtrC name = aMenuItem.GetAttributeL( aAttr, exists ); |
371 |
295 if( exists ) |
372 TPtrC name( menuItem->GetAttributeL( aAttr, exists ) ); |
|
373 |
|
374 if ( exists ) |
296 { |
375 { |
297 return name; |
376 return name; |
298 } |
377 } |
299 else |
378 |
300 { |
379 return KNullDesC(); |
301 return KNullDesC(); |
380 } |
302 } |
381 |
303 } |
382 // --------------------------------------------------------------------------- |
304 |
383 // CMCSPluginEngine::LaunchItemL |
305 // --------------------------------------------------------------------------- |
|
306 // Calls the open command for the given menu item header |
384 // Calls the open command for the given menu item header |
307 // --------------------------------------------------------------------------- |
385 // --------------------------------------------------------------------------- |
308 // |
386 // |
309 void CMCSPluginEngine::LaunchItemL( const TInt& aIndex ) |
387 void CMCSPluginEngine::LaunchItemL( const TInt& aIndex ) |
310 { |
388 { |
311 |
389 if ( iBackupRestore ) |
312 if ( iSuspend ) |
|
313 { |
390 { |
314 HBufC* temp = StringLoader::LoadLC( R_MCS_DISABLE_OPEN_ITEM ); |
391 HBufC* temp = StringLoader::LoadLC( R_MCS_DISABLE_OPEN_ITEM ); |
|
392 |
|
393 CAknNoteDialog* dialog = new (ELeave) CAknNoteDialog( |
|
394 CAknNoteDialog::EConfirmationTone, |
|
395 CAknNoteDialog::ENoTimeout ); |
|
396 dialog->SetTextL( temp->Des() ); |
|
397 dialog->ExecuteDlgLD( R_MCS_DISABLE_OPEN_ITEM_DLG ); |
|
398 |
|
399 CleanupStack::PopAndDestroy( temp ); |
|
400 return; |
|
401 } |
|
402 |
|
403 if( iWatcher->IsActive()) |
|
404 { |
|
405 return; |
|
406 } |
|
407 |
|
408 TMCSData& dataItem( iPluginData->DataItemL( aIndex ) ); |
|
409 |
|
410 CMenuItem* item( CMenuItem::OpenL( iMenu, dataItem.MenuItem().Id() ) ); |
|
411 CleanupStack::PushL( item ); |
|
412 |
|
413 |
|
414 TBool attrExists = ETrue; |
|
415 |
|
416 TPtrC uid = item->GetAttributeL( KMenuAttrUid, attrExists ); |
|
417 |
|
418 // trying to run non-existing application ( that was replaced by "Undefined" app ) |
|
419 // OR trying to run hidden or missing application (e.g. unistalled app |
|
420 // or app on MMC which was removed ) |
|
421 // -> We display a note for a user that this is not possible¨ |
|
422 TUint32 isHidden = item->Flags() & TMenuItem::EHidden; |
|
423 TUint32 isMissing = item->Flags() & TMenuItem::EMissing; |
|
424 |
|
425 if ( ( attrExists && uid == KMenuAttrUndefUid ) || isHidden || isMissing ) |
|
426 { |
|
427 CleanupStack::PopAndDestroy( item ); |
|
428 |
|
429 HBufC* temp = StringLoader::LoadLC( R_MCS_DISABLE_OPEN_ITEM_MISSING ); |
315 |
430 |
316 CAknNoteDialog* dialog = new (ELeave) CAknNoteDialog( |
431 CAknNoteDialog* dialog = new (ELeave) CAknNoteDialog( |
317 CAknNoteDialog::EConfirmationTone, |
432 CAknNoteDialog::EConfirmationTone, |
318 CAknNoteDialog::ENoTimeout ); |
433 CAknNoteDialog::ENoTimeout ); |
319 dialog->SetTextL( temp->Des() ); |
434 dialog->SetTextL( temp->Des() ); |
320 dialog->ExecuteDlgLD( R_MCS_DISABLE_OPEN_ITEM_DLG ); |
435 dialog->ExecuteDlgLD( R_MCS_DISABLE_OPEN_ITEM_DLG ); |
321 CleanupStack::PopAndDestroy( temp ); |
436 CleanupStack::PopAndDestroy( temp ); |
|
437 temp = NULL; |
|
438 |
322 return; |
439 return; |
323 } |
440 } |
324 if( iWatcher->IsActive()) |
441 |
325 { |
442 // run item based on its type |
326 return; |
443 TPtrC type( item->Type() ); |
327 } |
|
328 |
|
329 |
|
330 TMCSData& dataItem = iPluginData->DataItemL( aIndex ); |
|
331 CMenuItem* item = CMenuItem::OpenL( iMenu, dataItem.MenuItem()); |
|
332 CleanupStack::PushL( item ); |
|
333 TPtrC type = item->Type(); |
|
334 |
444 |
335 // run folder |
445 // run folder |
336 if ( type == KMenuTypeFolder ) |
446 if ( type == KMenuTypeFolder ) |
337 { |
447 { |
338 |
|
339 // message for MM application |
448 // message for MM application |
340 HBufC8* message; |
449 HBufC8* message; |
341 |
450 |
342 // prepare message for launching folder |
451 // prepare message for launching folder |
343 TBool hasApplicationGroupName = EFalse; |
452 TBool hasApplicationGroupName( EFalse ); |
344 TPtrC applicationGroupName = item->GetAttributeL( KApplicationGroupName, |
453 |
345 hasApplicationGroupName ); |
454 TPtrC applicationGroupName( item->GetAttributeL( |
|
455 KApplicationGroupName, hasApplicationGroupName ) ); |
|
456 |
346 if ( !hasApplicationGroupName ) |
457 if ( !hasApplicationGroupName ) |
347 { |
458 { |
348 CleanupStack::PopAndDestroy( item ); |
459 CleanupStack::PopAndDestroy( item ); |
349 return; |
460 return; |
350 } |
461 } |
|
462 |
351 message = HBufC8::NewLC( KMMApplication().Length() + |
463 message = HBufC8::NewLC( KMMApplication().Length() + |
352 KSetFocusString().Length() + |
464 KSetFocusString().Length() + |
353 applicationGroupName.Length() + |
465 applicationGroupName.Length() + |
354 KHideExit2().Length() ); |
466 KHideExit2().Length() ); |
355 |
467 |
358 message->Des().Append( applicationGroupName ); |
470 message->Des().Append( applicationGroupName ); |
359 message->Des().Append( KHideExit2 ); |
471 message->Des().Append( KHideExit2 ); |
360 |
472 |
361 // find MM application |
473 // find MM application |
362 TApaTaskList taskList( CCoeEnv::Static()->WsSession() ); |
474 TApaTaskList taskList( CCoeEnv::Static()->WsSession() ); |
363 TApaTask task = taskList.FindApp( KMMUid ); |
475 TApaTask task( taskList.FindApp( KMMUid ) ); |
364 |
476 |
365 if ( task.Exists() ) |
477 if ( task.Exists() ) |
366 { |
478 { |
367 // MM is already running in background - send APA Message |
479 // MM is already running in background - send APA Message |
368 task.SendMessage( TUid::Uid( KUidApaMessageSwitchOpenFileValue ), *message ); |
480 task.SendMessage( |
|
481 TUid::Uid( KUidApaMessageSwitchOpenFileValue ), *message ); |
369 } |
482 } |
370 else |
483 else |
371 { |
484 { |
372 // MM not running yet - use Command Line Tail |
485 // MM not running yet - use Command Line Tail |
373 RApaLsSession appArcSession; |
486 RApaLsSession appArcSession; |
374 CleanupClosePushL( appArcSession ); |
487 CleanupClosePushL( appArcSession ); |
|
488 |
375 User::LeaveIfError( appArcSession.Connect() ); |
489 User::LeaveIfError( appArcSession.Connect() ); |
|
490 |
376 TApaAppInfo appInfo; |
491 TApaAppInfo appInfo; |
377 TInt err = appArcSession.GetAppInfo( appInfo, KMMUid ); |
492 TInt err( appArcSession.GetAppInfo( appInfo, KMMUid ) ); |
|
493 |
378 if ( err == KErrNone ) |
494 if ( err == KErrNone ) |
379 { |
495 { |
380 CApaCommandLine* cmdLine = CApaCommandLine::NewLC(); |
496 CApaCommandLine* cmdLine = CApaCommandLine::NewLC(); |
381 cmdLine->SetExecutableNameL( appInfo.iFullName ); |
497 cmdLine->SetExecutableNameL( appInfo.iFullName ); |
382 cmdLine->SetCommandL( EApaCommandRun ); |
498 cmdLine->SetCommandL( EApaCommandRun ); |
383 cmdLine->SetTailEndL( *message ); |
499 cmdLine->SetTailEndL( *message ); |
384 appArcSession.StartApp( *cmdLine ); |
500 appArcSession.StartApp( *cmdLine ); |
385 CleanupStack::PopAndDestroy( cmdLine ); |
501 CleanupStack::PopAndDestroy( cmdLine ); |
386 } |
502 } |
|
503 |
387 CleanupStack::PopAndDestroy( &appArcSession ); |
504 CleanupStack::PopAndDestroy( &appArcSession ); |
388 } |
505 } |
|
506 |
389 CleanupStack::PopAndDestroy( message ); |
507 CleanupStack::PopAndDestroy( message ); |
390 } |
508 } |
391 else |
509 else |
392 { |
510 { |
393 TBool exists( EFalse ); |
511 TBool exists( EFalse ); |
|
512 |
394 TPtrC desc( item->GetAttributeL( KMenuAttrUid, exists ) ); |
513 TPtrC desc( item->GetAttributeL( KMenuAttrUid, exists ) ); |
395 |
514 |
396 if( exists ) |
515 if ( exists ) |
397 { |
516 { |
398 _LIT( KPrefix, "0x" ); |
517 _LIT( KPrefix, "0x" ); |
|
518 |
399 const TInt pos( desc.FindF( KPrefix ) ); |
519 const TInt pos( desc.FindF( KPrefix ) ); |
400 |
520 |
401 if( pos != KErrNotFound ) |
521 if ( pos != KErrNotFound ) |
402 { |
522 { |
403 TLex lex( desc.Mid( pos + KPrefix().Length() ) ); |
523 TLex lex( desc.Mid( pos + KPrefix().Length() ) ); |
|
524 |
404 // Hex parsing needs unsigned int |
525 // Hex parsing needs unsigned int |
405 TUint32 value = 0; |
526 TUint32 value( 0 ); |
406 const TInt parseResult = lex.Val( value, EHex ); |
527 const TInt parseResult( lex.Val( value, EHex ) ); |
407 |
528 |
408 if ( parseResult == KErrNone ) |
529 if ( parseResult == KErrNone ) |
409 { |
530 { |
410 TUid uid( KNullUid ); |
531 TUid uid( KNullUid ); |
411 TInt32 value32( value ); |
532 TInt32 value32( value ); |
412 uid.iUid = value32; |
533 uid.iUid = value32; |
413 |
534 |
414 if( uid != KNullUid ) |
535 if ( uid != KNullUid ) |
415 { |
536 { |
416 //start a full screen effect |
537 //start a full screen effect |
417 GfxTransEffect::BeginFullScreen( |
538 GfxTransEffect::BeginFullScreen( |
418 AknTransEffect::EApplicationStart, |
539 AknTransEffect::EApplicationStart, |
419 TRect(0,0,0,0), |
540 TRect(), |
420 AknTransEffect::EParameterType, |
541 AknTransEffect::EParameterType, |
421 AknTransEffect::GfxTransParam( uid, |
542 AknTransEffect::GfxTransParam( uid, |
422 AknTransEffect::TParameter::EActivateExplicitContinue )); |
543 AknTransEffect::TParameter::EActivateExplicitContinue ) ); |
423 } |
544 } |
424 } |
545 } |
425 } |
546 } |
426 } |
547 } |
427 |
548 |
428 // run application/shortcut/bookmark |
549 // run application/shortcut/bookmark |
429 CMenuOperation* operation = item->HandleCommandL( |
550 CMenuOperation* operation( item->HandleCommandL( |
430 KMenuCmdOpen, KNullDesC8, iWatcher->iStatus ); |
551 KMenuCmdOpen, KNullDesC8, iWatcher->iStatus ) ); |
|
552 |
431 iWatcher->Watch( operation ); |
553 iWatcher->Watch( operation ); |
432 } |
554 } |
|
555 |
433 CleanupStack::PopAndDestroy( item ); |
556 CleanupStack::PopAndDestroy( item ); |
434 } |
557 } |
435 |
558 |
436 // --------------------------------------------------------------------------- |
559 // --------------------------------------------------------------------------- |
|
560 // CMCSPluginEngine::HandleNotifyL |
437 // Handle the change in Menu Content |
561 // Handle the change in Menu Content |
438 // --------------------------------------------------------------------------- |
562 // --------------------------------------------------------------------------- |
439 // |
563 // |
440 void CMCSPluginEngine::HandleNotifyL() |
564 void CMCSPluginEngine::HandleNotifyL() |
441 { |
565 { |
442 TInt count( iPluginData->DataCount()); |
566 TInt count( iPluginData->DataCount() ); |
443 for( TInt i = 0; i < count; i++ ) |
567 |
444 { |
568 for ( TInt i = 0; i < count; i++ ) |
445 TMCSData& data = iPluginData->DataItemL(i); |
569 { |
|
570 TMCSData& data( iPluginData->DataItemL(i) ); |
|
571 data.SetDirty( ETrue ); |
|
572 |
446 // Check that all the data still exist is MCS, if flag is hidden or |
573 // Check that all the data still exist is MCS, if flag is hidden or |
447 // missing, we have to remove data from UI |
574 // missing, we have to remove data from UI |
448 CMenuItem* menuItem = CMenuItem::OpenL( iMenu, data.MenuItem().Id() ); |
575 CMenuItem* menuItem = NULL; |
449 CleanupStack::PushL( menuItem ); |
576 |
450 if ( !menuItem || |
577 TRAP_IGNORE ( |
451 ( menuItem->Flags() & TMenuItem::EHidden ) || |
578 menuItem = CMenuItem::OpenL( iMenu, data.MenuItem().Id() ); |
452 ( menuItem->Flags() & TMenuItem::EMissing ) ) |
579 ) |
|
580 |
|
581 // item not found. Use "Undefined" item as a replacement |
|
582 if ( !menuItem ) |
453 { |
583 { |
454 // Get the replacement for hidden data |
584 CleanupStack::PushL( menuItem ); |
455 CMenuFilter* filter = CMenuFilter::NewL(); |
585 iPluginData->ReplaceMenuItemL( i, iUndefinedItemHeader ); |
456 CleanupStack::PushL( filter ); |
586 iPluginData->SaveSettingsL( i, *iUndefinedItem ); |
457 // 'Undefined' item |
587 CleanupStack::Pop( menuItem ); |
458 filter->HaveAttributeL( KMenuAttrUid, KMenuAttrUndefUid ); |
588 } |
459 TMenuItem undefItem = FindMenuItemL( *filter ); |
589 |
460 iPluginData->ReplaceMenuItemL( i, undefItem ); |
590 delete menuItem; |
461 iPluginData->SaveSettingsL( i, *FetchMenuItemL(undefItem) ); |
|
462 CleanupStack::PopAndDestroy( filter ); |
|
463 } |
|
464 CleanupStack::PopAndDestroy( menuItem ); |
|
465 menuItem = NULL; |
591 menuItem = NULL; |
466 } |
592 } |
|
593 |
467 // Notification must be activated again |
594 // Notification must be activated again |
468 iNotifyWatcher->Cancel(); |
595 iNotifyWatcher->Cancel(); |
|
596 |
469 iNotifier.Notify( 0, |
597 iNotifier.Notify( 0, |
470 RMenuNotifier::EItemsAddedRemoved | |
598 RMenuNotifier::EItemsAddedRemoved | |
471 RMenuNotifier::EItemsReordered | |
599 RMenuNotifier::EItemsReordered | |
472 RMenuNotifier::EItemAttributeChanged, |
600 RMenuNotifier::EItemAttributeChanged, |
473 iNotifyWatcher->iStatus ); |
601 iNotifyWatcher->iStatus ); |
474 |
602 |
475 iNotifyWatcher->WatchNotify( this ); |
603 iNotifyWatcher->WatchNotify( this ); |
|
604 |
476 // Publish changed data |
605 // Publish changed data |
477 iPlugin.PublishL(); |
606 iPlugin.PublishL(); |
478 } |
607 } |
479 |
608 |
480 // --------------------------------------------------------------------------- |
609 // --------------------------------------------------------------------------- |
481 // From class MMsvSessionObserver. |
610 // CMCSPluginEngine::HandleSessionEventL |
482 // Handles an event from the message server. |
611 // Handles an event from the message server. |
483 // --------------------------------------------------------------------------- |
612 // --------------------------------------------------------------------------- |
484 // |
613 // |
485 void CMCSPluginEngine::HandleSessionEventL( |
614 void CMCSPluginEngine::HandleSessionEventL( TMsvSessionEvent aEvent, |
486 TMsvSessionEvent aEvent, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) |
615 TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) |
487 { |
616 { |
488 switch ( aEvent ) |
617 switch ( aEvent ) |
489 { |
618 { |
490 case EMsvEntriesDeleted: |
619 case EMsvEntriesDeleted: |
491 // fall-through intended here |
620 // fall-through intended here |
492 case EMsvEntriesChanged: |
621 case EMsvEntriesChanged: |
493 { |
|
494 |
|
495 } |
|
496 break; |
|
497 default: |
|
498 break; |
|
499 } |
|
500 } |
|
501 |
|
502 // ----------------------------------------------------------------------------- |
|
503 // From class MFavouritesDbObserver. |
|
504 // Handles database event. |
|
505 // ----------------------------------------------------------------------------- |
|
506 // |
|
507 void CMCSPluginEngine::HandleFavouritesDbEventL( RDbNotifier::TEvent aEvent ) |
|
508 { |
|
509 switch ( aEvent ) |
|
510 { |
|
511 case RDbNotifier::ERollback: |
|
512 // fall-through intended here |
|
513 case RDbNotifier::ERecover: |
|
514 // fall-through intended here |
|
515 case RDbNotifier::ECommit: |
|
516 { |
622 { |
517 // Get list of favourites bookmarks |
|
518 CFavouritesItemList* favItems = |
|
519 new (ELeave) CFavouritesItemList(); |
|
520 CleanupStack::PushL( favItems ); |
|
521 TInt err = iBookmarkDb.GetAll( *favItems, KFavouritesNullUid, |
|
522 CFavouritesItem::EItem ); |
|
523 if ( err != KErrNone ) |
|
524 { |
|
525 ASSERT(0); |
|
526 } |
|
527 TInt count_fav = favItems->Count(); |
|
528 |
|
529 // Do for each plugin data (4x times) |
|
530 TInt count_data( iPluginData->DataCount() ); |
|
531 for ( TInt item_index = 0; item_index < count_data; item_index++ ) |
|
532 { |
|
533 // Get item ID and open its menu related item |
|
534 TMCSData& data = iPluginData->DataItemL( item_index ); |
|
535 TInt itemID( data.MenuItem().Id() ); |
|
536 CMenuItem* menuItem = CMenuItem::OpenL( iMenu, itemID ); |
|
537 CleanupStack::PushL( menuItem ); |
|
538 |
|
539 // Get URL aatribute |
|
540 TBool attrExists = EFalse; |
|
541 TPtrC url = menuItem->GetAttributeL( _L("url"), attrExists ); |
|
542 // If bookmark... |
|
543 if ( attrExists ) |
|
544 { |
|
545 // Get bookmark UID |
|
546 TPtrC uid_item_ptr = menuItem->GetAttributeL( |
|
547 KMenuAttrUid, attrExists ); |
|
548 |
|
549 // Compare with each item in fav. bookmarks list |
|
550 TBool itemExists = EFalse; |
|
551 for ( TInt fav_index = count_fav - 1; fav_index >= 0; fav_index-- ) // newest on top |
|
552 { |
|
553 // Get list item UID |
|
554 TUid uid_fav = TUid::Uid( favItems->At( fav_index )->Uid() ); |
|
555 if ( uid_fav.Name() == uid_item_ptr ) |
|
556 { |
|
557 // Bookmark still exist in fav. bookmarks list |
|
558 itemExists = ETrue; |
|
559 break; |
|
560 } |
|
561 } |
|
562 |
|
563 if ( !itemExists ) |
|
564 { |
|
565 // If item not axist any more, replace it by undefined icon |
|
566 CMenuFilter* filter = CMenuFilter::NewL(); |
|
567 CleanupStack::PushL( filter ); |
|
568 // 'Undefined' item |
|
569 filter->HaveAttributeL( KMenuAttrUid, |
|
570 KMenuAttrUndefUid ); |
|
571 TMenuItem undefItem = FindMenuItemL( *filter ); |
|
572 iPluginData->ReplaceMenuItemL( item_index, undefItem ); |
|
573 iPluginData->SaveSettingsL( item_index, *FetchMenuItemL( |
|
574 undefItem ) ); |
|
575 CleanupStack::PopAndDestroy( filter ); |
|
576 } |
|
577 } |
|
578 CleanupStack::PopAndDestroy( menuItem ); |
|
579 } |
|
580 CleanupStack::PopAndDestroy( favItems ); |
|
581 } |
623 } |
582 break; |
624 break; |
583 default: |
625 default: |
584 break; |
626 break; |
585 } |
627 } |
586 } |
628 } |
587 |
629 |
588 // --------------------------------------------------------------------------- |
630 // --------------------------------------------------------------------------- |
589 // Resumes the engine |
631 // CMCSPluginEngine::SetBackupRestore |
590 // --------------------------------------------------------------------------- |
632 // |
591 // |
633 // --------------------------------------------------------------------------- |
592 void CMCSPluginEngine::ResumeL() |
634 // |
593 { |
635 void CMCSPluginEngine::SetBackupRestore( TBool aBackupRestore ) |
594 iSuspend = EFalse; |
636 { |
595 } |
637 iBackupRestore = aBackupRestore; |
596 |
638 } |
597 // --------------------------------------------------------------------------- |
639 |
598 // Suspends the engine |
640 // --------------------------------------------------------------------------- |
599 // --------------------------------------------------------------------------- |
641 // CMCSPluginEngine::ShowSettingsL |
600 // |
|
601 void CMCSPluginEngine::Suspend() |
|
602 { |
|
603 iSuspend = ETrue; |
|
604 } |
|
605 |
|
606 // --------------------------------------------------------------------------- |
|
607 // Launch General Settings plugin |
642 // Launch General Settings plugin |
608 // --------------------------------------------------------------------------- |
643 // --------------------------------------------------------------------------- |
609 // |
644 // |
610 void CMCSPluginEngine::ShowSettingsL() |
645 void CMCSPluginEngine::ShowSettingsL() |
611 { |
646 { |
612 TUid uid = {AI_UID_ECOM_IMPLEMENTATION_SETTINGS_MCSPLUGIN}; |
647 TUid uid = {AI_UID_ECOM_IMPLEMENTATION_SETTINGS_MCSPLUGIN}; |
613 CGSLauncher* l = CGSLauncher::NewLC(); |
648 |
614 l->LaunchGSViewL ( uid, |
649 CGSLauncher* launcher = CGSLauncher::NewLC(); |
615 KHomescreenUid, |
650 |
616 iInstanceUid ); |
651 launcher->LaunchGSViewL ( uid, KHomescreenUid, iInstanceUid ); |
617 CleanupStack::PopAndDestroy( l ); |
652 |
618 |
653 CleanupStack::PopAndDestroy( launcher ); |
619 } |
654 } |
620 // --------------------------------------------------------------------------- |
655 |
621 // ResolveSkinItemId |
656 // --------------------------------------------------------------------------- |
|
657 // CMCSPluginEngine::ConstructMenuItemForIconL |
622 // Syntax: skin(major minor):mif(filename bimapId maskId) |
658 // Syntax: skin(major minor):mif(filename bimapId maskId) |
623 // --------------------------------------------------------------------------- |
659 // --------------------------------------------------------------------------- |
624 // |
660 // |
625 TBool CMCSPluginEngine::ConstructMenuItemForIconL( const TDesC& aPath, CMenuItem& aMenuItem ) |
661 TBool CMCSPluginEngine::ConstructMenuItemForIconL( const TDesC& aPath, |
|
662 CMenuItem& aMenuItem ) |
626 { |
663 { |
627 TInt pos = aPath.Locate( ':' ); |
664 TInt pos( aPath.Locate( ':' ) ); |
628 if( pos == KErrNotFound ) |
665 |
|
666 if ( pos == KErrNotFound ) |
629 { |
667 { |
630 pos = aPath.Length(); |
668 pos = aPath.Length(); |
631 } |
669 } |
632 TPtrC skin = aPath.Left( pos ); |
670 |
633 TInt sf = skin.FindF( KSkin ); |
671 TPtrC skin( aPath.Left( pos ) ); |
634 if( sf == KErrNotFound ) |
672 TInt sf( skin.FindF( KSkin ) ); |
|
673 |
|
674 if ( sf == KErrNotFound ) |
635 { |
675 { |
636 return EFalse; |
676 return EFalse; |
637 } |
677 } |
638 TPtrC temp = skin.Mid( sf + KSkin().Length()); |
678 |
639 TLex input( temp ); |
679 TPtrC temp( skin.Mid( sf + KSkin().Length() ) ); |
|
680 |
|
681 TLex input( temp ); |
640 input.SkipSpace(); |
682 input.SkipSpace(); |
641 if( !input.Eos() && input.Peek() == '(') |
683 |
|
684 if ( !input.Eos() && input.Peek() == '(' ) |
642 { |
685 { |
643 input.Inc(); |
686 input.Inc(); |
644 } |
687 } |
645 TPtrC majorId = NextIdToken( input ); |
688 |
646 TPtrC minorId = NextIdToken( input ); |
689 TPtrC majorId( NextIdToken( input ) ); |
|
690 TPtrC minorId( NextIdToken( input ) ); |
|
691 |
647 aMenuItem.SetAttributeL( KMenuAttrIconSkinMajorId, majorId ); |
692 aMenuItem.SetAttributeL( KMenuAttrIconSkinMajorId, majorId ); |
648 aMenuItem.SetAttributeL( KMenuAttrIconSkinMinorId, minorId ); |
693 aMenuItem.SetAttributeL( KMenuAttrIconSkinMinorId, minorId ); |
649 |
694 |
650 //TPtrC mif = aPath.Mid( pos + 1 ); |
695 //TPtrC mif = aPath.Mid( pos + 1 ); |
651 //TInt mf = mif.FindF( KMif ); |
696 //TInt mf = mif.FindF( KMif ); |
652 if( aPath.Length() > pos && (aPath.Mid( pos + 1 ).FindF( KMif ) != KErrNotFound )) |
697 |
|
698 if ( aPath.Length() > pos && |
|
699 ( aPath.Mid( pos + 1 ).FindF( KMif ) != KErrNotFound ) ) |
653 { |
700 { |
654 TPtrC mif = aPath.Mid( pos + 1 ); |
701 TPtrC mif( aPath.Mid( pos + 1 ) ); |
655 TInt mf = mif.FindF( KMif ); |
702 TInt mf( mif.FindF( KMif ) ); |
|
703 |
656 //TPtrC temp1 = mif.Mid( mf+ KMif().Length()); |
704 //TPtrC temp1 = mif.Mid( mf+ KMif().Length()); |
657 TLex input1( mif.Mid( mf+ KMif().Length()) ); |
705 |
|
706 TLex input1( mif.Mid( mf + KMif().Length() ) ); |
658 input1.SkipSpace(); |
707 input1.SkipSpace(); |
659 if( !input1.Eos() && input1.Peek() == '(') |
708 |
|
709 if ( !input1.Eos() && input1.Peek() == '(' ) |
660 { |
710 { |
661 input1.Inc(); |
711 input1.Inc(); |
662 } |
712 } |
663 TPtrC file = NextIdToken( input1 ); |
713 |
664 TPtrC bitmapId = NextIdToken( input1 ); |
714 TPtrC file( NextIdToken( input1 ) ); |
665 TPtrC maskId = NextIdToken( input1 ); |
715 TPtrC bitmapId( NextIdToken( input1 ) ); |
|
716 TPtrC maskId( NextIdToken( input1 ) ); |
|
717 |
666 aMenuItem.SetAttributeL( KMenuAttrIconFile, file ); |
718 aMenuItem.SetAttributeL( KMenuAttrIconFile, file ); |
667 aMenuItem.SetAttributeL( KMenuAttrIconId, bitmapId ); |
719 aMenuItem.SetAttributeL( KMenuAttrIconId, bitmapId ); |
668 aMenuItem.SetAttributeL( KMenuAttrMaskId, maskId ); |
720 aMenuItem.SetAttributeL( KMenuAttrMaskId, maskId ); |
669 } |
721 } |
|
722 |
670 return ETrue; |
723 return ETrue; |
671 } |
724 } |
672 |
725 |
673 // --------------------------------------------------------------------------- |
726 // --------------------------------------------------------------------------- |
|
727 // CMCSPluginEngine::CleanMCSItemsL |
674 // Called during plugin desctruction |
728 // Called during plugin desctruction |
675 // Decrements reference counters of all run-time generated items |
729 // Decrements reference counters of all run-time generated items |
676 // and deletes those which have reference counter == 0 |
730 // and deletes those which have reference counter == 0 |
677 // --------------------------------------------------------------------------- |
731 // --------------------------------------------------------------------------- |
678 // |
732 // |
679 void CMCSPluginEngine::CleanMCSItemsL() |
733 void CMCSPluginEngine::CleanMCSItemsL() |
680 { |
734 { |
681 const TInt count( iPluginData->DataCount() ); |
735 const TInt count( iPluginData->DataCount() ); |
|
736 |
682 for( TInt i = 0; i < count; i++ ) |
737 for( TInt i = 0; i < count; i++ ) |
683 { |
738 { |
684 TMCSData& data = iPluginData->DataItemL(i); |
739 TMCSData& data( iPluginData->DataItemL(i) ); |
685 |
740 |
686 CMenuItem* menuItem = CMenuItem::OpenL( iMenu, data.MenuItem().Id() ); |
741 CMenuItem* menuItem = CMenuItem::OpenL( iMenu, data.MenuItem().Id() ); |
687 if( !menuItem ) |
742 |
|
743 if ( !menuItem ) |
688 { |
744 { |
689 continue; |
745 continue; |
690 } |
746 } |
|
747 |
691 CleanupStack::PushL( menuItem ); |
748 CleanupStack::PushL( menuItem ); |
692 |
749 |
693 // check if ref_count attribute exists |
750 // check if ref_count attribute exists |
694 TBool exists = EFalse; |
751 TBool exists( EFalse ); |
695 TPtrC param = menuItem->GetAttributeL( KMenuAttrRefcount, exists ); |
752 |
|
753 TPtrC param( menuItem->GetAttributeL( KMenuAttrRefcount, exists ) ); |
|
754 |
696 if( exists ) |
755 if( exists ) |
697 { |
756 { |
698 const TInt references = UpdateMenuItemsRefCountL( menuItem, -1 ); |
757 const TInt references( UpdateMenuItemsRefCountL( menuItem, -1 ) ); |
699 |
758 |
700 // Create a nested loop inside CActiveScheduler. |
759 // Create a nested loop inside CActiveScheduler. |
701 CActiveSchedulerWait* wait = new (ELeave) CActiveSchedulerWait; |
760 CActiveSchedulerWait* wait = |
|
761 new ( ELeave ) CActiveSchedulerWait; |
702 CleanupStack::PushL( wait ); |
762 CleanupStack::PushL( wait ); |
703 |
763 |
704 if( references > 0 ) |
764 if( references > 0 ) |
705 { |
765 { |
706 // if counter is still > 0, update its value in MCS |
766 // if counter is still > 0, update its value in MCS |