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: ECom plugin install/uninstall/version listener |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "DunAtEcomListen.h" |
|
20 #include "DunDebug.h" |
|
21 |
|
22 // --------------------------------------------------------------------------- |
|
23 // Two-phased constructor. |
|
24 // --------------------------------------------------------------------------- |
|
25 // |
|
26 CDunAtEcomListen* CDunAtEcomListen::NewL( |
|
27 RATExt* aAtCmdExt, |
|
28 MDunAtEcomListen* aCallback ) |
|
29 { |
|
30 CDunAtEcomListen* self = NewLC( aAtCmdExt, aCallback ); |
|
31 CleanupStack::Pop( self ); |
|
32 return self; |
|
33 } |
|
34 |
|
35 // --------------------------------------------------------------------------- |
|
36 // Two-phased constructor. |
|
37 // --------------------------------------------------------------------------- |
|
38 // |
|
39 CDunAtEcomListen* CDunAtEcomListen::NewLC( |
|
40 RATExt* aAtCmdExt, |
|
41 MDunAtEcomListen* aCallback ) |
|
42 { |
|
43 CDunAtEcomListen* self = new (ELeave) CDunAtEcomListen( aAtCmdExt, |
|
44 aCallback ); |
|
45 CleanupStack::PushL( self ); |
|
46 self->ConstructL(); |
|
47 return self; |
|
48 } |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // Destructor. |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 CDunAtEcomListen::~CDunAtEcomListen() |
|
55 { |
|
56 FTRACE(FPrint( _L("CDunAtEcomListen::~CDunAtEcomListen()") )); |
|
57 ResetData(); |
|
58 FTRACE(FPrint( _L("CDunAtEcomListen::~CDunAtEcomListen() complete") )); |
|
59 } |
|
60 |
|
61 // --------------------------------------------------------------------------- |
|
62 // Resets data to initial values |
|
63 // --------------------------------------------------------------------------- |
|
64 // |
|
65 void CDunAtEcomListen::ResetData() |
|
66 { |
|
67 FTRACE(FPrint( _L("CDunAtEcomListen::ResetData()") )); |
|
68 // APIs affecting this: |
|
69 // IssueRequest() |
|
70 Stop(); |
|
71 // Internal |
|
72 Initialize(); |
|
73 FTRACE(FPrint( _L("CDunAtEcomListen::ResetData() complete") )); |
|
74 } |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // Starts waiting for ECom plugin install/uninstall/version status changes |
|
78 // --------------------------------------------------------------------------- |
|
79 // |
|
80 TInt CDunAtEcomListen::IssueRequest() |
|
81 { |
|
82 FTRACE(FPrint( _L("CDunAtEcomListen::IssueRequest()") )); |
|
83 if ( iEcomListenState != EDunStateIdle ) |
|
84 { |
|
85 FTRACE(FPrint( _L("CDunAtEcomListen::IssueRequest() (not ready) complete") )); |
|
86 return KErrNotReady; |
|
87 } |
|
88 iStatus = KRequestPending; |
|
89 iAtCmdExt->ReceiveEcomPluginChange( iStatus, iPluginUidPckg, iEcomTypePckg ); |
|
90 SetActive(); |
|
91 iEcomListenState = EDunStateEcomListening; |
|
92 FTRACE(FPrint( _L("CDunAtEcomListen::IssueRequest() complete") )); |
|
93 return KErrNone; |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------------------------- |
|
97 // Stops waiting for Ecom plugin install/uninstall/version status changes |
|
98 // --------------------------------------------------------------------------- |
|
99 // |
|
100 TInt CDunAtEcomListen::Stop() |
|
101 { |
|
102 FTRACE(FPrint( _L("CDunAtEcomListen::Stop()") )); |
|
103 if ( iEcomListenState != EDunStateEcomListening ) |
|
104 { |
|
105 FTRACE(FPrint( _L("CDunAtEcomListen::Stop() (not ready) complete" ))); |
|
106 return KErrNotReady; |
|
107 } |
|
108 iAtCmdExt->CancelReceiveEcomPluginChange(); |
|
109 Cancel(); |
|
110 iEcomListenState = EDunStateIdle; |
|
111 FTRACE(FPrint( _L("CDunAtEcomListen::Stop() complete") )); |
|
112 return KErrNone; |
|
113 } |
|
114 |
|
115 // --------------------------------------------------------------------------- |
|
116 // CDunAtEcomListen::CDunAtEcomListen |
|
117 // --------------------------------------------------------------------------- |
|
118 // |
|
119 CDunAtEcomListen::CDunAtEcomListen( RATExt* aAtCmdExt, |
|
120 MDunAtEcomListen* aCallback ) : |
|
121 CActive( EPriorityHigh ), |
|
122 iAtCmdExt( aAtCmdExt ), |
|
123 iCallback( aCallback ), |
|
124 iPluginUidPckg( iPluginUid ), |
|
125 iEcomTypePckg( EEcomTypeUninstall ) |
|
126 { |
|
127 Initialize(); |
|
128 } |
|
129 |
|
130 // --------------------------------------------------------------------------- |
|
131 // CDunAtEcomListen::ConstructL |
|
132 // --------------------------------------------------------------------------- |
|
133 // |
|
134 void CDunAtEcomListen::ConstructL() |
|
135 { |
|
136 FTRACE(FPrint( _L("CDunAtEcomListen::ConstructL()") )); |
|
137 if ( !iAtCmdExt || !iCallback ) |
|
138 { |
|
139 User::Leave( KErrGeneral ); |
|
140 } |
|
141 CActiveScheduler::Add( this ); |
|
142 FTRACE(FPrint( _L("CDunAtEcomListen::ConstructL() complete") )); |
|
143 } |
|
144 |
|
145 // --------------------------------------------------------------------------- |
|
146 // Initializes this class |
|
147 // --------------------------------------------------------------------------- |
|
148 // |
|
149 void CDunAtEcomListen::Initialize() |
|
150 { |
|
151 // Don't initialize iAtCmdExt here (it is set through NewL) |
|
152 // Don't initialize iCallback here (it is set through NewL) |
|
153 iEcomListenState = EDunStateIdle; |
|
154 iPluginUid = TUid::Null(); |
|
155 } |
|
156 |
|
157 // --------------------------------------------------------------------------- |
|
158 // From class CActive. |
|
159 // Gets called when plugin installed, uninstalled or changed |
|
160 // --------------------------------------------------------------------------- |
|
161 // |
|
162 void CDunAtEcomListen::RunL() |
|
163 { |
|
164 FTRACE(FPrint( _L("CDunAtEcomListen::RunL()") )); |
|
165 iEcomListenState = EDunStateIdle; |
|
166 TInt retTemp = iStatus.Int(); |
|
167 if ( retTemp != KErrNone ) |
|
168 { |
|
169 FTRACE(FPrint( _L("CDunAtEcomListen::RunL() (ERROR) complete (%d)"), retTemp )); |
|
170 return; |
|
171 } |
|
172 IssueRequest(); |
|
173 // Now the operation is either unintall or install of plugin |
|
174 // Notify parent and ATEXT |
|
175 if ( iEcomTypePckg() == EEcomTypeUninstall ) |
|
176 { |
|
177 iCallback->NotifyPluginUninstallation( iPluginUid ); |
|
178 } |
|
179 else if ( iEcomTypePckg() == EEcomTypeInstall ) |
|
180 { |
|
181 iCallback->NotifyPluginInstallation( iPluginUid ); |
|
182 } |
|
183 else |
|
184 { |
|
185 FTRACE(FPrint( _L("CDunAtEcomListen::RunL() (not supported) complete") )); |
|
186 } |
|
187 FTRACE(FPrint( _L("CDunAtEcomListen::RunL() complete") )); |
|
188 } |
|
189 |
|
190 // --------------------------------------------------------------------------- |
|
191 // From class CActive. |
|
192 // Gets called on cancel |
|
193 // --------------------------------------------------------------------------- |
|
194 // |
|
195 void CDunAtEcomListen::DoCancel() |
|
196 { |
|
197 FTRACE(FPrint( _L("CDunAtEcomListen::DoCancel()") )); |
|
198 FTRACE(FPrint( _L("CDunAtEcomListen::DoCancel() complete") )); |
|
199 } |
|