photosgallery/logging/app/src/glxloggingappui.cpp
changeset 0 4e91876724a2
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     1 /*
       
     2 * Copyright (c) 2008-2009 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:    Logging utility application for MC Photos
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include <avkon.hrh>
       
    22 #include <aknnotewrappers.h> 
       
    23 
       
    24 #include <glxlogger.h>
       
    25 
       
    26 #include "glxlogging.pan"
       
    27 #include "glxloggingappui.h"
       
    28 #include "glxloggingapp.hrh"
       
    29 
       
    30 
       
    31 // Constants
       
    32 namespace
       
    33     {
       
    34 
       
    35 const TInt KLoggingDriveLetterLength = 3;
       
    36 
       
    37 _LIT(KColonBackSlash, ":\\");    
       
    38       
       
    39 #ifdef __WINSCW__
       
    40     // log to the c: drive on the emulator
       
    41     _LIT(KGlxLoggingFolderDrive, "c");
       
    42 #else
       
    43     // log to the root of the removable media card on hardware
       
    44     _LIT(KGlxLoggingFolderDrive, "e");
       
    45 #endif
       
    46     
       
    47     // write logged data to the file every 0.5s
       
    48     const TInt KGlxLoggingIntervalMicroSec = 500000;
       
    49     }
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // ConstructL
       
    53 // -----------------------------------------------------------------------------
       
    54 void CGlxLoggingAppUi::ConstructL()
       
    55     {
       
    56     BaseConstructL();
       
    57 
       
    58     // we dont want to respond to shutdown events
       
    59     iEikonEnv->SetRespondsToShutdownEvent( EFalse );
       
    60     
       
    61     // Log manager
       
    62     iLogManager.CreateL();
       
    63       
       
    64     // Create and start the timer
       
    65     iTimer = CPeriodic::NewL( CActive::EPriorityStandard );
       
    66     iTimer->Start( KGlxLoggingIntervalMicroSec,
       
    67         KGlxLoggingIntervalMicroSec, TCallBack( TimerCallback, this ) );
       
    68     }
       
    69 
       
    70 // -----------------------------------------------------------------------------
       
    71 // CGlxLoggingAppUi
       
    72 // -----------------------------------------------------------------------------
       
    73 CGlxLoggingAppUi::CGlxLoggingAppUi()                              
       
    74     {
       
    75     // delete timer
       
    76     delete iTimer;
       
    77     // release the chunks
       
    78     iLogManager.Release();
       
    79     }
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // ~CGlxLoggingAppUi
       
    83 // -----------------------------------------------------------------------------
       
    84 CGlxLoggingAppUi::~CGlxLoggingAppUi()
       
    85     {
       
    86     // try to write the remainder of the log
       
    87     DoLog();
       
    88     }
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // TimerCallback
       
    92 // -----------------------------------------------------------------------------
       
    93 TInt CGlxLoggingAppUi::TimerCallback( TAny* aParam )
       
    94     {
       
    95     return reinterpret_cast<CGlxLoggingAppUi*>( aParam )->DoLog();
       
    96     }
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // DoLog
       
   100 // -----------------------------------------------------------------------------
       
   101 TInt CGlxLoggingAppUi::DoLog()
       
   102     {
       
   103     // Timer has called back so update the log file with all the entries
       
   104     // that have been written to the chunks in the meantime
       
   105     // just try to write all, nothing to do on leave
       
   106     TBuf<KLoggingDriveLetterLength> driveLetter;
       
   107     driveLetter.Append(KGlxLoggingFolderDrive);
       
   108     driveLetter.Append(KColonBackSlash);
       
   109     TRAP_IGNORE( iLogManager.CommitToFileL( driveLetter ) );
       
   110     return KErrNone;
       
   111     }
       
   112 
       
   113 // -----------------------------------------------------------------------------
       
   114 // HandleCommandL. handle any menu commands
       
   115 // -----------------------------------------------------------------------------
       
   116 void CGlxLoggingAppUi::HandleCommandL(TInt aCommand)
       
   117     {
       
   118     switch(aCommand)
       
   119         {
       
   120         case EEikCmdExit:
       
   121         case EAknSoftkeyExit:
       
   122             Exit();
       
   123             break;
       
   124         default:
       
   125             Panic(EGlxLoggingBasicUi);
       
   126             break;
       
   127         }
       
   128     }
       
   129 
       
   130 
       
   131