commsconfig/cscapplicationui/src/cscappui.cpp
branchRCL_3
changeset 8 7117cbf1600a
parent 6 fc8c25e5a2e8
child 9 bddb6d4447db
--- a/commsconfig/cscapplicationui/src/cscappui.cpp	Fri Feb 19 22:44:34 2010 +0200
+++ b/commsconfig/cscapplicationui/src/cscappui.cpp	Fri Mar 12 15:42:09 2010 +0200
@@ -29,6 +29,9 @@
 #include <xSPViewServices.h>
 #include <AiwServiceHandler.h>
 #include <mspnotifychangeobserver.h>
+#include <gsfwviewuids.h>
+#include <apgwgnam.h>
+#include <csc.hlp.hrh>
 
 #include "cscappui.h"
 #include "csclogger.h"
@@ -45,6 +48,7 @@
 #include "cscenguiextensionpluginhandler.h"
 
 const TInt KMaxParamLength = 255;
+const TInt KGSChildAppWindowGroupNameLength = 100;
 
 // ======== MEMBER FUNCTIONS ========
 
@@ -190,12 +194,19 @@
     
     switch ( aCommand )
         {
+        case EAknSoftkeyBack:
+            {
+            Exit();
+            break;
+            }
         case EEikCmdExit:
         case EAknSoftkeyExit:
-        case EAknSoftkeyBack:
         case EAknCmdExit:
+            {
+            ExitGSIfParentL();
             Exit();
             break;
+            }
         default:
             break;
         }
@@ -457,3 +468,50 @@
     
     CSCDEBUG( "CCSCAppUi::SnapCheckL - end" );  
     }
+
+// ---------------------------------------------------------------------------
+// Check if GS has to be closed
+// ---------------------------------------------------------------------------
+//
+TBool CCSCAppUi::ExitGSIfParentL()
+    {
+    TBool ret = EFalse;
+    
+    RWsSession ws  = CEikonEnv::Static()->WsSession();
+    TApaTaskList taskList( ws );
+    TApaTask gstask = taskList.FindApp( KUidGS  );
+
+    if ( gstask.Exists() )
+        {
+        TInt gswgid = gstask.WgId();
+        RArray<RWsSession::TWindowGroupChainInfo> wgrp;
+        ws.WindowGroupList( &wgrp );
+        TInt i = 0;
+
+        // Loop window groups, find GS's child app
+        for ( i=0; i < wgrp.Count() ; ++i )
+            {
+            TBuf< KGSChildAppWindowGroupNameLength > name;
+            ws.GetWindowGroupNameFromIdentifier( wgrp[i].iId , name );
+            RWsSession::TWindowGroupChainInfo wginfo = wgrp[i];
+            if ( wginfo.iParentId == gswgid ) // Child of GS found
+                {
+                CApaWindowGroupName* windowName1 =
+                    CApaWindowGroupName::NewLC( ws, wginfo.iId ); // CS:1
+                TUid embeddeeuid;
+                embeddeeuid = windowName1->AppUid();
+
+                // Check if CSC is the child of GS
+                if ( KUidCscHelp == embeddeeuid )
+                    {
+                    ret = ETrue;
+                    gstask.EndTask();
+                    }
+                CleanupStack::PopAndDestroy( windowName1 );  // CS:0
+                }
+            }
+        wgrp.Close();
+        }
+    
+    return ret;
+    }