1 /* |
1 // |
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
2 // ============================================================================ |
3 * All rights reserved. |
3 // Name : WidgetMMCHandler.cpp |
4 * This component and the accompanying materials are made available |
4 // Part of : SW Installer UIs / WidgetInstallerUI |
5 * under the terms of "Eclipse Public License v1.0" |
5 // |
6 * which accompanies this distribution, and is available |
6 // Description: Handle notifications of MMC events. |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 // |
8 * |
8 // |
9 * Initial Contributors: |
9 // Version : 3.1 |
10 * Nokia Corporation - initial contribution. |
10 // |
11 * |
11 // Copyright © 2006 Nokia Corporation. |
12 * Contributors: |
12 // This material, including documentation and any related |
13 * |
13 // computer programs, is protected by copyright controlled by |
14 * Description: Handle notifications of MMC events. |
14 // Nokia Corporation. All rights are reserved. Copying, |
15 * |
15 // including reproducing, storing, adapting or translating, any |
16 * |
16 // or all of this material requires the prior written consent of |
17 * |
17 // Nokia Corporation. This material also contains confidential |
18 */ |
18 // information which may not be disclosed to others without the |
19 |
19 // prior written consent of Nokia Corporation. |
|
20 // ============================================================================== |
|
21 /// |
|
22 |
|
23 // INCLUDE FILES |
20 #include "wrtusbhandler.h" |
24 #include "wrtusbhandler.h" |
21 #include "wrtharvester.h" |
25 #include "wrtharvester.h" |
22 #include "wrtusbhandler.h" |
26 #include "wrtusbhandler.h" |
23 #include <DriveInfo.h> |
27 #include <DriveInfo.h> |
24 |
28 |
25 // CONSTANTS |
29 // CONSTANTS |
26 |
30 |
27 |
31 |
|
32 static TInt TimerCallBack( TAny* ptr ) |
|
33 { |
|
34 CWrtUsbHandler* temp = static_cast<CWrtUsbHandler*>(ptr); |
|
35 if(temp) |
|
36 { |
|
37 temp->DeleteTimer(); |
|
38 temp->DoScanAndUpdate(); |
|
39 } |
|
40 return 0; |
|
41 } |
28 // ============================================================================ |
42 // ============================================================================ |
29 // CWrtUsbHandler::NewL() |
43 // CWrtUsbHandler::NewL() |
30 // two-phase constructor |
44 // two-phase constructor |
31 // |
45 // |
32 // @since 3.1 |
46 // @since 3.1 |
108 // |
122 // |
109 // @since 3.1 |
123 // @since 3.1 |
110 // ============================================================================ |
124 // ============================================================================ |
111 void CWrtUsbHandler::RunL() |
125 void CWrtUsbHandler::RunL() |
112 { |
126 { |
113 TInt status = iStatus.Int(); |
127 if ( iStatus == KErrNone ) |
114 |
128 { |
115 // Restart NotifyChange |
129 //Call back Timer |
116 Start(); |
130 iCallBackTimer = CPeriodic::NewL(CActive::EPriorityLow); |
117 |
131 iCallBackTimer->Start(10000000,0,TCallBack(&TimerCallBack,this)); |
118 if ( status == KErrNone ) |
132 } |
119 { |
|
120 DoScanAndUpdate(); |
|
121 } |
|
122 } |
133 } |
123 |
134 |
124 void CWrtUsbHandler::DoScanAndUpdate() |
135 void CWrtUsbHandler::DoScanAndUpdate() |
125 { |
136 { |
126 TInt err = 0; |
137 TInt err = 0; |
131 deltaDriveFlags = iDriveFlags ^ driveFlags; |
142 deltaDriveFlags = iDriveFlags ^ driveFlags; |
132 iDriveFlags = driveFlags; |
143 iDriveFlags = driveFlags; |
133 } |
144 } |
134 |
145 |
135 if ( deltaDriveFlags ) |
146 if ( deltaDriveFlags ) |
136 { |
147 { |
|
148 //Unpluging USB from Mass storage . . . |
|
149 if(iHarvester->IsInMSMode() == 1) |
|
150 { |
|
151 iHarvester->SetMSMode(0); |
|
152 iHarvester->ClearAllOperations(); |
|
153 TRAP(err, iHarvester->UpdateL() ); |
|
154 iFs.NotifyChange( ENotifyDisk, iStatus ); |
|
155 SetActive(); |
|
156 return; |
|
157 } |
|
158 |
137 TVolumeInfo volInfo; |
159 TVolumeInfo volInfo; |
138 TInt temp = deltaDriveFlags; |
160 TInt temp = deltaDriveFlags; |
139 TBool massMemAltered = EFalse; |
161 TBool massMemAltered = EFalse; |
140 TBool massMemAvailable = EFalse; |
|
141 for(TInt DriveNo = EDriveA+1 ; DriveNo<=EDriveY; DriveNo++ ) |
162 for(TInt DriveNo = EDriveA+1 ; DriveNo<=EDriveY; DriveNo++ ) |
142 { |
163 { |
143 temp = temp >> 1; |
164 temp = temp >> 1; |
144 if( temp & 01) |
165 if( temp & 01) |
145 { |
166 { |
146 TUint status(0); |
167 TUint status(0); |
147 err = DriveInfo::GetDriveStatus( iFs, DriveNo , status ); |
168 err = DriveInfo::GetDriveStatus( iFs, DriveNo , status ); |
148 if(!err && (status & DriveInfo::EDriveExternallyMountable) && (status & DriveInfo::EDriveInternal )) |
169 if(!err && (status & DriveInfo::EDriveExternallyMountable) && (status & DriveInfo::EDriveInternal )) |
149 { |
170 { |
150 //Internal Memory |
171 //Internal Memory |
151 massMemAltered = ETrue; |
172 massMemAltered = ETrue; |
152 // Check is the internal memory available or not |
|
153 if(iDriveFlags & (1<<DriveNo)) |
|
154 massMemAvailable = ETrue; |
|
155 } |
173 } |
156 } |
174 } |
157 } |
175 } |
158 if( massMemAltered ) |
176 if( massMemAltered ) |
159 { |
177 { |
160 if(!massMemAvailable) |
178 iHarvester->SetMSMode(1); |
161 { |
179 } |
162 // Mass storage is plugged |
180 |
163 iHarvester->SetMSMode(1); |
181 TRAP( err, iHarvester->UpdateL() ); |
164 } |
182 } |
165 else |
183 iFs.NotifyChange( ENotifyDisk, iStatus ); |
166 { |
184 SetActive(); |
167 // Mass storage was unplugged |
|
168 if(iHarvester->IsInMSMode() == 1) |
|
169 { |
|
170 iHarvester->SetMSMode(0); |
|
171 iHarvester->ClearAllOperations(); |
|
172 } |
|
173 } |
|
174 } |
|
175 } |
|
176 } |
185 } |
177 |
186 |
178 |
187 |
179 // ============================================================================ |
188 // ============================================================================ |
180 // CWrtUsbHandler::RunError() |
189 // CWrtUsbHandler::RunError() |