|
1 /* |
|
2 * Copyright (c) 2004 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: This module contains the implementation of CCbsDiskSpaceMonitor class |
|
15 * member functions. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32property.h> |
|
22 #include "CCbsDiskSpaceMonitor.h" |
|
23 #include <UikonInternalPSKeys.h> // KPSUidUikon, KUikFFSFreeLevel |
|
24 #include "CCbsDbImp.H" |
|
25 #include "CbsLogger.h" |
|
26 |
|
27 // CONSTANTS |
|
28 |
|
29 // Value to receive from critical level notification for "OK" |
|
30 const TInt KCriticalLevelDiskOk = 0; |
|
31 |
|
32 |
|
33 // ================= MEMBER FUNCTIONS ======================= |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CCbsDiskSpaceMonitor::CCbsDiskSpaceMonitor |
|
37 // C++ default constructor can NOT contain any code, that |
|
38 // might leave. |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CCbsDiskSpaceMonitor::CCbsDiskSpaceMonitor( CCbsDbImp& aDbImp ) |
|
42 : CActive( EPriorityStandard ), |
|
43 iDbImp( aDbImp ) |
|
44 { |
|
45 } |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CCbsDiskSpaceMonitor::ConstructL |
|
49 // Symbian 2nd phase constructor can leave. |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 void CCbsDiskSpaceMonitor::ConstructL() |
|
53 { |
|
54 CBSLOGSTRING("CBSSERVER: >>> CCbsDiskSpaceMonitor::ConstructL()"); |
|
55 |
|
56 CActiveScheduler::Add( this ); |
|
57 |
|
58 // Attach to disk space property |
|
59 iProperty.Attach( KPSUidUikon, KUikFFSFreeLevel ); |
|
60 |
|
61 CBSLOGSTRING("CBSSERVER: <<< CCbsDiskSpaceMonitor::ConstructL()"); |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CCbsDiskSpaceMonitor::NewL |
|
66 // Two-phased constructor. |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 CCbsDiskSpaceMonitor* CCbsDiskSpaceMonitor::NewL( CCbsDbImp& aDbImp ) |
|
70 { |
|
71 CBSLOGSTRING("CBSSERVER: >>> CCbsDiskSpaceMonitor::NewL()"); |
|
72 |
|
73 CCbsDiskSpaceMonitor* self = |
|
74 new ( ELeave ) CCbsDiskSpaceMonitor( aDbImp ); |
|
75 CleanupStack::PushL( self ); |
|
76 self->ConstructL(); |
|
77 CleanupStack::Pop(); |
|
78 |
|
79 CBSLOGSTRING("CBSSERVER: <<< CCbsDiskSpaceMonitor::NewL(), returning self."); |
|
80 return self; |
|
81 } |
|
82 |
|
83 // Destructor |
|
84 CCbsDiskSpaceMonitor::~CCbsDiskSpaceMonitor() |
|
85 { |
|
86 CBSLOGSTRING("CBSSERVER: >>> CCbsDiskSpaceMonitor::~CCbsDiskSpaceMonitor()"); |
|
87 Cancel(); |
|
88 iProperty.Close(); |
|
89 CBSLOGSTRING("CBSSERVER: <<< CCbsDiskSpaceMonitor::~CCbsDiskSpaceMonitor()"); |
|
90 } |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // CCbsDiskSpaceMonitor::IssueRequest |
|
94 // Requests that we are notified when the system state changes. |
|
95 // (other items were commented in a header). |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 void CCbsDiskSpaceMonitor::IssueRequest() |
|
99 { |
|
100 CBSLOGSTRING("CBSSERVER: >>> CCbsDiskSpaceMonitor::IssueRequest()"); |
|
101 |
|
102 if ( !IsActive() ) |
|
103 { |
|
104 // Subscribe again |
|
105 iProperty.Subscribe( iStatus ); |
|
106 SetActive(); |
|
107 CBSLOGSTRING("CBSSERVER: CCbsDiskSpaceMonitor::IssueRequest(): New Subscribe() set active."); |
|
108 } |
|
109 |
|
110 CBSLOGSTRING("CBSSERVER: <<< CCbsDiskSpaceMonitor::IssueRequest()"); |
|
111 } |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CCbsDiskSpaceMonitor::RunL |
|
115 // Becomes active when the system state changes. |
|
116 // (other items were commented in a header). |
|
117 // ----------------------------------------------------------------------------- |
|
118 // |
|
119 void CCbsDiskSpaceMonitor::RunL() |
|
120 { |
|
121 CBSLOGSTRING2("CBSSERVER: >>> CCbsDiskSpaceMonitor::RunL(): iStatus: %d", iStatus.Int() ); |
|
122 |
|
123 if ( iStatus == KErrNone ) |
|
124 { |
|
125 // Property updated, get new value |
|
126 TInt state( 0 ); |
|
127 TInt error( KErrNone ); |
|
128 error = iProperty.Get( state ); |
|
129 CBSLOGSTRING2("CBSSERVER: CCbsDiskSpaceMonitor::RunL(): property.Get() error: %d", error ); |
|
130 CBSLOGSTRING2("CBSSERVER: CCbsDiskSpaceMonitor::RunL(): property.Get() state: %d", state ); |
|
131 |
|
132 // If we received DISK_SPACE_OK, try to create the database |
|
133 // components. |
|
134 if ( state == KCriticalLevelDiskOk ) |
|
135 { |
|
136 CBSLOGSTRING("CBSSERVER: CCbsDiskSpaceMonitor::RunL(): Calling CreateComponentsL()..." ); |
|
137 iDbImp.CreateComponentsL(); |
|
138 CBSLOGSTRING("CBSSERVER: CCbsDiskSpaceMonitor::RunL(): CreateComponentsL() finished." ); |
|
139 } |
|
140 // To prevent ARMV5 compiler error |
|
141 if ( error ) |
|
142 { |
|
143 error = KErrNone; |
|
144 } |
|
145 } |
|
146 CBSLOGSTRING("CBSSERVER: <<< CCbsDiskSpaceMonitor::RunL()"); |
|
147 } |
|
148 |
|
149 // ----------------------------------------------------------------------------- |
|
150 // CCbsDiskSpaceMonitor::DoCancel |
|
151 // Cancels an outstanding Subscribe request. |
|
152 // (other items were commented in a header). |
|
153 // ----------------------------------------------------------------------------- |
|
154 // |
|
155 void CCbsDiskSpaceMonitor::DoCancel() |
|
156 { |
|
157 CBSLOGSTRING("CBSSERVER: >>> CCbsDiskSpaceMonitor::DoCancel()"); |
|
158 iProperty.Cancel(); |
|
159 CBSLOGSTRING("CBSSERVER: <<< CCbsDiskSpaceMonitor::DoCancel()"); |
|
160 } |
|
161 |
|
162 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
163 |
|
164 // End of File |