uifw/AvKon/src/AknTaskList.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     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 "AknTaskList.h"
       
    18 #include <apgwgnam.h>
       
    19 #include "AknPanic.h"
       
    20 
       
    21 EXPORT_C CAknTaskList* CAknTaskList::NewL(RWsSession& aWsSession)
       
    22 	{
       
    23 	CAknTaskList* self = NewLC(aWsSession);
       
    24 	CleanupStack::Pop(self);
       
    25 	return self;
       
    26 	}
       
    27 
       
    28 EXPORT_C CAknTaskList* CAknTaskList::NewLC(RWsSession& aWsSession)
       
    29 	{
       
    30 	CAknTaskList* self = new(ELeave) CAknTaskList(aWsSession);
       
    31 	CleanupStack::PushL(self);
       
    32 	self->ConstructL();
       
    33 	return self;
       
    34 	}
       
    35 
       
    36 CAknTaskList::CAknTaskList(RWsSession& aWsSession)
       
    37 : iWs(aWsSession)
       
    38 	{
       
    39 	}
       
    40 
       
    41 void CAknTaskList::ConstructL()
       
    42 	{
       
    43 	UpdateListL();
       
    44 	}
       
    45 
       
    46 EXPORT_C CAknTaskList::~CAknTaskList()
       
    47 	{
       
    48 	iWgs.Close();
       
    49 	}
       
    50 
       
    51 EXPORT_C void CAknTaskList::UpdateListL()
       
    52 	{
       
    53 	User::LeaveIfError(iWs.WindowGroupList(0, &iWgs));
       
    54 	}
       
    55 
       
    56 EXPORT_C const RArray<RWsSession::TWindowGroupChainInfo>& CAknTaskList::WgArray() const
       
    57 	{
       
    58 	return iWgs;
       
    59 	}
       
    60 
       
    61 EXPORT_C TApaTask CAknTaskList::FindRootApp(TUid aAppUid) const
       
    62 	{
       
    63 	TApaTask task(iWs);
       
    64 	task.SetWgId(0);		// initialise task to non-existant task
       
    65 	// wgId = 0 tells FindAppByUid to start looking for apps
       
    66 	TInt wgId=0;
       
    67 	FOREVER
       
    68 		{
       
    69 	 	CApaWindowGroupName::FindByAppUid(aAppUid, iWs, wgId);
       
    70 	 	// KErrNotFound means that no more apps can be found
       
    71 	 	if (wgId == KErrNotFound)
       
    72 	 		break;
       
    73 	 	if (IsRootWindowGroup(wgId))
       
    74 	 		{
       
    75 	 		// Found a root wg with the right app UID, return it.
       
    76 	 		task.SetWgId(wgId);
       
    77 	 		break;
       
    78 	 		}
       
    79 		}
       
    80 	return task;
       
    81 	}
       
    82 
       
    83 EXPORT_C TBool CAknTaskList::IsRootWindowGroup(TInt aWgId) const
       
    84 	{
       
    85 	TInt count = iWgs.Count();
       
    86 	for (TInt ii=0; ii<count; ii++)
       
    87 		{
       
    88         const RWsSession::TWindowGroupChainInfo& info = iWgs[ii];
       
    89         // find the window group id and check that it has no parent
       
    90         if (info.iId == aWgId)
       
    91         	return (info.iParentId <= 0);
       
    92 		}
       
    93 	return EFalse;
       
    94 	}
       
    95 
       
    96 EXPORT_C TInt CAknTaskList::FindParentWgId(TInt aWgId) const
       
    97 	{
       
    98 	TInt count = iWgs.Count();
       
    99 	for (TInt ii=0; ii<count; ii++)
       
   100 		{
       
   101         const RWsSession::TWindowGroupChainInfo& info = iWgs[ii];
       
   102         if (info.iId == aWgId && info.iParentId > 0 && info.iParentId != info.iId)
       
   103         	return info.iParentId;
       
   104 		}
       
   105 	return 0;
       
   106 	}
       
   107 
       
   108 EXPORT_C TInt CAknTaskList::FindChildWgId(TInt aWgId) const
       
   109 	{
       
   110 	TInt count = iWgs.Count();
       
   111 	for (TInt ii=0; ii<count; ii++)
       
   112 		{
       
   113         const RWsSession::TWindowGroupChainInfo& info = iWgs[ii];
       
   114         if (info.iParentId == aWgId && info.iId > 0 && info.iParentId != info.iId)
       
   115         	return info.iId;
       
   116 		}
       
   117 	return 0;
       
   118 	}
       
   119 
       
   120 
       
   121 
       
   122 
       
   123