|
1 // Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "ssastartupwatcher.h" |
|
17 |
|
18 /*! |
|
19 Factory function to create a new instance of the CSSAStartupWatcher |
|
20 \return new CSSAStartupWatcher object |
|
21 */ |
|
22 CSSAStartupWatcher* CSSAStartupWatcher::NewL(TStartupCallBack aCallback) |
|
23 { |
|
24 CSSAStartupWatcher* self = new (ELeave) CSSAStartupWatcher(KDmHierarchyIdStartup, |
|
25 KSM2AppServicesDomain3, aCallback); |
|
26 CleanupStack::PushL(self); |
|
27 self->ConstructL(); |
|
28 CleanupStack::Pop(self); |
|
29 return self; |
|
30 } |
|
31 |
|
32 /*! |
|
33 Factory function to create a new instance of the CSSAStartupWatcher |
|
34 \return new CSSAStartupWatcher object |
|
35 */ |
|
36 CSSAStartupWatcher* CSSAStartupWatcher::New(TStartupCallBack aCallback) |
|
37 { |
|
38 CSSAStartupWatcher* self = NULL; |
|
39 TRAP_IGNORE( self = NewL(aCallback); ); |
|
40 return self; |
|
41 } |
|
42 |
|
43 /*! |
|
44 Constructor of CWatcherSSAStartupMgr |
|
45 |
|
46 \param aHierarchyId The Id of the domain hierarchy to connect to |
|
47 \param aDomainId The Id of the domain to connect to |
|
48 */ |
|
49 CSSAStartupWatcher::CSSAStartupWatcher(TDmHierarchyId aHierarchyId, |
|
50 TDmDomainId aDomainId, TStartupCallBack aCallback) |
|
51 : CDmDomain(aHierarchyId,aDomainId), |
|
52 iCallback(aCallback) |
|
53 { |
|
54 } |
|
55 |
|
56 /*! |
|
57 Destructor |
|
58 */ |
|
59 CSSAStartupWatcher::~CSSAStartupWatcher() |
|
60 { |
|
61 Cancel(); |
|
62 } |
|
63 |
|
64 /** |
|
65 Second-stage constructor. |
|
66 |
|
67 This method indicates how the CWatcherSSAStartupMgr interacts with the |
|
68 Domain manager to keep aware of the startup state change. |
|
69 */ |
|
70 void CSSAStartupWatcher::ConstructL() |
|
71 { |
|
72 // Connect to the Domain Manager |
|
73 CDmDomain::ConstructL(); |
|
74 |
|
75 // Get the start-up state from the Domain Manager. |
|
76 TDmDomainState state = GetState(); |
|
77 |
|
78 // Something wrong with the Domain Manager |
|
79 if( state <= EStartupStateUndefined ) { |
|
80 User::Leave(KErrNotReady); |
|
81 } |
|
82 |
|
83 // Already passed the non critical state |
|
84 if( state >= EStartupStateNonCritical ) { |
|
85 NotifyState(state); |
|
86 } |
|
87 else { |
|
88 RequestTransitionNotification(); |
|
89 } |
|
90 } |
|
91 |
|
92 /*! |
|
93 Notify state change |
|
94 */ |
|
95 void CSSAStartupWatcher::NotifyState(TInt aValue) |
|
96 { |
|
97 (*iCallback)(aValue); |
|
98 } |
|
99 |
|
100 /*! |
|
101 Executed when the startup state change is done, it does the same thing |
|
102 as the method InitialiseL(). |
|
103 */ |
|
104 void CSSAStartupWatcher::RunL() |
|
105 { |
|
106 // Leave if our previous request to be notified a state change has |
|
107 // returned an error and let RunError handle this. |
|
108 if (iStatus.Int()!=KErrNone) { |
|
109 NotifyState( iStatus.Int() ); |
|
110 } |
|
111 else { |
|
112 // Get the start-up state from the Domain Manager. |
|
113 TDmDomainState state = GetState(); |
|
114 |
|
115 // Reached the non critical startup state |
|
116 if( state >= EStartupStateNonCritical ) { |
|
117 NotifyState(state); |
|
118 } |
|
119 else { |
|
120 AcknowledgeLastState(KErrNone); |
|
121 RequestTransitionNotification(); |
|
122 } |
|
123 } |
|
124 } |
|
125 |
|
126 // End of file |