1 /* |
|
2 * Copyright (c) 2008 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <gsplugininterface.h> |
|
20 #include "GSEComNotifier.h" |
|
21 #include "GsLogger.h" |
|
22 |
|
23 // ======== MEMBER FUNCTIONS ======== |
|
24 |
|
25 |
|
26 // --------------------------------------------------------------------------- |
|
27 // |
|
28 // --------------------------------------------------------------------------- |
|
29 // |
|
30 CGSEComNotifier::CGSEComNotifier( MGSEComObserver* aObserver, |
|
31 RImplInfoPtrArray aImplInfo ) |
|
32 : CActive( EPriorityStandard ), |
|
33 iObserver( aObserver ), |
|
34 iOriginalImplInfo( aImplInfo ) |
|
35 { |
|
36 CActiveScheduler::Add( this ); |
|
37 } |
|
38 |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 // --------------------------------------------------------------------------- |
|
43 // |
|
44 void CGSEComNotifier::ConstructL() |
|
45 { |
|
46 iEComSession = REComSession::OpenL(); |
|
47 IssueRequest(); |
|
48 } |
|
49 |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 EXPORT_C CGSEComNotifier* CGSEComNotifier::NewL( MGSEComObserver* aObserver, |
|
56 RImplInfoPtrArray aImplInfo ) |
|
57 { |
|
58 CGSEComNotifier* self = new( ELeave ) CGSEComNotifier( |
|
59 aObserver, |
|
60 aImplInfo ); |
|
61 |
|
62 CleanupStack::PushL( self ); |
|
63 self->ConstructL(); |
|
64 CleanupStack::Pop( self ); |
|
65 return self; |
|
66 } |
|
67 |
|
68 |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 EXPORT_C CGSEComNotifier::~CGSEComNotifier() |
|
74 { |
|
75 Cancel(); |
|
76 iEComSession.Close(); |
|
77 } |
|
78 |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 // See base class. |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 void CGSEComNotifier::DoCancel() |
|
85 { |
|
86 iEComSession.CancelNotifyOnChange( iStatus ); |
|
87 } |
|
88 |
|
89 |
|
90 // --------------------------------------------------------------------------- |
|
91 // See base class. |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 void CGSEComNotifier::RunL() |
|
95 { |
|
96 __GSLOGSTRING1( "[CGSEComNotifier::RunL] iStatus:%d", iStatus ); |
|
97 |
|
98 if( PluginCountDeltaL() < 0 ) |
|
99 { |
|
100 iObserver->HandleEComEvent( MGSEComObserver::EPluginRemoved ); |
|
101 } |
|
102 |
|
103 IssueRequest(); |
|
104 |
|
105 __GSLOGSTRING1( "[CGSEComNotifier::RunL] iStatus:%d", iStatus ); |
|
106 } |
|
107 |
|
108 |
|
109 // --------------------------------------------------------------------------- |
|
110 // See base class. |
|
111 // --------------------------------------------------------------------------- |
|
112 // |
|
113 TInt CGSEComNotifier::RunError( TInt aError ) |
|
114 { |
|
115 __GSLOGSTRING2( |
|
116 "[CGSEComNotifier::RunError] aError:%d iStatus:%d", |
|
117 aError, iStatus ); |
|
118 |
|
119 // Special case: Application can throw KLeaveExit basically anytime so we |
|
120 // have to forward it upwards to app framework. |
|
121 if( aError == KLeaveExit ) |
|
122 { |
|
123 return aError; |
|
124 } |
|
125 return KErrNone; |
|
126 } |
|
127 |
|
128 |
|
129 // --------------------------------------------------------------------------- |
|
130 // |
|
131 // --------------------------------------------------------------------------- |
|
132 // |
|
133 void CGSEComNotifier::IssueRequest() |
|
134 { |
|
135 if( !IsActive() ) |
|
136 { |
|
137 // NotifyOnChange is single shot. |
|
138 iEComSession.NotifyOnChange( iStatus ); |
|
139 SetActive(); |
|
140 } |
|
141 } |
|
142 |
|
143 |
|
144 // --------------------------------------------------------------------------- |
|
145 // |
|
146 // --------------------------------------------------------------------------- |
|
147 // |
|
148 TInt CGSEComNotifier::PluginCountDeltaL() |
|
149 { |
|
150 // Owned |
|
151 RImplInfoPtrArray newImplInfo; |
|
152 |
|
153 REComSession::ListImplementationsL( |
|
154 KGSPluginInterfaceUid, |
|
155 newImplInfo ); |
|
156 |
|
157 TInt oldInfoCount = iOriginalImplInfo.Count(); |
|
158 TInt newInfoCount = newImplInfo.Count(); |
|
159 |
|
160 __GSLOGSTRING2( |
|
161 "[CGSEComNotifier::PluginCountDeltaL] iOriginalImplInfo:%d newImplInfo:%d", |
|
162 oldInfoCount, newInfoCount ); |
|
163 |
|
164 newImplInfo.ResetAndDestroy(); |
|
165 newImplInfo.Close(); |
|
166 |
|
167 // Count the delta between old and current infos: |
|
168 return newInfoCount - oldInfoCount; |
|
169 } |
|
170 |
|
171 |
|
172 // End of File |
|