|
1 /* |
|
2 * Copyright (c) 2008 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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 #include<apgwgnam.h> |
|
19 |
|
20 #include"catasklist.h" |
|
21 |
|
22 CCaTaskList* CCaTaskList::NewL( RWsSession& aWsSession ) |
|
23 { |
|
24 CCaTaskList* self = NewLC( aWsSession ); |
|
25 CleanupStack::Pop( self ); |
|
26 return self; |
|
27 } |
|
28 |
|
29 CCaTaskList* CCaTaskList::NewLC( RWsSession& aWsSession ) |
|
30 { |
|
31 CCaTaskList* self = new(ELeave) CCaTaskList( aWsSession ); |
|
32 CleanupStack::PushL( self ); |
|
33 self->ConstructL(); |
|
34 return self; |
|
35 } |
|
36 |
|
37 CCaTaskList::CCaTaskList( RWsSession& aWsSession ) |
|
38 : iWs(aWsSession) |
|
39 { |
|
40 } |
|
41 |
|
42 void CCaTaskList::ConstructL() |
|
43 { |
|
44 UpdateListL(); |
|
45 } |
|
46 |
|
47 CCaTaskList::~CCaTaskList() |
|
48 { |
|
49 iWgs.Close(); |
|
50 } |
|
51 |
|
52 void CCaTaskList::UpdateListL() |
|
53 { |
|
54 User::LeaveIfError( iWs.WindowGroupList( &iWgs ) ); |
|
55 } |
|
56 |
|
57 |
|
58 TApaTask CCaTaskList::FindRootApp( TUid aAppUid ) const |
|
59 { |
|
60 TApaTask task( iWs ); |
|
61 task.SetWgId(0); // initialise task to non-existant task |
|
62 // wgId = 0 tells FindAppByUid to start looking for apps |
|
63 TInt wgId(0); |
|
64 FOREVER |
|
65 { |
|
66 CApaWindowGroupName::FindByAppUid( aAppUid, iWs, wgId ); |
|
67 // KErrNotFound means that no more apps can be found |
|
68 if( wgId == KErrNotFound ) |
|
69 break; |
|
70 if( IsRootWindowGroup( wgId ) ) |
|
71 { |
|
72 // Found a root wg with the right app UID, return it. |
|
73 task.SetWgId( wgId ); |
|
74 break; |
|
75 } |
|
76 } |
|
77 return task; |
|
78 } |
|
79 |
|
80 TBool CCaTaskList::IsRootWindowGroup( TInt aWgId ) const |
|
81 { |
|
82 TInt count = iWgs.Count(); |
|
83 for( TInt i=0; i<count; i++ ) |
|
84 { |
|
85 const RWsSession::TWindowGroupChainInfo& info = iWgs[i]; |
|
86 // find the window group id and check that it has no parent |
|
87 if ( info.iId == aWgId ) |
|
88 { |
|
89 return ( info.iParentId <= 0 ); |
|
90 } |
|
91 } |
|
92 return EFalse; |
|
93 } |