| Start/ | End/ | |||
| True | False | - | Line | Source |
| 1 | /* | |||
| 2 | * Copyright (c) 2007-2010 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 | * | |||
| 16 | */ | |||
| 17 | ||||
| 18 | ||||
| 19 | // SYSTEM INCLUDES | |||
| 20 | #include <e32property.h> | |||
| 21 | #include <data_caging_path_literals.hrh> | |||
| 22 | #include <driveinfo.h> | |||
| 23 | #include <outofdiskmonitor.rsg> | |||
| 24 | #include <bautils.h> // BaflUtils | |||
| 25 | #include <StringLoader.h> | |||
| 26 | ||||
| 27 | ||||
| 28 | // USER INCLUDES | |||
| 29 | #include "UiklafInternalCRKeys.h" | |||
| 30 | #include "OodTraces.h" | |||
| 31 | #include "outofdiskglobalnote.h" | |||
| 32 | #include "outofdiskmonitor.h" | |||
| 33 | ||||
| 34 | // CONSTANTS | |||
| 35 | _LIT(KOODWatcherResourceFileName, "outofdiskmonitor.rsc"); | |||
| 36 | // --------------------------------------------------------- | |||
| 37 | // | |||
| 38 | // --------------------------------------------------------- | |||
| 39 | // | |||
| Top | ||||
| 1 | 0 | 40 | COutOfDiskGlobalNote* COutOfDiskGlobalNote::NewL | |
| 41 | ( COutOfDiskMonitor* aOutOfDiskMonitor, RFs& aFs ) | |||
| 42 | { | |||
| 43 | TRACES("COutOfDiskGlobalNote::NewL"); | |||
| 44 | COutOfDiskGlobalNote* self = new (ELeave) COutOfDiskGlobalNote( aOutOfDiskMonitor, aFs ); | |||
| 45 | CleanupStack::PushL(self); | |||
| 46 | self->ConstructL(); | |||
| 47 | CleanupStack::Pop(self); | |||
| 48 | TRACES("COutOfDiskGlobalNote::NewL: End"); | |||
| 49 | return self; | |||
| 50 | } | |||
| 51 | ||||
| 52 | // --------------------------------------------------------- | |||
| 53 | // | |||
| 54 | // --------------------------------------------------------- | |||
| 55 | // | |||
| Top | ||||
| 1 | 1 | 56 | COutOfDiskGlobalNote::~COutOfDiskGlobalNote() | |
| 57 | { | |||
| 58 | TRACES("COutOfDiskGlobalNote::~COutOfDiskGlobalNote"); | |||
| 59 | iOODResourceFile.Close(); | |||
| 60 | delete iNote; | |||
| 61 | iNote=NULL; | |||
| 62 | } | |||
| 63 | ||||
| 64 | // --------------------------------------------------------- | |||
| 65 | // | |||
| 66 | // --------------------------------------------------------- | |||
| 67 | // | |||
| Top | ||||
| 1 | 1 | 68 | COutOfDiskGlobalNote::COutOfDiskGlobalNote( COutOfDiskMonitor* aOutOfDiskMonitor, RFs& aFs ) : | |
| 69 | iOutOfDiskMonitor( aOutOfDiskMonitor ), | |||
| 70 | iFs( aFs ) | |||
| 71 | { | |||
| 72 | TRACES("COutOfDiskGlobalNote::COutOfDiskGlobalNote"); | |||
| 73 | TRACES("COutOfDiskGlobalNote::COutOfDiskGlobalNote: End"); | |||
| 74 | } | |||
| 75 | ||||
| 76 | // --------------------------------------------------------- | |||
| 77 | // | |||
| 78 | // --------------------------------------------------------- | |||
| 79 | // | |||
| Top | ||||
| 1 | 1 | 80 | void COutOfDiskGlobalNote::ConstructL() | |
| 81 | { | |||
| 82 | TRACES("COutOfDiskGlobalNote::ConstructL"); | |||
| 83 | iNoteInfo.iNoteId = KErrNotFound; | |||
| 84 | iNoteInfo.iStatus = DISK_SPACE_OK; | |||
| 85 | iNoteInfo.iDrive = KErrNotFound; | |||
| 86 | iNote= CHbDeviceMessageBoxSymbian::NewL(CHbDeviceMessageBoxSymbian::EWarning); | |||
| 87 | TRACES("COutOfDiskGlobalNote::ConstructL: Open OOD resource file"); | |||
| 88 | TFileName OODFileName; | |||
| 89 | OODFileName.Append(_L("Z")); | |||
| 90 | OODFileName.Append(_L(":")); | |||
| 91 | OODFileName.Append(KDC_RESOURCE_FILES_DIR); | |||
| 92 | OODFileName.Append(KOODWatcherResourceFileName); | |||
| 93 | BaflUtils::NearestLanguageFile(iFs, OODFileName); | |||
| 94 | iOODResourceFile.OpenL(iFs, OODFileName); | |||
| 95 | TRACES1("COutOfDiskGlobalNote::ConstructL: Opened %S",&OODFileName); | |||
| 96 | TRACES("COutOfDiskGlobalNote::ConstructL: End"); | |||
| 97 | } | |||
| 98 | ||||
| 99 | // --------------------------------------------------------- | |||
| 100 | // | |||
| 101 | // --------------------------------------------------------- | |||
| 102 | // | |||
| Top | ||||
| 0 | 0 | - | 103 | void COutOfDiskGlobalNote::DisplayL(const TDesC& aMessage) |
| 104 | { | |||
| 105 | TRACES("COutOfDiskGlobalNote::DisplayL"); | |||
| 106 | ||||
| 107 | TRACES("COutOfDiskGlobalNote::COutOfDiskGlobalNote::DisplayL: set text and observer for the note"); | |||
| 108 | iNote->SetTextL(aMessage); | |||
| 109 | iNote->SetObserver(this); | |||
| 110 | iNote->SetTimeout(0); | |||
| 111 | iNote->ShowL(); | |||
| 112 | ||||
| 113 | TRACES("COutOfDiskGlobalNote::DisplayL: End"); | |||
| 114 | } | |||
| 115 | ||||
| 116 | // --------------------------------------------------------- | |||
| 117 | // Use a global query to display the message but make sure that eiksrv is | |||
| 118 | // there (state must not be initialising (AVKON + UIKON) | |||
| 119 | // --------------------------------------------------------- | |||
| 120 | // | |||
| Top | ||||
| 0 | 0 | - | 121 | void COutOfDiskGlobalNote::ShowGlobalQueryL(TInt aStatus, TInt aDrive) |
| 122 | { | |||
| 123 | TRACES("COutOfDiskGlobalNote::ShowGlobalQueryL"); | |||
| 124 | ||||
| 125 | if (NoteOnDisplay()) | |||
| 126 | { | |||
| 127 | TRACES("COutOfDiskGlobalNote::ShowGlobalQueryL: Note already on display"); | |||
| 128 | return; | |||
| 129 | } | |||
| 130 | ||||
| 131 | if (iOutOfDiskMonitor->GetGlobalNotesAllowed()) | |||
| 132 | { | |||
| 133 | ||||
| 134 | TResourceReader resReader; | |||
| 135 | HBufC8* str(NULL); | |||
| 136 | CDesCArray* strings = new ( ELeave ) CDesCArrayFlat( 2 ); | |||
| 137 | CleanupStack::PushL( strings ); | |||
| 138 | ||||
| 139 | TDriveName driveName; | |||
| 140 | TChar driveChar; | |||
| 141 | User::LeaveIfError( iFs.DriveToChar( aDrive, driveChar ) ); | |||
| 142 | driveName.Append(driveChar); | |||
| 143 | driveName.Append(_L(":")); | |||
| 144 | ||||
| 145 | TVolumeInfo volInfo; | |||
| 146 | iFs.Volume( volInfo, aDrive ); | |||
| 147 | TInt nameLength(volInfo.iName.Length()); | |||
| 148 | ||||
| 149 | TUint driveStatus(0); | |||
| 150 | DriveInfo::GetDriveStatus( iFs, aDrive, driveStatus ); | |||
| 151 | ||||
| 152 | if (aStatus==DISK_SPACE_WARNING) | |||
| 153 | { | |||
| 154 | TRACES1("COutOfDiskGlobalNote::ShowGlobalQueryL: Warning note! Drive: %c", aDrive+'A'); | |||
| 155 | ||||
| 156 | if (aDrive == iOutOfDiskMonitor->GetDefaultPhoneMemory()) | |||
| 157 | { | |||
| 158 | str = iOODResourceFile.AllocReadLC(R_QTN_MEMLO_DEVICE_MEMORY_LOW); | |||
| 159 | resReader.SetBuffer(str); | |||
| 160 | strings->AppendL( driveName ); | |||
| 161 | } | |||
| 162 | else if (driveStatus & DriveInfo::EDriveRemovable) | |||
| 163 | { | |||
| 164 | TRACES1("COutOfDiskGlobalNote::ShowGlobalQueryL: Warning note! volNameLength: %d", nameLength); | |||
| 165 | TBufC<KMaxFileName> name(volInfo.iName); | |||
| 166 | if (nameLength) | |||
| 167 | { | |||
| 168 | str = iOODResourceFile.AllocReadLC(R_QTN_MEMLO_MEMORY_CARD_LOW_NAME); | |||
| 169 | resReader.SetBuffer(str); | |||
| 170 | strings->AppendL( driveName ); | |||
| 171 | strings->AppendL( name ); | |||
| 172 | } | |||
| 173 | else | |||
| 174 | { | |||
| 175 | str = iOODResourceFile.AllocReadLC | |||
| 176 | (R_QTN_MEMLO_MEMORY_CARD_LOW_DEFAULTNAME); | |||
| 177 | resReader.SetBuffer(str); | |||
| 178 | strings->AppendL( driveName ); | |||
| 179 | } | |||
| 180 | } | |||
| 181 | else | |||
| 182 | { | |||
| 183 | str = iOODResourceFile.AllocReadLC(R_QTN_MEMLO_MASS_STORAGE_MEMORY_LOW); | |||
| 184 | resReader.SetBuffer(str); | |||
| 185 | strings->AppendL( driveName ); | |||
| 186 | } | |||
| 187 | } | |||
| 188 | else if (aStatus==DISK_SPACE_CRITICAL) | |||
| 189 | { | |||
| 190 | TRACES1("COutOfDiskGlobalNote::ShowGlobalQueryL: Critical note! Drive: %c", aDrive+'A'); | |||
| 191 | if (aDrive == iOutOfDiskMonitor->GetDefaultPhoneMemory()) | |||
| 192 | { | |||
| 193 | str = iOODResourceFile.AllocReadLC(R_QTN_MEMLO_DEVICE_MEMORY_FULL); | |||
| 194 | resReader.SetBuffer(str); | |||
| 195 | strings->AppendL( driveName ); | |||
| 196 | } | |||
| 197 | else if (driveStatus & DriveInfo::EDriveRemovable) | |||
| 198 | { | |||
| 199 | TBufC<KMaxFileName> name(volInfo.iName); | |||
| 200 | if (nameLength) | |||
| 201 | { | |||
| 202 | str = iOODResourceFile.AllocReadLC(R_QTN_MEMLO_MEMORY_CARD_FULL_NAME); | |||
| 203 | resReader.SetBuffer(str); | |||
| 204 | strings->AppendL( driveName ); | |||
| 205 | strings->AppendL( name ); | |||
| 206 | } | |||
| 207 | else | |||
| 208 | { | |||
| 209 | str = iOODResourceFile.AllocReadLC | |||
| 210 | (R_QTN_MEMLO_MEMORY_CARD_FULL_DEFAULTNAME); | |||
| 211 | resReader.SetBuffer(str); | |||
| 212 | strings->AppendL( driveName ); | |||
| 213 | } | |||
| 214 | } | |||
| 215 | else | |||
| 216 | { | |||
| 217 | str = iOODResourceFile.AllocReadLC(R_QTN_MEMLO_MASS_STORAGE_FULL); | |||
| 218 | resReader.SetBuffer(str); | |||
| 219 | strings->AppendL( driveName ); | |||
| 220 | } | |||
| 221 | } | |||
| 222 | resReader.SetBuffer(str); | |||
| 223 | HBufC* resHandle = resReader.ReadHBufCL(); | |||
| 224 | CleanupStack::PushL( resHandle ); | |||
| 225 | HBufC* message(FormatStringL(resHandle->Des(),*strings)); | |||
| 226 | CleanupStack::PushL( message ); | |||
| 227 | TRACES1("COutOfDiskMonitor::ShowGlobalQueryL: txt: %S",message); | |||
| 228 | DisplayL(message->Des()); | |||
| 229 | ||||
| 230 | iNoteInfo.iStatus = aStatus; | |||
| 231 | iNoteInfo.iDrive = aDrive; | |||
| 232 | CleanupStack::PopAndDestroy(message); | |||
| 233 | CleanupStack::PopAndDestroy(resHandle); | |||
| 234 | CleanupStack::PopAndDestroy( str ); | |||
| 235 | CleanupStack::PopAndDestroy( strings ); | |||
| 236 | iOutOfDiskMonitor->SetAsDisplayedL(aDrive, aStatus); | |||
| 237 | } | |||
| 238 | TRACES("COutOfDiskGlobalNote::ShowGlobalQueryL: End"); | |||
| 239 | } | |||
| 240 | ||||
| 241 | // --------------------------------------------------------------------------- | |||
| 242 | // COutOfDiskGlobalNote::FormatStringL( TDesC& aSource, | |||
| 243 | // const MDesCArray& aStrings, | |||
| 244 | // TInt aParamNumber ) | |||
| 245 | // --------------------------------------------------------------------------- | |||
| 246 | // | |||
| Top | ||||
| 0 | 0 | - | 247 | HBufC* COutOfDiskGlobalNote::FormatStringL( |
| 248 | const TDesC& aSource, | |||
| 249 | const MDesCArray& aStrings) | |||
| 250 | { | |||
| 251 | TRACES1("COutOfDiskGlobalNote::FormatStringL: input: %S",&aSource); | |||
| 252 | ||||
| 253 | TInt count( aStrings.MdcaCount() ); //Number of input strings. | |||
| 254 | TRACES1("COutOfDiskGlobalNote::FormatStringL: Number of parameters: %d",count); | |||
| 255 | ||||
| 256 | TInt length = aSource.Length(); | |||
| 257 | for(TInt i=0; i < count; i++) | |||
| 258 | { | |||
| 259 | length += aStrings.MdcaPoint( i ).Length(); | |||
| 260 | } | |||
| 261 | ||||
| 262 | HBufC* retbuf = HBufC::NewLC( length ); | |||
| 263 | TPtr retptr( retbuf->Des() ); | |||
| 264 | ||||
| 265 | if(count > 1) | |||
| 266 | { | |||
| 267 | HBufC* temp = HBufC::NewLC( length ); | |||
| 268 | *temp = aSource; | |||
| 269 | for(TInt i=0; i < count; i++) | |||
| 270 | { | |||
| 271 | StringLoader::Format( retptr, *temp, i, aStrings.MdcaPoint( i )); | |||
| 272 | *temp = *retbuf; | |||
| 273 | } | |||
| 274 | CleanupStack::PopAndDestroy( temp ); | |||
| 275 | } | |||
| 276 | else | |||
| 277 | { | |||
| 278 | StringLoader::Format( retptr, aSource, -1, aStrings.MdcaPoint( 0 )); | |||
| 279 | } | |||
| 280 | CleanupStack::Pop( retbuf ); | |||
| 281 | ||||
| 282 | TRACES("COutOfDiskGlobalNote::FormatStringL: End"); | |||
| 283 | return retbuf; | |||
| 284 | } | |||
| 285 | ||||
| 286 | // ----------------------------------------------------------------------------- | |||
| 287 | // COutOfDiskGlobalNote::MessageBoxClosed | |||
| 288 | // ----------------------------------------------------------------------------- | |||
| 289 | // | |||
| Top | ||||
| 0 | 0 | - | 290 | void COutOfDiskGlobalNote::MessageBoxClosed(const CHbDeviceMessageBoxSymbian* aMessageBox, |
| 291 | CHbDeviceMessageBoxSymbian::TButtonId aButton) | |||
| 292 | { | |||
| 293 | TRACES("COutOfDiskGlobalNote::closed"); | |||
| 294 | iNoteInfo.iNoteId = KErrNotFound; | |||
| 295 | iNoteInfo.iStatus = DISK_SPACE_OK; | |||
| 296 | iNoteInfo.iDrive = KErrNotFound; | |||
| 297 | ||||
| 298 | TInt drive = iOutOfDiskMonitor->GetTopPriorityDrive(); | |||
| 299 | if (drive != KErrNotFound) | |||
| 300 | { | |||
| 301 | ShowGlobalQueryL(iOutOfDiskMonitor->GetDriveStatus(drive), drive); | |||
| 302 | } | |||
| 303 | ||||
| 304 | TRACES("COutOfDiskGlobalNote::RunL: End"); | |||
| 305 | } | |||
| 306 | ||||
| 307 | ||||
| 308 | // ----------------------------------------------------------------------------- | |||
| 309 | // COutOfDiskGlobalNote::NoteOnDisplay | |||
| 310 | // ----------------------------------------------------------------------------- | |||
| 311 | // | |||
| Top | ||||
| 28 | 0 | 312 | TBool COutOfDiskGlobalNote::NoteOnDisplay() | |
| 313 | { | |||
| 314 | TRACES("COutOfDiskGlobalNote::NoteOnDisplay"); | |||
| 315 | TBool note( EFalse); | |||
| 316 | if (iNoteInfo.iNoteId > KErrNotFound) | |||
| 317 | { | |||
| 318 | note = ETrue; | |||
| 319 | } | |||
| 320 | TRACES1("COutOfDiskGlobalNote::NoteOnDisplay: End: return %d",note); | |||
| 321 | return note; | |||
| 322 | } | |||
| 323 | ||||
| 324 | // ----------------------------------------------------------------------------- | |||
| 325 | // COutOfDiskGlobalNote::GetNoteInfo | |||
| 326 | // ----------------------------------------------------------------------------- | |||
| 327 | // | |||
| Top | ||||
| 28 | 0 | 328 | TNoteInfo COutOfDiskGlobalNote::GetNoteInfo() | |
| 329 | { | |||
| 330 | TRACES("COutOfDiskGlobalNote::GetNoteInfo"); | |||
| 331 | return iNoteInfo; | |||
| 332 | } | |||
| ***TER 60% (6/10) of SOURCE FILE outofdiskglobalnote.cpp | ||||