|
1 /* |
|
2 * Copyright (c) 2007 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: Lock App internal state control |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "lockappstatecontrol.h" |
|
20 #include "lockappstatepublisher.h" |
|
21 #include "lockappkeyguardcontrol.h" |
|
22 #include "lockapputils.h" |
|
23 #include "lockappecsdetector.h" |
|
24 |
|
25 const TInt KLockAppObserverListGranularity = 4; |
|
26 |
|
27 // --------------------------------------------------------------------------- |
|
28 // Standard C++ constructor |
|
29 // --------------------------------------------------------------------------- |
|
30 CLockAppObserverList::CLockAppObserverList( ) |
|
31 { |
|
32 // no implementation required |
|
33 } |
|
34 |
|
35 // --------------------------------------------------------------------------- |
|
36 // Destroys the observer list and all existing observers. |
|
37 // --------------------------------------------------------------------------- |
|
38 CLockAppObserverList::~CLockAppObserverList( ) |
|
39 { |
|
40 if ( iObserverList ) |
|
41 { |
|
42 TInt count = iObserverList->Count( ); |
|
43 for (TInt index=0; index<count; index++ ) |
|
44 { |
|
45 delete (*iObserverList)[index]; |
|
46 } |
|
47 iObserverList->Reset( ); |
|
48 delete iObserverList; |
|
49 } |
|
50 } |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // Adds lock state observer to the observer list. |
|
54 // --------------------------------------------------------------------------- |
|
55 void CLockAppObserverList::AddObserverL( MLockAppStateObserver* aObserver ) |
|
56 { |
|
57 if ( aObserver ) |
|
58 { |
|
59 TBool found(EFalse); |
|
60 // check that the observer has not been added before |
|
61 TInt count = iObserverList->Count( ); |
|
62 for ( TInt index=0; index<count; index++ ) |
|
63 { |
|
64 if ( ((*iObserverList)[index]) == aObserver ) |
|
65 { |
|
66 found = ETrue; |
|
67 } |
|
68 } |
|
69 if ( !found ) |
|
70 { |
|
71 iObserverList->AppendL( aObserver ); |
|
72 } |
|
73 } |
|
74 } |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // Removes lock state observer from the observer list. |
|
78 // --------------------------------------------------------------------------- |
|
79 void CLockAppObserverList::RemoveObserver( MLockAppStateObserver* aObserver ) |
|
80 { |
|
81 if ( aObserver ) |
|
82 { |
|
83 TInt count = iObserverList->Count( ); |
|
84 for ( TInt index=0; index<count; index++ ) |
|
85 { |
|
86 if ( ((*iObserverList)[index]) == aObserver ) |
|
87 { |
|
88 iObserverList->Remove( index ); |
|
89 return; |
|
90 } |
|
91 } |
|
92 } |
|
93 } |
|
94 |
|
95 // --------------------------------------------------------------------------- |
|
96 // Constructs the observer list. |
|
97 // --------------------------------------------------------------------------- |
|
98 void CLockAppObserverList::BaseConstructL( ) |
|
99 { |
|
100 // create observer list |
|
101 iObserverList = new (ELeave) RPointerArray<MLockAppStateObserver>(KLockAppObserverListGranularity); |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------------------------- |
|
105 // Not implemented, meant for derived classes |
|
106 // --------------------------------------------------------------------------- |
|
107 void CLockAppObserverList::HandleLockStatusChangedL( TLockStatus /*aLockStatus*/) |
|
108 { |
|
109 } |
|
110 |
|
111 // --------------------------------------------------------------------------- |
|
112 // Informs observers that the lock state has changed. |
|
113 // --------------------------------------------------------------------------- |
|
114 void CLockAppObserverList::PostStatusChangeL( TLockStatus aStatusChange ) |
|
115 { |
|
116 // first inform the main control |
|
117 HandleLockStatusChangedL( aStatusChange ); |
|
118 |
|
119 // for child observers |
|
120 TInt count = iObserverList->Count( ); |
|
121 for ( TInt index=count-1; index>=0; index-- ) |
|
122 { |
|
123 //TRAP_IGNORE |
|
124 ((*iObserverList)[index])->HandleLockStatusChangedL( aStatusChange ); |
|
125 } |
|
126 } |