|
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: This module contains the implementation of CIAUpdateRefreshHandler class |
|
15 * member functions. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 //INCLUDES |
|
21 #include <e32property.h> |
|
22 #include <apgwgnam.h> |
|
23 |
|
24 #include "iaupdaterefreshhandler.h" |
|
25 #include "iaupdaterefreshobserver.h" |
|
26 #include "iaupdateinstallationlistener.h" |
|
27 #include "iaupdateuids.h" |
|
28 #include "iaupdatedebug.h" |
|
29 |
|
30 //CONSTANTS |
|
31 const TUid KPSUid = { KIAUpdateUiUid }; |
|
32 const TUint32 KIAUpdateUiRefresh = 0x00000002; |
|
33 const TUid KSid = { KIAUpdateUiUid }; |
|
34 |
|
35 //MACROS |
|
36 _LIT_SECURITY_POLICY_PASS( KReadPolicy ); |
|
37 _LIT_SECURITY_POLICY_S0( KWritePolicy, (TSecureId ) KSid ); |
|
38 |
|
39 |
|
40 // ================= MEMBER FUNCTIONS ======================= |
|
41 |
|
42 // --------------------------------------------------------------------------- |
|
43 // CIAUpdateRefreshHandler::NewL |
|
44 // Two-phased constructor. |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 CIAUpdateRefreshHandler* CIAUpdateRefreshHandler::NewL() |
|
48 { |
|
49 CIAUpdateRefreshHandler* self = CIAUpdateRefreshHandler::NewLC(); |
|
50 CleanupStack::Pop( self ); |
|
51 return self; |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CIAUpdateRefreshHandler::NewLC |
|
56 // Two-phased constructor. |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 CIAUpdateRefreshHandler* CIAUpdateRefreshHandler::NewLC() |
|
60 { |
|
61 CIAUpdateRefreshHandler* self = new( ELeave ) CIAUpdateRefreshHandler(); |
|
62 CleanupStack::PushL( self ); |
|
63 self->ConstructL(); |
|
64 return self; |
|
65 } |
|
66 |
|
67 |
|
68 |
|
69 // --------------------------------------------------------------------------- |
|
70 // CIAUpdateRefreshHandler::ConstructL |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 void CIAUpdateRefreshHandler::ConstructL() |
|
74 { |
|
75 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateRefreshHandler::ConstructL() begin"); |
|
76 CActiveScheduler::Add( this ); |
|
77 TInt err = RProperty::Define( KPSUid, |
|
78 KIAUpdateUiRefresh, |
|
79 RProperty::EInt, |
|
80 KReadPolicy, |
|
81 KWritePolicy ); |
|
82 if ( err != KErrAlreadyExists ) |
|
83 { |
|
84 User::LeaveIfError( err ); |
|
85 } |
|
86 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateRefreshHandler::ConstructL() end"); |
|
87 } |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // CIAUpdateRefreshHandler::CIAUpdateRefreshHandler |
|
91 // constructor |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 CIAUpdateRefreshHandler::CIAUpdateRefreshHandler() |
|
95 : CActive( CActive::EPriorityStandard ) |
|
96 { |
|
97 iEikEnv = CEikonEnv::Static(); |
|
98 } |
|
99 |
|
100 // --------------------------------------------------------------------------- |
|
101 // CIAUpdateRefreshHandler::~CIAUpdateRefreshHandler |
|
102 // Destructor |
|
103 // --------------------------------------------------------------------------- |
|
104 // |
|
105 CIAUpdateRefreshHandler::~CIAUpdateRefreshHandler() |
|
106 { |
|
107 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateRefreshHandler::~CIAUpdateRefreshHandler() begin"); |
|
108 |
|
109 Cancel(); |
|
110 iProperty.Close(); |
|
111 delete iInstallationListener; |
|
112 |
|
113 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateRefreshHandler::~CIAUpdateRefreshHandler() end"); |
|
114 } |
|
115 |
|
116 |
|
117 // --------------------------------------------------------------------------- |
|
118 // CIAUpdateRefreshHandler::InformRefreshL() |
|
119 // |
|
120 // --------------------------------------------------------------------------- |
|
121 // |
|
122 void CIAUpdateRefreshHandler::InformRefreshL() |
|
123 { |
|
124 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateRefreshHandler::InformRefreshL() begin"); |
|
125 TInt wgId = iEikEnv->RootWin().Identifier(); |
|
126 User::LeaveIfError( RProperty::Set( KPSUid, |
|
127 KIAUpdateUiRefresh, |
|
128 wgId ) ); |
|
129 |
|
130 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateRefreshHandler::InformRefreshL() end"); |
|
131 } |
|
132 |
|
133 // --------------------------------------------------------------------------- |
|
134 // CIAUpdateRefreshHandler::StartListeningL() |
|
135 // |
|
136 // --------------------------------------------------------------------------- |
|
137 // |
|
138 void CIAUpdateRefreshHandler::StartListeningL( MIAUpdateRefreshObserver* aObserver ) |
|
139 { |
|
140 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateRefreshHandler::StartListeningL() begin"); |
|
141 |
|
142 if ( !iObserver ) |
|
143 { |
|
144 iObserver = aObserver; |
|
145 User::LeaveIfError( iProperty.Attach( KPSUid, KIAUpdateUiRefresh ) ); |
|
146 } |
|
147 |
|
148 Cancel(); |
|
149 iProperty.Subscribe( iStatus ); |
|
150 SetActive(); |
|
151 |
|
152 if ( !iInstallationListener ) |
|
153 { |
|
154 iInstallationListener = CIAUpdateInstallationListener::NewL(); |
|
155 } |
|
156 iInstallationListener->StartListeningL( aObserver ); |
|
157 |
|
158 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateRefreshHandler::StartListeningL() end"); |
|
159 } |
|
160 |
|
161 // ----------------------------------------------------------------------------- |
|
162 // CIAUpdateRefreshHandler::DoCancel |
|
163 // |
|
164 // ----------------------------------------------------------------------------- |
|
165 // |
|
166 void CIAUpdateRefreshHandler::DoCancel() |
|
167 { |
|
168 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateRefreshHandler::DoCancel() begin"); |
|
169 |
|
170 iProperty.Cancel(); |
|
171 |
|
172 |
|
173 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateRefreshHandler::DoCancel() end"); |
|
174 } |
|
175 |
|
176 // ----------------------------------------------------------------------------- |
|
177 // CIAUpdateRefreshHandler::RunL |
|
178 // |
|
179 // ----------------------------------------------------------------------------- |
|
180 // |
|
181 void CIAUpdateRefreshHandler::RunL() |
|
182 { |
|
183 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateRefreshHandler::RunL() begin"); |
|
184 iProperty.Subscribe( iStatus ); |
|
185 SetActive(); |
|
186 TInt wgId = 0; |
|
187 User::LeaveIfError( RProperty::Get( KPSUid, |
|
188 KIAUpdateUiRefresh, |
|
189 wgId ) ); |
|
190 if ( wgId != iEikEnv->RootWin().Identifier() ) |
|
191 { |
|
192 // only requests from other IAD instances are handled |
|
193 iObserver->HandleUiRefreshL(); |
|
194 } |
|
195 |
|
196 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateRefreshHandler::RunL() end"); |
|
197 } |
|
198 |
|
199 |
|
200 // ----------------------------------------------------------------------------- |
|
201 // CIAUpdateRefreshHandler::RunError |
|
202 // |
|
203 // ----------------------------------------------------------------------------- |
|
204 // |
|
205 TInt CIAUpdateRefreshHandler::RunError( TInt aError ) |
|
206 { |
|
207 IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateRefreshHandler::RunError() error id: %d", aError ); |
|
208 return KErrNone; |
|
209 } |
|
210 |
|
211 // End of File |