|
1 /* |
|
2 * Copyright (c) 2002 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 * Observer for phone events. Used to deactive/active the side-key |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #include <e32property.h> |
|
22 #include <PSVariables.h> |
|
23 #include <ctsydomainpskeys.h> |
|
24 #include "AutolockAppUiPS.h" |
|
25 #include "AutoLockValueObserverPS.h" |
|
26 #include <coreapplicationuisdomainpskeys.h> |
|
27 #include <startupdomainpskeys.h> |
|
28 |
|
29 // ================= MEMBER FUNCTIONS ======================= |
|
30 // |
|
31 // ---------------------------------------------------------- |
|
32 // CValueObserver::NewL() |
|
33 // Constructs a new entry with given values. |
|
34 // ---------------------------------------------------------- |
|
35 // |
|
36 CValueObserver* CValueObserver::NewL(CAutolockAppUi* aAppUi) |
|
37 { |
|
38 CValueObserver* self = new (ELeave) CValueObserver(aAppUi); |
|
39 CleanupStack::PushL(self); |
|
40 self->ConstructL(); |
|
41 CleanupStack::Pop(); |
|
42 return self; |
|
43 } |
|
44 // |
|
45 // ---------------------------------------------------------- |
|
46 // CValueObserver::CValueObserver() |
|
47 // Destructor |
|
48 // ---------------------------------------------------------- |
|
49 // |
|
50 CValueObserver::~CValueObserver() |
|
51 { |
|
52 Cancel(); |
|
53 } |
|
54 // |
|
55 // ---------------------------------------------------------- |
|
56 // CValueObserver::Start() |
|
57 // Starts listening KUidCurrentCall event |
|
58 // ---------------------------------------------------------- |
|
59 // |
|
60 TInt CValueObserver::Start() |
|
61 { |
|
62 if (IsActive()) |
|
63 return KErrInUse; |
|
64 iStatus = KRequestPending; |
|
65 iProperty.Attach(KPSUidCtsyCallInformation, KCTsyCallState); |
|
66 iProperty.Subscribe(iStatus); |
|
67 SetActive(); |
|
68 #if defined(_DEBUG) |
|
69 RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 ); |
|
70 #endif |
|
71 return KErrNone; |
|
72 } |
|
73 // |
|
74 // ---------------------------------------------------------- |
|
75 // CValueObserver::Stop() |
|
76 // Stops listening KUidCurrentCall event |
|
77 // ---------------------------------------------------------- |
|
78 // |
|
79 void CValueObserver::Stop() |
|
80 { |
|
81 #if defined(_DEBUG) |
|
82 RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 ); |
|
83 #endif |
|
84 Cancel(); |
|
85 } |
|
86 // |
|
87 // ---------------------------------------------------------- |
|
88 // CLockObserver::CLockObserver() |
|
89 // C++ constructor |
|
90 // ---------------------------------------------------------- |
|
91 // |
|
92 CValueObserver::CValueObserver(CAutolockAppUi* aAppUi) : CActive(0), iAppUi(aAppUi) |
|
93 { |
|
94 #if defined(_DEBUG) |
|
95 RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 ); |
|
96 #endif |
|
97 } |
|
98 // |
|
99 // ---------------------------------------------------------- |
|
100 // CLockObserver::ConstructL() |
|
101 // Symbian OS default constructor |
|
102 // ---------------------------------------------------------- |
|
103 // |
|
104 void CValueObserver::ConstructL() |
|
105 { |
|
106 // Add this active object to the scheduler. |
|
107 #if defined(_DEBUG) |
|
108 RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 ); |
|
109 #endif |
|
110 CActiveScheduler::Add(this); |
|
111 } |
|
112 // |
|
113 // ---------------------------------------------------------- |
|
114 // CValueObserver::RunL() |
|
115 // |
|
116 // ---------------------------------------------------------- |
|
117 // |
|
118 void CValueObserver::RunL() |
|
119 { |
|
120 #if defined(_DEBUG) |
|
121 RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 ); |
|
122 #endif |
|
123 TInt atForeground = iAppUi->IsForeground(); |
|
124 TInt value(EStartupUiPhaseUninitialized); |
|
125 RProperty::Get(KPSUidStartup, KPSStartupUiPhase, value); |
|
126 TInt callState; |
|
127 iProperty.Get( callState ); |
|
128 #if defined(_DEBUG) |
|
129 RDebug::Printf( "%s %s (%u) callState=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, callState ); |
|
130 RDebug::Printf( "%s %s (%u) EPSCTsyCallStateNone=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, EPSCTsyCallStateNone ); |
|
131 RDebug::Printf( "%s %s (%u) EPSCTsyCallStateUninitialized=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, EPSCTsyCallStateUninitialized ); |
|
132 RDebug::Printf( "%s %s (%u) atForeground=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, atForeground ); |
|
133 RDebug::Printf( "%s %s (%u) KPSStartupUiPhase value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, value ); |
|
134 RDebug::Printf( "%s %s (%u) EStartupUiPhaseSystemWelcomeDone=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, EStartupUiPhaseSystemWelcomeDone ); |
|
135 #endif |
|
136 |
|
137 |
|
138 if (callState == EPSCTsyCallStateNone && !atForeground) |
|
139 { |
|
140 if( value<EStartupUiPhaseSystemWelcomeDone ) |
|
141 { |
|
142 #if defined(_DEBUG) |
|
143 RDebug::Printf( "%s %s (%u) re-start=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 ); |
|
144 #endif |
|
145 Start(); |
|
146 } |
|
147 else |
|
148 { |
|
149 // app back to foreground |
|
150 TInt iAppUi_Locked = iAppUi->Locked(); |
|
151 TInt alocked = RProperty::Get(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, value); |
|
152 #if defined(_DEBUG) |
|
153 RDebug::Printf( "%s %s (%u) alocked=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, alocked ); |
|
154 RDebug::Printf( "%s %s (%u) iAppUi_Locked=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, iAppUi_Locked ); |
|
155 #endif |
|
156 if(iAppUi_Locked) |
|
157 { |
|
158 #if defined(_DEBUG) |
|
159 RDebug::Printf( "%s %s (%u) BringAppToForegroundL=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 ); |
|
160 #endif |
|
161 iAppUi->BringAppToForegroundL(); |
|
162 } |
|
163 } |
|
164 } |
|
165 else |
|
166 { |
|
167 { |
|
168 if( value<EStartupUiPhaseSystemWelcomeDone ) |
|
169 { |
|
170 #if defined(_DEBUG) |
|
171 RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 ); |
|
172 #endif |
|
173 if( callState != EPSCTsyCallStateNone && callState != EPSCTsyCallStateUninitialized && !atForeground) |
|
174 { |
|
175 #if defined(_DEBUG) |
|
176 RDebug::Printf( "%s %s (%u) 2=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 2 ); |
|
177 #endif |
|
178 iAppUi->BringAppToForegroundL(); |
|
179 } |
|
180 else if( (callState == EPSCTsyCallStateNone || callState == EPSCTsyCallStateUninitialized) && atForeground) |
|
181 { |
|
182 #if defined(_DEBUG) |
|
183 RDebug::Printf( "%s %s (%u) calling BringAppToForegroundL=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 ); |
|
184 #endif |
|
185 iAppUi->BringAppToForegroundL(); |
|
186 #if defined(_DEBUG) |
|
187 RDebug::Printf( "%s %s (%u) calling SwitchToPreviousAppL=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 2 ); |
|
188 #endif |
|
189 iAppUi->SwitchToPreviousAppL(); |
|
190 #if defined(_DEBUG) |
|
191 RDebug::Printf( "%s %s (%u) done=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 3 ); |
|
192 #endif |
|
193 } |
|
194 } |
|
195 } |
|
196 Start(); |
|
197 } |
|
198 |
|
199 } |
|
200 // |
|
201 // ---------------------------------------------------------- |
|
202 // CValueObserver::DoCancel() |
|
203 // Cancels event listening |
|
204 // ---------------------------------------------------------- |
|
205 // |
|
206 void CValueObserver::DoCancel() |
|
207 { |
|
208 iProperty.Cancel(); |
|
209 } |
|
210 |
|
211 // End of file |