|
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 // |
|
15 |
|
16 #include "apgnotif.h" |
|
17 #include "APGSTD.H" |
|
18 |
|
19 EXPORT_C CApaAppListNotifier::~CApaAppListNotifier() |
|
20 /** The destructor calls Cancel() and closes the session with the server. |
|
21 |
|
22 @see CActive::Cancel() */ |
|
23 { |
|
24 Cancel(); |
|
25 iLsSession.Close(); |
|
26 } |
|
27 |
|
28 |
|
29 EXPORT_C CApaAppListNotifier* CApaAppListNotifier::NewL(MApaAppListServObserver* aObserver, TPriority aPriority) |
|
30 /** Allocates and constructs an application list change notifier. |
|
31 |
|
32 It creates a session with the application architecture server (RApaLsSession), |
|
33 issues the notification request to the server and adds itself to the active scheduler. |
|
34 |
|
35 @param aObserver Observer whose HandleAppListEvent() function is called when application list is changed. |
|
36 @param aPriority The active object priority. |
|
37 @return The application list change notifier. */ |
|
38 { |
|
39 __ASSERT_DEBUG(aObserver!=NULL,Panic(EDPanicInvalidObserver)); |
|
40 CApaAppListNotifier* self=new(ELeave) CApaAppListNotifier(*aObserver, aPriority); |
|
41 CleanupStack::PushL(self); |
|
42 self->ConstructL(); |
|
43 CleanupStack::Pop(); // self |
|
44 return self; |
|
45 } |
|
46 |
|
47 CApaAppListNotifier::CApaAppListNotifier(MApaAppListServObserver& aObserver, TPriority aPriority) |
|
48 :CActive(aPriority), |
|
49 iObserver(aObserver) |
|
50 { |
|
51 } |
|
52 |
|
53 void CApaAppListNotifier::ConstructL() |
|
54 { |
|
55 User::LeaveIfError(iLsSession.Connect()); |
|
56 iLsSession.SetNotify(EFalse, iStatus); |
|
57 CActiveScheduler::Add(this); |
|
58 SetActive(); |
|
59 } |
|
60 |
|
61 void CApaAppListNotifier::DoCancel() |
|
62 { |
|
63 iLsSession.CancelNotify(); |
|
64 } |
|
65 |
|
66 void CApaAppListNotifier::RunL() |
|
67 { |
|
68 TInt status=iStatus.Int(); |
|
69 iLsSession.SetNotify(EFalse, iStatus); // requeue before handling in case the handling changes things |
|
70 SetActive(); |
|
71 User::LeaveIfError(status); |
|
72 // On Leave, its not necessary to inform observers as nothing is updated |
|
73 iObserver.HandleAppListEvent(status); |
|
74 } |
|
75 |
|
76 //This function is implemented to avoid panic the clients (with E32USER-CBase 47) when RunL leaves |
|
77 TInt CApaAppListNotifier::RunError(TInt /*aError*/) |
|
78 { |
|
79 return KErrNone; |
|
80 } |
|
81 |
|
82 // |
|
83 // MApaAppListServObserver |
|
84 // |
|
85 /** Constructor for MApaAppListServObserver */ |
|
86 EXPORT_C MApaAppListServObserver::MApaAppListServObserver() |
|
87 { |
|
88 } |
|
89 |
|
90 /** Reserved for future use */ |
|
91 EXPORT_C void MApaAppListServObserver::MApaAppListServObserver_Reserved1() |
|
92 { |
|
93 } |
|
94 |
|
95 /** Reserved for future use */ |
|
96 EXPORT_C void MApaAppListServObserver::MApaAppListServObserver_Reserved2() |
|
97 { |
|
98 } |