|
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: File System format monitor |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <f32file.h> |
|
21 #ifdef RD_MULTIPLE_DRIVE |
|
22 #include <driveinfo.h> |
|
23 #endif //RD_MULTIPLE_DRIVE |
|
24 #include <mpxlog.h> |
|
25 #include "mpxfsformatmonitor.h" |
|
26 |
|
27 #ifdef RD_MULTIPLE_DRIVE |
|
28 static const TInt KDriveCount = 2; |
|
29 #else |
|
30 static const TInt KDriveCount = 1; |
|
31 #endif |
|
32 |
|
33 // ======== MEMBER FUNCTIONS ======== |
|
34 |
|
35 // --------------------------------------------------------------------------- |
|
36 // Default Constructor |
|
37 // --------------------------------------------------------------------------- |
|
38 // |
|
39 CMPXFsFormatMonitor::CMPXFsFormatMonitor( MMPXSystemEventObserver& aObserver ) : |
|
40 iObserver( aObserver ) |
|
41 { |
|
42 |
|
43 } |
|
44 |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // Second Phase Constructor |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 void CMPXFsFormatMonitor::ConstructL() |
|
51 { |
|
52 MPX_DEBUG1(_L("CMPXFsFormatMonitor::ConstructL <---")); |
|
53 |
|
54 iBackupSession = CBaBackupSessionWrapper::NewL(); |
|
55 iBackupSession->RegisterBackupOperationObserverL( *this ); |
|
56 |
|
57 TInt drive = EDriveE; |
|
58 for(TInt i=0; i<KDriveCount; ++i) |
|
59 { |
|
60 iBackupDrives.Append(drive); |
|
61 ++drive; |
|
62 } |
|
63 |
|
64 MPX_DEBUG1(_L("CMPXFsFormatMonitor::ConstructL --->")); |
|
65 } |
|
66 |
|
67 |
|
68 // --------------------------------------------------------------------------- |
|
69 // Two-Phased Constructor |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 CMPXFsFormatMonitor* CMPXFsFormatMonitor::NewL |
|
73 ( MMPXSystemEventObserver& aObserver ) |
|
74 { |
|
75 CMPXFsFormatMonitor* self = CMPXFsFormatMonitor::NewLC( aObserver ); |
|
76 CleanupStack::Pop( self ); |
|
77 return self; |
|
78 } |
|
79 |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // Two-Phased Constructor |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 CMPXFsFormatMonitor* CMPXFsFormatMonitor::NewLC |
|
86 ( MMPXSystemEventObserver& aObserver ) |
|
87 { |
|
88 CMPXFsFormatMonitor* self = new( ELeave ) CMPXFsFormatMonitor( aObserver); |
|
89 CleanupStack::PushL( self ); |
|
90 self->ConstructL(); |
|
91 return self; |
|
92 } |
|
93 |
|
94 |
|
95 // --------------------------------------------------------------------------- |
|
96 // destructor |
|
97 // --------------------------------------------------------------------------- |
|
98 // |
|
99 CMPXFsFormatMonitor::~CMPXFsFormatMonitor() |
|
100 { |
|
101 iBackupDrives.Close(); |
|
102 |
|
103 if( iBackupSession ) |
|
104 { |
|
105 iBackupSession->DeRegisterBackupOperationObserver( *this ); |
|
106 } |
|
107 delete iBackupSession; |
|
108 } |
|
109 |
|
110 // --------------------------------------------------------------------------- |
|
111 // Checks the current status |
|
112 // --------------------------------------------------------------------------- |
|
113 // |
|
114 void CMPXFsFormatMonitor::PollStatus() |
|
115 { |
|
116 TBool aFormatting = iBackupSession->IsBackupOperationRunning(); |
|
117 if( aFormatting ) |
|
118 { |
|
119 for(TInt i=0; i<KDriveCount; ++i) |
|
120 { |
|
121 TRAP_IGNORE(iObserver.HandleSystemEventL(EFormatStartEvent, iBackupDrives[i])); |
|
122 } |
|
123 } |
|
124 } |
|
125 |
|
126 // --------------------------------------------------------------------------- |
|
127 // CMPXFsFormatMonitor::HandleBackupOperationEventL |
|
128 // Handles a format operation |
|
129 // --------------------------------------------------------------------------- |
|
130 // |
|
131 void CMPXFsFormatMonitor::HandleBackupOperationEventL( |
|
132 const TBackupOperationAttributes& aBackupOperationAttributes) |
|
133 { |
|
134 MPX_DEBUG1(_L("CMPXFsFormatMonitor::HandleBackupOperationEventL <---")); |
|
135 |
|
136 if( aBackupOperationAttributes.iOperation == EStart ) |
|
137 { |
|
138 for(TInt i=0; i<KDriveCount; ++i) |
|
139 { |
|
140 iObserver.HandleSystemEventL(EFormatStartEvent, iBackupDrives[i]); |
|
141 } |
|
142 } |
|
143 else // TOperationType::EEnd or TOperationType::EAbort |
|
144 { |
|
145 for(TInt i=0; i<KDriveCount; ++i) |
|
146 { |
|
147 iObserver.HandleSystemEventL(EFormatEndEvent, iBackupDrives[i]); |
|
148 } |
|
149 } |
|
150 |
|
151 MPX_DEBUG1(_L("CMPXFsFormatMonitor::HandleBackupOperationEventL --->")); |
|
152 } |