commonutilities/common/src/glxtnmonitor.cpp
changeset 33 1ee2af37811f
child 36 6481344a6d67
equal deleted inserted replaced
29:2c833fc9e98f 33:1ee2af37811f
       
     1 /*
       
     2 * Copyright (c) 2006-2007 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 #include "glxtnmonitor.h"
       
    20 #include <glxlog.h>
       
    21 
       
    22 //#include <ScreenSaverInternalPSKeys.h>
       
    23 #include <e32debug.h>
       
    24 
       
    25 const TUid KTAGDPSNotification = { 0x2001FD51 };
       
    26 //const TInt KForceBackgroundGeneration = 0x00000010;
       
    27 const TInt KItemsleft = 0x00000008;
       
    28 
       
    29 CGlxTNMonitor::CGlxTNMonitor( MGlxTNObserver *observer )
       
    30 : CActive( CActive::EPriorityHigh ),
       
    31   iObserver( observer )
       
    32 {    
       
    33 }
       
    34 
       
    35 // ---------------------------------------------------------------------------
       
    36 // ~CGlxPauseMonitor.
       
    37 // Destructor.
       
    38 // ---------------------------------------------------------------------------
       
    39 //
       
    40 CGlxTNMonitor::~CGlxTNMonitor()
       
    41 {
       
    42 	Cancel();
       
    43 	iScreenSaverProperty.Close();
       
    44 }
       
    45 
       
    46 // ---------------------------------------------------------------------------
       
    47 // NewL
       
    48 // ---------------------------------------------------------------------------
       
    49 //
       
    50 EXPORT_C CGlxTNMonitor* CGlxTNMonitor::NewL( MGlxTNObserver *observer  )
       
    51 {
       
    52     //GLX_LOG_ENTRY_EXIT("CGlxTNMonitor::NewL");    
       
    53     CGlxTNMonitor* self = new (ELeave) CGlxTNMonitor( observer );
       
    54     CleanupStack::PushL( self );
       
    55     self->ConstructL();
       
    56     CleanupStack::Pop( self );
       
    57     return self;
       
    58 }
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 // ConstructL.
       
    62 // Second-phase constructor.
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 void CGlxTNMonitor::ConstructL()
       
    66 {
       
    67     iScreenSaverProperty.Attach( KTAGDPSNotification, KItemsleft );
       
    68 	CActiveScheduler::Add( this );
       
    69     RunL();
       
    70 }
       
    71 
       
    72 void CGlxTNMonitor::RunL()
       
    73 {	
       
    74 	GLX_LOG_ENTRY_EXIT("CGlxTNMonitor::RunL");    
       
    75     // resubscribe before processing new value to prevent missing updates
       
    76 	iScreenSaverProperty.Subscribe( iStatus );
       
    77     SetActive();
       
    78 	//User::WaitForRequest(iStatus);
       
    79     TInt intValue;
       
    80 	TInt err = iScreenSaverProperty.Get( intValue ) ;
       
    81 	if ( err != KErrNotFound ){
       
    82 	    iObserver->updateTNCount( intValue );
       
    83 	}
       
    84 }
       
    85     
       
    86 // ---------------------------------------------------------------------------
       
    87 // DoCancel
       
    88 // ---------------------------------------------------------------------------
       
    89 //
       
    90 void CGlxTNMonitor::DoCancel()
       
    91 {
       
    92 	iScreenSaverProperty.Cancel();
       
    93 }
       
    94 
       
    95 // ---------------------------------------------------------------------------
       
    96 // RunError
       
    97 // ---------------------------------------------------------------------------
       
    98 //
       
    99 TInt CGlxTNMonitor::RunError( TInt )
       
   100 {
       
   101     GLX_LOG_ENTRY_EXIT("CGlxTNMonitor::RunError");       
       
   102     return KErrNone;
       
   103 }
       
   104 
       
   105