1 /* |
1 /* |
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
16 */ |
16 */ |
17 |
17 |
18 |
18 |
19 // SYSTEM INCLUDES |
19 // SYSTEM INCLUDES |
20 #include <e32property.h> |
20 #include <e32property.h> |
21 #include <AknGlobalNote.h> |
|
22 #include <secondarydisplay/AknSecondaryDisplayDefs.h> |
|
23 #include <aknSDData.h> |
|
24 #include <avkon.rsg> |
|
25 #include <data_caging_path_literals.hrh> |
21 #include <data_caging_path_literals.hrh> |
26 #include <driveinfo.h> |
22 #include <driveinfo.h> |
27 #include <outofdiskmonitor.rsg> |
23 #include <outofdiskmonitor.rsg> |
28 #include <bautils.h> // BaflUtils |
24 #include <bautils.h> // BaflUtils |
29 #include <StringLoader.h> |
25 #include <StringLoader.h> |
30 #include <aknnotewrappers.h> |
26 |
31 |
27 |
32 // USER INCLUDES |
28 // USER INCLUDES |
33 #include "UiklafInternalCRKeys.h" |
29 #include "UiklafInternalCRKeys.h" |
34 #include "OodTraces.h" |
30 #include "OodTraces.h" |
35 #include "outofdiskglobalnote.h" |
31 #include "outofdiskglobalnote.h" |
58 // --------------------------------------------------------- |
54 // --------------------------------------------------------- |
59 // |
55 // |
60 COutOfDiskGlobalNote::~COutOfDiskGlobalNote() |
56 COutOfDiskGlobalNote::~COutOfDiskGlobalNote() |
61 { |
57 { |
62 TRACES("COutOfDiskGlobalNote::~COutOfDiskGlobalNote"); |
58 TRACES("COutOfDiskGlobalNote::~COutOfDiskGlobalNote"); |
63 delete iQuery; |
|
64 iOODResourceFile.Close(); |
59 iOODResourceFile.Close(); |
65 Cancel(); // Cancel active object |
60 delete iNote; |
66 TRACES("COutOfDiskGlobalNote::~COutOfDiskGlobalNote: End"); |
61 iNote=NULL; |
67 } |
62 } |
68 |
63 |
69 // --------------------------------------------------------- |
64 // --------------------------------------------------------- |
70 // |
65 // |
71 // --------------------------------------------------------- |
66 // --------------------------------------------------------- |
72 // |
67 // |
73 COutOfDiskGlobalNote::COutOfDiskGlobalNote( COutOfDiskMonitor* aOutOfDiskMonitor, RFs& aFs ) : |
68 COutOfDiskGlobalNote::COutOfDiskGlobalNote( COutOfDiskMonitor* aOutOfDiskMonitor, RFs& aFs ) : |
74 CActive( EPriorityStandard ), |
|
75 iOutOfDiskMonitor( aOutOfDiskMonitor ), |
69 iOutOfDiskMonitor( aOutOfDiskMonitor ), |
76 iFs( aFs ) |
70 iFs( aFs ) |
77 { |
71 { |
78 TRACES("COutOfDiskGlobalNote::COutOfDiskGlobalNote"); |
72 TRACES("COutOfDiskGlobalNote::COutOfDiskGlobalNote"); |
79 CActiveScheduler::Add( this ); |
|
80 TRACES("COutOfDiskGlobalNote::COutOfDiskGlobalNote: End"); |
73 TRACES("COutOfDiskGlobalNote::COutOfDiskGlobalNote: End"); |
81 } |
74 } |
82 |
75 |
83 // --------------------------------------------------------- |
76 // --------------------------------------------------------- |
84 // |
77 // |
88 { |
81 { |
89 TRACES("COutOfDiskGlobalNote::ConstructL"); |
82 TRACES("COutOfDiskGlobalNote::ConstructL"); |
90 iNoteInfo.iNoteId = KErrNotFound; |
83 iNoteInfo.iNoteId = KErrNotFound; |
91 iNoteInfo.iStatus = DISK_SPACE_OK; |
84 iNoteInfo.iStatus = DISK_SPACE_OK; |
92 iNoteInfo.iDrive = KErrNotFound; |
85 iNoteInfo.iDrive = KErrNotFound; |
93 |
86 iNote= CHbDeviceMessageBoxSymbian::NewL(CHbDeviceMessageBoxSymbian::EWarning); |
94 TRACES("COutOfDiskGlobalNote::ConstructL: Open OOD resource file"); |
87 TRACES("COutOfDiskGlobalNote::ConstructL: Open OOD resource file"); |
95 TFileName OODFileName; |
88 TFileName OODFileName; |
96 OODFileName.Append(_L("Z")); |
89 OODFileName.Append(_L("Z")); |
97 OODFileName.Append(_L(":")); |
90 OODFileName.Append(_L(":")); |
98 OODFileName.Append(KDC_RESOURCE_FILES_DIR); |
91 OODFileName.Append(KDC_RESOURCE_FILES_DIR); |
108 // --------------------------------------------------------- |
101 // --------------------------------------------------------- |
109 // |
102 // |
110 void COutOfDiskGlobalNote::DisplayL(const TDesC& aMessage) |
103 void COutOfDiskGlobalNote::DisplayL(const TDesC& aMessage) |
111 { |
104 { |
112 TRACES("COutOfDiskGlobalNote::DisplayL"); |
105 TRACES("COutOfDiskGlobalNote::DisplayL"); |
113 if (iNoteInfo.iNoteId > KErrNotFound) |
106 |
114 { |
107 TRACES("COutOfDiskGlobalNote::COutOfDiskGlobalNote::DisplayL: set text and observer for the note"); |
115 CancelNoteL(); |
108 iNote->SetTextL(aMessage); |
116 } |
109 iNote->SetObserver(this); |
117 |
110 iNote->SetTimeout(0); |
118 if (!iQuery) |
111 iNote->ShowL(); |
119 { |
112 |
120 TRACES("COutOfDiskGlobalNote::COutOfDiskGlobalNote::DisplayL: Create iQuery"); |
|
121 iQuery = CAknGlobalNote::NewL(); |
|
122 iQuery->SetSoftkeys(R_AVKON_SOFTKEYS_OK_EMPTY); |
|
123 } |
|
124 iNoteInfo.iNoteId = iQuery->ShowNoteL(iStatus, EAknGlobalWarningNote, aMessage); |
|
125 SetActive(); |
|
126 TRACES("COutOfDiskGlobalNote::DisplayL: End"); |
113 TRACES("COutOfDiskGlobalNote::DisplayL: End"); |
127 } |
114 } |
128 |
115 |
129 // --------------------------------------------------------- |
116 // --------------------------------------------------------- |
130 // Use a global query to display the message but make sure that eiksrv is |
117 // Use a global query to display the message but make sure that eiksrv is |
167 { |
153 { |
168 TRACES1("COutOfDiskGlobalNote::ShowGlobalQueryL: Warning note! Drive: %c", aDrive+'A'); |
154 TRACES1("COutOfDiskGlobalNote::ShowGlobalQueryL: Warning note! Drive: %c", aDrive+'A'); |
169 |
155 |
170 if (aDrive == iOutOfDiskMonitor->GetDefaultPhoneMemory()) |
156 if (aDrive == iOutOfDiskMonitor->GetDefaultPhoneMemory()) |
171 { |
157 { |
172 sdDialogId = EAknDiskWarnignNote; |
|
173 str = iOODResourceFile.AllocReadLC(R_QTN_MEMLO_DEVICE_MEMORY_LOW); |
158 str = iOODResourceFile.AllocReadLC(R_QTN_MEMLO_DEVICE_MEMORY_LOW); |
174 resReader.SetBuffer(str); |
159 resReader.SetBuffer(str); |
175 strings->AppendL( driveName ); |
160 strings->AppendL( driveName ); |
176 } |
161 } |
177 else if (driveStatus & DriveInfo::EDriveRemovable) |
162 else if (driveStatus & DriveInfo::EDriveRemovable) |
178 { |
163 { |
179 TRACES1("COutOfDiskGlobalNote::ShowGlobalQueryL: Warning note! volNameLength: %d", nameLength); |
164 TRACES1("COutOfDiskGlobalNote::ShowGlobalQueryL: Warning note! volNameLength: %d", nameLength); |
180 sdDialogId = EAknMMCWarningNote; |
|
181 TBufC<KMaxFileName> name(volInfo.iName); |
165 TBufC<KMaxFileName> name(volInfo.iName); |
182 if (nameLength) |
166 if (nameLength) |
183 { |
167 { |
184 str = iOODResourceFile.AllocReadLC(R_QTN_MEMLO_MEMORY_CARD_LOW_NAME); |
168 str = iOODResourceFile.AllocReadLC(R_QTN_MEMLO_MEMORY_CARD_LOW_NAME); |
185 resReader.SetBuffer(str); |
169 resReader.SetBuffer(str); |
194 strings->AppendL( driveName ); |
178 strings->AppendL( driveName ); |
195 } |
179 } |
196 } |
180 } |
197 else |
181 else |
198 { |
182 { |
199 sdDialogId = EAknDiskWarnignNote; |
|
200 str = iOODResourceFile.AllocReadLC(R_QTN_MEMLO_MASS_STORAGE_MEMORY_LOW); |
183 str = iOODResourceFile.AllocReadLC(R_QTN_MEMLO_MASS_STORAGE_MEMORY_LOW); |
201 resReader.SetBuffer(str); |
184 resReader.SetBuffer(str); |
202 strings->AppendL( driveName ); |
185 strings->AppendL( driveName ); |
203 } |
186 } |
204 } |
187 } |
205 else if (aStatus==DISK_SPACE_CRITICAL) |
188 else if (aStatus==DISK_SPACE_CRITICAL) |
206 { |
189 { |
207 TRACES1("COutOfDiskGlobalNote::ShowGlobalQueryL: Critical note! Drive: %c", aDrive+'A'); |
190 TRACES1("COutOfDiskGlobalNote::ShowGlobalQueryL: Critical note! Drive: %c", aDrive+'A'); |
208 if (aDrive == iOutOfDiskMonitor->GetDefaultPhoneMemory()) |
191 if (aDrive == iOutOfDiskMonitor->GetDefaultPhoneMemory()) |
209 { |
192 { |
210 sdDialogId = EAknDiskFullNote; |
|
211 str = iOODResourceFile.AllocReadLC(R_QTN_MEMLO_DEVICE_MEMORY_FULL); |
193 str = iOODResourceFile.AllocReadLC(R_QTN_MEMLO_DEVICE_MEMORY_FULL); |
212 resReader.SetBuffer(str); |
194 resReader.SetBuffer(str); |
213 strings->AppendL( driveName ); |
195 strings->AppendL( driveName ); |
214 } |
196 } |
215 else if (driveStatus & DriveInfo::EDriveRemovable) |
197 else if (driveStatus & DriveInfo::EDriveRemovable) |
216 { |
198 { |
217 sdDialogId = EAknMMCFullNote; |
|
218 TBufC<KMaxFileName> name(volInfo.iName); |
199 TBufC<KMaxFileName> name(volInfo.iName); |
219 if (nameLength) |
200 if (nameLength) |
220 { |
201 { |
221 str = iOODResourceFile.AllocReadLC(R_QTN_MEMLO_MEMORY_CARD_FULL_NAME); |
202 str = iOODResourceFile.AllocReadLC(R_QTN_MEMLO_MEMORY_CARD_FULL_NAME); |
222 resReader.SetBuffer(str); |
203 resReader.SetBuffer(str); |
231 strings->AppendL( driveName ); |
212 strings->AppendL( driveName ); |
232 } |
213 } |
233 } |
214 } |
234 else |
215 else |
235 { |
216 { |
236 sdDialogId = EAknDiskFullNote; |
|
237 str = iOODResourceFile.AllocReadLC(R_QTN_MEMLO_MASS_STORAGE_FULL); |
217 str = iOODResourceFile.AllocReadLC(R_QTN_MEMLO_MASS_STORAGE_FULL); |
238 resReader.SetBuffer(str); |
218 resReader.SetBuffer(str); |
239 strings->AppendL( driveName ); |
219 strings->AppendL( driveName ); |
240 } |
220 } |
241 } |
221 } |
242 resReader.SetBuffer(str); |
222 resReader.SetBuffer(str); |
243 HBufC* resHandle = resReader.ReadHBufCL(); |
223 HBufC* resHandle = resReader.ReadHBufCL(); |
244 CleanupStack::PushL( resHandle ); |
224 CleanupStack::PushL( resHandle ); |
245 HBufC* message(FormatStringL(resHandle->Des(),*strings)); |
225 HBufC* message(FormatStringL(resHandle->Des(),*strings)); |
246 CleanupStack::PushL( message ); |
226 CleanupStack::PushL( message ); |
247 TRACES1("COutOfDiskMonitor::ShowGlobalQueryL: txt: %S",message); |
227 TRACES1("COutOfDiskMonitor::ShowGlobalQueryL: txt: %S",message); |
248 DisplayL(message->Des()); |
228 DisplayL(message->Des()); |
249 |
|
250 TBuf8<2> sdDriveName; |
|
251 sdDriveName.Append(aDrive+'A'); |
|
252 sdDriveName.Append(_L8(":")); |
|
253 CAknSDData* sd = CAknSDData::NewL(KAknSecondaryDisplayCategory, sdDialogId, sdDriveName); |
|
254 iQuery->SetSecondaryDisplayData(sd); |
|
255 |
229 |
256 iNoteInfo.iStatus = aStatus; |
230 iNoteInfo.iStatus = aStatus; |
257 iNoteInfo.iDrive = aDrive; |
231 iNoteInfo.iDrive = aDrive; |
258 CleanupStack::PopAndDestroy(message); |
232 CleanupStack::PopAndDestroy(message); |
259 CleanupStack::PopAndDestroy(resHandle); |
233 CleanupStack::PopAndDestroy(resHandle); |
308 TRACES("COutOfDiskGlobalNote::FormatStringL: End"); |
282 TRACES("COutOfDiskGlobalNote::FormatStringL: End"); |
309 return retbuf; |
283 return retbuf; |
310 } |
284 } |
311 |
285 |
312 // ----------------------------------------------------------------------------- |
286 // ----------------------------------------------------------------------------- |
313 // COutOfDiskGlobalNote::DoCancel |
287 // COutOfDiskGlobalNote::MessageBoxClosed |
314 // ----------------------------------------------------------------------------- |
288 // ----------------------------------------------------------------------------- |
315 // |
289 // |
316 void COutOfDiskGlobalNote::DoCancel() |
290 void COutOfDiskGlobalNote::MessageBoxClosed(const CHbDeviceMessageBoxSymbian* aMessageBox, |
317 { |
291 CHbDeviceMessageBoxSymbian::TButtonId aButton) |
318 TRACES("COutOfDiskGlobalNote::DoCancel"); |
292 { |
319 } |
293 TRACES("COutOfDiskGlobalNote::closed"); |
320 |
|
321 // ----------------------------------------------------------------------------- |
|
322 // COutOfDiskGlobalNote::RunL |
|
323 // ----------------------------------------------------------------------------- |
|
324 // |
|
325 void COutOfDiskGlobalNote::RunL() |
|
326 { |
|
327 TRACES("COutOfDiskGlobalNote::RunL"); |
|
328 iNoteInfo.iNoteId = KErrNotFound; |
294 iNoteInfo.iNoteId = KErrNotFound; |
329 iNoteInfo.iStatus = DISK_SPACE_OK; |
295 iNoteInfo.iStatus = DISK_SPACE_OK; |
330 iNoteInfo.iDrive = KErrNotFound; |
296 iNoteInfo.iDrive = KErrNotFound; |
331 |
297 |
332 TInt drive = iOutOfDiskMonitor->GetTopPriorityDrive(); |
298 TInt drive = iOutOfDiskMonitor->GetTopPriorityDrive(); |
336 } |
302 } |
337 |
303 |
338 TRACES("COutOfDiskGlobalNote::RunL: End"); |
304 TRACES("COutOfDiskGlobalNote::RunL: End"); |
339 } |
305 } |
340 |
306 |
341 // ----------------------------------------------------------------------------- |
|
342 // COutOfDiskGlobalNote::CancelNoteL |
|
343 // ----------------------------------------------------------------------------- |
|
344 // |
|
345 void COutOfDiskGlobalNote::CancelNoteL() |
|
346 { |
|
347 TRACES("COutOfDiskGlobalNote::CancelNoteL"); |
|
348 |
|
349 if (iNoteInfo.iNoteId > KErrNotFound) |
|
350 { |
|
351 iQuery->CancelNoteL(iNoteInfo.iNoteId); |
|
352 } |
|
353 Cancel(); |
|
354 TRACES("COutOfDiskGlobalNote::CancelNoteL: End"); |
|
355 } |
|
356 |
307 |
357 // ----------------------------------------------------------------------------- |
308 // ----------------------------------------------------------------------------- |
358 // COutOfDiskGlobalNote::NoteOnDisplay |
309 // COutOfDiskGlobalNote::NoteOnDisplay |
359 // ----------------------------------------------------------------------------- |
310 // ----------------------------------------------------------------------------- |
360 // |
311 // |