|
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 "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // apgcli.cpp |
|
15 // |
|
16 |
|
17 #include "../apserv/APSCLSV.H" |
|
18 #include "../apserv/apsserv.h" |
|
19 |
|
20 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
21 #if !defined(__APA_INTERNAL_H__) |
|
22 #include "apainternal.h" |
|
23 #endif |
|
24 #if !defined(__APGICNFL_PARTNER_H__) |
|
25 #include "apgicnflpartner.h" |
|
26 #endif |
|
27 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS |
|
28 #include "APGCLI.H" |
|
29 #include "APGSTD.H" |
|
30 #include "APGICNFL.H" |
|
31 #include "APGPRIV.H" |
|
32 #include "apprivate.h" |
|
33 |
|
34 const TUint KInitialIconBufSize = sizeof(TSize)*6 + sizeof(TInt); |
|
35 const TUint KInitialViewDataBufSize = sizeof(TApaAppViewInfo)*6 + sizeof(TInt); |
|
36 const TUint KInitialOwnedFilesBufSize = sizeof(TFileName)*6 + sizeof(TInt); |
|
37 const TUint KDefaultBufSize = 0x400; |
|
38 const TUint KAsyncMessageSlots = 4; // One slot each for, RApaLsSession::SetNotify, RApaLsSession:: |
|
39 // RegisterListPopulationCompleteObserver and RApaLsSession::NotifyOnDataMappingChange |
|
40 // CAsyncFileRecognition::Start makes an asynch request of apparc server. |
|
41 |
|
42 extern void CleanupAppServiceArray(TAny* aServiceArray); |
|
43 |
|
44 IMPORT_C extern const TInt KMinApplicationStackSize; |
|
45 |
|
46 /** |
|
47 @internalComponent |
|
48 */ |
|
49 class MArrayFiller |
|
50 { |
|
51 public: |
|
52 virtual void AppendItemFromStreamL(RReadStream& aReadStream) = 0; |
|
53 }; |
|
54 |
|
55 /** |
|
56 @internalComponent |
|
57 */ |
|
58 NONSHARABLE_CLASS(TSizeArrayFiller) : public MArrayFiller |
|
59 { |
|
60 public: |
|
61 inline TSizeArrayFiller(CArrayFixFlat<TSize>& aArray) : iArray(aArray) {} |
|
62 public: // from MArrayFiller |
|
63 void AppendItemFromStreamL(RReadStream& aReadStream); |
|
64 private: |
|
65 CArrayFixFlat<TSize>& iArray; |
|
66 }; |
|
67 |
|
68 /** |
|
69 @internalComponent |
|
70 */ |
|
71 NONSHARABLE_CLASS(TViewDataArrayFiller) : public MArrayFiller |
|
72 { |
|
73 public: |
|
74 inline TViewDataArrayFiller(CApaAppViewArray& aArray) : iArray(aArray) {} |
|
75 public: // from MArrayFiller |
|
76 void AppendItemFromStreamL(RReadStream& aReadStream); |
|
77 private: |
|
78 CApaAppViewArray& iArray; |
|
79 }; |
|
80 |
|
81 /** |
|
82 @internalComponent |
|
83 */ |
|
84 NONSHARABLE_CLASS(TDesCArrayFiller) : public MArrayFiller |
|
85 { |
|
86 public: |
|
87 inline TDesCArrayFiller(CDesCArray& aArray) : iArray(aArray) {} |
|
88 public: // from MArrayFiller |
|
89 void AppendItemFromStreamL(RReadStream& aReadStream); |
|
90 private: |
|
91 CDesCArray& iArray; |
|
92 }; |
|
93 |
|
94 // TSizeArrayFiller |
|
95 |
|
96 void TSizeArrayFiller::AppendItemFromStreamL(RReadStream& aReadStream) |
|
97 { |
|
98 TSize size; |
|
99 size.iWidth = aReadStream.ReadUint32L(); |
|
100 size.iHeight= aReadStream.ReadUint32L(); |
|
101 iArray.AppendL(size); |
|
102 } |
|
103 |
|
104 // TViewDataArrayFiller |
|
105 |
|
106 void TViewDataArrayFiller::AppendItemFromStreamL(RReadStream& aReadStream) |
|
107 { |
|
108 TApaAppViewInfo info; |
|
109 aReadStream >> info; |
|
110 iArray.AppendL(info); |
|
111 } |
|
112 |
|
113 // TDesCArrayFiller |
|
114 |
|
115 void TDesCArrayFiller::AppendItemFromStreamL(RReadStream& aReadStream) |
|
116 { |
|
117 TFileName info; |
|
118 aReadStream >> info; |
|
119 iArray.AppendL(info); |
|
120 } |
|
121 |
|
122 /** |
|
123 @internalComponent |
|
124 */ |
|
125 EXPORT_C TUint MinApplicationStackSize() |
|
126 { |
|
127 return KMinApplicationStackSize; |
|
128 } |
|
129 |
|
130 |
|
131 // |
|
132 // class RApaLsSession |
|
133 // |
|
134 |
|
135 EXPORT_C RApaLsSession::RApaLsSession() |
|
136 : iExtension(NULL) |
|
137 {} |
|
138 |
|
139 |
|
140 |
|
141 /** Connects a client to the application architecture server, creating a session |
|
142 with it. |
|
143 |
|
144 @return KErrNone if successful; otherwise, one of the system-wide error codes. |
|
145 */ |
|
146 EXPORT_C TInt RApaLsSession::Connect() |
|
147 { |
|
148 TInt r=CreateSession(KAppListServerName,Version(),KAsyncMessageSlots); |
|
149 return(r); |
|
150 } |
|
151 |
|
152 EXPORT_C void RApaLsSession::Close() |
|
153 /** |
|
154 Closes the session. Needs to be called to avoid memory leaks. |
|
155 @publishedAll |
|
156 @released |
|
157 */ |
|
158 { |
|
159 CancelRecognizeFiles(); |
|
160 RHandleBase::Close(); |
|
161 } |
|
162 |
|
163 |
|
164 /** Gets the version of the application architecture server. |
|
165 |
|
166 @return The version number. |
|
167 */ |
|
168 EXPORT_C TVersion RApaLsSession::Version(void) const |
|
169 { |
|
170 return(TVersion(KAppListServMajorVersionNumber,KAppListServMinorVersionNumber,KAppListServBuildVersionNumber)); |
|
171 } |
|
172 |
|
173 |
|
174 /** Gets the total number of applications. |
|
175 |
|
176 Control panel applications are excluded. |
|
177 |
|
178 @param aCount On return, the total number of applications. |
|
179 @return KErrNone if successful, otherwise one of the system-wide error codes. |
|
180 */ |
|
181 EXPORT_C TInt RApaLsSession::AppCount(TInt& aCount) const |
|
182 { |
|
183 return DoAppCount(aCount, EAppListServAppCount); |
|
184 } |
|
185 |
|
186 |
|
187 /** Gets the total number of embeddable applications. |
|
188 |
|
189 Control panel applications are excluded. |
|
190 |
|
191 @param aCount On return, the total number of embeddable applications. |
|
192 @return KErrNone, if successful, otherwise one of the system-wide error codes. |
|
193 */ |
|
194 EXPORT_C TInt RApaLsSession::EmbeddableAppCount(TInt& aCount) const |
|
195 { |
|
196 return DoAppCount(aCount, EAppListServEmbedCount); |
|
197 } |
|
198 |
|
199 |
|
200 TInt RApaLsSession::DoAppCount(TInt& aCount,TInt aCommand) const |
|
201 // returns the number of embeddable apps in the server side list |
|
202 { |
|
203 __ASSERT_DEBUG(aCommand==EAppListServEmbedCount || aCommand==EAppListServAppCount,Panic(EDPanicWrongCommand)); |
|
204 const TInt returnValue = SendReceiveWithReconnect(aCommand,TIpcArgs()); |
|
205 if (returnValue < 0) |
|
206 return returnValue; |
|
207 |
|
208 aCount = returnValue; |
|
209 return KErrNone; |
|
210 } |
|
211 |
|
212 |
|
213 |
|
214 /** Initialises the process of getting all applications in the cached list. |
|
215 |
|
216 Control panel applications are excluded. |
|
217 |
|
218 A call to this function is followed by subsequent and repeated calls to GetNextApp() |
|
219 to retrieve all applications in the cached list. |
|
220 |
|
221 @return KErrNone, if successful, otherwise one of the system-wide error codes. |
|
222 */ |
|
223 EXPORT_C TInt RApaLsSession::GetAllApps() const |
|
224 { |
|
225 return GetAllApps(0); |
|
226 } |
|
227 |
|
228 |
|
229 /** Initialises the process of getting all applications in the cached list. |
|
230 |
|
231 Control panel applications are excluded. |
|
232 |
|
233 A call to this function is followed by subsequent and repeated calls to GetNextApp() |
|
234 to retrieve all applications supporting aScreenMode in the cached list. |
|
235 |
|
236 @param aScreenMode Only applications which define a view supporting aScreenMode |
|
237 will be returned by subsequent calls to GetNextApp(). If an application does not |
|
238 define views in it's application information file, only screen mode 0 is supported. |
|
239 @return KErrNone, if successful, otherwise one of the system-wide error codes. |
|
240 */ |
|
241 EXPORT_C TInt RApaLsSession::GetAllApps(TInt aScreenMode) const |
|
242 { |
|
243 return GetFilteredApps(TApaAppCapability::EControlPanelItem, 0, aScreenMode); // exclude control panel apps |
|
244 } |
|
245 |
|
246 |
|
247 |
|
248 /** Initialises the process of getting all embeddable applications from the cached list. |
|
249 |
|
250 Control panel applications are excluded. |
|
251 |
|
252 A call to this function is followed by subsequent and repeated calls to GetNextApp() |
|
253 to retrieve embeddable applications in the cached list. |
|
254 |
|
255 Only applications which specify KAppEmbeddable or KAppEmbeddableOnly in their |
|
256 application information file will be returned by subsequent calls to GetNextApp(). |
|
257 |
|
258 @return KErrNone, if successful, otherwise one of the system-wide error codes. |
|
259 */ |
|
260 EXPORT_C TInt RApaLsSession::GetEmbeddableApps() const |
|
261 { |
|
262 return GetEmbeddableApps(0); |
|
263 } |
|
264 |
|
265 |
|
266 |
|
267 /** Initialises the process of getting embeddable applications from the cached list |
|
268 that support the specified screen mode. |
|
269 |
|
270 Control panel applications are excluded. |
|
271 |
|
272 A call to this function is followed by subsequent and repeated calls to GetNextApp() |
|
273 to retrieve embeddable applications in the cached list. |
|
274 |
|
275 Only applications which specify KAppEmbeddable or KAppEmbeddableOnly in their |
|
276 application information file will be returned by subsequent calls to GetNextApp(). |
|
277 |
|
278 @param aScreenMode Only embeddable applications which define a view supporting |
|
279 aScreenMode will be returned by subsequent calls to GetNextApp(). If an application |
|
280 does not define views in it's application information file, only screen mode 0 is supported. |
|
281 @return KErrNone, if successful, otherwise one of the system-wide error codes. |
|
282 */ |
|
283 EXPORT_C TInt RApaLsSession::GetEmbeddableApps(TInt aScreenMode) const |
|
284 { |
|
285 TApaEmbeddabilityFilter filter; |
|
286 filter.AddEmbeddability(TApaAppCapability::EEmbeddable); |
|
287 filter.AddEmbeddability(TApaAppCapability::EEmbeddableOnly); |
|
288 return GetFilteredApps(filter, aScreenMode); |
|
289 } |
|
290 |
|
291 |
|
292 |
|
293 /** Initialises the process of getting all applications matching aFilter in the |
|
294 cached list. |
|
295 |
|
296 Control panel applications are excluded. |
|
297 |
|
298 A call to this function is followed by subsequent and repeated calls to GetNextApp() |
|
299 to retrieve all applications matching aFilter in the cached list. |
|
300 |
|
301 @param aFilter Defines the filter to be applied to the cached list. |
|
302 @return KErrNone, if successful, otherwise one of the system-wide error codes. |
|
303 */ |
|
304 EXPORT_C TInt RApaLsSession::GetFilteredApps(const TApaEmbeddabilityFilter& aFilter) const |
|
305 { |
|
306 return GetFilteredApps(aFilter, 0); |
|
307 } |
|
308 |
|
309 |
|
310 |
|
311 /** Initialises the process of getting all applications matching aFilter in the |
|
312 cached list. |
|
313 |
|
314 Control panel applications are excluded. |
|
315 |
|
316 A call to this function is followed by subsequent and repeated calls to GetNextApp() |
|
317 to retrieve all applications matching aFilter in the cached list. |
|
318 |
|
319 @param aFilter Defines the filter to be applied to the cached list. |
|
320 @param aScreenMode Only applications which define a view supporting aScreenMode |
|
321 will be returned by subsequent calls to GetNextApp(). If an application does not |
|
322 define views in it's application information file, only screen mode 0 is supported. |
|
323 @return KErrNone, if successful, otherwise one of the system-wide error codes. |
|
324 */ |
|
325 EXPORT_C TInt RApaLsSession::GetFilteredApps(const TApaEmbeddabilityFilter& aFilter, TInt aScreenMode) const |
|
326 { |
|
327 const TPckgC<TApaEmbeddabilityFilter> filter(aFilter); |
|
328 return SendReceiveWithReconnect(EAppListServInitFilteredEmbedList,TIpcArgs(aScreenMode,&filter)); |
|
329 } |
|
330 |
|
331 |
|
332 |
|
333 /** Initialises the process of getting all applications matching the specified |
|
334 application attributes. |
|
335 |
|
336 A call to this function is followed by subsequent and repeated calls to GetNextApp() |
|
337 to retrieve all applications matching the filter in the cached list. |
|
338 |
|
339 Attributes are defined by TApaAppCapability::TCapabilityAttribute |
|
340 |
|
341 @param aCapabilityAttributeMask Specifies the attributes whose values will be |
|
342 used to filter the cached list. If the mask specifies more than one attribute, |
|
343 all associated attribute values must match. |
|
344 @param aCapabilityAttributeValue Specifies the attribute values for each attribute |
|
345 identified by the mask. |
|
346 @return KErrNone, if successful, otherwise one of the system-wide error codes. |
|
347 @see TCapabilityAttribute |
|
348 */ |
|
349 EXPORT_C TInt RApaLsSession::GetFilteredApps(TUint aCapabilityAttributeMask, TUint aCapabilityAttributeValue) const |
|
350 { |
|
351 return GetFilteredApps(aCapabilityAttributeMask, aCapabilityAttributeValue, 0); |
|
352 } |
|
353 |
|
354 |
|
355 |
|
356 /** Initialises the process of getting all applications matching the specified |
|
357 application attributes. |
|
358 |
|
359 A call to this function is followed by subsequent and repeated calls to GetNextApp() |
|
360 to retrieve all applications matching the filter in the cached list. |
|
361 |
|
362 Attributes are defined by TApaAppCapability::TCapabilityAttribute |
|
363 |
|
364 @param aCapabilityAttributeMask Specifies the attributes whose values will be |
|
365 used to filter the cached list. If the mask specifies more than one attribute, |
|
366 all associated attribute values must match. |
|
367 @param aCapabilityAttributeValue Specifies the attribute values for each attribute |
|
368 identified by the mask. |
|
369 @param aScreenMode Only applications which define a view supporting aScreenMode |
|
370 will be returned by subsequent calls to GetNextApp(). If an application does not |
|
371 define views in it's application information file, only screen mode 0 is supported. |
|
372 @return KErrNone, if successful, otherwise one of the system-wide error codes. |
|
373 @see TCapabilityAttribute |
|
374 */ |
|
375 EXPORT_C TInt RApaLsSession::GetFilteredApps(TUint aCapabilityAttributeMask, TUint aCapabilityAttributeValue, TInt aScreenMode) const |
|
376 { |
|
377 return SendReceiveWithReconnect(EAppListServInitAttrFilteredList,TIpcArgs(aScreenMode, aCapabilityAttributeMask, aCapabilityAttributeValue)); |
|
378 } |
|
379 |
|
380 |
|
381 |
|
382 /** Initialises the process of getting server applications in the cached list. |
|
383 |
|
384 Control panel applications are excluded. |
|
385 |
|
386 A call to this function is followed by subsequent and repeated calls to GetNextApp() |
|
387 to retrieve server applications in the cached list. |
|
388 |
|
389 Only applications which specify one or more services in their application |
|
390 information file will be returned by subsequent calls to GetNextApp(). |
|
391 |
|
392 @return KErrNone, if successful, otherwise one of the system-wide error codes. |
|
393 @publishedPartner |
|
394 @released |
|
395 */ |
|
396 EXPORT_C TInt RApaLsSession::GetServerApps(TUid aServiceUid) const |
|
397 { |
|
398 return GetServerApps(aServiceUid, 0); |
|
399 } |
|
400 |
|
401 /** Initialises the process of getting server applications in the cached list. |
|
402 |
|
403 Control panel applications are excluded. |
|
404 |
|
405 A call to this function is followed by subsequent and repeated calls to GetNextApp() |
|
406 to retrieve server applications in the cached list. |
|
407 |
|
408 Only applications which specify one or more services in their application |
|
409 information file will be returned by subsequent calls to GetNextApp(). |
|
410 |
|
411 @param aScreenMode Only server applications which define a view supporting |
|
412 aScreenMode will be returned by subsequent calls to GetNextApp(). If an application |
|
413 does not define views in its application information file, only screen mode 0 is supported. |
|
414 @return KErrNone, if successful, otherwise one of the system-wide error codes. |
|
415 @publishedPartner |
|
416 @released |
|
417 */ |
|
418 EXPORT_C TInt RApaLsSession::GetServerApps(TUid aServiceUid, TInt aScreenMode) const |
|
419 { |
|
420 return SendReceiveWithReconnect(EAppListServInitServerAppList,TIpcArgs(aScreenMode, aServiceUid.iUid)); |
|
421 } |
|
422 |
|
423 /** Gets information about the next application or embeddable application from |
|
424 the cached list. |
|
425 |
|
426 A sequence of calls to this function must always be preceded by a call to |
|
427 one of GetAllApps(), GetEmbeddableApps() or GetFilteredApps(). |
|
428 |
|
429 @param aInfo On return, contains application information. |
|
430 @return KErrNone if successful; ENoMoreAppsInList, if there are no more applications |
|
431 in the list; EAppListInvalid if the server's initial population of the list has |
|
432 not completed; otherwise one of the other system wide error codes. |
|
433 */ |
|
434 EXPORT_C TInt RApaLsSession::GetNextApp(TApaAppInfo& aInfo) const |
|
435 { |
|
436 return GetNextApp(aInfo,0); |
|
437 } |
|
438 |
|
439 /** Gets information about the next application or embeddable application from |
|
440 the cached list. |
|
441 |
|
442 A sequence of calls to this function must always be preceded by a call to |
|
443 one of GetAllApps(), GetEmbeddableApps() or GetFilteredApps(). |
|
444 |
|
445 @param aInfo On return, contains application information. |
|
446 @param aScreenMode This parameter is ignored. |
|
447 @return KErrNone if successful; ENoMoreAppsInList, if there are no more applications |
|
448 in the list; EAppListInvalid if the server's initial population of the list has |
|
449 not completed; otherwise one of the other system wide error codes. |
|
450 */ |
|
451 EXPORT_C TInt RApaLsSession::GetNextApp(TApaAppInfo& aInfo,TInt aScreenMode) const |
|
452 { |
|
453 TPckg<TApaAppInfo> info(aInfo); |
|
454 TInt err = SendReceiveWithReconnect(EAppListServGetNextApp, TIpcArgs(aScreenMode,&info)); |
|
455 if (!err) |
|
456 aInfo = info(); |
|
457 else if (err==KErrNotFound) |
|
458 err = ENoMoreAppsInList; |
|
459 else if (err==KErrCorrupt) |
|
460 err = EAppListInvalid; |
|
461 |
|
462 return err; |
|
463 } |
|
464 |
|
465 |
|
466 |
|
467 /** Gets information about the application with the specified UID. |
|
468 |
|
469 @param aInfo On return, contains the application information, if an application |
|
470 with the specified UID is found. If no matching application is found, then |
|
471 this object is not changed. |
|
472 @param aAppUid The application specific UID. |
|
473 @return KErrNone if successful; KErrNotFound if a matching entry could not be found; |
|
474 otherwise one of the other system wide error codes. |
|
475 */ |
|
476 EXPORT_C TInt RApaLsSession::GetAppInfo(TApaAppInfo& aInfo, TUid aAppUid) const |
|
477 { |
|
478 TPckg<TApaAppInfo> info(aInfo); |
|
479 return SendReceiveWithReconnect(EAppListServGetAppInfo, TIpcArgs(aAppUid.iUid,&info)); |
|
480 } //lint !e1764 Suppress reference parameter 'aInfo' could be declared const ref |
|
481 |
|
482 /** Sets the short caption of the application. |
|
483 |
|
484 Overrides the short caption specified in the localizable resource file for this application. |
|
485 Short captions set using this API will only take effect until the next device reset. |
|
486 |
|
487 @param aShortCaption The short caption of the application. The maximum length allowed is KApaMaxAppCaption. |
|
488 @param aLanguage The language corresponding to the caption. If this is ELangNone the caption is used |
|
489 for all languages for which a language specific short caption has not been set. |
|
490 @param aAppUid The uid of the application. |
|
491 @return KErrNone if successful, otherwise one of the system wide error codes. |
|
492 */ |
|
493 EXPORT_C TInt RApaLsSession::SetAppShortCaption(const TDesC& aShortCaption, TLanguage aLanguage, TUid aAppUid) |
|
494 { |
|
495 if (aShortCaption.Length() > KApaMaxAppCaption || aShortCaption.Length() == 0) |
|
496 return KErrArgument; |
|
497 |
|
498 return SendReceiveWithReconnect(EAppListServSetAppShortCaption, TIpcArgs(aAppUid.iUid, &aShortCaption, aLanguage)); |
|
499 } //lint !e1762 Suppress member function could be made const |
|
500 |
|
501 |
|
502 /** Gets the default screen-number of the application with the specified UID. |
|
503 |
|
504 @param aDefaultScreenNumber On return, contains the default screen-number, if an application |
|
505 with the specified UID is found. If no matching application is found, then |
|
506 this object is not changed. |
|
507 @param aAppUid The application specific UID. |
|
508 @return KErrNone if successful; KErrNotFound if a matching entry could not be found; |
|
509 otherwise one of the other system wide error codes. |
|
510 */ |
|
511 EXPORT_C TInt RApaLsSession::GetDefaultScreenNumber(TInt& aDefaultScreenNumber, TUid aAppUid) const |
|
512 { |
|
513 const TInt result = SendReceiveWithReconnect(EAppListServGetDefaultScreenNumber, TIpcArgs(aAppUid.iUid)); |
|
514 if (result < 0) |
|
515 return result; |
|
516 |
|
517 aDefaultScreenNumber = result; |
|
518 return KErrNone; |
|
519 } |
|
520 |
|
521 |
|
522 /** Gets the capabilities of the application with the specified UID. |
|
523 |
|
524 @param aCapabilityBuf A modifiable descriptor that, on return, contains the |
|
525 application's capability information. The data returned in the descriptor |
|
526 is mapped by the TApaAppCapability class. If no matching application is found, |
|
527 then the content of this descriptor is not changed. |
|
528 @param aAppUid The application specific UID. |
|
529 @return KErrNone, if successful; KErrNotFound, if no matching entry can be found; otherwise |
|
530 one of the other system wide error codes. |
|
531 */ |
|
532 EXPORT_C TInt RApaLsSession::GetAppCapability(TDes8& aCapabilityBuf,TUid aAppUid) const |
|
533 { |
|
534 return SendReceiveWithReconnect(EAppListServGetAppCapability,TIpcArgs(&aCapabilityBuf,aAppUid.iUid)); |
|
535 } |
|
536 |
|
537 |
|
538 /** Gets the UID of an application that can handle the specified data (MIME) type. |
|
539 |
|
540 If no application can be found, the function returns the UID of the preferred |
|
541 default handler. If none of the default handlers can handle the data type, |
|
542 then a NULL UID is returned. |
|
543 |
|
544 @param aDataType The data (MIME) type. |
|
545 @param aAppUid On return, the UID of the application that can handle the data |
|
546 (MIME) type; this may be NULL. |
|
547 @return KErrNone, if successful; otherwise one of the other system-wide error |
|
548 codes. |
|
549 */ |
|
550 EXPORT_C TInt RApaLsSession::AppForDataType(const TDataType& aDataType, TUid& aAppUid) const |
|
551 { |
|
552 const TPckgC<TDataType> dataType(aDataType); |
|
553 TPckg<TUid> uid(aAppUid); |
|
554 return SendReceiveWithReconnect(EAppListServAppForDataType,TIpcArgs(&dataType,&uid)); |
|
555 } //lint !e1764 Suppress reference parameter 'aAppUid' could be declared const ref |
|
556 |
|
557 |
|
558 /** Gets the available icon sizes for the application with the specified UID. |
|
559 |
|
560 @param aAppUid The application specific UID. |
|
561 @param aArrayToFill On return, the array contains all of the available icon |
|
562 sizes. |
|
563 @return KErrNone, if successful; KErrNotFound, if no matching application can |
|
564 be found; KErrNotSupported, if the application provides icons in non-MBM format; |
|
565 otherwise one of the other system wide error codes. |
|
566 */ |
|
567 EXPORT_C TInt RApaLsSession::GetAppIconSizes(TUid aAppUid, CArrayFixFlat<TSize>& aArrayToFill) const |
|
568 { |
|
569 TRAPD(error, DoGetAppIconSizesL(aAppUid,aArrayToFill)); |
|
570 return error; |
|
571 } |
|
572 |
|
573 void RApaLsSession::DoGetAppIconSizesL(TUid aAppUid, CArrayFixFlat<TSize>& aArrayToFill) const |
|
574 { |
|
575 TSizeArrayFiller arrayFiller(aArrayToFill); |
|
576 FetchArrayL(arrayFiller, aAppUid, EAppListServGetAppIconSizes, KInitialIconBufSize); |
|
577 } |
|
578 |
|
579 /** |
|
580 This method implementes a generic mechanism for retrieving data items from the AppArc server. |
|
581 The data items can be either TSize, TApaAppViewInfo, or TDesC (see MArrayFiller). |
|
582 @internalTechnology |
|
583 */ |
|
584 void RApaLsSession::FetchArrayL(MArrayFiller& aArray, TUid aAppUid, TInt aOpcode, TInt aInitialBufSize) const |
|
585 { |
|
586 // Create a buffer to recieve the data in |
|
587 CBufFlat* buffer = CBufFlat::NewL(aInitialBufSize); |
|
588 CleanupStack::PushL(buffer); |
|
589 |
|
590 // Set its size and create a pointer for writing to it |
|
591 buffer->ExpandL(0,aInitialBufSize); |
|
592 TPtr8 bufPtr = buffer->Ptr(0); |
|
593 |
|
594 // Get the data from the AppArc server |
|
595 |
|
596 const TInt sizeRequired = SendReceiveWithReconnect(aOpcode,TIpcArgs(aAppUid.iUid,buffer->Size(),&bufPtr)); |
|
597 User::LeaveIfError(sizeRequired); // Negative values are error codes |
|
598 if (sizeRequired > 0) // If the initial buffer was too small... |
|
599 { |
|
600 // (This should really never happen - the code below is a backup for release builds only |
|
601 ASSERT(0); // so panic any debug builds) |
|
602 |
|
603 // ...create a bigger one and try again |
|
604 CleanupStack::PopAndDestroy(buffer); |
|
605 buffer = CBufFlat::NewL(sizeRequired); |
|
606 CleanupStack::PushL(buffer); |
|
607 buffer->ExpandL(0, sizeRequired); |
|
608 bufPtr.Set(buffer->Ptr(0)); |
|
609 User::LeaveIfError(SendReceiveWithReconnect(aOpcode, TIpcArgs(aAppUid.iUid, buffer->Size(), &bufPtr))); |
|
610 } |
|
611 |
|
612 // Create a read stream for reading from the buffer |
|
613 RBufReadStream readStream; |
|
614 CleanupClosePushL(readStream); |
|
615 readStream.Open(*buffer); |
|
616 |
|
617 // Get the item count from the stream and popoulate the array |
|
618 const TInt count = readStream.ReadUint32L(); |
|
619 for (TInt i = 0; i < count; ++i) |
|
620 aArray.AppendItemFromStreamL(readStream); |
|
621 |
|
622 CleanupStack::PopAndDestroy(&readStream); |
|
623 CleanupStack::PopAndDestroy(buffer); |
|
624 } |
|
625 |
|
626 |
|
627 /** Gets the nearest matching application icon for the application with the specified |
|
628 UID. |
|
629 |
|
630 The function gets the icon whose size matches the specified size. If there |
|
631 is no exact match, then the function gets the closest smaller icon. |
|
632 |
|
633 This function should be used in preference to the TInt GetAppIcon(TUid,TInt,CApaMaskedBitmap&); |
|
634 overload. |
|
635 |
|
636 @param aAppUid The application specific UID. |
|
637 @param aSize The required size of the icon. |
|
638 @param aAppBitmap On return, the application icon. |
|
639 @return KErrNone, if successful; KErrNotFound, if a matching entry could not be found, or no |
|
640 icon equal to or smaller than the specified size can be found; KErrNotSupported, if the |
|
641 application provides icons in non-MBM format; otherwise one of the other system wide |
|
642 error codes. |
|
643 */ |
|
644 EXPORT_C TInt RApaLsSession::GetAppIcon(TUid aAppUid, TSize aSize, CApaMaskedBitmap& aAppBitmap) const |
|
645 { |
|
646 SReturnData_AppIconByUidAndSize returnData = {0,0}; |
|
647 TPckg<SReturnData_AppIconByUidAndSize> returnData_asDescriptor(returnData); |
|
648 TInt error = SendReceiveWithReconnect(EAppListServAppIconByUidAndSize, TIpcArgs(aAppUid.iUid,aSize.iWidth,aSize.iHeight,&returnData_asDescriptor)); |
|
649 if (!error) |
|
650 { |
|
651 error = aAppBitmap.Duplicate(returnData.iIcon); |
|
652 if (!error) |
|
653 error = aAppBitmap.Mask()->Duplicate(returnData.iIconMask); |
|
654 } |
|
655 |
|
656 return error; |
|
657 } |
|
658 |
|
659 |
|
660 /** |
|
661 gets the bitmap handles from the Server, forms these up into a CApaMaskedBitmap |
|
662 |
|
663 Sets aAppBitmap to be the small, medium or large app icon of the app with uid |
|
664 aAppUid, when aSize=0, 1 or 2 respectively. |
|
665 Panics the caller if a different index is specified. |
|
666 The overload which takes a TSize should be used instead. |
|
667 |
|
668 @deprecated |
|
669 @param aAppUid The application specific UID. |
|
670 @param aSize The required size of the icon. |
|
671 @param aAppBitmap On return, the application icon. |
|
672 @return KErrNone, if successful; KErrNotFound, if a matching entry could not be found, or no |
|
673 icon equal to or smaller than the specified size can be found; KErrNotSupported, if the |
|
674 application provides icons in non-MBM format, otherwise one of the other system wide |
|
675 error codes. |
|
676 */ |
|
677 EXPORT_C TInt RApaLsSession::GetAppIcon(TUid aAppUid, TInt aSize, CApaMaskedBitmap& aAppBitmap) const |
|
678 { |
|
679 __ASSERT_ALWAYS((aSize>=0) && (aSize<3), Panic(EDPanicBadIconSize)); |
|
680 SReturnData_AppIconByUid returnData = {0,0}; |
|
681 TPckg<SReturnData_AppIconByUid> returnData_asDescriptor(returnData); |
|
682 TInt error = SendReceiveWithReconnect(EAppListServAppIconByUid,TIpcArgs(aAppUid.iUid,aSize,&returnData_asDescriptor)); |
|
683 if (!error) |
|
684 { |
|
685 error = aAppBitmap.Duplicate(returnData.iIcon); |
|
686 if (!error) |
|
687 error = aAppBitmap.Mask()->Duplicate(returnData.iIconMask); |
|
688 } |
|
689 |
|
690 return error; |
|
691 } |
|
692 |
|
693 |
|
694 /** Gets an open shareable read only file handle to the application icon file for the |
|
695 application with the specified UID. |
|
696 |
|
697 An icon file can only be defined by applications providing an application registration file. |
|
698 |
|
699 An icon file may be in any graphics format and contain one or more icons. |
|
700 |
|
701 On entering this function, aFile must be non-open. It is recommended that aFile is |
|
702 pushed onto the cleanup-stack (via CleanupClosePushL()) before this function is called. |
|
703 |
|
704 @param aAppUid The application specific UID. |
|
705 @param aFile On return, a read only open file handle to the icon file. |
|
706 @return KErrNone, if successful; KErrNotFound, if a matching application could not be found, |
|
707 or an icon filename was not defined; otherwise one of the other system wide error codes. |
|
708 @see GetAppIcon |
|
709 */ |
|
710 EXPORT_C TInt RApaLsSession::GetAppIcon(TUid aAppUid, RFile& aFile) const |
|
711 { |
|
712 __ASSERT_ALWAYS(aFile.SubSessionHandle() == KNullHandle, Panic(EDPanicHandleAlreadySet)); |
|
713 TPckgBuf<TInt> fileHandle; |
|
714 TInt sessionHandleOrErrorCode = SendReceiveWithReconnect(EAppListServAppIconFileHandle, TIpcArgs(aAppUid.iUid, &fileHandle)); |
|
715 if (sessionHandleOrErrorCode >= KErrNone) |
|
716 { |
|
717 sessionHandleOrErrorCode = aFile.AdoptFromServer(sessionHandleOrErrorCode, fileHandle()); |
|
718 } |
|
719 return sessionHandleOrErrorCode; |
|
720 } |
|
721 |
|
722 |
|
723 /** Gets the data (MIME) type of the data in the specified file and gets the UID |
|
724 of an application that can handle this type. |
|
725 |
|
726 @param aFileName The name of the file containing the data. |
|
727 @param aAppUid On return, the UID of the application that can handle the data |
|
728 (MIME) type; this may be NULL. |
|
729 @param aDataType On return, the data (MIME) type. |
|
730 @return KErrNone, if successful; otherwise one of the other system-wide error |
|
731 codes. */ |
|
732 EXPORT_C TInt RApaLsSession::AppForDocument(const TDesC& aFileName, TUid& aAppUid, TDataType& aDataType) const |
|
733 { |
|
734 return DoAppForDocumentOptionallySpecifyingService(aFileName, TUid::Null(), aAppUid, aDataType, EAppListServAppForDocument); |
|
735 } |
|
736 |
|
737 |
|
738 /** Gets the data (MIME) type of the data in the specified file and gets the UID |
|
739 of an application that can handle this type. |
|
740 |
|
741 @param aFile The file containing the data. Before this function can be called, |
|
742 the file server session which owns this file handle must first be marked as shareable by |
|
743 calling RFs::ShareProtected(). |
|
744 @param aAppUid On return, the UID of the application that can handle the data |
|
745 (MIME) type; this may be NULL. |
|
746 @param aDataType On return, the data (MIME) type. |
|
747 @return KErrNone, if successful; otherwise one of the other system-wide error |
|
748 codes. |
|
749 */ |
|
750 EXPORT_C TInt RApaLsSession::AppForDocument(const RFile& aFile, TUid& aAppUid, TDataType& aDataType) const |
|
751 { |
|
752 return DoAppForDocumentOptionallySpecifyingService(aFile, TUid::Null(), aAppUid, aDataType, EAppListServAppForDocumentPassedByFileHandle); |
|
753 } |
|
754 |
|
755 |
|
756 /** Tests whether the file is a native executable (DLL or EXE). |
|
757 |
|
758 @param aFileName The name of the file containing the data. |
|
759 @param aProgram On return, true, if the file contains application code; false, |
|
760 otherwise. |
|
761 @return KErrNone, if successful; otherwise one of the other system-wide error |
|
762 codes. |
|
763 */ |
|
764 EXPORT_C TInt RApaLsSession::IsProgram(const TDesC& aFileName, TBool& aProgram) const |
|
765 { |
|
766 _LIT(KLitSysBin, "\\sys\\bin\\"); |
|
767 aProgram=(TParsePtrC(aFileName).Path().CompareF(KLitSysBin)==0); |
|
768 return KErrNone; |
|
769 } |
|
770 |
|
771 |
|
772 /** Gets the preferred number of bytes of data to read from a file for the purpose |
|
773 of recognizing the data type. |
|
774 |
|
775 This should be used to determine the size of buffer to pass to the 3-parameter |
|
776 overload of RecognizeData() or to the 4-parameter overload of RecognizeSpecificData(). |
|
777 |
|
778 @param aPreferredBufSize On return, contains either the largest buffer size required |
|
779 by any of the currently installed data-recognizers, or the value that would be |
|
780 returned by GetMaxDataBufSize(), whichever is less. |
|
781 @return KErrNone, if successful; otherwise one of the other system-wide error |
|
782 codes. |
|
783 @see GetMaxDataBufSize() */ |
|
784 EXPORT_C TInt RApaLsSession::GetPreferredBufSize(TInt& aPreferredBufSize) const |
|
785 { |
|
786 const TInt preferredBufSize = SendReceiveWithReconnect(EAppListServPreferredBufSize, TIpcArgs()); |
|
787 if (preferredBufSize < KErrNone) |
|
788 return preferredBufSize; // it's an error |
|
789 |
|
790 aPreferredBufSize = preferredBufSize; |
|
791 return KErrNone; |
|
792 } |
|
793 |
|
794 |
|
795 /** Gets the maximum size of the data that can be read from a file for the purpose |
|
796 of recognizing the data type. |
|
797 |
|
798 To determine the size of buffer to pass to the 3-parameter overload of RecognizeData() |
|
799 or to the 4-parameter overload of RecognizeSpecificData(), use GetPreferredBufSize() |
|
800 rather than this function. |
|
801 |
|
802 @param aBufSize On return, contains the maximum size. |
|
803 @return KErrNone, if successful; otherwise one of the other system-wide error |
|
804 codes. |
|
805 @see SetMaxDataBufSize() |
|
806 @see GetPreferredBufSize() */ |
|
807 EXPORT_C TInt RApaLsSession::GetMaxDataBufSize(TInt& aBufSize) const |
|
808 { |
|
809 const TInt returnValue = SendReceiveWithReconnect(EAppListServGetBufSize, TIpcArgs()); |
|
810 if (returnValue < 0) |
|
811 return returnValue; |
|
812 |
|
813 aBufSize = returnValue; |
|
814 return KErrNone; |
|
815 } |
|
816 |
|
817 |
|
818 /** Sets the maximum size of the data that can be read from a file for the purpose |
|
819 of recognizing the data type. |
|
820 |
|
821 The value is not used when the client explicitly supplies a buffer, for example |
|
822 in calls to RecognizeData() and RecognizeSpecificData(), but is used in the |
|
823 implementation of functions such as StartDocument() and CreateDocument(). |
|
824 |
|
825 Unless explicitly set, a default value of KApaAppListServMaxBuffer is used. |
|
826 |
|
827 @param aBufSize The maximum size of data to be read. |
|
828 @return KErrNone, if successful; otherwise one of the other system-wide error |
|
829 codes. |
|
830 @see CreateDocument() |
|
831 @see StartDocument() |
|
832 @see RecognizeData() |
|
833 @see RecognizeSpecificData() |
|
834 */ |
|
835 EXPORT_C TInt RApaLsSession::SetMaxDataBufSize(TInt aBufSize) |
|
836 { |
|
837 return SendReceiveWithReconnect(EAppListServSetBufSize,TIpcArgs(aBufSize)); |
|
838 } //lint !e1762 Suppress member function could be made const |
|
839 |
|
840 |
|
841 /** Gets the icon for the specified view published by the application that has |
|
842 the specified UID. |
|
843 |
|
844 The icon returned is that which is closest in size to the specified size. |
|
845 |
|
846 @param aAppUid The application specific UID. |
|
847 @param aViewUid The UID identifying the view. |
|
848 @param aSize The requested size of the icon. |
|
849 @param aViewBitmap On return, the icon that is closest in size to the requested |
|
850 size. |
|
851 @return KErrNone, if successful; KErrNotFound, if no matching application nor matching view |
|
852 can be found; KErrNotSupported, if the application provides icons in non-MBM format; |
|
853 otherwise one of the other system wide error codes. |
|
854 */ |
|
855 EXPORT_C TInt RApaLsSession::GetAppViewIcon(TUid aAppUid, TUid aViewUid, const TSize& aSize, CApaMaskedBitmap& aViewBitmap) const |
|
856 { |
|
857 const TApaAppViewIconSizeData appViewIconSizeData(aAppUid, aViewUid, aSize); |
|
858 const TPckgC<TApaAppViewIconSizeData> inputData(appViewIconSizeData); |
|
859 SReturnData_ViewIconByUidAndSize returnData = {0,0}; |
|
860 TPckg<SReturnData_ViewIconByUidAndSize> returnData_asDescriptor(returnData); |
|
861 TInt error = SendReceiveWithReconnect(EAppListServViewIconByUidAndSize,TIpcArgs(&inputData,&returnData_asDescriptor)); |
|
862 if (!error) |
|
863 { |
|
864 error = aViewBitmap.Duplicate(returnData.iIcon); |
|
865 if (!error) |
|
866 error = aViewBitmap.Mask()->Duplicate(returnData.iIconMask); |
|
867 } |
|
868 |
|
869 return error; |
|
870 } |
|
871 |
|
872 |
|
873 /** Gets the views published by the application that has the specified UID. |
|
874 |
|
875 Information on each view is contained in a TApaAppViewInfo object, and this |
|
876 set of objects is put into the array supplied by the caller. |
|
877 |
|
878 @param aAppViews On return, the array contains information on all of the views |
|
879 published by the specified application. |
|
880 @param aAppUid The application specific UID. |
|
881 @return KErrNone, if successful; KErrNotFound, if no matching application can |
|
882 be found; otherwise one of the other system wide error codes. |
|
883 @see TApaAppViewInfo |
|
884 */ |
|
885 EXPORT_C TInt RApaLsSession::GetAppViews(CApaAppViewArray& aAppViews, TUid aAppUid) const |
|
886 { |
|
887 TRAPD(error,DoGetAppViewsL(aAppViews,aAppUid)); |
|
888 return error; |
|
889 } |
|
890 |
|
891 void RApaLsSession::DoGetAppViewsL(CApaAppViewArray& aArrayToFill, TUid aAppUid) const |
|
892 { |
|
893 TViewDataArrayFiller arrayFiller(aArrayToFill); |
|
894 FetchArrayL(arrayFiller, aAppUid, EAppListServGetAppViews, KInitialViewDataBufSize); |
|
895 } |
|
896 |
|
897 |
|
898 /** Gets the list of file names for which the application with the specified |
|
899 UID claims ownership. |
|
900 |
|
901 The list is written to a descriptor array supplied by the caller. |
|
902 |
|
903 Note that if the function fails due to lack of memory, the array is left in |
|
904 an undefined state. |
|
905 |
|
906 @param aAppOwnedFiles On return, the descriptor array contains the file names. |
|
907 @param aAppUid The application specific UID. |
|
908 @return KErrNone, if successful; KErrNotFound, if no matching application can |
|
909 be found; otherwise one of the other system wide error codes. |
|
910 */ |
|
911 EXPORT_C TInt RApaLsSession::GetAppOwnedFiles(CDesCArray& aAppOwnedFiles, TUid aAppUid) const |
|
912 { |
|
913 TRAPD(error,DoGetAppOwnedFilesL(aAppOwnedFiles,aAppUid)); |
|
914 return error; |
|
915 } |
|
916 |
|
917 |
|
918 /** Gets the number of icons defined by the app that has the specified UID |
|
919 |
|
920 Applications that don't define icons in their application information file will |
|
921 return an aCount value of zero when this function is called. |
|
922 |
|
923 @param aAppUid The application specific UID |
|
924 @param aCount On return, contains the number of icons defined by the application |
|
925 @return KErrNone, if successful; KErrNotFound, if a matching application could not be found; |
|
926 KErrNotSupported, if the application provides icons in non-MBM format; otherwise one of |
|
927 the other system-wide error codes. |
|
928 */ |
|
929 EXPORT_C TInt RApaLsSession::NumberOfOwnDefinedIcons(TUid aAppUid, TInt& aCount) const |
|
930 { |
|
931 TPckgBuf<TInt> pckg; |
|
932 const TInt err = SendReceiveWithReconnect(EAppListServNumberOfOwnDefinedIcons,TIpcArgs(aAppUid.iUid,&pckg)); |
|
933 if (!err) |
|
934 aCount = pckg(); |
|
935 |
|
936 return err; |
|
937 } |
|
938 |
|
939 |
|
940 /** Gets the full filename of a file containing application icons for the |
|
941 application with the specified UID. |
|
942 |
|
943 An icon file can only be defined by applications providing an application registration file. |
|
944 |
|
945 An icon file may be in any graphics format and contain one or more icons. |
|
946 |
|
947 @param aAppUid The application specific UID. |
|
948 @param aFullFileName On return, the full filename of a file containing one or more |
|
949 application icons. Returns a pointer to the filename and transfers ownership to the caller. |
|
950 @return KErrNone, if successful; KErrNotFound, if a matching application could not be found, |
|
951 or an icon filename was not defined; KErrNotSupported, if the application does not |
|
952 provide an application registration file; otherwise one of the other system wide error codes. |
|
953 */ |
|
954 EXPORT_C TInt RApaLsSession::GetAppIcon(TUid aAppUid, HBufC*& aFullFileName) const |
|
955 { |
|
956 TFileName fileName; |
|
957 TPckg<TFileName> filenamePckg(fileName); |
|
958 const TInt err = SendReceiveWithReconnect(EAppListServAppIconFileName, TIpcArgs(aAppUid.iUid, &filenamePckg)); |
|
959 if (!err) |
|
960 { |
|
961 HBufC* fullFileName = HBufC::New(fileName.Length()); |
|
962 if (fullFileName == NULL) |
|
963 return KErrNoMemory; |
|
964 else |
|
965 { |
|
966 *fullFileName = fileName; |
|
967 aFullFileName = fullFileName; // ownership transferred to caller |
|
968 } |
|
969 } |
|
970 |
|
971 return err; |
|
972 } |
|
973 |
|
974 |
|
975 /** Gets the full filename of a file containing view-specific icons for the application |
|
976 with the specified UID and view. |
|
977 |
|
978 A file containing view-specific icons can only be defined by applications providing |
|
979 an application registration file. |
|
980 |
|
981 A view icon file may be in any graphics format and contain one or more view icons. |
|
982 |
|
983 @param aAppUid The application specific UID. |
|
984 @param aViewUid The UID identifying the view. |
|
985 @param aFullFileName On return, the full filename of a file containing one or more |
|
986 view icons. Returns a pointer to the filename and transfers ownership to the caller. |
|
987 @return KErrNone, if successful; KErrNotFound, if no matching application nor matching view |
|
988 could be found, or a view icon filename was not defined; KErrNotSupported, if the application |
|
989 does not provide an application registration file; otherwise one of the other system wide error codes. |
|
990 */ |
|
991 EXPORT_C TInt RApaLsSession::GetAppViewIcon(TUid aAppUid, TUid aViewUid, HBufC*& aFullFileName) const |
|
992 { |
|
993 TFileName fileName; |
|
994 TPckg<TFileName> filenamePckg(fileName); |
|
995 const TInt err = SendReceiveWithReconnect(EAppListServAppViewIconFileName, TIpcArgs(aAppUid.iUid, aViewUid.iUid, &filenamePckg)); |
|
996 if (!err) |
|
997 { |
|
998 HBufC* fullFileName = HBufC::New(fileName.Length()); |
|
999 if (fullFileName == NULL) |
|
1000 return KErrNoMemory; |
|
1001 else |
|
1002 { |
|
1003 *fullFileName = fileName; |
|
1004 aFullFileName = fullFileName; // ownership transferred to caller |
|
1005 } |
|
1006 } |
|
1007 |
|
1008 return err; |
|
1009 } |
|
1010 |
|
1011 |
|
1012 /** Changes an existing data type mapping, or adds a new one. |
|
1013 |
|
1014 If the data type is not currently mapped, a new mapping is added. |
|
1015 If the data type is mapped, its mapping is replaced. |
|
1016 |
|
1017 @capability WriteDeviceData Prevent addition of data type mappings by malicious programs. |
|
1018 @param aDataType A new or existing data type. |
|
1019 @param aPriority The priority with which the application handles the data type. |
|
1020 @param aUid The UID of the application to associate with the data type. |
|
1021 @return KErrNone on success, or a system-wide error code. |
|
1022 */ |
|
1023 EXPORT_C TInt RApaLsSession::InsertDataMapping(const TDataType& aDataType, TDataTypePriority aPriority, TUid aUid) |
|
1024 { |
|
1025 return InsertDataMapping(aDataType, aPriority, aUid, KOpenServiceUid); |
|
1026 } |
|
1027 |
|
1028 |
|
1029 /** Changes an existing data type mapping, or adds a new one. |
|
1030 |
|
1031 If the data type is not currently mapped, a new mapping is added. |
|
1032 If the data type is mapped, its mapping is replaced. |
|
1033 |
|
1034 @capability WriteDeviceData Prevent addition of data type mappings by malicious programs. |
|
1035 @param aDataType A new or existing data type. |
|
1036 @param aPriority The priority with which the application handles the data type. |
|
1037 @param aUid The UID of the application to associate with the data type. |
|
1038 @param aServiceUid The UID of the service. |
|
1039 @return KErrNone on success, or a system-wide error code. |
|
1040 @internalComponent |
|
1041 @released |
|
1042 */ |
|
1043 EXPORT_C TInt RApaLsSession::InsertDataMapping(const TDataType& aDataType, TDataTypePriority aPriority, |
|
1044 TUid aUid, TUid aServiceUid) |
|
1045 { |
|
1046 const TPckgC<TDataType> dataType(aDataType); |
|
1047 return SendReceiveWithReconnect(EAppListInsertDataMapping, |
|
1048 TIpcArgs(&dataType, TInt(aPriority), aUid.iUid, aServiceUid.iUid)); |
|
1049 } //lint !e1762 Suppress member function could be made const |
|
1050 |
|
1051 |
|
1052 /** Changes an existing data type mapping, or adds a new one. |
|
1053 If the data type is not currently mapped, it is added. |
|
1054 If the data type is mapped with a priority lower than aPriority, the new mapping replaces the existing one. |
|
1055 Otherwise, no change is made. |
|
1056 |
|
1057 @capability WriteDeviceData Prevent addition of data type mappings by malicious programs. |
|
1058 @param aDataType A new or existing data type. |
|
1059 @param aPriority The priority with which the application handles the data type. |
|
1060 @param aUid The UID of the application to associate with the data type. |
|
1061 @param aInserted Non-zero if the new mapping was added or an existing mapping replaced, zero otherwise. |
|
1062 @return KErrNone on success, or a system-wide error code. |
|
1063 */ |
|
1064 EXPORT_C TInt RApaLsSession::InsertDataMappingIfHigher(const TDataType& aDataType, TDataTypePriority aPriority, TUid aUid, TBool& aInserted) |
|
1065 { |
|
1066 TPckgBuf<TBool> inserted(EFalse); |
|
1067 const TPckgC<TDataType> dataType(aDataType); |
|
1068 const TInt err = SendReceiveWithReconnect(EAppListInsertDataMappingIfHigher, TIpcArgs(&dataType, TInt(aPriority), aUid.iUid, &inserted)); |
|
1069 if(!err) |
|
1070 aInserted = inserted(); |
|
1071 |
|
1072 return err; |
|
1073 } //lint !e1762 Suppress member function could be made const |
|
1074 |
|
1075 |
|
1076 |
|
1077 /** Removes an existing user mapping between an application and data-type made through InsertDataMapping() or InsertDataMappingIfHigher(). |
|
1078 |
|
1079 @capability WriteDeviceData Prevent removal of data type mappings by malicious programs. |
|
1080 @param aDataType Data type whose mapping should be removed. |
|
1081 @panic USER 0 The specified data type cannot be found. Debug builds only. |
|
1082 @return KErrNone on success, or a system-wide error code. |
|
1083 @see InsertDataMapping() |
|
1084 @see InsertDataMappingIfHigher() |
|
1085 */ |
|
1086 EXPORT_C TInt RApaLsSession::DeleteDataMapping(const TDataType& aDataType) |
|
1087 { |
|
1088 return DeleteDataMapping(aDataType, KOpenServiceUid); |
|
1089 } |
|
1090 |
|
1091 |
|
1092 /** Removes an existing data type mapping. |
|
1093 |
|
1094 @capability WriteDeviceData Prevent removal of data type mappings by malicious programs. |
|
1095 @param aDataType Data type whose mapping should be removed. |
|
1096 @param aServiceUid The UID of the service. |
|
1097 @panic USER 0 The specified data type cannot be found. Debug builds only. |
|
1098 @return KErrNone on success, or a system-wide error code. |
|
1099 @internalComponent |
|
1100 @released |
|
1101 */ |
|
1102 EXPORT_C TInt RApaLsSession::DeleteDataMapping(const TDataType& aDataType, TUid aServiceUid) |
|
1103 { |
|
1104 const TPckgC<TDataType> dataType(aDataType); |
|
1105 return SendReceiveWithReconnect(EAppListDeleteDataMapping, TIpcArgs(&dataType, aServiceUid.iUid)); |
|
1106 } //lint !e1762 Suppress member function could be made const |
|
1107 |
|
1108 |
|
1109 /** Gets the application associated with the data type and the service uid from |
|
1110 the datatype store. |
|
1111 |
|
1112 The function will only look into the datatype store and will not use the |
|
1113 default type associations. This is different from the AppForDataTypeAndService() function. |
|
1114 |
|
1115 @param aDataType The data (MIME) type. |
|
1116 @param aAppUid On return, the UID of the application that can handle the data |
|
1117 (MIME) type; this may be NULL. |
|
1118 @param aServiceUid The UID of the service. |
|
1119 @return KErrNone, if successful; otherwise one of the other system-wide error |
|
1120 codes. |
|
1121 @internalComponent |
|
1122 @released |
|
1123 */ |
|
1124 EXPORT_C TInt RApaLsSession::GetAppByDataType(const TDataType& aDataType, TUid aServiceUid, TUid& aAppUid) const |
|
1125 { |
|
1126 const TPckgC<TDataType> dataType(aDataType); |
|
1127 TPckg<TUid> uid(aAppUid); |
|
1128 const TInt returnValue = SendReceiveWithReconnect(EAppListServGetAppByDataType,TIpcArgs(&dataType, aServiceUid.iUid, &uid)); |
|
1129 if (returnValue < 0) |
|
1130 return returnValue; |
|
1131 |
|
1132 return (aAppUid == KNullUid ? KErrNotFound : KErrNone); |
|
1133 } //lint !e1764 Suppress reference parameter 'aAppUid' could be declared const ref |
|
1134 |
|
1135 |
|
1136 /** Determines the current language an application is using to display its |
|
1137 user interface. |
|
1138 @param aAppUid The application specific UID. |
|
1139 @param aLanguage On return, the application language. |
|
1140 @return KErrNone, if successful; KErrNotFound, if a matching application could not be found; |
|
1141 otherwise one of the other system wide error codes. |
|
1142 */ |
|
1143 EXPORT_C TInt RApaLsSession::ApplicationLanguage(TUid aAppUid, TLanguage& aLanguage) const |
|
1144 { |
|
1145 TPckgBuf<TLanguage> pckg; |
|
1146 const TInt err = SendReceiveWithReconnect(EAppListServApplicationLanguage, TIpcArgs(aAppUid.iUid, &pckg)); |
|
1147 if (!err) |
|
1148 aLanguage = pckg(); |
|
1149 |
|
1150 return err; |
|
1151 } |
|
1152 |
|
1153 |
|
1154 /** Gets the services implemented by the application that has the specified |
|
1155 application UID. |
|
1156 |
|
1157 The returned CApaAppServiceInfoArray object contains an array of TApaAppServiceInfo objects. |
|
1158 |
|
1159 Information on each service implementation is contained in a TApaAppServiceInfo object. |
|
1160 |
|
1161 TApaAppServiceInfo::Uid() returns the service UID of the service implemented by the |
|
1162 specified application UID. |
|
1163 |
|
1164 @param aAppUid The application specific UID. |
|
1165 @return A pointer to a CApaAppServiceInfoArray object left on the cleanup stack. |
|
1166 @leave KErrNotFound No matching application can be found, or a matching application |
|
1167 does not implement any services. |
|
1168 @leave KErrNotSupported The specified application does not provide an application |
|
1169 registration file. |
|
1170 @leave KErrNoMemory There is insufficient memory to perform the operation. |
|
1171 @see CApaAppServiceInfoArray::Array() |
|
1172 @see TApaAppServiceInfo |
|
1173 @publishedPartner |
|
1174 @released |
|
1175 */ |
|
1176 EXPORT_C CApaAppServiceInfoArray* RApaLsSession::GetAppServicesLC(TUid aAppUid) const |
|
1177 { |
|
1178 CArrayFixFlat<TApaAppServiceInfo>* serviceArray = new(ELeave) CArrayFixFlat<TApaAppServiceInfo>(4); |
|
1179 CleanupStack::PushL(TCleanupItem(CleanupAppServiceArray, serviceArray)); |
|
1180 CBufBase* buffer = GetServiceBufferLC(EAppListServGetAppServices, aAppUid); |
|
1181 RBufReadStream readStream(*buffer); |
|
1182 readStream >> *serviceArray; |
|
1183 CleanupStack::PopAndDestroy(buffer); |
|
1184 CleanupStack::Pop(serviceArray); |
|
1185 CApaAppServiceInfoArrayImpl* wrapper = CApaAppServiceInfoArrayImpl::NewL(serviceArray); // takes ownership of serviceArray |
|
1186 CleanupStack::PushL(wrapper); |
|
1187 return wrapper; |
|
1188 } |
|
1189 |
|
1190 CBufBase* RApaLsSession::GetServiceBufferLC(TInt aOpcode, TUid aUid1, TUid aUid2/*=KNullUid*/) const |
|
1191 { |
|
1192 CBufFlat* buffer=CBufFlat::NewL(KDefaultBufSize); // allocate buffer with a default size that should be large enough in most cases |
|
1193 CleanupStack::PushL(buffer); |
|
1194 buffer->ExpandL(0,KDefaultBufSize); |
|
1195 TPtr8 bufPtr=buffer->Ptr(0); |
|
1196 const TInt sizeRequired=User::LeaveIfError(SendReceiveWithReconnect(aOpcode,TIpcArgs(aUid1.iUid,aUid2.iUid,buffer->Size(),&bufPtr))); |
|
1197 if (sizeRequired>0) |
|
1198 { |
|
1199 CleanupStack::PopAndDestroy(buffer); |
|
1200 buffer=CBufFlat::NewL(sizeRequired); |
|
1201 CleanupStack::PushL(buffer); |
|
1202 buffer->ExpandL(0,sizeRequired); |
|
1203 bufPtr.Set(buffer->Ptr(0)); |
|
1204 #if defined(_DEBUG) |
|
1205 const TInt check= |
|
1206 #endif |
|
1207 User::LeaveIfError(SendReceiveWithReconnect(aOpcode,TIpcArgs(aUid1.iUid,aUid2.iUid,0,&bufPtr))); |
|
1208 __ASSERT_DEBUG(check==0,User::Invariant()); |
|
1209 } |
|
1210 return buffer; |
|
1211 } |
|
1212 |
|
1213 CBufBase* RApaLsSession::GetServiceBufferLC(TInt aOpcode, TUid aUid1, const TDataType& aDataType) const |
|
1214 { |
|
1215 const TPckgC<TDataType> dataType(aDataType); |
|
1216 CBufFlat* buffer=CBufFlat::NewL(KDefaultBufSize); // allocate buffer with a default size that should be large enough in most cases |
|
1217 CleanupStack::PushL(buffer); |
|
1218 buffer->ExpandL(0,KDefaultBufSize); |
|
1219 TPtr8 bufPtr=buffer->Ptr(0); |
|
1220 const TInt sizeRequired=User::LeaveIfError(SendReceiveWithReconnect(aOpcode,TIpcArgs(aUid1.iUid,&dataType,buffer->Size(),&bufPtr))); |
|
1221 if (sizeRequired>0) |
|
1222 { |
|
1223 CleanupStack::PopAndDestroy(buffer); |
|
1224 buffer=CBufFlat::NewL(sizeRequired); |
|
1225 CleanupStack::PushL(buffer); |
|
1226 buffer->ExpandL(0,sizeRequired); |
|
1227 bufPtr.Set(buffer->Ptr(0)); |
|
1228 #if defined(_DEBUG) |
|
1229 const TInt check= |
|
1230 #endif |
|
1231 User::LeaveIfError(SendReceiveWithReconnect(aOpcode,TIpcArgs(aUid1.iUid,&dataType,0,&bufPtr))); |
|
1232 __ASSERT_DEBUG(check==0,User::Invariant()); |
|
1233 } |
|
1234 return buffer; |
|
1235 } |
|
1236 |
|
1237 |
|
1238 |
|
1239 /** Gets the service implementations for the specified service UID. |
|
1240 |
|
1241 The returned CApaAppServiceInfoArray object contains an array of TApaAppServiceInfo objects. |
|
1242 |
|
1243 Information on each implementation is contained in a TApaAppServiceInfo object. |
|
1244 |
|
1245 TApaAppServiceInfo::Uid() returns the UID of the application that implements the |
|
1246 specified service UID. |
|
1247 |
|
1248 @param aServiceUid The service UID. |
|
1249 @return A pointer to a CApaAppServiceInfoArray object left on the cleanup stack. |
|
1250 @leave KErrNotFound No service implementations for the specified service UID can be found. |
|
1251 @leave EAppListInvalid The server's initial population of the list has not completed. |
|
1252 @leave KErrNoMemory There is insufficient memory to perform the operation. |
|
1253 @see CApaAppServiceInfoArray::Array() |
|
1254 @see TApaAppServiceInfo |
|
1255 @publishedPartner |
|
1256 @released |
|
1257 */ |
|
1258 EXPORT_C CApaAppServiceInfoArray* RApaLsSession::GetServiceImplementationsLC(TUid aServiceUid) const |
|
1259 { |
|
1260 CArrayFixFlat<TApaAppServiceInfo>* serviceArray = new(ELeave) CArrayFixFlat<TApaAppServiceInfo>(4); |
|
1261 CleanupStack::PushL(TCleanupItem(CleanupAppServiceArray, serviceArray)); |
|
1262 CBufBase* buffer = GetServiceBufferLC(EAppListServGetServiceImplementations, aServiceUid); |
|
1263 RBufReadStream readStream(*buffer); |
|
1264 readStream >> *serviceArray; |
|
1265 CleanupStack::PopAndDestroy(buffer); |
|
1266 CleanupStack::Pop(serviceArray); |
|
1267 CApaAppServiceInfoArrayImpl* wrapper = CApaAppServiceInfoArrayImpl::NewL(serviceArray); // takes ownership of serviceArray |
|
1268 CleanupStack::PushL(wrapper); |
|
1269 return wrapper; |
|
1270 } |
|
1271 |
|
1272 EXPORT_C CApaAppServiceInfoArray* RApaLsSession::GetServiceImplementationsLC(TUid aServiceUid, const TDataType& aDataType) const |
|
1273 /** Gets the service implementations for the specified service UID. The implementation must also be |
|
1274 able to handle the data type given as argument. |
|
1275 |
|
1276 The returned CApaAppServiceInfoArray object contains an array of TApaAppServiceInfo objects. |
|
1277 |
|
1278 Information on each implementation is contained in a TApaAppServiceInfo object. |
|
1279 |
|
1280 TApaAppServiceInfo::Uid() returns the UID of the application that implements the |
|
1281 specified service UID. |
|
1282 |
|
1283 @param aServiceUid The service UID. |
|
1284 @param aDataType The data type that must be supported by the implementation. |
|
1285 @return A pointer to a CApaAppServiceInfoArray object left on the cleanup stack. |
|
1286 @leave KErrNotFound No service implementations for the specified service UID can be found. |
|
1287 @leave EAppListInvalid The server's initial population of the list has not completed. |
|
1288 @leave KErrNoMemory There is insufficient memory to perform the operation. |
|
1289 @see CApaAppServiceInfoArray::Array() |
|
1290 @see TApaAppServiceInfo |
|
1291 @publishedPartner |
|
1292 @released |
|
1293 */ |
|
1294 { |
|
1295 CArrayFixFlat<TApaAppServiceInfo>* serviceArray = new(ELeave) CArrayFixFlat<TApaAppServiceInfo>(4); |
|
1296 CleanupStack::PushL(TCleanupItem(CleanupAppServiceArray, serviceArray)); |
|
1297 CBufBase* buffer = GetServiceBufferLC(EAppListServGetServiceImplementationsDataType, aServiceUid, aDataType); |
|
1298 RBufReadStream readStream(*buffer); |
|
1299 readStream >> *serviceArray; |
|
1300 CleanupStack::PopAndDestroy(buffer); |
|
1301 CleanupStack::Pop(serviceArray); |
|
1302 CApaAppServiceInfoArrayImpl* wrapper = CApaAppServiceInfoArrayImpl::NewL(serviceArray); // takes ownership of serviceArray |
|
1303 CleanupStack::PushL(wrapper); |
|
1304 return wrapper; |
|
1305 } |
|
1306 |
|
1307 /** Gets the service UIDs implemented by the application with the specified UID. |
|
1308 |
|
1309 @param aAppUid The application specific UID. |
|
1310 @param aServiceUids On return, contains the service UIDs implemented by the specified |
|
1311 application UID. |
|
1312 @leave KErrNotFound No matching application can be found, or a matching application |
|
1313 does not implement any services. |
|
1314 @leave KErrNotSupported The specified application does not provide an application |
|
1315 registration file. |
|
1316 @leave KErrNoMemory There is insufficient memory to perform the operation. |
|
1317 @publishedPartner |
|
1318 @released |
|
1319 */ |
|
1320 EXPORT_C void RApaLsSession::GetAppServicesL(TUid aAppUid, CArrayFixFlat<TUid>& aServiceUids) const |
|
1321 { |
|
1322 CBufBase* buffer = GetServiceBufferLC(EAppListServGetAppServiceUids, aAppUid); |
|
1323 RBufReadStream readStream(*buffer); |
|
1324 readStream >> aServiceUids; |
|
1325 CleanupStack::PopAndDestroy(buffer); |
|
1326 } |
|
1327 |
|
1328 |
|
1329 |
|
1330 /** Gets the service implementation's opaque data for the specified application and service. |
|
1331 |
|
1332 The specified application may provide more than one implementation of the specified service. |
|
1333 |
|
1334 The returned CApaAppServiceInfoArray object contains an array of TApaAppServiceInfo objects, |
|
1335 each of which provides information on an implementation. |
|
1336 |
|
1337 For each TApaAppServiceInfo object, TApaAppServiceInfo::Uid() returns the specified service UID. |
|
1338 |
|
1339 @param aAppUid The application specific UID. |
|
1340 @param aServiceUid The service UID. |
|
1341 @return A pointer to a CApaAppServiceInfoArray object left on the cleanup stack. |
|
1342 @leave KErrNotFound No matching application can be found, or a matching application |
|
1343 does not implement the specified service. |
|
1344 @leave KErrNotSupported The specified application does not provide an application |
|
1345 registration file. |
|
1346 @leave KErrNoMemory There is insufficient memory to perform the operation. |
|
1347 @see CApaAppServiceInfoArray::Array() |
|
1348 @see TApaAppServiceInfo |
|
1349 @publishedPartner |
|
1350 @released |
|
1351 */ |
|
1352 EXPORT_C CApaAppServiceInfoArray* RApaLsSession::GetAppServiceOpaqueDataLC(TUid aAppUid, TUid aServiceUid) const |
|
1353 { |
|
1354 CArrayFixFlat<TApaAppServiceInfo>* serviceArray = new(ELeave) CArrayFixFlat<TApaAppServiceInfo>(4); |
|
1355 CleanupStack::PushL(TCleanupItem(CleanupAppServiceArray, serviceArray)); |
|
1356 CBufBase* buffer = GetServiceBufferLC(EAppListServGetAppServiceOpaqueData, aAppUid, aServiceUid); |
|
1357 RBufReadStream readStream(*buffer); |
|
1358 readStream >> *serviceArray; |
|
1359 CleanupStack::PopAndDestroy(buffer); |
|
1360 CleanupStack::Pop(serviceArray); |
|
1361 CApaAppServiceInfoArrayImpl* wrapper = CApaAppServiceInfoArrayImpl::NewL(serviceArray); // takes ownership of serviceArray |
|
1362 CleanupStack::PushL(wrapper); |
|
1363 return wrapper; |
|
1364 } |
|
1365 |
|
1366 |
|
1367 /** Gets the UID of an application that can handle the specified data (MIME) type and service. |
|
1368 |
|
1369 If no application can be found, the function returns the UID of the preferred |
|
1370 default handler. If none of the default handlers can handle the combination |
|
1371 of data type and service, then a NULL UID is returned in aAppUid. |
|
1372 |
|
1373 @param aDataType The data (MIME) type. |
|
1374 @param aServiceUid The service UID. |
|
1375 @param aAppUid On return, the UID of the application that can handle the data |
|
1376 (MIME) type and service; this may be NULL. |
|
1377 @return KErrNone, if successful; otherwise one of the other system-wide error |
|
1378 codes. |
|
1379 @publishedPartner |
|
1380 @released |
|
1381 */ |
|
1382 EXPORT_C TInt RApaLsSession::AppForDataTypeAndService(const TDataType& aDataType, TUid aServiceUid, TUid& aAppUid) const |
|
1383 { |
|
1384 const TPckgC<TDataType> dataType(aDataType); |
|
1385 TPckg<TUid> uid(aAppUid); |
|
1386 return SendReceiveWithReconnect(EAppListServAppForDataTypeAndService,TIpcArgs(&dataType, aServiceUid.iUid,&uid)); |
|
1387 } //lint !e1764 Suppress reference parameter 'aAppUid' could be declared const ref |
|
1388 |
|
1389 EXPORT_C TInt RApaLsSession::AppForDocumentAndService(const TDesC& aFileName, TUid aServiceUid, TUid& aAppUid, TDataType& aDataType) const |
|
1390 /** Gets the data (MIME) type of the data in the specified file and gets the UID |
|
1391 of an application that can handle this type and service. |
|
1392 |
|
1393 @param aFileName The name of the file containing the data. |
|
1394 @param aServiceUid The service UID |
|
1395 @param aUid On return, the UID of the application that can handle the data |
|
1396 (MIME) type and service; this may be NULL. |
|
1397 @param aDataType On return, the data (MIME) type. |
|
1398 @return KErrNone, if successful; otherwise one of the other system-wide error |
|
1399 codes. |
|
1400 @publishedPartner |
|
1401 @released |
|
1402 */ |
|
1403 { |
|
1404 return DoAppForDocumentOptionallySpecifyingService(aFileName, aServiceUid, aAppUid, aDataType, EAppListServAppForDocumentAndService); |
|
1405 } |
|
1406 |
|
1407 EXPORT_C TInt RApaLsSession::AppForDocumentAndService(const RFile& aFile, TUid aServiceUid, TUid& aAppUid, TDataType& aDataType) const |
|
1408 /** Gets the data (MIME) type of the data in the specified file and gets the UID |
|
1409 of an application that can handle this type and service. |
|
1410 |
|
1411 @param aFile The file handle. Before this function can be called, |
|
1412 the file server session which owns this file handle must first be marked as shareable by |
|
1413 calling RFs::ShareProtected(). |
|
1414 @param aServiceUid The service UID. |
|
1415 @param aUid On return, the UID of the application that can handle the data |
|
1416 (MIME) type and service; this may be NULL. |
|
1417 @param aDataType On return, the data (MIME) type. |
|
1418 @return KErrNone, if successful; otherwise one of the other system-wide error |
|
1419 codes. |
|
1420 @publishedPartner |
|
1421 @released |
|
1422 */ |
|
1423 { |
|
1424 return DoAppForDocumentOptionallySpecifyingService(aFile, aServiceUid, aAppUid, aDataType, EAppListServAppForDocumentAndServicePassedByFileHandle); |
|
1425 } |
|
1426 |
|
1427 TInt RApaLsSession::DoAppForDocumentOptionallySpecifyingService(const TDesC& aFileName, TUid aServiceUid, TUid& aAppUid, TDataType& aDataType, TInt aOpcode) const |
|
1428 { |
|
1429 if (!aFileName.Length()) |
|
1430 { |
|
1431 aAppUid = KNullUid; |
|
1432 return KErrNone; |
|
1433 } |
|
1434 |
|
1435 HBufC8* buffer = NULL; |
|
1436 TInt error = GetNewBufferFromFile(buffer, aFileName); |
|
1437 if (error) |
|
1438 return error; |
|
1439 |
|
1440 SReturnData_AppForDocument returnData; |
|
1441 TPckg<SReturnData_AppForDocument> returnData_asDescriptor(returnData); |
|
1442 error = SendReceiveWithReconnect(aOpcode, TIpcArgs(&returnData_asDescriptor, aServiceUid.iUid, &aFileName, buffer)); |
|
1443 delete buffer; |
|
1444 buffer = NULL; |
|
1445 |
|
1446 if (!error) |
|
1447 { |
|
1448 aAppUid = returnData.iUid; |
|
1449 aDataType = returnData.iDataType; |
|
1450 } |
|
1451 |
|
1452 return error; |
|
1453 } |
|
1454 |
|
1455 /** |
|
1456 */ |
|
1457 TInt RApaLsSession::DoAppForDocumentOptionallySpecifyingService(const RFile& aFile, TUid aServiceUid, TUid& aAppUid, TDataType& aDataType, TInt aOpcode) const |
|
1458 { |
|
1459 SReturnData_AppForDocument returnData; |
|
1460 TPckg<SReturnData_AppForDocument> returnData_asDescriptor(returnData); |
|
1461 TIpcArgs ipcArgs(&returnData_asDescriptor, aServiceUid.iUid); |
|
1462 TInt error = aFile.TransferToServer(ipcArgs, 2, 3); |
|
1463 if (!error) |
|
1464 error = SendReceiveWithReconnect(aOpcode, ipcArgs); |
|
1465 |
|
1466 if (!error) |
|
1467 { |
|
1468 aAppUid = returnData.iUid; |
|
1469 aDataType = returnData.iDataType; |
|
1470 } |
|
1471 |
|
1472 return error; |
|
1473 } |
|
1474 |
|
1475 /** |
|
1476 */ |
|
1477 TInt RApaLsSession::GetNewBufferFromFile(HBufC8*& aBuffer, const TDesC& aFileName) const |
|
1478 { |
|
1479 aBuffer = NULL; |
|
1480 TInt preferredBufSize = 0; |
|
1481 const TInt error = GetPreferredBufSize(preferredBufSize); |
|
1482 if (error < KErrNone) |
|
1483 return error; |
|
1484 |
|
1485 HBufC8* const buffer = HBufC8::New(Max(8, preferredBufSize)); // 8 is a sensible minimum |
|
1486 if (!buffer) |
|
1487 return KErrNoMemory; |
|
1488 |
|
1489 const RFs* fsSession = FsSession(); |
|
1490 RFs tempFsSession; |
|
1491 if (!fsSession) |
|
1492 { |
|
1493 const TInt error = tempFsSession.Connect(); |
|
1494 if (error) |
|
1495 { |
|
1496 delete buffer; |
|
1497 return error; |
|
1498 } |
|
1499 |
|
1500 fsSession = &tempFsSession; |
|
1501 } |
|
1502 |
|
1503 if (fsSession->IsValidName(aFileName)) |
|
1504 { |
|
1505 TPtr8 buffer_asWritable(buffer->Des()); |
|
1506 const TInt error = fsSession->ReadFileSection(aFileName, 0, buffer_asWritable, preferredBufSize); |
|
1507 if (error) |
|
1508 { |
|
1509 delete buffer; |
|
1510 tempFsSession.Close(); |
|
1511 return error; |
|
1512 } |
|
1513 } |
|
1514 |
|
1515 if (fsSession == &tempFsSession) |
|
1516 tempFsSession.Close(); |
|
1517 |
|
1518 aBuffer = buffer; |
|
1519 return KErrNone; |
|
1520 } |
|
1521 |
|
1522 |
|
1523 /** |
|
1524 @internalTechnology |
|
1525 */ |
|
1526 EXPORT_C void RApaLsSession::SetFsSessionL(RFs& aFsSession) |
|
1527 { // static |
|
1528 User::LeaveIfError(Dll::SetTls(&aFsSession)); |
|
1529 } |
|
1530 |
|
1531 /** |
|
1532 @internalTechnology |
|
1533 */ |
|
1534 EXPORT_C void RApaLsSession::ClearFsSession() |
|
1535 { // static |
|
1536 Dll::FreeTls(); |
|
1537 } |
|
1538 |
|
1539 /** |
|
1540 @internalTechnology |
|
1541 */ |
|
1542 EXPORT_C RFs* RApaLsSession::FsSession() |
|
1543 { // static |
|
1544 return static_cast<RFs*>(Dll::Tls()); |
|
1545 } |
|
1546 |
|
1547 /** @publishedPartner */ |
|
1548 EXPORT_C void RApaLsSession::RegisterNonNativeApplicationTypeL(TUid aApplicationType, const TDesC& aNativeExecutable) |
|
1549 { |
|
1550 User::LeaveIfError(SendReceiveWithReconnect(EAppListServRegisterNonNativeApplicationType, TIpcArgs(aApplicationType.iUid, &aNativeExecutable))); |
|
1551 } //lint !e1762 Suppress member function could be made const |
|
1552 |
|
1553 /** @publishedPartner */ |
|
1554 EXPORT_C void RApaLsSession::DeregisterNonNativeApplicationTypeL(TUid aApplicationType) |
|
1555 { |
|
1556 User::LeaveIfError(SendReceiveWithReconnect(EAppListServDeregisterNonNativeApplicationType, TIpcArgs(aApplicationType.iUid))); |
|
1557 } //lint !e1762 Suppress member function could be made const |
|
1558 |
|
1559 /** @publishedPartner */ |
|
1560 EXPORT_C void RApaLsSession::PrepareNonNativeApplicationsUpdatesL() |
|
1561 { |
|
1562 TIpcArgs ipcArgs(0, 0, 0, 0); |
|
1563 User::LeaveIfError(SendReceiveWithReconnect(EAppListServPrepareNonNativeApplicationsUpdates, ipcArgs)); |
|
1564 } //lint !e1762 Suppress member function could be made const |
|
1565 |
|
1566 /** @publishedPartner */ |
|
1567 EXPORT_C void RApaLsSession::RegisterNonNativeApplicationL(TUid aApplicationType, const TDriveUnit& aDrive, CApaRegistrationResourceFileWriter& aRegistrationResourceFile, CApaLocalisableResourceFileWriter* aLocalisableResourceFile, const RFile* aIconFile) |
|
1568 { |
|
1569 TIpcArgs ipcArgs(0, 0, 0, 0); |
|
1570 RBuf8 ipcParameter0; |
|
1571 CleanupClosePushL(ipcParameter0); |
|
1572 RBuf8 ipcParameter1; |
|
1573 CleanupClosePushL(ipcParameter1); |
|
1574 if (aLocalisableResourceFile==NULL) |
|
1575 { |
|
1576 __ASSERT_ALWAYS(aIconFile==NULL, Panic(EPanicIconFileWithoutLocalisableResourceFile)); |
|
1577 ipcArgs.Set(1, NULL); |
|
1578 } |
|
1579 else |
|
1580 { |
|
1581 TParse* const parser=new(ELeave) TParse; |
|
1582 CleanupStack::PushL(parser); |
|
1583 const TDriveName driveName(aDrive.Name()); // TDriveName is a TBuf<2> |
|
1584 |
|
1585 if (aIconFile!=NULL) |
|
1586 { |
|
1587 User::LeaveIfError(aIconFile->TransferToServer(ipcArgs, 2, 3)); |
|
1588 |
|
1589 TFileName* const fileName=new(ELeave) TFileName; |
|
1590 CleanupStack::PushL(fileName); |
|
1591 User::LeaveIfError(aIconFile->Name(*fileName)); |
|
1592 parser->SetNoWild(*fileName, &KLitPathForNonNativeResourceAndIconFiles, &driveName); |
|
1593 aLocalisableResourceFile->SetIconFileL(parser->FullName()); |
|
1594 CleanupStack::PopAndDestroy(fileName); |
|
1595 } |
|
1596 aLocalisableResourceFile->GenerateFileContentsL(ipcParameter1); // must be done after the aLocalisableResourceFile->SetIconFileL call (if there is one) |
|
1597 const TDesC8& ipcParameter1_asConst=ipcParameter1; |
|
1598 ipcArgs.Set(1, &ipcParameter1_asConst); |
|
1599 |
|
1600 TBuf<30> fileName; |
|
1601 fileName.Format(KLitFormatForLocalisableResourceFile, aRegistrationResourceFile.AppUid().iUid); |
|
1602 parser->SetNoWild(fileName, &KLitPathForNonNativeResourceAndIconFiles, &driveName); |
|
1603 aRegistrationResourceFile.SetLocalisableResourceFileL(parser->FullName()); |
|
1604 |
|
1605 CleanupStack::PopAndDestroy(parser); |
|
1606 } |
|
1607 |
|
1608 aRegistrationResourceFile.GenerateFileContentsL(ipcParameter0); // must be done after the aRegistrationResourceFile.SetLocalisableResourceFileL call (if there is one) |
|
1609 SNonNativeApplicationInfo nonNativeApplicationInfo; |
|
1610 nonNativeApplicationInfo.iApplicationType=aApplicationType; |
|
1611 nonNativeApplicationInfo.iDrive=aDrive; |
|
1612 ipcParameter0.ReAllocL(sizeof(SNonNativeApplicationInfo)+ipcParameter0.Length()); |
|
1613 ipcParameter0.Insert(0, TPckgC<SNonNativeApplicationInfo>(nonNativeApplicationInfo)); |
|
1614 const TDesC8& ipcParameter0_asConst=ipcParameter0; |
|
1615 ipcArgs.Set(0, &ipcParameter0_asConst); |
|
1616 |
|
1617 User::LeaveIfError(SendReceiveWithReconnect(EAppListServRegisterNonNativeApplication, ipcArgs)); |
|
1618 CleanupStack::PopAndDestroy(2, &ipcParameter0); |
|
1619 } //lint !e1762 Suppress member function could be made const |
|
1620 |
|
1621 /** @publishedPartner */ |
|
1622 EXPORT_C void RApaLsSession::DeregisterNonNativeApplicationL(TUid aApplication) |
|
1623 { |
|
1624 User::LeaveIfError(SendReceiveWithReconnect(EAppListServDeregisterNonNativeApplication, TIpcArgs(aApplication.iUid))); |
|
1625 } //lint !e1762 Suppress member function could be made const |
|
1626 |
|
1627 /** |
|
1628 Commits the non-native application updates. This is a synchronous method which waits |
|
1629 until the application list is updated. |
|
1630 |
|
1631 @see ForceCommitNonNativeApplicationsUpdatesL |
|
1632 @publishedPartner |
|
1633 @released |
|
1634 */ |
|
1635 |
|
1636 EXPORT_C void RApaLsSession::CommitNonNativeApplicationsUpdatesL() |
|
1637 { |
|
1638 TIpcArgs ipcArgs(EFalse, 0, 0, 0); |
|
1639 User::LeaveIfError(SendReceiveWithReconnect(EAppListServCommitNonNativeApplications, ipcArgs)); |
|
1640 } //lint !e1762 Suppress member function could be made const |
|
1641 |
|
1642 |
|
1643 /** |
|
1644 Commits the non-native application updates. This is an asynchronous method which will not wait until |
|
1645 the application list is updated. CApaAppListNotifier class should be used to synchronize the completion |
|
1646 of updating the application list. |
|
1647 |
|
1648 @see CommitNonNativeApplicationsUpdatesL |
|
1649 @see CApaAppListNotifier |
|
1650 @publishedPartner |
|
1651 @released |
|
1652 */ |
|
1653 |
|
1654 EXPORT_C void RApaLsSession::ForceCommitNonNativeApplicationsUpdatesL() |
|
1655 { |
|
1656 TIpcArgs ipcArgs(ETrue, 0, 0, 0); |
|
1657 User::LeaveIfError(SendReceiveWithReconnect(EAppListServCommitNonNativeApplications, ipcArgs)); |
|
1658 } |
|
1659 |
|
1660 /** |
|
1661 Rolls back all changes made to the list of installed non-native applications since the last call to |
|
1662 PrepareNonNativeApplicationsUpdatesL(). |
|
1663 |
|
1664 This function can be called even if PrepareNonNativeApplicationsUpdatesL() hasn't been called before (in which |
|
1665 case it does nothing). |
|
1666 |
|
1667 @publishedPartner |
|
1668 */ |
|
1669 EXPORT_C TInt RApaLsSession::RollbackNonNativeApplicationsUpdates() |
|
1670 { |
|
1671 TIpcArgs ipcArgs(0, 0, 0, 0); |
|
1672 return SendReceiveWithReconnect(EAppListServRollbackNonNativeApplications, ipcArgs); |
|
1673 } //lint !e1762 Suppress member function could be made const |
|
1674 |
|
1675 /** |
|
1676 @internalTechnology |
|
1677 */ |
|
1678 EXPORT_C void RApaLsSession::SetNotify(TBool aCompleteImmediatelyIfNoScanImpendingOrInProgress, TRequestStatus& aStatus) |
|
1679 { |
|
1680 SendReceive(ESetNotify,TIpcArgs(aCompleteImmediatelyIfNoScanImpendingOrInProgress),aStatus); |
|
1681 } //lint !e1762 Suppress member function could be made const |
|
1682 |
|
1683 /** |
|
1684 @internalTechnology |
|
1685 */ |
|
1686 EXPORT_C void RApaLsSession::CancelNotify() |
|
1687 { |
|
1688 SendReceive(ECancelNotify,TIpcArgs()); |
|
1689 } //lint !e1762 Suppress member function could be made const |
|
1690 |
|
1691 /** |
|
1692 Gets the application type of the application. For a native application the type is KNullUid. |
|
1693 @return A standard error code. |
|
1694 @publishedPartner |
|
1695 @released |
|
1696 @param aTypeUid On return contains the application's type |
|
1697 @param aAppUid The application's UID passed into TIpcArgs |
|
1698 */ |
|
1699 EXPORT_C TInt RApaLsSession::GetAppType(TUid& aTypeUid, TUid aAppUid) const |
|
1700 { |
|
1701 TPckg<TUid> uid(aTypeUid); |
|
1702 return SendReceiveWithReconnect(EAppListServGetAppType,TIpcArgs(aAppUid.iUid,&uid)); |
|
1703 } //lint !e1764 Suppress reference parameter 'aTypeUid' could be declared const ref |
|
1704 |
|
1705 /** |
|
1706 This function is only for use by Software Install. |
|
1707 |
|
1708 As part of the fix for defect INC069526, we added a check in apparc. We check if the application has |
|
1709 been installed before adding it to the apparc db. A side-effect of this fix is that it is not possible |
|
1710 to launch applications that are being installed from the installation process itself. This is a regresssion. |
|
1711 |
|
1712 To fix this regression we added this function. It allows Software Install to specify a list of registration |
|
1713 files that need to be included in apparc's list even if they have not been marked as installed in the |
|
1714 SISRegistry or JavaRegistry. The list of registration files is cleared once Software Install notifies |
|
1715 (via P&S) the end of the installation (whether successful or not). |
|
1716 The function also forces a rescan and only returns when this rescan is complete. This is because |
|
1717 Software Install needs to be sure the registration files have been added to apparc's list before |
|
1718 trying to launch the recently installed applications. |
|
1719 |
|
1720 @param aRegFiles The list of registration files for which the SISRegistry check must be ignored. |
|
1721 @return A standard error code. |
|
1722 @internalAll |
|
1723 @released |
|
1724 */ |
|
1725 EXPORT_C TInt RApaLsSession::ForceRegistration(const RPointerArray<TDesC>& aRegFiles) |
|
1726 { |
|
1727 CBufFlat* buffer = 0; |
|
1728 TRAPD(err, buffer = CreateRegFilesBufferL(aRegFiles)); |
|
1729 if (err) |
|
1730 return err; |
|
1731 |
|
1732 TPtr8 ptr = buffer->Ptr(0); |
|
1733 const TInt returnValue=SendReceiveWithReconnect(EAppListServForceRegistration,TIpcArgs(&ptr)); |
|
1734 delete buffer; |
|
1735 return returnValue; |
|
1736 } //lint !e1762 Suppress member function could be made const |
|
1737 |
|
1738 |
|
1739 /** |
|
1740 Make a call to AppArc server's aFunction, passing it aIpcArgs. |
|
1741 */ |
|
1742 TInt RApaLsSession::SendReceiveWithReconnect(TInt aFunction, const TIpcArgs& aIpcArgs) const |
|
1743 { |
|
1744 TInt ret = SendReceive(aFunction, aIpcArgs); |
|
1745 if(ret != KErrServerTerminated) |
|
1746 { |
|
1747 return ret; |
|
1748 } |
|
1749 |
|
1750 RApaLsSession ls; |
|
1751 TInt err=ls.Connect(); |
|
1752 if (err==KErrNone) |
|
1753 { |
|
1754 RApaLsSession* const localThis = const_cast<RApaLsSession*>(this); |
|
1755 localThis->Close(); |
|
1756 localThis->iHandle=ls.iHandle; |
|
1757 ret = SendReceive(aFunction, aIpcArgs); |
|
1758 } |
|
1759 return ret; |
|
1760 } |
|
1761 |
|
1762 void RApaLsSession::DoGetAppOwnedFilesL(CDesCArray& aArrayToFill, TUid aAppUid) const |
|
1763 { |
|
1764 TDesCArrayFiller arrayFiller(aArrayToFill); |
|
1765 FetchArrayL(arrayFiller, aAppUid, EAppListServGetFileOwnershipInfo, KInitialOwnedFilesBufSize); |
|
1766 } |
|
1767 |
|
1768 |
|
1769 /** Registers an observer with apparc server to notify when the initial population of applist is completed |
|
1770 |
|
1771 @param aStatus Request status object. On successful completion contains KErrNone, otherwise one of the |
|
1772 system-wide error codes. |
|
1773 @see CancelListPopulationCompleteObserver() |
|
1774 */ |
|
1775 EXPORT_C void RApaLsSession::RegisterListPopulationCompleteObserver(TRequestStatus& aStatus) const |
|
1776 { |
|
1777 SendReceive(ERegisterListPopulationCompleteObserver,TIpcArgs(TIpcArgs::ENothing),aStatus); |
|
1778 } |
|
1779 |
|
1780 |
|
1781 /** Cancels the observer registered with apparc server to notify when the initial population of applist is completed |
|
1782 |
|
1783 @return KErrNone, if successful; otherwise one of the system-wide error codes. |
|
1784 */ |
|
1785 EXPORT_C TInt RApaLsSession::CancelListPopulationCompleteObserver() const |
|
1786 { |
|
1787 return SendReceiveWithReconnect(ECancelListPopulationCompleteObserver,TIpcArgs(TIpcArgs::ENothing)); |
|
1788 } |
|
1789 |
|
1790 |
|
1791 /** Tests whether the given TSecurityPolicy matches with the application TSecurityPolicy. |
|
1792 |
|
1793 @param aMatches On return, contains the result. ETrue if the application TSecurityPolicy matches the given TSecurityPolicy or else EFalse |
|
1794 @param aAppUid Uid of the application for which the security policy has to be matched |
|
1795 @param aSecurityPolicy TSecurityPolicy to test whether the application with given uid matches with its TSecurityPolicy or not. |
|
1796 @return KErrNone, if successful; otherwise one of the other system-wide error codes. |
|
1797 @see TSecurityPolicy |
|
1798 */ |
|
1799 EXPORT_C TInt RApaLsSession::MatchesSecurityPolicy(TBool& aMatches, TUid aAppUid, const TSecurityPolicy& aSecurityPolicy) const |
|
1800 { |
|
1801 const TPckgC<TSecurityPolicy> securityPolicy(aSecurityPolicy); |
|
1802 const TInt result = SendReceiveWithReconnect(EMatchesSecurityPolicy,TIpcArgs(aAppUid.iUid, &securityPolicy)); |
|
1803 |
|
1804 if (result>=0) |
|
1805 aMatches = result; |
|
1806 |
|
1807 return result; |
|
1808 } |
|
1809 |
|
1810 |
|
1811 EXPORT_C void RApaLsSession::RApaLsSession_Reserved1() |
|
1812 { |
|
1813 } |
|
1814 |
|
1815 EXPORT_C void RApaLsSession::RApaLsSession_Reserved2() |
|
1816 { |
|
1817 } |
|
1818 |
|
1819 |
|
1820 /** Notification of changes in data-type mapping |
|
1821 |
|
1822 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. |
|
1823 |
|
1824 @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. |
|
1825 @see CancelNotifyOnDataTypeMappingChange |
|
1826 */ |
|
1827 EXPORT_C void RApaLsSession::NotifyOnDataMappingChange(TRequestStatus& aRequestStatus) |
|
1828 { |
|
1829 SendReceive(ENotifyOnDataMappingChange,TIpcArgs(), aRequestStatus); |
|
1830 } //lint !e1762 Suppress member function could be made const |
|
1831 |
|
1832 |
|
1833 /** Cancellation of notification of changes in data-type mapping |
|
1834 |
|
1835 This cancels the outstanding the NotifyOnDataTypeMappingChange issued by this client, if there is one outstanding. Otherwise it does nothing. |
|
1836 @see NotifyOnDataTypeMappingChange |
|
1837 */ |
|
1838 EXPORT_C void RApaLsSession::CancelNotifyOnDataMappingChange() |
|
1839 { |
|
1840 SendReceive(ECancelNotifyOnDataMappingChange,TIpcArgs()); |
|
1841 } //lint !e1762 Suppress member function could be made const |
|
1842 |
|
1843 |
|
1844 CBufFlat* RApaLsSession::CreateRegFilesBufferL(const RPointerArray<TDesC>& aRegFiles) |
|
1845 { |
|
1846 // Serialize the array |
|
1847 // Format of the buffer is : |
|
1848 // 4 bytes for array item count |
|
1849 // for each item : 4 bytes for length and then the string contents |
|
1850 const TInt count = aRegFiles.Count(); |
|
1851 TInt requiredBufferSize = 4; // For the array item count |
|
1852 for (TInt index = 0; index < count; ++index) |
|
1853 { |
|
1854 requiredBufferSize += 4; // For the string length |
|
1855 requiredBufferSize += aRegFiles[index]->Size(); |
|
1856 } |
|
1857 |
|
1858 CBufFlat* const buffer = CBufFlat::NewL(requiredBufferSize); |
|
1859 CleanupStack::PushL(buffer); |
|
1860 buffer->ExpandL(0,requiredBufferSize); |
|
1861 RBufWriteStream writeStream; |
|
1862 writeStream.Open(*buffer); |
|
1863 CleanupClosePushL(writeStream); |
|
1864 writeStream.WriteUint32L(count); |
|
1865 for (TInt index = 0; index < count; ++index) |
|
1866 { |
|
1867 writeStream.WriteUint32L(aRegFiles[index]->Length()); |
|
1868 writeStream.WriteL(*aRegFiles[index]); |
|
1869 } |
|
1870 |
|
1871 writeStream.CommitL(); |
|
1872 CleanupStack::PopAndDestroy(&writeStream); |
|
1873 CleanupStack::Pop(buffer); |
|
1874 return buffer; |
|
1875 } |