108 Server().DropSession(); |
109 Server().DropSession(); |
109 } |
110 } |
110 |
111 |
111 void CSisRegistryAccessSession::ServiceL(const RMessage2& aMessage) |
112 void CSisRegistryAccessSession::ServiceL(const RMessage2& aMessage) |
112 { |
113 { |
113 // create transaction on SCR for mutable operations |
114 TSisRegistryAccessMessages f = static_cast<TSisRegistryAccessMessages>(aMessage.Function()); |
114 Server().RegistrySession().CreateTransactionL(); |
115 TTime timer; |
115 // SWI regsitry needs a transaction to cover updates to logs during package add/update/removal |
116 StartTimer(timer); |
116 Usif::RStsSession stsSession; |
117 TInt err(0); |
117 TInt64 transactionID = stsSession.CreateTransactionL(); |
118 if(f == EAddAppRegInfo) |
118 CleanupClosePushL(stsSession); |
119 { |
119 TInt err(0); |
120 TUint regFileNameLen = aMessage.GetDesLengthL(0); |
120 |
121 HBufC* regFileName = HBufC::NewLC(regFileNameLen); |
121 TTime timer; |
122 TPtr namePtr = regFileName->Des(); |
122 StartTimer(timer); |
123 aMessage.ReadL(0, namePtr); |
123 |
124 TUid appUid = TUid::Uid(aMessage.Int1()); |
124 TSisRegistryAccessMessages f = static_cast<TSisRegistryAccessMessages>(aMessage.Function()); |
125 Swi::RSisRegistrySession sisRegistryWritableSession; |
125 switch (f) |
126 CleanupClosePushL(sisRegistryWritableSession); |
126 { |
127 TRAP(err, sisRegistryWritableSession.Connect()); |
127 case EAddEntry: |
128 TRAP(err, sisRegistryWritableSession.AddAppRegInfoL(*regFileName);); |
128 case EUpdateEntry: |
129 CleanupStack::PopAndDestroy(2, regFileName); |
129 { |
130 } |
130 TInt len = aMessage.GetDesLengthL(0); |
131 else if(f == ERemoveAppRegInfo) |
131 HBufC8 *controllerData = HBufC8::NewLC(len); |
132 { |
132 TPtr8 ptrControllerData(controllerData->Des()); |
133 TUint regFileNameLen = aMessage.GetDesLengthL(0); |
133 aMessage.ReadL(0, ptrControllerData); |
134 HBufC* regFileName = HBufC::NewLC(regFileNameLen); |
134 |
135 TPtr namePtr = regFileName->Des(); |
135 // create the controller |
136 aMessage.ReadL(0, namePtr); |
136 Swi::CDesDataProvider *desProvider = Swi::CDesDataProvider::NewLC(ptrControllerData); |
137 TUid appUid = TUid::Uid(aMessage.Int1()); |
137 Swi::Sis::CController *controller = Swi::Sis::CController::NewLC(*desProvider, Swi::Sis::EAssumeType); |
138 Swi::RSisRegistrySession sisRegistryWritableSession; |
138 // setup the application |
139 CleanupClosePushL(sisRegistryWritableSession); |
139 Swi::CApplication *app = Swi::CApplication::NewLC(); |
140 TRAP(err, sisRegistryWritableSession.Connect()); |
140 app->SetInstall(*controller); |
141 TRAP(err, sisRegistryWritableSession.RemoveAppRegInfoL(*regFileName);); |
141 // since the attributes chosen by the user don't have impact on the adding/updating entry tests, |
142 CleanupStack::PopAndDestroy(2, regFileName); |
142 // they are set with the constant values. |
143 } |
143 app->UserSelections().SetLanguage(ELangEnglish); |
144 else |
144 app->UserSelections().SetDrive(2); |
145 { |
145 |
146 // create transaction on SCR for mutable operations |
146 if(EAddEntry == f) |
147 Server().RegistrySession().CreateTransactionL(); |
147 { |
148 // SWI regsitry needs a transaction to cover updates to logs during package add/update/removal |
148 TRAP(err, Server().RegistrySession().AddEntryL(*app, ptrControllerData, transactionID)); |
149 Usif::RStsSession stsSession; |
149 } |
150 TInt64 transactionID = stsSession.CreateTransactionL(); |
150 else |
151 CleanupClosePushL(stsSession); |
151 { |
152 |
152 TRAP(err, Server().RegistrySession().UpdateEntryL(*app, ptrControllerData, transactionID)); |
153 switch (f) |
153 } |
154 { |
154 CleanupStack::PopAndDestroy(4, controllerData); // controllerData, desProvider, controller, app |
155 case EAddEntry: |
155 break; |
156 case EUpdateEntry: |
156 } |
157 { |
157 case EDeleteEntry: |
158 TInt len = aMessage.GetDesLengthL(0); |
158 { |
159 HBufC8 *controllerData = HBufC8::NewLC(len); |
159 // Get Uid and index |
160 TPtr8 ptrControllerData(controllerData->Des()); |
160 // Augmentation index - argument 0 |
161 aMessage.ReadL(0, ptrControllerData); |
161 TInt packageIndex = aMessage.Int0(); |
162 |
162 |
163 // create the controller |
163 // Uid (ipc argument 1) |
164 Swi::CDesDataProvider *desProvider = Swi::CDesDataProvider::NewLC(ptrControllerData); |
164 TUid uid; |
165 Swi::Sis::CController *controller = Swi::Sis::CController::NewLC(*desProvider, Swi::Sis::EAssumeType); |
165 TPckg<TUid> packageUid(uid); |
166 // setup the application |
166 aMessage.ReadL(1, packageUid); |
167 Swi::CApplication *app = Swi::CApplication::NewLC(); |
167 |
168 app->SetInstall(*controller); |
168 // Invoke SisRegistry server API using SisRegistryClient |
169 // since the attributes chosen by the user don't have impact on the adding/updating entry tests, |
169 Swi::CSisRegistryPackage* package = Swi::CSisRegistryPackage::NewLC(uid, KNullDesC, KNullDesC); // For the delete API, the name and the vendor of the package are irrelevant |
170 // they are set with the constant values. |
170 package->SetIndex(packageIndex); |
171 app->UserSelections().SetLanguage(ELangEnglish); |
171 TRAP(err, Server().RegistrySession().DeleteEntryL(*package, transactionID)); |
172 app->UserSelections().SetDrive(2); |
172 |
173 |
173 CleanupStack::PopAndDestroy(package); |
174 if(EAddEntry == f) |
174 break; |
175 { |
175 } |
176 TRAP(err, Server().RegistrySession().AddEntryL(*app, ptrControllerData, transactionID)); |
176 default: |
177 } |
177 { |
178 else |
178 PanicClient(aMessage, EPanicIllegalFunction); |
179 { |
179 break; |
180 TRAP(err, Server().RegistrySession().UpdateEntryL(*app, ptrControllerData, transactionID)); |
180 } |
181 } |
181 } |
182 CleanupStack::PopAndDestroy(4, controllerData); // controllerData, desProvider, controller, app |
182 |
183 break; |
183 stsSession.CommitL(); |
184 } |
184 CleanupStack::PopAndDestroy(&stsSession); |
185 case EDeleteEntry: |
185 |
186 { |
186 Server().RegistrySession().CommitTransactionL(); |
187 // Get Uid and index |
187 |
188 // Augmentation index - argument 0 |
|
189 TInt packageIndex = aMessage.Int0(); |
|
190 |
|
191 // Uid (ipc argument 1) |
|
192 TUid uid; |
|
193 TPckg<TUid> packageUid(uid); |
|
194 aMessage.ReadL(1, packageUid); |
|
195 |
|
196 // Invoke SisRegistry server API using SisRegistryClient |
|
197 Swi::CSisRegistryPackage* package = Swi::CSisRegistryPackage::NewLC(uid, KNullDesC, KNullDesC); // For the delete API, the name and the vendor of the package are irrelevant |
|
198 package->SetIndex(packageIndex); |
|
199 TRAP(err, Server().RegistrySession().DeleteEntryL(*package, transactionID)); |
|
200 |
|
201 CleanupStack::PopAndDestroy(package); |
|
202 break; |
|
203 } |
|
204 default: |
|
205 { |
|
206 PanicClient(aMessage, EPanicIllegalFunction); |
|
207 break; |
|
208 } |
|
209 } |
|
210 |
|
211 stsSession.CommitL(); |
|
212 CleanupStack::PopAndDestroy(&stsSession); |
|
213 Server().RegistrySession().CommitTransactionL(); |
|
214 } |
188 TPckg<TInt> timePckg(StopTimer(timer)); |
215 TPckg<TInt> timePckg(StopTimer(timer)); |
189 if(EDeleteEntry == f) |
216 if(EDeleteEntry == f) |
190 aMessage.WriteL(2, timePckg); |
217 aMessage.WriteL(2, timePckg); |
191 else |
218 else |
192 aMessage.WriteL(1, timePckg); |
219 aMessage.WriteL(1, timePckg); |