idlefw/plugins/mcsplugin/settings/src/mcspluginsettings.cpp
branchRCL_3
changeset 31 8baec10861af
parent 30 a5a39a295112
--- a/idlefw/plugins/mcsplugin/settings/src/mcspluginsettings.cpp	Wed Sep 01 12:22:09 2010 +0100
+++ b/idlefw/plugins/mcsplugin/settings/src/mcspluginsettings.cpp	Tue Sep 14 21:55:16 2010 +0300
@@ -75,6 +75,8 @@
 //
 void CMCSPluginSettings::ConstructL()
 {
+    iTimer = CPeriodic::NewL( CActive::EPriorityUserInput );
+    
     FeatureManager::InitializeLibL();
 
     TParsePtrC driveParse(PathInfo::RomRootPath());
@@ -113,6 +115,12 @@
     FeatureManager::UnInitializeLib();
     iResourceLoader.Close();
     delete iModel;
+    
+    if (iTimer->IsActive())
+        {
+        iTimer->Cancel();
+        }
+    delete iTimer;
 }
 
 // ---------------------------------------------------------------------------
@@ -160,11 +168,49 @@
 //
 void CMCSPluginSettings::DoActivateL(const TVwsViewId& aPrevViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage)
     {
-    iModel->SetPluginIdL( aCustomMessage );
+    // Parse the custom message
+    TInt locate = aCustomMessage.Locate('/');
+    TInt editIdx = -1;
+    
     iModel->UpdateAppListL( EFalse );
     iModel->UpdateBkmListL( EFalse );
-    iModel->UpdateSettingsL();
-    CGSBaseView::DoActivateL( aPrevViewId, aCustomMessageId, aCustomMessage );
+    
+    if (locate > 0)
+        {
+        // if / is located in the custom mesage
+        // upto / is the plugin id
+        iModel->SetPluginIdL(aCustomMessage.Left(locate));
+
+        // right most character is the edit index
+        TLex8 lex(aCustomMessage.Right(1));
+        lex.Val(editIdx);
+
+        iModel->UpdateSettingsL();
+        CGSBaseView::DoActivateL(aPrevViewId, aCustomMessageId,
+                aCustomMessage.Left(locate));        
+
+        if (editIdx > 0)
+            {
+            // set the current edit item
+            Container()->SetCurrentItemIndex(editIdx - 1);
+            
+            // Set timer for handle the change of shortcut item
+            // Otherwise status bar is not shown correctly
+            if (iTimer->IsActive())
+                {
+                iTimer->Cancel();
+                }
+            iTimer->Start( 0, 0, TCallBack( TimerCallbackL, this ) );
+            }
+        }
+    else
+        { 
+        // if '/' is not located, custommessage has only the plugin id 
+        iModel->SetPluginIdL(aCustomMessage);
+        iModel->UpdateSettingsL();
+        CGSBaseView::DoActivateL(aPrevViewId, aCustomMessageId,
+                aCustomMessage);
+        }
     }
 
 // ----------------------------------------------------------------------------
@@ -258,4 +304,18 @@
     Container()->HandleChangeCommandL();
 }
 
+// ---------------------------------------------------------------------------
+// Callback for direct settings change
+// ---------------------------------------------------------------------------
+//
+TInt CMCSPluginSettings::TimerCallbackL( TAny *aPtr )
+    {
+    CMCSPluginSettings* self = reinterpret_cast< CMCSPluginSettings* >( aPtr );
+    self->iTimer->Cancel();
+    // Handle the change
+    self->HandleListBoxSelectionL();
+    
+    return 0;
+    }
+
 // End of File.