|
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: This checks for uninstallation (presently only for sisx uninstallation) or |
|
15 * removal of memory card. Whenever there is uninstallation the database has |
|
16 * to be updated for the parameters changes. |
|
17 * This depends Application installer & the SCPDatabase. |
|
18 * |
|
19 */ |
|
20 |
|
21 #include "SCPEventHandler.h" |
|
22 #include "SCPParamDBController.h" |
|
23 #include "SCPClient.h" |
|
24 #include "SCPServerInterface.h" |
|
25 #include "DmEventNotifierDebug.h" |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // CSCPEventHandler::CSCPEventHandler |
|
29 // C++ default constructor can NOT contain any code, that |
|
30 // might leave. |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 CSCPEventHandler::CSCPEventHandler() |
|
34 { |
|
35 } |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CSCPEventHandler::ConstructL |
|
39 // Symbian 2nd phase constructor can leave. |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 void CSCPEventHandler::ConstructL() |
|
43 { |
|
44 //No values to assign |
|
45 } |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CSCPEventHandler::NewL |
|
49 // Two-phased constructor. |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 EXPORT_C CSCPEventHandler* CSCPEventHandler::NewL() |
|
53 { |
|
54 |
|
55 CSCPEventHandler* self = NewLC(); |
|
56 CleanupStack::Pop(); |
|
57 |
|
58 return self; |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CSCPEventHandler::NewLC |
|
63 // Two-phased constructor. |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 EXPORT_C CSCPEventHandler* CSCPEventHandler::NewLC() |
|
67 { |
|
68 CSCPEventHandler* self = new( ELeave ) CSCPEventHandler(); |
|
69 |
|
70 CleanupStack::PushL( self ); |
|
71 self->ConstructL(); |
|
72 |
|
73 return self; |
|
74 } |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // Destructor |
|
78 // ----------------------------------------------------------------------------- |
|
79 CSCPEventHandler::~CSCPEventHandler() |
|
80 { |
|
81 } |
|
82 |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // NotifyChangesL |
|
86 // ----------------------------------------------------------------------------- |
|
87 EXPORT_C void CSCPEventHandler::NotifyChangesL(THandlerServiceId aEvent, THandlerOperation aOperation) |
|
88 { |
|
89 |
|
90 FLOG(_L("[CSCPEventHandler]-> started NotifyChangesL() aOperation=%d"), aOperation); |
|
91 |
|
92 if( (EOpnUninstall == aOperation) || (EOpnRemoved == aOperation)) |
|
93 { |
|
94 FLOG(_L("[CSCPEventHandler]-> EUninstallation == aOperation || EOpnRemoved == aOperation")); |
|
95 RArray <TUid> uids; |
|
96 CleanupClosePushL(uids); |
|
97 |
|
98 // Call database api & fill the uids |
|
99 CSCPParamDBController* dbObj = CSCPParamDBController::NewLC(); |
|
100 |
|
101 //calling...ListApplicationsL |
|
102 FLOG(_L("[CSCPEventHandler]-> ListApplicationsL started")); |
|
103 dbObj->ListApplicationsL(uids); |
|
104 CleanupStack :: PopAndDestroy(); // dbObj |
|
105 FLOG(_L("[CSCPEventHandler]-> ListApplicationsL ended")); |
|
106 FLOG(_L("[CSCPEventHandler]-> uids = %d"), uids.Count()); |
|
107 |
|
108 /* RArray <TUid> sisUids; |
|
109 CleanupClosePushL( sisUids );*/ |
|
110 |
|
111 //GetInstalledSisUidsL(sisUids); |
|
112 Swi::RSisRegistrySession sisses ; |
|
113 CleanupClosePushL( sisses ); |
|
114 User :: LeaveIfError(sisses.Connect()); |
|
115 |
|
116 //RArray <TUid> javaUids; |
|
117 //CleanupClosePushL( javaUids ); |
|
118 //GetInstalledJavaUidsL(javaUids); |
|
119 |
|
120 RArray <TUid> resultUids; |
|
121 CleanupClosePushL(resultUids); |
|
122 FLOG(_L("[CSCPEventHandler]-> Entering loop for each application, to check with AI")); |
|
123 |
|
124 for (int i=0; i < uids.Count(); i++) |
|
125 { |
|
126 FLOG(_L("[CSCPEventHandler]-> INFO: Checking case for UID %d"), uids[i].iUid); |
|
127 |
|
128 switch(uids[i].iUid) { |
|
129 case KNSmlDMHostServer1ID: |
|
130 case KNSmlDMHostServer2ID: |
|
131 case KNSmlDMHostServer3ID: |
|
132 case KNSmlDMHostServer4ID: |
|
133 FLOG(_L("[CSCPEventHandler]-> INFO: UID is marked as an exception, cleanup request bypassed...")); |
|
134 break; |
|
135 default: { |
|
136 Swi::RSisRegistryEntry sisEntry; |
|
137 //Opens the base package entry by specifying a UID. |
|
138 TInt lErr = sisEntry.Open(sisses, uids[i]); |
|
139 CleanupClosePushL(sisEntry); |
|
140 |
|
141 FLOG(_L("[CSCPEventHandler]-> INFO: lErr = %d"), lErr); |
|
142 |
|
143 //if(EFalse == isInstalledSis(uids[i], sisUids)) |
|
144 |
|
145 // If the application does not exist |
|
146 if( lErr != KErrNone || EFalse == sisEntry.IsPresentL()) |
|
147 { |
|
148 FLOG(_L("[CSCPEventHandler]-> INFO: UID %d was identified as uninstalled,\ |
|
149 performing cleanup on the same"), uids[i].iUid); |
|
150 // Does not exist in sis-registry, need to check in java registry |
|
151 //if(EFalse == isInstalledJava(uids[i], javaUids)) |
|
152 resultUids.Append(uids[i]); |
|
153 } |
|
154 |
|
155 CleanupStack :: PopAndDestroy(); // sisEntry |
|
156 } |
|
157 break; |
|
158 }; |
|
159 } // for uids |
|
160 |
|
161 //CleanupStack::PopAndDestroy( &sisUids ); // sisUids |
|
162 //CleanupStack::PopAndDestroy( &javaUids ); // javaUids |
|
163 FLOG(_L("[CSCPEventHandler]->NotifyChangesL(): Loop ended")); |
|
164 FLOG(_L("[CSCPEventHandler]-> resultUids = %d"), resultUids.Count()); |
|
165 |
|
166 if(resultUids.Count()) |
|
167 { |
|
168 NotifyCleanupL(resultUids); |
|
169 } |
|
170 CleanupStack :: PopAndDestroy(3); // resultUids, sisses, uids |
|
171 }// if (EUninstallation == aOperation) |
|
172 |
|
173 FLOG(_L("[CSCPEventHandler]-> end of NotifyChangesL()")); |
|
174 } |
|
175 |
|
176 /* |
|
177 void CSCPEventHandler::GetInstalledJavaUidsL(RArray<TUid>& aUids) |
|
178 { |
|
179 JavaRegistry* JavaRegistryEntry = NULL; |
|
180 |
|
181 JavaRegistryEntry = CJavaRegistry::NewL(); |
|
182 |
|
183 JavaRegistryEntry->GetRegistryEntryUidsL( aUids ); |
|
184 delete JavaRegistryEntry; |
|
185 JavaRegistryEntry = NULL; |
|
186 } |
|
187 */ |
|
188 |
|
189 /* |
|
190 // Check for application existance, return true is exists. |
|
191 inline TBool CSCPEventHandler::isInstalledJava(const TUid& aUid, const RArray<TUid>& aUids ) const |
|
192 { |
|
193 TBool found( EFalse ); |
|
194 TInt uidc( aUids.Count() ); |
|
195 for( TInt j( 0 ); found == EFalse && j < uidc; j++ ) |
|
196 { |
|
197 if( aUids[j] == aUid ) |
|
198 { |
|
199 found = ETrue; |
|
200 break; |
|
201 } |
|
202 } |
|
203 return found; |
|
204 } |
|
205 */ |
|
206 |
|
207 inline void CSCPEventHandler::NotifyCleanupL(RArray<TUid>& aUids) |
|
208 { |
|
209 FLOG(_L("[CSCPEventHandler:NotifyCleanupL]-> RSCPClient creation & connecting...")) |
|
210 RSCPClient lClient; |
|
211 CleanupClosePushL (lClient); |
|
212 User :: LeaveIfError(lClient.Connect()); |
|
213 |
|
214 FLOG(_L("[CSCPEventHandler]-> Initializing cleanup...")); |
|
215 //TRAPD(lErr, lClient.PerformCleanupL(ESCPApplicationUninstalled, aUids)); |
|
216 User :: LeaveIfError(lClient.PerformCleanupL(aUids)); |
|
217 CleanupStack :: PopAndDestroy(); // lClient |
|
218 FLOG(_L("[CSCPEventHandler]-> cleanup complete...")); |
|
219 FLOG(_L("[CSCPEventHandler:NotifyCleanupL]-> RSCPClient operation Completed...")) |
|
220 } |