27 |
27 |
28 #include "sislauncherclient.h" |
28 #include "sislauncherclient.h" |
29 #include "sislauncherclientserver.h" |
29 #include "sislauncherclientserver.h" |
30 #include "sisregistryfiledescription.h" |
30 #include "sisregistryfiledescription.h" |
31 #include "secutils.h" |
31 #include "secutils.h" |
|
32 |
32 #include "arrayutils.h" // from source/sisregistry/common/ |
33 #include "arrayutils.h" // from source/sisregistry/common/ |
33 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
34 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
34 #include "swtypereginfo.h" |
35 #include "swtypereginfo.h" |
35 #include "ipcutil.h" |
|
36 #endif |
36 #endif |
37 |
37 |
38 using namespace Swi; |
38 using namespace Swi; |
39 |
39 |
40 static TInt StartSisLauncherServer() |
40 static TInt StartSisLauncherServer() |
41 { |
41 { |
42 const TUidType serverUid(KNullUid, KNullUid, KServerUid3); |
42 const TUidType serverUid(KNullUid, KNullUid, KServerUid3); |
43 RProcess server; |
43 RProcess server; |
44 TInt err = server.Create(KSisLauncherServerImg, KNullDesC, serverUid); |
44 TInt err = server.Create(KSisLauncherServerImg, KNullDesC, serverUid); |
45 if (err != KErrNone) |
45 if (err != KErrNone) |
46 { |
46 { |
47 return err; |
47 return err; |
48 } |
48 } |
49 TRequestStatus stat; |
49 TRequestStatus stat; |
50 server.Rendezvous(stat); |
50 server.Rendezvous(stat); |
51 if (stat != KRequestPending) |
51 if (stat != KRequestPending) |
52 { |
52 { |
53 server.Kill(0); // abort startup |
53 server.Kill(0); // abort startup |
54 } |
54 } |
55 else |
55 else |
56 { |
56 { |
57 server.Resume(); // logon OK - start the server |
57 server.Resume(); // logon OK - start the server |
58 } |
58 } |
59 User::WaitForRequest(stat); // wait for start or death |
59 User::WaitForRequest(stat); // wait for start or death |
60 // we can't use the 'exit reason' if the server panicked as this |
60 // we can't use the 'exit reason' if the server panicked as this |
61 // is the panic 'reason' and may be '0' which cannot be distinguished |
61 // is the panic 'reason' and may be '0' which cannot be distinguished |
62 // from KErrNone |
62 // from KErrNone |
63 err = (server.ExitType() == EExitPanic) ? KErrGeneral : stat.Int(); |
63 err = (server.ExitType() == EExitPanic) ? KErrGeneral : stat.Int(); |
64 server.Close(); |
64 server.Close(); |
65 return err; |
65 return err; |
66 } |
66 } |
67 |
67 |
68 EXPORT_C TInt RSisLauncherSession::Connect() |
68 EXPORT_C TInt RSisLauncherSession::Connect() |
69 // |
69 // |
70 // Connect to the server, attempting to start it if necessary |
70 // Connect to the server, attempting to start it if necessary |
71 // |
71 // |
72 { |
72 { |
73 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
73 TInt retry=2; |
74 iBuffForLanguages = NULL; |
74 for (;;) |
75 #endif |
75 { |
76 |
76 TInt err = CreateSession(KSisLauncherServerName, TVersion(0, 0, 0), 1); |
77 TInt retry=2; |
77 if (err != KErrNotFound && err != KErrServerTerminated) |
78 for (;;) |
78 { |
79 { |
79 return err; |
80 TInt err = CreateSession(KSisLauncherServerName, TVersion(0, 0, 0), 1); |
80 } |
81 if (err != KErrNotFound && err != KErrServerTerminated) |
81 if (--retry==0) |
82 { |
82 { |
83 return err; |
83 return err; |
84 } |
84 } |
85 if (--retry==0) |
85 err = StartSisLauncherServer(); |
86 { |
86 if (err != KErrNone && err != KErrAlreadyExists) |
87 return err; |
87 { |
88 } |
88 return err; |
89 err = StartSisLauncherServer(); |
89 } |
90 if (err != KErrNone && err != KErrAlreadyExists) |
90 } |
91 { |
91 } |
92 return err; |
92 |
93 } |
93 EXPORT_C void RSisLauncherSession::RunExecutableL(const TDesC& aFileName, TBool aWait) |
94 } |
94 { |
95 } |
95 TPckgC<TBool> wait(aWait); |
|
96 User::LeaveIfError(SendReceive(ERunExecutable, TIpcArgs(&aFileName, &wait))); |
|
97 } |
|
98 |
|
99 EXPORT_C void RSisLauncherSession::StartDocumentL(RFile& aFile, TBool aWait) |
|
100 { |
|
101 TPckgC<TBool> wait(aWait); |
|
102 TIpcArgs ipcArgs; |
|
103 aFile.TransferToServer(ipcArgs, 0, 1); |
|
104 ipcArgs.Set(2, &wait); |
|
105 User::LeaveIfError(SendReceive(EStartDocumentByHandle, ipcArgs)); |
|
106 } |
|
107 |
|
108 EXPORT_C void RSisLauncherSession::StartByMimeL(RFile& aFile, const TDesC8& aMimeType, TBool aWait) |
|
109 { |
|
110 TPckgC<TBool> wait(aWait); |
|
111 TIpcArgs ipcArgs; |
|
112 aFile.TransferToServer(ipcArgs, 0, 1); |
|
113 ipcArgs.Set(2, &aMimeType); |
|
114 ipcArgs.Set(3, &wait); |
|
115 |
|
116 User::LeaveIfError(SendReceive(EStartByMimeByHandle, ipcArgs)); |
|
117 } |
|
118 |
|
119 EXPORT_C void RSisLauncherSession::StartDocumentL(const TDesC& aFileName, TBool aWait) |
|
120 { |
|
121 TPckgC<TBool> wait(aWait); |
|
122 User::LeaveIfError(SendReceive(EStartDocument, TIpcArgs(&aFileName, &wait))); |
|
123 } |
|
124 |
|
125 EXPORT_C void RSisLauncherSession::StartByMimeL(const TDesC& aFileName, const TDesC8& aMimeType, TBool aWait) |
|
126 { |
|
127 TPckgC<TBool> wait(aWait); |
|
128 User::LeaveIfError(SendReceive(EStartByMime, TIpcArgs(&aFileName, &aMimeType, &wait))); |
|
129 } |
|
130 |
|
131 EXPORT_C void RSisLauncherSession::ShutdownAllL() |
|
132 { |
|
133 User::LeaveIfError(SendReceive(EShutdownAll)); |
|
134 } |
|
135 |
|
136 EXPORT_C void RSisLauncherSession::CheckApplicationInUseL(RArray<TAppInUse>& aUidList) |
|
137 { |
|
138 TInt uidCount=aUidList.Count(); |
|
139 if (uidCount) |
|
140 { |
|
141 HBufC8* appInUseBuf=HBufC8::NewLC(uidCount * sizeof(TAppInUse)); |
|
142 TPtr8 appInUsePtr=appInUseBuf->Des(); |
|
143 TUint8* dataPtr(NULL); |
|
144 TInt i; |
|
145 for (i = 0 ; i < uidCount ; ++i) |
|
146 { |
|
147 dataPtr=reinterpret_cast<TUint8*>(&aUidList[i]); |
|
148 appInUsePtr.Append(dataPtr, sizeof(TAppInUse)); |
|
149 } |
|
150 User::LeaveIfError((SendReceive(ECheckApplicationInUse, TIpcArgs(&appInUsePtr)))); |
|
151 |
|
152 //Copy the result back to the RArray |
|
153 dataPtr=const_cast<TUint8*>(appInUsePtr.Ptr()); |
|
154 TAppInUse* appInUseDataPtr=reinterpret_cast<TAppInUse*>(dataPtr); |
|
155 for (i = 0; i < uidCount; ++i) |
|
156 { |
|
157 aUidList[i]=appInUseDataPtr[i]; |
|
158 } |
|
159 |
|
160 CleanupStack::PopAndDestroy(appInUseBuf); |
|
161 } |
|
162 } |
|
163 |
|
164 EXPORT_C void RSisLauncherSession::ShutdownL(const RArray<TUid>& aUidList, TInt aTimeout) |
|
165 { |
|
166 TInt uidCount=aUidList.Count(); |
|
167 if (uidCount) |
|
168 { |
|
169 HBufC8* tUidBuf=HBufC8::NewLC(uidCount * sizeof(TUid)); |
|
170 TPtr8 tUidBufPtr=tUidBuf->Des(); |
|
171 const TUint8* dataPtr(NULL); |
|
172 |
|
173 for (TInt i=0;i<uidCount;i++) |
|
174 { |
|
175 dataPtr=reinterpret_cast<const TUint8*>(&aUidList[i]); |
|
176 tUidBufPtr.Append(dataPtr, sizeof(TUid)); |
|
177 } |
|
178 User::LeaveIfError((SendReceive(EShutdown, TIpcArgs(&tUidBufPtr, aTimeout)))); |
|
179 CleanupStack::PopAndDestroy(tUidBuf); |
|
180 } |
|
181 } |
|
182 |
|
183 EXPORT_C void RSisLauncherSession::NotifyNewAppsL(const RPointerArray<TDesC>& aFiles) |
|
184 { |
|
185 if (aFiles.Count() > 0) |
|
186 { |
|
187 CBufFlat* tmpBuf = CBufFlat::NewL(255); |
|
188 CleanupStack::PushL(tmpBuf); |
|
189 |
|
190 RBufWriteStream stream(*tmpBuf); |
|
191 CleanupClosePushL(stream); |
|
192 |
|
193 ExternalizePointerArrayL(aFiles, stream); |
|
194 |
|
195 // Create an HBufC8 from the stream buf's length, and copy |
|
196 // the stream buffer into this descriptor |
|
197 HBufC8* buffer = HBufC8::NewLC(tmpBuf->Size()); |
|
198 TPtr8 ptr(buffer->Des()); |
|
199 tmpBuf->Read(0, ptr, tmpBuf->Size()); |
|
200 |
|
201 User::LeaveIfError(SendReceive(ENotifyNewApps, TIpcArgs(&ptr))); |
|
202 CleanupStack::PopAndDestroy(3, tmpBuf); |
|
203 } |
|
204 } |
|
205 |
|
206 EXPORT_C void RSisLauncherSession::RunAfterEcomNotificationL(const RPointerArray<CSisRegistryFileDescription>& aFileList) |
|
207 { |
|
208 TInt count = aFileList.Count(); |
|
209 if (count <= 0) |
|
210 { |
|
211 return; |
|
212 } |
|
213 |
|
214 RFs fs; |
|
215 User::LeaveIfError(fs.Connect()); |
|
216 CleanupClosePushL(fs); |
|
217 User::LeaveIfError(fs.ShareProtected()); |
|
218 |
|
219 for (TInt i = 0; i < count; ++i) |
|
220 { |
|
221 CSisRegistryFileDescription* fileDes = aFileList[i]; |
|
222 |
|
223 // open the file entry |
|
224 TEntry entry; |
|
225 if (fs.Entry(fileDes->Target(), entry) != KErrNone) |
|
226 { |
|
227 // just ignore, there's nothing we can do and we should try to process the |
|
228 // remaining files. |
|
229 continue; |
|
230 } |
|
231 |
|
232 TIpcArgs ipcArgs; |
|
233 TBool waitEnd = 0 != (fileDes->OperationOptions() & Sis::EInstFileRunOptionWaitEnd); |
|
234 TPckgC<TBool> wait(waitEnd); |
|
235 ipcArgs.Set(2, &wait); |
|
236 |
|
237 TInt err = KErrNone; |
|
238 |
|
239 if (entry.IsTypeValid() && SecUtils::IsExe(entry)) |
|
240 { |
|
241 ipcArgs.Set(0,&fileDes->Target()); |
|
242 err = SendReceive(EQueueRunExecutable, ipcArgs); |
|
243 } |
|
244 else |
|
245 { |
|
246 RFile file; |
|
247 CleanupClosePushL(file); |
|
248 err = file.Open(fs, fileDes->Target(), EFileShareExclusive|EFileWrite); |
|
249 |
|
250 HBufC8* mimeType = 0; |
|
251 |
|
252 if (err == KErrNone) |
|
253 { |
|
254 if (fileDes->OperationOptions() & Sis::EInstFileRunOptionByMimeType) |
|
255 { |
|
256 mimeType = HBufC8::NewLC(fileDes->MimeType().Length()); |
|
257 TPtr8 ptr = mimeType->Des(); |
|
258 ptr.Copy(fileDes->MimeType()); |
|
259 } |
|
260 |
|
261 if (file.TransferToServer(ipcArgs, 0, 1) != KErrNone) |
|
262 { |
|
263 // best effort is to continue with remaining exes |
|
264 } |
|
265 else if (mimeType != 0) |
|
266 { |
|
267 TPtrC8 x = mimeType->Des(); |
|
268 ipcArgs.Set(3, &x); |
|
269 err = SendReceive(EQueueStartByMimeByHandle, ipcArgs); |
|
270 } |
|
271 else |
|
272 { |
|
273 err = SendReceive(EQueueStartDocumentByHandle, ipcArgs); |
|
274 } |
|
275 if (mimeType != 0) |
|
276 { |
|
277 CleanupStack::PopAndDestroy(mimeType); |
|
278 } |
|
279 } |
|
280 CleanupStack::PopAndDestroy(&file); |
|
281 } |
|
282 // best effort is to continue with other exes in the event of an error |
|
283 // so do nothing here. |
|
284 } |
|
285 CleanupStack::PopAndDestroy(&fs); |
|
286 User::LeaveIfError(SendReceive(EExecuteQueue)); |
|
287 |
|
288 } |
|
289 |
96 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
290 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
97 EXPORT_C void RSisLauncherSession::Close() |
291 EXPORT_C void RSisLauncherSession::ParseSwTypeRegFileL(RFile& aFile, RPointerArray<CSoftwareTypeRegInfo>& aSwTypeRegInfoArray) |
98 { |
292 { |
99 if (iBuffForLanguages) |
293 // Pack the file handle |
100 { |
294 TIpcArgs ipcArgs; |
101 delete iBuffForLanguages; |
295 aFile.TransferToServer(ipcArgs, 0, 1); |
102 iBuffForLanguages = NULL; |
296 |
103 } |
297 // Allocate a buffer for the parsed registration info |
104 |
298 TInt bufLen = 0; |
105 RSessionBase::Close(); |
299 User::LeaveIfError(aFile.Size(bufLen)); |
106 } |
300 HBufC8* buf = HBufC8::NewLC(bufLen); // using the size of the file here is overhead but provides very simple code |
|
301 |
|
302 // Packe the buffer |
|
303 TPtr8 bufPtr(buf->Des()); |
|
304 ipcArgs.Set(2, &bufPtr); |
|
305 |
|
306 // Send request to the server |
|
307 User::LeaveIfError(SendReceive(EParseSwTypeRegFile, ipcArgs)); |
|
308 |
|
309 // Unpack the parsed registration info |
|
310 RDesReadStream rs(*buf); |
|
311 CleanupClosePushL(rs); |
|
312 SoftwareTypeRegInfoUtils::UnserializeArrayL(rs, aSwTypeRegInfoArray); |
|
313 |
|
314 CleanupStack::PopAndDestroy(2, buf); // rs |
|
315 } |
|
316 |
|
317 EXPORT_C void RSisLauncherSession::RegisterSifLauncherMimeTypesL(const RPointerArray<HBufC8>& aMimeTypes) |
|
318 { |
|
319 RegisterSifLauncherMimeTypesImplL(aMimeTypes, ETrue); |
|
320 } |
|
321 |
|
322 EXPORT_C void RSisLauncherSession::UnregisterSifLauncherMimeTypesL(const RPointerArray<HBufC8>& aMimeTypes) |
|
323 { |
|
324 RegisterSifLauncherMimeTypesImplL(aMimeTypes, EFalse); |
|
325 } |
|
326 |
|
327 void RSisLauncherSession::RegisterSifLauncherMimeTypesImplL(const RPointerArray<HBufC8>& aMimeTypes, TBool aRegister) |
|
328 { |
|
329 // Calculate the size of aMimeTypes in a buffer |
|
330 TInt bufLen = sizeof(TInt); |
|
331 for (TInt i=0; i<aMimeTypes.Count(); ++i) |
|
332 { |
|
333 bufLen += sizeof(TInt) + aMimeTypes[i]->Size(); |
|
334 } |
|
335 |
|
336 // Externalize MIME types |
|
337 HBufC8* buf = HBufC8::NewLC(bufLen); |
|
338 TPtr8 bufPtr(buf->Des()); |
|
339 |
|
340 RDesWriteStream ws(bufPtr); |
|
341 CleanupClosePushL(ws); |
|
342 |
|
343 ExternalizePointerArrayL(aMimeTypes, ws); |
|
344 |
|
345 ws.CommitL(); |
|
346 CleanupStack::PopAndDestroy(&ws); |
|
347 |
|
348 // Send MIME types to the server |
|
349 TIpcArgs ipcArgs(&bufPtr); |
|
350 User::LeaveIfError(SendReceive(aRegister?ERegisterSifLauncherMimeTypes:EUnregisterSifLauncherMimeTypes, ipcArgs)); |
|
351 |
|
352 CleanupStack::PopAndDestroy(buf); |
|
353 } |
107 #endif |
354 #endif |
108 EXPORT_C void RSisLauncherSession::RunExecutableL(const TDesC& aFileName, TBool aWait) |
|
109 { |
|
110 TPckgC<TBool> wait(aWait); |
|
111 User::LeaveIfError(SendReceive(ERunExecutable, TIpcArgs(&aFileName, &wait))); |
|
112 } |
|
113 |
|
114 EXPORT_C void RSisLauncherSession::StartDocumentL(RFile& aFile, TBool aWait) |
|
115 { |
|
116 TPckgC<TBool> wait(aWait); |
|
117 TIpcArgs ipcArgs; |
|
118 aFile.TransferToServer(ipcArgs, 0, 1); |
|
119 ipcArgs.Set(2, &wait); |
|
120 User::LeaveIfError(SendReceive(EStartDocumentByHandle, ipcArgs)); |
|
121 } |
|
122 |
|
123 EXPORT_C void RSisLauncherSession::StartByMimeL(RFile& aFile, const TDesC8& aMimeType, TBool aWait) |
|
124 { |
|
125 TPckgC<TBool> wait(aWait); |
|
126 TIpcArgs ipcArgs; |
|
127 aFile.TransferToServer(ipcArgs, 0, 1); |
|
128 ipcArgs.Set(2, &aMimeType); |
|
129 ipcArgs.Set(3, &wait); |
|
130 |
|
131 User::LeaveIfError(SendReceive(EStartByMimeByHandle, ipcArgs)); |
|
132 } |
|
133 |
|
134 EXPORT_C void RSisLauncherSession::StartDocumentL(const TDesC& aFileName, TBool aWait) |
|
135 { |
|
136 TPckgC<TBool> wait(aWait); |
|
137 User::LeaveIfError(SendReceive(EStartDocument, TIpcArgs(&aFileName, &wait))); |
|
138 } |
|
139 |
|
140 EXPORT_C void RSisLauncherSession::StartByMimeL(const TDesC& aFileName, const TDesC8& aMimeType, TBool aWait) |
|
141 { |
|
142 TPckgC<TBool> wait(aWait); |
|
143 User::LeaveIfError(SendReceive(EStartByMime, TIpcArgs(&aFileName, &aMimeType, &wait))); |
|
144 } |
|
145 |
|
146 EXPORT_C void RSisLauncherSession::ShutdownAllL() |
|
147 { |
|
148 User::LeaveIfError(SendReceive(EShutdownAll)); |
|
149 } |
|
150 |
|
151 EXPORT_C void RSisLauncherSession::CheckApplicationInUseL(RArray<TAppInUse>& aUidList) |
|
152 { |
|
153 TInt uidCount=aUidList.Count(); |
|
154 if (uidCount) |
|
155 { |
|
156 HBufC8* appInUseBuf=HBufC8::NewLC(uidCount * sizeof(TAppInUse)); |
|
157 TPtr8 appInUsePtr=appInUseBuf->Des(); |
|
158 TUint8* dataPtr(NULL); |
|
159 TInt i; |
|
160 for (i = 0 ; i < uidCount ; ++i) |
|
161 { |
|
162 dataPtr=reinterpret_cast<TUint8*>(&aUidList[i]); |
|
163 appInUsePtr.Append(dataPtr, sizeof(TAppInUse)); |
|
164 } |
|
165 User::LeaveIfError((SendReceive(ECheckApplicationInUse, TIpcArgs(&appInUsePtr)))); |
|
166 |
|
167 //Copy the result back to the RArray |
|
168 dataPtr=const_cast<TUint8*>(appInUsePtr.Ptr()); |
|
169 TAppInUse* appInUseDataPtr=reinterpret_cast<TAppInUse*>(dataPtr); |
|
170 for (i = 0; i < uidCount; ++i) |
|
171 { |
|
172 aUidList[i]=appInUseDataPtr[i]; |
|
173 } |
|
174 |
|
175 CleanupStack::PopAndDestroy(appInUseBuf); |
|
176 } |
|
177 } |
|
178 |
|
179 EXPORT_C void RSisLauncherSession::ShutdownL(const RArray<TUid>& aUidList, TInt aTimeout) |
|
180 { |
|
181 TInt uidCount=aUidList.Count(); |
|
182 if (uidCount) |
|
183 { |
|
184 HBufC8* tUidBuf=HBufC8::NewLC(uidCount * sizeof(TUid)); |
|
185 TPtr8 tUidBufPtr=tUidBuf->Des(); |
|
186 const TUint8* dataPtr(NULL); |
|
187 |
|
188 for (TInt i=0;i<uidCount;i++) |
|
189 { |
|
190 dataPtr=reinterpret_cast<const TUint8*>(&aUidList[i]); |
|
191 tUidBufPtr.Append(dataPtr, sizeof(TUid)); |
|
192 } |
|
193 User::LeaveIfError((SendReceive(EShutdown, TIpcArgs(&tUidBufPtr, aTimeout)))); |
|
194 CleanupStack::PopAndDestroy(tUidBuf); |
|
195 } |
|
196 } |
|
197 |
|
198 EXPORT_C void RSisLauncherSession::NotifyNewAppsL(const RPointerArray<TDesC>& aFiles) |
|
199 { |
|
200 if (aFiles.Count() > 0) |
|
201 { |
|
202 CBufFlat* tmpBuf = CBufFlat::NewL(255); |
|
203 CleanupStack::PushL(tmpBuf); |
|
204 |
|
205 RBufWriteStream stream(*tmpBuf); |
|
206 CleanupClosePushL(stream); |
|
207 |
|
208 ExternalizePointerArrayL(aFiles, stream); |
|
209 |
|
210 // Create an HBufC8 from the stream buf's length, and copy |
|
211 // the stream buffer into this descriptor |
|
212 HBufC8* buffer = HBufC8::NewLC(tmpBuf->Size()); |
|
213 TPtr8 ptr(buffer->Des()); |
|
214 tmpBuf->Read(0, ptr, tmpBuf->Size()); |
|
215 |
|
216 User::LeaveIfError(SendReceive(ENotifyNewApps, TIpcArgs(&ptr))); |
|
217 CleanupStack::PopAndDestroy(3, tmpBuf); |
|
218 } |
|
219 } |
|
220 |
|
221 EXPORT_C void RSisLauncherSession::RunAfterEcomNotificationL(const RPointerArray<CSisRegistryFileDescription>& aFileList) |
|
222 { |
|
223 TInt count = aFileList.Count(); |
|
224 if (count <= 0) |
|
225 { |
|
226 return; |
|
227 } |
|
228 |
|
229 RFs fs; |
|
230 User::LeaveIfError(fs.Connect()); |
|
231 CleanupClosePushL(fs); |
|
232 User::LeaveIfError(fs.ShareProtected()); |
|
233 |
|
234 for (TInt i = 0; i < count; ++i) |
|
235 { |
|
236 CSisRegistryFileDescription* fileDes = aFileList[i]; |
|
237 |
|
238 // open the file entry |
|
239 TEntry entry; |
|
240 if (fs.Entry(fileDes->Target(), entry) != KErrNone) |
|
241 { |
|
242 // just ignore, there's nothing we can do and we should try to process the |
|
243 // remaining files. |
|
244 continue; |
|
245 } |
|
246 |
|
247 TIpcArgs ipcArgs; |
|
248 TBool waitEnd = 0 != (fileDes->OperationOptions() & Sis::EInstFileRunOptionWaitEnd); |
|
249 TPckgC<TBool> wait(waitEnd); |
|
250 ipcArgs.Set(2, &wait); |
|
251 |
|
252 TInt err = KErrNone; |
|
253 |
|
254 if (entry.IsTypeValid() && SecUtils::IsExe(entry)) |
|
255 { |
|
256 ipcArgs.Set(0,&fileDes->Target()); |
|
257 err = SendReceive(EQueueRunExecutable, ipcArgs); |
|
258 } |
|
259 else |
|
260 { |
|
261 RFile file; |
|
262 CleanupClosePushL(file); |
|
263 err = file.Open(fs, fileDes->Target(), EFileShareExclusive|EFileWrite); |
|
264 |
|
265 HBufC8* mimeType = 0; |
|
266 |
|
267 if (err == KErrNone) |
|
268 { |
|
269 if (fileDes->OperationOptions() & Sis::EInstFileRunOptionByMimeType) |
|
270 { |
|
271 mimeType = HBufC8::NewLC(fileDes->MimeType().Length()); |
|
272 TPtr8 ptr = mimeType->Des(); |
|
273 ptr.Copy(fileDes->MimeType()); |
|
274 } |
|
275 |
|
276 if (file.TransferToServer(ipcArgs, 0, 1) != KErrNone) |
|
277 { |
|
278 // best effort is to continue with remaining exes |
|
279 } |
|
280 else if (mimeType != 0) |
|
281 { |
|
282 TPtrC8 x = mimeType->Des(); |
|
283 ipcArgs.Set(3, &x); |
|
284 err = SendReceive(EQueueStartByMimeByHandle, ipcArgs); |
|
285 } |
|
286 else |
|
287 { |
|
288 err = SendReceive(EQueueStartDocumentByHandle, ipcArgs); |
|
289 } |
|
290 if (mimeType != 0) |
|
291 { |
|
292 CleanupStack::PopAndDestroy(mimeType); |
|
293 } |
|
294 } |
|
295 CleanupStack::PopAndDestroy(&file); |
|
296 } |
|
297 // best effort is to continue with other exes in the event of an error |
|
298 // so do nothing here. |
|
299 } |
|
300 CleanupStack::PopAndDestroy(&fs); |
|
301 User::LeaveIfError(SendReceive(EExecuteQueue)); |
|
302 |
|
303 } |
|
304 |
|
305 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
306 EXPORT_C void RSisLauncherSession::ParseSwTypeRegFileL(RFile& aFile, RPointerArray<Usif::CSoftwareTypeRegInfo>& aSwTypeRegInfoArray) |
|
307 { |
|
308 // Pack the file handle |
|
309 TIpcArgs ipcArgs; |
|
310 aFile.TransferToServer(ipcArgs, 0, 1); |
|
311 |
|
312 // Allocate a buffer for the parsed registration info |
|
313 TInt bufLen = 0; |
|
314 User::LeaveIfError(aFile.Size(bufLen)); |
|
315 HBufC8* buf = HBufC8::NewLC(bufLen); // using the size of the file here is overhead but provides very simple code |
|
316 |
|
317 // Packe the buffer |
|
318 TPtr8 bufPtr(buf->Des()); |
|
319 ipcArgs.Set(2, &bufPtr); |
|
320 |
|
321 // Send request to the server |
|
322 User::LeaveIfError(SendReceive(EParseSwTypeRegFile, ipcArgs)); |
|
323 |
|
324 // Unpack the parsed registration info |
|
325 RDesReadStream rs(*buf); |
|
326 CleanupClosePushL(rs); |
|
327 SoftwareTypeRegInfoUtils::UnserializeArrayL(rs, aSwTypeRegInfoArray); |
|
328 |
|
329 CleanupStack::PopAndDestroy(2, buf); // rs |
|
330 } |
|
331 |
|
332 EXPORT_C void RSisLauncherSession::RegisterSifLauncherMimeTypesL(const RPointerArray<HBufC8>& aMimeTypes) |
|
333 { |
|
334 RegisterSifLauncherMimeTypesImplL(aMimeTypes, ETrue); |
|
335 } |
|
336 |
|
337 EXPORT_C void RSisLauncherSession::UnregisterSifLauncherMimeTypesL(const RPointerArray<HBufC8>& aMimeTypes) |
|
338 { |
|
339 RegisterSifLauncherMimeTypesImplL(aMimeTypes, EFalse); |
|
340 } |
|
341 |
|
342 void RSisLauncherSession::RegisterSifLauncherMimeTypesImplL(const RPointerArray<HBufC8>& aMimeTypes, TBool aRegister) |
|
343 { |
|
344 // Calculate the size of aMimeTypes in a buffer |
|
345 TInt bufLen = sizeof(TInt); |
|
346 for (TInt i=0; i<aMimeTypes.Count(); ++i) |
|
347 { |
|
348 bufLen += sizeof(TInt) + aMimeTypes[i]->Size(); |
|
349 } |
|
350 |
|
351 // Externalize MIME types |
|
352 HBufC8* buf = HBufC8::NewLC(bufLen); |
|
353 TPtr8 bufPtr(buf->Des()); |
|
354 |
|
355 RDesWriteStream ws(bufPtr); |
|
356 CleanupClosePushL(ws); |
|
357 |
|
358 ExternalizePointerArrayL(aMimeTypes, ws); |
|
359 |
|
360 ws.CommitL(); |
|
361 CleanupStack::PopAndDestroy(&ws); |
|
362 |
|
363 // Send MIME types to the server |
|
364 TIpcArgs ipcArgs(&bufPtr); |
|
365 User::LeaveIfError(SendReceive(aRegister?ERegisterSifLauncherMimeTypes:EUnregisterSifLauncherMimeTypes, ipcArgs)); |
|
366 |
|
367 CleanupStack::PopAndDestroy(buf); |
|
368 } |
|
369 |
|
370 EXPORT_C void RSisLauncherSession::AsyncParseResourceFileSizeL(const RFile& aRegistrationFile, const RArray<TLanguage>& aAppLanguages, TRequestStatus& aStatus) |
|
371 { |
|
372 TInt langCount = aAppLanguages.Count(); |
|
373 const TInt maxBufSize= sizeof(TInt) + langCount*sizeof(TLanguage); // Size(Number of entries) + (Number of entries)*(Size of Language Id) |
|
374 |
|
375 // Allocate buffer for the array |
|
376 if (iBuffForLanguages) |
|
377 { |
|
378 delete iBuffForLanguages; |
|
379 iBuffForLanguages = NULL; |
|
380 } |
|
381 iBuffForLanguages = HBufC8::NewMaxL(maxBufSize); |
|
382 TPtr8 ptrBufForLanguages = iBuffForLanguages->Des(); |
|
383 |
|
384 RDesWriteStream ins(ptrBufForLanguages); |
|
385 CleanupClosePushL(ins); |
|
386 ins.WriteInt32L(langCount); |
|
387 for (TInt i = 0; i < langCount; ++i) |
|
388 { |
|
389 ins.WriteInt32L((TInt)(aAppLanguages[i])); |
|
390 } |
|
391 |
|
392 ins.CommitL(); |
|
393 CleanupStack::PopAndDestroy(&ins); |
|
394 |
|
395 TIpcArgs args; |
|
396 aRegistrationFile.TransferToServer(args, 0, 1); |
|
397 args.Set(2,&ptrBufForLanguages); |
|
398 SendReceive(EAsyncParseResourceFileSize, args, aStatus); |
|
399 } |
|
400 |
|
401 EXPORT_C Usif::CApplicationRegistrationData* RSisLauncherSession::AsyncParseResourceFileDataL(TInt aDataSize) |
|
402 { |
|
403 HBufC8* appRegData=HBufC8::NewMaxLC(aDataSize); |
|
404 TPtr8 appRegDataDes = appRegData->Des(); |
|
405 TInt err=SendReceive(EAsyncParseResourceFileData, TIpcArgs(&appRegDataDes )); |
|
406 User::LeaveIfError(err); |
|
407 |
|
408 Usif::CApplicationRegistrationData* applicationData= Usif::CApplicationRegistrationData::NewLC(); |
|
409 // Got the buffer, internalise the arrays |
|
410 RDesReadStream readStream(*appRegData); |
|
411 CleanupClosePushL(readStream); |
|
412 applicationData->InternalizeL(readStream); |
|
413 CleanupStack::PopAndDestroy(&readStream); |
|
414 CleanupStack::Pop(applicationData); |
|
415 CleanupStack::PopAndDestroy(appRegData); |
|
416 if (iBuffForLanguages) |
|
417 { |
|
418 delete iBuffForLanguages; |
|
419 iBuffForLanguages = NULL; |
|
420 } |
|
421 return applicationData; |
|
422 } |
|
423 |
|
424 EXPORT_C Usif::CApplicationRegistrationData* RSisLauncherSession::SyncParseResourceFileL(const RFile& aRegistrationFile, const RArray<TLanguage>& aAppLanguages) |
|
425 { |
|
426 // Get the size of data |
|
427 TRequestStatus status; |
|
428 AsyncParseResourceFileSizeL (aRegistrationFile , aAppLanguages , status ); |
|
429 User::WaitForRequest(status); |
|
430 TInt size = status.Int(); |
|
431 if (size < KErrNone) |
|
432 { |
|
433 User::LeaveIfError(status.Int()); |
|
434 return NULL; |
|
435 } |
|
436 |
|
437 // Return the app reg data |
|
438 Usif::CApplicationRegistrationData* appRegData = AsyncParseResourceFileDataL(size); |
|
439 return appRegData; |
|
440 } |
|
441 |
|
442 |
|
443 EXPORT_C void RSisLauncherSession::NotifyNewAppsL(const RPointerArray<Usif::CApplicationRegistrationData>& aAppRegData) |
|
444 { |
|
445 if (aAppRegData.Count() > 0) |
|
446 { |
|
447 TInt bufLen = sizeof(TInt); |
|
448 const TInt appCount = aAppRegData.Count(); |
|
449 for (TInt i=0; i<appCount; ++i) |
|
450 { |
|
451 bufLen += GetObjectSizeL(aAppRegData[i]); |
|
452 } |
|
453 |
|
454 HBufC8* buffer = HBufC8::NewLC(bufLen); |
|
455 TPtr8 bufPtr(buffer->Des()); |
|
456 |
|
457 RDesWriteStream ws(bufPtr); |
|
458 CleanupClosePushL(ws); |
|
459 |
|
460 ws.WriteInt32L(appCount); |
|
461 for (TInt i=0; i<appCount; ++i) |
|
462 { |
|
463 const Usif::CApplicationRegistrationData& info = *aAppRegData[i]; |
|
464 ws << info; |
|
465 } |
|
466 ws.CommitL(); |
|
467 CleanupStack::PopAndDestroy(&ws); |
|
468 |
|
469 TIpcArgs ipcArgs(&bufPtr); |
|
470 User::LeaveIfError(SendReceive(ENotifyNewAppsData, ipcArgs)); |
|
471 |
|
472 CleanupStack::PopAndDestroy(buffer); |
|
473 } |
|
474 } |
|
475 |
|
476 |
|
477 EXPORT_C void RSisLauncherSession::NotifyNewAppsL(const RArray<TAppUpdateInfo>& aAppUpdateInfo) |
|
478 { |
|
479 TInt bufLen = sizeof(TInt); |
|
480 const TInt appCount = aAppUpdateInfo.Count(); |
|
481 for (TInt i=0; i<appCount; ++i) |
|
482 { |
|
483 bufLen += GetObjectSizeL(&aAppUpdateInfo[i]); |
|
484 } |
|
485 |
|
486 HBufC8* buffer = HBufC8::NewLC(bufLen); |
|
487 TPtr8 bufPtr(buffer->Des()); |
|
488 |
|
489 RDesWriteStream ws(bufPtr); |
|
490 CleanupClosePushL(ws); |
|
491 |
|
492 ws.WriteInt32L(appCount); |
|
493 for (TInt i=0; i<appCount; ++i) |
|
494 { |
|
495 const TAppUpdateInfo& info = aAppUpdateInfo[i]; |
|
496 ws << info; |
|
497 } |
|
498 ws.CommitL(); |
|
499 CleanupStack::PopAndDestroy(&ws); |
|
500 |
|
501 TIpcArgs ipcArgs(&bufPtr); |
|
502 User::LeaveIfError(SendReceive(ENotifyApparcForApps, ipcArgs)); |
|
503 |
|
504 CleanupStack::PopAndDestroy(buffer); |
|
505 } |
|
506 |
|
507 EXPORT_C TAppUpdateInfo::TAppUpdateInfo() |
|
508 { |
|
509 } |
|
510 |
|
511 EXPORT_C TAppUpdateInfo::TAppUpdateInfo(TUid aAppUid, InstallActions aAction) |
|
512 { |
|
513 iAppUid = aAppUid; |
|
514 iAction = aAction; |
|
515 } |
|
516 |
|
517 EXPORT_C void TAppUpdateInfo::InternalizeL(RReadStream& aReadStream) |
|
518 { |
|
519 iAppUid = TUid::Uid(aReadStream.ReadUint32L()); |
|
520 iAction = (Swi::InstallActions)aReadStream.ReadUint32L(); |
|
521 } |
|
522 |
|
523 EXPORT_C void TAppUpdateInfo::ExternalizeL(RWriteStream& aWriteStream) const |
|
524 { |
|
525 aWriteStream.WriteUint32L(iAppUid.iUid); |
|
526 aWriteStream.WriteInt32L(iAction); |
|
527 } |
|
528 |
|
529 #endif |
|