|
1 /* |
|
2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Listener class for Ecom events |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "epos_csuplecomeventwatcher.h" |
|
21 |
|
22 |
|
23 // ================= MEMBER FUNCTIONS ======================= |
|
24 |
|
25 //------------------------------------------- |
|
26 // Two phased constructor. |
|
27 //------------------------------------------- |
|
28 // |
|
29 CSuplEcomEventWatcher* CSuplEcomEventWatcher::NewL(MSuplEcomEventObserver& aSuplEcomEventObserver, TUid aInterfaceUid, TUid aImplId) |
|
30 { |
|
31 CSuplEcomEventWatcher* self = new(ELeave) CSuplEcomEventWatcher(aSuplEcomEventObserver, aInterfaceUid, aImplId); |
|
32 CleanupStack::PushL(self); |
|
33 self->ConstructL(); |
|
34 CleanupStack::Pop(); |
|
35 return self; |
|
36 } |
|
37 |
|
38 //------------------------------------------- |
|
39 // Constructor. |
|
40 //------------------------------------------- |
|
41 // |
|
42 CSuplEcomEventWatcher::CSuplEcomEventWatcher(MSuplEcomEventObserver& aSuplEcomEventObserver, TUid aInterfaceUid, TUid aImplId) |
|
43 : CActive(EPriorityStandard), |
|
44 iSuplEcomEventObserver(aSuplEcomEventObserver), |
|
45 iEComSession(NULL), |
|
46 iPlugInInterfaceUid(aInterfaceUid), |
|
47 iPlugInImplUid(aImplId), |
|
48 iSuplEcomPlugInStatus(ENotExist) |
|
49 { |
|
50 CActiveScheduler::Add(this); |
|
51 } |
|
52 |
|
53 //------------------------------------------- |
|
54 // ConstructL. |
|
55 //------------------------------------------- |
|
56 // |
|
57 void CSuplEcomEventWatcher::ConstructL() |
|
58 { |
|
59 |
|
60 REComSession& ecomSession = REComSession::OpenL(); |
|
61 |
|
62 iEComSession = &ecomSession; |
|
63 |
|
64 TBool isImplPresent = IsImplementationExistL(); |
|
65 if(isImplPresent == EFalse) |
|
66 { |
|
67 User::Leave(KErrNotFound); |
|
68 } |
|
69 |
|
70 iSuplEcomPlugInStatus = EExist ; |
|
71 //NotifyOnPlugInUnInstallation(); |
|
72 } |
|
73 |
|
74 //------------------------------------------- |
|
75 // Destructor. |
|
76 //------------------------------------------- |
|
77 // |
|
78 CSuplEcomEventWatcher::~CSuplEcomEventWatcher() |
|
79 { |
|
80 Cancel(); |
|
81 if(iEComSession) |
|
82 iEComSession->Close(); |
|
83 } |
|
84 |
|
85 // NotifyOnPlugInUnInstallation |
|
86 void CSuplEcomEventWatcher::NotifyOnPlugInUnInstallation() |
|
87 { |
|
88 // request ecom framework for notification |
|
89 iEComSession->NotifyOnChange(iStatus); |
|
90 SetActive(); |
|
91 } |
|
92 |
|
93 //--------------------------------------------------------------- |
|
94 // Implementation of RunL. |
|
95 // RunL() calls observer method if there is any uninstallation in |
|
96 // already instantiated handler plug-in. |
|
97 //--------------------------------------------------------------- |
|
98 // |
|
99 void CSuplEcomEventWatcher::RunL() |
|
100 { |
|
101 // request ecom framework for notification |
|
102 NotifyOnPlugInUnInstallation(); |
|
103 |
|
104 // check plug-in unload |
|
105 TBool isImplPresent = IsImplementationExistL(); |
|
106 |
|
107 if(isImplPresent == EFalse) |
|
108 { |
|
109 if(iSuplEcomPlugInStatus == EExist) |
|
110 { |
|
111 iSuplEcomPlugInStatus = ENotExist ; |
|
112 // here to inform observer |
|
113 iSuplEcomEventObserver.PlugInUninstalled(); |
|
114 } |
|
115 } |
|
116 |
|
117 } |
|
118 |
|
119 //------------------------------------------- |
|
120 // RunError. |
|
121 //------------------------------------------- |
|
122 // |
|
123 TInt CSuplEcomEventWatcher::RunError(TInt /*aError*/) |
|
124 { |
|
125 |
|
126 return KErrNone; |
|
127 } |
|
128 |
|
129 //------------------------------------------- |
|
130 // DoCancel. |
|
131 //------------------------------------------- |
|
132 // |
|
133 void CSuplEcomEventWatcher::DoCancel() |
|
134 { |
|
135 if(iEComSession) |
|
136 { |
|
137 // cancel request for ecom notification |
|
138 iEComSession->CancelNotifyOnChange(iStatus); |
|
139 } |
|
140 } |
|
141 |
|
142 |
|
143 //------------------------------------------------------------------------------------- |
|
144 // IsImplementationExist. |
|
145 // This method checks the existance of specific plug-in and returns result accordingly. |
|
146 // (other items were commented in a header). |
|
147 //------------------------------------------------------------------------------------- |
|
148 // |
|
149 TBool CSuplEcomEventWatcher::IsImplementationExistL() |
|
150 { |
|
151 TBool retVal = EFalse; |
|
152 RImplInfoPtrArray implInfoArray; |
|
153 |
|
154 REComSession::ListImplementationsL(iPlugInInterfaceUid, implInfoArray); |
|
155 TInt implementationCount = implInfoArray.Count(); |
|
156 |
|
157 for(TInt loop=0; loop < implementationCount; loop++) |
|
158 { |
|
159 if(implInfoArray[loop]->ImplementationUid() == iPlugInImplUid) |
|
160 { |
|
161 retVal = ETrue; |
|
162 break; |
|
163 } |
|
164 } |
|
165 |
|
166 implInfoArray.ResetAndDestroy(); |
|
167 |
|
168 return retVal; |
|
169 } |
|
170 //End of File |
|
171 |
|
172 |
|
173 |