|
1 /* |
|
2 * Copyright (c) 2006 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 * Memory Scan Event Receiver |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 // SYSTEM INCLUDES |
|
23 #include <msenguihandler.h> |
|
24 |
|
25 |
|
26 // USER INCLUDES |
|
27 #include "cmemscaneventreceiver.h" |
|
28 |
|
29 |
|
30 // ========================= MEMBER FUNCTIONS ================================ |
|
31 |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // CMemScanEventReceiver::CMemScanEventReceiver() |
|
35 // |
|
36 // C++ default constructor. |
|
37 // --------------------------------------------------------------------------- |
|
38 CMemScanEventReceiver::CMemScanEventReceiver( MMsengUIHandler& aUIHandler ) |
|
39 : CActive(EPriorityStandard), iUIHandler(aUIHandler) |
|
40 { |
|
41 CActiveScheduler::Add(this); |
|
42 } |
|
43 |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // CMemScanEventReceiver::NewL() |
|
47 // |
|
48 // |
|
49 // --------------------------------------------------------------------------- |
|
50 CMemScanEventReceiver* CMemScanEventReceiver::NewL( MMsengUIHandler& aUIHandler ) |
|
51 { |
|
52 CMemScanEventReceiver* self = new( ELeave ) CMemScanEventReceiver( aUIHandler ); |
|
53 CleanupStack::PushL( self ); |
|
54 self->ConstructL( ); |
|
55 CleanupStack::Pop( self ); |
|
56 return self; |
|
57 } |
|
58 |
|
59 |
|
60 // --------------------------------------------------------------------------- |
|
61 // CMemScanEventReceiver::ConstructL() |
|
62 // |
|
63 // Destructor |
|
64 // --------------------------------------------------------------------------- |
|
65 void CMemScanEventReceiver::ConstructL() |
|
66 { |
|
67 User::LeaveIfError( iScanClient.Connect() ); |
|
68 } |
|
69 |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // CMemScanEventReceiver::~CMemScanEventReceiver() |
|
73 // |
|
74 // |
|
75 // --------------------------------------------------------------------------- |
|
76 CMemScanEventReceiver::~CMemScanEventReceiver() |
|
77 { |
|
78 Cancel(); |
|
79 iScanClient.Close(); |
|
80 } |
|
81 |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // CMemScanEventReceiver::RunL() |
|
85 // |
|
86 // |
|
87 // --------------------------------------------------------------------------- |
|
88 void CMemScanEventReceiver::RunL() |
|
89 { |
|
90 User::LeaveIfError( iStatus.Int() ); |
|
91 |
|
92 switch( iStatus.Int() ) |
|
93 { |
|
94 case EMemScanEventScanningStarted: |
|
95 { |
|
96 iUIHandler.StartL(); |
|
97 break; |
|
98 } |
|
99 |
|
100 case EMemScanEventScanningFinished: |
|
101 { |
|
102 iUIHandler.QuitL(iEventError); |
|
103 break; |
|
104 } |
|
105 |
|
106 case EMemScanEventScanningError: |
|
107 { |
|
108 iUIHandler.ErrorL(iEventError); |
|
109 break; |
|
110 } |
|
111 |
|
112 default: |
|
113 { |
|
114 break; |
|
115 } |
|
116 } |
|
117 |
|
118 RegisterForScanEvents(); |
|
119 } |
|
120 |
|
121 |
|
122 // --------------------------------------------------------------------------- |
|
123 // CMemScanEventReceiver::DoCancel() |
|
124 // |
|
125 // |
|
126 // --------------------------------------------------------------------------- |
|
127 void CMemScanEventReceiver::DoCancel() |
|
128 { |
|
129 iScanClient.RequestScanEventsCancel(); |
|
130 } |
|
131 |
|
132 |
|
133 // --------------------------------------------------------------------------- |
|
134 // CMemScanEventReceiver::RunError() |
|
135 // |
|
136 // |
|
137 // --------------------------------------------------------------------------- |
|
138 TInt CMemScanEventReceiver::RunError( TInt /*aError*/ ) |
|
139 { |
|
140 RegisterForScanEvents(); |
|
141 return KErrNone; |
|
142 } |
|
143 |
|
144 |
|
145 // --------------------------------------------------------------------------- |
|
146 // CMemScanEventReceiver::DataGroupsL() |
|
147 // |
|
148 // |
|
149 // --------------------------------------------------------------------------- |
|
150 CDesCArray* CMemScanEventReceiver::DataGroupsL() const |
|
151 { |
|
152 CDesCArray* dataGroupArray = iScanClient.DataGroupsL(); |
|
153 return dataGroupArray; |
|
154 } |
|
155 |
|
156 |
|
157 // --------------------------------------------------------------------------- |
|
158 // CMemScanEventReceiver::ScanResultL() |
|
159 // |
|
160 // |
|
161 // --------------------------------------------------------------------------- |
|
162 CArrayFix<TInt64>* CMemScanEventReceiver::ScanResultL() const |
|
163 { |
|
164 CArrayFix<TInt64>* scanResultArray = iScanClient.ScanResultL(); |
|
165 return scanResultArray; |
|
166 } |
|
167 |
|
168 |
|
169 // --------------------------------------------------------------------------- |
|
170 // CMemScanEventReceiver::ScanInProgress() |
|
171 // |
|
172 // |
|
173 // --------------------------------------------------------------------------- |
|
174 TBool CMemScanEventReceiver::ScanInProgress() const |
|
175 { |
|
176 return iScanClient.ScanInProgress(); |
|
177 } |
|
178 |
|
179 |
|
180 // --------------------------------------------------------------------------- |
|
181 // CMemScanEventReceiver::ScanL() |
|
182 // |
|
183 // |
|
184 // --------------------------------------------------------------------------- |
|
185 TInt CMemScanEventReceiver::ScanL(TDriveNumber aDrive) |
|
186 { |
|
187 RegisterForScanEvents(); |
|
188 |
|
189 return iScanClient.Scan(aDrive); |
|
190 } |
|
191 |
|
192 |
|
193 // --------------------------------------------------------------------------- |
|
194 // CMemScanEventReceiver::RegisterForScanEvents() |
|
195 // |
|
196 // |
|
197 // --------------------------------------------------------------------------- |
|
198 void CMemScanEventReceiver::RegisterForScanEvents() |
|
199 { |
|
200 Cancel(); |
|
201 |
|
202 // We request events from the server. When the server has an event |
|
203 // for us, it will complete our request status (iStatus) with an |
|
204 // event type (i.e. one of the TMemScanEvent enumerations) and |
|
205 // also ensures that iEventError is updated with any associated error |
|
206 // value. This will then cause the RunL method to be called. |
|
207 iScanClient.RequestScanEvents( iEventError, iStatus ); |
|
208 SetActive(); |
|
209 } |