|
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: ?Description |
|
15 * |
|
16 */ |
|
17 #include <e32property.h> |
|
18 #include <SWInstallerInternalPSKeys.h> |
|
19 #include <swi/sisregistrysession.h> |
|
20 #include <swi/sisregistryentry.h> |
|
21 #include <swi/sisregistrypackage.h> |
|
22 #include <javadomainpskeys.h> |
|
23 #include <javaregistry.h> |
|
24 #include <javaregistrypackageentry.h> |
|
25 #include <javaregistryapplicationentry.h> |
|
26 #include "mcsinstallstrategy.h" |
|
27 |
|
28 |
|
29 |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 CMcsNotifierStrategy::CMcsNotifierStrategy( |
|
35 RProperty& aProperty, MMcsInstallListener& aListener ) : |
|
36 iProperty( aProperty ), iListener( aListener ) |
|
37 { |
|
38 } |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 // --------------------------------------------------------------------------- |
|
43 // |
|
44 CMcsSwiInstallStrategy* CMcsSwiInstallStrategy::NewL( |
|
45 RProperty& aProperty, MMcsInstallListener& aListener ) |
|
46 { |
|
47 CMcsSwiInstallStrategy* self = new ( ELeave ) CMcsSwiInstallStrategy( |
|
48 aProperty, aListener ); |
|
49 CleanupStack::PushL( self ); |
|
50 self->ConstructL(); |
|
51 CleanupStack::Pop( self ); |
|
52 return self; |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 void CMcsSwiInstallStrategy::NotifyListenerL() |
|
60 { |
|
61 TInt appUid; |
|
62 User::LeaveIfError( iProperty.Get( KUidSystemCategory, |
|
63 KUidSwiLatestInstallation, appUid ) ); |
|
64 if( appUid ) |
|
65 { |
|
66 HandleInstallNotifyL( appUid ); |
|
67 } |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------- |
|
71 // |
|
72 // --------------------------------------------------------- |
|
73 // |
|
74 void CMcsSwiInstallStrategy::HandleInstallNotifyL( TInt aUid ) |
|
75 { |
|
76 Swi::RSisRegistrySession iSisRegSession; |
|
77 User::LeaveIfError( iSisRegSession.Connect() ); |
|
78 CleanupClosePushL( iSisRegSession ); |
|
79 |
|
80 // Open sis package entry related to aUid |
|
81 Swi::RSisRegistryEntry packageEntry; |
|
82 if( KErrNone == packageEntry.Open( iSisRegSession, TUid::Uid( aUid ) ) ) |
|
83 { |
|
84 CleanupClosePushL( packageEntry ); |
|
85 |
|
86 // Get packageEntry's embedded sis' |
|
87 RPointerArray<Swi::CSisRegistryPackage> embedded; |
|
88 CleanupClosePushL( embedded ); |
|
89 packageEntry.EmbeddedPackagesL( embedded ); |
|
90 if( embedded.Count() ) |
|
91 { |
|
92 // For each embadded sis we notify storage - recursive call |
|
93 for( TInt i = 0; i < embedded.Count(); ++i ) |
|
94 { |
|
95 iListener.HandleInstallNotifyL( embedded[i]->Uid(), |
|
96 CMcsInstallNotifier::ESisInstallNotification ); |
|
97 } |
|
98 } |
|
99 else |
|
100 { |
|
101 // There are no embaddes sis', so we can notify storage |
|
102 // of changes in apps included in packageEntry |
|
103 NotifyL( packageEntry ); |
|
104 } |
|
105 embedded.ResetAndDestroy(); |
|
106 CleanupStack::PopAndDestroy( &embedded ); |
|
107 CleanupStack::PopAndDestroy( &packageEntry ); |
|
108 } |
|
109 |
|
110 CleanupStack::PopAndDestroy( &iSisRegSession ); |
|
111 } |
|
112 |
|
113 // --------------------------------------------------------- |
|
114 // |
|
115 // --------------------------------------------------------- |
|
116 // |
|
117 void CMcsSwiInstallStrategy::NotifyL( Swi::RSisRegistryEntry & aPackageEntry ) |
|
118 { |
|
119 // Get sids ( == uids of exetucables included in aPackageEntry ) |
|
120 RArray<TUid> sids; |
|
121 CleanupClosePushL( sids ); |
|
122 aPackageEntry.SidsL( sids ); |
|
123 if( sids.Count() ) |
|
124 { |
|
125 // For each sid we notify storage |
|
126 for( TInt i = 0; i < sids.Count(); ++i ) |
|
127 { |
|
128 iListener.HandleInstallNotifyL( |
|
129 sids[i], CMcsInstallNotifier::ESisInstallNotification ); |
|
130 } |
|
131 } |
|
132 CleanupStack::PopAndDestroy( &sids ); |
|
133 } |
|
134 |
|
135 |
|
136 // --------------------------------------------------------------------------- |
|
137 // |
|
138 // --------------------------------------------------------------------------- |
|
139 // |
|
140 CMcsSwiInstallStrategy::CMcsSwiInstallStrategy( |
|
141 RProperty& aProperty, MMcsInstallListener& aListener ) |
|
142 : CMcsNotifierStrategy( aProperty, aListener ) |
|
143 { |
|
144 iProperty.Attach( KUidSystemCategory, KUidSwiLatestInstallation ); |
|
145 } |
|
146 |
|
147 // --------------------------------------------------------------------------- |
|
148 // |
|
149 // --------------------------------------------------------------------------- |
|
150 // |
|
151 void CMcsSwiInstallStrategy::ConstructL() |
|
152 { |
|
153 } |
|
154 |
|
155 // --------------------------------------------------------------------------- |
|
156 // |
|
157 // --------------------------------------------------------------------------- |
|
158 // |
|
159 CMcsJavaInstallStrategy* CMcsJavaInstallStrategy::NewL( |
|
160 RProperty& aProperty, MMcsInstallListener& aListener ) |
|
161 { |
|
162 CMcsJavaInstallStrategy* self = |
|
163 new ( ELeave ) CMcsJavaInstallStrategy( aProperty, aListener ); |
|
164 CleanupStack::PushL( self ); |
|
165 self->ConstructL(); |
|
166 CleanupStack::Pop( self ); |
|
167 return self; |
|
168 } |
|
169 |
|
170 // --------------------------------------------------------------------------- |
|
171 // |
|
172 // --------------------------------------------------------------------------- |
|
173 // |
|
174 void CMcsJavaInstallStrategy::NotifyListenerL() |
|
175 { |
|
176 TInt state; |
|
177 User::LeaveIfError( iProperty.Get( KUidSystemCategory, |
|
178 KPSUidJavaLatestInstallationState, state ) ); |
|
179 if( ( ( state & ESASwisInstall ) || ( state & ESASwisUninstall ) ) |
|
180 && ( state & ESASwisStatusSuccess ) ) |
|
181 { |
|
182 TInt appUid; |
|
183 User::LeaveIfError( iProperty.Get( KUidSystemCategory, |
|
184 KPSUidJavaLatestInstallation, appUid ) ); |
|
185 HandleInstallNotifyL( TUid::Uid( appUid ) ); |
|
186 } |
|
187 } |
|
188 |
|
189 // --------------------------------------------------------- |
|
190 // |
|
191 // --------------------------------------------------------- |
|
192 // |
|
193 void CMcsJavaInstallStrategy::HandleInstallNotifyL( TUid aPackageUid ) |
|
194 { |
|
195 RArray<TUid> uids; |
|
196 CleanupClosePushL( uids ); |
|
197 |
|
198 Java::CJavaRegistry* javaRegistry; |
|
199 javaRegistry = Java::CJavaRegistry::NewLC(); |
|
200 |
|
201 Java::CJavaRegistryEntry* regEntry = |
|
202 javaRegistry->RegistryEntryL( aPackageUid ); |
|
203 |
|
204 if( regEntry ) |
|
205 { |
|
206 CleanupStack::PushL( regEntry ); |
|
207 |
|
208 Java::TJavaRegistryEntryType entryType = regEntry->Type(); |
|
209 |
|
210 if ( ( entryType >= Java::EGeneralPackage ) && |
|
211 (entryType < Java::EGeneralApplication) ) |
|
212 { |
|
213 //package entry |
|
214 Java::CJavaRegistryPackageEntry* regPackageEntry = |
|
215 static_cast<Java::CJavaRegistryPackageEntry*>( regEntry ); |
|
216 regPackageEntry->GetEmbeddedEntries( uids ); |
|
217 } |
|
218 else |
|
219 { |
|
220 //application entry |
|
221 uids.AppendL( regEntry->Uid() ); |
|
222 } |
|
223 |
|
224 for ( TInt i = 0; i < uids.Count(); i++ ) |
|
225 { |
|
226 iListener.HandleInstallNotifyL( |
|
227 uids[i], CMcsInstallNotifier::EJavaInstallNotification ); |
|
228 } |
|
229 |
|
230 CleanupStack::PopAndDestroy( regEntry ); |
|
231 } |
|
232 else |
|
233 { |
|
234 iListener.HandleInstallNotifyL( |
|
235 TUid::Null(), CMcsInstallNotifier::EJavaInstallNotification ); |
|
236 } |
|
237 CleanupStack::PopAndDestroy( javaRegistry ); |
|
238 CleanupStack::PopAndDestroy( &uids ); |
|
239 } |
|
240 |
|
241 |
|
242 // --------------------------------------------------------------------------- |
|
243 // |
|
244 // --------------------------------------------------------------------------- |
|
245 // |
|
246 CMcsJavaInstallStrategy::CMcsJavaInstallStrategy( |
|
247 RProperty& aProperty, MMcsInstallListener& aListener ) |
|
248 : CMcsNotifierStrategy( aProperty, aListener ) |
|
249 { |
|
250 iProperty.Attach( KUidSystemCategory, KPSUidJavaLatestInstallationState ); |
|
251 } |
|
252 |
|
253 // --------------------------------------------------------------------------- |
|
254 // |
|
255 // --------------------------------------------------------------------------- |
|
256 // |
|
257 void CMcsJavaInstallStrategy::ConstructL() |
|
258 { |
|
259 } |
|
260 |