|
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Symbian Foundation License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "../apserv/APSCLSV.H" |
|
17 #include "APGCLI.H" |
|
18 #include "APACMDLN.H" |
|
19 #include "APGSTD.H" |
|
20 #include "APGICNFL.H" |
|
21 #include <apsserv.h> |
|
22 #include <apmrec.h> |
|
23 #include <s32mem.h> |
|
24 #include "APGPRIV.H" |
|
25 #include <apadef.h> |
|
26 #include "apprivate.h" |
|
27 |
|
28 #if defined(USE_IH_RAISE_EVENT) |
|
29 #include <SystemMonitor/RaiseEvent.h> |
|
30 #include <test/testinstrumentation.h> |
|
31 #endif |
|
32 |
|
33 class CApaLsSessionExtension; |
|
34 |
|
35 const TUint KInitialIconBufSize=sizeof(TSize)*6+sizeof(TInt); |
|
36 const TUint KInitialViewDataBufSize=sizeof(TApaAppViewInfo)*6+sizeof(TInt); |
|
37 const TUint KInitialOwnedFilesBufSize=sizeof(TFileName)*6+sizeof(TInt); |
|
38 const TUint KDefaultBufSize = 0x400; |
|
39 const TUint KAsyncMessageSlots=4; //one slot each for, RApaLsSession::SetNotify, RApaLsSession:: |
|
40 //RegisterListPopulationCompleteObserver and RApaLsSession::NotifyOnDataMappingChange |
|
41 //CAsyncFileRecognition::Start makes an asynch request of apparc server. |
|
42 |
|
43 _LIT8(KAllDataTypes,"*"); |
|
44 |
|
45 extern void CleanupServiceArray(TAny* aServiceArray); |
|
46 |
|
47 IMPORT_C extern const TInt KMinApplicationStackSize; |
|
48 |
|
49 class MArrayFiller |
|
50 { |
|
51 public: |
|
52 virtual void AppendItemL(RReadStream& aReadStream)=0; |
|
53 }; |
|
54 |
|
55 class TSizeArrayFiller : public MArrayFiller |
|
56 { |
|
57 public: |
|
58 inline TSizeArrayFiller(CArrayFixFlat<TSize>& aArray) :iArray(aArray) {} |
|
59 virtual void AppendItemL(RReadStream& aReadStream); |
|
60 private: |
|
61 CArrayFixFlat<TSize>& iArray; |
|
62 }; |
|
63 |
|
64 class TViewDataArrayFiller : public MArrayFiller |
|
65 { |
|
66 public: |
|
67 inline TViewDataArrayFiller(CApaAppViewArray& aArray) :iArray(aArray) {} |
|
68 virtual void AppendItemL(RReadStream& aReadStream); |
|
69 private: |
|
70 CApaAppViewArray& iArray; |
|
71 }; |
|
72 |
|
73 class TDesCArrayFiller : public MArrayFiller |
|
74 { |
|
75 public: |
|
76 inline TDesCArrayFiller(CDesCArray& aArray) :iArray(aArray) {} |
|
77 virtual void AppendItemL(RReadStream& aReadStream); |
|
78 private: |
|
79 CDesCArray& iArray; |
|
80 }; |
|
81 |
|
82 /** |
|
83 This class is used to simplify the usage of the asynchronous RApaLsSession::RecognizeFilesL() function. |
|
84 @internalComponent |
|
85 */ |
|
86 class CAsyncFileRecognition : public CActive |
|
87 { |
|
88 public: |
|
89 CAsyncFileRecognition(CDataRecognitionResultArray& aResult, TRequestStatus& aUsersRequestStatus, CApaLsSessionExtension& aSession); |
|
90 ~CAsyncFileRecognition(); |
|
91 void Start(const TDesC& aPath, const TDesC8& aDataType); |
|
92 private: |
|
93 void RunL(); |
|
94 void DoCancel(); |
|
95 private: // data |
|
96 TPckgBuf<TUint> iRequiredBufferSizePckg; |
|
97 CDataRecognitionResultArray& iResult; |
|
98 TRequestStatus& iUsersRequestStatus; |
|
99 CApaLsSessionExtension& iSession; |
|
100 const TDesC* iPath; |
|
101 const TDesC8* iDataType; |
|
102 }; |
|
103 |
|
104 /** |
|
105 This class is an extension class for RApaLsSession. It was added to reduce the need |
|
106 of BC breaks in later releases. |
|
107 @internalComponent |
|
108 */ |
|
109 class CApaLsSessionExtension : public CBase |
|
110 { |
|
111 public: |
|
112 CApaLsSessionExtension(RApaLsSession& aSession); |
|
113 ~CApaLsSessionExtension(); |
|
114 |
|
115 void SendReceive(TInt aFunction,const TIpcArgs& aArgs,TRequestStatus& aStatus) const; |
|
116 TInt SendReceive(TInt aFunction,const TIpcArgs& aArgs) const; |
|
117 |
|
118 // file recognition functions |
|
119 void RecognizeFilesL(const TDesC& aPath, const TDesC8& aDataType, CDataRecognitionResultArray& aResult, TRequestStatus& aStatus); |
|
120 void CancelRecognizeFiles(); |
|
121 void FilesRecognized(const TDesC& aPath, TInt aRequiredBufferSize, CDataRecognitionResultArray& aResult, TRequestStatus& aUsersRequestStatus, const TRequestStatus& aErrorCode); |
|
122 TBool RecognitionActive() const; |
|
123 private: |
|
124 RApaLsSession& iSession; // we are a friend of this class! |
|
125 CAsyncFileRecognition* iAsyncFileRecognition; |
|
126 }; |
|
127 |
|
128 /** |
|
129 An entry of a CDataRecognitionResultArray object. Stores TDataRecognitionResult and the file name |
|
130 in a compact format. |
|
131 @internalComponent |
|
132 */ |
|
133 class CDataRecognitionResultArrayEntry : public CBase |
|
134 { |
|
135 public: |
|
136 CDataRecognitionResultArrayEntry(HBufC* aFileName, HBufC8* aDataType, TUid aUid, TInt aConfidence); |
|
137 ~CDataRecognitionResultArrayEntry(); |
|
138 void GetDataRecognitionResult(TDataRecognitionResult& aResult) const; |
|
139 const TDesC& FileName() const; |
|
140 private: |
|
141 HBufC* iFileName; |
|
142 HBufC8* iDataType; |
|
143 TUid iUid; |
|
144 TInt iConfidence; |
|
145 }; |
|
146 |
|
147 ////////////////////////////// |
|
148 // CAsyncFileRecognition |
|
149 ////////////////////////////// |
|
150 |
|
151 CAsyncFileRecognition::CAsyncFileRecognition(CDataRecognitionResultArray& aResult, TRequestStatus& aUsersRequestStatus, CApaLsSessionExtension& aSession) |
|
152 : CActive(EPriorityStandard), |
|
153 iResult(aResult), |
|
154 iUsersRequestStatus(aUsersRequestStatus), |
|
155 iSession(aSession) |
|
156 { |
|
157 CActiveScheduler::Add(this); |
|
158 } |
|
159 |
|
160 void CAsyncFileRecognition::Start(const TDesC& aPath, const TDesC8& aDataType) |
|
161 { |
|
162 iPath = &aPath; |
|
163 iDataType = &aDataType; |
|
164 iStatus = KRequestPending; |
|
165 iSession.SendReceive(EAppListServRecognizeFilesAsync,TIpcArgs(&aPath,&iRequiredBufferSizePckg,&aDataType),iStatus); |
|
166 SetActive(); |
|
167 } |
|
168 |
|
169 CAsyncFileRecognition::~CAsyncFileRecognition() |
|
170 { |
|
171 Cancel(); |
|
172 iPath = NULL; |
|
173 iDataType = NULL; |
|
174 } |
|
175 |
|
176 void CAsyncFileRecognition::RunL() |
|
177 { |
|
178 iSession.FilesRecognized(*iPath, iRequiredBufferSizePckg(), iResult, iUsersRequestStatus, iStatus); |
|
179 } |
|
180 |
|
181 void CAsyncFileRecognition::DoCancel() |
|
182 { |
|
183 iSession.SendReceive(ECancelRecognizeFiles,TIpcArgs(TIpcArgs::ENothing)); |
|
184 TRequestStatus* status = &iUsersRequestStatus; |
|
185 User::RequestComplete( status, KErrCancel ); |
|
186 } |
|
187 |
|
188 ////////////////////////////// |
|
189 // CApaLsSessionExtension |
|
190 ////////////////////////////// |
|
191 |
|
192 CApaLsSessionExtension::CApaLsSessionExtension(RApaLsSession& aSession) |
|
193 : iSession(aSession), |
|
194 iAsyncFileRecognition(NULL) |
|
195 { |
|
196 } |
|
197 |
|
198 CApaLsSessionExtension::~CApaLsSessionExtension() |
|
199 { |
|
200 delete iAsyncFileRecognition; |
|
201 } |
|
202 |
|
203 void CApaLsSessionExtension::SendReceive(TInt aFunction,const TIpcArgs& aArgs,TRequestStatus& aStatus) const |
|
204 { |
|
205 iSession.SendReceive(aFunction,aArgs,aStatus); //lint !e1060 Suppress protected member is not accessible to non-member non-friend |
|
206 } |
|
207 |
|
208 TInt CApaLsSessionExtension::SendReceive(TInt aFunction,const TIpcArgs& aArgs) const |
|
209 { |
|
210 return iSession.SendReceive(aFunction,aArgs); //lint !e1060 Suppress protected member is not accessible to non-member non-friend |
|
211 } |
|
212 |
|
213 /** |
|
214 Asynchronous recognition of a directory. |
|
215 Function uses an internal CAsyncFileRecognition object to hide the |
|
216 second server message (transferring the data to the client) from the user. |
|
217 When the path is not correct or the server is already busy with another |
|
218 recognition request, the function completes the request with an error. |
|
219 @internalComponent |
|
220 */ |
|
221 void CApaLsSessionExtension::RecognizeFilesL(const TDesC& aPath, const TDesC8& aDataType, CDataRecognitionResultArray& aResult, TRequestStatus& aStatus) |
|
222 { |
|
223 _LIT(KBackslash,"\\"); |
|
224 |
|
225 if(aPath.Right(1) != KBackslash) |
|
226 { |
|
227 TRequestStatus* status = &aStatus; |
|
228 User::RequestComplete(status,KErrPathNotFound); |
|
229 } |
|
230 |
|
231 aResult.SetPath(aPath); |
|
232 aStatus = KRequestPending; |
|
233 |
|
234 if(!iAsyncFileRecognition) |
|
235 { |
|
236 iAsyncFileRecognition = new (ELeave) CAsyncFileRecognition(aResult, aStatus, *this); |
|
237 iAsyncFileRecognition->Start(aPath, aDataType); |
|
238 } |
|
239 else |
|
240 { |
|
241 TRequestStatus* status = &aStatus; |
|
242 User::RequestComplete(status,KErrInUse); |
|
243 } |
|
244 } |
|
245 |
|
246 TBool CApaLsSessionExtension::RecognitionActive() const |
|
247 { |
|
248 return iAsyncFileRecognition ? ETrue : EFalse; |
|
249 } |
|
250 |
|
251 void CApaLsSessionExtension::CancelRecognizeFiles() |
|
252 { |
|
253 if(iAsyncFileRecognition) |
|
254 { |
|
255 iAsyncFileRecognition->Cancel(); |
|
256 delete iAsyncFileRecognition; |
|
257 iAsyncFileRecognition = NULL; |
|
258 } |
|
259 } |
|
260 |
|
261 void CApaLsSessionExtension::FilesRecognized(const TDesC& aPath, TInt aRequiredBufferSize, CDataRecognitionResultArray& aResult, TRequestStatus& aUsersRequestStatus, const TRequestStatus& aErrorCode) |
|
262 /** |
|
263 Callback function called by an CAsyncFileRecognition object, when an asynchronous |
|
264 recognition has finished. If the recognition was successful, the data is transferred |
|
265 to the client-side. |
|
266 @internalComponent |
|
267 */ |
|
268 { |
|
269 TRequestStatus* status = &aUsersRequestStatus; |
|
270 if(aErrorCode == KErrNone) |
|
271 { |
|
272 // transfer the result |
|
273 TRAPD(error,iSession.TransferAndInternalizeDataL(aPath, aRequiredBufferSize, aResult)); |
|
274 User::RequestComplete(status, error); |
|
275 } |
|
276 else |
|
277 { |
|
278 User::RequestComplete(status, aErrorCode.Int()); |
|
279 } |
|
280 delete iAsyncFileRecognition; |
|
281 iAsyncFileRecognition = 0; |
|
282 } |
|
283 |
|
284 |
|
285 /////////////////////////////////////// |
|
286 // CDataRecognitionResultArrayEntry |
|
287 /////////////////////////////////////// |
|
288 |
|
289 CDataRecognitionResultArrayEntry::CDataRecognitionResultArrayEntry(HBufC* aFileName, HBufC8* aDataType, TUid aUid, TInt aConfidence) |
|
290 : iFileName(aFileName), |
|
291 iDataType(aDataType), |
|
292 iUid(aUid), |
|
293 iConfidence(aConfidence) |
|
294 { |
|
295 } |
|
296 |
|
297 CDataRecognitionResultArrayEntry::~CDataRecognitionResultArrayEntry() |
|
298 { |
|
299 delete iFileName; |
|
300 delete iDataType; |
|
301 } |
|
302 |
|
303 void CDataRecognitionResultArrayEntry::GetDataRecognitionResult(TDataRecognitionResult& aResult) const |
|
304 { |
|
305 TDataRecognitionResult result; |
|
306 if(iDataType->Length() != 0) |
|
307 { |
|
308 TDataType dataType(*iDataType); |
|
309 result.iDataType = dataType; |
|
310 } |
|
311 else |
|
312 { |
|
313 TDataType dataType(iUid); |
|
314 result.iDataType = dataType; |
|
315 } |
|
316 result.iConfidence = iConfidence; |
|
317 aResult = result; |
|
318 } |
|
319 |
|
320 const TDesC& CDataRecognitionResultArrayEntry::FileName() const |
|
321 { |
|
322 if (iFileName == NULL) |
|
323 return KNullDesC; |
|
324 else |
|
325 return *iFileName; |
|
326 } |
|
327 |
|
328 |
|
329 /////////////////////////////////// |
|
330 // CDataRecognitionResultArray |
|
331 /////////////////////////////////// |
|
332 |
|
333 /** |
|
334 Constructor |
|
335 @publishedAll |
|
336 @released |
|
337 */ |
|
338 EXPORT_C CDataRecognitionResultArray::CDataRecognitionResultArray() |
|
339 { |
|
340 } |
|
341 |
|
342 /** |
|
343 Destructor |
|
344 @publishedAll |
|
345 @released |
|
346 */ |
|
347 EXPORT_C CDataRecognitionResultArray::~CDataRecognitionResultArray() |
|
348 { |
|
349 iEntries.ResetAndDestroy(); |
|
350 } |
|
351 |
|
352 /** |
|
353 Returns the path of the recognition results. |
|
354 @publishedAll |
|
355 @released |
|
356 @return The path of the recognition results |
|
357 */ |
|
358 EXPORT_C const TFileName& CDataRecognitionResultArray::Path() const |
|
359 { |
|
360 return iPath; |
|
361 } |
|
362 |
|
363 /** |
|
364 Returns the number of entries in the CDataRecognitionResultArray. |
|
365 @publishedAll |
|
366 @released |
|
367 @return The number of entries in the CDataRecognitionResultArray. |
|
368 */ |
|
369 EXPORT_C TUint CDataRecognitionResultArray::Count() const |
|
370 { |
|
371 return iEntries.Count(); |
|
372 } |
|
373 |
|
374 /** |
|
375 Returns the recognition result of the given index. |
|
376 @publishedAll |
|
377 @released |
|
378 @param aResult On successful completion, this parameter contains the recognition result at the given index. |
|
379 @param aIndex The index of the recognition result to be returned. An invalid index causes |
|
380 the function to leave with KErrNotFound. |
|
381 @return The requested TDataRecognitionResult object |
|
382 @leave KErrNotFound An invalid index is passed |
|
383 */ |
|
384 EXPORT_C void CDataRecognitionResultArray::GetDataRecognitionResultL(TDataRecognitionResult& aResult, const TUint aIndex) const |
|
385 { |
|
386 if( aIndex >= iEntries.Count() ) |
|
387 { |
|
388 User::Leave(KErrNotFound); |
|
389 } |
|
390 iEntries[aIndex]->GetDataRecognitionResult(aResult); |
|
391 } |
|
392 |
|
393 /** |
|
394 Returns the file name of the object at the given index. |
|
395 @publishedAll |
|
396 @released |
|
397 @param aFileName On successful completion, this parameter contains the file name of the object at the given index. |
|
398 @param aIndex Specifies which file name to be returned. An invalid index causes |
|
399 the function to leave with KErrNotFound. |
|
400 @return The requested file name |
|
401 @leave KErrNotFound An invalid index is passed |
|
402 */ |
|
403 EXPORT_C void CDataRecognitionResultArray::GetFileNameL(TFileName& aFileName, const TUint aIndex) const |
|
404 { |
|
405 if( aIndex >= iEntries.Count() ) |
|
406 { |
|
407 User::Leave(KErrNotFound); |
|
408 } |
|
409 aFileName.Zero(); |
|
410 aFileName.Copy( (iEntries[aIndex]->FileName()) ); |
|
411 } |
|
412 |
|
413 TUint CDataRecognitionResultArray::InternalizeL(const CBufFlat& aBuffer) |
|
414 { |
|
415 RBufReadStream readStream; |
|
416 |
|
417 readStream.Open(aBuffer); |
|
418 const TInt count=readStream.ReadUint32L(); |
|
419 for (TInt i=0; i<count; ++i) |
|
420 { |
|
421 const TInt fileNameLength = readStream.ReadUint8L(); |
|
422 HBufC* const fileName = HBufC::NewLC(fileNameLength); |
|
423 TPtr fileNamePtr = fileName->Des(); |
|
424 readStream.ReadL(fileNamePtr,fileNameLength); |
|
425 |
|
426 const TInt dataTypeLength = readStream.ReadUint8L(); |
|
427 HBufC8* const dataType = HBufC8::NewLC(dataTypeLength); |
|
428 TPtr8 dataTypePtr = dataType->Des(); |
|
429 readStream.ReadL(dataTypePtr,dataTypeLength); |
|
430 |
|
431 TUid uid; |
|
432 uid.iUid = readStream.ReadInt32L(); |
|
433 |
|
434 TInt const confidence = readStream.ReadInt32L(); |
|
435 |
|
436 CDataRecognitionResultArrayEntry* entry = new (ELeave) CDataRecognitionResultArrayEntry(fileName,dataType,uid,confidence); |
|
437 iEntries.Append(entry); |
|
438 |
|
439 CleanupStack::Pop(dataType); // ownership was transferred to "entry" |
|
440 CleanupStack::Pop(fileName); // ownership was transferred to "entry" |
|
441 } |
|
442 |
|
443 readStream.Close(); |
|
444 |
|
445 return KErrNone; |
|
446 } |
|
447 |
|
448 void CDataRecognitionResultArray::SetPath(const TFileName& aPath) |
|
449 { |
|
450 iPath.Copy(aPath); |
|
451 } |
|
452 |
|
453 //////////////////////////////////// |
|
454 //RApaLsSession |
|
455 //////////////////////////////////// |
|
456 |
|
457 EXPORT_C RApaLsSession::RApaLsSession() |
|
458 : iExtension(0) |
|
459 {} |
|
460 |
|
461 |
|
462 |
|
463 /** Connects a client to the application architecture server, creating a session |
|
464 with it. |
|
465 |
|
466 @return KErrNone if successful; otherwise, one of the system-wide error codes. |
|
467 */ |
|
468 EXPORT_C TInt RApaLsSession::Connect() |
|
469 { |
|
470 TInt r=CreateSession(KAppListServerName,Version(),KAsyncMessageSlots); |
|
471 return(r); |
|
472 } |
|
473 |
|
474 |
|
475 |
|
476 /** Gets the version of the application architecture server. |
|
477 |
|
478 @return The version number. |
|
479 */ |
|
480 EXPORT_C TVersion RApaLsSession::Version(void) const |
|
481 { |
|
482 return(TVersion(KAppListServMajorVersionNumber,KAppListServMinorVersionNumber,KAppListServBuildVersionNumber)); |
|
483 } |
|
484 |
|
485 |
|
486 |
|
487 /** Gets the total number of applications. |
|
488 |
|
489 Control panel applications are excluded. |
|
490 |
|
491 @param aCount On return, the total number of applications. |
|
492 @return KErrNone if successful, otherwise one of the system-wide error codes. |
|
493 */ |
|
494 EXPORT_C TInt RApaLsSession::AppCount(TInt& aCount) const |
|
495 { |
|
496 return DoAppCount(aCount,EAppListServAppCount); |
|
497 } |
|
498 |
|
499 |
|
500 |
|
501 /** Gets the total number of embeddable applications. |
|
502 |
|
503 Control panel applications are excluded. |
|
504 |
|
505 @param aCount On return, the total number of embeddable applications. |
|
506 @return KErrNone, if successful, otherwise one of the system-wide error codes. |
|
507 */ |
|
508 EXPORT_C TInt RApaLsSession::EmbeddableAppCount(TInt& aCount) const |
|
509 { |
|
510 return DoAppCount(aCount,EAppListServEmbedCount); |
|
511 } |
|
512 |
|
513 TInt RApaLsSession::DoAppCount(TInt& aCount,TInt aCommand) const |
|
514 // returns the number of embeddable apps in the server side list |
|
515 { |
|
516 __ASSERT_DEBUG(aCommand==EAppListServEmbedCount || aCommand==EAppListServAppCount,Panic(EDPanicWrongCommand)); |
|
517 const TInt returnValue=SendReceiveWithReconnect(aCommand,TIpcArgs()); |
|
518 if (returnValue<0) |
|
519 { |
|
520 return returnValue; |
|
521 } |
|
522 aCount=returnValue; |
|
523 return KErrNone; |
|
524 } |
|
525 |
|
526 |
|
527 |
|
528 /** Initialises the process of getting all applications in the cached list. |
|
529 |
|
530 Control panel applications are excluded. |
|
531 |
|
532 A call to this function is followed by subsequent and repeated calls to GetNextApp() |
|
533 to retrieve all applications in the cached list. |
|
534 |
|
535 @return KErrNone, if successful, otherwise one of the system-wide error codes. |
|
536 */ |
|
537 EXPORT_C TInt RApaLsSession::GetAllApps() const |
|
538 { |
|
539 return GetAllApps(0); |
|
540 } |
|
541 |
|
542 |
|
543 |
|
544 /** Initialises the process of getting all applications in the cached list. |
|
545 |
|
546 Control panel applications are excluded. |
|
547 |
|
548 A call to this function is followed by subsequent and repeated calls to GetNextApp() |
|
549 to retrieve all applications supporting aScreenMode in the cached list. |
|
550 |
|
551 @param aScreenMode Only applications which define a view supporting aScreenMode |
|
552 will be returned by subsequent calls to GetNextApp(). If an application does not |
|
553 define views in it's application information file, only screen mode 0 is supported. |
|
554 @return KErrNone, if successful, otherwise one of the system-wide error codes. |
|
555 */ |
|
556 EXPORT_C TInt RApaLsSession::GetAllApps(TInt aScreenMode) const |
|
557 { |
|
558 return GetFilteredApps(TApaAppCapability::EControlPanelItem, 0, aScreenMode); // exclude control panel apps |
|
559 } |
|
560 |
|
561 |
|
562 |
|
563 /** Initialises the process of getting all embeddable applications from the cached list. |
|
564 |
|
565 Control panel applications are excluded. |
|
566 |
|
567 A call to this function is followed by subsequent and repeated calls to GetNextApp() |
|
568 to retrieve embeddable applications in the cached list. |
|
569 |
|
570 Only applications which specify KAppEmbeddable or KAppEmbeddableOnly in their |
|
571 application information file will be returned by subsequent calls to GetNextApp(). |
|
572 |
|
573 @return KErrNone, if successful, otherwise one of the system-wide error codes. |
|
574 */ |
|
575 EXPORT_C TInt RApaLsSession::GetEmbeddableApps() const |
|
576 { |
|
577 return GetEmbeddableApps(0); |
|
578 } |
|
579 |
|
580 |
|
581 |
|
582 /** Initialises the process of getting embeddable applications from the cached list |
|
583 that support the specified screen mode. |
|
584 |
|
585 Control panel applications are excluded. |
|
586 |
|
587 A call to this function is followed by subsequent and repeated calls to GetNextApp() |
|
588 to retrieve embeddable applications in the cached list. |
|
589 |
|
590 Only applications which specify KAppEmbeddable or KAppEmbeddableOnly in their |
|
591 application information file will be returned by subsequent calls to GetNextApp(). |
|
592 |
|
593 @param aScreenMode Only embeddable applications which define a view supporting |
|
594 aScreenMode will be returned by subsequent calls to GetNextApp(). If an application |
|
595 does not define views in it's application information file, only screen mode 0 is supported. |
|
596 @return KErrNone, if successful, otherwise one of the system-wide error codes. |
|
597 */ |
|
598 EXPORT_C TInt RApaLsSession::GetEmbeddableApps(TInt aScreenMode) const |
|
599 { |
|
600 TApaEmbeddabilityFilter filter; |
|
601 filter.AddEmbeddability(TApaAppCapability::EEmbeddable); |
|
602 filter.AddEmbeddability(TApaAppCapability::EEmbeddableOnly); |
|
603 return GetFilteredApps(filter, aScreenMode); |
|
604 } |
|
605 |
|
606 |
|
607 |
|
608 /** Initialises the process of getting all applications matching aFilter in the |
|
609 cached list. |
|
610 |
|
611 Control panel applications are excluded. |
|
612 |
|
613 A call to this function is followed by subsequent and repeated calls to GetNextApp() |
|
614 to retrieve all applications matching aFilter in the cached list. |
|
615 |
|
616 @param aFilter Defines the filter to be applied to the cached list. |
|
617 @return KErrNone, if successful, otherwise one of the system-wide error codes. |
|
618 */ |
|
619 EXPORT_C TInt RApaLsSession::GetFilteredApps(const TApaEmbeddabilityFilter& aFilter) const |
|
620 { |
|
621 return GetFilteredApps(aFilter, 0); |
|
622 } |
|
623 |
|
624 |
|
625 |
|
626 /** Initialises the process of getting all applications matching aFilter in the |
|
627 cached list. |
|
628 |
|
629 Control panel applications are excluded. |
|
630 |
|
631 A call to this function is followed by subsequent and repeated calls to GetNextApp() |
|
632 to retrieve all applications matching aFilter in the cached list. |
|
633 |
|
634 @param aFilter Defines the filter to be applied to the cached list. |
|
635 @param aScreenMode Only applications which define a view supporting aScreenMode |
|
636 will be returned by subsequent calls to GetNextApp(). If an application does not |
|
637 define views in it's application information file, only screen mode 0 is supported. |
|
638 @return KErrNone, if successful, otherwise one of the system-wide error codes. |
|
639 */ |
|
640 EXPORT_C TInt RApaLsSession::GetFilteredApps(const TApaEmbeddabilityFilter& aFilter, TInt aScreenMode) const |
|
641 { |
|
642 const TPckgC<TApaEmbeddabilityFilter> filter(aFilter); |
|
643 return SendReceiveWithReconnect(EAppListServInitFilteredEmbedList,TIpcArgs(aScreenMode,&filter)); |
|
644 } |
|
645 |
|
646 |
|
647 |
|
648 /** Initialises the process of getting all applications matching the specified |
|
649 application attributes. |
|
650 |
|
651 A call to this function is followed by subsequent and repeated calls to GetNextApp() |
|
652 to retrieve all applications matching the filter in the cached list. |
|
653 |
|
654 Attributes are defined by TApaAppCapability::TCapabilityAttribute |
|
655 |
|
656 @param aCapabilityAttributeMask Specifies the attributes whose values will be |
|
657 used to filter the cached list. If the mask specifies more than one attribute, |
|
658 all associated attribute values must match. |
|
659 @param aCapabilityAttributeValue Specifies the attribute values for each attribute |
|
660 identified by the mask. |
|
661 @return KErrNone, if successful, otherwise one of the system-wide error codes. |
|
662 @see TCapabilityAttribute |
|
663 */ |
|
664 EXPORT_C TInt RApaLsSession::GetFilteredApps(TUint aCapabilityAttributeMask, TUint aCapabilityAttributeValue) const |
|
665 { |
|
666 return GetFilteredApps(aCapabilityAttributeMask, aCapabilityAttributeValue, 0); |
|
667 } |
|
668 |
|
669 |
|
670 |
|
671 /** Initialises the process of getting all applications matching the specified |
|
672 application attributes. |
|
673 |
|
674 A call to this function is followed by subsequent and repeated calls to GetNextApp() |
|
675 to retrieve all applications matching the filter in the cached list. |
|
676 |
|
677 Attributes are defined by TApaAppCapability::TCapabilityAttribute |
|
678 |
|
679 @param aCapabilityAttributeMask Specifies the attributes whose values will be |
|
680 used to filter the cached list. If the mask specifies more than one attribute, |
|
681 all associated attribute values must match. |
|
682 @param aCapabilityAttributeValue Specifies the attribute values for each attribute |
|
683 identified by the mask. |
|
684 @param aScreenMode Only applications which define a view supporting aScreenMode |
|
685 will be returned by subsequent calls to GetNextApp(). If an application does not |
|
686 define views in it's application information file, only screen mode 0 is supported. |
|
687 @return KErrNone, if successful, otherwise one of the system-wide error codes. |
|
688 @see TCapabilityAttribute |
|
689 */ |
|
690 EXPORT_C TInt RApaLsSession::GetFilteredApps(TUint aCapabilityAttributeMask, TUint aCapabilityAttributeValue, TInt aScreenMode) const |
|
691 { |
|
692 return SendReceiveWithReconnect(EAppListServInitAttrFilteredList,TIpcArgs(aScreenMode, aCapabilityAttributeMask, aCapabilityAttributeValue)); |
|
693 } |
|
694 |
|
695 |
|
696 |
|
697 /** Initialises the process of getting server applications in the cached list. |
|
698 |
|
699 Control panel applications are excluded. |
|
700 |
|
701 A call to this function is followed by subsequent and repeated calls to GetNextApp() |
|
702 to retrieve server applications in the cached list. |
|
703 |
|
704 Only applications which specify one or more services in their application |
|
705 information file will be returned by subsequent calls to GetNextApp(). |
|
706 |
|
707 @return KErrNone, if successful, otherwise one of the system-wide error codes. |
|
708 @publishedPartner |
|
709 @released |
|
710 */ |
|
711 EXPORT_C TInt RApaLsSession::GetServerApps(TUid aServiceUid) const |
|
712 { |
|
713 return GetServerApps(aServiceUid, 0); |
|
714 } |
|
715 |
|
716 |
|
717 |
|
718 /** Initialises the process of getting server applications in the cached list. |
|
719 |
|
720 Control panel applications are excluded. |
|
721 |
|
722 A call to this function is followed by subsequent and repeated calls to GetNextApp() |
|
723 to retrieve server applications in the cached list. |
|
724 |
|
725 Only applications which specify one or more services in their application |
|
726 information file will be returned by subsequent calls to GetNextApp(). |
|
727 |
|
728 @param aScreenMode Only server applications which define a view supporting |
|
729 aScreenMode will be returned by subsequent calls to GetNextApp(). If an application |
|
730 does not define views in its application information file, only screen mode 0 is supported. |
|
731 @return KErrNone, if successful, otherwise one of the system-wide error codes. |
|
732 @publishedPartner |
|
733 @released |
|
734 */ |
|
735 EXPORT_C TInt RApaLsSession::GetServerApps(TUid aServiceUid, TInt aScreenMode) const |
|
736 { |
|
737 return SendReceiveWithReconnect(EAppListServInitServerAppList,TIpcArgs(aScreenMode, aServiceUid.iUid)); |
|
738 } |
|
739 |
|
740 |
|
741 |
|
742 /** Gets information about the next application or embeddable application from |
|
743 the cached list. |
|
744 |
|
745 A sequence of calls to this function must always be preceded by a call to |
|
746 one of GetAllApps(), GetEmbeddableApps() or GetFilteredApps(). |
|
747 |
|
748 @param aInfo On return, contains application information. |
|
749 @return KErrNone if successful; ENoMoreAppsInList, if there are no more applications |
|
750 in the list; EAppListInvalid if the server's initial population of the list has |
|
751 not completed; otherwise one of the other system wide error codes. |
|
752 */ |
|
753 EXPORT_C TInt RApaLsSession::GetNextApp(TApaAppInfo& aInfo) const |
|
754 { |
|
755 return GetNextApp(aInfo,0); |
|
756 } |
|
757 |
|
758 |
|
759 |
|
760 /** Gets information about the next application or embeddable application from |
|
761 the cached list. |
|
762 |
|
763 A sequence of calls to this function must always be preceded by a call to |
|
764 one of GetAllApps(), GetEmbeddableApps() or GetFilteredApps(). |
|
765 |
|
766 @param aInfo On return, contains application information. |
|
767 @param aScreenMode This parameter is ignored. |
|
768 @return KErrNone if successful; ENoMoreAppsInList, if there are no more applications |
|
769 in the list; EAppListInvalid if the server's initial population of the list has |
|
770 not completed; otherwise one of the other system wide error codes. |
|
771 */ |
|
772 EXPORT_C TInt RApaLsSession::GetNextApp(TApaAppInfo& aInfo,TInt aScreenMode) const |
|
773 { |
|
774 TPckg<TApaAppInfo> info(aInfo); |
|
775 TInt ret=SendReceiveWithReconnect(EAppListServGetNextApp,TIpcArgs(aScreenMode,&info)); |
|
776 if (ret==KErrNone) |
|
777 aInfo = info(); |
|
778 else if (ret==KErrNotFound) |
|
779 ret = ENoMoreAppsInList; |
|
780 else if (ret==KErrCorrupt) |
|
781 ret = EAppListInvalid; |
|
782 return ret; |
|
783 } |
|
784 |
|
785 |
|
786 |
|
787 /** Gets information about the application with the specified UID. |
|
788 |
|
789 @param aInfo On return, contains the application information, if an application |
|
790 with the specified UID is found. If no matching application is found, then |
|
791 this object is not changed. |
|
792 @param aAppUid The application specific UID. |
|
793 @return KErrNone if successful; KErrNotFound if a matching entry could not be found; |
|
794 otherwise one of the other system wide error codes. |
|
795 */ |
|
796 EXPORT_C TInt RApaLsSession::GetAppInfo(TApaAppInfo& aInfo,TUid aAppUid) const |
|
797 { |
|
798 TPckg<TApaAppInfo> info(aInfo); |
|
799 return SendReceiveWithReconnect(EAppListServGetAppInfo,TIpcArgs(aAppUid.iUid,&info)); |
|
800 } //lint !e1764 Suppress reference parameter 'aInfo' could be declared const ref |
|
801 |
|
802 /** Sets the short caption of the application. |
|
803 |
|
804 Overrides the short caption specified in the localizable resource file for this application. |
|
805 Short captions set using this API will only take effect until the next device reset. |
|
806 |
|
807 @param aShortCaption The short caption of the application. The maximum length allowed is KApaMaxAppCaption. |
|
808 @param aLanguage The language corresponding to the caption. If this is ELangNone the caption is used |
|
809 for all languages for which a language specific short caption has not been set. |
|
810 @param aAppUid The uid of the application. |
|
811 @return KErrNone if successful, otherwise one of the system wide error codes. |
|
812 */ |
|
813 EXPORT_C TInt RApaLsSession::SetAppShortCaption(const TDesC& aShortCaption, TLanguage aLanguage, TUid aAppUid) |
|
814 { |
|
815 if (aShortCaption.Length() > KApaMaxAppCaption || aShortCaption.Length() == 0) |
|
816 { |
|
817 return KErrArgument; |
|
818 } |
|
819 return SendReceiveWithReconnect(EAppListServSetAppShortCaption, TIpcArgs(aAppUid.iUid, &aShortCaption, aLanguage)); |
|
820 } //lint !e1762 Suppress member function could be made const |
|
821 |
|
822 /** Gets the default screen-number of the application with the specified UID. |
|
823 |
|
824 @param aDefaultScreenNumber On return, contains the default screen-number, if an application |
|
825 with the specified UID is found. If no matching application is found, then |
|
826 this object is not changed. |
|
827 @param aAppUid The application specific UID. |
|
828 @return KErrNone if successful; KErrNotFound if a matching entry could not be found; |
|
829 otherwise one of the other system wide error codes. |
|
830 */ |
|
831 EXPORT_C TInt RApaLsSession::GetDefaultScreenNumber(TInt& aDefaultScreenNumber, TUid aAppUid) const |
|
832 { |
|
833 const TInt result=SendReceiveWithReconnect(EAppListServGetDefaultScreenNumber, TIpcArgs(aAppUid.iUid)); |
|
834 if (result<0) |
|
835 { |
|
836 return result; |
|
837 } |
|
838 aDefaultScreenNumber=result; |
|
839 return KErrNone; |
|
840 } |
|
841 |
|
842 |
|
843 /** Gets the capabilities of the application with the specified UID. |
|
844 |
|
845 @param aCapabilityBuf A modifiable descriptor that, on return, contains the |
|
846 application's capability information. The data returned in the descriptor |
|
847 is mapped by the TApaAppCapability class. If no matching application is found, |
|
848 then the content of this descriptor is not changed. |
|
849 @param aAppUid The application specific UID. |
|
850 @return KErrNone, if successful; KErrNotFound, if no matching entry can be found; otherwise |
|
851 one of the other system wide error codes. |
|
852 */ |
|
853 EXPORT_C TInt RApaLsSession::GetAppCapability(TDes8& aCapabilityBuf,TUid aAppUid) const |
|
854 { |
|
855 return SendReceiveWithReconnect(EAppListServGetAppCapability,TIpcArgs(&aCapabilityBuf,aAppUid.iUid)); |
|
856 } |
|
857 |
|
858 |
|
859 |
|
860 /** Starts an application defined by the specified command line information. |
|
861 This is an asynchronous method which doesn't wait for the process creation to complete. |
|
862 To be informed of the process creation success, |
|
863 then appropriate overloaded method taking a TRequestStatus parameter should be used. |
|
864 |
|
865 This is only recommended for non document based applications. |
|
866 |
|
867 View based applications are usually started by activating a specific view |
|
868 using CCoeAppUi::ActivateViewL. Alternatively, using StartApp() to start a |
|
869 view based application will activate the application's default view. |
|
870 |
|
871 @param aCommandLine The command line. |
|
872 @return KErrNone, if successful; KErrNotFound, if the application cannot be |
|
873 found; otherwise one of the other system-wide error codes. |
|
874 @see CCoeAppUi::ActivateViewL() |
|
875 */ |
|
876 EXPORT_C TInt RApaLsSession::StartApp(const CApaCommandLine& aCommandLine) |
|
877 { |
|
878 return DoStartApp(aCommandLine, NULL,NULL); |
|
879 } |
|
880 |
|
881 /** Starts an application defined by the specified command line information. |
|
882 This is an asynchronous method which doesn't wait for the process creation to complete. |
|
883 To be informed of the process creation success, |
|
884 then appropriate overloaded method taking a TRequestStatus parameter should be used. |
|
885 |
|
886 This is only recommended for non document based applications. |
|
887 |
|
888 View based applications are usually started by activating a specific view |
|
889 using CCoeAppUi::ActivateViewL. Alternatively, using StartApp() to start a |
|
890 view based application will activate the application's default view. |
|
891 |
|
892 @param aCommandLine The command line. |
|
893 @param aThreadId On return, the id of the main thread started. |
|
894 @return KErrNone, if successful; KErrNotFound, if the application cannot be |
|
895 found; otherwise one of the other system-wide error codes. |
|
896 @see CCoeAppUi::ActivateViewL() |
|
897 */ |
|
898 EXPORT_C TInt RApaLsSession::StartApp(const CApaCommandLine& aCommandLine,TThreadId& aThreadId) |
|
899 { |
|
900 return DoStartApp(aCommandLine, &aThreadId,NULL); |
|
901 } |
|
902 |
|
903 |
|
904 /** Starts an application defined by the specified command line information. |
|
905 |
|
906 This is only recommended for non document based applications. |
|
907 |
|
908 View based applications are usually started by activating a specific view |
|
909 using CCoeAppUi::ActivateViewL. Alternatively, using StartApp() to start a |
|
910 view based application will activate the application's default view. |
|
911 |
|
912 @param aCommandLine The command line. |
|
913 @param aThreadId On return, the id of the main thread started. |
|
914 @param aRequestStatusForRendezvous If not NULL, the asynchronous RProcess::Rendezvous() |
|
915 function is called (being passed this TRequestStatus object) before RProcess::Resume() is called on |
|
916 the new application process. If this function does not return KErrNone, RProcess::Rendezvous() will |
|
917 not be called passing aRequestStatusForRendezvous, so in this case the caller must not wait |
|
918 on aRequestStatusForRendezvous. |
|
919 @return KErrNone, if successful; KErrNotFound, if the application cannot be |
|
920 found; otherwise one of the other system-wide error codes. |
|
921 @see CCoeAppUi::ActivateViewL() |
|
922 */ |
|
923 EXPORT_C TInt RApaLsSession::StartApp(const CApaCommandLine& aCommandLine,TThreadId& aThreadId,TRequestStatus* aRequestStatusForRendezvous ) |
|
924 { |
|
925 return DoStartApp(aCommandLine, &aThreadId,aRequestStatusForRendezvous); |
|
926 } |
|
927 |
|
928 |
|
929 TInt RApaLsSession::DoStartApp(const CApaCommandLine& aCommandLine, TThreadId* aThreadId,TRequestStatus* aRequestStatusForRendezvous) |
|
930 { |
|
931 TRAPD(error, DoStartAppL(aCommandLine, aThreadId, aRequestStatusForRendezvous)); |
|
932 return error; |
|
933 } |
|
934 |
|
935 void RApaLsSession::DoStartAppL(const CApaCommandLine& aCommandLine, TThreadId* aThreadId,TRequestStatus* aRequestStatusForRendezvous) |
|
936 { |
|
937 // This function does not require "this" object to be connected to the Apparc server, |
|
938 // but if not, it works with some limitations (see the following document for a list |
|
939 // of these limitations: |
|
940 // generic/app-framework/Documentation/PREQ967_solution_constraints.doc). |
|
941 |
|
942 #if defined(USE_IH_RAISE_EVENT) |
|
943 const TInt appStartupInstrumentationEventIdBase=aCommandLine.AppStartupInstrumentationEventIdBase(); |
|
944 if (appStartupInstrumentationEventIdBase!=0) |
|
945 { |
|
946 IH_DECLARE( lInstrumentationHandler ); |
|
947 IH_CREATE( lInstrumentationHandler ); |
|
948 IH_RAISE_EVENT( lInstrumentationHandler, appStartupInstrumentationEventIdBase+MTestInstrumentation::TIDOffsetBeginApplicationFirstRedraw ); |
|
949 IH_RAISE_EVENT( lInstrumentationHandler, appStartupInstrumentationEventIdBase+MTestInstrumentation::TIDOffsetBeginApplicationReadyForInput ); |
|
950 IH_DELETE( lInstrumentationHandler ); |
|
951 } |
|
952 #endif |
|
953 |
|
954 // Retrieve the executable name from the CApaCommandLine object passed in. |
|
955 const TPtrC logicalExecutableName(aCommandLine.ExecutableName()); |
|
956 // Rule-based app launching is not allowed unless there is a connected RApaLsSession object. |
|
957 if(Handle() != KNullHandle) |
|
958 { |
|
959 // requesting from rule-based plug-ins if we can run an application |
|
960 // if server fails while requested rule-based plug-ins it returns a negative value - proceed with launching the application in this case |
|
961 TBool okayToRun = SendReceiveWithReconnect(EAppListServRuleBasedLaunching, TIpcArgs(&logicalExecutableName)); |
|
962 if(!okayToRun) |
|
963 { |
|
964 User::Leave(KErrCancel); |
|
965 } |
|
966 } |
|
967 |
|
968 TFileName nativeExecutableNameOfNonNativeApplication; |
|
969 RProcess process; |
|
970 HBufC8* opaqueData=NULL; |
|
971 CleanupStack::PushL(TCleanupItem(DeletePointerToPointerToTAny, &opaqueData)); |
|
972 |
|
973 // if we're connected to the Apparc server, try to get the opaque-data and native-executable name |
|
974 // (the latter is only if it's a non-native application that we're launching) |
|
975 if (Handle()!=KNullHandle) |
|
976 { |
|
977 const TInt lengthOfOpaqueData=User::LeaveIfError(SendReceiveWithReconnect(EAppListServGetNativeExecutableNameIfNonNative, TIpcArgs(&nativeExecutableNameOfNonNativeApplication, &logicalExecutableName))); |
|
978 if (lengthOfOpaqueData>0) |
|
979 { |
|
980 User::LeaveIfError(GetOpaqueData(opaqueData, lengthOfOpaqueData)); |
|
981 } |
|
982 } |
|
983 |
|
984 // try first to create the application process without interacting with the Apparc server at all - |
|
985 // assumes "logicalExecutableName" is itself a native executable |
|
986 TUidType uidType(KNullUid, KNullUid, KNullUid); |
|
987 TInt err = process.CreateWithStackOverride(logicalExecutableName, KNullDesC, uidType, MinApplicationStackSize(), EOwnerProcess); |
|
988 |
|
989 // If we haven't been able to create the process using the native executable name from the command line |
|
990 // object, instead try to create it using the native executable name of the non-native application. |
|
991 // Can only do this if apparc is connected and thus this name has been retrieved above and |
|
992 // nativeExecutableNameOfNonNativeApplication populated. |
|
993 if ((err != KErrNone) && nativeExecutableNameOfNonNativeApplication.Length()>0) |
|
994 { |
|
995 err = process.CreateWithStackOverride(nativeExecutableNameOfNonNativeApplication, KNullDesC, uidType, MinApplicationStackSize(), EOwnerProcess); |
|
996 } |
|
997 |
|
998 // if we managed to create the process via either of the two methods attempted above (with the native |
|
999 // name or the native name of the non-native app), finish setting it up and "resume" it |
|
1000 if (err == KErrNone) |
|
1001 { |
|
1002 CleanupStack::PushL(TCleanupItem(CleanupOperation, &process)); |
|
1003 if (opaqueData!=NULL) |
|
1004 { |
|
1005 const_cast<CApaCommandLine&>(aCommandLine).SetOpaqueDataL(*opaqueData); |
|
1006 } |
|
1007 aCommandLine.SetProcessEnvironmentL(process); |
|
1008 if (aThreadId!=NULL) |
|
1009 { |
|
1010 GetThreadIdL(*aThreadId, process); |
|
1011 } |
|
1012 if (aRequestStatusForRendezvous!=NULL) |
|
1013 { |
|
1014 process.Rendezvous(*aRequestStatusForRendezvous); |
|
1015 } |
|
1016 // Note - must not leave between here and the end of this method because we only expect |
|
1017 // the caller to wait on aRequestStatusForRendezvous if this method does not leave. |
|
1018 if(aRequestStatusForRendezvous != NULL && *aRequestStatusForRendezvous != KRequestPending) |
|
1019 { |
|
1020 User::WaitForRequest(*aRequestStatusForRendezvous); |
|
1021 User::Leave(aRequestStatusForRendezvous->Int()); // item on cleanupstack terminates and closes the process |
|
1022 } |
|
1023 else |
|
1024 { |
|
1025 process.Resume(); |
|
1026 } |
|
1027 CleanupStack::Pop(&process); |
|
1028 process.Close(); |
|
1029 } |
|
1030 else // Couldn't create a process |
|
1031 { |
|
1032 if (Handle()==KNullHandle) // not connected to apparc |
|
1033 { |
|
1034 const TPtrC executableName(aCommandLine.ExecutableName()); |
|
1035 |
|
1036 // Java applications have an empty ExecutableName, as they use the CApaCommandLine's |
|
1037 // opaque-data attribute. Not connected to apparc so can't start a non-native app. |
|
1038 // Therefore we should handle this case with KErrNotSupported rather than whatever |
|
1039 // RProcess::Create returns when passed an empty descriptor. |
|
1040 if (executableName.Length() == 0) |
|
1041 { |
|
1042 User::Leave(KErrNotSupported); |
|
1043 } |
|
1044 |
|
1045 // Otherwise return the error code from RProcess::Create. |
|
1046 User::Leave(err); |
|
1047 |
|
1048 } |
|
1049 else // Handle()!=KNullHandle |
|
1050 { |
|
1051 // we can only proceed with the remaining option if we're connected to the Apparc server |
|
1052 // as a last resort, try use the legacy file-recognizer framework to launch the application |
|
1053 TThreadId dummyThreadId; |
|
1054 TPckg<TThreadId> threadId((aThreadId!=NULL)? *aThreadId: dummyThreadId); |
|
1055 const TInt opcode=(aThreadId==NULL)? |
|
1056 EAppListServStartAppWithoutReturningThreadId: |
|
1057 EAppListServStartAppReturningThreadId; |
|
1058 TIpcArgs ipcArgs; |
|
1059 aCommandLine.GetIpcArgsLC(ipcArgs); |
|
1060 if (aThreadId!=NULL) |
|
1061 { |
|
1062 ipcArgs.Set(CApaCommandLine::EIpcFirstFreeSlot, &threadId); |
|
1063 } |
|
1064 User::LeaveIfError(SendReceiveWithReconnect(opcode, ipcArgs)); |
|
1065 if (aRequestStatusForRendezvous!=NULL) |
|
1066 { |
|
1067 User::RequestComplete(aRequestStatusForRendezvous,KErrNone); |
|
1068 } |
|
1069 CleanupStack::PopAndDestroy(); // the TIpcArgs |
|
1070 } |
|
1071 } |
|
1072 CleanupStack::PopAndDestroy(&opaqueData); |
|
1073 } //lint !e1762 Suppress member function could be made const |
|
1074 |
|
1075 void RApaLsSession::CleanupOperation(TAny* aAny) |
|
1076 { |
|
1077 RProcess* activeProcess = reinterpret_cast<RProcess*>(aAny); |
|
1078 activeProcess->Terminate(KErrGeneral); |
|
1079 activeProcess->Close(); |
|
1080 } |
|
1081 |
|
1082 void RApaLsSession::GetThreadIdL(TThreadId& aThreadId, const RProcess& aProcess) |
|
1083 { // static |
|
1084 TFullName fullName(aProcess.Name()); |
|
1085 _LIT(KCCMain,"::Main"); |
|
1086 fullName.Append(KCCMain); |
|
1087 RThread thread; |
|
1088 User::LeaveIfError(thread.Open(fullName,EOwnerThread)); |
|
1089 aThreadId=thread.Id(); |
|
1090 thread.Close(); |
|
1091 } |
|
1092 |
|
1093 void RApaLsSession::DeletePointerToPointerToTAny(TAny* aPointerToPointerToTAny) |
|
1094 { // static |
|
1095 __ASSERT_ALWAYS(aPointerToPointerToTAny, Panic(EPanicNullPointer)); |
|
1096 delete *static_cast<TAny**>(aPointerToPointerToTAny); //lint !e613 Suppress possible use of null pointer |
|
1097 } //lint !e818 Suppress pointer parameter could be declared as pointing to const |
|
1098 |
|
1099 /** |
|
1100 Sets up slots 0 and 1 in aIpcArgs - assumes that slots 2 and 3 have already been set up; |
|
1101 it then invokes aOpcode |
|
1102 */ |
|
1103 TInt RApaLsSession::GetExecutableName(TDes& aNativeExecutableName, TDes& aLogicalExecutableName, HBufC8*& aOpaqueData, TIpcArgs& aIpcArgs, TInt aOpcode) const |
|
1104 { |
|
1105 aNativeExecutableName.SetLength(0); // if this comes out zero-length from EAppListServExecutableNameForXxx below then use the logicalExecutableName in RProcess::Create (in this case it's a native C++ application) |
|
1106 aIpcArgs.Set(0, &aNativeExecutableName); |
|
1107 aIpcArgs.Set(1, &aLogicalExecutableName); |
|
1108 const TInt lengthOfOpaqueData=SendReceiveWithReconnect(aOpcode, aIpcArgs); |
|
1109 if (lengthOfOpaqueData<0) |
|
1110 { |
|
1111 return lengthOfOpaqueData; // it's an error code |
|
1112 } |
|
1113 if (lengthOfOpaqueData>0) |
|
1114 { |
|
1115 return GetOpaqueData(aOpaqueData, lengthOfOpaqueData); |
|
1116 } |
|
1117 aOpaqueData=NULL; |
|
1118 return KErrNone; |
|
1119 } |
|
1120 |
|
1121 TInt RApaLsSession::GetOpaqueData(HBufC8*& aOpaqueData, TInt aLengthOfOpaqueData) const |
|
1122 { |
|
1123 HBufC8* const opaqueData=HBufC8::New(aLengthOfOpaqueData); |
|
1124 if (opaqueData==NULL) |
|
1125 { |
|
1126 return KErrNoMemory; |
|
1127 } |
|
1128 TPtr8 opaqueData_asWritable(opaqueData->Des()); |
|
1129 const TInt error=SendReceiveWithReconnect(EAppListServGetOpaqueData, TIpcArgs(&opaqueData_asWritable)); |
|
1130 if (error!=KErrNone) |
|
1131 { |
|
1132 delete opaqueData; |
|
1133 return error; |
|
1134 } |
|
1135 aOpaqueData=opaqueData; |
|
1136 return error; |
|
1137 } |
|
1138 |
|
1139 TInt RApaLsSession::StartApplicationPassingFileHandle(const TDesC& aNativeExecutableName, const TDesC& aLogicalExecutableName, const TDesC8* aOpaqueData, const RFile& aFile, TThreadId& aThreadId, TRequestStatus* aRequestStatusForRendezvous) |
|
1140 { |
|
1141 TFileName documentName; |
|
1142 aFile.FullName(documentName); |
|
1143 CApaCommandLine* commandLine=NULL; |
|
1144 TRAPD(error, commandLine=CApaCommandLine::NewLC(); |
|
1145 commandLine->SetCommandL(EApaCommandOpen); |
|
1146 commandLine->SetExecutableNameL(aLogicalExecutableName); |
|
1147 commandLine->SetFileByHandleL(aFile); |
|
1148 commandLine->SetDocumentNameL(documentName); |
|
1149 if (aOpaqueData!=NULL) |
|
1150 { |
|
1151 commandLine->SetOpaqueDataL(*aOpaqueData); |
|
1152 } |
|
1153 StartApplicationL(aNativeExecutableName, *commandLine, aThreadId, aRequestStatusForRendezvous); |
|
1154 CleanupStack::PopAndDestroy(commandLine)); |
|
1155 return error; |
|
1156 } |
|
1157 |
|
1158 TInt RApaLsSession::StartApplicationPassingDocumentName(const TDesC& aNativeExecutableName, const TDesC& aLogicalExecutableName, const TDesC8* aOpaqueData, const TDesC& aDocumentName, TThreadId& aThreadId,TApaCommand aCommand, TRequestStatus* aRequestStatusForRendezvous) |
|
1159 { |
|
1160 CApaCommandLine* commandLine=NULL; |
|
1161 TRAPD(error, commandLine=CApaCommandLine::NewLC(); |
|
1162 commandLine->SetCommandL(aCommand); |
|
1163 commandLine->SetExecutableNameL(aLogicalExecutableName); |
|
1164 commandLine->SetDocumentNameL(aDocumentName); |
|
1165 if (aOpaqueData!=NULL) |
|
1166 { |
|
1167 commandLine->SetOpaqueDataL(*aOpaqueData); |
|
1168 } |
|
1169 StartApplicationL(aNativeExecutableName, *commandLine, aThreadId, aRequestStatusForRendezvous); |
|
1170 CleanupStack::PopAndDestroy(commandLine)); |
|
1171 return error; |
|
1172 } |
|
1173 |
|
1174 void RApaLsSession::StartApplicationL(const TDesC& aNativeExecutableName, const CApaCommandLine& aCommandLine, TThreadId& aThreadId, TRequestStatus* aRequestStatusForRendezvous) |
|
1175 { |
|
1176 RProcess process; |
|
1177 TPtrC actualNativeExecutableName(aNativeExecutableName); |
|
1178 if (actualNativeExecutableName.Length()==0) |
|
1179 { |
|
1180 actualNativeExecutableName.Set(aCommandLine.ExecutableName()); // it's a native C++ application, rather than a MIDlet, Python script, etc |
|
1181 } |
|
1182 |
|
1183 if(Handle() != KNullHandle) |
|
1184 { |
|
1185 //requesting from rule-based plug-ins if we can run an application |
|
1186 TBool okayToRun = SendReceiveWithReconnect(EAppListServRuleBasedLaunching, TIpcArgs(&actualNativeExecutableName)); |
|
1187 //If server fails while requested rule-based plug-ins it returns a negative value. |
|
1188 //We shall proceed with launching an application in this case. |
|
1189 if(!okayToRun) |
|
1190 { |
|
1191 User::Leave(KErrCancel); |
|
1192 } |
|
1193 } |
|
1194 |
|
1195 TUidType uidType(KNullUid, KNullUid, KNullUid); |
|
1196 User::LeaveIfError(process.CreateWithStackOverride(actualNativeExecutableName, KNullDesC, uidType, MinApplicationStackSize(), EOwnerProcess)); // RProcess::CreateWithStackOveride - TESTED |
|
1197 |
|
1198 CleanupClosePushL(process); |
|
1199 aCommandLine.SetProcessEnvironmentL(process); |
|
1200 GetThreadIdL(aThreadId, process); |
|
1201 if (aRequestStatusForRendezvous!=NULL) |
|
1202 { |
|
1203 process.Rendezvous(*aRequestStatusForRendezvous); |
|
1204 } |
|
1205 process.Resume(); |
|
1206 CleanupStack::PopAndDestroy(&process); |
|
1207 } //lint !e1762 Suppress member function could be made const |
|
1208 |
|
1209 |
|
1210 |
|
1211 /** Gets the data (MIME) type for data taken from a file with a specified name. |
|
1212 |
|
1213 @param aName The full filename, including drive and path, of the file containing the data. |
|
1214 @param aBuffer A buffer containing data taken from the specified file; typically |
|
1215 the data is read from the beginning of the file. |
|
1216 @param aDataType On return, contains the result of the attempt to recognize |
|
1217 data. |
|
1218 @return KErrNone, if successful; otherwise one of the other system-wide error |
|
1219 codes. |
|
1220 */ |
|
1221 EXPORT_C TInt RApaLsSession::RecognizeData(const TDesC& aName, const TDesC8& aBuffer, TDataRecognitionResult& aDataType) const |
|
1222 { |
|
1223 TPckg<TDataRecognitionResult> result(aDataType); |
|
1224 return SendReceiveWithReconnect(EAppListServRecognizeData,TIpcArgs(&result, &aName, &aBuffer)); |
|
1225 } //lint !e1764: Suppress reference parameter could be declared const ref |
|
1226 |
|
1227 /** Gets the data (MIME) type for data in a file passed by handle. |
|
1228 |
|
1229 @param aFile The file containing the data. Before this function can be called, |
|
1230 the file server session which owns this file handle must first be marked as shareable by |
|
1231 calling RFs::ShareProtected(). |
|
1232 @param aDataType On return, contains the result of the attempt to recognize |
|
1233 data. |
|
1234 @return KErrNone, if successful; otherwise one of the other system-wide error |
|
1235 codes. */ |
|
1236 EXPORT_C TInt RApaLsSession::RecognizeData(const RFile& aFile, TDataRecognitionResult& aDataType) const |
|
1237 { |
|
1238 TPckg<TDataRecognitionResult> result(aDataType); |
|
1239 TIpcArgs ipcArgs(&result); |
|
1240 const TInt error = aFile.TransferToServer(ipcArgs, 1, 2); |
|
1241 if (error != KErrNone) |
|
1242 { |
|
1243 return error; |
|
1244 } |
|
1245 return SendReceiveWithReconnect(EAppListServRecognizeDataPassedByFileHandle,ipcArgs); |
|
1246 } //lint !e1764 Suppress reference parameter 'aDataType' could be declared const ref |
|
1247 |
|
1248 |
|
1249 |
|
1250 /** Tests whether data taken from a named file has the specified |
|
1251 data (MIME) type. |
|
1252 |
|
1253 @param aName The name of the file containing the data. |
|
1254 @param aBuffer A buffer containing data taken from the specified file; typically |
|
1255 the data is read from the beginning of the file. |
|
1256 @param aDataType The data (MIME) type. |
|
1257 @param aResult On return, contains the result of the test. |
|
1258 @return KErrNone, if successful; otherwise one of the other system-wide error |
|
1259 codes. |
|
1260 */ |
|
1261 EXPORT_C TInt RApaLsSession::RecognizeSpecificData(const TDesC& aName, const TDesC8& aBuffer, const TDataType& aDataType, TBool& aResult) const |
|
1262 { |
|
1263 const TPckgC<TDataType> dataType(aDataType); |
|
1264 const TInt returnValue=SendReceiveWithReconnect(EAppListServRecognizeSpecificData,TIpcArgs(&dataType, &aName, &aBuffer)); |
|
1265 if (returnValue<0) |
|
1266 { |
|
1267 return returnValue; |
|
1268 } |
|
1269 aResult=returnValue; |
|
1270 return KErrNone; |
|
1271 } |
|
1272 |
|
1273 EXPORT_C TInt RApaLsSession::RecognizeFilesL(const TDesC& aPath, CDataRecognitionResultArray& aResult) const |
|
1274 /** |
|
1275 Gets the data (MIME) type for files in a specified directory. Because this call may take a long |
|
1276 time to complete, the asynchronous version is strongly recommended. Furthermore, it is not possible |
|
1277 to use this synchronous function while an asynchronous request is still active. |
|
1278 @publishedAll |
|
1279 @released |
|
1280 @param aPath A valid path. Note that the path must end with a backslash. |
|
1281 @param aResult If the call was successful, this parameter contains the recognition result. |
|
1282 @return KErrNone, if successful; otherwise one of the other system-wide error codes. |
|
1283 */ |
|
1284 { |
|
1285 return RecognizeFilesL(aPath, KAllDataTypes, aResult); |
|
1286 } |
|
1287 |
|
1288 EXPORT_C TInt RApaLsSession::RecognizeFilesL(const TDesC& aPath, const TDesC8& aDataType, CDataRecognitionResultArray& aResult) const |
|
1289 /** |
|
1290 Gets the data (MIME) type for files in a specified directory. Because this call may take a long |
|
1291 time to complete, the asynchronous version is strongly recommended. Furthermore, it is not possible |
|
1292 to use this synchronous function while an asynchronous request is still active. |
|
1293 @publishedAll |
|
1294 @released |
|
1295 @param aPath A valid path. Note that the path must end with a backslash. |
|
1296 @param aDataType A data type filter. Wildcards are allowed. For example, "text*" would also |
|
1297 add "text/plain" data types to the result. |
|
1298 @param aResult If the call was successful, this parameter contains the recognition result. |
|
1299 @return KErrNone, if successful; otherwise one of the other system-wide error codes. |
|
1300 */ |
|
1301 { |
|
1302 if(iExtension && iExtension->RecognitionActive()) |
|
1303 { |
|
1304 return KErrInUse; |
|
1305 } |
|
1306 _LIT(KBackslash,"\\"); |
|
1307 if(aPath.Right(1) != KBackslash) |
|
1308 { |
|
1309 return KErrPathNotFound; |
|
1310 } |
|
1311 |
|
1312 TPckgBuf<TUint> requiredBufferSizePckg; |
|
1313 aResult.SetPath(aPath); |
|
1314 TInt error = SendReceiveWithReconnect(EAppListServRecognizeFiles,TIpcArgs(&aPath,&requiredBufferSizePckg,&aDataType)); |
|
1315 if(KErrNone == error) |
|
1316 { |
|
1317 error=TransferAndInternalizeDataL(aPath, requiredBufferSizePckg(), aResult); |
|
1318 } |
|
1319 return error; |
|
1320 |
|
1321 } |
|
1322 |
|
1323 EXPORT_C void RApaLsSession::RecognizeFilesL(const TDesC& aPath, CDataRecognitionResultArray& aResult, TRequestStatus& aStatus) |
|
1324 /** |
|
1325 Gets the data (MIME) type for files in a specified directory. |
|
1326 @publishedAll |
|
1327 @released |
|
1328 @param aPath A valid path. Note that the path must end with a backslash. |
|
1329 @param aResult If the call was successful, this parameter contains the recognition result. |
|
1330 @param aStatus A request status object. |
|
1331 */ |
|
1332 { |
|
1333 RecognizeFilesL(aPath,KAllDataTypes,aResult,aStatus); |
|
1334 } |
|
1335 |
|
1336 EXPORT_C void RApaLsSession::RecognizeFilesL(const TDesC& aPath, const TDesC8& aDataType, CDataRecognitionResultArray& aResult, TRequestStatus& aStatus) |
|
1337 /** |
|
1338 Gets the data (MIME) type for files in a specified directory. |
|
1339 @publishedAll |
|
1340 @released |
|
1341 @param aPath A valid path. Note that the path must end with a backslash. |
|
1342 @param aDataType A data type filter. Wildcards are allowed. For example, "text*" would also |
|
1343 add "text/plain" data types to the result. |
|
1344 @param aResult If the call was successful, this parameter contains the recognition result. |
|
1345 @param aStatus A request status object |
|
1346 */ |
|
1347 { |
|
1348 if(iExtension == NULL) |
|
1349 { |
|
1350 iExtension = new (ELeave) CApaLsSessionExtension(*this); |
|
1351 } |
|
1352 iExtension->RecognizeFilesL(aPath, aDataType, aResult, aStatus); |
|
1353 } |
|
1354 |
|
1355 TInt RApaLsSession::TransferAndInternalizeDataL(const TDesC& aPath, const TInt aRequiredBufferSize, CDataRecognitionResultArray& aResult) const |
|
1356 /** |
|
1357 This function transfers the data to the client-side and "fills" the CDataRecognitionResultArray object. |
|
1358 @internalComponent |
|
1359 */ |
|
1360 { |
|
1361 CBufFlat* const buffer=CBufFlat::NewL(aRequiredBufferSize); |
|
1362 CleanupStack::PushL(buffer); |
|
1363 buffer->ExpandL(0,aRequiredBufferSize); |
|
1364 TPtr8 bufPtr=buffer->Ptr(0); |
|
1365 |
|
1366 // transfer recognition buffer |
|
1367 TInt error = SendReceiveWithReconnect(EAppListServTransferRecognitionResult,TIpcArgs(&aPath,&bufPtr,aRequiredBufferSize)); |
|
1368 if(KErrNone == error) |
|
1369 { |
|
1370 error = aResult.InternalizeL(*buffer); |
|
1371 } |
|
1372 CleanupStack::PopAndDestroy(buffer); |
|
1373 return error; |
|
1374 } |
|
1375 |
|
1376 EXPORT_C void RApaLsSession::CancelRecognizeFiles() |
|
1377 /** |
|
1378 Cancels any outstanding asynchronous recognition requests. |
|
1379 @publishedAll |
|
1380 @released |
|
1381 */ |
|
1382 { |
|
1383 if(iExtension) |
|
1384 { |
|
1385 iExtension->CancelRecognizeFiles(); |
|
1386 } |
|
1387 } |
|
1388 |
|
1389 EXPORT_C void RApaLsSession::Close() |
|
1390 /** |
|
1391 Closes the session. Needs to be called to avoid memory leaks. |
|
1392 @publishedAll |
|
1393 @released |
|
1394 */ |
|
1395 { |
|
1396 CancelRecognizeFiles(); |
|
1397 RHandleBase::Close(); |
|
1398 delete iExtension; |
|
1399 iExtension = NULL; |
|
1400 } |
|
1401 |
|
1402 EXPORT_C TInt RApaLsSession::RecognizeSpecificData(const RFile& aFile, const TDataType& aDataType, TBool& aResult) const |
|
1403 /** Tests whether data taken from a file passed by handle has the specified |
|
1404 data (MIME) type. |
|
1405 |
|
1406 @param aFile The file containing the data. Before this function can be called, |
|
1407 the file server session which owns this file handle must first be marked as shareable by |
|
1408 calling RFs::ShareProtected(). |
|
1409 @param aDataType The data (MIME) type. |
|
1410 @param aResult On return, contains the result of the test. |
|
1411 @return KErrNone, if successful; otherwise one of the other system-wide error |
|
1412 codes. */ |
|
1413 { |
|
1414 const TPckgC<TDataType> dataType(aDataType); |
|
1415 TIpcArgs ipcArgs(&dataType); |
|
1416 TInt returnValue = aFile.TransferToServer(ipcArgs, 1, 2); |
|
1417 if (returnValue == KErrNone) |
|
1418 { |
|
1419 returnValue=SendReceiveWithReconnect(EAppListServRecognizeSpecificDataPassedByFileHandle,ipcArgs); |
|
1420 } |
|
1421 if (returnValue < KErrNone) |
|
1422 { |
|
1423 return returnValue; |
|
1424 } |
|
1425 aResult=returnValue; |
|
1426 return KErrNone; |
|
1427 } |
|
1428 |
|
1429 |
|
1430 /** Gets the UID of an application that can handle the specified data (MIME) type. |
|
1431 |
|
1432 If no application can be found, the function returns the UID of the preferred |
|
1433 default handler. If none of the default handlers can handle the data type, |
|
1434 then a NULL UID is returned. |
|
1435 |
|
1436 @param aDataType The data (MIME) type. |
|
1437 @param aAppUid On return, the UID of the application that can handle the data |
|
1438 (MIME) type; this may be NULL. |
|
1439 @return KErrNone, if successful; otherwise one of the other system-wide error |
|
1440 codes. |
|
1441 */ |
|
1442 EXPORT_C TInt RApaLsSession::AppForDataType(const TDataType& aDataType, TUid& aAppUid) const |
|
1443 { |
|
1444 const TPckgC<TDataType> dataType(aDataType); |
|
1445 TPckg<TUid> uid(aAppUid); |
|
1446 return SendReceiveWithReconnect(EAppListServAppForDataType,TIpcArgs(&dataType,&uid)); |
|
1447 } //lint !e1764 Suppress reference parameter 'aAppUid' could be declared const ref |
|
1448 |
|
1449 |
|
1450 /** Finds and launches an application to handle the document contained in the specified |
|
1451 file. |
|
1452 |
|
1453 @param aFileName The document name. |
|
1454 @param aThreadId On return, the id of the main thread started. |
|
1455 @param aLaunchType Not used. Reserved for future use. |
|
1456 @return KErrNone, if successful; EAppListInvalid, if the server's initial population of |
|
1457 the list has not completed; KErrNotFound, if a matching entry could not be found; otherwise |
|
1458 one of the other system-wide error codes. |
|
1459 */ |
|
1460 EXPORT_C TInt RApaLsSession::StartDocument(const TDesC& aFileName, TThreadId& aThreadId, TLaunchType /*aLaunchType*/) |
|
1461 { |
|
1462 HBufC8* buffer=NULL; |
|
1463 TInt error=GetBufferFromFile(buffer, aFileName); |
|
1464 if (error!=KErrNone) |
|
1465 { |
|
1466 return error; |
|
1467 } |
|
1468 TFileName nativeExecutableName; // the name of the EXE that we pass to RProcess::Create |
|
1469 TFileName logicalExecutableName; // the name of the MIDlet, Python script, etc |
|
1470 HBufC8* opaqueData=NULL; |
|
1471 TIpcArgs ipcArgs; |
|
1472 ipcArgs.Set(2, &aFileName); |
|
1473 ipcArgs.Set(3, buffer); |
|
1474 error=GetExecutableName(nativeExecutableName, logicalExecutableName, opaqueData, ipcArgs, EAppListServGetExecutableNameGivenDocument); |
|
1475 if (error!=KErrNone) |
|
1476 { |
|
1477 delete buffer; |
|
1478 return error; |
|
1479 } |
|
1480 error = StartApplicationPassingDocumentName(nativeExecutableName, logicalExecutableName, opaqueData, aFileName, aThreadId, EApaCommandOpen, NULL); |
|
1481 delete opaqueData; |
|
1482 if(error!=KErrNone && error!=KErrCancel) |
|
1483 { |
|
1484 TPckg<TThreadId> threadId(aThreadId); |
|
1485 error = SendReceiveWithReconnect(EAppListServStartDocument,TIpcArgs(&threadId, &aFileName, buffer)); |
|
1486 } |
|
1487 delete buffer; |
|
1488 return error; |
|
1489 } |
|
1490 |
|
1491 EXPORT_C TInt RApaLsSession::StartDocument(RFile& aFile, TThreadId& aThreadId, TRequestStatus* aRequestStatusForRendezvous/*=NULL*/) |
|
1492 /** Finds and launches an application to handle the document contained in the specified file |
|
1493 |
|
1494 @param aFile The file handle. Before this function can be called, |
|
1495 the file server session which owns this file handle must first be marked as shareable by |
|
1496 calling RFs::ShareProtected(). |
|
1497 @param aThreadId On return, the id of the main thread started. |
|
1498 @param aRequestStatusForRendezvous If not NULL, the asynchronous RProcess::Rendezvous() |
|
1499 function is called (being passed this TRequestStatus object) before RProcess::Resume() is called on |
|
1500 the new application process. |
|
1501 @return KErrNone, if successful; KErrNotFound, if no suitable application can |
|
1502 be found; otherwise one of the other system-wide error codes. */ |
|
1503 { |
|
1504 TFileName nativeExecutableName; // the name of the EXE that we pass to RProcess::Create |
|
1505 TFileName logicalExecutableName; // the name of the MIDlet, Python script, etc |
|
1506 HBufC8* opaqueData=NULL; |
|
1507 TIpcArgs ipcArgs; |
|
1508 TInt error=aFile.TransferToServer(ipcArgs, 2, 3); |
|
1509 if (error == KErrNone) |
|
1510 { |
|
1511 error=GetExecutableName(nativeExecutableName, logicalExecutableName, opaqueData, ipcArgs, EAppListServGetExecutableNameGivenDocumentPassedByFileHandle); |
|
1512 } |
|
1513 if (error!=KErrNone) |
|
1514 { |
|
1515 return error; |
|
1516 } |
|
1517 error=StartApplicationPassingFileHandle(nativeExecutableName, logicalExecutableName, opaqueData, aFile, aThreadId, aRequestStatusForRendezvous); |
|
1518 delete opaqueData; |
|
1519 return error; |
|
1520 } //lint !e1764 Suppress reference parameter could be declared const ref |
|
1521 |
|
1522 |
|
1523 /** Launches an application that can handle the specified data (MIME) type. |
|
1524 |
|
1525 The application handles the document contained in the specified file. |
|
1526 |
|
1527 @param aFileName The document name. |
|
1528 @param aDataType The data (MIME) type. |
|
1529 @param aThreadId On return, the id of the main thread started. |
|
1530 @param aLaunchType Not used. Reserved for future use. |
|
1531 @return KErrNone, if successful; EAppListInvalid if the server's initial population of |
|
1532 the list has not completed; KErrNotFound, if no suitable application can |
|
1533 be found; otherwise one of the other system-wide error codes. |
|
1534 */ |
|
1535 EXPORT_C TInt RApaLsSession::StartDocument(const TDesC& aFileName, const TDataType& aDataType, TThreadId& aThreadId, TLaunchType /*aLaunchType*/) |
|
1536 { |
|
1537 TFileName nativeExecutableName; // the name of the EXE that we pass to RProcess::Create |
|
1538 TFileName logicalExecutableName; // the name of the MIDlet, Python script, etc |
|
1539 HBufC8* opaqueData=NULL; |
|
1540 const TPckgC<TDataType> dataType(aDataType); |
|
1541 TIpcArgs ipcArgs; |
|
1542 ipcArgs.Set(2, &dataType); |
|
1543 TInt error=GetExecutableName(nativeExecutableName, logicalExecutableName, opaqueData, ipcArgs, EAppListServGetExecutableNameGivenDataType); |
|
1544 if (error!=KErrNone) |
|
1545 { |
|
1546 return error; |
|
1547 } |
|
1548 error = StartApplicationPassingDocumentName(nativeExecutableName, logicalExecutableName, opaqueData, aFileName, aThreadId,EApaCommandOpen,NULL); |
|
1549 delete opaqueData; |
|
1550 if(error!=KErrNone && error!=KErrCancel) |
|
1551 { |
|
1552 TPckg<TThreadId> threadId(aThreadId); |
|
1553 error = SendReceiveWithReconnect(EAppListServStartDocumentByDataType,TIpcArgs(&threadId, &aFileName, &dataType)); |
|
1554 } |
|
1555 return error; |
|
1556 } |
|
1557 |
|
1558 EXPORT_C TInt RApaLsSession::StartDocument(RFile& aFile, const TDataType& aDataType, TThreadId& aThreadId, TRequestStatus* aRequestStatusForRendezvous/*=NULL*/) |
|
1559 /** Finds and launches an application to handle the document contained in the specified file |
|
1560 |
|
1561 @param aFile The file handle. |
|
1562 @param aDataType The data (MIME) type. |
|
1563 @param aThreadId On return, the id of the main thread started. |
|
1564 @param aRequestStatusForRendezvous If not NULL, the asynchronous RProcess::Rendezvous() |
|
1565 function is called (being passed this TRequestStatus object) before RProcess::Resume() is called on |
|
1566 the new application process. |
|
1567 @return KErrNone, if successful; KErrNotFound, if no suitable application can |
|
1568 be found; otherwise one of the other system-wide error codes. */ |
|
1569 { |
|
1570 TFileName nativeExecutableName; // the name of the EXE that we pass to RProcess::Create |
|
1571 TFileName logicalExecutableName; // the name of the MIDlet, Python script, etc |
|
1572 HBufC8* opaqueData=NULL; |
|
1573 const TPckgC<TDataType> dataType(aDataType); |
|
1574 TIpcArgs ipcArgs; |
|
1575 ipcArgs.Set(2, &dataType); |
|
1576 TInt error=GetExecutableName(nativeExecutableName, logicalExecutableName, opaqueData, ipcArgs, EAppListServGetExecutableNameGivenDataType); |
|
1577 if (error!=KErrNone) |
|
1578 { |
|
1579 return error; |
|
1580 } |
|
1581 error=StartApplicationPassingFileHandle(nativeExecutableName, logicalExecutableName, opaqueData, aFile, aThreadId, aRequestStatusForRendezvous); |
|
1582 delete opaqueData; |
|
1583 return error; |
|
1584 } //lint !e1764 Suppress reference parameter could be declared const ref |
|
1585 |
|
1586 EXPORT_C TInt RApaLsSession::StartDocument(const TDesC& aFileName, TUid aAppUid, TThreadId& aThreadId, TLaunchType aLaunchType) |
|
1587 /** Launches the application identified by the specified UID. |
|
1588 |
|
1589 The application handles the document contained in the specified file. |
|
1590 |
|
1591 @param aFileName The document name. |
|
1592 @param aAppUid The application specific UID. |
|
1593 @param aThreadId On return, the id of the main thread started. |
|
1594 @param aLaunchType Not used. Reserved for future use. |
|
1595 @return KErrNone, if successful; EAppListInvalid if the server's initial population of |
|
1596 the list has not completed; KErrNotFound, if no suitable application can |
|
1597 be found; otherwise one of the other system-wide error codes. */ |
|
1598 { |
|
1599 TFileName nativeExecutableName; // the name of the EXE that we pass to RProcess::Create |
|
1600 TFileName logicalExecutableName; // the name of the MIDlet, Python script, etc |
|
1601 HBufC8* opaqueData=NULL; |
|
1602 TIpcArgs ipcArgs; |
|
1603 ipcArgs.Set(2, aAppUid.iUid); |
|
1604 TInt error=GetExecutableName(nativeExecutableName, logicalExecutableName, opaqueData, ipcArgs, EAppListServGetExecutableNameGivenAppUid); |
|
1605 if (error!=KErrNone) |
|
1606 { |
|
1607 return error; |
|
1608 } |
|
1609 error = StartApplicationPassingDocumentName(nativeExecutableName, logicalExecutableName, opaqueData, aFileName, aThreadId,EApaCommandOpen,NULL); |
|
1610 delete opaqueData; |
|
1611 if(error!=KErrNone && error!=KErrCancel) |
|
1612 { |
|
1613 error = StartAndCreate(EAppListServStartDocumentByUid,aFileName,aAppUid,aThreadId,aLaunchType); |
|
1614 } |
|
1615 return error; |
|
1616 } |
|
1617 |
|
1618 EXPORT_C TInt RApaLsSession::StartDocument(RFile& aFile, TUid aAppUid, TThreadId& aThreadId, TRequestStatus* aRequestStatusForRendezvous/*=NULL*/) |
|
1619 /** Finds and launches an application to handle the document contained in the specified file |
|
1620 |
|
1621 @param aFile The file handle. |
|
1622 @param aAppUid The application specific UID. |
|
1623 @param aThreadId On return, the id of the main thread started. |
|
1624 @param aRequestStatusForRendezvous If not NULL, the asynchronous RProcess::Rendezvous() |
|
1625 function is called (being passed this TRequestStatus object) before RProcess::Resume() is called on |
|
1626 the new application process. |
|
1627 @return KErrNone, if successful; KErrNotFound, if no suitable application can |
|
1628 be found; otherwise one of the other system-wide error codes. */ |
|
1629 { |
|
1630 TFileName nativeExecutableName; // the name of the EXE that we pass to RProcess::Create |
|
1631 TFileName logicalExecutableName; // the name of the MIDlet, Python script, etc |
|
1632 HBufC8* opaqueData=NULL; |
|
1633 TIpcArgs ipcArgs; |
|
1634 ipcArgs.Set(2, aAppUid.iUid); |
|
1635 TInt error=GetExecutableName(nativeExecutableName, logicalExecutableName, opaqueData, ipcArgs, EAppListServGetExecutableNameGivenAppUid); |
|
1636 if (error!=KErrNone) |
|
1637 { |
|
1638 return error; |
|
1639 } |
|
1640 error=StartApplicationPassingFileHandle(nativeExecutableName, logicalExecutableName, opaqueData, aFile, aThreadId, aRequestStatusForRendezvous); |
|
1641 delete opaqueData; |
|
1642 return error; |
|
1643 } //lint !e1764 Suppress reference parameter could be declared const ref |
|
1644 |
|
1645 |
|
1646 /** Launches the application identified by the specified UID and creates a new document. |
|
1647 |
|
1648 To create a document file with the passed document name, the application needs to override the 3-parameter |
|
1649 overload of ProcessCommandParametersL() to call the 2-parameter overload. |
|
1650 |
|
1651 Otherwise, a document will be created with the default document name present in the application resource file. |
|
1652 If default document name is empty or not provided, no document is created. |
|
1653 |
|
1654 If the application resource file is not present, a document with application caption name is created. |
|
1655 |
|
1656 @param aFileName The document name. |
|
1657 @param aAppUid The application specific UID. |
|
1658 @param aThreadId On return, the id of the main thread started. |
|
1659 @param aLaunchType Not used. Reserved for future use. |
|
1660 @return KErrNone, if successful; EAppListInvalid if the server's initial population of |
|
1661 the list has not completed; KErrNotFound, if no suitable application can |
|
1662 be found; otherwise one of the other system-wide error codes. |
|
1663 @see CEikAppUi::ProcessCommandParametersL(). |
|
1664 */ |
|
1665 EXPORT_C TInt RApaLsSession::CreateDocument(const TDesC& aFileName, TUid aAppUid, TThreadId& aThreadId, TLaunchType aLaunchType) |
|
1666 { |
|
1667 TFileName nativeExecutableName; // the name of the EXE that we pass to RProcess::Create |
|
1668 TFileName logicalExecutableName; // the name of the MIDlet, Python script, etc |
|
1669 HBufC8* opaqueData=NULL; |
|
1670 TIpcArgs ipcArgs; |
|
1671 ipcArgs.Set(2, aAppUid.iUid); |
|
1672 TInt error=GetExecutableName(nativeExecutableName, logicalExecutableName, opaqueData, ipcArgs, EAppListServGetExecutableNameGivenAppUid); |
|
1673 if (error!=KErrNone) |
|
1674 { |
|
1675 return error; |
|
1676 } |
|
1677 error = StartApplicationPassingDocumentName(nativeExecutableName, logicalExecutableName, opaqueData, aFileName, aThreadId,EApaCommandCreate,NULL); |
|
1678 delete opaqueData; |
|
1679 if(error!=KErrNone && error!=KErrCancel) |
|
1680 { |
|
1681 error = StartAndCreate(EAppListServCreateDocumentByUid,aFileName,aAppUid,aThreadId,aLaunchType); |
|
1682 } |
|
1683 return error; |
|
1684 } |
|
1685 |
|
1686 TInt RApaLsSession::StartAndCreate(TInt aRqst,const TDesC& aFileName, TUid aAppUid, TThreadId& aThreadId, TLaunchType /*aLaunchType*/) |
|
1687 { |
|
1688 TPckg<TThreadId> threadId(aThreadId); |
|
1689 return SendReceiveWithReconnect(aRqst,TIpcArgs(&threadId, &aFileName, aAppUid.iUid)); |
|
1690 } //lint !e1762 !e1764 |
|
1691 //Suppress reference parameter 'aThreadId' could be declared const ref |
|
1692 //Suppress member function could be made const |
|
1693 |
|
1694 |
|
1695 |
|
1696 |
|
1697 /** Gets the available icon sizes for the application with the specified UID. |
|
1698 |
|
1699 @param aAppUid The application specific UID. |
|
1700 @param aArrayToFill On return, the array contains all of the available icon |
|
1701 sizes. |
|
1702 @return KErrNone, if successful; KErrNotFound, if no matching application can |
|
1703 be found; KErrNotSupported, if the application provides icons in non-MBM format; |
|
1704 otherwise one of the other system wide error codes. |
|
1705 */ |
|
1706 EXPORT_C TInt RApaLsSession::GetAppIconSizes(TUid aAppUid, CArrayFixFlat<TSize>& aArrayToFill) const |
|
1707 { |
|
1708 TRAPD(error,DoGetAppIconSizesL(aAppUid,aArrayToFill)); |
|
1709 return error; |
|
1710 } |
|
1711 |
|
1712 void RApaLsSession::FetchArrayL(MArrayFiller& aArrayFiller,TUid aAppUid, TInt aOpcode, TInt aInitialBufSize) const |
|
1713 { |
|
1714 CBufFlat* buffer=CBufFlat::NewL(aInitialBufSize); |
|
1715 CleanupStack::PushL(buffer); |
|
1716 buffer->ExpandL(0,aInitialBufSize); |
|
1717 TPtr8 bufPtr=buffer->Ptr(0); |
|
1718 const TInt sizeRequired=User::LeaveIfError(SendReceiveWithReconnect(aOpcode,TIpcArgs(aAppUid.iUid,buffer->Size(),&bufPtr))); |
|
1719 if (sizeRequired>0) |
|
1720 { |
|
1721 __ASSERT_DEBUG(sizeRequired>buffer->Size(),User::Invariant()); |
|
1722 CleanupStack::PopAndDestroy(buffer); |
|
1723 buffer=CBufFlat::NewL(sizeRequired); |
|
1724 CleanupStack::PushL(buffer); |
|
1725 buffer->ExpandL(0,sizeRequired); |
|
1726 bufPtr.Set(buffer->Ptr(0)); |
|
1727 #if defined(_DEBUG) |
|
1728 const TInt check= |
|
1729 #endif |
|
1730 User::LeaveIfError(SendReceiveWithReconnect(aOpcode,TIpcArgs(aAppUid.iUid,buffer->Size(),&bufPtr))); |
|
1731 __ASSERT_DEBUG(check==0,User::Invariant()); |
|
1732 } |
|
1733 RBufReadStream readStream; |
|
1734 readStream.Open(*buffer); |
|
1735 const TInt count=readStream.ReadUint32L(); |
|
1736 for (TInt i=0; i<count; ++i) |
|
1737 { |
|
1738 aArrayFiller.AppendItemL(readStream); |
|
1739 } |
|
1740 CleanupStack::PopAndDestroy(buffer); |
|
1741 } |
|
1742 |
|
1743 void RApaLsSession::DoGetAppIconSizesL(TUid aAppUid, CArrayFixFlat<TSize>& aArrayToFill) const |
|
1744 { |
|
1745 TSizeArrayFiller arrayFiller(aArrayToFill); |
|
1746 FetchArrayL(arrayFiller, aAppUid, EAppListServGetAppIconSizes, KInitialIconBufSize); |
|
1747 } |
|
1748 |
|
1749 |
|
1750 |
|
1751 /** Gets the nearest matching application icon for the application with the specified |
|
1752 UID. |
|
1753 |
|
1754 The function gets the icon whose size matches the specified size. If there |
|
1755 is no exact match, then the function gets the closest smaller icon. |
|
1756 |
|
1757 This function should be used in preference to the TInt GetAppIcon(TUid,TInt,CApaMaskedBitmap&); |
|
1758 overload. |
|
1759 |
|
1760 @param aAppUid The application specific UID. |
|
1761 @param aSize The required size of the icon. |
|
1762 @param aAppBitmap On return, the application icon. |
|
1763 @return KErrNone, if successful; KErrNotFound, if a matching entry could not be found, or no |
|
1764 icon equal to or smaller than the specified size can be found; KErrNotSupported, if the |
|
1765 application provides icons in non-MBM format; otherwise one of the other system wide |
|
1766 error codes. |
|
1767 */ |
|
1768 EXPORT_C TInt RApaLsSession::GetAppIcon(TUid aAppUid, TSize aSize, CApaMaskedBitmap& aAppBitmap) const |
|
1769 { |
|
1770 SReturnData_AppIconByUidAndSize returnData = {0,0}; |
|
1771 TPckg<SReturnData_AppIconByUidAndSize> returnData_asDescriptor(returnData); |
|
1772 TInt error=SendReceiveWithReconnect(EAppListServAppIconByUidAndSize,TIpcArgs(aAppUid.iUid,aSize.iWidth,aSize.iHeight,&returnData_asDescriptor)); |
|
1773 if (error==KErrNone) |
|
1774 { |
|
1775 error=aAppBitmap.Duplicate(returnData.iIcon); |
|
1776 if (error==KErrNone) |
|
1777 { |
|
1778 error=aAppBitmap.Mask()->Duplicate(returnData.iIconMask); |
|
1779 } |
|
1780 } |
|
1781 return error; |
|
1782 } |
|
1783 |
|
1784 |
|
1785 |
|
1786 /** |
|
1787 gets the bitmap handles from the Server, forms these up into a CApaMaskedBitmap |
|
1788 |
|
1789 Sets aAppBitmap to be the small, medium or large app icon of the app with uid |
|
1790 aAppUid, when aSize=0, 1 or 2 respectively. |
|
1791 Panics the caller if a different index is specified. |
|
1792 The overload which takes a TSize should be used instead. |
|
1793 |
|
1794 @deprecated |
|
1795 @param aAppUid The application specific UID. |
|
1796 @param aSize The required size of the icon. |
|
1797 @param aAppBitmap On return, the application icon. |
|
1798 @return KErrNone, if successful; KErrNotFound, if a matching entry could not be found, or no |
|
1799 icon equal to or smaller than the specified size can be found; KErrNotSupported, if the |
|
1800 application provides icons in non-MBM format, otherwise one of the other system wide |
|
1801 error codes. |
|
1802 */ |
|
1803 EXPORT_C TInt RApaLsSession::GetAppIcon(TUid aAppUid, TInt aSize, CApaMaskedBitmap& aAppBitmap) const |
|
1804 { |
|
1805 __ASSERT_ALWAYS((aSize>=0) && (aSize<3), Panic(EDPanicBadIconSize)); |
|
1806 SReturnData_AppIconByUid returnData = {0,0}; |
|
1807 TPckg<SReturnData_AppIconByUid> returnData_asDescriptor(returnData); |
|
1808 TInt error=SendReceiveWithReconnect(EAppListServAppIconByUid,TIpcArgs(aAppUid.iUid,aSize,&returnData_asDescriptor)); |
|
1809 if (error==KErrNone) |
|
1810 { |
|
1811 error=aAppBitmap.Duplicate(returnData.iIcon); |
|
1812 if (error==KErrNone) |
|
1813 { |
|
1814 error=aAppBitmap.Mask()->Duplicate(returnData.iIconMask); |
|
1815 } |
|
1816 } |
|
1817 return error; |
|
1818 } |
|
1819 |
|
1820 |
|
1821 |
|
1822 EXPORT_C TInt RApaLsSession::GetAppIcon(TUid aAppUid, RFile& aFile) const |
|
1823 /** Gets an open shareable read only file handle to the application icon file for the |
|
1824 application with the specified UID. |
|
1825 |
|
1826 An icon file can only be defined by applications providing an application registration file. |
|
1827 |
|
1828 An icon file may be in any graphics format and contain one or more icons. |
|
1829 |
|
1830 On entering this function, aFile must be non-open. It is recommended that aFile is |
|
1831 pushed onto the cleanup-stack (via CleanupClosePushL()) before this function is called. |
|
1832 |
|
1833 @param aAppUid The application specific UID. |
|
1834 @param aFile On return, a read only open file handle to the icon file. |
|
1835 @return KErrNone, if successful; KErrNotFound, if a matching application could not be found, |
|
1836 or an icon filename was not defined; otherwise one of the other system wide error codes. |
|
1837 @see GetAppIcon |
|
1838 */ |
|
1839 { |
|
1840 __ASSERT_ALWAYS(aFile.SubSessionHandle() == KNullHandle, Panic(EDPanicHandleAlreadySet)); |
|
1841 TPckgBuf<TInt> fileHandle; |
|
1842 TInt sessionHandleOrErrorCode = SendReceiveWithReconnect(EAppListServAppIconFileHandle, TIpcArgs(aAppUid.iUid, &fileHandle)); |
|
1843 if (sessionHandleOrErrorCode >= KErrNone) |
|
1844 { |
|
1845 sessionHandleOrErrorCode = aFile.AdoptFromServer(sessionHandleOrErrorCode, fileHandle()); |
|
1846 } |
|
1847 return sessionHandleOrErrorCode; |
|
1848 } |
|
1849 |
|
1850 |
|
1851 |
|
1852 EXPORT_C TInt RApaLsSession::AppForDocument(const TDesC& aFileName, TUid& aAppUid, TDataType& aDataType) const |
|
1853 /** Gets the data (MIME) type of the data in the specified file and gets the UID |
|
1854 of an application that can handle this type. |
|
1855 |
|
1856 @param aFileName The name of the file containing the data. |
|
1857 @param aAppUid On return, the UID of the application that can handle the data |
|
1858 (MIME) type; this may be NULL. |
|
1859 @param aDataType On return, the data (MIME) type. |
|
1860 @return KErrNone, if successful; otherwise one of the other system-wide error |
|
1861 codes. */ |
|
1862 { |
|
1863 return DoAppForDocumentOptionallySpecifyingService(aFileName, TUid::Null(), aAppUid, aDataType, EAppListServAppForDocument); |
|
1864 } |
|
1865 |
|
1866 |
|
1867 /** Gets the data (MIME) type of the data in the specified file and gets the UID |
|
1868 of an application that can handle this type. |
|
1869 |
|
1870 @param aFile The file containing the data. Before this function can be called, |
|
1871 the file server session which owns this file handle must first be marked as shareable by |
|
1872 calling RFs::ShareProtected(). |
|
1873 @param aAppUid On return, the UID of the application that can handle the data |
|
1874 (MIME) type; this may be NULL. |
|
1875 @param aDataType On return, the data (MIME) type. |
|
1876 @return KErrNone, if successful; otherwise one of the other system-wide error |
|
1877 codes. |
|
1878 */ |
|
1879 EXPORT_C TInt RApaLsSession::AppForDocument(const RFile& aFile, TUid& aAppUid, TDataType& aDataType) const |
|
1880 { |
|
1881 return DoAppForDocumentOptionallySpecifyingService(aFile, TUid::Null(), aAppUid, aDataType, EAppListServAppForDocumentPassedByFileHandle); |
|
1882 } |
|
1883 |
|
1884 /** Tests whether the file is a native executable (DLL or EXE). |
|
1885 |
|
1886 @param aFileName The name of the file containing the data. |
|
1887 @param aProgram On return, true, if the file contains application code; false, |
|
1888 otherwise. |
|
1889 @return KErrNone, if successful; otherwise one of the other system-wide error |
|
1890 codes. |
|
1891 */ |
|
1892 EXPORT_C TInt RApaLsSession::IsProgram(const TDesC& aFileName, TBool& aProgram) const |
|
1893 { |
|
1894 _LIT(KLitSysBin, "\\sys\\bin\\"); |
|
1895 aProgram=(TParsePtrC(aFileName).Path().CompareF(KLitSysBin)==0); |
|
1896 return KErrNone; |
|
1897 } |
|
1898 |
|
1899 /** Gets the confidence threshold for successful data recognition. |
|
1900 |
|
1901 This is the minimum acceptable confidence level that must be reported by a |
|
1902 data recognizer for data to be accepted as of a given type. |
|
1903 |
|
1904 @param aConfidence On return, the confidence threshold. |
|
1905 @return KErrNone, if successful; otherwise one of the other system-wide error |
|
1906 codes. |
|
1907 */ |
|
1908 EXPORT_C TInt RApaLsSession::GetAcceptedConfidence(TInt& aConfidence) const |
|
1909 { |
|
1910 TPckg<TInt> confidence(aConfidence); |
|
1911 return SendReceiveWithReconnect(EAppListServGetConfidence,TIpcArgs(&confidence)); |
|
1912 } //lint !e1764 Suppress reference parameter could be declared const ref |
|
1913 |
|
1914 |
|
1915 |
|
1916 /** Sets the confidence threshold for successful data recognition. |
|
1917 |
|
1918 This is the minimum acceptable confidence level that must be reported by a |
|
1919 data recognizer for data to be accepted as of a given type. |
|
1920 |
|
1921 @param aConfidence The confidence threshold. Although this is an integer value, |
|
1922 data recognizers use the discrete values defined by the CApaDataRecognizerType::TRecognitionConfidence |
|
1923 enumeration. |
|
1924 @return KErrNone, if successful; otherwise one of the other system-wide error |
|
1925 codes. |
|
1926 @capability WriteDeviceData |
|
1927 */ |
|
1928 EXPORT_C TInt RApaLsSession::SetAcceptedConfidence(TInt aConfidence) |
|
1929 { |
|
1930 return SendReceiveWithReconnect(EAppListServSetConfidence,TIpcArgs(aConfidence)); |
|
1931 } //lint !e1762 Suppress member function could be made const |
|
1932 |
|
1933 |
|
1934 EXPORT_C TInt RApaLsSession::GetPreferredBufSize(TInt& aPreferredBufSize) const |
|
1935 /** Gets the preferred number of bytes of data to read from a file for the purpose |
|
1936 of recognizing the data type. |
|
1937 |
|
1938 This should be used to determine the size of buffer to pass to the 3-parameter |
|
1939 overload of RecognizeData() or to the 4-parameter overload of RecognizeSpecificData(). |
|
1940 |
|
1941 @param aPreferredBufSize On return, contains either the largest buffer size required |
|
1942 by any of the currently installed data-recognizers, or the value that would be |
|
1943 returned by GetMaxDataBufSize(), whichever is less. |
|
1944 @return KErrNone, if successful; otherwise one of the other system-wide error |
|
1945 codes. |
|
1946 @see GetMaxDataBufSize() */ |
|
1947 { |
|
1948 const TInt preferredBufSize=SendReceiveWithReconnect(EAppListServPreferredBufSize, TIpcArgs()); |
|
1949 if (preferredBufSize<KErrNone) |
|
1950 { |
|
1951 return preferredBufSize; // it's an error |
|
1952 } |
|
1953 aPreferredBufSize=preferredBufSize; |
|
1954 return KErrNone; |
|
1955 } |
|
1956 |
|
1957 EXPORT_C TInt RApaLsSession::GetMaxDataBufSize(TInt& aBufSize) const |
|
1958 /** Gets the maximum size of the data that can be read from a file for the purpose |
|
1959 of recognizing the data type. |
|
1960 |
|
1961 To determine the size of buffer to pass to the 3-parameter overload of RecognizeData() |
|
1962 or to the 4-parameter overload of RecognizeSpecificData(), use GetPreferredBufSize() |
|
1963 rather than this function. |
|
1964 |
|
1965 @param aBufSize On return, contains the maximum size. |
|
1966 @return KErrNone, if successful; otherwise one of the other system-wide error |
|
1967 codes. |
|
1968 @see SetMaxDataBufSize() |
|
1969 @see GetPreferredBufSize() */ |
|
1970 { |
|
1971 const TInt returnValue=SendReceiveWithReconnect(EAppListServGetBufSize,TIpcArgs()); |
|
1972 if (returnValue<0) |
|
1973 { |
|
1974 return returnValue; |
|
1975 } |
|
1976 aBufSize=returnValue; |
|
1977 return KErrNone; |
|
1978 } |
|
1979 |
|
1980 |
|
1981 |
|
1982 /** Sets the maximum size of the data that can be read from a file for the purpose |
|
1983 of recognizing the data type. |
|
1984 |
|
1985 The value is not used when the client explicitly supplies a buffer, for example |
|
1986 in calls to RecognizeData() and RecognizeSpecificData(), but is used in the |
|
1987 implementation of functions such as StartDocument() and CreateDocument(). |
|
1988 |
|
1989 Unless explicitly set, a default value of KApaAppListServMaxBuffer is used. |
|
1990 |
|
1991 @param aBufSize The maximum size of data to be read. |
|
1992 @return KErrNone, if successful; otherwise one of the other system-wide error |
|
1993 codes. |
|
1994 @see CreateDocument() |
|
1995 @see StartDocument() |
|
1996 @see RecognizeData() |
|
1997 @see RecognizeSpecificData() |
|
1998 */ |
|
1999 EXPORT_C TInt RApaLsSession::SetMaxDataBufSize(TInt aBufSize) |
|
2000 { |
|
2001 return SendReceiveWithReconnect(EAppListServSetBufSize,TIpcArgs(aBufSize)); |
|
2002 } //lint !e1762 Suppress member function could be made const |
|
2003 |
|
2004 |
|
2005 |
|
2006 /** Gets a list of recognized data(MIME) types by all recognizers. |
|
2007 |
|
2008 @param aDataTypes The array of data (MIME) types. |
|
2009 @return KErrNone, if successful; otherwise one of the other system-wide error |
|
2010 codes. |
|
2011 */ |
|
2012 EXPORT_C TInt RApaLsSession::GetSupportedDataTypesL(CDataTypeArray& aDataTypes) const |
|
2013 { |
|
2014 // gets the datatype count in terms of buffer length; negative value means one of the system-wide error |
|
2015 TInt ret=SendReceiveWithReconnect(EAppListServGetDataTypesPhase1,TIpcArgs()); |
|
2016 if (ret>0) |
|
2017 { |
|
2018 CBufFlat* const buf=CBufFlat::NewL(ret); |
|
2019 CleanupStack::PushL(buf); |
|
2020 buf->ExpandL(0,ret); |
|
2021 TPtr8 ptr=buf->Ptr(0); |
|
2022 ret=SendReceiveWithReconnect(EAppListServGetDataTypesPhase2,TIpcArgs(&ptr)); |
|
2023 if (ret==KErrNone) |
|
2024 { |
|
2025 RBufReadStream readStream(*buf); |
|
2026 readStream >> aDataTypes; |
|
2027 } |
|
2028 CleanupStack::PopAndDestroy(buf); |
|
2029 } |
|
2030 return ret; |
|
2031 } |
|
2032 |
|
2033 |
|
2034 |
|
2035 /** Gets the icon for the specified view published by the application that has |
|
2036 the specified UID. |
|
2037 |
|
2038 The icon returned is that which is closest in size to the specified size. |
|
2039 |
|
2040 @param aAppUid The application specific UID. |
|
2041 @param aViewUid The UID identifying the view. |
|
2042 @param aSize The requested size of the icon. |
|
2043 @param aViewBitmap On return, the icon that is closest in size to the requested |
|
2044 size. |
|
2045 @return KErrNone, if successful; KErrNotFound, if no matching application nor matching view |
|
2046 can be found; KErrNotSupported, if the application provides icons in non-MBM format; |
|
2047 otherwise one of the other system wide error codes. |
|
2048 */ |
|
2049 EXPORT_C TInt RApaLsSession::GetAppViewIcon(TUid aAppUid, TUid aViewUid, const TSize& aSize, CApaMaskedBitmap& aViewBitmap) const |
|
2050 { |
|
2051 const TApaAppViewIconSizeData appViewIconSizeData(aAppUid, aViewUid, aSize); |
|
2052 const TPckgC<TApaAppViewIconSizeData> inputData(appViewIconSizeData); |
|
2053 SReturnData_ViewIconByUidAndSize returnData = {0,0}; |
|
2054 TPckg<SReturnData_ViewIconByUidAndSize> returnData_asDescriptor(returnData); |
|
2055 TInt error=SendReceiveWithReconnect(EAppListServViewIconByUidAndSize,TIpcArgs(&inputData,&returnData_asDescriptor)); |
|
2056 if (error==KErrNone) |
|
2057 { |
|
2058 error=aViewBitmap.Duplicate(returnData.iIcon); |
|
2059 if (error==KErrNone) |
|
2060 { |
|
2061 error=aViewBitmap.Mask()->Duplicate(returnData.iIconMask); |
|
2062 } |
|
2063 } |
|
2064 return error; |
|
2065 } |
|
2066 |
|
2067 |
|
2068 |
|
2069 /** Gets the views published by the application that has the specified UID. |
|
2070 |
|
2071 Information on each view is contained in a TApaAppViewInfo object, and this |
|
2072 set of objects is put into the array supplied by the caller. |
|
2073 |
|
2074 @param aAppViews On return, the array contains information on all of the views |
|
2075 published by the specified application. |
|
2076 @param aAppUid The application specific UID. |
|
2077 @return KErrNone, if successful; KErrNotFound, if no matching application can |
|
2078 be found; otherwise one of the other system wide error codes. |
|
2079 @see TApaAppViewInfo |
|
2080 */ |
|
2081 EXPORT_C TInt RApaLsSession::GetAppViews(CApaAppViewArray& aAppViews, TUid aAppUid) const |
|
2082 { |
|
2083 TRAPD(error,DoGetAppViewsL(aAppViews,aAppUid)); |
|
2084 return error; |
|
2085 } |
|
2086 |
|
2087 void RApaLsSession::DoGetAppViewsL(CApaAppViewArray& aArrayToFill, TUid aAppUid) const |
|
2088 { |
|
2089 TViewDataArrayFiller arrayFiller(aArrayToFill); |
|
2090 FetchArrayL(arrayFiller, aAppUid, EAppListServGetAppViews, KInitialViewDataBufSize); |
|
2091 } |
|
2092 |
|
2093 |
|
2094 |
|
2095 /** Gets the list of file names for which the application with the specified |
|
2096 UID claims ownership. |
|
2097 |
|
2098 The list is written to a descriptor array supplied by the caller. |
|
2099 |
|
2100 Note that if the function fails due to lack of memory, the array is left in |
|
2101 an undefined state. |
|
2102 |
|
2103 @param aAppOwnedFiles On return, the descriptor array contains the file names. |
|
2104 @param aAppUid The application specific UID. |
|
2105 @return KErrNone, if successful; KErrNotFound, if no matching application can |
|
2106 be found; otherwise one of the other system wide error codes. |
|
2107 */ |
|
2108 EXPORT_C TInt RApaLsSession::GetAppOwnedFiles(CDesCArray& aAppOwnedFiles, TUid aAppUid) const |
|
2109 { |
|
2110 TRAPD(error,DoGetAppOwnedFilesL(aAppOwnedFiles,aAppUid)); |
|
2111 return error; |
|
2112 } |
|
2113 |
|
2114 |
|
2115 |
|
2116 /** Gets the number of icons defined by the app that has the specified UID |
|
2117 |
|
2118 Applications that don't define icons in their application information file will |
|
2119 return an aCount value of zero when this function is called. |
|
2120 |
|
2121 @param aAppUid The application specific UID |
|
2122 @param aCount On return, contains the number of icons defined by the application |
|
2123 @return KErrNone, if successful; KErrNotFound, if a matching application could not be found; |
|
2124 KErrNotSupported, if the application provides icons in non-MBM format; otherwise one of |
|
2125 the other system-wide error codes. |
|
2126 */ |
|
2127 EXPORT_C TInt RApaLsSession::NumberOfOwnDefinedIcons(TUid aAppUid, TInt& aCount) const |
|
2128 { |
|
2129 TPckgBuf<TInt> pckg; |
|
2130 TInt ret=SendReceiveWithReconnect(EAppListServNumberOfOwnDefinedIcons,TIpcArgs(aAppUid.iUid,&pckg)); |
|
2131 if (ret==KErrNone) |
|
2132 { |
|
2133 aCount=pckg(); |
|
2134 } |
|
2135 return ret; |
|
2136 } |
|
2137 |
|
2138 |
|
2139 |
|
2140 /** Gets the full filename of a file containing application icons for the |
|
2141 application with the specified UID. |
|
2142 |
|
2143 An icon file can only be defined by applications providing an application registration file. |
|
2144 |
|
2145 An icon file may be in any graphics format and contain one or more icons. |
|
2146 |
|
2147 @param aAppUid The application specific UID. |
|
2148 @param aFullFileName On return, the full filename of a file containing one or more |
|
2149 application icons. Returns a pointer to the filename and transfers ownership to the caller. |
|
2150 @return KErrNone, if successful; KErrNotFound, if a matching application could not be found, |
|
2151 or an icon filename was not defined; KErrNotSupported, if the application does not |
|
2152 provide an application registration file; otherwise one of the other system wide error codes. |
|
2153 */ |
|
2154 EXPORT_C TInt RApaLsSession::GetAppIcon(TUid aAppUid, HBufC*& aFullFileName) const |
|
2155 { |
|
2156 TFileName fileName; |
|
2157 TPckg<TFileName> filenamePckg(fileName); |
|
2158 TInt ret=SendReceiveWithReconnect(EAppListServAppIconFileName, TIpcArgs(aAppUid.iUid, &filenamePckg)); |
|
2159 if (ret==KErrNone) |
|
2160 { |
|
2161 HBufC* fullFileName = HBufC::New(fileName.Length()); |
|
2162 if (fullFileName == NULL) |
|
2163 { |
|
2164 return KErrNoMemory; |
|
2165 } |
|
2166 else |
|
2167 { |
|
2168 *fullFileName = fileName; |
|
2169 aFullFileName = fullFileName; // ownership transferred to caller |
|
2170 } |
|
2171 } |
|
2172 return ret; |
|
2173 } |
|
2174 |
|
2175 |
|
2176 |
|
2177 /** Gets the full filename of a file containing view-specific icons for the application |
|
2178 with the specified UID and view. |
|
2179 |
|
2180 A file containing view-specific icons can only be defined by applications providing |
|
2181 an application registration file. |
|
2182 |
|
2183 A view icon file may be in any graphics format and contain one or more view icons. |
|
2184 |
|
2185 @param aAppUid The application specific UID. |
|
2186 @param aViewUid The UID identifying the view. |
|
2187 @param aFullFileName On return, the full filename of a file containing one or more |
|
2188 view icons. Returns a pointer to the filename and transfers ownership to the caller. |
|
2189 @return KErrNone, if successful; KErrNotFound, if no matching application nor matching view |
|
2190 could be found, or a view icon filename was not defined; KErrNotSupported, if the application |
|
2191 does not provide an application registration file; otherwise one of the other system wide error codes. |
|
2192 */ |
|
2193 EXPORT_C TInt RApaLsSession::GetAppViewIcon(TUid aAppUid, TUid aViewUid, HBufC*& aFullFileName) const |
|
2194 { |
|
2195 TFileName fileName; |
|
2196 TPckg<TFileName> filenamePckg(fileName); |
|
2197 TInt ret=SendReceiveWithReconnect(EAppListServAppViewIconFileName, TIpcArgs(aAppUid.iUid, aViewUid.iUid, &filenamePckg)); |
|
2198 if (ret==KErrNone) |
|
2199 { |
|
2200 HBufC* fullFileName = HBufC::New(fileName.Length()); |
|
2201 if (fullFileName == NULL) |
|
2202 { |
|
2203 return KErrNoMemory; |
|
2204 } |
|
2205 else |
|
2206 { |
|
2207 *fullFileName = fileName; |
|
2208 aFullFileName = fullFileName; // ownership transferred to caller |
|
2209 } |
|
2210 } |
|
2211 return ret; |
|
2212 } |
|
2213 |
|
2214 |
|
2215 |
|
2216 /** Changes an existing data type mapping, or adds a new one. |
|
2217 |
|
2218 If the data type is not currently mapped, a new mapping is added. |
|
2219 If the data type is mapped, its mapping is replaced. |
|
2220 |
|
2221 @capability WriteDeviceData Prevent addition of data type mappings by malicious programs. |
|
2222 @param aDataType A new or existing data type. |
|
2223 @param aPriority The priority with which the application handles the data type. |
|
2224 @param aUid The UID of the application to associate with the data type. |
|
2225 @return KErrNone on success, or a system-wide error code. |
|
2226 */ |
|
2227 EXPORT_C TInt RApaLsSession::InsertDataMapping(const TDataType& aDataType, TDataTypePriority aPriority, TUid aUid) |
|
2228 { |
|
2229 return InsertDataMapping(aDataType, aPriority, aUid, KOpenServiceUid); |
|
2230 } |
|
2231 |
|
2232 /** Changes an existing data type mapping, or adds a new one. |
|
2233 |
|
2234 If the data type is not currently mapped, a new mapping is added. |
|
2235 If the data type is mapped, its mapping is replaced. |
|
2236 |
|
2237 @capability WriteDeviceData Prevent addition of data type mappings by malicious programs. |
|
2238 @param aDataType A new or existing data type. |
|
2239 @param aPriority The priority with which the application handles the data type. |
|
2240 @param aUid The UID of the application to associate with the data type. |
|
2241 @param aServiceUid The UID of the service. |
|
2242 @return KErrNone on success, or a system-wide error code. |
|
2243 */ |
|
2244 EXPORT_C TInt RApaLsSession::InsertDataMapping(const TDataType& aDataType, TDataTypePriority aPriority, |
|
2245 TUid aUid, TUid aServiceUid) |
|
2246 { |
|
2247 const TPckgC<TDataType> dataType(aDataType); |
|
2248 return SendReceiveWithReconnect(EAppListInsertDataMapping, |
|
2249 TIpcArgs(&dataType, TInt(aPriority), aUid.iUid, aServiceUid.iUid)); |
|
2250 } //lint !e1762 Suppress member function could be made const |
|
2251 |
|
2252 /** Changes an existing data type mapping, or adds a new one. |
|
2253 If the data type is not currently mapped, it is added. |
|
2254 If the data type is mapped with a priority lower than aPriority, the new mapping replaces the existing one. |
|
2255 Otherwise, no change is made. |
|
2256 |
|
2257 @capability WriteDeviceData Prevent addition of data type mappings by malicious programs. |
|
2258 @param aDataType A new or existing data type. |
|
2259 @param aPriority The priority with which the application handles the data type. |
|
2260 @param aUid The UID of the application to associate with the data type. |
|
2261 @param aInserted Non-zero if the new mapping was added or an existing mapping replaced, zero otherwise. |
|
2262 @return KErrNone on success, or a system-wide error code. |
|
2263 */ |
|
2264 EXPORT_C TInt RApaLsSession::InsertDataMappingIfHigher(const TDataType& aDataType, TDataTypePriority aPriority, TUid aUid, TBool& aInserted) |
|
2265 { |
|
2266 TPckgBuf<TBool> inserted(EFalse); |
|
2267 const TPckgC<TDataType> dataType(aDataType); |
|
2268 const TInt ret = SendReceiveWithReconnect(EAppListInsertDataMappingIfHigher, TIpcArgs(&dataType, TInt(aPriority), aUid.iUid, &inserted)); |
|
2269 if(ret == KErrNone) |
|
2270 { |
|
2271 aInserted = inserted(); |
|
2272 } |
|
2273 return ret; |
|
2274 } //lint !e1762 Suppress member function could be made const |
|
2275 |
|
2276 |
|
2277 |
|
2278 /** Removes an existing user mapping between an application and data-type made through InsertDataMapping() or InsertDataMappingIfHigher(). |
|
2279 |
|
2280 @capability WriteDeviceData Prevent removal of data type mappings by malicious programs. |
|
2281 @param aDataType Data type whose mapping should be removed. |
|
2282 @panic USER 0 The specified data type cannot be found. Debug builds only. |
|
2283 @return KErrNone on success, or a system-wide error code. |
|
2284 @see InsertDataMapping() |
|
2285 @see InsertDataMappingIfHigher() |
|
2286 */ |
|
2287 EXPORT_C TInt RApaLsSession::DeleteDataMapping(const TDataType& aDataType) |
|
2288 { |
|
2289 return DeleteDataMapping(aDataType, KOpenServiceUid); |
|
2290 } |
|
2291 |
|
2292 /** Removes an existing data type mapping. |
|
2293 |
|
2294 @capability WriteDeviceData Prevent removal of data type mappings by malicious programs. |
|
2295 @param aDataType Data type whose mapping should be removed. |
|
2296 @param aServiceUid The UID of the service. |
|
2297 @panic USER 0 The specified data type cannot be found. Debug builds only. |
|
2298 @return KErrNone on success, or a system-wide error code. |
|
2299 */ |
|
2300 EXPORT_C TInt RApaLsSession::DeleteDataMapping(const TDataType& aDataType, TUid aServiceUid) |
|
2301 { |
|
2302 const TPckgC<TDataType> dataType(aDataType); |
|
2303 return SendReceiveWithReconnect(EAppListDeleteDataMapping, TIpcArgs(&dataType, aServiceUid.iUid)); |
|
2304 } //lint !e1762 Suppress member function could be made const |
|
2305 |
|
2306 /** Gets the application associated with the data type and the service uid from |
|
2307 the datatype store. |
|
2308 |
|
2309 The function will only look into the datatype store and will not use the |
|
2310 default type associations. This is different from the AppForDataTypeAndService() function. |
|
2311 |
|
2312 @param aDataType The data (MIME) type. |
|
2313 @param aAppUid On return, the UID of the application that can handle the data |
|
2314 (MIME) type; this may be NULL. |
|
2315 @param aServiceUid The UID of the service. |
|
2316 @return KErrNone, if successful; otherwise one of the other system-wide error |
|
2317 codes. |
|
2318 */ |
|
2319 EXPORT_C TInt RApaLsSession::GetAppByDataType(const TDataType& aDataType, TUid aServiceUid, TUid& aAppUid) const |
|
2320 { |
|
2321 const TPckgC<TDataType> dataType(aDataType); |
|
2322 TPckg<TUid> uid(aAppUid); |
|
2323 const TInt returnValue=SendReceiveWithReconnect(EAppListServGetAppByDataType,TIpcArgs(&dataType, aServiceUid.iUid, &uid)); |
|
2324 if (returnValue<0) |
|
2325 { |
|
2326 return returnValue; |
|
2327 } |
|
2328 if (aAppUid == KNullUid) |
|
2329 { |
|
2330 return KErrNotFound; |
|
2331 } |
|
2332 else |
|
2333 { |
|
2334 return KErrNone; |
|
2335 } |
|
2336 } //lint !e1764 Suppress reference parameter 'aAppUid' could be declared const ref |
|
2337 |
|
2338 /** Determines the current language an application is using to display its |
|
2339 user interface. |
|
2340 @param aAppUid The application specific UID. |
|
2341 @param aLanguage On return, the application language. |
|
2342 @return KErrNone, if successful; KErrNotFound, if a matching application could not be found; |
|
2343 otherwise one of the other system wide error codes. |
|
2344 */ |
|
2345 EXPORT_C TInt RApaLsSession::ApplicationLanguage(TUid aAppUid, TLanguage& aLanguage) const |
|
2346 { |
|
2347 TPckgBuf<TLanguage> pckg; |
|
2348 TInt errVal = SendReceiveWithReconnect(EAppListServApplicationLanguage, TIpcArgs(aAppUid.iUid, &pckg)); |
|
2349 if (errVal == KErrNone) |
|
2350 { |
|
2351 aLanguage = pckg(); |
|
2352 } |
|
2353 return errVal; |
|
2354 } |
|
2355 |
|
2356 /** Gets the services implemented by the application that has the specified |
|
2357 application UID. |
|
2358 |
|
2359 The returned CApaAppServiceInfoArray object contains an array of TApaAppServiceInfo objects. |
|
2360 |
|
2361 Information on each service implementation is contained in a TApaAppServiceInfo object. |
|
2362 |
|
2363 TApaAppServiceInfo::Uid() returns the service UID of the service implemented by the |
|
2364 specified application UID. |
|
2365 |
|
2366 @param aAppUid The application specific UID. |
|
2367 @return A pointer to a CApaAppServiceInfoArray object left on the cleanup stack. |
|
2368 @leave KErrNotFound No matching application can be found, or a matching application |
|
2369 does not implement any services. |
|
2370 @leave KErrNotSupported The specified application does not provide an application |
|
2371 registration file. |
|
2372 @leave KErrNoMemory There is insufficient memory to perform the operation. |
|
2373 @see CApaAppServiceInfoArray::Array() |
|
2374 @see TApaAppServiceInfo |
|
2375 @publishedPartner |
|
2376 @released |
|
2377 */ |
|
2378 EXPORT_C CApaAppServiceInfoArray* RApaLsSession::GetAppServicesLC(TUid aAppUid) const |
|
2379 { |
|
2380 CArrayFixFlat<TApaAppServiceInfo>* serviceArray = new(ELeave) CArrayFixFlat<TApaAppServiceInfo>(4); |
|
2381 CleanupStack::PushL(TCleanupItem(CleanupServiceArray, serviceArray)); |
|
2382 CBufBase* buffer = GetServiceBufferLC(EAppListServGetAppServices, aAppUid); |
|
2383 RBufReadStream readStream(*buffer); |
|
2384 readStream >> *serviceArray; |
|
2385 CleanupStack::PopAndDestroy(buffer); |
|
2386 CleanupStack::Pop(serviceArray); |
|
2387 CApaAppServiceInfoArrayWrapper* wrapper = CApaAppServiceInfoArrayWrapper::NewL(serviceArray); // takes ownership of serviceArray |
|
2388 CleanupStack::PushL(wrapper); |
|
2389 return wrapper; |
|
2390 } |
|
2391 |
|
2392 CBufBase* RApaLsSession::GetServiceBufferLC(TInt aOpcode, TUid aUid1, TUid aUid2/*=KNullUid*/) const |
|
2393 { |
|
2394 CBufFlat* buffer=CBufFlat::NewL(KDefaultBufSize); // allocate buffer with a default size that should be large enough in most cases |
|
2395 CleanupStack::PushL(buffer); |
|
2396 buffer->ExpandL(0,KDefaultBufSize); |
|
2397 TPtr8 bufPtr=buffer->Ptr(0); |
|
2398 const TInt sizeRequired=User::LeaveIfError(SendReceiveWithReconnect(aOpcode,TIpcArgs(aUid1.iUid,aUid2.iUid,buffer->Size(),&bufPtr))); |
|
2399 if (sizeRequired>0) |
|
2400 { |
|
2401 CleanupStack::PopAndDestroy(buffer); |
|
2402 buffer=CBufFlat::NewL(sizeRequired); |
|
2403 CleanupStack::PushL(buffer); |
|
2404 buffer->ExpandL(0,sizeRequired); |
|
2405 bufPtr.Set(buffer->Ptr(0)); |
|
2406 #if defined(_DEBUG) |
|
2407 const TInt check= |
|
2408 #endif |
|
2409 User::LeaveIfError(SendReceiveWithReconnect(aOpcode,TIpcArgs(aUid1.iUid,aUid2.iUid,0,&bufPtr))); |
|
2410 __ASSERT_DEBUG(check==0,User::Invariant()); |
|
2411 } |
|
2412 return buffer; |
|
2413 } |
|
2414 |
|
2415 CBufBase* RApaLsSession::GetServiceBufferLC(TInt aOpcode, TUid aUid1, const TDataType& aDataType) const |
|
2416 { |
|
2417 const TPckgC<TDataType> dataType(aDataType); |
|
2418 CBufFlat* buffer=CBufFlat::NewL(KDefaultBufSize); // allocate buffer with a default size that should be large enough in most cases |
|
2419 CleanupStack::PushL(buffer); |
|
2420 buffer->ExpandL(0,KDefaultBufSize); |
|
2421 TPtr8 bufPtr=buffer->Ptr(0); |
|
2422 const TInt sizeRequired=User::LeaveIfError(SendReceiveWithReconnect(aOpcode,TIpcArgs(aUid1.iUid,&dataType,buffer->Size(),&bufPtr))); |
|
2423 if (sizeRequired>0) |
|
2424 { |
|
2425 CleanupStack::PopAndDestroy(buffer); |
|
2426 buffer=CBufFlat::NewL(sizeRequired); |
|
2427 CleanupStack::PushL(buffer); |
|
2428 buffer->ExpandL(0,sizeRequired); |
|
2429 bufPtr.Set(buffer->Ptr(0)); |
|
2430 #if defined(_DEBUG) |
|
2431 const TInt check= |
|
2432 #endif |
|
2433 User::LeaveIfError(SendReceiveWithReconnect(aOpcode,TIpcArgs(aUid1.iUid,&dataType,0,&bufPtr))); |
|
2434 __ASSERT_DEBUG(check==0,User::Invariant()); |
|
2435 } |
|
2436 return buffer; |
|
2437 } |
|
2438 |
|
2439 |
|
2440 |
|
2441 /** Gets the service implementations for the specified service UID. |
|
2442 |
|
2443 The returned CApaAppServiceInfoArray object contains an array of TApaAppServiceInfo objects. |
|
2444 |
|
2445 Information on each implementation is contained in a TApaAppServiceInfo object. |
|
2446 |
|
2447 TApaAppServiceInfo::Uid() returns the UID of the application that implements the |
|
2448 specified service UID. |
|
2449 |
|
2450 @param aServiceUid The service UID. |
|
2451 @return A pointer to a CApaAppServiceInfoArray object left on the cleanup stack. |
|
2452 @leave KErrNotFound No service implementations for the specified service UID can be found. |
|
2453 @leave EAppListInvalid The server's initial population of the list has not completed. |
|
2454 @leave KErrNoMemory There is insufficient memory to perform the operation. |
|
2455 @see CApaAppServiceInfoArray::Array() |
|
2456 @see TApaAppServiceInfo |
|
2457 @publishedPartner |
|
2458 @released |
|
2459 */ |
|
2460 EXPORT_C CApaAppServiceInfoArray* RApaLsSession::GetServiceImplementationsLC(TUid aServiceUid) const |
|
2461 { |
|
2462 CArrayFixFlat<TApaAppServiceInfo>* serviceArray = new(ELeave) CArrayFixFlat<TApaAppServiceInfo>(4); |
|
2463 CleanupStack::PushL(TCleanupItem(CleanupServiceArray, serviceArray)); |
|
2464 CBufBase* buffer = GetServiceBufferLC(EAppListServGetServiceImplementations, aServiceUid); |
|
2465 RBufReadStream readStream(*buffer); |
|
2466 readStream >> *serviceArray; |
|
2467 CleanupStack::PopAndDestroy(buffer); |
|
2468 CleanupStack::Pop(serviceArray); |
|
2469 CApaAppServiceInfoArrayWrapper* wrapper = CApaAppServiceInfoArrayWrapper::NewL(serviceArray); // takes ownership of serviceArray |
|
2470 CleanupStack::PushL(wrapper); |
|
2471 return wrapper; |
|
2472 } |
|
2473 |
|
2474 EXPORT_C CApaAppServiceInfoArray* RApaLsSession::GetServiceImplementationsLC(TUid aServiceUid, const TDataType& aDataType) const |
|
2475 /** Gets the service implementations for the specified service UID. The implementation must also be |
|
2476 able to handle the data type given as argument. |
|
2477 |
|
2478 The returned CApaAppServiceInfoArray object contains an array of TApaAppServiceInfo objects. |
|
2479 |
|
2480 Information on each implementation is contained in a TApaAppServiceInfo object. |
|
2481 |
|
2482 TApaAppServiceInfo::Uid() returns the UID of the application that implements the |
|
2483 specified service UID. |
|
2484 |
|
2485 @param aServiceUid The service UID. |
|
2486 @param aDataType The data type that must be supported by the implementation. |
|
2487 @return A pointer to a CApaAppServiceInfoArray object left on the cleanup stack. |
|
2488 @leave KErrNotFound No service implementations for the specified service UID can be found. |
|
2489 @leave EAppListInvalid The server's initial population of the list has not completed. |
|
2490 @leave KErrNoMemory There is insufficient memory to perform the operation. |
|
2491 @see CApaAppServiceInfoArray::Array() |
|
2492 @see TApaAppServiceInfo |
|
2493 @publishedPartner |
|
2494 @released |
|
2495 */ |
|
2496 { |
|
2497 CArrayFixFlat<TApaAppServiceInfo>* serviceArray = new(ELeave) CArrayFixFlat<TApaAppServiceInfo>(4); |
|
2498 CleanupStack::PushL(TCleanupItem(CleanupServiceArray, serviceArray)); |
|
2499 CBufBase* buffer = GetServiceBufferLC(EAppListServGetServiceImplementationsDataType, aServiceUid, aDataType); |
|
2500 RBufReadStream readStream(*buffer); |
|
2501 readStream >> *serviceArray; |
|
2502 CleanupStack::PopAndDestroy(buffer); |
|
2503 CleanupStack::Pop(serviceArray); |
|
2504 CApaAppServiceInfoArrayWrapper* wrapper = CApaAppServiceInfoArrayWrapper::NewL(serviceArray); // takes ownership of serviceArray |
|
2505 CleanupStack::PushL(wrapper); |
|
2506 return wrapper; |
|
2507 } |
|
2508 |
|
2509 /** Gets the service UIDs implemented by the application with the specified UID. |
|
2510 |
|
2511 @param aAppUid The application specific UID. |
|
2512 @param aServiceUids On return, contains the service UIDs implemented by the specified |
|
2513 application UID. |
|
2514 @leave KErrNotFound No matching application can be found, or a matching application |
|
2515 does not implement any services. |
|
2516 @leave KErrNotSupported The specified application does not provide an application |
|
2517 registration file. |
|
2518 @leave KErrNoMemory There is insufficient memory to perform the operation. |
|
2519 @publishedPartner |
|
2520 @released |
|
2521 */ |
|
2522 EXPORT_C void RApaLsSession::GetAppServicesL(TUid aAppUid, CArrayFixFlat<TUid>& aServiceUids) const |
|
2523 { |
|
2524 CBufBase* buffer = GetServiceBufferLC(EAppListServGetAppServiceUids, aAppUid); |
|
2525 RBufReadStream readStream(*buffer); |
|
2526 readStream >> aServiceUids; |
|
2527 CleanupStack::PopAndDestroy(buffer); |
|
2528 } |
|
2529 |
|
2530 |
|
2531 |
|
2532 /** Gets the service implementation's opaque data for the specified application and service. |
|
2533 |
|
2534 The specified application may provide more than one implementation of the specified service. |
|
2535 |
|
2536 The returned CApaAppServiceInfoArray object contains an array of TApaAppServiceInfo objects, |
|
2537 each of which provides information on an implementation. |
|
2538 |
|
2539 For each TApaAppServiceInfo object, TApaAppServiceInfo::Uid() returns the specified service UID. |
|
2540 |
|
2541 @param aAppUid The application specific UID. |
|
2542 @param aServiceUid The service UID. |
|
2543 @return A pointer to a CApaAppServiceInfoArray object left on the cleanup stack. |
|
2544 @leave KErrNotFound No matching application can be found, or a matching application |
|
2545 does not implement the specified service. |
|
2546 @leave KErrNotSupported The specified application does not provide an application |
|
2547 registration file. |
|
2548 @leave KErrNoMemory There is insufficient memory to perform the operation. |
|
2549 @see CApaAppServiceInfoArray::Array() |
|
2550 @see TApaAppServiceInfo |
|
2551 @publishedPartner |
|
2552 @released |
|
2553 */ |
|
2554 EXPORT_C CApaAppServiceInfoArray* RApaLsSession::GetAppServiceOpaqueDataLC(TUid aAppUid, TUid aServiceUid) const |
|
2555 { |
|
2556 CArrayFixFlat<TApaAppServiceInfo>* serviceArray = new(ELeave) CArrayFixFlat<TApaAppServiceInfo>(4); |
|
2557 CleanupStack::PushL(TCleanupItem(CleanupServiceArray, serviceArray)); |
|
2558 CBufBase* buffer = GetServiceBufferLC(EAppListServGetAppServiceOpaqueData, aAppUid, aServiceUid); |
|
2559 RBufReadStream readStream(*buffer); |
|
2560 readStream >> *serviceArray; |
|
2561 CleanupStack::PopAndDestroy(buffer); |
|
2562 CleanupStack::Pop(serviceArray); |
|
2563 CApaAppServiceInfoArrayWrapper* wrapper = CApaAppServiceInfoArrayWrapper::NewL(serviceArray); // takes ownership of serviceArray |
|
2564 CleanupStack::PushL(wrapper); |
|
2565 return wrapper; |
|
2566 } |
|
2567 |
|
2568 |
|
2569 |
|
2570 /** Gets the UID of an application that can handle the specified data (MIME) type and service. |
|
2571 |
|
2572 If no application can be found, the function returns the UID of the preferred |
|
2573 default handler. If none of the default handlers can handle the combination |
|
2574 of data type and service, then a NULL UID is returned in aAppUid. |
|
2575 |
|
2576 @param aDataType The data (MIME) type. |
|
2577 @param aServiceUid The service UID. |
|
2578 @param aAppUid On return, the UID of the application that can handle the data |
|
2579 (MIME) type and service; this may be NULL. |
|
2580 @return KErrNone, if successful; otherwise one of the other system-wide error |
|
2581 codes. |
|
2582 @publishedPartner |
|
2583 @released |
|
2584 */ |
|
2585 EXPORT_C TInt RApaLsSession::AppForDataTypeAndService(const TDataType& aDataType, TUid aServiceUid, TUid& aAppUid) const |
|
2586 { |
|
2587 const TPckgC<TDataType> dataType(aDataType); |
|
2588 TPckg<TUid> uid(aAppUid); |
|
2589 return SendReceiveWithReconnect(EAppListServAppForDataTypeAndService,TIpcArgs(&dataType, aServiceUid.iUid,&uid)); |
|
2590 } //lint !e1764 Suppress reference parameter 'aAppUid' could be declared const ref |
|
2591 |
|
2592 EXPORT_C TInt RApaLsSession::AppForDocumentAndService(const TDesC& aFileName, TUid aServiceUid, TUid& aAppUid, TDataType& aDataType) const |
|
2593 /** Gets the data (MIME) type of the data in the specified file and gets the UID |
|
2594 of an application that can handle this type and service. |
|
2595 |
|
2596 @param aFileName The name of the file containing the data. |
|
2597 @param aServiceUid The service UID |
|
2598 @param aUid On return, the UID of the application that can handle the data |
|
2599 (MIME) type and service; this may be NULL. |
|
2600 @param aDataType On return, the data (MIME) type. |
|
2601 @return KErrNone, if successful; otherwise one of the other system-wide error |
|
2602 codes. |
|
2603 @publishedPartner |
|
2604 @released |
|
2605 */ |
|
2606 { |
|
2607 return DoAppForDocumentOptionallySpecifyingService(aFileName, aServiceUid, aAppUid, aDataType, EAppListServAppForDocumentAndService); |
|
2608 } |
|
2609 |
|
2610 EXPORT_C TInt RApaLsSession::AppForDocumentAndService(const RFile& aFile, TUid aServiceUid, TUid& aAppUid, TDataType& aDataType) const |
|
2611 /** Gets the data (MIME) type of the data in the specified file and gets the UID |
|
2612 of an application that can handle this type and service. |
|
2613 |
|
2614 @param aFile The file handle. Before this function can be called, |
|
2615 the file server session which owns this file handle must first be marked as shareable by |
|
2616 calling RFs::ShareProtected(). |
|
2617 @param aServiceUid The service UID. |
|
2618 @param aUid On return, the UID of the application that can handle the data |
|
2619 (MIME) type and service; this may be NULL. |
|
2620 @param aDataType On return, the data (MIME) type. |
|
2621 @return KErrNone, if successful; otherwise one of the other system-wide error |
|
2622 codes. |
|
2623 @publishedPartner |
|
2624 @released |
|
2625 */ |
|
2626 { |
|
2627 return DoAppForDocumentOptionallySpecifyingService(aFile, aServiceUid, aAppUid, aDataType, EAppListServAppForDocumentAndServicePassedByFileHandle); |
|
2628 } |
|
2629 |
|
2630 TInt RApaLsSession::DoAppForDocumentOptionallySpecifyingService(const TDesC& aFileName, TUid aServiceUid, TUid& aAppUid, TDataType& aDataType, TInt aOpcode) const |
|
2631 { |
|
2632 if (aFileName.Length()==0) |
|
2633 { |
|
2634 aAppUid = KNullUid; |
|
2635 return KErrNone; |
|
2636 } |
|
2637 HBufC8* buffer=NULL; |
|
2638 TInt error=GetBufferFromFile(buffer, aFileName); |
|
2639 if (error!=KErrNone) |
|
2640 { |
|
2641 return error; |
|
2642 } |
|
2643 SReturnData_AppForDocument returnData; |
|
2644 TPckg<SReturnData_AppForDocument> returnData_asDescriptor(returnData); |
|
2645 error=SendReceiveWithReconnect(aOpcode,TIpcArgs(&returnData_asDescriptor, aServiceUid.iUid, &aFileName, buffer)); |
|
2646 delete buffer; |
|
2647 buffer=NULL; |
|
2648 if (error==KErrNone) |
|
2649 { |
|
2650 aAppUid=returnData.iUid; |
|
2651 aDataType=returnData.iDataType; |
|
2652 } |
|
2653 return error; |
|
2654 } |
|
2655 |
|
2656 TInt RApaLsSession::DoAppForDocumentOptionallySpecifyingService(const RFile& aFile, TUid aServiceUid, TUid& aAppUid, TDataType& aDataType, TInt aOpcode) const |
|
2657 { |
|
2658 SReturnData_AppForDocument returnData; |
|
2659 TPckg<SReturnData_AppForDocument> returnData_asDescriptor(returnData); |
|
2660 TIpcArgs ipcArgs(&returnData_asDescriptor, aServiceUid.iUid); |
|
2661 TInt error=aFile.TransferToServer(ipcArgs, 2, 3); |
|
2662 if (error == KErrNone) |
|
2663 { |
|
2664 error=SendReceiveWithReconnect(aOpcode, ipcArgs); |
|
2665 } |
|
2666 if (error==KErrNone) |
|
2667 { |
|
2668 aAppUid=returnData.iUid; |
|
2669 aDataType=returnData.iDataType; |
|
2670 } |
|
2671 return error; |
|
2672 } |
|
2673 |
|
2674 TInt RApaLsSession::GetBufferFromFile(HBufC8*& aBuffer, const TDesC& aFileName) const |
|
2675 { |
|
2676 TInt preferredBufSize=0; |
|
2677 const TInt error=GetPreferredBufSize(preferredBufSize); |
|
2678 if (error<KErrNone) |
|
2679 { |
|
2680 return error; |
|
2681 } |
|
2682 HBufC8* const buffer=HBufC8::New(Max(8, preferredBufSize)); // 8 is a sensible minimum |
|
2683 if (buffer==NULL) |
|
2684 { |
|
2685 return KErrNoMemory; |
|
2686 } |
|
2687 const RFs* fsSession=FsSession(); |
|
2688 RFs tempFsSession; |
|
2689 if (fsSession==NULL) |
|
2690 { |
|
2691 const TInt error=tempFsSession.Connect(); |
|
2692 if (error!=KErrNone) |
|
2693 { |
|
2694 delete buffer; |
|
2695 return error; |
|
2696 } |
|
2697 fsSession=&tempFsSession; |
|
2698 } |
|
2699 if (fsSession->IsValidName(aFileName)) |
|
2700 { |
|
2701 TPtr8 buffer_asWritable(buffer->Des()); |
|
2702 const TInt error=fsSession->ReadFileSection(aFileName, 0, buffer_asWritable, preferredBufSize); |
|
2703 if (error!=KErrNone) |
|
2704 { |
|
2705 delete buffer; |
|
2706 tempFsSession.Close(); |
|
2707 return error; |
|
2708 } |
|
2709 } |
|
2710 if (fsSession==&tempFsSession) |
|
2711 { |
|
2712 tempFsSession.Close(); |
|
2713 } |
|
2714 aBuffer=buffer; |
|
2715 return KErrNone; |
|
2716 } |
|
2717 |
|
2718 EXPORT_C void RApaLsSession::SetFsSessionL(RFs& aFsSession) |
|
2719 /** |
|
2720 @internalTechnology |
|
2721 */ |
|
2722 { // static |
|
2723 User::LeaveIfError(Dll::SetTls(&aFsSession)); |
|
2724 } |
|
2725 |
|
2726 EXPORT_C void RApaLsSession::ClearFsSession() |
|
2727 /** |
|
2728 @internalTechnology |
|
2729 */ |
|
2730 { // static |
|
2731 Dll::FreeTls(); |
|
2732 } |
|
2733 |
|
2734 EXPORT_C RFs* RApaLsSession::FsSession() |
|
2735 /** |
|
2736 @internalComponent |
|
2737 */ |
|
2738 { // static |
|
2739 return static_cast<RFs*>(Dll::Tls()); |
|
2740 } |
|
2741 |
|
2742 /** @publishedPartner */ |
|
2743 EXPORT_C void RApaLsSession::RegisterNonNativeApplicationTypeL(TUid aApplicationType, const TDesC& aNativeExecutable) |
|
2744 { |
|
2745 User::LeaveIfError(SendReceiveWithReconnect(EAppListServRegisterNonNativeApplicationType, TIpcArgs(aApplicationType.iUid, &aNativeExecutable))); |
|
2746 } //lint !e1762 Suppress member function could be made const |
|
2747 |
|
2748 /** @publishedPartner */ |
|
2749 EXPORT_C void RApaLsSession::DeregisterNonNativeApplicationTypeL(TUid aApplicationType) |
|
2750 { |
|
2751 User::LeaveIfError(SendReceiveWithReconnect(EAppListServDeregisterNonNativeApplicationType, TIpcArgs(aApplicationType.iUid))); |
|
2752 } //lint !e1762 Suppress member function could be made const |
|
2753 |
|
2754 /** @publishedPartner */ |
|
2755 EXPORT_C void RApaLsSession::PrepareNonNativeApplicationsUpdatesL() |
|
2756 { |
|
2757 TIpcArgs ipcArgs(0, 0, 0, 0); |
|
2758 User::LeaveIfError(SendReceiveWithReconnect(EAppListServPrepareNonNativeApplicationsUpdates, ipcArgs)); |
|
2759 } //lint !e1762 Suppress member function could be made const |
|
2760 |
|
2761 /** @publishedPartner */ |
|
2762 EXPORT_C void RApaLsSession::RegisterNonNativeApplicationL(TUid aApplicationType, const TDriveUnit& aDrive, CApaRegistrationResourceFileWriter& aRegistrationResourceFile, CApaLocalisableResourceFileWriter* aLocalisableResourceFile, const RFile* aIconFile) |
|
2763 { |
|
2764 TIpcArgs ipcArgs(0, 0, 0, 0); |
|
2765 RBuf8 ipcParameter0; |
|
2766 CleanupClosePushL(ipcParameter0); |
|
2767 RBuf8 ipcParameter1; |
|
2768 CleanupClosePushL(ipcParameter1); |
|
2769 if (aLocalisableResourceFile==NULL) |
|
2770 { |
|
2771 __ASSERT_ALWAYS(aIconFile==NULL, Panic(EPanicIconFileWithoutLocalisableResourceFile)); |
|
2772 ipcArgs.Set(1, NULL); |
|
2773 } |
|
2774 else |
|
2775 { |
|
2776 TParse* const parser=new(ELeave) TParse; |
|
2777 CleanupStack::PushL(parser); |
|
2778 const TDriveName driveName(aDrive.Name()); // TDriveName is a TBuf<2> |
|
2779 |
|
2780 if (aIconFile!=NULL) |
|
2781 { |
|
2782 User::LeaveIfError(aIconFile->TransferToServer(ipcArgs, 2, 3)); |
|
2783 |
|
2784 TFileName* const fileName=new(ELeave) TFileName; |
|
2785 CleanupStack::PushL(fileName); |
|
2786 User::LeaveIfError(aIconFile->Name(*fileName)); |
|
2787 parser->SetNoWild(*fileName, &KLitPathForNonNativeResourceAndIconFiles, &driveName); |
|
2788 aLocalisableResourceFile->SetIconFileL(parser->FullName()); |
|
2789 CleanupStack::PopAndDestroy(fileName); |
|
2790 } |
|
2791 aLocalisableResourceFile->GenerateFileContentsL(ipcParameter1); // must be done after the aLocalisableResourceFile->SetIconFileL call (if there is one) |
|
2792 const TDesC8& ipcParameter1_asConst=ipcParameter1; |
|
2793 ipcArgs.Set(1, &ipcParameter1_asConst); |
|
2794 |
|
2795 TBuf<30> fileName; |
|
2796 fileName.Format(KLitFormatForLocalisableResourceFile, aRegistrationResourceFile.AppUid().iUid); |
|
2797 parser->SetNoWild(fileName, &KLitPathForNonNativeResourceAndIconFiles, &driveName); |
|
2798 aRegistrationResourceFile.SetLocalisableResourceFileL(parser->FullName()); |
|
2799 |
|
2800 CleanupStack::PopAndDestroy(parser); |
|
2801 } |
|
2802 aRegistrationResourceFile.GenerateFileContentsL(ipcParameter0); // must be done after the aRegistrationResourceFile.SetLocalisableResourceFileL call (if there is one) |
|
2803 SNonNativeApplicationInfo nonNativeApplicationInfo; |
|
2804 nonNativeApplicationInfo.iApplicationType=aApplicationType; |
|
2805 nonNativeApplicationInfo.iDrive=aDrive; |
|
2806 ipcParameter0.ReAllocL(sizeof(SNonNativeApplicationInfo)+ipcParameter0.Length()); |
|
2807 ipcParameter0.Insert(0, TPckgC<SNonNativeApplicationInfo>(nonNativeApplicationInfo)); |
|
2808 const TDesC8& ipcParameter0_asConst=ipcParameter0; |
|
2809 ipcArgs.Set(0, &ipcParameter0_asConst); |
|
2810 |
|
2811 User::LeaveIfError(SendReceiveWithReconnect(EAppListServRegisterNonNativeApplication, ipcArgs)); |
|
2812 CleanupStack::PopAndDestroy(2, &ipcParameter0); |
|
2813 } //lint !e1762 Suppress member function could be made const |
|
2814 |
|
2815 /** @publishedPartner */ |
|
2816 EXPORT_C void RApaLsSession::DeregisterNonNativeApplicationL(TUid aApplication) |
|
2817 { |
|
2818 User::LeaveIfError(SendReceiveWithReconnect(EAppListServDeregisterNonNativeApplication, TIpcArgs(aApplication.iUid))); |
|
2819 } //lint !e1762 Suppress member function could be made const |
|
2820 |
|
2821 /** |
|
2822 Commits the non-native application updates. This is a synchronous method which waits |
|
2823 until the application list is updated. |
|
2824 |
|
2825 @see ForceCommitNonNativeApplicationsUpdatesL |
|
2826 @publishedPartner |
|
2827 @released |
|
2828 */ |
|
2829 |
|
2830 EXPORT_C void RApaLsSession::CommitNonNativeApplicationsUpdatesL() |
|
2831 { |
|
2832 TIpcArgs ipcArgs(EFalse, 0, 0, 0); |
|
2833 User::LeaveIfError(SendReceiveWithReconnect(EAppListServCommitNonNativeApplications, ipcArgs)); |
|
2834 } //lint !e1762 Suppress member function could be made const |
|
2835 |
|
2836 |
|
2837 /** |
|
2838 Commits the non-native application updates. This is an asynchronous method which will not wait until |
|
2839 the application list is updated. CApaAppListNotifier class should be used to synchronize the completion |
|
2840 of updating the application list. |
|
2841 |
|
2842 @see CommitNonNativeApplicationsUpdatesL |
|
2843 @see CApaAppListNotifier |
|
2844 @publishedPartner |
|
2845 @released |
|
2846 */ |
|
2847 |
|
2848 EXPORT_C void RApaLsSession::ForceCommitNonNativeApplicationsUpdatesL() |
|
2849 { |
|
2850 TIpcArgs ipcArgs(ETrue, 0, 0, 0); |
|
2851 User::LeaveIfError(SendReceiveWithReconnect(EAppListServCommitNonNativeApplications, ipcArgs)); |
|
2852 } |
|
2853 |
|
2854 /** |
|
2855 Rolls back all changes made to the list of installed non-native applications since the last call to |
|
2856 PrepareNonNativeApplicationsUpdatesL(). |
|
2857 |
|
2858 This function can be called even if PrepareNonNativeApplicationsUpdatesL() hasn't been called before (in which |
|
2859 case it does nothing). |
|
2860 |
|
2861 @publishedPartner |
|
2862 */ |
|
2863 EXPORT_C TInt RApaLsSession::RollbackNonNativeApplicationsUpdates() |
|
2864 { |
|
2865 TIpcArgs ipcArgs(0, 0, 0, 0); |
|
2866 return SendReceiveWithReconnect(EAppListServRollbackNonNativeApplications, ipcArgs); |
|
2867 } //lint !e1762 Suppress member function could be made const |
|
2868 |
|
2869 EXPORT_C void RApaLsSession::SetNotify(TBool aCompleteImmediatelyIfNoScanImpendingOrInProgress, TRequestStatus& aStatus) |
|
2870 /** |
|
2871 @internalTechnology */ |
|
2872 { |
|
2873 SendReceive(ESetNotify,TIpcArgs(aCompleteImmediatelyIfNoScanImpendingOrInProgress),aStatus); |
|
2874 } //lint !e1762 Suppress member function could be made const |
|
2875 |
|
2876 EXPORT_C void RApaLsSession::CancelNotify() |
|
2877 /** |
|
2878 @internalTechnology */ |
|
2879 { |
|
2880 SendReceive(ECancelNotify,TIpcArgs()); |
|
2881 } //lint !e1762 Suppress member function could be made const |
|
2882 |
|
2883 /** |
|
2884 Gets the application type of the application. For a native application the type is KNullUid. |
|
2885 @return A standard error code. |
|
2886 @publishedPartner |
|
2887 @released |
|
2888 @param aTypeUid On return contains the application's type |
|
2889 @param aAppUid The application's UID passed into TIpcArgs |
|
2890 */ |
|
2891 EXPORT_C TInt RApaLsSession::GetAppType(TUid& aTypeUid, TUid aAppUid) const |
|
2892 { |
|
2893 TPckg<TUid> uid(aTypeUid); |
|
2894 return SendReceiveWithReconnect(EAppListServGetAppType,TIpcArgs(aAppUid.iUid,&uid)); |
|
2895 } //lint !e1764 Suppress reference parameter 'aTypeUid' could be declared const ref |
|
2896 |
|
2897 /** |
|
2898 This function is only for use by Software Install. |
|
2899 |
|
2900 As part of the fix for defect INC069526, we added a check in apparc. We check if the application has |
|
2901 been installed before adding it to the apparc db. A side-effect of this fix is that it is not possible |
|
2902 to launch applications that are being installed from the installation process itself. This is a regresssion. |
|
2903 |
|
2904 To fix this regression we added this function. It allows Software Install to specify a list of registration |
|
2905 files that need to be included in apparc's list even if they have not been marked as installed in the |
|
2906 SISRegistry or JavaRegistry. The list of registration files is cleared once Software Install notifies |
|
2907 (via P&S) the end of the installation (whether successful or not). |
|
2908 The function also forces a rescan and only returns when this rescan is complete. This is because |
|
2909 Software Install needs to be sure the registration files have been added to apparc's list before |
|
2910 trying to launch the recently installed applications. |
|
2911 |
|
2912 @param aRegFiles The list of registration files for which the SISRegistry check must be ignored. |
|
2913 @return A standard error code. |
|
2914 @internalAll |
|
2915 @released |
|
2916 */ |
|
2917 EXPORT_C TInt RApaLsSession::ForceRegistration(const RPointerArray<TDesC>& aRegFiles) |
|
2918 { |
|
2919 CBufFlat* buffer = 0; |
|
2920 TRAPD(err, buffer = CreateRegFilesBufferL(aRegFiles)); |
|
2921 if (err != KErrNone) |
|
2922 { |
|
2923 return err; |
|
2924 } |
|
2925 TPtr8 ptr = buffer->Ptr(0); |
|
2926 const TInt returnValue=SendReceiveWithReconnect(EAppListServForceRegistration,TIpcArgs(&ptr)); |
|
2927 delete buffer; |
|
2928 return returnValue; |
|
2929 } //lint !e1762 Suppress member function could be made const |
|
2930 |
|
2931 TInt RApaLsSession::SendReceiveWithReconnect(TInt aFunction,const TIpcArgs& aIpcArgs) const |
|
2932 { |
|
2933 TInt ret = SendReceive(aFunction, aIpcArgs); |
|
2934 if(ret != KErrServerTerminated) |
|
2935 { |
|
2936 return ret; |
|
2937 } |
|
2938 |
|
2939 RApaLsSession ls; |
|
2940 TInt err=ls.Connect(); |
|
2941 if (err==KErrNone) |
|
2942 { |
|
2943 RApaLsSession* const localThis = const_cast<RApaLsSession*>(this); |
|
2944 localThis->Close(); |
|
2945 localThis->iHandle=ls.iHandle; |
|
2946 ret = SendReceive(aFunction, aIpcArgs); |
|
2947 } |
|
2948 return ret; |
|
2949 } |
|
2950 |
|
2951 void RApaLsSession::DoGetAppOwnedFilesL(CDesCArray& aArrayToFill, TUid aAppUid) const |
|
2952 { |
|
2953 TDesCArrayFiller arrayFiller(aArrayToFill); |
|
2954 FetchArrayL(arrayFiller, aAppUid, EAppListServGetFileOwnershipInfo, KInitialOwnedFilesBufSize); |
|
2955 } |
|
2956 |
|
2957 EXPORT_C void RApaLsSession::RegisterListPopulationCompleteObserver(TRequestStatus& aStatus) const |
|
2958 /** Registers an observer with apparc server to notify when the initial population of applist is completed |
|
2959 |
|
2960 @param aStatus Request status object. On successful completion contains KErrNone, otherwise one of the |
|
2961 system-wide error codes. |
|
2962 @see CancelListPopulationCompleteObserver() |
|
2963 */ |
|
2964 { |
|
2965 SendReceive(ERegisterListPopulationCompleteObserver,TIpcArgs(TIpcArgs::ENothing),aStatus); |
|
2966 } |
|
2967 |
|
2968 EXPORT_C TInt RApaLsSession::CancelListPopulationCompleteObserver() const |
|
2969 /** Cancels the observer registered with apparc server to notify when the initial population of applist is completed |
|
2970 |
|
2971 @return KErrNone, if successful; otherwise one of the system-wide error codes. |
|
2972 */ |
|
2973 { |
|
2974 return SendReceiveWithReconnect(ECancelListPopulationCompleteObserver,TIpcArgs(TIpcArgs::ENothing)); |
|
2975 } |
|
2976 |
|
2977 EXPORT_C TInt RApaLsSession::MatchesSecurityPolicy(TBool& aMatches, TUid aAppUid, const TSecurityPolicy& aSecurityPolicy) const |
|
2978 /** Tests whether the given TSecurityPolicy matches with the application TSecurityPolicy. |
|
2979 |
|
2980 @param aMatches On return, contains the result. ETrue if the application TSecurityPolicy matches the given TSecurityPolicy or else EFalse |
|
2981 @param aAppUid Uid of the application for which the security policy has to be matched |
|
2982 @param aSecurityPolicy TSecurityPolicy to test whether the application with given uid matches with its TSecurityPolicy or not. |
|
2983 @return KErrNone, if successful; otherwise one of the other system-wide error codes. |
|
2984 @see TSecurityPolicy |
|
2985 */ |
|
2986 { |
|
2987 const TPckgC<TSecurityPolicy> securityPolicy(aSecurityPolicy); |
|
2988 const TInt result = SendReceiveWithReconnect(EMatchesSecurityPolicy,TIpcArgs(aAppUid.iUid, &securityPolicy)); |
|
2989 |
|
2990 if (result>=0) |
|
2991 { |
|
2992 aMatches = result; |
|
2993 } |
|
2994 return result; |
|
2995 } |
|
2996 |
|
2997 EXPORT_C void RApaLsSession::RApaLsSession_Reserved1() |
|
2998 { |
|
2999 } |
|
3000 |
|
3001 EXPORT_C void RApaLsSession::RApaLsSession_Reserved2() |
|
3002 { |
|
3003 } |
|
3004 |
|
3005 EXPORT_C void RApaLsSession::NotifyOnDataMappingChange(TRequestStatus& aRequestStatus) |
|
3006 /** Notification of changes in data-type mapping |
|
3007 |
|
3008 This asynchronous function (whose corresponding "cancel" operation is CancelNotifyOnDataTypeMappingChange) completes when any data-type / application-UID association changes, i.e. when the default application handling a particular MIME-type changes. |
|
3009 |
|
3010 @param aRequestStatus As is normal for an asynchronous operation, this object is set to something other than KRequestPending when the asynchronous operation that has been triggered by this function completes. |
|
3011 @see CancelNotifyOnDataTypeMappingChange |
|
3012 */ |
|
3013 { |
|
3014 SendReceive(ENotifyOnDataMappingChange,TIpcArgs(), aRequestStatus); |
|
3015 } //lint !e1762 Suppress member function could be made const |
|
3016 |
|
3017 EXPORT_C void RApaLsSession::CancelNotifyOnDataMappingChange() |
|
3018 /** Cancellation of notification of changes in data-type mapping |
|
3019 |
|
3020 This cancels the outstanding the NotifyOnDataTypeMappingChange issued by this client, if there is one outstanding. Otherwise it does nothing. |
|
3021 @see NotifyOnDataTypeMappingChange |
|
3022 */ |
|
3023 { |
|
3024 SendReceive(ECancelNotifyOnDataMappingChange,TIpcArgs()); |
|
3025 } //lint !e1762 Suppress member function could be made const |
|
3026 |
|
3027 CBufFlat* RApaLsSession::CreateRegFilesBufferL(const RPointerArray<TDesC>& aRegFiles) |
|
3028 { |
|
3029 // Serialize the array |
|
3030 // Format of the buffer is : |
|
3031 // 4 bytes for array item count |
|
3032 // for each item : 4 bytes for length and then the string contents |
|
3033 const TInt count = aRegFiles.Count(); |
|
3034 TInt requiredBufferSize = 4; // For the array item count |
|
3035 for (TInt index = 0; index < count; ++index) |
|
3036 { |
|
3037 requiredBufferSize += 4; // For the string length |
|
3038 requiredBufferSize += aRegFiles[index]->Size(); |
|
3039 } |
|
3040 |
|
3041 CBufFlat* const buffer = CBufFlat::NewL(requiredBufferSize); |
|
3042 CleanupStack::PushL(buffer); |
|
3043 buffer->ExpandL(0,requiredBufferSize); |
|
3044 RBufWriteStream writeStream; |
|
3045 writeStream.Open(*buffer); |
|
3046 CleanupClosePushL(writeStream); |
|
3047 writeStream.WriteUint32L(count); |
|
3048 for (TInt index = 0; index < count; ++index) |
|
3049 { |
|
3050 writeStream.WriteUint32L(aRegFiles[index]->Length()); |
|
3051 writeStream.WriteL(*aRegFiles[index]); |
|
3052 } |
|
3053 writeStream.CommitL(); |
|
3054 CleanupStack::PopAndDestroy(&writeStream); |
|
3055 CleanupStack::Pop(buffer); |
|
3056 return buffer; |
|
3057 } |
|
3058 |
|
3059 // TSizeArrayFiller |
|
3060 |
|
3061 void TSizeArrayFiller::AppendItemL(RReadStream& aReadStream) |
|
3062 { |
|
3063 TSize size; |
|
3064 size.iWidth =aReadStream.ReadUint32L(); |
|
3065 size.iHeight=aReadStream.ReadUint32L(); |
|
3066 iArray.AppendL(size); |
|
3067 } |
|
3068 |
|
3069 |
|
3070 |
|
3071 // TViewDataArrayFiller |
|
3072 |
|
3073 void TViewDataArrayFiller::AppendItemL(RReadStream& aReadStream) |
|
3074 { |
|
3075 TApaAppViewInfo info; |
|
3076 aReadStream >> info; |
|
3077 iArray.AppendL(info); |
|
3078 } |
|
3079 |
|
3080 |
|
3081 |
|
3082 // TDesCArrayFiller |
|
3083 |
|
3084 void TDesCArrayFiller::AppendItemL(RReadStream& aReadStream) |
|
3085 { |
|
3086 TFileName info; |
|
3087 aReadStream >> info; |
|
3088 iArray.AppendL(info); |
|
3089 } |
|
3090 |
|
3091 /* @internalComponent |
|
3092 */ |
|
3093 EXPORT_C TUint MinApplicationStackSize() |
|
3094 { |
|
3095 return KMinApplicationStackSize; |
|
3096 } |