sysresmonitoring/oodmonitor/oodmonitor2/src/outofdiskglobalnote.cpp
changeset 21 c4cbaa4fb734
parent 0 2e3d3ce01487
child 29 6a787171e1de
equal deleted inserted replaced
0:2e3d3ce01487 21:c4cbaa4fb734
     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     Cancel(); // Cancel active object    
    66     TRACES("COutOfDiskGlobalNote::~COutOfDiskGlobalNote: End");
    61     TRACES("COutOfDiskGlobalNote::~COutOfDiskGlobalNote: End");
    67     }
    62     }
    68 
    63 
   108 // ---------------------------------------------------------
   103 // ---------------------------------------------------------
   109 //
   104 //
   110 void COutOfDiskGlobalNote::DisplayL(const TDesC& aMessage)
   105 void COutOfDiskGlobalNote::DisplayL(const TDesC& aMessage)
   111     {
   106     {
   112     TRACES("COutOfDiskGlobalNote::DisplayL");
   107     TRACES("COutOfDiskGlobalNote::DisplayL");
   113     if (iNoteInfo.iNoteId > KErrNotFound)
   108        
   114         {
   109      TRACES("COutOfDiskGlobalNote::COutOfDiskGlobalNote::DisplayL: Create iQuery");        
   115         CancelNoteL();
   110      CHbDeviceMessageBoxSymbian* globalNote = CHbDeviceMessageBoxSymbian::NewL(CHbDeviceMessageBoxSymbian::EWarning);
   116         }
   111      CleanupStack::PushL(globalNote);
   117     
   112      globalNote->SetTextL(aMessage);
   118     if (!iQuery)
   113      globalNote->SetTimeoutL(0);
   119         {
   114      globalNote->ExecL();
   120         TRACES("COutOfDiskGlobalNote::COutOfDiskGlobalNote::DisplayL: Create iQuery");        
   115      CleanupStack::PopAndDestroy(globalNote);
   121         iQuery = CAknGlobalNote::NewL();
   116      
   122         iQuery->SetSoftkeys(R_AVKON_SOFTKEYS_OK_EMPTY);
       
   123         }
       
   124     iNoteInfo.iNoteId = iQuery->ShowNoteL(iStatus, EAknGlobalWarningNote, aMessage);
       
   125     SetActive();
       
   126     TRACES("COutOfDiskGlobalNote::DisplayL: End");
   117     TRACES("COutOfDiskGlobalNote::DisplayL: End");
   127     }
   118     }
   128 
   119 
   129 // ---------------------------------------------------------
   120 // ---------------------------------------------------------
   130 // Use a global query to display the message but make sure that eiksrv is
   121 // Use a global query to display the message but make sure that eiksrv is
   141         return;    
   132         return;    
   142         }
   133         }
   143 
   134 
   144     if (iOutOfDiskMonitor->GetGlobalNotesAllowed())
   135     if (iOutOfDiskMonitor->GetGlobalNotesAllowed())
   145         {
   136         {
   146         TInt sdDialogId = 0;
   137     
   147 
       
   148         TResourceReader resReader;
   138         TResourceReader resReader;
   149         HBufC8* str(NULL);
   139         HBufC8* str(NULL);
   150         CDesCArray* strings = new ( ELeave ) CDesCArrayFlat( 2 );
   140         CDesCArray* strings = new ( ELeave ) CDesCArrayFlat( 2 );
   151         CleanupStack::PushL( strings );
   141         CleanupStack::PushL( strings );
   152 
   142 
   167             {
   157             {
   168             TRACES1("COutOfDiskGlobalNote::ShowGlobalQueryL: Warning note! Drive: %c", aDrive+'A');
   158             TRACES1("COutOfDiskGlobalNote::ShowGlobalQueryL: Warning note! Drive: %c", aDrive+'A');
   169             
   159             
   170             if (aDrive == iOutOfDiskMonitor->GetDefaultPhoneMemory())
   160             if (aDrive == iOutOfDiskMonitor->GetDefaultPhoneMemory())
   171                 {
   161                 {
   172                 sdDialogId = EAknDiskWarnignNote;
       
   173                 str = iOODResourceFile.AllocReadLC(R_QTN_MEMLO_DEVICE_MEMORY_LOW);
   162                 str = iOODResourceFile.AllocReadLC(R_QTN_MEMLO_DEVICE_MEMORY_LOW);
   174                 resReader.SetBuffer(str);    
   163                 resReader.SetBuffer(str);    
   175                 strings->AppendL( driveName );
   164                 strings->AppendL( driveName );
   176                 }
   165                 }
   177             else if (driveStatus & DriveInfo::EDriveRemovable)
   166             else if (driveStatus & DriveInfo::EDriveRemovable)
   178                 {
   167                 {
   179                 TRACES1("COutOfDiskGlobalNote::ShowGlobalQueryL: Warning note! volNameLength: %d", nameLength);
   168                 TRACES1("COutOfDiskGlobalNote::ShowGlobalQueryL: Warning note! volNameLength: %d", nameLength);
   180                 sdDialogId = EAknMMCWarningNote;
       
   181                 TBufC<KMaxFileName> name(volInfo.iName);
   169                 TBufC<KMaxFileName> name(volInfo.iName);
   182                 if (nameLength)
   170                 if (nameLength)
   183                     {
   171                     {
   184         	        str = iOODResourceFile.AllocReadLC(R_QTN_MEMLO_MEMORY_CARD_LOW_NAME);
   172         	        str = iOODResourceFile.AllocReadLC(R_QTN_MEMLO_MEMORY_CARD_LOW_NAME);
   185     	            resReader.SetBuffer(str);    
   173     	            resReader.SetBuffer(str);    
   194 		            strings->AppendL( driveName );
   182 		            strings->AppendL( driveName );
   195                     }
   183                     }
   196                 }
   184                 }
   197             else
   185             else
   198                 {
   186                 {
   199                 sdDialogId = EAknDiskWarnignNote;
       
   200                 str = iOODResourceFile.AllocReadLC(R_QTN_MEMLO_MASS_STORAGE_MEMORY_LOW);
   187                 str = iOODResourceFile.AllocReadLC(R_QTN_MEMLO_MASS_STORAGE_MEMORY_LOW);
   201                 resReader.SetBuffer(str);    
   188                 resReader.SetBuffer(str);    
   202                 strings->AppendL( driveName );                
   189                 strings->AppendL( driveName );                
   203                 }
   190                 }
   204             }
   191             }
   205         else if (aStatus==DISK_SPACE_CRITICAL)
   192         else if (aStatus==DISK_SPACE_CRITICAL)
   206             {
   193             {
   207             TRACES1("COutOfDiskGlobalNote::ShowGlobalQueryL: Critical note! Drive: %c", aDrive+'A');
   194             TRACES1("COutOfDiskGlobalNote::ShowGlobalQueryL: Critical note! Drive: %c", aDrive+'A');
   208             if (aDrive == iOutOfDiskMonitor->GetDefaultPhoneMemory())
   195             if (aDrive == iOutOfDiskMonitor->GetDefaultPhoneMemory())
   209                 {
   196                 {
   210                 sdDialogId = EAknDiskFullNote;
       
   211                 str = iOODResourceFile.AllocReadLC(R_QTN_MEMLO_DEVICE_MEMORY_FULL);
   197                 str = iOODResourceFile.AllocReadLC(R_QTN_MEMLO_DEVICE_MEMORY_FULL);
   212                 resReader.SetBuffer(str);    
   198                 resReader.SetBuffer(str);    
   213                 strings->AppendL( driveName );                
   199                 strings->AppendL( driveName );                
   214                 }                
   200                 }                
   215             else if (driveStatus & DriveInfo::EDriveRemovable)
   201             else if (driveStatus & DriveInfo::EDriveRemovable)
   216                 {
   202                 {
   217                 sdDialogId = EAknMMCFullNote;
       
   218                 TBufC<KMaxFileName> name(volInfo.iName);
   203                 TBufC<KMaxFileName> name(volInfo.iName);
   219                 if (nameLength)
   204                 if (nameLength)
   220                     {
   205                     {
   221         	        str = iOODResourceFile.AllocReadLC(R_QTN_MEMLO_MEMORY_CARD_FULL_NAME);
   206         	        str = iOODResourceFile.AllocReadLC(R_QTN_MEMLO_MEMORY_CARD_FULL_NAME);
   222     	            resReader.SetBuffer(str);    
   207     	            resReader.SetBuffer(str);    
   231 		            strings->AppendL( driveName );
   216 		            strings->AppendL( driveName );
   232                     }                    
   217                     }                    
   233                 }
   218                 }
   234             else
   219             else
   235                 {
   220                 {
   236                 sdDialogId = EAknDiskFullNote;
       
   237                 str = iOODResourceFile.AllocReadLC(R_QTN_MEMLO_MASS_STORAGE_FULL);
   221                 str = iOODResourceFile.AllocReadLC(R_QTN_MEMLO_MASS_STORAGE_FULL);
   238                 resReader.SetBuffer(str);
   222                 resReader.SetBuffer(str);
   239                 strings->AppendL( driveName );                
   223                 strings->AppendL( driveName );                
   240                 }
   224                 }
   241             }
   225             }
   242         resReader.SetBuffer(str);
   226         resReader.SetBuffer(str);
   243 	    HBufC* message( FormatStringL(resReader.ReadHBufCL()->Des(), *strings));
   227 	      HBufC* resHandle = resReader.ReadHBufCL();
   244 	    TRACES1("COutOfDiskMonitor::ShowGlobalQueryL: txt: %S",message);
   228         CleanupStack::PushL( resHandle );
       
   229         HBufC* message(FormatStringL(resHandle->Des(),*strings));
       
   230         CleanupStack::PushL( message );
       
   231 	      TRACES1("COutOfDiskMonitor::ShowGlobalQueryL: txt: %S",message);
   245         DisplayL(message->Des());
   232         DisplayL(message->Des());
   246 
       
   247 		TBuf8<2> sdDriveName;
       
   248 		sdDriveName.Append(aDrive+'A');
       
   249 		sdDriveName.Append(_L8(":"));	
       
   250         CAknSDData* sd = CAknSDData::NewL(KAknSecondaryDisplayCategory, sdDialogId, sdDriveName);
       
   251         iQuery->SetSecondaryDisplayData(sd);     
       
   252 
   233 
   253         iNoteInfo.iStatus = aStatus;
   234         iNoteInfo.iStatus = aStatus;
   254         iNoteInfo.iDrive = aDrive;        
   235         iNoteInfo.iDrive = aDrive;        
       
   236         CleanupStack::PopAndDestroy(message);
       
   237         CleanupStack::PopAndDestroy(resHandle);
   255         CleanupStack::PopAndDestroy( str );
   238         CleanupStack::PopAndDestroy( str );
   256         CleanupStack::PopAndDestroy( strings );
   239         CleanupStack::PopAndDestroy( strings ); 
   257         iOutOfDiskMonitor->SetAsDisplayedL(aDrive, aStatus);
   240         iOutOfDiskMonitor->SetAsDisplayedL(aDrive, aStatus);
   258         }
   241         }
   259     TRACES("COutOfDiskGlobalNote::ShowGlobalQueryL: End");
   242     TRACES("COutOfDiskGlobalNote::ShowGlobalQueryL: End");
   260     }
   243     }
   261 
   244 
   339 //
   322 //
   340 void COutOfDiskGlobalNote::CancelNoteL()
   323 void COutOfDiskGlobalNote::CancelNoteL()
   341     {
   324     {
   342     TRACES("COutOfDiskGlobalNote::CancelNoteL");
   325     TRACES("COutOfDiskGlobalNote::CancelNoteL");
   343     
   326     
   344     if (iNoteInfo.iNoteId > KErrNotFound)
       
   345         {    
       
   346         iQuery->CancelNoteL(iNoteInfo.iNoteId);
       
   347         }
       
   348     Cancel();
   327     Cancel();
   349     TRACES("COutOfDiskGlobalNote::CancelNoteL: End");    
   328     TRACES("COutOfDiskGlobalNote::CancelNoteL: End");    
   350     }    
   329     }    
   351 
   330 
   352 // -----------------------------------------------------------------------------
   331 // -----------------------------------------------------------------------------