|
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 <e32base.h> |
|
18 #include "AknExtendedFaderStartupWatcher.h" |
|
19 |
|
20 CAknExtendedFaderStartupWatcher::CAknExtendedFaderStartupWatcher(MAknExtendedFaderStartupObserver& aObserver) |
|
21 : CActive(EPriorityStandard), iObserver(aObserver) |
|
22 { |
|
23 } |
|
24 |
|
25 CAknExtendedFaderStartupWatcher::~CAknExtendedFaderStartupWatcher() |
|
26 { |
|
27 // Cancel active object notifications |
|
28 Cancel(); |
|
29 } |
|
30 |
|
31 CAknExtendedFaderStartupWatcher* CAknExtendedFaderStartupWatcher::NewL(MAknExtendedFaderStartupObserver& aObserver) |
|
32 { |
|
33 CAknExtendedFaderStartupWatcher* self = new (ELeave) CAknExtendedFaderStartupWatcher(aObserver); |
|
34 |
|
35 CleanupStack::PushL(self); |
|
36 self->ConstructL(); |
|
37 CleanupStack::Pop(); // self |
|
38 |
|
39 return self; |
|
40 } |
|
41 |
|
42 void CAknExtendedFaderStartupWatcher::ConstructL() |
|
43 { |
|
44 // Add AO to active scheduler |
|
45 CActiveScheduler::Add(this); |
|
46 |
|
47 // Attach & subscribe to startup property |
|
48 User::LeaveIfError(iProperty.Attach(KPSUidStartup, KPSGlobalSystemState)); |
|
49 iProperty.Subscribe(iStatus); |
|
50 |
|
51 // Set AO active |
|
52 SetActive(); |
|
53 |
|
54 // Get current value (if possible) and notify observer |
|
55 TInt value; |
|
56 if(iProperty.Get(value)==KErrNone) |
|
57 { |
|
58 iObserver.GlobalSystemStateChangedL(static_cast<TPSGlobalSystemState>(value)); |
|
59 } |
|
60 |
|
61 |
|
62 } |
|
63 |
|
64 void CAknExtendedFaderStartupWatcher::RunL() |
|
65 { |
|
66 if(iStatus==KErrNone) |
|
67 { |
|
68 TInt value; |
|
69 if(iProperty.Get(value)==KErrNone) |
|
70 { |
|
71 iObserver.GlobalSystemStateChangedL(static_cast<TPSGlobalSystemState>(value)); |
|
72 } |
|
73 } |
|
74 |
|
75 // Resubscribe |
|
76 iProperty.Subscribe(iStatus); |
|
77 SetActive(); |
|
78 } |
|
79 |
|
80 void CAknExtendedFaderStartupWatcher::DoCancel() |
|
81 { |
|
82 iProperty.Cancel(); |
|
83 } |